@librechat/agents 3.4.0 → 3.4.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 (204) hide show
  1. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  2. package/dist/cjs/graphs/Graph.cjs +165 -57
  3. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  4. package/dist/cjs/graphs/MultiAgentGraph.cjs +81 -33
  5. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  6. package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs +14 -0
  7. package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -0
  8. package/dist/cjs/graphs/createGraph.cjs +15 -0
  9. package/dist/cjs/graphs/createGraph.cjs.map +1 -0
  10. package/dist/cjs/graphs/index.cjs +1 -0
  11. package/dist/cjs/hooks/HookRegistry.cjs +83 -0
  12. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
  13. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +1 -1
  14. package/dist/cjs/hooks/executeHooks.cjs +60 -14
  15. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  16. package/dist/cjs/hooks/index.cjs.map +1 -1
  17. package/dist/cjs/hooks/types.cjs +2 -0
  18. package/dist/cjs/hooks/types.cjs.map +1 -1
  19. package/dist/cjs/llm/init.cjs +3 -3
  20. package/dist/cjs/llm/invoke.cjs +2 -2
  21. package/dist/cjs/main.cjs +34 -24
  22. package/dist/cjs/messages/format.cjs +40 -23
  23. package/dist/cjs/messages/format.cjs.map +1 -1
  24. package/dist/cjs/run.cjs +130 -53
  25. package/dist/cjs/run.cjs.map +1 -1
  26. package/dist/cjs/session/AgentSession.cjs +37 -2
  27. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  28. package/dist/cjs/session/JsonlSessionStore.cjs +2 -2
  29. package/dist/cjs/stream.cjs +1 -1
  30. package/dist/cjs/summarization/node.cjs +6 -3
  31. package/dist/cjs/summarization/node.cjs.map +1 -1
  32. package/dist/cjs/tools/BashExecutor.cjs +1 -1
  33. package/dist/cjs/tools/CodeExecutor.cjs +1 -1
  34. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +1 -1
  35. package/dist/cjs/tools/SubagentTool.cjs +4 -4
  36. package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
  37. package/dist/cjs/tools/ToolNode.cjs +321 -95
  38. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  39. package/dist/cjs/tools/ToolSearch.cjs +1 -1
  40. package/dist/cjs/tools/eagerEventExecution.cjs +1 -0
  41. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +3 -3
  42. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +2 -2
  43. package/dist/cjs/tools/search/rerankers.cjs +154 -1
  44. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  45. package/dist/cjs/tools/search/tool.cjs +4 -1
  46. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  47. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +601 -0
  48. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -0
  49. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +1114 -233
  50. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  51. package/dist/cjs/tools/subagent/SubagentReplay.cjs +177 -0
  52. package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -0
  53. package/dist/cjs/tools/subagent/childGraphConfig.cjs +278 -0
  54. package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -0
  55. package/dist/cjs/tools/subagent/index.cjs +1 -0
  56. package/dist/cjs/tools/subagent/runtimeLimits.cjs +5 -0
  57. package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -0
  58. package/dist/cjs/tools/toolOutputReferences.cjs +20 -0
  59. package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
  60. package/dist/cjs/utils/index.cjs +2 -2
  61. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  62. package/dist/esm/graphs/Graph.mjs +165 -57
  63. package/dist/esm/graphs/Graph.mjs.map +1 -1
  64. package/dist/esm/graphs/MultiAgentGraph.mjs +81 -33
  65. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  66. package/dist/esm/graphs/applyGraphRuntimeConfig.mjs +14 -0
  67. package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -0
  68. package/dist/esm/graphs/createGraph.mjs +15 -0
  69. package/dist/esm/graphs/createGraph.mjs.map +1 -0
  70. package/dist/esm/graphs/index.mjs +1 -0
  71. package/dist/esm/hooks/HookRegistry.mjs +83 -0
  72. package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
  73. package/dist/esm/hooks/createWorkspacePolicyHook.mjs +1 -1
  74. package/dist/esm/hooks/executeHooks.mjs +60 -14
  75. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  76. package/dist/esm/hooks/index.mjs.map +1 -1
  77. package/dist/esm/hooks/types.mjs +2 -1
  78. package/dist/esm/hooks/types.mjs.map +1 -1
  79. package/dist/esm/llm/init.mjs +1 -1
  80. package/dist/esm/llm/invoke.mjs +2 -2
  81. package/dist/esm/main.mjs +21 -19
  82. package/dist/esm/messages/format.mjs +40 -23
  83. package/dist/esm/messages/format.mjs.map +1 -1
  84. package/dist/esm/run.mjs +131 -54
  85. package/dist/esm/run.mjs.map +1 -1
  86. package/dist/esm/session/AgentSession.mjs +37 -2
  87. package/dist/esm/session/AgentSession.mjs.map +1 -1
  88. package/dist/esm/session/JsonlSessionStore.mjs +2 -2
  89. package/dist/esm/stream.mjs +1 -1
  90. package/dist/esm/summarization/node.mjs +6 -3
  91. package/dist/esm/summarization/node.mjs.map +1 -1
  92. package/dist/esm/tools/BashExecutor.mjs +1 -1
  93. package/dist/esm/tools/CodeExecutor.mjs +1 -1
  94. package/dist/esm/tools/ProgrammaticToolCalling.mjs +1 -1
  95. package/dist/esm/tools/SubagentTool.mjs +4 -4
  96. package/dist/esm/tools/SubagentTool.mjs.map +1 -1
  97. package/dist/esm/tools/ToolNode.mjs +322 -96
  98. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  99. package/dist/esm/tools/ToolSearch.mjs +1 -1
  100. package/dist/esm/tools/eagerEventExecution.mjs +1 -1
  101. package/dist/esm/tools/local/LocalExecutionEngine.mjs +3 -3
  102. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +2 -2
  103. package/dist/esm/tools/search/rerankers.mjs +154 -1
  104. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  105. package/dist/esm/tools/search/tool.mjs +4 -1
  106. package/dist/esm/tools/search/tool.mjs.map +1 -1
  107. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +597 -0
  108. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -0
  109. package/dist/esm/tools/subagent/SubagentExecutor.mjs +1114 -233
  110. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  111. package/dist/esm/tools/subagent/SubagentReplay.mjs +170 -0
  112. package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -0
  113. package/dist/esm/tools/subagent/childGraphConfig.mjs +272 -0
  114. package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -0
  115. package/dist/esm/tools/subagent/index.mjs +1 -0
  116. package/dist/esm/tools/subagent/runtimeLimits.mjs +5 -0
  117. package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -0
  118. package/dist/esm/tools/toolOutputReferences.mjs +20 -0
  119. package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
  120. package/dist/esm/utils/index.mjs +2 -2
  121. package/dist/types/agents/AgentContext.d.ts +1 -1
  122. package/dist/types/graphs/Graph.d.ts +22 -2
  123. package/dist/types/graphs/MultiAgentGraph.d.ts +7 -1
  124. package/dist/types/graphs/applyGraphRuntimeConfig.d.ts +3 -0
  125. package/dist/types/graphs/createGraph.d.ts +13 -0
  126. package/dist/types/graphs/graphFactory.d.ts +13 -0
  127. package/dist/types/graphs/index.d.ts +2 -0
  128. package/dist/types/hooks/HookRegistry.d.ts +10 -1
  129. package/dist/types/hooks/executeHooks.d.ts +5 -1
  130. package/dist/types/hooks/index.d.ts +2 -2
  131. package/dist/types/hooks/types.d.ts +12 -0
  132. package/dist/types/run.d.ts +6 -3
  133. package/dist/types/session/AgentSession.d.ts +1 -0
  134. package/dist/types/tools/SubagentTool.d.ts +1 -1
  135. package/dist/types/tools/ToolNode.d.ts +23 -15
  136. package/dist/types/tools/search/rerankers.d.ts +28 -0
  137. package/dist/types/tools/search/types.d.ts +38 -1
  138. package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +171 -0
  139. package/dist/types/tools/subagent/SubagentExecutor.d.ts +70 -36
  140. package/dist/types/tools/subagent/SubagentReplay.d.ts +85 -0
  141. package/dist/types/tools/subagent/childGraphConfig.d.ts +37 -0
  142. package/dist/types/tools/subagent/index.d.ts +1 -1
  143. package/dist/types/tools/subagent/runtimeLimits.d.ts +4 -0
  144. package/dist/types/tools/toolOutputReferences.d.ts +12 -0
  145. package/dist/types/types/graph.d.ts +189 -24
  146. package/dist/types/types/hitl.d.ts +15 -0
  147. package/package.json +8 -2
  148. package/src/agents/AgentContext.ts +1 -1
  149. package/src/graphs/Graph.ts +349 -104
  150. package/src/graphs/MultiAgentGraph.ts +149 -47
  151. package/src/graphs/__tests__/Graph.breakerLifecycle.test.ts +48 -9
  152. package/src/graphs/__tests__/Graph.contextOverflow.test.ts +1 -1
  153. package/src/graphs/__tests__/Graph.subagentResumeState.test.ts +80 -0
  154. package/src/graphs/__tests__/MultiAgentGraph.test.ts +86 -0
  155. package/src/graphs/__tests__/composition.smoke.test.ts +152 -0
  156. package/src/graphs/__tests__/createGraph.test.ts +206 -0
  157. package/src/graphs/applyGraphRuntimeConfig.ts +25 -0
  158. package/src/graphs/createGraph.ts +32 -0
  159. package/src/graphs/graphFactory.ts +12 -0
  160. package/src/graphs/index.ts +2 -0
  161. package/src/hooks/HookRegistry.ts +151 -1
  162. package/src/hooks/__tests__/HookRegistry.test.ts +96 -0
  163. package/src/hooks/__tests__/executeHooks.test.ts +160 -0
  164. package/src/hooks/executeHooks.ts +133 -15
  165. package/src/hooks/index.ts +3 -1
  166. package/src/hooks/types.ts +16 -0
  167. package/src/messages/format.ts +54 -26
  168. package/src/messages/formatAgentMessages.reducer.test.ts +162 -0
  169. package/src/messages/formatAgentMessages.steer.test.ts +16 -11
  170. package/src/messages/formatAgentMessages.test.ts +7 -2
  171. package/src/run.ts +214 -56
  172. package/src/session/AgentSession.ts +52 -2
  173. package/src/session/__tests__/JsonlSessionStore.test.ts +53 -0
  174. package/src/specs/graph-subagent.live.test.ts +242 -0
  175. package/src/specs/graph-subagent.test.ts +322 -0
  176. package/src/specs/langfuse-routing.integration.test.ts +120 -1
  177. package/src/specs/subagent.test.ts +130 -4
  178. package/src/summarization/__tests__/node.test.ts +32 -14
  179. package/src/summarization/node.ts +15 -11
  180. package/src/tools/SubagentTool.ts +4 -4
  181. package/src/tools/ToolNode.ts +643 -157
  182. package/src/tools/__tests__/SubagentExecutor.test.ts +740 -15
  183. package/src/tools/__tests__/SubagentReplay.test.ts +329 -0
  184. package/src/tools/__tests__/ToolNode.breakerSignal.test.ts +208 -2
  185. package/src/tools/__tests__/directToolHITLResumeScope.test.ts +512 -2
  186. package/src/tools/__tests__/hitl.test.ts +234 -5
  187. package/src/tools/__tests__/subagentHooks.test.ts +1126 -61
  188. package/src/tools/__tests__/toolOutputReferences.test.ts +19 -2
  189. package/src/tools/search/rag-api-reranker.test.ts +891 -0
  190. package/src/tools/search/rerankers.ts +260 -0
  191. package/src/tools/search/tool.ts +6 -0
  192. package/src/tools/search/types.ts +45 -1
  193. package/src/tools/subagent/SubagentExecutionRegistry.ts +1159 -0
  194. package/src/tools/subagent/SubagentExecutor.ts +2232 -312
  195. package/src/tools/subagent/SubagentReplay.ts +584 -0
  196. package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +637 -0
  197. package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +3054 -0
  198. package/src/tools/subagent/__tests__/childGraphConfig.test.ts +521 -0
  199. package/src/tools/subagent/childGraphConfig.ts +694 -0
  200. package/src/tools/subagent/index.ts +6 -0
  201. package/src/tools/subagent/runtimeLimits.ts +7 -0
  202. package/src/tools/toolOutputReferences.ts +40 -1
  203. package/src/types/graph.ts +222 -24
  204. package/src/types/hitl.ts +16 -0
@@ -30,6 +30,31 @@ export declare class CohereReranker extends BaseReranker {
30
30
  } & t.HttpAgentConfig);
31
31
  rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
32
32
  }
33
+ /**
34
+ * Calls the public `danny-avila/rag_api` `/v1/rerank` endpoint (the
35
+ * `fast-v1` profile). Auth is supplied per call by a token supplier (a
36
+ * short-lived JWT minted by the host app) rather than a static key. A
37
+ * reranker failure must never throw into the search flow: on a missing
38
+ * base URL/token supplier, a timeout (covering token acquisition as well as
39
+ * the request), a non-2xx response, or any malformed payload, this falls back
40
+ * to the candidates' original order via {@link BaseReranker.getDefaultRanking}.
41
+ */
42
+ export declare class RagApiReranker extends BaseReranker {
43
+ private baseUrl?;
44
+ private tokenSupplier?;
45
+ private profile;
46
+ private timeout;
47
+ private httpAgent?;
48
+ private httpsAgent?;
49
+ constructor({ baseUrl, tokenSupplier, profile, timeout, logger, httpAgent, httpsAgent, }: {
50
+ baseUrl?: string;
51
+ tokenSupplier?: t.RagApiTokenSupplier;
52
+ profile?: string;
53
+ timeout?: number;
54
+ logger?: t.Logger;
55
+ } & t.HttpAgentConfig);
56
+ rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
57
+ }
33
58
  export declare class InfinityReranker extends BaseReranker {
34
59
  constructor(logger?: t.Logger);
35
60
  rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
@@ -42,6 +67,9 @@ export declare const createReranker: (config: {
42
67
  jinaApiKey?: string;
43
68
  jinaApiUrl?: string;
44
69
  cohereApiKey?: string;
70
+ ragApiUrl?: string;
71
+ ragApiTokenSupplier?: t.RagApiTokenSupplier;
72
+ ragApiProfile?: string;
45
73
  rerankerTimeout?: number;
46
74
  logger?: t.Logger;
47
75
  } & t.HttpAgentConfig) => BaseReranker | undefined;
@@ -18,7 +18,7 @@ export interface BaseSearchProviderConfig extends HttpAgentConfig {
18
18
  }
19
19
  export type SearchProvider = 'serper' | 'searxng' | 'tavily' | 'keenable' | 'crw';
20
20
  export type ScraperProvider = 'firecrawl' | 'serper' | 'tavily' | 'crw' | 'keenable';
21
- export type RerankerType = 'infinity' | 'jina' | 'cohere' | 'none';
21
+ export type RerankerType = 'infinity' | 'jina' | 'cohere' | 'rag-api' | 'none';
22
22
  export interface Highlight {
23
23
  score: number;
24
24
  text: string;
@@ -298,6 +298,34 @@ export interface CohereRerankerResponse {
298
298
  };
299
299
  };
300
300
  }
301
+ /** Mints a short-lived JWT per call; rag_api tokens are never cached or
302
+ * reused across requests by the reranker itself. Receives the rerank
303
+ * deadline's `AbortSignal` so a supplier minting its token over the network
304
+ * can cancel that request when the deadline fires instead of leaving it
305
+ * running past its caller. The argument is optional: zero-argument suppliers
306
+ * remain valid. */
307
+ export type RagApiTokenSupplier = (signal?: AbortSignal) => string | Promise<string>;
308
+ export interface RagApiRerankCandidate {
309
+ id: string;
310
+ text: string;
311
+ base_score: number;
312
+ }
313
+ export interface RagApiRerankRequestBody {
314
+ profile: string;
315
+ query: string;
316
+ candidates: RagApiRerankCandidate[];
317
+ top_n: number;
318
+ }
319
+ export interface RagApiRerankResult {
320
+ id: string;
321
+ index: number;
322
+ score: number;
323
+ }
324
+ export interface RagApiRerankResponse {
325
+ profile: string;
326
+ model: string;
327
+ results: RagApiRerankResult[];
328
+ }
301
329
  export type SafeSearchLevel = 0 | 1 | 2;
302
330
  export type Logger = WinstonLogger;
303
331
  export interface SearchToolConfig extends SearchConfig, ProcessSourcesConfig, FirecrawlConfig {
@@ -316,6 +344,15 @@ export interface SearchToolConfig extends SearchConfig, ProcessSourcesConfig, Fi
316
344
  jinaApiKey?: string;
317
345
  jinaApiUrl?: string;
318
346
  cohereApiKey?: string;
347
+ /** Base URL of the public `rag_api` service (`RAG_API_URL` env fallback).
348
+ * Requests post to `${ragApiUrl}/v1/rerank`. */
349
+ ragApiUrl?: string;
350
+ /** Resolves a short-lived rag_api JWT immediately before each rerank call.
351
+ * Required for the `'rag-api'` reranker type — without it, reranking falls
352
+ * back to default (unranked) ordering. */
353
+ ragApiTokenSupplier?: RagApiTokenSupplier;
354
+ /** rag_api rerank profile. Defaults to `'fast-v1'`. */
355
+ ragApiProfile?: string;
319
356
  rerankerType?: RerankerType;
320
357
  /** Timeout (ms) for rerank API requests. Defaults to 10,000. */
321
358
  rerankerTimeout?: number;
@@ -0,0 +1,171 @@
1
+ import type { RunnableConfig } from '@langchain/core/runnables';
2
+ import type { SubagentResumeExecution } from './SubagentReplay';
3
+ export type SubagentExecutionAddressInput = {
4
+ threadId?: string;
5
+ parentToolCallId: string;
6
+ parentConfigurable?: Record<string, unknown>;
7
+ };
8
+ export type SubagentExecutionAddress = Readonly<{
9
+ key: string;
10
+ baseChildThreadId: string;
11
+ branchChildThreadId: string;
12
+ currentChildRunId: string;
13
+ explicitResumeAttempt: boolean;
14
+ parentToolCallId: string;
15
+ resumeAttemptId: string;
16
+ }>;
17
+ export type SubagentExecutionIdentity = Readonly<{
18
+ childRunId: string;
19
+ childThreadId: string;
20
+ approvalExecutionScope: string;
21
+ }>;
22
+ export interface SubagentExecutionPreparationLease {
23
+ readonly ownsCheckpoint: boolean;
24
+ readonly ownsCreatedCheckpoint: boolean;
25
+ readonly ownsApprovalScope: boolean;
26
+ readonly ownsCreatedApprovalScope: boolean;
27
+ assertOwned(): void;
28
+ markCheckpointCreated(cleanup: () => Promise<void>): void;
29
+ markApprovalScopeCreated(cleanup: () => Promise<void>): void;
30
+ release(): void;
31
+ rollback(cause: unknown, cleanup?: (lease: SubagentExecutionPreparationLease) => Promise<void>): Promise<never>;
32
+ }
33
+ export type PreparedSubagentExecutionIdentity = Readonly<{
34
+ identity: SubagentExecutionIdentity;
35
+ lease: SubagentExecutionPreparationLease;
36
+ commit?: (lease: SubagentExecutionPreparationLease) => void;
37
+ rollback?: (lease: SubagentExecutionPreparationLease) => Promise<void>;
38
+ }>;
39
+ export type SubagentDefinitionBinding = Readonly<{
40
+ subagentType?: string;
41
+ configId?: string;
42
+ }>;
43
+ export type SubagentInvocationBinding = Readonly<{
44
+ description: string;
45
+ subagentType: string;
46
+ configId?: string;
47
+ }>;
48
+ export type SubagentSettlementBinding = Readonly<{
49
+ definitionAuthority: 'provisional' | 'effective';
50
+ fingerprint: string;
51
+ invocation: SubagentInvocationBinding;
52
+ subagentType?: string;
53
+ configId?: string;
54
+ }>;
55
+ export type SubagentExecutionPhase = 'registered' | 'active' | 'interrupted' | 'failed' | 'completed' | 'invalidated';
56
+ export interface ExecutionSnapshot<TResult, TResolvedConfig, TActiveRun> {
57
+ readonly address: SubagentExecutionAddress;
58
+ readonly phase: SubagentExecutionPhase;
59
+ readonly identity?: SubagentExecutionIdentity;
60
+ readonly binding?: SubagentDefinitionBinding;
61
+ readonly invocation?: SubagentInvocationBinding;
62
+ readonly settlement?: SubagentSettlementBinding;
63
+ readonly resumeExecution?: SubagentResumeExecution;
64
+ readonly activeRun?: TActiveRun;
65
+ readonly completedResult?: TResult;
66
+ readonly resolvedConfig?: TResolvedConfig;
67
+ readonly started: boolean;
68
+ readonly completed: boolean;
69
+ readonly resolvingIdentity: boolean;
70
+ readonly resolving: boolean;
71
+ readonly executing: boolean;
72
+ readonly settling: boolean;
73
+ readonly settled: boolean;
74
+ }
75
+ export type SubagentExecutionRegistryOptions = {
76
+ parentRunId: string;
77
+ parentAgentId?: string;
78
+ durable: boolean;
79
+ };
80
+ type ResumeSelection = {
81
+ parentToolCallIds?: ReadonlySet<string>;
82
+ config?: RunnableConfig;
83
+ };
84
+ export declare function getSubagentApprovalExecutionScope(childRunId: string, resumeAttemptId: string): string;
85
+ export declare class SubagentExecutionInvalidatedError extends Error {
86
+ constructor();
87
+ }
88
+ export declare class SubagentDefinitionBindingError extends Error {
89
+ constructor();
90
+ }
91
+ export declare class SubagentInvocationBindingError extends Error {
92
+ constructor();
93
+ }
94
+ export declare class SubagentSettlementBindingError extends Error {
95
+ constructor();
96
+ }
97
+ /** In-process source of truth for one Durable Subagent Execution. */
98
+ export declare class SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput = never> {
99
+ readonly address: SubagentExecutionAddress;
100
+ private identityValue?;
101
+ private bindingValue?;
102
+ private bindingAuthority?;
103
+ private invocationValue?;
104
+ private settlementValue?;
105
+ private settledOutputValue?;
106
+ private resumeExecutionValue?;
107
+ private activeRunValue?;
108
+ private completedResultValue?;
109
+ private resolvedConfigValue?;
110
+ private pendingIdentityResolution?;
111
+ private pendingConfigResolution?;
112
+ private pendingExecution?;
113
+ private pendingSettlement?;
114
+ private phaseValue;
115
+ private startedValue;
116
+ private completedValue;
117
+ private settledValue;
118
+ constructor(address: SubagentExecutionAddress, resumeExecution?: SubagentResumeExecution);
119
+ get snapshot(): ExecutionSnapshot<TResult, TResolvedConfig, TActiveRun>;
120
+ get identity(): SubagentExecutionIdentity | undefined;
121
+ get binding(): SubagentDefinitionBinding | undefined;
122
+ get resumeExecution(): SubagentResumeExecution | undefined;
123
+ get invocation(): SubagentInvocationBinding | undefined;
124
+ get activeRun(): TActiveRun | undefined;
125
+ get settlement(): SubagentSettlementBinding | undefined;
126
+ get settledOutput(): TSettledOutput | undefined;
127
+ get completedResult(): TResult | undefined;
128
+ get resolvedConfig(): TResolvedConfig | undefined;
129
+ get started(): boolean;
130
+ get completed(): boolean;
131
+ assertUsable(signal?: AbortSignal): void;
132
+ attachResumeExecution(resumeExecution?: SubagentResumeExecution): void;
133
+ bindIdentity(identity: SubagentExecutionIdentity): void;
134
+ resolveIdentity(resolve: () => Promise<PreparedSubagentExecutionIdentity>): Promise<SubagentExecutionIdentity>;
135
+ bindDefinition(binding: SubagentDefinitionBinding, authority: 'provisional' | 'effective'): void;
136
+ resolveConfig(resolve: () => Promise<TResolvedConfig>, signal: AbortSignal): Promise<TResolvedConfig>;
137
+ execute(invocation: SubagentInvocationBinding, execute: () => Promise<TResult>): Promise<TResult>;
138
+ settle(settlement: SubagentSettlementBinding, settledOutput: TSettledOutput, persist: () => Promise<void>): Promise<void>;
139
+ activate(activeRun: TActiveRun): TActiveRun;
140
+ markStarted(): void;
141
+ markInterrupted(): void;
142
+ markFailed(): void;
143
+ markCompleted(result: TResult): void;
144
+ releaseActiveRun(): TActiveRun | undefined;
145
+ releaseResolvedConfig(): void;
146
+ invalidate(): void;
147
+ private bindInvocation;
148
+ private assertCurrentIdentityResolution;
149
+ private transitionTo;
150
+ }
151
+ /** Owns canonical addressing, record selection, and invalidation. */
152
+ export declare class SubagentExecutionRegistry<TResult, TResolvedConfig, TActiveRun, TSettledOutput = never> {
153
+ private readonly options;
154
+ private readonly recordsByAddress;
155
+ private readonly checkpointThreadIds;
156
+ private readonly preparationResourceOwners;
157
+ private nextPreparationToken;
158
+ constructor(options: SubagentExecutionRegistryOptions);
159
+ open(input: SubagentExecutionAddressInput): SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>;
160
+ remove(record: SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>): void;
161
+ beginIdentityPreparation(record: SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>, identity: SubagentExecutionIdentity): SubagentExecutionPreparationLease;
162
+ selectForResume(selection?: ResumeSelection): SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>[];
163
+ rememberCheckpointThread(...threadIds: string[]): void;
164
+ getCheckpointThreadIds(getNestedThreadIds?: (activeRun: TActiveRun) => ReadonlyArray<string>): string[];
165
+ resetCheckpointThreadIds(): void;
166
+ retireResumeSources(current: SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>, sourceThreadIds: ReadonlySet<string>, retire: (source: SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>) => void): void;
167
+ clear(dispose?: (record: SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput>) => void): void;
168
+ private selectScopedRecords;
169
+ private createAddress;
170
+ }
171
+ export {};
@@ -1,13 +1,20 @@
1
- import type { BaseMessage } from '@langchain/core/messages';
2
- import type { AgentInputs, StandardGraphInput, ResolvedSubagentConfig, SubagentConfig, SubagentUsageSink, TokenCounter } from '@/types';
1
+ import { BaseMessage } from '@langchain/core/messages';
2
+ import type { RunnableConfig } from '@langchain/core/runnables';
3
+ import type { ToolCall } from '@langchain/core/messages/tool';
4
+ import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentUsageSink, TokenCounter } from '@/types';
5
+ import type { SubagentResumeManifest, SettledSubagentToolOutput } from './SubagentReplay';
3
6
  import type { HookRegistry } from '@/hooks';
4
- import type { AgentContext } from '@/agents/AgentContext';
7
+ import type { GraphFactory } from '@/graphs/graphFactory';
5
8
  import type { StandardGraph } from '@/graphs/Graph';
6
9
  import type { HandlerRegistry } from '@/events';
10
+ export { buildChildInputs, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, } from './childGraphConfig';
11
+ export declare const DEFAULT_SUBAGENT_DESCRIPTION = "No task description provided";
7
12
  export type SubagentExecuteParams = {
8
13
  description: string;
9
14
  subagentType: string;
10
15
  threadId?: string;
16
+ /** Signal attached to this specific parent tool invocation. */
17
+ signal?: AbortSignal;
11
18
  /**
12
19
  * Breaker controller captured at the parent TOOL BATCH's entry, before
13
20
  * PreToolUse hooks. Preferred over the live scope accessor: a graph reset
@@ -34,11 +41,12 @@ export type SubagentExecuteParams = {
34
41
  *
35
42
  * Inheritance details (verified empirically against LangGraph):
36
43
  * - host-set keys propagate as-is into the child's tool dispatches;
37
- * - `thread_id` propagates (with `childRunId` as a fallback when
38
- * parent did not supply one) — matches the "subagent is part of
39
- * the same conversation" mental model and aligns with the
40
- * `sessionId: this.parentRunId` convention this executor already
41
- * uses for `SubagentStart` / `SubagentStop` hooks;
44
+ * - with nested HITL enabled, `thread_id` is replaced with a stable
45
+ * child checkpoint id derived from the parent's durable thread id,
46
+ * checkpoint fork, parent agent id, and spawning tool call id so parent
47
+ * and child checkpoints cannot collide, sibling parent forks stay
48
+ * isolated, and reconstruction returns to the same child checkpoint;
49
+ * parent-scoped hook lookup remains keyed by the inherited `run_id`;
42
50
  * - `parent_run_id` propagates when the host put it on parent's
43
51
  * configurable;
44
52
  * - `run_id` is *overwritten by the LangGraph runtime* at child
@@ -68,7 +76,7 @@ export type SubagentExecuteResult = {
68
76
  */
69
77
  export type ChildGraphFactory = (input: StandardGraphInput) => StandardGraph;
70
78
  export type SubagentExecutorOptions = {
71
- configs: Map<string, ResolvedSubagentConfig>;
79
+ configs: ReadonlyMap<string, ExecutableSubagentConfigEntry>;
72
80
  parentSignal?: AbortSignal;
73
81
  /** Run-scoped breaker abort shared by every executor of one graph, so a
74
82
  * child tripping a stream limit stops subagents running under OTHER
@@ -84,6 +92,8 @@ export type SubagentExecutorOptions = {
84
92
  hookRegistry?: HookRegistry;
85
93
  parentRunId: string;
86
94
  parentAgentId?: string;
95
+ /** Root identity, policy session, and lineage inherited by a child graph. */
96
+ executionContext?: SubagentExecutionContext;
87
97
  langfuse?: StandardGraphInput['langfuse'];
88
98
  tokenCounter?: TokenCounter;
89
99
  /**
@@ -95,6 +105,11 @@ export type SubagentExecutorOptions = {
95
105
  * revert to the defaults.
96
106
  */
97
107
  streamLimits?: StandardGraphInput['streamLimits'];
108
+ humanInTheLoop?: HumanInTheLoopConfig;
109
+ /** Shared durable saver used to recover outer tool lifecycle results before
110
+ * parent hooks re-enter after a process rebuild. Narrowed structurally at
111
+ * construction because graph compile options also permit framework flags. */
112
+ checkpointer?: unknown;
98
113
  /** Remaining nesting budget. 0 or negative blocks execution. */
99
114
  maxDepth?: number;
100
115
  /**
@@ -103,6 +118,9 @@ export type SubagentExecutorOptions = {
103
118
  * module dependency.
104
119
  */
105
120
  createChildGraph: ChildGraphFactory;
121
+ /** Preferred polymorphic child constructor. The legacy standard-only
122
+ * factory remains required for source compatibility. */
123
+ createChildGraphByKind?: GraphFactory;
106
124
  /**
107
125
  * Parent's event handler registry. When provided, child-graph events are
108
126
  * forwarded through this registry so hosts can:
@@ -140,12 +158,18 @@ export declare class SubagentExecutor {
140
158
  private readonly hookRegistry?;
141
159
  private readonly parentRunId;
142
160
  private readonly parentAgentId?;
161
+ private readonly executionContext;
143
162
  private readonly langfuse?;
144
163
  private readonly tokenCounter?;
145
164
  private readonly streamLimits?;
165
+ private readonly humanInTheLoop?;
166
+ private readonly checkpointer?;
146
167
  private readonly maxDepth;
147
168
  private readonly createChildGraph;
169
+ private readonly createChildGraphByKind?;
148
170
  private readonly usageSink?;
171
+ private readonly executions;
172
+ private replayCheckpointWorkflow?;
149
173
  private readonly resolveParentHandlerRegistry?;
150
174
  constructor(options: SubagentExecutorOptions);
151
175
  /** The breaker controller current for this execution — read per spawn
@@ -157,7 +181,39 @@ export declare class SubagentExecutor {
157
181
  private composeChildSignal;
158
182
  /** Snapshot of the parent's registry at the moment a subagent is dispatched. */
159
183
  private getParentHandlerRegistry;
184
+ private bindExecutionDefinition;
185
+ /** Resolve one lazy descriptor per stable child execution. Concurrent
186
+ * duplicate dispatches share the same in-flight resolution; HITL re-entry
187
+ * on this executor reuses the resolved config until the child settles. */
188
+ private resolveExecutionConfig;
189
+ /**
190
+ * Keeps the original child thread as an immutable resume source once a
191
+ * different parent Run reconstructs it. Each rebuilt parent gets a private
192
+ * checkpoint fork, while the persisted child run ID remains stable for
193
+ * activity and usage correlation across the interrupt boundary.
194
+ */
195
+ private resolveChildExecutionIdentity;
196
+ private createChildExecutionIdentity;
197
+ private prepareIdentity;
198
+ private prepareCheckpointFork;
199
+ private checkpointThreadExists;
200
+ /** Captures one exact checkpoint head per namespace for a child thread. */
201
+ private getLatestCheckpointSnapshot;
202
+ /** Copies exact checkpoint lineages, including pending task writes. */
203
+ private forkCheckpointSnapshot;
204
+ private createResumeManifest;
205
+ getResumeManifest(parentToolCallIds?: ReadonlySet<string>, config?: RunnableConfig): Promise<SubagentResumeManifest | undefined>;
206
+ getChildCheckpointThreadIds(): string[];
207
+ resetCheckpointThreadIds(): void;
208
+ private getGraphChildCheckpointThreadIds;
209
+ private clearChildGraph;
210
+ clearHeavyState(): void;
211
+ private getResumeCheckpointMarker;
212
+ getSettledToolOutput(call: ToolCall, config: RunnableConfig): Promise<SettledSubagentToolOutput | undefined>;
213
+ persistSettledToolOutput(call: ToolCall, config: RunnableConfig, settled: SettledSubagentToolOutput): Promise<void>;
214
+ private persistChildCheckpointMarker;
160
215
  execute(params: SubagentExecuteParams): Promise<SubagentExecuteResult>;
216
+ private executeOnce;
161
217
  /**
162
218
  * Emits a single {@link GraphEvents.ON_SUBAGENT_UPDATE} envelope through the
163
219
  * parent's handler registry. Silent no-op when no parent registry is set.
@@ -185,6 +241,11 @@ export declare function sanitizeForwardedSubagentUpdateData(eventName: string, d
185
241
  * a compact status ticker without parsing the raw payload.
186
242
  */
187
243
  export declare function summarizeEvent(eventName: string, data: unknown): string;
244
+ /**
245
+ * Reads only the result member captured by MultiAgentGraph. Worker output is
246
+ * never used as a fallback when the designated result member is textless.
247
+ */
248
+ export declare function filterGraphSubagentResult(state: MultiAgentGraphState, resultAgentId: string): string;
188
249
  /**
189
250
  * Walk messages from last to first, returning the text content of the most
190
251
  * recent AIMessage that has any. Non-text blocks (tool_use, thinking,
@@ -199,30 +260,3 @@ export declare function summarizeEvent(eventName: string, data: unknown): string
199
260
  * any text.
200
261
  */
201
262
  export declare function filterSubagentResult(messages: BaseMessage[]): string;
202
- /**
203
- * Resolve self-spawn configs by filling in agentInputs from the parent context.
204
- * Returns configs with agentInputs guaranteed present. Throws on duplicate
205
- * `type` values to prevent silent config shadowing.
206
- */
207
- export declare function resolveSubagentConfigs(configs: SubagentConfig[], parentContext: AgentContext): ResolvedSubagentConfig[];
208
- /**
209
- * Build child AgentInputs from a resolved config, stripping nesting and
210
- * (optionally) event-driven fields. When `allowNested: true`, the child's
211
- * `maxSubagentDepth` is decremented so that depth is consumed as the call
212
- * chain deepens across graph boundaries — the parent's executor-level check
213
- * alone cannot see into the child graph's separate executor.
214
- *
215
- * When `keepToolDefinitions` is `true`, the child retains the parent's
216
- * `toolDefinitions` so event-driven tools remain usable. This is only safe
217
- * when the caller has wired a forwarder for `ON_TOOL_EXECUTE` to a
218
- * registered handler — otherwise the child will hang on tool dispatch.
219
- *
220
- * @remarks Advanced utility: exported primarily for testing and by
221
- * {@link SubagentExecutor}. Host applications configuring subagents should
222
- * not need to call this directly — it is invoked internally when a subagent
223
- * tool is dispatched. The depth-countdown contract (parent's `maxDepth` in,
224
- * child's decremented `maxSubagentDepth` on the returned inputs) is the
225
- * mechanism that bounds nesting across graph boundaries; callers must
226
- * respect it.
227
- */
228
- export declare function buildChildInputs(config: ResolvedSubagentConfig, childAgentId: string, parentMaxDepth: number, keepToolDefinitions?: boolean): AgentInputs;
@@ -0,0 +1,85 @@
1
+ import type { ToolCall, ToolMessage } from '@langchain/core/messages/tool';
2
+ import type { RunnableConfig } from '@langchain/core/runnables';
3
+ import type { ToolOutputReferenceState } from '@/tools/toolOutputReferences';
4
+ import type { ToolApprovalReplaySnapshot } from '@/hooks';
5
+ import type { ToolSessionContext } from '@/types';
6
+ export declare const SUBAGENT_RESUME_MANIFEST_CONFIG_KEY = "__librechat_subagent_resume_manifest";
7
+ export declare const SUBAGENT_RESUME_ATTEMPT_CONFIG_KEY = "__librechat_subagent_resume_attempt";
8
+ export declare const SUBAGENT_PARENT_BATCH_CONFIG_KEY = "__librechat_subagent_parent_batch";
9
+ export interface SubagentCheckpointReference {
10
+ threadId: string;
11
+ checkpointId: string;
12
+ checkpointNs: string;
13
+ }
14
+ export interface SubagentToolCallStepReference {
15
+ toolCallId: string;
16
+ stepId: string;
17
+ }
18
+ export interface SubagentToolSessionReference {
19
+ toolName: string;
20
+ context: ToolSessionContext;
21
+ }
22
+ export interface SubagentToolNodeResumeState {
23
+ stateKey: string;
24
+ toolUsageCounts: Array<{
25
+ toolName: string;
26
+ count: number;
27
+ }>;
28
+ directPathTurns: Array<{
29
+ toolCallId: string;
30
+ turn: number;
31
+ }>;
32
+ }
33
+ export interface SubagentEagerToolUsageState {
34
+ agentId: string;
35
+ toolUsageCounts: Array<{
36
+ toolName: string;
37
+ count: number;
38
+ }>;
39
+ }
40
+ export interface SubagentGraphResumeState {
41
+ toolCallSteps: SubagentToolCallStepReference[];
42
+ toolSessions: SubagentToolSessionReference[];
43
+ toolNodes: SubagentToolNodeResumeState[];
44
+ eagerToolUsage: SubagentEagerToolUsageState[];
45
+ eagerToolSuppressions: string[];
46
+ toolOutputReferences?: ToolOutputReferenceState;
47
+ }
48
+ /** Private checkpoint payload linking a parent pause to an exact child state. */
49
+ export interface SubagentResumeExecution {
50
+ parentToolCallId: string;
51
+ childRunId: string;
52
+ /** Effective child type bound when this execution first ran. */
53
+ subagentType?: string;
54
+ /** Lazy child revision bound when this execution first resolved. */
55
+ configId?: string;
56
+ approvalExecutionScope: string;
57
+ checkpoints: SubagentCheckpointReference[];
58
+ graphState: SubagentGraphResumeState;
59
+ approvalReplays: ToolApprovalReplaySnapshot[];
60
+ descendant?: SubagentResumeManifest;
61
+ }
62
+ /** Private checkpoint payload linking a parent pause to every child state. */
63
+ export interface SubagentResumeManifest {
64
+ version: 1;
65
+ executions: SubagentResumeExecution[];
66
+ }
67
+ export declare function getSubagentResumeManifest(payload: unknown): SubagentResumeManifest | undefined;
68
+ export declare function requireValidSubagentResumeManifest(payload: unknown): SubagentResumeManifest | undefined;
69
+ export declare function attachSubagentResumeManifest(payload: unknown, manifest: SubagentResumeManifest): object;
70
+ export declare function stripSubagentResumeManifest(payload: unknown): unknown;
71
+ export declare const SUBAGENT_REPLAY_CONTROLLER: unique symbol;
72
+ export type SettledSubagentToolOutput = {
73
+ output: ToolMessage;
74
+ additionalContexts: string[];
75
+ resolvedArgs?: Record<string, unknown>;
76
+ referenceContent?: string;
77
+ };
78
+ export interface SubagentReplayController {
79
+ getResumeManifest?(parentToolCallIds?: ReadonlySet<string>, config?: RunnableConfig): Promise<SubagentResumeManifest | undefined>;
80
+ getSettledOutput(call: ToolCall, config: RunnableConfig): Promise<SettledSubagentToolOutput | undefined>;
81
+ persistSettledOutput(call: ToolCall, config: RunnableConfig, settled: SettledSubagentToolOutput): Promise<void>;
82
+ }
83
+ export type ReplayableSubagentTool = {
84
+ [SUBAGENT_REPLAY_CONTROLLER]?: SubagentReplayController;
85
+ };
@@ -0,0 +1,37 @@
1
+ import type { AgentInputs, ExecutableSubagentConfig, ExecutableSubagentConfigEntry, GraphEdge, GraphSubagentConfig, ResolvedSubagentConfig, ResolvedSubagentConfigEntry, SubagentConfig, SubagentConfigEntry } from '@/types';
2
+ import type { AgentContext } from '@/agents/AgentContext';
3
+ type ChildGraphPlanBase = {
4
+ subjectAgentId: string;
5
+ checkpointNodeId: string;
6
+ agents: AgentInputs[];
7
+ memberInputs: ReadonlyMap<string, AgentInputs>;
8
+ };
9
+ export type ChildGraphPlan = (ChildGraphPlanBase & {
10
+ kind: 'agent';
11
+ }) | (ChildGraphPlanBase & {
12
+ kind: 'graph';
13
+ edges: GraphEdge[];
14
+ entryAgentId: string;
15
+ resultAgentId: string;
16
+ });
17
+ type CreateChildGraphPlanParams = {
18
+ config: ResolvedSubagentConfigEntry;
19
+ executionSuffix: string;
20
+ parentAgentId?: string;
21
+ parentMaxDepth: number;
22
+ keepToolDefinitions: boolean;
23
+ };
24
+ export declare function isGraphSubagentConfig(config: SubagentConfigEntry): config is GraphSubagentConfig;
25
+ export declare function validateGraphSubagentConfig(config: unknown): void;
26
+ /** Normalize eager, self, lazy, and graph subagent entries for advertisement. */
27
+ export declare function normalizeSubagentConfigEntries(configs: SubagentConfigEntry[], parentContext: AgentContext): ExecutableSubagentConfigEntry[];
28
+ /** Resolve self-spawn inputs and validate explicit graph configs. */
29
+ export declare function resolveSubagentConfigEntries(configs: SubagentConfigEntry[], parentContext: AgentContext): ResolvedSubagentConfigEntry[];
30
+ /** Resolve legacy single-agent configs with the original public signature. */
31
+ export declare function resolveSubagentConfigs(configs: SubagentConfig[], parentContext: AgentContext): ResolvedSubagentConfig[];
32
+ /** Normalize legacy single-agent configs while rejecting graph entries. */
33
+ export declare function normalizeSubagentConfigs(configs: SubagentConfig[], parentContext: AgentContext): ExecutableSubagentConfig[];
34
+ export declare function buildChildInputs(config: ResolvedSubagentConfig, childAgentId: string, parentMaxDepth: number, keepToolDefinitions?: boolean): AgentInputs;
35
+ export declare function buildGraphChildInputs(config: GraphSubagentConfig, parentMaxDepth: number, keepToolDefinitions?: boolean): AgentInputs[];
36
+ export declare function createChildGraphPlan({ config, executionSuffix, parentAgentId, parentMaxDepth, keepToolDefinitions, }: CreateChildGraphPlanParams): ChildGraphPlan;
37
+ export {};
@@ -1,2 +1,2 @@
1
- export { SubagentExecutor, filterSubagentResult, resolveSubagentConfigs, buildChildInputs, summarizeEvent, } from './SubagentExecutor';
1
+ export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, filterGraphSubagentResult, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, buildChildInputs, summarizeEvent, } from './SubagentExecutor';
2
2
  export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor';
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_SUBAGENT_MAX_TURNS = 25;
2
+ export declare const SUBAGENT_RECURSION_MULTIPLIER = 3;
3
+ export declare const MAX_GRAPH_SUBAGENT_MEMBERS = 32;
4
+ export declare const MAX_GRAPH_SUBAGENT_TURNS: number;
@@ -53,6 +53,14 @@ export type ToolOutputReferenceRegistryOptions = {
53
53
  */
54
54
  maxActiveRuns?: number;
55
55
  };
56
+ export interface ToolOutputReferenceState {
57
+ entries: Array<{
58
+ key: string;
59
+ value: string;
60
+ }>;
61
+ turnCounter: number;
62
+ warnedNonStringTools: string[];
63
+ }
56
64
  /**
57
65
  * Result of resolving placeholders in tool args.
58
66
  */
@@ -189,6 +197,10 @@ export declare class ToolOutputReferenceRegistry {
189
197
  * completed.
190
198
  */
191
199
  snapshot(runId: string | undefined): ToolOutputResolveView;
200
+ /** Captures the checkpoint-safe state needed to resume one run bucket. */
201
+ snapshotState(runId: string | undefined): ToolOutputReferenceState;
202
+ /** Restores a checkpointed run bucket under the current resume scope. */
203
+ restoreState(runId: string | undefined, state: ToolOutputReferenceState): void;
192
204
  private resolveAgainst;
193
205
  private transform;
194
206
  private replaceInString;