@tangle-network/sandbox 1.0.190 → 1.0.192
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/agent/index.d.ts +4 -4
- package/dist/agent/index.js +9 -6
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +1 -1
- package/dist/{agent-run-outcome-Cst4px_l.d.ts → agent-run-outcome-BO5paRhX.d.ts} +2 -2
- package/dist/{api-request-CZlFy3ku.js → api-request-BHbSfsRr.js} +1 -1
- package/dist/{browser-interactive-control-controller-DHIS8edi.js → browser-interactive-control-controller-BYbNLahH.js} +1 -1
- package/dist/{browser-interactive-control-controller-DIvMQyer.d.ts → browser-interactive-control-controller-KOK6qn2s.d.ts} +1 -1
- package/dist/{chunked-upload-vAE2hVcP.js → chunked-upload-D5ytV_s6.js} +9 -13
- package/dist/{chunked-upload-file-HLSriv3V.js → chunked-upload-file-DL1-AqRp.js} +2 -2
- package/dist/{client-BERYosgI.js → client-DuWQNr-Q.js} +159 -109
- package/dist/{client-C4SnCCpF.d.ts → client-yWdLuj_P.d.ts} +5 -5
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-CmT6Ygiv.js → collaboration-Bbr45lyk.js} +3 -3
- package/dist/{core-BT-0QZT-.js → core-BU1I2KvV.js} +13 -7
- package/dist/core.d.ts +6 -6
- package/dist/core.js +5 -5
- package/dist/errors-Mzq10WZq.js +583 -0
- package/dist/{file-download-BXgu9BNh.js → file-download-CKOxcATB.js} +1 -1
- package/dist/{index-DDIymnCZ.d.ts → index-DKsOu5sq.d.ts} +5 -5
- package/dist/index.d.ts +9 -9
- package/dist/index.js +10 -10
- package/dist/intelligence/index.js +9 -5
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-DXGWBdYK.d.ts → interactive-controller-YyZEsoB0.d.ts} +3 -3
- package/dist/{interactive-controller-C876Pjaj.js → interactive-controller-jr3_74Pq.js} +90 -57
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-Br3ygqhP.d.ts → lines-CCHDUfQg.d.ts} +1 -1
- package/dist/{lines-DxHJhxCe.js → lines-DrG0WOW6.js} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{mcp-local-D7MpwsW0.js → mcp-local-O1HzsQiZ.js} +3 -3
- package/dist/{prepared-evidence-CP1MmeCQ.js → prepared-evidence-4prvV0YK.js} +1 -1
- package/dist/{prepared-process-BWVz93cT.js → prepared-process-BSpZXDDw.js} +1 -1
- package/dist/{preview-DUxqnKSk.d.ts → preview-I1z42VGY.d.ts} +3 -3
- package/dist/{public-templates-DQiblzzK.d.ts → public-templates-Cw6gmWJD.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +7 -4
- package/dist/{raw-evidence-archive-CgbWa4es.js → raw-evidence-archive-BD37zHN5.js} +2 -2
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +9 -7
- package/dist/{sandbox-B_Xbc9wR.js → sandbox-Dtb-_btd.js} +317 -221
- package/dist/select-seat-command.d.ts +1 -1
- package/dist/select-seat-command.js +5 -2
- package/dist/session-gateway/index.js +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-Sg9ORVAA.js → tangle-fs17QlcY.js} +2 -2
- package/dist/{terminal-stream-types-1YKRrkZB.d.ts → terminal-stream-types-BqNv5EuG.d.ts} +280 -305
- package/dist/{types-B-UsXSi6.d.ts → types-CiuGb4lZ.d.ts} +4 -2
- package/package.json +4 -4
- package/dist/errors-CaX0a5Ry.js +0 -636
- /package/dist/{abort-signal-PgWPMn_e.js → abort-signal-Cu4F2VVz.js} +0 -0
- /package/dist/{file-transfer-DTHgLccV.js → file-transfer-Cr9Ossea.js} +0 -0
- /package/dist/{retry-after-header-Bt-XvU-x.js → retry-after-header-DUdCC0KJ.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { C as boundedIdentifierSchema, T as boundedJsonSchema, o as canonicalCandidateDigest } from "./harness-DMaNgn0S.js";
|
|
2
|
-
import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-
|
|
2
|
+
import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-BYbNLahH.js";
|
|
3
3
|
import { r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
|
|
4
|
-
import {
|
|
5
|
-
import { n as awaitWithAbort, r as combineAbortSignals, t as abortableSleep } from "./abort-signal-
|
|
4
|
+
import { C as ServerError, D as ValidationError, S as SandboxError, g as NetworkError, i as parseResponseError, l as CapabilityError, t as TerminalStreamError } from "./errors-Mzq10WZq.js";
|
|
5
|
+
import { n as awaitWithAbort, r as combineAbortSignals, t as abortableSleep } from "./abort-signal-Cu4F2VVz.js";
|
|
6
6
|
import { t as parseSSEStream } from "./sse-parser-B4aH89Nq.js";
|
|
7
|
-
import { s as uploadChunked } from "./chunked-upload-
|
|
7
|
+
import { s as uploadChunked } from "./chunked-upload-D5ytV_s6.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
/** Stable declaration order; registry tests check the shipped spec composition. */
|
|
10
10
|
const ALL_BACKEND_TYPES = Object.values({
|
|
@@ -785,9 +785,9 @@ function assertCurrentBackendType(value, field = "backend.type") {
|
|
|
785
785
|
function applyRequestedModel(backend, requestedModel) {
|
|
786
786
|
if (requestedModel === void 0) return backend;
|
|
787
787
|
const model = requestedModel.trim();
|
|
788
|
-
if (!model) throw new ValidationError("model must be a non-empty model id", { model: "Must be a non-empty model id" });
|
|
788
|
+
if (!model) throw new ValidationError("model must be a non-empty model id", { fields: { model: "Must be a non-empty model id" } });
|
|
789
789
|
const explicit = backend?.model?.model;
|
|
790
|
-
if (explicit !== void 0 && explicit !== model) throw new ValidationError(`Conflicting per-turn models: options.model="${model}" vs backend.model.model="${explicit}". Set one of them.`, { model: "Conflicts with backend.model.model" });
|
|
790
|
+
if (explicit !== void 0 && explicit !== model) throw new ValidationError(`Conflicting per-turn models: options.model="${model}" vs backend.model.model="${explicit}". Set one of them.`, { fields: { model: "Conflicts with backend.model.model" } });
|
|
791
791
|
return {
|
|
792
792
|
...backend,
|
|
793
793
|
model: {
|
|
@@ -1034,12 +1034,14 @@ function sameExactRunControlRef(left, right) {
|
|
|
1034
1034
|
}
|
|
1035
1035
|
function validateAcceptedDispatchRunRef(raw, expected, sandboxId, sessionId, executionId, endpoint = "/agents/run/stream") {
|
|
1036
1036
|
const parsed = AgentExactRunControlRefSchema.safeParse(raw);
|
|
1037
|
-
if (!parsed.success) throw new ServerError("Sandbox returned an invalid exact run reference on admission",
|
|
1037
|
+
if (!parsed.success) throw new ServerError("Sandbox returned an invalid exact run reference on admission", {
|
|
1038
|
+
status: 502,
|
|
1038
1039
|
origin: "runtime",
|
|
1039
1040
|
endpoint
|
|
1040
1041
|
});
|
|
1041
1042
|
const accepted = parsed.data;
|
|
1042
|
-
if (accepted.environmentId !== sandboxId || accepted.sessionId !== sessionId || accepted.executionId !== executionId || !sameExactRunControlRef(accepted, expected)) throw new ServerError("Sandbox returned an exact run reference for another execution",
|
|
1043
|
+
if (accepted.environmentId !== sandboxId || accepted.sessionId !== sessionId || accepted.executionId !== executionId || !sameExactRunControlRef(accepted, expected)) throw new ServerError("Sandbox returned an exact run reference for another execution", {
|
|
1044
|
+
status: 502,
|
|
1043
1045
|
origin: "runtime",
|
|
1044
1046
|
endpoint
|
|
1045
1047
|
});
|
|
@@ -1077,7 +1079,7 @@ function mintTraceId() {
|
|
|
1077
1079
|
*/
|
|
1078
1080
|
function resolveTraceId(requested) {
|
|
1079
1081
|
if (requested === void 0) return mintTraceId();
|
|
1080
|
-
if (!isTraceId(requested)) throw new ValidationError("traceId must be 8-200 characters of letters, digits, '_' or '-'", { traceId: "Invalid trace id" });
|
|
1082
|
+
if (!isTraceId(requested)) throw new ValidationError("traceId must be 8-200 characters of letters, digits, '_' or '-'", { fields: { traceId: "Invalid trace id" } });
|
|
1081
1083
|
return requested;
|
|
1082
1084
|
}
|
|
1083
1085
|
/**
|
|
@@ -1095,7 +1097,7 @@ function traceHeaders(traceId) {
|
|
|
1095
1097
|
//#region src/runtime-credential-retry.ts
|
|
1096
1098
|
/** A 503 the runtime answers before any work starts; the request may be resent. */
|
|
1097
1099
|
function isRetryableCredentialRefusal(error) {
|
|
1098
|
-
return error instanceof SandboxError && error.status === 503 && (error.
|
|
1100
|
+
return error instanceof SandboxError && error.status === 503 && (error.wireCode === "MODEL_CREDENTIAL_SUPERSEDED" || error.wireCode === "MODEL_CREDENTIAL_PLATFORM_UNAVAILABLE" || error.wireCode === "HUB_CREDENTIAL_REFRESH_UNAVAILABLE" || error.wireCode === "HUB_CREDENTIAL_REFRESH_FAILED" && Number.isFinite(error.retryAfterMs));
|
|
1099
1101
|
}
|
|
1100
1102
|
//#endregion
|
|
1101
1103
|
//#region src/generated/file-write-preconditions.ts
|
|
@@ -1232,7 +1234,7 @@ var RuntimeFiles = class extends RuntimeApiTransport {
|
|
|
1232
1234
|
expectedHash: options.ifHash,
|
|
1233
1235
|
ifAbsent: options.ifAbsent
|
|
1234
1236
|
});
|
|
1235
|
-
if (!payload.data) throw new ServerError("Invalid file write response: missing data", 502);
|
|
1237
|
+
if (!payload.data) throw new ServerError("Invalid file write response: missing data", { status: 502 });
|
|
1236
1238
|
return payload.data;
|
|
1237
1239
|
}
|
|
1238
1240
|
async readFiles(paths, options = {}) {
|
|
@@ -1350,10 +1352,10 @@ var RuntimeFiles = class extends RuntimeApiTransport {
|
|
|
1350
1352
|
const response = await this.request(`/files/usage?${params}`, { method: "GET" });
|
|
1351
1353
|
const payload = await response.json();
|
|
1352
1354
|
if (response.status !== 202) {
|
|
1353
|
-
if (!payload.data) throw new ServerError("Workspace usage response was malformed", 502);
|
|
1355
|
+
if (!payload.data) throw new ServerError("Workspace usage response was malformed", { status: 502 });
|
|
1354
1356
|
return payload.data;
|
|
1355
1357
|
}
|
|
1356
|
-
if (payload.state !== "preparing" || Date.now() >= deadline) throw new ServerError("Workspace usage observation timed out", 504);
|
|
1358
|
+
if (payload.state !== "preparing" || Date.now() >= deadline) throw new ServerError("Workspace usage observation timed out", { status: 504 });
|
|
1357
1359
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
1358
1360
|
}
|
|
1359
1361
|
}
|
|
@@ -1542,17 +1544,20 @@ var SandboxRuntimeApi = class extends RuntimeFiles {
|
|
|
1542
1544
|
});
|
|
1543
1545
|
if (payload?.receipt === null) return null;
|
|
1544
1546
|
const receipt = payload?.receipt;
|
|
1545
|
-
if (!receipt || typeof receipt.info?.id !== "string" || !receipt.info.id || receipt.processing !== true) throw new ServerError("Runtime returned an invalid message admission receipt",
|
|
1547
|
+
if (!receipt || typeof receipt.info?.id !== "string" || !receipt.info.id || receipt.processing !== true) throw new ServerError("Runtime returned an invalid message admission receipt", {
|
|
1548
|
+
status: 502,
|
|
1546
1549
|
origin: "runtime",
|
|
1547
1550
|
endpoint
|
|
1548
1551
|
});
|
|
1549
1552
|
const parsedRef = receipt.runControlRef === void 0 ? void 0 : AgentExactRunControlRefSchema.safeParse(receipt.runControlRef);
|
|
1550
|
-
if (parsedRef && !parsedRef.success) throw new ServerError("Admission returned an invalid exact run reference",
|
|
1553
|
+
if (parsedRef && !parsedRef.success) throw new ServerError("Admission returned an invalid exact run reference", {
|
|
1554
|
+
status: 502,
|
|
1551
1555
|
origin: "runtime",
|
|
1552
1556
|
endpoint
|
|
1553
1557
|
});
|
|
1554
1558
|
const runControlRef = parsedRef?.data;
|
|
1555
|
-
if (runControlRef && (runControlRef.sessionId !== sessionId || runControlRef.executionId !== receipt.info.id)) throw new ServerError("Admission control reference does not match its execution",
|
|
1559
|
+
if (runControlRef && (runControlRef.sessionId !== sessionId || runControlRef.executionId !== receipt.info.id)) throw new ServerError("Admission control reference does not match its execution", {
|
|
1560
|
+
status: 502,
|
|
1556
1561
|
origin: "runtime",
|
|
1557
1562
|
endpoint
|
|
1558
1563
|
});
|
|
@@ -1573,12 +1578,14 @@ var SandboxRuntimeApi = class extends RuntimeFiles {
|
|
|
1573
1578
|
method: "GET",
|
|
1574
1579
|
signal: options.signal
|
|
1575
1580
|
});
|
|
1576
|
-
if (payload.success !== true || !Array.isArray(payload.executions)) throw new ServerError("Session runs response has an invalid shape",
|
|
1581
|
+
if (payload.success !== true || !Array.isArray(payload.executions)) throw new ServerError("Session runs response has an invalid shape", {
|
|
1582
|
+
status: 502,
|
|
1577
1583
|
origin: "runtime",
|
|
1578
1584
|
endpoint
|
|
1579
1585
|
});
|
|
1580
1586
|
const executions = payload.executions.map((value) => normalizeSessionExecutionInfo(value, sessionId));
|
|
1581
|
-
if (executions.some((execution) => execution === null)) throw new ServerError("Session runs response has an invalid execution",
|
|
1587
|
+
if (executions.some((execution) => execution === null)) throw new ServerError("Session runs response has an invalid execution", {
|
|
1588
|
+
status: 502,
|
|
1582
1589
|
origin: "runtime",
|
|
1583
1590
|
endpoint
|
|
1584
1591
|
});
|
|
@@ -1600,7 +1607,8 @@ var SandboxRuntimeApi = class extends RuntimeFiles {
|
|
|
1600
1607
|
...backend && Object.keys(backend).length > 0 ? { backend } : {}
|
|
1601
1608
|
})
|
|
1602
1609
|
}));
|
|
1603
|
-
if (!info) throw new ServerError("Session creation response missing session id",
|
|
1610
|
+
if (!info) throw new ServerError("Session creation response missing session id", {
|
|
1611
|
+
status: 502,
|
|
1604
1612
|
endpoint: "/agents/sessions",
|
|
1605
1613
|
origin: "runtime"
|
|
1606
1614
|
});
|
|
@@ -1634,7 +1642,8 @@ var SandboxRuntimeApi = class extends RuntimeFiles {
|
|
|
1634
1642
|
...options.isolateFileWrites !== void 0 ? { isolateFileWrites: options.isolateFileWrites } : {}
|
|
1635
1643
|
})
|
|
1636
1644
|
});
|
|
1637
|
-
if (!info.id) throw new ServerError("Task session creation response missing session id",
|
|
1645
|
+
if (!info.id) throw new ServerError("Task session creation response missing session id", {
|
|
1646
|
+
status: 502,
|
|
1638
1647
|
endpoint: "/tasks",
|
|
1639
1648
|
origin: "runtime"
|
|
1640
1649
|
});
|
|
@@ -1721,8 +1730,14 @@ function assertScopedTokenActive(token, expectedScope) {
|
|
|
1721
1730
|
}
|
|
1722
1731
|
function parseScopedTokenResponse(raw, expectedScope, expectedAccess) {
|
|
1723
1732
|
const parsed = scopedTokenResponseSchema.safeParse(raw);
|
|
1724
|
-
if (!parsed.success) throw new ServerError("Sandbox API returned an invalid scoped token response.",
|
|
1725
|
-
|
|
1733
|
+
if (!parsed.success) throw new ServerError("Sandbox API returned an invalid scoped token response.", {
|
|
1734
|
+
status: 502,
|
|
1735
|
+
origin: "sandbox-api"
|
|
1736
|
+
});
|
|
1737
|
+
if (parsed.data.scope !== expectedScope || parsed.data.access !== expectedAccess) throw new ServerError("Sandbox API did not acknowledge the requested token scope and access.", {
|
|
1738
|
+
status: 502,
|
|
1739
|
+
origin: "sandbox-api"
|
|
1740
|
+
});
|
|
1726
1741
|
const token = {
|
|
1727
1742
|
token: parsed.data.token,
|
|
1728
1743
|
expiresAt: /* @__PURE__ */ new Date(parsed.data.expiresAt * 1e3),
|
|
@@ -1734,7 +1749,10 @@ function parseScopedTokenResponse(raw, expectedScope, expectedAccess) {
|
|
|
1734
1749
|
try {
|
|
1735
1750
|
assertScopedTokenActive(token, expectedScope);
|
|
1736
1751
|
} catch {
|
|
1737
|
-
throw new ServerError("Sandbox API returned an expired or invalid scoped token.",
|
|
1752
|
+
throw new ServerError("Sandbox API returned an expired or invalid scoped token.", {
|
|
1753
|
+
status: 502,
|
|
1754
|
+
origin: "sandbox-api"
|
|
1755
|
+
});
|
|
1738
1756
|
}
|
|
1739
1757
|
return token;
|
|
1740
1758
|
}
|
|
@@ -1760,13 +1778,16 @@ async function requestScopedToken(client, sandboxId, options, requestOptions) {
|
|
|
1760
1778
|
try {
|
|
1761
1779
|
raw = await response.json();
|
|
1762
1780
|
} catch {
|
|
1763
|
-
throw new ServerError("Sandbox API returned invalid scoped token JSON.",
|
|
1781
|
+
throw new ServerError("Sandbox API returned invalid scoped token JSON.", {
|
|
1782
|
+
status: 502,
|
|
1783
|
+
origin: "sandbox-api"
|
|
1784
|
+
});
|
|
1764
1785
|
}
|
|
1765
1786
|
return parseScopedTokenResponse(raw, options.scope, access);
|
|
1766
1787
|
}
|
|
1767
1788
|
function parseInteractiveSessionTokenRef(ref) {
|
|
1768
1789
|
const parsed = AgentInteractiveSessionRefSchema.safeParse(ref);
|
|
1769
|
-
if (!parsed.success) throw new ValidationError("Interactive session ref is invalid.", { ref: parsed.error.issues[0]?.message ?? "invalid ref" });
|
|
1790
|
+
if (!parsed.success) throw new ValidationError("Interactive session ref is invalid.", { fields: { ref: parsed.error.issues[0]?.message ?? "invalid ref" } });
|
|
1770
1791
|
return parsed.data;
|
|
1771
1792
|
}
|
|
1772
1793
|
function interactiveSessionTokenOptions(ref, options = {}) {
|
|
@@ -1805,7 +1826,7 @@ const DEFAULT_ROWS = 24;
|
|
|
1805
1826
|
* unpadded).
|
|
1806
1827
|
*/
|
|
1807
1828
|
function base64UrlEncodeUtf8(value) {
|
|
1808
|
-
if (typeof btoa !== "function") throw new TerminalStreamError("global btoa is unavailable; cannot build the edge bearer subprotocol", "ENVIRONMENT");
|
|
1829
|
+
if (typeof btoa !== "function") throw new TerminalStreamError("global btoa is unavailable; cannot build the edge bearer subprotocol", { code: "ENVIRONMENT" });
|
|
1809
1830
|
const bytes = new TextEncoder().encode(value);
|
|
1810
1831
|
let binary = "";
|
|
1811
1832
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
@@ -1826,11 +1847,11 @@ async function resolveTerminalToken(token, signal) {
|
|
|
1826
1847
|
try {
|
|
1827
1848
|
assertScopedTokenActive(value, "session-runtime");
|
|
1828
1849
|
} catch {
|
|
1829
|
-
throw new TerminalStreamError("Terminal stream scoped token is expired or invalid", "INVALID_TOKEN");
|
|
1850
|
+
throw new TerminalStreamError("Terminal stream scoped token is expired or invalid", { code: "INVALID_TOKEN" });
|
|
1830
1851
|
}
|
|
1831
1852
|
return value.token;
|
|
1832
1853
|
}
|
|
1833
|
-
if (typeof value !== "string" || !value.trim()) throw new TerminalStreamError(typeof token === "function" ? "Terminal stream token provider returned an empty token" : "Terminal stream token must not be empty", "INVALID_TOKEN");
|
|
1854
|
+
if (typeof value !== "string" || !value.trim()) throw new TerminalStreamError(typeof token === "function" ? "Terminal stream token provider returned an empty token" : "Terminal stream token must not be empty", { code: "INVALID_TOKEN" });
|
|
1834
1855
|
return value;
|
|
1835
1856
|
}
|
|
1836
1857
|
function isApiKeyToken(token) {
|
|
@@ -1841,9 +1862,12 @@ async function resolveDialCredential(token, authFormat, signal) {
|
|
|
1841
1862
|
kind: "subprotocol",
|
|
1842
1863
|
token: await resolveTerminalToken(token, signal)
|
|
1843
1864
|
};
|
|
1844
|
-
if (!token.apiKey.trim()) throw new TerminalStreamError("Terminal stream API key must not be empty", "INVALID_TOKEN");
|
|
1845
|
-
if (authFormat === "sidecar-direct") throw new TerminalStreamError("An API key authenticates the public API proxy, not a direct sidecar dial", "INVALID_TOKEN");
|
|
1846
|
-
if (!terminalUpgradeHeadersSupported()) throw new TerminalStreamError("This runtime cannot set headers on a WebSocket upgrade; dial with a scoped token",
|
|
1865
|
+
if (!token.apiKey.trim()) throw new TerminalStreamError("Terminal stream API key must not be empty", { code: "INVALID_TOKEN" });
|
|
1866
|
+
if (authFormat === "sidecar-direct") throw new TerminalStreamError("An API key authenticates the public API proxy, not a direct sidecar dial", { code: "INVALID_TOKEN" });
|
|
1867
|
+
if (!terminalUpgradeHeadersSupported()) throw new TerminalStreamError("This runtime cannot set headers on a WebSocket upgrade; dial with a scoped token", {
|
|
1868
|
+
code: "ENVIRONMENT",
|
|
1869
|
+
beforeOpen: true
|
|
1870
|
+
});
|
|
1847
1871
|
return {
|
|
1848
1872
|
kind: "apiKey",
|
|
1849
1873
|
apiKey: token.apiKey
|
|
@@ -1885,7 +1909,7 @@ function buildUpgradeRequest(options, credential, identity, traceId) {
|
|
|
1885
1909
|
}
|
|
1886
1910
|
function openWebSocket(request, credential) {
|
|
1887
1911
|
const WebSocketCtor = globalThis.WebSocket;
|
|
1888
|
-
if (typeof WebSocketCtor !== "function") throw new TerminalStreamError("global WebSocket is unavailable in this environment (Node >= 22 or a browser is required)", "ENVIRONMENT");
|
|
1912
|
+
if (typeof WebSocketCtor !== "function") throw new TerminalStreamError("global WebSocket is unavailable in this environment (Node >= 22 or a browser is required)", { code: "ENVIRONMENT" });
|
|
1889
1913
|
if (Object.keys(request.headers).length === 0) return new WebSocketCtor(request.url, request.protocols);
|
|
1890
1914
|
const WebSocketWithHeaders = WebSocketCtor;
|
|
1891
1915
|
try {
|
|
@@ -1894,13 +1918,16 @@ function openWebSocket(request, credential) {
|
|
|
1894
1918
|
headers: request.headers
|
|
1895
1919
|
});
|
|
1896
1920
|
} catch (cause) {
|
|
1897
|
-
if (credential.kind === "apiKey") throw new TerminalStreamError(`This runtime rejected WebSocket upgrade headers: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
1921
|
+
if (credential.kind === "apiKey") throw new TerminalStreamError(`This runtime rejected WebSocket upgrade headers: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
1922
|
+
code: "ENVIRONMENT",
|
|
1923
|
+
beforeOpen: true
|
|
1924
|
+
});
|
|
1898
1925
|
return new WebSocketCtor(request.url, request.protocols);
|
|
1899
1926
|
}
|
|
1900
1927
|
}
|
|
1901
1928
|
function resolveStreamTraceId(requested) {
|
|
1902
1929
|
if (requested === void 0) return mintTraceId();
|
|
1903
|
-
if (!isTraceId(requested)) throw new TerminalStreamError("Terminal stream traceId must be 8-200 characters of letters, digits, '_' or '-'", "INVALID_TRACE_ID");
|
|
1930
|
+
if (!isTraceId(requested)) throw new TerminalStreamError("Terminal stream traceId must be 8-200 characters of letters, digits, '_' or '-'", { code: "INVALID_TRACE_ID" });
|
|
1904
1931
|
return requested;
|
|
1905
1932
|
}
|
|
1906
1933
|
function terminalAbortReason(signal) {
|
|
@@ -1937,24 +1964,24 @@ function toWebSocketUrl(url) {
|
|
|
1937
1964
|
try {
|
|
1938
1965
|
parsed = new URL(url);
|
|
1939
1966
|
} catch {
|
|
1940
|
-
throw new TerminalStreamError(`Terminal WebSocket URL is not absolute: ${url}`, "INVALID_URL");
|
|
1967
|
+
throw new TerminalStreamError(`Terminal WebSocket URL is not absolute: ${url}`, { code: "INVALID_URL" });
|
|
1941
1968
|
}
|
|
1942
1969
|
if (parsed.protocol === "https:") parsed.protocol = "wss:";
|
|
1943
1970
|
else if (parsed.protocol === "http:") parsed.protocol = "ws:";
|
|
1944
|
-
if (parsed.protocol !== "wss:" && parsed.protocol !== "ws:") throw new TerminalStreamError(`Terminal WebSocket URL must be ws(s) or http(s), got ${parsed.protocol}`, "INVALID_URL");
|
|
1971
|
+
if (parsed.protocol !== "wss:" && parsed.protocol !== "ws:") throw new TerminalStreamError(`Terminal WebSocket URL must be ws(s) or http(s), got ${parsed.protocol}`, { code: "INVALID_URL" });
|
|
1945
1972
|
return parsed.toString();
|
|
1946
1973
|
}
|
|
1947
1974
|
function assertDimension(name, value) {
|
|
1948
|
-
if (!Number.isInteger(value) || value < 1 || value > 4096) throw new TerminalStreamError(`${name} must be an integer in [1, ${TERMINAL_WS_MAX_DIMENSION}], got ${value}`, "INVALID_DIMENSION");
|
|
1975
|
+
if (!Number.isInteger(value) || value < 1 || value > 4096) throw new TerminalStreamError(`${name} must be an integer in [1, ${TERMINAL_WS_MAX_DIMENSION}], got ${value}`, { code: "INVALID_DIMENSION" });
|
|
1949
1976
|
}
|
|
1950
1977
|
/** Decode the sidecar's base64 output frame without a Node-only dependency. */
|
|
1951
1978
|
function decodeBase64(value) {
|
|
1952
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) throw new TerminalStreamError("Terminal output frame is not valid base64", "INVALID_FRAME");
|
|
1979
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) throw new TerminalStreamError("Terminal output frame is not valid base64", { code: "INVALID_FRAME" });
|
|
1953
1980
|
let binary;
|
|
1954
1981
|
try {
|
|
1955
1982
|
binary = atob(value);
|
|
1956
1983
|
} catch {
|
|
1957
|
-
throw new TerminalStreamError("Terminal output frame is not valid base64", "INVALID_FRAME");
|
|
1984
|
+
throw new TerminalStreamError("Terminal output frame is not valid base64", { code: "INVALID_FRAME" });
|
|
1958
1985
|
}
|
|
1959
1986
|
const bytes = new Uint8Array(binary.length);
|
|
1960
1987
|
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
@@ -1962,12 +1989,12 @@ function decodeBase64(value) {
|
|
|
1962
1989
|
}
|
|
1963
1990
|
function normalizeInteractiveSessionIdentity(incarnationId, control) {
|
|
1964
1991
|
if (incarnationId === void 0 && control === void 0) return void 0;
|
|
1965
|
-
if (typeof incarnationId !== "string" || incarnationId.length === 0 || incarnationId.trim() !== incarnationId) throw new TerminalStreamError("Interactive terminal attach requires an exact incarnationId", "INVALID_INTERACTIVE_IDENTITY");
|
|
1966
|
-
if (control === void 0) throw new TerminalStreamError("Interactive terminal attach requires an exact control claim", "INVALID_INTERACTIVE_CONTROL");
|
|
1992
|
+
if (typeof incarnationId !== "string" || incarnationId.length === 0 || incarnationId.trim() !== incarnationId) throw new TerminalStreamError("Interactive terminal attach requires an exact incarnationId", { code: "INVALID_INTERACTIVE_IDENTITY" });
|
|
1993
|
+
if (control === void 0) throw new TerminalStreamError("Interactive terminal attach requires an exact control claim", { code: "INVALID_INTERACTIVE_CONTROL" });
|
|
1967
1994
|
const parsedControl = AgentInteractiveSessionControlClaimSchema.safeParse(control);
|
|
1968
|
-
if (!parsedControl.success) throw new TerminalStreamError("Interactive terminal attach requires an exact control claim", "INVALID_INTERACTIVE_CONTROL");
|
|
1995
|
+
if (!parsedControl.success) throw new TerminalStreamError("Interactive terminal attach requires an exact control claim", { code: "INVALID_INTERACTIVE_CONTROL" });
|
|
1969
1996
|
const expiresAt = Date.parse(parsedControl.data.expiresAt);
|
|
1970
|
-
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now()) throw new TerminalStreamError("Interactive terminal control claim is expired", "INTERACTIVE_CONTROL_EXPIRED");
|
|
1997
|
+
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now()) throw new TerminalStreamError("Interactive terminal control claim is expired", { code: "INTERACTIVE_CONTROL_EXPIRED" });
|
|
1971
1998
|
return {
|
|
1972
1999
|
incarnationId,
|
|
1973
2000
|
control: parsedControl.data
|
|
@@ -1976,9 +2003,9 @@ function normalizeInteractiveSessionIdentity(incarnationId, control) {
|
|
|
1976
2003
|
/** The incarnation an observer stream watches, or undefined for any other stream. */
|
|
1977
2004
|
function observedIncarnationId(options) {
|
|
1978
2005
|
if (options.observe !== true) return void 0;
|
|
1979
|
-
if (options.control !== void 0) throw new TerminalStreamError("An interactive terminal observer carries no control claim", "INVALID_INTERACTIVE_CONTROL");
|
|
2006
|
+
if (options.control !== void 0) throw new TerminalStreamError("An interactive terminal observer carries no control claim", { code: "INVALID_INTERACTIVE_CONTROL" });
|
|
1980
2007
|
const { incarnationId } = options;
|
|
1981
|
-
if (typeof incarnationId !== "string" || incarnationId.length === 0 || incarnationId.trim() !== incarnationId) throw new TerminalStreamError("An interactive terminal observer requires an exact incarnationId", "INVALID_INTERACTIVE_IDENTITY");
|
|
2008
|
+
if (typeof incarnationId !== "string" || incarnationId.length === 0 || incarnationId.trim() !== incarnationId) throw new TerminalStreamError("An interactive terminal observer requires an exact incarnationId", { code: "INVALID_INTERACTIVE_IDENTITY" });
|
|
1982
2009
|
return incarnationId;
|
|
1983
2010
|
}
|
|
1984
2011
|
function interactiveInitFields(options, identity) {
|
|
@@ -1994,7 +2021,7 @@ function interactiveInitFields(options, identity) {
|
|
|
1994
2021
|
};
|
|
1995
2022
|
}
|
|
1996
2023
|
function buildTerminalInitMessage(options, identity, traceId) {
|
|
1997
|
-
if (typeof options.connectionId !== "string" || !options.connectionId.trim()) throw new TerminalStreamError("Terminal stream connectionId must not be empty", "INVALID_CONNECTION_ID");
|
|
2024
|
+
if (typeof options.connectionId !== "string" || !options.connectionId.trim()) throw new TerminalStreamError("Terminal stream connectionId must not be empty", { code: "INVALID_CONNECTION_ID" });
|
|
1998
2025
|
if (options.cols !== void 0) assertDimension("cols", options.cols);
|
|
1999
2026
|
if (options.rows !== void 0) assertDimension("rows", options.rows);
|
|
2000
2027
|
const parsed = terminalInitMessageSchema.safeParse({
|
|
@@ -2008,12 +2035,12 @@ function buildTerminalInitMessage(options, identity, traceId) {
|
|
|
2008
2035
|
...interactiveInitFields(options, identity),
|
|
2009
2036
|
...terminalUpgradeHeadersSupported() ? {} : { traceId }
|
|
2010
2037
|
});
|
|
2011
|
-
if (!parsed.success) throw new TerminalStreamError("Terminal stream init does not match the shared terminal protocol", "INVALID_INIT");
|
|
2038
|
+
if (!parsed.success) throw new TerminalStreamError("Terminal stream init does not match the shared terminal protocol", { code: "INVALID_INIT" });
|
|
2012
2039
|
return parsed.data;
|
|
2013
2040
|
}
|
|
2014
2041
|
function assertInteractiveControlActive(identity) {
|
|
2015
2042
|
if (identity === void 0) return;
|
|
2016
|
-
if (Date.parse(identity.control.expiresAt) <= Date.now()) throw new TerminalStreamError("Interactive terminal control claim is expired", "INTERACTIVE_CONTROL_EXPIRED");
|
|
2043
|
+
if (Date.parse(identity.control.expiresAt) <= Date.now()) throw new TerminalStreamError("Interactive terminal control claim is expired", { code: "INTERACTIVE_CONTROL_EXPIRED" });
|
|
2017
2044
|
}
|
|
2018
2045
|
/**
|
|
2019
2046
|
* Split input so each serialized `input` frame stays under the server's
|
|
@@ -2150,7 +2177,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2150
2177
|
let opened = false;
|
|
2151
2178
|
const timeoutMs = this.#options.connectTimeoutMs ?? 15e3;
|
|
2152
2179
|
const timer = setTimeout(() => {
|
|
2153
|
-
fail(new TerminalStreamError(`Terminal attach timed out after ${timeoutMs}ms waiting for ready`, "CONNECT_TIMEOUT"));
|
|
2180
|
+
fail(new TerminalStreamError(`Terminal attach timed out after ${timeoutMs}ms waiting for ready`, { code: "CONNECT_TIMEOUT" }));
|
|
2154
2181
|
this.ws.close(1e3, "connect timeout");
|
|
2155
2182
|
}, timeoutMs);
|
|
2156
2183
|
const cleanup = () => {
|
|
@@ -2186,7 +2213,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2186
2213
|
try {
|
|
2187
2214
|
assertInteractiveControlActive(this.interactiveIdentity);
|
|
2188
2215
|
} catch (error) {
|
|
2189
|
-
fail(error instanceof TerminalStreamError ? error : new TerminalStreamError("Interactive terminal control claim is expired", "INTERACTIVE_CONTROL_EXPIRED"));
|
|
2216
|
+
fail(error instanceof TerminalStreamError ? error : new TerminalStreamError("Interactive terminal control claim is expired", { code: "INTERACTIVE_CONTROL_EXPIRED" }));
|
|
2190
2217
|
return;
|
|
2191
2218
|
}
|
|
2192
2219
|
this.ws.send(JSON.stringify(this.#initMessage));
|
|
@@ -2199,11 +2226,17 @@ var TerminalStream = class TerminalStream {
|
|
|
2199
2226
|
});
|
|
2200
2227
|
});
|
|
2201
2228
|
this.ws.addEventListener("error", () => {
|
|
2202
|
-
fail(new TerminalStreamError("Terminal WebSocket transport failed before ready",
|
|
2229
|
+
fail(new TerminalStreamError("Terminal WebSocket transport failed before ready", {
|
|
2230
|
+
code: "TRANSPORT",
|
|
2231
|
+
beforeOpen: !opened
|
|
2232
|
+
}));
|
|
2203
2233
|
});
|
|
2204
2234
|
this.ws.addEventListener("close", (event) => {
|
|
2205
2235
|
this.closed = true;
|
|
2206
|
-
fail(new TerminalStreamError(`Terminal WebSocket closed before ready (code ${event.code}${event.reason ? `: ${event.reason}` : ""})`,
|
|
2236
|
+
fail(new TerminalStreamError(`Terminal WebSocket closed before ready (code ${event.code}${event.reason ? `: ${event.reason}` : ""})`, {
|
|
2237
|
+
code: "CLOSED_BEFORE_READY",
|
|
2238
|
+
beforeOpen: !opened
|
|
2239
|
+
}));
|
|
2207
2240
|
for (const waiter of this.closeWaiters) waiter();
|
|
2208
2241
|
this.closeWaiters = [];
|
|
2209
2242
|
this.handlers.onClose?.(event.code, event.reason);
|
|
@@ -2219,7 +2252,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2219
2252
|
return;
|
|
2220
2253
|
}
|
|
2221
2254
|
const failProtocolFrame = () => {
|
|
2222
|
-
const error = new TerminalStreamError("Terminal control frame does not match the shared terminal protocol", "INVALID_FRAME");
|
|
2255
|
+
const error = new TerminalStreamError("Terminal control frame does not match the shared terminal protocol", { code: "INVALID_FRAME" });
|
|
2223
2256
|
const beforeReady = !connectPhase.settled();
|
|
2224
2257
|
if (this.ws.readyState === WebSocket.OPEN) this.ws.close(1e3, "invalid terminal frame");
|
|
2225
2258
|
if (beforeReady) connectPhase.fail(error);
|
|
@@ -2268,7 +2301,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2268
2301
|
this.handlers.onOutput?.(parsed.data.seq, bytes);
|
|
2269
2302
|
if (this.handlers.onOutput === void 0) this.handlers.onData?.(bytes);
|
|
2270
2303
|
} catch (error) {
|
|
2271
|
-
const protocolError = error instanceof TerminalStreamError ? error : new TerminalStreamError("Terminal output frame is not valid base64", "INVALID_FRAME");
|
|
2304
|
+
const protocolError = error instanceof TerminalStreamError ? error : new TerminalStreamError("Terminal output frame is not valid base64", { code: "INVALID_FRAME" });
|
|
2272
2305
|
if (!connectPhase.settled()) connectPhase.fail(protocolError);
|
|
2273
2306
|
else this.handlers.onError?.(protocolError);
|
|
2274
2307
|
if (this.ws.readyState === WebSocket.OPEN) this.ws.close(1e3, "invalid terminal output");
|
|
@@ -2282,7 +2315,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2282
2315
|
return;
|
|
2283
2316
|
case "renewed": return;
|
|
2284
2317
|
case "error": {
|
|
2285
|
-
const error = new TerminalStreamError(parsed.data.message, parsed.data.code);
|
|
2318
|
+
const error = new TerminalStreamError(parsed.data.message, { code: parsed.data.code });
|
|
2286
2319
|
if (!connectPhase.settled()) {
|
|
2287
2320
|
connectPhase.fail(error);
|
|
2288
2321
|
return;
|
|
@@ -2298,7 +2331,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2298
2331
|
}
|
|
2299
2332
|
/** The server's `ready` acknowledgement. Set once `connect()` resolves. */
|
|
2300
2333
|
get ready() {
|
|
2301
|
-
if (!this.readyInfo) throw new TerminalStreamError("Terminal stream is not ready yet", "NOT_READY");
|
|
2334
|
+
if (!this.readyInfo) throw new TerminalStreamError("Terminal stream is not ready yet", { code: "NOT_READY" });
|
|
2302
2335
|
return this.readyInfo;
|
|
2303
2336
|
}
|
|
2304
2337
|
/** Correlation id of this attach (`x-tangle-trace-id` / `traceId`). */
|
|
@@ -2429,7 +2462,7 @@ var TerminalStream = class TerminalStream {
|
|
|
2429
2462
|
};
|
|
2430
2463
|
}
|
|
2431
2464
|
assertOpen(action) {
|
|
2432
|
-
if (!this.isOpen) throw new TerminalStreamError(`Cannot ${action}: terminal stream is not open`, "NOT_OPEN");
|
|
2465
|
+
if (!this.isOpen) throw new TerminalStreamError(`Cannot ${action}: terminal stream is not open`, { code: "NOT_OPEN" });
|
|
2433
2466
|
}
|
|
2434
2467
|
};
|
|
2435
2468
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as runPreparedEvidence } from "../prepared-evidence-
|
|
1
|
+
import { t as runPreparedEvidence } from "../prepared-evidence-4prvV0YK.js";
|
|
2
2
|
export { runPreparedEvidence };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-
|
|
1
|
+
import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-BSpZXDDw.js";
|
|
2
2
|
export { runPreparedProcess, withPreparedProcessCalls };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-
|
|
1
|
+
import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-CiuGb4lZ.js";
|
|
2
2
|
|
|
3
3
|
//#region src/line-application.d.ts
|
|
4
4
|
/** Bounded callback request bytes after canonicalization, including JSON framing. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ValidationError, r as parseErrorResponse } from "./errors-Mzq10WZq.js";
|
|
2
2
|
//#region src/line-identity.ts
|
|
3
3
|
/**
|
|
4
4
|
* The instance key that serves one member: `keyPrefix` plus the first 32 hex
|
package/dist/lines.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-
|
|
1
|
+
import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-CCHDUfQg.js";
|
|
2
2
|
export { Line, LineAgentRolePolicy, LineAllowance, LineAllowanceSubject, LineApplicationAttachOptions, LineAttachOptions, LineAttachment, LineAttachmentReauthorization, LineExecutionKey, LineFromConnectionInput, LineImage, LineInstanceAttachOptions, LineInstanceCreate, LineLimits, LineMember, LineMemberInstance, LineMemberPatch, LineMemberSpec, LineMessage, LineNumberInventory, LineProvider, LineReminderPreferences, LineReplyCode, LineReplyCodeInput, LineReplyGate, LineRespondAgent, LineRespondView, LineRole, LineSendInput, LineSendReceipt, LineSenderVerification, LineSenderVerificationStart, LineThread, LineTransport, LineVoice, LineVoiceOptions, LinesClient, LinesHttpClient, SandboxLines, lineInstanceKey, profileChannelReference };
|
package/dist/lines.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-
|
|
1
|
+
import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-DrG0WOW6.js";
|
|
2
2
|
export { LinesClient, SandboxLines, lineInstanceKey, profileChannelReference };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-
|
|
2
|
-
import "./api-request-
|
|
1
|
+
import { u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-Cr9Ossea.js";
|
|
2
|
+
import "./api-request-BHbSfsRr.js";
|
|
3
3
|
import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-B3TTvqlm.js";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -396,7 +396,7 @@ async function createMcpServer(box, options = {}) {
|
|
|
396
396
|
const { bindings, handlers } = bindToolSpecs(box, options);
|
|
397
397
|
const server = new serverModule.Server({
|
|
398
398
|
name: options.name ?? "tangle-sandbox",
|
|
399
|
-
version: options.version ?? "1.0.
|
|
399
|
+
version: options.version ?? "1.0.192"
|
|
400
400
|
}, { capabilities: { tools: {} } });
|
|
401
401
|
server.setRequestHandler(typesModule.ListToolsRequestSchema, async () => ({ tools: bindings.map(({ spec: s }) => ({
|
|
402
402
|
name: s.name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-
|
|
1
|
+
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DUdCC0KJ.js";
|
|
2
2
|
//#region src/lib/prepared-evidence.mjs
|
|
3
3
|
async function receipt(response, idField) {
|
|
4
4
|
const reader = response.body?.getReader();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-
|
|
1
|
+
import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DUdCC0KJ.js";
|
|
2
2
|
//#region src/lib/prepared-process.mjs
|
|
3
3
|
/** Request and pause share one deadline, including independent cancellation cleanup. */
|
|
4
4
|
function processRequests(request, deadline, signal) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as SandboxInstance } from "./index-
|
|
2
|
-
import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-
|
|
3
|
-
import { t as Sandbox } from "./client-
|
|
1
|
+
import { O as SandboxInstance } from "./index-DKsOu5sq.js";
|
|
2
|
+
import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-CiuGb4lZ.js";
|
|
3
|
+
import { t as Sandbox } from "./client-yWdLuj_P.js";
|
|
4
4
|
|
|
5
5
|
//#region src/agent/preview-operations.d.ts
|
|
6
6
|
type AgentPreviewOptions = Pick<EnsureDevServerOptions, "sessionId" | "cwd"> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bt as SandboxError } from "./terminal-stream-types-
|
|
2
|
-
import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-
|
|
1
|
+
import { bt as SandboxError } from "./terminal-stream-types-BqNv5EuG.js";
|
|
2
|
+
import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-CiuGb4lZ.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/public-templates.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-
|
|
1
|
+
import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-Cw6gmWJD.js";
|
|
2
2
|
export { PublicTemplatePublishArtifact, PublicTemplatePublishError, PublicTemplatePublishJob, PublicTemplatePublishRequestOptions, PublicTemplatesClient };
|
package/dist/public-templates.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as SandboxError, a as readResponseJson } from "./errors-Mzq10WZq.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/public-templates.ts
|
|
4
4
|
const publicationStatus = z.enum([
|
|
@@ -36,11 +36,14 @@ var PublicTemplatePublishError = class extends SandboxError {
|
|
|
36
36
|
job;
|
|
37
37
|
artifact;
|
|
38
38
|
constructor(message, code, job, artifact, cause) {
|
|
39
|
-
super(message,
|
|
40
|
-
|
|
39
|
+
super(message, {
|
|
40
|
+
code,
|
|
41
|
+
status: cause instanceof SandboxError ? cause.status : void 0,
|
|
42
|
+
origin: "sandbox-api",
|
|
43
|
+
cause
|
|
44
|
+
});
|
|
41
45
|
this.job = job;
|
|
42
46
|
this.artifact = artifact;
|
|
43
|
-
this.cause = cause;
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
function pause(ms, signal) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as verifyDownload } from "./file-download-
|
|
2
|
-
import { t as runPreparedEvidence } from "./prepared-evidence-
|
|
1
|
+
import { n as verifyDownload } from "./file-download-CKOxcATB.js";
|
|
2
|
+
import { t as runPreparedEvidence } from "./prepared-evidence-4prvV0YK.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/lib/raw-evidence-archive.ts
|
|
5
5
|
const digest = z.string().regex(/^sha256:[a-f0-9]{64}$/).transform((value) => `sha256:${value.slice(7)}`);
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ct as ServerError, Dt as TimeoutError, Ot as ValidationError, St as SandboxFailureDetail, _t as ProfileFileMountPathError, bt as SandboxError, gt as PartialFailureError, ht as NotFoundError, it as AuthError, mt as NetworkError, ot as CapabilityError, u as ScopedToken, ut as FileWriteConflictError, vt as QuotaError, wt as StateError, xt as SandboxErrorJson } from "./terminal-stream-types-
|
|
2
|
-
import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-
|
|
3
|
-
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-
|
|
4
|
-
import { t as BrowserInteractiveSessionController } from "./interactive-controller-
|
|
5
|
-
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-
|
|
1
|
+
import { Ct as ServerError, Dt as TimeoutError, Ot as ValidationError, St as SandboxFailureDetail, _t as ProfileFileMountPathError, bt as SandboxError, gt as PartialFailureError, ht as NotFoundError, it as AuthError, mt as NetworkError, ot as CapabilityError, u as ScopedToken, ut as FileWriteConflictError, vt as QuotaError, wt as StateError, xt as SandboxErrorJson } from "./terminal-stream-types-BqNv5EuG.js";
|
|
2
|
+
import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-CiuGb4lZ.js";
|
|
3
|
+
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-KOK6qn2s.js";
|
|
4
|
+
import { t as BrowserInteractiveSessionController } from "./interactive-controller-YyZEsoB0.js";
|
|
5
|
+
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-BO5paRhX.js";
|
|
6
6
|
|
|
7
7
|
//#region src/lib/chunked-upload.d.ts
|
|
8
8
|
/** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
|
package/dist/runtime.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-
|
|
2
|
-
import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-
|
|
3
|
-
import { C as
|
|
4
|
-
import { n as fetchSandboxApi } from "./api-request-
|
|
5
|
-
import { s as uploadChunked } from "./chunked-upload-
|
|
1
|
+
import { I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-jr3_74Pq.js";
|
|
2
|
+
import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-BYbNLahH.js";
|
|
3
|
+
import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, _ as NotFoundError, b as QuotaError, g as NetworkError, l as CapabilityError, p as FileWriteConflictError, s as AuthError, v as PartialFailureError, w as StateError, y as ProfileFileMountPathError } from "./errors-Mzq10WZq.js";
|
|
4
|
+
import { n as fetchSandboxApi } from "./api-request-BHbSfsRr.js";
|
|
5
|
+
import { s as uploadChunked } from "./chunked-upload-D5ytV_s6.js";
|
|
6
6
|
//#region src/runtime-client.ts
|
|
7
7
|
const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
|
|
8
8
|
function requireToken(token) {
|
|
@@ -52,11 +52,13 @@ var SandboxRuntimeClient = class extends SandboxRuntimeApi {
|
|
|
52
52
|
apiKey: auth.token,
|
|
53
53
|
timeoutMs,
|
|
54
54
|
fetchImpl,
|
|
55
|
-
timeoutError: (ms) => new TimeoutError(
|
|
55
|
+
timeoutError: (ms) => new TimeoutError(`Request timed out after ${ms}ms`, {
|
|
56
|
+
timeoutMs: ms,
|
|
56
57
|
origin: "runtime",
|
|
57
58
|
endpoint: path
|
|
58
59
|
}),
|
|
59
|
-
networkError: (error) => new NetworkError(`Scoped runtime request failed: ${path}`,
|
|
60
|
+
networkError: (error) => new NetworkError(`Scoped runtime request failed: ${path}`, {
|
|
61
|
+
cause: error instanceof Error ? error : new Error(String(error)),
|
|
60
62
|
origin: "runtime",
|
|
61
63
|
endpoint: path
|
|
62
64
|
})
|