@anna-ai/app-runtime 0.11.0 → 0.13.0

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 (2) hide show
  1. package/dist/index.js +82 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -155,6 +155,10 @@
155
155
  // browser→R2 PUT itself is direct (not via this SDK), but the host
156
156
  // round-trip for finalize needs DB+R2 head ~ up to a few seconds.
157
157
  files: 60000,
158
+ // `web.*` — search is usually <5s but fetch crawls up to 10 pages with
159
+ // a 30s per-page budget under host-side concurrency limits. Apps doing
160
+ // large fetch batches should pass { timeoutMs: 90000 } per call.
161
+ web: 60000,
158
162
  };
159
163
  const DEFAULT_TIMEOUT_MS = 30000;
160
164
 
@@ -173,6 +177,59 @@
173
177
  );
174
178
  }
175
179
 
180
+ // ---- Web namespace (v0.13.0; Phase 2 adds image_search / image_fetch) ----
181
+ //
182
+ // Plain proxy over the `web` namespace with camelCase aliases so both
183
+ // `anna.web.image_search(...)` (wire name, matches the manifest
184
+ // `ui.host_api.web` entry) and `anna.web.imageSearch(...)` (RFC §2.3
185
+ // spelling) hit the same dispatcher method.
186
+ const WEB_METHOD_ALIASES = {
187
+ imageSearch: "image_search",
188
+ imageFetch: "image_fetch",
189
+ };
190
+ function buildWebNamespace(rt) {
191
+ return new Proxy(
192
+ {},
193
+ {
194
+ get(_, method) {
195
+ if (typeof method !== "string") return undefined;
196
+ const wire = WEB_METHOD_ALIASES[method] || method;
197
+ return (args, opts) => rt.call("web", wire, args || {}, opts);
198
+ },
199
+ }
200
+ );
201
+ }
202
+
203
+ // ---- Tools namespace (v0.12.0) ----
204
+ //
205
+ // Plain RPC proxy (`anna.tools.invoke`, `anna.tools.list`) plus one
206
+ // client-side subscription helper:
207
+ //
208
+ // const off = anna.tools.onChanged(({ client_id, deployed }) => {
209
+ // // deploy reconciliation just landed tools on the agent —
210
+ // // re-run anna.tools.list() and re-enable buttons.
211
+ // });
212
+ //
213
+ // Fired when the host broadcasts a `tools.changed` window event (deploy
214
+ // reconciliation §6.3). Returns an unsubscribe function. `tools.list`
215
+ // entries MAY carry an optional `status` field ("available" |
216
+ // "deploying" | "unavailable"); treat a missing `status` as available
217
+ // (hosts without fact data degrade to the legacy static list).
218
+ function buildToolsNamespace(rt) {
219
+ return new Proxy(
220
+ {},
221
+ {
222
+ get(_, method) {
223
+ if (typeof method !== "string") return undefined;
224
+ if (method === "onChanged") {
225
+ return (fn) => rt.on("tools.changed", fn);
226
+ }
227
+ return (args, opts) => rt.call("tools", method, args || {}, opts);
228
+ },
229
+ }
230
+ );
231
+ }
232
+
176
233
  // ---- Agent namespace (v0.2.0) ----
177
234
  //
178
235
  // Exposes both raw RPCs (`anna.agent.session.create({submode, ...})`,
@@ -481,7 +538,7 @@
481
538
  this.geometry = null;
482
539
 
483
540
  // namespace proxies
484
- this.tools = buildNamespace(this, "tools");
541
+ this.tools = buildToolsNamespace(this);
485
542
  this.chat = buildNamespace(this, "chat");
486
543
  this.artifact = buildNamespace(this, "artifact");
487
544
  this.llm = buildLlmNamespace(this);
@@ -513,6 +570,30 @@
513
570
  // user-enabled per-app credentials_grant.
514
571
  this.credentials = buildNamespace(this, "credentials");
515
572
 
573
+ // ---- web namespace (v0.13.0; host-managed search/fetch) ----
574
+ // anna.web.search({query, max_results?, search_depth?, topic?,
575
+ // time_range?, region?, include_domains?, exclude_domains?})
576
+ // → {results, provider_tier, quota_consumed, cached?}
577
+ // anna.web.fetch({urls, format?, max_chars?, timeout_ms?})
578
+ // → {pages, quota_consumed}
579
+ // Phase 2:
580
+ // anna.web.image_search({query, max_results?, min_width?, min_height?,
581
+ // aspect?}) → {results: [{image_url, thumbnail_url?, source_url,
582
+ // title?, width?, height?, mime_type?, license_hint?}],
583
+ // quota_consumed, cached?} (safe-search force-enabled host-side)
584
+ // anna.web.image_fetch({url, max_bytes?, purpose?})
585
+ // → {path, get_url, mime_type, bytes_size, sha256, source_url,
586
+ // final_url, quota_consumed} (artifact reference — never bytes;
587
+ // stored in the app's APS files self-scope)
588
+ // camelCase aliases: anna.web.imageSearch / anna.web.imageFetch map to
589
+ // the same wire methods (image_search / image_fetch).
590
+ // Provider keys / routing / SSRF guard / billing all stay host-side.
591
+ // Requires manifest ui.host_api.web AND the user-enabled per-app
592
+ // web_grant (first call returns APP_NOT_GRANTED → consent card;
593
+ // image_search / image_fetch default OFF even when web is enabled).
594
+ // See matrix-nexus docs/design/app-web-search.md §2.
595
+ this.web = buildWebNamespace(this);
596
+
516
597
  // ---- files namespace (APS object/blob API; v0.5.x) ----
517
598
  // anna.files.upload_init({path, content_type, size, ttl_seconds?, metadata?, tags?, if_match?})
518
599
  // anna.files.upload_finalize({path, etag, size_bytes, metadata?})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anna-ai/app-runtime",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Anna App browser runtime SDK. Loaded by every Anna App iframe; provides typed proxy over the postMessage RPC bridge to the host (Anna dashboard / `anna-app dev` harness).",
5
5
  "license": "MIT",
6
6
  "type": "module",