Skip to content

gitflarePublicPartly agent-ready50

cf-workflows-pipeline

Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.

Fix pipeline runs failing at ingest (steps.attempt NOT NULL)629b2fa
JavaScript27 lines2.5 KB
import { el } from "./dom.js";import { api } from "./api.js";import { validateForm, buildPayload } from "./lib.js";export function formView(go) {  const inj = {}; const rows = ["extract", "summarise", "publish"].map((n) => {    const cb = el("input", { type: "checkbox", id: `i-${n}`, "aria-label": `Inject failure in ${n}` });    const num = el("input", { type: "number", min: "1", max: "3", value: "1", id: `n-${n}`, "aria-label": `Failures for ${n}`, disabled: true });    cb.addEventListener("change", () => { num.disabled = !cb.checked; }); inj[n] = () => (cb.checked ? num.value : 0);    return el("div", { class: "row" }, cb, el("label", { for: `i-${n}`, style: "margin:0" }, `Fail ${n}`), el("span", { class: "muted" }, "first"), num, el("span", { class: "muted" }, "attempts"));  });  const url = el("input", { id: "url", type: "url", placeholder: "https://example.com/article", autocomplete: "off", "aria-describedby": "src-err" });  const text = el("textarea", { id: "text", placeholder: "…or paste text here" });  const len = el("select", { id: "len" }, ["short", "medium", "long"].map((v) => el("option", { value: v, selected: v === "medium" }, v[0].toUpperCase() + v.slice(1))));  const err = el("p", { class: "err-msg", id: "src-err", role: "alert" }); const btn = el("button", { class: "btn pri", type: "submit" }, "Launch run");  const form = el("form", { novalidate: true }, el("label", { for: "url" }, "Source URL"), url, el("label", { for: "text" }, "Or paste text"), text, err,    el("label", { for: "len" }, "Summary length"), len, el("fieldset", {}, el("legend", {}, "Failure injection"), el("p", { class: "muted" }, "Make a step throw on its first N attempts to watch retries."), rows),    el("p", {}, btn));  form.addEventListener("submit", async (e) => {    e.preventDefault(); const f = { url: url.value, text: text.value, length: len.value, inject: { extract: inj.extract(), summarise: inj.summarise(), publish: inj.publish() } };    const v = validateForm(f); err.textContent = v.source || ""; if (v.source) return (url.value ? url : text).focus();    btn.disabled = true; btn.textContent = "Launching…";    try { const d = await api("/api/runs", { method: "POST", body: buildPayload(f) }); go(`/runs/${d.id || d.run?.id}`); }    catch (x) { err.textContent = x.message; btn.disabled = false; btn.textContent = "Launch run"; }  });  return el("div", {}, el("h1", {}, "New run"), el("p", { class: "lead" }, "Ingest, extract, summarise, approve, publish — each step durable and retried."), el("div", { class: "card" }, form));}