@assistant-ui/react-ag-ui 0.0.56 → 0.0.58
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 +16 -0
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts +5 -17
- package/dist/runtime/AgUiThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadRuntimeCore.js +133 -234
- package/dist/runtime/AgUiThreadRuntimeCore.js.map +1 -1
- package/dist/runtime/adapter/conversions.d.ts.map +1 -1
- package/dist/runtime/adapter/conversions.js +54 -25
- package/dist/runtime/adapter/conversions.js.map +1 -1
- package/dist/runtime/adapter/run-aggregator.d.ts +31 -4
- package/dist/runtime/adapter/run-aggregator.d.ts.map +1 -1
- package/dist/runtime/adapter/run-aggregator.js +419 -123
- package/dist/runtime/adapter/run-aggregator.js.map +1 -1
- package/dist/runtime/adapter/subscriber.d.ts +9 -0
- package/dist/runtime/adapter/subscriber.d.ts.map +1 -1
- package/dist/runtime/adapter/subscriber.js +4 -1
- package/dist/runtime/adapter/subscriber.js.map +1 -1
- package/dist/runtime/adapter/tool-approval.d.ts +3 -1
- package/dist/runtime/adapter/tool-approval.d.ts.map +1 -1
- package/dist/runtime/adapter/tool-approval.js +11 -12
- package/dist/runtime/adapter/tool-approval.js.map +1 -1
- package/dist/runtime/event-parser.d.ts.map +1 -1
- package/dist/runtime/event-parser.js +176 -45
- package/dist/runtime/event-parser.js.map +1 -1
- package/dist/runtime/types.d.ts +42 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/useAgUiRuntime.js +12 -9
- package/dist/useAgUiRuntime.js.map +1 -1
- package/package.json +10 -10
- package/src/runtime/AgUiThreadRuntimeCore.test.ts +105 -0
- package/src/runtime/AgUiThreadRuntimeCore.ts +190 -319
- package/src/runtime/adapter/conversions.ts +128 -36
- package/src/runtime/adapter/run-aggregator.approval.test.ts +128 -0
- package/src/runtime/adapter/run-aggregator.ts +670 -148
- package/src/runtime/adapter/subscriber.ts +10 -1
- package/src/runtime/adapter/tool-approval.test.ts +75 -0
- package/src/runtime/adapter/tool-approval.ts +17 -12
- package/src/runtime/event-parser.ts +216 -36
- package/src/runtime/types.ts +70 -12
- package/src/useAgUiRuntime.approval.test.tsx +34 -24
- package/src/useAgUiRuntime.history.test.tsx +76 -0
- package/src/useAgUiRuntime.toolDeferral.test.tsx +186 -0
- package/src/useAgUiRuntime.ts +12 -9
package/README.md
CHANGED
|
@@ -33,6 +33,22 @@ export function Provider({ children }: { children: React.ReactNode }) {
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
## Subagents
|
|
37
|
+
|
|
38
|
+
An AG-UI backend that runs subagents (the agents-as-tools pattern) emits `SUBAGENT_STARTED` / `SUBAGENT_FINISHED` / `SUBAGENT_ERROR` plus a `subagentRunId` on the events each subagent produces. This adapter groups that activity into one nested assistant message per subagent run and attaches it to the spawning tool call as `ToolCallMessagePart.messages`, joined on `SUBAGENT_STARTED.parentToolCallId`. `PartPrimitive.Messages` renders it without extra wiring, and the subagent's name, description, result, and error code ride on that message's `agui` metadata.
|
|
39
|
+
|
|
40
|
+
A subagent that names no reachable spawning call (`parentToolCallId` is optional, may name a call this run never saw, or two runs may name each other) has nowhere to nest, so its output renders in the parent thread instead of being dropped. This matches the downgrade the protocol's own pre-subagent compatibility middleware performs.
|
|
41
|
+
|
|
42
|
+
A subagent's frontend-executed tool calls work the same way the root agent's do: a call nested on `ToolCallMessagePart.messages` is reachable by `getPendingToolCalls()`, resolves through `addToolResult`, and its result rides the resume as a `tool` record on the spawning assistant record, the same flattened wire shape these calls had before subagent attribution.
|
|
43
|
+
|
|
44
|
+
Approval gates cover nested calls too: a gate that names a subagent-scoped call projects onto the nested part, the frontend tool stays unexecuted while the gate is open, decisions recorded through `respondToToolApproval` land on the nested part, and an undecided gate's result is never exported to the backend.
|
|
45
|
+
|
|
46
|
+
Two limitations are worth knowing before you rely on this:
|
|
47
|
+
|
|
48
|
+
- **Nested structure does not survive a reload.** Thread restore reads the flattened wire shape, so a restored subagent tool call comes back as a root-level part rather than nested under its spawning call. Results and decisions are preserved; only the nesting is not.
|
|
49
|
+
|
|
50
|
+
- **Nested human-in-the-loop is not wired up.** A `SUBAGENT_FINISHED` with a `suspended` outcome marks the nested message `requires-action`, and its `interruptIds` are preserved on the message metadata, but there is no resume path that answers them yet.
|
|
51
|
+
|
|
36
52
|
## See also
|
|
37
53
|
|
|
38
54
|
- `@assistant-ui/react-a2a` for the A2A v1.0 protocol.
|
|
@@ -32,8 +32,7 @@ declare class AgUiThreadRuntimeCore {
|
|
|
32
32
|
private readonly notifyUpdate;
|
|
33
33
|
private readonly reportedErrors;
|
|
34
34
|
private runtime;
|
|
35
|
-
private readonly
|
|
36
|
-
private exportedRepository;
|
|
35
|
+
private readonly session;
|
|
37
36
|
private isRunningFlag;
|
|
38
37
|
private abortController;
|
|
39
38
|
private activeRunAgent;
|
|
@@ -47,6 +46,7 @@ declare class AgUiThreadRuntimeCore {
|
|
|
47
46
|
private readonly historyWrites;
|
|
48
47
|
private _isLoading;
|
|
49
48
|
private _loadPromise;
|
|
49
|
+
private _loadRequested;
|
|
50
50
|
private pendingResumeMessageId;
|
|
51
51
|
private pendingA2uiResume;
|
|
52
52
|
private pendingA2uiAction;
|
|
@@ -56,16 +56,6 @@ declare class AgUiThreadRuntimeCore {
|
|
|
56
56
|
detachRuntime(): void;
|
|
57
57
|
getMessages(): readonly ThreadMessage[];
|
|
58
58
|
getMessageRepository(): ExportedMessageRepository;
|
|
59
|
-
private tryGetMessage;
|
|
60
|
-
private tryGetMessages;
|
|
61
|
-
private hasMessage;
|
|
62
|
-
private addOrUpdateMessage;
|
|
63
|
-
private deleteMessage;
|
|
64
|
-
private tryDeleteMessage;
|
|
65
|
-
private switchToBranch;
|
|
66
|
-
private resetRepositoryHead;
|
|
67
|
-
private clearRepository;
|
|
68
|
-
private updateMessage;
|
|
69
59
|
getState(): ReadonlyJSONValue | undefined;
|
|
70
60
|
isRunning(): boolean;
|
|
71
61
|
get isLoading(): boolean;
|
|
@@ -99,9 +89,9 @@ declare class AgUiThreadRuntimeCore {
|
|
|
99
89
|
*/
|
|
100
90
|
private resumeWithResponses;
|
|
101
91
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
92
|
+
* A rejected decision reaches the caller through the approval seam, and
|
|
93
|
+
* `onError` in addition, because a consumer watching only the runtime would
|
|
94
|
+
* otherwise miss it. A failure raised by the resumed run itself was already
|
|
105
95
|
* reported by `startRun` before it rethrew, so reporting it here again would
|
|
106
96
|
* give the consumer two notifications for one failure.
|
|
107
97
|
*/
|
|
@@ -121,14 +111,12 @@ declare class AgUiThreadRuntimeCore {
|
|
|
121
111
|
private maybeCompleteAfterToolResults;
|
|
122
112
|
private startResumeRun;
|
|
123
113
|
applyExternalMessages(messages: readonly ThreadMessage[]): void;
|
|
124
|
-
private applyExternalMessageRepository;
|
|
125
114
|
loadExternalState(state: ReadonlyJSONValue): void;
|
|
126
115
|
setState(next: ReadonlyJSONValue | ((prev: ReadonlyJSONValue | undefined) => ReadonlyJSONValue)): void;
|
|
127
116
|
resetState(): void;
|
|
128
117
|
private startRun;
|
|
129
118
|
private consumeResumeStream;
|
|
130
119
|
private buildRunInput;
|
|
131
|
-
private installResumeShim;
|
|
132
120
|
private setRunning;
|
|
133
121
|
private finishRun;
|
|
134
122
|
private insertAssistantPlaceholder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgUiThreadRuntimeCore.d.ts","names":[],"sources":["../../src/runtime/AgUiThreadRuntimeCore.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"AgUiThreadRuntimeCore.d.ts","names":[],"sources":["../../src/runtime/AgUiThreadRuntimeCore.ts"],"mappings":";;;;;;KA8EK,YAAY,YAAY;KACxB,gBACH,SAAS,wBACN,eAAe;KACf;EACH;EACA;EACA,WAAW;EACX,SAAS;;KAGN;EACH,OAAO;EACP,QAA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