@andorra-labs/code 0.1.17 → 0.1.19

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 (313) hide show
  1. package/dist/src/account-jev-savings.d.ts +4 -0
  2. package/dist/src/account-jev-savings.js +92 -0
  3. package/dist/src/acp-agent.js +2 -2
  4. package/dist/src/agent-execution.js +441 -53
  5. package/dist/src/agent-mcp.js +7 -1
  6. package/dist/src/agent-modifiers.js +5 -7
  7. package/dist/src/analytics.d.ts +19 -1
  8. package/dist/src/analytics.js +9 -1
  9. package/dist/src/andorra/entry.js +15 -6
  10. package/dist/src/andorra/errors.js +3 -0
  11. package/dist/src/andorra/hosted.d.ts +8 -0
  12. package/dist/src/andorra/hosted.js +22 -3
  13. package/dist/src/andorra/streams.d.ts +49 -0
  14. package/dist/src/andorra/streams.js +98 -0
  15. package/dist/src/antigravity-acp.d.ts +28 -0
  16. package/dist/src/antigravity-acp.js +150 -0
  17. package/dist/src/antigravity-terminal.d.ts +2 -0
  18. package/dist/src/antigravity-terminal.js +214 -0
  19. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  20. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  21. package/dist/src/app-server/artifact.d.ts +14 -0
  22. package/dist/src/app-server/artifact.js +46 -0
  23. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  24. package/dist/src/app-server/legal-protocol.js +16 -0
  25. package/dist/src/app-server/protocol.d.ts +34 -3
  26. package/dist/src/app-server/protocol.js +3 -1
  27. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  28. package/dist/src/app-server/telemetry-protocol.js +2 -0
  29. package/dist/src/app-server/telemetry.d.ts +38 -0
  30. package/dist/src/app-server/telemetry.js +163 -0
  31. package/dist/src/app-server/workspace.d.ts +21 -0
  32. package/dist/src/app-server/workspace.js +192 -10
  33. package/dist/src/app-server.d.ts +82 -26
  34. package/dist/src/app-server.js +1573 -417
  35. package/dist/src/attachments.d.ts +10 -0
  36. package/dist/src/attachments.js +102 -7
  37. package/dist/src/auth/AuthManager.d.ts +11 -2
  38. package/dist/src/auth/AuthManager.js +56 -13
  39. package/dist/src/auth/index.d.ts +5 -1
  40. package/dist/src/auth/index.js +8 -1
  41. package/dist/src/auth/lifecycle.d.ts +13 -0
  42. package/dist/src/auth/lifecycle.js +109 -0
  43. package/dist/src/auth/store.d.ts +1 -0
  44. package/dist/src/auth/store.js +12 -0
  45. package/dist/src/auth/types.d.ts +12 -0
  46. package/dist/src/automation-runner.js +2 -0
  47. package/dist/src/automation-service.js +7 -2
  48. package/dist/src/automation-tool.js +2 -1
  49. package/dist/src/benchmark-scores.d.ts +88 -0
  50. package/dist/src/benchmark-scores.js +302 -0
  51. package/dist/src/bridge/command.js +16 -1
  52. package/dist/src/bridge/control.d.ts +3 -1
  53. package/dist/src/bridge/control.js +9 -3
  54. package/dist/src/bridge/engines.d.ts +2 -0
  55. package/dist/src/bridge/engines.js +9 -0
  56. package/dist/src/bridge/github.d.ts +108 -0
  57. package/dist/src/bridge/github.js +378 -0
  58. package/dist/src/bridge/host-ops.d.ts +3 -3
  59. package/dist/src/bridge/host-ops.js +14 -2
  60. package/dist/src/bridge/host.d.ts +2 -0
  61. package/dist/src/bridge/host.js +70 -16
  62. package/dist/src/bridge/protocol.d.ts +1 -0
  63. package/dist/src/bridge/protocol.js +1 -0
  64. package/dist/src/browser-panel-tool.d.ts +12 -0
  65. package/dist/src/browser-panel-tool.js +30 -3
  66. package/dist/src/browser-runner.js +53 -62
  67. package/dist/src/browser-server.js +10 -4
  68. package/dist/src/browser-session.d.ts +14 -0
  69. package/dist/src/browser-session.js +57 -12
  70. package/dist/src/browser-view.d.ts +40 -1
  71. package/dist/src/browser-view.js +163 -9
  72. package/dist/src/browser-window-style.d.ts +27 -0
  73. package/dist/src/browser-window-style.js +244 -0
  74. package/dist/src/bug-report-attachments.d.ts +48 -0
  75. package/dist/src/bug-report-attachments.js +327 -0
  76. package/dist/src/bug-report.d.ts +23 -3
  77. package/dist/src/bug-report.js +72 -9
  78. package/dist/src/claude-provider.d.ts +1 -0
  79. package/dist/src/claude-provider.js +77 -36
  80. package/dist/src/cli.d.ts +1 -3
  81. package/dist/src/cli.js +245 -62
  82. package/dist/src/codex-provider.d.ts +1 -0
  83. package/dist/src/codex-provider.js +44 -8
  84. package/dist/src/coding-tools.d.ts +1 -0
  85. package/dist/src/coding-tools.js +28 -7
  86. package/dist/src/command-screens.d.ts +1 -1
  87. package/dist/src/command-screens.js +2 -2
  88. package/dist/src/commands.d.ts +9 -2
  89. package/dist/src/commands.js +69 -64
  90. package/dist/src/completion.js +13 -7
  91. package/dist/src/config.d.ts +14 -3
  92. package/dist/src/config.js +57 -17
  93. package/dist/src/context-budget.d.ts +11 -2
  94. package/dist/src/context-budget.js +38 -4
  95. package/dist/src/context-compaction.d.ts +10 -8
  96. package/dist/src/context-compaction.js +23 -24
  97. package/dist/src/deadline.js +1 -1
  98. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  99. package/dist/src/decision/DecisionManager.d.ts +16 -0
  100. package/dist/src/decision/DecisionManager.js +75 -2
  101. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  102. package/dist/src/decision/applyTaskKind.js +53 -0
  103. package/dist/src/decision/applyToolMenu.js +6 -2
  104. package/dist/src/decision/hostedPolicy.js +6 -3
  105. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  106. package/dist/src/decision/optimizationPolicy.js +23 -3
  107. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
  108. package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
  109. package/dist/src/decision/providers/index.js +1 -1
  110. package/dist/src/decision/taskKind.d.ts +52 -0
  111. package/dist/src/decision/taskKind.js +76 -0
  112. package/dist/src/decision/toolFamilies.js +1 -1
  113. package/dist/src/decision/types.d.ts +3 -1
  114. package/dist/src/default-graph.js +1 -1
  115. package/dist/src/efficiency.d.ts +80 -1
  116. package/dist/src/efficiency.js +119 -4
  117. package/dist/src/effort-routing.d.ts +27 -0
  118. package/dist/src/effort-routing.js +34 -0
  119. package/dist/src/evidence.d.ts +110 -0
  120. package/dist/src/evidence.js +195 -0
  121. package/dist/src/extensions.d.ts +2 -0
  122. package/dist/src/extensions.js +30 -20
  123. package/dist/src/github-app/agent-writes.d.ts +1 -1
  124. package/dist/src/github-app/agent-writes.js +1 -1
  125. package/dist/src/github-app/client.d.ts +19 -0
  126. package/dist/src/github-app/client.js +21 -1
  127. package/dist/src/github-app/event-source.d.ts +0 -5
  128. package/dist/src/github-app/event-source.js +1 -31
  129. package/dist/src/github-app/metrics.d.ts +2 -5
  130. package/dist/src/github-app/metrics.js +2 -14
  131. package/dist/src/github-app/review-loop.d.ts +5 -5
  132. package/dist/src/github-app/review-loop.js +1 -1
  133. package/dist/src/github-app/review-node.d.ts +2 -2
  134. package/dist/src/github-app/triggers.d.ts +3 -3
  135. package/dist/src/github-names.d.ts +7 -0
  136. package/dist/src/github-names.js +7 -0
  137. package/dist/src/glob-search.d.ts +1 -0
  138. package/dist/src/glob-search.js +3 -0
  139. package/dist/src/google-provider.d.ts +5 -28
  140. package/dist/src/google-provider.js +6 -141
  141. package/dist/src/graph-editor-session.d.ts +1 -0
  142. package/dist/src/graph-editor-session.js +2 -0
  143. package/dist/src/graph-health.js +3 -1
  144. package/dist/src/graph-preview.d.ts +2 -0
  145. package/dist/src/graph-preview.js +1 -0
  146. package/dist/src/graph-runner.js +20 -14
  147. package/dist/src/graph-selection.d.ts +3 -1
  148. package/dist/src/graph-selection.js +2 -2
  149. package/dist/src/graph-server.d.ts +8 -1
  150. package/dist/src/graph-server.js +49 -12
  151. package/dist/src/graph-sync.d.ts +2 -1
  152. package/dist/src/graph-sync.js +13 -0
  153. package/dist/src/graph-ui/app.js +49 -8
  154. package/dist/src/graph-ui/index.html +1 -1
  155. package/dist/src/graphs.d.ts +23 -1
  156. package/dist/src/graphs.js +58 -7
  157. package/dist/src/grok-provider.js +17 -14
  158. package/dist/src/hardened-runtime.js +39 -25
  159. package/dist/src/jev-savings.d.ts +4 -0
  160. package/dist/src/jev-savings.js +13 -0
  161. package/dist/src/legal/client.d.ts +25 -0
  162. package/dist/src/legal/client.js +47 -0
  163. package/dist/src/legal/command.d.ts +13 -0
  164. package/dist/src/legal/command.js +98 -0
  165. package/dist/src/legal/documents.d.ts +2 -0
  166. package/dist/src/legal/documents.js +14 -0
  167. package/dist/src/legal/gate.d.ts +13 -0
  168. package/dist/src/legal/gate.js +96 -0
  169. package/dist/src/legal/manifest.d.ts +21 -0
  170. package/dist/src/legal/manifest.js +23 -0
  171. package/dist/src/legal/receipt.d.ts +13 -0
  172. package/dist/src/legal/receipt.js +137 -0
  173. package/dist/src/legal/release.d.ts +27 -0
  174. package/dist/src/legal/release.js +28 -0
  175. package/dist/src/managed-sign-in.d.ts +0 -1
  176. package/dist/src/managed-sign-in.js +0 -13
  177. package/dist/src/membership.d.ts +27 -1
  178. package/dist/src/membership.js +139 -7
  179. package/dist/src/model-health-cache.js +1 -1
  180. package/dist/src/model-metadata.js +3 -7
  181. package/dist/src/model-override.d.ts +2 -1
  182. package/dist/src/model-override.js +9 -0
  183. package/dist/src/model-pool.d.ts +99 -0
  184. package/dist/src/model-pool.js +136 -0
  185. package/dist/src/model-relay/local.js +5 -0
  186. package/dist/src/model-relay/remote.d.ts +2 -0
  187. package/dist/src/model-relay/remote.js +4 -0
  188. package/dist/src/model-tiers.d.ts +16 -1
  189. package/dist/src/model-tiers.js +31 -7
  190. package/dist/src/opencode-cli-provider.js +59 -56
  191. package/dist/src/opencode-provider.js +16 -13
  192. package/dist/src/permissions.d.ts +5 -0
  193. package/dist/src/permissions.js +7 -0
  194. package/dist/src/plan-pass.js +2 -1
  195. package/dist/src/pool-scores.d.ts +45 -0
  196. package/dist/src/pool-scores.js +40 -0
  197. package/dist/src/provider-connection.js +3 -17
  198. package/dist/src/provider-engine.d.ts +13 -1
  199. package/dist/src/provider-engine.js +116 -12
  200. package/dist/src/provider-request-error.d.ts +8 -0
  201. package/dist/src/provider-request-error.js +12 -0
  202. package/dist/src/provider-settings.d.ts +1 -1
  203. package/dist/src/provider-settings.js +36 -18
  204. package/dist/src/provider-turn-deadline.d.ts +39 -0
  205. package/dist/src/provider-turn-deadline.js +139 -0
  206. package/dist/src/providers.d.ts +8 -9
  207. package/dist/src/providers.js +211 -150
  208. package/dist/src/pull-request-merge.d.ts +1 -8
  209. package/dist/src/pull-request-merge.js +0 -4
  210. package/dist/src/pull-requests.d.ts +83 -57
  211. package/dist/src/pull-requests.js +266 -225
  212. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  213. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  214. package/dist/src/react-runtime.js +245 -71
  215. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  216. package/dist/src/reasoning-probe-cloud.js +209 -0
  217. package/dist/src/remote/engine-pool.d.ts +3 -0
  218. package/dist/src/remote/engine-pool.js +88 -21
  219. package/dist/src/remote/recovery.d.ts +6 -0
  220. package/dist/src/remote/recovery.js +37 -0
  221. package/dist/src/run-records.d.ts +13 -3
  222. package/dist/src/run-records.js +59 -34
  223. package/dist/src/runtime.d.ts +47 -2
  224. package/dist/src/runtime.js +33 -7
  225. package/dist/src/session-summary.d.ts +8 -0
  226. package/dist/src/session-summary.js +34 -0
  227. package/dist/src/sessions.d.ts +32 -0
  228. package/dist/src/sessions.js +65 -3
  229. package/dist/src/shell.js +6 -0
  230. package/dist/src/side-panel.js +36 -2
  231. package/dist/src/sign-in-detection.d.ts +1 -1
  232. package/dist/src/sign-in-detection.js +4 -10
  233. package/dist/src/sign-in-offer.js +1 -1
  234. package/dist/src/skill-commands.js +1 -1
  235. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  236. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  237. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  238. package/dist/src/skills/bundled/provenance.json +3 -3
  239. package/dist/src/subagent-run.js +50 -50
  240. package/dist/src/subscription-usage.d.ts +50 -0
  241. package/dist/src/subscription-usage.js +92 -0
  242. package/dist/src/task-checkout.d.ts +157 -0
  243. package/dist/src/task-checkout.js +628 -0
  244. package/dist/src/telemetry/access.d.ts +18 -0
  245. package/dist/src/telemetry/access.js +43 -0
  246. package/dist/src/telemetry/aggregate.d.ts +18 -2
  247. package/dist/src/telemetry/aggregate.js +22 -9
  248. package/dist/src/telemetry/capture-core.d.ts +33 -14
  249. package/dist/src/telemetry/capture-core.js +124 -25
  250. package/dist/src/telemetry/capture.d.ts +3 -2
  251. package/dist/src/telemetry/capture.js +21 -1
  252. package/dist/src/telemetry/decision-capture.js +4 -0
  253. package/dist/src/telemetry/emitter.d.ts +6 -7
  254. package/dist/src/telemetry/emitter.js +124 -29
  255. package/dist/src/telemetry/gate.d.ts +41 -2
  256. package/dist/src/telemetry/gate.js +89 -4
  257. package/dist/src/telemetry/home.d.ts +1 -0
  258. package/dist/src/telemetry/home.js +20 -0
  259. package/dist/src/telemetry/identity.d.ts +6 -3
  260. package/dist/src/telemetry/identity.js +19 -6
  261. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  262. package/dist/src/telemetry/lifecycle.js +76 -0
  263. package/dist/src/telemetry/outbox.d.ts +13 -8
  264. package/dist/src/telemetry/outbox.js +68 -12
  265. package/dist/src/telemetry/permission-command.d.ts +38 -0
  266. package/dist/src/telemetry/permission-command.js +208 -0
  267. package/dist/src/telemetry/permission.d.ts +168 -0
  268. package/dist/src/telemetry/permission.js +662 -0
  269. package/dist/src/telemetry/record-installation.d.ts +1 -0
  270. package/dist/src/telemetry/record-installation.js +9 -0
  271. package/dist/src/telemetry/region-data.d.ts +12 -0
  272. package/dist/src/telemetry/region-data.js +1314 -0
  273. package/dist/src/telemetry/region.d.ts +34 -0
  274. package/dist/src/telemetry/region.js +87 -0
  275. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  276. package/dist/src/telemetry/run-privacy.js +165 -0
  277. package/dist/src/telemetry/schema.d.ts +27 -6
  278. package/dist/src/telemetry/schema.js +109 -14
  279. package/dist/src/telemetry/state.d.ts +11 -7
  280. package/dist/src/telemetry/state.js +39 -6
  281. package/dist/src/telemetry/surface.d.ts +20 -3
  282. package/dist/src/telemetry/surface.js +71 -15
  283. package/dist/src/telemetry/uploader.d.ts +6 -11
  284. package/dist/src/telemetry/uploader.js +72 -46
  285. package/dist/src/telemetry/uploads.d.ts +5 -1
  286. package/dist/src/telemetry/uploads.js +25 -6
  287. package/dist/src/telemetry/version.d.ts +5 -0
  288. package/dist/src/telemetry/version.js +34 -0
  289. package/dist/src/telemetry/workspace.d.ts +4 -1
  290. package/dist/src/telemetry/workspace.js +18 -3
  291. package/dist/src/terminal-ui.d.ts +3 -0
  292. package/dist/src/terminal-ui.js +48 -6
  293. package/dist/src/test-edit-guard.d.ts +30 -0
  294. package/dist/src/test-edit-guard.js +167 -2
  295. package/dist/src/thinking-level-detect.d.ts +13 -0
  296. package/dist/src/thinking-level-detect.js +52 -0
  297. package/dist/src/thinking-levels.d.ts +30 -0
  298. package/dist/src/thinking-levels.js +131 -0
  299. package/dist/src/timers.d.ts +3 -0
  300. package/dist/src/todos.d.ts +2 -1
  301. package/dist/src/todos.js +24 -4
  302. package/dist/src/tool-argument-coercion.d.ts +7 -0
  303. package/dist/src/tool-argument-coercion.js +49 -0
  304. package/dist/src/tool-catalog.d.ts +2 -2
  305. package/dist/src/tool-catalog.js +1 -1
  306. package/dist/src/tools.js +67 -22
  307. package/dist/src/transcript.js +3 -2
  308. package/dist/src/types.d.ts +48 -1
  309. package/dist/src/update.js +4 -0
  310. package/dist/src/usage-analytics.d.ts +7 -0
  311. package/dist/src/usage-analytics.js +85 -13
  312. package/dist/telemetry-consent-v1 +1 -0
  313. package/package.json +97 -96
@@ -111,10 +111,44 @@ function planSection(data, width, rows) {
111
111
  if (rows < 2 || !data.todos.length)
112
112
  return [];
113
113
  const done = data.todos.filter(todo => todo.status === 'completed').length;
114
+ const budget = rows - 1;
115
+ const title = heading('Plan', width, [{ text: `${done}/${data.todos.length}`, color: GRAY }]);
116
+ if (data.todos.some(todo => todo.parentId !== undefined)) {
117
+ const overflows = data.todos.length > budget;
118
+ const room = overflows && budget > 1 ? budget - 1 : budget;
119
+ const selected = new Set();
120
+ if (overflows) {
121
+ for (const status of ['in_progress', 'pending', 'completed']) {
122
+ const limit = status === 'in_progress' ? budget : room;
123
+ for (const todo of data.todos) {
124
+ if (selected.size >= limit)
125
+ break;
126
+ if (todo.status !== status)
127
+ continue;
128
+ if (todo.parentId !== undefined)
129
+ selected.add(todo.parentId);
130
+ if (selected.size < limit)
131
+ selected.add(todo.id);
132
+ }
133
+ }
134
+ }
135
+ // Preserve the phase and sibling order in the snapshot once the priority pass selects the rows.
136
+ const visible = overflows ? data.todos.filter(todo => selected.has(todo.id)) : data.todos;
137
+ const body = visible.map(todo => {
138
+ const indent = todo.parentId === undefined ? '' : ' ';
139
+ const mark = todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○';
140
+ const markerColor = todo.status === 'in_progress' ? accentSgr() : SUBTLE;
141
+ const textColor = todo.status === 'in_progress' ? WHITE : GRAY;
142
+ return row({ text: `${indent}${mark} `, color: markerColor }, { text: clip(todo.text, width - indent.length - 2), color: textColor });
143
+ });
144
+ if (body.length < budget && visible.length < data.todos.length) {
145
+ body.push(row({ text: clip(`… ${data.todos.length - visible.length} more`, width), color: FAINT }));
146
+ }
147
+ return [title, ...body];
148
+ }
114
149
  const body = [];
115
150
  const active = data.todos.filter(todo => todo.status === 'in_progress');
116
151
  const pending = data.todos.filter(todo => todo.status === 'pending');
117
- const budget = rows - 1;
118
152
  const doneRow = done ? 1 : 0;
119
153
  const fits = active.length + doneRow + pending.length <= budget;
120
154
  const room = fits ? budget : Math.max(1, budget - 1);
@@ -135,7 +169,7 @@ function planSection(data, width, rows) {
135
169
  body.push(row({ text: clip(`… ${omitted.join(' · ')}`, width), color: FAINT }));
136
170
  if (!body.length)
137
171
  body.push(row({ text: `${done}/${data.todos.length} done`, color: GRAY }));
138
- return [heading('Plan', width, [{ text: `${done}/${data.todos.length}`, color: GRAY }]), ...body.slice(0, budget)];
172
+ return [title, ...body.slice(0, budget)];
139
173
  }
140
174
  export function panelDuration(milliseconds) {
141
175
  return formatHms(milliseconds / 1000);
@@ -1,6 +1,6 @@
1
1
  import type { Config } from './config.js';
2
2
  import type { ProviderConfig } from './providers.js';
3
- export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode", "google"];
3
+ export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"];
4
4
  export type DetectableSignInType = typeof DETECTABLE_SIGN_IN_TYPES[number];
5
5
  export declare function isDetectableSignInType(value: unknown): value is DetectableSignInType;
6
6
  export interface DetectedSignIn {
@@ -4,20 +4,20 @@ import { resolveCliExecutable } from './cli-executable.js';
4
4
  import { readCodexModels } from './codex-auth.js';
5
5
  import { resolveCodexExecutable } from './codex-executable.js';
6
6
  import { connectCodex } from './codex-rpc.js';
7
- import { GOOGLE_BASE_URL, GOOGLE_EXECUTABLE, readGoogleCatalog } from './google-provider.js';
8
7
  import { GROK_BASE_URL, GROK_EXECUTABLE, readGrokCatalog } from './grok-provider.js';
9
8
  import { OPENCODE_BASE_URL, OPENCODE_EXECUTABLE, readOpenCodeCatalog, sharedOpenCodeServer } from './opencode-cli-provider.js';
10
9
  import { uniqueProviderId } from './provider-import.js';
11
- export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode', 'google'];
10
+ // A Google subscription starts a dedicated Antigravity session.
11
+ export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode'];
12
12
  export function isDetectableSignInType(value) {
13
13
  return DETECTABLE_SIGN_IN_TYPES.includes(value);
14
14
  }
15
15
  const SIGNED_OUT = { signedIn: false, models: [] };
16
16
  const MAX_MODELS = 5000;
17
17
  const FIXED_BASE_URL = {
18
- claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL, google: GOOGLE_BASE_URL,
18
+ claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
19
19
  };
20
- const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode', google: 'Google' };
20
+ const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
21
21
  export function defaultSignInProbes() {
22
22
  const present = async (resolve) => { try {
23
23
  await resolve();
@@ -60,12 +60,6 @@ export function defaultSignInProbes() {
60
60
  const catalog = await readGrokCatalog(signal);
61
61
  return { signedIn: catalog.signedIn, models: catalog.models, ...(catalog.email ? { email: catalog.email } : {}) };
62
62
  },
63
- google: async (signal) => {
64
- if (!await present(() => resolveCliExecutable(GOOGLE_EXECUTABLE)))
65
- return SIGNED_OUT;
66
- const catalog = await readGoogleCatalog(signal);
67
- return { signedIn: catalog.signedIn, models: catalog.models };
68
- },
69
63
  opencode: async (signal) => {
70
64
  if (!await present(() => resolveCliExecutable(OPENCODE_EXECUTABLE)))
71
65
  return SIGNED_OUT;
@@ -5,7 +5,7 @@ import { changeConfigFile, configDirectory, loadConfig } from './config.js';
5
5
  import { applySignInImports, detectSignIns } from './sign-in-detection.js';
6
6
  const DETECT_TIMEOUT_MS = 8_000;
7
7
  const MAX_ATTEMPTS = 3;
8
- const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode', google: 'Google' };
8
+ const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
9
9
  const statePath = (home) => join(home, 'sign-in-offer.json');
10
10
  export async function readSignInOfferState(home = configDirectory()) {
11
11
  try {
@@ -1,5 +1,5 @@
1
1
  const BUILTIN_COMMANDS = new Set([
2
- 'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
2
+ 'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'antigravity', 'subagent', 'reasoning',
3
3
  'graph', 'codegraph', 'dashboard', 'attach', 'usage', 'permissions', 'jev',
4
4
  'feedback', 'yolo', 'tools', 'skill', 'skills', 'plugins', 'mcp', 'logout', 'status',
5
5
  'clear', 'compact', 'goal', 'help', 'exit', 'quit',
@@ -9,7 +9,7 @@ This sends a bug report about **Andorra Code itself** (the terminal app, the des
9
9
  models, tools) to the Andorra team. It is not for bugs in the user's own project: if that is what they
10
10
  describe, say so and help with the project instead.
11
11
 
12
- You send the report with the `submit_bug_report` tool. The tool shows the user the exact text and sends it
12
+ You send the report with the `submit_bug_report` tool. The tool shows the user the exact report and sends it
13
13
  only when they choose **Send report**, so you never send anything they have not read.
14
14
 
15
15
  ## Before you ask anything
@@ -23,6 +23,29 @@ only when they choose **Send report**, so you never send anything they have not
23
23
  - Use what the user already told you, in this message and earlier in the conversation. Do not ask again
24
24
  for something they have said.
25
25
 
26
+ ## Which session has the problem
27
+
28
+ A report about something that went wrong in a session carries that session's graph and a compressed
29
+ trajectory, so the team can see what ran. Find out which session it is before you write anything:
30
+
31
+ 1. Call `list_bug_report_sessions`. It returns the session this conversation is in (`current`, with its
32
+ name) and the most recent other sessions, each with an id, a name and a date. It only reads this
33
+ machine; nothing is sent.
34
+ 2. Ask the user one question, with these three answers:
35
+ - **This session**, named by the name the tool gave ("This session: Fix the login redirect").
36
+ - **Another session**. Then ask which one, offering the names from `others`. If theirs is not listed,
37
+ ask for something to recognise it by and pick the match; if none matches, say so and ask whether to
38
+ send without a session.
39
+ - **Not a session problem**: a bug in the program itself, such as the app not starting, sign-in,
40
+ settings, an update or a window that will not open.
41
+ 3. Remember the answer as the `session` you pass to `submit_bug_report`: `current`, the other session's
42
+ `id`, or `none`.
43
+
44
+ Ask even when the answer looks obvious: the user may be reporting from a fresh conversation about a
45
+ session that broke earlier. Skip the question only when they have already said which session it is. If
46
+ `current` is `null`, this conversation is not saved as a session yet, so offer only another session or
47
+ "not a session problem".
48
+
26
49
  ## The interview
27
50
 
28
51
  Ask one question at a time, in plain words, and wait for each answer. Use `ask_user` when you have it;
@@ -35,12 +58,12 @@ otherwise ask in your reply and continue when they answer. Skip a question whose
35
58
  3. **What they expected** to happen instead.
36
59
  4. **How often and since when**, if it is not already clear: every time or sometimes, and whether it
37
60
  worked before (an update, a new setting, a different model).
38
- 5. **Anything else that helps**: which model or graph, the terminal app or the desktop app, a screenshot
61
+ 5. **Anything else that helps**: which model, the terminal app or the desktop app, a screenshot
39
62
  described in words.
40
63
 
41
64
  Stop asking once you can write a report someone else could act on. Three or four questions is usual; do
42
- not go through the list for its own sake, and do not ask for the app version or operating system (the
43
- tool attaches those).
65
+ not go through the list for its own sake, and do not ask for the app version, the operating system or
66
+ which graph ran (the tool attaches those).
44
67
 
45
68
  ## Write the report
46
69
 
@@ -50,6 +73,19 @@ tool attaches those).
50
73
  "Happened once", and what changed recently if they said.
51
74
  - `steps`: numbered steps. Leave it out if the user does not know them.
52
75
  - `expected` and `actual`: one or two sentences each.
76
+ - `session`: `current`, another session's id, or `none`, from the answer above.
77
+
78
+ The graph and the trajectory are not yours to write. When `session` names a session, the tool reads them
79
+ from that session's own record and attaches:
80
+
81
+ - **The affected graph**: the graph the session last ran, as its nodes, settings, tools and routes. The
82
+ text of each instruction and prompt is replaced by its length.
83
+ - **A compressed trajectory**: each run as a short list of steps (which node ran, which tools, how long,
84
+ retries, refused completions, how the run stopped) with the first 200 characters of each error. It
85
+ holds no prompt, no model reply, no tool arguments and no output of a tool that succeeded.
86
+
87
+ Do not paste a graph, a trajectory, a log or a transcript into `description` yourself: the attachments
88
+ are bounded and cleaned, and what you paste is not.
53
89
 
54
90
  Rules for the text:
55
91
 
@@ -65,16 +101,24 @@ Rules for the text:
65
101
 
66
102
  ## Send it
67
103
 
68
- Call `submit_bug_report` once with the fields above. Then:
104
+ Call `submit_bug_report` once with the fields above. The tool then asks the user the final question
105
+ itself: it shows the whole report, the graph and the trajectory in full when a session is attached, and
106
+ closes with how the report is used: only to debug the problem, kept in the Andorra team's private bug
107
+ tracker, and never used to train models. That confirmation is the user's decision to send or not. Do not
108
+ ask "shall I send it?" yourself before calling the tool, and do not restate or reword the assurance: the
109
+ tool's wording is the one the team stands behind. If the user asks about it, tell them exactly that and
110
+ no more; do not promise that the report is deleted, or anything else the confirmation does not say.
111
+
112
+ Then:
69
113
 
70
114
  - `sent: true`: give the user the `reference` (for example `BR-1234`) and thank them. There is no page to
71
115
  open: the tracker is private, so do not offer a link or promise a reply.
72
116
  - `sent: false` with a `userReply`: they want a change. Make it and call the tool again so they confirm
73
- the new text.
117
+ the new text. If they do not want the graph or trajectory sent, call again with `session` set to `none`.
74
118
  - `sent: false` without one: they chose not to send. Say nothing was sent and stop.
75
119
  - An error: tell the user what it said in plain words. Signed out: they sign in and run `/bug-report`
76
120
  again. Daily limit reached: say when they can send it. Service unavailable: say so; do not retry in a
77
- loop.
121
+ loop. No such session: call `list_bug_report_sessions` again and ask which one they meant.
78
122
 
79
123
  Send one report per problem. If the user describes two separate bugs, finish the first, then ask whether
80
124
  to report the second.
@@ -55,8 +55,8 @@ What you need to know:
55
55
  - What each agent may touch (read only, write files, run shell, open pull requests).
56
56
  - What input a run needs beyond the task text.
57
57
  - When the workflow opens, reviews or fixes pull requests: which agent owns the PR and its review comments.
58
- Build it with the "Pull request with review fixes" pattern in `patterns.md`: that agent switches Auto-fix on
59
- itself and loops on the reviews, and the graph's entry stays where it is.
58
+ Use the "Pull request with review fixes" pattern in `patterns.md`. The owner decides when to monitor the
59
+ PR with `await_review` and how to act on review comments and reaction changes. The graph's entry stays where it is.
60
60
 
61
61
  Then sketch the nodes and routes. To show the user a graph, call the `andorra_graph_show` action: with
62
62
  `draftId` for a draft you are building, or with `id` (and `revision`, if not the latest) for a published graph.
@@ -67,7 +67,7 @@ check (loop modifier) --pass--> done
67
67
  `pass` or runs out of attempts. It exposes only the `pass` port; use it when the same agent fixes and
68
68
  rechecks its own work.
69
69
 
70
- ## Pull request with review fixes (Auto-fix)
70
+ ## Pull request with review fixes
71
71
 
72
72
  ```
73
73
  orchestrator --completed--> pr-owner --completed--> done
@@ -75,24 +75,18 @@ orchestrator --completed--> pr-owner --completed--> done
75
75
 
76
76
  Use this whenever the workflow opens a pull request, reviews one, or answers its review comments.
77
77
 
78
- - One agent owns the PR end to end: it opens or attaches the PR, switches Auto-fix on itself (the `pull_request`
79
- tool, `action: "attach"` or `"update"` with `autoFix: true`), and fixes the review comments. Auto-fix prompts
80
- go back to the node that switched Auto-fix on (or, when none did, to the node that attached the PR), not to
81
- the graph's entry. So that call belongs in the PR owner's instruction, never in an Orchestrator or planner
82
- that hands the work on.
83
- - Do not move the entry, demote an Orchestrator, or add edges back into the owner to steer Auto-fix there. A
84
- prompt is never routed through the graph's edges; it is addressed to the node.
85
- - The owner's instruction is a loop it runs itself: push the fix, resolve the threads it fixed, reply to the
86
- findings it disputes, then wait for the next review. If the `pull_request` tool offers an `await_review`
87
- action, call it and repeat until it reports the PR merged or closed (or the round cap below): the agent keeps
88
- its whole conversation, and waiting costs no tokens. Without that action, end the turn once the round is
89
- pushed; Auto-fix wakes this same node with the next comments, continuing its attempt when it stopped short.
90
- - Never wait with `sleep`, a shell polling loop, or `set_timer` (timers are for reminders the user asked for).
91
- Waiting inside a tool call is the only wait that does not hold the model.
92
- - Give the owner shell, file-write and network access (it runs `git` and `gh`), and a `limits.wallTimeMs` with
93
- room for several fix rounds: a 15-minute ceiling stops it in the middle of a fix.
94
- - Put the exit rule in its instruction: stop when the PR is merged or closed (Auto-fix then switches itself
95
- off), when the reviewer signs off, or after a fixed number of rounds the user chose.
78
+ - One agent owns the PR from opening or attaching it through answering review comments. Keep the
79
+ graph's entry where it is and put the review instructions on the PR owner's node.
80
+ - When the workflow calls for PR monitoring, the owner can use `pull_request` with
81
+ `action: "await_review"`. This holds the current run and preserves its conversation. Use the returned
82
+ comment classifications as hints. Verify findings in the review and check reaction changes for context.
83
+ The owner fixes findings it agrees with, pushes, replies and resolves the threads it fixed, and replies
84
+ to disputed findings. The owner decides whether to wait again based on the task and the review status.
85
+ - Give the owner shell, file-write and network access for `git` and `gh`. Set `limits.wallTimeMs`
86
+ with room for any review rounds the user requests. Use the review tool for waits on surfaces that
87
+ support it.
88
+ - Have the owner stop when the reviewer signs off, the PR closes or merges, or the requested round
89
+ limit is reached. Merge only when authorized.
96
90
 
97
91
  ## Single agent with a human approval
98
92
 
@@ -714,7 +714,7 @@
714
714
  {
715
715
  "source": "src/skills/bundled/graph-manager/SKILL.md",
716
716
  "asset": "graph-manager/SKILL.md",
717
- "sha256": "cedffd79e4e632d62426758d8b50b6f0e8b2f5e30cc764efd1ff20fa40f3d6db"
717
+ "sha256": "a64da6d3b2a8f47ac8fa9012f4eb4fa44ac188b75a94f4872cbfebd6096035f1"
718
718
  },
719
719
  {
720
720
  "source": "src/skills/bundled/graph-manager/errors.md",
@@ -724,12 +724,12 @@
724
724
  {
725
725
  "source": "src/skills/bundled/graph-manager/patterns.md",
726
726
  "asset": "graph-manager/patterns.md",
727
- "sha256": "bf57e2421697360cc293109b5eaa84ecff0d93fc5dcd957a34d8173ca91b1e2c"
727
+ "sha256": "fc585892e2010e1f8c828b4d28ed14341ff35ec7f0b276ade2aff3e781a379f1"
728
728
  },
729
729
  {
730
730
  "source": "src/skills/bundled/bug-report/SKILL.md",
731
731
  "asset": "bug-report/SKILL.md",
732
- "sha256": "20777e7df3e9a93e2062f681069d09a090b487268cf12a2f5359f989ab809e2d"
732
+ "sha256": "f5899f2bcb3e4c2f809673e4f2f40a138da3de4d3e7fa20cf33638003d521e01"
733
733
  },
734
734
  {
735
735
  "source": "src/skills/bundled/diagram/SKILL.md",
@@ -1,13 +1,14 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { requireLegalAcceptance } from './legal/gate.js';
2
3
  import { homedir } from 'node:os';
3
4
  import { realpath, stat } from 'node:fs/promises';
4
- import { writeFile } from 'node:fs/promises';
5
- import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
6
- import { createRunHandle, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
5
+ import { configDirectory, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
6
+ import { beginTelemetryRun, runTelemetryMetadata, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
7
+ import { loadCliConfig, cliTelemetryResult } from './telemetry/permission-command.js';
7
8
  import { configuredContextWindow, createAdapter, providerModels } from './providers.js';
8
- import { getMembership, loadAccessibleGraph } from './membership.js';
9
+ import { getMembership, loadAccessibleGraph, withAnonymousJev } from './membership.js';
9
10
  import { currentGraphSubject } from './graph-selection.js';
10
- import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
11
+ import { createRunTelemetry, recordModelUse, mergeRunTelemetry, hasRunTelemetry } from './telemetry/capture.js';
11
12
  import { hostedGate } from './andorra/hosted.js';
12
13
  import { checkGraphModelHealth, plainHealthFailure } from './graph-health.js';
13
14
  import { validateGraph } from './graphs.js';
@@ -23,8 +24,8 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
23
24
  import { DecisionManager } from './decision/DecisionManager.js';
24
25
  import { permissionMode } from './permissions.js';
25
26
  import { TodoStore } from './todos.js';
26
- import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
27
- import { SessionStore, projectIdentity, sessionName } from './sessions.js';
27
+ import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, summaryForStoppedRecord, writeFinalRunRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
28
+ import { SessionStore, projectIdentity, randomSessionName } from './sessions.js';
28
29
  export const SUBAGENT_GRAPH_ID = 'default';
29
30
  export const MAX_SUBAGENT_TASK_CHARS = 100_000;
30
31
  export const MAX_SUBAGENT_MODEL_CHARS = 500;
@@ -127,7 +128,10 @@ export async function subagentDecisionConfig(config, membership) {
127
128
  const decisions = config.decisions;
128
129
  if (config.jevEnabled === false || !decisions || decisions.provider === 'none' || decisions.mode === 'off')
129
130
  return { mode: 'off', provider: 'none' };
130
- return (await membership()).subject ? decisions : { mode: 'off', provider: 'none' };
131
+ const access = await withAnonymousJev(await membership());
132
+ if (access.subject)
133
+ return decisions;
134
+ return access.anonymousJev ? { ...decisions, anonymous: true } : { mode: 'off', provider: 'none' };
131
135
  }
132
136
  export class SubagentRunner {
133
137
  defaults;
@@ -170,60 +174,63 @@ export class SubagentRunner {
170
174
  }
171
175
  async begin(options, permissions) {
172
176
  const directory = options.directory ?? this.defaults.directory ?? configDirectory();
177
+ await requireLegalAcceptance(directory);
178
+ const startedAt = new Date().toISOString();
179
+ const telemetryHandle = await beginTelemetryRun({ home: directory, surface: 'subagent' }, startedAt, {
180
+ graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: permissions,
181
+ }, options.workspace).catch(() => undefined);
182
+ const telemetryAccess = { home: directory, lease: telemetryHandle?.lease };
173
183
  const workspace = await canonicalWorkspace(options.workspace);
174
- const config = await (this.defaults.loadConfig ?? loadConfig)(directory);
184
+ const config = await (this.defaults.loadConfig ?? loadCliConfig)(directory);
175
185
  const { provider, model } = resolveSubagentProvider(config, options);
176
186
  if (!claimProcessWorkspace(workspace, this.reservationId))
177
187
  throw new SubagentRunInProgressError();
178
188
  this.reservedWorkspace = workspace;
179
- const telemetryRunId = randomUUID();
180
189
  const accountSubject = await currentGraphSubject().catch(() => undefined);
181
190
  const runId = randomUUID();
182
191
  const run = {
183
- runId, sessionId: randomUUID(), task: options.task, workspace, directory, telemetryRunId,
192
+ runId, sessionId: randomUUID(), name: randomSessionName(), task: options.task, workspace, directory, telemetryHandle,
184
193
  ...(accountSubject === undefined ? {} : { accountSubject }),
185
194
  jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off',
186
- providerId: provider.id, model, permissions, controller: new AbortController(), startedAt: new Date().toISOString(),
195
+ providerId: provider.id, model, permissions, controller: new AbortController(), startedAt,
187
196
  events: [], notices: [], journal: Promise.resolve(), finished: Promise.resolve(),
188
197
  journalWriter: createRunJournalWriter(directory, runId), checkpoints: createCheckpointFailureTracker(directory, runId),
189
- probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
198
+ probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeTelemetry: createRunTelemetry(telemetryAccess),
190
199
  providerType: provider.type, baseUrl: provider.baseUrl,
191
200
  };
201
+ if (telemetryHandle)
202
+ Object.assign(telemetryHandle.dimensions, { jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off' });
192
203
  const openRecord = {
193
204
  id: run.runId, status: 'running', sessionId: run.sessionId, startedAt: run.startedAt, pid: process.pid,
194
205
  graphSelection: SUBAGENT_GRAPH_ID, graph: { id: SUBAGENT_GRAPH_ID }, provider: provider.id, model,
195
206
  ...(accountSubject === undefined ? {} : { accountSubject }),
196
207
  surface: 'subagent',
197
- telemetry: { runId: telemetryRunId, nodes: 1, subagents: false, jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off', startSent: false },
208
+ telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
198
209
  subagent: true,
199
210
  permissions: run.permissions,
200
211
  };
201
212
  try {
202
- await writeOpenRunRecord(directory, openRecord);
213
+ await writeOpenRunRecord(directory, openRecord, telemetryAccess);
203
214
  }
204
215
  catch (error) {
205
216
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
206
217
  const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
207
218
  throw Object.assign(new Error(`Could not write the subagent run record: ${error instanceof Error ? error.message : String(error)}`), typeof code === 'string' ? { code } : {}, error instanceof Error ? { cause: error } : {});
208
219
  }
209
- run.telemetryHandle = createRunHandle(run.telemetryRunId, run.startedAt, {
210
- graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
211
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
212
- }, workspace);
213
- run.telemetryStart = reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle).catch(() => { });
220
+ run.telemetryStart = telemetryHandle ? reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle).catch(() => { }) : Promise.resolve();
214
221
  await run.telemetryStart;
215
222
  await writeOpenRunRecord(directory, {
216
223
  ...openRecord,
217
- telemetry: { ...openRecord.telemetry, startSent: run.telemetryHandle.started !== false },
218
- }).catch(() => { });
224
+ telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
225
+ }, telemetryAccess).catch(() => { });
219
226
  try {
220
227
  await this.saveSession(run, { summary: RUNNING_TURN_SUMMARY, tests: [], status: 'running' });
221
228
  }
222
229
  catch (error) {
223
230
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
224
231
  await run.telemetryStart;
225
- await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, { graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
226
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting }), { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
232
+ if (telemetryHandle)
233
+ await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle, { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
227
234
  throw error;
228
235
  }
229
236
  this.active = run;
@@ -255,7 +262,7 @@ export class SubagentRunner {
255
262
  if (!run.outcome)
256
263
  return { state: 'running' };
257
264
  return { state: 'finished', status: run.outcome.status,
258
- ...(run.outcome.result !== undefined ? { result: run.outcome.result } : {}),
265
+ ...(run.outcome.result !== undefined ? { result: cliTelemetryResult(run.directory, run.outcome.result, run.telemetryHandle?.lease) } : {}),
259
266
  ...(run.outcome.reason !== undefined ? { reason: run.outcome.reason } : {}) };
260
267
  }
261
268
  cancel() {
@@ -342,14 +349,8 @@ export class SubagentRunner {
342
349
  onUsage: (delta, reference) => {
343
350
  foldUsage(run.probeUsage, delta);
344
351
  options.healthDependencies?.onUsage?.(delta, reference);
345
- const key = `${reference.provider}\0${reference.model}`;
346
- const entry = run.probeModels.get(key) ?? { provider: reference.provider, model: reference.model, usage: {} };
347
- for (const field of ['requests', 'inputTokens', 'outputTokens', 'cacheRead', 'cacheWrite']) {
348
- const value = delta[field];
349
- if (typeof value === 'number')
350
- entry.usage[field] = (entry.usage[field] ?? 0) + value;
351
- }
352
- run.probeModels.set(key, entry);
352
+ if (hasRunTelemetry(run.probeTelemetry))
353
+ recordModelUse(run.probeTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: reference.model, role: 'other', usage: delta });
353
354
  },
354
355
  });
355
356
  if (!health.healthy) {
@@ -387,12 +388,13 @@ export class SubagentRunner {
387
388
  ...(meta?.generation === undefined ? {} : { generation: meta.generation }),
388
389
  ...(meta?.provider === undefined ? {} : { provider: meta.provider }),
389
390
  ...(meta?.model === undefined ? {} : { model: meta.model }),
390
- }))
391
+ }, { lease: run.telemetryHandle?.lease }))
391
392
  .then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
392
393
  return checkpointWrites;
393
394
  };
394
395
  const { createTools } = await import('./tools.js');
395
396
  const graphOptions = {
397
+ telemetry: { home: run.directory, lease: run.telemetryHandle?.lease },
396
398
  task: run.task, runId: run.runId, provider: run.providerId, model: run.model,
397
399
  adapter: adapterFor(resolvedProvider),
398
400
  ...(resolvedProvider.contextWindow === undefined ? {} : { contextWindow: resolvedProvider.contextWindow }),
@@ -442,7 +444,7 @@ export class SubagentRunner {
442
444
  }
443
445
  async saveSession(run, completion, usage = { requests: 0, inputTokens: 0, outputTokens: 0 }, updatedAt = new Date().toISOString()) {
444
446
  await new SessionStore(run.directory).save({
445
- version: 1, id: run.sessionId, name: sessionName(run.task), workspace: run.workspace, updatedAt,
447
+ version: 1, id: run.sessionId, name: run.name, workspace: run.workspace, updatedAt,
446
448
  history: [{ task: run.task, completion, runId: run.runId }], usage, projectId: projectIdentity(run.workspace),
447
449
  });
448
450
  }
@@ -450,25 +452,21 @@ export class SubagentRunner {
450
452
  const status = result?.status ?? (run.controller.signal.aborted ? 'cancelled' : 'infrastructure_error');
451
453
  const reason = result?.reason ?? (failure !== undefined ? (failure instanceof Error ? failure.message : String(failure)) : undefined);
452
454
  const telemetrySurface = { home: run.directory, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) };
453
- const telemetryHandle = run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, {
454
- graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
455
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
456
- }, run.workspace);
455
+ const telemetryHandle = run.telemetryHandle;
456
+ const telemetryAccess = { home: run.directory, lease: telemetryHandle?.lease };
457
457
  let telemetryFinished = false;
458
458
  const settleTelemetry = (settled, why) => {
459
- if (telemetryFinished)
459
+ if (telemetryFinished || !telemetryHandle)
460
460
  return Promise.resolve();
461
461
  telemetryFinished = true;
462
- const finishedTelemetry = result?.telemetry ?? createRunTelemetry();
463
- for (const probe of run.probeModels.values()) {
464
- recordModelUse(finishedTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: probe.model, role: 'other', usage: probe.usage });
465
- }
462
+ const finishedTelemetry = result?.telemetry ?? createRunTelemetry(telemetryAccess);
463
+ mergeRunTelemetry(finishedTelemetry, run.probeTelemetry);
466
464
  return (run.telemetryStart ?? Promise.resolve()).then(() => reportRunFinished(telemetrySurface, telemetryHandle, {
467
465
  status: settled, ...(why === undefined ? {} : { reason: why }),
468
466
  ...(result?.providerRequestFailed || run.healthProviderFailed ? { providerRequestFailed: true } : {}),
469
467
  ...(result?.providerOverflow ? { providerOverflow: true } : {}),
470
468
  ...(result?.failureCode === undefined ? {} : { errorCode: result.failureCode }),
471
- ...(result?.telemetry !== undefined || run.probeModels.size > 0 ? { telemetry: finishedTelemetry } : {}),
469
+ ...(result?.telemetry !== undefined || (hasRunTelemetry(run.probeTelemetry) && run.probeTelemetry.models.length > 0) ? { telemetry: finishedTelemetry } : {}),
472
470
  ...(result?.toolCalls === undefined ? {} : { toolCalls: result.toolCalls }),
473
471
  })).catch(() => { });
474
472
  };
@@ -491,14 +489,14 @@ export class SubagentRunner {
491
489
  record.checkpointFailures = run.checkpoints.failures;
492
490
  }
493
491
  try {
494
- await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify(record, null, 2) + '\n', { mode: 0o600 });
492
+ await writeFinalRunRecord(run.directory, record, telemetryAccess);
495
493
  }
496
494
  catch (error) {
497
495
  process.stderr.write(`Could not record the stopped subagent run: ${error instanceof Error ? error.message : String(error)}\n`);
498
496
  const detail = error instanceof Error ? error.message : String(error);
499
- const terminalized = await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify({
497
+ const terminalized = await writeFinalRunRecord(run.directory, {
500
498
  ...record, status: 'infrastructure_error', reason: `The run record could not be written: ${detail}`, endedAt,
501
- }, null, 2) + '\n', { mode: 0o600 }).then(() => true, () => false);
499
+ }, telemetryAccess).then(() => true, () => false);
502
500
  if (terminalized) {
503
501
  await writeStudioRunSummary(run.directory, {
504
502
  id: run.runId, status: 'infrastructure_error', startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
@@ -517,7 +515,8 @@ export class SubagentRunner {
517
515
  this.releaseWorkspace();
518
516
  this.release(run);
519
517
  await settleTelemetry('infrastructure_error', `The run record could not be written: ${detail}`);
520
- await drainTelemetry(telemetrySurface).catch(() => { });
518
+ if (telemetryHandle)
519
+ await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
521
520
  run.outcome = { status: 'infrastructure_error', reason: `The run record could not be written: ${detail}` };
522
521
  return;
523
522
  }
@@ -544,7 +543,8 @@ export class SubagentRunner {
544
543
  this.releaseWorkspace();
545
544
  this.release(run);
546
545
  await settleTelemetry(status, reason);
547
- await drainTelemetry(telemetrySurface).catch(() => { });
546
+ if (telemetryHandle)
547
+ await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
548
548
  run.outcome = { status, ...(result !== undefined ? { result } : {}), ...(reason !== undefined ? { reason } : {}) };
549
549
  }
550
550
  runSignal() {
@@ -0,0 +1,50 @@
1
+ import { type CodexConnect } from './codex-rpc.js';
2
+ import type { EfficiencyConfig } from './efficiency.js';
3
+ import type { QuotaReadings, QuotaWindow } from './model-pool.js';
4
+ import type { ProviderConfig } from './providers.js';
5
+ /**
6
+ * Subscription usage for pool routing, read from each provider's own client. Nothing here reads another tool's
7
+ * files: a provider with no built-in source simply has no reading, and pool routing treats that as no known limit.
8
+ */
9
+ /** How long one reading is reused before the provider is asked again. */
10
+ export declare const USAGE_READING_TTL_MS = 60000;
11
+ export type UsageProvider = Pick<ProviderConfig, 'id' | 'type' | 'codexAccount'>;
12
+ export type UsageSource = (provider: UsageProvider, signal: AbortSignal) => Promise<QuotaWindow[] | undefined>;
13
+ /** The hosted allowance as the hosted monitor reports it. */
14
+ export type HostedUsageReading = {
15
+ kind: string;
16
+ usedPercent?: number;
17
+ resetsAt?: string;
18
+ } | undefined;
19
+ /** The usage windows in a Codex `account/rateLimits/read` answer. */
20
+ export declare function codexWindows(rateLimits: unknown): QuotaWindow[];
21
+ /** Ask the signed-in Codex client for its account's usage windows. */
22
+ export declare function readCodexUsage(provider: UsageProvider, signal: AbortSignal, connect?: CodexConnect): Promise<QuotaWindow[] | undefined>;
23
+ /** The hosted weekly allowance as one usage window. */
24
+ export declare function hostedWindows(usage: HostedUsageReading): QuotaWindow[] | undefined;
25
+ /** The provider types whose client can report usage. */
26
+ export declare const USAGE_SOURCES: Readonly<Partial<Record<string, UsageSource>>>;
27
+ type UsageCache = Map<string, {
28
+ at: number;
29
+ windows: Promise<QuotaWindow[] | undefined>;
30
+ }>;
31
+ export interface UsageReaderOptions {
32
+ /** Read only these provider ids. */
33
+ only?: readonly string[];
34
+ sources?: Readonly<Partial<Record<string, UsageSource>>>;
35
+ hosted?: () => HostedUsageReading;
36
+ now?: () => number;
37
+ ttlMs?: number;
38
+ cache?: UsageCache;
39
+ }
40
+ /**
41
+ * A reader of usage by provider id. Each provider is asked at most once per `ttlMs`; a read that fails or times out
42
+ * gives no reading for that provider and never fails the caller.
43
+ */
44
+ export declare function createUsageReader(providers: () => readonly UsageProvider[], options?: UsageReaderOptions): (signal: AbortSignal) => Promise<QuotaReadings>;
45
+ /** The usage reader for a configuration's pool: it asks only the providers the pool names. */
46
+ export declare function poolUsageReader(config: {
47
+ providers: readonly UsageProvider[];
48
+ efficiency?: EfficiencyConfig;
49
+ }, hosted?: () => HostedUsageReading): (signal: AbortSignal) => Promise<QuotaReadings>;
50
+ export {};