@kenkaiiii/gg-agent 5.29.0 → 5.30.0
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/dist/index.cjs +26 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -20,6 +20,13 @@ interface AgentTool<T extends z.ZodType = z.ZodType> extends Tool {
|
|
|
20
20
|
* batch runs in source order so stateful mutations cannot race each other.
|
|
21
21
|
*/
|
|
22
22
|
executionMode?: ToolExecutionMode;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides the loop's default per-tool timeout. A tool that owns a longer
|
|
25
|
+
* internal budget than the default must declare it here, or the loop cancels
|
|
26
|
+
* it first and the tool's own timeout — with its specific, actionable error
|
|
27
|
+
* message — becomes unreachable.
|
|
28
|
+
*/
|
|
29
|
+
timeoutMs?: number;
|
|
23
30
|
execute: (args: z.infer<T>, context: ToolContext) => ToolExecuteResult | Promise<ToolExecuteResult>;
|
|
24
31
|
}
|
|
25
32
|
interface AgentTextDeltaEvent {
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ interface AgentTool<T extends z.ZodType = z.ZodType> extends Tool {
|
|
|
20
20
|
* batch runs in source order so stateful mutations cannot race each other.
|
|
21
21
|
*/
|
|
22
22
|
executionMode?: ToolExecutionMode;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides the loop's default per-tool timeout. A tool that owns a longer
|
|
25
|
+
* internal budget than the default must declare it here, or the loop cancels
|
|
26
|
+
* it first and the tool's own timeout — with its specific, actionable error
|
|
27
|
+
* message — becomes unreachable.
|
|
28
|
+
*/
|
|
29
|
+
timeoutMs?: number;
|
|
23
30
|
execute: (args: z.infer<T>, context: ToolContext) => ToolExecuteResult | Promise<ToolExecuteResult>;
|
|
24
31
|
}
|
|
25
32
|
interface AgentTextDeltaEvent {
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ function isLocalBackendUrl(baseUrl) {
|
|
|
35
35
|
|
|
36
36
|
// src/agent-loop.ts
|
|
37
37
|
var DEFAULT_MAX_TURNS = 300;
|
|
38
|
+
var DEFAULT_TOOL_TIMEOUT_MS = 3e5;
|
|
38
39
|
var _diagFn = null;
|
|
39
40
|
function setStreamDiagnostic(fn) {
|
|
40
41
|
_diagFn = fn;
|
|
@@ -704,7 +705,15 @@ async function* agentLoop(messages, options) {
|
|
|
704
705
|
role: "assistant",
|
|
705
706
|
content: [{ type: "text", text: attemptText }]
|
|
706
707
|
});
|
|
707
|
-
messages.push({
|
|
708
|
+
messages.push({
|
|
709
|
+
role: "user",
|
|
710
|
+
content: PARTIAL_CONTINUATION_PROMPT,
|
|
711
|
+
provenance: {
|
|
712
|
+
source: "runtime",
|
|
713
|
+
kind: "continuation",
|
|
714
|
+
visibility: "hidden"
|
|
715
|
+
}
|
|
716
|
+
});
|
|
708
717
|
preservedChars = attemptText.length;
|
|
709
718
|
}
|
|
710
719
|
diag("retry", {
|
|
@@ -874,7 +883,15 @@ async function* agentLoop(messages, options) {
|
|
|
874
883
|
model: options.model
|
|
875
884
|
});
|
|
876
885
|
yield { type: "truncated", reason: "max_tokens", continued: true };
|
|
877
|
-
messages.push({
|
|
886
|
+
messages.push({
|
|
887
|
+
role: "user",
|
|
888
|
+
content: MAX_TOKENS_CONTINUATION_PROMPT,
|
|
889
|
+
provenance: {
|
|
890
|
+
source: "runtime",
|
|
891
|
+
kind: "continuation",
|
|
892
|
+
visibility: "hidden"
|
|
893
|
+
}
|
|
894
|
+
});
|
|
878
895
|
continue;
|
|
879
896
|
}
|
|
880
897
|
yield { type: "truncated", reason: "max_tokens", continued: false };
|
|
@@ -1015,7 +1032,12 @@ async function* agentLoop(messages, options) {
|
|
|
1015
1032
|
};
|
|
1016
1033
|
messages.push({
|
|
1017
1034
|
role: "user",
|
|
1018
|
-
content: turnBudgetContinuationPrompt()
|
|
1035
|
+
content: turnBudgetContinuationPrompt(),
|
|
1036
|
+
provenance: {
|
|
1037
|
+
source: "runtime",
|
|
1038
|
+
kind: "continuation",
|
|
1039
|
+
visibility: "hidden"
|
|
1040
|
+
}
|
|
1019
1041
|
});
|
|
1020
1042
|
}
|
|
1021
1043
|
}
|
|
@@ -1081,7 +1103,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1081
1103
|
try {
|
|
1082
1104
|
const parsed = tool.parameters.parse(toolCall.args);
|
|
1083
1105
|
const callerSignal = options.signal;
|
|
1084
|
-
const toolTimeout = AbortSignal.timeout(
|
|
1106
|
+
const toolTimeout = AbortSignal.timeout(tool.timeoutMs ?? DEFAULT_TOOL_TIMEOUT_MS);
|
|
1085
1107
|
const ctx = {
|
|
1086
1108
|
signal: callerSignal ? AbortSignal.any([callerSignal, toolTimeout]) : toolTimeout,
|
|
1087
1109
|
toolCallId: toolCall.id,
|