@ponythewhite/base-context 1.0.9 → 1.0.11

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 (80) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/base-context-runtime/pyproject.toml +1 -1
  3. package/dist/base-context-runtime/uv.lock +1 -1
  4. package/dist/build-info.json +1 -1
  5. package/dist/bundle/{bundled-modules-5JRM6P4T.js → bundled-modules-PEFT72QN.js} +2 -2
  6. package/dist/bundle/{chunk-VVI3UKGR.js → chunk-JZHGOOFM.js} +87 -57
  7. package/dist/bundle/{chunk-NEHLB7JV.js → chunk-TOOVREMP.js} +596 -102
  8. package/dist/bundle/{cli-main-YUDBEYE2.js → cli-main-BRXGYTGK.js} +2 -2
  9. package/dist/bundle/cli.js +1 -1
  10. package/dist/bundle/{main-ZLGGAAGU.js → main-POUXGEL6.js} +2 -2
  11. package/dist/core/agent-session.d.ts +0 -1
  12. package/dist/core/agent-session.d.ts.map +1 -1
  13. package/dist/core/agent-session.js +85 -45
  14. package/dist/core/agent-session.js.map +1 -1
  15. package/dist/core/canonical-context.d.ts +19 -3
  16. package/dist/core/canonical-context.d.ts.map +1 -1
  17. package/dist/core/canonical-context.js +245 -39
  18. package/dist/core/canonical-context.js.map +1 -1
  19. package/dist/core/context-epoch-copy.d.ts +1 -1
  20. package/dist/core/context-epoch-copy.d.ts.map +1 -1
  21. package/dist/core/context-epoch-copy.js +18 -7
  22. package/dist/core/context-epoch-copy.js.map +1 -1
  23. package/dist/core/context-epoch.d.ts +18 -3
  24. package/dist/core/context-epoch.d.ts.map +1 -1
  25. package/dist/core/context-epoch.js +13 -2
  26. package/dist/core/context-epoch.js.map +1 -1
  27. package/dist/core/context-tree.d.ts +1 -1
  28. package/dist/core/context-tree.d.ts.map +1 -1
  29. package/dist/core/context-tree.js +98 -8
  30. package/dist/core/context-tree.js.map +1 -1
  31. package/dist/core/history-index-worker.d.ts.map +1 -1
  32. package/dist/core/history-index-worker.js +59 -6
  33. package/dist/core/history-index-worker.js.map +1 -1
  34. package/dist/core/history-index.d.ts +17 -0
  35. package/dist/core/history-index.d.ts.map +1 -1
  36. package/dist/core/history-index.js +22 -0
  37. package/dist/core/history-index.js.map +1 -1
  38. package/dist/core/inference-coordinator.d.ts.map +1 -1
  39. package/dist/core/inference-coordinator.js +5 -1
  40. package/dist/core/inference-coordinator.js.map +1 -1
  41. package/dist/core/public-context.d.ts.map +1 -1
  42. package/dist/core/public-context.js +20 -8
  43. package/dist/core/public-context.js.map +1 -1
  44. package/dist/core/request-view-selection.d.ts +2 -1
  45. package/dist/core/request-view-selection.d.ts.map +1 -1
  46. package/dist/core/request-view-selection.js +29 -2
  47. package/dist/core/request-view-selection.js.map +1 -1
  48. package/dist/core/session-fork-messages.d.ts +5 -0
  49. package/dist/core/session-fork-messages.d.ts.map +1 -1
  50. package/dist/core/session-fork-messages.js +44 -0
  51. package/dist/core/session-fork-messages.js.map +1 -1
  52. package/dist/core/session-history-index.d.ts +5 -0
  53. package/dist/core/session-history-index.d.ts.map +1 -1
  54. package/dist/core/session-history-index.js +7 -0
  55. package/dist/core/session-history-index.js.map +1 -1
  56. package/dist/core/session-manager.d.ts +2 -0
  57. package/dist/core/session-manager.d.ts.map +1 -1
  58. package/dist/core/session-manager.js +155 -13
  59. package/dist/core/session-manager.js.map +1 -1
  60. package/dist/core/session-tree.d.ts +9 -0
  61. package/dist/core/session-tree.d.ts.map +1 -1
  62. package/dist/core/session-tree.js +71 -11
  63. package/dist/core/session-tree.js.map +1 -1
  64. package/dist/modes/agent-connection/in-process-agent-connection.d.ts.map +1 -1
  65. package/dist/modes/agent-connection/in-process-agent-connection.js +4 -4
  66. package/dist/modes/agent-connection/in-process-agent-connection.js.map +1 -1
  67. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  68. package/dist/modes/daemon/daemon-mode.js +19 -34
  69. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  70. package/dist/modes/daemon/daemon-socket.d.ts +5 -0
  71. package/dist/modes/daemon/daemon-socket.d.ts.map +1 -1
  72. package/dist/modes/daemon/daemon-socket.js +19 -0
  73. package/dist/modes/daemon/daemon-socket.js.map +1 -1
  74. package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
  75. package/dist/modes/daemon/daemon-supervisor.js +6 -7
  76. package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
  77. package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
  78. package/dist/modes/daemon/daemon-worker-client.js +5 -5
  79. package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
  80. package/package.json +4 -4
@@ -15,9 +15,9 @@ import { addLoginGuidanceToAuthError, formatAuthenticationFailedMessage, formatN
15
15
  import { addAutonomousContinuation, addAutonomousUsage, autonomousStatus, createAutonomousRuntimeState, nextAutonomousContinuation, refreshAutonomousQualityGates, setAutonomousEnabled, } from "./autonomous.js";
16
16
  import { executeBashWithOperations } from "./bash-executor.js";
17
17
  import { stringifyBoundedJson } from "./bounded-json.js";
18
- import { CanonicalContextCompiler, canonicalRecoveryBoundary, getCanonicalEpochContext, getCanonicalMessageSource, getCanonicalViewUnits, prepareCanonicalEpoch, prepareContextModeEpoch, prepareRecoveryCompaction, readCanonicalContextMode, } from "./canonical-context.js";
18
+ import { CanonicalContextCompiler, canonicalRecoveryBoundary, getCanonicalEpochContext, getCanonicalMessageSource, getCanonicalViewSelectionSource, getCanonicalViewUnits, MissingRecoveryReplayContractError, prepareCanonicalEpoch, prepareContextModeEpoch, prepareRecoveryCompaction, readCanonicalContextMode, } from "./canonical-context.js";
19
19
  import { COMPACT_SKILL_NAME, calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, prepareViewCompaction, serializeConversation, shouldCompact, takeNativeBranchSummaryWrite, } from "./compaction/index.js";
20
- import { appendContextEpoch, assertContextRequestContract, CONTEXT_EPOCH_DETAIL, CONTEXT_SKILL_EPOCH_RENDERER, contextEpochMode, contextEpochRepresentation, contextRequestContract, retainedContextRequestContract, snapshotContextEpoch, } from "./context-epoch.js";
20
+ import { appendContextEpoch, assertContextRequestContract, CONTEXT_EPOCH_DETAIL, CONTEXT_SKILL_EPOCH_RENDERER, contextEpochMode, contextEpochRepresentation, contextRequestContract, retainedContextRequestContract, snapshotContextEpoch, UnsupportedContextEpochConfigurationError, } from "./context-epoch.js";
21
21
  import { ContextTreeRequest, computeOwnAndTotalUsage, loadContextTreeChildFromDisk, loadContextTreeChildrenFromDisk, readContextTreeUsage, readResidentContextTreeUsage, } from "./context-tree.js";
22
22
  import { normalizeHeartbeatDeliveryMode } from "./cron-jobs.js";
23
23
  import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
@@ -32,7 +32,7 @@ import { convertToLlm, createCompactionOutcomeMessage, createHeartbeatPromptMess
32
32
  import { throwIfPromptAdmissionCancelled } from "./prompt-admission.js";
33
33
  import { expandPromptTemplate } from "./prompt-templates.js";
34
34
  import { appendGlobalRefinement, applyRefinementProposal, generateRefinementId, getGlobalHarnessStateDir, getLocalHarnessStateDir, getRefinementHistory, getWorkspaceHarnessStateDir, inferRefinementResultScope, loadGlobalRefinementHistory, loadHarnessState, mergeHarnessStates, mergeRefinementHistory, normalizeRefinementProposal, planRefinement, prepareRefinementApplication, REFINE_SKILL_NAME, reviewAutoRefine, saveHarnessState, takeNativePlannerRequestWrite, withRefinementBaseline, } from "./refinement/index.js";
35
- import { PublicContextBudgetError } from "./request-view-selection.js";
35
+ import { getRecoveryCompactionAuthorization, PublicContextBudgetError } from "./request-view-selection.js";
36
36
  import { resolveConfigValue } from "./resolve-config-value.js";
37
37
  import { assertResourceCurrent } from "./resource-view.js";
38
38
  import { createDefaultRlmSubagentSessionName, createRlmDeleteSubagentHostHandler, createRlmFindModelsHostHandler, createRlmListSubagentsHostHandler, createRlmRunHostHandler, findRlmModelMatches, normalizeRequestedRlmSubagentModel, normalizeRequestedRlmSubagentSessionName, normalizeRequestedRlmSubagentThinkingLevel, } from "./rlm-runtime.js";
@@ -45,8 +45,9 @@ import { appendSentAgentMessageToToolResult, IPYTHON_SENT_AGENT_MESSAGE_CUSTOM_E
45
45
  import { ContextUsageReader } from "./session-context-usage.js";
46
46
  import { bindNativeEntryWriter, } from "./session-entry-origin.js";
47
47
  import { readUserMessagesForForking } from "./session-fork-messages.js";
48
+ import { hydrateCapturedHistoryEntry } from "./session-history-index.js";
48
49
  import { exportSessionBranchToJsonl } from "./session-jsonl-export.js";
49
- import { applyChildUsageAttributions, getLatestCompactionEntry, SessionManager, } from "./session-manager.js";
50
+ import { getLatestCompactionEntry, SessionManager, } from "./session-manager.js";
50
51
  import { getPythonSkillRuntimeInfo } from "./skills.js";
51
52
  import { parseRefineCommandOptions, parseSessionSlashCommand, parseSlashCommand, } from "./slash-commands.js";
52
53
  import { createSyntheticSourceInfo } from "./source-info.js";
@@ -616,7 +617,10 @@ export class AgentSession {
616
617
  if (epochContext)
617
618
  this._contextMode = epochContext.mode;
618
619
  const unbudgetedPublic = !contextEpochsEnabled &&
619
- Boolean(epochContext?.toolContinuations?.length || epochContext?.taskFrameRebased || epochContext?.checkpoint);
620
+ Boolean(epochContext?.toolContinuations?.length ||
621
+ epochContext?.taskFrameRebased ||
622
+ epochContext?.checkpoint ||
623
+ getCanonicalViewSelectionSource(messages)?.recoveryContractRequested);
620
624
  const nativeSkills = Boolean(contextEpochsEnabled || epochContext?.checkpoint || unbudgetedPublic);
621
625
  const skillPolicy = nativeSkills ? (this._nativeRecoveryEnabled() ? "enabled" : "unavailable") : undefined;
622
626
  if (this._baseSystemPromptOptions.nativeSkillSelection !== skillPolicy) {
@@ -663,7 +667,37 @@ export class AgentSession {
663
667
  candidate.projection.pendingPublicMessageGroups?.length))
664
668
  throw new Error("Tool continuation requires its exact public candidate before epoch ACK");
665
669
  assertResourceCurrent(resource);
666
- const representation = contextEpochRepresentation(candidate.request, candidate.assessment, limits.maxSourceBytes, unbudgetedPublic, candidate.responseItemIdentity);
670
+ let representation;
671
+ try {
672
+ representation = contextEpochRepresentation(candidate.request, candidate.assessment, limits.maxSourceBytes, unbudgetedPublic, candidate.responseItemIdentity);
673
+ }
674
+ catch (error) {
675
+ if (error instanceof UnsupportedContextEpochConfigurationError &&
676
+ !contextEpochsEnabled &&
677
+ !candidate.assessment &&
678
+ !committed &&
679
+ !acknowledged &&
680
+ !epochContext.taskFrameRebased &&
681
+ !epochContext.selectedSkills?.length &&
682
+ !epochContext.toolContinuations?.length &&
683
+ !candidate.publicMessages) {
684
+ const source = getCanonicalViewSelectionSource(messages);
685
+ const selected = new Set(candidate.selectedUnitIds);
686
+ if (source.recoveryContractRequested &&
687
+ !source.requiresEpoch &&
688
+ !source.pendingPublicMessageGroups?.length &&
689
+ this.sessionManager === epochManager &&
690
+ compaction.isCurrent() &&
691
+ JSON.stringify(candidate.source) === JSON.stringify(source.source) &&
692
+ candidate.selectedUnitIds.length === source.units.length &&
693
+ selected.size === source.units.length &&
694
+ source.units.every((unit) => selected.has(unit.id))) {
695
+ // Optional capture only. Keep the unchanged full-native offer; grant no epoch or omission.
696
+ return;
697
+ }
698
+ }
699
+ throw error;
700
+ }
667
701
  const replayContract = "replayContract" in candidate.projection &&
668
702
  candidate.projection.replayContract === "message-groups"
669
703
  ? "message-groups"
@@ -4755,7 +4789,7 @@ export class AgentSession {
4755
4789
  async _runPreTurnCompaction() {
4756
4790
  const lastAssistant = this._findLastAssistantMessage();
4757
4791
  if (lastAssistant)
4758
- await this._checkCompaction(lastAssistant, false, false);
4792
+ await this._checkCompaction(lastAssistant, false, false, undefined, true);
4759
4793
  }
4760
4794
  async _prepareForCommit(policy, steps) {
4761
4795
  if (policy.initialRefineBarrier === "always" ||
@@ -7727,7 +7761,7 @@ export class AgentSession {
7727
7761
  }
7728
7762
  }
7729
7763
  /** A private compiled context keeps extension summary edits separate from retained source recipes. */
7730
- async _prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false) {
7764
+ async _prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, capacity) {
7731
7765
  this._assertCompactionOwner(owner);
7732
7766
  const limits = this.settingsManager.getCanonicalContextLimits();
7733
7767
  const resource = this._captureKernelResource();
@@ -7744,13 +7778,14 @@ export class AgentSession {
7744
7778
  const context = getCanonicalEpochContext(messages);
7745
7779
  if (context.checkpoint?.includeSummary && pathEntries.at(-1)?.type === "compaction")
7746
7780
  return { preparation: undefined, maxSourceBytes: limits.maxSourceBytes };
7747
- const boundary = canonicalRecoveryBoundary(messages);
7781
+ const authorization = getRecoveryCompactionAuthorization(capacity);
7782
+ const boundary = canonicalRecoveryBoundary(messages, authorization);
7748
7783
  const preparation = budgetPressure || context.checkpoint || boundary
7749
7784
  ? prepareViewCompaction(messages, context.references.map((ref) => ref?.ref.entryId), pathEntries, settings, boundary, allowShortSession, budgetPressure)
7750
7785
  : prepareCompaction(pathEntries, settings, allowShortSession);
7751
7786
  // Refuse unsupported public data or open groups before starting the summary model call.
7752
7787
  if (preparation)
7753
- prepareRecoveryCompaction(messages, preparation.firstKeptEntryId, limits.maxSourceBytes);
7788
+ prepareRecoveryCompaction(messages, preparation.firstKeptEntryId, limits.maxSourceBytes, authorization);
7754
7789
  return {
7755
7790
  preparation,
7756
7791
  messages,
@@ -7766,7 +7801,7 @@ export class AgentSession {
7766
7801
  */
7767
7802
  async _performCompaction(options) {
7768
7803
  const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges, pathEntries, settings, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, } = options;
7769
- const prepared = await this._prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner, allowShortSession, budgetPressure);
7804
+ const prepared = await this._prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner, allowShortSession, budgetPressure, options.capacity);
7770
7805
  this._assertCompactionOwner(owner);
7771
7806
  if (prepared.resource)
7772
7807
  assertResourceCurrent(prepared.resource);
@@ -7864,7 +7899,7 @@ export class AgentSession {
7864
7899
  this._assertCompactionOwner(owner);
7865
7900
  const result = JSON.parse(JSON.stringify({ summary, firstKeptEntryId, tokensBefore, details }));
7866
7901
  const recovery = prepared.messages
7867
- ? prepareRecoveryCompaction(prepared.messages, firstKeptEntryId, prepared.maxSourceBytes)
7902
+ ? prepareRecoveryCompaction(prepared.messages, firstKeptEntryId, prepared.maxSourceBytes, getRecoveryCompactionAuthorization(options.capacity))
7868
7903
  : undefined;
7869
7904
  if (prepared.resource)
7870
7905
  assertResourceCurrent(prepared.resource);
@@ -8557,7 +8592,31 @@ export class AgentSession {
8557
8592
  const sessionHistory = (async () => {
8558
8593
  if (residentEntries !== undefined)
8559
8594
  return residentEntries;
8560
- return (await this.sessionManager.materializeSourceHistory(limits)).entries.map(({ entry }) => entry);
8595
+ return this.sessionManager.readSourceHistory(async (history) => {
8596
+ const entries = [];
8597
+ let sourceBytes = 0;
8598
+ let after = 0;
8599
+ for (;;) {
8600
+ const page = await history.page(after, 128);
8601
+ if (page.indexedThrough < history.source.sourceSequence)
8602
+ throw new Error("Captured refinement history has incomplete index coverage");
8603
+ for (const reference of page.events) {
8604
+ if (reference.kind !== "custom")
8605
+ continue;
8606
+ // Refinement consumes custom records, not archived conversation or request bodies.
8607
+ if (entries.length >= limits.maxEntries)
8608
+ throw new Error("Refinement history entry budget exceeded");
8609
+ if (sourceBytes + reference.locator.length > limits.maxSourceBytes)
8610
+ throw new Error("Refinement history source byte budget exceeded");
8611
+ const hydrated = await hydrateCapturedHistoryEntry(reference, limits.maxSourceBytes - sourceBytes, history.readPayload);
8612
+ entries.push(hydrated.entry);
8613
+ sourceBytes += reference.locator.length;
8614
+ }
8615
+ if (page.nextAfter === null)
8616
+ return entries;
8617
+ after = page.nextAfter;
8618
+ }
8619
+ });
8561
8620
  })();
8562
8621
  const [globalResult, sessionResult] = await Promise.allSettled([globalHistory, sessionHistory]);
8563
8622
  if (globalResult.status === "rejected") {
@@ -8935,7 +8994,7 @@ export class AgentSession {
8935
8994
  return undefined;
8936
8995
  return calculateContextTokens(assistantMessage.usage);
8937
8996
  }
8938
- async _checkCompaction(assistantMessage, skipAbortedCheck = true, queueAutonomousContinuation = true, invocationOwner) {
8997
+ async _checkCompaction(assistantMessage, skipAbortedCheck = true, queueAutonomousContinuation = true, invocationOwner, beforeNextTurn = false) {
8939
8998
  if (this._compactionSetupFailure)
8940
8999
  return false;
8941
9000
  if (invocationOwner && !this._isCompactionSourceOwnerCurrent(invocationOwner))
@@ -9036,7 +9095,7 @@ export class AgentSession {
9036
9095
  if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
9037
9096
  this._removeLastAssistantFromContext();
9038
9097
  }
9039
- return await this._runAutoCompaction("overflow", true, owner);
9098
+ return await this._runAutoCompaction("overflow", true, owner, false, undefined, beforeNextTurn);
9040
9099
  }
9041
9100
  if (this._pendingRequestedCompaction !== undefined) {
9042
9101
  return await this._runAutoCompaction("requested", false, owner);
@@ -9063,7 +9122,7 @@ export class AgentSession {
9063
9122
  }
9064
9123
  if (!this._isCompactionOwnerCurrent(owner) || !this._contextOptimizationAllowed())
9065
9124
  return false;
9066
- return await this._runAutoCompaction("threshold", false, owner);
9125
+ return await this._runAutoCompaction("threshold", false, owner, false, undefined, beforeNextTurn);
9067
9126
  }
9068
9127
  return false;
9069
9128
  }
@@ -9109,7 +9168,7 @@ export class AgentSession {
9109
9168
  this._emit({ type: "message_start", message: outcomeMessage });
9110
9169
  this._emit({ type: "message_end", message: outcomeMessage });
9111
9170
  }
9112
- async _runAutoCompaction(reason, willRetry, capturedOwner, resumeInPlace = false, capacity) {
9171
+ async _runAutoCompaction(reason, willRetry, capturedOwner, resumeInPlace = false, capacity, beforeNextTurn = false) {
9113
9172
  const checkpoint = this._pendingCheckpoint;
9114
9173
  const pending = this._pendingRequestedCompaction;
9115
9174
  const owner = checkpoint?.owner ?? pending?.owner ?? capturedOwner ?? this._captureCompactionOwner();
@@ -9245,6 +9304,13 @@ export class AgentSession {
9245
9304
  if (!this._isCompactionSourceOwnerCurrent(owner))
9246
9305
  throw failure;
9247
9306
  this._clearQueuedAutonomousContinuationsAfterSkippedThresholdCompaction(reason === "threshold" && shouldContinueAfterCompaction, queuedAutonomousContinuationsForThisCompaction);
9307
+ if (beforeNextTurn && error instanceof MissingRecoveryReplayContractError) {
9308
+ // Let the imminent MAIN obtain its own actual projection/ACK. This was not a recovery attempt.
9309
+ if (reason === "overflow")
9310
+ this._overflowRecovery = "idle";
9311
+ await this._endCompactionUnsuccessfully(reason, "skipped", "Compaction deferred until the next native request establishes recovery replay coverage.", { errorSeverity: "warning", customInstructions, owner });
9312
+ return false;
9313
+ }
9248
9314
  const errorMessage = error instanceof Error ? error.message : "compaction failed";
9249
9315
  const aborted = errorMessage === "Compaction cancelled" ||
9250
9316
  (error instanceof Error && error.name === "AbortError") ||
@@ -12282,39 +12348,13 @@ export class AgentSession {
12282
12348
  _contextWindowResolver() {
12283
12349
  return (provider, modelId) => this._modelRegistry.find(provider, modelId)?.contextWindow;
12284
12350
  }
12285
- _ownUsageMemo;
12286
12351
  // Whole-source own spend, identical to the catalog reduction at passivation.
12287
12352
  async getOwnUsageSummary() {
12288
12353
  if (!this.sessionManager.supportsCapturedHistoryReads()) {
12289
- const entries = await this.sessionManager.readEntries();
12354
+ const entries = this.sessionManager.getEntries();
12290
12355
  return sessionUsageSummaryFrom(computeOwnAndTotalUsage(entries, entries).ownUsage);
12291
12356
  }
12292
- const limits = { maxEntries: 16_384, maxSourceBytes: 64 * 1024 * 1024 };
12293
- return this.sessionManager.readSourceHistory(async (history) => {
12294
- const { sessionId, sessionFile, sourceSequence } = history.source;
12295
- const memo = this._ownUsageMemo;
12296
- if (memo &&
12297
- memo.sessionId === sessionId &&
12298
- memo.sessionFile === sessionFile &&
12299
- memo.sourceSequence === sourceSequence &&
12300
- memo.count <= limits.maxEntries &&
12301
- memo.sourceBytes <= limits.maxSourceBytes) {
12302
- return memo.usage ? { ...memo.usage } : undefined;
12303
- }
12304
- const materialized = await history.materialize(limits);
12305
- const entries = materialized.entries.map(({ entry }) => entry);
12306
- applyChildUsageAttributions(entries);
12307
- const usage = sessionUsageSummaryFrom(computeOwnAndTotalUsage(entries, entries).ownUsage);
12308
- this._ownUsageMemo = {
12309
- sessionId,
12310
- sessionFile,
12311
- sourceSequence,
12312
- count: entries.length,
12313
- sourceBytes: materialized.sourceBytes,
12314
- usage,
12315
- };
12316
- return usage ? { ...usage } : undefined;
12317
- });
12357
+ return this.sessionManager.readOwnUsageSummary();
12318
12358
  }
12319
12359
  /**
12320
12360
  * Build the agent context overview for /context: this session as the root