@ponythewhite/base-context 1.0.13 → 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 (83) hide show
  1. package/CHANGELOG.md +18 -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/amazon-bedrock.js +3 -3
  6. package/dist/bundle/{anthropic-BJVPUMPB.js → anthropic-AXUXEET7.js} +1 -1
  7. package/dist/bundle/{azure-openai-responses-ERRMAXK6.js → azure-openai-responses-J3NTJKEO.js} +2 -2
  8. package/dist/bundle/{bundled-modules-URKVA3UB.js → bundled-modules-O67MEO74.js} +5 -5
  9. package/dist/bundle/{chunk-FOGKLC7V.js → chunk-72LSQYUV.js} +1 -1
  10. package/dist/bundle/{chunk-TXVF6Q5H.js → chunk-DGO66I3L.js} +87 -51
  11. package/dist/bundle/{chunk-MUFZODP5.js → chunk-EGFIZABJ.js} +1 -1
  12. package/dist/bundle/{chunk-AEMRBMI2.js → chunk-IEM74GZ5.js} +9 -9
  13. package/dist/bundle/{chunk-25VYRAC6.js → chunk-JKKXN6JE.js} +72 -0
  14. package/dist/bundle/{chunk-TKOBEJ5E.js → chunk-RQFC34FM.js} +151 -51
  15. package/dist/bundle/{chunk-Q6UAHLII.js → chunk-V6LOBH6X.js} +2 -2
  16. package/dist/bundle/{cli-main-ZTJM5EEH.js → cli-main-2RER6PBE.js} +4 -4
  17. package/dist/bundle/cli.js +1 -1
  18. package/dist/bundle/{google-4GA4YMUX.js → google-QLKV2ZLC.js} +2 -2
  19. package/dist/bundle/{google-vertex-7AMALD7D.js → google-vertex-UGLUZV6B.js} +2 -2
  20. package/dist/bundle/{main-53I74INO.js → main-YERLD3T4.js} +5 -5
  21. package/dist/bundle/{mistral-74BXMNRM.js → mistral-2ITSLHYF.js} +1 -1
  22. package/dist/bundle/{openai-codex-responses-COXNC4IH.js → openai-codex-responses-FRREQXS3.js} +5 -4
  23. package/dist/bundle/{openai-completions-BCSA5Q6S.js → openai-completions-HF6UPPLW.js} +1 -1
  24. package/dist/bundle/{openai-responses-ONCIZSJS.js → openai-responses-LRTMBDFW.js} +2 -2
  25. package/dist/core/agent-session.d.ts.map +1 -1
  26. package/dist/core/agent-session.js +42 -25
  27. package/dist/core/agent-session.js.map +1 -1
  28. package/dist/core/autonomous.d.ts +2 -0
  29. package/dist/core/autonomous.d.ts.map +1 -1
  30. package/dist/core/autonomous.js +4 -0
  31. package/dist/core/autonomous.js.map +1 -1
  32. package/dist/core/canonical-context.d.ts.map +1 -1
  33. package/dist/core/canonical-context.js +7 -0
  34. package/dist/core/canonical-context.js.map +1 -1
  35. package/dist/core/compaction/compaction.d.ts +1 -1
  36. package/dist/core/compaction/compaction.d.ts.map +1 -1
  37. package/dist/core/compaction/compaction.js +11 -9
  38. package/dist/core/compaction/compaction.js.map +1 -1
  39. package/dist/core/inference-coordinator.d.ts.map +1 -1
  40. package/dist/core/inference-coordinator.js +13 -2
  41. package/dist/core/inference-coordinator.js.map +1 -1
  42. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  43. package/dist/core/kernel/repl-manager.js +5 -0
  44. package/dist/core/kernel/repl-manager.js.map +1 -1
  45. package/dist/core/public-context.d.ts.map +1 -1
  46. package/dist/core/public-context.js +2 -0
  47. package/dist/core/public-context.js.map +1 -1
  48. package/dist/core/session-manager.d.ts +8 -0
  49. package/dist/core/session-manager.d.ts.map +1 -1
  50. package/dist/core/session-manager.js +57 -0
  51. package/dist/core/session-manager.js.map +1 -1
  52. package/dist/core/view-units.d.ts.map +1 -1
  53. package/dist/core/view-units.js +3 -0
  54. package/dist/core/view-units.js.map +1 -1
  55. package/dist/main.d.ts.map +1 -1
  56. package/dist/main.js +1 -1
  57. package/dist/main.js.map +1 -1
  58. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  59. package/dist/modes/daemon/daemon-mode.js +21 -20
  60. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  61. package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
  62. package/dist/modes/daemon/daemon-supervisor.js +11 -5
  63. package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
  64. package/dist/modes/daemon/daemon-worker-client.d.ts +1 -0
  65. package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
  66. package/dist/modes/daemon/daemon-worker-client.js +8 -0
  67. package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
  68. package/dist/modes/daemon/daemon-worker-protocol.d.ts +3 -0
  69. package/dist/modes/daemon/daemon-worker-protocol.d.ts.map +1 -1
  70. package/dist/modes/daemon/daemon-worker-protocol.js +2 -0
  71. package/dist/modes/daemon/daemon-worker-protocol.js.map +1 -1
  72. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  73. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  74. package/dist/modes/interactive/interactive-mode.js +29 -4
  75. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  76. package/dist/modes/print-mode.d.ts.map +1 -1
  77. package/dist/modes/print-mode.js +24 -21
  78. package/dist/modes/print-mode.js.map +1 -1
  79. package/docs/json.md +14 -1
  80. package/docs/long-running-agents.md +23 -2
  81. package/docs/providers.md +17 -0
  82. package/docs/upstream-1.0.15.md +83 -0
  83. package/package.json +4 -4
@@ -12,7 +12,7 @@ import { sleep } from "../utils/sleep.js";
12
12
  import { AGENT_MESSAGE_CUSTOM_TYPE, AGENT_MESSAGE_RECEIVED_PREVIEW_LABEL, AGENT_MESSAGE_SKILL_NAME, assertAgentMessageQueueCapacity, assertAgentSessionNameAvailable, assertDirectAgentMessageTarget, createAgentMessageHostHandlers, DEFAULT_AGENT_MESSAGE_MAX_PENDING_PER_SESSION, formatAgentSessionNameUnavailable, isAgentSessionMessage, isAgentSessionMessagePrompt, normalizeAgentSessionMessage, parseAgentSessionMessagePromptId, startsAgentRun, } from "./agent-messages.js";
13
13
  import { AGENT_OBSERVE_SKILL_NAME, createAgentObserveHostHandlers, normalizeObserveLimit, normalizeObserveMaxChars, ORCHESTRATION_HEARTBEAT_SKILL_NAME, } from "./agent-observe.js";
14
14
  import { addLoginGuidanceToAuthError, formatAuthenticationFailedMessage, formatNoApiKeyFoundMessage, formatNoModelSelectedMessage, isLikelyAuthenticationError, } from "./auth-guidance.js";
15
- import { addAutonomousContinuation, addAutonomousUsage, autonomousStatus, createAutonomousRuntimeState, nextAutonomousContinuation, refreshAutonomousQualityGates, setAutonomousEnabled, } from "./autonomous.js";
15
+ import { addAutonomousContinuation, addAutonomousUsage, autonomousRunLimitReason, 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
18
  import { CanonicalContextCompiler, canonicalRecoveryBoundary, getCanonicalEpochContext, getCanonicalMessageSource, getCanonicalViewSelectionSource, getCanonicalViewUnits, MissingRecoveryReplayContractError, prepareCanonicalEpoch, prepareContextModeEpoch, prepareRecoveryCompaction, readCanonicalContextMode, } from "./canonical-context.js";
@@ -2345,6 +2345,9 @@ export class AgentSession {
2345
2345
  "proceed");
2346
2346
  }
2347
2347
  async _getTurnOutcome(context, signal) {
2348
+ // Usage is recorded by message_end. Join it before admitting another native tool turn.
2349
+ if (this._autonomousState.enabled)
2350
+ await this._agentEventQueue;
2348
2351
  const sourceOwner = signal ? this._invocationCompactionOwner : this._captureCompactionOwner();
2349
2352
  if (!sourceOwner ||
2350
2353
  signal?.aborted ||
@@ -2371,6 +2374,8 @@ export class AgentSession {
2371
2374
  return { kind: "finish" };
2372
2375
  if (!current())
2373
2376
  return { kind: "cancelled" };
2377
+ if (this._autonomousState.enabled && autonomousRunLimitReason(this._autonomousState))
2378
+ return { kind: "finish" };
2374
2379
  try {
2375
2380
  if (await this._accountGoalUsageForAssistantMessage(context.message, goalOwner)) {
2376
2381
  this._assertGoalContinuationOwner(goalOwner);
@@ -3212,14 +3217,14 @@ export class AgentSession {
3212
3217
  this._assertCompactionOwner(owner);
3213
3218
  const compaction = owner.manager.bindCompactionSink();
3214
3219
  const captured = owner.requests.capture(compaction);
3215
- let branch;
3216
3220
  let preparation;
3221
+ let leafKind;
3217
3222
  try {
3218
- branch = await compaction.readBranch();
3219
- this._assertCompactionOwner(owner);
3220
- preparation = this.isStreaming
3221
- ? (await this._prepareCapturedCompaction(branch, settings, captured, compaction, owner)).preparation
3222
- : undefined;
3223
+ if (this.isStreaming) {
3224
+ const prepared = await this._prepareCapturedCompaction(settings, captured, compaction, owner);
3225
+ preparation = prepared.preparation;
3226
+ leafKind = prepared.leafKind;
3227
+ }
3223
3228
  }
3224
3229
  catch (error) {
3225
3230
  try {
@@ -3240,10 +3245,9 @@ export class AgentSession {
3240
3245
  reason: "no active turn; compaction can only be requested while a turn is running",
3241
3246
  };
3242
3247
  if (!preparation) {
3243
- const lastEntry = branch.at(-1);
3244
3248
  return {
3245
3249
  scheduled: false,
3246
- reason: lastEntry?.type === "compaction" ? "already compacted" : "session is too short to compact",
3250
+ reason: leafKind === "compaction" ? "already compacted" : "session is too short to compact",
3247
3251
  };
3248
3252
  }
3249
3253
  this._assertContextOptimizationAllowed();
@@ -6487,10 +6491,13 @@ export class AgentSession {
6487
6491
  actionId: action.id,
6488
6492
  submittedText: input.submitted?.text,
6489
6493
  };
6494
+ const clearedGoal = Boolean(this._goalState.objective) && this._parseGoalSlashCommand(input.text)?.kind === "clear";
6490
6495
  await this._handleGoalSlashCommand(input.text, input.images, goalOrigin);
6491
6496
  resultText = this._goalState.objective
6492
6497
  ? `Goal ${this._goalState.status}: ${this._goalState.objective}`
6493
- : "No active goal.";
6498
+ : clearedGoal
6499
+ ? "Goal cleared."
6500
+ : "No active goal.";
6494
6501
  break;
6495
6502
  }
6496
6503
  case "autonomous":
@@ -7781,14 +7788,12 @@ export class AgentSession {
7781
7788
  const semanticEdges = owner.semanticEdges;
7782
7789
  compaction = owner.manager.bindCompactionSink();
7783
7790
  requests = owner.requests.capture(compaction);
7784
- const pathEntries = await compaction.readBranch();
7785
7791
  this._assertCompactionOwner(owner);
7786
7792
  const { apiKey, headers } = await this._getRequiredRequestAuth(model);
7787
7793
  this._assertCompactionOwner(owner);
7788
7794
  committed = await this._performCompaction({
7789
7795
  model,
7790
7796
  thinkingLevel,
7791
- pathEntries,
7792
7797
  settings,
7793
7798
  requests,
7794
7799
  compaction,
@@ -7882,33 +7887,47 @@ export class AgentSession {
7882
7887
  }
7883
7888
  }
7884
7889
  /** A private compiled context keeps extension summary edits separate from retained source recipes. */
7885
- 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) {
7886
7891
  this._assertCompactionOwner(owner);
7887
7892
  const limits = this.settingsManager.getCanonicalContextLimits();
7888
7893
  const resource = this._captureKernelResource();
7889
7894
  const source = await compaction.source;
7890
7895
  this._assertCompactionOwner(owner);
7891
- if (!source.persistent)
7896
+ if (!source.persistent) {
7897
+ const pathEntries = await compaction.readBranch();
7898
+ this._assertCompactionOwner(owner);
7892
7899
  return {
7893
7900
  preparation: prepareCompaction(pathEntries, settings, allowShortSession),
7901
+ pathEntries,
7902
+ leafKind: pathEntries.at(-1)?.type,
7894
7903
  maxSourceBytes: limits.maxSourceBytes,
7895
7904
  };
7905
+ }
7896
7906
  return requests.readHistory(async (view) => {
7897
7907
  const messages = await new CanonicalContextCompiler().compile(view, limits, undefined, {}, resource, this._initialContextMode, false, "read");
7898
7908
  this._assertCompactionOwner(owner);
7899
7909
  const context = getCanonicalEpochContext(messages);
7900
- if (context.checkpoint?.includeSummary && pathEntries.at(-1)?.type === "compaction")
7901
- 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
+ };
7902
7921
  const authorization = getRecoveryCompactionAuthorization(capacity);
7903
7922
  const boundary = canonicalRecoveryBoundary(messages, authorization);
7904
- const preparation = budgetPressure || context.checkpoint || boundary
7905
- ? prepareViewCompaction(messages, context.references.map((ref) => ref?.ref.entryId), pathEntries, settings, boundary, allowShortSession, budgetPressure)
7906
- : prepareCompaction(pathEntries, settings, allowShortSession);
7923
+ const preparation = prepareViewCompaction(messages, entryIds, pathEntries, settings, boundary, allowShortSession, budgetPressure, selected.suffixAnchors);
7907
7924
  // Refuse unsupported public data or open groups before starting the summary model call.
7908
7925
  if (preparation)
7909
7926
  prepareRecoveryCompaction(messages, preparation.firstKeptEntryId, limits.maxSourceBytes, authorization);
7910
7927
  return {
7911
7928
  preparation,
7929
+ pathEntries,
7930
+ leafKind: selected.leafKind,
7912
7931
  messages,
7913
7932
  resource: context.resourceRevision !== undefined ? resource : undefined,
7914
7933
  maxSourceBytes: limits.maxSourceBytes,
@@ -7921,15 +7940,15 @@ export class AgentSession {
7921
7940
  * Error("Compaction cancelled") on abort or extension cancel.
7922
7941
  */
7923
7942
  async _performCompaction(options) {
7924
- const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges, pathEntries, settings, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, } = options;
7925
- 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);
7926
7945
  this._assertCompactionOwner(owner);
7927
7946
  if (prepared.resource)
7928
7947
  assertResourceCurrent(prepared.resource);
7929
7948
  const preparation = prepared.preparation;
7949
+ const pathEntries = prepared.pathEntries;
7930
7950
  if (!preparation) {
7931
- const lastEntry = pathEntries[pathEntries.length - 1];
7932
- if (lastEntry?.type === "compaction") {
7951
+ if (prepared.leafKind === "compaction") {
7933
7952
  throw new CompactionSkippedError("Already compacted");
7934
7953
  }
7935
7954
  throw new CompactionSkippedError("Session is too short to compact — try again once it grows");
@@ -9361,7 +9380,6 @@ export class AgentSession {
9361
9380
  const semanticEdges = owner.semanticEdges;
9362
9381
  compaction = owner.manager.bindCompactionSink();
9363
9382
  requests = owner.requests.capture(compaction);
9364
- const pathEntries = await compaction.readBranch();
9365
9383
  this._assertCompactionOwner(owner);
9366
9384
  const authResult = model ? await this._modelRegistry.getApiKeyAndHeaders(model) : undefined;
9367
9385
  this._assertCompactionOwner(owner);
@@ -9380,7 +9398,6 @@ export class AgentSession {
9380
9398
  committed = await this._performCompaction({
9381
9399
  model,
9382
9400
  thinkingLevel,
9383
- pathEntries,
9384
9401
  settings,
9385
9402
  requests,
9386
9403
  compaction,