@librechat/agents 3.7.0 → 3.7.2

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 (101) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +11 -2
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/eventActor/EventActorExecutor.cjs +797 -0
  4. package/dist/cjs/eventActor/EventActorExecutor.cjs.map +1 -0
  5. package/dist/cjs/eventActor/index.cjs +1 -0
  6. package/dist/cjs/graphs/Graph.cjs +7 -2
  7. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  8. package/dist/cjs/llm/invoke.cjs +56 -9
  9. package/dist/cjs/llm/invoke.cjs.map +1 -1
  10. package/dist/cjs/main.cjs +15 -1
  11. package/dist/cjs/messages/content.cjs +8 -5
  12. package/dist/cjs/messages/content.cjs.map +1 -1
  13. package/dist/cjs/messages/format.cjs +15 -5
  14. package/dist/cjs/messages/format.cjs.map +1 -1
  15. package/dist/cjs/messages/index.cjs +2 -1
  16. package/dist/cjs/messages/projectionInvariant.cjs +74 -0
  17. package/dist/cjs/messages/projectionInvariant.cjs.map +1 -0
  18. package/dist/cjs/messages/provenance.cjs +30 -8
  19. package/dist/cjs/messages/provenance.cjs.map +1 -1
  20. package/dist/cjs/messages/recency.cjs +202 -7
  21. package/dist/cjs/messages/recency.cjs.map +1 -1
  22. package/dist/cjs/messages/toolResultTypes.cjs +1 -0
  23. package/dist/cjs/session/AgentSession.cjs +4 -23
  24. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  25. package/dist/cjs/session/deriveMessages.cjs +25 -0
  26. package/dist/cjs/session/deriveMessages.cjs.map +1 -0
  27. package/dist/cjs/session/index.cjs +1 -0
  28. package/dist/cjs/summarization/node.cjs +13 -6
  29. package/dist/cjs/summarization/node.cjs.map +1 -1
  30. package/dist/cjs/tools/subagent/InMemorySubagentTaskStore.cjs +65 -8
  31. package/dist/cjs/tools/subagent/InMemorySubagentTaskStore.cjs.map +1 -1
  32. package/dist/esm/agents/AgentContext.mjs +11 -2
  33. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  34. package/dist/esm/eventActor/EventActorExecutor.mjs +796 -0
  35. package/dist/esm/eventActor/EventActorExecutor.mjs.map +1 -0
  36. package/dist/esm/eventActor/index.mjs +2 -0
  37. package/dist/esm/graphs/Graph.mjs +8 -3
  38. package/dist/esm/graphs/Graph.mjs.map +1 -1
  39. package/dist/esm/llm/invoke.mjs +56 -9
  40. package/dist/esm/llm/invoke.mjs.map +1 -1
  41. package/dist/esm/main.mjs +8 -4
  42. package/dist/esm/messages/content.mjs +8 -6
  43. package/dist/esm/messages/content.mjs.map +1 -1
  44. package/dist/esm/messages/format.mjs +16 -6
  45. package/dist/esm/messages/format.mjs.map +1 -1
  46. package/dist/esm/messages/index.mjs +2 -1
  47. package/dist/esm/messages/projectionInvariant.mjs +72 -0
  48. package/dist/esm/messages/projectionInvariant.mjs.map +1 -0
  49. package/dist/esm/messages/provenance.mjs +30 -9
  50. package/dist/esm/messages/provenance.mjs.map +1 -1
  51. package/dist/esm/messages/recency.mjs +201 -8
  52. package/dist/esm/messages/recency.mjs.map +1 -1
  53. package/dist/esm/messages/toolResultTypes.mjs +1 -1
  54. package/dist/esm/session/AgentSession.mjs +4 -23
  55. package/dist/esm/session/AgentSession.mjs.map +1 -1
  56. package/dist/esm/session/deriveMessages.mjs +25 -0
  57. package/dist/esm/session/deriveMessages.mjs.map +1 -0
  58. package/dist/esm/session/index.mjs +1 -0
  59. package/dist/esm/summarization/node.mjs +14 -7
  60. package/dist/esm/summarization/node.mjs.map +1 -1
  61. package/dist/esm/tools/subagent/InMemorySubagentTaskStore.mjs +65 -8
  62. package/dist/esm/tools/subagent/InMemorySubagentTaskStore.mjs.map +1 -1
  63. package/dist/types/agents/AgentContext.d.ts +6 -1
  64. package/dist/types/eventActor/EventActorExecutor.d.ts +18 -0
  65. package/dist/types/eventActor/index.d.ts +2 -0
  66. package/dist/types/eventActor/types.d.ts +193 -0
  67. package/dist/types/index.d.ts +1 -0
  68. package/dist/types/messages/content.d.ts +4 -1
  69. package/dist/types/messages/format.d.ts +6 -0
  70. package/dist/types/messages/index.d.ts +1 -0
  71. package/dist/types/messages/projectionInvariant.d.ts +25 -0
  72. package/dist/types/messages/provenance.d.ts +10 -0
  73. package/dist/types/messages/recency.d.ts +30 -18
  74. package/dist/types/session/deriveMessages.d.ts +11 -0
  75. package/dist/types/session/index.d.ts +2 -0
  76. package/dist/types/tools/subagent/InMemorySubagentTaskStore.d.ts +13 -1
  77. package/dist/types/types/graph.d.ts +1 -1
  78. package/dist/types/types/subagentTasks.d.ts +22 -0
  79. package/dist/types/types/summarize.d.ts +15 -13
  80. package/package.json +68 -77
  81. package/src/agents/AgentContext.ts +19 -5
  82. package/src/eventActor/EventActorExecutor.ts +1499 -0
  83. package/src/eventActor/index.ts +32 -0
  84. package/src/eventActor/types.ts +250 -0
  85. package/src/graphs/Graph.ts +9 -1
  86. package/src/index.ts +3 -0
  87. package/src/llm/invoke.ts +102 -23
  88. package/src/messages/content.ts +20 -10
  89. package/src/messages/format.ts +29 -5
  90. package/src/messages/index.ts +1 -0
  91. package/src/messages/projectionInvariant.ts +134 -0
  92. package/src/messages/provenance.ts +60 -18
  93. package/src/messages/recency.ts +429 -27
  94. package/src/session/AgentSession.ts +4 -30
  95. package/src/session/deriveMessages.ts +37 -0
  96. package/src/session/index.ts +2 -0
  97. package/src/summarization/node.ts +37 -15
  98. package/src/tools/subagent/InMemorySubagentTaskStore.ts +139 -6
  99. package/src/types/graph.ts +1 -0
  100. package/src/types/subagentTasks.ts +28 -0
  101. package/src/types/summarize.ts +15 -13
@@ -5,6 +5,7 @@ const DEFAULT_MAX_ERROR_CHARS = 4 * 1024;
5
5
  const DEFAULT_MAX_MESSAGE_CHARS = 64 * 1024;
6
6
  const DEFAULT_TASK_TIMEOUT_MS = 1800 * 1e3;
7
7
  const DEFAULT_MAX_CONTROLS = 32;
8
+ const DEFAULT_MAX_CONTROL_RECEIPTS = 64;
8
9
  const DEFAULT_MAX_RESULT_CHARS = 1e5;
9
10
  const DEFAULT_MAX_RUNNING_PER_SCOPE = 10;
10
11
  const DEFAULT_MAX_RUNNING_TOTAL = 100;
@@ -20,6 +21,7 @@ function resolveOptions(options) {
20
21
  completedTtlMs: resolvePositiveInteger(options.completedTtlMs, DEFAULT_COMPLETED_TTL_MS),
21
22
  maxControlMessageChars: resolvePositiveInteger(options.maxControlMessageChars, DEFAULT_MAX_MESSAGE_CHARS),
22
23
  maxControlsPerTask: resolvePositiveInteger(options.maxControlsPerTask, DEFAULT_MAX_CONTROLS),
24
+ maxControlReceiptsPerTask: Math.max(resolvePositiveInteger(options.maxControlReceiptsPerTask, DEFAULT_MAX_CONTROL_RECEIPTS), resolvePositiveInteger(options.maxControlsPerTask, DEFAULT_MAX_CONTROLS)),
23
25
  maxErrorChars: resolvePositiveInteger(options.maxErrorChars, DEFAULT_MAX_ERROR_CHARS),
24
26
  maxResultChars: resolvePositiveInteger(options.maxResultChars, DEFAULT_MAX_RESULT_CHARS),
25
27
  maxRunningPerScope: Math.min(resolvePositiveInteger(options.maxRunningPerScope, DEFAULT_MAX_RUNNING_PER_SCOPE), maxTasksPerScope),
@@ -58,10 +60,14 @@ function snapshot(task) {
58
60
  resultAvailable: task.status === "completed" && task.result != null && !task.resultClaimed,
59
61
  resultClaimed: task.resultClaimed,
60
62
  pendingControls: task.controls.length,
63
+ controlReceipts: [...task.controlReceipts.values()].map((receipt) => ({ ...receipt })),
61
64
  ...task.progress == null ? {} : { progress: { ...task.progress } },
62
65
  ...task.error == null ? {} : { error: task.error }
63
66
  };
64
67
  }
68
+ function cloneControlReceipt(receipt) {
69
+ return { ...receipt };
70
+ }
65
71
  function abortReason(signal) {
66
72
  return signal.reason instanceof Error ? signal.reason : /* @__PURE__ */ new Error("Detached subagent task cancelled.");
67
73
  }
@@ -73,6 +79,12 @@ var InMemorySubagentTaskStore = class {
73
79
  constructor(options = {}) {
74
80
  this.options = resolveOptions(options);
75
81
  }
82
+ onControlReceipt(_scopeId, _taskId, _receipt) {}
83
+ emitControlReceipt(task, receipt) {
84
+ try {
85
+ this.onControlReceipt(task.scopeId, task.id, cloneControlReceipt(receipt));
86
+ } catch {}
87
+ }
76
88
  start(request) {
77
89
  const scopeId = request.scopeId.trim();
78
90
  const idempotencyKey = request.idempotencyKey.trim();
@@ -128,6 +140,7 @@ var InMemorySubagentTaskStore = class {
128
140
  updatedAt: now,
129
141
  controller: new AbortController(),
130
142
  controls: [],
143
+ controlReceipts: /* @__PURE__ */ new Map(),
131
144
  progressEvents: 0,
132
145
  resultClaimed: false,
133
146
  acceptingControls: true
@@ -153,6 +166,7 @@ var InMemorySubagentTaskStore = class {
153
166
  }
154
167
  task.status = "completed";
155
168
  task.acceptingControls = false;
169
+ this.failPendingControls(task, "task_completed");
156
170
  task.controls.length = 0;
157
171
  task.result = truncateMiddle(result.content, this.options.maxResultChars);
158
172
  task.updatedAt = Date.now();
@@ -233,11 +247,13 @@ var InMemorySubagentTaskStore = class {
233
247
  status: "control_not_found",
234
248
  task: snapshot(task)
235
249
  };
236
- task.controls.splice(index, 1);
250
+ const [control] = task.controls.splice(index, 1);
237
251
  task.updatedAt = Date.now();
252
+ this.transitionControl(task, control.id, "rejected", { reason: "withdrawn" });
238
253
  return {
239
254
  status: "accepted",
240
- task: snapshot(task)
255
+ task: snapshot(task),
256
+ controlId: control.id
241
257
  };
242
258
  }
243
259
  const message = command.message.trim();
@@ -253,6 +269,10 @@ var InMemorySubagentTaskStore = class {
253
269
  status: "invalid",
254
270
  message: `Task already has ${this.options.maxControlsPerTask} pending messages.`
255
271
  };
272
+ if (!this.makeRoomForControlReceipt(task)) return {
273
+ status: "invalid",
274
+ message: "Task control receipt capacity is unavailable."
275
+ };
256
276
  const control = {
257
277
  id: nanoid(),
258
278
  action: command.action,
@@ -260,6 +280,15 @@ var InMemorySubagentTaskStore = class {
260
280
  };
261
281
  task.controls.push(control);
262
282
  task.updatedAt = Date.now();
283
+ const receipt = {
284
+ controlId: control.id,
285
+ action: control.action,
286
+ status: "accepted",
287
+ createdAt: task.updatedAt,
288
+ updatedAt: task.updatedAt
289
+ };
290
+ task.controlReceipts.set(control.id, receipt);
291
+ this.emitControlReceipt(task, receipt);
263
292
  return {
264
293
  status: "accepted",
265
294
  task: snapshot(task),
@@ -321,6 +350,30 @@ var InMemorySubagentTaskStore = class {
321
350
  dropEmptyBucket(scopeId, bucket) {
322
351
  if (bucket.tasks.size === 0 && this.buckets.get(scopeId) === bucket) this.buckets.delete(scopeId);
323
352
  }
353
+ makeRoomForControlReceipt(task) {
354
+ while (task.controlReceipts.size >= this.options.maxControlReceiptsPerTask) {
355
+ const terminal = [...task.controlReceipts].find(([, receipt]) => receipt.status !== "accepted");
356
+ if (terminal == null) return false;
357
+ task.controlReceipts.delete(terminal[0]);
358
+ }
359
+ return true;
360
+ }
361
+ transitionControl(task, controlId, status, detail = {}) {
362
+ const receipt = task.controlReceipts.get(controlId);
363
+ if (receipt == null || receipt.status !== "accepted") return;
364
+ const transitioned = {
365
+ ...receipt,
366
+ status,
367
+ updatedAt: Date.now(),
368
+ ...detail.boundary == null ? {} : { boundary: detail.boundary },
369
+ ...detail.reason == null ? {} : { reason: detail.reason }
370
+ };
371
+ task.controlReceipts.set(controlId, transitioned);
372
+ this.emitControlReceipt(task, transitioned);
373
+ }
374
+ failPendingControls(task, reason) {
375
+ for (const control of task.controls) this.transitionControl(task, control.id, reason === "task_failed" ? "failed" : "rejected", { reason });
376
+ }
324
377
  scheduleExpiry(task) {
325
378
  this.clearTaskTimeout(task);
326
379
  this.clearTaskExpiry(task);
@@ -346,6 +399,7 @@ var InMemorySubagentTaskStore = class {
346
399
  task.status = status;
347
400
  this.runningTasks -= 1;
348
401
  task.acceptingControls = false;
402
+ this.failPendingControls(task, status === "cancelled" ? "task_cancelled" : "task_failed");
349
403
  task.controls.length = 0;
350
404
  task.error = message;
351
405
  task.updatedAt = Date.now();
@@ -353,13 +407,16 @@ var InMemorySubagentTaskStore = class {
353
407
  task.controller.abort(resolved);
354
408
  }
355
409
  createRuntime(task) {
356
- const take = (accept) => {
410
+ const take = (boundary, accept) => {
357
411
  if (task.status !== "running") return [];
358
412
  const selected = [];
359
413
  const retained = [];
360
414
  for (const control of task.controls) (accept(control) ? selected : retained).push(control);
361
415
  task.controls = retained;
362
- if (selected.length > 0) task.updatedAt = Date.now();
416
+ if (selected.length > 0) {
417
+ task.updatedAt = Date.now();
418
+ for (const control of selected) this.transitionControl(task, control.id, "applied", { boundary });
419
+ }
363
420
  return selected.map(toInjectedMessage);
364
421
  };
365
422
  return {
@@ -367,12 +424,12 @@ var InMemorySubagentTaskStore = class {
367
424
  signal: task.controller.signal,
368
425
  shouldPreempt: () => task.status === "running" && task.controls.some((control) => control.action === "interrupt"),
369
426
  drain: (boundary) => {
370
- if (boundary === "preempt") return take((control) => control.action === "interrupt");
371
- if (boundary === "tool") return take((control) => control.action !== "queue");
372
- return take(() => true);
427
+ if (boundary === "preempt") return take(boundary, (control) => control.action === "interrupt");
428
+ if (boundary === "tool") return take(boundary, (control) => control.action !== "queue");
429
+ return take(boundary, () => true);
373
430
  },
374
431
  closeTurn: () => {
375
- const messages = take(() => true);
432
+ const messages = take("turn", () => true);
376
433
  if (messages.length > 0) return {
377
434
  closed: false,
378
435
  messages
@@ -1 +1 @@
1
- {"version":3,"file":"InMemorySubagentTaskStore.mjs","names":[],"sources":["../../../../src/tools/subagent/InMemorySubagentTaskStore.ts"],"mappings":";;AAiBA,MAAM,2BAA2B,OAAU;AAC3C,MAAM,0BAA0B,IAAI;AACpC,MAAM,4BAA4B,KAAK;AACvC,MAAM,0BAA0B,OAAU;AAC1C,MAAM,uBAAuB;AAC7B,MAAM,2BAA2B;AACjC,MAAM,gCAAgC;AACtC,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAkDhC,SAAS,uBACP,OACA,UACQ;CACR,OAAO,OAAO,cAAc,KAAK,K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O;IAErD,OAAO,WAAW,IAAI;GACxB;GACA,iBAAmE;IACjE,MAAM,WAAW,WAAW,IAAI;IAChC,IAAI,SAAS,SAAS,GACpB,OAAO;KAAE,QAAQ;KAAO;IAAS;IAEnC,KAAK,oBAAoB;IACzB,OAAO;KAAE,QAAQ;KAAM,UAAU,CAAC;IAAE;GACtC;GACA,iBAAiB,UAAqC;IACpD,IAAI,KAAK,WAAW,WAClB;IAEF,KAAK,kBAAkB;IACvB,KAAK,YAAY,KAAK,IAAI;IAC1B,KAAK,WAAW;KACd,OAAO,MAAM;KACb,IAAI,KAAK;KACT,YAAY,KAAK;KACjB,GAAI,MAAM,SAAS,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,MAAM;IACtD;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"InMemorySubagentTaskStore.mjs","names":[],"sources":["../../../../src/tools/subagent/InMemorySubagentTaskStore.ts"],"mappings":";;AAkBA,MAAM,2BAA2B,OAAU;AAC3C,MAAM,0BAA0B,IAAI;AACpC,MAAM,4BAA4B,KAAK;AACvC,MAAM,0BAA0B,OAAU;AAC1C,MAAM,uBAAuB;AAC7B,MAAM,+BAA+B;AACrC,MAAM,2BAA2B;AACjC,MAAM,gCAAgC;AACtC,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAoDhC,SAAS,uBACP,OACA,UACQ;CACR,OAAO,OAAO,cAAc,KAAK,KAAK,SAAS,QAAQ,QAAQ,IAC3D,QACA;AACN;AAEA,SAAS,eACP,SACiB;CACjB,MAAM,mBAAmB,uBACvB,QAAQ,kBACR,2BACF;CACA,MAAM,gBAAgB,uBACpB,QAAQ,eACR,uBACF;CACA,OAAO;EACL,gBAAgB,uBACd,QAAQ,gBACR,wBACF;EACA,wBAAwB,uBACtB,QAAQ,wBACR,yBACF;EACA,oBAAoB,uBAClB,QAAQ,oBACR,oBACF;EACA,2BAA2B,KAAK,IAC9B,uBACE,QAAQ,2BACR,4BACF,GACA,u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AK,WAAW;GACxB,qBACE,KAAK,WAAW,aAChB,KAAK,SAAS,MAAM,YAAY,QAAQ,WAAW,WAAW;GAChE,QAAQ,aAAsD;IAC5D,IAAI,aAAa,WACf,OAAO,KAAK,WAAW,YAAY,QAAQ,WAAW,WAAW;IAEnE,IAAI,aAAa,QACf,OAAO,KAAK,WAAW,YAAY,QAAQ,WAAW,OAAO;IAE/D,OAAO,KAAK,gBAAgB,IAAI;GAClC;GACA,iBAAmE;IACjE,MAAM,WAAW,KAAK,cAAc,IAAI;IACxC,IAAI,SAAS,SAAS,GACpB,OAAO;KAAE,QAAQ;KAAO;IAAS;IAEnC,KAAK,oBAAoB;IACzB,OAAO;KAAE,QAAQ;KAAM,UAAU,CAAC;IAAE;GACtC;GACA,iBAAiB,UAAqC;IACpD,IAAI,KAAK,WAAW,WAClB;IAEF,KAAK,kBAAkB;IACvB,KAAK,YAAY,KAAK,IAAI;IAC1B,KAAK,WAAW;KACd,OAAO,MAAM;KACb,IAAI,KAAK;KACT,YAAY,KAAK;KACjB,GAAI,MAAM,SAAS,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,MAAM;IACtD;GACF;EACF;CACF;AACF"}
@@ -150,6 +150,8 @@ export declare class AgentContext {
150
150
  * - `'none'`: no summary present
151
151
  */
152
152
  private _summaryLocation;
153
+ /** Whether a mid-run summary must appear before every retained message. */
154
+ private summaryPrecedesMessages;
153
155
  /**
154
156
  * Durable summary that survives reset() calls. Set from initialSummary
155
157
  * during fromConfig() and updated by setSummary() so that the latest
@@ -158,6 +160,7 @@ export declare class AgentContext {
158
160
  */
159
161
  private _durableSummaryText?;
160
162
  private _durableSummaryTokenCount;
163
+ private durableSummaryPrecedesMessages;
161
164
  /** Number of summarization cycles that have occurred for this agent context */
162
165
  private _summaryVersion;
163
166
  /**
@@ -348,7 +351,9 @@ export declare class AgentContext {
348
351
  * Call this when resetting the agent or when handoff context is no longer relevant.
349
352
  */
350
353
  clearHandoffContext(): void;
351
- setSummary(text: string, tokenCount: number): void;
354
+ setSummary(text: string, tokenCount: number, options?: {
355
+ precedesMessages?: boolean;
356
+ }): void;
352
357
  /** Sets a cross-run summary that is injected into the system prompt. */
353
358
  setInitialSummary(text: string, tokenCount: number): void;
354
359
  /**
@@ -0,0 +1,18 @@
1
+ import type { EventActorAppliedResult, EventActorDiscardReason, EventActorEvent, EventActorExecutionRequest, EventActorExecutionResult, EventActorExecutorOptions, EventActorHostAdapter, EventActorInvocationResult, EventActorPreparedInvocation, EventActorPrepareRequest, EventActorPreparation, EventActorSettlementResult } from './types';
2
+ /**
3
+ * Runs one event against an isolated checkpoint fork and advances the stable
4
+ * actor head only through the host's atomic commit interface.
5
+ */
6
+ export declare class EventActorExecutor<TEvent extends EventActorEvent, TResult extends EventActorEvent> {
7
+ #private;
8
+ constructor(adapter: EventActorHostAdapter<TEvent, TResult>, options?: EventActorExecutorOptions);
9
+ prepare(request: EventActorPrepareRequest<TEvent>, signal?: AbortSignal): Promise<EventActorPreparation<TEvent>>;
10
+ coldContinue(preparation: Extract<EventActorPreparation<TEvent>, {
11
+ status: 'checkpoint_unavailable';
12
+ }>, signal?: AbortSignal): Promise<EventActorPreparedInvocation<TEvent>>;
13
+ invoke(invocation: EventActorPreparedInvocation<TEvent>, signal?: AbortSignal): Promise<EventActorInvocationResult<TResult>>;
14
+ commit(settlement: EventActorAppliedResult<TResult>): Promise<EventActorSettlementResult<TResult>>;
15
+ discard(invocation: EventActorPreparedInvocation<TEvent>, reason: EventActorDiscardReason): Promise<void>;
16
+ execute(request: EventActorExecutionRequest<TEvent>): Promise<EventActorExecutionResult<TResult>>;
17
+ }
18
+ export declare function createEventActorExecutor<TEvent extends EventActorEvent, TResult extends EventActorEvent>(adapter: EventActorHostAdapter<TEvent, TResult>, options?: EventActorExecutorOptions): EventActorExecutor<TEvent, TResult>;
@@ -0,0 +1,2 @@
1
+ export { EventActorExecutor, createEventActorExecutor, } from './EventActorExecutor';
2
+ export type { EventActorAdapterPrepareRequest, EventActorAdapterPreparation, EventActorAppliedResult, EventActorCheckpointFork, EventActorCheckpointReference, EventActorCommitRequest, EventActorCommitResult, EventActorDiscardReason, EventActorDiscardRequest, EventActorEvent, EventActorExecutionRequest, EventActorExecutionResult, EventActorExecutorOptions, EventActorHead, EventActorHostAdapter, EventActorInvocation, EventActorInvocationContext, EventActorIndeterminateResult, EventActorInvocationReference, EventActorInvocationResult, EventActorPreparation, EventActorPreparationContext, EventActorPreparedInvocation, EventActorPrepareRequest, EventActorSettlementResult, EventActorTerminalResult, } from './types';
@@ -0,0 +1,193 @@
1
+ import type { RunnableConfig } from '@langchain/core/runnables';
2
+ /** Durable event payload accepted by the actor lifecycle. */
3
+ export type EventActorEvent = null | boolean | number | string | readonly EventActorEvent[] | {
4
+ readonly [key: string]: EventActorEvent;
5
+ };
6
+ /** Stable reference to one persisted LangGraph checkpoint. */
7
+ export interface EventActorCheckpointReference {
8
+ threadId: string;
9
+ checkpointId?: string;
10
+ checkpointNs: string;
11
+ }
12
+ /** Committed logical head read before an event invocation is prepared. */
13
+ export interface EventActorHead {
14
+ actorThreadId: string;
15
+ generation: number;
16
+ checkpoint?: EventActorCheckpointReference;
17
+ }
18
+ /** Invocation-owned checkpoint fork that cannot become authoritative in place. */
19
+ export interface EventActorCheckpointFork extends EventActorCheckpointReference {
20
+ invocationId: string;
21
+ }
22
+ export interface EventActorInvocationReference {
23
+ actorThreadId: string;
24
+ invocationId: string;
25
+ depth: number;
26
+ continuation: 'warm' | 'cold';
27
+ base: EventActorHead;
28
+ fork: EventActorCheckpointFork;
29
+ }
30
+ export interface EventActorInvocation<TEvent extends EventActorEvent> extends EventActorInvocationReference {
31
+ event: TEvent;
32
+ }
33
+ export interface EventActorPreparedInvocation<TEvent extends EventActorEvent> extends EventActorInvocation<TEvent> {
34
+ /**
35
+ * Executor-authenticated, time-bounded binding over the complete prepared
36
+ * invocation. Its wire representation is opaque to callers.
37
+ */
38
+ preparationDigest: string;
39
+ }
40
+ export type EventActorAdapterPreparation<TEvent extends EventActorEvent> = {
41
+ status: 'ready';
42
+ invocation: EventActorInvocation<TEvent>;
43
+ } | {
44
+ status: 'checkpoint_unavailable';
45
+ head: EventActorHead;
46
+ };
47
+ export type EventActorPreparation<TEvent extends EventActorEvent> = {
48
+ status: 'ready';
49
+ invocation: EventActorPreparedInvocation<TEvent>;
50
+ } | {
51
+ status: 'checkpoint_unavailable';
52
+ request: EventActorPrepareRequest<TEvent>;
53
+ head: EventActorHead;
54
+ /** Executor-authenticated binding over this exact request/head pair. */
55
+ preparationDigest: string;
56
+ };
57
+ export type EventActorTerminalResult<TResult extends EventActorEvent> = {
58
+ status: 'applied';
59
+ result: TResult;
60
+ checkpoint: EventActorCheckpointFork;
61
+ } | {
62
+ status: 'completed_no_action';
63
+ result?: TResult;
64
+ };
65
+ export type EventActorAppliedResult<TResult extends EventActorEvent> = Extract<EventActorTerminalResult<TResult>, {
66
+ status: 'applied';
67
+ }> & {
68
+ /** Executor-issued one-shot settlement for the invocation that produced this action. */
69
+ invocation: EventActorInvocationReference;
70
+ };
71
+ export interface EventActorIndeterminateResult<TResult extends EventActorEvent> {
72
+ /** Applied handling cannot be proven safe to retry; retain its fork. */
73
+ status: 'commit_indeterminate';
74
+ result?: TResult;
75
+ checkpoint: EventActorCheckpointFork;
76
+ error: Error;
77
+ }
78
+ export type EventActorInvocationResult<TResult extends EventActorEvent> = EventActorAppliedResult<TResult> | EventActorIndeterminateResult<TResult> | Extract<EventActorTerminalResult<TResult>, {
79
+ status: 'completed_no_action';
80
+ }>;
81
+ export interface EventActorInvocationContext {
82
+ signal: AbortSignal;
83
+ config: RunnableConfig;
84
+ }
85
+ export interface EventActorPreparationContext {
86
+ /** Explicit task-owned cancellation; parent-run ambient signals are excluded. */
87
+ signal: AbortSignal;
88
+ }
89
+ export interface EventActorPrepareRequest<TEvent extends EventActorEvent> {
90
+ actorThreadId: string;
91
+ invocationId: string;
92
+ depth: number;
93
+ event: TEvent;
94
+ }
95
+ export interface EventActorAdapterPrepareRequest<TEvent extends EventActorEvent> extends EventActorPrepareRequest<TEvent> {
96
+ /** Unique execution-attempt namespace; invocationId remains the logical idempotency key. */
97
+ checkpointNs: string;
98
+ }
99
+ export interface EventActorCommitRequest<TResult extends EventActorEvent> {
100
+ invocation: EventActorInvocationReference;
101
+ expectedHead: EventActorHead;
102
+ checkpoint: EventActorCheckpointFork;
103
+ result: TResult;
104
+ retention: {
105
+ committedCheckpoints: 2;
106
+ dormantCheckpointTtlMs: number;
107
+ };
108
+ }
109
+ export type EventActorCommitResult = {
110
+ status: 'committed';
111
+ head: EventActorHead;
112
+ } | {
113
+ status: 'stale';
114
+ head?: EventActorHead;
115
+ };
116
+ /** Public settlement outcome after an action has already been applied. */
117
+ export type EventActorSettlementResult<TResult extends EventActorEvent> = EventActorCommitResult | EventActorIndeterminateResult<TResult>;
118
+ export type EventActorDiscardReason = 'cancelled' | 'completed_no_action' | 'failed';
119
+ export interface EventActorDiscardRequest {
120
+ invocation: EventActorInvocationReference;
121
+ reason: EventActorDiscardReason;
122
+ }
123
+ /**
124
+ * Host adapter for durable actor state and the concrete agent invocation.
125
+ * `commit` must compare both the expected generation and checkpoint identity
126
+ * atomically before advancing the logical actor head. The host mailbox
127
+ * deduplicates the logical `invocationId` before entering this seam, while each
128
+ * SDK execution attempt receives a distinct checkpoint namespace. Preparation
129
+ * methods own rollback until they return a ready invocation and must treat the
130
+ * request event as immutable. On cancellation they roll back and reject with
131
+ * `context.signal.reason`; cleanup failures reject with their own error so they
132
+ * remain observable. `invoke` returns only after its provider, stream, timer,
133
+ * and executor resources have been released. Once qualifying action evidence
134
+ * exists, `invoke` must return `applied` even if a later abort or provider
135
+ * failure occurs; a thrown error is therefore a definite no-action failure
136
+ * whose fork is safe to discard. `commit` must not reclaim an applied stale
137
+ * fork: the SDK retains and surfaces it as `commit_conflict` for host
138
+ * reconciliation. `discard` must be idempotent for the same invocation because
139
+ * an ambiguous cleanup failure can be retried through the public lifecycle.
140
+ */
141
+ export interface EventActorHostAdapter<TEvent extends EventActorEvent, TResult extends EventActorEvent> {
142
+ prepare(request: EventActorAdapterPrepareRequest<TEvent>, context: EventActorPreparationContext): Promise<EventActorAdapterPreparation<TEvent>>;
143
+ coldContinue(request: EventActorAdapterPrepareRequest<TEvent>, head: EventActorHead, context: EventActorPreparationContext): Promise<EventActorInvocation<TEvent>>;
144
+ invoke(invocation: EventActorInvocation<TEvent>, context: EventActorInvocationContext): Promise<EventActorTerminalResult<TResult>>;
145
+ commit(request: EventActorCommitRequest<TResult>): Promise<EventActorCommitResult>;
146
+ discard(request: EventActorDiscardRequest): Promise<void>;
147
+ }
148
+ export interface EventActorExecutionRequest<TEvent extends EventActorEvent> {
149
+ actorThreadId: string;
150
+ invocationId: string;
151
+ event: TEvent;
152
+ depth?: number;
153
+ /** Explicit task-owned signal. Ambient parent-run signals are ignored. */
154
+ signal?: AbortSignal;
155
+ }
156
+ export type EventActorExecutionResult<TResult extends EventActorEvent> = {
157
+ status: 'applied';
158
+ result: TResult;
159
+ head: EventActorHead;
160
+ continuation: 'warm' | 'cold';
161
+ } | {
162
+ status: 'completed_no_action';
163
+ result?: TResult;
164
+ continuation: 'warm' | 'cold';
165
+ } | {
166
+ status: 'cancelled';
167
+ continuation: 'warm' | 'cold';
168
+ } | {
169
+ /** The action happened, but another head won the CAS. Reconcile; do not retry. */
170
+ status: 'commit_conflict';
171
+ result: TResult;
172
+ checkpoint: EventActorCheckpointFork;
173
+ head?: EventActorHead;
174
+ continuation: 'warm' | 'cold';
175
+ } | {
176
+ /** Applied handling cannot be proven safe to retry; retain its fork. */
177
+ status: 'commit_indeterminate';
178
+ result?: TResult;
179
+ checkpoint: EventActorCheckpointFork;
180
+ error: Error;
181
+ continuation: 'warm' | 'cold';
182
+ } | {
183
+ status: 'failed';
184
+ error: Error;
185
+ continuation: 'warm' | 'cold';
186
+ };
187
+ export interface EventActorExecutorOptions {
188
+ maxDepth?: number;
189
+ /** Also bounds signed preparation authority and local terminal fences. */
190
+ dormantCheckpointTtlMs?: number;
191
+ /** Stable private key of at least 32 bytes for cross-lifetime handoffs. */
192
+ preparationSigningKey?: string | Uint8Array;
193
+ }
@@ -27,6 +27,7 @@ export * from './common';
27
27
  export * from './utils';
28
28
  export * from './hooks';
29
29
  export * from './session';
30
+ export * from './eventActor';
30
31
  export * from './hitl';
31
32
  export type * from './types';
32
33
  export * from './langchain';
@@ -1,9 +1,12 @@
1
- import type { BaseMessage } from '@langchain/core/messages';
1
+ import type { BaseMessage, MessageContentComplex } from '@langchain/core/messages';
2
2
  /**
3
3
  * Whether {@link formatContentStrings} will flatten this message's content:
4
4
  * a human/ai/system message whose content is an array of text-only blocks.
5
5
  */
6
6
  export declare const isLegacyConvertible: (message: BaseMessage) => boolean;
7
+ /** Joins the text of {@link isLegacyConvertible} content blocks into the exact
8
+ * string {@link formatContentStrings} has always produced for them. */
9
+ export declare const flattenLegacyContent: (blocks: MessageContentComplex[]) => string;
7
10
  /**
8
11
  * Formats an array of messages for LangChain, making sure all content fields are strings
9
12
  * @param {Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>} payload - The array of messages to format.
@@ -91,6 +91,12 @@ interface LangChainMessage {
91
91
  export declare const formatFromLangChain: (message: LangChainMessage) => Record<string, any>;
92
92
  interface FormatAgentMessagesOptions {
93
93
  provider?: ProviderName;
94
+ /** Emit flattenable text content as the joined string the legacy-content
95
+ * projection would produce, so the per-request `formatContentStrings` pass
96
+ * finds nothing to convert and every history message keeps its identity —
97
+ * which is what lets exact-count reuse skip re-tokenizing it. Set this if
98
+ * and only if the run's provider uses legacy string content. */
99
+ legacyContent?: boolean;
94
100
  /** Reconstruct hidden `reasoning_content` from `THINK` parts onto prior
95
101
  * tool-call messages. Explicit opt-in for OpenAI-compatible endpoints that
96
102
  * replay reasoning across turns; defaults to on for DeepSeek thinking-mode. */
@@ -16,3 +16,4 @@ export * from './reducer';
16
16
  export * from './recency';
17
17
  export * from './assistantPhase';
18
18
  export * from './provenance';
19
+ export * from './projectionInvariant';
@@ -0,0 +1,25 @@
1
+ import type { BaseMessage } from '@langchain/core/messages';
2
+ export type ProviderMessageProjectionInvariantMode = 'off' | 'observe' | 'assert';
3
+ export type ProviderMessageProjectionIssueCode = 'absent_provenance' | 'invalid_provenance' | 'unsourced_non_synthetic_part';
4
+ export interface ProviderMessageProjectionInvariantIssue {
5
+ readonly code: ProviderMessageProjectionIssueCode;
6
+ readonly messageIndex: number;
7
+ readonly messageType: string;
8
+ }
9
+ export interface ProviderMessageProjectionInvariantReport {
10
+ readonly valid: boolean;
11
+ readonly messageCount: number;
12
+ readonly sourceBackedMessageCount: number;
13
+ readonly syntheticMessageCount: number;
14
+ readonly gapMessageCount: number;
15
+ readonly issues: readonly ProviderMessageProjectionInvariantIssue[];
16
+ }
17
+ /** Resolves the opt-in provider projection invariant without enabling it for
18
+ * unrecognized values. */
19
+ export declare function resolveProviderMessageProjectionInvariantMode(value?: string | undefined): ProviderMessageProjectionInvariantMode;
20
+ /** Inspects provider-bound lineage without reading message content or source ids. */
21
+ export declare function inspectProviderMessageProjection(messages: readonly BaseMessage[]): ProviderMessageProjectionInvariantReport;
22
+ export declare class ProviderMessageProjectionInvariantError extends Error {
23
+ readonly report: ProviderMessageProjectionInvariantReport;
24
+ constructor(report: ProviderMessageProjectionInvariantReport);
25
+ }
@@ -73,6 +73,16 @@ export declare function hasBijectiveProviderContentPartMapping(parts: readonly P
73
73
  export declare function getProviderSourceMessageIds(message: BaseMessage): string[];
74
74
  /** Replaces typed provenance and synchronizes its stable plural source ids. */
75
75
  export declare function setProviderMessageProvenance(message: BaseMessage, parts: readonly ProviderMessageProvenancePart[]): void;
76
+ /**
77
+ * {@link setProviderMessageProvenance} for a message the caller itself just
78
+ * constructed from locally built plain objects. Such a message cannot carry
79
+ * proxies, accessors, or foreign aliases in `additional_kwargs`/`lc_kwargs`,
80
+ * so the publication skips the hardened descriptor walks while producing the
81
+ * same end state: fresh replacement objects on both slots, with the
82
+ * serialization mirror aliasing the live kwargs. Never call this with a
83
+ * message received across a seam — that is what the hardened variant is for.
84
+ */
85
+ export declare function setFreshProviderMessageProvenance(message: BaseMessage, parts: readonly ProviderMessageProvenancePart[]): void;
76
86
  /** Publishes the canonical fail-closed marker for malformed provenance. */
77
87
  export declare function setInvalidProviderMessageProvenance(message: BaseMessage): void;
78
88
  /** Marks a provider-visible runtime message as host-generated context. */
@@ -1,20 +1,21 @@
1
1
  import type { BaseMessage } from '@langchain/core/messages';
2
2
  export declare const DEFAULT_RETAIN_RECENT_TURNS = 2;
3
+ export declare const DEFAULT_INTRA_TURN_RETAIN_RATIO = 0.16;
3
4
  /**
4
5
  * Configuration for splitting a message list into a head (to be summarized)
5
6
  * and a tail (to be preserved verbatim).
6
7
  */
7
8
  export interface RecencyWindowOptions {
8
9
  /**
9
- * Maximum number of recent user-led turns to keep in the tail. A "turn"
10
- * begins at a HumanMessage and includes every following AIMessage and
11
- * ToolMessage up to (but not including) the next HumanMessage. Cutting
12
- * at turn boundaries guarantees that tool_use / tool_result pairs are
13
- * never split across the head/tail divide.
10
+ * Maximum number of recent user-led turns to keep in the tail. A "turn"
11
+ * begins at a user-authored HumanMessage and includes every following
12
+ * AIMessage and tool result up to the next user-authored HumanMessage.
13
+ * Provider-native HumanMessages containing only tool results remain in the
14
+ * current turn, so the boundary cannot split them from their calls.
14
15
  *
15
- * The most recent turn is always preserved regardless of this value or
16
- * the token cap, so that a single oversized first message is never
17
- * destroyed by summarization.
16
+ * The most recent turn is preserved unless `intraTurnTokens` enables the
17
+ * pairing-balanced fallback for a tool-heavy history. A lone oversized user
18
+ * message is never eligible for that fallback.
18
19
  *
19
20
  * Defaults to `2`. A value of `0` disables the recency window (head =
20
21
  * everything, tail = empty), restoring the pre-recency-window behavior.
@@ -32,29 +33,40 @@ export interface RecencyWindowOptions {
32
33
  tokens?: number;
33
34
  /** Token-counter used to evaluate the optional `tokens` cap. */
34
35
  tokenCounter?: (m: BaseMessage) => number;
36
+ /**
37
+ * Minimum token budget to retain when the turn window would otherwise make
38
+ * the whole history indivisible. When set with `tokenCounter`, older closed
39
+ * tool-call/result units may be summarized from within the earliest retained
40
+ * turn. A lone user payload and open tool units remain indivisible.
41
+ */
42
+ intraTurnTokens?: number;
35
43
  }
36
44
  export interface RecencySplit {
37
45
  /** Older messages eligible for summarization. Empty when nothing to summarize. */
38
46
  head: BaseMessage[];
39
- /** Recent messages preserved verbatim. Always contains the most recent turn when any HumanMessage exists. */
47
+ /** Recent messages preserved verbatim, beginning at a pairing-balanced boundary. */
40
48
  tail: BaseMessage[];
41
49
  /** Number of user-led turns retained in the tail (0 if no HumanMessage exists). */
42
50
  tailTurnCount: number;
43
51
  /** Index in the original `messages` array where the tail begins. */
44
52
  tailStartIndex: number;
53
+ /** True when the pairing-balanced fallback selected the boundary. */
54
+ usedIntraTurnFallback: boolean;
45
55
  }
56
+ export declare function resolveIntraTurnRetainTokens({ tokens, maxContextTokens, }: {
57
+ tokens?: number;
58
+ maxContextTokens?: number;
59
+ }): number | undefined;
46
60
  /**
47
61
  * Splits `messages` into a head (older, to summarize) and a tail (recent,
48
- * to preserve verbatim) at user-message boundaries. The most recent
49
- * user-led turn is always included in the tail; additional older turns
50
- * are added subject to `turns` and `tokens` caps.
62
+ * to preserve verbatim), preferring user-message boundaries. The most recent
63
+ * user-led turn is normally included in the tail; additional older turns are
64
+ * added subject to `turns` and `tokens` caps.
51
65
  *
52
- * Cutting strictly at HumanMessage boundaries ensures that:
53
- * - tool_use tool_result pairs are never split (they always live within
54
- * the same turn);
55
- * - the first user message is never replaced by a summary, addressing
56
- * the "first turn destruction" failure mode where a single large
57
- * user-pasted payload would otherwise be replaced by a generic summary.
66
+ * When that policy exposes no compactable head, `intraTurnTokens` may select
67
+ * a boundary after older closed tool-call/result units. This keeps runaway
68
+ * first-turn tool loops compactable without splitting parallel calls from
69
+ * their results. A user payload without a completed tool unit stays intact.
58
70
  *
59
71
  * When `messages` contains no HumanMessage (degenerate state — e.g. system
60
72
  * + assistant messages from a programmatic preamble), everything is
@@ -0,0 +1,11 @@
1
+ import type { BaseMessage } from '@langchain/core/messages';
2
+ import type { SessionEntry } from './types';
3
+ export interface DerivedSessionMessages {
4
+ initialSummary?: {
5
+ text: string;
6
+ tokenCount: number;
7
+ };
8
+ messages: BaseMessage[];
9
+ }
10
+ /** Derives the active model context from one append-only session-log path. */
11
+ export declare function deriveMessages(entries: readonly SessionEntry[]): DerivedSessionMessages;