@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/mcp.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
2
2
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
3
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
4
|
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
-
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { authorize } from './tools.js';
|
|
8
8
|
import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
|
|
@@ -132,6 +132,238 @@ function checkCatalogTool(id, tool, seen) {
|
|
|
132
132
|
throw new Error('MCP tool metadata exceeds limits');
|
|
133
133
|
seen.add(mcpToolName(id, tool.name));
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* The transport one configured server is reached over.
|
|
137
|
+
*
|
|
138
|
+
* The SDK adds its minimal default environment; only the explicitly configured entries are passed,
|
|
139
|
+
* so unrelated provider and cloud credentials never reach an MCP process. `${NAME}` references in
|
|
140
|
+
* the environment and headers are expanded from this process's environment (and `${PLUGIN_ROOT}`
|
|
141
|
+
* from the plugin that declared the server); a reference that is not set throws.
|
|
142
|
+
*/
|
|
143
|
+
function mcpTransport(config, workspace, overflow) {
|
|
144
|
+
const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
|
|
145
|
+
throw new Error(MISSING_REFERENCE); return value; });
|
|
146
|
+
const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, overflow) });
|
|
147
|
+
if (transport instanceof StdioClientTransport)
|
|
148
|
+
transport.stderr?.on('data', () => { });
|
|
149
|
+
return transport;
|
|
150
|
+
}
|
|
151
|
+
const MISSING_REFERENCE = 'Missing MCP environment reference';
|
|
152
|
+
/**
|
|
153
|
+
* A server definition as an edit form sent it, applied over the saved one.
|
|
154
|
+
*
|
|
155
|
+
* Environment values and header values are secrets the engine never returns, so the form cannot
|
|
156
|
+
* send them back: an entry whose value is `null` keeps the saved value of that name, an entry with
|
|
157
|
+
* a string is the new value, and a name the edit leaves out is removed. An endpoint sent without
|
|
158
|
+
* the query string the saved one carries (the form is shown it without, since a query can hold a
|
|
159
|
+
* credential) keeps the saved endpoint. The transport may change; whether the server is enabled
|
|
160
|
+
* does not — the switch beside it does that.
|
|
161
|
+
*/
|
|
162
|
+
export function mergeMcpEdit(saved, edit) {
|
|
163
|
+
if (!edit || typeof edit !== 'object' || Array.isArray(edit))
|
|
164
|
+
throw new Error('Invalid MCP server');
|
|
165
|
+
const draft = edit;
|
|
166
|
+
const keep = (values, previous, what) => {
|
|
167
|
+
if (values === undefined)
|
|
168
|
+
return undefined;
|
|
169
|
+
if (!values || typeof values !== 'object' || Array.isArray(values))
|
|
170
|
+
throw new Error(`Invalid MCP ${what}`);
|
|
171
|
+
const merged = {};
|
|
172
|
+
for (const [key, value] of Object.entries(values)) {
|
|
173
|
+
if (value === null) {
|
|
174
|
+
if (previous === undefined || !Object.prototype.hasOwnProperty.call(previous, key))
|
|
175
|
+
throw new Error(`MCP ${what} ${key} has no saved value to keep`);
|
|
176
|
+
merged[key] = previous[key];
|
|
177
|
+
}
|
|
178
|
+
else
|
|
179
|
+
merged[key] = value;
|
|
180
|
+
}
|
|
181
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
182
|
+
};
|
|
183
|
+
const enabled = saved.enabled === undefined ? {} : { enabled: saved.enabled };
|
|
184
|
+
if (draft.transport === 'stdio') {
|
|
185
|
+
const env = keep(draft.env, saved.transport === 'stdio' ? saved.env : undefined, 'environment variable');
|
|
186
|
+
return validateMcpServer({ transport: 'stdio', command: draft.command, ...(draft.args === undefined ? {} : { args: draft.args }), ...(env === undefined ? {} : { env }), ...enabled });
|
|
187
|
+
}
|
|
188
|
+
if (draft.transport === 'http') {
|
|
189
|
+
const headers = keep(draft.headers, saved.transport === 'http' ? saved.headers : undefined, 'header');
|
|
190
|
+
let url = draft.url;
|
|
191
|
+
if (saved.transport === 'http' && typeof url === 'string') {
|
|
192
|
+
try {
|
|
193
|
+
const bare = new URL(saved.url);
|
|
194
|
+
bare.search = '';
|
|
195
|
+
if (new URL(url).href === bare.href)
|
|
196
|
+
url = saved.url;
|
|
197
|
+
}
|
|
198
|
+
catch { /* An endpoint that does not parse is refused by the validation below. */ }
|
|
199
|
+
}
|
|
200
|
+
return validateMcpServer({ transport: 'http', url, ...(headers === undefined ? {} : { headers }), ...enabled });
|
|
201
|
+
}
|
|
202
|
+
throw new Error('MCP transport must be stdio or http');
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A reporter that records what a task's connections answered. A task names a server from the
|
|
206
|
+
* configuration `configured:<id>` (the extension snapshot's namespace, apart from plugins' servers),
|
|
207
|
+
* and the record is filed under the configuration's own id, which is what the settings page lists.
|
|
208
|
+
*/
|
|
209
|
+
export function mcpTaskStatusReporter(directory) {
|
|
210
|
+
const store = mcpStatusStore(directory);
|
|
211
|
+
return (id, config, result) => {
|
|
212
|
+
const configured = id.startsWith('configured:') ? id.slice('configured:'.length) : id;
|
|
213
|
+
void store.record(configured, config, result, 'task').catch(() => { });
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The identity of a server's definition — command, arguments, environment, address, headers — and
|
|
218
|
+
* not whether it is turned on, so a status survives the switch but not an edit. Credentials in the
|
|
219
|
+
* definition only enter the digest.
|
|
220
|
+
*/
|
|
221
|
+
export function mcpDefinitionKey(config) {
|
|
222
|
+
const { enabled: _enabled, ...definition } = config;
|
|
223
|
+
return createHash('sha256').update(canonical(definition)).digest('hex');
|
|
224
|
+
}
|
|
225
|
+
/** Status records are small; a file past this was not written here and is not read. */
|
|
226
|
+
const MCP_STATUS_FILE_MAX_BYTES = 16_000;
|
|
227
|
+
/**
|
|
228
|
+
* The last thing each server answered, one small file per server under the configuration home, so a
|
|
229
|
+
* settings page can show it without starting anything. A task's connection writes it, and so does an
|
|
230
|
+
* explicit check (`mcp.status`); one file per server keeps two processes recording at once from
|
|
231
|
+
* overwriting each other's servers. Every failure to read reads as "not checked".
|
|
232
|
+
*/
|
|
233
|
+
export function mcpStatusStore(directory) {
|
|
234
|
+
const root = join(directory, 'mcp-status');
|
|
235
|
+
const file = (id) => join(root, `${createHash('sha256').update(id).digest('hex')}.json`);
|
|
236
|
+
return {
|
|
237
|
+
async list() {
|
|
238
|
+
let names;
|
|
239
|
+
try {
|
|
240
|
+
names = await readdir(root);
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
const records = [];
|
|
246
|
+
for (const name of names.filter(entry => /^[a-f0-9]{64}\.json$/.test(entry)).slice(0, 1000)) {
|
|
247
|
+
try {
|
|
248
|
+
const raw = await readFile(join(root, name), 'utf8');
|
|
249
|
+
if (raw.length > MCP_STATUS_FILE_MAX_BYTES)
|
|
250
|
+
continue;
|
|
251
|
+
const parsed = JSON.parse(raw);
|
|
252
|
+
if (parsed.version !== 1 || typeof parsed.id !== 'string' || typeof parsed.definition !== 'string' || typeof parsed.checkedAt !== 'string'
|
|
253
|
+
|| (parsed.state !== 'ready' && parsed.state !== 'failed') || (parsed.source !== 'task' && parsed.source !== 'check'))
|
|
254
|
+
continue;
|
|
255
|
+
records.push({
|
|
256
|
+
id: parsed.id, definition: parsed.definition, state: parsed.state, checkedAt: parsed.checkedAt, source: parsed.source,
|
|
257
|
+
...(typeof parsed.tools === 'number' ? { tools: parsed.tools } : {}),
|
|
258
|
+
...(typeof parsed.error === 'string' ? { error: parsed.error } : {}),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
catch { /* An unreadable record is a server not checked. */ }
|
|
262
|
+
}
|
|
263
|
+
return records;
|
|
264
|
+
},
|
|
265
|
+
async record(id, config, result, source, at = new Date()) {
|
|
266
|
+
const record = {
|
|
267
|
+
id, definition: mcpDefinitionKey(config), state: result.state, checkedAt: at.toISOString(), source,
|
|
268
|
+
...(result.state === 'ready' ? { tools: result.tools } : { error: result.error }),
|
|
269
|
+
};
|
|
270
|
+
const target = file(id);
|
|
271
|
+
const staging = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
272
|
+
try {
|
|
273
|
+
await mkdir(root, { recursive: true });
|
|
274
|
+
await writeFile(staging, `${JSON.stringify({ version: 1, ...record })}\n`, { mode: 0o600 });
|
|
275
|
+
await rename(staging, target);
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
await rm(staging, { force: true }).catch(() => { });
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
return record;
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Start one configured server, list its tools, and stop it again: the check a person asks for from
|
|
287
|
+
* the settings page ("Check Connection"), never one a page makes on its own — a task asks before it
|
|
288
|
+
* connects a server, and opening a page is not that consent.
|
|
289
|
+
*
|
|
290
|
+
* Nothing is kept. The catalog is only counted, and the client — with the process it started, for a
|
|
291
|
+
* stdio server — is closed before this returns, whatever happened. A probe is bounded in time as a
|
|
292
|
+
* task's connection is: 15 seconds to connect, 15 per page of tools, 30 in all.
|
|
293
|
+
*/
|
|
294
|
+
export async function probeMcpServer(config, workspace, signal) {
|
|
295
|
+
const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
|
|
296
|
+
const limit = AbortSignal.timeout(30_000);
|
|
297
|
+
const probeSignal = signal === undefined ? limit : AbortSignal.any([signal, limit]);
|
|
298
|
+
let http;
|
|
299
|
+
try {
|
|
300
|
+
validateMcpServer(config);
|
|
301
|
+
const transport = mcpTransport(config, workspace, () => { void client.close().catch(() => { }); });
|
|
302
|
+
if (transport instanceof StreamableHTTPClientTransport)
|
|
303
|
+
http = transport;
|
|
304
|
+
await client.connect(transport, { signal: probeSignal, timeout: 15_000 });
|
|
305
|
+
let tools = 0;
|
|
306
|
+
const cursors = new Set();
|
|
307
|
+
let cursor;
|
|
308
|
+
let pages = 0;
|
|
309
|
+
do {
|
|
310
|
+
if (++pages > 100)
|
|
311
|
+
throw new Error('MCP catalog exceeded the 100-page limit');
|
|
312
|
+
const page = await client.listTools({ cursor }, { signal: probeSignal, timeout: 15_000 });
|
|
313
|
+
tools += page.tools.length;
|
|
314
|
+
cursor = page.nextCursor;
|
|
315
|
+
if (cursor && cursors.has(cursor))
|
|
316
|
+
throw new Error('MCP catalog repeated a cursor');
|
|
317
|
+
if (cursor)
|
|
318
|
+
cursors.add(cursor);
|
|
319
|
+
} while (cursor);
|
|
320
|
+
return { state: 'ready', tools };
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
return { state: 'failed', error: probeFailureReason(error, config) };
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
try {
|
|
327
|
+
await http?.terminateSession();
|
|
328
|
+
}
|
|
329
|
+
catch { }
|
|
330
|
+
await client.close().catch(() => { });
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Why a probe failed, in words a person can act on.
|
|
335
|
+
*
|
|
336
|
+
* A transport error can carry what the server sent back, and an HTTP one can echo the request's own
|
|
337
|
+
* headers, so the message itself is never passed on: the error is sorted into a known kind, and only
|
|
338
|
+
* the facts that are the configuration's own (its command) or the protocol's (a status code) are named.
|
|
339
|
+
*/
|
|
340
|
+
export function probeFailureReason(error, config) {
|
|
341
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
342
|
+
const name = error instanceof Error ? error.name : '';
|
|
343
|
+
const code = error?.code ?? error?.cause?.code;
|
|
344
|
+
if (message === MISSING_REFERENCE)
|
|
345
|
+
return 'An environment variable its settings refer to is not set.';
|
|
346
|
+
if (message.startsWith('Invalid MCP') || message.startsWith('MCP requires') || message.startsWith('MCP transport'))
|
|
347
|
+
return 'Its settings are not valid.';
|
|
348
|
+
if (config.transport === 'stdio' && (code === 'ENOENT' || /\bENOENT\b/.test(message)))
|
|
349
|
+
return `Command not found: ${config.command ?? 'the configured command'}.`;
|
|
350
|
+
if (config.transport === 'stdio' && (code === 'EACCES' || /\bEACCES\b/.test(message)))
|
|
351
|
+
return `Not allowed to run ${config.command ?? 'the configured command'}.`;
|
|
352
|
+
if (name === 'TimeoutError' || /timed? ?out/i.test(message) || code === -32001)
|
|
353
|
+
return 'It did not answer in time.';
|
|
354
|
+
const status = /\(HTTP (\d{3})\)/.exec(message)?.[1];
|
|
355
|
+
if (status === '401' || status === '403')
|
|
356
|
+
return `Not authorized (HTTP ${status}). Check its headers.`;
|
|
357
|
+
if (status !== undefined)
|
|
358
|
+
return `The server answered HTTP ${status}.`;
|
|
359
|
+
if (typeof code === 'string' && /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ECONNRESET|ETIMEDOUT|EHOSTUNREACH)$/.test(code))
|
|
360
|
+
return 'Could not reach the server.';
|
|
361
|
+
if (/connection closed/i.test(message))
|
|
362
|
+
return 'The server stopped before it answered.';
|
|
363
|
+
if (message === 'MCP response exceeds 1 MiB transport limit')
|
|
364
|
+
return 'Its answer was larger than 1 MiB.';
|
|
365
|
+
return 'Could not connect or list its tools. Check its command and authentication.';
|
|
366
|
+
}
|
|
135
367
|
const OVER_BUDGET = 'MCP catalog exceeds task metadata budget';
|
|
136
368
|
// Transport errors can contain server-provided strings or auth headers: report a bounded, non-secret status.
|
|
137
369
|
const unavailableReason = (error) => error instanceof Error && error.message === 'Permission denied' ? 'connection permission denied'
|
|
@@ -214,14 +446,8 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
|
|
|
214
446
|
const connectServer = async (id, config, accept) => {
|
|
215
447
|
const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
|
|
216
448
|
try {
|
|
217
|
-
const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
|
|
218
|
-
throw new Error('Missing MCP environment reference'); return value; });
|
|
219
449
|
startupSignal.throwIfAborted();
|
|
220
|
-
|
|
221
|
-
// entries so unrelated provider/cloud credentials never reach MCP processes.
|
|
222
|
-
const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: context.workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, () => { void client.close().catch(() => { }); }) });
|
|
223
|
-
if (transport instanceof StdioClientTransport)
|
|
224
|
-
transport.stderr?.on('data', () => { });
|
|
450
|
+
const transport = mcpTransport(config, context.workspace, () => { void client.close().catch(() => { }); });
|
|
225
451
|
clients.set(client, transport instanceof StreamableHTTPClientTransport ? transport : undefined);
|
|
226
452
|
await client.connect(transport, { signal: startupSignal, timeout: 15_000 });
|
|
227
453
|
const discoverySignal = AbortSignal.any([startupSignal, AbortSignal.timeout(30_000)]);
|
|
@@ -374,6 +600,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
|
|
|
374
600
|
});
|
|
375
601
|
});
|
|
376
602
|
background = connection.then(async (live) => {
|
|
603
|
+
options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
|
|
377
604
|
// Key order inside a schema is the server's serializer's business, not a change of catalog.
|
|
378
605
|
if (canonical(live.catalog) === canonical(known.catalog)) {
|
|
379
606
|
notice(`MCP ${id}: ${known.catalog.length} tools available to agents with shell permission.`);
|
|
@@ -390,6 +617,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
|
|
|
390
617
|
// A task that is ending says nothing about the server: its record stands.
|
|
391
618
|
if (startupSignal.aborted)
|
|
392
619
|
return;
|
|
620
|
+
options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
|
|
393
621
|
// The next task asks the server before offering its tools, as for one never seen.
|
|
394
622
|
await store.remove(key).catch(() => { });
|
|
395
623
|
notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
|
|
@@ -434,6 +662,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
|
|
|
434
662
|
}
|
|
435
663
|
catalogBytes += limits.bytes;
|
|
436
664
|
notice(`MCP ${id}: ${live.catalog.length} tools available to agents with shell permission.`);
|
|
665
|
+
options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
|
|
437
666
|
// Remembered for the next task. An empty catalog offers nothing to wait for and is asked again.
|
|
438
667
|
if (store && key !== undefined && live.catalog.length > 0)
|
|
439
668
|
await store.write(key, { tools: live.catalog }).catch(() => { });
|
|
@@ -444,6 +673,9 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
|
|
|
444
673
|
// next task is told the same thing without waiting for the server to say it again.
|
|
445
674
|
if (store && key !== undefined && error instanceof Error && error.message === OVER_BUDGET)
|
|
446
675
|
await store.write(key, { overBudget: true }).catch(() => { });
|
|
676
|
+
// A catalog refused for the task's budget came from a server that answered: that is not its status.
|
|
677
|
+
else
|
|
678
|
+
options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
|
|
447
679
|
notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
|
|
448
680
|
}
|
|
449
681
|
}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/** What a membership check found, as far as naming the refusal needs. */
|
|
2
|
+
export interface MembershipVerdict {
|
|
3
|
+
paid: boolean;
|
|
4
|
+
unavailable?: boolean;
|
|
5
|
+
failureReason?: 'tls' | 'dns' | 'network';
|
|
6
|
+
subject?: string;
|
|
7
|
+
}
|
|
1
8
|
/** A graph feature the account's membership does not reach. */
|
|
2
9
|
export declare class PaidMembershipRequiredError extends Error {
|
|
3
10
|
constructor(message?: string);
|
|
11
|
+
/**
|
|
12
|
+
* The refusal for one membership answer, naming which of its causes applies.
|
|
13
|
+
*
|
|
14
|
+
* One message used to cover all three, so a dropped connection and a lost sign-in both read as
|
|
15
|
+
* "paid membership is required" and sent people to check a membership they had.
|
|
16
|
+
*/
|
|
17
|
+
static for(access: MembershipVerdict): PaidMembershipRequiredError;
|
|
4
18
|
}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
const FEATURES = 'the Andorra workflow, custom workflows and the Workflow Editor';
|
|
2
|
+
const REASONS = {
|
|
3
|
+
tls: 'a secure connection to the account service could not be verified',
|
|
4
|
+
dns: 'the account service address could not be resolved',
|
|
5
|
+
network: 'the account service could not be reached',
|
|
6
|
+
};
|
|
1
7
|
/** A graph feature the account's membership does not reach. */
|
|
2
8
|
export class PaidMembershipRequiredError extends Error {
|
|
3
|
-
constructor(message =
|
|
9
|
+
constructor(message = `Paid membership is required for ${FEATURES}. Use /login to sign in. If already signed in, check your membership or connection.`) { super(message); }
|
|
10
|
+
/**
|
|
11
|
+
* The refusal for one membership answer, naming which of its causes applies.
|
|
12
|
+
*
|
|
13
|
+
* One message used to cover all three, so a dropped connection and a lost sign-in both read as
|
|
14
|
+
* "paid membership is required" and sent people to check a membership they had.
|
|
15
|
+
*/
|
|
16
|
+
static for(access) {
|
|
17
|
+
if (access.unavailable) {
|
|
18
|
+
const reason = access.failureReason ? `: ${REASONS[access.failureReason]}` : ' right now';
|
|
19
|
+
return new PaidMembershipRequiredError(`Your Andorra membership could not be checked${reason}. This does not mean you were signed out; check your connection and retry.`);
|
|
20
|
+
}
|
|
21
|
+
if (!access.subject)
|
|
22
|
+
return new PaidMembershipRequiredError(`You are signed out of your Andorra account. Use /login to sign in again; ${FEATURES} need a signed-in account.`);
|
|
23
|
+
if (!access.paid)
|
|
24
|
+
return new PaidMembershipRequiredError('This needs a paid membership, and your Andorra account does not have one.');
|
|
25
|
+
return new PaidMembershipRequiredError();
|
|
26
|
+
}
|
|
4
27
|
}
|
package/dist/src/membership.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import type { TelemetryPlan } from './telemetry/schema.js';
|
|
|
6
6
|
* The selection id and the export name keep their `software-engineer` spellings for saved-run and
|
|
7
7
|
* saved-selection compatibility; the agent the user sees is the Andorra Agent, which handles general
|
|
8
8
|
* tasks and coding alike.
|
|
9
|
+
*
|
|
10
|
+
* Its body is {@link DEFAULT_AGENT_GRAPH}, which the latest bundled `default` revision shown in Graph
|
|
11
|
+
* Studio is built from too, so the editor shows exactly what a Default run executes. The run identity
|
|
12
|
+
* stays as it was: schema version 2, `software-engineer` and revision 1, which saved runs recorded.
|
|
9
13
|
*/
|
|
10
14
|
export declare const SOFTWARE_ENGINEER_HARNESS: Graph;
|
|
11
15
|
/** Reserved selection cannot collide with a saved graph's filesystem-safe id. */
|
|
@@ -21,6 +25,13 @@ export type MembershipFailureReason = 'tls' | 'dns' | 'network';
|
|
|
21
25
|
*/
|
|
22
26
|
export type MembershipTier = 'free' | 'legacy' | 'paid';
|
|
23
27
|
export declare const MEMBERSHIP_TIERS: readonly MembershipTier[];
|
|
28
|
+
/**
|
|
29
|
+
* The rolling-window fields of a membership answer, each kept only when it is well formed.
|
|
30
|
+
*
|
|
31
|
+
* They are display metadata from a newer service: an older one sends none, and a malformed one is
|
|
32
|
+
* dropped on its own rather than failing the whole membership.
|
|
33
|
+
*/
|
|
34
|
+
export declare function windowFields(result: Record<string, unknown>): Pick<Membership, 'fairUse' | 'windowDays' | 'windowDecisionLimit' | 'windowDecisionUsed' | 'windowDecisionResetsAt'>;
|
|
24
35
|
export interface Membership {
|
|
25
36
|
paid: boolean;
|
|
26
37
|
unavailable?: boolean;
|
|
@@ -32,6 +43,15 @@ export interface Membership {
|
|
|
32
43
|
dailyDecisionUsed?: number;
|
|
33
44
|
dailyDecisionResetsAt?: string;
|
|
34
45
|
decisionsSinceRollout?: number; /**
|
|
46
|
+
* The rolling allowance: Free accounts get `windowDecisionLimit` decisions per `windowDays` UTC days;
|
|
47
|
+
* Paid and Legacy accounts are unlimited under fair use (`fairUse`), with a daily and a window cap.
|
|
48
|
+
* `windowDecisionResetsAt` is when the oldest counted decision leaves the window.
|
|
49
|
+
*/
|
|
50
|
+
fairUse?: boolean;
|
|
51
|
+
windowDays?: number;
|
|
52
|
+
windowDecisionLimit?: number;
|
|
53
|
+
windowDecisionUsed?: number;
|
|
54
|
+
windowDecisionResetsAt?: string; /**
|
|
35
55
|
* Where the account's billing lives, when the service has a billing page for it. Subscription
|
|
36
56
|
* billing is not set up yet, so the account service does not send this.
|
|
37
57
|
*/
|
package/dist/src/membership.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
|
|
2
|
+
import { DEFAULT_HARNESS, GRAPH_MANAGER_GRAPH_ID, GRAPH_MANAGER_HARNESS, GraphDeletedError, isDeletedGraph, loadGraph } from './graphs.js';
|
|
2
3
|
import { AUTH_REFRESH_BUDGET_MS, AuthError, getAccessToken, getAuthConfiguration } from './auth/index.js';
|
|
3
4
|
import { graphStorageDirectory } from './graph-account.js';
|
|
4
5
|
import { configDirectory, loadConfig } from './config.js';
|
|
@@ -13,18 +14,15 @@ import { loadFreeTierGraph } from './graph-quota.js';
|
|
|
13
14
|
* The selection id and the export name keep their `software-engineer` spellings for saved-run and
|
|
14
15
|
* saved-selection compatibility; the agent the user sees is the Andorra Agent, which handles general
|
|
15
16
|
* tasks and coding alike.
|
|
17
|
+
*
|
|
18
|
+
* Its body is {@link DEFAULT_AGENT_GRAPH}, which the latest bundled `default` revision shown in Graph
|
|
19
|
+
* Studio is built from too, so the editor shows exactly what a Default run executes. The run identity
|
|
20
|
+
* stays as it was: schema version 2, `software-engineer` and revision 1, which saved runs recorded.
|
|
16
21
|
*/
|
|
22
|
+
// Keys keep their original order, so the serialized run graph is byte-identical to earlier releases.
|
|
17
23
|
export const SOFTWARE_ENGINEER_HARNESS = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
nodes: {
|
|
21
|
-
engineer: { id: 'engineer', name: 'Andorra Agent', type: 'agent', executor: 'react-basic',
|
|
22
|
-
instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. If no pull request was created or its number is unknown, say so rather than guessing. Start new implementation work only when the user requests it.',
|
|
23
|
-
contextPolicy: { history: true }, jevEnabled: true,
|
|
24
|
-
subagents: { enabled: false }, position: { x: 120, y: 120 } },
|
|
25
|
-
done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
|
|
26
|
-
},
|
|
27
|
-
edges: [{ id: 'engineer-done', source: 'engineer', target: 'done', outcome: 'completed' }],
|
|
24
|
+
schemaVersion: 2, id: 'software-engineer', name: DEFAULT_AGENT_GRAPH.name, revision: 1, entry: DEFAULT_AGENT_GRAPH.entry,
|
|
25
|
+
nodes: structuredClone(DEFAULT_AGENT_GRAPH.nodes), edges: structuredClone(DEFAULT_AGENT_GRAPH.edges),
|
|
28
26
|
};
|
|
29
27
|
/** Reserved selection cannot collide with a saved graph's filesystem-safe id. */
|
|
30
28
|
export const ANDORRA_GRAPH_SELECTION = ':andorra';
|
|
@@ -37,6 +35,28 @@ export function getAndorraHarness() {
|
|
|
37
35
|
return graph;
|
|
38
36
|
}
|
|
39
37
|
export const MEMBERSHIP_TIERS = ['free', 'legacy', 'paid'];
|
|
38
|
+
/**
|
|
39
|
+
* The rolling-window fields of a membership answer, each kept only when it is well formed.
|
|
40
|
+
*
|
|
41
|
+
* They are display metadata from a newer service: an older one sends none, and a malformed one is
|
|
42
|
+
* dropped on its own rather than failing the whole membership.
|
|
43
|
+
*/
|
|
44
|
+
export function windowFields(result) {
|
|
45
|
+
const positive = (value) => Number.isSafeInteger(value) && value > 0;
|
|
46
|
+
const fields = {};
|
|
47
|
+
if (typeof result.fairUse === 'boolean')
|
|
48
|
+
fields.fairUse = result.fairUse;
|
|
49
|
+
if (positive(result.windowDays) && result.windowDays <= 366)
|
|
50
|
+
fields.windowDays = result.windowDays;
|
|
51
|
+
if (positive(result.windowDecisionLimit))
|
|
52
|
+
fields.windowDecisionLimit = result.windowDecisionLimit;
|
|
53
|
+
if (Number.isSafeInteger(result.windowDecisionUsed) && result.windowDecisionUsed >= 0)
|
|
54
|
+
fields.windowDecisionUsed = result.windowDecisionUsed;
|
|
55
|
+
const reset = result.windowDecisionResetsAt;
|
|
56
|
+
if (typeof reset === 'string' && reset.length <= 40 && /^\d{4}-\d{2}-\d{2}T/.test(reset) && Number.isFinite(Date.parse(reset)))
|
|
57
|
+
fields.windowDecisionResetsAt = reset;
|
|
58
|
+
return fields;
|
|
59
|
+
}
|
|
40
60
|
/**
|
|
41
61
|
* How a membership is named to the user.
|
|
42
62
|
*
|
|
@@ -174,6 +194,7 @@ export function createMembershipClient(deps) {
|
|
|
174
194
|
// answer records as Legacy.
|
|
175
195
|
const observedAt = new Date().toISOString();
|
|
176
196
|
await (deps.recordPlan ?? recordPlanConfirmation)({ subject: result.subject, tier: analyticsPlanFromMembership(tier, result.paid), observedAt }, home).catch(() => { });
|
|
197
|
+
const windowed = windowFields(result);
|
|
177
198
|
const lifetime = Number.isSafeInteger(result.decisionsSinceRollout) && result.decisionsSinceRollout >= 0
|
|
178
199
|
? result.decisionsSinceRollout : undefined;
|
|
179
200
|
// A billing link opens a page in the user's browser, so it is checked before it is used.
|
|
@@ -182,6 +203,7 @@ export function createMembershipClient(deps) {
|
|
|
182
203
|
return { paid: result.paid, subject: result.subject, ...(email ? { email } : {}), ...(tier ? { tier } : {}), ...(result.dailyDecisionLimit === undefined ? {} : { dailyDecisionLimit: result.dailyDecisionLimit }),
|
|
183
204
|
...(validUsage ? { dailyDecisionUsed: result.dailyDecisionUsed, dailyDecisionResetsAt: reset } : {}),
|
|
184
205
|
...(lifetime === undefined ? {} : { decisionsSinceRollout: lifetime }),
|
|
206
|
+
...windowed,
|
|
185
207
|
...(billing === undefined ? {} : { billingUrl: billing }) };
|
|
186
208
|
}
|
|
187
209
|
catch (error) {
|
|
@@ -206,8 +228,9 @@ export const getMembership = createMembershipClient({
|
|
|
206
228
|
fetch: (...args) => globalThis.fetch(...args),
|
|
207
229
|
});
|
|
208
230
|
export async function requirePaidMembership(signal) {
|
|
209
|
-
|
|
210
|
-
|
|
231
|
+
const access = await getMembership(signal);
|
|
232
|
+
if (!access.paid)
|
|
233
|
+
throw PaidMembershipRequiredError.for(access);
|
|
211
234
|
}
|
|
212
235
|
/**
|
|
213
236
|
* Refuse graph building to an account the membership service has not confirmed.
|
|
@@ -222,7 +245,7 @@ export async function requireGraphMembership(signal) {
|
|
|
222
245
|
export async function readGraphMembership(signal) {
|
|
223
246
|
const access = await getMembership(signal);
|
|
224
247
|
if (!access.paid && !access.subject)
|
|
225
|
-
throw
|
|
248
|
+
throw PaidMembershipRequiredError.for(access);
|
|
226
249
|
return access;
|
|
227
250
|
}
|
|
228
251
|
/** Called for every CLI run so a saved selection cannot bypass a membership downgrade. */
|
|
@@ -230,15 +253,21 @@ export async function loadAccessibleGraph(id = 'default', signal, membership = g
|
|
|
230
253
|
signal?.throwIfAborted();
|
|
231
254
|
if (id === 'default')
|
|
232
255
|
return structuredClone(SOFTWARE_ENGINEER_HARNESS);
|
|
256
|
+
// Graph Studio's own chat graph is built in like the default: it is no account's saved graph, so
|
|
257
|
+
// no membership or free allowance decides it, and every account that opens Graph Studio runs it.
|
|
258
|
+
if (id === GRAPH_MANAGER_GRAPH_ID)
|
|
259
|
+
return structuredClone(GRAPH_MANAGER_HARNESS);
|
|
233
260
|
const access = await membership(signal);
|
|
234
261
|
signal?.throwIfAborted();
|
|
235
262
|
// A free account runs its one custom graph; the Andorra preset stays Premium. Membership that could
|
|
236
263
|
// not be read names no subject, so it is refused here as before.
|
|
237
264
|
if (!access.paid && (id === ANDORRA_GRAPH_SELECTION || access.unavailable))
|
|
238
|
-
throw
|
|
265
|
+
throw PaidMembershipRequiredError.for(access);
|
|
239
266
|
if (id === ANDORRA_GRAPH_SELECTION)
|
|
240
267
|
return getAndorraHarness();
|
|
241
|
-
if (!access.subject
|
|
268
|
+
if (!access.subject)
|
|
269
|
+
throw PaidMembershipRequiredError.for(access);
|
|
270
|
+
if (!/^[A-Za-z0-9-]{1,128}$/.test(access.subject))
|
|
242
271
|
throw new PaidMembershipRequiredError();
|
|
243
272
|
const directory = await graphStorageDirectory(undefined, access.subject);
|
|
244
273
|
const graph = access.paid ? await loadGraph(id, undefined, directory) : await loadFreeTierGraph(id, directory);
|
package/dist/src/palette.d.ts
CHANGED
|
@@ -15,26 +15,43 @@ export declare const SUBTLE = 250;
|
|
|
15
15
|
export declare const WHITE = 231;
|
|
16
16
|
/** The accent: the brightest neutral, so emphasis reads as strength rather than color. */
|
|
17
17
|
export declare const ACCENT_INDEX = 231;
|
|
18
|
-
/** A picked skill in the composer: bold indigo, so a recognised command reads apart from typed text and
|
|
18
|
+
/** A picked skill in the composer: bold indigo, so a recognised command reads apart from typed text and bold attachments. */
|
|
19
19
|
export declare const SKILL_CHIP = 147;
|
|
20
20
|
/**
|
|
21
21
|
* Semantic status colors, the only hues in the palette.
|
|
22
22
|
*
|
|
23
|
-
* These carry meaning (
|
|
24
|
-
* neutral accent cannot. `error` is the one red, kept for failures and removed lines.
|
|
23
|
+
* These carry meaning (a passed check or an added line, a failure or a removed line) that
|
|
24
|
+
* the neutral accent cannot. `error` is the one red, kept for failures and removed lines.
|
|
25
|
+
* There is no amber: something that needs attention is set in {@link ATTENTION}, by weight.
|
|
25
26
|
*/
|
|
26
27
|
export declare const STATUS: {
|
|
27
28
|
readonly ok: 114;
|
|
28
|
-
readonly warn: 214;
|
|
29
29
|
readonly error: 203;
|
|
30
30
|
readonly added: 114;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Attention without a hue, as an SGR parameter: bold in the terminal's own foreground.
|
|
34
|
+
*
|
|
35
|
+
* The elevated Full Access permission state, the model-override hint and a node a run stopped
|
|
36
|
+
* on need to stand out from the gray chrome around them, but the palette keeps hue for status.
|
|
37
|
+
* Weight carries it instead, and the terminal's default foreground keeps it legible on dark
|
|
38
|
+
* and light themes alike, where a fixed bright neutral would vanish on a light background.
|
|
39
|
+
*
|
|
40
|
+
* `39` restores that default foreground explicitly: bold alone keeps whatever foreground an
|
|
41
|
+
* enclosing paint set, and the welcome wraps the override hint in the draft gray (252), which
|
|
42
|
+
* would leave it near-white on a light theme.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ATTENTION = "1;39";
|
|
45
|
+
/**
|
|
46
|
+
* Attachment tokens in the composer, as an SGR parameter: plain bold in the terminal's own
|
|
47
|
+
* foreground.
|
|
48
|
+
*
|
|
49
|
+
* An inline paste, image, or file reference must read as an object rather than as typed
|
|
50
|
+
* text. Weight and its bracketed label carry that, so a token never borrows a status hue and
|
|
51
|
+
* never matches the indigo skill chip, and it stays legible on a light terminal theme. As with
|
|
52
|
+
* {@link ATTENTION}, `39` resets any inherited foreground so the token never takes the draft gray.
|
|
36
53
|
*/
|
|
37
|
-
export declare const ATTACHMENT_TOKEN =
|
|
54
|
+
export declare const ATTACHMENT_TOKEN = "1;39";
|
|
38
55
|
/**
|
|
39
56
|
* Whether the terminal can render 24-bit color.
|
|
40
57
|
*
|
package/dist/src/palette.js
CHANGED
|
@@ -15,21 +15,39 @@ export const SUBTLE = 250;
|
|
|
15
15
|
export const WHITE = 231;
|
|
16
16
|
/** The accent: the brightest neutral, so emphasis reads as strength rather than color. */
|
|
17
17
|
export const ACCENT_INDEX = WHITE;
|
|
18
|
-
/** A picked skill in the composer: bold indigo, so a recognised command reads apart from typed text and
|
|
18
|
+
/** A picked skill in the composer: bold indigo, so a recognised command reads apart from typed text and bold attachments. */
|
|
19
19
|
export const SKILL_CHIP = 147;
|
|
20
20
|
/**
|
|
21
21
|
* Semantic status colors, the only hues in the palette.
|
|
22
22
|
*
|
|
23
|
-
* These carry meaning (
|
|
24
|
-
* neutral accent cannot. `error` is the one red, kept for failures and removed lines.
|
|
23
|
+
* These carry meaning (a passed check or an added line, a failure or a removed line) that
|
|
24
|
+
* the neutral accent cannot. `error` is the one red, kept for failures and removed lines.
|
|
25
|
+
* There is no amber: something that needs attention is set in {@link ATTENTION}, by weight.
|
|
25
26
|
*/
|
|
26
|
-
export const STATUS = { ok: 114,
|
|
27
|
+
export const STATUS = { ok: 114, error: 203, added: 114 };
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Attention without a hue, as an SGR parameter: bold in the terminal's own foreground.
|
|
30
|
+
*
|
|
31
|
+
* The elevated Full Access permission state, the model-override hint and a node a run stopped
|
|
32
|
+
* on need to stand out from the gray chrome around them, but the palette keeps hue for status.
|
|
33
|
+
* Weight carries it instead, and the terminal's default foreground keeps it legible on dark
|
|
34
|
+
* and light themes alike, where a fixed bright neutral would vanish on a light background.
|
|
35
|
+
*
|
|
36
|
+
* `39` restores that default foreground explicitly: bold alone keeps whatever foreground an
|
|
37
|
+
* enclosing paint set, and the welcome wraps the override hint in the draft gray (252), which
|
|
38
|
+
* would leave it near-white on a light theme.
|
|
39
|
+
*/
|
|
40
|
+
export const ATTENTION = '1;39';
|
|
41
|
+
/**
|
|
42
|
+
* Attachment tokens in the composer, as an SGR parameter: plain bold in the terminal's own
|
|
43
|
+
* foreground.
|
|
44
|
+
*
|
|
45
|
+
* An inline paste, image, or file reference must read as an object rather than as typed
|
|
46
|
+
* text. Weight and its bracketed label carry that, so a token never borrows a status hue and
|
|
47
|
+
* never matches the indigo skill chip, and it stays legible on a light terminal theme. As with
|
|
48
|
+
* {@link ATTENTION}, `39` resets any inherited foreground so the token never takes the draft gray.
|
|
31
49
|
*/
|
|
32
|
-
export const ATTACHMENT_TOKEN =
|
|
50
|
+
export const ATTACHMENT_TOKEN = '1;39';
|
|
33
51
|
/**
|
|
34
52
|
* Whether the terminal can render 24-bit color.
|
|
35
53
|
*
|
|
@@ -23,12 +23,12 @@ export interface EngineTransport {
|
|
|
23
23
|
}
|
|
24
24
|
export declare function isEngineContextOverflow(errorMessage: string): boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Move the serializer's conversation breakpoint off the trailing
|
|
26
|
+
* Move the serializer's conversation breakpoint off the trailing messages a later request rewrites.
|
|
27
27
|
*
|
|
28
28
|
* Anthropic writes a cache entry only at a marked block, and the vendored serializer marks the
|
|
29
|
-
* final message.
|
|
30
|
-
* request
|
|
31
|
-
*
|
|
29
|
+
* final message. When that message is transient guidance, the entry would end at a message the
|
|
30
|
+
* next request replaces, so no prefix of the next request ever matches it and the whole history
|
|
31
|
+
* is re-written every turn. Marking the last committed message instead lets
|
|
32
32
|
* the next request find that entry by looking back from its own breakpoint.
|
|
33
33
|
*/
|
|
34
34
|
export declare function relocateConversationBreakpoint(body: Record<string, unknown>, mutableTail: number): void;
|