ai 5.1.0-beta.27 → 5.1.0-beta.28
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 +9 -0
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.1.0-beta.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 521c537: feat(ai): Tool.needsApproval can be a function
|
|
8
|
+
- Updated dependencies [521c537]
|
|
9
|
+
- @ai-sdk/provider-utils@3.1.0-beta.9
|
|
10
|
+
- @ai-sdk/gateway@1.1.0-beta.19
|
|
11
|
+
|
|
3
12
|
## 5.1.0-beta.27
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -809,7 +809,7 @@ function detectMediaType({
|
|
|
809
809
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
810
810
|
|
|
811
811
|
// src/version.ts
|
|
812
|
-
var VERSION = true ? "5.1.0-beta.
|
|
812
|
+
var VERSION = true ? "5.1.0-beta.28" : "0.0.0-test";
|
|
813
813
|
|
|
814
814
|
// src/util/download/download.ts
|
|
815
815
|
var download = async ({ url }) => {
|
|
@@ -2155,6 +2155,26 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
|
|
|
2155
2155
|
}
|
|
2156
2156
|
};
|
|
2157
2157
|
|
|
2158
|
+
// src/generate-text/is-approval-needed.ts
|
|
2159
|
+
async function isApprovalNeeded({
|
|
2160
|
+
tool: tool3,
|
|
2161
|
+
toolCall,
|
|
2162
|
+
messages,
|
|
2163
|
+
experimental_context
|
|
2164
|
+
}) {
|
|
2165
|
+
if (tool3.needsApproval == null) {
|
|
2166
|
+
return false;
|
|
2167
|
+
}
|
|
2168
|
+
if (typeof tool3.needsApproval === "boolean") {
|
|
2169
|
+
return tool3.needsApproval;
|
|
2170
|
+
}
|
|
2171
|
+
return await tool3.needsApproval(toolCall.input, {
|
|
2172
|
+
toolCallId: toolCall.toolCallId,
|
|
2173
|
+
messages,
|
|
2174
|
+
experimental_context
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2158
2178
|
// src/generate-text/parse-tool-call.ts
|
|
2159
2179
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
2160
2180
|
async function parseToolCall({
|
|
@@ -2703,7 +2723,12 @@ async function generateText({
|
|
|
2703
2723
|
experimental_context
|
|
2704
2724
|
});
|
|
2705
2725
|
}
|
|
2706
|
-
if (
|
|
2726
|
+
if (await isApprovalNeeded({
|
|
2727
|
+
tool: tool3,
|
|
2728
|
+
toolCall,
|
|
2729
|
+
messages: stepInputMessages,
|
|
2730
|
+
experimental_context
|
|
2731
|
+
})) {
|
|
2707
2732
|
toolApprovalRequests[toolCall.toolCallId] = {
|
|
2708
2733
|
type: "tool-approval-request",
|
|
2709
2734
|
approvalId: generateId2(),
|
|
@@ -4591,7 +4616,12 @@ function runToolsTransformation({
|
|
|
4591
4616
|
experimental_context
|
|
4592
4617
|
});
|
|
4593
4618
|
}
|
|
4594
|
-
if (
|
|
4619
|
+
if (await isApprovalNeeded({
|
|
4620
|
+
tool: tool3,
|
|
4621
|
+
toolCall,
|
|
4622
|
+
messages,
|
|
4623
|
+
experimental_context
|
|
4624
|
+
})) {
|
|
4595
4625
|
toolResultsStreamController.enqueue({
|
|
4596
4626
|
type: "tool-approval-request",
|
|
4597
4627
|
approvalId: generateId2(),
|