@strands-agents/sdk 0.2.2 → 0.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.
- package/README.md +43 -0
- package/dist/src/__fixtures__/mock-hook-provider.d.ts +3 -7
- package/dist/src/__fixtures__/mock-hook-provider.d.ts.map +1 -1
- package/dist/src/__fixtures__/mock-hook-provider.js +3 -9
- package/dist/src/__fixtures__/mock-hook-provider.js.map +1 -1
- package/dist/src/__fixtures__/mock-message-model.d.ts +8 -2
- package/dist/src/__fixtures__/mock-message-model.d.ts.map +1 -1
- package/dist/src/__fixtures__/mock-message-model.js +1 -0
- package/dist/src/__fixtures__/mock-message-model.js.map +1 -1
- package/dist/src/__fixtures__/mock-storage-provider.d.ts +37 -0
- package/dist/src/__fixtures__/mock-storage-provider.d.ts.map +1 -0
- package/dist/src/__fixtures__/mock-storage-provider.js +105 -0
- package/dist/src/__fixtures__/mock-storage-provider.js.map +1 -0
- package/dist/src/__fixtures__/slim-types.d.ts +50 -0
- package/dist/src/__fixtures__/slim-types.d.ts.map +1 -0
- package/dist/src/__fixtures__/slim-types.js +6 -0
- package/dist/src/__fixtures__/slim-types.js.map +1 -0
- package/dist/src/__fixtures__/tool-helpers.d.ts +8 -3
- package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -1
- package/dist/src/__fixtures__/tool-helpers.js +1 -1
- package/dist/src/__fixtures__/tool-helpers.js.map +1 -1
- package/dist/src/agent/__tests__/agent.hook.test.js +18 -18
- package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -1
- package/dist/src/agent/__tests__/agent.test.js +124 -8
- package/dist/src/agent/__tests__/agent.test.js.map +1 -1
- package/dist/src/agent/__tests__/printer.test.js +5 -9
- package/dist/src/agent/__tests__/printer.test.js.map +1 -1
- package/dist/src/agent/__tests__/snapshot.test.d.ts +2 -0
- package/dist/src/agent/__tests__/snapshot.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/snapshot.test.js +249 -0
- package/dist/src/agent/__tests__/snapshot.test.js.map +1 -0
- package/dist/src/agent/__tests__/state.test.js +19 -0
- package/dist/src/agent/__tests__/state.test.js.map +1 -1
- package/dist/src/agent/agent.d.ts +19 -4
- package/dist/src/agent/agent.d.ts.map +1 -1
- package/dist/src/agent/agent.js +104 -34
- package/dist/src/agent/agent.js.map +1 -1
- package/dist/src/agent/printer.d.ts +4 -0
- package/dist/src/agent/printer.d.ts.map +1 -1
- package/dist/src/agent/printer.js +18 -6
- package/dist/src/agent/printer.js.map +1 -1
- package/dist/src/agent/snapshot.d.ts +132 -0
- package/dist/src/agent/snapshot.d.ts.map +1 -0
- package/dist/src/agent/snapshot.js +151 -0
- package/dist/src/agent/snapshot.js.map +1 -0
- package/dist/src/agent/state.d.ts +14 -1
- package/dist/src/agent/state.d.ts.map +1 -1
- package/dist/src/agent/state.js +21 -0
- package/dist/src/agent/state.js.map +1 -1
- package/dist/src/errors.d.ts +15 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +18 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/hooks/__tests__/events.test.js +102 -21
- package/dist/src/hooks/__tests__/events.test.js.map +1 -1
- package/dist/src/hooks/events.d.ts +156 -22
- package/dist/src/hooks/events.d.ts.map +1 -1
- package/dist/src/hooks/events.js +158 -18
- package/dist/src/hooks/events.js.map +1 -1
- package/dist/src/hooks/index.d.ts +12 -4
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +11 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/registry.d.ts +5 -5
- package/dist/src/hooks/registry.d.ts.map +1 -1
- package/dist/src/hooks/registry.js.map +1 -1
- package/dist/src/hooks/types.d.ts +5 -5
- package/dist/src/hooks/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/__tests__/anthropic.test.js +31 -42
- package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
- package/dist/src/models/__tests__/bedrock.test.js +70 -107
- package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
- package/dist/src/models/__tests__/gemini.test.js +438 -141
- package/dist/src/models/__tests__/gemini.test.js.map +1 -1
- package/dist/src/models/__tests__/model.test.js +14 -13
- package/dist/src/models/__tests__/model.test.js.map +1 -1
- package/dist/src/models/__tests__/openai.test.js +73 -83
- package/dist/src/models/__tests__/openai.test.js.map +1 -1
- package/dist/src/models/gemini/adapters.d.ts +2 -1
- package/dist/src/models/gemini/adapters.d.ts.map +1 -1
- package/dist/src/models/gemini/adapters.js +97 -10
- package/dist/src/models/gemini/adapters.js.map +1 -1
- package/dist/src/models/gemini/model.d.ts.map +1 -1
- package/dist/src/models/gemini/model.js +37 -1
- package/dist/src/models/gemini/model.js.map +1 -1
- package/dist/src/models/gemini/types.d.ts +9 -1
- package/dist/src/models/gemini/types.d.ts.map +1 -1
- package/dist/src/models/model.d.ts.map +1 -1
- package/dist/src/models/model.js +4 -0
- package/dist/src/models/model.js.map +1 -1
- package/dist/src/models/streaming.d.ts +13 -0
- package/dist/src/models/streaming.d.ts.map +1 -1
- package/dist/src/models/streaming.js +17 -0
- package/dist/src/models/streaming.js.map +1 -1
- package/dist/src/multiagent/__tests__/nodes.test.d.ts +2 -0
- package/dist/src/multiagent/__tests__/nodes.test.d.ts.map +1 -0
- package/dist/src/multiagent/__tests__/nodes.test.js +98 -0
- package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -0
- package/dist/src/multiagent/events.d.ts +24 -0
- package/dist/src/multiagent/events.d.ts.map +1 -0
- package/dist/src/multiagent/events.js +19 -0
- package/dist/src/multiagent/events.js.map +1 -0
- package/dist/src/multiagent/index.d.ts +11 -0
- package/dist/src/multiagent/index.d.ts.map +1 -0
- package/dist/src/multiagent/index.js +7 -0
- package/dist/src/multiagent/index.js.map +1 -0
- package/dist/src/multiagent/nodes.d.ts +75 -0
- package/dist/src/multiagent/nodes.d.ts.map +1 -0
- package/dist/src/multiagent/nodes.js +101 -0
- package/dist/src/multiagent/nodes.js.map +1 -0
- package/dist/src/multiagent/state.d.ts +55 -0
- package/dist/src/multiagent/state.d.ts.map +1 -0
- package/dist/src/multiagent/state.js +43 -0
- package/dist/src/multiagent/state.js.map +1 -0
- package/dist/src/multiagent/types.d.ts +5 -0
- package/dist/src/multiagent/types.d.ts.map +1 -0
- package/dist/src/multiagent/types.js +2 -0
- package/dist/src/multiagent/types.js.map +1 -0
- package/dist/src/registry/tool-registry.d.ts +2 -1
- package/dist/src/registry/tool-registry.d.ts.map +1 -1
- package/dist/src/registry/tool-registry.js +4 -2
- package/dist/src/registry/tool-registry.js.map +1 -1
- package/dist/src/session/__tests__/file-storage.test.node.d.ts +2 -0
- package/dist/src/session/__tests__/file-storage.test.node.d.ts.map +1 -0
- package/dist/src/session/__tests__/file-storage.test.node.js +218 -0
- package/dist/src/session/__tests__/file-storage.test.node.js.map +1 -0
- package/dist/src/session/__tests__/s3-storage.test.node.d.ts +2 -0
- package/dist/src/session/__tests__/s3-storage.test.node.d.ts.map +1 -0
- package/dist/src/session/__tests__/s3-storage.test.node.js +375 -0
- package/dist/src/session/__tests__/s3-storage.test.node.js.map +1 -0
- package/dist/src/session/__tests__/validation.test.d.ts +2 -0
- package/dist/src/session/__tests__/validation.test.d.ts.map +1 -0
- package/dist/src/session/__tests__/validation.test.js +20 -0
- package/dist/src/session/__tests__/validation.test.js.map +1 -0
- package/dist/src/session/file-storage.d.ts +79 -0
- package/dist/src/session/file-storage.d.ts.map +1 -0
- package/dist/src/session/file-storage.js +144 -0
- package/dist/src/session/file-storage.js.map +1 -0
- package/dist/src/session/index.d.ts +19 -0
- package/dist/src/session/index.d.ts.map +1 -0
- package/dist/src/session/index.js +18 -0
- package/dist/src/session/index.js.map +1 -0
- package/dist/src/session/s3-storage.d.ts +93 -0
- package/dist/src/session/s3-storage.d.ts.map +1 -0
- package/dist/src/session/s3-storage.js +150 -0
- package/dist/src/session/s3-storage.js.map +1 -0
- package/dist/src/session/storage.d.ts +91 -0
- package/dist/src/session/storage.d.ts.map +1 -0
- package/dist/src/session/storage.js +2 -0
- package/dist/src/session/storage.js.map +1 -0
- package/dist/src/session/types.d.ts +49 -0
- package/dist/src/session/types.d.ts.map +1 -0
- package/dist/src/session/types.js +2 -0
- package/dist/src/session/types.js.map +1 -0
- package/dist/src/session/validation.d.ts +10 -0
- package/dist/src/session/validation.d.ts.map +1 -0
- package/dist/src/session/validation.js +16 -0
- package/dist/src/session/validation.js.map +1 -0
- package/dist/src/structured-output/__tests__/context.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/context.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/context.test.js +201 -0
- package/dist/src/structured-output/__tests__/context.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/exceptions.test.js +103 -0
- package/dist/src/structured-output/__tests__/exceptions.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/tool.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/tool.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/tool.test.js +256 -0
- package/dist/src/structured-output/__tests__/tool.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/utils.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/utils.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/utils.test.js +183 -0
- package/dist/src/structured-output/__tests__/utils.test.js.map +1 -0
- package/dist/src/structured-output/context.d.ts +91 -0
- package/dist/src/structured-output/context.d.ts.map +1 -0
- package/dist/src/structured-output/context.js +112 -0
- package/dist/src/structured-output/context.js.map +1 -0
- package/dist/src/structured-output/exceptions.d.ts +18 -0
- package/dist/src/structured-output/exceptions.d.ts.map +1 -0
- package/dist/src/structured-output/exceptions.js +28 -0
- package/dist/src/structured-output/exceptions.js.map +1 -0
- package/dist/src/structured-output/tool.d.ts +33 -0
- package/dist/src/structured-output/tool.d.ts.map +1 -0
- package/dist/src/structured-output/tool.js +73 -0
- package/dist/src/structured-output/tool.js.map +1 -0
- package/dist/src/structured-output/utils.d.ts +23 -0
- package/dist/src/structured-output/utils.d.ts.map +1 -0
- package/dist/src/structured-output/utils.js +104 -0
- package/dist/src/structured-output/utils.js.map +1 -0
- package/dist/src/tools/zod-tool.d.ts.map +1 -1
- package/dist/src/tools/zod-tool.js +2 -5
- package/dist/src/tools/zod-tool.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types/__tests__/media.test.js +216 -1
- package/dist/src/types/__tests__/media.test.js.map +1 -1
- package/dist/src/types/__tests__/messages.test.js +193 -4
- package/dist/src/types/__tests__/messages.test.js.map +1 -1
- package/dist/src/types/agent.d.ts +13 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/agent.js +8 -1
- package/dist/src/types/agent.js.map +1 -1
- package/dist/src/types/json.d.ts +61 -0
- package/dist/src/types/json.d.ts.map +1 -1
- package/dist/src/types/json.js +24 -0
- package/dist/src/types/json.js.map +1 -1
- package/dist/src/types/media.d.ts +84 -4
- package/dist/src/types/media.d.ts.map +1 -1
- package/dist/src/types/media.js +194 -0
- package/dist/src/types/media.js.map +1 -1
- package/dist/src/types/messages.d.ts +158 -9
- package/dist/src/types/messages.d.ts.map +1 -1
- package/dist/src/types/messages.js +242 -7
- package/dist/src/types/messages.js.map +1 -1
- package/dist/src/types/serializable.d.ts +31 -0
- package/dist/src/types/serializable.d.ts.map +1 -0
- package/dist/src/types/serializable.js +19 -0
- package/dist/src/types/serializable.js.map +1 -0
- package/dist/src/utils/zod.d.ts +11 -0
- package/dist/src/utils/zod.d.ts.map +1 -0
- package/dist/src/utils/zod.js +14 -0
- package/dist/src/utils/zod.js.map +1 -0
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts +2 -0
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts.map +1 -0
- package/dist/src/vended-tools/bash/__tests__/{bash.test.js → bash.test.node.js} +3 -4
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -0
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts +2 -0
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts.map +1 -0
- package/dist/src/vended-tools/file_editor/__tests__/{file-editor.test.js → file-editor.test.node.js} +1 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.js.map +1 -0
- package/package.json +7 -2
- package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts +0 -2
- package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts.map +0 -1
- package/dist/src/vended-tools/bash/__tests__/bash.test.js.map +0 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts +0 -2
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts.map +0 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.js.map +0 -1
package/dist/src/agent/agent.js
CHANGED
|
@@ -52,13 +52,16 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
52
52
|
});
|
|
53
53
|
import { AgentResult, BedrockModel, contentBlockFromData, McpClient, Message, TextBlock, ToolResultBlock, ToolUseBlock, } from '../index.js';
|
|
54
54
|
import { systemPromptFromData } from '../types/messages.js';
|
|
55
|
-
import { normalizeError, ConcurrentInvocationError } from '../errors.js';
|
|
55
|
+
import { normalizeError, ConcurrentInvocationError, MaxTokensError } from '../errors.js';
|
|
56
|
+
import { isModelStreamEvent } from '../models/streaming.js';
|
|
56
57
|
import { ToolRegistry } from '../registry/tool-registry.js';
|
|
57
58
|
import { AgentState } from './state.js';
|
|
58
59
|
import { AgentPrinter, getDefaultAppender } from './printer.js';
|
|
59
60
|
import { SlidingWindowConversationManager } from '../conversation-manager/sliding-window-conversation-manager.js';
|
|
60
61
|
import { HookRegistryImplementation } from '../hooks/registry.js';
|
|
61
|
-
import {
|
|
62
|
+
import { InitializedEvent, AfterInvocationEvent, AfterModelCallEvent, AfterToolCallEvent, AfterToolsEvent, BeforeInvocationEvent, BeforeModelCallEvent, BeforeToolCallEvent, BeforeToolsEvent, HookableEvent, MessageAddedEvent, ModelStreamUpdateEvent, ContentBlockEvent, ModelMessageEvent, ToolResultEvent, AgentResultEvent, ToolStreamUpdateEvent, } from '../hooks/events.js';
|
|
63
|
+
import { createStructuredOutputContext } from '../structured-output/context.js';
|
|
64
|
+
import { StructuredOutputException } from '../structured-output/exceptions.js';
|
|
62
65
|
/**
|
|
63
66
|
* Orchestrates the interaction between a model, a set of tools, and MCP clients.
|
|
64
67
|
* The Agent is responsible for managing the lifecycle of tools and clients
|
|
@@ -96,6 +99,7 @@ export class Agent {
|
|
|
96
99
|
_initialized;
|
|
97
100
|
_isInvoking = false;
|
|
98
101
|
_printer;
|
|
102
|
+
_structuredOutputSchema;
|
|
99
103
|
/**
|
|
100
104
|
* Creates an instance of the Agent.
|
|
101
105
|
* @param config - The configuration for the agent.
|
|
@@ -126,6 +130,8 @@ export class Agent {
|
|
|
126
130
|
if (printer) {
|
|
127
131
|
this._printer = new AgentPrinter(getDefaultAppender());
|
|
128
132
|
}
|
|
133
|
+
// Store structured output schema
|
|
134
|
+
this._structuredOutputSchema = config?.structuredOutputSchema;
|
|
129
135
|
this._initialized = false;
|
|
130
136
|
}
|
|
131
137
|
async initialize() {
|
|
@@ -230,8 +236,9 @@ export class Agent {
|
|
|
230
236
|
let result = await streamGenerator.next();
|
|
231
237
|
while (!result.done) {
|
|
232
238
|
const event = result.value;
|
|
233
|
-
// Invoke hook callbacks for
|
|
234
|
-
|
|
239
|
+
// Invoke hook callbacks for hookable events (all current events are hookable;
|
|
240
|
+
// the guard exists for future StreamEvent subclasses that may not be)
|
|
241
|
+
if (event instanceof HookableEvent) {
|
|
235
242
|
await this.hooks.invokeCallbacks(event);
|
|
236
243
|
}
|
|
237
244
|
this._printer?.processEvent(event);
|
|
@@ -239,7 +246,10 @@ export class Agent {
|
|
|
239
246
|
result = await streamGenerator.next();
|
|
240
247
|
}
|
|
241
248
|
// Yield final result as last event
|
|
242
|
-
|
|
249
|
+
const agentResultEvent = new AgentResultEvent({ agent: this, result: result.value });
|
|
250
|
+
await this.hooks.invokeCallbacks(agentResultEvent);
|
|
251
|
+
this._printer?.processEvent(agentResultEvent);
|
|
252
|
+
yield agentResultEvent;
|
|
243
253
|
return result.value;
|
|
244
254
|
}
|
|
245
255
|
catch (e_1) {
|
|
@@ -259,32 +269,69 @@ export class Agent {
|
|
|
259
269
|
*/
|
|
260
270
|
async *_stream(args) {
|
|
261
271
|
let currentArgs = args;
|
|
262
|
-
|
|
272
|
+
let forcedToolChoice = undefined;
|
|
273
|
+
// Create structured output context (uses null object pattern when no schema)
|
|
274
|
+
const schema = this._structuredOutputSchema;
|
|
275
|
+
const context = createStructuredOutputContext(schema);
|
|
276
|
+
// Emit event before the try block
|
|
263
277
|
yield new BeforeInvocationEvent({ agent: this });
|
|
264
278
|
try {
|
|
279
|
+
// Register structured output tool
|
|
280
|
+
context.registerTool(this._toolRegistry);
|
|
265
281
|
// Main agent loop - continues until model stops without requesting tools
|
|
266
282
|
while (true) {
|
|
267
|
-
const modelResult = yield* this.invokeModel(currentArgs);
|
|
283
|
+
const modelResult = yield* this.invokeModel(currentArgs, forcedToolChoice);
|
|
268
284
|
currentArgs = undefined; // Only pass args on first invocation
|
|
285
|
+
const wasForced = forcedToolChoice !== undefined;
|
|
286
|
+
forcedToolChoice = undefined; // Clear after use
|
|
269
287
|
if (modelResult.stopReason !== 'toolUse') {
|
|
270
|
-
//
|
|
271
|
-
|
|
272
|
-
|
|
288
|
+
// Special handling for maxTokens - always fail regardless of whether we have structured output
|
|
289
|
+
if (modelResult.stopReason === 'maxTokens') {
|
|
290
|
+
throw new MaxTokensError('The model reached maxTokens before producing structured output. Consider increasing maxTokens in your model configuration.', modelResult.message);
|
|
291
|
+
}
|
|
292
|
+
// Check if we need to force structured output tool
|
|
293
|
+
if (!context.hasResult()) {
|
|
294
|
+
if (wasForced) {
|
|
295
|
+
// Already tried forcing - LLM refused to use the tool
|
|
296
|
+
throw new StructuredOutputException('The model failed to invoke the structured output tool even after it was forced.');
|
|
297
|
+
}
|
|
298
|
+
// Force the model to use the structured output tool
|
|
299
|
+
const toolName = context.getToolName();
|
|
300
|
+
forcedToolChoice = { tool: { name: toolName } };
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
// Loop terminates - no tool use requested (and structured output satisfied if needed)
|
|
304
|
+
yield this._appendMessage(modelResult.message);
|
|
305
|
+
const structuredOutput = context.getResult();
|
|
273
306
|
return new AgentResult({
|
|
274
307
|
stopReason: modelResult.stopReason,
|
|
275
308
|
lastMessage: modelResult.message,
|
|
309
|
+
structuredOutput,
|
|
276
310
|
});
|
|
277
311
|
}
|
|
278
312
|
// Execute tools sequentially
|
|
279
313
|
const toolResultMessage = yield* this.executeTools(modelResult.message, this._toolRegistry);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Deferred append: both messages are added AFTER tool execution completes.
|
|
316
|
+
* This keeps agent.messages in a valid, reinvokable state at all times:
|
|
317
|
+
*
|
|
318
|
+
* - If interrupted during tool execution, messages has no dangling toolUse
|
|
319
|
+
* without a matching toolResult, so the agent can be reinvoked cleanly.
|
|
320
|
+
* - The Python SDK appends the assistant message BEFORE tool execution,
|
|
321
|
+
* requiring recovery logic (generate_missing_tool_result_content) on
|
|
322
|
+
* interrupts. We avoid that by deferring.
|
|
323
|
+
* - Trade-off: MessageAddedEvent for the assistant message fires after tools
|
|
324
|
+
* complete (not before as in Python), and agent.messages is incomplete
|
|
325
|
+
* during tool execution. Events like BeforeToolsEvent.message and
|
|
326
|
+
* BeforeToolCallEvent.toolUse provide the data directly.
|
|
327
|
+
*/
|
|
328
|
+
yield this._appendMessage(modelResult.message);
|
|
329
|
+
yield this._appendMessage(toolResultMessage);
|
|
285
330
|
}
|
|
286
331
|
}
|
|
287
332
|
finally {
|
|
333
|
+
// Cleanup structured output context
|
|
334
|
+
context.cleanup(this._toolRegistry);
|
|
288
335
|
// Always emit final event
|
|
289
336
|
yield new AfterInvocationEvent({ agent: this });
|
|
290
337
|
}
|
|
@@ -348,22 +395,28 @@ export class Agent {
|
|
|
348
395
|
* Invokes the model provider and streams all events.
|
|
349
396
|
*
|
|
350
397
|
* @param args - Optional arguments for invoking the model
|
|
398
|
+
* @param toolChoice - Optional tool choice to force specific tool usage
|
|
351
399
|
* @returns Object containing the assistant message and stop reason
|
|
352
400
|
*/
|
|
353
|
-
async *invokeModel(args) {
|
|
401
|
+
async *invokeModel(args, forcedToolChoice) {
|
|
354
402
|
// Normalize input and append messages to conversation
|
|
355
403
|
const messagesToAppend = this._normalizeInput(args);
|
|
356
404
|
for (const message of messagesToAppend) {
|
|
357
|
-
yield
|
|
405
|
+
yield this._appendMessage(message);
|
|
358
406
|
}
|
|
359
407
|
const toolSpecs = this._toolRegistry.values().map((tool) => tool.toolSpec);
|
|
360
408
|
const streamOptions = { toolSpecs };
|
|
361
409
|
if (this.systemPrompt !== undefined) {
|
|
362
410
|
streamOptions.systemPrompt = this.systemPrompt;
|
|
363
411
|
}
|
|
412
|
+
// Add tool choice if provided (for structured output forcing)
|
|
413
|
+
if (forcedToolChoice) {
|
|
414
|
+
streamOptions.toolChoice = forcedToolChoice;
|
|
415
|
+
}
|
|
364
416
|
yield new BeforeModelCallEvent({ agent: this });
|
|
365
417
|
try {
|
|
366
418
|
const { message, stopReason } = yield* this._streamFromModel(this.messages, streamOptions);
|
|
419
|
+
yield new ModelMessageEvent({ agent: this, message, stopReason });
|
|
367
420
|
const afterModelCallEvent = new AfterModelCallEvent({ agent: this, stopData: { message, stopReason } });
|
|
368
421
|
yield afterModelCallEvent;
|
|
369
422
|
if (afterModelCallEvent.retry) {
|
|
@@ -386,7 +439,16 @@ export class Agent {
|
|
|
386
439
|
}
|
|
387
440
|
}
|
|
388
441
|
/**
|
|
389
|
-
* Streams events from the model and
|
|
442
|
+
* Streams events from the model and dispatches appropriate events for each.
|
|
443
|
+
*
|
|
444
|
+
* The model's `streamAggregated()` yields two kinds of output:
|
|
445
|
+
* - **ModelStreamEvent**: Transient streaming deltas (partial data while generating).
|
|
446
|
+
* Wrapped in {@link ModelStreamUpdateEvent} before yielding.
|
|
447
|
+
* - **ContentBlock**: Fully assembled results (after all deltas accumulate).
|
|
448
|
+
* Wrapped in {@link ContentBlockEvent} before yielding.
|
|
449
|
+
*
|
|
450
|
+
* These are separate event classes because they represent different granularities
|
|
451
|
+
* (partial deltas vs finished blocks). Both are yielded in the stream and hookable.
|
|
390
452
|
*
|
|
391
453
|
* @param messages - Messages to send to the model
|
|
392
454
|
* @param streamOptions - Options for streaming
|
|
@@ -397,10 +459,14 @@ export class Agent {
|
|
|
397
459
|
let result = await streamGenerator.next();
|
|
398
460
|
while (!result.done) {
|
|
399
461
|
const event = result.value;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
462
|
+
if (isModelStreamEvent(event)) {
|
|
463
|
+
// ModelStreamEvent: wrap in ModelStreamUpdateEvent
|
|
464
|
+
yield new ModelStreamUpdateEvent({ agent: this, event });
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// ContentBlock: wrap in ContentBlockEvent
|
|
468
|
+
yield new ContentBlockEvent({ agent: this, contentBlock: event });
|
|
469
|
+
}
|
|
404
470
|
result = await streamGenerator.next();
|
|
405
471
|
}
|
|
406
472
|
// result.done is true, result.value contains the return value
|
|
@@ -425,8 +491,8 @@ export class Agent {
|
|
|
425
491
|
for (const toolUseBlock of toolUseBlocks) {
|
|
426
492
|
const toolResultBlock = yield* this.executeTool(toolUseBlock, toolRegistry);
|
|
427
493
|
toolResultBlocks.push(toolResultBlock);
|
|
428
|
-
// Yield the tool result
|
|
429
|
-
yield toolResultBlock;
|
|
494
|
+
// Yield the tool result event as it's created
|
|
495
|
+
yield new ToolResultEvent({ agent: this, result: toolResultBlock });
|
|
430
496
|
}
|
|
431
497
|
// Create user message with tool results
|
|
432
498
|
const toolResultMessage = new Message({
|
|
@@ -478,7 +544,16 @@ export class Agent {
|
|
|
478
544
|
agent: this,
|
|
479
545
|
};
|
|
480
546
|
try {
|
|
481
|
-
|
|
547
|
+
// Manually iterate tool stream to wrap each ToolStreamEvent in ToolStreamUpdateEvent.
|
|
548
|
+
// This keeps the tool authoring interface unchanged — tools construct ToolStreamEvent
|
|
549
|
+
// without knowledge of agents or hooks, and we wrap at the boundary.
|
|
550
|
+
const toolGenerator = tool.stream(toolContext);
|
|
551
|
+
let toolNext = await toolGenerator.next();
|
|
552
|
+
while (!toolNext.done) {
|
|
553
|
+
yield new ToolStreamUpdateEvent({ agent: this, event: toolNext.value });
|
|
554
|
+
toolNext = await toolGenerator.next();
|
|
555
|
+
}
|
|
556
|
+
const result = toolNext.value;
|
|
482
557
|
if (!result) {
|
|
483
558
|
// Tool didn't return a result
|
|
484
559
|
toolResult = new ToolResultBlock({
|
|
@@ -519,19 +594,14 @@ export class Agent {
|
|
|
519
594
|
}
|
|
520
595
|
}
|
|
521
596
|
/**
|
|
522
|
-
* Appends a message to the conversation history
|
|
523
|
-
* and returns the event for yielding.
|
|
597
|
+
* Appends a message to the conversation history and returns the event for yielding.
|
|
524
598
|
*
|
|
525
599
|
* @param message - The message to append
|
|
526
|
-
* @returns MessageAddedEvent to be yielded
|
|
600
|
+
* @returns MessageAddedEvent to be yielded
|
|
527
601
|
*/
|
|
528
|
-
|
|
602
|
+
_appendMessage(message) {
|
|
529
603
|
this.messages.push(message);
|
|
530
|
-
|
|
531
|
-
// Invoke hooks immediately for message tracking
|
|
532
|
-
await this.hooks.invokeCallbacks(event);
|
|
533
|
-
// Return event for yielding (stream will skip hook invocation for MessageAddedEvent)
|
|
534
|
-
return event;
|
|
604
|
+
return new MessageAddedEvent({ agent: this, message });
|
|
535
605
|
}
|
|
536
606
|
}
|
|
537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CAAC,OAAgB;QACrC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3B,OAAO,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACxD,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,QAAkB;IACtC,MAAM,KAAK,GAAW,EAAE,CAAA;IACxB,MAAM,UAAU,GAAgB,EAAE,CAAA;IAElC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;YAC/E,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;YAC1B,UAAU,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAA;QACtC,CAAC;aAAM,IAAI,IAAI,YAAY,SAAS,EAAE,CAAC;YACrC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;AAC9B,CAAC"}
|
|
@@ -46,6 +46,10 @@ export declare class AgentPrinter implements Printer {
|
|
|
46
46
|
* @param event - The event to process
|
|
47
47
|
*/
|
|
48
48
|
processEvent(event: AgentStreamEvent): void;
|
|
49
|
+
/**
|
|
50
|
+
* Handle raw model stream events unwrapped from ModelStreamUpdateEvent.
|
|
51
|
+
*/
|
|
52
|
+
private handleModelStreamEvent;
|
|
49
53
|
/**
|
|
50
54
|
* Handle content block delta events (text or reasoning).
|
|
51
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../../src/agent/printer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../../src/agent/printer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAQzD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAO3D;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC5C;AAED;;;GAGG;AACH,qBAAa,YAAa,YAAW,OAAO;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;IAClD,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,oBAAoB,CAAiB;IAE7C;;;OAGG;gBACS,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;IAI5C;;;OAGG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAInC;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAgBlD;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAgB9B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwB/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAS/B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAW9B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;CAOzB"}
|
|
@@ -40,6 +40,22 @@ export class AgentPrinter {
|
|
|
40
40
|
* @param event - The event to process
|
|
41
41
|
*/
|
|
42
42
|
processEvent(event) {
|
|
43
|
+
switch (event.type) {
|
|
44
|
+
case 'modelStreamUpdateEvent':
|
|
45
|
+
this.handleModelStreamEvent(event.event);
|
|
46
|
+
break;
|
|
47
|
+
case 'toolResultEvent':
|
|
48
|
+
this.handleToolResult(event);
|
|
49
|
+
break;
|
|
50
|
+
// Ignore other event types
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handle raw model stream events unwrapped from ModelStreamUpdateEvent.
|
|
57
|
+
*/
|
|
58
|
+
handleModelStreamEvent(event) {
|
|
43
59
|
switch (event.type) {
|
|
44
60
|
case 'modelContentBlockDeltaEvent':
|
|
45
61
|
this.handleContentBlockDelta(event);
|
|
@@ -50,10 +66,6 @@ export class AgentPrinter {
|
|
|
50
66
|
case 'modelContentBlockStopEvent':
|
|
51
67
|
this.handleContentBlockStop();
|
|
52
68
|
break;
|
|
53
|
-
case 'toolResultBlock':
|
|
54
|
-
this.handleToolResult(event);
|
|
55
|
-
break;
|
|
56
|
-
// Ignore other event types
|
|
57
69
|
default:
|
|
58
70
|
break;
|
|
59
71
|
}
|
|
@@ -134,10 +146,10 @@ export class AgentPrinter {
|
|
|
134
146
|
* Outputs completion status.
|
|
135
147
|
*/
|
|
136
148
|
handleToolResult(event) {
|
|
137
|
-
if (event.status === 'success') {
|
|
149
|
+
if (event.result.status === 'success') {
|
|
138
150
|
this.write('✓ Tool completed\n');
|
|
139
151
|
}
|
|
140
|
-
else if (event.status === 'error') {
|
|
152
|
+
else if (event.result.status === 'error') {
|
|
141
153
|
this.write('✗ Tool failed\n');
|
|
142
154
|
}
|
|
143
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.js","sourceRoot":"","sources":["../../../src/agent/printer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"printer.js","sourceRoot":"","sources":["../../../src/agent/printer.ts"],"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;YAC3C,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot API for capturing and restoring agent state.
|
|
3
|
+
*
|
|
4
|
+
* This module provides types and utilities for point-in-time capture and restoration
|
|
5
|
+
* of agent state, enabling use cases like checkpointing, undo/redo, and branching
|
|
6
|
+
* conversation flows.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: The takeSnapshot and loadSnapshot functions are currently internal implementation
|
|
9
|
+
* details. We anticipate opening these up as public Agent methods in a future release
|
|
10
|
+
* after API review, but for now they are top-level functions to unblock snapshot
|
|
11
|
+
* functionality without committing to a public API surface.
|
|
12
|
+
*/
|
|
13
|
+
import type { JSONValue } from '../types/json.js';
|
|
14
|
+
import type { Agent } from './agent.js';
|
|
15
|
+
/**
|
|
16
|
+
* Current schema version of the snapshot format.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SNAPSHOT_SCHEMA_VERSION = "1.0";
|
|
19
|
+
/**
|
|
20
|
+
* All available fields that can be included in a snapshot.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ALL_SNAPSHOT_FIELDS: readonly ["messages", "state", "systemPrompt"];
|
|
23
|
+
/**
|
|
24
|
+
* Strongly typed preset definitions for snapshot field selection.
|
|
25
|
+
* This object allows easy evolution of presets and type-safe access.
|
|
26
|
+
*/
|
|
27
|
+
export declare const SNAPSHOT_PRESETS: {
|
|
28
|
+
readonly session: readonly ["messages", "state", "systemPrompt"];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Preset name for snapshot field selection.
|
|
32
|
+
*/
|
|
33
|
+
export type SnapshotPreset = keyof typeof SNAPSHOT_PRESETS;
|
|
34
|
+
/**
|
|
35
|
+
* Valid snapshot field names.
|
|
36
|
+
*/
|
|
37
|
+
export type SnapshotField = (typeof ALL_SNAPSHOT_FIELDS)[number];
|
|
38
|
+
/**
|
|
39
|
+
* Scope defines the context for snapshot data.
|
|
40
|
+
*/
|
|
41
|
+
export type Scope = 'agent' | 'multiAgent';
|
|
42
|
+
/**
|
|
43
|
+
* Point-in-time capture of agent state.
|
|
44
|
+
*/
|
|
45
|
+
export interface Snapshot {
|
|
46
|
+
/**
|
|
47
|
+
* Scope identifying the snapshot context (agent or multi-agent).
|
|
48
|
+
*/
|
|
49
|
+
scope: Scope;
|
|
50
|
+
/**
|
|
51
|
+
* Schema version string for forward compatibility.
|
|
52
|
+
*/
|
|
53
|
+
schemaVersion: string;
|
|
54
|
+
/**
|
|
55
|
+
* ISO 8601 timestamp of when snapshot was created.
|
|
56
|
+
*/
|
|
57
|
+
createdAt: string;
|
|
58
|
+
/**
|
|
59
|
+
* Agent's evolving state (messages, state, systemPrompt). Strands-owned.
|
|
60
|
+
*/
|
|
61
|
+
data: Record<string, JSONValue>;
|
|
62
|
+
/**
|
|
63
|
+
* Application-owned data. Strands does not read or modify this.
|
|
64
|
+
*/
|
|
65
|
+
appData: Record<string, JSONValue>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates an ISO 8601 timestamp string.
|
|
69
|
+
*
|
|
70
|
+
* @returns Current timestamp in ISO 8601 format
|
|
71
|
+
*/
|
|
72
|
+
export declare function createTimestamp(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Options for taking a snapshot of agent state.
|
|
75
|
+
*/
|
|
76
|
+
export type TakeSnapshotOptions = {
|
|
77
|
+
/**
|
|
78
|
+
* Preset to use as the starting set of fields.
|
|
79
|
+
* If not specified, starts with an empty set (unless include is specified).
|
|
80
|
+
*/
|
|
81
|
+
preset?: SnapshotPreset;
|
|
82
|
+
/**
|
|
83
|
+
* Fields to add to the snapshot.
|
|
84
|
+
* These are added to the preset fields (if any).
|
|
85
|
+
*/
|
|
86
|
+
include?: SnapshotField[];
|
|
87
|
+
/**
|
|
88
|
+
* Fields to exclude from the snapshot.
|
|
89
|
+
* Applied after preset and include to filter out specific fields.
|
|
90
|
+
*/
|
|
91
|
+
exclude?: SnapshotField[];
|
|
92
|
+
/**
|
|
93
|
+
* Application-owned data to store in the snapshot.
|
|
94
|
+
* Strands does not read or modify this data.
|
|
95
|
+
*/
|
|
96
|
+
appData?: Record<string, JSONValue>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Takes a snapshot of the agent's current state.
|
|
100
|
+
*
|
|
101
|
+
* NOTE: This is currently an internal implementation detail. We anticipate
|
|
102
|
+
* exposing this as a public Agent method in a future release after API review.
|
|
103
|
+
*
|
|
104
|
+
* @param agent - The agent to snapshot
|
|
105
|
+
* @param options - Snapshot options
|
|
106
|
+
* @returns A snapshot of the agent's state
|
|
107
|
+
*/
|
|
108
|
+
export declare function takeSnapshot(agent: Agent, options: TakeSnapshotOptions): Snapshot;
|
|
109
|
+
/**
|
|
110
|
+
* Loads a snapshot into the agent, restoring its state.
|
|
111
|
+
*
|
|
112
|
+
* NOTE: This is currently an internal implementation detail. We anticipate
|
|
113
|
+
* exposing this as a public Agent method in a future release after API review.
|
|
114
|
+
*
|
|
115
|
+
* @param agent - The agent to restore state into
|
|
116
|
+
* @param snapshot - The snapshot to load
|
|
117
|
+
*/
|
|
118
|
+
export declare function loadSnapshot(agent: Agent, snapshot: Snapshot): void;
|
|
119
|
+
/**
|
|
120
|
+
* Resolves snapshot fields based on preset/include/exclude parameters.
|
|
121
|
+
*
|
|
122
|
+
* Order of operations:
|
|
123
|
+
* 1. Start with preset fields (if specified)
|
|
124
|
+
* 2. Add include fields
|
|
125
|
+
* 3. Remove exclude fields
|
|
126
|
+
*
|
|
127
|
+
* @param options - Snapshot options containing preset, include, and exclude fields
|
|
128
|
+
* @returns Set of resolved field names
|
|
129
|
+
* @throws Error if no fields would be included
|
|
130
|
+
*/
|
|
131
|
+
export declare function resolveSnapshotFields(options?: TakeSnapshotOptions): Set<SnapshotField>;
|
|
132
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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