@inferencesh/sdk 0.6.21 → 0.6.26
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 +9 -12
- package/dist/api/agents.js +5 -3
- package/dist/api/files.d.ts +19 -0
- package/dist/api/files.js +62 -57
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +75 -5
- package/dist/types.js +15 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +5 -1
- package/package.json +6 -1
package/dist/agent/actions.js
CHANGED
|
@@ -4,27 +4,25 @@
|
|
|
4
4
|
* Action creators that handle side effects (API calls, streaming).
|
|
5
5
|
* These are created once per provider instance with access to dispatch.
|
|
6
6
|
*/
|
|
7
|
-
import { ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress, ToolTypeClient,
|
|
7
|
+
import { ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress, ToolTypeClient, } from '../types';
|
|
8
|
+
import { isChatBusy } from '../utils';
|
|
8
9
|
import { StreamableManager } from '../http/streamable';
|
|
9
10
|
import { PollManager } from '../http/poll';
|
|
10
11
|
import { isAdHocConfig, extractClientToolHandlers } from './types';
|
|
11
12
|
import * as api from './api';
|
|
12
13
|
// =============================================================================
|
|
13
|
-
// Track dispatched client tool invocations to prevent duplicates
|
|
14
|
-
// =============================================================================
|
|
15
|
-
const dispatchedToolInvocations = new Set();
|
|
16
|
-
// =============================================================================
|
|
17
14
|
// Action Creators
|
|
18
15
|
// =============================================================================
|
|
19
16
|
export function createActions(ctx) {
|
|
17
|
+
const dispatchedToolInvocations = new Set();
|
|
20
18
|
const { client, dispatch, getConfig, getChatId, getClientToolHandlers, getStreamManager, setStreamManager, getStreamEnabled, getPollIntervalMs, callbacks } = ctx;
|
|
21
19
|
let prevChatWasBusy = false;
|
|
22
20
|
const checkTurnEnd = (chat) => {
|
|
23
|
-
const
|
|
24
|
-
if (prevChatWasBusy && !
|
|
21
|
+
const busy = isChatBusy(chat);
|
|
22
|
+
if (prevChatWasBusy && !busy) {
|
|
25
23
|
callbacks.onTurnEnd?.(chat);
|
|
26
24
|
}
|
|
27
|
-
prevChatWasBusy =
|
|
25
|
+
prevChatWasBusy = busy;
|
|
28
26
|
};
|
|
29
27
|
// =========================================================================
|
|
30
28
|
// Internal helpers
|
|
@@ -32,8 +30,7 @@ export function createActions(ctx) {
|
|
|
32
30
|
const setChat = (chat) => {
|
|
33
31
|
dispatch({ type: 'SET_CHAT', payload: chat });
|
|
34
32
|
if (chat) {
|
|
35
|
-
|
|
36
|
-
callbacks.onStatusChange?.(status);
|
|
33
|
+
callbacks.onStatusChange?.(isChatBusy(chat) ? 'streaming' : 'idle');
|
|
37
34
|
checkTurnEnd(chat);
|
|
38
35
|
}
|
|
39
36
|
};
|
|
@@ -136,8 +133,7 @@ export function createActions(ctx) {
|
|
|
136
133
|
manager.addEventListener('chats', (chatData) => {
|
|
137
134
|
dispatch({ type: 'UPDATE_CHAT', payload: chatData });
|
|
138
135
|
if (chatData) {
|
|
139
|
-
|
|
140
|
-
callbacks.onStatusChange?.(status);
|
|
136
|
+
callbacks.onStatusChange?.(isChatBusy(chatData) ? 'streaming' : 'idle');
|
|
141
137
|
checkTurnEnd(chatData);
|
|
142
138
|
}
|
|
143
139
|
});
|
|
@@ -218,6 +214,7 @@ export function createActions(ctx) {
|
|
|
218
214
|
const trimmedText = text.trim();
|
|
219
215
|
if (!trimmedText)
|
|
220
216
|
return;
|
|
217
|
+
dispatchedToolInvocations.clear();
|
|
221
218
|
// Update status
|
|
222
219
|
dispatch({ type: 'SET_CONNECTION_STATUS', payload: 'streaming' });
|
|
223
220
|
dispatch({ type: 'SET_ERROR', payload: undefined });
|
package/dist/api/agents.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StreamableManager } from '../http/streamable';
|
|
2
2
|
import { PollManager } from '../http/poll';
|
|
3
|
-
import { ToolTypeClient, ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress,
|
|
3
|
+
import { ToolTypeClient, ToolInvocationStatusAwaitingInput, ToolInvocationStatusInProgress, } from '../types';
|
|
4
|
+
import { isChatBusy } from '../utils';
|
|
4
5
|
/**
|
|
5
6
|
* Agent for chat interactions
|
|
6
7
|
*
|
|
@@ -25,6 +26,7 @@ export class Agent {
|
|
|
25
26
|
}
|
|
26
27
|
/** Send a message to the agent */
|
|
27
28
|
async sendMessage(text, options = {}) {
|
|
29
|
+
this.dispatchedToolCalls.clear();
|
|
28
30
|
const isTemplate = typeof this.config === 'string';
|
|
29
31
|
const hasCallbacks = !!(options.onMessage || options.onChat || options.onToolCall);
|
|
30
32
|
// Process files - either already uploaded (FileDTO with uri) or needs upload (Blob)
|
|
@@ -156,7 +158,7 @@ export class Agent {
|
|
|
156
158
|
});
|
|
157
159
|
this.stream.addEventListener('chats', (chat) => {
|
|
158
160
|
options.onChat?.(chat);
|
|
159
|
-
if (chat
|
|
161
|
+
if (!isChatBusy(chat)) {
|
|
160
162
|
resolve();
|
|
161
163
|
}
|
|
162
164
|
});
|
|
@@ -234,7 +236,7 @@ export class Agent {
|
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
|
-
if (chat
|
|
239
|
+
if (!isChatBusy(chat)) {
|
|
238
240
|
this.poller?.stop();
|
|
239
241
|
this.poller = null;
|
|
240
242
|
resolve();
|
package/dist/api/files.d.ts
CHANGED
|
@@ -9,6 +9,25 @@ export interface UploadFileOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Files API
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* Everything about a presigned upload except which endpoint mints the record.
|
|
14
|
+
*
|
|
15
|
+
* js/app's platform-media API posts to /admin/media/upload with a category
|
|
16
|
+
* instead of /files, and had re-derived all of this — content type, filename,
|
|
17
|
+
* the PUT, the ok check — losing the data-URI and base64 handling in the
|
|
18
|
+
* process. Splitting the transfer from the create call lets both share one
|
|
19
|
+
* implementation of the part that talks to S3.
|
|
20
|
+
*/
|
|
21
|
+
export interface ResolvedUpload {
|
|
22
|
+
contentType: string;
|
|
23
|
+
filename?: string;
|
|
24
|
+
size?: number;
|
|
25
|
+
/** The bytes to PUT, normalised from a Blob, a data URI or bare base64. */
|
|
26
|
+
body: Blob;
|
|
27
|
+
}
|
|
28
|
+
export declare function resolveUpload(data: string | Blob, options?: UploadFileOptions): ResolvedUpload;
|
|
29
|
+
/** PUTs the bytes to a presigned URL and throws on a non-2xx response. */
|
|
30
|
+
export declare function putToSignedUrl(uploadUrl: string, body: Blob): Promise<void>;
|
|
12
31
|
export declare class FilesAPI {
|
|
13
32
|
private readonly http;
|
|
14
33
|
constructor(http: HttpClient);
|
package/dist/api/files.js
CHANGED
|
@@ -37,9 +37,63 @@ function parseDataUri(uri) {
|
|
|
37
37
|
return { mediaType, data: encoder.encode(decoded) };
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const extMimeTypes = {
|
|
41
|
+
jfif: 'image/jpeg', jpe: 'image/jpeg', jpg: 'image/jpeg', jpeg: 'image/jpeg',
|
|
42
|
+
png: 'image/png', gif: 'image/gif', webp: 'image/webp', avif: 'image/avif',
|
|
43
|
+
heic: 'image/heif', heif: 'image/heif', tif: 'image/tiff', tiff: 'image/tiff',
|
|
44
|
+
bmp: 'image/bmp', svg: 'image/svg+xml',
|
|
45
|
+
mp4: 'video/mp4', mov: 'video/quicktime', webm: 'video/webm', mkv: 'video/x-matroska',
|
|
46
|
+
mp3: 'audio/mpeg', wav: 'audio/wav', ogg: 'audio/ogg', flac: 'audio/flac',
|
|
47
|
+
aac: 'audio/aac', m4a: 'audio/mp4',
|
|
48
|
+
pdf: 'application/pdf',
|
|
49
|
+
};
|
|
50
|
+
function mimeFromFilename(name) {
|
|
51
|
+
const ext = name.split('.').pop()?.toLowerCase();
|
|
52
|
+
return ext ? extMimeTypes[ext] : undefined;
|
|
53
|
+
}
|
|
54
|
+
export function resolveUpload(data, options = {}) {
|
|
55
|
+
let filename = options.filename;
|
|
56
|
+
if (!filename && data instanceof globalThis.File) {
|
|
57
|
+
filename = data.name;
|
|
58
|
+
}
|
|
59
|
+
const contentType = options.contentType ||
|
|
60
|
+
(data instanceof Blob ? data.type : data.match(/^data:([^;,]*)[;,]/)?.[1]) ||
|
|
61
|
+
(filename ? mimeFromFilename(filename) : undefined) ||
|
|
62
|
+
'application/octet-stream';
|
|
63
|
+
let body;
|
|
64
|
+
if (data instanceof Blob) {
|
|
65
|
+
body = data;
|
|
66
|
+
}
|
|
67
|
+
else if (data.startsWith('data:')) {
|
|
68
|
+
const parsed = parseDataUri(data);
|
|
69
|
+
body = new Blob([parsed.data.buffer], { type: parsed.mediaType });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const binaryStr = atob(data);
|
|
73
|
+
const bytes = new Uint8Array(binaryStr.length);
|
|
74
|
+
for (let i = 0; i < binaryStr.length; i++) {
|
|
75
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
76
|
+
}
|
|
77
|
+
body = new Blob([bytes.buffer], { type: contentType });
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
contentType,
|
|
81
|
+
filename,
|
|
82
|
+
size: data instanceof Blob ? data.size : undefined,
|
|
83
|
+
body,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** PUTs the bytes to a presigned URL and throws on a non-2xx response. */
|
|
87
|
+
export async function putToSignedUrl(uploadUrl, body) {
|
|
88
|
+
const response = await fetch(uploadUrl, {
|
|
89
|
+
method: 'PUT',
|
|
90
|
+
body,
|
|
91
|
+
headers: { 'Content-Type': body.type || 'application/octet-stream' },
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
throw new Error(`Failed to upload file content: ${response.statusText}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
43
97
|
export class FilesAPI {
|
|
44
98
|
constructor(http) {
|
|
45
99
|
this.http = http;
|
|
@@ -66,33 +120,14 @@ export class FilesAPI {
|
|
|
66
120
|
* Upload a file (Blob or base64 string)
|
|
67
121
|
*/
|
|
68
122
|
async upload(data, options = {}) {
|
|
69
|
-
|
|
70
|
-
let contentType = options.contentType;
|
|
71
|
-
if (!contentType) {
|
|
72
|
-
if (data instanceof Blob) {
|
|
73
|
-
contentType = data.type;
|
|
74
|
-
}
|
|
75
|
-
else if (typeof data === 'string' && data.startsWith('data:')) {
|
|
76
|
-
// Extract media type from data URI
|
|
77
|
-
const match = data.match(/^data:([^;,]*)?/);
|
|
78
|
-
contentType = match?.[1] || 'application/octet-stream';
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
contentType = 'application/octet-stream';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Extract filename from File object if not provided in options
|
|
85
|
-
let filename = options.filename;
|
|
86
|
-
if (!filename && data instanceof globalThis.File) {
|
|
87
|
-
filename = data.name;
|
|
88
|
-
}
|
|
123
|
+
const resolved = resolveUpload(data, options);
|
|
89
124
|
// Step 1: Create the file record
|
|
90
125
|
const fileRequest = {
|
|
91
126
|
uri: '', // Empty URI as it will be set by the server
|
|
92
|
-
filename,
|
|
93
|
-
content_type: contentType,
|
|
127
|
+
filename: resolved.filename,
|
|
128
|
+
content_type: resolved.contentType,
|
|
94
129
|
path: options.path,
|
|
95
|
-
size:
|
|
130
|
+
size: resolved.size,
|
|
96
131
|
};
|
|
97
132
|
const response = await this.http.request('post', '/files', {
|
|
98
133
|
data: { files: [fileRequest] },
|
|
@@ -102,37 +137,7 @@ export class FilesAPI {
|
|
|
102
137
|
if (!file.upload_url) {
|
|
103
138
|
throw new Error('No upload URL provided by the server');
|
|
104
139
|
}
|
|
105
|
-
|
|
106
|
-
if (data instanceof Blob) {
|
|
107
|
-
contentToUpload = data;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// If it's a base64 string, convert it to a Blob
|
|
111
|
-
if (data.startsWith('data:')) {
|
|
112
|
-
const parsed = parseDataUri(data);
|
|
113
|
-
contentToUpload = new Blob([parsed.data.buffer], { type: parsed.mediaType });
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
// Assume it's a clean base64 string
|
|
117
|
-
const binaryStr = atob(data);
|
|
118
|
-
const bytes = new Uint8Array(binaryStr.length);
|
|
119
|
-
for (let i = 0; i < binaryStr.length; i++) {
|
|
120
|
-
bytes[i] = binaryStr.charCodeAt(i);
|
|
121
|
-
}
|
|
122
|
-
contentToUpload = new Blob([bytes.buffer], { type: options.contentType || 'application/octet-stream' });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Upload to S3 using the signed URL
|
|
126
|
-
const uploadResponse = await fetch(file.upload_url, {
|
|
127
|
-
method: 'PUT',
|
|
128
|
-
body: contentToUpload,
|
|
129
|
-
headers: {
|
|
130
|
-
'Content-Type': contentToUpload.type,
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
if (!uploadResponse.ok) {
|
|
134
|
-
throw new Error(`Failed to upload file content: ${uploadResponse.statusText}`);
|
|
135
|
-
}
|
|
140
|
+
await putToSignedUrl(file.upload_url, resolved.body);
|
|
136
141
|
return file;
|
|
137
142
|
}
|
|
138
143
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { ProjectsAPI } from './api/projects';
|
|
|
22
22
|
export { MCPServersAPI } from './api/mcp-servers';
|
|
23
23
|
export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
24
24
|
export type { ClientTool, ClientToolHandler } from './tool-builder';
|
|
25
|
-
export { parseStatus, isTerminalStatus } from './utils';
|
|
25
|
+
export { parseStatus, isTerminalStatus, isChatBusy } from './utils';
|
|
26
26
|
export * from './types';
|
|
27
27
|
export type { TaskDTO as Task } from './types';
|
|
28
28
|
import { HttpClient, type HttpClientConfig } from './http/client';
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export { MCPServersAPI } from './api/mcp-servers';
|
|
|
27
27
|
// Tool Builder (fluent API)
|
|
28
28
|
export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
|
|
29
29
|
// Status utilities (handle both int and string status values)
|
|
30
|
-
export { parseStatus, isTerminalStatus } from './utils';
|
|
30
|
+
export { parseStatus, isTerminalStatus, isChatBusy } from './utils';
|
|
31
31
|
// Types - includes TaskStatus constants and all DTOs
|
|
32
32
|
export * from './types';
|
|
33
33
|
// =============================================================================
|
package/dist/types.d.ts
CHANGED
|
@@ -241,6 +241,20 @@ export interface CoreAppConfigInput {
|
|
|
241
241
|
setup?: any;
|
|
242
242
|
input?: any;
|
|
243
243
|
}
|
|
244
|
+
export interface AgentRunDTO extends BaseModelDTO, PermissionModelDTO {
|
|
245
|
+
agent_id: string;
|
|
246
|
+
agent?: AgentDTO;
|
|
247
|
+
agent_version_id?: string;
|
|
248
|
+
chat_id: string;
|
|
249
|
+
user_message_id?: string;
|
|
250
|
+
state: AgentRunState;
|
|
251
|
+
error?: string;
|
|
252
|
+
interrupt_reason?: InterruptReason;
|
|
253
|
+
interrupt_tool_id?: string;
|
|
254
|
+
interrupt_meta?: any;
|
|
255
|
+
trigger_id?: string;
|
|
256
|
+
metadata?: any;
|
|
257
|
+
}
|
|
244
258
|
export interface APIResponse<T extends any> {
|
|
245
259
|
success: boolean;
|
|
246
260
|
status: number;
|
|
@@ -512,9 +526,7 @@ export interface CreateApiKeyRequest {
|
|
|
512
526
|
* EstimateCostRequest is the request for POST /store/apps/{appId}/estimate.
|
|
513
527
|
*/
|
|
514
528
|
export interface EstimateCostRequest {
|
|
515
|
-
input:
|
|
516
|
-
[key: string]: any;
|
|
517
|
-
};
|
|
529
|
+
input: any;
|
|
518
530
|
function?: string;
|
|
519
531
|
}
|
|
520
532
|
/**
|
|
@@ -1099,6 +1111,27 @@ export interface ResourceStatusDTO {
|
|
|
1099
1111
|
status: any;
|
|
1100
1112
|
updated_at: string;
|
|
1101
1113
|
}
|
|
1114
|
+
/**
|
|
1115
|
+
* AvailabilityResponse answers "can I use this name?" — for page slugs, team
|
|
1116
|
+
* usernames and voucher codes alike.
|
|
1117
|
+
* The three checks had three different shapes, and one of them was an untyped
|
|
1118
|
+
* map[string]bool that generated no client type at all, so each caller invented
|
|
1119
|
+
* its own handling. Reason exists because "not available" was previously
|
|
1120
|
+
* indistinguishable from "reserved": every client that wanted to say why had to
|
|
1121
|
+
* mirror the server's reserved-name list to guess, and those mirrors went stale.
|
|
1122
|
+
*/
|
|
1123
|
+
export interface AvailabilityResponse {
|
|
1124
|
+
/**
|
|
1125
|
+
* Value is the normalized form of what was checked — the server may slugify
|
|
1126
|
+
* or lowercase the input, and the client should show what it actually took.
|
|
1127
|
+
*/
|
|
1128
|
+
value: string;
|
|
1129
|
+
available: boolean;
|
|
1130
|
+
/**
|
|
1131
|
+
* Reason is set only when Available is false: "taken" or "reserved".
|
|
1132
|
+
*/
|
|
1133
|
+
reason?: string;
|
|
1134
|
+
}
|
|
1102
1135
|
/**
|
|
1103
1136
|
* ChatDTO for API responses
|
|
1104
1137
|
*/
|
|
@@ -1119,6 +1152,7 @@ export interface ChatDTO extends BaseModelDTO, PermissionModelDTO {
|
|
|
1119
1152
|
description: string;
|
|
1120
1153
|
chat_messages: ChatMessageDTO[];
|
|
1121
1154
|
agent_data: ChatData;
|
|
1155
|
+
active_run?: AgentRunDTO;
|
|
1122
1156
|
}
|
|
1123
1157
|
/**
|
|
1124
1158
|
* ChatMessageDTO for API responses
|
|
@@ -1126,6 +1160,7 @@ export interface ChatDTO extends BaseModelDTO, PermissionModelDTO {
|
|
|
1126
1160
|
export interface ChatMessageDTO extends BaseModelDTO, PermissionModelDTO {
|
|
1127
1161
|
chat_id: string;
|
|
1128
1162
|
chat?: ChatDTO;
|
|
1163
|
+
agent_run_id?: string;
|
|
1129
1164
|
order: number;
|
|
1130
1165
|
status: ChatMessageStatus;
|
|
1131
1166
|
task_id?: string;
|
|
@@ -1136,10 +1171,10 @@ export interface ChatMessageDTO extends BaseModelDTO, PermissionModelDTO {
|
|
|
1136
1171
|
tool_invocations?: ToolInvocationDTO[];
|
|
1137
1172
|
}
|
|
1138
1173
|
/**
|
|
1139
|
-
* SearchRequest represents a search request
|
|
1174
|
+
* SearchRequest represents a search request.
|
|
1175
|
+
* Each model declares its own SearchFields() on the repository.
|
|
1140
1176
|
*/
|
|
1141
1177
|
export interface SearchRequest {
|
|
1142
|
-
fields: string[];
|
|
1143
1178
|
term: string;
|
|
1144
1179
|
exact: boolean;
|
|
1145
1180
|
}
|
|
@@ -1835,6 +1870,11 @@ export interface PageMetadata {
|
|
|
1835
1870
|
type?: string;
|
|
1836
1871
|
icon?: string;
|
|
1837
1872
|
hide_from_nav?: boolean;
|
|
1873
|
+
/**
|
|
1874
|
+
* PublishAt is when a scheduled page goes live. Only meaningful while the
|
|
1875
|
+
* page's status is PageStatusScheduled.
|
|
1876
|
+
*/
|
|
1877
|
+
publish_at?: string;
|
|
1838
1878
|
}
|
|
1839
1879
|
/**
|
|
1840
1880
|
* MenuItem represents an item in a menu (can be nested)
|
|
@@ -1863,6 +1903,11 @@ export interface PageDTO extends BaseModelDTO, PermissionModelDTO {
|
|
|
1863
1903
|
type: PageType;
|
|
1864
1904
|
metadata: PageMetadata;
|
|
1865
1905
|
slug: string;
|
|
1906
|
+
/**
|
|
1907
|
+
* PublishAt mirrors Metadata.PublishAt, which remains the field clients write.
|
|
1908
|
+
* Surfaced here so a reader does not have to reach into the metadata blob.
|
|
1909
|
+
*/
|
|
1910
|
+
publish_at?: string;
|
|
1866
1911
|
}
|
|
1867
1912
|
/**
|
|
1868
1913
|
* MenuDTO for API responses
|
|
@@ -2684,6 +2729,29 @@ export interface Widget {
|
|
|
2684
2729
|
children?: WidgetNode[];
|
|
2685
2730
|
actions?: WidgetActionButton[];
|
|
2686
2731
|
}
|
|
2732
|
+
/**
|
|
2733
|
+
* AgentRunState tracks the lifecycle of an agent run (one user→agent turn).
|
|
2734
|
+
* Maps to A2A TaskState and AG-UI Run outcome for protocol compliance.
|
|
2735
|
+
*/
|
|
2736
|
+
export type AgentRunState = string;
|
|
2737
|
+
export declare const AgentRunStateSubmitted: AgentRunState;
|
|
2738
|
+
export declare const AgentRunStateWorking: AgentRunState;
|
|
2739
|
+
export declare const AgentRunStateInputRequired: AgentRunState;
|
|
2740
|
+
export declare const AgentRunStateAuthRequired: AgentRunState;
|
|
2741
|
+
export declare const AgentRunStateCompleted: AgentRunState;
|
|
2742
|
+
export declare const AgentRunStateFailed: AgentRunState;
|
|
2743
|
+
export declare const AgentRunStateCanceled: AgentRunState;
|
|
2744
|
+
export declare const AgentRunStateRejected: AgentRunState;
|
|
2745
|
+
/**
|
|
2746
|
+
* InterruptReason describes why an agent run is in an interrupted state.
|
|
2747
|
+
* Aligns with AG-UI interrupt outcome reasons.
|
|
2748
|
+
*/
|
|
2749
|
+
export type InterruptReason = string;
|
|
2750
|
+
export declare const InterruptReasonToolApproval: InterruptReason;
|
|
2751
|
+
export declare const InterruptReasonClientTool: InterruptReason;
|
|
2752
|
+
export declare const InterruptReasonWidget: InterruptReason;
|
|
2753
|
+
export declare const InterruptReasonAuth: InterruptReason;
|
|
2754
|
+
export declare const InterruptReasonConfirmation: InterruptReason;
|
|
2687
2755
|
export type AppCategory = string;
|
|
2688
2756
|
export declare const AppCategoryImage: AppCategory;
|
|
2689
2757
|
export declare const AppCategoryVideo: AppCategory;
|
|
@@ -2854,6 +2922,7 @@ export declare const EngineStatusRunning: EngineStatus;
|
|
|
2854
2922
|
export declare const EngineStatusPending: EngineStatus;
|
|
2855
2923
|
export declare const EngineStatusDraining: EngineStatus;
|
|
2856
2924
|
export declare const EngineStatusDisconnected: EngineStatus;
|
|
2925
|
+
export declare const EngineStatusRestarting: EngineStatus;
|
|
2857
2926
|
export declare const EngineStatusStopping: EngineStatus;
|
|
2858
2927
|
export declare const EngineStatusStopped: EngineStatus;
|
|
2859
2928
|
/**
|
|
@@ -3011,6 +3080,7 @@ export declare const PageStatusUnknown: PageStatus;
|
|
|
3011
3080
|
export declare const PageStatusDraft: PageStatus;
|
|
3012
3081
|
export declare const PageStatusPublished: PageStatus;
|
|
3013
3082
|
export declare const PageStatusArchived: PageStatus;
|
|
3083
|
+
export declare const PageStatusScheduled: PageStatus;
|
|
3014
3084
|
/**
|
|
3015
3085
|
* PageType represents the type of page content
|
|
3016
3086
|
*/
|
package/dist/types.js
CHANGED
|
@@ -261,6 +261,19 @@ export const RequirementTypeScope = "scope";
|
|
|
261
261
|
export const SetupActionAddSecret = "add_secret";
|
|
262
262
|
export const SetupActionConnect = "connect";
|
|
263
263
|
export const SetupActionAddScopes = "add_scopes";
|
|
264
|
+
export const AgentRunStateSubmitted = "submitted";
|
|
265
|
+
export const AgentRunStateWorking = "working";
|
|
266
|
+
export const AgentRunStateInputRequired = "input_required";
|
|
267
|
+
export const AgentRunStateAuthRequired = "auth_required";
|
|
268
|
+
export const AgentRunStateCompleted = "completed";
|
|
269
|
+
export const AgentRunStateFailed = "failed";
|
|
270
|
+
export const AgentRunStateCanceled = "canceled";
|
|
271
|
+
export const AgentRunStateRejected = "rejected";
|
|
272
|
+
export const InterruptReasonToolApproval = "tool_approval";
|
|
273
|
+
export const InterruptReasonClientTool = "client_tool";
|
|
274
|
+
export const InterruptReasonWidget = "widget";
|
|
275
|
+
export const InterruptReasonAuth = "auth";
|
|
276
|
+
export const InterruptReasonConfirmation = "confirmation";
|
|
264
277
|
export const AppCategoryImage = "image";
|
|
265
278
|
export const AppCategoryVideo = "video";
|
|
266
279
|
export const AppCategoryAudio = "audio";
|
|
@@ -329,6 +342,7 @@ export const EngineStatusRunning = "running";
|
|
|
329
342
|
export const EngineStatusPending = "pending";
|
|
330
343
|
export const EngineStatusDraining = "draining";
|
|
331
344
|
export const EngineStatusDisconnected = "disconnected";
|
|
345
|
+
export const EngineStatusRestarting = "restarting";
|
|
332
346
|
export const EngineStatusStopping = "stopping";
|
|
333
347
|
export const EngineStatusStopped = "stopped";
|
|
334
348
|
export const WorkerStatusReserved = "reserved";
|
|
@@ -389,6 +403,7 @@ export const PageStatusUnknown = 0;
|
|
|
389
403
|
export const PageStatusDraft = 1;
|
|
390
404
|
export const PageStatusPublished = 2;
|
|
391
405
|
export const PageStatusArchived = 3;
|
|
406
|
+
export const PageStatusScheduled = 4;
|
|
392
407
|
export const PageTypeDoc = "doc";
|
|
393
408
|
export const PageTypeBlog = "blog";
|
|
394
409
|
export const PageTypePage = "page";
|
package/dist/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides future compatibility when API migrates from int to string status.
|
|
4
4
|
*/
|
|
5
5
|
import { TaskStatus } from './types';
|
|
6
|
+
import type { ChatDTO } from './types';
|
|
6
7
|
/**
|
|
7
8
|
* Parse task status from int or string to TaskStatus number.
|
|
8
9
|
* Handles both current int-based API and future string-based API.
|
|
@@ -13,3 +14,4 @@ export declare function parseStatus(status: number | string | undefined | null):
|
|
|
13
14
|
* Handles both int and string status values.
|
|
14
15
|
*/
|
|
15
16
|
export declare function isTerminalStatus(status: number | string | undefined | null): boolean;
|
|
17
|
+
export declare function isChatBusy(chat: ChatDTO | null | undefined): boolean;
|
package/dist/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Status utilities for handling both int and string-based status values.
|
|
3
3
|
* Provides future compatibility when API migrates from int to string status.
|
|
4
4
|
*/
|
|
5
|
-
import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, } from './types';
|
|
5
|
+
import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, AgentRunStateWorking, AgentRunStateSubmitted, } from './types';
|
|
6
6
|
/** Map string status names to TaskStatus values (for future string-based API) */
|
|
7
7
|
const STATUS_STRING_MAP = {
|
|
8
8
|
unknown: TaskStatusUnknown,
|
|
@@ -43,3 +43,7 @@ export function isTerminalStatus(status) {
|
|
|
43
43
|
const parsed = parseStatus(status);
|
|
44
44
|
return parsed === TaskStatusCompleted || parsed === TaskStatusFailed || parsed === TaskStatusCancelled;
|
|
45
45
|
}
|
|
46
|
+
export function isChatBusy(chat) {
|
|
47
|
+
const state = chat?.active_run?.state;
|
|
48
|
+
return state === AgentRunStateWorking || state === AgentRunStateSubmitted;
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inferencesh/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.26",
|
|
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",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"types": "./dist/agent/index.d.ts",
|
|
40
40
|
"inference-src": "./src/agent/index.ts",
|
|
41
41
|
"default": "./dist/agent/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./internal/upload": {
|
|
44
|
+
"types": "./dist/api/files.d.ts",
|
|
45
|
+
"inference-src": "./src/api/files.ts",
|
|
46
|
+
"default": "./dist/api/files.js"
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
"scripts": {
|