@inferencesh/sdk 0.6.54 → 0.7.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,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-09-23
11
+
12
+ ### Changed
13
+
14
+ - `client.credentials` (`CredentialsAPI`) replaces `client.integrations` / `IntegrationsAPI`; both old names remain as deprecated aliases
15
+ - `httpTool().auth({ credential, credentialId })` writes auth type `credential`; `integration` / `integrationId` still work
16
+ - Requirement errors use type `credential` (was `integration`); check against `RequirementTypeCredential`
17
+ - `CredentialsAPI.checkRequirements` is typed (`CheckRequirementsRequest` with `credentials`, `CheckRequirementsResponse`)
18
+ - API key scopes are `credentials:read` / `credentials:write` (`integrations:*` keys keep working)
19
+
10
20
  ## [0.6.8] - 2026-05-20
11
21
 
12
22
  ### Added
package/README.md CHANGED
@@ -377,7 +377,7 @@ Use the fluent builders to define `AgentTool` schemas. Client tools (`tool`) run
377
377
  | `agentTool(name, agentRef)` | Server | Delegate to a sub-agent |
378
378
  | `httpTool(name, url)` / `callTool(name, url)` | Server | HTTP request with credential injection (preferred over `webhookTool`) |
379
379
  | `webhookTool(name, url)` | Server | Unsigned webhook (legacy; use `httpTool` for new tools) |
380
- | `mcpTool(name, integrationId, toolName)` | Server | Call a tool on a connected MCP integration |
380
+ | `mcpTool(name, credentialId, toolName)` | Server | Call a tool through a connected MCP credential |
381
381
  | `internalTools()` | Server | Built-in plan, memory, and widget tools |
382
382
 
383
383
  ```typescript
@@ -397,11 +397,11 @@ const clientTool = tool('get_weather')
397
397
  .param('city', string('City name'))
398
398
  .build();
399
399
 
400
- // HTTP tool with OAuth integration credentials (injected server-side)
400
+ // HTTP tool authenticated with a connected account (token injected server-side)
401
401
  const gmailSend = httpTool('gmail_send', 'https://gmail.googleapis.com/gmail/v1/users/me/messages/send')
402
402
  .describe('Send an email via Gmail')
403
403
  .method('POST')
404
- .auth({ integration: CredentialProviderGoogle, integrationId: 'your-integration-id' })
404
+ .auth({ credential: CredentialProviderGoogle, credentialId: 'your-credential-id' })
405
405
  .build();
406
406
 
407
407
  // API key or bearer auth
@@ -420,7 +420,7 @@ const imageGen = appTool('generate_image', 'infsh/flux-schnell@abc123')
420
420
  .requireApproval()
421
421
  .build();
422
422
 
423
- const mcpSearch = mcpTool('notion_search', 'your-mcp-integration-id', 'search')
423
+ const mcpSearch = mcpTool('notion_search', 'your-mcp-credential-id', 'search')
424
424
  .describe('Search Notion pages')
425
425
  .param('query', string('Search query'))
426
426
  .build();
@@ -642,9 +642,9 @@ if (task.status === TaskStatusCompleted) {
642
642
  }
643
643
  ```
644
644
 
645
- ## Integration Constants
645
+ ## Credential Constants
646
646
 
647
- `CredentialDTO` fields (`provider`, `type`, `auth`, `status`) use typed string unions exported as constants:
647
+ `CredentialDTO` fields (`provider`, `type`, `status`) use typed string unions exported as constants:
648
648
 
649
649
  ```typescript
650
650
  import type { CredentialDTO } from '@inferencesh/sdk';
@@ -655,24 +655,25 @@ import {
655
655
  CredentialStatusDisconnected,
656
656
  CredentialStatusExpired,
657
657
  CredentialStatusError,
658
+ RequirementTypeCredential,
658
659
  isRequirementsNotMetException,
659
660
  } from '@inferencesh/sdk';
660
661
 
661
- function isGoogleConnected(integration: CredentialDTO): boolean {
662
+ function isGoogleConnected(credential: CredentialDTO): boolean {
662
663
  return (
663
- integration.provider === CredentialProviderGoogle &&
664
- integration.status === CredentialStatusConnected
664
+ credential.provider === CredentialProviderGoogle &&
665
+ credential.status === CredentialStatusConnected
665
666
  );
666
667
  }
667
668
 
668
- // HTTP 412 when an app requires a missing secret, integration, or scope
669
+ // HTTP 412 when an app requires a missing secret, credential, or scope
669
670
  try {
670
671
  await client.run({ app: 'my-app', input: {} });
671
672
  } catch (error) {
672
673
  if (isRequirementsNotMetException(error)) {
673
674
  for (const req of error.errors) {
674
- if (req.type === 'integration' && req.action?.provider === CredentialProviderGoogle) {
675
- // User must connect Google — see https://inference.sh/docs/extend/integrations
675
+ if (req.type === RequirementTypeCredential && req.action?.provider === CredentialProviderGoogle) {
676
+ // User must connect Google — see https://inference.sh/docs/extend/credentials
676
677
  }
677
678
  }
678
679
  }
@@ -1,22 +1,22 @@
1
1
  import { HttpClient } from '../http/client';
2
2
  import type { Response } from '../http/response';
3
- import { CredentialDTO, CredentialConfigDTO, CredentialConnectRequest, CredentialConnectResponse, CursorListRequest, CursorListResponse } from '../types';
3
+ import { CheckRequirementsRequest, CheckRequirementsResponse, CredentialDTO, CredentialConfigDTO, CredentialConnectRequest, CredentialConnectResponse, CursorListRequest, CursorListResponse } from '../types';
4
4
  /**
5
- * Integrations API
5
+ * Credentials API: the accounts and keys a team has connected to external services.
6
6
  */
7
- export declare class IntegrationsAPI {
7
+ export declare class CredentialsAPI {
8
8
  private readonly http;
9
9
  constructor(http: HttpClient);
10
10
  /**
11
- * List integrations with cursor-based pagination
11
+ * List credentials with cursor-based pagination
12
12
  */
13
13
  list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<CredentialDTO>>>;
14
14
  /**
15
- * Get available integrations
15
+ * List the providers a credential can be connected for
16
16
  */
17
17
  listAvailable(): Promise<Response<CredentialConfigDTO[]>>;
18
18
  /**
19
- * Get integration configs
19
+ * Get provider connection configs
20
20
  */
21
21
  getConfigs(): Promise<Response<CredentialConfigDTO[]>>;
22
22
  /**
@@ -24,19 +24,19 @@ export declare class IntegrationsAPI {
24
24
  */
25
25
  getCapabilities(): Promise<Response<unknown>>;
26
26
  /**
27
- * Check requirements
27
+ * Check whether secret and credential requirements are satisfied
28
28
  */
29
- checkRequirements(data: unknown): Promise<Response<unknown>>;
29
+ checkRequirements(data: CheckRequirementsRequest): Promise<Response<CheckRequirementsResponse>>;
30
30
  /**
31
- * Connect an integration
31
+ * Connect a credential
32
32
  */
33
33
  connect(data: CredentialConnectRequest): Promise<Response<CredentialConnectResponse>>;
34
34
  /**
35
- * Get an integration by provider key
35
+ * Get a credential by provider key
36
36
  */
37
37
  get(provider: string): Promise<Response<CredentialDTO>>;
38
38
  /**
39
- * Disconnect an integration
39
+ * Disconnect a credential
40
40
  */
41
41
  disconnect(provider: string): Promise<Response<void>>;
42
42
  }
@@ -1,24 +1,24 @@
1
1
  /**
2
- * Integrations API
2
+ * Credentials API: the accounts and keys a team has connected to external services.
3
3
  */
4
- export class IntegrationsAPI {
4
+ export class CredentialsAPI {
5
5
  constructor(http) {
6
6
  this.http = http;
7
7
  }
8
8
  /**
9
- * List integrations with cursor-based pagination
9
+ * List credentials with cursor-based pagination
10
10
  */
11
11
  async list(params) {
12
12
  return this.http.request('post', '/credentials/list', { data: params });
13
13
  }
14
14
  /**
15
- * Get available integrations
15
+ * List the providers a credential can be connected for
16
16
  */
17
17
  async listAvailable() {
18
18
  return this.http.request('get', '/credentials/available');
19
19
  }
20
20
  /**
21
- * Get integration configs
21
+ * Get provider connection configs
22
22
  */
23
23
  async getConfigs() {
24
24
  return this.http.request('get', '/credentials/configs');
@@ -30,27 +30,27 @@ export class IntegrationsAPI {
30
30
  return this.http.request('get', '/credentials/capabilities');
31
31
  }
32
32
  /**
33
- * Check requirements
33
+ * Check whether secret and credential requirements are satisfied
34
34
  */
35
35
  async checkRequirements(data) {
36
36
  return this.http.request('post', '/credentials/check', { data });
37
37
  }
38
38
  /**
39
- * Connect an integration
39
+ * Connect a credential
40
40
  */
41
41
  async connect(data) {
42
42
  return this.http.request('post', '/credentials', { data });
43
43
  }
44
44
  /**
45
- * Get an integration by provider key
45
+ * Get a credential by provider key
46
46
  */
47
47
  async get(provider) {
48
- return this.http.request('get', `/credentials/${provider}`);
48
+ return this.http.request('get', `/credentials/${encodeURIComponent(provider)}`);
49
49
  }
50
50
  /**
51
- * Disconnect an integration
51
+ * Disconnect a credential
52
52
  */
53
53
  async disconnect(provider) {
54
- return this.http.request('delete', `/credentials/${provider}`);
54
+ return this.http.request('delete', `/credentials/${encodeURIComponent(provider)}`);
55
55
  }
56
56
  }
@@ -34,6 +34,7 @@ export declare class SocketsAPI {
34
34
  forTask(taskId: string): Promise<SocketDTO | null>;
35
35
  /** A fresh credential for the caller's end, e.g. after a reload or to redial. */
36
36
  access(id: string): Promise<Response<SocketAccess>>;
37
+ private credentialFor;
37
38
  delete(id: string): Promise<Response<void>>;
38
39
  /**
39
40
  * Dials the caller's end of a stream task's socket. The session is
@@ -27,6 +27,12 @@ export class SocketsAPI {
27
27
  async access(id) {
28
28
  return this.http.request('post', `/sockets/${id}/access`);
29
29
  }
30
+ async credentialFor(taskId) {
31
+ const socket = await this.forTask(taskId);
32
+ if (!socket)
33
+ throw new Error(`task ${taskId} has no socket: is it a stream function?`);
34
+ return (await this.access(socket.id)).data;
35
+ }
30
36
  async delete(id) {
31
37
  return this.http.request('delete', `/sockets/${id}`);
32
38
  }
@@ -35,20 +41,17 @@ export class SocketsAPI {
35
41
  * `waiting` until the app's first frame, then `live`; see LiveSession.
36
42
  */
37
43
  async open(target, handlers = {}, options = {}) {
38
- const task = typeof target === 'string' ? (await this.tasks.get(target)).data : target;
39
- let access = typeof target === 'string' ? undefined : target.socket;
40
- let socketId = access?.id;
41
- if (!access) {
42
- const socket = await this.forTask(task.id);
43
- if (!socket)
44
- throw new Error(`task ${task.id} has no socket: is it a stream function?`);
45
- socketId = socket.id;
46
- access = (await this.access(socket.id)).data;
47
- }
44
+ const taskId = typeof target === 'string' ? target : target.id;
45
+ // Given only an id, the task (for the watch) and a credential for its
46
+ // socket are independent: fetch them together.
47
+ const [task, access] = await Promise.all([
48
+ typeof target === 'string' ? this.tasks.get(target).then((res) => res.data) : target,
49
+ (typeof target !== 'string' && target.socket) || this.credentialFor(taskId),
50
+ ]);
48
51
  const session = new LiveSession({
49
52
  access,
50
53
  handlers,
51
- renew: async () => (await this.access(socketId)).data,
54
+ renew: async () => (await this.access(access.id)).data,
52
55
  task: options.watchTask === false ? undefined : this.tasks.watch(task),
53
56
  webSocket: options.webSocket,
54
57
  });
package/dist/index.d.ts CHANGED
@@ -20,11 +20,13 @@ export { ArtifactsAPI } from './api/artifacts';
20
20
  export { TeamsAPI, type MeResponse } from './api/teams';
21
21
  export { SecretsAPI } from './api/secrets';
22
22
  export { ApiKeysAPI } from './api/api-keys';
23
- export { IntegrationsAPI } from './api/integrations';
23
+ export { CredentialsAPI } from './api/credentials';
24
+ /** @deprecated renamed CredentialsAPI */
25
+ export { CredentialsAPI as IntegrationsAPI } from './api/credentials';
24
26
  export { SearchAPI } from './api/search';
25
27
  export { ProjectsAPI } from './api/projects';
26
28
  export { MCPServersAPI } from './api/mcp-servers';
27
- export { LiveSession } from './live/session';
29
+ export { LiveSession, accessUrl } from './live/session';
28
30
  export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, WebSocketLike, WebSocketConstructor } from './live/session';
29
31
  export { STREAM_FORMAT, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
30
32
  export type { JsonSchema, MediaType, PCMFormat, LiveField } from './live/schema';
@@ -56,7 +58,7 @@ import { ArtifactsAPI } from './api/artifacts';
56
58
  import { TeamsAPI } from './api/teams';
57
59
  import { SecretsAPI } from './api/secrets';
58
60
  import { ApiKeysAPI } from './api/api-keys';
59
- import { IntegrationsAPI } from './api/integrations';
61
+ import { CredentialsAPI } from './api/credentials';
60
62
  import { SearchAPI } from './api/search';
61
63
  import { ProjectsAPI } from './api/projects';
62
64
  import { MCPServersAPI } from './api/mcp-servers';
@@ -112,11 +114,13 @@ export declare class Inference {
112
114
  readonly teams: TeamsAPI;
113
115
  readonly secrets: SecretsAPI;
114
116
  readonly apiKeys: ApiKeysAPI;
115
- readonly integrations: IntegrationsAPI;
117
+ readonly credentials: CredentialsAPI;
116
118
  readonly search: SearchAPI;
117
119
  readonly projects: ProjectsAPI;
118
120
  readonly mcpServers: MCPServersAPI;
119
121
  readonly sockets: SocketsAPI;
122
+ /** @deprecated renamed `credentials` */
123
+ get integrations(): CredentialsAPI;
120
124
  constructor(config: InferenceConfig | HttpClientConfig);
121
125
  /** @internal */
122
126
  _request<T>(method: 'get' | 'post' | 'put' | 'delete', endpoint: string, options?: {
package/dist/index.js CHANGED
@@ -22,12 +22,14 @@ export { ArtifactsAPI } from './api/artifacts';
22
22
  export { TeamsAPI } from './api/teams';
23
23
  export { SecretsAPI } from './api/secrets';
24
24
  export { ApiKeysAPI } from './api/api-keys';
25
- export { IntegrationsAPI } from './api/integrations';
25
+ export { CredentialsAPI } from './api/credentials';
26
+ /** @deprecated renamed CredentialsAPI */
27
+ export { CredentialsAPI as IntegrationsAPI } from './api/credentials';
26
28
  export { SearchAPI } from './api/search';
27
29
  export { ProjectsAPI } from './api/projects';
28
30
  export { MCPServersAPI } from './api/mcp-servers';
29
31
  // Live: the socket of a stream task and the live fields of its schemas
30
- export { LiveSession } from './live/session';
32
+ export { LiveSession, accessUrl } from './live/session';
31
33
  export { STREAM_FORMAT, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
32
34
  // Tool Builder (fluent API)
33
35
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
@@ -58,7 +60,7 @@ import { ArtifactsAPI } from './api/artifacts';
58
60
  import { TeamsAPI } from './api/teams';
59
61
  import { SecretsAPI } from './api/secrets';
60
62
  import { ApiKeysAPI } from './api/api-keys';
61
- import { IntegrationsAPI } from './api/integrations';
63
+ import { CredentialsAPI } from './api/credentials';
62
64
  import { SearchAPI } from './api/search';
63
65
  import { ProjectsAPI } from './api/projects';
64
66
  import { MCPServersAPI } from './api/mcp-servers';
@@ -72,6 +74,10 @@ import { MCPServersAPI } from './api/mcp-servers';
72
74
  * ```
73
75
  */
74
76
  export class Inference {
77
+ /** @deprecated renamed `credentials` */
78
+ get integrations() {
79
+ return this.credentials;
80
+ }
75
81
  constructor(config) {
76
82
  // Handle both simple config and full HttpClientConfig
77
83
  this.http = new HttpClient({
@@ -101,7 +107,7 @@ export class Inference {
101
107
  this.teams = new TeamsAPI(this.http);
102
108
  this.secrets = new SecretsAPI(this.http);
103
109
  this.apiKeys = new ApiKeysAPI(this.http);
104
- this.integrations = new IntegrationsAPI(this.http);
110
+ this.credentials = new CredentialsAPI(this.http);
105
111
  this.search = new SearchAPI(this.http);
106
112
  this.projects = new ProjectsAPI(this.http);
107
113
  this.mcpServers = new MCPServersAPI(this.http);
@@ -46,7 +46,10 @@ export function pcmFormat(media) {
46
46
  return null;
47
47
  return { sampleRate, channels };
48
48
  }
49
- /** Resolves a `#/$defs/` reference against the root, recursively. */
49
+ /**
50
+ * Resolves a `#/$defs/` reference against the root, recursively. The result
51
+ * carries no top-level `$ref` (a validator ignores a `$ref`'s siblings).
52
+ */
50
53
  function deref(schema, root) {
51
54
  if (!schema.$ref || !root.$defs)
52
55
  return schema;
@@ -55,14 +58,17 @@ function deref(schema, root) {
55
58
  if (!target)
56
59
  return schema;
57
60
  // The reference's own fields (title, description) win over the target's.
58
- return { ...deref(target, root), ...schema };
61
+ const { $ref: _ref, ...own } = schema;
62
+ return { ...deref(target, root), ...own };
59
63
  }
60
64
  function itemAlternatives(items, root) {
61
65
  const resolved = deref(items, root);
62
66
  const options = (resolved.anyOf ?? resolved.oneOf);
63
- if (options?.length)
64
- return options.map((option) => deref(option, root));
65
- return [resolved];
67
+ const alternatives = options?.length ? options.map((option) => deref(option, root)) : [resolved];
68
+ // Each alternative must stand on its own (a form validates it without the
69
+ // root), and nested references (an enum field, a nested model) still point
70
+ // into the root's $defs, so they travel with it.
71
+ return root.$defs ? alternatives.map((alternative) => ({ ...alternative, $defs: root.$defs })) : alternatives;
66
72
  }
67
73
  /**
68
74
  * Splits a function schema into what a form renders (the ordinary
@@ -67,6 +67,11 @@ export interface LiveSessionOptions {
67
67
  /** The WebSocket to dial with; defaults to the runtime's global one. */
68
68
  webSocket?: WebSocketConstructor;
69
69
  }
70
+ /**
71
+ * Where to dial. A browser cannot set headers on a WebSocket, so the
72
+ * credential rides in the query, as the relay documents.
73
+ */
74
+ export declare function accessUrl(access: Pick<SocketAccess, 'url' | 'token'>): string;
70
75
  export declare class LiveSession {
71
76
  private ws;
72
77
  private current;
@@ -11,6 +11,14 @@ function globalWebSocket() {
11
11
  }
12
12
  return ctor;
13
13
  }
14
+ /**
15
+ * Where to dial. A browser cannot set headers on a WebSocket, so the
16
+ * credential rides in the query, as the relay documents.
17
+ */
18
+ export function accessUrl(access) {
19
+ const sep = access.url.includes('?') ? '&' : '?';
20
+ return `${access.url}${sep}access_token=${encodeURIComponent(access.token)}`;
21
+ }
14
22
  export class LiveSession {
15
23
  constructor(options) {
16
24
  this.ws = null;
@@ -37,9 +45,7 @@ export class LiveSession {
37
45
  connect() {
38
46
  this.setState('connecting');
39
47
  this.watchTask();
40
- // A browser cannot set headers on a WebSocket, so the credential rides in
41
- // the query, as the relay documents.
42
- const ws = new this.WebSocket(`${this.access.url}?access_token=${encodeURIComponent(this.access.token)}`);
48
+ const ws = new this.WebSocket(accessUrl(this.access));
43
49
  ws.binaryType = 'arraybuffer';
44
50
  this.ws = ws;
45
51
  ws.onopen = () => this.setState('waiting');
@@ -86,9 +86,16 @@ declare class HTTPToolBuilder extends ToolBuilder {
86
86
  private headerMap;
87
87
  constructor(name: string, url: string);
88
88
  method(m: string): this;
89
+ /**
90
+ * How the tool authenticates: `credential` sends a connected account's
91
+ * access token (pick the account with `credentialId`), `apiKey` / `bearer`
92
+ * send a vault secret.
93
+ */
89
94
  auth(config: {
90
- integration?: string;
91
- integrationId?: string;
95
+ credential?: string;
96
+ credentialId?: string;
97
+ /** @deprecated renamed `credential` */ integration?: string;
98
+ /** @deprecated renamed `credentialId` */ integrationId?: string;
92
99
  apiKey?: string;
93
100
  bearer?: string;
94
101
  header?: string;
@@ -109,11 +116,12 @@ export declare const httpTool: (name: string, url: string) => HTTPToolBuilder;
109
116
  /** Create a call tool — makes authenticated HTTP requests. Preferred name for httpTool. */
110
117
  export declare const callTool: (name: string, url: string) => HTTPToolBuilder;
111
118
  /** Create an MCP connector tool (calls a tool on a connected MCP server) */
112
- export declare const mcpTool: (name: string, integrationId: string, toolName: string) => MCPToolBuilder;
119
+ /** `credentialId` is the MCP credential the tool runs through. */
120
+ export declare const mcpTool: (name: string, credentialId: string, toolName: string) => MCPToolBuilder;
113
121
  declare class MCPToolBuilder extends ToolBuilder {
114
- private integrationId;
122
+ private credentialId;
115
123
  private toolName;
116
- constructor(name: string, integrationId: string, toolName: string);
124
+ constructor(name: string, credentialId: string, toolName: string);
117
125
  build(): AgentTool;
118
126
  }
119
127
  declare class InternalToolsBuilder {
@@ -128,6 +136,8 @@ declare class InternalToolsBuilder {
128
136
  finish(enabled?: boolean): this;
129
137
  /** Enable meta tools */
130
138
  meta(enabled?: boolean): this;
139
+ /** Enable remote tools (run commands on the user's connected remotes) */
140
+ remote(enabled?: boolean): this;
131
141
  /** Enable all internal tools */
132
142
  all(): this;
133
143
  /** Disable all internal tools */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tool Builder - Fluent API for defining agent tools
3
3
  */
4
- import { ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook, ToolTypeHTTP, ToolTypeMCP } from './types';
4
+ import { ToolAuthTypeAPIKey, ToolAuthTypeBearer, ToolAuthTypeCredential, ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook, ToolTypeHTTP, ToolTypeMCP } from './types';
5
5
  // =============================================================================
6
6
  // Schema Builders
7
7
  // =============================================================================
@@ -183,15 +183,21 @@ class HTTPToolBuilder extends ToolBuilder {
183
183
  this.httpMethod = m;
184
184
  return this;
185
185
  }
186
+ /**
187
+ * How the tool authenticates: `credential` sends a connected account's
188
+ * access token (pick the account with `credentialId`), `apiKey` / `bearer`
189
+ * send a vault secret.
190
+ */
186
191
  auth(config) {
187
- if (config.integration) {
188
- this.authConfig = { type: 'integration', provider: config.integration, integration_id: config.integrationId };
192
+ const provider = config.credential ?? config.integration;
193
+ if (provider) {
194
+ this.authConfig = { type: ToolAuthTypeCredential, provider, credential_id: config.credentialId ?? config.integrationId };
189
195
  }
190
196
  else if (config.apiKey) {
191
- this.authConfig = { type: 'api_key', secret: config.apiKey, header: config.header || 'X-API-Key' };
197
+ this.authConfig = { type: ToolAuthTypeAPIKey, secret: config.apiKey, header: config.header || 'X-API-Key' };
192
198
  }
193
199
  else if (config.bearer) {
194
- this.authConfig = { type: 'bearer', secret: config.bearer };
200
+ this.authConfig = { type: ToolAuthTypeBearer, secret: config.bearer };
195
201
  }
196
202
  return this;
197
203
  }
@@ -232,11 +238,12 @@ export const httpTool = (name, url) => new HTTPToolBuilder(name, url);
232
238
  /** Create a call tool — makes authenticated HTTP requests. Preferred name for httpTool. */
233
239
  export const callTool = (name, url) => new HTTPToolBuilder(name, url);
234
240
  /** Create an MCP connector tool (calls a tool on a connected MCP server) */
235
- export const mcpTool = (name, integrationId, toolName) => new MCPToolBuilder(name, integrationId, toolName);
241
+ /** `credentialId` is the MCP credential the tool runs through. */
242
+ export const mcpTool = (name, credentialId, toolName) => new MCPToolBuilder(name, credentialId, toolName);
236
243
  class MCPToolBuilder extends ToolBuilder {
237
- constructor(name, integrationId, toolName) {
244
+ constructor(name, credentialId, toolName) {
238
245
  super(name);
239
- this.integrationId = integrationId;
246
+ this.credentialId = credentialId;
240
247
  this.toolName = toolName;
241
248
  }
242
249
  build() {
@@ -246,7 +253,7 @@ class MCPToolBuilder extends ToolBuilder {
246
253
  description: this.desc,
247
254
  type: ToolTypeMCP,
248
255
  require_approval: this.approval || undefined,
249
- mcp: { integration_id: this.integrationId, tool_name: this.toolName },
256
+ mcp: { credential_id: this.credentialId, tool_name: this.toolName },
250
257
  };
251
258
  }
252
259
  }
@@ -282,6 +289,11 @@ class InternalToolsBuilder {
282
289
  this.config.meta = enabled;
283
290
  return this;
284
291
  }
292
+ /** Enable remote tools (run commands on the user's connected remotes) */
293
+ remote(enabled = true) {
294
+ this.config.remote = enabled;
295
+ return this;
296
+ }
285
297
  /** Enable all internal tools */
286
298
  all() {
287
299
  this.config.plan = true;
package/dist/types.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface InternalToolsConfig {
11
11
  meta?: boolean;
12
12
  artifact?: boolean;
13
13
  spawn?: boolean;
14
+ remote?: boolean;
14
15
  }
15
16
  /**
16
17
  * AgentTool represents a unified tool that can be used by an agent
@@ -99,12 +100,37 @@ export interface ClientToolConfig {
99
100
  input_schema?: any;
100
101
  output_schema?: any;
101
102
  }
103
+ /**
104
+ * ToolAuthType says how an HTTP tool authenticates.
105
+ */
106
+ export type ToolAuthType = string;
107
+ /**
108
+ * ToolAuthTypeNone sends no credentials (same as leaving type empty).
109
+ */
110
+ export declare const ToolAuthTypeNone: ToolAuthType;
111
+ /**
112
+ * ToolAuthTypeCredential sends a connected credential's access token.
113
+ */
114
+ export declare const ToolAuthTypeCredential: ToolAuthType;
115
+ /**
116
+ * ToolAuthTypeAPIKey sends a vault secret in a header.
117
+ */
118
+ export declare const ToolAuthTypeAPIKey: ToolAuthType;
119
+ /**
120
+ * ToolAuthTypeBearer sends a vault secret as a bearer token.
121
+ */
122
+ export declare const ToolAuthTypeBearer: ToolAuthType;
102
123
  /**
103
124
  * ToolAuthConfig declares how a tool authenticates.
104
125
  */
105
126
  export interface ToolAuthConfig {
106
- type: string;
127
+ type: ToolAuthType;
107
128
  provider?: string;
129
+ credential_id?: string;
130
+ /**
131
+ * Deprecated: the credential id used to be called integration_id. Read
132
+ * through CredentialRef(); never written.
133
+ */
108
134
  integration_id?: string;
109
135
  secret?: string;
110
136
  header?: string;
@@ -120,7 +146,12 @@ export interface HTTPToolConfig {
120
146
  output_schema?: any;
121
147
  }
122
148
  export interface MCPToolConfig {
123
- integration_id: string;
149
+ credential_id?: string;
150
+ /**
151
+ * Deprecated: the credential id used to be called integration_id. Read
152
+ * through CredentialRef(); never written.
153
+ */
154
+ integration_id?: string;
124
155
  tool_name: string;
125
156
  }
126
157
  export interface AppToolConfigDTO {
@@ -160,7 +191,7 @@ export interface HTTPToolConfigDTO {
160
191
  output_schema?: any;
161
192
  }
162
193
  export interface MCPToolConfigDTO {
163
- integration_id: string;
194
+ credential_id: string;
164
195
  tool_name: string;
165
196
  }
166
197
  /**
@@ -195,6 +226,15 @@ export interface AgentDTO extends BaseModelDTO, PermissionModelDTO, ProjectModel
195
226
  images: AgentImages;
196
227
  version_id: string;
197
228
  version?: AgentVersionDTO;
229
+ /**
230
+ * ProfileID is set when a harness profile on a remote thinks for this
231
+ * agent instead of our loop.
232
+ */
233
+ profile_id?: string;
234
+ /**
235
+ * RemoteID is the machine the agent's terminal tools run on by default.
236
+ */
237
+ remote_id?: string;
198
238
  }
199
239
  export interface AgentVersionDTO extends BaseModelDTO, PermissionModelDTO {
200
240
  description: string;
@@ -266,6 +306,12 @@ export interface AgentRunDTO extends BaseModelDTO, PermissionModelDTO {
266
306
  tool_invocation_id?: string;
267
307
  trigger_id?: string;
268
308
  metadata?: any;
309
+ /**
310
+ * ProfileID is the harness profile that thought for this run; nil when it
311
+ * was our own loop. RemoteID is the machine it ran on, if any.
312
+ */
313
+ profile_id?: string;
314
+ remote_id?: string;
269
315
  }
270
316
  export interface APIResponse<T extends any> {
271
317
  success: boolean;
@@ -392,7 +438,7 @@ export interface AppVersionInput {
392
438
  };
393
439
  kernel?: string;
394
440
  required_secrets?: SecretRequirement[];
395
- required_integrations?: CredentialRequirement[];
441
+ required_credentials?: CredentialRequirement[];
396
442
  resources?: AppResources;
397
443
  }
398
444
  /**
@@ -551,7 +597,7 @@ export interface CredentialCompleteOAuthRequest {
551
597
  code_verifier?: string;
552
598
  }
553
599
  export interface CredentialConnectResponse {
554
- integration?: CredentialDTO;
600
+ credential?: CredentialDTO;
555
601
  auth_url?: string;
556
602
  state?: string;
557
603
  code_verifier?: string;
@@ -808,15 +854,16 @@ export declare const ScopeSecretsRead: Scope;
808
854
  */
809
855
  export declare const ScopeSecretsWrite: Scope;
810
856
  /**
811
- * Action-level scopes for Integrations
857
+ * Action-level scopes for credentials (connected accounts, vaults,
858
+ * custom providers, MCP servers). Formerly integrations:read|write.
812
859
  */
813
- export declare const ScopeIntegrationsRead: Scope;
860
+ export declare const ScopeCredentialsRead: Scope;
814
861
  /**
815
862
  * API Key Scopes - hierarchical permission system.
816
863
  * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
817
864
  * Empty scopes = full access (for backwards compatibility with existing keys).
818
865
  */
819
- export declare const ScopeIntegrationsWrite: Scope;
866
+ export declare const ScopeCredentialsWrite: Scope;
820
867
  /**
821
868
  * Action-level scopes for Engines
822
869
  */
@@ -897,7 +944,7 @@ export declare const ScopeGroupProjects: ScopeGroup;
897
944
  export declare const ScopeGroupTeams: ScopeGroup;
898
945
  export declare const ScopeGroupBilling: ScopeGroup;
899
946
  export declare const ScopeGroupSecrets: ScopeGroup;
900
- export declare const ScopeGroupIntegrations: ScopeGroup;
947
+ export declare const ScopeGroupCredentials: ScopeGroup;
901
948
  export declare const ScopeGroupEngines: ScopeGroup;
902
949
  export declare const ScopeGroupApiKeys: ScopeGroup;
903
950
  export declare const ScopeGroupKnowledge: ScopeGroup;
@@ -1046,10 +1093,10 @@ export interface SecretRequirement {
1046
1093
  optional?: boolean;
1047
1094
  }
1048
1095
  /**
1049
- * CredentialRequirement defines an integration that an app requires.
1096
+ * CredentialRequirement defines a credential that an app requires.
1050
1097
  * Key is the provider slug (e.g. "bytedance", "google").
1051
- * Secrets lists the specific env var names to inject from this integration.
1052
- * Scopes lists OAuth scopes needed (for OAuth integrations).
1098
+ * Secrets lists the specific env var names to inject from this credential.
1099
+ * Scopes lists OAuth scopes needed (for OAuth credentials).
1053
1100
  */
1054
1101
  export interface CredentialRequirement {
1055
1102
  key: string;
@@ -1106,7 +1153,7 @@ export interface AppVersionDTO extends BaseModelDTO {
1106
1153
  };
1107
1154
  kernel: string;
1108
1155
  required_secrets?: SecretRequirement[];
1109
- required_integrations?: CredentialRequirement[];
1156
+ required_credentials?: CredentialRequirement[];
1110
1157
  resources: AppResources;
1111
1158
  checksum?: string;
1112
1159
  }
@@ -1633,6 +1680,15 @@ export interface ChatDTO extends BaseModelDTO, PermissionModelDTO {
1633
1680
  agent_data: ChatData;
1634
1681
  active_run?: AgentRunDTO;
1635
1682
  pending_interrupts?: InterruptDTO[];
1683
+ /**
1684
+ * HarnessSessionID is the harness's own session id when a remote profile
1685
+ * thinks for this chat; `claude --resume <id>` opens it on that machine.
1686
+ */
1687
+ harness_session_id?: string;
1688
+ /**
1689
+ * ForkedFromMessageID is the message this chat was branched at.
1690
+ */
1691
+ forked_from_message_id?: string;
1636
1692
  }
1637
1693
  /**
1638
1694
  * ChatMessageDTO for API responses
@@ -3058,9 +3114,9 @@ export interface CompletePaymentRequest {
3058
3114
  payment_id?: string;
3059
3115
  }
3060
3116
  /**
3061
- * UpdateIntegrationScopesRequest updates integration scopes.
3117
+ * UpdateCredentialScopesRequest adds OAuth scopes to a connected credential.
3062
3118
  */
3063
- export interface UpdateIntegrationScopesRequest {
3119
+ export interface UpdateCredentialScopesRequest {
3064
3120
  scopes: string[];
3065
3121
  }
3066
3122
  /**
@@ -3105,7 +3161,7 @@ export declare const RequirementTypeSecret: RequirementType;
3105
3161
  /**
3106
3162
  * Requirement error types
3107
3163
  */
3108
- export declare const RequirementTypeIntegration: RequirementType;
3164
+ export declare const RequirementTypeCredential: RequirementType;
3109
3165
  /**
3110
3166
  * Requirement error types
3111
3167
  */
@@ -3143,7 +3199,7 @@ export interface SetupAction {
3143
3199
  */
3144
3200
  export interface CheckRequirementsRequest {
3145
3201
  secrets?: SecretRequirement[];
3146
- integrations?: CredentialRequirement[];
3202
+ credentials?: CredentialRequirement[];
3147
3203
  }
3148
3204
  /**
3149
3205
  * CheckRequirementsResponse is the API response for checking requirements
@@ -4143,7 +4199,7 @@ export declare const GraphNodeTypeApproval: GraphNodeType;
4143
4199
  export declare const GraphNodeTypeConditional: GraphNodeType;
4144
4200
  export declare const GraphNodeTypeFlowNode: GraphNodeType;
4145
4201
  export declare const GraphNodeTypeTrigger: GraphNodeType;
4146
- export declare const GraphNodeTypeIntegrationRequirement: GraphNodeType;
4202
+ export declare const GraphNodeTypeCredentialRequirement: GraphNodeType;
4147
4203
  /**
4148
4204
  * GraphNodeStatus represents the status of a node
4149
4205
  */
package/dist/types.js CHANGED
@@ -1,4 +1,20 @@
1
1
  // Code generated by gotypegen. DO NOT EDIT.
2
+ /**
3
+ * ToolAuthTypeNone sends no credentials (same as leaving type empty).
4
+ */
5
+ export const ToolAuthTypeNone = "none";
6
+ /**
7
+ * ToolAuthTypeCredential sends a connected credential's access token.
8
+ */
9
+ export const ToolAuthTypeCredential = "credential";
10
+ /**
11
+ * ToolAuthTypeAPIKey sends a vault secret in a header.
12
+ */
13
+ export const ToolAuthTypeAPIKey = "api_key";
14
+ /**
15
+ * ToolAuthTypeBearer sends a vault secret as a bearer token.
16
+ */
17
+ export const ToolAuthTypeBearer = "bearer";
2
18
  /**
3
19
  * API Key Scopes - hierarchical permission system.
4
20
  * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
@@ -182,15 +198,16 @@ export const ScopeSecretsRead = "secrets:read";
182
198
  */
183
199
  export const ScopeSecretsWrite = "secrets:write";
184
200
  /**
185
- * Action-level scopes for Integrations
201
+ * Action-level scopes for credentials (connected accounts, vaults,
202
+ * custom providers, MCP servers). Formerly integrations:read|write.
186
203
  */
187
- export const ScopeIntegrationsRead = "integrations:read";
204
+ export const ScopeCredentialsRead = "credentials:read";
188
205
  /**
189
206
  * API Key Scopes - hierarchical permission system.
190
207
  * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
191
208
  * Empty scopes = full access (for backwards compatibility with existing keys).
192
209
  */
193
- export const ScopeIntegrationsWrite = "integrations:write";
210
+ export const ScopeCredentialsWrite = "credentials:write";
194
211
  /**
195
212
  * Action-level scopes for Engines
196
213
  */
@@ -267,7 +284,7 @@ export const ScopeGroupProjects = "projects";
267
284
  export const ScopeGroupTeams = "teams";
268
285
  export const ScopeGroupBilling = "billing";
269
286
  export const ScopeGroupSecrets = "secrets";
270
- export const ScopeGroupIntegrations = "integrations";
287
+ export const ScopeGroupCredentials = "credentials";
271
288
  export const ScopeGroupEngines = "engines";
272
289
  export const ScopeGroupApiKeys = "apikeys";
273
290
  export const ScopeGroupKnowledge = "knowledge";
@@ -383,7 +400,7 @@ export const RequirementTypeSecret = "secret";
383
400
  /**
384
401
  * Requirement error types
385
402
  */
386
- export const RequirementTypeIntegration = "integration";
403
+ export const RequirementTypeCredential = "credential";
387
404
  /**
388
405
  * Requirement error types
389
406
  */
@@ -537,7 +554,7 @@ export const GraphNodeTypeApproval = "approval";
537
554
  export const GraphNodeTypeConditional = "conditional";
538
555
  export const GraphNodeTypeFlowNode = "flow_node";
539
556
  export const GraphNodeTypeTrigger = "trigger";
540
- export const GraphNodeTypeIntegrationRequirement = "integration_requirement";
557
+ export const GraphNodeTypeCredentialRequirement = "credential_requirement";
541
558
  export const GraphNodeStatusPending = "pending";
542
559
  export const GraphNodeStatusReady = "ready";
543
560
  export const GraphNodeStatusRunning = "running";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.6.54",
3
+ "version": "0.7.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",