@ponythewhite/base-context 1.0.14 → 1.0.15

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 (40) hide show
  1. package/CHANGELOG.md +9 -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-UODO7ZR7.js → bundled-modules-O67MEO74.js} +2 -2
  6. package/dist/bundle/{chunk-NLRWERWA.js → chunk-DGO66I3L.js} +51 -20
  7. package/dist/bundle/{chunk-SX7CAXWU.js → chunk-RQFC34FM.js} +131 -49
  8. package/dist/bundle/{cli-main-6GXXIMQQ.js → cli-main-2RER6PBE.js} +2 -2
  9. package/dist/bundle/cli.js +1 -1
  10. package/dist/bundle/{main-HF64B4HM.js → main-YERLD3T4.js} +2 -2
  11. package/dist/core/agent-session.d.ts.map +1 -1
  12. package/dist/core/agent-session.js +36 -24
  13. package/dist/core/agent-session.js.map +1 -1
  14. package/dist/core/compaction/compaction.d.ts +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +11 -9
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/inference-coordinator.d.ts.map +1 -1
  19. package/dist/core/inference-coordinator.js +13 -2
  20. package/dist/core/inference-coordinator.js.map +1 -1
  21. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  22. package/dist/core/kernel/repl-manager.js +5 -0
  23. package/dist/core/kernel/repl-manager.js.map +1 -1
  24. package/dist/core/session-manager.d.ts +8 -0
  25. package/dist/core/session-manager.d.ts.map +1 -1
  26. package/dist/core/session-manager.js +57 -0
  27. package/dist/core/session-manager.js.map +1 -1
  28. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  29. package/dist/modes/daemon/daemon-mode.js +17 -17
  30. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  31. package/dist/modes/daemon/daemon-worker-client.d.ts +1 -0
  32. package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
  33. package/dist/modes/daemon/daemon-worker-client.js +8 -0
  34. package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
  35. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  36. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  37. package/dist/modes/interactive/interactive-mode.js +29 -4
  38. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  39. package/docs/upstream-1.0.15.md +83 -0
  40. package/package.json +4 -4
@@ -3217,14 +3217,14 @@ export class AgentSession {
3217
3217
  this._assertCompactionOwner(owner);
3218
3218
  const compaction = owner.manager.bindCompactionSink();
3219
3219
  const captured = owner.requests.capture(compaction);
3220
- let branch;
3221
3220
  let preparation;
3221
+ let leafKind;
3222
3222
  try {
3223
- branch = await compaction.readBranch();
3224
- this._assertCompactionOwner(owner);
3225
- preparation = this.isStreaming
3226
- ? (await this._prepareCapturedCompaction(branch, settings, captured, compaction, owner)).preparation
3227
- : undefined;
3223
+ if (this.isStreaming) {
3224
+ const prepared = await this._prepareCapturedCompaction(settings, captured, compaction, owner);
3225
+ preparation = prepared.preparation;
3226
+ leafKind = prepared.leafKind;
3227
+ }
3228
3228
  }
3229
3229
  catch (error) {
3230
3230
  try {
@@ -3245,10 +3245,9 @@ export class AgentSession {
3245
3245
  reason: "no active turn; compaction can only be requested while a turn is running",
3246
3246
  };
3247
3247
  if (!preparation) {
3248
- const lastEntry = branch.at(-1);
3249
3248
  return {
3250
3249
  scheduled: false,
3251
- reason: lastEntry?.type === "compaction" ? "already compacted" : "session is too short to compact",
3250
+ reason: leafKind === "compaction" ? "already compacted" : "session is too short to compact",
3252
3251
  };
3253
3252
  }
3254
3253
  this._assertContextOptimizationAllowed();
@@ -6492,10 +6491,13 @@ export class AgentSession {
6492
6491
  actionId: action.id,
6493
6492
  submittedText: input.submitted?.text,
6494
6493
  };
6494
+ const clearedGoal = Boolean(this._goalState.objective) && this._parseGoalSlashCommand(input.text)?.kind === "clear";
6495
6495
  await this._handleGoalSlashCommand(input.text, input.images, goalOrigin);
6496
6496
  resultText = this._goalState.objective
6497
6497
  ? `Goal ${this._goalState.status}: ${this._goalState.objective}`
6498
- : "No active goal.";
6498
+ : clearedGoal
6499
+ ? "Goal cleared."
6500
+ : "No active goal.";
6499
6501
  break;
6500
6502
  }
6501
6503
  case "autonomous":
@@ -7786,14 +7788,12 @@ export class AgentSession {
7786
7788
  const semanticEdges = owner.semanticEdges;
7787
7789
  compaction = owner.manager.bindCompactionSink();
7788
7790
  requests = owner.requests.capture(compaction);
7789
- const pathEntries = await compaction.readBranch();
7790
7791
  this._assertCompactionOwner(owner);
7791
7792
  const { apiKey, headers } = await this._getRequiredRequestAuth(model);
7792
7793
  this._assertCompactionOwner(owner);
7793
7794
  committed = await this._performCompaction({
7794
7795
  model,
7795
7796
  thinkingLevel,
7796
- pathEntries,
7797
7797
  settings,
7798
7798
  requests,
7799
7799
  compaction,
@@ -7887,33 +7887,47 @@ export class AgentSession {
7887
7887
  }
7888
7888
  }
7889
7889
  /** A private compiled context keeps extension summary edits separate from retained source recipes. */
7890
- async _prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, capacity) {
7890
+ async _prepareCapturedCompaction(settings, requests, compaction, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, capacity) {
7891
7891
  this._assertCompactionOwner(owner);
7892
7892
  const limits = this.settingsManager.getCanonicalContextLimits();
7893
7893
  const resource = this._captureKernelResource();
7894
7894
  const source = await compaction.source;
7895
7895
  this._assertCompactionOwner(owner);
7896
- if (!source.persistent)
7896
+ if (!source.persistent) {
7897
+ const pathEntries = await compaction.readBranch();
7898
+ this._assertCompactionOwner(owner);
7897
7899
  return {
7898
7900
  preparation: prepareCompaction(pathEntries, settings, allowShortSession),
7901
+ pathEntries,
7902
+ leafKind: pathEntries.at(-1)?.type,
7899
7903
  maxSourceBytes: limits.maxSourceBytes,
7900
7904
  };
7905
+ }
7901
7906
  return requests.readHistory(async (view) => {
7902
7907
  const messages = await new CanonicalContextCompiler().compile(view, limits, undefined, {}, resource, this._initialContextMode, false, "read");
7903
7908
  this._assertCompactionOwner(owner);
7904
7909
  const context = getCanonicalEpochContext(messages);
7905
- if (context.checkpoint?.includeSummary && pathEntries.at(-1)?.type === "compaction")
7906
- return { preparation: undefined, maxSourceBytes: limits.maxSourceBytes };
7910
+ const entryIds = context.references.map((ref) => ref?.ref.entryId);
7911
+ const selected = await compaction.readCompactionEntries(entryIds.filter((id) => id !== undefined));
7912
+ this._assertCompactionOwner(owner);
7913
+ const pathEntries = selected.entries;
7914
+ if (context.checkpoint?.includeSummary && selected.leafKind === "compaction")
7915
+ return {
7916
+ preparation: undefined,
7917
+ pathEntries,
7918
+ leafKind: selected.leafKind,
7919
+ maxSourceBytes: limits.maxSourceBytes,
7920
+ };
7907
7921
  const authorization = getRecoveryCompactionAuthorization(capacity);
7908
7922
  const boundary = canonicalRecoveryBoundary(messages, authorization);
7909
- const preparation = budgetPressure || context.checkpoint || boundary
7910
- ? prepareViewCompaction(messages, context.references.map((ref) => ref?.ref.entryId), pathEntries, settings, boundary, allowShortSession, budgetPressure)
7911
- : prepareCompaction(pathEntries, settings, allowShortSession);
7923
+ const preparation = prepareViewCompaction(messages, entryIds, pathEntries, settings, boundary, allowShortSession, budgetPressure, selected.suffixAnchors);
7912
7924
  // Refuse unsupported public data or open groups before starting the summary model call.
7913
7925
  if (preparation)
7914
7926
  prepareRecoveryCompaction(messages, preparation.firstKeptEntryId, limits.maxSourceBytes, authorization);
7915
7927
  return {
7916
7928
  preparation,
7929
+ pathEntries,
7930
+ leafKind: selected.leafKind,
7917
7931
  messages,
7918
7932
  resource: context.resourceRevision !== undefined ? resource : undefined,
7919
7933
  maxSourceBytes: limits.maxSourceBytes,
@@ -7926,15 +7940,15 @@ export class AgentSession {
7926
7940
  * Error("Compaction cancelled") on abort or extension cancel.
7927
7941
  */
7928
7942
  async _performCompaction(options) {
7929
- const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges, pathEntries, settings, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, } = options;
7930
- const prepared = await this._prepareCapturedCompaction(pathEntries, settings, requests, compaction, owner, allowShortSession, budgetPressure, options.capacity);
7943
+ const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges, settings, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, } = options;
7944
+ const prepared = await this._prepareCapturedCompaction(settings, requests, compaction, owner, allowShortSession, budgetPressure, options.capacity);
7931
7945
  this._assertCompactionOwner(owner);
7932
7946
  if (prepared.resource)
7933
7947
  assertResourceCurrent(prepared.resource);
7934
7948
  const preparation = prepared.preparation;
7949
+ const pathEntries = prepared.pathEntries;
7935
7950
  if (!preparation) {
7936
- const lastEntry = pathEntries[pathEntries.length - 1];
7937
- if (lastEntry?.type === "compaction") {
7951
+ if (prepared.leafKind === "compaction") {
7938
7952
  throw new CompactionSkippedError("Already compacted");
7939
7953
  }
7940
7954
  throw new CompactionSkippedError("Session is too short to compact — try again once it grows");
@@ -9366,7 +9380,6 @@ export class AgentSession {
9366
9380
  const semanticEdges = owner.semanticEdges;
9367
9381
  compaction = owner.manager.bindCompactionSink();
9368
9382
  requests = owner.requests.capture(compaction);
9369
- const pathEntries = await compaction.readBranch();
9370
9383
  this._assertCompactionOwner(owner);
9371
9384
  const authResult = model ? await this._modelRegistry.getApiKeyAndHeaders(model) : undefined;
9372
9385
  this._assertCompactionOwner(owner);
@@ -9385,7 +9398,6 @@ export class AgentSession {
9385
9398
  committed = await this._performCompaction({
9386
9399
  model,
9387
9400
  thinkingLevel,
9388
- pathEntries,
9389
9401
  settings,
9390
9402
  requests,
9391
9403
  compaction,