@inferencesh/sdk 0.38.15 → 0.39.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+ - `tasks.run()` and `tasks.watch().done` reject with `TaskCancelledError` when the task is cancelled and `TaskFailedError` when it fails, instead of a plain `Error`. Both carry the task as `error.task`. A task cancelled after its app returned a result now ends cancelled with that result as its `output`, so a caller that cancels reads the partial result from `error.task.output`. Messages are unchanged (`task cancelled`, the task's error). `isTaskCancelledError` and `isTaskFailedError` are the type guards.
12
+
10
13
  ## [0.38.0] - 2026-10-29
11
14
 
12
15
  ### Changed
package/README.md CHANGED
@@ -176,6 +176,22 @@ const task = await client.tasks.run(
176
176
  await client.tasks.cancel(task.id);
177
177
  ```
178
178
 
179
+ A `run()` that is waiting on a task rejects with `TaskCancelledError` when the task is cancelled. A task cancelled after its app returned a result ends cancelled and keeps that result as its `output` (billed like any other); it is `null` when the app returned nothing. The task is on the error:
180
+
181
+ ```typescript
182
+ import { isTaskCancelledError } from '@inferencesh/sdk';
183
+
184
+ try {
185
+ const result = await client.tasks.run({ app: 'long-running-app', input: {} });
186
+ } catch (error) {
187
+ if (isTaskCancelledError(error) && error.task.output != null) {
188
+ console.log('cancelled, partial result:', error.task.output);
189
+ }
190
+ }
191
+ ```
192
+
193
+ A failed task rejects with `TaskFailedError` the same way: the task's error as the message and the task on `error.task`.
194
+
179
195
  ### Stream Functions (Live Sockets)
180
196
 
181
197
  A stream function keeps a socket open with its caller for the life of the task: frames go both ways until the caller closes or the app returns. `client.live` starts the task and dials its socket; the run response carries where to dial (`task.socket`).
@@ -572,6 +588,8 @@ Runs a task on inference.sh.
572
588
  | `onPartialUpdate` | `function` | - | Callback for partial NDJSON stream updates `(task, fields)` |
573
589
  | `maxReconnects` | `number` | `5` | Max poll retries when `stream: false` |
574
590
 
591
+ **Returns:** the completed task. Rejects with `TaskFailedError` when the task fails and `TaskCancelledError` when it is cancelled; both carry the task as `error.task`, so a cancelled task's output (when its app returned one) is `error.task.output`.
592
+
575
593
  ### `client.tasks.get(taskId)`
576
594
 
577
595
  Gets a task by ID.
@@ -98,9 +98,13 @@ export declare class SkillsAPI {
98
98
  */
99
99
  download(namespace: string, name: string): Promise<Response<unknown>>;
100
100
  /**
101
- * Get skill content
101
+ * Get a skill's SKILL.md. The API answers with the markdown itself.
102
102
  */
103
- getContent(namespace: string, name: string): Promise<Response<unknown>>;
103
+ getContent(namespace: string, name: string): Promise<Response<string>>;
104
+ /**
105
+ * Get one of a skill's files by its path in the skill (e.g. "scripts/run.sh").
106
+ */
107
+ getFile(namespace: string, name: string, path: string): Promise<Response<string>>;
104
108
  /**
105
109
  * Transfer ownership
106
110
  */
@@ -139,10 +139,19 @@ export class SkillsAPI {
139
139
  return this.http.request('get', `/skills/${namespace}/${name}/download`);
140
140
  }
141
141
  /**
142
- * Get skill content
142
+ * Get a skill's SKILL.md. The API answers with the markdown itself.
143
143
  */
144
144
  async getContent(namespace, name) {
145
- return this.http.request('get', `/skills/${namespace}/${name}/content`);
145
+ const response = await this.http.fetch(`/skills/${namespace}/${name}/content`);
146
+ return { data: await response.text(), messages: [] };
147
+ }
148
+ /**
149
+ * Get one of a skill's files by its path in the skill (e.g. "scripts/run.sh").
150
+ */
151
+ async getFile(namespace, name, path) {
152
+ const filePath = path.split('/').map(encodeURIComponent).join('/');
153
+ const response = await this.http.fetch(`/skills/${namespace}/${name}/files/${filePath}`);
154
+ return { data: await response.text(), messages: [] };
146
155
  }
147
156
  /**
148
157
  * Transfer ownership
@@ -17,9 +17,12 @@ export declare class MCPServersAPI {
17
17
  */
18
18
  get(slug: string): Promise<Response<MCPServerDTO>>;
19
19
  /**
20
- * List tools for an MCP server
20
+ * List tools for an MCP server. The API answers from the catalogue it
21
+ * recorded within the hour; refresh asks the server again.
21
22
  */
22
- listTools(slug: string): Promise<Response<unknown[]>>;
23
+ listTools(slug: string, options?: {
24
+ refresh?: boolean;
25
+ }): Promise<Response<unknown[]>>;
23
26
  /**
24
27
  * Call a tool on an MCP server
25
28
  */
@@ -18,10 +18,11 @@ export class MCPServersAPI {
18
18
  return this.http.request('get', `/mcps/${slug}`);
19
19
  }
20
20
  /**
21
- * List tools for an MCP server
21
+ * List tools for an MCP server. The API answers from the catalogue it
22
+ * recorded within the hour; refresh asks the server again.
22
23
  */
23
- async listTools(slug) {
24
- return this.http.request('get', `/mcps/${slug}/tools`);
24
+ async listTools(slug, options) {
25
+ return this.http.request('get', `/mcps/${slug}/tools`, options?.refresh ? { params: { refresh: 1 } } : {});
25
26
  }
26
27
  /**
27
28
  * Call a tool on an MCP server
@@ -0,0 +1,38 @@
1
+ import { HttpClient } from '../http/client.js';
2
+ import type { Response } from '../http/response.js';
3
+ import type { PublicationCreateBody, PublicationUpdateBody } from './write-bodies.js';
4
+ import { PublicationDTO } from '../types.js';
5
+ /**
6
+ * Publications API
7
+ *
8
+ * A publication makes a resource (an agent) embeddable on other sites:
9
+ * which origins may embed it, its rate limit and its theme.
10
+ */
11
+ export declare class PublicationsAPI {
12
+ private readonly http;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * List a resource's publications
16
+ */
17
+ list(resourceType: string, resourceId: string): Promise<Response<PublicationDTO[]>>;
18
+ /**
19
+ * Get a publication by ID
20
+ */
21
+ get(id: string): Promise<Response<PublicationDTO>>;
22
+ /**
23
+ * Publish a resource
24
+ */
25
+ create(data: PublicationCreateBody): Promise<Response<PublicationDTO>>;
26
+ /**
27
+ * Write a publication's whole row: a field left out is cleared
28
+ */
29
+ update(id: string, data: PublicationUpdateBody): Promise<Response<PublicationDTO>>;
30
+ /**
31
+ * Write only the fields sent
32
+ */
33
+ patch(id: string, data: PublicationUpdateBody): Promise<Response<PublicationDTO>>;
34
+ /**
35
+ * Unpublish
36
+ */
37
+ delete(id: string): Promise<Response<void>>;
38
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Publications API
3
+ *
4
+ * A publication makes a resource (an agent) embeddable on other sites:
5
+ * which origins may embed it, its rate limit and its theme.
6
+ */
7
+ export class PublicationsAPI {
8
+ constructor(http) {
9
+ this.http = http;
10
+ }
11
+ /**
12
+ * List a resource's publications
13
+ */
14
+ async list(resourceType, resourceId) {
15
+ return this.http.request('get', '/publications', {
16
+ params: { resource_type: resourceType, resource_id: resourceId },
17
+ });
18
+ }
19
+ /**
20
+ * Get a publication by ID
21
+ */
22
+ async get(id) {
23
+ return this.http.request('get', `/publications/${id}`);
24
+ }
25
+ /**
26
+ * Publish a resource
27
+ */
28
+ async create(data) {
29
+ return this.http.request('post', '/publications', { data });
30
+ }
31
+ /**
32
+ * Write a publication's whole row: a field left out is cleared
33
+ */
34
+ async update(id, data) {
35
+ return this.http.request('put', `/publications/${id}`, { data });
36
+ }
37
+ /**
38
+ * Write only the fields sent
39
+ */
40
+ async patch(id, data) {
41
+ return this.http.request('patch', `/publications/${id}`, { data });
42
+ }
43
+ /**
44
+ * Unpublish
45
+ */
46
+ async delete(id) {
47
+ return this.http.request('delete', `/publications/${id}`);
48
+ }
49
+ }
@@ -0,0 +1,38 @@
1
+ import { HttpClient } from '../http/client.js';
2
+ import type { Response } from '../http/response.js';
3
+ import { CreateSandboxRequest, CursorListRequest, CursorListResponse, SandboxDTO } from '../types.js';
4
+ /**
5
+ * Sandboxes API
6
+ *
7
+ * A sandbox is a box on one of our engines that runs belt and connects back
8
+ * as a remote. The owner sets what it should be (running, stopped, deleted);
9
+ * start, stop and delete answer at once and the status follows.
10
+ */
11
+ export declare class SandboxesAPI {
12
+ private readonly http;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * List the caller's sandboxes with cursor-based pagination
16
+ */
17
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<SandboxDTO>>>;
18
+ /**
19
+ * Get a sandbox by ID
20
+ */
21
+ get(id: string): Promise<Response<SandboxDTO>>;
22
+ /**
23
+ * Create a sandbox. Sizes left out take the defaults; it starts on its own.
24
+ */
25
+ create(data: CreateSandboxRequest): Promise<Response<SandboxDTO>>;
26
+ /**
27
+ * Start a stopped sandbox. Its disk is new; its remote is the same.
28
+ */
29
+ start(id: string): Promise<Response<SandboxDTO>>;
30
+ /**
31
+ * Stop a sandbox. The record and its remote stay.
32
+ */
33
+ stop(id: string): Promise<Response<SandboxDTO>>;
34
+ /**
35
+ * Stop a sandbox, then remove the record and its remote
36
+ */
37
+ delete(id: string): Promise<Response<void>>;
38
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Sandboxes API
3
+ *
4
+ * A sandbox is a box on one of our engines that runs belt and connects back
5
+ * as a remote. The owner sets what it should be (running, stopped, deleted);
6
+ * start, stop and delete answer at once and the status follows.
7
+ */
8
+ export class SandboxesAPI {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ /**
13
+ * List the caller's sandboxes with cursor-based pagination
14
+ */
15
+ async list(params) {
16
+ return this.http.request('post', '/sandboxes/list', { data: params });
17
+ }
18
+ /**
19
+ * Get a sandbox by ID
20
+ */
21
+ async get(id) {
22
+ return this.http.request('get', `/sandboxes/${id}`);
23
+ }
24
+ /**
25
+ * Create a sandbox. Sizes left out take the defaults; it starts on its own.
26
+ */
27
+ async create(data) {
28
+ return this.http.request('post', '/sandboxes', { data });
29
+ }
30
+ /**
31
+ * Start a stopped sandbox. Its disk is new; its remote is the same.
32
+ */
33
+ async start(id) {
34
+ return this.http.request('post', `/sandboxes/${id}/start`);
35
+ }
36
+ /**
37
+ * Stop a sandbox. The record and its remote stay.
38
+ */
39
+ async stop(id) {
40
+ return this.http.request('post', `/sandboxes/${id}/stop`);
41
+ }
42
+ /**
43
+ * Stop a sandbox, then remove the record and its remote
44
+ */
45
+ async delete(id) {
46
+ return this.http.request('delete', `/sandboxes/${id}`);
47
+ }
48
+ }
@@ -74,13 +74,18 @@ export declare class TasksAPI {
74
74
  */
75
75
  stream(taskId: string): Promise<import("eventsource").EventSource | null>;
76
76
  /**
77
- * Run a task and optionally wait for completion
77
+ * Run a task and optionally wait for completion. With `wait` (the
78
+ * default) it resolves with the completed task and rejects with
79
+ * `TaskFailedError` or `TaskCancelledError`, both carrying the task; a
80
+ * cancelled task's output, when its app returned one, is on
81
+ * `error.task.output`.
78
82
  */
79
83
  run(params: ApiAppRunRequest, processedInput: unknown, options?: RunOptions): Promise<Task>;
80
84
  /**
81
85
  * Follows a task until it ends. `done` resolves with the task when it
82
- * completes and rejects when it fails or is cancelled; `stop` ends the
83
- * watch early and leaves `done` pending.
86
+ * completes and rejects with `TaskFailedError` or `TaskCancelledError`
87
+ * (the task, with any output, on `error.task`) when it fails or is
88
+ * cancelled; `stop` ends the watch early and leaves `done` pending.
84
89
  */
85
90
  watch(task: Pick<Task, 'id' | 'status'>, options?: WatchOptions): TaskWatch;
86
91
  private watchStream;
package/dist/api/tasks.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { streamUntilTerminal } from '../http/stream-until-terminal.js';
2
2
  import { PollManager } from '../http/poll.js';
3
+ import { TaskCancelledError, TaskFailedError } from '../http/errors.js';
3
4
  import { TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, TaskStatusRejected, } from '../types.js';
4
5
  import { parseStatus } from '../utils.js';
5
6
  //TODO: This is ugly...
@@ -16,17 +17,22 @@ function stripTask(task) {
16
17
  session_id: task.session_id,
17
18
  };
18
19
  }
19
- /** Settles a watch when `data` carries a terminal status; no-op otherwise. */
20
+ /**
21
+ * Settles a watch when `data` carries a terminal status; no-op otherwise.
22
+ * Failed and cancelled reject with the task on the error: a task cancelled
23
+ * after its app returned a result ends cancelled with that result as its
24
+ * output, and the caller reads it from `TaskCancelledError.task`.
25
+ */
20
26
  function settleTerminal(data, stripped, settle) {
21
27
  switch (parseStatus(data.status)) {
22
28
  case TaskStatusCompleted:
23
29
  settle.resolve(stripped);
24
30
  break;
25
31
  case TaskStatusFailed:
26
- settle.reject(new Error(data.error || 'task failed'));
32
+ settle.reject(new TaskFailedError(stripped));
27
33
  break;
28
34
  case TaskStatusCancelled:
29
- settle.reject(new Error('task cancelled'));
35
+ settle.reject(new TaskCancelledError(stripped));
30
36
  break;
31
37
  case TaskStatusRejected:
32
38
  settle.reject(new Error(data.error || 'task rejected'));
@@ -101,7 +107,11 @@ export class TasksAPI {
101
107
  return this.http.createEventSource(`/tasks/${taskId}/stream`);
102
108
  }
103
109
  /**
104
- * Run a task and optionally wait for completion
110
+ * Run a task and optionally wait for completion. With `wait` (the
111
+ * default) it resolves with the completed task and rejects with
112
+ * `TaskFailedError` or `TaskCancelledError`, both carrying the task; a
113
+ * cancelled task's output, when its app returned one, is on
114
+ * `error.task.output`.
105
115
  */
106
116
  async run(params, processedInput, options = {}) {
107
117
  const { wait = true } = options;
@@ -116,8 +126,9 @@ export class TasksAPI {
116
126
  }
117
127
  /**
118
128
  * Follows a task until it ends. `done` resolves with the task when it
119
- * completes and rejects when it fails or is cancelled; `stop` ends the
120
- * watch early and leaves `done` pending.
129
+ * completes and rejects with `TaskFailedError` or `TaskCancelledError`
130
+ * (the task, with any output, on `error.task`) when it fails or is
131
+ * cancelled; `stop` ends the watch early and leaves `done` pending.
121
132
  */
122
133
  watch(task, options = {}) {
123
134
  const useStream = options.stream ?? this.http.getStreamDefault();
@@ -15,7 +15,7 @@
15
15
  * chats, engines and teams send PATCH; apps.patch and flows.patch are the
16
16
  * partial siblings of the POST updates that also edit a version.
17
17
  */
18
- import type { AgentConfigInput, ResourceImages, AppDTO, ChatDTO, CredentialRequirements, EngineDTO, FlowDTO, FlowVersionDTO, KnowledgeDTO, MCPServerDTO, ProjectDTO, TeamDTO, Visibility } from '../types.js';
18
+ import type { AgentConfigInput, ResourceImages, AppDTO, ChatDTO, CredentialRequirements, EngineDTO, FlowDTO, FlowVersionDTO, KnowledgeDTO, MCPServerDTO, ProjectDTO, PublicationDTO, TeamDTO, Visibility } from '../types.js';
19
19
  /**
20
20
  * POST /agents/{id}. Images, and a new version when `version` is set.
21
21
  * Visibility: `agents.updateVisibility`. Name, title, harness, placement:
@@ -121,3 +121,14 @@ export interface MCPServerUpdateBody {
121
121
  documentation_url?: string;
122
122
  credentials?: CredentialRequirements;
123
123
  }
124
+ /**
125
+ * POST /publications. What to publish (`resource_type`, e.g. "agent", and
126
+ * `resource_id`), where it may be embedded and how it looks. Namespace and
127
+ * name come from the resource; a new publication is enabled.
128
+ */
129
+ export type PublicationCreateBody = Pick<PublicationDTO, 'resource_type' | 'resource_id'> & Partial<Pick<PublicationDTO, 'title' | 'allowed_origins' | 'rate_limit_rpm' | 'theme' | 'label' | 'visibility'>>;
130
+ /**
131
+ * PUT /publications/{id} writes the whole row: a field left out is cleared.
132
+ * PATCH (`publications.patch`) writes only the fields sent.
133
+ */
134
+ export type PublicationUpdateBody = Partial<Pick<PublicationDTO, 'title' | 'allowed_origins' | 'rate_limit_rpm' | 'theme' | 'label' | 'enabled'>>;
@@ -4,7 +4,7 @@
4
4
  * Note: types.ts contains interfaces (APIError, RequirementsNotMetError) that describe
5
5
  * the API response data shapes. These classes are throwable Error subclasses for SDK use.
6
6
  */
7
- import type { RequirementError } from '../types.js';
7
+ import type { RequirementError, TaskDTO } from '../types.js';
8
8
  /**
9
9
  * General HTTP/API error thrown by the SDK.
10
10
  *
@@ -132,6 +132,36 @@ export declare class SessionEndedError extends SessionError {
132
132
  export declare class WorkerLostError extends SessionError {
133
133
  constructor(sessionId: string, responseBody?: string);
134
134
  }
135
+ /**
136
+ * Error `tasks.run()` and `tasks.watch().done` reject with when a task is
137
+ * cancelled. A task cancelled after its app returned a result keeps that
138
+ * result: `task.output` carries it, billed like any other. `task.output`
139
+ * is null when the app returned nothing.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * try {
144
+ * const task = await client.tasks.run(params);
145
+ * } catch (e) {
146
+ * if (isTaskCancelledError(e) && e.task.output != null) {
147
+ * usePartialResult(e.task.output);
148
+ * }
149
+ * }
150
+ * ```
151
+ */
152
+ export declare class TaskCancelledError extends Error {
153
+ /** The task as it ended; its output when the app returned one before stopping. */
154
+ readonly task: TaskDTO;
155
+ constructor(task: TaskDTO);
156
+ }
157
+ /**
158
+ * Error `tasks.run()` and `tasks.watch().done` reject with when a task
159
+ * fails. The message is the task's error; `task` is the task as it ended.
160
+ */
161
+ export declare class TaskFailedError extends Error {
162
+ readonly task: TaskDTO;
163
+ constructor(task: TaskDTO);
164
+ }
135
165
  /**
136
166
  * Type guard for RequirementsNotMetException.
137
167
  * Handles cross-module issues where instanceof may fail.
@@ -145,3 +175,11 @@ export declare function isInferenceError(err: unknown): err is InferenceError;
145
175
  * Type guard for SessionError (or any subclass).
146
176
  */
147
177
  export declare function isSessionError(err: unknown): err is SessionError;
178
+ /**
179
+ * Type guard for TaskCancelledError.
180
+ */
181
+ export declare function isTaskCancelledError(err: unknown): err is TaskCancelledError;
182
+ /**
183
+ * Type guard for TaskFailedError.
184
+ */
185
+ export declare function isTaskFailedError(err: unknown): err is TaskFailedError;
@@ -154,6 +154,42 @@ export class WorkerLostError extends SessionError {
154
154
  this.name = 'WorkerLostError';
155
155
  }
156
156
  }
157
+ // Task outcome errors
158
+ /**
159
+ * Error `tasks.run()` and `tasks.watch().done` reject with when a task is
160
+ * cancelled. A task cancelled after its app returned a result keeps that
161
+ * result: `task.output` carries it, billed like any other. `task.output`
162
+ * is null when the app returned nothing.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * try {
167
+ * const task = await client.tasks.run(params);
168
+ * } catch (e) {
169
+ * if (isTaskCancelledError(e) && e.task.output != null) {
170
+ * usePartialResult(e.task.output);
171
+ * }
172
+ * }
173
+ * ```
174
+ */
175
+ export class TaskCancelledError extends Error {
176
+ constructor(task) {
177
+ super('task cancelled');
178
+ this.name = 'TaskCancelledError';
179
+ this.task = task;
180
+ }
181
+ }
182
+ /**
183
+ * Error `tasks.run()` and `tasks.watch().done` reject with when a task
184
+ * fails. The message is the task's error; `task` is the task as it ended.
185
+ */
186
+ export class TaskFailedError extends Error {
187
+ constructor(task) {
188
+ super(task.error || 'task failed');
189
+ this.name = 'TaskFailedError';
190
+ this.task = task;
191
+ }
192
+ }
157
193
  // =============================================================================
158
194
  // Type Guards
159
195
  // =============================================================================
@@ -195,3 +231,25 @@ export function isSessionError(err) {
195
231
  return typeof e.sessionId === 'string' && typeof e.statusCode === 'number' &&
196
232
  ['SessionError', 'SessionNotFoundError', 'SessionExpiredError', 'SessionEndedError', 'WorkerLostError'].includes(e.name);
197
233
  }
234
+ /**
235
+ * Type guard for TaskCancelledError.
236
+ */
237
+ export function isTaskCancelledError(err) {
238
+ if (err instanceof TaskCancelledError)
239
+ return true;
240
+ if (typeof err !== 'object' || err === null)
241
+ return false;
242
+ const e = err;
243
+ return e.name === 'TaskCancelledError' && typeof e.task === 'object' && e.task !== null;
244
+ }
245
+ /**
246
+ * Type guard for TaskFailedError.
247
+ */
248
+ export function isTaskFailedError(err) {
249
+ if (err instanceof TaskFailedError)
250
+ return true;
251
+ if (typeof err !== 'object' || err === null)
252
+ return false;
253
+ const e = err;
254
+ return e.name === 'TaskFailedError' && typeof e.task === 'object' && e.task !== null;
255
+ }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { StreamManager, type StreamManagerOptions, type PartialDataWrapper } fro
5
5
  export { StreamableManager, type StreamableManagerOptions, type StreamReconnectOptions, type StreamableSource, type StreamRequest, type StreamRequestInit, type StreamableMessage, streamable, streamableRaw } from './http/streamable.js';
6
6
  export { PollManager, type PollManagerOptions } from './http/poll.js';
7
7
  export { isLoopbackHost, isHttpsOrLoopback } from './http/loopback.js';
8
- export { InferenceError, RequirementsNotMetException, SessionError, SessionNotFoundError, SessionExpiredError, SessionEndedError, WorkerLostError, isRequirementsNotMetException, isInferenceError, isSessionError, } from './http/errors.js';
8
+ export { InferenceError, RequirementsNotMetException, SessionError, SessionNotFoundError, SessionExpiredError, SessionEndedError, WorkerLostError, TaskCancelledError, TaskFailedError, isRequirementsNotMetException, isInferenceError, isSessionError, isTaskCancelledError, isTaskFailedError, } from './http/errors.js';
9
9
  export { TasksAPI, type RunOptions, type WatchOptions, type TaskWatch } from './api/tasks.js';
10
10
  export { SocketsAPI, type SocketTarget, type OpenSocketOptions } from './api/sockets.js';
11
11
  export { FilesAPI, type UploadFileOptions } from './api/files.js';
@@ -18,7 +18,7 @@ export { FlowRunsAPI } from './api/flow-runs.js';
18
18
  export { EnginesAPI } from './api/engines.js';
19
19
  export { KnowledgeAPI, SkillsAPI } from './api/knowledge.js';
20
20
  export { ArtifactsAPI } from './api/artifacts.js';
21
- export type { AgentUpdateBody, AppPatchBody, AppUpdateBody, ChatUpdateBody, EngineUpdateBody, FlowUpdateBody, FlowPatchBody, FlowViewportBody, ProjectWriteBody, ProjectCreateBody, ProjectUpdateBody, KnowledgeUpdateBody, TeamUpdateBody, MCPServerCreateBody, MCPServerUpdateBody, } from './api/write-bodies.js';
21
+ export type { AgentUpdateBody, AppPatchBody, AppUpdateBody, ChatUpdateBody, EngineUpdateBody, FlowUpdateBody, FlowPatchBody, FlowViewportBody, ProjectWriteBody, ProjectCreateBody, ProjectUpdateBody, KnowledgeUpdateBody, TeamUpdateBody, MCPServerCreateBody, MCPServerUpdateBody, PublicationCreateBody, PublicationUpdateBody, } from './api/write-bodies.js';
22
22
  export { TeamsAPI } from './api/teams.js';
23
23
  export { SecretsAPI } from './api/secrets.js';
24
24
  export { ApiKeysAPI } from './api/api-keys.js';
@@ -26,6 +26,8 @@ export { CredentialsAPI } from './api/credentials.js';
26
26
  export { SearchAPI } from './api/search.js';
27
27
  export { ProjectsAPI } from './api/projects.js';
28
28
  export { MCPServersAPI } from './api/mcp-servers.js';
29
+ export { SandboxesAPI } from './api/sandboxes.js';
30
+ export { PublicationsAPI } from './api/publications.js';
29
31
  export { LiveSession, accessUrl } from './live/session.js';
30
32
  export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, RealtimeOptions, LiveUpdate, WebSocketLike, WebSocketConstructor } from './live/session.js';
31
33
  export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES, RELAY_KEY } from './live/protocol.js';
@@ -62,6 +64,8 @@ import { CredentialsAPI } from './api/credentials.js';
62
64
  import { SearchAPI } from './api/search.js';
63
65
  import { ProjectsAPI } from './api/projects.js';
64
66
  import { MCPServersAPI } from './api/mcp-servers.js';
67
+ import { SandboxesAPI } from './api/sandboxes.js';
68
+ import { PublicationsAPI } from './api/publications.js';
65
69
  import { ApiAppRunRequest, TaskDTO as Task, AgentConfigInput as AgentConfig, FileDTO as File } from './types.js';
66
70
  export interface InferenceConfig {
67
71
  /** Your inference.sh API key (required unless using proxyUrl) */
@@ -118,6 +122,8 @@ export declare class Inference {
118
122
  readonly search: SearchAPI;
119
123
  readonly projects: ProjectsAPI;
120
124
  readonly mcpServers: MCPServersAPI;
125
+ readonly sandboxes: SandboxesAPI;
126
+ readonly publications: PublicationsAPI;
121
127
  readonly sockets: SocketsAPI;
122
128
  constructor(config: InferenceConfig | HttpClientConfig);
123
129
  /** @internal */
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@ export { StreamManager } from './http/stream.js';
4
4
  export { StreamableManager, streamable, streamableRaw } from './http/streamable.js';
5
5
  export { PollManager } from './http/poll.js';
6
6
  export { isLoopbackHost, isHttpsOrLoopback } from './http/loopback.js';
7
- export { InferenceError, RequirementsNotMetException, SessionError, SessionNotFoundError, SessionExpiredError, SessionEndedError, WorkerLostError,
7
+ export { InferenceError, RequirementsNotMetException, SessionError, SessionNotFoundError, SessionExpiredError, SessionEndedError, WorkerLostError, TaskCancelledError, TaskFailedError,
8
8
  // Type guards (use these instead of instanceof for reliability)
9
- isRequirementsNotMetException, isInferenceError, isSessionError, } from './http/errors.js';
9
+ isRequirementsNotMetException, isInferenceError, isSessionError, isTaskCancelledError, isTaskFailedError, } from './http/errors.js';
10
10
  // API modules
11
11
  export { TasksAPI } from './api/tasks.js';
12
12
  export { SocketsAPI } from './api/sockets.js';
@@ -27,6 +27,8 @@ export { CredentialsAPI } from './api/credentials.js';
27
27
  export { SearchAPI } from './api/search.js';
28
28
  export { ProjectsAPI } from './api/projects.js';
29
29
  export { MCPServersAPI } from './api/mcp-servers.js';
30
+ export { SandboxesAPI } from './api/sandboxes.js';
31
+ export { PublicationsAPI } from './api/publications.js';
30
32
  // Live: the socket of a stream task and the live fields of its schemas
31
33
  export { LiveSession, accessUrl } from './live/session.js';
32
34
  export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES, RELAY_KEY } from './live/protocol.js';
@@ -64,6 +66,8 @@ import { CredentialsAPI } from './api/credentials.js';
64
66
  import { SearchAPI } from './api/search.js';
65
67
  import { ProjectsAPI } from './api/projects.js';
66
68
  import { MCPServersAPI } from './api/mcp-servers.js';
69
+ import { SandboxesAPI } from './api/sandboxes.js';
70
+ import { PublicationsAPI } from './api/publications.js';
67
71
  /**
68
72
  * Inference.sh SDK Client
69
73
  *
@@ -107,6 +111,8 @@ export class Inference {
107
111
  this.search = new SearchAPI(this.http);
108
112
  this.projects = new ProjectsAPI(this.http);
109
113
  this.mcpServers = new MCPServersAPI(this.http);
114
+ this.sandboxes = new SandboxesAPI(this.http);
115
+ this.publications = new PublicationsAPI(this.http);
110
116
  this.sockets = new SocketsAPI(this.http, this.tasks);
111
117
  }
112
118
  // Legacy methods for backward compatibility
package/dist/types.d.ts CHANGED
@@ -478,7 +478,6 @@ export interface ApiAppRunRequest {
478
478
  session?: string;
479
479
  session_timeout?: number;
480
480
  run_at?: string;
481
- metadata?: TaskMetadata;
482
481
  }
483
482
  /**
484
483
  * MessageInput is a message a caller sends to an agent: its text and the
@@ -909,6 +908,13 @@ export interface CredentialCompleteOAuthRequest {
909
908
  export interface CredentialConnectResponse {
910
909
  credential?: CredentialDTO;
911
910
  auth_url?: string;
911
+ /**
912
+ * ConnectURL is a short link on our app that sends the person who
913
+ * started this connect on to AuthURL. A client that does not finish the
914
+ * flow in its own browser tab (a CLI, an agent) shows this one: the
915
+ * app's callback completes only a flow its browser started.
916
+ */
917
+ connect_url?: string;
912
918
  state?: string;
913
919
  code_verifier?: string;
914
920
  instructions?: string;
@@ -5134,6 +5140,48 @@ export interface ProjectDTO extends BaseModelDTO, PermissionModelDTO {
5134
5140
  parent?: ProjectDTO;
5135
5141
  children: (ProjectDTO | undefined)[];
5136
5142
  }
5143
+ /**
5144
+ * PublicationThemeColors defines the core colors for one mode (light or dark).
5145
+ */
5146
+ export interface PublicationThemeColors {
5147
+ primary: string;
5148
+ secondary: string;
5149
+ background: string;
5150
+ text: string;
5151
+ border?: string;
5152
+ }
5153
+ /**
5154
+ * PublicationTheme defines branding colors for embedded UIs.
5155
+ */
5156
+ export interface PublicationTheme {
5157
+ light: PublicationThemeColors;
5158
+ dark?: PublicationThemeColors;
5159
+ }
5160
+ /**
5161
+ * PublicationDTO for API responses.
5162
+ */
5163
+ export interface PublicationDTO extends BaseModelDTO, PermissionModelDTO {
5164
+ resource_type: string;
5165
+ resource_id: string;
5166
+ namespace: string;
5167
+ name: string;
5168
+ /**
5169
+ * Title is the human-readable name; empty falls back to Name.
5170
+ */
5171
+ title: string;
5172
+ allowed_origins?: string[];
5173
+ rate_limit_rpm?: number;
5174
+ theme?: PublicationTheme;
5175
+ label?: string;
5176
+ enabled: boolean;
5177
+ /**
5178
+ * VisitorReads is the scope groups of the team's resources (knowledge,
5179
+ * artifacts, files, remotes) a visitor can ask the published agent's
5180
+ * current version to reach by id: what its built-in tools add to an
5181
+ * embed run. Empty when its tools reach only what it names itself.
5182
+ */
5183
+ visitor_reads: ScopeGroup[];
5184
+ }
5137
5185
  /**
5138
5186
  * AccessNoticeDTO is the redlist's notice to a restricted caller, as a
5139
5187
  * refusal's meta.notice and /me's access_notice carry it.
@@ -8799,20 +8847,6 @@ export declare const TaskLogTypeRun: TaskLogType;
8799
8847
  export declare const TaskLogTypeServe: TaskLogType;
8800
8848
  export declare const TaskLogTypeSetup: TaskLogType;
8801
8849
  export declare const TaskLogTypeTask: TaskLogType;
8802
- /**
8803
- * TaskAction defines an action to execute when a task reaches a specific status.
8804
- */
8805
- export interface TaskAction {
8806
- key: string;
8807
- on: string;
8808
- params?: any;
8809
- }
8810
- /**
8811
- * TaskMetadata holds optional metadata attached to a task.
8812
- */
8813
- export interface TaskMetadata {
8814
- action?: TaskAction;
8815
- }
8816
8850
  export type TeamType = "personal" | "team" | "system" | "org";
8817
8851
  export declare const TeamTypePersonal: TeamType;
8818
8852
  export declare const TeamTypeTeam: TeamType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.38.15",
3
+ "version": "0.39.0",
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",