Skip to main content

Local-dev in-memory runtime for Anna Apps. Wraps anna-app-core's dispatcher with an InMemoryWindowStore + WebSocket bridge.

Project description

anna-app-runtime-local

Local-dev in-memory runtime for Anna Apps. Reuses the production anna_app_rpc_dispatcher through WindowStoreProtocol so harness behaviour is byte-identical to nexus production.

How it shares code with production

This package does not vendor a copy of the dispatcher. Instead it:

  1. Imports dispatch, WindowStoreProtocol, HostRpcError from src.services.anna_app_rpc_dispatcher (matrix-nexus source).
  2. Provides InMemoryWindowStore — a WindowStoreProtocol impl that keeps state in dictionaries and queues SSE events in memory.
  3. Wires the production dispatch(store, …) against in-memory state.

Because the wheel imports src.services.… directly, the bridge process must be launched from a Python environment that has matrix-nexus on PYTHONPATH (typically: cd matrix-nexus && uv run python -m anna_app_runtime_local.bridge).

Public surface

from anna_app_runtime_local import LocalDispatcherSession, mint_dev_token

session = LocalDispatcherSession.create(
    user_id=1,
    app_slug="focus-flow",
    manifest_dict={...},  # parsed manifest.json
    view="main",
    entry_payload={"topic": "ECM"},
)
result = await session.call("storage", "set", {"key": "x", "value": 42})
events = session.drain_events()  # list[dict] for SSE relay

stdio bridge

python -m anna_app_runtime_local.bridge

Speaks JSON-RPC 2.0 over stdin/stdout (one envelope per line). Methods:

  • session.create{ session_id, window_uuid, token, view, view_meta }
  • session.call → forwards to dispatch(); returns { ok, result | error }
  • session.drain_events → flushes queued SSE events
  • session.close → drops the session
  • session.refresh_token → re-mints a dev token for an active session
  • executas.register → registers {tool_id, project_dir, command?} for tools.invoke; first call lazy-spawns uv run --project <dir> <tool_id> and reuses the warm subprocess.

The Node-side harness (anna-app-cli/src/harness/bridge.ts) speaks this protocol over python-shell.

Local HMAC tokens

mint_dev_token / verify_dev_token use a per-user key at ~/.anna-app/dev.key (mode 600, generated on first use). TTL defaults to 30 s — shorter than production's 120 s — to surface SDK refresh bugs early.

These tokens are not interoperable with the production JWT path; production's _is_tool_allowed already rejects tool-dev-… prefixes.

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

anna_app_runtime_local-0.2.0a6.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

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

anna_app_runtime_local-0.2.0a6-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file anna_app_runtime_local-0.2.0a6.tar.gz.

File metadata

  • Download URL: anna_app_runtime_local-0.2.0a6.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for anna_app_runtime_local-0.2.0a6.tar.gz
Algorithm Hash digest
SHA256 d9f5a3467627c8609150e99599418f6819449fd032e26e4126ce0c20249b2022
MD5 5f6108c0cf001263cefbe84c9179e5bc
BLAKE2b-256 e13bc3b706cef8ff30c6ebc5130be649c74d638c714222c5771b1138502e8e30

See more details on using hashes here.

File details

Details for the file anna_app_runtime_local-0.2.0a6-py3-none-any.whl.

File metadata

File hashes

Hashes for anna_app_runtime_local-0.2.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 4f44e9a4a851705d5364f67f20f8b9143ef07196eb785fec7a1ccb4c0f1f0d48
MD5 7d69e0eda79db7a3402fcd79f859adc9
BLAKE2b-256 c4f2b7666dc0bc783509c85a7c0c5cbe121e1923f8aa4d71ba2e90627cff6312

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