lemma-sdk 0.2.37 → 0.2.38
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/README.md +20 -11
- package/dist/browser/lemma-client.js +1 -114
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -3
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -2
- package/dist/namespaces/conversations.d.ts +0 -5
- package/dist/namespaces/conversations.js +0 -15
- package/dist/openapi_client/models/AgentModelName.d.ts +1 -1
- package/dist/openapi_client/models/AgentModelName.js +1 -1
- package/dist/openapi_client/models/MessageResponse.d.ts +0 -1
- package/dist/openapi_client/services/AgentConversationsService.d.ts +4 -14
- package/dist/openapi_client/services/AgentConversationsService.js +4 -30
- package/dist/react/index.d.ts +0 -8
- package/dist/react/index.js +0 -4
- package/dist/react/useAssistantController.js +0 -2
- package/dist/react/useAssistantSession.d.ts +0 -2
- package/dist/react/useAssistantSession.js +8 -14
- package/dist/run-utils.d.ts +1 -5
- package/dist/run-utils.js +0 -10
- package/dist/types.d.ts +0 -42
- package/package.json +1 -1
- package/dist/namespaces/tasks.d.ts +0 -25
- package/dist/namespaces/tasks.js +0 -91
- package/dist/react/useAgentRun.d.ts +0 -38
- package/dist/react/useAgentRun.js +0 -149
- package/dist/react/useAgentRuns.d.ts +0 -33
- package/dist/react/useAgentRuns.js +0 -149
- package/dist/react/useAssistantRun.d.ts +0 -27
- package/dist/react/useAssistantRun.js +0 -47
- package/dist/react/useTaskSession.d.ts +0 -35
- package/dist/react/useTaskSession.js +0 -269
- package/dist/task-events.d.ts +0 -8
- package/dist/task-events.js +0 -115
package/README.md
CHANGED
|
@@ -60,7 +60,6 @@ npm install react react-dom
|
|
|
60
60
|
```tsx
|
|
61
61
|
import {
|
|
62
62
|
AuthGuard,
|
|
63
|
-
useAgentRun,
|
|
64
63
|
useConversationMessages,
|
|
65
64
|
useConversations,
|
|
66
65
|
useRecordForm,
|
|
@@ -78,8 +77,8 @@ import {
|
|
|
78
77
|
| Record mutations | `useCreateRecord`, `useUpdateRecord`, `useDeleteRecord`, `useBulkRecords` | Stable | Create, update, delete, or bulk-delete rows from headless UI. Function-backed mutations via `createVia`/`updateVia` options. |
|
|
79
78
|
| Record forms | `useRecordSchema`, `useRecordForm`, `useForeignKeyOptions`, `useSchemaForm` | Stable | Render schema-driven record forms, enum fields, and foreign-key selectors. `useRecordForm` is the canonical table-bound form hook; `useSchemaForm` remains available for raw JSON-schema flows. |
|
|
80
79
|
| Files | `useFiles`, `useFile`, `useUploadFile`, `useUpdateFile`, `useDeleteFile`, `useCreateFolder`, `useFileSearch`, `useFileTree`, `useFilePreview`, `useGlobalSearch` | Stable | Browse private or pod folders, mutate file state, search indexed files, load directory trees, preview content, and compose multi-source desk search. |
|
|
81
|
-
| Conversations | `useConversations`, `useConversation`, `useConversationMessages`, `
|
|
82
|
-
| Agents | `
|
|
80
|
+
| Conversations | `useConversations`, `useConversation`, `useConversationMessages`, `useAssistantSession`, `useAssistantRuntime`, `useAssistantController` | Stable except controller/runtime | Build custom chat, conversation lists, streaming output, and final-answer views for default assistant conversations or named agents. |
|
|
81
|
+
| Agents | `useAgentInputSchema` | Stable | Inspect structured input/output schemas for named agents. Agent execution goes through conversations. |
|
|
83
82
|
| Workflows | `useWorkflowStart`, `useWorkflowRun`, `useWorkflowRuns`, `useWorkflowResume` | Stable | Start, poll, resume, cancel, retry, and inspect workflow runs. |
|
|
84
83
|
| Workflow compatibility | `useFlowSession`, `useFlowRunHistory` | Deprecated naming | Kept for existing callers; prefer workflow-named hooks for new code. |
|
|
85
84
|
| Functions | `useFunctionRun`, `useFunctionRuns`, `useFunctionSession` | Stable except raw session | Run functions, poll function runs, and list function history. |
|
|
@@ -107,7 +106,7 @@ List hooks generally expose:
|
|
|
107
106
|
|
|
108
107
|
Run hooks generally expose:
|
|
109
108
|
|
|
110
|
-
- `run`
|
|
109
|
+
- `run`
|
|
111
110
|
- `status`
|
|
112
111
|
- `isPolling`, `isStreaming`, or `isRunning`
|
|
113
112
|
- `output`
|
|
@@ -168,25 +167,35 @@ function SupportThread({ client }: { client: LemmaClient }) {
|
|
|
168
167
|
}
|
|
169
168
|
```
|
|
170
169
|
|
|
171
|
-
|
|
170
|
+
Start an agent conversation:
|
|
172
171
|
|
|
173
172
|
```tsx
|
|
174
|
-
import {
|
|
173
|
+
import { useConversationMessages } from "lemma-sdk/react";
|
|
175
174
|
|
|
176
175
|
function AgentButton({ client }: { client: LemmaClient }) {
|
|
177
|
-
const
|
|
176
|
+
const conversation = useConversationMessages({
|
|
178
177
|
client,
|
|
179
178
|
agentName: "triage_agent",
|
|
179
|
+
autoResume: true,
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
return (
|
|
183
183
|
<button
|
|
184
|
-
disabled={
|
|
184
|
+
disabled={conversation.isStreaming}
|
|
185
185
|
onClick={() => {
|
|
186
|
-
void
|
|
186
|
+
void (async () => {
|
|
187
|
+
const thread = await conversation.createConversation({
|
|
188
|
+
title: "Triage ticket ticket_123",
|
|
189
|
+
setActive: true,
|
|
190
|
+
});
|
|
191
|
+
await conversation.sendMessage(JSON.stringify({
|
|
192
|
+
ticket_id: "ticket_123",
|
|
193
|
+
prompt: "Triage this ticket.",
|
|
194
|
+
}), { conversationId: thread.id });
|
|
195
|
+
})();
|
|
187
196
|
}}
|
|
188
197
|
>
|
|
189
|
-
{
|
|
198
|
+
{conversation.status ?? "Message agent"}
|
|
190
199
|
</button>
|
|
191
200
|
);
|
|
192
201
|
}
|
|
@@ -446,7 +455,7 @@ From `0.2.30` onward:
|
|
|
446
455
|
From `0.2.37` onward:
|
|
447
456
|
|
|
448
457
|
- Agent APIs are the runtime abstraction. `client.assistants` is removed; use `client.agents` for definitions and `client.conversations` for turns/messages.
|
|
449
|
-
- Conversations are pod-scoped under the agent conversation API; message sends stream
|
|
458
|
+
- Conversations are pod-scoped under the agent conversation API; message sends stream conversation events until final output.
|
|
450
459
|
- File APIs are namespace-aware. Shared pod files are the default for backwards-compatible file workspaces; pass `namespace: "PRIVATE"` for personal file input/upload flows and `namespace: "POD"` when you want to be explicit. The live OpenAPI currently names the private namespace `PERSONAL`; the SDK accepts `PRIVATE` as the product-facing alias.
|
|
451
460
|
|
|
452
461
|
## Local Development
|
|
@@ -52,7 +52,6 @@ const pod_surfaces_js_1 = require("./namespaces/pod-surfaces.js");
|
|
|
52
52
|
const records_js_1 = require("./namespaces/records.js");
|
|
53
53
|
const resources_js_1 = require("./namespaces/resources.js");
|
|
54
54
|
const tables_js_1 = require("./namespaces/tables.js");
|
|
55
|
-
const tasks_js_1 = require("./namespaces/tasks.js");
|
|
56
55
|
const users_js_1 = require("./namespaces/users.js");
|
|
57
56
|
const workflows_js_1 = require("./namespaces/workflows.js");
|
|
58
57
|
const datastore_js_1 = require("./namespaces/datastore.js");
|
|
@@ -75,7 +74,6 @@ class LemmaClient {
|
|
|
75
74
|
this.files = new files_js_1.FilesNamespace(this._generated, this._http, podIdFn);
|
|
76
75
|
this.functions = new functions_js_1.FunctionsNamespace(this._generated, podIdFn);
|
|
77
76
|
this.agents = new agents_js_1.AgentsNamespace(this._generated, podIdFn);
|
|
78
|
-
this.tasks = new tasks_js_1.TasksNamespace(this._http, podIdFn);
|
|
79
77
|
this.conversations = new conversations_js_1.ConversationsNamespace(this._http, podIdFn);
|
|
80
78
|
this.workflows = new workflows_js_1.WorkflowsNamespace(this._generated, this._http, podIdFn);
|
|
81
79
|
this.desks = new desks_js_1.DesksNamespace(this._generated, this._http, podIdFn);
|
|
@@ -1712,24 +1710,9 @@ class ConversationsNamespace {
|
|
|
1712
1710
|
},
|
|
1713
1711
|
});
|
|
1714
1712
|
}
|
|
1715
|
-
sendOrCreateMessageStream(payload, options = {}) {
|
|
1716
|
-
const podId = this.requirePodId(options.pod_id);
|
|
1717
|
-
return this.http.stream(`/pods/${podId}/conversations/messages`, {
|
|
1718
|
-
method: "POST",
|
|
1719
|
-
body: payload,
|
|
1720
|
-
signal: options.signal,
|
|
1721
|
-
headers: {
|
|
1722
|
-
"Content-Type": "application/json",
|
|
1723
|
-
Accept: "text/event-stream",
|
|
1724
|
-
},
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
1713
|
resumeStream(conversationId, options = {}) {
|
|
1728
1714
|
const podId = this.requirePodId(options.pod_id);
|
|
1729
1715
|
return this.http.stream(`/pods/${podId}/conversations/${conversationId}/stream`, {
|
|
1730
|
-
params: {
|
|
1731
|
-
agent_run_id: options.agent_run_id,
|
|
1732
|
-
},
|
|
1733
1716
|
signal: options.signal,
|
|
1734
1717
|
headers: {
|
|
1735
1718
|
Accept: "text/event-stream",
|
|
@@ -1755,7 +1738,7 @@ exports.AgentModelName = void 0;
|
|
|
1755
1738
|
/* tslint:disable */
|
|
1756
1739
|
/* eslint-disable */
|
|
1757
1740
|
/**
|
|
1758
|
-
* Models that can be selected for an agent
|
|
1741
|
+
* Models that can be selected for an agent conversation.
|
|
1759
1742
|
*/
|
|
1760
1743
|
var AgentModelName;
|
|
1761
1744
|
(function (AgentModelName) {
|
|
@@ -4861,102 +4844,6 @@ class TablesService {
|
|
|
4861
4844
|
}
|
|
4862
4845
|
exports.TablesService = TablesService;
|
|
4863
4846
|
|
|
4864
|
-
},
|
|
4865
|
-
"./namespaces/tasks.js": function (module, exports, require) {
|
|
4866
|
-
"use strict";
|
|
4867
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4868
|
-
exports.TasksNamespace = void 0;
|
|
4869
|
-
function toTask(conversation, inputData) {
|
|
4870
|
-
return {
|
|
4871
|
-
id: conversation.id,
|
|
4872
|
-
agent_id: conversation.agent_id,
|
|
4873
|
-
pod_id: conversation.pod_id,
|
|
4874
|
-
user_id: conversation.user_id,
|
|
4875
|
-
input_data: inputData ?? null,
|
|
4876
|
-
output_data: null,
|
|
4877
|
-
error: null,
|
|
4878
|
-
status: conversation.status?.toUpperCase() ?? "WAITING",
|
|
4879
|
-
created_at: conversation.created_at,
|
|
4880
|
-
updated_at: conversation.updated_at,
|
|
4881
|
-
conversation,
|
|
4882
|
-
};
|
|
4883
|
-
}
|
|
4884
|
-
function normalizeConversation(conversation) {
|
|
4885
|
-
return {
|
|
4886
|
-
...conversation,
|
|
4887
|
-
model: conversation.model ?? conversation.model_name ?? null,
|
|
4888
|
-
status: conversation.status ?? "waiting",
|
|
4889
|
-
};
|
|
4890
|
-
}
|
|
4891
|
-
function normalizeMessages(messages) {
|
|
4892
|
-
return messages;
|
|
4893
|
-
}
|
|
4894
|
-
class TasksNamespace {
|
|
4895
|
-
constructor(http, podId) {
|
|
4896
|
-
this.http = http;
|
|
4897
|
-
this.podId = podId;
|
|
4898
|
-
this.messages = {
|
|
4899
|
-
list: (taskId, options = {}) => this.http.request("GET", `/pods/${this.podId()}/conversations/${taskId}/messages`, {
|
|
4900
|
-
params: {
|
|
4901
|
-
limit: options.limit ?? 100,
|
|
4902
|
-
after_sequence: options.page_token,
|
|
4903
|
-
},
|
|
4904
|
-
}).then((response) => ({
|
|
4905
|
-
...response,
|
|
4906
|
-
items: normalizeMessages(response.items ?? []),
|
|
4907
|
-
})),
|
|
4908
|
-
add: (taskId, payload) => {
|
|
4909
|
-
return this.http.request("POST", `/pods/${this.podId()}/conversations/${taskId}/messages`, {
|
|
4910
|
-
body: payload,
|
|
4911
|
-
}).then(() => this.get(taskId));
|
|
4912
|
-
},
|
|
4913
|
-
};
|
|
4914
|
-
}
|
|
4915
|
-
list(options = {}) {
|
|
4916
|
-
return this.http.request("GET", `/pods/${this.podId()}/conversations`, {
|
|
4917
|
-
params: {
|
|
4918
|
-
agent_name: options.agent_name,
|
|
4919
|
-
limit: options.limit ?? 100,
|
|
4920
|
-
page_token: options.page_token,
|
|
4921
|
-
},
|
|
4922
|
-
}).then((response) => {
|
|
4923
|
-
const conversations = (response.items ?? []).map(normalizeConversation);
|
|
4924
|
-
return {
|
|
4925
|
-
items: conversations.map((conversation) => toTask(conversation)),
|
|
4926
|
-
limit: response.limit ?? options.limit ?? 100,
|
|
4927
|
-
next_page_token: response.next_page_token ?? null,
|
|
4928
|
-
total: response.total,
|
|
4929
|
-
};
|
|
4930
|
-
});
|
|
4931
|
-
}
|
|
4932
|
-
create(payload) {
|
|
4933
|
-
return this.http.request("POST", `/pods/${this.podId()}/conversations`, {
|
|
4934
|
-
body: {
|
|
4935
|
-
agent_name: payload.agent_name,
|
|
4936
|
-
title: payload.title ?? payload.content ?? payload.agent_name,
|
|
4937
|
-
},
|
|
4938
|
-
}).then((conversation) => toTask(normalizeConversation(conversation), payload.input_data));
|
|
4939
|
-
}
|
|
4940
|
-
get(taskId) {
|
|
4941
|
-
return this.http.request("GET", `/pods/${this.podId()}/conversations/${taskId}`)
|
|
4942
|
-
.then((conversation) => toTask(normalizeConversation(conversation)));
|
|
4943
|
-
}
|
|
4944
|
-
stop(taskId) {
|
|
4945
|
-
return this.http.request("POST", `/pods/${this.podId()}/conversations/${taskId}/stop`, {
|
|
4946
|
-
body: {},
|
|
4947
|
-
}).then((conversation) => toTask(normalizeConversation(conversation)));
|
|
4948
|
-
}
|
|
4949
|
-
stream(taskId, options = {}) {
|
|
4950
|
-
return this.http.stream(`/pods/${this.podId()}/conversations/${taskId}/stream`, {
|
|
4951
|
-
signal: options.signal,
|
|
4952
|
-
headers: {
|
|
4953
|
-
Accept: "text/event-stream",
|
|
4954
|
-
},
|
|
4955
|
-
});
|
|
4956
|
-
}
|
|
4957
|
-
}
|
|
4958
|
-
exports.TasksNamespace = TasksNamespace;
|
|
4959
|
-
|
|
4960
4847
|
},
|
|
4961
4848
|
"./namespaces/users.js": function (module, exports, require) {
|
|
4962
4849
|
"use strict";
|
package/dist/client.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
|
|
|
15
15
|
import { RecordsNamespace } from "./namespaces/records.js";
|
|
16
16
|
import { ResourcesNamespace } from "./namespaces/resources.js";
|
|
17
17
|
import { TablesNamespace } from "./namespaces/tables.js";
|
|
18
|
-
import { TasksNamespace } from "./namespaces/tasks.js";
|
|
19
18
|
import { UsersNamespace } from "./namespaces/users.js";
|
|
20
19
|
import { WorkflowsNamespace } from "./namespaces/workflows.js";
|
|
21
20
|
import { DatastoreNamespace } from "./namespaces/datastore.js";
|
|
@@ -38,7 +37,6 @@ export declare class LemmaClient {
|
|
|
38
37
|
readonly files: FilesNamespace;
|
|
39
38
|
readonly functions: FunctionsNamespace;
|
|
40
39
|
readonly agents: AgentsNamespace;
|
|
41
|
-
readonly tasks: TasksNamespace;
|
|
42
40
|
readonly conversations: ConversationsNamespace;
|
|
43
41
|
readonly workflows: WorkflowsNamespace;
|
|
44
42
|
readonly desks: DesksNamespace;
|
package/dist/client.js
CHANGED
|
@@ -17,7 +17,6 @@ import { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
|
|
|
17
17
|
import { RecordsNamespace } from "./namespaces/records.js";
|
|
18
18
|
import { ResourcesNamespace } from "./namespaces/resources.js";
|
|
19
19
|
import { TablesNamespace } from "./namespaces/tables.js";
|
|
20
|
-
import { TasksNamespace } from "./namespaces/tasks.js";
|
|
21
20
|
import { UsersNamespace } from "./namespaces/users.js";
|
|
22
21
|
import { WorkflowsNamespace } from "./namespaces/workflows.js";
|
|
23
22
|
import { DatastoreNamespace } from "./namespaces/datastore.js";
|
|
@@ -36,7 +35,6 @@ export class LemmaClient {
|
|
|
36
35
|
files;
|
|
37
36
|
functions;
|
|
38
37
|
agents;
|
|
39
|
-
tasks;
|
|
40
38
|
conversations;
|
|
41
39
|
workflows;
|
|
42
40
|
desks;
|
|
@@ -68,7 +66,6 @@ export class LemmaClient {
|
|
|
68
66
|
this.files = new FilesNamespace(this._generated, this._http, podIdFn);
|
|
69
67
|
this.functions = new FunctionsNamespace(this._generated, podIdFn);
|
|
70
68
|
this.agents = new AgentsNamespace(this._generated, podIdFn);
|
|
71
|
-
this.tasks = new TasksNamespace(this._http, podIdFn);
|
|
72
69
|
this.conversations = new ConversationsNamespace(this._http, podIdFn);
|
|
73
70
|
this.workflows = new WorkflowsNamespace(this._generated, this._http, podIdFn);
|
|
74
71
|
this.desks = new DesksNamespace(this._generated, this._http, podIdFn);
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,8 @@ export { ApiError } from "./http.js";
|
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
export { readSSE, parseSSEJson } from "./streams.js";
|
|
8
8
|
export type { SseRawEvent } from "./streams.js";
|
|
9
|
-
export { normalizeRunStatus,
|
|
9
|
+
export { normalizeRunStatus, isTerminalFunctionStatus, isTerminalFlowStatus, sleep, nextBackoffDelay, } from "./run-utils.js";
|
|
10
10
|
export type { AnyRunStatus } from "./run-utils.js";
|
|
11
|
-
export { parseTaskStreamEvent, upsertTaskMessage } from "./task-events.js";
|
|
12
|
-
export type { ParsedTaskStreamEvent } from "./task-events.js";
|
|
13
11
|
export { parseAssistantStreamEvent, upsertConversationMessage } from "./assistant-events.js";
|
|
14
12
|
export type { ParsedAssistantStreamEvent } from "./assistant-events.js";
|
|
15
13
|
export { DEFAULT_RECORD_FORM_HIDDEN_FIELDS, buildRecordFormValues, buildRecordPayload, buildRecordSchemaFields, formatRecordValueForForm, getEditableRecordFields, getRecordFieldKind, orderRecordSchemaFields, } from "./record-form.js";
|
|
@@ -36,6 +34,5 @@ export type { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
|
|
|
36
34
|
export type { RecordsNamespace } from "./namespaces/records.js";
|
|
37
35
|
export type { ResourceType, ResourcesNamespace } from "./namespaces/resources.js";
|
|
38
36
|
export type { TablesNamespace } from "./namespaces/tables.js";
|
|
39
|
-
export type { TasksNamespace } from "./namespaces/tasks.js";
|
|
40
37
|
export type { UsersNamespace } from "./namespaces/users.js";
|
|
41
38
|
export type { WorkflowsNamespace } from "./namespaces/workflows.js";
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,7 @@ export { AuthManager, buildAuthUrl, buildFederatedLogoutUrl, clearTestingToken,
|
|
|
3
3
|
export { ApiError } from "./http.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
export { readSSE, parseSSEJson } from "./streams.js";
|
|
6
|
-
export { normalizeRunStatus,
|
|
7
|
-
export { parseTaskStreamEvent, upsertTaskMessage } from "./task-events.js";
|
|
6
|
+
export { normalizeRunStatus, isTerminalFunctionStatus, isTerminalFlowStatus, sleep, nextBackoffDelay, } from "./run-utils.js";
|
|
8
7
|
export { parseAssistantStreamEvent, upsertConversationMessage } from "./assistant-events.js";
|
|
9
8
|
export { DEFAULT_RECORD_FORM_HIDDEN_FIELDS, buildRecordFormValues, buildRecordPayload, buildRecordSchemaFields, formatRecordValueForForm, getEditableRecordFields, getRecordFieldKind, orderRecordSchemaFields, } from "./record-form.js";
|
|
10
9
|
export { buildDefaultRecordDetailFieldGroups, detectRecordDescriptionColumn, detectRecordStatusColumn, detectRecordTitleColumn, formatRecordDateDisplayValue, formatRecordDisplayValue, formatRecordPlainValue, humanizeRecordFieldName, isDefaultRecordDetailHiddenField, } from "./record-display.js";
|
|
@@ -46,13 +46,8 @@ export declare class ConversationsNamespace {
|
|
|
46
46
|
pod_id?: string | null;
|
|
47
47
|
signal?: AbortSignal;
|
|
48
48
|
}): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
49
|
-
sendOrCreateMessageStream(payload: SendMessageRequest, options?: {
|
|
50
|
-
pod_id?: string | null;
|
|
51
|
-
signal?: AbortSignal;
|
|
52
|
-
}): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
53
49
|
resumeStream(conversationId: string, options?: {
|
|
54
50
|
pod_id?: string | null;
|
|
55
|
-
agent_run_id?: string | null;
|
|
56
51
|
signal?: AbortSignal;
|
|
57
52
|
}): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
58
53
|
stopRun(conversationId: string, options?: {
|
|
@@ -118,24 +118,9 @@ export class ConversationsNamespace {
|
|
|
118
118
|
},
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
sendOrCreateMessageStream(payload, options = {}) {
|
|
122
|
-
const podId = this.requirePodId(options.pod_id);
|
|
123
|
-
return this.http.stream(`/pods/${podId}/conversations/messages`, {
|
|
124
|
-
method: "POST",
|
|
125
|
-
body: payload,
|
|
126
|
-
signal: options.signal,
|
|
127
|
-
headers: {
|
|
128
|
-
"Content-Type": "application/json",
|
|
129
|
-
Accept: "text/event-stream",
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
121
|
resumeStream(conversationId, options = {}) {
|
|
134
122
|
const podId = this.requirePodId(options.pod_id);
|
|
135
123
|
return this.http.stream(`/pods/${podId}/conversations/${conversationId}/stream`, {
|
|
136
|
-
params: {
|
|
137
|
-
agent_run_id: options.agent_run_id,
|
|
138
|
-
},
|
|
139
124
|
signal: options.signal,
|
|
140
125
|
headers: {
|
|
141
126
|
Accept: "text/event-stream",
|
|
@@ -4,7 +4,6 @@ import type { ThinkingContent } from './ThinkingContent.js';
|
|
|
4
4
|
import type { ToolCallContent } from './ToolCallContent.js';
|
|
5
5
|
import type { ToolReturnContent } from './ToolReturnContent.js';
|
|
6
6
|
export type MessageResponse = {
|
|
7
|
-
agent_run_id?: (string | null);
|
|
8
7
|
content: (NotificationContent | TextContent | ThinkingContent | ToolCallContent | ToolReturnContent);
|
|
9
8
|
conversation_id: string;
|
|
10
9
|
created_at: string;
|
|
@@ -26,15 +26,6 @@ export declare class AgentConversationsService {
|
|
|
26
26
|
* @throws ApiError
|
|
27
27
|
*/
|
|
28
28
|
static agentConversationCreate(podId: string, requestBody: CreateConversationRequest): CancelablePromise<ConversationResponse>;
|
|
29
|
-
/**
|
|
30
|
-
* Send Pod Conversation Message
|
|
31
|
-
* Create or continue a pod-scoped assistant or agent conversation and stream runtime events over Server-Sent Events until the active run completes. Provide agent_name to target a pod agent; omit it for the default pod assistant.
|
|
32
|
-
* @param podId
|
|
33
|
-
* @param requestBody
|
|
34
|
-
* @returns any Successful Response
|
|
35
|
-
* @throws ApiError
|
|
36
|
-
*/
|
|
37
|
-
static agentConversationMessageSendOrCreate(podId: string, requestBody: SendMessageRequest): CancelablePromise<any>;
|
|
38
29
|
/**
|
|
39
30
|
* Get Pod Conversation
|
|
40
31
|
* Get a single pod-scoped assistant or agent conversation by id.
|
|
@@ -67,7 +58,7 @@ export declare class AgentConversationsService {
|
|
|
67
58
|
static agentConversationMessageList(podId: string, conversationId: string, afterSequence?: (number | null), limit?: number): CancelablePromise<MessageListResponse>;
|
|
68
59
|
/**
|
|
69
60
|
* Send Pod Conversation Message
|
|
70
|
-
* Append a user message to a pod-scoped conversation and stream runtime events over Server-Sent Events until the active
|
|
61
|
+
* Append a user message to a pod-scoped conversation and stream runtime events over Server-Sent Events until the active turn completes. User messages can also be appended while work is already active; the next harness step sees the new message in persisted history.
|
|
71
62
|
* @param podId
|
|
72
63
|
* @param conversationId
|
|
73
64
|
* @param requestBody
|
|
@@ -77,7 +68,7 @@ export declare class AgentConversationsService {
|
|
|
77
68
|
static agentConversationMessageSend(podId: string, conversationId: string, requestBody: SendMessageRequest): CancelablePromise<any>;
|
|
78
69
|
/**
|
|
79
70
|
* Stop Pod Conversation
|
|
80
|
-
* Request cancellation of the active
|
|
71
|
+
* Request cancellation of the active conversation work.
|
|
81
72
|
* @param podId
|
|
82
73
|
* @param conversationId
|
|
83
74
|
* @returns ConversationResponse Successful Response
|
|
@@ -86,12 +77,11 @@ export declare class AgentConversationsService {
|
|
|
86
77
|
static agentConversationStop(podId: string, conversationId: string): CancelablePromise<ConversationResponse>;
|
|
87
78
|
/**
|
|
88
79
|
* Stream Pod Conversation
|
|
89
|
-
* Subscribe to Server-Sent Events for an existing pod-scoped conversation. The stream closes immediately when the conversation has no active
|
|
80
|
+
* Subscribe to Server-Sent Events for an existing pod-scoped conversation. The stream closes immediately when the conversation has no active work.
|
|
90
81
|
* @param podId
|
|
91
82
|
* @param conversationId
|
|
92
|
-
* @param agentRunId
|
|
93
83
|
* @returns any Successful Response
|
|
94
84
|
* @throws ApiError
|
|
95
85
|
*/
|
|
96
|
-
static agentConversationStream(podId: string, conversationId: string
|
|
86
|
+
static agentConversationStream(podId: string, conversationId: string): CancelablePromise<any>;
|
|
97
87
|
}
|
|
@@ -50,28 +50,6 @@ export class AgentConversationsService {
|
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Send Pod Conversation Message
|
|
55
|
-
* Create or continue a pod-scoped assistant or agent conversation and stream runtime events over Server-Sent Events until the active run completes. Provide agent_name to target a pod agent; omit it for the default pod assistant.
|
|
56
|
-
* @param podId
|
|
57
|
-
* @param requestBody
|
|
58
|
-
* @returns any Successful Response
|
|
59
|
-
* @throws ApiError
|
|
60
|
-
*/
|
|
61
|
-
static agentConversationMessageSendOrCreate(podId, requestBody) {
|
|
62
|
-
return __request(OpenAPI, {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
url: '/pods/{pod_id}/conversations/messages',
|
|
65
|
-
path: {
|
|
66
|
-
'pod_id': podId,
|
|
67
|
-
},
|
|
68
|
-
body: requestBody,
|
|
69
|
-
mediaType: 'application/json',
|
|
70
|
-
errors: {
|
|
71
|
-
422: `Validation Error`,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
53
|
/**
|
|
76
54
|
* Get Pod Conversation
|
|
77
55
|
* Get a single pod-scoped assistant or agent conversation by id.
|
|
@@ -146,7 +124,7 @@ export class AgentConversationsService {
|
|
|
146
124
|
}
|
|
147
125
|
/**
|
|
148
126
|
* Send Pod Conversation Message
|
|
149
|
-
* Append a user message to a pod-scoped conversation and stream runtime events over Server-Sent Events until the active
|
|
127
|
+
* Append a user message to a pod-scoped conversation and stream runtime events over Server-Sent Events until the active turn completes. User messages can also be appended while work is already active; the next harness step sees the new message in persisted history.
|
|
150
128
|
* @param podId
|
|
151
129
|
* @param conversationId
|
|
152
130
|
* @param requestBody
|
|
@@ -170,7 +148,7 @@ export class AgentConversationsService {
|
|
|
170
148
|
}
|
|
171
149
|
/**
|
|
172
150
|
* Stop Pod Conversation
|
|
173
|
-
* Request cancellation of the active
|
|
151
|
+
* Request cancellation of the active conversation work.
|
|
174
152
|
* @param podId
|
|
175
153
|
* @param conversationId
|
|
176
154
|
* @returns ConversationResponse Successful Response
|
|
@@ -191,14 +169,13 @@ export class AgentConversationsService {
|
|
|
191
169
|
}
|
|
192
170
|
/**
|
|
193
171
|
* Stream Pod Conversation
|
|
194
|
-
* Subscribe to Server-Sent Events for an existing pod-scoped conversation. The stream closes immediately when the conversation has no active
|
|
172
|
+
* Subscribe to Server-Sent Events for an existing pod-scoped conversation. The stream closes immediately when the conversation has no active work.
|
|
195
173
|
* @param podId
|
|
196
174
|
* @param conversationId
|
|
197
|
-
* @param agentRunId
|
|
198
175
|
* @returns any Successful Response
|
|
199
176
|
* @throws ApiError
|
|
200
177
|
*/
|
|
201
|
-
static agentConversationStream(podId, conversationId
|
|
178
|
+
static agentConversationStream(podId, conversationId) {
|
|
202
179
|
return __request(OpenAPI, {
|
|
203
180
|
method: 'GET',
|
|
204
181
|
url: '/pods/{pod_id}/conversations/{conversation_id}/stream',
|
|
@@ -206,9 +183,6 @@ export class AgentConversationsService {
|
|
|
206
183
|
'pod_id': podId,
|
|
207
184
|
'conversation_id': conversationId,
|
|
208
185
|
},
|
|
209
|
-
query: {
|
|
210
|
-
'agent_run_id': agentRunId,
|
|
211
|
-
},
|
|
212
186
|
errors: {
|
|
213
187
|
422: `Validation Error`,
|
|
214
188
|
},
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,18 +2,12 @@ export { AuthGuard } from "./AuthGuard.js";
|
|
|
2
2
|
export type { AuthGuardProps } from "./AuthGuard.js";
|
|
3
3
|
export { useAuth } from "./useAuth.js";
|
|
4
4
|
export type { UseAuthResult } from "./useAuth.js";
|
|
5
|
-
export { useAssistantRun } from "./useAssistantRun.js";
|
|
6
|
-
export type { UseAssistantRunOptions, UseAssistantRunResult } from "./useAssistantRun.js";
|
|
7
5
|
export { useConversations } from "./useConversations.js";
|
|
8
6
|
export type { UseConversationsOptions, UseConversationsResult } from "./useConversations.js";
|
|
9
7
|
export { useConversation } from "./useConversation.js";
|
|
10
8
|
export type { UseConversationOptions, UseConversationResult } from "./useConversation.js";
|
|
11
9
|
export { useConversationMessages } from "./useConversationMessages.js";
|
|
12
10
|
export type { UseConversationMessagesOptions, UseConversationMessagesResult, } from "./useConversationMessages.js";
|
|
13
|
-
export { useAgentRun } from "./useAgentRun.js";
|
|
14
|
-
export type { UseAgentRunOptions, UseAgentRunResult } from "./useAgentRun.js";
|
|
15
|
-
export { useAgentRuns } from "./useAgentRuns.js";
|
|
16
|
-
export type { UseAgentRunsOptions, UseAgentRunsResult } from "./useAgentRuns.js";
|
|
17
11
|
export { useAgentInputSchema } from "./useAgentInputSchema.js";
|
|
18
12
|
export type { UseAgentInputSchemaOptions, UseAgentInputSchemaResult, } from "./useAgentInputSchema.js";
|
|
19
13
|
export { useAssistantSession } from "./useAssistantSession.js";
|
|
@@ -92,8 +86,6 @@ export { useSchemaForm } from "./useSchemaForm.js";
|
|
|
92
86
|
export type { UseSchemaFormOptions, UseSchemaFormResult } from "./useSchemaForm.js";
|
|
93
87
|
export { useAssistantController } from "./useAssistantController.js";
|
|
94
88
|
export type { AssistantAction, AssistantConversationScope, AssistantMessagePart, AssistantRenderableMessage, AssistantToolInvocation, UseAssistantControllerOptions, UseAssistantControllerResult, } from "./useAssistantController.js";
|
|
95
|
-
export { useTaskSession } from "./useTaskSession.js";
|
|
96
|
-
export type { CreateTaskInput, UseTaskSessionOptions, UseTaskSessionResult, } from "./useTaskSession.js";
|
|
97
89
|
export { useFunctionSession } from "./useFunctionSession.js";
|
|
98
90
|
export type { UseFunctionSessionOptions, UseFunctionSessionResult, } from "./useFunctionSession.js";
|
|
99
91
|
export { useFunctionRun } from "./useFunctionRun.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export { AuthGuard } from "./AuthGuard.js";
|
|
2
2
|
export { useAuth } from "./useAuth.js";
|
|
3
|
-
export { useAssistantRun } from "./useAssistantRun.js";
|
|
4
3
|
export { useConversations } from "./useConversations.js";
|
|
5
4
|
export { useConversation } from "./useConversation.js";
|
|
6
5
|
export { useConversationMessages } from "./useConversationMessages.js";
|
|
7
|
-
export { useAgentRun } from "./useAgentRun.js";
|
|
8
|
-
export { useAgentRuns } from "./useAgentRuns.js";
|
|
9
6
|
export { useAgentInputSchema } from "./useAgentInputSchema.js";
|
|
10
7
|
export { useAssistantSession } from "./useAssistantSession.js";
|
|
11
8
|
export { useAssistantRuntime } from "./useAssistantRuntime.js";
|
|
@@ -45,7 +42,6 @@ export { useRecordSchema } from "./useRecordSchema.js";
|
|
|
45
42
|
export { useRecordForm } from "./useRecordForm.js";
|
|
46
43
|
export { useSchemaForm } from "./useSchemaForm.js";
|
|
47
44
|
export { useAssistantController } from "./useAssistantController.js";
|
|
48
|
-
export { useTaskSession } from "./useTaskSession.js";
|
|
49
45
|
export { useFunctionSession } from "./useFunctionSession.js";
|
|
50
46
|
export { useFunctionRun } from "./useFunctionRun.js";
|
|
51
47
|
export { useFunctionRuns } from "./useFunctionRuns.js";
|
|
@@ -1057,7 +1057,6 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1057
1057
|
touchConversation(finalConversationId, { status: "running" });
|
|
1058
1058
|
await sessionSendMessage(messageContent, {
|
|
1059
1059
|
conversationId: finalConversationId,
|
|
1060
|
-
createIfMissing: false,
|
|
1061
1060
|
});
|
|
1062
1061
|
touchConversation(finalConversationId, { updated_at: new Date().toISOString() });
|
|
1063
1062
|
}
|
|
@@ -1102,7 +1101,6 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1102
1101
|
setIsStreaming(true);
|
|
1103
1102
|
await sessionSendMessage(fileMessage, {
|
|
1104
1103
|
conversationId: activeId,
|
|
1105
|
-
createIfMissing: false,
|
|
1106
1104
|
});
|
|
1107
1105
|
await loadConversationMessages(activeId);
|
|
1108
1106
|
touchConversation(activeId, { updated_at: new Date().toISOString() });
|
|
@@ -54,8 +54,6 @@ export interface CreateConversationInput {
|
|
|
54
54
|
}
|
|
55
55
|
export interface SendAssistantMessageOptions {
|
|
56
56
|
conversationId?: string | null;
|
|
57
|
-
createIfMissing?: boolean;
|
|
58
|
-
createConversation?: CreateConversationInput;
|
|
59
57
|
syncOnTurnEnd?: boolean;
|
|
60
58
|
}
|
|
61
59
|
export interface ResumeAssistantOptions {
|
|
@@ -342,7 +342,7 @@ export function useAssistantSession(options) {
|
|
|
342
342
|
}
|
|
343
343
|
catch (streamError) {
|
|
344
344
|
if (!(streamError instanceof Error && streamError.name === "AbortError")) {
|
|
345
|
-
const normalized = normalizeError(streamError, "Failed to stream
|
|
345
|
+
const normalized = normalizeError(streamError, "Failed to stream conversation.");
|
|
346
346
|
setError(normalized);
|
|
347
347
|
onErrorRef.current?.(streamError);
|
|
348
348
|
}
|
|
@@ -362,7 +362,7 @@ export function useAssistantSession(options) {
|
|
|
362
362
|
setConversationStatus,
|
|
363
363
|
syncOnTurnEnd,
|
|
364
364
|
]);
|
|
365
|
-
const ensureConversation = useCallback(async (overrideConversationId
|
|
365
|
+
const ensureConversation = useCallback(async (overrideConversationId) => {
|
|
366
366
|
const existingId = overrideConversationId ?? conversationId;
|
|
367
367
|
if (existingId) {
|
|
368
368
|
// Avoid a network roundtrip on every send when we already have this conversation in state.
|
|
@@ -374,23 +374,17 @@ export function useAssistantSession(options) {
|
|
|
374
374
|
return existing;
|
|
375
375
|
throw new Error("Failed to resolve existing conversation.");
|
|
376
376
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
return createConversation({
|
|
381
|
-
...(options.createConversation ?? {}),
|
|
382
|
-
setActive: true,
|
|
383
|
-
});
|
|
384
|
-
}, [conversation, conversationId, createConversation, refreshConversation]);
|
|
377
|
+
throw new Error("conversationId is required. Create a conversation before sending a message.");
|
|
378
|
+
}, [conversation, conversationId, refreshConversation]);
|
|
385
379
|
const sendMessage = useCallback(async (content, input = {}) => {
|
|
386
380
|
setError(null);
|
|
387
381
|
try {
|
|
388
|
-
const resolvedConversation = await ensureConversation(input.conversationId
|
|
382
|
+
const resolvedConversation = await ensureConversation(input.conversationId);
|
|
389
383
|
const resolvedConversationId = requireConversationId(resolvedConversation.id);
|
|
390
384
|
cancel();
|
|
391
385
|
const controller = new AbortController();
|
|
392
386
|
abortRef.current = controller;
|
|
393
|
-
const scope = normalizeScope(client, defaultScope
|
|
387
|
+
const scope = normalizeScope(client, defaultScope);
|
|
394
388
|
const scopedClient = applyPodScope(client, scope.podId);
|
|
395
389
|
const stream = await scopedClient.conversations.sendMessageStream(resolvedConversationId, { content }, {
|
|
396
390
|
pod_id: scope.podId ?? undefined,
|
|
@@ -438,7 +432,7 @@ export function useAssistantSession(options) {
|
|
|
438
432
|
});
|
|
439
433
|
}
|
|
440
434
|
catch (resumeError) {
|
|
441
|
-
const normalized = normalizeError(resumeError, "Failed to resume
|
|
435
|
+
const normalized = normalizeError(resumeError, "Failed to resume conversation.");
|
|
442
436
|
setError(normalized);
|
|
443
437
|
onErrorRef.current?.(resumeError);
|
|
444
438
|
throw normalized;
|
|
@@ -491,7 +485,7 @@ export function useAssistantSession(options) {
|
|
|
491
485
|
clearStreamingText();
|
|
492
486
|
}
|
|
493
487
|
catch (stopError) {
|
|
494
|
-
const normalized = normalizeError(stopError, "Failed to stop
|
|
488
|
+
const normalized = normalizeError(stopError, "Failed to stop conversation.");
|
|
495
489
|
setError(normalized);
|
|
496
490
|
onErrorRef.current?.(stopError);
|
|
497
491
|
throw normalized;
|