@andorra-labs/code 0.1.14 → 0.1.15
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 +54 -0
- package/dist/src/acp-agent.js +991 -0
- package/dist/src/agent-execution.js +4 -0
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +2 -0
- package/dist/src/agent-mcp.js +84 -2
- package/dist/src/andorra/entry.js +21 -3
- package/dist/src/andorra/hosted.d.ts +3 -0
- package/dist/src/andorra/hosted.js +5 -1
- package/dist/src/andorra/notices.d.ts +10 -1
- package/dist/src/andorra/notices.js +25 -2
- package/dist/src/andorra/terminal.d.ts +2 -0
- package/dist/src/andorra/terminal.js +2 -2
- package/dist/src/app-server/protocol.d.ts +6 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +141 -10
- package/dist/src/app-server.d.ts +8 -0
- package/dist/src/app-server.js +87 -41
- package/dist/src/auth/AuthManager.js +4 -4
- package/dist/src/browser-bridge.d.ts +1 -0
- package/dist/src/browser-bridge.js +5 -2
- package/dist/src/browser-external-app.d.ts +27 -0
- package/dist/src/browser-external-app.js +60 -0
- package/dist/src/browser-panel-tool.d.ts +6 -0
- package/dist/src/browser-panel-tool.js +36 -0
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +60 -2
- package/dist/src/bug-report.d.ts +81 -0
- package/dist/src/bug-report.js +235 -0
- package/dist/src/claude-provider.d.ts +2 -1
- package/dist/src/claude-provider.js +10 -8
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +164 -34
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +9 -2
- package/dist/src/command-screens.js +161 -94
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +1 -0
- package/dist/src/completion-gates.d.ts +22 -0
- package/dist/src/completion-gates.js +11 -0
- package/dist/src/config.d.ts +5 -0
- package/dist/src/config.js +48 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.js +1 -1
- package/dist/src/graph-manager-chat.js +6 -1
- package/dist/src/graph-sync.d.ts +1 -0
- package/dist/src/graph-sync.js +93 -34
- package/dist/src/graph-tool.d.ts +2 -0
- package/dist/src/graph-tool.js +2 -2
- package/dist/src/graph-ui/app.js +67 -8
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/live-model.d.ts +24 -0
- package/dist/src/live-model.js +37 -0
- package/dist/src/managed-sign-in.d.ts +1 -0
- package/dist/src/managed-sign-in.js +13 -0
- package/dist/src/membership-errors.d.ts +2 -0
- package/dist/src/membership-errors.js +5 -1
- package/dist/src/membership.d.ts +3 -0
- package/dist/src/membership.js +19 -2
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +8 -1
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/provider-connection.js +17 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +3 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.js +14 -2
- package/dist/src/providers.d.ts +16 -2
- package/dist/src/providers.js +36 -12
- package/dist/src/react-runtime.js +21 -5
- package/dist/src/read-document-tool.d.ts +2 -0
- package/dist/src/read-document-tool.js +6 -6
- package/dist/src/remote/engine-pool.js +26 -2
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/save-lock.js +14 -7
- package/dist/src/session-title.d.ts +3 -0
- package/dist/src/session-title.js +5 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +10 -3
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
- package/dist/src/skills/bundled/provenance.json +7 -2
- package/dist/src/skills/runtime-skills.js +1 -0
- package/dist/src/telemetry/uploader.d.ts +7 -1
- package/dist/src/telemetry/uploader.js +11 -2
- package/dist/src/terminal-links.d.ts +16 -0
- package/dist/src/terminal-links.js +113 -0
- package/dist/src/terminal-ui.d.ts +8 -1
- package/dist/src/terminal-ui.js +40 -14
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/trajectory.js +6 -1
- package/dist/src/transcript.d.ts +2 -0
- package/dist/src/transcript.js +2 -1
- package/dist/src/types.d.ts +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { resolveCliExecutable } from './cli-executable.js';
|
|
3
|
+
import { runBoundedCli } from './cli-process.js';
|
|
4
|
+
import { allowanceInstruction, boundTextStep, parseStructuredStep, STRUCTURED_STEP_PROMPT, STRUCTURED_STEP_SCHEMA, structuredStepPrompt, TEXT_STEP_PROMPT } from './structured-step.js';
|
|
5
|
+
export const GOOGLE_BASE_URL = 'https://antigravity.google';
|
|
6
|
+
export const GOOGLE_EXECUTABLE = {
|
|
7
|
+
names: ['agy'], overrideEnv: 'ANDORRA_AGY_PATH', homeDirectories: [join('AppData', 'Local', 'agy', 'bin'), join('.local', 'bin')],
|
|
8
|
+
installMessage: 'Install the Antigravity CLI (agy) from antigravity.google, sign in with Google, then retry the Google provider.',
|
|
9
|
+
};
|
|
10
|
+
const SIGN_IN_MESSAGE = 'Sign in with Google in the Antigravity CLI (agy) on this machine, then retry the Google provider.';
|
|
11
|
+
const REQUEST_TIMEOUT_MS = 10 * 60_000;
|
|
12
|
+
const CATALOG_TIMEOUT_MS = 30_000;
|
|
13
|
+
// Strict permissions make the CLI ask before every one of its own tools, and a headless run cannot
|
|
14
|
+
// answer, so each is denied: the CLI serves as a model and Andorra runs the tools.
|
|
15
|
+
const STEP_SETTINGS = JSON.stringify({ toolPermission: 'strict', disableSlashCommands: true, allowNonWorkspaceAccess: false });
|
|
16
|
+
export function googleEnvironment(source = process.env) {
|
|
17
|
+
const env = Object.fromEntries(Object.entries(source).filter(([key]) => !/^(?:GEMINI_API_KEY$|GOOGLE_API_KEY$|GOOGLE_GENAI_|NODE_OPTIONS$)/i.test(key)));
|
|
18
|
+
return { ...env, NO_COLOR: '1' };
|
|
19
|
+
}
|
|
20
|
+
export const runGoogleProcess = async (args, signal, options = {}) => {
|
|
21
|
+
const executable = await resolveCliExecutable(GOOGLE_EXECUTABLE);
|
|
22
|
+
return runBoundedCli(executable, () => args, signal, { env: googleEnvironment(), label: 'Antigravity CLI', ...options });
|
|
23
|
+
};
|
|
24
|
+
/** The CLI also lists models from other vendors; only Google's own are offered here. */
|
|
25
|
+
const GOOGLE_MODEL = /^gemini-[\w.-]{1,200}$/;
|
|
26
|
+
export function parseGoogleModels(output) {
|
|
27
|
+
const plain = output.replace(/\u001b\[[0-9;]*m/g, '');
|
|
28
|
+
if (/\b(?:please sign in|authentication required|not (?:authenticated|signed in|logged in))\b/i.test(plain))
|
|
29
|
+
return { signedIn: false, models: [] };
|
|
30
|
+
const models = [];
|
|
31
|
+
let listed = 0;
|
|
32
|
+
for (const line of plain.split(/\r?\n/)) {
|
|
33
|
+
const id = line.match(/^([\w.-]+)\t/)?.[1];
|
|
34
|
+
if (!id)
|
|
35
|
+
continue;
|
|
36
|
+
listed += 1;
|
|
37
|
+
if (GOOGLE_MODEL.test(id) && !models.includes(id) && models.length < 1000)
|
|
38
|
+
models.push(id);
|
|
39
|
+
}
|
|
40
|
+
return { signedIn: listed > 0, models };
|
|
41
|
+
}
|
|
42
|
+
export async function readGoogleCatalog(signal, dependencies = {}) {
|
|
43
|
+
const run = dependencies.run ?? runGoogleProcess;
|
|
44
|
+
const bounded = AbortSignal.any([signal, AbortSignal.timeout(CATALOG_TIMEOUT_MS)]);
|
|
45
|
+
const { stdout, stderr } = await run(['models'], bounded, { captureStderr: true, acceptedExitCodes: [0, 1] });
|
|
46
|
+
return parseGoogleModels(`${stdout}\n${stderr}`);
|
|
47
|
+
}
|
|
48
|
+
function frames(text) {
|
|
49
|
+
return text.split(/\r?\n/).filter(line => line.trim().startsWith('{')).map(line => {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(line);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new Error('Antigravity CLI returned malformed JSON');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function googleUsage(usage) {
|
|
59
|
+
if (!usage || typeof usage !== 'object')
|
|
60
|
+
return undefined;
|
|
61
|
+
const token = (name) => Number.isSafeInteger(usage[name]) && usage[name] >= 0 ? usage[name] : undefined;
|
|
62
|
+
const input = token('input_tokens');
|
|
63
|
+
const output = token('output_tokens');
|
|
64
|
+
const read = token('cache_read_tokens');
|
|
65
|
+
if (!input && !output && !read)
|
|
66
|
+
return { requests: 1 };
|
|
67
|
+
return { requests: 1,
|
|
68
|
+
...(input === undefined ? {} : { inputTokens: input + (read ?? 0) }),
|
|
69
|
+
...(output === undefined ? {} : { outputTokens: output }),
|
|
70
|
+
...(read === undefined ? {} : { cacheRead: read }) };
|
|
71
|
+
}
|
|
72
|
+
function failure(message) {
|
|
73
|
+
if (typeof message === 'string' && /\bauthenticat|\bsign in\b|\blog in\b/i.test(message))
|
|
74
|
+
return new Error(SIGN_IN_MESSAGE);
|
|
75
|
+
return new Error('Google inference failed. Check the Antigravity CLI sign-in, model access, and plan limits.');
|
|
76
|
+
}
|
|
77
|
+
function singleResult(output, attempted) {
|
|
78
|
+
const events = frames(output);
|
|
79
|
+
for (const event of events) {
|
|
80
|
+
const step = event?.event === 'step_update' ? event.step_update : undefined;
|
|
81
|
+
if (step && (step.step_type === 'tool' || step.tool_name !== undefined || step.tool_info !== undefined || step.subagent_info !== undefined))
|
|
82
|
+
throw new Error(attempted);
|
|
83
|
+
}
|
|
84
|
+
const results = events.filter(event => event?.event === 'result').map(event => event.result);
|
|
85
|
+
if (results.length !== 1 || !results[0] || typeof results[0] !== 'object')
|
|
86
|
+
throw new Error('Google did not return exactly one model result');
|
|
87
|
+
const result = results[0];
|
|
88
|
+
if (result.status !== 'SUCCESS')
|
|
89
|
+
throw failure(result.error);
|
|
90
|
+
if (Array.isArray(result.denied_actions) && result.denied_actions.length)
|
|
91
|
+
throw new Error(attempted);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
export function parseGoogleResponse(output, tools = []) {
|
|
95
|
+
const result = singleResult(output, 'Google attempted a native tool');
|
|
96
|
+
let structured = result.structured_output;
|
|
97
|
+
if (structured === undefined && typeof result.response === 'string') {
|
|
98
|
+
try {
|
|
99
|
+
structured = JSON.parse(result.response);
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
}
|
|
103
|
+
if (structured === undefined)
|
|
104
|
+
throw new Error('Google did not return a complete Andorra model step');
|
|
105
|
+
const response = parseStructuredStep(structured, tools, 'Google');
|
|
106
|
+
const usage = googleUsage(result.usage);
|
|
107
|
+
if (usage)
|
|
108
|
+
response.usage = usage;
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
export function parseGoogleText(output) {
|
|
112
|
+
const result = singleResult(output, 'Google attempted a tool during text generation');
|
|
113
|
+
const usage = googleUsage(result.usage);
|
|
114
|
+
return { text: typeof result.response === 'string' ? result.response.replace(/\r?\n$/, '') : '', toolCalls: [], ...(usage ? { usage } : {}) };
|
|
115
|
+
}
|
|
116
|
+
export function createGoogleAdapter(_config, dependencies = {}) {
|
|
117
|
+
const run = dependencies.run ?? runGoogleProcess;
|
|
118
|
+
return {
|
|
119
|
+
async listModels(signal) {
|
|
120
|
+
const catalog = await readGoogleCatalog(signal, dependencies);
|
|
121
|
+
if (!catalog.signedIn)
|
|
122
|
+
throw new Error(SIGN_IN_MESSAGE);
|
|
123
|
+
return catalog.models;
|
|
124
|
+
},
|
|
125
|
+
async generate(request) {
|
|
126
|
+
request.signal.throwIfAborted();
|
|
127
|
+
if (!GOOGLE_MODEL.test(request.model))
|
|
128
|
+
throw new Error('The Google provider runs Gemini models only. Choose a Gemini model.');
|
|
129
|
+
const auxiliary = request.maxTokens !== undefined;
|
|
130
|
+
if (auxiliary && (!Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1))
|
|
131
|
+
throw new Error('Invalid auxiliary output allowance.');
|
|
132
|
+
if (auxiliary && request.tools.length)
|
|
133
|
+
throw new Error('Google cannot apply an auxiliary output allowance to tool-bearing requests.');
|
|
134
|
+
const signal = AbortSignal.any([request.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
|
|
135
|
+
const imageCount = request.messages.reduce((total, message) => total + (message.images?.length ?? 0), 0);
|
|
136
|
+
// The CLI has no system-prompt override, so the model-component instructions travel in the prompt.
|
|
137
|
+
const prompt = JSON.stringify({
|
|
138
|
+
instructions: auxiliary ? `${TEXT_STEP_PROMPT} ${allowanceInstruction(request.maxTokens)}` : STRUCTURED_STEP_PROMPT,
|
|
139
|
+
...JSON.parse(structuredStepPrompt(request)),
|
|
140
|
+
...(imageCount ? { omittedImages: `This provider cannot forward images; ${imageCount} image${imageCount === 1 ? ' was' : 's were'} omitted from the conversation.` } : {})
|
|
141
|
+
});
|
|
142
|
+
request.onRequest?.();
|
|
143
|
+
const { stdout } = await run(['--input-format', 'stream-json', '--output-format', 'stream-json', '--model', request.model,
|
|
144
|
+
'--settings', STEP_SETTINGS, '--disable-slash-commands',
|
|
145
|
+
...(auxiliary ? [] : ['--json-schema', JSON.stringify(STRUCTURED_STEP_SCHEMA)])], signal, { input: `${JSON.stringify({ event: 'user', message: { content: prompt } })}\n`, acceptedExitCodes: [0, 1] });
|
|
146
|
+
signal.throwIfAborted();
|
|
147
|
+
if (!auxiliary)
|
|
148
|
+
return parseGoogleResponse(stdout, request.tools);
|
|
149
|
+
const text = parseGoogleText(stdout);
|
|
150
|
+
return boundTextStep(text, request.maxTokens, text.usage?.outputTokens);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
package/dist/src/graph-health.js
CHANGED
|
@@ -157,7 +157,7 @@ export async function checkGraphModelHealth(graph, config, signal, dependencies
|
|
|
157
157
|
// The probe of an Andorra model makes one attempt. The adapter's retry schedule (up to minutes, for a
|
|
158
158
|
// router that cannot be reached) belongs to a conversation, where each retry is shown; here it would
|
|
159
159
|
// only be a silent wait, so the first retry it announces ends the probe with that retry's reason.
|
|
160
|
-
...(provider.type === 'andorra' ? { onRetry: (retry) => { throw new Error(retry.reason); } } : {}),
|
|
160
|
+
...(provider.type === 'andorra' ? { onRetry: (retry) => { throw new Error(retry.cause && /^[A-Z][A-Z0-9_]{0,63}$/.test(retry.cause) ? `${retry.reason} (${retry.cause})` : retry.reason); } } : {}),
|
|
161
161
|
});
|
|
162
162
|
}), aborted]);
|
|
163
163
|
signal.throwIfAborted();
|
|
@@ -7,6 +7,7 @@ import { createInterface } from 'node:readline';
|
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { stopAutomationWorker } from './automation-worker-shutdown.js';
|
|
9
9
|
import { configDirectory } from './config.js';
|
|
10
|
+
import { announceGraphVisibilityChange } from './graph-visibility.js';
|
|
10
11
|
import { GRAPH_MANAGER_GRAPH_ID } from './graphs.js';
|
|
11
12
|
import { clipText } from './text.js';
|
|
12
13
|
import { describeTool } from './transcript.js';
|
|
@@ -579,7 +580,11 @@ export class GraphManagerChat {
|
|
|
579
580
|
await stopAutomationWorker(engine.child, engine.closed);
|
|
580
581
|
}
|
|
581
582
|
onEngineEvent(event, data) {
|
|
582
|
-
|
|
583
|
+
// The manager runs in its own engine process, so a change it makes to the account's graphs (project visibility
|
|
584
|
+
// included) is announced only there. Pass it on, so the engine hosting this editor tells its clients to reload.
|
|
585
|
+
if (event === 'graphs.changed')
|
|
586
|
+
announceGraphVisibilityChange();
|
|
587
|
+
else if (event === 'run.started' && typeof data.runId === 'string' && this.state === 'starting')
|
|
583
588
|
this.runId = data.runId;
|
|
584
589
|
else if (event === 'run.event')
|
|
585
590
|
this.onRunEvent(record(data.event));
|
package/dist/src/graph-sync.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class GraphSync {
|
|
|
23
23
|
private generation;
|
|
24
24
|
private deadline;
|
|
25
25
|
private readonly lastDraft;
|
|
26
|
+
private readonly stored;
|
|
26
27
|
private readonly folder;
|
|
27
28
|
constructor(directory: string, subject: string, deps?: GraphSyncDependencies);
|
|
28
29
|
start(): Promise<void>;
|
package/dist/src/graph-sync.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdir, readdir, readFile, rename, writeFile, link, unlink } from 'node:fs/promises';
|
|
2
|
+
import { mkdir, readdir, readFile, rename, stat, writeFile, link, unlink } from 'node:fs/promises';
|
|
3
3
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
4
|
import { join, relative } from 'node:path';
|
|
5
5
|
import { AUTH_REFRESH_BUDGET_MS, getAccessToken, getAuthConfiguration, getAuthStatus } from './auth/index.js';
|
|
@@ -118,6 +118,7 @@ export class GraphSync {
|
|
|
118
118
|
generation = 0;
|
|
119
119
|
deadline = 0;
|
|
120
120
|
lastDraft = new Map();
|
|
121
|
+
stored = new Map();
|
|
121
122
|
folder;
|
|
122
123
|
constructor(directory, subject, deps = defaults) {
|
|
123
124
|
this.directory = directory;
|
|
@@ -574,6 +575,7 @@ export class GraphSync {
|
|
|
574
575
|
|| (saved.file !== undefined && (typeof saved.file !== 'string' || !/^(?:\d+|[a-f0-9]{64})\.json$/.test(saved.file)))
|
|
575
576
|
|| (saved.drafts !== undefined && typeof saved.drafts !== 'boolean')
|
|
576
577
|
|| (saved.invalid !== undefined && (!Number.isSafeInteger(saved.invalid) || saved.invalid < 0))
|
|
578
|
+
|| (saved.head !== undefined && !safeId(saved.head))
|
|
577
579
|
|| (saved.refused !== undefined && (!Array.isArray(saved.refused) || saved.refused.length > 10_000
|
|
578
580
|
|| saved.refused.some((file) => typeof file !== 'string' || !REFUSED_FILE.test(file)))))
|
|
579
581
|
throw new Error('Invalid local checkpoint');
|
|
@@ -585,21 +587,36 @@ export class GraphSync {
|
|
|
585
587
|
let processed = 0, localComplete = false;
|
|
586
588
|
const refused = new Set(local.refused ?? []);
|
|
587
589
|
let confirmKept;
|
|
590
|
+
// Resolves true when the file cost a request, false when it was already stored or cannot be read.
|
|
591
|
+
// `head` marks the newest-revision pass below, whose files the history sweep also visits and counts.
|
|
588
592
|
const upload = async (path, kind, filename, options = {}) => {
|
|
589
|
-
let raw;
|
|
593
|
+
let raw, mark;
|
|
590
594
|
try {
|
|
595
|
+
// A file this process already found stored is recognized by its size and times, without opening it:
|
|
596
|
+
// every pass now visits every file, and reading them all again each time would cost far more than it saves.
|
|
597
|
+
const info = await stat(path);
|
|
598
|
+
mark = `${info.size}:${info.mtimeMs}:${info.ino}`;
|
|
599
|
+
if (!options.confirm && this.stored.get(path) === mark)
|
|
600
|
+
return false;
|
|
591
601
|
const body = await readFile(path, 'utf8');
|
|
592
|
-
if (!options.confirm && receipts[path] === digest(body))
|
|
602
|
+
if (!options.confirm && receipts[path] === digest(body)) {
|
|
603
|
+
this.stored.set(path, mark);
|
|
593
604
|
return false;
|
|
605
|
+
}
|
|
594
606
|
raw = kind === 'revision' ? envelope(kind, JSON.parse(body)) : body;
|
|
595
607
|
parseSnapshot(raw, kind === 'draft' ? filename.slice(0, -5) : digest(raw));
|
|
596
608
|
}
|
|
597
609
|
catch {
|
|
598
|
-
|
|
610
|
+
if (!options.head)
|
|
611
|
+
local.invalid = (local.invalid ?? 0) + 1;
|
|
599
612
|
return false;
|
|
600
613
|
}
|
|
601
614
|
const hash = digest(raw);
|
|
602
|
-
if (options.confirm
|
|
615
|
+
if (!options.confirm && await this.cached(hash)) {
|
|
616
|
+
this.stored.set(path, mark);
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
{
|
|
603
620
|
if (this.status === recheck)
|
|
604
621
|
this.status = { state: 'syncing', detail: 'Saving graphs to your account…' };
|
|
605
622
|
try {
|
|
@@ -614,47 +631,89 @@ export class GraphSync {
|
|
|
614
631
|
return true;
|
|
615
632
|
}
|
|
616
633
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
634
|
+
this.stored.set(path, mark);
|
|
617
635
|
return true;
|
|
618
636
|
}
|
|
619
|
-
return false;
|
|
620
637
|
};
|
|
621
638
|
const exhausted = () => processed >= 32 || this.now() >= localDeadline || this.stopped;
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
// A file that was already stored costs no request, so it does not count against the batch and its
|
|
640
|
+
// checkpoint is written once for the run of them: a sweep over an account's settled history takes
|
|
641
|
+
// one pass, not one pass per 32 files.
|
|
642
|
+
let unsaved = false;
|
|
643
|
+
const advance = async (worked) => {
|
|
644
|
+
if (!worked) {
|
|
645
|
+
unsaved = true;
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
processed++;
|
|
649
|
+
unsaved = false;
|
|
650
|
+
await atomic(localPath, JSON.stringify(local));
|
|
651
|
+
};
|
|
652
|
+
const dirs = (await entries(join(this.directory, 'graphs'))).filter(dir => dir.isDirectory() && safeId(dir.name) && !deleted.has(dir.name)).sort((a, b) => a.name < b.name ? -1 : 1);
|
|
653
|
+
const revisions = async (id) => (await entries(join(this.directory, 'graphs', id))).filter(file => file.isFile() && /^\d+\.json$/.test(file.name));
|
|
654
|
+
const newest = async (id) => (await revisions(id)).sort((a, b) => Number.parseInt(b.name, 10) - Number.parseInt(a.name, 10))[0];
|
|
655
|
+
const kept = (await readGraphQuota(this.directory).catch(() => undefined))?.freeGraphId;
|
|
656
|
+
const latest = kept && dirs.some(dir => dir.name === kept) ? await newest(kept) : undefined;
|
|
657
|
+
if (kept && latest) {
|
|
658
|
+
let confirmed = false;
|
|
659
|
+
confirmKept = async () => {
|
|
660
|
+
if (confirmed)
|
|
661
|
+
return;
|
|
662
|
+
confirmed = true;
|
|
663
|
+
await upload(join(this.directory, 'graphs', kept, latest.name), 'revision', latest.name, { pin: true, confirm: true });
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
// The newest revision of every graph goes up before the sweep resumes, the kept graph first so it
|
|
667
|
+
// takes the free pin. A graph that was just published is therefore stored by the pass its save
|
|
668
|
+
// starts, wherever the sweep's checkpoint stands; the sweep still carries the older revisions.
|
|
669
|
+
// It shares the sweep's batch and takes at most half its local time, so neither many new graphs nor
|
|
670
|
+
// a collection too large to check in one slice keeps the pass from the sweep and the account index.
|
|
671
|
+
// A scan that is cut short records the last graph it checked and the next pass carries on after it.
|
|
672
|
+
const refusedBefore = refused.size, resumedAfter = local.head;
|
|
673
|
+
const headDeadline = Math.min(localDeadline, this.now() + 2500);
|
|
674
|
+
const others = dirs.filter(dir => dir.name !== kept);
|
|
675
|
+
const rotated = resumedAfter === undefined ? others
|
|
676
|
+
: [...others.filter(dir => dir.name > resumedAfter), ...others.filter(dir => dir.name <= resumedAfter)];
|
|
677
|
+
let headsDone = true;
|
|
678
|
+
for (const dir of [...dirs.filter(dir => dir.name === kept), ...rotated]) {
|
|
679
|
+
if (processed >= 32 || this.now() >= headDeadline || this.stopped) {
|
|
680
|
+
headsDone = false;
|
|
681
|
+
break;
|
|
639
682
|
}
|
|
683
|
+
const head = dir.name === kept ? latest : await newest(dir.name);
|
|
684
|
+
if (dir.name !== kept)
|
|
685
|
+
local.head = dir.name;
|
|
686
|
+
if (!head)
|
|
687
|
+
continue;
|
|
688
|
+
const path = join(this.directory, 'graphs', dir.name, head.name);
|
|
689
|
+
if (refused.has(relative(this.directory, path).replace(/\\/g, '/')))
|
|
690
|
+
continue;
|
|
691
|
+
if (await upload(path, 'revision', head.name, { pin: dir.name === kept, head: true }))
|
|
692
|
+
processed++;
|
|
693
|
+
}
|
|
694
|
+
if (headsDone)
|
|
695
|
+
delete local.head;
|
|
696
|
+
if (refused.size > refusedBefore || local.head !== resumedAfter)
|
|
697
|
+
await atomic(localPath, JSON.stringify(local));
|
|
698
|
+
if (!local.drafts) {
|
|
640
699
|
outer: for (const dir of dirs) {
|
|
641
700
|
if (local.directory && dir.name < local.directory)
|
|
642
701
|
continue;
|
|
643
|
-
const files = (await
|
|
702
|
+
const files = (await revisions(dir.name)).sort((a, b) => a.name < b.name ? -1 : 1);
|
|
644
703
|
for (const file of files) {
|
|
645
704
|
if (dir.name === local.directory && local.file && file.name <= local.file)
|
|
646
705
|
continue;
|
|
647
706
|
if (exhausted())
|
|
648
707
|
break outer;
|
|
649
|
-
await upload(join(this.directory, 'graphs', dir.name, file.name), 'revision', file.name, { pin: dir.name === kept });
|
|
708
|
+
const worked = await upload(join(this.directory, 'graphs', dir.name, file.name), 'revision', file.name, { pin: dir.name === kept });
|
|
650
709
|
local.directory = dir.name;
|
|
651
710
|
local.file = file.name;
|
|
652
|
-
|
|
653
|
-
await atomic(localPath, JSON.stringify(local));
|
|
711
|
+
await advance(worked);
|
|
654
712
|
}
|
|
655
713
|
}
|
|
656
714
|
if (!exhausted()) {
|
|
657
|
-
local = { drafts: true, invalid: local.invalid, ...(refused.size ? { refused: [...refused] } : {}) };
|
|
715
|
+
local = { drafts: true, invalid: local.invalid, ...(refused.size ? { refused: [...refused] } : {}), ...(local.head ? { head: local.head } : {}) };
|
|
716
|
+
unsaved = false;
|
|
658
717
|
await atomic(localPath, JSON.stringify(local));
|
|
659
718
|
}
|
|
660
719
|
}
|
|
@@ -674,22 +733,22 @@ export class GraphSync {
|
|
|
674
733
|
if (deleted.has(parseSnapshot(raw, file.name.slice(0, -5)).graphId)) {
|
|
675
734
|
await unlink(join(this.directory, 'graph-drafts', file.name)).catch(() => { });
|
|
676
735
|
local.file = file.name;
|
|
677
|
-
|
|
678
|
-
await atomic(localPath, JSON.stringify(local));
|
|
736
|
+
await advance(true);
|
|
679
737
|
continue;
|
|
680
738
|
}
|
|
681
739
|
}
|
|
682
740
|
catch { }
|
|
683
741
|
}
|
|
684
|
-
await upload(join(this.directory, 'graph-drafts', file.name), 'draft', file.name);
|
|
742
|
+
const worked = await upload(join(this.directory, 'graph-drafts', file.name), 'draft', file.name);
|
|
685
743
|
local.file = file.name;
|
|
686
|
-
|
|
687
|
-
await atomic(localPath, JSON.stringify(local));
|
|
744
|
+
await advance(worked);
|
|
688
745
|
}
|
|
689
746
|
}
|
|
747
|
+
if (unsaved && !localComplete)
|
|
748
|
+
await atomic(localPath, JSON.stringify(local));
|
|
690
749
|
const invalidLocalFiles = local.invalid ?? 0;
|
|
691
750
|
if (localComplete)
|
|
692
|
-
await atomic(localPath,
|
|
751
|
+
await atomic(localPath, JSON.stringify(local.head ? { head: local.head } : {}));
|
|
693
752
|
const progressPath = join(this.folder, 'index-progress.json');
|
|
694
753
|
let progress = {};
|
|
695
754
|
try {
|
package/dist/src/graph-tool.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Tool } from './types.js';
|
|
|
2
2
|
export interface GraphBackend {
|
|
3
3
|
call(name: string, args: unknown, options?: {
|
|
4
4
|
beforeSave?: () => void;
|
|
5
|
+
workspace?: string;
|
|
5
6
|
}): Promise<{
|
|
6
7
|
ok: true;
|
|
7
8
|
data: unknown;
|
|
@@ -20,6 +21,7 @@ export declare class GraphBackendPool {
|
|
|
20
21
|
});
|
|
21
22
|
call(directory: string, action: string, args: unknown, options?: {
|
|
22
23
|
beforeSave?: () => void;
|
|
24
|
+
workspace?: string;
|
|
23
25
|
}): Promise<{
|
|
24
26
|
ok: true;
|
|
25
27
|
data: unknown;
|
package/dist/src/graph-tool.js
CHANGED
|
@@ -61,7 +61,7 @@ function actionSummary() {
|
|
|
61
61
|
export function createGraphTool(pool = sharedPool) {
|
|
62
62
|
return {
|
|
63
63
|
name: 'graphs', capability: 'external', executionMode: 'sequential',
|
|
64
|
-
description: 'Create, edit, validate, publish, delete or restore Andorra graphs (multi-agent workflows) in the signed-in account\'s graph store, the same store the Graph Builder and graph picker use. Never write graph files on disk. '
|
|
64
|
+
description: 'Create, edit, validate, publish, delete or restore Andorra graphs, and choose which projects list them, (multi-agent workflows) in the signed-in account\'s graph store, the same store the Graph Builder and graph picker use. Never write graph files on disk. '
|
|
65
65
|
+ 'Call action andorra_graph_guide first for node types, ports, limits and error codes; load the skill andorra:graph-manager to design a graph with the user. '
|
|
66
66
|
+ 'Put the action\'s arguments in args. Drafts are kept in this Andorra process for up to an hour; publish saves a revision and syncs it to the account. Publish, delete and restore ask the user for permission, except under Full Access, which approves them without a prompt; never tell the user a prompt is coming when the task runs in Full Access. '
|
|
67
67
|
+ `Actions and their args (* required): ${actionSummary()}.`,
|
|
@@ -93,7 +93,7 @@ export function createGraphTool(pool = sharedPool) {
|
|
|
93
93
|
throw error;
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const reply = await pool.call(context.automationDirectory ?? configDirectory(), action, input, { beforeSave });
|
|
96
|
+
const reply = await pool.call(context.automationDirectory ?? configDirectory(), action, input, { beforeSave, workspace: context.workspace });
|
|
97
97
|
if (refused !== undefined)
|
|
98
98
|
throw refused;
|
|
99
99
|
let text = JSON.stringify(reply);
|
package/dist/src/graph-ui/app.js
CHANGED
|
@@ -252,7 +252,7 @@ function outcomes(node) {
|
|
|
252
252
|
function edgeOutcome(edge) { return edge.outcome || 'completed'; }
|
|
253
253
|
function pruneRoutes(node) { state.graph.edges = state.graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge))); }
|
|
254
254
|
function selectedNodes() { return (state.selectedIds.length ? state.selectedIds : state.selected ? [state.selected] : []).map(id => state.graph?.nodes[id]).filter(Boolean); }
|
|
255
|
-
function selectionType(node) { return
|
|
255
|
+
function selectionType(node) { return node.type; }
|
|
256
256
|
function clearSelection() { state.selectedIds = []; state.selected = null; state.selectedEdge = null; state.routePick = null; state.bulkOutcome = null; }
|
|
257
257
|
function showInspector() { $('inspector').classList.remove('hidden'); $('toggle-inspector').setAttribute('aria-expanded','true'); }
|
|
258
258
|
function selectNode(node, event = {}) {
|
|
@@ -281,10 +281,65 @@ function routeSelectionTo(targetId) {
|
|
|
281
281
|
},true);
|
|
282
282
|
status(`Routed ${sources.length} steps to ${target.name}. Existing matching connections were kept; set the inputs of new ones below.`);
|
|
283
283
|
}
|
|
284
|
+
const MIXED = 'Mixed';
|
|
285
|
+
// What every selected step has for one setting, or `mixed` when they differ.
|
|
286
|
+
function sharedValue(nodes, read) {
|
|
287
|
+
const first = read(nodes[0]), key = JSON.stringify(first ?? null);
|
|
288
|
+
return nodes.every(node => JSON.stringify(read(node) ?? null) === key) ? { value: first, mixed: false } : { value: undefined, mixed: true };
|
|
289
|
+
}
|
|
290
|
+
function bulkChoice(parent, label, nodes, read, values, write) {
|
|
291
|
+
const { value, mixed } = sharedValue(nodes, read);
|
|
292
|
+
const options = values.map(item => typeof item === 'string' ? { value: item, label: item.replaceAll('-', ' ') } : item);
|
|
293
|
+
const input = field(parent, label, mixed ? '' : value, chosen => { if (chosen !== '') for (const node of nodes) write(node, chosen); }, { options: mixed ? [{ value: '', label: MIXED }, ...options] : options, refresh: true });
|
|
294
|
+
if (mixed) input.children[0].disabled = true;
|
|
295
|
+
return input;
|
|
296
|
+
}
|
|
297
|
+
function bulkCheck(parent, label, nodes, read, write) {
|
|
298
|
+
const { value, mixed } = sharedValue(nodes, node => !!read(node));
|
|
299
|
+
const input = check(parent, label, !mixed && value, checked => { for (const node of nodes) write(node, checked); });
|
|
300
|
+
if (mixed) { input.indeterminate = true; input.setAttribute('aria-checked', 'mixed'); }
|
|
301
|
+
return input;
|
|
302
|
+
}
|
|
303
|
+
function bulkNumber(parent, label, nodes, read, write, options = {}) {
|
|
304
|
+
const { value, mixed } = sharedValue(nodes, read);
|
|
305
|
+
const input = field(parent, label, mixed ? '' : value, next => { for (const node of nodes) write(node, next); }, { type: 'number', refresh: true, ...options, placeholder: mixed ? MIXED : options.placeholder });
|
|
306
|
+
const commit = input.onchange;
|
|
307
|
+
// A blank box leaves the steps as they are while they differ, and is not a number where one is required.
|
|
308
|
+
input.onchange = () => { if (input.value.trim() === '' && (mixed || !options.optional)) { renderInspector(); return; } commit(); };
|
|
309
|
+
return input;
|
|
310
|
+
}
|
|
311
|
+
function renderBulkSettings(panels, nodes) {
|
|
312
|
+
explain(bulkCheck(panels.general, 'Jev decisions', nodes, node => node.jevEnabled === true, (node, on) => { if (on) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists each selected agent with routing decisions. A dash means some of the selected steps have it on; ticking turns it on for all of them.');
|
|
313
|
+
const models = sharedValue(nodes, node => [node.provider ?? null, node.model ?? null]);
|
|
314
|
+
modelFields(panels.model, models.mixed ? {} : { provider: nodes[0].provider, model: nodes[0].model }, value => { for (const node of nodes) { node.provider = value.provider; node.model = value.model; } }, undefined, undefined, undefined, { mixed: models.mixed });
|
|
315
|
+
bulkChoice(panels.model, 'Conversation', nodes, node => node.contextPolicy?.conversation ?? 'reuse', [{value:'reuse',label:'Reuse with the same provider and model'}, {value:'isolate',label:'Start an isolated conversation'}], (node, value) => { node.contextPolicy = { ...node.contextPolicy, conversation: value }; });
|
|
316
|
+
bulkChoice(panels.model, 'Skill inheritance', nodes, node => node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active graph skills'}, {value:'none',label:'Do not inherit skills'}], (node, value) => { node.contextPolicy = { ...node.contextPolicy, skillInheritance: value }; });
|
|
317
|
+
const advanced = panels.advanced;
|
|
318
|
+
const caps = disclosure(advanced, 'Permissions');
|
|
319
|
+
for (const [key, values] of Object.entries(CAPABILITIES)) bulkChoice(caps, key.charAt(0).toUpperCase() + key.slice(1), nodes, node => node.capabilities?.[key] || effectiveCaps()[key], values, (node, value) => { node.capabilities = { ...effectiveCaps(), ...node.capabilities, [key]: value }; });
|
|
320
|
+
const context = disclosure(advanced, 'Context sharing');
|
|
321
|
+
bulkCheck(context, 'Include previous task summaries', nodes, node => node.contextPolicy?.history ?? false, (node, value) => { node.contextPolicy = { ...node.contextPolicy, history: value }; });
|
|
322
|
+
bulkChoice(context, 'Visible predecessor state', nodes, node => node.contextPolicy?.predecessors || 'none', ['none', 'direct', 'all'], (node, value) => { node.contextPolicy = { ...node.contextPolicy, predecessors: value }; });
|
|
323
|
+
bulkNumber(context, 'Maximum context characters', nodes, node => node.contextPolicy?.maxChars ?? 32000, (node, value) => { node.contextPolicy = { ...node.contextPolicy, maxChars: value }; }, { min: 1 });
|
|
324
|
+
const limits = disclosure(advanced, 'Execution limits');
|
|
325
|
+
for (const [key, label, defaultValue] of [['maxContextChars', 'Context characters', 120000], ['maxCompletionRepairs', 'Completion repair tries', 2]]) bulkNumber(limits, label, nodes, node => node.limits?.[key] ?? defaultValue, (node, value) => { node.limits = { ...node.limits, [key]: value }; delete node.limits.maxTokens; }, { min: key === 'maxCompletionRepairs' ? 0 : 1 });
|
|
326
|
+
bulkNumber(limits, 'Iterations (blank = unlimited)', nodes, node => node.limits?.maxIterations ?? node.maxIterations, (node, value) => { node.limits = { ...node.limits, maxIterations: value }; delete node.limits.maxTokens; if (value === undefined) { delete node.limits.maxIterations; delete node.maxIterations; } else node.maxIterations = value; }, { min: 0, max: 1000, optional: true, placeholder: 'Unlimited' });
|
|
327
|
+
bulkNumber(limits, 'Wall time, seconds (blank = unlimited)', nodes, node => msToSeconds(node.limits?.wallTimeMs), (node, value) => { node.limits = { ...node.limits, wallTimeMs: secondsToMs(value) }; delete node.limits.maxTokens; if (value === undefined) delete node.limits.wallTimeMs; }, { min: 0, step: 'any', optional: true, placeholder: 'Unlimited' });
|
|
328
|
+
bulkNumber(limits, 'Tool calls (blank = unlimited)', nodes, node => node.limits?.maxToolCalls, (node, value) => { node.limits = { ...node.limits, maxToolCalls: value }; if (value === undefined) delete node.limits.maxToolCalls; }, { min: 0, optional: true, placeholder: 'Unlimited' });
|
|
329
|
+
bulkNumber(advanced, 'Retries', nodes, node => node.retry?.maxAttempts ?? 1, (node, value) => { node.retry = { ...node.retry, maxAttempts: value }; }, { min: 1 });
|
|
330
|
+
const tools = disclosure(advanced, 'Tool allowlist'), all = () => state.tools.map(tool => typeof tool === 'string' ? tool : tool.name || tool.id);
|
|
331
|
+
for (const name of [...new Set([...all(), ...nodes.flatMap(node => node.tools || [])])]) bulkCheck(tools, name, nodes, node => node.tools === undefined || node.tools.includes(name), (node, enabled) => { node.tools = enabled ? [...new Set([...(node.tools ?? all()), name])] : (node.tools ?? all()).filter(tool => tool !== name); });
|
|
332
|
+
}
|
|
284
333
|
function renderBulkInspector(parent, nodes) {
|
|
285
334
|
$('inspector-title').textContent = `${nodes.length} steps selected`;
|
|
286
335
|
parent.append(el('p',nodes.map(node=>node.name).join(', '),'help'));
|
|
287
|
-
|
|
336
|
+
let routing = parent;
|
|
337
|
+
if (nodes.every(node => node.type === 'agent')) {
|
|
338
|
+
parent.append(el('p', `Changes here apply to all ${nodes.length} selected steps. ${MIXED} marks a setting the steps do not share yet; names, prompts and outcomes stay per step.`, 'help'));
|
|
339
|
+
const panels = inspectorTabs(parent, ['general', 'model', 'behavior', 'advanced']);
|
|
340
|
+
renderBulkSettings(panels, nodes); routing = panels.behavior;
|
|
341
|
+
}
|
|
342
|
+
const group = section(routing,'Output step');
|
|
288
343
|
const shared = outcomes(nodes[0]).filter(outcome => nodes.every(node => outcomes(node).includes(outcome)));
|
|
289
344
|
if (!shared.length) {group.append(el('p','These steps have no shared outcome. Give them a matching completion outcome before routing together.','help'));return;}
|
|
290
345
|
if (!shared.includes(state.bulkOutcome)) state.bulkOutcome=shared[0];
|
|
@@ -848,14 +903,17 @@ function renderEdges() {
|
|
|
848
903
|
for(const [name,value] of Object.entries({'text-anchor':'middle',fill:palette.pillInk}))text.setAttribute(name,value);
|
|
849
904
|
text.textContent=outcome;group.append(rect,text);pillLayer.append(group);
|
|
850
905
|
const pill={rect,text,width:Math.max(28,Math.round(outcome.length*6.6+16))};
|
|
851
|
-
entry.pill=group;drawnEdges[index].pill=pill;drawnPills.push({pill,at});
|
|
906
|
+
entry.pill=group;drawnEdges[index].pill=pill;drawnPills.push({pill,at,index});
|
|
852
907
|
}
|
|
853
908
|
$('edges').append(pillLayer,caption);
|
|
854
|
-
|
|
909
|
+
const pillWidths=[];
|
|
910
|
+
for(const {pill,index} of drawnPills){
|
|
855
911
|
const measured=typeof pill.text.getComputedTextLength==='function'?pill.text.getComputedTextLength():0;
|
|
856
912
|
if(measured>0)pill.width=Math.max(28,Math.ceil(measured+16));
|
|
857
|
-
pill.rect.setAttribute('width',String(pill.width));
|
|
913
|
+
pill.rect.setAttribute('width',String(pill.width));pillWidths[index]=pill.width;
|
|
858
914
|
}
|
|
915
|
+
const pillSpots=AndorraEdgeRouter.placeLabels?.(routedPoints,pillWidths,PILL_HEIGHT,rectangles);
|
|
916
|
+
for(const {pill,at,index} of drawnPills)placePill(pill,pillSpots?.[index]||at);
|
|
859
917
|
emphasize(state.selectedEdge);
|
|
860
918
|
}
|
|
861
919
|
function removeNodes(ids) {
|
|
@@ -1131,6 +1189,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1131
1189
|
const pickerButton = modelPickerButton({
|
|
1132
1190
|
ariaLabel: 'Model',
|
|
1133
1191
|
current: () => {
|
|
1192
|
+
if (options.mixed) return { model: MIXED, provider: '', entry: undefined };
|
|
1134
1193
|
const pinned = target.model?.trim();
|
|
1135
1194
|
const entry = entryFor(effectiveProvider);
|
|
1136
1195
|
if (!pinned && !target.provider && options.defaultLabel) return { model: options.defaultLabel, provider: '', entry: undefined };
|
|
@@ -1147,7 +1206,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1147
1206
|
});
|
|
1148
1207
|
},
|
|
1149
1208
|
selected: () => target.model?.trim() ? { provider: effectiveProvider, model: target.model.trim() } : null,
|
|
1150
|
-
defaultRow: () => options.noDefault ? undefined : ({ label: defaultLabel, hint: defaultHint, selected: !target.provider && !target.model?.trim() }),
|
|
1209
|
+
defaultRow: () => options.noDefault ? undefined : ({ label: defaultLabel, hint: defaultHint, selected: !options.mixed && !target.provider && !target.model?.trim() }),
|
|
1151
1210
|
pickDefault: () => mutate(() => update({ ...target, provider: undefined, model: undefined }), true),
|
|
1152
1211
|
pick: ({ provider: chosenProvider, model: chosenModel }) => {
|
|
1153
1212
|
if (chosenProvider === effectiveProvider && !(options.requireProvider && !target.provider)) { model.value = chosenModel; model.onchange(); return; }
|
|
@@ -1217,13 +1276,13 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1217
1276
|
parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
|
|
1218
1277
|
}
|
|
1219
1278
|
}
|
|
1220
|
-
const info = el('p', 'Context window: detecting from model…', 'help model-context'); parent.append(info);
|
|
1279
|
+
const info = el('p', options.mixed ? 'The selected steps use different models. Choosing one applies it to all of them.' : 'Context window: detecting from model…', 'help model-context'); parent.append(info);
|
|
1221
1280
|
const key = JSON.stringify([target.provider || '', target.model || '', provider?.model || '']);
|
|
1222
1281
|
const registryGeneration = state.providerRegistryGeneration || 0;
|
|
1223
1282
|
state.modelContextRequests ||= new Map();
|
|
1224
1283
|
if (!state.modelContextRequests.has(key)) state.modelContextRequests.set(key, api(`/api/model-context?provider=${encodeURIComponent(target.provider || '')}&model=${encodeURIComponent(target.model || '')}`).catch(() => ({contextWindow:null})));
|
|
1225
1284
|
state.modelContextRequests.get(key).then(data => {
|
|
1226
|
-
if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
|
|
1285
|
+
if (options.mixed || (state.providerRegistryGeneration || 0) !== registryGeneration) return;
|
|
1227
1286
|
info.textContent = data.contextWindow ? `Context window: ${data.contextWindow.toLocaleString()} tokens (automatic)` : 'Context window: not reported by this model. Runtime uses its default budget.';
|
|
1228
1287
|
});
|
|
1229
1288
|
const override = disclosure(parent, 'Custom model name');
|