@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
@@ -50,7 +50,7 @@ import { DaemonRlmCapacityClient } from "./daemon-rlm-capacity.js";
50
50
  import { getDaemonRuntimeIdentity } from "./daemon-runtime-identity.js";
51
51
  import { buildRlmChildSnapshots, buildSessionList, classifySessionRosterStatus, hasLiveSessionWork, inactiveLifecycleForSession, scheduledJobRegistrations, snapshotActiveSessionSummary, summaryForActiveSession, } from "./daemon-session-list.js";
52
52
  import { DaemonSessionSummarizer } from "./daemon-session-summarizer.js";
53
- import { cleanupDaemonSocketPath, defaultDaemonSocketPath, getDaemonSocketIdentity, normalizeSocketPath, prepareDaemonSocketPath, restrictDaemonSocketPath, } from "./daemon-socket.js";
53
+ import { cleanupDaemonSocketPath, closeDaemonServer, defaultDaemonSocketPath, getDaemonSocketIdentity, normalizeSocketPath, prepareDaemonSocketPath, restrictDaemonSocketPath, } from "./daemon-socket.js";
54
54
  import { assertDaemonSupervisorOwnerCurrent, isDaemonShutdownAdmissionActive } from "./daemon-supervisor-ownership.js";
55
55
  import { DAEMON_WORKER_ACTIVE_SESSION_ID_ENV, DAEMON_WORKER_PEER_TRANSPORT_CAPABILITY, DAEMON_WORKER_RECOVERY_JOURNAL_ENV, DAEMON_WORKER_ROLE_ENV, DAEMON_WORKER_ROSTER_CAPABILITY, DAEMON_WORKER_SUPERVISOR_SOCKET_ENV, DAEMON_WORKER_TOKEN_ENV, isDaemonWorkerFrameHeader, ROSTER_HEARTBEAT_INTERVAL_MS, SESSION_LEASE_OWNER_ID_ENV, SESSION_LEASES_ENABLED_ENV, } from "./daemon-worker-protocol.js";
56
56
  import { MutationDrainLatch } from "./mutation-drain-latch.js";
@@ -3520,7 +3520,7 @@ export class AgentDaemon {
3520
3520
  });
3521
3521
  }
3522
3522
  if (streamsSnapshot) {
3523
- const snapshotId = `${state.activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
3523
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
3524
3524
  let transcript;
3525
3525
  try {
3526
3526
  transcript = createSnapshotTranscriptChunks({
@@ -4541,20 +4541,18 @@ export class AgentDaemon {
4541
4541
  }
4542
4542
  async createAttachResult(client, state, command) {
4543
4543
  const snapshot = await this.createSessionSnapshot(state);
4544
+ const { lastEventSequence, lastEventCursor } = snapshot;
4544
4545
  const replay = command.resumeCursor?.activeSessionId && command.resumeCursor.activeSessionId !== state.activeSessionId
4545
4546
  ? {
4546
4547
  status: "unavailable",
4547
4548
  fromSequence: "sequence" in command.resumeCursor
4548
4549
  ? command.resumeCursor.sequence
4549
4550
  : command.resumeCursor.eventSequence,
4550
- toSequence: state.lastEventSequence,
4551
- toCursor: {
4552
- generation: state.eventGeneration,
4553
- sequence: state.lastEventSequence,
4554
- },
4551
+ toSequence: lastEventSequence,
4552
+ toCursor: lastEventCursor,
4555
4553
  reason: "resume_cursor_session_mismatch",
4556
4554
  }
4557
- : createDaemonReplayInfo(command.resumeCursor, state.lastEventSequence, state.eventGeneration);
4555
+ : createDaemonReplayInfo(command.resumeCursor, lastEventSequence, lastEventCursor?.generation);
4558
4556
  // Slim clients read summary/messages from the snapshot; duplicating them at
4559
4557
  // the top level would serialize the full history twice more per attach.
4560
4558
  const capabilities = daemonClientCapabilitiesForSession(client, state.activeSessionId);
@@ -4565,11 +4563,8 @@ export class AgentDaemon {
4565
4563
  ...(slim ? {} : { state: snapshot.summary, messages: snapshot.messages }),
4566
4564
  snapshot,
4567
4565
  replay,
4568
- lastEventSequence: state.lastEventSequence,
4569
- lastEventCursor: {
4570
- generation: state.eventGeneration,
4571
- sequence: state.lastEventSequence,
4572
- },
4566
+ lastEventSequence,
4567
+ lastEventCursor,
4573
4568
  client: {
4574
4569
  id: client.id,
4575
4570
  capabilities: [...capabilities],
@@ -6018,10 +6013,9 @@ Use prime_context read/search with selected lines or a query.`;
6018
6013
  }
6019
6014
  }
6020
6015
  beginReplacementSnapshot(client, state, message) {
6021
- const snapshotId = `${state.activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
6022
6016
  // Mark before the registry read so later events queue behind this snapshot.
6023
6017
  const snapshotSignal = markClientSnapshotStreaming(client, state.activeSessionId);
6024
- void this.prepareReplacementSnapshot(client, state, message, snapshotId, snapshotSignal).catch((error) => {
6018
+ void this.prepareReplacementSnapshot(client, state, message, snapshotSignal).catch((error) => {
6025
6019
  finishClientSnapshotStreaming(client, state.activeSessionId);
6026
6020
  this.log(`could not prepare replacement snapshot: ${String(error)}`);
6027
6021
  if (!client.socket.destroyed && this.sessions.get(state.activeSessionId) === state) {
@@ -6032,7 +6026,7 @@ Use prime_context read/search with selected lines or a query.`;
6032
6026
  }
6033
6027
  });
6034
6028
  }
6035
- async prepareReplacementSnapshot(client, state, message, snapshotId, snapshotSignal) {
6029
+ async prepareReplacementSnapshot(client, state, message, snapshotSignal) {
6036
6030
  const result = await this.createAttachResult(client, state, {
6037
6031
  type: "attach",
6038
6032
  activeSessionId: state.activeSessionId,
@@ -6044,6 +6038,7 @@ Use prime_context read/search with selected lines or a query.`;
6044
6038
  }
6045
6039
  return;
6046
6040
  }
6041
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
6047
6042
  const transcript = createSnapshotTranscriptChunks({
6048
6043
  activeSessionId: state.activeSessionId,
6049
6044
  snapshotId,
@@ -6404,10 +6399,10 @@ Use prime_context read/search with selected lines or a query.`;
6404
6399
  state: result.snapshot.state,
6405
6400
  messages: [],
6406
6401
  snapshotFollows: true,
6407
- meta: createDaemonEventMeta(activeSessionId, state.lastEventSequence, undefined, state.eventGeneration),
6402
+ meta: createDaemonEventMeta(activeSessionId, result.lastEventSequence, undefined, result.lastEventCursor?.generation),
6408
6403
  });
6409
6404
  }
6410
- const snapshotId = `${activeSessionId}-${state.eventGeneration}-${state.lastEventSequence}`;
6405
+ const snapshotId = `${result.activeSessionId}-${result.lastEventCursor?.generation}-${result.lastEventSequence}`;
6411
6406
  const snapshotSignal = markClientSnapshotStreaming(client, activeSessionId);
6412
6407
  let transcript;
6413
6408
  try {
@@ -6435,7 +6430,7 @@ Use prime_context read/search with selected lines or a query.`;
6435
6430
  }, transcript, purpose === "replacement" ? "replacement" : "catchup", snapshotSignal, true);
6436
6431
  continue;
6437
6432
  }
6438
- const meta = createDaemonEventMeta(activeSessionId, state.lastEventSequence, undefined, state.eventGeneration);
6433
+ const meta = createDaemonEventMeta(activeSessionId, result.lastEventSequence, undefined, result.lastEventCursor?.generation);
6439
6434
  const catchup = purpose === "replacement"
6440
6435
  ? {
6441
6436
  type: "session_replaced",
@@ -6613,17 +6608,7 @@ Use prime_context read/search with selected lines or a query.`;
6613
6608
  shutdownFailure = true;
6614
6609
  this.log(`RLM journal shutdown failed: ${error instanceof Error ? error.message : String(error)}`);
6615
6610
  }
6616
- for (const client of this.clients) {
6617
- client.detachInput();
6618
- client.socket.end();
6619
- }
6620
- await new Promise((resolveClose) => {
6621
- if (!this.server) {
6622
- resolveClose();
6623
- return;
6624
- }
6625
- this.server.close(() => resolveClose());
6626
- });
6611
+ await closeDaemonServer(this.server, this.clients);
6627
6612
  this.cleanupSocketPath();
6628
6613
  process.exit(exitCode || (shutdownFailure ? 1 : 0));
6629
6614
  }