@andorra-labs/code 0.1.15 → 0.1.17

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 (242) hide show
  1. package/dist/src/acp-agent.d.ts +6 -0
  2. package/dist/src/acp-agent.js +15 -4
  3. package/dist/src/agent-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +15 -10
  5. package/dist/src/agent-mcp-catalog.js +1 -0
  6. package/dist/src/agent-mcp.d.ts +4 -1
  7. package/dist/src/agent-mcp.js +46 -10
  8. package/dist/src/andorra/entry.d.ts +10 -0
  9. package/dist/src/andorra/entry.js +18 -4
  10. package/dist/src/andorra/hosted.d.ts +2 -1
  11. package/dist/src/andorra/hosted.js +2 -1
  12. package/dist/src/andorra/notices.d.ts +5 -0
  13. package/dist/src/andorra/notices.js +7 -0
  14. package/dist/src/andorra/state.d.ts +3 -2
  15. package/dist/src/andorra/state.js +4 -4
  16. package/dist/src/andorra/terminal.js +7 -2
  17. package/dist/src/anthropic-credentials.js +2 -0
  18. package/dist/src/app-server/error.d.ts +5 -0
  19. package/dist/src/app-server/error.js +7 -0
  20. package/dist/src/app-server/protocol.d.ts +22 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +89 -0
  23. package/dist/src/app-server/workspace.js +457 -11
  24. package/dist/src/app-server.d.ts +465 -32
  25. package/dist/src/app-server.js +3308 -517
  26. package/dist/src/auth/deployment.js +2 -2
  27. package/dist/src/bridge/cloud.d.ts +27 -0
  28. package/dist/src/bridge/cloud.js +187 -0
  29. package/dist/src/bridge/command.d.ts +30 -0
  30. package/dist/src/bridge/command.js +347 -0
  31. package/dist/src/bridge/control.d.ts +68 -0
  32. package/dist/src/bridge/control.js +233 -0
  33. package/dist/src/bridge/engines.d.ts +90 -0
  34. package/dist/src/bridge/engines.js +601 -0
  35. package/dist/src/bridge/host-ops.d.ts +9 -0
  36. package/dist/src/bridge/host-ops.js +129 -0
  37. package/dist/src/bridge/host.d.ts +47 -0
  38. package/dist/src/bridge/host.js +540 -0
  39. package/dist/src/bridge/link.d.ts +38 -0
  40. package/dist/src/bridge/link.js +508 -0
  41. package/dist/src/bridge/login-link.d.ts +29 -0
  42. package/dist/src/bridge/login-link.js +54 -0
  43. package/dist/src/bridge/protocol.d.ts +136 -0
  44. package/dist/src/bridge/protocol.js +11 -0
  45. package/dist/src/bridge/store.d.ts +12 -0
  46. package/dist/src/bridge/store.js +61 -0
  47. package/dist/src/bridge/wording.d.ts +6 -0
  48. package/dist/src/bridge/wording.js +10 -0
  49. package/dist/src/browser-runner.js +1 -0
  50. package/dist/src/browser-server.js +7 -1
  51. package/dist/src/browser-ui/style.css +3 -3
  52. package/dist/src/browser-ui/tokens.css +28 -17
  53. package/dist/src/change-authors.d.ts +41 -0
  54. package/dist/src/change-authors.js +146 -0
  55. package/dist/src/claude-provider.js +3 -1
  56. package/dist/src/cli.js +202 -38
  57. package/dist/src/codex-errors.js +4 -1
  58. package/dist/src/coding-tools.js +15 -15
  59. package/dist/src/command-screens.d.ts +6 -0
  60. package/dist/src/command-screens.js +19 -14
  61. package/dist/src/commands.d.ts +14 -1
  62. package/dist/src/compaction-phrases.d.ts +4 -0
  63. package/dist/src/compaction-phrases.js +20 -0
  64. package/dist/src/completion.js +82 -5
  65. package/dist/src/config.d.ts +71 -3
  66. package/dist/src/config.js +202 -77
  67. package/dist/src/context-compaction.js +2 -1
  68. package/dist/src/deadline.js +13 -1
  69. package/dist/src/decision/DecisionManager.js +3 -2
  70. package/dist/src/decision/checks.js +1 -1
  71. package/dist/src/decision/requestPhrases.d.ts +4 -0
  72. package/dist/src/decision/requestPhrases.js +22 -0
  73. package/dist/src/default-graph.js +1 -1
  74. package/dist/src/file-diff.d.ts +4 -0
  75. package/dist/src/file-diff.js +2 -1
  76. package/dist/src/github-app/agent-writes.d.ts +102 -0
  77. package/dist/src/github-app/agent-writes.js +320 -0
  78. package/dist/src/github-app/client.d.ts +349 -0
  79. package/dist/src/github-app/client.js +810 -0
  80. package/dist/src/github-app/event-source.d.ts +208 -0
  81. package/dist/src/github-app/event-source.js +684 -0
  82. package/dist/src/github-app/metrics.d.ts +32 -0
  83. package/dist/src/github-app/metrics.js +49 -0
  84. package/dist/src/github-app/review-loop.d.ts +274 -0
  85. package/dist/src/github-app/review-loop.js +1177 -0
  86. package/dist/src/github-app/review-node.d.ts +81 -0
  87. package/dist/src/github-app/review-node.js +205 -0
  88. package/dist/src/github-app/review-post.d.ts +73 -0
  89. package/dist/src/github-app/review-post.js +139 -0
  90. package/dist/src/github-app/review-text.d.ts +107 -0
  91. package/dist/src/github-app/review-text.js +1133 -0
  92. package/dist/src/github-app/review-threads.d.ts +47 -0
  93. package/dist/src/github-app/review-threads.js +107 -0
  94. package/dist/src/github-app/reviewer.d.ts +121 -0
  95. package/dist/src/github-app/reviewer.js +598 -0
  96. package/dist/src/github-app/store.d.ts +59 -0
  97. package/dist/src/github-app/store.js +148 -0
  98. package/dist/src/github-app/triggers.d.ts +141 -0
  99. package/dist/src/github-app/triggers.js +441 -0
  100. package/dist/src/github-inbox.d.ts +55 -0
  101. package/dist/src/github-inbox.js +153 -0
  102. package/dist/src/github-names.d.ts +8 -0
  103. package/dist/src/github-names.js +8 -0
  104. package/dist/src/glob-search.d.ts +61 -0
  105. package/dist/src/glob-search.js +180 -0
  106. package/dist/src/graph-health.js +13 -4
  107. package/dist/src/graph-manager-chat.js +1 -1
  108. package/dist/src/graph-preview.d.ts +46 -0
  109. package/dist/src/graph-preview.js +55 -0
  110. package/dist/src/graph-provider-portability.js +34 -11
  111. package/dist/src/graph-quota.d.ts +29 -2
  112. package/dist/src/graph-quota.js +68 -10
  113. package/dist/src/graph-runner.js +88 -10
  114. package/dist/src/graph-server.d.ts +1 -1
  115. package/dist/src/graph-server.js +11 -9
  116. package/dist/src/graph-sync.js +3 -3
  117. package/dist/src/graph-ui/app.js +201 -40
  118. package/dist/src/graph-ui/controls.css +1 -0
  119. package/dist/src/graph-ui/embed.js +2 -2
  120. package/dist/src/graph-ui/icons.js +3 -1
  121. package/dist/src/graph-ui/index.html +1 -1
  122. package/dist/src/graph-ui/manager.css +1 -1
  123. package/dist/src/graph-ui/manager.js +2 -2
  124. package/dist/src/graph-ui/sidebar.js +30 -0
  125. package/dist/src/graph-ui/studio-canvas.js +26 -13
  126. package/dist/src/graph-ui/studio.css +15 -7
  127. package/dist/src/graph-ui/studio.js +26 -5
  128. package/dist/src/graph-ui/style.css +77 -45
  129. package/dist/src/graph-ui/theme.js +3 -36
  130. package/dist/src/graph-ui/tokens.css +28 -20
  131. package/dist/src/graphs.d.ts +34 -1
  132. package/dist/src/graphs.js +162 -17
  133. package/dist/src/image-input.d.ts +16 -0
  134. package/dist/src/image-input.js +41 -0
  135. package/dist/src/membership.d.ts +30 -1
  136. package/dist/src/membership.js +48 -8
  137. package/dist/src/model-health-cache.js +1 -1
  138. package/dist/src/model-metadata.d.ts +7 -1
  139. package/dist/src/model-metadata.js +39 -17
  140. package/dist/src/model-relay/local.d.ts +116 -0
  141. package/dist/src/model-relay/local.js +468 -0
  142. package/dist/src/model-relay/remote.d.ts +129 -0
  143. package/dist/src/model-relay/remote.js +252 -0
  144. package/dist/src/model-relay/runs.d.ts +34 -0
  145. package/dist/src/model-relay/runs.js +146 -0
  146. package/dist/src/model-relay/wire.d.ts +5 -0
  147. package/dist/src/model-relay/wire.js +5 -0
  148. package/dist/src/plan-pass.d.ts +59 -0
  149. package/dist/src/plan-pass.js +165 -0
  150. package/dist/src/project-registry.d.ts +21 -0
  151. package/dist/src/project-registry.js +74 -0
  152. package/dist/src/provider-engine.js +3 -0
  153. package/dist/src/provider-import.d.ts +0 -12
  154. package/dist/src/provider-import.js +7 -195
  155. package/dist/src/providers.d.ts +40 -2
  156. package/dist/src/providers.js +93 -23
  157. package/dist/src/pull-request-checks.d.ts +26 -0
  158. package/dist/src/pull-request-checks.js +56 -0
  159. package/dist/src/pull-request-conversation.d.ts +134 -0
  160. package/dist/src/pull-request-conversation.js +221 -0
  161. package/dist/src/pull-request-create.d.ts +175 -0
  162. package/dist/src/pull-request-create.js +392 -0
  163. package/dist/src/pull-request-details.d.ts +242 -0
  164. package/dist/src/pull-request-details.js +614 -0
  165. package/dist/src/pull-request-edit.d.ts +23 -0
  166. package/dist/src/pull-request-edit.js +91 -0
  167. package/dist/src/pull-request-logs.d.ts +87 -0
  168. package/dist/src/pull-request-logs.js +183 -0
  169. package/dist/src/pull-request-merge.d.ts +112 -0
  170. package/dist/src/pull-request-merge.js +258 -0
  171. package/dist/src/pull-request-review.d.ts +137 -0
  172. package/dist/src/pull-request-review.js +401 -0
  173. package/dist/src/pull-requests.d.ts +369 -8
  174. package/dist/src/pull-requests.js +524 -55
  175. package/dist/src/react-runtime.js +38 -5
  176. package/dist/src/remote/engine-pool.d.ts +88 -4
  177. package/dist/src/remote/engine-pool.js +379 -90
  178. package/dist/src/remote/roots.d.ts +19 -0
  179. package/dist/src/remote/roots.js +45 -7
  180. package/dist/src/remote/types.d.ts +0 -44
  181. package/dist/src/run-control.d.ts +17 -0
  182. package/dist/src/run-control.js +47 -0
  183. package/dist/src/run-progress.d.ts +10 -0
  184. package/dist/src/run-progress.js +122 -0
  185. package/dist/src/run-records.d.ts +7 -2
  186. package/dist/src/run-records.js +71 -6
  187. package/dist/src/runtime.d.ts +9 -1
  188. package/dist/src/runtime.js +24 -4
  189. package/dist/src/session-changes.d.ts +35 -0
  190. package/dist/src/session-changes.js +194 -6
  191. package/dist/src/session-monitor.js +2 -1
  192. package/dist/src/session-reaper.d.ts +1 -1
  193. package/dist/src/session-reaper.js +6 -1
  194. package/dist/src/session-summary.d.ts +2 -1
  195. package/dist/src/session-summary.js +2 -1
  196. package/dist/src/sessions.d.ts +11 -1
  197. package/dist/src/sessions.js +17 -4
  198. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  199. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  200. package/dist/src/skills/bundled/provenance.json +2 -2
  201. package/dist/src/skills/runtime-skills.js +1 -1
  202. package/dist/src/subagent-run.js +1 -0
  203. package/dist/src/telemetry/capture-core.d.ts +17 -0
  204. package/dist/src/telemetry/capture-core.js +59 -1
  205. package/dist/src/telemetry/classify.d.ts +3 -1
  206. package/dist/src/telemetry/classify.js +37 -0
  207. package/dist/src/telemetry/emitter.d.ts +17 -0
  208. package/dist/src/telemetry/emitter.js +76 -5
  209. package/dist/src/telemetry/schema.d.ts +47 -2
  210. package/dist/src/telemetry/schema.js +120 -5
  211. package/dist/src/telemetry/surface.d.ts +3 -1
  212. package/dist/src/telemetry/surface.js +4 -1
  213. package/dist/src/telemetry/uploader.d.ts +6 -1
  214. package/dist/src/telemetry/uploader.js +22 -3
  215. package/dist/src/terminal-ui.d.ts +1 -0
  216. package/dist/src/terminal-ui.js +10 -3
  217. package/dist/src/test-edit-guard.d.ts +7 -0
  218. package/dist/src/test-edit-guard.js +49 -1
  219. package/dist/src/timers.d.ts +2 -0
  220. package/dist/src/tools.js +59 -9
  221. package/dist/src/transcript.js +8 -2
  222. package/dist/src/types.d.ts +7 -0
  223. package/dist/src/usage-analytics.js +18 -10
  224. package/package.json +6 -1
  225. package/dist/src/remote/cert.d.ts +0 -11
  226. package/dist/src/remote/cert.js +0 -87
  227. package/dist/src/remote/client.d.ts +0 -119
  228. package/dist/src/remote/client.js +0 -544
  229. package/dist/src/remote/command.d.ts +0 -4
  230. package/dist/src/remote/command.js +0 -194
  231. package/dist/src/remote/errors.d.ts +0 -11
  232. package/dist/src/remote/errors.js +0 -14
  233. package/dist/src/remote/network.d.ts +0 -22
  234. package/dist/src/remote/network.js +0 -102
  235. package/dist/src/remote/pairing.d.ts +0 -63
  236. package/dist/src/remote/pairing.js +0 -299
  237. package/dist/src/remote/pem.d.ts +0 -2
  238. package/dist/src/remote/pem.js +0 -7
  239. package/dist/src/remote/serve.d.ts +0 -68
  240. package/dist/src/remote/serve.js +0 -244
  241. package/dist/src/remote/server.d.ts +0 -21
  242. package/dist/src/remote/server.js +0 -406
@@ -4,12 +4,11 @@ import { PERMISSION_OPTIONS } from './permissions.js';
4
4
  import { editProviderSettings } from './provider-settings.js';
5
5
  import { retireRemovedCodexAccounts, retireUnsavedCodexAccounts } from './codex-auth.js';
6
6
  import { droppedAnthropicAccounts, retireAnthropicAccounts } from './anthropic-console-auth.js';
7
- import { importProvidersFromRemote } from './provider-import.js';
8
7
  import { DEFAULT_GRAPH, listGraphs, withoutDeletedGraphs } from './graphs.js';
9
8
  import { graphStorageDirectory } from './graph-account.js';
10
9
  import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
11
10
  import { getMembership, loadAccessibleGraph, requireGraphMembership } from './membership.js';
12
- import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_LIMIT_MESSAGE, readGraphQuota } from './graph-quota.js';
11
+ import { FREE_GRAPH_LIMIT_MESSAGE, freeTierGraphViolation, readGraphQuota } from './graph-quota.js';
13
12
  import { GraphProviderUnavailableError } from './graph-provider-portability.js';
14
13
  import { confirmAndApplyModelOverride } from './model-override.js';
15
14
  import { andorraRefusal } from './commands.js';
@@ -44,6 +43,14 @@ export function isScreenCommand(line) {
44
43
  return ['/model', '/providers', '/graph', '/usage', '/permissions', '/skills', '/plugins', '/mcp', '/subagent'].includes(line.trim());
45
44
  }
46
45
  const CLEAR_SUBAGENT_SELECTION = '*clear*';
46
+ /** Signs out and removes the Codex and Claude Console accounts of providers `next` no longer has. */
47
+ export async function retireDroppedAccounts(previous, next, signal) {
48
+ await retireRemovedCodexAccounts(previous, next, signal ? { signal } : {}).catch(() => { });
49
+ await retireAnthropicAccounts(droppedAnthropicAccounts(previous, next)).catch(() => { });
50
+ }
51
+ /** Thrown by a live persist when the change it carried was refused, so the enclosing save keeps the old config. */
52
+ export class SelectionReverted extends Error {
53
+ }
47
54
  export async function runCommandScreen(line, state, ui, persist, signal, adapterFactory = createAdapter, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership, membership: getMembership }, openGraphBuilder, graphSubject = currentGraphSubject) {
48
55
  const unchanged = { clear: false };
49
56
  if (!isScreenCommand(line) || signal.aborted)
@@ -60,7 +67,11 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
60
67
  try {
61
68
  await (removesAndorra ? removingAndorraEntry(configDirectory(), () => persist(reconciled)) : persist(reconciled));
62
69
  }
63
- catch {
70
+ catch (error) {
71
+ // The live persist refused the change it carried (a provider the run could not move to): nothing was
72
+ // saved, so the configuration in memory stays as it was instead of taking the rejected draft.
73
+ if (error instanceof SelectionReverted)
74
+ return unchanged;
64
75
  await retireUnsavedCodexAccounts(reconciled.providers, state.config.providers, { signal });
65
76
  await retireAnthropicAccounts(droppedAnthropicAccounts(reconciled.providers, state.config.providers)).catch(() => { });
66
77
  if (!signal.aborted)
@@ -73,8 +84,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
73
84
  Object.assign(state.config, reconciled);
74
85
  if (removesAndorra)
75
86
  await state.andorra?.entryChanged?.();
76
- await retireRemovedCodexAccounts(previousProviders, reconciled.providers, { signal }).catch(() => { });
77
- await retireAnthropicAccounts(droppedAnthropicAccounts(previousProviders, reconciled.providers)).catch(() => { });
87
+ await (state.retireAccounts ?? retireDroppedAccounts)(previousProviders, reconciled.providers, signal).catch(() => { });
78
88
  if (reconciled.externalSubagent === undefined)
79
89
  delete state.config.externalSubagent;
80
90
  return { clear: true };
@@ -245,7 +255,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
245
255
  return { id: item.id, label: providerLabel(item, state.config.providers), ...(refusal ? { description: refusal } : {}) };
246
256
  }),
247
257
  { id: ':add', label: '+ Add provider' },
248
- { id: ':import', label: 'Import from remote connection' },
249
258
  ];
250
259
  };
251
260
  while (!signal.aborted) {
@@ -278,12 +287,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
278
287
  draft.provider = id;
279
288
  return await save(draft);
280
289
  }
281
- if (selected === ':import') {
282
- const draft = await importProvidersFromRemote(state.config, ui, signal);
283
- if (draft)
284
- return await save(draft);
285
- continue;
286
- }
287
290
  if (selected === ':add' || selected.startsWith(':edit:')) {
288
291
  const id = selected === ':add' ? undefined : selected.slice(6);
289
292
  if (id && !state.config.providers.some(item => item.id === id))
@@ -317,12 +320,14 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
317
320
  return unchanged;
318
321
  const access = await graphAccess.membership?.(signal);
319
322
  const free = access !== undefined && !access.paid && !access.unavailable && access.subject !== undefined;
320
- const atLimit = free && (await readGraphQuota(directory, saved)).customGraphs >= FREE_CUSTOM_GRAPH_LIMIT;
323
+ const kept = free ? (await readGraphQuota(directory, saved, { adopt: true })).freeGraphId : undefined;
324
+ const atLimit = free && kept !== undefined;
325
+ const viewOnly = (graph) => free && (graph.id !== kept || freeTierGraphViolation(graph) !== undefined);
321
326
  const items = [{
322
327
  id: DEFAULT_GRAPH.id,
323
328
  label: 'Default',
324
329
  description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
325
- }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
330
+ }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: viewOnly(graph) ? 'View only on the free tier. Duplicate it in the Graph Editor to change it.' : 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
326
331
  while (!signal.aborted) {
327
332
  const selected = await ui.select('Graph', items, { selectedId: state.graph ?? DEFAULT_GRAPH.id, description: 'Choose and save your default graph for this account, or create one in the web builder. After saving, reopen /graph to select it.', signal });
328
333
  if (selected === undefined || signal.aborted)
@@ -32,6 +32,11 @@ export interface CommandState {
32
32
  goal?: SessionGoal;
33
33
  jev?: boolean;
34
34
  andorra?: TerminalAndorraHooks;
35
+ /**
36
+ * Retires the sign-ins of providers a saved change dropped. Unset, a manager retires them at once; a run that is
37
+ * still working sets it to defer retirement until it ends, since its requests still read those credentials.
38
+ */
39
+ retireAccounts?: (previous: readonly import('./providers.js').ProviderConfig[], next: readonly import('./providers.js').ProviderConfig[], signal?: AbortSignal) => Promise<void>;
35
40
  }
36
41
  /** The message refusing a switch to this provider, or undefined when it may be selected. An absent `state.andorra` counts as available. */
37
42
  export declare function andorraRefusal(state: Pick<CommandState, 'andorra' | 'config'>, providerId: string): string | undefined;
@@ -49,18 +54,26 @@ export interface ConversationTurn {
49
54
  task: string;
50
55
  completion: Completion;
51
56
  runId?: string;
57
+ /** Given to the agent with the task but not shown with it (`run.note`), such as the person's hand edits. */
58
+ note?: string;
52
59
  resumed?: boolean;
53
60
  direction?: string;
54
61
  attachments?: import('./attachments.js').UserAttachmentRef[];
55
62
  wake?: TurnWake;
56
63
  steers?: {
57
64
  text: string;
65
+ note?: string;
58
66
  attachments?: import('./attachments.js').UserAttachmentRef[];
59
67
  wake?: TurnWake;
60
68
  subagentId?: string;
61
69
  }[];
62
70
  }
63
- export type TurnWake = 'timer' | 'auto-fix';
71
+ /**
72
+ * Why a turn started without the person typing it: a timer the agent set, Auto-fix, the PR tab's Fix with Agent,
73
+ * the person mentioning the App's bot on the task's PR (`mention`), or the Andorra review loop handing its findings to the
74
+ * task that owns the PR (`andorra-review`).
75
+ */
76
+ export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
64
77
  export declare function compactHistory(turns: ConversationTurn[]): ConversationTurn[];
65
78
  export declare function compactedContextEstimate(turns: ConversationTurn[]): number;
66
79
  export declare function subagentClearRequested(line: string, providers: {
@@ -0,0 +1,4 @@
1
+ export declare const COMPACTION_DEFAULT_TEXT = "Summarizing earlier work to free context.";
2
+ export declare const COMPACTION_PHRASES: readonly string[];
3
+ export declare function pickCompactionPhrase(random?: () => number): string;
4
+ export declare function compactionText(text: unknown): string;
@@ -0,0 +1,20 @@
1
+ // What the transcript says while earlier work is summarized to free context. The engine picks one per
2
+ // compaction batch and carries it on `agent.context.compaction.started` as `text`, so the CLI and the
3
+ // desktop show the same line; the plain description stays available as the default.
4
+ export const COMPACTION_DEFAULT_TEXT = 'Summarizing earlier work to free context.';
5
+ export const COMPACTION_PHRASES = [
6
+ 'Vacuum-sealing the conversation',
7
+ 'Writing the CliffsNotes of this chat',
8
+ 'Stuffing memories into a carry-on',
9
+ 'Shrink-wrapping the context',
10
+ 'Condensing the chat like canned soup',
11
+ 'Turning the context into a sticky note',
12
+ ];
13
+ export function pickCompactionPhrase(random = Math.random) {
14
+ const index = Math.floor(random() * COMPACTION_PHRASES.length);
15
+ return COMPACTION_PHRASES[Math.min(Math.max(index, 0), COMPACTION_PHRASES.length - 1)] ?? COMPACTION_DEFAULT_TEXT;
16
+ }
17
+ // Only a phrase from the list is shown, with an ellipsis; anything else falls back to the default line.
18
+ export function compactionText(text) {
19
+ return typeof text === 'string' && COMPACTION_PHRASES.includes(text) ? `${text}…` : COMPACTION_DEFAULT_TEXT;
20
+ }
@@ -395,6 +395,74 @@ function splitFusedArguments(envelope, notes) {
395
395
  }
396
396
  }
397
397
  const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts)"\s*:/;
398
+ const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining'];
399
+ const RAW_CONTROL = { '\n': '\\n', '\r': '\\r', '\t': '\\t' };
400
+ function emptyField(value) {
401
+ if (value === undefined || value === null)
402
+ return true;
403
+ if (Array.isArray(value))
404
+ return value.length === 0;
405
+ return typeof value === 'object' && Object.keys(value).length === 0;
406
+ }
407
+ const JSON_ESCAPE = /\\(["\\/bfnrt]|u[0-9a-fA-F]{4})/g;
408
+ const JSON_ESCAPED = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' };
409
+ const MARK = '\u0000';
410
+ /** Reads one level of JSON string escaping in a single pass, so an escaped backslash is never read twice. */
411
+ function decodeOneLevel(text) {
412
+ return text.replace(JSON_ESCAPE, (_, escape) => escape.length === 1 ? JSON_ESCAPED[escape] : String.fromCharCode(parseInt(escape.slice(1), 16)));
413
+ }
414
+ /**
415
+ * Recovers a completion whose summary string swallowed the rest of the envelope: the model escaped
416
+ * the quote that should have closed summary, so tests, outcome and output arrived as text inside it.
417
+ * The summary is cut where the first swallowed field starts and only what follows is parsed, so the
418
+ * answer's own text (a Windows path, a regular expression) is never read as JSON escapes. The parsed
419
+ * fields fill the ones the envelope lacks; a field the envelope already carries is never replaced.
420
+ */
421
+ function unpackEmbeddedEnvelope(envelope, notes) {
422
+ if (typeof envelope.summary !== 'string' || envelope.summary.includes(MARK))
423
+ return;
424
+ let candidate = envelope.summary;
425
+ // The swallowed fields sit at the summary's own escaping level, or one or two levels deeper when the
426
+ // model escaped the whole tail again.
427
+ for (let level = 0; level < 3; level += 1, candidate = decodeOneLevel(candidate)) {
428
+ let marked = false;
429
+ const masked = mapOutsideCode(candidate, prose => marked ? prose : prose.replace(EMBEDDED_ENVELOPE_FIELD, found => { marked = true; return MARK + found.slice(1); }));
430
+ const cut = masked.indexOf(MARK);
431
+ if (!marked || masked.length !== candidate.length || candidate[cut] !== '"')
432
+ continue;
433
+ let inner;
434
+ try {
435
+ inner = JSON.parse(`{"summary":""${candidate.slice(cut + 1).replace(/[\n\r\t]/g, char => RAW_CONTROL[char])}`);
436
+ }
437
+ catch {
438
+ continue;
439
+ }
440
+ if (!inner || typeof inner !== 'object' || Array.isArray(inner))
441
+ continue;
442
+ const fields = inner;
443
+ // At the summary's own level only its quotes can still be escaped: the model escaped them for the
444
+ // string it believed it was still inside.
445
+ const summary = level === 0 ? candidate.slice(0, cut).replace(/\\"/g, '"') : candidate.slice(0, cut);
446
+ if (!summary.trim())
447
+ continue;
448
+ if (Object.keys(fields).some(key => key !== 'summary' && !EMBEDDED_FIELDS.includes(key)))
449
+ continue;
450
+ if (fields.tests !== undefined && !ENVELOPE_FIELDS.tests(fields.tests))
451
+ continue;
452
+ if (fields.outcome !== undefined && typeof fields.outcome !== 'string')
453
+ continue;
454
+ const moved = [];
455
+ for (const key of EMBEDDED_FIELDS) {
456
+ if (fields[key] === undefined || !emptyField(envelope[key]))
457
+ continue;
458
+ envelope[key] = fields[key];
459
+ moved.push(key);
460
+ }
461
+ envelope.summary = summary;
462
+ notes?.push(`completion summary carried the rest of the envelope as text${moved.length ? ` (${moved.join(', ')})` : ''}; the host separated the fields`);
463
+ return;
464
+ }
465
+ }
398
466
  function rejectEmbeddedEnvelope(summary) {
399
467
  let field;
400
468
  mapOutsideCode(summary, prose => {
@@ -482,17 +550,23 @@ export function stripEchoedEnvelope(summary, outcome, notes) {
482
550
  notes?.push(`completion summary ended with its own ${[...fields].join(', ')} fields written out as text, removed by the host`);
483
551
  return answer;
484
552
  }
553
+ const CONTRACT_MISMATCH = 'Completion outcome or output does not match the declared contract';
485
554
  export function parseCompletion(text, options, reject, notes, stopReason) {
486
555
  const body = text.replace(/^```(?:json)?\s*\n?/, '').replace(/\n?```\s*$/, '');
487
556
  try {
488
557
  const value = parseCompletionJson(body, stopReason, notes);
489
- if (value && typeof value === 'object' && !Array.isArray(value))
558
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
490
559
  splitFusedArguments(value, notes);
560
+ unpackEmbeddedEnvelope(value, notes);
561
+ }
491
562
  if (options.completionPolicy && value && typeof value === 'object' && !Array.isArray(value)) {
492
563
  const policy = options.completionPolicy;
493
564
  const outcome = value.outcome ?? (policy.mode === 'single' ? policy.outcome : undefined);
494
- if (typeof outcome !== 'string' || !(policy.mode === 'single' ? [policy.outcome] : policy.outcomes).includes(outcome))
495
- throw new Error("Completion outcome or output does not match the declared contract");
565
+ const declared = policy.mode === 'single' ? [policy.outcome] : policy.outcomes;
566
+ if (typeof outcome !== 'string' || !declared.includes(outcome)) {
567
+ const got = outcome === undefined ? 'outcome is missing' : `outcome ${(JSON.stringify(outcome) ?? String(outcome)).slice(0, 80)} is not declared`;
568
+ throw new Error(`${CONTRACT_MISMATCH}: ${got}; send outcome as ${declared.length === 1 ? '' : 'one of '}${declared.map(item => JSON.stringify(item)).join(', ')}`);
569
+ }
496
570
  let output = value.output ?? (typeof value.summary === 'string' ? { summary: value.summary, tests: value.tests ?? [] } : undefined);
497
571
  if (typeof output === 'string') {
498
572
  try {
@@ -504,8 +578,11 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
504
578
  }
505
579
  catch { }
506
580
  }
507
- if (!output || typeof output !== 'object' || Array.isArray(output))
508
- throw new Error("Completion outcome or output does not match the declared contract");
581
+ if (!output || typeof output !== 'object' || Array.isArray(output)) {
582
+ throw new Error(output === undefined || output === null
583
+ ? `${CONTRACT_MISMATCH}: it has neither a summary nor an output; send summary (the final answer, in markdown), tests, outcome and output as complete_agent arguments`
584
+ : `${CONTRACT_MISMATCH}: output is ${Array.isArray(output) ? 'an array' : `a ${typeof output}`} and must be a JSON object`);
585
+ }
509
586
  if (value.output !== undefined)
510
587
  output = liftEnvelopeFields(value, output, options.outputSchema, notes);
511
588
  if (options.canonicalTask !== undefined)
@@ -7,7 +7,7 @@ import { type AnalyticsConfig } from './analytics.js';
7
7
  import { type PermissionMode } from './permissions.js';
8
8
  import { type ToolProfile } from './tool-profile.js';
9
9
  import { type Limits } from './limits.js';
10
- import type { ProjectEntry, RemoteConfig } from './remote/types.js';
10
+ import type { ProjectEntry, RemoteShare } from './remote/types.js';
11
11
  export interface LimitsConfig {
12
12
  maxIterations?: number;
13
13
  wallTimeMs?: number;
@@ -35,6 +35,27 @@ export type McpServerConfig = {
35
35
  headers?: Record<string, string>;
36
36
  enabled?: boolean;
37
37
  };
38
+ export interface BridgeConfig {
39
+ folders?: RemoteShare[];
40
+ }
41
+ /**
42
+ * `modelRelay`: by Andorra account subject, the linked machines (environment ids) allowed to use this computer's
43
+ * providers through the model relay, oldest first. A list (the shape before accounts were told apart) is ignored on read
44
+ * and replaced on the next write.
45
+ */
46
+ export interface EnvironmentsConfig {
47
+ modelRelay?: Record<string, string[]> | string[];
48
+ }
49
+ /** At most this many machines are allowed per account; allowing another drops the oldest. */
50
+ export declare const MODEL_RELAY_ALLOWED_LIMIT = 64;
51
+ /** The machines `subject` allowed to use this computer's models, from a saved `environments.modelRelay`. */
52
+ export declare function modelRelayAllowedFor(environments: EnvironmentsConfig | undefined, subject: string | undefined): string[];
53
+ /**
54
+ * `map` with `subject`'s list set to `list` and moved to the end: the object's key order is the order in which the
55
+ * accounts' lists were last written. Past 64 accounts, the least recently written are dropped, so the file always
56
+ * validates. (Account subjects are Cognito ids, never integer-like keys, so the order holds.)
57
+ */
58
+ export declare function withModelRelayEntry(map: Record<string, string[]>, subject: string, list: string[]): Record<string, string[]>;
38
59
  export interface Config {
39
60
  version: 1;
40
61
  provider: string;
@@ -59,18 +80,64 @@ export interface Config {
59
80
  mcpServers?: Record<string, McpServerConfig>;
60
81
  workspacePermissions?: Record<string, PermissionMode>;
61
82
  projectExtensions?: Record<string, ProjectExtensionOverride>;
62
- remote?: RemoteConfig;
83
+ remote?: Record<string, unknown>;
84
+ bridge?: BridgeConfig;
63
85
  projects?: ProjectEntry[];
64
86
  externalSubagent?: {
65
87
  provider: string;
66
88
  model: string;
67
89
  };
90
+ environments?: EnvironmentsConfig;
68
91
  systemPromptOverride?: string;
69
92
  toolProfile?: ToolProfile;
70
93
  autoArchiveDays?: number;
71
94
  browser?: BrowserConfig;
72
95
  webSearch?: WebSearchConfig;
96
+ github?: GitHubConfig;
73
97
  }
98
+ /**
99
+ * The Andorra GitHub App, per user. `app.enabled: false` turns its events off on this installation (every PR
100
+ * is polled through gh, as without the App). `app.agentWrites` says who the agent's replies, resolves and PR
101
+ * comments post as on a PR the App covers: `bot` (the default) for the App's bot, `me` for the person's own gh
102
+ * account. `app.triggers: false` stops a mention of the App's bot on a task's PR from waking the task on this
103
+ * installation (the per-machine opt-out; on by default). `app.reviews: false` refuses switching the Andorra review loop
104
+ * on here (on by default); `app.reviewNewPullRequests: true` switches it on for each PR a task opens (off by default).
105
+ * Other keys under `github.app` belong to later versions and are kept as written.
106
+ */
107
+ export declare const GITHUB_AGENT_WRITES: readonly ["bot", "me"];
108
+ export type GitHubAgentWrites = typeof GITHUB_AGENT_WRITES[number];
109
+ export interface GitHubConfig {
110
+ app?: {
111
+ enabled?: boolean;
112
+ agentWrites?: GitHubAgentWrites;
113
+ triggers?: boolean;
114
+ reviews?: boolean;
115
+ reviewNewPullRequests?: boolean;
116
+ } & Record<string, unknown>;
117
+ }
118
+ export declare function validateGitHubConfig(value: unknown): GitHubConfig;
119
+ export declare function githubAgentWrites(config: Pick<Config, 'github'>): GitHubAgentWrites;
120
+ /** The same, read from `config.json` for each write and each Auto-fix prompt, without validation or keyring; unreadable reads as `bot`. */
121
+ export declare function readGitHubAgentWrites(directory: string): Promise<GitHubAgentWrites>;
122
+ /** Whether the GitHub App's events may run here: not switched off in config, nor by `ANDORRA_GITHUB_APP=off`. */
123
+ export declare function githubAppEventsEnabled(config: Pick<Config, 'github'>, env?: NodeJS.ProcessEnv): boolean;
124
+ /**
125
+ * The same, read cheaply for a check that runs every minute: only `github.app.enabled` is taken from
126
+ * `config.json`, with no validation, no provider keys and no keyring. A missing or unreadable file reads as on,
127
+ * as `loadConfig`'s default config would.
128
+ */
129
+ export declare function readGitHubAppEventsEnabled(directory: string, env?: NodeJS.ProcessEnv): Promise<boolean>;
130
+ export declare function githubAppTriggersEnabled(config: Pick<Config, 'github'>): boolean;
131
+ /** The same, read from `config.json` for each mention, without validation or keyring; a missing or unreadable file reads as on. */
132
+ export declare function readGitHubAppTriggersEnabled(directory: string): Promise<boolean>;
133
+ /** The Andorra review loop may be switched on here: only `github.app.reviews: false` says no. */
134
+ export declare function githubAppReviewsEnabled(config: Pick<Config, 'github'>): boolean;
135
+ /** The same, read from `config.json` without validation or keyring; a missing or unreadable file reads as on. */
136
+ export declare function readGitHubAppReviewsEnabled(directory: string): Promise<boolean>;
137
+ /** A PR a task opens starts with the review loop on: only `github.app.reviewNewPullRequests: true` says so. */
138
+ export declare function githubAppReviewNewPullRequests(config: Pick<Config, 'github'>): boolean;
139
+ /** The same, read from `config.json`; a missing or unreadable file reads as off. */
140
+ export declare function readGitHubAppReviewNewPullRequests(directory: string): Promise<boolean>;
74
141
  export interface BrowserConfig {
75
142
  capsolverApiKey?: string;
76
143
  }
@@ -134,6 +201,7 @@ export declare class ConfigConflictError extends Error {
134
201
  export declare function changeConfigFile<T = undefined>(directory: string, change: (current: Config, prepared: T) => Config, attempts?: number, prepare?: () => Promise<T>): Promise<Config>;
135
202
  export declare function validateCodeIntelConfig(codeIntel: unknown): void;
136
203
  export declare function resolveCodeIntelConfig(config: Config): Required<Pick<CodeIntelConfig, 'enabled'>> & CodeIntelConfig;
137
- export declare function validateRemoteConfig(remote: unknown): void;
204
+ export declare function validateBridgeConfig(bridge: unknown): void;
205
+ export declare function validateEnvironmentsConfig(environments: unknown): void;
138
206
  export declare function validateProjectsConfig(projects: unknown): void;
139
207
  export declare function validateDecisionConfig(value: unknown): void;