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", "F"]
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.0.tar.gz (26.2 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.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: app_control_protocol-0.1.0.tar.gz
  • Upload date:
  • Size: 26.2 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.0.tar.gz
Algorithm Hash digest
SHA256 126cf74b101023aa94b700522bcfa7b9f0752db627963133546ea54e7ef0850a
MD5 696dbedeeed27ffed349feffc209bc8f
BLAKE2b-256 6888f0ce3c1909496ba3eb9f80bb9b97fefff0be1f8e9a91ce4e164bd04fab02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for app_control_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d483da3361d06fbc73029d24221f3711ec2d998bb5ddce1c55fde743e89ec76d
MD5 039364d0c135b3f9081484a8ca6a0350
BLAKE2b-256 788afd406abbd25b2e0bf13f961892a42f3db3612169ec7db00edd7c4153d994

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