@andorra-labs/code 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/dist/src/account-jev-savings.d.ts +4 -0
  2. package/dist/src/account-jev-savings.js +92 -0
  3. package/dist/src/acp-agent.js +2 -2
  4. package/dist/src/agent-execution.js +441 -53
  5. package/dist/src/agent-mcp.js +7 -1
  6. package/dist/src/agent-modifiers.js +5 -7
  7. package/dist/src/analytics.d.ts +19 -1
  8. package/dist/src/analytics.js +9 -1
  9. package/dist/src/andorra/entry.js +15 -6
  10. package/dist/src/andorra/errors.js +3 -0
  11. package/dist/src/andorra/hosted.d.ts +8 -0
  12. package/dist/src/andorra/hosted.js +22 -3
  13. package/dist/src/andorra/streams.d.ts +49 -0
  14. package/dist/src/andorra/streams.js +98 -0
  15. package/dist/src/antigravity-acp.d.ts +28 -0
  16. package/dist/src/antigravity-acp.js +150 -0
  17. package/dist/src/antigravity-terminal.d.ts +2 -0
  18. package/dist/src/antigravity-terminal.js +214 -0
  19. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  20. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  21. package/dist/src/app-server/artifact.d.ts +14 -0
  22. package/dist/src/app-server/artifact.js +46 -0
  23. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  24. package/dist/src/app-server/legal-protocol.js +16 -0
  25. package/dist/src/app-server/protocol.d.ts +34 -3
  26. package/dist/src/app-server/protocol.js +3 -1
  27. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  28. package/dist/src/app-server/telemetry-protocol.js +2 -0
  29. package/dist/src/app-server/telemetry.d.ts +38 -0
  30. package/dist/src/app-server/telemetry.js +163 -0
  31. package/dist/src/app-server/workspace.d.ts +21 -0
  32. package/dist/src/app-server/workspace.js +192 -10
  33. package/dist/src/app-server.d.ts +82 -26
  34. package/dist/src/app-server.js +1573 -417
  35. package/dist/src/attachments.d.ts +10 -0
  36. package/dist/src/attachments.js +102 -7
  37. package/dist/src/auth/AuthManager.d.ts +11 -2
  38. package/dist/src/auth/AuthManager.js +56 -13
  39. package/dist/src/auth/index.d.ts +5 -1
  40. package/dist/src/auth/index.js +8 -1
  41. package/dist/src/auth/lifecycle.d.ts +13 -0
  42. package/dist/src/auth/lifecycle.js +109 -0
  43. package/dist/src/auth/store.d.ts +1 -0
  44. package/dist/src/auth/store.js +12 -0
  45. package/dist/src/auth/types.d.ts +12 -0
  46. package/dist/src/automation-runner.js +2 -0
  47. package/dist/src/automation-service.js +7 -2
  48. package/dist/src/automation-tool.js +2 -1
  49. package/dist/src/benchmark-scores.d.ts +88 -0
  50. package/dist/src/benchmark-scores.js +302 -0
  51. package/dist/src/bridge/command.js +16 -1
  52. package/dist/src/bridge/control.d.ts +3 -1
  53. package/dist/src/bridge/control.js +9 -3
  54. package/dist/src/bridge/engines.d.ts +2 -0
  55. package/dist/src/bridge/engines.js +9 -0
  56. package/dist/src/bridge/github.d.ts +108 -0
  57. package/dist/src/bridge/github.js +378 -0
  58. package/dist/src/bridge/host-ops.d.ts +3 -3
  59. package/dist/src/bridge/host-ops.js +14 -2
  60. package/dist/src/bridge/host.d.ts +2 -0
  61. package/dist/src/bridge/host.js +70 -16
  62. package/dist/src/bridge/protocol.d.ts +1 -0
  63. package/dist/src/bridge/protocol.js +1 -0
  64. package/dist/src/browser-panel-tool.d.ts +12 -0
  65. package/dist/src/browser-panel-tool.js +30 -3
  66. package/dist/src/browser-runner.js +53 -62
  67. package/dist/src/browser-server.js +10 -4
  68. package/dist/src/browser-session.d.ts +14 -0
  69. package/dist/src/browser-session.js +57 -12
  70. package/dist/src/browser-view.d.ts +40 -1
  71. package/dist/src/browser-view.js +163 -9
  72. package/dist/src/browser-window-style.d.ts +27 -0
  73. package/dist/src/browser-window-style.js +244 -0
  74. package/dist/src/bug-report-attachments.d.ts +48 -0
  75. package/dist/src/bug-report-attachments.js +327 -0
  76. package/dist/src/bug-report.d.ts +23 -3
  77. package/dist/src/bug-report.js +72 -9
  78. package/dist/src/claude-provider.d.ts +1 -0
  79. package/dist/src/claude-provider.js +77 -36
  80. package/dist/src/cli.d.ts +1 -3
  81. package/dist/src/cli.js +245 -62
  82. package/dist/src/codex-provider.d.ts +1 -0
  83. package/dist/src/codex-provider.js +44 -8
  84. package/dist/src/coding-tools.d.ts +1 -0
  85. package/dist/src/coding-tools.js +28 -7
  86. package/dist/src/command-screens.d.ts +1 -1
  87. package/dist/src/command-screens.js +2 -2
  88. package/dist/src/commands.d.ts +9 -2
  89. package/dist/src/commands.js +69 -64
  90. package/dist/src/completion.js +13 -7
  91. package/dist/src/config.d.ts +14 -3
  92. package/dist/src/config.js +57 -17
  93. package/dist/src/context-budget.d.ts +11 -2
  94. package/dist/src/context-budget.js +38 -4
  95. package/dist/src/context-compaction.d.ts +10 -8
  96. package/dist/src/context-compaction.js +23 -24
  97. package/dist/src/deadline.js +1 -1
  98. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  99. package/dist/src/decision/DecisionManager.d.ts +16 -0
  100. package/dist/src/decision/DecisionManager.js +75 -2
  101. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  102. package/dist/src/decision/applyTaskKind.js +53 -0
  103. package/dist/src/decision/applyToolMenu.js +6 -2
  104. package/dist/src/decision/hostedPolicy.js +6 -3
  105. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  106. package/dist/src/decision/optimizationPolicy.js +23 -3
  107. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
  108. package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
  109. package/dist/src/decision/providers/index.js +1 -1
  110. package/dist/src/decision/taskKind.d.ts +52 -0
  111. package/dist/src/decision/taskKind.js +76 -0
  112. package/dist/src/decision/toolFamilies.js +1 -1
  113. package/dist/src/decision/types.d.ts +3 -1
  114. package/dist/src/default-graph.js +1 -1
  115. package/dist/src/efficiency.d.ts +80 -1
  116. package/dist/src/efficiency.js +119 -4
  117. package/dist/src/effort-routing.d.ts +27 -0
  118. package/dist/src/effort-routing.js +34 -0
  119. package/dist/src/evidence.d.ts +110 -0
  120. package/dist/src/evidence.js +195 -0
  121. package/dist/src/extensions.d.ts +2 -0
  122. package/dist/src/extensions.js +30 -20
  123. package/dist/src/github-app/agent-writes.d.ts +1 -1
  124. package/dist/src/github-app/agent-writes.js +1 -1
  125. package/dist/src/github-app/client.d.ts +19 -0
  126. package/dist/src/github-app/client.js +21 -1
  127. package/dist/src/github-app/event-source.d.ts +0 -5
  128. package/dist/src/github-app/event-source.js +1 -31
  129. package/dist/src/github-app/metrics.d.ts +2 -5
  130. package/dist/src/github-app/metrics.js +2 -14
  131. package/dist/src/github-app/review-loop.d.ts +5 -5
  132. package/dist/src/github-app/review-loop.js +1 -1
  133. package/dist/src/github-app/review-node.d.ts +2 -2
  134. package/dist/src/github-app/triggers.d.ts +3 -3
  135. package/dist/src/github-names.d.ts +7 -0
  136. package/dist/src/github-names.js +7 -0
  137. package/dist/src/glob-search.d.ts +1 -0
  138. package/dist/src/glob-search.js +3 -0
  139. package/dist/src/google-provider.d.ts +5 -28
  140. package/dist/src/google-provider.js +6 -141
  141. package/dist/src/graph-editor-session.d.ts +1 -0
  142. package/dist/src/graph-editor-session.js +2 -0
  143. package/dist/src/graph-health.js +3 -1
  144. package/dist/src/graph-preview.d.ts +2 -0
  145. package/dist/src/graph-preview.js +1 -0
  146. package/dist/src/graph-runner.js +20 -14
  147. package/dist/src/graph-selection.d.ts +3 -1
  148. package/dist/src/graph-selection.js +2 -2
  149. package/dist/src/graph-server.d.ts +8 -1
  150. package/dist/src/graph-server.js +49 -12
  151. package/dist/src/graph-sync.d.ts +2 -1
  152. package/dist/src/graph-sync.js +13 -0
  153. package/dist/src/graph-ui/app.js +49 -8
  154. package/dist/src/graph-ui/index.html +1 -1
  155. package/dist/src/graphs.d.ts +23 -1
  156. package/dist/src/graphs.js +58 -7
  157. package/dist/src/grok-provider.js +17 -14
  158. package/dist/src/hardened-runtime.js +39 -25
  159. package/dist/src/jev-savings.d.ts +4 -0
  160. package/dist/src/jev-savings.js +13 -0
  161. package/dist/src/legal/client.d.ts +25 -0
  162. package/dist/src/legal/client.js +47 -0
  163. package/dist/src/legal/command.d.ts +13 -0
  164. package/dist/src/legal/command.js +98 -0
  165. package/dist/src/legal/documents.d.ts +2 -0
  166. package/dist/src/legal/documents.js +14 -0
  167. package/dist/src/legal/gate.d.ts +13 -0
  168. package/dist/src/legal/gate.js +96 -0
  169. package/dist/src/legal/manifest.d.ts +21 -0
  170. package/dist/src/legal/manifest.js +23 -0
  171. package/dist/src/legal/receipt.d.ts +13 -0
  172. package/dist/src/legal/receipt.js +137 -0
  173. package/dist/src/legal/release.d.ts +27 -0
  174. package/dist/src/legal/release.js +28 -0
  175. package/dist/src/managed-sign-in.d.ts +0 -1
  176. package/dist/src/managed-sign-in.js +0 -13
  177. package/dist/src/membership.d.ts +27 -1
  178. package/dist/src/membership.js +139 -7
  179. package/dist/src/model-health-cache.js +1 -1
  180. package/dist/src/model-metadata.js +3 -7
  181. package/dist/src/model-override.d.ts +2 -1
  182. package/dist/src/model-override.js +9 -0
  183. package/dist/src/model-pool.d.ts +99 -0
  184. package/dist/src/model-pool.js +136 -0
  185. package/dist/src/model-relay/local.js +5 -0
  186. package/dist/src/model-relay/remote.d.ts +2 -0
  187. package/dist/src/model-relay/remote.js +4 -0
  188. package/dist/src/model-tiers.d.ts +16 -1
  189. package/dist/src/model-tiers.js +31 -7
  190. package/dist/src/opencode-cli-provider.js +59 -56
  191. package/dist/src/opencode-provider.js +16 -13
  192. package/dist/src/permissions.d.ts +5 -0
  193. package/dist/src/permissions.js +7 -0
  194. package/dist/src/plan-pass.js +2 -1
  195. package/dist/src/pool-scores.d.ts +45 -0
  196. package/dist/src/pool-scores.js +40 -0
  197. package/dist/src/provider-connection.js +3 -17
  198. package/dist/src/provider-engine.d.ts +13 -1
  199. package/dist/src/provider-engine.js +116 -12
  200. package/dist/src/provider-request-error.d.ts +8 -0
  201. package/dist/src/provider-request-error.js +12 -0
  202. package/dist/src/provider-settings.d.ts +1 -1
  203. package/dist/src/provider-settings.js +36 -18
  204. package/dist/src/provider-turn-deadline.d.ts +39 -0
  205. package/dist/src/provider-turn-deadline.js +139 -0
  206. package/dist/src/providers.d.ts +8 -9
  207. package/dist/src/providers.js +211 -150
  208. package/dist/src/pull-request-merge.d.ts +1 -8
  209. package/dist/src/pull-request-merge.js +0 -4
  210. package/dist/src/pull-requests.d.ts +83 -57
  211. package/dist/src/pull-requests.js +266 -225
  212. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  213. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  214. package/dist/src/react-runtime.js +245 -71
  215. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  216. package/dist/src/reasoning-probe-cloud.js +209 -0
  217. package/dist/src/remote/engine-pool.d.ts +3 -0
  218. package/dist/src/remote/engine-pool.js +88 -21
  219. package/dist/src/remote/recovery.d.ts +6 -0
  220. package/dist/src/remote/recovery.js +37 -0
  221. package/dist/src/run-records.d.ts +13 -3
  222. package/dist/src/run-records.js +59 -34
  223. package/dist/src/runtime.d.ts +47 -2
  224. package/dist/src/runtime.js +33 -7
  225. package/dist/src/session-summary.d.ts +8 -0
  226. package/dist/src/session-summary.js +34 -0
  227. package/dist/src/sessions.d.ts +32 -0
  228. package/dist/src/sessions.js +65 -3
  229. package/dist/src/shell.js +6 -0
  230. package/dist/src/side-panel.js +36 -2
  231. package/dist/src/sign-in-detection.d.ts +1 -1
  232. package/dist/src/sign-in-detection.js +4 -10
  233. package/dist/src/sign-in-offer.js +1 -1
  234. package/dist/src/skill-commands.js +1 -1
  235. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  236. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  237. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  238. package/dist/src/skills/bundled/provenance.json +3 -3
  239. package/dist/src/subagent-run.js +50 -50
  240. package/dist/src/subscription-usage.d.ts +50 -0
  241. package/dist/src/subscription-usage.js +92 -0
  242. package/dist/src/task-checkout.d.ts +157 -0
  243. package/dist/src/task-checkout.js +628 -0
  244. package/dist/src/telemetry/access.d.ts +18 -0
  245. package/dist/src/telemetry/access.js +43 -0
  246. package/dist/src/telemetry/aggregate.d.ts +18 -2
  247. package/dist/src/telemetry/aggregate.js +22 -9
  248. package/dist/src/telemetry/capture-core.d.ts +33 -14
  249. package/dist/src/telemetry/capture-core.js +124 -25
  250. package/dist/src/telemetry/capture.d.ts +3 -2
  251. package/dist/src/telemetry/capture.js +21 -1
  252. package/dist/src/telemetry/decision-capture.js +4 -0
  253. package/dist/src/telemetry/emitter.d.ts +6 -7
  254. package/dist/src/telemetry/emitter.js +124 -29
  255. package/dist/src/telemetry/gate.d.ts +41 -2
  256. package/dist/src/telemetry/gate.js +89 -4
  257. package/dist/src/telemetry/home.d.ts +1 -0
  258. package/dist/src/telemetry/home.js +20 -0
  259. package/dist/src/telemetry/identity.d.ts +6 -3
  260. package/dist/src/telemetry/identity.js +19 -6
  261. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  262. package/dist/src/telemetry/lifecycle.js +76 -0
  263. package/dist/src/telemetry/outbox.d.ts +13 -8
  264. package/dist/src/telemetry/outbox.js +68 -12
  265. package/dist/src/telemetry/permission-command.d.ts +38 -0
  266. package/dist/src/telemetry/permission-command.js +208 -0
  267. package/dist/src/telemetry/permission.d.ts +168 -0
  268. package/dist/src/telemetry/permission.js +662 -0
  269. package/dist/src/telemetry/record-installation.d.ts +1 -0
  270. package/dist/src/telemetry/record-installation.js +9 -0
  271. package/dist/src/telemetry/region-data.d.ts +12 -0
  272. package/dist/src/telemetry/region-data.js +1314 -0
  273. package/dist/src/telemetry/region.d.ts +34 -0
  274. package/dist/src/telemetry/region.js +87 -0
  275. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  276. package/dist/src/telemetry/run-privacy.js +165 -0
  277. package/dist/src/telemetry/schema.d.ts +27 -6
  278. package/dist/src/telemetry/schema.js +109 -14
  279. package/dist/src/telemetry/state.d.ts +11 -7
  280. package/dist/src/telemetry/state.js +39 -6
  281. package/dist/src/telemetry/surface.d.ts +20 -3
  282. package/dist/src/telemetry/surface.js +71 -15
  283. package/dist/src/telemetry/uploader.d.ts +6 -11
  284. package/dist/src/telemetry/uploader.js +72 -46
  285. package/dist/src/telemetry/uploads.d.ts +5 -1
  286. package/dist/src/telemetry/uploads.js +25 -6
  287. package/dist/src/telemetry/version.d.ts +5 -0
  288. package/dist/src/telemetry/version.js +34 -0
  289. package/dist/src/telemetry/workspace.d.ts +4 -1
  290. package/dist/src/telemetry/workspace.js +18 -3
  291. package/dist/src/terminal-ui.d.ts +3 -0
  292. package/dist/src/terminal-ui.js +48 -6
  293. package/dist/src/test-edit-guard.d.ts +30 -0
  294. package/dist/src/test-edit-guard.js +167 -2
  295. package/dist/src/thinking-level-detect.d.ts +13 -0
  296. package/dist/src/thinking-level-detect.js +52 -0
  297. package/dist/src/thinking-levels.d.ts +30 -0
  298. package/dist/src/thinking-levels.js +131 -0
  299. package/dist/src/timers.d.ts +3 -0
  300. package/dist/src/todos.d.ts +2 -1
  301. package/dist/src/todos.js +24 -4
  302. package/dist/src/tool-argument-coercion.d.ts +7 -0
  303. package/dist/src/tool-argument-coercion.js +49 -0
  304. package/dist/src/tool-catalog.d.ts +2 -2
  305. package/dist/src/tool-catalog.js +1 -1
  306. package/dist/src/tools.js +67 -22
  307. package/dist/src/transcript.js +3 -2
  308. package/dist/src/types.d.ts +48 -1
  309. package/dist/src/update.js +4 -0
  310. package/dist/src/usage-analytics.d.ts +7 -0
  311. package/dist/src/usage-analytics.js +85 -13
  312. package/dist/telemetry-consent-v1 +1 -0
  313. package/package.json +97 -96
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { realpath } from 'node:fs/promises';
3
3
  import { isAbsolute, relative } from 'node:path';
4
+ import { requireLegalAcceptance } from './legal/gate.js';
4
5
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
6
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
6
7
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
@@ -45,10 +46,13 @@ export const GRAPH_AGENT_GUIDE = [
45
46
  ' For multi-outcome agents supply completion: {mode: "outcomes", outcomes: ["pass", "fail"]}.',
46
47
  ' Every declared outcome must have an outgoing edge unless completion.requireRoutes is explicitly false.',
47
48
  ' Agents created or modified through MCP must set provider; never assume the active provider is inherited.',
48
- ' subagents {enabled, maxConcurrent, maxTotal, maxDepth, workspace, modelPolicy, toolInheritance, context, roles}:',
49
+ ' subagents {enabled, maxConcurrent, maxTotal, maxDepth, workspace, modelPolicy, toolInheritance, context, freeform, roles}:',
49
50
  ' workspace is shared-read-only (default; roles only read), shared-write (writes in place; maxConcurrent 1 when roles write)',
50
51
  ' or worktree (each child gets its own Git worktree; required for writing roles on an Orchestrator; needs parent git write).',
51
52
  ' modelPolicy: inherit | specific | per-role. toolInheritance: restricted | inherit. context: selected | task-only.',
53
+ ' freeform: off (default; every spawn names a configured role) | read-only | write. When not off, spawn_subagent may omit role',
54
+ ' to run a general subagent on a task the agent writes. write gives it the node permissions and needs workspace shared-write',
55
+ ' (maxConcurrent 1) or worktree; on an Orchestrator it requires worktree and counts as delegation, like a writing role.',
52
56
  ' Validation messages name the field and the values to set. This guide and those messages are the whole reference: never search source code for them.',
53
57
  'condition: requires condition {source, path, equals}; ports true and false; source must run before it on every path.',
54
58
  'loop: requires loop {maxIterations}; ports body and done. A body edge may return to the loop.',
@@ -668,6 +672,8 @@ export class AgentMcpBackend {
668
672
  : 'The graph is listed only in ' + projects.join(', ') + '. Other projects no longer offer it in the graph picker.' };
669
673
  }
670
674
  async dispatch(name, args, beforeSave, workspace) {
675
+ if (!['andorra_graph_guide', 'andorra_projects_list', 'andorra_sessions_list', 'andorra_sessions_attention', 'andorra_subagent_status', 'andorra_subagent_result', 'andorra_subagent_cancel', 'andorra_providers_list'].includes(name))
676
+ await requireLegalAcceptance(this.directory);
671
677
  if (name === 'andorra_graph_guide')
672
678
  return { architecture: GRAPH_AGENT_GUIDE, resourceUri: 'andorra://graph/architecture' };
673
679
  if (name === 'andorra_projects_list')
@@ -4,12 +4,13 @@ import { isDeepStrictEqual } from 'node:util';
4
4
  import { executeAgentNode } from './agent-execution.js';
5
5
  import { DEFAULT_GRAPH, LIMIT_KEYS, isUnlimitedAlias, resolveLimits } from './runtime.js';
6
6
  import { bindUserWaits, createRuntimeBudget } from './deadline.js';
7
- import { createRunTelemetry, mergeRunTelemetry } from './telemetry/capture.js';
7
+ import { resolveTelemetryCapture, bindRunTelemetry, createRunTelemetry, mergeRunTelemetry } from './telemetry/capture.js';
8
8
  export function matchesOutput(completion, predicate) {
9
9
  const value = predicate.path.split('.').reduce((value, key) => value && typeof value === 'object' && Object.hasOwn(value, key) ? value[key] : undefined, completion.output);
10
10
  return isDeepStrictEqual(value, predicate.equals);
11
11
  }
12
12
  export async function executeModifiedAgent(node, options) {
13
+ options = { ...options, telemetry: resolveTelemetryCapture(options.telemetry) };
13
14
  const modifiers = node.modifiers;
14
15
  if (!modifiers?.loop && modifiers?.parallel?.mode !== 'copies')
15
16
  return executeAgentNode(node, options);
@@ -45,8 +46,7 @@ export async function executeModifiedAgent(node, options) {
45
46
  return () => { resume(); resumeParent?.(); };
46
47
  } };
47
48
  const aggregate = { inputTokens: 0, outputTokens: 0, requests: 0 };
48
- const telemetry = createRunTelemetry();
49
- let sawTelemetry = false;
49
+ const telemetry = createRunTelemetry(options.telemetry);
50
50
  let toolCalls = 0;
51
51
  let previous = options.resumeState?.previousIterationCompletion;
52
52
  let last;
@@ -163,10 +163,8 @@ export async function executeModifiedAgent(node, options) {
163
163
  };
164
164
  await Promise.all(Array.from({ length: concurrency }, runCopy));
165
165
  for (const result of results.filter(Boolean)) {
166
- if (result.telemetry) {
167
- sawTelemetry = true;
166
+ if (result.telemetry)
168
167
  mergeRunTelemetry(telemetry, result.telemetry);
169
- }
170
168
  aggregate.inputTokens += result.usage.inputTokens;
171
169
  aggregate.outputTokens += result.usage.outputTokens;
172
170
  aggregate.requests += result.usage.requests;
@@ -255,7 +253,7 @@ export async function executeModifiedAgent(node, options) {
255
253
  last = { ...last, status: 'exhausted', reason: 'wallTimeMs' };
256
254
  delete last.completion;
257
255
  }
258
- return { ...last, usage: aggregate, toolCalls, ...(sawTelemetry ? { telemetry } : {}) };
256
+ return bindRunTelemetry({ ...last, usage: aggregate, toolCalls }, telemetry);
259
257
  }
260
258
  function steeringBroadcast(source) {
261
259
  const log = [];
@@ -1,5 +1,15 @@
1
+ /**
2
+ * Legacy OUTSIDE-region product usage preference and plan rule (ADR 0021).
3
+ * This block is NEVER affirmative regional permission. Permission lives in privacy/ and must
4
+ * be resolved before interpreting this preference, hashing a subject or reading the plan cache.
5
+ * Protected/unknown Yes reports on every plan; No/pending reports on none. Only effective out
6
+ * delegates here, preserving the existing enabled/generation and named-Paid behavior exactly.
7
+ * Reports use a random installation ID; they must not be described as anonymous.
8
+ */
9
+ import type { MembershipTier } from './membership.js';
1
10
  import type { TelemetryPlan } from './telemetry/schema.js';
2
11
  export interface AnalyticsConfig {
12
+ /** The outside-region saved preference. Unset means on; this is not regional permission. */
3
13
  enabled?: boolean;
4
14
  generation?: number;
5
15
  }
@@ -7,7 +17,15 @@ export declare function validateAnalyticsConfig(analytics: unknown): void;
7
17
  export declare function resolveAnalyticsConfig(config: {
8
18
  analytics?: AnalyticsConfig;
9
19
  }): Required<AnalyticsConfig>;
10
- export declare function analyticsPlanFromMembership(tier: 'free' | 'legacy' | 'paid' | undefined, paid: boolean): TelemetryPlan;
20
+ /**
21
+ * Normalize a `/me` answer into the plan tier telemetry may trust.
22
+ *
23
+ * Only a named tier counts as confirmed. A server that reports `paid: true` without a tier cannot
24
+ * distinguish a paying account from a Legacy account covered by the promotion, so that answer is
25
+ * `unknown` — under the legacy outside-region rule it collects. A pre-tier server's `tier: "free", paid: true`
26
+ * is Legacy, the same normalization `membershipPlanLabel` applies.
27
+ */
28
+ export declare function analyticsPlanFromMembership(tier: MembershipTier | undefined, paid: boolean): TelemetryPlan;
11
29
  export declare function planCanOptOut(plan: TelemetryPlan): boolean;
12
30
  export declare function feedbackAllowed(preferenceOn: boolean | {
13
31
  analytics?: AnalyticsConfig;
@@ -14,8 +14,16 @@ export function resolveAnalyticsConfig(config) {
14
14
  validateAnalyticsConfig(analytics);
15
15
  return { enabled: true, generation: 0, ...analytics };
16
16
  }
17
+ /**
18
+ * Normalize a `/me` answer into the plan tier telemetry may trust.
19
+ *
20
+ * Only a named tier counts as confirmed. A server that reports `paid: true` without a tier cannot
21
+ * distinguish a paying account from a Legacy account covered by the promotion, so that answer is
22
+ * `unknown` — under the legacy outside-region rule it collects. A pre-tier server's `tier: "free", paid: true`
23
+ * is Legacy, the same normalization `membershipPlanLabel` applies.
24
+ */
17
25
  export function analyticsPlanFromMembership(tier, paid) {
18
- if (tier === 'paid')
26
+ if (tier === 'paid' || tier === 'plus' || tier === 'ultra' || tier === 'max')
19
27
  return 'paid';
20
28
  if (tier === 'legacy')
21
29
  return 'legacy';
@@ -1,6 +1,7 @@
1
1
  import { reconcileSubagentPair } from '../config.js';
2
2
  import { applyModelContextWindow, MAX_MODEL_DISPLAY_NAME_LENGTH, modelDisplayName } from '../providers.js';
3
3
  import { ANDORRA_PROVIDER_BASE_URL } from './endpoint.js';
4
+ import { withDetectedLevels } from '../thinking-levels.js';
4
5
  const ANDORRA_ID = 'andorra';
5
6
  const ANDORRA_NAME = 'Andorra';
6
7
  export function hasAndorraEntry(config) {
@@ -82,21 +83,29 @@ export function applyAndorraEntry(config, answer, mode) {
82
83
  ...(Object.keys(modelParameters).length ? { modelParameters } : {}), ...(freeModels.length ? { freeModels } : {}),
83
84
  ...(textOnlyModels.length ? { textOnlyModels } : {}) };
84
85
  const index = config.providers.findIndex(provider => provider.type === 'andorra');
85
- if (index < 0) {
86
+ const existing = config.providers[index];
87
+ // The catalog owns hosted capabilities. Retain switches on levels the router still supports.
88
+ const thinkingLevels = Object.fromEntries(answer.models.flatMap(({ id, reasoningLevels }) => {
89
+ if (reasoningLevels === undefined || UNSAFE_KEYS.includes(id))
90
+ return [];
91
+ return [[id, withDetectedLevels({ thinkingLevels: existing?.thinkingLevels }, id, reasoningLevels).thinkingLevels[id]]];
92
+ }));
93
+ const reasoning = Object.keys(thinkingLevels).length ? { thinkingLevels } : {};
94
+ if (!existing) {
86
95
  if (mode !== 'create')
87
96
  return undefined;
88
97
  const entry = { id: freeId(config.providers), type: 'andorra', name: ANDORRA_NAME, baseUrl: ANDORRA_PROVIDER_BASE_URL,
89
- model: models[0], models, modelContextWindows, ...named };
98
+ model: models[0], models, modelContextWindows, ...named, ...reasoning };
90
99
  return { ...config, providers: [entry, ...config.providers], provider: config.providers.length === 0 ? entry.id : config.provider };
91
100
  }
92
- const existing = config.providers[index];
93
101
  const model = models.includes(existing.model) ? existing.model : models[0];
94
102
  if (model === existing.model && sameList(existing.models, models) && sameWindows(existing.modelContextWindows, modelContextWindows)
95
103
  && sameNames(existing.modelNames, modelNames) && sameNumbers(existing.modelParameters, modelParameters)
96
- && sameList(existing.freeModels ?? [], freeModels) && sameList(existing.textOnlyModels ?? [], textOnlyModels))
104
+ && sameList(existing.freeModels ?? [], freeModels) && sameList(existing.textOnlyModels ?? [], textOnlyModels)
105
+ && JSON.stringify(existing.thinkingLevels ?? {}) === JSON.stringify(thinkingLevels))
97
106
  return undefined;
98
- const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, textOnlyModels: _textOnly, ...rest } = existing;
99
- const refreshed = { ...rest, model, models, modelContextWindows, ...named };
107
+ const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, textOnlyModels: _textOnly, thinkingLevels: _reasoning, ...rest } = existing;
108
+ const refreshed = { ...rest, model, models, modelContextWindows, ...named, ...reasoning };
100
109
  if (refreshed.contextWindow !== undefined)
101
110
  applyModelContextWindow(refreshed, model);
102
111
  const providers = config.providers.slice();
@@ -35,5 +35,8 @@ export function andorraRefusal(status, body, retryAfter) {
35
35
  const seconds = retrySeconds(retryAfter);
36
36
  return `Andorra is busy. Try again in ${seconds === undefined ? 'a moment' : `${seconds} second${seconds === 1 ? '' : 's'}`}.`;
37
37
  }
38
+ if (status === 429 && code === 'stream_limit_reached') {
39
+ return 'You are running your limit of concurrent requests. Finish one before starting another.';
40
+ }
38
41
  return undefined;
39
42
  }
@@ -1,3 +1,4 @@
1
+ import { type ReasoningEffort } from '../providers.js';
1
2
  /** `parametersBillions`: the model's size, where the router states one. `free`: served past the weekly allowance. `imageInput: false`: text-only, never sent images. */
2
3
  export interface HostedModel {
3
4
  id: string;
@@ -6,18 +7,25 @@ export interface HostedModel {
6
7
  parametersBillions?: number;
7
8
  free?: boolean;
8
9
  imageInput?: false;
10
+ reasoningLevels?: ReasoningEffort[];
9
11
  }
10
12
  /** How much of the account's weekly allowance is used (0-100) and when it renews (ISO timestamp). */
11
13
  export interface HostedAllowance {
12
14
  usedPercent: number;
13
15
  resetsAt: string;
14
16
  }
17
+ /** The account's limit of chat requests running at once (null: no limit) and how many it has running at the router now. */
18
+ export interface HostedStreams {
19
+ limit: number | null;
20
+ running: number;
21
+ }
15
22
  export interface HostedAnswer {
16
23
  enabled: boolean;
17
24
  promotionId: string | null;
18
25
  models: HostedModel[];
19
26
  allowance?: HostedAllowance;
20
27
  available?: boolean;
28
+ streams?: HostedStreams;
21
29
  }
22
30
  export type HostedCheck = {
23
31
  kind: 'answer';
@@ -1,4 +1,4 @@
1
- import { isModelParameters } from '../providers.js';
1
+ import { isModelParameters, REASONING_EFFORTS } from '../providers.js';
2
2
  import { ANDORRA_PROVIDER_BASE_URL, ANDORRA_SIGN_IN_MESSAGE, ANDORRA_UNAVAILABLE_MESSAGE, andorraAccessToken, andorraBaseUrl } from './endpoint.js';
3
3
  export const HOSTED_CHECK_TIMEOUT_MS = 5_000;
4
4
  const HOSTED_BODY_LIMIT = 64 * 1024;
@@ -21,11 +21,15 @@ export function parseHostedAnswer(value) {
21
21
  if (typeof item.contextWindow !== 'number' || !Number.isSafeInteger(item.contextWindow) || item.contextWindow <= 0)
22
22
  return undefined;
23
23
  const name = typeof item.name === 'string' && item.name ? item.name : item.id;
24
- // Both are optional and descriptive: a malformed one is dropped on its own and never fails the answer.
24
+ // An empty list records a completed probe. An unavailable or malformed list is omitted.
25
+ const raw = item.reasoningLevels;
26
+ const reasoningLevels = Array.isArray(raw) && raw.every(level => REASONING_EFFORTS.includes(level))
27
+ ? REASONING_EFFORTS.filter(level => raw.includes(level)) : undefined;
25
28
  models.push({ id: item.id, name, contextWindow: item.contextWindow,
26
29
  ...(isModelParameters(item.parametersBillions) ? { parametersBillions: item.parametersBillions } : {}),
27
30
  ...(item.free === true ? { free: true } : {}),
28
- ...(item.imageInput === false ? { imageInput: false } : {}) });
31
+ ...(item.imageInput === false ? { imageInput: false } : {}),
32
+ ...(reasoningLevels === undefined ? {} : { reasoningLevels }) });
29
33
  }
30
34
  const answer = { enabled: true, promotionId: body.promotionId, models };
31
35
  const allowance = parseAllowance(body.allowance);
@@ -33,8 +37,23 @@ export function parseHostedAnswer(value) {
33
37
  answer.allowance = allowance;
34
38
  if (typeof body.available === 'boolean')
35
39
  answer.available = body.available;
40
+ const streams = parseStreams(body.streams);
41
+ if (streams)
42
+ answer.streams = streams;
36
43
  return answer;
37
44
  }
45
+ /** Malformed streams are dropped on their own, as a malformed allowance is; an older router sends none. */
46
+ function parseStreams(value) {
47
+ const item = record(value);
48
+ if (!item)
49
+ return undefined;
50
+ const { limit, running } = item;
51
+ if (limit !== null && (typeof limit !== 'number' || !Number.isSafeInteger(limit) || limit < 1))
52
+ return undefined;
53
+ if (typeof running !== 'number' || !Number.isSafeInteger(running) || running < 0)
54
+ return undefined;
55
+ return { limit, running };
56
+ }
38
57
  /** A malformed allowance is dropped on its own; it never fails the whole answer. */
39
58
  function parseAllowance(value) {
40
59
  const item = record(value);
@@ -0,0 +1,49 @@
1
+ import { type HostedCheck } from './hosted.js';
2
+ export declare const ANDORRA_STREAMS_TOOL = "currentAndorraStreams";
3
+ export interface AndorraStreamHold {
4
+ /** `onAndorra` is asked each time the streams are counted, so a model change during the run is followed. */
5
+ watch(onAndorra: () => boolean): void;
6
+ release(): void;
7
+ /** Runs the agent's work so that the requests it sends count as this agent's own. */
8
+ run<T>(work: () => T): T;
9
+ }
10
+ /** One agent's place, taken when its run starts and given back when it ends. It counts only once it is watched. */
11
+ export declare function holdAndorraStream(): AndorraStreamHold;
12
+ /** Marks one request to the router as running; the returned function ends it, and only its first call counts. */
13
+ export declare function andorraRequestStarted(): () => void;
14
+ /**
15
+ * `agents`: the agents here on an Andorra model. `betweenRequests`: those of them with no request of their own
16
+ * running. `requests`: every request this process has running at the router, an agent's or not. `unownedRequests`:
17
+ * those of them that no agent sent.
18
+ */
19
+ export declare function localAndorraStreams(): {
20
+ agents: number;
21
+ betweenRequests: number;
22
+ requests: number;
23
+ unownedRequests: number;
24
+ };
25
+ export type AndorraStreamsReport =
26
+ /** `limit: null`: the account has no cap. `available` is absent then. */
27
+ {
28
+ status: 'ok';
29
+ limit: number | null;
30
+ inUse: number;
31
+ available?: number;
32
+ requestsRunning: number;
33
+ agentsHere: number;
34
+ agentsHereBetweenRequests: number;
35
+ message: string;
36
+ } | {
37
+ status: 'unknown';
38
+ agentsHere: number;
39
+ message: string;
40
+ } | {
41
+ status: 'signed_out' | 'unavailable';
42
+ message: string;
43
+ };
44
+ /**
45
+ * How many of the account's Andorra streams are taken and how many are free. The router's count of running
46
+ * requests covers every session and device of the account; the agents here that are between requests are added
47
+ * to it, because the router cannot see them. Agents between requests in another session are not counted.
48
+ */
49
+ export declare function currentAndorraStreams(check?: (signal?: AbortSignal) => Promise<HostedCheck>, signal?: AbortSignal): Promise<AndorraStreamsReport>;
@@ -0,0 +1,98 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { ANDORRA_SIGN_IN_MESSAGE, ANDORRA_UNAVAILABLE_MESSAGE } from './endpoint.js';
3
+ import { defaultHostedCheck } from './hosted.js';
4
+ export const ANDORRA_STREAMS_TOOL = 'currentAndorraStreams';
5
+ const holds = new Set();
6
+ /** The agent whose run the current code belongs to, so a request can be told apart from one no agent sent. */
7
+ const owner = new AsyncLocalStorage();
8
+ let requests = 0;
9
+ /** The running requests no agent sent. */
10
+ let unowned = 0;
11
+ /** One agent's place, taken when its run starts and given back when it ends. It counts only once it is watched. */
12
+ export function holdAndorraStream() {
13
+ const place = { requests: 0 };
14
+ return {
15
+ watch(onAndorra) {
16
+ place.onAndorra = onAndorra;
17
+ holds.add(place);
18
+ },
19
+ release() {
20
+ holds.delete(place);
21
+ delete place.onAndorra;
22
+ },
23
+ run: work => owner.run(place, work),
24
+ };
25
+ }
26
+ /** Marks one request to the router as running; the returned function ends it, and only its first call counts. */
27
+ export function andorraRequestStarted() {
28
+ // A request sent outside any agent's run (a session title, for one) is no agent's own: it takes a stream of its
29
+ // own at the router, and no agent here stops being between requests because of it.
30
+ const place = owner.getStore();
31
+ requests += 1;
32
+ if (place)
33
+ place.requests += 1;
34
+ else
35
+ unowned += 1;
36
+ let done = false;
37
+ return () => {
38
+ if (done)
39
+ return;
40
+ done = true;
41
+ requests -= 1;
42
+ if (place)
43
+ place.requests -= 1;
44
+ else
45
+ unowned -= 1;
46
+ };
47
+ }
48
+ /**
49
+ * `agents`: the agents here on an Andorra model. `betweenRequests`: those of them with no request of their own
50
+ * running. `requests`: every request this process has running at the router, an agent's or not. `unownedRequests`:
51
+ * those of them that no agent sent.
52
+ */
53
+ export function localAndorraStreams() {
54
+ let agents = 0, betweenRequests = 0;
55
+ for (const place of holds) {
56
+ if (!place.onAndorra?.())
57
+ continue;
58
+ agents += 1;
59
+ if (place.requests === 0)
60
+ betweenRequests += 1;
61
+ }
62
+ return { agents, betweenRequests, requests, unownedRequests: unowned };
63
+ }
64
+ const BETWEEN = 'An agent between requests (running a tool, waiting for a subagent) still holds its stream.';
65
+ /**
66
+ * How many of the account's Andorra streams are taken and how many are free. The router's count of running
67
+ * requests covers every session and device of the account; the agents here that are between requests are added
68
+ * to it, because the router cannot see them. Agents between requests in another session are not counted.
69
+ */
70
+ export async function currentAndorraStreams(check = defaultHostedCheck(), signal) {
71
+ const result = await check(signal).catch(() => ({ kind: 'failed' }));
72
+ signal?.throwIfAborted();
73
+ const here = localAndorraStreams();
74
+ if (result.kind === 'signed-out')
75
+ return { status: 'signed_out', message: ANDORRA_SIGN_IN_MESSAGE };
76
+ if (result.kind === 'answer' && !result.answer.enabled)
77
+ return { status: 'unavailable', message: ANDORRA_UNAVAILABLE_MESSAGE };
78
+ const streams = result.kind === 'answer' ? result.answer.streams : undefined;
79
+ if (!streams) {
80
+ return { status: 'unknown', agentsHere: here.agents,
81
+ message: `The stream limit could not be read. ${here.agents} agent${here.agents === 1 ? '' : 's'} in this session ${here.agents === 1 ? 'is' : 'are'} on an Andorra model. Start subagents on Andorra models one at a time.` };
82
+ }
83
+ // An agent's running request is in the router's count already; only the agents with none of their own are added.
84
+ const between = here.betweenRequests;
85
+ // This process alone holds a stream per agent and per request no agent sent. A request counts here from before
86
+ // it is sent, so the router's reading can miss one that is on its way; the count is never taken below that.
87
+ const inUse = Math.max(streams.running + between, here.agents + here.unownedRequests);
88
+ const shared = { requestsRunning: streams.running, agentsHere: here.agents, agentsHereBetweenRequests: between };
89
+ if (streams.limit === null) {
90
+ return { status: 'ok', limit: null, inUse, ...shared, message: `This account has no stream limit. ${inUse} in use.` };
91
+ }
92
+ const available = Math.max(0, streams.limit - inUse);
93
+ return { status: 'ok', limit: streams.limit, inUse, available, ...shared,
94
+ message: `${inUse} of ${streams.limit} Andorra streams are in use, and you are counted among them. ${BETWEEN} `
95
+ + (available === 0
96
+ ? 'None is free: do not start a subagent on an Andorra model until one finishes.'
97
+ : `Start at most ${available} more agent${available === 1 ? '' : 's'} on Andorra models at the same time.`) };
98
+ }
@@ -0,0 +1,28 @@
1
+ import { type PromptResponse, type RequestPermissionRequest, type SessionConfigOption, type SessionUpdate } from '@agentclientprotocol/sdk';
2
+ export interface AntigravitySessionOptions {
3
+ cwd: string;
4
+ signal?: AbortSignal;
5
+ version?: string;
6
+ onUpdate(update: SessionUpdate): void;
7
+ requestPermission(request: RequestPermissionRequest): Promise<string | undefined>;
8
+ onClosed?(message: string): void;
9
+ }
10
+ export declare class AntigravitySession {
11
+ readonly id: string;
12
+ private configs;
13
+ private connection;
14
+ private child;
15
+ private taskkill;
16
+ private prompting;
17
+ private cancelTimer?;
18
+ private stopping?;
19
+ private closing;
20
+ private constructor();
21
+ static start(options: AntigravitySessionOptions): Promise<AntigravitySession>;
22
+ get options(): SessionConfigOption[];
23
+ get isOpen(): boolean;
24
+ prompt(text: string): Promise<PromptResponse>;
25
+ cancel(): Promise<void>;
26
+ setOption(configId: string, value: string): Promise<SessionConfigOption[]>;
27
+ close(): Promise<void>;
28
+ }
@@ -0,0 +1,150 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { realpath, stat } from 'node:fs/promises';
3
+ import { resolve } from 'node:path';
4
+ import { Readable, Writable } from 'node:stream';
5
+ import { client, methods, ndJsonStream, PROTOCOL_VERSION, RequestError, } from '@agentclientprotocol/sdk';
6
+ import { resolveCliExecutable } from './cli-executable.js';
7
+ import { stopProcessTree } from './cli-process.js';
8
+ import { GOOGLE_EXECUTABLE, googleEnvironment } from './google-provider.js';
9
+ import { resolveTrustedTaskkill } from './shell.js';
10
+ const SIGN_IN = 'Sign in to Google with agy acp --login, then start a new Antigravity session.';
11
+ const DISCONNECTED = 'The Antigravity ACP process closed. Start a new session to continue.';
12
+ const START_TIMEOUT_MS = 30_000;
13
+ const CANCEL_TIMEOUT_MS = 5_000;
14
+ function sessionError(error) {
15
+ if (error instanceof RequestError && (error.code === -32000 || /authentication required/i.test(error.message))) {
16
+ return new Error(SIGN_IN, { cause: error });
17
+ }
18
+ return error;
19
+ }
20
+ export class AntigravitySession {
21
+ id;
22
+ configs;
23
+ connection;
24
+ child;
25
+ taskkill;
26
+ prompting = false;
27
+ cancelTimer;
28
+ stopping;
29
+ closing = false;
30
+ constructor(id, configs, connection, child, taskkill) {
31
+ this.id = id;
32
+ this.configs = configs;
33
+ this.connection = connection;
34
+ this.child = child;
35
+ this.taskkill = taskkill;
36
+ }
37
+ static async start(options) {
38
+ const { command, args } = await resolveCliExecutable(GOOGLE_EXECUTABLE);
39
+ const cwd = await realpath(resolve(options.cwd));
40
+ if (!(await stat(cwd)).isDirectory())
41
+ throw new Error('Choose a local project directory for Antigravity.');
42
+ const taskkill = process.platform === 'win32' ? await resolveTrustedTaskkill(cwd) : undefined;
43
+ const signal = AbortSignal.any([AbortSignal.timeout(START_TIMEOUT_MS), ...(options.signal ? [options.signal] : [])]);
44
+ signal.throwIfAborted();
45
+ const child = spawn(command, [...args, 'acp'], {
46
+ cwd, env: googleEnvironment(), stdio: 'pipe', windowsHide: true,
47
+ detached: process.platform !== 'win32',
48
+ });
49
+ child.stderr.resume();
50
+ let session;
51
+ const connection = client({ name: 'Andorra Code' })
52
+ .onNotification(methods.client.session.update, ({ params }) => {
53
+ if (!session || params.sessionId !== session.id || session.closing)
54
+ return;
55
+ if (params.update.sessionUpdate === 'config_option_update')
56
+ session.configs = params.update.configOptions;
57
+ options.onUpdate(params.update);
58
+ })
59
+ .onRequest(methods.client.session.requestPermission, async ({ params }) => {
60
+ if (!session || params.sessionId !== session.id || session.closing || !session.prompting || session.cancelTimer) {
61
+ return { outcome: { outcome: 'cancelled' } };
62
+ }
63
+ const optionId = await options.requestPermission(params).catch(() => undefined);
64
+ return optionId !== undefined && params.options.some(option => option.optionId === optionId)
65
+ ? { outcome: { outcome: 'selected', optionId } }
66
+ : { outcome: { outcome: 'cancelled' } };
67
+ })
68
+ .connect(ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout)));
69
+ child.on('error', error => connection.close(error));
70
+ child.stdin.on('error', error => connection.close(error));
71
+ try {
72
+ const initialized = await connection.agent.request(methods.agent.initialize, {
73
+ protocolVersion: PROTOCOL_VERSION,
74
+ clientInfo: { name: 'andorra-code', title: 'Andorra Code', version: options.version ?? 'unknown' },
75
+ clientCapabilities: {},
76
+ }, { cancellationSignal: signal, stopWaitingOnCancel: true });
77
+ if (initialized.protocolVersion !== PROTOCOL_VERSION)
78
+ throw new Error('This Antigravity CLI uses an incompatible ACP protocol. Update agy and try again.');
79
+ const created = await connection.agent.request(methods.agent.session.new, { cwd, mcpServers: [] }, { cancellationSignal: signal, stopWaitingOnCancel: true });
80
+ session = new AntigravitySession(created.sessionId, created.configOptions ?? [], connection, child, taskkill);
81
+ const active = session;
82
+ void connection.closed.then(async () => {
83
+ if (active.closing)
84
+ return;
85
+ try {
86
+ options.onClosed?.(DISCONNECTED);
87
+ }
88
+ finally {
89
+ await active.close();
90
+ }
91
+ }).catch(() => { });
92
+ return active;
93
+ }
94
+ catch (error) {
95
+ connection.close();
96
+ await stopProcessTree(child, taskkill);
97
+ if (signal.reason instanceof Error && signal.reason.name === 'TimeoutError') {
98
+ throw new Error('Antigravity ACP timed out during startup. Check that agy is up to date and signed in.');
99
+ }
100
+ throw sessionError(error);
101
+ }
102
+ }
103
+ get options() { return this.configs; }
104
+ get isOpen() { return !this.closing && !this.connection.signal.aborted; }
105
+ async prompt(text) {
106
+ if (this.prompting)
107
+ throw new Error('Antigravity is already processing a prompt.');
108
+ if (!this.isOpen)
109
+ throw new Error(DISCONNECTED);
110
+ this.prompting = true;
111
+ try {
112
+ return await this.connection.agent.request(methods.agent.session.prompt, {
113
+ sessionId: this.id, prompt: [{ type: 'text', text }],
114
+ });
115
+ }
116
+ catch (error) {
117
+ throw sessionError(error);
118
+ }
119
+ finally {
120
+ this.prompting = false;
121
+ clearTimeout(this.cancelTimer);
122
+ this.cancelTimer = undefined;
123
+ }
124
+ }
125
+ async cancel() {
126
+ if (!this.prompting || this.cancelTimer || this.closing)
127
+ return;
128
+ this.cancelTimer = setTimeout(() => {
129
+ this.connection.close(new Error('Antigravity did not finish cancellation. Start a new session to continue.'));
130
+ }, CANCEL_TIMEOUT_MS);
131
+ this.cancelTimer.unref();
132
+ await this.connection.agent.notify(methods.agent.session.cancel, { sessionId: this.id });
133
+ }
134
+ async setOption(configId, value) {
135
+ if (this.prompting)
136
+ throw new Error('Wait for the current Antigravity turn to finish before changing options.');
137
+ if (!this.isOpen)
138
+ throw new Error(DISCONNECTED);
139
+ const result = await this.connection.agent.request(methods.agent.session.setConfigOption, {
140
+ sessionId: this.id, configId, value,
141
+ }, { cancellationSignal: AbortSignal.timeout(START_TIMEOUT_MS), stopWaitingOnCancel: true });
142
+ return this.configs = result.configOptions;
143
+ }
144
+ close() {
145
+ this.closing = true;
146
+ clearTimeout(this.cancelTimer);
147
+ this.connection.close();
148
+ return this.stopping ??= stopProcessTree(this.child, this.taskkill);
149
+ }
150
+ }
@@ -0,0 +1,2 @@
1
+ import type { TerminalUI } from './terminal-ui.js';
2
+ export declare function runAntigravityTerminal(terminal: TerminalUI, cwd: string, controller: AbortController, setInterrupt: (handler: (() => void) | undefined) => void): Promise<void>;