nexum-code 0.12.5 → 0.12.8
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/{app-COTk2IwE.mjs → app-CwvgT8jS.mjs} +1102 -402
- package/dist/main.mjs +1 -1
- package/dist/{text-input-dialog-B_4fy5St.mjs → text-input-dialog-CHwbHQah.mjs} +26 -0
- package/dist/{text-input-dialog-B5imDNC1.mjs → text-input-dialog-CaC9DMZb.mjs} +1 -1
- package/package.json +3 -2
- package/dist/assets/fsevents-9Sj9I9VP.node +0 -0
|
@@ -7,7 +7,7 @@ import { i as __require, o as __toESM, r as __exportAll, t as __commonJSMin } fr
|
|
|
7
7
|
import "./suppress-sqlite-warning-C2VB0doZ.mjs";
|
|
8
8
|
import { C as join$1, D as resolve$1, E as relative$1, S as isAbsolute$1, T as parse$7, a as isSupportedFile, b as basename$1, i as ingestFile, r as ingestDirectory, t as multiSearch, w as normalize, x as dirname$2, y as KnowledgeStore } from "./src-BH9W5k24.mjs";
|
|
9
9
|
import { t as require_base64_js } from "./base64-js-DzVmk6Nb.mjs";
|
|
10
|
-
import { a as setLocale, i as getLocale, n as assertNexumHostIdentity, o as t, r as createNexumDefaultHeaders, t as TextInputDialogComponent } from "./text-input-dialog-
|
|
10
|
+
import { a as setLocale, i as getLocale, n as assertNexumHostIdentity, o as t, r as createNexumDefaultHeaders, t as TextInputDialogComponent } from "./text-input-dialog-CHwbHQah.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
13
13
|
import * as fs$1 from "node:fs/promises";
|
|
@@ -54,7 +54,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
54
54
|
import { Command, Option } from "commander";
|
|
55
55
|
import { createInterface } from "node:readline/promises";
|
|
56
56
|
import chalk, { chalkStderr } from "chalk";
|
|
57
|
-
import { CombinedAutocompleteProvider, Container, Editor,
|
|
57
|
+
import { CombinedAutocompleteProvider, Container, Editor, HStack, Image, Input, Key, Markdown, ProcessTerminal, ScrollView, Spacer, Text, TuiAltScreen, VStack, decodeKittyPrintable, deleteAllKittyImages, fuzzyFilter, fuzzyMatch, getCapabilities, getImageDimensions, isKeyRelease, matchesKey, sliceByColumn, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
58
58
|
import { highlight, supportsLanguage } from "cli-highlight";
|
|
59
59
|
import { diffWords } from "diff";
|
|
60
60
|
import { gt, valid } from "semver";
|
|
@@ -5600,7 +5600,7 @@ var _BetaToolRunner_instances, _BetaToolRunner_consumed, _BetaToolRunner_mutated
|
|
|
5600
5600
|
/**
|
|
5601
5601
|
* Just Promise.withResolvers(), which is not available in all environments.
|
|
5602
5602
|
*/
|
|
5603
|
-
function promiseWithResolvers() {
|
|
5603
|
+
function promiseWithResolvers$1() {
|
|
5604
5604
|
let resolve;
|
|
5605
5605
|
let reject;
|
|
5606
5606
|
return {
|
|
@@ -5646,7 +5646,7 @@ var BetaToolRunner = class {
|
|
|
5646
5646
|
...options,
|
|
5647
5647
|
headers: buildHeaders$2([{ "x-stainless-helper": helperValue }, options?.headers])
|
|
5648
5648
|
}, "f");
|
|
5649
|
-
__classPrivateFieldSet$1(this, _BetaToolRunner_completion, promiseWithResolvers(), "f");
|
|
5649
|
+
__classPrivateFieldSet$1(this, _BetaToolRunner_completion, promiseWithResolvers$1(), "f");
|
|
5650
5650
|
if (params.compactionControl?.enabled) console.warn("Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: \"compact_20260112\" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction");
|
|
5651
5651
|
}
|
|
5652
5652
|
async *[(_BetaToolRunner_consumed = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_mutated = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_state = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_options = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_message = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_toolResponse = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_completion = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_iterationCount = /* @__PURE__ */ new WeakMap(), _BetaToolRunner_instances = /* @__PURE__ */ new WeakSet(), _BetaToolRunner_checkAndCompact = async function _BetaToolRunner_checkAndCompact() {
|
|
@@ -5742,7 +5742,7 @@ var BetaToolRunner = class {
|
|
|
5742
5742
|
__classPrivateFieldSet$1(this, _BetaToolRunner_consumed, false, "f");
|
|
5743
5743
|
__classPrivateFieldGet$1(this, _BetaToolRunner_completion, "f").promise.catch(() => {});
|
|
5744
5744
|
__classPrivateFieldGet$1(this, _BetaToolRunner_completion, "f").reject(error);
|
|
5745
|
-
__classPrivateFieldSet$1(this, _BetaToolRunner_completion, promiseWithResolvers(), "f");
|
|
5745
|
+
__classPrivateFieldSet$1(this, _BetaToolRunner_completion, promiseWithResolvers$1(), "f");
|
|
5746
5746
|
throw error;
|
|
5747
5747
|
}
|
|
5748
5748
|
}
|
|
@@ -68263,68 +68263,6 @@ var require_nodefs_handler = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
68263
68263
|
module.exports = NodeFsHandler;
|
|
68264
68264
|
}));
|
|
68265
68265
|
//#endregion
|
|
68266
|
-
//#region ../../node_modules/.pnpm/fsevents@2.3.2/node_modules/fsevents/fsevents.js
|
|
68267
|
-
var require_fsevents = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
68268
|
-
if (process.platform !== "darwin") throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`);
|
|
68269
|
-
const Native = __require("./assets/fsevents-9Sj9I9VP.node");
|
|
68270
|
-
const events = Native.constants;
|
|
68271
|
-
function watch(path, since, handler) {
|
|
68272
|
-
if (typeof path !== "string") throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
|
|
68273
|
-
if ("function" === typeof since && "undefined" === typeof handler) {
|
|
68274
|
-
handler = since;
|
|
68275
|
-
since = Native.flags.SinceNow;
|
|
68276
|
-
}
|
|
68277
|
-
if (typeof since !== "number") throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`);
|
|
68278
|
-
if (typeof handler !== "function") throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`);
|
|
68279
|
-
let instance = Native.start(Native.global, path, since, handler);
|
|
68280
|
-
if (!instance) throw new Error(`could not watch: ${path}`);
|
|
68281
|
-
return () => {
|
|
68282
|
-
const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(void 0);
|
|
68283
|
-
instance = void 0;
|
|
68284
|
-
return result;
|
|
68285
|
-
};
|
|
68286
|
-
}
|
|
68287
|
-
function getInfo(path, flags) {
|
|
68288
|
-
return {
|
|
68289
|
-
path,
|
|
68290
|
-
flags,
|
|
68291
|
-
event: getEventType(flags),
|
|
68292
|
-
type: getFileType(flags),
|
|
68293
|
-
changes: getFileChanges(flags)
|
|
68294
|
-
};
|
|
68295
|
-
}
|
|
68296
|
-
function getFileType(flags) {
|
|
68297
|
-
if (events.ItemIsFile & flags) return "file";
|
|
68298
|
-
if (events.ItemIsDir & flags) return "directory";
|
|
68299
|
-
if (events.ItemIsSymlink & flags) return "symlink";
|
|
68300
|
-
}
|
|
68301
|
-
function anyIsTrue(obj) {
|
|
68302
|
-
for (let key in obj) if (obj[key]) return true;
|
|
68303
|
-
return false;
|
|
68304
|
-
}
|
|
68305
|
-
function getEventType(flags) {
|
|
68306
|
-
if (events.ItemRemoved & flags) return "deleted";
|
|
68307
|
-
if (events.ItemRenamed & flags) return "moved";
|
|
68308
|
-
if (events.ItemCreated & flags) return "created";
|
|
68309
|
-
if (events.ItemModified & flags) return "modified";
|
|
68310
|
-
if (events.RootChanged & flags) return "root-changed";
|
|
68311
|
-
if (events.ItemCloned & flags) return "cloned";
|
|
68312
|
-
if (anyIsTrue(flags)) return "modified";
|
|
68313
|
-
return "unknown";
|
|
68314
|
-
}
|
|
68315
|
-
function getFileChanges(flags) {
|
|
68316
|
-
return {
|
|
68317
|
-
inode: !!(events.ItemInodeMetaMod & flags),
|
|
68318
|
-
finder: !!(events.ItemFinderInfoMod & flags),
|
|
68319
|
-
access: !!(events.ItemChangeOwner & flags),
|
|
68320
|
-
xattrs: !!(events.ItemXattrMod & flags)
|
|
68321
|
-
};
|
|
68322
|
-
}
|
|
68323
|
-
exports.watch = watch;
|
|
68324
|
-
exports.getInfo = getInfo;
|
|
68325
|
-
exports.constants = events;
|
|
68326
|
-
}));
|
|
68327
|
-
//#endregion
|
|
68328
68266
|
//#region ../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/fsevents-handler.js
|
|
68329
68267
|
var require_fsevents_handler = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
68330
68268
|
const fs$11 = __require("fs");
|
|
@@ -68332,7 +68270,7 @@ var require_fsevents_handler = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
68332
68270
|
const { promisify: promisify$2 } = __require("util");
|
|
68333
68271
|
let fsevents;
|
|
68334
68272
|
try {
|
|
68335
|
-
fsevents =
|
|
68273
|
+
fsevents = __require("fsevents");
|
|
68336
68274
|
} catch (error) {
|
|
68337
68275
|
if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
|
|
68338
68276
|
}
|
|
@@ -82195,14 +82133,84 @@ function maybeStatusCode(error) {
|
|
|
82195
82133
|
}
|
|
82196
82134
|
//#endregion
|
|
82197
82135
|
//#region ../../packages/agent-core/src/agent/context/projector.ts
|
|
82198
|
-
|
|
82199
|
-
|
|
82136
|
+
/** Synthetic error text used when a tool result is missing and must be
|
|
82137
|
+
* filled in so the provider accepts the message sequence. */
|
|
82138
|
+
const SYNTHETIC_TOOL_RESULT_TEXT = "<system>ERROR: The tool call did not complete because of an interruption. Do not assume the tool executed successfully, and do not invent its result.</system>";
|
|
82139
|
+
function project(history, options) {
|
|
82140
|
+
return repairToolExchangeAdjacency(mergeAdjacentUserMessages(history.filter((message) => {
|
|
82200
82141
|
return message.partial !== true && !(message.role === "assistant" && message.content.length === 0 && message.toolCalls.length === 0);
|
|
82201
|
-
});
|
|
82202
|
-
const last = usable.at(-1);
|
|
82203
|
-
return mergeAdjacentUserMessages(last?.role === "assistant" && last.toolCalls.length > 0 ? usable.slice(0, -1) : usable);
|
|
82142
|
+
}), options?.onAnomaly), options);
|
|
82204
82143
|
}
|
|
82205
|
-
|
|
82144
|
+
/**
|
|
82145
|
+
* Closes every tool exchange whose assistant `tool_use` is not fully answered
|
|
82146
|
+
* by a matching `tool_result`. A mid-history orphan (a later user/assistant
|
|
82147
|
+
* message follows) can never be in-flight, so it is always closed by
|
|
82148
|
+
* synthesizing an error result. A trailing orphan is closed only when
|
|
82149
|
+
* `synthesizeMissing` is set — otherwise it is left for the trim / replay
|
|
82150
|
+
* synthesis. This prevents the provider error "must be followed by tool
|
|
82151
|
+
* messages responding to each tool_call_id" after an interruption (e.g. a
|
|
82152
|
+
* network drop mid-batch).
|
|
82153
|
+
*/
|
|
82154
|
+
function repairToolExchangeAdjacency(messages, options) {
|
|
82155
|
+
let lastNonToolIndex = messages.length - 1;
|
|
82156
|
+
while (lastNonToolIndex >= 0 && messages[lastNonToolIndex]?.role === "tool") lastNonToolIndex -= 1;
|
|
82157
|
+
const out = [];
|
|
82158
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
82159
|
+
for (let i = 0; i < messages.length; i++) {
|
|
82160
|
+
if (consumed.has(i)) continue;
|
|
82161
|
+
const message = messages[i];
|
|
82162
|
+
if (message.role !== "assistant" || message.toolCalls.length === 0) {
|
|
82163
|
+
out.push(message);
|
|
82164
|
+
continue;
|
|
82165
|
+
}
|
|
82166
|
+
out.push(message);
|
|
82167
|
+
const pending = new Set(message.toolCalls.map((toolCall) => toolCall.id));
|
|
82168
|
+
let foreignBetween = false;
|
|
82169
|
+
for (let j = i + 1; j < messages.length && pending.size > 0; j++) {
|
|
82170
|
+
if (consumed.has(j)) continue;
|
|
82171
|
+
const next = messages[j];
|
|
82172
|
+
const toolCallId = next.toolCallId;
|
|
82173
|
+
if (next.role === "tool" && toolCallId !== void 0 && pending.has(toolCallId)) {
|
|
82174
|
+
out.push(next);
|
|
82175
|
+
consumed.add(j);
|
|
82176
|
+
pending.delete(toolCallId);
|
|
82177
|
+
if (foreignBetween) options?.onAnomaly?.({
|
|
82178
|
+
kind: "tool_result_reordered",
|
|
82179
|
+
toolCallId
|
|
82180
|
+
});
|
|
82181
|
+
} else foreignBetween = true;
|
|
82182
|
+
}
|
|
82183
|
+
const isMidHistory = i < lastNonToolIndex;
|
|
82184
|
+
if (options?.synthesizeMissing === true || isMidHistory) for (const missingId of pending) {
|
|
82185
|
+
out.push(makeSyntheticToolResult(missingId));
|
|
82186
|
+
options?.onAnomaly?.({
|
|
82187
|
+
kind: "tool_result_synthesized",
|
|
82188
|
+
toolCallId: missingId,
|
|
82189
|
+
trailing: !isMidHistory
|
|
82190
|
+
});
|
|
82191
|
+
}
|
|
82192
|
+
}
|
|
82193
|
+
return out;
|
|
82194
|
+
}
|
|
82195
|
+
function makeSyntheticToolResult(toolCallId) {
|
|
82196
|
+
return {
|
|
82197
|
+
role: "tool",
|
|
82198
|
+
content: [{
|
|
82199
|
+
type: "text",
|
|
82200
|
+
text: SYNTHETIC_TOOL_RESULT_TEXT
|
|
82201
|
+
}],
|
|
82202
|
+
toolCalls: [],
|
|
82203
|
+
toolCallId
|
|
82204
|
+
};
|
|
82205
|
+
}
|
|
82206
|
+
/**
|
|
82207
|
+
* Drops a trailing open tool exchange from a projected message list: when the
|
|
82208
|
+
* last assistant message carries tool calls whose results never arrived and
|
|
82209
|
+
* nothing follows, truncate from that batch so the compacted history does not
|
|
82210
|
+
* carry an unterminated exchange (which would be rejected or, if synthesized,
|
|
82211
|
+
* pollute the compaction prompt).
|
|
82212
|
+
*/
|
|
82213
|
+
function mergeAdjacentUserMessages(history, _onAnomaly) {
|
|
82206
82214
|
const out = [];
|
|
82207
82215
|
for (const message of history) {
|
|
82208
82216
|
const previous = out.at(-1);
|
|
@@ -82246,10 +82254,10 @@ function stripContextMetadata(message) {
|
|
|
82246
82254
|
}
|
|
82247
82255
|
//#endregion
|
|
82248
82256
|
//#region ../../packages/agent-core/src/agent/compaction/compaction-instruction.md
|
|
82249
|
-
var compaction_instruction_default = "\r\n--- This message is a direct task, not part of the above conversation ---\r\n\r\nYou are now given a task to compact this conversation context according to specific priorities and output requirements.\r\n\r\nOutput text only. DO NOT CALL ANY TOOLS. Calling tools will be rejected and fails the task. You already have all the information you need in the conversation history. You have only one chance.\r\n\r\nThe goal of compaction is to keep essential code patterns, technical details, and architectural decisions for continuing development without losing context after the above messages are cleared work.\r\n\r\n{{ customInstruction }}\r\n\r\n<!-- Memory Memo Extraction (PRIORITY — do not skip) -->\r\n\r\n## 任务经验提取\r\n\r\nAFTER completing the compaction summary below, scan the messages being compacted for **
|
|
82257
|
+
var compaction_instruction_default = "\r\n--- This message is a direct task, not part of the above conversation ---\r\n\r\nYou are now given a task to compact this conversation context according to specific priorities and output requirements.\r\n\r\nOutput text only. DO NOT CALL ANY TOOLS. Calling tools will be rejected and fails the task. You already have all the information you need in the conversation history. You have only one chance.\r\n\r\nThe goal of compaction is to keep essential code patterns, technical details, and architectural decisions for continuing development without losing context after the above messages are cleared work.\r\n\r\n{{ customInstruction }}\r\n\r\n<!-- Memory Memo Extraction (PRIORITY — do not skip) -->\r\n\r\n## 任务经验提取\r\n\r\nAFTER completing the compaction summary below, scan the messages being compacted for **task loops**. A task loop is \"completed\" when:\r\n- The user made a clear request or asked a specific question\r\n- You provided a solution or answer\r\n- The outcome is clear (success, partial success, or failure)\r\n\r\n**You MUST output at least one memory-memo block** (or the `{\"none\": true}` marker) at the very end of your response — omitting the section entirely is not allowed. Record completed task loops as full experience records; record **in-progress work** as a lower-priority record whose \"outcome\" is \"进行中\" (so the ongoing task survives compaction and can be resumed later).\r\n\r\nFor each task loop found, output a structured experience record **at the very end of your response**:\r\n\r\n```memory-memo\r\n{\r\n \"userNeed\": \"<the user's need or goal, one sentence>\",\r\n \"approach\": \"<what was done — the approach taken, 2-4 sentences>\",\r\n \"outcome\": \"<final result, e.g. '完成', '部分完成', '失败: reason', or '进行中' for in-progress work>\",\r\n \"whatFailed\": \"<dead ends tried — things that didn't work, or 'none'>\",\r\n \"whatWorked\": \"<key actions that ultimately worked, or 'none'>\",\r\n \"tags\": [\"<tag1>\", \"<tag2>\", \"<tag3>\"],\r\n \"note\": \"<optional: a soft, AI-readable note/suggestion that makes the record easier for future turns to understand — e.g. '这类任务先查接口可用性再写代码'. Omit if none>\"\r\n}\r\n```\r\n\r\nGuidelines:\r\n- Record important failed attempts in \"whatFailed\" to help avoid repeating mistakes.\r\n- Record key successful actions in \"whatWorked\" to help reuse effective approaches.\r\n- Include 3-5 semantic \"tags\" summarizing the task domain, tech stack, or action type (e.g. [\"react\", \"auth\", \"部署\"]).\r\n- \"note\" is optional: a one-sentence advisory note that helps future AI understand/reuse the record faster. It is a soft suggestion, not a user-enforced rule.\r\n- For in-progress work: record it with \"outcome\": \"进行中\" and describe where the task stands and what remains — this is what lets the agent resume seamlessly after compaction.\r\n- Merge closely related sub-tasks into a single record.\r\n- Use the exact field names and JSON format shown above (no extra fields beyond \"note\").\r\n\r\nIf no task loops (completed or in-progress) are found in the compacted messages, output:\r\n```memory-memo\r\n{\"none\": true}\r\n```\r\n\r\n<!-- Compression Priorities (in order) -->\r\n\r\n1. **Current Task State**: What is being worked on RIGHT NOW\r\n2. **Errors & Solutions**: All encountered errors and their resolutions\r\n3. **Code Evolution**: Final working versions only (remove intermediate attempts)\r\n4. **System Context**: Project structure, dependencies, environment setup\r\n5. **Design Decisions**: Architectural choices and their rationale\r\n6. **Next Steps**: The ordered, actionable plan going forward\r\n7. **TODO Items**: Unfinished tasks and known issues\r\n\r\n<!-- Required Output Structure -->\r\n\r\n## Current Focus\r\n\r\n[What we're working on now]\r\n\r\n## Environment\r\n\r\n- [Key setup/config points]\r\n- ...\r\n\r\n## Completed Tasks\r\n\r\n- [Task]: [Brief outcome]\r\n- ...\r\n\r\n## Active Issues\r\n\r\n- [Issue]: [Status/Next steps]\r\n- ...\r\n\r\n## Key Decisions\r\n\r\n- [Decision]: [rationale] — preserve architectural choices and why they were made\r\n- ...\r\n\r\n## Next Steps\r\n\r\n1. [The very next actionable step]\r\n2. [Then this]\r\n3. ...\r\n\r\n## Code State\r\n\r\n### [Critical file name]\r\n\r\n[Brief description of the file's purpose and current state]\r\n\r\n```\r\n[The latest version of critical code snippets in this file, <20 lines]\r\n```\r\n\r\n### [Critical file name]\r\n\r\n- [Useful classes/methods/functions]: [Brief description/usage]\r\n- ...\r\n\r\n<!-- Omit non-critical code, intermediate attempts, and resolved errors -->\r\n\r\n## Important Context\r\n\r\n- [Any crucial information not covered above]\r\n- ...\r\n\r\n## All User Messages\r\n\r\n- [Detailed non tool use user message]\r\n- ...\r\n\r\n## Skill candidates\r\n\r\nScan the compressed messages for reusable processes (project-specific build\r\nsteps, recurring debugging patterns, or tool workflows). If any is genuinely\r\nworth capturing as a reusable skill, output at the very end, at most one:\r\n\r\n[[skill-candidate: <name>|<one-line purpose>|<evidence>]]\r\n\r\n- The evidence must be concrete and verifiable: exact file paths, commands, or\r\n step sequences from the conversation (e.g. \"run `pnpm vitest run -t compaction`\r\n in packages/agent-core to reproduce the compaction snapshots\"). Vague evidence\r\n like \"used a script\" is not acceptable.\r\n- Only emit a candidate when the process is genuinely reusable beyond this one\r\n task; do not emit for one-off actions.\r\n\r\nOmit if none.\r\n";
|
|
82250
82258
|
//#endregion
|
|
82251
82259
|
//#region ../../packages/agent-core/src/agent/compaction/compaction-update-instruction.md
|
|
82252
|
-
var compaction_update_instruction_default = "\r\n--- This message is a direct task, not part of the above conversation ---\r\n\r\nYou are now given a task to UPDATE an existing compaction summary with new messages that came in after the last compaction.\r\n\r\nA previous compaction summary already exists at the top of the conversation (the first assistant message). You must NOT discard it. Instead, merge the new information into the existing structure, keeping all previously captured state intact unless explicitly contradicted or resolved by the new messages.\r\n\r\nOutput text only. DO NOT CALL ANY TOOLS. Calling tools will be rejected and fails the task. You have only one chance.\r\n\r\n{{ customInstruction }}\r\n\r\n<!-- Previous Summary Reference -->\r\n\r\nThe first assistant message above is the PREVIOUS summary. Treat it as the source of truth for everything that happened before the new messages. Do not restate it verbatim — produce an updated, merged summary.\r\n\r\n<!-- Memory Memo Extraction (PRIORITY — do not skip) -->\r\n\r\n## 任务经验提取\r\n\r\nAFTER completing the updated summary below, scan ONLY the new messages being compacted (not those already covered by the previous summary) for **
|
|
82260
|
+
var compaction_update_instruction_default = "\r\n--- This message is a direct task, not part of the above conversation ---\r\n\r\nYou are now given a task to UPDATE an existing compaction summary with new messages that came in after the last compaction.\r\n\r\nA previous compaction summary already exists at the top of the conversation (the first assistant message). You must NOT discard it. Instead, merge the new information into the existing structure, keeping all previously captured state intact unless explicitly contradicted or resolved by the new messages.\r\n\r\nOutput text only. DO NOT CALL ANY TOOLS. Calling tools will be rejected and fails the task. You have only one chance.\r\n\r\n{{ customInstruction }}\r\n\r\n<!-- Previous Summary Reference -->\r\n\r\nThe first assistant message above is the PREVIOUS summary. Treat it as the source of truth for everything that happened before the new messages. Do not restate it verbatim — produce an updated, merged summary.\r\n\r\n<!-- Memory Memo Extraction (PRIORITY — do not skip) -->\r\n\r\n## 任务经验提取\r\n\r\nAFTER completing the updated summary below, scan ONLY the new messages being compacted (not those already covered by the previous summary) for **task loops**. A task loop is \"completed\" when:\r\n- The user made a clear request or asked a specific question\r\n- You provided a solution or answer\r\n- The outcome is clear (success, partial success, or failure)\r\n\r\n**You MUST output at least one memory-memo block** (or the `{\"none\": true}` marker) at the very end of your response — omitting the section entirely is not allowed. Record completed task loops as full experience records; record **in-progress work** as a lower-priority record whose \"outcome\" is \"进行中\" (so the ongoing task survives compaction and can be resumed later).\r\n\r\nFor each task loop found, output a structured experience record **at the very end of your response**:\r\n\r\n```memory-memo\r\n{\r\n \"userNeed\": \"<the user's need or goal, one sentence>\",\r\n \"approach\": \"<what was done — the approach taken, 2-4 sentences>\",\r\n \"outcome\": \"<final result, e.g. '完成', '部分完成', '失败: reason', or '进行中' for in-progress work>\",\r\n \"whatFailed\": \"<dead ends tried — things that didn't work, or 'none'>\",\r\n \"whatWorked\": \"<key actions that ultimately worked, or 'none'>\",\r\n \"tags\": [\"<tag1>\", \"<tag2>\", \"<tag3>\"],\r\n \"note\": \"<optional: a soft, AI-readable note/suggestion that makes the record easier for future turns to understand — e.g. '这类任务先查接口可用性再写代码'. Omit if none>\"\r\n}\r\n```\r\n\r\nGuidelines:\r\n- Record important failed attempts in \"whatFailed\" to help avoid repeating mistakes.\r\n- Record key successful actions in \"whatWorked\" to help reuse effective approaches.\r\n- Include 3-5 semantic \"tags\" summarizing the task domain, tech stack, or action type.\r\n- For in-progress work: record it with \"outcome\": \"进行中\" and describe where the task stands and what remains — this is what lets the agent resume seamlessly after compaction.\r\n- Merge closely related sub-tasks into a single record.\r\n- Use the exact field names and JSON format shown above.\r\n\r\nIf no task loops (completed or in-progress) are found in the new compacted messages, output:\r\n```memory-memo\r\n{\"none\": true}\r\n```\r\n\r\n<!-- Update Rules -->\r\n\r\n1. Preserve the section structure of the previous summary (Current Focus, Environment, Completed Tasks, Active Issues, Key Decisions, Next Steps, Code State, Important Context, All User Messages).\r\n2. Move newly-completed tasks from \"Current Focus\" / \"Active Issues\" into \"Completed Tasks\".\r\n3. Update \"Current Focus\" to reflect what is being worked on RIGHT NOW.\r\n4. Append new user messages to \"All User Messages\" — do not repeat those already captured.\r\n5. Refresh \"Code State\" code snippets only if newer versions exist in the new messages.\r\n6. Drop resolved issues from \"Active Issues\"; add newly-discovered ones.\r\n7. Merge new decisions into \"Key Decisions\" (keep prior decisions unless explicitly overturned); merge new steps into \"Next Steps\" (reorder if priorities changed).\r\n8. Do not invent new information. If the new messages say nothing about a section, carry the previous content forward unchanged.\r\n\r\n<!-- Required Output Structure -->\r\n\r\n## Current Focus\r\n\r\n[What we're working on now]\r\n\r\n## Environment\r\n\r\n- [Key setup/config points]\r\n- ...\r\n\r\n## Completed Tasks\r\n\r\n- [Task]: [Brief outcome]\r\n- ...\r\n\r\n## Active Issues\r\n\r\n- [Issue]: [Status/Next steps]\r\n- ...\r\n\r\n## Key Decisions\r\n\r\n- [Decision]: [rationale] — preserve architectural choices and why they were made\r\n- ...\r\n\r\n## Next Steps\r\n\r\n1. [The very next actionable step]\r\n2. [Then this]\r\n3. ...\r\n\r\n## Code State\r\n\r\n### [Critical file name]\r\n\r\n[Brief description of the file's purpose and current state]\r\n\r\n```\r\n[The latest version of critical code snippets in this file, <20 lines]\r\n```\r\n\r\n## Important Context\r\n\r\n- [Any crucial information not covered above]\r\n- ...\r\n\r\n## All User Messages\r\n\r\n- [Detailed non tool use user message]\r\n- ...\r\n";
|
|
82253
82261
|
//#endregion
|
|
82254
82262
|
//#region ../../packages/agent-core/src/agent/compaction/render-messages.ts
|
|
82255
82263
|
const TOOL_RESULT_MAX_CHARS = 2e3;
|
|
@@ -82341,8 +82349,9 @@ const DEFAULT_COMPACTION_CONFIG = {
|
|
|
82341
82349
|
blockRatio: .85,
|
|
82342
82350
|
reservedContextSize: 5e4,
|
|
82343
82351
|
maxCompactionPerTurn: 3,
|
|
82344
|
-
maxRecentMessages:
|
|
82345
|
-
maxRecentUserMessages:
|
|
82352
|
+
maxRecentMessages: 16,
|
|
82353
|
+
maxRecentUserMessages: 8,
|
|
82354
|
+
maxRecentTokens: 2e4,
|
|
82346
82355
|
maxRecentSizeRatio: .2,
|
|
82347
82356
|
minOverflowReductionRatio: .05,
|
|
82348
82357
|
turnGrowthMultiplier: 2.5
|
|
@@ -82384,7 +82393,7 @@ var DefaultCompactionStrategy = class {
|
|
|
82384
82393
|
if (m2.role === "user") recentUserMessages++;
|
|
82385
82394
|
recentSize += estimateTokensForMessage(m2);
|
|
82386
82395
|
if (canSplitAfter(messages, splitIndex)) bestN = splitIndex + 1;
|
|
82387
|
-
if ((recentMessages >= this.config.maxRecentMessages || recentUserMessages >= this.config.maxRecentUserMessages || recentSize >= this.maxSize * this.config.maxRecentSizeRatio) && bestN !== void 0) break;
|
|
82396
|
+
if ((recentMessages >= this.config.maxRecentMessages || recentUserMessages >= this.config.maxRecentUserMessages || recentSize >= this.config.maxRecentTokens || recentSize >= this.maxSize * this.config.maxRecentSizeRatio) && bestN !== void 0) break;
|
|
82388
82397
|
}
|
|
82389
82398
|
return bestN ?? 0;
|
|
82390
82399
|
}
|
|
@@ -82472,12 +82481,23 @@ function extractFileOpsFromMessage(message, ops) {
|
|
|
82472
82481
|
}
|
|
82473
82482
|
}
|
|
82474
82483
|
}
|
|
82484
|
+
/** Projects a `FileOperations` accumulator into the persistent, sorted
|
|
82485
|
+
* file lists stored on `CompactionResult`. Unlike `formatFileOperations`
|
|
82486
|
+
* this keeps the full list (no `FILE_LIMIT` elision) so later compactions
|
|
82487
|
+
* can merge the previous round's file context without losing entries. */
|
|
82488
|
+
function computeFileLists(ops) {
|
|
82489
|
+
const modified = new Set([...ops.edited, ...ops.written]);
|
|
82490
|
+
return {
|
|
82491
|
+
readFiles: [...ops.read].toSorted(),
|
|
82492
|
+
modifiedFiles: [...modified].toSorted()
|
|
82493
|
+
};
|
|
82494
|
+
}
|
|
82475
82495
|
const FILE_LIMIT = 20;
|
|
82476
82496
|
function formatFileOperations(ops) {
|
|
82477
82497
|
const modified = new Set([...ops.edited, ...ops.written]);
|
|
82478
|
-
const readOnly = [...ops.read].filter((f) => !modified.has(f)).
|
|
82479
|
-
const modifiedFiles = [...modified].
|
|
82480
|
-
const all = [...new Set([...readOnly, ...modifiedFiles])].
|
|
82498
|
+
const readOnly = [...ops.read].filter((f) => !modified.has(f)).toSorted();
|
|
82499
|
+
const modifiedFiles = [...modified].toSorted();
|
|
82500
|
+
const all = [...new Set([...readOnly, ...modifiedFiles])].toSorted();
|
|
82481
82501
|
if (all.length === 0) return "";
|
|
82482
82502
|
const mode = /* @__PURE__ */ new Map();
|
|
82483
82503
|
for (const f of readOnly) mode.set(f, "Read");
|
|
@@ -82620,6 +82640,10 @@ var FullCompaction = class {
|
|
|
82620
82640
|
* limit → overflow → compact cycle from consuming the entire
|
|
82621
82641
|
* maxCompactionPerTurn budget with marginal savings. */
|
|
82622
82642
|
reactiveAttempted = false;
|
|
82643
|
+
/** File lists from the most recent successful compaction. Merged into the
|
|
82644
|
+
* next compaction's file operations so file context accumulates across
|
|
82645
|
+
* repeated compactions instead of being reset each round. */
|
|
82646
|
+
lastCompactionFiles;
|
|
82623
82647
|
compacting = null;
|
|
82624
82648
|
_compactedHistory = [];
|
|
82625
82649
|
strategy;
|
|
@@ -82851,15 +82875,25 @@ var FullCompaction = class {
|
|
|
82851
82875
|
const recent = originalHistory.slice(compactedCount);
|
|
82852
82876
|
const messagesToCompactForOps = originalHistory.slice(0, compactedCount);
|
|
82853
82877
|
const fileOps = createFileOps();
|
|
82878
|
+
if (this.lastCompactionFiles !== void 0 && extractPreviousSummary(originalHistory) !== null) {
|
|
82879
|
+
for (const f of this.lastCompactionFiles.readFiles) fileOps.read.add(f);
|
|
82880
|
+
for (const f of this.lastCompactionFiles.modifiedFiles) fileOps.edited.add(f);
|
|
82881
|
+
} else this.lastCompactionFiles = void 0;
|
|
82854
82882
|
for (const msg of messagesToCompactForOps) extractFileOpsFromMessage(msg, fileOps);
|
|
82855
82883
|
const toolCallHistory = formatToolCallHistory(messagesToCompactForOps);
|
|
82856
|
-
const processedSummary = this.postProcessSummary(summary, fileOps, toolCallHistory);
|
|
82884
|
+
const processedSummary = this.postProcessSummary(summary, fileOps, toolCallHistory, compactedCount);
|
|
82857
82885
|
const tokensAfter = estimateTokens$1(processedSummary) + estimateTokensForMessages(recent);
|
|
82886
|
+
const fileLists = computeFileLists(fileOps);
|
|
82887
|
+
const MAX_PERSISTED_FILES = 100;
|
|
82888
|
+
const readFiles = fileLists.readFiles.slice(0, MAX_PERSISTED_FILES);
|
|
82889
|
+
const modifiedFiles = fileLists.modifiedFiles.slice(0, MAX_PERSISTED_FILES);
|
|
82858
82890
|
const result = {
|
|
82859
82891
|
summary: processedSummary,
|
|
82860
82892
|
compactedCount,
|
|
82861
82893
|
tokensBefore,
|
|
82862
82894
|
tokensAfter,
|
|
82895
|
+
...readFiles.length > 0 ? { readFiles } : {},
|
|
82896
|
+
...modifiedFiles.length > 0 ? { modifiedFiles } : {},
|
|
82863
82897
|
...isUpdate ? { isUpdate: true } : {}
|
|
82864
82898
|
};
|
|
82865
82899
|
this.markCompleted();
|
|
@@ -82868,8 +82902,9 @@ var FullCompaction = class {
|
|
|
82868
82902
|
result
|
|
82869
82903
|
});
|
|
82870
82904
|
this.agent.context.applyCompaction(result);
|
|
82905
|
+
this.lastCompactionFiles = fileLists;
|
|
82871
82906
|
this.lowWaterMark = Math.floor(this.effectiveTokenCount * 1.1);
|
|
82872
|
-
await this.extractAndStoreMemos(processedSummary);
|
|
82907
|
+
await this.extractAndStoreMemos(processedSummary, messagesToCompactForOps);
|
|
82873
82908
|
this.triggerPostCompactHook(data, result);
|
|
82874
82909
|
this.detectSkillCandidates(processedSummary);
|
|
82875
82910
|
this.consecutiveCompactionFailures = 0;
|
|
@@ -82933,16 +82968,27 @@ var FullCompaction = class {
|
|
|
82933
82968
|
}
|
|
82934
82969
|
});
|
|
82935
82970
|
}
|
|
82936
|
-
/** Extract memory memos from compaction summary and store them.
|
|
82937
|
-
|
|
82971
|
+
/** Extract memory memos from compaction summary and store them. When the
|
|
82972
|
+
* summary carries no memory-memo block, fall back to recording the most
|
|
82973
|
+
* recent real user message from the compacted history as a low-confidence
|
|
82974
|
+
* in-progress memo, so an ongoing task survives compaction even if the
|
|
82975
|
+
* model omitted the extraction section. */
|
|
82976
|
+
async extractAndStoreMemos(summary, messagesToCompact) {
|
|
82938
82977
|
const memoStore = this.agent.memoStore;
|
|
82939
82978
|
if (!memoStore) {
|
|
82940
82979
|
this.agent.log.info("Memory memo store not available, skipping extraction");
|
|
82941
82980
|
return;
|
|
82942
82981
|
}
|
|
82943
82982
|
this.agent.log.info("Scanning compaction summary for memory memos", { summaryLen: summary.length });
|
|
82944
|
-
|
|
82983
|
+
let memos = parseMemoryMemos(summary);
|
|
82945
82984
|
this.agent.log.info("Memory memo parse result", { memoCount: memos.length });
|
|
82985
|
+
if (memos.length === 0 && messagesToCompact !== void 0) {
|
|
82986
|
+
const fallback = /```memory-memo[\s\S]*?"none"\s*:\s*true[\s\S]*?```/.test(summary) ? void 0 : this.buildFallbackMemo(messagesToCompact);
|
|
82987
|
+
if (fallback !== void 0) {
|
|
82988
|
+
memos = [fallback];
|
|
82989
|
+
this.agent.log.info("Compaction summary carried no memory-memo; stored fallback memo", { userNeed: fallback.userNeed.slice(0, 120) });
|
|
82990
|
+
}
|
|
82991
|
+
}
|
|
82946
82992
|
if (memos.length === 0) return;
|
|
82947
82993
|
const sessionId = this.agent.homedir ? basename$1(dirname$2(dirname$2(this.agent.homedir))) : "unknown";
|
|
82948
82994
|
const sessionTitle = await this.agent.getSessionTitle();
|
|
@@ -82961,6 +83007,28 @@ var FullCompaction = class {
|
|
|
82961
83007
|
sessionId
|
|
82962
83008
|
});
|
|
82963
83009
|
}
|
|
83010
|
+
/** Build a low-confidence fallback memo from the most recent real user
|
|
83011
|
+
* message in the compacted history (origin.kind === 'user'), so an ongoing
|
|
83012
|
+
* task is not lost when the summary omits the memory-memo section. */
|
|
83013
|
+
buildFallbackMemo(messages) {
|
|
83014
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
83015
|
+
const msg = messages[i];
|
|
83016
|
+
if (msg === void 0 || msg.role !== "user" || msg.origin?.kind !== "user") continue;
|
|
83017
|
+
const text = msg.content.filter((p) => p.type === "text").map((p) => p.text).join("").trim();
|
|
83018
|
+
if (text.length === 0) continue;
|
|
83019
|
+
return createMemoryMemo({
|
|
83020
|
+
sourceSessionId: "",
|
|
83021
|
+
userNeed: text.slice(0, 300),
|
|
83022
|
+
approach: "(压缩时自动兜底记录:压缩摘要未生成完整任务经验提取,此处记录最近一条用户请求,用于跨压缩恢复进行中任务。请结合会话上下文核实。)",
|
|
83023
|
+
outcome: "进行中",
|
|
83024
|
+
whatFailed: "none",
|
|
83025
|
+
whatWorked: "none",
|
|
83026
|
+
tags: ["compaction-fallback"],
|
|
83027
|
+
note: "低置信度自动记录:建议后续在上下文恢复后核实并补充完整经验。",
|
|
83028
|
+
extractionSource: "compaction"
|
|
83029
|
+
});
|
|
83030
|
+
}
|
|
83031
|
+
}
|
|
82964
83032
|
/**
|
|
82965
83033
|
* Detects [[skill-candidate: <name>|<purpose>|<evidence>]] markers in the
|
|
82966
83034
|
* compaction summary and emits a `skill_candidate` event for each one (at
|
|
@@ -82993,10 +83061,18 @@ var FullCompaction = class {
|
|
|
82993
83061
|
* the compaction summary so active tasks and file context survive
|
|
82994
83062
|
* compression. Without this, both are lost after compaction because the
|
|
82995
83063
|
* original messages containing them are removed from the context window.
|
|
83064
|
+
*
|
|
83065
|
+
* When messages were actually compacted (`compactedCount > 0`), a leading
|
|
83066
|
+
* elision note tells the model how much of the conversation is missing and
|
|
83067
|
+
* that the summary is working notes, not verbatim history — so the tail
|
|
83068
|
+
* messages after the summary are not mistaken for a continuous conversation.
|
|
82996
83069
|
*/
|
|
82997
|
-
postProcessSummary(summary, fileOps, toolCallHistory) {
|
|
83070
|
+
postProcessSummary(summary, fileOps, toolCallHistory, compactedCount) {
|
|
82998
83071
|
const todos = this.agent.tools.storeData()["todo"] ?? [];
|
|
82999
|
-
const
|
|
83072
|
+
const base = summary.trim().replaceAll(/<files>[\s\S]*?<\/files>\s*/g, "").replace(/^> The conversation before this point was compacted:[\s\S]*?continue from here\.\s*\n+/m, "").trimEnd();
|
|
83073
|
+
const sections = [];
|
|
83074
|
+
if (compactedCount > 0) sections.push(`> The conversation before this point was compacted: ${String(compactedCount)} earlier message(s) were omitted and are covered by this summary. Treat the summary below as working notes, not verbatim history — the messages after it continue from here.`);
|
|
83075
|
+
if (base.length > 0) sections.push(base);
|
|
83000
83076
|
if (todos.length > 0) {
|
|
83001
83077
|
const lines = todos.map((t) => {
|
|
83002
83078
|
return `- [${t.status === "done" ? "x" : t.status === "in_progress" ? "-" : " "}] ${t.title}`;
|
|
@@ -84473,6 +84549,15 @@ const TOOL_OUTPUT_EMPTY_TEXT = "Tool output is empty.";
|
|
|
84473
84549
|
* result via streaming; only the history copy is truncated. */
|
|
84474
84550
|
const MAX_TOOL_RESULT_TOKENS = 5e3;
|
|
84475
84551
|
const TOOL_TRUNCATION_NOTICE = "\n[content truncated — use read_file to re-read if needed]";
|
|
84552
|
+
const GRAPHEME_SEGMENTER = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
84553
|
+
function splitGraphemes(text) {
|
|
84554
|
+
return Array.from(GRAPHEME_SEGMENTER.segment(text), ({ segment }) => segment);
|
|
84555
|
+
}
|
|
84556
|
+
function estimateGraphemeTokens(grapheme) {
|
|
84557
|
+
let tokens = 0;
|
|
84558
|
+
for (const codePoint of grapheme) tokens += codePoint.codePointAt(0) <= 127 ? 1 / 4 : 1;
|
|
84559
|
+
return tokens;
|
|
84560
|
+
}
|
|
84476
84561
|
var ContextMemory = class {
|
|
84477
84562
|
agent;
|
|
84478
84563
|
_history = [];
|
|
@@ -84655,12 +84740,15 @@ var ContextMemory = class {
|
|
|
84655
84740
|
* message mutated (compaction summary, micro-compaction truncation, or a
|
|
84656
84741
|
* projection repair) and the cache broke from that index.
|
|
84657
84742
|
*
|
|
84658
|
-
*
|
|
84659
|
-
*
|
|
84743
|
+
* Unlike the read-only `messages` getter, this path closes any trailing
|
|
84744
|
+
* in-flight tool call by synthesizing an error result (synthesizeMissing):
|
|
84745
|
+
* these messages go straight to the provider, which rejects an assistant
|
|
84746
|
+
* tool_calls message with no matching tool result (e.g. after a network
|
|
84747
|
+
* drop mid-batch).
|
|
84660
84748
|
*/
|
|
84661
84749
|
messagesForLLM() {
|
|
84662
84750
|
this.agent.microCompaction.detect();
|
|
84663
|
-
const messages = project(this.agent.microCompaction.compact(this.history));
|
|
84751
|
+
const messages = project(this.agent.microCompaction.compact(this.history), { synthesizeMissing: true });
|
|
84664
84752
|
this.observePrefixStability(messages);
|
|
84665
84753
|
return messages;
|
|
84666
84754
|
}
|
|
@@ -84762,6 +84850,31 @@ var ContextMemory = class {
|
|
|
84762
84850
|
hasOpenToolExchange() {
|
|
84763
84851
|
return this.pendingToolResultIds.size > 0;
|
|
84764
84852
|
}
|
|
84853
|
+
/**
|
|
84854
|
+
* Defensive teardown for a live turn that ended — normally, cancelled, or
|
|
84855
|
+
* failed — while recorded tool calls were still awaiting results (e.g. the
|
|
84856
|
+
* batch's result dispatch died after a `tool.call` was already recorded,
|
|
84857
|
+
* like a network drop mid-execution). Synthesizes an error result for each
|
|
84858
|
+
* dangling call so the exchange closes: left open, the assistant tool_calls
|
|
84859
|
+
* message would have no matching tool message and the next request would be
|
|
84860
|
+
* rejected by the provider ("must be followed by tool messages responding
|
|
84861
|
+
* to each tool_call_id"). No-op when the exchange is already closed.
|
|
84862
|
+
*/
|
|
84863
|
+
closeAbandonedToolExchange(output) {
|
|
84864
|
+
if (this.pendingToolResultIds.size === 0) return 0;
|
|
84865
|
+
const interruptedToolCallIds = [...this.pendingToolResultIds];
|
|
84866
|
+
for (const toolCallId of interruptedToolCallIds) this.appendLoopEvent({
|
|
84867
|
+
type: "tool.result",
|
|
84868
|
+
parentUuid: toolCallId,
|
|
84869
|
+
toolCallId,
|
|
84870
|
+
result: {
|
|
84871
|
+
output,
|
|
84872
|
+
isError: true
|
|
84873
|
+
}
|
|
84874
|
+
});
|
|
84875
|
+
this.flushDeferredMessagesIfToolExchangeClosed();
|
|
84876
|
+
return interruptedToolCallIds.length;
|
|
84877
|
+
}
|
|
84765
84878
|
pushHistory(...messages) {
|
|
84766
84879
|
this._history.push(...messages);
|
|
84767
84880
|
for (const message of messages) {
|
|
@@ -84803,22 +84916,23 @@ function truncateToolOutput(text) {
|
|
|
84803
84916
|
if (budget <= 0) return TOOL_TRUNCATION_NOTICE.trim();
|
|
84804
84917
|
const headBudget = Math.floor(budget * .25);
|
|
84805
84918
|
const tailBudget = budget - headBudget;
|
|
84919
|
+
const graphemes = splitGraphemes(text);
|
|
84806
84920
|
let head = "";
|
|
84807
84921
|
let headTokens = 0;
|
|
84808
|
-
for (const
|
|
84809
|
-
const
|
|
84810
|
-
if (headTokens +
|
|
84811
|
-
head +=
|
|
84812
|
-
headTokens +=
|
|
84922
|
+
for (const grapheme of graphemes) {
|
|
84923
|
+
const graphemeTokens = estimateGraphemeTokens(grapheme);
|
|
84924
|
+
if (headTokens + graphemeTokens > headBudget) break;
|
|
84925
|
+
head += grapheme;
|
|
84926
|
+
headTokens += graphemeTokens;
|
|
84813
84927
|
}
|
|
84814
|
-
const reversed =
|
|
84928
|
+
const reversed = graphemes.toReversed();
|
|
84815
84929
|
const tailChars = [];
|
|
84816
84930
|
let tailTokens = 0;
|
|
84817
|
-
for (const
|
|
84818
|
-
const
|
|
84819
|
-
if (tailTokens +
|
|
84820
|
-
tailChars.push(
|
|
84821
|
-
tailTokens +=
|
|
84931
|
+
for (const grapheme of reversed) {
|
|
84932
|
+
const graphemeTokens = estimateGraphemeTokens(grapheme);
|
|
84933
|
+
if (tailTokens + graphemeTokens > tailBudget) break;
|
|
84934
|
+
tailChars.push(grapheme);
|
|
84935
|
+
tailTokens += graphemeTokens;
|
|
84822
84936
|
}
|
|
84823
84937
|
const tail = tailChars.toReversed().join("");
|
|
84824
84938
|
const notice = `\n[content truncated - ~${Math.max(0, Math.round(estimateTokens$1(text) - headTokens - tailTokens))} tokens omitted]\n`;
|
|
@@ -84857,11 +84971,11 @@ function truncateContentParts(parts) {
|
|
|
84857
84971
|
if (remaining > 0) {
|
|
84858
84972
|
let kept = "";
|
|
84859
84973
|
let t = 0;
|
|
84860
|
-
for (const
|
|
84861
|
-
const
|
|
84862
|
-
if (t +
|
|
84863
|
-
kept +=
|
|
84864
|
-
t +=
|
|
84974
|
+
for (const grapheme of splitGraphemes(p.text)) {
|
|
84975
|
+
const graphemeTokens = estimateGraphemeTokens(grapheme);
|
|
84976
|
+
if (t + graphemeTokens > remaining) break;
|
|
84977
|
+
kept += grapheme;
|
|
84978
|
+
t += graphemeTokens;
|
|
84865
84979
|
}
|
|
84866
84980
|
if (kept.length > 0) headParts.push({
|
|
84867
84981
|
type: "text",
|
|
@@ -84886,14 +85000,15 @@ function truncateContentParts(parts) {
|
|
|
84886
85000
|
} else {
|
|
84887
85001
|
const remaining = tailBudget - tailUsed;
|
|
84888
85002
|
if (remaining > 0) {
|
|
84889
|
-
const
|
|
85003
|
+
const graphemes = splitGraphemes(p.text);
|
|
84890
85004
|
let kept = "";
|
|
84891
85005
|
let t = 0;
|
|
84892
|
-
for (let j =
|
|
84893
|
-
const
|
|
84894
|
-
|
|
84895
|
-
|
|
84896
|
-
|
|
85006
|
+
for (let j = graphemes.length - 1; j >= 0; j--) {
|
|
85007
|
+
const grapheme = graphemes[j];
|
|
85008
|
+
const graphemeTokens = estimateGraphemeTokens(grapheme);
|
|
85009
|
+
if (t + graphemeTokens > remaining) break;
|
|
85010
|
+
kept = grapheme + kept;
|
|
85011
|
+
t += graphemeTokens;
|
|
84897
85012
|
}
|
|
84898
85013
|
if (kept.length > 0) tailParts.unshift({
|
|
84899
85014
|
type: "text",
|
|
@@ -102190,6 +102305,11 @@ var ToolCallDeduplicator = class {
|
|
|
102190
102305
|
};
|
|
102191
102306
|
//#endregion
|
|
102192
102307
|
//#region ../../packages/agent-core/src/agent/turn/index.ts
|
|
102308
|
+
/** Builds the error text synthesized for tool calls abandoned when a live
|
|
102309
|
+
* turn ends (cancelled, failed, or completed) before their results arrived. */
|
|
102310
|
+
function abandonedToolResultOutput(ended) {
|
|
102311
|
+
return `Tool call did not complete: ${ended.reason === "cancelled" ? "the turn was cancelled" : ended.reason === "failed" ? `the turn failed${ended.error !== void 0 ? ` (${ended.error.message})` : ""}` : "the turn ended"} before its result was recorded. Do not assume the tool completed successfully.`;
|
|
102312
|
+
}
|
|
102193
102313
|
const GOAL_CONTINUATION_PROMPT = [
|
|
102194
102314
|
"Continue working toward the active goal.",
|
|
102195
102315
|
"Keep the self-audit brief. Do not explore unrelated interpretations once the goal can be",
|
|
@@ -102424,6 +102544,11 @@ var TurnFlow = class {
|
|
|
102424
102544
|
turnId,
|
|
102425
102545
|
reason: "completed"
|
|
102426
102546
|
};
|
|
102547
|
+
try {
|
|
102548
|
+
this.agent.context.closeAbandonedToolExchange(abandonedToolResultOutput(ended));
|
|
102549
|
+
} catch (error) {
|
|
102550
|
+
this.agent.log.error("closeAbandonedToolExchange failed", error);
|
|
102551
|
+
}
|
|
102427
102552
|
this.agent.usage.endTurn();
|
|
102428
102553
|
this.agent.emitEvent(ended);
|
|
102429
102554
|
return ended;
|
|
@@ -102503,6 +102628,11 @@ var TurnFlow = class {
|
|
|
102503
102628
|
};
|
|
102504
102629
|
}
|
|
102505
102630
|
}
|
|
102631
|
+
try {
|
|
102632
|
+
this.agent.context.closeAbandonedToolExchange(abandonedToolResultOutput(ended));
|
|
102633
|
+
} catch (error) {
|
|
102634
|
+
this.agent.log.error("closeAbandonedToolExchange failed", error);
|
|
102635
|
+
}
|
|
102506
102636
|
if (this.currentId === turnId) this.agent.usage.endTurn();
|
|
102507
102637
|
this.agent.emitEvent(ended);
|
|
102508
102638
|
if (standalone && this.currentId === turnId) this.activeTurn = null;
|
|
@@ -108425,7 +108555,7 @@ var SessionSubagentHost = class {
|
|
|
108425
108555
|
text: childPrompt
|
|
108426
108556
|
}], origin);
|
|
108427
108557
|
await runChildTurnToCompletion(child, options.signal);
|
|
108428
|
-
let result = lastAssistantText(child);
|
|
108558
|
+
let result = lastAssistantText$1(child);
|
|
108429
108559
|
let remainingContinuations = SUMMARY_CONTINUATION_ATTEMPTS;
|
|
108430
108560
|
while (remainingContinuations > 0 && result.length < SUMMARY_MIN_LENGTH) {
|
|
108431
108561
|
remainingContinuations -= 1;
|
|
@@ -108435,7 +108565,7 @@ var SessionSubagentHost = class {
|
|
|
108435
108565
|
text: summary_continuation_default
|
|
108436
108566
|
}], origin);
|
|
108437
108567
|
await runChildTurnToCompletion(child, options.signal);
|
|
108438
|
-
result = lastAssistantText(child);
|
|
108568
|
+
result = lastAssistantText$1(child);
|
|
108439
108569
|
}
|
|
108440
108570
|
const usage = child.usage.data().total;
|
|
108441
108571
|
let findingsBlock = "";
|
|
@@ -108551,7 +108681,7 @@ async function runChildTurnToCompletion(child, signal) {
|
|
|
108551
108681
|
function throwIfSubagentStoppedAtMaxTokens(stopReason) {
|
|
108552
108682
|
if (stopReason === "max_tokens") throw new Error(`${SUBAGENT_MAX_TOKENS_ERROR}.`);
|
|
108553
108683
|
}
|
|
108554
|
-
function lastAssistantText(agent) {
|
|
108684
|
+
function lastAssistantText$1(agent) {
|
|
108555
108685
|
for (const message of [...agent.context.history].toReversed()) {
|
|
108556
108686
|
if (message.role !== "assistant") continue;
|
|
108557
108687
|
const text = message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
@@ -126055,10 +126185,10 @@ var NexumAuthFacade = class {
|
|
|
126055
126185
|
};
|
|
126056
126186
|
//#endregion
|
|
126057
126187
|
//#region ../../packages/node-sdk/src/rpc.ts
|
|
126058
|
-
const MAIN_AGENT_ID$
|
|
126188
|
+
const MAIN_AGENT_ID$3 = "main";
|
|
126059
126189
|
var SDKRpcClient = class {
|
|
126060
126190
|
core;
|
|
126061
|
-
interactiveAgentId = MAIN_AGENT_ID$
|
|
126191
|
+
interactiveAgentId = MAIN_AGENT_ID$3;
|
|
126062
126192
|
ready;
|
|
126063
126193
|
rpc;
|
|
126064
126194
|
eventListeners = /* @__PURE__ */ new Set();
|
|
@@ -126636,7 +126766,7 @@ function errorMessage$2(error) {
|
|
|
126636
126766
|
}
|
|
126637
126767
|
//#endregion
|
|
126638
126768
|
//#region ../../packages/node-sdk/src/session.ts
|
|
126639
|
-
const MAIN_AGENT_ID$
|
|
126769
|
+
const MAIN_AGENT_ID$2 = "main";
|
|
126640
126770
|
var Session = class {
|
|
126641
126771
|
id;
|
|
126642
126772
|
workDir;
|
|
@@ -127076,7 +127206,7 @@ var Session = class {
|
|
|
127076
127206
|
this.emit({
|
|
127077
127207
|
type: "session.meta.updated",
|
|
127078
127208
|
sessionId: this.id,
|
|
127079
|
-
agentId: MAIN_AGENT_ID$
|
|
127209
|
+
agentId: MAIN_AGENT_ID$2,
|
|
127080
127210
|
title: patch.title,
|
|
127081
127211
|
patch
|
|
127082
127212
|
});
|
|
@@ -127498,7 +127628,7 @@ function optionalBuildString(value) {
|
|
|
127498
127628
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
127499
127629
|
}
|
|
127500
127630
|
const NEXUM_BUILD_INFO = {
|
|
127501
|
-
version: optionalBuildString("0.12.
|
|
127631
|
+
version: optionalBuildString("0.12.8"),
|
|
127502
127632
|
channel: optionalBuildString(""),
|
|
127503
127633
|
commit: optionalBuildString(""),
|
|
127504
127634
|
buildTarget: optionalBuildString("win32-x64")
|
|
@@ -128484,28 +128614,46 @@ const BUILTIN_SLASH_COMMANDS = [
|
|
|
128484
128614
|
name: "auto",
|
|
128485
128615
|
aliases: [],
|
|
128486
128616
|
description: "registry.auto_desc",
|
|
128487
|
-
priority:
|
|
128617
|
+
priority: 220,
|
|
128488
128618
|
availability: "always"
|
|
128489
128619
|
},
|
|
128490
128620
|
{
|
|
128491
128621
|
name: "yes",
|
|
128492
128622
|
aliases: ["yolo"],
|
|
128493
128623
|
description: "registry.yolo_desc",
|
|
128494
|
-
priority:
|
|
128624
|
+
priority: 219,
|
|
128495
128625
|
availability: "always"
|
|
128496
128626
|
},
|
|
128497
128627
|
{
|
|
128498
128628
|
name: "ask",
|
|
128499
128629
|
aliases: ["ask"],
|
|
128500
128630
|
description: "registry.ask_desc",
|
|
128501
|
-
priority:
|
|
128631
|
+
priority: 218,
|
|
128632
|
+
availability: "always"
|
|
128633
|
+
},
|
|
128634
|
+
{
|
|
128635
|
+
name: "goal",
|
|
128636
|
+
aliases: ["goaloff"],
|
|
128637
|
+
description: "registry.goal_desc",
|
|
128638
|
+
argumentHint: "[objective]",
|
|
128639
|
+
priority: 217,
|
|
128640
|
+
availability: (args) => {
|
|
128641
|
+
const trimmed = args.trim();
|
|
128642
|
+
return trimmed === "" || trimmed === "status" || trimmed === "pause" || trimmed === "off" ? "always" : "idle-only";
|
|
128643
|
+
}
|
|
128644
|
+
},
|
|
128645
|
+
{
|
|
128646
|
+
name: "wolfpack",
|
|
128647
|
+
aliases: ["wp"],
|
|
128648
|
+
description: "registry.wolfpack_desc",
|
|
128649
|
+
priority: 216,
|
|
128502
128650
|
availability: "always"
|
|
128503
128651
|
},
|
|
128504
128652
|
{
|
|
128505
128653
|
name: "rlm",
|
|
128506
128654
|
aliases: ["rlm"],
|
|
128507
128655
|
description: "registry.rlm_desc",
|
|
128508
|
-
priority:
|
|
128656
|
+
priority: 215,
|
|
128509
128657
|
availability: "always"
|
|
128510
128658
|
},
|
|
128511
128659
|
{
|
|
@@ -128513,39 +128661,21 @@ const BUILTIN_SLASH_COMMANDS = [
|
|
|
128513
128661
|
aliases: [],
|
|
128514
128662
|
description: "registry.rlm_max_depth_desc",
|
|
128515
128663
|
argumentHint: "[N]",
|
|
128516
|
-
priority:
|
|
128517
|
-
availability: "always"
|
|
128518
|
-
},
|
|
128519
|
-
{
|
|
128520
|
-
name: "wolfpack",
|
|
128521
|
-
aliases: ["wp"],
|
|
128522
|
-
description: "registry.wolfpack_desc",
|
|
128523
|
-
priority: 122,
|
|
128664
|
+
priority: 214,
|
|
128524
128665
|
availability: "always"
|
|
128525
128666
|
},
|
|
128526
128667
|
{
|
|
128527
128668
|
name: "sessions",
|
|
128528
128669
|
aliases: ["resume"],
|
|
128529
128670
|
description: "registry.sessions_desc",
|
|
128530
|
-
priority:
|
|
128531
|
-
},
|
|
128532
|
-
{
|
|
128533
|
-
name: "goal",
|
|
128534
|
-
aliases: ["goaloff"],
|
|
128535
|
-
description: "registry.goal_desc",
|
|
128536
|
-
argumentHint: "[objective]",
|
|
128537
|
-
priority: 120,
|
|
128538
|
-
availability: (args) => {
|
|
128539
|
-
const trimmed = args.trim();
|
|
128540
|
-
return trimmed === "" || trimmed === "status" || trimmed === "pause" || trimmed === "off" ? "always" : "idle-only";
|
|
128541
|
-
}
|
|
128671
|
+
priority: 213
|
|
128542
128672
|
},
|
|
128543
128673
|
{
|
|
128544
128674
|
name: "memory",
|
|
128545
128675
|
aliases: ["memo", "mem"],
|
|
128546
128676
|
description: "registry.memory_desc",
|
|
128547
128677
|
argumentHint: "[query]",
|
|
128548
|
-
priority:
|
|
128678
|
+
priority: 212,
|
|
128549
128679
|
availability: "always"
|
|
128550
128680
|
},
|
|
128551
128681
|
{
|
|
@@ -128553,96 +128683,61 @@ const BUILTIN_SLASH_COMMANDS = [
|
|
|
128553
128683
|
aliases: ["know"],
|
|
128554
128684
|
description: "registry.knowledge_desc",
|
|
128555
128685
|
argumentHint: "[query]",
|
|
128556
|
-
priority:
|
|
128686
|
+
priority: 211,
|
|
128557
128687
|
availability: "always"
|
|
128558
128688
|
},
|
|
128559
|
-
{
|
|
128560
|
-
name: "new",
|
|
128561
|
-
aliases: ["clear"],
|
|
128562
|
-
description: "registry.new_desc",
|
|
128563
|
-
priority: 120
|
|
128564
|
-
},
|
|
128565
128689
|
{
|
|
128566
128690
|
name: "model",
|
|
128567
128691
|
aliases: [],
|
|
128568
128692
|
description: "registry.model_desc",
|
|
128569
128693
|
argumentHint: "[alias]",
|
|
128570
|
-
priority:
|
|
128694
|
+
priority: 210
|
|
128695
|
+
},
|
|
128696
|
+
{
|
|
128697
|
+
name: "new",
|
|
128698
|
+
aliases: ["clear"],
|
|
128699
|
+
description: "registry.new_desc",
|
|
128700
|
+
priority: 209
|
|
128571
128701
|
},
|
|
128572
128702
|
{
|
|
128573
128703
|
name: "compact",
|
|
128574
128704
|
aliases: [],
|
|
128575
128705
|
description: "registry.compact_desc",
|
|
128576
|
-
priority:
|
|
128706
|
+
priority: 208
|
|
128577
128707
|
},
|
|
128578
128708
|
{
|
|
128579
|
-
name: "
|
|
128580
|
-
aliases: ["
|
|
128581
|
-
description: "registry.
|
|
128582
|
-
priority:
|
|
128583
|
-
availability: "idle-only"
|
|
128709
|
+
name: "fusionplan",
|
|
128710
|
+
aliases: ["fp"],
|
|
128711
|
+
description: "registry.fusionplan_desc",
|
|
128712
|
+
priority: 207,
|
|
128713
|
+
availability: (args) => args.trim().toLowerCase() === "clear" ? "idle-only" : "always"
|
|
128584
128714
|
},
|
|
128585
128715
|
{
|
|
128586
128716
|
name: "plan",
|
|
128587
128717
|
aliases: [],
|
|
128588
128718
|
description: "registry.plan_desc",
|
|
128589
|
-
priority:
|
|
128590
|
-
availability: (args) => args.trim().toLowerCase() === "clear" ? "idle-only" : "always"
|
|
128591
|
-
},
|
|
128592
|
-
{
|
|
128593
|
-
name: "fusionplan",
|
|
128594
|
-
aliases: ["fp"],
|
|
128595
|
-
description: "registry.fusionplan_desc",
|
|
128596
|
-
priority: 118,
|
|
128719
|
+
priority: 206,
|
|
128597
128720
|
availability: (args) => args.trim().toLowerCase() === "clear" ? "idle-only" : "always"
|
|
128598
128721
|
},
|
|
128599
128722
|
{
|
|
128600
128723
|
name: "tasks",
|
|
128601
128724
|
aliases: ["task"],
|
|
128602
128725
|
description: "registry.tasks_desc",
|
|
128603
|
-
priority:
|
|
128604
|
-
availability: "always"
|
|
128605
|
-
},
|
|
128606
|
-
{
|
|
128607
|
-
name: "help",
|
|
128608
|
-
aliases: ["h", "?"],
|
|
128609
|
-
description: "registry.help_desc",
|
|
128610
|
-
priority: 116,
|
|
128611
|
-
availability: "always"
|
|
128612
|
-
},
|
|
128613
|
-
{
|
|
128614
|
-
name: "status",
|
|
128615
|
-
aliases: [],
|
|
128616
|
-
description: "registry.status_desc",
|
|
128617
|
-
priority: 115,
|
|
128618
|
-
availability: "always"
|
|
128619
|
-
},
|
|
128620
|
-
{
|
|
128621
|
-
name: "usage",
|
|
128622
|
-
aliases: [],
|
|
128623
|
-
description: "registry.usage_desc",
|
|
128624
|
-
priority: 114,
|
|
128726
|
+
priority: 205,
|
|
128625
128727
|
availability: "always"
|
|
128626
128728
|
},
|
|
128627
128729
|
{
|
|
128628
128730
|
name: "btw",
|
|
128629
128731
|
aliases: [],
|
|
128630
128732
|
description: "registry.btw_desc",
|
|
128631
|
-
priority:
|
|
128733
|
+
priority: 204,
|
|
128632
128734
|
availability: "always"
|
|
128633
128735
|
},
|
|
128634
128736
|
{
|
|
128635
128737
|
name: "like",
|
|
128636
128738
|
aliases: [],
|
|
128637
128739
|
description: "registry.like_desc",
|
|
128638
|
-
priority:
|
|
128639
|
-
availability: "always"
|
|
128640
|
-
},
|
|
128641
|
-
{
|
|
128642
|
-
name: "mcp",
|
|
128643
|
-
aliases: [],
|
|
128644
|
-
description: "registry.mcp_desc",
|
|
128645
|
-
priority: 112,
|
|
128740
|
+
priority: 203,
|
|
128646
128741
|
availability: "always"
|
|
128647
128742
|
},
|
|
128648
128743
|
{
|
|
@@ -128653,121 +128748,162 @@ const BUILTIN_SLASH_COMMANDS = [
|
|
|
128653
128748
|
"plugins"
|
|
128654
128749
|
],
|
|
128655
128750
|
description: "registry.skill_desc",
|
|
128656
|
-
priority:
|
|
128751
|
+
priority: 202,
|
|
128657
128752
|
availability: "always"
|
|
128658
128753
|
},
|
|
128659
128754
|
{
|
|
128660
|
-
name: "
|
|
128755
|
+
name: "fork",
|
|
128661
128756
|
aliases: [],
|
|
128662
|
-
description: "registry.
|
|
128663
|
-
priority:
|
|
128757
|
+
description: "registry.fork_desc",
|
|
128758
|
+
priority: 201
|
|
128759
|
+
},
|
|
128760
|
+
{
|
|
128761
|
+
name: "title",
|
|
128762
|
+
aliases: ["rename"],
|
|
128763
|
+
description: "registry.title_desc",
|
|
128764
|
+
priority: 200,
|
|
128664
128765
|
availability: "always"
|
|
128665
128766
|
},
|
|
128666
128767
|
{
|
|
128667
|
-
name: "
|
|
128768
|
+
name: "config",
|
|
128668
128769
|
aliases: [],
|
|
128669
|
-
description: "registry.
|
|
128670
|
-
priority:
|
|
128770
|
+
description: "registry.config_desc",
|
|
128771
|
+
priority: 199
|
|
128772
|
+
},
|
|
128773
|
+
{
|
|
128774
|
+
name: "help",
|
|
128775
|
+
aliases: ["h", "?"],
|
|
128776
|
+
description: "registry.help_desc",
|
|
128777
|
+
priority: 198,
|
|
128671
128778
|
availability: "always"
|
|
128672
128779
|
},
|
|
128673
128780
|
{
|
|
128674
|
-
name: "
|
|
128675
|
-
aliases: [],
|
|
128676
|
-
description: "registry.
|
|
128677
|
-
priority:
|
|
128781
|
+
name: "make-skill",
|
|
128782
|
+
aliases: ["makeskill", "craftskill"],
|
|
128783
|
+
description: "registry.make_skill_desc",
|
|
128784
|
+
priority: 197,
|
|
128678
128785
|
availability: "idle-only"
|
|
128679
128786
|
},
|
|
128680
128787
|
{
|
|
128681
|
-
name: "
|
|
128788
|
+
name: "mcp",
|
|
128682
128789
|
aliases: [],
|
|
128683
|
-
description: "registry.
|
|
128684
|
-
priority:
|
|
128790
|
+
description: "registry.mcp_desc",
|
|
128791
|
+
priority: 196,
|
|
128792
|
+
availability: "always"
|
|
128685
128793
|
},
|
|
128686
128794
|
{
|
|
128687
|
-
name: "
|
|
128688
|
-
aliases: [
|
|
128689
|
-
description: "registry.
|
|
128690
|
-
priority:
|
|
128795
|
+
name: "status",
|
|
128796
|
+
aliases: [],
|
|
128797
|
+
description: "registry.status_desc",
|
|
128798
|
+
priority: 195,
|
|
128691
128799
|
availability: "always"
|
|
128692
128800
|
},
|
|
128693
128801
|
{
|
|
128694
|
-
name: "
|
|
128802
|
+
name: "usage",
|
|
128695
128803
|
aliases: [],
|
|
128696
|
-
description: "registry.
|
|
128697
|
-
priority:
|
|
128804
|
+
description: "registry.usage_desc",
|
|
128805
|
+
priority: 194,
|
|
128806
|
+
availability: "always"
|
|
128698
128807
|
},
|
|
128699
128808
|
{
|
|
128700
|
-
name: "
|
|
128809
|
+
name: "revoke",
|
|
128701
128810
|
aliases: [],
|
|
128702
|
-
description: "registry.
|
|
128703
|
-
priority:
|
|
128811
|
+
description: "registry.revoke_desc",
|
|
128812
|
+
priority: 193,
|
|
128813
|
+
availability: "idle-only"
|
|
128814
|
+
},
|
|
128815
|
+
{
|
|
128816
|
+
name: "cc",
|
|
128817
|
+
aliases: [],
|
|
128818
|
+
description: "registry.cc_desc",
|
|
128819
|
+
priority: 192,
|
|
128820
|
+
availability: "always"
|
|
128821
|
+
},
|
|
128822
|
+
{
|
|
128823
|
+
name: "cc-connect",
|
|
128824
|
+
aliases: [],
|
|
128825
|
+
description: "registry.cc_connect_desc",
|
|
128826
|
+
priority: 191,
|
|
128704
128827
|
availability: "always"
|
|
128705
128828
|
},
|
|
128706
128829
|
{
|
|
128707
128830
|
name: "theme",
|
|
128708
128831
|
aliases: [],
|
|
128709
128832
|
description: "registry.theme_desc",
|
|
128710
|
-
priority:
|
|
128833
|
+
priority: 190,
|
|
128711
128834
|
availability: "always"
|
|
128712
128835
|
},
|
|
128713
128836
|
{
|
|
128714
128837
|
name: "language",
|
|
128715
128838
|
aliases: ["lang"],
|
|
128716
128839
|
description: "registry.language_desc",
|
|
128717
|
-
priority:
|
|
128840
|
+
priority: 189,
|
|
128841
|
+
availability: "always"
|
|
128842
|
+
},
|
|
128843
|
+
{
|
|
128844
|
+
name: "permission",
|
|
128845
|
+
aliases: [],
|
|
128846
|
+
description: "registry.permission_desc",
|
|
128847
|
+
priority: 188,
|
|
128718
128848
|
availability: "always"
|
|
128719
128849
|
},
|
|
128720
128850
|
{
|
|
128721
128851
|
name: "editor",
|
|
128722
128852
|
aliases: [],
|
|
128723
128853
|
description: "registry.editor_desc",
|
|
128724
|
-
priority:
|
|
128854
|
+
priority: 187,
|
|
128725
128855
|
availability: "always"
|
|
128726
128856
|
},
|
|
128727
128857
|
{
|
|
128728
128858
|
name: "settings",
|
|
128729
128859
|
aliases: [],
|
|
128730
128860
|
description: "registry.settings_desc",
|
|
128731
|
-
priority:
|
|
128861
|
+
priority: 186,
|
|
128732
128862
|
availability: "always"
|
|
128733
128863
|
},
|
|
128734
128864
|
{
|
|
128735
128865
|
name: "init",
|
|
128736
128866
|
aliases: [],
|
|
128737
128867
|
description: "registry.init_desc",
|
|
128738
|
-
priority:
|
|
128868
|
+
priority: 185
|
|
128739
128869
|
},
|
|
128740
128870
|
{
|
|
128741
128871
|
name: "export-md",
|
|
128742
128872
|
aliases: ["export"],
|
|
128743
128873
|
description: "registry.export_md_desc",
|
|
128744
|
-
priority:
|
|
128874
|
+
priority: 184
|
|
128745
128875
|
},
|
|
128746
128876
|
{
|
|
128747
128877
|
name: "export-debug-zip",
|
|
128748
128878
|
aliases: [],
|
|
128749
128879
|
description: "registry.export_debug_desc",
|
|
128750
|
-
priority:
|
|
128880
|
+
priority: 183
|
|
128881
|
+
},
|
|
128882
|
+
{
|
|
128883
|
+
name: "eval",
|
|
128884
|
+
aliases: [],
|
|
128885
|
+
description: "registry.eval_desc",
|
|
128886
|
+
priority: 182
|
|
128751
128887
|
},
|
|
128752
128888
|
{
|
|
128753
128889
|
name: "update",
|
|
128754
128890
|
aliases: [],
|
|
128755
128891
|
description: "registry.update_desc",
|
|
128756
|
-
priority:
|
|
128892
|
+
priority: 181,
|
|
128757
128893
|
availability: "idle-only"
|
|
128758
128894
|
},
|
|
128759
128895
|
{
|
|
128760
128896
|
name: "version",
|
|
128761
128897
|
aliases: [],
|
|
128762
128898
|
description: "registry.version_desc",
|
|
128763
|
-
priority:
|
|
128899
|
+
priority: 180,
|
|
128764
128900
|
availability: "always"
|
|
128765
128901
|
},
|
|
128766
128902
|
{
|
|
128767
128903
|
name: "logout",
|
|
128768
128904
|
aliases: ["disconnect"],
|
|
128769
128905
|
description: "registry.logout_desc",
|
|
128770
|
-
priority:
|
|
128906
|
+
priority: 179
|
|
128771
128907
|
},
|
|
128772
128908
|
{
|
|
128773
128909
|
name: "exit",
|
|
@@ -128885,7 +129021,7 @@ function getCtrlDHint() {
|
|
|
128885
129021
|
function getCtrlCHint() {
|
|
128886
129022
|
return t("constant.ctrl_c_hint");
|
|
128887
129023
|
}
|
|
128888
|
-
const MAIN_AGENT_ID = "main";
|
|
129024
|
+
const MAIN_AGENT_ID$1 = "main";
|
|
128889
129025
|
const EXIT_CONFIRM_WINDOW_MS = 1500;
|
|
128890
129026
|
function isManagedUsageProvider(providerKey) {
|
|
128891
129027
|
return providerKey === DEFAULT_OAUTH_PROVIDER_NAME;
|
|
@@ -129856,7 +129992,7 @@ async function handleConnectCommand(host, args) {
|
|
|
129856
129992
|
ok: false,
|
|
129857
129993
|
label: "Failed to load catalog."
|
|
129858
129994
|
});
|
|
129859
|
-
host.showError(
|
|
129995
|
+
host.showError(t("auth.catalog_fetch_failed", { error: formatErrorMessage(error) }));
|
|
129860
129996
|
}
|
|
129861
129997
|
}
|
|
129862
129998
|
}
|
|
@@ -131409,7 +131545,15 @@ const HEADING_HASH_PREFIX = /^((?:\u001B\[[0-9;]*m)*)#{1,6}[ \t]+/;
|
|
|
131409
131545
|
* takes one formatter function per token; tokens not listed here fall back to
|
|
131410
131546
|
* its DEFAULT_THEME.
|
|
131411
131547
|
*/
|
|
131412
|
-
|
|
131548
|
+
/**
|
|
131549
|
+
* Markdown code-block highlight theme: green-dominant mapping (keyword,
|
|
131550
|
+
* function, built_in → primary; strings → success; numbers → warning;
|
|
131551
|
+
* comments → textDim). Kept distinct from the shared preview theme in
|
|
131552
|
+
* code-highlight-theme.ts on purpose — markdown code blocks use the green
|
|
131553
|
+
* primary hue, while file-preview panels use the classic blue/red/yellow
|
|
131554
|
+
* scheme mapped to the same palette. Both follow the active theme.
|
|
131555
|
+
*/
|
|
131556
|
+
function createMarkdownCodeHighlightTheme(colors) {
|
|
131413
131557
|
const keyword = chalk.hex(colors.primary);
|
|
131414
131558
|
const str = chalk.hex(colors.success);
|
|
131415
131559
|
const comment = chalk.hex(colors.textDim);
|
|
@@ -131459,7 +131603,7 @@ function createMarkdownTheme(colors) {
|
|
|
131459
131603
|
const stripHash = (text) => text.replace(HEADING_HASH_PREFIX, "$1");
|
|
131460
131604
|
const muted = chalk.hex(colors.textMuted);
|
|
131461
131605
|
const border = chalk.hex(colors.border);
|
|
131462
|
-
const codeTheme =
|
|
131606
|
+
const codeTheme = createMarkdownCodeHighlightTheme(colors);
|
|
131463
131607
|
return {
|
|
131464
131608
|
heading: (text) => chalk.bold.hex(colors.text)(stripHash(text)),
|
|
131465
131609
|
link: (text) => chalk.hex(colors.mdLink)(text),
|
|
@@ -133284,7 +133428,7 @@ async function guidedGoalSetup(host) {
|
|
|
133284
133428
|
host.showNotice(t("goal.storm_breaker"), t("goal.conflict_loop"));
|
|
133285
133429
|
return;
|
|
133286
133430
|
}
|
|
133287
|
-
const { TextInputDialogComponent } = await import("./text-input-dialog-
|
|
133431
|
+
const { TextInputDialogComponent } = await import("./text-input-dialog-CaC9DMZb.mjs");
|
|
133288
133432
|
const initialDesc = await promptText(host, TextInputDialogComponent, {
|
|
133289
133433
|
title: t("goal.setup_title_initial"),
|
|
133290
133434
|
subtitle: t("goal.setup_desc_hint"),
|
|
@@ -133305,7 +133449,7 @@ async function guidedGoalSetup(host) {
|
|
|
133305
133449
|
await showGoalConfigWizard(host, session, confirmed.trim() || objective, false);
|
|
133306
133450
|
}
|
|
133307
133451
|
async function showGoalConfigWizard(host, session, objective, replace) {
|
|
133308
|
-
const { TextInputDialogComponent } = await import("./text-input-dialog-
|
|
133452
|
+
const { TextInputDialogComponent } = await import("./text-input-dialog-CaC9DMZb.mjs");
|
|
133309
133453
|
const turnInput = await promptNumber(host, TextInputDialogComponent, {
|
|
133310
133454
|
title: t("goal.wizard_title", { objective }),
|
|
133311
133455
|
subtitle: t("goal.budget_turns_hint"),
|
|
@@ -134120,7 +134264,7 @@ var AssistantMessageComponent = class {
|
|
|
134120
134264
|
const age = Date.now() - (this.fadeStartMs ?? 0);
|
|
134121
134265
|
this.cachedWidth = void 0;
|
|
134122
134266
|
this.cachedLines = void 0;
|
|
134123
|
-
this.ui?.
|
|
134267
|
+
this.ui?.requestRender();
|
|
134124
134268
|
if (age >= 1200) this.stopFade();
|
|
134125
134269
|
}, FADE_TICK_MS);
|
|
134126
134270
|
this.ui.requestRender();
|
|
@@ -134614,7 +134758,7 @@ var ThinkingComponent = class {
|
|
|
134614
134758
|
if (this.ui === void 0 || this.spinnerInterval !== void 0) return;
|
|
134615
134759
|
this.spinnerInterval = setInterval(() => {
|
|
134616
134760
|
this.spinnerFrame = (this.spinnerFrame + 1) % BRAILLE_SPINNER_FRAMES.length;
|
|
134617
|
-
this.ui?.
|
|
134761
|
+
this.ui?.requestRender();
|
|
134618
134762
|
}, 80);
|
|
134619
134763
|
}
|
|
134620
134764
|
stopSpinner() {
|
|
@@ -134673,6 +134817,60 @@ var CachedContainer = class extends Container {
|
|
|
134673
134817
|
}
|
|
134674
134818
|
};
|
|
134675
134819
|
//#endregion
|
|
134820
|
+
//#region src/tui/theme/code-highlight-theme.ts
|
|
134821
|
+
function createCodeHighlightTheme(colors) {
|
|
134822
|
+
const keyword = chalk.hex(colors.mdCodeBlock);
|
|
134823
|
+
const str = chalk.hex(colors.error);
|
|
134824
|
+
const num = chalk.hex(colors.primary);
|
|
134825
|
+
const fn = chalk.hex(colors.warning);
|
|
134826
|
+
const builtin = chalk.hex(colors.planMode);
|
|
134827
|
+
const cls = chalk.hex(colors.accent);
|
|
134828
|
+
const text = chalk.hex(colors.text);
|
|
134829
|
+
return {
|
|
134830
|
+
keyword,
|
|
134831
|
+
built_in: builtin,
|
|
134832
|
+
type: keyword,
|
|
134833
|
+
literal: builtin,
|
|
134834
|
+
number: num,
|
|
134835
|
+
regexp: str,
|
|
134836
|
+
string: str,
|
|
134837
|
+
subst: str,
|
|
134838
|
+
symbol: num,
|
|
134839
|
+
class: cls,
|
|
134840
|
+
function: fn,
|
|
134841
|
+
title: fn,
|
|
134842
|
+
params: text,
|
|
134843
|
+
comment: num,
|
|
134844
|
+
doctag: num,
|
|
134845
|
+
meta: chalk.hex(colors.textMuted),
|
|
134846
|
+
"meta-keyword": keyword,
|
|
134847
|
+
"meta-string": str,
|
|
134848
|
+
section: keyword,
|
|
134849
|
+
tag: keyword,
|
|
134850
|
+
name: fn,
|
|
134851
|
+
"builtin-name": builtin,
|
|
134852
|
+
attr: fn,
|
|
134853
|
+
attribute: fn,
|
|
134854
|
+
variable: text,
|
|
134855
|
+
bullet: num,
|
|
134856
|
+
code: str,
|
|
134857
|
+
emphasis: (s) => chalk.italic(s),
|
|
134858
|
+
strong: (s) => chalk.bold(s),
|
|
134859
|
+
formula: text,
|
|
134860
|
+
link: chalk.hex(colors.mdLink),
|
|
134861
|
+
quote: chalk.hex(colors.mdQuote),
|
|
134862
|
+
addition: chalk.hex(colors.diffAdded),
|
|
134863
|
+
deletion: chalk.hex(colors.diffRemoved),
|
|
134864
|
+
"selector-tag": keyword,
|
|
134865
|
+
"selector-id": cls,
|
|
134866
|
+
"selector-class": cls,
|
|
134867
|
+
"selector-attr": fn,
|
|
134868
|
+
"selector-pseudo": fn,
|
|
134869
|
+
"template-tag": str,
|
|
134870
|
+
"template-variable": fn
|
|
134871
|
+
};
|
|
134872
|
+
}
|
|
134873
|
+
//#endregion
|
|
134676
134874
|
//#region src/tui/components/media/code-highlight.ts
|
|
134677
134875
|
/**
|
|
134678
134876
|
* Shared syntax-highlighting helpers for code previews
|
|
@@ -134710,13 +134908,14 @@ function langFromPath(filePath) {
|
|
|
134710
134908
|
const lang = EXT_LANG_MAP[ext] ?? ext;
|
|
134711
134909
|
return supportsLanguage(lang) ? lang : void 0;
|
|
134712
134910
|
}
|
|
134713
|
-
function highlightLines(code, lang) {
|
|
134911
|
+
function highlightLines(code, lang, colors) {
|
|
134714
134912
|
const normalizedLang = lang?.trim().toLowerCase();
|
|
134715
134913
|
if (!normalizedLang || !supportsLanguage(normalizedLang)) return code.split("\n");
|
|
134716
134914
|
try {
|
|
134717
134915
|
return highlight(code, {
|
|
134718
134916
|
language: normalizedLang,
|
|
134719
|
-
ignoreIllegals: true
|
|
134917
|
+
ignoreIllegals: true,
|
|
134918
|
+
theme: createCodeHighlightTheme(colors)
|
|
134720
134919
|
}).split("\n");
|
|
134721
134920
|
} catch {
|
|
134722
134921
|
return code.split("\n");
|
|
@@ -134778,10 +134977,12 @@ function visualizeIndent(line) {
|
|
|
134778
134977
|
}
|
|
134779
134978
|
/**
|
|
134780
134979
|
* Render a diff line's code with leading-whitespace visualization (tabs as
|
|
134781
|
-
* `->`, spaces as `·`, dimmed) and optional syntax highlighting.
|
|
134782
|
-
* runs on the raw code
|
|
134783
|
-
*
|
|
134784
|
-
*
|
|
134980
|
+
* `->`, spaces as `·`, dimmed) and optional syntax highlighting. Indent
|
|
134981
|
+
* visualization runs on the raw code FIRST, then highlighting runs on the
|
|
134982
|
+
* stripped remainder: once the text is ANSI-tinted (the theme's `default`
|
|
134983
|
+
* color wraps whitespace too), a leading tab is no longer the first raw
|
|
134984
|
+
* character and would be missed. The dimmed indent itself carries no token
|
|
134985
|
+
* color.
|
|
134785
134986
|
*
|
|
134786
134987
|
* When highlighting is on and produced token colors, the diff line color is
|
|
134787
134988
|
* layered as the base foreground: syntax tokens override it, but every ANSI
|
|
@@ -134790,17 +134991,18 @@ function visualizeIndent(line) {
|
|
|
134790
134991
|
* When highlighting is off (streaming) or produced no token colors, the code
|
|
134791
134992
|
* part is colored with the diff line color instead.
|
|
134792
134993
|
*/
|
|
134793
|
-
function renderDiffCode(code, colorFn, highlight, lang) {
|
|
134794
|
-
const { text, indentEnd } = visualizeIndent(
|
|
134994
|
+
function renderDiffCode(code, colorFn, highlight, lang, colors) {
|
|
134995
|
+
const { text, indentEnd } = visualizeIndent(code);
|
|
134795
134996
|
const indent = text.slice(0, indentEnd);
|
|
134796
134997
|
const rest = text.slice(indentEnd);
|
|
134797
134998
|
const dimIndent = indent.length > 0 ? chalk.dim(indent) : indent;
|
|
134798
|
-
|
|
134999
|
+
const source = highlight ? highlightLines(rest, lang, colors)[0] ?? rest : rest;
|
|
135000
|
+
if (highlight && ANSI_RE.test(source)) {
|
|
134799
135001
|
const prefix = extractAnsiPrefix(colorFn);
|
|
134800
|
-
if (prefix.length > 0) return dimIndent + prefix +
|
|
134801
|
-
return dimIndent +
|
|
135002
|
+
if (prefix.length > 0) return dimIndent + prefix + source.replace(ANSI_RESET_RE, (m) => m + prefix) + "\x1B[39m";
|
|
135003
|
+
return dimIndent + source;
|
|
134802
135004
|
}
|
|
134803
|
-
return dimIndent + colorFn(
|
|
135005
|
+
return dimIndent + colorFn(source);
|
|
134804
135006
|
}
|
|
134805
135007
|
/**
|
|
134806
135008
|
* Compute word-level diff between two single lines and highlight the changed
|
|
@@ -134934,7 +135136,7 @@ function renderDiffLines(oldText, newText, path, colors, isIncomplete = false, o
|
|
|
134934
135136
|
const line = shown[i];
|
|
134935
135137
|
const marker = line.kind === "add" ? "+" : "-";
|
|
134936
135138
|
const color = line.kind === "add" ? s.add : s.del;
|
|
134937
|
-
output.push(s.gutter(String(line.lineNum).padStart(4) + " ") + color(`${marker} `) + renderDiffCode(line.code, color, doHighlight, lang));
|
|
135139
|
+
output.push(s.gutter(String(line.lineNum).padStart(4) + " ") + color(`${marker} `) + renderDiffCode(line.code, color, doHighlight, lang, colors));
|
|
134938
135140
|
i += 1;
|
|
134939
135141
|
}
|
|
134940
135142
|
const hidden = changedLines.length - shown.length;
|
|
@@ -134985,11 +135187,11 @@ function buildClusters(diffLines, contextLines) {
|
|
|
134985
135187
|
removedCount: removed
|
|
134986
135188
|
};
|
|
134987
135189
|
}
|
|
134988
|
-
function formatDiffRow(line, s, doHighlight, lang) {
|
|
135190
|
+
function formatDiffRow(line, s, doHighlight, lang, colors) {
|
|
134989
135191
|
const gutter = s.gutter(String(line.lineNum).padStart(4) + " ");
|
|
134990
|
-
if (line.kind === "add") return gutter + s.add("+ ") + renderDiffCode(line.code, s.add, doHighlight, lang);
|
|
134991
|
-
if (line.kind === "delete") return gutter + s.del("- ") + renderDiffCode(line.code, s.del, doHighlight, lang);
|
|
134992
|
-
return gutter + " " + renderDiffCode(line.code, (x) => x, doHighlight, lang);
|
|
135192
|
+
if (line.kind === "add") return gutter + s.add("+ ") + renderDiffCode(line.code, s.add, doHighlight, lang, colors);
|
|
135193
|
+
if (line.kind === "delete") return gutter + s.del("- ") + renderDiffCode(line.code, s.del, doHighlight, lang, colors);
|
|
135194
|
+
return gutter + " " + renderDiffCode(line.code, (x) => x, doHighlight, lang, colors);
|
|
134993
135195
|
}
|
|
134994
135196
|
/**
|
|
134995
135197
|
* Render a diff with surrounding context, eliding unchanged middle
|
|
@@ -135060,7 +135262,7 @@ function renderDiffLinesClustered(oldText, newText, path, colors, opts = {}) {
|
|
|
135060
135262
|
i += 2;
|
|
135061
135263
|
continue;
|
|
135062
135264
|
}
|
|
135063
|
-
output.push(formatDiffRow(line, s, doHighlight, lang));
|
|
135265
|
+
output.push(formatDiffRow(line, s, doHighlight, lang, colors));
|
|
135064
135266
|
body++;
|
|
135065
135267
|
if (line.kind !== "context") shownChanges++;
|
|
135066
135268
|
prevEnd = i;
|
|
@@ -136943,7 +137145,7 @@ var ToolCallComponent = class ToolCallComponent extends CachedContainer {
|
|
|
136943
137145
|
if (name === "Write") {
|
|
136944
137146
|
const content = str(this.toolCall.args["content"]);
|
|
136945
137147
|
if (content.length === 0) return;
|
|
136946
|
-
const allLines = highlightLines(content, langFromPath(str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"])));
|
|
137148
|
+
const allLines = highlightLines(content, langFromPath(str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"])), this.colors);
|
|
136947
137149
|
const writeShouldCap = !this.expanded;
|
|
136948
137150
|
const shown = writeShouldCap ? allLines.slice(0, 10) : allLines;
|
|
136949
137151
|
const remaining = allLines.length - shown.length;
|
|
@@ -137048,7 +137250,7 @@ var ToolCallComponent = class ToolCallComponent extends CachedContainer {
|
|
|
137048
137250
|
const fragmentEnd = Math.min(streamText.length, fragmentStart + ToolCallComponent.WRITE_STREAM_TAIL_RAW_CHARS);
|
|
137049
137251
|
const fragment = unescapeJsonStringValue(streamText, fragmentStart, fragmentEnd);
|
|
137050
137252
|
if (fragment.length === 0) return;
|
|
137051
|
-
const lines = highlightLines(fragment, this.writeStreamLang);
|
|
137253
|
+
const lines = highlightLines(fragment, this.writeStreamLang, this.colors);
|
|
137052
137254
|
const displayLines = lines.slice(-10);
|
|
137053
137255
|
const firstFragmentLineNo = this.writeStreamNlCount + (tailStart > contentStart ? 2 : 1);
|
|
137054
137256
|
const skipped = lines.length - displayLines.length;
|
|
@@ -139056,7 +139258,7 @@ var MoonLoader = class extends Text {
|
|
|
139056
139258
|
const frame = BRAILLE_SPINNER_FRAMES[this.currentFrame];
|
|
139057
139259
|
const coloredFrame = this.colorFn ? this.colorFn(frame) : frame;
|
|
139058
139260
|
this.setText(this.label ? `${coloredFrame} ${this.label}` : coloredFrame);
|
|
139059
|
-
this.ui.
|
|
139261
|
+
this.ui.requestRender();
|
|
139060
139262
|
}
|
|
139061
139263
|
};
|
|
139062
139264
|
//#endregion
|
|
@@ -139192,9 +139394,6 @@ function getFallbackSkillMarketplace() {
|
|
|
139192
139394
|
}
|
|
139193
139395
|
//#endregion
|
|
139194
139396
|
//#region src/tui/utils/component-capabilities.ts
|
|
139195
|
-
function isExpandable(obj) {
|
|
139196
|
-
return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
|
|
139197
|
-
}
|
|
139198
139397
|
function isPlanExpandable(obj) {
|
|
139199
139398
|
return typeof obj === "object" && obj !== null && "setPlanExpanded" in obj && typeof obj.setPlanExpanded === "function";
|
|
139200
139399
|
}
|
|
@@ -141878,6 +142077,429 @@ async function handleKnowledgeCommand(host, _args) {
|
|
|
141878
142077
|
showMenu();
|
|
141879
142078
|
}
|
|
141880
142079
|
//#endregion
|
|
142080
|
+
//#region ../../packages/evals/src/judge.ts
|
|
142081
|
+
/** Runs every rule against the input; a rule passes when its check is true. */
|
|
142082
|
+
function judgeOutput(input, rules) {
|
|
142083
|
+
const passed = [];
|
|
142084
|
+
const failed = [];
|
|
142085
|
+
for (const rule of rules) if (rule.check(input)) passed.push(rule.name);
|
|
142086
|
+
else failed.push(rule.name);
|
|
142087
|
+
return {
|
|
142088
|
+
passed,
|
|
142089
|
+
failed
|
|
142090
|
+
};
|
|
142091
|
+
}
|
|
142092
|
+
//#endregion
|
|
142093
|
+
//#region ../../packages/evals/src/harness.ts
|
|
142094
|
+
/**
|
|
142095
|
+
* Minimal end-to-end eval harness built on the public node-sdk
|
|
142096
|
+
* `NexumHarness`. Each eval run gets an isolated temp **workspace** so runs
|
|
142097
|
+
* never touch real project files; the nexum home defaults to the real one so
|
|
142098
|
+
* the provider/API-key configuration in `~/.nexum-code/config.toml` is
|
|
142099
|
+
* honored (pass `nexumHome` to override for fully isolated runs). Model
|
|
142100
|
+
* selection follows `NEXUM_EVAL_MODEL` (e.g. `provider/model`);
|
|
142101
|
+
* when unset the harness throws with a clear message.
|
|
142102
|
+
*/
|
|
142103
|
+
/** The main agent id; only its events settle the eval turn wait. */
|
|
142104
|
+
const MAIN_AGENT_ID = "main";
|
|
142105
|
+
/** The current nexum default model, when resolvable from config. */
|
|
142106
|
+
const DEFAULT_EVAL_MODEL = process.env["NEXUM_EVAL_MODEL"];
|
|
142107
|
+
/**
|
|
142108
|
+
* Runs a single end-to-end prompt against a fresh isolated session and
|
|
142109
|
+
* returns the final assistant text plus token usage. The session, workspace
|
|
142110
|
+
* and nexum home are torn down afterwards.
|
|
142111
|
+
*/
|
|
142112
|
+
async function runEvalPrompt(input, options = {}) {
|
|
142113
|
+
const workDir = options.workDir ?? await mkdtemp(join(tmpdir(), "nexum-eval-ws-"));
|
|
142114
|
+
const nexumHome = options.nexumHome;
|
|
142115
|
+
const createdWorkDir = options.workDir === void 0;
|
|
142116
|
+
let harness;
|
|
142117
|
+
let session;
|
|
142118
|
+
try {
|
|
142119
|
+
for (const fixture of (typeof input === "string" ? [] : input.fixtures) ?? []) await writeFile(join(workDir, fixture.name), fixture.content, "utf-8");
|
|
142120
|
+
const prompt = typeof input === "string" ? input : input.prompt;
|
|
142121
|
+
const model = options.model ?? DEFAULT_EVAL_MODEL;
|
|
142122
|
+
if (model === void 0 || model.length === 0) throw new Error("No eval model configured. Set NEXUM_EVAL_MODEL, e.g. NEXUM_EVAL_MODEL=provider/model pnpm eval");
|
|
142123
|
+
const [provider, modelId, ...rest] = model.split("/");
|
|
142124
|
+
const usageProvider = rest.length > 0 ? model : provider ?? "unknown";
|
|
142125
|
+
const usageModel = modelId === void 0 || rest.length > 0 ? model : modelId;
|
|
142126
|
+
harness = new NexumHarness({ homeDir: nexumHome });
|
|
142127
|
+
session = await harness.createSession({
|
|
142128
|
+
workDir,
|
|
142129
|
+
model,
|
|
142130
|
+
thinking: options.thinking ?? "off",
|
|
142131
|
+
permission: "yolo"
|
|
142132
|
+
});
|
|
142133
|
+
const { timedOut } = await promptAndWaitForTurnEnd(session, prompt);
|
|
142134
|
+
let output = "";
|
|
142135
|
+
try {
|
|
142136
|
+
output = lastAssistantText((await session.getContext()).history);
|
|
142137
|
+
} catch {
|
|
142138
|
+
output = "";
|
|
142139
|
+
}
|
|
142140
|
+
const total = (await session.getUsage().catch(() => void 0))?.total;
|
|
142141
|
+
let verifiedFile = false;
|
|
142142
|
+
if (options.verifyFileAfterTurn !== void 0) try {
|
|
142143
|
+
verifiedFile = await readFile(join(workDir, options.verifyFileAfterTurn.path), "utf-8") === options.verifyFileAfterTurn.content;
|
|
142144
|
+
} catch {
|
|
142145
|
+
verifiedFile = false;
|
|
142146
|
+
}
|
|
142147
|
+
return {
|
|
142148
|
+
output,
|
|
142149
|
+
timedOut,
|
|
142150
|
+
verifiedFile,
|
|
142151
|
+
usage: {
|
|
142152
|
+
provider: usageProvider,
|
|
142153
|
+
model: usageModel,
|
|
142154
|
+
inputTokens: total?.inputOther ?? 0,
|
|
142155
|
+
outputTokens: total?.output ?? 0,
|
|
142156
|
+
totalTokens: (total?.inputOther ?? 0) + (total?.output ?? 0) + (total?.inputCacheRead ?? 0) + (total?.inputCacheCreation ?? 0)
|
|
142157
|
+
}
|
|
142158
|
+
};
|
|
142159
|
+
} finally {
|
|
142160
|
+
if (session !== void 0) await session.close({ extractMemories: false }).catch(() => {});
|
|
142161
|
+
if (createdWorkDir) await rm(workDir, {
|
|
142162
|
+
recursive: true,
|
|
142163
|
+
force: true
|
|
142164
|
+
}).catch(() => {});
|
|
142165
|
+
}
|
|
142166
|
+
}
|
|
142167
|
+
function lastAssistantText(history) {
|
|
142168
|
+
for (let i = history.length - 1; i >= 0; i -= 1) {
|
|
142169
|
+
const message = history[i];
|
|
142170
|
+
if (message.role !== "assistant") continue;
|
|
142171
|
+
const text = (message.content ?? []).filter((part) => part.type === "text" && part.text !== void 0).map((part) => part.text).join("");
|
|
142172
|
+
if (text.trim().length > 0) return text.trim();
|
|
142173
|
+
}
|
|
142174
|
+
return "";
|
|
142175
|
+
}
|
|
142176
|
+
/**
|
|
142177
|
+
* Sends a prompt and resolves when the main agent's turn ends. `Session.prompt`
|
|
142178
|
+
* only enqueues the RPC request; the assistant reply arrives asynchronously as
|
|
142179
|
+
* events, so we must wait for the `turn.ended` event to know the run finished.
|
|
142180
|
+
*
|
|
142181
|
+
* A hard timeout guards against a turn that never ends (e.g. a model looping
|
|
142182
|
+
* through tools instead of converging, or a network interruption). On timeout
|
|
142183
|
+
* we cancel the session so the caller's cleanup path still runs instead of
|
|
142184
|
+
* leaking the session and temp workspace. 90s is enough to complete any
|
|
142185
|
+
* legitimate single-turn tool round-trip; longer waits are almost always a
|
|
142186
|
+
* stuck model, so we fail fast instead of burning tokens.
|
|
142187
|
+
*/
|
|
142188
|
+
const TURN_WAIT_TIMEOUT_MS = 9e4;
|
|
142189
|
+
/**
|
|
142190
|
+
* Resolves with `timedOut: true` when the turn hit the timeout (model looping
|
|
142191
|
+
* or stuck) instead of throwing, so callers can still inspect side effects
|
|
142192
|
+
* (e.g. a file the Write tool already created). Real errors (turn failed /
|
|
142193
|
+
* error event) still reject.
|
|
142194
|
+
*/
|
|
142195
|
+
async function promptAndWaitForTurnEnd(session, prompt) {
|
|
142196
|
+
const { promise, resolve, reject } = promiseWithResolvers();
|
|
142197
|
+
let activeTurnId;
|
|
142198
|
+
let activeAgentId;
|
|
142199
|
+
let settled = false;
|
|
142200
|
+
let timeout;
|
|
142201
|
+
let graceTimer;
|
|
142202
|
+
/** Set once the timeout fires; guards against the cancel-triggered
|
|
142203
|
+
* `turn.ended('cancelled')` being misread as a real failure. */
|
|
142204
|
+
let timeoutFired = false;
|
|
142205
|
+
const finish = (result) => {
|
|
142206
|
+
if (settled) return;
|
|
142207
|
+
settled = true;
|
|
142208
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
142209
|
+
if (graceTimer !== void 0) clearTimeout(graceTimer);
|
|
142210
|
+
if (result instanceof Error) reject(result);
|
|
142211
|
+
else resolve(result);
|
|
142212
|
+
};
|
|
142213
|
+
const unsubscribe = session.onEvent((event) => {
|
|
142214
|
+
if (event.agentId !== MAIN_AGENT_ID) return;
|
|
142215
|
+
if (event.type === "error") {
|
|
142216
|
+
finish(/* @__PURE__ */ new Error(`${event.code}: ${event.message}`));
|
|
142217
|
+
return;
|
|
142218
|
+
}
|
|
142219
|
+
if (event.type === "turn.started" && activeTurnId === void 0) {
|
|
142220
|
+
activeTurnId = event.turnId;
|
|
142221
|
+
activeAgentId = event.agentId;
|
|
142222
|
+
return;
|
|
142223
|
+
}
|
|
142224
|
+
if (activeTurnId === void 0 || activeAgentId === void 0 || !("turnId" in event) || event.turnId !== activeTurnId || event.agentId !== activeAgentId) return;
|
|
142225
|
+
if (event.type === "turn.ended") if (event.reason === "completed") finish({ timedOut: false });
|
|
142226
|
+
else if (timeoutFired && event.reason === "cancelled") return;
|
|
142227
|
+
else finish(/* @__PURE__ */ new Error(`Turn ended with reason: ${event.reason}`));
|
|
142228
|
+
});
|
|
142229
|
+
try {
|
|
142230
|
+
await session.prompt(prompt);
|
|
142231
|
+
timeout = setTimeout(() => {
|
|
142232
|
+
timeoutFired = true;
|
|
142233
|
+
session.cancel().catch(() => {});
|
|
142234
|
+
graceTimer = setTimeout(() => {
|
|
142235
|
+
finish({ timedOut: true });
|
|
142236
|
+
}, 500);
|
|
142237
|
+
}, TURN_WAIT_TIMEOUT_MS);
|
|
142238
|
+
return await promise;
|
|
142239
|
+
} finally {
|
|
142240
|
+
unsubscribe();
|
|
142241
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
142242
|
+
if (graceTimer !== void 0) clearTimeout(graceTimer);
|
|
142243
|
+
}
|
|
142244
|
+
}
|
|
142245
|
+
function promiseWithResolvers() {
|
|
142246
|
+
let resolve;
|
|
142247
|
+
let reject;
|
|
142248
|
+
return {
|
|
142249
|
+
promise: new Promise((res, rej) => {
|
|
142250
|
+
resolve = res;
|
|
142251
|
+
reject = rej;
|
|
142252
|
+
}),
|
|
142253
|
+
resolve,
|
|
142254
|
+
reject
|
|
142255
|
+
};
|
|
142256
|
+
}
|
|
142257
|
+
const EVAL_CASES = [
|
|
142258
|
+
{
|
|
142259
|
+
id: "smoke",
|
|
142260
|
+
name: "Smoke — answers a trivial question",
|
|
142261
|
+
input: "What is the capital of France? Answer in one word.",
|
|
142262
|
+
rules: [{
|
|
142263
|
+
name: "answers the capital",
|
|
142264
|
+
check: (output) => {
|
|
142265
|
+
const lower = output.toLowerCase();
|
|
142266
|
+
return lower.includes("paris") || lower.includes("巴黎");
|
|
142267
|
+
}
|
|
142268
|
+
}],
|
|
142269
|
+
extra: (result) => {
|
|
142270
|
+
const failures = [];
|
|
142271
|
+
if (result.usage.totalTokens <= 0) failures.push("usage.totalTokens must be > 0");
|
|
142272
|
+
if (result.usage.model.length === 0) failures.push("usage.model must be non-empty");
|
|
142273
|
+
return failures;
|
|
142274
|
+
}
|
|
142275
|
+
},
|
|
142276
|
+
{
|
|
142277
|
+
id: "read-file",
|
|
142278
|
+
name: "Regression — reads a file via the Read tool",
|
|
142279
|
+
input: {
|
|
142280
|
+
prompt: "Read the file data.txt in the current directory using the Read tool, then tell me what it contains.",
|
|
142281
|
+
fixtures: [{
|
|
142282
|
+
name: "data.txt",
|
|
142283
|
+
content: "The quick brown fox jumps over the lazy dog."
|
|
142284
|
+
}]
|
|
142285
|
+
},
|
|
142286
|
+
rules: [{
|
|
142287
|
+
name: "reports file content",
|
|
142288
|
+
check: (output) => output.includes("quick brown fox")
|
|
142289
|
+
}]
|
|
142290
|
+
},
|
|
142291
|
+
{
|
|
142292
|
+
id: "write-file",
|
|
142293
|
+
name: "Regression — writes a file via the Write tool",
|
|
142294
|
+
input: { prompt: "Create a file named output.txt in the current directory using the Write tool. Write exactly the text: hello eval world. Make exactly one Write tool call and do not call any other tool afterwards. After the tool completes, immediately answer with the exact text you wrote and nothing else." },
|
|
142295
|
+
rules: [{
|
|
142296
|
+
name: "Write tool landed the file",
|
|
142297
|
+
check: (output) => output.includes("hello eval world")
|
|
142298
|
+
}],
|
|
142299
|
+
verifyFile: {
|
|
142300
|
+
path: "output.txt",
|
|
142301
|
+
content: "hello eval world"
|
|
142302
|
+
},
|
|
142303
|
+
extra: (result) => {
|
|
142304
|
+
const failures = [];
|
|
142305
|
+
if (!result.verifiedFile) failures.push("output.txt was not created with the exact content");
|
|
142306
|
+
return failures;
|
|
142307
|
+
}
|
|
142308
|
+
},
|
|
142309
|
+
{
|
|
142310
|
+
id: "isolated-workspace",
|
|
142311
|
+
name: "Regression — runs in an isolated temp workspace",
|
|
142312
|
+
input: {
|
|
142313
|
+
prompt: "Run \"pwd\" in a shell and answer with only the absolute path that the command printed.",
|
|
142314
|
+
fixtures: [{
|
|
142315
|
+
name: "marker.txt",
|
|
142316
|
+
content: "isolated"
|
|
142317
|
+
}]
|
|
142318
|
+
},
|
|
142319
|
+
rules: [{
|
|
142320
|
+
name: "prints an absolute path",
|
|
142321
|
+
check: (output) => output.match(/(?:\/[\w.\-/]+|[A-Za-z]:[\\/][\w.\\/-]*)/)?.[0] !== void 0
|
|
142322
|
+
}, {
|
|
142323
|
+
name: "path is not the repo",
|
|
142324
|
+
check: (output) => !output.match(/(?:\/[\w.\-/]+|[A-Za-z]:[\\/][\w.\\/-]*)/)?.[0]?.includes("nexum-code")
|
|
142325
|
+
}]
|
|
142326
|
+
}
|
|
142327
|
+
];
|
|
142328
|
+
/** Runs every eval case sequentially and returns a structured report. */
|
|
142329
|
+
async function runAllEvals(options = {}) {
|
|
142330
|
+
const results = [];
|
|
142331
|
+
let passedCount = 0;
|
|
142332
|
+
let failedCount = 0;
|
|
142333
|
+
for (const caseDef of EVAL_CASES) {
|
|
142334
|
+
let result;
|
|
142335
|
+
try {
|
|
142336
|
+
result = await runEvalPrompt(caseDef.input, {
|
|
142337
|
+
model: options.model,
|
|
142338
|
+
verifyFileAfterTurn: caseDef.verifyFile
|
|
142339
|
+
});
|
|
142340
|
+
} catch (error) {
|
|
142341
|
+
results.push({
|
|
142342
|
+
id: caseDef.id,
|
|
142343
|
+
name: caseDef.name,
|
|
142344
|
+
passed: false,
|
|
142345
|
+
failedRules: [],
|
|
142346
|
+
passedRules: [],
|
|
142347
|
+
extraFailures: [],
|
|
142348
|
+
output: "",
|
|
142349
|
+
error: error instanceof Error ? error.message : String(error),
|
|
142350
|
+
timedOut: false,
|
|
142351
|
+
toolCheckFailed: false
|
|
142352
|
+
});
|
|
142353
|
+
failedCount += 1;
|
|
142354
|
+
options.onProgress?.({
|
|
142355
|
+
completed: results.length,
|
|
142356
|
+
total: EVAL_CASES.length,
|
|
142357
|
+
currentId: caseDef.id,
|
|
142358
|
+
currentName: caseDef.name,
|
|
142359
|
+
passed: passedCount,
|
|
142360
|
+
failed: failedCount
|
|
142361
|
+
});
|
|
142362
|
+
continue;
|
|
142363
|
+
}
|
|
142364
|
+
const judged = judgeOutput(result.output, caseDef.rules);
|
|
142365
|
+
const extraFailures = caseDef.extra?.(result) ?? [];
|
|
142366
|
+
const passed = judged.failed.length === 0 && extraFailures.length === 0;
|
|
142367
|
+
if (passed) passedCount += 1;
|
|
142368
|
+
else failedCount += 1;
|
|
142369
|
+
const toolCheckFailed = caseDef.verifyFile !== void 0 && !result.verifiedFile;
|
|
142370
|
+
results.push({
|
|
142371
|
+
id: caseDef.id,
|
|
142372
|
+
name: caseDef.name,
|
|
142373
|
+
passed,
|
|
142374
|
+
failedRules: judged.failed,
|
|
142375
|
+
passedRules: judged.passed,
|
|
142376
|
+
extraFailures,
|
|
142377
|
+
output: result.output,
|
|
142378
|
+
timedOut: result.timedOut,
|
|
142379
|
+
toolCheckFailed
|
|
142380
|
+
});
|
|
142381
|
+
options.onProgress?.({
|
|
142382
|
+
completed: results.length,
|
|
142383
|
+
total: EVAL_CASES.length,
|
|
142384
|
+
currentId: caseDef.id,
|
|
142385
|
+
currentName: caseDef.name,
|
|
142386
|
+
passed: passedCount,
|
|
142387
|
+
failed: failedCount
|
|
142388
|
+
});
|
|
142389
|
+
}
|
|
142390
|
+
return {
|
|
142391
|
+
results,
|
|
142392
|
+
passed: passedCount,
|
|
142393
|
+
failed: failedCount
|
|
142394
|
+
};
|
|
142395
|
+
}
|
|
142396
|
+
//#endregion
|
|
142397
|
+
//#region src/tui/commands/eval.ts
|
|
142398
|
+
const EVAL_PANEL_DISMISS_MS = 6e4;
|
|
142399
|
+
let activeEvalPanel;
|
|
142400
|
+
let activeEvalTimer;
|
|
142401
|
+
/** Guards against overlapping runs (each run calls a real model and costs
|
|
142402
|
+
* tokens; a second /eval while one is running is almost certainly a mistake). */
|
|
142403
|
+
let evalRunning = false;
|
|
142404
|
+
function dismissEvalPanel(state) {
|
|
142405
|
+
if (activeEvalTimer !== void 0) {
|
|
142406
|
+
clearTimeout(activeEvalTimer);
|
|
142407
|
+
activeEvalTimer = void 0;
|
|
142408
|
+
}
|
|
142409
|
+
if (activeEvalPanel !== void 0) {
|
|
142410
|
+
state.transcriptContainer.removeChild(activeEvalPanel);
|
|
142411
|
+
activeEvalPanel = void 0;
|
|
142412
|
+
state.ui.requestRender();
|
|
142413
|
+
}
|
|
142414
|
+
}
|
|
142415
|
+
function clearEvalPanelState(state) {
|
|
142416
|
+
dismissEvalPanel(state);
|
|
142417
|
+
}
|
|
142418
|
+
/** Model selector for eval runs; falls back to the active session model. */
|
|
142419
|
+
function resolveEvalModel(host) {
|
|
142420
|
+
return host.state.appState.model;
|
|
142421
|
+
}
|
|
142422
|
+
/**
|
|
142423
|
+
* Runs the end-to-end evals in the background (they call a real model and can
|
|
142424
|
+
* take minutes) and renders the per-case report when done. Returns immediately
|
|
142425
|
+
* so the TUI keeps responding.
|
|
142426
|
+
*/
|
|
142427
|
+
function runEvalCommand(host) {
|
|
142428
|
+
if (evalRunning) {
|
|
142429
|
+
host.showStatus(t("dispatch.eval_running"));
|
|
142430
|
+
return;
|
|
142431
|
+
}
|
|
142432
|
+
const model = resolveEvalModel(host);
|
|
142433
|
+
if (model === void 0 || model.length === 0) {
|
|
142434
|
+
host.showError(t("dispatch.eval_no_model"));
|
|
142435
|
+
return;
|
|
142436
|
+
}
|
|
142437
|
+
const sessionId = host.state.appState.sessionId;
|
|
142438
|
+
evalRunning = true;
|
|
142439
|
+
host.showStatus(t("dispatch.eval_started", { model }));
|
|
142440
|
+
(async () => {
|
|
142441
|
+
let summary;
|
|
142442
|
+
try {
|
|
142443
|
+
summary = await runAllEvals({
|
|
142444
|
+
model,
|
|
142445
|
+
onProgress: ({ completed, total, passed, failed, currentName }) => {
|
|
142446
|
+
host.showStatus(t("dispatch.eval_progress", {
|
|
142447
|
+
completed: String(completed),
|
|
142448
|
+
total: String(total),
|
|
142449
|
+
passed: String(passed),
|
|
142450
|
+
failed: String(failed),
|
|
142451
|
+
name: currentName
|
|
142452
|
+
}));
|
|
142453
|
+
}
|
|
142454
|
+
});
|
|
142455
|
+
} catch (error) {
|
|
142456
|
+
evalRunning = false;
|
|
142457
|
+
host.showError(t("dispatch.eval_failed", { error: error instanceof Error ? error.message : String(error) }));
|
|
142458
|
+
return;
|
|
142459
|
+
}
|
|
142460
|
+
evalRunning = false;
|
|
142461
|
+
if (sessionId !== void 0 && sessionId !== host.state.appState.sessionId) return;
|
|
142462
|
+
try {
|
|
142463
|
+
renderEvalSummary(host, summary);
|
|
142464
|
+
} catch (error) {
|
|
142465
|
+
host.showError(t("dispatch.eval_failed", { error: error instanceof Error ? error.message : String(error) }));
|
|
142466
|
+
}
|
|
142467
|
+
})();
|
|
142468
|
+
}
|
|
142469
|
+
function renderEvalSummary(host, summary) {
|
|
142470
|
+
const colors = host.state.theme.colors;
|
|
142471
|
+
const lines = [chalk.hex(colors.primary)(`${summary.passed} ${t("dispatch.eval_passed")} · ${summary.failed} ${t("dispatch.eval_failed_count")}`), ""];
|
|
142472
|
+
for (const result of summary.results) {
|
|
142473
|
+
const mark = result.passed ? "✓" : "×";
|
|
142474
|
+
const color = result.passed ? colors.success : colors.error;
|
|
142475
|
+
lines.push(`${chalk.hex(color)(mark)} ${result.name}`);
|
|
142476
|
+
if (result.passed) continue;
|
|
142477
|
+
lines.push(` ${chalk.hex(colors.error)(suggestionFor(result))}`);
|
|
142478
|
+
const details = [];
|
|
142479
|
+
for (const rule of result.failedRules) details.push(rule);
|
|
142480
|
+
for (const failure of result.extraFailures) details.push(failure);
|
|
142481
|
+
if (result.error !== void 0) details.push(result.error);
|
|
142482
|
+
if (result.output.length > 0) details.push(`output: ${result.output.slice(0, 160)}`);
|
|
142483
|
+
for (const detail of details) lines.push(` ${chalk.hex(colors.textDim)(`· ${detail}`)}`);
|
|
142484
|
+
}
|
|
142485
|
+
lines.push("");
|
|
142486
|
+
dismissEvalPanel(host.state);
|
|
142487
|
+
const panel = new UsagePanelComponent(lines, colors.primary, " Eval ");
|
|
142488
|
+
host.state.transcriptContainer.addChild(panel);
|
|
142489
|
+
activeEvalPanel = panel;
|
|
142490
|
+
activeEvalTimer = setTimeout(() => {
|
|
142491
|
+
dismissEvalPanel(host.state);
|
|
142492
|
+
}, EVAL_PANEL_DISMISS_MS);
|
|
142493
|
+
host.state.ui.requestRender();
|
|
142494
|
+
}
|
|
142495
|
+
/** Picks a user-facing self-check hint based on how the case failed. */
|
|
142496
|
+
function suggestionFor(result) {
|
|
142497
|
+
if (result.error !== void 0) return t("dispatch.eval_suggest_error");
|
|
142498
|
+
if (result.timedOut) return t("dispatch.eval_suggest_timeout");
|
|
142499
|
+
if (result.toolCheckFailed) return t("dispatch.eval_suggest_tool");
|
|
142500
|
+
return t("dispatch.eval_suggest_answer");
|
|
142501
|
+
}
|
|
142502
|
+
//#endregion
|
|
141881
142503
|
//#region src/tui/commands/dispatch.ts
|
|
141882
142504
|
function dispatchInput(host, text) {
|
|
141883
142505
|
if (parseSlashInput(text) !== null) {
|
|
@@ -142051,6 +142673,9 @@ async function handleBuiltInSlashCommand(host, name, args) {
|
|
|
142051
142673
|
case "logout":
|
|
142052
142674
|
await handleLogoutCommand(host);
|
|
142053
142675
|
return;
|
|
142676
|
+
case "eval":
|
|
142677
|
+
runEvalCommand(host);
|
|
142678
|
+
return;
|
|
142054
142679
|
case "memory":
|
|
142055
142680
|
await handleMemoryCommand(host, args);
|
|
142056
142681
|
return;
|
|
@@ -142078,6 +142703,17 @@ var AuthFlowController = class {
|
|
|
142078
142703
|
availableModels: config.models ?? {},
|
|
142079
142704
|
availableProviders: config.providers ?? {}
|
|
142080
142705
|
});
|
|
142706
|
+
this.prefetchCatalogCache();
|
|
142707
|
+
}
|
|
142708
|
+
/**
|
|
142709
|
+
* Best-effort background catalog refresh. Fetches the remote catalog and,
|
|
142710
|
+
* on success, updates the on-disk cache. On failure it stays silent: the
|
|
142711
|
+
* existing cache (or built-in) keeps working. Never throws.
|
|
142712
|
+
*/
|
|
142713
|
+
async prefetchCatalogCache() {
|
|
142714
|
+
try {
|
|
142715
|
+
saveCatalogCache(await fetchCatalog(DEFAULT_CATALOG_URL), resolveNexumHome());
|
|
142716
|
+
} catch {}
|
|
142081
142717
|
}
|
|
142082
142718
|
async activateModelAfterLogin(model, thinkingLevel) {
|
|
142083
142719
|
const { host } = this;
|
|
@@ -143426,6 +144062,8 @@ var SessionEventHandler = class {
|
|
|
143426
144062
|
this.renderedSkillActivationIds.clear();
|
|
143427
144063
|
this.renderedMcpServerStatusKeys.clear();
|
|
143428
144064
|
this.stopAllMcpServerStatusSpinners();
|
|
144065
|
+
this.pendingSkillCandidates = [];
|
|
144066
|
+
this.promptedSkillCandidates.clear();
|
|
143429
144067
|
this.host.setAppState({ subagentUsage: {} });
|
|
143430
144068
|
}
|
|
143431
144069
|
startSubscription() {
|
|
@@ -143681,6 +144319,12 @@ var SessionEventHandler = class {
|
|
|
143681
144319
|
const todos = this.host.state.todoPanel.getTodos();
|
|
143682
144320
|
if (todos.length > 0 && todos.every((todo) => todo.status === "done")) this.host.streamingUI.setTodoList([]);
|
|
143683
144321
|
this.host.streamingUI.resetToolUi();
|
|
144322
|
+
if (this.pendingSkillCandidates.length > 0 && this.host.state.queuedMessages.length === 0) {
|
|
144323
|
+
const pending = this.pendingSkillCandidates;
|
|
144324
|
+
this.pendingSkillCandidates = [];
|
|
144325
|
+
const session = this.host.session;
|
|
144326
|
+
if (session !== void 0) for (const candidate of pending) this.promptSkillCandidate(session, candidate.name, candidate.purpose);
|
|
144327
|
+
}
|
|
143684
144328
|
this.host.streamingUI.finalizeTurn(sendQueued);
|
|
143685
144329
|
}
|
|
143686
144330
|
handleStepBegin(event) {
|
|
@@ -144055,6 +144699,10 @@ var SessionEventHandler = class {
|
|
|
144055
144699
|
}
|
|
144056
144700
|
/** Candidates already prompted this session, to avoid repeating the request. */
|
|
144057
144701
|
promptedSkillCandidates = /* @__PURE__ */ new Set();
|
|
144702
|
+
/** Skill candidates detected while a turn was still active. Flushed at the
|
|
144703
|
+
* next turn end so the AskUserQuestion dialog never interrupts an ongoing
|
|
144704
|
+
* response. */
|
|
144705
|
+
pendingSkillCandidates = [];
|
|
144058
144706
|
/**
|
|
144059
144707
|
* Handles a `skill_candidate` event emitted after compaction detected a
|
|
144060
144708
|
* reusable process in the summary. Best-effort and non-fatal: if the session
|
|
@@ -144062,6 +144710,10 @@ var SessionEventHandler = class {
|
|
|
144062
144710
|
* no confirmation. When it works, the model runs an AskUserQuestion dialog
|
|
144063
144711
|
* (确定/忽略) so the user can confirm or dismiss with a single keystroke,
|
|
144064
144712
|
* then generates the skill via MakeSkillPlanTool on confirmation.
|
|
144713
|
+
*
|
|
144714
|
+
* If a turn is still streaming (the compaction finished while the agent was
|
|
144715
|
+
* mid-response), the candidate is queued and prompted at the next turn end —
|
|
144716
|
+
* never interrupting the running turn.
|
|
144065
144717
|
*/
|
|
144066
144718
|
handleSkillCandidate(event) {
|
|
144067
144719
|
try {
|
|
@@ -144071,10 +144723,25 @@ var SessionEventHandler = class {
|
|
|
144071
144723
|
this.promptedSkillCandidates.add(name);
|
|
144072
144724
|
const session = this.host.session;
|
|
144073
144725
|
if (session === void 0) return;
|
|
144074
|
-
|
|
144075
|
-
|
|
144726
|
+
if (this.host.streamingUI.hasActiveTurn()) {
|
|
144727
|
+
this.pendingSkillCandidates.push({
|
|
144728
|
+
name,
|
|
144729
|
+
purpose
|
|
144730
|
+
});
|
|
144731
|
+
return;
|
|
144732
|
+
}
|
|
144733
|
+
this.promptSkillCandidate(session, name, purpose);
|
|
144076
144734
|
} catch {}
|
|
144077
144735
|
}
|
|
144736
|
+
/** Fire the AskUserQuestion prompt for a skill candidate. On failure, surface
|
|
144737
|
+
* a status hint instead of failing silently so the user still learns the
|
|
144738
|
+
* candidate was detected. */
|
|
144739
|
+
promptSkillCandidate(session, name, purpose) {
|
|
144740
|
+
const request = `检测到可复用过程「${name}」${purpose ? `(${purpose})` : ""}。请用 AskUserQuestion 工具询问用户是否将其保存为可复用技能(选项:生成 / 忽略)。用户选择「生成」后,用 MakeSkillPlanTool 生成该技能;选择「忽略」则直接说明已跳过。`;
|
|
144741
|
+
session.prompt(request).catch(() => {
|
|
144742
|
+
this.host.showStatus(`检测到可复用过程「${name}」,但询问失败。可稍后手动处理。`, this.host.state.theme.colors.warning);
|
|
144743
|
+
});
|
|
144744
|
+
}
|
|
144078
144745
|
finishCompaction(sendQueued) {
|
|
144079
144746
|
if (!this.host.streamingUI.hasActiveTurn()) {
|
|
144080
144747
|
this.host.setAppState({
|
|
@@ -146433,9 +147100,8 @@ var TasksBrowserController = class {
|
|
|
146433
147100
|
colors: state.theme.colors,
|
|
146434
147101
|
...this.buildCallbacks()
|
|
146435
147102
|
}, state.terminal);
|
|
146436
|
-
const
|
|
146437
|
-
state.ui.
|
|
146438
|
-
state.ui.addChild(component);
|
|
147103
|
+
const savedLayoutRoot = state.layoutRoot;
|
|
147104
|
+
state.ui.setLayoutRoot(component);
|
|
146439
147105
|
state.ui.setFocus(component);
|
|
146440
147106
|
state.ui.requestRender(true);
|
|
146441
147107
|
const pollTimer = setInterval(() => {
|
|
@@ -146443,7 +147109,7 @@ var TasksBrowserController = class {
|
|
|
146443
147109
|
}, 1e3);
|
|
146444
147110
|
this.host.setTasksBrowser({
|
|
146445
147111
|
component,
|
|
146446
|
-
|
|
147112
|
+
savedLayoutRoot,
|
|
146447
147113
|
filter,
|
|
146448
147114
|
selectedTaskId,
|
|
146449
147115
|
tailOutput: void 0,
|
|
@@ -146463,8 +147129,7 @@ var TasksBrowserController = class {
|
|
|
146463
147129
|
if (browser.viewer !== void 0) this.closeOutputViewer();
|
|
146464
147130
|
if (browser.pollTimer !== void 0) clearInterval(browser.pollTimer);
|
|
146465
147131
|
if (browser.flashTimer !== void 0) clearTimeout(browser.flashTimer);
|
|
146466
|
-
state.ui.
|
|
146467
|
-
for (const child of browser.savedChildren) state.ui.addChild(child);
|
|
147132
|
+
state.ui.setLayoutRoot(browser.savedLayoutRoot);
|
|
146468
147133
|
this.host.setTasksBrowser(void 0);
|
|
146469
147134
|
state.ui.setFocus(state.editor);
|
|
146470
147135
|
state.ui.requestRender(true);
|
|
@@ -146634,9 +147299,8 @@ var TasksBrowserController = class {
|
|
|
146634
147299
|
this.closeOutputViewer();
|
|
146635
147300
|
}
|
|
146636
147301
|
}, state.terminal);
|
|
146637
|
-
const
|
|
146638
|
-
state.ui.
|
|
146639
|
-
state.ui.addChild(viewer);
|
|
147302
|
+
const savedBrowserLayout = state.layoutRoot;
|
|
147303
|
+
state.ui.setLayoutRoot(viewer);
|
|
146640
147304
|
state.ui.setFocus(viewer);
|
|
146641
147305
|
state.ui.requestRender(true);
|
|
146642
147306
|
const pollTimer = setInterval(() => {
|
|
@@ -146644,7 +147308,7 @@ var TasksBrowserController = class {
|
|
|
146644
147308
|
}, 1e3);
|
|
146645
147309
|
browser.viewer = {
|
|
146646
147310
|
component: viewer,
|
|
146647
|
-
|
|
147311
|
+
savedLayoutRoot: savedBrowserLayout,
|
|
146648
147312
|
taskId,
|
|
146649
147313
|
output,
|
|
146650
147314
|
refreshId: 0,
|
|
@@ -146700,8 +147364,7 @@ var TasksBrowserController = class {
|
|
|
146700
147364
|
const viewer = browser.viewer;
|
|
146701
147365
|
clearInterval(viewer.pollTimer);
|
|
146702
147366
|
browser.viewer = void 0;
|
|
146703
|
-
this.host.state.ui.
|
|
146704
|
-
for (const child of viewer.savedChildren) this.host.state.ui.addChild(child);
|
|
147367
|
+
this.host.state.ui.setLayoutRoot(viewer.savedLayoutRoot);
|
|
146705
147368
|
this.host.state.ui.setFocus(browser.component);
|
|
146706
147369
|
this.host.state.ui.requestRender(true);
|
|
146707
147370
|
}
|
|
@@ -147137,13 +147800,6 @@ var TranscriptController = class TranscriptController {
|
|
|
147137
147800
|
toggleToolOutputExpansion() {
|
|
147138
147801
|
const { state } = this.host;
|
|
147139
147802
|
state.toolOutputExpanded = !state.toolOutputExpanded;
|
|
147140
|
-
const walk = (children) => {
|
|
147141
|
-
for (const child of children) {
|
|
147142
|
-
if (isExpandable(child)) child.setExpanded(state.toolOutputExpanded);
|
|
147143
|
-
if ("children" in child && Array.isArray(child.children)) walk(child.children);
|
|
147144
|
-
}
|
|
147145
|
-
};
|
|
147146
|
-
walk(state.transcriptContainer.children);
|
|
147147
147803
|
state.ui.requestRender();
|
|
147148
147804
|
}
|
|
147149
147805
|
togglePlanExpansion() {
|
|
@@ -147192,6 +147848,44 @@ var GutterContainer = class extends Container {
|
|
|
147192
147848
|
}
|
|
147193
147849
|
};
|
|
147194
147850
|
//#endregion
|
|
147851
|
+
//#region src/tui/components/panes/status-bar-pane.ts
|
|
147852
|
+
/**
|
|
147853
|
+
* A fixed one-line status bar shown directly above the input editor: it
|
|
147854
|
+
* displays the current work phase (idle / waiting / thinking / composing /
|
|
147855
|
+
* tool) with its spinner, pinned to the bottom of the terminal via the dock
|
|
147856
|
+
* VStack. Designed to hold more status widgets later — add children to the
|
|
147857
|
+
* container when needed.
|
|
147858
|
+
*/
|
|
147859
|
+
var StatusBarPaneComponent = class extends Container {
|
|
147860
|
+
constructor(options) {
|
|
147861
|
+
super();
|
|
147862
|
+
this.update(options);
|
|
147863
|
+
}
|
|
147864
|
+
/** Re-renders the bar for a new mode/label. The spinner/pulse are the
|
|
147865
|
+
* caller's shared instances (kept alive across mode changes), so this only
|
|
147866
|
+
* swaps which children are visible. */
|
|
147867
|
+
update(options) {
|
|
147868
|
+
this.clear();
|
|
147869
|
+
if (options.mode === "idle") return;
|
|
147870
|
+
if (options.mode === "waiting" || options.mode === "tool" || options.mode === "composing" || options.mode === "thinking") {
|
|
147871
|
+
if (options.pulseWave !== void 0) {
|
|
147872
|
+
if (options.label.length > 0) {
|
|
147873
|
+
const row = new HStack();
|
|
147874
|
+
row.addChild(options.pulseWave);
|
|
147875
|
+
row.addChild(new Text(` ${options.label}`, 1, 0));
|
|
147876
|
+
this.addChild(row);
|
|
147877
|
+
} else this.addChild(options.pulseWave);
|
|
147878
|
+
return;
|
|
147879
|
+
}
|
|
147880
|
+
if (options.spinner !== void 0) {
|
|
147881
|
+
this.addChild(options.spinner);
|
|
147882
|
+
return;
|
|
147883
|
+
}
|
|
147884
|
+
if (options.label.length > 0) this.addChild(new Text(options.label, 1, 0));
|
|
147885
|
+
}
|
|
147886
|
+
}
|
|
147887
|
+
};
|
|
147888
|
+
//#endregion
|
|
147195
147889
|
//#region src/tui/theme/bundle.ts
|
|
147196
147890
|
function createNexumTUIThemeBundle(theme, resolvedTheme) {
|
|
147197
147891
|
const actualTheme = resolvedTheme ?? resolveThemeSync(theme);
|
|
@@ -147483,36 +148177,11 @@ var PulseWaveLoader = class extends Text {
|
|
|
147483
148177
|
}
|
|
147484
148178
|
};
|
|
147485
148179
|
//#endregion
|
|
147486
|
-
//#region src/tui/components/panes/activity-pane.ts
|
|
147487
|
-
var ActivityPaneComponent = class extends Container {
|
|
147488
|
-
constructor(options) {
|
|
147489
|
-
super();
|
|
147490
|
-
if (options.mode === "waiting" || options.mode === "tool") {
|
|
147491
|
-
if (options.spinner !== void 0) {
|
|
147492
|
-
this.addChild(new Spacer(1));
|
|
147493
|
-
this.addChild(options.spinner);
|
|
147494
|
-
}
|
|
147495
|
-
if (options.pulseWave !== void 0) {
|
|
147496
|
-
this.addChild(new Spacer(1));
|
|
147497
|
-
this.addChild(options.pulseWave);
|
|
147498
|
-
}
|
|
147499
|
-
return;
|
|
147500
|
-
}
|
|
147501
|
-
if (options.mode === "composing" && options.spinner !== void 0) {
|
|
147502
|
-
this.addChild(new Spacer(1));
|
|
147503
|
-
this.addChild(options.spinner);
|
|
147504
|
-
if (options.pulseWave !== void 0) {
|
|
147505
|
-
this.addChild(new Spacer(1));
|
|
147506
|
-
this.addChild(options.pulseWave);
|
|
147507
|
-
}
|
|
147508
|
-
}
|
|
147509
|
-
}
|
|
147510
|
-
};
|
|
147511
|
-
//#endregion
|
|
147512
148180
|
//#region src/tui/controllers/lifecycle-controller.ts
|
|
147513
148181
|
var LifecycleController = class LifecycleController {
|
|
147514
148182
|
host;
|
|
147515
148183
|
signalCleanupHandlers = [];
|
|
148184
|
+
footerWrap;
|
|
147516
148185
|
ccConnectPollTimer;
|
|
147517
148186
|
memoryIdleTimer;
|
|
147518
148187
|
memoryCountdownTimer;
|
|
@@ -147520,6 +148189,9 @@ var LifecycleController = class LifecycleController {
|
|
|
147520
148189
|
terminalFocusTrackingDispose;
|
|
147521
148190
|
terminalThemeTrackingDispose;
|
|
147522
148191
|
lastActivityMode;
|
|
148192
|
+
/** The active status-bar loader (PulseWaveLoader or MoonLoader). Owned by
|
|
148193
|
+
* this controller; stopped before replacement to avoid leaking timers. */
|
|
148194
|
+
statusBarLoader;
|
|
147523
148195
|
static MEMORY_IDLE_MS = 900 * 1e3;
|
|
147524
148196
|
static MEMORY_COUNTDOWN_MS = 15 * 1e3;
|
|
147525
148197
|
static MEMORY_EXTRACT_COOLDOWN_MS = 600 * 1e3;
|
|
@@ -147659,19 +148331,72 @@ var LifecycleController = class LifecycleController {
|
|
|
147659
148331
|
buildLayout() {
|
|
147660
148332
|
const { ui } = this.host.state;
|
|
147661
148333
|
ui.clear();
|
|
147662
|
-
|
|
147663
|
-
|
|
147664
|
-
|
|
147665
|
-
|
|
147666
|
-
|
|
147667
|
-
|
|
147668
|
-
|
|
147669
|
-
|
|
148334
|
+
const scrollContent = new Container();
|
|
148335
|
+
scrollContent.addChild(this.host.state.transcriptContainer);
|
|
148336
|
+
scrollContent.addChild(this.host.state.activityContainer);
|
|
148337
|
+
scrollContent.addChild(this.host.state.queueContainer);
|
|
148338
|
+
const transcriptScrollView = new ScrollView(scrollContent, {
|
|
148339
|
+
follow: "end",
|
|
148340
|
+
primary: true,
|
|
148341
|
+
scrollbar: "auto"
|
|
148342
|
+
});
|
|
148343
|
+
const dock = new VStack([
|
|
148344
|
+
{
|
|
148345
|
+
component: this.host.state.todoPanelContainer,
|
|
148346
|
+
shrink: 1,
|
|
148347
|
+
minSize: 0,
|
|
148348
|
+
visible: (viewport) => viewport.width >= 90
|
|
148349
|
+
},
|
|
148350
|
+
{
|
|
148351
|
+
component: this.host.state.errorBannerContainer,
|
|
148352
|
+
shrink: 1,
|
|
148353
|
+
minSize: 0
|
|
148354
|
+
},
|
|
148355
|
+
{
|
|
148356
|
+
component: this.host.state.planModeBannerContainer,
|
|
148357
|
+
shrink: 1,
|
|
148358
|
+
minSize: 0
|
|
148359
|
+
},
|
|
148360
|
+
{
|
|
148361
|
+
component: this.host.state.statusBarContainer,
|
|
148362
|
+
shrink: 1,
|
|
148363
|
+
minSize: 1,
|
|
148364
|
+
visible: (viewport) => viewport.width >= 60
|
|
148365
|
+
},
|
|
148366
|
+
{
|
|
148367
|
+
component: this.host.state.editorContainer,
|
|
148368
|
+
shrink: 1,
|
|
148369
|
+
minSize: 3
|
|
148370
|
+
},
|
|
148371
|
+
{
|
|
148372
|
+
component: this.ensureFooterWrap(),
|
|
148373
|
+
shrink: 1,
|
|
148374
|
+
minSize: 1
|
|
148375
|
+
}
|
|
148376
|
+
]);
|
|
148377
|
+
const layoutRoot = new VStack([{
|
|
148378
|
+
component: transcriptScrollView,
|
|
148379
|
+
basis: 0,
|
|
148380
|
+
grow: 1,
|
|
148381
|
+
shrink: 1,
|
|
148382
|
+
minSize: 1
|
|
148383
|
+
}, {
|
|
148384
|
+
component: dock,
|
|
148385
|
+
basis: "auto",
|
|
148386
|
+
grow: 0,
|
|
148387
|
+
shrink: 1,
|
|
148388
|
+
minSize: 1
|
|
148389
|
+
}]);
|
|
148390
|
+
ui.setLayoutRoot(layoutRoot);
|
|
148391
|
+
this.host.state.layoutRoot = layoutRoot;
|
|
147670
148392
|
}
|
|
147671
148393
|
mountFooter() {
|
|
147672
|
-
|
|
147673
|
-
footerWrap.addChild(this.host.state.footer);
|
|
147674
|
-
|
|
148394
|
+
this.ensureFooterWrap();
|
|
148395
|
+
this.footerWrap.addChild(this.host.state.footer);
|
|
148396
|
+
}
|
|
148397
|
+
ensureFooterWrap() {
|
|
148398
|
+
if (this.footerWrap === void 0) this.footerWrap = new GutterContainer(1, 1);
|
|
148399
|
+
return this.footerWrap;
|
|
147675
148400
|
}
|
|
147676
148401
|
refreshTerminalThemeTracking() {
|
|
147677
148402
|
this.stopTerminalThemeTracking();
|
|
@@ -147706,48 +148431,57 @@ var LifecycleController = class LifecycleController {
|
|
|
147706
148431
|
this.syncTerminalProgress(this.shouldShowTerminalProgress(effectiveMode));
|
|
147707
148432
|
if (effectiveMode === this.lastActivityMode) return;
|
|
147708
148433
|
this.lastActivityMode = effectiveMode;
|
|
148434
|
+
this.updateStatusBar(effectiveMode);
|
|
147709
148435
|
const { state } = this.host;
|
|
147710
148436
|
state.activityContainer.clear();
|
|
147711
148437
|
switch (effectiveMode) {
|
|
147712
148438
|
case "hidden":
|
|
148439
|
+
case "idle":
|
|
147713
148440
|
this.stopActivitySpinner();
|
|
147714
148441
|
this.stopPulseWave();
|
|
147715
|
-
state.ui.requestRender();
|
|
147716
|
-
return;
|
|
147717
|
-
case "waiting": {
|
|
147718
|
-
this.stopActivitySpinner();
|
|
147719
|
-
const pulseWave = this.ensurePulseWave();
|
|
147720
|
-
state.activityContainer.addChild(new ActivityPaneComponent({
|
|
147721
|
-
mode: "waiting",
|
|
147722
|
-
pulseWave
|
|
147723
|
-
}));
|
|
147724
148442
|
break;
|
|
147725
|
-
|
|
148443
|
+
case "waiting":
|
|
147726
148444
|
case "thinking":
|
|
148445
|
+
case "composing":
|
|
148446
|
+
case "tool":
|
|
147727
148447
|
this.stopActivitySpinner();
|
|
147728
148448
|
this.stopPulseWave();
|
|
147729
148449
|
break;
|
|
147730
|
-
|
|
147731
|
-
|
|
147732
|
-
|
|
147733
|
-
|
|
147734
|
-
|
|
147735
|
-
|
|
147736
|
-
|
|
147737
|
-
|
|
147738
|
-
|
|
147739
|
-
|
|
147740
|
-
|
|
147741
|
-
|
|
147742
|
-
|
|
147743
|
-
|
|
147744
|
-
|
|
148450
|
+
}
|
|
148451
|
+
state.ui.requestRender();
|
|
148452
|
+
}
|
|
148453
|
+
/**
|
|
148454
|
+
* Updates the fixed status bar above the editor to reflect the current
|
|
148455
|
+
* work phase. Called only when the phase actually changes. Uses its OWN
|
|
148456
|
+
* spinner/pulse instances (a component can only have one parent, so the
|
|
148457
|
+
* activity pane's instances must not be shared). Recreating a loader on
|
|
148458
|
+
* every call would leak setInterval timers (each PulseWaveLoader.start()
|
|
148459
|
+
* registers one and the old instance is never stopped), so the previous
|
|
148460
|
+
* instance is explicitly stopped before a new one is mounted. Idle leaves
|
|
148461
|
+
* the bar empty.
|
|
148462
|
+
*/
|
|
148463
|
+
updateStatusBar(mode) {
|
|
148464
|
+
const { state } = this.host;
|
|
148465
|
+
state.statusBarContainer.clear();
|
|
148466
|
+
this.statusBarLoader?.stop();
|
|
148467
|
+
this.statusBarLoader = void 0;
|
|
148468
|
+
switch (mode) {
|
|
148469
|
+
case "waiting":
|
|
148470
|
+
case "composing":
|
|
148471
|
+
case "tool":
|
|
148472
|
+
{
|
|
148473
|
+
const loader = new PulseWaveLoader(state.ui, state.theme.colors.primary);
|
|
148474
|
+
this.statusBarLoader = loader;
|
|
148475
|
+
state.statusBarContainer.addChild(new StatusBarPaneComponent({
|
|
148476
|
+
mode,
|
|
148477
|
+
label: "",
|
|
148478
|
+
pulseWave: loader
|
|
148479
|
+
}));
|
|
148480
|
+
}
|
|
147745
148481
|
break;
|
|
147746
|
-
|
|
148482
|
+
case "thinking": break;
|
|
147747
148483
|
case "idle":
|
|
147748
|
-
|
|
147749
|
-
this.stopPulseWave();
|
|
147750
|
-
break;
|
|
148484
|
+
case "hidden": break;
|
|
147751
148485
|
}
|
|
147752
148486
|
state.ui.requestRender();
|
|
147753
148487
|
}
|
|
@@ -147770,28 +148504,12 @@ var LifecycleController = class LifecycleController {
|
|
|
147770
148504
|
this.host.state.terminal.setProgress(active);
|
|
147771
148505
|
this.host.state.terminalState.progressActive = active;
|
|
147772
148506
|
}
|
|
147773
|
-
ensureActivitySpinner(label = "", colorFn) {
|
|
147774
|
-
if (this.host.state.activitySpinner === null) {
|
|
147775
|
-
const instance = new MoonLoader(this.host.state.ui, colorFn, label);
|
|
147776
|
-
this.host.state.activitySpinner = { instance };
|
|
147777
|
-
return instance;
|
|
147778
|
-
}
|
|
147779
|
-
this.host.state.activitySpinner.instance.setLabel(label);
|
|
147780
|
-
if (colorFn !== void 0) this.host.state.activitySpinner.instance.setColorFn(colorFn);
|
|
147781
|
-
return this.host.state.activitySpinner.instance;
|
|
147782
|
-
}
|
|
147783
148507
|
stopActivitySpinner() {
|
|
147784
148508
|
if (this.host.state.activitySpinner !== null) {
|
|
147785
148509
|
this.host.state.activitySpinner.instance.stop();
|
|
147786
148510
|
this.host.state.activitySpinner = null;
|
|
147787
148511
|
}
|
|
147788
148512
|
}
|
|
147789
|
-
ensurePulseWave() {
|
|
147790
|
-
if (this.host.state.pulseWave !== null) return this.host.state.pulseWave;
|
|
147791
|
-
const instance = new PulseWaveLoader(this.host.state.ui, this.host.state.theme.colors.primary);
|
|
147792
|
-
this.host.state.pulseWave = instance;
|
|
147793
|
-
return instance;
|
|
147794
|
-
}
|
|
147795
148513
|
stopPulseWave() {
|
|
147796
148514
|
if (this.host.state.pulseWave !== null) {
|
|
147797
148515
|
this.host.state.pulseWave.stop();
|
|
@@ -148218,18 +148936,10 @@ var InputController = class InputController {
|
|
|
148218
148936
|
this.host = host;
|
|
148219
148937
|
}
|
|
148220
148938
|
setupAutocomplete() {
|
|
148221
|
-
const
|
|
148222
|
-
const slashCommands = visible.map((cmd) => cmd);
|
|
148939
|
+
const slashCommands = this.host.getSlashCommands().filter((command) => !(command.name.startsWith("skill:") && command.source === "builtin")).map((cmd) => cmd);
|
|
148223
148940
|
const { state } = this.host;
|
|
148224
148941
|
const provider = new FileMentionProvider(slashCommands, state.appState.workDir, state.fdPath, state.gitLsFilesCache);
|
|
148225
148942
|
state.editor.setAutocompleteProvider(provider);
|
|
148226
|
-
const argumentHints = /* @__PURE__ */ new Map();
|
|
148227
|
-
for (const cmd of visible) {
|
|
148228
|
-
if (cmd.argumentHint === void 0) continue;
|
|
148229
|
-
argumentHints.set(cmd.name, cmd.argumentHint);
|
|
148230
|
-
for (const alias of cmd.aliases) argumentHints.set(alias, cmd.argumentHint);
|
|
148231
|
-
}
|
|
148232
|
-
state.editor.setArgumentHints(argumentHints);
|
|
148233
148943
|
state.editor.onFirstInput = () => {
|
|
148234
148944
|
this.host.stopWelcomeBreathing();
|
|
148235
148945
|
this.#permanentlyStopBreathing();
|
|
@@ -149524,8 +150234,7 @@ function createTUIState(options) {
|
|
|
149524
150234
|
const initialAppState = options.initialAppState;
|
|
149525
150235
|
const theme = createNexumTUIThemeBundle(initialAppState.theme, options.resolvedTheme);
|
|
149526
150236
|
const terminal = new ProcessTerminal();
|
|
149527
|
-
const ui = new
|
|
149528
|
-
ui.setClearOnShrink(true);
|
|
150237
|
+
const ui = new TuiAltScreen(terminal);
|
|
149529
150238
|
const uiAny = ui;
|
|
149530
150239
|
const originalDoRender = uiAny["doRender"].bind(ui);
|
|
149531
150240
|
let recovering = false;
|
|
@@ -149551,6 +150260,7 @@ function createTUIState(options) {
|
|
|
149551
150260
|
};
|
|
149552
150261
|
const transcriptContainer = new GutterContainer(1, 1);
|
|
149553
150262
|
const activityContainer = new GutterContainer(1, 1);
|
|
150263
|
+
const statusBarContainer = new GutterContainer(1, 1);
|
|
149554
150264
|
const todoPanelContainer = new GutterContainer(1, 1);
|
|
149555
150265
|
const todoPanel = new TodoPanelComponent(theme.colors);
|
|
149556
150266
|
const queueContainer = new GutterContainer(1, 1);
|
|
@@ -149568,8 +150278,10 @@ function createTUIState(options) {
|
|
|
149568
150278
|
return {
|
|
149569
150279
|
ui,
|
|
149570
150280
|
terminal,
|
|
150281
|
+
layoutRoot: void 0,
|
|
149571
150282
|
transcriptContainer,
|
|
149572
150283
|
activityContainer,
|
|
150284
|
+
statusBarContainer,
|
|
149573
150285
|
todoPanelContainer,
|
|
149574
150286
|
todoPanel,
|
|
149575
150287
|
queueContainer,
|
|
@@ -150329,7 +151041,7 @@ var SessionManager$1 = class {
|
|
|
150329
151041
|
}
|
|
150330
151042
|
resetSessionRuntime() {
|
|
150331
151043
|
this.host.state.queuedMessages = [];
|
|
150332
|
-
this.host.harness.interactiveAgentId = MAIN_AGENT_ID;
|
|
151044
|
+
this.host.harness.interactiveAgentId = MAIN_AGENT_ID$1;
|
|
150333
151045
|
this.host.streamingUI.discardPending();
|
|
150334
151046
|
this.host.streamingUI.resetToolCallState();
|
|
150335
151047
|
this.host.streamingUI.resetToolUi();
|
|
@@ -150382,7 +151094,7 @@ function renderDisplayBlock(block, s, colors) {
|
|
|
150382
151094
|
});
|
|
150383
151095
|
case "file_content": {
|
|
150384
151096
|
const lang = block.language ?? langFromPath(block.path);
|
|
150385
|
-
const allLines = highlightLines(replaceTabs(block.content), lang);
|
|
151097
|
+
const allLines = highlightLines(replaceTabs(block.content), lang, colors);
|
|
150386
151098
|
const shown = allLines.slice(0, CONTENT_SUMMARY_MAX_LINES);
|
|
150387
151099
|
const lines = [s.strong(block.path)];
|
|
150388
151100
|
for (const [i, line] of shown.entries()) lines.push(s.gutter(String(i + 1).padStart(4) + " ") + line);
|
|
@@ -150479,7 +151191,7 @@ var ApprovalPanelComponent = class extends Container {
|
|
|
150479
151191
|
};
|
|
150480
151192
|
if (this.ui !== void 0) this.intervalId = setInterval(() => {
|
|
150481
151193
|
this.animFrame = (this.animFrame + 1) % PIXEL_PULSE_FRAMES.length;
|
|
150482
|
-
this.ui?.
|
|
151194
|
+
this.ui?.requestRender();
|
|
150483
151195
|
}, 100);
|
|
150484
151196
|
}
|
|
150485
151197
|
/** Stop the selection pulse. Idempotent; called on submit and on hide. */
|
|
@@ -150793,7 +151505,7 @@ function buildDiffBody(block, colors) {
|
|
|
150793
151505
|
}
|
|
150794
151506
|
function buildFileContentBody(block, colors) {
|
|
150795
151507
|
const lang = block.language ?? langFromPath(block.path);
|
|
150796
|
-
const highlighted = highlightLines(block.content, lang);
|
|
151508
|
+
const highlighted = highlightLines(block.content, lang, colors);
|
|
150797
151509
|
const gutter = chalk.hex(colors.diffGutter);
|
|
150798
151510
|
return {
|
|
150799
151511
|
lines: highlighted.map((line, i) => gutter(String(i + 1).padStart(4) + " ") + line),
|
|
@@ -151707,7 +152419,7 @@ var QuestionDialogComponent = class extends Container {
|
|
|
151707
152419
|
this.answers = Array.from({ length: total }, () => void 0);
|
|
151708
152420
|
if (this.ui !== void 0) this.intervalId = setInterval(() => {
|
|
151709
152421
|
this.animFrame = (this.animFrame + 1) % PIXEL_PULSE_FRAMES.length;
|
|
151710
|
-
this.ui?.
|
|
152422
|
+
this.ui?.requestRender();
|
|
151711
152423
|
}, 100);
|
|
151712
152424
|
}
|
|
151713
152425
|
/** Stop the wizard pulse. Idempotent; called on respond and on hide. */
|
|
@@ -152419,7 +153131,7 @@ var DialogManager = class {
|
|
|
152419
153131
|
}
|
|
152420
153132
|
openApprovalPreview(panel, block) {
|
|
152421
153133
|
if (this.approvalPreview !== void 0) return;
|
|
152422
|
-
const
|
|
153134
|
+
const savedLayoutRoot = this.host.state.layoutRoot;
|
|
152423
153135
|
const viewer = new ApprovalPreviewViewer({
|
|
152424
153136
|
block,
|
|
152425
153137
|
colors: this.host.state.theme.colors,
|
|
@@ -152427,13 +153139,12 @@ var DialogManager = class {
|
|
|
152427
153139
|
this.closeApprovalPreview();
|
|
152428
153140
|
}
|
|
152429
153141
|
}, this.host.state.terminal);
|
|
152430
|
-
this.host.state.ui.
|
|
152431
|
-
this.host.state.ui.addChild(viewer);
|
|
153142
|
+
this.host.state.ui.setLayoutRoot(viewer);
|
|
152432
153143
|
this.host.state.ui.setFocus(viewer);
|
|
152433
153144
|
this.host.state.ui.requestRender(true);
|
|
152434
153145
|
this.approvalPreview = {
|
|
152435
153146
|
component: viewer,
|
|
152436
|
-
|
|
153147
|
+
savedLayoutRoot,
|
|
152437
153148
|
panel
|
|
152438
153149
|
};
|
|
152439
153150
|
}
|
|
@@ -152441,8 +153152,7 @@ var DialogManager = class {
|
|
|
152441
153152
|
const preview = this.approvalPreview;
|
|
152442
153153
|
if (preview === void 0) return;
|
|
152443
153154
|
this.approvalPreview = void 0;
|
|
152444
|
-
this.host.state.ui.
|
|
152445
|
-
for (const child of preview.savedChildren) this.host.state.ui.addChild(child);
|
|
153155
|
+
this.host.state.ui.setLayoutRoot(preview.savedLayoutRoot);
|
|
152446
153156
|
this.host.state.ui.setFocus(preview.panel);
|
|
152447
153157
|
this.host.state.ui.requestRender(true);
|
|
152448
153158
|
}
|
|
@@ -152533,7 +153243,6 @@ var NexumTUI = class {
|
|
|
152533
153243
|
deferUserMessages = false;
|
|
152534
153244
|
aborted = false;
|
|
152535
153245
|
isShuttingDown = false;
|
|
152536
|
-
tightModeHandler = null;
|
|
152537
153246
|
reverseRpcDisposers = [];
|
|
152538
153247
|
startupNotice;
|
|
152539
153248
|
balancePollTimer;
|
|
@@ -152631,11 +153340,6 @@ var NexumTUI = class {
|
|
|
152631
153340
|
this.inputController.setupAutocomplete();
|
|
152632
153341
|
}
|
|
152633
153342
|
async start() {
|
|
152634
|
-
this.tightModeHandler = () => {
|
|
152635
|
-
setTightMode((process.stdout.columns ?? 80) < 60);
|
|
152636
|
-
};
|
|
152637
|
-
this.tightModeHandler();
|
|
152638
|
-
process.stdout.on("resize", this.tightModeHandler);
|
|
152639
153343
|
this.lifecycleController.installSignalHandlers();
|
|
152640
153344
|
try {
|
|
152641
153345
|
const shouldReplayHistory = await this.initMainTui();
|
|
@@ -152722,11 +153426,6 @@ var NexumTUI = class {
|
|
|
152722
153426
|
async stop(exitCode) {
|
|
152723
153427
|
if (this.isShuttingDown) return;
|
|
152724
153428
|
this.isShuttingDown = true;
|
|
152725
|
-
if (this.tightModeHandler !== null) {
|
|
152726
|
-
process.stdout.off("resize", this.tightModeHandler);
|
|
152727
|
-
this.tightModeHandler = null;
|
|
152728
|
-
}
|
|
152729
|
-
setTightMode(false);
|
|
152730
153429
|
this.lifecycleController.stopCcConnectPolling();
|
|
152731
153430
|
if (this.balancePollTimer !== void 0) {
|
|
152732
153431
|
clearInterval(this.balancePollTimer);
|
|
@@ -152993,6 +153692,7 @@ var NexumTUI = class {
|
|
|
152993
153692
|
this.sessionEventHandler.stopAllMcpServerStatusSpinners();
|
|
152994
153693
|
clearGoalState();
|
|
152995
153694
|
clearInfoPanelState(this.state);
|
|
153695
|
+
clearEvalPanelState(this.state);
|
|
152996
153696
|
this.state.terminal.write("\x1B[3J");
|
|
152997
153697
|
this.transcriptController.clearAndRedraw();
|
|
152998
153698
|
this.state.ui.requestRender(true);
|