@inferencesh/sdk 0.2.0 → 0.2.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/README.md CHANGED
@@ -218,7 +218,7 @@ await agent.sendMessage('What is the weather in Paris?', {
218
218
  | `sendMessage(text, options?)` | Send a message to the agent |
219
219
  | `getChat(chatId?)` | Get chat history |
220
220
  | `stopChat(chatId?)` | Stop current generation |
221
- | `submitToolResult(toolId, result)` | Submit result for a client tool |
221
+ | `submitToolResult(toolId, resultOrAction)` | Submit result for a client tool (string or {action, form_data}) |
222
222
  | `streamMessages(chatId?, options?)` | Stream message updates |
223
223
  | `streamChat(chatId?, options?)` | Stream chat updates |
224
224
  | `disconnect()` | Clean up streams |
package/dist/agent.d.ts CHANGED
@@ -3,26 +3,19 @@
3
3
  *
4
4
  * Chat with AI agents without UI dependencies.
5
5
  */
6
- import { ChatDTO, ChatMessageDTO, AgentTool, InternalToolsConfig } from './types';
6
+ import { ChatDTO, ChatMessageDTO, AgentRuntimeConfig } from './types';
7
7
  export interface AgentConfig {
8
8
  apiKey: string;
9
9
  baseUrl?: string;
10
10
  }
11
- /** Ad-hoc agent configuration (no saved template) */
12
- export interface AdHocAgentOptions {
13
- /** Core LLM app: namespace/name@shortid */
14
- coreApp: string;
15
- /** LLM parameters */
16
- coreAppInput?: Record<string, unknown>;
17
- /** Agent name */
18
- name?: string;
19
- /** System prompt */
20
- systemPrompt?: string;
21
- /** Tools */
22
- tools?: AgentTool[];
23
- /** Internal tools config */
24
- internalTools?: InternalToolsConfig;
25
- }
11
+ /**
12
+ * Ad-hoc agent configuration - extends AgentRuntimeConfig with core_app_ref required
13
+ * Uses Partial to make name/system_prompt optional for ad-hoc usage
14
+ */
15
+ export type AdHocAgentOptions = Partial<AgentRuntimeConfig> & {
16
+ /** Core LLM app ref: namespace/name@shortid (required for ad-hoc agents) */
17
+ core_app_ref: string;
18
+ };
26
19
  /** Template agent configuration */
27
20
  export interface TemplateAgentOptions {
28
21
  /** Agent reference: namespace/name@version (e.g., "my-org/assistant@abc123") */
@@ -58,8 +51,18 @@ export declare class Agent {
58
51
  getChat(chatId?: string): Promise<ChatDTO | null>;
59
52
  /** Stop the current chat generation */
60
53
  stopChat(): Promise<void>;
61
- /** Submit a tool result */
62
- submitToolResult(toolInvocationId: string, result: string): Promise<void>;
54
+ /**
55
+ * Submit a tool result
56
+ * @param toolInvocationId - The tool invocation ID
57
+ * @param resultOrAction - Either a raw result string, or an object with action and optional form_data (will be JSON-serialized)
58
+ */
59
+ submitToolResult(toolInvocationId: string, resultOrAction: string | {
60
+ action: {
61
+ type: string;
62
+ payload?: Record<string, unknown>;
63
+ };
64
+ form_data?: Record<string, unknown>;
65
+ }): Promise<void>;
63
66
  /** Stop streaming and cleanup */
64
67
  disconnect(): void;
65
68
  /** Reset the agent (start fresh chat) */
package/dist/agent.js CHANGED
@@ -27,7 +27,7 @@ class Agent {
27
27
  }
28
28
  /** Send a message to the agent */
29
29
  async sendMessage(text, options = {}) {
30
- const isAdHoc = 'coreApp' in this.options;
30
+ const isAdHoc = 'core_app_ref' in this.options;
31
31
  // Upload files if provided
32
32
  let imageUri;
33
33
  let fileUris;
@@ -42,22 +42,10 @@ class Agent {
42
42
  fileUris = others.map(f => f.uri);
43
43
  }
44
44
  // Both template and ad-hoc use /agents/run
45
+ const input = { text, image: imageUri, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 };
45
46
  const body = isAdHoc
46
- ? {
47
- chat_id: this.chatId,
48
- core_app: this.options.coreApp,
49
- core_app_input: this.options.coreAppInput,
50
- name: this.options.name,
51
- system_prompt: this.options.systemPrompt,
52
- tools: this.options.tools,
53
- internal_tools: this.options.internalTools,
54
- input: { text, image: imageUri, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 },
55
- }
56
- : {
57
- chat_id: this.chatId,
58
- agent: this.options.agent,
59
- input: { text, image: imageUri, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 },
60
- };
47
+ ? { chat_id: this.chatId, agent_config: this.options, input }
48
+ : { chat_id: this.chatId, agent: this.options.agent, input };
61
49
  const response = await this.request('post', '/agents/run', { data: body });
62
50
  // Update chat ID if new
63
51
  if (!this.chatId && response.assistant_message.chat_id) {
@@ -79,13 +67,17 @@ class Agent {
79
67
  return;
80
68
  await this.request('post', `/chats/${this.chatId}/stop`);
81
69
  }
82
- /** Submit a tool result */
83
- async submitToolResult(toolInvocationId, result) {
84
- if (!this.chatId)
85
- throw new Error('No active chat');
86
- await this.request('post', `/chats/${this.chatId}/tool-result`, {
87
- data: { tool_invocation_id: toolInvocationId, result },
88
- });
70
+ /**
71
+ * Submit a tool result
72
+ * @param toolInvocationId - The tool invocation ID
73
+ * @param resultOrAction - Either a raw result string, or an object with action and optional form_data (will be JSON-serialized)
74
+ */
75
+ async submitToolResult(toolInvocationId, resultOrAction) {
76
+ // Serialize widget actions to JSON string
77
+ const result = typeof resultOrAction === 'string'
78
+ ? resultOrAction
79
+ : JSON.stringify(resultOrAction);
80
+ await this.request('post', `/tools/${toolInvocationId}`, { data: { result } });
89
81
  }
90
82
  /** Stop streaming and cleanup */
91
83
  disconnect() {
package/dist/client.d.ts CHANGED
@@ -1,20 +1,13 @@
1
- import { ApiAppRunRequest, TaskDTO as Task, File, ChatDTO, ChatMessageDTO, AgentTool, InternalToolsConfig } from './types';
1
+ import { ApiAppRunRequest, TaskDTO as Task, File, ChatDTO, ChatMessageDTO, AgentRuntimeConfig } from './types';
2
2
  import { EventSource } from 'eventsource';
3
- /** Ad-hoc agent configuration (no saved template) */
4
- export interface AdHocAgentConfig {
5
- /** Core LLM app: namespace/name@shortid */
6
- coreApp: string;
7
- /** LLM parameters */
8
- coreAppInput?: Record<string, unknown>;
9
- /** Agent name */
10
- name?: string;
11
- /** System prompt */
12
- systemPrompt?: string;
13
- /** Tools */
14
- tools?: AgentTool[];
15
- /** Internal tools config */
16
- internalTools?: InternalToolsConfig;
17
- }
3
+ /**
4
+ * Ad-hoc agent configuration - extends AgentRuntimeConfig with core_app_ref required
5
+ * Uses Partial to make name/system_prompt optional for ad-hoc usage
6
+ */
7
+ export type AdHocAgentConfig = Partial<AgentRuntimeConfig> & {
8
+ /** Core LLM app ref: namespace/name@shortid (required for ad-hoc agents) */
9
+ core_app_ref: string;
10
+ };
18
11
  export interface SendMessageOptions {
19
12
  /** File attachments (Blob or base64 data URI) */
20
13
  files?: (Blob | string)[];
@@ -131,8 +124,8 @@ export declare class Inference {
131
124
  *
132
125
  * // Ad-hoc agent
133
126
  * const agent = client.agent({
134
- * coreApp: 'infsh/claude-sonnet-4@xyz789',
135
- * systemPrompt: 'You are a helpful assistant',
127
+ * core_app_ref: 'infsh/claude-sonnet-4@xyz789',
128
+ * system_prompt: 'You are a helpful assistant',
136
129
  * tools: [...]
137
130
  * })
138
131
  *
@@ -152,6 +145,7 @@ export declare class Agent {
152
145
  private readonly config;
153
146
  private chatId;
154
147
  private stream;
148
+ private dispatchedToolCalls;
155
149
  /** @internal */
156
150
  constructor(client: Inference, config: string | AdHocAgentConfig);
157
151
  /** Get current chat ID */
@@ -162,13 +156,24 @@ export declare class Agent {
162
156
  getChat(chatId?: string): Promise<ChatDTO | null>;
163
157
  /** Stop the current chat generation */
164
158
  stopChat(): Promise<void>;
165
- /** Submit a tool result */
166
- submitToolResult(toolInvocationId: string, result: string): Promise<void>;
159
+ /**
160
+ * Submit a tool result
161
+ * @param toolInvocationId - The tool invocation ID
162
+ * @param resultOrAction - Either a raw result string, or an object with action and optional form_data (will be JSON-serialized)
163
+ */
164
+ submitToolResult(toolInvocationId: string, resultOrAction: string | {
165
+ action: {
166
+ type: string;
167
+ payload?: Record<string, unknown>;
168
+ };
169
+ form_data?: Record<string, unknown>;
170
+ }): Promise<void>;
167
171
  /** Stop streaming and cleanup */
168
172
  disconnect(): void;
169
173
  /** Reset the agent (start fresh chat) */
170
174
  reset(): void;
171
- private startStreaming;
175
+ /** Stream events until chat becomes idle */
176
+ private streamUntilIdle;
172
177
  }
173
178
  /**
174
179
  * Factory function for creating an Inference client (lowercase for branding)
package/dist/client.js CHANGED
@@ -310,8 +310,8 @@ class Inference {
310
310
  *
311
311
  * // Ad-hoc agent
312
312
  * const agent = client.agent({
313
- * coreApp: 'infsh/claude-sonnet-4@xyz789',
314
- * systemPrompt: 'You are a helpful assistant',
313
+ * core_app_ref: 'infsh/claude-sonnet-4@xyz789',
314
+ * system_prompt: 'You are a helpful assistant',
315
315
  * tools: [...]
316
316
  * })
317
317
  *
@@ -337,6 +337,7 @@ class Agent {
337
337
  constructor(client, config) {
338
338
  this.chatId = null;
339
339
  this.stream = null;
340
+ this.dispatchedToolCalls = new Set();
340
341
  this.client = client;
341
342
  this.config = config;
342
343
  }
@@ -362,23 +363,23 @@ class Agent {
362
363
  const body = isTemplate
363
364
  ? {
364
365
  chat_id: this.chatId,
365
- agent: this.config,
366
+ agent_ref: this.config,
366
367
  input: { text, image: imageUri, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 },
367
368
  }
368
369
  : {
369
370
  chat_id: this.chatId,
370
- core_app: this.config.coreApp,
371
- core_app_input: this.config.coreAppInput,
372
- name: this.config.name,
373
- system_prompt: this.config.systemPrompt,
374
- tools: this.config.tools,
375
- internal_tools: this.config.internalTools,
371
+ agent_config: this.config,
376
372
  input: { text, image: imageUri, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 },
377
373
  };
378
374
  const response = await this.client._request('post', '/agents/run', { data: body });
379
- if (!this.chatId && response.assistant_message.chat_id) {
375
+ // Start streaming for new chats or continue existing stream
376
+ const isNewChat = !this.chatId && response.assistant_message.chat_id;
377
+ if (isNewChat) {
380
378
  this.chatId = response.assistant_message.chat_id;
381
- this.startStreaming(options);
379
+ }
380
+ // Wait for streaming to complete if callbacks are provided
381
+ if (options.onMessage || options.onChat || options.onToolCall) {
382
+ await this.streamUntilIdle(options);
382
383
  }
383
384
  return response.assistant_message;
384
385
  }
@@ -395,13 +396,17 @@ class Agent {
395
396
  return;
396
397
  await this.client._request('post', `/chats/${this.chatId}/stop`);
397
398
  }
398
- /** Submit a tool result */
399
- async submitToolResult(toolInvocationId, result) {
400
- if (!this.chatId)
401
- throw new Error('No active chat');
402
- await this.client._request('post', `/chats/${this.chatId}/tool-result`, {
403
- data: { tool_invocation_id: toolInvocationId, result },
404
- });
399
+ /**
400
+ * Submit a tool result
401
+ * @param toolInvocationId - The tool invocation ID
402
+ * @param resultOrAction - Either a raw result string, or an object with action and optional form_data (will be JSON-serialized)
403
+ */
404
+ async submitToolResult(toolInvocationId, resultOrAction) {
405
+ // Serialize widget actions to JSON string
406
+ const result = typeof resultOrAction === 'string'
407
+ ? resultOrAction
408
+ : JSON.stringify(resultOrAction);
409
+ await this.client._request('post', `/tools/${toolInvocationId}`, { data: { result } });
405
410
  }
406
411
  /** Stop streaming and cleanup */
407
412
  disconnect() {
@@ -412,32 +417,46 @@ class Agent {
412
417
  reset() {
413
418
  this.disconnect();
414
419
  this.chatId = null;
420
+ this.dispatchedToolCalls.clear();
415
421
  }
416
- startStreaming(options) {
422
+ /** Stream events until chat becomes idle */
423
+ streamUntilIdle(options) {
417
424
  if (!this.chatId)
418
- return;
419
- this.stream = new stream_1.StreamManager({
420
- createEventSource: async () => this.client._createEventSource(`/chats/${this.chatId}/stream`),
421
- autoReconnect: true,
422
- });
423
- this.stream.addEventListener('chats', (chat) => {
424
- options.onChat?.(chat);
425
- });
426
- this.stream.addEventListener('chat_messages', (message) => {
427
- options.onMessage?.(message);
428
- if (message.tool_invocations && options.onToolCall) {
429
- for (const inv of message.tool_invocations) {
430
- if (inv.type === types_1.ToolTypeClient && inv.status === types_1.ToolInvocationStatusAwaitingInput) {
431
- options.onToolCall({
432
- id: inv.id,
433
- name: inv.function?.name || '',
434
- args: inv.function?.arguments || {},
435
- });
425
+ return Promise.resolve();
426
+ return new Promise((resolve) => {
427
+ // Stop any existing stream
428
+ this.stream?.stop();
429
+ this.stream = new stream_1.StreamManager({
430
+ createEventSource: async () => this.client._createEventSource(`/chats/${this.chatId}/stream`),
431
+ autoReconnect: true,
432
+ });
433
+ this.stream.addEventListener('chats', (chat) => {
434
+ options.onChat?.(chat);
435
+ // Resolve when chat becomes idle (generation complete)
436
+ if (chat.status === 'idle') {
437
+ resolve();
438
+ }
439
+ });
440
+ this.stream.addEventListener('chat_messages', (message) => {
441
+ options.onMessage?.(message);
442
+ if (message.tool_invocations && options.onToolCall) {
443
+ for (const inv of message.tool_invocations) {
444
+ // Skip if already dispatched
445
+ if (this.dispatchedToolCalls.has(inv.id))
446
+ continue;
447
+ if (inv.type === types_1.ToolTypeClient && inv.status === types_1.ToolInvocationStatusAwaitingInput) {
448
+ this.dispatchedToolCalls.add(inv.id);
449
+ options.onToolCall({
450
+ id: inv.id,
451
+ name: inv.function?.name || '',
452
+ args: inv.function?.arguments || {},
453
+ });
454
+ }
436
455
  }
437
456
  }
438
- }
457
+ });
458
+ this.stream.connect();
439
459
  });
440
- this.stream.connect();
441
460
  }
442
461
  }
443
462
  exports.Agent = Agent;
@@ -95,15 +95,13 @@ class AppToolBuilder extends ToolBuilder {
95
95
  this.appRef = appRef;
96
96
  }
97
97
  build() {
98
- const [ns, rest] = this.appRef.split('/');
99
- const [appName, version] = rest?.split('@') || [];
100
98
  return {
101
99
  name: this.name,
102
100
  display_name: this.displayName || this.name,
103
101
  description: this.desc,
104
102
  type: types_1.ToolTypeApp,
105
103
  require_approval: this.approval || undefined,
106
- app: { id: `${ns}/${appName}`, version_id: version },
104
+ app: { ref: this.appRef },
107
105
  };
108
106
  }
109
107
  }
@@ -113,15 +111,13 @@ class AgentToolBuilder extends ToolBuilder {
113
111
  this.agentRef = agentRef;
114
112
  }
115
113
  build() {
116
- const [ns, rest] = this.agentRef.split('/');
117
- const [agentName, version] = rest?.split('@') || [];
118
114
  return {
119
115
  name: this.name,
120
116
  display_name: this.displayName || this.name,
121
117
  description: this.desc,
122
118
  type: types_1.ToolTypeAgent,
123
119
  require_approval: this.approval || undefined,
124
- agent: { id: `${ns}/${agentName}`, version_id: version },
120
+ agent: { ref: this.agentRef },
125
121
  };
126
122
  }
127
123
  }
@@ -169,12 +169,12 @@ describe('AppToolBuilder (appTool)', () => {
169
169
  .describe('Generate image')
170
170
  .build();
171
171
  expect(t.type).toBe(types_1.ToolTypeApp);
172
- expect(t.app).toEqual({ id: 'infsh/flux', version_id: 'v1.0' });
172
+ expect(t.app).toEqual({ ref: 'infsh/flux@v1.0' });
173
173
  expect(t.description).toBe('Generate image');
174
174
  });
175
175
  it('handles app reference with latest version', () => {
176
176
  const t = (0, tool_builder_1.appTool)('browse', 'my-org/browser@latest').build();
177
- expect(t.app).toEqual({ id: 'my-org/browser', version_id: 'latest' });
177
+ expect(t.app).toEqual({ ref: 'my-org/browser@latest' });
178
178
  });
179
179
  it('includes parameters', () => {
180
180
  const t = (0, tool_builder_1.appTool)('fetch', 'infsh/fetch@v1')
@@ -190,7 +190,7 @@ describe('AgentToolBuilder (agentTool)', () => {
190
190
  .describe('Research a topic')
191
191
  .build();
192
192
  expect(t.type).toBe(types_1.ToolTypeAgent);
193
- expect(t.agent).toEqual({ id: 'acme/researcher', version_id: 'v2' });
193
+ expect(t.agent).toEqual({ ref: 'acme/researcher@v2' });
194
194
  });
195
195
  it('supports display name and approval', () => {
196
196
  const t = (0, tool_builder_1.agentTool)('coder', 'infsh/code-agent@latest')
package/dist/types.d.ts CHANGED
@@ -20,10 +20,18 @@ export declare const ToolTypeInternal: ToolType;
20
20
  * AppToolConfig contains configuration for an app tool
21
21
  */
22
22
  export interface AppToolConfig {
23
- id: string;
23
+ /**
24
+ * Ref is the human-readable reference: "namespace/name@shortVersionId"
25
+ * This is what users specify in configs/SDKs
26
+ */
27
+ ref: string;
28
+ /**
29
+ * ID and VersionID are resolved full database UUIDs (populated at runtime)
30
+ */
31
+ id?: string;
24
32
  version_id?: string;
25
33
  /**
26
- * Resolved at runtime, not stored
34
+ * Resolved app object (populated at runtime)
27
35
  */
28
36
  app?: App;
29
37
  }
@@ -31,10 +39,18 @@ export interface AppToolConfig {
31
39
  * AgentToolConfig contains configuration for a sub-agent tool
32
40
  */
33
41
  export interface AgentToolConfig {
34
- id: string;
42
+ /**
43
+ * Ref is the human-readable reference: "namespace/name@shortVersionId"
44
+ * This is what users specify in configs/SDKs
45
+ */
46
+ ref: string;
47
+ /**
48
+ * ID and VersionID are resolved full database UUIDs (populated at runtime)
49
+ */
50
+ id?: string;
35
51
  version_id?: string;
36
52
  /**
37
- * Resolved at runtime, not stored
53
+ * Resolved agent object (populated at runtime)
38
54
  */
39
55
  agent?: Agent;
40
56
  }
@@ -73,6 +89,14 @@ export interface AgentTool {
73
89
  agent?: AgentToolConfig;
74
90
  hook?: HookToolConfig;
75
91
  client?: ClientToolConfig;
92
+ internal?: InternalToolConfig;
93
+ }
94
+ /**
95
+ * InternalToolConfig contains configuration for internal/built-in tools
96
+ */
97
+ export interface InternalToolConfig {
98
+ category: string;
99
+ operation: string;
76
100
  }
77
101
  /**
78
102
  * AgentToolDTO for API responses
@@ -92,12 +116,14 @@ export interface AgentToolDTO {
92
116
  client?: ClientToolConfigDTO;
93
117
  }
94
118
  export interface AppToolConfigDTO {
95
- id: string;
119
+ ref: string;
120
+ id?: string;
96
121
  version_id?: string;
97
122
  app?: AppDTO;
98
123
  }
99
124
  export interface AgentToolConfigDTO {
100
- id: string;
125
+ ref: string;
126
+ id?: string;
101
127
  version_id?: string;
102
128
  agent?: AgentDTO;
103
129
  }
@@ -210,7 +236,10 @@ export interface AgentRuntimeConfig {
210
236
  example_prompts?: string[];
211
237
  /**
212
238
  * Core LLM
239
+ * CoreAppRef is the user-facing ref (namespace/name@shortid) - used in ad-hoc configs
240
+ * CoreApp is the resolved config - populated by backend after resolving CoreAppRef
213
241
  */
242
+ core_app_ref?: string;
214
243
  core_app?: CoreAppConfig;
215
244
  core_app_input?: any;
216
245
  /**
@@ -237,6 +266,7 @@ export interface AgentRuntimeConfigDTO {
237
266
  description?: string;
238
267
  system_prompt: string;
239
268
  example_prompts?: string[];
269
+ core_app_ref?: string;
240
270
  core_app?: CoreAppConfigDTO;
241
271
  core_app_input?: any;
242
272
  tools?: (AgentToolDTO | undefined)[];
@@ -298,31 +328,15 @@ export interface ApiAgentRunRequest {
298
328
  /**
299
329
  * Template agent reference in format: namespace/name@shortid
300
330
  * Example: "my-org/assistant@abc123"
301
- * Use this OR core_app, not both
331
+ * Use this OR AgentConfig, not both
302
332
  */
303
333
  agent?: string;
304
334
  /**
305
- * Core LLM app reference for ad-hoc agents in format: namespace/name@shortid
306
- * Example: "infsh/claude-sonnet-4@1195p4sq"
307
- * Use this for ad-hoc agents (without a saved template)
335
+ * Ad-hoc agent configuration
336
+ * For ad-hoc agents, set core_app_ref to the LLM app reference
337
+ * Example: { "core_app_ref": "infsh/claude-sonnet-4@abc123", "system_prompt": "..." }
308
338
  */
309
- core_app?: string;
310
- /**
311
- * LLM parameters for ad-hoc agents (temperature, top_p, context_size, etc.)
312
- */
313
- core_app_input?: any;
314
- /**
315
- * Agent configuration for ad-hoc agents
316
- */
317
- name?: string;
318
- description?: string;
319
- system_prompt?: string;
320
- example_prompts?: string[];
321
- /**
322
- * Tools configuration for ad-hoc agents
323
- */
324
- tools?: (AgentTool | undefined)[];
325
- internal_tools?: InternalToolsConfig;
339
+ agent_config?: AgentRuntimeConfig;
326
340
  /**
327
341
  * The message to send
328
342
  */
@@ -356,15 +370,15 @@ export interface CreateChatMessageResponse {
356
370
  }
357
371
  /**
358
372
  * WidgetActionRequest represents a user's response to a widget
359
- * Uses WidgetAction and WidgetFormData from chat.go
373
+ * @deprecated Use ToolResultRequest with action field instead
360
374
  */
361
375
  export interface WidgetActionRequest {
362
376
  action: WidgetAction;
363
377
  form_data?: WidgetFormData;
364
378
  }
365
379
  /**
366
- * ToolResultRequest represents a generic tool result callback
367
- * Used by hooks and other tools that expect an async callback
380
+ * ToolResultRequest represents a tool result submission
381
+ * For widget actions, clients should JSON-serialize { action, form_data } as the result string
368
382
  */
369
383
  export interface ToolResultRequest {
370
384
  result: string;
@@ -781,6 +795,14 @@ export declare const ChatMessageRoleSystem: ChatMessageRole;
781
795
  export declare const ChatMessageRoleUser: ChatMessageRole;
782
796
  export declare const ChatMessageRoleAssistant: ChatMessageRole;
783
797
  export declare const ChatMessageRoleTool: ChatMessageRole;
798
+ /**
799
+ * ChatMessageStatus represents the lifecycle status of a chat message
800
+ */
801
+ export type ChatMessageStatus = string;
802
+ export declare const ChatMessageStatusPending: ChatMessageStatus;
803
+ export declare const ChatMessageStatusReady: ChatMessageStatus;
804
+ export declare const ChatMessageStatusFailed: ChatMessageStatus;
805
+ export declare const ChatMessageStatusCancelled: ChatMessageStatus;
784
806
  export type ChatMessageContentType = string;
785
807
  export declare const ChatMessageContentTypeText: ChatMessageContentType;
786
808
  export declare const ChatMessageContentTypeReasoning: ChatMessageContentType;
@@ -861,8 +883,8 @@ export interface ChatMessageDTO extends BaseModel, PermissionModelDTO {
861
883
  chat_id: string;
862
884
  chat?: ChatDTO;
863
885
  order: number;
886
+ status: ChatMessageStatus;
864
887
  task_id?: string;
865
- task_status?: TaskStatus;
866
888
  role: ChatMessageRole;
867
889
  content: ChatMessageContent[];
868
890
  tools?: Tool[];
package/dist/types.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // Code generated by tygo. DO NOT EDIT.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.EngineStatusRunning = exports.DeviceAuthStatusLoading = exports.DeviceAuthStatusInvalid = exports.DeviceAuthStatusValid = exports.DeviceAuthStatusDenied = exports.DeviceAuthStatusExpired = exports.DeviceAuthStatusApproved = exports.DeviceAuthStatusPending = exports.IntegrationTypeTelegram = exports.IntegrationTypeTeams = exports.IntegrationTypeDiscord = exports.IntegrationTypeSlack = exports.ChatMessageContentTypeTool = exports.ChatMessageContentTypeFile = exports.ChatMessageContentTypeImage = exports.ChatMessageContentTypeReasoning = exports.ChatMessageContentTypeText = exports.ChatMessageRoleTool = exports.ChatMessageRoleAssistant = exports.ChatMessageRoleUser = exports.ChatMessageRoleSystem = exports.PlanStepStatusCancelled = exports.PlanStepStatusCompleted = exports.PlanStepStatusInProgress = exports.PlanStepStatusPending = exports.ChatStatusCompleted = exports.ChatStatusIdle = exports.ChatStatusBusy = exports.VisibilityUnlisted = exports.VisibilityPublic = exports.VisibilityPrivate = exports.GPUTypeApple = exports.GPUTypeAMD = exports.GPUTypeNvidia = exports.GPUTypeIntel = exports.GPUTypeNone = exports.GPUTypeAny = exports.AppCategoryFlow = exports.AppCategoryOther = exports.AppCategory3D = exports.AppCategoryChat = exports.AppCategoryText = exports.AppCategoryAudio = exports.AppCategoryVideo = exports.AppCategoryImage = exports.ToolTypeInternal = exports.ToolTypeClient = exports.ToolTypeHook = exports.ToolTypeAgent = exports.ToolTypeApp = void 0;
5
- exports.TaskLogTypeServe = exports.TaskLogTypeRun = exports.TaskLogTypeBuild = exports.InfraPrivateFirst = exports.InfraCloud = exports.InfraPrivate = exports.TaskStatusCancelled = exports.TaskStatusFailed = exports.TaskStatusCompleted = exports.TaskStatusUploading = exports.TaskStatusRunning = exports.TaskStatusSettingUp = exports.TaskStatusServing = exports.TaskStatusPreparing = exports.TaskStatusScheduled = exports.TaskStatusQueued = exports.TaskStatusReceived = exports.TaskStatusUnknown = exports.InstanceStatusDeleted = exports.InstanceStatusActive = exports.InstanceStatusPending = exports.CloudShade = exports.CloudVultr = exports.CloudMassedCompute = exports.CloudDatacrunch = exports.CloudPaperspace = exports.CloudOblivus = exports.CloudJarvisLabs = exports.CloudLatitude = exports.CloudRunPod = exports.CloudTensorDock = exports.CloudLambdaLabs = exports.CloudAzure = exports.CloudAWS = exports.ContentUnrated = exports.ContentSelfHarm = exports.ContentDrugs = exports.ContentGore = exports.ContentViolenceGraphic = exports.ContentViolenceNonGraphic = exports.ContentSexualExplicit = exports.ContentSexualSuggestive = exports.ContentSafe = exports.ProjectTypeOther = exports.ProjectTypeFlow = exports.ProjectTypeApp = exports.ProjectTypeAgent = exports.EngineStatusStopped = exports.EngineStatusStopping = exports.EngineStatusPending = void 0;
6
- exports.WidgetNodeTypePlanList = exports.WidgetNodeTypeCol = exports.WidgetNodeTypeRow = exports.WidgetNodeTypeCheckbox = exports.WidgetNodeTypeSelect = exports.WidgetNodeTypeInput = exports.WidgetNodeTypeButton = exports.WidgetNodeTypeBadge = exports.WidgetNodeTypeImage = exports.WidgetNodeTypeMarkdown = exports.WidgetNodeTypeText = exports.RoleSystem = exports.RoleAdmin = exports.RoleUser = exports.RoleGuest = exports.VideoRes4K = exports.VideoRes1440P = exports.VideoRes1080P = exports.VideoRes720P = exports.VideoRes480P = exports.MetaItemTypeRaw = exports.MetaItemTypeAudio = exports.MetaItemTypeVideo = exports.MetaItemTypeImage = exports.MetaItemTypeText = exports.UsageEventResourceTierCloud = exports.UsageEventResourceTierPrivate = exports.PaymentRecordTypeAutoRecharge = exports.PaymentRecordTypeCheckout = exports.PaymentRecordStatusExpired = exports.PaymentRecordStatusFailed = exports.PaymentRecordStatusComplete = exports.PaymentRecordStatusPending = exports.TransactionTypeDebit = exports.TransactionTypeCredit = exports.ToolInvocationStatusCancelled = exports.ToolInvocationStatusFailed = exports.ToolInvocationStatusCompleted = exports.ToolInvocationStatusAwaitingApproval = exports.ToolInvocationStatusAwaitingInput = exports.ToolInvocationStatusInProgress = exports.ToolInvocationStatusPending = exports.TeamRoleMember = exports.TeamRoleAdmin = exports.TeamRoleOwner = exports.TeamTypeSystem = exports.TeamTypeTeam = exports.TeamTypePersonal = exports.TaskLogTypeTask = exports.TaskLogTypeSetup = void 0;
7
- exports.WidgetNodeTypeStatusBadge = exports.WidgetNodeTypeKeyValue = void 0;
4
+ exports.DeviceAuthStatusDenied = exports.DeviceAuthStatusExpired = exports.DeviceAuthStatusApproved = exports.DeviceAuthStatusPending = exports.IntegrationTypeTelegram = exports.IntegrationTypeTeams = exports.IntegrationTypeDiscord = exports.IntegrationTypeSlack = exports.ChatMessageContentTypeTool = exports.ChatMessageContentTypeFile = exports.ChatMessageContentTypeImage = exports.ChatMessageContentTypeReasoning = exports.ChatMessageContentTypeText = exports.ChatMessageStatusCancelled = exports.ChatMessageStatusFailed = exports.ChatMessageStatusReady = exports.ChatMessageStatusPending = exports.ChatMessageRoleTool = exports.ChatMessageRoleAssistant = exports.ChatMessageRoleUser = exports.ChatMessageRoleSystem = exports.PlanStepStatusCancelled = exports.PlanStepStatusCompleted = exports.PlanStepStatusInProgress = exports.PlanStepStatusPending = exports.ChatStatusCompleted = exports.ChatStatusIdle = exports.ChatStatusBusy = exports.VisibilityUnlisted = exports.VisibilityPublic = exports.VisibilityPrivate = exports.GPUTypeApple = exports.GPUTypeAMD = exports.GPUTypeNvidia = exports.GPUTypeIntel = exports.GPUTypeNone = exports.GPUTypeAny = exports.AppCategoryFlow = exports.AppCategoryOther = exports.AppCategory3D = exports.AppCategoryChat = exports.AppCategoryText = exports.AppCategoryAudio = exports.AppCategoryVideo = exports.AppCategoryImage = exports.ToolTypeInternal = exports.ToolTypeClient = exports.ToolTypeHook = exports.ToolTypeAgent = exports.ToolTypeApp = void 0;
5
+ exports.InfraCloud = exports.InfraPrivate = exports.TaskStatusCancelled = exports.TaskStatusFailed = exports.TaskStatusCompleted = exports.TaskStatusUploading = exports.TaskStatusRunning = exports.TaskStatusSettingUp = exports.TaskStatusServing = exports.TaskStatusPreparing = exports.TaskStatusScheduled = exports.TaskStatusQueued = exports.TaskStatusReceived = exports.TaskStatusUnknown = exports.InstanceStatusDeleted = exports.InstanceStatusActive = exports.InstanceStatusPending = exports.CloudShade = exports.CloudVultr = exports.CloudMassedCompute = exports.CloudDatacrunch = exports.CloudPaperspace = exports.CloudOblivus = exports.CloudJarvisLabs = exports.CloudLatitude = exports.CloudRunPod = exports.CloudTensorDock = exports.CloudLambdaLabs = exports.CloudAzure = exports.CloudAWS = exports.ContentUnrated = exports.ContentSelfHarm = exports.ContentDrugs = exports.ContentGore = exports.ContentViolenceGraphic = exports.ContentViolenceNonGraphic = exports.ContentSexualExplicit = exports.ContentSexualSuggestive = exports.ContentSafe = exports.ProjectTypeOther = exports.ProjectTypeFlow = exports.ProjectTypeApp = exports.ProjectTypeAgent = exports.EngineStatusStopped = exports.EngineStatusStopping = exports.EngineStatusPending = exports.EngineStatusRunning = exports.DeviceAuthStatusLoading = exports.DeviceAuthStatusInvalid = exports.DeviceAuthStatusValid = void 0;
6
+ exports.WidgetNodeTypeSelect = exports.WidgetNodeTypeInput = exports.WidgetNodeTypeButton = exports.WidgetNodeTypeBadge = exports.WidgetNodeTypeImage = exports.WidgetNodeTypeMarkdown = exports.WidgetNodeTypeText = exports.RoleSystem = exports.RoleAdmin = exports.RoleUser = exports.RoleGuest = exports.VideoRes4K = exports.VideoRes1440P = exports.VideoRes1080P = exports.VideoRes720P = exports.VideoRes480P = exports.MetaItemTypeRaw = exports.MetaItemTypeAudio = exports.MetaItemTypeVideo = exports.MetaItemTypeImage = exports.MetaItemTypeText = exports.UsageEventResourceTierCloud = exports.UsageEventResourceTierPrivate = exports.PaymentRecordTypeAutoRecharge = exports.PaymentRecordTypeCheckout = exports.PaymentRecordStatusExpired = exports.PaymentRecordStatusFailed = exports.PaymentRecordStatusComplete = exports.PaymentRecordStatusPending = exports.TransactionTypeDebit = exports.TransactionTypeCredit = exports.ToolInvocationStatusCancelled = exports.ToolInvocationStatusFailed = exports.ToolInvocationStatusCompleted = exports.ToolInvocationStatusAwaitingApproval = exports.ToolInvocationStatusAwaitingInput = exports.ToolInvocationStatusInProgress = exports.ToolInvocationStatusPending = exports.TeamRoleMember = exports.TeamRoleAdmin = exports.TeamRoleOwner = exports.TeamTypeSystem = exports.TeamTypeTeam = exports.TeamTypePersonal = exports.TaskLogTypeTask = exports.TaskLogTypeSetup = exports.TaskLogTypeServe = exports.TaskLogTypeRun = exports.TaskLogTypeBuild = exports.InfraPrivateFirst = void 0;
7
+ exports.WidgetNodeTypeStatusBadge = exports.WidgetNodeTypeKeyValue = exports.WidgetNodeTypePlanList = exports.WidgetNodeTypeCol = exports.WidgetNodeTypeRow = exports.WidgetNodeTypeCheckbox = void 0;
8
8
  exports.ToolTypeApp = "app"; // App tools - creates a Task
9
9
  exports.ToolTypeAgent = "agent"; // Sub-agent tools - creates a sub-Chat
10
10
  exports.ToolTypeHook = "hook"; // Webhook tools - HTTP POST to external URL
@@ -41,6 +41,10 @@ exports.ChatMessageRoleSystem = "system";
41
41
  exports.ChatMessageRoleUser = "user";
42
42
  exports.ChatMessageRoleAssistant = "assistant";
43
43
  exports.ChatMessageRoleTool = "tool";
44
+ exports.ChatMessageStatusPending = "pending"; // Message is being generated
45
+ exports.ChatMessageStatusReady = "ready"; // Message complete, tools ready for execution
46
+ exports.ChatMessageStatusFailed = "failed"; // Message generation failed
47
+ exports.ChatMessageStatusCancelled = "cancelled"; // Message was cancelled
44
48
  exports.ChatMessageContentTypeText = "text";
45
49
  exports.ChatMessageContentTypeReasoning = "reasoning";
46
50
  exports.ChatMessageContentTypeImage = "image";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official JavaScript/TypeScript SDK for inference.sh - Run AI models with a simple API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",