ai 7.0.85 → 7.0.86
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 +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/index.d.ts +17 -1
- package/dist/internal/index.js +99 -84
- package/dist/internal/index.js.map +1 -1
- package/docs/03-agents/06-tool-approvals.mdx +6 -3
- package/docs/03-agents/07-workflow-agent.mdx +43 -0
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +4 -0
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +25 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1146,7 +1146,7 @@ import {
|
|
|
1146
1146
|
} from "@ai-sdk/provider-utils";
|
|
1147
1147
|
|
|
1148
1148
|
// src/version.ts
|
|
1149
|
-
var VERSION = true ? "7.0.
|
|
1149
|
+
var VERSION = true ? "7.0.86" : "0.0.0-test";
|
|
1150
1150
|
|
|
1151
1151
|
// src/util/download/download.ts
|
|
1152
1152
|
var download = async ({
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -2692,6 +2692,22 @@ declare function collectToolApprovals<TOOLS extends ToolSet>({ messages, }: {
|
|
|
2692
2692
|
deniedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
|
|
2693
2693
|
};
|
|
2694
2694
|
|
|
2695
|
+
declare function signToolApproval({ secret, approvalId, toolCallId, toolName, input, }: {
|
|
2696
|
+
secret: string | Uint8Array;
|
|
2697
|
+
approvalId: string;
|
|
2698
|
+
toolCallId: string;
|
|
2699
|
+
toolName: string;
|
|
2700
|
+
input: unknown;
|
|
2701
|
+
}): Promise<string>;
|
|
2702
|
+
declare function verifyToolApprovalSignature({ secret, signature, approvalId, toolCallId, toolName, input, }: {
|
|
2703
|
+
secret: string | Uint8Array;
|
|
2704
|
+
signature: string;
|
|
2705
|
+
approvalId: string;
|
|
2706
|
+
toolCallId: string;
|
|
2707
|
+
toolName: string;
|
|
2708
|
+
input: unknown;
|
|
2709
|
+
}): Promise<boolean>;
|
|
2710
|
+
|
|
2695
2711
|
/**
|
|
2696
2712
|
* Re-validates approved tool approvals reconstructed from client-supplied
|
|
2697
2713
|
* message history before they are executed. Checks HMAC signature (when
|
|
@@ -2721,4 +2737,4 @@ declare function toResponseMessages<TOOLS extends ToolSet>({ content: inputConte
|
|
|
2721
2737
|
tools: TOOLS | undefined;
|
|
2722
2738
|
}): Promise<Array<AssistantModelMessage | ToolModelMessage>>;
|
|
2723
2739
|
|
|
2724
|
-
export { type CollectedToolApprovals, DefaultStepResult, type DownloadFunction, addLanguageModelUsage, asLanguageModelUsage, collectToolApprovals, convertToLanguageModelPrompt, createAsyncIterableStream, createDefaultDownloadFunction, createNullLanguageModelUsage, createRestrictedTelemetryDispatcher, createTelemetryDispatcher, createToolModelOutput, downloadAssets, mapToolResultOutput, mergeAbortSignals, mergeCallbacks, parseToolCall, prepareLanguageModelCallOptions as prepareCallSettings, prepareLanguageModelCallOptions, prepareRetries, prepareToolChoice, prepareTools, resolveLanguageModel, standardizePrompt, toResponseMessages, validateApprovedToolApprovals };
|
|
2740
|
+
export { type CollectedToolApprovals, DefaultStepResult, type DownloadFunction, addLanguageModelUsage, asLanguageModelUsage, collectToolApprovals, convertToLanguageModelPrompt, createAsyncIterableStream, createDefaultDownloadFunction, createNullLanguageModelUsage, createRestrictedTelemetryDispatcher, createTelemetryDispatcher, createToolModelOutput, downloadAssets, mapToolResultOutput, mergeAbortSignals, mergeCallbacks, parseToolCall, prepareLanguageModelCallOptions as prepareCallSettings, prepareLanguageModelCallOptions, prepareRetries, prepareToolChoice, prepareTools, resolveLanguageModel, signToolApproval, standardizePrompt, toResponseMessages, validateApprovedToolApprovals, verifyToolApprovalSignature };
|
package/dist/internal/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "@ai-sdk/provider-utils";
|
|
92
92
|
|
|
93
93
|
// src/version.ts
|
|
94
|
-
var VERSION = true ? "7.0.
|
|
94
|
+
var VERSION = true ? "7.0.86" : "0.0.0-test";
|
|
95
95
|
|
|
96
96
|
// src/util/download/download.ts
|
|
97
97
|
var download = async ({
|
|
@@ -3176,88 +3176,6 @@ function collectToolApprovals({
|
|
|
3176
3176
|
return { approvedToolApprovals, deniedToolApprovals };
|
|
3177
3177
|
}
|
|
3178
3178
|
|
|
3179
|
-
// src/generate-text/validate-tool-approvals.ts
|
|
3180
|
-
import {
|
|
3181
|
-
asSchema as asSchema3,
|
|
3182
|
-
isExecutableTool,
|
|
3183
|
-
safeValidateTypes as safeValidateTypes3
|
|
3184
|
-
} from "@ai-sdk/provider-utils";
|
|
3185
|
-
|
|
3186
|
-
// src/generate-text/validate-tool-context.ts
|
|
3187
|
-
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
3188
|
-
async function validateToolContext({
|
|
3189
|
-
toolName,
|
|
3190
|
-
context,
|
|
3191
|
-
contextSchema
|
|
3192
|
-
}) {
|
|
3193
|
-
if (contextSchema == null) {
|
|
3194
|
-
return context;
|
|
3195
|
-
}
|
|
3196
|
-
return await validateTypes({
|
|
3197
|
-
value: context,
|
|
3198
|
-
schema: contextSchema,
|
|
3199
|
-
context: {
|
|
3200
|
-
field: "tool context",
|
|
3201
|
-
entityName: toolName
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
}
|
|
3205
|
-
|
|
3206
|
-
// src/generate-text/resolve-tool-approval.ts
|
|
3207
|
-
async function resolveToolApproval({
|
|
3208
|
-
tools,
|
|
3209
|
-
toolCall,
|
|
3210
|
-
toolApproval,
|
|
3211
|
-
messages,
|
|
3212
|
-
toolsContext,
|
|
3213
|
-
runtimeContext
|
|
3214
|
-
}) {
|
|
3215
|
-
if (toolApproval != null && typeof toolApproval === "function") {
|
|
3216
|
-
return normalizeToolApprovalStatus(
|
|
3217
|
-
await toolApproval({
|
|
3218
|
-
toolCall,
|
|
3219
|
-
tools,
|
|
3220
|
-
toolsContext,
|
|
3221
|
-
messages,
|
|
3222
|
-
runtimeContext
|
|
3223
|
-
})
|
|
3224
|
-
);
|
|
3225
|
-
}
|
|
3226
|
-
const toolName = toolCall.toolName;
|
|
3227
|
-
const tool = getOwn(tools, toolName);
|
|
3228
|
-
const input = toolCall.input;
|
|
3229
|
-
const userDefinedToolApprovalStatus = getOwn(toolApproval, toolName);
|
|
3230
|
-
if (userDefinedToolApprovalStatus != null) {
|
|
3231
|
-
const approvalStatus = typeof userDefinedToolApprovalStatus === "function" ? await userDefinedToolApprovalStatus(input, {
|
|
3232
|
-
toolCallId: toolCall.toolCallId,
|
|
3233
|
-
messages,
|
|
3234
|
-
toolContext: await validateToolContext({
|
|
3235
|
-
toolName,
|
|
3236
|
-
context: getOwn(toolsContext, toolName),
|
|
3237
|
-
contextSchema: tool == null ? void 0 : tool.contextSchema
|
|
3238
|
-
}),
|
|
3239
|
-
runtimeContext
|
|
3240
|
-
}) : userDefinedToolApprovalStatus;
|
|
3241
|
-
return normalizeToolApprovalStatus(approvalStatus);
|
|
3242
|
-
}
|
|
3243
|
-
if ((tool == null ? void 0 : tool.needsApproval) == null) {
|
|
3244
|
-
return { type: "not-applicable" };
|
|
3245
|
-
}
|
|
3246
|
-
const needsApproval = typeof tool.needsApproval === "function" ? await tool.needsApproval(input, {
|
|
3247
|
-
toolCallId: toolCall.toolCallId,
|
|
3248
|
-
messages,
|
|
3249
|
-
context: await validateToolContext({
|
|
3250
|
-
toolName,
|
|
3251
|
-
context: getOwn(toolsContext, toolName),
|
|
3252
|
-
contextSchema: tool == null ? void 0 : tool.contextSchema
|
|
3253
|
-
})
|
|
3254
|
-
}) : tool.needsApproval;
|
|
3255
|
-
return needsApproval ? { type: "user-approval" } : { type: "not-applicable" };
|
|
3256
|
-
}
|
|
3257
|
-
function normalizeToolApprovalStatus(status) {
|
|
3258
|
-
return status === void 0 ? { type: "not-applicable" } : typeof status === "string" ? { type: status } : status;
|
|
3259
|
-
}
|
|
3260
|
-
|
|
3261
3179
|
// src/generate-text/tool-approval-signature.ts
|
|
3262
3180
|
import { convertBase64ToUint8Array } from "@ai-sdk/provider-utils";
|
|
3263
3181
|
|
|
@@ -3325,6 +3243,19 @@ ${toolName}
|
|
|
3325
3243
|
${inputDigest}`
|
|
3326
3244
|
);
|
|
3327
3245
|
}
|
|
3246
|
+
async function signToolApproval({
|
|
3247
|
+
secret,
|
|
3248
|
+
approvalId,
|
|
3249
|
+
toolCallId,
|
|
3250
|
+
toolName,
|
|
3251
|
+
input
|
|
3252
|
+
}) {
|
|
3253
|
+
const key = await importKey(secret);
|
|
3254
|
+
const inputDigest = await hashCanonical(input);
|
|
3255
|
+
const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
|
|
3256
|
+
const sig = await crypto.subtle.sign("HMAC", key, payload);
|
|
3257
|
+
return toBase64url(new Uint8Array(sig));
|
|
3258
|
+
}
|
|
3328
3259
|
async function verifyToolApprovalSignature({
|
|
3329
3260
|
secret,
|
|
3330
3261
|
signature,
|
|
@@ -3352,6 +3283,88 @@ async function verifyToolApprovalSignature({
|
|
|
3352
3283
|
return false;
|
|
3353
3284
|
}
|
|
3354
3285
|
|
|
3286
|
+
// src/generate-text/validate-tool-approvals.ts
|
|
3287
|
+
import {
|
|
3288
|
+
asSchema as asSchema3,
|
|
3289
|
+
isExecutableTool,
|
|
3290
|
+
safeValidateTypes as safeValidateTypes3
|
|
3291
|
+
} from "@ai-sdk/provider-utils";
|
|
3292
|
+
|
|
3293
|
+
// src/generate-text/validate-tool-context.ts
|
|
3294
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
3295
|
+
async function validateToolContext({
|
|
3296
|
+
toolName,
|
|
3297
|
+
context,
|
|
3298
|
+
contextSchema
|
|
3299
|
+
}) {
|
|
3300
|
+
if (contextSchema == null) {
|
|
3301
|
+
return context;
|
|
3302
|
+
}
|
|
3303
|
+
return await validateTypes({
|
|
3304
|
+
value: context,
|
|
3305
|
+
schema: contextSchema,
|
|
3306
|
+
context: {
|
|
3307
|
+
field: "tool context",
|
|
3308
|
+
entityName: toolName
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
// src/generate-text/resolve-tool-approval.ts
|
|
3314
|
+
async function resolveToolApproval({
|
|
3315
|
+
tools,
|
|
3316
|
+
toolCall,
|
|
3317
|
+
toolApproval,
|
|
3318
|
+
messages,
|
|
3319
|
+
toolsContext,
|
|
3320
|
+
runtimeContext
|
|
3321
|
+
}) {
|
|
3322
|
+
if (toolApproval != null && typeof toolApproval === "function") {
|
|
3323
|
+
return normalizeToolApprovalStatus(
|
|
3324
|
+
await toolApproval({
|
|
3325
|
+
toolCall,
|
|
3326
|
+
tools,
|
|
3327
|
+
toolsContext,
|
|
3328
|
+
messages,
|
|
3329
|
+
runtimeContext
|
|
3330
|
+
})
|
|
3331
|
+
);
|
|
3332
|
+
}
|
|
3333
|
+
const toolName = toolCall.toolName;
|
|
3334
|
+
const tool = getOwn(tools, toolName);
|
|
3335
|
+
const input = toolCall.input;
|
|
3336
|
+
const userDefinedToolApprovalStatus = getOwn(toolApproval, toolName);
|
|
3337
|
+
if (userDefinedToolApprovalStatus != null) {
|
|
3338
|
+
const approvalStatus = typeof userDefinedToolApprovalStatus === "function" ? await userDefinedToolApprovalStatus(input, {
|
|
3339
|
+
toolCallId: toolCall.toolCallId,
|
|
3340
|
+
messages,
|
|
3341
|
+
toolContext: await validateToolContext({
|
|
3342
|
+
toolName,
|
|
3343
|
+
context: getOwn(toolsContext, toolName),
|
|
3344
|
+
contextSchema: tool == null ? void 0 : tool.contextSchema
|
|
3345
|
+
}),
|
|
3346
|
+
runtimeContext
|
|
3347
|
+
}) : userDefinedToolApprovalStatus;
|
|
3348
|
+
return normalizeToolApprovalStatus(approvalStatus);
|
|
3349
|
+
}
|
|
3350
|
+
if ((tool == null ? void 0 : tool.needsApproval) == null) {
|
|
3351
|
+
return { type: "not-applicable" };
|
|
3352
|
+
}
|
|
3353
|
+
const needsApproval = typeof tool.needsApproval === "function" ? await tool.needsApproval(input, {
|
|
3354
|
+
toolCallId: toolCall.toolCallId,
|
|
3355
|
+
messages,
|
|
3356
|
+
context: await validateToolContext({
|
|
3357
|
+
toolName,
|
|
3358
|
+
context: getOwn(toolsContext, toolName),
|
|
3359
|
+
contextSchema: tool == null ? void 0 : tool.contextSchema
|
|
3360
|
+
})
|
|
3361
|
+
}) : tool.needsApproval;
|
|
3362
|
+
return needsApproval ? { type: "user-approval" } : { type: "not-applicable" };
|
|
3363
|
+
}
|
|
3364
|
+
function normalizeToolApprovalStatus(status) {
|
|
3365
|
+
return status === void 0 ? { type: "not-applicable" } : typeof status === "string" ? { type: status } : status;
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3355
3368
|
// src/generate-text/validate-tool-approvals.ts
|
|
3356
3369
|
async function validateApprovedToolApprovals({
|
|
3357
3370
|
approvedToolApprovals,
|
|
@@ -3661,8 +3674,10 @@ export {
|
|
|
3661
3674
|
prepareToolChoice,
|
|
3662
3675
|
prepareTools,
|
|
3663
3676
|
resolveLanguageModel,
|
|
3677
|
+
signToolApproval,
|
|
3664
3678
|
standardizePrompt,
|
|
3665
3679
|
toResponseMessages,
|
|
3666
|
-
validateApprovedToolApprovals
|
|
3680
|
+
validateApprovedToolApprovals,
|
|
3681
|
+
verifyToolApprovalSignature
|
|
3667
3682
|
};
|
|
3668
3683
|
//# sourceMappingURL=index.js.map
|