@andorra-labs/code 0.1.15 → 0.1.17
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/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +22 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +13 -4
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
package/dist/src/acp-agent.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export declare function promptText(blocks: readonly ContentBlock[]): string;
|
|
|
18
18
|
export declare function toolKind(name: string): ToolKind;
|
|
19
19
|
/** A short, readable title for a tool call: what it reads, changes, searches for or runs. */
|
|
20
20
|
export declare function toolTitle(name: string, input: unknown, cwd: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* What "Always allow" in a session covers: the tool, except that each of pull_request's writes of public text
|
|
23
|
+
* (reply, resolve, comment) is allowed on its own, so allowing a settings change never lets the agent post on
|
|
24
|
+
* GitHub unasked.
|
|
25
|
+
*/
|
|
26
|
+
export declare function alwaysAllowKey(name: string, input: unknown): string;
|
|
21
27
|
/** A file's text for a diff: null when it does not exist, undefined when it cannot be shown whole. */
|
|
22
28
|
export type FileSnapshot = string | null | undefined;
|
|
23
29
|
/**
|
package/dist/src/acp-agent.js
CHANGED
|
@@ -288,6 +288,16 @@ export function toolTitle(name, input, cwd) {
|
|
|
288
288
|
}
|
|
289
289
|
/** Files larger than this are shown as a positioned text diff instead of whole before and after texts. */
|
|
290
290
|
const MAX_DIFF_FILE_BYTES = 1_000_000;
|
|
291
|
+
/**
|
|
292
|
+
* What "Always allow" in a session covers: the tool, except that each of pull_request's writes of public text
|
|
293
|
+
* (reply, resolve, comment) is allowed on its own, so allowing a settings change never lets the agent post on
|
|
294
|
+
* GitHub unasked.
|
|
295
|
+
*/
|
|
296
|
+
export function alwaysAllowKey(name, input) {
|
|
297
|
+
const tool = canonicalCodingToolName(name) ?? name;
|
|
298
|
+
const action = typeof input === 'object' && input !== null ? input.action : undefined;
|
|
299
|
+
return tool === 'pull_request' && (action === 'reply' || action === 'resolve' || action === 'comment') ? `pull_request ${action}` : tool;
|
|
300
|
+
}
|
|
291
301
|
/** A text as lines that keep their own line endings. */
|
|
292
302
|
function snapshotLines(text) {
|
|
293
303
|
return text === null || text === '' ? [] : text.split(/(?<=\n)/);
|
|
@@ -551,11 +561,12 @@ export async function runAcpAgent(options = {}) {
|
|
|
551
561
|
await new Promise(next => setImmediate(next));
|
|
552
562
|
const name = typeof data.name === 'string' ? data.name : 'tool';
|
|
553
563
|
const key = canonicalCodingToolName(name) ?? name;
|
|
554
|
-
|
|
564
|
+
const rawInput = toolInput(data.arguments);
|
|
565
|
+
const allowKey = alwaysAllowKey(name, rawInput);
|
|
566
|
+
if (session.alwaysAllow.has(allowKey)) {
|
|
555
567
|
await answerApproval(id, true);
|
|
556
568
|
return;
|
|
557
569
|
}
|
|
558
|
-
const rawInput = toolInput(data.arguments);
|
|
559
570
|
// The engine asks after the call has started: point the request at that call, so the client shows one item.
|
|
560
571
|
let matched;
|
|
561
572
|
for (const [toolCallId, open] of [...openTools].reverse()) {
|
|
@@ -577,7 +588,7 @@ export async function runAcpAgent(options = {}) {
|
|
|
577
588
|
toolCall: { toolCallId: matched ?? `approval-${id}`, title, kind: toolKind(name), status: 'pending', rawInput },
|
|
578
589
|
options: [
|
|
579
590
|
{ optionId: 'allow', name: 'Allow', kind: 'allow_once' },
|
|
580
|
-
{ optionId: 'allow-always', name: `Always allow ${
|
|
591
|
+
{ optionId: 'allow-always', name: `Always allow ${allowKey} in this session`, kind: 'allow_always' },
|
|
581
592
|
{ optionId: 'reject', name: 'Reject', kind: 'reject_once' },
|
|
582
593
|
],
|
|
583
594
|
});
|
|
@@ -588,7 +599,7 @@ export async function runAcpAgent(options = {}) {
|
|
|
588
599
|
}
|
|
589
600
|
catch { }
|
|
590
601
|
if (always)
|
|
591
|
-
session.alwaysAllow.add(
|
|
602
|
+
session.alwaysAllow.add(allowKey);
|
|
592
603
|
if (matched && approved)
|
|
593
604
|
update({ sessionUpdate: 'tool_call_update', toolCallId: matched, status: 'in_progress' });
|
|
594
605
|
await answerApproval(id, approved);
|
|
@@ -3,6 +3,7 @@ import { mkdir, readdir, readFile, writeFile, rename, rm, unlink } from 'node:fs
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { validateSchema } from './handoffs.js';
|
|
5
5
|
import { configDirectory } from './config.js';
|
|
6
|
+
import { findProviderById, providerModelId } from './providers.js';
|
|
6
7
|
import { acquireSaveLock, archiveUnpublishedSnapshot, SaveLockBusyError } from './save-lock.js';
|
|
7
8
|
import { GraphConflictError, validateGraph, createOrchestratorNode, nodeOutcomes } from './graphs.js';
|
|
8
9
|
const base = { filesystem: 'read-write', shell: 'allowed', git: 'write', github: 'pull-request', browser: 'playwright', deployment: 'none' };
|
|
@@ -210,20 +211,42 @@ export function parseAgentExport(input) {
|
|
|
210
211
|
return { name: agent.name.trim(), description: agent.description ?? '', node: structuredClone(agent.node) };
|
|
211
212
|
}
|
|
212
213
|
function adoptModelProfiles(node, providers, defaultProvider) {
|
|
213
|
-
|
|
214
|
-
const
|
|
214
|
+
// Ids and models are matched without regard to case and kept in this machine's spelling.
|
|
215
|
+
const known = (id) => findProviderById(providers, id) !== undefined;
|
|
216
|
+
const forget = (ref) => { if (ref.provider === undefined)
|
|
217
|
+
return; const local = findProviderById(providers, ref.provider); if (local)
|
|
218
|
+
ref.provider = local.id;
|
|
219
|
+
else {
|
|
215
220
|
delete ref.provider;
|
|
216
221
|
delete ref.model;
|
|
217
222
|
} };
|
|
218
223
|
const offers = (ref, inherited) => {
|
|
219
|
-
const profile = providers
|
|
220
|
-
if (ref.model
|
|
224
|
+
const profile = findProviderById(providers, ref.provider ?? inherited);
|
|
225
|
+
if (ref.model === undefined)
|
|
226
|
+
return;
|
|
227
|
+
const local = profile ? providerModelId({ model: profile.model ?? '', models: profile.models }, ref.model) : undefined;
|
|
228
|
+
if (local === undefined)
|
|
221
229
|
delete ref.model;
|
|
230
|
+
else
|
|
231
|
+
ref.model = local;
|
|
232
|
+
};
|
|
233
|
+
const respell = (ref, inherited) => {
|
|
234
|
+
const profile = findProviderById(providers, ref.provider ?? inherited);
|
|
235
|
+
const local = profile && ref.model !== undefined ? providerModelId({ model: profile.model ?? '', models: profile.models }, ref.model) : undefined;
|
|
236
|
+
if (local !== undefined)
|
|
237
|
+
ref.model = local;
|
|
222
238
|
};
|
|
223
239
|
forget(node);
|
|
240
|
+
respell(node, defaultProvider);
|
|
224
241
|
const retry = node.retry;
|
|
225
|
-
if (record(retry) && record(retry.fallback)
|
|
226
|
-
|
|
242
|
+
if (record(retry) && record(retry.fallback)) {
|
|
243
|
+
if (!known(retry.fallback.provider))
|
|
244
|
+
delete retry.fallback;
|
|
245
|
+
else {
|
|
246
|
+
forget(retry.fallback);
|
|
247
|
+
respell(retry.fallback, undefined);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
227
250
|
const inherited = node.provider ?? defaultProvider;
|
|
228
251
|
const subagents = node.subagents;
|
|
229
252
|
if (!record(subagents))
|
|
@@ -27,7 +27,7 @@ import { bindUserWaits, createRuntimeBudget } from './deadline.js';
|
|
|
27
27
|
import { createAgentEngine } from './hardened-runtime.js';
|
|
28
28
|
import { completionTool } from './completion.js';
|
|
29
29
|
import { applyToolProfile } from './tool-profile.js';
|
|
30
|
-
import { DELIVERED_OUTCOME, GRAPH_MANAGER_GRAPH_ID, capabilitySubset, delegatesWriting, effectiveCapabilities, intakeCapabilities, isTestingNode, isWritingRole, laterAgentNodes, permitsBuiltInTool, testerOnEveryRoute } from './graphs.js';
|
|
30
|
+
import { DELIVERED_OUTCOME, GRAPH_MANAGER_GRAPH_ID, REVIEWER_GRAPH_ID, capabilitySubset, isolatedGraph, reviewerOutputProblem, delegatesWriting, effectiveCapabilities, intakeCapabilities, isTestingNode, isWritingRole, laterAgentNodes, permitsBuiltInTool, testerOnEveryRoute } from './graphs.js';
|
|
31
31
|
import { DELEGATION_DIFF_LIMIT, LandingRestoreError, addChangeWorktree, assertDelegationGit, applyLanding, collectChange, prepareLanding, removeChangeWorktree, repositoryRoot, snapshotWorkspace } from './delegation-changes.js';
|
|
32
32
|
import { stopQaProcessesUnder } from './qa/runtime/ProcessManager.js';
|
|
33
33
|
import { qaGuidance } from './qa/guidance.js';
|
|
@@ -147,6 +147,8 @@ export async function executeAgentNode(node, options) {
|
|
|
147
147
|
options = { ...options, runId: randomUUID() };
|
|
148
148
|
const store = options.artifactStore ?? new ArtifactStore(options.runId ?? randomUUID());
|
|
149
149
|
const orchestrator = node.agentRole === 'orchestrator';
|
|
150
|
+
// An isolated graph's agent (the review loop's reviewer) gets its configured tools and the completion tools, nothing more.
|
|
151
|
+
const isolated = isolatedGraph(options.graph?.id);
|
|
150
152
|
// With declared outcomes the Orchestrator picks its route itself; with a single outcome, delegation needs a routed delivered port.
|
|
151
153
|
const routedDelegation = orchestrator && delegatesWriting(node) && node.completion?.mode === 'outcomes';
|
|
152
154
|
const delegationActive = routedDelegation || (orchestrator && delegatesWriting(node) && !!options.graph?.edges.some(edge => edge.source === node.id && edge.outcome === DELIVERED_OUTCOME));
|
|
@@ -368,7 +370,9 @@ export async function executeAgentNode(node, options) {
|
|
|
368
370
|
let provider = configuredProvider, resolved = await resolve(provider, configuredModel);
|
|
369
371
|
if (!resolved)
|
|
370
372
|
throw new Error(`Unknown provider ${provider}. Run andorra and open /providers first.`);
|
|
371
|
-
|
|
373
|
+
// The resolved model is the provider's own spelling of the configured one when they differ only in case.
|
|
374
|
+
const spelled = (wanted, got) => wanted !== undefined && wanted.toLowerCase() === got.toLowerCase() ? got : wanted ?? got;
|
|
375
|
+
let model = spelled(configured.model, resolved.model);
|
|
372
376
|
let fallbackAttempt = parentFallback;
|
|
373
377
|
const orchestratorCompletionGuard = () => {
|
|
374
378
|
if (!clarified)
|
|
@@ -379,7 +383,7 @@ export async function executeAgentNode(node, options) {
|
|
|
379
383
|
return 'Inspect relevant repository files, search or list the workspace (or obtain a successful research child result) before completing.';
|
|
380
384
|
};
|
|
381
385
|
let observedResearch = false;
|
|
382
|
-
const codeManager = options.codeIntel;
|
|
386
|
+
const codeManager = isolated ? undefined : options.codeIntel;
|
|
383
387
|
const codeLedger = codeManager?.createLedger();
|
|
384
388
|
const codeIntel = codeManager?.active && permitsBuiltInTool(configured, 'repo_explore') ? codeManager : undefined;
|
|
385
389
|
const researchTool = (name) => ['Read', 'Glob', 'Grep', 'git_read', 'repo_explore'].includes(canonicalToolName(name));
|
|
@@ -456,7 +460,7 @@ export async function executeAgentNode(node, options) {
|
|
|
456
460
|
} });
|
|
457
461
|
if (orchestrator && depth === 0 && effectiveCapabilities(configured).filesystem !== 'none')
|
|
458
462
|
tools.push(removeUntrackedFileTool());
|
|
459
|
-
if (!orchestrator && depth === 0 && options.context.approvalMode !== 'headless' && options.context.askUser)
|
|
463
|
+
if (!orchestrator && !isolated && depth === 0 && options.context.approvalMode !== 'headless' && options.context.askUser)
|
|
460
464
|
tools.push({ name: 'ask_user', executionMode: 'sequential', description: 'Ask the user a question only they can answer and wait for the answer. Use it whenever a choice is theirs to make: a skill or instruction that says to ask, a preference, a missing requirement. A question written in your reply does not pause the run and may go unseen, so never ask that way. Ask one short question per call in plain language; when the options are known give 2-4 short choices, the recommended one first and labelled (Recommended). Do not ask what your tools can find out or what you can reasonably decide yourself. Before asking where something is or what a name refers to, finish a search for it by file name and by content; a search that was cut short or timed out does not count.',
|
|
461
465
|
parameters: { type: 'object', properties: { question: { type: 'string', minLength: 1, maxLength: 500, description: 'One plain-language question.' }, choices: { type: 'array', items: { type: 'string', minLength: 1, maxLength: 200 }, minItems: 2, maxItems: 8, description: 'Short answers the user can pick from; they can always type their own.' } }, required: ['question'], additionalProperties: false },
|
|
462
466
|
execute: async (args, ctx) => {
|
|
@@ -482,7 +486,7 @@ export async function executeAgentNode(node, options) {
|
|
|
482
486
|
throw new Error('The answer exceeds 16000 characters; ask for a shorter decision.');
|
|
483
487
|
return JSON.stringify({ answered: true, answer });
|
|
484
488
|
} });
|
|
485
|
-
if (depth === 0)
|
|
489
|
+
if (depth === 0 && !isolated)
|
|
486
490
|
tools.push({ name: 'present_plan', executionMode: 'sequential', description: 'Present the implementation plan for the user to approve, reject, or send feedback on. Only meaningful while the run is in plan mode: file mutations and escalations stay refused until a plan is approved. Present one complete plan in markdown after researching; a later call may present a revised plan after feedback.',
|
|
487
491
|
parameters: { type: 'object', properties: { plan: { type: 'string', minLength: 1, maxLength: 16000, description: 'The implementation plan in markdown: what will change, the files or areas touched, the approach, and how it will be verified.' } }, required: ['plan'], additionalProperties: false },
|
|
488
492
|
execute: async (args, ctx) => {
|
|
@@ -948,7 +952,7 @@ export async function executeAgentNode(node, options) {
|
|
|
948
952
|
|| options.efficiency?.projectSkillDiscovery === true
|
|
949
953
|
|| (options.efficiency?.projectSkillDiscovery !== false && options.decisionManager?.skillRoutingEnabled === true));
|
|
950
954
|
const resourceReader = tools.find(tool => tool.name === 'read_skill_resource');
|
|
951
|
-
const skills = discoverProjectSkills || requestedInheritedSkills.length > 0 || promptSkillNames.length > 0 || resourceReader || tools.some(tool => tool.name === 'qa.browser_session')
|
|
955
|
+
const skills = !isolated && (discoverProjectSkills || requestedInheritedSkills.length > 0 || promptSkillNames.length > 0 || resourceReader || tools.some(tool => tool.name === 'qa.browser_session'))
|
|
952
956
|
? await discoverRuntimeSkills(context.workspace, context.signal, tools.map(tool => tool.name), discoverProjectSkills) : [];
|
|
953
957
|
// A skill inherited from earlier nodes that this node cannot load (broken locally, or no skill
|
|
954
958
|
// reader among its tools) is left out for this node only; the run continues without it.
|
|
@@ -1475,7 +1479,7 @@ export async function executeAgentNode(node, options) {
|
|
|
1475
1479
|
return [...replay, ...fresh];
|
|
1476
1480
|
};
|
|
1477
1481
|
result = await createAgentEngine().execute({ ...options, instructions: nodeInstructions || undefined, todoStore, context, provider, model,
|
|
1478
|
-
todoList: options.todoList !== false && options.graph?.id !== GRAPH_MANAGER_GRAPH_ID,
|
|
1482
|
+
todoList: options.todoList !== false && options.graph?.id !== GRAPH_MANAGER_GRAPH_ID && !isolated,
|
|
1479
1483
|
efficiency: configured.tools && options.efficiency?.toolMenuRouting
|
|
1480
1484
|
? { ...options.efficiency, toolMenuRouting: { ...options.efficiency.toolMenuRouting, pinnedTools: [...new Set([...(options.efficiency.toolMenuRouting.pinnedTools ?? []), ...configured.tools.map(canonicalToolName)])] } }
|
|
1481
1485
|
: options.efficiency,
|
|
@@ -1521,8 +1525,9 @@ export async function executeAgentNode(node, options) {
|
|
|
1521
1525
|
if (!routedDelegation && !records.some(change => change.state === 'landed'))
|
|
1522
1526
|
return 'Land at least one accepted change before completing as delivered.';
|
|
1523
1527
|
}
|
|
1524
|
-
} : depth === 0 &&
|
|
1525
|
-
: inheritedSkills.length || promptSkills.length ?
|
|
1528
|
+
} : isolated && depth === 0 && options.graph?.id === REVIEWER_GRAPH_ID ? completion => reviewerOutputProblem(completion.output)
|
|
1529
|
+
: depth === 0 && policy.enabled ? () => backgroundGuard() ?? (inheritedSkills.length || promptSkills.length ? missingSkillError() : undefined)
|
|
1530
|
+
: inheritedSkills.length || promptSkills.length ? () => missingSkillError() : undefined, completionPolicy, outputSchema: configured.outputSchema,
|
|
1526
1531
|
history: configured.contextPolicy?.history ? options.history : [],
|
|
1527
1532
|
task: attemptRepoBlock ? `${taskBase}\n\n${attemptRepoBlock}` : taskBase,
|
|
1528
1533
|
onUsage: (usage, origin) => {
|
|
@@ -1555,7 +1560,7 @@ export async function executeAgentNode(node, options) {
|
|
|
1555
1560
|
resolved = await resolve(provider, configured.retry.fallback.model);
|
|
1556
1561
|
if (!resolved)
|
|
1557
1562
|
throw new Error(`Unknown fallback provider: ${provider}`);
|
|
1558
|
-
model = configured.retry.fallback.model
|
|
1563
|
+
model = spelled(configured.retry.fallback.model, resolved.model);
|
|
1559
1564
|
}
|
|
1560
1565
|
}
|
|
1561
1566
|
researchResults.set(result, observedResearch);
|
|
@@ -18,6 +18,7 @@ export const AGENT_MCP_CATALOG = [
|
|
|
18
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
19
|
{ name: 'andorra_graph_edge_remove', description: 'Remove an edge by ID from a draft.', inputSchema: obj({ ...graphDraftSchema, edgeId: str }, ['draftId', 'edgeId']) },
|
|
20
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_show', description: 'Show a graph to the user in the chat. The Andorra desktop app draws it the way the Graph Editor does (steps, models, outcome routes, the entry); other hosts get the reply\'s plain-text sketch. Pass draftId for a draft, or id (and optionally revision) for a published graph. Use it whenever you present, sketch or review a graph, instead of drawing a diagram.', inputSchema: obj({ draftId: str, id: str, revision: { type: 'integer', minimum: 1 } }) },
|
|
21
22
|
{ name: 'andorra_graph_validate', description: 'Validate a draft; report all missing provider and outcome paths, plus graph topology issues.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
22
23
|
{ name: 'andorra_graph_publish', description: 'Validate and atomically publish the next immutable graph revision; optimistic concurrency guards other editors.', inputSchema: obj(graphDraftSchema, ['draftId']) },
|
|
23
24
|
{ 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']) },
|
package/dist/src/agent-mcp.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadConfig } from './config.js';
|
|
2
2
|
import { GraphSync } from './graph-sync.js';
|
|
3
3
|
import { getAuthStatus } from './auth/index.js';
|
|
4
|
-
import { getMembership } from './membership.js';
|
|
4
|
+
import { type getMembership } from './membership.js';
|
|
5
5
|
import { type GraphNode } from './graphs.js';
|
|
6
6
|
import { SessionStore } from './sessions.js';
|
|
7
7
|
import { type SubagentProviderListing } from './subagent-run.js';
|
|
@@ -40,6 +40,8 @@ export interface AgentMcpBackendOptions {
|
|
|
40
40
|
subagentWorkspace?: string;
|
|
41
41
|
subagentAdapterFactory?: (provider: import('./providers.js').ProviderConfig) => ModelAdapter;
|
|
42
42
|
recoverRuns?: boolean;
|
|
43
|
+
/** Whether a desktop app draws andorra_graph_show replies; defaults to running under one (ANDORRA_DESKTOP_HOST_PID). */
|
|
44
|
+
desktopHost?: boolean;
|
|
43
45
|
}
|
|
44
46
|
export declare const GRAPH_AGENT_GUIDE: string;
|
|
45
47
|
export declare class AgentMcpError extends Error {
|
|
@@ -81,6 +83,7 @@ export declare class AgentMcpBackend {
|
|
|
81
83
|
private assertGraphIdentity;
|
|
82
84
|
private obtainDraft;
|
|
83
85
|
private providers;
|
|
86
|
+
private showGraph;
|
|
84
87
|
private setDeleted;
|
|
85
88
|
private readGraph;
|
|
86
89
|
private upsertNode;
|
package/dist/src/agent-mcp.js
CHANGED
|
@@ -10,14 +10,17 @@ import { graphStorageDirectory } from './graph-account.js';
|
|
|
10
10
|
import { GraphSync } from './graph-sync.js';
|
|
11
11
|
import { stampGraphProviderProfiles } from './graph-provider-portability.js';
|
|
12
12
|
import { getAuthStatus } from './auth/index.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { GraphConflictError, isDeletedGraph, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, optionalOutcomes,
|
|
13
|
+
import { getGraphMembership, PaidMembershipRequiredError } from './membership.js';
|
|
14
|
+
import { FREE_GRAPH_LIMIT_MESSAGE, FREE_LOCKED_GRAPH_MESSAGE, FreeTierLimitError, notePremiumGraphAccount, readGraphQuota, saveFreeTierGraph, savePremiumGraph } from './graph-quota.js';
|
|
15
|
+
import { GraphConflictError, isDeletedGraph, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, optionalOutcomes, validateGraph, withoutDeletedGraphs } from './graphs.js';
|
|
16
16
|
import { getAgentSession, listAgentProjects, queryAgentSessions, scanAgentSessions, SessionQueryError } from './session-monitor.js';
|
|
17
17
|
import { AutomationStore } from './automations.js';
|
|
18
18
|
import { canonicalWorkspace, MAX_SUBAGENT_TASK_CHARS, SubagentInvalidArgumentError, SubagentProviderNotSetError, SubagentRunInProgressError, SubagentRunner, SubagentSelectionError } from './subagent-run.js';
|
|
19
19
|
import { reconcileInterruptedRuns } from './run-records.js';
|
|
20
20
|
import { AGENT_MCP_CATALOG, AGENT_MCP_TOOL_NAMES } from './agent-mcp-catalog.js';
|
|
21
|
+
import { graphPreview, graphSketch } from './graph-preview.js';
|
|
22
|
+
/** The longest andorra_graph_show reply that still carries its sketch, inside the 24,000-character tool event. */
|
|
23
|
+
const SHOW_REPLY_BUDGET = 20_000;
|
|
21
24
|
export const GRAPH_AGENT_GUIDE = [
|
|
22
25
|
'# Andorra Code Graph Agent Architecture (MCP)',
|
|
23
26
|
'',
|
|
@@ -32,6 +35,7 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
32
35
|
'4. andorra_graph_edge_upsert links the exact source outcome to a target node.',
|
|
33
36
|
'5. andorra_graph_patch sets entry, name, limits, widgets and schemas.',
|
|
34
37
|
'6. andorra_graph_validate returns all missing-provider and missing-path issues plus the structural validator error.',
|
|
38
|
+
' andorra_graph_show draws a draft (draftId) or a published graph (id) for the user in the chat; use it instead of a diagram.',
|
|
35
39
|
'7. andorra_graph_publish validates and saves an optimistic, immutable revision. Fix issues; do not suppress them.',
|
|
36
40
|
'8. andorra_graph_discard abandons a draft. Drafts are process-local, expire after an hour and are not published until saved.',
|
|
37
41
|
'',
|
|
@@ -52,6 +56,10 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
52
56
|
' A cycle still needs a ceiling: graph.limits.maxNodeVisits or graph.limits.wallTimeMs, one of the two.',
|
|
53
57
|
' A finite graph.limits.maxNodeVisits must be large enough for loop maxIterations plus reentry.',
|
|
54
58
|
'approval: ports approved and rejected. The live runtime asks the person before advancing.',
|
|
59
|
+
'review: Andorra review of the task\'s pull request; requires review {rounds 1-10, when "ready"|"always", instruction <= 2 KiB, provider and model together or neither}.',
|
|
60
|
+
' Ports findings, clean and stopped. Each visit posts one review as andorra-code[bot]; route findings back to the Agent that fixes them',
|
|
61
|
+
' with inputMapping {taskInstruction: "$source.output.prompt"}, and clean and stopped onward. On a cycle, a finite graph.limits.maxNodeVisits must be at least rounds.',
|
|
62
|
+
' Output: round, rounds, loop, head, reviewUrl, findings [{priority, where, threadId, url, path, line, title}], nits, reason, prompt.',
|
|
55
63
|
'join: join {mode:"all"|"any"}. Join all must not wait on mutually exclusive outcome branches.',
|
|
56
64
|
'parallel: fan-out; connect its completed port to downstream work.',
|
|
57
65
|
'action: action {kind:"command"|"tests"|"git",command:"..."}; graph capability constraints still apply.',
|
|
@@ -67,7 +75,7 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
67
75
|
'Ask the user in chat first; confirm must repeat the id. Every revision stays stored; the graph leaves listings and new runs refuse it.',
|
|
68
76
|
'Sessions that already ran it keep resuming. andorra_graphs_list {includeDeleted:true} lists deleted graphs with deleted=true.',
|
|
69
77
|
'andorra_graph_restore {id, expectedRevision} publishes the next revision without the marker.',
|
|
70
|
-
'A
|
|
78
|
+
'A free account\'s own graph still counts as its one custom graph while deleted, so a free account restores it rather than replacing it. The other graphs a free account holds are view only: they can be read, but not edited, deleted or restored.',
|
|
71
79
|
'DEFAULT_GRAPH: the bundled Default graph cannot be deleted.',
|
|
72
80
|
'',
|
|
73
81
|
'## Project visibility',
|
|
@@ -149,7 +157,7 @@ function draftId(args) {
|
|
|
149
157
|
throw new AgentMcpError('INVALID_DRAFT', 'draftId must be the UUID returned by andorra_graph_begin.');
|
|
150
158
|
return value;
|
|
151
159
|
}
|
|
152
|
-
const knownTypes = ['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval'];
|
|
160
|
+
const knownTypes = ['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval', 'review'];
|
|
153
161
|
const CARD_WIDTH = 210, CARD_HEIGHT = 94, PORT_HEIGHT = 25;
|
|
154
162
|
const UNPLACED_SPACING = 290;
|
|
155
163
|
const COORDINATE_LIMIT = 100_000;
|
|
@@ -336,7 +344,7 @@ export class AgentMcpBackend {
|
|
|
336
344
|
throw new AgentMcpError('AUTH_REQUIRED', 'Sign in to your Andorra Code account to edit graphs.');
|
|
337
345
|
if (!/^[A-Za-z0-9-]{1,128}$/.test(before.subject))
|
|
338
346
|
throw new AgentMcpError('AUTH_REQUIRED', 'The signed-in account has an invalid graph storage identity. Sign in again.');
|
|
339
|
-
const membership = await (this.options.membershipStatus ??
|
|
347
|
+
const membership = await (this.options.membershipStatus ?? getGraphMembership)();
|
|
340
348
|
if (!membership.paid && !membership.subject)
|
|
341
349
|
throw PaidMembershipRequiredError.for(membership);
|
|
342
350
|
if (!membership.subject || membership.subject !== before.subject)
|
|
@@ -348,6 +356,8 @@ export class AgentMcpBackend {
|
|
|
348
356
|
const confirmed = await authStatus();
|
|
349
357
|
if (!confirmed.signedIn || confirmed.subject !== membership.subject)
|
|
350
358
|
throw new AgentMcpError('AUTH_CHANGED', 'Account changed while opening graph storage. Retry graph access with the current account.');
|
|
359
|
+
if (membership.paid)
|
|
360
|
+
await notePremiumGraphAccount(directory);
|
|
351
361
|
access = { directory, subject: membership.subject, free: !membership.paid };
|
|
352
362
|
}
|
|
353
363
|
const key = access.directory + '\0' + (access.subject ?? '');
|
|
@@ -421,6 +431,28 @@ export class AgentMcpBackend {
|
|
|
421
431
|
// not only its default; without it validation rejects a graph the app itself runs.
|
|
422
432
|
return { providers: config.providers.map(({ id, model, type, models }) => ({ id, model, type, ...(models?.length ? { models: [...models] } : {}) })), active: config.provider };
|
|
423
433
|
}
|
|
434
|
+
async showGraph(args, access) {
|
|
435
|
+
const byDraft = args.draftId !== undefined, byId = args.id !== undefined;
|
|
436
|
+
if (byDraft === byId)
|
|
437
|
+
throw new AgentMcpError('INVALID_ARGUMENTS', 'Pass draftId to show a draft, or id (and optionally revision) to show a published graph, not both.');
|
|
438
|
+
const revision = args.revision;
|
|
439
|
+
if (revision !== undefined && (byDraft || typeof revision !== 'number' || !Number.isSafeInteger(revision) || revision < 1))
|
|
440
|
+
throw new AgentMcpError('INVALID_ARGUMENTS', 'revision must be a positive safe integer, and only with id.');
|
|
441
|
+
const graph = byDraft ? this.obtainDraft(draftId(args), access).graph : await this.readGraph(field(args, 'id'), access.directory, revision);
|
|
442
|
+
await this.assertGraphIdentity(access);
|
|
443
|
+
const { providers, active } = await this.providers();
|
|
444
|
+
const deleted = !byDraft && isDeletedGraph(graph);
|
|
445
|
+
const preview = { ...graphPreview(graph, byDraft ? 'draft' : graph.revision, provider => providers.find(item => item.id === (provider ?? active))?.model),
|
|
446
|
+
...(deleted ? { deleted: true } : {}) };
|
|
447
|
+
const drawn = this.options.desktopHost ?? Boolean(process.env.ANDORRA_DESKTOP_HOST_PID);
|
|
448
|
+
// The chat reads the reply from an event cut at 24,000 characters; the sketch goes only while the whole reply stays well inside it.
|
|
449
|
+
const sketch = graphSketch(preview);
|
|
450
|
+
const fits = JSON.stringify({ preview, sketch }).length <= SHOW_REPLY_BUDGET;
|
|
451
|
+
const note = drawn
|
|
452
|
+
? 'The Andorra desktop app draws this graph in the chat; do not draw it again or retype it as arrows.'
|
|
453
|
+
: fits ? 'Nothing in this host draws the graph: put the sketch in your reply.' : 'Nothing in this host draws the graph, and it is too large for a sketch: describe its steps and routes in words.';
|
|
454
|
+
return { preview, ...(fits ? { sketch } : {}), ...(deleted ? { deletedAt: graph.metadata.deletedAt } : {}), note };
|
|
455
|
+
}
|
|
424
456
|
async setDeleted(deleting, args, access, beforeSave) {
|
|
425
457
|
const tool = deleting ? 'andorra_graph_delete' : 'andorra_graph_restore';
|
|
426
458
|
const id = field(args, 'id');
|
|
@@ -462,7 +494,7 @@ export class AgentMcpBackend {
|
|
|
462
494
|
const next = { ...latest, metadata };
|
|
463
495
|
beforeSave?.();
|
|
464
496
|
const saved = freshAccess.free ? await saveFreeTierGraph(next, latest.revision, access.directory)
|
|
465
|
-
: await
|
|
497
|
+
: await savePremiumGraph(next, latest.revision, access.directory);
|
|
466
498
|
if (deleting)
|
|
467
499
|
for (const [key, draft] of this.drafts)
|
|
468
500
|
if (draft.graph.id === id && draft.directory === access.directory)
|
|
@@ -470,7 +502,7 @@ export class AgentMcpBackend {
|
|
|
470
502
|
void this.sync?.sync();
|
|
471
503
|
const note = 'Revision saved locally. Cloud synchronization may still be pending.';
|
|
472
504
|
return deleting
|
|
473
|
-
? { id, revision: saved.revision, deletedAt, note: freshAccess.free ? note + '
|
|
505
|
+
? { id, revision: saved.revision, deletedAt, note: freshAccess.free ? note + ' This graph still counts as this free account\'s one custom graph while deleted; restore it to use it again.' : note }
|
|
474
506
|
: { id, revision: saved.revision, note };
|
|
475
507
|
}
|
|
476
508
|
async readGraph(id, directory, revision) {
|
|
@@ -777,6 +809,8 @@ export class AgentMcpBackend {
|
|
|
777
809
|
const latest = await this.readGraph(id, access.directory);
|
|
778
810
|
if (isDeletedGraph(latest))
|
|
779
811
|
throw new AgentMcpError('GRAPH_DELETED', 'Graph ' + id + ' is deleted. Restore it with andorra_graph_restore before editing it.');
|
|
812
|
+
if (access.free && (await readGraphQuota(access.directory, undefined, { adopt: true })).freeGraphId !== id)
|
|
813
|
+
throw new FreeTierLimitError(FREE_LOCKED_GRAPH_MESSAGE);
|
|
780
814
|
graph = migrateGraphForEditor(latest, { addOrchestrator: !access.free });
|
|
781
815
|
expectedRevision = graph.revision;
|
|
782
816
|
}
|
|
@@ -792,7 +826,7 @@ export class AgentMcpBackend {
|
|
|
792
826
|
if (error.code !== 'ENOENT')
|
|
793
827
|
throw error;
|
|
794
828
|
}
|
|
795
|
-
if (access.free && (await readGraphQuota(access.directory)).
|
|
829
|
+
if (access.free && (await readGraphQuota(access.directory, undefined, { adopt: true })).freeGraphId !== undefined)
|
|
796
830
|
throw new FreeTierLimitError(FREE_GRAPH_LIMIT_MESSAGE);
|
|
797
831
|
graph = { schemaVersion: 3, id, name: nameValue, revision: 0, entry: '', nodes: {}, edges: [] };
|
|
798
832
|
expectedRevision = null;
|
|
@@ -810,6 +844,8 @@ export class AgentMcpBackend {
|
|
|
810
844
|
publishing: false, touched: Date.now(), authoredAgents: new Set() });
|
|
811
845
|
return { draftId: key, graph, expectedRevision, note: 'This draft is local to this MCP process until published.' };
|
|
812
846
|
}
|
|
847
|
+
if (name === 'andorra_graph_show')
|
|
848
|
+
return this.showGraph(args, access);
|
|
813
849
|
if (name === 'andorra_graph_discard') {
|
|
814
850
|
const key = draftId(args);
|
|
815
851
|
this.obtainDraft(key, access);
|
|
@@ -906,7 +942,7 @@ export class AgentMcpBackend {
|
|
|
906
942
|
throw new AgentMcpError('VALIDATION_FAILED', 'Graph exceeds 512 KiB after portable provider identities are recorded.');
|
|
907
943
|
beforeSave?.();
|
|
908
944
|
const saved = finalAccess.free ? await saveFreeTierGraph(stamped, draft.expectedRevision, access.directory)
|
|
909
|
-
: await
|
|
945
|
+
: await savePremiumGraph(stamped, draft.expectedRevision, access.directory);
|
|
910
946
|
await this.sync?.reviveGraph(saved.id);
|
|
911
947
|
draft.graph = saved;
|
|
912
948
|
draft.expectedRevision = saved.revision;
|
|
@@ -17,5 +17,15 @@ export declare function applyAndorraEntry(config: Config, answer: HostedAnswer,
|
|
|
17
17
|
* Andorra is offered and not saved yet. It exists in memory only; nothing validates, saves or sends requests with it.
|
|
18
18
|
*/
|
|
19
19
|
export declare function virtualAndorraEntry(config: Pick<Config, 'providers'>, answer: HostedAnswer): ProviderConfig | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The move an Andorra entry made when the model it was on left the offer: the display names of the model before
|
|
22
|
+
* and after (the id where the router gave no other name). Undefined when the entry is new, gone, on the same
|
|
23
|
+
* model, or changed model while the old one is still served (the user's own pick).
|
|
24
|
+
*/
|
|
25
|
+
export declare function andorraModelSwitch(before: Pick<Config, 'providers'>, after: Pick<Config, 'providers'>): {
|
|
26
|
+
id: string;
|
|
27
|
+
from: string;
|
|
28
|
+
to: string;
|
|
29
|
+
} | undefined;
|
|
20
30
|
/** The provider to select when the active one goes away: never Andorra by position. */
|
|
21
31
|
export declare function fallbackProviderId(providers: readonly Pick<ProviderConfig, 'id' | 'type'>[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reconcileSubagentPair } from '../config.js';
|
|
2
|
-
import { applyModelContextWindow, MAX_MODEL_DISPLAY_NAME_LENGTH } from '../providers.js';
|
|
2
|
+
import { applyModelContextWindow, MAX_MODEL_DISPLAY_NAME_LENGTH, modelDisplayName } from '../providers.js';
|
|
3
3
|
import { ANDORRA_PROVIDER_BASE_URL } from './endpoint.js';
|
|
4
4
|
const ANDORRA_ID = 'andorra';
|
|
5
5
|
const ANDORRA_NAME = 'Andorra';
|
|
@@ -77,8 +77,10 @@ export function applyAndorraEntry(config, answer, mode) {
|
|
|
77
77
|
const modelNames = hostedNames(answer);
|
|
78
78
|
const modelParameters = hostedParameters(answer);
|
|
79
79
|
const freeModels = answer.models.filter(model => model.free === true).map(model => model.id);
|
|
80
|
+
const textOnlyModels = answer.models.filter(model => model.imageInput === false).map(model => model.id);
|
|
80
81
|
const named = { ...(Object.keys(modelNames).length ? { modelNames } : {}),
|
|
81
|
-
...(Object.keys(modelParameters).length ? { modelParameters } : {}), ...(freeModels.length ? { freeModels } : {})
|
|
82
|
+
...(Object.keys(modelParameters).length ? { modelParameters } : {}), ...(freeModels.length ? { freeModels } : {}),
|
|
83
|
+
...(textOnlyModels.length ? { textOnlyModels } : {}) };
|
|
82
84
|
const index = config.providers.findIndex(provider => provider.type === 'andorra');
|
|
83
85
|
if (index < 0) {
|
|
84
86
|
if (mode !== 'create')
|
|
@@ -91,9 +93,9 @@ export function applyAndorraEntry(config, answer, mode) {
|
|
|
91
93
|
const model = models.includes(existing.model) ? existing.model : models[0];
|
|
92
94
|
if (model === existing.model && sameList(existing.models, models) && sameWindows(existing.modelContextWindows, modelContextWindows)
|
|
93
95
|
&& sameNames(existing.modelNames, modelNames) && sameNumbers(existing.modelParameters, modelParameters)
|
|
94
|
-
&& sameList(existing.freeModels ?? [], freeModels))
|
|
96
|
+
&& sameList(existing.freeModels ?? [], freeModels) && sameList(existing.textOnlyModels ?? [], textOnlyModels))
|
|
95
97
|
return undefined;
|
|
96
|
-
const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, ...rest } = existing;
|
|
98
|
+
const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, textOnlyModels: _textOnly, ...rest } = existing;
|
|
97
99
|
const refreshed = { ...rest, model, models, modelContextWindows, ...named };
|
|
98
100
|
if (refreshed.contextWindow !== undefined)
|
|
99
101
|
applyModelContextWindow(refreshed, model);
|
|
@@ -112,6 +114,18 @@ export function virtualAndorraEntry(config, answer) {
|
|
|
112
114
|
return undefined;
|
|
113
115
|
return applyAndorraEntry({ version: 1, provider: '', providers: [...config.providers] }, answer, 'create')?.providers[0];
|
|
114
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The move an Andorra entry made when the model it was on left the offer: the display names of the model before
|
|
119
|
+
* and after (the id where the router gave no other name). Undefined when the entry is new, gone, on the same
|
|
120
|
+
* model, or changed model while the old one is still served (the user's own pick).
|
|
121
|
+
*/
|
|
122
|
+
export function andorraModelSwitch(before, after) {
|
|
123
|
+
const next = after.providers.find(provider => provider.type === 'andorra');
|
|
124
|
+
const previous = next && before.providers.find(provider => provider.type === 'andorra' && provider.id === next.id);
|
|
125
|
+
if (!next || !previous || previous.model === next.model || !next.models || next.models.includes(previous.model))
|
|
126
|
+
return undefined;
|
|
127
|
+
return { id: next.id, from: modelDisplayName(previous, previous.model), to: modelDisplayName(next, next.model) };
|
|
128
|
+
}
|
|
115
129
|
/** The provider to select when the active one goes away: never Andorra by position. */
|
|
116
130
|
export function fallbackProviderId(providers) {
|
|
117
131
|
return providers.find(provider => provider.type !== 'andorra')?.id ?? providers[0]?.id ?? '';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/** `parametersBillions`: the model's size, where the router states one. `free`: served past the weekly allowance. */
|
|
1
|
+
/** `parametersBillions`: the model's size, where the router states one. `free`: served past the weekly allowance. `imageInput: false`: text-only, never sent images. */
|
|
2
2
|
export interface HostedModel {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
contextWindow: number;
|
|
6
6
|
parametersBillions?: number;
|
|
7
7
|
free?: boolean;
|
|
8
|
+
imageInput?: false;
|
|
8
9
|
}
|
|
9
10
|
/** How much of the account's weekly allowance is used (0-100) and when it renews (ISO timestamp). */
|
|
10
11
|
export interface HostedAllowance {
|
|
@@ -24,7 +24,8 @@ export function parseHostedAnswer(value) {
|
|
|
24
24
|
// Both are optional and descriptive: a malformed one is dropped on its own and never fails the answer.
|
|
25
25
|
models.push({ id: item.id, name, contextWindow: item.contextWindow,
|
|
26
26
|
...(isModelParameters(item.parametersBillions) ? { parametersBillions: item.parametersBillions } : {}),
|
|
27
|
-
...(item.free === true ? { free: true } : {})
|
|
27
|
+
...(item.free === true ? { free: true } : {}),
|
|
28
|
+
...(item.imageInput === false ? { imageInput: false } : {}) });
|
|
28
29
|
}
|
|
29
30
|
const answer = { enabled: true, promotionId: body.promotionId, models };
|
|
30
31
|
const allowance = parseAllowance(body.allowance);
|
|
@@ -9,6 +9,11 @@ export declare function andorraAnnouncement(random?: () => number): string;
|
|
|
9
9
|
export declare const ANDORRA_ADD_HINT = "Choose Andorra in /model to use it.";
|
|
10
10
|
/** Said when the model the user picked is not served by the entry that was just saved (the offer changed meanwhile). */
|
|
11
11
|
export declare const ANDORRA_MODEL_GONE = "That model is no longer available.";
|
|
12
|
+
/**
|
|
13
|
+
* Said when the Andorra model the user was on left the offer and they were moved to another one. `from` and `to`
|
|
14
|
+
* are display names; without a name for the one that went, the sentence does not guess at one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function andorraModelSwitched(from: string | undefined, to: string): string;
|
|
12
17
|
/** The last line of the bubble, in two parts so the terminal can draw the tail as part of the box. */
|
|
13
18
|
export declare const ANDORRA_BUBBLE_TAIL = " \u2570 ";
|
|
14
19
|
export declare const ANDORRA_BUBBLE_SPEAKER = "Andorra";
|
|
@@ -23,6 +23,13 @@ export function andorraAnnouncement(random = Math.random) {
|
|
|
23
23
|
export const ANDORRA_ADD_HINT = 'Choose Andorra in /model to use it.';
|
|
24
24
|
/** Said when the model the user picked is not served by the entry that was just saved (the offer changed meanwhile). */
|
|
25
25
|
export const ANDORRA_MODEL_GONE = 'That model is no longer available.';
|
|
26
|
+
/**
|
|
27
|
+
* Said when the Andorra model the user was on left the offer and they were moved to another one. `from` and `to`
|
|
28
|
+
* are display names; without a name for the one that went, the sentence does not guess at one.
|
|
29
|
+
*/
|
|
30
|
+
export function andorraModelSwitched(from, to) {
|
|
31
|
+
return `${from ?? 'Your Andorra model'} is not available at the moment. Switched to ${to}.`;
|
|
32
|
+
}
|
|
26
33
|
/** The last line of the bubble, in two parts so the terminal can draw the tail as part of the box. */
|
|
27
34
|
export const ANDORRA_BUBBLE_TAIL = ' ╰ ';
|
|
28
35
|
export const ANDORRA_BUBBLE_SPEAKER = 'Andorra';
|
|
@@ -69,8 +69,9 @@ export declare function removingAndorraEntry<T>(home: string, save: () => Promis
|
|
|
69
69
|
export declare function recordAndorraRemoved(home?: string): Promise<boolean>;
|
|
70
70
|
/**
|
|
71
71
|
* What one client surface should say about a new answer, and what it has now seen. `entry` is the user's decision:
|
|
72
|
-
* a removed provider is silent, and the turned-off notice is only for someone who added the provider.
|
|
73
|
-
* is
|
|
72
|
+
* a removed provider is silent, and the turned-off notice is only for someone who added the provider. A model
|
|
73
|
+
* leaving an offer that stays on is not said here: the client that was on it is moved and told which one it is on
|
|
74
|
+
* now (`andorraModelSwitch`). The surface is advanced in every case, so nothing replays later.
|
|
74
75
|
*/
|
|
75
76
|
export declare function advanceSurface(surface: SurfaceState | undefined, answer: HostedAnswer, entry?: AndorraEntryState): {
|
|
76
77
|
surface: SurfaceState;
|
|
@@ -213,14 +213,14 @@ export function recordAndorraRemoved(home = configDirectory()) {
|
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* What one client surface should say about a new answer, and what it has now seen. `entry` is the user's decision:
|
|
216
|
-
* a removed provider is silent, and the turned-off notice is only for someone who added the provider.
|
|
217
|
-
* is
|
|
216
|
+
* a removed provider is silent, and the turned-off notice is only for someone who added the provider. A model
|
|
217
|
+
* leaving an offer that stays on is not said here: the client that was on it is moved and told which one it is on
|
|
218
|
+
* now (`andorraModelSwitch`). The surface is advanced in every case, so nothing replays later.
|
|
218
219
|
*/
|
|
219
220
|
export function advanceSurface(surface, answer, entry) {
|
|
220
221
|
const ids = answer.enabled ? answer.models.map(m => m.id) : [];
|
|
221
222
|
const fresh = answer.enabled && !!answer.promotionId && answer.promotionId !== surface?.announced;
|
|
222
|
-
const
|
|
223
|
-
const changed = surface?.available === true && (!answer.enabled || lostModel);
|
|
223
|
+
const changed = surface?.available === true && !answer.enabled;
|
|
224
224
|
const next = {};
|
|
225
225
|
const announced = fresh ? answer.promotionId : surface?.announced;
|
|
226
226
|
if (announced !== undefined)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { changeConfigFile, loadConfig, reconcileSubagentPair } from '../config.js';
|
|
2
2
|
import { ANDORRA_CHANGED_MESSAGE } from './endpoint.js';
|
|
3
|
-
import { fallbackProviderId, hasAndorraEntry, virtualAndorraEntry } from './entry.js';
|
|
3
|
+
import { andorraModelSwitch, fallbackProviderId, hasAndorraEntry, virtualAndorraEntry } from './entry.js';
|
|
4
4
|
import { HostedMonitor } from './monitor.js';
|
|
5
|
-
import { ANDORRA_ADD_HINT, andorraAnnouncement, speechBubble } from './notices.js';
|
|
5
|
+
import { ANDORRA_ADD_HINT, andorraAnnouncement, andorraModelSwitched, speechBubble } from './notices.js';
|
|
6
6
|
import { addAndorraEntry, saveAndorraAnswer } from './opt-in.js';
|
|
7
7
|
import { readHostedState, recordAndorraRemoved } from './state.js';
|
|
8
8
|
/** The ids of the providers that serve Andorra's hosted models: the footer shows the usage while one of them is in play. */
|
|
@@ -81,7 +81,12 @@ export function createTerminalAndorra(options) {
|
|
|
81
81
|
// Written or not, take the entry as the file has it, so one another client added or removed shows here.
|
|
82
82
|
const saved = await saveAndorraAnswer(directory, answer) ?? await loadConfig(directory);
|
|
83
83
|
const before = JSON.stringify([config.providers.find(provider => provider.type === 'andorra'), config.provider]);
|
|
84
|
+
const held = { providers: structuredClone(config.providers.filter(provider => provider.type === 'andorra')) };
|
|
84
85
|
adoptAndorraEntry(config, saved);
|
|
86
|
+
// The model this terminal was on left the offer, whichever client saved the move: say which one it is on now.
|
|
87
|
+
const moved = andorraModelSwitch(held, config);
|
|
88
|
+
if (moved !== undefined && config.provider === moved.id)
|
|
89
|
+
options.print(andorraModelSwitched(moved.from, moved.to));
|
|
85
90
|
if (JSON.stringify([config.providers.find(provider => provider.type === 'andorra'), config.provider]) !== before)
|
|
86
91
|
options.refreshStatus();
|
|
87
92
|
},
|
|
@@ -40,6 +40,8 @@ export function signInRequired(providerId) {
|
|
|
40
40
|
}
|
|
41
41
|
const REFRESH_FAILED = 'Your Claude Console sign-in expired or could not be refreshed. Sign in again.';
|
|
42
42
|
export async function providerAuthHeaders(provider, options = {}) {
|
|
43
|
+
if (provider.type === 'relayed')
|
|
44
|
+
throw new Error('A relayed provider needs a run.');
|
|
43
45
|
if (provider.type === 'andorra') {
|
|
44
46
|
assertProviderCredentials(provider);
|
|
45
47
|
const token = await andorraAccessToken(options.signal);
|