strands-darwin 0.0.53 → 0.0.54
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/patches/{@strands-agents+sdk+1.21.0.patch → @strands-agents+sdk+1.25.0.patch} +73 -48
- package/dist/src/agent/prompt-steering.d.ts +21 -0
- package/dist/src/agent/prompt-steering.js +58 -0
- package/dist/src/agent/prompt-steering.js.map +1 -0
- package/dist/src/agent/runtime.d.ts +2 -1
- package/dist/src/agent/runtime.js +18 -1
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/sdk-logging.js +7 -6
- package/dist/src/agent/sdk-logging.js.map +1 -1
- package/dist/src/config.d.ts +7 -5
- package/dist/src/config.js +30 -7
- package/dist/src/config.js.map +1 -1
- package/dist/src/mcp/codegraph-preflight.js +23 -16
- package/dist/src/mcp/codegraph-preflight.js.map +1 -1
- package/dist/src/mcp/web-search-empty-results.js +23 -15
- package/dist/src/mcp/web-search-empty-results.js.map +1 -1
- package/dist/src/model-headers-command.d.ts +30 -0
- package/dist/src/model-headers-command.js +354 -0
- package/dist/src/model-headers-command.js.map +1 -0
- package/dist/src/trajectory/record.d.ts +3 -1
- package/dist/src/trajectory/record.js.map +1 -1
- package/dist/src/trajectory/rewind-history.js +2 -2
- package/dist/src/trajectory/rewind-history.js.map +1 -1
- package/dist/src/trajectory/writer.d.ts +4 -2
- package/dist/src/trajectory/writer.js +14 -2
- package/dist/src/trajectory/writer.js.map +1 -1
- package/dist/src/tui/App.js +23 -3
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/prompt-queue.d.ts +7 -4
- package/dist/src/tui/prompt-queue.js +17 -4
- package/dist/src/tui/prompt-queue.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p>
|
|
6
6
|
<a href="https://nodejs.org/"><img alt="Node.js >=22.0.0" src="https://img.shields.io/badge/Node.js-%3E%3D22.0.0-339933?logo=nodedotjs&logoColor=white"></a>
|
|
7
7
|
<a href="https://www.typescriptlang.org/"><img alt="TypeScript 7.0.2" src="https://img.shields.io/badge/TypeScript-7.0.2-3178C6?logo=typescript&logoColor=white"></a>
|
|
8
|
-
<a href="https://www.npmjs.com/package/@strands-agents/sdk"><img alt="Strands Agents SDK 1.
|
|
8
|
+
<a href="https://www.npmjs.com/package/@strands-agents/sdk"><img alt="Strands Agents SDK 1.25.0" src="https://img.shields.io/badge/Strands_Agents_SDK-1.25.0-5E4AE3"></a>
|
|
9
9
|
<a href="https://spdx.org/licenses/ISC.html"><img alt="ISC License" src="https://img.shields.io/badge/License-ISC-blue.svg"></a>
|
|
10
10
|
</p>
|
|
11
11
|
<img src="docs/images/welcome.png" alt="darwin terminal welcome screen" width="100%">
|
|
@@ -104,7 +104,7 @@ The only active model/provider configuration is `~/.darwin/config.json`. With no
|
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
Bedrock uses the standard AWS credential chain and requires an inference-profile model ID such as `us.`, `eu.`, `apac.`, or `global.`, not a bare `anthropic.*` ID. Direct providers use `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`; direct Anthropic also
|
|
107
|
+
Bedrock uses the standard AWS credential chain and requires an inference-profile model ID such as `us.`, `eu.`, `apac.`, or `global.`, not a bare `anthropic.*` ID. Direct providers use `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`; direct Anthropic and OpenAI also honour `baseUrl` (or their provider's base-URL environment variable). OpenAI gateways with rotating bearer/identity headers can use a bounded [`headersCommand` login helper](docs/user-guide/getting-started.md#openai-gateways-with-a-login-helper).
|
|
108
108
|
|
|
109
109
|
For multiple switchable models, provider-specific fields, Bedrock Mantle, caching, thinking effort, context limits, and all session settings, read [Getting started and providers](docs/user-guide/getting-started.md) and [Configuration and context](docs/user-guide/configuration.md).
|
|
110
110
|
|
package/README.zh-CN.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p>
|
|
6
6
|
<a href="https://nodejs.org/"><img alt="Node.js >=22.0.0" src="https://img.shields.io/badge/Node.js-%3E%3D22.0.0-339933?logo=nodedotjs&logoColor=white"></a>
|
|
7
7
|
<a href="https://www.typescriptlang.org/"><img alt="TypeScript 7.0.2" src="https://img.shields.io/badge/TypeScript-7.0.2-3178C6?logo=typescript&logoColor=white"></a>
|
|
8
|
-
<a href="https://www.npmjs.com/package/@strands-agents/sdk"><img alt="Strands Agents SDK 1.
|
|
8
|
+
<a href="https://www.npmjs.com/package/@strands-agents/sdk"><img alt="Strands Agents SDK 1.25.0" src="https://img.shields.io/badge/Strands_Agents_SDK-1.25.0-5E4AE3"></a>
|
|
9
9
|
<a href="https://spdx.org/licenses/ISC.html"><img alt="ISC License" src="https://img.shields.io/badge/License-ISC-blue.svg"></a>
|
|
10
10
|
</p>
|
|
11
11
|
<img src="docs/images/welcome.png" alt="darwin 终端欢迎界面" width="100%">
|
|
@@ -104,7 +104,7 @@ pnpm build # 输出 dist/(CLI、内置 skill 和生成的 pat
|
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
Bedrock 使用标准 AWS 凭证链。模型 ID 必须是 `us.`、`eu.`、`apac.` 或 `global.` 等推理配置文件 ID,不能直接填写 `anthropic.*`。直连供应商默认读取 `ANTHROPIC_API_KEY` 或 `OPENAI_API_KEY`;直连 Anthropic
|
|
107
|
+
Bedrock 使用标准 AWS 凭证链。模型 ID 必须是 `us.`、`eu.`、`apac.` 或 `global.` 等推理配置文件 ID,不能直接填写 `anthropic.*`。直连供应商默认读取 `ANTHROPIC_API_KEY` 或 `OPENAI_API_KEY`;直连 Anthropic 和 OpenAI 还支持 `baseUrl`(或对应供应商的 base-URL 环境变量)。需要动态 bearer 和身份认证头的 OpenAI 网关可通过有界的 [`headersCommand` 登录 helper](docs/user-guide/getting-started.zh-CN.md#通过登录-helper-接入-openai-网关) 接入。
|
|
108
108
|
|
|
109
109
|
多模型切换、各供应商字段、Bedrock Mantle、缓存、思考强度、上下文限制和全部会话设置,见[入门与模型供应商](docs/user-guide/getting-started.zh-CN.md)和[配置与上下文](docs/user-guide/configuration.zh-CN.md)。
|
|
110
110
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/index.d.ts b/node_modules/@strands-agents/sdk/dist/src/index.d.ts
|
|
2
|
-
index
|
|
2
|
+
index efdd001a474c19b92c1aee8a02ed40f0a78c96f1..909f39e2d0afce9f248b2327fd4836515caf5e7f 100644
|
|
3
3
|
--- a/node_modules/@strands-agents/sdk/dist/src/index.d.ts
|
|
4
4
|
+++ b/node_modules/@strands-agents/sdk/dist/src/index.d.ts
|
|
5
|
-
@@ -
|
|
5
|
+
@@ -70,6 +70,7 @@ export { ConversationManager, type ProactiveCompressionConfig, type Conversation
|
|
6
6
|
export { NullConversationManager } from './conversation-manager/null-conversation-manager.js';
|
|
7
7
|
export { SlidingWindowConversationManager, type SlidingWindowConversationManagerConfig, } from './conversation-manager/sliding-window-conversation-manager.js';
|
|
8
8
|
export { SummarizingConversationManager, type SummarizingConversationManagerConfig, } from './conversation-manager/summarizing-conversation-manager.js';
|
|
@@ -11,7 +11,7 @@ index 1918f11258bdad49dee3e3552440a48ff0feba80..5f24f38fa0bd7dec9dc8faa471ae727d
|
|
|
11
11
|
export type { Logger } from './logging/types.js';
|
|
12
12
|
export { type McpClientOptions, type McpListOptions, type McpListToolsOptions, type McpProgress, type McpProgressCallback, type McpToolFilterCallback, type McpToolFilters, type McpToolMatcher, type McpClientConfig, type McpClientCredentials, type McpTransport, type McpCallToolOptions, type TasksConfig, type McpConnectionState, type McpLoadServersOptions, type McpServerConfig, type SerializableMcpToolFilters, McpClient, McpTaskCancelledError, McpTaskFailedError, } from './mcp/index.js';
|
|
13
13
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/index.js b/node_modules/@strands-agents/sdk/dist/src/index.js
|
|
14
|
-
index
|
|
14
|
+
index bcfae4d52b91f0de2b7e118ec76092fdf8b2ded8..9a2d0c96bc91fb5e669907bd9b7a1886b66b213c 100644
|
|
15
15
|
--- a/node_modules/@strands-agents/sdk/dist/src/index.js
|
|
16
16
|
+++ b/node_modules/@strands-agents/sdk/dist/src/index.js
|
|
17
17
|
@@ -57,6 +57,7 @@ export { ConversationManager, } from './conversation-manager/conversation-manage
|
|
@@ -23,10 +23,10 @@ index aaa869eda7dc0f4b408c9f5085ea96e960a84c50..ca4c9519a51fd5528b27e051e7958e31
|
|
|
23
23
|
export { configureLogging } from './logging/logger.js';
|
|
24
24
|
// MCP Client types and implementations
|
|
25
25
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/anthropic.js b/node_modules/@strands-agents/sdk/dist/src/models/anthropic.js
|
|
26
|
-
index
|
|
26
|
+
index fe1ca5dd5d8ba9d2a2af47c0c2eeb11a181a4881..dc45112656c1dd9141d6631778b7275bb14abb43 100644
|
|
27
27
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/anthropic.js
|
|
28
28
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/anthropic.js
|
|
29
|
-
@@ -
|
|
29
|
+
@@ -1073,6 +1073,11 @@ export class AnthropicModel extends Model {
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
case 'reasoningBlock':
|
|
@@ -39,34 +39,27 @@ index d3b97dfe1f49f9c8251f4d74a2640b7684691f98..e747a7ac319ba38ce340aec08800dc75
|
|
|
39
39
|
return {
|
|
40
40
|
type: 'thinking',
|
|
41
41
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/bedrock.js b/node_modules/@strands-agents/sdk/dist/src/models/bedrock.js
|
|
42
|
-
index
|
|
42
|
+
index 49031689ba7ada7acc5f4ea931be053a1e7f242c..0e34b89daf925858a8201601ef9a3c0e6c4b8a4d 100644
|
|
43
43
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/bedrock.js
|
|
44
44
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/bedrock.js
|
|
45
|
-
@@ -
|
|
45
|
+
@@ -1126,6 +1126,12 @@ export class BedrockModel extends Model {
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
case 'reasoningBlock': {
|
|
49
|
-
+ // darwin patch (SER-101): Responses
|
|
50
|
-
+ //
|
|
51
|
-
+ //
|
|
52
|
-
+ // which is what another Converse model's reasoning (Kimi) carries.
|
|
49
|
+
+ // darwin patch (SER-101): Responses provenance is not an Anthropic
|
|
50
|
+
+ // signature, and must never reach Converse, including unknown profiles.
|
|
51
|
+
+ // Upstream _rejectsReasoningBlock owns unsigned Claude filtering now.
|
|
53
52
|
+ if (typeof block.signature === 'string' && block.signature.startsWith('darwin-responses:')) {
|
|
54
53
|
+ return undefined;
|
|
55
|
-
+ }
|
|
56
|
-
+ if (block.signature === undefined &&
|
|
57
|
-
+ !block.redactedContent &&
|
|
58
|
-
+ /anthropic|claude/i.test(this._config.modelId ?? '')) {
|
|
59
|
-
+ logger.debug(`model_id=<${this._config.modelId}> | signature-less reasoning | dropping`);
|
|
60
|
-
+ return undefined;
|
|
61
54
|
+ }
|
|
62
55
|
if (block.text !== undefined || block.signature !== undefined) {
|
|
63
56
|
return {
|
|
64
57
|
reasoningContent: {
|
|
65
58
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/openai/chat-adapter.js b/node_modules/@strands-agents/sdk/dist/src/models/openai/chat-adapter.js
|
|
66
|
-
index
|
|
59
|
+
index 900accb2abe4523d13861a00a2d62df153ffce1a..ee072b3ab4c1f1ad7ec9c404ec46c66548884589 100644
|
|
67
60
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/openai/chat-adapter.js
|
|
68
61
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/openai/chat-adapter.js
|
|
69
|
-
@@ -
|
|
62
|
+
@@ -244,6 +244,12 @@ function formatChatMessages(messages) {
|
|
70
63
|
break;
|
|
71
64
|
}
|
|
72
65
|
case 'reasoningBlock': {
|
|
@@ -92,23 +85,23 @@ index 17a473fe3bcdcc02e17cd95283c832d9021634c1..6e5cda23f672684b3926450322459279
|
|
|
92
85
|
/**
|
|
93
86
|
* Error patterns that indicate rate limiting.
|
|
94
87
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/openai/model.js b/node_modules/@strands-agents/sdk/dist/src/models/openai/model.js
|
|
95
|
-
index
|
|
88
|
+
index a09ae7052847894f0b23374c3c491ae899f732fc..7bcbad5135fbc5359bcd58305d9862159e58ca15 100644
|
|
96
89
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/openai/model.js
|
|
97
90
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/openai/model.js
|
|
98
|
-
@@ -
|
|
99
|
-
|
|
100
|
-
const request = formatResponsesRequest(this._config, messages, options, this.
|
|
91
|
+
@@ -252,7 +252,7 @@ export class OpenAIModel extends Model {
|
|
92
|
+
const stateful = this.stateful;
|
|
93
|
+
const request = formatResponsesRequest(this._config, messages, options, stateful, this.modelInfo);
|
|
101
94
|
const stream = await this._client.responses.create(request, { signal: options?.cancelSignal });
|
|
102
95
|
- const state = createResponsesStreamState();
|
|
103
96
|
+ const state = createResponsesStreamState(request.model);
|
|
104
97
|
for await (const event of stream) {
|
|
105
|
-
for (const sdkEvent of mapResponsesEventToSDK(event, state,
|
|
98
|
+
for (const sdkEvent of mapResponsesEventToSDK(event, state, stateful, options?.modelState)) {
|
|
106
99
|
yield sdkEvent;
|
|
107
100
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.d.ts b/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.d.ts
|
|
108
|
-
index
|
|
101
|
+
index 656dea6674a1f6d58a7cf2dc716ff7a924155c7c..898b86a7f4e115d84004ac9b9849638b7da561e4 100644
|
|
109
102
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.d.ts
|
|
110
103
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.d.ts
|
|
111
|
-
@@ -
|
|
104
|
+
@@ -57,13 +57,32 @@ export interface ResponsesStreamState {
|
|
112
105
|
cacheWriteInputTokens?: number;
|
|
113
106
|
} | null;
|
|
114
107
|
stopReason: StopReason;
|
|
@@ -143,12 +136,12 @@ index a7b4edd12a5ac33277a5ad2c4bcea4c4d8c1ea7d..655e065df9823e8897759978a46cac8b
|
|
|
143
136
|
* Maps a single Responses API stream event to zero or more SDK events. Mutates
|
|
144
137
|
* `state` and, when `stateful` is `true`, writes `responseId` into `modelState`.
|
|
145
138
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.js b/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.js
|
|
146
|
-
index
|
|
139
|
+
index 0f046114e8f68242b1ec1a0bf11ef6e9a8e6ce1c..f20fd9722f177556dd75f3d4a0b0acb08acf8882 100644
|
|
147
140
|
--- a/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.js
|
|
148
141
|
+++ b/node_modules/@strands-agents/sdk/dist/src/models/openai/responses-adapter.js
|
|
149
|
-
@@ -
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
@@ -24,6 +24,72 @@ export const DEFAULT_RESPONSES_MODEL_ID = MODEL_DEFAULTS.openai.modelId;
|
|
143
|
+
/** Input content types that accept `prompt_cache_breakpoint` (gpt-5.6+). */
|
|
144
|
+
const CACHEABLE_INPUT_TYPES = new Set(['input_text', 'input_image', 'input_file']);
|
|
152
145
|
const MANAGED_PARAMS = new Set(['model', 'input', 'stream', 'store']);
|
|
153
146
|
+/**
|
|
154
147
|
+ * darwin patch (SER-101): provenance of reasoning captured on the Responses path.
|
|
@@ -219,16 +212,48 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
219
212
|
/**
|
|
220
213
|
* Logs a warning for each responses-managed key present in `params`.
|
|
221
214
|
*
|
|
222
|
-
@@ -
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
+
|
|
215
|
+
@@ -42,9 +108,12 @@ export function formatResponsesRequest(config, messages, options, stateful, mode
|
|
216
|
+
const { cacheConfig } = config;
|
|
217
|
+
const cachePoints = modelInfo.capabilities?.promptCaching === 'cachePoints';
|
|
218
|
+
const cacheMessages = cachePoints && cacheConfig !== undefined && cacheConfig.messagesTTL !== false;
|
|
219
|
+
+ // darwin patch (SER-101): both upstream formatting paths keep the same
|
|
220
|
+
+ // stateless, same-model provenance boundary; this does not enable caching.
|
|
221
|
+
+ const replayModelId = stateful ? undefined : (config.modelId ?? DEFAULT_RESPONSES_MODEL_ID);
|
|
222
|
+
const { input, explicitCache } = cacheMessages
|
|
223
|
+
- ? formatCacheableResponsesMessages(messages, options?.dynamicTrailingBlocks, cacheConfig.messagesTTL)
|
|
224
|
+
- : { input: formatResponsesMessages(messages), explicitCache: false };
|
|
225
|
+
+ ? formatCacheableResponsesMessages(messages, options?.dynamicTrailingBlocks, cacheConfig.messagesTTL, replayModelId)
|
|
226
|
+
+ : { input: formatResponsesMessages(messages, replayModelId), explicitCache: false };
|
|
228
227
|
// User `params` are spread first so provider-managed fields (asserted
|
|
229
228
|
// required by `ResponseCreateParamsStreaming` below) always win. The
|
|
230
229
|
// managed-params warning fires at config time to surface the collision.
|
|
231
|
-
@@ -
|
|
230
|
+
@@ -127,14 +196,14 @@ export function formatResponsesRequest(config, messages, options, stateful, mode
|
|
231
|
+
* whether the request should default `prompt_cache_options.mode` to explicit; without a checkpoint or
|
|
232
|
+
* a temporary suffix, implicit caching stays so the request still caches.
|
|
233
|
+
*/
|
|
234
|
+
-function formatCacheableResponsesMessages(messages, dynamicTrailingBlocks = 0, messagesTTL) {
|
|
235
|
+
+function formatCacheableResponsesMessages(messages, dynamicTrailingBlocks = 0, messagesTTL, replayModelId) {
|
|
236
|
+
const ttl = typeof messagesTTL === 'string' && CACHE_LIFETIMES.has(messagesTTL) ? { ttl: messagesTTL } : {};
|
|
237
|
+
const input = [];
|
|
238
|
+
let hasCheckpoints = false;
|
|
239
|
+
for (const [index, { role, content }] of messages.entries()) {
|
|
240
|
+
const dynamicCount = role === 'user' && index === messages.length - 1 ? dynamicTrailingBlocks : 0;
|
|
241
|
+
const boundary = Math.max(0, content.length - dynamicCount);
|
|
242
|
+
- const items = formatResponsesMessages([new Message({ role, content: content.slice(0, boundary) })]);
|
|
243
|
+
+ const items = formatResponsesMessages([new Message({ role, content: content.slice(0, boundary) })], replayModelId);
|
|
244
|
+
normalizeToolOutputs(items);
|
|
245
|
+
const part = role === 'user' ? lastCacheablePart(items) : undefined;
|
|
246
|
+
if (part) {
|
|
247
|
+
@@ -144,7 +213,7 @@ function formatCacheableResponsesMessages(messages, dynamicTrailingBlocks = 0, m
|
|
248
|
+
hasCheckpoints = true;
|
|
249
|
+
}
|
|
250
|
+
if (dynamicCount > 0) {
|
|
251
|
+
- const tail = formatResponsesMessages([new Message({ role: 'user', content: content.slice(boundary) })]);
|
|
252
|
+
+ const tail = formatResponsesMessages([new Message({ role: 'user', content: content.slice(boundary) })], replayModelId);
|
|
253
|
+
normalizeToolOutputs(tail);
|
|
254
|
+
appendDynamicContent(items, tail);
|
|
255
|
+
}
|
|
256
|
+
@@ -189,11 +258,15 @@ function appendDynamicContent(items, tail) {
|
|
232
257
|
* - Text/media → grouped in `{ role, content: [...] }`
|
|
233
258
|
* - Tool calls → separate `{ type: 'function_call', ... }` items
|
|
234
259
|
* - Tool results → separate `{ type: 'function_call_output', ... }` items
|
|
@@ -245,7 +270,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
245
270
|
const contentItems = [];
|
|
246
271
|
const toolCallItems = [];
|
|
247
272
|
const toolResultItems = [];
|
|
248
|
-
@@ -
|
|
273
|
+
@@ -249,6 +322,11 @@ function formatResponsesMessages(messages) {
|
|
249
274
|
break;
|
|
250
275
|
}
|
|
251
276
|
case 'reasoningBlock': {
|
|
@@ -257,7 +282,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
257
282
|
logger.warn('block_type=<reasoningBlock> | reasoning content is not yet supported in multi-turn conversations with the responses api');
|
|
258
283
|
break;
|
|
259
284
|
}
|
|
260
|
-
@@ -
|
|
285
|
+
@@ -259,6 +337,7 @@ function formatResponsesMessages(messages) {
|
|
261
286
|
}
|
|
262
287
|
}
|
|
263
288
|
}
|
|
@@ -265,7 +290,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
265
290
|
if (contentItems.length > 0) {
|
|
266
291
|
if (role === 'assistant') {
|
|
267
292
|
// Only the string EasyInputMessage form is a valid assistant *input* shape
|
|
268
|
-
@@ -
|
|
293
|
+
@@ -385,12 +464,16 @@ function formatDocumentInput(docBlock) {
|
|
269
294
|
*
|
|
270
295
|
* @internal
|
|
271
296
|
*/
|
|
@@ -283,7 +308,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
283
308
|
};
|
|
284
309
|
}
|
|
285
310
|
/**
|
|
286
|
-
@@ -
|
|
311
|
+
@@ -411,13 +494,13 @@ function mapResponsesUsage(usage) {
|
|
287
312
|
totalTokens: usage.total_tokens,
|
|
288
313
|
};
|
|
289
314
|
const cached = usage.input_tokens_details?.cached_tokens;
|
|
@@ -299,7 +324,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
299
324
|
mapped.cacheWriteInputTokens = cacheWrite;
|
|
300
325
|
}
|
|
301
326
|
return mapped;
|
|
302
|
-
@@ -
|
|
327
|
+
@@ -448,22 +531,66 @@ export function mapResponsesEventToSDK(event, state, stateful, modelState) {
|
|
303
328
|
case 'response.output_text.delta': {
|
|
304
329
|
events.push(...switchContent('text', state.dataType));
|
|
305
330
|
state.dataType = 'text';
|
|
@@ -366,7 +391,7 @@ index ddf156fe33b08dfb6a1dc265eb86f2fac31d9c53..c4cd19b5064de07722f88bb718745670
|
|
|
366
391
|
case 'response.output_text.annotation.added': {
|
|
367
392
|
// The SDK types `event.annotation` as `unknown` and doesn't export a
|
|
368
393
|
// named annotation union, so we narrow structurally on the fields we use.
|
|
369
|
-
@@ -
|
|
394
|
+
@@ -477,6 +604,7 @@ export function mapResponsesEventToSDK(event, state, stateful, modelState) {
|
|
370
395
|
// a fresh TextBlock.
|
|
371
396
|
events.push(...switchContent('citations', state.dataType));
|
|
372
397
|
state.dataType = 'citations';
|
|
@@ -1473,7 +1498,7 @@ index 1be553288395c19e1251d86ef7c4d798c1917ace..6eeccf95f2a8666b0c8daaefaeac6ce5
|
|
|
1473
1498
|
//# sourceMappingURL=types.d.ts.map
|
|
1474
1499
|
|
|
1475
1500
|
diff --git a/node_modules/@strands-agents/sdk/dist/src/vended-tools/file-editor/file-editor.js b/node_modules/@strands-agents/sdk/dist/src/vended-tools/file-editor/file-editor.js
|
|
1476
|
-
index
|
|
1501
|
+
index 3c1976c218d188347522fd33f4375ab08720431c..014e2daec186d05040f353b903011600fa920a1f 100644
|
|
1477
1502
|
--- a/node_modules/@strands-agents/sdk/dist/src/vended-tools/file-editor/file-editor.js
|
|
1478
1503
|
+++ b/node_modules/@strands-agents/sdk/dist/src/vended-tools/file-editor/file-editor.js
|
|
1479
1504
|
@@ -7,6 +7,11 @@ import * as path from 'path';
|
|
@@ -1508,7 +1533,7 @@ index c8f38b7acac37a781e1467a655e88834aa97b4ef..06cc4454899669805633df0ff0228b26
|
|
|
1508
1533
|
case 'insert':
|
|
1509
1534
|
return handleInsert(sandbox, filePath, input.insert_line, input.new_str);
|
|
1510
1535
|
default:
|
|
1511
|
-
@@ -
|
|
1536
|
+
@@ -113,35 +122,178 @@ function applyViewRange(fileContent, viewRange) {
|
|
1512
1537
|
if (start < 1 || start > nLines) {
|
|
1513
1538
|
throw new Error(`Invalid \`view_range\`: [${start}, ${end}]. Its first element \`${start}\` should be within the range of lines of the file: [1, ${nLines}]`);
|
|
1514
1539
|
}
|
|
@@ -1697,7 +1722,7 @@ index c8f38b7acac37a781e1467a655e88834aa97b4ef..06cc4454899669805633df0ff0228b26
|
|
|
1697
1722
|
const replacementLine = originalContent.substring(0, matchIndex).split('\n').length - 1;
|
|
1698
1723
|
const insertedLines = replacement.split('\n').length;
|
|
1699
1724
|
const originalLines = oldStr.split('\n').length;
|
|
1700
|
-
@@ -
|
|
1725
|
+
@@ -150,7 +302,7 @@ function buildStrReplaceResult(originalContent, oldStr, newStr, filePath) {
|
|
1701
1726
|
const startLine = Math.max(0, replacementLine - SNIPPET_LINES);
|
|
1702
1727
|
const endLine = Math.min(newLines.length, replacementLine + SNIPPET_LINES + lineDifference + 1);
|
|
1703
1728
|
const snippet = newLines.slice(startLine, endLine).join('\n');
|
|
@@ -1706,7 +1731,7 @@ index c8f38b7acac37a781e1467a655e88834aa97b4ef..06cc4454899669805633df0ff0228b26
|
|
|
1706
1731
|
}
|
|
1707
1732
|
/**
|
|
1708
1733
|
* Inserts text at a 0-indexed line in file content. Validates the insertion
|
|
1709
|
-
@@ -
|
|
1734
|
+
@@ -292,7 +444,7 @@ async function handleCreate(sandbox, filePath, fileText) {
|
|
1710
1735
|
await sandbox.writeText(filePath, fileText);
|
|
1711
1736
|
return `File created successfully at: ${filePath}`;
|
|
1712
1737
|
}
|
|
@@ -1715,7 +1740,7 @@ index c8f38b7acac37a781e1467a655e88834aa97b4ef..06cc4454899669805633df0ff0228b26
|
|
|
1715
1740
|
if (oldStr === undefined) {
|
|
1716
1741
|
throw new Error('Parameter `old_str` is required for command: str_replace');
|
|
1717
1742
|
}
|
|
1718
|
-
@@ -
|
|
1743
|
+
@@ -306,8 +458,12 @@ async function handleStrReplace(sandbox, filePath, oldStr, newStr) {
|
|
1719
1744
|
}
|
|
1720
1745
|
const fileContent = await sandbox.readText(filePath);
|
|
1721
1746
|
assertWithinSizeLimit(fileContent);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Human queue delivery through the SDK's post-tool-batch hook, never a second loop. */
|
|
2
|
+
import { type Agent } from '@strands-agents/sdk';
|
|
3
|
+
export interface SteeringPrompt {
|
|
4
|
+
readonly text: string;
|
|
5
|
+
}
|
|
6
|
+
/** Claim transfers ownership provisionally; only the SDK's append confirms delivery. */
|
|
7
|
+
export interface PromptSteeringSource {
|
|
8
|
+
pending(): readonly SteeringPrompt[];
|
|
9
|
+
claim(prompt: SteeringPrompt): boolean;
|
|
10
|
+
delivered(prompt: SteeringPrompt): void;
|
|
11
|
+
restore(prompts: readonly SteeringPrompt[]): void;
|
|
12
|
+
reject(prompt: SteeringPrompt, reason: string): void;
|
|
13
|
+
}
|
|
14
|
+
/** Bound each boundary's hook work; remaining entries stay visible in the driver's queue. */
|
|
15
|
+
export declare const MAX_STEERING_PER_BOUNDARY = 16;
|
|
16
|
+
/**
|
|
17
|
+
* AfterToolsEvent owns the complete user-role tool-result message before the SDK
|
|
18
|
+
* appends it. Append text after results, preserving every tool pair and letting
|
|
19
|
+
* the next ordinary model call see it. No private SDK API or history mutation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function installPromptSteering(agent: Agent, source: PromptSteeringSource, prepare: (text: string) => Promise<string>, accepted: (text: string) => Promise<void>): () => void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Human queue delivery through the SDK's post-tool-batch hook, never a second loop. */
|
|
2
|
+
import { AfterToolsEvent, MessageAddedEvent, HookOrder, TextBlock } from '@strands-agents/sdk';
|
|
3
|
+
/** Bound each boundary's hook work; remaining entries stay visible in the driver's queue. */
|
|
4
|
+
export const MAX_STEERING_PER_BOUNDARY = 16;
|
|
5
|
+
/**
|
|
6
|
+
* AfterToolsEvent owns the complete user-role tool-result message before the SDK
|
|
7
|
+
* appends it. Append text after results, preserving every tool pair and letting
|
|
8
|
+
* the next ordinary model call see it. No private SDK API or history mutation.
|
|
9
|
+
*/
|
|
10
|
+
export function installPromptSteering(agent, source, prepare, accepted) {
|
|
11
|
+
let offered;
|
|
12
|
+
const removeOffer = agent.addHook(AfterToolsEvent, async (event) => {
|
|
13
|
+
if (event.agent.cancelSignal.aborted || event.endTurn !== false ||
|
|
14
|
+
!event.message.content.some(block => block.type === 'toolResultBlock'))
|
|
15
|
+
return;
|
|
16
|
+
// AfterToolsEvent also fires from failed-batch cleanup. Nothing is recorded or
|
|
17
|
+
// echoed until this exact message is actually appended by the SDK below.
|
|
18
|
+
const batch = { message: event.message, prompts: [] };
|
|
19
|
+
offered = batch;
|
|
20
|
+
for (const prompt of source.pending().slice(0, MAX_STEERING_PER_BOUNDARY)) {
|
|
21
|
+
// A prior preparation await may have let the user take back later entries.
|
|
22
|
+
if (event.agent.cancelSignal.aborted || event.endTurn !== false || source.pending()[0] !== prompt)
|
|
23
|
+
break;
|
|
24
|
+
let text;
|
|
25
|
+
try {
|
|
26
|
+
text = await prepare(prompt.text);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
source.reject(prompt, error instanceof Error ? error.message : String(error));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (event.agent.cancelSignal.aborted || !source.claim(prompt))
|
|
33
|
+
break;
|
|
34
|
+
batch.prompts.push(prompt);
|
|
35
|
+
event.message.content.push(new TextBlock(text));
|
|
36
|
+
}
|
|
37
|
+
}, { order: HookOrder.SDK_LAST });
|
|
38
|
+
const removeDelivery = agent.addHook(MessageAddedEvent, async (event) => {
|
|
39
|
+
if (offered?.message !== event.message)
|
|
40
|
+
return;
|
|
41
|
+
const { prompts } = offered;
|
|
42
|
+
offered = undefined;
|
|
43
|
+
// All these texts are now in history, even if cancellation arrives during the
|
|
44
|
+
// bounded recording barrier. None may be returned as unsent after this point.
|
|
45
|
+
for (const prompt of prompts) {
|
|
46
|
+
source.delivered(prompt);
|
|
47
|
+
await accepted(prompt.text);
|
|
48
|
+
}
|
|
49
|
+
}, { order: HookOrder.SDK_FIRST });
|
|
50
|
+
return () => {
|
|
51
|
+
removeOffer();
|
|
52
|
+
removeDelivery();
|
|
53
|
+
if (offered !== undefined && offered.prompts.length > 0)
|
|
54
|
+
source.restore(offered.prompts);
|
|
55
|
+
offered = undefined;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=prompt-steering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-steering.js","sourceRoot":"","sources":["../../../src/agent/prompt-steering.ts"],"names":[],"mappings":"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"}
|
|
@@ -18,6 +18,7 @@ import { type MemoryCommandResult } from '../memory/command.js';
|
|
|
18
18
|
import { MemoryToolController } from '../memory/controller.js';
|
|
19
19
|
import { CloudMemory } from '../agentcore/controller.js';
|
|
20
20
|
import type { MemoryStatus } from '../memory/store.js';
|
|
21
|
+
import { type PromptSteeringSource } from './prompt-steering.js';
|
|
21
22
|
import type { ContextCompactedEntry, TaskNotificationFields } from '../trajectory/record.js';
|
|
22
23
|
import { type RecorderOptions, type TrajectoryStatus } from '../trajectory/writer.js';
|
|
23
24
|
import { type ContextBreakdown } from './context-breakdown.js';
|
|
@@ -539,7 +540,7 @@ export declare class AgentRuntime {
|
|
|
539
540
|
* no user quote to anchor to. Everything else — hooks, gate, recording, delivery
|
|
540
541
|
* ledger — is the ordinary turn.
|
|
541
542
|
*/
|
|
542
|
-
send(input: string, userInput?: string, image?: ImageBlock, origin?: TaskNotificationFields | PeerInput): AsyncIterable<AgentStreamEvent>;
|
|
543
|
+
send(input: string, userInput?: string, image?: ImageBlock, origin?: TaskNotificationFields | PeerInput, steering?: PromptSteeringSource): AsyncIterable<AgentStreamEvent>;
|
|
543
544
|
/**
|
|
544
545
|
* Adds one completed turn's delta to its model's share. Runs in `send`'s `finally`,
|
|
545
546
|
* so it cannot throw: a tally that failed would replace the provider's error with
|
|
@@ -53,6 +53,7 @@ import { createMemoryTools } from '../memory/tools.js';
|
|
|
53
53
|
import { CloudMemory } from '../agentcore/controller.js';
|
|
54
54
|
import { createCloudMemoryTools } from '../agentcore/tools.js';
|
|
55
55
|
import { recordStream } from '../trajectory/stream.js';
|
|
56
|
+
import { installPromptSteering } from './prompt-steering.js';
|
|
56
57
|
import { TrajectoryRecorder, } from '../trajectory/writer.js';
|
|
57
58
|
import { DARWIN_VERSION } from '../version.js';
|
|
58
59
|
import { TerminalDeliveryLedger } from './task-terminal-delivery.js';
|
|
@@ -956,7 +957,7 @@ export class AgentRuntime {
|
|
|
956
957
|
* no user quote to anchor to. Everything else — hooks, gate, recording, delivery
|
|
957
958
|
* ledger — is the ordinary turn.
|
|
958
959
|
*/
|
|
959
|
-
async *send(input, userInput = input, image, origin) {
|
|
960
|
+
async *send(input, userInput = input, image, origin, steering) {
|
|
960
961
|
this.suggestionAbort?.abort();
|
|
961
962
|
this.recapAbort?.abort();
|
|
962
963
|
const peer = origin !== undefined && 'kind' in origin ? origin : undefined;
|
|
@@ -993,6 +994,7 @@ export class AgentRuntime {
|
|
|
993
994
|
let naturallyCompleted = false;
|
|
994
995
|
let uploadTurn;
|
|
995
996
|
let streamStarted = false;
|
|
997
|
+
let removeSteering;
|
|
996
998
|
this.activeTurnBefore = before;
|
|
997
999
|
try {
|
|
998
1000
|
// A multimodal turn's durable text is the literal submitted prompt. Expanded
|
|
@@ -1030,6 +1032,20 @@ export class AgentRuntime {
|
|
|
1030
1032
|
this.checkCloudPreparation(cloudGeneration);
|
|
1031
1033
|
if (peer)
|
|
1032
1034
|
this.collaboration.validateDelivery(peer);
|
|
1035
|
+
if (steering !== undefined) {
|
|
1036
|
+
removeSteering = installPromptSteering(this.agent, steering, async (text) => {
|
|
1037
|
+
const submitted = await this.codexHooks?.userPromptSubmit(text);
|
|
1038
|
+
if (submitted !== undefined && !submitted.allowed) {
|
|
1039
|
+
throw new Error(submitted.reason ?? 'UserPromptSubmit hook blocked this correction.');
|
|
1040
|
+
}
|
|
1041
|
+
return injectCodexContext(text, submitted?.context);
|
|
1042
|
+
}, async (text) => {
|
|
1043
|
+
recording?.steeringInput(text);
|
|
1044
|
+
await recording?.inputDurable();
|
|
1045
|
+
if (recording !== undefined && this.trajectory?.status.active === false)
|
|
1046
|
+
this.memoryController?.discard();
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1033
1049
|
streamStarted = true;
|
|
1034
1050
|
const stream = this.backgroundDelegation.observe(this.agent.stream(invocation));
|
|
1035
1051
|
for await (const event of recordStream(stream, recording)) {
|
|
@@ -1066,6 +1082,7 @@ export class AgentRuntime {
|
|
|
1066
1082
|
naturallyCompleted = true;
|
|
1067
1083
|
}
|
|
1068
1084
|
finally {
|
|
1085
|
+
removeSteering?.();
|
|
1069
1086
|
if (uploadTurn !== undefined)
|
|
1070
1087
|
this.cloudMemory?.sealTurn(uploadTurn, naturallyCompleted && completed && cloudGeneration === this.cloudMemory.cancelGeneration);
|
|
1071
1088
|
// Seeing an endTurn event is not enough when the consumer abandons this
|