@assistant-ui/react-ag-ui 0.0.60 → 0.0.62
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/agUiExtras.d.ts +1 -3
- package/dist/agUiExtras.d.ts.map +1 -1
- package/dist/hooks.d.ts +3 -5
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts +152 -144
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadRuntimeCore.js +141 -23
- package/dist/runtime/AgUiThreadRuntimeCore.js.map +1 -1
- package/dist/runtime/adapter/conversions.d.ts +51 -53
- package/dist/runtime/adapter/conversions.d.ts.map +1 -1
- package/dist/runtime/adapter/conversions.js +65 -21
- package/dist/runtime/adapter/conversions.js.map +1 -1
- package/dist/runtime/adapter/run-aggregator.d.ts +89 -88
- package/dist/runtime/adapter/run-aggregator.d.ts.map +1 -1
- package/dist/runtime/adapter/run-aggregator.js +35 -2
- package/dist/runtime/adapter/run-aggregator.js.map +1 -1
- package/dist/runtime/adapter/subscriber.d.ts +107 -108
- package/dist/runtime/adapter/subscriber.d.ts.map +1 -1
- package/dist/runtime/adapter/tool-approval.d.ts +3 -4
- package/dist/runtime/adapter/tool-approval.d.ts.map +1 -1
- package/dist/runtime/event-parser.d.ts +3 -5
- package/dist/runtime/event-parser.d.ts.map +1 -1
- package/dist/runtime/interrupt-internals.d.ts +1 -3
- package/dist/runtime/interrupt-internals.d.ts.map +1 -1
- package/dist/runtime/logger.d.ts +2 -4
- package/dist/runtime/logger.d.ts.map +1 -1
- package/dist/runtime/mcp-tool-result.d.ts +4 -6
- package/dist/runtime/mcp-tool-result.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +237 -238
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/useAgUiRuntime.d.ts +13 -15
- package/dist/useAgUiRuntime.d.ts.map +1 -1
- package/dist/useAgUiRuntime.js +9 -2
- package/dist/useAgUiRuntime.js.map +1 -1
- package/package.json +6 -6
- package/src/runtime/AgUiThreadRuntimeCore.ts +239 -32
- package/src/runtime/adapter/conversions.content.test.ts +56 -0
- package/src/runtime/adapter/conversions.ts +112 -44
- package/src/runtime/adapter/run-aggregator.ts +53 -2
- package/src/useAgUiRuntime.history.test.tsx +93 -2
- package/src/useAgUiRuntime.thread-switch.test.tsx +84 -4
- package/src/useAgUiRuntime.ts +12 -3
- package/src/useAgUiRuntime.voice.test.tsx +402 -0
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
//#region src/runtime/types.d.ts
|
|
1
|
+
import type { CreateAppendMessage, AttachmentAdapter, DictationAdapter, ExternalStoreSharedOptions, ExternalStoreThreadListAdapter, FeedbackAdapter, RealtimeVoiceAdapter, SpeechSynthesisAdapter, ThreadHistoryAdapter, ThreadMessage } from "@assistant-ui/core";
|
|
2
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
3
|
+
import type { Logger } from "./logger.js";
|
|
4
|
+
import type { ReadonlyJSONValue } from "assistant-stream/utils";
|
|
5
|
+
import type { McpToolCallResult } from "./mcp-tool-result.js";
|
|
7
6
|
/**
|
|
8
7
|
* @experimental This API is still under active development and might change without notice.
|
|
9
8
|
*
|
|
@@ -11,259 +10,259 @@ import { ReadonlyJSONValue } from "assistant-stream/utils";
|
|
|
11
10
|
* the messages (and optional state) to hydrate the thread with.
|
|
12
11
|
*/
|
|
13
12
|
type SwitchToThreadResult = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
messages: readonly ThreadMessage[];
|
|
14
|
+
state?: ReadonlyJSONValue;
|
|
15
|
+
/**
|
|
16
|
+
* Set when the thread has a run in flight. The runtime resumes the run
|
|
17
|
+
* after hydrating, the same way `ThreadHistoryAdapter.load()` does when it
|
|
18
|
+
* returns `unstable_resume: true`.
|
|
19
|
+
*/
|
|
20
|
+
unstable_resume?: boolean;
|
|
22
21
|
};
|
|
23
22
|
export type UseAgUiThreadListAdapter = Omit<ExternalStoreThreadListAdapter, "onSwitchToThread"> & {
|
|
24
|
-
|
|
23
|
+
onSwitchToThread?: ((threadId: string) => Promise<SwitchToThreadResult> | SwitchToThreadResult) | undefined;
|
|
25
24
|
};
|
|
26
25
|
export type UseAgUiRuntimeAdapters = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
attachments?: AttachmentAdapter;
|
|
27
|
+
speech?: SpeechSynthesisAdapter;
|
|
28
|
+
dictation?: DictationAdapter;
|
|
29
|
+
voice?: RealtimeVoiceAdapter;
|
|
30
|
+
feedback?: FeedbackAdapter;
|
|
31
|
+
history?: ThreadHistoryAdapter;
|
|
32
|
+
/**
|
|
33
|
+
* @experimental This API is still under active development and might change without notice.
|
|
34
|
+
*/
|
|
35
|
+
threadList?: UseAgUiThreadListAdapter;
|
|
37
36
|
};
|
|
38
37
|
export type AgUiResumeTranscript = "full" | "appended";
|
|
39
38
|
export type UseAgUiRuntimeOptions = ExternalStoreSharedOptions & {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
39
|
+
agent: AbstractAgent;
|
|
40
|
+
logger?: Partial<Logger>;
|
|
41
|
+
showThinking?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* What `messages` carries on a resume run, meaning a `RunAgentInput` that
|
|
44
|
+
* also carries `resume`. The AG-UI interrupt spec leaves this undefined: its
|
|
45
|
+
* contract rules constrain the thread id, interrupt coverage, idempotency,
|
|
46
|
+
* and expiry, and none of them mentions `messages`. Hosts therefore disagree,
|
|
47
|
+
* and both readings are conformant.
|
|
48
|
+
*
|
|
49
|
+
* `"full"` sends the whole thread, which is what `@ag-ui/client` itself does.
|
|
50
|
+
* Hosts that resume from a checkpoint ignore the transcript, and hosts that
|
|
51
|
+
* rebuild the interrupted run from it need it.
|
|
52
|
+
*
|
|
53
|
+
* `"appended"` sends only what was appended locally after the interrupted
|
|
54
|
+
* assistant message, which is nothing for an approval or a denial and the new
|
|
55
|
+
* user turn for `steerAway`. Choose it for a host that owns the thread and
|
|
56
|
+
* seeds a resume request from its own stored snapshot, because such a host
|
|
57
|
+
* appends the request body to that snapshot and a re-sent transcript
|
|
58
|
+
* duplicates the interrupted turn in its stored history. A host that rebuilds
|
|
59
|
+
* the run from `messages` has nothing to resume from under `"appended"`, and
|
|
60
|
+
* a host that derives its outgoing `MESSAGES_SNAPSHOT` from the request body
|
|
61
|
+
* emits a truncated one.
|
|
62
|
+
*
|
|
63
|
+
* Defaults to `"full"`.
|
|
64
|
+
*/
|
|
65
|
+
resumeTranscript?: AgUiResumeTranscript | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* When the user sends, edits, or reloads a message while client-side tool
|
|
68
|
+
* calls are still pending, automatically cancel the unresolved tool calls
|
|
69
|
+
* with an error result so the agent's tool-call accounting stays
|
|
70
|
+
* consistent. Pending AG-UI interrupts are exempt: they still reject the
|
|
71
|
+
* run and must be answered with `useAgUiSubmitInterruptResponses` or
|
|
72
|
+
* discarded with `useAgUiSteerAway`. When disabled, `useAgUiSteerAway`
|
|
73
|
+
* remains the explicit way to cancel pending tool calls.
|
|
74
|
+
* Defaults to `true`.
|
|
75
|
+
*/
|
|
76
|
+
autoCancelPendingToolCalls?: boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Buffer a message sent while a run is in flight and send it once the run
|
|
79
|
+
* settles, exposing it on `composer.queue` for `ComposerPrimitive.Queue`.
|
|
80
|
+
* The runtime owns the queue lifecycle because flushing needs the agent's
|
|
81
|
+
* send path and the run's own busy and idle edges.
|
|
82
|
+
*/
|
|
83
|
+
unstable_enableMessageQueue?: boolean | undefined;
|
|
84
|
+
onError?: (e: Error) => void;
|
|
85
|
+
onCancel?: () => void;
|
|
86
|
+
adapters?: UseAgUiRuntimeAdapters;
|
|
88
87
|
};
|
|
89
88
|
export type AgUiInterruptReason = "tool_call" | "input_required" | "confirmation" | (string & {});
|
|
90
89
|
export type AgUiInterrupt = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
id: string;
|
|
91
|
+
reason: AgUiInterruptReason;
|
|
92
|
+
message?: string;
|
|
93
|
+
toolCallId?: string;
|
|
94
|
+
responseSchema?: Record<string, unknown>;
|
|
95
|
+
expiresAt?: string;
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
98
97
|
};
|
|
99
98
|
export type AgUiResumeEntry = {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
interruptId: string;
|
|
100
|
+
status: "resolved" | "cancelled";
|
|
101
|
+
payload?: unknown;
|
|
103
102
|
};
|
|
104
103
|
export type AgUiRuntimeExtras = {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
interrupts: readonly AgUiInterrupt[];
|
|
105
|
+
sendA2uiAction: (action: Record<string, unknown>) => void;
|
|
106
|
+
submitInterruptResponses: (responses: readonly AgUiResumeEntry[]) => Promise<void>;
|
|
107
|
+
steerAway: (message: CreateAppendMessage, responses?: readonly AgUiResumeEntry[]) => Promise<void>;
|
|
108
|
+
state: ReadonlyJSONValue | undefined;
|
|
109
|
+
setState: (next: ReadonlyJSONValue | ((prev: ReadonlyJSONValue | undefined) => ReadonlyJSONValue)) => void;
|
|
111
110
|
};
|
|
112
111
|
export type AgUiRunFinishedOutcome = {
|
|
113
|
-
|
|
112
|
+
type: "success";
|
|
114
113
|
} | {
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
type: "interrupt";
|
|
115
|
+
interrupts: AgUiInterrupt[];
|
|
117
116
|
};
|
|
118
117
|
export type AgUiSubagentFinishedOutcome = {
|
|
119
|
-
|
|
118
|
+
type: "success";
|
|
120
119
|
} | {
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
type: "suspended";
|
|
121
|
+
interruptIds?: string[];
|
|
123
122
|
};
|
|
124
123
|
export type AgUiEvent = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
} | {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} | {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
} | {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} | {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} | {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} | {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} | {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} | {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
} | {
|
|
160
|
-
|
|
161
|
-
} | {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} | {
|
|
165
|
-
|
|
166
|
-
} | {
|
|
167
|
-
|
|
168
|
-
} | {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} | {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} | {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} | {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} | {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
} | {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
} | {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
} | {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} | {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} | {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
} | {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
} | {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} | {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} | {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
} | {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
} | {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} | {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
} | {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
} | {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
} | {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
124
|
+
type: "RUN_STARTED";
|
|
125
|
+
runId: string;
|
|
126
|
+
} | {
|
|
127
|
+
type: "RUN_FINISHED";
|
|
128
|
+
runId: string;
|
|
129
|
+
outcome?: AgUiRunFinishedOutcome;
|
|
130
|
+
} | {
|
|
131
|
+
type: "RUN_CANCELLED";
|
|
132
|
+
runId?: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "RUN_ERROR";
|
|
135
|
+
message?: string;
|
|
136
|
+
code?: string;
|
|
137
|
+
} | {
|
|
138
|
+
type: "TEXT_MESSAGE_START";
|
|
139
|
+
messageId?: string;
|
|
140
|
+
subagentRunId?: string;
|
|
141
|
+
} | {
|
|
142
|
+
type: "TEXT_MESSAGE_CONTENT";
|
|
143
|
+
messageId?: string;
|
|
144
|
+
delta: string;
|
|
145
|
+
subagentRunId?: string;
|
|
146
|
+
} | {
|
|
147
|
+
type: "TEXT_MESSAGE_END";
|
|
148
|
+
messageId?: string;
|
|
149
|
+
subagentRunId?: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: "TEXT_MESSAGE_CHUNK";
|
|
152
|
+
messageId?: string;
|
|
153
|
+
delta: string;
|
|
154
|
+
subagentRunId?: string;
|
|
155
|
+
} | {
|
|
156
|
+
type: "THINKING_START";
|
|
157
|
+
title?: string;
|
|
158
|
+
} | {
|
|
159
|
+
type: "THINKING_TEXT_MESSAGE_START";
|
|
160
|
+
} | {
|
|
161
|
+
type: "THINKING_TEXT_MESSAGE_CONTENT";
|
|
162
|
+
delta: string;
|
|
163
|
+
} | {
|
|
164
|
+
type: "THINKING_TEXT_MESSAGE_END";
|
|
165
|
+
} | {
|
|
166
|
+
type: "THINKING_END";
|
|
167
|
+
} | {
|
|
168
|
+
type: "REASONING_START";
|
|
169
|
+
messageId?: string;
|
|
170
|
+
subagentRunId?: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: "REASONING_MESSAGE_START";
|
|
173
|
+
messageId?: string;
|
|
174
|
+
subagentRunId?: string;
|
|
175
|
+
} | {
|
|
176
|
+
type: "REASONING_MESSAGE_CONTENT";
|
|
177
|
+
messageId?: string;
|
|
178
|
+
delta: string;
|
|
179
|
+
subagentRunId?: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "REASONING_MESSAGE_END";
|
|
182
|
+
messageId?: string;
|
|
183
|
+
subagentRunId?: string;
|
|
184
|
+
} | {
|
|
185
|
+
type: "REASONING_ENCRYPTED_VALUE";
|
|
186
|
+
subtype: "message" | "tool-call";
|
|
187
|
+
entityId: string;
|
|
188
|
+
encryptedValue: string;
|
|
189
|
+
subagentRunId?: string;
|
|
190
|
+
} | {
|
|
191
|
+
type: "REASONING_END";
|
|
192
|
+
messageId?: string;
|
|
193
|
+
subagentRunId?: string;
|
|
194
|
+
} | {
|
|
195
|
+
type: "TOOL_CALL_START";
|
|
196
|
+
toolCallId: string;
|
|
197
|
+
toolCallName?: string;
|
|
198
|
+
parentMessageId?: string;
|
|
199
|
+
subagentRunId?: string;
|
|
200
|
+
} | {
|
|
201
|
+
type: "TOOL_CALL_ARGS";
|
|
202
|
+
toolCallId: string;
|
|
203
|
+
delta: string;
|
|
204
|
+
subagentRunId?: string;
|
|
205
|
+
} | {
|
|
206
|
+
type: "TOOL_CALL_END";
|
|
207
|
+
toolCallId: string;
|
|
208
|
+
subagentRunId?: string;
|
|
209
|
+
} | {
|
|
210
|
+
type: "TOOL_CALL_CHUNK";
|
|
211
|
+
toolCallId?: string;
|
|
212
|
+
toolCallName?: string;
|
|
213
|
+
parentMessageId?: string;
|
|
214
|
+
delta?: string;
|
|
215
|
+
subagentRunId?: string;
|
|
216
|
+
} | {
|
|
217
|
+
type: "TOOL_CALL_RESULT";
|
|
218
|
+
messageId?: string;
|
|
219
|
+
toolCallId: string;
|
|
220
|
+
content: string;
|
|
221
|
+
role?: "tool";
|
|
222
|
+
mcpResult?: McpToolCallResult;
|
|
223
|
+
subagentRunId?: string;
|
|
224
|
+
} | {
|
|
225
|
+
type: "ACTIVITY_SNAPSHOT";
|
|
226
|
+
activityType: string;
|
|
227
|
+
content: Record<string, unknown>;
|
|
228
|
+
messageId?: string;
|
|
229
|
+
replace?: boolean;
|
|
230
|
+
subagentRunId?: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: "RAW";
|
|
233
|
+
event: any;
|
|
234
|
+
source?: string;
|
|
235
|
+
} | {
|
|
236
|
+
type: "CUSTOM";
|
|
237
|
+
name: string;
|
|
238
|
+
value: any;
|
|
239
|
+
} | {
|
|
240
|
+
type: "STATE_SNAPSHOT";
|
|
241
|
+
snapshot: any;
|
|
242
|
+
} | {
|
|
243
|
+
type: "STATE_DELTA";
|
|
244
|
+
delta: any[];
|
|
245
|
+
} | {
|
|
246
|
+
type: "MESSAGES_SNAPSHOT";
|
|
247
|
+
messages: any[];
|
|
248
|
+
} | {
|
|
249
|
+
type: "SUBAGENT_STARTED";
|
|
250
|
+
subagentRunId: string;
|
|
251
|
+
name: string;
|
|
252
|
+
description?: string;
|
|
253
|
+
parentSubagentRunId?: string;
|
|
254
|
+
parentToolCallId?: string;
|
|
255
|
+
parentMessageId?: string;
|
|
256
|
+
} | {
|
|
257
|
+
type: "SUBAGENT_FINISHED";
|
|
258
|
+
subagentRunId: string;
|
|
259
|
+
result?: unknown;
|
|
260
|
+
outcome?: AgUiSubagentFinishedOutcome;
|
|
261
|
+
} | {
|
|
262
|
+
type: "SUBAGENT_ERROR";
|
|
263
|
+
subagentRunId: string;
|
|
264
|
+
message: string;
|
|
265
|
+
code?: string;
|
|
267
266
|
};
|
|
268
|
-
|
|
267
|
+
export {};
|
|
269
268
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
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;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
package/dist/useAgUiRuntime.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/useAgUiRuntime.d.ts
|
|
1
|
+
import type { AssistantRuntime } from "@assistant-ui/core";
|
|
2
|
+
import type { AgUiInterrupt, AgUiResumeEntry, UseAgUiRuntimeOptions } from "./runtime/types.js";
|
|
4
3
|
export type AgUiAssistantRuntime = AssistantRuntime & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use the `useAgUiInterrupts()` hook instead. This method is kept
|
|
6
|
+
* for backward compatibility and will be removed in a future major release.
|
|
7
|
+
*/
|
|
8
|
+
unstable_getPendingInterrupts: () => readonly AgUiInterrupt[];
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use the `useAgUiSubmitInterruptResponses()` hook instead. This
|
|
11
|
+
* method is kept for backward compatibility and will be removed in a future
|
|
12
|
+
* major release.
|
|
13
|
+
*/
|
|
14
|
+
unstable_submitInterruptResponses: (responses: readonly AgUiResumeEntry[]) => Promise<void>;
|
|
16
15
|
};
|
|
17
16
|
export declare function useAgUiRuntime(options: UseAgUiRuntimeOptions): AgUiAssistantRuntime;
|
|
18
|
-
//#endregion
|
|
19
17
|
//# sourceMappingURL=useAgUiRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgUiRuntime.d.ts","
|
|
1
|
+
{"version":3,"file":"useAgUiRuntime.d.ts","sourceRoot":"","sources":["../src/useAgUiRuntime.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,gBAAgB,EAIjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACtB,2BAAwB;AASzB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD;;;OAGG;IACH,6BAA6B,EAAE,MAAM,SAAS,aAAa,EAAE,CAAC;IAC9D;;;;OAIG;IACH,iCAAiC,EAAE,CACjC,SAAS,EAAE,SAAS,eAAe,EAAE,KAClC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,CAgRtB"}
|
package/dist/useAgUiRuntime.js
CHANGED
|
@@ -82,19 +82,23 @@ function useAgUiRuntime(options) {
|
|
|
82
82
|
...rest,
|
|
83
83
|
onSwitchToNewThread: onSwitchToNewThread ? async () => {
|
|
84
84
|
const generation = ++threadSwitchGenerationRef.current;
|
|
85
|
+
core.applyExternalMessages([]);
|
|
86
|
+
core.resetThreadState();
|
|
85
87
|
await onSwitchToNewThread();
|
|
86
88
|
if (generation !== threadSwitchGenerationRef.current) return;
|
|
87
89
|
core.applyExternalMessages([]);
|
|
88
|
-
core.
|
|
90
|
+
core.resetThreadState();
|
|
89
91
|
} : void 0,
|
|
90
92
|
onSwitchToThread: onSwitchToThread ? async (threadId) => {
|
|
91
93
|
const generation = ++threadSwitchGenerationRef.current;
|
|
92
94
|
core.applyExternalMessages([]);
|
|
95
|
+
core.resetThreadState();
|
|
93
96
|
const result = await onSwitchToThread(threadId);
|
|
94
97
|
if (generation !== threadSwitchGenerationRef.current) return;
|
|
98
|
+
core.applyExternalMessages([]);
|
|
99
|
+
core.resetThreadState();
|
|
95
100
|
core.applyExternalMessages(result.messages);
|
|
96
101
|
if (result.state !== void 0) core.loadExternalState(result.state);
|
|
97
|
-
else core.resetState();
|
|
98
102
|
if (result.unstable_resume) core.resumeInFlightRun(result.messages);
|
|
99
103
|
} : void 0
|
|
100
104
|
};
|
|
@@ -129,8 +133,10 @@ function useAgUiRuntime(options) {
|
|
|
129
133
|
setState: (next) => core.setState(next)
|
|
130
134
|
}),
|
|
131
135
|
unstable_enableToolInvocations: true,
|
|
136
|
+
unstable_persistsHistory: true,
|
|
132
137
|
setToolStatuses,
|
|
133
138
|
onNew: (message) => core.append(message),
|
|
139
|
+
onVoiceTranscript: (message) => core.appendVoiceTranscript(message),
|
|
134
140
|
onEdit: (message) => {
|
|
135
141
|
queueController?.clear();
|
|
136
142
|
return core.edit(message);
|
|
@@ -144,6 +150,7 @@ function useAgUiRuntime(options) {
|
|
|
144
150
|
core.cancel();
|
|
145
151
|
},
|
|
146
152
|
onAddToolResult: (options) => core.addToolResult(options),
|
|
153
|
+
unstable_onRecordToolInteraction: (options) => core.recordToolInteraction(options),
|
|
147
154
|
onRespondToToolApproval: (options) => core.respondToToolApproval(options).catch((error) => {
|
|
148
155
|
core.reportError(error);
|
|
149
156
|
throw error;
|