@tangle-network/agent-app 0.46.18 → 0.46.20
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/chat-routes/index.js +1 -1
- package/dist/{chunk-47LN6Q2U.js → chunk-G6A4BEZI.js} +36 -5
- package/dist/chunk-G6A4BEZI.js.map +1 -0
- package/dist/sandbox/diagnostics.d.ts +9 -2
- package/dist/sandbox/index.d.ts +5 -5
- package/dist/sandbox/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-47LN6Q2U.js.map +0 -1
|
@@ -112,7 +112,7 @@ import {
|
|
|
112
112
|
flattenHistory,
|
|
113
113
|
readSandboxBinaryBytes,
|
|
114
114
|
statSandboxFileSize
|
|
115
|
-
} from "../chunk-
|
|
115
|
+
} from "../chunk-G6A4BEZI.js";
|
|
116
116
|
import "../chunk-TH7L265V.js";
|
|
117
117
|
import "../chunk-LWSJK546.js";
|
|
118
118
|
import "../chunk-P5PIAQVS.js";
|
|
@@ -511,15 +511,28 @@ function isSandboxApiBearerAuthFailure(diagnostics) {
|
|
|
511
511
|
return /^\/v1\/sandboxes\/[^/?#]+(?:\/(?!runtime(?:[/?#]|$))[^?#]*)?(?:[?#].*)?$/.test(endpointPath);
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
|
+
var SANDBOX_BACKING_CONTAINER_MISSING_CODE = "BACKING_CONTAINER_MISSING";
|
|
515
|
+
function isLegacySandboxBackingContainerMissingMessage(message) {
|
|
516
|
+
return /host-agent startcontainer failed \(404\):/i.test(message) && /container not found/i.test(message) && /"code"\s*:\s*"not_found"/i.test(message);
|
|
517
|
+
}
|
|
514
518
|
function isSandboxApiSandboxMissingFailure(diagnostics) {
|
|
515
519
|
return diagnostics.causes.some((cause) => {
|
|
516
520
|
const status = typeof cause.status === "number" ? cause.status : typeof cause.status === "string" ? Number.parseInt(cause.status, 10) : void 0;
|
|
517
|
-
if (status !== 404) return false;
|
|
518
521
|
if (cause.origin !== "sandbox-api") return false;
|
|
519
522
|
if (typeof cause.endpoint !== "string") return false;
|
|
520
523
|
const endpointPath = sandboxApiEndpointPath(cause.endpoint);
|
|
521
524
|
if (!endpointPath) return false;
|
|
522
|
-
|
|
525
|
+
const sandboxResource = /^\/v1\/sandboxes\/[^/?#]+(?:\/(?!runtime(?:[/?#]|$))[^?#]*)?(?:[?#].*)?$/.test(endpointPath);
|
|
526
|
+
if (!sandboxResource) return false;
|
|
527
|
+
if (status === 404) return true;
|
|
528
|
+
if (status !== 500 || !/^\/v1\/sandboxes\/[^/?#]+\/resume(?:[?#].*)?$/.test(endpointPath)) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
const code = typeof cause.code === "string" ? cause.code.toUpperCase() : void 0;
|
|
532
|
+
if (code === SANDBOX_BACKING_CONTAINER_MISSING_CODE) return true;
|
|
533
|
+
if (code !== void 0 && code !== "SERVER_ERROR") return false;
|
|
534
|
+
const message = typeof cause.message === "string" ? cause.message : "";
|
|
535
|
+
return isLegacySandboxBackingContainerMissingMessage(message);
|
|
523
536
|
});
|
|
524
537
|
}
|
|
525
538
|
function isSandboxHostCapacityFailure(diagnostics) {
|
|
@@ -1605,14 +1618,31 @@ async function isReusableBox(box, harness, probe) {
|
|
|
1605
1618
|
else livenessVerifiedAt.delete(box.id);
|
|
1606
1619
|
return alive;
|
|
1607
1620
|
}
|
|
1621
|
+
function stoppedBoxResumeError(box, cause) {
|
|
1622
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
1623
|
+
const code = error.code;
|
|
1624
|
+
if (code === SANDBOX_BACKING_CONTAINER_MISSING_CODE) return cause;
|
|
1625
|
+
if (code !== void 0 && code !== "SERVER_ERROR") return cause;
|
|
1626
|
+
if (!isLegacySandboxBackingContainerMissingMessage(error.message)) return cause;
|
|
1627
|
+
const status = typeof cause === "object" && cause !== null ? cause.status : void 0;
|
|
1628
|
+
if (typeof status !== "number" && typeof status !== "string") return cause;
|
|
1629
|
+
const wrapped = new Error(error.message, { cause: error });
|
|
1630
|
+
wrapped.name = error.name;
|
|
1631
|
+
return Object.assign(wrapped, {
|
|
1632
|
+
status,
|
|
1633
|
+
origin: "sandbox-api",
|
|
1634
|
+
endpoint: `/v1/sandboxes/${encodeURIComponent(box.id)}/resume`,
|
|
1635
|
+
...typeof code === "number" || typeof code === "string" ? { code } : {}
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1608
1638
|
async function resumeStoppedBox(box, timeoutMs, onProgress) {
|
|
1609
1639
|
try {
|
|
1610
1640
|
livenessVerifiedAt.delete(box.id);
|
|
1611
1641
|
await box.resume({ timeoutMs });
|
|
1612
1642
|
await box.waitFor("running", { timeoutMs, ...onProgress ? { onProgress } : {} });
|
|
1613
1643
|
return ok(box);
|
|
1614
|
-
} catch (
|
|
1615
|
-
return fail(
|
|
1644
|
+
} catch (cause) {
|
|
1645
|
+
return fail(stoppedBoxResumeError(box, cause));
|
|
1616
1646
|
}
|
|
1617
1647
|
}
|
|
1618
1648
|
async function recoverUnresponsiveBox(client, box, harness, probe, stage, name, resumeTimeout, onProgress) {
|
|
@@ -2388,6 +2418,7 @@ export {
|
|
|
2388
2418
|
formatSandboxProvisioningSupportDetails,
|
|
2389
2419
|
isSandboxAuthFailure,
|
|
2390
2420
|
isSandboxApiBearerAuthFailure,
|
|
2421
|
+
SANDBOX_BACKING_CONTAINER_MISSING_CODE,
|
|
2391
2422
|
isSandboxApiSandboxMissingFailure,
|
|
2392
2423
|
isSandboxHostCapacityFailure,
|
|
2393
2424
|
formatSandboxProvisioningUserMessage,
|
|
@@ -2448,4 +2479,4 @@ export {
|
|
|
2448
2479
|
isTerminalPromptEvent,
|
|
2449
2480
|
detectInteractiveQuestion
|
|
2450
2481
|
};
|
|
2451
|
-
//# sourceMappingURL=chunk-
|
|
2482
|
+
//# sourceMappingURL=chunk-G6A4BEZI.js.map
|