@librechat/agents 3.1.67 → 3.1.68-dev.1

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 (185) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +23 -3
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/common/enum.cjs +16 -1
  4. package/dist/cjs/common/enum.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +91 -0
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/graphs/MultiAgentGraph.cjs +36 -0
  8. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  9. package/dist/cjs/hooks/HookRegistry.cjs +162 -0
  10. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -0
  11. package/dist/cjs/hooks/executeHooks.cjs +276 -0
  12. package/dist/cjs/hooks/executeHooks.cjs.map +1 -0
  13. package/dist/cjs/hooks/matchers.cjs +256 -0
  14. package/dist/cjs/hooks/matchers.cjs.map +1 -0
  15. package/dist/cjs/hooks/types.cjs +27 -0
  16. package/dist/cjs/hooks/types.cjs.map +1 -0
  17. package/dist/cjs/main.cjs +54 -0
  18. package/dist/cjs/main.cjs.map +1 -1
  19. package/dist/cjs/messages/format.cjs +74 -12
  20. package/dist/cjs/messages/format.cjs.map +1 -1
  21. package/dist/cjs/run.cjs +111 -0
  22. package/dist/cjs/run.cjs.map +1 -1
  23. package/dist/cjs/summarization/index.cjs +41 -0
  24. package/dist/cjs/summarization/index.cjs.map +1 -1
  25. package/dist/cjs/summarization/node.cjs +165 -19
  26. package/dist/cjs/summarization/node.cjs.map +1 -1
  27. package/dist/cjs/tools/BashExecutor.cjs +165 -0
  28. package/dist/cjs/tools/BashExecutor.cjs.map +1 -0
  29. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +287 -0
  30. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -0
  31. package/dist/cjs/tools/CodeExecutor.cjs +0 -9
  32. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  33. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +7 -23
  34. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  35. package/dist/cjs/tools/ReadFile.cjs +43 -0
  36. package/dist/cjs/tools/ReadFile.cjs.map +1 -0
  37. package/dist/cjs/tools/SkillTool.cjs +50 -0
  38. package/dist/cjs/tools/SkillTool.cjs.map +1 -0
  39. package/dist/cjs/tools/SubagentTool.cjs +92 -0
  40. package/dist/cjs/tools/SubagentTool.cjs.map +1 -0
  41. package/dist/cjs/tools/ToolNode.cjs +304 -140
  42. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  43. package/dist/cjs/tools/ToolSearch.cjs +2 -13
  44. package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
  45. package/dist/cjs/tools/skillCatalog.cjs +84 -0
  46. package/dist/cjs/tools/skillCatalog.cjs.map +1 -0
  47. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +511 -0
  48. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -0
  49. package/dist/esm/agents/AgentContext.mjs +23 -3
  50. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  51. package/dist/esm/common/enum.mjs +15 -2
  52. package/dist/esm/common/enum.mjs.map +1 -1
  53. package/dist/esm/graphs/Graph.mjs +91 -0
  54. package/dist/esm/graphs/Graph.mjs.map +1 -1
  55. package/dist/esm/graphs/MultiAgentGraph.mjs +36 -0
  56. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  57. package/dist/esm/hooks/HookRegistry.mjs +160 -0
  58. package/dist/esm/hooks/HookRegistry.mjs.map +1 -0
  59. package/dist/esm/hooks/executeHooks.mjs +273 -0
  60. package/dist/esm/hooks/executeHooks.mjs.map +1 -0
  61. package/dist/esm/hooks/matchers.mjs +251 -0
  62. package/dist/esm/hooks/matchers.mjs.map +1 -0
  63. package/dist/esm/hooks/types.mjs +25 -0
  64. package/dist/esm/hooks/types.mjs.map +1 -0
  65. package/dist/esm/main.mjs +13 -2
  66. package/dist/esm/main.mjs.map +1 -1
  67. package/dist/esm/messages/format.mjs +66 -4
  68. package/dist/esm/messages/format.mjs.map +1 -1
  69. package/dist/esm/run.mjs +111 -0
  70. package/dist/esm/run.mjs.map +1 -1
  71. package/dist/esm/summarization/index.mjs +41 -1
  72. package/dist/esm/summarization/index.mjs.map +1 -1
  73. package/dist/esm/summarization/node.mjs +165 -19
  74. package/dist/esm/summarization/node.mjs.map +1 -1
  75. package/dist/esm/tools/BashExecutor.mjs +159 -0
  76. package/dist/esm/tools/BashExecutor.mjs.map +1 -0
  77. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +278 -0
  78. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -0
  79. package/dist/esm/tools/CodeExecutor.mjs +0 -9
  80. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  81. package/dist/esm/tools/ProgrammaticToolCalling.mjs +8 -24
  82. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  83. package/dist/esm/tools/ReadFile.mjs +38 -0
  84. package/dist/esm/tools/ReadFile.mjs.map +1 -0
  85. package/dist/esm/tools/SkillTool.mjs +45 -0
  86. package/dist/esm/tools/SkillTool.mjs.map +1 -0
  87. package/dist/esm/tools/SubagentTool.mjs +85 -0
  88. package/dist/esm/tools/SubagentTool.mjs.map +1 -0
  89. package/dist/esm/tools/ToolNode.mjs +306 -142
  90. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  91. package/dist/esm/tools/ToolSearch.mjs +3 -14
  92. package/dist/esm/tools/ToolSearch.mjs.map +1 -1
  93. package/dist/esm/tools/skillCatalog.mjs +82 -0
  94. package/dist/esm/tools/skillCatalog.mjs.map +1 -0
  95. package/dist/esm/tools/subagent/SubagentExecutor.mjs +505 -0
  96. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -0
  97. package/dist/types/agents/AgentContext.d.ts +6 -0
  98. package/dist/types/common/enum.d.ts +10 -2
  99. package/dist/types/graphs/Graph.d.ts +2 -0
  100. package/dist/types/graphs/MultiAgentGraph.d.ts +12 -0
  101. package/dist/types/hooks/HookRegistry.d.ts +56 -0
  102. package/dist/types/hooks/executeHooks.d.ts +79 -0
  103. package/dist/types/hooks/index.d.ts +6 -0
  104. package/dist/types/hooks/matchers.d.ts +95 -0
  105. package/dist/types/hooks/types.d.ts +320 -0
  106. package/dist/types/index.d.ts +8 -0
  107. package/dist/types/messages/format.d.ts +2 -1
  108. package/dist/types/run.d.ts +1 -0
  109. package/dist/types/summarization/index.d.ts +2 -0
  110. package/dist/types/summarization/node.d.ts +2 -0
  111. package/dist/types/tools/BashExecutor.d.ts +45 -0
  112. package/dist/types/tools/BashProgrammaticToolCalling.d.ts +72 -0
  113. package/dist/types/tools/ProgrammaticToolCalling.d.ts +4 -9
  114. package/dist/types/tools/ReadFile.d.ts +28 -0
  115. package/dist/types/tools/SkillTool.d.ts +40 -0
  116. package/dist/types/tools/SubagentTool.d.ts +36 -0
  117. package/dist/types/tools/ToolNode.d.ts +24 -2
  118. package/dist/types/tools/ToolSearch.d.ts +2 -2
  119. package/dist/types/tools/skillCatalog.d.ts +19 -0
  120. package/dist/types/tools/subagent/SubagentExecutor.d.ts +137 -0
  121. package/dist/types/tools/subagent/index.d.ts +2 -0
  122. package/dist/types/types/graph.d.ts +61 -2
  123. package/dist/types/types/index.d.ts +1 -0
  124. package/dist/types/types/run.d.ts +20 -0
  125. package/dist/types/types/skill.d.ts +9 -0
  126. package/dist/types/types/tools.d.ts +38 -10
  127. package/package.json +5 -1
  128. package/src/agents/AgentContext.ts +26 -2
  129. package/src/common/enum.ts +15 -1
  130. package/src/graphs/Graph.ts +113 -0
  131. package/src/graphs/MultiAgentGraph.ts +39 -0
  132. package/src/graphs/__tests__/MultiAgentGraph.test.ts +91 -0
  133. package/src/hooks/HookRegistry.ts +208 -0
  134. package/src/hooks/__tests__/HookRegistry.test.ts +190 -0
  135. package/src/hooks/__tests__/compactHooks.test.ts +214 -0
  136. package/src/hooks/__tests__/executeHooks.test.ts +1013 -0
  137. package/src/hooks/__tests__/integration.test.ts +337 -0
  138. package/src/hooks/__tests__/matchers.test.ts +238 -0
  139. package/src/hooks/__tests__/toolHooks.test.ts +669 -0
  140. package/src/hooks/executeHooks.ts +375 -0
  141. package/src/hooks/index.ts +57 -0
  142. package/src/hooks/matchers.ts +280 -0
  143. package/src/hooks/types.ts +404 -0
  144. package/src/index.ts +10 -0
  145. package/src/messages/format.ts +74 -4
  146. package/src/messages/formatAgentMessages.skills.test.ts +334 -0
  147. package/src/run.ts +126 -0
  148. package/src/scripts/multi-agent-subagent.ts +246 -0
  149. package/src/scripts/programmatic_exec.ts +1 -10
  150. package/src/scripts/subagent-event-driven-debug.ts +190 -0
  151. package/src/scripts/subagent-tools-debug.ts +160 -0
  152. package/src/scripts/test_code_api.ts +0 -7
  153. package/src/scripts/tool_search.ts +1 -10
  154. package/src/specs/subagent.test.ts +305 -0
  155. package/src/summarization/__tests__/node.test.ts +42 -0
  156. package/src/summarization/__tests__/trigger.test.ts +100 -1
  157. package/src/summarization/index.ts +47 -0
  158. package/src/summarization/node.ts +202 -24
  159. package/src/tools/BashExecutor.ts +193 -0
  160. package/src/tools/BashProgrammaticToolCalling.ts +381 -0
  161. package/src/tools/CodeExecutor.ts +0 -11
  162. package/src/tools/ProgrammaticToolCalling.ts +4 -29
  163. package/src/tools/ReadFile.ts +39 -0
  164. package/src/tools/SkillTool.ts +46 -0
  165. package/src/tools/SubagentTool.ts +100 -0
  166. package/src/tools/ToolNode.ts +391 -169
  167. package/src/tools/ToolSearch.ts +3 -19
  168. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +7 -8
  169. package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -1
  170. package/src/tools/__tests__/ReadFile.test.ts +44 -0
  171. package/src/tools/__tests__/SkillTool.test.ts +442 -0
  172. package/src/tools/__tests__/SubagentExecutor.test.ts +1148 -0
  173. package/src/tools/__tests__/SubagentTool.test.ts +149 -0
  174. package/src/tools/__tests__/ToolNode.session.test.ts +12 -12
  175. package/src/tools/__tests__/ToolSearch.integration.test.ts +7 -8
  176. package/src/tools/__tests__/skillCatalog.test.ts +161 -0
  177. package/src/tools/__tests__/subagentHooks.test.ts +215 -0
  178. package/src/tools/skillCatalog.ts +126 -0
  179. package/src/tools/subagent/SubagentExecutor.ts +676 -0
  180. package/src/tools/subagent/index.ts +13 -0
  181. package/src/types/graph.ts +80 -1
  182. package/src/types/index.ts +1 -0
  183. package/src/types/run.ts +20 -0
  184. package/src/types/skill.ts +11 -0
  185. package/src/types/tools.ts +41 -10
@@ -18,7 +18,13 @@ import type {
18
18
  import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
19
19
  import type { ChatGenerationChunk } from '@langchain/core/outputs';
20
20
  import type { GoogleAIToolType } from '@langchain/google-common';
21
- import type { ToolMap, ToolEndEvent, GenericTool, LCTool } from '@/types/tools';
21
+ import type {
22
+ ToolMap,
23
+ ToolEndEvent,
24
+ GenericTool,
25
+ LCTool,
26
+ ToolExecuteBatchRequest,
27
+ } from '@/types/tools';
22
28
  import type { Providers, Callback, GraphNodeKeys } from '@/common';
23
29
  import type { StandardGraph, MultiAgentGraph } from '@/graphs';
24
30
  import type { ClientOptions } from '@/types/llm';
@@ -105,7 +111,9 @@ export interface EventHandler {
105
111
  | SummarizeStartEvent
106
112
  | SummarizeDeltaEvent
107
113
  | SummarizeCompleteEvent
114
+ | SubagentUpdateEvent
108
115
  | AgentLogEvent
116
+ | ToolExecuteBatchRequest
109
117
  | { result: ToolEndEvent },
110
118
  metadata?: Record<string, unknown>,
111
119
  graph?: StandardGraph | MultiAgentGraph
@@ -388,6 +396,73 @@ export type MultiAgentGraphInput = StandardGraphInput & {
388
396
  edges: GraphEdge[];
389
397
  };
390
398
 
399
+ /** Configuration for a subagent type that can be spawned by a parent agent. */
400
+ export type SubagentConfig = {
401
+ /** Identifier used in the tool's `subagent_type` enum (e.g. 'researcher', 'coder'). */
402
+ type: string;
403
+ /** Human-readable display name. */
404
+ name: string;
405
+ /** What this subagent specializes in — shown to the LLM. */
406
+ description: string;
407
+ /** Full agent config for the child graph. Omit when `self` is true. */
408
+ agentInputs?: AgentInputs;
409
+ /** When true, reuse the parent's AgentInputs (context isolation without separate config). */
410
+ self?: boolean;
411
+ /** Max AGENT→TOOLS cycles before forced stop (default: 25). */
412
+ maxTurns?: number;
413
+ /** Allow this subagent to spawn its own subagents (default: false). */
414
+ allowNested?: boolean;
415
+ };
416
+
417
+ /** SubagentConfig with agentInputs guaranteed present (self-spawn resolved). */
418
+ export type ResolvedSubagentConfig = SubagentConfig & {
419
+ agentInputs: AgentInputs;
420
+ };
421
+
422
+ /** Lifecycle phase carried on {@link SubagentUpdateEvent}. */
423
+ export type SubagentUpdatePhase =
424
+ | 'start'
425
+ | 'run_step'
426
+ | 'run_step_delta'
427
+ | 'run_step_completed'
428
+ | 'message_delta'
429
+ | 'reasoning_delta'
430
+ | 'stop'
431
+ | 'error';
432
+
433
+ /**
434
+ * Wrapper event emitted when a subagent's child graph dispatches activity.
435
+ * Lets hosts show subagent progress in a UI surface separate from the parent
436
+ * conversation without having to untangle events by agent ID.
437
+ */
438
+ export interface SubagentUpdateEvent {
439
+ /** Parent run ID. */
440
+ runId: string;
441
+ /** Child run ID (unique per subagent execution). */
442
+ subagentRunId: string;
443
+ /**
444
+ * Parent-side `tool_call_id` for the `subagent` tool invocation that
445
+ * triggered this run. Stable for the duration of the child; lets hosts
446
+ * correlate updates deterministically instead of inferring by ordering.
447
+ * Omitted when the executor was invoked outside of a tool-call context.
448
+ */
449
+ parentToolCallId?: string;
450
+ /** Subagent `type` identifier from the SubagentConfig. */
451
+ subagentType: string;
452
+ /** Child agent ID assigned to this subagent execution. */
453
+ subagentAgentId: string;
454
+ /** Parent agent ID that spawned this subagent. */
455
+ parentAgentId?: string;
456
+ /** Lifecycle phase carried by this update. */
457
+ phase: SubagentUpdatePhase;
458
+ /** Underlying event payload (shape depends on phase). */
459
+ data?: unknown;
460
+ /** Short human-readable description. Hosts can render this directly. */
461
+ label?: string;
462
+ /** ISO timestamp for ordering / display. */
463
+ timestamp: string;
464
+ }
465
+
391
466
  export interface AgentInputs {
392
467
  agentId: string;
393
468
  /** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
@@ -431,6 +506,10 @@ export interface AgentInputs {
431
506
  maxToolResultChars?: number;
432
507
  /** Pre-computed tool schema token count (from cache). Skips recalculation when provided. */
433
508
  toolSchemaTokens?: number;
509
+ /** Subagent configurations for hierarchical delegation. Each defines a child agent type. */
510
+ subagentConfigs?: SubagentConfig[];
511
+ /** Maximum subagent nesting depth. Default 1 means top-level agents can spawn subagents but subagents cannot nest further. */
512
+ maxSubagentDepth?: number;
434
513
  }
435
514
 
436
515
  export interface ContextPruningConfig {
@@ -2,6 +2,7 @@
2
2
  export * from './graph';
3
3
  export * from './llm';
4
4
  export * from './run';
5
+ export * from './skill';
5
6
  export * from './stream';
6
7
  export * from './tools';
7
8
  export * from './summarize';
package/src/types/run.ts CHANGED
@@ -11,6 +11,8 @@ import type * as s from '@/types/stream';
11
11
  import type * as e from '@/common/enum';
12
12
  import type * as g from '@/types/graph';
13
13
  import type * as l from '@/types/llm';
14
+ import type { ToolSessionMap } from '@/types/tools';
15
+ import type { HookRegistry } from '@/hooks';
14
16
 
15
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
18
  export type ZodObjectAny = z.ZodObject<any, any, any, any>;
@@ -112,6 +114,18 @@ export type RunConfig = {
112
114
  runId: string;
113
115
  graphConfig: LegacyGraphConfig | StandardGraphConfig | MultiAgentGraphConfig;
114
116
  customHandlers?: Record<string, g.EventHandler>;
117
+ /**
118
+ * Pre-constructed hook registry for this run. Hooks fire at lifecycle
119
+ * points in `processStream` (RunStart, UserPromptSubmit, Stop,
120
+ * StopFailure) and around tool calls (PreToolUse, PostToolUse,
121
+ * PostToolUseFailure, PermissionDenied).
122
+ *
123
+ * Pass `undefined` (the default) to skip all hook dispatch. When a
124
+ * registry is provided, the run attaches it to the `Graph` so internal
125
+ * nodes can fire hooks too, and clears the session in the `finally`
126
+ * block to prevent leaks.
127
+ */
128
+ hooks?: HookRegistry;
115
129
  returnContent?: boolean;
116
130
  tokenCounter?: TokenCounter;
117
131
  indexTokenCountMap?: Record<string, number>;
@@ -126,6 +140,12 @@ export type RunConfig = {
126
140
  calibrationRatio?: number;
127
141
  /** Skip post-stream cleanup (clearHeavyState) — useful for tests that inspect graph state after processStream */
128
142
  skipCleanup?: boolean;
143
+ /**
144
+ * Initial session state to seed the Graph's ToolSessionMap.
145
+ * Used to carry over code environment sessions from skill file priming
146
+ * at run start, so ToolNode can inject session_id + files into tool calls.
147
+ */
148
+ initialSessions?: ToolSessionMap;
129
149
  };
130
150
 
131
151
  export type ProvidedCallbacks =
@@ -0,0 +1,11 @@
1
+ // src/types/skill.ts
2
+
3
+ /** Minimal skill metadata for catalog assembly. The host provides these from its own data layer. */
4
+ export type SkillCatalogEntry = {
5
+ /** Kebab-case identifier (what the model passes to SkillTool) */
6
+ name: string;
7
+ /** One-line description for the catalog listing */
8
+ description: string;
9
+ /** Optional human-readable label (UI only, not shown to model) */
10
+ displayTitle?: string;
11
+ };
@@ -2,8 +2,8 @@
2
2
  import type { StructuredToolInterface } from '@langchain/core/tools';
3
3
  import type { RunnableToolLike } from '@langchain/core/runnables';
4
4
  import type { ToolCall } from '@langchain/core/messages/tool';
5
- import type { ToolErrorData } from './stream';
6
- import { EnvVar } from '@/common';
5
+ import type { HookRegistry } from '@/hooks';
6
+ import type { MessageContentComplex, ToolErrorData } from './stream';
7
7
 
8
8
  /** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
9
9
  export type CustomToolCall = {
@@ -49,6 +49,12 @@ export type ToolNodeOptions = {
49
49
  agentId?: string;
50
50
  /** Tool names that must be executed directly (via runTool) even in event-driven mode (e.g., graph-managed handoff tools) */
51
51
  directToolNames?: Set<string>;
52
+ /**
53
+ * Hook registry for PreToolUse/PostToolUse lifecycle hooks.
54
+ * Only fires for event-driven tool calls (`dispatchToolEvents`). Tools
55
+ * routed through `directToolNames` bypass hook dispatch entirely.
56
+ */
57
+ hookRegistry?: HookRegistry;
52
58
  /** Max context tokens for the agent — used to compute tool result truncation limits. */
53
59
  maxContextTokens?: number;
54
60
  /**
@@ -81,9 +87,7 @@ export type CodeExecutionToolParams =
81
87
  | {
82
88
  session_id?: string;
83
89
  user_id?: string;
84
- apiKey?: string;
85
90
  files?: CodeEnvFile[];
86
- [EnvVar.CODE_API_KEY]?: string;
87
91
  };
88
92
 
89
93
  export type FileRef = {
@@ -186,6 +190,26 @@ export type ToolExecuteBatchRequest = {
186
190
  reject: (error: Error) => void;
187
191
  };
188
192
 
193
+ /**
194
+ * A message injected into graph state by any tool execution handler.
195
+ * Generic mechanism: any tool returning `injectedMessages` in its `ToolExecuteResult`
196
+ * will have these appended to state after the ToolMessage for this call.
197
+ */
198
+ export type InjectedMessage = {
199
+ /** 'user' for skill body injection, 'system' for context hints.
200
+ * Both are converted to HumanMessage at runtime; the original role
201
+ * is preserved in additional_kwargs.role. */
202
+ role: 'user' | 'system';
203
+ /** Message content: string for simple text, array for complex multi-part content */
204
+ content: string | MessageContentComplex[];
205
+ /** When true, the message is framework-internal: not shown in UI, not counted as a user turn */
206
+ isMeta?: boolean;
207
+ /** Origin tag for downstream consumers (UI, pruner, compaction) */
208
+ source?: 'skill' | 'hook' | 'system';
209
+ /** Only set when source is 'skill', for compaction preservation */
210
+ skillName?: string;
211
+ };
212
+
189
213
  /** Result for a single tool call in event-driven execution */
190
214
  export type ToolExecuteResult = {
191
215
  /** Matches ToolCallRequest.id */
@@ -198,6 +222,13 @@ export type ToolExecuteResult = {
198
222
  status: 'success' | 'error';
199
223
  /** Error message if status is 'error' */
200
224
  errorMessage?: string;
225
+ /**
226
+ * Messages to inject into graph state after the ToolMessage for this call.
227
+ * Placed after tool results to respect provider message ordering (tool_call -> tool_result adjacency).
228
+ * The host's message formatter may merge injected user messages with the preceding tool_result turn.
229
+ * Generic mechanism: any tool execution handler can use this.
230
+ */
231
+ injectedMessages?: InjectedMessage[];
201
232
  };
202
233
 
203
234
  /** Map of tool names to tool definitions */
@@ -213,7 +244,6 @@ export type McpNameFormat = 'full' | 'base';
213
244
 
214
245
  /** Parameters for creating a Tool Search tool */
215
246
  export type ToolSearchParams = {
216
- apiKey?: string;
217
247
  toolRegistry?: LCToolRegistry;
218
248
  onlyDeferred?: boolean;
219
249
  baseUrl?: string;
@@ -223,7 +253,6 @@ export type ToolSearchParams = {
223
253
  mcpServer?: string | string[];
224
254
  /** Format for MCP tool names: 'full' (tool_mcp_server) or 'base' (tool only). Default: 'full' */
225
255
  mcpNameFormat?: McpNameFormat;
226
- [key: string]: unknown;
227
256
  };
228
257
 
229
258
  /** Simplified tool metadata for search purposes */
@@ -318,12 +347,16 @@ export type ProgrammaticExecutionArtifact = {
318
347
  files?: FileRefs;
319
348
  };
320
349
 
350
+ /** Parameters for creating a bash execution tool (same API as CodeExecutor, bash-only) */
351
+ export type BashExecutionToolParams = CodeExecutionToolParams;
352
+
353
+ /** Parameters for creating a bash programmatic tool calling tool (same API as PTC, bash-only) */
354
+ export type BashProgrammaticToolCallingParams = ProgrammaticToolCallingParams;
355
+
321
356
  /**
322
357
  * Initialization parameters for the PTC tool
323
358
  */
324
359
  export type ProgrammaticToolCallingParams = {
325
- /** Code API key (or use CODE_API_KEY env var) */
326
- apiKey?: string;
327
360
  /** Code API base URL (or use CODE_BASEURL env var) */
328
361
  baseUrl?: string;
329
362
  /** Safety limit for round-trips (default: 20) */
@@ -332,8 +365,6 @@ export type ProgrammaticToolCallingParams = {
332
365
  proxy?: string;
333
366
  /** Enable debug logging (or set PTC_DEBUG=true env var) */
334
367
  debug?: boolean;
335
- /** Environment variable key for API key */
336
- [key: string]: unknown;
337
368
  };
338
369
 
339
370
  // ============================================================================