@ponythewhite/base-context 1.0.5 → 1.0.7

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 (42) hide show
  1. package/CHANGELOG.md +12 -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-UVCJPNFC.js → bundled-modules-PS66L3IT.js} +2 -2
  6. package/dist/bundle/{chunk-WFJRFQGG.js → chunk-PFROC4EV.js} +4 -3
  7. package/dist/bundle/{chunk-6FZM46AU.js → chunk-VCW3YDFF.js} +90 -47
  8. package/dist/bundle/{cli-main-OYVMMJUO.js → cli-main-MMHTK7EB.js} +2 -2
  9. package/dist/bundle/cli.js +1 -1
  10. package/dist/bundle/{main-AVMYOTHF.js → main-XAIVH4Y7.js} +2 -2
  11. package/dist/cli/product-doctor.d.ts.map +1 -1
  12. package/dist/cli/product-doctor.js +2 -2
  13. package/dist/cli/product-doctor.js.map +1 -1
  14. package/dist/core/agent-session.d.ts.map +1 -1
  15. package/dist/core/agent-session.js +23 -12
  16. package/dist/core/agent-session.js.map +1 -1
  17. package/dist/core/canonical-context.d.ts +3 -1
  18. package/dist/core/canonical-context.d.ts.map +1 -1
  19. package/dist/core/canonical-context.js +46 -16
  20. package/dist/core/canonical-context.js.map +1 -1
  21. package/dist/core/context-epoch-copy.d.ts.map +1 -1
  22. package/dist/core/context-epoch-copy.js +1 -1
  23. package/dist/core/context-epoch-copy.js.map +1 -1
  24. package/dist/core/context-epoch.d.ts +13 -3
  25. package/dist/core/context-epoch.d.ts.map +1 -1
  26. package/dist/core/context-epoch.js +47 -24
  27. package/dist/core/context-epoch.js.map +1 -1
  28. package/dist/core/inference-coordinator.d.ts.map +1 -1
  29. package/dist/core/inference-coordinator.js +3 -1
  30. package/dist/core/inference-coordinator.js.map +1 -1
  31. package/dist/core/request-view-selection.d.ts +3 -3
  32. package/dist/core/request-view-selection.d.ts.map +1 -1
  33. package/dist/core/request-view-selection.js +14 -7
  34. package/dist/core/request-view-selection.js.map +1 -1
  35. package/dist/core/sdk.d.ts.map +1 -1
  36. package/dist/core/sdk.js +1 -1
  37. package/dist/core/sdk.js.map +1 -1
  38. package/dist/core/session-bootstrap.d.ts +1 -0
  39. package/dist/core/session-bootstrap.d.ts.map +1 -1
  40. package/dist/core/session-bootstrap.js +1 -1
  41. package/dist/core/session-bootstrap.js.map +1 -1
  42. package/package.json +4 -4
@@ -592,7 +592,9 @@ export class AgentSession {
592
592
  try {
593
593
  const messages = await captured.readHistory(async (view) => {
594
594
  const sameSource = controls?.sessionId === view.source.sessionId && controls?.sessionFile === view.source.sessionFile;
595
- const result = await this._contextCompiler.compile(view, limits, sameSource ? omitted : undefined, {}, resource, this._initialContextMode, contextEpochsEnabled);
595
+ const result = await this._contextCompiler.compile(view, limits, sameSource ? omitted : undefined, {}, resource, this._initialContextMode,
596
+ // This MAIN owner binds public admission below, independently of optional token budgets.
597
+ true);
596
598
  if (sameSource && this._contextOmissions === controls) {
597
599
  // Only prune this captured set. A newer control or source switch must survive this read.
598
600
  for (const id of omitted)
@@ -608,7 +610,8 @@ export class AgentSession {
608
610
  const epochContext = getCanonicalEpochContext(messages);
609
611
  if (epochContext)
610
612
  this._contextMode = epochContext.mode;
611
- const nativeSkills = Boolean(contextEpochsEnabled || epochContext?.checkpoint);
613
+ const unbudgetedPublic = !contextEpochsEnabled && Boolean(epochContext?.toolContinuations?.length);
614
+ const nativeSkills = Boolean(contextEpochsEnabled || epochContext?.checkpoint || unbudgetedPublic);
612
615
  const skillPolicy = nativeSkills ? (this._nativeRecoveryEnabled() ? "enabled" : "unavailable") : undefined;
613
616
  if (this._baseSystemPromptOptions.nativeSkillSelection !== skillPolicy) {
614
617
  const previousBase = this._baseSystemPrompt;
@@ -618,14 +621,16 @@ export class AgentSession {
618
621
  if (epochContext?.resourceRevision !== undefined &&
619
622
  getCanonicalViewUnits(messages)?.length !== messages.length)
620
623
  throw new Error("Current resource view requires tracked canonical context");
621
- if (epochContext?.checkpoint && getCanonicalViewUnits(messages)?.length !== messages.length)
624
+ if ((epochContext?.checkpoint || unbudgetedPublic) &&
625
+ getCanonicalViewUnits(messages)?.length !== messages.length)
622
626
  throw new Error("Committed context epoch cannot admit untracked transient messages");
623
627
  if (epochContext &&
624
- (contextEpochsEnabled || epochContext.checkpoint) &&
628
+ (contextEpochsEnabled || epochContext.checkpoint || unbudgetedPublic) &&
625
629
  getCanonicalViewUnits(messages)?.length === messages.length) {
626
630
  let committed = epochContext.checkpoint;
627
631
  let committedEntry = epochContext.checkpointEntry;
628
- const fixed = epochContext.mode === "off" || (committed?.policyOnly === true && !contextEpochsEnabled);
632
+ const fixed = epochContext.mode === "off" ||
633
+ (committed?.policyOnly === true && !contextEpochsEnabled && !unbudgetedPublic);
629
634
  let requestContract = fixed ? retainedContextRequestContract(committed) : undefined;
630
635
  const nativeTail = messages.some((message) => message.role === "toolResult" ||
631
636
  (message.role === "assistant" &&
@@ -651,7 +656,7 @@ export class AgentSession {
651
656
  candidate.projection.pendingPublicMessageGroups?.length))
652
657
  throw new Error("Tool continuation requires its exact public candidate before epoch ACK");
653
658
  assertResourceCurrent(resource);
654
- const representation = contextEpochRepresentation(candidate.request, candidate.assessment, limits.maxSourceBytes);
659
+ const representation = contextEpochRepresentation(candidate.request, candidate.assessment, limits.maxSourceBytes, unbudgetedPublic);
655
660
  const replayContract = "replayContract" in candidate.projection &&
656
661
  candidate.projection.replayContract === "message-groups"
657
662
  ? "message-groups"
@@ -691,7 +696,7 @@ export class AgentSession {
691
696
  const prepared = prepareCanonicalEpoch(candidate.publicMessages ?? messages, candidate.selectedUnitIds, representation, limits.maxSourceBytes, replayContract, publicWindow);
692
697
  if (JSON.stringify(prepared.checkpoint.source) !== JSON.stringify(candidate.source))
693
698
  throw new Error("Context epoch candidate does not match its captured source");
694
- const tokensBefore = candidate.originalAssessment.estimatedInputTokens;
699
+ const tokensBefore = candidate.originalAssessment?.estimatedInputTokens ?? null;
695
700
  const result = {
696
701
  summary: "",
697
702
  firstKeptEntryId: prepared.checkpoint.literalTailId,
@@ -737,7 +742,7 @@ export class AgentSession {
737
742
  return;
738
743
  if (acceptedBody === undefined || request.body !== acceptedBody)
739
744
  throw new Error("Committed context epoch requires a compatible final provider projection");
740
- if (contextEpochRepresentation(request, assessment, limits.maxSourceBytes) !==
745
+ if (contextEpochRepresentation(request, assessment, limits.maxSourceBytes, unbudgetedPublic) !==
741
746
  committed.representation)
742
747
  throw new Error("Context epoch representation changed without a committed boundary");
743
748
  if (committed.resourceRevision !== epochContext.resourceRevision)
@@ -4479,7 +4484,10 @@ export class AgentSession {
4479
4484
  }
4480
4485
  const limits = this.settingsManager.getCanonicalContextLimits();
4481
4486
  const outcomes = structuredClone(this._unpersistedOutcomes);
4482
- const { context } = await readSessionBootstrap(this.sessionManager, limits);
4487
+ const { context } = await readSessionBootstrap(this.sessionManager, limits, {
4488
+ initialContextMode: this._initialContextMode,
4489
+ purpose: "read",
4490
+ });
4483
4491
  this._mergeUnpersistedOutcomes(context.messages, outcomes);
4484
4492
  if (context.messages.length > limits.maxMessages)
4485
4493
  throw new Error("Canonical context message budget exceeded");
@@ -7647,7 +7655,7 @@ export class AgentSession {
7647
7655
  maxSourceBytes: limits.maxSourceBytes,
7648
7656
  };
7649
7657
  return requests.readHistory(async (view) => {
7650
- const messages = await new CanonicalContextCompiler().compile(view, limits, undefined, {}, resource);
7658
+ const messages = await new CanonicalContextCompiler().compile(view, limits, undefined, {}, resource, this._initialContextMode, false, "read");
7651
7659
  this._assertCompactionOwner(owner);
7652
7660
  const context = getCanonicalEpochContext(messages);
7653
7661
  if (context.checkpoint?.includeSummary && pathEntries.at(-1)?.type === "compaction")
@@ -7812,7 +7820,10 @@ export class AgentSession {
7812
7820
  }
7813
7821
  try {
7814
7822
  this._assertCompactionOwner(owner);
7815
- const bootstrap = await readSessionBootstrap(owner.manager, this.settingsManager.getCanonicalContextLimits());
7823
+ const bootstrap = await readSessionBootstrap(owner.manager, this.settingsManager.getCanonicalContextLimits(), {
7824
+ purpose: "read",
7825
+ initialContextMode: this._initialContextMode,
7826
+ });
7816
7827
  this._assertCompactionOwner(owner);
7817
7828
  owner.agent.state.messages = bootstrap.context.messages;
7818
7829
  this._contextOmissions = undefined;
@@ -11971,7 +11982,7 @@ export class AgentSession {
11971
11982
  if (label && !summaryText) {
11972
11983
  await this.sessionManager.appendLabelChange(targetId, label);
11973
11984
  }
11974
- const { context: sessionContext } = await readSessionBootstrap(this.sessionManager, this.settingsManager.getCanonicalContextLimits(), { allowPendingToolPublic: this._contextEpochsEnabled, initialContextMode: this._initialContextMode });
11985
+ const { context: sessionContext } = await readSessionBootstrap(this.sessionManager, this.settingsManager.getCanonicalContextLimits(), { purpose: "read", initialContextMode: this._initialContextMode });
11975
11986
  this.agent.state.messages = sessionContext.messages;
11976
11987
  this._contextOmissions = undefined;
11977
11988
  this._mergeUnpersistedOutcomes(this.agent.state.messages);