@tangle-network/sandbox 0.60.78-develop.20261017134105.a6b32a2 → 0.60.78-develop.20261021201434.3bcd5ef
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/README.md +61 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +2 -2
- package/dist/{agent-run-outcome-CTEpjCEZ.d.ts → agent-run-outcome-brwJbH5S.d.ts} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +5 -5
- package/dist/{backend-types-D6bYbvMB.js → backend-types-CLvdSX8V.js} +41 -1
- package/dist/{browser-interactive-control-controller-rpTbyvAS.d.ts → browser-interactive-control-controller-CvObO_Kf.d.ts} +1 -1
- package/dist/{browser-interactive-control-controller-BJf0P_J4.js → browser-interactive-control-controller-DHx53yre.js} +16 -1
- package/dist/{chunked-upload-DtIvkKNo.js → chunked-upload-DN2twsUu.js} +2 -59
- package/dist/{chunked-upload-file-DnsHEjg0.js → chunked-upload-file-Dpv1YsoA.js} +2 -1
- package/dist/{cli-auth-bundle-cSJjPeFF.js → cli-auth-bundle-CFeHsq-5.js} +23 -11
- package/dist/{client-R1tw-4Px.js → client-CgtR203z.js} +3349 -3341
- package/dist/client-Dr8qasCR.d.ts +6076 -0
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-DaJU5O0E.js → collaboration-g_HzXa6f.js} +5 -5
- package/dist/core.d.ts +7 -7
- package/dist/core.js +7 -6
- package/dist/direct-http2-Dar5erTH.js +99 -0
- package/dist/{errors-DSJBKmGZ.js → errors-BfbOP_rx.js} +171 -22
- package/dist/{index-DO7GVpk_.d.ts → index-C8VSFtWl.d.ts} +1 -1
- package/dist/{index-DZ27pdB8.d.ts → index-CVjTnRWP.d.ts} +1 -1
- package/dist/{sandbox-CoIGxzm_.d.ts → index-D5dVNm76.d.ts} +2117 -1519
- package/dist/index.d.ts +12 -4704
- package/dist/index.js +40 -15
- package/dist/intelligence/index.js +1 -1
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-CJ24g8Va.js → interactive-controller-OAsASPd_.js} +662 -620
- package/dist/interactive-controller-nMhGqXxq.d.ts +41 -0
- package/dist/keep-alive-fetch-BBzJDWyt.js +247 -0
- package/dist/{lines-DodQslsf.d.ts → lines-C5CPSg8n.d.ts} +21 -17
- package/dist/lines-C5ER4aN_.js +298 -0
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -295
- package/dist/{local-cli-auth-CBV7Vjk5.js → local-cli-auth-D-CQ0-ub.js} +1 -1
- package/dist/{mcp-local-DjryqUiY.js → mcp-local-BjLG7VHY.js} +1 -1
- package/dist/{preview-wpGGk0bu.d.ts → preview-COO7TSBk.d.ts} +3 -3
- package/dist/public-templates-BDrchm0J.d.ts +80 -0
- package/dist/public-templates.d.ts +2 -0
- package/dist/public-templates.js +173 -0
- package/dist/{raw-evidence-archive-Br5a3xZ_.js → raw-evidence-archive-CDYDqHNv.js} +161 -69
- package/dist/runtime.d.ts +49 -41
- package/dist/runtime.js +8 -8
- package/dist/{sandbox-C7Tk62qn.js → sandbox-BrZxAq11.js} +9048 -8939
- package/dist/{secp256k1-Dx2XABHz.js → secp256k1-CmLpsmWl.js} +1 -1
- package/dist/session-gateway/index.d.ts +23 -67
- package/dist/session-gateway/index.js +578 -451
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-Ba4Kz5zT.js → tangle-GiPBak5X.js} +176 -169
- package/dist/terminal-stream-types-ClZCArRg.d.ts +662 -0
- package/dist/{types-B_QF-iHm.d.ts → types-CtH0GRql.d.ts} +6161 -5812
- package/package.json +11 -6
- package/dist/client-Lhxo82x1.d.ts +0 -1261
- package/dist/errors-mPL-qvgF.d.ts +0 -347
- package/dist/index-DRto9Ijb.d.ts +0 -579
- package/dist/managed-process-B7WfqKmi.d.ts +0 -15
- package/dist/terminal-stream-jdYomM1m.d.ts +0 -389
- /package/dist/{cli-auth-bundle-ODe06Ts7.d.ts → cli-auth-bundle-Dyw3hCGx.d.ts} +0 -0
- /package/dist/{line-application-Cq6dJLBD.js → line-application-DY9ZTdgF.js} +0 -0
- /package/dist/{preview-operations-DqSo-IBm.js → preview-operations-Ca02vPDJ.js} +0 -0
- /package/dist/{utils-B7_9Hl_z.js → utils-BGvM02yJ.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as CollaborationTransportConfig, a as CollaborationClient, c as CollaborationClientConfig, d as CollaborationDocumentRef, f as CollaborationFileBridgeOptions, g as CollaborationTokenRefreshResponse, h as CollaborationTokenRefreshRequest, i as parseCollaborationDocumentId, l as CollaborationDocumentAdapter, m as CollaborationPermissions, n as buildCollaborationDocumentId, o as CollaborationBootstrapRequest, p as CollaborationFileEvent, r as normalizeCollaborationPath, s as CollaborationBootstrapResponse, t as CollaborationFileBridge, u as CollaborationDocumentChange, v as SaveCollaborationSnapshotRequest, y as SaveCollaborationSnapshotResponse } from "../index-
|
|
1
|
+
import { _ as CollaborationTransportConfig, a as CollaborationClient, c as CollaborationClientConfig, d as CollaborationDocumentRef, f as CollaborationFileBridgeOptions, g as CollaborationTokenRefreshResponse, h as CollaborationTokenRefreshRequest, i as parseCollaborationDocumentId, l as CollaborationDocumentAdapter, m as CollaborationPermissions, n as buildCollaborationDocumentId, o as CollaborationBootstrapRequest, p as CollaborationFileEvent, r as normalizeCollaborationPath, s as CollaborationBootstrapResponse, t as CollaborationFileBridge, u as CollaborationDocumentChange, v as SaveCollaborationSnapshotRequest, y as SaveCollaborationSnapshotResponse } from "../index-CVjTnRWP.js";
|
|
2
2
|
export { CollaborationBootstrapRequest, CollaborationBootstrapResponse, CollaborationClient, CollaborationClientConfig, CollaborationDocumentAdapter, CollaborationDocumentChange, CollaborationDocumentRef, CollaborationFileBridge, CollaborationFileBridgeOptions, CollaborationFileEvent, CollaborationPermissions, CollaborationTokenRefreshRequest, CollaborationTokenRefreshResponse, CollaborationTransportConfig, SaveCollaborationSnapshotRequest, SaveCollaborationSnapshotResponse, buildCollaborationDocumentId, normalizeCollaborationPath, parseCollaborationDocumentId };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "../collaboration-
|
|
1
|
+
import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "../collaboration-g_HzXa6f.js";
|
|
2
2
|
export { CollaborationClient, CollaborationFileBridge, buildCollaborationDocumentId, normalizeCollaborationPath, parseCollaborationDocumentId };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as NetworkError, n as parseErrorResponse, w as TimeoutError } from "./errors-BfbOP_rx.js";
|
|
2
2
|
//#region src/collaboration/client.ts
|
|
3
3
|
const DEFAULT_TIMEOUT_MS = 3e4;
|
|
4
4
|
function normalizeBaseUrl(url) {
|
|
@@ -8,12 +8,12 @@ var CollaborationClient = class {
|
|
|
8
8
|
baseUrl;
|
|
9
9
|
timeoutMs;
|
|
10
10
|
fetchImpl;
|
|
11
|
-
headers;
|
|
11
|
+
#headers;
|
|
12
12
|
constructor(config) {
|
|
13
13
|
this.baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
14
14
|
this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
15
15
|
this.fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
16
|
-
this
|
|
16
|
+
this.#headers = config.headers;
|
|
17
17
|
}
|
|
18
18
|
async bootstrap(request) {
|
|
19
19
|
return this.requestJson("/api/collaboration/bootstrap", {
|
|
@@ -61,8 +61,8 @@ var CollaborationClient = class {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
async resolveHeaders() {
|
|
64
|
-
if (typeof this
|
|
65
|
-
return this
|
|
64
|
+
if (typeof this.#headers === "function") return this.#headers();
|
|
65
|
+
return this.#headers;
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
//#endregion
|
package/dist/core.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
1
|
+
import { B as WorkspaceImages, O as SandboxInstance, V as ProfileFileDeliveryReport, z as WorkspaceImagePublishRequestOptions } from "./index-D5dVNm76.js";
|
|
2
|
+
import { A as NotFoundError, F as SandboxError, H as TimeoutError, I as SandboxErrorJson, L as SandboxFailureDetail, M as ProfileFileMountPathError, N as QuotaError, R as ServerError, S as CapabilityError, T as FileWriteConflictError, U as ValidationError, b as AuthError, j as PartialFailureError, k as NetworkError, z as StateError } from "./terminal-stream-types-ClZCArRg.js";
|
|
3
|
+
import { Ai as ManagedProcessRecord, Ct as SessionMessageAdmission, H as PreviewLinkInfo, Ha as WorkspaceImagePublishResult, Ja as SandboxEnvRecovery, Mi as ManagedProcessSpec, Ni as ManagedProcessState, Oi as ManagedProcessJobs, U as PreviewLinkManager, Va as WorkspaceImagePublishInput, W as PreviewLinkWaitOptions, Ya as SandboxEnvRecoveryView, _r as NetworkConfig, ar as CreateSandboxOptions, dr as SandboxStatus, ei as ExecOptions, ji as ManagedProcessResumeOptions, ki as ManagedProcessOptions, nt as ConversationTurnResult, or as SandboxConfig, ti as ExecResult, tt as ConversationTurnOptions, ua as PromptInputPart, zn as SandboxInfo } from "./types-CtH0GRql.js";
|
|
4
|
+
import { D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, G as LineApplicationRequest, H as LINE_APPLICATION_REPLY_MAX_CHARS, I as LineSenderVerificationStart, J as LineApplicationView, K as LineApplicationResult, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, T as LineProvider, U as LINE_APPLICATION_REQUEST_MAX_BYTES, W as LineApplication, X as parseLineApplicationResult, Y as parseLineApplicationRequest, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, l as LineApplicationAttachOptions, o as LineAgentRolePolicy, p as LineExecutionKey, q as LineApplicationState, r as lineInstanceKey, t as LinesClient, w as LineNumberInventory, y as LineMember } from "./lines-C5CPSg8n.js";
|
|
5
|
+
import { Ct as InstancesClient, _t as EnsureInstanceOptions, an as BackendRegistryInteractionKind, bt as InstanceRecord, cn as backendRegistryEntrySchema, dn as isBackendRegistryInteractionKind, fn as parseBackendRegistryResponse, in as BackendRegistryEntry, it as ManagedProcessClient, ln as backendRegistryInteractionKindSchema, on as BackendRegistryResponse, pn as parseBackendRegistryResponseBody, rn as BackendRegistryCapabilities, sn as backendRegistryCapabilitiesSchema, t as Sandbox, un as backendRegistryResponseSchema, vt as HostedInstance, xt as InstanceRestartingError, yt as InstanceProfile } from "./client-Dr8qasCR.js";
|
|
6
|
+
import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-BDrchm0J.js";
|
|
7
7
|
|
|
8
8
|
//#region src/core.d.ts
|
|
9
9
|
/** Local SDK protocol support only, not a deployed-host readiness assertion.
|
|
@@ -12,4 +12,4 @@ import { t as ManagedProcessClient } from "./managed-process-B7WfqKmi.js";
|
|
|
12
12
|
* still inspect the host receipt and their own customer/workspace binding. */
|
|
13
13
|
declare const ISOLATED_CREATION_ATTESTATION_VERSION: 1;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { AuthError, type BackendRegistryCapabilities, type BackendRegistryEntry, type BackendRegistryInteractionKind, type BackendRegistryResponse, CapabilityError, type ConversationTurnOptions, type ConversationTurnResult, type CreateSandboxOptions, type EnsureInstanceOptions, type ExecOptions, type ExecResult, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, type InstanceProfile, type InstanceRecord, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, type Line, type LineAgentRolePolicy, type LineApplication, type LineApplicationAttachOptions, type LineApplicationRequest, type LineApplicationResult, type LineApplicationState, type LineApplicationView, type LineAttachment, type LineAttachmentReauthorization, type LineExecutionKey, type LineImage, type LineInstanceAttachOptions, type LineInstanceCreate, type LineMember, type LineMemberInstance, type LineNumberInventory, type LineProvider, type LineReminderPreferences, type LineReplyCode, type LineReplyCodeInput, type LineSendInput, type LineSendReceipt, type LineSenderVerification, type LineSenderVerificationStart, LinesClient, ManagedProcessClient, type ManagedProcessJobs, type ManagedProcessOptions, type ManagedProcessRecord, type ManagedProcessResumeOptions, type ManagedProcessSpec, type ManagedProcessState, type NetworkConfig, NetworkError, NotFoundError, PartialFailureError, type PreviewLinkInfo, type PreviewLinkManager, type PreviewLinkWaitOptions, type ProfileFileDeliveryReport, type PromptInputPart, QuotaError, Sandbox, type SandboxConfig, type SandboxEnvRecovery, type SandboxEnvRecoveryView, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, type SandboxInfo, SandboxInstance, type SandboxStatus, ServerError, type SessionMessageAdmission, StateError, TimeoutError, ValidationError, type WorkspaceImagePublishInput, type WorkspaceImagePublishRequestOptions, type WorkspaceImagePublishResult, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference };
|
|
15
|
+
export { AuthError, type BackendRegistryCapabilities, type BackendRegistryEntry, type BackendRegistryInteractionKind, type BackendRegistryResponse, CapabilityError, type ConversationTurnOptions, type ConversationTurnResult, type CreateSandboxOptions, type EnsureInstanceOptions, type ExecOptions, type ExecResult, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, type InstanceProfile, type InstanceRecord, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, type Line, type LineAgentRolePolicy, type LineApplication, type LineApplicationAttachOptions, type LineApplicationRequest, type LineApplicationResult, type LineApplicationState, type LineApplicationView, type LineAttachment, type LineAttachmentReauthorization, type LineExecutionKey, type LineImage, type LineInstanceAttachOptions, type LineInstanceCreate, type LineMember, type LineMemberInstance, type LineNumberInventory, type LineProvider, type LineReminderPreferences, type LineReplyCode, type LineReplyCodeInput, type LineSendInput, type LineSendReceipt, type LineSenderVerification, type LineSenderVerificationStart, LinesClient, ManagedProcessClient, type ManagedProcessJobs, type ManagedProcessOptions, type ManagedProcessRecord, type ManagedProcessResumeOptions, type ManagedProcessSpec, type ManagedProcessState, type NetworkConfig, NetworkError, NotFoundError, PartialFailureError, type PreviewLinkInfo, type PreviewLinkManager, type PreviewLinkWaitOptions, type ProfileFileDeliveryReport, ProfileFileMountPathError, type PromptInputPart, type PublicTemplatePublishArtifact, PublicTemplatePublishError, type PublicTemplatePublishJob, type PublicTemplatePublishRequestOptions, PublicTemplatesClient, QuotaError, Sandbox, type SandboxConfig, type SandboxEnvRecovery, type SandboxEnvRecoveryView, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, type SandboxInfo, SandboxInstance, type SandboxStatus, ServerError, type SessionMessageAdmission, StateError, TimeoutError, ValidationError, type WorkspaceImagePublishInput, type WorkspaceImagePublishRequestOptions, type WorkspaceImagePublishResult, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference };
|
package/dist/core.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as parseBackendRegistryResponse, a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { S as StateError, T as ValidationError, _ as ProfileFileMountPathError, a as AuthError, b as SandboxError, g as PartialFailureError, h as NotFoundError, m as NetworkError, s as CapabilityError, u as FileWriteConflictError, v as QuotaError, w as TimeoutError, x as ServerError } from "./errors-BfbOP_rx.js";
|
|
2
|
+
import { _ as parseBackendRegistryResponse, a as InstancesClient, f as backendRegistryCapabilitiesSchema, g as isBackendRegistryInteractionKind, h as backendRegistryResponseSchema, i as InstanceRestartingError, m as backendRegistryInteractionKindSchema, p as backendRegistryEntrySchema, r as HostedInstance, t as Sandbox, v as parseBackendRegistryResponseBody } from "./client-CgtR203z.js";
|
|
3
|
+
import { r as WorkspaceImages, t as SandboxInstance, x as ManagedProcessClient } from "./sandbox-BrZxAq11.js";
|
|
4
|
+
import { i as profileChannelReference, r as lineInstanceKey, t as LinesClient } from "./lines-C5ER4aN_.js";
|
|
5
|
+
import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
|
|
6
|
+
import { i as parseLineApplicationResult, n as LINE_APPLICATION_REQUEST_MAX_BYTES, r as parseLineApplicationRequest, t as LINE_APPLICATION_REPLY_MAX_CHARS } from "./line-application-DY9ZTdgF.js";
|
|
6
7
|
//#region src/core.ts
|
|
7
8
|
/** Local SDK protocol support only, not a deployed-host readiness assertion.
|
|
8
9
|
* Version 1 refuses unconfirmed isolated receipts before materializing any
|
|
@@ -10,4 +11,4 @@ import { i as parseLineApplicationResult, n as LINE_APPLICATION_REQUEST_MAX_BYTE
|
|
|
10
11
|
* still inspect the host receipt and their own customer/workspace binding. */
|
|
11
12
|
const ISOLATED_CREATION_ATTESTATION_VERSION = 1;
|
|
12
13
|
//#endregion
|
|
13
|
-
export { AuthError, CapabilityError, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, LinesClient, ManagedProcessClient, NetworkError, NotFoundError, PartialFailureError, QuotaError, Sandbox, SandboxError, SandboxInstance, ServerError, StateError, TimeoutError, ValidationError, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference };
|
|
14
|
+
export { AuthError, CapabilityError, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, LinesClient, ManagedProcessClient, NetworkError, NotFoundError, PartialFailureError, ProfileFileMountPathError, PublicTemplatePublishError, PublicTemplatesClient, QuotaError, Sandbox, SandboxError, SandboxInstance, ServerError, StateError, TimeoutError, ValidationError, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { t as emitTiming } from "./keep-alive-fetch-BBzJDWyt.js";
|
|
2
|
+
//#region src/lib/direct-http2.ts
|
|
3
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
4
|
+
const inFlight = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
async function fetchDirectHttp2(url, init, timing) {
|
|
6
|
+
const { connect } = await import("node:http2");
|
|
7
|
+
const { Readable } = await import("node:stream");
|
|
8
|
+
const request = new Request(url, init);
|
|
9
|
+
request.signal.throwIfAborted();
|
|
10
|
+
const target = new URL(url);
|
|
11
|
+
let session = sessions.get(target.origin);
|
|
12
|
+
const reused = !!session && !session.closed && !session.destroyed;
|
|
13
|
+
if (!session || session.closed || session.destroyed) {
|
|
14
|
+
session = connect(target.origin);
|
|
15
|
+
sessions.set(target.origin, session);
|
|
16
|
+
const opened = session;
|
|
17
|
+
const forget = () => {
|
|
18
|
+
if (sessions.get(target.origin) === opened) sessions.delete(target.origin);
|
|
19
|
+
};
|
|
20
|
+
opened.on("error", forget);
|
|
21
|
+
opened.on("close", forget);
|
|
22
|
+
opened.on("goaway", () => {
|
|
23
|
+
forget();
|
|
24
|
+
opened.close();
|
|
25
|
+
});
|
|
26
|
+
opened.setTimeout(6e4, () => opened.close());
|
|
27
|
+
opened.unref();
|
|
28
|
+
}
|
|
29
|
+
const activeSession = session;
|
|
30
|
+
const headers = {
|
|
31
|
+
":method": request.method,
|
|
32
|
+
":path": target.pathname + target.search
|
|
33
|
+
};
|
|
34
|
+
for (const [key, value] of request.headers) if (![
|
|
35
|
+
"connection",
|
|
36
|
+
"host",
|
|
37
|
+
"transfer-encoding",
|
|
38
|
+
"upgrade",
|
|
39
|
+
"keep-alive"
|
|
40
|
+
].includes(key)) headers[key] = value;
|
|
41
|
+
const started = performance.now();
|
|
42
|
+
const stream = activeSession.request(headers);
|
|
43
|
+
activeSession.ref();
|
|
44
|
+
inFlight.set(activeSession, (inFlight.get(activeSession) ?? 0) + 1);
|
|
45
|
+
stream.once("close", () => {
|
|
46
|
+
const count = (inFlight.get(activeSession) ?? 1) - 1;
|
|
47
|
+
inFlight.set(activeSession, count);
|
|
48
|
+
if (!count) activeSession.unref();
|
|
49
|
+
});
|
|
50
|
+
const abort = () => stream.destroy(request.signal.reason instanceof Error ? request.signal.reason : /* @__PURE__ */ new Error("Request aborted"));
|
|
51
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
52
|
+
stream.once("close", () => request.signal.removeEventListener("abort", abort));
|
|
53
|
+
const response = new Promise((resolve, reject) => {
|
|
54
|
+
stream.on("error", reject);
|
|
55
|
+
stream.once("response", (received) => {
|
|
56
|
+
const status = Number(received[":status"]);
|
|
57
|
+
const responseHeaders = new Headers();
|
|
58
|
+
for (const [key, value] of Object.entries(received)) {
|
|
59
|
+
if (key.startsWith(":")) continue;
|
|
60
|
+
if (Array.isArray(value)) for (const item of value) responseHeaders.append(key, item);
|
|
61
|
+
else if (value !== void 0) responseHeaders.set(key, String(value));
|
|
62
|
+
}
|
|
63
|
+
const serverTiming = responseHeaders.get("server-timing");
|
|
64
|
+
emitTiming(timing.onTiming, {
|
|
65
|
+
name: "sdk.request",
|
|
66
|
+
durMs: performance.now() - started,
|
|
67
|
+
desc: "http2",
|
|
68
|
+
method: request.method,
|
|
69
|
+
path: timing.path,
|
|
70
|
+
status,
|
|
71
|
+
socket: reused ? "reused" : "new",
|
|
72
|
+
...serverTiming ? { serverTiming } : {}
|
|
73
|
+
});
|
|
74
|
+
const noBody = request.method === "HEAD" || [
|
|
75
|
+
204,
|
|
76
|
+
205,
|
|
77
|
+
304
|
|
78
|
+
].includes(status);
|
|
79
|
+
if (noBody) stream.resume();
|
|
80
|
+
resolve(new Response(noBody ? null : Readable.toWeb(stream), {
|
|
81
|
+
status,
|
|
82
|
+
headers: responseHeaders
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
stream.once("aborted", () => reject(/* @__PURE__ */ new Error("HTTP/2 request aborted")));
|
|
86
|
+
stream.once("close", () => {
|
|
87
|
+
reject(/* @__PURE__ */ new Error(`HTTP/2 stream closed before response (${stream.rstCode})`));
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
if (request.body) {
|
|
91
|
+
const body = Readable.fromWeb(request.body);
|
|
92
|
+
body.on("error", (error) => stream.destroy(error));
|
|
93
|
+
stream.once("close", () => body.destroy());
|
|
94
|
+
body.pipe(stream);
|
|
95
|
+
} else stream.end();
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { fetchDirectHttp2 };
|
|
@@ -1,4 +1,111 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region ../../../packages/runtime-contracts/dist/file-api-roots.js
|
|
2
|
+
/**
|
|
3
|
+
* The agent user's home directory inside a sandbox. A profile mount path
|
|
4
|
+
* that starts with `~/` resolves under it.
|
|
5
|
+
*/
|
|
6
|
+
const SANDBOX_AGENT_HOME = "/home/agent";
|
|
7
|
+
/**
|
|
8
|
+
* Absolute roots that the sidecar file API accepts in addition to the
|
|
9
|
+
* workspace root. This list is the single source: the sidecar's
|
|
10
|
+
* `resolveWorkspacePath` and the SDK's profile mount routing both read it.
|
|
11
|
+
*
|
|
12
|
+
* A root in this list is not writable on every runtime:
|
|
13
|
+
* - Docker with an egress proxy has a read-only root filesystem. Only the
|
|
14
|
+
* workspace, the /tmp tmpfs and the /opt/cache volume are writable there.
|
|
15
|
+
* A write to /output or /home/user then fails deterministically.
|
|
16
|
+
* - Firecracker writes its root through a per-VM copy-on-write snapshot, and
|
|
17
|
+
* the sidecar runs as root, so every root here is writable. With
|
|
18
|
+
* FC_SHARED_ROOTFS the root is read-only, and so are /tmp and /var/tmp:
|
|
19
|
+
* fc-init mounts tmpfs only on /dev/shm.
|
|
20
|
+
*/
|
|
21
|
+
const SANDBOX_FILE_API_ABSOLUTE_ROOTS = [
|
|
22
|
+
"/tmp",
|
|
23
|
+
"/output",
|
|
24
|
+
"/home/user",
|
|
25
|
+
SANDBOX_AGENT_HOME,
|
|
26
|
+
"/opt/cache"
|
|
27
|
+
];
|
|
28
|
+
/** Stable code for a profile file mount path that the sidecar refuses. */
|
|
29
|
+
const PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE = "PROFILE_FILE_MOUNT_OUTSIDE_ROOTS";
|
|
30
|
+
/**
|
|
31
|
+
* Return true when the sidecar refuses a profile file mount path:
|
|
32
|
+
* - any path with a `.` or `..` segment, relative or absolute, because its
|
|
33
|
+
* target is not the path as written;
|
|
34
|
+
* - an absolute path outside {@link SANDBOX_FILE_API_ABSOLUTE_ROOTS}.
|
|
35
|
+
*
|
|
36
|
+
* Other relative paths resolve in the workspace, and `~/` paths resolve in
|
|
37
|
+
* the agent home, so neither is refused.
|
|
38
|
+
*/
|
|
39
|
+
function isProfileFileMountOutsideRoots(path) {
|
|
40
|
+
const segments = path.split("/").filter((segment) => segment.length > 0);
|
|
41
|
+
if (segments.some((segment) => segment === "." || segment === "..")) return true;
|
|
42
|
+
if (!path.startsWith("/")) return false;
|
|
43
|
+
const normalized = `/${segments.join("/")}`;
|
|
44
|
+
return !SANDBOX_FILE_API_ABSOLUTE_ROOTS.some((root) => normalized === root || normalized.startsWith(`${root}/`));
|
|
45
|
+
}
|
|
46
|
+
/** The refusal text for a profile file mount path that the sidecar refuses. */
|
|
47
|
+
function profileFileMountOutsideRootsMessage(path) {
|
|
48
|
+
return `Profile file mount path ${path} is outside the sandbox file roots (${SANDBOX_FILE_API_ABSOLUTE_ROOTS.join(", ")}, ~/ or a path relative to the workspace, with no . or .. segment). Mount the file under one of them.`;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region ../../../packages/runtime-contracts/dist/file-limits.js
|
|
52
|
+
const MEBIBYTE$1 = 1024 * 1024;
|
|
53
|
+
10 * MEBIBYTE$1;
|
|
54
|
+
const FILE_DECODED_WRITE_MAX_BYTES = 5 * MEBIBYTE$1;
|
|
55
|
+
5 * MEBIBYTE$1;
|
|
56
|
+
10 * MEBIBYTE$1;
|
|
57
|
+
5 * MEBIBYTE$1;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../../packages/runtime-contracts/dist/request-limits.js
|
|
60
|
+
/**
|
|
61
|
+
* Raw WIRE/TRANSPORT caps: request-byte limits checked while the body
|
|
62
|
+
* streams in (bodyLimit middleware, Content-Length, encoded proxy bodies),
|
|
63
|
+
* before anything is parsed or decoded. Rejections against these carry
|
|
64
|
+
* code `PAYLOAD_TOO_LARGE` (`payload-too-large.ts`) — the remedy is to
|
|
65
|
+
* split the delivery. Decoded/parsed-content caps (code `FILE_TOO_LARGE`)
|
|
66
|
+
* live in `file-io.ts`.
|
|
67
|
+
*/
|
|
68
|
+
const MEBIBYTE = 1024 * 1024;
|
|
69
|
+
/**
|
|
70
|
+
* Gateway (CF Worker) proxy cap on any request body it forwards — both
|
|
71
|
+
* pass-through requests and route-constructed (`options.body`) proxy
|
|
72
|
+
* payloads. Workers buffer forwarded bodies (streaming upstream stalls),
|
|
73
|
+
* so this bounds Worker memory per request.
|
|
74
|
+
*/
|
|
75
|
+
const SANDBOX_PROXY_REQUEST_MAX_BYTES = MEBIBYTE;
|
|
76
|
+
32 * MEBIBYTE;
|
|
77
|
+
/**
|
|
78
|
+
* Max assembled size of one chunked-upload session — the ceiling of the
|
|
79
|
+
* sanctioned >1 MiB delivery path. Parts stage in sidecar memory until
|
|
80
|
+
* commit, so this bounds per-session memory, not the destination
|
|
81
|
+
* filesystem.
|
|
82
|
+
*/
|
|
83
|
+
const FILE_UPLOAD_SESSION_MAX_BYTES = 64 * MEBIBYTE;
|
|
84
|
+
128 * MEBIBYTE;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region ../../../packages/runtime-contracts/dist/size-limit-errors.js
|
|
87
|
+
/** Canonical error codes for wire-size and decoded-content rejections. */
|
|
88
|
+
const PAYLOAD_TOO_LARGE_CODE = "PAYLOAD_TOO_LARGE";
|
|
89
|
+
const FILE_TOO_LARGE_CODE = "FILE_TOO_LARGE";
|
|
90
|
+
function isRecord(value) {
|
|
91
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
92
|
+
}
|
|
93
|
+
function isPositiveInteger(value) {
|
|
94
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
95
|
+
}
|
|
96
|
+
function isSizeLimitErrorBodyFor(value, code) {
|
|
97
|
+
if (!isRecord(value) || value.success !== false || !isRecord(value.error)) return false;
|
|
98
|
+
const error = value.error;
|
|
99
|
+
return error.code === code && typeof error.message === "string" && typeof error.surface === "string" && isPositiveInteger(error.limitBytes) && (error.actualBytes === void 0 || isPositiveInteger(error.actualBytes));
|
|
100
|
+
}
|
|
101
|
+
function isPayloadTooLargeErrorBody(value) {
|
|
102
|
+
return isSizeLimitErrorBodyFor(value, PAYLOAD_TOO_LARGE_CODE);
|
|
103
|
+
}
|
|
104
|
+
function isFileTooLargeErrorBody(value) {
|
|
105
|
+
return isSizeLimitErrorBodyFor(value, FILE_TOO_LARGE_CODE);
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/error-classes.ts
|
|
2
109
|
/**
|
|
3
110
|
* Base error class for all Sandbox SDK errors.
|
|
4
111
|
*/
|
|
@@ -98,12 +205,6 @@ const NON_RETRYABLE_CREATE_QUOTA_REASONS = new Set([
|
|
|
98
205
|
"CREDIT_EXHAUSTED",
|
|
99
206
|
"EGRESS_LIMIT"
|
|
100
207
|
]);
|
|
101
|
-
function quotaTypeFromResponse(data, reason) {
|
|
102
|
-
const normalizedReason = reason?.trim().toUpperCase();
|
|
103
|
-
if (normalizedReason && NON_RETRYABLE_CREATE_QUOTA_REASONS.has(normalizedReason)) return normalizedReason;
|
|
104
|
-
if (typeof data.quotaType === "string" && data.quotaType.trim()) return data.quotaType;
|
|
105
|
-
return "rate_limit";
|
|
106
|
-
}
|
|
107
208
|
/**
|
|
108
209
|
* The requested capability is unavailable for the account, driver, or sandbox.
|
|
109
210
|
*/
|
|
@@ -130,20 +231,6 @@ var GpuProviderNotConfiguredError = class extends CapabilityError {
|
|
|
130
231
|
this.providers = providers;
|
|
131
232
|
}
|
|
132
233
|
};
|
|
133
|
-
function readGpuProviderRequirements(data) {
|
|
134
|
-
return (Array.isArray(data.providers) ? data.providers : []).flatMap((entry) => {
|
|
135
|
-
if (!isFailureDetail(entry)) return [];
|
|
136
|
-
const provider = asString(entry.provider);
|
|
137
|
-
const state = asString(entry.state);
|
|
138
|
-
const envVars = Array.isArray(entry.envVars) ? entry.envVars : [];
|
|
139
|
-
if (!provider || !state) return [];
|
|
140
|
-
return [{
|
|
141
|
-
provider,
|
|
142
|
-
state,
|
|
143
|
-
envVars: envVars.filter((name) => typeof name === "string")
|
|
144
|
-
}];
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
234
|
/**
|
|
148
235
|
* A multi-resource operation failed for one or more branches.
|
|
149
236
|
*/
|
|
@@ -181,6 +268,22 @@ var ValidationError = class extends SandboxError {
|
|
|
181
268
|
}
|
|
182
269
|
};
|
|
183
270
|
/**
|
|
271
|
+
* A profile file mount names a path that the sidecar file API refuses: an
|
|
272
|
+
* absolute path outside `SANDBOX_FILE_API_ABSOLUTE_ROOTS`. create() throws it
|
|
273
|
+
* before it provisions a sandbox, and a turn throws it before any write. The
|
|
274
|
+
* status is 422 and the code is `PROFILE_FILE_MOUNT_OUTSIDE_ROOTS`: a retry
|
|
275
|
+
* with the same profile gets the same refusal.
|
|
276
|
+
*/
|
|
277
|
+
var ProfileFileMountPathError = class extends SandboxError {
|
|
278
|
+
/** The refused mount path, exactly as the profile gave it. */
|
|
279
|
+
path;
|
|
280
|
+
constructor(path, message, code, metadata) {
|
|
281
|
+
super(message, code, 422, metadata);
|
|
282
|
+
this.name = "ProfileFileMountPathError";
|
|
283
|
+
this.path = path;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
184
287
|
* The sandbox is not in a valid state for the requested operation.
|
|
185
288
|
*/
|
|
186
289
|
var StateError = class extends SandboxError {
|
|
@@ -388,6 +491,33 @@ var ServerError = class extends SandboxError {
|
|
|
388
491
|
this.name = "ServerError";
|
|
389
492
|
}
|
|
390
493
|
};
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/errors.ts
|
|
496
|
+
/**
|
|
497
|
+
* Sandbox SDK Errors
|
|
498
|
+
*
|
|
499
|
+
* Error classes for the Sandbox client SDK.
|
|
500
|
+
*/
|
|
501
|
+
function quotaTypeFromResponse(data, reason) {
|
|
502
|
+
const normalizedReason = reason?.trim().toUpperCase();
|
|
503
|
+
if (normalizedReason && NON_RETRYABLE_CREATE_QUOTA_REASONS.has(normalizedReason)) return normalizedReason;
|
|
504
|
+
if (typeof data.quotaType === "string" && data.quotaType.trim()) return data.quotaType;
|
|
505
|
+
return "rate_limit";
|
|
506
|
+
}
|
|
507
|
+
function readGpuProviderRequirements(data) {
|
|
508
|
+
return (Array.isArray(data.providers) ? data.providers : []).flatMap((entry) => {
|
|
509
|
+
if (!isFailureDetail(entry)) return [];
|
|
510
|
+
const provider = asString(entry.provider);
|
|
511
|
+
const state = asString(entry.state);
|
|
512
|
+
const envVars = Array.isArray(entry.envVars) ? entry.envVars : [];
|
|
513
|
+
if (!provider || !state) return [];
|
|
514
|
+
return [{
|
|
515
|
+
provider,
|
|
516
|
+
state,
|
|
517
|
+
envVars: envVars.filter((name) => typeof name === "string")
|
|
518
|
+
}];
|
|
519
|
+
});
|
|
520
|
+
}
|
|
391
521
|
function parseRetryAfterMs(rawValue, data) {
|
|
392
522
|
if (typeof data.retryAfterMs === "number" && Number.isFinite(data.retryAfterMs)) return Math.max(0, data.retryAfterMs);
|
|
393
523
|
if (!rawValue) return void 0;
|
|
@@ -520,6 +650,7 @@ function parseErrorResponse(status, body, context, headers) {
|
|
|
520
650
|
if (isCapabilityCode(code)) return new CapabilityError(message, code, status, metadata, readCapability(data, errorObj));
|
|
521
651
|
if (isPartialFailureCode(code)) return new PartialFailureError(message, code, status, metadata, readFailures(data, errorObj));
|
|
522
652
|
if (code === "EGRESS_PROXY_RECOVERY_REQUIRED") return new EgressProxyRecoveryError(message, metadata);
|
|
653
|
+
if (code === "PROFILE_FILE_MOUNT_OUTSIDE_ROOTS" && typeof data.path === "string") return new ProfileFileMountPathError(data.path, message, code, metadata);
|
|
523
654
|
if (code === "RESUME_ENV_REQUIRED") {
|
|
524
655
|
const keys = data.missingEnvKeys;
|
|
525
656
|
return new ResumeEnvRequiredError(message, Array.isArray(keys) ? keys.filter((key) => typeof key === "string") : [], metadata);
|
|
@@ -562,5 +693,23 @@ function readResponseJson(response) {
|
|
|
562
693
|
throw error;
|
|
563
694
|
});
|
|
564
695
|
}
|
|
696
|
+
/** A protocol `error` control frame or a transport failure. */
|
|
697
|
+
var TerminalStreamError = class extends Error {
|
|
698
|
+
/** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
|
|
699
|
+
code;
|
|
700
|
+
/**
|
|
701
|
+
* True when the socket never reached OPEN: the upgrade was refused (a
|
|
702
|
+
* WebSocket client cannot read the HTTP status, so a 401 and a network drop
|
|
703
|
+
* look alike) or the runtime rejected the dial's options. No PTY work had
|
|
704
|
+
* started on the client's side of that dial.
|
|
705
|
+
*/
|
|
706
|
+
beforeOpen;
|
|
707
|
+
constructor(message, code, options = {}) {
|
|
708
|
+
super(message);
|
|
709
|
+
this.name = "TerminalStreamError";
|
|
710
|
+
this.code = code;
|
|
711
|
+
this.beforeOpen = options.beforeOpen === true;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
565
714
|
//#endregion
|
|
566
|
-
export {
|
|
715
|
+
export { FILE_DECODED_WRITE_MAX_BYTES as A, StreamInterruptedError as C, isPayloadTooLargeErrorBody as D, isFileTooLargeErrorBody as E, profileFileMountOutsideRootsMessage as F, SANDBOX_AGENT_HOME as M, SANDBOX_FILE_API_ABSOLUTE_ROOTS as N, FILE_UPLOAD_SESSION_MAX_BYTES as O, isProfileFileMountOutsideRoots as P, StateError as S, ValidationError as T, ProfileFileMountPathError as _, AuthError as a, SandboxError as b, EdgeNotReadyError as c, GpuProviderNotConfiguredError as d, KeyBudgetExhaustedError as f, PartialFailureError as g, NotFoundError as h, readResponseJson as i, PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE as j, SANDBOX_PROXY_REQUEST_MAX_BYTES as k, EgressProxyRecoveryError as l, NetworkError as m, parseErrorResponse as n, BranchFanoutExceedsHostError as o, NON_RETRYABLE_CREATE_QUOTA_REASONS as p, parseResponseError as r, CapabilityError as s, TerminalStreamError as t, FileWriteConflictError as u, QuotaError as v, TimeoutError as w, ServerError as x, ResumeEnvRequiredError as y };
|
|
@@ -172,8 +172,8 @@ declare function isTokenExpiringSoon(payload: AnyTokenPayload, bufferSeconds?: n
|
|
|
172
172
|
* Use this in your backend to issue read tokens for WebSocket connections.
|
|
173
173
|
*/
|
|
174
174
|
declare class ProductTokenIssuer {
|
|
175
|
+
#private;
|
|
175
176
|
private readonly productId;
|
|
176
|
-
private readonly signingSecret;
|
|
177
177
|
private readonly ttlMinutes;
|
|
178
178
|
constructor(config: {
|
|
179
179
|
productId: string;
|
|
@@ -91,10 +91,10 @@ interface CollaborationClientConfig {
|
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/collaboration/client.d.ts
|
|
93
93
|
declare class CollaborationClient {
|
|
94
|
+
#private;
|
|
94
95
|
private readonly baseUrl;
|
|
95
96
|
private readonly timeoutMs;
|
|
96
97
|
private readonly fetchImpl;
|
|
97
|
-
private readonly headers?;
|
|
98
98
|
constructor(config: CollaborationClientConfig);
|
|
99
99
|
bootstrap(request: CollaborationBootstrapRequest): Promise<CollaborationBootstrapResponse>;
|
|
100
100
|
refreshToken(request: CollaborationTokenRefreshRequest): Promise<CollaborationTokenRefreshResponse>;
|