@inferencesh/sdk 0.5.16 → 0.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tool-builder.d.ts +19 -0
- package/dist/tool-builder.js +47 -1
- package/dist/types.d.ts +124 -11
- package/dist/types.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
official javascript/typescript sdk for [inference.sh](https://inference.sh) — the ai agent runtime for serverless ai inference.
|
|
9
9
|
|
|
10
|
-
run ai models, build ai agents, and deploy generative ai applications with a simple api. access
|
|
10
|
+
run ai models, build ai agents, and deploy generative ai applications with a simple api. access 250+ models including flux, stable diffusion, llms (claude, gpt, gemini), video generation (veo, seedance), and more.
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
@@ -408,7 +408,7 @@ import type { Task, ApiTaskRequest, RunOptions } from '@inferencesh/sdk';
|
|
|
408
408
|
|
|
409
409
|
- [documentation](https://inference.sh/docs) — getting started guides and api reference
|
|
410
410
|
- [blog](https://inference.sh/blog) — tutorials on ai agents, image generation, and more
|
|
411
|
-
- [app store](https://app.inference.sh) — browse
|
|
411
|
+
- [app store](https://app.inference.sh) — browse 250+ ai models
|
|
412
412
|
- [discord](https://discord.gg/RM77SWSbyT) — community support
|
|
413
413
|
- [github](https://github.com/inference-sh) — open source projects
|
|
414
414
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { ChatsAPI } from './api/chats';
|
|
|
12
12
|
export { FlowsAPI } from './api/flows';
|
|
13
13
|
export { FlowRunsAPI } from './api/flow-runs';
|
|
14
14
|
export { EnginesAPI } from './api/engines';
|
|
15
|
-
export { tool, appTool, agentTool, webhookTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
15
|
+
export { tool, appTool, agentTool, webhookTool, httpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
16
16
|
export type { ClientTool, ClientToolHandler } from './tool-builder';
|
|
17
17
|
export { parseStatus, isTerminalStatus } from './utils';
|
|
18
18
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export { FlowsAPI } from './api/flows';
|
|
|
17
17
|
export { FlowRunsAPI } from './api/flow-runs';
|
|
18
18
|
export { EnginesAPI } from './api/engines';
|
|
19
19
|
// Tool Builder (fluent API)
|
|
20
|
-
export { tool, appTool, agentTool, webhookTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
20
|
+
export { tool, appTool, agentTool, webhookTool, httpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
21
21
|
// Status utilities (handle both int and string status values)
|
|
22
22
|
export { parseStatus, isTerminalStatus } from './utils';
|
|
23
23
|
// Types - includes TaskStatus constants and all DTOs
|
package/dist/tool-builder.d.ts
CHANGED
|
@@ -79,6 +79,23 @@ declare class WebhookToolBuilder extends ToolBuilder {
|
|
|
79
79
|
secret(key: string): this;
|
|
80
80
|
build(): AgentTool;
|
|
81
81
|
}
|
|
82
|
+
declare class HTTPToolBuilder extends ToolBuilder {
|
|
83
|
+
private url;
|
|
84
|
+
private httpMethod;
|
|
85
|
+
private authConfig?;
|
|
86
|
+
private headerMap;
|
|
87
|
+
constructor(name: string, url: string);
|
|
88
|
+
method(m: string): this;
|
|
89
|
+
auth(config: {
|
|
90
|
+
integration?: string;
|
|
91
|
+
integrationId?: string;
|
|
92
|
+
apiKey?: string;
|
|
93
|
+
bearer?: string;
|
|
94
|
+
header?: string;
|
|
95
|
+
}): this;
|
|
96
|
+
header(name: string, value: string): this;
|
|
97
|
+
build(): AgentTool;
|
|
98
|
+
}
|
|
82
99
|
/** Create a client tool (executed by SDK consumer) */
|
|
83
100
|
export declare const tool: (name: string) => ClientToolBuilder;
|
|
84
101
|
/** Create an app tool (runs another inference app) */
|
|
@@ -87,6 +104,8 @@ export declare const appTool: (name: string, appRef: string) => AppToolBuilder;
|
|
|
87
104
|
export declare const agentTool: (name: string, agentRef: string) => AgentToolBuilder;
|
|
88
105
|
/** Create a webhook tool (calls external URL) */
|
|
89
106
|
export declare const webhookTool: (name: string, url: string) => WebhookToolBuilder;
|
|
107
|
+
/** Create an HTTP tool with credential injection (replaces webhookTool for new code) */
|
|
108
|
+
export declare const httpTool: (name: string, url: string) => HTTPToolBuilder;
|
|
90
109
|
declare class InternalToolsBuilder {
|
|
91
110
|
private config;
|
|
92
111
|
/** Enable plan tools (Create, Update, Load) */
|
package/dist/tool-builder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool Builder - Fluent API for defining agent tools
|
|
3
3
|
*/
|
|
4
|
-
import { ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook } from './types';
|
|
4
|
+
import { ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook, ToolTypeHTTP } from './types';
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// Schema Builders
|
|
7
7
|
// =============================================================================
|
|
@@ -172,6 +172,50 @@ class WebhookToolBuilder extends ToolBuilder {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
class HTTPToolBuilder extends ToolBuilder {
|
|
176
|
+
constructor(name, url) {
|
|
177
|
+
super(name);
|
|
178
|
+
this.httpMethod = 'POST';
|
|
179
|
+
this.headerMap = {};
|
|
180
|
+
this.url = url;
|
|
181
|
+
}
|
|
182
|
+
method(m) {
|
|
183
|
+
this.httpMethod = m;
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
auth(config) {
|
|
187
|
+
if (config.integration) {
|
|
188
|
+
this.authConfig = { type: 'integration', provider: config.integration, integration_id: config.integrationId };
|
|
189
|
+
}
|
|
190
|
+
else if (config.apiKey) {
|
|
191
|
+
this.authConfig = { type: 'api_key', secret: config.apiKey, header: config.header || 'X-API-Key' };
|
|
192
|
+
}
|
|
193
|
+
else if (config.bearer) {
|
|
194
|
+
this.authConfig = { type: 'bearer', secret: config.bearer };
|
|
195
|
+
}
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
header(name, value) {
|
|
199
|
+
this.headerMap[name] = value;
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
build() {
|
|
203
|
+
return {
|
|
204
|
+
name: this.name,
|
|
205
|
+
display_name: this.displayNameValue || this.name,
|
|
206
|
+
description: this.desc,
|
|
207
|
+
type: ToolTypeHTTP,
|
|
208
|
+
require_approval: this.approval || undefined,
|
|
209
|
+
http: {
|
|
210
|
+
url: this.url,
|
|
211
|
+
method: this.httpMethod !== 'POST' ? this.httpMethod : undefined,
|
|
212
|
+
auth: this.authConfig,
|
|
213
|
+
headers: Object.keys(this.headerMap).length ? this.headerMap : undefined,
|
|
214
|
+
input_schema: toJsonSchema(this.params),
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
175
219
|
// =============================================================================
|
|
176
220
|
// Public API
|
|
177
221
|
// =============================================================================
|
|
@@ -183,6 +227,8 @@ export const appTool = (name, appRef) => new AppToolBuilder(name, appRef);
|
|
|
183
227
|
export const agentTool = (name, agentRef) => new AgentToolBuilder(name, agentRef);
|
|
184
228
|
/** Create a webhook tool (calls external URL) */
|
|
185
229
|
export const webhookTool = (name, url) => new WebhookToolBuilder(name, url);
|
|
230
|
+
/** Create an HTTP tool with credential injection (replaces webhookTool for new code) */
|
|
231
|
+
export const httpTool = (name, url) => new HTTPToolBuilder(name, url);
|
|
186
232
|
// =============================================================================
|
|
187
233
|
// Internal Tools Builder
|
|
188
234
|
// =============================================================================
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type ToolType = string;
|
|
|
16
16
|
export declare const ToolTypeApp: ToolType;
|
|
17
17
|
export declare const ToolTypeAgent: ToolType;
|
|
18
18
|
export declare const ToolTypeHook: ToolType;
|
|
19
|
+
export declare const ToolTypeHTTP: ToolType;
|
|
20
|
+
export declare const ToolTypeMCP: ToolType;
|
|
19
21
|
export declare const ToolTypeClient: ToolType;
|
|
20
22
|
export declare const ToolTypeInternal: ToolType;
|
|
21
23
|
/**
|
|
@@ -86,6 +88,57 @@ export interface ClientToolConfig {
|
|
|
86
88
|
input_schema?: any;
|
|
87
89
|
output_schema?: any;
|
|
88
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* ToolAuthConfig declares how a tool authenticates. Resolved at runtime — never contains actual credentials.
|
|
93
|
+
*/
|
|
94
|
+
export interface ToolAuthConfig {
|
|
95
|
+
/**
|
|
96
|
+
* Type: "integration", "api_key", "bearer", "none"
|
|
97
|
+
*/
|
|
98
|
+
type: string;
|
|
99
|
+
/**
|
|
100
|
+
* For type=integration: which provider to look up (e.g. "google", "mcp", "slack")
|
|
101
|
+
*/
|
|
102
|
+
provider?: string;
|
|
103
|
+
/**
|
|
104
|
+
* For type=integration: specific integration ID (optional — if empty, uses team's primary for provider)
|
|
105
|
+
*/
|
|
106
|
+
integration_id?: string;
|
|
107
|
+
/**
|
|
108
|
+
* For type=api_key or bearer: name of the secret in the team's secret store
|
|
109
|
+
*/
|
|
110
|
+
secret?: string;
|
|
111
|
+
/**
|
|
112
|
+
* For type=api_key: which header to inject (default: "X-API-Key")
|
|
113
|
+
*/
|
|
114
|
+
header?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* HTTPToolConfig contains configuration for an authenticated HTTP tool
|
|
118
|
+
*/
|
|
119
|
+
export interface HTTPToolConfig {
|
|
120
|
+
url: string;
|
|
121
|
+
method?: string;
|
|
122
|
+
auth?: ToolAuthConfig;
|
|
123
|
+
headers?: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
};
|
|
126
|
+
input_schema?: any;
|
|
127
|
+
output_schema?: any;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* MCPToolConfig contains configuration for a remote MCP server tool
|
|
131
|
+
*/
|
|
132
|
+
export interface MCPToolConfig {
|
|
133
|
+
/**
|
|
134
|
+
* IntegrationID references the MCP integration (has server_url, tokens, cached tools)
|
|
135
|
+
*/
|
|
136
|
+
integration_id: string;
|
|
137
|
+
/**
|
|
138
|
+
* ToolName is the tool name on the remote MCP server
|
|
139
|
+
*/
|
|
140
|
+
tool_name: string;
|
|
141
|
+
}
|
|
89
142
|
/**
|
|
90
143
|
* AgentTool represents a unified tool that can be used by an agent
|
|
91
144
|
*/
|
|
@@ -104,6 +157,8 @@ export interface AgentTool {
|
|
|
104
157
|
app?: AppToolConfig;
|
|
105
158
|
agent?: AgentToolConfig;
|
|
106
159
|
hook?: HookToolConfig;
|
|
160
|
+
http?: HTTPToolConfig;
|
|
161
|
+
mcp?: MCPToolConfig;
|
|
107
162
|
client?: ClientToolConfig;
|
|
108
163
|
internal?: InternalToolConfig;
|
|
109
164
|
}
|
|
@@ -129,6 +184,8 @@ export interface AgentToolDTO {
|
|
|
129
184
|
app?: AppToolConfigDTO;
|
|
130
185
|
agent?: AgentToolConfigDTO;
|
|
131
186
|
hook?: HookToolConfigDTO;
|
|
187
|
+
http?: HTTPToolConfigDTO;
|
|
188
|
+
mcp?: MCPToolConfigDTO;
|
|
132
189
|
client?: ClientToolConfigDTO;
|
|
133
190
|
}
|
|
134
191
|
export interface AppToolConfigDTO {
|
|
@@ -166,6 +223,20 @@ export interface ClientToolConfigDTO {
|
|
|
166
223
|
input_schema?: any;
|
|
167
224
|
output_schema?: any;
|
|
168
225
|
}
|
|
226
|
+
export interface HTTPToolConfigDTO {
|
|
227
|
+
url: string;
|
|
228
|
+
method?: string;
|
|
229
|
+
auth?: ToolAuthConfig;
|
|
230
|
+
headers?: {
|
|
231
|
+
[key: string]: string;
|
|
232
|
+
};
|
|
233
|
+
input_schema?: any;
|
|
234
|
+
output_schema?: any;
|
|
235
|
+
}
|
|
236
|
+
export interface MCPToolConfigDTO {
|
|
237
|
+
integration_id: string;
|
|
238
|
+
tool_name: string;
|
|
239
|
+
}
|
|
169
240
|
/**
|
|
170
241
|
* CoreAppConfig references an app used as the agent's core
|
|
171
242
|
*/
|
|
@@ -375,6 +446,10 @@ export interface ApiAppRunRequest {
|
|
|
375
446
|
* Task stays queued until this time. Past timestamps run immediately.
|
|
376
447
|
*/
|
|
377
448
|
run_at?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Optional metadata (e.g., action to trigger on completion)
|
|
451
|
+
*/
|
|
452
|
+
metadata?: TaskMetadata;
|
|
378
453
|
}
|
|
379
454
|
/**
|
|
380
455
|
* ApiAgentRunRequest is the request body for /agents/run endpoint.
|
|
@@ -592,6 +667,16 @@ export interface CheckoutCompleteRequest {
|
|
|
592
667
|
*/
|
|
593
668
|
export type StripeCheckoutCreateRequest = CheckoutCreateRequest;
|
|
594
669
|
export type StripeCheckoutCompleteRequest = CheckoutCompleteRequest;
|
|
670
|
+
/**
|
|
671
|
+
* AuthResponse is returned after successful authentication (OAuth, magic link, SSO)
|
|
672
|
+
*/
|
|
673
|
+
export interface AuthResponse {
|
|
674
|
+
user?: UserDTO;
|
|
675
|
+
session_id: string;
|
|
676
|
+
otp_required?: boolean;
|
|
677
|
+
redirect_to?: string;
|
|
678
|
+
provider?: string;
|
|
679
|
+
}
|
|
595
680
|
/**
|
|
596
681
|
* DeviceAuthResponse is returned when a device initiates auth
|
|
597
682
|
*/
|
|
@@ -740,8 +825,13 @@ export interface MoveAgentToProjectRequest {
|
|
|
740
825
|
agent_id: string;
|
|
741
826
|
project_id: string;
|
|
742
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* WorkerGPUConfig holds GPU identifiers for a worker.
|
|
830
|
+
* GPUs accepts both integer indexes (legacy) and string GPU IDs.
|
|
831
|
+
* Use GPUIndexes() and GPUIDs() to separate them after unmarshaling.
|
|
832
|
+
*/
|
|
743
833
|
export interface WorkerGPUConfig {
|
|
744
|
-
gpus:
|
|
834
|
+
gpus: any[];
|
|
745
835
|
}
|
|
746
836
|
export interface WorkerCPUConfig {
|
|
747
837
|
count: number;
|
|
@@ -1465,6 +1555,10 @@ export interface FlowVersion extends BaseModel {
|
|
|
1465
1555
|
* ConfigHash for deduplication - SHA256 of config content
|
|
1466
1556
|
*/
|
|
1467
1557
|
config_hash: string;
|
|
1558
|
+
/**
|
|
1559
|
+
* GraphVersion is an incrementing counter for optimistic locking on action-based edits
|
|
1560
|
+
*/
|
|
1561
|
+
graph_version: number;
|
|
1468
1562
|
/**
|
|
1469
1563
|
* Flow graph configuration
|
|
1470
1564
|
*/
|
|
@@ -1557,6 +1651,7 @@ export interface FlowDTO extends BaseModel, PermissionModelDTO {
|
|
|
1557
1651
|
viewport?: FlowViewport;
|
|
1558
1652
|
}
|
|
1559
1653
|
export interface FlowVersionDTO extends BaseModel {
|
|
1654
|
+
graph_version: number;
|
|
1560
1655
|
input_schema: any;
|
|
1561
1656
|
input: FlowRunInputs;
|
|
1562
1657
|
output_schema: any;
|
|
@@ -1693,6 +1788,7 @@ export type StringSlice = string[];
|
|
|
1693
1788
|
export interface IntegrationDTO extends BaseModel, PermissionModelDTO {
|
|
1694
1789
|
provider: string;
|
|
1695
1790
|
type: string;
|
|
1791
|
+
auth: string;
|
|
1696
1792
|
status: string;
|
|
1697
1793
|
display_name: string;
|
|
1698
1794
|
scopes: StringSlice;
|
|
@@ -1706,6 +1802,17 @@ export interface IntegrationDTO extends BaseModel, PermissionModelDTO {
|
|
|
1706
1802
|
is_primary: boolean;
|
|
1707
1803
|
error_message?: string;
|
|
1708
1804
|
}
|
|
1805
|
+
/**
|
|
1806
|
+
* KnowledgeFile represents a file in a knowledge entry (stored as JSONB in knowledge_versions)
|
|
1807
|
+
*/
|
|
1808
|
+
export interface KnowledgeFile {
|
|
1809
|
+
path: string;
|
|
1810
|
+
uri?: string;
|
|
1811
|
+
size: number;
|
|
1812
|
+
hash: string;
|
|
1813
|
+
content?: string;
|
|
1814
|
+
}
|
|
1815
|
+
export type SkillFile = KnowledgeFile;
|
|
1709
1816
|
/**
|
|
1710
1817
|
* ProjectType represents different types of projects
|
|
1711
1818
|
*/
|
|
@@ -1906,16 +2013,6 @@ export interface InstanceEnvVar {
|
|
|
1906
2013
|
name: string;
|
|
1907
2014
|
value: string;
|
|
1908
2015
|
}
|
|
1909
|
-
/**
|
|
1910
|
-
* SkillFile represents a file in the skill directory (stored as JSONB in skill_versions)
|
|
1911
|
-
*/
|
|
1912
|
-
export interface SkillFile {
|
|
1913
|
-
path: string;
|
|
1914
|
-
uri?: string;
|
|
1915
|
-
size: number;
|
|
1916
|
-
hash: string;
|
|
1917
|
-
content?: string;
|
|
1918
|
-
}
|
|
1919
2016
|
/**
|
|
1920
2017
|
* Hardware/System related types
|
|
1921
2018
|
*/
|
|
@@ -2057,6 +2154,21 @@ export type Infra = string;
|
|
|
2057
2154
|
export declare const InfraPrivate: Infra;
|
|
2058
2155
|
export declare const InfraCloud: Infra;
|
|
2059
2156
|
export declare const InfraPrivateFirst: Infra;
|
|
2157
|
+
/**
|
|
2158
|
+
* TaskAction defines an action to execute when a task reaches a specific status.
|
|
2159
|
+
* Used by the action projector to trigger side effects (e.g., updating app covers).
|
|
2160
|
+
*/
|
|
2161
|
+
export interface TaskAction {
|
|
2162
|
+
key: string;
|
|
2163
|
+
on: string;
|
|
2164
|
+
params?: any;
|
|
2165
|
+
}
|
|
2166
|
+
/**
|
|
2167
|
+
* TaskMetadata holds optional metadata attached to a task.
|
|
2168
|
+
*/
|
|
2169
|
+
export interface TaskMetadata {
|
|
2170
|
+
action?: TaskAction;
|
|
2171
|
+
}
|
|
2060
2172
|
export interface Task extends BaseModel, PermissionModel {
|
|
2061
2173
|
is_featured: boolean;
|
|
2062
2174
|
status: TaskStatus;
|
|
@@ -2093,6 +2205,7 @@ export interface Task extends BaseModel, PermissionModel {
|
|
|
2093
2205
|
*/
|
|
2094
2206
|
sub_flow_run_id?: string;
|
|
2095
2207
|
webhook?: string;
|
|
2208
|
+
metadata?: TaskMetadata;
|
|
2096
2209
|
setup?: any;
|
|
2097
2210
|
input: any;
|
|
2098
2211
|
output: any;
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// Code generated by
|
|
1
|
+
// Code generated by gotypegen. DO NOT EDIT.
|
|
2
2
|
export const ToolTypeApp = "app"; // App tools - creates a Task
|
|
3
3
|
export const ToolTypeAgent = "agent"; // Sub-agent tools - creates a sub-Chat
|
|
4
|
-
export const ToolTypeHook = "hook"; // Webhook tools - HTTP POST to external URL
|
|
4
|
+
export const ToolTypeHook = "hook"; // Webhook tools - HTTP POST to external URL (legacy)
|
|
5
|
+
export const ToolTypeHTTP = "http"; // HTTP tools - authenticated HTTP request/response
|
|
6
|
+
export const ToolTypeMCP = "mcp"; // MCP tools - calls remote MCP server
|
|
5
7
|
export const ToolTypeClient = "client"; // Client tools - executed by frontend
|
|
6
8
|
export const ToolTypeInternal = "internal"; // Internal/built-in tools (plan, memory, widget, finish)
|
|
7
9
|
export const ScopeGroupAgents = "agents";
|