@tangle-network/agent-app 0.60.285 → 0.60.286
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,23 @@ 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 terminalFailureMessage(error) {
|
|
2110
|
+
if (/\bENOSPC\b|no space left on device/i.test(error)) {
|
|
2111
|
+
return "The Sandbox ran out of disk space before the execution finished.";
|
|
2112
|
+
}
|
|
2113
|
+
if (error === RUNTIME_RESTARTED_ERROR) return RUNTIME_RESTARTED_ERROR;
|
|
2114
|
+
if (/\bcancelled\b|\bcanceled\b/i.test(error)) return "Native Sandbox execution was cancelled.";
|
|
2115
|
+
if (/MCP.*(?:did not become ready|bootstrap)|(?:MCP|runtime) bootstrap failed/i.test(error)) {
|
|
2116
|
+
return "The Sandbox could not start the agent runtime.";
|
|
2117
|
+
}
|
|
2118
|
+
return "Native Sandbox execution failed before producing an answer.";
|
|
2119
|
+
}
|
|
2120
|
+
function exactFailedResult(value, turnId, sessionId) {
|
|
2121
|
+
const result = record(value);
|
|
2122
|
+
if (result?.executionId !== turnId || result.sessionId !== void 0 && result.sessionId !== sessionId) return void 0;
|
|
2123
|
+
if (result.success !== false || !["error", "failed", "cancelled"].includes(String(result.status))) return void 0;
|
|
2124
|
+
return typeof result.error === "string" && result.error.trim() ? result : void 0;
|
|
2125
|
+
}
|
|
2109
2126
|
function interruptedMessages(messages, turnId) {
|
|
2110
2127
|
return messages.filter(
|
|
2111
2128
|
(message) => message.role === "assistant" && message.metadata?.turnId === turnId && (message.metadata.interrupted === true || message.metadata.status === "interrupted")
|
|
@@ -2249,6 +2266,21 @@ async function observeNativeCompletion(options) {
|
|
|
2249
2266
|
recovered.push({ turnId, state: "failed", text: "", parts: [], usage: {}, error: RUNTIME_RESTARTED_ERROR });
|
|
2250
2267
|
continue;
|
|
2251
2268
|
}
|
|
2269
|
+
if ((run.status === "failed" || run.status === "cancelled") && interrupted.length === 0 && turnAssistantMessages(messages ?? [], turnId).length === 0 && run.sessionId === options.sessionId && replayableExecution(run)) {
|
|
2270
|
+
const result = exactFailedResult(await exactSession.result({ executionId: turnId }), turnId, options.sessionId);
|
|
2271
|
+
if (result) {
|
|
2272
|
+
recovered.push({
|
|
2273
|
+
turnId,
|
|
2274
|
+
state: "failed",
|
|
2275
|
+
text: "",
|
|
2276
|
+
parts: [],
|
|
2277
|
+
usage: usageFromResult(result),
|
|
2278
|
+
...attributionFromResult(result),
|
|
2279
|
+
error: terminalFailureMessage(result.error)
|
|
2280
|
+
});
|
|
2281
|
+
continue;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2252
2284
|
if ((run.status === "failed" || run.status === "cancelled") && interrupted.length === 1) {
|
|
2253
2285
|
const message = recoverSandboxAssistantMessage(interrupted[0]);
|
|
2254
2286
|
const result = replayableExecution(run) ? await exactSession.result({ executionId: turnId }) : void 0;
|
|
@@ -2259,7 +2291,7 @@ async function observeNativeCompletion(options) {
|
|
|
2259
2291
|
parts: message.parts ?? [],
|
|
2260
2292
|
usage: { ...message.usage, ...usageFromResult(result) },
|
|
2261
2293
|
...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
|
|
2294
|
+
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.")
|
|
2263
2295
|
});
|
|
2264
2296
|
continue;
|
|
2265
2297
|
}
|