@anna-ai/app-runtime 0.12.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 +51 -0
  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,29 @@
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
+
176
203
  // ---- Tools namespace (v0.12.0) ----
177
204
  //
178
205
  // Plain RPC proxy (`anna.tools.invoke`, `anna.tools.list`) plus one
@@ -543,6 +570,30 @@
543
570
  // user-enabled per-app credentials_grant.
544
571
  this.credentials = buildNamespace(this, "credentials");
545
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
+
546
597
  // ---- files namespace (APS object/blob API; v0.5.x) ----
547
598
  // anna.files.upload_init({path, content_type, size, ttl_seconds?, metadata?, tags?, if_match?})
548
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.12.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",