@anna-ai/app-runtime 0.8.0 → 0.11.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.
- package/dist/index.js +146 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anna App Runtime SDK — v0.
|
|
2
|
+
* Anna App Runtime SDK — v0.11.0
|
|
3
|
+
*
|
|
4
|
+
* v0.11.0 — Adds the `anna.credentials.*` namespace — platform-credentials
|
|
5
|
+
* multi-account access (design platform-credentials-multi-account.md §7).
|
|
6
|
+
* `anna.credentials.list_accounts({provider})` lists the user's authorized
|
|
7
|
+
* accounts (metadata only — never tokens); `anna.credentials.get_token(
|
|
8
|
+
* {provider, account_id?})` returns a short-lived access_token for one
|
|
9
|
+
* account (`account_id` omitted → the user's default account). Gated by
|
|
10
|
+
* manifest `ui.host_api.credentials` (a list of PROVIDER IDS, e.g.
|
|
11
|
+
* ["google"]) plus the user-enabled per-app `credentials_grant`.
|
|
12
|
+
* Coordinated bump: wire namespace `credentials/*` — dispatcher_version
|
|
13
|
+
* 0.13.0 + schema 0.13.0 + anna-app-core 0.12.0. Additive: old hosts
|
|
14
|
+
* return `-32601 Method not found` for `credentials.*`.
|
|
15
|
+
*
|
|
16
|
+
* v0.10.0 — Adds `anna.llm.stream(req)` — streaming L1 completion. Takes the
|
|
17
|
+
* SAME request shape as `anna.llm.complete(req)` but returns an
|
|
18
|
+
* AgentRunStream (async-iterable) instead of a single result; the host
|
|
19
|
+
* streams `{event:"model_token", text}` frames followed by a terminal
|
|
20
|
+
* `{event:"complete", role, content, model, stopReason, usage, _meta}` frame
|
|
21
|
+
* over the shared `rpc.stream` topic (same reassembly machinery as
|
|
22
|
+
* `agent.session.run`):
|
|
23
|
+
* for await (const ev of anna.llm.stream({ messages, maxTokens })) {
|
|
24
|
+
* if (ev.event === "model_token") render(ev.text);
|
|
25
|
+
* }
|
|
26
|
+
* Coordinated bump: wire method `llm/stream` — dispatcher_version 0.12.0 +
|
|
27
|
+
* schema 0.12.0 + anna-app-core 0.11.0. Additive: old hosts return
|
|
28
|
+
* `-32601 Method not found` for `llm.stream` (apps should feature-detect
|
|
29
|
+
* and fall back to `llm.complete`).
|
|
30
|
+
*
|
|
31
|
+
* v0.9.0 — Adds the `anna.apps.*` launcher namespace and view `chrome`
|
|
32
|
+
* support. New raw RPCs `apps.list` / `apps.search` / `apps.get` /
|
|
33
|
+
* `apps.launch` browse and open other installed Anna Apps, and the nested
|
|
34
|
+
* `anna.apps.deck.{list,add,remove,reorder}` namespace manages the user's
|
|
35
|
+
* pinned app deck (wire methods `apps/deck.*`). `app_ref` accepts a numeric
|
|
36
|
+
* app id or an `@handle/slug` string. Also surfaces the per-view `chrome`
|
|
37
|
+
* ("solid" | "vibrancy") and `transparent` flags on `viewMeta`, which the
|
|
38
|
+
* host window manager uses to render translucent / transparent chrome.
|
|
39
|
+
* Coordinated bump: wire namespace `apps/*` + manifest `ui.host_api.apps`
|
|
40
|
+
* and `ui.views[].chrome` / `.transparent` — dispatcher_version 0.11.0 +
|
|
41
|
+
* schema 0.11.0 + anna-app-core 0.10.0. Additive: old hosts return
|
|
42
|
+
* `-32601 Method not found` for `apps.*` and ignore `chrome`/`transparent`.
|
|
3
43
|
*
|
|
4
44
|
* v0.8.0 — Adds `anna.agent.session.refresh(args)` plus the same `.refresh()`
|
|
5
45
|
* sugar on the AgentSession handle, and surfaces session lifecycle metadata
|
|
@@ -185,6 +225,95 @@
|
|
|
185
225
|
return ns;
|
|
186
226
|
}
|
|
187
227
|
|
|
228
|
+
// ---- LLM namespace (L1) ----
|
|
229
|
+
//
|
|
230
|
+
// `anna.llm.complete(req)` / `anna.llm.embed(req)` are plain RPCs that
|
|
231
|
+
// resolve to a single result. `anna.llm.stream(req)` mirrors
|
|
232
|
+
// `AgentSession.run`: it returns an AgentRunStream (async-iterable) and the
|
|
233
|
+
// host streams `{event:"model_token", text}` frames followed by a terminal
|
|
234
|
+
// `{event:"complete", ...}` frame over the shared `rpc.stream` topic.
|
|
235
|
+
//
|
|
236
|
+
// for await (const ev of anna.llm.stream({ messages, maxTokens })) {
|
|
237
|
+
// if (ev.event === "model_token") render(ev.text);
|
|
238
|
+
// else if (ev.event === "complete") done(ev.content.text);
|
|
239
|
+
// }
|
|
240
|
+
//
|
|
241
|
+
// `stream(req)` takes the SAME request shape as `complete(req)`
|
|
242
|
+
// (`{messages, maxTokens?, temperature?, systemPrompt?, stopSequences?,
|
|
243
|
+
// modelPreferences?, metadata?}`).
|
|
244
|
+
function buildLlmNamespace(rt) {
|
|
245
|
+
return new Proxy(
|
|
246
|
+
{},
|
|
247
|
+
{
|
|
248
|
+
get(_, method) {
|
|
249
|
+
if (typeof method !== "string") return undefined;
|
|
250
|
+
if (method === "stream") {
|
|
251
|
+
return (req = {}) => {
|
|
252
|
+
const stream = new AgentRunStream(null, req.run_id || null);
|
|
253
|
+
rt.call("llm", "stream", req || {}).then(
|
|
254
|
+
(res) => {
|
|
255
|
+
stream.streamId = res.stream_id || stream.streamId;
|
|
256
|
+
stream.runId = res.run_id || stream.runId;
|
|
257
|
+
if (stream.streamId)
|
|
258
|
+
rt._registerStream(stream.streamId, stream);
|
|
259
|
+
// Host returned no stream_id (e.g. cached error) → close.
|
|
260
|
+
if (!stream.streamId) stream._emit(null, true);
|
|
261
|
+
},
|
|
262
|
+
(err) => {
|
|
263
|
+
stream._emit(
|
|
264
|
+
{ event: "error", code: err.code, message: err.message },
|
|
265
|
+
true
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
return stream;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return (args, opts) => rt.call("llm", method, args || {}, opts);
|
|
273
|
+
},
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ---- Apps namespace (v0.9.0) ----
|
|
279
|
+
//
|
|
280
|
+
// The Apps launcher surface lets an app browse/launch other installed
|
|
281
|
+
// Anna Apps and manage the user's pinned "deck":
|
|
282
|
+
//
|
|
283
|
+
// await anna.apps.list({ search }) // installed apps
|
|
284
|
+
// await anna.apps.search({ q }) // alias of list w/ search
|
|
285
|
+
// await anna.apps.get({ app_ref }) // single card
|
|
286
|
+
// await anna.apps.launch({ app_ref, view, payload }) // open a window
|
|
287
|
+
// await anna.apps.deck.list() // pinned deck
|
|
288
|
+
// await anna.apps.deck.add({ app_ref })
|
|
289
|
+
// await anna.apps.deck.remove({ app_ref })
|
|
290
|
+
// await anna.apps.deck.reorder({ ordered })
|
|
291
|
+
//
|
|
292
|
+
// `app_ref` accepts either a numeric app id or an `@handle/slug` string.
|
|
293
|
+
// The nested `deck.*` methods map to wire methods `apps/deck.<m>`.
|
|
294
|
+
function buildAppsNamespace(rt) {
|
|
295
|
+
const deck = new Proxy(
|
|
296
|
+
{},
|
|
297
|
+
{
|
|
298
|
+
get(_, method) {
|
|
299
|
+
if (typeof method !== "string") return undefined;
|
|
300
|
+
return (args, opts) =>
|
|
301
|
+
rt.call("apps", "deck." + method, args || {}, opts);
|
|
302
|
+
},
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
return new Proxy(
|
|
306
|
+
{},
|
|
307
|
+
{
|
|
308
|
+
get(_, method) {
|
|
309
|
+
if (typeof method !== "string") return undefined;
|
|
310
|
+
if (method === "deck") return deck;
|
|
311
|
+
return (args, opts) => rt.call("apps", method, args || {}, opts);
|
|
312
|
+
},
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
188
317
|
// ---- HTTP-backed namespaces removed in v0.4.0 ----
|
|
189
318
|
//
|
|
190
319
|
// `anna.image.*` and `anna.upload.*` are now plain postMessage RPCs
|
|
@@ -355,7 +484,7 @@
|
|
|
355
484
|
this.tools = buildNamespace(this, "tools");
|
|
356
485
|
this.chat = buildNamespace(this, "chat");
|
|
357
486
|
this.artifact = buildNamespace(this, "artifact");
|
|
358
|
-
this.llm =
|
|
487
|
+
this.llm = buildLlmNamespace(this);
|
|
359
488
|
this.fs = buildNamespace(this, "fs");
|
|
360
489
|
this.storage = buildNamespace(this, "storage");
|
|
361
490
|
this.prefs = buildNamespace(this, "prefs");
|
|
@@ -376,6 +505,14 @@
|
|
|
376
505
|
this.image = buildNamespace(this, "image");
|
|
377
506
|
this.upload = buildNamespace(this, "upload");
|
|
378
507
|
|
|
508
|
+
// ---- credentials namespace (v0.11.0; multi-account) ----
|
|
509
|
+
// anna.credentials.list_accounts({provider}) — metadata only, no tokens
|
|
510
|
+
// anna.credentials.get_token({provider, account_id?}) — short-lived
|
|
511
|
+
// access_token for one account; account_id omitted → default account.
|
|
512
|
+
// Requires manifest ui.host_api.credentials (provider ids) AND the
|
|
513
|
+
// user-enabled per-app credentials_grant.
|
|
514
|
+
this.credentials = buildNamespace(this, "credentials");
|
|
515
|
+
|
|
379
516
|
// ---- files namespace (APS object/blob API; v0.5.x) ----
|
|
380
517
|
// anna.files.upload_init({path, content_type, size, ttl_seconds?, metadata?, tags?, if_match?})
|
|
381
518
|
// anna.files.upload_finalize({path, etag, size_bytes, metadata?})
|
|
@@ -384,6 +521,13 @@
|
|
|
384
521
|
// anna.files.delete({path, if_match?})
|
|
385
522
|
this.files = buildNamespace(this, "files");
|
|
386
523
|
|
|
524
|
+
// ---- apps namespace (launcher + deck; v0.9.0) ----
|
|
525
|
+
// anna.apps.list({search?}) / search({q}) / get({app_ref}) /
|
|
526
|
+
// launch({app_ref, view?, payload?})
|
|
527
|
+
// anna.apps.deck.list() / add({app_ref}) / remove({app_ref}) /
|
|
528
|
+
// reorder({ordered})
|
|
529
|
+
this.apps = buildAppsNamespace(this);
|
|
530
|
+
|
|
387
531
|
// Reassembly buffers for `rpc.stream` events. Map<stream_id, AgentRunStream>.
|
|
388
532
|
this._streams = new Map();
|
|
389
533
|
this.on("rpc.stream", (payload) => this._onStreamFrame(payload || {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anna-ai/app-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|