@inferencesh/sdk 0.6.25 → 0.6.27

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.
@@ -106,10 +106,11 @@ export function createActions(ctx) {
106
106
  return;
107
107
  }
108
108
  // Single unified stream with TypedEvents (both Chat and ChatMessage events)
109
- const { url, headers } = api.getChatStreamConfig(client, id);
109
+ const { url, headers, credentials } = api.getChatStreamConfig(client, id);
110
110
  const manager = new StreamableManager({
111
111
  url,
112
112
  headers,
113
+ credentials,
113
114
  onError: (error) => {
114
115
  console.warn('[AgentSDK] Stream error:', error);
115
116
  callbacks.onError?.(error);
@@ -74,4 +74,5 @@ export declare function uploadFile(client: AgentClient, file: globalThis.File):
74
74
  export declare function getChatStreamConfig(client: AgentClient, chatId: string): {
75
75
  url: string;
76
76
  headers: Record<string, string>;
77
+ credentials: RequestCredentials;
77
78
  };
@@ -149,12 +149,13 @@ export class Agent {
149
149
  streamUntilIdle(options) {
150
150
  if (!this.chatId)
151
151
  return Promise.resolve();
152
- const { url, headers } = this.http.getStreamableConfig(`/chats/${this.chatId}/stream`);
152
+ const { url, headers, credentials } = this.http.getStreamableConfig(`/chats/${this.chatId}/stream`);
153
153
  return new Promise((resolve) => {
154
154
  this.stream?.stop();
155
155
  this.stream = new StreamableManager({
156
156
  url,
157
157
  headers,
158
+ credentials,
158
159
  });
159
160
  this.stream.addEventListener('chats', (chat) => {
160
161
  options.onChat?.(chat);
package/dist/api/tasks.js CHANGED
@@ -87,11 +87,12 @@ export class TasksAPI {
87
87
  // Wait for completion with optional updates via NDJSON streaming
88
88
  // Accumulate state across partial updates to preserve fields like session_id
89
89
  let accumulatedTask = { ...task };
90
- const { url, headers } = this.http.getStreamableConfig(`/tasks/${task.id}/stream`);
90
+ const { url, headers, credentials } = this.http.getStreamableConfig(`/tasks/${task.id}/stream`);
91
91
  return new Promise((resolve, reject) => {
92
92
  const streamManager = new StreamableManager({
93
93
  url,
94
94
  headers,
95
+ credentials,
95
96
  onData: (data) => {
96
97
  // Merge new data, preserving existing fields if not in update
97
98
  accumulatedTask = { ...accumulatedTask, ...data };
@@ -83,6 +83,7 @@ export declare class HttpClient {
83
83
  getStreamableConfig(endpoint: string): {
84
84
  url: string;
85
85
  headers: Record<string, string>;
86
+ credentials: RequestCredentials;
86
87
  };
87
88
  /**
88
89
  * Pull a human-readable detail string from a parsed problem+json / API error
@@ -162,7 +162,7 @@ export class HttpClient {
162
162
  headers['Authorization'] = `Bearer ${token}`;
163
163
  }
164
164
  }
165
- return { url, headers };
165
+ return { url, headers, credentials: this.credentials };
166
166
  }
167
167
  /**
168
168
  * Pull a human-readable detail string from a parsed problem+json / API error
@@ -14,6 +14,8 @@ export interface StreamableOptions {
14
14
  signal?: AbortSignal;
15
15
  /** Skip heartbeat messages (default: true) */
16
16
  skipHeartbeats?: boolean;
17
+ /** Request credentials mode (for cookie-based auth) */
18
+ credentials?: RequestCredentials;
17
19
  }
18
20
  export interface StreamableMessage<T = unknown> {
19
21
  /** Optional event type */
@@ -39,6 +41,8 @@ export interface StreamableManagerOptions<T> {
39
41
  url: string;
40
42
  /** Additional headers */
41
43
  headers?: Record<string, string>;
44
+ /** Request credentials mode (for cookie-based auth) */
45
+ credentials?: RequestCredentials;
42
46
  /** Request body */
43
47
  body?: unknown;
44
48
  /** Called for each message */
@@ -8,7 +8,7 @@
8
8
  * Yields parsed JSON objects, automatically filtering heartbeats.
9
9
  */
10
10
  export async function* streamable(url, options = {}) {
11
- const { headers = {}, body, method = body ? 'POST' : 'GET', signal, skipHeartbeats = true, } = options;
11
+ const { headers = {}, body, method = body ? 'POST' : 'GET', signal, skipHeartbeats = true, credentials, } = options;
12
12
  const requestHeaders = {
13
13
  Accept: 'application/x-ndjson',
14
14
  ...headers,
@@ -21,6 +21,7 @@ export async function* streamable(url, options = {}) {
21
21
  headers: requestHeaders,
22
22
  body: body ? JSON.stringify(body) : undefined,
23
23
  signal,
24
+ credentials,
24
25
  });
25
26
  if (!res.ok) {
26
27
  const text = await res.text();
@@ -112,6 +113,7 @@ export class StreamableManager {
112
113
  headers: this.options.headers,
113
114
  body: this.options.body,
114
115
  signal: this.abortController.signal,
116
+ credentials: this.options.credentials,
115
117
  })) {
116
118
  if (!this.isRunning)
117
119
  break;
@@ -169,7 +171,7 @@ export class StreamableManager {
169
171
  * Use this when you need access to event type or fields.
170
172
  */
171
173
  export async function* streamableRaw(url, options = {}) {
172
- const { headers = {}, body, method = body ? 'POST' : 'GET', signal, skipHeartbeats = true, } = options;
174
+ const { headers = {}, body, method = body ? 'POST' : 'GET', signal, skipHeartbeats = true, credentials, } = options;
173
175
  const requestHeaders = {
174
176
  Accept: 'application/x-ndjson',
175
177
  ...headers,
@@ -182,6 +184,7 @@ export async function* streamableRaw(url, options = {}) {
182
184
  headers: requestHeaders,
183
185
  body: body ? JSON.stringify(body) : undefined,
184
186
  signal,
187
+ credentials,
185
188
  });
186
189
  if (!res.ok) {
187
190
  const text = await res.text();
package/dist/types.d.ts CHANGED
@@ -1171,10 +1171,10 @@ export interface ChatMessageDTO extends BaseModelDTO, PermissionModelDTO {
1171
1171
  tool_invocations?: ToolInvocationDTO[];
1172
1172
  }
1173
1173
  /**
1174
- * SearchRequest represents a search request
1174
+ * SearchRequest represents a search request.
1175
+ * Each model declares its own SearchFields() on the repository.
1175
1176
  */
1176
1177
  export interface SearchRequest {
1177
- fields: string[];
1178
1178
  term: string;
1179
1179
  exact: boolean;
1180
1180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.6.25",
3
+ "version": "0.6.27",
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",