@tangle-network/sandbox 0.30.2 → 0.31.0-develop.20260820224055.6e958e9
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 +1 -0
- package/dist/abort-signal-si1WMfJb.js +31 -0
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/{agent-run-outcome-TwIC-Ccd.d.ts → agent-run-outcome-CM7xD7Mg.d.ts} +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/browser-interactive-control-controller-B476gcui.d.ts +96 -0
- package/dist/browser-interactive-control-controller-wXQ7W5pT.js +276 -0
- package/dist/{client-CLuVW5gB.js → client-BfnJ44gF.js} +29 -6
- package/dist/{client-BkPr0m7Z.d.ts → client-Do_HS671.d.ts} +28 -3
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/core.d.ts +4 -4
- package/dist/core.js +2 -2
- package/dist/{index-DAxioMfr.d.ts → index-ebsVOlUc.d.ts} +2 -2
- package/dist/index.d.ts +11 -9
- package/dist/index.js +7 -6
- package/dist/interactive-control.d.ts +2 -0
- package/dist/interactive-control.js +2 -0
- package/dist/{runtime-api-TVLbV10b.js → runtime-api-B0tx7NJM.js} +2 -6
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +2 -1
- package/dist/{sandbox-BKaSZNC7.js → sandbox-AUHcCJe1.js} +1419 -569
- package/dist/{sandbox-Caev7isY.d.ts → sandbox-Cr-4qzaA.d.ts} +134 -187
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-D6-D3qL4.js → tangle-iDk_s8vt.js} +1 -1
- package/dist/terminal-stream-4KNJ6SmL.d.ts +256 -0
- package/dist/{types-D_ykdqn6.d.ts → types-BwYLVqxX.d.ts} +14 -250
- package/package.json +10 -5
- /package/dist/{collaboration-COCXdRrk.js → collaboration-DQD9kCdN.js} +0 -0
- /package/dist/{errors-Bdy5jXzc.d.ts → errors-CQOvGddH.d.ts} +0 -0
- /package/dist/{index-DtRFVx5U.d.ts → index-Bq_z_u6A.d.ts} +0 -0
- /package/dist/{index-Cp1KYanB.d.ts → index-CMLW3u5K.d.ts} +0 -0
- /package/dist/{local-cli-auth-D4u7fsnH.js → local-cli-auth-CJmSpTjk.js} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ export SANDBOX_BASE_URL=https://sandbox.tangle.tools
|
|
|
23
23
|
| Full client, sandboxes, fleets, images, sessions, and trace utilities | `@tangle-network/sandbox` |
|
|
24
24
|
| Edge-safe client without `viem` | `@tangle-network/sandbox/core` |
|
|
25
25
|
| Browser or Worker access with a short-lived scoped token | `@tangle-network/sandbox/runtime` |
|
|
26
|
+
| Browser status, claim, and release control for an interactive session | `@tangle-network/sandbox/interactive-control` |
|
|
26
27
|
| Direct Tangle chain operations | `@tangle-network/sandbox/tangle` |
|
|
27
28
|
| Server-side token issuance and validation | `@tangle-network/sandbox/auth` |
|
|
28
29
|
| Collaborative document clients and file bridging | `@tangle-network/sandbox/collaboration` |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/lib/abort-signal.ts
|
|
2
|
+
function combineAbortSignals(signals) {
|
|
3
|
+
return AbortSignal.any(signals);
|
|
4
|
+
}
|
|
5
|
+
function awaitWithAbort(work, signal) {
|
|
6
|
+
if (!signal) return work;
|
|
7
|
+
signal.throwIfAborted();
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
let settled = false;
|
|
10
|
+
const onAbort = () => {
|
|
11
|
+
if (settled) return;
|
|
12
|
+
settled = true;
|
|
13
|
+
signal.removeEventListener("abort", onAbort);
|
|
14
|
+
reject(signal.reason ?? new DOMException("The request was aborted", "AbortError"));
|
|
15
|
+
};
|
|
16
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
17
|
+
work.then((value) => {
|
|
18
|
+
if (settled) return;
|
|
19
|
+
settled = true;
|
|
20
|
+
signal.removeEventListener("abort", onAbort);
|
|
21
|
+
resolve(value);
|
|
22
|
+
}, (cause) => {
|
|
23
|
+
if (settled) return;
|
|
24
|
+
settled = true;
|
|
25
|
+
signal.removeEventListener("abort", onAbort);
|
|
26
|
+
reject(cause);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { combineAbortSignals as n, awaitWithAbort as t };
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as SandboxSession, h as SandboxTaskSession, r as SandboxInstance } from "../sandbox-
|
|
2
|
-
import { D as CodeResultPart, E as CodeLanguage, T as CodeExecutionResult, d as BackendConfig,
|
|
3
|
-
import { i as Sandbox } from "../client-
|
|
1
|
+
import { g as SandboxSession, h as SandboxTaskSession, r as SandboxInstance } from "../sandbox-Cr-4qzaA.js";
|
|
2
|
+
import { D as CodeResultPart, E as CodeLanguage, T as CodeExecutionResult, d as BackendConfig, gi as SessionInfo, vi as SessionListOptions, w as CodeExecutionOptions } from "../types-BwYLVqxX.js";
|
|
3
|
+
import { i as Sandbox } from "../client-Do_HS671.js";
|
|
4
4
|
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
|
|
6
6
|
//#region src/agent/instances.d.ts
|
package/dist/agent/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as assertCurrentBackendType } from "../runtime-api-B0tx7NJM.js";
|
|
2
2
|
import { d as StateError, o as NotFoundError, p as ValidationError } from "../errors-C6kn-3zt.js";
|
|
3
|
-
import { n as Sandbox } from "../client-
|
|
4
|
-
import { t as SandboxInstance } from "../sandbox-
|
|
3
|
+
import { n as Sandbox } from "../client-BfnJ44gF.js";
|
|
4
|
+
import { t as SandboxInstance } from "../sandbox-AUHcCJe1.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
//#region src/agent/instances.ts
|
|
7
7
|
const managers = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as DurablePlanSnapshot, a as AgentQuestionRequest,
|
|
1
|
+
import { Q as DurablePlanSnapshot, a as AgentQuestionRequest, i as AgentApprovalRequirement, o as AgentRunStatus, s as AgentToolInvocation, ur as SandboxEvent } from "./types-BwYLVqxX.js";
|
|
2
2
|
import { InteractionRequest } from "@tangle-network/agent-interface";
|
|
3
3
|
|
|
4
4
|
//#region src/agent-run-outcome.d.ts
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as ReadTokenPayload, a as issueCollaborationToken, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-
|
|
1
|
+
import { _ as ReadTokenPayload, a as issueCollaborationToken, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-Bq_z_u6A.js";
|
|
2
2
|
export { AnyTokenPayload, BatchScopedTokenPayload, CollaborationAccess, CollaborationTokenPayload, IssueCollaborationTokenOptions, ProductTokenIssuer, ProjectScopedTokenPayload, ReadTokenPayload, SessionScopedTokenPayload, TokenScope, getTokenTTL, isTokenExpiringSoon, issueBatchScopedToken, issueCollaborationToken, issueProjectScopedToken, issueReadToken, issueSessionScopedToken, unsafeDecodeToken, verifyToken };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { r as TerminalStreamHandlers } from "./terminal-stream-4KNJ6SmL.js";
|
|
2
|
+
import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionStatus } from "@tangle-network/agent-interface";
|
|
3
|
+
import { AgentInteractiveSessionControlClaim as AgentInteractiveSessionControlClaim$1, AgentInteractiveSessionControlClaimRequest as AgentInteractiveSessionControlClaimRequest$1, AgentInteractiveSessionRef as AgentInteractiveSessionRef$1 } from "@tangle-network/agent-interface/environment-interactive-control";
|
|
4
|
+
|
|
5
|
+
//#region src/interactive-types.d.ts
|
|
6
|
+
/** Cancellation for an interactive SDK request. */
|
|
7
|
+
interface InteractiveRequestOptions {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/** Cancellation for a control-claim request. */
|
|
11
|
+
type InteractiveControlClaimOptions = InteractiveRequestOptions;
|
|
12
|
+
/** Exact attach command after the controller has claimed control. */
|
|
13
|
+
type InteractiveAttachOptions = AgentInteractiveSessionAttach & {
|
|
14
|
+
handlers?: TerminalStreamHandlers;
|
|
15
|
+
};
|
|
16
|
+
/** Published Interface control-claim acknowledgement. */
|
|
17
|
+
type InteractiveControlClaimAcknowledgement = AgentInteractiveSessionControlClaimAcknowledgement;
|
|
18
|
+
/** Provider-observed status without write authority. */
|
|
19
|
+
type InteractiveSessionStatus = AgentInteractiveSessionStatus;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/interactive-control-controller.d.ts
|
|
22
|
+
/** The exact identity needed to control one admitted interactive process. */
|
|
23
|
+
interface InteractiveSessionIdentity {
|
|
24
|
+
ref: AgentInteractiveSessionRef$1;
|
|
25
|
+
control: AgentInteractiveSessionControlClaim$1;
|
|
26
|
+
}
|
|
27
|
+
/** Transport for the status, claim, and release control operations. */
|
|
28
|
+
interface InteractiveSessionControlTransport {
|
|
29
|
+
status(sessionId: string, incarnationId: string, options?: InteractiveRequestOptions): Promise<InteractiveSessionStatus | null>;
|
|
30
|
+
claimControl(sessionId: string, request: AgentInteractiveSessionControlClaimRequest$1, options?: InteractiveRequestOptions): Promise<InteractiveControlClaimAcknowledgement>;
|
|
31
|
+
releaseControl(sessionId: string, ref: AgentInteractiveSessionRef$1, control: AgentInteractiveSessionControlClaim$1, options?: InteractiveRequestOptions): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Maximum time spent on bounded claim recovery and release cleanup. */
|
|
34
|
+
declare const INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS = 5000;
|
|
35
|
+
interface InteractiveSessionControlControllerOptions {
|
|
36
|
+
sessionId: string;
|
|
37
|
+
incarnationId: string;
|
|
38
|
+
holderId: string;
|
|
39
|
+
/** Check that the provider identity belongs to the expected environment. */
|
|
40
|
+
environmentId?: string;
|
|
41
|
+
/** Injectable only for deterministic callers and tests. */
|
|
42
|
+
operationIdFactory?: () => string;
|
|
43
|
+
/** Bound cleanup requests when a transport ignores AbortSignal. */
|
|
44
|
+
cleanupTimeoutMs?: number;
|
|
45
|
+
}
|
|
46
|
+
/** Create a holder id for one in-memory interactive controller. */
|
|
47
|
+
declare function createInteractiveControlHolderId(prefix?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Own the one status → claim → release sequence shared by browser and SDK callers.
|
|
50
|
+
*
|
|
51
|
+
* This module deliberately has no terminal or WebSocket dependency. Attach-capable
|
|
52
|
+
* callers extend it with the stream operation after a claim has been resolved.
|
|
53
|
+
*/
|
|
54
|
+
declare class InteractiveSessionControlController {
|
|
55
|
+
protected readonly transport: InteractiveSessionControlTransport;
|
|
56
|
+
protected readonly options: InteractiveSessionControlControllerOptions;
|
|
57
|
+
private readonly operationIdFactory;
|
|
58
|
+
private readonly cleanupTimeoutMs;
|
|
59
|
+
private resolveInFlight?;
|
|
60
|
+
constructor(transport: InteractiveSessionControlTransport, options: InteractiveSessionControlControllerOptions);
|
|
61
|
+
protected safelyReleaseClaim(identity: InteractiveSessionIdentity): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Recover a claim whose response or commit may have been lost or corrupted.
|
|
64
|
+
*
|
|
65
|
+
* The same operation id and digest make this replay idempotent. Recovery uses
|
|
66
|
+
* an independent bounded signal so caller abort cannot strand an invisible claim.
|
|
67
|
+
*/
|
|
68
|
+
private recoverAmbiguousClaim;
|
|
69
|
+
/** Release one claim that this controller resolved. */
|
|
70
|
+
release(identity: InteractiveSessionIdentity, requestOptions?: InteractiveRequestOptions): Promise<void>;
|
|
71
|
+
/** Observe and claim the current exact process incarnation. */
|
|
72
|
+
resolve(requestOptions?: InteractiveRequestOptions): Promise<InteractiveSessionIdentity>;
|
|
73
|
+
private resolveInternal;
|
|
74
|
+
/** Expose the canonical ref digest used by persisted control identities. */
|
|
75
|
+
static identityDigest(identity: InteractiveSessionIdentity): string;
|
|
76
|
+
}
|
|
77
|
+
/** Expose the same digest used to bind persistence and control identities. */
|
|
78
|
+
declare function interactiveSessionIdentityDigest(identity: InteractiveSessionIdentity): string;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/browser-interactive-control-controller.d.ts
|
|
81
|
+
interface BrowserInteractiveSessionControlControllerOptions extends InteractiveSessionControlControllerOptions {
|
|
82
|
+
sessionApiUrl: string;
|
|
83
|
+
token: string;
|
|
84
|
+
fetchImpl?: typeof fetch;
|
|
85
|
+
}
|
|
86
|
+
/** Browser controller for status, claim, and release without terminal attach. */
|
|
87
|
+
declare class BrowserInteractiveSessionControlController extends InteractiveSessionControlController {
|
|
88
|
+
constructor(options: BrowserInteractiveSessionControlControllerOptions);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Return one stable browser holder per exact sandbox process incarnation.
|
|
92
|
+
* Storage failures produce a new holder and never reuse persisted authority.
|
|
93
|
+
*/
|
|
94
|
+
declare function browserInteractiveControlHolderId(environmentId: string, sessionId: string, incarnationId: string): string;
|
|
95
|
+
//#endregion
|
|
96
|
+
export { InteractiveSessionControlController as a, InteractiveSessionIdentity as c, InteractiveAttachOptions as d, InteractiveControlClaimAcknowledgement as f, InteractiveSessionStatus as h, INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS as i, createInteractiveControlHolderId as l, InteractiveRequestOptions as m, BrowserInteractiveSessionControlControllerOptions as n, InteractiveSessionControlControllerOptions as o, InteractiveControlClaimOptions as p, browserInteractiveControlHolderId as r, InteractiveSessionControlTransport as s, BrowserInteractiveSessionControlController as t, interactiveSessionIdentityDigest as u };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { t as awaitWithAbort } from "./abort-signal-si1WMfJb.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimRequestDigest } from "@tangle-network/agent-interface/environment-interactive-control";
|
|
4
|
+
//#region ../../../packages/runtime-contracts/dist/interactive-session-control-http.js
|
|
5
|
+
const interactiveSessionStatusResponseSchema = z.object({
|
|
6
|
+
success: z.literal(true),
|
|
7
|
+
data: z.object({ status: AgentInteractiveSessionStatusSchema }).strict()
|
|
8
|
+
}).strict();
|
|
9
|
+
const interactiveSessionControlClaimResponseSchema = z.object({
|
|
10
|
+
success: z.literal(true),
|
|
11
|
+
data: AgentInteractiveSessionControlClaimAcknowledgementSchema
|
|
12
|
+
}).strict();
|
|
13
|
+
const interactiveSessionControlReleaseBodySchema = z.object({
|
|
14
|
+
ref: AgentInteractiveSessionRefSchema,
|
|
15
|
+
control: AgentInteractiveSessionControlClaimSchema
|
|
16
|
+
}).strict();
|
|
17
|
+
const interactiveSessionControlReleaseResponseSchema = z.object({
|
|
18
|
+
success: z.literal(true),
|
|
19
|
+
data: z.object({ status: z.enum([
|
|
20
|
+
"released",
|
|
21
|
+
"already-released",
|
|
22
|
+
"absent"
|
|
23
|
+
]) }).strict()
|
|
24
|
+
}).strict();
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/interactive-control-controller.ts
|
|
27
|
+
/** Maximum time spent on bounded claim recovery and release cleanup. */
|
|
28
|
+
const INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS = 5e3;
|
|
29
|
+
function randomId(prefix) {
|
|
30
|
+
const cryptoApi = globalThis.crypto;
|
|
31
|
+
if (cryptoApi && typeof cryptoApi.randomUUID === "function") return `${prefix}-${cryptoApi.randomUUID()}`;
|
|
32
|
+
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
33
|
+
}
|
|
34
|
+
/** Create a holder id for one in-memory interactive controller. */
|
|
35
|
+
function createInteractiveControlHolderId(prefix = "interactive") {
|
|
36
|
+
return randomId(prefix);
|
|
37
|
+
}
|
|
38
|
+
function assertInteractiveSessionRef(ref, options) {
|
|
39
|
+
if (ref.run.sessionId !== options.sessionId || ref.incarnationId !== options.incarnationId || options.environmentId !== void 0 && ref.run.environmentId !== options.environmentId) throw new Error("Interactive session identity does not match this sandbox");
|
|
40
|
+
}
|
|
41
|
+
function assertActiveControlClaim(control) {
|
|
42
|
+
const expiresAt = Date.parse(control.expiresAt);
|
|
43
|
+
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now()) throw new Error("Interactive control claim is stale");
|
|
44
|
+
}
|
|
45
|
+
function createCleanupScope(timeoutMs) {
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
const timer = setTimeout(() => {
|
|
48
|
+
controller.abort(new DOMException(`Interactive control cleanup timed out after ${timeoutMs}ms`, "TimeoutError"));
|
|
49
|
+
}, timeoutMs);
|
|
50
|
+
return {
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
dispose: () => clearTimeout(timer)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function claimAcknowledgementMatchesRequest(ref, request, acknowledgement) {
|
|
56
|
+
if (!agentInteractiveSessionControlClaimAcknowledgementMatchesRequest(request, acknowledgement)) return false;
|
|
57
|
+
if (acknowledgement.status !== "accepted" && acknowledgement.status !== "replayed") return true;
|
|
58
|
+
return acknowledgement.control !== void 0 && agentInteractiveSessionControlClaimMatchesRef(ref, acknowledgement.control) && acknowledgement.control.holderId === request.holderId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Own the one status → claim → release sequence shared by browser and SDK callers.
|
|
62
|
+
*
|
|
63
|
+
* This module deliberately has no terminal or WebSocket dependency. Attach-capable
|
|
64
|
+
* callers extend it with the stream operation after a claim has been resolved.
|
|
65
|
+
*/
|
|
66
|
+
var InteractiveSessionControlController = class {
|
|
67
|
+
operationIdFactory;
|
|
68
|
+
cleanupTimeoutMs;
|
|
69
|
+
resolveInFlight;
|
|
70
|
+
constructor(transport, options) {
|
|
71
|
+
this.transport = transport;
|
|
72
|
+
this.options = options;
|
|
73
|
+
this.operationIdFactory = options.operationIdFactory ?? (() => randomId("interactive-claim"));
|
|
74
|
+
this.cleanupTimeoutMs = options.cleanupTimeoutMs ?? 5e3;
|
|
75
|
+
if (!Number.isFinite(this.cleanupTimeoutMs) || this.cleanupTimeoutMs <= 0) throw new RangeError("Interactive control cleanup timeout must be greater than zero");
|
|
76
|
+
}
|
|
77
|
+
async safelyReleaseClaim(identity) {
|
|
78
|
+
const cleanupScope = createCleanupScope(this.cleanupTimeoutMs);
|
|
79
|
+
try {
|
|
80
|
+
await awaitWithAbort(this.release(identity, { signal: cleanupScope.signal }), cleanupScope.signal);
|
|
81
|
+
} catch {} finally {
|
|
82
|
+
cleanupScope.dispose();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Recover a claim whose response or commit may have been lost or corrupted.
|
|
87
|
+
*
|
|
88
|
+
* The same operation id and digest make this replay idempotent. Recovery uses
|
|
89
|
+
* an independent bounded signal so caller abort cannot strand an invisible claim.
|
|
90
|
+
*/
|
|
91
|
+
async recoverAmbiguousClaim(ref, request) {
|
|
92
|
+
const cleanupScope = createCleanupScope(this.cleanupTimeoutMs);
|
|
93
|
+
try {
|
|
94
|
+
const acknowledgement = AgentInteractiveSessionControlClaimAcknowledgementSchema.parse(await awaitWithAbort(this.transport.claimControl(this.options.sessionId, request, { signal: cleanupScope.signal }), cleanupScope.signal));
|
|
95
|
+
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && acknowledgement.control !== void 0 && claimAcknowledgementMatchesRequest(ref, request, acknowledgement) && agentInteractiveSessionControlClaimMatchesRef(ref, acknowledgement.control)) await this.safelyReleaseClaim({
|
|
96
|
+
ref,
|
|
97
|
+
control: acknowledgement.control
|
|
98
|
+
});
|
|
99
|
+
} catch {} finally {
|
|
100
|
+
cleanupScope.dispose();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Release one claim that this controller resolved. */
|
|
104
|
+
async release(identity, requestOptions) {
|
|
105
|
+
requestOptions?.signal?.throwIfAborted();
|
|
106
|
+
const exactRef = AgentInteractiveSessionRefSchema.parse(identity.ref);
|
|
107
|
+
assertInteractiveSessionRef(exactRef, this.options);
|
|
108
|
+
if (!agentInteractiveSessionControlClaimMatchesRef(exactRef, identity.control)) throw new Error("Interactive control claim is not bound to the session");
|
|
109
|
+
await this.transport.releaseControl(this.options.sessionId, exactRef, identity.control, requestOptions);
|
|
110
|
+
}
|
|
111
|
+
/** Observe and claim the current exact process incarnation. */
|
|
112
|
+
async resolve(requestOptions) {
|
|
113
|
+
requestOptions?.signal?.throwIfAborted();
|
|
114
|
+
if (this.resolveInFlight !== void 0) return await awaitWithAbort(this.resolveInFlight, requestOptions?.signal);
|
|
115
|
+
const operation = this.resolveInternal(requestOptions);
|
|
116
|
+
let tracked;
|
|
117
|
+
tracked = operation.finally(() => {
|
|
118
|
+
if (this.resolveInFlight === tracked) this.resolveInFlight = void 0;
|
|
119
|
+
});
|
|
120
|
+
this.resolveInFlight = tracked;
|
|
121
|
+
return await tracked;
|
|
122
|
+
}
|
|
123
|
+
async resolveInternal(requestOptions) {
|
|
124
|
+
let claimedIdentity;
|
|
125
|
+
try {
|
|
126
|
+
requestOptions?.signal?.throwIfAborted();
|
|
127
|
+
const status = await this.transport.status(this.options.sessionId, this.options.incarnationId, requestOptions);
|
|
128
|
+
requestOptions?.signal?.throwIfAborted();
|
|
129
|
+
if (!status || status.state !== "running") throw new Error("Interactive session is not running or has stale identity");
|
|
130
|
+
const ref = AgentInteractiveSessionRefSchema.parse(status.ref);
|
|
131
|
+
assertInteractiveSessionRef(ref, this.options);
|
|
132
|
+
let expectedGeneration = 1;
|
|
133
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
134
|
+
requestOptions?.signal?.throwIfAborted();
|
|
135
|
+
const material = {
|
|
136
|
+
operationId: this.operationIdFactory(),
|
|
137
|
+
ref,
|
|
138
|
+
holderId: this.options.holderId,
|
|
139
|
+
expectedGeneration
|
|
140
|
+
};
|
|
141
|
+
const request = AgentInteractiveSessionControlClaimRequestSchema.parse({
|
|
142
|
+
...material,
|
|
143
|
+
requestDigest: agentInteractiveSessionControlClaimRequestDigest(material)
|
|
144
|
+
});
|
|
145
|
+
let acknowledgement;
|
|
146
|
+
try {
|
|
147
|
+
acknowledgement = AgentInteractiveSessionControlClaimAcknowledgementSchema.parse(await this.transport.claimControl(this.options.sessionId, request, requestOptions));
|
|
148
|
+
} catch (error) {
|
|
149
|
+
await this.recoverAmbiguousClaim(ref, request);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
if (!claimAcknowledgementMatchesRequest(ref, request, acknowledgement)) {
|
|
153
|
+
await this.recoverAmbiguousClaim(ref, request);
|
|
154
|
+
throw new Error("Interactive control claim acknowledgement does not match the request");
|
|
155
|
+
}
|
|
156
|
+
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && acknowledgement.control) {
|
|
157
|
+
if (!agentInteractiveSessionControlClaimMatchesRef(ref, acknowledgement.control)) throw new Error("Interactive control claim is not bound to the session");
|
|
158
|
+
claimedIdentity = {
|
|
159
|
+
ref,
|
|
160
|
+
control: acknowledgement.control
|
|
161
|
+
};
|
|
162
|
+
requestOptions?.signal?.throwIfAborted();
|
|
163
|
+
assertActiveControlClaim(acknowledgement.control);
|
|
164
|
+
return claimedIdentity;
|
|
165
|
+
}
|
|
166
|
+
requestOptions?.signal?.throwIfAborted();
|
|
167
|
+
if (acknowledgement.status === "conflict" && acknowledgement.conflictReason === "generation_mismatch" && acknowledgement.currentGeneration !== void 0 && acknowledgement.currentGeneration > expectedGeneration) {
|
|
168
|
+
expectedGeneration = acknowledgement.currentGeneration;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
throw new Error(acknowledgement.message ?? "Interactive control is held by another client");
|
|
172
|
+
}
|
|
173
|
+
throw new Error("Interactive control claim became stale during attach");
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (claimedIdentity !== void 0) await this.safelyReleaseClaim(claimedIdentity);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Expose the canonical ref digest used by persisted control identities. */
|
|
180
|
+
static identityDigest(identity) {
|
|
181
|
+
const ref = AgentInteractiveSessionRefSchema.parse(identity.ref);
|
|
182
|
+
const control = AgentInteractiveSessionControlClaimSchema.parse(identity.control);
|
|
183
|
+
if (!agentInteractiveSessionControlClaimMatchesRef(ref, control)) throw new Error("Interactive control claim is not bound to the session");
|
|
184
|
+
return control.refDigest;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
/** Expose the same digest used to bind persistence and control identities. */
|
|
188
|
+
function interactiveSessionIdentityDigest(identity) {
|
|
189
|
+
return InteractiveSessionControlController.identityDigest(identity);
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/browser-interactive-control-controller.ts
|
|
193
|
+
function browserInteractiveSessionEndpoint(baseUrl, sessionId, suffix = "") {
|
|
194
|
+
return `${baseUrl.replace(/\/+$/, "")}/agents/sessions/${encodeURIComponent(sessionId)}/interactive${suffix}`;
|
|
195
|
+
}
|
|
196
|
+
function browserInteractiveTerminalEndpoint(baseUrl, sessionId) {
|
|
197
|
+
return `${baseUrl.replace(/\/+$/, "")}/terminals/${encodeURIComponent(sessionId)}/ws`;
|
|
198
|
+
}
|
|
199
|
+
function authHeaders(token, includeContentType = false) {
|
|
200
|
+
return {
|
|
201
|
+
Authorization: `Bearer ${token}`,
|
|
202
|
+
...includeContentType ? { "Content-Type": "application/json" } : {}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
async function readError(response) {
|
|
206
|
+
if (response.status === 404) return /* @__PURE__ */ new Error("Interactive session identity is stale or no longer exists");
|
|
207
|
+
return /* @__PURE__ */ new Error(`Interactive session request failed (${response.status})`);
|
|
208
|
+
}
|
|
209
|
+
function createBrowserInteractiveSessionControlTransport(options) {
|
|
210
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
211
|
+
if (typeof fetchImpl !== "function") throw new Error("Interactive browser controller requires fetch");
|
|
212
|
+
return {
|
|
213
|
+
async status(sessionId, incarnationId, requestOptions) {
|
|
214
|
+
const response = await fetchImpl(`${browserInteractiveSessionEndpoint(options.sessionApiUrl, sessionId)}?incarnationId=${encodeURIComponent(incarnationId)}`, {
|
|
215
|
+
headers: authHeaders(options.token),
|
|
216
|
+
...requestOptions?.signal === void 0 ? {} : { signal: requestOptions.signal }
|
|
217
|
+
});
|
|
218
|
+
if (response.status === 404) return null;
|
|
219
|
+
if (!response.ok) throw await readError(response);
|
|
220
|
+
const parsed = interactiveSessionStatusResponseSchema.safeParse(await response.json());
|
|
221
|
+
if (!parsed.success) throw new Error("Interactive session is not running or has stale identity");
|
|
222
|
+
return parsed.data.data.status;
|
|
223
|
+
},
|
|
224
|
+
async claimControl(sessionId, request, requestOptions) {
|
|
225
|
+
const response = await fetchImpl(browserInteractiveSessionEndpoint(options.sessionApiUrl, sessionId, "/control"), {
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: authHeaders(options.token, true),
|
|
228
|
+
body: JSON.stringify(request),
|
|
229
|
+
...requestOptions?.signal === void 0 ? {} : { signal: requestOptions.signal }
|
|
230
|
+
});
|
|
231
|
+
if (!response.ok) throw await readError(response);
|
|
232
|
+
const parsed = interactiveSessionControlClaimResponseSchema.safeParse(await response.json());
|
|
233
|
+
if (!parsed.success) throw new Error("Interactive control claim response is invalid");
|
|
234
|
+
return parsed.data.data;
|
|
235
|
+
},
|
|
236
|
+
async releaseControl(sessionId, ref, control, requestOptions) {
|
|
237
|
+
const body = interactiveSessionControlReleaseBodySchema.parse({
|
|
238
|
+
ref,
|
|
239
|
+
control
|
|
240
|
+
});
|
|
241
|
+
const response = await fetchImpl(browserInteractiveSessionEndpoint(options.sessionApiUrl, sessionId, "/control/release"), {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: authHeaders(options.token, true),
|
|
244
|
+
body: JSON.stringify(body),
|
|
245
|
+
...requestOptions?.signal === void 0 ? {} : { signal: requestOptions.signal }
|
|
246
|
+
});
|
|
247
|
+
if (!response.ok) throw await readError(response);
|
|
248
|
+
if (!interactiveSessionControlReleaseResponseSchema.safeParse(await response.json()).success) throw new Error("Interactive control release response is invalid");
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/** Browser controller for status, claim, and release without terminal attach. */
|
|
253
|
+
var BrowserInteractiveSessionControlController = class extends InteractiveSessionControlController {
|
|
254
|
+
constructor(options) {
|
|
255
|
+
super(createBrowserInteractiveSessionControlTransport(options), options);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Return one stable browser holder per exact sandbox process incarnation.
|
|
260
|
+
* Storage failures produce a new holder and never reuse persisted authority.
|
|
261
|
+
*/
|
|
262
|
+
function browserInteractiveControlHolderId(environmentId, sessionId, incarnationId) {
|
|
263
|
+
const key = `tangle.interactive.control-holder:${environmentId}:${sessionId}:${incarnationId}`;
|
|
264
|
+
try {
|
|
265
|
+
const storage = globalThis.sessionStorage;
|
|
266
|
+
const existing = storage.getItem(key);
|
|
267
|
+
if (existing) return existing;
|
|
268
|
+
const holderId = createInteractiveControlHolderId("browser");
|
|
269
|
+
storage.setItem(key, holderId);
|
|
270
|
+
return holderId;
|
|
271
|
+
} catch {
|
|
272
|
+
return createInteractiveControlHolderId("browser");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS as a, createInteractiveControlHolderId as c, interactiveSessionControlReleaseResponseSchema as d, interactiveSessionStatusResponseSchema as f, createBrowserInteractiveSessionControlTransport as i, interactiveSessionIdentityDigest as l, browserInteractiveControlHolderId as n, InteractiveSessionControlController as o, browserInteractiveTerminalEndpoint as r, assertInteractiveSessionRef as s, BrowserInteractiveSessionControlController as t, interactiveSessionControlClaimResponseSchema as u };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as encodePromptForWire, d as assertCurrentBackendType, f as normalizeRuntimeBackendConfig, g as backendTypeSchema, l as encodeTextForWire, o as SANDBOX_PROXY_REQUEST_MAX_BYTES, u as applyRequestedModel } from "./runtime-api-B0tx7NJM.js";
|
|
2
2
|
import { a as NetworkError, f as TimeoutError, l as SandboxError, m as parseErrorResponse, o as NotFoundError, p as ValidationError, s as PartialFailureError, t as AuthError, u as ServerError } from "./errors-C6kn-3zt.js";
|
|
3
|
-
import {
|
|
3
|
+
import { n as combineAbortSignals } from "./abort-signal-si1WMfJb.js";
|
|
4
|
+
import { C as normalizeConnection, O as parseSSEStream, T as exportTraceBundle, _ as requestInteractiveSessionToken, i as normalizeStartupDiagnostics, n as createSandboxInstanceFromResponse, r as normalizeSandboxCreateReceipt } from "./sandbox-AUHcCJe1.js";
|
|
4
5
|
import { agentProfileSchema } from "@tangle-network/agent-interface";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
//#region src/backend-registry.ts
|
|
@@ -2444,11 +2445,11 @@ function withRequestContextHeaders(response, path, method) {
|
|
|
2444
2445
|
});
|
|
2445
2446
|
}
|
|
2446
2447
|
async function resolveLocalCliAuthFiles(backendType) {
|
|
2447
|
-
const { discoverLocalCliAuthFiles } = await import("./local-cli-auth-
|
|
2448
|
+
const { discoverLocalCliAuthFiles } = await import("./local-cli-auth-CJmSpTjk.js");
|
|
2448
2449
|
return discoverLocalCliAuthFiles(backendType);
|
|
2449
2450
|
}
|
|
2450
2451
|
async function describeLocalCliAuthExpectation(backendType) {
|
|
2451
|
-
const { describeLocalCliAuthExpectation: describe } = await import("./local-cli-auth-
|
|
2452
|
+
const { describeLocalCliAuthExpectation: describe } = await import("./local-cli-auth-CJmSpTjk.js");
|
|
2452
2453
|
return describe(backendType);
|
|
2453
2454
|
}
|
|
2454
2455
|
async function hydrateLocalCliBackendAuth(backend, baseUrl, trustLocalCliAuth) {
|
|
@@ -2822,6 +2823,16 @@ var Sandbox = class {
|
|
|
2822
2823
|
return parseBackendRegistryResponseBody(body);
|
|
2823
2824
|
}
|
|
2824
2825
|
/**
|
|
2826
|
+
* Get one registered agent backend by its canonical type.
|
|
2827
|
+
*
|
|
2828
|
+
* An absent entry means the authenticated Sandbox deployment does not
|
|
2829
|
+
* advertise that backend. The lookup uses the same typed catalog as
|
|
2830
|
+
* {@link listBackends}; it does not maintain a second registry.
|
|
2831
|
+
*/
|
|
2832
|
+
async getBackend(type) {
|
|
2833
|
+
return (await this.listBackends()).backends.find((backend) => backend.type === type);
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2825
2836
|
* List all sandboxes.
|
|
2826
2837
|
*
|
|
2827
2838
|
* @param options - Filtering and pagination options
|
|
@@ -2880,6 +2891,16 @@ var Sandbox = class {
|
|
|
2880
2891
|
return createSandboxInstanceFromResponse(this, this.parseInfo(data));
|
|
2881
2892
|
}
|
|
2882
2893
|
/**
|
|
2894
|
+
* Mint the terminal-capable token for one exact interactive session.
|
|
2895
|
+
*
|
|
2896
|
+
* This is a server-side operation. It validates the complete session
|
|
2897
|
+
* reference, derives the sandbox and runtime session IDs from that reference,
|
|
2898
|
+
* and makes one scoped-token request without loading the sandbox first.
|
|
2899
|
+
*/
|
|
2900
|
+
async mintInteractiveSessionToken(ref, options = {}) {
|
|
2901
|
+
return requestInteractiveSessionToken(this, ref, options);
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2883
2904
|
* Return the identity the public Sandbox API observed for this credential.
|
|
2884
2905
|
*
|
|
2885
2906
|
* This is useful for deployment checks that must confirm which account and
|
|
@@ -3116,6 +3137,7 @@ var Sandbox = class {
|
|
|
3116
3137
|
const requestTimeoutMs = typeof fetchOptions?.timeoutMs === "number" && fetchOptions.timeoutMs > 0 ? fetchOptions.timeoutMs : this.timeoutMs;
|
|
3117
3138
|
const controller = new AbortController();
|
|
3118
3139
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
3140
|
+
const requestSignal = options?.signal ? combineAbortSignals([options.signal, controller.signal]) : controller.signal;
|
|
3119
3141
|
try {
|
|
3120
3142
|
const headers = new Headers(options?.headers);
|
|
3121
3143
|
headers.set("Authorization", `Bearer ${this.apiKey}`);
|
|
@@ -3124,10 +3146,11 @@ var Sandbox = class {
|
|
|
3124
3146
|
return withRequestContextHeaders(await globalThis.fetch(url, {
|
|
3125
3147
|
...options,
|
|
3126
3148
|
headers,
|
|
3127
|
-
signal:
|
|
3149
|
+
signal: requestSignal
|
|
3128
3150
|
}), path, options?.method);
|
|
3129
3151
|
} catch (err) {
|
|
3130
|
-
if (
|
|
3152
|
+
if (controller.signal.aborted && requestSignal.reason === controller.signal.reason) throw new TimeoutError(requestTimeoutMs);
|
|
3153
|
+
if (options?.signal?.aborted) throw options.signal.reason ?? err;
|
|
3131
3154
|
throw new NetworkError(`Failed to connect to Sandbox API: ${err instanceof Error ? err.message : String(err)}`, err instanceof Error ? err : void 0, {
|
|
3132
3155
|
endpoint: path,
|
|
3133
3156
|
origin: "sandbox-api"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-
|
|
2
|
-
import {
|
|
1
|
+
import { l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-Cr-4qzaA.js";
|
|
2
|
+
import { l as ScopedToken, s as MintInteractiveSessionTokenOptions } from "./terminal-stream-4KNJ6SmL.js";
|
|
3
|
+
import { An as PromptInputPart, At as FleetExecDispatchResult, Bn as PublishPublicTemplateVersionOptions, Ct as FleetDispatchCancelResult, Dt as FleetDriveTurnOutcome, Er as SandboxFleetOperationsSummary, Et as FleetDispatchStreamOptions, F as CreateSandboxFleetWithCoordinatorOptions, Fr as SandboxFleetWorkspaceReconcileResult, Hn as ReapExpiredSandboxFleetsResult, I as CreateSandboxOptions, Ir as SandboxFleetWorkspaceRestoreResult, Ln as PublicTemplateInfo, Lr as SandboxFleetWorkspaceSnapshotResult, M as CreateRequestOptions, Mn as PromptResult, Mr as SandboxFleetTraceOptions, Mt as FleetPromptDispatchOptions, N as CreateSandboxFleetOptions, Ni as SubscriptionInfo, Nr as SandboxFleetUsage, Nt as FleetPromptDispatchResult, Or as SandboxFleetToken, Ot as FleetDriveTurnRequest, P as CreateSandboxFleetTokenOptions, Rn as PublicTemplateVersionInfo, Rr as SandboxIdentity, Sr as SandboxFleetMachineRecord, Tt as FleetDispatchResultBufferOptions, Un as ReconcileSandboxFleetsOptions, Vn as ReapExpiredSandboxFleetsOptions, Wi as TokenRefreshHandler, Wn as ReconcileSandboxFleetsResult, Xi as UsageInfo, _ as BatchRunOptions, an as IntelligenceReportWindow, ci as SecretsManager, ct as ExecOptions, dr as SandboxFleetArtifact, fr as SandboxFleetArtifactSpec, g as BatchResult, gr as SandboxFleetDriverCapability, hr as SandboxFleetDispatchResponse, ia as BatchEvent, j as CreateIntelligenceReportOptions, jn as PromptOptions, jt as FleetMachineId, ki as SshKeysManager, kr as SandboxFleetTraceBundle, kt as FleetExecDispatchOptions, l as AttachSandboxFleetMachineOptions, ln as ListSandboxFleetOptions, lr as SandboxEnvironment, lt as ExecResult, nn as IntelligenceReportBudget, pr as SandboxFleetCostEstimate, rn as IntelligenceReportCompareTo, rr as SandboxConfig, tn as IntelligenceReport, un as ListSandboxOptions, v as BatchRunRequest, vr as SandboxFleetInfo, wr as SandboxFleetManifest, wt as FleetDispatchResultBuffer, zn as PublishPublicTemplateOptions, zr as SandboxInfo } from "./types-BwYLVqxX.js";
|
|
4
|
+
import { AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
|
|
5
7
|
//#region src/backend-registry.d.ts
|
|
@@ -280,6 +282,13 @@ declare class SandboxFleetClient {
|
|
|
280
282
|
private listBySandboxMetadata;
|
|
281
283
|
}
|
|
282
284
|
//#endregion
|
|
285
|
+
//#region src/scoped-token.d.ts
|
|
286
|
+
interface ScopedTokenHttpClient {
|
|
287
|
+
fetch(path: string, options?: RequestInit, fetchOptions?: {
|
|
288
|
+
timeoutMs?: number;
|
|
289
|
+
}): Promise<Response>;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
283
292
|
//#region src/session-events.d.ts
|
|
284
293
|
/** Event delivered to a product session through the Sandbox session gateway. */
|
|
285
294
|
interface SessionBroadcastEvent {
|
|
@@ -324,7 +333,7 @@ interface SessionBroadcastResult {
|
|
|
324
333
|
* await box.delete();
|
|
325
334
|
* ```
|
|
326
335
|
*/
|
|
327
|
-
declare class Sandbox implements HttpClient {
|
|
336
|
+
declare class Sandbox implements HttpClient, ScopedTokenHttpClient {
|
|
328
337
|
private readonly baseUrl;
|
|
329
338
|
private readonly apiKey;
|
|
330
339
|
private readonly timeoutMs;
|
|
@@ -432,6 +441,14 @@ declare class Sandbox implements HttpClient {
|
|
|
432
441
|
* fewer interaction kinds after its configuration is applied.
|
|
433
442
|
*/
|
|
434
443
|
listBackends(): Promise<BackendRegistryResponse>;
|
|
444
|
+
/**
|
|
445
|
+
* Get one registered agent backend by its canonical type.
|
|
446
|
+
*
|
|
447
|
+
* An absent entry means the authenticated Sandbox deployment does not
|
|
448
|
+
* advertise that backend. The lookup uses the same typed catalog as
|
|
449
|
+
* {@link listBackends}; it does not maintain a second registry.
|
|
450
|
+
*/
|
|
451
|
+
getBackend(type: string): Promise<BackendRegistryEntry | undefined>;
|
|
435
452
|
/**
|
|
436
453
|
* List all sandboxes.
|
|
437
454
|
*
|
|
@@ -463,6 +480,14 @@ declare class Sandbox implements HttpClient {
|
|
|
463
480
|
* ```
|
|
464
481
|
*/
|
|
465
482
|
get(id: string): Promise<SandboxInstance | null>;
|
|
483
|
+
/**
|
|
484
|
+
* Mint the terminal-capable token for one exact interactive session.
|
|
485
|
+
*
|
|
486
|
+
* This is a server-side operation. It validates the complete session
|
|
487
|
+
* reference, derives the sandbox and runtime session IDs from that reference,
|
|
488
|
+
* and makes one scoped-token request without loading the sandbox first.
|
|
489
|
+
*/
|
|
490
|
+
mintInteractiveSessionToken(ref: AgentInteractiveSessionRef, options?: MintInteractiveSessionTokenOptions): Promise<ScopedToken>;
|
|
466
491
|
/**
|
|
467
492
|
* Return the identity the public Sandbox API observed for this credential.
|
|
468
493
|
*
|
|
@@ -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-CMLW3u5K.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-DQD9kCdN.js";
|
|
2
2
|
export { CollaborationClient, CollaborationFileBridge, buildCollaborationDocumentId, normalizeCollaborationPath, parseCollaborationDocumentId };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as WorkspaceImagePublishRequestOptions, i as WorkspaceImagePublishInput, o as WorkspaceImagePublishResult, r as SandboxInstance, s as WorkspaceImages } from "./sandbox-
|
|
2
|
-
import {
|
|
3
|
-
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, b as backendRegistryEntrySchema, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-
|
|
4
|
-
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-
|
|
1
|
+
import { a as WorkspaceImagePublishRequestOptions, i as WorkspaceImagePublishInput, o as WorkspaceImagePublishResult, r as SandboxInstance, s as WorkspaceImages } from "./sandbox-Cr-4qzaA.js";
|
|
2
|
+
import { An as PromptInputPart, I as CreateSandboxOptions, bn as PreviewLinkManager, ct as ExecOptions, lt as ExecResult, mn as NetworkConfig, qr as SandboxStatus, rr as SandboxConfig, xn as PreviewLinkWaitOptions, yn as PreviewLinkInfo, zr as SandboxInfo } from "./types-BwYLVqxX.js";
|
|
3
|
+
import { C as isBackendRegistryInteractionKind, S as backendRegistryResponseSchema, T as parseBackendRegistryResponseBody, _ as BackendRegistryInteractionKind, b as backendRegistryEntrySchema, g as BackendRegistryEntry, h as BackendRegistryCapabilities, i as Sandbox, v as BackendRegistryResponse, w as parseBackendRegistryResponse, x as backendRegistryInteractionKindSchema, y as backendRegistryCapabilitiesSchema } from "./client-Do_HS671.js";
|
|
4
|
+
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-CQOvGddH.js";
|
|
5
5
|
export { AuthError, type BackendRegistryCapabilities, type BackendRegistryEntry, type BackendRegistryInteractionKind, type BackendRegistryResponse, CapabilityError, type CreateSandboxOptions, type ExecOptions, type ExecResult, FileWriteConflictError, type NetworkConfig, NetworkError, NotFoundError, PartialFailureError, type PreviewLinkInfo, type PreviewLinkManager, type PreviewLinkWaitOptions, type PromptInputPart, QuotaError, Sandbox, type SandboxConfig, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, type SandboxInfo, SandboxInstance, type SandboxStatus, ServerError, StateError, TimeoutError, ValidationError, type WorkspaceImagePublishInput, type WorkspaceImagePublishRequestOptions, type WorkspaceImagePublishResult, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, parseBackendRegistryResponse, parseBackendRegistryResponseBody };
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as NetworkError, c as QuotaError, d as StateError, f as TimeoutError, i as FileWriteConflictError, l as SandboxError, n as CapabilityError, o as NotFoundError, p as ValidationError, s as PartialFailureError, t as AuthError, u as ServerError } from "./errors-C6kn-3zt.js";
|
|
2
|
-
import { _ as parseBackendRegistryResponseBody, d as backendRegistryCapabilitiesSchema, f as backendRegistryEntrySchema, g as parseBackendRegistryResponse, h as isBackendRegistryInteractionKind, m as backendRegistryResponseSchema, n as Sandbox, p as backendRegistryInteractionKindSchema } from "./client-
|
|
3
|
-
import { a as WorkspaceImages, t as SandboxInstance } from "./sandbox-
|
|
2
|
+
import { _ as parseBackendRegistryResponseBody, d as backendRegistryCapabilitiesSchema, f as backendRegistryEntrySchema, g as parseBackendRegistryResponse, h as isBackendRegistryInteractionKind, m as backendRegistryResponseSchema, n as Sandbox, p as backendRegistryInteractionKindSchema } from "./client-BfnJ44gF.js";
|
|
3
|
+
import { a as WorkspaceImages, t as SandboxInstance } from "./sandbox-AUHcCJe1.js";
|
|
4
4
|
export { AuthError, CapabilityError, FileWriteConflictError, NetworkError, NotFoundError, PartialFailureError, QuotaError, Sandbox, SandboxError, SandboxInstance, ServerError, StateError, TimeoutError, ValidationError, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, isBackendRegistryInteractionKind, parseBackendRegistryResponse, parseBackendRegistryResponseBody };
|