@anna-ai/app-runtime 0.8.0 → 0.10.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 +126 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anna App Runtime SDK — v0.
|
|
2
|
+
* Anna App Runtime SDK — v0.10.0
|
|
3
|
+
*
|
|
4
|
+
* v0.10.0 — Adds `anna.llm.stream(req)` — streaming L1 completion. Takes the
|
|
5
|
+
* SAME request shape as `anna.llm.complete(req)` but returns an
|
|
6
|
+
* AgentRunStream (async-iterable) instead of a single result; the host
|
|
7
|
+
* streams `{event:"model_token", text}` frames followed by a terminal
|
|
8
|
+
* `{event:"complete", role, content, model, stopReason, usage, _meta}` frame
|
|
9
|
+
* over the shared `rpc.stream` topic (same reassembly machinery as
|
|
10
|
+
* `agent.session.run`):
|
|
11
|
+
* for await (const ev of anna.llm.stream({ messages, maxTokens })) {
|
|
12
|
+
* if (ev.event === "model_token") render(ev.text);
|
|
13
|
+
* }
|
|
14
|
+
* Coordinated bump: wire method `llm/stream` — dispatcher_version 0.12.0 +
|
|
15
|
+
* schema 0.12.0 + anna-app-core 0.11.0. Additive: old hosts return
|
|
16
|
+
* `-32601 Method not found` for `llm.stream` (apps should feature-detect
|
|
17
|
+
* and fall back to `llm.complete`).
|
|
18
|
+
*
|
|
19
|
+
* v0.9.0 — Adds the `anna.apps.*` launcher namespace and view `chrome`
|
|
20
|
+
* support. New raw RPCs `apps.list` / `apps.search` / `apps.get` /
|
|
21
|
+
* `apps.launch` browse and open other installed Anna Apps, and the nested
|
|
22
|
+
* `anna.apps.deck.{list,add,remove,reorder}` namespace manages the user's
|
|
23
|
+
* pinned app deck (wire methods `apps/deck.*`). `app_ref` accepts a numeric
|
|
24
|
+
* app id or an `@handle/slug` string. Also surfaces the per-view `chrome`
|
|
25
|
+
* ("solid" | "vibrancy") and `transparent` flags on `viewMeta`, which the
|
|
26
|
+
* host window manager uses to render translucent / transparent chrome.
|
|
27
|
+
* Coordinated bump: wire namespace `apps/*` + manifest `ui.host_api.apps`
|
|
28
|
+
* and `ui.views[].chrome` / `.transparent` — dispatcher_version 0.11.0 +
|
|
29
|
+
* schema 0.11.0 + anna-app-core 0.10.0. Additive: old hosts return
|
|
30
|
+
* `-32601 Method not found` for `apps.*` and ignore `chrome`/`transparent`.
|
|
3
31
|
*
|
|
4
32
|
* v0.8.0 — Adds `anna.agent.session.refresh(args)` plus the same `.refresh()`
|
|
5
33
|
* sugar on the AgentSession handle, and surfaces session lifecycle metadata
|
|
@@ -185,6 +213,95 @@
|
|
|
185
213
|
return ns;
|
|
186
214
|
}
|
|
187
215
|
|
|
216
|
+
// ---- LLM namespace (L1) ----
|
|
217
|
+
//
|
|
218
|
+
// `anna.llm.complete(req)` / `anna.llm.embed(req)` are plain RPCs that
|
|
219
|
+
// resolve to a single result. `anna.llm.stream(req)` mirrors
|
|
220
|
+
// `AgentSession.run`: it returns an AgentRunStream (async-iterable) and the
|
|
221
|
+
// host streams `{event:"model_token", text}` frames followed by a terminal
|
|
222
|
+
// `{event:"complete", ...}` frame over the shared `rpc.stream` topic.
|
|
223
|
+
//
|
|
224
|
+
// for await (const ev of anna.llm.stream({ messages, maxTokens })) {
|
|
225
|
+
// if (ev.event === "model_token") render(ev.text);
|
|
226
|
+
// else if (ev.event === "complete") done(ev.content.text);
|
|
227
|
+
// }
|
|
228
|
+
//
|
|
229
|
+
// `stream(req)` takes the SAME request shape as `complete(req)`
|
|
230
|
+
// (`{messages, maxTokens?, temperature?, systemPrompt?, stopSequences?,
|
|
231
|
+
// modelPreferences?, metadata?}`).
|
|
232
|
+
function buildLlmNamespace(rt) {
|
|
233
|
+
return new Proxy(
|
|
234
|
+
{},
|
|
235
|
+
{
|
|
236
|
+
get(_, method) {
|
|
237
|
+
if (typeof method !== "string") return undefined;
|
|
238
|
+
if (method === "stream") {
|
|
239
|
+
return (req = {}) => {
|
|
240
|
+
const stream = new AgentRunStream(null, req.run_id || null);
|
|
241
|
+
rt.call("llm", "stream", req || {}).then(
|
|
242
|
+
(res) => {
|
|
243
|
+
stream.streamId = res.stream_id || stream.streamId;
|
|
244
|
+
stream.runId = res.run_id || stream.runId;
|
|
245
|
+
if (stream.streamId)
|
|
246
|
+
rt._registerStream(stream.streamId, stream);
|
|
247
|
+
// Host returned no stream_id (e.g. cached error) → close.
|
|
248
|
+
if (!stream.streamId) stream._emit(null, true);
|
|
249
|
+
},
|
|
250
|
+
(err) => {
|
|
251
|
+
stream._emit(
|
|
252
|
+
{ event: "error", code: err.code, message: err.message },
|
|
253
|
+
true
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
return stream;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return (args, opts) => rt.call("llm", method, args || {}, opts);
|
|
261
|
+
},
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ---- Apps namespace (v0.9.0) ----
|
|
267
|
+
//
|
|
268
|
+
// The Apps launcher surface lets an app browse/launch other installed
|
|
269
|
+
// Anna Apps and manage the user's pinned "deck":
|
|
270
|
+
//
|
|
271
|
+
// await anna.apps.list({ search }) // installed apps
|
|
272
|
+
// await anna.apps.search({ q }) // alias of list w/ search
|
|
273
|
+
// await anna.apps.get({ app_ref }) // single card
|
|
274
|
+
// await anna.apps.launch({ app_ref, view, payload }) // open a window
|
|
275
|
+
// await anna.apps.deck.list() // pinned deck
|
|
276
|
+
// await anna.apps.deck.add({ app_ref })
|
|
277
|
+
// await anna.apps.deck.remove({ app_ref })
|
|
278
|
+
// await anna.apps.deck.reorder({ ordered })
|
|
279
|
+
//
|
|
280
|
+
// `app_ref` accepts either a numeric app id or an `@handle/slug` string.
|
|
281
|
+
// The nested `deck.*` methods map to wire methods `apps/deck.<m>`.
|
|
282
|
+
function buildAppsNamespace(rt) {
|
|
283
|
+
const deck = new Proxy(
|
|
284
|
+
{},
|
|
285
|
+
{
|
|
286
|
+
get(_, method) {
|
|
287
|
+
if (typeof method !== "string") return undefined;
|
|
288
|
+
return (args, opts) =>
|
|
289
|
+
rt.call("apps", "deck." + method, args || {}, opts);
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
return new Proxy(
|
|
294
|
+
{},
|
|
295
|
+
{
|
|
296
|
+
get(_, method) {
|
|
297
|
+
if (typeof method !== "string") return undefined;
|
|
298
|
+
if (method === "deck") return deck;
|
|
299
|
+
return (args, opts) => rt.call("apps", method, args || {}, opts);
|
|
300
|
+
},
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
188
305
|
// ---- HTTP-backed namespaces removed in v0.4.0 ----
|
|
189
306
|
//
|
|
190
307
|
// `anna.image.*` and `anna.upload.*` are now plain postMessage RPCs
|
|
@@ -355,7 +472,7 @@
|
|
|
355
472
|
this.tools = buildNamespace(this, "tools");
|
|
356
473
|
this.chat = buildNamespace(this, "chat");
|
|
357
474
|
this.artifact = buildNamespace(this, "artifact");
|
|
358
|
-
this.llm =
|
|
475
|
+
this.llm = buildLlmNamespace(this);
|
|
359
476
|
this.fs = buildNamespace(this, "fs");
|
|
360
477
|
this.storage = buildNamespace(this, "storage");
|
|
361
478
|
this.prefs = buildNamespace(this, "prefs");
|
|
@@ -384,6 +501,13 @@
|
|
|
384
501
|
// anna.files.delete({path, if_match?})
|
|
385
502
|
this.files = buildNamespace(this, "files");
|
|
386
503
|
|
|
504
|
+
// ---- apps namespace (launcher + deck; v0.9.0) ----
|
|
505
|
+
// anna.apps.list({search?}) / search({q}) / get({app_ref}) /
|
|
506
|
+
// launch({app_ref, view?, payload?})
|
|
507
|
+
// anna.apps.deck.list() / add({app_ref}) / remove({app_ref}) /
|
|
508
|
+
// reorder({ordered})
|
|
509
|
+
this.apps = buildAppsNamespace(this);
|
|
510
|
+
|
|
387
511
|
// Reassembly buffers for `rpc.stream` events. Map<stream_id, AgentRunStream>.
|
|
388
512
|
this._streams = new Map();
|
|
389
513
|
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.10.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",
|