@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
|
@@ -16,7 +16,19 @@ const bundled = [
|
|
|
16
16
|
{ id: 'andorra:ai-elements', path: 'ai-elements/SKILL.md', description: 'Build AI chat interfaces using Vercel AI Elements; read relevant references lazily.', source: 'bundled' },
|
|
17
17
|
{ id: 'andorra:web-gui-tester', path: 'web-gui-tester/SKILL.md', description: 'Test web interfaces through observed GUI actions, DOM checks and visual evidence.', source: 'bundled', requiredTools: ['qa.browser_session'] },
|
|
18
18
|
{ id: 'andorra:control-browser', path: 'control-browser/SKILL.md', description: 'Use the available persistent browser runtime to navigate, inspect and interact with web pages.', source: 'bundled', requiredTools: ['qa.browser_session'] },
|
|
19
|
+
// Andorra's own setup skills: written for the agent, typeable as /name, loaded on matching requests.
|
|
20
|
+
{ id: 'andorra:manage-mcp', path: 'manage-mcp/SKILL.md', description: "Add, change, test, turn off or remove an MCP server in Andorra Code. Use when the user wants to connect a tool server (GitHub, a database, a browser, an internal API), asks why an MCP server's tools are missing, or wants one disconnected.", source: 'bundled' },
|
|
21
|
+
{ id: 'andorra:create-skill', path: 'create-skill/SKILL.md', description: "Write a new Andorra Code skill: a SKILL.md that tells an agent how to do a recurring task. Use when the user wants to capture a workflow, checklist or house style as a reusable /command, or asks how to make a skill.", source: 'bundled' },
|
|
22
|
+
{ id: 'andorra:manage-skills', path: 'manage-skills/SKILL.md', description: "List, install, turn on or off, and remove Andorra Code skills and plugins. Use when the user asks what skills they have, wants to add a skill from GitHub or a folder, disable one, or clean up skills they no longer use.", source: 'bundled' },
|
|
23
|
+
{ id: 'andorra:create-agent', path: 'create-agent/SKILL.md', description: "Design a reusable Andorra Code Agent (a role with its own instructions, model, capabilities and input/output contract) and produce a file the user imports into their Agent library. Use when the user wants a custom reviewer, tester, researcher or other role to reuse across graphs.", source: 'bundled' },
|
|
24
|
+
{ id: 'andorra:doctor', path: 'doctor/SKILL.md', description: "Check that Andorra Code is set up and healthy: Node, sign-in, configuration, providers, MCP servers, disk space. Use when something does not work (no models, tools missing, sign-in errors, tasks failing at start) or the user asks to check their setup.", source: 'bundled' },
|
|
25
|
+
{ id: 'andorra:write-instructions', path: 'write-instructions/SKILL.md', description: "Create or improve a repository's agent instructions (ANDORRA.md or AGENTS.md): build and test commands, conventions, and rules agents must follow. Use when the user wants agents to work the way their team does, or asks to set up or tighten project instructions.", source: 'bundled' },
|
|
26
|
+
{ id: 'andorra:graph-manager', path: 'graph-manager/SKILL.md', description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent workflows) from the user's requirements, through Andorra's graph MCP tools. Use when the user wants a new workflow, wants to change how an existing graph routes work, or wants a graph removed or brought back.", source: 'bundled' },
|
|
19
27
|
];
|
|
28
|
+
/** Andorra's own skills, as registered: what a person can type and the agent can load by id. */
|
|
29
|
+
export function bundledSkillCatalog() {
|
|
30
|
+
return bundled.map(({ id, description, path, requiredTools }) => ({ id, description, path, ...(requiredTools ? { requiredTools: [...requiredTools] } : {}) }));
|
|
31
|
+
}
|
|
20
32
|
const inside = (root, target) => { const value = relative(root, target); return !isAbsolute(value) && value !== '..' && !value.startsWith(`..${sep}`); };
|
|
21
33
|
/** Linux's proc fd paths let Node perform a no-follow walk relative to pinned
|
|
22
34
|
* directory handles. Every lookup below '/' contains exactly one component;
|
|
@@ -118,6 +130,15 @@ function find(skills, name) {
|
|
|
118
130
|
throw new Error(`Skill ${matches[0].id} unavailable: ${matches[0].unavailable}`);
|
|
119
131
|
return matches[0];
|
|
120
132
|
}
|
|
133
|
+
/** The catalog skill a name loads, as the Skill tool resolves it; undefined when none would load. */
|
|
134
|
+
export function matchRuntimeSkill(skills, name) {
|
|
135
|
+
try {
|
|
136
|
+
return find(skills, name);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
121
142
|
export async function loadRuntimeSkill(workspace, skill, signal, maxContentChars = MAX_BYTES) {
|
|
122
143
|
if (skill.unavailable)
|
|
123
144
|
throw new Error(`Skill unavailable: ${skill.unavailable}`);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { GenerateRequest, ModelResponse, ToolSchema } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The structured step a vendor CLI returns in place of native tool calls.
|
|
4
|
+
*
|
|
5
|
+
* The CLI providers ask their model for exactly this object, so Andorra keeps tool execution,
|
|
6
|
+
* permissions and graph state: the vendor only ever sees tool names and JSON arguments as data.
|
|
7
|
+
*/
|
|
8
|
+
export declare const STRUCTURED_STEP_SCHEMA: {
|
|
9
|
+
type: string;
|
|
10
|
+
additionalProperties: boolean;
|
|
11
|
+
required: string[];
|
|
12
|
+
properties: {
|
|
13
|
+
text: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
toolCalls: {
|
|
17
|
+
type: string;
|
|
18
|
+
items: {
|
|
19
|
+
type: string;
|
|
20
|
+
additionalProperties: boolean;
|
|
21
|
+
required: string[];
|
|
22
|
+
properties: {
|
|
23
|
+
name: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
arguments: {
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const STRUCTURED_STEP_PROMPT = "You are the model component of Andorra Code. The supplied conversation is the complete context. Return one structured response with text and toolCalls. To request an Andorra tool, return its name and JSON-encoded arguments in toolCalls. Andorra authorizes and executes tools and supplies observations in the next conversation. Do not use built-in tools. Otherwise return text and an empty toolCalls array.";
|
|
35
|
+
export declare const TEXT_STEP_PROMPT = "You are the text-only model component of Andorra Code. The supplied conversation is the complete context. Follow its instructions and return only the requested text. Do not call tools.";
|
|
36
|
+
/** The instruction that states a bounded text step's output allowance to the model. */
|
|
37
|
+
export declare function allowanceInstruction(maxTokens: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Hold a text step to its output allowance.
|
|
40
|
+
*
|
|
41
|
+
* The vendor CLIs have no output cap a caller can set, so the allowance is stated to the model and
|
|
42
|
+
* then enforced on what comes back: an answer whose measured visible output — or, unmeasured, its
|
|
43
|
+
* length at about four characters a token — exceeds the allowance is cut to fit and reported as
|
|
44
|
+
* `length`, which is how callers such as context compaction learn to shrink their request.
|
|
45
|
+
*/
|
|
46
|
+
export declare function boundTextStep(response: ModelResponse, maxTokens: number, visibleOutputTokens?: number): ModelResponse;
|
|
47
|
+
/** The conversation as one JSON document; images travel separately where the vendor accepts them. */
|
|
48
|
+
export declare function structuredStepPrompt(request: Pick<GenerateRequest, 'messages' | 'tools'>): string;
|
|
49
|
+
/**
|
|
50
|
+
* Validate one structured step against the tool manifest the request offered.
|
|
51
|
+
*
|
|
52
|
+
* A call outside the manifest, malformed arguments, or a repeated call is refused rather than
|
|
53
|
+
* repaired: Andorra would otherwise run something the model did not cleanly ask for.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseStructuredStep(value: unknown, tools: readonly Pick<ToolSchema, 'name'>[], vendor: string): ModelResponse;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
/**
|
|
4
|
+
* The structured step a vendor CLI returns in place of native tool calls.
|
|
5
|
+
*
|
|
6
|
+
* The CLI providers ask their model for exactly this object, so Andorra keeps tool execution,
|
|
7
|
+
* permissions and graph state: the vendor only ever sees tool names and JSON arguments as data.
|
|
8
|
+
*/
|
|
9
|
+
export const STRUCTURED_STEP_SCHEMA = {
|
|
10
|
+
type: 'object', additionalProperties: false, required: ['text', 'toolCalls'],
|
|
11
|
+
properties: {
|
|
12
|
+
text: { type: 'string' },
|
|
13
|
+
toolCalls: { type: 'array', items: {
|
|
14
|
+
type: 'object', additionalProperties: false, required: ['name', 'arguments'],
|
|
15
|
+
properties: { name: { type: 'string' }, arguments: { type: 'string' } },
|
|
16
|
+
} },
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const STRUCTURED_STEP_PROMPT = 'You are the model component of Andorra Code. The supplied conversation is the complete context. Return one structured response with text and toolCalls. To request an Andorra tool, return its name and JSON-encoded arguments in toolCalls. Andorra authorizes and executes tools and supplies observations in the next conversation. Do not use built-in tools. Otherwise return text and an empty toolCalls array.';
|
|
20
|
+
export const TEXT_STEP_PROMPT = 'You are the text-only model component of Andorra Code. The supplied conversation is the complete context. Follow its instructions and return only the requested text. Do not call tools.';
|
|
21
|
+
/** The instruction that states a bounded text step's output allowance to the model. */
|
|
22
|
+
export function allowanceInstruction(maxTokens) {
|
|
23
|
+
return `Keep the answer within ${maxTokens} tokens.`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hold a text step to its output allowance.
|
|
27
|
+
*
|
|
28
|
+
* The vendor CLIs have no output cap a caller can set, so the allowance is stated to the model and
|
|
29
|
+
* then enforced on what comes back: an answer whose measured visible output — or, unmeasured, its
|
|
30
|
+
* length at about four characters a token — exceeds the allowance is cut to fit and reported as
|
|
31
|
+
* `length`, which is how callers such as context compaction learn to shrink their request.
|
|
32
|
+
*/
|
|
33
|
+
export function boundTextStep(response, maxTokens, visibleOutputTokens) {
|
|
34
|
+
const measured = visibleOutputTokens !== undefined && visibleOutputTokens > 0 ? visibleOutputTokens : undefined;
|
|
35
|
+
const over = measured !== undefined ? measured > maxTokens : response.text.length > maxTokens * 4;
|
|
36
|
+
if (!over)
|
|
37
|
+
return response;
|
|
38
|
+
const keep = measured !== undefined ? Math.floor(response.text.length * maxTokens / measured) : maxTokens * 4;
|
|
39
|
+
return { ...response, text: response.text.slice(0, keep), stopReason: 'length' };
|
|
40
|
+
}
|
|
41
|
+
/** The conversation as one JSON document; images travel separately where the vendor accepts them. */
|
|
42
|
+
export function structuredStepPrompt(request) {
|
|
43
|
+
return JSON.stringify({
|
|
44
|
+
conversation: request.messages.map(({ images, providerContinuation, reasoningContent, ...message }) => ({ ...message, ...(images?.length ? { imageCount: images.length } : {}) })),
|
|
45
|
+
availableTools: request.tools,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function argumentObject(value, vendor) {
|
|
49
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
50
|
+
throw new Error(`${vendor} returned invalid Andorra tool arguments`);
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
function sameCalls(first, second) {
|
|
54
|
+
return isDeepStrictEqual(first.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })), second.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate one structured step against the tool manifest the request offered.
|
|
58
|
+
*
|
|
59
|
+
* A call outside the manifest, malformed arguments, or a repeated call is refused rather than
|
|
60
|
+
* repaired: Andorra would otherwise run something the model did not cleanly ask for.
|
|
61
|
+
*/
|
|
62
|
+
export function parseStructuredStep(value, tools, vendor) {
|
|
63
|
+
const step = value;
|
|
64
|
+
if (!step || typeof step !== 'object' || Array.isArray(step) || typeof step.text !== 'string' || !Array.isArray(step.toolCalls) || step.toolCalls.length > 100
|
|
65
|
+
|| Object.keys(step).some(key => key !== 'text' && key !== 'toolCalls'))
|
|
66
|
+
throw new Error(`${vendor} returned an invalid Andorra response`);
|
|
67
|
+
const names = new Set(tools.map(tool => tool.name));
|
|
68
|
+
const calls = step.toolCalls.map((call) => {
|
|
69
|
+
if (!call || typeof call.name !== 'string' || !call.name.trim() || typeof call.arguments !== 'string')
|
|
70
|
+
throw new Error(`${vendor} returned a malformed Andorra tool call`);
|
|
71
|
+
if (!names.has(call.name))
|
|
72
|
+
throw new Error(`${vendor} requested a tool outside the Andorra manifest`);
|
|
73
|
+
try {
|
|
74
|
+
argumentObject(JSON.parse(call.arguments), vendor);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error(`${vendor} returned invalid Andorra tool arguments`);
|
|
78
|
+
}
|
|
79
|
+
return { id: randomUUID(), name: call.name, arguments: call.arguments };
|
|
80
|
+
});
|
|
81
|
+
if (calls.some((call, index) => calls.slice(0, index).some(previous => sameCalls([previous], [call])))) {
|
|
82
|
+
throw new Error(`${vendor} returned duplicate Andorra tool calls`);
|
|
83
|
+
}
|
|
84
|
+
return { text: step.text, toolCalls: calls };
|
|
85
|
+
}
|
|
@@ -10,7 +10,7 @@ import type { ModelAdapter } from './types.js';
|
|
|
10
10
|
*
|
|
11
11
|
* The restriction is structural — the id is a constant here, never a parameter on any surface —
|
|
12
12
|
* and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
|
|
13
|
-
*
|
|
13
|
+
* Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
|
|
14
14
|
* membership. That is what makes a one-shot external run headless-safe and lets the caller's
|
|
15
15
|
* provider/model choice reach every request the run makes.
|
|
16
16
|
*/
|
package/dist/src/subagent-run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { realpath, stat } from 'node:fs/promises';
|
|
4
|
-
import {
|
|
4
|
+
import { writeFile } from 'node:fs/promises';
|
|
5
5
|
import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
|
|
6
6
|
import { createRunHandle, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
|
|
7
7
|
import { configuredContextWindow, createAdapter, providerModels } from './providers.js';
|
|
@@ -23,14 +23,14 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
|
|
|
23
23
|
import { DecisionManager } from './decision/DecisionManager.js';
|
|
24
24
|
import { permissionMode } from './permissions.js';
|
|
25
25
|
import { TodoStore } from './todos.js';
|
|
26
|
-
import { claimProcessWorkspace, clearOpenRunClaim,
|
|
26
|
+
import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
|
|
27
27
|
import { SessionStore, projectIdentity, sessionName } from './sessions.js';
|
|
28
28
|
/**
|
|
29
29
|
* External subagent mode: the only graph an external host (Claude CLI, Codex CLI) may run.
|
|
30
30
|
*
|
|
31
31
|
* The restriction is structural — the id is a constant here, never a parameter on any surface —
|
|
32
32
|
* and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
|
|
33
|
-
*
|
|
33
|
+
* Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
|
|
34
34
|
* membership. That is what makes a one-shot external run headless-safe and lets the caller's
|
|
35
35
|
* provider/model choice reach every request the run makes.
|
|
36
36
|
*/
|
|
@@ -193,14 +193,14 @@ const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
|
193
193
|
/**
|
|
194
194
|
* The health failure a subagent caller is given.
|
|
195
195
|
*
|
|
196
|
-
* A subagent always runs the built-in
|
|
196
|
+
* A subagent always runs the built-in Andorra Agent graph, whose node has no editable model
|
|
197
197
|
* selection, so the ordinary remedy — edit the graph's model selections — cannot be followed. The
|
|
198
198
|
* caller has to pick another provider and model, or repair that provider's credentials.
|
|
199
199
|
*/
|
|
200
200
|
function subagentHealthFailure(health) {
|
|
201
201
|
return ['The provider/model this subagent run would use is not usable:',
|
|
202
202
|
...health.failures.map(failure => `- ${failure.provider}/${failure.model}: ${failure.reason}`),
|
|
203
|
-
'A subagent run always uses the built-in
|
|
203
|
+
'A subagent run always uses the built-in Andorra Agent graph, whose model is the one you picked, so there is no graph to edit: retry with another provider and model, or repair that provider credentials.',
|
|
204
204
|
].join('\n');
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -316,12 +316,14 @@ export class SubagentRunner {
|
|
|
316
316
|
// ask the gate for the account that owns this run, or a shared installation answers with
|
|
317
317
|
// whichever account most recently confirmed a plan.
|
|
318
318
|
const accountSubject = await currentGraphSubject().catch(() => undefined);
|
|
319
|
+
const runId = randomUUID();
|
|
319
320
|
const run = {
|
|
320
|
-
runId
|
|
321
|
+
runId, sessionId: randomUUID(), task: options.task, workspace, directory, telemetryRunId,
|
|
321
322
|
...(accountSubject === undefined ? {} : { accountSubject }),
|
|
322
323
|
jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off',
|
|
323
324
|
providerId: provider.id, model, permissions, controller: new AbortController(), startedAt: new Date().toISOString(),
|
|
324
325
|
events: [], notices: [], journal: Promise.resolve(), finished: Promise.resolve(),
|
|
326
|
+
journalWriter: createRunJournalWriter(directory, runId), checkpoints: createCheckpointFailureTracker(directory, runId),
|
|
325
327
|
probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
|
|
326
328
|
providerType: provider.type, baseUrl: provider.baseUrl,
|
|
327
329
|
};
|
|
@@ -508,18 +510,11 @@ export class SubagentRunner {
|
|
|
508
510
|
if (event.type === 'graph.node.started' && typeof data.nodeId === 'string')
|
|
509
511
|
run.currentNode = data.nodeId;
|
|
510
512
|
// The journal keeps the order the events happened in, and the runtime awaits the callback for
|
|
511
|
-
// exactly that reason: the
|
|
512
|
-
// filesystem does not finish them in the order they were started.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
// The run keeps going — a storage hiccup must not kill the work — but the journal is no
|
|
517
|
-
// longer a complete account: the events after this failure are written, so nothing in the
|
|
518
|
-
// file itself reveals the hole. Left unmarked, a crashed attempt would replay to a
|
|
519
|
-
// position missing whatever this append ate, and a resume would repeat that work.
|
|
520
|
-
run.journalFailed = true;
|
|
521
|
-
await noteJournalWriteFailure(run.directory, run.runId, error instanceof Error ? error.message : String(error)).catch(() => { });
|
|
522
|
-
});
|
|
513
|
+
// exactly that reason: the writer chains its appends rather than launching them side by side,
|
|
514
|
+
// because the filesystem does not finish them in the order they were started. The run keeps
|
|
515
|
+
// going when an append fails (a storage hiccup must not kill the work): the writer holds the
|
|
516
|
+
// event and writes it once the file accepts appends again.
|
|
517
|
+
run.journal = run.journalWriter.append(event);
|
|
523
518
|
return run.journal;
|
|
524
519
|
}
|
|
525
520
|
/**
|
|
@@ -631,15 +626,11 @@ export class SubagentRunner {
|
|
|
631
626
|
...(meta?.provider === undefined ? {} : { provider: meta.provider }),
|
|
632
627
|
...(meta?.model === undefined ? {} : { model: meta.model }),
|
|
633
628
|
}))
|
|
634
|
-
.catch(async (error) => {
|
|
635
629
|
// The run keeps going — durability is a convenience, never the run's outcome. But a
|
|
636
|
-
// checkpoint that could not be written is the conversation a resume re-enters the
|
|
637
|
-
// node
|
|
638
|
-
//
|
|
639
|
-
|
|
640
|
-
run.checkpointFailed = true;
|
|
641
|
-
await noteCheckpointWriteFailure(run.directory, run.runId, error instanceof Error ? error.message : String(error)).catch(() => { });
|
|
642
|
-
});
|
|
630
|
+
// checkpoint that could not be written is the conversation a resume re-enters the node
|
|
631
|
+
// with, so the node stays marked until one of its later writes lands; a resume of an
|
|
632
|
+
// attempt that stopped while it was marked warns that the node may repeat work.
|
|
633
|
+
.then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
|
|
643
634
|
// The write is handed back so the runtime can await it: the checkpoint is the conversation
|
|
644
635
|
// a resume re-enters the node with, and a run that advanced past a mutating tool call
|
|
645
636
|
// while its checkpoint was still queued could be killed with that conversation unwritten.
|
|
@@ -687,7 +678,7 @@ export class SubagentRunner {
|
|
|
687
678
|
decisionManager: new DecisionManager({ config: await subagentDecisionConfig(config, () => (options.membership ?? getMembership)(signal)), onEvent: event => this.observe(run, event) }),
|
|
688
679
|
decisionNodeOptIn: true,
|
|
689
680
|
// The code intelligence of the installation this run works in, so the run has the same
|
|
690
|
-
// repository coverage an ordinary
|
|
681
|
+
// repository coverage an ordinary Andorra Agent run has.
|
|
691
682
|
...(codeIntel ? { codeIntel } : {}),
|
|
692
683
|
// The checkpoints a resume reads: without them a replay re-enters the node from its
|
|
693
684
|
// opening task and repeats the writes and shell calls that already ran.
|
|
@@ -769,15 +760,20 @@ export class SubagentRunner {
|
|
|
769
760
|
// The journal is drained before the record that says the run finished: a record that reports a
|
|
770
761
|
// completed run while its last events are still being written is a record whose journal tail
|
|
771
762
|
// may never land.
|
|
763
|
+
// Settling also retries whatever the file refused earlier, so space freed since then lets the
|
|
764
|
+
// journal finish whole.
|
|
772
765
|
await run.journal.catch(() => { });
|
|
773
|
-
|
|
774
|
-
//
|
|
775
|
-
|
|
766
|
+
const journalIntact = await run.journalWriter.settle();
|
|
767
|
+
// The record carries the flag the resume reads when the marker file could not be written: a
|
|
768
|
+
// resume of an attempt whose journal has a hole warns that a step may repeat.
|
|
769
|
+
if (!journalIntact)
|
|
776
770
|
record.journalIntegrity = 'failed';
|
|
777
|
-
// The same flag for a checkpoint
|
|
778
|
-
// from
|
|
779
|
-
if (run.
|
|
771
|
+
// The same flag for a node whose newest checkpoint could not be written: a resume re-enters
|
|
772
|
+
// that node from an older conversation, and warns that it may repeat work.
|
|
773
|
+
if (!run.checkpoints.intact) {
|
|
780
774
|
record.checkpointIntegrity = 'failed';
|
|
775
|
+
record.checkpointFailures = run.checkpoints.failures;
|
|
776
|
+
}
|
|
781
777
|
// The terminal record is written before the session is finalized. A crash between the two
|
|
782
778
|
// leaves a session whose turn is still marked running, which the startup recovery repairs
|
|
783
779
|
// from the record; the other order would leave a session that reports the completion while
|
|
@@ -27,7 +27,7 @@ export type TelemetryTaskCategory = typeof TELEMETRY_TASK_CATEGORIES[number];
|
|
|
27
27
|
export declare const TELEMETRY_WORKSPACE_BUCKETS: readonly ["0", "1-9", "10-99", "100-999", "1000-9999", "10000+"];
|
|
28
28
|
export type TelemetryWorkspaceBucket = typeof TELEMETRY_WORKSPACE_BUCKETS[number];
|
|
29
29
|
/** The permission values ordinary runs persist, in the order `PERMISSION_MODES` lists them. */
|
|
30
|
-
export declare const TELEMETRY_PERMISSION_MODES: readonly ["read-only", "ask-for-approval", "approve-for-me", "full-access"];
|
|
30
|
+
export declare const TELEMETRY_PERMISSION_MODES: readonly ["read-only", "plan", "ask-for-approval", "approve-for-me", "full-access"];
|
|
31
31
|
export declare const TELEMETRY_OPERATING_SYSTEMS: readonly ["darwin", "win32", "linux", "freebsd", "openbsd", "sunos", "aix", "android", "other"];
|
|
32
32
|
export declare const TELEMETRY_ARCHITECTURES: readonly ["x64", "arm64", "arm", "ia32", "ppc64", "s390x", "riscv64", "loong64", "mips", "mipsel", "ppc", "s390", "other"];
|
|
33
33
|
export declare const TELEMETRY_LANGUAGES: readonly ["typescript", "javascript", "python", "go", "rust", "java", "kotlin", "swift", "csharp", "cpp", "c", "ruby", "php", "scala", "elixir", "dart", "shell", "sql", "html", "css", "other"];
|
|
@@ -35,7 +35,7 @@ export type TelemetryLanguage = typeof TELEMETRY_LANGUAGES[number];
|
|
|
35
35
|
export declare const TELEMETRY_FRAMEWORKS: readonly ["react", "vue", "angular", "svelte", "nextjs", "nestjs", "express", "fastapi", "django", "flask", "spring", "rails", "laravel", "dotnet", "actix", "axum", "gin", "flutter", "electron", "tauri", "other"];
|
|
36
36
|
export type TelemetryFramework = typeof TELEMETRY_FRAMEWORKS[number];
|
|
37
37
|
/** Product-owned tool names, plus the three buckets user- or server-named tools collapse into. */
|
|
38
|
-
export declare const TELEMETRY_TOOL_NAMES: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "read_skill_resource", "ask_user", "spawn_subagent", "qa.browser", "qa.browser_session", "qa.deep", "qa.fast", "qa.inspect_project", "qa.security", "qa.status", "qa.terminal", "qa.test", "browser.panel", "mcp", "plugin", "other"];
|
|
38
|
+
export declare const TELEMETRY_TOOL_NAMES: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "read_skill_resource", "ask_user", "spawn_subagent", "qa.browser", "qa.browser_session", "qa.deep", "qa.fast", "qa.inspect_project", "qa.security", "qa.status", "qa.terminal", "qa.test", "browser.panel", "browser.incognito", "browser.solve_captcha", "web_search", "mcp", "plugin", "other"];
|
|
39
39
|
export type TelemetryToolName = typeof TELEMETRY_TOOL_NAMES[number];
|
|
40
40
|
/**
|
|
41
41
|
* Public model ids a run may name. Provider configuration accepts a user-supplied string of up to
|
|
@@ -35,7 +35,7 @@ export const TELEMETRY_ROUTING = ['off', 'shadow', 'active'];
|
|
|
35
35
|
export const TELEMETRY_TASK_CATEGORIES = ['implement', 'fix', 'test', 'docs', 'investigate'];
|
|
36
36
|
export const TELEMETRY_WORKSPACE_BUCKETS = ['0', '1-9', '10-99', '100-999', '1000-9999', '10000+'];
|
|
37
37
|
/** The permission values ordinary runs persist, in the order `PERMISSION_MODES` lists them. */
|
|
38
|
-
export const TELEMETRY_PERMISSION_MODES = ['read-only', 'ask-for-approval', 'approve-for-me', 'full-access'];
|
|
38
|
+
export const TELEMETRY_PERMISSION_MODES = ['read-only', 'plan', 'ask-for-approval', 'approve-for-me', 'full-access'];
|
|
39
39
|
export const TELEMETRY_OPERATING_SYSTEMS = ['darwin', 'win32', 'linux', 'freebsd', 'openbsd', 'sunos', 'aix', 'android', 'other'];
|
|
40
40
|
export const TELEMETRY_ARCHITECTURES = ['x64', 'arm64', 'arm', 'ia32', 'ppc64', 's390x', 'riscv64', 'loong64', 'mips', 'mipsel', 'ppc', 's390', 'other'];
|
|
41
41
|
export const TELEMETRY_LANGUAGES = ['typescript', 'javascript', 'python', 'go', 'rust', 'java', 'kotlin', 'swift', 'csharp', 'cpp', 'c', 'ruby', 'php', 'scala', 'elixir', 'dart', 'shell', 'sql', 'html', 'css', 'other'];
|
|
@@ -50,7 +50,8 @@ export const TELEMETRY_TOOL_NAMES = [
|
|
|
50
50
|
// rides the same browser capability and stays attributable the same way.
|
|
51
51
|
'qa.browser', 'qa.browser_session', 'qa.deep', 'qa.fast', 'qa.inspect_project', 'qa.security',
|
|
52
52
|
'qa.status', 'qa.terminal', 'qa.test',
|
|
53
|
-
'browser.panel',
|
|
53
|
+
'browser.panel', 'browser.incognito',
|
|
54
|
+
'browser.solve_captcha', 'web_search',
|
|
54
55
|
'mcp', 'plugin', 'other',
|
|
55
56
|
];
|
|
56
57
|
/**
|
|
@@ -355,6 +355,10 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
355
355
|
* drained at turn boundaries.
|
|
356
356
|
*/
|
|
357
357
|
private attachments;
|
|
358
|
+
/** The skills the `/` popup offers after the built-in commands, with the description it shows. */
|
|
359
|
+
private skillCommands;
|
|
360
|
+
/** The command the skill chip in the draft stands for, while one is there. */
|
|
361
|
+
private skillChip?;
|
|
358
362
|
private attachmentSeq;
|
|
359
363
|
/**
|
|
360
364
|
* Generation of the composer's attachment surface. Advanced by every draft clear and steer
|
|
@@ -623,6 +627,25 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
623
627
|
* to the draft once that composer is armed again.
|
|
624
628
|
*/
|
|
625
629
|
addAttachment(pending: PendingAttachment): boolean;
|
|
630
|
+
/** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
|
|
631
|
+
setSkillCommands(skills: readonly {
|
|
632
|
+
command: string;
|
|
633
|
+
description: string;
|
|
634
|
+
}[]): void;
|
|
635
|
+
private skillCommand;
|
|
636
|
+
/** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
|
|
637
|
+
private insertSkillChip;
|
|
638
|
+
/**
|
|
639
|
+
* Turn a leading, fully typed skill command into the chip once a space follows it, so a command
|
|
640
|
+
* typed out in full reads the same as one picked from the popup.
|
|
641
|
+
*/
|
|
642
|
+
private chipTypedSkill;
|
|
643
|
+
/**
|
|
644
|
+
* Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
|
|
645
|
+
* one keystroke, so a picked skill comes out as it went in.
|
|
646
|
+
*/
|
|
647
|
+
private backspace;
|
|
648
|
+
private deleteForward;
|
|
626
649
|
/** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
|
|
627
650
|
takeAttachments(): PendingAttachment[];
|
|
628
651
|
/** The amber label a token draws as in the composer. */
|
|
@@ -636,6 +659,12 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
636
659
|
* command submits without them, so the command runs and the attachments stay queued.
|
|
637
660
|
*/
|
|
638
661
|
private submittedDraft;
|
|
662
|
+
/**
|
|
663
|
+
* The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
|
|
664
|
+
* written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
|
|
665
|
+
* not survive the trip, and the draft would lose the skill it names.
|
|
666
|
+
*/
|
|
667
|
+
private parkedDraft;
|
|
639
668
|
/** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
|
|
640
669
|
private restoredDraft;
|
|
641
670
|
/** Remove draft elements, dropping the attachment behind every token they held. */
|
|
@@ -673,6 +702,15 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
673
702
|
* The system writer is preferred; without one, or when it fails, an OSC 52 sequence asks
|
|
674
703
|
* the terminal to set the clipboard instead.
|
|
675
704
|
*/
|
|
705
|
+
/**
|
|
706
|
+
* Put text on the clipboard of whoever is looking at this terminal.
|
|
707
|
+
*
|
|
708
|
+
* `terminalOnly` skips the system writer for an OSC 52 sequence alone: over SSH the system
|
|
709
|
+
* clipboard belongs to the remote host, while the terminal's is the one on the user's own machine.
|
|
710
|
+
*/
|
|
711
|
+
copyText(text: string, options?: {
|
|
712
|
+
terminalOnly?: boolean;
|
|
713
|
+
}): void;
|
|
676
714
|
private copySelection;
|
|
677
715
|
private complete;
|
|
678
716
|
/** Put `command ` in the composer and open its argument list, without submitting anything. */
|