@assistant-ui/react-ag-ui 0.1.1 → 0.1.2
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 +2 -0
- package/dist/runtime/AgUiThreadController.d.ts +11 -0
- package/dist/runtime/AgUiThreadController.d.ts.map +1 -1
- package/dist/runtime/AgUiThreadController.js +212 -22
- package/dist/runtime/AgUiThreadController.js.map +1 -1
- package/dist/runtime/adapter/conversions.d.ts +9 -1
- package/dist/runtime/adapter/conversions.d.ts.map +1 -1
- package/dist/runtime/adapter/conversions.js +184 -9
- package/dist/runtime/adapter/conversions.js.map +1 -1
- package/dist/runtime/adapter/run-aggregator.d.ts +1 -0
- package/dist/runtime/adapter/run-aggregator.d.ts.map +1 -1
- package/dist/runtime/adapter/run-aggregator.js +34 -12
- 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/adapter/subscriber.js +1 -8
- package/dist/runtime/adapter/subscriber.js.map +1 -1
- package/dist/runtime/event-parser.d.ts.map +1 -1
- package/dist/runtime/event-parser.js +1 -0
- package/dist/runtime/event-parser.js.map +1 -1
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js +2 -1
- package/dist/runtime/types.js.map +1 -1
- package/package.json +5 -5
- package/src/runtime/AgUiThreadController.disconnect.test.ts +914 -0
- package/src/runtime/AgUiThreadController.interrupt-history.test.ts +392 -0
- package/src/runtime/AgUiThreadController.replay.test.ts +8 -1
- package/src/runtime/AgUiThreadController.snapshot-head-move.test.ts +167 -0
- package/src/runtime/AgUiThreadController.subagent-snapshot.test.ts +854 -0
- package/src/runtime/AgUiThreadController.test.ts +40 -0
- package/src/runtime/AgUiThreadController.ts +459 -27
- package/src/runtime/adapter/conversions.content.test.ts +129 -0
- package/src/runtime/adapter/conversions.subagent-messages.test.ts +550 -0
- package/src/runtime/adapter/conversions.ts +331 -20
- package/src/runtime/adapter/run-aggregator.metadata.test.ts +151 -0
- package/src/runtime/adapter/run-aggregator.ts +52 -9
- package/src/runtime/adapter/subscriber.test.ts +1 -1
- package/src/runtime/adapter/subscriber.ts +1 -6
- package/src/runtime/event-parser.ts +3 -0
- package/src/runtime/types.ts +5 -0
|
@@ -539,6 +539,46 @@ describe("AgUiThreadController activity deltas", () => {
|
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
541
|
|
|
542
|
+
describe("AgUiThreadController run state", () => {
|
|
543
|
+
type Subscriber = {
|
|
544
|
+
onStateSnapshotEvent?: (payload: {
|
|
545
|
+
event: { type: "STATE_SNAPSHOT"; snapshot: { count: number } };
|
|
546
|
+
}) => void;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
it("sends an empty state when no snapshot exists and preserves null", async () => {
|
|
550
|
+
const runAgent = vi.fn(
|
|
551
|
+
async (_input: { state: unknown }, subscriber: Subscriber) => {
|
|
552
|
+
if (runAgent.mock.calls.length === 1) {
|
|
553
|
+
subscriber.onStateSnapshotEvent?.({
|
|
554
|
+
event: { type: "STATE_SNAPSHOT", snapshot: { count: 1 } },
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
);
|
|
559
|
+
const agent = {
|
|
560
|
+
runAgent,
|
|
561
|
+
abortRun: vi.fn(),
|
|
562
|
+
} as unknown as AbstractAgent;
|
|
563
|
+
const { core } = createCore(undefined, agent);
|
|
564
|
+
|
|
565
|
+
await core.append({ ...userMessage("initial"), startRun: true });
|
|
566
|
+
expect(runAgent.mock.calls[0]?.[0].state).toEqual({});
|
|
567
|
+
expect(agent.state).toEqual({});
|
|
568
|
+
|
|
569
|
+
core.resetState();
|
|
570
|
+
expect(core.getState()).toBeUndefined();
|
|
571
|
+
await core.append({ ...userMessage("after reset"), startRun: true });
|
|
572
|
+
expect(runAgent.mock.calls[1]?.[0].state).toEqual({});
|
|
573
|
+
expect(agent.state).toEqual({});
|
|
574
|
+
|
|
575
|
+
core.setState(null);
|
|
576
|
+
await core.append({ ...userMessage("explicit null"), startRun: true });
|
|
577
|
+
expect(runAgent.mock.calls[2]?.[0].state).toBeNull();
|
|
578
|
+
expect(agent.state).toBeNull();
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
|
|
542
582
|
describe("AgUiThreadController setState", () => {
|
|
543
583
|
it("keeps a cancel the updater makes while a send waits for history", async () => {
|
|
544
584
|
const { history, finish } = deferredHistory();
|