@inferencesh/sdk 0.21.0 → 0.22.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 +47 -0
- package/dist/agent/api.d.ts +35 -1
- package/dist/agent/api.js +35 -1
- package/dist/agent/reducer.js +23 -7
- package/dist/agent/types.d.ts +29 -4
- package/dist/api/agents.d.ts +9 -3
- package/dist/api/agents.js +87 -63
- package/dist/api/api-keys.d.ts +2 -5
- package/dist/api/apps.d.ts +9 -2
- package/dist/api/apps.js +9 -1
- package/dist/api/chats.d.ts +13 -3
- package/dist/api/chats.js +13 -2
- package/dist/api/engines.d.ts +4 -2
- package/dist/api/engines.js +3 -2
- package/dist/api/flow-runs.d.ts +7 -2
- package/dist/api/flow-runs.js +7 -2
- package/dist/api/flows.d.ts +13 -2
- package/dist/api/flows.js +15 -1
- package/dist/api/knowledge.d.ts +7 -4
- package/dist/api/knowledge.js +6 -4
- package/dist/api/mcp-servers.d.ts +2 -1
- package/dist/api/projects.d.ts +5 -3
- package/dist/api/projects.js +3 -2
- package/dist/api/secrets.d.ts +2 -2
- package/dist/api/tasks.js +38 -56
- package/dist/api/teams.d.ts +4 -2
- package/dist/api/teams.js +3 -2
- package/dist/api/write-bodies.d.ts +110 -0
- package/dist/api/write-bodies.js +1 -0
- package/dist/http/client.d.ts +1 -1
- package/dist/http/client.js +2 -1
- package/dist/http/loopback.d.ts +8 -0
- package/dist/http/loopback.js +18 -0
- package/dist/http/stream-until-terminal.d.ts +55 -0
- package/dist/http/stream-until-terminal.js +88 -0
- package/dist/http/stream.d.ts +1 -0
- package/dist/http/stream.js +7 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/proxy/endpoints.json +156 -0
- package/dist/proxy/express.d.ts +5 -6
- package/dist/proxy/express.js +18 -2
- package/dist/proxy/hono.d.ts +5 -3
- package/dist/proxy/hono.js +4 -3
- package/dist/proxy/index.d.ts +165 -6
- package/dist/proxy/index.js +409 -25
- package/dist/proxy/nextjs.d.ts +29 -17
- package/dist/proxy/nextjs.js +72 -62
- package/dist/proxy/remix.d.ts +5 -3
- package/dist/proxy/remix.js +4 -3
- package/dist/proxy/svelte.d.ts +5 -4
- package/dist/proxy/svelte.js +4 -4
- package/dist/types.d.ts +423 -6
- package/dist/types.js +111 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +7 -0
- package/package.json +2 -1
package/dist/api/chats.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
-
import {
|
|
3
|
+
import type { ChatUpdateBody } from './write-bodies';
|
|
4
|
+
import { ChatDTO as Chat, ChatMessageDTO, ChatSettingsDTO, ChatSettingsRequest, ChatTraceDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Chats API
|
|
6
7
|
*/
|
|
@@ -16,9 +17,18 @@ export declare class ChatsAPI {
|
|
|
16
17
|
*/
|
|
17
18
|
get(chatId: string): Promise<Response<Chat>>;
|
|
18
19
|
/**
|
|
19
|
-
* Update a chat
|
|
20
|
+
* Update a chat's name and description (PATCH): only the fields sent are
|
|
21
|
+
* written. Visibility and the other chat settings: updateSettings.
|
|
20
22
|
*/
|
|
21
|
-
update(chatId: string, data:
|
|
23
|
+
update(chatId: string, data: ChatUpdateBody): Promise<Response<Chat>>;
|
|
24
|
+
/**
|
|
25
|
+
* Change a chat's settings (name, visibility, tool approval, hooks,
|
|
26
|
+
* memory). Answers with the settings as they now are. Widening what runs
|
|
27
|
+
* without approval needs approvals:write, held only by the account
|
|
28
|
+
* holder's own sign-in: other credentials get 403 `requires_sign_in`
|
|
29
|
+
* (ErrorCodeRequiresSignIn).
|
|
30
|
+
*/
|
|
31
|
+
updateSettings(chatId: string, settings: ChatSettingsRequest): Promise<Response<ChatSettingsDTO>>;
|
|
22
32
|
/**
|
|
23
33
|
* Delete a chat
|
|
24
34
|
*/
|
package/dist/api/chats.js
CHANGED
|
@@ -18,10 +18,21 @@ export class ChatsAPI {
|
|
|
18
18
|
return this.http.request('get', `/chats/${chatId}`);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Update a chat
|
|
21
|
+
* Update a chat's name and description (PATCH): only the fields sent are
|
|
22
|
+
* written. Visibility and the other chat settings: updateSettings.
|
|
22
23
|
*/
|
|
23
24
|
async update(chatId, data) {
|
|
24
|
-
return this.http.request('
|
|
25
|
+
return this.http.request('patch', `/chats/${chatId}`, { data });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Change a chat's settings (name, visibility, tool approval, hooks,
|
|
29
|
+
* memory). Answers with the settings as they now are. Widening what runs
|
|
30
|
+
* without approval needs approvals:write, held only by the account
|
|
31
|
+
* holder's own sign-in: other credentials get 403 `requires_sign_in`
|
|
32
|
+
* (ErrorCodeRequiresSignIn).
|
|
33
|
+
*/
|
|
34
|
+
async updateSettings(chatId, settings) {
|
|
35
|
+
return this.http.request('post', `/chats/${chatId}/settings`, { data: settings });
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* Delete a chat
|
package/dist/api/engines.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { EngineUpdateBody } from './write-bodies';
|
|
3
4
|
import { EngineDTO as Engine, CursorListRequest, CursorListResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Engines API
|
|
@@ -27,9 +28,10 @@ export declare class EnginesAPI {
|
|
|
27
28
|
*/
|
|
28
29
|
create(data: Partial<Engine>): Promise<Response<Engine>>;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Rename an engine (see EngineUpdateBody). PATCH: only the fields sent are
|
|
32
|
+
* written.
|
|
31
33
|
*/
|
|
32
|
-
update(engineId: string, data:
|
|
34
|
+
update(engineId: string, data: EngineUpdateBody): Promise<Response<Engine>>;
|
|
33
35
|
/**
|
|
34
36
|
* Delete an engine
|
|
35
37
|
*/
|
package/dist/api/engines.js
CHANGED
|
@@ -30,10 +30,11 @@ export class EnginesAPI {
|
|
|
30
30
|
return this.http.request('post', '/engines', { data });
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Rename an engine (see EngineUpdateBody). PATCH: only the fields sent are
|
|
34
|
+
* written.
|
|
34
35
|
*/
|
|
35
36
|
async update(engineId, data) {
|
|
36
|
-
return this.http.request('
|
|
37
|
+
return this.http.request('patch', `/engines/${engineId}`, { data });
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Delete an engine
|
package/dist/api/flow-runs.d.ts
CHANGED
|
@@ -24,7 +24,11 @@ export declare class FlowRunsAPI {
|
|
|
24
24
|
*/
|
|
25
25
|
clone(flowRunId: string): Promise<Response<FlowRun>>;
|
|
26
26
|
/**
|
|
27
|
-
* Update a flow run
|
|
27
|
+
* Update a flow run.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated A flow run has no caller-writable fields: the API refuses this
|
|
30
|
+
* request. To change who can see a run, use {@link FlowRunsAPI.updateVisibility}.
|
|
31
|
+
* Kept so existing code still compiles; it will be removed in a future major version.
|
|
28
32
|
*/
|
|
29
33
|
update(flowRunId: string, data: Partial<FlowRun>): Promise<Response<FlowRun>>;
|
|
30
34
|
/**
|
|
@@ -40,7 +44,8 @@ export declare class FlowRunsAPI {
|
|
|
40
44
|
*/
|
|
41
45
|
streamTasks(flowRunId: string): Promise<import("eventsource").EventSource | null>;
|
|
42
46
|
/**
|
|
43
|
-
*
|
|
47
|
+
* Set who can see a flow run: `private`, `team`, `unlisted` or `public`.
|
|
48
|
+
* This is the one change a caller can make to a run.
|
|
44
49
|
*/
|
|
45
50
|
updateVisibility(flowRunId: string, visibility: string): Promise<Response<FlowRun>>;
|
|
46
51
|
}
|
package/dist/api/flow-runs.js
CHANGED
|
@@ -30,7 +30,11 @@ export class FlowRunsAPI {
|
|
|
30
30
|
return this.http.request('post', `/flowruns/${flowRunId}/clone`);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Update a flow run
|
|
33
|
+
* Update a flow run.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated A flow run has no caller-writable fields: the API refuses this
|
|
36
|
+
* request. To change who can see a run, use {@link FlowRunsAPI.updateVisibility}.
|
|
37
|
+
* Kept so existing code still compiles; it will be removed in a future major version.
|
|
34
38
|
*/
|
|
35
39
|
async update(flowRunId, data) {
|
|
36
40
|
return this.http.request('post', `/flowruns/${flowRunId}`, { data });
|
|
@@ -54,7 +58,8 @@ export class FlowRunsAPI {
|
|
|
54
58
|
return this.http.createEventSource(`/flowruns/${flowRunId}/tasks/stream`);
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
|
-
*
|
|
61
|
+
* Set who can see a flow run: `private`, `team`, `unlisted` or `public`.
|
|
62
|
+
* This is the one change a caller can make to a run.
|
|
58
63
|
*/
|
|
59
64
|
async updateVisibility(flowRunId, visibility) {
|
|
60
65
|
return this.http.request('post', `/flowruns/${flowRunId}/visibility`, { data: { visibility } });
|
package/dist/api/flows.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { FlowPatchBody, FlowUpdateBody, FlowViewportBody } from './write-bodies';
|
|
3
4
|
import { FlowDTO as Flow, FlowVersionDTO, AppDTO as App, CursorListRequest, CursorListResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Flows API
|
|
@@ -20,9 +21,19 @@ export declare class FlowsAPI {
|
|
|
20
21
|
*/
|
|
21
22
|
create(name: string): Promise<Response<Flow>>;
|
|
22
23
|
/**
|
|
23
|
-
* Update a flow
|
|
24
|
+
* Update a flow's copy and images, and save its draft graph when the body
|
|
25
|
+
* names the draft (see FlowUpdateBody). A field left out is written
|
|
26
|
+
* empty: to change some fields only, use patch.
|
|
24
27
|
*/
|
|
25
|
-
update(flowId: string, data:
|
|
28
|
+
update(flowId: string, data: FlowUpdateBody): Promise<Response<Flow>>;
|
|
29
|
+
/**
|
|
30
|
+
* Change some of a flow's fields: only the fields sent are written.
|
|
31
|
+
*/
|
|
32
|
+
patch(flowId: string, data: FlowPatchBody): Promise<Response<Flow>>;
|
|
33
|
+
/**
|
|
34
|
+
* Save where the editor's canvas looks on the flow's draft.
|
|
35
|
+
*/
|
|
36
|
+
saveViewport(flowId: string, viewport: FlowViewportBody): Promise<Response<void>>;
|
|
26
37
|
/**
|
|
27
38
|
* Update flow visibility
|
|
28
39
|
*/
|
package/dist/api/flows.js
CHANGED
|
@@ -24,11 +24,25 @@ export class FlowsAPI {
|
|
|
24
24
|
return this.http.request('post', '/flows', { data: { name } });
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Update a flow
|
|
27
|
+
* Update a flow's copy and images, and save its draft graph when the body
|
|
28
|
+
* names the draft (see FlowUpdateBody). A field left out is written
|
|
29
|
+
* empty: to change some fields only, use patch.
|
|
28
30
|
*/
|
|
29
31
|
async update(flowId, data) {
|
|
30
32
|
return this.http.request('post', `/flows/${flowId}`, { data });
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Change some of a flow's fields: only the fields sent are written.
|
|
36
|
+
*/
|
|
37
|
+
async patch(flowId, data) {
|
|
38
|
+
return this.http.request('patch', `/flows/${flowId}`, { data });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Save where the editor's canvas looks on the flow's draft.
|
|
42
|
+
*/
|
|
43
|
+
async saveViewport(flowId, viewport) {
|
|
44
|
+
return this.http.request('post', `/flows/${flowId}/viewport`, { data: viewport });
|
|
45
|
+
}
|
|
32
46
|
/**
|
|
33
47
|
* Update flow visibility
|
|
34
48
|
*/
|
package/dist/api/knowledge.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { KnowledgeUpdateBody } from './write-bodies';
|
|
3
4
|
import { KnowledgeDTO, KnowledgeVersionDTO, KnowledgeCreateRequest, SkillDTO, SkillVersionDTO, CursorListRequest, CursorListResponse, PublicSkillStoreDTO } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Knowledge API
|
|
@@ -24,9 +25,10 @@ export declare class KnowledgeAPI {
|
|
|
24
25
|
*/
|
|
25
26
|
create(data: KnowledgeCreateRequest): Promise<Response<KnowledgeDTO>>;
|
|
26
27
|
/**
|
|
27
|
-
* Update a knowledge entry
|
|
28
|
+
* Update a knowledge entry (PATCH): only the fields sent are written, the
|
|
29
|
+
* others keep their value.
|
|
28
30
|
*/
|
|
29
|
-
update(id: string, data:
|
|
31
|
+
update(id: string, data: KnowledgeUpdateBody): Promise<Response<KnowledgeDTO>>;
|
|
30
32
|
/**
|
|
31
33
|
* Delete a knowledge entry
|
|
32
34
|
*/
|
|
@@ -75,9 +77,10 @@ export declare class SkillsAPI {
|
|
|
75
77
|
*/
|
|
76
78
|
create(data: Partial<SkillDTO>): Promise<Response<SkillDTO>>;
|
|
77
79
|
/**
|
|
78
|
-
* Update a skill
|
|
80
|
+
* Update a skill (PATCH): only the fields sent are written, the others
|
|
81
|
+
* keep their value.
|
|
79
82
|
*/
|
|
80
|
-
update(id: string, data:
|
|
83
|
+
update(id: string, data: KnowledgeUpdateBody): Promise<Response<SkillDTO>>;
|
|
81
84
|
/**
|
|
82
85
|
* Delete a skill
|
|
83
86
|
*/
|
package/dist/api/knowledge.js
CHANGED
|
@@ -30,10 +30,11 @@ export class KnowledgeAPI {
|
|
|
30
30
|
return this.http.request('post', '/knowledge', { data });
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Update a knowledge entry
|
|
33
|
+
* Update a knowledge entry (PATCH): only the fields sent are written, the
|
|
34
|
+
* others keep their value.
|
|
34
35
|
*/
|
|
35
36
|
async update(id, data) {
|
|
36
|
-
return this.http.request('
|
|
37
|
+
return this.http.request('patch', `/knowledge/${id}`, { data });
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Delete a knowledge entry
|
|
@@ -107,10 +108,11 @@ export class SkillsAPI {
|
|
|
107
108
|
return this.http.request('post', '/skills', { data });
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
* Update a skill
|
|
111
|
+
* Update a skill (PATCH): only the fields sent are written, the others
|
|
112
|
+
* keep their value.
|
|
111
113
|
*/
|
|
112
114
|
async update(id, data) {
|
|
113
|
-
return this.http.request('
|
|
115
|
+
return this.http.request('patch', `/skills/${id}`, { data });
|
|
114
116
|
}
|
|
115
117
|
/**
|
|
116
118
|
* Delete a skill
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { MCPServerUpdateBody } from './write-bodies';
|
|
3
4
|
import { MCPServerDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* MCP Servers API
|
|
@@ -38,7 +39,7 @@ export declare class MCPServersAPI {
|
|
|
38
39
|
/**
|
|
39
40
|
* Update an MCP server
|
|
40
41
|
*/
|
|
41
|
-
update(id: string, data:
|
|
42
|
+
update(id: string, data: MCPServerUpdateBody): Promise<Response<MCPServerDTO>>;
|
|
42
43
|
/**
|
|
43
44
|
* Delete an MCP server
|
|
44
45
|
*/
|
package/dist/api/projects.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { ProjectWriteBody } from './write-bodies';
|
|
3
4
|
import { ProjectDTO, CursorListRequest, CursorListResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Projects API
|
|
@@ -18,11 +19,12 @@ export declare class ProjectsAPI {
|
|
|
18
19
|
/**
|
|
19
20
|
* Create a project
|
|
20
21
|
*/
|
|
21
|
-
create(data:
|
|
22
|
+
create(data: ProjectWriteBody): Promise<Response<ProjectDTO>>;
|
|
22
23
|
/**
|
|
23
|
-
* Update a project
|
|
24
|
+
* Update a project (PATCH): only the fields sent are written, the others
|
|
25
|
+
* keep their value.
|
|
24
26
|
*/
|
|
25
|
-
update(id: string, data:
|
|
27
|
+
update(id: string, data: ProjectWriteBody): Promise<Response<ProjectDTO>>;
|
|
26
28
|
/**
|
|
27
29
|
* Delete a project
|
|
28
30
|
*/
|
package/dist/api/projects.js
CHANGED
|
@@ -24,10 +24,11 @@ export class ProjectsAPI {
|
|
|
24
24
|
return this.http.request('post', '/projects', { data });
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Update a project
|
|
27
|
+
* Update a project (PATCH): only the fields sent are written, the others
|
|
28
|
+
* keep their value.
|
|
28
29
|
*/
|
|
29
30
|
async update(id, data) {
|
|
30
|
-
return this.http.request('
|
|
31
|
+
return this.http.request('patch', `/projects/${id}`, { data });
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Delete a project
|
package/dist/api/secrets.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
-
import { SecretDTO, SecretCreateRequest, CursorListRequest, CursorListResponse } from '../types';
|
|
3
|
+
import { SecretDTO, SecretCreateRequest, SecretUpdateRequest, CursorListRequest, CursorListResponse } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Secrets API
|
|
6
6
|
*/
|
|
@@ -18,7 +18,7 @@ export declare class SecretsAPI {
|
|
|
18
18
|
/**
|
|
19
19
|
* Update a secret
|
|
20
20
|
*/
|
|
21
|
-
update(key: string, data:
|
|
21
|
+
update(key: string, data: SecretUpdateRequest): Promise<Response<SecretDTO>>;
|
|
22
22
|
/**
|
|
23
23
|
* Delete a secret
|
|
24
24
|
*/
|
package/dist/api/tasks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { streamUntilTerminal } from '../http/stream-until-terminal';
|
|
2
2
|
import { PollManager } from '../http/poll';
|
|
3
3
|
import { TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, } from '../types';
|
|
4
4
|
import { parseStatus } from '../utils';
|
|
@@ -16,6 +16,20 @@ function stripTask(task) {
|
|
|
16
16
|
session_id: task.session_id,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
/** Settles a watch when `data` carries a terminal status; no-op otherwise. */
|
|
20
|
+
function settleTerminal(data, stripped, settle) {
|
|
21
|
+
switch (parseStatus(data.status)) {
|
|
22
|
+
case TaskStatusCompleted:
|
|
23
|
+
settle.resolve(stripped);
|
|
24
|
+
break;
|
|
25
|
+
case TaskStatusFailed:
|
|
26
|
+
settle.reject(new Error(data.error || 'task failed'));
|
|
27
|
+
break;
|
|
28
|
+
case TaskStatusCancelled:
|
|
29
|
+
settle.reject(new Error('task cancelled'));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
/**
|
|
20
34
|
* Tasks API
|
|
21
35
|
*/
|
|
@@ -110,47 +124,26 @@ export class TasksAPI {
|
|
|
110
124
|
const { onUpdate, onPartialUpdate, onDelta } = options;
|
|
111
125
|
// Accumulate state across partial updates to preserve fields like session_id
|
|
112
126
|
let accumulatedTask = { ...task };
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
else if (parseStatus(data.status) === TaskStatusCancelled) {
|
|
125
|
-
streamManager.stop();
|
|
126
|
-
reject(new Error('task cancelled'));
|
|
127
|
-
}
|
|
127
|
+
return streamUntilTerminal((settle) => {
|
|
128
|
+
const observe = (data, fields) => {
|
|
129
|
+
// Merge new data, preserving existing fields if not in update
|
|
130
|
+
accumulatedTask = { ...accumulatedTask, ...data };
|
|
131
|
+
const stripped = stripTask(accumulatedTask);
|
|
132
|
+
if (fields)
|
|
133
|
+
onPartialUpdate?.(stripped, fields);
|
|
134
|
+
else
|
|
135
|
+
onUpdate?.(stripped);
|
|
136
|
+
settleTerminal(data, stripped, settle);
|
|
128
137
|
};
|
|
129
|
-
|
|
138
|
+
return {
|
|
130
139
|
request: (init) => this.http.fetch(`/tasks/${task.id}/stream`, init),
|
|
131
140
|
onDelta,
|
|
132
|
-
onData: (data) =>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
settle(data, stripped);
|
|
138
|
-
},
|
|
139
|
-
onPartialData: (data, fields) => {
|
|
140
|
-
// Merge partial update, preserving fields not in this update
|
|
141
|
-
accumulatedTask = { ...accumulatedTask, ...data };
|
|
142
|
-
const stripped = stripTask(accumulatedTask);
|
|
143
|
-
onPartialUpdate?.(stripped, fields);
|
|
144
|
-
settle(data, stripped);
|
|
145
|
-
},
|
|
146
|
-
onError: (error) => {
|
|
147
|
-
reject(error);
|
|
148
|
-
streamManager.stop();
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
streamManager.start();
|
|
141
|
+
onData: (data) => observe(data),
|
|
142
|
+
onPartialData: (data, fields) => observe(data, fields),
|
|
143
|
+
reconcile: async () => observe((await this.get(task.id)).data),
|
|
144
|
+
closedMessage: `Task stream closed before task ${task.id} finished`,
|
|
145
|
+
};
|
|
152
146
|
});
|
|
153
|
-
return { done, stop: () => streamManager.stop() };
|
|
154
147
|
}
|
|
155
148
|
/** Poll GET /tasks/{id}/status until terminal, full-fetch on status change. */
|
|
156
149
|
watchPoll(task, options) {
|
|
@@ -159,6 +152,10 @@ export class TasksAPI {
|
|
|
159
152
|
let prevStatus = task.status;
|
|
160
153
|
let poller;
|
|
161
154
|
const done = new Promise((resolve, reject) => {
|
|
155
|
+
const settle = {
|
|
156
|
+
resolve: (value) => { poller.stop(); resolve(value); },
|
|
157
|
+
reject: (error) => { poller.stop(); reject(error); },
|
|
158
|
+
};
|
|
162
159
|
poller = new PollManager({
|
|
163
160
|
pollFunction: async () => {
|
|
164
161
|
const resp = await this.http.request('get', `/tasks/${task.id}/status`);
|
|
@@ -176,28 +173,13 @@ export class TasksAPI {
|
|
|
176
173
|
const fullTask = fullResp.data;
|
|
177
174
|
const stripped = stripTask(fullTask);
|
|
178
175
|
onUpdate?.(stripped);
|
|
179
|
-
|
|
180
|
-
poller.stop();
|
|
181
|
-
resolve(stripped);
|
|
182
|
-
}
|
|
183
|
-
else if (parseStatus(fullTask.status) === TaskStatusFailed) {
|
|
184
|
-
poller.stop();
|
|
185
|
-
reject(new Error(fullTask.error || 'task failed'));
|
|
186
|
-
}
|
|
187
|
-
else if (parseStatus(fullTask.status) === TaskStatusCancelled) {
|
|
188
|
-
poller.stop();
|
|
189
|
-
reject(new Error('task cancelled'));
|
|
190
|
-
}
|
|
176
|
+
settleTerminal(fullTask, stripped, settle);
|
|
191
177
|
}
|
|
192
178
|
catch (err) {
|
|
193
|
-
|
|
194
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
179
|
+
settle.reject(err instanceof Error ? err : new Error(String(err)));
|
|
195
180
|
}
|
|
196
181
|
},
|
|
197
|
-
onError: (error) =>
|
|
198
|
-
reject(error);
|
|
199
|
-
poller.stop();
|
|
200
|
-
},
|
|
182
|
+
onError: (error) => settle.reject(error),
|
|
201
183
|
});
|
|
202
184
|
poller.start();
|
|
203
185
|
});
|
package/dist/api/teams.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from '../http/client';
|
|
2
2
|
import type { Response } from '../http/response';
|
|
3
|
+
import type { TeamUpdateBody } from './write-bodies';
|
|
3
4
|
import { MeResponse, TeamDTO, TeamMemberDTO, TeamInviteDTO, TeamCreateRequest, TeamMemberAddRequest, TeamInviteCreateRequest, AvailabilityResponse } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* Teams API
|
|
@@ -24,9 +25,10 @@ export declare class TeamsAPI {
|
|
|
24
25
|
*/
|
|
25
26
|
create(data: TeamCreateRequest): Promise<Response<TeamDTO>>;
|
|
26
27
|
/**
|
|
27
|
-
* Update a team
|
|
28
|
+
* Update a team's profile (PATCH): only the fields sent are written, the
|
|
29
|
+
* others keep their value.
|
|
28
30
|
*/
|
|
29
|
-
update(teamId: string, data:
|
|
31
|
+
update(teamId: string, data: TeamUpdateBody): Promise<Response<TeamDTO>>;
|
|
30
32
|
/**
|
|
31
33
|
* Delete a team
|
|
32
34
|
*/
|
package/dist/api/teams.js
CHANGED
|
@@ -30,10 +30,11 @@ export class TeamsAPI {
|
|
|
30
30
|
return this.http.request('post', '/teams', { data });
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Update a team
|
|
33
|
+
* Update a team's profile (PATCH): only the fields sent are written, the
|
|
34
|
+
* others keep their value.
|
|
34
35
|
*/
|
|
35
36
|
async update(teamId, data) {
|
|
36
|
-
return this.http.request('
|
|
37
|
+
return this.http.request('patch', `/teams/${teamId}`, { data });
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Delete a team
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request bodies of the generic create/update routes.
|
|
3
|
+
*
|
|
4
|
+
* Each type names exactly the fields its route writes; the API leaves every
|
|
5
|
+
* other field of the body alone (a full DTO sent back is fine, its other
|
|
6
|
+
* fields are ignored). A field with its own endpoint is listed next to the
|
|
7
|
+
* type that cannot set it.
|
|
8
|
+
*
|
|
9
|
+
* A POST /{resource}/{id} update writes every field below that the route
|
|
10
|
+
* takes: a field left out of the body is written empty. A PATCH writes only
|
|
11
|
+
* the fields sent. The SDK's update methods for projects, knowledge, skills,
|
|
12
|
+
* chats, engines and teams send PATCH; apps.patch and flows.patch are the
|
|
13
|
+
* partial siblings of the POST updates that also edit a version.
|
|
14
|
+
*/
|
|
15
|
+
import type { AgentConfigInput, AgentImages, AppDTO, ChatDTO, EngineDTO, FlowDTO, FlowVersionDTO, KnowledgeDTO, MCPServerAuthType, ProjectDTO, TeamDTO, Visibility } from '../types';
|
|
16
|
+
/**
|
|
17
|
+
* POST /agents/{id}. Visibility and images, and a new version when
|
|
18
|
+
* `version` is set. Name, title, harness, placement: set at creation.
|
|
19
|
+
* Project: `agents.moveToProject`; owner: `agents.transferOwnership`.
|
|
20
|
+
*/
|
|
21
|
+
export interface AgentUpdateBody {
|
|
22
|
+
visibility?: Visibility;
|
|
23
|
+
images?: AgentImages;
|
|
24
|
+
version?: AgentConfigInput;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* PATCH /apps/{id}: only the fields sent are written. The app's copy;
|
|
28
|
+
* the version is edited through POST (`apps.update`).
|
|
29
|
+
*/
|
|
30
|
+
export type AppPatchBody = Partial<Pick<AppDTO, 'title' | 'description' | 'agent_description' | 'category' | 'images' | 'tags'>>;
|
|
31
|
+
/**
|
|
32
|
+
* POST /apps/{id}. The app's copy, plus an in-place edit of the version
|
|
33
|
+
* named by `version_id` (its metadata, required secrets and required
|
|
34
|
+
* credentials). Status: `apps.updateStatus`; visibility:
|
|
35
|
+
* `apps.updateVisibility`; name, namespace and version contents: a deploy.
|
|
36
|
+
*/
|
|
37
|
+
export type AppUpdateBody = AppPatchBody & Partial<Pick<AppDTO, 'version_id' | 'version'>>;
|
|
38
|
+
/**
|
|
39
|
+
* PATCH /chats/{id}. Name and description. Visibility and the chat's
|
|
40
|
+
* settings: `chats.updateSettings`.
|
|
41
|
+
*/
|
|
42
|
+
export type ChatUpdateBody = Partial<Pick<ChatDTO, 'name' | 'description'>>;
|
|
43
|
+
/** PATCH /engines/{id}. The engine's name; the rest is the engine's own report. */
|
|
44
|
+
export type EngineUpdateBody = Partial<Pick<EngineDTO, 'name'>>;
|
|
45
|
+
/** PATCH /flows/{id}: only the fields sent are written. */
|
|
46
|
+
export type FlowPatchBody = Partial<Pick<FlowDTO, 'name' | 'title' | 'description' | 'card_image' | 'thumbnail' | 'banner_image'>>;
|
|
47
|
+
/**
|
|
48
|
+
* POST /flows/{id}. The flow's copy and images (as PATCH), plus
|
|
49
|
+
* `draft_version`, naming the flow's own draft by id, which saves that
|
|
50
|
+
* draft's graph. Visibility: `flows.updateVisibility`; viewport:
|
|
51
|
+
* `flows.saveViewport`.
|
|
52
|
+
*/
|
|
53
|
+
export type FlowUpdateBody = FlowPatchBody & {
|
|
54
|
+
draft_version?: Partial<FlowVersionDTO> & {
|
|
55
|
+
id: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/** Where the flow editor's canvas looks (POST /flows/{id}/viewport). */
|
|
59
|
+
export interface FlowViewportBody {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
zoom: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* POST /projects and PATCH /projects/{id}. Visibility is taken on create
|
|
66
|
+
* only; no route changes it afterwards. Parent: none.
|
|
67
|
+
*/
|
|
68
|
+
export type ProjectWriteBody = Partial<Pick<ProjectDTO, 'name' | 'description' | 'type' | 'color' | 'icon'>> & {
|
|
69
|
+
visibility?: Visibility;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* PATCH /knowledge/{id} and PATCH /skills/{id}. Copy and lifecycle. Name and
|
|
73
|
+
* type: fixed at creation; content: a new version (`create` with the same
|
|
74
|
+
* name); visibility: `updateVisibility`.
|
|
75
|
+
*/
|
|
76
|
+
export interface KnowledgeUpdateBody {
|
|
77
|
+
title?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
repo_url?: string;
|
|
80
|
+
lifecycle?: KnowledgeDTO['lifecycle'];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* PATCH /teams/{id}. A team admin changes the profile; status and
|
|
84
|
+
* concurrency are platform staff's. The username is the team's namespace
|
|
85
|
+
* and does not change here.
|
|
86
|
+
*/
|
|
87
|
+
export type TeamUpdateBody = Partial<Pick<TeamDTO, 'name' | 'email' | 'avatar_url'>>;
|
|
88
|
+
/**
|
|
89
|
+
* PUT /mcp-servers/{id}. A field left out keeps its value. Title,
|
|
90
|
+
* description, icon URL and documentation URL take what is sent, and ""
|
|
91
|
+
* clears them; slug, name, server URL, auth type and the OAuth client
|
|
92
|
+
* change only to a non-empty value. Headers sent replace the set ({}
|
|
93
|
+
* clears it). Visibility: `POST /mcp-servers/{id}/visibility`.
|
|
94
|
+
*/
|
|
95
|
+
export interface MCPServerUpdateBody {
|
|
96
|
+
slug?: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
title?: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
icon_url?: string;
|
|
101
|
+
server_url?: string;
|
|
102
|
+
auth_type?: MCPServerAuthType;
|
|
103
|
+
oauth_client_id?: string;
|
|
104
|
+
oauth_secret_key?: string;
|
|
105
|
+
default_scopes?: string[];
|
|
106
|
+
headers?: {
|
|
107
|
+
[key: string]: string;
|
|
108
|
+
};
|
|
109
|
+
documentation_url?: string;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/http/client.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export declare class HttpClient {
|
|
|
103
103
|
/**
|
|
104
104
|
* Make an HTTP request to the API
|
|
105
105
|
*/
|
|
106
|
-
request<T, P extends object = Record<string, unknown>>(method: 'get' | 'post' | 'put' | 'delete', endpoint: string, { handleErrors, ...options }?: {
|
|
106
|
+
request<T, P extends object = Record<string, unknown>>(method: 'get' | 'post' | 'put' | 'patch' | 'delete', endpoint: string, { handleErrors, ...options }?: {
|
|
107
107
|
params?: P;
|
|
108
108
|
data?: unknown;
|
|
109
109
|
/**
|
package/dist/http/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InferenceError, RequirementsNotMetException } from './errors';
|
|
2
2
|
import { EventSource } from 'eventsource';
|
|
3
|
+
import { SDK_VERSION } from '../version';
|
|
3
4
|
/**
|
|
4
5
|
* Low-level HTTP client for inference.sh API
|
|
5
6
|
*
|
|
@@ -16,7 +17,7 @@ export class HttpClient {
|
|
|
16
17
|
this.baseUrl = config.baseUrl || 'https://api.inference.sh';
|
|
17
18
|
this.proxyUrl = config.proxyUrl;
|
|
18
19
|
this.getToken = config.getToken;
|
|
19
|
-
this.customHeaders = { 'X-Client-Source':
|
|
20
|
+
this.customHeaders = { 'X-Client-Source': `inference-sdk-js/${SDK_VERSION}`, ...config.headers };
|
|
20
21
|
// Bearer auth needs no cookies, and 'include' makes browsers reject the
|
|
21
22
|
// response unless the API answers with Allow-Credentials — which it does not
|
|
22
23
|
// for third-party origins (WebKit reports that as "Load failed"). Cookies
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loopback hosts, where plain http never leaves the machine (local dev):
|
|
3
|
+
* `localhost`, any `*.localhost`, `[::1]` and 127.0.0.0/8. This is the one
|
|
4
|
+
* copy of the rule; the proxy, the app and common-js all ask it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isLoopbackHost(hostname: string): boolean;
|
|
7
|
+
/** Whether `url` is https, or plain http to a loopback host. */
|
|
8
|
+
export declare function isHttpsOrLoopback(url: URL): boolean;
|