@andorra-labs/code 0.1.18 → 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 (277) 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 +347 -45
  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/hosted.d.ts +8 -0
  11. package/dist/src/andorra/hosted.js +22 -3
  12. package/dist/src/andorra/streams.d.ts +49 -0
  13. package/dist/src/andorra/streams.js +98 -0
  14. package/dist/src/antigravity-acp.d.ts +28 -0
  15. package/dist/src/antigravity-acp.js +150 -0
  16. package/dist/src/antigravity-terminal.d.ts +2 -0
  17. package/dist/src/antigravity-terminal.js +214 -0
  18. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  19. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  20. package/dist/src/app-server/artifact.d.ts +14 -0
  21. package/dist/src/app-server/artifact.js +46 -0
  22. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  23. package/dist/src/app-server/legal-protocol.js +16 -0
  24. package/dist/src/app-server/protocol.d.ts +23 -3
  25. package/dist/src/app-server/protocol.js +3 -1
  26. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  27. package/dist/src/app-server/telemetry-protocol.js +2 -0
  28. package/dist/src/app-server/telemetry.d.ts +38 -0
  29. package/dist/src/app-server/telemetry.js +163 -0
  30. package/dist/src/app-server/workspace.d.ts +3 -1
  31. package/dist/src/app-server/workspace.js +39 -8
  32. package/dist/src/app-server.d.ts +50 -25
  33. package/dist/src/app-server.js +1008 -400
  34. package/dist/src/auth/AuthManager.d.ts +11 -2
  35. package/dist/src/auth/AuthManager.js +56 -13
  36. package/dist/src/auth/index.d.ts +5 -1
  37. package/dist/src/auth/index.js +8 -1
  38. package/dist/src/auth/lifecycle.d.ts +13 -0
  39. package/dist/src/auth/lifecycle.js +109 -0
  40. package/dist/src/auth/store.d.ts +1 -0
  41. package/dist/src/auth/store.js +12 -0
  42. package/dist/src/auth/types.d.ts +12 -0
  43. package/dist/src/automation-runner.js +2 -0
  44. package/dist/src/automation-service.js +7 -2
  45. package/dist/src/benchmark-scores.d.ts +88 -0
  46. package/dist/src/benchmark-scores.js +302 -0
  47. package/dist/src/bridge/command.js +4 -1
  48. package/dist/src/bridge/control.js +2 -1
  49. package/dist/src/bridge/engines.d.ts +2 -0
  50. package/dist/src/bridge/engines.js +9 -0
  51. package/dist/src/bridge/host-ops.d.ts +2 -2
  52. package/dist/src/bridge/host-ops.js +4 -2
  53. package/dist/src/bridge/host.d.ts +2 -0
  54. package/dist/src/bridge/host.js +63 -12
  55. package/dist/src/bridge/protocol.d.ts +1 -0
  56. package/dist/src/bridge/protocol.js +1 -0
  57. package/dist/src/browser-panel-tool.d.ts +12 -0
  58. package/dist/src/browser-panel-tool.js +30 -3
  59. package/dist/src/browser-runner.js +53 -62
  60. package/dist/src/browser-server.js +10 -4
  61. package/dist/src/browser-session.d.ts +14 -0
  62. package/dist/src/browser-session.js +57 -12
  63. package/dist/src/browser-view.d.ts +40 -1
  64. package/dist/src/browser-view.js +163 -9
  65. package/dist/src/browser-window-style.d.ts +27 -0
  66. package/dist/src/browser-window-style.js +244 -0
  67. package/dist/src/claude-provider.d.ts +1 -0
  68. package/dist/src/claude-provider.js +77 -36
  69. package/dist/src/cli.js +235 -58
  70. package/dist/src/codex-provider.d.ts +1 -0
  71. package/dist/src/codex-provider.js +43 -7
  72. package/dist/src/coding-tools.d.ts +1 -0
  73. package/dist/src/coding-tools.js +19 -5
  74. package/dist/src/command-screens.d.ts +1 -1
  75. package/dist/src/command-screens.js +2 -2
  76. package/dist/src/commands.d.ts +8 -1
  77. package/dist/src/commands.js +67 -63
  78. package/dist/src/completion.js +5 -3
  79. package/dist/src/config.d.ts +14 -3
  80. package/dist/src/config.js +54 -16
  81. package/dist/src/context-budget.d.ts +11 -2
  82. package/dist/src/context-budget.js +23 -2
  83. package/dist/src/context-compaction.d.ts +10 -8
  84. package/dist/src/context-compaction.js +23 -24
  85. package/dist/src/deadline.js +1 -1
  86. package/dist/src/decision/DecisionManager.d.ts +5 -0
  87. package/dist/src/decision/DecisionManager.js +39 -2
  88. package/dist/src/decision/applyToolMenu.js +6 -2
  89. package/dist/src/decision/hostedPolicy.js +6 -4
  90. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  91. package/dist/src/decision/optimizationPolicy.js +23 -3
  92. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -1
  93. package/dist/src/decision/providers/AndorraDecisionProvider.js +17 -7
  94. package/dist/src/decision/providers/index.js +1 -1
  95. package/dist/src/decision/toolFamilies.js +1 -1
  96. package/dist/src/decision/types.d.ts +2 -0
  97. package/dist/src/efficiency.d.ts +75 -1
  98. package/dist/src/efficiency.js +114 -3
  99. package/dist/src/extensions.d.ts +2 -0
  100. package/dist/src/extensions.js +30 -20
  101. package/dist/src/github-app/agent-writes.d.ts +1 -1
  102. package/dist/src/github-app/agent-writes.js +1 -1
  103. package/dist/src/github-app/event-source.d.ts +0 -5
  104. package/dist/src/github-app/event-source.js +1 -31
  105. package/dist/src/github-app/metrics.d.ts +2 -5
  106. package/dist/src/github-app/metrics.js +2 -14
  107. package/dist/src/github-app/review-loop.d.ts +5 -5
  108. package/dist/src/github-app/review-loop.js +1 -1
  109. package/dist/src/github-app/review-node.d.ts +2 -2
  110. package/dist/src/github-app/triggers.d.ts +3 -3
  111. package/dist/src/glob-search.d.ts +1 -0
  112. package/dist/src/glob-search.js +3 -0
  113. package/dist/src/google-provider.d.ts +5 -28
  114. package/dist/src/google-provider.js +6 -141
  115. package/dist/src/graph-editor-session.d.ts +1 -0
  116. package/dist/src/graph-editor-session.js +2 -0
  117. package/dist/src/graph-health.js +3 -1
  118. package/dist/src/graph-runner.js +19 -13
  119. package/dist/src/graph-selection.d.ts +3 -1
  120. package/dist/src/graph-selection.js +2 -2
  121. package/dist/src/graph-server.d.ts +8 -1
  122. package/dist/src/graph-server.js +45 -10
  123. package/dist/src/graph-sync.d.ts +2 -1
  124. package/dist/src/graph-sync.js +13 -0
  125. package/dist/src/graph-ui/app.js +19 -8
  126. package/dist/src/graph-ui/index.html +1 -1
  127. package/dist/src/graphs.d.ts +17 -1
  128. package/dist/src/graphs.js +51 -5
  129. package/dist/src/grok-provider.js +17 -14
  130. package/dist/src/hardened-runtime.js +7 -4
  131. package/dist/src/jev-savings.d.ts +4 -0
  132. package/dist/src/jev-savings.js +13 -0
  133. package/dist/src/legal/client.d.ts +25 -0
  134. package/dist/src/legal/client.js +47 -0
  135. package/dist/src/legal/command.d.ts +13 -0
  136. package/dist/src/legal/command.js +98 -0
  137. package/dist/src/legal/documents.d.ts +2 -0
  138. package/dist/src/legal/documents.js +14 -0
  139. package/dist/src/legal/gate.d.ts +13 -0
  140. package/dist/src/legal/gate.js +96 -0
  141. package/dist/src/legal/manifest.d.ts +21 -0
  142. package/dist/src/legal/manifest.js +23 -0
  143. package/dist/src/legal/receipt.d.ts +13 -0
  144. package/dist/src/legal/receipt.js +137 -0
  145. package/dist/src/legal/release.d.ts +27 -0
  146. package/dist/src/legal/release.js +28 -0
  147. package/dist/src/managed-sign-in.d.ts +0 -1
  148. package/dist/src/managed-sign-in.js +0 -13
  149. package/dist/src/membership.d.ts +27 -1
  150. package/dist/src/membership.js +139 -7
  151. package/dist/src/model-metadata.js +3 -7
  152. package/dist/src/model-pool.d.ts +99 -0
  153. package/dist/src/model-pool.js +136 -0
  154. package/dist/src/model-relay/local.js +5 -0
  155. package/dist/src/model-relay/remote.d.ts +2 -0
  156. package/dist/src/model-relay/remote.js +4 -0
  157. package/dist/src/model-tiers.d.ts +13 -1
  158. package/dist/src/model-tiers.js +28 -4
  159. package/dist/src/opencode-cli-provider.js +59 -56
  160. package/dist/src/opencode-provider.js +16 -13
  161. package/dist/src/permissions.d.ts +5 -0
  162. package/dist/src/permissions.js +7 -0
  163. package/dist/src/plan-pass.js +2 -1
  164. package/dist/src/pool-scores.d.ts +45 -0
  165. package/dist/src/pool-scores.js +40 -0
  166. package/dist/src/provider-connection.js +3 -17
  167. package/dist/src/provider-engine.js +42 -12
  168. package/dist/src/provider-request-error.d.ts +8 -0
  169. package/dist/src/provider-request-error.js +12 -0
  170. package/dist/src/provider-settings.d.ts +1 -1
  171. package/dist/src/provider-settings.js +36 -18
  172. package/dist/src/provider-turn-deadline.d.ts +39 -0
  173. package/dist/src/provider-turn-deadline.js +139 -0
  174. package/dist/src/providers.d.ts +3 -9
  175. package/dist/src/providers.js +181 -146
  176. package/dist/src/pull-request-merge.d.ts +1 -8
  177. package/dist/src/pull-request-merge.js +0 -4
  178. package/dist/src/pull-requests.d.ts +82 -66
  179. package/dist/src/pull-requests.js +266 -276
  180. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  181. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  182. package/dist/src/react-runtime.js +147 -56
  183. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  184. package/dist/src/reasoning-probe-cloud.js +209 -0
  185. package/dist/src/remote/engine-pool.d.ts +3 -0
  186. package/dist/src/remote/engine-pool.js +85 -18
  187. package/dist/src/remote/recovery.d.ts +6 -0
  188. package/dist/src/remote/recovery.js +37 -0
  189. package/dist/src/run-records.d.ts +13 -3
  190. package/dist/src/run-records.js +59 -34
  191. package/dist/src/runtime.d.ts +18 -1
  192. package/dist/src/runtime.js +25 -7
  193. package/dist/src/session-summary.d.ts +8 -0
  194. package/dist/src/session-summary.js +34 -0
  195. package/dist/src/sessions.d.ts +8 -0
  196. package/dist/src/sessions.js +12 -3
  197. package/dist/src/shell.js +6 -0
  198. package/dist/src/side-panel.js +36 -2
  199. package/dist/src/sign-in-detection.d.ts +1 -1
  200. package/dist/src/sign-in-detection.js +4 -10
  201. package/dist/src/sign-in-offer.js +1 -1
  202. package/dist/src/skill-commands.js +1 -1
  203. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  204. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  205. package/dist/src/skills/bundled/provenance.json +2 -2
  206. package/dist/src/subagent-run.js +50 -50
  207. package/dist/src/subscription-usage.d.ts +50 -0
  208. package/dist/src/subscription-usage.js +92 -0
  209. package/dist/src/task-checkout.d.ts +20 -4
  210. package/dist/src/task-checkout.js +78 -8
  211. package/dist/src/telemetry/access.d.ts +18 -0
  212. package/dist/src/telemetry/access.js +43 -0
  213. package/dist/src/telemetry/aggregate.d.ts +18 -2
  214. package/dist/src/telemetry/aggregate.js +22 -9
  215. package/dist/src/telemetry/capture-core.d.ts +33 -14
  216. package/dist/src/telemetry/capture-core.js +124 -25
  217. package/dist/src/telemetry/capture.d.ts +3 -2
  218. package/dist/src/telemetry/capture.js +21 -1
  219. package/dist/src/telemetry/decision-capture.js +4 -0
  220. package/dist/src/telemetry/emitter.d.ts +6 -7
  221. package/dist/src/telemetry/emitter.js +124 -29
  222. package/dist/src/telemetry/gate.d.ts +41 -2
  223. package/dist/src/telemetry/gate.js +89 -4
  224. package/dist/src/telemetry/home.d.ts +1 -0
  225. package/dist/src/telemetry/home.js +20 -0
  226. package/dist/src/telemetry/identity.d.ts +6 -3
  227. package/dist/src/telemetry/identity.js +19 -6
  228. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  229. package/dist/src/telemetry/lifecycle.js +76 -0
  230. package/dist/src/telemetry/outbox.d.ts +13 -8
  231. package/dist/src/telemetry/outbox.js +68 -12
  232. package/dist/src/telemetry/permission-command.d.ts +38 -0
  233. package/dist/src/telemetry/permission-command.js +208 -0
  234. package/dist/src/telemetry/permission.d.ts +168 -0
  235. package/dist/src/telemetry/permission.js +662 -0
  236. package/dist/src/telemetry/record-installation.d.ts +1 -0
  237. package/dist/src/telemetry/record-installation.js +9 -0
  238. package/dist/src/telemetry/region-data.d.ts +12 -0
  239. package/dist/src/telemetry/region-data.js +1314 -0
  240. package/dist/src/telemetry/region.d.ts +34 -0
  241. package/dist/src/telemetry/region.js +87 -0
  242. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  243. package/dist/src/telemetry/run-privacy.js +165 -0
  244. package/dist/src/telemetry/schema.d.ts +27 -6
  245. package/dist/src/telemetry/schema.js +109 -14
  246. package/dist/src/telemetry/state.d.ts +11 -7
  247. package/dist/src/telemetry/state.js +39 -6
  248. package/dist/src/telemetry/surface.d.ts +20 -3
  249. package/dist/src/telemetry/surface.js +71 -15
  250. package/dist/src/telemetry/uploader.d.ts +6 -11
  251. package/dist/src/telemetry/uploader.js +72 -46
  252. package/dist/src/telemetry/uploads.d.ts +5 -1
  253. package/dist/src/telemetry/uploads.js +25 -6
  254. package/dist/src/telemetry/version.d.ts +5 -0
  255. package/dist/src/telemetry/version.js +34 -0
  256. package/dist/src/telemetry/workspace.d.ts +4 -1
  257. package/dist/src/telemetry/workspace.js +18 -3
  258. package/dist/src/terminal-ui.d.ts +3 -0
  259. package/dist/src/terminal-ui.js +48 -6
  260. package/dist/src/thinking-level-detect.d.ts +3 -1
  261. package/dist/src/thinking-level-detect.js +8 -3
  262. package/dist/src/thinking-levels.d.ts +1 -1
  263. package/dist/src/thinking-levels.js +11 -4
  264. package/dist/src/timers.d.ts +2 -0
  265. package/dist/src/todos.d.ts +2 -1
  266. package/dist/src/todos.js +24 -4
  267. package/dist/src/tool-argument-coercion.d.ts +7 -0
  268. package/dist/src/tool-argument-coercion.js +49 -0
  269. package/dist/src/tool-catalog.d.ts +2 -2
  270. package/dist/src/tools.js +67 -22
  271. package/dist/src/transcript.js +2 -1
  272. package/dist/src/types.d.ts +14 -1
  273. package/dist/src/update.js +4 -0
  274. package/dist/src/usage-analytics.d.ts +7 -0
  275. package/dist/src/usage-analytics.js +85 -13
  276. package/dist/telemetry-consent-v1 +1 -0
  277. package/package.json +97 -96
@@ -67,7 +67,7 @@ check (loop modifier) --pass--> done
67
67
  `pass` or runs out of attempts. It exposes only the `pass` port; use it when the same agent fixes and
68
68
  rechecks its own work.
69
69
 
70
- ## Pull request with review fixes (Auto-fix)
70
+ ## Pull request with review fixes
71
71
 
72
72
  ```
73
73
  orchestrator --completed--> pr-owner --completed--> done
@@ -75,24 +75,18 @@ orchestrator --completed--> pr-owner --completed--> done
75
75
 
76
76
  Use this whenever the workflow opens a pull request, reviews one, or answers its review comments.
77
77
 
78
- - One agent owns the PR end to end: it opens or attaches the PR, switches Auto-fix on itself (the `pull_request`
79
- tool, `action: "attach"` or `"update"` with `autoFix: true`), and fixes the review comments. Auto-fix prompts
80
- go back to the node that switched Auto-fix on (or, when none did, to the node that attached the PR), not to
81
- the graph's entry. So that call belongs in the PR owner's instruction, never in an Orchestrator or planner
82
- that hands the work on.
83
- - Do not move the entry, demote an Orchestrator, or add edges back into the owner to steer Auto-fix there. A
84
- prompt is never routed through the graph's edges; it is addressed to the node.
85
- - The owner's instruction is a loop it runs itself: push the fix, resolve the threads it fixed, reply to the
86
- findings it disputes, then wait for the next review. If the `pull_request` tool offers an `await_review`
87
- action, call it and repeat until it reports the PR merged or closed (or the round cap below): the agent keeps
88
- its whole conversation, and waiting costs no tokens. Without that action, end the turn once the round is
89
- pushed; Auto-fix wakes this same node with the next comments, continuing its attempt when it stopped short.
90
- - Never wait with `sleep`, a shell polling loop, or `set_timer` (timers are for reminders the user asked for).
91
- Waiting inside a tool call is the only wait that does not hold the model.
92
- - Give the owner shell, file-write and network access (it runs `git` and `gh`), and a `limits.wallTimeMs` with
93
- room for several fix rounds: a 15-minute ceiling stops it in the middle of a fix.
94
- - Put the exit rule in its instruction: stop when the PR is merged or closed (Auto-fix then switches itself
95
- off), when the reviewer signs off, or after a fixed number of rounds the user chose.
78
+ - One agent owns the PR from opening or attaching it through answering review comments. Keep the
79
+ graph's entry where it is and put the review instructions on the PR owner's node.
80
+ - When the workflow calls for PR monitoring, the owner can use `pull_request` with
81
+ `action: "await_review"`. This holds the current run and preserves its conversation. Use the returned
82
+ comment classifications as hints. Verify findings in the review and check reaction changes for context.
83
+ The owner fixes findings it agrees with, pushes, replies and resolves the threads it fixed, and replies
84
+ to disputed findings. The owner decides whether to wait again based on the task and the review status.
85
+ - Give the owner shell, file-write and network access for `git` and `gh`. Set `limits.wallTimeMs`
86
+ with room for any review rounds the user requests. Use the review tool for waits on surfaces that
87
+ support it.
88
+ - Have the owner stop when the reviewer signs off, the PR closes or merges, or the requested round
89
+ limit is reached. Merge only when authorized.
96
90
 
97
91
  ## Single agent with a human approval
98
92
 
@@ -714,7 +714,7 @@
714
714
  {
715
715
  "source": "src/skills/bundled/graph-manager/SKILL.md",
716
716
  "asset": "graph-manager/SKILL.md",
717
- "sha256": "cedffd79e4e632d62426758d8b50b6f0e8b2f5e30cc764efd1ff20fa40f3d6db"
717
+ "sha256": "a64da6d3b2a8f47ac8fa9012f4eb4fa44ac188b75a94f4872cbfebd6096035f1"
718
718
  },
719
719
  {
720
720
  "source": "src/skills/bundled/graph-manager/errors.md",
@@ -724,7 +724,7 @@
724
724
  {
725
725
  "source": "src/skills/bundled/graph-manager/patterns.md",
726
726
  "asset": "graph-manager/patterns.md",
727
- "sha256": "bf57e2421697360cc293109b5eaa84ecff0d93fc5dcd957a34d8173ca91b1e2c"
727
+ "sha256": "fc585892e2010e1f8c828b4d28ed14341ff35ec7f0b276ade2aff3e781a379f1"
728
728
  },
729
729
  {
730
730
  "source": "src/skills/bundled/bug-report/SKILL.md",
@@ -1,13 +1,14 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { requireLegalAcceptance } from './legal/gate.js';
2
3
  import { homedir } from 'node:os';
3
4
  import { realpath, stat } from 'node:fs/promises';
4
- import { writeFile } from 'node:fs/promises';
5
- import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
6
- import { createRunHandle, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
5
+ import { configDirectory, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
6
+ import { beginTelemetryRun, runTelemetryMetadata, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
7
+ import { loadCliConfig, cliTelemetryResult } from './telemetry/permission-command.js';
7
8
  import { configuredContextWindow, createAdapter, providerModels } from './providers.js';
8
- import { getMembership, loadAccessibleGraph } from './membership.js';
9
+ import { getMembership, loadAccessibleGraph, withAnonymousJev } from './membership.js';
9
10
  import { currentGraphSubject } from './graph-selection.js';
10
- import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
11
+ import { createRunTelemetry, recordModelUse, mergeRunTelemetry, hasRunTelemetry } from './telemetry/capture.js';
11
12
  import { hostedGate } from './andorra/hosted.js';
12
13
  import { checkGraphModelHealth, plainHealthFailure } from './graph-health.js';
13
14
  import { validateGraph } from './graphs.js';
@@ -23,8 +24,8 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
23
24
  import { DecisionManager } from './decision/DecisionManager.js';
24
25
  import { permissionMode } from './permissions.js';
25
26
  import { TodoStore } from './todos.js';
26
- import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
27
- import { SessionStore, projectIdentity, sessionName } from './sessions.js';
27
+ import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, summaryForStoppedRecord, writeFinalRunRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
28
+ import { SessionStore, projectIdentity, randomSessionName } from './sessions.js';
28
29
  export const SUBAGENT_GRAPH_ID = 'default';
29
30
  export const MAX_SUBAGENT_TASK_CHARS = 100_000;
30
31
  export const MAX_SUBAGENT_MODEL_CHARS = 500;
@@ -127,7 +128,10 @@ export async function subagentDecisionConfig(config, membership) {
127
128
  const decisions = config.decisions;
128
129
  if (config.jevEnabled === false || !decisions || decisions.provider === 'none' || decisions.mode === 'off')
129
130
  return { mode: 'off', provider: 'none' };
130
- return (await membership()).subject ? decisions : { mode: 'off', provider: 'none' };
131
+ const access = await withAnonymousJev(await membership());
132
+ if (access.subject)
133
+ return decisions;
134
+ return access.anonymousJev ? { ...decisions, anonymous: true } : { mode: 'off', provider: 'none' };
131
135
  }
132
136
  export class SubagentRunner {
133
137
  defaults;
@@ -170,60 +174,63 @@ export class SubagentRunner {
170
174
  }
171
175
  async begin(options, permissions) {
172
176
  const directory = options.directory ?? this.defaults.directory ?? configDirectory();
177
+ await requireLegalAcceptance(directory);
178
+ const startedAt = new Date().toISOString();
179
+ const telemetryHandle = await beginTelemetryRun({ home: directory, surface: 'subagent' }, startedAt, {
180
+ graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: permissions,
181
+ }, options.workspace).catch(() => undefined);
182
+ const telemetryAccess = { home: directory, lease: telemetryHandle?.lease };
173
183
  const workspace = await canonicalWorkspace(options.workspace);
174
- const config = await (this.defaults.loadConfig ?? loadConfig)(directory);
184
+ const config = await (this.defaults.loadConfig ?? loadCliConfig)(directory);
175
185
  const { provider, model } = resolveSubagentProvider(config, options);
176
186
  if (!claimProcessWorkspace(workspace, this.reservationId))
177
187
  throw new SubagentRunInProgressError();
178
188
  this.reservedWorkspace = workspace;
179
- const telemetryRunId = randomUUID();
180
189
  const accountSubject = await currentGraphSubject().catch(() => undefined);
181
190
  const runId = randomUUID();
182
191
  const run = {
183
- runId, sessionId: randomUUID(), task: options.task, workspace, directory, telemetryRunId,
192
+ runId, sessionId: randomUUID(), name: randomSessionName(), task: options.task, workspace, directory, telemetryHandle,
184
193
  ...(accountSubject === undefined ? {} : { accountSubject }),
185
194
  jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off',
186
- providerId: provider.id, model, permissions, controller: new AbortController(), startedAt: new Date().toISOString(),
195
+ providerId: provider.id, model, permissions, controller: new AbortController(), startedAt,
187
196
  events: [], notices: [], journal: Promise.resolve(), finished: Promise.resolve(),
188
197
  journalWriter: createRunJournalWriter(directory, runId), checkpoints: createCheckpointFailureTracker(directory, runId),
189
- probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
198
+ probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeTelemetry: createRunTelemetry(telemetryAccess),
190
199
  providerType: provider.type, baseUrl: provider.baseUrl,
191
200
  };
201
+ if (telemetryHandle)
202
+ Object.assign(telemetryHandle.dimensions, { jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off' });
192
203
  const openRecord = {
193
204
  id: run.runId, status: 'running', sessionId: run.sessionId, startedAt: run.startedAt, pid: process.pid,
194
205
  graphSelection: SUBAGENT_GRAPH_ID, graph: { id: SUBAGENT_GRAPH_ID }, provider: provider.id, model,
195
206
  ...(accountSubject === undefined ? {} : { accountSubject }),
196
207
  surface: 'subagent',
197
- telemetry: { runId: telemetryRunId, nodes: 1, subagents: false, jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off', startSent: false },
208
+ telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
198
209
  subagent: true,
199
210
  permissions: run.permissions,
200
211
  };
201
212
  try {
202
- await writeOpenRunRecord(directory, openRecord);
213
+ await writeOpenRunRecord(directory, openRecord, telemetryAccess);
203
214
  }
204
215
  catch (error) {
205
216
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
206
217
  const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
207
218
  throw Object.assign(new Error(`Could not write the subagent run record: ${error instanceof Error ? error.message : String(error)}`), typeof code === 'string' ? { code } : {}, error instanceof Error ? { cause: error } : {});
208
219
  }
209
- run.telemetryHandle = createRunHandle(run.telemetryRunId, run.startedAt, {
210
- graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
211
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
212
- }, workspace);
213
- run.telemetryStart = reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle).catch(() => { });
220
+ run.telemetryStart = telemetryHandle ? reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle).catch(() => { }) : Promise.resolve();
214
221
  await run.telemetryStart;
215
222
  await writeOpenRunRecord(directory, {
216
223
  ...openRecord,
217
- telemetry: { ...openRecord.telemetry, startSent: run.telemetryHandle.started !== false },
218
- }).catch(() => { });
224
+ telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
225
+ }, telemetryAccess).catch(() => { });
219
226
  try {
220
227
  await this.saveSession(run, { summary: RUNNING_TURN_SUMMARY, tests: [], status: 'running' });
221
228
  }
222
229
  catch (error) {
223
230
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
224
231
  await run.telemetryStart;
225
- await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, { graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
226
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting }), { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
232
+ if (telemetryHandle)
233
+ await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle, { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
227
234
  throw error;
228
235
  }
229
236
  this.active = run;
@@ -255,7 +262,7 @@ export class SubagentRunner {
255
262
  if (!run.outcome)
256
263
  return { state: 'running' };
257
264
  return { state: 'finished', status: run.outcome.status,
258
- ...(run.outcome.result !== undefined ? { result: run.outcome.result } : {}),
265
+ ...(run.outcome.result !== undefined ? { result: cliTelemetryResult(run.directory, run.outcome.result, run.telemetryHandle?.lease) } : {}),
259
266
  ...(run.outcome.reason !== undefined ? { reason: run.outcome.reason } : {}) };
260
267
  }
261
268
  cancel() {
@@ -342,14 +349,8 @@ export class SubagentRunner {
342
349
  onUsage: (delta, reference) => {
343
350
  foldUsage(run.probeUsage, delta);
344
351
  options.healthDependencies?.onUsage?.(delta, reference);
345
- const key = `${reference.provider}\0${reference.model}`;
346
- const entry = run.probeModels.get(key) ?? { provider: reference.provider, model: reference.model, usage: {} };
347
- for (const field of ['requests', 'inputTokens', 'outputTokens', 'cacheRead', 'cacheWrite']) {
348
- const value = delta[field];
349
- if (typeof value === 'number')
350
- entry.usage[field] = (entry.usage[field] ?? 0) + value;
351
- }
352
- run.probeModels.set(key, entry);
352
+ if (hasRunTelemetry(run.probeTelemetry))
353
+ recordModelUse(run.probeTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: reference.model, role: 'other', usage: delta });
353
354
  },
354
355
  });
355
356
  if (!health.healthy) {
@@ -387,12 +388,13 @@ export class SubagentRunner {
387
388
  ...(meta?.generation === undefined ? {} : { generation: meta.generation }),
388
389
  ...(meta?.provider === undefined ? {} : { provider: meta.provider }),
389
390
  ...(meta?.model === undefined ? {} : { model: meta.model }),
390
- }))
391
+ }, { lease: run.telemetryHandle?.lease }))
391
392
  .then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
392
393
  return checkpointWrites;
393
394
  };
394
395
  const { createTools } = await import('./tools.js');
395
396
  const graphOptions = {
397
+ telemetry: { home: run.directory, lease: run.telemetryHandle?.lease },
396
398
  task: run.task, runId: run.runId, provider: run.providerId, model: run.model,
397
399
  adapter: adapterFor(resolvedProvider),
398
400
  ...(resolvedProvider.contextWindow === undefined ? {} : { contextWindow: resolvedProvider.contextWindow }),
@@ -442,7 +444,7 @@ export class SubagentRunner {
442
444
  }
443
445
  async saveSession(run, completion, usage = { requests: 0, inputTokens: 0, outputTokens: 0 }, updatedAt = new Date().toISOString()) {
444
446
  await new SessionStore(run.directory).save({
445
- version: 1, id: run.sessionId, name: sessionName(run.task), workspace: run.workspace, updatedAt,
447
+ version: 1, id: run.sessionId, name: run.name, workspace: run.workspace, updatedAt,
446
448
  history: [{ task: run.task, completion, runId: run.runId }], usage, projectId: projectIdentity(run.workspace),
447
449
  });
448
450
  }
@@ -450,25 +452,21 @@ export class SubagentRunner {
450
452
  const status = result?.status ?? (run.controller.signal.aborted ? 'cancelled' : 'infrastructure_error');
451
453
  const reason = result?.reason ?? (failure !== undefined ? (failure instanceof Error ? failure.message : String(failure)) : undefined);
452
454
  const telemetrySurface = { home: run.directory, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) };
453
- const telemetryHandle = run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, {
454
- graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
455
- jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
456
- }, run.workspace);
455
+ const telemetryHandle = run.telemetryHandle;
456
+ const telemetryAccess = { home: run.directory, lease: telemetryHandle?.lease };
457
457
  let telemetryFinished = false;
458
458
  const settleTelemetry = (settled, why) => {
459
- if (telemetryFinished)
459
+ if (telemetryFinished || !telemetryHandle)
460
460
  return Promise.resolve();
461
461
  telemetryFinished = true;
462
- const finishedTelemetry = result?.telemetry ?? createRunTelemetry();
463
- for (const probe of run.probeModels.values()) {
464
- recordModelUse(finishedTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: probe.model, role: 'other', usage: probe.usage });
465
- }
462
+ const finishedTelemetry = result?.telemetry ?? createRunTelemetry(telemetryAccess);
463
+ mergeRunTelemetry(finishedTelemetry, run.probeTelemetry);
466
464
  return (run.telemetryStart ?? Promise.resolve()).then(() => reportRunFinished(telemetrySurface, telemetryHandle, {
467
465
  status: settled, ...(why === undefined ? {} : { reason: why }),
468
466
  ...(result?.providerRequestFailed || run.healthProviderFailed ? { providerRequestFailed: true } : {}),
469
467
  ...(result?.providerOverflow ? { providerOverflow: true } : {}),
470
468
  ...(result?.failureCode === undefined ? {} : { errorCode: result.failureCode }),
471
- ...(result?.telemetry !== undefined || run.probeModels.size > 0 ? { telemetry: finishedTelemetry } : {}),
469
+ ...(result?.telemetry !== undefined || (hasRunTelemetry(run.probeTelemetry) && run.probeTelemetry.models.length > 0) ? { telemetry: finishedTelemetry } : {}),
472
470
  ...(result?.toolCalls === undefined ? {} : { toolCalls: result.toolCalls }),
473
471
  })).catch(() => { });
474
472
  };
@@ -491,14 +489,14 @@ export class SubagentRunner {
491
489
  record.checkpointFailures = run.checkpoints.failures;
492
490
  }
493
491
  try {
494
- await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify(record, null, 2) + '\n', { mode: 0o600 });
492
+ await writeFinalRunRecord(run.directory, record, telemetryAccess);
495
493
  }
496
494
  catch (error) {
497
495
  process.stderr.write(`Could not record the stopped subagent run: ${error instanceof Error ? error.message : String(error)}\n`);
498
496
  const detail = error instanceof Error ? error.message : String(error);
499
- const terminalized = await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify({
497
+ const terminalized = await writeFinalRunRecord(run.directory, {
500
498
  ...record, status: 'infrastructure_error', reason: `The run record could not be written: ${detail}`, endedAt,
501
- }, null, 2) + '\n', { mode: 0o600 }).then(() => true, () => false);
499
+ }, telemetryAccess).then(() => true, () => false);
502
500
  if (terminalized) {
503
501
  await writeStudioRunSummary(run.directory, {
504
502
  id: run.runId, status: 'infrastructure_error', startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
@@ -517,7 +515,8 @@ export class SubagentRunner {
517
515
  this.releaseWorkspace();
518
516
  this.release(run);
519
517
  await settleTelemetry('infrastructure_error', `The run record could not be written: ${detail}`);
520
- await drainTelemetry(telemetrySurface).catch(() => { });
518
+ if (telemetryHandle)
519
+ await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
521
520
  run.outcome = { status: 'infrastructure_error', reason: `The run record could not be written: ${detail}` };
522
521
  return;
523
522
  }
@@ -544,7 +543,8 @@ export class SubagentRunner {
544
543
  this.releaseWorkspace();
545
544
  this.release(run);
546
545
  await settleTelemetry(status, reason);
547
- await drainTelemetry(telemetrySurface).catch(() => { });
546
+ if (telemetryHandle)
547
+ await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
548
548
  run.outcome = { status, ...(result !== undefined ? { result } : {}), ...(reason !== undefined ? { reason } : {}) };
549
549
  }
550
550
  runSignal() {
@@ -0,0 +1,50 @@
1
+ import { type CodexConnect } from './codex-rpc.js';
2
+ import type { EfficiencyConfig } from './efficiency.js';
3
+ import type { QuotaReadings, QuotaWindow } from './model-pool.js';
4
+ import type { ProviderConfig } from './providers.js';
5
+ /**
6
+ * Subscription usage for pool routing, read from each provider's own client. Nothing here reads another tool's
7
+ * files: a provider with no built-in source simply has no reading, and pool routing treats that as no known limit.
8
+ */
9
+ /** How long one reading is reused before the provider is asked again. */
10
+ export declare const USAGE_READING_TTL_MS = 60000;
11
+ export type UsageProvider = Pick<ProviderConfig, 'id' | 'type' | 'codexAccount'>;
12
+ export type UsageSource = (provider: UsageProvider, signal: AbortSignal) => Promise<QuotaWindow[] | undefined>;
13
+ /** The hosted allowance as the hosted monitor reports it. */
14
+ export type HostedUsageReading = {
15
+ kind: string;
16
+ usedPercent?: number;
17
+ resetsAt?: string;
18
+ } | undefined;
19
+ /** The usage windows in a Codex `account/rateLimits/read` answer. */
20
+ export declare function codexWindows(rateLimits: unknown): QuotaWindow[];
21
+ /** Ask the signed-in Codex client for its account's usage windows. */
22
+ export declare function readCodexUsage(provider: UsageProvider, signal: AbortSignal, connect?: CodexConnect): Promise<QuotaWindow[] | undefined>;
23
+ /** The hosted weekly allowance as one usage window. */
24
+ export declare function hostedWindows(usage: HostedUsageReading): QuotaWindow[] | undefined;
25
+ /** The provider types whose client can report usage. */
26
+ export declare const USAGE_SOURCES: Readonly<Partial<Record<string, UsageSource>>>;
27
+ type UsageCache = Map<string, {
28
+ at: number;
29
+ windows: Promise<QuotaWindow[] | undefined>;
30
+ }>;
31
+ export interface UsageReaderOptions {
32
+ /** Read only these provider ids. */
33
+ only?: readonly string[];
34
+ sources?: Readonly<Partial<Record<string, UsageSource>>>;
35
+ hosted?: () => HostedUsageReading;
36
+ now?: () => number;
37
+ ttlMs?: number;
38
+ cache?: UsageCache;
39
+ }
40
+ /**
41
+ * A reader of usage by provider id. Each provider is asked at most once per `ttlMs`; a read that fails or times out
42
+ * gives no reading for that provider and never fails the caller.
43
+ */
44
+ export declare function createUsageReader(providers: () => readonly UsageProvider[], options?: UsageReaderOptions): (signal: AbortSignal) => Promise<QuotaReadings>;
45
+ /** The usage reader for a configuration's pool: it asks only the providers the pool names. */
46
+ export declare function poolUsageReader(config: {
47
+ providers: readonly UsageProvider[];
48
+ efficiency?: EfficiencyConfig;
49
+ }, hosted?: () => HostedUsageReading): (signal: AbortSignal) => Promise<QuotaReadings>;
50
+ export {};
@@ -0,0 +1,92 @@
1
+ import { codexConnectFor } from './codex-rpc.js';
2
+ /**
3
+ * Subscription usage for pool routing, read from each provider's own client. Nothing here reads another tool's
4
+ * files: a provider with no built-in source simply has no reading, and pool routing treats that as no known limit.
5
+ */
6
+ /** How long one reading is reused before the provider is asked again. */
7
+ export const USAGE_READING_TTL_MS = 60_000;
8
+ const USAGE_READ_TIMEOUT_MS = 10_000;
9
+ const WEEK_SECONDS = 7 * 86_400;
10
+ function codexWindow(value) {
11
+ if (!value || typeof value !== 'object')
12
+ return undefined;
13
+ const { usedPercent, windowDurationMins, resetsAt } = value;
14
+ if (typeof usedPercent !== 'number' || !Number.isFinite(usedPercent))
15
+ return undefined;
16
+ // Codex reports the reset as seconds since the epoch.
17
+ const reset = typeof resetsAt === 'number' && Number.isFinite(resetsAt) && resetsAt > 0 ? (resetsAt < 100_000_000_000 ? resetsAt * 1000 : resetsAt) : undefined;
18
+ const seconds = typeof windowDurationMins === 'number' && Number.isFinite(windowDurationMins) && windowDurationMins > 0 ? windowDurationMins * 60 : undefined;
19
+ return { usedPercent, ...(reset === undefined ? {} : { resetsAt: reset }), ...(seconds === undefined ? {} : { windowSeconds: seconds }) };
20
+ }
21
+ /** The usage windows in a Codex `account/rateLimits/read` answer. */
22
+ export function codexWindows(rateLimits) {
23
+ if (!rateLimits || typeof rateLimits !== 'object')
24
+ return [];
25
+ const { primary, secondary } = rateLimits;
26
+ return [codexWindow(primary), codexWindow(secondary)].filter((item) => item !== undefined);
27
+ }
28
+ /** Ask the signed-in Codex client for its account's usage windows. */
29
+ export async function readCodexUsage(provider, signal, connect = codexConnectFor(provider)) {
30
+ const rpc = await connect(AbortSignal.any([signal, AbortSignal.timeout(USAGE_READ_TIMEOUT_MS)]));
31
+ try {
32
+ const windows = codexWindows((await rpc.request('account/rateLimits/read', {}))?.rateLimits);
33
+ return windows.length ? windows : undefined;
34
+ }
35
+ finally {
36
+ rpc.close();
37
+ }
38
+ }
39
+ /** The hosted weekly allowance as one usage window. */
40
+ export function hostedWindows(usage) {
41
+ if (!usage || usage.kind !== 'meter' || typeof usage.usedPercent !== 'number' || !Number.isFinite(usage.usedPercent))
42
+ return undefined;
43
+ const reset = typeof usage.resetsAt === 'string' ? Date.parse(usage.resetsAt) : NaN;
44
+ return [{ usedPercent: usage.usedPercent, ...(Number.isFinite(reset) ? { resetsAt: reset, windowSeconds: WEEK_SECONDS } : {}) }];
45
+ }
46
+ /** The provider types whose client can report usage. */
47
+ export const USAGE_SOURCES = { codex: readCodexUsage };
48
+ const sharedCache = new Map();
49
+ /**
50
+ * A reader of usage by provider id. Each provider is asked at most once per `ttlMs`; a read that fails or times out
51
+ * gives no reading for that provider and never fails the caller.
52
+ */
53
+ export function createUsageReader(providers, options = {}) {
54
+ const sources = options.sources ?? USAGE_SOURCES;
55
+ const cache = options.cache ?? sharedCache;
56
+ const now = options.now ?? Date.now;
57
+ const ttl = options.ttlMs ?? USAGE_READING_TTL_MS;
58
+ return async (signal) => {
59
+ signal.throwIfAborted();
60
+ const readings = {};
61
+ await Promise.all(providers().filter(provider => !options.only || options.only.includes(provider.id)).map(async (provider) => {
62
+ if (provider.type === 'andorra') {
63
+ const hosted = hostedWindows(options.hosted?.());
64
+ if (hosted)
65
+ readings[provider.id] = hosted;
66
+ return;
67
+ }
68
+ const source = sources[provider.type];
69
+ if (!source)
70
+ return;
71
+ const key = JSON.stringify([provider.type, provider.id, provider.codexAccount ?? null]);
72
+ let entry = cache.get(key);
73
+ if (!entry || now() - entry.at >= ttl) {
74
+ // The read is shared by every run, so it is bounded by its own deadline and not by one run's cancellation.
75
+ entry = { at: now(), windows: Promise.resolve().then(() => source(provider, AbortSignal.timeout(USAGE_READ_TIMEOUT_MS))).catch(() => undefined) };
76
+ cache.set(key, entry);
77
+ }
78
+ const windows = await entry.windows;
79
+ if (windows?.length)
80
+ readings[provider.id] = windows;
81
+ }));
82
+ return readings;
83
+ };
84
+ }
85
+ /** The usage reader for a configuration's pool: it asks only the providers the pool names. */
86
+ export function poolUsageReader(config, hosted) {
87
+ // With `candidates: all` any configured provider can be chosen, so each one that has a source is asked.
88
+ if (config.efficiency?.adaptiveRouting?.candidates === 'all')
89
+ return createUsageReader(() => config.providers, hosted ? { hosted } : {});
90
+ const only = [...new Set((config.efficiency?.adaptiveRouting?.pool ?? []).map(entry => entry.provider))];
91
+ return createUsageReader(() => config.providers, { only, ...(hosted ? { hosted } : {}) });
92
+ }
@@ -57,10 +57,12 @@ export declare function repositoryOf(root: string): Promise<{
57
57
  } | undefined>;
58
58
  /** What New Task offers to start from in `root`'s repository. */
59
59
  export declare function taskStartPoints(root: string): Promise<TaskStartPoints>;
60
- /** A task branch's name from the prompt: lower case, hyphens, at most 40 characters. */
60
+ /** The name a caller picked for a task branch, made a safe slug: lower case, hyphens, at most 40 characters. */
61
61
  export declare function taskSlug(text: string): string;
62
+ /** A random 8-character task name (`a92x9dwe`): what a worktree, its `task/<name>` branch and a session start under. */
63
+ export declare function randomTaskName(): string;
62
64
  /**
63
- * Where task worktrees go: `~/worktrees/<project>/<slug>`, outside Andorra's home, whose files the permission rules
65
+ * Where task worktrees go: `~/worktrees/<project>/<name>`, outside Andorra's home, whose files the permission rules
64
66
  * protect from the agent.
65
67
  */
66
68
  export declare function worktreesRoot(): string;
@@ -72,8 +74,10 @@ export declare function forgetPrepared(home: string, key: string): Promise<void>
72
74
  export declare function takePrepared(home: string, root: string, key: string): Promise<SessionCheckout>;
73
75
  /**
74
76
  * Makes a writing task's worktree: resolves `base` to a commit (refreshing the default branch from its remote first),
75
- * then adds a worktree on a new `task/<slug>` branch in `~/worktrees/<project>`. Names stay distinct across simultaneous
76
- * starts. The same `key` returns the same worktree while it still stands, so a retried start reuses its preparation.
77
+ * then adds a worktree on a new `task/<name>` branch in `~/worktrees/<project>`, where `name` is the random id the
78
+ * caller picked. A collision with an existing branch or folder is rare; a start that hits one draws a fresh random
79
+ * name instead of growing a suffix. The same `key` returns the same worktree while it still stands, so a retried
80
+ * start reuses its preparation.
77
81
  */
78
82
  export declare function prepareTaskWorktree(options: {
79
83
  home: string;
@@ -83,6 +87,18 @@ export declare function prepareTaskWorktree(options: {
83
87
  key: string;
84
88
  worktrees?: string;
85
89
  }): Promise<PreparedTaskCheckout>;
90
+ /** Whether a task branch still carries the automatic name its start gave it (`task/<random id>`). */
91
+ export declare function isAutoTaskBranch(branch: string | undefined): boolean;
92
+ /**
93
+ * Renames a task's own branch to the name the model gave the task (`task/fix-login-redirect-loop`), replacing the
94
+ * random id the start created. Only a branch that still carries the automatic name is renamed — a branch a person or
95
+ * the agent already moved is never touched, and neither is one that has a remote upstream, which means it was pushed,
96
+ * perhaps under review. A name that is taken gets a `-2`, `-3`… suffix. Returns the new branch name, or undefined
97
+ * when nothing was renamed.
98
+ */
99
+ export declare function renameTaskBranch(checkout: SessionCheckout, name: string): Promise<string | undefined>;
100
+ /** Puts a task branch back under its previous name, when a rename succeeded but could not be recorded. */
101
+ export declare function revertTaskBranchRename(checkout: SessionCheckout, from: string, to: string): Promise<void>;
86
102
  /** What an in-place task records: the project folder, and the branch and commit it began on. */
87
103
  export declare function inPlaceCheckout(root: string): Promise<SessionCheckout>;
88
104
  export declare function checkoutTop(checkout: SessionCheckout): string;