@andorra-labs/code 0.1.4 → 0.1.6

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 (171) hide show
  1. package/dist/src/account-presentation.js +3 -3
  2. package/dist/src/agent-execution.d.ts +2 -0
  3. package/dist/src/agent-execution.js +126 -20
  4. package/dist/src/agent-mcp.d.ts +18 -1
  5. package/dist/src/agent-mcp.js +103 -8
  6. package/dist/src/app-server/protocol.d.ts +33 -3
  7. package/dist/src/app-server/protocol.js +14 -1
  8. package/dist/src/app-server/workspace.d.ts +1 -0
  9. package/dist/src/app-server/workspace.js +7 -1
  10. package/dist/src/app-server.d.ts +115 -41
  11. package/dist/src/app-server.js +1229 -219
  12. package/dist/src/automation-runner.d.ts +9 -0
  13. package/dist/src/automation-runner.js +22 -1
  14. package/dist/src/automation-tool.js +8 -1
  15. package/dist/src/automations.js +1 -1
  16. package/dist/src/browser-captcha-tool.d.ts +54 -0
  17. package/dist/src/browser-captcha-tool.js +374 -0
  18. package/dist/src/browser-panel-tool.d.ts +7 -0
  19. package/dist/src/browser-panel-tool.js +74 -3
  20. package/dist/src/browser-runner.js +19 -4
  21. package/dist/src/browser-server.js +21 -1
  22. package/dist/src/browser-session.d.ts +16 -0
  23. package/dist/src/browser-session.js +35 -0
  24. package/dist/src/browser-ui/app.js +193 -3
  25. package/dist/src/browser-ui/style.css +15 -1
  26. package/dist/src/browser-view.d.ts +72 -4
  27. package/dist/src/browser-view.js +229 -17
  28. package/dist/src/capabilities.js +13 -2
  29. package/dist/src/capsolver.d.ts +60 -0
  30. package/dist/src/capsolver.js +101 -0
  31. package/dist/src/claude-provider.d.ts +6 -0
  32. package/dist/src/claude-provider.js +34 -3
  33. package/dist/src/cli-executable.d.ts +33 -0
  34. package/dist/src/cli-executable.js +64 -0
  35. package/dist/src/cli-process.d.ts +47 -0
  36. package/dist/src/cli-process.js +113 -0
  37. package/dist/src/cli-sign-in.d.ts +68 -0
  38. package/dist/src/cli-sign-in.js +224 -0
  39. package/dist/src/cli.js +54 -23
  40. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
  41. package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
  42. package/dist/src/coding-tools.js +44 -5
  43. package/dist/src/command-output-tap.d.ts +16 -0
  44. package/dist/src/command-output-tap.js +45 -0
  45. package/dist/src/command-screens.js +3 -3
  46. package/dist/src/commands.d.ts +10 -1
  47. package/dist/src/commands.js +7 -7
  48. package/dist/src/completion.d.ts +23 -5
  49. package/dist/src/completion.js +334 -17
  50. package/dist/src/config.d.ts +13 -0
  51. package/dist/src/config.js +28 -2
  52. package/dist/src/deadline.js +6 -0
  53. package/dist/src/extensions.d.ts +1 -0
  54. package/dist/src/extensions.js +16 -3
  55. package/dist/src/graph-provider-portability.js +2 -2
  56. package/dist/src/graph-quota.d.ts +1 -1
  57. package/dist/src/graph-quota.js +1 -1
  58. package/dist/src/graph-runner.js +35 -21
  59. package/dist/src/graph-selection.d.ts +6 -0
  60. package/dist/src/graph-selection.js +10 -0
  61. package/dist/src/graph-server.d.ts +7 -0
  62. package/dist/src/graph-server.js +61 -3
  63. package/dist/src/graph-sync.d.ts +50 -0
  64. package/dist/src/graph-sync.js +383 -12
  65. package/dist/src/graph-ui/app.js +61 -8
  66. package/dist/src/graph-ui/icons.js +1 -0
  67. package/dist/src/graph-ui/index.html +1 -1
  68. package/dist/src/graph-ui/skill-picker.js +242 -0
  69. package/dist/src/graph-ui/style.css +19 -0
  70. package/dist/src/graphs.d.ts +46 -4
  71. package/dist/src/graphs.js +152 -27
  72. package/dist/src/grok-provider.d.ts +50 -0
  73. package/dist/src/grok-provider.js +186 -0
  74. package/dist/src/handoffs.d.ts +13 -0
  75. package/dist/src/handoffs.js +31 -1
  76. package/dist/src/managed-sign-in.d.ts +38 -0
  77. package/dist/src/managed-sign-in.js +169 -0
  78. package/dist/src/markdown.d.ts +5 -0
  79. package/dist/src/markdown.js +5 -2
  80. package/dist/src/mcp.js +11 -0
  81. package/dist/src/membership.d.ts +8 -1
  82. package/dist/src/membership.js +15 -5
  83. package/dist/src/model-metadata.js +14 -2
  84. package/dist/src/model-override.d.ts +10 -0
  85. package/dist/src/model-override.js +20 -0
  86. package/dist/src/opencode-cli-provider.d.ts +122 -0
  87. package/dist/src/opencode-cli-provider.js +415 -0
  88. package/dist/src/opencode-provider.js +23 -8
  89. package/dist/src/palette.d.ts +2 -0
  90. package/dist/src/palette.js +2 -0
  91. package/dist/src/permissions.d.ts +19 -1
  92. package/dist/src/permissions.js +30 -1
  93. package/dist/src/powershell-pool.d.ts +2 -2
  94. package/dist/src/powershell-pool.js +18 -5
  95. package/dist/src/provider-connection.js +36 -0
  96. package/dist/src/provider-engine.d.ts +2 -1
  97. package/dist/src/provider-engine.js +64 -13
  98. package/dist/src/provider-import.js +6 -1
  99. package/dist/src/provider-settings.js +22 -3
  100. package/dist/src/providers.d.ts +12 -1
  101. package/dist/src/providers.js +27 -8
  102. package/dist/src/pull-requests.d.ts +111 -17
  103. package/dist/src/pull-requests.js +308 -76
  104. package/dist/src/qa/qa-authorize.js +9 -1
  105. package/dist/src/react-runtime.js +76 -5
  106. package/dist/src/remote/engine-pool.js +1 -1
  107. package/dist/src/run-progress.js +6 -1
  108. package/dist/src/run-records.d.ts +133 -27
  109. package/dist/src/run-records.js +320 -40
  110. package/dist/src/runtime.d.ts +38 -1
  111. package/dist/src/runtime.js +27 -4
  112. package/dist/src/save-lock.d.ts +11 -0
  113. package/dist/src/save-lock.js +29 -2
  114. package/dist/src/sessions.js +4 -1
  115. package/dist/src/shell.js +4 -1
  116. package/dist/src/side-panel.d.ts +1 -1
  117. package/dist/src/side-panel.js +1 -1
  118. package/dist/src/skill-commands.d.ts +2 -0
  119. package/dist/src/skill-commands.js +2 -0
  120. package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
  121. package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
  122. package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
  123. package/dist/src/skills/bundled/graph-manager/SKILL.md +97 -0
  124. package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
  125. package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
  126. package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
  127. package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
  128. package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
  129. package/dist/src/skills/bundled/provenance.json +50 -0
  130. package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
  131. package/dist/src/skills/invocable-skills.d.ts +41 -0
  132. package/dist/src/skills/invocable-skills.js +49 -0
  133. package/dist/src/skills/prompt-skills.d.ts +1 -0
  134. package/dist/src/skills/prompt-skills.js +33 -0
  135. package/dist/src/skills/runtime-skills.d.ts +4 -0
  136. package/dist/src/skills/runtime-skills.js +21 -0
  137. package/dist/src/structured-step.d.ts +55 -0
  138. package/dist/src/structured-step.js +85 -0
  139. package/dist/src/subagent-run.d.ts +1 -1
  140. package/dist/src/subagent-run.js +29 -33
  141. package/dist/src/telemetry/schema.d.ts +2 -2
  142. package/dist/src/telemetry/schema.js +3 -2
  143. package/dist/src/terminal-ui.d.ts +29 -0
  144. package/dist/src/terminal-ui.js +112 -28
  145. package/dist/src/timers.d.ts +21 -2
  146. package/dist/src/timers.js +12 -4
  147. package/dist/src/tool-names.d.ts +18 -0
  148. package/dist/src/tool-names.js +26 -0
  149. package/dist/src/tools.js +45 -11
  150. package/dist/src/trajectory.js +32 -12
  151. package/dist/src/types.d.ts +23 -0
  152. package/dist/src/update.d.ts +26 -16
  153. package/dist/src/update.js +232 -275
  154. package/docs/agents/install-for-agents.md +15 -24
  155. package/docs/agents/mcp-server.md +13 -1
  156. package/docs/agents/subagent-mode.md +7 -4
  157. package/docs/concepts/security.md +2 -0
  158. package/docs/getting-started/README.md +14 -6
  159. package/docs/getting-started/configure-providers.md +29 -2
  160. package/docs/guides/README.md +1 -1
  161. package/docs/guides/browser.md +12 -0
  162. package/docs/guides/desktop-app.md +45 -9
  163. package/docs/guides/graph-builder.md +8 -0
  164. package/docs/guides/update.md +37 -16
  165. package/docs/reference/cli.md +1 -1
  166. package/docs/reference/config.md +2 -2
  167. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
  168. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
  169. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
  170. package/package.json +1 -1
  171. package/tests/permissions-test-plan.md +2 -1
@@ -0,0 +1,50 @@
1
+ import { type CliExecutableSpec } from './cli-executable.js';
2
+ import type { ModelAdapter, ModelResponse, ToolSchema } from './types.js';
3
+ /** A marker, not an endpoint: requests go through the signed-in Grok CLI on this machine. */
4
+ export declare const GROK_BASE_URL = "https://api.x.ai";
5
+ export declare const GROK_EXECUTABLE: CliExecutableSpec;
6
+ /**
7
+ * The child environment: the parent's, minus every xAI key the CLI would fall back to.
8
+ *
9
+ * A subscription provider must be billed to the signed-in account or fail; a stray `XAI_API_KEY`
10
+ * in the parent environment would otherwise turn a signed-out run into metered API usage.
11
+ */
12
+ export declare function grokEnvironment(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
13
+ export interface GrokRunOptions {
14
+ files?: Record<string, string>;
15
+ captureStderr?: boolean;
16
+ acceptedExitCodes?: number[];
17
+ }
18
+ export type GrokRun = (args: (cwd: string) => string[], signal: AbortSignal, options?: GrokRunOptions) => Promise<{
19
+ stdout: string;
20
+ stderr: string;
21
+ }>;
22
+ export interface GrokDependencies {
23
+ run?: GrokRun;
24
+ }
25
+ export declare const runGrokProcess: GrokRun;
26
+ /** What `grok models` says about the sign-in and the catalog it serves. */
27
+ export declare function parseGrokModels(output: string): {
28
+ signedIn: boolean;
29
+ models: string[];
30
+ email?: string;
31
+ };
32
+ /** Read the CLI's sign-in state and model catalog without inference. */
33
+ export declare function readGrokCatalog(signal: AbortSignal, dependencies?: GrokDependencies): Promise<{
34
+ signedIn: boolean;
35
+ models: string[];
36
+ email?: string;
37
+ }>;
38
+ /**
39
+ * Accept one model step only, from the Messages-shaped stream the CLI prints.
40
+ *
41
+ * Any native tool the CLI exposed or the model called is refused: the step must come back as the
42
+ * structured object, and Andorra alone executes what it names.
43
+ */
44
+ export declare function parseGrokResponse(output: string, tools?: readonly Pick<ToolSchema, 'name'>[]): ModelResponse;
45
+ /** A text-only step: every assistant text block, in order, and nothing else. */
46
+ export declare function parseGrokText(output: string): ModelResponse;
47
+ /** Grok produces one model response; Andorra owns tool execution, graph state, and permissions. */
48
+ export declare function createGrokAdapter(_config: {
49
+ model: string;
50
+ }, dependencies?: GrokDependencies): ModelAdapter;
@@ -0,0 +1,186 @@
1
+ import { join } from 'node:path';
2
+ import { resolveCliExecutable } from './cli-executable.js';
3
+ import { runBoundedCli } from './cli-process.js';
4
+ import { allowanceInstruction, boundTextStep, parseStructuredStep, STRUCTURED_STEP_PROMPT, STRUCTURED_STEP_SCHEMA, structuredStepPrompt, TEXT_STEP_PROMPT } from './structured-step.js';
5
+ /** A marker, not an endpoint: requests go through the signed-in Grok CLI on this machine. */
6
+ export const GROK_BASE_URL = 'https://api.x.ai';
7
+ export const GROK_EXECUTABLE = {
8
+ names: ['grok'], overrideEnv: 'ANDORRA_GROK_PATH', homeDirectories: [join('.grok', 'bin')],
9
+ installMessage: 'Install the Grok CLI from x.ai, sign in, then retry the Grok provider.',
10
+ };
11
+ const SIGN_IN_MESSAGE = 'Sign in to Grok (grok login) on this machine, then retry the Grok provider.';
12
+ const REQUEST_TIMEOUT_MS = 10 * 60_000;
13
+ const CATALOG_TIMEOUT_MS = 30_000;
14
+ /**
15
+ * The child environment: the parent's, minus every xAI key the CLI would fall back to.
16
+ *
17
+ * A subscription provider must be billed to the signed-in account or fail; a stray `XAI_API_KEY`
18
+ * in the parent environment would otherwise turn a signed-out run into metered API usage.
19
+ */
20
+ export function grokEnvironment(source = process.env) {
21
+ const env = Object.fromEntries(Object.entries(source).filter(([key]) => !/^(?:XAI_|GROK_API_KEY$|NODE_OPTIONS$)/i.test(key)));
22
+ return { ...env, GROK_DISABLE_AUTOUPDATER: '1', NO_COLOR: '1' };
23
+ }
24
+ export const runGrokProcess = async (args, signal, options = {}) => {
25
+ const executable = await resolveCliExecutable(GROK_EXECUTABLE);
26
+ return runBoundedCli(executable, args, signal, { env: grokEnvironment(), label: 'Grok CLI', ...options });
27
+ };
28
+ /** What `grok models` says about the sign-in and the catalog it serves. */
29
+ export function parseGrokModels(output) {
30
+ const plain = output.replace(/\u001b\[[0-9;]*m/g, '');
31
+ const models = [];
32
+ for (const line of plain.split(/\r?\n/)) {
33
+ const bullet = line.match(/^\s*[*-]\s+(\S+)/);
34
+ if (bullet?.[1] && !models.includes(bullet[1]) && models.length < 1000)
35
+ models.push(bullet[1]);
36
+ }
37
+ const signedOut = /\bnot (?:authenticated|signed in|logged in)\b/i.test(plain);
38
+ const email = plain.match(/\b(?:logged|signed) in as\s+([^\s@]+@[^\s@]+\.[^\s.,;)]+)/i)?.[1];
39
+ return { signedIn: !signedOut && models.length > 0, models: signedOut ? [] : models, ...(email && !signedOut ? { email } : {}) };
40
+ }
41
+ /** Read the CLI's sign-in state and model catalog without inference. */
42
+ export async function readGrokCatalog(signal, dependencies = {}) {
43
+ const run = dependencies.run ?? runGrokProcess;
44
+ const bounded = AbortSignal.any([signal, AbortSignal.timeout(CATALOG_TIMEOUT_MS)]);
45
+ // `models` takes no update flag; the environment already turns the updater off.
46
+ const { stdout, stderr } = await run(() => ['models'], bounded, { captureStderr: true, acceptedExitCodes: [0, 1] });
47
+ return parseGrokModels(`${stdout}\n${stderr}`);
48
+ }
49
+ function parseJson(text) {
50
+ try {
51
+ return JSON.parse(text);
52
+ }
53
+ catch {
54
+ throw new Error('Grok CLI returned malformed JSON');
55
+ }
56
+ }
57
+ function frames(text) { return text.split(/\r?\n/).filter(line => line.trim().startsWith('{')).map(parseJson); }
58
+ /** Messages API usage; `input_tokens` is uncached only, so both cache buckets join it. */
59
+ function grokUsage(usage) {
60
+ if (!usage || typeof usage !== 'object')
61
+ return undefined;
62
+ const token = (name) => Number.isSafeInteger(usage[name]) && usage[name] >= 0 ? usage[name] : undefined;
63
+ const input = token('input_tokens');
64
+ const output = token('output_tokens');
65
+ const read = token('cache_read_input_tokens');
66
+ const created = token('cache_creation_input_tokens');
67
+ // An all-zero ledger means the CLI could not account for the turn, not that it was free.
68
+ if (!input && !output && !read && !created)
69
+ return { requests: 1 };
70
+ return { requests: 1,
71
+ ...(input === undefined ? {} : { inputTokens: input + (read ?? 0) + (created ?? 0) }),
72
+ ...(output === undefined ? {} : { outputTokens: output }),
73
+ ...(read === undefined ? {} : { cacheRead: read }), ...(created === undefined ? {} : { cacheWrite: created }) };
74
+ }
75
+ function failure(message) {
76
+ if (typeof message === 'string' && /not (?:signed in|authenticated|logged in)/i.test(message))
77
+ return new Error(SIGN_IN_MESSAGE);
78
+ return new Error('Grok inference failed. Check its sign-in, model access, and subscription limits.');
79
+ }
80
+ const STRUCTURED_TOOL = /^structured_?output$/i;
81
+ /**
82
+ * Accept one model step only, from the Messages-shaped stream the CLI prints.
83
+ *
84
+ * Any native tool the CLI exposed or the model called is refused: the step must come back as the
85
+ * structured object, and Andorra alone executes what it names.
86
+ */
87
+ export function parseGrokResponse(output, tools = []) {
88
+ const events = frames(output);
89
+ const error = events.find(frame => frame?.type === 'error');
90
+ if (error)
91
+ throw failure(error.message);
92
+ for (const event of events.filter(frame => frame?.type === 'system' && frame.subtype === 'init')) {
93
+ if (event.tools !== undefined && (!Array.isArray(event.tools) || event.tools.some((name) => typeof name !== 'string' || !STRUCTURED_TOOL.test(name)))) {
94
+ throw new Error('Grok exposed unexpected native tools');
95
+ }
96
+ }
97
+ for (const event of events.filter(frame => frame?.type === 'assistant')) {
98
+ if (event.parent_tool_use_id || !Array.isArray(event.message?.content))
99
+ throw new Error('Grok returned an invalid assistant step');
100
+ if (event.message.content.some((block) => (block?.type === 'tool_use' || block?.type === 'server_tool_use') && !STRUCTURED_TOOL.test(String(block.name)))) {
101
+ throw new Error('Grok attempted a native tool');
102
+ }
103
+ }
104
+ const results = events.filter(frame => frame?.type === 'result');
105
+ if (results.length !== 1)
106
+ throw new Error('Grok did not return exactly one model result');
107
+ const result = results[0];
108
+ if (result.is_error !== false || result.subtype !== 'success')
109
+ throw failure(Array.isArray(result.errors) ? result.errors.join(' ') : result.result);
110
+ let structured = result.structured_output;
111
+ if (structured === undefined && typeof result.result === 'string') {
112
+ try {
113
+ structured = JSON.parse(result.result);
114
+ }
115
+ catch { /* reported below */ }
116
+ }
117
+ if (structured === undefined)
118
+ throw new Error('Grok did not return a complete Andorra model step');
119
+ const response = parseStructuredStep(structured, tools, 'Grok');
120
+ const usage = grokUsage(result.usage);
121
+ if (usage)
122
+ response.usage = usage;
123
+ return response;
124
+ }
125
+ /** A text-only step: every assistant text block, in order, and nothing else. */
126
+ export function parseGrokText(output) {
127
+ const events = frames(output);
128
+ const error = events.find(frame => frame?.type === 'error');
129
+ if (error)
130
+ throw failure(error.message);
131
+ const results = events.filter(frame => frame?.type === 'result');
132
+ if (results.length !== 1 || results[0].is_error !== false || results[0].subtype !== 'success')
133
+ throw failure(results[0]?.result);
134
+ const texts = [];
135
+ for (const event of events.filter(frame => frame?.type === 'assistant')) {
136
+ for (const block of Array.isArray(event.message?.content) ? event.message.content : []) {
137
+ if (block?.type === 'text' && typeof block.text === 'string')
138
+ texts.push(block.text);
139
+ else if (block?.type === 'tool_use' || block?.type === 'server_tool_use')
140
+ throw new Error('Grok attempted a tool during text generation');
141
+ }
142
+ }
143
+ const text = texts.length ? texts.join('') : typeof results[0].result === 'string' ? results[0].result : '';
144
+ const usage = grokUsage(results[0].usage);
145
+ return { text, toolCalls: [], ...(usage ? { usage } : {}) };
146
+ }
147
+ /** Flags that leave the CLI a bare model: no built-in tools, subagents, memory, plans, search or updates. */
148
+ const ISOLATION_ARGS = ['--tools', '', '--disallowed-tools', 'Agent', '--no-subagents', '--no-memory', '--no-plan',
149
+ '--disable-web-search', '--no-auto-update', '--permission-mode', 'dontAsk', '--max-turns', '1', '--verbatim'];
150
+ /** Grok produces one model response; Andorra owns tool execution, graph state, and permissions. */
151
+ export function createGrokAdapter(_config, dependencies = {}) {
152
+ const run = dependencies.run ?? runGrokProcess;
153
+ return {
154
+ async listModels(signal) {
155
+ const catalog = await readGrokCatalog(signal, dependencies);
156
+ if (!catalog.signedIn)
157
+ throw new Error(SIGN_IN_MESSAGE);
158
+ return catalog.models;
159
+ },
160
+ async generate(request) {
161
+ request.signal.throwIfAborted();
162
+ const auxiliary = request.maxTokens !== undefined;
163
+ if (auxiliary && (!Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1))
164
+ throw new Error('Invalid auxiliary output allowance.');
165
+ if (auxiliary && request.tools.length)
166
+ throw new Error('Grok cannot apply an auxiliary output allowance to tool-bearing requests.');
167
+ const signal = AbortSignal.any([request.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
168
+ const imageCount = request.messages.reduce((total, message) => total + (message.images?.length ?? 0), 0);
169
+ // The prompt travels in a file: a conversation outgrows the Windows command-line limit, and the
170
+ // CLI does not read stdin in headless mode. Images cannot be forwarded through it yet, so the
171
+ // model is told how many were left out rather than reasoning as if it had seen them.
172
+ const prompt = JSON.stringify({ ...JSON.parse(structuredStepPrompt(request)),
173
+ ...(imageCount ? { omittedImages: `This provider cannot forward images; ${imageCount} image${imageCount === 1 ? ' was' : 's were'} omitted from the conversation.` } : {}) });
174
+ request.onRequest?.();
175
+ const { stdout } = await run(cwd => ['--prompt-file', join(cwd, 'prompt.json'), '--output-format', 'streaming-messages-json',
176
+ '-m', request.model, ...ISOLATION_ARGS,
177
+ ...(auxiliary ? ['--system-prompt-override', `${TEXT_STEP_PROMPT} ${allowanceInstruction(request.maxTokens)}`] : ['--json-schema', JSON.stringify(STRUCTURED_STEP_SCHEMA), '--system-prompt-override', STRUCTURED_STEP_PROMPT])], signal, { files: { 'prompt.json': prompt }, acceptedExitCodes: [0, 1] });
178
+ signal.throwIfAborted();
179
+ if (!auxiliary)
180
+ return parseGrokResponse(stdout, request.tools);
181
+ // The CLI has no output cap, so the allowance is stated above and enforced on the answer.
182
+ const text = parseGrokText(stdout);
183
+ return boundTextStep(text, request.maxTokens, text.usage?.outputTokens);
184
+ },
185
+ };
186
+ }
@@ -29,6 +29,19 @@ export interface ValueScope {
29
29
  export declare function validateMappingConstants(graph: unknown): void;
30
30
  export declare function validateSchema(schema: unknown, path?: string, depth?: number): asserts schema is JsonSchema;
31
31
  export declare function validateValue(schema: JsonSchema, value: unknown, path?: string): void;
32
+ /** A mapping read a value its scope does not hold (an omitted optional field, unset state). */
33
+ export declare class MissingReferenceError extends Error {
34
+ }
32
35
  export declare function resolveValue(expression: ValueExpression, scope: ValueScope): unknown;
36
+ /**
37
+ * Whether a mapping failure only means the input is absent. validateMappings refuses to map a field
38
+ * the source schema marks optional into a required destination input, and accepts it into an
39
+ * optional one, so the runtime honours the same contract: a missing value for an optional input
40
+ * leaves the input out and the target runs, while one for a required input (reachable only through
41
+ * an open source schema) still stops the run.
42
+ */
43
+ export declare function isAbsentOptionalInput(error: unknown, key: string, inputSchema: JsonSchema | undefined): boolean;
44
+ /** Resolve a node's or edge's input mapping into the target's inputs, leaving absent optional inputs out. */
45
+ export declare function resolveMapping(mapping: Record<string, ValueExpression> | undefined, scope: ValueScope, inputSchema: JsonSchema | undefined): Record<string, unknown>;
33
46
  export declare function schemaAt(schema: JsonSchema | undefined, keys: string[], label: string, requirePresent?: boolean): JsonSchema | undefined;
34
47
  export declare function validateMappings(graph: Graph): void;
@@ -115,6 +115,9 @@ export function validateValue(schema, value, path = 'value') {
115
115
  for (const [i, item] of value.entries())
116
116
  validateValue(schema.items, item, `${path}[${i}]`);
117
117
  }
118
+ /** A mapping read a value its scope does not hold (an omitted optional field, unset state). */
119
+ export class MissingReferenceError extends Error {
120
+ }
118
121
  export function resolveValue(expression, scope) {
119
122
  if (object(expression) && Object.keys(expression).length === 1 && Object.hasOwn(expression, 'constant'))
120
123
  return structuredClone(expression.constant);
@@ -122,12 +125,39 @@ export function resolveValue(expression, scope) {
122
125
  throw new Error('Invalid input expression: use $source.output.field, $source.artifacts, $run.input.field, $run.state.field, $run.loop.iteration or {constant: value}');
123
126
  let value = scope;
124
127
  for (const key of expression.slice(1).split('.')) {
125
- if (['__proto__', 'constructor', 'prototype'].includes(key) || (!object(value) && !Array.isArray(value)) || !Object.hasOwn(value, key))
128
+ if (['__proto__', 'constructor', 'prototype'].includes(key))
126
129
  throw new Error(`Input mapping ${expression}: referenced value is missing`);
130
+ if ((!object(value) && !Array.isArray(value)) || !Object.hasOwn(value, key))
131
+ throw new MissingReferenceError(`Input mapping ${expression}: referenced value is missing`);
127
132
  value = value[key];
128
133
  }
129
134
  return structuredClone(value);
130
135
  }
136
+ /**
137
+ * Whether a mapping failure only means the input is absent. validateMappings refuses to map a field
138
+ * the source schema marks optional into a required destination input, and accepts it into an
139
+ * optional one, so the runtime honours the same contract: a missing value for an optional input
140
+ * leaves the input out and the target runs, while one for a required input (reachable only through
141
+ * an open source schema) still stops the run.
142
+ */
143
+ export function isAbsentOptionalInput(error, key, inputSchema) {
144
+ return error instanceof MissingReferenceError && !inputSchema?.required?.includes(key);
145
+ }
146
+ /** Resolve a node's or edge's input mapping into the target's inputs, leaving absent optional inputs out. */
147
+ export function resolveMapping(mapping, scope, inputSchema) {
148
+ const inputs = {};
149
+ for (const [key, expression] of Object.entries(mapping ?? {})) {
150
+ try {
151
+ inputs[key] = resolveValue(expression, scope);
152
+ }
153
+ catch (error) {
154
+ if (isAbsentOptionalInput(error, key, inputSchema))
155
+ continue;
156
+ throw error;
157
+ }
158
+ }
159
+ return inputs;
160
+ }
131
161
  export function schemaAt(schema, keys, label, requirePresent = false) {
132
162
  let current = schema;
133
163
  for (const key of keys) {
@@ -0,0 +1,38 @@
1
+ import { CliSignIn, type ManagedSignInState } from './cli-sign-in.js';
2
+ import { type OpenCodeServerLike, type OpenCodeSignInOption } from './opencode-cli-provider.js';
3
+ /** Claude subscription sign-in through the official Claude Code CLI's own login. */
4
+ export declare function claudeSignIn(): CliSignIn;
5
+ /** Grok subscription sign-in through the Grok CLI's device-code login, which opens no browser itself. */
6
+ export declare function grokSignIn(): CliSignIn;
7
+ /** OpenCode's state: the upstream providers it has connected, and the browser sign-ins it offers. */
8
+ export interface OpenCodeSignInState extends ManagedSignInState {
9
+ connected?: {
10
+ id: string;
11
+ name: string;
12
+ }[];
13
+ signInOptions?: OpenCodeSignInOption[];
14
+ /** The upstream provider the attempt in progress signs in to. */
15
+ signInProvider?: string;
16
+ }
17
+ /**
18
+ * Sign-in to an upstream provider inside OpenCode, through its local server.
19
+ *
20
+ * OpenCode runs the OAuth exchange and stores the credential where its CLI keeps it; Andorra asks
21
+ * the server to begin, opens the page it names, and waits for — or forwards the code to — its
22
+ * callback. The connected providers are whatever OpenCode reports afterwards.
23
+ */
24
+ export declare class OpenCodeSignIn {
25
+ private readonly server;
26
+ private attempt?;
27
+ private closed;
28
+ constructor(server?: () => OpenCodeServerLike);
29
+ private overview;
30
+ status(attemptId?: string): Promise<OpenCodeSignInState>;
31
+ start(attemptId: string, providerId: unknown, method: unknown): Promise<OpenCodeSignInState>;
32
+ private finish;
33
+ submitCode(attemptId: string, code: string): Promise<OpenCodeSignInState>;
34
+ cancel(attemptId: string): Promise<OpenCodeSignInState>;
35
+ /** Sign one upstream provider out of OpenCode. */
36
+ logout(providerId: unknown): Promise<OpenCodeSignInState>;
37
+ close(): Promise<void>;
38
+ }
@@ -0,0 +1,169 @@
1
+ import { resolveCliExecutable } from './cli-executable.js';
2
+ import { CliSignIn } from './cli-sign-in.js';
3
+ import { claudeEnvironment, readClaudeSignIn } from './claude-provider.js';
4
+ import { resolveClaudeExecutable } from './claude-executable.js';
5
+ import { GROK_EXECUTABLE, grokEnvironment, readGrokCatalog } from './grok-provider.js';
6
+ import { authorizeOpenCode, completeOpenCode, listOpenCodeSignIns, readOpenCodeCatalog, sharedOpenCodeServer, signOutOpenCode, } from './opencode-cli-provider.js';
7
+ /** Claude subscription sign-in through the official Claude Code CLI's own login. */
8
+ export function claudeSignIn() {
9
+ return new CliSignIn({
10
+ product: 'Claude',
11
+ resolveExecutable: async () => ({ command: await resolveClaudeExecutable(), args: [] }),
12
+ env: () => claudeEnvironment(),
13
+ loginArgs: ['auth', 'login', '--claudeai'],
14
+ logoutArgs: ['auth', 'logout'],
15
+ status: signal => readClaudeSignIn(signal),
16
+ pageHosts: ['claude.com', 'claude.ai', 'anthropic.com'],
17
+ acceptsCode: true,
18
+ });
19
+ }
20
+ /** Grok subscription sign-in through the Grok CLI's device-code login, which opens no browser itself. */
21
+ export function grokSignIn() {
22
+ return new CliSignIn({
23
+ product: 'Grok',
24
+ resolveExecutable: () => resolveCliExecutable(GROK_EXECUTABLE),
25
+ env: () => grokEnvironment(),
26
+ loginArgs: ['login', '--device-auth'],
27
+ logoutArgs: ['logout'],
28
+ status: signal => readGrokCatalog(signal),
29
+ pageHosts: ['x.ai', 'grok.com'],
30
+ deviceCode: true,
31
+ });
32
+ }
33
+ /**
34
+ * Sign-in to an upstream provider inside OpenCode, through its local server.
35
+ *
36
+ * OpenCode runs the OAuth exchange and stores the credential where its CLI keeps it; Andorra asks
37
+ * the server to begin, opens the page it names, and waits for — or forwards the code to — its
38
+ * callback. The connected providers are whatever OpenCode reports afterwards.
39
+ */
40
+ export class OpenCodeSignIn {
41
+ server;
42
+ attempt;
43
+ closed = false;
44
+ constructor(server = sharedOpenCodeServer) {
45
+ this.server = server;
46
+ }
47
+ async overview(signal) {
48
+ const [catalog, options] = await Promise.all([readOpenCodeCatalog(signal, this.server()), listOpenCodeSignIns(signal, this.server())]);
49
+ return { connected: catalog.connected, signInOptions: options };
50
+ }
51
+ async status(attemptId) {
52
+ const attempt = this.attempt;
53
+ if (attemptId !== undefined) {
54
+ if (attempt?.id !== attemptId)
55
+ return { state: 'cancelled', attemptId, message: 'This OpenCode sign-in attempt is no longer active.' };
56
+ if (attempt.live)
57
+ return { ...attempt.view };
58
+ }
59
+ try {
60
+ const overview = await this.overview(AbortSignal.timeout(45_000));
61
+ if (attemptId !== undefined && attempt)
62
+ return { ...attempt.view, ...overview };
63
+ // OpenCode is usable as soon as it serves a model, including its own free tier.
64
+ return { state: overview.connected?.length ? 'signedIn' : 'signedOut', ...overview };
65
+ }
66
+ catch (error) {
67
+ return { state: 'error', reason: 'unavailable', message: error instanceof Error ? error.message : 'OpenCode is unavailable.' };
68
+ }
69
+ }
70
+ async start(attemptId, providerId, method) {
71
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(attemptId))
72
+ return { state: 'error', reason: 'unsupported', message: 'A valid sign-in attempt ID is required.' };
73
+ if (typeof providerId !== 'string' || typeof method !== 'number')
74
+ return { state: 'error', reason: 'unsupported', attemptId, message: 'Choose a provider to sign in to through OpenCode.' };
75
+ if (this.closed)
76
+ return { state: 'error', reason: 'unavailable', attemptId, message: 'The OpenCode sign-in service has closed.' };
77
+ if (this.attempt?.id === attemptId)
78
+ return { ...this.attempt.view };
79
+ if (this.attempt?.live)
80
+ return { state: 'error', reason: 'busy', attemptId, message: 'Another OpenCode sign-in is already in progress. Finish or cancel it first.' };
81
+ const controller = new AbortController();
82
+ const attempt = { id: attemptId, providerId, method, live: true, controller, mode: 'auto',
83
+ view: { state: 'starting', attemptId, signInProvider: providerId } };
84
+ this.attempt = attempt;
85
+ let authorization;
86
+ try {
87
+ authorization = await authorizeOpenCode(providerId, method, AbortSignal.any([controller.signal, AbortSignal.timeout(60_000)]), this.server());
88
+ }
89
+ catch (error) {
90
+ attempt.live = false;
91
+ attempt.view = { state: 'error', reason: 'unavailable', attemptId, message: error instanceof Error ? error.message : 'OpenCode could not start that sign-in.' };
92
+ return { ...attempt.view };
93
+ }
94
+ attempt.mode = authorization.method;
95
+ // A device flow (GitHub Copilot, for one) names the code to confirm inside its instructions; it
96
+ // is lifted out so the panel can show it as prominently as a CLI's own device code.
97
+ const userCode = authorization.instructions?.match(/\b([A-Z0-9]{4,5}-[A-Z0-9]{4,5})\b/)?.[1];
98
+ attempt.view = { state: 'waiting', attemptId, signInProvider: providerId, ...(authorization.method === 'code' ? { acceptsCode: true } : {}),
99
+ ...(userCode ? { userCode } : {}), ...(authorization.instructions ? { message: authorization.instructions } : {}) };
100
+ // The automatic flow completes on OpenCode's own loopback callback; this call returns when it has.
101
+ if (authorization.method === 'auto')
102
+ void this.finish(attempt, undefined);
103
+ return { ...attempt.view, authUrl: authorization.url };
104
+ }
105
+ async finish(attempt, code) {
106
+ try {
107
+ const done = await completeOpenCode(attempt.providerId, attempt.method, code, AbortSignal.any([attempt.controller.signal, AbortSignal.timeout(10 * 60_000)]), this.server());
108
+ if (!attempt.live)
109
+ return;
110
+ attempt.view = done ? { state: 'signedIn', attemptId: attempt.id, signInProvider: attempt.providerId }
111
+ : { state: 'error', reason: 'denied', attemptId: attempt.id, message: 'OpenCode sign-in did not complete. Try again.' };
112
+ }
113
+ catch {
114
+ if (!attempt.live)
115
+ return;
116
+ attempt.view = attempt.controller.signal.aborted ? attempt.view
117
+ : { state: 'error', reason: 'timeout', attemptId: attempt.id, message: 'OpenCode sign-in did not complete in time. Try again.' };
118
+ }
119
+ attempt.live = false;
120
+ }
121
+ async submitCode(attemptId, code) {
122
+ const attempt = this.attempt;
123
+ if (attempt?.id !== attemptId)
124
+ return { state: 'cancelled', attemptId, message: 'This OpenCode sign-in attempt is no longer active.' };
125
+ if (!attempt.live || attempt.mode !== 'code' || attempt.submitted)
126
+ return { ...attempt.view };
127
+ const value = code.trim();
128
+ if (!value || value.length > 2000 || /[\s\u0000-\u001f\u007f]/.test(value))
129
+ return { ...attempt.view, message: 'That code is not valid. Copy the whole code from the sign-in page.' };
130
+ // The exchange can outlast a request's deadline, so it finishes in the background and the
131
+ // panel's status polling reports the result.
132
+ attempt.submitted = true;
133
+ attempt.view = { ...attempt.view, acceptsCode: undefined, message: 'Checking the code with OpenCode…' };
134
+ void this.finish(attempt, value);
135
+ return { ...attempt.view };
136
+ }
137
+ async cancel(attemptId) {
138
+ const attempt = this.attempt;
139
+ if (attempt?.id !== attemptId)
140
+ return { state: 'cancelled', attemptId, message: 'This OpenCode sign-in attempt is no longer active.' };
141
+ if (attempt.live) {
142
+ attempt.view = { state: 'cancelled', attemptId, message: 'OpenCode sign-in cancelled.' };
143
+ attempt.live = false;
144
+ attempt.controller.abort();
145
+ }
146
+ return { ...attempt.view };
147
+ }
148
+ /** Sign one upstream provider out of OpenCode. */
149
+ async logout(providerId) {
150
+ if (this.attempt?.live)
151
+ return { state: 'error', reason: 'busy', message: 'An OpenCode sign-in is in progress. Finish or cancel it before signing out.' };
152
+ if (typeof providerId !== 'string')
153
+ return { state: 'error', reason: 'unsupported', message: 'Choose the provider to sign out of OpenCode.' };
154
+ try {
155
+ if (!await signOutOpenCode(providerId, AbortSignal.timeout(30_000), this.server()))
156
+ return { state: 'error', reason: 'logoutFailed', message: 'OpenCode could not sign out of that provider.' };
157
+ return await this.status();
158
+ }
159
+ catch {
160
+ return { state: 'error', reason: 'logoutFailed', message: 'OpenCode could not sign out of that provider.' };
161
+ }
162
+ }
163
+ async close() {
164
+ this.closed = true;
165
+ this.attempt?.controller.abort();
166
+ if (this.attempt)
167
+ this.attempt.live = false;
168
+ }
169
+ }
@@ -21,6 +21,11 @@ export interface RenderedMarkdown {
21
21
  export declare const CODE_GUTTER = "\u2506";
22
22
  /** Prefix marking a rendered heading line; `transcriptColor` maps it to white. */
23
23
  export declare const HEADING_PREFIX = "\u258C";
24
+ /**
25
+ * Whether a line ends the paragraph, so emphasis or a code span cannot span across it. Exported so
26
+ * completion parsing finds the same multi-line code spans the transcript renders.
27
+ */
28
+ export declare const interruptsParagraph: (line: string) => boolean;
24
29
  /**
25
30
  * Render an agent message for the transcript.
26
31
  * @param source - the message text, already stripped of control characters, with outer
@@ -245,8 +245,11 @@ function stripInlineMarkdown(text) {
245
245
  }
246
246
  /** The ASCII punctuation GFM lets a backslash escape. */
247
247
  const ESCAPABLE = new Set('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~');
248
- /** Whether a line ends the paragraph, so emphasis cannot span across it. */
249
- const interruptsParagraph = (line) => line.trim() === '' || NON_PARAGRAPH.test(line) || THEMATIC_BREAK.test(line) || SETEXT_UNDERLINE.test(line);
248
+ /**
249
+ * Whether a line ends the paragraph, so emphasis or a code span cannot span across it. Exported so
250
+ * completion parsing finds the same multi-line code spans the transcript renders.
251
+ */
252
+ export const interruptsParagraph = (line) => line.trim() === '' || NON_PARAGRAPH.test(line) || THEMATIC_BREAK.test(line) || SETEXT_UNDERLINE.test(line);
250
253
  /**
251
254
  * Mask emphasis spans that cross a soft line break before the prose is split into lines.
252
255
  * Line-level rendering cannot match delimiters across `\n`, which would leave both halves
package/dist/src/mcp.js CHANGED
@@ -3,6 +3,7 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
3
3
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { authorize } from './tools.js';
6
+ import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
6
7
  import { validateMcpServer } from './config.js';
7
8
  import { clipText } from './text.js';
8
9
  const MCP_CATALOG_MAX_BYTES = 16_000;
@@ -131,7 +132,17 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
131
132
  if (catalogBytes + discoveredBytes > MCP_CATALOG_MAX_BYTES)
132
133
  throw new Error('MCP catalog exceeds task metadata budget');
133
134
  discovered.push({ ...advertised, capability: 'external', executionMode: 'sequential', execute: async (args, callContext) => {
135
+ // MCP execution has no read-only enforcement: a call can change the workspace or the
136
+ // host, so plan mode refuses it the way it refuses QA host execution, rather than
137
+ // letting a per-call approval stand in for the plan the mode exists to require.
138
+ if (permissionMode(callContext) === 'plan')
139
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
134
140
  await authorize(mcpToolName(id, tool.name), { server: id, tool: tool.name, arguments: args }, callContext);
141
+ // Authorization may have been awaiting an approval when the run entered Plan.
142
+ // A per-call grant must never dispatch an unsandboxed external operation in Plan.
143
+ if (permissionMode(callContext) === 'plan')
144
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
145
+ callContext.signal.throwIfAborted();
135
146
  const result = await client.callTool({ name: tool.name, arguments: args }, undefined, { signal: callContext.signal, timeout: 60_000 });
136
147
  const rendered = clipText(JSON.stringify(result), 32_768);
137
148
  if (result.isError)
@@ -1,6 +1,12 @@
1
1
  import { type Graph } from './graphs.js';
2
2
  import type { TelemetryPlan } from './telemetry/schema.js';
3
- /** Every account's default graph has one agent and cannot delegate to additional agents. */
3
+ /**
4
+ * Every account's default graph has one agent and cannot delegate to additional agents.
5
+ *
6
+ * The selection id and the export name keep their `software-engineer` spellings for saved-run and
7
+ * saved-selection compatibility; the agent the user sees is the Andorra Agent, which handles general
8
+ * tasks and coding alike.
9
+ */
4
10
  export declare const SOFTWARE_ENGINEER_HARNESS: Graph;
5
11
  /** Reserved selection cannot collide with a saved graph's filesystem-safe id. */
6
12
  export declare const ANDORRA_GRAPH_SELECTION = ":andorra";
@@ -78,4 +84,5 @@ export declare function readGraphMembership(signal?: AbortSignal): Promise<Membe
78
84
  /** Called for every CLI run so a saved selection cannot bypass a membership downgrade. */
79
85
  export declare function loadAccessibleGraph(id?: string, signal?: AbortSignal, membership?: (signal?: AbortSignal, home?: string) => Promise<Membership>, options?: {
80
86
  bindProviders?: boolean;
87
+ allowDeleted?: boolean;
81
88
  }): Promise<Graph>;
@@ -1,4 +1,4 @@
1
- import { DEFAULT_HARNESS, loadGraph } from './graphs.js';
1
+ import { DEFAULT_HARNESS, GraphDeletedError, isDeletedGraph, loadGraph } from './graphs.js';
2
2
  import { AUTH_REFRESH_BUDGET_MS, AuthError, getAccessToken, getAuthConfiguration } from './auth/index.js';
3
3
  import { graphStorageDirectory } from './graph-account.js';
4
4
  import { configDirectory, loadConfig } from './config.js';
@@ -7,13 +7,19 @@ import { recordConfirmedPlan } from './telemetry/state.js';
7
7
  import { telemetryDirectory } from './telemetry/identity.js';
8
8
  import { bindPortableGraphProviders } from './graph-provider-portability.js';
9
9
  import { loadFreeTierGraph } from './graph-quota.js';
10
- /** Every account's default graph has one agent and cannot delegate to additional agents. */
10
+ /**
11
+ * Every account's default graph has one agent and cannot delegate to additional agents.
12
+ *
13
+ * The selection id and the export name keep their `software-engineer` spellings for saved-run and
14
+ * saved-selection compatibility; the agent the user sees is the Andorra Agent, which handles general
15
+ * tasks and coding alike.
16
+ */
11
17
  export const SOFTWARE_ENGINEER_HARNESS = {
12
18
  // Version 2 supports single-agent graphs; version 3 explicitly requires an intake Orchestrator.
13
- schemaVersion: 2, id: 'software-engineer', name: 'Software Engineer', revision: 1, entry: 'engineer',
19
+ schemaVersion: 2, id: 'software-engineer', name: 'Andorra Agent', revision: 1, entry: 'engineer',
14
20
  nodes: {
15
- engineer: { id: 'engineer', name: 'Software Engineer', type: 'agent', executor: 'react-basic',
16
- instruction: 'Inspect the workspace, implement the user\'s task, and verify changes with appropriate tools. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. If no pull request was created or its number is unknown, say so rather than guessing. Start new implementation work only when the user requests it.',
21
+ engineer: { id: 'engineer', name: 'Andorra Agent', type: 'agent', executor: 'react-basic',
22
+ instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. If no pull request was created or its number is unknown, say so rather than guessing. Start new implementation work only when the user requests it.',
17
23
  contextPolicy: { history: true }, jevEnabled: true,
18
24
  subagents: { enabled: false }, position: { x: 120, y: 120 } },
19
25
  done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
@@ -236,6 +242,10 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
236
242
  throw new PaidMembershipRequiredError();
237
243
  const directory = await graphStorageDirectory(undefined, access.subject);
238
244
  const graph = access.paid ? await loadGraph(id, undefined, directory) : await loadFreeTierGraph(id, directory);
245
+ // A deleted graph starts no new run. A resume passes allowDeleted: the session already ran it, and
246
+ // refusing it would leave that session impossible to resume.
247
+ if (!options.allowDeleted && isDeletedGraph(graph))
248
+ throw new GraphDeletedError(graph.name);
239
249
  // The graph's own provider references are resolved against this installation's providers, and a
240
250
  // reference to a provider that is gone fails the load. A run that overrides every node's model
241
251
  // sets those references aside, so it loads the graph without resolving them: the override is