@inferencesh/sdk 0.6.26 → 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.
- package/dist/agent/actions.js +2 -1
- package/dist/agent/api.d.ts +1 -0
- package/dist/api/agents.js +2 -1
- package/dist/api/tasks.js +2 -1
- package/dist/http/client.d.ts +1 -0
- package/dist/http/client.js +1 -1
- package/dist/http/streamable.d.ts +4 -0
- package/dist/http/streamable.js +5 -2
- package/package.json +1 -1
package/dist/agent/actions.js
CHANGED
|
@@ -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);
|
package/dist/agent/api.d.ts
CHANGED
package/dist/api/agents.js
CHANGED
|
@@ -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 };
|
package/dist/http/client.d.ts
CHANGED
package/dist/http/client.js
CHANGED
|
@@ -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 */
|
package/dist/http/streamable.js
CHANGED
|
@@ -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();
|