@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tools the Andorra agent-control MCP server advertises, as plain data.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `agent-mcp.ts` so the engine can describe its built-in `graphs` tool without
|
|
5
|
+
* loading the graph backend (and its sync, membership and subagent modules) until a graph action runs.
|
|
6
|
+
*/
|
|
7
|
+
export interface AgentMcpToolSpec {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: 'object';
|
|
12
|
+
properties: Record<string, unknown>;
|
|
13
|
+
required: string[];
|
|
14
|
+
additionalProperties: false;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const AGENT_MCP_CATALOG: readonly AgentMcpToolSpec[];
|
|
18
|
+
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
19
|
+
export declare const AGENT_MCP_TOOL_NAMES: readonly string[];
|
|
20
|
+
/** Graph authoring: what the engine's built-in `graphs` tool offers. Session and subagent tools stay MCP-only. */
|
|
21
|
+
export declare const AGENT_MCP_GRAPH_TOOLS: readonly AgentMcpToolSpec[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const obj = (properties, required = []) => ({ type: 'object',
|
|
2
|
+
properties, required, additionalProperties: false });
|
|
3
|
+
const str = { type: 'string' };
|
|
4
|
+
const num = { type: 'integer', minimum: 0 };
|
|
5
|
+
const graphDraftSchema = { draftId: str };
|
|
6
|
+
const graphReference = { draftId: str, nodeId: str };
|
|
7
|
+
const searchFilters = { projectName: str, projectPath: str,
|
|
8
|
+
lookbackMinutes: num, updatedAfter: str, updatedBefore: str, includeArchived: { type: 'boolean' } };
|
|
9
|
+
export const AGENT_MCP_CATALOG = [
|
|
10
|
+
{ name: 'andorra_graph_guide', description: 'Read Andorra graph architecture, node types, outcome routes, loops and save error contracts.', inputSchema: obj({}) },
|
|
11
|
+
{ name: 'andorra_providers_list', description: 'List valid graph provider IDs and models without credentials.', inputSchema: obj({}) },
|
|
12
|
+
{ name: 'andorra_graphs_list', description: 'List available graphs, names and revisions. Deleted graphs are listed only with includeDeleted.', inputSchema: obj({ includeDeleted: { type: 'boolean' } }) },
|
|
13
|
+
{ name: 'andorra_graph_get', description: 'Read one published graph, optionally by revision.', inputSchema: obj({ id: str, revision: { type: 'integer', minimum: 1 } }, ['id']) },
|
|
14
|
+
{ name: 'andorra_graph_begin', description: 'Open an ephemeral graph draft. mode=create needs a new id and name; mode=edit opens latest.', inputSchema: obj({ mode: { type: 'string', enum: ['create', 'edit'] }, id: str, name: str }, ['mode', 'id']) },
|
|
15
|
+
{ name: 'andorra_graph_node_upsert', description: 'Create or replace a node in a draft. Agent nodes require a configured provider ID.', inputSchema: obj({ draftId: str, node: { type: 'object' } }, ['draftId', 'node']) },
|
|
16
|
+
{ name: 'andorra_graph_node_patch', description: 'Change an existing node prompt, instruction, model, provider, completion, etc. without replacing other fields.', inputSchema: obj({ ...graphReference, patch: { type: 'object' } }, ['draftId', 'nodeId', 'patch']) },
|
|
17
|
+
{ name: 'andorra_graph_node_remove', description: 'Remove a non-entry node and its incident edges from a draft.', inputSchema: obj(graphReference, ['draftId', 'nodeId']) },
|
|
18
|
+
{ name: 'andorra_graph_edge_upsert', description: 'Create or replace an edge. Outcome must match a source node port (pass/fail, true/false, body/done...).', inputSchema: obj({ draftId: str, edge: { type: 'object' } }, ['draftId', 'edge']) },
|
|
19
|
+
{ name: 'andorra_graph_edge_remove', description: 'Remove an edge by ID from a draft.', inputSchema: obj({ ...graphDraftSchema, edgeId: str }, ['draftId', 'edgeId']) },
|
|
20
|
+
{ name: 'andorra_graph_patch', description: 'Set graph entry, name, limits, schemas, widgets or metadata in a draft.', inputSchema: obj({ draftId: str, patch: { type: 'object' } }, ['draftId', 'patch']) },
|
|
21
|
+
{ name: 'andorra_graph_validate', description: 'Validate a draft; report all missing provider and outcome paths, plus graph topology issues.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
22
|
+
{ name: 'andorra_graph_publish', description: 'Validate and atomically publish the next immutable graph revision; optimistic concurrency guards other editors.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
23
|
+
{ name: 'andorra_graph_delete', description: 'Soft-delete a graph after the user confirms in chat: publishes a revision marked deleted, hides it from listings and new runs, keeps every revision. confirm must repeat the id.', inputSchema: obj({ id: str, expectedRevision: { type: 'integer', minimum: 1 }, confirm: str }, ['id', 'expectedRevision', 'confirm']) },
|
|
24
|
+
{ name: 'andorra_graph_restore', description: 'Restore a soft-deleted graph by publishing the next revision without the deleted marker.', inputSchema: obj({ id: str, expectedRevision: { type: 'integer', minimum: 1 } }, ['id', 'expectedRevision']) },
|
|
25
|
+
{ name: 'andorra_graph_discard', description: 'Discard an unpublished local graph draft.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
26
|
+
{ name: 'andorra_projects_list', description: 'List registered projects and discovered session workspaces.', inputSchema: obj({}) },
|
|
27
|
+
{ name: 'andorra_sessions_list', description: 'Search sessions by project, status and last X minutes (lookbackMinutes). Supports paginated results.', inputSchema: obj({ ...searchFilters, status: { type: 'string', enum: ['completed', 'pending', 'running', 'required_input', 'incomplete'] },
|
|
28
|
+
offset: num, limit: { type: 'integer', minimum: 1, maximum: 100 } }) },
|
|
29
|
+
{ name: 'andorra_session_get', description: 'Read session metadata and up to 20 recent turn excerpts; no filesystem access.', inputSchema: obj({ sessionId: str,
|
|
30
|
+
historyLimit: { type: 'integer', minimum: 0, maximum: 20 }, historyOffset: num }, ['sessionId']) },
|
|
31
|
+
{ name: 'andorra_sessions_attention', description: 'Find sessions requiring human feedback or review: required_input and incomplete; supports project and time filters.', inputSchema: obj(searchFilters) },
|
|
32
|
+
{ name: 'andorra_subagent_start', description: 'Run the bundled Andorra Agent graph once as an Andorra subagent. Requires a provider/model: pass provider and model, or the saved /subagent setting. On PROVIDER_NOT_SET, show the listed providers and models to your user, ask which to use, then retry with provider and model. Writes are allowed unless permissions is read-only.', inputSchema: obj({ prompt: str, provider: str, model: str, permissions: { type: 'string', enum: ['full-access', 'read-only'] }, workspace: str }, ['prompt']) },
|
|
33
|
+
{ name: 'andorra_subagent_status', description: 'Poll the subagent run: state, current node and recent events. The runId must be the one the start returned, so the answer is about that run.', inputSchema: obj({ runId: str }, ['runId']) },
|
|
34
|
+
{ name: 'andorra_subagent_result', description: 'Read the subagent run outcome. waitMs (0-60000) waits for completion within the call; otherwise returns running immediately when unfinished. The finished reply carries the full run result including completion summary and status. The runId must be the one the start returned.', inputSchema: obj({ waitMs: { type: 'integer', minimum: 0, maximum: 60000 }, runId: str }, ['runId']) },
|
|
35
|
+
{ name: 'andorra_subagent_cancel', description: 'Cancel the subagent run. The runId must be the one the start returned, so a delayed cancellation cannot stop a run that replaced it.', inputSchema: obj({ runId: str }, ['runId']) },
|
|
36
|
+
];
|
|
37
|
+
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
38
|
+
export const AGENT_MCP_TOOL_NAMES = AGENT_MCP_CATALOG.map(tool => tool.name);
|
|
39
|
+
/** Graph authoring: what the engine's built-in `graphs` tool offers. Session and subagent tools stay MCP-only. */
|
|
40
|
+
export const AGENT_MCP_GRAPH_TOOLS = AGENT_MCP_CATALOG.filter(tool => tool.name.startsWith('andorra_graph_') || tool.name === 'andorra_graphs_list' || tool.name === 'andorra_providers_list');
|
package/dist/src/agent-mcp.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { getMembership } from './membership.js';
|
|
|
5
5
|
import { SessionStore } from './sessions.js';
|
|
6
6
|
import { type SubagentProviderListing } from './subagent-run.js';
|
|
7
7
|
import type { ModelAdapter } from './types.js';
|
|
8
|
+
import { AGENT_MCP_TOOL_NAMES } from './agent-mcp-catalog.js';
|
|
8
9
|
type Issue = {
|
|
9
10
|
code: string;
|
|
10
11
|
message: string;
|
|
@@ -22,7 +23,7 @@ export type AgentMcpReply = {
|
|
|
22
23
|
issues?: Issue[];
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
|
-
type GraphSyncClient = Pick<GraphSync, 'start' | 'waitForSync' | 'close' | 'sync' | 'status'>;
|
|
26
|
+
type GraphSyncClient = Pick<GraphSync, 'start' | 'waitForSync' | 'close' | 'sync' | 'status' | 'reviveGraph'>;
|
|
26
27
|
export interface AgentMcpBackendOptions {
|
|
27
28
|
directory?: string;
|
|
28
29
|
/** Test-only or embedded-host override. Production graph access enforces paid membership and account ownership. */
|
|
@@ -45,15 +46,31 @@ export interface AgentMcpBackendOptions {
|
|
|
45
46
|
subagentWorkspace?: string;
|
|
46
47
|
/** Test-only adapter so subagent runs stay offline and deterministic. */
|
|
47
48
|
subagentAdapterFactory?: (provider: import('./providers.js').ProviderConfig) => ModelAdapter;
|
|
49
|
+
/**
|
|
50
|
+
* Whether construction sweeps the home for runs a crashed process left `running` (default true).
|
|
51
|
+
*
|
|
52
|
+
* The stdio server needs it: a host that only talks to the server would otherwise never see its own
|
|
53
|
+
* crashed runs classified. The engine's built-in `graphs` tool passes false: it starts no subagent
|
|
54
|
+
* runs, and the run records of its home belong to the engine that hosts it.
|
|
55
|
+
*/
|
|
56
|
+
recoverRuns?: boolean;
|
|
48
57
|
}
|
|
49
58
|
export declare const GRAPH_AGENT_GUIDE: string;
|
|
50
59
|
export declare class AgentMcpError extends Error {
|
|
51
60
|
readonly code: string;
|
|
52
61
|
readonly info: Partial<Issue> & {
|
|
53
62
|
issues?: Issue[];
|
|
63
|
+
automations?: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
}[];
|
|
54
67
|
};
|
|
55
68
|
constructor(code: string, message: string, info?: Partial<Issue> & {
|
|
56
69
|
issues?: Issue[];
|
|
70
|
+
automations?: {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
}[];
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
76
|
export declare class AgentMcpBackend {
|
|
@@ -94,12 +111,28 @@ export declare class AgentMcpBackend {
|
|
|
94
111
|
private assertGraphIdentity;
|
|
95
112
|
private obtainDraft;
|
|
96
113
|
private providers;
|
|
114
|
+
/**
|
|
115
|
+
* Soft-delete or restore: publish the next revision with metadata.deletedAt set or removed.
|
|
116
|
+
*
|
|
117
|
+
* The revision goes through the same save path as a publish, so free-tier rules and the optimistic
|
|
118
|
+
* revision check apply unchanged, and cloud sync carries the marker to every machine.
|
|
119
|
+
*/
|
|
120
|
+
private setDeleted;
|
|
97
121
|
/** Missing graph identity is not a broken graph. Tell the agent to list or create it. */
|
|
98
122
|
private readGraph;
|
|
99
123
|
private upsertNode;
|
|
100
124
|
private upsertEdge;
|
|
101
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Run one tool call. `beforeSave` runs synchronously immediately before a revision is written
|
|
127
|
+
* (publish, delete, restore), after every await that precedes the write; throwing from it abandons
|
|
128
|
+
* the save. An embedding host uses it to refuse a save its task may no longer make (cancelled, or
|
|
129
|
+
* switched to Plan) while the call was waiting on sign-in checks or cloud sync.
|
|
130
|
+
*/
|
|
131
|
+
call(name: string, rawArgs?: unknown, options?: {
|
|
132
|
+
beforeSave?: () => void;
|
|
133
|
+
}): Promise<AgentMcpReply>;
|
|
102
134
|
private dispatch;
|
|
103
135
|
}
|
|
136
|
+
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
137
|
+
export { AGENT_MCP_TOOL_NAMES };
|
|
104
138
|
export declare function runAgentMcpServer(): Promise<number>;
|
|
105
|
-
export {};
|
package/dist/src/agent-mcp.js
CHANGED
|
@@ -9,10 +9,12 @@ import { stampGraphProviderProfiles } from './graph-provider-portability.js';
|
|
|
9
9
|
import { getAuthStatus } from './auth/index.js';
|
|
10
10
|
import { getMembership, PaidMembershipRequiredError } from './membership.js';
|
|
11
11
|
import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_LIMIT_MESSAGE, FreeTierLimitError, readGraphQuota, saveFreeTierGraph } from './graph-quota.js';
|
|
12
|
-
import { GraphConflictError, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, saveGraph, validateGraph } from './graphs.js';
|
|
12
|
+
import { GraphConflictError, isDeletedGraph, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, saveGraph, validateGraph, withoutDeletedGraphs } from './graphs.js';
|
|
13
13
|
import { getAgentSession, listAgentProjects, queryAgentSessions, scanAgentSessions, SessionQueryError } from './session-monitor.js';
|
|
14
|
+
import { AutomationStore } from './automations.js';
|
|
14
15
|
import { canonicalWorkspace, MAX_SUBAGENT_TASK_CHARS, SubagentInvalidArgumentError, SubagentProviderNotSetError, SubagentRunInProgressError, SubagentRunner, SubagentSelectionError } from './subagent-run.js';
|
|
15
16
|
import { reconcileInterruptedRuns } from './run-records.js';
|
|
17
|
+
import { AGENT_MCP_CATALOG, AGENT_MCP_TOOL_NAMES } from './agent-mcp-catalog.js';
|
|
16
18
|
export const GRAPH_AGENT_GUIDE = [
|
|
17
19
|
'# Andorra Code Graph Agent Architecture (MCP)',
|
|
18
20
|
'',
|
|
@@ -49,6 +51,17 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
49
51
|
'All nodes must be reachable from entry. Every edge source/target must exist; outcome must match a source port.',
|
|
50
52
|
'A graph with a version-3 Orchestrator needs that Orchestrator as entry and it cannot have incoming edges.',
|
|
51
53
|
'',
|
|
54
|
+
'## Deleting and restoring',
|
|
55
|
+
'andorra_graph_delete {id, expectedRevision, confirm} soft-deletes a graph: it publishes the next revision with metadata.deletedAt set.',
|
|
56
|
+
'Ask the user in chat first; confirm must repeat the id. Every revision stays stored; the graph leaves listings and new runs refuse it.',
|
|
57
|
+
'Sessions that already ran it keep resuming. andorra_graphs_list {includeDeleted:true} lists deleted graphs with deleted=true.',
|
|
58
|
+
'andorra_graph_restore {id, expectedRevision} publishes the next revision without the marker.',
|
|
59
|
+
'A deleted graph still counts toward a free account\'s one custom graph, so a free account restores it rather than replacing it.',
|
|
60
|
+
'DEFAULT_GRAPH: the bundled Default graph and the Andorra preset cannot be deleted.',
|
|
61
|
+
'CONFIRMATION_MISMATCH: confirm must equal id. GRAPH_IN_USE: an automation runs the graph; the error lists them; change them first.',
|
|
62
|
+
'GRAPH_DELETED: the graph is deleted; restore it before editing or deleting it again. GRAPH_NOT_DELETED: restore needs a deleted graph.',
|
|
63
|
+
'RESERVED_METADATA: metadata.deletedAt is set only by the delete and restore tools; andorra_graph_patch and publishing refuse it.',
|
|
64
|
+
'',
|
|
52
65
|
'## Example: two-outcome QA workflow',
|
|
53
66
|
'Begin graph id=qa-flow name="QA Flow". Add agent id=check, provider=<configured id>,',
|
|
54
67
|
'completion={mode:"outcomes",outcomes:["pass","fail"]}, instruction="Run checks and report pass or fail".',
|
|
@@ -79,7 +92,7 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
79
92
|
'a completed needs_clarification outcome is still observable.',
|
|
80
93
|
'',
|
|
81
94
|
'## Subagent runs',
|
|
82
|
-
'andorra_subagent_start runs exactly the bundled
|
|
95
|
+
'andorra_subagent_start runs exactly the bundled Andorra Agent graph (single agent, no graph selection).',
|
|
83
96
|
'A provider/model is mandatory: name provider and model in the call, or rely on the saved /subagent setting.',
|
|
84
97
|
'PROVIDER_NOT_SET replies list every configured provider with its models — present that list to the user, ask',
|
|
85
98
|
'which pair to use, and retry the call with provider and model. Runs write files unless permissions=read-only;',
|
|
@@ -242,7 +255,8 @@ export class AgentMcpBackend {
|
|
|
242
255
|
// Another engine in this process may have a live run in this home — an app-server, or a
|
|
243
256
|
// second backend. A record this process is running is not this backend's to classify, so the
|
|
244
257
|
// sweep leaves it alone.
|
|
245
|
-
this.recovery =
|
|
258
|
+
this.recovery = options.recoverRuns === false ? Promise.resolve()
|
|
259
|
+
: reconcileInterruptedRuns(this.directory, undefined, { skipOwnProcess: true }).then(() => undefined).catch(() => undefined);
|
|
246
260
|
}
|
|
247
261
|
/** The startup recovery, finished before the first subagent start is accepted. */
|
|
248
262
|
recovery;
|
|
@@ -400,6 +414,67 @@ export class AgentMcpBackend {
|
|
|
400
414
|
const config = await (this.options.providerConfig ? this.options.providerConfig() : loadConfig(this.directory));
|
|
401
415
|
return { providers: config.providers.map(({ id, model, type }) => ({ id, model, type })), active: config.provider };
|
|
402
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Soft-delete or restore: publish the next revision with metadata.deletedAt set or removed.
|
|
419
|
+
*
|
|
420
|
+
* The revision goes through the same save path as a publish, so free-tier rules and the optimistic
|
|
421
|
+
* revision check apply unchanged, and cloud sync carries the marker to every machine.
|
|
422
|
+
*/
|
|
423
|
+
async setDeleted(deleting, args, access, beforeSave) {
|
|
424
|
+
const tool = deleting ? 'andorra_graph_delete' : 'andorra_graph_restore';
|
|
425
|
+
const id = field(args, 'id');
|
|
426
|
+
if (id === 'default' || id.includes(':'))
|
|
427
|
+
throw new AgentMcpError('DEFAULT_GRAPH', 'The bundled Default graph and the Andorra preset cannot be deleted or restored.');
|
|
428
|
+
if (!safeId(id))
|
|
429
|
+
throw new AgentMcpError('INVALID_GRAPH_ID', 'Graph id must be a safe identifier of 1-80 characters.');
|
|
430
|
+
if (Object.keys(args).some(key => !['id', 'expectedRevision', ...(deleting ? ['confirm'] : [])].includes(key)))
|
|
431
|
+
throw new AgentMcpError('INVALID_ARGUMENTS', tool + ' takes only id, expectedRevision' + (deleting ? ' and confirm.' : '.'));
|
|
432
|
+
const expectedRevision = args.expectedRevision;
|
|
433
|
+
if (typeof expectedRevision !== 'number' || !Number.isSafeInteger(expectedRevision) || expectedRevision < 1)
|
|
434
|
+
throw new AgentMcpError('INVALID_ARGUMENTS', 'expectedRevision must be the positive revision andorra_graph_get or andorra_graphs_list reported.');
|
|
435
|
+
if (deleting && args.confirm !== id)
|
|
436
|
+
throw new AgentMcpError('CONFIRMATION_MISMATCH', 'confirm must repeat the graph id ' + id + '. Ask the user to confirm the deletion in chat first.');
|
|
437
|
+
// Bring in a revision another machine published, so the revision check compares against it.
|
|
438
|
+
await this.sync?.sync();
|
|
439
|
+
const latest = await this.readGraph(id, access.directory);
|
|
440
|
+
await this.assertGraphIdentity(access);
|
|
441
|
+
if (latest.revision !== expectedRevision)
|
|
442
|
+
throw new GraphConflictError('Graph ' + id + ' is at revision ' + latest.revision + ', not ' + expectedRevision + '. Read it again before ' + (deleting ? 'deleting' : 'restoring') + ' it.');
|
|
443
|
+
if (deleting && isDeletedGraph(latest))
|
|
444
|
+
throw new AgentMcpError('GRAPH_DELETED', 'Graph ' + id + ' is already deleted.');
|
|
445
|
+
if (!deleting && !isDeletedGraph(latest))
|
|
446
|
+
throw new AgentMcpError('GRAPH_NOT_DELETED', 'Graph ' + id + ' is not deleted, so there is nothing to restore.');
|
|
447
|
+
if (deleting) {
|
|
448
|
+
// An automation would fail at its next run; the user decides what it runs instead.
|
|
449
|
+
const users = (await new AutomationStore(this.directory).list()).filter(job => job.execution?.graph === id);
|
|
450
|
+
if (users.length)
|
|
451
|
+
throw new AgentMcpError('GRAPH_IN_USE', 'Graph ' + id + ' is run by automation'
|
|
452
|
+
+ (users.length === 1 ? ' ' : 's ') + users.map(job => '"' + job.name + '"').join(', ') + '. Change or remove ' + (users.length === 1 ? 'it' : 'them') + ' first.', { automations: users.map(job => ({ id: job.id, name: job.name })) });
|
|
453
|
+
}
|
|
454
|
+
const freshAccess = await this.graphAccess();
|
|
455
|
+
if (freshAccess.directory !== access.directory || freshAccess.subject !== access.subject)
|
|
456
|
+
throw new AgentMcpError('AUTH_CHANGED', 'Account changed during graph synchronization. Retry with the current account.');
|
|
457
|
+
const deletedAt = new Date().toISOString();
|
|
458
|
+
const metadata = { ...latest.metadata };
|
|
459
|
+
if (deleting)
|
|
460
|
+
metadata.deletedAt = deletedAt;
|
|
461
|
+
else
|
|
462
|
+
delete metadata.deletedAt;
|
|
463
|
+
const next = { ...latest, metadata };
|
|
464
|
+
beforeSave?.();
|
|
465
|
+
const saved = freshAccess.free ? await saveFreeTierGraph(next, latest.revision, access.directory)
|
|
466
|
+
: await saveGraph(next, latest.revision, access.directory);
|
|
467
|
+
// A draft of a deleted graph could only publish over the deletion.
|
|
468
|
+
if (deleting)
|
|
469
|
+
for (const [key, draft] of this.drafts)
|
|
470
|
+
if (draft.graph.id === id && draft.directory === access.directory)
|
|
471
|
+
this.drafts.delete(key);
|
|
472
|
+
void this.sync?.sync();
|
|
473
|
+
const note = 'Revision saved locally. Cloud synchronization may still be pending.';
|
|
474
|
+
return deleting
|
|
475
|
+
? { id, revision: saved.revision, deletedAt, note: freshAccess.free ? note + ' A deleted graph still counts as this free account\'s one custom graph; restore it to use it again.' : note }
|
|
476
|
+
: { id, revision: saved.revision, note };
|
|
477
|
+
}
|
|
403
478
|
/** Missing graph identity is not a broken graph. Tell the agent to list or create it. */
|
|
404
479
|
async readGraph(id, directory, revision) {
|
|
405
480
|
try {
|
|
@@ -462,9 +537,15 @@ export class AgentMcpBackend {
|
|
|
462
537
|
draft.graph.edges[index] = edge;
|
|
463
538
|
return { edge, edgeCount: draft.graph.edges.length };
|
|
464
539
|
}
|
|
465
|
-
|
|
540
|
+
/**
|
|
541
|
+
* Run one tool call. `beforeSave` runs synchronously immediately before a revision is written
|
|
542
|
+
* (publish, delete, restore), after every await that precedes the write; throwing from it abandons
|
|
543
|
+
* the save. An embedding host uses it to refuse a save its task may no longer make (cancelled, or
|
|
544
|
+
* switched to Plan) while the call was waiting on sign-in checks or cloud sync.
|
|
545
|
+
*/
|
|
546
|
+
async call(name, rawArgs = {}, options = {}) {
|
|
466
547
|
try {
|
|
467
|
-
return { ok: true, data: await this.dispatch(name, argsRecord(rawArgs)) };
|
|
548
|
+
return { ok: true, data: await this.dispatch(name, argsRecord(rawArgs), options.beforeSave) };
|
|
468
549
|
}
|
|
469
550
|
catch (error) {
|
|
470
551
|
if (error instanceof GraphConflictError)
|
|
@@ -489,7 +570,7 @@ export class AgentMcpBackend {
|
|
|
489
570
|
return { ok: false, error: backendIssue(error) };
|
|
490
571
|
}
|
|
491
572
|
}
|
|
492
|
-
async dispatch(name, args) {
|
|
573
|
+
async dispatch(name, args, beforeSave) {
|
|
493
574
|
if (name === 'andorra_graph_guide')
|
|
494
575
|
return { architecture: GRAPH_AGENT_GUIDE, resourceUri: 'andorra://graph/architecture' };
|
|
495
576
|
if (name === 'andorra_projects_list')
|
|
@@ -520,7 +601,7 @@ export class AgentMcpBackend {
|
|
|
520
601
|
}
|
|
521
602
|
if (name === 'andorra_providers_list')
|
|
522
603
|
return this.providers();
|
|
523
|
-
// Subagent runs need no account or membership: they execute the bundled
|
|
604
|
+
// Subagent runs need no account or membership: they execute the bundled Andorra Agent
|
|
524
605
|
// harness with a locally configured provider, the same tier as provider discovery.
|
|
525
606
|
if (name === 'andorra_subagent_start') {
|
|
526
607
|
const task = field(args, 'prompt');
|
|
@@ -605,11 +686,15 @@ export class AgentMcpBackend {
|
|
|
605
686
|
}
|
|
606
687
|
const access = await this.graphAccess();
|
|
607
688
|
if (name === 'andorra_graphs_list') {
|
|
608
|
-
|
|
689
|
+
if (args.includeDeleted !== undefined && typeof args.includeDeleted !== 'boolean')
|
|
690
|
+
throw new AgentMcpError('INVALID_ARGUMENTS', 'includeDeleted must be a boolean when supplied.');
|
|
691
|
+
const saved = await listGraphs(access.directory);
|
|
609
692
|
await this.assertGraphIdentity(access);
|
|
693
|
+
const graphs = args.includeDeleted === true ? saved : withoutDeletedGraphs(saved);
|
|
610
694
|
return { graphs: graphs.map(graph => ({
|
|
611
695
|
id: graph.id, name: graph.name, revision: graph.revision, entry: graph.entry, nodes: Object.keys(graph.nodes).length,
|
|
612
696
|
edges: graph.edges.length, description: graph.metadata?.description ?? '',
|
|
697
|
+
...(isDeletedGraph(graph) ? { deleted: true, deletedAt: graph.metadata.deletedAt } : {}),
|
|
613
698
|
})), sync: this.sync?.status ?? null };
|
|
614
699
|
}
|
|
615
700
|
if (name === 'andorra_graph_get') {
|
|
@@ -620,8 +705,10 @@ export class AgentMcpBackend {
|
|
|
620
705
|
// Read tools return the exact published revision, not an editor migration.
|
|
621
706
|
// Recheck account identity *after* the awaited account-owned filesystem read.
|
|
622
707
|
await this.assertGraphIdentity(access);
|
|
623
|
-
return { graph };
|
|
708
|
+
return { graph, ...(isDeletedGraph(graph) ? { deletedAt: graph.metadata.deletedAt } : {}) };
|
|
624
709
|
}
|
|
710
|
+
if (name === 'andorra_graph_delete' || name === 'andorra_graph_restore')
|
|
711
|
+
return this.setDeleted(name === 'andorra_graph_delete', args, access, beforeSave);
|
|
625
712
|
if (name === 'andorra_graph_begin') {
|
|
626
713
|
const mode = field(args, 'mode');
|
|
627
714
|
const id = field(args, 'id');
|
|
@@ -637,7 +724,10 @@ export class AgentMcpBackend {
|
|
|
637
724
|
let graph;
|
|
638
725
|
let expectedRevision;
|
|
639
726
|
if (mode === 'edit') {
|
|
640
|
-
|
|
727
|
+
const latest = await this.readGraph(id, access.directory);
|
|
728
|
+
if (isDeletedGraph(latest))
|
|
729
|
+
throw new AgentMcpError('GRAPH_DELETED', 'Graph ' + id + ' is deleted. Restore it with andorra_graph_restore before editing it.');
|
|
730
|
+
graph = migrateGraphForEditor(latest, { addOrchestrator: !access.free });
|
|
641
731
|
expectedRevision = graph.revision;
|
|
642
732
|
}
|
|
643
733
|
else if (mode === 'create') {
|
|
@@ -735,12 +825,18 @@ export class AgentMcpBackend {
|
|
|
735
825
|
if (!record(args.patch) || Object.keys(args.patch).some(key => !['name', 'entry', 'limits', 'metadata', 'widgets', 'inputSchema', 'stateSchema'].includes(key)))
|
|
736
826
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'Graph patch permits only name, entry, limits, metadata, widgets, inputSchema, stateSchema.');
|
|
737
827
|
const patch = structuredClone(args.patch);
|
|
828
|
+
if (record(patch.metadata) && Object.hasOwn(patch.metadata, 'deletedAt'))
|
|
829
|
+
throw new AgentMcpError('RESERVED_METADATA', 'metadata.deletedAt is reserved. Delete a graph with andorra_graph_delete and restore it with andorra_graph_restore.');
|
|
738
830
|
if (patch.entry !== undefined && (!safeId(patch.entry) || !Object.hasOwn(draft.graph.nodes, patch.entry)))
|
|
739
831
|
throw new AgentMcpError('ENTRY_NOT_FOUND', 'entry must be the id of an existing node.');
|
|
740
832
|
Object.assign(draft.graph, patch);
|
|
741
833
|
return { graphId: draft.graph.id, entry: draft.graph.entry, name: draft.graph.name };
|
|
742
834
|
}
|
|
743
835
|
if (name === 'andorra_graph_validate' || name === 'andorra_graph_publish') {
|
|
836
|
+
// A draft opened before this rule, or a node patch, could still carry the marker; publishing it
|
|
837
|
+
// would delete the graph without the delete tool's confirmation and automation checks.
|
|
838
|
+
if (draft.graph.metadata && Object.hasOwn(draft.graph.metadata, 'deletedAt'))
|
|
839
|
+
throw new AgentMcpError('RESERVED_METADATA', 'metadata.deletedAt is reserved. Delete a graph with andorra_graph_delete and restore it with andorra_graph_restore.');
|
|
744
840
|
const profiles = await this.providers();
|
|
745
841
|
const issues = graphIssues(draft.graph, profiles.providers, profiles.active, draft.authoredAgents);
|
|
746
842
|
if (name === 'andorra_graph_validate')
|
|
@@ -782,8 +878,13 @@ export class AgentMcpBackend {
|
|
|
782
878
|
const stamped = stampGraphProviderProfiles(normalized, latestProfiles);
|
|
783
879
|
if (Buffer.byteLength(JSON.stringify(stamped)) > 512 * 1024)
|
|
784
880
|
throw new AgentMcpError('VALIDATION_FAILED', 'Graph exceeds 512 KiB after portable provider identities are recorded.');
|
|
881
|
+
beforeSave?.();
|
|
785
882
|
const saved = finalAccess.free ? await saveFreeTierGraph(stamped, draft.expectedRevision, access.directory)
|
|
786
883
|
: await saveGraph(stamped, draft.expectedRevision, access.directory);
|
|
884
|
+
// A re-created graph id must not stay deleted: the editor's save endpoint clears the
|
|
885
|
+
// tombstone after its save, and a publish that reuses a deleted id must too, or the
|
|
886
|
+
// replacement keeps refusing autosaves and its cloud snapshots never restore here.
|
|
887
|
+
await this.sync?.reviveGraph(saved.id);
|
|
787
888
|
draft.graph = saved;
|
|
788
889
|
draft.expectedRevision = saved.revision;
|
|
789
890
|
void this.sync?.sync();
|
|
@@ -798,44 +899,12 @@ export class AgentMcpBackend {
|
|
|
798
899
|
}
|
|
799
900
|
}
|
|
800
901
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
const str = { type: 'string' };
|
|
804
|
-
const num = { type: 'integer', minimum: 0 };
|
|
805
|
-
const graphDraftSchema = { draftId: str };
|
|
806
|
-
const graphReference = { draftId: str, nodeId: str };
|
|
807
|
-
const searchFilters = { projectName: str, projectPath: str,
|
|
808
|
-
lookbackMinutes: num, updatedAfter: str, updatedBefore: str, includeArchived: { type: 'boolean' } };
|
|
809
|
-
const catalog = [
|
|
810
|
-
{ name: 'andorra_graph_guide', description: 'Read Andorra graph architecture, node types, outcome routes, loops and save error contracts.', inputSchema: obj({}) },
|
|
811
|
-
{ name: 'andorra_providers_list', description: 'List valid graph provider IDs and models without credentials.', inputSchema: obj({}) },
|
|
812
|
-
{ name: 'andorra_graphs_list', description: 'List available graphs, names and revisions.', inputSchema: obj({}) },
|
|
813
|
-
{ name: 'andorra_graph_get', description: 'Read one published graph, optionally by revision.', inputSchema: obj({ id: str, revision: { type: 'integer', minimum: 1 } }, ['id']) },
|
|
814
|
-
{ name: 'andorra_graph_begin', description: 'Open an ephemeral graph draft. mode=create needs a new id and name; mode=edit opens latest.', inputSchema: obj({ mode: { type: 'string', enum: ['create', 'edit'] }, id: str, name: str }, ['mode', 'id']) },
|
|
815
|
-
{ name: 'andorra_graph_node_upsert', description: 'Create or replace a node in a draft. Agent nodes require a configured provider ID.', inputSchema: obj({ draftId: str, node: { type: 'object' } }, ['draftId', 'node']) },
|
|
816
|
-
{ name: 'andorra_graph_node_patch', description: 'Change an existing node prompt, instruction, model, provider, completion, etc. without replacing other fields.', inputSchema: obj({ ...graphReference, patch: { type: 'object' } }, ['draftId', 'nodeId', 'patch']) },
|
|
817
|
-
{ name: 'andorra_graph_node_remove', description: 'Remove a non-entry node and its incident edges from a draft.', inputSchema: obj(graphReference, ['draftId', 'nodeId']) },
|
|
818
|
-
{ name: 'andorra_graph_edge_upsert', description: 'Create or replace an edge. Outcome must match a source node port (pass/fail, true/false, body/done...).', inputSchema: obj({ draftId: str, edge: { type: 'object' } }, ['draftId', 'edge']) },
|
|
819
|
-
{ name: 'andorra_graph_edge_remove', description: 'Remove an edge by ID from a draft.', inputSchema: obj({ ...graphDraftSchema, edgeId: str }, ['draftId', 'edgeId']) },
|
|
820
|
-
{ name: 'andorra_graph_patch', description: 'Set graph entry, name, limits, schemas, widgets or metadata in a draft.', inputSchema: obj({ draftId: str, patch: { type: 'object' } }, ['draftId', 'patch']) },
|
|
821
|
-
{ name: 'andorra_graph_validate', description: 'Validate a draft; report all missing provider and outcome paths, plus graph topology issues.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
822
|
-
{ name: 'andorra_graph_publish', description: 'Validate and atomically publish the next immutable graph revision; optimistic concurrency guards other editors.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
823
|
-
{ name: 'andorra_graph_discard', description: 'Discard an unpublished local graph draft.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
824
|
-
{ name: 'andorra_projects_list', description: 'List registered projects and discovered session workspaces.', inputSchema: obj({}) },
|
|
825
|
-
{ name: 'andorra_sessions_list', description: 'Search sessions by project, status and last X minutes (lookbackMinutes). Supports paginated results.', inputSchema: obj({ ...searchFilters, status: { type: 'string', enum: ['completed', 'pending', 'running', 'required_input', 'incomplete'] },
|
|
826
|
-
offset: num, limit: { type: 'integer', minimum: 1, maximum: 100 } }) },
|
|
827
|
-
{ name: 'andorra_session_get', description: 'Read session metadata and up to 20 recent turn excerpts; no filesystem access.', inputSchema: obj({ sessionId: str,
|
|
828
|
-
historyLimit: { type: 'integer', minimum: 0, maximum: 20 }, historyOffset: num }, ['sessionId']) },
|
|
829
|
-
{ name: 'andorra_sessions_attention', description: 'Find sessions requiring human feedback or review: required_input and incomplete; supports project and time filters.', inputSchema: obj(searchFilters) },
|
|
830
|
-
{ name: 'andorra_subagent_start', description: 'Run the bundled Software Engineer graph once as an Andorra subagent. Requires a provider/model: pass provider and model, or the saved /subagent setting. On PROVIDER_NOT_SET, show the listed providers and models to your user, ask which to use, then retry with provider and model. Writes are allowed unless permissions is read-only.', inputSchema: obj({ prompt: str, provider: str, model: str, permissions: { type: 'string', enum: ['full-access', 'read-only'] }, workspace: str }, ['prompt']) },
|
|
831
|
-
{ name: 'andorra_subagent_status', description: 'Poll the subagent run: state, current node and recent events. The runId must be the one the start returned, so the answer is about that run.', inputSchema: obj({ runId: str }, ['runId']) },
|
|
832
|
-
{ name: 'andorra_subagent_result', description: 'Read the subagent run outcome. waitMs (0-60000) waits for completion within the call; otherwise returns running immediately when unfinished. The finished reply carries the full run result including completion summary and status. The runId must be the one the start returned.', inputSchema: obj({ waitMs: { type: 'integer', minimum: 0, maximum: 60000 }, runId: str }, ['runId']) },
|
|
833
|
-
{ name: 'andorra_subagent_cancel', description: 'Cancel the subagent run. The runId must be the one the start returned, so a delayed cancellation cannot stop a run that replaced it.', inputSchema: obj({ runId: str }, ['runId']) },
|
|
834
|
-
];
|
|
902
|
+
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
903
|
+
export { AGENT_MCP_TOOL_NAMES };
|
|
835
904
|
export async function runAgentMcpServer() {
|
|
836
905
|
const backend = new AgentMcpBackend();
|
|
837
906
|
const server = new Server({ name: 'andorra-code-agent-control', version: '1.0.0' }, { capabilities: { tools: {}, resources: {} } });
|
|
838
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools:
|
|
907
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...AGENT_MCP_CATALOG] }));
|
|
839
908
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
840
909
|
const reply = await backend.call(request.params.name, request.params.arguments ?? {});
|
|
841
910
|
return { isError: !reply.ok, content: [{ type: 'text', text: JSON.stringify(reply) }] };
|
|
@@ -44,7 +44,7 @@ export declare const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
|
44
44
|
* one when a client omits it. An engine without it rebuilds a replaced entry from its own field
|
|
45
45
|
* list, so a save through it silently drops the rename and every surface falls back to the id; a
|
|
46
46
|
* client that can show the field must refuse the write first. */
|
|
47
|
-
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "automations", "providers.models", "providers.test", "providers.test.model", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.name", "providers.claude", "providers.opencodeGo", "providers.discover.draft", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.steer", "run.overrideAllNodes", "run.setModel", "run.start.continueSession", "remote.owner.projects", "remote.workspaces.probe", "remote.engine.relay", "remote.hosting.device.grant", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "browser.view.go"];
|
|
47
|
+
export declare const APP_SERVER_CAPABILITIES: readonly ["run.start.runPermissions", "automations", "providers.models", "providers.test", "providers.test.model", "providers.streamIdleTimeout", "providers.modelContextWindows", "providers.name", "providers.claude", "providers.claudeAuth", "providers.grok", "providers.opencode", "providers.auth.submit", "providers.opencodeGo", "providers.discover.draft", "providers.codexAuth", "providers.codexAuth.logout", "providers.codexAccounts", "providers.anthropicConsole", "run.resume.direction", "run.resume.model", "run.steer", "run.overrideAllNodes", "run.setModel", "run.setModel.node", "run.setPermissions", "run.start.continueSession", "run.start.entryHistory", "remote.owner.projects", "remote.workspaces.probe", "remote.engine.relay", "remote.hosting.device.grant", "extensions.manage", "extensions.resources", "skills.invoke", "mcp.manage", "runs.files", "sessions.files", "account.profile", "sessions.stats", "sessions.usage", "config.analytics", "config.analytics.planGate", "sessions.trajectory", "config.externalSubagent", "config.decisions", "browser.view", "attachments.read", "config.general", "sessions.pullRequest", "browser.view.go", "config.browser", "config.webSearch"];
|
|
48
48
|
/** One client call. `params` is omitted only for calls that take no arguments. */
|
|
49
49
|
export interface AppServerRequest {
|
|
50
50
|
id: number | string;
|
|
@@ -103,7 +103,7 @@ export interface AppServerHostInfo {
|
|
|
103
103
|
*/
|
|
104
104
|
export type AppServerErrorCode = 'invalid-request' | 'unknown-method' | 'invalid-params' | 'busy' | 'engine-busy' | 'not-found' | 'login-required' | 'auth' | 'storage' | 'network' | 'cancelled' | 'internal' | 'remote' | 'nothing-to-continue';
|
|
105
105
|
/** The permission modes a project can hold, mirroring `src/permissions.ts`. */
|
|
106
|
-
export type AppServerPermissionMode = 'read-only' | 'ask-for-approval' | 'approve-for-me' | 'full-access';
|
|
106
|
+
export type AppServerPermissionMode = 'read-only' | 'plan' | 'ask-for-approval' | 'approve-for-me' | 'full-access';
|
|
107
107
|
/** Verified official Codex account/catalog, never its credentials or token payloads. */
|
|
108
108
|
export interface AppServerProviderAuth {
|
|
109
109
|
state: 'signedOut' | 'starting' | 'waiting' | 'signedIn' | 'cancelled' | 'error';
|
|
@@ -123,11 +123,30 @@ export interface AppServerProviderAuth {
|
|
|
123
123
|
organization?: string;
|
|
124
124
|
/** The Claude Console workspace a signed-in Anthropic provider's token is bound to. */
|
|
125
125
|
workspace?: string;
|
|
126
|
+
/** A device code the person confirms on the sign-in page (Grok). Only a start answer carries it. */
|
|
127
|
+
userCode?: string;
|
|
128
|
+
/** The CLI waits for a code the sign-in page shows; submit it with providers.auth.submit. */
|
|
129
|
+
acceptsCode?: boolean;
|
|
130
|
+
/** OpenCode: the upstream providers it has connected. */
|
|
131
|
+
connected?: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
name: string;
|
|
134
|
+
}>;
|
|
135
|
+
/** OpenCode: the browser sign-ins it offers, by upstream provider and method index. */
|
|
136
|
+
signInOptions?: Array<{
|
|
137
|
+
providerId: string;
|
|
138
|
+
providerName: string;
|
|
139
|
+
method: number;
|
|
140
|
+
label: string;
|
|
141
|
+
connected: boolean;
|
|
142
|
+
}>;
|
|
143
|
+
/** OpenCode: the upstream provider the attempt in progress signs in to. */
|
|
144
|
+
signInProvider?: string;
|
|
126
145
|
}
|
|
127
146
|
/** One configured provider as the client may see it. API keys are never included. */
|
|
128
147
|
export interface AppServerProvider {
|
|
129
148
|
id: string;
|
|
130
|
-
type: 'openai-compatible' | 'anthropic' | 'codex' | 'claude' | 'opencode-go';
|
|
149
|
+
type: 'openai-compatible' | 'anthropic' | 'codex' | 'claude' | 'opencode-go' | 'grok' | 'opencode';
|
|
131
150
|
baseUrl: string;
|
|
132
151
|
model: string;
|
|
133
152
|
apiKeyEnv?: string;
|
|
@@ -214,6 +233,32 @@ export interface AppServerConfig {
|
|
|
214
233
|
systemPromptOverride?: string | null;
|
|
215
234
|
/** Days without activity before a session is archived automatically (1-30); null in a patch turns it off. */
|
|
216
235
|
autoArchiveDays?: number | null;
|
|
236
|
+
/**
|
|
237
|
+
* Browser tool settings. The CapSolver key itself is never reported: `hasCapsolverKey` says one is
|
|
238
|
+
* saved, and `capsolverKeySource` which key the solve tool would use (the saved one wins over
|
|
239
|
+
* `CAPSOLVER_API_KEY`). A patch sends `{ browser: { capsolverApiKey: string | null } }`.
|
|
240
|
+
*/
|
|
241
|
+
browser?: {
|
|
242
|
+
hasCapsolverKey: boolean;
|
|
243
|
+
capsolverKeySource?: 'config' | 'env';
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* The web_search tool's services. Keys are never reported: for each service `saved` says the
|
|
247
|
+
* configuration holds its key (or, for SearXNG, its URL), and `source` which value the tool would
|
|
248
|
+
* use (absent when it is not usable). The search engine ID and SearXNG URL are not secrets and come
|
|
249
|
+
* back as saved. A patch sends `{ webSearch: { <field>: string | null } }` with any of
|
|
250
|
+
* defaultProvider, braveApiKey, tavilyApiKey, exaApiKey, serperApiKey, googleApiKey,
|
|
251
|
+
* googleSearchEngineId and searxngUrl; null removes the field and an omitted one is kept.
|
|
252
|
+
*/
|
|
253
|
+
webSearch?: {
|
|
254
|
+
defaultProvider?: 'brave' | 'tavily' | 'exa' | 'serper' | 'google' | 'searxng';
|
|
255
|
+
providers: Record<'brave' | 'tavily' | 'exa' | 'serper' | 'google' | 'searxng', {
|
|
256
|
+
saved: boolean;
|
|
257
|
+
source?: 'config' | 'env';
|
|
258
|
+
}>;
|
|
259
|
+
googleSearchEngineId?: string;
|
|
260
|
+
searxngUrl?: string;
|
|
261
|
+
};
|
|
217
262
|
}
|
|
218
263
|
export interface AppServerAccount {
|
|
219
264
|
signedIn: boolean;
|
|
@@ -329,6 +374,8 @@ export interface AppServerSessionSummary {
|
|
|
329
374
|
requests: number;
|
|
330
375
|
cacheRead?: number;
|
|
331
376
|
cacheWrite?: number;
|
|
377
|
+
localCacheInputTokens?: number;
|
|
378
|
+
localCacheReadTokens?: number;
|
|
332
379
|
};
|
|
333
380
|
}
|
|
334
381
|
/** How a saved attempt ended. `succeeded` is the engine's reading of a turn that carries no status. */
|
|
@@ -379,7 +426,11 @@ export interface AppServerGitFile {
|
|
|
379
426
|
index: string;
|
|
380
427
|
worktree: string;
|
|
381
428
|
}
|
|
382
|
-
/**
|
|
429
|
+
/**
|
|
430
|
+
* `truncated` means the working tree listed more changes than the engine reads in one answer, and
|
|
431
|
+
* `repository` is false unless a `.git` sits at the workspace folder or its immediate parent: a
|
|
432
|
+
* repository Git would only reach by walking further up the tree is not that folder's.
|
|
433
|
+
*/
|
|
383
434
|
export interface AppServerGitStatus {
|
|
384
435
|
repository: boolean;
|
|
385
436
|
branch?: string;
|
|
@@ -391,7 +442,8 @@ export interface AppServerGitStatus {
|
|
|
391
442
|
*
|
|
392
443
|
* `current` is absent in a detached HEAD rather than naming the commit as if it were a branch, and
|
|
393
444
|
* `branches` holds local branches only: a remote-tracking ref is not a branch a checkout can land on
|
|
394
|
-
* without a decision — which local branch tracks it — the client cannot express here.
|
|
445
|
+
* without a decision — which local branch tracks it — the client cannot express here. The repository
|
|
446
|
+
* has to be the workspace folder itself or its immediate parent; `repository` is false otherwise.
|
|
395
447
|
*/
|
|
396
448
|
export interface AppServerBranchList {
|
|
397
449
|
repository: boolean;
|
|
@@ -37,6 +37,10 @@ export const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
|
37
37
|
// attempt's first steering message. An engine without it accepts the field and ignores it, so a
|
|
38
38
|
// client that offers a continuation message must not send one to such an engine: the resume would
|
|
39
39
|
// succeed with the user's instruction silently dropped.
|
|
40
|
+
// `run.resume.model`: `run.resume` honors an explicit `provider`/`model` pair and runs the continued
|
|
41
|
+
// attempt on it (checkpoint re-attribution, like a live model switch). An engine without it accepts
|
|
42
|
+
// the fields and ignores them, so a client that offers a switched pair must not send one to such an
|
|
43
|
+
// engine: the resume would succeed while silently continuing on the stopped attempt's own pair.
|
|
40
44
|
// `remote.engine.relay`: this engine can proxy a full-grant paired workspace's engine surface —
|
|
41
45
|
// `remote.engine.connect`/`request`/`disconnect` — so a window may run tasks on that machine. An
|
|
42
46
|
// engine without it has only the browse subset, and the desktop keeps the read-only presentation.
|
|
@@ -77,6 +81,11 @@ export const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
|
77
81
|
// parameter and forks: the work still runs, but the session the client is showing stays behind and
|
|
78
82
|
// the rail grows a duplicate-named thread, so a client that keeps one task tree sends the flag only
|
|
79
83
|
// to an engine that advertises it.
|
|
84
|
+
// `run.start.entryHistory`: `run.start` accepts `entryHistory` with a `sessionId`, which hands the
|
|
85
|
+
// session's retained history to the graph's entry node whatever that node's own context policy says.
|
|
86
|
+
// A client sends it when the session switches to another graph, which starts from its entry node. An
|
|
87
|
+
// engine without it ignores the parameter, and the entry node sees the history only when its own
|
|
88
|
+
// policy asks for it.
|
|
80
89
|
// `automations`: the engine owns persistent schedules: `automations.*` lists, creates, updates,
|
|
81
90
|
// deletes and runs saved prompts, and reports the scheduler service's state, each firing as its own
|
|
82
91
|
// session. An engine without it answers `unknown-method`, so a window on such an engine hides the
|
|
@@ -103,4 +112,12 @@ export const APP_SERVER_PROTOCOL_VERSION = 2;
|
|
|
103
112
|
// engine without it answers `unknown-method`, and a client that offers steering must not fall back to
|
|
104
113
|
// cancelling the run: the attempt would stop for a message this engine could only deliver by starting
|
|
105
114
|
// it over.
|
|
106
|
-
|
|
115
|
+
// `run.setPermissions`: a live attempt changes its permission mode without restarting. Pending approvals are
|
|
116
|
+
// handed back to their tools to be decided again under the new mode, and the change is journaled as
|
|
117
|
+
// `run.permissions.changed`. An engine without it answers `unknown-method`; its running task keeps the mode it
|
|
118
|
+
// started with, and a client offers the pick for the next task only.
|
|
119
|
+
// `run.setModel.node`: `run.setModel` accepts `nodeId`, which scopes the switch to one agent node —
|
|
120
|
+
// and the children it delegates without a model of their own — instead of the run. An engine that
|
|
121
|
+
// advertises `run.setModel` but not this ignores the unknown parameter and would answer a node-scoped
|
|
122
|
+
// request as a whole-run one, so a client that promises one node's switch must refuse it here first.
|
|
123
|
+
export const APP_SERVER_CAPABILITIES = ['run.start.runPermissions', 'automations', 'providers.models', 'providers.test', 'providers.test.model', 'providers.streamIdleTimeout', 'providers.modelContextWindows', 'providers.name', 'providers.claude', 'providers.claudeAuth', 'providers.grok', 'providers.opencode', 'providers.auth.submit', 'providers.opencodeGo', 'providers.discover.draft', 'providers.codexAuth', 'providers.codexAuth.logout', 'providers.codexAccounts', 'providers.anthropicConsole', 'run.resume.direction', 'run.resume.model', 'run.steer', 'run.overrideAllNodes', 'run.setModel', 'run.setModel.node', 'run.setPermissions', 'run.start.continueSession', 'run.start.entryHistory', 'remote.owner.projects', 'remote.workspaces.probe', 'remote.engine.relay', 'remote.hosting.device.grant', 'extensions.manage', 'extensions.resources', 'skills.invoke', 'mcp.manage', 'runs.files', 'sessions.files', 'account.profile', 'sessions.stats', 'sessions.usage', 'config.analytics', 'config.analytics.planGate', 'sessions.trajectory', 'config.externalSubagent', 'config.decisions', 'browser.view', 'attachments.read', 'config.general', 'sessions.pullRequest', 'browser.view.go', 'config.browser', 'config.webSearch'];
|