@songsid/agend 2.3.5-beta.2 → 2.3.5-beta.3

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 (135) hide show
  1. package/dist/agent-cli-instructions.md +2 -2
  2. package/dist/auth-api.d.ts +2 -0
  3. package/dist/auth-api.js +5 -1
  4. package/dist/auth-api.js.map +1 -1
  5. package/dist/backend/claude-code.d.ts +2 -0
  6. package/dist/backend/claude-code.js +16 -3
  7. package/dist/backend/claude-code.js.map +1 -1
  8. package/dist/backend/cli-env-probe.js +6 -2
  9. package/dist/backend/cli-env-probe.js.map +1 -1
  10. package/dist/backend/codex.d.ts +5 -3
  11. package/dist/backend/codex.js +31 -13
  12. package/dist/backend/codex.js.map +1 -1
  13. package/dist/backend/kiro.js +1 -1
  14. package/dist/backend/kiro.js.map +1 -1
  15. package/dist/backend/types.d.ts +5 -1
  16. package/dist/backend/types.js.map +1 -1
  17. package/dist/bundled-tmux-guard.d.ts +4 -0
  18. package/dist/bundled-tmux-guard.js +7 -0
  19. package/dist/bundled-tmux-guard.js.map +1 -1
  20. package/dist/cache-service.d.ts +6 -0
  21. package/dist/cache-service.js +105 -0
  22. package/dist/cache-service.js.map +1 -1
  23. package/dist/channel/mcp-tools.js +2 -2
  24. package/dist/channel/mcp-tools.js.map +1 -1
  25. package/dist/daemon.d.ts +3 -0
  26. package/dist/daemon.js +17 -2
  27. package/dist/daemon.js.map +1 -1
  28. package/dist/fleet-manager.d.ts +71 -0
  29. package/dist/fleet-manager.js +393 -92
  30. package/dist/fleet-manager.js.map +1 -1
  31. package/dist/fleet-process-handlers.d.ts +1 -1
  32. package/dist/fleet-process-handlers.js +3 -2
  33. package/dist/fleet-process-handlers.js.map +1 -1
  34. package/dist/general-knowledge/skills/concepts/SKILL.md +11 -12
  35. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
  36. package/dist/general-knowledge/skills/fleet-config/SKILL.md +12 -0
  37. package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -1
  38. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +4 -0
  39. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -11
  40. package/dist/instance-lifecycle.d.ts +1 -1
  41. package/dist/instance-lifecycle.js +16 -1
  42. package/dist/instance-lifecycle.js.map +1 -1
  43. package/dist/instructions.js +29 -6
  44. package/dist/instructions.js.map +1 -1
  45. package/dist/kiro-history-scan.d.ts +26 -0
  46. package/dist/kiro-history-scan.js +141 -0
  47. package/dist/kiro-history-scan.js.map +1 -0
  48. package/dist/kiro-history-worker.d.ts +1 -0
  49. package/dist/kiro-history-worker.js +9 -0
  50. package/dist/kiro-history-worker.js.map +1 -0
  51. package/dist/kiro-history.d.ts +20 -0
  52. package/dist/kiro-history.js +96 -0
  53. package/dist/kiro-history.js.map +1 -0
  54. package/dist/kiro-usage-run.d.ts +2 -0
  55. package/dist/kiro-usage-run.js +4 -1
  56. package/dist/kiro-usage-run.js.map +1 -1
  57. package/dist/locale.js +67 -67
  58. package/dist/locale.js.map +1 -1
  59. package/dist/login-flows.d.ts +4 -0
  60. package/dist/login-flows.js +8 -4
  61. package/dist/login-flows.js.map +1 -1
  62. package/dist/office-levels.d.ts +4 -3
  63. package/dist/office-levels.js +3 -3
  64. package/dist/office-levels.js.map +1 -1
  65. package/dist/outbound-handlers.js +32 -12
  66. package/dist/outbound-handlers.js.map +1 -1
  67. package/dist/outbound-schemas.d.ts +14 -0
  68. package/dist/outbound-schemas.js +4 -0
  69. package/dist/outbound-schemas.js.map +1 -1
  70. package/dist/setup-i18n.js +4 -4
  71. package/dist/setup-i18n.js.map +1 -1
  72. package/dist/subagent-records.d.ts +42 -0
  73. package/dist/subagent-records.js +159 -0
  74. package/dist/subagent-records.js.map +1 -0
  75. package/dist/subagent-service.d.ts +27 -0
  76. package/dist/subagent-service.js +199 -0
  77. package/dist/subagent-service.js.map +1 -0
  78. package/dist/tool-permissions.d.ts +2 -3
  79. package/dist/tool-permissions.js +3 -3
  80. package/dist/tool-permissions.js.map +1 -1
  81. package/dist/ui/backend-signin.js +62 -62
  82. package/dist/ui/chat-commands.js +7 -0
  83. package/dist/ui/chat-store.js +9 -4
  84. package/dist/ui/chat-strings.js +18 -18
  85. package/dist/ui/fleet-cache.js +3 -3
  86. package/dist/ui/fleet-canvas.js +2 -2
  87. package/dist/ui/fleet-office-editor.js +1 -1
  88. package/dist/ui/fleet-office.js +1 -1
  89. package/dist/ui/fleet-org.js +2 -2
  90. package/dist/ui/fleet-task-card.js +1 -1
  91. package/dist/ui/fleet-task-common.js +7 -7
  92. package/dist/ui/model-picker.js +64 -0
  93. package/dist/ui/panel-chat.js +47 -16
  94. package/dist/ui/panel-fleet.js +8 -8
  95. package/dist/ui/panel-needs.js +3 -3
  96. package/dist/ui/panel-settings.js +16 -6
  97. package/dist/ui/settings-catalog.js +19 -4
  98. package/dist/ui/settings-dialogs.js +25 -8
  99. package/dist/ui/settings-guests.js +1 -1
  100. package/dist/ui/settings-registry.js +3 -1
  101. package/dist/ui/settings-strings.js +30 -26
  102. package/dist/ui/settings-update.js +69 -0
  103. package/dist/ui/shared/app-i18n.js +8 -4
  104. package/dist/ui/shared/app-shell.js +2 -0
  105. package/dist/ui/shared/app-update.js +215 -0
  106. package/dist/ui/shared/app.css +48 -2
  107. package/dist/ui/shared/instance-nav.js +1 -1
  108. package/dist/ui/shared/model-picker.css +21 -0
  109. package/dist/ui/shared/setup-host-text.js +4 -4
  110. package/dist/ui/shared/signin.js +32 -16
  111. package/dist/ui/shared/subagent-row.css +15 -0
  112. package/dist/ui/shared/view-strings.js +17 -17
  113. package/dist/ui/structured-signin.js +26 -26
  114. package/dist/ui/subagent-row.js +64 -0
  115. package/dist/ui/web-terminal/terminal.js +9 -9
  116. package/dist/update-marker.d.ts +2 -2
  117. package/dist/update-marker.js +4 -3
  118. package/dist/update-marker.js.map +1 -1
  119. package/dist/usage/providers.js +2 -2
  120. package/dist/usage/providers.js.map +1 -1
  121. package/dist/usage-rollup.d.ts +3 -0
  122. package/dist/usage-rollup.js +2 -0
  123. package/dist/usage-rollup.js.map +1 -1
  124. package/dist/web-api.d.ts +14 -0
  125. package/dist/web-api.js +216 -2
  126. package/dist/web-api.js.map +1 -1
  127. package/dist/web-auth.js +2 -1
  128. package/dist/web-auth.js.map +1 -1
  129. package/dist/web-commands.d.ts +8 -0
  130. package/dist/web-commands.js +6 -0
  131. package/dist/web-commands.js.map +1 -1
  132. package/dist/web-update.d.ts +77 -0
  133. package/dist/web-update.js +102 -0
  134. package/dist/web-update.js.map +1 -0
  135. package/package.json +2 -2
package/dist/web-api.js CHANGED
@@ -453,6 +453,131 @@ function handleAppIcon(req, res, url, ctx, method) {
453
453
  });
454
454
  return true;
455
455
  }
456
+ /**
457
+ * M-2738 (#3332): updating AgEnD from the web.
458
+ * GET /ui/update { admin, current, offer?, checked_at?, check_failed?, progress?, now } — an admin session; a
459
+ * read-only session gets { admin: false, current } (its stale-tab reload line)
460
+ * POST /ui/update/check look now (one a minute) → the GET's answer
461
+ * POST /ui/update/start { confirm: "update-agend" } + Idempotency-Key → 202 { started } (the progress is the GET's)
462
+ * GET /ui/update/log { text, error } — the updater's own words, for the failure's "full log"
463
+ * Signed-in sessions only (never the CLI's token, a guest or the public link: none of these is a public route); an
464
+ * admin's for all but the version. Asked again once a body is in.
465
+ */
466
+ function handleWebUpdate(req, res, url, ctx, path, method) {
467
+ const host = ctx.webUpdate;
468
+ if (!host) {
469
+ json(res, 404, { error: "not found" });
470
+ return true;
471
+ }
472
+ const routes = { "/ui/update": "GET", "/ui/update/check": "POST", "/ui/update/start": "POST", "/ui/update/log": "GET" };
473
+ if (!routes[path]) {
474
+ json(res, 404, { error: "not found" });
475
+ return true;
476
+ }
477
+ if (routes[path] !== method) {
478
+ res.setHeader("Allow", routes[path]);
479
+ json(res, 405, { error: "method not allowed" });
480
+ return true;
481
+ }
482
+ if (gatewayRequestContext(req)) {
483
+ json(res, 404, { error: "not found" });
484
+ return true;
485
+ }
486
+ res.setHeader("Cache-Control", "no-store");
487
+ const who = () => {
488
+ const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
489
+ if (verdict.kind !== "allow")
490
+ return { status: 401, error: WEB_TOKEN_INVALID_MESSAGE };
491
+ if (verdict.via !== "session" || !verdict.session || verdict.session.tier === "guest")
492
+ return { status: 403, error: "update_needs_a_signed_in_person" };
493
+ const owner = verdict.session.owner;
494
+ return { admin: verdict.session.tier === "admin", person: owner ? webPersonKey(owner) : "admin-session" };
495
+ };
496
+ const view = (admin) => {
497
+ const st = host.updateState();
498
+ if (!admin)
499
+ return { admin: false, current: st.current };
500
+ const progress = host.updateProgress();
501
+ return { admin: true, current: st.current, offer: st.offer, checked_at: st.checkedAt, check_failed: st.checkFailed, progress, now: Date.now() };
502
+ };
503
+ const first = who();
504
+ if ("status" in first) {
505
+ json(res, first.status, { error: first.error });
506
+ return true;
507
+ }
508
+ if (path === "/ui/update") {
509
+ json(res, 200, view(first.admin));
510
+ return true;
511
+ }
512
+ if (!first.admin) {
513
+ json(res, 403, { error: "update_needs_an_admin_session" });
514
+ return true;
515
+ }
516
+ if (path === "/ui/update/log") {
517
+ const l = host.updateLog();
518
+ json(res, 200, { text: l.text, error: l.error });
519
+ return true;
520
+ }
521
+ (async () => {
522
+ let body = {};
523
+ try {
524
+ body = await parseBody(req);
525
+ }
526
+ catch {
527
+ if (path === "/ui/update/start") {
528
+ json(res, 400, { error: "Invalid JSON" });
529
+ return;
530
+ }
531
+ }
532
+ if (!permitWebContinuation(req, res, ctx) || res.destroyed)
533
+ return;
534
+ const now = who();
535
+ if ("status" in now) {
536
+ json(res, now.status, { error: now.error });
537
+ return;
538
+ }
539
+ if (!now.admin) {
540
+ json(res, 403, { error: "update_needs_an_admin_session" });
541
+ return;
542
+ }
543
+ if (path === "/ui/update/check") {
544
+ const r = await host.checkUpdateNow();
545
+ if (!r.ok) {
546
+ json(res, r.status, { error: r.error });
547
+ return;
548
+ }
549
+ json(res, 200, view(true));
550
+ return;
551
+ }
552
+ const header = req.headers["idempotency-key"];
553
+ const key = typeof header === "string" ? header : "";
554
+ if (!/^[A-Za-z0-9_.:-]{8,128}$/.test(key)) {
555
+ json(res, 400, { error: "Idempotency-Key required (8-128 chars of [A-Za-z0-9_.:-])" });
556
+ return;
557
+ }
558
+ // A literal, not a boolean: a stray `true` in a replayed body never means "update AgEnD".
559
+ if (body.confirm !== "update-agend") {
560
+ json(res, 400, { error: 'confirm must be the literal "update-agend"' });
561
+ return;
562
+ }
563
+ // Prism #3505 P2-3: the session that asked, still current and still an admin's, right up to the updater's launch.
564
+ const stillAllowed = () => { const v = who(); return !("status" in v) && v.admin && v.person === now.person; };
565
+ const r = await host.startWebUpdate(key, now.person, stillAllowed);
566
+ if (!r.ok) {
567
+ json(res, r.status, { error: r.error });
568
+ return;
569
+ }
570
+ ctx.logger.info({ person: now.person }, "web: update started");
571
+ json(res, 202, { started: true });
572
+ })().catch((err) => {
573
+ ctx.logger.error({ err: err.message }, "Web update request failed");
574
+ try {
575
+ json(res, 500, { error: "update_request_failed" });
576
+ }
577
+ catch { /* already answered */ }
578
+ });
579
+ return true;
580
+ }
456
581
  /**
457
582
  * #2636: Office share links — GET /ui/office-share (the open ones, and whether this fleet offers them), POST { office,
458
583
  * minutes?, text?, theme? } (a new one; #2715 theme "auto" | "light" | "dark"; answers its URL once its tunnel is up, or why not), DELETE /ui/office-share/<id|all>.
@@ -1921,6 +2046,52 @@ export function handleWebRequest(req, res, url, ctx) {
1921
2046
  }
1922
2047
  // ── Backend detection ─────────────────────────────────
1923
2048
  // #2072: the model a Settings field offers — the cached catalog of that backend (that instance's account's). Read only.
2049
+ if (method === "POST" && path === "/ui/models/refresh") {
2050
+ const admission = adminAdmissionOf(req, url, ctx);
2051
+ if (!admission) {
2052
+ json(res, 403, { error: "admin_required" });
2053
+ return true;
2054
+ }
2055
+ void (async () => {
2056
+ let body;
2057
+ try {
2058
+ body = await parseBody(req);
2059
+ }
2060
+ catch {
2061
+ json(res, 400, { error: "Invalid JSON" });
2062
+ return;
2063
+ }
2064
+ if (!permitWebContinuation(req, res, ctx))
2065
+ return;
2066
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2067
+ json(res, 403, { error: "admin_required" });
2068
+ return;
2069
+ }
2070
+ if (!body || Array.isArray(body) || typeof body !== "object" || Object.keys(body).some(k => k !== "backend" && k !== "instance")) {
2071
+ json(res, 400, { error: "invalid model target" });
2072
+ return;
2073
+ }
2074
+ const backend = body.backend, instance = body.instance ?? null;
2075
+ if (typeof backend !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(backend) || (instance !== null && (typeof instance !== "string" || !isSafeInstanceName(instance)))) {
2076
+ json(res, 400, { error: "invalid model target" });
2077
+ return;
2078
+ }
2079
+ if (!ctx.refreshModelCatalogFor) {
2080
+ json(res, 503, { error: "model_refresh_unavailable" });
2081
+ return;
2082
+ }
2083
+ const result = await ctx.refreshModelCatalogFor(backend, instance);
2084
+ if (!permitWebContinuation(req, res, ctx))
2085
+ return;
2086
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2087
+ json(res, 403, { error: "admin_required" });
2088
+ return;
2089
+ }
2090
+ json(res, 200, { backend, ...result });
2091
+ })().catch(() => { if (!res.headersSent)
2092
+ json(res, 500, { error: "model_refresh_failed" }); });
2093
+ return true;
2094
+ }
1924
2095
  if (method === "GET" && path === "/ui/models") {
1925
2096
  const backend = url.searchParams.get("backend") ?? "";
1926
2097
  const instance = url.searchParams.get("instance");
@@ -2137,6 +2308,38 @@ export function handleWebRequest(req, res, url, ctx) {
2137
2308
  // ── #1218: the Log tab ─────────────────────────────────
2138
2309
  // An instance's steps, read on demand from its own transcript (log-service.ts). Read-only, and offered on the public
2139
2310
  // link on purpose (the user's decision): the same masking applies to every viewer. Passive (web-auth.ts).
2311
+ // Deliberately absent from public gateway, guest, View and Hub projections.
2312
+ if (method === "GET" && path === "/ui/subagents") {
2313
+ const admission = adminAdmissionOf(req, url, ctx), name = url.searchParams.get("instance") ?? "";
2314
+ if (!admission || gatewayRequestContext(req) || guestRequestOf(req)) {
2315
+ json(res, 403, { error: "admin_only" });
2316
+ return true;
2317
+ }
2318
+ if (!name || name.length > 128 || !safeInstanceSegment(name)) {
2319
+ json(res, 400, { error: "invalid instance" });
2320
+ return true;
2321
+ }
2322
+ if (!ctx.subagentRuns) {
2323
+ json(res, 404, { error: "not available" });
2324
+ return true;
2325
+ }
2326
+ void ctx.subagentRuns(name).then(answer => {
2327
+ if (res.destroyed)
2328
+ return;
2329
+ if (adminAdmissionOf(req, url, ctx) !== admission || gatewayRequestContext(req) || guestRequestOf(req)) {
2330
+ json(res, 403, { error: "admin_only" });
2331
+ return;
2332
+ }
2333
+ if (answer.status === "busy") {
2334
+ res.setHeader("Retry-After", "2");
2335
+ json(res, 429, { error: "busy" });
2336
+ return;
2337
+ }
2338
+ json(res, 200, answer);
2339
+ }).catch(() => { if (!res.destroyed)
2340
+ json(res, 503, { error: "unavailable" }); });
2341
+ return true;
2342
+ }
2140
2343
  if (method === "GET" && path === "/ui/steps") {
2141
2344
  const p = url.searchParams;
2142
2345
  const instance = p.get("instance") ?? "";
@@ -2876,6 +3079,8 @@ export function handleWebRequest(req, res, url, ctx) {
2876
3079
  // #2308: the app icon (handleAppIcon: its state for a signed-in person; changing it, an admin's session only).
2877
3080
  if (path === "/ui/app-icon")
2878
3081
  return handleAppIcon(req, res, url, ctx, method);
3082
+ if (path === "/ui/update" || path.startsWith("/ui/update/"))
3083
+ return handleWebUpdate(req, res, url, ctx, path, method);
2879
3084
  // #1629 r4-5: mods — a person's import, uninstall and export (handleMods: sessions only, never the public link).
2880
3085
  if (path === "/ui/mods" || path.startsWith("/ui/mods/"))
2881
3086
  return handleMods(req, res, url, ctx, path, method);
@@ -3056,6 +3261,10 @@ export function handleWebRequest(req, res, url, ctx) {
3056
3261
  json(res, 400, { error: "args too long" });
3057
3262
  return;
3058
3263
  }
3264
+ if (body.action !== undefined && !["refresh", "more", "refreshAll"].includes(body.action)) {
3265
+ json(res, 400, { error: "invalid model action" });
3266
+ return;
3267
+ }
3059
3268
  if (body.confirm !== undefined && !(typeof body.confirm === "string" && /^[0-9a-f]{32}$/.test(body.confirm))) {
3060
3269
  json(res, 400, { error: "invalid confirmation" });
3061
3270
  return;
@@ -3089,7 +3298,9 @@ export function handleWebRequest(req, res, url, ctx) {
3089
3298
  }
3090
3299
  try {
3091
3300
  const { authority } = confirmAfterBody(arrival, webAuthorityOf(req, url, ctx, instance));
3092
- const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
3301
+ const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm, ...(body.action ? { action: body.action } : {}) }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
3302
+ if (!stillAuthorized(req, res, url, ctx))
3303
+ return;
3093
3304
  json(res, r.status, r.body);
3094
3305
  }
3095
3306
  finally {
@@ -4676,7 +4887,10 @@ function shellBodyTag(req, ctx, mode, viewer) {
4676
4887
  ownerCssState = "unknown";
4677
4888
  }
4678
4889
  const attr = (v) => String(v ?? "").replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
4679
- return `<body data-mode="${mode}"${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
4890
+ const admission = evaluateWebRequest(req, new URL(req.url ?? "/", "http://localhost"), ctx.webToken ?? null, ctx.webSessions, { touch: false });
4891
+ const childMark = mode === "full" && !gatewayRequestContext(req) && !viewer?.guest && admission.kind === "allow"
4892
+ && (admission.via !== "session" || admission.session.tier === "admin");
4893
+ return `<body data-mode="${mode}"${childMark ? ' data-subagents="1"' : ""}${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
4680
4894
  + ` data-preview-boot="${attr(p?.previewOrigin ? p.boot : "")}" data-preview-reason="${attr(p ? p.reason : "Previews are not available on this fleet.")}"`
4681
4895
  // #1554: no availability asked (the public link, or not the full app) still says why, in the page's language.
4682
4896
  + ` data-preview-reason-code="${attr(p ? p.code ?? "" : gatewayRequestContext(req) ? "publicLink" : "notOffered")}"`