@apolloyh/apollo-agent 0.2.0 → 0.2.1
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/brand.d.ts +2 -2
- package/dist/brand.js +2 -2
- package/dist/coordinator/workflow.d.ts.map +1 -1
- package/dist/coordinator/workflow.js +6 -5
- package/dist/goal/goal-mode.d.ts +0 -4
- package/dist/goal/goal-mode.d.ts.map +1 -1
- package/dist/goal/goal-mode.js +6 -5
- package/dist/index.js +17 -12
- package/dist/runtime/permissions.d.ts.map +1 -1
- package/dist/runtime/permissions.js +5 -4
- package/dist/runtime/query-engine.d.ts +3 -1
- package/dist/runtime/query-engine.d.ts.map +1 -1
- package/dist/runtime/query-engine.js +9 -1
- package/dist/sdk.d.ts +4 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +2 -0
- package/dist/status-ui.d.ts +1 -10
- package/dist/status-ui.d.ts.map +1 -1
- package/dist/status-ui.js +9 -7
- package/dist/terminal-theme.d.ts +45 -0
- package/dist/terminal-theme.d.ts.map +1 -0
- package/dist/terminal-theme.js +47 -0
- package/dist/thought-fold.d.ts.map +1 -1
- package/dist/thought-fold.js +3 -5
- package/dist/tools/builtin.js +1 -1
- package/dist/tools/registry.d.ts +1 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +3 -0
- package/dist/trace.d.ts +2 -0
- package/dist/trace.d.ts.map +1 -1
- package/dist/trace.js +56 -30
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/sdk.md +44 -0
- package/package.json +2 -1
package/dist/brand.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Product identity — single source of truth for display strings. */
|
|
2
2
|
export declare const PRODUCT: {
|
|
3
3
|
readonly name: "Apollo";
|
|
4
|
-
readonly version: "0.2.
|
|
4
|
+
readonly version: "0.2.1";
|
|
5
5
|
readonly tagline: "Your personal agent — answer first, act when needed.";
|
|
6
6
|
readonly packageName: "@apolloyh/apollo-agent";
|
|
7
|
-
readonly userAgent: "ApolloAgent/0.
|
|
7
|
+
readonly userAgent: "ApolloAgent/0.2";
|
|
8
8
|
readonly prompt: "apollo";
|
|
9
9
|
};
|
|
10
10
|
/**
|
package/dist/brand.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Product identity — single source of truth for display strings. */
|
|
2
2
|
export const PRODUCT = {
|
|
3
3
|
name: "Apollo",
|
|
4
|
-
version: "0.2.
|
|
4
|
+
version: "0.2.1",
|
|
5
5
|
tagline: "Your personal agent — answer first, act when needed.",
|
|
6
6
|
packageName: "@apolloyh/apollo-agent",
|
|
7
|
-
userAgent: "ApolloAgent/0.
|
|
7
|
+
userAgent: "ApolloAgent/0.2",
|
|
8
8
|
prompt: "apollo",
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/coordinator/workflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/coordinator/workflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGjE,MAAM,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAI,GAAG,aAAa,CAY1E;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAgC3E;AAED,wBAAgB,cAAc,CAC5B,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,EACvC,OAAO,CAAC,EAAE,MAAM,GACf,aAAa,CAcf;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,aAAa,GAAG,qBAAqB,GAAG,SAAS,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,CAqB7D;AAED,+CAA+C;AAC/C,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAgCnF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TERMINAL_ANSI } from "../terminal-theme.js";
|
|
1
2
|
export function createWorkflow(goal, maxRetries = 2) {
|
|
2
3
|
return {
|
|
3
4
|
goal,
|
|
@@ -12,12 +13,12 @@ export function createWorkflow(goal, maxRetries = 2) {
|
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
export function workflowStatusBar(wf, color) {
|
|
15
|
-
const dim = color ?
|
|
16
|
+
const dim = color ? TERMINAL_ANSI.inactive : "";
|
|
16
17
|
const reset = color ? "\x1b[0m" : "";
|
|
17
|
-
const green = color ?
|
|
18
|
-
const red = color ?
|
|
19
|
-
const blue = color ?
|
|
20
|
-
const yellow = color ?
|
|
18
|
+
const green = color ? TERMINAL_ANSI.success : "";
|
|
19
|
+
const red = color ? TERMINAL_ANSI.error : "";
|
|
20
|
+
const blue = color ? TERMINAL_ANSI.permission : "";
|
|
21
|
+
const yellow = color ? TERMINAL_ANSI.warning : "";
|
|
21
22
|
const parts = wf.phases.map((p) => {
|
|
22
23
|
let mark = "○";
|
|
23
24
|
let c = dim;
|
package/dist/goal/goal-mode.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goal mode — pursue a user goal until done (open-ended autonomous loop).
|
|
3
|
-
* Differs from fixed 4-phase workflow: steps are free-form; exit via markers or /goal stop.
|
|
4
|
-
*/
|
|
5
1
|
export type GoalStatus = "active" | "completed" | "failed" | "blocked" | "paused";
|
|
6
2
|
export type GoalState = {
|
|
7
3
|
goal: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-mode.d.ts","sourceRoot":"","sources":["../../src/goal/goal-mode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"goal-mode.d.ts","sourceRoot":"","sources":["../../src/goal/goal-mode.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAElF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,SAAK,EAAE,QAAQ,GAAE,MAAM,EAAO,GAAG,SAAS,CAU/F;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAsClE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CA2CpD;AAED,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAiCtE;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,SAAS,GAAG,OAAO,CAExD;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAO3D"}
|
package/dist/goal/goal-mode.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Goal mode — pursue a user goal until done (open-ended autonomous loop).
|
|
3
3
|
* Differs from fixed 4-phase workflow: steps are free-form; exit via markers or /goal stop.
|
|
4
4
|
*/
|
|
5
|
+
import { TERMINAL_ANSI } from "../terminal-theme.js";
|
|
5
6
|
export function createGoal(goal, maxIterations = 12, criteria = []) {
|
|
6
7
|
return {
|
|
7
8
|
goal: goal.trim(),
|
|
@@ -14,12 +15,12 @@ export function createGoal(goal, maxIterations = 12, criteria = []) {
|
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
export function goalStatusBar(g, color) {
|
|
17
|
-
const dim = color ?
|
|
18
|
+
const dim = color ? TERMINAL_ANSI.inactive : "";
|
|
18
19
|
const reset = color ? "\x1b[0m" : "";
|
|
19
|
-
const green = color ?
|
|
20
|
-
const red = color ?
|
|
21
|
-
const yellow = color ?
|
|
22
|
-
const blue = color ?
|
|
20
|
+
const green = color ? TERMINAL_ANSI.success : "";
|
|
21
|
+
const red = color ? TERMINAL_ANSI.error : "";
|
|
22
|
+
const yellow = color ? TERMINAL_ANSI.warning : "";
|
|
23
|
+
const blue = color ? TERMINAL_ANSI.permission : "";
|
|
23
24
|
let mark = "◉";
|
|
24
25
|
let c = yellow;
|
|
25
26
|
if (g.status === "completed") {
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createCliApprovalProvider } from "./runtime/permissions.js";
|
|
|
11
11
|
import { formatResumeTime, moveResumeSelection, resumeHistoryEntries } from "./session/resume-ui.js";
|
|
12
12
|
import { formatOutcomeLine, formatWaitLine, STATUS_TICK_MS } from "./status-ui.js";
|
|
13
13
|
import { ThoughtFoldManager } from "./thought-fold.js";
|
|
14
|
+
import { TERMINAL_ANSI } from "./terminal-theme.js";
|
|
14
15
|
import { workflowStatusBar } from "./coordinator/workflow.js";
|
|
15
16
|
import { CliTraceRenderer, stripTerminalEscapes } from "./trace.js";
|
|
16
17
|
let activeCliInput;
|
|
@@ -630,7 +631,7 @@ async function pickSessionWithArrows(sessions) {
|
|
|
630
631
|
const marker = active ? "›" : " ";
|
|
631
632
|
const title = truncateDisplay(session.title || "untitled", Math.min(42, width));
|
|
632
633
|
const line = `${marker} ${title} ${formatResumeTime(session.updatedAt)} ${session.id}`;
|
|
633
|
-
lines.push(active ? `\x1b[
|
|
634
|
+
lines.push(active ? `\x1b[1m${TERMINAL_ANSI.permission}${line}\x1b[0m` : line);
|
|
634
635
|
}
|
|
635
636
|
lines.push("", "↑/↓ select · Enter resume · Esc cancel");
|
|
636
637
|
stdout.write(`${lines.join("\n")}\n`);
|
|
@@ -671,7 +672,7 @@ function renderResumedHistory(snapshot, color) {
|
|
|
671
672
|
if (!entries.length)
|
|
672
673
|
return;
|
|
673
674
|
const dim = color ? "\x1b[2m" : "";
|
|
674
|
-
const blue = color ?
|
|
675
|
+
const blue = color ? TERMINAL_ANSI.permission : "";
|
|
675
676
|
const reset = color ? "\x1b[0m" : "";
|
|
676
677
|
stdout.write(`\n${dim}Conversation history · ${entries.length} entries${reset}\n\n`);
|
|
677
678
|
const historyRenderer = new CliTraceRenderer({
|
|
@@ -994,7 +995,7 @@ function startTurnInput(runtime, color, history, pendingMessages) {
|
|
|
994
995
|
async function readCliLine(options) {
|
|
995
996
|
if (!stdin.isTTY || !stdout.isTTY) {
|
|
996
997
|
const p = PRODUCT.prompt;
|
|
997
|
-
stdout.write(options.color ?
|
|
998
|
+
stdout.write(options.color ? `${TERMINAL_ANSI.brandBlue}${p}>\x1b[0m ` : `${p}> `);
|
|
998
999
|
return readStdinLine();
|
|
999
1000
|
}
|
|
1000
1001
|
let buffer = "";
|
|
@@ -1077,7 +1078,11 @@ async function readCliLine(options) {
|
|
|
1077
1078
|
stdout.write(lines.join("\n"));
|
|
1078
1079
|
renderedLines = lines.length;
|
|
1079
1080
|
const view = renderInputView(buffer, cursor, inputContentWidth(), pastedTextBlocks);
|
|
1080
|
-
|
|
1081
|
+
const statusRows = renderLiveStatusLine(options.color) ? 1 : 0;
|
|
1082
|
+
const thinkingRows = liveStatus?.text === "Thinking" && liveThinkingPreview
|
|
1083
|
+
? renderLiveThinkingLines(liveThinkingPreview, options.color).length
|
|
1084
|
+
: 0;
|
|
1085
|
+
renderedCursorLine = statusRows + thinkingRows + 1 + view.cursorLine;
|
|
1081
1086
|
const rowsBelowInput = lines.length - 1 - renderedCursorLine;
|
|
1082
1087
|
stdout.write(`\x1b[${rowsBelowInput}A\r\x1b[${3 + view.cursorWidth}G`);
|
|
1083
1088
|
stdout.write(options.queueMode && !buffer ? "\x1b[?25l" : "\x1b[?25h");
|
|
@@ -1387,7 +1392,7 @@ async function askChoice(prompt, choices, initial, color) {
|
|
|
1387
1392
|
let selected = Math.max(0, Math.min(initial, choices.length - 1));
|
|
1388
1393
|
let renderedLines = 0;
|
|
1389
1394
|
const previousRawMode = stdin.isRaw;
|
|
1390
|
-
const blue = color ?
|
|
1395
|
+
const blue = color ? `\x1b[1m${TERMINAL_ANSI.permission}` : "";
|
|
1391
1396
|
const dim = color ? "\x1b[90m" : "";
|
|
1392
1397
|
const reset = color ? "\x1b[0m" : "";
|
|
1393
1398
|
const clear = () => {
|
|
@@ -1479,10 +1484,10 @@ async function readStdinLine() {
|
|
|
1479
1484
|
}
|
|
1480
1485
|
function renderSlashCommandMenu(useColor) {
|
|
1481
1486
|
const width = Math.max(...slashCommands.map((c) => displayLength(c.usage)));
|
|
1482
|
-
const title = useColor ?
|
|
1487
|
+
const title = useColor ? `${TERMINAL_ANSI.permission}Slash commands\x1b[0m` : "Slash commands";
|
|
1483
1488
|
const rows = slashCommands
|
|
1484
1489
|
.map((command) => {
|
|
1485
|
-
const usage = useColor ?
|
|
1490
|
+
const usage = useColor ? `${TERMINAL_ANSI.permission}${command.usage}\x1b[0m` : command.usage;
|
|
1486
1491
|
return ` ${padDisplay(command.usage, width, usage)} ${command.description}`;
|
|
1487
1492
|
})
|
|
1488
1493
|
.join("\n");
|
|
@@ -1491,7 +1496,7 @@ function renderSlashCommandMenu(useColor) {
|
|
|
1491
1496
|
function renderSlashPaletteLines(selectedIndex, useColor, filtered, buffer) {
|
|
1492
1497
|
const query = buffer.startsWith("/") ? buffer.slice(1) : buffer;
|
|
1493
1498
|
const title = useColor
|
|
1494
|
-
?
|
|
1499
|
+
? `${TERMINAL_ANSI.permission}Commands${query ? ` · “${query}”` : ""}\x1b[0m`
|
|
1495
1500
|
: `Commands${query ? ` · “${query}”` : ""}`;
|
|
1496
1501
|
if (filtered.length === 0) {
|
|
1497
1502
|
const empty = useColor ? "\x1b[90m (no matching commands)\x1b[0m" : " (no matching commands)";
|
|
@@ -1562,7 +1567,7 @@ class TaskActivityLog {
|
|
|
1562
1567
|
render(useColor) {
|
|
1563
1568
|
if (this.activities.length === 0)
|
|
1564
1569
|
return "\nNo Task activity yet.\n";
|
|
1565
|
-
const title = useColor ?
|
|
1570
|
+
const title = useColor ? `${TERMINAL_ANSI.permission}Tasks\x1b[0m` : "Tasks";
|
|
1566
1571
|
const rows = this.activities
|
|
1567
1572
|
.slice(-12)
|
|
1568
1573
|
.map((a) => this.renderActivity(a, useColor))
|
|
@@ -1590,7 +1595,7 @@ class TaskActivityLog {
|
|
|
1590
1595
|
function paint(text, colorName, useColor) {
|
|
1591
1596
|
if (!useColor)
|
|
1592
1597
|
return text;
|
|
1593
|
-
const code = colorName === "green" ?
|
|
1598
|
+
const code = colorName === "green" ? TERMINAL_ANSI.success : colorName === "blue" ? TERMINAL_ANSI.permission : TERMINAL_ANSI.inactive;
|
|
1594
1599
|
return `${code}${text}\x1b[0m`;
|
|
1595
1600
|
}
|
|
1596
1601
|
function compactLine(text, max) {
|
|
@@ -1600,7 +1605,7 @@ function compactLine(text, max) {
|
|
|
1600
1605
|
return truncateDisplay(normalized, max);
|
|
1601
1606
|
}
|
|
1602
1607
|
function renderInputPrompt(useColor) {
|
|
1603
|
-
return useColor ?
|
|
1608
|
+
return useColor ? `${TERMINAL_ANSI.brandBlue}›\x1b[0m ` : "› ";
|
|
1604
1609
|
}
|
|
1605
1610
|
function renderTurnInputHint(useColor) {
|
|
1606
1611
|
const hint = "Type to queue a message · Esc to interrupt";
|
|
@@ -1654,7 +1659,7 @@ function renderInputBorder(position, useColor) {
|
|
|
1654
1659
|
return useColor ? `\x1b[38;2;84;94;112m${line}\x1b[0m` : line;
|
|
1655
1660
|
}
|
|
1656
1661
|
function renderWelcomeBanner(options) {
|
|
1657
|
-
const blue = options.color ?
|
|
1662
|
+
const blue = options.color ? TERMINAL_ANSI.brandBlue : "";
|
|
1658
1663
|
const green = options.color ? "\x1b[32m" : "";
|
|
1659
1664
|
const dim = options.color ? "\x1b[90m" : "";
|
|
1660
1665
|
const reset = options.color ? "\x1b[0m" : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/runtime/permissions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/runtime/permissions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7F,KAAK,kBAAkB,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,EACpC,OAAO,GAAE,kBAAuB,GAC/B,gBAAgB,CA8BlB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAa7G"}
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import readline from "node:readline/promises";
|
|
4
4
|
import { stdin as input, stderr as output } from "node:process";
|
|
5
|
+
import { TERMINAL_ANSI } from "../terminal-theme.js";
|
|
5
6
|
import { stringify } from "../utils.js";
|
|
6
7
|
export function createCliApprovalProvider(config, emit, assumeYes, options = {}) {
|
|
7
8
|
return async (request) => {
|
|
@@ -126,11 +127,11 @@ function paint(value, color, enabled) {
|
|
|
126
127
|
if (!enabled || color === "normal")
|
|
127
128
|
return value;
|
|
128
129
|
const code = color === "dim"
|
|
129
|
-
?
|
|
130
|
+
? TERMINAL_ANSI.inactive
|
|
130
131
|
: color === "yellow"
|
|
131
|
-
?
|
|
132
|
+
? TERMINAL_ANSI.warning
|
|
132
133
|
: color === "yellowBold"
|
|
133
|
-
?
|
|
134
|
-
:
|
|
134
|
+
? `\x1b[1m${TERMINAL_ANSI.warning}`
|
|
135
|
+
: `\x1b[1m${TERMINAL_ANSI.permission}`;
|
|
135
136
|
return `${code}${value}\x1b[0m`;
|
|
136
137
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentConfig, ApprovalProvider, AskUserFn, LlmConfig, Message, SubagentConfig, TraceSink } from "../types.js";
|
|
1
|
+
import type { AgentConfig, ApprovalProvider, AskUserFn, LlmConfig, Message, SubagentConfig, TraceSink, ToolDefinition } from "../types.js";
|
|
2
2
|
import { type AnthropicUsage } from "../llm/anthropic.js";
|
|
3
3
|
import { type PlanState } from "../plan/plan-mode.js";
|
|
4
4
|
import { type WorkflowState } from "../coordinator/workflow.js";
|
|
@@ -15,6 +15,8 @@ export type QueryEngineOptions = {
|
|
|
15
15
|
depth?: number;
|
|
16
16
|
askUser?: AskUserFn;
|
|
17
17
|
sessionId?: string;
|
|
18
|
+
extraTools?: ToolDefinition[];
|
|
19
|
+
memoryEnabled?: boolean;
|
|
18
20
|
};
|
|
19
21
|
export type UsageCategory = "main" | "task" | "compaction";
|
|
20
22
|
type UsageCounters = AnthropicUsage & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-engine.d.ts","sourceRoot":"","sources":["../../src/runtime/query-engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAChB,SAAS,EAET,SAAS,EACT,OAAO,EACP,cAAc,EAEd,SAAS,
|
|
1
|
+
{"version":3,"file":"query-engine.d.ts","sourceRoot":"","sources":["../../src/runtime/query-engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAChB,SAAS,EAET,SAAS,EACT,OAAO,EACP,cAAc,EAEd,SAAS,EACT,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,cAAc,EAEpB,MAAM,qBAAqB,CAAC;AAkB7B,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB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,MAAM;;;;IAI9C;;;OAGG;IACG,mBAAmB,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;IAgDlF,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2UnD,iBAAiB,IAAI,IAAI;IASzB,OAAO,CAAC,YAAY;YAcN,sBAAsB;YAOtB,sBAAsB;YAgBtB,yBAAyB;YAuEzB,sBAAsB;YAoBtB,OAAO;IAoBrB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,sBAAsB;IAgC9B,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,uBAAuB;IA0B/B,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,2BAA2B;CAOpC"}
|
|
@@ -486,12 +486,19 @@ export class QueryEngine {
|
|
|
486
486
|
allowedTools: this.options.subagent?.tools,
|
|
487
487
|
runTask: isSubagent ? undefined : (agent, prompt, emit) => this.runTask(agent, prompt, emit),
|
|
488
488
|
});
|
|
489
|
+
if (this.options.memoryEnabled === false) {
|
|
490
|
+
registry.remove("memory_search");
|
|
491
|
+
registry.remove("memory_save");
|
|
492
|
+
registry.remove("memory_list");
|
|
493
|
+
}
|
|
494
|
+
for (const tool of this.options.extraTools ?? [])
|
|
495
|
+
registry.register(tool);
|
|
489
496
|
registry.setHooks(this.hooks);
|
|
490
497
|
registry.setPlanMode(this.mode === "plan");
|
|
491
498
|
const [availableSkills, matchedSkills, memBlock] = await Promise.all([
|
|
492
499
|
this.skillManager.metadata(),
|
|
493
500
|
this.matchedSkillsForPrompt(input),
|
|
494
|
-
isSubagent ? Promise.resolve("") : memoryContextBlock(this.options.agentConfig.workspaceRoot, input),
|
|
501
|
+
isSubagent || this.options.memoryEnabled === false ? Promise.resolve("") : memoryContextBlock(this.options.agentConfig.workspaceRoot, input),
|
|
495
502
|
]);
|
|
496
503
|
const modeExtra = this.runtimeModeContext();
|
|
497
504
|
const memoryExtra = this.takeMemoryContext(memBlock);
|
|
@@ -673,6 +680,7 @@ export class QueryEngine {
|
|
|
673
680
|
isError: result.isError,
|
|
674
681
|
content: truncate(result.content, 1000),
|
|
675
682
|
fileChange: result.fileChange,
|
|
683
|
+
artifacts: result.artifacts,
|
|
676
684
|
});
|
|
677
685
|
// refresh plan after write
|
|
678
686
|
if (toolUse.name === "write_file" && this.mode === "plan") {
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryEngine, type QueryEngineOptions } from "./runtime/query-engine.js";
|
|
2
|
-
import type { AgentConfig, ApprovalProvider, AskUserFn, LlmConfig, TraceSink } from "./types.js";
|
|
2
|
+
import type { AgentConfig, ApprovalProvider, AskUserFn, LlmConfig, ToolDefinition, TraceSink } from "./types.js";
|
|
3
3
|
export type CreateQueryEngineOptions = {
|
|
4
4
|
configPath?: string;
|
|
5
5
|
configMode?: "layered" | "isolated";
|
|
@@ -13,6 +13,8 @@ export type CreateQueryEngineOptions = {
|
|
|
13
13
|
onEvent?: TraceSink;
|
|
14
14
|
askUser?: AskUserFn;
|
|
15
15
|
sessionId?: string;
|
|
16
|
+
extraTools?: ToolDefinition[];
|
|
17
|
+
memoryEnabled?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export type RunAgentTurnOptions = CreateQueryEngineOptions & {
|
|
18
20
|
input: string;
|
|
@@ -31,5 +33,5 @@ export { createWorkflow, workflowStatusBar } from "./coordinator/workflow.js";
|
|
|
31
33
|
export { skillifySession } from "./skillify/skillify.js";
|
|
32
34
|
export { saveMemory, searchMemories, listMemories } from "./memory/memdir.js";
|
|
33
35
|
export { listSessions, loadSession, loadLatestSession } from "./session/store.js";
|
|
34
|
-
export type { AgentConfig, AnthropicTool, ApprovalProvider, AskUserFn, FileChangeDisplay, LlmConfig, Message, SubagentConfig, ToolDefinition, ToolResult, TraceEvent, } from "./types.js";
|
|
36
|
+
export type { AgentConfig, AnthropicTool, ApprovalProvider, AskUserFn, FileChangeDisplay, LlmConfig, JsonObject, Message, SubagentConfig, ToolDefinition, ToolArtifact, ToolResult, TraceEvent, } from "./types.js";
|
|
35
37
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAc,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAc,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7H,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,SAAS,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AY,CAAC"}
|
package/dist/sdk.js
CHANGED
|
@@ -15,6 +15,8 @@ export async function createQueryEngine(options = {}) {
|
|
|
15
15
|
stream: options.stream,
|
|
16
16
|
askUser: options.askUser,
|
|
17
17
|
sessionId: options.sessionId,
|
|
18
|
+
extraTools: options.extraTools,
|
|
19
|
+
memoryEnabled: options.memoryEnabled,
|
|
18
20
|
});
|
|
19
21
|
if (options.sessionId) {
|
|
20
22
|
await engine.resumeSession(options.sessionId);
|
package/dist/status-ui.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code–style waiting indicator + outcome dots.
|
|
3
|
-
*
|
|
4
|
-
* Running: morphing sparkle · ✢ ✳ ✶ ✻ ✽ + shimmer label
|
|
5
|
-
* Success: green ● (CC uses ● / ⏺ for completed status)
|
|
6
|
-
* Failure: red ●
|
|
7
|
-
*
|
|
8
|
-
* Refs: SpinnerGlyph (stalled→error red), figures BLACK_CIRCLE, BriefIdleStatus ●
|
|
9
|
-
*/
|
|
10
1
|
/** Filled circle — CC completed / idle status glyph. */
|
|
11
2
|
export declare const STATUS_DOT = "\u25CF";
|
|
12
3
|
export declare function spinnerGlyph(frame: number): string;
|
|
13
4
|
export declare function glimmerIndex(frame: number, messageWidth: number): number;
|
|
14
5
|
export declare function shimmerLabel(label: string, frame: number, useColor: boolean): string;
|
|
15
6
|
export declare function formatSpinnerGlyph(frame: number, useColor: boolean): string;
|
|
16
|
-
export declare const STATUS_TICK_MS =
|
|
7
|
+
export declare const STATUS_TICK_MS = 140;
|
|
17
8
|
export declare function formatWaitLine(options: {
|
|
18
9
|
frame: number;
|
|
19
10
|
label: string;
|
package/dist/status-ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-ui.d.ts","sourceRoot":"","sources":["../src/status-ui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status-ui.d.ts","sourceRoot":"","sources":["../src/status-ui.ts"],"names":[],"mappings":"AA6CA,wDAAwD;AACxD,eAAO,MAAM,UAAU,WAAM,CAAC;AAE9B,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKxE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAkBpF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAO3E;AAED,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,MAAM,CAKT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,MAAM,CAcT;AAeD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAErE;AACD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
package/dist/status-ui.js
CHANGED
|
@@ -7,18 +7,20 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Refs: SpinnerGlyph (stalled→error red), figures BLACK_CIRCLE, BriefIdleStatus ●
|
|
9
9
|
*/
|
|
10
|
+
import { TERMINAL_DARK_RGB } from "./terminal-theme.js";
|
|
10
11
|
const SPINNER_CHARS = ["·", "✢", "✳", "✶", "✻", "✽"];
|
|
11
12
|
const SPINNER_FRAMES = [
|
|
12
13
|
...SPINNER_CHARS,
|
|
13
14
|
...[...SPINNER_CHARS].reverse(),
|
|
14
15
|
];
|
|
15
|
-
const GLYPH_EVERY =
|
|
16
|
+
const GLYPH_EVERY = 1;
|
|
16
17
|
const SHIMMER_EVERY = 4;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
18
|
+
const asRgb = (value) => ({ r: value[0], g: value[1], b: value[2] });
|
|
19
|
+
const BASE_RGB = asRgb(TERMINAL_DARK_RGB.spinnerBase);
|
|
20
|
+
const SHIMMER_RGB = asRgb(TERMINAL_DARK_RGB.spinnerShimmer);
|
|
21
|
+
const GLYPH_RGB = asRgb(TERMINAL_DARK_RGB.spinnerBlue);
|
|
22
|
+
const GREEN_RGB = asRgb(TERMINAL_DARK_RGB.success);
|
|
23
|
+
const RED_RGB = asRgb(TERMINAL_DARK_RGB.error);
|
|
22
24
|
function lerp(a, b, t) {
|
|
23
25
|
return Math.round(a + (b - a) * t);
|
|
24
26
|
}
|
|
@@ -77,7 +79,7 @@ export function formatSpinnerGlyph(frame, useColor) {
|
|
|
77
79
|
const nearPeak = step === peak || step === SPINNER_FRAMES.length - peak - 1;
|
|
78
80
|
return `${rgbAnsi(nearPeak ? SHIMMER_RGB : GLYPH_RGB)}${ch}${RESET}`;
|
|
79
81
|
}
|
|
80
|
-
export const STATUS_TICK_MS =
|
|
82
|
+
export const STATUS_TICK_MS = 140;
|
|
81
83
|
export function formatWaitLine(options) {
|
|
82
84
|
const glyph = formatSpinnerGlyph(options.frame, options.useColor);
|
|
83
85
|
const label = shimmerLabel(options.label, options.frame, options.useColor);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type TerminalRgb = readonly [number, number, number];
|
|
2
|
+
/** Canonical brand colors. Terminal surfaces use the softer dark theme below. */
|
|
3
|
+
export declare const APOLLO_BRAND_PALETTE: {
|
|
4
|
+
readonly blue: "#4285F4";
|
|
5
|
+
readonly red: "#EA4335";
|
|
6
|
+
readonly yellow: "#FBBC05";
|
|
7
|
+
readonly green: "#34A853";
|
|
8
|
+
};
|
|
9
|
+
/** Dark terminal palette matched to cc-yh's theme and Monokai Extended syntax colors. */
|
|
10
|
+
export declare const TERMINAL_DARK_RGB: {
|
|
11
|
+
brandBlue: [number, number, number];
|
|
12
|
+
spinnerBase: [number, number, number];
|
|
13
|
+
spinnerBlue: [number, number, number];
|
|
14
|
+
spinnerShimmer: [number, number, number];
|
|
15
|
+
permission: [number, number, number];
|
|
16
|
+
permissionShimmer: [number, number, number];
|
|
17
|
+
success: [number, number, number];
|
|
18
|
+
error: [number, number, number];
|
|
19
|
+
warning: [number, number, number];
|
|
20
|
+
text: [number, number, number];
|
|
21
|
+
inactive: [number, number, number];
|
|
22
|
+
subtle: [number, number, number];
|
|
23
|
+
diffAdded: [number, number, number];
|
|
24
|
+
diffRemoved: [number, number, number];
|
|
25
|
+
keyword: [number, number, number];
|
|
26
|
+
storage: [number, number, number];
|
|
27
|
+
syntaxGreen: [number, number, number];
|
|
28
|
+
literal: [number, number, number];
|
|
29
|
+
string: [number, number, number];
|
|
30
|
+
params: [number, number, number];
|
|
31
|
+
comment: [number, number, number];
|
|
32
|
+
};
|
|
33
|
+
export declare function terminalForeground(rgb: TerminalRgb): string;
|
|
34
|
+
export declare function terminalBackground(rgb: TerminalRgb): string;
|
|
35
|
+
export declare const TERMINAL_ANSI: {
|
|
36
|
+
readonly brandBlue: string;
|
|
37
|
+
readonly permission: string;
|
|
38
|
+
readonly success: string;
|
|
39
|
+
readonly error: string;
|
|
40
|
+
readonly warning: string;
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly inactive: string;
|
|
43
|
+
readonly subtle: string;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=terminal-theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-theme.d.ts","sourceRoot":"","sources":["../src/terminal-theme.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5D,iFAAiF;AACjF,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX,yFAAyF;AACzF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;CAsBS,CAAC;AAExC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAE3D;AAED,eAAO,MAAM,aAAa;;;;;;;;;CAShB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Canonical brand colors. Terminal surfaces use the softer dark theme below. */
|
|
2
|
+
export const APOLLO_BRAND_PALETTE = {
|
|
3
|
+
blue: "#4285F4",
|
|
4
|
+
red: "#EA4335",
|
|
5
|
+
yellow: "#FBBC05",
|
|
6
|
+
green: "#34A853",
|
|
7
|
+
};
|
|
8
|
+
/** Dark terminal palette matched to cc-yh's theme and Monokai Extended syntax colors. */
|
|
9
|
+
export const TERMINAL_DARK_RGB = {
|
|
10
|
+
brandBlue: [66, 133, 244],
|
|
11
|
+
spinnerBase: [148, 163, 184],
|
|
12
|
+
spinnerBlue: [96, 165, 250],
|
|
13
|
+
spinnerShimmer: [147, 197, 253],
|
|
14
|
+
permission: [177, 185, 249],
|
|
15
|
+
permissionShimmer: [207, 215, 255],
|
|
16
|
+
success: [78, 186, 101],
|
|
17
|
+
error: [255, 107, 128],
|
|
18
|
+
warning: [255, 193, 7],
|
|
19
|
+
text: [248, 248, 242],
|
|
20
|
+
inactive: [153, 153, 153],
|
|
21
|
+
subtle: [80, 80, 80],
|
|
22
|
+
diffAdded: [34, 92, 43],
|
|
23
|
+
diffRemoved: [122, 41, 54],
|
|
24
|
+
keyword: [249, 38, 114],
|
|
25
|
+
storage: [102, 217, 239],
|
|
26
|
+
syntaxGreen: [166, 226, 46],
|
|
27
|
+
literal: [190, 132, 255],
|
|
28
|
+
string: [230, 219, 116],
|
|
29
|
+
params: [253, 151, 31],
|
|
30
|
+
comment: [117, 113, 94],
|
|
31
|
+
};
|
|
32
|
+
export function terminalForeground(rgb) {
|
|
33
|
+
return `\x1b[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
34
|
+
}
|
|
35
|
+
export function terminalBackground(rgb) {
|
|
36
|
+
return `\x1b[48;2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
37
|
+
}
|
|
38
|
+
export const TERMINAL_ANSI = {
|
|
39
|
+
brandBlue: terminalForeground(TERMINAL_DARK_RGB.brandBlue),
|
|
40
|
+
permission: terminalForeground(TERMINAL_DARK_RGB.permission),
|
|
41
|
+
success: terminalForeground(TERMINAL_DARK_RGB.success),
|
|
42
|
+
error: terminalForeground(TERMINAL_DARK_RGB.error),
|
|
43
|
+
warning: terminalForeground(TERMINAL_DARK_RGB.warning),
|
|
44
|
+
text: terminalForeground(TERMINAL_DARK_RGB.text),
|
|
45
|
+
inactive: terminalForeground(TERMINAL_DARK_RGB.inactive),
|
|
46
|
+
subtle: terminalForeground(TERMINAL_DARK_RGB.subtle),
|
|
47
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thought-fold.d.ts","sourceRoot":"","sources":["../src/thought-fold.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"thought-fold.d.ts","sourceRoot":"","sources":["../src/thought-fold.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAIF,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAAqB;gBAExB,OAAO,EAAE,kBAAkB;IAIvC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI9B,qDAAqD;IACrD,SAAS,IAAI,IAAI;IAQjB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKlC,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,SAAM,GAAG,IAAI;IAevD;;;OAGG;IACH,gBAAgB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,UAAQ,EAAE,WAAW,UAAQ,GAAG,YAAY,GAAG,IAAI;IAWnG,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,GAAG;CAIZ"}
|
package/dist/thought-fold.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
* Bounded terminal preview for model thinking tokens.
|
|
3
3
|
*/
|
|
4
4
|
import { stripTerminalEscapes } from "./trace.js";
|
|
5
|
-
|
|
5
|
+
import { TERMINAL_ANSI } from "./terminal-theme.js";
|
|
6
6
|
const RESET = "\x1b[0m";
|
|
7
|
-
const GREEN = "\x1b[32m";
|
|
8
|
-
const RED = "\x1b[31m";
|
|
9
7
|
export class ThoughtFoldManager {
|
|
10
8
|
current = null;
|
|
11
9
|
options;
|
|
@@ -65,7 +63,7 @@ export class ThoughtFoldManager {
|
|
|
65
63
|
return `${(ms / 1000).toFixed(1)}s`;
|
|
66
64
|
}
|
|
67
65
|
printHeader(block) {
|
|
68
|
-
const color = block.failed ?
|
|
66
|
+
const color = block.failed ? TERMINAL_ANSI.error : TERMINAL_ANSI.success;
|
|
69
67
|
const dot = this.options.color ? `${color}●${RESET}` : "●";
|
|
70
68
|
const label = block.failed
|
|
71
69
|
? `Failed · ${this.duration(block)}`
|
|
@@ -76,6 +74,6 @@ export class ThoughtFoldManager {
|
|
|
76
74
|
dim(text) {
|
|
77
75
|
if (!this.options.color)
|
|
78
76
|
return text;
|
|
79
|
-
return `${
|
|
77
|
+
return `${TERMINAL_ANSI.inactive}${text}${RESET}`;
|
|
80
78
|
}
|
|
81
79
|
}
|
package/dist/tools/builtin.js
CHANGED
|
@@ -160,7 +160,7 @@ export function createBuiltinRegistry(options) {
|
|
|
160
160
|
const command = requiredString(input, "command");
|
|
161
161
|
const timeout = numberInput(input, "timeoutMs", 30000);
|
|
162
162
|
try {
|
|
163
|
-
const { stdout, stderr } = await execFileAsync("
|
|
163
|
+
const { stdout, stderr } = await execFileAsync(process.env.SHELL || "/bin/sh", ["-lc", command], {
|
|
164
164
|
cwd: config.workspaceRoot,
|
|
165
165
|
timeout,
|
|
166
166
|
maxBuffer: 1024 * 1024 * 4,
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class ToolRegistry {
|
|
|
9
9
|
setPlanMode(active: boolean): void;
|
|
10
10
|
register(tool: ToolDefinition): void;
|
|
11
11
|
has(name: string): boolean;
|
|
12
|
+
remove(name: string): void;
|
|
12
13
|
pick(names: string[]): ToolRegistry;
|
|
13
14
|
definitions(): AnthropicTool[];
|
|
14
15
|
riskOf(name: string): import("../types.js").ToolRisk | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C,q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,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY;IAWnC,WAAW,IAAI,aAAa,EAAE;IAQ9B,MAAM,CAAC,IAAI,EAAE,MAAM;IAIb,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CA+CnG"}
|
package/dist/tools/registry.js
CHANGED
package/dist/trace.d.ts
CHANGED
package/dist/trace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EACL,oBAAoB,EAKrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,IAAI,uBAAuB,EAAE,CAAC;AAiB3D,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,gBAAgB;IAiBf,OAAO,CAAC,QAAQ,CAAC,OAA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,OAAO,EAAE,OAAO,GAAG,SAAS,CAO9D;AAgGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY1D"}
|
package/dist/trace.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { stderr } from "node:process";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import { highlight, supportsLanguage } from "cli-highlight";
|
|
2
4
|
import { formatWaitLine } from "./status-ui.js";
|
|
5
|
+
import { APOLLO_BRAND_PALETTE, TERMINAL_ANSI, TERMINAL_DARK_RGB, terminalBackground, terminalForeground, } from "./terminal-theme.js";
|
|
6
|
+
export { APOLLO_BRAND_PALETTE as APOLLO_STANDARD_PALETTE };
|
|
3
7
|
const color = {
|
|
4
8
|
reset: "\x1b[0m",
|
|
5
9
|
normal: "",
|
|
6
10
|
dim: "\x1b[2m",
|
|
7
11
|
bold: "\x1b[1m",
|
|
8
|
-
cyan:
|
|
9
|
-
blue:
|
|
10
|
-
green:
|
|
11
|
-
yellow:
|
|
12
|
-
red:
|
|
12
|
+
cyan: terminalForeground(TERMINAL_DARK_RGB.storage),
|
|
13
|
+
blue: TERMINAL_ANSI.permission,
|
|
14
|
+
green: TERMINAL_ANSI.success,
|
|
15
|
+
yellow: TERMINAL_ANSI.warning,
|
|
16
|
+
red: TERMINAL_ANSI.error,
|
|
13
17
|
magenta: "\x1b[35m",
|
|
14
18
|
gray: "\x1b[90m",
|
|
19
|
+
output: TERMINAL_ANSI.inactive,
|
|
15
20
|
};
|
|
16
21
|
export class CliTraceRenderer {
|
|
17
22
|
options;
|
|
@@ -224,7 +229,7 @@ export class CliTraceRenderer {
|
|
|
224
229
|
const elapsed = startedAt ? ` ${this.elapsedSince(startedAt)}` : "";
|
|
225
230
|
this.bullet(`${formatCompletedStatusText(label)}${elapsed}`, colorName);
|
|
226
231
|
if (detail)
|
|
227
|
-
this.subBullet(detail, "
|
|
232
|
+
this.subBullet(detail, "output");
|
|
228
233
|
}
|
|
229
234
|
/** Non-interactive: Claude Code–style morphing glyph + shimmer label. */
|
|
230
235
|
renderStatus() {
|
|
@@ -272,10 +277,10 @@ export class CliTraceRenderer {
|
|
|
272
277
|
const removed = `${change.removed} ${change.removed === 1 ? "line" : "lines"}`;
|
|
273
278
|
const summary = change.kind === "create" ? `Added ${added}` : `Added ${added}, removed ${removed}`;
|
|
274
279
|
this.out(`${this.paint("●", "green")} ${this.paint(`${action}(${path})`, "bold")}\n`);
|
|
275
|
-
this.out(` ${this.paint("└", "
|
|
280
|
+
this.out(` ${this.paint("└", "blue")} ${this.paint(summary, "output")}\n`);
|
|
276
281
|
this.renderCodeChange(change);
|
|
277
282
|
if (change.omitted > 0) {
|
|
278
|
-
this.out(` ${this.paint("└", "
|
|
283
|
+
this.out(` ${this.paint("└", "blue")} ${this.paint(`… +${change.omitted} lines`, "output")}\n`);
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
renderInteractiveToolResult(event, denied) {
|
|
@@ -284,11 +289,12 @@ export class CliTraceRenderer {
|
|
|
284
289
|
return;
|
|
285
290
|
const lines = toolOutputLines(event.tool, event.content);
|
|
286
291
|
for (const [index, line] of lines.entries()) {
|
|
287
|
-
this.out(` ${this.paint(index === 0 ? "└" : " ", "
|
|
292
|
+
this.out(` ${this.paint(index === 0 ? "└" : " ", "blue")} ${this.paint(truncateDisplayLine(line, 140), "output")}\n`);
|
|
288
293
|
}
|
|
289
294
|
}
|
|
290
295
|
renderCodeChange(change) {
|
|
291
296
|
const width = Math.max(40, Math.min(this.options.stdout?.columns ?? 120, 160));
|
|
297
|
+
const language = extname(change.path).slice(1);
|
|
292
298
|
let oldLine = 1;
|
|
293
299
|
let newLine = 1;
|
|
294
300
|
for (const rawLine of change.lines) {
|
|
@@ -326,7 +332,7 @@ export class CliTraceRenderer {
|
|
|
326
332
|
oldLine += 1;
|
|
327
333
|
newLine += 1;
|
|
328
334
|
}
|
|
329
|
-
this.out(`${renderCodeLine(number, marker, content, style, width, this.options.color)}\n`);
|
|
335
|
+
this.out(`${renderCodeLine(number, marker, content, style, width, this.options.color, language)}\n`);
|
|
330
336
|
}
|
|
331
337
|
}
|
|
332
338
|
paint(text, colorName) {
|
|
@@ -450,35 +456,55 @@ function truncateDisplayLine(value, max) {
|
|
|
450
456
|
const characters = Array.from(value.replace(/\t/g, " "));
|
|
451
457
|
return characters.length <= max ? characters.join("") : `${characters.slice(0, max - 1).join("")}…`;
|
|
452
458
|
}
|
|
453
|
-
function renderCodeLine(lineNumber, marker, value, style, width, useColor) {
|
|
459
|
+
function renderCodeLine(lineNumber, marker, value, style, width, useColor, language) {
|
|
454
460
|
const prefix = ` ${String(lineNumber).padStart(5)} ${marker} `;
|
|
455
461
|
const content = truncateDisplayLine(value, Math.max(10, width - displayCells(prefix)));
|
|
456
462
|
const padding = " ".repeat(Math.max(0, width - displayCells(prefix) - displayCells(content)));
|
|
457
463
|
if (!useColor)
|
|
458
464
|
return `${prefix}${content}${padding}`;
|
|
459
465
|
const background = style === "add"
|
|
460
|
-
?
|
|
466
|
+
? terminalBackground(TERMINAL_DARK_RGB.diffAdded)
|
|
461
467
|
: style === "remove"
|
|
462
|
-
?
|
|
468
|
+
? terminalBackground(TERMINAL_DARK_RGB.diffRemoved)
|
|
463
469
|
: "";
|
|
464
470
|
const gutter = style === "add"
|
|
465
|
-
?
|
|
471
|
+
? TERMINAL_ANSI.success
|
|
466
472
|
: style === "remove"
|
|
467
|
-
?
|
|
468
|
-
:
|
|
469
|
-
return `${background}${gutter}${prefix}${highlightCode(content)}${padding}\x1b[0m`;
|
|
473
|
+
? TERMINAL_ANSI.error
|
|
474
|
+
: TERMINAL_ANSI.inactive;
|
|
475
|
+
return `${background}${gutter}${prefix}${highlightCode(content, language)}${padding}\x1b[0m`;
|
|
470
476
|
}
|
|
471
|
-
function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
477
|
+
const STORAGE_KEYWORDS = new Set(["const", "let", "var", "function", "class", "type", "interface", "enum", "namespace", "module", "def"]);
|
|
478
|
+
const syntax = (rgb) => (value) => `${terminalForeground(rgb)}${value}\x1b[39m`;
|
|
479
|
+
const syntaxTheme = {
|
|
480
|
+
default: syntax(TERMINAL_DARK_RGB.text),
|
|
481
|
+
keyword: (value) => syntax(STORAGE_KEYWORDS.has(value.trim()) ? TERMINAL_DARK_RGB.storage : TERMINAL_DARK_RGB.keyword)(value),
|
|
482
|
+
built_in: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
483
|
+
type: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
484
|
+
literal: syntax(TERMINAL_DARK_RGB.literal),
|
|
485
|
+
number: syntax(TERMINAL_DARK_RGB.literal),
|
|
486
|
+
string: syntax(TERMINAL_DARK_RGB.string),
|
|
487
|
+
regexp: syntax(TERMINAL_DARK_RGB.string),
|
|
488
|
+
title: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
489
|
+
function: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
490
|
+
params: syntax(TERMINAL_DARK_RGB.params),
|
|
491
|
+
comment: syntax(TERMINAL_DARK_RGB.comment),
|
|
492
|
+
doctag: syntax(TERMINAL_DARK_RGB.comment),
|
|
493
|
+
meta: syntax(TERMINAL_DARK_RGB.comment),
|
|
494
|
+
name: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
495
|
+
attr: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
496
|
+
attribute: syntax(TERMINAL_DARK_RGB.syntaxGreen),
|
|
497
|
+
symbol: syntax(TERMINAL_DARK_RGB.literal),
|
|
498
|
+
};
|
|
499
|
+
function highlightCode(value, language) {
|
|
500
|
+
if (!language || !supportsLanguage(language))
|
|
501
|
+
return `${TERMINAL_ANSI.text}${value}`;
|
|
502
|
+
try {
|
|
503
|
+
return highlight(value, { language, ignoreIllegals: true, theme: syntaxTheme });
|
|
504
|
+
}
|
|
505
|
+
catch {
|
|
506
|
+
return `${TERMINAL_ANSI.text}${value}`;
|
|
507
|
+
}
|
|
482
508
|
}
|
|
483
509
|
function displayCells(value) {
|
|
484
510
|
let width = 0;
|
|
@@ -512,8 +538,8 @@ export function stripTerminalEscapes(value) {
|
|
|
512
538
|
}
|
|
513
539
|
function renderInlineMarkdown(value, useColor) {
|
|
514
540
|
let rendered = stripTerminalEscapes(value);
|
|
515
|
-
rendered = rendered.replace(/\[([^\]]+)]\((https?:\/\/[^)]+)\)/g, (_match, label, url) => useColor ? `\x1b[
|
|
516
|
-
rendered = rendered.replace(/`([^`]+)`/g, (_match, codeText) => useColor ? `\x1b[48;5;236m
|
|
541
|
+
rendered = rendered.replace(/\[([^\]]+)]\((https?:\/\/[^)]+)\)/g, (_match, label, url) => useColor ? `\x1b[4m${TERMINAL_ANSI.permission}${label}\x1b[0m ${TERMINAL_ANSI.inactive}(${url})\x1b[0m` : `${label} (${url})`);
|
|
542
|
+
rendered = rendered.replace(/`([^`]+)`/g, (_match, codeText) => useColor ? `\x1b[48;5;236m${TERMINAL_ANSI.permission} ${codeText} \x1b[0m` : codeText);
|
|
517
543
|
rendered = rendered.replace(/\*\*([^*]+)\*\*/g, (_match, boldText) => useColor ? `\x1b[1m${boldText}\x1b[0m` : boldText);
|
|
518
544
|
rendered = rendered.replace(/__([^_]+)__/g, (_match, boldText) => useColor ? `\x1b[1m${boldText}\x1b[0m` : boldText);
|
|
519
545
|
rendered = rendered.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g, (_match, prefix, italicText) => useColor ? `${prefix}\x1b[3m${italicText}\x1b[0m` : `${prefix}${italicText}`);
|
package/dist/types.d.ts
CHANGED
|
@@ -35,6 +35,12 @@ export type ToolResult = {
|
|
|
35
35
|
content: string;
|
|
36
36
|
isError?: boolean;
|
|
37
37
|
fileChange?: FileChangeDisplay;
|
|
38
|
+
artifacts?: ToolArtifact[];
|
|
39
|
+
};
|
|
40
|
+
export type ToolArtifact = {
|
|
41
|
+
path: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
size?: number;
|
|
38
44
|
};
|
|
39
45
|
export type FileChangeDisplay = {
|
|
40
46
|
path: string;
|
|
@@ -83,6 +89,7 @@ export type TraceEvent = {
|
|
|
83
89
|
isError?: boolean;
|
|
84
90
|
content: string;
|
|
85
91
|
fileChange?: FileChangeDisplay;
|
|
92
|
+
artifacts?: ToolArtifact[];
|
|
86
93
|
} | {
|
|
87
94
|
type: "approval_required";
|
|
88
95
|
tool: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAA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MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACX,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,cAAc,CAAC;QAC1C,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC"}
|
package/docs/sdk.md
CHANGED
|
@@ -93,6 +93,8 @@ const engine = await createQueryEngine({
|
|
|
93
93
|
| `assumeYes` | `boolean \| (() => boolean)` | 使用默认审批器时自动批准;服务端不建议启用 |
|
|
94
94
|
| `stream` | `boolean \| (() => boolean)` | 是否使用模型流式响应,默认开启 |
|
|
95
95
|
| `sessionId` | `string` | 创建后立即恢复指定会话 |
|
|
96
|
+
| `extraTools` | `ToolDefinition[]` | 向当前 Engine 注册宿主应用专用工具;工具名不能与已有工具重复 |
|
|
97
|
+
| `memoryEnabled` | `boolean` | 设为 `false` 时禁用记忆检索、保存、列表工具和自动记忆注入;默认开启 |
|
|
96
98
|
|
|
97
99
|
如果同时传入 `agentConfig` 和 `configPath`,使用 `agentConfig`;如果同时传入 `llmConfig` 和环境变量,使用 `llmConfig`。
|
|
98
100
|
|
|
@@ -154,6 +156,48 @@ const engine = await createQueryEngine({
|
|
|
154
156
|
`onEvent` 可能包含工具参数或结果。转发到日志和前端前,应按宿主系统的数据策略脱敏。
|
|
155
157
|
成功的 `write_file` 事件还会携带 `fileChange`,用于渲染新文件预览或彩色 diff;该字段不会发送给模型。
|
|
156
158
|
|
|
159
|
+
## 宿主工具与文件产物
|
|
160
|
+
|
|
161
|
+
Web 服务可以使用 `extraTools` 注册只属于当前入口的业务工具。工具返回的 `content` 会交给模型继续处理;`artifacts` 只随 `tool_result` 事件上报给宿主 UI,用于可靠展示和下载文件。
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { createQueryEngine, type ToolDefinition } from "@apolloyh/apollo-agent";
|
|
165
|
+
|
|
166
|
+
const generateReport: ToolDefinition = {
|
|
167
|
+
name: "generate_report",
|
|
168
|
+
description: "生成业务报告并保存到当前工作区。",
|
|
169
|
+
risk: "high",
|
|
170
|
+
input_schema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: { topic: { type: "string" } },
|
|
173
|
+
required: ["topic"],
|
|
174
|
+
},
|
|
175
|
+
async execute(input, context) {
|
|
176
|
+
const relativePath = "artifacts/report.docx";
|
|
177
|
+
await generateDocx(context.workspaceRoot, relativePath, String(input.topic));
|
|
178
|
+
return {
|
|
179
|
+
content: `报告已生成:${relativePath}`,
|
|
180
|
+
artifacts: [{ path: relativePath, title: "业务报告.docx" }],
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const engine = await createQueryEngine({
|
|
186
|
+
configPath: ".apollo/web-entry.json",
|
|
187
|
+
configMode: "isolated",
|
|
188
|
+
workspaceRoot: tenant.workspaceRoot,
|
|
189
|
+
extraTools: [generateReport],
|
|
190
|
+
memoryEnabled: false,
|
|
191
|
+
onEvent(event) {
|
|
192
|
+
if (event.type === "tool_result" && event.artifacts?.length) {
|
|
193
|
+
ui.showFiles(event.artifacts);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
`ToolArtifact.path` 应指向 `workspaceRoot` 内的真实文件。SDK 只传递元数据,不负责提供 HTTP 下载地址;宿主服务必须自行验证真实路径、文件类型、大小和用户权限,禁止直接信任模型给出的路径。
|
|
200
|
+
|
|
157
201
|
## 权限审批
|
|
158
202
|
|
|
159
203
|
自定义 `approvalProvider` 会接收每次工具调用。宿主系统应根据用户、工作区、工具和风险等级决定是否允许。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolloyh/apollo-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Apollo — your personal agent. Answer first, act when needed, with tools, skills, and isolated Task subagents.",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
47
|
+
"cli-highlight": "^2.1.11",
|
|
47
48
|
"diff": "^9.0.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|