@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
@@ -0,0 +1,131 @@
1
+ import { REASONING_EFFORTS, supportsReasoningEffort } from './providers.js';
2
+ // Read at call time, not at load: this module and the provider module can be loaded in either order.
3
+ const position = (level) => REASONING_EFFORTS.indexOf(level);
4
+ const isLevel = (value) => typeof value === 'string' && REASONING_EFFORTS.includes(value);
5
+ const ordered = (levels) => REASONING_EFFORTS.filter(level => new Set(levels).has(level));
6
+ /**
7
+ * The levels a model may run at, lowest first: the ones it accepts minus the ones switched off. A model nobody has
8
+ * detected yet counts as accepting every level, which is what the engine sent before levels were tracked.
9
+ */
10
+ export function enabledLevels(provider, model) {
11
+ if (!provider || !supportsReasoningEffort(provider.type))
12
+ return [];
13
+ const entry = provider.thinkingLevels?.[model];
14
+ if (provider.type === 'andorra' && entry?.supported === undefined)
15
+ return [];
16
+ const disabled = new Set(entry?.disabled ?? []);
17
+ return ordered(entry?.supported ?? REASONING_EFFORTS).filter(level => !disabled.has(level));
18
+ }
19
+ /** The levels nearly every provider that takes a level accepts. */
20
+ const WIDELY_ACCEPTED = ['low', 'medium', 'high'];
21
+ /**
22
+ * The levels Auto may pick for a model. For a detected model these are its enabled levels. For one nobody has
23
+ * detected, Auto stays inside the widely accepted levels, so that it never sends a level the provider would refuse
24
+ * and fail the run; a level the user sets by hand is still sent as written.
25
+ */
26
+ export function autoLevels(provider, model) {
27
+ const enabled = enabledLevels(provider, model);
28
+ return provider?.thinkingLevels?.[model]?.supported === undefined ? enabled.filter(level => WIDELY_ACCEPTED.includes(level)) : enabled;
29
+ }
30
+ /** The wanted level when it is enabled, else the closest enabled one, the higher of two equally close. */
31
+ export function nearestEnabled(levels, wanted) {
32
+ if (levels.includes(wanted))
33
+ return wanted;
34
+ const at = position(wanted);
35
+ let best;
36
+ let distance = Infinity;
37
+ for (const level of levels) {
38
+ const gap = Math.abs(position(level) - at);
39
+ if (gap < distance || (gap === distance && position(level) > at)) {
40
+ best = level;
41
+ distance = gap;
42
+ }
43
+ }
44
+ return best;
45
+ }
46
+ export function validateThinkingLevels(value, providerType) {
47
+ if (value === undefined)
48
+ return;
49
+ const fail = () => { throw new Error('Invalid thinkingLevels: a map of model ids to { supported, disabled } lists of none, minimal, low, medium, high, xhigh or max, with at least one thinking level left enabled'); };
50
+ if (!supportsReasoningEffort(providerType))
51
+ throw new Error('thinkingLevels belongs to a provider that accepts a thinking level');
52
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
53
+ fail();
54
+ for (const [model, entry] of Object.entries(value)) {
55
+ if (!model.trim() || model.length > 500 || typeof entry !== 'object' || entry === null || Array.isArray(entry))
56
+ fail();
57
+ const { supported, disabled, ...rest } = entry;
58
+ if (Object.keys(rest).length)
59
+ fail();
60
+ for (const list of [supported, disabled]) {
61
+ if (list === undefined)
62
+ continue;
63
+ if (!Array.isArray(list) || list.some(level => !isLevel(level)) || new Set(list).size !== list.length)
64
+ fail();
65
+ }
66
+ const off = new Set(disabled ?? []);
67
+ if (!(supported ?? REASONING_EFFORTS).some(level => !off.has(level))
68
+ && (supported?.length ?? 1) > 0)
69
+ fail();
70
+ }
71
+ }
72
+ /** HTTP answers that say nothing about the level asked for: the request never reached a decision on it. */
73
+ const INCONCLUSIVE = new Set([401, 403, 404, 408, 429]);
74
+ /**
75
+ * Which levels a model accepts. A catalogued model answers from the catalog. Any other is asked once per level with
76
+ * `send`, which returns the HTTP status of one minimal request at that level; a 2xx keeps the level. Returns undefined,
77
+ * so that nothing is saved, when the server could not be reached or refused for a reason unrelated to the level.
78
+ */
79
+ export async function detectLevels(send, signal, catalog, onAccepted) {
80
+ if (catalog) {
81
+ const levels = ordered(catalog);
82
+ levels.forEach(level => onAccepted?.(level));
83
+ return levels;
84
+ }
85
+ const accepted = [];
86
+ for (const level of REASONING_EFFORTS) {
87
+ signal.throwIfAborted();
88
+ let status;
89
+ try {
90
+ status = await send(level, signal);
91
+ }
92
+ catch {
93
+ signal.throwIfAborted();
94
+ return undefined;
95
+ }
96
+ if (INCONCLUSIVE.has(status) || status >= 500)
97
+ return undefined;
98
+ if (status >= 200 && status < 300) {
99
+ accepted.push(level);
100
+ onAccepted?.(level);
101
+ }
102
+ }
103
+ return accepted;
104
+ }
105
+ /** The provider with a model's detected levels saved. The user's switched-off levels are kept where still accepted. */
106
+ export function withDetectedLevels(provider, model, supported) {
107
+ const levels = ordered(supported);
108
+ const kept = (provider.thinkingLevels?.[model]?.disabled ?? []).filter(level => levels.includes(level));
109
+ const disabled = kept.length >= levels.length ? [] : ordered(kept);
110
+ return { ...provider, thinkingLevels: { ...provider.thinkingLevels, [model]: { supported: levels, ...(disabled.length ? { disabled } : {}) } } };
111
+ }
112
+ /** The provider with a model's switched-off levels replaced. Throws when that would leave no level enabled. */
113
+ export function withDisabledLevels(provider, model, disabled) {
114
+ const entry = provider.thinkingLevels?.[model];
115
+ const supported = entry?.supported ?? [...REASONING_EFFORTS];
116
+ const off = ordered(disabled.filter(level => supported.includes(level)));
117
+ if (supported.length > 0 && off.length >= supported.length)
118
+ throw new Error('At least one thinking level must stay enabled');
119
+ const next = { ...(entry?.supported ? { supported: entry.supported } : {}), ...(off.length ? { disabled: off } : {}) };
120
+ const all = { ...provider.thinkingLevels };
121
+ if (Object.keys(next).length)
122
+ all[model] = next;
123
+ else
124
+ delete all[model];
125
+ const result = { ...provider };
126
+ if (Object.keys(all).length)
127
+ result.thinkingLevels = all;
128
+ else
129
+ delete result.thinkingLevels;
130
+ return result;
131
+ }
@@ -7,8 +7,11 @@ export interface WakeCarry {
7
7
  graph?: string;
8
8
  provider?: string;
9
9
  model?: string;
10
+ /** A thinking level, or 'auto' for a run whose own level is Auto. */
10
11
  reasoningEffort?: string;
11
12
  overrideAllNodes?: boolean;
13
+ /** The run was on Auto: the runs its wakes start are on Auto too. */
14
+ autoModel?: boolean;
12
15
  panelBrowserRelay?: boolean;
13
16
  /** The session's run used a desktop's providers: a wake cannot start it here, only a resume from that desktop can. */
14
17
  relayed?: boolean;
@@ -3,9 +3,10 @@ export interface TodoItem {
3
3
  id: string;
4
4
  text: string;
5
5
  status: TodoStatus;
6
+ parentId?: string;
6
7
  }
7
8
  export declare class TodoStore {
8
9
  private items;
9
10
  snapshot(): TodoItem[];
10
- update(value: unknown, maxSerializedChars?: number): TodoItem[];
11
+ update(value: unknown, maxSerializedChars?: number, omittedIds?: ReadonlySet<string>): TodoItem[];
11
12
  }
package/dist/src/todos.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export class TodoStore {
2
2
  items = [];
3
3
  snapshot() { return this.items.map(item => ({ ...item })); }
4
- update(value, maxSerializedChars = 12_000) {
4
+ update(value, maxSerializedChars = 12_000, omittedIds) {
5
5
  if (!Array.isArray(value) || value.length < 1 || value.length > 100)
6
6
  throw new Error('todos must contain 1-100 items');
7
7
  const ids = new Set();
@@ -9,7 +9,7 @@ export class TodoStore {
9
9
  if (!item || typeof item !== 'object' || Array.isArray(item))
10
10
  throw new Error('Each todo must be an object');
11
11
  const todo = item;
12
- if (Object.keys(todo).some(key => !['id', 'text', 'status'].includes(key))
12
+ if (Object.keys(todo).some(key => !['id', 'text', 'status', 'parentId'].includes(key))
13
13
  || typeof todo.id !== 'string' || !todo.id.trim() || todo.id.length > 80
14
14
  || typeof todo.text !== 'string' || !todo.text.trim() || todo.text.length > 500
15
15
  || typeof todo.status !== 'string' || !['pending', 'in_progress', 'completed'].includes(todo.status)) {
@@ -19,12 +19,32 @@ export class TodoStore {
19
19
  if (ids.has(id))
20
20
  throw new Error(`Duplicate todo id: ${id}`);
21
21
  ids.add(id);
22
- return { id, text: todo.text.trim(), status: todo.status };
22
+ if (todo.parentId !== undefined && (typeof todo.parentId !== 'string' || !todo.parentId.trim() || todo.parentId.length > 80)) {
23
+ throw new Error('parentId must be a nonempty string of at most 80 characters');
24
+ }
25
+ return { id, text: todo.text.trim(), status: todo.status, ...(todo.parentId === undefined ? {} : { parentId: todo.parentId.trim() }) };
23
26
  });
24
27
  if (JSON.stringify(JSON.stringify(next)).length > maxSerializedChars) {
25
28
  throw new Error(`Serialized todos exceed ${maxSerializedChars} characters; publish a shorter plan`);
26
29
  }
27
- this.items = next;
30
+ const merged = [...next, ...this.items.filter(item => omittedIds?.has(item.id) && !ids.has(item.id))];
31
+ const byId = new Map(merged.map(item => [item.id, item]));
32
+ const subtasks = new Map();
33
+ for (const item of merged) {
34
+ if (item.parentId === undefined)
35
+ continue;
36
+ const parent = byId.get(item.parentId);
37
+ if (!parent || parent.parentId !== undefined) {
38
+ throw new Error(`Subtask "${item.id}" must reference a top-level todo by parentId ("${item.parentId}")`);
39
+ }
40
+ const siblings = subtasks.get(parent.id) ?? [];
41
+ siblings.push(item);
42
+ subtasks.set(parent.id, siblings);
43
+ }
44
+ if (merged.length > 100 || JSON.stringify(JSON.stringify(merged)).length > 12_000) {
45
+ throw new Error('The plan including retained todos must fit within 100 items and 12000 serialized characters');
46
+ }
47
+ this.items = merged.filter(item => item.parentId === undefined).flatMap(item => [item, ...(subtasks.get(item.id) ?? [])]);
28
48
  return this.snapshot();
29
49
  }
30
50
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Models sometimes write a tool argument as a string that plainly spells the declared type: "60000" for an
3
+ * integer, "true" for a boolean, a JSON-encoded list for an array. Schema validation used to reject the whole
4
+ * call for that. This takes the value the string spells, for top-level properties only, and leaves anything
5
+ * ambiguous alone so validation still reports it.
6
+ */
7
+ export declare function coerceStringArguments(args: unknown, schema: unknown): unknown;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Models sometimes write a tool argument as a string that plainly spells the declared type: "60000" for an
3
+ * integer, "true" for a boolean, a JSON-encoded list for an array. Schema validation used to reject the whole
4
+ * call for that. This takes the value the string spells, for top-level properties only, and leaves anything
5
+ * ambiguous alone so validation still reports it.
6
+ */
7
+ export function coerceStringArguments(args, schema) {
8
+ if (!isRecord(args) || !isRecord(schema) || !isRecord(schema.properties))
9
+ return args;
10
+ let result;
11
+ for (const [key, value] of Object.entries(args)) {
12
+ if (typeof value !== 'string')
13
+ continue;
14
+ const property = schema.properties[key];
15
+ if (!isRecord(property))
16
+ continue;
17
+ const types = Array.isArray(property.type) ? property.type : [property.type];
18
+ if (types.includes('string'))
19
+ continue;
20
+ const coerced = coerce(value, types);
21
+ if (coerced === undefined)
22
+ continue;
23
+ result ??= { ...args };
24
+ result[key] = coerced;
25
+ }
26
+ return result ?? args;
27
+ }
28
+ function coerce(value, types) {
29
+ const text = value.trim();
30
+ if ((types.includes('integer') || types.includes('number')) && /^-?\d+(?:\.\d+)?$/.test(text)) {
31
+ const number = Number(text);
32
+ if (Number.isFinite(number) && (types.includes('number') || Number.isSafeInteger(number)))
33
+ return number;
34
+ }
35
+ if (types.includes('boolean') && (text === 'true' || text === 'false'))
36
+ return text === 'true';
37
+ if ((types.includes('array') && text.startsWith('[')) || (types.includes('object') && text.startsWith('{'))) {
38
+ try {
39
+ const parsed = JSON.parse(text);
40
+ if (Array.isArray(parsed) ? types.includes('array') : isRecord(parsed) && types.includes('object'))
41
+ return parsed;
42
+ }
43
+ catch { /* not JSON: validation reports the string as it was sent */ }
44
+ }
45
+ return undefined;
46
+ }
47
+ function isRecord(value) {
48
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
49
+ }
@@ -1,4 +1,4 @@
1
- import type { Tool } from './types.js';
1
+ import type { Tool, ToolSchema } from './types.js';
2
2
  import type { WorkspaceFacts } from './workspace-facts.js';
3
3
  export interface CatalogSelectionInput {
4
4
  tools: Tool[];
@@ -16,7 +16,7 @@ export interface CatalogSelection {
16
16
  schemaCharsBefore: number;
17
17
  schemaCharsAfter: number;
18
18
  }
19
- export declare function schemaChars(tools: readonly Tool[]): number;
19
+ export declare function schemaChars(tools: readonly ToolSchema[]): number;
20
20
  export declare function selectToolCatalog(input: CatalogSelectionInput): CatalogSelection;
21
21
  export interface SkillSummary {
22
22
  id: string;
@@ -1,7 +1,7 @@
1
1
  import { toolFamily } from './decision/toolFamilies.js';
2
2
  import { canonicalToolName } from './tool-names.js';
3
3
  import { identifierTokens } from './context-selection.js';
4
- const PROTECTED = new Set(['complete_agent', 'complete', 'complete_task', 'submit_completion', 'update_todos', 'ask_user', 'submit_bug_report', 'load_project_skill', 'restore_tools', 'prepare_steps', 'update_widget', 'Skill', 'read_skill_resource', 'expand_tool_output', 'read_artifact', 'write_artifact']);
4
+ const PROTECTED = new Set(['complete_agent', 'complete', 'complete_task', 'submit_completion', 'update_todos', 'ask_user', 'submit_bug_report', 'list_bug_report_sessions', 'load_project_skill', 'restore_tools', 'prepare_steps', 'update_widget', 'Skill', 'read_skill_resource', 'expand_tool_output', 'read_artifact', 'write_artifact']);
5
5
  const GIT_WORDS = /\b(git|commit|branch|rebase|merge|stash|diff|blame|checkout|pull request|pr\b|push|history|log)\b/i;
6
6
  const MEMORY_WORDS = /\b(remember|recall|memory|previous(ly)?|last time|earlier|convention|decision history)\b/i;
7
7
  const WEB_WORDS = /\b(docs?|documentation|https?:\/\/|url|website|web|online|latest version|api reference|changelog|npm package|look up|search the)\b/i;
package/dist/src/tools.js CHANGED
@@ -383,6 +383,13 @@ export async function authorize(name, args, context) {
383
383
  }
384
384
  }
385
385
  }
386
+ /** The notice a caller of files() shows when the walk skipped folders it could not open; undefined when none were skipped. */
387
+ function skippedFoldersNotice(budget, covered) {
388
+ const count = budget.unreadable ?? 0;
389
+ if (!count)
390
+ return undefined;
391
+ return `[INCOMPLETE ${covered === 'listed' ? 'LISTING' : 'SEARCH'}: ${count.toLocaleString('en-US')} folder${count === 1 ? '' : 's'} could not be opened (permission denied) and ${count === 1 ? 'was' : 'were'} skipped. Files inside ${count === 1 ? 'it' : 'them'} were not ${covered}, so this result does not show that a file or match is absent.]`;
392
+ }
386
393
  async function* files(context, directory, depth = 0, budget = { entries: 0 }) {
387
394
  if (depth > 20)
388
395
  return;
@@ -392,7 +399,21 @@ async function* files(context, directory, depth = 0, budget = { entries: 0 }) {
392
399
  ? await fileProtectedRoots(await realpath(context.workspace)) : [];
393
400
  const homeGuarded = guardsHarnessHome(context);
394
401
  const workspaceRoot = homeGuarded ? await realpath(context.workspace) : '';
395
- for await (const entry of await opendir(resolved)) {
402
+ let listing;
403
+ try {
404
+ listing = await opendir(resolved);
405
+ }
406
+ catch (error) {
407
+ // A folder the user may not open (another user's container volume, a systemd private /tmp folder) is
408
+ // skipped and counted, so one such folder no longer fails the whole listing.
409
+ const code = error?.code;
410
+ if (depth > 0 && (code === 'EACCES' || code === 'EPERM')) {
411
+ budget.unreadable = (budget.unreadable ?? 0) + 1;
412
+ return;
413
+ }
414
+ throw error;
415
+ }
416
+ for await (const entry of listing) {
396
417
  context.signal.throwIfAborted();
397
418
  if (++budget.entries > (budget.limit ?? 10_000))
398
419
  throw new Error(`Directory scan limit reached (${(budget.limit ?? 10_000).toLocaleString('en-US')} entries); use a narrower path`);
@@ -622,10 +643,19 @@ const REVIEW_END_TEXT = {
622
643
  };
623
644
  function reviewLoopEndAnswer(ended) {
624
645
  const why = REVIEW_END_TEXT[ended.reason] ?? (ended.detail === undefined ? '' : ended.detail);
625
- const next = ended.pullRequest.autoFix
626
- ? 'Auto-fix is still on: call await_review again to wait for other reviewers, or finish and report.'
627
- : 'There is no review left to wait for; finish your work and report.';
628
- return `The Andorra review loop ended: ${ended.reason}.${why ? ` ${why}` : ''} ${next}`;
646
+ return `The Andorra review loop ended: ${ended.reason}.${why ? ` ${why}` : ''} If another review is needed, call await_review again.`;
647
+ }
648
+ function reviewReactionLines(reactions) {
649
+ if (reactions.length === 0)
650
+ return '';
651
+ const icons = {
652
+ THUMBS_UP: '+1', THUMBS_DOWN: '-1', EYES: 'eyes', HEART: 'heart',
653
+ HOORAY: 'hooray', LAUGH: 'laugh', CONFUSED: 'confused', ROCKET: 'rocket',
654
+ };
655
+ const lines = reactions.slice(0, 20).map(reaction => `- ${reaction.actor ?? 'A GitHub account'} ${reaction.kind} ${icons[reaction.content] ?? reaction.content}`);
656
+ if (reactions.length > lines.length)
657
+ lines.push(`- ${reactions.length - lines.length} more reaction changes on GitHub`);
658
+ return `\nMain-post reaction changes:\n${lines.join('\n')}`;
629
659
  }
630
660
  function reviewWaitAnswer(ended, minutes, signal) {
631
661
  switch (ended.kind) {
@@ -634,10 +664,19 @@ function reviewWaitAnswer(ended, minutes, signal) {
634
664
  case 'review-ended': return reviewLoopEndAnswer(ended);
635
665
  case 'comments': return `${ended.prompt}
636
666
 
637
- When this round is pushed and its threads are answered, call pull_request with action await_review again to wait for the next review.`;
638
- case 'approved': return `Codex signed off on ${ended.pullRequest.url}${ended.headSha === undefined ? '' : ` at ${ended.headSha.slice(0, 10)}`}: it reviewed that commit and found nothing (its thumbs-up on the pull request, or a review with no findings), and no new review comment is waiting. Treat this as an approval of that commit. There is no review left to wait for; finish your work and report, and merge only if the user asked you to. Call await_review again only after you push another commit.`;
639
- case 'finished': return `${ended.pullRequest.url} is ${ended.pullRequest.state}, so Auto-fix is off and there is no review left to wait for. Finish your work and report.`;
640
- case 'off': return `Auto-fix is off for ${ended.pullRequest.url} and no Andorra review loop is running, so no review will be waited for. Finish your work and report; switch Auto-fix or Andorra review on only if the user asks.`;
667
+ If another review is needed after you push and answer its threads, call pull_request with action await_review again.`;
668
+ case 'activity': {
669
+ const comments = ended.comments.map(comment => {
670
+ const label = comment.kind === 'approval' ? 'Possible approval comment' : comment.kind === 'review' ? 'Code-review comment' : 'Review activity (unclassified)';
671
+ const location = comment.url ?? comment.threadId;
672
+ return `- ${label} from ${comment.author}${location ? ` (${location})` : ''}`;
673
+ });
674
+ const notices = comments.length > 0 ? `\n${comments.join('\n')}` : '';
675
+ return `New activity on ${ended.pullRequest.url}.${notices}${reviewReactionLines(ended.reactions)}
676
+ Read the relevant comments or reactions on GitHub before acting. Comment labels are advisory. Verify any approval against the current head, and merge only if authorized. Call pull_request with action await_review again if the task needs further monitoring.`;
677
+ }
678
+ case 'approved': return `Codex signed off on ${ended.pullRequest.url}${ended.headSha === undefined ? '' : ` at ${ended.headSha.slice(0, 10)}`}: it reviewed that commit and found nothing (its thumbs-up on the pull request, or a review with no findings), and no new review comment is waiting. Treat this as an approval of that commit. There is no review left to wait for; finish your work and report, and merge only if the user asked you to. Call await_review again if the task needs further monitoring.${reviewReactionLines(ended.reactions ?? [])}`;
679
+ case 'finished': return `${ended.pullRequest.url} is ${ended.pullRequest.state}, so there is no review left to wait for. Finish your work and report.`;
641
680
  case 'none': return 'No pull request is tracked for this session, so there is no review to wait for.';
642
681
  case 'timeout': return `No new review arrived in ${minutes} minute${minutes === 1 ? '' : 's'}. Call await_review again to keep waiting, or finish and report.`;
643
682
  case 'steered': return 'The user sent you a message while you were waiting for a review. Read and answer it; call await_review again afterwards if the review loop should continue.';
@@ -655,13 +694,17 @@ export function createTools() {
655
694
  }, ['path'], readFileTool),
656
695
  legacyTool('list_files', 'Recursively list up to 1,000 files, depth 20; skip symlinks, .git, node_modules and .andorracode.', { path: property('Workspace-relative directory, default .') }, [], async (args, context) => {
657
696
  const result = [];
658
- for await (const name of files(context, args.path === undefined ? '.' : string(args, 'path'))) {
697
+ const budget = { entries: 0 };
698
+ for await (const name of files(context, args.path === undefined ? '.' : string(args, 'path'), 0, budget)) {
659
699
  result.push(name);
660
700
  if (result.length >= 1000) {
661
701
  result.push('[file limit reached]');
662
702
  break;
663
703
  }
664
704
  }
705
+ const skipped = skippedFoldersNotice(budget, 'listed');
706
+ if (skipped)
707
+ result.unshift(skipped);
665
708
  return bounded(result.join('\n'));
666
709
  }),
667
710
  legacyTool('search_files', 'Bounded source search. Default smart mode is case-insensitive and relaxes whitespace/extra words plus simple word suffixes (for example "Create new graph" matches "Create a new Graph" and "Edit graph" matches "Edit Graphs"). Use mode=regex for an explicit JavaScript regular expression or mode=literal for substring matching. Searches at most 1,000 files and 16 MiB; returns 50 matches by default (max 200), with long matching lines clipped. Prefer repo_explore/CodeGraph first when it is available; use this as textual fallback or exact confirmation.', {
@@ -707,7 +750,8 @@ export function createTools() {
707
750
  }
708
751
  const result = [];
709
752
  let count = 0, bytes = 0, outputChars = 0;
710
- for await (const name of files(context, args.path === undefined ? '.' : string(args, 'path'))) {
753
+ const searchBudget = { entries: 0 };
754
+ for await (const name of files(context, args.path === undefined ? '.' : string(args, 'path'), 0, searchBudget)) {
711
755
  if (++count > 1000) {
712
756
  result.push('[file limit reached; narrow path]');
713
757
  break;
@@ -738,11 +782,14 @@ export function createTools() {
738
782
  result.push(match);
739
783
  outputChars += match.length + 1;
740
784
  if (result.length >= maxResults || outputChars > 12_000) {
741
- return bounded(result.join('\n') + '\n[match/output limit reached; narrow path/query or raise maxResults]');
785
+ const skippedSoFar = skippedFoldersNotice(searchBudget, 'searched');
786
+ return bounded((skippedSoFar ? skippedSoFar + '\n' : '') + result.join('\n') + '\n[match/output limit reached; narrow path/query or raise maxResults]');
742
787
  }
743
788
  }
744
789
  }
745
- return bounded(result.join('\n')) || 'No matches';
790
+ const skipped = skippedFoldersNotice(searchBudget, 'searched');
791
+ const body = bounded(result.join('\n')) || 'No matches';
792
+ return skipped ? skipped + '\n' + body : body;
746
793
  }),
747
794
  legacyTool('write_file', 'Create or overwrite a UTF-8 workspace file; obeys workspace permissions; protected or outside paths require approval.', { path: property('Workspace-relative file path'), content: property('Complete file content') }, ['path', 'content'], async (args, context) => {
748
795
  const name = string(args, 'path'), content = string(args, 'content', true);
@@ -783,27 +830,25 @@ export function createTools() {
783
830
  context.wakesArmed?.push(timer.id);
784
831
  return `Timer ${timer.id.slice(0, 8)} armed: your prompt will be delivered in ${args.seconds} second${args.seconds === 1 ? '' : 's'}, at ${new Date(timer.fireAt).toISOString()}. It fires once.`;
785
832
  }),
786
- { ...tool('pull_request', `Show or change the pull request this session tracks in the desktop Plan card. A PR you open with \`gh pr create\` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. review switches on Andorra review: the Andorra Code bot reviews the PR up to reviewRounds times (1 to ${REVIEW_ROUNDS_MAX}, default ${REVIEW_ROUNDS_DEFAULT}) and you are woken to fix its findings between reviews; reviewInstruction tells the reviewer what to focus on, reviewModel picks its provider/model (default: this task's), and review false switches it off. It needs a paid Andorra plan and a pull request the Andorra Code GitHub App covers; the result says why when it cannot be switched on. await_review keeps you in this run while Auto-fix or Andorra review is on: it waits, without using the model, until new review comments arrive (and returns them), Andorra review posts its next round (and returns it) or ends, Codex signs off on the head commit (its thumbs-up on the pull request, which is its approval), the PR is merged or closed, the user messages you, or timeoutMinutes pass. Use it to own the review loop: fix a round, push, resolve the threads you fixed, then call await_review again, until the PR is merged or closed. Never wait for a review with sleep, a shell loop or set_timer. Where Codex reviews the repository but shows no sign of having picked up the head commit after 30 seconds (no eyes reaction, no review, no comment), the wait posts "@codex review" on the PR once for that commit, as the gh account that reads the PR; do not post that comment yourself. reply answers a review thread (threadId, body), resolve resolves one (resolved false reopens it), and comment posts on the PR's conversation (body); they act only on the tracked PR. Where the Andorra Code GitHub App covers the PR they post as its bot, otherwise as the gh account that reads the PR; the result says who posted and why. dismiss stops tracking an open PR, and only when the user asks you to: never dismiss as cleanup after a merge, because a merged or closed PR stays on the task as its record and dismiss refuses one. Only change a setting the user asked you to change.`, {
787
- action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'reply', 'resolve', 'comment', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for the next review round; reply, resolve and comment write on the tracked PR; dismiss stops tracking an open PR when the user asks (refused once it is merged or closed)' },
833
+ { ...tool('pull_request', `Show or change the pull request this session tracks in the desktop Plan card. A PR you open with \`gh pr create\` is attached automatically; use attach for one opened another way. update changes its settings when the user asks, including converting to a draft or marking it ready (draft). review switches on Andorra review: the Andorra Code bot reviews the PR up to reviewRounds times (1 to ${REVIEW_ROUNDS_MAX}, default ${REVIEW_ROUNDS_DEFAULT}) and you are woken to fix its findings between reviews; reviewInstruction tells the reviewer what to focus on, reviewModel picks its provider/model (default: this task's), and review false switches it off. It needs a paid Andorra plan and a pull request the Andorra Code GitHub App covers; the result says why when it cannot be switched on. Call await_review when the task needs you to monitor a tracked PR. It waits in the current run for new reviewer comments, additions or removals of reactions on the PR?s main post, Andorra review rounds, current-head Codex approval (its thumbs-up on the pull request, which is its approval), PR closure or merge, user input, or timeoutMinutes. Jev can classify new comments when enabled. Check the linked GitHub activity before you act on an advisory label. If review follow-up is part of the task, fix findings you agree with, push, reply and resolve the threads you fixed, and wait again when another review is needed. Stop when the requested review is complete; merge only when authorized. Never wait for a review with sleep, a shell loop or set_timer. Where Codex reviews the repository but shows no sign of having picked up the head commit after 30 seconds (no eyes reaction, no review, no comment), the wait posts "@codex review" on the PR once for that commit, as the gh account that reads the PR; do not post that comment yourself. reply answers a review thread (threadId, body), resolve resolves one (resolved false reopens it), and comment posts on the PR's conversation (body); they act only on the tracked PR. Where the Andorra Code GitHub App covers the PR they post as its bot, otherwise as the gh account that reads the PR; the result says who posted and why. dismiss stops tracking an open PR, and only when the user asks you to: never dismiss as cleanup after a merge, because a merged or closed PR stays on the task as its record and dismiss refuses one. Only change a setting the user asked you to change.`, {
834
+ action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'reply', 'resolve', 'comment', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for review activity on the tracked PR; reply, resolve and comment write on the tracked PR; dismiss stops tracking an open PR when the user asks (refused once it is merged or closed)' },
788
835
  threadId: property('The review thread\'s id, PRRT_…, from gh\'s reviewThreads query (reply and resolve only)'),
789
836
  body: property('The text to post (reply and comment only)'),
790
837
  resolved: { type: 'boolean', description: 'resolve only: false reopens a resolved thread (default true)' },
791
838
  url: property('The GitHub pull request URL (attach only)'),
792
- autoFix: { type: 'boolean', description: 'Wake this session when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments, until the PR is merged or closed' },
793
- mergeWhenReady: { type: 'boolean', description: 'GitHub auto-merge once checks and reviews pass' },
794
839
  draft: { type: 'boolean', description: 'true converts to a draft, false marks it ready for review' },
795
840
  review: { type: 'boolean', description: 'Andorra review: true has the Andorra Code bot review the PR in rounds and wakes you to fix its findings between them; false stops it' },
796
841
  reviewRounds: { type: 'integer', minimum: 1, maximum: REVIEW_ROUNDS_MAX, description: `How many reviews Andorra review posts at most (1 to ${REVIEW_ROUNDS_MAX}, default ${REVIEW_ROUNDS_DEFAULT})` },
797
842
  reviewInstruction: property(`What Andorra review's reviewer should focus on, for example "focus on security" (at most ${REVIEW_INSTRUCTION_BYTES} bytes; empty clears it)`),
798
843
  reviewModel: property('The reviewer\'s provider/model, for example anthropic/claude-sonnet-4-5 (empty: this task\'s model)'),
799
- timeoutMinutes: { type: 'integer', minimum: 1, maximum: 1440, description: `How long await_review waits for a review before returning (1 to 1440, default ${AWAIT_REVIEW_DEFAULT_MINUTES})` },
844
+ timeoutMinutes: { type: 'integer', minimum: 1, maximum: 1440, description: `How long await_review waits for PR activity before returning (1 to 1440, default ${AWAIT_REVIEW_DEFAULT_MINUTES})` },
800
845
  }, ['action'], async (args, context) => {
801
846
  const control = context.pullRequests;
802
847
  if (!control)
803
848
  throw new Error('pull_request is unavailable here; no session tracks a pull request for this run.');
804
849
  const settings = { ...pullRequestSettings(args), ...reviewLoopSettings(args) };
805
850
  const approve = () => approveOperation(context, 'pull_request', { ...args, warning: 'Changes the pull request on GitHub, or what Andorra does on its own when the PR changes.' });
806
- const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: autoFix ${pr.autoFix ? 'on' : 'off'}, mergeWhenReady ${pr.mergeWhenReady ? 'on' : 'off'}, ${describeReview(pr)}`;
851
+ const describe = (pr) => `${pr.url} (${pr.state})${pr.title ? ` "${pr.title}"` : ''}: ${describeReview(pr)}`;
807
852
  switch (args.action) {
808
853
  case 'status': {
809
854
  const pr = await control.status();
@@ -817,19 +862,19 @@ export function createTools() {
817
862
  }
818
863
  case 'update': {
819
864
  if (!Object.keys(settings).length)
820
- throw new Error('update needs at least one of autoFix, mergeWhenReady, draft, review, reviewRounds, reviewInstruction, reviewModel');
865
+ throw new Error('update needs at least one of draft, review, reviewRounds, reviewInstruction, reviewModel');
821
866
  await approve();
822
867
  return `Updated ${describe(await control.update(settings, context.wakeOrigin))}`;
823
868
  }
824
869
  case 'await_review': {
825
870
  if (!control.awaitReview)
826
- throw new Error('await_review is unavailable here; this surface cannot hold a run open for a review. End your turn: Auto-fix wakes you when comments arrive.');
871
+ throw new Error('await_review is unavailable here because this surface cannot hold a run open for a review.');
827
872
  const minutes = args.timeoutMinutes === undefined ? AWAIT_REVIEW_DEFAULT_MINUTES : args.timeoutMinutes;
828
873
  if (typeof minutes !== 'number' || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 1_440)
829
874
  throw new Error('timeoutMinutes must be an integer from 1 to 1440');
830
875
  const awaitReview = control.awaitReview.bind(control);
831
876
  const approveBump = (detail) => approveOperation(context, 'pull_request', { ...args, body: REVIEW_BUMP_COMMENT, warning: `Changes the pull request on GitHub. ${detail}` });
832
- const wait = () => awaitReview(context.signal, minutes * 60_000, context.wakeOrigin, { approveBump });
877
+ const wait = () => awaitReview(context.signal, minutes * 60_000, context.wakeOrigin, { approveBump, invocationId: context.toolInvocationId });
833
878
  const ended = await (context.waitOutside ? context.waitOutside(wait) : wait());
834
879
  return reviewWaitAnswer(ended, minutes, context.signal);
835
880
  }
@@ -48,6 +48,7 @@ export function describeTool(name, value) {
48
48
  case 'wait_subagent': return 'Wait for a subagent';
49
49
  case 'message_subagent': return `Message a subagent: ${line(args.message)}`;
50
50
  case 'cancel_subagent': return 'Stop a subagent';
51
+ case 'currentAndorraStreams': return 'Check free Andorra streams';
51
52
  case 'ask_user': return 'Ask a question';
52
53
  case 'submit_bug_report': return `Send a bug report: ${line(args.title)}`;
53
54
  case 'git_read':
@@ -104,7 +105,7 @@ export function formatEvent(event) {
104
105
  if (event.type === 'decision.fallback' && data.reason !== 'low_confidence') {
105
106
  const reasons = {
106
107
  authentication_required: 'Sign in required', decision_daily_limit_reached: 'Daily quota reached',
107
- decision_window_limit_reached: '30-day Jev limit reached',
108
+ decision_window_limit_reached: 'Jev limit reached',
108
109
  decision_service_unavailable: 'Service unavailable', invalid_response: 'Invalid response',
109
110
  decision_protocol_unsupported: 'Request not accepted by the service',
110
111
  decision_input_too_large: 'Context exceeds hosted size limits; evaluation skipped locally',
@@ -136,7 +137,7 @@ export function formatEvent(event) {
136
137
  return { text: `${line(data.nodeName ?? data.nodeId)} - copy ${line(data.copy)}/${line(data.copies)} started` };
137
138
  if (event.type === 'graph.todos.updated') {
138
139
  const todos = data.todos;
139
- return { text: todos.length ? `Todo\n${todos.map(todo => ` ${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${line(todo.text)}`).join('\n')}` : 'Todo: cleared' };
140
+ return { text: todos.length ? `Todo\n${todos.map(todo => ` ${todo.parentId === undefined ? '' : ' '}${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${line(todo.text)}`).join('\n')}` : 'Todo: cleared' };
140
141
  }
141
142
  if (event.type === 'agent.message') {
142
143
  const body = clean(data.text).replace(/^(?:[ \t]*\n)+/, '').replace(/\s+$/, '');
@@ -1,8 +1,21 @@
1
+ import type { TelemetryAuthMode } from './telemetry/schema.js';
1
2
  export interface ToolCall {
2
3
  id: string;
3
4
  name: string;
4
5
  arguments: string;
5
6
  }
7
+ /**
8
+ * One entry of the `reasoning_details` Andorra's router adds to an answer from a model it serves through Anthropic's
9
+ * Messages API: a block of Claude's answer (signed thinking, redacted thinking, a text length or a tool call's place),
10
+ * sealed for the router to rebuild the turn from. The client keeps it as received and sends it back unchanged.
11
+ */
12
+ export interface RouterReasoningDetail {
13
+ type: 'reasoning.encrypted';
14
+ format: 'anthropic-messages-v1';
15
+ index: number;
16
+ data: string;
17
+ [key: string]: unknown;
18
+ }
6
19
  export interface ProviderContinuation {
7
20
  api: string;
8
21
  provider: string;
@@ -13,6 +26,8 @@ export interface ProviderContinuation {
13
26
  thinkingSignature?: string;
14
27
  redacted?: boolean;
15
28
  }[];
29
+ /** Andorra's router only: the answer's `reasoning_details`, sent back on the same assistant message. */
30
+ reasoningDetails?: RouterReasoningDetail[];
16
31
  }
17
32
  export interface ToolImage {
18
33
  mimeType: 'image/png' | 'image/jpeg';
@@ -21,6 +36,8 @@ export interface ToolImage {
21
36
  export interface Message {
22
37
  role: 'system' | 'user' | 'assistant' | 'tool';
23
38
  contextSummary?: true;
39
+ /** Host-added retrieval, not user instructions. May be retired under request pressure, including after Resume. */
40
+ optionalContext?: 'memory' | 'repository';
24
41
  content: string;
25
42
  reasoningContent?: string;
26
43
  providerContinuation?: ProviderContinuation;
@@ -50,6 +67,16 @@ export interface ModelResponse {
50
67
  stopReason?: string;
51
68
  reasoningContent?: string;
52
69
  providerContinuation?: ProviderContinuation;
70
+ /** Privacy-bounded facts observed at the adapter, for aggregate usage reporting. */
71
+ servedModel?: string;
72
+ authMode?: TelemetryAuthMode;
73
+ /** Token fields the provider actually reported, when runtime usage also has synthetic defaults. */
74
+ reportedUsage?: Partial<Usage>;
75
+ /**
76
+ * Messages an adapter added at the end of the request this answer replies to, which the run keeps in its history right
77
+ * before the answer: Claude's thinking comes back from Andorra's router only while its earlier conversation is unchanged.
78
+ */
79
+ requestTail?: Message[];
53
80
  }
54
81
  export interface ModelRequestContext {
55
82
  runId?: string;
@@ -112,6 +139,8 @@ export interface ToolRuntimeState {
112
139
  fileReads: Map<string, ToolFileReadState>;
113
140
  }
114
141
  export interface ToolContext {
142
+ /** The project a task is filed under, when it works elsewhere (its own worktree); `workspace` is where it works. */
143
+ project?: string;
115
144
  automationDirectory?: string;
116
145
  browserSessionOwner?: object;
117
146
  browserToolBatch?: object;
@@ -133,12 +162,29 @@ export interface ToolContext {
133
162
  qaHostApproved?: boolean;
134
163
  approvalMode?: 'interactive' | 'headless';
135
164
  approve: (name: string, args: Record<string, unknown>, signal: AbortSignal) => Promise<boolean | 'policy-changed'>;
136
- askUser?: (question: string, signal: AbortSignal, choices?: readonly string[]) => Promise<string | undefined>;
165
+ chatHandoffs?: boolean;
166
+ askUser?: (question: string, signal: AbortSignal, choices?: readonly string[], handoff?: {
167
+ prompt: string;
168
+ model: string;
169
+ effort?: string;
170
+ }) => Promise<string | undefined>;
137
171
  approvePlan?: () => Promise<import('./permissions.js').PermissionMode>;
138
172
  waitOutside?: <T>(work: () => Promise<T>) => Promise<T>;
139
173
  onApprovalEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
140
174
  onBrowserEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
141
175
  onCommandOutput?: (chunk: string) => void;
176
+ /**
177
+ * Records a shell command the agent runs, for the turn's evidence: called before it starts (the runtime reads the
178
+ * revision it runs against), and the returned function when it ends.
179
+ */
180
+ observeCommand?: (start: {
181
+ command: string;
182
+ directory: string;
183
+ signal?: AbortSignal;
184
+ }) => Promise<(end: {
185
+ exitCode?: number;
186
+ output: string;
187
+ }) => void>;
142
188
  onFilePathAuthorized?: (canonicalTarget: string) => void | Promise<void>;
143
189
  toolState?: ToolRuntimeState;
144
190
  timers?: import('./timers.js').TimerRegistry;
@@ -146,6 +192,7 @@ export interface ToolContext {
146
192
  wakeOrigin?: import('./timers.js').WakeOrigin;
147
193
  wakesArmed?: string[];
148
194
  sessionScope?: string;
195
+ sessionId?: string;
149
196
  pullRequests?: import('./pull-requests.js').PullRequestControl;
150
197
  fileChanges?: import('./session-changes.js').FileChangeRecorder;
151
198
  }