@tangle-network/agent-app 0.60.43 → 0.60.45
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.
|
@@ -1819,6 +1819,21 @@ function aggregateNativeCompletionReceipts(turns) {
|
|
|
1819
1819
|
completedTurnIds: turns.map((turn) => turn.turnId)
|
|
1820
1820
|
};
|
|
1821
1821
|
}
|
|
1822
|
+
var TOOL_ABORTED_ERROR = "The Sandbox aborted a tool call before the turn finished, as when its runtime restarts mid-turn";
|
|
1823
|
+
function abortedToolCall(parts) {
|
|
1824
|
+
for (const part of parts) {
|
|
1825
|
+
if (part.type !== "tool") continue;
|
|
1826
|
+
const state = part.state;
|
|
1827
|
+
if (state?.status === "error" && /tool execution aborted/i.test(String(state.error ?? ""))) {
|
|
1828
|
+
return typeof part.tool === "string" ? part.tool : "tool";
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
return void 0;
|
|
1832
|
+
}
|
|
1833
|
+
function sessionHoldsLiveWork(status) {
|
|
1834
|
+
if (status.status !== "queued" && status.status !== "running") return false;
|
|
1835
|
+
return status.raw?.state !== "stale";
|
|
1836
|
+
}
|
|
1822
1837
|
function missingTurnReceipt(turnId, error) {
|
|
1823
1838
|
return { turnId, state: "failed", text: "", parts: [], usage: {}, error };
|
|
1824
1839
|
}
|
|
@@ -1854,7 +1869,7 @@ async function observeNativeCompletion(options) {
|
|
|
1854
1869
|
}
|
|
1855
1870
|
const exactSession = session;
|
|
1856
1871
|
if (admission.state === "open") {
|
|
1857
|
-
if (status
|
|
1872
|
+
if (sessionHoldsLiveWork(status)) {
|
|
1858
1873
|
admission = await options.admissionStore.renew(options.executionId, new Date(now)) ?? admission;
|
|
1859
1874
|
} else if (leaseUntil <= now) {
|
|
1860
1875
|
admission = await options.admissionStore.closeExpired(options.executionId, new Date(now)) ?? admission;
|
|
@@ -1883,13 +1898,17 @@ async function observeNativeCompletion(options) {
|
|
|
1883
1898
|
}
|
|
1884
1899
|
const completed = run.status === "completed" ? await readCompletedSandboxTurn(source, { turnId, sessionId: options.sessionId, since }) : null;
|
|
1885
1900
|
if (run.status === "completed" && completed) {
|
|
1901
|
+
const aborted = abortedToolCall(completed.parts ?? []);
|
|
1886
1902
|
recovered.push({
|
|
1887
1903
|
...completed,
|
|
1888
1904
|
turnId,
|
|
1889
|
-
|
|
1905
|
+
// A run the runtime ended while a tool was still running reports
|
|
1906
|
+
// completed, but its reply stops mid-work. It is a failed turn.
|
|
1907
|
+
state: aborted ? "failed" : "completed",
|
|
1890
1908
|
text: completed.text ?? "",
|
|
1891
1909
|
parts: completed.parts ?? [],
|
|
1892
|
-
usage: completed.usage ?? {}
|
|
1910
|
+
usage: completed.usage ?? {},
|
|
1911
|
+
...aborted ? { error: `${TOOL_ABORTED_ERROR} (${aborted})` } : {}
|
|
1893
1912
|
});
|
|
1894
1913
|
continue;
|
|
1895
1914
|
}
|
|
@@ -3373,6 +3392,7 @@ export {
|
|
|
3373
3392
|
OOXML_WORD_MACRO_ENABLED_MIME,
|
|
3374
3393
|
OOXML_WORD_MIME,
|
|
3375
3394
|
PROMOTE_MAX_FILE_BYTES,
|
|
3395
|
+
TOOL_ABORTED_ERROR,
|
|
3376
3396
|
UPLOAD_INLINE_MAX_BYTES,
|
|
3377
3397
|
UPLOAD_MAX_FILE_BYTES,
|
|
3378
3398
|
aggregateNativeCompletionReceipts,
|