veryfront 0.1.136 → 0.1.137
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/esm/deno.js +1 -1
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +7 -1
- package/esm/src/agent/runtime/repair-tool-call.d.ts +3 -0
- package/esm/src/agent/runtime/repair-tool-call.d.ts.map +1 -0
- package/esm/src/agent/runtime/repair-tool-call.js +37 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/runtime/index.ts +7 -1
- package/src/src/agent/runtime/repair-tool-call.ts +54 -0
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EAEZ,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EAEZ,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAiB/D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAA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CAAC;IA2CzB;;;OAGG;IACG,MAAM,CACV,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,CAAC,EAAE;QACV,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;QAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;KAC9C,EACD,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAsHtC;;OAEG;YACW,gBAAgB;IA2O9B;;;;OAIG;YACW,yBAAyB;IAkPvC;;OAEG;YACW,eAAe;IAqC7B;;OAEG;YACW,mBAAmB;IAOjC;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC;IAI5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAIF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
|
@@ -20,6 +20,7 @@ import { addSpanEvent, setSpanAttributes, withSpan, } from "../../observability/
|
|
|
20
20
|
import { convertToModelMessages } from "./model-message-converter.js";
|
|
21
21
|
import { convertToolsToAISDK } from "./model-tool-converter.js";
|
|
22
22
|
import { createStreamState, processStream } from "./ai-stream-handler.js";
|
|
23
|
+
import { repairToolCall } from "./repair-tool-call.js";
|
|
23
24
|
import { MiddlewareChain } from "../middleware/chain.js";
|
|
24
25
|
import { generateText, streamText } from "ai";
|
|
25
26
|
import { AGENT_DEFAULTS } from "../ai-defaults.js";
|
|
@@ -313,7 +314,11 @@ export class AgentRuntime {
|
|
|
313
314
|
model: languageModel,
|
|
314
315
|
system: systemPrompt,
|
|
315
316
|
messages: convertToModelMessages(currentMessages),
|
|
316
|
-
tools: convertToolsToAISDK(tools
|
|
317
|
+
tools: convertToolsToAISDK(tools, {
|
|
318
|
+
model: effectiveModel,
|
|
319
|
+
allowedToolNames: allowedRemoteToolNames,
|
|
320
|
+
}),
|
|
321
|
+
experimental_repairToolCall: repairToolCall,
|
|
317
322
|
maxOutputTokens: this.resolveMaxOutputTokens(maxOutputTokensOverride),
|
|
318
323
|
temperature: DEFAULT_TEMPERATURE,
|
|
319
324
|
});
|
|
@@ -506,6 +511,7 @@ export class AgentRuntime {
|
|
|
506
511
|
model: effectiveModel,
|
|
507
512
|
allowedToolNames: allowedRemoteToolNames,
|
|
508
513
|
}),
|
|
514
|
+
experimental_repairToolCall: repairToolCall,
|
|
509
515
|
maxOutputTokens: this.resolveMaxOutputTokens(maxOutputTokensOverride),
|
|
510
516
|
temperature: DEFAULT_TEMPERATURE,
|
|
511
517
|
abortSignal,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-tool-call.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/repair-tool-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AAIZ,eAAO,MAAM,cAAc,EAAE,sBAAsB,CAAC,OAAO,CA4C1D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InvalidToolInputError, NoSuchToolError, } from "ai";
|
|
2
|
+
const REPAIRABLE_PROVIDER_TOOL_NAMES = new Set(["web_search"]);
|
|
3
|
+
export const repairToolCall = async ({ toolCall, error, }) => {
|
|
4
|
+
if (NoSuchToolError.isInstance(error)) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
if (!REPAIRABLE_PROVIDER_TOOL_NAMES.has(toolCall.toolName)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (toolCall.providerExecuted !== true) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (!InvalidToolInputError.isInstance(error) || typeof toolCall.input !== "string") {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const trimmedInput = toolCall.input.trim();
|
|
17
|
+
if (trimmedInput.length === 0) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
let normalizedQuery = trimmedInput;
|
|
21
|
+
try {
|
|
22
|
+
const parsedInput = JSON.parse(trimmedInput);
|
|
23
|
+
if (typeof parsedInput === "string") {
|
|
24
|
+
normalizedQuery = parsedInput.trim();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Raw string input is also repairable for provider-native web_search.
|
|
29
|
+
}
|
|
30
|
+
if (normalizedQuery.length === 0) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...toolCall,
|
|
35
|
+
input: JSON.stringify({ query: normalizedQuery }),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.137";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import { convertToModelMessages } from "./model-message-converter.js";
|
|
35
35
|
import { convertToolsToAISDK } from "./model-tool-converter.js";
|
|
36
36
|
import { createStreamState, processStream } from "./ai-stream-handler.js";
|
|
37
|
+
import { repairToolCall } from "./repair-tool-call.js";
|
|
37
38
|
import { MiddlewareChain } from "../middleware/chain.js";
|
|
38
39
|
import { generateText, type LanguageModel, streamText } from "ai";
|
|
39
40
|
import { AGENT_DEFAULTS } from "../ai-defaults.js";
|
|
@@ -459,7 +460,11 @@ export class AgentRuntime {
|
|
|
459
460
|
model: languageModel,
|
|
460
461
|
system: systemPrompt,
|
|
461
462
|
messages: convertToModelMessages(currentMessages),
|
|
462
|
-
tools: convertToolsToAISDK(tools
|
|
463
|
+
tools: convertToolsToAISDK(tools, {
|
|
464
|
+
model: effectiveModel,
|
|
465
|
+
allowedToolNames: allowedRemoteToolNames,
|
|
466
|
+
}),
|
|
467
|
+
experimental_repairToolCall: repairToolCall,
|
|
463
468
|
maxOutputTokens: this.resolveMaxOutputTokens(maxOutputTokensOverride),
|
|
464
469
|
temperature: DEFAULT_TEMPERATURE,
|
|
465
470
|
});
|
|
@@ -705,6 +710,7 @@ export class AgentRuntime {
|
|
|
705
710
|
model: effectiveModel,
|
|
706
711
|
allowedToolNames: allowedRemoteToolNames,
|
|
707
712
|
}),
|
|
713
|
+
experimental_repairToolCall: repairToolCall,
|
|
708
714
|
maxOutputTokens: this.resolveMaxOutputTokens(maxOutputTokensOverride),
|
|
709
715
|
temperature: DEFAULT_TEMPERATURE,
|
|
710
716
|
abortSignal,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InvalidToolInputError,
|
|
3
|
+
NoSuchToolError,
|
|
4
|
+
type ToolCallRepairFunction,
|
|
5
|
+
type ToolSet,
|
|
6
|
+
} from "ai";
|
|
7
|
+
|
|
8
|
+
const REPAIRABLE_PROVIDER_TOOL_NAMES = new Set(["web_search"]);
|
|
9
|
+
|
|
10
|
+
export const repairToolCall: ToolCallRepairFunction<ToolSet> = async ({
|
|
11
|
+
toolCall,
|
|
12
|
+
error,
|
|
13
|
+
}) => {
|
|
14
|
+
if (NoSuchToolError.isInstance(error)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!REPAIRABLE_PROVIDER_TOOL_NAMES.has(toolCall.toolName)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (toolCall.providerExecuted !== true) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!InvalidToolInputError.isInstance(error) || typeof toolCall.input !== "string") {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const trimmedInput = toolCall.input.trim();
|
|
31
|
+
if (trimmedInput.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let normalizedQuery = trimmedInput;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const parsedInput = JSON.parse(trimmedInput) as unknown;
|
|
39
|
+
if (typeof parsedInput === "string") {
|
|
40
|
+
normalizedQuery = parsedInput.trim();
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
// Raw string input is also repairable for provider-native web_search.
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (normalizedQuery.length === 0) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
...toolCall,
|
|
52
|
+
input: JSON.stringify({ query: normalizedQuery }),
|
|
53
|
+
};
|
|
54
|
+
};
|