@songsid/agend 2.2.0-beta.9 → 2.2.1

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 (226) hide show
  1. package/README.md +40 -24
  2. package/README.zh-TW.md +40 -24
  3. package/dist/agent-endpoint.js +3 -0
  4. package/dist/agent-endpoint.js.map +1 -1
  5. package/dist/agent-whats-new.js +7 -1
  6. package/dist/agent-whats-new.js.map +1 -1
  7. package/dist/auth-api.d.ts +3 -1
  8. package/dist/auth-api.js +15 -1
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/antigravity.d.ts +33 -0
  11. package/dist/backend/antigravity.js +126 -18
  12. package/dist/backend/antigravity.js.map +1 -1
  13. package/dist/backend/claude-code.d.ts +3 -0
  14. package/dist/backend/claude-code.js +9 -0
  15. package/dist/backend/claude-code.js.map +1 -1
  16. package/dist/backend/codex-metadata.d.ts +33 -0
  17. package/dist/backend/codex-metadata.js +122 -18
  18. package/dist/backend/codex-metadata.js.map +1 -1
  19. package/dist/backend/codex.d.ts +3 -0
  20. package/dist/backend/codex.js +17 -1
  21. package/dist/backend/codex.js.map +1 -1
  22. package/dist/backend/effort-metadata.d.ts +37 -1
  23. package/dist/backend/effort-metadata.js +86 -15
  24. package/dist/backend/effort-metadata.js.map +1 -1
  25. package/dist/backend/grok.d.ts +3 -0
  26. package/dist/backend/grok.js +9 -0
  27. package/dist/backend/grok.js.map +1 -1
  28. package/dist/backend/kiro.d.ts +3 -1
  29. package/dist/backend/kiro.js +7 -3
  30. package/dist/backend/kiro.js.map +1 -1
  31. package/dist/backend/launch-effort.d.ts +61 -0
  32. package/dist/backend/launch-effort.js +170 -0
  33. package/dist/backend/launch-effort.js.map +1 -0
  34. package/dist/backend/types.d.ts +24 -0
  35. package/dist/backend/types.js +12 -1
  36. package/dist/backend/types.js.map +1 -1
  37. package/dist/backend-command.d.ts +91 -0
  38. package/dist/backend-command.js +122 -0
  39. package/dist/backend-command.js.map +1 -0
  40. package/dist/channel/adapters/discord.d.ts +12 -0
  41. package/dist/channel/adapters/discord.js +49 -2
  42. package/dist/channel/adapters/discord.js.map +1 -1
  43. package/dist/channel/adapters/telegram.d.ts +18 -0
  44. package/dist/channel/adapters/telegram.js +24 -3
  45. package/dist/channel/adapters/telegram.js.map +1 -1
  46. package/dist/channel/mcp-tools.js +2 -0
  47. package/dist/channel/mcp-tools.js.map +1 -1
  48. package/dist/channel/tool-router.d.ts +2 -0
  49. package/dist/channel/tool-router.js +1 -1
  50. package/dist/channel/tool-router.js.map +1 -1
  51. package/dist/channel/types.d.ts +16 -0
  52. package/dist/cli.js +124 -24
  53. package/dist/cli.js.map +1 -1
  54. package/dist/command-table.d.ts +2 -2
  55. package/dist/command-table.js +5 -2
  56. package/dist/command-table.js.map +1 -1
  57. package/dist/compact-watch.d.ts +86 -0
  58. package/dist/compact-watch.js +288 -0
  59. package/dist/compact-watch.js.map +1 -0
  60. package/dist/config-validator.js +39 -0
  61. package/dist/config-validator.js.map +1 -1
  62. package/dist/config.d.ts +1 -0
  63. package/dist/config.js +2 -1
  64. package/dist/config.js.map +1 -1
  65. package/dist/daemon.d.ts +11 -0
  66. package/dist/daemon.js +179 -18
  67. package/dist/daemon.js.map +1 -1
  68. package/dist/delivery-outbox.d.ts +8 -1
  69. package/dist/delivery-outbox.js +6 -2
  70. package/dist/delivery-outbox.js.map +1 -1
  71. package/dist/doctor.js +7 -0
  72. package/dist/doctor.js.map +1 -1
  73. package/dist/fleet-context.d.ts +7 -0
  74. package/dist/fleet-manager.d.ts +158 -9
  75. package/dist/fleet-manager.js +827 -118
  76. package/dist/fleet-manager.js.map +1 -1
  77. package/dist/forged-envelope-scan.d.ts +4 -3
  78. package/dist/forged-envelope-scan.js +4 -3
  79. package/dist/forged-envelope-scan.js.map +1 -1
  80. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -1
  81. package/dist/install-lock.d.ts +18 -1
  82. package/dist/install-lock.js +30 -3
  83. package/dist/install-lock.js.map +1 -1
  84. package/dist/instance-avatar.d.ts +5 -4
  85. package/dist/instance-avatar.js +12 -8
  86. package/dist/instance-avatar.js.map +1 -1
  87. package/dist/instructions.js +2 -2
  88. package/dist/instructions.js.map +1 -1
  89. package/dist/kiro-compact-pane.d.ts +38 -0
  90. package/dist/kiro-compact-pane.js +57 -0
  91. package/dist/kiro-compact-pane.js.map +1 -0
  92. package/dist/launchd-handoff.d.ts +43 -0
  93. package/dist/launchd-handoff.js +56 -0
  94. package/dist/launchd-handoff.js.map +1 -0
  95. package/dist/locale.js +202 -30
  96. package/dist/locale.js.map +1 -1
  97. package/dist/log-service.js +10 -2
  98. package/dist/log-service.js.map +1 -1
  99. package/dist/login-shell.d.ts +21 -0
  100. package/dist/login-shell.js +98 -0
  101. package/dist/login-shell.js.map +1 -0
  102. package/dist/outbound-handlers.d.ts +27 -0
  103. package/dist/outbound-handlers.js +120 -36
  104. package/dist/outbound-handlers.js.map +1 -1
  105. package/dist/outbound-schemas.d.ts +12 -0
  106. package/dist/outbound-schemas.js +15 -4
  107. package/dist/outbound-schemas.js.map +1 -1
  108. package/dist/provider-probe.d.ts +29 -0
  109. package/dist/provider-probe.js +198 -2
  110. package/dist/provider-probe.js.map +1 -1
  111. package/dist/public-web-gateway.d.ts +2 -0
  112. package/dist/public-web-gateway.js +11 -1
  113. package/dist/public-web-gateway.js.map +1 -1
  114. package/dist/quickstart-api.d.ts +1 -1
  115. package/dist/quickstart-api.js +8 -6
  116. package/dist/quickstart-api.js.map +1 -1
  117. package/dist/quickstart.d.ts +12 -0
  118. package/dist/quickstart.js +36 -6
  119. package/dist/quickstart.js.map +1 -1
  120. package/dist/reply-buttons-controller.d.ts +86 -5
  121. package/dist/reply-buttons-controller.js +271 -7
  122. package/dist/reply-buttons-controller.js.map +1 -1
  123. package/dist/reply-buttons.d.ts +48 -3
  124. package/dist/reply-buttons.js +105 -10
  125. package/dist/reply-buttons.js.map +1 -1
  126. package/dist/reply-polls.d.ts +85 -0
  127. package/dist/reply-polls.js +154 -0
  128. package/dist/reply-polls.js.map +1 -0
  129. package/dist/restart-guard.d.ts +6 -3
  130. package/dist/restart-guard.js +6 -3
  131. package/dist/restart-guard.js.map +1 -1
  132. package/dist/restart-progress.d.ts +0 -2
  133. package/dist/restart-progress.js +0 -2
  134. package/dist/restart-progress.js.map +1 -1
  135. package/dist/sd-notify.d.ts +22 -1
  136. package/dist/sd-notify.js +63 -10
  137. package/dist/sd-notify.js.map +1 -1
  138. package/dist/service-activation.d.ts +15 -7
  139. package/dist/service-activation.js +42 -26
  140. package/dist/service-activation.js.map +1 -1
  141. package/dist/service-installer.d.ts +24 -0
  142. package/dist/service-installer.js +49 -1
  143. package/dist/service-installer.js.map +1 -1
  144. package/dist/service-plan.d.ts +11 -0
  145. package/dist/service-plan.js +23 -0
  146. package/dist/service-plan.js.map +1 -1
  147. package/dist/systemd-peer-bus.d.ts +95 -0
  148. package/dist/systemd-peer-bus.js +430 -0
  149. package/dist/systemd-peer-bus.js.map +1 -0
  150. package/dist/systemd-runtime.d.ts +27 -1
  151. package/dist/systemd-runtime.js +69 -7
  152. package/dist/systemd-runtime.js.map +1 -1
  153. package/dist/tool-permissions.js +3 -3
  154. package/dist/tool-permissions.js.map +1 -1
  155. package/dist/topic-commands.d.ts +68 -2
  156. package/dist/topic-commands.js +141 -27
  157. package/dist/topic-commands.js.map +1 -1
  158. package/dist/transcript-jsonl.d.ts +7 -2
  159. package/dist/transcript-jsonl.js +13 -7
  160. package/dist/transcript-jsonl.js.map +1 -1
  161. package/dist/transcript-sources.js +6 -1
  162. package/dist/transcript-sources.js.map +1 -1
  163. package/dist/types.d.ts +8 -0
  164. package/dist/ui/chat-commands.js +1 -0
  165. package/dist/ui/chat-render.js +55 -10
  166. package/dist/ui/chat-store.js +69 -5
  167. package/dist/ui/chat-strings.js +28 -16
  168. package/dist/ui/chat-thread.js +132 -14
  169. package/dist/ui/chat-tour.js +17 -14
  170. package/dist/ui/panel-chat.js +16 -10
  171. package/dist/ui/panel-fleet.js +15 -2
  172. package/dist/ui/panel-log.js +4 -4
  173. package/dist/ui/panel-needs.js +10 -7
  174. package/dist/ui/panel-settings.js +58 -7
  175. package/dist/ui/settings-dialogs.js +11 -6
  176. package/dist/ui/settings-model.js +3 -1
  177. package/dist/ui/settings-strings.js +24 -10
  178. package/dist/ui/settings-token.js +7 -0
  179. package/dist/ui/settings-wizard.js +5 -3
  180. package/dist/ui/shared/app-i18n.js +1 -1
  181. package/dist/ui/shared/app-stream.js +4 -1
  182. package/dist/ui/shared/app.css +52 -10
  183. package/dist/ui/shared/header-tools.js +34 -14
  184. package/dist/ui/shared/instance-switch.js +5 -2
  185. package/dist/ui/shared/panel-view.js +15 -4
  186. package/dist/ui/shared/signin.js +15 -9
  187. package/dist/ui/shared/ui-icons.js +1 -0
  188. package/dist/ui/shared/view-strings.js +10 -2
  189. package/dist/ui/signin.html +8 -3
  190. package/dist/update-check.d.ts +31 -0
  191. package/dist/update-check.js +47 -0
  192. package/dist/update-check.js.map +1 -1
  193. package/dist/update-launch.d.ts +48 -1
  194. package/dist/update-launch.js +159 -5
  195. package/dist/update-launch.js.map +1 -1
  196. package/dist/usage/providers.d.ts +28 -8
  197. package/dist/usage/providers.js +96 -41
  198. package/dist/usage/providers.js.map +1 -1
  199. package/dist/view-api.js +26 -9
  200. package/dist/view-api.js.map +1 -1
  201. package/dist/web-api.d.ts +44 -2
  202. package/dist/web-api.js +265 -57
  203. package/dist/web-api.js.map +1 -1
  204. package/dist/web-chat-history.d.ts +26 -1
  205. package/dist/web-chat-history.js +47 -8
  206. package/dist/web-chat-history.js.map +1 -1
  207. package/dist/web-commands.d.ts +39 -3
  208. package/dist/web-commands.js +22 -5
  209. package/dist/web-commands.js.map +1 -1
  210. package/dist/web-login.d.ts +14 -0
  211. package/dist/web-login.js +4 -2
  212. package/dist/web-login.js.map +1 -1
  213. package/dist/web-prefs.d.ts +18 -0
  214. package/dist/web-prefs.js +36 -4
  215. package/dist/web-prefs.js.map +1 -1
  216. package/dist/web-profile.d.ts +32 -0
  217. package/dist/web-profile.js +132 -0
  218. package/dist/web-profile.js.map +1 -0
  219. package/dist/web-session.d.ts +14 -0
  220. package/dist/web-session.js +10 -0
  221. package/dist/web-session.js.map +1 -1
  222. package/dist/web-upload.d.ts +119 -4
  223. package/dist/web-upload.js +252 -39
  224. package/dist/web-upload.js.map +1 -1
  225. package/launcher/install-admission.cjs +61 -6
  226. package/package.json +3 -3
@@ -1,3 +1,46 @@
1
+ /** Chat updates must survive the fleet's service cgroup being stopped (#1490 row 37). */
2
+ import { type ChildProcess } from "node:child_process";
3
+ /** How many bytes to cap the update.log file at (across all runs). */
4
+ export declare const UPDATE_LOG_FILE_CAP: number;
5
+ /**
6
+ * Path of the update log file (mode 0600; raw updater output is written directly — secrets are
7
+ * masked only when extracting the short cause shown in chat; the file itself is owner-readable only).
8
+ */
9
+ export declare function updateLogPath(dataDir: string): string;
10
+ /**
11
+ * Extract a short human-readable cause from raw updater output.
12
+ * #1947: AgEnD's own install refusal first — the postinstall's "AgEnD cannot be installed here: …" or the preinstall's
13
+ * "AgEnD 2.2 needs Node …" — which npm prints after its `code`/`path` lines (prefixed `npm error`), so it was never
14
+ * shown. Then the last `npm ERR!`/`npm error` summary line or the last `✗` line.
15
+ * Falls back to the last non-blank line. Masks secrets and caps at ~300 chars.
16
+ */
17
+ export declare function extractUpdateCause(output: string): string | null;
18
+ /**
19
+ * #1829: the one-line fix for a failure AgEnD knows, from this run's output (a small lookup; anything else: null).
20
+ * - `agendGone`: the launched `agend` is no longer there (an install that removed it and did not put it back).
21
+ * - npm `ENOTEMPTY` on its rename: a staging directory left by an interrupted install. npm names the same one on every
22
+ * retry, so the retry fails the same way until it is removed — only that exact directory, and only when it is one of
23
+ * AgEnD's own (`@songsid/.agend…`), never a pattern.
24
+ * - "systemd does not know …": the activation proof could not read the user manager (#1804): the one-time manual hop.
25
+ */
26
+ export declare function updateFixHint(output: string, opts?: {
27
+ agendGone?: boolean;
28
+ }): string | null;
29
+ /**
30
+ * Rotate the log file if needed, write a run header, and return an open file descriptor
31
+ * for the child process to write to directly — not a pipe.
32
+ *
33
+ * Using an fd instead of a pipe means the updater can keep writing after the fleet process
34
+ * that spawned it has been stopped: there is no read end to close, so no EPIPE.
35
+ * The caller must closeSync(fd) after spawn so the parent's copy of the fd is released.
36
+ *
37
+ * Returns `null` when the log file cannot be opened (dataDir unwritable, disk full, etc.).
38
+ * In that case the caller should fall back to `stdio: "ignore"` and omit the log note.
39
+ */
40
+ export declare function openUpdateLog(logPath: string, header: string): {
41
+ fd: number;
42
+ offset: number;
43
+ } | null;
1
44
  export interface UpdateLaunchDeps {
2
45
  platform: string;
3
46
  cgroup(): Promise<string>;
@@ -19,4 +62,8 @@ export type UpdateLaunch = {
19
62
  /** Same UID, no privileged or remote manager, no credentials in argv. No unsafe detached fallback. */
20
63
  export declare function resolveUpdateLaunch(agend: string, deps?: UpdateLaunchDeps): Promise<UpdateLaunch>;
21
64
  /** Spawn/manager refusal and nonzero updater exit are visible; exit 75 is the existing pending hand-off. */
22
- export declare function watchUpdateLaunch(child: Pick<import("node:child_process").ChildProcess, "once">, fail: (message: string) => void): void;
65
+ export declare function watchUpdateLaunch(child: Pick<ChildProcess, "once">, fail: (message: string) => void, logPath?: string,
66
+ /** Byte offset into the log file at which this run's output begins. */
67
+ logOffset?: number,
68
+ /** The `agend` the updater runs: there at launch and gone after a failure → reinstalling is the fix (#1829). */
69
+ agendPath?: string): void;
@@ -1,9 +1,147 @@
1
1
  /** Chat updates must survive the fleet's service cgroup being stopped (#1490 row 37). */
2
2
  import { execFile } from "node:child_process";
3
3
  import { randomBytes } from "node:crypto";
4
+ import { appendFileSync, existsSync, fchmodSync, openSync, readFileSync, statSync, writeFileSync } from "node:fs";
4
5
  import { readFile } from "node:fs/promises";
6
+ import { basename, dirname, isAbsolute, join } from "node:path";
5
7
  import { promisify } from "node:util";
6
8
  import { updateCommand } from "./update-dispatch.js";
9
+ import { maskSecrets } from "./log-steps.js";
10
+ import { t } from "./locale.js";
11
+ /** How many bytes to read from the tail of the log when extracting a cause after the updater exits. */
12
+ const CAUSE_TAIL_BYTES = 8 * 1024;
13
+ /** How many bytes to cap the update.log file at (across all runs). */
14
+ export const UPDATE_LOG_FILE_CAP = 400 * 1024;
15
+ /**
16
+ * Path of the update log file (mode 0600; raw updater output is written directly — secrets are
17
+ * masked only when extracting the short cause shown in chat; the file itself is owner-readable only).
18
+ */
19
+ export function updateLogPath(dataDir) {
20
+ return join(dataDir, "update.log");
21
+ }
22
+ /**
23
+ * Extract a short human-readable cause from raw updater output.
24
+ * #1947: AgEnD's own install refusal first — the postinstall's "AgEnD cannot be installed here: …" or the preinstall's
25
+ * "AgEnD 2.2 needs Node …" — which npm prints after its `code`/`path` lines (prefixed `npm error`), so it was never
26
+ * shown. Then the last `npm ERR!`/`npm error` summary line or the last `✗` line.
27
+ * Falls back to the last non-blank line. Masks secrets and caps at ~300 chars.
28
+ */
29
+ export function extractUpdateCause(output) {
30
+ // Lines starting with --- are log headers, not updater output.
31
+ const lines = output.split("\n").map(l => l.trimEnd()).filter(l => Boolean(l) && !l.startsWith("---"));
32
+ if (!lines.length)
33
+ return null;
34
+ const refusal = lines.map(l => /^(?:npm (?:ERR!|error)\s+)?\s*(AgEnD cannot be installed here: .+|AgEnD 2\.2 needs Node .+)$/i.exec(l)?.[1]).find(Boolean);
35
+ if (refusal)
36
+ return maskSecrets(refusal).slice(0, 300);
37
+ // npm ERR! ends with !, a non-word char: \b does not anchor here. Use (?:\s|$) instead.
38
+ const npmErrRe = /^npm (ERR!|error)(?:\s|$)/i;
39
+ const npmLines = lines.filter(l => npmErrRe.test(l));
40
+ if (npmLines.length) {
41
+ // npm 10 always ends with "A complete log of this run can be found in: …". Skip that footer.
42
+ // Prefer the first `npm error code` line plus the next for context.
43
+ const codeIdx = npmLines.findIndex(l => /^npm (ERR!|error) code\s/i.test(l));
44
+ if (codeIdx >= 0) {
45
+ const summary = [npmLines[codeIdx], npmLines[codeIdx + 1]].filter(Boolean).join(" — ");
46
+ return maskSecrets(summary).slice(0, 300);
47
+ }
48
+ const meaningful = npmLines.filter(l => !/A complete log of this run can be found in/i.test(l));
49
+ const pick = meaningful.length ? meaningful[meaningful.length - 1] : npmLines[npmLines.length - 1];
50
+ return maskSecrets(pick).slice(0, 300);
51
+ }
52
+ const cross = lines.filter(l => /^\s*[✗✕×✘]/.test(l));
53
+ if (cross.length)
54
+ return maskSecrets(cross[cross.length - 1]).slice(0, 300);
55
+ return maskSecrets(lines[lines.length - 1]).slice(0, 300);
56
+ }
57
+ /** A version or dist-tag as the updater printed it, safe to put in a suggested command; else a placeholder. */
58
+ function updateTarget(output) {
59
+ const to = /Updating AgEnD v\S+ → v(\S+?)\.\.\./.exec(output)?.[1] ?? /Updating AgEnD to (\S+?)\.\.\./.exec(output)?.[1];
60
+ return to && /^[0-9A-Za-z][0-9A-Za-z.+-]*$/.test(to) ? to : "<version>";
61
+ }
62
+ /**
63
+ * #1829: the one-line fix for a failure AgEnD knows, from this run's output (a small lookup; anything else: null).
64
+ * - `agendGone`: the launched `agend` is no longer there (an install that removed it and did not put it back).
65
+ * - npm `ENOTEMPTY` on its rename: a staging directory left by an interrupted install. npm names the same one on every
66
+ * retry, so the retry fails the same way until it is removed — only that exact directory, and only when it is one of
67
+ * AgEnD's own (`@songsid/.agend…`), never a pattern.
68
+ * - "systemd does not know …": the activation proof could not read the user manager (#1804): the one-time manual hop.
69
+ */
70
+ export function updateFixHint(output, opts = {}) {
71
+ const target = updateTarget(output);
72
+ if (opts.agendGone)
73
+ return `\`npm install -g @songsid/agend@${target}\``;
74
+ if (/^npm (?:ERR!|error) code ENOTEMPTY\b/im.test(output)) {
75
+ const named = /^npm (?:ERR!|error) dest (.+)$/im.exec(output)?.[1] ?? /ENOTEMPTY[^\n]*rename '[^'\n]+' -> '([^'\n]+)'/.exec(output)?.[1];
76
+ const ours = named && isAbsolute(named) && !/['"\s\\`$]/.test(named)
77
+ && basename(dirname(named)) === "@songsid" && /^\.agend[A-Za-z0-9._-]*$/.test(basename(named));
78
+ if (ours)
79
+ return t("update.failure.remove_staging", `\`rm -rf '${named}' && agend update\``);
80
+ return null;
81
+ }
82
+ if (/systemd does not know /.test(output))
83
+ return `\`npm i -g @songsid/agend@${target} && agend restart\``;
84
+ return null;
85
+ }
86
+ /**
87
+ * Rotate the log file if needed, write a run header, and return an open file descriptor
88
+ * for the child process to write to directly — not a pipe.
89
+ *
90
+ * Using an fd instead of a pipe means the updater can keep writing after the fleet process
91
+ * that spawned it has been stopped: there is no read end to close, so no EPIPE.
92
+ * The caller must closeSync(fd) after spawn so the parent's copy of the fd is released.
93
+ *
94
+ * Returns `null` when the log file cannot be opened (dataDir unwritable, disk full, etc.).
95
+ * In that case the caller should fall back to `stdio: "ignore"` and omit the log note.
96
+ */
97
+ export function openUpdateLog(logPath, header) {
98
+ // Rotate BEFORE opening the fd the child will use (never write to the same inode concurrently).
99
+ try {
100
+ if (existsSync(logPath) && statSync(logPath).size > UPDATE_LOG_FILE_CAP / 2) {
101
+ const old = readFileSync(logPath);
102
+ writeFileSync(logPath, old.subarray(Math.max(0, old.length - UPDATE_LOG_FILE_CAP / 2)));
103
+ }
104
+ }
105
+ catch { /* best-effort */ }
106
+ try {
107
+ appendFileSync(logPath, `${header}\n`, { mode: 0o600 });
108
+ }
109
+ catch { /* best-effort */ }
110
+ let fd;
111
+ try {
112
+ fd = openSync(logPath, "a", 0o600);
113
+ }
114
+ catch {
115
+ return null; // caller falls back to stdio: "ignore" and no log note
116
+ }
117
+ // fchmod: mode param of openSync only applies to new files; existing files keep their mode.
118
+ try {
119
+ fchmodSync(fd, 0o600);
120
+ }
121
+ catch { /* best-effort */ }
122
+ // Record the offset so readRunCause only reads this run's output, not previous runs.
123
+ const offset = (() => { try {
124
+ return statSync(logPath).size;
125
+ }
126
+ catch {
127
+ return 0;
128
+ } })();
129
+ return { fd, offset };
130
+ }
131
+ /**
132
+ * Read only this run's output from the log (from `offset`): its tail, for the cause and the fix.
133
+ * Prevents a run with no output from picking up the previous run's error as the cause.
134
+ */
135
+ function readRunTail(logPath, offset) {
136
+ try {
137
+ const buf = readFileSync(logPath);
138
+ const runBytes = buf.subarray(offset);
139
+ return runBytes.subarray(Math.max(0, runBytes.length - CAUSE_TAIL_BYTES)).toString("utf8");
140
+ }
141
+ catch {
142
+ return null;
143
+ }
144
+ }
7
145
  export const defaultUpdateLaunchDeps = {
8
146
  platform: process.platform,
9
147
  cgroup: async () => {
@@ -89,18 +227,34 @@ export async function resolveUpdateLaunch(agend, deps = defaultUpdateLaunchDeps)
89
227
  ] };
90
228
  }
91
229
  /** Spawn/manager refusal and nonzero updater exit are visible; exit 75 is the existing pending hand-off. */
92
- export function watchUpdateLaunch(child, fail) {
230
+ export function watchUpdateLaunch(child, fail, logPath,
231
+ /** Byte offset into the log file at which this run's output begins. */
232
+ logOffset,
233
+ /** The `agend` the updater runs: there at launch and gone after a failure → reinstalling is the fix (#1829). */
234
+ agendPath) {
93
235
  let reported = false;
236
+ const agendAtLaunch = agendPath !== undefined && existsSync(agendPath);
94
237
  const report = (reason) => {
95
238
  if (reported)
96
239
  return;
97
240
  reported = true;
98
- fail(`/update could not complete (${reason}). Run \`agend update\` from a host shell.`);
241
+ const tail = logPath != null && logOffset != null ? readRunTail(logPath, logOffset) : null;
242
+ const cause = tail === null ? null : extractUpdateCause(tail);
243
+ const fix = updateFixHint(tail ?? "", { agendGone: agendAtLaunch && !existsSync(agendPath) });
244
+ // The persisted marker caps this text at 300 chars: keep the action and log before raw diagnostics.
245
+ fail([
246
+ fix ? t("update.failure.fix", fix) : t("update.failure.shell"),
247
+ ...(logPath ? [t("update.failure.log", logPath)] : []),
248
+ t("update.failure.summary", reason),
249
+ ...(cause ? [t("update.failure.cause", cause)] : []),
250
+ ].join(" "));
99
251
  };
100
- child.once("error", () => report("updater launch failed"));
252
+ child.once("error", () => report(t("update.failure.launch")));
101
253
  child.once("exit", (code, signal) => {
102
- if (signal || (code !== 0 && code !== 75))
103
- report(signal ? "updater was interrupted" : `updater exited ${code ?? "without a status"}`);
254
+ if (signal || (code !== 0 && code !== 75)) {
255
+ report(signal ? t("update.failure.interrupted")
256
+ : code == null ? t("update.failure.no_status") : t("update.failure.exit", code));
257
+ }
104
258
  });
105
259
  }
106
260
  //# sourceMappingURL=update-launch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-launch.js","sourceRoot":"","sources":["../src/update-launch.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AASrD,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACvD,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,MAAM,EAAE,KAAK,IAAI,EAAE;QACjB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5G,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,IAAI,IAAI;YAAE,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC7E,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,EAAE;gBAC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CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -143,22 +143,42 @@ export interface ClaudeUsageScope {
143
143
  * always; beside profiles (`besideProfiles`), its statusline fallback leaves the profiles' instances out.
144
144
  */
145
145
  export declare function fetchClaudeUsage(storeHome?: string, scope?: ClaudeUsageScope): Promise<Omit<ProviderUsage, "id" | "name">>;
146
+ /**
147
+ * One quota bucket of `retrieveUserQuotaSummary` (agy's proto: QuotaSummaryBucket). `group` is not on the wire: it is
148
+ * the display name of the QuotaSummaryGroup the bucket came in, copied on by agyQuotaBuckets.
149
+ */
146
150
  interface AgyBucket {
147
151
  bucketId?: string;
148
152
  displayName?: string;
153
+ window?: string;
154
+ disabled?: boolean;
149
155
  remainingFraction?: number;
150
156
  resetTime?: string;
157
+ group?: string;
151
158
  }
159
+ interface AgyQuotaSummary {
160
+ groups?: {
161
+ displayName?: string;
162
+ buckets?: AgyBucket[];
163
+ }[];
164
+ buckets?: AgyBucket[];
165
+ }
166
+ /** The summary's buckets, each tagged with its group's name. The top-level list (deprecated in the proto) only counts
167
+ * when no group carries any bucket. */
168
+ export declare function agyQuotaBuckets(body: AgyQuotaSummary): AgyBucket[];
152
169
  /**
153
- * Pool the summary's buckets into at most four metrics.
170
+ * Pool the summary's buckets into one metric per pool and limit.
171
+ *
172
+ * Three payload shapes exist:
173
+ * - pooled ids (`gemini-5h`, `gemini-weekly`, `3p-5h`, `3p-weekly`), which map 1:1;
174
+ * - PER-MODEL buckets (`gemini-3.6-flash-high`, `claude-sonnet-4-6`, …), aggregated into a Gemini pool and an
175
+ * everything-else pool;
176
+ * - (#1898, agy 2026-10) named groups ("Gemini Models", "Claude and GPT Models") whose buckets are the group's
177
+ * five-hour and weekly limits. The group decides the pool; the bucket's window, id or name decides the limit.
154
178
  *
155
- * Two payload shapes exist. Older accounts report pooled ids (`gemini-5h`,
156
- * `gemini-weekly`, `3p-5h`, `3p-weekly`), which map 1:1. This machine's live
157
- * response instead lists PER-MODEL buckets (`gemini-3.6-flash-high`,
158
- * `claude-sonnet-4-6`, `gpt-oss-120b-medium`, …) — those aggregate into a
159
- * Gemini pool and an everything-else pool, keeping each pool's WORST remaining
160
- * fraction, because eleven per-model meters is noise and the binding constraint
161
- * is the one that runs out first.
179
+ * Every metric keeps the WORST remaining fraction of its buckets, because the binding constraint is the one that runs
180
+ * out first. Within one pool a bucket with a known limit is authoritative over per-model buckets; one pool never hides
181
+ * another. Disabled buckets (agy dims them, no number) are left out.
162
182
  */
163
183
  export declare function agyPoolMetrics(buckets: AgyBucket[]): UsageMetric[];
164
184
  interface AgyStoredToken {
@@ -549,42 +549,96 @@ function agyOAuthClient(env = process.env) {
549
549
  /** Refreshed bearer, cached until shortly before expiry. The CLI's token file is
550
550
  * never written back — it belongs to agy; refresh tokens are reusable. */
551
551
  let agyTokenCache = null;
552
+ /** The summary's buckets, each tagged with its group's name. The top-level list (deprecated in the proto) only counts
553
+ * when no group carries any bucket. */
554
+ export function agyQuotaBuckets(body) {
555
+ const grouped = (body.groups ?? []).flatMap(g => (g.buckets ?? []).map(b => ({ ...b, group: g.displayName?.trim() || undefined })));
556
+ return grouped.length ? grouped : (body.buckets ?? []);
557
+ }
558
+ const AGY_POOLED = {
559
+ "gemini-5h": { pool: "Gemini", window: "session" },
560
+ "gemini-weekly": { pool: "Gemini", window: "weekly" },
561
+ "3p-5h": { pool: "Claude & others", window: "session" },
562
+ "3p-weekly": { pool: "Claude & others", window: "weekly" },
563
+ };
564
+ /** The pool a bucket belongs to: its group when the summary names one (#1898), else a guess from the bucket id. */
565
+ function agyPool(b, id) {
566
+ const pooled = AGY_POOLED[id];
567
+ if (pooled)
568
+ return pooled.pool;
569
+ const group = b.group;
570
+ if (group) {
571
+ if (/gemini/i.test(group))
572
+ return "Gemini";
573
+ if (/claude|gpt|third.?party|\b3p\b/i.test(group))
574
+ return "Claude & others";
575
+ return group;
576
+ }
577
+ return id.startsWith("gemini") ? "Gemini" : "Claude & others";
578
+ }
579
+ /** The limit a bucket counts against ("Five Hour Limit", window "5h" …), or null for a per-model bucket. */
580
+ function agyWindow(b, id) {
581
+ const pooled = AGY_POOLED[id];
582
+ if (pooled)
583
+ return pooled.window;
584
+ // One source at a time, the most specific first: the bucket's own window, then its id, then — only inside a named
585
+ // group, where a per-model name ("Gemini 2.5 High") cannot occur — its display name. A word that merely appears in an
586
+ // opaque id never overrides a window the bucket states.
587
+ for (const text of [b.window, id, b.group ? b.displayName : undefined]) {
588
+ const window = text ? agyWindowOf(text) : null;
589
+ if (window)
590
+ return window;
591
+ }
592
+ return null;
593
+ }
594
+ /** "5h", "5 h", "5-hour", "5_hours", "Five Hour Limit", "session" → session; "weekly", "7d", "7 days" → weekly. */
595
+ function agyWindowOf(text) {
596
+ if (/(^|[^0-9.])5[\s_-]*h(ours?|rs?)?\b|five[\s_-]*h(ours?|rs?)\b|\bsession\b/i.test(text))
597
+ return "session";
598
+ if (/week|(^|[^0-9.])7[\s_-]*d(ays?)?\b|seven[\s_-]*days?\b/i.test(text))
599
+ return "weekly";
600
+ return null;
601
+ }
602
+ function agyLabel(pool, window) {
603
+ if (pool === "Claude & others") {
604
+ return window === "session" ? { text: "Claude & others (session)", i18n: i18n("usage.metric.agy_claude_others_session") }
605
+ : window === "weekly" ? { text: "Claude & others (weekly)", i18n: i18n("usage.metric.agy_claude_others_weekly") }
606
+ : { text: pool, i18n: i18n("usage.metric.agy_claude_others") };
607
+ }
608
+ return window === "session" ? { text: `${pool} (session)`, i18n: i18n("usage.metric.named_session", pool) }
609
+ : window === "weekly" ? { text: `${pool} (weekly)`, i18n: i18n("usage.metric.named_weekly", pool) }
610
+ : { text: pool, i18n: i18n("usage.metric.named", pool) };
611
+ }
552
612
  /**
553
- * Pool the summary's buckets into at most four metrics.
613
+ * Pool the summary's buckets into one metric per pool and limit.
554
614
  *
555
- * Two payload shapes exist. Older accounts report pooled ids (`gemini-5h`,
556
- * `gemini-weekly`, `3p-5h`, `3p-weekly`), which map 1:1. This machine's live
557
- * response instead lists PER-MODEL buckets (`gemini-3.6-flash-high`,
558
- * `claude-sonnet-4-6`, `gpt-oss-120b-medium`, …) — those aggregate into a
559
- * Gemini pool and an everything-else pool, keeping each pool's WORST remaining
560
- * fraction, because eleven per-model meters is noise and the binding constraint
561
- * is the one that runs out first.
615
+ * Three payload shapes exist:
616
+ * - pooled ids (`gemini-5h`, `gemini-weekly`, `3p-5h`, `3p-weekly`), which map 1:1;
617
+ * - PER-MODEL buckets (`gemini-3.6-flash-high`, `claude-sonnet-4-6`, …), aggregated into a Gemini pool and an
618
+ * everything-else pool;
619
+ * - (#1898, agy 2026-10) named groups ("Gemini Models", "Claude and GPT Models") whose buckets are the group's
620
+ * five-hour and weekly limits. The group decides the pool; the bucket's window, id or name decides the limit.
621
+ *
622
+ * Every metric keeps the WORST remaining fraction of its buckets, because the binding constraint is the one that runs
623
+ * out first. Within one pool a bucket with a known limit is authoritative over per-model buckets; one pool never hides
624
+ * another. Disabled buckets (agy dims them, no number) are left out.
562
625
  */
563
626
  export function agyPoolMetrics(buckets) {
564
- const POOLED = {
565
- "gemini-5h": { text: "Gemini (session)", i18n: i18n("usage.metric.named_session", "Gemini") },
566
- "gemini-weekly": { text: "Gemini (weekly)", i18n: i18n("usage.metric.named_weekly", "Gemini") },
567
- "3p-5h": { text: "Claude & others (session)", i18n: i18n("usage.metric.agy_claude_others_session") },
568
- "3p-weekly": { text: "Claude & others (weekly)", i18n: i18n("usage.metric.agy_claude_others_weekly") },
569
- };
570
- const direct = [];
571
- const pools = new Map();
627
+ const entries = new Map();
572
628
  for (const b of buckets) {
573
- if (!b.bucketId || typeof b.remainingFraction !== "number" || !Number.isFinite(b.remainingFraction))
629
+ const id = b.bucketId?.trim() || (b.group ? b.displayName?.trim() : undefined);
630
+ if (!id || b.disabled === true || typeof b.remainingFraction !== "number" || !Number.isFinite(b.remainingFraction))
574
631
  continue;
632
+ const pool = agyPool(b, id);
633
+ const window = agyWindow(b, id);
634
+ const key = `${pool}\u0000${window ?? ""}`;
575
635
  const reset = b.resetTime ?? null;
576
- const pooledLabel = POOLED[b.bucketId];
577
- if (pooledLabel) {
578
- direct.push({ label: pooledLabel.text, labelI18n: pooledLabel.i18n, type: "percent", used: (1 - b.remainingFraction) * 100, resetsAt: reset });
579
- continue;
580
- }
581
- const pool = b.bucketId.startsWith("gemini") ? "Gemini" : "Claude & others";
582
- const existing = pools.get(pool);
636
+ const existing = entries.get(key);
583
637
  if (!existing) {
584
- pools.set(pool, { fraction: b.remainingFraction, resetsAt: reset, models: 1 });
638
+ entries.set(key, { pool, window, fraction: b.remainingFraction, resetsAt: reset, models: 1 });
585
639
  continue;
586
640
  }
587
- // Count every model in the pool; track the worst separately. Replacing the
641
+ // Count every bucket in the entry; track the worst separately. Replacing the
588
642
  // whole entry on a new worst would restart the count at that bucket.
589
643
  existing.models += 1;
590
644
  if (b.remainingFraction < existing.fraction) {
@@ -592,22 +646,24 @@ export function agyPoolMetrics(buckets) {
592
646
  existing.resetsAt = reset;
593
647
  }
594
648
  }
595
- if (direct.length)
596
- return direct;
597
- return [...pools.entries()].map(([label, p]) => ({
598
- label,
599
- labelI18n: label === "Claude & others"
600
- ? i18n("usage.metric.agy_claude_others")
601
- : i18n("usage.metric.named", label),
602
- type: "percent",
603
- used: (1 - p.fraction) * 100,
604
- resetsAt: p.resetsAt,
649
+ const limited = new Set([...entries.values()].filter(e => e.window).map(e => e.pool));
650
+ const order = (w) => (w === "session" ? 0 : w === "weekly" ? 1 : 2);
651
+ const pools = [...new Set([...entries.values()].map(e => e.pool))];
652
+ return [...entries.values()]
653
+ .filter(e => e.window || !limited.has(e.pool))
654
+ .sort((a, b) => pools.indexOf(a.pool) - pools.indexOf(b.pool) || order(a.window) - order(b.window))
655
+ .map(e => {
656
+ const label = agyLabel(e.pool, e.window);
657
+ const metric = { label: label.text, labelI18n: label.i18n, type: "percent", used: (1 - e.fraction) * 100, resetsAt: e.resetsAt };
605
658
  // Which number this is: the highest usage across the pool's models. Without
606
659
  // it a flat 0% right after a weekly rollover is indistinguishable from a
607
660
  // broken reading — which is exactly how it was reported.
608
- note: `busiest of ${p.models} model${p.models === 1 ? "" : "s"}`,
609
- noteI18n: i18n(p.models === 1 ? "usage.note.busiest_model" : "usage.note.busiest_models", p.models),
610
- }));
661
+ if (!e.window || e.models > 1) {
662
+ metric.note = `busiest of ${e.models} model${e.models === 1 ? "" : "s"}`;
663
+ metric.noteI18n = i18n(e.models === 1 ? "usage.note.busiest_model" : "usage.note.busiest_models", e.models);
664
+ }
665
+ return metric;
666
+ });
611
667
  }
612
668
  /**
613
669
  * agy's token file, in either shape.
@@ -735,8 +791,7 @@ async function fetchAntigravityUsage() {
735
791
  catch {
736
792
  continue;
737
793
  }
738
- const buckets = (body.groups ?? []).flatMap(g => g.buckets ?? []);
739
- const metrics = agyPoolMetrics(buckets);
794
+ const metrics = agyPoolMetrics(agyQuotaBuckets(body ?? {}));
740
795
  return metrics.length
741
796
  ? { status: "ok", plan: null, metrics }
742
797
  : { status: "ok", plan: null, hint: "No quota information reported for this account.", hintI18n: i18n("usage.hint.no_quota"), metrics: [] };