@inferencesh/sdk 0.39.1 → 0.39.3

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/api/files.js CHANGED
@@ -137,7 +137,14 @@ export class FilesAPI {
137
137
  if (!file.upload_url) {
138
138
  throw new Error('No upload URL provided by the server');
139
139
  }
140
- await putToSignedUrl(file.upload_url, resolved.body);
140
+ try {
141
+ await putToSignedUrl(file.upload_url, resolved.body);
142
+ }
143
+ catch (err) {
144
+ // The record was counted at its size and holds nothing: drop it.
145
+ await this.delete(file.id).catch(() => undefined);
146
+ throw err;
147
+ }
141
148
  return file;
142
149
  }
143
150
  /**
@@ -1,6 +1,95 @@
1
1
  import { HttpClient } from '../http/client.js';
2
2
  import type { Response } from '../http/response.js';
3
- import { CreateSandboxRequest, CursorListRequest, CursorListResponse, SandboxDTO } from '../types.js';
3
+ import type { FilesAPI } from './files.js';
4
+ import { CreateSandboxRequest, CursorListRequest, CursorListResponse, EnforcementMode, EntitlementType, FileDTO as File, SandboxDTO } from '../types.js';
5
+ /** One command run on a remote (the API's ExecRunDTO, the fields read here). */
6
+ export interface SandboxExecRun {
7
+ id: string;
8
+ status: 'pending' | 'running' | 'exited' | 'killed' | 'denied';
9
+ exit_code?: number;
10
+ timed_out?: boolean;
11
+ error?: string;
12
+ [key: string]: unknown;
13
+ }
14
+ /** The result of {@link SandboxesAPI.exec}: the run, and the last MiB of each stream. */
15
+ export interface SandboxExecResult {
16
+ run: SandboxExecRun;
17
+ /**
18
+ * false: the command was still running when the wait ran out; it keeps
19
+ * running. Read from `run.status` (the API answers no `done`).
20
+ */
21
+ done: boolean;
22
+ stdout: string;
23
+ stderr: string;
24
+ }
25
+ export interface SandboxExecOptions {
26
+ args?: string[];
27
+ cwd?: string;
28
+ /** KEY=VALUE entries. */
29
+ env?: string[];
30
+ /** Kill the command after this long (ms). */
31
+ timeoutMs?: number;
32
+ /** How long to wait for it to finish, whole seconds from 1 to 600. Default 60. */
33
+ waitSeconds?: number;
34
+ }
35
+ /** One entry of a directory on a running sandbox. */
36
+ export interface SandboxFileEntry {
37
+ name: string;
38
+ kind: 'file' | 'dir' | 'link' | 'other';
39
+ size: number;
40
+ /** Octal permission bits, e.g. "644". */
41
+ mode: string;
42
+ modified_at?: string;
43
+ }
44
+ /**
45
+ * An import or an export: the path on the box, the platform file on the
46
+ * other side (its `size` is the file's) and, for an export, a short-lived
47
+ * URL that downloads it.
48
+ */
49
+ export interface SandboxFileTransfer {
50
+ path: string;
51
+ file?: File;
52
+ download_url?: string;
53
+ }
54
+ /**
55
+ * One team limit and its use now (the API's ResourceUsage). A `warn` limit
56
+ * (kept disks, snapshots) is soft: going past it is not refused.
57
+ * TODO(models): use the generated ResourceUsage once the models release carries it.
58
+ */
59
+ export interface SandboxResourceUsage {
60
+ /** "sandboxes", "sandbox_vcpus", or another sandbox_* resource. */
61
+ resource: string;
62
+ label: string;
63
+ unit?: string;
64
+ type: EntitlementType;
65
+ usage: number;
66
+ /** Not read when `unlimited`. */
67
+ limit: number;
68
+ unlimited: boolean;
69
+ enabled: boolean;
70
+ mode?: EnforcementMode;
71
+ }
72
+ export interface SandboxRange {
73
+ default: number;
74
+ max: number;
75
+ }
76
+ /** What the team may run now, and the sizes one sandbox may ask for. */
77
+ export interface SandboxLimits {
78
+ /**
79
+ * `sandboxes` (running at once) and every sandbox_* limit (e.g.
80
+ * `sandbox_vcpus`), sorted by resource.
81
+ */
82
+ limits: SandboxResourceUsage[];
83
+ vcpus_per_sandbox: SandboxRange;
84
+ memory_mib: SandboxRange;
85
+ disk_mib: SandboxRange;
86
+ /** Seconds; 0 never stops. */
87
+ idle_timeout_default: number;
88
+ idle_timeout_min: number;
89
+ idle_timeout_max: number;
90
+ /** Seconds a stopped sandbox's disk is kept. */
91
+ disk_kept_for: number;
92
+ }
4
93
  /**
5
94
  * Sandboxes API
6
95
  *
@@ -10,7 +99,11 @@ import { CreateSandboxRequest, CursorListRequest, CursorListResponse, SandboxDTO
10
99
  */
11
100
  export declare class SandboxesAPI {
12
101
  private readonly http;
13
- constructor(http: HttpClient);
102
+ private readonly files?;
103
+ /** files uploads and deletes the storage copy writeFile and readFile move bytes through. */
104
+ constructor(http: HttpClient, files?: FilesAPI | undefined);
105
+ /** Each sandbox's remote id, as exec last found it. */
106
+ private readonly remoteIds;
14
107
  /**
15
108
  * List the caller's sandboxes with cursor-based pagination
16
109
  */
@@ -35,4 +128,42 @@ export declare class SandboxesAPI {
35
128
  * Stop a sandbox, then remove the record and its remote
36
129
  */
37
130
  delete(id: string): Promise<Response<void>>;
131
+ /**
132
+ * Run a command on a running sandbox and wait for it (up to
133
+ * `waitSeconds`, default 60). Returns the run with the last MiB of stdout
134
+ * and stderr; `done` is false when it is still running.
135
+ */
136
+ exec(id: string, command: string, options?: SandboxExecOptions): Promise<SandboxExecResult>;
137
+ /** The remote of a running sandbox, looked up and kept for the next exec. */
138
+ private remoteId;
139
+ /** List the directory at an absolute path on a running sandbox. */
140
+ listFiles(id: string, path: string): Promise<Response<SandboxFileEntry[]>>;
141
+ /** Delete a file (not a directory) on a running sandbox. */
142
+ deleteFile(id: string, path: string): Promise<void>;
143
+ /**
144
+ * Have a running sandbox download a platform file (see `files.upload`) to
145
+ * an absolute path. The bytes go from storage to the box directly.
146
+ */
147
+ importFile(id: string, path: string, fileId: string): Promise<SandboxFileTransfer>;
148
+ /**
149
+ * Have a running sandbox upload the file at an absolute path into a new
150
+ * platform file of yours; `download_url` fetches it for 15 minutes.
151
+ */
152
+ exportFile(id: string, path: string): Promise<SandboxFileTransfer>;
153
+ /**
154
+ * Read a file from a running sandbox. It goes through your file storage
155
+ * (an export, then a download); the storage copy is deleted after.
156
+ */
157
+ readFile(id: string, path: string): Promise<Uint8Array>;
158
+ /** Read a UTF-8 text file from a running sandbox; a leading BOM is kept. */
159
+ readTextFile(id: string, path: string): Promise<string>;
160
+ /**
161
+ * Write a file on a running sandbox, making its directory. It goes
162
+ * through your file storage (an upload, then an import), so it can be as
163
+ * large as one upload; the storage copy is deleted after. Storage takes
164
+ * no empty upload: make an empty file with {@link exec} (`touch`).
165
+ */
166
+ writeFile(id: string, path: string, content: Uint8Array | string | Blob): Promise<SandboxFileTransfer>;
167
+ /** What the team may run now, and the sizes one sandbox may ask for. */
168
+ limits(): Promise<Response<SandboxLimits>>;
38
169
  }
@@ -1,3 +1,9 @@
1
+ import { InferenceError } from '../http/errors.js';
2
+ /** A run's statuses once it has finished. */
3
+ const EXEC_RUN_FINISHED = new Set(['exited', 'killed', 'denied']);
4
+ /** The longest {@link SandboxExecOptions.waitSeconds} the API holds a request. */
5
+ const EXEC_WAIT_MAX = 600;
6
+ const filesPath = (id, path) => `/sandboxes/${encodeURIComponent(id)}/files?path=${encodeURIComponent(path)}`;
1
7
  /**
2
8
  * Sandboxes API
3
9
  *
@@ -6,8 +12,12 @@
6
12
  * start, stop and delete answer at once and the status follows.
7
13
  */
8
14
  export class SandboxesAPI {
9
- constructor(http) {
15
+ /** files uploads and deletes the storage copy writeFile and readFile move bytes through. */
16
+ constructor(http, files) {
10
17
  this.http = http;
18
+ this.files = files;
19
+ /** Each sandbox's remote id, as exec last found it. */
20
+ this.remoteIds = new Map();
11
21
  }
12
22
  /**
13
23
  * List the caller's sandboxes with cursor-based pagination
@@ -37,12 +47,145 @@ export class SandboxesAPI {
37
47
  * Stop a sandbox. The record and its remote stay.
38
48
  */
39
49
  async stop(id) {
50
+ this.remoteIds.delete(id);
40
51
  return this.http.request('post', `/sandboxes/${id}/stop`);
41
52
  }
42
53
  /**
43
54
  * Stop a sandbox, then remove the record and its remote
44
55
  */
45
56
  async delete(id) {
57
+ this.remoteIds.delete(id);
46
58
  return this.http.request('delete', `/sandboxes/${id}`);
47
59
  }
60
+ /**
61
+ * Run a command on a running sandbox and wait for it (up to
62
+ * `waitSeconds`, default 60). Returns the run with the last MiB of stdout
63
+ * and stderr; `done` is false when it is still running.
64
+ */
65
+ async exec(id, command, options = {}) {
66
+ const wait = options.waitSeconds ?? 60;
67
+ // 0 would answer the bare run, not a result: the API waits only for 1 or more.
68
+ if (!Number.isInteger(wait) || wait < 1 || wait > EXEC_WAIT_MAX) {
69
+ throw new RangeError(`waitSeconds is whole seconds from 1 to ${EXEC_WAIT_MAX}, not ${wait}`);
70
+ }
71
+ const run = async (remoteId) => {
72
+ const res = await this.http.request('post', `/remotes/${encodeURIComponent(remoteId)}/execs`, {
73
+ params: { wait },
74
+ data: { command, args: options.args, cwd: options.cwd, env: options.env, timeout_ms: options.timeoutMs },
75
+ });
76
+ return { ...res.data, done: EXEC_RUN_FINISHED.has(res.data.run.status) };
77
+ };
78
+ const cached = this.remoteIds.get(id);
79
+ if (cached) {
80
+ try {
81
+ return await run(cached);
82
+ }
83
+ catch (err) {
84
+ // The remote went away or is not connected: look the sandbox up again.
85
+ if (!(err instanceof InferenceError) || (err.statusCode !== 404 && err.statusCode !== 409)) {
86
+ throw err;
87
+ }
88
+ this.remoteIds.delete(id);
89
+ }
90
+ }
91
+ return run(await this.remoteId(id));
92
+ }
93
+ /** The remote of a running sandbox, looked up and kept for the next exec. */
94
+ async remoteId(id) {
95
+ const sandbox = (await this.get(id)).data;
96
+ if (sandbox.status !== 'running') {
97
+ throw new Error(`sandbox ${id} is ${sandbox.status}, not running; start it first`);
98
+ }
99
+ if (!sandbox.remote_id) {
100
+ throw new Error(`sandbox ${id} has no remote yet; wait until it is running`);
101
+ }
102
+ this.remoteIds.set(id, sandbox.remote_id);
103
+ return sandbox.remote_id;
104
+ }
105
+ /** List the directory at an absolute path on a running sandbox. */
106
+ async listFiles(id, path) {
107
+ return this.http.request('get', filesPath(id, path));
108
+ }
109
+ /** Delete a file (not a directory) on a running sandbox. */
110
+ async deleteFile(id, path) {
111
+ await this.http.request('delete', filesPath(id, path));
112
+ }
113
+ /**
114
+ * Have a running sandbox download a platform file (see `files.upload`) to
115
+ * an absolute path. The bytes go from storage to the box directly.
116
+ */
117
+ async importFile(id, path, fileId) {
118
+ const res = await this.http.request('post', `/sandboxes/${encodeURIComponent(id)}/files/import`, {
119
+ data: { path, file_id: fileId },
120
+ });
121
+ return res.data;
122
+ }
123
+ /**
124
+ * Have a running sandbox upload the file at an absolute path into a new
125
+ * platform file of yours; `download_url` fetches it for 15 minutes.
126
+ */
127
+ async exportFile(id, path) {
128
+ const res = await this.http.request('post', `/sandboxes/${encodeURIComponent(id)}/files/export`, {
129
+ data: { path },
130
+ });
131
+ return res.data;
132
+ }
133
+ /**
134
+ * Read a file from a running sandbox. It goes through your file storage
135
+ * (an export, then a download); the storage copy is deleted after.
136
+ */
137
+ async readFile(id, path) {
138
+ // Without it the export's storage copy could not be deleted after.
139
+ if (!this.files) {
140
+ throw new Error('readFile needs the files API: use the client\'s sandboxes, not a bare SandboxesAPI');
141
+ }
142
+ const files = this.files;
143
+ const t = await this.exportFile(id, path);
144
+ try {
145
+ if (!t.download_url) {
146
+ throw new Error(`the export of ${path} returned no download URL`);
147
+ }
148
+ const res = await fetch(t.download_url);
149
+ if (!res.ok) {
150
+ throw new Error(`downloading ${path} from storage: HTTP ${res.status}`);
151
+ }
152
+ return new Uint8Array(await res.arrayBuffer());
153
+ }
154
+ finally {
155
+ if (t.file?.id) {
156
+ await files.delete(t.file.id).catch(() => undefined);
157
+ }
158
+ }
159
+ }
160
+ /** Read a UTF-8 text file from a running sandbox; a leading BOM is kept. */
161
+ async readTextFile(id, path) {
162
+ return new TextDecoder('utf-8', { ignoreBOM: true }).decode(await this.readFile(id, path));
163
+ }
164
+ /**
165
+ * Write a file on a running sandbox, making its directory. It goes
166
+ * through your file storage (an upload, then an import), so it can be as
167
+ * large as one upload; the storage copy is deleted after. Storage takes
168
+ * no empty upload: make an empty file with {@link exec} (`touch`).
169
+ */
170
+ async writeFile(id, path, content) {
171
+ if (!this.files) {
172
+ throw new Error('writeFile needs the files API: use the client\'s sandboxes, not a bare SandboxesAPI');
173
+ }
174
+ const blob = content instanceof Blob ? content : new Blob([typeof content === 'string' ? new TextEncoder().encode(content) : content]);
175
+ if (blob.size === 0) {
176
+ throw new RangeError(`${path}: an empty file is not uploaded; make it with exec('touch')`);
177
+ }
178
+ const name = path.split('/').pop() || 'file';
179
+ const file = await this.files.upload(blob, { filename: name });
180
+ try {
181
+ return await this.importFile(id, path, file.id);
182
+ }
183
+ finally {
184
+ await this.files.delete(file.id).catch(() => undefined);
185
+ }
186
+ }
187
+ /** What the team may run now, and the sizes one sandbox may ask for. */
188
+ async limits() {
189
+ return this.http.request('get', '/sandboxes/limits');
190
+ }
48
191
  }
@@ -262,6 +262,12 @@ export class HttpClient {
262
262
  if (response.status === 204 || !responseText) {
263
263
  return { data: undefined, messages: [] };
264
264
  }
265
+ // A held request (exec wait, file import/export) answers 200 before its
266
+ // outcome; when it fails, the body under that 200 is a problem.
267
+ const heldStatus = problemStatus(data);
268
+ if (heldStatus !== undefined) {
269
+ throw this.responseError(heldStatus, responseText, data);
270
+ }
265
271
  // Unwrap V3 envelope: {"data": <dto>, "messages": [...]}
266
272
  if (data && typeof data === 'object' && 'data' in data && !Array.isArray(data)) {
267
273
  const messages = data.messages ?? [];
@@ -316,6 +322,20 @@ export class HttpClient {
316
322
  return Promise.resolve(new EventSource(this.streamUrl(targetUrl), { fetch: doFetch }));
317
323
  }
318
324
  }
325
+ /**
326
+ * The status of a problem+json body (RFC 9457): an object with a numeric
327
+ * `status` of 400 or more and a `title`, `detail` or `type`.
328
+ */
329
+ function problemStatus(data) {
330
+ if (!data || typeof data !== 'object' || Array.isArray(data))
331
+ return undefined;
332
+ const d = data;
333
+ if (typeof d.status !== 'number' || d.status < 400)
334
+ return undefined;
335
+ if (typeof d.title !== 'string' && typeof d.detail !== 'string' && typeof d.type !== 'string')
336
+ return undefined;
337
+ return d.status;
338
+ }
319
339
  /**
320
340
  * Create an HTTP client instance
321
341
  */
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export { SearchAPI } from './api/search.js';
27
27
  export { ProjectsAPI } from './api/projects.js';
28
28
  export { MCPServersAPI } from './api/mcp-servers.js';
29
29
  export { SandboxesAPI } from './api/sandboxes.js';
30
+ export type { SandboxExecRun, SandboxExecResult, SandboxExecOptions, SandboxFileEntry, SandboxFileTransfer, SandboxResourceUsage, SandboxRange, SandboxLimits, } from './api/sandboxes.js';
30
31
  export { PublicationsAPI } from './api/publications.js';
31
32
  export { LiveSession, accessUrl } from './live/session.js';
32
33
  export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, RealtimeOptions, LiveUpdate, WebSocketLike, WebSocketConstructor } from './live/session.js';
package/dist/index.js CHANGED
@@ -111,7 +111,7 @@ export class Inference {
111
111
  this.search = new SearchAPI(this.http);
112
112
  this.projects = new ProjectsAPI(this.http);
113
113
  this.mcpServers = new MCPServersAPI(this.http);
114
- this.sandboxes = new SandboxesAPI(this.http);
114
+ this.sandboxes = new SandboxesAPI(this.http, this.files);
115
115
  this.publications = new PublicationsAPI(this.http);
116
116
  this.sockets = new SocketsAPI(this.http, this.tasks);
117
117
  }
package/dist/types.d.ts CHANGED
@@ -341,6 +341,12 @@ export interface AgentVersionDTO extends BaseModelDTO, PermissionModelDTO {
341
341
  * platform's mode.
342
342
  */
343
343
  content_guard?: ContentGuardConfig;
344
+ /**
345
+ * VaultID is the agent's vault: the sandboxes its sandbox_create makes
346
+ * get the vault's inference.sh access (VaultDTO.APIScopes). Absent: no
347
+ * vault.
348
+ */
349
+ vault_id?: string;
344
350
  /**
345
351
  * VisitorReads is the scope groups of the team's resources (knowledge,
346
352
  * files, artifacts, remotes) a visitor of an embed of this version can
@@ -396,6 +402,11 @@ export interface AgentConfigInput {
396
402
  hooks?: LifecycleHookConfig[];
397
403
  output_schema?: any;
398
404
  content_guard?: ContentGuardConfig;
405
+ /**
406
+ * VaultID picks the agent's vault, whose inference.sh access the
407
+ * sandboxes it makes get. Empty: no vault.
408
+ */
409
+ vault_id?: string;
399
410
  }
400
411
  /**
401
412
  * CoreAppConfigInput is the API input shape for core app configuration.
@@ -478,6 +489,12 @@ export interface ApiAppRunRequest {
478
489
  session?: string;
479
490
  session_timeout?: number;
480
491
  run_at?: string;
492
+ /**
493
+ * StartTimeout, in seconds (1-86400): if no worker has started the task
494
+ * within it (counted from run_at when set), it is cancelled, not
495
+ * billed, and leaves the queue. Unset, it waits as any task does.
496
+ */
497
+ start_timeout?: number;
481
498
  }
482
499
  /**
483
500
  * MessageInput is a message a caller sends to an agent: its text and the
@@ -1410,6 +1427,11 @@ export interface ScopeDefinition {
1410
1427
  * apps, agents, flows).
1411
1428
  */
1412
1429
  costs_credits?: boolean;
1430
+ /**
1431
+ * Sandbox: a vault may grant it to a sandbox (its inference.sh access,
1432
+ * VaultDTO.APIScopes); the allowlist is models.SandboxMayHold.
1433
+ */
1434
+ sandbox?: boolean;
1413
1435
  }
1414
1436
  /**
1415
1437
  * ScopeCategory is the section of a permission list a scope group falls
@@ -2445,6 +2467,13 @@ export interface ChatSettingsRequest {
2445
2467
  * agent keeps for this conversation. A key that is not there is ignored.
2446
2468
  */
2447
2469
  forget_memory?: string[];
2470
+ /**
2471
+ * Strictness is what the agent does in this chat after the content
2472
+ * guard flags something it read: watch, ask or strict. "" clears the
2473
+ * chat's own level, so the agent's default applies. A team or org
2474
+ * minimum still raises it (GET /chats/{id}/strictness).
2475
+ */
2476
+ strictness?: ChatStrictness;
2448
2477
  }
2449
2478
  /**
2450
2479
  * ChatSettingsDTO is what POST /chats/{id}/settings answers with: the chat's
@@ -2465,6 +2494,56 @@ export interface ChatSettingsDTO {
2465
2494
  * Memory is agent_data.memory after forget_memory removed its keys.
2466
2495
  */
2467
2496
  memory: StringEncodedMap;
2497
+ /**
2498
+ * Strictness is agent_data.strictness: the chat's own level, "" when
2499
+ * it follows the agent's default.
2500
+ */
2501
+ strictness: ChatStrictness;
2502
+ }
2503
+ /**
2504
+ * ChatStrictnessDTO is GET /chats/{id}/strictness: what the agent does in
2505
+ * the chat after the content guard flags something it read, and where that
2506
+ * comes from. Effective is the strictest of the chat's level (Chat, else
2507
+ * AgentDefault, else watch), Minimum and Delegated.
2508
+ */
2509
+ export interface ChatStrictnessDTO {
2510
+ chat_id: string;
2511
+ /**
2512
+ * Chat is the chat's own level; "" when it follows the agent.
2513
+ */
2514
+ chat: ChatStrictness;
2515
+ /**
2516
+ * AgentDefault is the agent's content_guard.strictness; "" for watch.
2517
+ */
2518
+ agent_default: ChatStrictness;
2519
+ /**
2520
+ * Minimum is the strictest level the chat's team or org governance
2521
+ * policy sets; "" when neither sets one. Levels below it are locked.
2522
+ */
2523
+ minimum: ChatStrictness;
2524
+ /**
2525
+ * MinimumSetBy is the rung that set Minimum: team or org.
2526
+ */
2527
+ minimum_set_by?: PolicySubject;
2528
+ /**
2529
+ * Delegated is, for a sub-agent's chat, the level the chat that
2530
+ * delegated to it runs at: a floor, so a sub-agent never runs looser
2531
+ * than its delegating chat. "" for a chat no agent delegated.
2532
+ */
2533
+ delegated?: ChatStrictness;
2534
+ /**
2535
+ * Flagged reports that the content guard has flagged something an
2536
+ * agent read in this chat, or in the chat that delegated to it. It
2537
+ * lasts for the life of the chat: what was flagged stays in its
2538
+ * history, so ask and strict apply to every later run of the chat.
2539
+ * Lowering the chat's level (the person's sign-in) is how runs go on
2540
+ * unasked again.
2541
+ */
2542
+ flagged: boolean;
2543
+ /**
2544
+ * Effective is the level the chat runs at.
2545
+ */
2546
+ effective: ChatStrictness;
2468
2547
  }
2469
2548
  /**
2470
2549
  * ChatAgentDTO is what POST /chats/{id}/agent answers with: the agent the
@@ -2818,6 +2897,12 @@ export interface ContentGuardConfig {
2818
2897
  * job is reading Slack mentions).
2819
2898
  */
2820
2899
  ignore_rules?: string[];
2900
+ /**
2901
+ * Strictness is what the agent's chats do after the guard flags a
2902
+ * result, unless a chat sets its own: watch (default), ask or strict
2903
+ * (shared.ChatStrictness). A team or org minimum still raises it.
2904
+ */
2905
+ strictness?: ChatStrictness;
2821
2906
  }
2822
2907
  /**
2823
2908
  * ContentTier is how far a tool's output is from the agent's operator:
@@ -3342,7 +3427,7 @@ export interface WorkerRAM {
3342
3427
  * a task lists the ones it needs (Task.Requires); the scheduler only sends
3343
3428
  * a task to an engine that has every one it needs.
3344
3429
  */
3345
- export type EngineCapability = "egress_gateway" | "sandboxes" | "capacity" | "egress_pending" | "egress_grants" | "egress_decide" | "sized_sandboxes" | "sized_workers" | "sandbox_snapshots";
3430
+ export type EngineCapability = "egress_gateway" | "sandboxes" | "capacity" | "egress_pending" | "egress_grants" | "egress_decide" | "sized_sandboxes" | "sized_workers" | "sandbox_snapshots" | "sandbox_snapshot_store";
3346
3431
  /**
3347
3432
  * EngineCapabilityEgressGateway: the engine runs its sandboxes behind
3348
3433
  * the egress gateway, so it can take bound secrets (the v2 secrets
@@ -3410,6 +3495,16 @@ export declare const EngineCapabilitySizedWorkers: EngineCapability;
3410
3495
  * WsSandboxStartPayload.FromSnapshotID; INF-1251).
3411
3496
  */
3412
3497
  export declare const EngineCapabilitySandboxSnapshots: EngineCapability;
3498
+ /**
3499
+ * EngineCapabilitySandboxSnapshotStore: the engine also keeps a
3500
+ * snapshot in object storage when asked (WsSandboxSnapshotPayload.Store):
3501
+ * it exports the copy's used blocks, compressed, and uploads them in
3502
+ * parts through URLs the API presigns (it holds no storage credential).
3503
+ * It starts a sandbox from a stored snapshot it has no copy of
3504
+ * (WsSandboxStartPayload.FromSnapshot): it downloads the parts, checks
3505
+ * each against the manifest, and rebuilds the disk.
3506
+ */
3507
+ export declare const EngineCapabilitySandboxSnapshotStore: EngineCapability;
3413
3508
  /**
3414
3509
  * EngineCapabilities is a set of capabilities, kept as a list. Nil and
3415
3510
  * empty are the same: nothing beyond the base contract.
@@ -5660,6 +5755,14 @@ export interface CreateSandboxRequest {
5660
5755
  * smaller than the snapshot's.
5661
5756
  */
5662
5757
  from_snapshot_id?: string;
5758
+ /**
5759
+ * VaultID is the vault whose inference.sh access (VaultDTO.APIScopes)
5760
+ * the box gets, copied once now and cut to what the caller can hand
5761
+ * on. Empty: the box holds what it needs to run its remote and
5762
+ * nothing more. A sandbox an agent's sandbox_create makes takes the
5763
+ * agent's vault (AgentVersionDTO.VaultID) instead.
5764
+ */
5765
+ vault_id?: string;
5663
5766
  }
5664
5767
  /**
5665
5768
  * UpdateSandboxRequest is PATCH /sandboxes/{id}: the fields to change,
@@ -5787,6 +5890,12 @@ export interface SandboxDTO extends BaseModelDTO, PermissionModelDTO {
5787
5890
  * its box started, whichever is later.
5788
5891
  */
5789
5892
  last_activity_at?: string;
5893
+ /**
5894
+ * APIScopes are what the box may do with our API beyond running its
5895
+ * remote: copied from its vault when it was made (VaultID), for its
5896
+ * whole life. Absent or empty: nothing beyond the remote.
5897
+ */
5898
+ api_scopes?: Scope[];
5790
5899
  }
5791
5900
  /**
5792
5901
  * SandboxFileKind is what a path on a sandbox is.
@@ -5944,6 +6053,14 @@ export interface SandboxSnapshotDTO extends BaseModelDTO {
5944
6053
  status: SandboxSnapshotStatus;
5945
6054
  status_reason?: string;
5946
6055
  ready_at?: string;
6056
+ /**
6057
+ * StoreStatus is where keeping it in object storage stands: empty when
6058
+ * it is kept on its engine alone. Stored, a sandbox starts from it on
6059
+ * any engine, and it outlives the engine that took it. StoredBytes is
6060
+ * what the stored copy holds (compressed).
6061
+ */
6062
+ store_status?: SandboxSnapshotStoreStatus;
6063
+ stored_bytes?: number;
5947
6064
  /**
5948
6065
  * ForFork: taken by a fork for its sandboxes to start from, and
5949
6066
  * deleted once they have all started or failed. Not listed.
@@ -5989,6 +6106,28 @@ export interface ForkSandboxResponse {
5989
6106
  snapshot_id?: string;
5990
6107
  error?: string;
5991
6108
  }
6109
+ /**
6110
+ * SandboxSnapshotStoreStatus is where keeping a snapshot in object storage
6111
+ * stands (EngineCapabilitySandboxSnapshotStore).
6112
+ */
6113
+ export type SandboxSnapshotStoreStatus = "pending" | "uploading" | "stored" | "failed";
6114
+ /**
6115
+ * SandboxSnapshotStorePending: asked of the engine, not begun.
6116
+ */
6117
+ export declare const SandboxSnapshotStorePending: SandboxSnapshotStoreStatus;
6118
+ /**
6119
+ * SandboxSnapshotStoreUploading: the engine is uploading it.
6120
+ */
6121
+ export declare const SandboxSnapshotStoreUploading: SandboxSnapshotStoreStatus;
6122
+ /**
6123
+ * SandboxSnapshotStoreStored: it is in object storage, whole.
6124
+ */
6125
+ export declare const SandboxSnapshotStoreStored: SandboxSnapshotStoreStatus;
6126
+ /**
6127
+ * SandboxSnapshotStoreFailed: the upload did not finish; the snapshot
6128
+ * is still kept on its engine.
6129
+ */
6130
+ export declare const SandboxSnapshotStoreFailed: SandboxSnapshotStoreStatus;
5992
6131
  /**
5993
6132
  * SDKTypes is a phantom type for gotypegen dependency tracing.
5994
6133
  * Types listed here (and their transitive dependencies) are included
@@ -7731,6 +7870,22 @@ export declare const ChannelTypeSlack: ChannelType;
7731
7870
  export declare const ChannelTypeDiscord: ChannelType;
7732
7871
  export declare const ChannelTypeTeams: ChannelType;
7733
7872
  export declare const ChannelTypeTelegram: ChannelType;
7873
+ /**
7874
+ * ChatStrictness is what an agent does in a chat after the content guard
7875
+ * flags a tool result it read (a web page, an app's output, an MCP reply):
7876
+ * - watch: the flag is recorded and the run goes on. The default.
7877
+ * - ask: every later tool call of the run that has side effects waits
7878
+ * for a person's approval (the tool-approval prompt).
7879
+ * - strict: the run is stopped.
7880
+ * The agent's config sets the default (content_guard.strictness), a person
7881
+ * changes it per chat (agent_data.strictness), and a team or org governance
7882
+ * policy can set a minimum: the chat runs at the stricter of its own level
7883
+ * and the minimum (EffectiveChatStrictness).
7884
+ */
7885
+ export type ChatStrictness = "watch" | "ask" | "strict";
7886
+ export declare const ChatStrictnessWatch: ChatStrictness;
7887
+ export declare const ChatStrictnessAsk: ChatStrictness;
7888
+ export declare const ChatStrictnessStrict: ChatStrictness;
7734
7889
  /**
7735
7890
  * ChatData contains agent-specific data for a chat session
7736
7891
  */
@@ -7748,6 +7903,13 @@ export interface ChatData {
7748
7903
  * that reviews it.
7749
7904
  */
7750
7905
  disable_hooks?: boolean;
7906
+ /**
7907
+ * Strictness is what the agent does in this chat after the content
7908
+ * guard flags something it read: watch, ask or strict. Empty is the
7909
+ * agent's default (content_guard.strictness), itself watch when unset.
7910
+ * A team or org minimum can raise it (ChatStrictnessDTO.Effective).
7911
+ */
7912
+ strictness?: ChatStrictness;
7751
7913
  /**
7752
7914
  * Client is the app the chat was started from (web, mac, ios, cli,
7753
7915
  * sdk-js), as the request named itself (X-Client-Source). Shown, never
@@ -7859,7 +8021,7 @@ export interface ChatBackgroundEvent {
7859
8021
  * RunEndReason is why a run that completed ended the way it did, when its
7860
8022
  * last turn did not end with a reply.
7861
8023
  */
7862
- export type RunEndReason = "output_limit" | "no_reply" | "refusal";
8024
+ export type RunEndReason = "output_limit" | "no_reply" | "refusal" | "content_flagged";
7863
8025
  /**
7864
8026
  * RunEndReasonOutputLimit: the model's last turn hit its output limit
7865
8027
  * (max_tokens) before it replied or called a tool.
@@ -7877,6 +8039,12 @@ export declare const RunEndReasonNoReply: RunEndReason;
7877
8039
  * message is not refused for what this run held.
7878
8040
  */
7879
8041
  export declare const RunEndReasonRefusal: RunEndReason;
8042
+ /**
8043
+ * RunEndReasonContentFlagged: the content guard flagged a tool result
8044
+ * the run read and the chat's strictness is strict, so the run was
8045
+ * stopped there.
8046
+ */
8047
+ export declare const RunEndReasonContentFlagged: RunEndReason;
7880
8048
  /**
7881
8049
  * ChatRunEvent is how a run ended, on a run_ended event.
7882
8050
  */
@@ -9180,6 +9348,24 @@ export declare const PolicyKindWebFetch: PolicyKind;
9180
9348
  * secrets to a host.
9181
9349
  */
9182
9350
  export declare const PolicyKindSecretSend: PolicyKind;
9351
+ /**
9352
+ * PolicySubject is a rung of the subject ladder: what a policy is attached
9353
+ * to and what a decision names as its layer. Most specific first: remote,
9354
+ * chat, agent, user, team, org, platform. The values match CredentialScope
9355
+ * where both exist.
9356
+ */
9357
+ export type PolicySubject = "remote" | "chat" | "agent" | "user" | "team" | "org" | "platform";
9358
+ /**
9359
+ * PolicySubjectRemote is the machine a call runs on. Its policy is the
9360
+ * machine owner's, and only narrows.
9361
+ */
9362
+ export declare const PolicySubjectRemote: PolicySubject;
9363
+ export declare const PolicySubjectChat: PolicySubject;
9364
+ export declare const PolicySubjectAgent: PolicySubject;
9365
+ export declare const PolicySubjectUser: PolicySubject;
9366
+ export declare const PolicySubjectTeam: PolicySubject;
9367
+ export declare const PolicySubjectOrg: PolicySubject;
9368
+ export declare const PolicySubjectPlatform: PolicySubject;
9183
9369
  /**
9184
9370
  * FunctionKind is how an app function talks to its caller.
9185
9371
  */
package/dist/types.js CHANGED
@@ -570,6 +570,16 @@ export const EngineCapabilitySizedWorkers = "sized_workers";
570
570
  * WsSandboxStartPayload.FromSnapshotID; INF-1251).
571
571
  */
572
572
  export const EngineCapabilitySandboxSnapshots = "sandbox_snapshots";
573
+ /**
574
+ * EngineCapabilitySandboxSnapshotStore: the engine also keeps a
575
+ * snapshot in object storage when asked (WsSandboxSnapshotPayload.Store):
576
+ * it exports the copy's used blocks, compressed, and uploads them in
577
+ * parts through URLs the API presigns (it holds no storage credential).
578
+ * It starts a sandbox from a stored snapshot it has no copy of
579
+ * (WsSandboxStartPayload.FromSnapshot): it downloads the parts, checks
580
+ * each against the manifest, and rebuilds the disk.
581
+ */
582
+ export const EngineCapabilitySandboxSnapshotStore = "sandbox_snapshot_store";
573
583
  /**
574
584
  * MaxOvercommit and MaxCPUSlots bound what EngineCapacityPolicy may say.
575
585
  */
@@ -997,6 +1007,23 @@ export const SandboxSnapshotReady = "ready";
997
1007
  * says why), or the engine no longer has it.
998
1008
  */
999
1009
  export const SandboxSnapshotFailed = "failed";
1010
+ /**
1011
+ * SandboxSnapshotStorePending: asked of the engine, not begun.
1012
+ */
1013
+ export const SandboxSnapshotStorePending = "pending";
1014
+ /**
1015
+ * SandboxSnapshotStoreUploading: the engine is uploading it.
1016
+ */
1017
+ export const SandboxSnapshotStoreUploading = "uploading";
1018
+ /**
1019
+ * SandboxSnapshotStoreStored: it is in object storage, whole.
1020
+ */
1021
+ export const SandboxSnapshotStoreStored = "stored";
1022
+ /**
1023
+ * SandboxSnapshotStoreFailed: the upload did not finish; the snapshot
1024
+ * is still kept on its engine.
1025
+ */
1026
+ export const SandboxSnapshotStoreFailed = "failed";
1000
1027
  /**
1001
1028
  * UpdateRequested: the request was sent and nothing has answered it yet.
1002
1029
  * An engine older than engine_update_result never answers, so its update stays here.
@@ -1335,6 +1362,9 @@ export const ChannelTypeSlack = "slack";
1335
1362
  export const ChannelTypeDiscord = "discord";
1336
1363
  export const ChannelTypeTeams = "teams";
1337
1364
  export const ChannelTypeTelegram = "telegram";
1365
+ export const ChatStrictnessWatch = "watch";
1366
+ export const ChatStrictnessAsk = "ask";
1367
+ export const ChatStrictnessStrict = "strict";
1338
1368
  /**
1339
1369
  * ChatOriginUI is a person in one of our apps: web, mac, ios, watch or
1340
1370
  * the CLI.
@@ -1409,6 +1439,12 @@ export const RunEndReasonNoReply = "no_reply";
1409
1439
  * message is not refused for what this run held.
1410
1440
  */
1411
1441
  export const RunEndReasonRefusal = "refusal";
1442
+ /**
1443
+ * RunEndReasonContentFlagged: the content guard flagged a tool result
1444
+ * the run read and the chat's strictness is strict, so the run was
1445
+ * stopped there.
1446
+ */
1447
+ export const RunEndReasonContentFlagged = "content_flagged";
1412
1448
  /**
1413
1449
  * DescriptionLimitListing bounds the description of an app, agent, flow,
1414
1450
  * MCP server or knowledge entry. A description is shown in listings and
@@ -2069,6 +2105,17 @@ export const PolicyKindWebFetch = "WebFetch";
2069
2105
  * secrets to a host.
2070
2106
  */
2071
2107
  export const PolicyKindSecretSend = "SecretSend";
2108
+ /**
2109
+ * PolicySubjectRemote is the machine a call runs on. Its policy is the
2110
+ * machine owner's, and only narrows.
2111
+ */
2112
+ export const PolicySubjectRemote = "remote";
2113
+ export const PolicySubjectChat = "chat";
2114
+ export const PolicySubjectAgent = "agent";
2115
+ export const PolicySubjectUser = "user";
2116
+ export const PolicySubjectTeam = "team";
2117
+ export const PolicySubjectOrg = "org";
2118
+ export const PolicySubjectPlatform = "platform";
2072
2119
  /**
2073
2120
  * FunctionKindRun takes an input and returns an output (optionally
2074
2121
  * yielding progress on the way). The zero value means this.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.39.1",
3
+ "version": "0.39.3",
4
4
  "description": "Official JavaScript/TypeScript SDK for inference.sh - Run AI models with a simple API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",