@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { collectUsageRequests, usageTokens } from "../../core/usage-accounting.js";
|
|
1
2
|
/**
|
|
2
3
|
* Interactive mode for the coding agent.
|
|
3
4
|
* Handles TUI rendering and user interaction, delegating business logic to AgentSession.
|
|
@@ -3385,7 +3386,7 @@ export class InteractiveMode {
|
|
|
3385
3386
|
}
|
|
3386
3387
|
/**
|
|
3387
3388
|
* Show a transcript notice when a completed assistant message paid for a
|
|
3388
|
-
* significant cache miss.
|
|
3389
|
+
* significant cache miss. The overlap estimate cannot establish identical prompt content. It also shows
|
|
3389
3390
|
* a model switch, or an idle gap past the cache TTL.
|
|
3390
3391
|
*/
|
|
3391
3392
|
maybeShowCacheMissNotice(message) {
|
|
@@ -3400,10 +3401,10 @@ export class InteractiveMode {
|
|
|
3400
3401
|
if (miss.missedTokens < 20_000 && miss.missedCost < 0.1)
|
|
3401
3402
|
return;
|
|
3402
3403
|
const cost = miss.missedCost >= 0.01 ? ` (~$${miss.missedCost.toFixed(2)})` : "";
|
|
3403
|
-
const reBilled =
|
|
3404
|
-
let label = "
|
|
3404
|
+
const reBilled = `~${formatTokens(miss.missedTokens)} tokens may have missed cache${cost}`;
|
|
3405
|
+
let label = "Estimated cache miss";
|
|
3405
3406
|
if (miss.modelChanged) {
|
|
3406
|
-
label = "
|
|
3407
|
+
label = "Estimated cache miss after model switch";
|
|
3407
3408
|
}
|
|
3408
3409
|
else if (miss.idleMs >= CACHE_TTL_MS) {
|
|
3409
3410
|
label = `Cache miss after ${Math.round(miss.idleMs / 60_000)}m idle`;
|
|
@@ -6279,9 +6280,24 @@ export class InteractiveMode {
|
|
|
6279
6280
|
const prompt = "Generate a title of at most 6 words summarizing this request. " +
|
|
6280
6281
|
"Reply with the title only — no quotes, no trailing punctuation, no prefix.\n\n" +
|
|
6281
6282
|
`Request:\n${firstUserText.slice(0, 2000)}`;
|
|
6283
|
+
const requestSessionId = this.sessionManager.getSessionId();
|
|
6284
|
+
const requestSessionFile = this.sessionManager.getSessionFile();
|
|
6282
6285
|
const response = await this.session.modelRuntime.complete(model, {
|
|
6283
6286
|
messages: [{ role: "user", content: [{ type: "text", text: prompt }], timestamp: Date.now() }],
|
|
6284
6287
|
});
|
|
6288
|
+
if (this.sessionManager.getSessionId() !== requestSessionId) {
|
|
6289
|
+
if (requestSessionFile) {
|
|
6290
|
+
const target = SessionManager.open(requestSessionFile);
|
|
6291
|
+
try {
|
|
6292
|
+
target.appendRequestUsage("title", response);
|
|
6293
|
+
}
|
|
6294
|
+
finally {
|
|
6295
|
+
target.dispose();
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
6298
|
+
return;
|
|
6299
|
+
}
|
|
6300
|
+
this.sessionManager.appendRequestUsage("title", response);
|
|
6285
6301
|
let title = response.content
|
|
6286
6302
|
.filter((c) => c.type === "text")
|
|
6287
6303
|
.map((c) => c.text)
|
|
@@ -6307,19 +6323,12 @@ export class InteractiveMode {
|
|
|
6307
6323
|
// Cost/token totals per provider/model actually used (e.g. OpenRouter `auto`
|
|
6308
6324
|
// resolves to a concrete responseModel), sorted by cost descending.
|
|
6309
6325
|
const perModelMap = new Map();
|
|
6310
|
-
for (const
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
let bucket = perModelMap.get(key);
|
|
6317
|
-
if (!bucket) {
|
|
6318
|
-
bucket = { key, cost: 0, tokens: 0 };
|
|
6319
|
-
perModelMap.set(key, bucket);
|
|
6320
|
-
}
|
|
6321
|
-
bucket.cost += usage.cost.total;
|
|
6322
|
-
bucket.tokens += usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
6326
|
+
for (const request of collectUsageRequests(entries)) {
|
|
6327
|
+
const key = `${request.provider}/${request.model}`;
|
|
6328
|
+
const bucket = perModelMap.get(key) ?? { key, cost: 0, tokens: 0 };
|
|
6329
|
+
bucket.cost += request.usage.cost.total;
|
|
6330
|
+
bucket.tokens += usageTokens(request.usage);
|
|
6331
|
+
perModelMap.set(key, bucket);
|
|
6323
6332
|
}
|
|
6324
6333
|
const perModel = Array.from(perModelMap.values()).sort((a, b) => b.cost - a.cost);
|
|
6325
6334
|
let info = `${theme.bold("Session Info")}\n\n`;
|
|
@@ -6333,7 +6342,7 @@ export class InteractiveMode {
|
|
|
6333
6342
|
info += `${theme.fg("dim", "User:")} ${stats.userMessages}\n`;
|
|
6334
6343
|
info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}\n`;
|
|
6335
6344
|
info += `${theme.fg("dim", "Tools:")} ${stats.toolCalls} calls, ${stats.toolResults} results\n\n`;
|
|
6336
|
-
info += `${theme.bold("
|
|
6345
|
+
info += `${theme.bold("Parent tokens including auxiliary requests")}\n`;
|
|
6337
6346
|
// "Input" is the full prompt volume. With cache activity, split it into
|
|
6338
6347
|
// cached (served from cache) vs uncached (everything else) - the only
|
|
6339
6348
|
// provider-independent split. Cache writes, where reported, are a detail
|
|
@@ -6349,6 +6358,17 @@ export class InteractiveMode {
|
|
|
6349
6358
|
}
|
|
6350
6359
|
info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
|
|
6351
6360
|
info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
|
|
6361
|
+
if (stats.childUsage?.total) {
|
|
6362
|
+
info += `Children: ${stats.childUsage.total.toLocaleString()} tokens, $${stats.childUsage.cost.toFixed(3)}\n`;
|
|
6363
|
+
info += `Combined: ${stats.combinedUsage?.total.toLocaleString()} tokens, $${stats.combinedUsage?.cost.toFixed(3)}\n`;
|
|
6364
|
+
}
|
|
6365
|
+
if (stats.parentUsage?.unknownRequests)
|
|
6366
|
+
info += `Usage unavailable for ${stats.parentUsage.unknownRequests} request(s).\n`;
|
|
6367
|
+
if (stats.parentUsage?.partialRequests)
|
|
6368
|
+
info += `Usage incomplete for ${stats.parentUsage.partialRequests} request(s).\n`;
|
|
6369
|
+
if (stats.parentUsage?.unknownCosts)
|
|
6370
|
+
info += `Pricing unavailable for ${stats.parentUsage.unknownCosts} request(s).\n`;
|
|
6371
|
+
info += "Costs use catalog estimates unless the provider reports its account charge.\n";
|
|
6352
6372
|
if (stats.cost > 0 || cacheWaste.missedTokens > 0) {
|
|
6353
6373
|
info += `\n${theme.bold("Cost")}\n`;
|
|
6354
6374
|
info += `${theme.fg("dim", "Total:")} $${stats.cost.toFixed(3)}`;
|
|
@@ -6362,8 +6382,8 @@ export class InteractiveMode {
|
|
|
6362
6382
|
const detail = `${cacheWaste.missedTokens.toLocaleString()} tokens, ${missLabel}`;
|
|
6363
6383
|
info +=
|
|
6364
6384
|
cacheWaste.missedCost >= 0.0001
|
|
6365
|
-
? `\n${theme.fg("dim", "
|
|
6366
|
-
: `\n${theme.fg("dim", "
|
|
6385
|
+
? `\n${theme.fg("dim", "Estimated cache misses:")} $${cacheWaste.missedCost.toFixed(3)} ${theme.fg("dim", `(${detail})`)}`
|
|
6386
|
+
: `\n${theme.fg("dim", "Estimated cache misses:")} ${detail}`;
|
|
6367
6387
|
}
|
|
6368
6388
|
}
|
|
6369
6389
|
this.chatContainer.addChild(new Spacer(1));
|
|
@@ -6411,20 +6431,33 @@ export class InteractiveMode {
|
|
|
6411
6431
|
// context-window bar, and subscription plan usage.
|
|
6412
6432
|
async handleUsageCommand() {
|
|
6413
6433
|
const stats = this.session.getSessionStats();
|
|
6414
|
-
const sessionTotals = stats.tokens.total > 0
|
|
6434
|
+
const sessionTotals = stats.tokens.total > 0 ||
|
|
6435
|
+
stats.parentUsage?.requests ||
|
|
6436
|
+
stats.parentUsage?.unknownRequests ||
|
|
6437
|
+
stats.parentUsage?.partialRequests
|
|
6415
6438
|
? {
|
|
6416
6439
|
input: stats.tokens.input,
|
|
6417
6440
|
output: stats.tokens.output,
|
|
6418
6441
|
cacheRead: stats.tokens.cacheRead,
|
|
6419
6442
|
cacheWrite: stats.tokens.cacheWrite,
|
|
6420
6443
|
total: stats.tokens.total,
|
|
6444
|
+
requests: stats.parentUsage?.requests,
|
|
6445
|
+
unknownRequests: stats.parentUsage?.unknownRequests,
|
|
6446
|
+
partialRequests: stats.parentUsage?.partialRequests,
|
|
6421
6447
|
}
|
|
6422
6448
|
: undefined;
|
|
6423
6449
|
const context = this.session.getContextUsage();
|
|
6424
6450
|
const provider = this.session.model?.provider;
|
|
6425
6451
|
const planResult = await getAllPlanUsageResults(provider, this.session.modelRuntime);
|
|
6426
6452
|
const breakdown = this.collectUsageBreakdown();
|
|
6427
|
-
const lines = renderUsageBox({
|
|
6453
|
+
const lines = renderUsageBox({
|
|
6454
|
+
sessionTotals,
|
|
6455
|
+
childTotals: stats.childUsage,
|
|
6456
|
+
combinedTotals: stats.combinedUsage,
|
|
6457
|
+
context,
|
|
6458
|
+
plan: planResult.usages,
|
|
6459
|
+
breakdown,
|
|
6460
|
+
}, this.ui.terminal.columns);
|
|
6428
6461
|
this.chatContainer.addChild(new Spacer(1));
|
|
6429
6462
|
this.chatContainer.addChild(new Text(lines.join("\n"), 1, 0));
|
|
6430
6463
|
if (planResult.errors.length > 0)
|