feat: add trusted confirm and input forms
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ToolCallRecord } from "./tool-call-state";
|
||||
import { ConversationStore } from "./conversation-store";
|
||||
|
||||
class MemoryStorage implements Storage {
|
||||
@@ -70,4 +71,30 @@ describe("ConversationStore", () => {
|
||||
expect(store.snapshot()).toMatchObject({ cursor: 42 });
|
||||
expect(store.snapshot().items).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("persists Tool Call state and an unsubmitted form draft per conversation", () => {
|
||||
const storage = new MemoryStorage();
|
||||
const state: ToolCallRecord = {
|
||||
call_id: "call_form_001",
|
||||
conversation_id: conversationID,
|
||||
request: {
|
||||
call_id: "call_form_001",
|
||||
tool: "input",
|
||||
title: "Deploy",
|
||||
prompt: "Provide a version.",
|
||||
data: { form: {} },
|
||||
},
|
||||
status: "pending",
|
||||
created_at: createdAt,
|
||||
updated_at: createdAt,
|
||||
};
|
||||
const first = new ConversationStore(storage);
|
||||
first.open(conversationID);
|
||||
first.replaceToolCalls([state]);
|
||||
first.saveToolDraft("call_form_001", { version: "1.2.3" });
|
||||
|
||||
const reopened = new ConversationStore(storage).open(conversationID);
|
||||
expect(reopened.tool_calls).toEqual([expect.objectContaining({ call_id: "call_form_001", status: "pending" })]);
|
||||
expect(reopened.tool_drafts).toEqual({ call_form_001: { version: "1.2.3" } });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user