gitflarePublicPartly agent-ready50
cf-workflows-pipeline
Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
629b2faOct 20, 2026
Fix pipeline runs failing at ingest (steps.attempt NOT NULL)
629b2faimport { describe, it, expect } from "vitest";import { extract } from "../src/lib/extract";import { parsePlan, shouldFail } from "../src/lib/inject";import { validateUrl } from "../src/lib/validate";import { buildTimeline } from "../src/lib/timeline"; describe("extract", () => { it("strips noise, prefers article, gets title", () => { const r = extract("<title>Hi & bye</title><nav>menu</nav><script>x()</script><main>no</main><article><p>Hello</p>\n<p>world</p></article>"); expect(r.title).toBe("Hi & bye"); expect(r.text).toBe("Hello world"); }); it("falls back to main and body", () => { expect(extract("<main>A B</main>").text).toBe("A B"); expect(extract("<style>a{}</style><p>x</p>").text).toBe("x"); });});describe("inject", () => { it("fails first N attempts", () => { const p = parsePlan({ extract: 2, summarise: "x", publish: -1 }); expect(p).toEqual({ extract: 2 }); expect(shouldFail(p, "extract", 2)).toBe(true); expect(shouldFail(p, "extract", 3)).toBe(false); expect(shouldFail(p, "publish", 1)).toBe(false); });});describe("validate", () => { it("allows public https", () => expect(validateUrl("https://example.com/a").ok).toBe(true)); it("rejects bad", () => { for (const u of ["ftp://a.com", "http://127.0.0.1", "http://10.1.1.1", "http://192.168.0.1", "http://localhost", "http://[::1]", "nope"]) expect(validateUrl(u).ok).toBe(false); });});describe("timeline", () => { it("builds view with durations", () => { const t = buildTimeline([{ name: "extract", state: "retrying", attempt: 2, started_at: 100, ended_at: null, output_excerpt: null, error: "boom" }], 600); expect(t).toHaveLength(5); expect(t[0].state).toBe("queued"); expect(t[1]).toMatchObject({ label: "retrying 2/3", durationMs: 500, error: "boom" }); });});