nexum-code 0.15.1 → 0.15.3
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-5jOmOWG7.mjs → app-Dzqtno-_.mjs} +629 -34
- package/dist/{dispatch-DA_D42qp.mjs → dispatch-ClUS04uO.mjs} +1 -1
- package/dist/{dispatch-C98jHQkj.mjs → dispatch-RwKBVuHW.mjs} +255 -58
- package/dist/main.mjs +1 -1
- package/dist/public/assets/index-CGwN8W_j.js +93 -0
- package/dist/public/assets/index-CGwN8W_j.js.map +1 -0
- package/dist/public/assets/index-DMyG0a38.css +1 -0
- package/dist/public/gateway.html +156 -156
- package/dist/public/index.html +2 -2
- package/dist/{src-h6ZExh4A.mjs → src-CtMkYz0K.mjs} +1 -1
- package/dist/{src-tDEINaMV.mjs → src-DE9LHL58.mjs} +2 -2
- package/package.json +97 -96
- package/dist/public/assets/index-CrkM1eFC.css +0 -1
- package/dist/public/assets/index-DYpA3Upa.js +0 -93
- package/dist/public/assets/index-DYpA3Upa.js.map +0 -1
|
@@ -3,5 +3,5 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
|
3
3
|
import { dirname as __cjsShimDirname } from 'node:path';
|
|
4
4
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
|
-
import { Gt as handleConnectCommand } from "./dispatch-
|
|
6
|
+
import { Gt as handleConnectCommand } from "./dispatch-RwKBVuHW.mjs";
|
|
7
7
|
export { handleConnectCommand };
|
|
@@ -5,7 +5,7 @@ const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
6
|
import { i as __require, o as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk-D90kvbyJ.mjs";
|
|
7
7
|
import { t as require_base64_js } from "./base64-js-DzVmk6Nb.mjs";
|
|
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-
|
|
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-DE9LHL58.mjs";
|
|
9
9
|
import { a as setLocale, i as getLocale, n as assertNexumHostIdentity, o as t, r as createNexumDefaultHeaders, t as TextInputDialogComponent } from "./text-input-dialog-Dvux6kIR.mjs";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
@@ -34212,14 +34212,29 @@ function convertMediaUrl(url, fallbackMimeType) {
|
|
|
34212
34212
|
function createAbortError() {
|
|
34213
34213
|
return new DOMException("The operation was aborted.", "AbortError");
|
|
34214
34214
|
}
|
|
34215
|
-
|
|
34216
|
-
|
|
34215
|
+
/**
|
|
34216
|
+
* Race async work against an abort signal, ALWAYS detaching the listener.
|
|
34217
|
+
* The Google GenAI SDK does not accept an AbortSignal, so callers race the
|
|
34218
|
+
* SDK call against the signal manually. A bare `addEventListener({ once })`
|
|
34219
|
+
* inside a losing promise leaks the listener on the caller's signal for the
|
|
34220
|
+
* rest of its lifetime - with a session-scoped signal that accumulates one
|
|
34221
|
+
* listener per request. This wrapper guarantees cleanup in both outcomes.
|
|
34222
|
+
*/
|
|
34223
|
+
async function abortRace(signal, work) {
|
|
34224
|
+
if (signal === void 0) return work;
|
|
34217
34225
|
if (signal.aborted) throw createAbortError();
|
|
34218
|
-
|
|
34219
|
-
|
|
34226
|
+
let onAbort = void 0;
|
|
34227
|
+
const abortPromise = new Promise((_, reject) => {
|
|
34228
|
+
onAbort = () => {
|
|
34220
34229
|
reject(createAbortError());
|
|
34221
|
-
}
|
|
34230
|
+
};
|
|
34231
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
34222
34232
|
});
|
|
34233
|
+
try {
|
|
34234
|
+
return await Promise.race([work, abortPromise]);
|
|
34235
|
+
} finally {
|
|
34236
|
+
if (onAbort !== void 0) signal.removeEventListener("abort", onAbort);
|
|
34237
|
+
}
|
|
34223
34238
|
}
|
|
34224
34239
|
function messageToGoogleGenAI(message) {
|
|
34225
34240
|
if (message.role === "tool") throw new ChatProviderError("Tool messages must be converted via messagesToGoogleGenAIContents.");
|
|
@@ -34589,8 +34604,8 @@ var GoogleGenAIChatProvider = class {
|
|
|
34589
34604
|
contents,
|
|
34590
34605
|
config
|
|
34591
34606
|
};
|
|
34592
|
-
if (this._stream) return new GoogleGenAIStreamedMessage(await
|
|
34593
|
-
return new GoogleGenAIStreamedMessage(await
|
|
34607
|
+
if (this._stream) return new GoogleGenAIStreamedMessage(await abortRace(options?.signal, models.generateContentStream(params)), true, options?.signal);
|
|
34608
|
+
return new GoogleGenAIStreamedMessage(await abortRace(options?.signal, models.generateContent(params)), false, options?.signal);
|
|
34594
34609
|
} catch (error) {
|
|
34595
34610
|
if (error instanceof DOMException && error.name === "AbortError") throw error;
|
|
34596
34611
|
throw convertGoogleGenAIError(error);
|
|
@@ -47925,6 +47940,17 @@ var MemoryMemoStore = class MemoryMemoStore {
|
|
|
47925
47940
|
async append(entry) {
|
|
47926
47941
|
return this.withWriteLock(() => this.appendInternal(entry));
|
|
47927
47942
|
}
|
|
47943
|
+
/**
|
|
47944
|
+
* True when a memo with the same source session + user need + approach
|
|
47945
|
+
* already exists. Used by compaction-summary recovery to re-store memos
|
|
47946
|
+
* idempotently after a crash between compaction apply and extraction.
|
|
47947
|
+
* The approach field keeps two distinct memos that happen to share the
|
|
47948
|
+
* same user need from being collapsed into one.
|
|
47949
|
+
*/
|
|
47950
|
+
existsBySourceAndNeed(sourceSessionId, userNeed, approach) {
|
|
47951
|
+
if (this.db === void 0) return false;
|
|
47952
|
+
return this.db.prepare("SELECT 1 FROM memos WHERE source_session_id = ? AND user_need = ? AND approach = ? LIMIT 1").get(sourceSessionId, userNeed, approach) !== void 0;
|
|
47953
|
+
}
|
|
47928
47954
|
/** Delete a memo by id. */
|
|
47929
47955
|
async delete(id) {
|
|
47930
47956
|
return this.withWriteLock(() => this.deleteInternal(id));
|
|
@@ -49747,9 +49773,41 @@ function estimateTokensForMessage(message) {
|
|
|
49747
49773
|
messageTokenCache.set(message, total);
|
|
49748
49774
|
return total;
|
|
49749
49775
|
}
|
|
49776
|
+
/**
|
|
49777
|
+
* Media parts carry no width/height metadata, and providers differ on how they
|
|
49778
|
+
* tokenize media (image token counts range from a few hundred to ~1600 for a
|
|
49779
|
+
* single image depending on provider and resolution). There is no cross-
|
|
49780
|
+
* provider formula, so these estimates are deliberately conservative — for
|
|
49781
|
+
* watermark detection an OVERestimate only compacts slightly earlier
|
|
49782
|
+
* (harmless), whereas counting media as 0 systematically UNDERESTIMATED the
|
|
49783
|
+
* watermark and delayed compaction on media-heavy sessions.
|
|
49784
|
+
*
|
|
49785
|
+
* These estimates are consumed only by watermark detection and micro-compaction
|
|
49786
|
+
* recycling decisions — the real usage reported by the provider re-anchors the
|
|
49787
|
+
* context token count at each step end, so billing/usage accounting is
|
|
49788
|
+
* unaffected.
|
|
49789
|
+
*/
|
|
49790
|
+
const IMAGE_BASE_TOKENS = 1600;
|
|
49791
|
+
const IMAGE_MAX_TOKENS = 8e3;
|
|
49792
|
+
/** data-URI payloads above this many bytes are treated as high-resolution/long captures. */
|
|
49793
|
+
const IMAGE_LARGE_PAYLOAD_BYTES = 512e3;
|
|
49794
|
+
const AUDIO_TOKENS = 2e3;
|
|
49795
|
+
const VIDEO_TOKENS = 5e3;
|
|
49796
|
+
/** Long screenshots (large data URIs) carry more visual content than a single
|
|
49797
|
+
* bounded-resolution image; grow the estimate linearly and cap it. */
|
|
49798
|
+
function estimateDataUriTokens(url, baseTokens, maxTokens) {
|
|
49799
|
+
const start = url.indexOf("base64,");
|
|
49800
|
+
if (start < 0) return baseTokens;
|
|
49801
|
+
const bytes = Math.floor((url.length - start - 7) * 3 / 4);
|
|
49802
|
+
if (bytes <= IMAGE_LARGE_PAYLOAD_BYTES) return baseTokens;
|
|
49803
|
+
return Math.min(maxTokens, baseTokens + Math.floor((bytes - IMAGE_LARGE_PAYLOAD_BYTES) / 1e3));
|
|
49804
|
+
}
|
|
49750
49805
|
function estimateTokensForContentPart(part) {
|
|
49751
49806
|
if (part.type === "text") return estimateTokens$1(part.text);
|
|
49752
49807
|
else if (part.type === "think") return estimateTokens$1(part.think);
|
|
49808
|
+
else if (part.type === "image_url") return estimateDataUriTokens(part.imageUrl.url, IMAGE_BASE_TOKENS, IMAGE_MAX_TOKENS);
|
|
49809
|
+
else if (part.type === "audio_url") return AUDIO_TOKENS;
|
|
49810
|
+
else if (part.type === "video_url") return VIDEO_TOKENS;
|
|
49753
49811
|
return 0;
|
|
49754
49812
|
}
|
|
49755
49813
|
//#endregion
|
|
@@ -55379,7 +55437,7 @@ var KnowledgeLookupTool = class {
|
|
|
55379
55437
|
const llm = { generate: async (systemPrompt, userPrompt) => {
|
|
55380
55438
|
return this.agent.generateText(systemPrompt, userPrompt);
|
|
55381
55439
|
} };
|
|
55382
|
-
const { multiSearchWithTrace } = await import("./src-
|
|
55440
|
+
const { multiSearchWithTrace } = await import("./src-CtMkYz0K.mjs");
|
|
55383
55441
|
const { results, trace } = await multiSearchWithTrace(store, llm, query, { topK });
|
|
55384
55442
|
if (results.length === 0) return {
|
|
55385
55443
|
isError: false,
|
|
@@ -70827,7 +70885,7 @@ function renderPrompt(template, vars) {
|
|
|
70827
70885
|
}
|
|
70828
70886
|
//#endregion
|
|
70829
70887
|
//#region ../../packages/agent-core/src/tools/builtin/collaboration/skill-tool.md
|
|
70830
|
-
var skill_tool_default = "Invoke a registered skill from the current skill listing. BLOCKING REQUIREMENT: when a skill from the listing matches the user's request, you MUST call this tool (not free-form text). Do NOT call the same skill repeatedly inside one turn — recursive depth is capped at {{ MAX_SKILL_QUERY_DEPTH }}.\n\n## Currently model-invocable skills\n{{ AVAILABLE_SKILLS }}\nThis list is a construction-time snapshot; for the live catalog inspect the skill registry.\n\n**Not for inventory questions**: when the user asks what you have — in any wording (skills / plugins / capabilities / MCP / tools) — answer with **InspectOwnAssets** (the full read-only catalog), not this listing. To find or install new capabilities, use **ManagePlugin**. This listing exists for **invocation**: when one of the skills above matches the task at hand.\n\n## Matching guide\n\n- A skill matches when the user's request involves the scenarios/trigger conditions listed in the skill's \"When to use\" line.\n- Look for: (a) keywords in the user's request that match the skill's trigger phrases, (b) the task type or scenario described in the skill's \"When to use\", (c) similar requests the skill was designed for.\n- If a skill seems relevant, invoke it first — if it doesn't fit, you can always fall back to doing it yourself.\n";
|
|
70888
|
+
var skill_tool_default = "Invoke a registered skill from the current skill listing. BLOCKING REQUIREMENT: when a skill from the listing matches the user's request, you MUST call this tool (not free-form text). Do NOT call the same skill repeatedly inside one turn — recursive depth is capped at {{ MAX_SKILL_QUERY_DEPTH }}.\r\n\r\n## Currently model-invocable skills\r\n{{ AVAILABLE_SKILLS }}\r\nThis list is a construction-time snapshot; for the live catalog inspect the skill registry.\r\n\r\n**Not for inventory questions**: when the user asks what you have — in any wording (skills / plugins / capabilities / MCP / tools) — answer with **InspectOwnAssets** (the full read-only catalog), not this listing. To find or install new capabilities, use **ManagePlugin**. This listing exists for **invocation**: when one of the skills above matches the task at hand.\r\n\r\n## Matching guide\r\n\r\n- A skill matches when the user's request involves the scenarios/trigger conditions listed in the skill's \"When to use\" line.\r\n- Look for: (a) keywords in the user's request that match the skill's trigger phrases, (b) the task type or scenario described in the skill's \"When to use\", (c) similar requests the skill was designed for.\r\n- If a skill seems relevant, invoke it first — if it doesn't fit, you can always fall back to doing it yourself.\r\n";
|
|
70831
70889
|
/** Max skills to list inline in the tool description; rest are summarized. */
|
|
70832
70890
|
const MAX_INLINE_SKILLS = 15;
|
|
70833
70891
|
/** Max description length per skill line. */
|
|
@@ -81618,7 +81676,7 @@ function messageOf(error) {
|
|
|
81618
81676
|
}
|
|
81619
81677
|
//#endregion
|
|
81620
81678
|
//#region ../../packages/agent-core/src/tools/builtin/plugin/manage-plugin.md
|
|
81621
|
-
var manage_plugin_default = "Manage this product's own plugins. Plugins are the vehicle for add-on capabilities: each one can contribute skills, MCP servers, shell hooks, and — only after an explicit activate — code that runs in this process.\n\nUse this tool in two situations: (a) a task needs a capability you do not currently have — exhaust your existing tools first and add a plugin only when the gap is real; (b) the user asks you to find, install, configure, inspect, or clean up a capability (e.g. \"install something that can render mermaid\", \"disable the plugin I no longer use\"). In both cases, remove or disable additions again when the work is done unless the capability is broadly reusable.\n\n**Not for inventory questions**: when the user asks what you have — in any wording (skills / plugins / capabilities / MCP / tools / 技能 / 插件 / 能力) — answer with **InspectOwnAssets** (the read-only inventory: every skill package on disk with live `invocable` status, plus MCP declarations). `{\"action\":\"list\"}` here is the **plugin management view**: a pre-change check of the plugin table before installing or modifying, not the answer to \"what can you do\".\n\nChoose the lightest vehicle that solves the problem, in this order: a skill (prompt instructions — safest, no code, no process), an MCP server (an external process), a code plugin (runs in this process — the most powerful, needs its own approved `activate`).\n\n## Workflow\n\n1. `{\"action\":\"list\"}` — see what is already installed before adding anything. To confirm the gap is real, start from an `InspectOwnAssets` inventory (what exists on disk and what is invocable), then check this table for an existing plugin that already covers it. Do not grow a second plugin that duplicates an existing capability; enable, disable, or extend the one you already have.\n2. `{\"action\":\"marketplace\",\"query\":\"pdf\"}` — browse the catalog for a matching capability. Pass `source` to read a different catalog. `tier` is a display label only; judge an entry by its description and source. Entries whose origin previously produced a tripped plugin carry `quarantined: true`.\n3. `{\"action\":\"precheck\",\"source\":\"https://github.com/owner/repo\"}` — free read-only origin check before installing anything external that you have not vetted in this session: it reports past incidents recorded by the plugin center's immune memory (`quarantined:true` + the reason). Surface such a warning to the user BEFORE asking for the install approval.\n4. If nothing in the catalog fits and precheck is clean, you may search the web (`WebSearch` / `FetchURL`) and evaluate a repository yourself: read its README and manifest, prefer a pinned branch/tag/commit URL over a moving default, and check that it does something you cannot already do.\n5. To **make a capability yourself**: if the user invoked `/make-skill`, use the `MakeSkillPlan` → `MakeSkillApply` pair (it produces a valid skill package and registers it into this table automatically). Otherwise build a plugin directory by hand (a `nexum.plugin.json` manifest plus your SKILL.md under `skills/`) and register it with `register_generated` — that route lands in this table, hot-applies the same turn, and stays manageable here (disable/remove/circuit). Writing a plain SKILL.md into the user skills directory is also a legitimate skill, but it does NOT appear in this table and cannot be managed with this tool.\n6. `{\"action\":\"install\",\"source\":\"https://github.com/owner/repo/tree/v1.2.0\"}` — install from a local path, a GitHub URL, or a zip URL. **Installing never executes code.** The plugin's files are copied and its record is registered; a manifest `entryPoint` stays dormant until step 8.\n7. `{\"action\":\"install\",\"source\":\"...\",\"upgrade\":true}` — same-name refresh: backs up the current files (single slot under `plugins/backups/<id>/`), swaps in the new ones, and reloads; `from`/`to` versions and any downgrade warning are reported. If activation then fails, `rollback` restores the previous files in one approved step.\n8. `{\"action\":\"enable\",\"id\":\"...\"}` / `{\"action\":\"disable\",\"id\":\"...\"}` / `{\"action\":\"set_mcp_enabled\",\"id\":\"...\",\"server\":\"...\",\"enabled\":false}` — turn contributed capabilities on and off.\n9. `{\"action\":\"activate\",\"id\":\"...\"}` — the only action that runs a plugin's code entry point in this process. Skip it for skill-only and MCP-only plugins; they need no activation.\n10. `{\"action\":\"info\",\"id\":\"...\"}` / `{\"action\":\"check\"}` — inspect one record in full, or the health of the table. Each entry also carries `usage: {calls, okCalls, okRate, lastUsedAt}` from this machine: zero calls since install marks it as a cleanup candidate; high usage with a high okRate is worth keeping when you must choose.\n11. `{\"action\":\"reset\",\"id\":\"...\"}` — recover a circuit-tripped or manually disabled plugin: clears its failure ledger, re-derives the record from disk, enables it, and hot-applies its capabilities. It never runs code — a code plugin still needs its own approved `activate`.\n12. `{\"action\":\"rollback\",\"id\":\"...\"}` — restore the pre-upgrade backup taken by step 7 in one approved step.\n13. `{\"action\":\"reload\"}` — re-read the plugin table from disk and get an added/removed/error summary.\n14. `{\"action\":\"remove\",\"id\":\"...\"}` (or `disable` to keep the record) — retreat once the capability is no longer wanted.\n\n## Circuit breaker (limbs that fail get pulled, the loop never dies)\n\nPlugin-owned capabilities are counted per plugin: every failed tool call (in-process plugin tools and plugin MCP servers) and every faulty event handler. A success clears the streak; three consecutive failures trip the breaker, and the failing result arrives with a `[circuit]` advisory: the plugin was marked with the reason, disabled persistently, its code deactivated, and its tools, MCP servers, skills, and hooks pulled from every live session. Nothing retries automatically — read the state with `check` (each plugin carries `circuit: {failures, tripped}`), then `reset` to give it another chance or `remove` to let it go. User-configured MCP servers and built-in tools are never charged to anyone's breaker.\n\nEvery trip ALSO writes the origin into the plugin center's immune memory (quarantine ledger): future `precheck`/`install`/`marketplace` calls for the same repository will surface that history before anything is executed again, even across sessions — and even if the broken plugin was removed afterwards.\n\nChanges are hot-applied to the running session wherever the host supports it: mutating results carry a `sync` report (`{ok, applied[], failed[]}`) naming exactly what landed — `skills.inject`, `mcp.add`/`mcp.remove`, tool teardown. An `install` deliberately reports no `mcp.add`: installing never starts a plugin's MCP process; that waits for an approved `enable`/`activate`/`reload`. Treat `sync.failed` as advisory (the mutation itself already succeeded) and re-check with `info`/`check` rather than re-running the mutation. Reload before judging whether a change landed.\n\n## Registration of your own output\n\n`{\"action\":\"register_generated\",\"source\":\"/abs/path/to/generated/plugin\"}` registers a plugin directory you produced locally, without a copy step. It refuses any manifest that declares an `entryPoint`: this action is normally auto-approved and must never become a route to running code. For a code plugin, use `install` and then `activate`.\n\n## Approval contract\n\n- Read-only actions (`list`, `info`, `check`, `marketplace`) run without prompting.\n- Every mutating action (`install`, `register_generated`, `enable`, `disable`, `set_mcp_enabled`, `activate`, `deactivate`, `remove`, `reset`, `reload`) requires the user's approval. State what you are about to do and why in one line, then call the tool — never describe a plugin change you have not made.\n- The approval prompt for `install` and `register_generated` shows the full source string, and a session grant applies to that exact source only.\n- `activate` is the step that executes third-party code; treat it as its own decision, made after you have read what the plugin does.\n- A rejected approval is an answer, not a retry cue. Report the refusal and continue without the capability.\n\n## Output\n\nEvery action returns a JSON string. Success is a compact result object; failure is\n`{\"error\":{\"code\",\"message\",\"next\"}}` with `isError: true`. Follow `next` rather than\nguessing at a repair — it names the call that resolves the problem.\n";
|
|
81679
|
+
var manage_plugin_default = "Manage this product's own plugins. Plugins are the vehicle for add-on capabilities: each one can contribute skills, MCP servers, shell hooks, and — only after an explicit activate — code that runs in this process.\r\n\r\nUse this tool in two situations: (a) a task needs a capability you do not currently have — exhaust your existing tools first and add a plugin only when the gap is real; (b) the user asks you to find, install, configure, inspect, or clean up a capability (e.g. \"install something that can render mermaid\", \"disable the plugin I no longer use\"). In both cases, remove or disable additions again when the work is done unless the capability is broadly reusable.\r\n\r\n**Not for inventory questions**: when the user asks what you have — in any wording (skills / plugins / capabilities / MCP / tools / 技能 / 插件 / 能力) — answer with **InspectOwnAssets** (the read-only inventory: every skill package on disk with live `invocable` status, plus MCP declarations). `{\"action\":\"list\"}` here is the **plugin management view**: a pre-change check of the plugin table before installing or modifying, not the answer to \"what can you do\".\r\n\r\nChoose the lightest vehicle that solves the problem, in this order: a skill (prompt instructions — safest, no code, no process), an MCP server (an external process), a code plugin (runs in this process — the most powerful, needs its own approved `activate`).\r\n\r\n## Workflow\r\n\r\n1. `{\"action\":\"list\"}` — see what is already installed before adding anything. To confirm the gap is real, start from an `InspectOwnAssets` inventory (what exists on disk and what is invocable), then check this table for an existing plugin that already covers it. Do not grow a second plugin that duplicates an existing capability; enable, disable, or extend the one you already have.\r\n2. `{\"action\":\"marketplace\",\"query\":\"pdf\"}` — browse the catalog for a matching capability. Pass `source` to read a different catalog. `tier` is a display label only; judge an entry by its description and source. Entries whose origin previously produced a tripped plugin carry `quarantined: true`.\r\n3. `{\"action\":\"precheck\",\"source\":\"https://github.com/owner/repo\"}` — free read-only origin check before installing anything external that you have not vetted in this session: it reports past incidents recorded by the plugin center's immune memory (`quarantined:true` + the reason). Surface such a warning to the user BEFORE asking for the install approval.\r\n4. If nothing in the catalog fits and precheck is clean, you may search the web (`WebSearch` / `FetchURL`) and evaluate a repository yourself: read its README and manifest, prefer a pinned branch/tag/commit URL over a moving default, and check that it does something you cannot already do.\r\n5. To **make a capability yourself**: if the user invoked `/make-skill`, use the `MakeSkillPlan` → `MakeSkillApply` pair (it produces a valid skill package and registers it into this table automatically). Otherwise build a plugin directory by hand (a `nexum.plugin.json` manifest plus your SKILL.md under `skills/`) and register it with `register_generated` — that route lands in this table, hot-applies the same turn, and stays manageable here (disable/remove/circuit). Writing a plain SKILL.md into the user skills directory is also a legitimate skill, but it does NOT appear in this table and cannot be managed with this tool.\r\n6. `{\"action\":\"install\",\"source\":\"https://github.com/owner/repo/tree/v1.2.0\"}` — install from a local path, a GitHub URL, or a zip URL. **Installing never executes code.** The plugin's files are copied and its record is registered; a manifest `entryPoint` stays dormant until step 8.\r\n7. `{\"action\":\"install\",\"source\":\"...\",\"upgrade\":true}` — same-name refresh: backs up the current files (single slot under `plugins/backups/<id>/`), swaps in the new ones, and reloads; `from`/`to` versions and any downgrade warning are reported. If activation then fails, `rollback` restores the previous files in one approved step.\r\n8. `{\"action\":\"enable\",\"id\":\"...\"}` / `{\"action\":\"disable\",\"id\":\"...\"}` / `{\"action\":\"set_mcp_enabled\",\"id\":\"...\",\"server\":\"...\",\"enabled\":false}` — turn contributed capabilities on and off.\r\n9. `{\"action\":\"activate\",\"id\":\"...\"}` — the only action that runs a plugin's code entry point in this process. Skip it for skill-only and MCP-only plugins; they need no activation.\r\n10. `{\"action\":\"info\",\"id\":\"...\"}` / `{\"action\":\"check\"}` — inspect one record in full, or the health of the table. Each entry also carries `usage: {calls, okCalls, okRate, lastUsedAt}` from this machine: zero calls since install marks it as a cleanup candidate; high usage with a high okRate is worth keeping when you must choose.\r\n11. `{\"action\":\"reset\",\"id\":\"...\"}` — recover a circuit-tripped or manually disabled plugin: clears its failure ledger, re-derives the record from disk, enables it, and hot-applies its capabilities. It never runs code — a code plugin still needs its own approved `activate`.\r\n12. `{\"action\":\"rollback\",\"id\":\"...\"}` — restore the pre-upgrade backup taken by step 7 in one approved step.\r\n13. `{\"action\":\"reload\"}` — re-read the plugin table from disk and get an added/removed/error summary.\r\n14. `{\"action\":\"remove\",\"id\":\"...\"}` (or `disable` to keep the record) — retreat once the capability is no longer wanted.\r\n\r\n## Circuit breaker (limbs that fail get pulled, the loop never dies)\r\n\r\nPlugin-owned capabilities are counted per plugin: every failed tool call (in-process plugin tools and plugin MCP servers) and every faulty event handler. A success clears the streak; three consecutive failures trip the breaker, and the failing result arrives with a `[circuit]` advisory: the plugin was marked with the reason, disabled persistently, its code deactivated, and its tools, MCP servers, skills, and hooks pulled from every live session. Nothing retries automatically — read the state with `check` (each plugin carries `circuit: {failures, tripped}`), then `reset` to give it another chance or `remove` to let it go. User-configured MCP servers and built-in tools are never charged to anyone's breaker.\r\n\r\nEvery trip ALSO writes the origin into the plugin center's immune memory (quarantine ledger): future `precheck`/`install`/`marketplace` calls for the same repository will surface that history before anything is executed again, even across sessions — and even if the broken plugin was removed afterwards.\r\n\r\nChanges are hot-applied to the running session wherever the host supports it: mutating results carry a `sync` report (`{ok, applied[], failed[]}`) naming exactly what landed — `skills.inject`, `mcp.add`/`mcp.remove`, tool teardown. An `install` deliberately reports no `mcp.add`: installing never starts a plugin's MCP process; that waits for an approved `enable`/`activate`/`reload`. Treat `sync.failed` as advisory (the mutation itself already succeeded) and re-check with `info`/`check` rather than re-running the mutation. Reload before judging whether a change landed.\r\n\r\n## Registration of your own output\r\n\r\n`{\"action\":\"register_generated\",\"source\":\"/abs/path/to/generated/plugin\"}` registers a plugin directory you produced locally, without a copy step. It refuses any manifest that declares an `entryPoint`: this action is normally auto-approved and must never become a route to running code. For a code plugin, use `install` and then `activate`.\r\n\r\n## Approval contract\r\n\r\n- Read-only actions (`list`, `info`, `check`, `marketplace`) run without prompting.\r\n- Every mutating action (`install`, `register_generated`, `enable`, `disable`, `set_mcp_enabled`, `activate`, `deactivate`, `remove`, `reset`, `reload`) requires the user's approval. State what you are about to do and why in one line, then call the tool — never describe a plugin change you have not made.\r\n- The approval prompt for `install` and `register_generated` shows the full source string, and a session grant applies to that exact source only.\r\n- `activate` is the step that executes third-party code; treat it as its own decision, made after you have read what the plugin does.\r\n- A rejected approval is an answer, not a retry cue. Report the refusal and continue without the capability.\r\n\r\n## Output\r\n\r\nEvery action returns a JSON string. Success is a compact result object; failure is\r\n`{\"error\":{\"code\",\"message\",\"next\"}}` with `isError: true`. Follow `next` rather than\r\nguessing at a repair — it names the call that resolves the problem.\r\n";
|
|
81622
81680
|
//#endregion
|
|
81623
81681
|
//#region ../../packages/agent-core/src/tools/builtin/plugin/manage-plugin.ts
|
|
81624
81682
|
/** Every action this tool understands. */
|
|
@@ -83385,7 +83443,7 @@ function describeError(error) {
|
|
|
83385
83443
|
}
|
|
83386
83444
|
//#endregion
|
|
83387
83445
|
//#region ../../packages/agent-core/src/tools/builtin/state/inspect-own-assets.md
|
|
83388
|
-
var inspect_own_assets_default = "Use this tool to inspect the agent's own persistent assets: skills, MCP server declarations, configuration files, the memory store, and the knowledge base. It reports what exists, where it lives, and whether it looks valid.\n\n**When to use:**\n- The user asks \"what skills do you have?\", \"show me your mcp config\", \"how is your memory set up?\", \"where is your knowledge base?\", \"检查技能/插件状态\"\n- Auditing your own configuration and data (e.g. checking whether mcp.json parses, why a skill is not usable, which plugin directories are unregistered)\n\n**Inventory questions — this tool is the single answering view.** When the user asks what you have, in ANY wording (skills / plugins / capabilities / MCP / tools / 技能 / 插件 / 能力), treat it as one intent and answer from this inventory: it reports the skill packages in the three standard skill scopes (user, plugin-managed, project) with live `invocable` status from the skill registry, plus MCP declarations. Every \"not invocable\" entry carries its concrete reason (registered but not invocable / broken frontmatter with the parse message / unregistered), and plugin-managed entries show whether their directory is registered in the plugin table, with unregistered directories listed separately — so a status question is answered by this single call, no need to consult ManagePlugin for the same facts. Skills discovered from non-standard locations (nested directories, `.agents/skills`) may not appear here. Pair it with the system-prompt skills section for the \"callable right now\" view. Division of labor: **InspectOwnAssets = inventory (read-only)**, **ManagePlugin = changes (install/enable/remove)**, **Skill tool = invocation**.\n\nYou must NOT modify any of these assets unless the user explicitly asks you to — this tool is strictly read-only.\n\n**When NOT to use:**\n- Reading the user's workspace files — use `read` / `glob` / `grep` instead\n- Writing or editing anything — this tool is strictly read-only\n\n**How to use:**\n- Call with no arguments (or `scope: \"all\"`) to inspect everything\n- Narrow with `scope: \"skills\"` / `\"mcp\"` / `\"config\"` / `\"memory\"` / `\"knowledge\"` to inspect a single category\n\nThis tool never writes, creates, or modifies any file.\n";
|
|
83446
|
+
var inspect_own_assets_default = "Use this tool to inspect the agent's own persistent assets: skills, MCP server declarations, configuration files, the memory store, and the knowledge base. It reports what exists, where it lives, and whether it looks valid.\r\n\r\n**When to use:**\r\n- The user asks \"what skills do you have?\", \"show me your mcp config\", \"how is your memory set up?\", \"where is your knowledge base?\", \"检查技能/插件状态\"\r\n- Auditing your own configuration and data (e.g. checking whether mcp.json parses, why a skill is not usable, which plugin directories are unregistered)\r\n\r\n**Inventory questions — this tool is the single answering view.** When the user asks what you have, in ANY wording (skills / plugins / capabilities / MCP / tools / 技能 / 插件 / 能力), treat it as one intent and answer from this inventory: it reports the skill packages in the three standard skill scopes (user, plugin-managed, project) with live `invocable` status from the skill registry, plus MCP declarations. Every \"not invocable\" entry carries its concrete reason (registered but not invocable / broken frontmatter with the parse message / unregistered), and plugin-managed entries show whether their directory is registered in the plugin table, with unregistered directories listed separately — so a status question is answered by this single call, no need to consult ManagePlugin for the same facts. Skills discovered from non-standard locations (nested directories, `.agents/skills`) may not appear here. Pair it with the system-prompt skills section for the \"callable right now\" view. Division of labor: **InspectOwnAssets = inventory (read-only)**, **ManagePlugin = changes (install/enable/remove)**, **Skill tool = invocation**.\r\n\r\nYou must NOT modify any of these assets unless the user explicitly asks you to — this tool is strictly read-only.\r\n\r\n**When NOT to use:**\r\n- Reading the user's workspace files — use `read` / `glob` / `grep` instead\r\n- Writing or editing anything — this tool is strictly read-only\r\n\r\n**How to use:**\r\n- Call with no arguments (or `scope: \"all\"`) to inspect everything\r\n- Narrow with `scope: \"skills\"` / `\"mcp\"` / `\"config\"` / `\"memory\"` / `\"knowledge\"` to inspect a single category\r\n\r\nThis tool never writes, creates, or modifies any file.\r\n";
|
|
83389
83447
|
const InspectOwnAssetsInputSchema = z.object({ scope: z.enum([
|
|
83390
83448
|
"all",
|
|
83391
83449
|
"skills",
|
|
@@ -85116,7 +85174,11 @@ var FullCompaction = class {
|
|
|
85116
85174
|
this.agent.context.applyCompaction(result);
|
|
85117
85175
|
this.lastCompactionFiles = fileLists;
|
|
85118
85176
|
this.lowWaterMark = Math.floor(this.effectiveTokenCount * 1.1);
|
|
85119
|
-
|
|
85177
|
+
try {
|
|
85178
|
+
await this.extractAndStoreMemos(processedSummary, messagesToCompactForOps);
|
|
85179
|
+
} catch (error) {
|
|
85180
|
+
this.agent.log.warn("Memory memo extraction failed (compaction itself succeeded)", { error });
|
|
85181
|
+
}
|
|
85120
85182
|
this.triggerPostCompactHook(data, result);
|
|
85121
85183
|
this.detectSkillCandidates(skillCandidateSummary);
|
|
85122
85184
|
this.consecutiveCompactionFailures = 0;
|
|
@@ -85336,6 +85398,28 @@ function extractPreviousSummary(history) {
|
|
|
85336
85398
|
const text = head.content.filter((p) => p.type === "text").map((p) => p.text).join("");
|
|
85337
85399
|
return text.length > 0 ? text : null;
|
|
85338
85400
|
}
|
|
85401
|
+
/**
|
|
85402
|
+
* Recover memos that may have been lost if the process stopped after the
|
|
85403
|
+
* compaction record was persisted but before memo extraction completed.
|
|
85404
|
+
* Existing memos are skipped, making replay idempotent.
|
|
85405
|
+
*/
|
|
85406
|
+
async function recoverMemosFromCompactionSummary(agent, summary) {
|
|
85407
|
+
const memoStore = agent.memoStore;
|
|
85408
|
+
if (!memoStore || summary === void 0 || summary.trim().length === 0) return;
|
|
85409
|
+
const memos = parseMemoryMemos(summary);
|
|
85410
|
+
if (memos.length === 0) return;
|
|
85411
|
+
const sessionId = agent.homedir ? basename$1(dirname$2(dirname$2(agent.homedir))) : "unknown";
|
|
85412
|
+
const sessionTitle = await agent.getSessionTitle().catch(() => void 0);
|
|
85413
|
+
const projectDir = agent.config.cwd;
|
|
85414
|
+
const failed = (await Promise.allSettled(memos.map(async (memo) => {
|
|
85415
|
+
if (memoStore.existsBySourceAndNeed(sessionId, memo.userNeed, memo.approach)) return;
|
|
85416
|
+
memo.sourceSessionId = sessionId;
|
|
85417
|
+
memo.sourceSessionTitle = sessionTitle ?? "";
|
|
85418
|
+
memo.projectDir = projectDir;
|
|
85419
|
+
await memoStore.append(memo);
|
|
85420
|
+
}))).filter((result) => result.status === "rejected").length;
|
|
85421
|
+
if (failed > 0) agent.log.warn("Some recovered memory memos failed to store", { failed });
|
|
85422
|
+
}
|
|
85339
85423
|
//#endregion
|
|
85340
85424
|
//#region ../../packages/agent-core/src/flags/registry.ts
|
|
85341
85425
|
/**
|
|
@@ -85554,7 +85638,7 @@ function findSupersededPaths(messages, cutoff) {
|
|
|
85554
85638
|
/**
|
|
85555
85639
|
* Lightweight compaction that truncates old tool results without an LLM call.
|
|
85556
85640
|
*
|
|
85557
|
-
* When the context window is filling up (>=
|
|
85641
|
+
* When the context window is filling up (>= 30% by default), old tool result
|
|
85558
85642
|
* messages are replaced with a short placeholder. This frees up tokens for the
|
|
85559
85643
|
* model without the cost and latency of a full compaction.
|
|
85560
85644
|
*
|
|
@@ -90110,6 +90194,7 @@ var FileSystemAgentRecordPersistence = class {
|
|
|
90110
90194
|
pendingRecords = [];
|
|
90111
90195
|
shouldClear = false;
|
|
90112
90196
|
directorySynced = false;
|
|
90197
|
+
rewriteSeq = 0;
|
|
90113
90198
|
flushPromise;
|
|
90114
90199
|
error;
|
|
90115
90200
|
constructor(filePath, options = {}) {
|
|
@@ -90219,7 +90304,27 @@ var FileSystemAgentRecordPersistence = class {
|
|
|
90219
90304
|
const content = (this.options.blobStore !== void 0 ? await Promise.all(batch.map((record) => this.options.blobStore.offload(record))) : batch).map((e) => JSON.stringify(e) + "\n").join("");
|
|
90220
90305
|
const directory = dirname$2(this.filePath);
|
|
90221
90306
|
await mkdir(directory, { recursive: true });
|
|
90222
|
-
|
|
90307
|
+
if (shouldClear) {
|
|
90308
|
+
const tmpPath = `${this.filePath}.${process.pid}.${this.rewriteSeq++}.tmp`;
|
|
90309
|
+
let renamed = false;
|
|
90310
|
+
try {
|
|
90311
|
+
const tmp = await open(tmpPath, "w");
|
|
90312
|
+
try {
|
|
90313
|
+
if (content.length > 0) await tmp.writeFile(content, "utf8");
|
|
90314
|
+
await tmp.sync();
|
|
90315
|
+
} finally {
|
|
90316
|
+
await tmp.close();
|
|
90317
|
+
}
|
|
90318
|
+
await rename(tmpPath, this.filePath);
|
|
90319
|
+
renamed = true;
|
|
90320
|
+
await syncDir(directory);
|
|
90321
|
+
this.directorySynced = true;
|
|
90322
|
+
return;
|
|
90323
|
+
} finally {
|
|
90324
|
+
if (!renamed) await unlink(tmpPath).catch(() => void 0);
|
|
90325
|
+
}
|
|
90326
|
+
}
|
|
90327
|
+
const fh = await open(this.filePath, "a");
|
|
90223
90328
|
try {
|
|
90224
90329
|
if (content.length > 0) await fh.writeFile(content, "utf8");
|
|
90225
90330
|
await fh.sync();
|
|
@@ -90576,6 +90681,7 @@ function restoreAgentRecord(agent, input) {
|
|
|
90576
90681
|
return;
|
|
90577
90682
|
case "context.apply_compaction":
|
|
90578
90683
|
agent.context.applyCompaction(input);
|
|
90684
|
+
recoverMemosFromCompactionSummary(agent, input.summary);
|
|
90579
90685
|
return;
|
|
90580
90686
|
case "context.snapshot":
|
|
90581
90687
|
agent.context.restoreJSONSnapshot(input.snapshot);
|
|
@@ -90677,6 +90783,10 @@ var AgentRecords = class {
|
|
|
90677
90783
|
if (!record) continue;
|
|
90678
90784
|
if (i < snapshotIndex && isSnapshotFoldedContextRecord(record.type)) continue;
|
|
90679
90785
|
this.restore(record);
|
|
90786
|
+
if (record.type === "context.snapshot") {
|
|
90787
|
+
const text = record.snapshot.history.find((message) => message.origin?.kind === "compaction_summary")?.content.map((part) => part.type === "text" ? part.text : "").join("");
|
|
90788
|
+
await recoverMemosFromCompactionSummary(this.agent, text);
|
|
90789
|
+
}
|
|
90680
90790
|
}
|
|
90681
90791
|
this.agent.context.dropVacuousOpenMessages();
|
|
90682
90792
|
if (shouldRewrite) {
|
|
@@ -103957,7 +104067,7 @@ function normalizeSourcePath(path) {
|
|
|
103957
104067
|
}
|
|
103958
104068
|
//#endregion
|
|
103959
104069
|
//#region ../../packages/agent-core/src/profile/default/agent.yaml
|
|
103960
|
-
var agent_default = "name: agent\ndescription: Default Nexum Code agent\n\nsystemPromptPath: ./system.md\npromptVars:\n roleAdditional: ''\n\ntools:\n - Read\n - Write\n - Edit\n - Grep\n - Glob\n - Bash\n - TaskList\n - TaskOutput\n - TaskStop\n - CronCreate\n - CronList\n - CronDelete\n - CreateGoal\n - GetGoal\n - SetGoalBudget\n - UpdateGoal\n - ReadMediaFile\n - TodoList\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n - MemoryWrite\n - KnowledgeLookup\n - InspectOwnAssets\n - Skill\n - MakeSkillPlan\n - MakeSkillApply\n # Main-agent capability management. Subagent profiles inherit this list, but\n # the tool is only registered for main agents, so it never reaches their\n # model-visible tool set.\n - ManagePlugin\n - WebSearch\n - Agent\n - WolfPack\n\n - FetchURL\n - AskUserQuestion\n - EnterPlanMode\n - FusionPlan\n - ExitPlanMode\n - mcp__*\n\nsubagents:\n coder:\n description: Good at general software engineering tasks.\n explore:\n description: Fast codebase exploration with prompt-enforced read-only behavior.\n plan:\n description: Read-only implementation planning and architecture design.\n verify:\n description: Verification specialist. Runs build, test, and lint commands to validate code changes.\n reviewer:\n description: Code review specialist. Identifies bugs and API contract violations before merge.\n oracle:\n description: Deep debugging, architecture decisions, and second opinions.\n worker:\n description: Office and document automation worker. Performs format conversion, batch file processing, file organization, and document transformation; never modifies code and does not write content.\n writer:\n description: Professional writing and document specialist. Researches, drafts, rewrites, edits, translates, summarizes, and uses available workspace-local toolchains to produce or revise Markdown, text, HTML, PDF/Office-compatible, spreadsheet-style, and presentation-oriented artifacts.\n";
|
|
104070
|
+
var agent_default = "name: agent\r\ndescription: Default Nexum Code agent\r\n\r\nsystemPromptPath: ./system.md\r\npromptVars:\r\n roleAdditional: ''\r\n\r\ntools:\r\n - Read\r\n - Write\r\n - Edit\r\n - Grep\r\n - Glob\r\n - Bash\r\n - TaskList\r\n - TaskOutput\r\n - TaskStop\r\n - CronCreate\r\n - CronList\r\n - CronDelete\r\n - CreateGoal\r\n - GetGoal\r\n - SetGoalBudget\r\n - UpdateGoal\r\n - ReadMediaFile\r\n - TodoList\r\n - MemoryLookup\r\n - MemoryConsolidatePlan\r\n - MemoryConsolidateApply\r\n - MemoryWrite\r\n - KnowledgeLookup\r\n - InspectOwnAssets\r\n - Skill\r\n - MakeSkillPlan\r\n - MakeSkillApply\r\n # Main-agent capability management. Subagent profiles inherit this list, but\r\n # the tool is only registered for main agents, so it never reaches their\r\n # model-visible tool set.\r\n - ManagePlugin\r\n - WebSearch\r\n - Agent\r\n - WolfPack\r\n\r\n - FetchURL\r\n - AskUserQuestion\r\n - EnterPlanMode\r\n - FusionPlan\r\n - ExitPlanMode\r\n - mcp__*\r\n\r\nsubagents:\r\n coder:\r\n description: Good at general software engineering tasks.\r\n explore:\r\n description: Fast codebase exploration with prompt-enforced read-only behavior.\r\n plan:\r\n description: Read-only implementation planning and architecture design.\r\n verify:\r\n description: Verification specialist. Runs build, test, and lint commands to validate code changes.\r\n reviewer:\r\n description: Code review specialist. Identifies bugs and API contract violations before merge.\r\n oracle:\r\n description: Deep debugging, architecture decisions, and second opinions.\r\n worker:\r\n description: Office and document automation worker. Performs format conversion, batch file processing, file organization, and document transformation; never modifies code and does not write content.\r\n writer:\r\n description: Professional writing and document specialist. Researches, drafts, rewrites, edits, translates, summarizes, and uses available workspace-local toolchains to produce or revise Markdown, text, HTML, PDF/Office-compatible, spreadsheet-style, and presentation-oriented artifacts.\r\n";
|
|
103961
104071
|
//#endregion
|
|
103962
104072
|
//#region ../../packages/agent-core/src/profile/default/coder.yaml
|
|
103963
104073
|
var coder_default = "extends: agent\r\nname: coder\r\npromptVars:\r\n roleAdditional: |\r\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\r\nwhenToUse: |\r\n Use this agent for non-trivial software engineering work that may require reading files, editing code, running commands, and returning a compact but technically complete summary to the parent agent.\r\ntools:\r\n - Bash\r\n - Read\r\n - ReadMediaFile\r\n - Glob\r\n - Grep\r\n - Write\r\n - Edit\r\n - WebSearch\r\n - FetchURL\r\n - MemoryLookup\r\n - MemoryConsolidatePlan\r\n - MemoryConsolidateApply\r\n - mcp__*\r\n";
|
|
@@ -111397,6 +111507,9 @@ var SessionSubagentHost = class {
|
|
|
111397
111507
|
backgroundTaskTimeoutMs;
|
|
111398
111508
|
modelBindings;
|
|
111399
111509
|
activeChildren = /* @__PURE__ */ new Map();
|
|
111510
|
+
/** Per-child per-model usage already folded into the parent totals, so a
|
|
111511
|
+
* resumed child's aggregation only adds the delta. */
|
|
111512
|
+
aggregatedChildUsage = /* @__PURE__ */ new WeakMap();
|
|
111400
111513
|
constructor(session, ownerAgentId, backgroundTaskTimeoutMs, modelBindings) {
|
|
111401
111514
|
this.session = session;
|
|
111402
111515
|
this.ownerAgentId = ownerAgentId;
|
|
@@ -111542,6 +111655,21 @@ var SessionSubagentHost = class {
|
|
|
111542
111655
|
result = lastAssistantText$1(child);
|
|
111543
111656
|
}
|
|
111544
111657
|
const usage = child.usage.data().total;
|
|
111658
|
+
const childByModel = child.usage.data().byModel ?? {};
|
|
111659
|
+
const previous = this.aggregatedChildUsage.get(child) ?? {};
|
|
111660
|
+
for (const [model, childUsage] of Object.entries(childByModel)) {
|
|
111661
|
+
const delta = previous[model] === void 0 ? childUsage : subtractUsage(childUsage, previous[model]);
|
|
111662
|
+
if (isZeroUsage(delta)) continue;
|
|
111663
|
+
try {
|
|
111664
|
+
parent.usage.record(model, delta, "session");
|
|
111665
|
+
} catch (error) {
|
|
111666
|
+
parent.log.warn("Failed to aggregate subagent usage", {
|
|
111667
|
+
model,
|
|
111668
|
+
error: String(error)
|
|
111669
|
+
});
|
|
111670
|
+
}
|
|
111671
|
+
}
|
|
111672
|
+
this.aggregatedChildUsage.set(child, childByModel);
|
|
111545
111673
|
let findingsBlock = "";
|
|
111546
111674
|
if (profileName === "reviewer") {
|
|
111547
111675
|
const findings = getFindingsFromStore(child.tools.toolStore);
|
|
@@ -111646,6 +111774,18 @@ var SessionSubagentHost = class {
|
|
|
111646
111774
|
});
|
|
111647
111775
|
}
|
|
111648
111776
|
};
|
|
111777
|
+
/** Element-wise subtraction clamped at zero (usage can never go negative). */
|
|
111778
|
+
function subtractUsage(current, previous) {
|
|
111779
|
+
return {
|
|
111780
|
+
inputOther: Math.max(0, current.inputOther - previous.inputOther),
|
|
111781
|
+
output: Math.max(0, current.output - previous.output),
|
|
111782
|
+
inputCacheRead: Math.max(0, current.inputCacheRead - previous.inputCacheRead),
|
|
111783
|
+
inputCacheCreation: Math.max(0, current.inputCacheCreation - previous.inputCacheCreation)
|
|
111784
|
+
};
|
|
111785
|
+
}
|
|
111786
|
+
function isZeroUsage(usage) {
|
|
111787
|
+
return usage.inputOther === 0 && usage.output === 0 && usage.inputCacheRead === 0 && usage.inputCacheCreation === 0;
|
|
111788
|
+
}
|
|
111649
111789
|
async function runChildTurnToCompletion(child, signal) {
|
|
111650
111790
|
const completion = await child.turn.waitForCurrentTurn(signal);
|
|
111651
111791
|
const turnEnded = completion.event;
|
|
@@ -131388,24 +131528,15 @@ const PIXEL_PULSE_FRAMES = [
|
|
|
131388
131528
|
"▒",
|
|
131389
131529
|
"▓"
|
|
131390
131530
|
];
|
|
131391
|
-
const
|
|
131392
|
-
|
|
131393
|
-
|
|
131394
|
-
|
|
131395
|
-
|
|
131396
|
-
|
|
131397
|
-
|
|
131398
|
-
|
|
131399
|
-
|
|
131400
|
-
{
|
|
131401
|
-
active: 2,
|
|
131402
|
-
forward: true
|
|
131403
|
-
},
|
|
131404
|
-
{
|
|
131405
|
-
active: 1,
|
|
131406
|
-
forward: false
|
|
131407
|
-
}
|
|
131408
|
-
];
|
|
131531
|
+
const forwardFrames = Array.from({ length: 8 }, (_, active) => ({
|
|
131532
|
+
active,
|
|
131533
|
+
forward: true
|
|
131534
|
+
}));
|
|
131535
|
+
const backwardFrames = Array.from({ length: 6 }, (_, i) => ({
|
|
131536
|
+
active: 6 - i,
|
|
131537
|
+
forward: false
|
|
131538
|
+
}));
|
|
131539
|
+
const PULSE_WAVE_FRAMES = [...forwardFrames, ...backwardFrames];
|
|
131409
131540
|
//#endregion
|
|
131410
131541
|
//#region src/utils/persistence.ts
|
|
131411
131542
|
/**
|
|
@@ -136028,7 +136159,7 @@ var FooterComponent = class {
|
|
|
136028
136159
|
this.onGitStatusChange = onGitStatusChange;
|
|
136029
136160
|
this.gitCacheWorkDir = state.workDir;
|
|
136030
136161
|
this.gitCache = createGitStatusCache(state.workDir, { onChange: this.onGitStatusChange });
|
|
136031
|
-
this
|
|
136162
|
+
this.restartStatusTimer(state.streamingPhase, state.goalActive);
|
|
136032
136163
|
}
|
|
136033
136164
|
setState(state) {
|
|
136034
136165
|
const previousPhase = this.state?.streamingPhase;
|
|
@@ -136042,7 +136173,7 @@ var FooterComponent = class {
|
|
|
136042
136173
|
this.startBalanceFlash();
|
|
136043
136174
|
}
|
|
136044
136175
|
this.state = state;
|
|
136045
|
-
if (state.streamingPhase !== previousPhase || state.goalActive !== previousGoalActive) this
|
|
136176
|
+
if (state.streamingPhase !== previousPhase || state.goalActive !== previousGoalActive) this.restartStatusTimer(state.streamingPhase, state.goalActive);
|
|
136046
136177
|
}
|
|
136047
136178
|
/** Drive the shimmer for BALANCE_FLASH_MS, then let the badge settle. */
|
|
136048
136179
|
startBalanceFlash() {
|
|
@@ -136079,19 +136210,28 @@ var FooterComponent = class {
|
|
|
136079
136210
|
invalidate() {}
|
|
136080
136211
|
/** Stop the active-status timer. Idempotent and safe during disposal. */
|
|
136081
136212
|
dispose() {
|
|
136082
|
-
this
|
|
136213
|
+
this.stopStatusTimer();
|
|
136083
136214
|
}
|
|
136084
|
-
|
|
136085
|
-
this
|
|
136215
|
+
restartStatusTimer(phase, goalActive) {
|
|
136216
|
+
this.stopStatusTimer();
|
|
136086
136217
|
if (phase === "idle" && !goalActive) return;
|
|
136087
136218
|
const intervalMs = 1e3 / 30;
|
|
136088
|
-
this.
|
|
136219
|
+
this.scheduleStatusTick(intervalMs, intervalMs);
|
|
136220
|
+
}
|
|
136221
|
+
scheduleStatusTick(intervalMs, delayMs) {
|
|
136222
|
+
const timer = setTimeout(() => {
|
|
136223
|
+
if (this.statusTimer !== timer) return;
|
|
136224
|
+
const startedAt = performance.now();
|
|
136089
136225
|
this.ui.requestRender();
|
|
136090
|
-
|
|
136226
|
+
const tickCostMs = performance.now() - startedAt;
|
|
136227
|
+
if (this.statusTimer !== timer) return;
|
|
136228
|
+
this.scheduleStatusTick(intervalMs, Math.max(0, intervalMs - tickCostMs));
|
|
136229
|
+
}, delayMs);
|
|
136230
|
+
this.statusTimer = timer;
|
|
136091
136231
|
}
|
|
136092
|
-
|
|
136232
|
+
stopStatusTimer() {
|
|
136093
136233
|
if (!this.statusTimer) return;
|
|
136094
|
-
|
|
136234
|
+
clearTimeout(this.statusTimer);
|
|
136095
136235
|
this.statusTimer = null;
|
|
136096
136236
|
}
|
|
136097
136237
|
render(width) {
|
|
@@ -138967,7 +139107,8 @@ var ThinkingComponent = class {
|
|
|
138967
139107
|
expanded = false;
|
|
138968
139108
|
ui;
|
|
138969
139109
|
spinnerFrame = 0;
|
|
138970
|
-
|
|
139110
|
+
spinnerTimer;
|
|
139111
|
+
lastSpinnerTickAt = 0;
|
|
138971
139112
|
textComponent;
|
|
138972
139113
|
cachedWidth;
|
|
138973
139114
|
cachedLines;
|
|
@@ -139051,17 +139192,41 @@ var ThinkingComponent = class {
|
|
|
139051
139192
|
}
|
|
139052
139193
|
return truncated;
|
|
139053
139194
|
}
|
|
139195
|
+
/**
|
|
139196
|
+
* setTimeout self-rescheduling chain with drift-free frame advancement and
|
|
139197
|
+
* paint-cost backpressure (same pattern as the pi-tui Loader): a slow tick
|
|
139198
|
+
* defers the next one instead of stacking intervals, keeping the live
|
|
139199
|
+
* thinking indicator ≤ ~10% CPU even under slow terminal writes.
|
|
139200
|
+
*/
|
|
139201
|
+
scheduleSpinnerTick(delayMs) {
|
|
139202
|
+
if (this.ui === void 0) return;
|
|
139203
|
+
const timer = setTimeout(() => {
|
|
139204
|
+
if (this.spinnerTimer !== timer) return;
|
|
139205
|
+
const startedAt = performance.now();
|
|
139206
|
+
const elapsed = startedAt - this.lastSpinnerTickAt;
|
|
139207
|
+
if (elapsed >= 80) {
|
|
139208
|
+
const steps = Math.floor(elapsed / 80);
|
|
139209
|
+
this.spinnerFrame = (this.spinnerFrame + steps) % BRAILLE_SPINNER_FRAMES.length;
|
|
139210
|
+
this.lastSpinnerTickAt += steps * 80;
|
|
139211
|
+
this.ui?.requestRender();
|
|
139212
|
+
}
|
|
139213
|
+
const frameCostMs = performance.now() - startedAt;
|
|
139214
|
+
if (this.spinnerTimer !== timer) return;
|
|
139215
|
+
const cadenceDelayMs = Math.max(0, 80 - frameCostMs);
|
|
139216
|
+
const backpressureDelayMs = frameCostMs * 9;
|
|
139217
|
+
this.scheduleSpinnerTick(Math.max(cadenceDelayMs, backpressureDelayMs));
|
|
139218
|
+
}, delayMs);
|
|
139219
|
+
this.spinnerTimer = timer;
|
|
139220
|
+
}
|
|
139054
139221
|
startSpinner() {
|
|
139055
|
-
if (this.ui === void 0 || this.
|
|
139056
|
-
this.
|
|
139057
|
-
|
|
139058
|
-
this.ui?.requestRender();
|
|
139059
|
-
}, 80);
|
|
139222
|
+
if (this.ui === void 0 || this.spinnerTimer !== void 0) return;
|
|
139223
|
+
this.lastSpinnerTickAt = performance.now();
|
|
139224
|
+
this.scheduleSpinnerTick(80);
|
|
139060
139225
|
}
|
|
139061
139226
|
stopSpinner() {
|
|
139062
|
-
if (this.
|
|
139063
|
-
|
|
139064
|
-
this.
|
|
139227
|
+
if (this.spinnerTimer === void 0) return;
|
|
139228
|
+
clearTimeout(this.spinnerTimer);
|
|
139229
|
+
this.spinnerTimer = void 0;
|
|
139065
139230
|
}
|
|
139066
139231
|
};
|
|
139067
139232
|
//#endregion
|
|
@@ -141947,7 +142112,11 @@ function findRevokeAnchorComponentIndex(children, count) {
|
|
|
141947
142112
|
function removeRevokeContextComponents(children, startIndex) {
|
|
141948
142113
|
for (let i = children.length - 1; i >= startIndex; i--) {
|
|
141949
142114
|
const child = children[i];
|
|
141950
|
-
if (child !== void 0 && isRevokeContextComponent(child))
|
|
142115
|
+
if (child !== void 0 && isRevokeContextComponent(child)) {
|
|
142116
|
+
const disposable = child;
|
|
142117
|
+
if (typeof disposable.dispose === "function") disposable.dispose();
|
|
142118
|
+
children.splice(i, 1);
|
|
142119
|
+
}
|
|
141951
142120
|
}
|
|
141952
142121
|
}
|
|
141953
142122
|
function isRevokeAnchorComponent(child) {
|
|
@@ -143625,6 +143794,8 @@ var MoonLoader = class extends Text {
|
|
|
143625
143794
|
ui;
|
|
143626
143795
|
colorFn;
|
|
143627
143796
|
label;
|
|
143797
|
+
/** Wall-clock time of the last frame advance, for drift-free scheduling. */
|
|
143798
|
+
lastTickAt = 0;
|
|
143628
143799
|
constructor(ui, colorFn, label = "") {
|
|
143629
143800
|
super("", 1, 0);
|
|
143630
143801
|
this.ui = ui;
|
|
@@ -143633,18 +143804,44 @@ var MoonLoader = class extends Text {
|
|
|
143633
143804
|
this.start();
|
|
143634
143805
|
}
|
|
143635
143806
|
start() {
|
|
143807
|
+
this.lastTickAt = performance.now();
|
|
143636
143808
|
this.updateDisplay();
|
|
143637
|
-
this.
|
|
143638
|
-
this.currentFrame = (this.currentFrame + 1) % BRAILLE_SPINNER_FRAMES.length;
|
|
143639
|
-
this.updateDisplay();
|
|
143640
|
-
}, 80);
|
|
143809
|
+
this.scheduleTick(80, 80);
|
|
143641
143810
|
}
|
|
143642
143811
|
stop() {
|
|
143643
143812
|
if (this.intervalId) {
|
|
143644
|
-
|
|
143813
|
+
clearTimeout(this.intervalId);
|
|
143645
143814
|
this.intervalId = null;
|
|
143646
143815
|
}
|
|
143647
143816
|
}
|
|
143817
|
+
dispose() {
|
|
143818
|
+
this.stop();
|
|
143819
|
+
}
|
|
143820
|
+
/**
|
|
143821
|
+
* setTimeout self-rescheduling chain with drift-free frame advancement and
|
|
143822
|
+
* paint-cost backpressure (same pattern as the pi-tui Loader): a slow tick
|
|
143823
|
+
* defers the next one by `max(0, interval - cost, cost × 9)` instead of
|
|
143824
|
+
* stacking intervals, keeping the spinner ≤ ~10% CPU under slow writes.
|
|
143825
|
+
*/
|
|
143826
|
+
scheduleTick(intervalMs, delayMs) {
|
|
143827
|
+
const timer = setTimeout(() => {
|
|
143828
|
+
if (this.intervalId !== timer) return;
|
|
143829
|
+
const startedAt = performance.now();
|
|
143830
|
+
const elapsed = startedAt - this.lastTickAt;
|
|
143831
|
+
if (elapsed >= intervalMs) {
|
|
143832
|
+
const steps = Math.floor(elapsed / intervalMs);
|
|
143833
|
+
this.currentFrame = (this.currentFrame + steps) % BRAILLE_SPINNER_FRAMES.length;
|
|
143834
|
+
this.lastTickAt += steps * intervalMs;
|
|
143835
|
+
this.updateDisplay();
|
|
143836
|
+
}
|
|
143837
|
+
const frameCostMs = performance.now() - startedAt;
|
|
143838
|
+
if (this.intervalId !== timer) return;
|
|
143839
|
+
const cadenceDelayMs = Math.max(0, intervalMs - frameCostMs);
|
|
143840
|
+
const backpressureDelayMs = frameCostMs * 9;
|
|
143841
|
+
this.scheduleTick(intervalMs, Math.max(cadenceDelayMs, backpressureDelayMs));
|
|
143842
|
+
}, delayMs);
|
|
143843
|
+
this.intervalId = timer;
|
|
143844
|
+
}
|
|
143648
143845
|
setLabel(label) {
|
|
143649
143846
|
this.label = label;
|
|
143650
143847
|
this.updateDisplay();
|
package/dist/main.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const __dirname = __cjsShimDirname(__filename);
|
|
|
6
6
|
import "./suppress-sqlite-warning-C2VB0doZ.mjs";
|
|
7
7
|
//#region src/main.ts
|
|
8
8
|
try {
|
|
9
|
-
(await import("./app-
|
|
9
|
+
(await import("./app-Dzqtno-_.mjs")).main();
|
|
10
10
|
} catch (error) {
|
|
11
11
|
process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
|
|
12
12
|
process.exit(1);
|