@andorra-labs/code 0.1.14 → 0.1.16
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-definitions.js +29 -6
- package/dist/src/agent-execution.js +8 -2
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +3 -1
- package/dist/src/agent-mcp.js +97 -11
- 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 +9 -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 +115 -0
- package/dist/src/app-server.js +980 -63
- package/dist/src/auth/AuthManager.js +4 -4
- package/dist/src/auth/deployment.js +2 -2
- 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-runner.js +1 -0
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +27 -16
- 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 +13 -9
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +184 -40
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +9 -2
- package/dist/src/command-screens.js +166 -97
- package/dist/src/commands.d.ts +3 -2
- package/dist/src/commands.js +1 -0
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -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/context-compaction.js +2 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +23 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.js +8 -4
- package/dist/src/graph-manager-chat.js +6 -1
- package/dist/src/graph-provider-portability.js +32 -10
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +24 -7
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +9 -7
- 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 +177 -41
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +11 -4
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +27 -19
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/graphs.js +4 -3
- 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 +23 -1
- package/dist/src/membership.js +48 -6
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +1 -1
- package/dist/src/model-metadata.js +12 -3
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/provider-connection.js +17 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +6 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.js +14 -2
- package/dist/src/providers.d.ts +33 -2
- package/dist/src/providers.js +101 -28
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +76 -0
- package/dist/src/pull-request-logs.js +172 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +43 -2
- package/dist/src/pull-requests.js +112 -21
- package/dist/src/react-runtime.js +58 -9
- 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 +42 -6
- package/dist/src/run-control.d.ts +10 -0
- package/dist/src/run-control.js +24 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +2 -2
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +14 -2
- 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/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +2 -0
- package/dist/src/telemetry/emitter.js +42 -5
- package/dist/src/telemetry/schema.d.ts +22 -0
- package/dist/src/telemetry/schema.js +68 -1
- package/dist/src/telemetry/surface.d.ts +1 -0
- package/dist/src/telemetry/uploader.d.ts +12 -1
- package/dist/src/telemetry/uploader.js +30 -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 +10 -3
- package/dist/src/types.d.ts +9 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeCommand } from './commands.js';
|
|
2
|
+
import { WORKING_SPINNER_FRAMES, WORKING_SPINNER_TICK_MS } from './session-title.js';
|
|
2
3
|
import { PERMISSION_OPTIONS } from './permissions.js';
|
|
3
4
|
import { editProviderSettings } from './provider-settings.js';
|
|
4
5
|
import { retireRemovedCodexAccounts, retireUnsavedCodexAccounts } from './codex-auth.js';
|
|
@@ -8,7 +9,7 @@ import { DEFAULT_GRAPH, listGraphs, withoutDeletedGraphs } from './graphs.js';
|
|
|
8
9
|
import { graphStorageDirectory } from './graph-account.js';
|
|
9
10
|
import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
|
|
10
11
|
import { getMembership, loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
11
|
-
import {
|
|
12
|
+
import { FREE_GRAPH_LIMIT_MESSAGE, freeTierGraphViolation, readGraphQuota } from './graph-quota.js';
|
|
12
13
|
import { GraphProviderUnavailableError } from './graph-provider-portability.js';
|
|
13
14
|
import { confirmAndApplyModelOverride } from './model-override.js';
|
|
14
15
|
import { andorraRefusal } from './commands.js';
|
|
@@ -24,6 +25,21 @@ export function pickPermissionMode(state, ui, signal, options = {}) {
|
|
|
24
25
|
const current = state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval');
|
|
25
26
|
return ui.select('Update Model Permissions', PERMISSION_OPTIONS.map((option, index) => ({ id: option.id, label: `${index + 1}. ${option.label}${option.id === current ? ' (current)' : ''}`, description: option.description })), { selectedId: current, description: 'Remembered for this workspace. Restricted commands require the Codex CLI OS sandbox.', signal, ...options });
|
|
26
27
|
}
|
|
28
|
+
/** The config with `model` on `providerId` as the selected pair: what choosing it in /model saves. */
|
|
29
|
+
export function withSelectedModel(config, providerId, model) {
|
|
30
|
+
const draft = structuredClone(config);
|
|
31
|
+
const next = draft.providers.find(item => item.id === providerId);
|
|
32
|
+
if (!next)
|
|
33
|
+
throw new Error(`Unknown provider: ${providerId}`);
|
|
34
|
+
draft.provider = providerId;
|
|
35
|
+
recordProviderModel(next, model);
|
|
36
|
+
if (next.model !== model) {
|
|
37
|
+
next.model = model;
|
|
38
|
+
applyModelContextWindow(next, model);
|
|
39
|
+
delete next.reasoningEffort;
|
|
40
|
+
}
|
|
41
|
+
return draft;
|
|
42
|
+
}
|
|
27
43
|
export function isScreenCommand(line) {
|
|
28
44
|
return ['/model', '/providers', '/graph', '/usage', '/permissions', '/skills', '/plugins', '/mcp', '/subagent'].includes(line.trim());
|
|
29
45
|
}
|
|
@@ -203,16 +219,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
203
219
|
}
|
|
204
220
|
if (target.id === state.config.provider && selected === target.model)
|
|
205
221
|
return overrideApplied ? { clear: true } : unchanged;
|
|
206
|
-
|
|
207
|
-
draft.provider = target.id;
|
|
208
|
-
const next = draft.providers.find(item => item.id === target.id);
|
|
209
|
-
recordProviderModel(next, selected);
|
|
210
|
-
if (next.model !== selected) {
|
|
211
|
-
next.model = selected;
|
|
212
|
-
applyModelContextWindow(next, selected);
|
|
213
|
-
delete next.reasoningEffort;
|
|
214
|
-
}
|
|
215
|
-
return await save(draft);
|
|
222
|
+
return await save(withSelectedModel(state.config, target.id, selected));
|
|
216
223
|
}
|
|
217
224
|
if (command === '/providers') {
|
|
218
225
|
if (!await waitForAndorraCheck(state, ui, signal))
|
|
@@ -310,12 +317,14 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
310
317
|
return unchanged;
|
|
311
318
|
const access = await graphAccess.membership?.(signal);
|
|
312
319
|
const free = access !== undefined && !access.paid && !access.unavailable && access.subject !== undefined;
|
|
313
|
-
const
|
|
320
|
+
const kept = free ? (await readGraphQuota(directory, saved, { adopt: true })).freeGraphId : undefined;
|
|
321
|
+
const atLimit = free && kept !== undefined;
|
|
322
|
+
const viewOnly = (graph) => free && (graph.id !== kept || freeTierGraphViolation(graph) !== undefined);
|
|
314
323
|
const items = [{
|
|
315
324
|
id: DEFAULT_GRAPH.id,
|
|
316
325
|
label: 'Default',
|
|
317
326
|
description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
|
|
318
|
-
}, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
|
|
327
|
+
}, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: viewOnly(graph) ? 'View only on the free tier. Duplicate it in the Graph Editor to change it.' : 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
|
|
319
328
|
while (!signal.aborted) {
|
|
320
329
|
const selected = await ui.select('Graph', items, { selectedId: state.graph ?? DEFAULT_GRAPH.id, description: 'Choose and save your default graph for this account, or create one in the web builder. After saving, reopen /graph to select it.', signal });
|
|
321
330
|
if (selected === undefined || signal.aborted)
|
|
@@ -587,6 +596,18 @@ async function runExtensionScreen(command, state, ui, save, signal) {
|
|
|
587
596
|
}
|
|
588
597
|
export const MODEL_TREE_EXPAND = ':expand:';
|
|
589
598
|
export const MODEL_TREE_COLLAPSE = ':collapse:';
|
|
599
|
+
/** How long a /model provider loads before its loading row and spinner are drawn, so a quick answer never flashes one. */
|
|
600
|
+
const MODEL_LOADING_GRACE_MS = 150;
|
|
601
|
+
/**
|
|
602
|
+
* Lets an answer already in hand (a stub, a cache) land before the tree is drawn again, waiting on microtasks only:
|
|
603
|
+
* no key or terminal event can be handled meanwhile, so nothing typed is lost while no screen is open.
|
|
604
|
+
*/
|
|
605
|
+
async function settleWithoutYielding(job) {
|
|
606
|
+
let settled = false;
|
|
607
|
+
void job.then(() => { settled = true; });
|
|
608
|
+
for (let turn = 0; turn < 32 && !settled; turn++)
|
|
609
|
+
await Promise.resolve();
|
|
610
|
+
}
|
|
590
611
|
export const modelTreeId = (row) => JSON.stringify(row.model === undefined ? [row.provider] : [row.provider, row.model]);
|
|
591
612
|
function parseModelTreeId(id) {
|
|
592
613
|
try {
|
|
@@ -639,7 +660,7 @@ export function andorraRefresh(state, rows) {
|
|
|
639
660
|
* at once and the check runs in the background. False when the screen was cancelled (Esc on the loading screen
|
|
640
661
|
* or the screen's signal aborted).
|
|
641
662
|
*/
|
|
642
|
-
async function waitForAndorraCheck(state, ui, signal) {
|
|
663
|
+
async function waitForAndorraCheck(state, ui, signal, yields = {}) {
|
|
643
664
|
const andorra = state.andorra;
|
|
644
665
|
if (!andorra)
|
|
645
666
|
return true;
|
|
@@ -653,16 +674,19 @@ async function waitForAndorraCheck(state, ui, signal) {
|
|
|
653
674
|
return finish();
|
|
654
675
|
loadSignal.addEventListener('abort', finish, { once: true });
|
|
655
676
|
andorra.opened().catch(() => { }).then(() => { loadSignal.removeEventListener('abort', finish); finish(); });
|
|
656
|
-
}), { description: 'Checking Andorra availability', signal });
|
|
677
|
+
}), { description: 'Checking Andorra availability', signal, ...yields });
|
|
657
678
|
return done === true && !signal.aborted;
|
|
658
679
|
}
|
|
659
680
|
/**
|
|
660
681
|
* The /model screen: every configured provider as a collapsed row ending in `>`, with its models
|
|
661
682
|
* indented beneath once expanded (Right Arrow or Enter expands, Left Arrow collapses). A provider's
|
|
662
|
-
* models load the first time it opens; when discovery fails its
|
|
683
|
+
* models load the first time it opens, behind a loading row in the open tree; when discovery fails its
|
|
684
|
+
* configured models are shown instead.
|
|
663
685
|
*/
|
|
664
|
-
export async function pickProviderModel(state, ui, adapterFactory, signal) {
|
|
665
|
-
|
|
686
|
+
export async function pickProviderModel(state, ui, adapterFactory, signal, options = {}) {
|
|
687
|
+
// Opened while a run is working, the tree closes when the run asks a question (an approval, a clarification).
|
|
688
|
+
const yields = options.yieldToQuestions ? { yieldToQuestions: true } : {};
|
|
689
|
+
if (!await waitForAndorraCheck(state, ui, signal, yields))
|
|
666
690
|
return undefined;
|
|
667
691
|
// A listed, not yet saved Andorra is shown first, like a saved provider. Its models come from the hosted answer:
|
|
668
692
|
// no request is ever sent on its behalf before the user picks it.
|
|
@@ -674,36 +698,50 @@ export async function pickProviderModel(state, ui, adapterFactory, signal) {
|
|
|
674
698
|
const expanded = new Set();
|
|
675
699
|
const loaded = new Map();
|
|
676
700
|
let cursor = active ? modelTreeId({ provider: active.id }) : undefined;
|
|
677
|
-
|
|
701
|
+
// Discovery runs behind the open tree: the expanded provider shows a loading row where its first model will be,
|
|
702
|
+
// and the rows are redrawn in place when the answer lands. Closing the picker abandons every load still running.
|
|
703
|
+
const loads = new AbortController();
|
|
704
|
+
const abandon = () => loads.abort();
|
|
705
|
+
signal.addEventListener('abort', abandon, { once: true });
|
|
706
|
+
const pending = new Map();
|
|
707
|
+
const pendingSince = new Map();
|
|
708
|
+
let frame = 0;
|
|
709
|
+
let redrawOpen;
|
|
710
|
+
const load = (provider) => {
|
|
678
711
|
if (loaded.has(provider.id))
|
|
679
|
-
return
|
|
712
|
+
return undefined;
|
|
680
713
|
if (provider === listed) {
|
|
681
714
|
loaded.set(provider.id, { models: providerModels(provider), configured: new Set() });
|
|
682
|
-
return
|
|
715
|
+
return undefined;
|
|
683
716
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
717
|
+
const running = pending.get(provider.id);
|
|
718
|
+
if (running)
|
|
719
|
+
return running;
|
|
720
|
+
const job = (async () => {
|
|
721
|
+
let discovered = [];
|
|
722
|
+
let note;
|
|
723
|
+
try {
|
|
688
724
|
const adapter = adapterFactory(provider);
|
|
689
725
|
if (!adapter.listModels)
|
|
690
726
|
throw new Error('Model discovery unavailable');
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
727
|
+
const models = await adapter.listModels(loads.signal);
|
|
728
|
+
discovered = [...new Set(models)].filter(id => typeof id === 'string' && id.trim().length > 0);
|
|
729
|
+
if (!discovered.length)
|
|
730
|
+
note = 'The provider returned no models.';
|
|
731
|
+
}
|
|
732
|
+
catch {
|
|
733
|
+
if (loads.signal.aborted)
|
|
734
|
+
return;
|
|
735
|
+
note = 'Could not load models; check the endpoint and credentials in /providers. Showing configured models.';
|
|
736
|
+
}
|
|
737
|
+
if (loads.signal.aborted)
|
|
738
|
+
return;
|
|
739
|
+
const configured = providerModels(provider).filter(id => !discovered.includes(id));
|
|
740
|
+
loaded.set(provider.id, { models: [...discovered, ...configured], configured: new Set(configured), ...(note ? { note } : {}) });
|
|
741
|
+
})().finally(() => { pending.delete(provider.id); pendingSince.delete(provider.id); redrawOpen?.(); });
|
|
742
|
+
pending.set(provider.id, job);
|
|
743
|
+
pendingSince.set(provider.id, Date.now());
|
|
744
|
+
return job;
|
|
707
745
|
};
|
|
708
746
|
const rows = () => {
|
|
709
747
|
// Rebuilt each time the tree is drawn, and in place when a check answers while it is open.
|
|
@@ -726,6 +764,13 @@ export async function pickProviderModel(state, ui, adapterFactory, signal) {
|
|
|
726
764
|
...(refusal ? { description: refusal } : open && entry?.note ? { description: entry.note } : {}),
|
|
727
765
|
...(isActive ? { bold: true } : {}),
|
|
728
766
|
});
|
|
767
|
+
if (open && !entry && pending.has(provider.id)) {
|
|
768
|
+
// Takes the place of the first model once the load has run past the grace period (the spinner's ticks
|
|
769
|
+
// redraw it in); picking it does nothing, like the empty-list row.
|
|
770
|
+
if (Date.now() - (pendingSince.get(provider.id) ?? 0) >= MODEL_LOADING_GRACE_MS)
|
|
771
|
+
items.push({ id: modelTreeId({ provider: provider.id, model: '' }), label: ` ${WORKING_SPINNER_FRAMES[frame % WORKING_SPINNER_FRAMES.length]} Loading models…` });
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
729
774
|
if (!open || !entry)
|
|
730
775
|
continue;
|
|
731
776
|
if (!entry.models.length)
|
|
@@ -735,70 +780,94 @@ export async function pickProviderModel(state, ui, adapterFactory, signal) {
|
|
|
735
780
|
}
|
|
736
781
|
return items;
|
|
737
782
|
};
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
783
|
+
try {
|
|
784
|
+
while (!signal.aborted) {
|
|
785
|
+
const choice = await ui.select('Models', rows(), {
|
|
786
|
+
...(cursor ? { selectedId: cursor } : {}),
|
|
787
|
+
checkedId: active ? modelTreeId({ provider: active.id, model: active.model }) : '',
|
|
788
|
+
...(active ? { description: `Current: ${providerLabel(active, providers)} / ${modelDisplayName(active, active.model)}` } : {}),
|
|
789
|
+
expandPrefix: MODEL_TREE_EXPAND, collapsePrefix: MODEL_TREE_COLLAPSE,
|
|
790
|
+
footer: '↑↓ Move · → Expand · ← Collapse · Enter Select · Esc Back',
|
|
791
|
+
signal, ...yields,
|
|
792
|
+
refresh: redraw => {
|
|
793
|
+
const stopAndorra = andorraRefresh(state, rows).refresh?.(redraw);
|
|
794
|
+
redrawOpen = () => redraw(rows());
|
|
795
|
+
// The loading row's spinner turns while any provider is still loading.
|
|
796
|
+
const spinner = pending.size ? setInterval(() => {
|
|
797
|
+
if (!pending.size) {
|
|
798
|
+
clearInterval(spinner);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
frame++;
|
|
802
|
+
redraw(rows());
|
|
803
|
+
}, WORKING_SPINNER_TICK_MS) : undefined;
|
|
804
|
+
spinner?.unref?.();
|
|
805
|
+
return () => { redrawOpen = undefined; if (spinner)
|
|
806
|
+
clearInterval(spinner); stopAndorra?.(); };
|
|
807
|
+
},
|
|
808
|
+
});
|
|
809
|
+
if (choice === undefined || signal.aborted)
|
|
810
|
+
return undefined;
|
|
811
|
+
const action = choice.startsWith(MODEL_TREE_EXPAND) ? 'expand' : choice.startsWith(MODEL_TREE_COLLAPSE) ? 'collapse' : 'pick';
|
|
812
|
+
const row = parseModelTreeId(action === 'expand' ? choice.slice(MODEL_TREE_EXPAND.length) : action === 'collapse' ? choice.slice(MODEL_TREE_COLLAPSE.length) : choice);
|
|
813
|
+
const provider = row && providers.find(item => item.id === row.provider);
|
|
814
|
+
// The listed Andorra can leave the tree while it is open (turned off, or removed elsewhere): draw it again.
|
|
815
|
+
if (row && !provider && row.provider === listedId)
|
|
816
|
+
continue;
|
|
817
|
+
if (!row || !provider)
|
|
818
|
+
throw new Error('Invalid model selection');
|
|
819
|
+
cursor = modelTreeId(row);
|
|
820
|
+
if (action === 'collapse') {
|
|
821
|
+
// Left on a model row folds its provider, like a file tree.
|
|
767
822
|
expanded.delete(provider.id);
|
|
823
|
+
cursor = modelTreeId({ provider: provider.id });
|
|
768
824
|
continue;
|
|
769
825
|
}
|
|
770
|
-
if (
|
|
826
|
+
if (row.model === undefined) {
|
|
827
|
+
if (action === 'pick' && expanded.has(provider.id)) {
|
|
828
|
+
expanded.delete(provider.id);
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
771
831
|
expanded.add(provider.id);
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
if (!loaded.get(provider.id)?.models.includes(row.model))
|
|
777
|
-
throw new Error('Invalid model selection');
|
|
778
|
-
if (provider === listed) {
|
|
779
|
-
// The user's own choice of an Andorra model: the entry is saved first; the caller then selects it as usual.
|
|
780
|
-
const added = await state.andorra?.add?.(row.model);
|
|
781
|
-
if (!added?.added) {
|
|
782
|
-
if (added?.message && !signal.aborted)
|
|
783
|
-
await ui.showScreen('Andorra', [added.message], { signal });
|
|
832
|
+
// The tree is drawn again at once, keeping the keyboard; a slow answer lands in it through `refresh`.
|
|
833
|
+
const job = load(provider);
|
|
834
|
+
if (job)
|
|
835
|
+
await settleWithoutYielding(job);
|
|
784
836
|
continue;
|
|
785
837
|
}
|
|
786
|
-
|
|
787
|
-
if (added.modelServed === false || (saved !== undefined && !providerModels(saved).includes(row.model))) {
|
|
788
|
-
// The offer changed between the tree being drawn and the pick: the entry was saved with what is served
|
|
789
|
-
// now, and the model that is gone is not selected. Say so and draw the tree with the saved entry's models.
|
|
790
|
-
if (!signal.aborted)
|
|
791
|
-
await ui.showScreen('Andorra', [added.message ?? ANDORRA_MODEL_GONE], { signal });
|
|
792
|
-
if (saved !== undefined) {
|
|
793
|
-
loaded.set(saved.id, { models: providerModels(saved), configured: new Set() });
|
|
794
|
-
expanded.add(saved.id);
|
|
795
|
-
cursor = modelTreeId({ provider: saved.id });
|
|
796
|
-
}
|
|
838
|
+
if (action === 'expand' || row.model === '')
|
|
797
839
|
continue;
|
|
840
|
+
if (!loaded.get(provider.id)?.models.includes(row.model))
|
|
841
|
+
throw new Error('Invalid model selection');
|
|
842
|
+
if (provider === listed) {
|
|
843
|
+
// The user's own choice of an Andorra model: the entry is saved first; the caller then selects it as usual.
|
|
844
|
+
const added = await state.andorra?.add?.(row.model);
|
|
845
|
+
if (!added?.added) {
|
|
846
|
+
if (added?.message && !signal.aborted)
|
|
847
|
+
await ui.showScreen('Andorra', [added.message], { signal, ...yields });
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
const saved = state.config.providers.find(item => item.id === (added.id ?? provider.id));
|
|
851
|
+
if (added.modelServed === false || (saved !== undefined && !providerModels(saved).includes(row.model))) {
|
|
852
|
+
// The offer changed between the tree being drawn and the pick: the entry was saved with what is served
|
|
853
|
+
// now, and the model that is gone is not selected. Say so and draw the tree with the saved entry's models.
|
|
854
|
+
if (!signal.aborted)
|
|
855
|
+
await ui.showScreen('Andorra', [added.message ?? ANDORRA_MODEL_GONE], { signal, ...yields });
|
|
856
|
+
if (saved !== undefined) {
|
|
857
|
+
loaded.set(saved.id, { models: providerModels(saved), configured: new Set() });
|
|
858
|
+
expanded.add(saved.id);
|
|
859
|
+
cursor = modelTreeId({ provider: saved.id });
|
|
860
|
+
}
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
return { provider: added.id ?? provider.id, model: row.model };
|
|
798
864
|
}
|
|
799
|
-
return { provider:
|
|
865
|
+
return { provider: provider.id, model: row.model };
|
|
800
866
|
}
|
|
801
|
-
return
|
|
867
|
+
return undefined;
|
|
868
|
+
}
|
|
869
|
+
finally {
|
|
870
|
+
signal.removeEventListener('abort', abandon);
|
|
871
|
+
abandon();
|
|
802
872
|
}
|
|
803
|
-
return undefined;
|
|
804
873
|
}
|
package/dist/src/commands.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { Usage } from './types.js';
|
|
|
9
9
|
import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
|
|
10
10
|
import { logoutCodex } from './codex-auth.js';
|
|
11
11
|
import type { TerminalAndorraHooks } from './andorra/terminal.js';
|
|
12
|
-
export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open the provider/model tree (\u2192 expands, \u2190 collapses) or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for this session, or show its setting\n /jev global <on|off> Turn the Global Jev switch on or off; off stops Jev in every session and agent\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill to this and every later message; qualify duplicate names by catalog ID\n /skill [on|off|remove] Show, pause, resume or end the session's active skill\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /goal [text|clear] Set, show or clear the session goal; a run keeps working until a completion check agrees the goal is met\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
|
|
12
|
+
export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /resume Same as /session\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open the provider/model tree (\u2192 expands, \u2190 collapses) or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for this session, or show its setting\n /jev global <on|off> Turn the Global Jev switch on or off; off stops Jev in every session and agent\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill to this and every later message; qualify duplicate names by catalog ID\n /skill [on|off|remove] Show, pause, resume or end the session's active skill\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /goal [text|clear] Set, show or clear the session goal; a run keeps working until a completion check agrees the goal is met\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
|
|
13
13
|
export interface CommandState {
|
|
14
14
|
config: Config;
|
|
15
15
|
yolo: boolean;
|
|
@@ -60,7 +60,8 @@ export interface ConversationTurn {
|
|
|
60
60
|
subagentId?: string;
|
|
61
61
|
}[];
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
/** Why a turn started without the person typing it: a timer the agent set, Auto-fix, or the PR tab's Fix with Agent. */
|
|
64
|
+
export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks';
|
|
64
65
|
export declare function compactHistory(turns: ConversationTurn[]): ConversationTurn[];
|
|
65
66
|
export declare function compactedContextEstimate(turns: ConversationTurn[]): number;
|
|
66
67
|
export declare function subagentClearRequested(line: string, providers: {
|
package/dist/src/commands.js
CHANGED
|
@@ -27,6 +27,7 @@ const REASONING_USAGE = 'Usage: /reasoning default|none|minimal|low|medium|high|
|
|
|
27
27
|
export const HELP = `Commands:
|
|
28
28
|
/browser Open the browser workspace (CLI stays available)
|
|
29
29
|
/session Browse and resume saved sessions (newest first)
|
|
30
|
+
/resume Same as /session
|
|
30
31
|
/login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)
|
|
31
32
|
/auth logout Remove this machine's saved Andorra account session
|
|
32
33
|
/auth status Show Andorra account session status
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const COMPACTION_DEFAULT_TEXT = "Summarizing earlier work to free context.";
|
|
2
|
+
export declare const COMPACTION_PHRASES: readonly string[];
|
|
3
|
+
export declare function pickCompactionPhrase(random?: () => number): string;
|
|
4
|
+
export declare function compactionText(text: unknown): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// What the transcript says while earlier work is summarized to free context. The engine picks one per
|
|
2
|
+
// compaction batch and carries it on `agent.context.compaction.started` as `text`, so the CLI and the
|
|
3
|
+
// desktop show the same line; the plain description stays available as the default.
|
|
4
|
+
export const COMPACTION_DEFAULT_TEXT = 'Summarizing earlier work to free context.';
|
|
5
|
+
export const COMPACTION_PHRASES = [
|
|
6
|
+
'Vacuum-sealing the conversation',
|
|
7
|
+
'Writing the CliffsNotes of this chat',
|
|
8
|
+
'Stuffing memories into a carry-on',
|
|
9
|
+
'Shrink-wrapping the context',
|
|
10
|
+
'Condensing the chat like canned soup',
|
|
11
|
+
'Turning the scroll into a sticky note',
|
|
12
|
+
];
|
|
13
|
+
export function pickCompactionPhrase(random = Math.random) {
|
|
14
|
+
const index = Math.floor(random() * COMPACTION_PHRASES.length);
|
|
15
|
+
return COMPACTION_PHRASES[Math.min(Math.max(index, 0), COMPACTION_PHRASES.length - 1)] ?? COMPACTION_DEFAULT_TEXT;
|
|
16
|
+
}
|
|
17
|
+
// Only a phrase from the list is shown, with an ellipsis; anything else falls back to the default line.
|
|
18
|
+
export function compactionText(text) {
|
|
19
|
+
return typeof text === 'string' && COMPACTION_PHRASES.includes(text) ? `${text}…` : COMPACTION_DEFAULT_TEXT;
|
|
20
|
+
}
|
|
@@ -21,3 +21,25 @@ export interface FinalAnswerGateResult {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function declaresUnfinishedWork(summary: string | undefined): boolean;
|
|
23
23
|
export declare function finalAnswerGate(input: FinalAnswerGateInput): FinalAnswerGateResult | undefined;
|
|
24
|
+
export interface ProseFinalAnswerInput {
|
|
25
|
+
text: string;
|
|
26
|
+
stopReason?: string;
|
|
27
|
+
/** The node declares exactly one outcome and that outcome ends the run. */
|
|
28
|
+
endsRun: boolean;
|
|
29
|
+
hasOutputSchema: boolean;
|
|
30
|
+
/** Someone is there to read the answer and reply to it. */
|
|
31
|
+
userPresent: boolean;
|
|
32
|
+
/** The run called a tool or wrote todos, or resumes an earlier invocation whose tool calls are not counted here. */
|
|
33
|
+
acted: boolean;
|
|
34
|
+
openTodos: number;
|
|
35
|
+
/** The response looks like a tool call the provider discarded. */
|
|
36
|
+
toolCallDropped: boolean;
|
|
37
|
+
/** The text carries a completion envelope written out as JSON. */
|
|
38
|
+
carriesEnvelope: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether a plain reply from a graph node is its final answer, so the node ends without a second
|
|
42
|
+
* request that only restates it through complete_agent. True only where nothing can be left undone
|
|
43
|
+
* or unrouted: no work was started, one outcome exists, it ends the run, and a user reads the reply.
|
|
44
|
+
*/
|
|
45
|
+
export declare function proseIsFinalAnswer(input: ProseFinalAnswerInput): boolean;
|
|
@@ -55,3 +55,14 @@ export function finalAnswerGate(input) {
|
|
|
55
55
|
}
|
|
56
56
|
return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')}${gates.includes('unfinished') ? '' : ' Then call complete_agent again.'}`, ...waiver };
|
|
57
57
|
}
|
|
58
|
+
const NATURAL_STOPS = [undefined, 'stop', 'end_turn'];
|
|
59
|
+
/**
|
|
60
|
+
* Whether a plain reply from a graph node is its final answer, so the node ends without a second
|
|
61
|
+
* request that only restates it through complete_agent. True only where nothing can be left undone
|
|
62
|
+
* or unrouted: no work was started, one outcome exists, it ends the run, and a user reads the reply.
|
|
63
|
+
*/
|
|
64
|
+
export function proseIsFinalAnswer(input) {
|
|
65
|
+
return input.endsRun && input.userPresent && !input.hasOutputSchema && !input.acted && input.openTodos === 0
|
|
66
|
+
&& !input.toolCallDropped && !input.carriesEnvelope && NATURAL_STOPS.includes(input.stopReason)
|
|
67
|
+
&& !!input.text.trim() && !declaresUnfinishedWork(input.text);
|
|
68
|
+
}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface Config {
|
|
|
41
41
|
providers: ProviderConfig[];
|
|
42
42
|
graph?: string;
|
|
43
43
|
graphSelections?: Record<string, string>;
|
|
44
|
+
graphVisibility?: Record<string, Record<string, string[]>>;
|
|
45
|
+
graphVisibilityChosen?: Record<string, string[]>;
|
|
44
46
|
codeIntel?: CodeIntelConfig;
|
|
45
47
|
memory?: MemoryConfig;
|
|
46
48
|
analytics?: AnalyticsConfig;
|
|
@@ -107,6 +109,9 @@ export declare const MAX_SYSTEM_PROMPT_OVERRIDE = 16000;
|
|
|
107
109
|
export declare const AUTO_ARCHIVE_MIN_DAYS = 1;
|
|
108
110
|
export declare const AUTO_ARCHIVE_MAX_DAYS = 30;
|
|
109
111
|
export declare function configDirectory(environment?: NodeJS.ProcessEnv): string;
|
|
112
|
+
export declare const MAX_GRAPH_VISIBILITY_PROJECTS = 500;
|
|
113
|
+
/** Per account (subject), per graph id: the project paths the graph is listed in. A graph with no entry is listed everywhere. */
|
|
114
|
+
export declare function validGraphVisibility(value: unknown): value is Record<string, Record<string, string[]>>;
|
|
110
115
|
export declare function validateConfig(value: unknown): Config;
|
|
111
116
|
export declare function reconcileSubagentPair(config: Config): Config;
|
|
112
117
|
export declare function validateMcpServer(value: unknown): McpServerConfig;
|
package/dist/src/config.js
CHANGED
|
@@ -6,7 +6,9 @@ import { randomUUID } from 'node:crypto';
|
|
|
6
6
|
import { isIP } from 'node:net';
|
|
7
7
|
import { cleanModelName, fallbackProviderId } from './andorra/entry.js';
|
|
8
8
|
import { readHostedState } from './andorra/state.js';
|
|
9
|
+
import { isModelParameters } from './providers.js';
|
|
9
10
|
import { assertProviderCredentials, assertRequestTimeout, assertStreamIdleTimeout, MAX_CODEX_ACCOUNT_KEY_LENGTH, MAX_PROVIDER_NAME_LENGTH, PROVIDER_TYPES, REASONING_EFFORTS } from './providers.js';
|
|
11
|
+
import { GOOGLE_BASE_URL } from './google-provider.js';
|
|
10
12
|
import { GROK_BASE_URL } from './grok-provider.js';
|
|
11
13
|
import { ANDORRA_PROVIDER_BASE_URL } from './andorra/endpoint.js';
|
|
12
14
|
import { OPENCODE_BASE_URL } from './opencode-cli-provider.js';
|
|
@@ -129,6 +131,29 @@ function privateHttpHost(host) {
|
|
|
129
131
|
*/
|
|
130
132
|
function normaliseAndorraEntry(provider) {
|
|
131
133
|
provider.baseUrl = ANDORRA_PROVIDER_BASE_URL;
|
|
134
|
+
const usable = (model) => typeof model === 'string' && !!model.trim() && model.length <= 500 && !['__proto__', 'constructor', 'prototype'].includes(model);
|
|
135
|
+
// The sizes and the free list are descriptive, like the names: what cannot be shown is dropped, never refused.
|
|
136
|
+
if (provider.modelParameters !== undefined) {
|
|
137
|
+
const saved = provider.modelParameters;
|
|
138
|
+
const sizes = {};
|
|
139
|
+
if (saved && typeof saved === 'object' && !Array.isArray(saved)) {
|
|
140
|
+
for (const [model, size] of Object.entries(saved))
|
|
141
|
+
if (usable(model) && isModelParameters(size))
|
|
142
|
+
sizes[model] = size;
|
|
143
|
+
}
|
|
144
|
+
if (Object.keys(sizes).length > 0)
|
|
145
|
+
provider.modelParameters = sizes;
|
|
146
|
+
else
|
|
147
|
+
delete provider.modelParameters;
|
|
148
|
+
}
|
|
149
|
+
if (provider.freeModels !== undefined) {
|
|
150
|
+
const saved = provider.freeModels;
|
|
151
|
+
const free = Array.isArray(saved) ? [...new Set(saved.filter(usable))] : [];
|
|
152
|
+
if (free.length > 0)
|
|
153
|
+
provider.freeModels = free;
|
|
154
|
+
else
|
|
155
|
+
delete provider.freeModels;
|
|
156
|
+
}
|
|
132
157
|
if (provider.modelNames === undefined)
|
|
133
158
|
return;
|
|
134
159
|
const saved = provider.modelNames;
|
|
@@ -147,6 +172,17 @@ function normaliseAndorraEntry(provider) {
|
|
|
147
172
|
else
|
|
148
173
|
delete provider.modelNames;
|
|
149
174
|
}
|
|
175
|
+
export const MAX_GRAPH_VISIBILITY_PROJECTS = 500;
|
|
176
|
+
const isPlainRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
177
|
+
/** Per account (subject), per graph id: the project paths the graph is listed in. A graph with no entry is listed everywhere. */
|
|
178
|
+
export function validGraphVisibility(value) {
|
|
179
|
+
if (!isPlainRecord(value))
|
|
180
|
+
return false;
|
|
181
|
+
return Object.entries(value).every(([subject, graphs]) => /^[A-Za-z0-9-]{1,128}$/.test(subject) && isPlainRecord(graphs)
|
|
182
|
+
&& Object.entries(graphs).every(([graph, paths]) => /^[\w-]{1,128}$/.test(graph) && graph !== 'default' && Array.isArray(paths)
|
|
183
|
+
&& paths.length <= MAX_GRAPH_VISIBILITY_PROJECTS
|
|
184
|
+
&& paths.every(path => typeof path === 'string' && path.length > 0 && path.length <= 4096 && !path.includes('\0'))));
|
|
185
|
+
}
|
|
150
186
|
export function validateConfig(value) {
|
|
151
187
|
const c = value;
|
|
152
188
|
if (!c || c.version !== 1 || typeof c.provider !== 'string' || !Array.isArray(c.providers)) {
|
|
@@ -161,6 +197,11 @@ export function validateConfig(value) {
|
|
|
161
197
|
if (c.graphSelections !== undefined && (!c.graphSelections || typeof c.graphSelections !== 'object' || Array.isArray(c.graphSelections)
|
|
162
198
|
|| Object.entries(c.graphSelections).some(([subject, graph]) => !/^[A-Za-z0-9-]{1,128}$/.test(subject) || typeof graph !== 'string' || !/^[\w-]{1,128}$/.test(graph))))
|
|
163
199
|
throw new Error('Invalid account graph selections');
|
|
200
|
+
if (c.graphVisibility !== undefined && !validGraphVisibility(c.graphVisibility))
|
|
201
|
+
throw new Error('Invalid account graph visibility');
|
|
202
|
+
if (c.graphVisibilityChosen !== undefined && (!isPlainRecord(c.graphVisibilityChosen) || Object.entries(c.graphVisibilityChosen).some(([subject, graphs]) => !/^[A-Za-z0-9-]{1,128}$/.test(subject)
|
|
203
|
+
|| !Array.isArray(graphs) || graphs.some(graph => typeof graph !== 'string' || !/^[\w-]{1,128}$/.test(graph)))))
|
|
204
|
+
throw new Error('Invalid account graph visibility choices');
|
|
164
205
|
if (c.externalSubagent !== undefined && (!c.externalSubagent || typeof c.externalSubagent !== 'object' || Array.isArray(c.externalSubagent)
|
|
165
206
|
|| typeof c.externalSubagent.provider !== 'string' || !/^[\w-]+$/.test(c.externalSubagent.provider)
|
|
166
207
|
|| typeof c.externalSubagent.model !== 'string' || !c.externalSubagent.model.trim() || c.externalSubagent.model.length > 500)) {
|
|
@@ -271,6 +312,10 @@ export function validateConfig(value) {
|
|
|
271
312
|
throw new Error('Provider modelNames is an Andorra-only map of model ids to one-line display names of up to 80 characters');
|
|
272
313
|
}
|
|
273
314
|
}
|
|
315
|
+
// An Andorra entry's were normalised above; on any other provider the keys have no meaning.
|
|
316
|
+
if (p.type !== 'andorra' && (p.modelParameters !== undefined || p.freeModels !== undefined)) {
|
|
317
|
+
throw new Error('Provider modelParameters and freeModels are Andorra-only and maintained by Andorra Code');
|
|
318
|
+
}
|
|
274
319
|
if (p.reasoningEffort !== undefined && (!['openai-compatible', 'opencode-go', 'anthropic'].includes(p.type) || !REASONING_EFFORTS.includes(p.reasoningEffort))) {
|
|
275
320
|
throw new Error('Invalid reasoningEffort: use an OpenAI-compatible, OpenCode Go or Anthropic provider and none, minimal, low, medium, high, xhigh, or max');
|
|
276
321
|
}
|
|
@@ -299,6 +344,9 @@ export function validateConfig(value) {
|
|
|
299
344
|
if (p.type === 'grok' && p.baseUrl !== GROK_BASE_URL) {
|
|
300
345
|
throw new Error('Grok providers use the installed Grok CLI sign-in; custom endpoints are not supported');
|
|
301
346
|
}
|
|
347
|
+
if (p.type === 'google' && p.baseUrl !== GOOGLE_BASE_URL) {
|
|
348
|
+
throw new Error('Google providers use the installed Antigravity CLI sign-in; custom endpoints are not supported');
|
|
349
|
+
}
|
|
302
350
|
if (p.type === 'opencode' && p.baseUrl !== OPENCODE_BASE_URL) {
|
|
303
351
|
throw new Error('OpenCode providers use the installed OpenCode CLI; custom endpoints are not supported');
|
|
304
352
|
}
|
|
@@ -2,6 +2,7 @@ import { engineModel } from './engine/protocol.js';
|
|
|
2
2
|
import { generateWithUsage } from './runtime.js';
|
|
3
3
|
import { selectCompactGroups } from '../vendor/zcode/source/compact/selection.js';
|
|
4
4
|
import { serializeContext } from './context-budget.js';
|
|
5
|
+
import { pickCompactionPhrase } from './compaction-phrases.js';
|
|
5
6
|
export const EFFICIENT_CONTEXT_POLICY = { triggerChars: 128_000, targetChars: 64_000, keepRecentToolTurns: 8, protectDiscovery: true };
|
|
6
7
|
function completeExchanges(messages) {
|
|
7
8
|
const exchanges = [];
|
|
@@ -248,7 +249,7 @@ export class HistoryCompactor {
|
|
|
248
249
|
let batchTarget = targetChars;
|
|
249
250
|
let batchMaxTokens = maxTokens;
|
|
250
251
|
await options.onEvent?.({ type: 'agent.context.compaction.started', time: new Date().toISOString(), data: {
|
|
251
|
-
runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber,
|
|
252
|
+
runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber, text: pickCompactionPhrase(),
|
|
252
253
|
} });
|
|
253
254
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
254
255
|
signal.throwIfAborted();
|