@assistant-ui/react-ag-ui 0.0.29 → 0.0.31
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 +41 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts +11 -0
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadRuntimeCore.js +186 -12
- package/dist/runtime/AgUiThreadRuntimeCore.js.map +1 -1
- package/dist/runtime/adapter/run-aggregator.d.ts +18 -5
- package/dist/runtime/adapter/run-aggregator.d.ts.map +1 -1
- package/dist/runtime/adapter/run-aggregator.js +134 -39
- package/dist/runtime/adapter/run-aggregator.js.map +1 -1
- package/dist/runtime/adapter/subscriber.d.ts +5 -0
- package/dist/runtime/adapter/subscriber.d.ts.map +1 -1
- package/dist/runtime/adapter/subscriber.js +55 -36
- package/dist/runtime/adapter/subscriber.js.map +1 -1
- package/dist/runtime/event-parser.d.ts +5 -1
- package/dist/runtime/event-parser.d.ts.map +1 -1
- package/dist/runtime/event-parser.js +48 -2
- package/dist/runtime/event-parser.js.map +1 -1
- package/dist/runtime/types.d.ts +22 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/useAgUiRuntime.d.ts +6 -2
- package/dist/useAgUiRuntime.d.ts.map +1 -1
- package/dist/useAgUiRuntime.js +7 -1
- package/dist/useAgUiRuntime.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -0
- package/src/runtime/AgUiThreadRuntimeCore.ts +251 -11
- package/src/runtime/adapter/run-aggregator.ts +168 -44
- package/src/runtime/adapter/subscriber.ts +53 -43
- package/src/runtime/event-parser.ts +64 -3
- package/src/runtime/types.ts +31 -1
- package/src/useAgUiRuntime.ts +23 -3
package/src/useAgUiRuntime.ts
CHANGED
|
@@ -15,12 +15,23 @@ import type {
|
|
|
15
15
|
} from "@assistant-ui/core";
|
|
16
16
|
import type { ReadonlyJSONValue } from "assistant-stream/utils";
|
|
17
17
|
import { makeLogger } from "./runtime/logger";
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
AgUiInterrupt,
|
|
20
|
+
AgUiResumeEntry,
|
|
21
|
+
UseAgUiRuntimeOptions,
|
|
22
|
+
} from "./runtime/types";
|
|
19
23
|
import { AgUiThreadRuntimeCore } from "./runtime/AgUiThreadRuntimeCore";
|
|
20
24
|
|
|
25
|
+
export type AgUiAssistantRuntime = AssistantRuntime & {
|
|
26
|
+
unstable_getPendingInterrupts: () => readonly AgUiInterrupt[];
|
|
27
|
+
unstable_submitInterruptResponses: (
|
|
28
|
+
responses: readonly AgUiResumeEntry[],
|
|
29
|
+
) => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
|
|
21
32
|
export function useAgUiRuntime(
|
|
22
33
|
options: UseAgUiRuntimeOptions,
|
|
23
|
-
):
|
|
34
|
+
): AgUiAssistantRuntime {
|
|
24
35
|
const logger = useMemo(() => makeLogger(options.logger), [options.logger]);
|
|
25
36
|
const [_version, setVersion] = useState(0);
|
|
26
37
|
const notifyUpdate = useCallback(() => setVersion((v) => v + 1), []);
|
|
@@ -174,7 +185,16 @@ export function useAgUiRuntime(
|
|
|
174
185
|
[adapterAdapters, core, _version, hasExecutingTools],
|
|
175
186
|
);
|
|
176
187
|
|
|
177
|
-
const
|
|
188
|
+
const baseRuntime = useExternalStoreRuntime(store);
|
|
189
|
+
|
|
190
|
+
const runtime = useMemo<AgUiAssistantRuntime>(() => {
|
|
191
|
+
const wrapper = Object.create(baseRuntime) as AgUiAssistantRuntime;
|
|
192
|
+
wrapper.unstable_getPendingInterrupts = () =>
|
|
193
|
+
core.getPendingInterrupts()?.interrupts ?? [];
|
|
194
|
+
wrapper.unstable_submitInterruptResponses = (responses) =>
|
|
195
|
+
core.submitInterruptResponses(responses);
|
|
196
|
+
return wrapper;
|
|
197
|
+
}, [baseRuntime, core]);
|
|
178
198
|
|
|
179
199
|
useEffect(() => {
|
|
180
200
|
core.attachRuntime(runtime);
|