@w6w/embed 0.2.33 → 0.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{DocumentFormModal-Cw85R4wk.js → DocumentFormModal-B3OkvI5v.js} +2 -2
  2. package/dist/{DocumentFormModal-Cw85R4wk.js.map → DocumentFormModal-B3OkvI5v.js.map} +1 -1
  3. package/dist/{ImportSpecModal-fU5RsVTa.js → ImportSpecModal-SQvTwtcX.js} +2 -2
  4. package/dist/{ImportSpecModal-fU5RsVTa.js.map → ImportSpecModal-SQvTwtcX.js.map} +1 -1
  5. package/dist/WorkflowEditor-D2EfEP-U.js +1201 -0
  6. package/dist/WorkflowEditor-D2EfEP-U.js.map +1 -0
  7. package/dist/apps-CFWdgGst.js +106 -0
  8. package/dist/apps-CFWdgGst.js.map +1 -0
  9. package/dist/chrome/HistoryView.d.ts +3 -0
  10. package/dist/editor-apps-ShwCmvLY.js +178 -0
  11. package/dist/editor-apps-ShwCmvLY.js.map +1 -0
  12. package/dist/{editor-tools-Dn7TgCP4.js → editor-tools-rY9nddqr.js} +49 -49
  13. package/dist/{editor-tools-Dn7TgCP4.js.map → editor-tools-rY9nddqr.js.map} +1 -1
  14. package/dist/editor.mjs +1 -1
  15. package/dist/editors.mjs +8 -8
  16. package/dist/index.mjs +4 -4
  17. package/dist/lib/history-query.d.ts +22 -1
  18. package/dist/lib/run-log-nodes.d.ts +43 -0
  19. package/dist/lists.mjs +6 -6
  20. package/dist/rail.mjs +1 -1
  21. package/dist/repos/history.d.ts +5 -1
  22. package/dist/repos.mjs +304 -300
  23. package/dist/{spec-import-CGPqUUjN.js → spec-import-CPbDnnuv.js} +2 -2
  24. package/dist/{spec-import-CGPqUUjN.js.map → spec-import-CPbDnnuv.js.map} +1 -1
  25. package/dist/{workflows-Dz8LMjnt.js → workflows-RhR8kwt7.js} +255 -214
  26. package/dist/workflows-RhR8kwt7.js.map +1 -0
  27. package/package.json +2 -2
  28. package/dist/WorkflowEditor-C7oudiIb.js +0 -1169
  29. package/dist/WorkflowEditor-C7oudiIb.js.map +0 -1
  30. package/dist/apps-FMcQfyL2.js +0 -92
  31. package/dist/apps-FMcQfyL2.js.map +0 -1
  32. package/dist/editor-apps-HEOclsxL.js +0 -152
  33. package/dist/editor-apps-HEOclsxL.js.map +0 -1
  34. package/dist/workflows-Dz8LMjnt.js.map +0 -1
@@ -1,152 +0,0 @@
1
- import { jsxs as C, jsx as d } from "react/jsx-runtime";
2
- import { u as X, a as tt, b as et, c as nt, d as rt } from "./apps-FMcQfyL2.js";
3
- import { H as _ } from "./workflows-Dz8LMjnt.js";
4
- import { ExecutionDetail as ot, ExecutionStats as st, ExecutionFilters as it, ExecutionList as lt, useW6WApi as ct } from "@w6w/ui";
5
- import { useRef as E, useState as R, useEffect as B, useLayoutEffect as ut, useCallback as L, useMemo as at } from "react";
6
- import { useQuery as dt } from "@tanstack/react-query";
7
- const ft = 300;
8
- function Y(o) {
9
- for (let r = (o == null ? void 0 : o.parentElement) ?? null; r; r = r.parentElement) {
10
- const l = getComputedStyle(r).overflowY;
11
- if ((l === "auto" || l === "scroll") && r.scrollHeight > r.clientHeight)
12
- return r;
13
- }
14
- return null;
15
- }
16
- function xt(o) {
17
- var Q, A, O;
18
- const { scope: r, showKind: l, filters: n, onFiltersChange: m, onOpenInEditor: f } = o, S = E(n);
19
- S.current = n;
20
- const [u, a] = R(n.q), p = E(null), [s, b] = R(null);
21
- B(() => {
22
- a(n.q);
23
- }, [n.q]), B(
24
- () => () => {
25
- p.current && clearTimeout(p.current);
26
- },
27
- []
28
- );
29
- const h = X(r, n), j = tt(r, n), I = et(s), c = nt(), D = rt(), [T, y] = R(null), g = E(null), w = E(null), k = (s == null ? void 0 : s.id) ?? null;
30
- ut(() => {
31
- var e;
32
- const t = g.current;
33
- if (t) {
34
- if (k !== null) {
35
- const i = Y(t);
36
- i ? i.scrollTop = 0 : t.getBoundingClientRect().top < 0 && ((e = t.scrollIntoView) == null || e.call(t, { block: "start" }));
37
- } else if (w.current) {
38
- const { parent: i, top: F } = w.current;
39
- w.current = null, i ? i.scrollTop = F : window.scrollTo(0, F);
40
- }
41
- }
42
- }, [k]);
43
- const H = E(s);
44
- H.current = s;
45
- const v = L((t) => {
46
- if (H.current === null) {
47
- const e = Y(g.current);
48
- w.current = { parent: e, top: e ? e.scrollTop : window.scrollY };
49
- }
50
- b(t);
51
- }, []), x = ((Q = h.data) == null ? void 0 : Q.executions) ?? [], q = n.offset, V = ((A = h.data) == null ? void 0 : A.hasMore) ?? !1, K = (t) => {
52
- m({ ...t, offset: 0 });
53
- }, W = (t) => {
54
- if (t.q === u) {
55
- K(t);
56
- return;
57
- }
58
- a(t.q), p.current && clearTimeout(p.current), p.current = setTimeout(() => {
59
- p.current = null, m({ ...S.current, q: t.q, offset: 0 });
60
- }, ft);
61
- }, $ = () => m({ ...n, q: u, offset: Math.max(0, q - _) }), G = () => m({ ...n, q: u, offset: q + _ }), U = L(
62
- (t) => {
63
- const e = x.find((i) => i.id === t);
64
- e && v(e);
65
- },
66
- [x, v]
67
- ), M = (t) => {
68
- c.mutate(t, {
69
- onSuccess: (e) => {
70
- e ? v(e) : b(null);
71
- }
72
- });
73
- }, N = c.isPending ? ((O = c.variables) == null ? void 0 : O.id) ?? null : null, Z = (t, e) => {
74
- y(null), D(t, e).then((i) => {
75
- i ? v(i) : y(`${e} is no longer available.`);
76
- }).catch(() => y(`Couldn't open ${e}.`));
77
- }, P = c.isError ? /* @__PURE__ */ C("p", { className: "error", "data-testid": "history-rerun-error", children: [
78
- "Couldn't re-run: ",
79
- c.error instanceof Error ? c.error.message : String(c.error)
80
- ] }) : null, z = {
81
- status: n.status,
82
- kind: n.kind,
83
- from: n.from,
84
- to: n.to,
85
- q: u
86
- }, J = (s == null ? void 0 : s.kind) === "workflow" && f ? () => f(s) : void 0;
87
- return s ? /* @__PURE__ */ C("div", { ref: g, children: [
88
- P,
89
- T && /* @__PURE__ */ d("p", { className: "error", "data-testid": "history-find-error", children: T }),
90
- /* @__PURE__ */ d(
91
- ot,
92
- {
93
- execution: I.data ?? null,
94
- loading: I.isLoading,
95
- errorMessage: I.isError ? "This execution is no longer available." : void 0,
96
- onBack: () => {
97
- c.reset(), y(null), b(null);
98
- },
99
- onOpenExecution: (t) => Z(s.callableId, t),
100
- onRerun: () => M(s),
101
- rerunning: N !== null,
102
- onOpenInEditor: J
103
- }
104
- )
105
- ] }) : /* @__PURE__ */ C("div", { className: "w6w-card-stack", "data-testid": "history-view", children: [
106
- /* @__PURE__ */ d(st, { stats: j.data ?? null }),
107
- /* @__PURE__ */ d(it, { showKind: l, value: z, onChange: W }),
108
- h.isError && /* @__PURE__ */ d("p", { className: "error", "data-testid": "history-error", children: "Couldn't load execution history." }),
109
- P,
110
- /* @__PURE__ */ d("div", { ref: g, children: /* @__PURE__ */ d(
111
- lt,
112
- {
113
- items: x,
114
- showCallable: l,
115
- loading: h.isLoading,
116
- hasPrev: q > 0,
117
- hasNext: V,
118
- onPrev: $,
119
- onNext: G,
120
- onSelect: U,
121
- onRerun: (t) => {
122
- const e = x.find((i) => i.id === t);
123
- e && M(e);
124
- },
125
- rerunningId: N
126
- }
127
- ) })
128
- ] });
129
- }
130
- const pt = /* @__PURE__ */ new Map();
131
- function mt(o) {
132
- var u;
133
- const r = ct(), l = (u = r.listAppsByIds) == null ? void 0 : u.bind(r), n = [...o].sort().join(","), f = dt({
134
- queryKey: ["editor-apps", n],
135
- queryFn: ({ signal: a }) => l ? l(o, { signal: a }) : Promise.resolve([]),
136
- enabled: o.length > 0 && typeof l == "function"
137
- }).data;
138
- return { byId: at(
139
- () => f ? new Map(f.map((a) => [a.id, a])) : pt,
140
- [f]
141
- ) };
142
- }
143
- function St(o) {
144
- const { byId: r } = mt(o ? [o] : []);
145
- return o ? r.get(o) : void 0;
146
- }
147
- export {
148
- xt as H,
149
- mt as a,
150
- St as u
151
- };
152
- //# sourceMappingURL=editor-apps-HEOclsxL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-apps-HEOclsxL.js","sources":["../src/chrome/HistoryView.tsx","../src/editor/editor-apps.ts"],"sourcesContent":["/**\n * `HistoryView` — the execution-history view body (T3.2.1, extracted from\n * `HistoryPage.tsx`'s T2.4.1 shape): stats + filters + paged list, OR the\n * selected execution's detail — never both. Opening a row swaps the list for\n * that execution (with a Back control to return to the list where it was\n * left); it does not stack the detail under a long list, where it lands\n * off-screen. Two hosts mount it — `HistoryPage` (the\n * project-wide and per-callable routes, filters URL-backed) and\n * `HistoryModal` (R-2's in-place modal, filters kept in local state) — so\n * this component owns every judgment call about HOW the view behaves, and\n * takes no position on WHERE its filters live: the host hands down\n * `filters` and gets every change back through `onFiltersChange`, exactly\n * the controlled-value shape `filtersToSearch`/`filtersFromSearch` already\n * assume on the URL-backed side.\n *\n * What stays here, same as it was in `HistoryPage` before the extraction:\n * - the search box's text, debounced, so a keystroke does not re-key and\n * re-issue both queries on every character (`onFiltersChange` — and so\n * the host's own write, URL or local state — fires only once typing\n * settles);\n * - which list row is selected, which is not shareable state and resets on\n * every mount;\n * - re-running an execution (a control on every row and in the detail): the\n * same input, against the callable's current definition. The view then\n * opens the NEW execution, so the outcome is what the author sees next;\n * - every filter change but paging snapping the page back to the first\n * (`offset` 0), because a narrowed result set has no meaningful \"page 3\".\n *\n * `onOpenInEditor`, when given, is called with the selected execution ONLY\n * while it is a workflow run (a function/endpoint invocation has no visual\n * editor to open) — the same gate `HistoryPage.tsx` applied inline before\n * this extraction. A host that never passes it (none of today's two do)\n * simply never sees the call.\n */\nimport {\n type ExecutionSummary,\n HISTORY_PAGE_SIZE,\n type HistoryFilters,\n type HistoryScope,\n useExecutionDetailQuery,\n useFindExecution,\n useHistoryQuery,\n useHistoryStatsQuery,\n useRerunExecutionMutation,\n} from \"@w6w/embed/repos\";\nimport {\n ExecutionDetail,\n type ExecutionFilterValue,\n ExecutionFilters,\n ExecutionList,\n ExecutionStats,\n} from \"@w6w/ui\";\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\n/** How long to wait after the last keystroke before `onFiltersChange` fires\n * with the new `q` (and so before either query re-issues with it). */\nconst SEARCH_DEBOUNCE_MS = 300;\n\n/** The nearest ancestor that actually scrolls (the modal body, the app's main\n * pane), or `null` when the document itself does. */\nfunction scrollParent(el: HTMLElement | null): HTMLElement | null {\n for (let p = el?.parentElement ?? null; p; p = p.parentElement) {\n const overflowY = getComputedStyle(p).overflowY;\n if ((overflowY === \"auto\" || overflowY === \"scroll\") && p.scrollHeight > p.clientHeight) {\n return p;\n }\n }\n return null;\n}\n\nexport interface HistoryViewProps {\n /** `null` ⇒ no scope known yet (the project-wide host, before its project\n * resolves) — both queries stay disabled, mirroring `repos/history.ts`'s\n * own `enabled: scope !== null`. */\n scope: HistoryScope | null;\n /** Project-wide chrome: the Kind filter, and the Callable column on every\n * row. A per-callable host (every callable already knows its own kind)\n * passes `false`. */\n showKind: boolean;\n filters: HistoryFilters;\n onFiltersChange: (next: HistoryFilters) => void;\n onOpenInEditor?: (execution: ExecutionSummary) => void;\n}\n\nexport function HistoryView(props: HistoryViewProps) {\n const { scope, showKind, filters, onFiltersChange, onOpenInEditor } = props;\n\n // The debounce below fires outside any render, so it needs the LATEST\n // filters (a status picked while a `q` write was still pending must\n // survive it) rather than the ones captured when typing started.\n const filtersRef = useRef(filters);\n filtersRef.current = filters;\n\n const [q, setQ] = useState(filters.q);\n const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [selected, setSelected] = useState<ExecutionSummary | null>(null);\n\n // Keep the search box in step with `filters.q` when IT moves from outside\n // (Back/Forward or a shared link on the URL-backed host). This never\n // fights a keystroke: an outside `q` only changes once typing has\n // settled, by which point `q` already equals it.\n useEffect(() => {\n setQ(filters.q);\n }, [filters.q]);\n\n // Drop a pending debounce on unmount.\n useEffect(\n () => () => {\n if (searchTimer.current) clearTimeout(searchTimer.current);\n },\n [],\n );\n\n const listQuery = useHistoryQuery(scope, filters);\n const statsQuery = useHistoryStatsQuery(scope, filters);\n const detailQuery = useExecutionDetailQuery(selected);\n const rerun = useRerunExecutionMutation();\n const findExecution = useFindExecution();\n const [findError, setFindError] = useState<string | null>(null);\n\n // Swapping list ⇄ detail keeps the scroll offset of whatever scrolls around\n // this view, which would open a detail scrolled past its own top (the row\n // was clicked far down the list). So: remember the list's offset on the\n // way in, show the detail from its top, and put the list back on the way out.\n const viewRef = useRef<HTMLDivElement>(null);\n const listScroll = useRef<{ parent: HTMLElement | null; top: number } | null>(null);\n const selectedId = selected?.id ?? null;\n useLayoutEffect(() => {\n const el = viewRef.current;\n if (!el) return;\n if (selectedId !== null) {\n const parent = scrollParent(el);\n if (parent) parent.scrollTop = 0;\n else if (el.getBoundingClientRect().top < 0) el.scrollIntoView?.({ block: \"start\" });\n } else if (listScroll.current) {\n const { parent, top } = listScroll.current;\n listScroll.current = null;\n if (parent) parent.scrollTop = top;\n else window.scrollTo(0, top);\n }\n }, [selectedId]);\n\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n const open = useCallback((next: ExecutionSummary) => {\n // Leaving the LIST (not one detail for another, as a re-run from the detail does).\n if (selectedRef.current === null) {\n const parent = scrollParent(viewRef.current);\n listScroll.current = { parent, top: parent ? parent.scrollTop : window.scrollY };\n }\n setSelected(next);\n }, []);\n\n const executions = listQuery.data?.executions ?? [];\n const offset = filters.offset;\n const hasMore = listQuery.data?.hasMore ?? false;\n\n /** Every filter change but paging reports a fresh filter set and resets\n * the page to the first. */\n const applyFilters = (next: ExecutionFilterValue) => {\n onFiltersChange({ ...next, offset: 0 });\n };\n\n const onChange = (next: ExecutionFilterValue) => {\n if (next.q === q) {\n applyFilters(next);\n return;\n }\n setQ(next.q);\n if (searchTimer.current) clearTimeout(searchTimer.current);\n searchTimer.current = setTimeout(() => {\n searchTimer.current = null;\n onFiltersChange({ ...filtersRef.current, q: next.q, offset: 0 });\n }, SEARCH_DEBOUNCE_MS);\n };\n\n const onPrev = () =>\n onFiltersChange({ ...filters, q, offset: Math.max(0, offset - HISTORY_PAGE_SIZE) });\n const onNext = () => onFiltersChange({ ...filters, q, offset: offset + HISTORY_PAGE_SIZE });\n\n const onSelect = useCallback(\n (executionId: string) => {\n const row = executions.find((r) => r.id === executionId);\n if (row) open(row);\n },\n [executions, open],\n );\n\n /** Re-run one execution, then open the new one — or, when it is not listed\n * yet, fall back to the (refreshed) list. */\n const startRerun = (summary: ExecutionSummary) => {\n rerun.mutate(summary, {\n onSuccess: (next) => {\n if (next) open(next);\n else setSelected(null);\n },\n });\n };\n const rerunningId = rerun.isPending ? (rerun.variables?.id ?? null) : null;\n\n /** \"Re-run of <id>\": open the original, from the callable this one belongs to. */\n const openOriginal = (callableId: string, id: string) => {\n setFindError(null);\n findExecution(callableId, id)\n .then((row) => {\n if (row) open(row);\n else setFindError(`${id} is no longer available.`);\n })\n .catch(() => setFindError(`Couldn't open ${id}.`));\n };\n const rerunError = rerun.isError ? (\n <p className=\"error\" data-testid=\"history-rerun-error\">\n Couldn't re-run: {rerun.error instanceof Error ? rerun.error.message : String(rerun.error)}\n </p>\n ) : null;\n\n const filterValue: ExecutionFilterValue = {\n status: filters.status,\n kind: filters.kind,\n from: filters.from,\n to: filters.to,\n q,\n };\n\n // A workflow run is the only execution with a visual editor to jump into\n // — a function/endpoint invocation has no such surface.\n const openInEditor =\n selected?.kind === \"workflow\" && onOpenInEditor ? () => onOpenInEditor(selected) : undefined;\n\n if (selected) {\n return (\n <div ref={viewRef}>\n {rerunError}\n {findError && (\n <p className=\"error\" data-testid=\"history-find-error\">\n {findError}\n </p>\n )}\n <ExecutionDetail\n execution={detailQuery.data ?? null}\n loading={detailQuery.isLoading}\n errorMessage={detailQuery.isError ? \"This execution is no longer available.\" : undefined}\n onBack={() => {\n rerun.reset();\n setFindError(null);\n setSelected(null);\n }}\n onOpenExecution={(id) => openOriginal(selected.callableId, id)}\n onRerun={() => startRerun(selected)}\n rerunning={rerunningId !== null}\n onOpenInEditor={openInEditor}\n />\n </div>\n );\n }\n\n // `.w6w-card-stack` spaces stats → filters → list. A bare fragment left them touching: every host\n // wraps this view in one element (`RunHistory`'s embed root, `HistoryModal`'s body), so the\n // page's own flex gap never reached these siblings.\n return (\n <div className=\"w6w-card-stack\" data-testid=\"history-view\">\n <ExecutionStats stats={statsQuery.data ?? null} />\n\n <ExecutionFilters showKind={showKind} value={filterValue} onChange={onChange} />\n\n {listQuery.isError && (\n <p className=\"error\" data-testid=\"history-error\">\n Couldn't load execution history.\n </p>\n )}\n\n {rerunError}\n\n <div ref={viewRef}>\n <ExecutionList\n items={executions}\n showCallable={showKind}\n loading={listQuery.isLoading}\n hasPrev={offset > 0}\n hasNext={hasMore}\n onPrev={onPrev}\n onNext={onNext}\n onSelect={onSelect}\n onRerun={(id) => {\n const row = executions.find((r) => r.id === id);\n if (row) startRerun(row);\n }}\n rerunningId={rerunningId}\n />\n </div>\n </div>\n );\n}\n","/**\n * The canvas's app lookups, through the host-provided `W6WApi` (`useW6WApi()` — in an embed that\n * is `createW6WUiAdapter`'s, in Studio the facade, which delegates to the same store/repo).\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { type AppSummary, useW6WApi } from \"@w6w/ui\";\nimport { useMemo } from \"react\";\n\n/** The per-app actions query key — the repos export itself (one declaration, no copy). */\nexport { appActionsKey } from \"../repos/apps.ts\";\n\nconst NO_APPS: ReadonlyMap<string, AppSummary> = new Map();\n\n/** A bounded set of app records by id. Empty when the host's API has no `listAppsByIds`. */\nexport function useEditorApps(ids: readonly string[]): { byId: ReadonlyMap<string, AppSummary> } {\n const api = useW6WApi();\n const list = api.listAppsByIds?.bind(api);\n const key = [...ids].sort().join(\",\");\n const q = useQuery({\n queryKey: [\"editor-apps\", key],\n queryFn: ({ signal }) => (list ? list(ids, { signal }) : Promise.resolve([] as AppSummary[])),\n enabled: ids.length > 0 && typeof list === \"function\",\n });\n const data = q.data;\n const byId = useMemo(\n () => (data ? new Map(data.map((a) => [a.id, a] as const)) : NO_APPS),\n [data],\n );\n return { byId };\n}\n\n/**\n * One app record by id, over {@link useEditorApps} (same `/apps` request, same cache entry as the\n * canvas's batch lookup). `undefined` while loading, for an empty id (which issues no request),\n * or when the host's API cannot look apps up by id.\n */\nexport function useEditorApp(id: string): AppSummary | undefined {\n const { byId } = useEditorApps(id ? [id] : []);\n return id ? byId.get(id) : undefined;\n}\n"],"names":["SEARCH_DEBOUNCE_MS","scrollParent","el","p","overflowY","HistoryView","props","scope","showKind","filters","onFiltersChange","onOpenInEditor","filtersRef","useRef","q","setQ","useState","searchTimer","selected","setSelected","useEffect","listQuery","useHistoryQuery","statsQuery","useHistoryStatsQuery","detailQuery","useExecutionDetailQuery","rerun","useRerunExecutionMutation","findExecution","useFindExecution","findError","setFindError","viewRef","listScroll","selectedId","useLayoutEffect","parent","top","selectedRef","open","useCallback","next","executions","_a","offset","hasMore","_b","applyFilters","onChange","onPrev","HISTORY_PAGE_SIZE","onNext","onSelect","executionId","row","r","startRerun","summary","rerunningId","_c","openOriginal","callableId","id","rerunError","jsxs","filterValue","openInEditor","jsx","ExecutionDetail","ExecutionStats","ExecutionFilters","ExecutionList","NO_APPS","useEditorApps","ids","api","useW6WApi","list","key","data","useQuery","signal","useMemo","useEditorApp","byId"],"mappings":";;;;;;AAwDA,MAAMA,KAAqB;AAI3B,SAASC,EAAaC,GAA4C;AAChE,WAASC,KAAID,KAAA,gBAAAA,EAAI,kBAAiB,MAAMC,GAAGA,IAAIA,EAAE,eAAe;AAC9D,UAAMC,IAAY,iBAAiBD,CAAC,EAAE;AACtC,SAAKC,MAAc,UAAUA,MAAc,aAAaD,EAAE,eAAeA,EAAE;AACzE,aAAOA;AAAA,EAEX;AACA,SAAO;AACT;AAgBO,SAASE,GAAYC,GAAyB;;AACnD,QAAM,EAAE,OAAAC,GAAO,UAAAC,GAAU,SAAAC,GAAS,iBAAAC,GAAiB,gBAAAC,MAAmBL,GAKhEM,IAAaC,EAAOJ,CAAO;AACjC,EAAAG,EAAW,UAAUH;AAErB,QAAM,CAAC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AA,EAAO,KAAK,GAAG,GAM9BK,IALIC,GAAS;AAAA,IACjB,UAAU,CAAC,eAAeF,CAAG;AAAA,IAC7B,SAAS,CAAC,EAAE,QAAAG,EAAA,MAAcJ,IAAOA,EAAKH,GAAK,EAAE,QAAAO,GAAQ,IAAI,QAAQ,QAAQ,CAAA,CAAkB;AAAA,IAC3F,SAASP,EAAI,SAAS,KAAK,OAAOG,KAAS;AAAA,EAAA,CAC5C,EACc;AAKf,SAAO,EAAE,MAJIK;AAAA,IACX,MAAOH,IAAO,IAAI,IAAIA,EAAK,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAU,CAAC,IAAIP;AAAA,IAC7D,CAACO,CAAI;AAAA,EAAA,EAEE;AACX;AAOO,SAASI,GAAarB,GAAoC;AAC/D,QAAM,EAAE,MAAAsB,MAASX,GAAcX,IAAK,CAACA,CAAE,IAAI,EAAE;AAC7C,SAAOA,IAAKsB,EAAK,IAAItB,CAAE,IAAI;AAC7B;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflows-Dz8LMjnt.js","sources":["../src/lib/workflow-live-run.ts","../src/lib/workflow-poll.ts","../src/lib/history-query.ts","../src/repos/workflows.ts"],"sourcesContent":["/**\n * Pure decision layer for the visual editor's live Run/Stop feature (T2.1.1,\n * A7). Every judgment call this feature makes that is NOT layout — is a run\n * in flight? should polling continue? is the canvas editable right now? what\n * should the Run button say and is it disabled? how does a cancel failure\n * get handled? how does a `RunState`'s steps map to the execution log\n * panel's rows, and what error does each row and the run show? what `input`\n * does the header Run send? — lives here as plain functions of (run state) -> result,\n * with no `.tsx` import and no React import, so `node --test` can load this\n * module directly. Same mechanical reason `workflow-poll.ts` and\n * `repos/reliability-uptime.ts` exist as separate `.ts` modules — read\n * `workflow-poll.ts`'s own header. `WorkflowsPage.tsx` calls these functions\n * rather than restating the conditions inline.\n */\nimport { type StateLogRow, foldStateLog } from \"@w6w/expr\";\nimport { type RunStatus, isTerminalRunStatus } from \"@w6w/sdk\";\n\nexport type { RunStatus };\n\n/**\n * The five states a workflow step's execution can be in — a thin LOCAL copy\n * of `@w6w/ui`'s `StepStatus` (itself a thin local copy of the engine's\n * `StepStatus` — see `run-visuals.ts`'s own header in `packages/ui`, the\n * same house idiom). `@w6w/sdk/console`'s `RunState.steps` is deliberately\n * typed `Record<string, unknown>` — opaque pass-through, by that module's\n * own documented design — so the real per-step shape has to be re-stated\n * here rather than imported.\n */\nexport type StepStatus = \"pending\" | \"running\" | \"succeeded\" | \"failed\" | \"skipped\";\n\n/** The per-step metadata (which app/version/action/connection ran) — one\n * local structural copy of the pinned `StepMeta`. A `type` alias, not an\n * `interface`, so it stays assignable to index-signature types. */\nexport type StepMetaLike = {\n app: string;\n version: string;\n action: string;\n connectionId: string | null;\n};\n\n/** The slice of a `StepExecution` this module reads, to build one\n * `ExecutionLogPanel` row. */\nexport interface StepExecutionLike {\n status: StepStatus;\n /** Why a `skipped` step did not run (`NodeExecution.skipReason`); read as `unknown` (opaque\n * wire) and carried only when it is one of the four known reasons. */\n skipReason?: unknown;\n startedAt?: string;\n finishedAt?: string;\n input?: unknown;\n output?: unknown;\n logs?: string[];\n /** `StepExecution.error` — a `StepError` on `failed` per rfcs/workflow.md\n * §StepExecution, but read as `unknown` because `RunState.steps` is opaque\n * on the wire; {@link toLogError} normalises whatever actually arrives. */\n error?: unknown;\n /** Recorded metadata; absent (or null) for steps that recorded none. */\n meta?: StepMetaLike | null;\n /** For each only (I3): per-iteration body records, read as `unknown` (opaque wire). */\n iterations?: unknown;\n iterationsTotal?: unknown;\n iterationsFailed?: unknown;\n iterationsTruncated?: unknown;\n}\n\n/** A step or run error, as the run log panel renders it — field-for-field\n * `@w6w/ui`'s `ExecutionLogError` (rfcs/workflow.md §StepError's\n * `code`/`message`/`phase`/`retryable`), restated locally for the same reason\n * as {@link ExecutionLogStepLike} below. `message` is never empty. */\nexport interface LogErrorLike {\n code?: string;\n message: string;\n phase?: string;\n retryable?: boolean;\n}\n\n/** One `RunState.stepErrors` entry the panel shows at run level — field-for-field\n * `@w6w/ui`'s `ExecutionLogRecordedError`, restated locally (see above). */\nexport interface RecordedLogErrorLike {\n stepId: string;\n label?: string;\n error: LogErrorLike;\n}\n\n/** The slice of a `RunState` {@link runLevelErrors} reads. */\nexport interface RunErrorSourceLike {\n status?: string;\n error?: unknown;\n stepErrors?: ReadonlyArray<{ nodeId?: string; stepId?: string; error: unknown }>;\n}\n\n/** The per-node execution map of a run record, in either shape — `nodes`\n * preferred, else the legacy `steps`. */\nexport function runNodeMap(\n run: { nodes?: unknown; steps?: unknown } | undefined | null,\n): Record<string, StepExecutionLike> | undefined {\n return (run?.nodes ?? run?.steps ?? undefined) as Record<string, StepExecutionLike> | undefined;\n}\n\n/** The slice of a saved step-test fixture (`StepTest`) {@link latestFixtureInput}\n * reads — `with` is what the trigger's Test tab invokes it with. */\nexport interface StepTestFixtureLike {\n with?: unknown;\n}\n\n/** The row-level fallback for a `failed` step that carries no `error` at all. */\nexport const STEP_FAILED_NO_REASON = \"Node failed without reporting a reason.\";\n\n/** The run-level fallback for a `failed` run where nothing carries a reason. */\nexport const RUN_FAILED_NO_REASON = \"Run failed without reporting a reason.\";\n\n/** One `ExecutionLogPanel` row — field-for-field `@w6w/ui`'s\n * `ExecutionLogStep`, restated locally for the same reason as\n * {@link StepExecutionLike} above (no runtime dependency on `@w6w/ui`,\n * which this module must not import — see the file header). */\nexport interface ExecutionLogStepLike {\n id: string;\n status: StepStatus;\n skipReason?: SkipReasonLike;\n startedAt?: string;\n finishedAt?: string;\n input?: unknown;\n output?: unknown;\n logs?: string[];\n error?: LogErrorLike;\n meta?: StepMetaLike;\n /** For each only (I4) — field-for-field `@w6w/ui`'s `ExecutionLogStep`. */\n iterations?: ExecutionLogIterationLike[];\n iterationsTotal?: number;\n iterationsFailed?: number;\n iterationsTruncated?: boolean;\n /** This node's state writes (`GET /runs/:id/state-writes` rows, in `seq` order) —\n * field-for-field `@w6w/ui`'s `ExecutionLogStep.stateWrites` (plan §2.7). Absent → no State block. */\n stateWrites?: StateWriteEntryLike[] | null;\n /** The state tree right after this node's last write (`foldStateLog`). */\n stateAfter?: Record<string, unknown> | null;\n}\n\n/** One state-write entry on a run-log row — `@w6w/ui`'s `ExecutionLogStep.stateWrites[number]`. */\nexport type StateWriteEntryLike = {\n path: string[];\n item?: number;\n old?: unknown;\n new?: unknown;\n warning?: string;\n};\n\n/** One For each iteration row (I4) — mirrors `@w6w/ui`'s `ExecutionLogIteration`. */\nexport interface ExecutionLogIterationLike {\n index: number;\n status: \"succeeded\" | \"failed\" | \"running\";\n failedNodeId?: string;\n steps: ExecutionLogStepLike[];\n}\n\n/** How a cancel-request failure should be handled (A6). */\nexport type CancelErrorOutcome = \"reconcile\" | \"surface\";\n\n/**\n * A2/M1 — the `refetchInterval` decision: keep polling (`true`) until the\n * run's status is terminal (`false`), including while no run has answered\n * yet (`status === undefined` — the very first poll hasn't landed, or no run\n * is active at all).\n */\nexport function shouldContinuePolling(status: RunStatus | undefined): boolean {\n return status === undefined || !isTerminalRunStatus(status);\n}\n\n/**\n * A4/M2/M3 — is a run currently \"in flight\" from this page's point of view?\n * `true` only while the poll has a live, non-terminal status AND the poll\n * itself hasn't given up/errored — a failed poll unlocks the canvas exactly\n * like reaching a real terminal status does (A4's own named failure case: \"a\n * canvas that stays locked after a cancel\"). Drives the canvas's `readOnly`\n * prop, the Stop button's visibility, and the Run button's disabled state —\n * one function, three call sites, so they can never drift out of sync with\n * each other.\n */\nexport function isRunInFlight(status: RunStatus | undefined, pollFailed: boolean): boolean {\n if (pollFailed) return false;\n if (status === undefined) return false;\n return !isTerminalRunStatus(status);\n}\n\n/**\n * When a run turns terminal, how long after (ms) the editor re-reads the workflow's saved step\n * tests. The server books every step that succeeded in an editor run as its passing saved test\n * (`step-passes.ts`) — the record the publish gate reads — but only AFTER the engine has\n * checkpointed the run's terminal state, so the poll can see `succeeded` a few milliseconds before\n * the pass lands. The immediate read covers the usual case; the later one covers that window.\n */\nexport const STEP_PASS_REFRESH_DELAYS_MS: readonly number[] = [0, 1500];\n\n/**\n * Should the editor re-read this workflow's saved step tests now? Only once the run it polls is\n * terminal and belongs to the open workflow — a run's passes are booked as it finishes, and the\n * step-tests cache never refetches on its own (`refetchOnWindowFocus: false`), so without this\n * the publish gate keeps the pre-run list and a step that just passed still blocks Publish.\n */\nexport function stepPassRefreshDue(\n status: RunStatus | undefined,\n runWorkflowId: string | undefined,\n workflowId: string,\n): boolean {\n return status !== undefined && isTerminalRunStatus(status) && runWorkflowId === workflowId;\n}\n\n/** A1/A6 — what the Run button should read right now. */\nexport function runButtonLabel(status: RunStatus | undefined, pollFailed: boolean): string {\n if (!isRunInFlight(status, pollFailed)) return \"Run\";\n return status === \"queued\" ? \"Queued…\" : \"Running…\";\n}\n\n/**\n * A6/M6 — classify a `cancel()` failure. `run_not_cancelable` (409) means\n * the run already reached a terminal state before the cancel request landed\n * — not a user-facing error, just reconcile to whatever the next poll\n * reports. Everything else (`unknown_run`, a network failure, …) is a real\n * failure the page's existing error affordance must show.\n */\nexport function classifyCancelError(code: string): CancelErrorOutcome {\n return code === \"run_not_cancelable\" ? \"reconcile\" : \"surface\";\n}\n\n/**\n * G5 — map a `RunState`'s opaque `steps` record onto `ExecutionLogPanel`'s\n * row shape, preserving its keys and timestamps. Record key order is not\n * execution order; `ExecutionLogPanel` sorts the rows chronologically for\n * both live runs and saved history.\n */\nexport function mapRunStateToLogSteps(\n steps: Record<string, StepExecutionLike> | undefined,\n stateLog?: readonly StateLogRow[],\n): ExecutionLogStepLike[] {\n if (!steps) return [];\n const state = stateLog ? stateFieldsByNode(stateLog) : undefined;\n return Object.entries(steps).map(([id, step]) => ({\n ...mapStep(id, step),\n ...iterationFields(step),\n ...(state?.get(id) ?? {}),\n }));\n}\n\n/**\n * The run's state-write log (`GET /runs/:id/state-writes`) grouped by node, in `seq`\n * order whatever order the rows arrive in: each node's entries (only `path` plus the\n * `item`/`old`/`new`/`warning` a row has — never `seq`/`nodeId`/`step`) and the tree\n * right after its last row, folded by `@w6w/expr`'s `foldStateLog` (one fold for the\n * whole product, R18). Rows with a null `nodeId` (the base row) attach to no node but\n * still seed every fold.\n */\nfunction stateFieldsByNode(\n log: readonly StateLogRow[],\n): Map<string, Pick<ExecutionLogStepLike, \"stateWrites\" | \"stateAfter\">> {\n const rows = [...log].sort((a, b) => a.seq - b.seq);\n const byNode = new Map<string, { writes: StateWriteEntryLike[]; lastSeq: number }>();\n for (const row of rows) {\n if (row.nodeId === null || row.nodeId === undefined) continue;\n const entry: StateWriteEntryLike = { path: row.path };\n if (row.item !== undefined) entry.item = row.item;\n if (row.old !== undefined) entry.old = row.old;\n if (row.new !== undefined) entry.new = row.new;\n if (row.warning !== undefined) entry.warning = row.warning;\n const group = byNode.get(row.nodeId) ?? { writes: [], lastSeq: row.seq };\n group.writes.push(entry);\n group.lastSeq = row.seq;\n byNode.set(row.nodeId, group);\n }\n const out = new Map<string, Pick<ExecutionLogStepLike, \"stateWrites\" | \"stateAfter\">>();\n for (const [id, { writes, lastSeq }] of byNode) {\n out.set(id, { stateWrites: writes, stateAfter: foldStateLog(rows, lastSeq) });\n }\n return out;\n}\n\n/** `@w6w/ui`'s `SkipReason`, restated locally (see {@link ExecutionLogStepLike}). */\nexport type SkipReasonLike = \"not_on_path\" | \"condition\" | \"stopped\" | \"disabled\";\n\nconst SKIP_REASONS: ReadonlySet<unknown> = new Set([\n \"not_on_path\",\n \"condition\",\n \"stopped\",\n \"disabled\",\n]);\n\n/** One wire record -> one row (shared by top-level rows and iteration body steps). */\nfunction mapStep(id: string, step: StepExecutionLike): ExecutionLogStepLike {\n return {\n id,\n status: step.status,\n ...(step.status === \"skipped\" && SKIP_REASONS.has(step.skipReason)\n ? { skipReason: step.skipReason as SkipReasonLike }\n : {}),\n startedAt: step.startedAt,\n finishedAt: step.finishedAt,\n input: step.input,\n output: step.output,\n ...(Array.isArray(step.logs) && step.logs.length\n ? { logs: step.logs.filter((line): line is string => typeof line === \"string\") }\n : {}),\n ...(step.meta !== undefined && step.meta !== null ? { meta: step.meta } : {}),\n ...rowError(step),\n };\n}\n\nconst ITERATION_STATUSES: ReadonlySet<unknown> = new Set([\"succeeded\", \"failed\", \"running\"]);\n\n/** The I4 `iterations*` keys for a For each record (I3) — empty (no own keys) when\n * `iterations` is not an array. */\nfunction iterationFields(\n step: StepExecutionLike,\n): Pick<\n ExecutionLogStepLike,\n \"iterations\" | \"iterationsTotal\" | \"iterationsFailed\" | \"iterationsTruncated\"\n> {\n if (!step || !Array.isArray(step.iterations)) return {};\n const iterations = (step.iterations as Array<Record<string, unknown> | null>)\n .filter((it): it is Record<string, unknown> => it !== null && typeof it === \"object\")\n .map((it) => {\n const nodes =\n it.nodes !== null && typeof it.nodes === \"object\"\n ? (it.nodes as Record<string, StepExecutionLike>)\n : {};\n // An inner For each is a body step with iterations of its own: recurse (nested loops).\n const steps = Object.entries(nodes).map(([id, s]) => ({\n ...mapStep(id, s),\n ...iterationFields(s),\n }));\n const failedNodeId =\n typeof it.failedNodeId === \"string\" && it.failedNodeId !== \"\"\n ? it.failedNodeId\n : steps.find((s) => s.status === \"failed\")?.id;\n const status = ITERATION_STATUSES.has(it.status)\n ? (it.status as ExecutionLogIterationLike[\"status\"])\n : steps.some((s) => s.status === \"failed\")\n ? \"failed\"\n : steps.some((s) => s.status === \"running\")\n ? \"running\"\n : \"succeeded\";\n return {\n index: it.index as number,\n status,\n ...(failedNodeId !== undefined ? { failedNodeId } : {}),\n steps,\n };\n })\n .sort((a, b) => a.index - b.index);\n const finite = (n: unknown): n is number => typeof n === \"number\" && Number.isFinite(n);\n return {\n iterations,\n ...(finite(step.iterationsTotal) ? { iterationsTotal: step.iterationsTotal } : {}),\n ...(finite(step.iterationsFailed) ? { iterationsFailed: step.iterationsFailed } : {}),\n ...(typeof step.iterationsTruncated === \"boolean\"\n ? { iterationsTruncated: step.iterationsTruncated }\n : {}),\n };\n}\n\n/** The `error` key for one row — present ONLY when the step reports an error\n * or is `failed` (then with {@link STEP_FAILED_NO_REASON}), so a healthy row\n * keeps exactly the shape it had before errors were carried. */\nfunction rowError(step: StepExecutionLike): { error?: LogErrorLike } {\n const error = toLogError(step.error);\n if (error) return { error };\n if (step.status === \"failed\") return { error: { message: STEP_FAILED_NO_REASON } };\n return {};\n}\n\n/**\n * Normalise whatever a step or run reported as its error into the panel's\n * {@link LogErrorLike}. `null`/`undefined` mean \"no error\". A non-empty string\n * is the message. An object contributes `code` (string), `message` (its own\n * non-empty `message`, else a non-empty `code`, else its JSON), `phase`\n * (string) and `retryable` (boolean). Anything else is stringified. The\n * returned `message` is never empty.\n */\nexport function toLogError(raw: unknown): LogErrorLike | undefined {\n if (raw === null || raw === undefined) return undefined;\n if (typeof raw === \"string\" && raw !== \"\") return { message: raw };\n if (typeof raw === \"object\") {\n const o = raw as Record<string, unknown>;\n const code = typeof o.code === \"string\" ? o.code : undefined;\n const message =\n typeof o.message === \"string\" && o.message !== \"\" ? o.message : code || safeJson(raw);\n return {\n ...(code !== undefined ? { code } : {}),\n message: message || \"Unknown error.\",\n ...(typeof o.phase === \"string\" ? { phase: o.phase } : {}),\n ...(typeof o.retryable === \"boolean\" ? { retryable: o.retryable } : {}),\n };\n }\n return { message: String(raw) || \"Unknown error.\" };\n}\n\n/** `JSON.stringify` that answers `\"\"` instead of throwing (a cycle, a BigInt)\n * or returning `undefined` (a `toJSON` that yields nothing). */\nfunction safeJson(raw: unknown): string {\n try {\n return JSON.stringify(raw) ?? \"\";\n } catch {\n return \"\";\n }\n}\n\n/**\n * The run-level half of the run log: `RunState.error` as `runError`, plus the\n * `RunState.stepErrors` entries whose step has NO row already carrying an\n * error (a `continue-record` failure is usually also on its own row — showing\n * it twice would read as two failures), in their given order. A row showing\n * only {@link STEP_FAILED_NO_REASON} does not count as carrying an error here,\n * so the reason recorded for that step is still surfaced. A `failed` run where\n * nothing — run, rows or surfaced step errors — carries a reason gets\n * {@link RUN_FAILED_NO_REASON}. `runError` is omitted when it duplicates a\n * row's error (equal `message` and equal `code`), since the step failure that\n * stopped the run is already shown on its row. It is likewise omitted when it\n * duplicates a surfaced `stepErrors` entry's error, by the same equality.\n * Keys are omitted when empty.\n */\nexport function runLevelErrors(\n run: RunErrorSourceLike | undefined,\n rows: ReadonlyArray<ExecutionLogStepLike>,\n): { runError?: LogErrorLike; stepErrors?: RecordedLogErrorLike[] } {\n if (!run) return {};\n const carried = new Set(rows.filter((r) => r.error !== undefined).map((r) => r.id));\n const reasoned = new Set(\n rows\n .filter((r) => r.error !== undefined && r.error.message !== STEP_FAILED_NO_REASON)\n .map((r) => r.id),\n );\n const stepErrors = (run.stepErrors ?? [])\n .map((e) => ({ e, id: e.nodeId ?? e.stepId ?? \"\" }))\n .filter(({ id }) => !reasoned.has(id))\n .map(({ e, id }) => ({\n stepId: id,\n error: toLogError(e.error) ?? { message: STEP_FAILED_NO_REASON },\n }));\n const own = toLogError(run.error);\n const sameAsOwn = (e: LogErrorLike | undefined) =>\n own !== undefined && e?.message === own.message && e?.code === own.code;\n const shown = rows.some((r) => sameAsOwn(r.error)) || stepErrors.some((e) => sameAsOwn(e.error));\n let runError = shown ? undefined : own;\n if (!runError && run.status === \"failed\" && carried.size === 0 && stepErrors.length === 0) {\n runError = { message: RUN_FAILED_NO_REASON };\n }\n return {\n ...(runError ? { runError } : {}),\n ...(stepErrors.length > 0 ? { stepErrors } : {}),\n };\n}\n\n/**\n * The header Run's `input`: the LAST saved fixture's `with` (`listStepTests`\n * answers oldest-first — the same \"last is latest\" reading\n * `@w6w/ui`'s `TriggerFillForm` seeds from), when it is a plain object.\n * Sent verbatim — `{type:\"expr\",…}` values included.\n */\nexport function latestFixtureInput(\n tests: ReadonlyArray<StepTestFixtureLike> | undefined,\n): Record<string, unknown> | undefined {\n const last = tests?.[tests.length - 1]?.with;\n if (last === null || typeof last !== \"object\" || Array.isArray(last)) return undefined;\n return last as Record<string, unknown>;\n}\n\n/**\n * Resolve the header Run's `input` for the manual trigger `triggerStepId`.\n * No trigger id → `undefined` without fetching. A fetch that throws or\n * rejects → `undefined`: a missing fixture never blocks the run. Fetched at\n * click time on purpose — a cached `stepTestsKey` query can be stale, since\n * saving a fixture does not invalidate it.\n */\nexport async function resolveHeaderRunInput(\n triggerStepId: string | undefined,\n list: (stepId: string) => Promise<ReadonlyArray<StepTestFixtureLike> | undefined>,\n remembered?: () => Promise<ReadonlyArray<{ nodeId: string; input: unknown }> | undefined>,\n): Promise<Record<string, unknown> | undefined> {\n if (!triggerStepId) return undefined;\n // The REMEMBERED test input (`node_test_inputs`) is what the trigger last ran with on any\n // editor surface, so it wins; a `{}` row was cleared (no `input`, no fixture fallback). No row\n // (or a failed read) falls back to the latest fixture, exactly as before.\n if (remembered) {\n try {\n const row = (await remembered())?.find((r) => r.nodeId === triggerStepId);\n if (row) {\n const input = row.input;\n if (input === null || typeof input !== \"object\" || Array.isArray(input)) return undefined;\n return Object.keys(input).length > 0 ? (input as Record<string, unknown>) : undefined;\n }\n } catch {\n // fall through to the fixture\n }\n }\n try {\n return latestFixtureInput(await list(triggerStepId));\n } catch {\n return undefined;\n }\n}\n\n/** The trigger the header Run starts at, and whether it is the Manual trigger. */\nexport interface HeaderRunEntry {\n id: string;\n manual: boolean;\n}\n\n/**\n * The trigger the header Run starts at, and so whose remembered sample payload it runs with: the\n * FIRST Manual trigger (a run's own default entry), else the first other entry trigger — a\n * webhook, a schedule or an app trigger. Before, only a Manual trigger was looked up, so a\n * webhook-started workflow's header Run sent no payload at all. `undefined` when nothing in\n * `steps` is a trigger. The predicates are injected (`@w6w/ui/flow`), as in `trigger-preview.ts`.\n */\nexport function headerRunEntry(\n steps: ReadonlyArray<{ id: string; uses?: { app?: string; trigger?: unknown } }>,\n isManualTrigger: (app: string) => boolean,\n isEntryTrigger: (uses: { app: string; trigger?: true }) => boolean,\n): HeaderRunEntry | undefined {\n const manual = steps.find((s) => !!s.uses?.app && isManualTrigger(s.uses.app));\n if (manual) return { id: manual.id, manual: true };\n const other = steps.find(\n (s) =>\n !!s.uses?.app &&\n isEntryTrigger({ app: s.uses.app, ...(s.uses.trigger === true ? { trigger: true } : {}) }),\n );\n return other ? { id: other.id, manual: false } : undefined;\n}\n","/**\n * The run-polling loop, split out of `api/client.ts`'s original `runWorkflow`\n * into its own PURE module — for the SAME mechanical reason\n * `repos/reliability-uptime.ts` exists (read that file's own header comment in\n * full): a `.ts` module that would otherwise transitively import\n * `../api/apiClient.tsx` (a `.tsx` file Node's type-stripping cannot load at\n * all) must be split out to stay reachable by `node --test`.\n *\n * Ported field-for-field from `api/client.ts`'s original `runWorkflow` (same\n * 500 ms interval, same 600-iteration cap, same \"one more fetch after the\n * loop\" shape) — the ONLY change is the injected `getRun`/`sleep` parameters,\n * which is what makes this loop testable on a fake clock instead of a real\n * 5-minute wait. See `../repos/workflows.ts` for the caller.\n */\nimport type { RunState } from \"@w6w/sdk/console\";\n\nconst TERMINAL = new Set([\"succeeded\", \"failed\", \"canceled\"]);\n\nfunction realSleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Poll `getRun` until the run reaches a terminal status, or 600 polls (~5\n * minutes at the default 500ms interval) elapse — whichever comes first.\n * Ported verbatim from `api/client.ts`'s `runWorkflow`; see\n * `../repos/workflows.ts` for the caller.\n */\nexport async function pollRunToTerminal(\n getRun: () => Promise<RunState>,\n sleep: (ms: number) => Promise<void> = realSleep,\n): Promise<RunState> {\n for (let i = 0; i < 600; i++) {\n const run = await getRun();\n if (TERMINAL.has(run.status)) return run;\n await sleep(500);\n }\n return getRun();\n}\n","// Run: node --test src/lib/__tests__/history-query.test.ts (Node 24, type-stripped)\n//\n// T2.3.1 — the pure data layer behind the project-wide and per-callable\n// History page (T2.4.1) and the Function/Endpoint/Workflow header's History\n// button (T2.4.2). Everything that is a judgment call rather than React\n// plumbing lives here: how a URL's search string becomes a `HistoryFilters`\n// (and back), how a filter set becomes the wire's own query params, the\n// query keys every hook in `repos/history.ts` shares, and how a summary row\n// is expanded into a full detail view for one of the three callable kinds.\n//\n// Zero runtime imports other than `./workflow-live-run.ts` and\n// `./workflow-poll.ts` (A1) — every other import here is `import type`, erased\n// at build time, so `node --test` can load this module directly with no React,\n// no SDK runtime, no JSX. The first reuses `mapRunStateToLogSteps`, the same\n// step mapper the visual editor's live-run overlay already uses, so a\n// workflow's historical detail view renders steps identically to its live\n// one; the second is the same run-polling loop the editor's own Run uses, so a\n// re-run waits for its workflow exactly as a run started there does.\n//\n// The wire shape (`ExecutionKind`, `ExecutionStatus`, `ExecutionSummary`,\n// `ExecutionStats`) is pinned verbatim against T2.1.1's own contract — do not\n// drift it; T2.4.1/T2.4.2 are written against this file's exports exactly.\n\nimport type { W6WClient } from \"@w6w/sdk\";\nimport { mapRunStateToLogSteps, runNodeMap } from \"./workflow-live-run.ts\";\nimport { pollRunToTerminal } from \"./workflow-poll.ts\";\n\n// ── wire types (pinned, identical to T2.1.1 §Wire) ──────────────────────\n\nexport type ExecutionKind = \"function\" | \"endpoint\" | \"workflow\";\nexport type ExecutionStatus = \"queued\" | \"running\" | \"succeeded\" | \"failed\" | \"canceled\";\n\nexport interface ExecutionSummary {\n id: string;\n kind: ExecutionKind;\n callableId: string;\n callableName: string;\n status: ExecutionStatus;\n startedAt: string;\n finishedAt: string | null;\n durationMs: number | null;\n workflowRunId: string | null;\n /** The execution this one RE-RUNS (History's Re-run), or `null`. Absent from an older server. */\n rerunOf?: string | null;\n /** How a workflow run was started (manual, schedule, webhook, event, replay); `null` for a\n * Function/Endpoint call. Absent from an older server. */\n trigger?: string | null;\n /** The trigger node a workflow run entered through. Absent from an older server. */\n triggerNodeId?: string | null;\n /** The start of the input as JSON text. Absent from an older server. */\n inputPreview?: string | null;\n}\n\nexport interface ExecutionStats {\n total: number;\n succeeded: number;\n failed: number;\n canceled: number;\n inFlight: number;\n successRate: number | null;\n avgDurationMs: number | null;\n}\n\n// ── scope + filters ───────────────────────────────────────────────────────\n\n/** Either the project-wide view or one callable's own history — mutually\n * exclusive, never both, mirroring the wire's own `project`|`callable`\n * params (exactly one). */\nexport type HistoryScope = { project: string } | { callable: string };\n\n/** Everything the History page's filter chrome can set, already parsed out\n * of the URL. `status`/`kind` are `\"\"` for \"any\"; `from`/`to` are the\n * `YYYY-MM-DD` the date pickers hand back, or `\"\"` for unset; `offset` is\n * always a non-negative integer (0 for \"first page\"). */\nexport interface HistoryFilters {\n status: ExecutionStatus | \"\";\n kind: ExecutionKind | \"\";\n from: string;\n to: string;\n q: string;\n offset: number;\n}\n\nexport const EMPTY_HISTORY_FILTERS: HistoryFilters = {\n status: \"\",\n kind: \"\",\n from: \"\",\n to: \"\",\n q: \"\",\n offset: 0,\n};\n\nexport const HISTORY_PAGE_SIZE = 25;\n\nconst VALID_STATUSES: ReadonlySet<string> = new Set([\n \"queued\",\n \"running\",\n \"succeeded\",\n \"failed\",\n \"canceled\",\n]);\nconst VALID_KINDS: ReadonlySet<string> = new Set([\"function\", \"endpoint\", \"workflow\"]);\nconst DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** True when `YYYY-MM-DD` names a real calendar day (`2026-02-30` rolls into\n * March through `new Date`, so a round-trip comparison rejects it). */\nfunction isRealDate(s: string): boolean {\n if (!DATE_RE.test(s)) return false;\n const { y, m, d } = dateParts(s);\n const dt = new Date(y, m - 1, d);\n return dt.getFullYear() === y && dt.getMonth() === m - 1 && dt.getDate() === d;\n}\n\n/** Parse a validated `YYYY-MM-DD` string into its three numeric parts. */\nfunction dateParts(value: string): { y: number; m: number; d: number } {\n const [y, m, d] = value.split(\"-\").map(Number);\n return { y, m, d };\n}\n\n/**\n * URL search string → `HistoryFilters`. An unrecognised `status`/`kind`, a\n * `from`/`to` not matching `YYYY-MM-DD`, or a non-integer/negative `offset`\n * all fall back to their empty/zero default rather than carrying a bogus\n * value forward into a request — a stale or hand-edited URL degrades to \"no\n * filter\" instead of erroring.\n */\nexport function filtersFromSearch(search: string): HistoryFilters {\n const params = new URLSearchParams(search);\n const status = params.get(\"status\") ?? \"\";\n const kind = params.get(\"kind\") ?? \"\";\n const from = params.get(\"from\") ?? \"\";\n const to = params.get(\"to\") ?? \"\";\n const q = params.get(\"q\") ?? \"\";\n const offsetRaw = params.get(\"offset\");\n let offset = 0;\n if (offsetRaw !== null) {\n const n = Number(offsetRaw);\n if (Number.isInteger(n) && n >= 0) offset = n;\n }\n return {\n status: VALID_STATUSES.has(status) ? (status as ExecutionStatus) : \"\",\n kind: VALID_KINDS.has(kind) ? (kind as ExecutionKind) : \"\",\n from: isRealDate(from) ? from : \"\",\n to: isRealDate(to) ? to : \"\",\n q,\n offset,\n };\n}\n\n/**\n * `HistoryFilters` → URL search string. `\"\"` when every field is at its\n * default, else a leading-`?` string with only the non-default fields, in\n * the pinned key order `status,kind,from,to,q,offset` (so two renders of the\n * same filters always produce byte-identical URLs — stable for bookmarking\n * and for `filtersFromSearch` round-tripping).\n */\nexport function filtersToSearch(f: HistoryFilters): string {\n const params = new URLSearchParams();\n if (f.status !== \"\") params.set(\"status\", f.status);\n if (f.kind !== \"\") params.set(\"kind\", f.kind);\n if (f.from !== \"\") params.set(\"from\", f.from);\n if (f.to !== \"\") params.set(\"to\", f.to);\n if (f.q !== \"\") params.set(\"q\", f.q);\n if (f.offset > 0) params.set(\"offset\", String(f.offset));\n const s = params.toString();\n return s === \"\" ? \"\" : `?${s}`;\n}\n\n/**\n * `HistoryFilters` + a scope → the wire's own query params (D3/pinned rules).\n * `kind` is sent only for a project scope with a non-empty kind — a\n * per-callable view already knows its one kind, and the server's `kind`\n * param is project-mode-only. `from`/`to` are expanded from the picked\n * calendar day into the half-open `[from, to)` ISO instant range the wire\n * wants — `to` is the NEXT day's midnight so the picked day itself is fully\n * inclusive. `q` is trimmed and omitted when blank (server-side id/name\n * search, D3 — never a payload scan). Paging params are added only when\n * `opts.paged`: `limit` always (defaulting to `HISTORY_PAGE_SIZE`), `offset`\n * only when it would change anything (`> 0`).\n */\nexport function historyRequestQuery(\n scope: HistoryScope,\n f: HistoryFilters,\n opts: { paged: boolean; limit?: number },\n): Record<string, string> {\n const query: Record<string, string> = {};\n\n if (\"project\" in scope) {\n query.project = scope.project;\n if (f.kind !== \"\") query.kind = f.kind;\n } else {\n query.callable = scope.callable;\n }\n\n if (f.status !== \"\") query.status = f.status;\n\n if (f.from !== \"\" && isRealDate(f.from)) {\n const { y, m, d } = dateParts(f.from);\n query.from = new Date(y, m - 1, d).toISOString();\n }\n if (f.to !== \"\" && isRealDate(f.to)) {\n const { y, m, d } = dateParts(f.to);\n query.to = new Date(y, m - 1, d + 1).toISOString();\n }\n\n const q = f.q.trim();\n if (q !== \"\") query.q = q;\n\n if (opts.paged) {\n query.limit = String(opts.limit ?? HISTORY_PAGE_SIZE);\n if (f.offset > 0) query.offset = String(f.offset);\n }\n\n return query;\n}\n\n// ── cache keys (ship from here, never from a caller — mirrors `repos/dashboard.ts`) ──\n\n/**\n * Every key this domain reads or invalidates. `list`/`stats` carry the full\n * scope and filters object so two distinct filter sets never collide on the\n * same cache entry (and the identical pair always do) — react-query's own\n * structural key hashing does the rest.\n */\nexport const historyKeys = {\n root: [\"history\"] as const,\n list(scope: HistoryScope, f: HistoryFilters, limit: number): readonly unknown[] {\n return [\"history\", \"list\", scope, f, limit];\n },\n stats(scope: HistoryScope, f: HistoryFilters): readonly unknown[] {\n return [\"history\", \"stats\", scope, f];\n },\n exists(callableId: string): readonly [\"history\", \"exists\", string] {\n return [\"history\", \"exists\", callableId];\n },\n detail(kind: ExecutionKind, id: string): readonly [\"history\", \"detail\", ExecutionKind, string] {\n return [\"history\", \"detail\", kind, id];\n },\n};\n\n// ── fetchers ─────────────────────────────────────────────────────────────\n\n/** `GET /history` — paged. */\nexport function getHistory(\n client: W6WClient,\n scope: HistoryScope,\n f: HistoryFilters,\n limit: number = HISTORY_PAGE_SIZE,\n): Promise<{ executions: ExecutionSummary[]; hasMore: boolean }> {\n return client\n .request<{ executions: ExecutionSummary[]; hasMore: boolean }>({\n method: \"GET\",\n path: \"/history\",\n query: historyRequestQuery(scope, f, { paged: true, limit }),\n })\n .then((response) => response.body);\n}\n\n/** `GET /history/stats` — unpaged (no `limit`/`offset`). */\nexport function getHistoryStats(\n client: W6WClient,\n scope: HistoryScope,\n f: HistoryFilters,\n): Promise<ExecutionStats> {\n return client\n .request<{ stats: ExecutionStats }>({\n method: \"GET\",\n path: \"/history/stats\",\n query: historyRequestQuery(scope, f, { paged: false }),\n })\n .then((response) => response.body.stats);\n}\n\n/** One execution's full detail — the shape `ExecutionDetail` (`@w6w/ui`,\n * T2.2.2) renders. `steps` is present only for a workflow run; a\n * function/endpoint invocation has none. */\nexport interface ExecutionDetailData {\n id: string;\n kind: ExecutionKind;\n callableName: string;\n status: ExecutionStatus;\n startedAt: string;\n finishedAt: string | null;\n durationMs: number | null;\n input?: unknown;\n output?: unknown;\n error?: unknown;\n /** The execution this one re-runs, carried from its summary row. */\n rerunOf?: string | null;\n steps?: Array<{\n id: string;\n status: \"pending\" | \"running\" | \"succeeded\" | \"failed\" | \"skipped\";\n skipReason?: \"not_on_path\" | \"condition\" | \"stopped\" | \"disabled\";\n startedAt?: string;\n finishedAt?: string;\n input?: unknown;\n output?: unknown;\n node?: StepNode;\n }>;\n}\n\n/** What a workflow step IS (`@w6w/ui`'s `ExecutionLogNode`, restated locally — A1): the app and\n * action it uses, whether it is a trigger, and the app's display names when it is a registered app.\n * A built-in `@w6w/*` node carries ids only; the panel names those from its own catalog. */\nexport interface StepNode {\n app: string;\n action: string;\n trigger?: boolean;\n appName?: string;\n actionName?: string;\n}\n\n/** The slice of a definition node this module reads. */\ninterface DefinitionNode {\n id?: unknown;\n uses?: { app?: unknown; action?: unknown; trigger?: unknown };\n}\n\n/**\n * Every node of the workflow's CURRENT definition, keyed by id, as a {@link StepNode} — with the\n * display names of each registered app (`GET /apps/:id`'s `displayName` and action titles, plus\n * `GET /apps/:id/triggers` for an app a trigger node uses). Best-effort throughout: a definition\n * that cannot be read yields an empty map, and an app that cannot be read keeps its raw ids.\n */\nexport async function describeWorkflowNodes(\n client: W6WClient,\n workflowId: string,\n): Promise<Map<string, StepNode>> {\n const out = new Map<string, StepNode>();\n let nodes: DefinitionNode[];\n try {\n const { workflow } = await client.console.workflows.get(workflowId);\n nodes = Array.isArray(workflow.nodes) ? (workflow.nodes as DefinitionNode[]) : [];\n } catch {\n return out;\n }\n for (const n of nodes) {\n const app = n.uses?.app;\n const action = n.uses?.action;\n if (typeof n.id !== \"string\" || typeof app !== \"string\" || typeof action !== \"string\") continue;\n out.set(n.id, { app, action, ...(n.uses?.trigger === true ? { trigger: true } : {}) });\n }\n\n // Built-in `@w6w/*` ids are not served by `/apps/:id`; the panel names those itself.\n const registered = [...new Set([...out.values()].map((n) => n.app))].filter(\n (app) => !app.startsWith(\"@w6w/\"),\n );\n const names = await Promise.all(\n registered.map(async (app) => {\n const wantsTriggers = [...out.values()].some((n) => n.app === app && n.trigger);\n const [detail, triggers] = await Promise.all([\n client.console.apps.get(app).catch(() => null),\n wantsTriggers ? client.console.apps.getTriggers(app).catch(() => []) : Promise.resolve([]),\n ]);\n const titles = new Map<string, string>();\n for (const a of detail?.actions ?? []) titles.set(`a:${a.key}`, a.title);\n for (const t of triggers) titles.set(`t:${t.key}`, t.title);\n return { app, displayName: detail?.app.displayName, titles };\n }),\n );\n for (const node of out.values()) {\n const named = names.find((n) => n.app === node.app);\n if (!named) continue;\n if (named.displayName) node.appName = named.displayName;\n const title = named.titles.get(`${node.trigger ? \"t\" : \"a\"}:${node.action}`);\n if (title) node.actionName = title;\n }\n return out;\n}\n\n/** The `GET /invocations/:id` response body's shape this module reads\n * (context notes: server `db/repos/invocations.ts` `InvocationRow`). */\ninterface InvocationDetailBody {\n status: ExecutionStatus;\n input?: unknown;\n output?: unknown;\n error?: unknown;\n durationMs: number | null;\n startedAt: string;\n finishedAt: string | null;\n}\n\n/**\n * Expand a list row into its full detail. Function/Endpoint invocations are\n * synchronous calls recorded one row per call (`.claude/docs/invocations.md`)\n * — `GET /invocations/:id` by the escape-hatch `client.request` (no typed SDK\n * method exists for this internal route, same reasoning as\n * `repos/callables.ts`'s `archiveCallable`/`deleteCallable` split; A1: no\n * other runtime import needed). A workflow run instead reuses\n * `client.console.workflows.getRun` (`repos/workflows.ts`'s own\n * `getRunState`) — its `variables` become the detail's `input`, and its\n * opaque `steps` map through the SAME `mapRunStateToLogSteps` the live-run\n * overlay uses, so a historical run's step list renders identically to a\n * live one. `callableName` always comes from the summary — neither read\n * carries a human-readable callable name of its own.\n */\nexport async function getExecutionDetail(\n client: W6WClient,\n summary: ExecutionSummary,\n): Promise<ExecutionDetailData> {\n if (summary.kind === \"workflow\") {\n const [run, described] = await Promise.all([\n client.console.workflows.getRun(summary.id),\n describeWorkflowNodes(client, summary.callableId),\n ]);\n // What STARTED the run: the start payload (`input`), else the trigger's delivered `event` —\n // both ride `GET /runs/:id` beside the SDK's typed fields — else, for a run that had\n // neither, its variables.\n const started = run as unknown as { input?: unknown; event?: unknown };\n return {\n id: summary.id,\n kind: \"workflow\",\n callableName: summary.callableName,\n status: run.status,\n startedAt: summary.startedAt,\n finishedAt: summary.finishedAt,\n durationMs: summary.durationMs,\n input: started.input ?? started.event ?? run.variables,\n output: run.output,\n error: run.error,\n rerunOf: summary.rerunOf ?? null,\n steps: mapRunStateToLogSteps(runNodeMap(run)).map((step) => {\n const node = described.get(step.id);\n return node ? { ...step, node } : step;\n }),\n };\n }\n\n const response = await client.request<{ invocation: InvocationDetailBody }>({\n method: \"GET\",\n path: `/invocations/${encodeURIComponent(summary.id)}`,\n });\n const invocation = response.body.invocation;\n return {\n id: summary.id,\n kind: summary.kind,\n callableName: summary.callableName,\n status: invocation.status,\n startedAt: invocation.startedAt,\n finishedAt: invocation.finishedAt,\n durationMs: invocation.durationMs,\n input: invocation.input,\n output: invocation.output,\n error: invocation.error,\n rerunOf: summary.rerunOf ?? null,\n };\n}\n\n// ── re-run ───────────────────────────────────────────────────────────────\n\n/** The invocation id a FAILED invoke still minted: the server stamps its frame\n * onto the error body (`withInvocationFrame`), and `@w6w/sdk`'s `ApiError`\n * keeps that body as `raw`. Duck-typed so this module stays SDK-runtime-free. */\nfunction invocationIdOf(err: unknown): string | undefined {\n const raw = (err as { raw?: unknown } | null)?.raw;\n const id = (raw as { invocationId?: unknown } | null)?.invocationId;\n return typeof id === \"string\" ? id : undefined;\n}\n\n/** A plain object, or `{}` — a stored input that is not an object (or is\n * absent) cannot be an invoke body. */\nfunction asRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\n/** Start the new execution and return its id: the run id for a workflow (once\n * the run is terminal), the invocation id for a function/endpoint — also when\n * the call itself failed, since a failed call is still a recorded execution. */\nasync function startRerun(\n client: W6WClient,\n summary: ExecutionSummary,\n sleep?: (ms: number) => Promise<void>,\n): Promise<string> {\n const callable = encodeURIComponent(summary.callableId);\n\n if (summary.kind === \"workflow\") {\n // The SERVER replays the stored seed — trigger type, variables, start input, the trigger's\n // delivered `event`, entry node, partial-run spec. A client-side replay through\n // `POST /workflows/:id/run` cannot: that route has no slot for `event`, which is where an app\n // or webhook trigger's payload lives.\n const res = await client.request<{ runId: string }>({\n method: \"POST\",\n path: `/runs/${encodeURIComponent(summary.id)}/rerun`,\n body: { allowUnpublished: true },\n });\n const runId = res.body.runId;\n await pollRunToTerminal(() => client.console.workflows.getRun(runId), sleep);\n return runId;\n }\n\n const past = await client.request<{ invocation: InvocationDetailBody }>({\n method: \"GET\",\n path: `/invocations/${encodeURIComponent(summary.id)}`,\n });\n const input = asRecord(past.body.invocation.input);\n // `rerunOf` marks the new invocation as a re-run of this one (`invocations.rerun_of`).\n const body: Record<string, unknown> =\n summary.kind === \"function\"\n ? { inputs: input, allowUnpublished: true, rerunOf: summary.id }\n : { input, allowUnpublished: true, rerunOf: summary.id };\n try {\n const res = await client.request<{ invocationId?: string }>({\n method: \"POST\",\n path: `/${summary.kind === \"function\" ? \"functions\" : \"endpoints\"}/${callable}/invoke`,\n body,\n });\n const id = res.body.invocationId;\n if (typeof id !== \"string\") throw new Error(\"The server did not return an invocation id.\");\n return id;\n } catch (err) {\n const id = invocationIdOf(err);\n if (id === undefined) throw err;\n return id;\n }\n}\n\n/**\n * Run a past execution again with the input it had, against the callable's\n * CURRENT definition (the stored draft — `allowUnpublished`, as the editor's\n * own Run and Test do), and return the new execution's summary row so the\n * host can open it. A workflow is replayed by the server from its stored seed\n * (`POST /runs/:id/rerun`, trigger payload included); a function replays its\n * `inputs`; an endpoint its `input`. `null` when the new row is not yet listed (the host then just\n * shows the refreshed list).\n */\nexport async function rerunExecution(\n client: W6WClient,\n summary: ExecutionSummary,\n opts: { sleep?: (ms: number) => Promise<void> } = {},\n): Promise<ExecutionSummary | null> {\n const id = await startRerun(client, summary, opts.sleep);\n return findExecution(client, summary.callableId, id);\n}\n\n/** One callable's execution by id, as its summary row (`GET /history`'s id search), or `null`\n * when it is not listed — e.g. the original a re-run names, once retention removed it. */\nexport async function findExecution(\n client: W6WClient,\n callableId: string,\n id: string,\n): Promise<ExecutionSummary | null> {\n const found = await getHistory(\n client,\n { callable: callableId },\n { ...EMPTY_HISTORY_FILTERS, q: id },\n 1,\n );\n return found.executions.find((row) => row.id === id) ?? null;\n}\n","import {\n type UseMutationResult,\n useMutation,\n useQuery,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport type { StateLogRow } from \"@w6w/expr\";\nimport { path } from \"@w6w/sdk\";\nimport type { RunStatus, W6WClient, WorkflowRunResult } from \"@w6w/sdk\";\nimport type { RunState } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { shouldContinuePolling } from \"../lib/workflow-live-run.ts\";\nimport { pollRunToTerminal } from \"../lib/workflow-poll.ts\";\n\nexport type { RunState, RunSummary } from \"@w6w/sdk/console\";\nexport type { WorkflowStatus, WorkflowSummary } from \"@w6w/sdk\";\n\n// `project` distinguishes a project-scoped entry (WorkflowsPage.tsx) from the\n// unscoped one (TargetSelector.tsx, SubscriptionsPage.tsx) — genuinely DIFFERENT\n// queries (not a spelling split to unify like T2.2.2's appActions fix). Keep them\n// as distinct cache entries.\nexport const workflowsKey = (project?: string) => [\"workflows\", project] as const;\n\nexport function listWorkflows(client: W6WClient, project?: string) {\n return client.workflows.list({ project });\n}\n\nexport function useWorkflowsQuery(project?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: workflowsKey(project),\n queryFn: () => listWorkflows(apiClient, project),\n enabled,\n });\n}\n\nexport const workflowKey = (id: string) => [\"workflow\", id] as const;\n\nexport function getWorkflow(client: W6WClient, id: string) {\n return client.workflows.get(id);\n}\n\nexport function useWorkflowQuery(id: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: workflowKey(id),\n queryFn: () => getWorkflow(apiClient, id),\n enabled,\n });\n}\n\n/**\n * A missing `project` here is not \"unscoped\" the way a read can legitimately\n * be — the write would silently land in the account's default project\n * instead of the one the caller is looking at. Both mutations refuse rather\n * than risk that; `WorkflowsPage.tsx`'s own `projectId != null` gate on\n * `useWorkflowsQuery` should mean `project` is always set by the time either\n * of these can actually be invoked from the UI, but the guard costs nothing.\n */\nexport function useCreateWorkflowMutation(project?: string) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (definition: unknown) => {\n if (!project) return Promise.reject(new Error(\"No project selected yet.\"));\n return apiClient.console.workflows.upsert(definition, { project });\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"workflows\"] }),\n });\n}\n\nexport function useSaveWorkflowMutation(project?: string) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { definition: unknown; ifUnmodifiedSince: string | null }) => {\n if (!project) return Promise.reject(new Error(\"No project selected yet.\"));\n return apiClient.console.workflows.upsert(vars.definition, {\n project,\n ifUnmodifiedSince: vars.ifUnmodifiedSince,\n });\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"workflows\"] }),\n });\n}\n\nexport function useArchiveWorkflowMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => apiClient.workflows.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"workflows\"] }),\n });\n}\n\nexport function useDeleteWorkflowMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => apiClient.workflows.delete(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"workflows\"] }),\n });\n}\n\nexport const runsKey = (workflowId: string) => [\"runs\", workflowId] as const;\n\nexport function useRunsQuery(workflowId: string) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: runsKey(workflowId),\n queryFn: () => apiClient.console.workflows.listRuns(workflowId),\n });\n}\n\n/**\n * Start a run and poll it to a terminal state.\n *\n * `input` is the run's START PAYLOAD, and it is a different thing from\n * `variables`: the server hands it to the entry `@w6w/trigger` node as that\n * node's own output, which is what makes `{{ steps.<trigger>.output.<field> }}`\n * resolve in a real run. Omitted, that node outputs `{}` and every reference to\n * a trigger field resolves to the empty string — the failure mode filed as\n * `.ai/projects/backlog/26-07-29-01-trigger-run-payload.md`, where a step tests\n * green and then does nothing in production. `variables` seeds `var.*` and\n * reaches the trigger node not at all.\n *\n * Goes through the typed `client.workflows.run()` with\n * `allowUnpublished: true`: this call site always runs the STORED draft, and\n * the server exempts a caller that sets the flag from the publish gate\n * (`packages/api/run-workflow.ts`'s `enqueueRun`). The SDK's result is the flat\n * run body, so the `runId` used to poll comes off `res.runId`.\n */\nexport function runWorkflow(\n client: W6WClient,\n id: string,\n variables: Record<string, unknown>,\n input?: Record<string, unknown>,\n): Promise<RunState> {\n return client.workflows\n .run(id, { variables, input, allowUnpublished: true })\n .then((res) => pollRunToTerminal(() => client.console.workflows.getRun(res.runId)));\n}\n\nexport function useRunWorkflowMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: {\n id: string;\n variables: Record<string, unknown>;\n input?: Record<string, unknown>;\n }) => runWorkflow(apiClient, vars.id, vars.variables, vars.input),\n onSuccess: (_res, vars) => qc.invalidateQueries({ queryKey: runsKey(vars.id) }),\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n\n/**\n * Run a Workflow SYNCHRONOUSLY — the `W6WApi.runWorkflow` facade member's\n * backing function (the Workflows tab's Test stage, D-11/D-15(c)). A sibling\n * of {@link runWorkflow}, NOT a replacement: that function's enqueue-then-poll\n * shape is the studio-wide \"Run this workflow\" action and stays exactly as it\n * is. This one instead sends `wait: true` on the SAME base `client.workflows\n * .run` call already published (`?wait=true` — the server polls internally,\n * up to its own timeout) — zero new server code, and no second poll loop:\n * there is no `pollRunToTerminal` here at all. `terminal`/`httpStatus` on the\n * result distinguish \"finished in time\" (`200`) from \"still going when the\n * server's own wait timed out\" (`202`, a legitimate outcome, not an error).\n */\nexport function runWorkflowSync(\n client: W6WClient,\n id: string,\n variables: Record<string, unknown>,\n input?: Record<string, unknown>,\n entry?: string,\n): Promise<WorkflowRunResult> {\n return client.workflows.run(id, { variables, input, entry, wait: true });\n}\n\n/**\n * T2.1.1 — the ENQUEUE half only: starts a run and returns its handle\n * immediately, without polling it to terminal. A genuine sibling of\n * {@link runWorkflow}, NOT a replacement — that function's \"enqueue, then\n * block to a terminal result\" shape is what `WorkflowDetailPage.tsx`'s \"Run\n * now\" panel is built on and stays exactly as it is. This one is for a host\n * that wants the `runId` right away so it can poll it live itself (the\n * visual editor's canvas + execution log panel) — see {@link useLiveRunQuery}.\n *\n * Like {@link runWorkflow}, this calls `client.workflows.run()` with\n * `allowUnpublished: true` unconditionally. Only `{ runId }` is returned, so\n * callers keep reading `runId` off the resolved value exactly as before.\n */\nexport function startWorkflowRun(\n client: W6WClient,\n id: string,\n variables: Record<string, unknown>,\n input?: Record<string, unknown>,\n) {\n return client.workflows\n .run(id, { variables, input, allowUnpublished: true })\n .then((res) => ({ runId: res.runId }));\n}\n\n/** What {@link startRunFromNode} sends: the paused nodes to stop before, and the start seed. */\nexport interface RunFromNodeBody {\n /** Node ids the run stops BEFORE (they do not execute) — the editor's paused nodes. */\n stopAt: string[];\n /** Upstream outputs keyed by node id, seeded from saved step tests / the last run. */\n nodes?: Record<string, { output?: unknown; meta?: unknown }>;\n /** The trigger's filled values, when the run starts at a trigger node. */\n input?: Record<string, unknown>;\n}\n\n/**\n * Run from a node — `POST /workflows/:id/nodes/:nodeId/run` with `continue: true`: a REAL run\n * that executes `nodeId`, continues through every node downstream of it the way a run follows\n * its edges, and stops before each `stopAt` node. Answers `202 { runId }` at once, like\n * {@link startWorkflowRun}, so the caller polls it live ({@link useLiveRunQuery}). The run\n * executes the STORED definition, so a caller flushes its draft first.\n *\n * The plain `client.request()` escape hatch, not a typed `@w6w/sdk` method: the route is a\n * console authoring aid, and a typed method would pull `packages/wrappers` (every language, in\n * lockstep) into an editor-only change.\n */\nexport async function startRunFromNode(\n client: W6WClient,\n id: string,\n nodeId: string,\n body: RunFromNodeBody,\n): Promise<{ runId: string }> {\n const res = await client.request<{ runId: string }>({\n method: \"POST\",\n path: path`/workflows/${id}/nodes/${nodeId}/run`,\n body: {\n continue: true,\n stopAt: body.stopAt,\n ...(body.nodes ? { state: { nodes: body.nodes } } : {}),\n ...(body.input ? { input: body.input } : {}),\n },\n });\n return { runId: res.body.runId };\n}\n\n/** A node output's structural shape, as the server records it (structural mirror of `@w6w/ui`'s). */\nexport type NodeSampleShape =\n | { type: \"string\" | \"number\" | \"boolean\" | \"null\" | \"unknown\" }\n | { type: \"object\"; fields: Record<string, NodeSampleShape> }\n | { type: \"array\"; items?: NodeSampleShape };\n\n/**\n * One persisted node sample — structural mirror of `@w6w/ui`'s `NodeSample` (this barrel may not\n * import `@w6w/ui`; the facade/UiBridge assignment typechecks against `W6WApi` structurally).\n */\nexport interface NodeSample {\n nodeId: string;\n shape: NodeSampleShape;\n sample?: unknown;\n sampleOmitted?: true;\n source: \"step_test\" | \"node_run\" | \"run\";\n runId?: string;\n updatedAt: string;\n}\n\n/**\n * The workflow's persisted node samples — `GET /workflows/:id/node-samples` → `{ nodeSamples }`:\n * each node's last output shape (and value, when kept), written server-side on every Test, node\n * run and run. Backs `W6WApi.loadNodeSamples`, so the editor's picker keeps upstream keys across a\n * reload. The plain `client.request()` escape hatch, for the same reason as {@link startRunFromNode}.\n */\nexport function listNodeSamples(client: W6WClient, id: string): Promise<NodeSample[]> {\n return client\n .request<{ nodeSamples?: NodeSample[] }>({\n method: \"GET\",\n path: path`/workflows/${id}/node-samples`,\n })\n .then((res) => res.body.nodeSamples ?? []);\n}\n\n/** One remembered node test input — structural mirror of `@w6w/ui`'s `NodeTestInput`. */\nexport interface NodeTestInput {\n nodeId: string;\n input: Record<string, unknown>;\n updatedAt: string;\n}\n\n/**\n * The test input each node of the workflow last ran with in the editor —\n * `GET /workflows/:id/test-inputs` → `{ testInputs }` (`node_test_inputs`, 0160). Backs\n * `W6WApi.loadTestInputs`, so the Run node modal, the Test tabs and the header Run reopen\n * prefilled. The plain `client.request()` escape hatch, for the same reason as {@link startRunFromNode}.\n */\nexport function listTestInputs(client: W6WClient, id: string): Promise<NodeTestInput[]> {\n return client\n .request<{ testInputs?: NodeTestInput[] }>({\n method: \"GET\",\n path: path`/workflows/${id}/test-inputs`,\n })\n .then((res) => res.body.testInputs ?? []);\n}\n\n/**\n * Remember a node's test input (`{}` clears it) — `PUT /workflows/:id/nodes/:nodeId/test-input`.\n * Backs `W6WApi.saveTestInput`; the server drops sealed envelopes before the write.\n */\nexport function saveTestInput(\n client: W6WClient,\n id: string,\n nodeId: string,\n input: Record<string, unknown>,\n): Promise<void> {\n return client\n .request<{ ok: boolean }>({\n method: \"PUT\",\n path: path`/workflows/${id}/nodes/${nodeId}/test-input`,\n body: { input },\n })\n .then(() => undefined);\n}\n\nexport function useRunFromNodeMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; nodeId: string; body: RunFromNodeBody }) =>\n startRunFromNode(apiClient, vars.id, vars.nodeId, vars.body),\n onSuccess: (_res, vars) => qc.invalidateQueries({ queryKey: runsKey(vars.id) }),\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n\nexport function useStartRunMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: {\n id: string;\n variables: Record<string, unknown>;\n input?: Record<string, unknown>;\n }) => startWorkflowRun(apiClient, vars.id, vars.variables, vars.input),\n onSuccess: (_res, vars) => qc.invalidateQueries({ queryKey: runsKey(vars.id) }),\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n\n/** What `client.workflows.cancel` resolves to. Named here because the SDK's root entry does not\n * export its `WorkflowCancelResult`: an inferred return type would name it and `vite-plugin-dts`\n * would skip this whole file (TS2742), leaving every `./repos` declaration out of the tarball. */\nexport type WorkflowCancelResult = Awaited<ReturnType<W6WClient[\"workflows\"][\"cancel\"]>>;\n\n/**\n * T2.1.1/A6 — cancel a queued or running run. `client.workflows.cancel`\n * itself never claims the run has stopped (its own doc comment: a `202`\n * means the request was RECORDED, not that the run finished) — the caller\n * keeps polling {@link useLiveRunQuery} until the run actually reaches a\n * terminal status. See `../lib/workflow-live-run.ts`'s `classifyCancelError`\n * for how a `409 run_not_cancelable` (the run beat the cancel to the finish\n * line) is told apart from a real failure.\n */\nexport function cancelWorkflowRun(client: W6WClient, runId: string): Promise<WorkflowCancelResult> {\n return client.workflows.cancel(runId);\n}\n\nexport function useCancelRunMutation(): UseMutationResult<WorkflowCancelResult, Error, string> {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: (runId: string) => cancelWorkflowRun(apiClient, runId),\n });\n}\n\n/** The single-shot half of {@link useLiveRunQuery} — a thin, directly\n * testable wrapper around `client.console.workflows.getRun`, so the polling\n * config below can be pinned without needing to render a hook. */\nexport function getRunState(client: W6WClient, runId: string): Promise<RunState> {\n return client.console.workflows.getRun(runId);\n}\n\n/** Query key for one run's live state — distinct from {@link runsKey}, which\n * is the workflow's run LIST. */\nexport const runStateKey = (runId: string) => [\"run\", runId] as const;\n\n/**\n * T2.1.1/A2/A3 — poll one run's live state at a fixed 500ms interval,\n * stopping once it reaches a terminal status ({@link shouldContinuePolling},\n * `../lib/workflow-live-run.ts`). A genuine sibling of `pollRunToTerminal`\n * (`../lib/workflow-poll.ts`) using the SAME underlying SDK call\n * (`client.console.workflows.getRun`), but publishing every intermediate\n * `RunState` to its caller via TanStack Query's own `data` — unlike\n * `pollRunToTerminal`, which discards every non-terminal result and hands\n * back only the last one. `runId === null` disables the query entirely (no\n * run started yet, or the page navigated to a different workflow).\n */\nexport function useLiveRunQuery(runId: string | null) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: runStateKey(runId ?? \"\"),\n queryFn: () => getRunState(apiClient, runId as string),\n enabled: runId != null,\n refetchInterval: (query) => (shouldContinuePolling(query.state.data?.status) ? 500 : false),\n });\n}\n\n/** `GET /runs/:id/state-writes` — the run's state-write log (plan §2.4). */\nexport interface RunStateWrites {\n writes: StateLogRow[];\n truncated: boolean;\n}\n\n/**\n * One run's state-write log, read for the run log's State block (\"state after this\n * step\"). The plain `client.request()` escape hatch, for the same reason as\n * {@link listNodeSamples}: the route has no typed `@w6w/sdk` method.\n */\nexport function getRunStateWrites(client: W6WClient, runId: string): Promise<RunStateWrites> {\n return client\n .request<{ writes?: StateLogRow[]; truncated?: boolean }>({\n method: \"GET\",\n path: path`/runs/${runId}/state-writes`,\n })\n .then((res) => ({ writes: res.body.writes ?? [], truncated: res.body.truncated === true }));\n}\n\n/** Query key for one run's state-write log. The last segment flips from `\"live\"` to\n * `\"final\"` when the run turns terminal, so the final log is fetched exactly once more. */\nexport function runStateWritesKey(runId: string, status: RunStatus | undefined) {\n return [\"run\", runId, \"state-writes\", shouldContinuePolling(status) ? \"live\" : \"final\"] as const;\n}\n\n/**\n * Poll one run's state-write log beside {@link useLiveRunQuery}: the same 500ms cadence\n * while the run (as `status`, the live run query's answer) is in flight, no polling once\n * terminal. `retry: false` — a failed read only leaves the run log without its State\n * block; it never touches the run poll.\n */\nexport function useRunStateWritesQuery(runId: string | null, status: RunStatus | undefined) {\n const apiClient = useEmbedClient();\n const live = shouldContinuePolling(status);\n return useQuery({\n queryKey: runStateWritesKey(runId ?? \"\", status),\n queryFn: () => getRunStateWrites(apiClient, runId as string),\n enabled: runId != null,\n refetchInterval: live ? 500 : false,\n retry: false,\n });\n}\n"],"names":["runNodeMap","run","STEP_FAILED_NO_REASON","RUN_FAILED_NO_REASON","shouldContinuePolling","status","isTerminalRunStatus","isRunInFlight","pollFailed","STEP_PASS_REFRESH_DELAYS_MS","stepPassRefreshDue","runWorkflowId","workflowId","runButtonLabel","classifyCancelError","code","mapRunStateToLogSteps","steps","stateLog","state","stateFieldsByNode","id","step","mapStep","iterationFields","log","rows","a","b","byNode","row","entry","group","out","writes","lastSeq","foldStateLog","SKIP_REASONS","line","rowError","ITERATION_STATUSES","iterations","it","nodes","s","failedNodeId","_a","finite","n","error","toLogError","raw","o","message","safeJson","runLevelErrors","carried","r","reasoned","stepErrors","e","own","sameAsOwn","runError","latestFixtureInput","tests","last","resolveHeaderRunInput","triggerStepId","list","remembered","input","headerRunEntry","isManualTrigger","isEntryTrigger","manual","other","TERMINAL","realSleep","ms","resolve","pollRunToTerminal","getRun","sleep","i","EMPTY_HISTORY_FILTERS","HISTORY_PAGE_SIZE","VALID_STATUSES","VALID_KINDS","DATE_RE","isRealDate","y","m","d","dateParts","dt","value","filtersFromSearch","search","params","kind","from","to","q","offsetRaw","offset","filtersToSearch","f","historyRequestQuery","scope","opts","query","historyKeys","limit","callableId","getHistory","client","response","getHistoryStats","describeWorkflowNodes","workflow","app","action","_b","_c","registered","names","wantsTriggers","detail","triggers","titles","t","node","named","title","getExecutionDetail","summary","described","started","invocation","invocationIdOf","err","asRecord","startRerun","callable","runId","past","body","rerunExecution","findExecution","workflowsKey","project","listWorkflows","useWorkflowsQuery","enabled","apiClient","useEmbedClient","useQuery","workflowKey","getWorkflow","useWorkflowQuery","useCreateWorkflowMutation","qc","useQueryClient","useMutation","definition","useSaveWorkflowMutation","vars","useArchiveWorkflowMutation","useDeleteWorkflowMutation","runsKey","useRunsQuery","runWorkflow","variables","res","useRunWorkflowMutation","_res","runWorkflowSync","startWorkflowRun","startRunFromNode","nodeId","path","listNodeSamples","listTestInputs","saveTestInput","useRunFromNodeMutation","useStartRunMutation","cancelWorkflowRun","useCancelRunMutation","getRunState","runStateKey","useLiveRunQuery","getRunStateWrites","runStateWritesKey","useRunStateWritesQuery","live"],"mappings":";;;;AA6FO,SAASA,EACdC,GAC+C;AAC/C,UAAQA,KAAA,gBAAAA,EAAK,WAASA,KAAA,gBAAAA,EAAK,UAAS;AACtC;AASO,MAAMC,IAAwB,2CAGxBC,IAAuB;AAuD7B,SAASC,EAAsBC,GAAwC;AAC5E,SAAOA,MAAW,UAAa,CAACC,EAAoBD,CAAM;AAC5D;AAYO,SAASE,EAAcF,GAA+BG,GAA8B;AAEzF,SADIA,KACAH,MAAW,SAAkB,KAC1B,CAACC,EAAoBD,CAAM;AACpC;AASO,MAAMI,KAAiD,CAAC,GAAG,IAAI;AAQ/D,SAASC,GACdL,GACAM,GACAC,GACS;AACT,SAAOP,MAAW,UAAaC,EAAoBD,CAAM,KAAKM,MAAkBC;AAClF;AAGO,SAASC,GAAeR,GAA+BG,GAA6B;AACzF,SAAKD,EAAcF,GAAQG,CAAU,IAC9BH,MAAW,WAAW,YAAY,aADM;AAEjD;AASO,SAASS,GAAoBC,GAAkC;AACpE,SAAOA,MAAS,uBAAuB,cAAc;AACvD;AAQO,SAASC,EACdC,GACAC,GACwB;AACxB,MAAI,CAACD,EAAO,QAAO,CAAA;AACnB,QAAME,IAAQD,IAAWE,EAAkBF,CAAQ,IAAI;AACvD,SAAO,OAAO,QAAQD,CAAK,EAAE,IAAI,CAAC,CAACI,GAAIC,CAAI,OAAO;AAAA,IAChD,GAAGC,EAAQF,GAAIC,CAA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