@assistant-ui/react-ag-ui 0.0.44 → 0.0.45
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 +0 -1
- package/dist/agUiExtras.d.ts.map +1 -1
- package/dist/hooks.d.ts +15 -9
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +17 -8
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts +26 -4
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadRuntimeCore.js +296 -89
- package/dist/runtime/AgUiThreadRuntimeCore.js.map +1 -1
- package/dist/runtime/adapter/conversions.d.ts +0 -1
- package/dist/runtime/adapter/conversions.d.ts.map +1 -1
- package/dist/runtime/adapter/conversions.js +2 -1
- package/dist/runtime/adapter/conversions.js.map +1 -1
- package/dist/runtime/adapter/run-aggregator.d.ts +0 -1
- package/dist/runtime/adapter/run-aggregator.d.ts.map +1 -1
- package/dist/runtime/adapter/run-aggregator.js +36 -7
- package/dist/runtime/adapter/run-aggregator.js.map +1 -1
- package/dist/runtime/adapter/subscriber.d.ts +0 -1
- package/dist/runtime/adapter/subscriber.d.ts.map +1 -1
- package/dist/runtime/event-parser.d.ts +0 -1
- package/dist/runtime/event-parser.d.ts.map +1 -1
- package/dist/runtime/event-parser.js +18 -9
- package/dist/runtime/event-parser.js.map +1 -1
- package/dist/runtime/logger.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +13 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/useAgUiRuntime.d.ts +0 -1
- package/dist/useAgUiRuntime.d.ts.map +1 -1
- package/dist/useAgUiRuntime.js +8 -2
- package/dist/useAgUiRuntime.js.map +1 -1
- package/package.json +6 -6
- package/src/hooks.ts +29 -7
- package/src/index.ts +2 -0
- package/src/runtime/AgUiThreadRuntimeCore.ts +390 -108
- package/src/runtime/adapter/conversions.ts +11 -4
- package/src/runtime/adapter/run-aggregator.ts +69 -5
- package/src/runtime/types.ts +17 -0
- package/src/useAgUiRuntime.ts +8 -1
package/src/hooks.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useAui } from "@assistant-ui/store";
|
|
4
4
|
import type { CreateAppendMessage } from "@assistant-ui/core";
|
|
5
|
+
import type { ReadonlyJSONValue } from "assistant-stream/utils";
|
|
5
6
|
import { agUiExtras } from "./agUiExtras";
|
|
6
7
|
import type { AgUiInterrupt, AgUiResumeEntry } from "./runtime/types";
|
|
7
8
|
|
|
@@ -25,13 +26,17 @@ export const useAgUiSubmitInterruptResponses = () => {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
* Returns a function that discards the pending AG-UI interrupts
|
|
29
|
-
* given user message, starting a fresh
|
|
30
|
-
*
|
|
31
|
-
* reported to the agent as cancelled
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
29
|
+
* Returns a function that discards the pending AG-UI interrupts or pending
|
|
30
|
+
* client-side tool calls and appends the given user message, starting a fresh
|
|
31
|
+
* run. Use this when the user sends a new message instead of resolving them:
|
|
32
|
+
* every open interrupt is reported to the agent as cancelled, and every
|
|
33
|
+
* unresolved client-side tool call receives an error result. The message
|
|
34
|
+
* accepts a plain string or a partial `AppendMessage` (the parent defaults to
|
|
35
|
+
* the current head). Pass `responses` to override the status of specific
|
|
36
|
+
* interrupts; the rest still default to cancelled. `responses` throws when
|
|
37
|
+
* tool calls rather than interrupts are pending. Unlike the
|
|
38
|
+
* `autoCancelPendingToolCalls` runtime option, this hook cancels regardless
|
|
39
|
+
* of that option's value.
|
|
35
40
|
*/
|
|
36
41
|
export const useAgUiSteerAway = () => {
|
|
37
42
|
const aui = useAui();
|
|
@@ -40,3 +45,20 @@ export const useAgUiSteerAway = () => {
|
|
|
40
45
|
responses?: readonly AgUiResumeEntry[],
|
|
41
46
|
): Promise<void> => agUiExtras.get(aui).steerAway(message, responses);
|
|
42
47
|
};
|
|
48
|
+
|
|
49
|
+
export const useAgUiState = <TState = ReadonlyJSONValue>():
|
|
50
|
+
| TState
|
|
51
|
+
| undefined =>
|
|
52
|
+
agUiExtras.use((e) => e.state as TState | undefined, undefined);
|
|
53
|
+
|
|
54
|
+
export const useAgUiSetState = <TState = ReadonlyJSONValue>() => {
|
|
55
|
+
const aui = useAui();
|
|
56
|
+
return (next: TState | ((prev: TState | undefined) => TState)): void =>
|
|
57
|
+
agUiExtras
|
|
58
|
+
.get(aui)
|
|
59
|
+
.setState(
|
|
60
|
+
next as
|
|
61
|
+
| ReadonlyJSONValue
|
|
62
|
+
| ((prev: ReadonlyJSONValue | undefined) => ReadonlyJSONValue),
|
|
63
|
+
);
|
|
64
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ export {
|
|
|
4
4
|
useAgUiInterrupts,
|
|
5
5
|
useAgUiSubmitInterruptResponses,
|
|
6
6
|
useAgUiSteerAway,
|
|
7
|
+
useAgUiState,
|
|
8
|
+
useAgUiSetState,
|
|
7
9
|
} from "./hooks";
|
|
8
10
|
export { fromAgUiMessages } from "./runtime/adapter/conversions";
|
|
9
11
|
export type { FromAgUiMessagesOptions } from "./runtime/adapter/conversions";
|