anna-app-runtime-local 0.2.0a32__tar.gz → 0.2.0a33__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/PKG-INFO +2 -2
  2. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/pyproject.toml +2 -2
  3. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/__init__.py +1 -1
  4. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/session.py +22 -27
  5. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/store.py +2 -3
  6. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/test_local_dispatch.py +15 -9
  7. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/test_reverse_rpc.py +3 -3
  8. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/.gitignore +0 -0
  9. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/README.md +0 -0
  10. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/bridge.py +0 -0
  11. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/executa.py +0 -0
  12. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/jobs.py +0 -0
  13. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/token.py +0 -0
  14. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/src/anna_app_runtime_local/web_local.py +0 -0
  15. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/__init__.py +0 -0
  16. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/conftest.py +0 -0
  17. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/test_frame_limits.py +0 -0
  18. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/test_tool_jobs.py +0 -0
  19. {anna_app_runtime_local-0.2.0a32 → anna_app_runtime_local-0.2.0a33}/tests/test_web_local_images.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: anna-app-runtime-local
3
- Version: 0.2.0a32
3
+ Version: 0.2.0a33
4
4
  Summary: Local-dev in-memory runtime for Anna Apps. Wraps anna-app-core's dispatcher with an InMemoryWindowStore + WebSocket bridge.
5
5
  Author: Talent AI
6
6
  License: Proprietary
7
7
  Keywords: anna,anna-app,dev,executa,harness
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: anna-app-core<0.28,>=0.27.0
9
+ Requires-Dist: anna-app-core<0.29,>=0.28.0
10
10
  Requires-Dist: ddgs<10,>=9.13
11
11
  Description-Content-Type: text/markdown
12
12
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "anna-app-runtime-local"
3
- version = "0.2.0a32"
3
+ version = "0.2.0a33"
4
4
  description = "Local-dev in-memory runtime for Anna Apps. Wraps anna-app-core's dispatcher with an InMemoryWindowStore + WebSocket bridge."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -36,7 +36,7 @@ keywords = ["anna", "anna-app", "executa", "dev", "harness"]
36
36
  # (platform-media-generation-music §7) — same bridge-forward / not_implemented
37
37
  # contract as video.*.
38
38
  dependencies = [
39
- "anna-app-core>=0.27.0,<0.28",
39
+ "anna-app-core>=0.28.0,<0.29",
40
40
  "ddgs>=9.13,<10",
41
41
  ]
42
42
 
@@ -29,4 +29,4 @@ __all__ = [
29
29
  "DevTokenError",
30
30
  ]
31
31
 
32
- __version__ = "0.2.0a32"
32
+ __version__ = "0.2.0a33"
@@ -86,9 +86,11 @@ class LocalDispatcherSession:
86
86
  app_slug: str | None = None,
87
87
  store: InMemoryWindowStore | None = None,
88
88
  ) -> "LocalDispatcherSession":
89
- from anna_app_core import AppManifest
89
+ from anna_app_core import AppManifest, normalize_legacy_manifest
90
90
 
91
- manifest = AppManifest.model_validate(manifest_dict)
91
+ # Harness ingest point (design app-permission-system-removal.md §5.2):
92
+ # schema ≤ 3 manifests are folded to schema 4 exactly like nexus does.
93
+ manifest = AppManifest.model_validate(normalize_legacy_manifest(manifest_dict))
92
94
 
93
95
  if store is None:
94
96
  store = InMemoryWindowStore()
@@ -196,20 +198,18 @@ _REVERSE_RPC_ROUTE: dict[str, tuple[str, str]] = {
196
198
  "image/generate": ("image", "generate"),
197
199
  "image/edit": ("image", "edit"),
198
200
  # NOTE: ``host/uploadFile`` is deliberately NOT in this table. It is an
199
- # executa-originated capability gated by the EXECUTA's own
200
- # ``upload_grant`` in production (matrix → nexus executa_upload_gate) —
201
- # the hosting app's ``ui.host_api`` ACL is never consulted. It is
202
- # handled by the dedicated ACL-bypass branch in
203
- # :class:`LocalServerRequestHandler` below (see ``_UPLOAD_MODE_TO_HOST``).
201
+ # executa-originated capability authorized by the EXECUTA's own
202
+ # ``upload_token`` in production (matrix → nexus executa_upload_gate). It
203
+ # is handled by the dedicated branch in :class:`LocalServerRequestHandler`
204
+ # below (see ``_UPLOAD_MODE_TO_HOST``).
204
205
  }
205
206
 
206
207
 
207
208
  # APS Files (object storage) reverse-RPC method → nexus storage REST method.
208
209
  #
209
- # These deliberately bypass the hosting app's ``ui.host_api`` ACL: in
210
- # production an executa's ``files/*`` calls travel on the executa's OWN
210
+ # In production an executa's ``files/*`` calls travel on the executa's OWN
211
211
  # ``storage_token`` (matrix Agent → ``/api/v1/storage/files/*``) and never
212
- # touch the app's grants. The local harness mirrors that by forwarding to
212
+ # touch the hosting app. The local harness mirrors that by forwarding to
213
213
  # ``host.storage.files_*`` over the python→node bridge, which the Node
214
214
  # ``LlmBridge`` turns into the matching ``/api/v1/storage/files/*`` request
215
215
  # using a minted ``storage_token`` — byte-for-byte the same path as
@@ -217,9 +217,8 @@ _REVERSE_RPC_ROUTE: dict[str, tuple[str, str]] = {
217
217
  #
218
218
  # Previously ``files/upload_begin`` / ``files/upload_complete`` were
219
219
  # misrouted onto the host-mediated ``upload.negotiate`` / ``upload.confirm``
220
- # facade, which (a) hit a different backend and (b) required a
221
- # ``ui.host_api.upload`` grant the App schema can't even express — so APS
222
- # Files via executa always failed under ``anna-app dev --storage aps``.
220
+ # facade, which hit a different backend — so APS Files via executa always
221
+ # failed under ``anna-app dev --storage aps``.
223
222
  _FILES_REVERSE_RPC: dict[str, str] = {
224
223
  "files/upload_begin": "files_init",
225
224
  "files/upload_complete": "files_finalize",
@@ -233,14 +232,11 @@ _FILES_REVERSE_RPC: dict[str, str] = {
233
232
  # Wire-identical to the matrix host handler (matrix
234
233
  # ``src/executa/host_upload.py``): a single JSON-RPC method whose
235
234
  # ``params.mode`` selects the sub-operation (default ``inline``). Like
236
- # ``files/*`` above, this is routed BEFORE the dispatcher route table so it
237
- # bypasses the app iframe ``ui.host_api`` ACL — in production an executa's
238
- # ``host/uploadFile`` is authorized by the executa's OWN ``upload_grant``
239
- # (nexus ``executa_upload_gate``) and never consults the hosting app's
240
- # manifest. Requiring ``ui.host_api.upload`` here broke the official
241
- # file-upload demo under `anna-app dev` (forum #159), and the old
242
- # ``("upload", "inline")`` route additionally ignored ``mode`` — silently
243
- # collapsing negotiate/confirm onto inline.
235
+ # ``files/*`` above, this is routed BEFORE the dispatcher route table — in
236
+ # production an executa's ``host/uploadFile`` is authorized by the executa's
237
+ # OWN ``upload_token`` (nexus ``executa_upload_gate``) and never consults the
238
+ # hosting app's manifest. The old ``("upload", "inline")`` route ignored
239
+ # ``mode`` — silently collapsing negotiate/confirm onto inline.
244
240
  _UPLOAD_MODE_TO_HOST: dict[str, str] = {
245
241
  "inline": "host.upload.inline",
246
242
  "negotiate": "host.upload.negotiate",
@@ -279,6 +275,7 @@ def _validate_sampling_text_only(args: dict) -> None:
279
275
  },
280
276
  )
281
277
 
278
+
282
279
  # Custom JSON-RPC code for "implemented in production but not in this
283
280
  # runtime" — matches the matrix host convention also used for the
284
281
  # dispatcher's ``not_implemented`` mapping below.
@@ -358,9 +355,8 @@ class LocalServerRequestHandler:
358
355
  args = {k: v for k, v in params.items() if k != "context"}
359
356
 
360
357
  # APS Files (object storage) reverse-RPC. Routed BEFORE the dispatcher
361
- # route table so it bypasses the app iframe ``ui.host_api`` ACL — in
362
- # production these go out on the executa's own ``storage_token`` and
363
- # never touch the hosting app's grants. Forward to the Node-side
358
+ # route table — in production these go out on the executa's own
359
+ # ``storage_token`` and never touch the hosting app. Forward to the Node-side
364
360
  # storage_token path when APS forwarding is wired; otherwise surface a
365
361
  # clean ``not_implemented`` (the in-memory harness has no object
366
362
  # storage backend, mirroring ``executa dev --storage memory``).
@@ -386,9 +382,8 @@ class LocalServerRequestHandler:
386
382
  # Host-mediated user-artifact upload. Routed BEFORE the dispatcher
387
383
  # route table so it bypasses the app iframe ``ui.host_api`` ACL —
388
384
  # see the ``_UPLOAD_MODE_TO_HOST`` comment for the production
389
- # semantics this mirrors. Grant enforcement happens server-side
390
- # (nexus rejects with APP_NOT_GRANTED when the dev app's
391
- # ``upload_grant`` is off).
385
+ # semantics this mirrors. Owner enforcement happens server-side
386
+ # (nexus rejects with APP_NOT_GRANTED when the dev app is disabled).
392
387
  if method == "host/uploadFile":
393
388
  mode = args.get("mode") or "inline"
394
389
  host_method = _UPLOAD_MODE_TO_HOST.get(mode)
@@ -437,8 +437,7 @@ class InMemoryWindowStore:
437
437
  async def agent_session_catalog(self, *, user_id, window, manifest, args):
438
438
  # Pre-create platform-tool discovery (dispatcher 0.18.0). The Node
439
439
  # LlmBridge answers locally (mock catalog derived from the manifest's
440
- # ``agent.tools`` declaration — the harness has no user-grant
441
- # concept, so ``user_granted`` is always true).
440
+ # ``agent.tools`` declaration).
442
441
  return await self._delegate(
443
442
  "host.agent.session.catalog", args, "agent.session.catalog"
444
443
  )
@@ -513,7 +512,7 @@ class InMemoryWindowStore:
513
512
  #
514
513
  # docs/design/platform-media-generation-video-audio.md §7 / §9 / §10.
515
514
  # Same host-mediated shape as image.*: production nexus delegates to
516
- # ``app_media_facade`` in-process (grant / quota / billing / job state
515
+ # ``app_media_facade`` in-process (owner check / quota / billing / job state
517
516
  # machine). With a bridge we forward ``host.video.*`` / ``host.audio.*`` /
518
517
  # ``host.llm.catalog`` so the Node LlmBridge mints and POSTs the matching
519
518
  # ``/api/v1/copilot/app/{video,audio,models}`` route; without one we
@@ -89,8 +89,7 @@ async def test_window_hello_returns_capabilities_and_view_meta():
89
89
  out = await sess.call("window", "hello", {})
90
90
  assert out["entry_payload"] == {"topic": "ECM"}
91
91
  assert out["view_meta"]["name"] == "main"
92
- assert "host_api_version" in out["capabilities"]
93
- assert "scopes" in out["capabilities"]
92
+ assert out["capabilities"] == {"host_api_version": "0.1.0"}
94
93
  assert out["is_resume"] is False
95
94
  # forum #376: app identity from the harness store (slug doubles as name).
96
95
  assert out["app"]["id"] == 1
@@ -191,14 +190,17 @@ async def test_tools_list_reflects_manifest_whitelist():
191
190
 
192
191
 
193
192
  @pytest.mark.asyncio
194
- async def test_unallowed_namespace_returns_permission_denied():
195
- # `chat` is missing from host_api below → dispatcher must reject.
193
+ async def test_undeclared_namespace_is_allowed():
194
+ # No method-level ACL (design app-permission-system-removal.md): an
195
+ # installed App may call every Host API method; legacy `host_api`
196
+ # method lists are folded away on ingest.
196
197
  sess = LocalDispatcherSession.create(
197
198
  user_id=1, manifest_dict=_manifest(host_api={"storage": ["*"]})
198
199
  )
199
- with pytest.raises(LocalSessionError) as exc:
200
- await sess.call("chat", "write_message", {"role": "assistant", "content": "hi"})
201
- assert exc.value.code == "permission_denied"
200
+ out = await sess.call(
201
+ "chat", "write_message", {"role": "assistant", "content": "hi"}
202
+ )
203
+ assert isinstance(out, dict)
202
204
 
203
205
 
204
206
  @pytest.mark.asyncio
@@ -372,8 +374,12 @@ async def test_bridge_session_create_returns_browser_permission_gates():
372
374
 
373
375
  async def create(manifest):
374
376
  resp = await bridge.handle(
375
- {"jsonrpc": "2.0", "id": 1, "method": "session.create",
376
- "params": {"user_id": 1, "manifest": manifest}}
377
+ {
378
+ "jsonrpc": "2.0",
379
+ "id": 1,
380
+ "method": "session.create",
381
+ "params": {"user_id": 1, "manifest": manifest},
382
+ }
377
383
  )
378
384
  return resp["result"]
379
385
 
@@ -701,9 +701,9 @@ async def test_files_legacy_mode_returns_not_implemented() -> None:
701
701
 
702
702
  # ---------------------------------------------------------------------------
703
703
  # host/uploadFile (host-mediated user-artifact upload) via an executa's
704
- # reverse-RPC. Must (a) bypass the app iframe ``ui.host_api`` ACL — in
705
- # production the executa's OWN ``upload_grant`` authorizes it, never the
706
- # hosting app's manifest (forum #159) — and (b) dispatch on ``params.mode``
704
+ # reverse-RPC. Must (a) never consult the hosting app's manifest — in
705
+ # production the executa's OWN ``upload_token`` authorizes it (forum #159) —
706
+ # and (b) dispatch on ``params.mode``
707
707
  # exactly like the matrix host handler, instead of collapsing
708
708
  # negotiate/confirm onto inline.
709
709
  # ---------------------------------------------------------------------------