feat: add logger and twilio poll backoff

This commit is contained in:
Peter Steinberger
2025-11-25 03:48:49 +01:00
parent 8bd406f6b1
commit 7fa071267c
8 changed files with 151 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { parseClaudeJsonText } from "./claude.js";
import { parseClaudeJson, parseClaudeJsonText } from "./claude.js";
describe("claude JSON parsing", () => {
it("extracts text from single JSON object", () => {
@@ -16,5 +16,17 @@ describe("claude JSON parsing", () => {
it("returns undefined on invalid JSON", () => {
expect(parseClaudeJsonText("not json")).toBeUndefined();
});
});
it("extracts text from Claude CLI result field and preserves metadata", () => {
const sample = {
type: "result",
subtype: "success",
result: "hello from result field",
duration_ms: 1234,
usage: { server_tool_use: { tool_a: 2 } },
};
const parsed = parseClaudeJson(JSON.stringify(sample));
expect(parsed?.text).toBe("hello from result field");
expect(parsed?.parsed).toMatchObject({ duration_ms: 1234 });
});
});