experimental-ash 0.10.3 → 0.10.4
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/CHANGELOG.md
CHANGED
|
@@ -226,30 +226,58 @@ function buildToolResponseParts(batch, responses) {
|
|
|
226
226
|
const responseMap = new Map(responses.map((r) => [r.requestId, r]));
|
|
227
227
|
const parts = [];
|
|
228
228
|
for (const request of batch.requests) {
|
|
229
|
-
parts.push(
|
|
229
|
+
parts.push(...buildToolResponsePartsForRequest(request, responseMap.get(request.requestId)));
|
|
230
230
|
}
|
|
231
231
|
return parts;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function buildToolResponsePartsForRequest(request, response) {
|
|
234
234
|
if (isApprovalRequest(request)) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
const approved = response?.optionId === "approve";
|
|
236
|
+
const reason = response === undefined ? IGNORED_INPUT_REASON : undefined;
|
|
237
|
+
const parts = [
|
|
238
|
+
{
|
|
239
|
+
approvalId: request.requestId,
|
|
240
|
+
approved,
|
|
241
|
+
reason,
|
|
242
|
+
type: "tool-approval-response",
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
/*
|
|
246
|
+
* On denial (explicit "deny" or auto-deny when the user continues
|
|
247
|
+
* without responding), splice in the matching `execution-denied`
|
|
248
|
+
* tool-result. AI SDK's `streamText` synthesizes this for the
|
|
249
|
+
* current turn's `initialResponseMessages`, but that synthesis is
|
|
250
|
+
* gated on the input messages' last entry being a tool message —
|
|
251
|
+
* on subsequent turns (when a new user message is the tail of
|
|
252
|
+
* history) the synthesis is skipped, and the persisted
|
|
253
|
+
* `tool-approval-response` is stripped during provider prompt
|
|
254
|
+
* conversion. Without an own `tool-result` in history, the prior
|
|
255
|
+
* `tool_use` block replays unmatched and some providers reject
|
|
256
|
+
* the request with 400.
|
|
257
|
+
*/
|
|
258
|
+
if (!approved) {
|
|
259
|
+
parts.push({
|
|
260
|
+
output: { type: "execution-denied", reason },
|
|
261
|
+
toolCallId: request.action.callId,
|
|
262
|
+
toolName: request.action.toolName,
|
|
263
|
+
type: "tool-result",
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return parts;
|
|
241
267
|
}
|
|
242
|
-
return
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
268
|
+
return [
|
|
269
|
+
{
|
|
270
|
+
output: {
|
|
271
|
+
type: "json",
|
|
272
|
+
value: response !== undefined
|
|
273
|
+
? { optionId: response.optionId, text: response.text, status: "answered" }
|
|
274
|
+
: { status: "ignored" },
|
|
275
|
+
},
|
|
276
|
+
toolCallId: request.action.callId,
|
|
277
|
+
toolName: request.action.toolName,
|
|
278
|
+
type: "tool-result",
|
|
248
279
|
},
|
|
249
|
-
|
|
250
|
-
toolName: request.action.toolName,
|
|
251
|
-
type: "tool-result",
|
|
252
|
-
};
|
|
280
|
+
];
|
|
253
281
|
}
|
|
254
282
|
function isApprovalRequest(request) {
|
|
255
283
|
return (request.options?.length === 2 &&
|
|
@@ -6,7 +6,7 @@ import { ASH_PACKAGE_NAME } from "#package-name.js";
|
|
|
6
6
|
let cachedPackageInfo;
|
|
7
7
|
// The package build stamps the published version into `dist` so bundled
|
|
8
8
|
// deployments can still report package metadata without resolving package.json.
|
|
9
|
-
const BUNDLED_FALLBACK_PACKAGE_VERSION = "0.10.
|
|
9
|
+
const BUNDLED_FALLBACK_PACKAGE_VERSION = "0.10.4";
|
|
10
10
|
const BUNDLED_FALLBACK_PACKAGE_VERSION_PLACEHOLDER = "__ASH_PACKAGE_VERSION_PLACEHOLDER__";
|
|
11
11
|
const WORKFLOW_MODULE_ALIASES = {
|
|
12
12
|
"workflow/api": "src/compiled/@workflow/core/runtime.js",
|