@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
@@ -1,3 +1,5 @@
1
+ import { configDirectory } from '../config.js';
2
+ import { withTelemetryAdmission } from './permission.js';
1
3
  import { readFile, readdir } from 'node:fs/promises';
2
4
  import { join, relative, sep } from 'node:path';
3
5
  import { classifyWorkspace } from './classify.js';
@@ -13,7 +15,7 @@ const MANIFEST_FILES = new Set([
13
15
  const MANIFEST_BYTES = 64 * 1024;
14
16
  const FILE_LIMIT = 10_000;
15
17
  const ENTRY_FACTOR = 2;
16
- export async function inspectWorkspace(root, options = {}) {
18
+ async function inspectWorkspaceAdmitted(root, options) {
17
19
  const limit = options.limit ?? FILE_LIMIT;
18
20
  const entryLimit = limit * ENTRY_FACTOR;
19
21
  const filePaths = [];
@@ -37,6 +39,8 @@ export async function inspectWorkspace(root, options = {}) {
37
39
  }
38
40
  entries.sort((a, b) => a.name.localeCompare(b.name));
39
41
  for (const entry of entries) {
42
+ if (options.signal?.aborted)
43
+ break;
40
44
  if (totalFiles >= limit || entriesSeen >= entryLimit)
41
45
  break;
42
46
  entriesSeen += 1;
@@ -57,16 +61,27 @@ export async function inspectWorkspace(root, options = {}) {
57
61
  if (MANIFEST_FILES.has(entry.name) && Object.keys(manifests).length < 32) {
58
62
  try {
59
63
  const handle = await readFile(join(root, path));
60
- if (handle.byteLength <= MANIFEST_BYTES)
64
+ if (!options.signal?.aborted && handle.byteLength <= MANIFEST_BYTES)
61
65
  manifests[manifestKey] = handle.toString('utf8');
62
66
  }
63
- catch { }
67
+ catch { /* a manifest that cannot be read is simply not evidence */ }
64
68
  }
65
69
  }
66
70
  }
67
71
  }
68
72
  return { filePaths: filePaths.map(path => path.split(sep).join('/')), totalFiles: Math.min(totalFiles, limit), manifests, sawCsproj };
69
73
  }
74
+ /** No directory or manifest access without fresh home authority. */
75
+ export async function inspectWorkspace(root, options = {}) {
76
+ const empty = () => ({ filePaths: [], totalFiles: 0, manifests: {}, sawCsproj: false });
77
+ return await withTelemetryAdmission({ home: options.home ?? configDirectory(), signals: options.signals }, async (admission) => {
78
+ if (admission.signal.aborted || options.signal?.aborted)
79
+ return empty();
80
+ const signal = options.signal ? AbortSignal.any([admission.signal, options.signal]) : admission.signal;
81
+ const observation = await inspectWorkspaceAdmitted(root, { ...options, signal });
82
+ return signal.aborted ? empty() : observation;
83
+ }, options.lease) ?? empty();
84
+ }
70
85
  export function workspaceShape(observation) {
71
86
  return classifyWorkspace(observation);
72
87
  }
@@ -40,6 +40,7 @@ export interface TerminalStatus {
40
40
  jevEnabled?: boolean;
41
41
  /** Jev is on but the last run could not use it (signed out, or the account lookup failed); cleared when the Jev setting changes. */
42
42
  jevOffThisRun?: boolean;
43
+ antigravity?: boolean;
43
44
  goal?: SessionGoal;
44
45
  changes?: PanelChanges;
45
46
  terminals?: readonly PanelTerminal[];
@@ -229,6 +230,7 @@ export declare class TerminalUI extends EventEmitter {
229
230
  conversationPrompt?: boolean;
230
231
  history?: boolean;
231
232
  secret?: boolean;
233
+ freshAction?: boolean;
232
234
  yieldToQuestions?: boolean;
233
235
  }): Promise<string>;
234
236
  chooseQuestion(prompt: string, items: TerminalChoice[], options?: {
@@ -251,6 +253,7 @@ export declare class TerminalUI extends EventEmitter {
251
253
  appendThinking(delta: string): void;
252
254
  clearConversation(): void;
253
255
  clearThinking(): void;
256
+ useAntigravityStatus(): () => void;
254
257
  setStatus(partial: Partial<TerminalStatus>): void;
255
258
  noteGeneratedTokens(tokens: number, invocationId?: string, final?: boolean, decodeMs?: number): void;
256
259
  noteStreamedOutput(text: string, invocationId?: string): void;
@@ -29,7 +29,7 @@ const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
29
29
  const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
30
30
  const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
31
31
  const oneLine = (text) => clean(text).replace(/\n/g, ' ');
32
- const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/resume', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
32
+ const commands = ['/model', '/providers', '/antigravity', '/subagent', '/reasoning', '/routing', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/resume', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
33
33
  const argumentCompletions = {
34
34
  '/jev': ['/jev status', '/jev on', '/jev off', '/jev global on', '/jev global off'],
35
35
  '/feedback': ['/feedback status', '/feedback on', '/feedback off'],
@@ -39,6 +39,7 @@ const argumentCompletions = {
39
39
  '/attach': [],
40
40
  '/goal': ['/goal clear'],
41
41
  '/logout': ['/logout codex'],
42
+ '/routing': ['/routing status', '/routing refresh'],
42
43
  '/skill': ['/skill off', '/skill on', '/skill remove'],
43
44
  };
44
45
  const argumentRequired = new Set(['/jev', '/feedback', '/yolo', '/reasoning', '/codegraph', '/attach']);
@@ -64,14 +65,15 @@ const commandDescriptions = {
64
65
  '/session': 'Browse and resume saved sessions', '/resume': 'Browse and resume saved sessions',
65
66
  '/login': 'Sign in or create an Andorra account', '/logout': 'Sign out of the Andorra account', '/logout codex': 'Sign out of every Codex account', '/auth logout': 'Sign out of the Andorra account', '/auth status': 'Account and membership status',
66
67
  '/model': 'Choose a model', '/providers': 'Choose or edit providers',
68
+ '/antigravity': 'Start a Gemini subscription session through Antigravity ACP',
67
69
  '/subagent': 'Choose the provider and model external hosts run Andorra with',
68
- '/reasoning': 'Choose thinking effort', '/dashboard': 'Toggle live dashboard / transcript',
70
+ '/reasoning': 'Choose thinking effort', '/routing': 'Show model routing and its scores', '/routing status': 'Show model routing and its scores', '/routing refresh': 'Re-score every configured model from benchmarks', '/dashboard': 'Toggle live dashboard / transcript',
69
71
  '/skill': 'Show the active skill', '/skill off': 'Pause the active skill', '/skill on': 'Resume the active skill', '/skill remove': 'End the active skill',
70
72
  '/skills': 'Manage and install skills', '/plugins': 'Manage and install plugins',
71
73
  '/mcp': 'Manage MCP servers',
72
74
  '/jev': 'Turn Jev on or off for this session', '/jev on': 'Turn Jev on for this session', '/jev off': 'Turn Jev off for this session', '/jev status': 'Show the session and global Jev settings',
73
75
  '/jev global on': 'Turn the Global Jev switch on', '/jev global off': 'Turn Jev off for every session and agent',
74
- '/feedback': 'Show the anonymous-feedback setting; Paid accounts can turn it off', '/feedback on': 'Allow anonymous product feedback', '/feedback off': 'Stop anonymous product feedback (Paid plan)', '/feedback status': 'Show saved feedback setting',
76
+ '/feedback': 'Show product usage report status', '/feedback on': 'Review product usage report permission', '/feedback off': 'Stop reports where optional; every plan in protected regions', '/feedback status': 'Show effective product usage report status',
75
77
  '/graph': 'Choose a graph', '/codegraph': 'Code intelligence status and actions', '/usage': 'Usage and token totals', '/yolo': 'Turn automatic approvals on or off', '/yolo on': 'Approve everything for this session', '/yolo off': 'Restore Ask for approval',
76
78
  '/permissions': 'Choose workspace permissions',
77
79
  '/tools': 'Available coding tools', '/status': 'Workspace and settings', '/clear': 'Clear conversation',
@@ -732,6 +734,27 @@ export class TerminalUI extends EventEmitter {
732
734
  this.updateWorkingClock();
733
735
  pending.signal?.addEventListener('abort', pending.abort, { once: true });
734
736
  this.scheduleRender();
737
+ if (options.freshAction) {
738
+ pending.freshArmed = false;
739
+ pending.label = 'Review the notice — input not armed yet';
740
+ this.clearPlainInput();
741
+ this.incoming = '';
742
+ this.paste = '';
743
+ this.pasting = false;
744
+ pending.freshTimer = setTimeout(() => {
745
+ if (this.pending !== pending || this.closed)
746
+ return;
747
+ this.clearPlainInput();
748
+ this.incoming = '';
749
+ this.paste = '';
750
+ this.pasting = false;
751
+ this.value = [];
752
+ this.cursor = 0;
753
+ pending.freshArmed = true;
754
+ pending.label = oneLine(label);
755
+ this.scheduleRender();
756
+ }, 100);
757
+ }
735
758
  });
736
759
  }
737
760
  async chooseQuestion(prompt, items, options = {}) {
@@ -968,6 +991,15 @@ export class TerminalUI extends EventEmitter {
968
991
  this.thinkingExpanded = true;
969
992
  this.scheduleRender();
970
993
  }
994
+ useAntigravityStatus() {
995
+ const { provider, model, graph, graphSelection, graphNeedsOverride, reasoningEffort, contextWindow, contextUsed, session, permissions, yolo, activity, backgroundActivity, goal, requests, inputTokens, outputTokens, antigravity } = this.status;
996
+ this.setStatus({ antigravity: true, provider: 'Antigravity', model: 'Gemini', graph: undefined, graphSelection: undefined,
997
+ graphNeedsOverride: false, reasoningEffort: undefined, contextWindow: undefined, contextUsed: undefined,
998
+ session: 'Antigravity subscription', permissions: 'Antigravity session rules', yolo: false, goal: undefined,
999
+ activity: 'Starting Antigravity ACP', requests: undefined, inputTokens: undefined, outputTokens: undefined });
1000
+ return () => this.setStatus({ antigravity, provider, model, graph, graphSelection, graphNeedsOverride, reasoningEffort,
1001
+ contextWindow, contextUsed, session, permissions, yolo, activity, backgroundActivity, goal, requests, inputTokens, outputTokens });
1002
+ }
971
1003
  setStatus(partial) {
972
1004
  const graphIdentity = (graph) => graph === undefined ? undefined : `${graph.id}@${graph.revision}`;
973
1005
  const modelChanged = (partial.provider !== undefined && partial.provider !== this.status.provider)
@@ -1143,7 +1175,7 @@ export class TerminalUI extends EventEmitter {
1143
1175
  const visible = this.todos.slice(this.todoOffset, this.todoOffset + count);
1144
1176
  const hidden = this.todos.length - count;
1145
1177
  const summary = this.expandedTodos && hidden ? `${this.todoOffset + 1}-${this.todoOffset + count}/${this.todos.length} · Page Up/Down · ` : hidden ? `… +${hidden} more ` : '';
1146
- return ['Todo', ...visible.map(todo => ` ${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${todo.text}`), `${summary}(${done} done) · ctrl+t to ${this.expandedTodos ? 'collapse' : 'expand'}`];
1178
+ return ['Todo', ...visible.map(todo => ` ${todo.parentId === undefined ? '' : ' '}${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${todo.text}`), `${summary}(${done} done) · ctrl+t to ${this.expandedTodos ? 'collapse' : 'expand'}`];
1147
1179
  }
1148
1180
  thinkingLines(width, seconds, maxRows) {
1149
1181
  if (!this.thinkingActive || maxRows < 1)
@@ -1233,6 +1265,7 @@ export class TerminalUI extends EventEmitter {
1233
1265
  finishQuestion() {
1234
1266
  this.commandInput = false;
1235
1267
  this.clearPlainInput();
1268
+ clearTimeout(this.pending?.freshTimer);
1236
1269
  if (this.pending?.abort)
1237
1270
  this.pending.signal?.removeEventListener('abort', this.pending.abort);
1238
1271
  this.pending = undefined;
@@ -1253,6 +1286,13 @@ export class TerminalUI extends EventEmitter {
1253
1286
  onEnd = () => this.close();
1254
1287
  onResize = () => this.scheduleRender();
1255
1288
  onData = (chunk) => {
1289
+ if (this.pending?.freshArmed === false) {
1290
+ // Drain OS-delivered type-ahead while the notice is unarmed, but retain cancellation.
1291
+ for (const char of chunk.toString())
1292
+ if (['\u001b', '\u0003', '\u0004'].includes(char))
1293
+ this.keys.write(char);
1294
+ return;
1295
+ }
1256
1296
  if (this.escapeTimer)
1257
1297
  clearTimeout(this.escapeTimer);
1258
1298
  this.escapeTimer = undefined;
@@ -1715,6 +1755,8 @@ export class TerminalUI extends EventEmitter {
1715
1755
  }
1716
1756
  clearDraft() { this.clipboardProbe += 1; this.value = []; this.cursor = 0; this.historyIndex = this.history.length; this.draft = ''; this.commandInput = false; this.completion = undefined; this.dismissedCompletion = undefined; this.attachments = []; this.scroll = 0; this.scheduleRender(); }
1717
1757
  onKey = (text, key) => {
1758
+ if (this.pending?.freshArmed === false && key.name !== 'escape' && !(key.ctrl && ['c', 'd'].includes(key.name ?? '')))
1759
+ return;
1718
1760
  if (this.selection && key.ctrl && key.name === 'c' && !emptySelection(this.selection)) {
1719
1761
  this.copyScreenSelection();
1720
1762
  this.selection = undefined;
@@ -2588,7 +2630,7 @@ export class TerminalUI extends EventEmitter {
2588
2630
  const model = oneLine(`${active.label} · Thinking: ${active.reasoningEffort ?? 'provider default'}`);
2589
2631
  const branch = oneLine(status.branch || 'no branch');
2590
2632
  const branchWidth = Math.min(Math.floor(width / 3), stringWidth(branch) + 3);
2591
- const jev = oneLine(status.account?.jevQuota ?? 'Jev unavailable').replace(/^Jev(?= )/, status.jevEnabled === false ? 'Jev [Disabled] ·' : status.jevEnabled === true ? (status.jevOffThisRun ? 'Jev [Off this run] ·' : 'Jev [Enabled] ·') : 'Jev');
2633
+ const jev = status.antigravity ? 'Jev unavailable' : oneLine(status.account?.jevQuota ?? 'Jev unavailable').replace(/^Jev(?= )/, status.jevEnabled === false ? 'Jev [Disabled] ·' : status.jevEnabled === true ? (status.jevOffThisRun ? 'Jev [Off this run] ·' : 'Jev [Enabled] ·') : 'Jev');
2592
2634
  const jevWidth = Math.min(stringWidth(jev), width - 1);
2593
2635
  const andorraUsage = this.andorraSegment();
2594
2636
  const andorraText = andorraUsage?.forms.find(text => stringWidth(model) + 1 + stringWidth(text) + 3 + jevWidth <= width - 1);
@@ -2597,7 +2639,7 @@ export class TerminalUI extends EventEmitter {
2597
2639
  lines.push(paint(pad(model, width - jevWidth - andorraWidth - 2) + ' ', GRAY) + paint(andorraText, andorraUsage.color) + paint(` · ${jev}`, GRAY));
2598
2640
  else
2599
2641
  lines.push(paint(pad(model, Math.max(0, width - jevWidth - 2)) + (width - jevWidth > 1 ? ' ' : '') + clip(jev, jevWidth), GRAY));
2600
- const graph = oneLine(`Graph: ${(status.graphSelection ?? (status.graph?.id === 'software-engineer' ? 'default' : status.graph?.id)) === 'default' ? 'Default' : status.graph?.name ?? 'Not selected'}${status.codeIntel ? ` · CodeGraph: ${status.codeIntel}` : ''}`);
2642
+ const graph = status.antigravity ? 'Harness: Antigravity ACP' : oneLine(`Graph: ${(status.graphSelection ?? (status.graph?.id === 'software-engineer' ? 'default' : status.graph?.id)) === 'default' ? 'Default' : status.graph?.name ?? 'Not selected'}${status.codeIntel ? ` · CodeGraph: ${status.codeIntel}` : ''}`);
2601
2643
  if (!compactFooter)
2602
2644
  lines.push(paint(pad(graph, width - branchWidth) + clip(`⎇ ${branch}`, branchWidth), GRAY));
2603
2645
  const count = (value) => Number.isFinite(value) && value >= 0 ? value : 0;
@@ -14,6 +14,12 @@ export declare function isTestPath(name: string): boolean;
14
14
  /** True when the task itself asks for existing tests to change, so editing them is the work and not a shortcut. */
15
15
  export declare function taskAsksForTestChanges(task: string | undefined): boolean;
16
16
  export declare function testEditNudge(edits: readonly TestEdit[], restoreFrom?: string): string;
17
+ /**
18
+ * The reminder for a run that changed code through the file tools and finishes with none of it left:
19
+ * a fix that was applied, checked and then taken out again (to compare against the original, or to
20
+ * leave the workspace as it was found) is not delivered.
21
+ */
22
+ export declare function undoneWorkNudge(files: readonly string[]): string;
17
23
  /**
18
24
  * Finds files under test locations that existed when a run started and were modified or deleted
19
25
  * during it. In a Git repository the comparison is against the commit and working tree the run
@@ -26,6 +32,8 @@ export declare class TestEditGuard {
26
32
  private readonly nudged;
27
33
  private readonly created;
28
34
  private readonly toolEdits;
35
+ private readonly sourceEdits;
36
+ private undoneAsked;
29
37
  private restoreFrom?;
30
38
  private readonly startedAt;
31
39
  private readonly stopper;
@@ -65,6 +73,18 @@ export declare class TestEditGuard {
65
73
  * a file born after the run started was made by the run (through the shell, say) and is its own to change.
66
74
  */
67
75
  noteToolMutation(target: string, existed: boolean, bornAtMs?: number): void;
76
+ /** False for a link to another file: the edit changed that file, which is reported under its own path. */
77
+ private namesItself;
78
+ /**
79
+ * The files outside test locations that existed before the run and were changed through Write or
80
+ * Edit, when the workspace's tracked code is now identical to the commit the run started from: the
81
+ * run undid everything it changed. Raised once. Nothing is reported without Git, when any tracked
82
+ * file outside test locations still differs (the work is there, perhaps in another file), when an
83
+ * edited file is not tracked (its contents cannot be compared) or already differed from the commit
84
+ * when the run started (returning it to the commit may be the fix), or on a Git failure, so a
85
+ * doubt never holds a run back.
86
+ */
87
+ undone(signal?: AbortSignal): Promise<string[]>;
68
88
  /**
69
89
  * The modified test files whose change only adds new tests: no line of the starting commit's file was
70
90
  * removed or replaced, and nothing added switches a test off or defines again a name the file already
@@ -73,6 +93,16 @@ export declare class TestEditGuard {
73
93
  */
74
94
  private onlyAddsTests;
75
95
  private current;
96
+ /**
97
+ * True, once, when the run finishes with the workspace's tracked code identical to the commit it
98
+ * started from, no edited file outside Git's view and no surviving new source file written through
99
+ * the file tools: nothing a task that calls for a change could have delivered. False without Git,
100
+ * on a Git failure, when the workspace's code already differed from the commit at the start, and
101
+ * after undone() or this has already raised the matter, so the agent is asked about it a single time.
102
+ * With testsCount, a change to a test file is work too: a request to write tests is delivered by them,
103
+ * while a defect is not fixed by a test alone.
104
+ */
105
+ unchanged(signal?: AbortSignal, testsCount?: boolean): Promise<boolean>;
76
106
  /**
77
107
  * Returns the changed pre-existing test files when at least one of them has not been reported yet,
78
108
  * and marks them reported; returns nothing otherwise, so each set of files is raised once.
@@ -22,6 +22,7 @@ const GIT_TIMEOUT_MS = 5_000;
22
22
  const HASH_FILE_LIMIT = 8 * 1024 * 1024;
23
23
  const BASELINE_DIRTY_LIMIT = 2_000;
24
24
  const MAX_NAMED_FILES = 12;
25
+ const UNTRACKED_LIMIT = 200;
25
26
  /** True for a path that holds tests, fixtures or expected output: a tests/test/testing directory, test_*.py, *_test.*, *.test.*, *.spec.*, conftest.py. */
26
27
  export function isTestPath(name) {
27
28
  const normalized = name.replace(/\\/g, '/').replace(/^\.\//, '');
@@ -53,6 +54,19 @@ export function testEditNudge(edits, restoreFrom) {
53
54
  + `Unless the task explicitly asks for these tests to change, ${restore} and change the code until the original tests pass.${keep} Adding new test files is fine, and so is adding new tests to an existing file without changing what it already holds. `
54
55
  + 'If the task does require these edits, call complete_agent again to finish; this reminder is not repeated for the same files.';
55
56
  }
57
+ /**
58
+ * The reminder for a run that changed code through the file tools and finishes with none of it left:
59
+ * a fix that was applied, checked and then taken out again (to compare against the original, or to
60
+ * leave the workspace as it was found) is not delivered.
61
+ */
62
+ export function undoneWorkNudge(files) {
63
+ const named = files.slice(0, MAX_NAMED_FILES).join(', ');
64
+ const more = files.length > MAX_NAMED_FILES ? `, and ${files.length - MAX_NAMED_FILES} more` : '';
65
+ const one = files.length === 1;
66
+ return `Completion not accepted yet. This run changed ${named}${more} and then restored ${one ? 'it' : 'them'}: the workspace now holds no change to its code. `
67
+ + 'If a change you made fixes a defect the task describes, apply it again and leave it in place. A fix that was verified and then removed is not delivered, and comparing against the original code is no reason to drop it. '
68
+ + 'If the changes were only instrumentation, or the task needs only an answer, call complete_agent again to finish; this reminder is not repeated.';
69
+ }
56
70
  function git(cwd, args, signal) {
57
71
  return new Promise((resolve, reject) => {
58
72
  execFile('git', ['-c', 'core.quotepath=off', ...args], {
@@ -99,6 +113,8 @@ export class TestEditGuard {
99
113
  nudged = new Set();
100
114
  created = new Set();
101
115
  toolEdits = new Map();
116
+ sourceEdits = new Set();
117
+ undoneAsked = false;
102
118
  restoreFrom;
103
119
  startedAt = Date.now();
104
120
  stopper = new AbortController();
@@ -164,7 +180,8 @@ export class TestEditGuard {
164
180
  }
165
181
  this.captured = true;
166
182
  this.restoreFrom = head.slice(0, 12);
167
- return { kind: 'git', root: path.resolve(root), prefix, head, dirty, unknown };
183
+ return { kind: 'git', root: path.resolve(root), prefix, head, dirty, unknown,
184
+ ...(local.length <= BASELINE_DIRTY_LIMIT ? { dirtyNames: new Set(local) } : {}) };
168
185
  }
169
186
  /**
170
187
  * Reports, before it runs, a tool that may change files: target is the file a file tool changes,
@@ -210,8 +227,73 @@ export class TestEditGuard {
210
227
  this.created.add(relative);
211
228
  return;
212
229
  }
213
- if (!this.created.has(relative) && isTestPath(relative))
230
+ if (this.created.has(relative))
231
+ return;
232
+ if (isTestPath(relative))
214
233
  this.toolEdits.set(relative, 'modified');
234
+ else if (this.namesItself(target, relative))
235
+ this.sourceEdits.add(relative);
236
+ }
237
+ /** False for a link to another file: the edit changed that file, which is reported under its own path. */
238
+ namesItself(target, relative) {
239
+ try {
240
+ return this.workspaceRelative(realpathSync(target)) === relative;
241
+ }
242
+ catch {
243
+ return true;
244
+ }
245
+ }
246
+ /**
247
+ * The files outside test locations that existed before the run and were changed through Write or
248
+ * Edit, when the workspace's tracked code is now identical to the commit the run started from: the
249
+ * run undid everything it changed. Raised once. Nothing is reported without Git, when any tracked
250
+ * file outside test locations still differs (the work is there, perhaps in another file), when an
251
+ * edited file is not tracked (its contents cannot be compared) or already differed from the commit
252
+ * when the run started (returning it to the commit may be the fix), or on a Git failure, so a
253
+ * doubt never holds a run back.
254
+ */
255
+ async undone(signal) {
256
+ if (this.undoneAsked || !this.sourceEdits.size)
257
+ return [];
258
+ const baseline = await (this.baseline ?? Promise.resolve({ kind: 'none' }));
259
+ if (baseline.kind !== 'git')
260
+ return [];
261
+ let changed;
262
+ try {
263
+ changed = (await git(this.workspace, ['diff', '--name-only', '-z', '--no-renames', '--relative', baseline.head, '--', '.'], signal)).split('\0').filter(Boolean);
264
+ }
265
+ catch {
266
+ return [];
267
+ }
268
+ if (changed.some(name => !isTestPath(name)))
269
+ return [];
270
+ // The comparison above covers tracked files only. A file Git does not track may still hold the
271
+ // run's change, so one among the edited files leaves the question open and nothing is reported.
272
+ const edited = [...this.sourceEdits];
273
+ if (edited.length > 200)
274
+ return [];
275
+ // "Identical to the commit" means "restored" only for a file that matched the commit when the run
276
+ // started. One that already differed may have been fixed by returning it to the commit, and one
277
+ // changed before the starting state was recorded has an unknown start.
278
+ if (!baseline.dirtyNames || this.racedUnknown || edited.some(name => baseline.dirtyNames.has(name) || this.racedPaths.has(name)))
279
+ return [];
280
+ let tracked;
281
+ try {
282
+ tracked = new Set((await git(this.workspace, ['ls-files', '-z', '--', ...edited], signal)).split('\0').filter(Boolean));
283
+ }
284
+ catch {
285
+ return [];
286
+ }
287
+ if (edited.some(name => !tracked.has(name)))
288
+ return [];
289
+ // Work delivered in a new file the run wrote, which Git does not list until it is added. An edit
290
+ // that replaces a file gives it a new creation time, so a file first seen as existing is not new.
291
+ for (const name of this.created) {
292
+ if (!isTestPath(name) && !this.sourceEdits.has(name) && await contentHash(path.join(this.workspace, name)) !== null)
293
+ return [];
294
+ }
295
+ this.undoneAsked = true;
296
+ return edited.sort((a, b) => a.localeCompare(b));
215
297
  }
216
298
  /**
217
299
  * The modified test files whose change only adds new tests: no line of the starting commit's file was
@@ -291,6 +373,89 @@ export class TestEditGuard {
291
373
  : unknown?.has(name) ? { path: name, state, startUnknown: true } : { path: name, state })
292
374
  .sort((a, b) => a.path.localeCompare(b.path));
293
375
  }
376
+ /**
377
+ * True, once, when the run finishes with the workspace's tracked code identical to the commit it
378
+ * started from, no edited file outside Git's view and no surviving new source file written through
379
+ * the file tools: nothing a task that calls for a change could have delivered. False without Git,
380
+ * on a Git failure, when the workspace's code already differed from the commit at the start, and
381
+ * after undone() or this has already raised the matter, so the agent is asked about it a single time.
382
+ * With testsCount, a change to a test file is work too: a request to write tests is delivered by them,
383
+ * while a defect is not fixed by a test alone.
384
+ */
385
+ async unchanged(signal, testsCount = false) {
386
+ const counts = (name) => testsCount || !isTestPath(name);
387
+ if (this.undoneAsked)
388
+ return false;
389
+ const baseline = await (this.baseline ?? Promise.resolve({ kind: 'none' }));
390
+ if (baseline.kind !== 'git')
391
+ return false;
392
+ // "Identical to the commit" means "nothing was delivered" only when the workspace's code matched
393
+ // the commit at the start: with source already changed then, returning it to the commit may be
394
+ // the fix. The same doubt holds when a tool changed files before the starting state was recorded.
395
+ if (!baseline.dirtyNames || this.racedUnknown || this.racedPaths.size
396
+ || [...baseline.dirtyNames].some(counts))
397
+ return false;
398
+ let changed;
399
+ try {
400
+ changed = (await git(this.workspace, ['diff', '--name-only', '--no-renames', '--relative', baseline.head, '--', '.'], signal)).split(/\r?\n/).filter(Boolean);
401
+ }
402
+ catch {
403
+ return false;
404
+ }
405
+ if (changed.some(counts))
406
+ return false;
407
+ // Git's comparison covers tracked files. Work may sit in an edited file Git does not track, or in a
408
+ // new file the run wrote that still exists.
409
+ const edited = [...this.sourceEdits];
410
+ if (edited.length > 200)
411
+ return false;
412
+ if (edited.length) {
413
+ let tracked;
414
+ try {
415
+ tracked = new Set((await git(this.workspace, ['ls-files', '--', ...edited], signal)).split(/\r?\n/).filter(Boolean));
416
+ }
417
+ catch {
418
+ return false;
419
+ }
420
+ if (edited.some(name => !tracked.has(name)))
421
+ return false;
422
+ }
423
+ for (const name of this.created) {
424
+ if (counts(name) && !this.sourceEdits.has(name) && await contentHash(path.join(this.workspace, name)) !== null)
425
+ return false;
426
+ }
427
+ // A shell command or subagent can write a new file without reporting it. Git lists such files as
428
+ // untracked; one written since the run started is the run's work, an older one was already there.
429
+ // An untracked directory may hold either, and too long a list is not examined: both abstain.
430
+ if (this.opaque) {
431
+ let untracked;
432
+ try {
433
+ untracked = statusPaths(await git(this.workspace, ['status', '--porcelain=v1', '-z', '--untracked-files=normal', '--', '.'], signal)
434
+ .then(output => output.split('\0').filter(entry => entry.startsWith('?? ')).join('\0')));
435
+ }
436
+ catch {
437
+ return false;
438
+ }
439
+ if (untracked.length > UNTRACKED_LIMIT)
440
+ return false;
441
+ for (const listed of untracked) {
442
+ const name = listed.startsWith(baseline.prefix) ? listed.slice(baseline.prefix.length) : listed;
443
+ if (!counts(name.replace(/\/$/, '')))
444
+ continue;
445
+ if (name.endsWith('/'))
446
+ return false;
447
+ try {
448
+ if ((await stat(path.join(this.workspace, name))).mtimeMs >= this.startedAt)
449
+ return false;
450
+ }
451
+ catch {
452
+ return false;
453
+ }
454
+ }
455
+ }
456
+ this.undoneAsked = true;
457
+ return true;
458
+ }
294
459
  /**
295
460
  * Returns the changed pre-existing test files when at least one of them has not been reported yet,
296
461
  * and marks them reported; returns nothing otherwise, so each set of files is raised once.
@@ -0,0 +1,13 @@
1
+ import { type ProviderConfig, type ReasoningEffort } from './providers.js';
2
+ import type { ModelAdapter } from './types.js';
3
+ /** The smallest output allowance at which an Anthropic request still thinks: a 1024-token budget plus 1024 to answer. */
4
+ export declare const ANTHROPIC_PROBE_MAX_TOKENS = 2048;
5
+ /** One minimal request at a level, answered with the HTTP status the provider gave it. Throws when there was none. */
6
+ export declare function probeLevel(adapter: ModelAdapter, model: string, signal: AbortSignal, maxTokens?: number): Promise<number>;
7
+ /** The levels the Codex and Claude command-line clients take. The client fixes them, so no request is spent asking. */
8
+ export declare const SIGN_IN_LEVELS: Partial<Record<string, readonly ReasoningEffort[]>>;
9
+ /**
10
+ * The thinking levels a provider's model accepts: from the built-in catalog for a catalogued Anthropic model, else by
11
+ * asking the provider once per level. Undefined when the provider type takes no level or the answer was inconclusive.
12
+ */
13
+ export declare function detectProviderLevels(provider: ProviderConfig, model: string, signal: AbortSignal, adapterFor?: (snapshot: ProviderConfig) => ModelAdapter, onAccepted?: (level: ReasoningEffort) => void): Promise<ReasoningEffort[] | undefined>;
@@ -0,0 +1,52 @@
1
+ import { anthropicCatalogLevels } from './provider-engine.js';
2
+ import { createAdapter, ProviderRequestError, supportsReasoningEffort } from './providers.js';
3
+ import { detectLevels } from './thinking-levels.js';
4
+ /** The smallest output allowance at which an Anthropic request still thinks: a 1024-token budget plus 1024 to answer. */
5
+ export const ANTHROPIC_PROBE_MAX_TOKENS = 2048;
6
+ /** One minimal request at a level, answered with the HTTP status the provider gave it. Throws when there was none. */
7
+ export async function probeLevel(adapter, model, signal, maxTokens = 16) {
8
+ // A retryable failure (rate limit, server error, timeout) says nothing about the level, and waiting through the
9
+ // adapter's retries would stall the probe: the first retry ends it.
10
+ const controller = new AbortController();
11
+ const bounded = AbortSignal.any([signal, controller.signal]);
12
+ let retried = false;
13
+ try {
14
+ await adapter.generate({ model, messages: [{ role: 'user', content: 'Reply with OK.' }], tools: [], signal: bounded, maxTokens,
15
+ onRetry: () => { retried = true; controller.abort(); } });
16
+ return 200;
17
+ }
18
+ catch (error) {
19
+ signal.throwIfAborted();
20
+ if (retried)
21
+ return 503;
22
+ if (!(error instanceof ProviderRequestError))
23
+ throw error;
24
+ // A refusal the adapter does not retry carries its status; one it would retry carries it in its telemetry code.
25
+ const direct = error.status;
26
+ const status = typeof direct === 'number' ? direct : Number(/^http_(\d{3})$/.exec(error.telemetryCode ?? '')?.[1]);
27
+ if (!Number.isInteger(status))
28
+ throw error;
29
+ return status;
30
+ }
31
+ }
32
+ /** The levels the Codex and Claude command-line clients take. The client fixes them, so no request is spent asking. */
33
+ export const SIGN_IN_LEVELS = {
34
+ codex: ['minimal', 'low', 'medium', 'high', 'xhigh'],
35
+ claude: ['low', 'medium', 'high', 'xhigh', 'max'],
36
+ };
37
+ /**
38
+ * The thinking levels a provider's model accepts: from the built-in catalog for a catalogued Anthropic model, else by
39
+ * asking the provider once per level. Undefined when the provider type takes no level or the answer was inconclusive.
40
+ */
41
+ export async function detectProviderLevels(provider, model, signal, adapterFor = snapshot => createAdapter(snapshot), onAccepted) {
42
+ if (!supportsReasoningEffort(provider.type) || provider.type === 'relayed')
43
+ return undefined;
44
+ const catalog = provider.type === 'anthropic' ? anthropicCatalogLevels(model) : SIGN_IN_LEVELS[provider.type];
45
+ return detectLevels((effort, probeSignal) => {
46
+ const snapshot = { ...provider, model, reasoningEffort: effort };
47
+ delete snapshot.thinkingLevels;
48
+ // An Anthropic request with a small output allowance has thinking turned off whatever level was asked for (the
49
+ // budget must leave 1024 tokens), so the probe would test nothing: give it room for the smallest budget.
50
+ return probeLevel(adapterFor(snapshot), model, probeSignal, provider.type === 'anthropic' ? ANTHROPIC_PROBE_MAX_TOKENS : 16);
51
+ }, signal, catalog, onAccepted);
52
+ }
@@ -0,0 +1,30 @@
1
+ import { type ProviderConfig, type ReasoningEffort } from './providers.js';
2
+ /** The thinking levels one model accepts and the ones the user switched off, as saved on its provider. */
3
+ export interface ModelThinkingLevels {
4
+ supported?: ReasoningEffort[];
5
+ disabled?: ReasoningEffort[];
6
+ }
7
+ /**
8
+ * The levels a model may run at, lowest first: the ones it accepts minus the ones switched off. A model nobody has
9
+ * detected yet counts as accepting every level, which is what the engine sent before levels were tracked.
10
+ */
11
+ export declare function enabledLevels(provider: Pick<ProviderConfig, 'type' | 'thinkingLevels'> | undefined, model: string): ReasoningEffort[];
12
+ /**
13
+ * The levels Auto may pick for a model. For a detected model these are its enabled levels. For one nobody has
14
+ * detected, Auto stays inside the widely accepted levels, so that it never sends a level the provider would refuse
15
+ * and fail the run; a level the user sets by hand is still sent as written.
16
+ */
17
+ export declare function autoLevels(provider: Pick<ProviderConfig, 'type' | 'thinkingLevels'> | undefined, model: string): ReasoningEffort[];
18
+ /** The wanted level when it is enabled, else the closest enabled one, the higher of two equally close. */
19
+ export declare function nearestEnabled(levels: readonly ReasoningEffort[], wanted: ReasoningEffort): ReasoningEffort | undefined;
20
+ export declare function validateThinkingLevels(value: unknown, providerType: string): void;
21
+ /**
22
+ * Which levels a model accepts. A catalogued model answers from the catalog. Any other is asked once per level with
23
+ * `send`, which returns the HTTP status of one minimal request at that level; a 2xx keeps the level. Returns undefined,
24
+ * so that nothing is saved, when the server could not be reached or refused for a reason unrelated to the level.
25
+ */
26
+ export declare function detectLevels(send: (effort: ReasoningEffort, signal: AbortSignal) => Promise<number>, signal: AbortSignal, catalog?: readonly ReasoningEffort[], onAccepted?: (level: ReasoningEffort) => void): Promise<ReasoningEffort[] | undefined>;
27
+ /** The provider with a model's detected levels saved. The user's switched-off levels are kept where still accepted. */
28
+ export declare function withDetectedLevels<T extends Pick<ProviderConfig, 'thinkingLevels'>>(provider: T, model: string, supported: readonly ReasoningEffort[]): T;
29
+ /** The provider with a model's switched-off levels replaced. Throws when that would leave no level enabled. */
30
+ export declare function withDisabledLevels<T extends Pick<ProviderConfig, 'thinkingLevels'>>(provider: T, model: string, disabled: readonly ReasoningEffort[]): T;