@anna-ai/app-runtime 0.7.0 → 0.8.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 +51 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anna App Runtime SDK — v0.
|
|
2
|
+
* Anna App Runtime SDK — v0.8.0
|
|
3
|
+
*
|
|
4
|
+
* v0.8.0 — Adds `anna.agent.session.refresh(args)` plus the same `.refresh()`
|
|
5
|
+
* sugar on the AgentSession handle, and surfaces session lifecycle metadata
|
|
6
|
+
* (`expires_at`, `max_lifetime_at`, `idle_ttl_seconds`, `session_expires_in`)
|
|
7
|
+
* on every AgentSession. `refresh` re-mints the short-lived capability token
|
|
8
|
+
* for an EXISTING session (by `app_session_uuid`) AND slides its idle window,
|
|
9
|
+
* so a session survives long idle gaps, iframe reloads and host restarts:
|
|
10
|
+
* await anna.agent.session.refresh({ app_session_uuid }) // raw RPC
|
|
11
|
+
* await sess.refresh() // handle sugar
|
|
12
|
+
* `refresh` is identity-authed (it does NOT require a live token), which is
|
|
13
|
+
* what lets it recover a session whose token already lapsed
|
|
14
|
+
* (`APP_SESSION_TOKEN_EXPIRED`). It fails with `APP_SESSION_EXPIRED` /
|
|
15
|
+
* `APP_SESSION_REVOKED` only when the underlying session is genuinely gone.
|
|
16
|
+
* The handle's lifecycle fields are refreshed in place from the response.
|
|
17
|
+
* Coordinated bump: wire method `agent/session.refresh` —
|
|
18
|
+
* dispatcher_version 0.10.0 + schema 0.10.0 + anna-app-core 0.9.0.
|
|
19
|
+
* Additive: old hosts return `-32601 Method not found`.
|
|
3
20
|
*
|
|
4
21
|
* v0.7.0 — Adds `anna.agent.session.attach(app_session_uuid)` — returns an
|
|
5
22
|
* AgentSession handle bound to an EXISTING session you already know the
|
|
@@ -148,8 +165,10 @@
|
|
|
148
165
|
// Also expose raw RPC sub-methods on the function — apps can do
|
|
149
166
|
// `anna.agent.session.create(...)` if they want to manage state manually.
|
|
150
167
|
// `list` is account/app-scoped (enumerate this app's sessions), so it
|
|
151
|
-
// lives only here, not on the per-session AgentSession wrapper.
|
|
152
|
-
|
|
168
|
+
// lives only here, not on the per-session AgentSession wrapper. `refresh`
|
|
169
|
+
// is identity-authed (re-mints token + slides idle window by uuid) and is
|
|
170
|
+
// also exposed as `.refresh()` sugar on the AgentSession handle.
|
|
171
|
+
for (const m of ["create", "run", "cancel", "history", "delete", "list", "refresh"]) {
|
|
153
172
|
ns.session[m] = sessionRpcs[m];
|
|
154
173
|
}
|
|
155
174
|
// `attach` re-wraps an EXISTING session (known uuid) as an AgentSession
|
|
@@ -245,6 +264,24 @@
|
|
|
245
264
|
this.submode = info.submode;
|
|
246
265
|
this.fixed_client_id = info.fixed_client_id || null;
|
|
247
266
|
this.granted_tools = info.granted_tools || [];
|
|
267
|
+
// Lifecycle metadata (v0.8.0). `expires_at` is the authoritative idle
|
|
268
|
+
// deadline; `max_lifetime_at` is the absolute cap; `idle_ttl_seconds` is
|
|
269
|
+
// how far each activity slides the window; `session_expires_in` is the
|
|
270
|
+
// seconds-until-`expires_at` snapshot at mint/refresh time. All are
|
|
271
|
+
// refreshed in place by `.refresh()`.
|
|
272
|
+
this._applyLifecycle(info);
|
|
273
|
+
}
|
|
274
|
+
// Copy lifecycle fields from a create/refresh response onto the handle.
|
|
275
|
+
_applyLifecycle(info) {
|
|
276
|
+
if (info == null) return;
|
|
277
|
+
if ("expires_in" in info) this.expires_in = info.expires_in;
|
|
278
|
+
this.expires_at = info.expires_at ?? this.expires_at ?? null;
|
|
279
|
+
this.max_lifetime_at =
|
|
280
|
+
info.max_lifetime_at ?? this.max_lifetime_at ?? null;
|
|
281
|
+
this.idle_ttl_seconds =
|
|
282
|
+
info.idle_ttl_seconds ?? this.idle_ttl_seconds ?? null;
|
|
283
|
+
this.session_expires_in =
|
|
284
|
+
info.session_expires_in ?? this.session_expires_in ?? null;
|
|
248
285
|
}
|
|
249
286
|
run(opts = {}) {
|
|
250
287
|
const args = Object.assign(
|
|
@@ -279,6 +316,17 @@
|
|
|
279
316
|
{ app_session_uuid: this.app_session_uuid }, opts
|
|
280
317
|
));
|
|
281
318
|
}
|
|
319
|
+
// Re-mint the capability token AND slide the idle window for this session.
|
|
320
|
+
// Identity-authed — works even if the previous token already lapsed
|
|
321
|
+
// (recovers from APP_SESSION_TOKEN_EXPIRED). Updates the handle's
|
|
322
|
+
// lifecycle fields in place from the response and returns it.
|
|
323
|
+
async refresh(opts = {}) {
|
|
324
|
+
const res = await this._rt.call("agent", "session.refresh", Object.assign(
|
|
325
|
+
{ app_session_uuid: this.app_session_uuid }, opts
|
|
326
|
+
));
|
|
327
|
+
this._applyLifecycle(res || {});
|
|
328
|
+
return res;
|
|
329
|
+
}
|
|
282
330
|
delete() {
|
|
283
331
|
return this._rt.call("agent", "session.delete", {
|
|
284
332
|
app_session_uuid: this.app_session_uuid,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anna-ai/app-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|