@ponythewhite/base-context 1.0.8 → 1.0.10

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 (50) hide show
  1. package/CHANGELOG.md +13 -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-IGMJH2MU.js → bundled-modules-MX6YNAM2.js} +2 -2
  6. package/dist/bundle/{chunk-EXEFSSF4.js → chunk-CDXQNS5P.js} +176 -37
  7. package/dist/bundle/{chunk-RVJVXZCS.js → chunk-UHLGPYMI.js} +20 -40
  8. package/dist/bundle/{cli-main-BUK7QTHO.js → cli-main-D7W3WWCV.js} +2 -2
  9. package/dist/bundle/cli.js +1 -1
  10. package/dist/bundle/{main-2FWHT2WZ.js → main-5J3QBZ5Y.js} +2 -2
  11. package/dist/core/agent-session.d.ts +3 -0
  12. package/dist/core/agent-session.d.ts.map +1 -1
  13. package/dist/core/agent-session.js +48 -5
  14. package/dist/core/agent-session.js.map +1 -1
  15. package/dist/core/canonical-context.d.ts.map +1 -1
  16. package/dist/core/canonical-context.js +115 -30
  17. package/dist/core/canonical-context.js.map +1 -1
  18. package/dist/core/context-epoch.d.ts +14 -3
  19. package/dist/core/context-epoch.d.ts.map +1 -1
  20. package/dist/core/context-epoch.js +5 -1
  21. package/dist/core/context-epoch.js.map +1 -1
  22. package/dist/core/inference-coordinator.d.ts +1 -1
  23. package/dist/core/inference-coordinator.d.ts.map +1 -1
  24. package/dist/core/inference-coordinator.js +2 -2
  25. package/dist/core/inference-coordinator.js.map +1 -1
  26. package/dist/core/public-context.d.ts.map +1 -1
  27. package/dist/core/public-context.js +20 -8
  28. package/dist/core/public-context.js.map +1 -1
  29. package/dist/core/request-view-selection.d.ts +4 -2
  30. package/dist/core/request-view-selection.d.ts.map +1 -1
  31. package/dist/core/request-view-selection.js +7 -4
  32. package/dist/core/request-view-selection.js.map +1 -1
  33. package/dist/core/session-manager.d.ts +2 -0
  34. package/dist/core/session-manager.d.ts.map +1 -1
  35. package/dist/core/session-manager.js +38 -13
  36. package/dist/core/session-manager.js.map +1 -1
  37. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  38. package/dist/modes/daemon/daemon-mode.js +15 -30
  39. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  40. package/dist/modes/daemon/daemon-socket.d.ts +5 -0
  41. package/dist/modes/daemon/daemon-socket.d.ts.map +1 -1
  42. package/dist/modes/daemon/daemon-socket.js +19 -0
  43. package/dist/modes/daemon/daemon-socket.js.map +1 -1
  44. package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
  45. package/dist/modes/daemon/daemon-supervisor.js +6 -7
  46. package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
  47. package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
  48. package/dist/modes/daemon/daemon-worker-client.js +5 -5
  49. package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
  50. package/package.json +4 -4
@@ -140,6 +140,7 @@ import {
140
140
  clearOrphanProcessJournal,
141
141
  clippedFullscreenDockHeight,
142
142
  cloneUsage,
143
+ closeDaemonServer,
143
144
  closeWatcher,
144
145
  collectDaemonClientEnv,
145
146
  collectDaemonLaunchEnv,
@@ -348,7 +349,7 @@ import {
348
349
  watchWithErrorHandler,
349
350
  workerRosterEntryFromSummary,
350
351
  wrapTextWithAnsi
351
- } from "./chunk-EXEFSSF4.js";
352
+ } from "./chunk-CDXQNS5P.js";
352
353
  import {
353
354
  array,
354
355
  boolean,
@@ -17361,16 +17362,14 @@ var DaemonWorkerClient = class {
17361
17362
  }, timeoutMs);
17362
17363
  this.pending.set(id, { resolve: resolve26, reject, timeout });
17363
17364
  });
17364
- try {
17365
- await this.channel.send({ kind: "command", requestId: id, commandType: command.type }, Buffer.from(serializeJsonLine(fullCommand)));
17366
- } catch (error) {
17365
+ void this.channel.send({ kind: "command", requestId: id, commandType: command.type }, Buffer.from(serializeJsonLine(fullCommand))).catch((error) => {
17367
17366
  const pending = this.pending.get(id);
17368
17367
  if (pending) {
17369
17368
  clearTimeout(pending.timeout);
17370
17369
  this.pending.delete(id);
17371
17370
  pending.reject(error instanceof Error ? error : new Error(String(error)));
17372
17371
  }
17373
- }
17372
+ });
17374
17373
  return response;
17375
17374
  }
17376
17375
  handleFrame(frame) {
@@ -63467,7 +63466,7 @@ var AgentDaemon = class {
63467
63466
  });
63468
63467
  }
63469
63468
  if (streamsSnapshot) {
63470
- const snapshotId = `${state.activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
63469
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
63471
63470
  let transcript;
63472
63471
  try {
63473
63472
  transcript = createSnapshotTranscriptChunks({
@@ -64445,16 +64444,14 @@ var AgentDaemon = class {
64445
64444
  }
64446
64445
  async createAttachResult(client, state, command) {
64447
64446
  const snapshot = await this.createSessionSnapshot(state);
64447
+ const { lastEventSequence, lastEventCursor } = snapshot;
64448
64448
  const replay = command.resumeCursor?.activeSessionId && command.resumeCursor.activeSessionId !== state.activeSessionId ? {
64449
64449
  status: "unavailable",
64450
64450
  fromSequence: "sequence" in command.resumeCursor ? command.resumeCursor.sequence : command.resumeCursor.eventSequence,
64451
- toSequence: state.lastEventSequence,
64452
- toCursor: {
64453
- generation: state.eventGeneration,
64454
- sequence: state.lastEventSequence
64455
- },
64451
+ toSequence: lastEventSequence,
64452
+ toCursor: lastEventCursor,
64456
64453
  reason: "resume_cursor_session_mismatch"
64457
- } : createDaemonReplayInfo(command.resumeCursor, state.lastEventSequence, state.eventGeneration);
64454
+ } : createDaemonReplayInfo(command.resumeCursor, lastEventSequence, lastEventCursor?.generation);
64458
64455
  const capabilities = daemonClientCapabilitiesForSession(client, state.activeSessionId);
64459
64456
  const slim = capabilities.has("slim_attach");
64460
64457
  return {
@@ -64463,11 +64460,8 @@ var AgentDaemon = class {
64463
64460
  ...slim ? {} : { state: snapshot.summary, messages: snapshot.messages },
64464
64461
  snapshot,
64465
64462
  replay,
64466
- lastEventSequence: state.lastEventSequence,
64467
- lastEventCursor: {
64468
- generation: state.eventGeneration,
64469
- sequence: state.lastEventSequence
64470
- },
64463
+ lastEventSequence,
64464
+ lastEventCursor,
64471
64465
  client: {
64472
64466
  id: client.id,
64473
64467
  capabilities: [...capabilities]
@@ -65780,9 +65774,8 @@ Use prime_context read/search with selected lines or a query.`;
65780
65774
  }
65781
65775
  }
65782
65776
  beginReplacementSnapshot(client, state, message) {
65783
- const snapshotId = `${state.activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
65784
65777
  const snapshotSignal = markClientSnapshotStreaming(client, state.activeSessionId);
65785
- void this.prepareReplacementSnapshot(client, state, message, snapshotId, snapshotSignal).catch((error) => {
65778
+ void this.prepareReplacementSnapshot(client, state, message, snapshotSignal).catch((error) => {
65786
65779
  finishClientSnapshotStreaming(client, state.activeSessionId);
65787
65780
  this.log(`could not prepare replacement snapshot: ${String(error)}`);
65788
65781
  if (!client.socket.destroyed && this.sessions.get(state.activeSessionId) === state) {
@@ -65793,7 +65786,7 @@ Use prime_context read/search with selected lines or a query.`;
65793
65786
  }
65794
65787
  });
65795
65788
  }
65796
- async prepareReplacementSnapshot(client, state, message, snapshotId, snapshotSignal) {
65789
+ async prepareReplacementSnapshot(client, state, message, snapshotSignal) {
65797
65790
  const result = await this.createAttachResult(client, state, {
65798
65791
  type: "attach",
65799
65792
  activeSessionId: state.activeSessionId
@@ -65805,6 +65798,7 @@ Use prime_context read/search with selected lines or a query.`;
65805
65798
  }
65806
65799
  return;
65807
65800
  }
65801
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
65808
65802
  const transcript = createSnapshotTranscriptChunks({
65809
65803
  activeSessionId: state.activeSessionId,
65810
65804
  snapshotId,
@@ -66147,10 +66141,10 @@ Use prime_context read/search with selected lines or a query.`;
66147
66141
  state: result.snapshot.state,
66148
66142
  messages: [],
66149
66143
  snapshotFollows: true,
66150
- meta: createDaemonEventMeta(activeSessionId, state.lastEventSequence, void 0, state.eventGeneration)
66144
+ meta: createDaemonEventMeta(activeSessionId, result.lastEventSequence, void 0, result.lastEventCursor?.generation)
66151
66145
  });
66152
66146
  }
66153
- const snapshotId = `${activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
66147
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
66154
66148
  const snapshotSignal = markClientSnapshotStreaming(client, activeSessionId);
66155
66149
  let transcript;
66156
66150
  try {
@@ -66177,7 +66171,7 @@ Use prime_context read/search with selected lines or a query.`;
66177
66171
  }, transcript, purpose === "replacement" ? "replacement" : "catchup", snapshotSignal, true);
66178
66172
  continue;
66179
66173
  }
66180
- const meta = createDaemonEventMeta(activeSessionId, state.lastEventSequence, void 0, state.eventGeneration);
66174
+ const meta = createDaemonEventMeta(activeSessionId, result.lastEventSequence, void 0, result.lastEventCursor?.generation);
66181
66175
  const catchup = purpose === "replacement" ? {
66182
66176
  type: "session_replaced",
66183
66177
  activeSessionId,
@@ -66341,17 +66335,7 @@ Use prime_context read/search with selected lines or a query.`;
66341
66335
  shutdownFailure = true;
66342
66336
  this.log(`RLM journal shutdown failed: ${error instanceof Error ? error.message : String(error)}`);
66343
66337
  }
66344
- for (const client of this.clients) {
66345
- client.detachInput();
66346
- client.socket.end();
66347
- }
66348
- await new Promise((resolveClose) => {
66349
- if (!this.server) {
66350
- resolveClose();
66351
- return;
66352
- }
66353
- this.server.close(() => resolveClose());
66354
- });
66338
+ await closeDaemonServer(this.server, this.clients);
66355
66339
  this.cleanupSocketPath();
66356
66340
  process.exit(exitCode || (shutdownFailure ? 1 : 0));
66357
66341
  }
@@ -68077,7 +68061,7 @@ var DaemonSupervisor = class {
68077
68061
  this.write(client, failure(command.id, command.type, "Daemon is preparing an update restart"));
68078
68062
  return;
68079
68063
  }
68080
- if (mutation && !UPDATE_RESTART_DRAIN_COMMANDS.has(command.type)) {
68064
+ if (mutation && command.type !== "release_session_input_pause" && !UPDATE_RESTART_DRAIN_COMMANDS.has(command.type)) {
68081
68065
  const idleEvictionFence = this.idleEvictionFence;
68082
68066
  if (idleEvictionFence) {
68083
68067
  await idleEvictionFence;
@@ -72477,11 +72461,7 @@ var DaemonSupervisor = class {
72477
72461
  }
72478
72462
  }
72479
72463
  await this.catalog.stop();
72480
- for (const client of this.clients) {
72481
- client.detachInput();
72482
- client.socket.end();
72483
- }
72484
- await new Promise((resolveClose) => this.server?.close(() => resolveClose()) ?? resolveClose());
72464
+ await closeDaemonServer(this.server, this.clients);
72485
72465
  await this.runCleanupStep("daemon socket", () => this.cleanupSocket());
72486
72466
  await this.runCleanupStep("supervisor cache", () => {
72487
72467
  rmSync13(this.snapshotCacheRoot, { recursive: true, force: true });
@@ -5,7 +5,7 @@ import {
5
5
  isOwnedSessionWorkerProcess,
6
6
  maybeRunOwnedSessionWorkerFrontend,
7
7
  maybeStartDaemonEarly
8
- } from "./chunk-EXEFSSF4.js";
8
+ } from "./chunk-CDXQNS5P.js";
9
9
  import {
10
10
  APP_NAME
11
11
  } from "./chunk-2IPDSTDR.js";
@@ -39,7 +39,7 @@ async function runCli() {
39
39
  }
40
40
  const [{ EnvHttpProxyAgent, setGlobalDispatcher }, { main }] = await Promise.all([
41
41
  import("undici"),
42
- import("./main-2FWHT2WZ.js")
42
+ import("./main-5J3QBZ5Y.js")
43
43
  ]);
44
44
  setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
45
45
  try {
@@ -52,6 +52,6 @@ var supported = assertNodeVersion({
52
52
  exit: (code) => process.exit(code)
53
53
  });
54
54
  if (supported) {
55
- const { runCli } = await import("./cli-main-BUK7QTHO.js");
55
+ const { runCli } = await import("./cli-main-D7W3WWCV.js");
56
56
  await runCli();
57
57
  }
@@ -17,8 +17,8 @@ import {
17
17
  shouldUseDaemonClientRuntime,
18
18
  shouldUseDaemonInteractive,
19
19
  shouldUseEphemeralSessionManagerForDaemonInteractive
20
- } from "./chunk-RVJVXZCS.js";
21
- import "./chunk-EXEFSSF4.js";
20
+ } from "./chunk-UHLGPYMI.js";
21
+ import "./chunk-CDXQNS5P.js";
22
22
  import "./chunk-CFNASUYO.js";
23
23
  import "./chunk-QKIFBA7N.js";
24
24
  import "./chunk-2IPDSTDR.js";
@@ -381,6 +381,7 @@ export declare class AgentSession {
381
381
  readonly runtimeServices: SessionRuntimeServices;
382
382
  private readonly _contextCompiler;
383
383
  private _failedAutomaticCompaction?;
384
+ private _failedThresholdCompaction?;
384
385
  private readonly _contextEpochsEnabled;
385
386
  private readonly _initialContextMode;
386
387
  private _contextMode;
@@ -687,6 +688,8 @@ export declare class AgentSession {
687
688
  private _runBackgroundPlan;
688
689
  private _runSerializedRefine;
689
690
  private _getLatestCompactionTimestamp;
691
+ private _thresholdCompactionConfiguration;
692
+ private _hasFailedThresholdCompaction;
690
693
  private _thresholdCompactionNeeded;
691
694
  private _captureThresholdAutonomousOwner;
692
695
  private _snapshotAutonomousRuntimeState;