@inferencesh/sdk 0.22.1 → 0.24.0
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/CHANGELOG.md +26 -0
- package/dist/agent/actions.d.ts +2 -2
- package/dist/agent/actions.js +131 -28
- package/dist/agent/api.d.ts +4 -4
- package/dist/agent/api.js +6 -3
- package/dist/agent/context.d.ts +1 -1
- package/dist/agent/hooks.d.ts +2 -2
- package/dist/agent/hooks.js +1 -1
- package/dist/agent/index.d.ts +6 -6
- package/dist/agent/index.js +5 -5
- package/dist/agent/mcp-input.d.ts +1 -1
- package/dist/agent/provider.d.ts +1 -1
- package/dist/agent/provider.js +5 -5
- package/dist/agent/reducer.d.ts +1 -1
- package/dist/agent/reducer.js +2 -2
- package/dist/agent/types.d.ts +20 -7
- package/dist/api/agents.d.ts +16 -14
- package/dist/api/agents.js +63 -40
- package/dist/api/api-keys.d.ts +3 -3
- package/dist/api/apps.d.ts +4 -4
- package/dist/api/artifacts.d.ts +3 -3
- package/dist/api/chats.d.ts +4 -4
- package/dist/api/credentials.d.ts +3 -3
- package/dist/api/engines.d.ts +4 -4
- package/dist/api/files.d.ts +3 -3
- package/dist/api/flow-runs.d.ts +3 -3
- package/dist/api/flows.d.ts +4 -4
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +4 -4
- package/dist/api/knowledge.d.ts +4 -4
- package/dist/api/mcp-servers.d.ts +4 -4
- package/dist/api/projects.d.ts +4 -4
- package/dist/api/search.d.ts +3 -3
- package/dist/api/secrets.d.ts +3 -3
- package/dist/api/sessions.d.ts +3 -3
- package/dist/api/sockets.d.ts +6 -6
- package/dist/api/sockets.js +2 -2
- package/dist/api/tasks.d.ts +3 -3
- package/dist/api/tasks.js +4 -4
- package/dist/api/teams.d.ts +4 -4
- package/dist/api/write-bodies.d.ts +1 -1
- package/dist/delta.d.ts +1 -1
- package/dist/delta.js +1 -1
- package/dist/hook-builder.d.ts +1 -1
- package/dist/hook-builder.js +1 -1
- package/dist/http/client.d.ts +2 -2
- package/dist/http/client.js +2 -2
- package/dist/http/errors.d.ts +1 -1
- package/dist/http/index.d.ts +4 -4
- package/dist/http/index.js +4 -4
- package/dist/http/response.d.ts +1 -1
- package/dist/http/stream-until-terminal.d.ts +22 -8
- package/dist/http/stream-until-terminal.js +17 -9
- package/dist/http/streamable.d.ts +63 -7
- package/dist/http/streamable.js +277 -119
- package/dist/index.d.ts +65 -65
- package/dist/index.js +53 -53
- package/dist/live/schema.js +1 -1
- package/dist/live/session.d.ts +3 -3
- package/dist/live/session.js +2 -2
- package/dist/proxy/express.d.ts +1 -1
- package/dist/proxy/express.js +1 -1
- package/dist/proxy/hono.d.ts +1 -1
- package/dist/proxy/hono.js +1 -1
- package/dist/proxy/index.js +0 -2
- package/dist/proxy/nextjs.d.ts +3 -3
- package/dist/proxy/nextjs.js +2 -2
- package/dist/proxy/remix.d.ts +1 -1
- package/dist/proxy/remix.js +1 -1
- package/dist/proxy/svelte.d.ts +1 -1
- package/dist/proxy/svelte.js +1 -1
- package/dist/tool-builder.d.ts +1 -1
- package/dist/tool-builder.js +1 -1
- package/dist/types.d.ts +182 -41
- package/dist/types.js +33 -9
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/package.json +2 -1
package/dist/api/agents.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { streamUntilTerminal } from '../http/stream-until-terminal';
|
|
2
|
-
import { PollManager } from '../http/poll';
|
|
3
|
-
import { createLLMDeltaAccumulator } from '../delta';
|
|
4
|
-
import { ToolTypeClient, ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress, } from '../types';
|
|
5
|
-
import { isChatBusy, isMessageTerminal } from '../utils';
|
|
1
|
+
import { streamUntilTerminal } from '../http/stream-until-terminal.js';
|
|
2
|
+
import { PollManager } from '../http/poll.js';
|
|
3
|
+
import { createLLMDeltaAccumulator } from '../delta.js';
|
|
4
|
+
import { ToolTypeClient, ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress, } from '../types.js';
|
|
5
|
+
import { isChatBusy, isMessageTerminal } from '../utils.js';
|
|
6
6
|
/**
|
|
7
7
|
* Decides when one sendMessage() turn is over.
|
|
8
8
|
*
|
|
@@ -90,7 +90,6 @@ export class Agent {
|
|
|
90
90
|
chat_id: this.chatId ?? undefined,
|
|
91
91
|
context: this.context,
|
|
92
92
|
input,
|
|
93
|
-
channel_context: options.channel_context,
|
|
94
93
|
...(isTemplate
|
|
95
94
|
? { agent: this.config }
|
|
96
95
|
: {
|
|
@@ -173,11 +172,17 @@ export class Agent {
|
|
|
173
172
|
await this.http.request('post', `/chats/${this.chatId}/stop`);
|
|
174
173
|
}
|
|
175
174
|
/**
|
|
176
|
-
* Submit a tool result
|
|
175
|
+
* Submit a tool result. `attachments` are files uploaded with POST /files
|
|
176
|
+
* (`files.upload`) that the tool returns; images reach the model as image
|
|
177
|
+
* input when it supports images.
|
|
177
178
|
*/
|
|
178
|
-
async submitToolResult(toolInvocationId, resultOrAction) {
|
|
179
|
+
async submitToolResult(toolInvocationId, resultOrAction, attachments) {
|
|
179
180
|
const result = typeof resultOrAction === 'string' ? resultOrAction : JSON.stringify(resultOrAction);
|
|
180
|
-
|
|
181
|
+
const data = { result };
|
|
182
|
+
if (attachments && attachments.length > 0) {
|
|
183
|
+
data.attachments = attachments;
|
|
184
|
+
}
|
|
185
|
+
await this.http.request('post', `/tools/${toolInvocationId}`, { data });
|
|
181
186
|
}
|
|
182
187
|
/** Stop streaming/polling and cleanup */
|
|
183
188
|
disconnect() {
|
|
@@ -243,6 +248,43 @@ export class Agent {
|
|
|
243
248
|
// the delta names, so a tool-call-only turn never shows the previous
|
|
244
249
|
// message's text. Same attribution rule as the React hooks.
|
|
245
250
|
const deltaAccums = new Map();
|
|
251
|
+
const observeMessage = (message) => {
|
|
252
|
+
// A terminal message receives no further deltas.
|
|
253
|
+
if (isMessageTerminal(message.status))
|
|
254
|
+
deltaAccums.delete(message.id);
|
|
255
|
+
gate.observeMessage(message);
|
|
256
|
+
options.onMessage?.(message);
|
|
257
|
+
if (idlePending && gate.settled)
|
|
258
|
+
settle.resolve();
|
|
259
|
+
if (message.tool_invocations && options.onToolCall) {
|
|
260
|
+
for (const inv of message.tool_invocations) {
|
|
261
|
+
if (this.dispatchedToolCalls.has(inv.id))
|
|
262
|
+
continue;
|
|
263
|
+
if (inv.type === ToolTypeClient && (inv.status === ToolInvocationStatusInProgress || inv.status === ToolInvocationStatusAwaitingInput)) {
|
|
264
|
+
this.dispatchedToolCalls.add(inv.id);
|
|
265
|
+
options.onToolCall({
|
|
266
|
+
id: inv.id,
|
|
267
|
+
name: inv.function?.name || '',
|
|
268
|
+
args: inv.function?.arguments || {},
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
// The chat and its latest messages as the API has them now: what a
|
|
275
|
+
// dropped stream missed, or whether a closed stream's turn is over.
|
|
276
|
+
// Messages first, so this turn's terminal message can gate the idle chat.
|
|
277
|
+
const resync = async () => {
|
|
278
|
+
// Deltas sent while disconnected are gone; the messages replace them.
|
|
279
|
+
deltaAccums.clear();
|
|
280
|
+
const [{ data: chat }, { data: page }] = await Promise.all([
|
|
281
|
+
this.http.request('get', `/chats/${chatId}`),
|
|
282
|
+
this.http.request('get', `/chats/${chatId}/messages`),
|
|
283
|
+
]);
|
|
284
|
+
for (const message of page?.items ?? [])
|
|
285
|
+
observeMessage(message);
|
|
286
|
+
observeChat(chat);
|
|
287
|
+
};
|
|
246
288
|
return {
|
|
247
289
|
request: (init) => this.http.fetch(`/chats/${chatId}/stream`, init),
|
|
248
290
|
events: {
|
|
@@ -264,36 +306,11 @@ export class Agent {
|
|
|
264
306
|
seq: evt.seq,
|
|
265
307
|
});
|
|
266
308
|
},
|
|
267
|
-
chat_messages: (message) =>
|
|
268
|
-
// A terminal message receives no further deltas.
|
|
269
|
-
if (isMessageTerminal(message.status))
|
|
270
|
-
deltaAccums.delete(message.id);
|
|
271
|
-
gate.observeMessage(message);
|
|
272
|
-
options.onMessage?.(message);
|
|
273
|
-
if (idlePending && gate.settled)
|
|
274
|
-
settle.resolve();
|
|
275
|
-
if (message.tool_invocations && options.onToolCall) {
|
|
276
|
-
for (const inv of message.tool_invocations) {
|
|
277
|
-
if (this.dispatchedToolCalls.has(inv.id))
|
|
278
|
-
continue;
|
|
279
|
-
if (inv.type === ToolTypeClient && (inv.status === ToolInvocationStatusInProgress || inv.status === ToolInvocationStatusAwaitingInput)) {
|
|
280
|
-
this.dispatchedToolCalls.add(inv.id);
|
|
281
|
-
options.onToolCall({
|
|
282
|
-
id: inv.id,
|
|
283
|
-
name: inv.function?.name || '',
|
|
284
|
-
args: inv.function?.arguments || {},
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
},
|
|
309
|
+
chat_messages: (message) => observeMessage(message),
|
|
290
310
|
},
|
|
291
311
|
// The stream closed before the chat was seen idle: the chat itself
|
|
292
|
-
// says whether the turn is over.
|
|
293
|
-
reconcile:
|
|
294
|
-
const { data: chat } = await this.http.request('get', `/chats/${chatId}`);
|
|
295
|
-
observeChat(chat);
|
|
296
|
-
},
|
|
312
|
+
// says whether the turn is over. A reconnect resyncs the same way.
|
|
313
|
+
reconcile: resync,
|
|
297
314
|
closedMessage: 'Chat stream closed before the chat became idle',
|
|
298
315
|
// Stopped by disconnect()/abort or replaced by a newer stream: the
|
|
299
316
|
// caller stopped waiting on purpose.
|
|
@@ -485,11 +502,17 @@ export class AgentsAPI {
|
|
|
485
502
|
return new Agent(this.http, this.files, config, options);
|
|
486
503
|
}
|
|
487
504
|
/**
|
|
488
|
-
* Submit a tool result
|
|
505
|
+
* Submit a tool result. `attachments` are files uploaded with POST /files
|
|
506
|
+
* (`files.upload`) that the tool returns; images reach the model as image
|
|
507
|
+
* input when it supports images.
|
|
489
508
|
*/
|
|
490
|
-
async submitToolResult(toolInvocationId, resultOrAction) {
|
|
509
|
+
async submitToolResult(toolInvocationId, resultOrAction, attachments) {
|
|
491
510
|
const result = typeof resultOrAction === 'string' ? resultOrAction : JSON.stringify(resultOrAction);
|
|
492
|
-
|
|
511
|
+
const data = { result };
|
|
512
|
+
if (attachments && attachments.length > 0) {
|
|
513
|
+
data.attachments = attachments;
|
|
514
|
+
}
|
|
515
|
+
await this.http.request('post', `/tools/${toolInvocationId}`, { data });
|
|
493
516
|
}
|
|
494
517
|
/**
|
|
495
518
|
* Resolve an interrupt gate on an agent run.
|
package/dist/api/api-keys.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { ApiKeyDTO, CreateApiKeyRequest, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { ApiKeyDTO, CreateApiKeyRequest, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* API Keys API
|
|
6
6
|
*/
|
package/dist/api/apps.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { AppPatchBody, AppUpdateBody } from './write-bodies';
|
|
4
|
-
import { AppDTO as App, AppVersionDTO, CursorListRequest, CursorListResponse, LicenseRecordDTO } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { AppPatchBody, AppUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { AppDTO as App, AppVersionDTO, CursorListRequest, CursorListResponse, LicenseRecordDTO } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Apps API
|
|
7
7
|
*/
|
package/dist/api/artifacts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { ArtifactDTO, ArtifactVersionDTO, ArtifactCreateRequest, ArtifactUpdateRequest, ArtifactPublishRequest, ArtifactContentResponse, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { ArtifactDTO, ArtifactVersionDTO, ArtifactCreateRequest, ArtifactUpdateRequest, ArtifactPublishRequest, ArtifactContentResponse, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Artifacts API — small self-contained HTML/Markdown pages published to a
|
|
6
6
|
* URL, versioned, permissioned, and shareable.
|
package/dist/api/chats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { ChatUpdateBody } from './write-bodies';
|
|
4
|
-
import { ChatDTO as Chat, ChatMessageDTO, ChatSettingsDTO, ChatSettingsRequest, ChatTraceDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { ChatUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { ChatDTO as Chat, ChatMessageDTO, ChatSettingsDTO, ChatSettingsRequest, ChatTraceDTO, CursorListRequest, CursorListResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Chats API
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { CheckRequirementsRequest, CheckRequirementsResponse, CredentialDTO, CredentialConfigDTO, CredentialConnectRequest, CredentialConnectResponse, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { CheckRequirementsRequest, CheckRequirementsResponse, CredentialDTO, CredentialConfigDTO, CredentialConnectRequest, CredentialConnectResponse, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Credentials API: the accounts and keys a team has connected to external services.
|
|
6
6
|
*/
|
package/dist/api/engines.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { EngineUpdateBody } from './write-bodies';
|
|
4
|
-
import { EngineDTO as Engine, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { EngineUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { EngineDTO as Engine, CursorListRequest, CursorListResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Engines API
|
|
7
7
|
*/
|
package/dist/api/files.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { FileDTO as File, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { FileDTO as File, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
export interface UploadFileOptions {
|
|
5
5
|
filename?: string;
|
|
6
6
|
contentType?: string;
|
package/dist/api/flow-runs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { FlowRunDTO as FlowRun, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { FlowRunDTO as FlowRun, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Flow Runs API
|
|
6
6
|
*/
|
package/dist/api/flows.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { FlowPatchBody, FlowUpdateBody, FlowViewportBody } from './write-bodies';
|
|
4
|
-
import { FlowDTO as Flow, FlowVersionDTO, AppDTO as App, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { FlowPatchBody, FlowUpdateBody, FlowViewportBody } from './write-bodies.js';
|
|
4
|
+
import { FlowDTO as Flow, FlowVersionDTO, AppDTO as App, CursorListRequest, CursorListResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Flows API
|
|
7
7
|
*/
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { TasksAPI, createTasksAPI, type RunOptions } from './tasks';
|
|
2
|
-
export { FilesAPI, createFilesAPI, type UploadFileOptions } from './files';
|
|
3
|
-
export { AgentsAPI, createAgentsAPI, Agent, type AgentOptions, type SendMessageOptions, type AgentRunOptions } from './agents';
|
|
4
|
-
export { SessionsAPI, createSessionsAPI } from './sessions';
|
|
1
|
+
export { TasksAPI, createTasksAPI, type RunOptions } from './tasks.js';
|
|
2
|
+
export { FilesAPI, createFilesAPI, type UploadFileOptions } from './files.js';
|
|
3
|
+
export { AgentsAPI, createAgentsAPI, Agent, type AgentOptions, type SendMessageOptions, type AgentRunOptions } from './agents.js';
|
|
4
|
+
export { SessionsAPI, createSessionsAPI } from './sessions.js';
|
package/dist/api/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { TasksAPI, createTasksAPI } from './tasks';
|
|
2
|
-
export { FilesAPI, createFilesAPI } from './files';
|
|
3
|
-
export { AgentsAPI, createAgentsAPI, Agent } from './agents';
|
|
4
|
-
export { SessionsAPI, createSessionsAPI } from './sessions';
|
|
1
|
+
export { TasksAPI, createTasksAPI } from './tasks.js';
|
|
2
|
+
export { FilesAPI, createFilesAPI } from './files.js';
|
|
3
|
+
export { AgentsAPI, createAgentsAPI, Agent } from './agents.js';
|
|
4
|
+
export { SessionsAPI, createSessionsAPI } from './sessions.js';
|
package/dist/api/knowledge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { KnowledgeUpdateBody } from './write-bodies';
|
|
4
|
-
import { KnowledgeDTO, KnowledgeVersionDTO, KnowledgeCreateRequest, SkillDTO, SkillVersionDTO, CursorListRequest, CursorListResponse, PublicSkillStoreDTO } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { KnowledgeUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { KnowledgeDTO, KnowledgeVersionDTO, KnowledgeCreateRequest, SkillDTO, SkillVersionDTO, CursorListRequest, CursorListResponse, PublicSkillStoreDTO } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Knowledge API
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { MCPServerUpdateBody } from './write-bodies';
|
|
4
|
-
import { MCPServerDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { MCPServerUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { MCPServerDTO, CursorListRequest, CursorListResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* MCP Servers API
|
|
7
7
|
*/
|
package/dist/api/projects.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { ProjectWriteBody } from './write-bodies';
|
|
4
|
-
import { ProjectDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { ProjectWriteBody } from './write-bodies.js';
|
|
4
|
+
import { ProjectDTO, CursorListRequest, CursorListResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Projects API
|
|
7
7
|
*/
|
package/dist/api/search.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { SuggestRequest, SuggestResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { SuggestRequest, SuggestResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Search API
|
|
6
6
|
*/
|
package/dist/api/secrets.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { SecretDTO, SecretCreateRequest, SecretUpdateRequest, CursorListRequest, CursorListResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { SecretDTO, SecretCreateRequest, SecretUpdateRequest, CursorListRequest, CursorListResponse } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Secrets API
|
|
6
6
|
*/
|
package/dist/api/sessions.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sessions API - namespaced session operations.
|
|
3
3
|
*/
|
|
4
|
-
import { HttpClient } from '../http/client';
|
|
5
|
-
import type { Response } from '../http/response';
|
|
6
|
-
import { AppSessionDTO } from '../types';
|
|
4
|
+
import { HttpClient } from '../http/client.js';
|
|
5
|
+
import type { Response } from '../http/response.js';
|
|
6
|
+
import { AppSessionDTO } from '../types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Sessions API for managing stateful worker leases.
|
|
9
9
|
*
|
package/dist/api/sockets.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { LiveSession, type LiveHandlers, type WebSocketConstructor } from '../live/session';
|
|
4
|
-
import type { JsonSchema } from '../live/schema';
|
|
5
|
-
import { CursorListRequest, CursorListResponse, SocketAccess, SocketDTO, TaskDTO as Task } from '../types';
|
|
6
|
-
import type { TasksAPI } from './tasks';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { LiveSession, type LiveHandlers, type WebSocketConstructor } from '../live/session.js';
|
|
4
|
+
import type { JsonSchema } from '../live/schema.js';
|
|
5
|
+
import { CursorListRequest, CursorListResponse, SocketAccess, SocketDTO, TaskDTO as Task } from '../types.js';
|
|
6
|
+
import type { TasksAPI } from './tasks.js';
|
|
7
7
|
/** What identifies the socket to open: the run response (which carries the access), a task, or a task id. */
|
|
8
8
|
export type SocketTarget = (Pick<Task, 'id' | 'status'> & {
|
|
9
9
|
socket?: SocketAccess;
|
package/dist/api/sockets.js
CHANGED
package/dist/api/tasks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import { TaskDTO as Task, TaskLogsDTO, TaskTimingsDTO, ApiAppRunRequest, TaskResultDTO, CursorListRequest, CursorListResponse, TaskFileDTO, DeleteTaskFilesResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import { TaskDTO as Task, TaskLogsDTO, TaskTimingsDTO, ApiAppRunRequest, TaskResultDTO, CursorListRequest, CursorListResponse, TaskFileDTO, DeleteTaskFilesResponse } from '../types.js';
|
|
4
4
|
/** How to follow a task while it runs; see TasksAPI.watch. */
|
|
5
5
|
export interface WatchOptions {
|
|
6
6
|
/** Callback for real-time status updates */
|
package/dist/api/tasks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { streamUntilTerminal } from '../http/stream-until-terminal';
|
|
2
|
-
import { PollManager } from '../http/poll';
|
|
3
|
-
import { TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, } from '../types';
|
|
4
|
-
import { parseStatus } from '../utils';
|
|
1
|
+
import { streamUntilTerminal } from '../http/stream-until-terminal.js';
|
|
2
|
+
import { PollManager } from '../http/poll.js';
|
|
3
|
+
import { TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, } from '../types.js';
|
|
4
|
+
import { parseStatus } from '../utils.js';
|
|
5
5
|
//TODO: This is ugly...
|
|
6
6
|
function stripTask(task) {
|
|
7
7
|
return {
|
package/dist/api/teams.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient } from '../http/client';
|
|
2
|
-
import type { Response } from '../http/response';
|
|
3
|
-
import type { TeamUpdateBody } from './write-bodies';
|
|
4
|
-
import { MeResponse, TeamDTO, TeamMemberDTO, TeamInviteDTO, TeamCreateRequest, TeamMemberAddRequest, TeamInviteCreateRequest, AvailabilityResponse } from '../types';
|
|
1
|
+
import { HttpClient } from '../http/client.js';
|
|
2
|
+
import type { Response } from '../http/response.js';
|
|
3
|
+
import type { TeamUpdateBody } from './write-bodies.js';
|
|
4
|
+
import { MeResponse, TeamDTO, TeamMemberDTO, TeamInviteDTO, TeamCreateRequest, TeamMemberAddRequest, TeamInviteCreateRequest, AvailabilityResponse } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Teams API
|
|
7
7
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* chats, engines and teams send PATCH; apps.patch and flows.patch are the
|
|
13
13
|
* partial siblings of the POST updates that also edit a version.
|
|
14
14
|
*/
|
|
15
|
-
import type { AgentConfigInput, AgentImages, AppDTO, ChatDTO, EngineDTO, FlowDTO, FlowVersionDTO, KnowledgeDTO, MCPServerAuthType, ProjectDTO, TeamDTO, Visibility } from '../types';
|
|
15
|
+
import type { AgentConfigInput, AgentImages, AppDTO, ChatDTO, EngineDTO, FlowDTO, FlowVersionDTO, KnowledgeDTO, MCPServerAuthType, ProjectDTO, TeamDTO, Visibility } from '../types.js';
|
|
16
16
|
/**
|
|
17
17
|
* POST /agents/{id}. Visibility and images, and a new version when
|
|
18
18
|
* `version` is set. Name, title, harness, placement: set at creation.
|
package/dist/delta.d.ts
CHANGED
package/dist/delta.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMDelta_fieldTags, ToolCallDelta_fieldTags, ToolCallFunctionDelta_fieldTags, MergeStrategyConcat, MergeStrategyIndexed, MergeStrategyNested, MergeStrategyReplace, } from './types';
|
|
1
|
+
import { LLMDelta_fieldTags, ToolCallDelta_fieldTags, ToolCallFunctionDelta_fieldTags, MergeStrategyConcat, MergeStrategyIndexed, MergeStrategyNested, MergeStrategyReplace, } from './types.js';
|
|
2
2
|
function mergeField(current, incoming, strategy, childTags, registry) {
|
|
3
3
|
if (incoming == null)
|
|
4
4
|
return current;
|
package/dist/hook-builder.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook Builder - Fluent API for defining lifecycle hooks
|
|
3
3
|
*/
|
|
4
|
-
import { LifecycleHookConfig, HookEvent, BuiltinHook } from './types';
|
|
4
|
+
import { LifecycleHookConfig, HookEvent, BuiltinHook } from './types.js';
|
|
5
5
|
export declare class LifecycleHookBuilder {
|
|
6
6
|
private event;
|
|
7
7
|
private handlerType;
|
package/dist/hook-builder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook Builder - Fluent API for defining lifecycle hooks
|
|
3
3
|
*/
|
|
4
|
-
import { HookHandlerWebhook, HookHandlerTask, HookHandlerBuiltin, BuiltinHookBeltSuggest, BuiltinHookBeltExtract, HookEventTurnStart, HookEventAgentComplete, HookEventPreCompact, } from './types';
|
|
4
|
+
import { HookHandlerWebhook, HookHandlerTask, HookHandlerBuiltin, BuiltinHookBeltSuggest, BuiltinHookBeltExtract, HookEventTurnStart, HookEventAgentComplete, HookEventPreCompact, } from './types.js';
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// Hook Builder
|
|
7
7
|
// =============================================================================
|
package/dist/http/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Response } from './response';
|
|
1
|
+
import type { Response } from './response.js';
|
|
2
2
|
import { EventSource } from 'eventsource';
|
|
3
3
|
/** What a failed request was sent with, for an error handler that acts on it. */
|
|
4
4
|
export interface FailedRequest {
|
|
@@ -21,7 +21,7 @@ export type ErrorHandler = (error: unknown, retry: () => Promise<unknown>, reque
|
|
|
21
21
|
export type HttpFetchInit = Omit<RequestInit, 'headers' | 'credentials'> & {
|
|
22
22
|
headers?: Record<string, string>;
|
|
23
23
|
};
|
|
24
|
-
export type MessageHandler = (messages: import('../types').ResponseMessage[]) => void;
|
|
24
|
+
export type MessageHandler = (messages: import('../types.js').ResponseMessage[]) => void;
|
|
25
25
|
export interface HttpClientConfig {
|
|
26
26
|
/** Your inference.sh API key (required unless using proxyUrl) */
|
|
27
27
|
apiKey?: string;
|
package/dist/http/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InferenceError, RequirementsNotMetException } from './errors';
|
|
1
|
+
import { InferenceError, RequirementsNotMetException } from './errors.js';
|
|
2
2
|
import { EventSource } from 'eventsource';
|
|
3
|
-
import { SDK_VERSION } from '../version';
|
|
3
|
+
import { SDK_VERSION } from '../version.js';
|
|
4
4
|
/**
|
|
5
5
|
* Low-level HTTP client for inference.sh API
|
|
6
6
|
*
|
package/dist/http/errors.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Note: types.ts contains interfaces (APIError, RequirementsNotMetError) that describe
|
|
5
5
|
* the API response data shapes. These classes are throwable Error subclasses for SDK use.
|
|
6
6
|
*/
|
|
7
|
-
import type { RequirementError } from '../types';
|
|
7
|
+
import type { RequirementError } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* General HTTP/API error thrown by the SDK.
|
|
10
10
|
*
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HttpClient, type HttpClientConfig, type ErrorHandler, type FailedRequest, type HttpFetchInit, createHttpClient } from './client';
|
|
2
|
-
export { StreamManager, type StreamManagerOptions, type PartialDataWrapper } from './stream';
|
|
3
|
-
export { streamable, streamableRaw, StreamableManager, type StreamableOptions, type StreamableMessage, type StreamableManagerOptions, type StreamableSource, type StreamRequest, type StreamRequestInit } from './streamable';
|
|
4
|
-
export { InferenceError, RequirementsNotMetException } from './errors';
|
|
1
|
+
export { HttpClient, type HttpClientConfig, type ErrorHandler, type FailedRequest, type HttpFetchInit, createHttpClient } from './client.js';
|
|
2
|
+
export { StreamManager, type StreamManagerOptions, type PartialDataWrapper } from './stream.js';
|
|
3
|
+
export { streamable, streamableRaw, StreamableManager, type StreamableOptions, type StreamableMessage, type StreamableManagerOptions, type StreamReconnectOptions, type StreamableSource, type StreamRequest, type StreamRequestInit } from './streamable.js';
|
|
4
|
+
export { InferenceError, RequirementsNotMetException } from './errors.js';
|
package/dist/http/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HttpClient, createHttpClient } from './client';
|
|
2
|
-
export { StreamManager } from './stream';
|
|
3
|
-
export { streamable, streamableRaw, StreamableManager } from './streamable';
|
|
4
|
-
export { InferenceError, RequirementsNotMetException } from './errors';
|
|
1
|
+
export { HttpClient, createHttpClient } from './client.js';
|
|
2
|
+
export { StreamManager } from './stream.js';
|
|
3
|
+
export { streamable, streamableRaw, StreamableManager } from './streamable.js';
|
|
4
|
+
export { InferenceError, RequirementsNotMetException } from './errors.js';
|
package/dist/http/response.d.ts
CHANGED
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
* Follow a resource's NDJSON stream until the resource reaches a terminal
|
|
3
3
|
* state.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* The stream reconnects after a network failure or a silent connection
|
|
6
|
+
* (StreamableManager `reconnect`, on by default here). The API does not
|
|
7
|
+
* replay what a dropped stream missed, so every reconnect fetches the
|
|
8
|
+
* resource (`resync`, default `reconcile`) before reading on; a resource
|
|
9
|
+
* that finished meanwhile settles the wait.
|
|
10
|
+
*
|
|
11
|
+
* A stream can also close cleanly before the resource is done (load balancer
|
|
12
|
+
* idle timeout, API deploy). A wait built on it must not hang then. This
|
|
13
|
+
* helper owns that contract for every "stream until done" wait: when the
|
|
14
|
+
* stream ends early it fetches the resource once (`reconcile`) and settles
|
|
15
|
+
* with what that shows, or rejects when the resource is still not terminal.
|
|
16
|
+
* sdk-py's `wait_for_completion` does the same final GET. The wait rejects
|
|
17
|
+
* with the stream's error once it stops retrying.
|
|
12
18
|
*/
|
|
13
|
-
import { type StreamableManagerOptions, type StreamRequest } from './streamable';
|
|
19
|
+
import { type StreamableManagerOptions, type StreamReconnectOptions, type StreamRequest } from './streamable.js';
|
|
14
20
|
/** Settles a stream-until-terminal wait. Calls after the first are ignored. */
|
|
15
21
|
export interface TerminalSettler<R> {
|
|
16
22
|
resolve(value: R): void;
|
|
@@ -28,6 +34,14 @@ export type StreamUntilTerminalSpec<T> = Pick<StreamableManagerOptions<T>, 'body
|
|
|
28
34
|
* rejects the wait with `closedMessage`.
|
|
29
35
|
*/
|
|
30
36
|
reconcile: () => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Called after the stream reconnected, before it is read again: fetch the
|
|
39
|
+
* resource and report it, settling if it is terminal (default `reconcile`).
|
|
40
|
+
* A rejection counts as a failed reconnect attempt.
|
|
41
|
+
*/
|
|
42
|
+
resync?: () => Promise<void>;
|
|
43
|
+
/** How the stream reconnects (default true: StreamReconnectOptions defaults); false fails the wait on the first error. */
|
|
44
|
+
reconnect?: boolean | StreamReconnectOptions;
|
|
31
45
|
/** Rejection message when the stream closed and the resource is still not terminal. */
|
|
32
46
|
closedMessage: string;
|
|
33
47
|
/**
|
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
* Follow a resource's NDJSON stream until the resource reaches a terminal
|
|
3
3
|
* state.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* The stream reconnects after a network failure or a silent connection
|
|
6
|
+
* (StreamableManager `reconnect`, on by default here). The API does not
|
|
7
|
+
* replay what a dropped stream missed, so every reconnect fetches the
|
|
8
|
+
* resource (`resync`, default `reconcile`) before reading on; a resource
|
|
9
|
+
* that finished meanwhile settles the wait.
|
|
10
|
+
*
|
|
11
|
+
* A stream can also close cleanly before the resource is done (load balancer
|
|
12
|
+
* idle timeout, API deploy). A wait built on it must not hang then. This
|
|
13
|
+
* helper owns that contract for every "stream until done" wait: when the
|
|
14
|
+
* stream ends early it fetches the resource once (`reconcile`) and settles
|
|
15
|
+
* with what that shows, or rejects when the resource is still not terminal.
|
|
16
|
+
* sdk-py's `wait_for_completion` does the same final GET. The wait rejects
|
|
17
|
+
* with the stream's error once it stops retrying.
|
|
12
18
|
*/
|
|
13
|
-
import { StreamableManager } from './streamable';
|
|
19
|
+
import { StreamableManager } from './streamable.js';
|
|
14
20
|
/**
|
|
15
21
|
* `build` receives the settler and returns the stream spec; its handlers call
|
|
16
22
|
* `settle.resolve`/`settle.reject` once the resource is terminal. Settling
|
|
@@ -39,10 +45,12 @@ export function streamUntilTerminal(build) {
|
|
|
39
45
|
reject(error);
|
|
40
46
|
},
|
|
41
47
|
};
|
|
42
|
-
const { events, reconcile, closedMessage, onStopped, keepOpen, ...managerOptions } = build(settle);
|
|
48
|
+
const { events, reconcile, resync = reconcile, reconnect = true, closedMessage, onStopped, keepOpen, ...managerOptions } = build(settle);
|
|
43
49
|
let streamError = null;
|
|
44
50
|
manager = new StreamableManager({
|
|
45
51
|
...managerOptions,
|
|
52
|
+
reconnect,
|
|
53
|
+
onReconnect: () => resync(),
|
|
46
54
|
onError: (error) => {
|
|
47
55
|
streamError = error;
|
|
48
56
|
},
|