@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.
Files changed (138) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
  3. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +5 -2
  4. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
  5. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +4 -1
  6. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -1
  7. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +2 -0
  8. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -1
  9. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +5 -0
  10. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  11. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +2 -0
  12. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  13. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +5 -1
  14. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +68 -40
  16. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +0 -3
  18. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  19. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +28 -4
  20. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  21. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  22. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +1 -0
  23. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +7 -1
  25. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +70 -38
  27. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -1
  28. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +9 -0
  29. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  30. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  31. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  32. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +13 -62
  33. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  34. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  35. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +1 -1
  36. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  37. package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
  38. package/dist/builtin-extensions/pi-tps.js +10 -2
  39. package/dist/builtin-extensions/pi-tps.js.map +1 -1
  40. package/dist/catalog/models.json +1 -1
  41. package/dist/catalog/providers/google-vertex.json +1 -1
  42. package/dist/catalog/providers/google.json +1 -1
  43. package/dist/catalog/publication.json +3 -3
  44. package/dist/core/agent-session.d.ts +6 -15
  45. package/dist/core/agent-session.d.ts.map +1 -1
  46. package/dist/core/agent-session.js +35 -50
  47. package/dist/core/agent-session.js.map +1 -1
  48. package/dist/core/cache-stats.d.ts +1 -1
  49. package/dist/core/cache-stats.d.ts.map +1 -1
  50. package/dist/core/cache-stats.js +1 -1
  51. package/dist/core/cache-stats.js.map +1 -1
  52. package/dist/core/compaction/branch-summarization.d.ts +2 -1
  53. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  54. package/dist/core/compaction/branch-summarization.js +1 -0
  55. package/dist/core/compaction/branch-summarization.js.map +1 -1
  56. package/dist/core/compaction/compaction.d.ts +5 -11
  57. package/dist/core/compaction/compaction.d.ts.map +1 -1
  58. package/dist/core/compaction/compaction.js +38 -92
  59. package/dist/core/compaction/compaction.js.map +1 -1
  60. package/dist/core/context-breakdown.d.ts +2 -2
  61. package/dist/core/context-breakdown.d.ts.map +1 -1
  62. package/dist/core/context-breakdown.js +22 -20
  63. package/dist/core/context-breakdown.js.map +1 -1
  64. package/dist/core/extensions/types.d.ts +3 -1
  65. package/dist/core/extensions/types.d.ts.map +1 -1
  66. package/dist/core/extensions/types.js.map +1 -1
  67. package/dist/core/session-manager.d.ts +5 -1
  68. package/dist/core/session-manager.d.ts.map +1 -1
  69. package/dist/core/session-manager.js +16 -1
  70. package/dist/core/session-manager.js.map +1 -1
  71. package/dist/core/usage-accounting.d.ts +47 -0
  72. package/dist/core/usage-accounting.d.ts.map +1 -0
  73. package/dist/core/usage-accounting.js +205 -0
  74. package/dist/core/usage-accounting.js.map +1 -0
  75. package/dist/core/usage-history.d.ts +1 -18
  76. package/dist/core/usage-history.d.ts.map +1 -1
  77. package/dist/core/usage-history.js +46 -114
  78. package/dist/core/usage-history.js.map +1 -1
  79. package/dist/gateway/mobile-commands.d.ts.map +1 -1
  80. package/dist/gateway/mobile-commands.js +13 -1
  81. package/dist/gateway/mobile-commands.js.map +1 -1
  82. package/dist/modes/interactive/components/context-view.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/context-view.js +2 -2
  84. package/dist/modes/interactive/components/context-view.js.map +1 -1
  85. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  86. package/dist/modes/interactive/components/footer.js +8 -12
  87. package/dist/modes/interactive/components/footer.js.map +1 -1
  88. package/dist/modes/interactive/components/usage-view.d.ts +5 -0
  89. package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
  90. package/dist/modes/interactive/components/usage-view.js +21 -6
  91. package/dist/modes/interactive/components/usage-view.js.map +1 -1
  92. package/dist/modes/interactive/interactive-mode.d.ts +1 -5
  93. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  94. package/dist/modes/interactive/interactive-mode.js +55 -22
  95. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  96. package/dist/node-runtime/{agent-session-services-KDMSPQDY.js → agent-session-services-RTUGP3XR.js} +5 -4
  97. package/dist/node-runtime/{builtin-extensions-OX6KELNX.js → builtin-extensions-N4EUD6SB.js} +1 -1
  98. package/dist/node-runtime/{chunk-A2WO6WIN.js → chunk-4QRUZ64T.js} +11 -5
  99. package/dist/node-runtime/{chunk-ZDJUR45D.js → chunk-BMRXLQWQ.js} +41 -38
  100. package/dist/node-runtime/{chunk-MQPKUHRN.js → chunk-DFMPRAQQ.js} +8 -8
  101. package/dist/node-runtime/{chunk-C3P6Q3B2.js → chunk-E5DQGNJI.js} +10 -10
  102. package/dist/node-runtime/{chunk-FIRA54AC.js → chunk-ICKGAKWX.js} +22 -55
  103. package/dist/node-runtime/{chunk-JWEVT363.js → chunk-JEK35V2M.js} +14 -8
  104. package/dist/node-runtime/{chunk-EPR2F3GU.js → chunk-PWHTSQC4.js} +15 -1
  105. package/dist/node-runtime/{chunk-AYHH7YSD.js → chunk-QT3F6UEV.js} +61 -30
  106. package/dist/node-runtime/{chunk-JQYNHAKX.js → chunk-RY3FJ6WI.js} +29 -27
  107. package/dist/node-runtime/{chunk-I2H5QMWW.js → chunk-STMX7W5I.js} +1 -1
  108. package/dist/node-runtime/chunk-SWWHZ2RI.js +158 -0
  109. package/dist/node-runtime/{chunk-QNVMKNNN.js → chunk-U3YVZ6UC.js} +4 -4
  110. package/dist/node-runtime/{command-3HMSY6W2.js → command-YRT7I2BW.js} +1 -1
  111. package/dist/node-runtime/{commands-OCSSEEWJ.js → commands-2ETOWWRA.js} +5 -5
  112. package/dist/node-runtime/{export-html-BRWF5AHI.js → export-html-DBQRRMAY.js} +1 -1
  113. package/dist/node-runtime/{gateway-6623C2U3.js → gateway-V6K2CDWN.js} +9 -9
  114. package/dist/node-runtime/{goal-AIHEDUYA.js → goal-J7TYMOBK.js} +9 -3
  115. package/dist/node-runtime/index.js +9 -8
  116. package/dist/node-runtime/{interactive-mode-FM5DNUSW.js → interactive-mode-ASZ7APYP.js} +7 -6
  117. package/dist/node-runtime/{lunr-cron-LKVA5CZZ.js → lunr-cron-WD3YH4CR.js} +4 -4
  118. package/dist/node-runtime/main.js +7 -6
  119. package/dist/node-runtime/{mobile-commands-XT3NQXLD.js → mobile-commands-ICUXFW5V.js} +2 -2
  120. package/dist/node-runtime/{pi-subagents-LT3CTO4E.js → pi-subagents-QPU3OXE4.js} +17 -62
  121. package/dist/node-runtime/rpc-entry.js +7 -6
  122. package/dist/node-runtime/{session-handoff-LNSPDTKY.js → session-handoff-LYH53ESV.js} +2 -2
  123. package/dist/node-runtime/{session-manager-YIFIAVGC.js → session-manager-ZJ3N5Q74.js} +1 -1
  124. package/dist/node-runtime/{subagent-executor-Q5F7DBVM.js → subagent-executor-UI6SHG3X.js} +294 -231
  125. package/docs/features.md +10 -0
  126. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  127. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  128. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  129. package/examples/extensions/gondolin/package-lock.json +2 -2
  130. package/examples/extensions/gondolin/package.json +1 -1
  131. package/examples/extensions/sandbox/package-lock.json +2 -2
  132. package/examples/extensions/sandbox/package.json +1 -1
  133. package/examples/extensions/with-deps/package-lock.json +2 -2
  134. package/examples/extensions/with-deps/package.json +1 -1
  135. package/install-lock/package-lock.json +24 -24
  136. package/install-lock/package.json +2 -2
  137. package/npm-shrinkwrap.json +21 -21
  138. 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. Only states observable facts: the miss itself,
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 = `${formatTokens(miss.missedTokens)} tokens re-billed${cost}`;
3404
- let label = "Cache miss";
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 = "Cache miss after model switch";
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 entry of entries) {
6311
- if (entry.type !== "message" || entry.message.role !== "assistant")
6312
- continue;
6313
- const message = entry.message;
6314
- const usage = message.usage;
6315
- const key = `${message.provider}/${message.responseModel ?? message.model}`;
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("Tokens")}\n`;
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", "Cache Re-billed:")} $${cacheWaste.missedCost.toFixed(3)} ${theme.fg("dim", `(${detail})`)}`
6366
- : `\n${theme.fg("dim", "Cache Re-billed:")} ${detail}`;
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({ sessionTotals, context, plan: planResult.usages, breakdown }, this.ui.terminal.columns);
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)