@inferencesh/sdk 0.5.15 → 0.5.16

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.
@@ -30,7 +30,9 @@ export function createActions(ctx) {
30
30
  };
31
31
  const updateMessage = (message) => {
32
32
  const chatId = getChatId();
33
- if (message.chat_id !== chatId)
33
+ // TODO: remove startsWith once the provider normalizes chatId to full ID after first fetchChat
34
+ // Support short ID matching (URL short IDs are prefixes of full IDs)
35
+ if (chatId && message.chat_id !== chatId && !message.chat_id.startsWith(chatId))
34
36
  return;
35
37
  dispatch({ type: 'UPDATE_MESSAGE', payload: message });
36
38
  // Check for client tool invocations that need execution
@@ -121,9 +123,13 @@ export function createActions(ctx) {
121
123
  }
122
124
  },
123
125
  });
124
- // Listen for Chat object updates (status changes)
126
+ // Listen for Chat object updates (status changes only — don't replace messages)
125
127
  manager.addEventListener('chats', (chatData) => {
126
- setChat(chatData);
128
+ dispatch({ type: 'UPDATE_CHAT', payload: chatData });
129
+ if (chatData) {
130
+ const status = chatData.status === ChatStatusBusy ? 'streaming' : 'idle';
131
+ callbacks.onStatusChange?.(status);
132
+ }
127
133
  });
128
134
  // Listen for ChatMessage updates
129
135
  manager.addEventListener('chat_messages', (message) => {
@@ -28,6 +28,13 @@ export function chatReducer(state, action) {
28
28
  const messages = [...(chat.chat_messages || [])].sort((a, b) => a.order - b.order);
29
29
  return { ...state, chat, messages };
30
30
  }
31
+ case 'UPDATE_CHAT': {
32
+ // Update chat metadata (e.g. status) without replacing messages
33
+ const chat = action.payload;
34
+ if (!chat)
35
+ return state;
36
+ return { ...state, chat };
37
+ }
31
38
  case 'SET_MESSAGES':
32
39
  return { ...state, messages: action.payload };
33
40
  case 'UPDATE_MESSAGE': {
@@ -176,6 +176,9 @@ export type ChatAction = {
176
176
  } | {
177
177
  type: 'SET_CHAT';
178
178
  payload: ChatDTO | null;
179
+ } | {
180
+ type: 'UPDATE_CHAT';
181
+ payload: ChatDTO | null;
179
182
  } | {
180
183
  type: 'SET_MESSAGES';
181
184
  payload: ChatMessageDTO[];
@@ -16,9 +16,7 @@ export class HttpClient {
16
16
  this.baseUrl = config.baseUrl || 'https://api.inference.sh';
17
17
  this.proxyUrl = config.proxyUrl;
18
18
  this.getToken = config.getToken;
19
- const isBrowser = typeof window !== 'undefined';
20
- const sourceKey = isBrowser ? 'X-Client-Source' : 'User-Agent';
21
- this.customHeaders = { [sourceKey]: 'inference-sdk-js/0.5.13', ...config.headers };
19
+ this.customHeaders = { 'X-Client-Source': 'inference-sdk-js/0.5.13', ...config.headers };
22
20
  this.credentials = config.credentials || 'include';
23
21
  this.onError = config.onError;
24
22
  this.streamDefault = config.stream ?? true;
package/dist/types.d.ts CHANGED
@@ -1339,6 +1339,7 @@ export interface WorkerState extends BaseModel, PermissionModel {
1339
1339
  index: number;
1340
1340
  status: WorkerStatus;
1341
1341
  status_updated_at?: string;
1342
+ heartbeat_at?: string;
1342
1343
  engine_id: string;
1343
1344
  engine?: EngineState;
1344
1345
  task_id?: string;
@@ -1434,6 +1435,7 @@ export interface File extends BaseModel, PermissionModel {
1434
1435
  content_type: string;
1435
1436
  size: number;
1436
1437
  filename: string;
1438
+ category: string;
1437
1439
  rating: ContentRating;
1438
1440
  metadata?: FileMetadata;
1439
1441
  }
@@ -1445,6 +1447,7 @@ export interface FileDTO extends BaseModel, PermissionModelDTO {
1445
1447
  content_type: string;
1446
1448
  size: number;
1447
1449
  filename: string;
1450
+ category: string;
1448
1451
  rating: ContentRating;
1449
1452
  metadata?: FileMetadata;
1450
1453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
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",