@andorra-labs/code 0.1.8 → 0.1.10
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/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/src/account-presentation.d.ts +11 -0
- package/dist/src/account-presentation.js +29 -2
- package/dist/src/agent-execution.js +57 -4
- package/dist/src/agent-mcp.d.ts +12 -0
- package/dist/src/agent-mcp.js +81 -2
- package/dist/src/app-server/protocol.d.ts +120 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server/reasoning.d.ts +0 -8
- package/dist/src/app-server/reasoning.js +15 -28
- package/dist/src/app-server.d.ts +32 -0
- package/dist/src/app-server.js +214 -21
- package/dist/src/auth/AuthManager.d.ts +15 -0
- package/dist/src/auth/AuthManager.js +66 -7
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/browser-runner.js +1 -2
- package/dist/src/browser-server.js +10 -2
- package/dist/src/browser-session.js +6 -2
- package/dist/src/browser-stealth.d.ts +29 -0
- package/dist/src/browser-stealth.js +166 -0
- package/dist/src/browser-ui/app.js +123 -28
- package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
- package/dist/src/browser-ui/index.html +8 -8
- package/dist/src/browser-ui/style.css +199 -171
- package/dist/src/browser-ui/tokens.css +198 -0
- package/dist/src/browser-view.d.ts +57 -9
- package/dist/src/browser-view.js +187 -36
- package/dist/src/cli.js +31 -9
- package/dist/src/coding-tools.js +9 -5
- package/dist/src/command-screens.js +4 -4
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +3 -2
- package/dist/src/completion-gates.d.ts +35 -0
- package/dist/src/completion-gates.js +25 -0
- package/dist/src/completion.d.ts +7 -1
- package/dist/src/completion.js +37 -4
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/context-budget.d.ts +11 -0
- package/dist/src/context-budget.js +13 -0
- package/dist/src/decision/DecisionEngine.d.ts +5 -1
- package/dist/src/decision/DecisionManager.d.ts +1 -0
- package/dist/src/decision/DecisionManager.js +14 -3
- package/dist/src/decision/FactContinuations.d.ts +6 -0
- package/dist/src/decision/FactContinuations.js +9 -1
- package/dist/src/decision/FactServiceGate.js +1 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/hostedSkills.d.ts +37 -0
- package/dist/src/decision/hostedSkills.js +64 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
- package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
- package/dist/src/default-graph.d.ts +11 -0
- package/dist/src/default-graph.js +20 -0
- package/dist/src/duration.d.ts +13 -2
- package/dist/src/duration.js +27 -3
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.d.ts +302 -0
- package/dist/src/graph-manager-chat.js +940 -0
- package/dist/src/graph-runner.js +6 -0
- package/dist/src/graph-server.d.ts +9 -0
- package/dist/src/graph-server.js +171 -20
- package/dist/src/graph-studio-features.js +2 -2
- package/dist/src/graph-sync.js +5 -2
- package/dist/src/graph-ui/app.js +369 -183
- package/dist/src/graph-ui/controls.css +55 -32
- package/dist/src/graph-ui/controls.js +85 -9
- package/dist/src/graph-ui/edge-router.js +114 -13
- package/dist/src/graph-ui/embed.js +32 -17
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/library.css +4 -10
- package/dist/src/graph-ui/manager-markdown.js +155 -0
- package/dist/src/graph-ui/manager-state.js +191 -0
- package/dist/src/graph-ui/manager.css +161 -0
- package/dist/src/graph-ui/manager.js +700 -0
- package/dist/src/graph-ui/skill-picker.js +6 -6
- package/dist/src/graph-ui/studio-canvas.js +17 -15
- package/dist/src/graph-ui/studio.css +24 -23
- package/dist/src/graph-ui/studio.js +69 -48
- package/dist/src/graph-ui/style.css +128 -93
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +217 -151
- package/dist/src/graphs.d.ts +76 -2
- package/dist/src/graphs.js +172 -9
- package/dist/src/hardened-runtime.js +8 -2
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +14 -0
- package/dist/src/membership-errors.js +24 -1
- package/dist/src/membership.d.ts +20 -0
- package/dist/src/membership.js +45 -16
- package/dist/src/palette.d.ts +25 -8
- package/dist/src/palette.js +26 -8
- package/dist/src/provider-engine.d.ts +4 -4
- package/dist/src/provider-engine.js +39 -22
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/providers.d.ts +24 -0
- package/dist/src/providers.js +47 -2
- package/dist/src/qa/guidance.d.ts +26 -0
- package/dist/src/qa/guidance.js +46 -0
- package/dist/src/qa/index.d.ts +1 -8
- package/dist/src/qa/index.js +1 -16
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
- package/dist/src/qa/runtime/ProcessManager.js +69 -13
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.d.ts +11 -0
- package/dist/src/react-runtime.js +203 -53
- package/dist/src/remote/engine-pool.js +21 -6
- package/dist/src/run-progress.d.ts +6 -0
- package/dist/src/run-progress.js +7 -0
- package/dist/src/runtime.d.ts +8 -0
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +117 -0
- package/dist/src/session-changes.js +796 -0
- package/dist/src/session-skills.d.ts +75 -0
- package/dist/src/session-skills.js +151 -0
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +6 -12
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
- package/dist/src/stall-recovery.d.ts +33 -0
- package/dist/src/stall-recovery.js +83 -0
- package/dist/src/subagent-run.js +1 -2
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +66 -22
- package/dist/src/terminal-ui.js +327 -92
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +26 -2
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +23 -3
- package/dist/src/types.d.ts +24 -4
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +55 -15
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/limits.md +9 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +16 -1
- package/docs/guides/tui.md +9 -9
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
- package/package.json +1 -1
- package/tests/chat-side-panel-test-plan.md +1 -1
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
package/dist/src/graphs.js
CHANGED
|
@@ -5,9 +5,16 @@ import { configDirectory } from './config.js';
|
|
|
5
5
|
import { acquireSaveLock, archiveUnpublishedSnapshot, removeLockedFolder, SaveLockBusyError } from './save-lock.js';
|
|
6
6
|
import { validateMappingConstants, validateMappings, validateSchema, validateValue, schemaAt, nodeOutputSchema } from './handoffs.js';
|
|
7
7
|
import { CANONICAL_CODING_TOOLS, canonicalToolName, canonicalizeToolList, toolNameMatches } from './tool-names.js';
|
|
8
|
-
|
|
8
|
+
import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
|
|
9
|
+
export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.terminal', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
|
|
9
10
|
/** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
|
|
10
|
-
export const QA_TOOL_NAMES = ['qa.
|
|
11
|
+
export const QA_TOOL_NAMES = ['qa.terminal', 'qa.browser'];
|
|
12
|
+
/**
|
|
13
|
+
* The QA check pipeline, removed: these tools ran lint, tests and a merge gate that the agent's
|
|
14
|
+
* own shell commands already cover, at about two extra requests per run. A saved graph may still
|
|
15
|
+
* list them in a node's tools; they are dropped on load instead of failing the graph.
|
|
16
|
+
*/
|
|
17
|
+
export const RETIRED_GRAPH_TOOLS = new Set(['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.security']);
|
|
11
18
|
export const isQaToolName = (name) => QA_TOOL_NAMES.includes(name);
|
|
12
19
|
export const LEGACY_DEFAULT_HARNESS = {
|
|
13
20
|
schemaVersion: 1, id: 'default', name: 'Software Engineer', revision: 1, entry: 'engineer',
|
|
@@ -87,10 +94,60 @@ export const DEFAULT_HARNESS_REVISION_5 = {
|
|
|
87
94
|
* tasks alongside coding. The agent still receives the confirmed task instruction through the same
|
|
88
95
|
* intake handoff, and topology, capabilities and tooling are exactly revision 5's, so the change is
|
|
89
96
|
* presentation and instruction only.
|
|
97
|
+
*
|
|
98
|
+
* Revision 6 is frozen and is no longer the latest `default`: it is the body of the paid Andorra
|
|
99
|
+
* preset (`getAndorraHarness`), the Orchestrator -> Andorra Agent -> Done workflow. The graph a
|
|
100
|
+
* Default run executes is {@link DEFAULT_GRAPH}.
|
|
90
101
|
*/
|
|
91
102
|
export const DEFAULT_HARNESS = { ...structuredClone(DEFAULT_HARNESS_REVISION_5), name: 'Andorra Agent', revision: 6 };
|
|
92
103
|
DEFAULT_HARNESS.nodes.engineer.name = 'Andorra Agent';
|
|
93
104
|
DEFAULT_HARNESS.nodes.engineer.instruction = 'Carry out the confirmed task instruction completely, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly. Use the supplied requirements, acceptance criteria, design considerations and repository findings to guide the work. Verify the result and report remaining issues.';
|
|
105
|
+
/**
|
|
106
|
+
* Revision 7, the latest `default`: one Andorra Agent and no Orchestrator intake.
|
|
107
|
+
*
|
|
108
|
+
* Selecting Default runs a single agent that cannot delegate (`SOFTWARE_ENGINEER_HARNESS`, built from
|
|
109
|
+
* the same {@link DEFAULT_AGENT_GRAPH} as this revision), while revision 6 put an Orchestrator in front of it. Graph
|
|
110
|
+
* Studio and the graph tools read `default` from here, so they showed a workflow that Default never
|
|
111
|
+
* ran. This revision describes what Default runs; revision 6 remains loadable as history and as the
|
|
112
|
+
* Andorra preset. It is schema version 3 so the editor's migration leaves it as one agent rather than
|
|
113
|
+
* adding an Orchestrator in front of it.
|
|
114
|
+
*/
|
|
115
|
+
export const DEFAULT_GRAPH = {
|
|
116
|
+
schemaVersion: 3, id: 'default', name: DEFAULT_AGENT_GRAPH.name, revision: 7, entry: DEFAULT_AGENT_GRAPH.entry,
|
|
117
|
+
nodes: structuredClone(DEFAULT_AGENT_GRAPH.nodes), edges: structuredClone(DEFAULT_AGENT_GRAPH.edges),
|
|
118
|
+
};
|
|
119
|
+
/** The id of the bundled Graph Manager graph. Reserved: no saved, synced or deleted graph may use it. */
|
|
120
|
+
export const GRAPH_MANAGER_GRAPH_ID = 'andorra-graph-manager';
|
|
121
|
+
/**
|
|
122
|
+
* The graph Graph Studio's Graph Manager chat runs: one top-level agent and no Orchestrator intake.
|
|
123
|
+
*
|
|
124
|
+
* It is built in rather than saved so every installation has it and no account can edit it, and it
|
|
125
|
+
* is hidden from graph lists because it is not a workflow a user selects for a task. The agent
|
|
126
|
+
* sets neither `capabilities` nor `tools`, exactly as the default graph's execution agent: the
|
|
127
|
+
* defaults allow the shell, which is what grants the `graphs` tool, and filesystem reads, which
|
|
128
|
+
* grant `read_skill_resource`. A delegated subagent never receives `graphs`, so the work stays on
|
|
129
|
+
* this node. Only an Orchestrator is given `ask_user`, so the agent asks in its reply and the user's
|
|
130
|
+
* next message is the answer; the node keeps session history so that message sees the question.
|
|
131
|
+
*/
|
|
132
|
+
export const GRAPH_MANAGER_HARNESS = {
|
|
133
|
+
schemaVersion: 3, id: GRAPH_MANAGER_GRAPH_ID, name: 'Graph Manager', revision: 1, entry: 'manager',
|
|
134
|
+
nodes: {
|
|
135
|
+
manager: { id: 'manager', name: 'Graph Manager', type: 'agent', executor: 'react-basic', instruction: 'You are Graph Manager inside Graph Studio. Before acting, load the bundled skill andorra:graph-manager with read_skill_resource and follow it. Work only through the graphs tool; never write graph files. Reply to the user in the conversation; when a choice is theirs, ask in your reply and wait for their next message.', contextPolicy: { history: true }, position: { x: 120, y: 120 } },
|
|
136
|
+
done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
|
|
137
|
+
}, edges: [{ id: 'manager-done', source: 'manager', target: 'done', outcome: 'completed' }],
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The configured MCP servers a run of this graph connects at its start.
|
|
141
|
+
*
|
|
142
|
+
* Graph Manager works only through the `graphs` tool and its bundled skill, and its chat runs
|
|
143
|
+
* under Ask for approval, where every server raises a connection prompt before the first reply:
|
|
144
|
+
* its run connects none. Every other graph connects what the user configured.
|
|
145
|
+
*/
|
|
146
|
+
export function graphMcpServers(graphId, servers) {
|
|
147
|
+
return graphId === GRAPH_MANAGER_GRAPH_ID ? {} : servers;
|
|
148
|
+
}
|
|
149
|
+
/** The refusal every path that would write, delete or tombstone the reserved id answers with. */
|
|
150
|
+
export const reservedGraphId = (id) => new Error(`Graph id ${id} is reserved for a built-in graph`);
|
|
94
151
|
/** Upgrade only in-memory copies. Stored snapshots remain unchanged. */
|
|
95
152
|
/**
|
|
96
153
|
* `addOrchestrator: false` upgrades a legacy graph without an Orchestrator to the current schema as it
|
|
@@ -209,7 +266,14 @@ export function delegatesWriting(node) {
|
|
|
209
266
|
return node.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0
|
|
210
267
|
&& (node.subagents.roles ?? []).some(isWritingRole);
|
|
211
268
|
}
|
|
212
|
-
|
|
269
|
+
/**
|
|
270
|
+
* The shell setting alone decides whether a node runs commands. Filesystem and Git settings govern
|
|
271
|
+
* their own structured tools (Write/Edit, git writes) and do not take the shell away: a reviewer set
|
|
272
|
+
* to read files but allowed a shell needs `gh pr diff`, and withholding the shell silently left it
|
|
273
|
+
* with instructions it could not follow (run 8a245b0f). Commands still go through the run's approval
|
|
274
|
+
* rules. Ordinary delegated children never run commands; only a delegated-worktree child does.
|
|
275
|
+
*/
|
|
276
|
+
const canRunCommands = (policy, child) => child !== true && policy.shell === 'allowed';
|
|
213
277
|
export function permitsBuiltInTool(node, name, child = false) {
|
|
214
278
|
if (node.tools !== undefined && !node.tools.some(configured => toolNameMatches(configured, name)))
|
|
215
279
|
return false;
|
|
@@ -431,6 +495,88 @@ function toolsValid(value, label) {
|
|
|
431
495
|
fail(`${label}: tools must be unique supported tool names`);
|
|
432
496
|
}
|
|
433
497
|
export function validateGraph(value, options = {}) { return validateGraphInternal(value, options); }
|
|
498
|
+
/**
|
|
499
|
+
* The agent nodes a run can reach after this node, nearest first, without the node itself.
|
|
500
|
+
*
|
|
501
|
+
* Every outgoing edge counts whatever its outcome, so the list is what may run after the node,
|
|
502
|
+
* not what will: a node told what later nodes exist leaves their work to them rather than doing
|
|
503
|
+
* it early. A node a loop leads back to is still excluded, because it is this node.
|
|
504
|
+
*/
|
|
505
|
+
export function laterAgentNodes(graph, nodeId) {
|
|
506
|
+
const seen = new Set([nodeId]);
|
|
507
|
+
const later = [];
|
|
508
|
+
const queue = [nodeId];
|
|
509
|
+
for (let index = 0; index < queue.length; index += 1) {
|
|
510
|
+
for (const edge of graph.edges ?? []) {
|
|
511
|
+
if (edge.source !== queue[index] || seen.has(edge.target))
|
|
512
|
+
continue;
|
|
513
|
+
seen.add(edge.target);
|
|
514
|
+
queue.push(edge.target);
|
|
515
|
+
const node = graph.nodes[edge.target];
|
|
516
|
+
if (node?.type === 'agent')
|
|
517
|
+
later.push(node);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return later;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Whether a node's name says it tests the change: "QA Tester", "Test runner", "Verifier".
|
|
524
|
+
*
|
|
525
|
+
* Graphs declare no testing role, so the name is the evidence a graph author gives; a name that
|
|
526
|
+
* does not say so is treated as not testing, which leaves the node's predecessors told to verify
|
|
527
|
+
* their own work as before.
|
|
528
|
+
*/
|
|
529
|
+
export function isTestingNode(node) {
|
|
530
|
+
return /\b(?:qa|tests?|tester|testing|verif(?:y|ier|ication))\b/i.test(node.name ?? '');
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* The testing node this node's work is sure to pass through: every outcome the node can complete
|
|
534
|
+
* with routes, along every path, through a testing node before the run can end. Absent when any
|
|
535
|
+
* route can finish untested — a delegating Orchestrator's `delivered` edge straight to Done, an
|
|
536
|
+
* outcome no edge handles (this node's or any node's on the way), or a branch that reaches an end
|
|
537
|
+
* first — because a node told to leave
|
|
538
|
+
* the running app to a tester must not be one whose work can ship without that tester.
|
|
539
|
+
*
|
|
540
|
+
* A path that leads back to the node itself is not an escape: the node runs again and its own
|
|
541
|
+
* routes are the ones being checked.
|
|
542
|
+
*/
|
|
543
|
+
export function testerOnEveryRoute(graph, nodeId) {
|
|
544
|
+
const node = graph.nodes[nodeId];
|
|
545
|
+
if (node === undefined)
|
|
546
|
+
return undefined;
|
|
547
|
+
// The targets of each outcome a node declares, the way the runner routes them: an edge with no
|
|
548
|
+
// outcome is the `completed` route. A declared outcome with no edge is an empty route, which ends
|
|
549
|
+
// the run there (a graph saved with `requireRoutes: false` may leave one unconnected).
|
|
550
|
+
const routes = (id, of) => nodeOutcomes(of).map(outcome => (graph.edges ?? []).filter(edge => edge.source === id && (edge.outcome ?? 'completed') === outcome).map(edge => edge.target));
|
|
551
|
+
const seen = new Set([nodeId]);
|
|
552
|
+
const stack = [];
|
|
553
|
+
for (const targets of routes(nodeId, node)) {
|
|
554
|
+
if (targets.length === 0)
|
|
555
|
+
return undefined;
|
|
556
|
+
stack.push(...targets);
|
|
557
|
+
}
|
|
558
|
+
let tester;
|
|
559
|
+
while (stack.length > 0) {
|
|
560
|
+
const id = stack.pop();
|
|
561
|
+
if (seen.has(id))
|
|
562
|
+
continue;
|
|
563
|
+
seen.add(id);
|
|
564
|
+
const next = graph.nodes[id];
|
|
565
|
+
if (next === undefined || next.type === 'end')
|
|
566
|
+
return undefined;
|
|
567
|
+
if (next.type === 'agent' && isTestingNode(next)) {
|
|
568
|
+
tester ??= next.name;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
// Every outcome of a node on the way counts, not only the ones the graph happened to connect.
|
|
572
|
+
const nextRoutes = routes(id, next);
|
|
573
|
+
if (nextRoutes.length === 0 || nextRoutes.some(targets => targets.length === 0))
|
|
574
|
+
return undefined;
|
|
575
|
+
for (const targets of nextRoutes)
|
|
576
|
+
stack.push(...targets);
|
|
577
|
+
}
|
|
578
|
+
return tester;
|
|
579
|
+
}
|
|
434
580
|
/**
|
|
435
581
|
* Whether a run of this graph can execute the session's own provider/model pair.
|
|
436
582
|
*
|
|
@@ -546,6 +692,8 @@ function validateGraphInternal(value, options = {}) {
|
|
|
546
692
|
if (node[k] !== undefined && (typeof node[k] !== 'string' || node[k].length > 100000))
|
|
547
693
|
fail(`${label}: invalid ${k}`);
|
|
548
694
|
modelRef(node, label, options);
|
|
695
|
+
if (Array.isArray(node.tools) && node.tools.some(tool => RETIRED_GRAPH_TOOLS.has(tool)))
|
|
696
|
+
node.tools = node.tools.filter(tool => !RETIRED_GRAPH_TOOLS.has(tool));
|
|
549
697
|
toolsValid(node.tools, label);
|
|
550
698
|
bounds(node.maxIterations, `${label} maxIterations`, 1000, 0);
|
|
551
699
|
if (node.maxIterations === 0)
|
|
@@ -768,6 +916,8 @@ function validateGraphInternal(value, options = {}) {
|
|
|
768
916
|
if (r.outputSchema)
|
|
769
917
|
objectSchema(r.outputSchema, `${label} role outputSchema`);
|
|
770
918
|
subagentModelRef({ ...r, provider: r.provider ?? node.provider ?? options.defaultProvider }, `${label} role ${r.id}`, options);
|
|
919
|
+
if (Array.isArray(r.tools) && r.tools.some(tool => RETIRED_GRAPH_TOOLS.has(tool)))
|
|
920
|
+
r.tools = r.tools.filter(tool => !RETIRED_GRAPH_TOOLS.has(tool));
|
|
771
921
|
toolsValid(r.tools, `${label} role ${r.id}`);
|
|
772
922
|
if (s.context === 'task-only' && r.inputSchema?.required?.length)
|
|
773
923
|
fail(`${label}: task-only context cannot supply required inputs for role ${r.id}; select selected context or make the role inputs optional`);
|
|
@@ -1032,6 +1182,8 @@ export async function restoreGraphRevision(input, directory, skip, floorOf) {
|
|
|
1032
1182
|
const graph = validateGraphInternal(input);
|
|
1033
1183
|
if (graph.id === 'default' || graph.revision < 1)
|
|
1034
1184
|
throw new Error('Invalid cloud revision');
|
|
1185
|
+
if (graph.id === GRAPH_MANAGER_GRAPH_ID)
|
|
1186
|
+
throw reservedGraphId(graph.id);
|
|
1035
1187
|
const folder = join(directory, 'graphs', graph.id);
|
|
1036
1188
|
await mkdir(folder, { recursive: true });
|
|
1037
1189
|
const release = await acquireSaveLock(folder);
|
|
@@ -1133,9 +1285,15 @@ export async function loadGraph(id, revision, directory = configDirectory()) {
|
|
|
1133
1285
|
if (revision !== undefined && (!Number.isSafeInteger(revision) || revision < 1))
|
|
1134
1286
|
throw new Error('Invalid graph revision');
|
|
1135
1287
|
if (id === 'default') {
|
|
1136
|
-
if (revision !== undefined && ![1, 2, 3, 4, 5, 6].includes(revision))
|
|
1288
|
+
if (revision !== undefined && ![1, 2, 3, 4, 5, 6, 7].includes(revision))
|
|
1137
1289
|
throw new Error('Default graph revision does not exist');
|
|
1138
|
-
return structuredClone(revision === 1 ? LEGACY_DEFAULT_HARNESS : revision === 2 ? DEFAULT_HARNESS_REVISION_2 : revision === 3 ? DEFAULT_HARNESS_REVISION_3 : revision === 4 ? DEFAULT_HARNESS_REVISION_4 : revision === 5 ? DEFAULT_HARNESS_REVISION_5 : DEFAULT_HARNESS);
|
|
1290
|
+
return structuredClone(revision === 1 ? LEGACY_DEFAULT_HARNESS : revision === 2 ? DEFAULT_HARNESS_REVISION_2 : revision === 3 ? DEFAULT_HARNESS_REVISION_3 : revision === 4 ? DEFAULT_HARNESS_REVISION_4 : revision === 5 ? DEFAULT_HARNESS_REVISION_5 : revision === 6 ? DEFAULT_HARNESS : DEFAULT_GRAPH);
|
|
1291
|
+
}
|
|
1292
|
+
// Built in like `default`: answered before storage is read, so a folder of the same name is never loaded.
|
|
1293
|
+
if (id === GRAPH_MANAGER_GRAPH_ID) {
|
|
1294
|
+
if (revision !== undefined && revision !== GRAPH_MANAGER_HARNESS.revision)
|
|
1295
|
+
throw new Error('Graph Manager graph revision does not exist');
|
|
1296
|
+
return structuredClone(GRAPH_MANAGER_HARNESS);
|
|
1139
1297
|
}
|
|
1140
1298
|
const folder = join(directory, 'graphs', id);
|
|
1141
1299
|
const selected = revision ?? JSON.parse(await readFile(join(folder, 'latest.json'), 'utf8'));
|
|
@@ -1153,11 +1311,11 @@ export async function listGraphs(directory = configDirectory(), onLoadError) {
|
|
|
1153
1311
|
}
|
|
1154
1312
|
catch (error) {
|
|
1155
1313
|
if (error.code === 'ENOENT')
|
|
1156
|
-
return [structuredClone(
|
|
1314
|
+
return [structuredClone(DEFAULT_GRAPH)];
|
|
1157
1315
|
throw error;
|
|
1158
1316
|
}
|
|
1159
|
-
const graphs = [structuredClone(
|
|
1160
|
-
for (const entry of entries.filter(item => item.isDirectory() && validId(item.name) && item.name !== 'default').sort((a, b) => a.name.localeCompare(b.name))) {
|
|
1317
|
+
const graphs = [structuredClone(DEFAULT_GRAPH)];
|
|
1318
|
+
for (const entry of entries.filter(item => item.isDirectory() && validId(item.name) && item.name !== 'default' && item.name !== GRAPH_MANAGER_GRAPH_ID).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
1161
1319
|
try {
|
|
1162
1320
|
graphs.push(await loadGraph(entry.name, undefined, directory));
|
|
1163
1321
|
}
|
|
@@ -1171,6 +1329,8 @@ export async function saveGraph(input, expectedRevision, directory = configDirec
|
|
|
1171
1329
|
const graph = validateGraph(input);
|
|
1172
1330
|
if (graph.id === 'default')
|
|
1173
1331
|
throw new Error('Duplicate the bundled default graph before customizing it');
|
|
1332
|
+
if (graph.id === GRAPH_MANAGER_GRAPH_ID)
|
|
1333
|
+
throw reservedGraphId(graph.id);
|
|
1174
1334
|
if (expectedRevision !== null && (!Number.isSafeInteger(expectedRevision) || expectedRevision < 1))
|
|
1175
1335
|
throw new Error('Invalid expected revision');
|
|
1176
1336
|
if (graph.revision !== (expectedRevision ?? 0))
|
|
@@ -1232,11 +1392,14 @@ export async function saveGraph(input, expectedRevision, directory = configDirec
|
|
|
1232
1392
|
* race one into leaving a half-written folder behind. The folder leaves the live path in one
|
|
1233
1393
|
* rename while the lock is held, so a save that lands during the removal writes into a fresh
|
|
1234
1394
|
* folder and survives it. Deleting the bundled `default` is refused: it has no storage to remove,
|
|
1235
|
-
* and a hidden preset would only return on the next launch.
|
|
1395
|
+
* and a hidden preset would only return on the next launch. The built-in Graph Manager graph is
|
|
1396
|
+
* refused for the same reason, by name.
|
|
1236
1397
|
*/
|
|
1237
1398
|
export async function deleteGraph(id, directory = configDirectory(), options = {}) {
|
|
1238
1399
|
if (!validId(id) || id === 'default')
|
|
1239
1400
|
throw new Error('Invalid graph id');
|
|
1401
|
+
if (id === GRAPH_MANAGER_GRAPH_ID)
|
|
1402
|
+
throw reservedGraphId(id);
|
|
1240
1403
|
const folder = join(directory, 'graphs', id);
|
|
1241
1404
|
let releaseLock;
|
|
1242
1405
|
try {
|
|
@@ -13,6 +13,7 @@ import { factTaskText } from './decision/facts.js';
|
|
|
13
13
|
import { isVerificationCheck } from './decision/checks.js';
|
|
14
14
|
import { FactContinuations, FACT_CONTINUATION_GUIDANCE, FINISH_SUMMARY_DESCRIPTION, PREPARE_FINISH, taskConstraints, localCheckResult, prepareFinishArguments, prepareFinishDescription } from './decision/FactContinuations.js';
|
|
15
15
|
import { bypassGeneration } from './decision/ContinuationAdapter.js';
|
|
16
|
+
import { bypassAccounting } from './context-budget.js';
|
|
16
17
|
/**
|
|
17
18
|
* Facts select concrete continuations at the coding-adapter boundary; the one React engine still
|
|
18
19
|
* validates and executes every call, hook, approval, budget and completion contract. A synthetic
|
|
@@ -98,6 +99,8 @@ export class AndorraAgentEngine {
|
|
|
98
99
|
let calls = [];
|
|
99
100
|
let automatic;
|
|
100
101
|
let acceptedAutomatic;
|
|
102
|
+
/** What each bypassed request would have sent, read from the request it answered. */
|
|
103
|
+
const bypassInput = new WeakMap();
|
|
101
104
|
let liveProvider = options.provider, liveModel = options.model;
|
|
102
105
|
let task = options.decisionTask ?? options.task;
|
|
103
106
|
let steered = false;
|
|
@@ -219,6 +222,9 @@ export class AndorraAgentEngine {
|
|
|
219
222
|
if (!automatic)
|
|
220
223
|
return undefined;
|
|
221
224
|
const next = automatic;
|
|
225
|
+
const wouldSend = request.estimateInputTokens?.();
|
|
226
|
+
if (wouldSend !== undefined)
|
|
227
|
+
bypassInput.set(next, wouldSend);
|
|
222
228
|
await emit('efficiency.facts.action', { action: next.kind });
|
|
223
229
|
await emit('efficiency.prepared.selected', { reason: 'fact_selected', kind: next.kind, evidenceSource: next.evidenceSource });
|
|
224
230
|
request.signal.throwIfAborted();
|
|
@@ -287,7 +293,7 @@ export class AndorraAgentEngine {
|
|
|
287
293
|
const outcome = batch.find(o => o.call.id === automatic.id);
|
|
288
294
|
if (outcome?.executionSucceeded && !outcome.isError) {
|
|
289
295
|
await emit('efficiency.prepared.executed', { kind: automatic.kind, succeeded: true });
|
|
290
|
-
await emit('decision.turn_bypassed', { kind: automatic.kind, selection: 'fact_selected', evidenceSource: automatic.evidenceSource, accounting: 'observed_bypass_not_net_savings' });
|
|
296
|
+
await emit('decision.turn_bypassed', { kind: automatic.kind, selection: 'fact_selected', evidenceSource: automatic.evidenceSource, accounting: 'observed_bypass_not_net_savings', ...bypassAccounting(bypassInput.get(automatic), liveProvider, liveModel) });
|
|
291
297
|
}
|
|
292
298
|
else
|
|
293
299
|
await emit('efficiency.prepared.rejected', { kind: automatic.kind, reason: 'execution_not_confirmed' });
|
|
@@ -367,7 +373,7 @@ export class AndorraAgentEngine {
|
|
|
367
373
|
});
|
|
368
374
|
// Count completion only when the normal engine actually accepted and returned success.
|
|
369
375
|
if (result.status === 'succeeded' && acceptedAutomatic) {
|
|
370
|
-
await emit('decision.turn_bypassed', { kind: 'complete', selection: 'fact_selected', evidenceSource: acceptedAutomatic.evidenceSource, accounting: 'observed_bypass_not_net_savings' });
|
|
376
|
+
await emit('decision.turn_bypassed', { kind: 'complete', selection: 'fact_selected', evidenceSource: acceptedAutomatic.evidenceSource, accounting: 'observed_bypass_not_net_savings', ...bypassAccounting(bypassInput.get(acceptedAutomatic), liveProvider, liveModel) });
|
|
371
377
|
}
|
|
372
378
|
return result;
|
|
373
379
|
}
|
package/dist/src/mcp.d.ts
CHANGED
|
@@ -42,6 +42,80 @@ export declare function mcpCatalogKey(id: string, config: RuntimeMcpServerConfig
|
|
|
42
42
|
/** Remembered catalogs as one small file each under the configuration home. Every failure reads as "not remembered". */
|
|
43
43
|
export declare function mcpCatalogStore(directory: string): McpCatalogStore;
|
|
44
44
|
export declare function mcpToolName(server: string, tool: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* A server definition as an edit form sent it, applied over the saved one.
|
|
47
|
+
*
|
|
48
|
+
* Environment values and header values are secrets the engine never returns, so the form cannot
|
|
49
|
+
* send them back: an entry whose value is `null` keeps the saved value of that name, an entry with
|
|
50
|
+
* a string is the new value, and a name the edit leaves out is removed. An endpoint sent without
|
|
51
|
+
* the query string the saved one carries (the form is shown it without, since a query can hold a
|
|
52
|
+
* credential) keeps the saved endpoint. The transport may change; whether the server is enabled
|
|
53
|
+
* does not — the switch beside it does that.
|
|
54
|
+
*/
|
|
55
|
+
export declare function mergeMcpEdit(saved: McpServerConfig, edit: unknown): McpServerConfig;
|
|
56
|
+
/** Told how a server's connection went, by the task that made it: what the status store records. */
|
|
57
|
+
export type McpStatusReporter = (id: string, config: RuntimeMcpServerConfig, result: McpProbeResult) => void;
|
|
58
|
+
/**
|
|
59
|
+
* A reporter that records what a task's connections answered. A task names a server from the
|
|
60
|
+
* configuration `configured:<id>` (the extension snapshot's namespace, apart from plugins' servers),
|
|
61
|
+
* and the record is filed under the configuration's own id, which is what the settings page lists.
|
|
62
|
+
*/
|
|
63
|
+
export declare function mcpTaskStatusReporter(directory: string): McpStatusReporter;
|
|
64
|
+
/** What a server last answered — to a task's connection or an explicit check — and when. */
|
|
65
|
+
export interface McpStatusRecord {
|
|
66
|
+
id: string;
|
|
67
|
+
/** The definition it answered for (`mcpDefinitionKey`): an edited server has no status yet. */
|
|
68
|
+
definition: string;
|
|
69
|
+
state: 'ready' | 'failed';
|
|
70
|
+
tools?: number;
|
|
71
|
+
error?: string;
|
|
72
|
+
checkedAt: string;
|
|
73
|
+
source: 'task' | 'check';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The identity of a server's definition — command, arguments, environment, address, headers — and
|
|
77
|
+
* not whether it is turned on, so a status survives the switch but not an edit. Credentials in the
|
|
78
|
+
* definition only enter the digest.
|
|
79
|
+
*/
|
|
80
|
+
export declare function mcpDefinitionKey(config: RuntimeMcpServerConfig): string;
|
|
81
|
+
/**
|
|
82
|
+
* The last thing each server answered, one small file per server under the configuration home, so a
|
|
83
|
+
* settings page can show it without starting anything. A task's connection writes it, and so does an
|
|
84
|
+
* explicit check (`mcp.status`); one file per server keeps two processes recording at once from
|
|
85
|
+
* overwriting each other's servers. Every failure to read reads as "not checked".
|
|
86
|
+
*/
|
|
87
|
+
export declare function mcpStatusStore(directory: string): {
|
|
88
|
+
list(): Promise<McpStatusRecord[]>;
|
|
89
|
+
record(id: string, config: RuntimeMcpServerConfig, result: McpProbeResult, source: McpStatusRecord['source'], at?: Date): Promise<McpStatusRecord>;
|
|
90
|
+
};
|
|
91
|
+
/** What a configured server answered when it was asked for its tools outside a task. */
|
|
92
|
+
export type McpProbeResult = {
|
|
93
|
+
state: 'ready';
|
|
94
|
+
tools: number;
|
|
95
|
+
} | {
|
|
96
|
+
state: 'failed';
|
|
97
|
+
error: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Start one configured server, list its tools, and stop it again: the check a person asks for from
|
|
101
|
+
* the settings page ("Check Connection"), never one a page makes on its own — a task asks before it
|
|
102
|
+
* connects a server, and opening a page is not that consent.
|
|
103
|
+
*
|
|
104
|
+
* Nothing is kept. The catalog is only counted, and the client — with the process it started, for a
|
|
105
|
+
* stdio server — is closed before this returns, whatever happened. A probe is bounded in time as a
|
|
106
|
+
* task's connection is: 15 seconds to connect, 15 per page of tools, 30 in all.
|
|
107
|
+
*/
|
|
108
|
+
export declare function probeMcpServer(config: RuntimeMcpServerConfig, workspace: string, signal?: AbortSignal): Promise<McpProbeResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Why a probe failed, in words a person can act on.
|
|
111
|
+
*
|
|
112
|
+
* A transport error can carry what the server sent back, and an HTTP one can echo the request's own
|
|
113
|
+
* headers, so the message itself is never passed on: the error is sorted into a known kind, and only
|
|
114
|
+
* the facts that are the configuration's own (its command) or the protocol's (a status code) are named.
|
|
115
|
+
*/
|
|
116
|
+
export declare function probeFailureReason(error: unknown, config: Pick<McpServerConfig, 'transport'> & {
|
|
117
|
+
command?: string;
|
|
118
|
+
}): string;
|
|
45
119
|
/**
|
|
46
120
|
* Each task owns its clients; no server tools or spawned processes survive task exit.
|
|
47
121
|
*
|
|
@@ -57,6 +131,7 @@ export declare function mcpToolName(server: string, tool: string): string;
|
|
|
57
131
|
*/
|
|
58
132
|
export declare function connectMcpServers(servers: Record<string, RuntimeMcpServerConfig>, context: ToolContext, notice: (message: string) => void, taskSignal?: AbortSignal, options?: {
|
|
59
133
|
catalogs?: McpCatalogStore;
|
|
134
|
+
status?: McpStatusReporter;
|
|
60
135
|
}): Promise<{
|
|
61
136
|
tools: Tool[];
|
|
62
137
|
close(): Promise<void>;
|