@andorra-labs/code 0.1.5 → 0.1.7
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/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +526 -41
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +36 -3
- package/dist/src/agent-mcp.js +114 -45
- package/dist/src/app-server/protocol.d.ts +57 -5
- package/dist/src/app-server/protocol.js +18 -1
- package/dist/src/app-server/workspace.d.ts +9 -1
- package/dist/src/app-server/workspace.js +50 -3
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1316 -221
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +18 -3
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +11 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +20 -5
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +84 -26
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +98 -53
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +15 -2
- package/dist/src/commands.js +14 -13
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +380 -17
- package/dist/src/config.d.ts +61 -0
- package/dist/src/config.js +276 -12
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/deadline.js +6 -0
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +8 -0
- package/dist/src/graph-server.js +76 -6
- package/dist/src/graph-sync.d.ts +65 -0
- package/dist/src/graph-sync.js +433 -13
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +272 -50
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +65 -12
- package/dist/src/graphs.d.ts +60 -5
- package/dist/src/graphs.js +191 -37
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +11 -2
- package/dist/src/powershell-pool.js +34 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +123 -20
- package/dist/src/pull-requests.js +334 -84
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +106 -7
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +8 -2
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +38 -0
- package/dist/src/terminal-ui.js +126 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +159 -20
- package/dist/src/trajectory.js +32 -12
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +28 -3
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +4 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +30 -3
- package/docs/guides/README.md +1 -0
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +11 -4
- package/docs/guides/graph-builder.md +9 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +4 -4
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
package/dist/src/terminal-ui.js
CHANGED
|
@@ -10,7 +10,7 @@ import { transcriptColor } from './transcript.js';
|
|
|
10
10
|
import { ToolCallClock, toolHeaderRows } from './tool-call-clock.js';
|
|
11
11
|
import { formatDuration } from './duration.js';
|
|
12
12
|
import { PagedTranscript } from './paged-transcript.js';
|
|
13
|
-
import { accentSgr, ATTACHMENT_TOKEN, DIM, FAINT, GRAY, STATUS, SUBTLE, WHITE } from './palette.js';
|
|
13
|
+
import { accentSgr, ATTACHMENT_TOKEN, DIM, FAINT, GRAY, SKILL_CHIP, STATUS, SUBTLE, WHITE } from './palette.js';
|
|
14
14
|
import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows } from './side-panel.js';
|
|
15
15
|
import { TokenRateMeter } from './token-rate.js';
|
|
16
16
|
import { attachmentLabel, droppedPaths, formatBytes, isLargePaste, MAX_ATTACHMENTS } from './attachments.js';
|
|
@@ -23,6 +23,12 @@ const graphemes = (text) => [...segmenter.segment(text)].map(part => part.segmen
|
|
|
23
23
|
*/
|
|
24
24
|
const TOKEN_BASE = 0x100000;
|
|
25
25
|
const isToken = (part) => (part.codePointAt(0) ?? 0) >= TOKEN_BASE;
|
|
26
|
+
/**
|
|
27
|
+
* The skill chip: the leading `/name` of a picked skill, held as one code point so Backspace, Delete,
|
|
28
|
+
* the arrows and selections treat it as a unit. It sits at the top of the private-use plane, above
|
|
29
|
+
* every attachment marker, and like them it cannot be typed or pasted (`clean` strips the plane).
|
|
30
|
+
*/
|
|
31
|
+
const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
|
|
26
32
|
/** Graphemes of a draft, keeping each token its own element even when a combining mark follows it. */
|
|
27
33
|
const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
|
|
28
34
|
const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
|
|
@@ -47,9 +53,9 @@ const argumentCompletions = {
|
|
|
47
53
|
* waits for the argument instead of running it; `/logout` is complete on its own.
|
|
48
54
|
*/
|
|
49
55
|
const argumentRequired = new Set(['/jev', '/feedback', '/yolo', '/reasoning', '/codegraph', '/attach']);
|
|
50
|
-
const completionOptions = (query) => {
|
|
56
|
+
const completionOptions = (query, skills = []) => {
|
|
51
57
|
const command = /^(\/\S+)\s/.exec(query)?.[1];
|
|
52
|
-
return (command === undefined ? commands : argumentCompletions[command] ?? []).filter(option => option.startsWith(query));
|
|
58
|
+
return (command === undefined ? [...commands, ...skills] : argumentCompletions[command] ?? []).filter(option => option.startsWith(query));
|
|
53
59
|
};
|
|
54
60
|
/**
|
|
55
61
|
* Whether the composer text is a command name, or a command with arguments, that the popup completes.
|
|
@@ -227,11 +233,11 @@ function composerRow(text, color, selection, tokens) {
|
|
|
227
233
|
let painted = '', run = '', style = '';
|
|
228
234
|
let column = 0;
|
|
229
235
|
const flush = () => { if (run)
|
|
230
|
-
painted += paint(style[1] === 'r' ? `\x1b[7m${run}` : run, style[0] === 't' ? ATTACHMENT_TOKEN : color); run = ''; };
|
|
236
|
+
painted += paint(style[1] === 'r' ? `\x1b[7m${run}` : run, style[0] === 't' ? ATTACHMENT_TOKEN : style[0] === 's' ? `1;38;5;${SKILL_CHIP}` : color); run = ''; };
|
|
231
237
|
for (const part of graphemes(text)) {
|
|
232
|
-
const token = tokens.
|
|
238
|
+
const token = tokens.find(([start, end]) => column >= start && column < end);
|
|
233
239
|
const selected = !!selection && column >= selection[0] && column < selection[1];
|
|
234
|
-
const next = `${token ? 't' : 'p'}${selected ? 'r' : '-'}`;
|
|
240
|
+
const next = `${token ? token[2] === 'skill' ? 's' : 't' : 'p'}${selected ? 'r' : '-'}`;
|
|
235
241
|
if (next !== style) {
|
|
236
242
|
flush();
|
|
237
243
|
style = next;
|
|
@@ -246,7 +252,7 @@ function composerRow(text, color, selection, tokens) {
|
|
|
246
252
|
function tokenColumns(draft, visible, positions, row) {
|
|
247
253
|
const spans = [];
|
|
248
254
|
draft.forEach((part, index) => { const position = positions[index]; if (isToken(part) && position?.row === row)
|
|
249
|
-
spans.push([position.column, position.column + stringWidth(visible[index])]); });
|
|
255
|
+
spans.push([position.column, position.column + stringWidth(visible[index]), part === SKILL_TOKEN ? 'skill' : 'attachment']); });
|
|
250
256
|
return spans;
|
|
251
257
|
}
|
|
252
258
|
/** Whitespace as one editor element; a token label is a single element that contains spaces. */
|
|
@@ -875,6 +881,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
875
881
|
* drained at turn boundaries.
|
|
876
882
|
*/
|
|
877
883
|
attachments = [];
|
|
884
|
+
/** The skills the `/` popup offers after the built-in commands, with the description it shows. */
|
|
885
|
+
skillCommands = [];
|
|
886
|
+
/** The command the skill chip in the draft stands for, while one is there. */
|
|
887
|
+
skillChip;
|
|
878
888
|
attachmentSeq = 0;
|
|
879
889
|
/**
|
|
880
890
|
* Generation of the composer's attachment surface. Advanced by every draft clear and steer
|
|
@@ -964,7 +974,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
964
974
|
// A question (approval or clarification) can interrupt a run while a steer is half typed.
|
|
965
975
|
// Park it, so taking the composer for the question does not silently discard the draft.
|
|
966
976
|
if (this.steering && this.value.length) {
|
|
967
|
-
this.steerDraft = this.
|
|
977
|
+
this.steerDraft = this.parkedDraft();
|
|
968
978
|
this.steerCursor = this.cursor;
|
|
969
979
|
}
|
|
970
980
|
this.value = [];
|
|
@@ -1816,7 +1826,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
1816
1826
|
insert(text) { if ((this.pending?.choices && !this.commandInput && !(this.runInputHandler && text.startsWith('/'))) || (!this.pending && !this.steering) || this.modal || !text)
|
|
1817
1827
|
return; if (this.pending?.choices && text.startsWith('/'))
|
|
1818
1828
|
this.commandInput = true; const selected = this.selectionRange(); if (selected)
|
|
1819
|
-
this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
|
|
1829
|
+
this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.chipTypedSkill(); this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
|
|
1820
1830
|
/** Whether the surface that owns the composer accepts task input — the only place attachments mean anything. */
|
|
1821
1831
|
conversationComposer() {
|
|
1822
1832
|
// Steering owns the conversation only while no question holds the composer: an approval or
|
|
@@ -1880,6 +1890,58 @@ export class TerminalUI extends EventEmitter {
|
|
|
1880
1890
|
this.scheduleRender();
|
|
1881
1891
|
return true;
|
|
1882
1892
|
}
|
|
1893
|
+
/** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
|
|
1894
|
+
setSkillCommands(skills) {
|
|
1895
|
+
this.skillCommands = skills.filter(skill => /^\/\S+$/.test(skill.command) && !commands.includes(skill.command)).map(skill => ({ command: skill.command, description: oneLine(skill.description) }));
|
|
1896
|
+
this.completion = undefined;
|
|
1897
|
+
this.scheduleRender();
|
|
1898
|
+
}
|
|
1899
|
+
skillCommand(command) { return this.skillCommands.some(skill => skill.command === command); }
|
|
1900
|
+
/** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
|
|
1901
|
+
insertSkillChip(command, rest = ' ') {
|
|
1902
|
+
this.skillChip = command;
|
|
1903
|
+
this.value = [SKILL_TOKEN, ...composerGraphemes(rest.startsWith(' ') ? rest : ' ' + rest)];
|
|
1904
|
+
this.cursor = 2;
|
|
1905
|
+
this.completion = undefined;
|
|
1906
|
+
this.dismissedCompletion = undefined;
|
|
1907
|
+
this.selectionAnchor = undefined;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Turn a leading, fully typed skill command into the chip once a space follows it, so a command
|
|
1911
|
+
* typed out in full reads the same as one picked from the popup.
|
|
1912
|
+
*/
|
|
1913
|
+
chipTypedSkill() {
|
|
1914
|
+
if (this.value[0] === SKILL_TOKEN)
|
|
1915
|
+
return;
|
|
1916
|
+
const typed = this.value.join('');
|
|
1917
|
+
const match = /^(\/\S+) /.exec(typed);
|
|
1918
|
+
if (!match || !this.skillCommand(match[1]) || this.value.slice(0, match[1].length).some(isToken))
|
|
1919
|
+
return;
|
|
1920
|
+
const length = graphemes(match[1]).length;
|
|
1921
|
+
this.skillChip = match[1];
|
|
1922
|
+
this.value.splice(0, length, SKILL_TOKEN);
|
|
1923
|
+
this.cursor = Math.max(1, this.cursor - length + 1);
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
|
|
1927
|
+
* one keystroke, so a picked skill comes out as it went in.
|
|
1928
|
+
*/
|
|
1929
|
+
backspace() {
|
|
1930
|
+
if (this.cursor === 2 && this.value[0] === SKILL_TOKEN && this.value[1] === ' ') {
|
|
1931
|
+
this.removeDraft(0, 2);
|
|
1932
|
+
this.cursor = 0;
|
|
1933
|
+
return;
|
|
1934
|
+
}
|
|
1935
|
+
if (this.cursor)
|
|
1936
|
+
this.removeDraft(--this.cursor, 1);
|
|
1937
|
+
}
|
|
1938
|
+
deleteForward() {
|
|
1939
|
+
if (this.cursor === 0 && this.value[0] === SKILL_TOKEN) {
|
|
1940
|
+
this.removeDraft(0, this.value[1] === ' ' ? 2 : 1);
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
this.removeDraft(this.cursor, 1);
|
|
1944
|
+
}
|
|
1883
1945
|
/** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
|
|
1884
1946
|
takeAttachments() { const queued = this.attachments.map(entry => entry.pending); this.attachments = []; this.scheduleRender(); return queued; }
|
|
1885
1947
|
/** The amber label a token draws as in the composer. */
|
|
@@ -1899,6 +1961,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
1899
1961
|
if (this.pending?.secret)
|
|
1900
1962
|
return this.value.map(() => '*');
|
|
1901
1963
|
const labels = new Map(this.attachments.map(entry => [entry.marker, clip(this.tokenLabel(entry), Math.max(1, width))]));
|
|
1964
|
+
if (this.skillChip)
|
|
1965
|
+
labels.set(SKILL_TOKEN, clip(this.skillChip, Math.max(1, width)));
|
|
1902
1966
|
return this.value.map(part => labels.get(part) ?? (isToken(part) ? '' : part));
|
|
1903
1967
|
}
|
|
1904
1968
|
/**
|
|
@@ -1910,22 +1974,36 @@ export class TerminalUI extends EventEmitter {
|
|
|
1910
1974
|
submittedDraft() {
|
|
1911
1975
|
const order = new Map(this.value.map((part, index) => [part, index]));
|
|
1912
1976
|
this.attachments.sort((left, right) => (order.get(left.marker) ?? Infinity) - (order.get(right.marker) ?? Infinity));
|
|
1913
|
-
const
|
|
1977
|
+
const draft = this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part);
|
|
1978
|
+
const typed = draft.filter(part => !isToken(part)).join('');
|
|
1914
1979
|
if (!typed.trim())
|
|
1915
1980
|
return '';
|
|
1916
1981
|
if (typed.trimStart().startsWith('/'))
|
|
1917
1982
|
return typed.trimStart();
|
|
1918
1983
|
const names = new Map(this.attachments.map(({ marker, pending }) => [marker, `[${pending.kind === 'file' ? pending.path : pending.name}]`]));
|
|
1919
|
-
return
|
|
1984
|
+
return draft.map(part => isToken(part) ? names.get(part) ?? '' : part).join('');
|
|
1920
1985
|
}
|
|
1986
|
+
/**
|
|
1987
|
+
* The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
|
|
1988
|
+
* written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
|
|
1989
|
+
* not survive the trip, and the draft would lose the skill it names.
|
|
1990
|
+
*/
|
|
1991
|
+
parkedDraft() { return this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part).join(''); }
|
|
1921
1992
|
/** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
|
|
1922
1993
|
restoredDraft(text) {
|
|
1923
1994
|
const live = new Set(this.attachments.map(entry => entry.marker));
|
|
1924
|
-
|
|
1995
|
+
const parts = composerGraphemes(text).filter(part => !isToken(part) || live.has(part));
|
|
1996
|
+
const match = /^(\/\S+)(?=\s|$)/.exec(parts.join(''));
|
|
1997
|
+
if (!match || !this.skillCommand(match[1]))
|
|
1998
|
+
return parts;
|
|
1999
|
+
this.skillChip = match[1];
|
|
2000
|
+
return [SKILL_TOKEN, ...parts.slice(graphemes(match[1]).length)];
|
|
1925
2001
|
}
|
|
1926
2002
|
/** Remove draft elements, dropping the attachment behind every token they held. */
|
|
1927
2003
|
removeDraft(start, count) {
|
|
1928
2004
|
const removed = new Set(this.value.splice(start, count).filter(isToken));
|
|
2005
|
+
if (removed.has(SKILL_TOKEN))
|
|
2006
|
+
this.skillChip = undefined;
|
|
1929
2007
|
if (removed.size)
|
|
1930
2008
|
this.attachments = this.attachments.filter(entry => !removed.has(entry.marker));
|
|
1931
2009
|
}
|
|
@@ -2120,6 +2198,11 @@ export class TerminalUI extends EventEmitter {
|
|
|
2120
2198
|
// substituted text is submitted, echoed and recorded exactly as if it had been typed.
|
|
2121
2199
|
if ((key.name === 'return' || key.name === 'enter') && !key.meta && !key.shift) {
|
|
2122
2200
|
const selected = this.selectedCompletion();
|
|
2201
|
+
if (selected && this.skillCommand(selected)) {
|
|
2202
|
+
this.insertSkillChip(selected);
|
|
2203
|
+
this.scheduleRender();
|
|
2204
|
+
return;
|
|
2205
|
+
}
|
|
2123
2206
|
if (selected) {
|
|
2124
2207
|
this.value = graphemes(selected);
|
|
2125
2208
|
this.cursor = this.value.length;
|
|
@@ -2241,12 +2324,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
2241
2324
|
while (this.cursor < this.value.length && this.value[this.cursor] !== '\n')
|
|
2242
2325
|
this.cursor++;
|
|
2243
2326
|
}
|
|
2244
|
-
else if (key.name === 'backspace')
|
|
2245
|
-
|
|
2246
|
-
this.removeDraft(--this.cursor, 1);
|
|
2247
|
-
}
|
|
2327
|
+
else if (key.name === 'backspace')
|
|
2328
|
+
this.backspace();
|
|
2248
2329
|
else if (key.name === 'delete')
|
|
2249
|
-
this.
|
|
2330
|
+
this.deleteForward();
|
|
2250
2331
|
else if (key.name === 'up' || key.name === 'down')
|
|
2251
2332
|
this.navigate(key.name === 'up' ? -1 : 1);
|
|
2252
2333
|
else if (key.name === 'tab')
|
|
@@ -2339,12 +2420,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
2339
2420
|
while (this.cursor < this.value.length && this.value[this.cursor] !== '\n')
|
|
2340
2421
|
this.cursor++;
|
|
2341
2422
|
}
|
|
2342
|
-
else if (key.name === 'backspace')
|
|
2343
|
-
|
|
2344
|
-
this.removeDraft(--this.cursor, 1);
|
|
2345
|
-
}
|
|
2423
|
+
else if (key.name === 'backspace')
|
|
2424
|
+
this.backspace();
|
|
2346
2425
|
else if (key.name === 'delete')
|
|
2347
|
-
this.
|
|
2426
|
+
this.deleteForward();
|
|
2348
2427
|
else if (key.name === 'up' || key.name === 'down')
|
|
2349
2428
|
this.navigate(key.name === 'up' ? -1 : 1);
|
|
2350
2429
|
else if (key.name === 'tab')
|
|
@@ -2401,7 +2480,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2401
2480
|
// scroll, so there is no exhaustion heuristic reconciling the two gestures.
|
|
2402
2481
|
if (this.pending?.history) {
|
|
2403
2482
|
if (this.historyIndex === this.history.length)
|
|
2404
|
-
this.draft = this.
|
|
2483
|
+
this.draft = this.parkedDraft();
|
|
2405
2484
|
this.historyIndex = historyAt;
|
|
2406
2485
|
this.value = this.restoredDraft(this.history[this.historyIndex] ?? this.draft);
|
|
2407
2486
|
this.cursor = this.value.length;
|
|
@@ -2492,12 +2571,28 @@ export class TerminalUI extends EventEmitter {
|
|
|
2492
2571
|
* The system writer is preferred; without one, or when it fails, an OSC 52 sequence asks
|
|
2493
2572
|
* the terminal to set the clipboard instead.
|
|
2494
2573
|
*/
|
|
2574
|
+
/**
|
|
2575
|
+
* Put text on the clipboard of whoever is looking at this terminal.
|
|
2576
|
+
*
|
|
2577
|
+
* `terminalOnly` skips the system writer for an OSC 52 sequence alone: over SSH the system
|
|
2578
|
+
* clipboard belongs to the remote host, while the terminal's is the one on the user's own machine.
|
|
2579
|
+
*/
|
|
2580
|
+
copyText(text, options = {}) {
|
|
2581
|
+
const osc52 = () => { if (this.started && !this.closed)
|
|
2582
|
+
this.output.write(`\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`); };
|
|
2583
|
+
if (this.clipboardTextWriter && !options.terminalOnly)
|
|
2584
|
+
void this.clipboardTextWriter(text).catch(osc52);
|
|
2585
|
+
else
|
|
2586
|
+
osc52();
|
|
2587
|
+
}
|
|
2495
2588
|
copySelection(cut) {
|
|
2496
2589
|
const range = this.selectionRange();
|
|
2497
2590
|
if (!range)
|
|
2498
2591
|
return;
|
|
2499
2592
|
// A token copies as what it stands for: the pasted text itself, a file's path, an image's name.
|
|
2500
2593
|
const tokens = new Map(this.attachments.map(({ marker, pending }) => [marker, pending.kind === 'text' ? pending.content : pending.kind === 'file' ? pending.path : `[${pending.name}]`]));
|
|
2594
|
+
if (this.skillChip)
|
|
2595
|
+
tokens.set(SKILL_TOKEN, this.skillChip);
|
|
2501
2596
|
const text = this.value.slice(range[0], range[1]).map(part => tokens.get(part) ?? part).join('');
|
|
2502
2597
|
const osc52 = () => { if (this.started && !this.closed)
|
|
2503
2598
|
this.output.write(`\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`); };
|
|
@@ -2510,10 +2605,13 @@ export class TerminalUI extends EventEmitter {
|
|
|
2510
2605
|
this.scheduleRender();
|
|
2511
2606
|
}
|
|
2512
2607
|
complete() { this.dismissedCompletion = undefined; const completion = this.commandMatches(true); const selected = completion?.options[completion.index]; if (!selected)
|
|
2513
|
-
return; if (
|
|
2608
|
+
return; if (this.skillCommand(selected)) {
|
|
2609
|
+
this.insertSkillChip(selected);
|
|
2610
|
+
return;
|
|
2611
|
+
} if (argumentRequired.has(selected)) {
|
|
2514
2612
|
this.awaitArgument(selected);
|
|
2515
2613
|
return;
|
|
2516
|
-
} this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
|
|
2614
|
+
} this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected, this.skillCommands.map(skill => skill.command)); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
|
|
2517
2615
|
/** Put `command ` in the composer and open its argument list, without submitting anything. */
|
|
2518
2616
|
awaitArgument(command) { this.value = graphemes(`${command} `); this.cursor = this.value.length; this.completion = undefined; this.dismissedCompletion = undefined; }
|
|
2519
2617
|
/**
|
|
@@ -2548,7 +2646,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2548
2646
|
if (this.pending?.secret || (!this.pending?.conversationPrompt && !this.runInputHandler) || this.modal || query === this.dismissedCompletion || !completable(query))
|
|
2549
2647
|
return undefined;
|
|
2550
2648
|
if (this.completion?.query !== query)
|
|
2551
|
-
this.completion = { query, options: completionOptions(query), index: 0 };
|
|
2649
|
+
this.completion = { query, options: completionOptions(query, this.skillCommands.map(skill => skill.command)), index: 0 };
|
|
2552
2650
|
if (visibleOnly) {
|
|
2553
2651
|
const width = this.chatColumns(), height = Math.max(1, this.output.rows || 24);
|
|
2554
2652
|
const inputRows = Math.min(editor(this.visibleDraft(width - 4), Math.max(1, width - 4)).lines.length, Math.min(6, Math.max(1, height - 9)));
|
|
@@ -2627,7 +2725,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2627
2725
|
const available = Math.max(1, width - 4); // the transcript adds two columns of inset
|
|
2628
2726
|
const graph = status.graph;
|
|
2629
2727
|
const selected = status.graphSelection ?? (graph?.id === 'software-engineer' ? 'default' : graph?.id);
|
|
2630
|
-
const graphName = selected === 'default' ? 'Default ·
|
|
2728
|
+
const graphName = selected === 'default' ? 'Default · Andorra Agent' : oneLine(graph?.name ?? 'Not selected');
|
|
2631
2729
|
const nodes = graph ? Object.keys(graph.nodes).length : 0;
|
|
2632
2730
|
const nodeCount = graph && selected !== 'default' ? ` · ${nodes} ${nodes === 1 ? 'node' : 'nodes'}` : '';
|
|
2633
2731
|
const activity = oneLine(status.activity || 'Ready');
|
|
@@ -2931,7 +3029,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2931
3029
|
for (let index = 0; index < popupRows; index++) {
|
|
2932
3030
|
const item = completion.options[first + index];
|
|
2933
3031
|
const selected = !!item && first + index === completion.index;
|
|
2934
|
-
const label = item ? `${selected ? '›' : ' '} ${item} ${commandDescriptions[item]}` : 'No matching commands';
|
|
3032
|
+
const label = item ? `${selected ? '›' : ' '} ${item} ${commandDescriptions[item] ?? this.skillCommands.find(skill => skill.command === item)?.description ?? ''}` : 'No matching commands';
|
|
2935
3033
|
const value = pad(label, cardWidth - 4);
|
|
2936
3034
|
lines.push(paint(' │ ', GRAY) + (selected ? `\x1b[48;5;236m${paint(value, DIM)}\x1b[0m` : paint(value)) + paint(' │', GRAY));
|
|
2937
3035
|
}
|
package/dist/src/timers.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ export interface WakeCarry {
|
|
|
59
59
|
input?: Record<string, unknown>;
|
|
60
60
|
state?: Record<string, unknown>;
|
|
61
61
|
}
|
|
62
|
+
/** Which attempt, and which node of its graph, armed a wake. */
|
|
63
|
+
export interface WakeOrigin {
|
|
64
|
+
runId: string;
|
|
65
|
+
nodeId: string;
|
|
66
|
+
}
|
|
62
67
|
export interface ArmedTimer {
|
|
63
68
|
id: string;
|
|
64
69
|
/** The prompt delivered when the timer fires, exactly as the agent submitted it. */
|
|
@@ -76,6 +81,16 @@ export interface ArmedTimer {
|
|
|
76
81
|
owner?: string;
|
|
77
82
|
/** What the run that armed this wake was started with, so its delivery can start the same kind of run. */
|
|
78
83
|
carry?: WakeCarry;
|
|
84
|
+
/**
|
|
85
|
+
* The attempt and graph node that armed this wake, when a graph node armed it.
|
|
86
|
+
*
|
|
87
|
+
* A wake is the arming node's own reminder about the work it was doing, so it is delivered back to that
|
|
88
|
+
* work: into the node while its run is still going, or as a continuation of the attempt from that node's
|
|
89
|
+
* checkpoint once the attempt stopped. It is never a new task that enters the graph at its entry node.
|
|
90
|
+
* A wake without it - armed by a surface that runs no graph node, or held from before the field existed -
|
|
91
|
+
* is delivered the way such wakes always were.
|
|
92
|
+
*/
|
|
93
|
+
origin?: WakeOrigin;
|
|
79
94
|
/**
|
|
80
95
|
* Earliest epoch milliseconds at which a drain may take this wake, set when a delivery hands it back.
|
|
81
96
|
*
|
|
@@ -118,11 +133,15 @@ export declare class TimerRegistry {
|
|
|
118
133
|
* wait it is still waiting on — and, for an engine, that it still owns the wake the run has not yet carried.
|
|
119
134
|
*/
|
|
120
135
|
list(owner?: string): ArmedTimer[];
|
|
136
|
+
/** One armed wake by id, whether or not a delivery holds it. */
|
|
137
|
+
get(id: string): ArmedTimer | undefined;
|
|
121
138
|
/** A wake in hand: taken for delivery, and still owed until {@link settle} or {@link restore} says otherwise. */
|
|
122
139
|
private held;
|
|
140
|
+
/** Whether a delivery has taken this wake and not yet said what became of it. */
|
|
141
|
+
isHeld(id: string): boolean;
|
|
123
142
|
/** The earliest epoch milliseconds at which a drain may take this wake again. */
|
|
124
143
|
private nextTakeAt;
|
|
125
|
-
arm(seconds: number, prompt: string, owner?: string, carry?: WakeCarry): ArmedTimer;
|
|
144
|
+
arm(seconds: number, prompt: string, owner?: string, carry?: WakeCarry, origin?: WakeOrigin): ArmedTimer;
|
|
126
145
|
/**
|
|
127
146
|
* Arm (or re-arm) the one wake-up for a timer.
|
|
128
147
|
*
|
|
@@ -147,7 +166,7 @@ export declare class TimerRegistry {
|
|
|
147
166
|
* answers for a session the moment its deadline passes and the run only later, this is the difference between
|
|
148
167
|
* a reload finding the wake it must keep routing to that engine, and a reload concluding nothing is owed.
|
|
149
168
|
*/
|
|
150
|
-
takeDueOne(now?: number, owner?: string): ArmedTimer | undefined;
|
|
169
|
+
takeDueOne(now?: number, owner?: string, accept?: (timer: ArmedTimer) => boolean): ArmedTimer | undefined;
|
|
151
170
|
/**
|
|
152
171
|
* Say a taken wake has been delivered or spent: it is no longer owed, and no longer waits.
|
|
153
172
|
*
|
package/dist/src/timers.js
CHANGED
|
@@ -73,15 +73,23 @@ export class TimerRegistry {
|
|
|
73
73
|
return (owner === undefined ? waiting : waiting.filter(timer => timer.owner === owner))
|
|
74
74
|
.sort((left, right) => left.fireAt - right.fireAt);
|
|
75
75
|
}
|
|
76
|
+
/** One armed wake by id, whether or not a delivery holds it. */
|
|
77
|
+
get(id) {
|
|
78
|
+
return this.armed.get(id)?.timer;
|
|
79
|
+
}
|
|
76
80
|
/** A wake in hand: taken for delivery, and still owed until {@link settle} or {@link restore} says otherwise. */
|
|
77
81
|
held(timer) {
|
|
78
82
|
return this.armed.get(timer.id)?.held === true;
|
|
79
83
|
}
|
|
84
|
+
/** Whether a delivery has taken this wake and not yet said what became of it. */
|
|
85
|
+
isHeld(id) {
|
|
86
|
+
return this.armed.get(id)?.held === true;
|
|
87
|
+
}
|
|
80
88
|
/** The earliest epoch milliseconds at which a drain may take this wake again. */
|
|
81
89
|
nextTakeAt(timer) {
|
|
82
90
|
return Math.max(timer.fireAt, timer.notBefore ?? 0);
|
|
83
91
|
}
|
|
84
|
-
arm(seconds, prompt, owner, carry) {
|
|
92
|
+
arm(seconds, prompt, owner, carry, origin) {
|
|
85
93
|
if (typeof seconds !== 'number' || !Number.isSafeInteger(seconds) || seconds < MIN_TIMER_SECONDS || seconds > MAX_TIMER_SECONDS) {
|
|
86
94
|
throw new Error(`seconds must be an integer from ${MIN_TIMER_SECONDS} to ${MAX_TIMER_SECONDS}`);
|
|
87
95
|
}
|
|
@@ -94,7 +102,7 @@ export class TimerRegistry {
|
|
|
94
102
|
// Cloned, because the run keeps working with the objects it handed here: a wake must not see a scope that
|
|
95
103
|
// its arming run mutated after the prompt was armed.
|
|
96
104
|
const stored = carry === undefined || Object.keys(carry).length === 0 ? undefined : structuredClone(carry);
|
|
97
|
-
const timer = { id: randomUUID(), prompt: prompt.trim(), seconds, fireAt: Date.now() + seconds * 1_000, ...(owner === undefined ? {} : { owner }), ...(stored === undefined ? {} : { carry: stored }) };
|
|
105
|
+
const timer = { id: randomUUID(), prompt: prompt.trim(), seconds, fireAt: Date.now() + seconds * 1_000, ...(owner === undefined ? {} : { owner }), ...(stored === undefined ? {} : { carry: stored }), ...(origin === undefined ? {} : { origin: { runId: origin.runId, nodeId: origin.nodeId } }) };
|
|
98
106
|
const entry = { timer };
|
|
99
107
|
this.schedule(timer, entry, seconds * 1_000);
|
|
100
108
|
this.armed.set(timer.id, entry);
|
|
@@ -135,8 +143,8 @@ export class TimerRegistry {
|
|
|
135
143
|
* answers for a session the moment its deadline passes and the run only later, this is the difference between
|
|
136
144
|
* a reload finding the wake it must keep routing to that engine, and a reload concluding nothing is owed.
|
|
137
145
|
*/
|
|
138
|
-
takeDueOne(now = Date.now(), owner) {
|
|
139
|
-
const next = this.list(owner).find(timer => this.nextTakeAt(timer) <= now && !this.held(timer));
|
|
146
|
+
takeDueOne(now = Date.now(), owner, accept) {
|
|
147
|
+
const next = this.list(owner).find(timer => this.nextTakeAt(timer) <= now && !this.held(timer) && (accept === undefined || accept(timer)));
|
|
140
148
|
if (next === undefined)
|
|
141
149
|
return undefined;
|
|
142
150
|
const entry = this.armed.get(next.id);
|
|
@@ -10,6 +10,10 @@ export function requiresToolBarrier(name, tool) {
|
|
|
10
10
|
// The caller must explicitly classify only those actions as parallel.
|
|
11
11
|
if (name === 'AsyncProcess' && tool?.executionMode === 'parallel')
|
|
12
12
|
return false;
|
|
13
|
+
// web_search rides the browser capability for policy, but only sends a query to a search service:
|
|
14
|
+
// it changes no page, file or session, so independent searches may overlap each other and reads.
|
|
15
|
+
if (name === 'web_search' && tool?.executionMode === 'parallel')
|
|
16
|
+
return false;
|
|
13
17
|
if (tool?.executionMode === 'sequential' || SEQUENTIAL.has(name))
|
|
14
18
|
return true;
|
|
15
19
|
return !!tool?.capability && !READ_CAPABILITIES.has(tool.capability);
|
package/dist/src/tool-names.d.ts
CHANGED
|
@@ -11,6 +11,24 @@ export declare function canonicalCodingToolName(name: string): CanonicalCodingTo
|
|
|
11
11
|
export declare function canonicalToolName(name: string): string;
|
|
12
12
|
export declare function toolNameMatches(configured: string, actual: string): boolean;
|
|
13
13
|
export declare function canonicalizeToolList(names: readonly string[] | undefined): string[] | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Rewrites the tool names one provider request sees and restores Andorra's names on everything
|
|
16
|
+
* that comes back. Canonical Andorra tool names use dots (`qa.fast`, `browser.panel`), while
|
|
17
|
+
* strict providers validate `function.name` against `^[a-zA-Z0-9_-]+$` and reject the whole
|
|
18
|
+
* request with an HTTP 400. The provider-side names are a pure transport encoding: journals,
|
|
19
|
+
* the executor and the desktop keep the canonical spellings.
|
|
20
|
+
*/
|
|
21
|
+
export interface ProviderToolNameCodec {
|
|
22
|
+
encode(name: string): string;
|
|
23
|
+
decode(name: string): string;
|
|
24
|
+
}
|
|
25
|
+
/** Encode a request's tool list for the provider and pair it with the matching name codec. */
|
|
26
|
+
export declare function encodeProviderToolNames<T extends {
|
|
27
|
+
name: string;
|
|
28
|
+
}>(tools: readonly T[]): {
|
|
29
|
+
tools: T[];
|
|
30
|
+
codec: ProviderToolNameCodec;
|
|
31
|
+
};
|
|
14
32
|
export declare const LEGACY_CODING_TOOL_NAMES: readonly string[];
|
|
15
33
|
/** Translate historical Pi/Andorra tool arguments into the canonical coding-tool contract. */
|
|
16
34
|
export declare function adaptLegacyCodingToolArguments(name: string, args: Record<string, unknown>): Record<string, unknown>;
|
package/dist/src/tool-names.js
CHANGED
|
@@ -32,6 +32,32 @@ export function canonicalizeToolList(names) {
|
|
|
32
32
|
return undefined;
|
|
33
33
|
return [...new Set(names.map(canonicalToolName))];
|
|
34
34
|
}
|
|
35
|
+
/** Characters provider tool-name validators (OpenAI-compatible endpoints, Messages API) reject. */
|
|
36
|
+
const UNSAFE_TOOL_NAME_CHARS = /[^a-zA-Z0-9_-]/g;
|
|
37
|
+
/** Encode a request's tool list for the provider and pair it with the matching name codec. */
|
|
38
|
+
export function encodeProviderToolNames(tools) {
|
|
39
|
+
const byEncoded = new Map();
|
|
40
|
+
const byOriginal = new Map();
|
|
41
|
+
const sanitized = (name) => name.replace(UNSAFE_TOOL_NAME_CHARS, '_');
|
|
42
|
+
const list = tools.map(tool => {
|
|
43
|
+
const base = sanitized(tool.name);
|
|
44
|
+
let encoded = base;
|
|
45
|
+
for (let n = 2; byEncoded.has(encoded); n++)
|
|
46
|
+
encoded = `${base}_${n}`;
|
|
47
|
+
byEncoded.set(encoded, tool.name);
|
|
48
|
+
byOriginal.set(tool.name, encoded);
|
|
49
|
+
return { ...tool, name: encoded };
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
tools: list,
|
|
53
|
+
codec: {
|
|
54
|
+
// History can hold calls for tools this request no longer advertises; those still must
|
|
55
|
+
// not carry rejected characters, even though their response aliases cannot be decoded.
|
|
56
|
+
encode: name => byOriginal.get(name) ?? sanitized(name),
|
|
57
|
+
decode: name => byEncoded.get(name) ?? name,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
35
61
|
export const LEGACY_CODING_TOOL_NAMES = Object.freeze(Object.keys(ALIASES).filter(name => !CANONICAL_CODING_TOOLS.includes(name)));
|
|
36
62
|
function escapeRegexLiteral(value) {
|
|
37
63
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
package/dist/src/tools.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { Tool, ToolContext } from './types.js';
|
|
2
|
+
export declare function within(root: string, target: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The paths among `names` (relative to `base`) where a write needs approval under workspace rules:
|
|
5
|
+
* outside the workspace, or inside it under protected repository/runtime metadata.
|
|
6
|
+
*/
|
|
7
|
+
export declare function classifyWorkspaceWrites(workspace: string, base: string, names: readonly string[]): Promise<{
|
|
8
|
+
outside: string[];
|
|
9
|
+
protected: string[];
|
|
10
|
+
}>;
|
|
2
11
|
export declare function authorize(name: string, args: Record<string, unknown>, context: ToolContext): Promise<void>;
|
|
3
12
|
export declare function createTools(): Tool[];
|