@strands-agents/sdk 1.2.0 → 1.4.0

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 (231) hide show
  1. package/README.md +13 -13
  2. package/dist/src/__fixtures__/test-sandbox.node.d.ts +15 -0
  3. package/dist/src/__fixtures__/test-sandbox.node.d.ts.map +1 -0
  4. package/dist/src/__fixtures__/test-sandbox.node.js +22 -0
  5. package/dist/src/__fixtures__/test-sandbox.node.js.map +1 -0
  6. package/dist/src/__tests__/mcp.test.js +14 -14
  7. package/dist/src/__tests__/mcp.test.js.map +1 -1
  8. package/dist/src/agent/__tests__/agent.test.js +195 -0
  9. package/dist/src/agent/__tests__/agent.test.js.map +1 -1
  10. package/dist/src/agent/__tests__/printer.test.js +58 -18
  11. package/dist/src/agent/__tests__/printer.test.js.map +1 -1
  12. package/dist/src/agent/__tests__/tool-caller.test.d.ts +2 -0
  13. package/dist/src/agent/__tests__/tool-caller.test.d.ts.map +1 -0
  14. package/dist/src/agent/__tests__/tool-caller.test.js +459 -0
  15. package/dist/src/agent/__tests__/tool-caller.test.js.map +1 -0
  16. package/dist/src/agent/agent.d.ts +68 -2
  17. package/dist/src/agent/agent.d.ts.map +1 -1
  18. package/dist/src/agent/agent.js +125 -66
  19. package/dist/src/agent/agent.js.map +1 -1
  20. package/dist/src/agent/printer.d.ts +14 -1
  21. package/dist/src/agent/printer.d.ts.map +1 -1
  22. package/dist/src/agent/printer.js +33 -5
  23. package/dist/src/agent/printer.js.map +1 -1
  24. package/dist/src/agent/tool-caller.d.ts +149 -0
  25. package/dist/src/agent/tool-caller.d.ts.map +1 -0
  26. package/dist/src/agent/tool-caller.js +198 -0
  27. package/dist/src/agent/tool-caller.js.map +1 -0
  28. package/dist/src/errors.d.ts +17 -0
  29. package/dist/src/errors.d.ts.map +1 -1
  30. package/dist/src/errors.js +21 -0
  31. package/dist/src/errors.js.map +1 -1
  32. package/dist/src/hooks/types.d.ts +2 -0
  33. package/dist/src/hooks/types.d.ts.map +1 -1
  34. package/dist/src/hooks/types.js +2 -0
  35. package/dist/src/hooks/types.js.map +1 -1
  36. package/dist/src/index.d.ts +10 -3
  37. package/dist/src/index.d.ts.map +1 -1
  38. package/dist/src/index.js +6 -1
  39. package/dist/src/index.js.map +1 -1
  40. package/dist/src/interventions/__tests__/handler.test.d.ts +2 -0
  41. package/dist/src/interventions/__tests__/handler.test.d.ts.map +1 -0
  42. package/dist/src/interventions/__tests__/handler.test.js +35 -0
  43. package/dist/src/interventions/__tests__/handler.test.js.map +1 -0
  44. package/dist/src/interventions/__tests__/registry.test.d.ts +2 -0
  45. package/dist/src/interventions/__tests__/registry.test.d.ts.map +1 -0
  46. package/dist/src/interventions/__tests__/registry.test.js +692 -0
  47. package/dist/src/interventions/__tests__/registry.test.js.map +1 -0
  48. package/dist/src/interventions/actions.d.ts +186 -0
  49. package/dist/src/interventions/actions.d.ts.map +1 -0
  50. package/dist/src/interventions/actions.js +56 -0
  51. package/dist/src/interventions/actions.js.map +1 -0
  52. package/dist/src/interventions/handler.d.ts +43 -0
  53. package/dist/src/interventions/handler.d.ts.map +1 -0
  54. package/dist/src/interventions/handler.js +41 -0
  55. package/dist/src/interventions/handler.js.map +1 -0
  56. package/dist/src/interventions/index.d.ts +12 -0
  57. package/dist/src/interventions/index.d.ts.map +1 -0
  58. package/dist/src/interventions/index.js +4 -0
  59. package/dist/src/interventions/index.js.map +1 -0
  60. package/dist/src/interventions/registry.d.ts +36 -0
  61. package/dist/src/interventions/registry.d.ts.map +1 -0
  62. package/dist/src/interventions/registry.js +252 -0
  63. package/dist/src/interventions/registry.js.map +1 -0
  64. package/dist/src/mcp.d.ts +20 -15
  65. package/dist/src/mcp.d.ts.map +1 -1
  66. package/dist/src/mcp.js +15 -8
  67. package/dist/src/mcp.js.map +1 -1
  68. package/dist/src/models/__tests__/anthropic.test.js +72 -8
  69. package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
  70. package/dist/src/models/__tests__/bedrock.test.js +142 -0
  71. package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
  72. package/dist/src/models/anthropic.d.ts +10 -0
  73. package/dist/src/models/anthropic.d.ts.map +1 -1
  74. package/dist/src/models/anthropic.js +24 -8
  75. package/dist/src/models/anthropic.js.map +1 -1
  76. package/dist/src/models/bedrock.d.ts +26 -1
  77. package/dist/src/models/bedrock.d.ts.map +1 -1
  78. package/dist/src/models/bedrock.js +22 -4
  79. package/dist/src/models/bedrock.js.map +1 -1
  80. package/dist/src/models/openai/__tests__/chat.test.js +2 -10
  81. package/dist/src/models/openai/__tests__/chat.test.js.map +1 -1
  82. package/dist/src/models/openai/__tests__/errors.test.d.ts +2 -0
  83. package/dist/src/models/openai/__tests__/errors.test.d.ts.map +1 -0
  84. package/dist/src/models/openai/__tests__/errors.test.js +30 -0
  85. package/dist/src/models/openai/__tests__/errors.test.js.map +1 -0
  86. package/dist/src/models/openai/__tests__/mantle.test.d.ts +2 -0
  87. package/dist/src/models/openai/__tests__/mantle.test.d.ts.map +1 -0
  88. package/dist/src/models/openai/__tests__/mantle.test.js +189 -0
  89. package/dist/src/models/openai/__tests__/mantle.test.js.map +1 -0
  90. package/dist/src/models/openai/__tests__/responses.test.js +0 -19
  91. package/dist/src/models/openai/__tests__/responses.test.js.map +1 -1
  92. package/dist/src/models/openai/errors.d.ts.map +1 -1
  93. package/dist/src/models/openai/errors.js +5 -3
  94. package/dist/src/models/openai/errors.js.map +1 -1
  95. package/dist/src/models/openai/index.d.ts +1 -0
  96. package/dist/src/models/openai/index.d.ts.map +1 -1
  97. package/dist/src/models/openai/mantle.d.ts +77 -0
  98. package/dist/src/models/openai/mantle.d.ts.map +1 -0
  99. package/dist/src/models/openai/mantle.js +83 -0
  100. package/dist/src/models/openai/mantle.js.map +1 -0
  101. package/dist/src/models/openai/model.d.ts.map +1 -1
  102. package/dist/src/models/openai/model.js +29 -1
  103. package/dist/src/models/openai/model.js.map +1 -1
  104. package/dist/src/models/openai/types.d.ts +11 -0
  105. package/dist/src/models/openai/types.d.ts.map +1 -1
  106. package/dist/src/multiagent/__tests__/nodes.test.js +50 -0
  107. package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -1
  108. package/dist/src/multiagent/nodes.d.ts +23 -2
  109. package/dist/src/multiagent/nodes.d.ts.map +1 -1
  110. package/dist/src/multiagent/nodes.js +18 -4
  111. package/dist/src/multiagent/nodes.js.map +1 -1
  112. package/dist/src/registry/__tests__/tool-registry.test.js +50 -1
  113. package/dist/src/registry/__tests__/tool-registry.test.js.map +1 -1
  114. package/dist/src/registry/tool-registry.d.ts +13 -0
  115. package/dist/src/registry/tool-registry.d.ts.map +1 -1
  116. package/dist/src/registry/tool-registry.js +35 -1
  117. package/dist/src/registry/tool-registry.js.map +1 -1
  118. package/dist/src/sandbox/__tests__/posix-shell.test.node.d.ts +2 -0
  119. package/dist/src/sandbox/__tests__/posix-shell.test.node.d.ts.map +1 -0
  120. package/dist/src/sandbox/__tests__/posix-shell.test.node.js +252 -0
  121. package/dist/src/sandbox/__tests__/posix-shell.test.node.js.map +1 -0
  122. package/dist/src/sandbox/base.d.ts +138 -0
  123. package/dist/src/sandbox/base.d.ts.map +1 -0
  124. package/dist/src/sandbox/base.js +84 -0
  125. package/dist/src/sandbox/base.js.map +1 -0
  126. package/dist/src/sandbox/constants.d.ts +7 -0
  127. package/dist/src/sandbox/constants.d.ts.map +1 -0
  128. package/dist/src/sandbox/constants.js +7 -0
  129. package/dist/src/sandbox/constants.js.map +1 -0
  130. package/dist/src/sandbox/posix-shell.d.ts +32 -0
  131. package/dist/src/sandbox/posix-shell.d.ts.map +1 -0
  132. package/dist/src/sandbox/posix-shell.js +78 -0
  133. package/dist/src/sandbox/posix-shell.js.map +1 -0
  134. package/dist/src/sandbox/stream-process.d.ts +32 -0
  135. package/dist/src/sandbox/stream-process.d.ts.map +1 -0
  136. package/dist/src/sandbox/stream-process.js +160 -0
  137. package/dist/src/sandbox/stream-process.js.map +1 -0
  138. package/dist/src/sandbox/types.d.ts +57 -0
  139. package/dist/src/sandbox/types.d.ts.map +1 -0
  140. package/dist/src/sandbox/types.js +8 -0
  141. package/dist/src/sandbox/types.js.map +1 -0
  142. package/dist/src/telemetry/__tests__/meter.test.js +11 -0
  143. package/dist/src/telemetry/__tests__/meter.test.js.map +1 -1
  144. package/dist/src/telemetry/meter.d.ts +10 -6
  145. package/dist/src/telemetry/meter.d.ts.map +1 -1
  146. package/dist/src/telemetry/meter.js +16 -3
  147. package/dist/src/telemetry/meter.js.map +1 -1
  148. package/dist/src/tsconfig.tsbuildinfo +1 -1
  149. package/dist/src/types/__tests__/messages.test.js +28 -0
  150. package/dist/src/types/__tests__/messages.test.js.map +1 -1
  151. package/dist/src/types/agent.d.ts +51 -0
  152. package/dist/src/types/agent.d.ts.map +1 -1
  153. package/dist/src/types/agent.js.map +1 -1
  154. package/dist/src/types/lifecycle-observer.d.ts +18 -0
  155. package/dist/src/types/lifecycle-observer.d.ts.map +1 -0
  156. package/dist/src/types/lifecycle-observer.js +2 -0
  157. package/dist/src/types/lifecycle-observer.js.map +1 -0
  158. package/dist/src/types/messages.d.ts +20 -2
  159. package/dist/src/types/messages.d.ts.map +1 -1
  160. package/dist/src/types/messages.js +9 -0
  161. package/dist/src/types/messages.js.map +1 -1
  162. package/dist/src/utils/shell-quote.d.ts +12 -0
  163. package/dist/src/utils/shell-quote.d.ts.map +1 -0
  164. package/dist/src/utils/shell-quote.js +14 -0
  165. package/dist/src/utils/shell-quote.js.map +1 -0
  166. package/dist/src/vended-interventions/hitl/__tests__/hitl.test.d.ts +2 -0
  167. package/dist/src/vended-interventions/hitl/__tests__/hitl.test.d.ts.map +1 -0
  168. package/dist/src/vended-interventions/hitl/__tests__/hitl.test.js +358 -0
  169. package/dist/src/vended-interventions/hitl/__tests__/hitl.test.js.map +1 -0
  170. package/dist/src/vended-interventions/hitl/hitl.d.ts +115 -0
  171. package/dist/src/vended-interventions/hitl/hitl.d.ts.map +1 -0
  172. package/dist/src/vended-interventions/hitl/hitl.js +138 -0
  173. package/dist/src/vended-interventions/hitl/hitl.js.map +1 -0
  174. package/dist/src/vended-interventions/hitl/index.d.ts +24 -0
  175. package/dist/src/vended-interventions/hitl/index.d.ts.map +1 -0
  176. package/dist/src/vended-interventions/hitl/index.js +23 -0
  177. package/dist/src/vended-interventions/hitl/index.js.map +1 -0
  178. package/dist/src/vended-interventions/steering/__tests__/handler.test.d.ts +2 -0
  179. package/dist/src/vended-interventions/steering/__tests__/handler.test.d.ts.map +1 -0
  180. package/dist/src/vended-interventions/steering/__tests__/handler.test.js +163 -0
  181. package/dist/src/vended-interventions/steering/__tests__/handler.test.js.map +1 -0
  182. package/dist/src/vended-interventions/steering/__tests__/llm.test.d.ts +2 -0
  183. package/dist/src/vended-interventions/steering/__tests__/llm.test.d.ts.map +1 -0
  184. package/dist/src/vended-interventions/steering/__tests__/llm.test.js +60 -0
  185. package/dist/src/vended-interventions/steering/__tests__/llm.test.js.map +1 -0
  186. package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.d.ts +2 -0
  187. package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.d.ts.map +1 -0
  188. package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.js +94 -0
  189. package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.js.map +1 -0
  190. package/dist/src/vended-interventions/steering/handlers/handler.d.ts +64 -0
  191. package/dist/src/vended-interventions/steering/handlers/handler.d.ts.map +1 -0
  192. package/dist/src/vended-interventions/steering/handlers/handler.js +71 -0
  193. package/dist/src/vended-interventions/steering/handlers/handler.js.map +1 -0
  194. package/dist/src/vended-interventions/steering/handlers/llm.d.ts +72 -0
  195. package/dist/src/vended-interventions/steering/handlers/llm.d.ts.map +1 -0
  196. package/dist/src/vended-interventions/steering/handlers/llm.js +177 -0
  197. package/dist/src/vended-interventions/steering/handlers/llm.js.map +1 -0
  198. package/dist/src/vended-interventions/steering/index.d.ts +31 -0
  199. package/dist/src/vended-interventions/steering/index.d.ts.map +1 -0
  200. package/dist/src/vended-interventions/steering/index.js +32 -0
  201. package/dist/src/vended-interventions/steering/index.js.map +1 -0
  202. package/dist/src/vended-interventions/steering/providers/context-provider.d.ts +55 -0
  203. package/dist/src/vended-interventions/steering/providers/context-provider.d.ts.map +1 -0
  204. package/dist/src/vended-interventions/steering/providers/context-provider.js +8 -0
  205. package/dist/src/vended-interventions/steering/providers/context-provider.js.map +1 -0
  206. package/dist/src/vended-interventions/steering/providers/tool-ledger.d.ts +49 -0
  207. package/dist/src/vended-interventions/steering/providers/tool-ledger.d.ts.map +1 -0
  208. package/dist/src/vended-interventions/steering/providers/tool-ledger.js +75 -0
  209. package/dist/src/vended-interventions/steering/providers/tool-ledger.js.map +1 -0
  210. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.js +208 -0
  211. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.js.map +1 -1
  212. package/dist/src/vended-plugins/context-offloader/__tests__/search.test.d.ts +2 -0
  213. package/dist/src/vended-plugins/context-offloader/__tests__/search.test.d.ts.map +1 -0
  214. package/dist/src/vended-plugins/context-offloader/__tests__/search.test.js +149 -0
  215. package/dist/src/vended-plugins/context-offloader/__tests__/search.test.js.map +1 -0
  216. package/dist/src/vended-plugins/context-offloader/plugin.d.ts.map +1 -1
  217. package/dist/src/vended-plugins/context-offloader/plugin.js +57 -10
  218. package/dist/src/vended-plugins/context-offloader/plugin.js.map +1 -1
  219. package/dist/src/vended-plugins/context-offloader/search.d.ts +25 -0
  220. package/dist/src/vended-plugins/context-offloader/search.d.ts.map +1 -0
  221. package/dist/src/vended-plugins/context-offloader/search.js +120 -0
  222. package/dist/src/vended-plugins/context-offloader/search.js.map +1 -0
  223. package/dist/src/vended-plugins/index.d.ts +11 -0
  224. package/dist/src/vended-plugins/index.d.ts.map +1 -0
  225. package/dist/src/vended-plugins/index.js +11 -0
  226. package/dist/src/vended-plugins/index.js.map +1 -0
  227. package/dist/src/vended-tools/index.d.ts +17 -0
  228. package/dist/src/vended-tools/index.d.ts.map +1 -0
  229. package/dist/src/vended-tools/index.js +17 -0
  230. package/dist/src/vended-tools/index.js.map +1 -0
  231. package/package.json +37 -11
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Direct tool calling support through agent.tool accessor.
3
+ *
4
+ * Enables method-style tool invocation without model inference:
5
+ * ```typescript
6
+ * const agent = new Agent({ tools: [myTool] })
7
+ * const result = await agent.tool.calculator!.invoke({ a: 5, b: 3 })
8
+ * ```
9
+ */
10
+ import { Message } from '../types/messages.js';
11
+ import { TextBlock, ToolUseBlock } from '../types/messages.js';
12
+ import { ToolStreamEvent } from '../tools/tool.js';
13
+ import { ConcurrentInvocationError } from '../errors.js';
14
+ /**
15
+ * Provides direct tool calling through the agent.
16
+ *
17
+ * Enables programmatic tool invocation without model inference via
18
+ * `agent.tool.toolName.invoke(input)` or `agent.tool.toolName.stream(input)`.
19
+ * Tools are called directly, bypassing the model loop, and results are optionally
20
+ * recorded in message history for context continuity.
21
+ *
22
+ * Supports underscore-to-hyphen and case-insensitive name normalization
23
+ * via {@link ToolRegistry.resolve}.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const agent = new Agent({ tools: [calculatorTool] })
28
+ *
29
+ * // Invoke and get the result
30
+ * const result = await agent.tool.calculator!.invoke({ operation: 'add', a: 5, b: 3 })
31
+ * console.log(result.status) // 'success'
32
+ *
33
+ * // Stream intermediate events
34
+ * for await (const event of agent.tool.calculator!.stream({ operation: 'add', a: 5, b: 3 })) {
35
+ * console.log('progress:', event)
36
+ * }
37
+ * ```
38
+ *
39
+ * @internal This class is not intended for direct instantiation by users.
40
+ */
41
+ export class ToolCaller {
42
+ _agent;
43
+ _appendMessage;
44
+ /**
45
+ * Creates a ToolCaller proxy for the given agent.
46
+ *
47
+ * Encapsulates the Proxy cast so callers don't need to handle the
48
+ * implementation detail that the constructor returns a Proxy, not
49
+ * a plain ToolCaller instance.
50
+ *
51
+ * @param agent - The owning agent instance
52
+ * @param appendMessage - Helper provided by the agent to append messages and fire hooks.
53
+ * Passed in (rather than calling a public agent method) so message mutation stays
54
+ * encapsulated within the agent.
55
+ */
56
+ static create(agent, appendMessage) {
57
+ return new ToolCaller(agent, appendMessage);
58
+ }
59
+ constructor(agent, appendMessage) {
60
+ this._agent = agent;
61
+ this._appendMessage = appendMessage;
62
+ // Return a Proxy that intercepts property access to resolve tool names
63
+ return new Proxy(this, {
64
+ get(target, prop, receiver) {
65
+ // Pass through symbol properties (Symbol.toPrimitive, Symbol.iterator, etc.)
66
+ // Uses Reflect.get for proper receiver forwarding.
67
+ if (typeof prop === 'symbol') {
68
+ return Reflect.get(target, prop, receiver);
69
+ }
70
+ // Prevent accidental thenable behavior — if a user writes `await agent.tool`
71
+ // the JS runtime checks for `.then`. Without this guard, the Proxy would return
72
+ // a ToolHandle for a non-existent tool named "then", which is confusing.
73
+ // Note: this means a tool literally named "then" cannot be accessed via this proxy.
74
+ if (prop === 'then') {
75
+ return undefined;
76
+ }
77
+ // Return a ToolHandle with .invoke() and .stream() for the named tool.
78
+ // We intentionally do NOT fall through to `prop in target` here — that would
79
+ // cause tool names that collide with inherited Object properties (e.g.,
80
+ // 'constructor', 'toString', 'valueOf') to return the wrong value.
81
+ return target._createToolHandle(prop);
82
+ },
83
+ });
84
+ }
85
+ /**
86
+ * Creates a ToolHandle for the given tool name.
87
+ */
88
+ _createToolHandle(name) {
89
+ return {
90
+ invoke: (input, options) => {
91
+ return this._callTool(name, input ?? {}, options);
92
+ },
93
+ stream: (input, options) => {
94
+ return this._streamTool(name, input ?? {}, options);
95
+ },
96
+ };
97
+ }
98
+ /**
99
+ * Executes a tool by name with the given input, consuming the full stream and returning the result.
100
+ *
101
+ * @param name - The tool name (supports underscore-to-hyphen and case-insensitive resolution)
102
+ * @param input - The input parameters for the tool
103
+ * @param options - Optional configuration for this call
104
+ * @returns The tool result
105
+ */
106
+ async _callTool(name, input, options) {
107
+ const gen = this._streamTool(name, input, options);
108
+ let result = await gen.next();
109
+ while (!result.done) {
110
+ result = await gen.next();
111
+ }
112
+ return result.value;
113
+ }
114
+ /**
115
+ * Streams a tool execution by name, yielding intermediate events.
116
+ *
117
+ * @param name - The tool name
118
+ * @param input - The input parameters for the tool
119
+ * @param options - Optional configuration for this call
120
+ * @returns Async generator that yields ToolStreamEvents and returns ToolResultBlock
121
+ */
122
+ async *_streamTool(name, input, options) {
123
+ const shouldRecord = options?.recordDirectToolCall ?? true;
124
+ // If recording, check that the agent is not currently invoking
125
+ if (shouldRecord && this._agent.isInvoking) {
126
+ throw new ConcurrentInvocationError('Direct tool call cannot be made while the agent is in the middle of an invocation. ' +
127
+ 'Set recordDirectToolCall: false to allow direct tool calls during agent invocation.');
128
+ }
129
+ // Resolve the tool via the registry's normalization (exact → hyphen → case-insensitive)
130
+ const tool = this._agent.toolRegistry.resolve(name);
131
+ // Generate unique tool use ID
132
+ const toolUseId = `tooluse_${globalThis.crypto.randomUUID()}`;
133
+ const toolUse = {
134
+ toolUseId,
135
+ name: tool.name,
136
+ input,
137
+ };
138
+ // Create tool context
139
+ const toolContext = {
140
+ toolUse,
141
+ agent: this._agent,
142
+ invocationState: {},
143
+ interrupt: () => {
144
+ throw new Error('Interrupts are not supported in direct tool calls');
145
+ },
146
+ };
147
+ // Execute the tool, yielding stream events
148
+ const toolResult = yield* this._executeTool(tool, toolContext);
149
+ // Record in message history if configured
150
+ if (shouldRecord) {
151
+ await this._recordToolExecution(toolUse, toolResult);
152
+ }
153
+ return toolResult;
154
+ }
155
+ /**
156
+ * Executes a tool's stream generator, yielding events and returning the final result.
157
+ */
158
+ async *_executeTool(tool, toolContext) {
159
+ const generator = tool.stream(toolContext);
160
+ let result = await generator.next();
161
+ while (!result.done) {
162
+ yield result.value;
163
+ result = await generator.next();
164
+ }
165
+ return result.value;
166
+ }
167
+ /**
168
+ * Records a tool execution in the agent's message history and fires MessageAddedEvent hooks.
169
+ *
170
+ * Creates a sequence of 3 messages that represent the tool execution:
171
+ * 1. An assistant message with the ToolUseBlock (what was called and with what input)
172
+ * 2. A user message with the ToolResultBlock (tool output)
173
+ * 3. An assistant message acknowledging the result
174
+ *
175
+ * Each message fires a {@link MessageAddedEvent} so that hooks registered via
176
+ * `agent.addHook(MessageAddedEvent, ...)` are notified of direct tool call messages.
177
+ */
178
+ async _recordToolExecution(toolUse, toolResult) {
179
+ const toolUseBlock = new ToolUseBlock({
180
+ toolUseId: toolUse.toolUseId,
181
+ name: toolUse.name,
182
+ input: toolUse.input,
183
+ });
184
+ const toolUseMsg = new Message({ role: 'assistant', content: [toolUseBlock] });
185
+ const toolResultMsg = new Message({ role: 'user', content: [toolResult] });
186
+ const assistantMsg = new Message({
187
+ role: 'assistant',
188
+ content: [new TextBlock(`agent.tool.${toolUse.name} was called.`)],
189
+ });
190
+ // Append messages and fire MessageAddedEvent hooks for each, using the
191
+ // helper provided by Agent. This keeps message mutation encapsulated in
192
+ // the agent — ToolCaller never touches `agent.messages` directly.
193
+ await this._appendMessage(toolUseMsg);
194
+ await this._appendMessage(toolResultMsg);
195
+ await this._appendMessage(assistantMsg);
196
+ }
197
+ }
198
+ //# sourceMappingURL=tool-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-caller.js","sourceRoot":"","sources":["../../../src/agent/tool-caller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AA4DxD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,UAAU;IACJ,MAAM,CAAO;IACb,cAAc,CAAiB;IAEhD;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CAAC,KAAY,EAAE,aAA8B;QACxD,OAAO,IAAI,UAAU,CAAC,KAAK,EAA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AwE;QACxE,kEAAkE;QAClE,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;QACrC,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;QACxC,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACzC,CAAC;CACF"}
@@ -161,6 +161,23 @@ export declare class ToolValidationError extends Error {
161
161
  export declare class StructuredOutputError extends Error {
162
162
  constructor(message: string);
163
163
  }
164
+ /**
165
+ * Error thrown when a tool cannot be found by name.
166
+ *
167
+ * Thrown by {@link ToolRegistry.resolve} when the requested tool name doesn't
168
+ * match any registered tool, even after underscore-to-hyphen normalization
169
+ * and case-insensitive matching.
170
+ */
171
+ export declare class ToolNotFoundError extends Error {
172
+ /** The tool name that was requested but not found. */
173
+ readonly toolName: string;
174
+ /**
175
+ * Creates a new ToolNotFoundError.
176
+ *
177
+ * @param toolName - The tool name that was not found
178
+ */
179
+ constructor(toolName: string);
180
+ }
164
181
  /**
165
182
  * Internal control-flow mechanism for unwinding nested `yield*` generator chains
166
183
  * when cancellation is detected during model streaming.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,UAAU;IACxD;;;;OAIG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;;OAGG;IACH,SAA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;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,sDAAsD;IACtD,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAEhC;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;CAK7B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;;CAKxC"}
@@ -190,6 +190,27 @@ export class StructuredOutputError extends Error {
190
190
  this.name = 'StructuredOutputError';
191
191
  }
192
192
  }
193
+ /**
194
+ * Error thrown when a tool cannot be found by name.
195
+ *
196
+ * Thrown by {@link ToolRegistry.resolve} when the requested tool name doesn't
197
+ * match any registered tool, even after underscore-to-hyphen normalization
198
+ * and case-insensitive matching.
199
+ */
200
+ export class ToolNotFoundError extends Error {
201
+ /** The tool name that was requested but not found. */
202
+ toolName;
203
+ /**
204
+ * Creates a new ToolNotFoundError.
205
+ *
206
+ * @param toolName - The tool name that was not found
207
+ */
208
+ constructor(toolName) {
209
+ super(`Tool '${toolName}' not found`);
210
+ this.name = 'ToolNotFoundError';
211
+ this.toolName = toolName;
212
+ }
213
+ }
193
214
  /**
194
215
  * Internal control-flow mechanism for unwinding nested `yield*` generator chains
195
216
  * when cancellation is detected during model streaming.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;GAOG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC;;;;;OAKG;IACH,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC1B,CAAC;CACF;AAED;;;;;;GAMG;AACH,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CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF"}
@@ -41,7 +41,9 @@ export type HookCleanup = () => void;
41
41
  */
42
42
  export declare const HookOrder: {
43
43
  readonly SDK_FIRST: -100;
44
+ readonly INTERVENTION_OUTPUT: -90;
44
45
  readonly DEFAULT: 0;
46
+ readonly INTERVENTION_INPUT: 90;
45
47
  readonly SDK_LAST: 100;
46
48
  };
47
49
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;GAEG;AAEH,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAEzG;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEtF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAA;AAEpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS;;;;CAIZ,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;GAEG;AAEH,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAEzG;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEtF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAA;AAEpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS;;;;;;CAMZ,CAAA"}
@@ -12,7 +12,9 @@
12
12
  */
13
13
  export const HookOrder = {
14
14
  SDK_FIRST: -100,
15
+ INTERVENTION_OUTPUT: -90,
15
16
  DEFAULT: 0,
17
+ INTERVENTION_INPUT: 90,
16
18
  SDK_LAST: 100,
17
19
  };
18
20
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS,EAAE,CAAC,GAAG;IACf,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,GAAG;CACL,CAAA"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS,EAAE,CAAC,GAAG;IACf,mBAAmB,EAAE,CAAC,EAAE;IACxB,OAAO,EAAE,CAAC;IACV,kBAAkB,EAAE,EAAE;IACtB,QAAQ,EAAE,GAAG;CACL,CAAA"}
@@ -9,11 +9,13 @@ export { StateStore } from './state-store.js';
9
9
  export { AgentResult } from './types/agent.js';
10
10
  export type { AgentConfig, ToolList, ToolExecutorStrategy } from './agent/agent.js';
11
11
  export type { AgentAsToolOptions } from './agent/agent-as-tool.js';
12
+ export type { ToolCaller, ToolCallerProxy, ToolHandle, DirectToolCallOptions } from './agent/tool-caller.js';
12
13
  export type { InvocationState, InvokeArgs, InvokeOptions, LocalAgent } from './types/agent.js';
14
+ export type { LifecycleObserver } from './types/lifecycle-observer.js';
13
15
  export { SNAPSHOT_SCHEMA_VERSION } from './types/snapshot.js';
14
16
  export type { Scope, Snapshot } from './types/snapshot.js';
15
17
  export type { TakeSnapshotOptions, SnapshotField, SnapshotPreset } from './agent/snapshot.js';
16
- export { ModelError, ContextWindowOverflowError, MaxTokensError, JsonValidationError, ConcurrentInvocationError, ModelThrottledError, ToolValidationError, StructuredOutputError, } from './errors.js';
18
+ export { ModelError, ContextWindowOverflowError, MaxTokensError, JsonValidationError, ConcurrentInvocationError, ModelThrottledError, ToolValidationError, StructuredOutputError, ToolNotFoundError, } from './errors.js';
17
19
  export type { Interrupt, InterruptSource } from './interrupt.js';
18
20
  export type { InterruptParams, InterruptResponse, InterruptResponseContentData } from './types/interrupt.js';
19
21
  export { InterruptResponseContent } from './types/interrupt.js';
@@ -37,11 +39,13 @@ export { isModelStreamEvent, ModelMessageStartEvent, ModelContentBlockStartEvent
37
39
  export type { BaseModelConfig, CountTokensOptions, StreamOptions, CacheConfig } from './models/model.js';
38
40
  export { Model } from './models/model.js';
39
41
  export { BedrockModel as BedrockModel } from './models/bedrock.js';
40
- export type { BedrockModelConfig, BedrockModelOptions, BedrockGuardrailConfig, BedrockGuardrailRedactionConfig, } from './models/bedrock.js';
42
+ export type { BedrockModelConfig, BedrockModelOptions, BedrockGuardrailConfig, BedrockGuardrailRedactionConfig, BedrockCacheConfig, BedrockCacheTTL, } from './models/bedrock.js';
41
43
  export type { AgentStreamEvent } from './types/agent.js';
42
44
  export { HookRegistry, HookOrder, StreamEvent, HookableEvent, InitializedEvent, BeforeInvocationEvent, AfterInvocationEvent, MessageAddedEvent, BeforeToolCallEvent, AfterToolCallEvent, BeforeModelCallEvent, AfterModelCallEvent, BeforeToolsEvent, AfterToolsEvent, ContentBlockEvent, ModelMessageEvent, ToolResultEvent, ToolStreamUpdateEvent, AgentResultEvent, InterruptEvent, ModelStreamUpdateEvent, } from './hooks/index.js';
43
45
  export type { HookCallback, HookableEventConstructor, HookCallbackOptions, ModelStopResponse, Redaction, ToolUseData, } from './hooks/index.js';
44
46
  export type { Plugin } from './plugins/index.js';
47
+ export { InterventionHandler, InterventionActions } from './interventions/index.js';
48
+ export type { OnError } from './interventions/index.js';
45
49
  export { type BackoffContext, type BackoffStrategy, type JitterKind, type ConstantBackoffOptions, type LinearBackoffOptions, type ExponentialBackoffOptions, ConstantBackoff, LinearBackoff, ExponentialBackoff, ModelRetryStrategy, DefaultModelRetryStrategy, type DefaultModelRetryStrategyOptions, type RetryStrategy, type RetryDecision, } from './retry/index.js';
46
50
  export { ConversationManager, type ProactiveCompressionConfig, type ConversationManagerReduceOptions, type ConversationManagerOptions, } from './conversation-manager/conversation-manager.js';
47
51
  export { NullConversationManager } from './conversation-manager/null-conversation-manager.js';
@@ -49,7 +53,7 @@ export { SlidingWindowConversationManager, type SlidingWindowConversationManager
49
53
  export { SummarizingConversationManager, type SummarizingConversationManagerConfig, } from './conversation-manager/summarizing-conversation-manager.js';
50
54
  export { configureLogging } from './logging/logger.js';
51
55
  export type { Logger } from './logging/types.js';
52
- export { type McpClientConfig, type McpClientCredentials, type McpTransport, type McpCallToolOptions, type TasksConfig, type McpConnectionState, McpClient, } from './mcp.js';
56
+ export { type McpClientOptions, type McpClientConfig, type McpClientCredentials, type McpTransport, type McpCallToolOptions, type TasksConfig, type McpConnectionState, McpClient, } from './mcp.js';
53
57
  export type { ElicitationCallback, ElicitationContext } from './types/elicitation.js';
54
58
  export { SessionManager } from './session/session-manager.js';
55
59
  export type { SessionManagerConfig, SaveLatestStrategy, MultiAgentSaveLatestStrategy, } from './session/session-manager.js';
@@ -58,6 +62,9 @@ export type { SessionStorage, SnapshotStorage, SnapshotLocation } from './sessio
58
62
  export { FileStorage } from './session/file-storage.js';
59
63
  export { AgentTrace } from './telemetry/tracer.js';
60
64
  export { AgentMetrics } from './telemetry/meter.js';
65
+ export { Sandbox, type ExecuteOptions } from './sandbox/base.js';
66
+ export { PosixShellSandbox } from './sandbox/posix-shell.js';
67
+ export type { StreamType, StreamChunk, FileInfo, OutputFile, ExecutionResult } from './sandbox/types.js';
61
68
  export { Graph } from './multiagent/index.js';
62
69
  export { Swarm } from './multiagent/index.js';
63
70
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACnF,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAK7F,OAAO,EACL,UAAU,EACV,0BAA0B,EAC1B,cAAc,EACd,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAC5G,OAAO,EA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AE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGxG,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA"}
package/dist/src/index.js CHANGED
@@ -15,7 +15,7 @@ export { SNAPSHOT_SCHEMA_VERSION } from './types/snapshot.js';
15
15
  // Error types
16
16
  // Note: CancelledError is intentionally not exported — it is an internal
17
17
  // control-flow mechanism, never thrown to consumers. See its docstring in errors.ts.
18
- export { ModelError, ContextWindowOverflowError, MaxTokensError, JsonValidationError, ConcurrentInvocationError, ModelThrottledError, ToolValidationError, StructuredOutputError, } from './errors.js';
18
+ export { ModelError, ContextWindowOverflowError, MaxTokensError, JsonValidationError, ConcurrentInvocationError, ModelThrottledError, ToolValidationError, StructuredOutputError, ToolNotFoundError, } from './errors.js';
19
19
  export { InterruptResponseContent } from './types/interrupt.js';
20
20
  // Message classes
21
21
  export { TextBlock, ToolUseBlock, ToolResultBlock, ReasoningBlock, CachePointBlock, GuardContentBlock, Message, JsonBlock, contentBlockFromData, toolResultContentFromData, } from './types/messages.js';
@@ -38,6 +38,8 @@ export { Model } from './models/model.js';
38
38
  export { BedrockModel as BedrockModel } from './models/bedrock.js';
39
39
  // Hooks system
40
40
  export { HookRegistry, HookOrder, StreamEvent, HookableEvent, InitializedEvent, BeforeInvocationEvent, AfterInvocationEvent, MessageAddedEvent, BeforeToolCallEvent, AfterToolCallEvent, BeforeModelCallEvent, AfterModelCallEvent, BeforeToolsEvent, AfterToolsEvent, ContentBlockEvent, ModelMessageEvent, ToolResultEvent, ToolStreamUpdateEvent, AgentResultEvent, InterruptEvent, ModelStreamUpdateEvent, } from './hooks/index.js';
41
+ // Intervention system
42
+ export { InterventionHandler, InterventionActions } from './interventions/index.js';
41
43
  // Retry
42
44
  export { ConstantBackoff, LinearBackoff, ExponentialBackoff, ModelRetryStrategy, DefaultModelRetryStrategy, } from './retry/index.js';
43
45
  // Conversation Manager
@@ -56,6 +58,9 @@ export { FileStorage } from './session/file-storage.js';
56
58
  export { AgentTrace } from './telemetry/tracer.js';
57
59
  // Local Metrics
58
60
  export { AgentMetrics } from './telemetry/meter.js';
61
+ // Sandbox
62
+ export { Sandbox } from './sandbox/base.js';
63
+ export { PosixShellSandbox } from './sandbox/posix-shell.js';
59
64
  // Multi-agent orchestration
60
65
  export { Graph } from './multiagent/index.js';
61
66
  export { Swarm } from './multiagent/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc;AACd,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,YAAY;AACZ,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAK9C,iBAAiB;AACjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAI7D,cAAc;AACd,yEAAyE;AACzE,qFAAqF;AACrF,OAAO,EACL,UAAU,EACV,0BAA0B,EAC1B,cAAc,EACd,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AA6B/D,kBAAkB;AAClB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAW5B,iBAAiB;AACj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,cAAc,EACd,sBAAsB,GACvB,MAAM,kBAAkB,CAAA;AAazB,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAGnF,QAAQ;AACR,OAAO,EAOL,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GAI1B,MAAM,kBAAkB,CAAA;AAEzB,uBAAuB;AACvB,OAAO,EACL,mBAAmB,GAIpB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,EACL,gCAAgC,GAEjC,MAAM,+DAA+D,CAAA;AACtE,OAAO,EACL,8BAA8B,GAE/B,MAAM,4DAA4D,CAAA;AAEnE,UAAU;AACV,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGtD,uCAAuC;AACvC,OAAO,EAQL,SAAS,GACV,MAAM,UAAU,CAAA;AAGjB,qBAAqB;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAQ7D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,eAAe;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,UAAU;AACV,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAG5D,4BAA4B;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=handler.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.test.d.ts","sourceRoot":"","sources":["../../../../src/interventions/__tests__/handler.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { InterventionHandler } from '../handler.js';
3
+ import { Agent } from '../../agent/agent.js';
4
+ import { BeforeToolCallEvent, AfterModelCallEvent } from '../../hooks/events.js';
5
+ class NoOpHandler extends InterventionHandler {
6
+ name = 'no-op';
7
+ }
8
+ class ToolOnlyHandler extends InterventionHandler {
9
+ name = 'tool-only';
10
+ beforeToolCall() {
11
+ return { type: 'deny', reason: 'blocked' };
12
+ }
13
+ }
14
+ describe('InterventionHandler', () => {
15
+ const agent = new Agent();
16
+ const toolUse = { name: 'test', toolUseId: 'id', input: {} };
17
+ it('default methods return proceed', () => {
18
+ const handler = new NoOpHandler();
19
+ expect(handler.beforeToolCall(new BeforeToolCallEvent({ agent, toolUse, tool: undefined, invocationState: {} }))).toEqual({
20
+ type: 'proceed',
21
+ });
22
+ expect(handler.afterModelCall(new AfterModelCallEvent({ agent, model: {}, invocationState: {}, attemptCount: 0 }))).toEqual({
23
+ type: 'proceed',
24
+ });
25
+ });
26
+ it('override detection works via prototype comparison', () => {
27
+ const noOp = new NoOpHandler();
28
+ const toolOnly = new ToolOnlyHandler();
29
+ expect(noOp.beforeToolCall).toBe(InterventionHandler.prototype.beforeToolCall);
30
+ expect(noOp.afterModelCall).toBe(InterventionHandler.prototype.afterModelCall);
31
+ expect(toolOnly.beforeToolCall).not.toBe(InterventionHandler.prototype.beforeToolCall);
32
+ expect(toolOnly.afterModelCall).toBe(InterventionHandler.prototype.afterModelCall);
33
+ });
34
+ });
35
+ //# sourceMappingURL=handler.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.test.js","sourceRoot":"","sources":["../../../../src/interventions/__tests__/handler.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OA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AG,IAAI,eAAe,EAAE,CAAA;QAEtC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAC9E,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAE9E,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QACtF,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACpF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=registry.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.test.d.ts","sourceRoot":"","sources":["../../../../src/interventions/__tests__/registry.test.ts"],"names":[],"mappings":""}