@kenkaiiii/gg-agent 5.73.0 → 5.74.1
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 +23 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -80,6 +80,11 @@ declare function buildStreamRuleReminder(rules: readonly StreamRule[]): Message;
|
|
|
80
80
|
interface StructuredToolResult {
|
|
81
81
|
content: ToolResultContent;
|
|
82
82
|
details?: unknown;
|
|
83
|
+
/** End the run after persisting this result, without another model call or
|
|
84
|
+
* draining steering/follow-ups. Use a sequential tool to also prevent later
|
|
85
|
+
* calls in the same batch from running (e.g. a pending plan-review handoff).
|
|
86
|
+
* Host control metadata only: never serialized into provider tool results. */
|
|
87
|
+
endRun?: boolean;
|
|
83
88
|
}
|
|
84
89
|
type ToolExecuteResult = string | StructuredToolResult;
|
|
85
90
|
interface ToolContext {
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,11 @@ declare function buildStreamRuleReminder(rules: readonly StreamRule[]): Message;
|
|
|
80
80
|
interface StructuredToolResult {
|
|
81
81
|
content: ToolResultContent;
|
|
82
82
|
details?: unknown;
|
|
83
|
+
/** End the run after persisting this result, without another model call or
|
|
84
|
+
* draining steering/follow-ups. Use a sequential tool to also prevent later
|
|
85
|
+
* calls in the same batch from running (e.g. a pending plan-review handoff).
|
|
86
|
+
* Host control metadata only: never serialized into provider tool results. */
|
|
87
|
+
endRun?: boolean;
|
|
83
88
|
}
|
|
84
89
|
type ToolExecuteResult = string | StructuredToolResult;
|
|
85
90
|
interface ToolContext {
|
package/dist/index.js
CHANGED
|
@@ -1523,6 +1523,7 @@ async function* agentLoop(messages, options) {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
messages.push({ role: "tool", content: executionResult.toolResults });
|
|
1525
1525
|
yield { type: "checkpoint", turn };
|
|
1526
|
+
if (executionResult.endRun) break;
|
|
1526
1527
|
const toolsAborted = executionResult.aborted;
|
|
1527
1528
|
if (fatalToolArgumentError) {
|
|
1528
1529
|
if (fatalToolArgumentRecoverable && !toolArgumentAutoContinueUsed) {
|
|
@@ -1659,6 +1660,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1659
1660
|
let resultContent;
|
|
1660
1661
|
let details;
|
|
1661
1662
|
let isError = false;
|
|
1663
|
+
let endRun = false;
|
|
1662
1664
|
let invalidArgAttempt;
|
|
1663
1665
|
const tool = options.toolMap.get(toolCall.name);
|
|
1664
1666
|
if (tool) {
|
|
@@ -1711,6 +1713,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1711
1713
|
};
|
|
1712
1714
|
const raw = await tool.execute(parsed, ctx);
|
|
1713
1715
|
const normalized = normalizeToolResult(raw);
|
|
1716
|
+
endRun = normalized.endRun === true;
|
|
1714
1717
|
resultContent = redactValue(normalized.content, toolRedactionOptions());
|
|
1715
1718
|
details = redactValue(normalized.details, toolRedactionOptions());
|
|
1716
1719
|
if (options.transformToolResult) {
|
|
@@ -1780,11 +1783,12 @@ ${hints}` : "") + "\nRe-issue the call with each field as the correct type.";
|
|
|
1780
1783
|
durationMs,
|
|
1781
1784
|
...invalidArgAttempt === void 0 ? {} : { invalidArgAttempt }
|
|
1782
1785
|
});
|
|
1783
|
-
return { toolCallId: toolCall.id, content: resultContent, isError };
|
|
1786
|
+
return { toolCallId: toolCall.id, content: resultContent, isError, endRun: endRun && !isError };
|
|
1784
1787
|
}
|
|
1785
1788
|
function createPreemptTracker(options, eventStream, state, resultsById, dispatchedIds) {
|
|
1786
1789
|
const running = /* @__PURE__ */ new Map();
|
|
1787
1790
|
let graceTimer;
|
|
1791
|
+
let endRun = false;
|
|
1788
1792
|
const preemptSignal = options.preemptSignal;
|
|
1789
1793
|
const abandon = () => {
|
|
1790
1794
|
graceTimer = void 0;
|
|
@@ -1808,7 +1812,7 @@ function createPreemptTracker(options, eventStream, state, resultsById, dispatch
|
|
|
1808
1812
|
preemptSignal?.addEventListener("abort", onPreempt, { once: true });
|
|
1809
1813
|
return {
|
|
1810
1814
|
async run(toolCall) {
|
|
1811
|
-
if (options.preemptSignal?.aborted) return;
|
|
1815
|
+
if (endRun || options.preemptSignal?.aborted) return;
|
|
1812
1816
|
dispatchedIds.add(toolCall.id);
|
|
1813
1817
|
const interruptible = isInterruptibleTool(options.toolMap.get(toolCall.name), toolCall.name);
|
|
1814
1818
|
running.set(toolCall.id, { toolCall, interruptible, startedAt: Date.now() });
|
|
@@ -1820,15 +1824,15 @@ function createPreemptTracker(options, eventStream, state, resultsById, dispatch
|
|
|
1820
1824
|
running.delete(toolCall.id);
|
|
1821
1825
|
if (resultsById.has(toolCall.id)) return;
|
|
1822
1826
|
const alreadyMarked = typeof record.content === "string" ? record.content.startsWith(STEER_INTERRUPTED_TEXT) : record.content[0]?.type === "text" && record.content[0].text.startsWith(STEER_INTERRUPTED_TEXT);
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
);
|
|
1827
|
+
const result = interruptible && preemptSignal?.aborted && !alreadyMarked ? markSteerInterrupted(record) : record;
|
|
1828
|
+
resultsById.set(toolCall.id, result);
|
|
1829
|
+
if (result.endRun && !result.isError) endRun = true;
|
|
1827
1830
|
if (preemptSignal?.aborted && graceTimer === void 0 && running.size === 0) {
|
|
1828
1831
|
eventStream.close();
|
|
1829
1832
|
}
|
|
1830
1833
|
},
|
|
1831
1834
|
preempted: () => preemptSignal?.aborted === true,
|
|
1835
|
+
endRun: () => endRun,
|
|
1832
1836
|
dispose: () => {
|
|
1833
1837
|
if (graceTimer !== void 0) clearTimeout(graceTimer);
|
|
1834
1838
|
preemptSignal?.removeEventListener("abort", onPreempt);
|
|
@@ -1863,7 +1867,7 @@ async function* executeToolCallsMixed(toolCalls, initialToolResults, options) {
|
|
|
1863
1867
|
void (async () => {
|
|
1864
1868
|
try {
|
|
1865
1869
|
for (const phase of phases) {
|
|
1866
|
-
if (options.signal?.aborted || options.preemptSignal?.aborted) break;
|
|
1870
|
+
if (options.signal?.aborted || options.preemptSignal?.aborted || tracker.endRun()) break;
|
|
1867
1871
|
if (phase.sequential) {
|
|
1868
1872
|
const signature = JSON.stringify([
|
|
1869
1873
|
phase.sequential.name,
|
|
@@ -1901,7 +1905,12 @@ async function* executeToolCallsMixed(toolCalls, initialToolResults, options) {
|
|
|
1901
1905
|
const toolResults = buildToolResults(initialToolResults, toolCalls, resultsById, dispatchedIds);
|
|
1902
1906
|
capToolResults(toolResults, options.maxToolResultChars);
|
|
1903
1907
|
capTurnToolResults(toolResults, options.maxTurnToolResultChars);
|
|
1904
|
-
return {
|
|
1908
|
+
return {
|
|
1909
|
+
toolResults,
|
|
1910
|
+
aborted,
|
|
1911
|
+
preempted: !aborted && tracker.preempted(),
|
|
1912
|
+
endRun: tracker.endRun()
|
|
1913
|
+
};
|
|
1905
1914
|
}
|
|
1906
1915
|
async function* executeToolCallsParallel(toolCalls, initialToolResults, options) {
|
|
1907
1916
|
const eventStream = new EventStream();
|
|
@@ -1935,7 +1944,12 @@ async function* executeToolCallsParallel(toolCalls, initialToolResults, options)
|
|
|
1935
1944
|
const toolResults = buildToolResults(initialToolResults, toolCalls, resultsById, dispatchedIds);
|
|
1936
1945
|
capToolResults(toolResults, options.maxToolResultChars);
|
|
1937
1946
|
capTurnToolResults(toolResults, options.maxTurnToolResultChars);
|
|
1938
|
-
return {
|
|
1947
|
+
return {
|
|
1948
|
+
toolResults,
|
|
1949
|
+
aborted,
|
|
1950
|
+
preempted: !aborted && tracker.preempted(),
|
|
1951
|
+
endRun: tracker.endRun()
|
|
1952
|
+
};
|
|
1939
1953
|
}
|
|
1940
1954
|
function cancelledBeforeStartText(name) {
|
|
1941
1955
|
return `\`${name}\` was cancelled before it started, so it had no effect. Safe to retry.`;
|