@tangle-network/sandbox 0.63.15 → 0.63.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +4 -4
- package/dist/agent/preview.d.ts +1 -1
- package/dist/{agent-run-outcome-BEhKOjQ4.d.ts → agent-run-outcome-vMD2ytAY.d.ts} +1 -1
- package/dist/{chunked-upload-B867njKv.js → chunked-upload-KJyRCAiC.js} +1 -1
- package/dist/{chunked-upload-file-Bs5qcfRB.js → chunked-upload-file-DfiGzqaR.js} +2 -2
- package/dist/{client-WJoyg-v9.d.ts → client-BRnWcZb6.d.ts} +7 -5
- package/dist/{client-Be-_CMPh.js → client-Dn_6xvvu.js} +6 -3
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-CXtTwK3x.js → collaboration-XHg5BEUI.js} +1 -1
- package/dist/core.d.ts +7 -7
- package/dist/core.js +3 -3
- package/dist/{errors-DqX66FDy.d.ts → error-classes-i7w5nzDv.d.ts} +2 -2
- package/dist/{errors-Bfhg_Zc6.js → errors-AB5BD3FM.js} +29 -27
- package/dist/{index-Dhorsvdh.d.ts → index--unlpqIN.d.ts} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +6 -6
- package/dist/intelligence/index.js +1 -1
- package/dist/{interactive-controller-C0bJnKLu.js → interactive-controller-zE6hwv3C.js} +2 -2
- package/dist/{lines-D_9Qpc4b.d.ts → lines-BsJeSsJM.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{managed-process-BGwa4-_A.d.ts → managed-process-CRwAzlIE.d.ts} +1 -1
- package/dist/{preview-QwdE17Ut.d.ts → preview-B3HbVfBv.d.ts} +3 -3
- package/dist/{public-templates-BGYdLtCV.d.ts → public-templates-bU_m4Ke5.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +3 -3
- package/dist/{sandbox-CDPa6RUB.d.ts → sandbox-Dv9Lkxwy.d.ts} +3 -3
- package/dist/{sandbox-C6Y2Hzlv.js → sandbox-WcGbtAjh.js} +482 -335
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-DUDjP2F4.js → tangle-B4gr0Zo_.js} +2 -2
- package/dist/{types-DXeFdLYg.d.ts → types-BcKuvP_Y.d.ts} +2227 -2216
- package/package.json +4 -4
|
@@ -1940,37 +1940,6 @@ interface BackendArtifact {
|
|
|
1940
1940
|
sizeBytes?: number;
|
|
1941
1941
|
updatedAt?: string;
|
|
1942
1942
|
}
|
|
1943
|
-
//#endregion
|
|
1944
|
-
//#region src/types/sessions.d.ts
|
|
1945
|
-
/**
|
|
1946
|
-
* Lifecycle state of an agent session inside a sandbox.
|
|
1947
|
-
*/
|
|
1948
|
-
type SessionStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
1949
|
-
/** Lifecycle state of an execution retained in the session replay ledger. */
|
|
1950
|
-
type SessionExecutionStatus = "active" | "completed" | "failed" | "cancelled";
|
|
1951
|
-
/**
|
|
1952
|
-
* Durable metadata for one session execution.
|
|
1953
|
-
*
|
|
1954
|
-
* The values come from the runtime replay ledger, not from a provider
|
|
1955
|
-
* response or an inferred model result.
|
|
1956
|
-
*/
|
|
1957
|
-
interface SessionExecutionInfo {
|
|
1958
|
-
executionId: string;
|
|
1959
|
-
sessionId: string;
|
|
1960
|
-
status: SessionExecutionStatus;
|
|
1961
|
-
startedAt: number;
|
|
1962
|
-
completedAt?: number;
|
|
1963
|
-
eventCount: number;
|
|
1964
|
-
lastEventId: string;
|
|
1965
|
-
}
|
|
1966
|
-
/** Admission identity survives replay retention; unavailable never means completed. */
|
|
1967
|
-
interface SessionMessageAdmission {
|
|
1968
|
-
sessionId: string;
|
|
1969
|
-
turnId: string;
|
|
1970
|
-
executionId: string;
|
|
1971
|
-
status: SessionExecutionStatus | "unavailable";
|
|
1972
|
-
runControlRef?: AgentExactRunControlRef;
|
|
1973
|
-
}
|
|
1974
1943
|
/** Secret-free model tuple selected by the sandbox runtime. */
|
|
1975
1944
|
/**
|
|
1976
1945
|
* Which layer supplied the model id that executed. `request` means the model
|
|
@@ -1991,1169 +1960,594 @@ interface EffectiveBackend {
|
|
|
1991
1960
|
/** Identity of the agent profile bound to the turn. */
|
|
1992
1961
|
profile?: EffectiveBackendProfile;
|
|
1993
1962
|
}
|
|
1963
|
+
//#endregion
|
|
1964
|
+
//#region src/types/agents.d.ts
|
|
1994
1965
|
/**
|
|
1995
|
-
*
|
|
1996
|
-
* not a bucketed label. A dispatched (detached) turn stops reading its SSE
|
|
1997
|
-
* stream the moment the sandbox admits the execution, so a spawn, profile
|
|
1998
|
-
* materialization or provider auth failure lands after the caller is gone;
|
|
1999
|
-
* this is how that caller learns what happened without replaying events.
|
|
1966
|
+
* Result of an agent prompt.
|
|
2000
1967
|
*/
|
|
2001
|
-
interface SessionFailureReason {
|
|
2002
|
-
/** The runtime's error message, unmodified. */
|
|
2003
|
-
message: string;
|
|
2004
|
-
/** Machine-readable code when the runtime classified the failure. */
|
|
2005
|
-
code?: string;
|
|
2006
|
-
/** Native HTTP failure status when the provider reported it. */
|
|
2007
|
-
statusCode?: number;
|
|
2008
|
-
/** Execution whose failure this describes. */
|
|
2009
|
-
executionId?: string;
|
|
2010
|
-
}
|
|
2011
1968
|
/**
|
|
2012
|
-
*
|
|
2013
|
-
*
|
|
1969
|
+
* Granular outcome of an agent run.
|
|
1970
|
+
* - `success` — reached a successful terminal event. Failed tool calls remain
|
|
1971
|
+
* available in `toolInvocations` because an agent can recover from them.
|
|
1972
|
+
* - `failed` — a run-level error, a failed terminal, a malformed terminal, or
|
|
1973
|
+
* a stream that ended with no terminal event.
|
|
1974
|
+
* - `blocked_on_approval` — a tool hit a hub approval gate; resolve it, then
|
|
1975
|
+
* re-run. See {@link AgentApprovalRequirement}.
|
|
1976
|
+
* - `awaiting_question` — the agent asked a question and the turn ended without
|
|
1977
|
+
* an answer. See {@link AgentQuestionRequest}.
|
|
1978
|
+
* - `awaiting_interaction` — the agent emitted another canonical interaction
|
|
1979
|
+
* request and the turn ended without a response.
|
|
2014
1980
|
*/
|
|
2015
|
-
|
|
2016
|
-
/** Stable session id assigned by the sandbox runtime. */
|
|
2017
|
-
id: string;
|
|
2018
|
-
/** Parent session id when this session was forked from another session. */
|
|
2019
|
-
parentId?: string;
|
|
2020
|
-
/** Current lifecycle state. */
|
|
2021
|
-
status: SessionStatus;
|
|
2022
|
-
/** Present when `status` is `"failed"` — the cause the runtime recorded. */
|
|
2023
|
-
failureReason?: SessionFailureReason;
|
|
2024
|
-
/** Execution currently running, when one is active. */
|
|
2025
|
-
activeExecutionId?: string;
|
|
2026
|
-
/** Most recent execution id, retained after completion for event replay. */
|
|
2027
|
-
latestExecutionId?: string;
|
|
2028
|
-
/** Exact identity of the latest admitted run, retained for canonical control. */
|
|
2029
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2030
|
-
/** Backend identifier (e.g. provider name). */
|
|
2031
|
-
backend?: string;
|
|
2032
|
-
/** Provider/model selected after request normalization and environment fallback. */
|
|
2033
|
-
effectiveBackend?: EffectiveBackend;
|
|
2034
|
-
/** Model id the session was created with. */
|
|
2035
|
-
model?: string;
|
|
2036
|
-
/** Number of prompts the session has processed. */
|
|
2037
|
-
promptCount?: number;
|
|
2038
|
-
/** When the session was created in the sandbox. */
|
|
2039
|
-
createdAt?: Date;
|
|
2040
|
-
/** When the session began executing. */
|
|
2041
|
-
startedAt?: Date;
|
|
2042
|
-
/** When the session reached a terminal state. */
|
|
2043
|
-
endedAt?: Date;
|
|
2044
|
-
/** Raw payload from the sidecar — stable subset above; this carries
|
|
2045
|
-
* everything else for forward-compatibility. */
|
|
2046
|
-
raw?: Record<string, unknown>;
|
|
2047
|
-
}
|
|
1981
|
+
type AgentRunStatus = "success" | "failed" | "blocked_on_approval" | "awaiting_question" | "awaiting_interaction" | "awaiting_plan_decision"
|
|
2048
1982
|
/**
|
|
2049
|
-
*
|
|
1983
|
+
* The stream ended before the run's terminal event and could not rejoin
|
|
1984
|
+
* (`errorCode` `STREAM_INTERRUPTED`). The run may still be running; rejoin
|
|
1985
|
+
* it with `streamPrompt(message, { executionId, lastEventId, sessionId })`
|
|
1986
|
+
* or read its session status.
|
|
2050
1987
|
*/
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
backend?: BackendType;
|
|
2056
|
-
}
|
|
2057
|
-
/** Options for creating a runtime agent session. */
|
|
2058
|
-
interface CreateSessionOptions {
|
|
2059
|
-
/** Existing agent-owned direct child of the box volume's `workspaces` directory, independent of runtime cwd. */
|
|
2060
|
-
workspaceRoot?: string;
|
|
2061
|
-
/** Complete ordered visible transcript imported into a new isolated runtime session. */
|
|
2062
|
-
conversationHistory?: Array<{
|
|
2063
|
-
id: string;
|
|
2064
|
-
role: "user" | "assistant";
|
|
2065
|
-
parts: Array<{
|
|
2066
|
-
type: "text";
|
|
2067
|
-
text: string;
|
|
2068
|
-
}>;
|
|
2069
|
-
timestamp: string;
|
|
2070
|
-
}>;
|
|
2071
|
-
/** Import the complete native transcript from another OpenCode session in this box. */
|
|
2072
|
-
importFromSessionId?: string;
|
|
2073
|
-
/** Workspace conversations survive idle-session collection until explicitly deleted. */
|
|
2074
|
-
retention?: "idle" | "workspace";
|
|
2075
|
-
/** Stable caller-supplied idempotency key. Repeating create with the same
|
|
2076
|
-
* id returns the existing session without creating another workspace or
|
|
2077
|
-
* backend session. Omit to let the runtime mint a random id. */
|
|
2078
|
-
sessionId?: string;
|
|
1988
|
+
| "unknown";
|
|
1989
|
+
interface DurablePlanSnapshot {
|
|
1990
|
+
id: string;
|
|
1991
|
+
revision: number;
|
|
2079
1992
|
title?: string;
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
* runtime's configured default backend. */
|
|
2083
|
-
backend?: BackendConfig;
|
|
2084
|
-
}
|
|
2085
|
-
/** Backend credentials forwarded to the platform if a sandbox must restart. */
|
|
2086
|
-
interface SessionBackendCredentials {
|
|
2087
|
-
apiKey: string;
|
|
2088
|
-
baseUrl?: string;
|
|
1993
|
+
body: string;
|
|
1994
|
+
submittedAt: string;
|
|
2089
1995
|
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
1996
|
+
type DurablePlan = DurablePlanSnapshot & {
|
|
1997
|
+
/** Canonical original source turn of this exact authenticated plan revision. */sourceTurnId: string;
|
|
1998
|
+
} & ({
|
|
1999
|
+
status: "pending";
|
|
2094
2000
|
} | {
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
state: {
|
|
2098
|
-
status: "pending" | "running" | "completed" | "failed";
|
|
2099
|
-
input?: unknown;
|
|
2100
|
-
output?: unknown;
|
|
2101
|
-
};
|
|
2001
|
+
status: "approved";
|
|
2002
|
+
decidedAt: string;
|
|
2102
2003
|
} | {
|
|
2103
|
-
|
|
2004
|
+
status: "rejected";
|
|
2005
|
+
decidedAt: string;
|
|
2006
|
+
feedback: string;
|
|
2104
2007
|
} | {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2008
|
+
status: "superseded";
|
|
2009
|
+
supersededAt: string;
|
|
2010
|
+
supersededByPlanId: string;
|
|
2011
|
+
} | {
|
|
2012
|
+
status: "withdrawn";
|
|
2013
|
+
withdrawnAt: string;
|
|
2014
|
+
reason: string;
|
|
2015
|
+
});
|
|
2016
|
+
interface DurablePlanDecisionOptions {
|
|
2017
|
+
/** Caller prepares and dispatches the existing follow-up with fresh grants and pins. */
|
|
2018
|
+
followUp?: {
|
|
2019
|
+
mode: "caller";
|
|
2116
2020
|
};
|
|
2117
|
-
|
|
2021
|
+
}
|
|
2022
|
+
interface DurablePlanFollowUpResume {
|
|
2023
|
+
/** Original native source turn; join immutable caller profile context using this ID. */
|
|
2024
|
+
sourceTurnId: string;
|
|
2025
|
+
continuation: PlanContinuation;
|
|
2026
|
+
/** Transient existing lease-bound admission nonce; never persist or log it. */
|
|
2027
|
+
credential: string;
|
|
2028
|
+
callbackUrl: string;
|
|
2029
|
+
expiresAt: string;
|
|
2030
|
+
}
|
|
2031
|
+
/** Fields accepted only on a message/preparation, never on session creation. */
|
|
2032
|
+
type TurnBackendConfig = Partial<BackendConfig> & {
|
|
2033
|
+
planContinuation?: PlanContinuation;
|
|
2118
2034
|
};
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
expectedPublicProfileRevision?: {
|
|
2128
|
-
workspacePlanDigest: `sha256:${string}`;
|
|
2129
|
-
materializedDigest: `sha256:${string}`;
|
|
2130
|
-
launchDigest: string;
|
|
2131
|
-
};
|
|
2132
|
-
/** Executor-only opaque receipt for a secret-bearing native revision. */
|
|
2133
|
-
expectedSecretProfileReceipt?: `hmac-sha256:${string}`;
|
|
2134
|
-
/** Router quote for a warm OpenCode turn with a total output ceiling. */
|
|
2135
|
-
managedQuoteVersion?: string;
|
|
2136
|
-
/** Use the sandbox's managed model credential for this turn only. */
|
|
2137
|
-
managedModelCredential?: true;
|
|
2138
|
-
/** Exact caller-owned execution identity for canonical cancellation. */
|
|
2139
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2140
|
-
/** Absolute UTC deadline for admitting the first native provider call. */
|
|
2141
|
-
admissionDeadline?: string;
|
|
2142
|
-
/** Execution time limit in milliseconds; a positive integer bounded by the runtime deployment ceiling. */
|
|
2143
|
-
ttlMs?: number;
|
|
2144
|
-
parts: SessionMessageInputPart[];
|
|
2145
|
-
system?: string;
|
|
2146
|
-
agent?: string;
|
|
2147
|
-
model?: {
|
|
2148
|
-
providerId: string;
|
|
2149
|
-
modelId: string;
|
|
2035
|
+
interface DurablePlanDecisionResult {
|
|
2036
|
+
plan: DurablePlan;
|
|
2037
|
+
followUp: {
|
|
2038
|
+
turnId: string;
|
|
2039
|
+
state: "awaiting_caller" | "queued" | "leased" | "started" | "completed" | "failed";
|
|
2040
|
+
mode?: "caller";
|
|
2041
|
+
executionId?: string;
|
|
2042
|
+
resume?: DurablePlanFollowUpResume;
|
|
2150
2043
|
};
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
interactions?: BackendConfig["interactions"];
|
|
2154
|
-
/** Run this turn with every provider tool disabled (OpenCode). */
|
|
2155
|
-
disableTools?: true;
|
|
2156
|
-
/**
|
|
2157
|
-
* Bound this turn to N upstream model calls (1-64). The runtime's model
|
|
2158
|
-
* proxy counts and enforces them; a turn it cannot count is refused. The
|
|
2159
|
-
* completed result reports `modelCalls`.
|
|
2160
|
-
*/
|
|
2161
|
-
maxModelCalls?: number;
|
|
2044
|
+
/** True when the server replayed a decision it had already recorded. */
|
|
2045
|
+
idempotent: boolean;
|
|
2162
2046
|
}
|
|
2163
|
-
/**
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
/** Receipt returned after a session message is accepted for processing. */
|
|
2174
|
-
interface SentSessionMessage {
|
|
2175
|
-
info: {
|
|
2176
|
-
id: string;
|
|
2177
|
-
role: "assistant";
|
|
2178
|
-
timestamp: string;
|
|
2179
|
-
};
|
|
2180
|
-
parts: [];
|
|
2181
|
-
userMessageId: string;
|
|
2182
|
-
processing: true;
|
|
2183
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2184
|
-
}
|
|
2185
|
-
/** Canonical portable profile attached to a task session. */
|
|
2186
|
-
type TaskSessionProfile = AgentProfile & {
|
|
2187
|
-
name: string;
|
|
2188
|
-
};
|
|
2189
|
-
/** Options for creating an isolated background task session. */
|
|
2190
|
-
interface CreateTaskSessionOptions {
|
|
2191
|
-
sessionId: string;
|
|
2192
|
-
backend: BackendConfig;
|
|
2193
|
-
title: string;
|
|
2194
|
-
profile?: TaskSessionProfile;
|
|
2195
|
-
parentSessionId?: string;
|
|
2196
|
-
isolateFileWrites?: boolean;
|
|
2197
|
-
}
|
|
2198
|
-
/** Task-session metadata returned at creation time. */
|
|
2199
|
-
interface TaskSessionInfo {
|
|
2200
|
-
id: string;
|
|
2201
|
-
title?: string;
|
|
2202
|
-
parentSessionId?: string;
|
|
2203
|
-
worktreeInfo?: {
|
|
2204
|
-
worktreePath: string;
|
|
2205
|
-
branchName: string;
|
|
2206
|
-
baseCommitSha: string;
|
|
2207
|
-
};
|
|
2208
|
-
profile?: TaskSessionProfile;
|
|
2209
|
-
}
|
|
2210
|
-
/** One changed file in an isolated task session. */
|
|
2211
|
-
interface TaskSessionFileChange {
|
|
2212
|
-
file: string;
|
|
2213
|
-
operation: "added" | "modified" | "deleted";
|
|
2214
|
-
additions: number;
|
|
2215
|
-
deletions: number;
|
|
2216
|
-
}
|
|
2217
|
-
/** Current diff and commit history for an isolated task session. */
|
|
2218
|
-
interface TaskSessionChanges {
|
|
2219
|
-
sessionId: string;
|
|
2220
|
-
files: TaskSessionFileChange[];
|
|
2221
|
-
diff: string;
|
|
2222
|
-
commits: Array<{
|
|
2223
|
-
sha: string;
|
|
2224
|
-
message: string;
|
|
2225
|
-
date: string;
|
|
2226
|
-
}>;
|
|
2227
|
-
worktreeInfo: {
|
|
2228
|
-
worktreePath: string;
|
|
2229
|
-
branchName: string;
|
|
2230
|
-
baseCommitSha: string;
|
|
2231
|
-
headCommitSha?: string;
|
|
2232
|
-
};
|
|
2047
|
+
/**
|
|
2048
|
+
* A tool the agent invoked during a run. `isError` flags a failed call
|
|
2049
|
+
* (errored, timed out, or rejected — e.g. a hub approval gate). Failed tools
|
|
2050
|
+
* are recorded, not dropped, so callers can inspect what the agent attempted.
|
|
2051
|
+
*/
|
|
2052
|
+
interface AgentToolInvocation {
|
|
2053
|
+
toolName: string;
|
|
2054
|
+
input?: unknown;
|
|
2055
|
+
result?: unknown;
|
|
2056
|
+
isError?: boolean;
|
|
2233
2057
|
}
|
|
2234
|
-
/**
|
|
2235
|
-
|
|
2058
|
+
/**
|
|
2059
|
+
* A hub approval gate the agent hit mid-run. Present on a result when
|
|
2060
|
+
* `status === "blocked_on_approval"`. Approve with the CLI
|
|
2061
|
+
* (`tangle hub approvals approve <approvalId>`) or the hub SDK, then re-run.
|
|
2062
|
+
*/
|
|
2063
|
+
interface AgentApprovalRequirement {
|
|
2064
|
+
/**
|
|
2065
|
+
* Approval id to act on. `undefined` when the in-sandbox hub bridge did not
|
|
2066
|
+
* preserve the structured approval object — surfaced honestly rather than
|
|
2067
|
+
* invented; inspect `message` in that case.
|
|
2068
|
+
*/
|
|
2069
|
+
approvalId?: string;
|
|
2070
|
+
/** Hub connection the gated tool belongs to, when known. */
|
|
2071
|
+
connectionId?: string;
|
|
2072
|
+
/** The tool error message that surfaced the gate. */
|
|
2236
2073
|
message?: string;
|
|
2237
|
-
files?: string[];
|
|
2238
2074
|
}
|
|
2239
|
-
/**
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2075
|
+
/**
|
|
2076
|
+
* A question the agent asked mid-run. Present on a result when
|
|
2077
|
+
* `status === "awaiting_question"`. Answer via
|
|
2078
|
+
* `box.session(id).answer(questionId, { [field]: value })`, then re-run.
|
|
2079
|
+
*/
|
|
2080
|
+
interface AgentQuestionRequest {
|
|
2081
|
+
/** Exact interaction id to pass as the first argument to `session.answer`. */
|
|
2082
|
+
questionId: string;
|
|
2083
|
+
/** The questions payload the agent emitted (prompt + options per entry). */
|
|
2084
|
+
questions: unknown;
|
|
2245
2085
|
}
|
|
2246
2086
|
/**
|
|
2247
|
-
*
|
|
2087
|
+
* Token usage counts for a single agent run. All counts are whole and
|
|
2088
|
+
* non-negative; a runtime that reports only one side leaves the other at 0.
|
|
2089
|
+
*
|
|
2090
|
+
* The three prompt-side fields are DISJOINT and additive:
|
|
2091
|
+
* `inputTokens + cacheReadTokens + cacheWriteTokens` is the size of the prompt
|
|
2092
|
+
* the model saw, and each term bills at its own rate. `inputTokens` alone is
|
|
2093
|
+
* the freshly billed tail — on a warm agent loop with a stable prefix it is a
|
|
2094
|
+
* small fraction of the context, so reading it as "context size" understates
|
|
2095
|
+
* the prompt by the cached share, and pricing it as the whole prompt
|
|
2096
|
+
* overcharges by the same amount.
|
|
2097
|
+
*
|
|
2098
|
+
* The cache fields are optional because absence is meaningful: a runtime that
|
|
2099
|
+
* reported no cache information at all is UNMETERED, which is not the same
|
|
2100
|
+
* fact as a measured zero.
|
|
2248
2101
|
*/
|
|
2249
|
-
interface
|
|
2250
|
-
/**
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
/**
|
|
2256
|
-
|
|
2102
|
+
interface TokenUsage {
|
|
2103
|
+
/** Prompt tokens billed at the full input rate: the uncached tail. */
|
|
2104
|
+
inputTokens: number;
|
|
2105
|
+
outputTokens: number;
|
|
2106
|
+
/** Prompt tokens served from the provider's prompt cache. */
|
|
2107
|
+
cacheReadTokens?: number;
|
|
2108
|
+
/** Prompt tokens written into the provider's prompt cache on this run. */
|
|
2109
|
+
cacheWriteTokens?: number;
|
|
2257
2110
|
}
|
|
2258
|
-
|
|
2259
|
-
interface SessionResultOptions {
|
|
2111
|
+
interface PromptResult {
|
|
2260
2112
|
/**
|
|
2261
|
-
*
|
|
2262
|
-
*
|
|
2263
|
-
*
|
|
2264
|
-
*
|
|
2113
|
+
* Whether the run succeeded. Shorthand for `status === "success"`: true only
|
|
2114
|
+
* when the run reached a terminal event with no run-level error and no failed
|
|
2115
|
+
* tool. Text presence is not required unless `requireVisibleAssistantOutput`
|
|
2116
|
+
* is set and no visible output was produced.
|
|
2265
2117
|
*/
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
interface SessionInterruptOptions {
|
|
2118
|
+
success: boolean;
|
|
2119
|
+
/** Granular run outcome. */
|
|
2120
|
+
status: AgentRunStatus;
|
|
2270
2121
|
/**
|
|
2271
|
-
* Runtime execution
|
|
2122
|
+
* Runtime execution that produced this result.
|
|
2272
2123
|
*
|
|
2273
|
-
*
|
|
2274
|
-
*
|
|
2124
|
+
* Preserve this value when a session may receive another turn: passing it
|
|
2125
|
+
* to `session.result({ executionId })` or
|
|
2126
|
+
* `session.interrupt({ executionId })` keeps the later operation bound to
|
|
2127
|
+
* this run instead of whichever run is newest at call time.
|
|
2275
2128
|
*/
|
|
2276
2129
|
executionId?: string;
|
|
2130
|
+
/** Agent's response text */
|
|
2131
|
+
response?: string;
|
|
2132
|
+
/** Error message when the run did not succeed */
|
|
2133
|
+
error?: string;
|
|
2134
|
+
/** Machine-readable error code from the runtime, e.g. `empty_visible_output`. */
|
|
2135
|
+
errorCode?: string;
|
|
2136
|
+
/** Native HTTP failure status when the provider reported it. */
|
|
2137
|
+
statusCode?: number;
|
|
2138
|
+
/** Tool calls the agent made this run, including failures (`isError`). */
|
|
2139
|
+
toolInvocations?: AgentToolInvocation[];
|
|
2140
|
+
/** Set when `status === "blocked_on_approval"`. */
|
|
2141
|
+
approval?: AgentApprovalRequirement;
|
|
2142
|
+
/** Set when `status === "awaiting_question"`. */
|
|
2143
|
+
question?: AgentQuestionRequest;
|
|
2144
|
+
/** Canonical request for any interaction that still needs a response. */
|
|
2145
|
+
interaction?: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
2146
|
+
/** Set when `status === "awaiting_plan_decision"`. */
|
|
2147
|
+
plan?: DurablePlanSnapshot;
|
|
2148
|
+
/**
|
|
2149
|
+
* Trace id this prompt sent as `x-tangle-trace-id`: the caller's
|
|
2150
|
+
* `PromptOptions.traceId`, or one the SDK minted. The Sandbox API, the
|
|
2151
|
+
* orchestrator's proxy log, the runtime and the router's dispatch rows all
|
|
2152
|
+
* record the same value, so it finds every hop of this turn.
|
|
2153
|
+
*/
|
|
2154
|
+
traceId?: string;
|
|
2155
|
+
/** Duration in milliseconds */
|
|
2156
|
+
durationMs: number;
|
|
2157
|
+
/** Token usage */
|
|
2158
|
+
usage?: TokenUsage;
|
|
2159
|
+
/** Provider-reported model cost in USD, when the runtime emitted it. */
|
|
2160
|
+
costUsd?: number;
|
|
2161
|
+
/**
|
|
2162
|
+
* A bounded turn's upstream model calls as the runtime's model proxy
|
|
2163
|
+
* relayed them (`maxModelCalls`), never the harness's own report.
|
|
2164
|
+
*/
|
|
2165
|
+
modelCalls?: {
|
|
2166
|
+
limit: number;
|
|
2167
|
+
count: number;
|
|
2168
|
+
/**
|
|
2169
|
+
* The model each counted call's upstream response named, in call order;
|
|
2170
|
+
* shorter than `count` when a response named none. The requested model
|
|
2171
|
+
* is `effectiveBackend.model`, a separate value.
|
|
2172
|
+
*/
|
|
2173
|
+
observedModels?: string[];
|
|
2174
|
+
};
|
|
2277
2175
|
}
|
|
2176
|
+
type PromptInputPart = {
|
|
2177
|
+
type: "text";
|
|
2178
|
+
text: string;
|
|
2179
|
+
} | {
|
|
2180
|
+
type: "image";
|
|
2181
|
+
filename?: string;
|
|
2182
|
+
mediaType?: string;
|
|
2183
|
+
url?: string;
|
|
2184
|
+
path?: string;
|
|
2185
|
+
} | {
|
|
2186
|
+
type: "file";
|
|
2187
|
+
filename: string;
|
|
2188
|
+
mediaType?: string;
|
|
2189
|
+
url: string;
|
|
2190
|
+
};
|
|
2278
2191
|
/**
|
|
2279
|
-
* Options for
|
|
2192
|
+
* Options for sending a prompt.
|
|
2280
2193
|
*/
|
|
2281
|
-
interface
|
|
2282
|
-
/**
|
|
2283
|
-
* that session is in flight is a lookup, not a second run — a
|
|
2284
|
-
* concurrency guard, not a retry key. Once the turn finishes (or if the
|
|
2285
|
-
* session was evicted) the same call dispatches again; pass `turnId` for
|
|
2286
|
-
* retry safety that outlives the turn. */
|
|
2194
|
+
interface PromptOptions {
|
|
2195
|
+
/** Session ID for conversation continuity */
|
|
2287
2196
|
sessionId?: string;
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
interface ListMessagesOptions {
|
|
2294
|
-
/** Session id whose messages to return (required). */
|
|
2295
|
-
sessionId: string;
|
|
2296
|
-
/** Max entries, default 100. Server caps at 1000. */
|
|
2297
|
-
limit?: number;
|
|
2298
|
-
/** Skip this many entries from the start. */
|
|
2299
|
-
offset?: number;
|
|
2300
|
-
/** Only return messages newer than this Unix-ms timestamp. */
|
|
2301
|
-
since?: number;
|
|
2302
|
-
}
|
|
2303
|
-
/**
|
|
2304
|
-
* Options for `box.session(id).fork()` — create a new session from an
|
|
2305
|
-
* existing conversation, optionally at a message boundary.
|
|
2306
|
-
*/
|
|
2307
|
-
interface SessionForkOptions {
|
|
2308
|
-
/** Fork at this message boundary. */
|
|
2309
|
-
messageId?: string;
|
|
2310
|
-
/** Target backend type for cross-backend forks. Defaults to parent backend. */
|
|
2311
|
-
targetBackend?: BackendType;
|
|
2312
|
-
/** Model override for the target backend. */
|
|
2313
|
-
targetModel?: {
|
|
2314
|
-
provider?: string;
|
|
2315
|
-
model?: string;
|
|
2316
|
-
apiKey?: string;
|
|
2317
|
-
baseUrl?: string;
|
|
2197
|
+
/** Resume one native conversation from the verified source snapshot. */
|
|
2198
|
+
nativeResume?: {
|
|
2199
|
+
harness: "claude-code" | "codex";
|
|
2200
|
+
nativeSessionId: string;
|
|
2201
|
+
sourceCheckpointId: string;
|
|
2318
2202
|
};
|
|
2319
2203
|
/**
|
|
2320
|
-
*
|
|
2321
|
-
*
|
|
2204
|
+
* Per-turn model id, forwarded to the runtime as `backend.model.model`.
|
|
2205
|
+
* Accepts a provider-prefixed slug ("zai/glm-4.7", "openai/gpt-5-mini")
|
|
2206
|
+
* or a bare id ("gpt-5-mini") the router resolves against the sandbox's
|
|
2207
|
+
* configured provider.
|
|
2208
|
+
*
|
|
2209
|
+
* This field exists because its absence produced silent model
|
|
2210
|
+
* substitution: `{ model: "gpt-5-mini" }` was an unknown option, the SDK
|
|
2211
|
+
* dropped it before the request left the process, and the sandbox served
|
|
2212
|
+
* the turn on its provisioned default model with no error anywhere.
|
|
2213
|
+
* A per-turn model request must either reach the wire or fail loud —
|
|
2214
|
+
* so a conflict with an explicit `backend.model.model` throws
|
|
2215
|
+
* `ValidationError` instead of silently preferring one.
|
|
2216
|
+
*
|
|
2217
|
+
* Equivalent to `backend: { model: { model } }`; use `backend.model` when
|
|
2218
|
+
* you also need provider/apiKey/baseUrl.
|
|
2219
|
+
*/
|
|
2220
|
+
model?: string;
|
|
2221
|
+
/**
|
|
2222
|
+
* Per-run backend override.
|
|
2223
|
+
*
|
|
2224
|
+
* Set `backend.model` for a model override and `backend.profile` for an
|
|
2225
|
+
* inline provider-neutral `AgentProfile`.
|
|
2226
|
+
* Same-runtime overrides retain unspecified defaults. Changing the harness,
|
|
2227
|
+
* provider, or base URL replaces the default backend configuration.
|
|
2322
2228
|
*/
|
|
2323
|
-
files?: string[];
|
|
2324
|
-
}
|
|
2325
|
-
/**
|
|
2326
|
-
* One message on a session — user, assistant, or system. The metadata
|
|
2327
|
-
* field carries the durability marker set by the sidecar:
|
|
2328
|
-
* - `status: "streaming"` and no `completed`/`interrupted` flag → turn
|
|
2329
|
-
* is in flight, OR the sidecar died before stamping a marker
|
|
2330
|
-
* (SIGKILL, OOM). The partial parts are the partial assistant
|
|
2331
|
-
* content the recorder flushed before death.
|
|
2332
|
-
* - `completed: true` + `completedAt` → turn finished normally. If a
|
|
2333
|
-
* `turnId` was supplied, its result is cached for idempotent retry.
|
|
2334
|
-
* - `interrupted: true` + `interruptedAt` + `interruptReason` → graceful
|
|
2335
|
-
* abort, timeout, or upstream error. Partial content is preserved
|
|
2336
|
-
* but not billable as a completion.
|
|
2337
|
-
*/
|
|
2338
|
-
interface SessionMessage {
|
|
2339
|
-
id: string;
|
|
2340
|
-
role: "user" | "assistant" | "system";
|
|
2341
|
-
/** ISO timestamp string. */
|
|
2342
|
-
timestamp: string;
|
|
2343
|
-
/** Message parts (text, tool calls, reasoning, files). Same shape as
|
|
2344
|
-
* events emitted by `streamPrompt`. */
|
|
2345
|
-
parts: unknown[];
|
|
2346
|
-
/** Durability + idempotency metadata. See class doc above. */
|
|
2347
|
-
metadata?: {
|
|
2348
|
-
status?: "streaming" | "completed" | "interrupted";
|
|
2349
|
-
completed?: boolean;
|
|
2350
|
-
completedAt?: string;
|
|
2351
|
-
interrupted?: boolean;
|
|
2352
|
-
interruptedAt?: string;
|
|
2353
|
-
interruptReason?: string;
|
|
2354
|
-
turnId?: string;
|
|
2355
|
-
startedAt?: string;
|
|
2356
|
-
[extra: string]: unknown;
|
|
2357
|
-
};
|
|
2358
|
-
}
|
|
2359
|
-
/**
|
|
2360
|
-
* Returned by `box.findCompletedTurn()` — the cached result of a
|
|
2361
|
-
* previously-completed turn, keyed on the caller's `turnId`.
|
|
2362
|
-
*/
|
|
2363
|
-
interface CompletedTurnResult {
|
|
2364
|
-
turnId: string;
|
|
2365
|
-
sessionId: string;
|
|
2366
|
-
/** ISO timestamp when the turn finished. */
|
|
2367
|
-
completedAt: string;
|
|
2368
|
-
/** The cached AgentExecutionResult-shape payload (text, toolInvocations,
|
|
2369
|
-
* sessionId, tokenUsage, etc.). */
|
|
2370
|
-
result: CompletedTurnPayload;
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* The cached result of a completed turn. `effectiveBackend` is the provider
|
|
2374
|
-
* and model that served the turn, the same field the live `result` and `done`
|
|
2375
|
-
* events carry. It is absent when the runtime did not record it, for example
|
|
2376
|
-
* on a record written before the runtime stored attribution: treat that as
|
|
2377
|
-
* unknown, never as the session's default model.
|
|
2378
|
-
*/
|
|
2379
|
-
type CompletedTurnPayload = Record<string, unknown> & {
|
|
2380
|
-
effectiveBackend?: EffectiveBackend;
|
|
2381
|
-
};
|
|
2382
|
-
/**
|
|
2383
|
-
* Returned by `box.dispatchPrompt()` — minimum the caller needs to track
|
|
2384
|
-
* the session afterward. The sandbox keeps running the prompt; use
|
|
2385
|
-
* `box.session(sessionId)` to follow it.
|
|
2386
|
-
*/
|
|
2387
|
-
interface DispatchedSession {
|
|
2388
|
-
/** Session id (either the one the caller supplied or one the sandbox
|
|
2389
|
-
* minted). */
|
|
2390
|
-
sessionId: string;
|
|
2391
|
-
/** Runtime execution id when the admission event supplied one. */
|
|
2392
|
-
executionId?: string;
|
|
2393
|
-
/** Exact run identity accepted by the runtime for canonical cancellation. */
|
|
2394
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2395
|
-
/** Lifecycle state at the moment dispatch returned. */
|
|
2396
|
-
status: SessionStatus;
|
|
2397
|
-
/** True when a session with the supplied id already existed. On its own
|
|
2398
|
-
* this says nothing about whether the prompt ran — an existing terminal
|
|
2399
|
-
* session still accepts a new turn. Read `dispatched` for that. */
|
|
2400
|
-
alreadyExisted: boolean;
|
|
2401
|
-
/** Whether this call actually dispatched the prompt. `false` means the
|
|
2402
|
-
* call was a no-op because the turn is already in flight (session
|
|
2403
|
-
* `queued`/`running`) or already finished (`turnId` hit the completed-
|
|
2404
|
-
* turn cache) — the prompt was deliberately not sent, and no new events
|
|
2405
|
-
* will appear on the session bus for it. */
|
|
2406
|
-
dispatched: boolean;
|
|
2407
|
-
}
|
|
2408
|
-
/**
|
|
2409
|
-
* Options for `box.driveTurn()` — one settle/poll/admit pass over a detached
|
|
2410
|
-
* turn. The first pass creates a session with the requested backend and admits
|
|
2411
|
-
* the turn through `SandboxSession.sendMessage()`. The session owns execution
|
|
2412
|
-
* and gateway replay after the request returns.
|
|
2413
|
-
*/
|
|
2414
|
-
/** Repeated messages in one native session, unlike the one-session-per-task driver. */
|
|
2415
|
-
interface ConversationTurnOptions {
|
|
2416
|
-
sessionId: string;
|
|
2417
|
-
turnId: string;
|
|
2418
|
-
/** Router quote included in the durable admission request. */
|
|
2419
|
-
managedQuoteVersion?: string;
|
|
2420
|
-
/** Use the sandbox's managed model credential for this turn only. */
|
|
2421
|
-
managedModelCredential?: true;
|
|
2422
|
-
/** Per-turn backend, profile, runtime attachments, and interaction settings. */
|
|
2423
2229
|
backend?: Partial<BackendConfig>;
|
|
2424
|
-
/**
|
|
2230
|
+
/** Public digest returned by prepareSecretProfileRevision for this run. */
|
|
2425
2231
|
expectedPublicProfileRequestDigest?: `sha256:${string}`;
|
|
2426
|
-
/**
|
|
2427
|
-
expectedPublicProfileRevision?: {
|
|
2428
|
-
workspacePlanDigest: `sha256:${string}`;
|
|
2429
|
-
materializedDigest: `sha256:${string}`;
|
|
2430
|
-
launchDigest: string;
|
|
2431
|
-
};
|
|
2432
|
-
/** Executor-only opaque receipt for a secret-bearing native revision. */
|
|
2232
|
+
/** Private native revision receipt for an isolated secret profile run. */
|
|
2433
2233
|
expectedSecretProfileReceipt?: `hmac-sha256:${string}`;
|
|
2434
|
-
/** Model shorthand; conflicts with backend.model.model are rejected. */
|
|
2435
|
-
model?: string;
|
|
2436
|
-
/** Exact execution identity retained by admission and cancellation. */
|
|
2437
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2438
|
-
/** Absolute UTC deadline for admitting the first native provider call. */
|
|
2439
|
-
admissionDeadline?: string;
|
|
2440
|
-
/** False is a passive settlement/cancellation lookup; never admits new work. */
|
|
2441
|
-
allowDispatch?: boolean;
|
|
2442
|
-
/** Run this turn with every provider tool disabled (OpenCode). */
|
|
2443
|
-
disableTools?: true;
|
|
2444
2234
|
/**
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2235
|
+
* Per-run budget in milliseconds. Bounds the client-side stream and is
|
|
2236
|
+
* forwarded to the runtime, where the backend's first-output watchdog
|
|
2237
|
+
* honors it. It sets the execution's time limit only when `ttlMs` is unset,
|
|
2238
|
+
* and is then subject to the same deployment maximum as `ttlMs`.
|
|
2448
2239
|
*/
|
|
2449
|
-
maxModelCalls?: number;
|
|
2450
2240
|
timeoutMs?: number;
|
|
2241
|
+
/**
|
|
2242
|
+
* Execution time limit in milliseconds. A positive integer; the runtime
|
|
2243
|
+
* cancels the execution when it elapses and the terminal error names the
|
|
2244
|
+
* limit. A value above the deployment's maximum (six hours by default) is
|
|
2245
|
+
* refused with `EXECUTION_TTL_EXCEEDS_LIMIT` before the run starts, by the
|
|
2246
|
+
* sandbox API on proxied calls and by the runtime itself on every call. The
|
|
2247
|
+
* code is the same from both; the surrounding error body follows each
|
|
2248
|
+
* service's own envelope, so read the code rather than the shape. Unset, the
|
|
2249
|
+
* runtime falls back to `timeoutMs`, then to its one-hour default.
|
|
2250
|
+
*
|
|
2251
|
+
* This limit governs how long the run may LIVE. A blocking call that waits
|
|
2252
|
+
* for the run is separately bounded by the runtime's one-hour request
|
|
2253
|
+
* timeout; a longer limit needs a streaming or session-message call, which
|
|
2254
|
+
* answers before the run finishes.
|
|
2255
|
+
*/
|
|
2256
|
+
ttlMs?: number;
|
|
2257
|
+
/** Additional context */
|
|
2258
|
+
context?: Record<string, unknown>;
|
|
2259
|
+
/**
|
|
2260
|
+
* Exact run identity bound to this first dispatch. The runtime stores this
|
|
2261
|
+
* reference with the live execution so delayed control operations cannot
|
|
2262
|
+
* target a newer run that reused the same execution id.
|
|
2263
|
+
*/
|
|
2264
|
+
runControlRef?: AgentExactRunControlRef;
|
|
2265
|
+
/** Fail chat-like runs that finish with no text or renderable interaction. */
|
|
2266
|
+
requireVisibleAssistantOutput?: boolean;
|
|
2267
|
+
/** AbortSignal for cancellation */
|
|
2451
2268
|
signal?: AbortSignal;
|
|
2452
|
-
wallCapMs?: number;
|
|
2453
2269
|
/**
|
|
2454
|
-
* Trace id sent as `x-tangle-trace-id` on this
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2270
|
+
* Trace id sent as `x-tangle-trace-id` on every request this prompt makes,
|
|
2271
|
+
* including reconnects. Pass your own turn or request id (8-200 letters,
|
|
2272
|
+
* digits, `_` or `-`) to join platform records to yours; omit it and the
|
|
2273
|
+
* SDK mints one. `PromptResult.traceId` returns the value used.
|
|
2457
2274
|
*/
|
|
2458
2275
|
traceId?: string;
|
|
2459
|
-
|
|
2460
|
-
|
|
2276
|
+
/**
|
|
2277
|
+
* Stable execution id for tracing a first dispatch or selecting an existing
|
|
2278
|
+
* execution for replay. Forwarded as `X-Execution-ID` on a first dispatch.
|
|
2279
|
+
* When combined with `lastEventId`, the SDK replays the existing execution
|
|
2280
|
+
* without sending the prompt again. An execution ID alone does not make a
|
|
2281
|
+
* repeated POST idempotent; use `turnId` for application-level retries.
|
|
2282
|
+
* Omit to let the SDK read the id from `execution.started` for in-call
|
|
2283
|
+
* reconnects.
|
|
2284
|
+
*/
|
|
2461
2285
|
executionId?: string;
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
*
|
|
2474
|
-
*
|
|
2475
|
-
*
|
|
2476
|
-
|
|
2477
|
-
/** Turn idempotency key for the platform's completed-turn cache.
|
|
2478
|
-
* Defaults to `sessionId`, which is correct for the one-turn-per-
|
|
2479
|
-
* session shape detached drivers use. */
|
|
2286
|
+
/**
|
|
2287
|
+
* Last event id the caller has already acknowledged. Requires `executionId`;
|
|
2288
|
+
* the SDK replays strictly after this id without dispatching a new prompt.
|
|
2289
|
+
* Omit on the first attempt.
|
|
2290
|
+
*/
|
|
2291
|
+
lastEventId?: string;
|
|
2292
|
+
/**
|
|
2293
|
+
* Caller-supplied turn idempotency key. When set, a retry with the
|
|
2294
|
+
* same `turnId` on the same `sessionId` short-circuits to the cached
|
|
2295
|
+
* result instead of re-issuing the upstream LLM call. Generate a
|
|
2296
|
+
* fresh `turnId` per logical attempt (a different user message gets
|
|
2297
|
+
* a new id) and reuse it only for retries of the same intent
|
|
2298
|
+
* (Stripe-style idempotency). Combine with `box.findCompletedTurn`
|
|
2299
|
+
* to check completion before re-dispatching.
|
|
2300
|
+
*/
|
|
2480
2301
|
turnId?: string;
|
|
2481
|
-
/**
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
*
|
|
2491
|
-
*
|
|
2492
|
-
*
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2302
|
+
/**
|
|
2303
|
+
* Detach the run from this stream's lifetime. When true, the run never
|
|
2304
|
+
* ends because a reader went away: closing the generator does not cancel
|
|
2305
|
+
* it, and the platform keeps executing it and buffering its events so a
|
|
2306
|
+
* later reconnect can replay. Use for batch or queue workloads.
|
|
2307
|
+
*
|
|
2308
|
+
* Without it, ending the stream early (breaking out of the loop, aborting
|
|
2309
|
+
* `signal`, or letting `timeoutMs` elapse) cancels the run. A dropped
|
|
2310
|
+
* connection does not: the platform keeps an interactive run through a
|
|
2311
|
+
* disconnect grace window so this stream can rejoin it.
|
|
2312
|
+
* `dispatchPrompt` always sets this so fire-and-detach is safe by
|
|
2313
|
+
* construction.
|
|
2314
|
+
*/
|
|
2315
|
+
detach?: boolean;
|
|
2316
|
+
/**
|
|
2317
|
+
* How long the SDK keeps rejoining this execution while it is unreachable,
|
|
2318
|
+
* in milliseconds. A dropped stream is a transport event, not an outcome:
|
|
2319
|
+
* the SDK reconnects with capped exponential backoff (1s doubling to 30s)
|
|
2320
|
+
* and resumes after the last delivered event, without duplicates. Each
|
|
2321
|
+
* replay connection that reaches the execution restarts the window, so a
|
|
2322
|
+
* long run survives any number of platform deploys. When the window
|
|
2323
|
+
* elapses, or the sandbox stops, the stream ends with an `error` event
|
|
2324
|
+
* whose `code` is `STREAM_INTERRUPTED` and `outcome` is `unknown`, and no
|
|
2325
|
+
* `done`: rejoin later with `executionId` + `lastEventId`.
|
|
2326
|
+
* Default six hours; 0 disables reconnection.
|
|
2327
|
+
*/
|
|
2328
|
+
reconnectWindowMs?: number;
|
|
2502
2329
|
}
|
|
2503
2330
|
/**
|
|
2504
|
-
*
|
|
2505
|
-
* one pass. Discriminated on `state`:
|
|
2506
|
-
* - `completed` — the turn finished with a text payload; `result` is
|
|
2507
|
-
* the full cached AgentExecutionResult-shape record.
|
|
2508
|
-
* - Waiting states preserve the response request and original result.
|
|
2509
|
-
* - `running` — the session is queued or executing; re-invoke after a
|
|
2510
|
-
* delay of your choosing.
|
|
2511
|
-
* - `failed` — terminal and deterministic: a failed/cancelled session,
|
|
2512
|
-
* a wall-cap cancellation, or an invalid terminal result.
|
|
2513
|
-
* Re-invoking will not change the outcome.
|
|
2331
|
+
* SSE event from sandbox streaming.
|
|
2514
2332
|
*/
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
conflicts?: PublicProfileConflict[];
|
|
2333
|
+
interface SandboxEvent {
|
|
2334
|
+
/** Event type */
|
|
2335
|
+
type: string;
|
|
2336
|
+
/** Event data */
|
|
2337
|
+
data: Record<string, unknown> & {
|
|
2338
|
+
effectiveBackend?: EffectiveBackend; /** Stable sidecar session used by runtime interaction routes. */
|
|
2339
|
+
runtimeSessionId?: string; /** Sandbox that produced this event, stamped by the SDK at intake. */
|
|
2340
|
+
sandboxId?: string;
|
|
2524
2341
|
};
|
|
2342
|
+
/** Event ID */
|
|
2343
|
+
id?: string;
|
|
2344
|
+
}
|
|
2345
|
+
interface SandboxTraceEvent {
|
|
2346
|
+
type: "sandbox.lifecycle.snapshot" | "sandbox.runtime.snapshot" | "sandbox.usage.snapshot" | "sandbox.insight.summary";
|
|
2347
|
+
timestamp: string;
|
|
2348
|
+
sandboxId: string;
|
|
2349
|
+
durationMs?: number;
|
|
2350
|
+
attributes: Record<string, unknown>;
|
|
2351
|
+
}
|
|
2352
|
+
interface SandboxTraceExport {
|
|
2353
|
+
schemaVersion: "sandbox.trace.v1";
|
|
2354
|
+
traceId: string;
|
|
2355
|
+
sandboxId: string;
|
|
2356
|
+
exportedAt: string;
|
|
2357
|
+
timings: {
|
|
2358
|
+
observedLifecycleMs: number;
|
|
2359
|
+
observedRuntimeMs: number;
|
|
2360
|
+
idleObservedMs: number;
|
|
2361
|
+
};
|
|
2362
|
+
criticalPath: {
|
|
2363
|
+
durationMs: number;
|
|
2364
|
+
phases: Array<{
|
|
2365
|
+
name: string;
|
|
2366
|
+
durationMs: number;
|
|
2367
|
+
}>;
|
|
2368
|
+
};
|
|
2369
|
+
events: SandboxTraceEvent[];
|
|
2370
|
+
}
|
|
2371
|
+
interface SandboxIntelligenceEnvelope {
|
|
2372
|
+
schemaVersion: "sandbox.intelligence.v1";
|
|
2373
|
+
source: "sandbox-api";
|
|
2374
|
+
subject: {
|
|
2375
|
+
type: "sandbox";
|
|
2376
|
+
sandboxId: string;
|
|
2377
|
+
};
|
|
2378
|
+
billing: {
|
|
2379
|
+
billable: false;
|
|
2380
|
+
billedTo: "platform";
|
|
2381
|
+
costUsd: 0;
|
|
2382
|
+
reason: "deterministic_platform_insight";
|
|
2383
|
+
};
|
|
2384
|
+
metrics: Record<string, number>;
|
|
2385
|
+
signals: Array<{
|
|
2386
|
+
name: string;
|
|
2387
|
+
value: string | number | boolean;
|
|
2388
|
+
severity: "info" | "warn" | "critical";
|
|
2389
|
+
rationale: string;
|
|
2390
|
+
}>;
|
|
2391
|
+
recommendedActions: string[];
|
|
2392
|
+
}
|
|
2393
|
+
interface SandboxTraceBundle {
|
|
2394
|
+
trace: SandboxTraceExport;
|
|
2395
|
+
intelligence?: SandboxIntelligenceEnvelope;
|
|
2396
|
+
}
|
|
2397
|
+
interface SandboxTraceOptions {
|
|
2525
2398
|
/**
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
*/
|
|
2529
|
-
usage?: TokenUsage;
|
|
2530
|
-
/**
|
|
2531
|
-
* A bounded turn's upstream model calls as the runtime's model proxy
|
|
2532
|
-
* relayed them (`maxModelCalls`), never the harness's own report.
|
|
2399
|
+
* Include the platform-generated intelligence envelope. Defaults to false.
|
|
2400
|
+
* Set true when a customer wants generated insight with the raw trace export.
|
|
2533
2401
|
*/
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
count: number;
|
|
2537
|
-
/**
|
|
2538
|
-
* The model each counted call's upstream response named, in call order;
|
|
2539
|
-
* shorter than `count` when a response named none. The requested model
|
|
2540
|
-
* is `effectiveBackend.model`, a separate value.
|
|
2541
|
-
*/
|
|
2542
|
-
observedModels?: string[];
|
|
2543
|
-
};
|
|
2544
|
-
} | {
|
|
2545
|
-
state: "awaiting_plan_decision";
|
|
2546
|
-
plan: DurablePlanSnapshot;
|
|
2547
|
-
result: Record<string, unknown>;
|
|
2548
|
-
} | {
|
|
2549
|
-
state: "blocked_on_approval";
|
|
2550
|
-
approval: AgentApprovalRequirement;
|
|
2551
|
-
result: Record<string, unknown>;
|
|
2552
|
-
} | {
|
|
2553
|
-
state: "awaiting_question";
|
|
2554
|
-
question: AgentQuestionRequest;
|
|
2555
|
-
interaction?: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
2556
|
-
result: Record<string, unknown>;
|
|
2557
|
-
} | {
|
|
2558
|
-
state: "awaiting_interaction";
|
|
2559
|
-
interaction: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
2560
|
-
result: Record<string, unknown>;
|
|
2561
|
-
} | {
|
|
2562
|
-
state: "running"; /** When the session began executing, if the runtime reported it. */
|
|
2563
|
-
startedAt?: Date; /** Milliseconds since `startedAt` at the moment of the poll. */
|
|
2564
|
-
elapsedMs?: number;
|
|
2565
|
-
} | {
|
|
2566
|
-
state: "failed"; /** Human-readable reason the turn is deterministically failed. */
|
|
2567
|
-
error: string;
|
|
2568
|
-
};
|
|
2569
|
-
//#endregion
|
|
2570
|
-
//#region src/types/agents.d.ts
|
|
2402
|
+
includeIntelligence?: boolean;
|
|
2403
|
+
}
|
|
2571
2404
|
/**
|
|
2572
|
-
*
|
|
2405
|
+
* Subject types for an Intelligence Report.
|
|
2406
|
+
*
|
|
2407
|
+
* - `sandbox`: one container's run.
|
|
2408
|
+
* - `fleet`: one managed grouping of sandboxes. Add `subject.dispatchId`
|
|
2409
|
+
* to narrow to a single coordinated command within the fleet
|
|
2410
|
+
* (previously a standalone `dispatch` subject type — now expressed
|
|
2411
|
+
* as a fleet refinement).
|
|
2573
2412
|
*/
|
|
2413
|
+
type IntelligenceReportSubjectType = "sandbox" | "fleet";
|
|
2414
|
+
interface IntelligenceReport {
|
|
2415
|
+
jobId: string;
|
|
2416
|
+
subject: {
|
|
2417
|
+
type: IntelligenceReportSubjectType;
|
|
2418
|
+
id: string; /** Present when the report was narrowed to a single fleet dispatch. */
|
|
2419
|
+
dispatchId?: string;
|
|
2420
|
+
};
|
|
2421
|
+
mode: "deterministic" | "agentic";
|
|
2422
|
+
status: "queued" | "running" | "completed" | "failed";
|
|
2423
|
+
billing: {
|
|
2424
|
+
billable: boolean;
|
|
2425
|
+
billedTo: "platform" | "customer";
|
|
2426
|
+
costUsd: number;
|
|
2427
|
+
reason: string;
|
|
2428
|
+
budgetMaxUsd?: number;
|
|
2429
|
+
};
|
|
2430
|
+
result: Record<string, unknown> | null;
|
|
2431
|
+
error?: string;
|
|
2432
|
+
createdAt: string;
|
|
2433
|
+
updatedAt: string;
|
|
2434
|
+
completedAt?: string;
|
|
2435
|
+
}
|
|
2436
|
+
interface IntelligenceReportBudget {
|
|
2437
|
+
maxUsd?: number;
|
|
2438
|
+
billTo?: "customer" | "platform";
|
|
2439
|
+
}
|
|
2574
2440
|
/**
|
|
2575
|
-
*
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
* a stream that ended with no terminal event.
|
|
2580
|
-
* - `blocked_on_approval` — a tool hit a hub approval gate; resolve it, then
|
|
2581
|
-
* re-run. See {@link AgentApprovalRequirement}.
|
|
2582
|
-
* - `awaiting_question` — the agent asked a question and the turn ended without
|
|
2583
|
-
* an answer. See {@link AgentQuestionRequest}.
|
|
2584
|
-
* - `awaiting_interaction` — the agent emitted another canonical interaction
|
|
2585
|
-
* request and the turn ended without a response.
|
|
2441
|
+
* Time window for an intelligence report. Both bounds are millisecond
|
|
2442
|
+
* epochs. Omit `since` to mean "from the subject's first observation";
|
|
2443
|
+
* omit `until` to mean "now". `since` must be <= `until` when both are
|
|
2444
|
+
* set; the server enforces this at the schema layer.
|
|
2586
2445
|
*/
|
|
2587
|
-
|
|
2446
|
+
interface IntelligenceReportWindow {
|
|
2447
|
+
since?: number;
|
|
2448
|
+
until?: number;
|
|
2449
|
+
}
|
|
2588
2450
|
/**
|
|
2589
|
-
*
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2592
|
-
*
|
|
2451
|
+
* Comparison baseline. When present, the report includes an explicit
|
|
2452
|
+
* delta between the primary subject and this baseline. Must be the
|
|
2453
|
+
* same `type` as the primary subject — the analyzer rejects mixed
|
|
2454
|
+
* subject-type comparisons because the delta would be meaningless.
|
|
2455
|
+
*
|
|
2456
|
+
* `dispatchId` is only valid when `type === "fleet"`.
|
|
2593
2457
|
*/
|
|
2594
|
-
|
|
2595
|
-
|
|
2458
|
+
interface IntelligenceReportCompareTo {
|
|
2459
|
+
type: IntelligenceReportSubjectType;
|
|
2596
2460
|
id: string;
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
body: string;
|
|
2600
|
-
submittedAt: string;
|
|
2461
|
+
/** Narrow the baseline to a single dispatch within the fleet. */
|
|
2462
|
+
dispatchId?: string;
|
|
2601
2463
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
} | {
|
|
2614
|
-
status: "superseded";
|
|
2615
|
-
supersededAt: string;
|
|
2616
|
-
supersededByPlanId: string;
|
|
2617
|
-
} | {
|
|
2618
|
-
status: "withdrawn";
|
|
2619
|
-
withdrawnAt: string;
|
|
2620
|
-
reason: string;
|
|
2621
|
-
});
|
|
2622
|
-
interface DurablePlanDecisionOptions {
|
|
2623
|
-
/** Caller prepares and dispatches the existing follow-up with fresh grants and pins. */
|
|
2624
|
-
followUp?: {
|
|
2625
|
-
mode: "caller";
|
|
2626
|
-
};
|
|
2627
|
-
}
|
|
2628
|
-
interface DurablePlanFollowUpResume {
|
|
2629
|
-
/** Original native source turn; join immutable caller profile context using this ID. */
|
|
2630
|
-
sourceTurnId: string;
|
|
2631
|
-
continuation: PlanContinuation;
|
|
2632
|
-
/** Transient existing lease-bound admission nonce; never persist or log it. */
|
|
2633
|
-
credential: string;
|
|
2634
|
-
callbackUrl: string;
|
|
2635
|
-
expiresAt: string;
|
|
2636
|
-
}
|
|
2637
|
-
/** Fields accepted only on a message/preparation, never on session creation. */
|
|
2638
|
-
type TurnBackendConfig = Partial<BackendConfig> & {
|
|
2639
|
-
planContinuation?: PlanContinuation;
|
|
2640
|
-
};
|
|
2641
|
-
interface DurablePlanDecisionResult {
|
|
2642
|
-
plan: DurablePlan;
|
|
2643
|
-
followUp: {
|
|
2644
|
-
turnId: string;
|
|
2645
|
-
state: "awaiting_caller" | "queued" | "leased" | "started" | "completed" | "failed";
|
|
2646
|
-
mode?: "caller";
|
|
2647
|
-
executionId?: string;
|
|
2648
|
-
resume?: DurablePlanFollowUpResume;
|
|
2464
|
+
interface CreateIntelligenceReportOptions {
|
|
2465
|
+
subject: {
|
|
2466
|
+
type: IntelligenceReportSubjectType;
|
|
2467
|
+
id: string;
|
|
2468
|
+
/**
|
|
2469
|
+
* Narrow the analysis to a single coordinated command within a
|
|
2470
|
+
* fleet. Only valid when `type === "fleet"`.
|
|
2471
|
+
*/
|
|
2472
|
+
dispatchId?: string; /** Bound the analysis to a time window. */
|
|
2473
|
+
window?: IntelligenceReportWindow; /** Compare the primary subject against a same-type baseline. */
|
|
2474
|
+
compareTo?: IntelligenceReportCompareTo;
|
|
2649
2475
|
};
|
|
2650
|
-
|
|
2651
|
-
|
|
2476
|
+
mode?: "deterministic" | "agentic";
|
|
2477
|
+
acknowledgeCost?: boolean;
|
|
2478
|
+
budget?: IntelligenceReportBudget;
|
|
2479
|
+
metadata?: Record<string, unknown>;
|
|
2652
2480
|
}
|
|
2653
2481
|
/**
|
|
2654
|
-
*
|
|
2655
|
-
* (errored, timed out, or rejected — e.g. a hub approval gate). Failed tools
|
|
2656
|
-
* are recorded, not dropped, so callers can inspect what the agent attempted.
|
|
2482
|
+
* Options for event streaming.
|
|
2657
2483
|
*/
|
|
2658
|
-
interface
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2484
|
+
interface EventStreamOptions {
|
|
2485
|
+
/** AbortSignal for cancellation */
|
|
2486
|
+
signal?: AbortSignal;
|
|
2487
|
+
/** Filter to specific event types */
|
|
2488
|
+
eventTypes?: string[];
|
|
2663
2489
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
*/
|
|
2669
|
-
|
|
2490
|
+
//#endregion
|
|
2491
|
+
//#region src/types/batch.d.ts
|
|
2492
|
+
/** A single task in a batch execution. */
|
|
2493
|
+
type BatchTask = BatchTaskInput;
|
|
2494
|
+
/** Backend configuration accepted by batch execution. */
|
|
2495
|
+
type BatchBackend = BatchBackendInput;
|
|
2496
|
+
/** Complete request accepted by `runBatch` and `streamBatch`. */
|
|
2497
|
+
type BatchRunRequest = PublicBatchRunRequestInput;
|
|
2498
|
+
/** Per-call controls that are not serialized into a batch request. */
|
|
2499
|
+
interface BatchRunOptions {
|
|
2670
2500
|
/**
|
|
2671
|
-
*
|
|
2672
|
-
*
|
|
2673
|
-
*
|
|
2501
|
+
* Retry identity for this exact request body. Reuse it only when retrying the
|
|
2502
|
+
* same logical batch. Keyed batches continue after a client disconnect so a
|
|
2503
|
+
* later call can join them. Unkeyed batches stop when the client disconnects.
|
|
2674
2504
|
*/
|
|
2675
|
-
|
|
2676
|
-
/**
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2505
|
+
idempotencyKey?: string;
|
|
2506
|
+
/**
|
|
2507
|
+
* Cancels this client stream. An unkeyed cancellation also stops server
|
|
2508
|
+
* execution; a keyed cancellation detaches while the shared run continues.
|
|
2509
|
+
*/
|
|
2510
|
+
signal?: AbortSignal;
|
|
2680
2511
|
}
|
|
2681
2512
|
/**
|
|
2682
|
-
*
|
|
2683
|
-
* `status === "awaiting_question"`. Answer via
|
|
2684
|
-
* `box.session(id).answer(questionId, { [field]: value })`, then re-run.
|
|
2513
|
+
* Result of a single task in a batch.
|
|
2685
2514
|
*/
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
}
|
|
2515
|
+
type BatchTaskResult = BatchTaskResult$1;
|
|
2516
|
+
/** Complete validated batch result. */
|
|
2517
|
+
type BatchResult = BatchResult$1;
|
|
2518
|
+
//#endregion
|
|
2519
|
+
//#region src/types/branch.d.ts
|
|
2692
2520
|
/**
|
|
2693
|
-
*
|
|
2694
|
-
* non-negative; a runtime that reports only one side leaves the other at 0.
|
|
2695
|
-
*
|
|
2696
|
-
* The three prompt-side fields are DISJOINT and additive:
|
|
2697
|
-
* `inputTokens + cacheReadTokens + cacheWriteTokens` is the size of the prompt
|
|
2698
|
-
* the model saw, and each term bills at its own rate. `inputTokens` alone is
|
|
2699
|
-
* the freshly billed tail — on a warm agent loop with a stable prefix it is a
|
|
2700
|
-
* small fraction of the context, so reading it as "context size" understates
|
|
2701
|
-
* the prompt by the cached share, and pricing it as the whole prompt
|
|
2702
|
-
* overcharges by the same amount.
|
|
2521
|
+
* Options for branching a running sandbox into N copy-on-write children.
|
|
2703
2522
|
*
|
|
2704
|
-
*
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2523
|
+
* Branch forks a LIVE VM's memory into many children at once (Firecracker
|
|
2524
|
+
* UFFD copy-on-write): the children share the parent's clean pages and the
|
|
2525
|
+
* parent stays running. For durable filesystem state use snapshots instead.
|
|
2707
2526
|
*/
|
|
2708
|
-
interface
|
|
2709
|
-
/**
|
|
2710
|
-
|
|
2711
|
-
outputTokens: number;
|
|
2712
|
-
/** Prompt tokens served from the provider's prompt cache. */
|
|
2713
|
-
cacheReadTokens?: number;
|
|
2714
|
-
/** Prompt tokens written into the provider's prompt cache on this run. */
|
|
2715
|
-
cacheWriteTokens?: number;
|
|
2716
|
-
}
|
|
2717
|
-
interface PromptResult {
|
|
2718
|
-
/**
|
|
2719
|
-
* Whether the run succeeded. Shorthand for `status === "success"`: true only
|
|
2720
|
-
* when the run reached a terminal event with no run-level error and no failed
|
|
2721
|
-
* tool. Text presence is not required unless `requireVisibleAssistantOutput`
|
|
2722
|
-
* is set and no visible output was produced.
|
|
2723
|
-
*/
|
|
2724
|
-
success: boolean;
|
|
2725
|
-
/** Granular run outcome. */
|
|
2726
|
-
status: AgentRunStatus;
|
|
2527
|
+
interface BranchOptions {
|
|
2528
|
+
/** Override environment variables in every child. */
|
|
2529
|
+
env?: Record<string, string>;
|
|
2727
2530
|
/**
|
|
2728
|
-
*
|
|
2531
|
+
* Custom metadata applied to every child.
|
|
2729
2532
|
*
|
|
2730
|
-
*
|
|
2731
|
-
*
|
|
2732
|
-
*
|
|
2733
|
-
* this run instead of whichever run is newest at call time.
|
|
2734
|
-
*/
|
|
2735
|
-
executionId?: string;
|
|
2736
|
-
/** Agent's response text */
|
|
2737
|
-
response?: string;
|
|
2738
|
-
/** Error message when the run did not succeed */
|
|
2739
|
-
error?: string;
|
|
2740
|
-
/** Machine-readable error code from the runtime, e.g. `empty_visible_output`. */
|
|
2741
|
-
errorCode?: string;
|
|
2742
|
-
/** Native HTTP failure status when the provider reported it. */
|
|
2743
|
-
statusCode?: number;
|
|
2744
|
-
/** Tool calls the agent made this run, including failures (`isError`). */
|
|
2745
|
-
toolInvocations?: AgentToolInvocation[];
|
|
2746
|
-
/** Set when `status === "blocked_on_approval"`. */
|
|
2747
|
-
approval?: AgentApprovalRequirement;
|
|
2748
|
-
/** Set when `status === "awaiting_question"`. */
|
|
2749
|
-
question?: AgentQuestionRequest;
|
|
2750
|
-
/** Canonical request for any interaction that still needs a response. */
|
|
2751
|
-
interaction?: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
2752
|
-
/** Set when `status === "awaiting_plan_decision"`. */
|
|
2753
|
-
plan?: DurablePlanSnapshot;
|
|
2754
|
-
/**
|
|
2755
|
-
* Trace id this prompt sent as `x-tangle-trace-id`: the caller's
|
|
2756
|
-
* `PromptOptions.traceId`, or one the SDK minted. The Sandbox API, the
|
|
2757
|
-
* orchestrator's proxy log, the runtime and the router's dispatch rows all
|
|
2758
|
-
* record the same value, so it finds every hop of this turn.
|
|
2533
|
+
* Resource overrides are intentionally NOT accepted: a live branch restores
|
|
2534
|
+
* the parent's memory copy-on-write into each child, which requires
|
|
2535
|
+
* matching resources — children always inherit the parent's.
|
|
2759
2536
|
*/
|
|
2760
|
-
|
|
2761
|
-
/** Duration in milliseconds */
|
|
2762
|
-
durationMs: number;
|
|
2763
|
-
/** Token usage */
|
|
2764
|
-
usage?: TokenUsage;
|
|
2765
|
-
/** Provider-reported model cost in USD, when the runtime emitted it. */
|
|
2766
|
-
costUsd?: number;
|
|
2537
|
+
metadata?: Record<string, unknown>;
|
|
2767
2538
|
/**
|
|
2768
|
-
*
|
|
2769
|
-
*
|
|
2539
|
+
* Retry identity for this fan-out. A retry with the same key and the same
|
|
2540
|
+
* options returns the children the first request materialized and creates
|
|
2541
|
+
* none; the same key with different options is refused.
|
|
2770
2542
|
*/
|
|
2771
|
-
|
|
2772
|
-
limit: number;
|
|
2773
|
-
count: number;
|
|
2774
|
-
/**
|
|
2775
|
-
* The model each counted call's upstream response named, in call order;
|
|
2776
|
-
* shorter than `count` when a response named none. The requested model
|
|
2777
|
-
* is `effectiveBackend.model`, a separate value.
|
|
2778
|
-
*/
|
|
2779
|
-
observedModels?: string[];
|
|
2780
|
-
};
|
|
2543
|
+
idempotencyKey?: string;
|
|
2781
2544
|
}
|
|
2782
|
-
type PromptInputPart = {
|
|
2783
|
-
type: "text";
|
|
2784
|
-
text: string;
|
|
2785
|
-
} | {
|
|
2786
|
-
type: "image";
|
|
2787
|
-
filename?: string;
|
|
2788
|
-
mediaType?: string;
|
|
2789
|
-
url?: string;
|
|
2790
|
-
path?: string;
|
|
2791
|
-
} | {
|
|
2792
|
-
type: "file";
|
|
2793
|
-
filename: string;
|
|
2794
|
-
mediaType?: string;
|
|
2795
|
-
url: string;
|
|
2796
|
-
};
|
|
2797
2545
|
/**
|
|
2798
|
-
*
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
/** Resume one native conversation from the verified source snapshot. */
|
|
2804
|
-
nativeResume?: {
|
|
2805
|
-
harness: "claude-code" | "codex";
|
|
2806
|
-
nativeSessionId: string;
|
|
2807
|
-
sourceCheckpointId: string;
|
|
2808
|
-
};
|
|
2809
|
-
/**
|
|
2810
|
-
* Per-turn model id, forwarded to the runtime as `backend.model.model`.
|
|
2811
|
-
* Accepts a provider-prefixed slug ("zai/glm-4.7", "openai/gpt-5-mini")
|
|
2812
|
-
* or a bare id ("gpt-5-mini") the router resolves against the sandbox's
|
|
2813
|
-
* configured provider.
|
|
2814
|
-
*
|
|
2815
|
-
* This field exists because its absence produced silent model
|
|
2816
|
-
* substitution: `{ model: "gpt-5-mini" }` was an unknown option, the SDK
|
|
2817
|
-
* dropped it before the request left the process, and the sandbox served
|
|
2818
|
-
* the turn on its provisioned default model with no error anywhere.
|
|
2819
|
-
* A per-turn model request must either reach the wire or fail loud —
|
|
2820
|
-
* so a conflict with an explicit `backend.model.model` throws
|
|
2821
|
-
* `ValidationError` instead of silently preferring one.
|
|
2822
|
-
*
|
|
2823
|
-
* Equivalent to `backend: { model: { model } }`; use `backend.model` when
|
|
2824
|
-
* you also need provider/apiKey/baseUrl.
|
|
2825
|
-
*/
|
|
2826
|
-
model?: string;
|
|
2827
|
-
/**
|
|
2828
|
-
* Per-run backend override.
|
|
2829
|
-
*
|
|
2830
|
-
* Set `backend.model` for a model override and `backend.profile` for an
|
|
2831
|
-
* inline provider-neutral `AgentProfile`.
|
|
2832
|
-
* Same-runtime overrides retain unspecified defaults. Changing the harness,
|
|
2833
|
-
* provider, or base URL replaces the default backend configuration.
|
|
2834
|
-
*/
|
|
2835
|
-
backend?: Partial<BackendConfig>;
|
|
2836
|
-
/** Public digest returned by prepareSecretProfileRevision for this run. */
|
|
2837
|
-
expectedPublicProfileRequestDigest?: `sha256:${string}`;
|
|
2838
|
-
/** Private native revision receipt for an isolated secret profile run. */
|
|
2839
|
-
expectedSecretProfileReceipt?: `hmac-sha256:${string}`;
|
|
2840
|
-
/**
|
|
2841
|
-
* Per-run budget in milliseconds. Bounds the client-side stream and is
|
|
2842
|
-
* forwarded to the runtime, where the backend's first-output watchdog
|
|
2843
|
-
* honors it. It sets the execution's time limit only when `ttlMs` is unset,
|
|
2844
|
-
* and is then subject to the same deployment maximum as `ttlMs`.
|
|
2845
|
-
*/
|
|
2846
|
-
timeoutMs?: number;
|
|
2847
|
-
/**
|
|
2848
|
-
* Execution time limit in milliseconds. A positive integer; the runtime
|
|
2849
|
-
* cancels the execution when it elapses and the terminal error names the
|
|
2850
|
-
* limit. A value above the deployment's maximum (six hours by default) is
|
|
2851
|
-
* refused with `EXECUTION_TTL_EXCEEDS_LIMIT` before the run starts, by the
|
|
2852
|
-
* sandbox API on proxied calls and by the runtime itself on every call. The
|
|
2853
|
-
* code is the same from both; the surrounding error body follows each
|
|
2854
|
-
* service's own envelope, so read the code rather than the shape. Unset, the
|
|
2855
|
-
* runtime falls back to `timeoutMs`, then to its one-hour default.
|
|
2856
|
-
*
|
|
2857
|
-
* This limit governs how long the run may LIVE. A blocking call that waits
|
|
2858
|
-
* for the run is separately bounded by the runtime's one-hour request
|
|
2859
|
-
* timeout; a longer limit needs a streaming or session-message call, which
|
|
2860
|
-
* answers before the run finishes.
|
|
2861
|
-
*/
|
|
2862
|
-
ttlMs?: number;
|
|
2863
|
-
/** Additional context */
|
|
2864
|
-
context?: Record<string, unknown>;
|
|
2865
|
-
/**
|
|
2866
|
-
* Exact run identity bound to this first dispatch. The runtime stores this
|
|
2867
|
-
* reference with the live execution so delayed control operations cannot
|
|
2868
|
-
* target a newer run that reused the same execution id.
|
|
2869
|
-
*/
|
|
2870
|
-
runControlRef?: AgentExactRunControlRef;
|
|
2871
|
-
/** Fail chat-like runs that finish with no text or renderable interaction. */
|
|
2872
|
-
requireVisibleAssistantOutput?: boolean;
|
|
2873
|
-
/** AbortSignal for cancellation */
|
|
2874
|
-
signal?: AbortSignal;
|
|
2875
|
-
/**
|
|
2876
|
-
* Trace id sent as `x-tangle-trace-id` on every request this prompt makes,
|
|
2877
|
-
* including reconnects. Pass your own turn or request id (8-200 letters,
|
|
2878
|
-
* digits, `_` or `-`) to join platform records to yours; omit it and the
|
|
2879
|
-
* SDK mints one. `PromptResult.traceId` returns the value used.
|
|
2880
|
-
*/
|
|
2881
|
-
traceId?: string;
|
|
2882
|
-
/**
|
|
2883
|
-
* Stable execution id for tracing a first dispatch or selecting an existing
|
|
2884
|
-
* execution for replay. Forwarded as `X-Execution-ID` on a first dispatch.
|
|
2885
|
-
* When combined with `lastEventId`, the SDK replays the existing execution
|
|
2886
|
-
* without sending the prompt again. An execution ID alone does not make a
|
|
2887
|
-
* repeated POST idempotent; use `turnId` for application-level retries.
|
|
2888
|
-
* Omit to let the SDK read the id from `execution.started` for in-call
|
|
2889
|
-
* reconnects.
|
|
2890
|
-
*/
|
|
2891
|
-
executionId?: string;
|
|
2892
|
-
/**
|
|
2893
|
-
* Last event id the caller has already acknowledged. Requires `executionId`;
|
|
2894
|
-
* the SDK replays strictly after this id without dispatching a new prompt.
|
|
2895
|
-
* Omit on the first attempt.
|
|
2896
|
-
*/
|
|
2897
|
-
lastEventId?: string;
|
|
2898
|
-
/**
|
|
2899
|
-
* Caller-supplied turn idempotency key. When set, a retry with the
|
|
2900
|
-
* same `turnId` on the same `sessionId` short-circuits to the cached
|
|
2901
|
-
* result instead of re-issuing the upstream LLM call. Generate a
|
|
2902
|
-
* fresh `turnId` per logical attempt (a different user message gets
|
|
2903
|
-
* a new id) and reuse it only for retries of the same intent
|
|
2904
|
-
* (Stripe-style idempotency). Combine with `box.findCompletedTurn`
|
|
2905
|
-
* to check completion before re-dispatching.
|
|
2906
|
-
*/
|
|
2907
|
-
turnId?: string;
|
|
2908
|
-
/**
|
|
2909
|
-
* Detach the run from this stream's lifetime. When true, the run never
|
|
2910
|
-
* ends because a reader went away: closing the generator does not cancel
|
|
2911
|
-
* it, and the platform keeps executing it and buffering its events so a
|
|
2912
|
-
* later reconnect can replay. Use for batch or queue workloads.
|
|
2913
|
-
*
|
|
2914
|
-
* Without it, ending the stream early (breaking out of the loop, aborting
|
|
2915
|
-
* `signal`, or letting `timeoutMs` elapse) cancels the run. A dropped
|
|
2916
|
-
* connection does not: the platform keeps an interactive run through a
|
|
2917
|
-
* disconnect grace window so this stream can rejoin it.
|
|
2918
|
-
* `dispatchPrompt` always sets this so fire-and-detach is safe by
|
|
2919
|
-
* construction.
|
|
2920
|
-
*/
|
|
2921
|
-
detach?: boolean;
|
|
2922
|
-
/**
|
|
2923
|
-
* How long the SDK keeps rejoining this execution while it is unreachable,
|
|
2924
|
-
* in milliseconds. A dropped stream is a transport event, not an outcome:
|
|
2925
|
-
* the SDK reconnects with capped exponential backoff (1s doubling to 30s)
|
|
2926
|
-
* and resumes after the last delivered event, without duplicates. Each
|
|
2927
|
-
* replay connection that reaches the execution restarts the window, so a
|
|
2928
|
-
* long run survives any number of platform deploys. When the window
|
|
2929
|
-
* elapses, or the sandbox stops, the stream ends with an `error` event
|
|
2930
|
-
* whose `code` is `STREAM_INTERRUPTED` and `outcome` is `unknown`, and no
|
|
2931
|
-
* `done`: rejoin later with `executionId` + `lastEventId`.
|
|
2932
|
-
* Default six hours; 0 disables reconnection.
|
|
2933
|
-
*/
|
|
2934
|
-
reconnectWindowMs?: number;
|
|
2935
|
-
}
|
|
2936
|
-
/**
|
|
2937
|
-
* SSE event from sandbox streaming.
|
|
2938
|
-
*/
|
|
2939
|
-
interface SandboxEvent {
|
|
2940
|
-
/** Event type */
|
|
2941
|
-
type: string;
|
|
2942
|
-
/** Event data */
|
|
2943
|
-
data: Record<string, unknown> & {
|
|
2944
|
-
effectiveBackend?: EffectiveBackend; /** Stable sidecar session used by runtime interaction routes. */
|
|
2945
|
-
runtimeSessionId?: string; /** Sandbox that produced this event, stamped by the SDK at intake. */
|
|
2946
|
-
sandboxId?: string;
|
|
2947
|
-
};
|
|
2948
|
-
/** Event ID */
|
|
2949
|
-
id?: string;
|
|
2950
|
-
}
|
|
2951
|
-
interface SandboxTraceEvent {
|
|
2952
|
-
type: "sandbox.lifecycle.snapshot" | "sandbox.runtime.snapshot" | "sandbox.usage.snapshot" | "sandbox.insight.summary";
|
|
2953
|
-
timestamp: string;
|
|
2954
|
-
sandboxId: string;
|
|
2955
|
-
durationMs?: number;
|
|
2956
|
-
attributes: Record<string, unknown>;
|
|
2957
|
-
}
|
|
2958
|
-
interface SandboxTraceExport {
|
|
2959
|
-
schemaVersion: "sandbox.trace.v1";
|
|
2960
|
-
traceId: string;
|
|
2961
|
-
sandboxId: string;
|
|
2962
|
-
exportedAt: string;
|
|
2963
|
-
timings: {
|
|
2964
|
-
observedLifecycleMs: number;
|
|
2965
|
-
observedRuntimeMs: number;
|
|
2966
|
-
idleObservedMs: number;
|
|
2967
|
-
};
|
|
2968
|
-
criticalPath: {
|
|
2969
|
-
durationMs: number;
|
|
2970
|
-
phases: Array<{
|
|
2971
|
-
name: string;
|
|
2972
|
-
durationMs: number;
|
|
2973
|
-
}>;
|
|
2974
|
-
};
|
|
2975
|
-
events: SandboxTraceEvent[];
|
|
2976
|
-
}
|
|
2977
|
-
interface SandboxIntelligenceEnvelope {
|
|
2978
|
-
schemaVersion: "sandbox.intelligence.v1";
|
|
2979
|
-
source: "sandbox-api";
|
|
2980
|
-
subject: {
|
|
2981
|
-
type: "sandbox";
|
|
2982
|
-
sandboxId: string;
|
|
2983
|
-
};
|
|
2984
|
-
billing: {
|
|
2985
|
-
billable: false;
|
|
2986
|
-
billedTo: "platform";
|
|
2987
|
-
costUsd: 0;
|
|
2988
|
-
reason: "deterministic_platform_insight";
|
|
2989
|
-
};
|
|
2990
|
-
metrics: Record<string, number>;
|
|
2991
|
-
signals: Array<{
|
|
2992
|
-
name: string;
|
|
2993
|
-
value: string | number | boolean;
|
|
2994
|
-
severity: "info" | "warn" | "critical";
|
|
2995
|
-
rationale: string;
|
|
2996
|
-
}>;
|
|
2997
|
-
recommendedActions: string[];
|
|
2998
|
-
}
|
|
2999
|
-
interface SandboxTraceBundle {
|
|
3000
|
-
trace: SandboxTraceExport;
|
|
3001
|
-
intelligence?: SandboxIntelligenceEnvelope;
|
|
3002
|
-
}
|
|
3003
|
-
interface SandboxTraceOptions {
|
|
3004
|
-
/**
|
|
3005
|
-
* Include the platform-generated intelligence envelope. Defaults to false.
|
|
3006
|
-
* Set true when a customer wants generated insight with the raw trace export.
|
|
3007
|
-
*/
|
|
3008
|
-
includeIntelligence?: boolean;
|
|
3009
|
-
}
|
|
3010
|
-
/**
|
|
3011
|
-
* Subject types for an Intelligence Report.
|
|
3012
|
-
*
|
|
3013
|
-
* - `sandbox`: one container's run.
|
|
3014
|
-
* - `fleet`: one managed grouping of sandboxes. Add `subject.dispatchId`
|
|
3015
|
-
* to narrow to a single coordinated command within the fleet
|
|
3016
|
-
* (previously a standalone `dispatch` subject type — now expressed
|
|
3017
|
-
* as a fleet refinement).
|
|
3018
|
-
*/
|
|
3019
|
-
type IntelligenceReportSubjectType = "sandbox" | "fleet";
|
|
3020
|
-
interface IntelligenceReport {
|
|
3021
|
-
jobId: string;
|
|
3022
|
-
subject: {
|
|
3023
|
-
type: IntelligenceReportSubjectType;
|
|
3024
|
-
id: string; /** Present when the report was narrowed to a single fleet dispatch. */
|
|
3025
|
-
dispatchId?: string;
|
|
3026
|
-
};
|
|
3027
|
-
mode: "deterministic" | "agentic";
|
|
3028
|
-
status: "queued" | "running" | "completed" | "failed";
|
|
3029
|
-
billing: {
|
|
3030
|
-
billable: boolean;
|
|
3031
|
-
billedTo: "platform" | "customer";
|
|
3032
|
-
costUsd: number;
|
|
3033
|
-
reason: string;
|
|
3034
|
-
budgetMaxUsd?: number;
|
|
3035
|
-
};
|
|
3036
|
-
result: Record<string, unknown> | null;
|
|
3037
|
-
error?: string;
|
|
3038
|
-
createdAt: string;
|
|
3039
|
-
updatedAt: string;
|
|
3040
|
-
completedAt?: string;
|
|
3041
|
-
}
|
|
3042
|
-
interface IntelligenceReportBudget {
|
|
3043
|
-
maxUsd?: number;
|
|
3044
|
-
billTo?: "customer" | "platform";
|
|
3045
|
-
}
|
|
3046
|
-
/**
|
|
3047
|
-
* Time window for an intelligence report. Both bounds are millisecond
|
|
3048
|
-
* epochs. Omit `since` to mean "from the subject's first observation";
|
|
3049
|
-
* omit `until` to mean "now". `since` must be <= `until` when both are
|
|
3050
|
-
* set; the server enforces this at the schema layer.
|
|
3051
|
-
*/
|
|
3052
|
-
interface IntelligenceReportWindow {
|
|
3053
|
-
since?: number;
|
|
3054
|
-
until?: number;
|
|
3055
|
-
}
|
|
3056
|
-
/**
|
|
3057
|
-
* Comparison baseline. When present, the report includes an explicit
|
|
3058
|
-
* delta between the primary subject and this baseline. Must be the
|
|
3059
|
-
* same `type` as the primary subject — the analyzer rejects mixed
|
|
3060
|
-
* subject-type comparisons because the delta would be meaningless.
|
|
3061
|
-
*
|
|
3062
|
-
* `dispatchId` is only valid when `type === "fleet"`.
|
|
3063
|
-
*/
|
|
3064
|
-
interface IntelligenceReportCompareTo {
|
|
3065
|
-
type: IntelligenceReportSubjectType;
|
|
3066
|
-
id: string;
|
|
3067
|
-
/** Narrow the baseline to a single dispatch within the fleet. */
|
|
3068
|
-
dispatchId?: string;
|
|
3069
|
-
}
|
|
3070
|
-
interface CreateIntelligenceReportOptions {
|
|
3071
|
-
subject: {
|
|
3072
|
-
type: IntelligenceReportSubjectType;
|
|
3073
|
-
id: string;
|
|
3074
|
-
/**
|
|
3075
|
-
* Narrow the analysis to a single coordinated command within a
|
|
3076
|
-
* fleet. Only valid when `type === "fleet"`.
|
|
3077
|
-
*/
|
|
3078
|
-
dispatchId?: string; /** Bound the analysis to a time window. */
|
|
3079
|
-
window?: IntelligenceReportWindow; /** Compare the primary subject against a same-type baseline. */
|
|
3080
|
-
compareTo?: IntelligenceReportCompareTo;
|
|
3081
|
-
};
|
|
3082
|
-
mode?: "deterministic" | "agentic";
|
|
3083
|
-
acknowledgeCost?: boolean;
|
|
3084
|
-
budget?: IntelligenceReportBudget;
|
|
3085
|
-
metadata?: Record<string, unknown>;
|
|
3086
|
-
}
|
|
3087
|
-
/**
|
|
3088
|
-
* Options for event streaming.
|
|
3089
|
-
*/
|
|
3090
|
-
interface EventStreamOptions {
|
|
3091
|
-
/** AbortSignal for cancellation */
|
|
3092
|
-
signal?: AbortSignal;
|
|
3093
|
-
/** Filter to specific event types */
|
|
3094
|
-
eventTypes?: string[];
|
|
3095
|
-
}
|
|
3096
|
-
//#endregion
|
|
3097
|
-
//#region src/types/batch.d.ts
|
|
3098
|
-
/** A single task in a batch execution. */
|
|
3099
|
-
type BatchTask = BatchTaskInput;
|
|
3100
|
-
/** Backend configuration accepted by batch execution. */
|
|
3101
|
-
type BatchBackend = BatchBackendInput;
|
|
3102
|
-
/** Complete request accepted by `runBatch` and `streamBatch`. */
|
|
3103
|
-
type BatchRunRequest = PublicBatchRunRequestInput;
|
|
3104
|
-
/** Per-call controls that are not serialized into a batch request. */
|
|
3105
|
-
interface BatchRunOptions {
|
|
3106
|
-
/**
|
|
3107
|
-
* Retry identity for this exact request body. Reuse it only when retrying the
|
|
3108
|
-
* same logical batch. Keyed batches continue after a client disconnect so a
|
|
3109
|
-
* later call can join them. Unkeyed batches stop when the client disconnects.
|
|
3110
|
-
*/
|
|
3111
|
-
idempotencyKey?: string;
|
|
3112
|
-
/**
|
|
3113
|
-
* Cancels this client stream. An unkeyed cancellation also stops server
|
|
3114
|
-
* execution; a keyed cancellation detaches while the shared run continues.
|
|
3115
|
-
*/
|
|
3116
|
-
signal?: AbortSignal;
|
|
3117
|
-
}
|
|
3118
|
-
/**
|
|
3119
|
-
* Result of a single task in a batch.
|
|
3120
|
-
*/
|
|
3121
|
-
type BatchTaskResult = BatchTaskResult$1;
|
|
3122
|
-
/** Complete validated batch result. */
|
|
3123
|
-
type BatchResult = BatchResult$1;
|
|
3124
|
-
//#endregion
|
|
3125
|
-
//#region src/types/branch.d.ts
|
|
3126
|
-
/**
|
|
3127
|
-
* Options for branching a running sandbox into N copy-on-write children.
|
|
3128
|
-
*
|
|
3129
|
-
* Branch forks a LIVE VM's memory into many children at once (Firecracker
|
|
3130
|
-
* UFFD copy-on-write): the children share the parent's clean pages and the
|
|
3131
|
-
* parent stays running. For durable filesystem state use snapshots instead.
|
|
3132
|
-
*/
|
|
3133
|
-
interface BranchOptions {
|
|
3134
|
-
/** Override environment variables in every child. */
|
|
3135
|
-
env?: Record<string, string>;
|
|
3136
|
-
/**
|
|
3137
|
-
* Custom metadata applied to every child.
|
|
3138
|
-
*
|
|
3139
|
-
* Resource overrides are intentionally NOT accepted: a live branch restores
|
|
3140
|
-
* the parent's memory copy-on-write into each child, which requires
|
|
3141
|
-
* matching resources — children always inherit the parent's.
|
|
3142
|
-
*/
|
|
3143
|
-
metadata?: Record<string, unknown>;
|
|
3144
|
-
/**
|
|
3145
|
-
* Retry identity for this fan-out. A retry with the same key and the same
|
|
3146
|
-
* options returns the children the first request materialized and creates
|
|
3147
|
-
* none; the same key with different options is refused.
|
|
3148
|
-
*/
|
|
3149
|
-
idempotencyKey?: string;
|
|
3150
|
-
}
|
|
3151
|
-
/**
|
|
3152
|
-
* How a keyed fork resolved.
|
|
3153
|
-
*
|
|
3154
|
-
* `created` ran this fan-out. `replayed` returned the children an earlier
|
|
3155
|
-
* request under the same key and options already materialized. Absent when the
|
|
3156
|
-
* request carried no key, or when the API predates the field.
|
|
2546
|
+
* How a keyed fork resolved.
|
|
2547
|
+
*
|
|
2548
|
+
* `created` ran this fan-out. `replayed` returned the children an earlier
|
|
2549
|
+
* request under the same key and options already materialized. Absent when the
|
|
2550
|
+
* request carried no key, or when the API predates the field.
|
|
3157
2551
|
*/
|
|
3158
2552
|
interface ForkIdempotency {
|
|
3159
2553
|
outcome: "created" | "replayed";
|
|
@@ -3327,6 +2721,8 @@ interface HttpClient {
|
|
|
3327
2721
|
getBaseUrl?(): string | undefined;
|
|
3328
2722
|
/** Receives the SDK's timing spans; see `SandboxConfig.onTiming`. */
|
|
3329
2723
|
readonly onTiming?: SdkTimingHook | undefined;
|
|
2724
|
+
/** False keeps exec on the API; see `SandboxConfig.directExec`. */
|
|
2725
|
+
readonly directExec?: boolean;
|
|
3330
2726
|
}
|
|
3331
2727
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
3332
2728
|
[key: string]: JsonValue;
|
|
@@ -5268,6 +4664,15 @@ interface SandboxConfig {
|
|
|
5268
4664
|
* A hook that throws is ignored. With no hook the SDK measures nothing.
|
|
5269
4665
|
*/
|
|
5270
4666
|
onTiming?: SdkTimingHook;
|
|
4667
|
+
/**
|
|
4668
|
+
* Send exec-family runtime calls (spawn, exec, terminal) straight to the
|
|
4669
|
+
* sandbox's cell when its connection carries an exec grant (`execHost` and
|
|
4670
|
+
* `execToken`), instead of through the API and the orchestrator. Default
|
|
4671
|
+
* `true`. A command the cell provably never received falls back to the
|
|
4672
|
+
* API, which resumes a stopped sandbox. `false` sends every runtime call
|
|
4673
|
+
* through the API.
|
|
4674
|
+
*/
|
|
4675
|
+
directExec?: boolean;
|
|
5271
4676
|
}
|
|
5272
4677
|
/**
|
|
5273
4678
|
* Status of a sandbox instance.
|
|
@@ -5773,1231 +5178,1837 @@ interface CreateSandboxOptions {
|
|
|
5773
5178
|
* before provisioning. When omitted the sandbox is personal
|
|
5774
5179
|
* (accessible only to the creator).
|
|
5775
5180
|
*/
|
|
5776
|
-
teamId?: string;
|
|
5181
|
+
teamId?: string;
|
|
5182
|
+
/**
|
|
5183
|
+
* Sidecar capabilities to enable at boot. Each capability boots an
|
|
5184
|
+
* additional subsystem inside the sandbox; absent capabilities incur
|
|
5185
|
+
* zero startup cost.
|
|
5186
|
+
*
|
|
5187
|
+
* Currently supported:
|
|
5188
|
+
* - `"computer_use"` — boots Xvfb, dbus, AT-SPI, and an MCP server
|
|
5189
|
+
* exposing mouse/keyboard/screenshot via the Anthropic + OpenAI
|
|
5190
|
+
* Responses computer-use surface. Required if you plan to call
|
|
5191
|
+
* {@link SandboxInstance.getMcpAccessToken | `getMcpAccessToken`}
|
|
5192
|
+
* with `capabilities: ["computer_use"]`.
|
|
5193
|
+
*
|
|
5194
|
+
* The capability is enforced at two layers:
|
|
5195
|
+
* 1. The sidecar refuses to start if a capability's binaries are
|
|
5196
|
+
* missing (`computer_use` needs the mounted Nix profile with
|
|
5197
|
+
* Xvfb, dbus, xdotool, and scrot available at runtime).
|
|
5198
|
+
* 2. The MCP token endpoint refuses to mint a `cap: ["computer_use"]`
|
|
5199
|
+
* JWT for a sandbox that wasn't created with that capability.
|
|
5200
|
+
*
|
|
5201
|
+
* **Sizing note:** `computer_use` boots an always-on Xvfb + dbus
|
|
5202
|
+
* stack costing roughly **~100 MB resident memory** inside the
|
|
5203
|
+
* container. Billing is by reserved capacity (not measured RSS), so
|
|
5204
|
+
* this comes out of your sandbox's RAM envelope rather than adding
|
|
5205
|
+
* a separate line item. On a 1 GB sandbox that is ~10% of your
|
|
5206
|
+
* workload's headroom; bump `resources.memoryMB` to 1.5–2 GB if
|
|
5207
|
+
* the agent will run anything memory-hungry alongside it.
|
|
5208
|
+
*
|
|
5209
|
+
* @example
|
|
5210
|
+
* ```typescript
|
|
5211
|
+
* const box = await client.create({
|
|
5212
|
+
* capabilities: ["computer_use"],
|
|
5213
|
+
* });
|
|
5214
|
+
* const { token } = await box.getMcpAccessToken({
|
|
5215
|
+
* capabilities: ["computer_use"],
|
|
5216
|
+
* });
|
|
5217
|
+
* ```
|
|
5218
|
+
*/
|
|
5219
|
+
capabilities?: ReadonlyArray<"computer_use">;
|
|
5220
|
+
/**
|
|
5221
|
+
* Privacy controls for the sandbox. Two independent layers:
|
|
5222
|
+
*
|
|
5223
|
+
* - **`egress`** — what happens when the sandbox sends a request to a
|
|
5224
|
+
* model vendor (Anthropic, OpenAI, your own router, etc.):
|
|
5225
|
+
* - `"redact"` — PII spans are masked before the request leaves
|
|
5226
|
+
* the sandbox. Emails, JWTs, API keys, credit cards (Luhn-
|
|
5227
|
+
* validated), SSNs, phone numbers, IPv4 addresses are caught
|
|
5228
|
+
* today; names / postal addresses / DOBs land when the OPF
|
|
5229
|
+
* model service is enabled. The agent receives normal
|
|
5230
|
+
* responses; the vendor sees masked input.
|
|
5231
|
+
* - `"block"` — PII presence fails the egress request closed.
|
|
5232
|
+
* For high-compliance flows that prefer fail-closed to leak.
|
|
5233
|
+
* - `"off"` — no egress filtering. Default for free tier; opt-in
|
|
5234
|
+
* for tasks that genuinely need raw PII (form-filling,
|
|
5235
|
+
* customer-support agents reading customer details).
|
|
5236
|
+
*
|
|
5237
|
+
* - **`logs`** — whether infrastructure logs / telemetry / Sentry
|
|
5238
|
+
* redact PII before recording. This is OUR side, not the model
|
|
5239
|
+
* vendor's, and there's basically never a reason to leak PII into
|
|
5240
|
+
* our own logs. Default `"on"`.
|
|
5241
|
+
*
|
|
5242
|
+
* Note: privacy controls operate at the boundary between the
|
|
5243
|
+
* sandbox and external systems. They do NOT redact contents inside
|
|
5244
|
+
* the sandbox workspace itself — files / code / database fixtures
|
|
5245
|
+
* the customer puts there are the customer's data and stay
|
|
5246
|
+
* unmodified. Snapshots preserve those contents verbatim.
|
|
5247
|
+
*
|
|
5248
|
+
* @example
|
|
5249
|
+
* ```typescript
|
|
5250
|
+
* const box = await client.create({
|
|
5251
|
+
* privacy: { egress: "redact", logs: "on" },
|
|
5252
|
+
* });
|
|
5253
|
+
* ```
|
|
5254
|
+
*/
|
|
5255
|
+
privacy?: {
|
|
5256
|
+
egress?: "redact" | "block" | "off";
|
|
5257
|
+
logs?: "on" | "off";
|
|
5258
|
+
};
|
|
5259
|
+
/**
|
|
5260
|
+
* Stable idempotency key for this logical create. Sent as the
|
|
5261
|
+
* `Idempotency-Key` header so the API derives a deterministic sandbox
|
|
5262
|
+
* identity from (owner, key): a retried create resolves to the SAME
|
|
5263
|
+
* provisioning sandbox and joins the in-flight provision instead of
|
|
5264
|
+
* starting a fresh cold start per retry. When omitted, the SDK
|
|
5265
|
+
* generates one per `create()` call and reuses it across its own
|
|
5266
|
+
* timeout-driven retries.
|
|
5267
|
+
*/
|
|
5268
|
+
idempotencyKey?: string;
|
|
5269
|
+
/**
|
|
5270
|
+
* Platform user id whose wallet funds managed model usage for this sandbox.
|
|
5271
|
+
*
|
|
5272
|
+
* Use only from a trusted first-party service acting for an authenticated
|
|
5273
|
+
* user. The Sandbox API honors this field only when the caller's exact
|
|
5274
|
+
* verified API key ID is allow-listed; otherwise strict deployments reject
|
|
5275
|
+
* the create.
|
|
5276
|
+
* It never grants the caller permission to charge arbitrary users.
|
|
5277
|
+
*
|
|
5278
|
+
* This option applies to the HTTP Sandbox API client. Direct Tangle job
|
|
5279
|
+
* creation does not support delegated billing.
|
|
5280
|
+
*/
|
|
5281
|
+
billingOwnerId?: string;
|
|
5282
|
+
/**
|
|
5283
|
+
* What pays this sandbox's compute. `"referral_credit"` spends the
|
|
5284
|
+
* account's referral Sandbox-compute credit only: it runs on spare capacity,
|
|
5285
|
+
* never falls back to the wallet, and stops with `scoped_credit_exhausted`
|
|
5286
|
+
* when the credit runs out or `scoped_credit_held` while its campaign is on
|
|
5287
|
+
* hold. Fixed for the sandbox's life. Personal sandboxes only. Defaults to
|
|
5288
|
+
* the wallet.
|
|
5289
|
+
*/
|
|
5290
|
+
funding?: "wallet" | "referral_credit";
|
|
5291
|
+
/**
|
|
5292
|
+
* Place this sandbox only on spare capacity.
|
|
5293
|
+
*
|
|
5294
|
+
* For first-party delegated creates only: the Sandbox API accepts it only
|
|
5295
|
+
* together with `billingOwnerId` from an allow-listed first-party service
|
|
5296
|
+
* key, and refuses every other create with 403 `CAPACITY_CLASS_FORBIDDEN`.
|
|
5297
|
+
* It restricts placement and is not a priority: no host outside the spare
|
|
5298
|
+
* pool takes the sandbox, and the create is refused with 503
|
|
5299
|
+
* `SPARE_CAPACITY_UNAVAILABLE` when no spare pool admits it. It also skips
|
|
5300
|
+
* the warm pool. The class is fixed at create; resume keeps it.
|
|
5301
|
+
*/
|
|
5302
|
+
capacityClass?: "spare_only";
|
|
5303
|
+
/**
|
|
5304
|
+
* Auto-split inline file mounts out of an inline `backend.profile` object
|
|
5305
|
+
* at create time, send the lean profile (mount refs stripped) in the
|
|
5306
|
+
* create request, then write the deferred files back once the sandbox is
|
|
5307
|
+
* running.
|
|
5308
|
+
*
|
|
5309
|
+
* When `true` (the default), a profile with sizeable inline mounts (e.g.
|
|
5310
|
+
* skills, tool scripts) does not bloat the create POST; the SDK
|
|
5311
|
+
* materializes those files via {@link FileSystem.writeMany} /
|
|
5312
|
+
* {@link FileSystem.uploadData} after the sandbox reaches `running`. A batch
|
|
5313
|
+
* write answered 502, 503 or 504, or lost with its connection, is sent again
|
|
5314
|
+
* for up to 10 seconds before create() raises `PartialFailureError`. Only
|
|
5315
|
+
* applies to an inline `AgentProfile` object on `backend.profile`; a
|
|
5316
|
+
* named-profile string is never split. Set `false` to send the full profile
|
|
5317
|
+
* in the create request without a post-create materialization step.
|
|
5318
|
+
*
|
|
5319
|
+
* @default true
|
|
5320
|
+
*/
|
|
5321
|
+
autoMaterializeProfileFiles?: boolean;
|
|
5322
|
+
/**
|
|
5323
|
+
* Auto-defer an inline `backend.profile`'s static corpus so it is delivered
|
|
5324
|
+
* once instead of on every turn. At create time the SDK strips inline
|
|
5325
|
+
* `resources.skills` from the create request (keeping the create body under
|
|
5326
|
+
* its wire cap), then primes the running sandbox with the full profile and
|
|
5327
|
+
* references it by hash (`backend.profileSha256`) on subsequent turns. The
|
|
5328
|
+
* handle still holds the full profile, so a cache miss transparently resends
|
|
5329
|
+
* it.
|
|
5330
|
+
*
|
|
5331
|
+
* When `false`, the full profile, including skills, travels with the create
|
|
5332
|
+
* request and every turn. This applies only to an inline `AgentProfile`
|
|
5333
|
+
* object on `backend.profile` and is independent of
|
|
5334
|
+
* {@link autoMaterializeProfileFiles}.
|
|
5335
|
+
*
|
|
5336
|
+
* A turn only substitutes the hash reference when the outgoing profile's
|
|
5337
|
+
* content still matches what was primed: mutate the profile (or pass a
|
|
5338
|
+
* changed per-turn `backend.profile`) and that turn sends the full profile
|
|
5339
|
+
* inline again, so the runtime always runs the profile you passed.
|
|
5340
|
+
*
|
|
5341
|
+
* @default true
|
|
5342
|
+
*/
|
|
5343
|
+
autoDeferProfile?: boolean;
|
|
5344
|
+
}
|
|
5345
|
+
/**
|
|
5346
|
+
* Per-call overrides for {@link Sandbox.create}.
|
|
5347
|
+
*/
|
|
5348
|
+
interface CreateRequestOptions {
|
|
5349
|
+
/**
|
|
5350
|
+
* Time budget for the whole create-and-reach-running flow, in
|
|
5351
|
+
* milliseconds. Cold provisions routinely take ~25–40s, so this
|
|
5352
|
+
* defaults high (120000). If the initial POST rides the deadline the
|
|
5353
|
+
* SDK polls the sandbox to `running` rather than re-POSTing.
|
|
5354
|
+
*/
|
|
5355
|
+
timeoutMs?: number;
|
|
5356
|
+
/** Abort the create + poll early. */
|
|
5357
|
+
signal?: AbortSignal;
|
|
5358
|
+
}
|
|
5359
|
+
//#endregion
|
|
5360
|
+
//#region src/types/sandbox-info.d.ts
|
|
5361
|
+
/**
|
|
5362
|
+
* SSH connection credentials.
|
|
5363
|
+
*/
|
|
5364
|
+
interface SSHCredentials {
|
|
5365
|
+
/** Username for SSH authentication */
|
|
5366
|
+
username: string;
|
|
5367
|
+
/** SSH server port */
|
|
5368
|
+
port: number;
|
|
5369
|
+
/** ProxyCommand for sandbox API tunnel-based SSH. */
|
|
5370
|
+
proxyCommand: string;
|
|
5371
|
+
}
|
|
5372
|
+
interface SSHCommandDescriptor {
|
|
5373
|
+
command: string;
|
|
5374
|
+
env: Record<string, string>;
|
|
5375
|
+
}
|
|
5376
|
+
/**
|
|
5377
|
+
* Connection information for a sandbox.
|
|
5378
|
+
*
|
|
5379
|
+
* Most code should use `SandboxInstance` methods (`exec`, `prompt`, etc.).
|
|
5380
|
+
* The raw `runtimeUrl` and `authToken` are surfaced only for advanced
|
|
5381
|
+
* lower-level use cases such as custom protocol clients.
|
|
5382
|
+
*/
|
|
5383
|
+
interface SandboxConnection {
|
|
5384
|
+
/** Sandbox runtime API URL for programmatic access */
|
|
5385
|
+
runtimeUrl?: string;
|
|
5386
|
+
/** Cell exec origin. Direct requests select this sandbox by header. */
|
|
5387
|
+
execHost?: string;
|
|
5388
|
+
/** Short command-only credential; refreshed through the Sandbox API. */
|
|
5389
|
+
execToken?: string;
|
|
5390
|
+
execTokenExpiresAt?: string;
|
|
5391
|
+
/** Access token for authenticating directly with the runtime (Bearer token) */
|
|
5392
|
+
authToken?: string;
|
|
5393
|
+
/** Token expiration timestamp (ISO 8601). Refresh before this time. */
|
|
5394
|
+
authTokenExpiresAt?: string;
|
|
5395
|
+
/** Public inbound edge attachment state for `runtimeUrl`. */
|
|
5396
|
+
edgeStatus?: "pending" | "ready" | "failed" | "skipped";
|
|
5397
|
+
/** Timestamp when the public edge reached this sandbox. */
|
|
5398
|
+
edgeReadyAt?: string;
|
|
5399
|
+
/** Last public edge attachment error message. */
|
|
5400
|
+
edgeError?: string;
|
|
5401
|
+
/** SSH connection info if `sshEnabled` was true during creation */
|
|
5402
|
+
ssh?: SSHCredentials;
|
|
5403
|
+
/** Web terminal URL if `webTerminalEnabled` was true during creation */
|
|
5404
|
+
webTerminalUrl?: string;
|
|
5405
|
+
}
|
|
5406
|
+
/**
|
|
5407
|
+
* One attributed step in a sandbox cold-start, as emitted by the
|
|
5408
|
+
* platform startup pipeline. Mirrors the platform
|
|
5409
|
+
* `StartupOperationTiming` shape one-to-one.
|
|
5410
|
+
*
|
|
5411
|
+
* - `operation` is by convention `<service>.<phase>`
|
|
5412
|
+
* (e.g. `host-agent.container_create`).
|
|
5413
|
+
* - `durationMs` is wall-clock time the step took. The platform
|
|
5414
|
+
* marks it optional on `skipped` steps, so it is optional here too.
|
|
5415
|
+
*/
|
|
5416
|
+
interface StartupOperation {
|
|
5417
|
+
/** `<service>.<phase>` operation name. */
|
|
5418
|
+
operation: string;
|
|
5419
|
+
/** Service that performed the step, when attributed. */
|
|
5420
|
+
service?: string;
|
|
5421
|
+
/** Terminal status of the step (e.g. `completed`, `skipped`, `error`). */
|
|
5422
|
+
status?: string;
|
|
5423
|
+
/** Wall-clock duration of the step in milliseconds, when measured. */
|
|
5424
|
+
durationMs?: number;
|
|
5425
|
+
/**
|
|
5426
|
+
* `operation` of the step whose wall CONTAINS this one; absent means the
|
|
5427
|
+
* step hangs directly under the flow total. Add only the steps that no
|
|
5428
|
+
* other step names as its parent — a parent re-measures the time its
|
|
5429
|
+
* children already report, so summing both over-counts the flow.
|
|
5430
|
+
*/
|
|
5431
|
+
parent?: string;
|
|
5432
|
+
/** PII-scrubbed step detail (counts, ids, error codes). */
|
|
5433
|
+
metadata?: Record<string, unknown>;
|
|
5434
|
+
}
|
|
5435
|
+
/**
|
|
5436
|
+
* The startup breakdown for a sandbox cold-start. Returned by
|
|
5437
|
+
* {@link SandboxInstance.startupDiagnostics} so a customer can read where
|
|
5438
|
+
* provisioning time went (host selection, container create/start, health
|
|
5439
|
+
* checks, runtime readiness, workspace setup, etc.).
|
|
5440
|
+
*
|
|
5441
|
+
* `operations` is the raw ordered list from the platform. `phases`
|
|
5442
|
+
* is a derived convenience map of operation name → `durationMs` for the
|
|
5443
|
+
* steps that reported a duration; steps without a measured duration are
|
|
5444
|
+
* omitted from `phases` but still present in `operations`.
|
|
5445
|
+
*
|
|
5446
|
+
* `phases` mixes containing steps with the steps they contain, so its values
|
|
5447
|
+
* do NOT add up to the flow wall. To add durations, filter `operations` to
|
|
5448
|
+
* those no other operation names as its `parent`.
|
|
5449
|
+
*/
|
|
5450
|
+
interface StartupDiagnostics {
|
|
5451
|
+
/** Ordered startup steps exactly as the platform emitted them. */
|
|
5452
|
+
operations: StartupOperation[];
|
|
5453
|
+
/** Derived map of operation name → measured duration in milliseconds. */
|
|
5454
|
+
phases: Record<string, number>;
|
|
5455
|
+
}
|
|
5456
|
+
/**
|
|
5457
|
+
* Full sandbox information returned from the API.
|
|
5458
|
+
*/
|
|
5459
|
+
interface SandboxInfo {
|
|
5460
|
+
/** Unique sandbox identifier */
|
|
5461
|
+
id: string;
|
|
5462
|
+
/** Human-readable name */
|
|
5463
|
+
name?: string;
|
|
5464
|
+
/** Control-plane identity of the currently published filesystem contents. */
|
|
5465
|
+
filesystemIncarnationId?: string;
|
|
5466
|
+
/** How the current filesystem contents were acquired. */
|
|
5467
|
+
filesystemIncarnationProvenance?: "fresh" | "restored" | "unknown";
|
|
5468
|
+
/** Whether this incarnation is safe for consumers to treat as authoritative. */
|
|
5469
|
+
filesystemIncarnationReadiness?: "transitioning" | "ready";
|
|
5470
|
+
/** Current status */
|
|
5471
|
+
status: SandboxStatus;
|
|
5472
|
+
/** Connection information */
|
|
5473
|
+
connection?: SandboxConnection;
|
|
5474
|
+
/** Custom metadata */
|
|
5475
|
+
metadata?: Record<string, unknown>;
|
|
5476
|
+
/** Verified current container identity, available on create and get. */
|
|
5477
|
+
captureProof?: SandboxCreateReceipt["captureProof"];
|
|
5777
5478
|
/**
|
|
5778
|
-
*
|
|
5779
|
-
*
|
|
5780
|
-
*
|
|
5781
|
-
*
|
|
5782
|
-
*
|
|
5783
|
-
*
|
|
5784
|
-
*
|
|
5785
|
-
* Responses computer-use surface. Required if you plan to call
|
|
5786
|
-
* {@link SandboxInstance.getMcpAccessToken | `getMcpAccessToken`}
|
|
5787
|
-
* with `capabilities: ["computer_use"]`.
|
|
5788
|
-
*
|
|
5789
|
-
* The capability is enforced at two layers:
|
|
5790
|
-
* 1. The sidecar refuses to start if a capability's binaries are
|
|
5791
|
-
* missing (`computer_use` needs the mounted Nix profile with
|
|
5792
|
-
* Xvfb, dbus, xdotool, and scrot available at runtime).
|
|
5793
|
-
* 2. The MCP token endpoint refuses to mint a `cap: ["computer_use"]`
|
|
5794
|
-
* JWT for a sandbox that wasn't created with that capability.
|
|
5795
|
-
*
|
|
5796
|
-
* **Sizing note:** `computer_use` boots an always-on Xvfb + dbus
|
|
5797
|
-
* stack costing roughly **~100 MB resident memory** inside the
|
|
5798
|
-
* container. Billing is by reserved capacity (not measured RSS), so
|
|
5799
|
-
* this comes out of your sandbox's RAM envelope rather than adding
|
|
5800
|
-
* a separate line item. On a 1 GB sandbox that is ~10% of your
|
|
5801
|
-
* workload's headroom; bump `resources.memoryMB` to 1.5–2 GB if
|
|
5802
|
-
* the agent will run anything memory-hungry alongside it.
|
|
5803
|
-
*
|
|
5804
|
-
* @example
|
|
5805
|
-
* ```typescript
|
|
5806
|
-
* const box = await client.create({
|
|
5807
|
-
* capabilities: ["computer_use"],
|
|
5808
|
-
* });
|
|
5809
|
-
* const { token } = await box.getMcpAccessToken({
|
|
5810
|
-
* capabilities: ["computer_use"],
|
|
5811
|
-
* });
|
|
5812
|
-
* ```
|
|
5479
|
+
* Server-derived compliance echo (HIPAA), read-only: present only as the
|
|
5480
|
+
* positive claim `{ hipaa: true }`, pinned from verified Platform
|
|
5481
|
+
* attribution at provision. There is deliberately NO create option for
|
|
5482
|
+
* this — a caller-asserted compliance flag would let a tenant either
|
|
5483
|
+
* dodge the observability gates or claim protection the platform never
|
|
5484
|
+
* granted. Absent means the platform made no claim; `hipaa: false` is
|
|
5485
|
+
* never emitted.
|
|
5813
5486
|
*/
|
|
5814
|
-
|
|
5487
|
+
readonly compliance?: {
|
|
5488
|
+
readonly hipaa: true;
|
|
5489
|
+
};
|
|
5490
|
+
/** When the sandbox was created */
|
|
5491
|
+
createdAt: Date;
|
|
5492
|
+
/** When the sandbox started running */
|
|
5493
|
+
startedAt?: Date;
|
|
5494
|
+
/** Last activity timestamp */
|
|
5495
|
+
lastActivityAt?: Date;
|
|
5496
|
+
/** When the sandbox will expire */
|
|
5497
|
+
expiresAt?: Date;
|
|
5498
|
+
/** Error message if status is 'failed' */
|
|
5499
|
+
error?: string;
|
|
5500
|
+
/** GPU lease attached during sandbox creation, when requested. */
|
|
5501
|
+
gpuLease?: GpuLease;
|
|
5815
5502
|
/**
|
|
5816
|
-
*
|
|
5817
|
-
*
|
|
5818
|
-
*
|
|
5819
|
-
*
|
|
5820
|
-
*
|
|
5821
|
-
*
|
|
5822
|
-
* validated), SSNs, phone numbers, IPv4 addresses are caught
|
|
5823
|
-
* today; names / postal addresses / DOBs land when the OPF
|
|
5824
|
-
* model service is enabled. The agent receives normal
|
|
5825
|
-
* responses; the vendor sees masked input.
|
|
5826
|
-
* - `"block"` — PII presence fails the egress request closed.
|
|
5827
|
-
* For high-compliance flows that prefer fail-closed to leak.
|
|
5828
|
-
* - `"off"` — no egress filtering. Default for free tier; opt-in
|
|
5829
|
-
* for tasks that genuinely need raw PII (form-filling,
|
|
5830
|
-
* customer-support agents reading customer details).
|
|
5831
|
-
*
|
|
5832
|
-
* - **`logs`** — whether infrastructure logs / telemetry / Sentry
|
|
5833
|
-
* redact PII before recording. This is OUR side, not the model
|
|
5834
|
-
* vendor's, and there's basically never a reason to leak PII into
|
|
5835
|
-
* our own logs. Default `"on"`.
|
|
5836
|
-
*
|
|
5837
|
-
* Note: privacy controls operate at the boundary between the
|
|
5838
|
-
* sandbox and external systems. They do NOT redact contents inside
|
|
5839
|
-
* the sandbox workspace itself — files / code / database fixtures
|
|
5840
|
-
* the customer puts there are the customer's data and stay
|
|
5841
|
-
* unmodified. Snapshots preserve those contents verbatim.
|
|
5842
|
-
*
|
|
5843
|
-
* @example
|
|
5844
|
-
* ```typescript
|
|
5845
|
-
* const box = await client.create({
|
|
5846
|
-
* privacy: { egress: "redact", logs: "on" },
|
|
5847
|
-
* });
|
|
5848
|
-
* ```
|
|
5503
|
+
* The shape the sandbox was granted. Always present on the create response
|
|
5504
|
+
* and on a `get` whose billing record could be read; absent on a list row
|
|
5505
|
+
* and when the platform has no record to read, where it reports no grant
|
|
5506
|
+
* rather than a default the box may not be running at. A sandbox created
|
|
5507
|
+
* before the platform recorded shapes reports what its billing row holds,
|
|
5508
|
+
* which for such a row is the repair value the ledger charges.
|
|
5849
5509
|
*/
|
|
5850
|
-
|
|
5851
|
-
egress?: "redact" | "block" | "off";
|
|
5852
|
-
logs?: "on" | "off";
|
|
5853
|
-
};
|
|
5510
|
+
resources?: SandboxShape;
|
|
5854
5511
|
/**
|
|
5855
|
-
*
|
|
5856
|
-
*
|
|
5857
|
-
*
|
|
5858
|
-
*
|
|
5859
|
-
* starting a fresh cold start per retry. When omitted, the SDK
|
|
5860
|
-
* generates one per `create()` call and reuses it across its own
|
|
5861
|
-
* timeout-driven retries.
|
|
5512
|
+
* Startup phase breakdown, present only on the create response (the
|
|
5513
|
+
* platform emits it once, at provision time). Use
|
|
5514
|
+
* {@link SandboxInstance.startupDiagnostics} rather than reading this
|
|
5515
|
+
* directly.
|
|
5862
5516
|
*/
|
|
5863
|
-
|
|
5517
|
+
startupDiagnostics?: StartupDiagnostics;
|
|
5864
5518
|
/**
|
|
5865
|
-
*
|
|
5866
|
-
*
|
|
5867
|
-
*
|
|
5868
|
-
*
|
|
5869
|
-
* verified API key ID is allow-listed; otherwise strict deployments reject
|
|
5870
|
-
* the create.
|
|
5871
|
-
* It never grants the caller permission to charge arbitrary users.
|
|
5872
|
-
*
|
|
5873
|
-
* This option applies to the HTTP Sandbox API client. Direct Tangle job
|
|
5874
|
-
* creation does not support delegated billing.
|
|
5519
|
+
* The platform verdict for the create call that returned this sandbox.
|
|
5520
|
+
* Present only on the create response. An absent value means the platform
|
|
5521
|
+
* reported no receipt: treat it as `unknown`, never as `created`. Use
|
|
5522
|
+
* {@link SandboxInstance.createReceipt} rather than reading this directly.
|
|
5875
5523
|
*/
|
|
5876
|
-
|
|
5524
|
+
createReceipt?: SandboxCreateReceipt;
|
|
5525
|
+
/** Resolved egress policy */
|
|
5526
|
+
egressPolicy?: EgressPolicy;
|
|
5527
|
+
/** Source of the egress policy */
|
|
5528
|
+
egressPolicySource?: "sandbox" | "team" | "platform";
|
|
5529
|
+
}
|
|
5530
|
+
/** Basic health reported by the runtime inside a sandbox. */
|
|
5531
|
+
interface SandboxRuntimeHealth {
|
|
5532
|
+
status: string;
|
|
5533
|
+
docker: {
|
|
5534
|
+
enabled: boolean;
|
|
5535
|
+
status: string;
|
|
5536
|
+
dockerHost?: string;
|
|
5537
|
+
error?: string;
|
|
5538
|
+
};
|
|
5539
|
+
backends: {
|
|
5540
|
+
total: number;
|
|
5541
|
+
byType: Record<string, number>;
|
|
5542
|
+
pending: number;
|
|
5543
|
+
};
|
|
5544
|
+
timestamp: string;
|
|
5545
|
+
}
|
|
5546
|
+
/** Public preview link associated with a listening runtime port. */
|
|
5547
|
+
interface SandboxPortPreviewLink {
|
|
5548
|
+
previewId: string;
|
|
5549
|
+
url: string;
|
|
5550
|
+
status: string;
|
|
5551
|
+
}
|
|
5552
|
+
/** One process listening on a port inside a sandbox. */
|
|
5553
|
+
interface SandboxPortBinding {
|
|
5554
|
+
pid: number;
|
|
5555
|
+
processName: string;
|
|
5556
|
+
commandPath: string;
|
|
5557
|
+
port: number;
|
|
5558
|
+
protocol: "tcp" | "udp";
|
|
5559
|
+
localAddress: string;
|
|
5560
|
+
family: "tcp4" | "tcp6" | "udp4" | "udp6";
|
|
5561
|
+
allowlisted: boolean;
|
|
5562
|
+
firstSeenAt: string;
|
|
5563
|
+
lastSeenAt: string;
|
|
5564
|
+
previewLink?: SandboxPortPreviewLink;
|
|
5565
|
+
}
|
|
5566
|
+
/** Options for creating an interactive terminal. */
|
|
5567
|
+
interface SandboxTerminalCreateOptions {
|
|
5568
|
+
name?: string;
|
|
5569
|
+
description?: string;
|
|
5570
|
+
shell?: string;
|
|
5571
|
+
cwd?: string;
|
|
5572
|
+
cols?: number;
|
|
5573
|
+
rows?: number;
|
|
5574
|
+
}
|
|
5575
|
+
/** Runtime request context used to attribute terminal events to an agent session. */
|
|
5576
|
+
interface SandboxTerminalRequestOptions {
|
|
5577
|
+
sessionId?: string;
|
|
5578
|
+
}
|
|
5579
|
+
/** Interactive terminal metadata returned by the runtime. */
|
|
5580
|
+
interface SandboxTerminalInfo {
|
|
5581
|
+
sessionId: string;
|
|
5582
|
+
connectionId?: string;
|
|
5583
|
+
name?: string;
|
|
5584
|
+
description?: string;
|
|
5585
|
+
shell?: string;
|
|
5586
|
+
command?: string;
|
|
5587
|
+
cwd?: string;
|
|
5588
|
+
cols?: number;
|
|
5589
|
+
rows?: number;
|
|
5590
|
+
createdAt?: string;
|
|
5591
|
+
lastActivityAt?: string;
|
|
5592
|
+
isRunning?: boolean;
|
|
5593
|
+
exitCode?: number;
|
|
5594
|
+
exitSignal?: string;
|
|
5595
|
+
/** WebSocket path for terminal input/output. */
|
|
5596
|
+
streamUrl?: string;
|
|
5597
|
+
history?: unknown[];
|
|
5598
|
+
}
|
|
5599
|
+
/** Interactive terminal operations. Input/output flows over `streamUrl`. */
|
|
5600
|
+
interface SandboxTerminalManager {
|
|
5601
|
+
create(options?: SandboxTerminalCreateOptions, request?: SandboxTerminalRequestOptions): Promise<SandboxTerminalInfo>;
|
|
5602
|
+
/** Send input through the runtime's HTTP fallback for an existing terminal. */
|
|
5603
|
+
input(terminalId: string, data: string, request?: SandboxTerminalRequestOptions): Promise<void>;
|
|
5604
|
+
list(): Promise<SandboxTerminalInfo[]>;
|
|
5605
|
+
get(sessionId: string): Promise<SandboxTerminalInfo | null>;
|
|
5606
|
+
}
|
|
5607
|
+
/** Options for `box.terminals.attach()`. */
|
|
5608
|
+
interface SandboxTerminalAttachOptions {
|
|
5609
|
+
/** Initial PTY geometry reported in the attach init frame. */
|
|
5610
|
+
cols?: number;
|
|
5611
|
+
rows?: number;
|
|
5612
|
+
/** Command to run when the connection id has no live PTY (default: shell). */
|
|
5613
|
+
command?: string;
|
|
5614
|
+
cwd?: string;
|
|
5615
|
+
env?: Record<string, string>;
|
|
5877
5616
|
/**
|
|
5878
|
-
*
|
|
5879
|
-
*
|
|
5880
|
-
*
|
|
5881
|
-
*
|
|
5882
|
-
* hold. Fixed for the sandbox's life. Personal sandboxes only. Defaults to
|
|
5883
|
-
* the wallet.
|
|
5617
|
+
* Stream callbacks, bound before the socket opens. Register `onData` here:
|
|
5618
|
+
* a reattached PTY replays its buffered screen immediately after the
|
|
5619
|
+
* attach acknowledgement, so a handler added after `attach()` resolves
|
|
5620
|
+
* would miss the replayed frames.
|
|
5884
5621
|
*/
|
|
5885
|
-
|
|
5622
|
+
handlers?: TerminalStreamHandlers;
|
|
5623
|
+
}
|
|
5624
|
+
/**
|
|
5625
|
+
* `box.terminals` — the REST terminal manager plus the live PTY attach
|
|
5626
|
+
* surface. `attach()` opens the terminal WebSocket through the secured
|
|
5627
|
+
* sidecar proxy — a Node caller sends its API key on the upgrade, a browser a
|
|
5628
|
+
* short-lived scoped token minted per dial — as a
|
|
5629
|
+
* {@link TerminalStream}: reusing a connection id reattaches the existing
|
|
5630
|
+
* PTY and replays its history; a new id spawns a fresh shell (or `command`).
|
|
5631
|
+
*/
|
|
5632
|
+
interface SandboxTerminals extends SandboxTerminalManager {
|
|
5633
|
+
attach(connectionId: string, options?: SandboxTerminalAttachOptions): Promise<TerminalStream>;
|
|
5634
|
+
}
|
|
5635
|
+
/**
|
|
5636
|
+
* Raw TEE attestation evidence returned by the sandbox runtime.
|
|
5637
|
+
*
|
|
5638
|
+
* Pass this object to `@tangle-network/tcloud-attestation` for caller-side
|
|
5639
|
+
* policy checks and hardware verification.
|
|
5640
|
+
*/
|
|
5641
|
+
interface TeeAttestationReport {
|
|
5642
|
+
/** TEE backend that produced the report, e.g. `Tdx`, `Sev`, or `Nitro`. */
|
|
5643
|
+
tee_type: string;
|
|
5644
|
+
/** Raw vendor evidence bytes. */
|
|
5645
|
+
evidence: number[];
|
|
5646
|
+
/** Runtime measurement bytes. */
|
|
5647
|
+
measurement: number[];
|
|
5648
|
+
/** Unix timestamp when the report was generated. */
|
|
5649
|
+
timestamp: number;
|
|
5650
|
+
}
|
|
5651
|
+
/**
|
|
5652
|
+
* Response from a sandbox TEE attestation request.
|
|
5653
|
+
*/
|
|
5654
|
+
interface TeeAttestationResponse {
|
|
5655
|
+
/** Sandbox identifier the attestation belongs to. */
|
|
5656
|
+
sandbox_id: string;
|
|
5657
|
+
/** Raw TEE attestation report. */
|
|
5658
|
+
attestation: TeeAttestationReport;
|
|
5659
|
+
/** Caller nonce used for this report, when supplied. */
|
|
5660
|
+
attestationNonce?: string;
|
|
5661
|
+
}
|
|
5662
|
+
/**
|
|
5663
|
+
* TEE-bound public key used for sealed-secret encryption.
|
|
5664
|
+
*/
|
|
5665
|
+
interface TeePublicKey {
|
|
5666
|
+
/** Key agreement/encryption algorithm, e.g. `x25519-hkdf-sha256`. */
|
|
5667
|
+
algorithm: string;
|
|
5668
|
+
/** Raw public key bytes. */
|
|
5669
|
+
public_key_bytes: number[];
|
|
5670
|
+
/** Attestation report binding this key to the enclave. */
|
|
5671
|
+
attestation: TeeAttestationReport;
|
|
5672
|
+
}
|
|
5673
|
+
/**
|
|
5674
|
+
* Response from a sandbox TEE public-key request.
|
|
5675
|
+
*/
|
|
5676
|
+
interface TeePublicKeyResponse {
|
|
5677
|
+
/** Sandbox identifier the public key belongs to. */
|
|
5678
|
+
sandbox_id: string;
|
|
5679
|
+
/** TEE-bound public key and its attestation proof. */
|
|
5680
|
+
public_key: TeePublicKey;
|
|
5681
|
+
}
|
|
5682
|
+
/**
|
|
5683
|
+
* Options for requesting fresh TEE attestation evidence.
|
|
5684
|
+
*/
|
|
5685
|
+
interface TeeAttestationOptions {
|
|
5886
5686
|
/**
|
|
5887
|
-
*
|
|
5888
|
-
*
|
|
5889
|
-
*
|
|
5890
|
-
* together with `billingOwnerId` from an allow-listed first-party service
|
|
5891
|
-
* key, and refuses every other create with 403 `CAPACITY_CLASS_FORBIDDEN`.
|
|
5892
|
-
* It restricts placement and is not a priority: no host outside the spare
|
|
5893
|
-
* pool takes the sandbox, and the create is refused with 503
|
|
5894
|
-
* `SPARE_CAPACITY_UNAVAILABLE` when no spare pool admits it. It also skips
|
|
5895
|
-
* the warm pool. The class is fixed at create; resume keeps it.
|
|
5687
|
+
* Hex-encoded 32-64 byte caller nonce. When supported by the selected TEE
|
|
5688
|
+
* backend, the runtime binds this to report data so the caller can reject
|
|
5689
|
+
* replayed quotes.
|
|
5896
5690
|
*/
|
|
5897
|
-
|
|
5691
|
+
attestationNonce?: string;
|
|
5692
|
+
}
|
|
5693
|
+
/**
|
|
5694
|
+
* Options for listing sandboxes.
|
|
5695
|
+
*/
|
|
5696
|
+
interface ListSandboxOptions {
|
|
5697
|
+
/** Filter by status */
|
|
5698
|
+
status?: SandboxStatus | SandboxStatus[];
|
|
5699
|
+
/** Filter personal/team visibility scope */
|
|
5700
|
+
scope?: "personal" | "team" | "all" | `team:${string}`;
|
|
5701
|
+
/** Maximum number of results */
|
|
5702
|
+
limit?: number;
|
|
5703
|
+
/** Offset for pagination */
|
|
5704
|
+
offset?: number;
|
|
5705
|
+
/** Only sandboxes created with this `metadata.run` (the caller's run id). */
|
|
5706
|
+
run?: string;
|
|
5707
|
+
}
|
|
5708
|
+
/**
|
|
5709
|
+
* One compute generation of a sandbox created for a caller run
|
|
5710
|
+
* (`metadata.run`). Deleted sandboxes keep theirs.
|
|
5711
|
+
*/
|
|
5712
|
+
interface SandboxRunGeneration {
|
|
5713
|
+
sandboxId: string;
|
|
5714
|
+
/** The sandbox's own compute generation id, not the caller run. */
|
|
5715
|
+
generation: string;
|
|
5716
|
+
generationSeq: number;
|
|
5717
|
+
orgId: string;
|
|
5718
|
+
state: string;
|
|
5719
|
+
startedAt: number;
|
|
5720
|
+
closedAt: number | null;
|
|
5721
|
+
closedReason: string | null;
|
|
5722
|
+
}
|
|
5723
|
+
//#endregion
|
|
5724
|
+
//#region src/types/fleet.d.ts
|
|
5725
|
+
/**
|
|
5726
|
+
* Stable worker identifier inside a sandbox fleet.
|
|
5727
|
+
*
|
|
5728
|
+
* Machine IDs are intentionally narrower than sandbox names so agents
|
|
5729
|
+
* can route work without smuggling shell metacharacters or path-like
|
|
5730
|
+
* values through tool calls.
|
|
5731
|
+
*/
|
|
5732
|
+
type FleetMachineId = string;
|
|
5733
|
+
/** Stable id of one agent in a fleet. It is also the agent's session id on its sandbox. */
|
|
5734
|
+
type FleetAgentId = string;
|
|
5735
|
+
/**
|
|
5736
|
+
* Where one agent runs. `shared` agents share a sandbox's filesystem, CPU and
|
|
5737
|
+
* memory with other agents of the same fleet; `dedicated` gives the agent a
|
|
5738
|
+
* sandbox of its own (repository writes, untrusted code).
|
|
5739
|
+
*/
|
|
5740
|
+
type FleetAgentPlacement = "shared" | "dedicated";
|
|
5741
|
+
/**
|
|
5742
|
+
* A saved profile from the Platform agent-profile catalog
|
|
5743
|
+
* (`GET /v1/agent-profiles/:id`). With `revision`, create refuses the fleet
|
|
5744
|
+
* unless the catalog still holds exactly that revision.
|
|
5745
|
+
*/
|
|
5746
|
+
interface SandboxFleetProfileRef {
|
|
5747
|
+
profileId: string;
|
|
5748
|
+
revision?: number;
|
|
5749
|
+
}
|
|
5750
|
+
interface SandboxFleetAgentSpec {
|
|
5751
|
+
/** Defaults to `agent-<index>`. */
|
|
5752
|
+
agentId?: FleetAgentId;
|
|
5753
|
+
/** Defaults to `shared`. */
|
|
5754
|
+
placement?: FleetAgentPlacement;
|
|
5755
|
+
/** Harness this agent runs. Defaults to `profile.harness`, then `defaults.backend.type`. */
|
|
5756
|
+
harness?: BackendType;
|
|
5898
5757
|
/**
|
|
5899
|
-
*
|
|
5900
|
-
*
|
|
5901
|
-
*
|
|
5902
|
-
* running.
|
|
5903
|
-
*
|
|
5904
|
-
* When `true` (the default), a profile with sizeable inline mounts (e.g.
|
|
5905
|
-
* skills, tool scripts) does not bloat the create POST; the SDK
|
|
5906
|
-
* materializes those files via {@link FileSystem.writeMany} /
|
|
5907
|
-
* {@link FileSystem.uploadData} after the sandbox reaches `running`. A batch
|
|
5908
|
-
* write answered 502, 503 or 504, or lost with its connection, is sent again
|
|
5909
|
-
* for up to 10 seconds before create() raises `PartialFailureError`. Only
|
|
5910
|
-
* applies to an inline `AgentProfile` object on `backend.profile`; a
|
|
5911
|
-
* named-profile string is never split. Set `false` to send the full profile
|
|
5912
|
-
* in the create request without a post-create materialization step.
|
|
5913
|
-
*
|
|
5914
|
-
* @default true
|
|
5758
|
+
* Model this agent runs: a model id, or a model config (`provider`,
|
|
5759
|
+
* `baseUrl`, `apiKeyEnv` naming a sandbox env var that holds the key).
|
|
5760
|
+
* Defaults to `profile.model.default`, then `defaults.backend.model`.
|
|
5915
5761
|
*/
|
|
5916
|
-
|
|
5762
|
+
model?: string | NonNullable<BackendConfig["model"]>;
|
|
5917
5763
|
/**
|
|
5918
|
-
*
|
|
5919
|
-
*
|
|
5920
|
-
*
|
|
5921
|
-
*
|
|
5922
|
-
* references it by hash (`backend.profileSha256`) on subsequent turns. The
|
|
5923
|
-
* handle still holds the full profile, so a cache miss transparently resends
|
|
5924
|
-
* it.
|
|
5925
|
-
*
|
|
5926
|
-
* When `false`, the full profile, including skills, travels with the create
|
|
5927
|
-
* request and every turn. This applies only to an inline `AgentProfile`
|
|
5928
|
-
* object on `backend.profile` and is independent of
|
|
5929
|
-
* {@link autoMaterializeProfileFiles}.
|
|
5930
|
-
*
|
|
5931
|
-
* A turn only substitutes the hash reference when the outgoing profile's
|
|
5932
|
-
* content still matches what was primed: mutate the profile (or pass a
|
|
5933
|
-
* changed per-turn `backend.profile`) and that turn sends the full profile
|
|
5934
|
-
* inline again, so the runtime always runs the profile you passed.
|
|
5935
|
-
*
|
|
5936
|
-
* @default true
|
|
5764
|
+
* The agent's profile: an inline `AgentProfile`, or a saved profile by id.
|
|
5765
|
+
* Every turn sends it as `backend.profile`, so the runtime materializes its
|
|
5766
|
+
* skills, instructions, MCP servers and files into the agent's own harness
|
|
5767
|
+
* session. Defaults to `defaults.backend.profile`.
|
|
5937
5768
|
*/
|
|
5938
|
-
|
|
5769
|
+
profile?: AgentProfile | SandboxFleetProfileRef;
|
|
5770
|
+
/** Runtime MCP bindings for this agent, separate from its profile. */
|
|
5771
|
+
runtimeAttachments?: AgentRuntimeAttachments;
|
|
5772
|
+
/** The agent's own task. `run()` sends it when called without a message. */
|
|
5773
|
+
task?: string | PromptInputPart[];
|
|
5939
5774
|
}
|
|
5940
5775
|
/**
|
|
5941
|
-
*
|
|
5776
|
+
* How a fleet packs agents onto sandboxes.
|
|
5777
|
+
*
|
|
5778
|
+
* - `auto` (default): as many agents per sandbox as its memory holds, from
|
|
5779
|
+
* the measured footprint of an idle sandbox and of one agent.
|
|
5780
|
+
* - `dedicated`: one sandbox per agent.
|
|
5781
|
+
* - `{ agentsPerSandbox }`: exactly that many shared agents per sandbox.
|
|
5942
5782
|
*/
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5783
|
+
type SandboxFleetPlacement = "auto" | "dedicated" | {
|
|
5784
|
+
agentsPerSandbox: number;
|
|
5785
|
+
};
|
|
5786
|
+
/** The fleet and agent that spawned a child fleet. */
|
|
5787
|
+
interface SandboxFleetParent {
|
|
5788
|
+
fleetId: string;
|
|
5789
|
+
agentId: FleetAgentId;
|
|
5790
|
+
}
|
|
5791
|
+
/** One agent of a fleet and the sandbox that hosts it. */
|
|
5792
|
+
interface SandboxFleetAgent {
|
|
5793
|
+
agentId: FleetAgentId;
|
|
5794
|
+
machineId: FleetMachineId;
|
|
5795
|
+
sandboxId: string;
|
|
5796
|
+
/** Session the agent's turns run in; equal to `agentId`. */
|
|
5797
|
+
sessionId: string;
|
|
5798
|
+
/** Harness the agent runs; unset means the sandbox's default backend. */
|
|
5799
|
+
harness?: BackendType;
|
|
5800
|
+
/** Model the agent runs; unset means the sandbox's default model. */
|
|
5801
|
+
model?: string;
|
|
5802
|
+
/** Name of the agent's profile, when it has one. */
|
|
5803
|
+
profileName?: string;
|
|
5953
5804
|
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
interface SSHCredentials {
|
|
5960
|
-
/** Username for SSH authentication */
|
|
5961
|
-
username: string;
|
|
5962
|
-
/** SSH server port */
|
|
5963
|
-
port: number;
|
|
5964
|
-
/** ProxyCommand for sandbox API tunnel-based SSH. */
|
|
5965
|
-
proxyCommand: string;
|
|
5805
|
+
interface FleetRunOptions extends Pick<PromptOptions, "timeoutMs" | "context"> {
|
|
5806
|
+
/** Agents to run. Defaults to every agent in the fleet. */
|
|
5807
|
+
agents?: FleetAgentId[];
|
|
5808
|
+
/** Aborts every agent turn this run started. */
|
|
5809
|
+
signal?: AbortSignal;
|
|
5966
5810
|
}
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5811
|
+
type FleetAgentRunStatus = "completed" | "failed" | "cancelled" | "budget_exhausted";
|
|
5812
|
+
interface FleetAgentResult extends SandboxFleetAgent {
|
|
5813
|
+
/**
|
|
5814
|
+
* `budget_exhausted`: the Platform refused the turn's model or compute
|
|
5815
|
+
* charge because the fleet's key budget is spent.
|
|
5816
|
+
*/
|
|
5817
|
+
status: FleetAgentRunStatus;
|
|
5818
|
+
/** The agent's turn result: response text, token usage, trace id. */
|
|
5819
|
+
result?: PromptResult;
|
|
5820
|
+
/** Model cost the runtime reported for this turn, when it reported one. */
|
|
5821
|
+
costUsd?: number;
|
|
5822
|
+
durationMs: number;
|
|
5823
|
+
error?: string;
|
|
5970
5824
|
}
|
|
5825
|
+
type FleetRunEvent = ({
|
|
5826
|
+
type: "agent.started";
|
|
5827
|
+
traceId: string;
|
|
5828
|
+
} & SandboxFleetAgent) | {
|
|
5829
|
+
type: "agent.finished";
|
|
5830
|
+
result: FleetAgentResult;
|
|
5831
|
+
} | {
|
|
5832
|
+
type: "fleet.finished";
|
|
5833
|
+
results: FleetAgentResult[]; /** Metered spend when it could be read; the results never depend on it. */
|
|
5834
|
+
spend?: SandboxFleetSpend;
|
|
5835
|
+
spendError?: string;
|
|
5836
|
+
durationMs: number;
|
|
5837
|
+
};
|
|
5971
5838
|
/**
|
|
5972
|
-
*
|
|
5973
|
-
*
|
|
5974
|
-
*
|
|
5975
|
-
*
|
|
5976
|
-
* lower-level use cases such as custom protocol clients.
|
|
5839
|
+
* Spend of a capped fleet, metered by the Platform on the fleet's budgeted
|
|
5840
|
+
* key: every router call and compute charge of every sandbox the fleet
|
|
5841
|
+
* created, whichever process or handle drove it. A child fleet's cap is
|
|
5842
|
+
* reserved from its parent's budget when the child is created.
|
|
5977
5843
|
*/
|
|
5978
|
-
interface
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
/** Access token for authenticating directly with the runtime (Bearer token) */
|
|
5987
|
-
authToken?: string;
|
|
5988
|
-
/** Token expiration timestamp (ISO 8601). Refresh before this time. */
|
|
5989
|
-
authTokenExpiresAt?: string;
|
|
5990
|
-
/** Public inbound edge attachment state for `runtimeUrl`. */
|
|
5991
|
-
edgeStatus?: "pending" | "ready" | "failed" | "skipped";
|
|
5992
|
-
/** Timestamp when the public edge reached this sandbox. */
|
|
5993
|
-
edgeReadyAt?: string;
|
|
5994
|
-
/** Last public edge attachment error message. */
|
|
5995
|
-
edgeError?: string;
|
|
5996
|
-
/** SSH connection info if `sshEnabled` was true during creation */
|
|
5997
|
-
ssh?: SSHCredentials;
|
|
5998
|
-
/** Web terminal URL if `webTerminalEnabled` was true during creation */
|
|
5999
|
-
webTerminalUrl?: string;
|
|
5844
|
+
interface SandboxFleetSpend {
|
|
5845
|
+
capUsd: number;
|
|
5846
|
+
/** Charges the Platform has settled against the fleet's key. */
|
|
5847
|
+
spentUsd: number;
|
|
5848
|
+
/** Budget held for child fleets' caps. */
|
|
5849
|
+
reservedForChildrenUsd: number;
|
|
5850
|
+
/** What the fleet may still spend or allocate: cap minus spent minus reserved. */
|
|
5851
|
+
remainingUsd: number;
|
|
6000
5852
|
}
|
|
5853
|
+
type SandboxFleetMachineRole = "coordinator" | "worker";
|
|
6001
5854
|
/**
|
|
6002
|
-
*
|
|
6003
|
-
* platform startup pipeline. Mirrors the platform
|
|
6004
|
-
* `StartupOperationTiming` shape one-to-one.
|
|
5855
|
+
* Resource policy for a single fleet create call.
|
|
6005
5856
|
*
|
|
6006
|
-
* -
|
|
6007
|
-
*
|
|
6008
|
-
* - `durationMs` is wall-clock time the step took. The platform
|
|
6009
|
-
* marks it optional on `skipped` steps, so it is optional here too.
|
|
5857
|
+
* These caps are enforced client-side before any sandbox is created.
|
|
5858
|
+
* Server-side plan quotas still apply and remain the source of truth.
|
|
6010
5859
|
*/
|
|
6011
|
-
interface
|
|
6012
|
-
/**
|
|
6013
|
-
|
|
6014
|
-
/**
|
|
6015
|
-
|
|
6016
|
-
/**
|
|
6017
|
-
|
|
6018
|
-
/**
|
|
6019
|
-
|
|
5860
|
+
interface SandboxFleetPolicy {
|
|
5861
|
+
/** Maximum number of machines in this create call. Defaults to machines.length. */
|
|
5862
|
+
maxMachines?: number;
|
|
5863
|
+
/** Maximum sandbox create fanout allowed for this fleet request. */
|
|
5864
|
+
maxConcurrentCreates?: number;
|
|
5865
|
+
/** Maximum total requested CPU cores across machines with explicit resources. */
|
|
5866
|
+
maxTotalCpu?: number;
|
|
5867
|
+
/** Maximum total requested memory across machines with explicit resources. */
|
|
5868
|
+
maxTotalMemoryMb?: number;
|
|
5869
|
+
/** Maximum total requested storage across machines with explicit resources. */
|
|
5870
|
+
maxTotalStorageMb?: number;
|
|
5871
|
+
/** Maximum total requested accelerator devices across machines. */
|
|
5872
|
+
maxTotalAccelerators?: number;
|
|
5873
|
+
/** Maximum lifetime in seconds for any machine in this fleet. */
|
|
5874
|
+
maxLifetimeSeconds?: number;
|
|
6020
5875
|
/**
|
|
6021
|
-
*
|
|
6022
|
-
*
|
|
6023
|
-
*
|
|
6024
|
-
*
|
|
5876
|
+
* The fleet's spend cap in USD, enforced by the Platform: the fleet's
|
|
5877
|
+
* sandboxes are created with a key budgeted at the cap, so model and compute
|
|
5878
|
+
* charges past it are refused for every process that drives the fleet. A
|
|
5879
|
+
* child fleet's cap is reserved from its parent's remaining budget.
|
|
6025
5880
|
*/
|
|
6026
|
-
|
|
6027
|
-
/**
|
|
6028
|
-
|
|
5881
|
+
maxSpendUsd?: number;
|
|
5882
|
+
/** Allowed infrastructure drivers for fleet machines. */
|
|
5883
|
+
allowedDrivers?: DriverType[];
|
|
5884
|
+
/** Allowed environments for fleet machines. */
|
|
5885
|
+
allowedEnvironments?: string[];
|
|
5886
|
+
/** Allowed personal or public template identifiers for fleet machines. */
|
|
5887
|
+
allowedTemplateIds?: string[];
|
|
5888
|
+
/** Whether machines may request accelerator devices. Defaults to allowed. */
|
|
5889
|
+
allowAccelerators?: boolean;
|
|
6029
5890
|
}
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
* `operations` is the raw ordered list from the platform. `phases`
|
|
6037
|
-
* is a derived convenience map of operation name → `durationMs` for the
|
|
6038
|
-
* steps that reported a duration; steps without a measured duration are
|
|
6039
|
-
* omitted from `phases` but still present in `operations`.
|
|
6040
|
-
*
|
|
6041
|
-
* `phases` mixes containing steps with the steps they contain, so its values
|
|
6042
|
-
* do NOT add up to the flow wall. To add durations, filter `operations` to
|
|
6043
|
-
* those no other operation names as its `parent`.
|
|
6044
|
-
*/
|
|
6045
|
-
interface StartupDiagnostics {
|
|
6046
|
-
/** Ordered startup steps exactly as the platform emitted them. */
|
|
6047
|
-
operations: StartupOperation[];
|
|
6048
|
-
/** Derived map of operation name → measured duration in milliseconds. */
|
|
6049
|
-
phases: Record<string, number>;
|
|
5891
|
+
interface SandboxFleetWorkspace {
|
|
5892
|
+
mode: "isolated" | "shared";
|
|
5893
|
+
id?: string;
|
|
5894
|
+
quotaMb?: number;
|
|
5895
|
+
mountPath?: string;
|
|
5896
|
+
snapshotId?: string;
|
|
6050
5897
|
}
|
|
6051
5898
|
/**
|
|
6052
|
-
*
|
|
5899
|
+
* Per-machine create spec for a sandbox fleet.
|
|
6053
5900
|
*/
|
|
6054
|
-
interface
|
|
6055
|
-
/**
|
|
6056
|
-
|
|
6057
|
-
/**
|
|
5901
|
+
interface SandboxFleetMachineSpec extends Omit<CreateSandboxOptions, "metadata" | "name"> {
|
|
5902
|
+
/** Stable agent-facing machine id, e.g. "coordinator" or "worker-1". */
|
|
5903
|
+
machineId: FleetMachineId;
|
|
5904
|
+
/** Optional display name. Defaults to `${fleetId}-${machineId}`. */
|
|
6058
5905
|
name?: string;
|
|
6059
|
-
/**
|
|
6060
|
-
filesystemIncarnationId?: string;
|
|
6061
|
-
/** How the current filesystem contents were acquired. */
|
|
6062
|
-
filesystemIncarnationProvenance?: "fresh" | "restored" | "unknown";
|
|
6063
|
-
/** Whether this incarnation is safe for consumers to treat as authoritative. */
|
|
6064
|
-
filesystemIncarnationReadiness?: "transitioning" | "ready";
|
|
6065
|
-
/** Current status */
|
|
6066
|
-
status: SandboxStatus;
|
|
6067
|
-
/** Connection information */
|
|
6068
|
-
connection?: SandboxConnection;
|
|
6069
|
-
/** Custom metadata */
|
|
5906
|
+
/** Machine-specific metadata. Fleet tags are added automatically. */
|
|
6070
5907
|
metadata?: Record<string, unknown>;
|
|
6071
|
-
/**
|
|
6072
|
-
|
|
5908
|
+
/** Optional orchestration role. Defaults to worker. */
|
|
5909
|
+
role?: SandboxFleetMachineRole;
|
|
5910
|
+
}
|
|
5911
|
+
/**
|
|
5912
|
+
* Create a named set of sandboxes for one workload.
|
|
5913
|
+
*/
|
|
5914
|
+
interface CreateSandboxFleetOptions {
|
|
5915
|
+
/** Stable fleet id. Generated when omitted. */
|
|
5916
|
+
fleetId?: string;
|
|
5917
|
+
/** Shared defaults applied to every machine before per-machine overrides. */
|
|
5918
|
+
defaults?: Omit<CreateSandboxOptions, "metadata" | "name">;
|
|
6073
5919
|
/**
|
|
6074
|
-
*
|
|
6075
|
-
*
|
|
6076
|
-
* attribution at provision. There is deliberately NO create option for
|
|
6077
|
-
* this — a caller-asserted compliance flag would let a tenant either
|
|
6078
|
-
* dodge the observability gates or claim protection the platform never
|
|
6079
|
-
* granted. Absent means the platform made no claim; `hipaa: false` is
|
|
6080
|
-
* never emitted.
|
|
5920
|
+
* Machines to create, for fleets driven by `dispatchExec`. Set either
|
|
5921
|
+
* `machines` or `agents`.
|
|
6081
5922
|
*/
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
5923
|
+
machines?: SandboxFleetMachineSpec[];
|
|
5924
|
+
/**
|
|
5925
|
+
* Agents to run: a count, or specs with ids and per-agent placement. The
|
|
5926
|
+
* fleet creates the sandboxes `placement` asks for, from `defaults`.
|
|
5927
|
+
*/
|
|
5928
|
+
agents?: number | SandboxFleetAgentSpec[];
|
|
5929
|
+
/** How agents are packed onto sandboxes. Defaults to `auto`. */
|
|
5930
|
+
placement?: SandboxFleetPlacement;
|
|
5931
|
+
/**
|
|
5932
|
+
* A budget in USD the Platform enforces. The fleet mints a Platform key
|
|
5933
|
+
* with this budget and creates its sandboxes and drives its turns with it,
|
|
5934
|
+
* so every charge made through the fleet counts against the budget and a
|
|
5935
|
+
* charge past it is refused. Only the client that created the fleet holds
|
|
5936
|
+
* the key: other processes can read, cancel and delete the fleet but not
|
|
5937
|
+
* run its agents. Without it, `policy.maxSpendUsd` stays a create-time
|
|
5938
|
+
* estimate check. A turn driven on a fleet sandbox with another key is
|
|
5939
|
+
* billed to that key, outside the budget.
|
|
5940
|
+
*/
|
|
5941
|
+
budgetUsd?: number;
|
|
5942
|
+
/**
|
|
5943
|
+
* The fleet and agent spawning this fleet. The API checks that the parent
|
|
5944
|
+
* exists and that this fleet's `policy.maxSpendUsd` fits in the parent's
|
|
5945
|
+
* unallocated cap; deleting or cancelling the parent reaches this fleet.
|
|
5946
|
+
*/
|
|
5947
|
+
parent?: SandboxFleetParent;
|
|
5948
|
+
/** Fleet-level metadata copied to each sandbox under stable tags. */
|
|
5949
|
+
metadata?: Record<string, unknown>;
|
|
5950
|
+
/** Workspace policy for isolated or driver-supported shared mounts. */
|
|
5951
|
+
workspace?: SandboxFleetWorkspace;
|
|
5952
|
+
/**
|
|
5953
|
+
* Client-side safety caps for this create call. These do not replace
|
|
5954
|
+
* server-side quota enforcement.
|
|
5955
|
+
*/
|
|
5956
|
+
policy?: SandboxFleetPolicy;
|
|
6097
5957
|
/**
|
|
6098
|
-
*
|
|
6099
|
-
*
|
|
6100
|
-
* and when the platform has no record to read, where it reports no grant
|
|
6101
|
-
* rather than a default the box may not be running at. A sandbox created
|
|
6102
|
-
* before the platform recorded shapes reports what its billing row holds,
|
|
6103
|
-
* which for such a row is the repair value the ledger charges.
|
|
5958
|
+
* Delete already-created machines if a later machine fails to create.
|
|
5959
|
+
* Defaults to true so partial fleets do not silently burn quota.
|
|
6104
5960
|
*/
|
|
6105
|
-
|
|
5961
|
+
cleanupOnFailure?: boolean;
|
|
6106
5962
|
/**
|
|
6107
|
-
*
|
|
6108
|
-
*
|
|
6109
|
-
*
|
|
6110
|
-
* directly.
|
|
5963
|
+
* Sandbox creates in flight at once. Defaults to 8: every create and delete
|
|
5964
|
+
* mints or revokes two Platform keys, and about 25 in flight has locked the
|
|
5965
|
+
* Platform key store for every customer (2026-09-15).
|
|
6111
5966
|
*/
|
|
6112
|
-
|
|
5967
|
+
maxConcurrentCreates?: number;
|
|
6113
5968
|
/**
|
|
6114
|
-
*
|
|
6115
|
-
* Present only on the create response. An absent value means the platform
|
|
6116
|
-
* reported no receipt: treat it as `unknown`, never as `created`. Use
|
|
6117
|
-
* {@link SandboxInstance.createReceipt} rather than reading this directly.
|
|
5969
|
+
* Idempotency key for the server-backed fleet record. Defaults to fleetId.
|
|
6118
5970
|
*/
|
|
6119
|
-
|
|
6120
|
-
/** Resolved egress policy */
|
|
6121
|
-
egressPolicy?: EgressPolicy;
|
|
6122
|
-
/** Source of the egress policy */
|
|
6123
|
-
egressPolicySource?: "sandbox" | "team" | "platform";
|
|
5971
|
+
idempotencyKey?: string;
|
|
6124
5972
|
}
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
enabled: boolean;
|
|
6130
|
-
status: string;
|
|
6131
|
-
dockerHost?: string;
|
|
6132
|
-
error?: string;
|
|
5973
|
+
interface CreateSandboxFleetWithCoordinatorOptions extends Omit<CreateSandboxFleetOptions, "machines" | "agents" | "placement"> {
|
|
5974
|
+
/** Coordinator machine. Defaults to machineId "coordinator". */
|
|
5975
|
+
coordinator?: Omit<SandboxFleetMachineSpec, "machineId" | "role"> & {
|
|
5976
|
+
machineId?: FleetMachineId;
|
|
6133
5977
|
};
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
5978
|
+
/** Worker machines attached to the same fleet. */
|
|
5979
|
+
workers: SandboxFleetMachineSpec[];
|
|
5980
|
+
}
|
|
5981
|
+
/**
|
|
5982
|
+
* A sandbox with its fleet-local machine id.
|
|
5983
|
+
*/
|
|
5984
|
+
interface SandboxFleetMachine {
|
|
5985
|
+
machineId: FleetMachineId;
|
|
5986
|
+
sandbox: SandboxInfo;
|
|
5987
|
+
role?: SandboxFleetMachineRole;
|
|
5988
|
+
}
|
|
5989
|
+
/**
|
|
5990
|
+
* Fleet create/list result.
|
|
5991
|
+
*/
|
|
5992
|
+
interface SandboxFleetInfo {
|
|
5993
|
+
fleetId: string;
|
|
5994
|
+
machines: SandboxFleetMachine[];
|
|
5995
|
+
policy?: SandboxFleetPolicy;
|
|
5996
|
+
parent?: SandboxFleetParent;
|
|
5997
|
+
createdAt?: string;
|
|
5998
|
+
/** Id of the budgeted Platform key a capped fleet's sandboxes charge. */
|
|
5999
|
+
keyId?: string;
|
|
6000
|
+
}
|
|
6001
|
+
interface FleetExecDispatchOptions extends Pick<ExecOptions, "cwd" | "env" | "timeoutMs"> {
|
|
6002
|
+
machines?: FleetMachineId[];
|
|
6003
|
+
/**
|
|
6004
|
+
* Branches in flight at once. Defaults to every selected machine. The API
|
|
6005
|
+
* runs on a Cloudflare Worker, which keeps at most six upstream connections
|
|
6006
|
+
* open per request, so branches past six queue (measured 2026-09-25: twelve
|
|
6007
|
+
* 8 s commands took 17.8 s, six took 9.7 s).
|
|
6008
|
+
*/
|
|
6009
|
+
maxConcurrent?: number;
|
|
6010
|
+
retry?: {
|
|
6011
|
+
attempts?: number;
|
|
6138
6012
|
};
|
|
6139
|
-
|
|
6013
|
+
/** Caller-supplied dispatch id for idempotency/result lookup when supported by the API. */
|
|
6014
|
+
dispatchId?: string;
|
|
6015
|
+
/** Ask the API to retain branch results for later `dispatchResults` calls. */
|
|
6016
|
+
bufferResults?: boolean;
|
|
6140
6017
|
}
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6018
|
+
interface FleetExecDispatchResult {
|
|
6019
|
+
machineId: FleetMachineId;
|
|
6020
|
+
sandboxId: string;
|
|
6021
|
+
ok: boolean;
|
|
6022
|
+
durationMs: number;
|
|
6023
|
+
attempts?: number;
|
|
6024
|
+
result?: ExecResult;
|
|
6025
|
+
error?: {
|
|
6026
|
+
message: string;
|
|
6027
|
+
status?: number;
|
|
6028
|
+
failureClass?: SandboxFleetDispatchFailureClass;
|
|
6029
|
+
retryAfterMs?: number;
|
|
6030
|
+
};
|
|
6146
6031
|
}
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
firstSeenAt: string;
|
|
6158
|
-
lastSeenAt: string;
|
|
6159
|
-
previewLink?: SandboxPortPreviewLink;
|
|
6032
|
+
interface FleetPromptDispatchOptions extends Pick<PromptOptions, "sessionId" | "backend" | "model" | "timeoutMs" | "context"> {
|
|
6033
|
+
machines?: FleetMachineId[];
|
|
6034
|
+
maxConcurrent?: number;
|
|
6035
|
+
retry?: {
|
|
6036
|
+
attempts?: number;
|
|
6037
|
+
};
|
|
6038
|
+
/** Caller-supplied dispatch id for idempotency/result lookup when supported by the API. */
|
|
6039
|
+
dispatchId?: string;
|
|
6040
|
+
/** Ask the API to retain branch results for later `dispatchResults` calls. */
|
|
6041
|
+
bufferResults?: boolean;
|
|
6160
6042
|
}
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6043
|
+
interface FleetPromptDispatchResult {
|
|
6044
|
+
machineId: FleetMachineId;
|
|
6045
|
+
sandboxId: string;
|
|
6046
|
+
ok: boolean;
|
|
6047
|
+
durationMs: number;
|
|
6048
|
+
attempts?: number;
|
|
6049
|
+
prompt?: PromptResult & {
|
|
6050
|
+
metadata?: Record<string, unknown>;
|
|
6051
|
+
};
|
|
6052
|
+
error?: {
|
|
6053
|
+
message: string;
|
|
6054
|
+
status?: number;
|
|
6055
|
+
failureClass?: SandboxFleetDispatchFailureClass;
|
|
6056
|
+
retryAfterMs?: number;
|
|
6057
|
+
};
|
|
6169
6058
|
}
|
|
6170
|
-
|
|
6171
|
-
interface
|
|
6172
|
-
|
|
6059
|
+
type SandboxFleetDispatchFailureClass = "oom" | "timeout" | "dependency" | "infra" | "model" | "user_code";
|
|
6060
|
+
interface FleetDispatchStreamOptions {
|
|
6061
|
+
signal?: AbortSignal;
|
|
6173
6062
|
}
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6063
|
+
interface FleetDispatchResultBufferOptions {
|
|
6064
|
+
cursor?: string;
|
|
6065
|
+
limit?: number;
|
|
6066
|
+
machines?: FleetMachineId[];
|
|
6067
|
+
}
|
|
6068
|
+
interface FleetDispatchResultBuffer<T = FleetExecDispatchResult> {
|
|
6069
|
+
fleetId: string;
|
|
6070
|
+
dispatchId: string;
|
|
6071
|
+
results: T[];
|
|
6072
|
+
cursor?: string;
|
|
6073
|
+
nextCursor?: string;
|
|
6074
|
+
done?: boolean;
|
|
6075
|
+
truncated?: boolean;
|
|
6076
|
+
trace?: SandboxFleetTraceExport;
|
|
6077
|
+
intelligence?: SandboxFleetIntelligenceEnvelope;
|
|
6078
|
+
}
|
|
6079
|
+
interface FleetDispatchCancelResult {
|
|
6080
|
+
fleetId: string;
|
|
6081
|
+
dispatchId: string;
|
|
6082
|
+
cancelled: boolean;
|
|
6083
|
+
status?: string;
|
|
6084
|
+
}
|
|
6085
|
+
interface SandboxFleetArtifactSpec {
|
|
6086
|
+
machineId: FleetMachineId;
|
|
6087
|
+
/**
|
|
6088
|
+
* Absolute path under /workspace. Fleet artifact collection intentionally
|
|
6089
|
+
* rejects host/system paths so caller-provided manifests cannot turn artifact
|
|
6090
|
+
* collection into arbitrary sandbox file reads.
|
|
6091
|
+
*/
|
|
6092
|
+
path: string;
|
|
6093
|
+
label?: string;
|
|
6094
|
+
/** Maximum allowed artifact content size in bytes. Defaults to 10 MiB. */
|
|
6095
|
+
maxBytes?: number;
|
|
6096
|
+
}
|
|
6097
|
+
interface SandboxFleetArtifact extends SandboxFleetArtifactSpec {
|
|
6098
|
+
sandboxId: string;
|
|
6099
|
+
content: string;
|
|
6100
|
+
}
|
|
6101
|
+
interface SandboxFleetDriverTimings {
|
|
6102
|
+
queueMs?: number;
|
|
6103
|
+
placementMs?: number;
|
|
6104
|
+
provisionMs?: number;
|
|
6105
|
+
startupMs?: number;
|
|
6106
|
+
cleanupMs?: number;
|
|
6107
|
+
}
|
|
6108
|
+
interface SandboxFleetMachineMeteredUsage {
|
|
6109
|
+
runtimeMs: number;
|
|
6110
|
+
updatedAt: string;
|
|
6111
|
+
}
|
|
6112
|
+
interface AttachSandboxFleetMachineOptions {
|
|
6113
|
+
machineId: FleetMachineId;
|
|
6114
|
+
sandboxId: string;
|
|
6115
|
+
status?: string;
|
|
6116
|
+
role?: SandboxFleetMachineRole;
|
|
6117
|
+
driverType?: DriverType;
|
|
6118
|
+
environment?: string;
|
|
6119
|
+
templateId?: string;
|
|
6120
|
+
publicTemplateId?: string;
|
|
6121
|
+
acceleratorCount?: number;
|
|
6122
|
+
driverTimings?: SandboxFleetDriverTimings;
|
|
6123
|
+
}
|
|
6124
|
+
interface SandboxFleetMachineRecord extends AttachSandboxFleetMachineOptions {
|
|
6125
|
+
workspaceMountPath?: string;
|
|
6126
|
+
meteredUsage?: SandboxFleetMachineMeteredUsage;
|
|
6185
6127
|
createdAt?: string;
|
|
6186
|
-
|
|
6187
|
-
isRunning?: boolean;
|
|
6188
|
-
exitCode?: number;
|
|
6189
|
-
exitSignal?: string;
|
|
6190
|
-
/** WebSocket path for terminal input/output. */
|
|
6191
|
-
streamUrl?: string;
|
|
6192
|
-
history?: unknown[];
|
|
6128
|
+
updatedAt?: string;
|
|
6193
6129
|
}
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6130
|
+
interface SandboxFleetManifestMachine {
|
|
6131
|
+
machineId: FleetMachineId;
|
|
6132
|
+
sandboxId: string;
|
|
6133
|
+
role?: SandboxFleetMachineRole;
|
|
6134
|
+
status?: string;
|
|
6135
|
+
driverType?: DriverType;
|
|
6136
|
+
environment?: string;
|
|
6137
|
+
templateId?: string;
|
|
6138
|
+
publicTemplateId?: string;
|
|
6139
|
+
acceleratorCount?: number;
|
|
6140
|
+
workspaceMountPath?: string;
|
|
6141
|
+
driverTimings?: SandboxFleetDriverTimings;
|
|
6142
|
+
meteredUsage?: SandboxFleetMachineMeteredUsage;
|
|
6143
|
+
createdAt?: string;
|
|
6144
|
+
updatedAt?: string;
|
|
6201
6145
|
}
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
handlers?: TerminalStreamHandlers;
|
|
6146
|
+
interface SandboxFleetManifest {
|
|
6147
|
+
fleetId?: string;
|
|
6148
|
+
id?: string;
|
|
6149
|
+
metadata?: Record<string, unknown>;
|
|
6150
|
+
policy?: SandboxFleetPolicy;
|
|
6151
|
+
resources?: Record<string, unknown>;
|
|
6152
|
+
workspace?: SandboxFleetWorkspace & {
|
|
6153
|
+
status?: string;
|
|
6154
|
+
createdAt?: string;
|
|
6155
|
+
updatedAt?: string;
|
|
6156
|
+
deletedAt?: string;
|
|
6157
|
+
};
|
|
6158
|
+
machines: SandboxFleetManifestMachine[];
|
|
6159
|
+
createdAt?: string;
|
|
6160
|
+
updatedAt?: string;
|
|
6218
6161
|
}
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
interface SandboxTerminals extends SandboxTerminalManager {
|
|
6228
|
-
attach(connectionId: string, options?: SandboxTerminalAttachOptions): Promise<TerminalStream>;
|
|
6162
|
+
interface SandboxFleetDispatchResponse<T = FleetExecDispatchResult> {
|
|
6163
|
+
fleetId: string;
|
|
6164
|
+
dispatchId: string;
|
|
6165
|
+
type: "exec" | "prompt";
|
|
6166
|
+
results: T[];
|
|
6167
|
+
durationMs: number;
|
|
6168
|
+
trace?: SandboxFleetTraceExport;
|
|
6169
|
+
intelligence?: SandboxFleetIntelligenceEnvelope;
|
|
6229
6170
|
}
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
interface TeeAttestationReport {
|
|
6237
|
-
/** TEE backend that produced the report, e.g. `Tdx`, `Sev`, or `Nitro`. */
|
|
6238
|
-
tee_type: string;
|
|
6239
|
-
/** Raw vendor evidence bytes. */
|
|
6240
|
-
evidence: number[];
|
|
6241
|
-
/** Runtime measurement bytes. */
|
|
6242
|
-
measurement: number[];
|
|
6243
|
-
/** Unix timestamp when the report was generated. */
|
|
6244
|
-
timestamp: number;
|
|
6171
|
+
interface SandboxFleetWorkspaceSnapshotResult {
|
|
6172
|
+
snapshotId?: string;
|
|
6173
|
+
id?: string;
|
|
6174
|
+
status?: string;
|
|
6175
|
+
createdAt?: string;
|
|
6176
|
+
[key: string]: JsonValue | undefined;
|
|
6245
6177
|
}
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
sandbox_id: string;
|
|
6252
|
-
/** Raw TEE attestation report. */
|
|
6253
|
-
attestation: TeeAttestationReport;
|
|
6254
|
-
/** Caller nonce used for this report, when supplied. */
|
|
6255
|
-
attestationNonce?: string;
|
|
6178
|
+
interface SandboxFleetWorkspaceRestoreResult {
|
|
6179
|
+
restored?: boolean;
|
|
6180
|
+
snapshotId?: string;
|
|
6181
|
+
status?: string;
|
|
6182
|
+
[key: string]: JsonValue | undefined;
|
|
6256
6183
|
}
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6184
|
+
interface SandboxFleetWorkspaceReconcileResult {
|
|
6185
|
+
fleetId: string;
|
|
6186
|
+
workspaceId?: string;
|
|
6187
|
+
checked: number;
|
|
6188
|
+
orphanedMounts: number;
|
|
6189
|
+
machines: Array<{
|
|
6190
|
+
machineId: string;
|
|
6191
|
+
sandboxId: string;
|
|
6192
|
+
mounted: boolean;
|
|
6193
|
+
}>;
|
|
6267
6194
|
}
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
sandbox_id: string;
|
|
6274
|
-
/** TEE-bound public key and its attestation proof. */
|
|
6275
|
-
public_key: TeePublicKey;
|
|
6195
|
+
interface SandboxFleetDriverCapability {
|
|
6196
|
+
driverType: DriverType;
|
|
6197
|
+
sharedWorkspace: boolean;
|
|
6198
|
+
accelerators: boolean;
|
|
6199
|
+
queueTimings: boolean;
|
|
6276
6200
|
}
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6201
|
+
interface SandboxFleetOperationsSummary {
|
|
6202
|
+
capacity: {
|
|
6203
|
+
fleets: number;
|
|
6204
|
+
machines: number;
|
|
6205
|
+
runningMachines: number;
|
|
6206
|
+
failedMachines: number;
|
|
6207
|
+
requestedCpu: number;
|
|
6208
|
+
requestedMemoryMb: number;
|
|
6209
|
+
requestedStorageMb: number;
|
|
6210
|
+
requestedAccelerators: number;
|
|
6211
|
+
};
|
|
6212
|
+
alerts: Array<{
|
|
6213
|
+
name: string;
|
|
6214
|
+
severity: "info" | "warn" | "critical";
|
|
6215
|
+
fleetId?: string;
|
|
6216
|
+
machineId?: string;
|
|
6217
|
+
message: string;
|
|
6218
|
+
runbook: string[];
|
|
6219
|
+
}>;
|
|
6287
6220
|
}
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
*/
|
|
6291
|
-
interface ListSandboxOptions {
|
|
6292
|
-
/** Filter by status */
|
|
6293
|
-
status?: SandboxStatus | SandboxStatus[];
|
|
6294
|
-
/** Filter personal/team visibility scope */
|
|
6295
|
-
scope?: "personal" | "team" | "all" | `team:${string}`;
|
|
6296
|
-
/** Maximum number of results */
|
|
6297
|
-
limit?: number;
|
|
6298
|
-
/** Offset for pagination */
|
|
6299
|
-
offset?: number;
|
|
6300
|
-
/** Only sandboxes created with this `metadata.run` (the caller's run id). */
|
|
6301
|
-
run?: string;
|
|
6221
|
+
interface ReconcileSandboxFleetsOptions {
|
|
6222
|
+
dryRun?: boolean;
|
|
6302
6223
|
}
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
closedReason: string | null;
|
|
6224
|
+
interface ReconcileSandboxFleetsResult {
|
|
6225
|
+
dryRun: boolean;
|
|
6226
|
+
checked: number;
|
|
6227
|
+
orphaned: number;
|
|
6228
|
+
removed: number;
|
|
6229
|
+
machines: Array<{
|
|
6230
|
+
fleetId: string;
|
|
6231
|
+
machineId: string;
|
|
6232
|
+
sandboxId: string;
|
|
6233
|
+
removed: boolean;
|
|
6234
|
+
status?: number;
|
|
6235
|
+
error?: string;
|
|
6236
|
+
}>;
|
|
6317
6237
|
}
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6238
|
+
interface SandboxFleetUsage {
|
|
6239
|
+
usage: {
|
|
6240
|
+
fleetId: string;
|
|
6241
|
+
status: string;
|
|
6242
|
+
machineCount: number;
|
|
6243
|
+
coordinatorCount: number;
|
|
6244
|
+
workerCount: number;
|
|
6245
|
+
runningMachines: number;
|
|
6246
|
+
failedMachines: number;
|
|
6247
|
+
resources?: {
|
|
6248
|
+
machines: number;
|
|
6249
|
+
totalCpu: number;
|
|
6250
|
+
totalMemoryMb: number;
|
|
6251
|
+
totalStorageMb: number;
|
|
6252
|
+
totalAccelerators: number;
|
|
6253
|
+
maxLifetimeSeconds?: number;
|
|
6254
|
+
};
|
|
6255
|
+
meteredUsage?: {
|
|
6256
|
+
runtimeMs: number;
|
|
6257
|
+
machineRuntimeMs: Record<string, number>;
|
|
6258
|
+
updatedAt: string;
|
|
6259
|
+
};
|
|
6260
|
+
createdAt: string;
|
|
6261
|
+
updatedAt: string;
|
|
6262
|
+
};
|
|
6263
|
+
insights: {
|
|
6264
|
+
reliabilityScore: number;
|
|
6265
|
+
parallelismEfficiencyScore: number;
|
|
6266
|
+
failureRate: number;
|
|
6267
|
+
recommendedActions: string[];
|
|
6268
|
+
};
|
|
6269
|
+
trace: SandboxFleetTraceExport;
|
|
6270
|
+
intelligence: SandboxFleetIntelligenceEnvelope;
|
|
6344
6271
|
}
|
|
6345
|
-
interface
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
/**
|
|
6353
|
-
* Model this agent runs: a model id, or a model config (`provider`,
|
|
6354
|
-
* `baseUrl`, `apiKeyEnv` naming a sandbox env var that holds the key).
|
|
6355
|
-
* Defaults to `profile.model.default`, then `defaults.backend.model`.
|
|
6356
|
-
*/
|
|
6357
|
-
model?: string | NonNullable<BackendConfig["model"]>;
|
|
6358
|
-
/**
|
|
6359
|
-
* The agent's profile: an inline `AgentProfile`, or a saved profile by id.
|
|
6360
|
-
* Every turn sends it as `backend.profile`, so the runtime materializes its
|
|
6361
|
-
* skills, instructions, MCP servers and files into the agent's own harness
|
|
6362
|
-
* session. Defaults to `defaults.backend.profile`.
|
|
6363
|
-
*/
|
|
6364
|
-
profile?: AgentProfile | SandboxFleetProfileRef;
|
|
6365
|
-
/** Runtime MCP bindings for this agent, separate from its profile. */
|
|
6366
|
-
runtimeAttachments?: AgentRuntimeAttachments;
|
|
6367
|
-
/** The agent's own task. `run()` sends it when called without a message. */
|
|
6368
|
-
task?: string | PromptInputPart[];
|
|
6272
|
+
interface SandboxFleetTraceEvent {
|
|
6273
|
+
type: "fleet.lifecycle.snapshot" | "fleet.machine.lifecycle.snapshot" | "fleet.workspace.lifecycle.snapshot" | "fleet.usage.snapshot" | "fleet.dispatch.result" | "fleet.insight.summary";
|
|
6274
|
+
timestamp: string;
|
|
6275
|
+
fleetId: string;
|
|
6276
|
+
machineId?: string;
|
|
6277
|
+
durationMs?: number;
|
|
6278
|
+
attributes: Record<string, unknown>;
|
|
6369
6279
|
}
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
* - `auto` (default): as many agents per sandbox as its memory holds, from
|
|
6374
|
-
* the measured footprint of an idle sandbox and of one agent.
|
|
6375
|
-
* - `dedicated`: one sandbox per agent.
|
|
6376
|
-
* - `{ agentsPerSandbox }`: exactly that many shared agents per sandbox.
|
|
6377
|
-
*/
|
|
6378
|
-
type SandboxFleetPlacement = "auto" | "dedicated" | {
|
|
6379
|
-
agentsPerSandbox: number;
|
|
6380
|
-
};
|
|
6381
|
-
/** The fleet and agent that spawned a child fleet. */
|
|
6382
|
-
interface SandboxFleetParent {
|
|
6280
|
+
interface SandboxFleetTraceExport {
|
|
6281
|
+
schemaVersion: "fleet.trace.v1";
|
|
6282
|
+
traceId: string;
|
|
6383
6283
|
fleetId: string;
|
|
6384
|
-
|
|
6284
|
+
exportedAt: string;
|
|
6285
|
+
timings: {
|
|
6286
|
+
observedLifecycleMs: number;
|
|
6287
|
+
machineObservedLifecycleMs: number;
|
|
6288
|
+
dispatchFanoutMs: number;
|
|
6289
|
+
dispatchRuntimeMs: number;
|
|
6290
|
+
cleanupObservedMs: number;
|
|
6291
|
+
driverQueueMs: number;
|
|
6292
|
+
driverPlacementMs: number;
|
|
6293
|
+
driverProvisionMs: number;
|
|
6294
|
+
driverStartupMs: number;
|
|
6295
|
+
driverCleanupMs: number;
|
|
6296
|
+
};
|
|
6297
|
+
criticalPath: {
|
|
6298
|
+
durationMs: number;
|
|
6299
|
+
phases: Array<{
|
|
6300
|
+
name: string;
|
|
6301
|
+
durationMs: number;
|
|
6302
|
+
machineId?: string;
|
|
6303
|
+
}>;
|
|
6304
|
+
};
|
|
6305
|
+
events: SandboxFleetTraceEvent[];
|
|
6385
6306
|
}
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6307
|
+
interface SandboxFleetIntelligenceEnvelope {
|
|
6308
|
+
schemaVersion: "fleet.intelligence.v1";
|
|
6309
|
+
source: "sandbox-api";
|
|
6310
|
+
subject: {
|
|
6311
|
+
type: "sandbox_fleet";
|
|
6312
|
+
fleetId: string;
|
|
6313
|
+
};
|
|
6314
|
+
billing: {
|
|
6315
|
+
billable: false;
|
|
6316
|
+
billedTo: "platform";
|
|
6317
|
+
costUsd: 0;
|
|
6318
|
+
reason: "deterministic_platform_insight";
|
|
6319
|
+
};
|
|
6320
|
+
metrics: Record<string, number>;
|
|
6321
|
+
signals: Array<{
|
|
6322
|
+
name: string;
|
|
6323
|
+
value: string | number | boolean;
|
|
6324
|
+
severity: "info" | "warn" | "critical";
|
|
6325
|
+
rationale: string;
|
|
6326
|
+
}>;
|
|
6327
|
+
recommendedActions: string[];
|
|
6399
6328
|
}
|
|
6400
|
-
interface
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
/** Aborts every agent turn this run started. */
|
|
6404
|
-
signal?: AbortSignal;
|
|
6329
|
+
interface SandboxFleetTraceBundle {
|
|
6330
|
+
trace: SandboxFleetTraceExport;
|
|
6331
|
+
intelligence?: SandboxFleetIntelligenceEnvelope;
|
|
6405
6332
|
}
|
|
6406
|
-
|
|
6407
|
-
interface FleetAgentResult extends SandboxFleetAgent {
|
|
6333
|
+
interface SandboxFleetTraceOptions {
|
|
6408
6334
|
/**
|
|
6409
|
-
*
|
|
6410
|
-
*
|
|
6335
|
+
* Include the platform-generated intelligence envelope. Defaults to false.
|
|
6336
|
+
* Set true when a customer wants generated insight with the raw trace export.
|
|
6411
6337
|
*/
|
|
6412
|
-
|
|
6413
|
-
/** The agent's turn result: response text, token usage, trace id. */
|
|
6414
|
-
result?: PromptResult;
|
|
6415
|
-
/** Model cost the runtime reported for this turn, when it reported one. */
|
|
6416
|
-
costUsd?: number;
|
|
6417
|
-
durationMs: number;
|
|
6418
|
-
error?: string;
|
|
6338
|
+
includeIntelligence?: boolean;
|
|
6419
6339
|
}
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
spentUsd: number;
|
|
6443
|
-
/** Budget held for child fleets' caps. */
|
|
6444
|
-
reservedForChildrenUsd: number;
|
|
6445
|
-
/** What the fleet may still spend or allocate: cap minus spent minus reserved. */
|
|
6446
|
-
remainingUsd: number;
|
|
6340
|
+
interface SandboxFleetCostEstimate {
|
|
6341
|
+
plan: "free" | "pro" | "enterprise";
|
|
6342
|
+
currency: "USD";
|
|
6343
|
+
hourlyUsd: number;
|
|
6344
|
+
maxLifetimeSeconds: number;
|
|
6345
|
+
estimatedMaxLifetimeUsd: number;
|
|
6346
|
+
requestedResources: {
|
|
6347
|
+
machines: number;
|
|
6348
|
+
totalCpu: number;
|
|
6349
|
+
totalMemoryMb: number;
|
|
6350
|
+
totalStorageMb: number;
|
|
6351
|
+
totalAccelerators: number;
|
|
6352
|
+
maxLifetimeSeconds?: number;
|
|
6353
|
+
};
|
|
6354
|
+
rates: {
|
|
6355
|
+
cpuPerHr: number;
|
|
6356
|
+
ramPerGbHr: number;
|
|
6357
|
+
diskPerGbHr: number;
|
|
6358
|
+
acceleratorPerDeviceHr: number;
|
|
6359
|
+
minChargePerHr: number;
|
|
6360
|
+
entDiscount: number;
|
|
6361
|
+
};
|
|
6447
6362
|
}
|
|
6448
|
-
type
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
*/
|
|
6455
|
-
|
|
6456
|
-
/** Maximum number of machines in this create call. Defaults to machines.length. */
|
|
6457
|
-
maxMachines?: number;
|
|
6458
|
-
/** Maximum sandbox create fanout allowed for this fleet request. */
|
|
6459
|
-
maxConcurrentCreates?: number;
|
|
6460
|
-
/** Maximum total requested CPU cores across machines with explicit resources. */
|
|
6461
|
-
maxTotalCpu?: number;
|
|
6462
|
-
/** Maximum total requested memory across machines with explicit resources. */
|
|
6463
|
-
maxTotalMemoryMb?: number;
|
|
6464
|
-
/** Maximum total requested storage across machines with explicit resources. */
|
|
6465
|
-
maxTotalStorageMb?: number;
|
|
6466
|
-
/** Maximum total requested accelerator devices across machines. */
|
|
6467
|
-
maxTotalAccelerators?: number;
|
|
6468
|
-
/** Maximum lifetime in seconds for any machine in this fleet. */
|
|
6469
|
-
maxLifetimeSeconds?: number;
|
|
6470
|
-
/**
|
|
6471
|
-
* The fleet's spend cap in USD, enforced by the Platform: the fleet's
|
|
6472
|
-
* sandboxes are created with a key budgeted at the cap, so model and compute
|
|
6473
|
-
* charges past it are refused for every process that drives the fleet. A
|
|
6474
|
-
* child fleet's cap is reserved from its parent's remaining budget.
|
|
6475
|
-
*/
|
|
6476
|
-
maxSpendUsd?: number;
|
|
6477
|
-
/** Allowed infrastructure drivers for fleet machines. */
|
|
6478
|
-
allowedDrivers?: DriverType[];
|
|
6479
|
-
/** Allowed environments for fleet machines. */
|
|
6480
|
-
allowedEnvironments?: string[];
|
|
6481
|
-
/** Allowed personal or public template identifiers for fleet machines. */
|
|
6482
|
-
allowedTemplateIds?: string[];
|
|
6483
|
-
/** Whether machines may request accelerator devices. Defaults to allowed. */
|
|
6484
|
-
allowAccelerators?: boolean;
|
|
6363
|
+
type SandboxFleetTokenAction = "list" | "create" | "delete" | "exec" | "prompt" | "read" | "write";
|
|
6364
|
+
interface CreateSandboxFleetTokenOptions {
|
|
6365
|
+
/** Allowed fleet actions. Defaults to read/list/exec. */
|
|
6366
|
+
actions?: SandboxFleetTokenAction[];
|
|
6367
|
+
/** Optional token-side policy caps enforced by the Sandbox API. */
|
|
6368
|
+
policy?: SandboxFleetPolicy;
|
|
6369
|
+
/** Token lifetime in minutes. API clamps to its server-side maximum. */
|
|
6370
|
+
ttlMinutes?: number;
|
|
6485
6371
|
}
|
|
6486
|
-
interface
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6372
|
+
interface SandboxFleetToken {
|
|
6373
|
+
token: string;
|
|
6374
|
+
expiresAt: number;
|
|
6375
|
+
fleetId: string;
|
|
6376
|
+
actions: SandboxFleetTokenAction[];
|
|
6377
|
+
policy?: SandboxFleetPolicy;
|
|
6378
|
+
}
|
|
6379
|
+
interface ReapExpiredSandboxFleetsOptions {
|
|
6380
|
+
dryRun?: boolean;
|
|
6381
|
+
}
|
|
6382
|
+
interface ReapExpiredSandboxFleetsResult {
|
|
6383
|
+
dryRun: boolean;
|
|
6384
|
+
expired: number;
|
|
6385
|
+
deleted: number;
|
|
6386
|
+
fleets: Array<{
|
|
6387
|
+
fleetId: string;
|
|
6388
|
+
expiredAt: string;
|
|
6389
|
+
deleted: boolean;
|
|
6390
|
+
machines: Array<{
|
|
6391
|
+
machineId: string;
|
|
6392
|
+
sandboxId: string;
|
|
6393
|
+
ok: boolean;
|
|
6394
|
+
status?: number;
|
|
6395
|
+
error?: string;
|
|
6396
|
+
}>;
|
|
6397
|
+
}>;
|
|
6398
|
+
}
|
|
6399
|
+
/**
|
|
6400
|
+
* Options for listing fleet machines.
|
|
6401
|
+
*/
|
|
6402
|
+
interface ListSandboxFleetOptions extends ListSandboxOptions {
|
|
6403
|
+
/** Fleet id to filter by. */
|
|
6404
|
+
fleetId: string;
|
|
6492
6405
|
}
|
|
6406
|
+
//#endregion
|
|
6407
|
+
//#region src/types/sessions.d.ts
|
|
6493
6408
|
/**
|
|
6494
|
-
*
|
|
6409
|
+
* Lifecycle state of an agent session inside a sandbox.
|
|
6495
6410
|
*/
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
/** Optional display name. Defaults to `${fleetId}-${machineId}`. */
|
|
6500
|
-
name?: string;
|
|
6501
|
-
/** Machine-specific metadata. Fleet tags are added automatically. */
|
|
6502
|
-
metadata?: Record<string, unknown>;
|
|
6503
|
-
/** Optional orchestration role. Defaults to worker. */
|
|
6504
|
-
role?: SandboxFleetMachineRole;
|
|
6505
|
-
}
|
|
6411
|
+
type SessionStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
6412
|
+
/** Lifecycle state of an execution retained in the session replay ledger. */
|
|
6413
|
+
type SessionExecutionStatus = "active" | "completed" | "failed" | "cancelled";
|
|
6506
6414
|
/**
|
|
6507
|
-
*
|
|
6415
|
+
* Durable metadata for one session execution.
|
|
6416
|
+
*
|
|
6417
|
+
* The values come from the runtime replay ledger, not from a provider
|
|
6418
|
+
* response or an inferred model result.
|
|
6508
6419
|
*/
|
|
6509
|
-
interface
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
*/
|
|
6518
|
-
machines?: SandboxFleetMachineSpec[];
|
|
6519
|
-
/**
|
|
6520
|
-
* Agents to run: a count, or specs with ids and per-agent placement. The
|
|
6521
|
-
* fleet creates the sandboxes `placement` asks for, from `defaults`.
|
|
6522
|
-
*/
|
|
6523
|
-
agents?: number | SandboxFleetAgentSpec[];
|
|
6524
|
-
/** How agents are packed onto sandboxes. Defaults to `auto`. */
|
|
6525
|
-
placement?: SandboxFleetPlacement;
|
|
6526
|
-
/**
|
|
6527
|
-
* A budget in USD the Platform enforces. The fleet mints a Platform key
|
|
6528
|
-
* with this budget and creates its sandboxes and drives its turns with it,
|
|
6529
|
-
* so every charge made through the fleet counts against the budget and a
|
|
6530
|
-
* charge past it is refused. Only the client that created the fleet holds
|
|
6531
|
-
* the key: other processes can read, cancel and delete the fleet but not
|
|
6532
|
-
* run its agents. Without it, `policy.maxSpendUsd` stays a create-time
|
|
6533
|
-
* estimate check. A turn driven on a fleet sandbox with another key is
|
|
6534
|
-
* billed to that key, outside the budget.
|
|
6535
|
-
*/
|
|
6536
|
-
budgetUsd?: number;
|
|
6537
|
-
/**
|
|
6538
|
-
* The fleet and agent spawning this fleet. The API checks that the parent
|
|
6539
|
-
* exists and that this fleet's `policy.maxSpendUsd` fits in the parent's
|
|
6540
|
-
* unallocated cap; deleting or cancelling the parent reaches this fleet.
|
|
6541
|
-
*/
|
|
6542
|
-
parent?: SandboxFleetParent;
|
|
6543
|
-
/** Fleet-level metadata copied to each sandbox under stable tags. */
|
|
6544
|
-
metadata?: Record<string, unknown>;
|
|
6545
|
-
/** Workspace policy for isolated or driver-supported shared mounts. */
|
|
6546
|
-
workspace?: SandboxFleetWorkspace;
|
|
6547
|
-
/**
|
|
6548
|
-
* Client-side safety caps for this create call. These do not replace
|
|
6549
|
-
* server-side quota enforcement.
|
|
6550
|
-
*/
|
|
6551
|
-
policy?: SandboxFleetPolicy;
|
|
6552
|
-
/**
|
|
6553
|
-
* Delete already-created machines if a later machine fails to create.
|
|
6554
|
-
* Defaults to true so partial fleets do not silently burn quota.
|
|
6555
|
-
*/
|
|
6556
|
-
cleanupOnFailure?: boolean;
|
|
6557
|
-
/**
|
|
6558
|
-
* Sandbox creates in flight at once. Defaults to 8: every create and delete
|
|
6559
|
-
* mints or revokes two Platform keys, and about 25 in flight has locked the
|
|
6560
|
-
* Platform key store for every customer (2026-09-15).
|
|
6561
|
-
*/
|
|
6562
|
-
maxConcurrentCreates?: number;
|
|
6563
|
-
/**
|
|
6564
|
-
* Idempotency key for the server-backed fleet record. Defaults to fleetId.
|
|
6565
|
-
*/
|
|
6566
|
-
idempotencyKey?: string;
|
|
6420
|
+
interface SessionExecutionInfo {
|
|
6421
|
+
executionId: string;
|
|
6422
|
+
sessionId: string;
|
|
6423
|
+
status: SessionExecutionStatus;
|
|
6424
|
+
startedAt: number;
|
|
6425
|
+
completedAt?: number;
|
|
6426
|
+
eventCount: number;
|
|
6427
|
+
lastEventId: string;
|
|
6567
6428
|
}
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6429
|
+
/** Admission identity survives replay retention; unavailable never means completed. */
|
|
6430
|
+
interface SessionMessageAdmission {
|
|
6431
|
+
sessionId: string;
|
|
6432
|
+
turnId: string;
|
|
6433
|
+
executionId: string;
|
|
6434
|
+
status: SessionExecutionStatus | "unavailable";
|
|
6435
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6575
6436
|
}
|
|
6576
6437
|
/**
|
|
6577
|
-
*
|
|
6438
|
+
* Why a session reached `status: "failed"` — the runtime's verbatim cause,
|
|
6439
|
+
* not a bucketed label. A dispatched (detached) turn stops reading its SSE
|
|
6440
|
+
* stream the moment the sandbox admits the execution, so a spawn, profile
|
|
6441
|
+
* materialization or provider auth failure lands after the caller is gone;
|
|
6442
|
+
* this is how that caller learns what happened without replaying events.
|
|
6578
6443
|
*/
|
|
6579
|
-
interface
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6444
|
+
interface SessionFailureReason {
|
|
6445
|
+
/** The runtime's error message, unmodified. */
|
|
6446
|
+
message: string;
|
|
6447
|
+
/** Machine-readable code when the runtime classified the failure. */
|
|
6448
|
+
code?: string;
|
|
6449
|
+
/** Native HTTP failure status when the provider reported it. */
|
|
6450
|
+
statusCode?: number;
|
|
6451
|
+
/** Execution whose failure this describes. */
|
|
6452
|
+
executionId?: string;
|
|
6583
6453
|
}
|
|
6584
6454
|
/**
|
|
6585
|
-
*
|
|
6455
|
+
* Snapshot of a session's state at the moment it was queried. Returned
|
|
6456
|
+
* by `box.session(id).status()` and `box.sessions()`.
|
|
6586
6457
|
*/
|
|
6587
|
-
interface
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6458
|
+
interface SessionInfo {
|
|
6459
|
+
/** Stable session id assigned by the sandbox runtime. */
|
|
6460
|
+
id: string;
|
|
6461
|
+
/** Parent session id when this session was forked from another session. */
|
|
6462
|
+
parentId?: string;
|
|
6463
|
+
/** Current lifecycle state. */
|
|
6464
|
+
status: SessionStatus;
|
|
6465
|
+
/** Present when `status` is `"failed"` — the cause the runtime recorded. */
|
|
6466
|
+
failureReason?: SessionFailureReason;
|
|
6467
|
+
/** Execution currently running, when one is active. */
|
|
6468
|
+
activeExecutionId?: string;
|
|
6469
|
+
/** Most recent execution id, retained after completion for event replay. */
|
|
6470
|
+
latestExecutionId?: string;
|
|
6471
|
+
/** Exact identity of the latest admitted run, retained for canonical control. */
|
|
6472
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6473
|
+
/** Backend identifier (e.g. provider name). */
|
|
6474
|
+
backend?: string;
|
|
6475
|
+
/** Provider/model selected after request normalization and environment fallback. */
|
|
6476
|
+
effectiveBackend?: EffectiveBackend;
|
|
6477
|
+
/** Model id the session was created with. */
|
|
6478
|
+
model?: string;
|
|
6479
|
+
/** Number of prompts the session has processed. */
|
|
6480
|
+
promptCount?: number;
|
|
6481
|
+
/** When the session was created in the sandbox. */
|
|
6482
|
+
createdAt?: Date;
|
|
6483
|
+
/** When the session began executing. */
|
|
6484
|
+
startedAt?: Date;
|
|
6485
|
+
/** When the session reached a terminal state. */
|
|
6486
|
+
endedAt?: Date;
|
|
6487
|
+
/** Raw payload from the sidecar — stable subset above; this carries
|
|
6488
|
+
* everything else for forward-compatibility. */
|
|
6489
|
+
raw?: Record<string, unknown>;
|
|
6595
6490
|
}
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
maxConcurrent?: number;
|
|
6605
|
-
retry?: {
|
|
6606
|
-
attempts?: number;
|
|
6607
|
-
};
|
|
6608
|
-
/** Caller-supplied dispatch id for idempotency/result lookup when supported by the API. */
|
|
6609
|
-
dispatchId?: string;
|
|
6610
|
-
/** Ask the API to retain branch results for later `dispatchResults` calls. */
|
|
6611
|
-
bufferResults?: boolean;
|
|
6491
|
+
/**
|
|
6492
|
+
* Options for `box.sessions()` listing.
|
|
6493
|
+
*/
|
|
6494
|
+
interface SessionListOptions {
|
|
6495
|
+
/** Filter by status. */
|
|
6496
|
+
status?: SessionStatus;
|
|
6497
|
+
/** Filter by backend identifier. */
|
|
6498
|
+
backend?: BackendType;
|
|
6612
6499
|
}
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6500
|
+
/** Options for creating a runtime agent session. */
|
|
6501
|
+
interface CreateSessionOptions {
|
|
6502
|
+
/** Existing agent-owned direct child of the box volume's `workspaces` directory, independent of runtime cwd. */
|
|
6503
|
+
workspaceRoot?: string;
|
|
6504
|
+
/** Complete ordered visible transcript imported into a new isolated runtime session. */
|
|
6505
|
+
conversationHistory?: Array<{
|
|
6506
|
+
id: string;
|
|
6507
|
+
role: "user" | "assistant";
|
|
6508
|
+
parts: Array<{
|
|
6509
|
+
type: "text";
|
|
6510
|
+
text: string;
|
|
6511
|
+
}>;
|
|
6512
|
+
timestamp: string;
|
|
6513
|
+
}>;
|
|
6514
|
+
/** Import the complete native transcript from another OpenCode session in this box. */
|
|
6515
|
+
importFromSessionId?: string;
|
|
6516
|
+
/** Workspace conversations survive idle-session collection until explicitly deleted. */
|
|
6517
|
+
retention?: "idle" | "workspace";
|
|
6518
|
+
/** Stable caller-supplied idempotency key. Repeating create with the same
|
|
6519
|
+
* id returns the existing session without creating another workspace or
|
|
6520
|
+
* backend session. Omit to let the runtime mint a random id. */
|
|
6521
|
+
sessionId?: string;
|
|
6522
|
+
title?: string;
|
|
6523
|
+
parentId?: string;
|
|
6524
|
+
/** Optional backend override. An omitted or type-less config uses the
|
|
6525
|
+
* runtime's configured default backend. */
|
|
6526
|
+
backend?: BackendConfig;
|
|
6626
6527
|
}
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6528
|
+
/** Backend credentials forwarded to the platform if a sandbox must restart. */
|
|
6529
|
+
interface SessionBackendCredentials {
|
|
6530
|
+
apiKey: string;
|
|
6531
|
+
baseUrl?: string;
|
|
6532
|
+
}
|
|
6533
|
+
/** One content part accepted by the runtime session message endpoint. */
|
|
6534
|
+
type SessionMessageInputPart = PromptInputPart | {
|
|
6535
|
+
type: "reasoning";
|
|
6536
|
+
text: string;
|
|
6537
|
+
} | {
|
|
6538
|
+
type: "tool";
|
|
6539
|
+
tool: string;
|
|
6540
|
+
state: {
|
|
6541
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
6542
|
+
input?: unknown;
|
|
6543
|
+
output?: unknown;
|
|
6544
|
+
};
|
|
6545
|
+
} | {
|
|
6546
|
+
type: "step-start";
|
|
6547
|
+
} | {
|
|
6548
|
+
type: "step-finish";
|
|
6549
|
+
reason?: string;
|
|
6550
|
+
tokens?: {
|
|
6551
|
+
total?: number;
|
|
6552
|
+
input?: number;
|
|
6553
|
+
output?: number;
|
|
6554
|
+
reasoning?: number;
|
|
6555
|
+
cache?: {
|
|
6556
|
+
write?: number;
|
|
6557
|
+
read?: number;
|
|
6558
|
+
};
|
|
6632
6559
|
};
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6560
|
+
cost?: number;
|
|
6561
|
+
};
|
|
6562
|
+
/** Message body accepted by `SandboxSession.sendMessage`. */
|
|
6563
|
+
interface SendSessionMessageRequest {
|
|
6564
|
+
messageId?: string;
|
|
6565
|
+
/** Per-turn overrides within the session's native backend. */
|
|
6566
|
+
backend?: TurnBackendConfig;
|
|
6567
|
+
/** Caller pin for the exact public backend request before native dispatch. */
|
|
6568
|
+
expectedPublicProfileRequestDigest?: `sha256:${string}`;
|
|
6569
|
+
/** Provider-composed native revision prepared for this public turn. */
|
|
6570
|
+
expectedPublicProfileRevision?: {
|
|
6571
|
+
workspacePlanDigest: `sha256:${string}`;
|
|
6572
|
+
materializedDigest: `sha256:${string}`;
|
|
6573
|
+
launchDigest: string;
|
|
6646
6574
|
};
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6575
|
+
/** Executor-only opaque receipt for a secret-bearing native revision. */
|
|
6576
|
+
expectedSecretProfileReceipt?: `hmac-sha256:${string}`;
|
|
6577
|
+
/** Router quote for a warm OpenCode turn with a total output ceiling. */
|
|
6578
|
+
managedQuoteVersion?: string;
|
|
6579
|
+
/** Use the sandbox's managed model credential for this turn only. */
|
|
6580
|
+
managedModelCredential?: true;
|
|
6581
|
+
/** Exact caller-owned execution identity for canonical cancellation. */
|
|
6582
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6583
|
+
/** Absolute UTC deadline for admitting the first native provider call. */
|
|
6584
|
+
admissionDeadline?: string;
|
|
6585
|
+
/** Execution time limit in milliseconds; a positive integer bounded by the runtime deployment ceiling. */
|
|
6586
|
+
ttlMs?: number;
|
|
6587
|
+
parts: SessionMessageInputPart[];
|
|
6588
|
+
system?: string;
|
|
6589
|
+
agent?: string;
|
|
6590
|
+
model?: {
|
|
6591
|
+
providerId: string;
|
|
6592
|
+
modelId: string;
|
|
6652
6593
|
};
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
interface FleetDispatchResultBufferOptions {
|
|
6659
|
-
cursor?: string;
|
|
6660
|
-
limit?: number;
|
|
6661
|
-
machines?: FleetMachineId[];
|
|
6662
|
-
}
|
|
6663
|
-
interface FleetDispatchResultBuffer<T = FleetExecDispatchResult> {
|
|
6664
|
-
fleetId: string;
|
|
6665
|
-
dispatchId: string;
|
|
6666
|
-
results: T[];
|
|
6667
|
-
cursor?: string;
|
|
6668
|
-
nextCursor?: string;
|
|
6669
|
-
done?: boolean;
|
|
6670
|
-
truncated?: boolean;
|
|
6671
|
-
trace?: SandboxFleetTraceExport;
|
|
6672
|
-
intelligence?: SandboxFleetIntelligenceEnvelope;
|
|
6673
|
-
}
|
|
6674
|
-
interface FleetDispatchCancelResult {
|
|
6675
|
-
fleetId: string;
|
|
6676
|
-
dispatchId: string;
|
|
6677
|
-
cancelled: boolean;
|
|
6678
|
-
status?: string;
|
|
6679
|
-
}
|
|
6680
|
-
interface SandboxFleetArtifactSpec {
|
|
6681
|
-
machineId: FleetMachineId;
|
|
6594
|
+
reasoningEffort?: ReasoningEffort;
|
|
6595
|
+
turnId?: string;
|
|
6596
|
+
interactions?: BackendConfig["interactions"];
|
|
6597
|
+
/** Run this turn with every provider tool disabled (OpenCode). */
|
|
6598
|
+
disableTools?: true;
|
|
6682
6599
|
/**
|
|
6683
|
-
*
|
|
6684
|
-
*
|
|
6685
|
-
*
|
|
6600
|
+
* Bound this turn to N upstream model calls (1-64). The runtime's model
|
|
6601
|
+
* proxy counts and enforces them; a turn it cannot count is refused. The
|
|
6602
|
+
* completed result reports `modelCalls`.
|
|
6686
6603
|
*/
|
|
6687
|
-
|
|
6688
|
-
label?: string;
|
|
6689
|
-
/** Maximum allowed artifact content size in bytes. Defaults to 10 MiB. */
|
|
6690
|
-
maxBytes?: number;
|
|
6691
|
-
}
|
|
6692
|
-
interface SandboxFleetArtifact extends SandboxFleetArtifactSpec {
|
|
6693
|
-
sandboxId: string;
|
|
6694
|
-
content: string;
|
|
6604
|
+
maxModelCalls?: number;
|
|
6695
6605
|
}
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6606
|
+
/** Per-call controls for `SandboxSession.sendMessage`. */
|
|
6607
|
+
interface SendSessionMessageOptions {
|
|
6608
|
+
/** Existing decision admission proof; used only for a caller-owned prepared follow-up. */
|
|
6609
|
+
planFollowUp?: DurablePlanFollowUpResume;
|
|
6610
|
+
credentials?: SessionBackendCredentials;
|
|
6611
|
+
timeoutMs?: number;
|
|
6612
|
+
signal?: AbortSignal;
|
|
6613
|
+
/** Trace id sent as `x-tangle-trace-id`; see `PromptOptions.traceId`. */
|
|
6614
|
+
traceId?: string;
|
|
6702
6615
|
}
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6616
|
+
/** Receipt returned after a session message is accepted for processing. */
|
|
6617
|
+
interface SentSessionMessage {
|
|
6618
|
+
info: {
|
|
6619
|
+
id: string;
|
|
6620
|
+
role: "assistant";
|
|
6621
|
+
timestamp: string;
|
|
6622
|
+
};
|
|
6623
|
+
parts: [];
|
|
6624
|
+
userMessageId: string;
|
|
6625
|
+
processing: true;
|
|
6626
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6706
6627
|
}
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6628
|
+
/** Canonical portable profile attached to a task session. */
|
|
6629
|
+
type TaskSessionProfile = AgentProfile & {
|
|
6630
|
+
name: string;
|
|
6631
|
+
};
|
|
6632
|
+
/** Options for creating an isolated background task session. */
|
|
6633
|
+
interface CreateTaskSessionOptions {
|
|
6634
|
+
sessionId: string;
|
|
6635
|
+
backend: BackendConfig;
|
|
6636
|
+
title: string;
|
|
6637
|
+
profile?: TaskSessionProfile;
|
|
6638
|
+
parentSessionId?: string;
|
|
6639
|
+
isolateFileWrites?: boolean;
|
|
6718
6640
|
}
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6641
|
+
/** Task-session metadata returned at creation time. */
|
|
6642
|
+
interface TaskSessionInfo {
|
|
6643
|
+
id: string;
|
|
6644
|
+
title?: string;
|
|
6645
|
+
parentSessionId?: string;
|
|
6646
|
+
worktreeInfo?: {
|
|
6647
|
+
worktreePath: string;
|
|
6648
|
+
branchName: string;
|
|
6649
|
+
baseCommitSha: string;
|
|
6650
|
+
};
|
|
6651
|
+
profile?: TaskSessionProfile;
|
|
6724
6652
|
}
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
environment?: string;
|
|
6732
|
-
templateId?: string;
|
|
6733
|
-
publicTemplateId?: string;
|
|
6734
|
-
acceleratorCount?: number;
|
|
6735
|
-
workspaceMountPath?: string;
|
|
6736
|
-
driverTimings?: SandboxFleetDriverTimings;
|
|
6737
|
-
meteredUsage?: SandboxFleetMachineMeteredUsage;
|
|
6738
|
-
createdAt?: string;
|
|
6739
|
-
updatedAt?: string;
|
|
6653
|
+
/** One changed file in an isolated task session. */
|
|
6654
|
+
interface TaskSessionFileChange {
|
|
6655
|
+
file: string;
|
|
6656
|
+
operation: "added" | "modified" | "deleted";
|
|
6657
|
+
additions: number;
|
|
6658
|
+
deletions: number;
|
|
6740
6659
|
}
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6660
|
+
/** Current diff and commit history for an isolated task session. */
|
|
6661
|
+
interface TaskSessionChanges {
|
|
6662
|
+
sessionId: string;
|
|
6663
|
+
files: TaskSessionFileChange[];
|
|
6664
|
+
diff: string;
|
|
6665
|
+
commits: Array<{
|
|
6666
|
+
sha: string;
|
|
6667
|
+
message: string;
|
|
6668
|
+
date: string;
|
|
6669
|
+
}>;
|
|
6670
|
+
worktreeInfo: {
|
|
6671
|
+
worktreePath: string;
|
|
6672
|
+
branchName: string;
|
|
6673
|
+
baseCommitSha: string;
|
|
6674
|
+
headCommitSha?: string;
|
|
6752
6675
|
};
|
|
6753
|
-
machines: SandboxFleetManifestMachine[];
|
|
6754
|
-
createdAt?: string;
|
|
6755
|
-
updatedAt?: string;
|
|
6756
|
-
}
|
|
6757
|
-
interface SandboxFleetDispatchResponse<T = FleetExecDispatchResult> {
|
|
6758
|
-
fleetId: string;
|
|
6759
|
-
dispatchId: string;
|
|
6760
|
-
type: "exec" | "prompt";
|
|
6761
|
-
results: T[];
|
|
6762
|
-
durationMs: number;
|
|
6763
|
-
trace?: SandboxFleetTraceExport;
|
|
6764
|
-
intelligence?: SandboxFleetIntelligenceEnvelope;
|
|
6765
6676
|
}
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
createdAt?: string;
|
|
6771
|
-
[key: string]: JsonValue | undefined;
|
|
6677
|
+
/** Options for merging task-session changes into the main workspace. */
|
|
6678
|
+
interface CommitTaskSessionOptions {
|
|
6679
|
+
message?: string;
|
|
6680
|
+
files?: string[];
|
|
6772
6681
|
}
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6682
|
+
/** Result of merging task-session changes into the main workspace. */
|
|
6683
|
+
interface TaskSessionCommitResult {
|
|
6684
|
+
success: true;
|
|
6685
|
+
commitSha?: string;
|
|
6686
|
+
conflicts?: string[];
|
|
6687
|
+
appliedFiles: number;
|
|
6778
6688
|
}
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6689
|
+
/**
|
|
6690
|
+
* Options for `SandboxSession.events()` streaming.
|
|
6691
|
+
*/
|
|
6692
|
+
interface SessionEventStreamOptions {
|
|
6693
|
+
/** Replay strictly after this event id. Omit to start at the live tail. */
|
|
6694
|
+
since?: string;
|
|
6695
|
+
/** Restrict replay to one execution within the session. Required with
|
|
6696
|
+
* `since` when attaching after a server-dispatched turn has already begun. */
|
|
6697
|
+
executionId?: string;
|
|
6698
|
+
/** Cancel the stream by aborting this signal. */
|
|
6699
|
+
signal?: AbortSignal;
|
|
6789
6700
|
}
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6701
|
+
/** Select one exact execution when awaiting a session result. */
|
|
6702
|
+
interface SessionResultOptions {
|
|
6703
|
+
/**
|
|
6704
|
+
* Runtime execution to replay and aggregate.
|
|
6705
|
+
*
|
|
6706
|
+
* When omitted, `result()` retains its existing behavior and selects the
|
|
6707
|
+
* session's latest execution at call time.
|
|
6708
|
+
*/
|
|
6709
|
+
executionId?: string;
|
|
6795
6710
|
}
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
requestedAccelerators: number;
|
|
6806
|
-
};
|
|
6807
|
-
alerts: Array<{
|
|
6808
|
-
name: string;
|
|
6809
|
-
severity: "info" | "warn" | "critical";
|
|
6810
|
-
fleetId?: string;
|
|
6811
|
-
machineId?: string;
|
|
6812
|
-
message: string;
|
|
6813
|
-
runbook: string[];
|
|
6814
|
-
}>;
|
|
6711
|
+
/** Select one exact execution when interrupting a session. */
|
|
6712
|
+
interface SessionInterruptOptions {
|
|
6713
|
+
/**
|
|
6714
|
+
* Runtime execution to cancel.
|
|
6715
|
+
*
|
|
6716
|
+
* When supplied, a newer execution on the same session is never cancelled.
|
|
6717
|
+
* When omitted, `interrupt()` selects the current execution.
|
|
6718
|
+
*/
|
|
6719
|
+
executionId?: string;
|
|
6815
6720
|
}
|
|
6816
|
-
|
|
6817
|
-
|
|
6721
|
+
/**
|
|
6722
|
+
* Options for `box.dispatchPrompt()` — fire-and-detach prompt semantics.
|
|
6723
|
+
*/
|
|
6724
|
+
interface DispatchPromptOptions extends PromptOptions {
|
|
6725
|
+
/** Client-supplied session id. Re-dispatching with the same id while
|
|
6726
|
+
* that session is in flight is a lookup, not a second run — a
|
|
6727
|
+
* concurrency guard, not a retry key. Once the turn finishes (or if the
|
|
6728
|
+
* session was evicted) the same call dispatches again; pass `turnId` for
|
|
6729
|
+
* retry safety that outlives the turn. */
|
|
6730
|
+
sessionId?: string;
|
|
6818
6731
|
}
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6732
|
+
/**
|
|
6733
|
+
* Options for `box.messages()` — list messages on a session including
|
|
6734
|
+
* mid-turn partial assistant content.
|
|
6735
|
+
*/
|
|
6736
|
+
interface ListMessagesOptions {
|
|
6737
|
+
/** Session id whose messages to return (required). */
|
|
6738
|
+
sessionId: string;
|
|
6739
|
+
/** Max entries, default 100. Server caps at 1000. */
|
|
6740
|
+
limit?: number;
|
|
6741
|
+
/** Skip this many entries from the start. */
|
|
6742
|
+
offset?: number;
|
|
6743
|
+
/** Only return messages newer than this Unix-ms timestamp. */
|
|
6744
|
+
since?: number;
|
|
6832
6745
|
}
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
maxLifetimeSeconds?: number;
|
|
6849
|
-
};
|
|
6850
|
-
meteredUsage?: {
|
|
6851
|
-
runtimeMs: number;
|
|
6852
|
-
machineRuntimeMs: Record<string, number>;
|
|
6853
|
-
updatedAt: string;
|
|
6854
|
-
};
|
|
6855
|
-
createdAt: string;
|
|
6856
|
-
updatedAt: string;
|
|
6857
|
-
};
|
|
6858
|
-
insights: {
|
|
6859
|
-
reliabilityScore: number;
|
|
6860
|
-
parallelismEfficiencyScore: number;
|
|
6861
|
-
failureRate: number;
|
|
6862
|
-
recommendedActions: string[];
|
|
6746
|
+
/**
|
|
6747
|
+
* Options for `box.session(id).fork()` — create a new session from an
|
|
6748
|
+
* existing conversation, optionally at a message boundary.
|
|
6749
|
+
*/
|
|
6750
|
+
interface SessionForkOptions {
|
|
6751
|
+
/** Fork at this message boundary. */
|
|
6752
|
+
messageId?: string;
|
|
6753
|
+
/** Target backend type for cross-backend forks. Defaults to parent backend. */
|
|
6754
|
+
targetBackend?: BackendType;
|
|
6755
|
+
/** Model override for the target backend. */
|
|
6756
|
+
targetModel?: {
|
|
6757
|
+
provider?: string;
|
|
6758
|
+
model?: string;
|
|
6759
|
+
apiKey?: string;
|
|
6760
|
+
baseUrl?: string;
|
|
6863
6761
|
};
|
|
6864
|
-
|
|
6865
|
-
|
|
6762
|
+
/**
|
|
6763
|
+
* Files to include. The runtime currently rejects non-empty file lists;
|
|
6764
|
+
* exposed here so the SDK type tracks the wire contract exactly.
|
|
6765
|
+
*/
|
|
6766
|
+
files?: string[];
|
|
6866
6767
|
}
|
|
6867
|
-
|
|
6868
|
-
|
|
6768
|
+
/**
|
|
6769
|
+
* One message on a session — user, assistant, or system. The metadata
|
|
6770
|
+
* field carries the durability marker set by the sidecar:
|
|
6771
|
+
* - `status: "streaming"` and no `completed`/`interrupted` flag → turn
|
|
6772
|
+
* is in flight, OR the sidecar died before stamping a marker
|
|
6773
|
+
* (SIGKILL, OOM). The partial parts are the partial assistant
|
|
6774
|
+
* content the recorder flushed before death.
|
|
6775
|
+
* - `completed: true` + `completedAt` → turn finished normally. If a
|
|
6776
|
+
* `turnId` was supplied, its result is cached for idempotent retry.
|
|
6777
|
+
* - `interrupted: true` + `interruptedAt` + `interruptReason` → graceful
|
|
6778
|
+
* abort, timeout, or upstream error. Partial content is preserved
|
|
6779
|
+
* but not billable as a completion.
|
|
6780
|
+
*/
|
|
6781
|
+
interface SessionMessage {
|
|
6782
|
+
id: string;
|
|
6783
|
+
role: "user" | "assistant" | "system";
|
|
6784
|
+
/** ISO timestamp string. */
|
|
6869
6785
|
timestamp: string;
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
dispatchRuntimeMs: number;
|
|
6885
|
-
cleanupObservedMs: number;
|
|
6886
|
-
driverQueueMs: number;
|
|
6887
|
-
driverPlacementMs: number;
|
|
6888
|
-
driverProvisionMs: number;
|
|
6889
|
-
driverStartupMs: number;
|
|
6890
|
-
driverCleanupMs: number;
|
|
6891
|
-
};
|
|
6892
|
-
criticalPath: {
|
|
6893
|
-
durationMs: number;
|
|
6894
|
-
phases: Array<{
|
|
6895
|
-
name: string;
|
|
6896
|
-
durationMs: number;
|
|
6897
|
-
machineId?: string;
|
|
6898
|
-
}>;
|
|
6786
|
+
/** Message parts (text, tool calls, reasoning, files). Same shape as
|
|
6787
|
+
* events emitted by `streamPrompt`. */
|
|
6788
|
+
parts: unknown[];
|
|
6789
|
+
/** Durability + idempotency metadata. See class doc above. */
|
|
6790
|
+
metadata?: {
|
|
6791
|
+
status?: "streaming" | "completed" | "interrupted";
|
|
6792
|
+
completed?: boolean;
|
|
6793
|
+
completedAt?: string;
|
|
6794
|
+
interrupted?: boolean;
|
|
6795
|
+
interruptedAt?: string;
|
|
6796
|
+
interruptReason?: string;
|
|
6797
|
+
turnId?: string;
|
|
6798
|
+
startedAt?: string;
|
|
6799
|
+
[extra: string]: unknown;
|
|
6899
6800
|
};
|
|
6900
|
-
events: SandboxFleetTraceEvent[];
|
|
6901
6801
|
}
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6802
|
+
/**
|
|
6803
|
+
* Returned by `box.findCompletedTurn()` — the cached result of a
|
|
6804
|
+
* previously-completed turn, keyed on the caller's `turnId`.
|
|
6805
|
+
*/
|
|
6806
|
+
interface CompletedTurnResult {
|
|
6807
|
+
turnId: string;
|
|
6808
|
+
sessionId: string;
|
|
6809
|
+
/** ISO timestamp when the turn finished. */
|
|
6810
|
+
completedAt: string;
|
|
6811
|
+
/** The cached AgentExecutionResult-shape payload (text, toolInvocations,
|
|
6812
|
+
* sessionId, tokenUsage, etc.). */
|
|
6813
|
+
result: CompletedTurnPayload;
|
|
6814
|
+
}
|
|
6815
|
+
/**
|
|
6816
|
+
* The cached result of a completed turn. `effectiveBackend` is the provider
|
|
6817
|
+
* and model that served the turn, the same field the live `result` and `done`
|
|
6818
|
+
* events carry. It is absent when the runtime did not record it, for example
|
|
6819
|
+
* on a record written before the runtime stored attribution: treat that as
|
|
6820
|
+
* unknown, never as the session's default model.
|
|
6821
|
+
*/
|
|
6822
|
+
type CompletedTurnPayload = Record<string, unknown> & {
|
|
6823
|
+
effectiveBackend?: EffectiveBackend;
|
|
6824
|
+
};
|
|
6825
|
+
/**
|
|
6826
|
+
* Returned by `box.dispatchPrompt()` — minimum the caller needs to track
|
|
6827
|
+
* the session afterward. The sandbox keeps running the prompt; use
|
|
6828
|
+
* `box.session(sessionId)` to follow it.
|
|
6829
|
+
*/
|
|
6830
|
+
interface DispatchedSession {
|
|
6831
|
+
/** Session id (either the one the caller supplied or one the sandbox
|
|
6832
|
+
* minted). */
|
|
6833
|
+
sessionId: string;
|
|
6834
|
+
/** Runtime execution id when the admission event supplied one. */
|
|
6835
|
+
executionId?: string;
|
|
6836
|
+
/** Exact run identity accepted by the runtime for canonical cancellation. */
|
|
6837
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6838
|
+
/** Lifecycle state at the moment dispatch returned. */
|
|
6839
|
+
status: SessionStatus;
|
|
6840
|
+
/** True when a session with the supplied id already existed. On its own
|
|
6841
|
+
* this says nothing about whether the prompt ran — an existing terminal
|
|
6842
|
+
* session still accepts a new turn. Read `dispatched` for that. */
|
|
6843
|
+
alreadyExisted: boolean;
|
|
6844
|
+
/** Whether this call actually dispatched the prompt. `false` means the
|
|
6845
|
+
* call was a no-op because the turn is already in flight (session
|
|
6846
|
+
* `queued`/`running`) or already finished (`turnId` hit the completed-
|
|
6847
|
+
* turn cache) — the prompt was deliberately not sent, and no new events
|
|
6848
|
+
* will appear on the session bus for it. */
|
|
6849
|
+
dispatched: boolean;
|
|
6850
|
+
}
|
|
6851
|
+
/**
|
|
6852
|
+
* Options for `box.driveTurn()` — one settle/poll/admit pass over a detached
|
|
6853
|
+
* turn. The first pass creates a session with the requested backend and admits
|
|
6854
|
+
* the turn through `SandboxSession.sendMessage()`. The session owns execution
|
|
6855
|
+
* and gateway replay after the request returns.
|
|
6856
|
+
*/
|
|
6857
|
+
/** Repeated messages in one native session, unlike the one-session-per-task driver. */
|
|
6858
|
+
interface ConversationTurnOptions {
|
|
6859
|
+
sessionId: string;
|
|
6860
|
+
turnId: string;
|
|
6861
|
+
/** Router quote included in the durable admission request. */
|
|
6862
|
+
managedQuoteVersion?: string;
|
|
6863
|
+
/** Use the sandbox's managed model credential for this turn only. */
|
|
6864
|
+
managedModelCredential?: true;
|
|
6865
|
+
/** Per-turn backend, profile, runtime attachments, and interaction settings. */
|
|
6866
|
+
backend?: Partial<BackendConfig>;
|
|
6867
|
+
/** Caller pin for the exact public backend request before native dispatch. */
|
|
6868
|
+
expectedPublicProfileRequestDigest?: `sha256:${string}`;
|
|
6869
|
+
/** Provider-composed native revision prepared for this public turn. */
|
|
6870
|
+
expectedPublicProfileRevision?: {
|
|
6871
|
+
workspacePlanDigest: `sha256:${string}`;
|
|
6872
|
+
materializedDigest: `sha256:${string}`;
|
|
6873
|
+
launchDigest: string;
|
|
6914
6874
|
};
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
}
|
|
6928
|
-
interface SandboxFleetTraceOptions {
|
|
6875
|
+
/** Executor-only opaque receipt for a secret-bearing native revision. */
|
|
6876
|
+
expectedSecretProfileReceipt?: `hmac-sha256:${string}`;
|
|
6877
|
+
/** Model shorthand; conflicts with backend.model.model are rejected. */
|
|
6878
|
+
model?: string;
|
|
6879
|
+
/** Exact execution identity retained by admission and cancellation. */
|
|
6880
|
+
runControlRef?: AgentExactRunControlRef;
|
|
6881
|
+
/** Absolute UTC deadline for admitting the first native provider call. */
|
|
6882
|
+
admissionDeadline?: string;
|
|
6883
|
+
/** False is a passive settlement/cancellation lookup; never admits new work. */
|
|
6884
|
+
allowDispatch?: boolean;
|
|
6885
|
+
/** Run this turn with every provider tool disabled (OpenCode). */
|
|
6886
|
+
disableTools?: true;
|
|
6929
6887
|
/**
|
|
6930
|
-
*
|
|
6931
|
-
*
|
|
6888
|
+
* Bound this turn to N upstream model calls (1-64). The runtime's model
|
|
6889
|
+
* proxy counts and enforces them; a turn it cannot count is refused. The
|
|
6890
|
+
* completed result reports `modelCalls`.
|
|
6932
6891
|
*/
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
totalCpu: number;
|
|
6944
|
-
totalMemoryMb: number;
|
|
6945
|
-
totalStorageMb: number;
|
|
6946
|
-
totalAccelerators: number;
|
|
6947
|
-
maxLifetimeSeconds?: number;
|
|
6948
|
-
};
|
|
6949
|
-
rates: {
|
|
6950
|
-
cpuPerHr: number;
|
|
6951
|
-
ramPerGbHr: number;
|
|
6952
|
-
diskPerGbHr: number;
|
|
6953
|
-
acceleratorPerDeviceHr: number;
|
|
6954
|
-
minChargePerHr: number;
|
|
6955
|
-
entDiscount: number;
|
|
6956
|
-
};
|
|
6957
|
-
}
|
|
6958
|
-
type SandboxFleetTokenAction = "list" | "create" | "delete" | "exec" | "prompt" | "read" | "write";
|
|
6959
|
-
interface CreateSandboxFleetTokenOptions {
|
|
6960
|
-
/** Allowed fleet actions. Defaults to read/list/exec. */
|
|
6961
|
-
actions?: SandboxFleetTokenAction[];
|
|
6962
|
-
/** Optional token-side policy caps enforced by the Sandbox API. */
|
|
6963
|
-
policy?: SandboxFleetPolicy;
|
|
6964
|
-
/** Token lifetime in minutes. API clamps to its server-side maximum. */
|
|
6965
|
-
ttlMinutes?: number;
|
|
6966
|
-
}
|
|
6967
|
-
interface SandboxFleetToken {
|
|
6968
|
-
token: string;
|
|
6969
|
-
expiresAt: number;
|
|
6970
|
-
fleetId: string;
|
|
6971
|
-
actions: SandboxFleetTokenAction[];
|
|
6972
|
-
policy?: SandboxFleetPolicy;
|
|
6892
|
+
maxModelCalls?: number;
|
|
6893
|
+
timeoutMs?: number;
|
|
6894
|
+
signal?: AbortSignal;
|
|
6895
|
+
wallCapMs?: number;
|
|
6896
|
+
/**
|
|
6897
|
+
* Trace id sent as `x-tangle-trace-id` on this pass's runtime requests.
|
|
6898
|
+
* Defaults to `turnId` when it is 8-200 letters, digits, `_` or `-`, so
|
|
6899
|
+
* every pass over one turn shares one trace; otherwise the SDK mints one.
|
|
6900
|
+
*/
|
|
6901
|
+
traceId?: string;
|
|
6973
6902
|
}
|
|
6974
|
-
|
|
6975
|
-
|
|
6903
|
+
type ConversationTurnResult = ((TurnDriveResult & {
|
|
6904
|
+
executionId?: string;
|
|
6905
|
+
}) | {
|
|
6906
|
+
state: "not_admitted";
|
|
6907
|
+
} | {
|
|
6908
|
+
state: "awaiting_input";
|
|
6909
|
+
executionId: string;
|
|
6910
|
+
requests: _$_tangle_network_agent_interface0.InteractionRequest[];
|
|
6911
|
+
}) & {
|
|
6912
|
+
/** Trace id this pass sent as `x-tangle-trace-id`. */traceId?: string;
|
|
6913
|
+
};
|
|
6914
|
+
interface DriveTurnOptions {
|
|
6915
|
+
/** Deterministic session id — required, it is the resume key. Every
|
|
6916
|
+
* tick for the same logical turn MUST pass the same id so a re-invoke
|
|
6917
|
+
* after a crash finds the in-flight session instead of starting a
|
|
6918
|
+
* second agent run. */
|
|
6919
|
+
sessionId: string;
|
|
6920
|
+
/** Turn idempotency key for the platform's completed-turn cache.
|
|
6921
|
+
* Defaults to `sessionId`, which is correct for the one-turn-per-
|
|
6922
|
+
* session shape detached drivers use. */
|
|
6923
|
+
turnId?: string;
|
|
6924
|
+
/** Backend bound to the session when the first pass creates it. */
|
|
6925
|
+
backend?: Partial<BackendConfig>;
|
|
6926
|
+
/** Model shorthand folded into `backend.model.model` at session creation. */
|
|
6927
|
+
model?: string;
|
|
6928
|
+
/** Admission request timeout in milliseconds. */
|
|
6929
|
+
timeoutMs?: number;
|
|
6930
|
+
/** Abort the admission request before the sandbox accepts it. */
|
|
6931
|
+
signal?: AbortSignal;
|
|
6932
|
+
/** Wall-clock cap in milliseconds, measured from the session's
|
|
6933
|
+
* `startedAt` (falling back to `createdAt`). When a still-running
|
|
6934
|
+
* session exceeds it, `driveTurn` cancels the session and reports
|
|
6935
|
+
* `state: "failed"` — bounding unattended runs that would otherwise
|
|
6936
|
+
* stall forever (e.g. an interactive question nothing will answer).
|
|
6937
|
+
* Omit for no cap. */
|
|
6938
|
+
wallCapMs?: number;
|
|
6976
6939
|
}
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
fleetId: string;
|
|
6983
|
-
expiredAt: string;
|
|
6984
|
-
deleted: boolean;
|
|
6985
|
-
machines: Array<{
|
|
6986
|
-
machineId: string;
|
|
6987
|
-
sandboxId: string;
|
|
6988
|
-
ok: boolean;
|
|
6989
|
-
status?: number;
|
|
6990
|
-
error?: string;
|
|
6991
|
-
}>;
|
|
6992
|
-
}>;
|
|
6940
|
+
/** Public side copy paths relative to the immutable profile revision workspace. */
|
|
6941
|
+
interface PublicProfileConflict {
|
|
6942
|
+
relPath: string;
|
|
6943
|
+
copyRelPath: string;
|
|
6944
|
+
reason: "existing" | "symlink";
|
|
6993
6945
|
}
|
|
6994
6946
|
/**
|
|
6995
|
-
*
|
|
6947
|
+
* Returned by `box.driveTurn()` — where the detached turn stands after
|
|
6948
|
+
* one pass. Discriminated on `state`:
|
|
6949
|
+
* - `completed` — the turn finished with a text payload; `result` is
|
|
6950
|
+
* the full cached AgentExecutionResult-shape record.
|
|
6951
|
+
* - Waiting states preserve the response request and original result.
|
|
6952
|
+
* - `running` — the session is queued or executing; re-invoke after a
|
|
6953
|
+
* delay of your choosing.
|
|
6954
|
+
* - `failed` — terminal and deterministic: a failed/cancelled session,
|
|
6955
|
+
* a wall-cap cancellation, or an invalid terminal result.
|
|
6956
|
+
* Re-invoking will not change the outcome.
|
|
6996
6957
|
*/
|
|
6997
|
-
|
|
6998
|
-
/**
|
|
6999
|
-
|
|
7000
|
-
|
|
6958
|
+
type TurnDriveResult = {
|
|
6959
|
+
state: "completed"; /** Final assistant text of the turn. */
|
|
6960
|
+
text: string; /** The full turn payload (text, toolInvocations, tokenUsage, etc.). */
|
|
6961
|
+
result: Record<string, unknown>; /** Executor-observed public native profile revision for this turn. */
|
|
6962
|
+
publicProfileRevision?: {
|
|
6963
|
+
workspacePlanDigest: string;
|
|
6964
|
+
materializedDigest: string;
|
|
6965
|
+
launchDigest: string; /** Absent for a result written before collision receipts existed. */
|
|
6966
|
+
conflicts?: PublicProfileConflict[];
|
|
6967
|
+
};
|
|
6968
|
+
/**
|
|
6969
|
+
* Token usage the turn reported, when the payload carried it. Typed
|
|
6970
|
+
* access to the counts otherwise buried untyped inside `result`.
|
|
6971
|
+
*/
|
|
6972
|
+
usage?: TokenUsage;
|
|
6973
|
+
/**
|
|
6974
|
+
* A bounded turn's upstream model calls as the runtime's model proxy
|
|
6975
|
+
* relayed them (`maxModelCalls`), never the harness's own report.
|
|
6976
|
+
*/
|
|
6977
|
+
modelCalls?: {
|
|
6978
|
+
limit: number;
|
|
6979
|
+
count: number;
|
|
6980
|
+
/**
|
|
6981
|
+
* The model each counted call's upstream response named, in call order;
|
|
6982
|
+
* shorter than `count` when a response named none. The requested model
|
|
6983
|
+
* is `effectiveBackend.model`, a separate value.
|
|
6984
|
+
*/
|
|
6985
|
+
observedModels?: string[];
|
|
6986
|
+
};
|
|
6987
|
+
} | {
|
|
6988
|
+
state: "awaiting_plan_decision";
|
|
6989
|
+
plan: DurablePlanSnapshot;
|
|
6990
|
+
result: Record<string, unknown>;
|
|
6991
|
+
} | {
|
|
6992
|
+
state: "blocked_on_approval";
|
|
6993
|
+
approval: AgentApprovalRequirement;
|
|
6994
|
+
result: Record<string, unknown>;
|
|
6995
|
+
} | {
|
|
6996
|
+
state: "awaiting_question";
|
|
6997
|
+
question: AgentQuestionRequest;
|
|
6998
|
+
interaction?: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
6999
|
+
result: Record<string, unknown>;
|
|
7000
|
+
} | {
|
|
7001
|
+
state: "awaiting_interaction";
|
|
7002
|
+
interaction: _$_tangle_network_agent_interface0.InteractionRequest;
|
|
7003
|
+
result: Record<string, unknown>;
|
|
7004
|
+
} | {
|
|
7005
|
+
state: "running"; /** When the session began executing, if the runtime reported it. */
|
|
7006
|
+
startedAt?: Date; /** Milliseconds since `startedAt` at the moment of the poll. */
|
|
7007
|
+
elapsedMs?: number;
|
|
7008
|
+
} | {
|
|
7009
|
+
state: "failed"; /** Human-readable reason the turn is deterministically failed. */
|
|
7010
|
+
error: string;
|
|
7011
|
+
};
|
|
7001
7012
|
//#endregion
|
|
7002
7013
|
//#region src/types/fleet-turns.d.ts
|
|
7003
7014
|
/**
|
|
@@ -8234,4 +8245,4 @@ interface InstalledTool {
|
|
|
8234
8245
|
active: boolean;
|
|
8235
8246
|
}
|
|
8236
8247
|
//#endregion
|
|
8237
|
-
export { BackendManager as $,
|
|
8248
|
+
export { BackendManager as $, BackendStatus as $a, ManagedProcessState as $i, SandboxConnection as $n, FileTreeOptions as $r, FleetAgentResult as $t, ProvisionStatus as A, DurablePlanSnapshot as Aa, GpuLeaseBilling as Ai, SandboxFleetMachineRecord as An, parseBackendType as Ao, EgressDenial as Ar, SessionExecutionStatus as At, Process as B, SandboxEvent as Ba, GpuLeaseStatus as Bi, SandboxFleetToken as Bn, ChunkedUploadResult as Br, SessionStatus as Bt, StopOptions as C, AgentRunStatus as Ca, CreateGpuLeaseOptions as Ci, SandboxFleetDispatchResponse as Cn, BatchBackendStats as Co, SandboxShapePreset as Cr, PublicProfileConflict as Ct, SshKeysManager as D, DurablePlanDecisionOptions as Da, DriverType as Di, SandboxFleetIntelligenceEnvelope as Dn, BatchTaskUsage as Do, SandboxResourceUsage as Dr, SessionBackendCredentials as Dt, SecretsManager as E, DurablePlan as Ea, DriverInfo as Ei, SandboxFleetInfo as En, BatchSidecarGroup as Eo, SecretBinding as Er, SentSessionMessage as Et, UsageInfo as F, IntelligenceReportSubjectType as Fa, GpuLeaseProviderName as Fi, SandboxFleetParent as Fn, NetworkManager as Fr, SessionListOptions as Ft, ProcessSignal as G, SandboxTraceOptions as Ga, CodeExecutionResult as Gi, SandboxFleetUsage as Gn, FileInfo as Gr, TaskSessionProfile as Gt, ProcessListOptions as H, SandboxTraceBundle as Ha, HostAgentRuntimeBackend as Hi, SandboxFleetTraceEvent as Hn, DownloadOptions as Hr, TaskSessionCommitResult as Ht, WaitForOptions as I, IntelligenceReportWindow as Ia, GpuLeaseProviderState as Ii, SandboxFleetPlacement as In, SandboxEgressUsage as Ir, SessionMessage as It, PreviewLinkInfo as J, BackendCapabilities as Ja, ManagedProcessJobs as Ji, SandboxFleetWorkspaceRestoreResult as Jn, FileReadError as Jr, CreateSandboxFleetOptions as Jt, ProcessSpawnOptions as K, TokenUsage as Ka, CodeLanguage as Ki, SandboxFleetWorkspace as Kn, FileReadBatchOptions as Kr, TurnDriveResult as Kt, DevServerInfo as L, PromptInputPart as La, GpuLeaseProviderStatus as Li, SandboxFleetPolicy as Ln, GitAuth as Lr, SessionMessageAdmission as Lt, ResumeOptions as M, IntelligenceReport as Ma, GpuLeaseExecOptions as Mi, SandboxFleetManifest as Mn, EgressPolicy as Mr, SessionForkOptions as Mt, SandboxIdentity as N, IntelligenceReportBudget as Na, GpuLeaseExecResult as Ni, SandboxFleetManifestMachine as Nn, MAX_EGRESS_DENIALS_LIMIT as Nr, SessionInfo as Nt, ProvisionEvent as O, DurablePlanDecisionResult as Oa, GPU_LEASE_PROVIDER_NAMES as Oi, SandboxFleetMachine as On, ALL_BACKEND_TYPES as Oo, SandboxRuntimeCapabilities as Or, SessionEventStreamOptions as Ot, SubscriptionInfo as P, IntelligenceReportCompareTo as Pa, GpuLeaseManager as Pi, SandboxFleetOperationsSummary as Pn, NetworkConfig as Pr, SessionInterruptOptions as Pt, AddUserOptions as Q, BackendRuntimeConfigUpdate as Qa, ManagedProcessSpec as Qi, SSHCredentials as Qn, FileTreeFile as Qr, FleetAgentPlacement as Qt, EnsureDevServerOptions as R, PromptOptions as Ra, GpuLeaseProviders as Ri, SandboxFleetProfileRef as Rn, GitConfig as Rr, SessionMessageInputPart as Rt, SnapshotResult as S, AgentQuestionRequest as Sa, AttachGpuLeaseOptions as Si, SandboxFleetDispatchFailureClass as Sn, PublicBatchRunRequest as So, SandboxShape as Sr, ListMessagesOptions as St, SecretInfo as T, CreateIntelligenceReportOptions as Ta, DriverConfig as Ti, SandboxFleetDriverTimings as Tn, BatchEventDataMap as To, SandboxStatus as Tr, SendSessionMessageRequest as Tt, ProcessLogEntry as U, SandboxTraceEvent as Ua, NonHostAgentDriverConfig as Ui, SandboxFleetTraceExport as Un, DownloadProgress as Ur, TaskSessionFileChange as Ut, ProcessInfo as V, SandboxIntelligenceEnvelope as Va, HostAgentDriverConfig as Vi, SandboxFleetTraceBundle as Vn, DeleteOptions as Vr, TaskSessionChanges as Vt, ProcessManager as W, SandboxTraceExport as Wa, CodeExecutionOptions as Wi, SandboxFleetTraceOptions as Wn, DownloadResult as Wr, TaskSessionInfo as Wt, PreviewLinkWaitOptions as X, BackendInfo as Xa, ManagedProcessRecord as Xi, ListSandboxOptions as Xn, FileRenameResult as Xr, CreateSandboxFleetWithCoordinatorOptions as Xt, PreviewLinkManager as Y, BackendConfig as Ya, ManagedProcessOptions as Yi, SandboxFleetWorkspaceSnapshotResult as Yn, FileReadResult as Yr, CreateSandboxFleetTokenOptions as Yt, AccessPolicyRule as Z, BackendMcpServerStatus as Za, ManagedProcessResumeOptions as Zi, SSHCommandDescriptor as Zn, FileSystem as Zr, FleetAgentId as Zt, SnapshotIdempotency as _, BatchRunOptions as _a, PublicTemplateVersionInfo as _i, SandboxFleetAgent as _n, RawEvidenceExportOptions as _o, TeePublicKeyResponse as _r, CreateSessionOptions as _t, DeleteMatchingSandboxesOptions as a, ForkIdempotency as aa, MkdirOptions as ai, FleetExecDispatchOptions as an, SandboxCreateOutcome as ao, SandboxTerminalAttachOptions as ar, GitBranch as at, SnapshotProvenance as b, BatchTaskResult as ba, SandboxEnvironment as bi, SandboxFleetArtifactSpec as bn, RawEvidenceRecordsFile as bo, SandboxConfig as br, DispatchedSession as bt, SandboxDeleteAcknowledgement as c, RolloutChildResult as ca, UploadProgress as ci, FleetPromptDispatchOptions as cn, SandboxEnvRecovery as co, SandboxTerminalManager as cr, GitStatus as ct, SandboxOperationInfo as d, RolloutStartResult as da, WriteManyOptions as di, FleetRunOptions as dn, RawEvidenceArchiveManifest as do, StartupDiagnostics as dr, TokenRefreshHandler as dt, HttpClient as ea, FileTreeResult as ei, FleetAgentRunStatus as en, EffectiveBackend as eo, SandboxInfo as er, DirectoryPermission as et, SandboxOperationKind as f, RolloutStatus as fa, SearchMatch as fi, ListSandboxFleetOptions as fn, RawEvidenceArchiveManifestNative as fo, StartupOperation as fr, CommitTaskSessionOptions as ft, SnapshotDeleteOutcome as g, BatchResult as ga, PublicTemplateInfo as gi, ReconcileSandboxFleetsResult as gn, RawEvidenceDirectoryExport as go, TeePublicKey as gr, ConversationTurnResult as gt, SnapshotDeleteAcknowledgement as h, BatchBackend as ha, ExecResult as hi, ReconcileSandboxFleetsOptions as hn, RawEvidenceBoxExportOptions as ho, TeeAttestationResponse as hr, ConversationTurnOptions as ht, DeleteMatchingSandboxesFilter as i, ForkCounts as ia, ListOptions as ii, FleetDispatchStreamOptions as in, RouterRoutingOptions as io, SandboxRuntimeHealth as ir, UpdateUserOptions as it, ProvisionStep as j, EventStreamOptions as ja, GpuLeaseCommandResult as ji, SandboxFleetMachineSpec as jn, EgressManager as jr, SessionFailureReason as jt, ProvisionResult as k, DurablePlanFollowUpResume as ka, GpuLease as ki, SandboxFleetMachineMeteredUsage as kn, BackendType as ko, StorageConfig as kr, SessionExecutionInfo as kt, SandboxDeleteOptions as l, RolloutOptions as la, WriteFileOptions as li, FleetPromptDispatchResult as ln, SandboxEnvRecoveryView as lo, SandboxTerminalRequestOptions as lr, FleetDriveTurnOutcome as lt, SandboxRemovalState as m, WaitForRolloutOptions as ma, ExecOptions as mi, ReapExpiredSandboxFleetsResult as mn, RawEvidenceBoxDirectoryExport as mo, TeeAttestationReport as mr, CompletedTurnResult as mt, DeleteMatchingSandboxOutcome as n, SdkTimingHook as na, FileUsageResult as ni, FleetDispatchResultBuffer as nn, EffectiveBackendSource as no, SandboxPortPreviewLink as nr, PermissionsManager as nt, DeleteMatchingSandboxesResult as o, ForkLookupOptions as oa, RenameOptions as oi, FleetExecDispatchResult as on, SandboxCreateReceipt as oo, SandboxTerminalCreateOptions as or, GitCommit as ot, SandboxOperationState as p, RolloutTurnPart as pa, SearchOptions as pi, ReapExpiredSandboxFleetsOptions as pn, RawEvidenceBoxArchiveManifest as po, TeeAttestationOptions as pr, CompletedTurnPayload as pt, ProcessStatus as q, TurnBackendConfig as qa, CodeResultPart as qi, SandboxFleetWorkspaceReconcileResult as qn, FileReadBatchResult as qr, AttachSandboxFleetMachineOptions as qt, DeleteMatchingSandboxResult as r, BranchOptions as ra, FileWriteResult as ri, FleetDispatchResultBufferOptions as rn, McpServerConfig as ro, SandboxRunGeneration as rr, SandboxUser as rt, RestoreSnapshotOptions as s, Rollout as sa, UploadOptions as si, FleetMachineId as sn, WorkspaceImagePublishResult as so, SandboxTerminalInfo as sr, GitDiff as st, InstalledTool as t, JsonValue as ta, FileUsageOptions as ti, FleetDispatchCancelResult as tn, EffectiveBackendProfile as to, SandboxPortBinding as tr, PermissionLevel as tt, SandboxDeleteOutcome as u, RolloutScorer as ua, WriteManyFile as ui, FleetRunEvent as un, NativeStoreHomeCopy as uo, SandboxTerminals as ur, FleetDriveTurnRequest as ut, SnapshotInfo as v, BatchRunRequest as va, PublishPublicTemplateOptions as vi, SandboxFleetAgentSpec as vn, RawEvidenceNativeFile as vo, CreateRequestOptions as vr, CreateTaskSessionOptions as vt, WorkspaceOperationLookup as w, AgentToolInvocation as wa, DockerDriverConfig as wi, SandboxFleetDriverCapability as wn, BatchEvent as wo, SandboxShapesInfo as wr, SendSessionMessageOptions as wt, SnapshotRemoteSync as x, AgentApprovalRequirement as xa, AcceleratorKind as xi, SandboxFleetCostEstimate as xn, InteractionResolutionAcknowledgement as xo, SandboxResources as xr, DriveTurnOptions as xt, SnapshotOptions as y, BatchTask as ya, PublishPublicTemplateVersionOptions as yi, SandboxFleetArtifact as yn, RawEvidencePayloadFile as yo, CreateSandboxOptions as yr, DispatchPromptOptions as yt, ExactProcessSpawnOptions as z, PromptResult as za, GpuLeaseProvidersOptions as zi, SandboxFleetSpend as zn, ChunkedUploadOptions as zr, SessionResultOptions as zt };
|