@andorra-labs/code 0.1.16 → 0.1.18

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 (236) 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-execution.js +108 -19
  4. package/dist/src/agent-mcp-catalog.js +1 -0
  5. package/dist/src/agent-mcp.d.ts +3 -0
  6. package/dist/src/agent-mcp.js +33 -1
  7. package/dist/src/andorra/entry.d.ts +10 -0
  8. package/dist/src/andorra/entry.js +18 -4
  9. package/dist/src/andorra/errors.js +3 -0
  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 +30 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +108 -0
  23. package/dist/src/app-server/workspace.js +608 -11
  24. package/dist/src/app-server.d.ts +390 -33
  25. package/dist/src/app-server.js +3033 -565
  26. package/dist/src/attachments.d.ts +10 -0
  27. package/dist/src/attachments.js +102 -7
  28. package/dist/src/automation-tool.js +2 -1
  29. package/dist/src/bridge/cloud.d.ts +27 -0
  30. package/dist/src/bridge/cloud.js +187 -0
  31. package/dist/src/bridge/command.d.ts +30 -0
  32. package/dist/src/bridge/command.js +359 -0
  33. package/dist/src/bridge/control.d.ts +70 -0
  34. package/dist/src/bridge/control.js +238 -0
  35. package/dist/src/bridge/engines.d.ts +90 -0
  36. package/dist/src/bridge/engines.js +601 -0
  37. package/dist/src/bridge/github.d.ts +108 -0
  38. package/dist/src/bridge/github.js +378 -0
  39. package/dist/src/bridge/host-ops.d.ts +9 -0
  40. package/dist/src/bridge/host-ops.js +139 -0
  41. package/dist/src/bridge/host.d.ts +47 -0
  42. package/dist/src/bridge/host.js +543 -0
  43. package/dist/src/bridge/link.d.ts +38 -0
  44. package/dist/src/bridge/link.js +508 -0
  45. package/dist/src/bridge/login-link.d.ts +29 -0
  46. package/dist/src/bridge/login-link.js +54 -0
  47. package/dist/src/bridge/protocol.d.ts +136 -0
  48. package/dist/src/bridge/protocol.js +11 -0
  49. package/dist/src/bridge/store.d.ts +12 -0
  50. package/dist/src/bridge/store.js +61 -0
  51. package/dist/src/bridge/wording.d.ts +6 -0
  52. package/dist/src/bridge/wording.js +10 -0
  53. package/dist/src/browser-server.js +7 -1
  54. package/dist/src/browser-ui/tokens.css +1 -1
  55. package/dist/src/bug-report-attachments.d.ts +48 -0
  56. package/dist/src/bug-report-attachments.js +327 -0
  57. package/dist/src/bug-report.d.ts +23 -3
  58. package/dist/src/bug-report.js +72 -9
  59. package/dist/src/change-authors.d.ts +41 -0
  60. package/dist/src/change-authors.js +146 -0
  61. package/dist/src/cli.d.ts +1 -3
  62. package/dist/src/cli.js +191 -35
  63. package/dist/src/codex-provider.js +1 -1
  64. package/dist/src/coding-tools.js +24 -17
  65. package/dist/src/command-screens.d.ts +6 -0
  66. package/dist/src/command-screens.js +14 -11
  67. package/dist/src/commands.d.ts +15 -3
  68. package/dist/src/commands.js +2 -1
  69. package/dist/src/compaction-phrases.js +1 -1
  70. package/dist/src/completion.js +89 -8
  71. package/dist/src/config.d.ts +71 -3
  72. package/dist/src/config.js +205 -78
  73. package/dist/src/context-budget.js +15 -2
  74. package/dist/src/deadline.js +13 -1
  75. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  76. package/dist/src/decision/DecisionManager.d.ts +11 -0
  77. package/dist/src/decision/DecisionManager.js +36 -0
  78. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  79. package/dist/src/decision/applyTaskKind.js +53 -0
  80. package/dist/src/decision/checks.js +1 -1
  81. package/dist/src/decision/hostedPolicy.js +2 -1
  82. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
  83. package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
  84. package/dist/src/decision/requestPhrases.js +0 -1
  85. package/dist/src/decision/taskKind.d.ts +52 -0
  86. package/dist/src/decision/taskKind.js +76 -0
  87. package/dist/src/decision/types.d.ts +1 -1
  88. package/dist/src/default-graph.js +1 -1
  89. package/dist/src/efficiency.d.ts +5 -0
  90. package/dist/src/efficiency.js +5 -1
  91. package/dist/src/effort-routing.d.ts +27 -0
  92. package/dist/src/effort-routing.js +34 -0
  93. package/dist/src/evidence.d.ts +110 -0
  94. package/dist/src/evidence.js +195 -0
  95. package/dist/src/file-diff.d.ts +4 -0
  96. package/dist/src/file-diff.js +2 -1
  97. package/dist/src/github-app/agent-writes.d.ts +102 -0
  98. package/dist/src/github-app/agent-writes.js +320 -0
  99. package/dist/src/github-app/client.d.ts +368 -0
  100. package/dist/src/github-app/client.js +830 -0
  101. package/dist/src/github-app/event-source.d.ts +208 -0
  102. package/dist/src/github-app/event-source.js +684 -0
  103. package/dist/src/github-app/metrics.d.ts +32 -0
  104. package/dist/src/github-app/metrics.js +49 -0
  105. package/dist/src/github-app/review-loop.d.ts +274 -0
  106. package/dist/src/github-app/review-loop.js +1177 -0
  107. package/dist/src/github-app/review-node.d.ts +81 -0
  108. package/dist/src/github-app/review-node.js +205 -0
  109. package/dist/src/github-app/review-post.d.ts +73 -0
  110. package/dist/src/github-app/review-post.js +139 -0
  111. package/dist/src/github-app/review-text.d.ts +107 -0
  112. package/dist/src/github-app/review-text.js +1133 -0
  113. package/dist/src/github-app/review-threads.d.ts +47 -0
  114. package/dist/src/github-app/review-threads.js +107 -0
  115. package/dist/src/github-app/reviewer.d.ts +121 -0
  116. package/dist/src/github-app/reviewer.js +598 -0
  117. package/dist/src/github-app/store.d.ts +59 -0
  118. package/dist/src/github-app/store.js +148 -0
  119. package/dist/src/github-app/triggers.d.ts +141 -0
  120. package/dist/src/github-app/triggers.js +441 -0
  121. package/dist/src/github-names.d.ts +15 -0
  122. package/dist/src/github-names.js +15 -0
  123. package/dist/src/glob-search.d.ts +61 -0
  124. package/dist/src/glob-search.js +180 -0
  125. package/dist/src/graph-health.js +6 -1
  126. package/dist/src/graph-manager-chat.js +1 -1
  127. package/dist/src/graph-preview.d.ts +48 -0
  128. package/dist/src/graph-preview.js +56 -0
  129. package/dist/src/graph-provider-portability.js +2 -1
  130. package/dist/src/graph-runner.js +65 -4
  131. package/dist/src/graph-server.js +7 -5
  132. package/dist/src/graph-sync.js +3 -3
  133. package/dist/src/graph-ui/app.js +121 -7
  134. package/dist/src/graph-ui/icons.js +2 -1
  135. package/dist/src/graph-ui/studio.js +15 -1
  136. package/dist/src/graph-ui/tokens.css +1 -1
  137. package/dist/src/graphs.d.ts +40 -1
  138. package/dist/src/graphs.js +164 -15
  139. package/dist/src/hardened-runtime.js +32 -21
  140. package/dist/src/image-input.d.ts +16 -0
  141. package/dist/src/image-input.js +41 -0
  142. package/dist/src/membership.d.ts +10 -0
  143. package/dist/src/membership.js +19 -4
  144. package/dist/src/model-health-cache.js +1 -1
  145. package/dist/src/model-metadata.d.ts +6 -0
  146. package/dist/src/model-metadata.js +35 -15
  147. package/dist/src/model-override.d.ts +2 -1
  148. package/dist/src/model-override.js +9 -0
  149. package/dist/src/model-relay/local.d.ts +116 -0
  150. package/dist/src/model-relay/local.js +468 -0
  151. package/dist/src/model-relay/remote.d.ts +129 -0
  152. package/dist/src/model-relay/remote.js +252 -0
  153. package/dist/src/model-relay/runs.d.ts +34 -0
  154. package/dist/src/model-relay/runs.js +146 -0
  155. package/dist/src/model-relay/wire.d.ts +5 -0
  156. package/dist/src/model-relay/wire.js +5 -0
  157. package/dist/src/model-tiers.d.ts +3 -0
  158. package/dist/src/model-tiers.js +3 -3
  159. package/dist/src/project-registry.d.ts +21 -0
  160. package/dist/src/project-registry.js +74 -0
  161. package/dist/src/provider-engine.d.ts +13 -1
  162. package/dist/src/provider-engine.js +74 -0
  163. package/dist/src/provider-import.d.ts +0 -12
  164. package/dist/src/provider-import.js +7 -195
  165. package/dist/src/providers.d.ts +28 -2
  166. package/dist/src/providers.js +59 -12
  167. package/dist/src/pull-request-logs.d.ts +12 -1
  168. package/dist/src/pull-request-logs.js +14 -3
  169. package/dist/src/pull-requests.d.ts +338 -8
  170. package/dist/src/pull-requests.js +482 -53
  171. package/dist/src/react-runtime.js +99 -16
  172. package/dist/src/remote/engine-pool.d.ts +88 -4
  173. package/dist/src/remote/engine-pool.js +367 -90
  174. package/dist/src/remote/roots.d.ts +19 -0
  175. package/dist/src/remote/roots.js +45 -7
  176. package/dist/src/remote/types.d.ts +0 -44
  177. package/dist/src/run-control.d.ts +7 -0
  178. package/dist/src/run-control.js +23 -0
  179. package/dist/src/run-records.d.ts +7 -2
  180. package/dist/src/run-records.js +71 -6
  181. package/dist/src/runtime.d.ts +34 -2
  182. package/dist/src/runtime.js +18 -2
  183. package/dist/src/session-changes.d.ts +35 -0
  184. package/dist/src/session-changes.js +194 -6
  185. package/dist/src/session-monitor.js +2 -1
  186. package/dist/src/session-reaper.d.ts +1 -1
  187. package/dist/src/session-reaper.js +6 -1
  188. package/dist/src/session-summary.d.ts +2 -1
  189. package/dist/src/session-summary.js +2 -1
  190. package/dist/src/sessions.d.ts +35 -1
  191. package/dist/src/sessions.js +70 -4
  192. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  193. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  194. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  195. package/dist/src/skills/bundled/provenance.json +3 -3
  196. package/dist/src/skills/runtime-skills.js +1 -1
  197. package/dist/src/task-checkout.d.ts +141 -0
  198. package/dist/src/task-checkout.js +558 -0
  199. package/dist/src/telemetry/emitter.d.ts +15 -0
  200. package/dist/src/telemetry/emitter.js +35 -1
  201. package/dist/src/telemetry/schema.d.ts +25 -2
  202. package/dist/src/telemetry/schema.js +52 -4
  203. package/dist/src/telemetry/surface.d.ts +2 -1
  204. package/dist/src/telemetry/surface.js +4 -1
  205. package/dist/src/terminal-ui.d.ts +1 -0
  206. package/dist/src/terminal-ui.js +10 -3
  207. package/dist/src/test-edit-guard.d.ts +37 -0
  208. package/dist/src/test-edit-guard.js +216 -3
  209. package/dist/src/thinking-level-detect.d.ts +11 -0
  210. package/dist/src/thinking-level-detect.js +47 -0
  211. package/dist/src/thinking-levels.d.ts +30 -0
  212. package/dist/src/thinking-levels.js +124 -0
  213. package/dist/src/timers.d.ts +3 -0
  214. package/dist/src/tool-catalog.js +1 -1
  215. package/dist/src/tools.js +59 -9
  216. package/dist/src/transcript.js +1 -1
  217. package/dist/src/types.d.ts +34 -0
  218. package/package.json +6 -1
  219. package/dist/src/remote/cert.d.ts +0 -11
  220. package/dist/src/remote/cert.js +0 -87
  221. package/dist/src/remote/client.d.ts +0 -119
  222. package/dist/src/remote/client.js +0 -544
  223. package/dist/src/remote/command.d.ts +0 -4
  224. package/dist/src/remote/command.js +0 -194
  225. package/dist/src/remote/errors.d.ts +0 -11
  226. package/dist/src/remote/errors.js +0 -14
  227. package/dist/src/remote/network.d.ts +0 -22
  228. package/dist/src/remote/network.js +0 -102
  229. package/dist/src/remote/pairing.d.ts +0 -63
  230. package/dist/src/remote/pairing.js +0 -299
  231. package/dist/src/remote/pem.d.ts +0 -2
  232. package/dist/src/remote/pem.js +0 -7
  233. package/dist/src/remote/serve.d.ts +0 -68
  234. package/dist/src/remote/serve.js +0 -244
  235. package/dist/src/remote/server.d.ts +0 -21
  236. package/dist/src/remote/server.js +0 -406
@@ -4,7 +4,6 @@ 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';
@@ -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))
@@ -4,7 +4,7 @@ import { currentGraphSubject } from './graph-selection.js';
4
4
  import { loadAccessibleGraph, requireGraphMembership } from './membership.js';
5
5
  import type { Config } from './config.js';
6
6
  import { type SessionGoal } from './session-goal.js';
7
- import type { Completion, RunResult } from './runtime.js';
7
+ import { type Completion, type RunResult } from './runtime.js';
8
8
  import type { Usage } from './types.js';
9
9
  import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
10
10
  import { logoutCodex } from './codex-auth.js';
@@ -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,19 +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
- /** Why a turn started without the person typing it: a timer the agent set, Auto-fix, or the PR tab's Fix with Agent. */
64
- export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks';
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';
65
77
  export declare function compactHistory(turns: ConversationTurn[]): ConversationTurn[];
66
78
  export declare function compactedContextEstimate(turns: ConversationTurn[]): number;
67
79
  export declare function subagentClearRequested(line: string, providers: {
@@ -11,6 +11,7 @@ import { GraphProviderUnavailableError } from './graph-provider-portability.js';
11
11
  import { confirmAndApplyModelOverride } from './model-override.js';
12
12
  import { applyGoalCommand } from './session-goal.js';
13
13
  import { changeConfigFile, configDirectory, loadConfig, loadSavedAnalytics } from './config.js';
14
+ import { turnModelCompletion } from './runtime.js';
14
15
  import { applyModelContextWindow, modelDisplayName, modelIdForDisplayName, providerLabel, recordProviderModel, REASONING_EFFORTS } from './providers.js';
15
16
  import { resolveRepositoryId } from './code-intelligence/repository.js';
16
17
  import { logoutCodex } from './codex-auth.js';
@@ -97,7 +98,7 @@ export function compactHistory(turns) {
97
98
  }];
98
99
  }
99
100
  export function compactedContextEstimate(turns) {
100
- return Math.ceil(JSON.stringify(turns).length / 4);
101
+ return Math.ceil(JSON.stringify(turns.map(turn => ({ ...turn, completion: turnModelCompletion(turn.completion) }))).length / 4);
101
102
  }
102
103
  const CODEGRAPH_USAGE = 'Usage: /codegraph status|enable|disable|rebuild. Add --global to enable|disable to set the saved default for every project (this clears per-repository overrides).';
103
104
  async function codegraphCommand(action, scope, state, signal) {
@@ -8,7 +8,7 @@ export const COMPACTION_PHRASES = [
8
8
  'Stuffing memories into a carry-on',
9
9
  'Shrink-wrapping the context',
10
10
  'Condensing the chat like canned soup',
11
- 'Turning the scroll into a sticky note',
11
+ 'Turning the context into a sticky note',
12
12
  ];
13
13
  export function pickCompactionPhrase(random = Math.random) {
14
14
  const index = Math.floor(random() * COMPACTION_PHRASES.length);
@@ -1,5 +1,6 @@
1
1
  import { validateJsonSchemaValue } from '../vendor/zcode/source/tool/json-schema.js';
2
2
  import { interruptsParagraph } from './markdown.js';
3
+ import { OUTCOMES_SCHEMA, parseOutcomes } from './evidence.js';
3
4
  export const COMPLETION_TOOL = 'complete_agent';
4
5
  export const FINAL_RESPONSE_GUIDANCE = "Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off.";
5
6
  export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences. Match the length to the work: a small change or a short answer is a few sentences or bullets with no headings; larger work uses short headings (## What changed, ## Not done) and bullet lists for parallel items. Do not list the checks again in the summary, because the tests array is shown beside it. Throughout, put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.`;
@@ -66,6 +67,7 @@ export function completionTool(options) {
66
67
  type: 'object',
67
68
  properties: {
68
69
  summary: { type: 'string', description: SUMMARY_DESCRIPTION }, tests: { type: 'array', items: { type: 'string', description: 'One short line: the check that ran, then its outcome.' } },
70
+ outcomes: OUTCOMES_SCHEMA,
69
71
  ...(options.finalAnswerOutcomes?.length ? { remaining: { type: 'array', maxItems: REMAINING_LIMIT, items: { type: 'string' }, description: REMAINING_DESCRIPTION } } : {}),
70
72
  ...(outcomes ? { artifacts: { type: 'array', maxItems: 50, items: { type: 'object', properties: { type: { type: 'string' }, ref: { type: 'string' } }, required: ['type', 'ref'], additionalProperties: false } } } : {}),
71
73
  ...(outcomes ? { outcome: { type: 'string', enum: outcomes }, output: providerOutputSchema(options.outputSchema ?? { type: 'object' }) } : {}),
@@ -394,7 +396,75 @@ function splitFusedArguments(envelope, notes) {
394
396
  notes?.push(`completion fields ${fields.map(([name]) => name).join(', ')} arrived fused into one key by leaked argument markup and were split apart`);
395
397
  }
396
398
  }
397
- const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts)"\s*:/;
399
+ const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts|outcomes)"\s*:/;
400
+ const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining', 'outcomes'];
401
+ const RAW_CONTROL = { '\n': '\\n', '\r': '\\r', '\t': '\\t' };
402
+ function emptyField(value) {
403
+ if (value === undefined || value === null)
404
+ return true;
405
+ if (Array.isArray(value))
406
+ return value.length === 0;
407
+ return typeof value === 'object' && Object.keys(value).length === 0;
408
+ }
409
+ const JSON_ESCAPE = /\\(["\\/bfnrt]|u[0-9a-fA-F]{4})/g;
410
+ const JSON_ESCAPED = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' };
411
+ const MARK = '\u0000';
412
+ /** Reads one level of JSON string escaping in a single pass, so an escaped backslash is never read twice. */
413
+ function decodeOneLevel(text) {
414
+ return text.replace(JSON_ESCAPE, (_, escape) => escape.length === 1 ? JSON_ESCAPED[escape] : String.fromCharCode(parseInt(escape.slice(1), 16)));
415
+ }
416
+ /**
417
+ * Recovers a completion whose summary string swallowed the rest of the envelope: the model escaped
418
+ * the quote that should have closed summary, so tests, outcome and output arrived as text inside it.
419
+ * The summary is cut where the first swallowed field starts and only what follows is parsed, so the
420
+ * answer's own text (a Windows path, a regular expression) is never read as JSON escapes. The parsed
421
+ * fields fill the ones the envelope lacks; a field the envelope already carries is never replaced.
422
+ */
423
+ function unpackEmbeddedEnvelope(envelope, notes) {
424
+ if (typeof envelope.summary !== 'string' || envelope.summary.includes(MARK))
425
+ return;
426
+ let candidate = envelope.summary;
427
+ // The swallowed fields sit at the summary's own escaping level, or one or two levels deeper when the
428
+ // model escaped the whole tail again.
429
+ for (let level = 0; level < 3; level += 1, candidate = decodeOneLevel(candidate)) {
430
+ let marked = false;
431
+ const masked = mapOutsideCode(candidate, prose => marked ? prose : prose.replace(EMBEDDED_ENVELOPE_FIELD, found => { marked = true; return MARK + found.slice(1); }));
432
+ const cut = masked.indexOf(MARK);
433
+ if (!marked || masked.length !== candidate.length || candidate[cut] !== '"')
434
+ continue;
435
+ let inner;
436
+ try {
437
+ inner = JSON.parse(`{"summary":""${candidate.slice(cut + 1).replace(/[\n\r\t]/g, char => RAW_CONTROL[char])}`);
438
+ }
439
+ catch {
440
+ continue;
441
+ }
442
+ if (!inner || typeof inner !== 'object' || Array.isArray(inner))
443
+ continue;
444
+ const fields = inner;
445
+ // At the summary's own level only its quotes can still be escaped: the model escaped them for the
446
+ // string it believed it was still inside.
447
+ const summary = level === 0 ? candidate.slice(0, cut).replace(/\\"/g, '"') : candidate.slice(0, cut);
448
+ if (!summary.trim())
449
+ continue;
450
+ if (Object.keys(fields).some(key => key !== 'summary' && !EMBEDDED_FIELDS.includes(key)))
451
+ continue;
452
+ if (fields.tests !== undefined && !ENVELOPE_FIELDS.tests(fields.tests))
453
+ continue;
454
+ if (fields.outcome !== undefined && typeof fields.outcome !== 'string')
455
+ continue;
456
+ const moved = [];
457
+ for (const key of EMBEDDED_FIELDS) {
458
+ if (fields[key] === undefined || !emptyField(envelope[key]))
459
+ continue;
460
+ envelope[key] = fields[key];
461
+ moved.push(key);
462
+ }
463
+ envelope.summary = summary;
464
+ notes?.push(`completion summary carried the rest of the envelope as text${moved.length ? ` (${moved.join(', ')})` : ''}; the host separated the fields`);
465
+ return;
466
+ }
467
+ }
398
468
  function rejectEmbeddedEnvelope(summary) {
399
469
  let field;
400
470
  mapOutsideCode(summary, prose => {
@@ -482,17 +552,23 @@ export function stripEchoedEnvelope(summary, outcome, notes) {
482
552
  notes?.push(`completion summary ended with its own ${[...fields].join(', ')} fields written out as text, removed by the host`);
483
553
  return answer;
484
554
  }
555
+ const CONTRACT_MISMATCH = 'Completion outcome or output does not match the declared contract';
485
556
  export function parseCompletion(text, options, reject, notes, stopReason) {
486
557
  const body = text.replace(/^```(?:json)?\s*\n?/, '').replace(/\n?```\s*$/, '');
487
558
  try {
488
559
  const value = parseCompletionJson(body, stopReason, notes);
489
- if (value && typeof value === 'object' && !Array.isArray(value))
560
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
490
561
  splitFusedArguments(value, notes);
562
+ unpackEmbeddedEnvelope(value, notes);
563
+ }
491
564
  if (options.completionPolicy && value && typeof value === 'object' && !Array.isArray(value)) {
492
565
  const policy = options.completionPolicy;
493
566
  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");
567
+ const declared = policy.mode === 'single' ? [policy.outcome] : policy.outcomes;
568
+ if (typeof outcome !== 'string' || !declared.includes(outcome)) {
569
+ const got = outcome === undefined ? 'outcome is missing' : `outcome ${(JSON.stringify(outcome) ?? String(outcome)).slice(0, 80)} is not declared`;
570
+ throw new Error(`${CONTRACT_MISMATCH}: ${got}; send outcome as ${declared.length === 1 ? '' : 'one of '}${declared.map(item => JSON.stringify(item)).join(', ')}`);
571
+ }
496
572
  let output = value.output ?? (typeof value.summary === 'string' ? { summary: value.summary, tests: value.tests ?? [] } : undefined);
497
573
  if (typeof output === 'string') {
498
574
  try {
@@ -504,8 +580,11 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
504
580
  }
505
581
  catch { }
506
582
  }
507
- if (!output || typeof output !== 'object' || Array.isArray(output))
508
- throw new Error("Completion outcome or output does not match the declared contract");
583
+ if (!output || typeof output !== 'object' || Array.isArray(output)) {
584
+ throw new Error(output === undefined || output === null
585
+ ? `${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`
586
+ : `${CONTRACT_MISMATCH}: output is ${Array.isArray(output) ? 'an array' : `a ${typeof output}`} and must be a JSON object`);
587
+ }
509
588
  if (value.output !== undefined)
510
589
  output = liftEnvelopeFields(value, output, options.outputSchema, notes);
511
590
  if (options.canonicalTask !== undefined)
@@ -546,13 +625,15 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
546
625
  if (written === undefined)
547
626
  notes?.push(OUTPUT_STOOD_IN_NOTE);
548
627
  const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes)), outcome, notes);
549
- return { summary,
628
+ const outcomes = parseOutcomes(value.outcomes, notes);
629
+ return { summary, ...(outcomes ? { outcomes } : {}),
550
630
  tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
551
631
  artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
552
632
  }
553
633
  if (value && typeof value.summary === 'string' && value.summary.trim()
554
634
  && Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
555
- return { summary: stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), typeof value.outcome === "string" ? value.outcome : undefined, notes), tests: value.tests };
635
+ const outcomes = parseOutcomes(value.outcomes, notes);
636
+ return { summary: stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), typeof value.outcome === "string" ? value.outcome : undefined, notes), tests: value.tests, ...(outcomes ? { outcomes } : {}) };
556
637
  }
557
638
  throw new Error("Completion needs a nonempty summary and a tests array of strings");
558
639
  }
@@ -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;