fix: extract question text from questions array per opencode tool schema
This commit is contained in:
@@ -44,7 +44,7 @@ describe("createOpenClawHook", () => {
|
||||
|
||||
await hook?.["tool.execute.before"]?.(
|
||||
{ tool: "ask_user_question", sessionID: "session-2" },
|
||||
{ args: { question: "Need approval?" } },
|
||||
{ args: { questions: [{ question: "Need approval?", options: [{ label: "Yes" }] }] } },
|
||||
)
|
||||
|
||||
expect(wakeOpenClawMock).toHaveBeenCalledWith(
|
||||
@@ -57,4 +57,26 @@ describe("createOpenClawHook", () => {
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
test("falls back to args.question string when questions array absent", async () => {
|
||||
const { createOpenClawHook } = await import("./openclaw")
|
||||
const hook = createOpenClawHook(
|
||||
{ directory: "/tmp/project" } as any,
|
||||
{ openclaw: { enabled: true } } as any,
|
||||
)
|
||||
|
||||
await hook?.["tool.execute.before"]?.(
|
||||
{ tool: "question", sessionID: "session-3" },
|
||||
{ args: { question: "Fallback?" } },
|
||||
)
|
||||
|
||||
expect(wakeOpenClawMock).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
"ask-user-question",
|
||||
expect.objectContaining({
|
||||
question: "Fallback?",
|
||||
sessionId: "session-3",
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user