@tangle-network/agent-app 0.60.285 → 0.60.287
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.
|
@@ -2106,6 +2106,27 @@ function isSandboxNotFoundError(value) {
|
|
|
2106
2106
|
const error = record(value);
|
|
2107
2107
|
return error?.name === "NotFoundError" || error?.code === "NOT_FOUND" || error?.status === 404;
|
|
2108
2108
|
}
|
|
2109
|
+
function isCanonicalUserStop(error) {
|
|
2110
|
+
return error === "Execution cancelled by user" || error === "Execution cancelled by the user";
|
|
2111
|
+
}
|
|
2112
|
+
function terminalFailureMessage(error, provenUserStop) {
|
|
2113
|
+
if (provenUserStop) return "Execution cancelled by the user";
|
|
2114
|
+
if (/\bENOSPC\b|no space left on device/i.test(error)) {
|
|
2115
|
+
return "The Sandbox ran out of disk space before the execution finished.";
|
|
2116
|
+
}
|
|
2117
|
+
if (error === RUNTIME_RESTARTED_ERROR) return RUNTIME_RESTARTED_ERROR;
|
|
2118
|
+
if (/\bcancelled\b|\bcanceled\b/i.test(error)) return "Native Sandbox execution was cancelled.";
|
|
2119
|
+
if (/MCP.*(?:did not become ready|bootstrap)|(?:MCP|runtime) bootstrap failed/i.test(error)) {
|
|
2120
|
+
return "The Sandbox could not start the agent runtime.";
|
|
2121
|
+
}
|
|
2122
|
+
return "Native Sandbox execution failed before producing an answer.";
|
|
2123
|
+
}
|
|
2124
|
+
function exactFailedResult(value, turnId, sessionId) {
|
|
2125
|
+
const result = record(value);
|
|
2126
|
+
if (result?.executionId !== turnId || result.sessionId !== void 0 && result.sessionId !== sessionId) return void 0;
|
|
2127
|
+
if (result.success !== false || !["error", "failed", "cancelled"].includes(String(result.status))) return void 0;
|
|
2128
|
+
return typeof result.error === "string" && result.error.trim() ? result : void 0;
|
|
2129
|
+
}
|
|
2109
2130
|
function interruptedMessages(messages, turnId) {
|
|
2110
2131
|
return messages.filter(
|
|
2111
2132
|
(message) => message.role === "assistant" && message.metadata?.turnId === turnId && (message.metadata.interrupted === true || message.metadata.status === "interrupted")
|
|
@@ -2249,9 +2270,25 @@ async function observeNativeCompletion(options) {
|
|
|
2249
2270
|
recovered.push({ turnId, state: "failed", text: "", parts: [], usage: {}, error: RUNTIME_RESTARTED_ERROR });
|
|
2250
2271
|
continue;
|
|
2251
2272
|
}
|
|
2273
|
+
if ((run.status === "failed" || run.status === "cancelled") && interrupted.length === 0 && turnAssistantMessages(messages ?? [], turnId).length === 0 && run.sessionId === options.sessionId && replayableExecution(run)) {
|
|
2274
|
+
const result = exactFailedResult(await exactSession.result({ executionId: turnId }), turnId, options.sessionId);
|
|
2275
|
+
if (result) {
|
|
2276
|
+
recovered.push({
|
|
2277
|
+
turnId,
|
|
2278
|
+
state: "failed",
|
|
2279
|
+
text: "",
|
|
2280
|
+
parts: [],
|
|
2281
|
+
usage: usageFromResult(result),
|
|
2282
|
+
...attributionFromResult(result),
|
|
2283
|
+
error: terminalFailureMessage(result.error, run.status === "cancelled" && isCanonicalUserStop(result.error))
|
|
2284
|
+
});
|
|
2285
|
+
continue;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2252
2288
|
if ((run.status === "failed" || run.status === "cancelled") && interrupted.length === 1) {
|
|
2253
2289
|
const message = recoverSandboxAssistantMessage(interrupted[0]);
|
|
2254
2290
|
const result = replayableExecution(run) ? await exactSession.result({ executionId: turnId }) : void 0;
|
|
2291
|
+
const provenUserStop = run.status === "cancelled" && (isCanonicalUserStop(interrupted[0].metadata?.interruptReason) || isCanonicalUserStop(exactFailedResult(result, turnId, options.sessionId)?.error));
|
|
2255
2292
|
recovered.push({
|
|
2256
2293
|
turnId,
|
|
2257
2294
|
state: "failed",
|
|
@@ -2259,7 +2296,7 @@ async function observeNativeCompletion(options) {
|
|
|
2259
2296
|
parts: message.parts ?? [],
|
|
2260
2297
|
usage: { ...message.usage, ...usageFromResult(result) },
|
|
2261
2298
|
...attributionFromResult(result),
|
|
2262
|
-
error: (typeof result?.error === "string" ? result.error : void 0) ?? interrupted[0].metadata?.interruptReason ?? (restarted ? RUNTIME_RESTARTED_ERROR : void 0) ?? status.failureReason?.message
|
|
2299
|
+
error: terminalFailureMessage((typeof result?.error === "string" ? result.error : void 0) ?? interrupted[0].metadata?.interruptReason ?? (restarted ? RUNTIME_RESTARTED_ERROR : void 0) ?? status.failureReason?.message ?? "Native Sandbox execution failed.", provenUserStop)
|
|
2263
2300
|
});
|
|
2264
2301
|
continue;
|
|
2265
2302
|
}
|