@andorra-labs/code 0.1.5 → 0.1.7
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.
- package/dist/src/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +526 -41
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +36 -3
- package/dist/src/agent-mcp.js +114 -45
- package/dist/src/app-server/protocol.d.ts +57 -5
- package/dist/src/app-server/protocol.js +18 -1
- package/dist/src/app-server/workspace.d.ts +9 -1
- package/dist/src/app-server/workspace.js +50 -3
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1316 -221
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +18 -3
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +11 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +20 -5
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +84 -26
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +98 -53
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +15 -2
- package/dist/src/commands.js +14 -13
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +380 -17
- package/dist/src/config.d.ts +61 -0
- package/dist/src/config.js +276 -12
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/deadline.js +6 -0
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +8 -0
- package/dist/src/graph-server.js +76 -6
- package/dist/src/graph-sync.d.ts +65 -0
- package/dist/src/graph-sync.js +433 -13
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +272 -50
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +65 -12
- package/dist/src/graphs.d.ts +60 -5
- package/dist/src/graphs.js +191 -37
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +11 -2
- package/dist/src/powershell-pool.js +34 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +123 -20
- package/dist/src/pull-requests.js +334 -84
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +106 -7
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +8 -2
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +38 -0
- package/dist/src/terminal-ui.js +126 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +159 -20
- package/dist/src/trajectory.js +32 -12
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +28 -3
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +4 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +30 -3
- package/docs/guides/README.md +1 -0
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +11 -4
- package/docs/guides/graph-builder.md +9 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +4 -4
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
package/dist/src/handoffs.js
CHANGED
|
@@ -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)
|
|
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) {
|
|
@@ -2,11 +2,11 @@ import { type HardenedRunOptions } from './react-runtime.js';
|
|
|
2
2
|
import type { RunResult } from './runtime.js';
|
|
3
3
|
export type { HardenedRunOptions, ToolExecutionMode, BeforeToolCallContext, BeforeToolCallResult, AfterToolCallContext, AfterToolCallResult } from './react-runtime.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Questions mode retains its existing implementation in the same engine.
|
|
5
|
+
* The files a run starts with, as paths and sizes, so the first model turn can read what it needs
|
|
6
|
+
* instead of spending a turn on `ls`. Bounded in depth, entries and time spent; undefined for an
|
|
7
|
+
* empty or unreadable workspace. File names are workspace data, so the caller labels them untrusted.
|
|
9
8
|
*/
|
|
9
|
+
export declare function workspaceListing(root: string): Promise<string | undefined>;
|
|
10
10
|
export declare class AndorraAgentEngine {
|
|
11
11
|
execute(options: HardenedRunOptions): Promise<RunResult>;
|
|
12
12
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { applyToolMenu } from './decision/applyToolMenu.js';
|
|
3
5
|
import { answerOnlyTask } from './decision/optimizationPolicy.js';
|
|
4
6
|
import { AndorraAgentEngine as ReactEngine } from './react-runtime.js';
|
|
@@ -9,7 +11,7 @@ import { toolFamily } from './decision/toolFamilies.js';
|
|
|
9
11
|
import { redactSecrets } from './memory/redaction.js';
|
|
10
12
|
import { factTaskText } from './decision/facts.js';
|
|
11
13
|
import { isVerificationCheck } from './decision/checks.js';
|
|
12
|
-
import { FactContinuations, FACT_CONTINUATION_GUIDANCE, PREPARE_FINISH, taskConstraints, localCheckResult, prepareFinishArguments, prepareFinishDescription } from './decision/FactContinuations.js';
|
|
14
|
+
import { FactContinuations, FACT_CONTINUATION_GUIDANCE, FINISH_SUMMARY_DESCRIPTION, PREPARE_FINISH, taskConstraints, localCheckResult, prepareFinishArguments, prepareFinishDescription } from './decision/FactContinuations.js';
|
|
13
15
|
import { bypassGeneration } from './decision/ContinuationAdapter.js';
|
|
14
16
|
/**
|
|
15
17
|
* Facts select concrete continuations at the coding-adapter boundary; the one React engine still
|
|
@@ -17,6 +19,54 @@ import { bypassGeneration } from './decision/ContinuationAdapter.js';
|
|
|
17
19
|
* continuation returns requests: 0 and never invokes the actual coding adapter or its onRequest.
|
|
18
20
|
* Questions mode retains its existing implementation in the same engine.
|
|
19
21
|
*/
|
|
22
|
+
const LISTING_SKIP = new Set(['.git', 'node_modules', '.venv', 'venv', '__pycache__', 'dist', 'build', 'target', '.codegraph', '.andorra', '.pytest_cache', '.mypy_cache', '.next', 'coverage', '.DS_Store']);
|
|
23
|
+
const LISTING_FILES = 60;
|
|
24
|
+
/**
|
|
25
|
+
* The files a run starts with, as paths and sizes, so the first model turn can read what it needs
|
|
26
|
+
* instead of spending a turn on `ls`. Bounded in depth, entries and time spent; undefined for an
|
|
27
|
+
* empty or unreadable workspace. File names are workspace data, so the caller labels them untrusted.
|
|
28
|
+
*/
|
|
29
|
+
export async function workspaceListing(root) {
|
|
30
|
+
const lines = [];
|
|
31
|
+
let more = 0, visited = 0;
|
|
32
|
+
const walk = async (dir, rel, depth) => {
|
|
33
|
+
let entries;
|
|
34
|
+
try {
|
|
35
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (LISTING_SKIP.has(entry.name) || ++visited > 2000)
|
|
43
|
+
continue;
|
|
44
|
+
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
if (depth < 4)
|
|
47
|
+
await walk(join(dir, entry.name), path, depth + 1);
|
|
48
|
+
else
|
|
49
|
+
lines.length < LISTING_FILES ? lines.push(`${path}/`) : more++;
|
|
50
|
+
}
|
|
51
|
+
else if (entry.isFile()) {
|
|
52
|
+
if (lines.length >= LISTING_FILES) {
|
|
53
|
+
more++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
let size = 0;
|
|
57
|
+
try {
|
|
58
|
+
size = (await stat(join(dir, entry.name))).size;
|
|
59
|
+
}
|
|
60
|
+
catch { /* Listed without a size. */ }
|
|
61
|
+
lines.push(`${path} (${size})`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
await walk(root, '', 0);
|
|
66
|
+
if (!lines.length)
|
|
67
|
+
return undefined;
|
|
68
|
+
return `Untrusted workspace data. Files present when this run started, as path (bytes); read the ones you need directly instead of listing the directory first:\n${lines.join('\n')}${more ? `\n(${more} more not listed)` : ''}`;
|
|
69
|
+
}
|
|
20
70
|
export class AndorraAgentEngine {
|
|
21
71
|
async execute(options) {
|
|
22
72
|
const runId = options.runId ?? randomUUID();
|
|
@@ -63,34 +113,77 @@ export class AndorraAgentEngine {
|
|
|
63
113
|
});
|
|
64
114
|
// The shell the model actually has, for the description's example and bare-command repair.
|
|
65
115
|
const shell = permitted.find(t => t.exitZeroOnReturn)?.name ?? catalog('shell')?.name;
|
|
116
|
+
// What complete_agent would require beyond the answer itself. A node with one outcome and no
|
|
117
|
+
// output contract leaves the model nothing to choose, so the runtime fills those fields in.
|
|
118
|
+
const policy = options.completionPolicy;
|
|
119
|
+
const outcomes = policy ? policy.mode === 'single' ? [policy.outcome] : policy.outcomes : undefined;
|
|
120
|
+
const completionProperties = completionTool(options).parameters.properties;
|
|
66
121
|
const prepareFinish = {
|
|
67
122
|
name: PREPARE_FINISH, executionMode: 'sequential',
|
|
68
123
|
description: prepareFinishDescription(shell),
|
|
69
124
|
prepareArguments: args => prepareFinishArguments(args, { has: name => !!catalog(name), shell }),
|
|
70
125
|
parameters: { type: 'object', properties: {
|
|
71
|
-
checks: { type: 'array', maxItems: 8, items: { type: '
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
126
|
+
checks: { type: 'array', maxItems: 8, items: { type: 'string' }, description: 'Verification commands, one per entry, exactly as you would run each in the shell. [] when the verification is not a command.' },
|
|
127
|
+
summary: { type: 'string', description: FINISH_SUMMARY_DESCRIPTION },
|
|
128
|
+
...(outcomes && outcomes.length > 1 ? { outcome: completionProperties.outcome } : {}),
|
|
129
|
+
...(outcomes && options.outputSchema ? { output: completionProperties.output } : {}),
|
|
130
|
+
}, required: ['checks'], additionalProperties: false },
|
|
131
|
+
// The advertised shape is the short one. Earlier shapes (a nested completion, checks as tool
|
|
132
|
+
// calls) stay callable, and the plan itself is validated when it is staged, where a slip can be
|
|
133
|
+
// answered without discarding the summary the model already wrote.
|
|
134
|
+
validationParameters: { type: 'object' },
|
|
75
135
|
execute: async (args, context) => {
|
|
76
136
|
context.signal.throwIfAborted();
|
|
77
|
-
|
|
78
|
-
|
|
137
|
+
const given = args.completion;
|
|
138
|
+
const completion = given && typeof given === 'object' && !Array.isArray(given) ? { ...given } : undefined;
|
|
139
|
+
if (completion && outcomes) {
|
|
140
|
+
if (completion.outcome === undefined && outcomes.length === 1)
|
|
141
|
+
completion.outcome = outcomes[0];
|
|
142
|
+
if (completion.output === undefined && !options.outputSchema)
|
|
143
|
+
completion.output = {};
|
|
144
|
+
}
|
|
145
|
+
router.stage(completion ? { ...args, completion } : args, calls.at(-1)?.name === PREPARE_FINISH && calls.filter(c => c.name === PREPARE_FINISH).length === 1,
|
|
146
|
+
// Alone means nothing in the batch produced a result the model has not seen; a todo update does not.
|
|
147
|
+
calls.every(c => [PREPARE_FINISH, 'update_todos', 'update_widget'].includes(c.name)));
|
|
148
|
+
return 'Finish plan prepared, not completed. Required checks and normal completion validation still have to succeed. If a check fails, fix it and call prepare_finish again with the checks only; the saved summary is reused.';
|
|
79
149
|
},
|
|
80
150
|
};
|
|
151
|
+
const listing = await workspaceListing(options.context.workspace).catch(() => undefined);
|
|
152
|
+
/** The same message at the same early position in every request, so the cached prefix holds. */
|
|
153
|
+
const withListing = (messages) => {
|
|
154
|
+
const first = listing ? messages.findIndex(message => message.role === 'user') : -1;
|
|
155
|
+
return first < 0 ? messages : [...messages.slice(0, first + 1), { role: 'user', content: listing }, ...messages.slice(first + 1)];
|
|
156
|
+
};
|
|
81
157
|
const wrapAdapter = (adapter) => ({
|
|
82
158
|
...(adapter.listModels ? { listModels: adapter.listModels.bind(adapter) } : {}),
|
|
83
159
|
generate: bypassGeneration(async (request) => {
|
|
84
160
|
if (!request.tools.some(t => t.name === 'complete_agent'))
|
|
85
161
|
return adapter.generate(request);
|
|
86
162
|
const finishing = !steered && !opaqueProtocol && router.finishing;
|
|
163
|
+
const followUp = !steered && !opaqueProtocol && !finishing ? router.followUp : undefined;
|
|
164
|
+
const nudge = !steered && !opaqueProtocol && !finishing && !followUp ? router.nudge : undefined;
|
|
165
|
+
if (!opaqueProtocol)
|
|
166
|
+
request = { ...request, messages: withListing(request.messages) };
|
|
87
167
|
if (steered || opaqueProtocol)
|
|
88
168
|
request = { ...request, tools: request.tools.filter(t => t.name !== PREPARE_FINISH) };
|
|
89
169
|
router.modelResumed();
|
|
90
170
|
const response = await adapter.generate(finishing ? {
|
|
91
171
|
...request,
|
|
92
172
|
// Keep schemas stable for prefix caching. This is guidance, not a claimed bypass.
|
|
93
|
-
messages: [...request.messages, { role: 'user', content:
|
|
173
|
+
messages: [...request.messages, { role: 'user', content: router.hasDraft
|
|
174
|
+
// The answer exists already: submitting it costs a few tokens, writing it again costs it all.
|
|
175
|
+
? 'Runtime: the recorded required checks passed on the current workspace and no todo is open. Complete now: call prepare_finish alone with checks [] to submit the summary you already wrote; reopen a todo only for genuinely unfinished required work. Do not add discretionary QA.'
|
|
176
|
+
: 'Runtime: the recorded required checks passed on the current workspace and no todo is open. Complete now using complete_agent; reopen a todo only for genuinely unfinished required work. Do not add discretionary QA.' }],
|
|
177
|
+
mutableTail: (request.mutableTail ?? 0) + 1,
|
|
178
|
+
} : followUp ? {
|
|
179
|
+
...request,
|
|
180
|
+
messages: [...request.messages, { role: 'user', content: `Runtime: after your edits the runtime ran \`${followUp}\` again and it passed on the current workspace. If the task is complete, finish now: call prepare_finish alone with checks [] and your summary. Do not run that check again, do not update todos first (they are closed for you) and do not add discretionary QA. Continue working only if something the task requires is still missing.` }],
|
|
181
|
+
mutableTail: (request.mutableTail ?? 0) + 1,
|
|
182
|
+
} : nudge ? {
|
|
183
|
+
...request,
|
|
184
|
+
messages: [...request.messages, { role: 'user', content: nudge === 'after_write'
|
|
185
|
+
? 'Runtime: if these edits complete the task, verify and finish in one step: call prepare_finish now with the check commands and your summary. The runtime runs the checks, returns their output to you if one fails, and submits the summary if they pass, so do not run them yourself first. If required work remains, continue with it instead.'
|
|
186
|
+
: 'Runtime: when your next edits should fix this, put prepare_finish (the check commands and your summary) last in that same batch. The runtime then runs the checks and finishes if they pass, or returns their output to you.' }],
|
|
94
187
|
mutableTail: (request.mutableTail ?? 0) + 1,
|
|
95
188
|
} : request);
|
|
96
189
|
calls = response.toolCalls;
|
|
@@ -153,6 +246,11 @@ export class AndorraAgentEngine {
|
|
|
153
246
|
acceptedAutomatic = automatic;
|
|
154
247
|
router.completionAccepted();
|
|
155
248
|
}
|
|
249
|
+
if (ours && event.type === 'node.tool.completed' && typeof d.toolCallId === 'string' && typeof d.durationMs === 'number') {
|
|
250
|
+
const seen = observed.get(d.toolCallId);
|
|
251
|
+
if (seen)
|
|
252
|
+
seen.durationMs = d.durationMs;
|
|
253
|
+
}
|
|
156
254
|
if (ours && ['node.tool.completed', 'node.tool.failed', 'node.tool.skipped'].includes(event.type) && typeof d.toolCallId === 'string' && !observed.has(d.toolCallId)) {
|
|
157
255
|
const call = calls.find(c => c.id === d.toolCallId);
|
|
158
256
|
if (call) {
|
|
@@ -237,7 +335,9 @@ export class AndorraAgentEngine {
|
|
|
237
335
|
const observation = { call: call.toolCall, args: call.args, output: safe,
|
|
238
336
|
isError: after?.isError ?? call.isError, executionSucceeded: !call.isError,
|
|
239
337
|
truncated: safe !== projected || projected !== output || clipped,
|
|
240
|
-
family: toolFamily(call.tool), readOnly: retrySafe(call.tool)
|
|
338
|
+
family: toolFamily(call.tool), readOnly: retrySafe(call.tool),
|
|
339
|
+
// A shell that returns only on exit 0 is exact evidence for any command it ran.
|
|
340
|
+
...(!(after?.isError ?? call.isError) && call.tool.exitZeroOnReturn ? { exitCode: 0 } : {}) };
|
|
241
341
|
// Structured QA status is exact local evidence even when its privacy projection omits
|
|
242
342
|
// source details. Only the projected, redacted form may ever be sent to Jev.
|
|
243
343
|
if (isVerificationCheck(call.tool.name, observation.family, call.args)) {
|
|
@@ -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
|
+
}
|
package/dist/src/markdown.d.ts
CHANGED
|
@@ -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
|
package/dist/src/markdown.js
CHANGED
|
@@ -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
|
-
/**
|
|
249
|
-
|
|
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)
|
package/dist/src/membership.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type Graph } from './graphs.js';
|
|
2
2
|
import type { TelemetryPlan } from './telemetry/schema.js';
|
|
3
|
-
/**
|
|
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>;
|
package/dist/src/membership.js
CHANGED
|
@@ -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
|
-
/**
|
|
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: '
|
|
19
|
+
schemaVersion: 2, id: 'software-engineer', name: 'Andorra Agent', revision: 1, entry: 'engineer',
|
|
14
20
|
nodes: {
|
|
15
|
-
engineer: { id: 'engineer', name: '
|
|
16
|
-
instruction: '
|
|
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
|
|
@@ -5,6 +5,8 @@ import { readOpenCodeModels } from './opencode-catalog.js';
|
|
|
5
5
|
import { readCodexCatalog } from './codex-provider.js';
|
|
6
6
|
import { codexConnectFor } from './codex-rpc.js';
|
|
7
7
|
import { readClaudeCatalog } from './claude-provider.js';
|
|
8
|
+
import { readGrokCatalog } from './grok-provider.js';
|
|
9
|
+
import { readOpenCodeCatalog } from './opencode-cli-provider.js';
|
|
8
10
|
/** Resolve metadata for a specific model without borrowing another model's saved limit. */
|
|
9
11
|
export async function resolveModelContext(provider, model, signal) {
|
|
10
12
|
return refreshModelContext(configuredModelSnapshot(provider, model), signal);
|
|
@@ -47,7 +49,7 @@ export function withEvaluationReasoningEffort(snapshot, effort) {
|
|
|
47
49
|
export async function refreshModelContext(provider, signal) {
|
|
48
50
|
const snapshot = configuredModelSnapshot(provider, undefined);
|
|
49
51
|
signal.throwIfAborted();
|
|
50
|
-
if (snapshot.type === 'codex' || snapshot.type === 'claude')
|
|
52
|
+
if (snapshot.type === 'codex' || snapshot.type === 'claude' || snapshot.type === 'grok')
|
|
51
53
|
return snapshot;
|
|
52
54
|
try {
|
|
53
55
|
const models = await discoverModelMetadata(snapshot, signal);
|
|
@@ -102,6 +104,14 @@ export async function discoverModelMetadata(provider, signal) {
|
|
|
102
104
|
return (await readCodexCatalog(signal, codexConnectFor(provider))).models.map(id => ({ id }));
|
|
103
105
|
if (provider.type === 'claude')
|
|
104
106
|
return (await readClaudeCatalog(signal)).models.map(id => ({ id }));
|
|
107
|
+
if (provider.type === 'grok') {
|
|
108
|
+
const catalog = await readGrokCatalog(signal);
|
|
109
|
+
if (!catalog.signedIn)
|
|
110
|
+
throw new Error('Sign in to Grok on this machine before listing its models.');
|
|
111
|
+
return catalog.models.map(id => ({ id }));
|
|
112
|
+
}
|
|
113
|
+
if (provider.type === 'opencode')
|
|
114
|
+
return (await readOpenCodeCatalog(signal)).models.map(model => ({ id: model.id, ...(model.contextWindow ? { contextWindow: model.contextWindow } : {}) }));
|
|
105
115
|
if (provider.type === 'opencode-go')
|
|
106
116
|
return readOpenCodeModels(signal, fetch, provider.requestTimeoutMs);
|
|
107
117
|
// A listing is bounded by the same ceiling the adapter uses, and by a provider that asked for
|
|
@@ -252,8 +262,10 @@ export async function discoverModelMetadata(provider, signal) {
|
|
|
252
262
|
}
|
|
253
263
|
}
|
|
254
264
|
signal.throwIfAborted();
|
|
265
|
+
// A catalog with any SparkDeck entry is a SparkDeck server, which has no LM Studio
|
|
266
|
+
// listing; its other entries (embedding models under their upstream owner) stay unknown.
|
|
255
267
|
if (provider.type === 'openai-compatible' && base.hostname !== 'api.openai.com' && /\/v1\/?$/.test(base.pathname)
|
|
256
|
-
&& models.some(model => model.contextWindow === undefined
|
|
268
|
+
&& sparkdeckModels.size === 0 && models.some(model => model.contextWindow === undefined)) {
|
|
257
269
|
// Optional LM Studio native metadata, confined to the same origin/path
|
|
258
270
|
// prefix. No redirect following, extra credentials, or broad server probes.
|
|
259
271
|
const native = new URL(base);
|