@tangle-network/sandbox 0.60.61 → 0.60.74

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.
Files changed (47) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +4 -4
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/{agent-run-outcome-jmKaXys4.d.ts → agent-run-outcome-eZF8RuUN.d.ts} +1 -1
  5. package/dist/auth/index.d.ts +1 -1
  6. package/dist/auth/index.js +1 -1
  7. package/dist/backend-types-D6bYbvMB.js +42 -0
  8. package/dist/{browser-interactive-control-controller-JUW3gOGH.d.ts → browser-interactive-control-controller-rpTbyvAS.d.ts} +1 -1
  9. package/dist/{chunked-upload-BklCn3Li.js → chunked-upload-CDrLMO8N.js} +1 -1
  10. package/dist/{chunked-upload-file-Cp-iWsWN.js → chunked-upload-file-BwbqHWUX.js} +1 -1
  11. package/dist/cli-auth-bundle-cSJjPeFF.js +1543 -0
  12. package/dist/{client-4G99U4L2.d.ts → client-BujziOIc.d.ts} +10 -6
  13. package/dist/{client-BuWj2tMd.js → client-C7Y6waVg.js} +29 -10
  14. package/dist/collaboration/index.d.ts +1 -1
  15. package/dist/collaboration/index.js +1 -1
  16. package/dist/{collaboration-B2g1j2ey.js → collaboration-CTbq2OYh.js} +1 -1
  17. package/dist/core.d.ts +7 -7
  18. package/dist/core.js +3 -3
  19. package/dist/{errors-CBy-dqOv.d.ts → errors-Bj5DL2ge.d.ts} +61 -2
  20. package/dist/{errors-iWIsey1D.js → errors-C8YcR1BL.js} +31 -1
  21. package/dist/{index-ClxFpHIl.d.ts → index-CP9a77KP.d.ts} +2 -2
  22. package/dist/index.d.ts +14 -15
  23. package/dist/index.js +9 -9
  24. package/dist/intelligence/index.js +1 -1
  25. package/dist/interactive-control.d.ts +1 -1
  26. package/dist/{interactive-controller-DaYmUCO_.js → interactive-controller-BFbCkMq4.js} +213 -21
  27. package/dist/{lines-Bm8NULkl.d.ts → lines-_rRdwxof.d.ts} +10 -2
  28. package/dist/lines.d.ts +2 -2
  29. package/dist/lines.js +1 -1
  30. package/dist/{local-cli-auth-CZjO7FeG.js → local-cli-auth-CBV7Vjk5.js} +1 -1
  31. package/dist/{managed-process-Ddx8dULu.d.ts → managed-process-CPHeQONO.d.ts} +1 -1
  32. package/dist/{preview-DqKY0kxQ.d.ts → preview-n41aOXde.d.ts} +3 -3
  33. package/dist/runtime.d.ts +5 -6
  34. package/dist/runtime.js +3 -3
  35. package/dist/{sandbox-C6BLOrcg.js → sandbox-DGoQMthD.js} +678 -69
  36. package/dist/{sandbox-CIK4LMS-.d.ts → sandbox-DfSqEr3f.d.ts} +70 -17
  37. package/dist/tangle/index.d.ts +1 -1
  38. package/dist/tangle/index.js +1 -1
  39. package/dist/{tangle-CvB_QTGV.js → tangle-vyeLQFFg.js} +2 -2
  40. package/dist/{terminal-stream-CV1pMSKC.d.ts → terminal-stream-jdYomM1m.d.ts} +123 -4
  41. package/dist/{types-CS_FytQM.d.ts → types-Mi83KD0D.d.ts} +194 -21
  42. package/package.json +5 -5
  43. package/dist/backend-types-C7b_Gpa0.js +0 -59
  44. package/dist/cli-auth-bundle-BWNakb5F.js +0 -1007
  45. package/dist/interactive-controller-DNbLzamS.d.ts +0 -40
  46. /package/dist/{index-BgmgfYZZ.d.ts → index-DO7GVpk_.d.ts} +0 -0
  47. /package/dist/{index-DHuHjNie.d.ts → index-DZ27pdB8.d.ts} +0 -0
@@ -1,11 +1,11 @@
1
1
  import { t as CliAuthReference } from "./cli-auth-bundle-ODe06Ts7.js";
2
- import { $a as InteractionResolutionAcknowledgement, $i as SessionInterruptOptions, $n as PromptOptions, A as CommitTaskSessionOptions, Ba as WriteManyFile, Bi as SearchOptions, Bn as PermissionsManager, C as BranchOptions, Ci as SandboxRuntimeHealth, Cn as ListMessagesOptions, D as CodeExecutionResult, Di as SandboxStatus, Dr as SandboxConnection, E as CodeExecutionOptions, Ea as TeeAttestationResponse, Et as FileSystem, Ga as SandboxEnvRecoveryView, Gi as SentSessionMessage, H as CreateTaskSessionOptions, Hn as PreviewLinkManager, Ia as WaitForOptions, Ja as RawEvidenceExportOptions, Ji as SessionExecutionInfo, Jn as ProcessManager, La as WaitForRolloutOptions, Li as SandboxTraceOptions, Ln as NetworkManager, M as ConversationTurnOptions, Mt as FileWriteResult, N as ConversationTurnResult, Ni as SandboxTerminals, Nr as SandboxEvent, O as CodeLanguage, Oa as TeePublicKeyResponse, Oi as SandboxTerminalAttachOptions, Or as SandboxDeleteAcknowledgement, Pi as SandboxTraceBundle, Q as DispatchedSession, Qa as WorkspaceImagePublishResult$1, Qi as SessionInfo, Qn as PromptInputPart, Qt as ForkLookupOptions, Ra as WorkspaceOperationLookup, Sa as TaskSessionInfo, Si as SandboxRuntimeCapabilities, Sn as JsonValue, Tr as SSHCredentials, Ua as SandboxCreateReceipt, Ui as SendSessionMessageOptions, V as CreateSessionOptions, Va as WriteManyOptions, Wa as SandboxEnvRecovery, Wi as SendSessionMessageRequest, Xt as ForkCounts, Z as DispatchPromptOptions, Zi as SessionForkOptions, Zt as ForkIdempotency, _n as IntelligenceReport, _r as Rollout, an as GitStatus, ar as PublicProfileConflict, ba as TaskSessionCommitResult, d as BackendConfig, da as SnapshotProvenance, dn as GpuLeaseManager, ea as SessionListOptions, er as PromptResult, gi as SandboxPortBinding, gn as InstalledTool, gr as ResumeOptions, gt as EventStreamOptions, ha as StartupDiagnostics, hr as RestoreSnapshotOptions, ia as SessionResultOptions, ii as SandboxFleetTraceBundle, in as GitDiff, it as DriverInfo, j as CompletedTurnResult, ja as TurnDriveResult, kr as SandboxDeleteOptions, la as SnapshotInfo, mi as SandboxInfo, na as SessionMessageAdmission, nn as GitCommit, nr as ProvisionResult, nt as DriveTurnOptions, oa as SnapshotDeleteAcknowledgement, on as GpuLease, ot as DurablePlan, p as BackendManager, pa as SnapshotResult, pt as EgressManager, qa as RawEvidenceDirectoryExport, qi as SessionEventStreamOptions, st as DurablePlanDecisionResult, ta as SessionMessage, tn as GitBranch, tr as ProvisionEvent, ua as SnapshotOptions, vn as IntelligenceReportBudget, vt as ExecOptions, wa as TeeAttestationOptions, wi as SandboxShape, wr as SSHCommandDescriptor, xn as IntelligenceReportWindow, xr as RolloutStartResult, ya as TaskSessionChanges, yi as SandboxResourceUsage, yn as IntelligenceReportCompareTo, yr as RolloutOptions, yt as ExecResult, za as WriteFileOptions, zi as SearchMatch } from "./types-CS_FytQM.js";
3
- import { a as TerminalStreamReconnectAuthority, c as MintScopedTokenOptions, h as TerminalReadyInfo, l as ScopedToken, r as TerminalStreamHandlers, t as TerminalStream } from "./terminal-stream-CV1pMSKC.js";
4
- import { f as InteractiveAttachOptions, g as InteractiveSessionStatus, h as InteractiveRequestOptions, m as InteractiveControlClaimOptions, p as InteractiveControlClaimAcknowledgement } from "./browser-interactive-control-controller-JUW3gOGH.js";
5
- import { r as InteractiveAttachRequest } from "./interactive-controller-DNbLzamS.js";
6
- import { R as SandboxLines } from "./lines-Bm8NULkl.js";
7
- import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentInteractiveTerminalSession, AgentInteractiveTerminalSession as AgentInteractiveTerminalSession$1, AgentProfile, AgentProfileFileMount, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand, TerminalOutputEvent, TerminalReplayWindow, agentInteractiveSessionPromptRequestDigest } from "@tangle-network/agent-interface";
2
+ import { $a as RawEvidenceDirectoryExport, $n as PromptInputPart, A as CommitTaskSessionOptions, Ar as SandboxDeleteOptions, C as BranchOptions, Ci as SandboxResourceUsage, Cn as JsonValue, D as CodeExecutionResult, Da as TaskSessionInfo, Di as SandboxRuntimeHealth, E as CodeExecutionOptions, Ei as SandboxRuntimeCapabilities, Er as SSHCredentials, Et as FileSystem, Ga as WriteManyFile, H as CreateTaskSessionOptions, Ha as WaitForRolloutOptions, Ia as TurnDriveResult, Ji as SendSessionMessageRequest, Ka as WriteManyOptions, Li as SandboxTerminals, M as ConversationTurnOptions, Mi as SandboxTerminalAttachOptions, Mt as FileWriteResult, N as ConversationTurnResult, Na as TeePublicKeyResponse, O as CodeLanguage, Oi as SandboxShape, Or as SandboxConnection, Pr as SandboxEvent, Q as DispatchedSession, Qi as SessionExecutionInfo, Qt as ForkLookupOptions, Ri as SandboxTraceBundle, Rn as NetworkManager, Sn as IntelligenceReportWindow, Sr as RolloutStartResult, Ta as TaskSessionCommitResult, Tr as SSHCommandDescriptor, Ua as WorkspaceOperationLookup, Ui as SearchMatch, Un as PreviewLinkManager, V as CreateSessionOptions, Va as WaitForOptions, Vi as SandboxTraceOptions, Vn as PermissionsManager, Wa as WriteFileOptions, Wi as SearchOptions, Xa as SandboxEnvRecovery, Xt as ForkCounts, Ya as SandboxCreateReceipt, Yi as SentSessionMessage, Yn as ProcessManager, Z as DispatchPromptOptions, Za as SandboxEnvRecoveryView, Zi as SessionEventStreamOptions, Zt as ForkIdempotency, _a as SnapshotResult, _i as SandboxOperationInfo, _n as InstalledTool, _r as ResumeOptions, aa as SessionMessage, ai as SandboxFleetTraceBundle, an as GitStatus, ao as InteractionResolutionAcknowledgement, bi as SandboxPortBinding, bn as IntelligenceReportCompareTo, br as RolloutOptions, ca as SessionResultOptions, d as BackendConfig, dn as GpuLeaseManager, eo as RawEvidenceExportOptions, er as PromptOptions, gn as HttpClient, gr as RestoreSnapshotOptions, gt as EventStreamOptions, ha as SnapshotProvenance, hi as SandboxInfo, ia as SessionListOptions, in as GitDiff, io as WorkspaceImagePublishResult$1, it as DriverInfo, j as CompletedTurnResult, ja as TeeAttestationResponse, ji as SandboxStatus, ka as TeeAttestationOptions, kr as SandboxDeleteAcknowledgement, ma as SnapshotOptions, na as SessionInfo, nn as GitCommit, nr as ProvisionEvent, nt as DriveTurnOptions, oa as SessionMessageAdmission, on as GpuLease, or as PublicProfileConflict, ot as DurablePlan, p as BackendManager, pa as SnapshotInfo, pt as EgressManager, qi as SendSessionMessageOptions, ra as SessionInterruptOptions, rr as ProvisionResult, st as DurablePlanDecisionResult, ta as SessionForkOptions, tn as GitBranch, tr as PromptResult, ua as SnapshotDeleteAcknowledgement, vi as SandboxOperationKind, vn as IntelligenceReport, vr as Rollout, vt as ExecOptions, wa as TaskSessionChanges, wn as ListMessagesOptions, xa as StopOptions, ya as StartupDiagnostics, yi as SandboxOperationState, yn as IntelligenceReportBudget, yt as ExecResult } from "./types-Mi83KD0D.js";
3
+ import { c as TerminalStreamReconnectAuthority, f as MintScopedTokenOptions, n as TerminalStream, o as TerminalStreamHandlers, p as ScopedToken, y as TerminalReadyInfo } from "./terminal-stream-jdYomM1m.js";
4
+ import { f as InteractiveAttachOptions, g as InteractiveSessionStatus, h as InteractiveRequestOptions, m as InteractiveControlClaimOptions, p as InteractiveControlClaimAcknowledgement } from "./browser-interactive-control-controller-rpTbyvAS.js";
5
+ import { p as SandboxError, w as InteractiveAttachRequest } from "./errors-Bj5DL2ge.js";
6
+ import { z as SandboxLines } from "./lines-_rRdwxof.js";
8
7
  import { z } from "zod";
8
+ import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentInteractiveTerminalSession, AgentInteractiveTerminalSession as AgentInteractiveTerminalSession$1, AgentProfile, AgentProfileFileMount, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand, TerminalOutputEvent, TerminalReplayWindow, agentInteractiveSessionPromptRequestDigest } from "@tangle-network/agent-interface";
9
9
 
10
10
  //#region src/mcp.d.ts
11
11
  /**
@@ -332,6 +332,38 @@ declare class InteractiveSessionHandle {
332
332
  stopLifecycle(options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
333
333
  }
334
334
  //#endregion
335
+ //#region src/operation.d.ts
336
+ /** An accepted operation ended in failure. `code` names why. */
337
+ declare class SandboxOperationFailedError extends SandboxError {
338
+ readonly operation: SandboxOperationInfo;
339
+ constructor(operation: SandboxOperationInfo);
340
+ }
341
+ declare class SandboxOperation {
342
+ #private;
343
+ /**
344
+ * @param client - null for a verb that already finished synchronously.
345
+ * @param onSettled - runs once when the operation is first seen succeeded.
346
+ */
347
+ constructor(info: SandboxOperationInfo, client: HttpClient | null, onSettled?: (info: SandboxOperationInfo) => void | Promise<void>);
348
+ /** A verb the API finished synchronously, as a succeeded operation. */
349
+ static completed(kind: SandboxOperationKind, sandboxId: string, result?: SandboxOperationInfo["result"]): SandboxOperation;
350
+ get id(): string;
351
+ get state(): SandboxOperationState;
352
+ /** The last state read. */
353
+ get info(): SandboxOperationInfo;
354
+ /** Read the operation's current state. */
355
+ refresh(): Promise<SandboxOperationInfo>;
356
+ /**
357
+ * Poll until the operation is terminal (250 ms, doubling to 2 s). Resolves
358
+ * with a succeeded operation; throws {@link SandboxOperationFailedError} on
359
+ * a failed one and {@link TimeoutError} past `timeoutMs` (default 10 min).
360
+ */
361
+ wait(options?: {
362
+ timeoutMs?: number;
363
+ signal?: AbortSignal;
364
+ }): Promise<SandboxOperationInfo>;
365
+ }
366
+ //#endregion
335
367
  //#region src/profile-file-mounts.d.ts
336
368
  interface SplitInlineProfileFileMountsResult {
337
369
  leanProfile: AgentProfile;
@@ -778,15 +810,6 @@ interface SessionMappingResult {
778
810
  reprovisionRequired: boolean;
779
811
  code?: string;
780
812
  }
781
- /**
782
- * HTTP client interface for making requests.
783
- */
784
- interface HttpClient {
785
- fetch(path: string, options?: RequestInit, fetchOptions?: {
786
- timeoutMs?: number;
787
- }): Promise<Response>;
788
- getApiKey?(): string | undefined;
789
- }
790
813
  /**
791
814
  * Git capability for repository operations.
792
815
  */
@@ -848,6 +871,7 @@ interface ForkAcknowledgement extends ForkCounts {
848
871
  * A sandbox instance with methods for interaction.
849
872
  */
850
873
  declare class SandboxInstance {
874
+ #private;
851
875
  private readonly client;
852
876
  private info;
853
877
  private refreshInFlight?;
@@ -1015,7 +1039,9 @@ declare class SandboxInstance {
1015
1039
  * Refresh sandbox information from the server.
1016
1040
  */
1017
1041
  refresh(signal?: AbortSignal): Promise<void>;
1042
+ private refreshFor;
1018
1043
  private refreshInfo;
1044
+ private readStatus;
1019
1045
  /**
1020
1046
  * What the direct regional read route has done for this sandbox: attempts,
1021
1047
  * reads it served, reads that fell back to the API, and the last reason.
@@ -1770,6 +1796,9 @@ declare class SandboxInstance {
1770
1796
  format: string;
1771
1797
  content: string;
1772
1798
  }>>;
1799
+ snapshot(options: SnapshotOptions & {
1800
+ wait: false;
1801
+ }): Promise<SandboxOperation>;
1773
1802
  snapshot(options?: SnapshotOptions): Promise<SnapshotResult>;
1774
1803
  /**
1775
1804
  * List all snapshots for this sandbox.
@@ -1949,6 +1978,18 @@ declare class SandboxInstance {
1949
1978
  * returns it (replacing the create breakdown).
1950
1979
  */
1951
1980
  stop(): Promise<void>;
1981
+ /**
1982
+ * With `wait: false`, answers as soon as the stop is durably accepted and
1983
+ * returns the {@link SandboxOperation}; `await op.wait()` resolves once the
1984
+ * sandbox is stopped. A stop the API finished synchronously comes back as an
1985
+ * operation that is already `succeeded`.
1986
+ */
1987
+ stop(options: StopOptions & {
1988
+ wait: false;
1989
+ }): Promise<SandboxOperation>;
1990
+ stop(options?: StopOptions): Promise<void>;
1991
+ /** Read an operation a `wait: false` stop or snapshot of this sandbox returned. */
1992
+ getOperation(operationId: string): Promise<SandboxOperation>;
1952
1993
  /** Read credential recovery metadata without changing sandbox lifecycle. */
1953
1994
  getEnvRecovery(): Promise<SandboxEnvRecoveryView>;
1954
1995
  /** Replace a stopped sandbox's policy, or inspect a proposed change with dryRun. */
@@ -2032,8 +2073,20 @@ declare class SandboxInstance {
2032
2073
  */
2033
2074
  private consumerConnectionReady;
2034
2075
  private hasFreshStatus;
2076
+ /**
2077
+ * The check before a runtime call. A handle that has seen the sandbox
2078
+ * running and ready dispatches at once: the authenticated runtime route
2079
+ * checks current sandbox state itself, so a status GET before every call was
2080
+ * a whole round trip through the Worker that only moved the same refusal
2081
+ * earlier. A stale cache surfaces as the call's own answer, which the
2082
+ * direct client and the prompt stream turn into a typed `StateError`. A
2083
+ * handle that has not seen the status, or saw one that is not runnable,
2084
+ * reads it first.
2085
+ */
2035
2086
  private ensureRunning;
2036
- private ensureRunningForPrompt;
2087
+ /** Why the status must be read before a runtime call, or undefined to trust the cache. */
2088
+ private statusReadReason;
2089
+ private assertRunnable;
2037
2090
  private assertFilesystemIncarnationReady;
2038
2091
  /**
2039
2092
  * One authenticated runtime HTTP call for this sandbox, relative endpoint
@@ -2347,4 +2400,4 @@ declare class SandboxInstance {
2347
2400
  }): Promise<DurablePlanDecisionResult>;
2348
2401
  }
2349
2402
  //#endregion
2350
- export { BuildSandboxMcpConfigOptions as $, InteractiveSessionControlClaim as A, InterruptResult as B, materializeProfileFileMounts as C, AgentInteractiveTerminalSession$1 as D, validateDeferredProfileFileMounts as E, InteractiveSessionInfo as F, InteractiveTerminalMetadata as G, agentInteractiveSessionPromptRequestDigest as H, InteractiveSessionRef as I, SandboxInteractionCommandResult as J, createInteractiveTerminalCapture as K, InteractiveSessionStartOptions as L, InteractiveSessionHandleOptions as M, InteractiveSessionHost as N, InteractiveControlClaimRequest as O, InteractiveSessionIncarnationId as P, BuildControlPlaneMcpConfigOptions as Q, InteractiveSessionStartResult as R, SplitInlineProfileSkillsResult as S, splitInlineProfileSkills as T, InteractiveTerminalCapture as U, RespondToPermissionOptions as V, InteractiveTerminalFrameLog as W, SandboxInteractionResolution as X, SandboxInteractionConflict as Y, SandboxInteractionResult as Z, SandboxSession as _, WorkspaceImagePublishRequestOptions as a, buildControlPlaneMcpConfig as at, MaterializeProfileFileMountsResult as b, TraceExportFormat as c, buildTraceExportPayload as d, CONTROL_PLANE_MCP_SERVER_NAME as et, exportTraceBundle as f, RawEvidenceExport as g, SandboxTaskSession as h, WorkspaceImagePublishInput as i, SandboxMcpServerEntry as it, InteractiveSessionHandle as j, InteractivePromptCommand as k, TraceExportResult as l, toOtelJson as m, HttpClient as n, SandboxMcpConfig as nt, WorkspaceImagePublishResult as o, buildSandboxMcpConfig as ot, otelTraceIdForTangleTrace as p, createInteractiveTerminalSession as q, SandboxInstance as r, SandboxMcpEndpoint as rt, WorkspaceImages as s, ForkAcknowledgement as t, SANDBOX_MCP_SERVER_NAME as tt, TraceExportSink as u, ProfileFileDeliveryReport as v, splitInlineProfileFileMounts as w, SplitInlineProfileFileMountsResult as x, MaterializeProfileFileMountsOptions as y, InteractiveStopCommand as z };
2403
+ export { BuildControlPlaneMcpConfigOptions as $, InteractivePromptCommand as A, InteractiveStopCommand as B, splitInlineProfileFileMounts as C, SandboxOperationFailedError as D, SandboxOperation as E, InteractiveSessionIncarnationId as F, InteractiveTerminalFrameLog as G, RespondToPermissionOptions as H, InteractiveSessionInfo as I, createInteractiveTerminalSession as J, InteractiveTerminalMetadata as K, InteractiveSessionRef as L, InteractiveSessionHandle as M, InteractiveSessionHandleOptions as N, AgentInteractiveTerminalSession$1 as O, InteractiveSessionHost as P, SandboxInteractionResult as Q, InteractiveSessionStartOptions as R, materializeProfileFileMounts as S, validateDeferredProfileFileMounts as T, agentInteractiveSessionPromptRequestDigest as U, InterruptResult as V, InteractiveTerminalCapture as W, SandboxInteractionConflict as X, SandboxInteractionCommandResult as Y, SandboxInteractionResolution as Z, ProfileFileDeliveryReport as _, WorkspaceImagePublishResult as a, SandboxMcpServerEntry as at, SplitInlineProfileFileMountsResult as b, TraceExportResult as c, exportTraceBundle as d, BuildSandboxMcpConfigOptions as et, otelTraceIdForTangleTrace as f, SandboxSession as g, RawEvidenceExport as h, WorkspaceImagePublishRequestOptions as i, SandboxMcpEndpoint as it, InteractiveSessionControlClaim as j, InteractiveControlClaimRequest as k, TraceExportSink as l, SandboxTaskSession as m, SandboxInstance as n, SANDBOX_MCP_SERVER_NAME as nt, WorkspaceImages as o, buildControlPlaneMcpConfig as ot, toOtelJson as p, createInteractiveTerminalCapture as q, WorkspaceImagePublishInput as r, SandboxMcpConfig as rt, TraceExportFormat as s, buildSandboxMcpConfig as st, ForkAcknowledgement as t, CONTROL_PLANE_MCP_SERVER_NAME as tt, buildTraceExportPayload as u, MaterializeProfileFileMountsOptions as v, splitInlineProfileSkills as w, SplitInlineProfileSkillsResult as x, MaterializeProfileFileMountsResult as y, InteractiveSessionStartResult as z };
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-ClxFpHIl.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-CP9a77KP.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JobQuoteDetails, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, QuoteDomain, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, SignedQuote, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, TangleSandboxClientConfig, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-CvB_QTGV.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-vyeLQFFg.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,5 +1,5 @@
1
- import { x as readResponseJson } from "./errors-iWIsey1D.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-C6BLOrcg.js";
1
+ import { S as readResponseJson } from "./errors-C8YcR1BL.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-DGoQMthD.js";
3
3
  import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-B7_9Hl_z.js";
4
4
  //#region src/tangle/abi.ts
5
5
  /**
@@ -1,9 +1,34 @@
1
- import { AgentInteractiveSessionControlClaim, AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
2
1
  import { z } from "zod";
2
+ import { AgentInteractiveSessionControlClaim, AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
3
3
 
4
4
  //#region ../../../packages/runtime-contracts/dist/terminal-websocket.d.ts
5
5
  /** Non-credential protocol selected during a successful terminal handshake. */
6
6
  declare const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
7
+ /**
8
+ * Server stamps for one attach, in epoch milliseconds on the sidecar's clock.
9
+ * They are absolute so a caller can lay them against its own marks and read
10
+ * each leg (client clock skew is the only error). `spawn*` and `initPersistAt`
11
+ * are absent when the attach adopted a PTY that already existed.
12
+ */
13
+ declare const terminalReadyTimingsSchema: z.ZodObject<{
14
+ upgradeAt: z.ZodNumber;
15
+ authAt: z.ZodNumber;
16
+ initAt: z.ZodNumber;
17
+ loadAt: z.ZodNumber;
18
+ spawnAt: z.ZodOptional<z.ZodNumber>;
19
+ initPersistAt: z.ZodOptional<z.ZodNumber>;
20
+ loadedAt: z.ZodNumber;
21
+ historyAt: z.ZodNumber;
22
+ historyEvents: z.ZodNumber;
23
+ historyBytes: z.ZodNumber;
24
+ readyAt: z.ZodNumber;
25
+ via: z.ZodEnum<{
26
+ upgrade: "upgrade";
27
+ frame: "frame";
28
+ }>;
29
+ ptid: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ type TerminalReadyTimings = z.infer<typeof terminalReadyTimingsSchema>;
7
32
  declare const terminalReadyMessageSchema: z.ZodObject<{
8
33
  type: z.ZodLiteral<"ready">;
9
34
  connectionId: z.ZodString;
@@ -15,6 +40,24 @@ declare const terminalReadyMessageSchema: z.ZodObject<{
15
40
  earliest: z.ZodNumber;
16
41
  latest: z.ZodNumber;
17
42
  }, z.core.$strip>>;
43
+ timings: z.ZodOptional<z.ZodObject<{
44
+ upgradeAt: z.ZodNumber;
45
+ authAt: z.ZodNumber;
46
+ initAt: z.ZodNumber;
47
+ loadAt: z.ZodNumber;
48
+ spawnAt: z.ZodOptional<z.ZodNumber>;
49
+ initPersistAt: z.ZodOptional<z.ZodNumber>;
50
+ loadedAt: z.ZodNumber;
51
+ historyAt: z.ZodNumber;
52
+ historyEvents: z.ZodNumber;
53
+ historyBytes: z.ZodNumber;
54
+ readyAt: z.ZodNumber;
55
+ via: z.ZodEnum<{
56
+ upgrade: "upgrade";
57
+ frame: "frame";
58
+ }>;
59
+ ptid: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strip>>;
18
61
  }, z.core.$strip>;
19
62
  type TerminalReadyMessage = z.infer<typeof terminalReadyMessageSchema>;
20
63
  type TerminalReadyInfo = Omit<TerminalReadyMessage, "type">;
@@ -98,7 +141,16 @@ interface ScopedToken {
98
141
  declare class TerminalStreamError extends Error {
99
142
  /** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
100
143
  readonly code: string;
101
- constructor(message: string, code: string);
144
+ /**
145
+ * True when the socket never reached OPEN: the upgrade was refused (a
146
+ * WebSocket client cannot read the HTTP status, so a 401 and a network drop
147
+ * look alike) or the runtime rejected the dial's options. No PTY work had
148
+ * started on the client's side of that dial.
149
+ */
150
+ readonly beforeOpen: boolean;
151
+ constructor(message: string, code: string, options?: {
152
+ beforeOpen?: boolean;
153
+ });
102
154
  }
103
155
  /**
104
156
  * Event callbacks, passed at construction (the same idiom as
@@ -143,7 +195,41 @@ interface TerminalStreamHandlers {
143
195
  * Scoped terminal tokens are short-lived (the platform clamps them to <= 15
144
196
  * minutes), so a provider lets the SDK re-mint a fresh token per dial.
145
197
  */
146
- type TerminalStreamToken = string | ScopedToken | ((signal?: AbortSignal) => Promise<string | ScopedToken> | string | ScopedToken);
198
+ type TerminalStreamBearerToken = string | ScopedToken | ((signal?: AbortSignal) => Promise<string | ScopedToken> | string | ScopedToken);
199
+ /**
200
+ * The account API key, sent as the `Authorization` header of the upgrade
201
+ * instead of a subprotocol credential. Only a runtime that can set headers on
202
+ * a WebSocket upgrade (Node, Bun) can dial this way — see
203
+ * {@link terminalUpgradeHeadersSupported}; a browser keeps a scoped token. The
204
+ * public API proxy takes its owner path for the key, so no scoped token is
205
+ * minted first. Dial the public API proxy with it, never the sidecar directly.
206
+ */
207
+ interface TerminalStreamApiKey {
208
+ readonly apiKey: string;
209
+ }
210
+ type TerminalStreamToken = TerminalStreamBearerToken | TerminalStreamApiKey;
211
+ /**
212
+ * Wall-clock marks for one attach, in milliseconds on the caller's monotonic
213
+ * clock. `server` holds the sidecar's absolute stamps from the `ready` frame
214
+ * (epoch milliseconds on the sidecar's clock); a caller lays them against its
215
+ * own epoch marks to split each leg.
216
+ */
217
+ interface TerminalAttachTimings {
218
+ /** The caller's wall to mint the scoped token; absent when the dial used the API key. */
219
+ mintMs?: number;
220
+ /** WebSocket construction to `open`: the upgrade round trip. */
221
+ wsOpenMs: number;
222
+ /** `open` to `ready`. One client/sidecar round trip plus the sidecar's work when `init` was a frame; the sidecar's work alone once the PTY starts on the upgrade. */
223
+ initToReadyMs: number;
224
+ /** `ready` to the first output byte (replayed screen or live output); absent until it arrives. */
225
+ firstByteMs?: number;
226
+ /** The first `write()` to the next output byte; absent until it arrives. */
227
+ echoRttMs?: number;
228
+ /** How the init was offered: on the upgrade URL as well as in the frame (a default-shell attach), or in the frame alone. */
229
+ init: "upgrade" | "frame";
230
+ /** The sidecar's stamps; absent from a sidecar that predates them. */
231
+ server?: TerminalReadyTimings;
232
+ }
147
233
  /** Authority refreshed before an interactive stream reconnects. */
148
234
  interface TerminalStreamReconnectBinding {
149
235
  incarnationId: TerminalInteractiveSessionIdentity["incarnationId"];
@@ -194,7 +280,23 @@ interface TerminalStreamOptions {
194
280
  signal?: AbortSignal;
195
281
  /** Reclaim interactive authority before a reconnecting dial. */
196
282
  reconnectAuthority?: TerminalStreamReconnectAuthority;
283
+ /**
284
+ * Correlation id for this attach: sent as `x-tangle-trace-id` where the
285
+ * runtime can set upgrade headers, and on the upgrade URL and the `init`
286
+ * frame everywhere else. A fresh id is minted when omitted.
287
+ */
288
+ traceId?: string;
289
+ /** Wall the caller spent minting this dial's credential, reported in {@link TerminalAttachTimings}. */
290
+ mintMs?: number;
197
291
  }
292
+ /**
293
+ * Whether this runtime's global `WebSocket` accepts request headers on the
294
+ * upgrade (Node >= 22 through undici, and Bun): the condition for dialing with
295
+ * the API key and for sending `x-tangle-trace-id` as a header. Browsers and
296
+ * Workers cannot. A runtime that is judged able but ignores the headers is
297
+ * still safe: the upgrade is refused, and the caller dials with a scoped token.
298
+ */
299
+ declare function terminalUpgradeHeadersSupported(): boolean;
198
300
  /**
199
301
  * Client for one terminal WebSocket connection. Construct via
200
302
  * {@link TerminalStream.connect}, which resolves once the server
@@ -207,6 +309,14 @@ declare class TerminalStream {
207
309
  private readonly interactiveIdentity;
208
310
  private readonly initMessage;
209
311
  private readonly handlers;
312
+ private readonly attachTraceId;
313
+ private readonly initOnUpgrade;
314
+ private readonly dialStartedAt;
315
+ private openedAt;
316
+ private readyAt;
317
+ private firstByteAt;
318
+ private firstWriteAt;
319
+ private echoRttMs;
210
320
  private readyInfo;
211
321
  private closed;
212
322
  private closeWaiters;
@@ -228,6 +338,15 @@ declare class TerminalStream {
228
338
  get connectionId(): string;
229
339
  /** The server's `ready` acknowledgement. Set once `connect()` resolves. */
230
340
  get ready(): TerminalReadyInfo;
341
+ /** Correlation id of this attach (`x-tangle-trace-id` / `traceId`). */
342
+ get traceId(): string;
343
+ /**
344
+ * Timings of this attach. `firstByteMs` and `echoRttMs` appear once the
345
+ * stream has produced the output they measure.
346
+ */
347
+ get timings(): TerminalAttachTimings;
348
+ /** Stamp the first output byte after `ready`, and the first one after the first write. */
349
+ private noteOutput;
231
350
  /** True while the socket is open. */
232
351
  get isOpen(): boolean;
233
352
  /**
@@ -267,4 +386,4 @@ declare class TerminalStream {
267
386
  private assertOpen;
268
387
  }
269
388
  //#endregion
270
- export { TerminalStreamReconnectAuthority as a, MintScopedTokenOptions as c, TERMINAL_WS_ECHO_SUBPROTOCOL as d, TerminalExitInfo as f, TerminalStreamAuthFormat as g, TerminalReadyInfo as h, TerminalStreamOptions as i, ScopedToken as l, TerminalOutputMessage as m, TerminalStreamError as n, TerminalStreamToken as o, TerminalInteractiveSessionIdentity as p, TerminalStreamHandlers as r, MintInteractiveSessionTokenOptions as s, TerminalStream as t, ScopedTokenScope as u };
389
+ export { TerminalInteractiveSessionIdentity as _, TerminalStreamError as a, TerminalReadyTimings as b, TerminalStreamReconnectAuthority as c, MintInteractiveSessionTokenOptions as d, MintScopedTokenOptions as f, TerminalExitInfo as g, TERMINAL_WS_ECHO_SUBPROTOCOL as h, TerminalStreamBearerToken as i, TerminalStreamToken as l, ScopedTokenScope as m, TerminalStream as n, TerminalStreamHandlers as o, ScopedToken as p, TerminalStreamApiKey as r, TerminalStreamOptions as s, TerminalAttachTimings as t, terminalUpgradeHeadersSupported as u, TerminalOutputMessage as v, TerminalStreamAuthFormat as x, TerminalReadyInfo as y };