@ashx-j/lunr 0.2.27 → 0.2.28
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/CHANGELOG.md +10 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +5 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +5 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +68 -40
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +0 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +28 -4
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +7 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +70 -38
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +9 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +13 -62
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-tps.js +10 -2
- package/dist/builtin-extensions/pi-tps.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/google-vertex.json +1 -1
- package/dist/catalog/providers/google.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/core/agent-session.d.ts +6 -15
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +35 -50
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -11
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +38 -92
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/context-breakdown.d.ts +2 -2
- package/dist/core/context-breakdown.d.ts.map +1 -1
- package/dist/core/context-breakdown.js +22 -20
- package/dist/core/context-breakdown.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/session-manager.d.ts +5 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +16 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/usage-accounting.d.ts +47 -0
- package/dist/core/usage-accounting.d.ts.map +1 -0
- package/dist/core/usage-accounting.js +205 -0
- package/dist/core/usage-accounting.js.map +1 -0
- package/dist/core/usage-history.d.ts +1 -18
- package/dist/core/usage-history.d.ts.map +1 -1
- package/dist/core/usage-history.js +46 -114
- package/dist/core/usage-history.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts.map +1 -1
- package/dist/gateway/mobile-commands.js +13 -1
- package/dist/gateway/mobile-commands.js.map +1 -1
- package/dist/modes/interactive/components/context-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/context-view.js +2 -2
- package/dist/modes/interactive/components/context-view.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -12
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts +5 -0
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-view.js +21 -6
- package/dist/modes/interactive/components/usage-view.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +55 -22
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/node-runtime/{agent-session-services-KDMSPQDY.js → agent-session-services-RTUGP3XR.js} +5 -4
- package/dist/node-runtime/{builtin-extensions-OX6KELNX.js → builtin-extensions-N4EUD6SB.js} +1 -1
- package/dist/node-runtime/{chunk-A2WO6WIN.js → chunk-4QRUZ64T.js} +11 -5
- package/dist/node-runtime/{chunk-ZDJUR45D.js → chunk-BMRXLQWQ.js} +41 -38
- package/dist/node-runtime/{chunk-MQPKUHRN.js → chunk-DFMPRAQQ.js} +8 -8
- package/dist/node-runtime/{chunk-C3P6Q3B2.js → chunk-E5DQGNJI.js} +10 -10
- package/dist/node-runtime/{chunk-FIRA54AC.js → chunk-ICKGAKWX.js} +22 -55
- package/dist/node-runtime/{chunk-JWEVT363.js → chunk-JEK35V2M.js} +14 -8
- package/dist/node-runtime/{chunk-EPR2F3GU.js → chunk-PWHTSQC4.js} +15 -1
- package/dist/node-runtime/{chunk-AYHH7YSD.js → chunk-QT3F6UEV.js} +61 -30
- package/dist/node-runtime/{chunk-JQYNHAKX.js → chunk-RY3FJ6WI.js} +29 -27
- package/dist/node-runtime/{chunk-I2H5QMWW.js → chunk-STMX7W5I.js} +1 -1
- package/dist/node-runtime/chunk-SWWHZ2RI.js +158 -0
- package/dist/node-runtime/{chunk-QNVMKNNN.js → chunk-U3YVZ6UC.js} +4 -4
- package/dist/node-runtime/{command-3HMSY6W2.js → command-YRT7I2BW.js} +1 -1
- package/dist/node-runtime/{commands-OCSSEEWJ.js → commands-2ETOWWRA.js} +5 -5
- package/dist/node-runtime/{export-html-BRWF5AHI.js → export-html-DBQRRMAY.js} +1 -1
- package/dist/node-runtime/{gateway-6623C2U3.js → gateway-V6K2CDWN.js} +9 -9
- package/dist/node-runtime/{goal-AIHEDUYA.js → goal-J7TYMOBK.js} +9 -3
- package/dist/node-runtime/index.js +9 -8
- package/dist/node-runtime/{interactive-mode-FM5DNUSW.js → interactive-mode-ASZ7APYP.js} +7 -6
- package/dist/node-runtime/{lunr-cron-LKVA5CZZ.js → lunr-cron-WD3YH4CR.js} +4 -4
- package/dist/node-runtime/main.js +7 -6
- package/dist/node-runtime/{mobile-commands-XT3NQXLD.js → mobile-commands-ICUXFW5V.js} +2 -2
- package/dist/node-runtime/{pi-subagents-LT3CTO4E.js → pi-subagents-QPU3OXE4.js} +17 -62
- package/dist/node-runtime/rpc-entry.js +7 -6
- package/dist/node-runtime/{session-handoff-LNSPDTKY.js → session-handoff-LYH53ESV.js} +2 -2
- package/dist/node-runtime/{session-manager-YIFIAVGC.js → session-manager-ZJ3N5Q74.js} +1 -1
- package/dist/node-runtime/{subagent-executor-Q5F7DBVM.js → subagent-executor-UI6SHG3X.js} +294 -231
- package/docs/features.md +10 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/install-lock/package-lock.json +24 -24
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +21 -21
- package/package.json +7 -7
|
@@ -550,6 +550,7 @@ var SessionManager = class _SessionManager {
|
|
|
550
550
|
* These need to be appended via appendCompaction() and appendBranchSummary() methods.
|
|
551
551
|
*/
|
|
552
552
|
appendMessage(message) {
|
|
553
|
+
message.role === "assistant" && (message.usage.requestId ??= randomUUID());
|
|
553
554
|
let entry = {
|
|
554
555
|
type: "message",
|
|
555
556
|
id: generateId(this.byId),
|
|
@@ -559,6 +560,19 @@ var SessionManager = class _SessionManager {
|
|
|
559
560
|
};
|
|
560
561
|
return this._appendEntry(entry), entry.id;
|
|
561
562
|
}
|
|
563
|
+
/** Persist an auxiliary request without adding it to model context. */
|
|
564
|
+
appendRequestUsage(purpose, message) {
|
|
565
|
+
let usage = { ...message.usage, requestId: message.usage.requestId ?? randomUUID() };
|
|
566
|
+
return this.appendCustomEntry("request-usage", {
|
|
567
|
+
id: usage.requestId,
|
|
568
|
+
purpose,
|
|
569
|
+
provider: message.provider,
|
|
570
|
+
model: message.responseModel ?? message.model,
|
|
571
|
+
timestamp: Date.now(),
|
|
572
|
+
usage,
|
|
573
|
+
stopReason: message.stopReason
|
|
574
|
+
});
|
|
575
|
+
}
|
|
562
576
|
/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
|
|
563
577
|
appendThinkingLevelChange(thinkingLevel) {
|
|
564
578
|
let entry = {
|
|
@@ -826,7 +840,7 @@ var SessionManager = class _SessionManager {
|
|
|
826
840
|
throw new Error(`Entry ${leafId} not found`);
|
|
827
841
|
let pathWithoutLabels = [], pathParentId = null;
|
|
828
842
|
for (let entry of path)
|
|
829
|
-
entry.type !== "label" && (pathWithoutLabels.push({ ...entry, parentId: pathParentId }), pathParentId = entry.id);
|
|
843
|
+
entry.type !== "label" && (pathWithoutLabels.push({ ...entry, inherited: !0, parentId: pathParentId }), pathParentId = entry.id);
|
|
830
844
|
let newSessionId = createSessionId(), timestamp = (/* @__PURE__ */ new Date()).toISOString(), fileTimestamp = timestamp.replace(/[:.]/g, "-"), newSessionFile = join(this.getSessionDir(), `${fileTimestamp}_${newSessionId}.jsonl`), header = {
|
|
831
845
|
type: "session",
|
|
832
846
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-US544NN6.js";
|
|
9
9
|
import {
|
|
10
10
|
computeContextBreakdown
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RY3FJ6WI.js";
|
|
12
12
|
import {
|
|
13
13
|
copyToClipboard,
|
|
14
14
|
readClipboardText
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
peekRollbackTurnsConsumed,
|
|
49
49
|
rollbackLastTurn,
|
|
50
50
|
setRollbackWarningHandler
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-BMRXLQWQ.js";
|
|
52
52
|
import {
|
|
53
53
|
notifyTodosEnabledChanged
|
|
54
54
|
} from "./chunk-CCCN2UCX.js";
|
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
defaultModelPerProvider,
|
|
102
102
|
findExactModelReferenceMatch,
|
|
103
103
|
resolveModelScope
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-ICKGAKWX.js";
|
|
105
105
|
import {
|
|
106
106
|
SubagentEscapeSequence,
|
|
107
107
|
getSubagentCancellation
|
|
@@ -134,11 +134,11 @@ import {
|
|
|
134
134
|
recordTuiActivity,
|
|
135
135
|
registerTransferHandler,
|
|
136
136
|
requestSessionTransfer
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-STMX7W5I.js";
|
|
138
138
|
import {
|
|
139
139
|
SessionManager,
|
|
140
140
|
sessionEntryToContextMessages
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-PWHTSQC4.js";
|
|
142
142
|
import {
|
|
143
143
|
createCompactionSummaryMessage
|
|
144
144
|
} from "./chunk-FVDOXRUD.js";
|
|
@@ -169,6 +169,11 @@ import {
|
|
|
169
169
|
import {
|
|
170
170
|
time
|
|
171
171
|
} from "./chunk-PVCDKGR6.js";
|
|
172
|
+
import {
|
|
173
|
+
collectUsageRequests,
|
|
174
|
+
totalRequestUsage,
|
|
175
|
+
usageTokens
|
|
176
|
+
} from "./chunk-SWWHZ2RI.js";
|
|
172
177
|
import {
|
|
173
178
|
markStartupMilestone
|
|
174
179
|
} from "./chunk-CCZJ3PYY.js";
|
|
@@ -1783,14 +1788,13 @@ var FooterComponent = class {
|
|
|
1783
1788
|
dispose() {
|
|
1784
1789
|
}
|
|
1785
1790
|
render(width) {
|
|
1786
|
-
let state = this.session.state,
|
|
1791
|
+
let state = this.session.state, totals = totalRequestUsage(collectUsageRequests(this.session.sessionManager.getEntries())), { input: totalInput, output: totalOutput, cacheRead: totalCacheRead, cacheWrite: totalCacheWrite } = totals, totalCost = totals.cost, latestCacheHitRate;
|
|
1787
1792
|
for (let entry of this.session.sessionManager.getEntries())
|
|
1788
1793
|
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
1789
|
-
totalInput += entry.message.usage.input, totalOutput += entry.message.usage.output, totalCacheRead += entry.message.usage.cacheRead, totalCacheWrite += entry.message.usage.cacheWrite, totalCost += entry.message.usage.cost.total;
|
|
1790
1794
|
let latestPromptTokens = entry.message.usage.input + entry.message.usage.cacheRead + entry.message.usage.cacheWrite;
|
|
1791
1795
|
latestCacheHitRate = latestPromptTokens > 0 ? entry.message.usage.cacheRead / latestPromptTokens * 100 : void 0;
|
|
1792
1796
|
}
|
|
1793
|
-
let contextUsage = this.session.getContextUsage(), contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0, contextPercentValue = contextUsage?.percent ?? 0, contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : "?", pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE), branch = this.footerData.getGitBranch();
|
|
1797
|
+
let contextUsage = this.session.getContextUsage(), contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0, contextPercentValue = contextUsage?.percent ?? 0, contextPercent = contextUsage?.percent !== null ? `${contextUsage?.estimated ? "~" : ""}${contextPercentValue.toFixed(1)}` : "?", pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE), branch = this.footerData.getGitBranch();
|
|
1794
1798
|
branch && (pwd = `${pwd} (${branch})`);
|
|
1795
1799
|
let sessionName = this.session.sessionManager.getSessionName();
|
|
1796
1800
|
sessionName && (pwd = `${pwd} \u2022 ${sessionName}`);
|
|
@@ -1881,8 +1885,8 @@ function renderThemedBox(headerText, content, maxWidth) {
|
|
|
1881
1885
|
}
|
|
1882
1886
|
function renderUsageBox(data, maxWidth) {
|
|
1883
1887
|
let content = [];
|
|
1884
|
-
if (data.sessionTotals && data.sessionTotals.total > 0 && (content.push("
|
|
1885
|
-
content.length > 0 && content.push(""), content.push("Context"), content.push(theme.fg("dim", "Estimated
|
|
1888
|
+
if (data.sessionTotals && (data.sessionTotals.total > 0 || data.sessionTotals.requests || data.sessionTotals.unknownRequests || data.sessionTotals.partialRequests) && (content.push("Parent usage including auxiliary requests"), content.push(` input ${formatTokens(data.sessionTotals.input + (data.sessionTotals.cacheRead ?? 0) + (data.sessionTotals.cacheWrite ?? 0))} output ${formatTokens(data.sessionTotals.output)} total ${formatTokens(data.sessionTotals.total)}${formatCachedSuffix(data.sessionTotals.input, data.sessionTotals.cacheRead ?? 0, data.sessionTotals.cacheWrite ?? 0)}`)), data.sessionTotals?.unknownRequests && content.push(` Usage unavailable for ${data.sessionTotals.unknownRequests} request(s).`), data.sessionTotals?.partialRequests && content.push(` Usage incomplete for ${data.sessionTotals.partialRequests} request(s).`), (data.childTotals?.total || data.childTotals?.unknownRequests || data.childTotals?.partialRequests) && content.push(` children ${formatTokens(data.childTotals.total)} combined ${formatTokens(data.combinedTotals?.total ?? 0)}`), data.childTotals?.unknownRequests && content.push(` Child usage unavailable for ${data.childTotals.unknownRequests} request(s).`), data.childTotals?.partialRequests && content.push(` Child usage incomplete for ${data.childTotals.partialRequests} request(s).`), data.breakdown) {
|
|
1889
|
+
content.length > 0 && content.push(""), content.push("Context"), content.push(theme.fg("dim", "Estimated visible context. Tokenization, images and hidden reasoning may differ."));
|
|
1886
1890
|
let rows = [
|
|
1887
1891
|
{ label: "System prompt", tokens: data.breakdown.systemPrompt },
|
|
1888
1892
|
...data.breakdown.contextFiles.map((file) => ({ label: file.label, tokens: file.tokens })),
|
|
@@ -1890,7 +1894,7 @@ function renderUsageBox(data, maxWidth) {
|
|
|
1890
1894
|
{ label: "Tool definitions", tokens: data.breakdown.toolDefinitions },
|
|
1891
1895
|
{ label: "User messages", tokens: data.breakdown.user },
|
|
1892
1896
|
{ label: "Assistant text", tokens: data.breakdown.assistantText },
|
|
1893
|
-
{ label: "
|
|
1897
|
+
{ label: "Visible thinking", tokens: data.breakdown.thinking },
|
|
1894
1898
|
{ label: "Tool calls", tokens: data.breakdown.toolCalls },
|
|
1895
1899
|
{ label: "Tool results", tokens: data.breakdown.toolResults },
|
|
1896
1900
|
{ label: "Summaries", tokens: data.breakdown.summaries },
|
|
@@ -1913,7 +1917,7 @@ function renderUsageBox(data, maxWidth) {
|
|
|
1913
1917
|
continue;
|
|
1914
1918
|
content.length > 0 && content.push("");
|
|
1915
1919
|
let planName = plan.planLabel ? `${plan.provider} \xB7 ${plan.planLabel}` : plan.provider;
|
|
1916
|
-
content.push(`Plan usage (${planName})`);
|
|
1920
|
+
content.push(`Plan usage (${planName}, cached up to 60s)`);
|
|
1917
1921
|
let labelWidth = Math.max(...plan.windows.map((window) => window.label.length));
|
|
1918
1922
|
for (let window of plan.windows)
|
|
1919
1923
|
content.push(planWindowLine(window, labelWidth));
|
|
@@ -1930,7 +1934,7 @@ function rowLine(row, labelWidth) {
|
|
|
1930
1934
|
}
|
|
1931
1935
|
function renderContextBox(data, maxWidth) {
|
|
1932
1936
|
let { breakdown } = data, content = [];
|
|
1933
|
-
data.model && content.push(data.model), content.push(theme.fg("dim", "Estimated
|
|
1937
|
+
data.model && content.push(data.model), content.push(theme.fg("dim", "Estimated visible context, current session only. Actual tokens and hidden reasoning may differ.")), content.push("");
|
|
1934
1938
|
let rows = [
|
|
1935
1939
|
{ label: "System prompt", tokens: breakdown.systemPrompt },
|
|
1936
1940
|
...breakdown.contextFiles.map((file) => ({ label: file.label, tokens: file.tokens })),
|
|
@@ -1938,7 +1942,7 @@ function renderContextBox(data, maxWidth) {
|
|
|
1938
1942
|
{ label: "Tool definitions", tokens: breakdown.toolDefinitions },
|
|
1939
1943
|
{ label: "User messages", tokens: breakdown.user, count: breakdown.counts.user },
|
|
1940
1944
|
{ label: "Assistant text", tokens: breakdown.assistantText, count: breakdown.counts.assistantText },
|
|
1941
|
-
{ label: "
|
|
1945
|
+
{ label: "Visible thinking", tokens: breakdown.thinking, count: breakdown.counts.thinking },
|
|
1942
1946
|
{ label: "Tool calls", tokens: breakdown.toolCalls, count: breakdown.counts.toolCalls },
|
|
1943
1947
|
{ label: "Tool results", tokens: breakdown.toolResults, count: breakdown.counts.toolResults },
|
|
1944
1948
|
{ label: "Summaries", tokens: breakdown.summaries, count: breakdown.counts.summaries }
|
|
@@ -7545,7 +7549,7 @@ ${message}`, ["Yes", "No"], opts) === "Yes";
|
|
|
7545
7549
|
}
|
|
7546
7550
|
/**
|
|
7547
7551
|
* Show a transcript notice when a completed assistant message paid for a
|
|
7548
|
-
* significant cache miss.
|
|
7552
|
+
* significant cache miss. The overlap estimate cannot establish identical prompt content. It also shows
|
|
7549
7553
|
* a model switch, or an idle gap past the cache TTL.
|
|
7550
7554
|
*/
|
|
7551
7555
|
maybeShowCacheMissNotice(message) {
|
|
@@ -7557,8 +7561,8 @@ ${message}`, ["Yes", "No"], opts) === "Yes";
|
|
|
7557
7561
|
addCacheMissNotice(miss) {
|
|
7558
7562
|
if (miss.missedTokens < 2e4 && miss.missedCost < 0.1)
|
|
7559
7563
|
return;
|
|
7560
|
-
let cost = miss.missedCost >= 0.01 ? ` (~$${miss.missedCost.toFixed(2)})` : "", reBilled =
|
|
7561
|
-
miss.modelChanged ? label = "
|
|
7564
|
+
let cost = miss.missedCost >= 0.01 ? ` (~$${miss.missedCost.toFixed(2)})` : "", reBilled = `~${formatTokens(miss.missedTokens)} tokens may have missed cache${cost}`, label = "Estimated cache miss";
|
|
7565
|
+
miss.modelChanged ? label = "Estimated cache miss after model switch" : miss.idleMs >= 3e5 && (label = `Cache miss after ${Math.round(miss.idleMs / 6e4)}m idle`);
|
|
7562
7566
|
let text = theme.fg("warning", `${label}: ${reBilled}`);
|
|
7563
7567
|
this.chatContainer.addChild(new Spacer19(1)), this.chatContainer.addChild(new Text21(text, 1, 0));
|
|
7564
7568
|
}
|
|
@@ -9528,9 +9532,22 @@ Gist: ${gistUrl}`);
|
|
|
9528
9532
|
let prompt = `Generate a title of at most 6 words summarizing this request. Reply with the title only \u2014 no quotes, no trailing punctuation, no prefix.
|
|
9529
9533
|
|
|
9530
9534
|
Request:
|
|
9531
|
-
${firstUserText.slice(0, 2e3)}`,
|
|
9535
|
+
${firstUserText.slice(0, 2e3)}`, requestSessionId = this.sessionManager.getSessionId(), requestSessionFile = this.sessionManager.getSessionFile(), response = await this.session.modelRuntime.complete(model, {
|
|
9532
9536
|
messages: [{ role: "user", content: [{ type: "text", text: prompt }], timestamp: Date.now() }]
|
|
9533
|
-
})
|
|
9537
|
+
});
|
|
9538
|
+
if (this.sessionManager.getSessionId() !== requestSessionId) {
|
|
9539
|
+
if (requestSessionFile) {
|
|
9540
|
+
let target = SessionManager.open(requestSessionFile);
|
|
9541
|
+
try {
|
|
9542
|
+
target.appendRequestUsage("title", response);
|
|
9543
|
+
} finally {
|
|
9544
|
+
target.dispose();
|
|
9545
|
+
}
|
|
9546
|
+
}
|
|
9547
|
+
return;
|
|
9548
|
+
}
|
|
9549
|
+
this.sessionManager.appendRequestUsage("title", response);
|
|
9550
|
+
let title = response.content.filter((c) => c.type === "text").map((c) => c.text).join(" ").replace(/\s+/g, " ").trim();
|
|
9534
9551
|
if (title = title.replace(/^["'`]+|["'`.!?]+$/g, "").trim(), !title || this.sessionManager.getSessionName())
|
|
9535
9552
|
return;
|
|
9536
9553
|
this.session.setSessionName(title);
|
|
@@ -9540,11 +9557,9 @@ ${firstUserText.slice(0, 2e3)}`, title = (await this.session.modelRuntime.comple
|
|
|
9540
9557
|
}
|
|
9541
9558
|
handleSessionCommand() {
|
|
9542
9559
|
let stats = this.session.getSessionStats(), sessionName = this.sessionManager.getSessionName(), entries = this.sessionManager.getEntries(), cacheWaste = computeCacheWaste(entries, this.session.modelRuntime), perModelMap = /* @__PURE__ */ new Map();
|
|
9543
|
-
for (let
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
let message = entry.message, usage = message.usage, key = `${message.provider}/${message.responseModel ?? message.model}`, bucket = perModelMap.get(key);
|
|
9547
|
-
bucket || (bucket = { key, cost: 0, tokens: 0 }, perModelMap.set(key, bucket)), bucket.cost += usage.cost.total, bucket.tokens += usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
9560
|
+
for (let request of collectUsageRequests(entries)) {
|
|
9561
|
+
let key = `${request.provider}/${request.model}`, bucket = perModelMap.get(key) ?? { key, cost: 0, tokens: 0 };
|
|
9562
|
+
bucket.cost += request.usage.cost.total, bucket.tokens += usageTokens(request.usage), perModelMap.set(key, bucket);
|
|
9548
9563
|
}
|
|
9549
9564
|
let perModel = Array.from(perModelMap.values()).sort((a, b) => b.cost - a.cost), info = `${theme.bold("Session Info")}
|
|
9550
9565
|
|
|
@@ -9559,7 +9574,7 @@ ${firstUserText.slice(0, 2e3)}`, title = (await this.session.modelRuntime.comple
|
|
|
9559
9574
|
`, info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}
|
|
9560
9575
|
`, info += `${theme.fg("dim", "Tools:")} ${stats.toolCalls} calls, ${stats.toolResults} results
|
|
9561
9576
|
|
|
9562
|
-
`, info += `${theme.bold("
|
|
9577
|
+
`, info += `${theme.bold("Parent tokens including auxiliary requests")}
|
|
9563
9578
|
`;
|
|
9564
9579
|
let { input, cacheRead, cacheWrite } = stats.tokens, promptTokens = input + cacheRead + cacheWrite;
|
|
9565
9580
|
if (info += `${theme.fg("dim", "Input:")} ${promptTokens.toLocaleString()}
|
|
@@ -9573,6 +9588,12 @@ ${firstUserText.slice(0, 2e3)}`, title = (await this.session.modelRuntime.comple
|
|
|
9573
9588
|
}
|
|
9574
9589
|
if (info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}
|
|
9575
9590
|
`, info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}
|
|
9591
|
+
`, stats.childUsage?.total && (info += `Children: ${stats.childUsage.total.toLocaleString()} tokens, $${stats.childUsage.cost.toFixed(3)}
|
|
9592
|
+
`, info += `Combined: ${stats.combinedUsage?.total.toLocaleString()} tokens, $${stats.combinedUsage?.cost.toFixed(3)}
|
|
9593
|
+
`), stats.parentUsage?.unknownRequests && (info += `Usage unavailable for ${stats.parentUsage.unknownRequests} request(s).
|
|
9594
|
+
`), stats.parentUsage?.partialRequests && (info += `Usage incomplete for ${stats.parentUsage.partialRequests} request(s).
|
|
9595
|
+
`), stats.parentUsage?.unknownCosts && (info += `Pricing unavailable for ${stats.parentUsage.unknownCosts} request(s).
|
|
9596
|
+
`), info += `Costs use catalog estimates unless the provider reports its account charge.
|
|
9576
9597
|
`, stats.cost > 0 || cacheWaste.missedTokens > 0) {
|
|
9577
9598
|
if (info += `
|
|
9578
9599
|
${theme.bold("Cost")}
|
|
@@ -9583,8 +9604,8 @@ ${theme.bold("Cost")}
|
|
|
9583
9604
|
if (cacheWaste.missedTokens > 0) {
|
|
9584
9605
|
let missLabel = cacheWaste.missCount === 1 ? "1 miss" : `${cacheWaste.missCount} misses`, detail = `${cacheWaste.missedTokens.toLocaleString()} tokens, ${missLabel}`;
|
|
9585
9606
|
info += cacheWaste.missedCost >= 1e-4 ? `
|
|
9586
|
-
${theme.fg("dim", "
|
|
9587
|
-
${theme.fg("dim", "
|
|
9607
|
+
${theme.fg("dim", "Estimated cache misses:")} $${cacheWaste.missedCost.toFixed(3)} ${theme.fg("dim", `(${detail})`)}` : `
|
|
9608
|
+
${theme.fg("dim", "Estimated cache misses:")} ${detail}`;
|
|
9588
9609
|
}
|
|
9589
9610
|
}
|
|
9590
9611
|
this.chatContainer.addChild(new Spacer19(1)), this.chatContainer.addChild(new Text21(info, 1, 0)), this.ui.requestRender();
|
|
@@ -9623,13 +9644,23 @@ ${theme.fg("dim", "Cache Re-billed:")} ${detail}`;
|
|
|
9623
9644
|
// lunr: /usage — current session only: token totals, live context split,
|
|
9624
9645
|
// context-window bar, and subscription plan usage.
|
|
9625
9646
|
async handleUsageCommand() {
|
|
9626
|
-
let stats = this.session.getSessionStats(), sessionTotals = stats.tokens.total > 0 ? {
|
|
9647
|
+
let stats = this.session.getSessionStats(), sessionTotals = stats.tokens.total > 0 || stats.parentUsage?.requests || stats.parentUsage?.unknownRequests || stats.parentUsage?.partialRequests ? {
|
|
9627
9648
|
input: stats.tokens.input,
|
|
9628
9649
|
output: stats.tokens.output,
|
|
9629
9650
|
cacheRead: stats.tokens.cacheRead,
|
|
9630
9651
|
cacheWrite: stats.tokens.cacheWrite,
|
|
9631
|
-
total: stats.tokens.total
|
|
9632
|
-
|
|
9652
|
+
total: stats.tokens.total,
|
|
9653
|
+
requests: stats.parentUsage?.requests,
|
|
9654
|
+
unknownRequests: stats.parentUsage?.unknownRequests,
|
|
9655
|
+
partialRequests: stats.parentUsage?.partialRequests
|
|
9656
|
+
} : void 0, context = this.session.getContextUsage(), provider = this.session.model?.provider, planResult = await getAllPlanUsageResults(provider, this.session.modelRuntime), breakdown = this.collectUsageBreakdown(), lines = renderUsageBox({
|
|
9657
|
+
sessionTotals,
|
|
9658
|
+
childTotals: stats.childUsage,
|
|
9659
|
+
combinedTotals: stats.combinedUsage,
|
|
9660
|
+
context,
|
|
9661
|
+
plan: planResult.usages,
|
|
9662
|
+
breakdown
|
|
9663
|
+
}, this.ui.terminal.columns);
|
|
9633
9664
|
this.chatContainer.addChild(new Spacer19(1)), this.chatContainer.addChild(new Text21(lines.join(`
|
|
9634
9665
|
`), 1, 0)), planResult.errors.length > 0 && this.showStatus(planResult.errors.join(`
|
|
9635
9666
|
`)), this.ui.requestRender();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
estimateTokens
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ICKGAKWX.js";
|
|
5
5
|
|
|
6
6
|
// packages/coding-agent/dist/core/context-breakdown.js
|
|
7
|
-
|
|
7
|
+
import { estimateTextTokens } from "@ashx-j/lunr-ai/compat";
|
|
8
|
+
var PROJECT_CONTEXT_RE = /<project_context>[\s\S]*?<\/project_context>/, PROJECT_INSTRUCTIONS_RE = /<project_instructions(?:\s+path="([^"]*)")?>([\s\S]*?)<\/project_instructions>/g, SKILLS_BLOCK_RE = /\n\nThe following skills provide specialized instructions for specific tasks\.[\s\S]*<\/available_skills>/;
|
|
8
9
|
function estimateChars(text) {
|
|
9
|
-
return
|
|
10
|
+
return estimateTextTokens(text);
|
|
10
11
|
}
|
|
11
12
|
function contextFileLabel(filePath, globalAgentsPath, modelAgentsPath) {
|
|
12
13
|
if (!filePath)
|
|
@@ -35,16 +36,16 @@ function splitSystemPromptSections(systemPrompt) {
|
|
|
35
36
|
return skillsMatch && (skills = skillsMatch[0], remaining = remaining.replace(skills, "")), { base: remaining, contextFiles, skills };
|
|
36
37
|
}
|
|
37
38
|
function estimateToolDefinitionTokens(tools) {
|
|
38
|
-
let
|
|
39
|
+
let text = "";
|
|
39
40
|
for (let tool of tools) {
|
|
40
|
-
|
|
41
|
+
text += tool.name + tool.description;
|
|
41
42
|
try {
|
|
42
43
|
let schema = JSON.stringify(tool.parameters);
|
|
43
|
-
schema && (
|
|
44
|
+
schema && (text += schema);
|
|
44
45
|
} catch {
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
+
return estimateTextTokens(text);
|
|
48
49
|
}
|
|
49
50
|
function computeContextBreakdown(input) {
|
|
50
51
|
let sections = splitSystemPromptSections(input.systemPrompt), systemPrompt = estimateChars(sections.base), contextFiles = sections.contextFiles.map((file) => ({
|
|
@@ -60,27 +61,28 @@ function computeContextBreakdown(input) {
|
|
|
60
61
|
summaries: 0
|
|
61
62
|
};
|
|
62
63
|
for (let message of input.messages)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (!(message.role === "bashExecution" && message.excludeFromContext))
|
|
65
|
+
switch (message.role) {
|
|
66
|
+
case "assistant": {
|
|
67
|
+
let text = "", thinkingText = "", toolCallText = "";
|
|
68
|
+
for (let block of message.content)
|
|
69
|
+
block.type === "text" ? text += block.text : block.type === "thinking" ? thinkingText += block.thinking : block.type === "toolCall" && (toolCallText += block.name + JSON.stringify(block.arguments));
|
|
70
|
+
assistantText += estimateTextTokens(text), thinking += estimateTextTokens(thinkingText), toolCalls += estimateTextTokens(toolCallText), text.length > 0 && counts.assistantText++, thinkingText.length > 0 && counts.thinking++, toolCallText.length > 0 && counts.toolCalls++;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "user":
|
|
74
|
+
case "custom":
|
|
75
|
+
user += estimateTokens(message), counts.user++;
|
|
76
|
+
break;
|
|
77
|
+
case "toolResult":
|
|
78
|
+
case "bashExecution":
|
|
79
|
+
toolResults += estimateTokens(message), counts.toolResults++;
|
|
80
|
+
break;
|
|
81
|
+
case "branchSummary":
|
|
82
|
+
case "compactionSummary":
|
|
83
|
+
summaries += estimateTokens(message), counts.summaries++;
|
|
84
|
+
break;
|
|
70
85
|
}
|
|
71
|
-
case "user":
|
|
72
|
-
case "custom":
|
|
73
|
-
user += estimateTokens(message), counts.user++;
|
|
74
|
-
break;
|
|
75
|
-
case "toolResult":
|
|
76
|
-
case "bashExecution":
|
|
77
|
-
toolResults += estimateTokens(message), counts.toolResults++;
|
|
78
|
-
break;
|
|
79
|
-
case "branchSummary":
|
|
80
|
-
case "compactionSummary":
|
|
81
|
-
summaries += estimateTokens(message), counts.summaries++;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
86
|
let contextFileTokens = contextFiles.reduce((sum, file) => sum + file.tokens, 0), total = systemPrompt + contextFileTokens + skills + toolDefinitions + user + assistantText + thinking + toolCalls + toolResults + summaries;
|
|
85
87
|
return {
|
|
86
88
|
systemPrompt,
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/coding-agent/dist/core/usage-accounting.js
|
|
4
|
+
var REQUEST_USAGE_TYPE = "request-usage";
|
|
5
|
+
function emptyUsageTotals() {
|
|
6
|
+
return {
|
|
7
|
+
requests: 0,
|
|
8
|
+
input: 0,
|
|
9
|
+
output: 0,
|
|
10
|
+
cacheRead: 0,
|
|
11
|
+
cacheWrite: 0,
|
|
12
|
+
total: 0,
|
|
13
|
+
cost: 0,
|
|
14
|
+
unknownRequests: 0,
|
|
15
|
+
partialRequests: 0,
|
|
16
|
+
unknownCosts: 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function usageTokens(usage) {
|
|
20
|
+
return usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
21
|
+
}
|
|
22
|
+
function collectUsageRequests(entries) {
|
|
23
|
+
let requests = /* @__PURE__ */ new Map();
|
|
24
|
+
for (let entry of entries) {
|
|
25
|
+
if (entry.inherited)
|
|
26
|
+
continue;
|
|
27
|
+
let request;
|
|
28
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
29
|
+
let message = entry.message;
|
|
30
|
+
if (!validUsage(message.usage))
|
|
31
|
+
continue;
|
|
32
|
+
request = {
|
|
33
|
+
id: message.usage.requestId ?? `${entry.id}:${entry.timestamp}:${message.provider}/${message.model}`,
|
|
34
|
+
purpose: "conversation",
|
|
35
|
+
provider: message.provider,
|
|
36
|
+
model: message.responseModel ?? message.model,
|
|
37
|
+
timestamp: Number.isFinite(Date.parse(entry.timestamp)) ? Date.parse(entry.timestamp) : message.timestamp,
|
|
38
|
+
usage: message.usage,
|
|
39
|
+
stopReason: message.stopReason
|
|
40
|
+
};
|
|
41
|
+
} else if (entry.type === "custom" && entry.customType === REQUEST_USAGE_TYPE) {
|
|
42
|
+
let data = entry.data;
|
|
43
|
+
validRequest(data) && (request = data);
|
|
44
|
+
}
|
|
45
|
+
request && validRequest(request) && requests.set(request.id, request);
|
|
46
|
+
}
|
|
47
|
+
return [...requests.values()];
|
|
48
|
+
}
|
|
49
|
+
function totalRequestUsage(requests) {
|
|
50
|
+
let total = emptyUsageTotals();
|
|
51
|
+
total.requests = requests.length;
|
|
52
|
+
for (let { usage } of requests)
|
|
53
|
+
total.input += usage.input, total.output += usage.output, total.cacheRead += usage.cacheRead, total.cacheWrite += usage.cacheWrite, total.total += usageTokens(usage), total.cost += usage.cost.total, total.unknownRequests += +(usage.measurement === "unknown"), total.partialRequests += +(usage.measurement === "partial"), total.unknownCosts += +(usage.costSource === "unknown");
|
|
54
|
+
return total;
|
|
55
|
+
}
|
|
56
|
+
function record(value) {
|
|
57
|
+
return value !== null && typeof value == "object" ? value : void 0;
|
|
58
|
+
}
|
|
59
|
+
function amount(value) {
|
|
60
|
+
return typeof value == "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
61
|
+
}
|
|
62
|
+
function validUsage(value) {
|
|
63
|
+
let usage = record(value), cost = record(usage?.cost);
|
|
64
|
+
return !!(usage && cost && [usage.input, usage.output, usage.cacheRead, usage.cacheWrite, cost.total].every((amount2) => typeof amount2 == "number" && Number.isFinite(amount2) && amount2 >= 0));
|
|
65
|
+
}
|
|
66
|
+
function validRequest(value) {
|
|
67
|
+
let request = record(value);
|
|
68
|
+
return !!(request && typeof request.id == "string" && request.id && validUsage(request.usage) && typeof request.timestamp == "number" && Number.isFinite(request.timestamp));
|
|
69
|
+
}
|
|
70
|
+
function collectChildUsage(entries) {
|
|
71
|
+
let children = /* @__PURE__ */ new Map(), inherited = /* @__PURE__ */ new Map(), requestGroups = /* @__PURE__ */ new Map(), inheritedRequestIds = /* @__PURE__ */ new Set(), requestOwners = /* @__PURE__ */ new Map();
|
|
72
|
+
for (let entry of entries) {
|
|
73
|
+
let details = entry.type === "custom_message" && ["subagent-notify", "subagent-slash-result"].includes(entry.customType) ? record(entry.details) : entry.type === "message" && entry.message.role === "toolResult" && entry.message.toolName?.startsWith("subagent") ? record(entry.message.details) : void 0;
|
|
74
|
+
if (!details)
|
|
75
|
+
continue;
|
|
76
|
+
let slash = record(record(details.result)?.details), candidates = details.children ?? slash?.results ?? details.results;
|
|
77
|
+
if (Array.isArray(candidates))
|
|
78
|
+
for (let candidate of candidates) {
|
|
79
|
+
let child = record(candidate), usage = record(child?.usage);
|
|
80
|
+
if (!child || !usage)
|
|
81
|
+
continue;
|
|
82
|
+
let identity = child.sessionFile ?? child.childId ?? child.id;
|
|
83
|
+
if (typeof identity != "string" || !identity)
|
|
84
|
+
continue;
|
|
85
|
+
let snapshot = {
|
|
86
|
+
id: identity,
|
|
87
|
+
label: String(child.description ?? child.agent ?? "child"),
|
|
88
|
+
sessionFile: typeof child.sessionFile == "string" ? child.sessionFile : void 0,
|
|
89
|
+
input: amount(usage.input),
|
|
90
|
+
output: amount(usage.output),
|
|
91
|
+
cacheRead: amount(usage.cacheRead),
|
|
92
|
+
cacheWrite: amount(usage.cacheWrite),
|
|
93
|
+
cost: amount(usage.cost),
|
|
94
|
+
turns: amount(usage.turns),
|
|
95
|
+
unknownRequests: amount(usage.unknownRequests),
|
|
96
|
+
partialRequests: amount(usage.partialRequests),
|
|
97
|
+
unknownCosts: amount(usage.unknownCosts)
|
|
98
|
+
};
|
|
99
|
+
if (Array.isArray(child.usageRequests)) {
|
|
100
|
+
let requests = requestGroups.get(identity) ?? /* @__PURE__ */ new Map();
|
|
101
|
+
requestGroups.set(identity, requests);
|
|
102
|
+
for (let request of child.usageRequests)
|
|
103
|
+
validRequest(request) && (entry.inherited ? inheritedRequestIds.add(request.id) : (!requestOwners.has(request.id) || requestOwners.get(request.id) === identity) && (requestOwners.set(request.id, identity), requests.set(request.id, request)));
|
|
104
|
+
}
|
|
105
|
+
let target = entry.inherited ? inherited : children, previous = target.get(identity);
|
|
106
|
+
(!previous || usageTokens(snapshot) >= usageTokens(previous)) && target.set(identity, snapshot);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [...children.values()].map((child) => {
|
|
110
|
+
let requests = requestGroups.get(child.id);
|
|
111
|
+
if (requests) {
|
|
112
|
+
let ownRequests = [...requests.values()].filter((request) => !inheritedRequestIds.has(request.id)), total = totalRequestUsage(ownRequests);
|
|
113
|
+
return {
|
|
114
|
+
...child,
|
|
115
|
+
input: total.input,
|
|
116
|
+
output: total.output,
|
|
117
|
+
cacheRead: total.cacheRead,
|
|
118
|
+
cacheWrite: total.cacheWrite,
|
|
119
|
+
cost: total.cost,
|
|
120
|
+
turns: ownRequests.length,
|
|
121
|
+
unknownRequests: total.unknownRequests,
|
|
122
|
+
partialRequests: total.partialRequests,
|
|
123
|
+
unknownCosts: total.unknownCosts
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
let baseline = inherited.get(child.id);
|
|
127
|
+
if (!baseline)
|
|
128
|
+
return child;
|
|
129
|
+
let own = { ...child };
|
|
130
|
+
for (let key of [
|
|
131
|
+
"input",
|
|
132
|
+
"output",
|
|
133
|
+
"cacheRead",
|
|
134
|
+
"cacheWrite",
|
|
135
|
+
"cost",
|
|
136
|
+
"turns",
|
|
137
|
+
"unknownRequests",
|
|
138
|
+
"partialRequests",
|
|
139
|
+
"unknownCosts"
|
|
140
|
+
])
|
|
141
|
+
own[key] = Math.max(0, child[key] - baseline[key]);
|
|
142
|
+
return own;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function totalChildUsage(children) {
|
|
146
|
+
let totals = emptyUsageTotals();
|
|
147
|
+
for (let child of children)
|
|
148
|
+
totals.requests += child.turns, totals.input += child.input, totals.output += child.output, totals.cacheRead += child.cacheRead, totals.cacheWrite += child.cacheWrite, totals.total += usageTokens(child), totals.cost += child.cost, totals.unknownRequests += child.unknownRequests, totals.partialRequests += child.partialRequests, totals.unknownCosts += child.unknownCosts;
|
|
149
|
+
return totals;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
usageTokens,
|
|
154
|
+
collectUsageRequests,
|
|
155
|
+
totalRequestUsage,
|
|
156
|
+
collectChildUsage,
|
|
157
|
+
totalChildUsage
|
|
158
|
+
};
|
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
createPicker,
|
|
7
7
|
gatewayPickerGeneration,
|
|
8
8
|
resolveWithinRoots
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4QRUZ64T.js";
|
|
10
10
|
import {
|
|
11
11
|
computeContextBreakdown
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RY3FJ6WI.js";
|
|
13
13
|
import {
|
|
14
14
|
findExactModelReferenceMatch
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ICKGAKWX.js";
|
|
16
16
|
import {
|
|
17
17
|
SessionManager
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PWHTSQC4.js";
|
|
19
19
|
import {
|
|
20
20
|
runtimeScope
|
|
21
21
|
} from "./chunk-IMLCWLPI.js";
|
|
@@ -32,7 +32,7 @@ lunr gateway autostart off|login|boot
|
|
|
32
32
|
lunr gateway pair approve <platform> <code> [--owner]
|
|
33
33
|
lunr gateway pair list`);
|
|
34
34
|
else {
|
|
35
|
-
let { runGateway } = await import("./gateway-
|
|
35
|
+
let { runGateway } = await import("./gateway-V6K2CDWN.js");
|
|
36
36
|
process.exitCode = await runGateway(sub === "run" ? args.slice(2) : args.slice(1));
|
|
37
37
|
}
|
|
38
38
|
} catch (error) {
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
formatHelpText,
|
|
6
6
|
runChatCommand,
|
|
7
7
|
sendCommandReply
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-U3YVZ6UC.js";
|
|
9
|
+
import "./chunk-4QRUZ64T.js";
|
|
10
10
|
import "./chunk-NNNR3QIY.js";
|
|
11
11
|
import "./chunk-WXYNALHD.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-RY3FJ6WI.js";
|
|
13
|
+
import "./chunk-ICKGAKWX.js";
|
|
14
14
|
import "./chunk-BYC6RKCN.js";
|
|
15
15
|
import "./chunk-CGBXPL3E.js";
|
|
16
16
|
import "./chunk-BBUVIEZB.js";
|
|
@@ -18,7 +18,7 @@ import "./chunk-APVM5NEU.js";
|
|
|
18
18
|
import "./chunk-F2V2F4ZG.js";
|
|
19
19
|
import "./chunk-BDRGN3L2.js";
|
|
20
20
|
import "./chunk-FY4A63RK.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-PWHTSQC4.js";
|
|
22
22
|
import "./chunk-FVDOXRUD.js";
|
|
23
23
|
import "./chunk-IMLCWLPI.js";
|
|
24
24
|
import "./chunk-MNQXDFPV.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
SessionManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PWHTSQC4.js";
|
|
5
5
|
import "./chunk-FVDOXRUD.js";
|
|
6
6
|
import "./chunk-MNQXDFPV.js";
|
|
7
7
|
import {
|