@inferencesh/sdk 0.4.26 → 0.5.1

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/types.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface InternalToolsConfig {
6
6
  memory?: boolean;
7
7
  widget?: boolean;
8
8
  finish?: boolean;
9
+ skills?: boolean;
9
10
  }
10
11
  /**
11
12
  * ToolType represents the type of tool (used in both AgentTool definition and ToolInvocation)
@@ -34,6 +35,15 @@ export interface AppToolConfig {
34
35
  * Resolved app object (populated at runtime)
35
36
  */
36
37
  app?: App;
38
+ /**
39
+ * Function to call on multi-function apps (empty = app's default function)
40
+ */
41
+ function?: string;
42
+ /**
43
+ * SessionEnabled allows the agent to control sessions for this tool
44
+ * When true, agent can pass session parameter and sees session_id in output
45
+ */
46
+ session_enabled?: boolean;
37
47
  /**
38
48
  * Pre-configured values
39
49
  */
@@ -125,6 +135,14 @@ export interface AppToolConfigDTO {
125
135
  id?: string;
126
136
  version_id?: string;
127
137
  app?: AppDTO;
138
+ /**
139
+ * Function to call on multi-function apps
140
+ */
141
+ function?: string;
142
+ /**
143
+ * SessionEnabled allows the agent to control sessions for this tool
144
+ */
145
+ session_enabled?: boolean;
128
146
  /**
129
147
  * Pre-configured values
130
148
  */
@@ -174,9 +192,7 @@ export interface AgentImages {
174
192
  thumbnail: string;
175
193
  banner: string;
176
194
  }
177
- export interface Agent {
178
- BaseModel: BaseModel;
179
- PermissionModel: PermissionModel;
195
+ export interface Agent extends BaseModel, PermissionModel {
180
196
  ProjectModel: ProjectModel;
181
197
  /**
182
198
  * Basic info
@@ -203,6 +219,16 @@ export interface AgentDTO extends BaseModel, PermissionModelDTO, ProjectModelDTO
203
219
  version_id: string;
204
220
  version?: AgentVersionDTO;
205
221
  }
222
+ /**
223
+ * SkillConfig defines a skill available to the agent.
224
+ * Skills are loaded on-demand via the skill_get internal tool.
225
+ */
226
+ export interface SkillConfig {
227
+ name: string;
228
+ description: string;
229
+ url?: string;
230
+ content?: string;
231
+ }
206
232
  /**
207
233
  * AgentConfig contains the shared configuration fields for agent execution.
208
234
  * This is embedded by both AgentVersion (DB model) and API request structs.
@@ -221,7 +247,11 @@ export interface AgentConfig {
221
247
  */
222
248
  tools?: (AgentTool | undefined)[];
223
249
  /**
224
- * Internal tools configuration (plan, memory, widget, finish)
250
+ * Skills available to this agent (loaded on-demand via skill_get tool)
251
+ */
252
+ skills?: SkillConfig[];
253
+ /**
254
+ * Internal tools configuration (plan, memory, widget, finish, skills)
225
255
  */
226
256
  internal_tools?: InternalToolsConfig;
227
257
  /**
@@ -229,14 +259,8 @@ export interface AgentConfig {
229
259
  */
230
260
  output_schema?: any;
231
261
  }
232
- export interface AgentVersion {
233
- BaseModel: BaseModel;
234
- PermissionModel: PermissionModel;
262
+ export interface AgentVersion extends BaseModel, PermissionModel {
235
263
  agent_id: string;
236
- /**
237
- * Short ID for human-readable version references (e.g., "abc123")
238
- */
239
- short_id: string;
240
264
  /**
241
265
  * ConfigHash for deduplication - SHA256 of config content
242
266
  */
@@ -266,7 +290,11 @@ export interface AgentVersionDTO extends BaseModel, PermissionModelDTO {
266
290
  */
267
291
  tools: (AgentToolDTO | undefined)[];
268
292
  /**
269
- * Internal tools configuration (plan, memory, widget, finish)
293
+ * Skills available to this agent (loaded on-demand via skill_get tool)
294
+ */
295
+ skills: SkillConfig[];
296
+ /**
297
+ * Internal tools configuration (plan, memory, widget, finish, skills)
270
298
  */
271
299
  internal_tools?: InternalToolsConfig;
272
300
  /**
@@ -315,6 +343,19 @@ export interface ApiAppRunRequest {
315
343
  * If true, returns SSE stream instead of JSON response
316
344
  */
317
345
  stream?: boolean;
346
+ /**
347
+ * Function to call on multi-function apps (defaults to "run" or app's default_function)
348
+ */
349
+ function?: string;
350
+ /**
351
+ * Session control: "new" to start a new session, "sess_xxx" to continue existing session
352
+ * When using sessions, the worker is leased and state persists across calls
353
+ */
354
+ session?: string;
355
+ /**
356
+ * Session timeout in seconds (1-3600). Only valid when session="new"
357
+ */
358
+ session_timeout?: number;
318
359
  }
319
360
  /**
320
361
  * ApiAgentRunRequest is the request body for /agents/run endpoint.
@@ -665,9 +706,7 @@ export interface AppImages {
665
706
  thumbnail: string;
666
707
  banner: string;
667
708
  }
668
- export interface App {
669
- BaseModel: BaseModel;
670
- PermissionModel: PermissionModel;
709
+ export interface App extends BaseModel, PermissionModel {
671
710
  /**
672
711
  * Namespace is copied from team.username at creation time and is IMMUTABLE.
673
712
  * This ensures stable references like "namespace/name" even if team username changes.
@@ -722,13 +761,7 @@ export interface AppFunction {
722
761
  input_schema: any;
723
762
  output_schema: any;
724
763
  }
725
- export interface AppVersion {
726
- BaseModel: BaseModel;
727
- /**
728
- * ShortID is a human-friendly version identifier (e.g., "abc123")
729
- * Unique within the app, used in references like "namespace/app@abc123"
730
- */
731
- short_id: string;
764
+ export interface AppVersion extends BaseModel {
732
765
  app_id: string;
733
766
  metadata: {
734
767
  [key: string]: any;
@@ -766,6 +799,11 @@ export interface AppVersion {
766
799
  */
767
800
  checksum?: string;
768
801
  }
802
+ export interface LicenseRecord extends BaseModel {
803
+ user_id: string;
804
+ app_id: string;
805
+ license: string;
806
+ }
769
807
  export interface AppDTO extends BaseModel, PermissionModelDTO {
770
808
  namespace: string;
771
809
  name: string;
@@ -777,7 +815,6 @@ export interface AppDTO extends BaseModel, PermissionModelDTO {
777
815
  version?: AppVersionDTO;
778
816
  }
779
817
  export interface AppVersionDTO extends BaseModel {
780
- short_id: string;
781
818
  metadata: {
782
819
  [key: string]: any;
783
820
  };
@@ -809,8 +846,45 @@ export interface AppVersionDTO extends BaseModel {
809
846
  */
810
847
  checksum?: string;
811
848
  }
849
+ export type AppSessionStatus = string;
850
+ export declare const AppSessionStatusActive: AppSessionStatus;
851
+ export declare const AppSessionStatusEnded: AppSessionStatus;
852
+ export declare const AppSessionStatusExpired: AppSessionStatus;
853
+ export interface AppSession extends BaseModel, PermissionModel {
854
+ /**
855
+ * Affinity binding
856
+ */
857
+ worker_id: string;
858
+ app_id: string;
859
+ app_version_id: string;
860
+ /**
861
+ * Lifecycle
862
+ */
863
+ status: AppSessionStatus;
864
+ expires_at: string;
865
+ ended_at?: string;
866
+ /**
867
+ * Billing link
868
+ */
869
+ task_id?: string;
870
+ /**
871
+ * Stats
872
+ */
873
+ call_count: number;
874
+ last_call_at?: string;
875
+ /**
876
+ * Custom idle timeout in seconds (nil = use default)
877
+ */
878
+ idle_timeout?: number;
879
+ /**
880
+ * Relations
881
+ */
882
+ worker?: WorkerState;
883
+ task?: Task;
884
+ }
812
885
  export interface BaseModel {
813
886
  id: string;
887
+ short_id: string;
814
888
  created_at: string;
815
889
  updated_at: string;
816
890
  deleted_at?: string;
@@ -1071,6 +1145,17 @@ export declare const EngineStatusRunning: EngineStatus;
1071
1145
  export declare const EngineStatusPending: EngineStatus;
1072
1146
  export declare const EngineStatusStopping: EngineStatus;
1073
1147
  export declare const EngineStatusStopped: EngineStatus;
1148
+ export interface EngineState extends BaseModel, PermissionModel {
1149
+ instance?: Instance;
1150
+ transaction_id: string;
1151
+ config: EngineConfig;
1152
+ public_key: string;
1153
+ name: string;
1154
+ api_url: string;
1155
+ status: EngineStatus;
1156
+ system_info?: SystemInfo;
1157
+ workers: (WorkerState | undefined)[];
1158
+ }
1074
1159
  export interface EngineStateDTO extends BaseModel, PermissionModelDTO {
1075
1160
  instance?: Instance;
1076
1161
  config: EngineConfig;
@@ -1090,6 +1175,30 @@ export interface EngineStateSummary extends BaseModel, PermissionModelDTO {
1090
1175
  * Worker-related types
1091
1176
  */
1092
1177
  export type WorkerStatus = string;
1178
+ export interface WorkerState extends BaseModel, PermissionModel {
1179
+ index: number;
1180
+ status: WorkerStatus;
1181
+ status_updated_at?: string;
1182
+ engine_id: string;
1183
+ engine?: EngineState;
1184
+ task_id?: string;
1185
+ app_id: string;
1186
+ app_version_id: string;
1187
+ /**
1188
+ * App session lease
1189
+ */
1190
+ active_session_id?: string;
1191
+ active_session?: AppSession;
1192
+ gpus: WorkerGPU[];
1193
+ cpus: WorkerCPU[];
1194
+ rams: WorkerRAM[];
1195
+ /**
1196
+ * WarmApps tracks app+version combos with warm containers for scheduling optimization.
1197
+ * Format: "appID:versionID@setupHash" - managed by Engine, synced via heartbeat.
1198
+ * Not persisted to DB - this is ephemeral runtime state.
1199
+ */
1200
+ warm_apps?: string[];
1201
+ }
1093
1202
  export interface WorkerGPU {
1094
1203
  id: string;
1095
1204
  worker_id: string;
@@ -1122,10 +1231,12 @@ export interface WorkerStateDTO extends BaseModel {
1122
1231
  task_id?: string;
1123
1232
  app_id: string;
1124
1233
  app_version_id: string;
1234
+ active_session_id?: string;
1125
1235
  gpus: WorkerGPU[];
1126
1236
  cpus: WorkerCPU[];
1127
1237
  rams: WorkerRAM[];
1128
1238
  system_info: SystemInfo;
1239
+ warm_apps?: string[];
1129
1240
  }
1130
1241
  export interface WorkerStateSummary {
1131
1242
  id: string;
@@ -1137,13 +1248,12 @@ export interface WorkerStateSummary {
1137
1248
  task_id?: string;
1138
1249
  app_id: string;
1139
1250
  app_version_id: string;
1251
+ active_session_id?: string;
1140
1252
  gpus: WorkerGPU[];
1141
1253
  cpus: WorkerCPU[];
1142
1254
  rams: WorkerRAM[];
1143
1255
  }
1144
- export interface File {
1145
- BaseModel: BaseModel;
1146
- PermissionModel: PermissionModel;
1256
+ export interface File extends BaseModel, PermissionModel {
1147
1257
  path: string;
1148
1258
  remote_path: string;
1149
1259
  upload_url: string;
@@ -1163,8 +1273,7 @@ export interface FileDTO extends BaseModel, PermissionModelDTO {
1163
1273
  filename: string;
1164
1274
  rating: ContentRating;
1165
1275
  }
1166
- export interface FlowVersion {
1167
- BaseModel: BaseModel;
1276
+ export interface FlowVersion extends BaseModel {
1168
1277
  /**
1169
1278
  * Permission fields - nullable for migration from existing data
1170
1279
  * After migration these will be populated from parent Flow
@@ -1174,10 +1283,6 @@ export interface FlowVersion {
1174
1283
  team_id: string;
1175
1284
  team?: Team;
1176
1285
  flow_id: string;
1177
- /**
1178
- * Short ID for human-readable version references (e.g., "abc123")
1179
- */
1180
- short_id: string;
1181
1286
  /**
1182
1287
  * ConfigHash for deduplication - SHA256 of config content
1183
1288
  */
@@ -1274,7 +1379,6 @@ export interface FlowDTO extends BaseModel, PermissionModelDTO {
1274
1379
  viewport?: FlowViewport;
1275
1380
  }
1276
1381
  export interface FlowVersionDTO extends BaseModel {
1277
- short_id: string;
1278
1382
  input_schema: any;
1279
1383
  input: FlowRunInputs;
1280
1384
  output_schema: any;
@@ -1443,9 +1547,7 @@ export interface ProjectModelDTO {
1443
1547
  /**
1444
1548
  * Project represents a container for organizing related resources
1445
1549
  */
1446
- export interface Project {
1447
- BaseModel: BaseModel;
1448
- PermissionModel: PermissionModel;
1550
+ export interface Project extends BaseModel, PermissionModel {
1449
1551
  name: string;
1450
1552
  description: string;
1451
1553
  type: ProjectType;
@@ -1526,6 +1628,14 @@ export interface SetupAction {
1526
1628
  provider?: string;
1527
1629
  scopes?: string[];
1528
1630
  }
1631
+ /**
1632
+ * SecretRef tracks which Secret record provided a value for a task (for billing)
1633
+ */
1634
+ export interface SecretRef {
1635
+ key: string;
1636
+ id: string;
1637
+ team_id: string;
1638
+ }
1529
1639
  export type InstanceCloudProvider = string;
1530
1640
  export declare const CloudAWS: InstanceCloudProvider;
1531
1641
  export declare const CloudAzure: InstanceCloudProvider;
@@ -1544,9 +1654,7 @@ export type InstanceStatus = string;
1544
1654
  export declare const InstanceStatusPending: InstanceStatus;
1545
1655
  export declare const InstanceStatusActive: InstanceStatus;
1546
1656
  export declare const InstanceStatusDeleted: InstanceStatus;
1547
- export interface Instance {
1548
- BaseModel: BaseModel;
1549
- PermissionModel: PermissionModel;
1657
+ export interface Instance extends BaseModel, PermissionModel {
1550
1658
  cloud: InstanceCloudProvider;
1551
1659
  name: string;
1552
1660
  region: string;
@@ -1762,6 +1870,71 @@ export type Infra = string;
1762
1870
  export declare const InfraPrivate: Infra;
1763
1871
  export declare const InfraCloud: Infra;
1764
1872
  export declare const InfraPrivateFirst: Infra;
1873
+ export interface Task extends BaseModel, PermissionModel {
1874
+ is_featured: boolean;
1875
+ status: TaskStatus;
1876
+ /**
1877
+ * Foreign keys
1878
+ */
1879
+ app_id: string;
1880
+ app?: App;
1881
+ version_id: string;
1882
+ app_version?: AppVersion;
1883
+ /**
1884
+ * Deprecated: Will be removed in favor of Setup
1885
+ */
1886
+ variant: string;
1887
+ /**
1888
+ * Function is the specific function to call on multi-function apps.
1889
+ * DEPRECATED: Standardizing on explicit function name.
1890
+ * Defaults to "run" for legacy tasks (backfilled via migration).
1891
+ */
1892
+ function: string;
1893
+ infra: Infra;
1894
+ workers: string[];
1895
+ engine_id?: string;
1896
+ engine?: EngineState;
1897
+ worker_id?: string;
1898
+ worker?: WorkerState;
1899
+ /**
1900
+ * Belongs to:
1901
+ */
1902
+ flow_run_id?: string;
1903
+ chat_id?: string;
1904
+ /**
1905
+ * Owns: (Can be replaced with graph execution edge/node)
1906
+ */
1907
+ sub_flow_run_id?: string;
1908
+ webhook?: string;
1909
+ setup?: any;
1910
+ input: any;
1911
+ output: any;
1912
+ error: string;
1913
+ rating: ContentRating;
1914
+ /**
1915
+ * Relationships
1916
+ */
1917
+ events: TaskEvent[];
1918
+ logs: TaskLog[];
1919
+ telemetry: TimescaleTask[];
1920
+ usage_events: (UsageEvent | undefined)[];
1921
+ transaction_id?: string;
1922
+ transaction?: Transaction;
1923
+ /**
1924
+ * Secret refs for billing (tracks ownership to determine partner fee)
1925
+ */
1926
+ secrets?: SecretRef[];
1927
+ /**
1928
+ * App session reference (for session calls)
1929
+ * Special value "new" means scheduler should create session when dispatching.
1930
+ */
1931
+ session_id?: string;
1932
+ session?: AppSession;
1933
+ /**
1934
+ * Session timeout in seconds (only used when session="new")
1935
+ */
1936
+ session_timeout?: number;
1937
+ }
1765
1938
  export interface TaskEvent {
1766
1939
  id: string;
1767
1940
  created_at: string;
@@ -1819,6 +1992,8 @@ export interface TaskDTO extends BaseModel, PermissionModelDTO {
1819
1992
  usage_events: (UsageEvent | undefined)[];
1820
1993
  transaction_id?: string;
1821
1994
  transaction?: Transaction;
1995
+ session_id?: string;
1996
+ session_timeout?: number;
1822
1997
  }
1823
1998
  export interface TimescaleTask {
1824
1999
  id: string;
@@ -1836,8 +2011,7 @@ export type TeamType = string;
1836
2011
  export declare const TeamTypePersonal: TeamType;
1837
2012
  export declare const TeamTypeTeam: TeamType;
1838
2013
  export declare const TeamTypeSystem: TeamType;
1839
- export interface Team {
1840
- BaseModel: BaseModel;
2014
+ export interface Team extends BaseModel {
1841
2015
  type: TeamType;
1842
2016
  username: string;
1843
2017
  email: string;
@@ -1944,8 +2118,7 @@ export declare const TransactionTypeDebit: TransactionType;
1944
2118
  /**
1945
2119
  * Transaction represents a single credit transaction
1946
2120
  */
1947
- export interface Transaction {
1948
- BaseModel: BaseModel;
2121
+ export interface Transaction extends BaseModel {
1949
2122
  PermissionModel: PermissionModel;
1950
2123
  type: TransactionType;
1951
2124
  amount: number;
@@ -1975,9 +2148,7 @@ export declare const PaymentRecordTypeAutoRecharge: PaymentRecordType;
1975
2148
  /**
1976
2149
  * PaymentRecord stores Stripe payment details for both checkout sessions and direct charges
1977
2150
  */
1978
- export interface PaymentRecord {
1979
- BaseModel: BaseModel;
1980
- PermissionModel: PermissionModel;
2151
+ export interface PaymentRecord extends BaseModel, PermissionModel {
1981
2152
  type: PaymentRecordType;
1982
2153
  status: PaymentRecordStatus;
1983
2154
  amount: number;
@@ -2055,9 +2226,7 @@ export interface OutputMeta {
2055
2226
  inputs: MetaItem[];
2056
2227
  outputs: MetaItem[];
2057
2228
  }
2058
- export interface UsageEvent {
2059
- BaseModel: BaseModel;
2060
- PermissionModel: PermissionModel;
2229
+ export interface UsageEvent extends BaseModel, PermissionModel {
2061
2230
  usage_billing_record_id: string;
2062
2231
  reference_id: string;
2063
2232
  resource_id: string;
@@ -2070,9 +2239,7 @@ export interface UsageEvent {
2070
2239
  quantity: number;
2071
2240
  unit: string;
2072
2241
  }
2073
- export interface UsageBillingRecord {
2074
- BaseModel: BaseModel;
2075
- PermissionModel: PermissionModel;
2242
+ export interface UsageBillingRecord extends BaseModel, PermissionModel {
2076
2243
  /**
2077
2244
  * Fee breakdown (all in microcents)
2078
2245
  */
@@ -2104,9 +2271,7 @@ export interface UsageBillingRecord {
2104
2271
  partner_credit_transaction_id: string;
2105
2272
  partner_credit_transaction?: Transaction;
2106
2273
  }
2107
- export interface UsageBillingRefund {
2108
- BaseModel: BaseModel;
2109
- PermissionModel: PermissionModel;
2274
+ export interface UsageBillingRefund extends BaseModel, PermissionModel {
2110
2275
  usage_billing_record_id: string;
2111
2276
  usage_billing_record?: UsageBillingRecord;
2112
2277
  /**
package/dist/types.js CHANGED
@@ -18,6 +18,9 @@ export const GPUTypeIntel = "intel";
18
18
  export const GPUTypeNvidia = "nvidia";
19
19
  export const GPUTypeAMD = "amd";
20
20
  export const GPUTypeApple = "apple";
21
+ export const AppSessionStatusActive = "active";
22
+ export const AppSessionStatusEnded = "ended";
23
+ export const AppSessionStatusExpired = "expired";
21
24
  export const VisibilityPrivate = "private";
22
25
  export const VisibilityPublic = "public";
23
26
  export const VisibilityUnlisted = "unlisted";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.4.26",
3
+ "version": "0.5.1",
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",