Skip to main content

Shared command, observation, event, error, and config contracts for app-control tools.

Project description

app-control-protocol

Shared protocol models for app-control tools.

This package defines the stable public contract used by computer-use-macos, wechat-desktop-tool, and third-party callers:

  • ToolCommand
  • ToolObservation
  • ToolEvent
  • ToolError
  • ServiceRequest
  • ServiceResponse
  • ServiceEventEnvelope
  • AppControlClient
  • AppControlConfig
  • LoggingToolObserver
  • packaged JSON Schema files for command, observation, event, error, and local service envelopes

It has no runtime dependencies and does not import product-specific modules, LLM SDKs, UI frameworks, or app-control backend implementations.

Observation status values are stable: ok, not_found, not_ready, permission_missing, timeout, failed, and unknown.

Example

from app_control_protocol import ToolCommand

command = ToolCommand(
    command_id="cmd_1",
    tool="macos.computer_use",
    operation="open_app",
    input={"app": "TextEdit"},
    timeout_ms=10_000,
)

payload = command.to_dict()
round_tripped = ToolCommand.from_dict(payload)
assert round_tripped == command

JSON Schemas

Schema assets are included in the wheel for non-Python callers:

app_control_protocol/schemas/command.schema.json
app_control_protocol/schemas/observation.schema.json
app_control_protocol/schemas/event.schema.json
app_control_protocol/schemas/error.schema.json
app_control_protocol/schemas/service-request.schema.json
app_control_protocol/schemas/service-response.schema.json
app_control_protocol/schemas/service-event.schema.json
app_control_protocol/schemas/helper-request.schema.json
app_control_protocol/schemas/helper-response.schema.json

Python callers can load the same packaged files:

from app_control_protocol import ProtocolValidationError, load_protocol_schema
from app_control_protocol import validate_protocol_payload

command_schema = load_protocol_schema("command")

try:
    validate_protocol_payload("command", payload)
except ProtocolValidationError as exc:
    print(exc)

Client Protocol

from app_control_protocol import AppControlClient

def use_client(client: AppControlClient) -> None:
    observation = client.run_command(command)
    print(observation.to_dict())

AppControlClient, StreamingAppControlClient, and ToolObserver are runtime_checkable protocols, so integrations can do a lightweight structural check before wiring tools together:

from app_control_protocol import AppControlClient

if not isinstance(client, AppControlClient):
    raise TypeError("app-control client must expose run_command(...)")

This checks the presence of protocol methods. Payload correctness is still validated with validate_protocol_payload(...).

Errors

Failed observations can embed a complete ToolError while keeping top-level failure fields for simpler callers:

from app_control_protocol import ToolError, ToolObservation

error = ToolError(
    failure_kind="not_ready",
    message="Helper is not running.",
    retryable=True,
    phase="readiness",
    operation="readiness",
)

failure = ToolObservation.failure(
    command_id="cmd_1",
    tool="macos.computer_use",
    operation="readiness",
    status="not_ready",
    error=error,
)

Local Service Envelopes

Use the service envelope models when submitting commands to a local computer-use-macos service:

from app_control_protocol import ServiceRequest, ToolCommand

command = ToolCommand(
    command_id="cmd_1",
    tool="macos.computer_use",
    operation="readiness",
)

request_payload = ServiceRequest.run(command, token="local-token").to_dict()
poll_payload = ServiceRequest.poll("req_1").to_dict()

Event Logging

from app_control_protocol import build_logging_observer

observer = build_logging_observer()
client.run_command(command, observer=observer)

Configuration

The repository includes a complete editable template at examples/app-control.toml.

[logging]
level = "info"
redact_text = true

[computer_use]
backend = "direct"
allowed_apps = ["TextEdit", "WeChat"]

[computer_use.allowed_app_bundle_ids]
TextEdit = "com.apple.TextEdit"
WeChat = "com.tencent.xinWeChat"

[wechat]
app_name = "WeChat"
bundle_id = "com.tencent.xinWeChat"
app_control_tool = "macos.computer_use"
search_hotkey = ["Command", "K"]
search_clear_hotkey = ["Command", "A"]
clear_key = "Delete"
submit_key = "Return"
max_message_chars = 2000
default_timeout_ms = 30000

Smoke tests and CI can override runtime values with environment variables such as APP_CONTROL_COMPUTER_USE_BACKEND, APP_CONTROL_COMPUTER_USE_ALLOWED_APPS, APP_CONTROL_COMPUTER_USE_ALLOWED_APP_BUNDLE_IDS, APP_CONTROL_HELPER_ENDPOINT, APP_CONTROL_HELPER_TOKEN, APP_CONTROL_WECHAT_BUNDLE_ID, APP_CONTROL_WECHAT_MAX_MESSAGE_CHARS, and APP_CONTROL_WECHAT_DEFAULT_TIMEOUT_MS.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

app_control_protocol-0.1.1.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

app_control_protocol-0.1.1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file app_control_protocol-0.1.1.tar.gz.

File metadata

  • Download URL: app_control_protocol-0.1.1.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for app_control_protocol-0.1.1.tar.gz
Algorithm Hash digest
SHA256 745d87ad3a2a588d1d81e52a2a09430cade7edfec0789f6f68f373155e6bf922
MD5 f2f8adb422773aa0aca1d2d2ee957f5f
BLAKE2b-256 38ee2f335a4789838a512cc9a2dd721867c14d9bf16c0a29ac9735c376b8e7c1

See more details on using hashes here.

File details

Details for the file app_control_protocol-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for app_control_protocol-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3fd86f36364147abf131246f255fac96359a838bf9d18ad0e8e0039434a4ad
MD5 c9ab0a20f9a8473740a2cd0038cb9de3
BLAKE2b-256 398a992d010602169dee08152b93827cdd1f6adbbea2e68725d83fad3c0ed17f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page