@andorra-labs/code 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +22 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +13 -4
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -4,12 +4,11 @@ import { PERMISSION_OPTIONS } from './permissions.js';
|
|
|
4
4
|
import { editProviderSettings } from './provider-settings.js';
|
|
5
5
|
import { retireRemovedCodexAccounts, retireUnsavedCodexAccounts } from './codex-auth.js';
|
|
6
6
|
import { droppedAnthropicAccounts, retireAnthropicAccounts } from './anthropic-console-auth.js';
|
|
7
|
-
import { importProvidersFromRemote } from './provider-import.js';
|
|
8
7
|
import { DEFAULT_GRAPH, listGraphs, withoutDeletedGraphs } from './graphs.js';
|
|
9
8
|
import { graphStorageDirectory } from './graph-account.js';
|
|
10
9
|
import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
|
|
11
10
|
import { getMembership, loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
12
|
-
import {
|
|
11
|
+
import { FREE_GRAPH_LIMIT_MESSAGE, freeTierGraphViolation, readGraphQuota } from './graph-quota.js';
|
|
13
12
|
import { GraphProviderUnavailableError } from './graph-provider-portability.js';
|
|
14
13
|
import { confirmAndApplyModelOverride } from './model-override.js';
|
|
15
14
|
import { andorraRefusal } from './commands.js';
|
|
@@ -44,6 +43,14 @@ export function isScreenCommand(line) {
|
|
|
44
43
|
return ['/model', '/providers', '/graph', '/usage', '/permissions', '/skills', '/plugins', '/mcp', '/subagent'].includes(line.trim());
|
|
45
44
|
}
|
|
46
45
|
const CLEAR_SUBAGENT_SELECTION = '*clear*';
|
|
46
|
+
/** Signs out and removes the Codex and Claude Console accounts of providers `next` no longer has. */
|
|
47
|
+
export async function retireDroppedAccounts(previous, next, signal) {
|
|
48
|
+
await retireRemovedCodexAccounts(previous, next, signal ? { signal } : {}).catch(() => { });
|
|
49
|
+
await retireAnthropicAccounts(droppedAnthropicAccounts(previous, next)).catch(() => { });
|
|
50
|
+
}
|
|
51
|
+
/** Thrown by a live persist when the change it carried was refused, so the enclosing save keeps the old config. */
|
|
52
|
+
export class SelectionReverted extends Error {
|
|
53
|
+
}
|
|
47
54
|
export async function runCommandScreen(line, state, ui, persist, signal, adapterFactory = createAdapter, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership, membership: getMembership }, openGraphBuilder, graphSubject = currentGraphSubject) {
|
|
48
55
|
const unchanged = { clear: false };
|
|
49
56
|
if (!isScreenCommand(line) || signal.aborted)
|
|
@@ -60,7 +67,11 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
60
67
|
try {
|
|
61
68
|
await (removesAndorra ? removingAndorraEntry(configDirectory(), () => persist(reconciled)) : persist(reconciled));
|
|
62
69
|
}
|
|
63
|
-
catch {
|
|
70
|
+
catch (error) {
|
|
71
|
+
// The live persist refused the change it carried (a provider the run could not move to): nothing was
|
|
72
|
+
// saved, so the configuration in memory stays as it was instead of taking the rejected draft.
|
|
73
|
+
if (error instanceof SelectionReverted)
|
|
74
|
+
return unchanged;
|
|
64
75
|
await retireUnsavedCodexAccounts(reconciled.providers, state.config.providers, { signal });
|
|
65
76
|
await retireAnthropicAccounts(droppedAnthropicAccounts(reconciled.providers, state.config.providers)).catch(() => { });
|
|
66
77
|
if (!signal.aborted)
|
|
@@ -73,8 +84,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
73
84
|
Object.assign(state.config, reconciled);
|
|
74
85
|
if (removesAndorra)
|
|
75
86
|
await state.andorra?.entryChanged?.();
|
|
76
|
-
await
|
|
77
|
-
await retireAnthropicAccounts(droppedAnthropicAccounts(previousProviders, reconciled.providers)).catch(() => { });
|
|
87
|
+
await (state.retireAccounts ?? retireDroppedAccounts)(previousProviders, reconciled.providers, signal).catch(() => { });
|
|
78
88
|
if (reconciled.externalSubagent === undefined)
|
|
79
89
|
delete state.config.externalSubagent;
|
|
80
90
|
return { clear: true };
|
|
@@ -245,7 +255,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
245
255
|
return { id: item.id, label: providerLabel(item, state.config.providers), ...(refusal ? { description: refusal } : {}) };
|
|
246
256
|
}),
|
|
247
257
|
{ id: ':add', label: '+ Add provider' },
|
|
248
|
-
{ id: ':import', label: 'Import from remote connection' },
|
|
249
258
|
];
|
|
250
259
|
};
|
|
251
260
|
while (!signal.aborted) {
|
|
@@ -278,12 +287,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
278
287
|
draft.provider = id;
|
|
279
288
|
return await save(draft);
|
|
280
289
|
}
|
|
281
|
-
if (selected === ':import') {
|
|
282
|
-
const draft = await importProvidersFromRemote(state.config, ui, signal);
|
|
283
|
-
if (draft)
|
|
284
|
-
return await save(draft);
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
290
|
if (selected === ':add' || selected.startsWith(':edit:')) {
|
|
288
291
|
const id = selected === ':add' ? undefined : selected.slice(6);
|
|
289
292
|
if (id && !state.config.providers.some(item => item.id === id))
|
|
@@ -317,12 +320,14 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
317
320
|
return unchanged;
|
|
318
321
|
const access = await graphAccess.membership?.(signal);
|
|
319
322
|
const free = access !== undefined && !access.paid && !access.unavailable && access.subject !== undefined;
|
|
320
|
-
const
|
|
323
|
+
const kept = free ? (await readGraphQuota(directory, saved, { adopt: true })).freeGraphId : undefined;
|
|
324
|
+
const atLimit = free && kept !== undefined;
|
|
325
|
+
const viewOnly = (graph) => free && (graph.id !== kept || freeTierGraphViolation(graph) !== undefined);
|
|
321
326
|
const items = [{
|
|
322
327
|
id: DEFAULT_GRAPH.id,
|
|
323
328
|
label: 'Default',
|
|
324
329
|
description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
|
|
325
|
-
}, ...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' }];
|
|
330
|
+
}, ...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' }];
|
|
326
331
|
while (!signal.aborted) {
|
|
327
332
|
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 });
|
|
328
333
|
if (selected === undefined || signal.aborted)
|
package/dist/src/commands.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface CommandState {
|
|
|
32
32
|
goal?: SessionGoal;
|
|
33
33
|
jev?: boolean;
|
|
34
34
|
andorra?: TerminalAndorraHooks;
|
|
35
|
+
/**
|
|
36
|
+
* Retires the sign-ins of providers a saved change dropped. Unset, a manager retires them at once; a run that is
|
|
37
|
+
* still working sets it to defer retirement until it ends, since its requests still read those credentials.
|
|
38
|
+
*/
|
|
39
|
+
retireAccounts?: (previous: readonly import('./providers.js').ProviderConfig[], next: readonly import('./providers.js').ProviderConfig[], signal?: AbortSignal) => Promise<void>;
|
|
35
40
|
}
|
|
36
41
|
/** The message refusing a switch to this provider, or undefined when it may be selected. An absent `state.andorra` counts as available. */
|
|
37
42
|
export declare function andorraRefusal(state: Pick<CommandState, 'andorra' | 'config'>, providerId: string): string | undefined;
|
|
@@ -49,18 +54,26 @@ export interface ConversationTurn {
|
|
|
49
54
|
task: string;
|
|
50
55
|
completion: Completion;
|
|
51
56
|
runId?: string;
|
|
57
|
+
/** Given to the agent with the task but not shown with it (`run.note`), such as the person's hand edits. */
|
|
58
|
+
note?: string;
|
|
52
59
|
resumed?: boolean;
|
|
53
60
|
direction?: string;
|
|
54
61
|
attachments?: import('./attachments.js').UserAttachmentRef[];
|
|
55
62
|
wake?: TurnWake;
|
|
56
63
|
steers?: {
|
|
57
64
|
text: string;
|
|
65
|
+
note?: string;
|
|
58
66
|
attachments?: import('./attachments.js').UserAttachmentRef[];
|
|
59
67
|
wake?: TurnWake;
|
|
60
68
|
subagentId?: string;
|
|
61
69
|
}[];
|
|
62
70
|
}
|
|
63
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Why a turn started without the person typing it: a timer the agent set, Auto-fix, the PR tab's Fix with Agent,
|
|
73
|
+
* the person mentioning the App's bot on the task's PR (`mention`), or the Andorra review loop handing its findings to the
|
|
74
|
+
* task that owns the PR (`andorra-review`).
|
|
75
|
+
*/
|
|
76
|
+
export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
|
|
64
77
|
export declare function compactHistory(turns: ConversationTurn[]): ConversationTurn[];
|
|
65
78
|
export declare function compactedContextEstimate(turns: ConversationTurn[]): number;
|
|
66
79
|
export declare function subagentClearRequested(line: string, providers: {
|
|
@@ -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 context 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
|
+
}
|
package/dist/src/completion.js
CHANGED
|
@@ -395,6 +395,74 @@ function splitFusedArguments(envelope, notes) {
|
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts)"\s*:/;
|
|
398
|
+
const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining'];
|
|
399
|
+
const RAW_CONTROL = { '\n': '\\n', '\r': '\\r', '\t': '\\t' };
|
|
400
|
+
function emptyField(value) {
|
|
401
|
+
if (value === undefined || value === null)
|
|
402
|
+
return true;
|
|
403
|
+
if (Array.isArray(value))
|
|
404
|
+
return value.length === 0;
|
|
405
|
+
return typeof value === 'object' && Object.keys(value).length === 0;
|
|
406
|
+
}
|
|
407
|
+
const JSON_ESCAPE = /\\(["\\/bfnrt]|u[0-9a-fA-F]{4})/g;
|
|
408
|
+
const JSON_ESCAPED = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' };
|
|
409
|
+
const MARK = '\u0000';
|
|
410
|
+
/** Reads one level of JSON string escaping in a single pass, so an escaped backslash is never read twice. */
|
|
411
|
+
function decodeOneLevel(text) {
|
|
412
|
+
return text.replace(JSON_ESCAPE, (_, escape) => escape.length === 1 ? JSON_ESCAPED[escape] : String.fromCharCode(parseInt(escape.slice(1), 16)));
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Recovers a completion whose summary string swallowed the rest of the envelope: the model escaped
|
|
416
|
+
* the quote that should have closed summary, so tests, outcome and output arrived as text inside it.
|
|
417
|
+
* The summary is cut where the first swallowed field starts and only what follows is parsed, so the
|
|
418
|
+
* answer's own text (a Windows path, a regular expression) is never read as JSON escapes. The parsed
|
|
419
|
+
* fields fill the ones the envelope lacks; a field the envelope already carries is never replaced.
|
|
420
|
+
*/
|
|
421
|
+
function unpackEmbeddedEnvelope(envelope, notes) {
|
|
422
|
+
if (typeof envelope.summary !== 'string' || envelope.summary.includes(MARK))
|
|
423
|
+
return;
|
|
424
|
+
let candidate = envelope.summary;
|
|
425
|
+
// The swallowed fields sit at the summary's own escaping level, or one or two levels deeper when the
|
|
426
|
+
// model escaped the whole tail again.
|
|
427
|
+
for (let level = 0; level < 3; level += 1, candidate = decodeOneLevel(candidate)) {
|
|
428
|
+
let marked = false;
|
|
429
|
+
const masked = mapOutsideCode(candidate, prose => marked ? prose : prose.replace(EMBEDDED_ENVELOPE_FIELD, found => { marked = true; return MARK + found.slice(1); }));
|
|
430
|
+
const cut = masked.indexOf(MARK);
|
|
431
|
+
if (!marked || masked.length !== candidate.length || candidate[cut] !== '"')
|
|
432
|
+
continue;
|
|
433
|
+
let inner;
|
|
434
|
+
try {
|
|
435
|
+
inner = JSON.parse(`{"summary":""${candidate.slice(cut + 1).replace(/[\n\r\t]/g, char => RAW_CONTROL[char])}`);
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (!inner || typeof inner !== 'object' || Array.isArray(inner))
|
|
441
|
+
continue;
|
|
442
|
+
const fields = inner;
|
|
443
|
+
// At the summary's own level only its quotes can still be escaped: the model escaped them for the
|
|
444
|
+
// string it believed it was still inside.
|
|
445
|
+
const summary = level === 0 ? candidate.slice(0, cut).replace(/\\"/g, '"') : candidate.slice(0, cut);
|
|
446
|
+
if (!summary.trim())
|
|
447
|
+
continue;
|
|
448
|
+
if (Object.keys(fields).some(key => key !== 'summary' && !EMBEDDED_FIELDS.includes(key)))
|
|
449
|
+
continue;
|
|
450
|
+
if (fields.tests !== undefined && !ENVELOPE_FIELDS.tests(fields.tests))
|
|
451
|
+
continue;
|
|
452
|
+
if (fields.outcome !== undefined && typeof fields.outcome !== 'string')
|
|
453
|
+
continue;
|
|
454
|
+
const moved = [];
|
|
455
|
+
for (const key of EMBEDDED_FIELDS) {
|
|
456
|
+
if (fields[key] === undefined || !emptyField(envelope[key]))
|
|
457
|
+
continue;
|
|
458
|
+
envelope[key] = fields[key];
|
|
459
|
+
moved.push(key);
|
|
460
|
+
}
|
|
461
|
+
envelope.summary = summary;
|
|
462
|
+
notes?.push(`completion summary carried the rest of the envelope as text${moved.length ? ` (${moved.join(', ')})` : ''}; the host separated the fields`);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
398
466
|
function rejectEmbeddedEnvelope(summary) {
|
|
399
467
|
let field;
|
|
400
468
|
mapOutsideCode(summary, prose => {
|
|
@@ -482,17 +550,23 @@ export function stripEchoedEnvelope(summary, outcome, notes) {
|
|
|
482
550
|
notes?.push(`completion summary ended with its own ${[...fields].join(', ')} fields written out as text, removed by the host`);
|
|
483
551
|
return answer;
|
|
484
552
|
}
|
|
553
|
+
const CONTRACT_MISMATCH = 'Completion outcome or output does not match the declared contract';
|
|
485
554
|
export function parseCompletion(text, options, reject, notes, stopReason) {
|
|
486
555
|
const body = text.replace(/^```(?:json)?\s*\n?/, '').replace(/\n?```\s*$/, '');
|
|
487
556
|
try {
|
|
488
557
|
const value = parseCompletionJson(body, stopReason, notes);
|
|
489
|
-
if (value && typeof value === 'object' && !Array.isArray(value))
|
|
558
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
490
559
|
splitFusedArguments(value, notes);
|
|
560
|
+
unpackEmbeddedEnvelope(value, notes);
|
|
561
|
+
}
|
|
491
562
|
if (options.completionPolicy && value && typeof value === 'object' && !Array.isArray(value)) {
|
|
492
563
|
const policy = options.completionPolicy;
|
|
493
564
|
const outcome = value.outcome ?? (policy.mode === 'single' ? policy.outcome : undefined);
|
|
494
|
-
|
|
495
|
-
|
|
565
|
+
const declared = policy.mode === 'single' ? [policy.outcome] : policy.outcomes;
|
|
566
|
+
if (typeof outcome !== 'string' || !declared.includes(outcome)) {
|
|
567
|
+
const got = outcome === undefined ? 'outcome is missing' : `outcome ${(JSON.stringify(outcome) ?? String(outcome)).slice(0, 80)} is not declared`;
|
|
568
|
+
throw new Error(`${CONTRACT_MISMATCH}: ${got}; send outcome as ${declared.length === 1 ? '' : 'one of '}${declared.map(item => JSON.stringify(item)).join(', ')}`);
|
|
569
|
+
}
|
|
496
570
|
let output = value.output ?? (typeof value.summary === 'string' ? { summary: value.summary, tests: value.tests ?? [] } : undefined);
|
|
497
571
|
if (typeof output === 'string') {
|
|
498
572
|
try {
|
|
@@ -504,8 +578,11 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
|
|
|
504
578
|
}
|
|
505
579
|
catch { }
|
|
506
580
|
}
|
|
507
|
-
if (!output || typeof output !== 'object' || Array.isArray(output))
|
|
508
|
-
throw new Error(
|
|
581
|
+
if (!output || typeof output !== 'object' || Array.isArray(output)) {
|
|
582
|
+
throw new Error(output === undefined || output === null
|
|
583
|
+
? `${CONTRACT_MISMATCH}: it has neither a summary nor an output; send summary (the final answer, in markdown), tests, outcome and output as complete_agent arguments`
|
|
584
|
+
: `${CONTRACT_MISMATCH}: output is ${Array.isArray(output) ? 'an array' : `a ${typeof output}`} and must be a JSON object`);
|
|
585
|
+
}
|
|
509
586
|
if (value.output !== undefined)
|
|
510
587
|
output = liftEnvelopeFields(value, output, options.outputSchema, notes);
|
|
511
588
|
if (options.canonicalTask !== undefined)
|
package/dist/src/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type AnalyticsConfig } from './analytics.js';
|
|
|
7
7
|
import { type PermissionMode } from './permissions.js';
|
|
8
8
|
import { type ToolProfile } from './tool-profile.js';
|
|
9
9
|
import { type Limits } from './limits.js';
|
|
10
|
-
import type { ProjectEntry,
|
|
10
|
+
import type { ProjectEntry, RemoteShare } from './remote/types.js';
|
|
11
11
|
export interface LimitsConfig {
|
|
12
12
|
maxIterations?: number;
|
|
13
13
|
wallTimeMs?: number;
|
|
@@ -35,6 +35,27 @@ export type McpServerConfig = {
|
|
|
35
35
|
headers?: Record<string, string>;
|
|
36
36
|
enabled?: boolean;
|
|
37
37
|
};
|
|
38
|
+
export interface BridgeConfig {
|
|
39
|
+
folders?: RemoteShare[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `modelRelay`: by Andorra account subject, the linked machines (environment ids) allowed to use this computer's
|
|
43
|
+
* providers through the model relay, oldest first. A list (the shape before accounts were told apart) is ignored on read
|
|
44
|
+
* and replaced on the next write.
|
|
45
|
+
*/
|
|
46
|
+
export interface EnvironmentsConfig {
|
|
47
|
+
modelRelay?: Record<string, string[]> | string[];
|
|
48
|
+
}
|
|
49
|
+
/** At most this many machines are allowed per account; allowing another drops the oldest. */
|
|
50
|
+
export declare const MODEL_RELAY_ALLOWED_LIMIT = 64;
|
|
51
|
+
/** The machines `subject` allowed to use this computer's models, from a saved `environments.modelRelay`. */
|
|
52
|
+
export declare function modelRelayAllowedFor(environments: EnvironmentsConfig | undefined, subject: string | undefined): string[];
|
|
53
|
+
/**
|
|
54
|
+
* `map` with `subject`'s list set to `list` and moved to the end: the object's key order is the order in which the
|
|
55
|
+
* accounts' lists were last written. Past 64 accounts, the least recently written are dropped, so the file always
|
|
56
|
+
* validates. (Account subjects are Cognito ids, never integer-like keys, so the order holds.)
|
|
57
|
+
*/
|
|
58
|
+
export declare function withModelRelayEntry(map: Record<string, string[]>, subject: string, list: string[]): Record<string, string[]>;
|
|
38
59
|
export interface Config {
|
|
39
60
|
version: 1;
|
|
40
61
|
provider: string;
|
|
@@ -59,18 +80,64 @@ export interface Config {
|
|
|
59
80
|
mcpServers?: Record<string, McpServerConfig>;
|
|
60
81
|
workspacePermissions?: Record<string, PermissionMode>;
|
|
61
82
|
projectExtensions?: Record<string, ProjectExtensionOverride>;
|
|
62
|
-
remote?:
|
|
83
|
+
remote?: Record<string, unknown>;
|
|
84
|
+
bridge?: BridgeConfig;
|
|
63
85
|
projects?: ProjectEntry[];
|
|
64
86
|
externalSubagent?: {
|
|
65
87
|
provider: string;
|
|
66
88
|
model: string;
|
|
67
89
|
};
|
|
90
|
+
environments?: EnvironmentsConfig;
|
|
68
91
|
systemPromptOverride?: string;
|
|
69
92
|
toolProfile?: ToolProfile;
|
|
70
93
|
autoArchiveDays?: number;
|
|
71
94
|
browser?: BrowserConfig;
|
|
72
95
|
webSearch?: WebSearchConfig;
|
|
96
|
+
github?: GitHubConfig;
|
|
73
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* The Andorra GitHub App, per user. `app.enabled: false` turns its events off on this installation (every PR
|
|
100
|
+
* is polled through gh, as without the App). `app.agentWrites` says who the agent's replies, resolves and PR
|
|
101
|
+
* comments post as on a PR the App covers: `bot` (the default) for the App's bot, `me` for the person's own gh
|
|
102
|
+
* account. `app.triggers: false` stops a mention of the App's bot on a task's PR from waking the task on this
|
|
103
|
+
* installation (the per-machine opt-out; on by default). `app.reviews: false` refuses switching the Andorra review loop
|
|
104
|
+
* on here (on by default); `app.reviewNewPullRequests: true` switches it on for each PR a task opens (off by default).
|
|
105
|
+
* Other keys under `github.app` belong to later versions and are kept as written.
|
|
106
|
+
*/
|
|
107
|
+
export declare const GITHUB_AGENT_WRITES: readonly ["bot", "me"];
|
|
108
|
+
export type GitHubAgentWrites = typeof GITHUB_AGENT_WRITES[number];
|
|
109
|
+
export interface GitHubConfig {
|
|
110
|
+
app?: {
|
|
111
|
+
enabled?: boolean;
|
|
112
|
+
agentWrites?: GitHubAgentWrites;
|
|
113
|
+
triggers?: boolean;
|
|
114
|
+
reviews?: boolean;
|
|
115
|
+
reviewNewPullRequests?: boolean;
|
|
116
|
+
} & Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
export declare function validateGitHubConfig(value: unknown): GitHubConfig;
|
|
119
|
+
export declare function githubAgentWrites(config: Pick<Config, 'github'>): GitHubAgentWrites;
|
|
120
|
+
/** The same, read from `config.json` for each write and each Auto-fix prompt, without validation or keyring; unreadable reads as `bot`. */
|
|
121
|
+
export declare function readGitHubAgentWrites(directory: string): Promise<GitHubAgentWrites>;
|
|
122
|
+
/** Whether the GitHub App's events may run here: not switched off in config, nor by `ANDORRA_GITHUB_APP=off`. */
|
|
123
|
+
export declare function githubAppEventsEnabled(config: Pick<Config, 'github'>, env?: NodeJS.ProcessEnv): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* The same, read cheaply for a check that runs every minute: only `github.app.enabled` is taken from
|
|
126
|
+
* `config.json`, with no validation, no provider keys and no keyring. A missing or unreadable file reads as on,
|
|
127
|
+
* as `loadConfig`'s default config would.
|
|
128
|
+
*/
|
|
129
|
+
export declare function readGitHubAppEventsEnabled(directory: string, env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
130
|
+
export declare function githubAppTriggersEnabled(config: Pick<Config, 'github'>): boolean;
|
|
131
|
+
/** The same, read from `config.json` for each mention, without validation or keyring; a missing or unreadable file reads as on. */
|
|
132
|
+
export declare function readGitHubAppTriggersEnabled(directory: string): Promise<boolean>;
|
|
133
|
+
/** The Andorra review loop may be switched on here: only `github.app.reviews: false` says no. */
|
|
134
|
+
export declare function githubAppReviewsEnabled(config: Pick<Config, 'github'>): boolean;
|
|
135
|
+
/** The same, read from `config.json` without validation or keyring; a missing or unreadable file reads as on. */
|
|
136
|
+
export declare function readGitHubAppReviewsEnabled(directory: string): Promise<boolean>;
|
|
137
|
+
/** A PR a task opens starts with the review loop on: only `github.app.reviewNewPullRequests: true` says so. */
|
|
138
|
+
export declare function githubAppReviewNewPullRequests(config: Pick<Config, 'github'>): boolean;
|
|
139
|
+
/** The same, read from `config.json`; a missing or unreadable file reads as off. */
|
|
140
|
+
export declare function readGitHubAppReviewNewPullRequests(directory: string): Promise<boolean>;
|
|
74
141
|
export interface BrowserConfig {
|
|
75
142
|
capsolverApiKey?: string;
|
|
76
143
|
}
|
|
@@ -134,6 +201,7 @@ export declare class ConfigConflictError extends Error {
|
|
|
134
201
|
export declare function changeConfigFile<T = undefined>(directory: string, change: (current: Config, prepared: T) => Config, attempts?: number, prepare?: () => Promise<T>): Promise<Config>;
|
|
135
202
|
export declare function validateCodeIntelConfig(codeIntel: unknown): void;
|
|
136
203
|
export declare function resolveCodeIntelConfig(config: Config): Required<Pick<CodeIntelConfig, 'enabled'>> & CodeIntelConfig;
|
|
137
|
-
export declare function
|
|
204
|
+
export declare function validateBridgeConfig(bridge: unknown): void;
|
|
205
|
+
export declare function validateEnvironmentsConfig(environments: unknown): void;
|
|
138
206
|
export declare function validateProjectsConfig(projects: unknown): void;
|
|
139
207
|
export declare function validateDecisionConfig(value: unknown): void;
|