@loopstack/loopstack-studio 0.35.1 → 0.37.0

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 (43) hide show
  1. package/dist/features/documents/DocumentRenderer.js +7 -7
  2. package/dist/features/documents/renderers/DocumentFormRenderer.js +1 -1
  3. package/dist/features/documents/renderers/DocumentMessageRenderer.js +23 -9
  4. package/dist/features/documents/renderers/LlmMessage.js +90 -50
  5. package/dist/features/file-explorer/components/FileExplorerPanel.js +66 -73
  6. package/dist/features/file-explorer/hooks/useFileExplorer.js +29 -25
  7. package/dist/features/file-explorer/providers/FileExplorerProvider.js +53 -53
  8. package/dist/features/git/components/WorkbenchGitPanel.js +36 -33
  9. package/dist/features/git/hooks/useGit.js +36 -33
  10. package/dist/features/oauth/OAuthCallbackPage.js +2 -0
  11. package/dist/features/run-view/RunView.js +153 -0
  12. package/dist/features/run-view/Transcript.js +127 -0
  13. package/dist/features/run-view/prompts/FormPrompt.js +129 -0
  14. package/dist/features/run-view/prompts/OAuthPrompt.js +94 -0
  15. package/dist/features/run-view/prompts/SandboxRunButton.js +35 -0
  16. package/dist/features/run-view/prompts/SecretPrompt.js +69 -0
  17. package/dist/features/run-view/prompts/SimplePrompts.js +196 -0
  18. package/dist/features/run-view/prompts/cards.js +90 -0
  19. package/dist/features/run-view/prompts/registry.js +16 -0
  20. package/dist/features/run-view/transcript.js +24 -0
  21. package/dist/features/run-view/useRunPrompts.js +111 -0
  22. package/dist/features/run-view/useRunTree.js +59 -0
  23. package/dist/features/run-view/useTreeLlmStreams.js +91 -0
  24. package/dist/features/secrets/components/WorkbenchSecretsPanel.js +1 -1
  25. package/dist/features/secrets/renderers/SecretInputRenderer.js +1 -1
  26. package/dist/features/workbench/WorkflowList.js +111 -52
  27. package/dist/features/workbench/components/EnvironmentSelector.js +46 -0
  28. package/dist/features/workbench/components/NewRunDialog.js +1 -1
  29. package/dist/features/workbench/index.js +1 -1
  30. package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +68 -56
  31. package/dist/features/workspaces/components/WorkspaceHomePage.js +1 -1
  32. package/dist/index.d.ts +2 -0
  33. package/dist/node_modules/dompurify/dist/purify.es.js +351 -228
  34. package/dist/packages/client/dist/resources/workflows.js +2 -1
  35. package/dist/packages/client/dist/stream/invalidations.js +9 -2
  36. package/dist/packages/client/dist/stream/stream.js +73 -28
  37. package/dist/packages/contracts/dist/park-view/index.js +2 -0
  38. package/dist/packages/contracts/dist/park-view/park-view.rules.js +102 -0
  39. package/dist/packages/contracts/dist/park-view/park-view.types.js +15 -0
  40. package/dist/packages/contracts/dist/types/types/ui-message.type.js +15 -2
  41. package/dist/pages/PreviewWorkbenchPage.js +23 -23
  42. package/dist/providers/StudioPreferencesProvider.js +2 -1
  43. package/package.json +4 -4
@@ -0,0 +1,129 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { Checkbox } from "../../../components/ui/checkbox.js";
3
+ import { Input } from "../../../components/ui/input.js";
4
+ import { Label } from "../../../components/ui/label.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { useMemo, useState } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ function FormPrompt(l) {
9
+ let d = c(47), { view: f, submit: p, isSubmitting: m } = l, h = f.schema, g;
10
+ d[0] === h?.properties ? g = d[1] : (g = h?.properties ?? {}, d[0] = h?.properties, d[1] = g);
11
+ let _ = g, v;
12
+ d[2] === f.options?.properties ? v = d[3] : (v = f.options?.properties ?? {}, d[2] = f.options?.properties, d[3] = v);
13
+ let y = v, b;
14
+ d[4] === f.content ? b = d[5] : (b = f.content ?? {}, d[4] = f.content, d[5] = b);
15
+ let x = b, S;
16
+ d[6] !== x || d[7] !== _ ? (S = () => {
17
+ let e = { ...x };
18
+ for (let [a, o] of Object.entries(_)) e[a] === void 0 && o.default !== void 0 && (e[a] = o.default);
19
+ return e;
20
+ }, d[6] = x, d[7] = _, d[8] = S) : S = d[8];
21
+ let [C, w] = useState(S), T, E, D, O, k, A;
22
+ if (d[9] !== x || d[10] !== m || d[11] !== _ || d[12] !== p || d[13] !== y || d[14] !== C || d[15] !== f.options?.actions || d[16] !== f.transitions) {
23
+ T = Symbol.for("react.early_return_sentinel");
24
+ bb0: {
25
+ let s;
26
+ d[23] === f.transitions ? s = d[24] : (s = (e) => e.transition && f.transitions.includes(e.transition), d[23] = f.transitions, d[24] = s);
27
+ let l = (f.options?.actions ?? []).filter(s);
28
+ if (l.length === 0) {
29
+ T = null;
30
+ break bb0;
31
+ }
32
+ let u;
33
+ d[25] !== _ || d[26] !== y ? (u = (e) => (y[e]?.readonly ?? _[e]?.readonly) === !0, d[25] = _, d[26] = y, d[27] = u) : u = d[27];
34
+ let h = u, g;
35
+ d[28] === Symbol.for("react.memo_cache_sentinel") ? (g = (e, a) => w((o) => ({
36
+ ...o,
37
+ [e]: a
38
+ })), d[28] = g) : g = d[28];
39
+ let v = g, b = typeof x.markdown == "string" ? x.markdown : void 0;
40
+ if (d[29] !== h || d[30] !== m || d[31] !== b || d[32] !== _ || d[33] !== C) {
41
+ let e = Object.keys(_).filter(_temp);
42
+ O = "space-y-3", d[37] === b ? k = d[38] : (k = b && /* @__PURE__ */ jsx("p", {
43
+ className: "text-sm whitespace-pre-wrap",
44
+ children: b
45
+ }), d[37] = b, d[38] = k), A = e.map((e) => {
46
+ let s = _[e], l = C[e], u = m || h(e), d = s.title ?? e;
47
+ return s.type === "boolean" ? /* @__PURE__ */ jsxs("div", {
48
+ className: "flex items-center gap-2",
49
+ children: [/* @__PURE__ */ jsx(Checkbox, {
50
+ id: `form-${e}`,
51
+ checked: l === !0,
52
+ onCheckedChange: (a) => v(e, a === !0),
53
+ disabled: u
54
+ }), /* @__PURE__ */ jsx(Label, {
55
+ htmlFor: `form-${e}`,
56
+ children: d
57
+ })]
58
+ }, e) : s.type === "number" || s.type === "integer" ? /* @__PURE__ */ jsxs("div", {
59
+ className: "space-y-1",
60
+ children: [/* @__PURE__ */ jsx(Label, {
61
+ htmlFor: `form-${e}`,
62
+ children: d
63
+ }), /* @__PURE__ */ jsx(Input, {
64
+ id: `form-${e}`,
65
+ type: "number",
66
+ value: typeof l == "number" ? l : "",
67
+ onChange: (a) => v(e, a.target.value === "" ? void 0 : Number(a.target.value)),
68
+ disabled: u
69
+ })]
70
+ }, e) : s.type === "string" || l === void 0 || typeof l == "string" ? /* @__PURE__ */ jsxs("div", {
71
+ className: "space-y-1",
72
+ children: [/* @__PURE__ */ jsx(Label, {
73
+ htmlFor: `form-${e}`,
74
+ children: d
75
+ }), /* @__PURE__ */ jsx(Input, {
76
+ id: `form-${e}`,
77
+ value: typeof l == "string" ? l : "",
78
+ onChange: (a) => v(e, a.target.value),
79
+ disabled: u
80
+ })]
81
+ }, e) : /* @__PURE__ */ jsxs("div", {
82
+ className: "space-y-1",
83
+ children: [/* @__PURE__ */ jsxs(Label, {
84
+ htmlFor: `form-${e}`,
85
+ children: [d, " (JSON)"]
86
+ }), /* @__PURE__ */ jsx("textarea", {
87
+ id: `form-${e}`,
88
+ className: "border-input w-full rounded-md border bg-transparent p-2 font-mono text-sm",
89
+ rows: 4,
90
+ defaultValue: JSON.stringify(l, null, 2),
91
+ onChange: (a) => {
92
+ try {
93
+ v(e, JSON.parse(a.target.value));
94
+ } catch {}
95
+ },
96
+ disabled: u
97
+ })]
98
+ }, e);
99
+ }), d[29] = h, d[30] = m, d[31] = b, d[32] = _, d[33] = C, d[34] = O, d[35] = k, d[36] = A;
100
+ } else O = d[34], k = d[35], A = d[36];
101
+ E = "flex gap-2", D = l.map((a) => /* @__PURE__ */ jsx(Button, {
102
+ onClick: () => p(C, a.transition),
103
+ disabled: m,
104
+ variant: a === l[0] ? "default" : "outline",
105
+ children: a.label ?? a.transition
106
+ }, a.transition));
107
+ }
108
+ d[9] = x, d[10] = m, d[11] = _, d[12] = p, d[13] = y, d[14] = C, d[15] = f.options?.actions, d[16] = f.transitions, d[17] = T, d[18] = E, d[19] = D, d[20] = O, d[21] = k, d[22] = A;
109
+ } else T = d[17], E = d[18], D = d[19], O = d[20], k = d[21], A = d[22];
110
+ if (T !== Symbol.for("react.early_return_sentinel")) return T;
111
+ let j;
112
+ d[39] !== E || d[40] !== D ? (j = /* @__PURE__ */ jsx("div", {
113
+ className: E,
114
+ children: D
115
+ }), d[39] = E, d[40] = D, d[41] = j) : j = d[41];
116
+ let M;
117
+ return d[42] !== j || d[43] !== O || d[44] !== k || d[45] !== A ? (M = /* @__PURE__ */ jsxs("div", {
118
+ className: O,
119
+ children: [
120
+ k,
121
+ A,
122
+ j
123
+ ]
124
+ }), d[42] = j, d[43] = O, d[44] = k, d[45] = A, d[46] = M) : M = d[46], M;
125
+ }
126
+ function _temp(e) {
127
+ return e !== "markdown";
128
+ }
129
+ export { FormPrompt };
@@ -0,0 +1,94 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { useOAuthPopup } from "../../oauth/useOAuthPopup.js";
3
+ import "../../oauth/index.js";
4
+ import { c } from "react/compiler-runtime";
5
+ import { useCallback, useEffect, useRef } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { AlertCircle, CheckCircle2, ExternalLink, Loader2 } from "lucide-react";
8
+ function providerLabel(r) {
9
+ return r ? r.charAt(0).toUpperCase() + r.slice(1) : "Provider";
10
+ }
11
+ function OAuthPrompt(f) {
12
+ let m = c(41), { view: h, submit: g, isSubmitting: _ } = f, v;
13
+ m[0] === h.content ? v = m[1] : (v = h.content ?? {}, m[0] = h.content, m[1] = v);
14
+ let y = v, { result: b, open: x, reset: S } = useOAuthPopup(), C = useRef(!1), w;
15
+ m[2] === y.provider ? w = m[3] : (w = providerLabel(y.provider), m[2] = y.provider, m[3] = w);
16
+ let T = w, E;
17
+ m[4] !== y.authUrl || m[5] !== y.state || m[6] !== x || m[7] !== S ? (E = () => {
18
+ !y.authUrl || !y.state || (C.current = !1, S(), x({
19
+ authUrl: y.authUrl,
20
+ state: y.state
21
+ }));
22
+ }, m[4] = y.authUrl, m[5] = y.state, m[6] = x, m[7] = S, m[8] = E) : E = m[8];
23
+ let D = E, O;
24
+ m[9] !== b.code || m[10] !== b.state || m[11] !== b.status || m[12] !== g ? (O = () => {
25
+ b.status === "success" && !C.current && (C.current = !0, g({
26
+ code: b.code,
27
+ state: b.state
28
+ }));
29
+ }, m[9] = b.code, m[10] = b.state, m[11] = b.status, m[12] = g, m[13] = O) : O = m[13];
30
+ let k;
31
+ if (m[14] !== b || m[15] !== g ? (k = [b, g], m[14] = b, m[15] = g, m[16] = k) : k = m[16], useEffect(O, k), y.status === "success") {
32
+ let r;
33
+ m[17] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4 text-green-600" }), m[17] = r) : r = m[17];
34
+ let u;
35
+ return m[18] === T ? u = m[19] : (u = /* @__PURE__ */ jsxs("p", {
36
+ className: "flex items-center gap-2 text-sm",
37
+ children: [
38
+ r,
39
+ " Connected to ",
40
+ T,
41
+ "."
42
+ ]
43
+ }), m[18] = T, m[19] = u), u;
44
+ }
45
+ let A = y.status === "error" ? y.message ?? `Signing in to ${T} failed.` : b.status === "error" ? b.error : b.status === "timeout" ? "The sign-in timed out." : b.status === "blocked" ? "The popup was blocked — allow popups and retry." : void 0;
46
+ if (A) {
47
+ let u;
48
+ m[20] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ jsx(AlertCircle, { className: "text-destructive h-4 w-4" }), m[20] = u) : u = m[20];
49
+ let d;
50
+ m[21] === A ? d = m[22] : (d = /* @__PURE__ */ jsxs("p", {
51
+ className: "flex items-center gap-2 text-sm",
52
+ children: [u, A]
53
+ }), m[21] = A, m[22] = d);
54
+ let f;
55
+ m[23] !== _ || m[24] !== D ? (f = /* @__PURE__ */ jsx(Button, {
56
+ variant: "outline",
57
+ onClick: D,
58
+ disabled: _,
59
+ children: "Retry"
60
+ }), m[23] = _, m[24] = D, m[25] = f) : f = m[25];
61
+ let p;
62
+ return m[26] !== d || m[27] !== f ? (p = /* @__PURE__ */ jsxs("div", {
63
+ className: "space-y-2",
64
+ children: [d, f]
65
+ }), m[26] = d, m[27] = f, m[28] = p) : p = m[28], p;
66
+ }
67
+ let j = _ || b.status === "pending" || b.status === "success", M;
68
+ m[29] === T ? M = m[30] : (M = /* @__PURE__ */ jsxs("p", {
69
+ className: "text-sm font-medium",
70
+ children: [
71
+ "Sign in with ",
72
+ T,
73
+ " to continue."
74
+ ]
75
+ }), m[29] = T, m[30] = M);
76
+ let N = j || !y.authUrl, P;
77
+ m[31] === j ? P = m[32] : (P = j ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), m[31] = j, m[32] = P);
78
+ let F;
79
+ m[33] !== T || m[34] !== D || m[35] !== N || m[36] !== P ? (F = /* @__PURE__ */ jsxs(Button, {
80
+ onClick: D,
81
+ disabled: N,
82
+ children: [
83
+ P,
84
+ "Sign in with ",
85
+ T
86
+ ]
87
+ }), m[33] = T, m[34] = D, m[35] = N, m[36] = P, m[37] = F) : F = m[37];
88
+ let I;
89
+ return m[38] !== M || m[39] !== F ? (I = /* @__PURE__ */ jsxs("div", {
90
+ className: "space-y-2",
91
+ children: [M, F]
92
+ }), m[38] = M, m[39] = F, m[40] = I) : I = m[40], I;
93
+ }
94
+ export { OAuthPrompt };
@@ -0,0 +1,35 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { Tooltip, TooltipContent, TooltipTrigger } from "../../../components/ui/tooltip.js";
3
+ import { useOptionalWorkbenchLayout } from "../../workbench/providers/WorkbenchLayoutProvider.js";
4
+ import "../../workbench/index.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { MonitorPlay } from "lucide-react";
8
+ function SandboxRunButton(u) {
9
+ let d = c(14), { slotId: f, label: p } = u, m = useOptionalWorkbenchLayout();
10
+ if (!m || !f) return null;
11
+ let h;
12
+ d[0] !== m.environments || d[1] !== f ? (h = m.environments?.find((e) => e.slotId === f), d[0] = m.environments, d[1] = f, d[2] = h) : h = d[2];
13
+ let g = h;
14
+ if (!g) return null;
15
+ let _;
16
+ d[3] !== m || d[4] !== f ? (_ = () => m.openPreviewWithEnvironment(f), d[3] = m, d[4] = f, d[5] = _) : _ = d[5];
17
+ let v;
18
+ d[6] === Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ jsx(MonitorPlay, { className: "h-4 w-4" }), d[6] = v) : v = d[6];
19
+ let y;
20
+ d[7] === _ ? y = d[8] : (y = /* @__PURE__ */ jsx(TooltipTrigger, {
21
+ asChild: !0,
22
+ children: /* @__PURE__ */ jsx(Button, {
23
+ type: "button",
24
+ variant: "outline",
25
+ size: "icon",
26
+ onClick: _,
27
+ children: v
28
+ })
29
+ }), d[7] = _, d[8] = y);
30
+ let b = p ?? (g.envName ? `Open ${g.envName}` : "Open Sandbox"), x;
31
+ d[9] === b ? x = d[10] : (x = /* @__PURE__ */ jsx(TooltipContent, { children: b }), d[9] = b, d[10] = x);
32
+ let S;
33
+ return d[11] !== y || d[12] !== x ? (S = /* @__PURE__ */ jsxs(Tooltip, { children: [y, x] }), d[11] = y, d[12] = x, d[13] = S) : S = d[13], S;
34
+ }
35
+ export { SandboxRunButton };
@@ -0,0 +1,69 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { Input } from "../../../components/ui/input.js";
3
+ import { Label } from "../../../components/ui/label.js";
4
+ import { useUpsertSecret } from "../../../hooks/useSecrets.js";
5
+ import { useState } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { Info, KeyRound, Loader2 } from "lucide-react";
8
+ function SecretPrompt({ view: u, submit: d, isSubmitting: f, workspaceId: p }) {
9
+ let m = (u.content?.variables ?? []).filter((e) => e.key?.trim()), h = useUpsertSecret(), [g, _] = useState(() => Object.fromEntries(m.map((e) => [e.key, e.value ?? ""]))), [v, y] = useState(!1), b = typeof u.options?.label == "string" ? u.options.label : "Save & Continue";
10
+ if (m.length === 0 || !p) return null;
11
+ let x = async () => {
12
+ y(!0);
13
+ try {
14
+ let e = [];
15
+ for (let c of m) {
16
+ let l = g[c.key]?.trim();
17
+ l && (await h.mutateAsync({
18
+ workspaceId: p,
19
+ key: c.key,
20
+ value: l
21
+ }), e.push(c.key));
22
+ }
23
+ d({ keys: e });
24
+ } finally {
25
+ y(!1);
26
+ }
27
+ }, S = v || f;
28
+ return /* @__PURE__ */ jsxs("div", {
29
+ className: "space-y-3",
30
+ children: [
31
+ /* @__PURE__ */ jsx("p", {
32
+ className: "text-sm font-medium",
33
+ children: "Secrets"
34
+ }),
35
+ m.map((e) => /* @__PURE__ */ jsxs("div", {
36
+ className: "space-y-1",
37
+ children: [/* @__PURE__ */ jsx(Label, {
38
+ className: "text-muted-foreground text-xs",
39
+ htmlFor: `secret-${e.key}`,
40
+ children: e.key
41
+ }), /* @__PURE__ */ jsx(Input, {
42
+ id: `secret-${e.key}`,
43
+ type: "password",
44
+ placeholder: "Enter value...",
45
+ value: g[e.key] ?? "",
46
+ onChange: (c) => _((l) => ({
47
+ ...l,
48
+ [e.key]: c.target.value
49
+ })),
50
+ disabled: S
51
+ })]
52
+ }, e.key)),
53
+ /* @__PURE__ */ jsxs("div", {
54
+ className: "text-muted-foreground flex items-center gap-2 text-xs",
55
+ children: [/* @__PURE__ */ jsx(Info, { className: "h-3.5 w-3.5 shrink-0" }), /* @__PURE__ */ jsx("span", { children: "Values are stored as workspace secrets — only the saved keys reach the workflow." })]
56
+ }),
57
+ /* @__PURE__ */ jsx("div", {
58
+ className: "flex justify-end",
59
+ children: /* @__PURE__ */ jsxs(Button, {
60
+ onClick: () => void x(),
61
+ disabled: S,
62
+ className: "w-48",
63
+ children: [S ? /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(KeyRound, { className: "mr-2 h-4 w-4" }), b]
64
+ })
65
+ })
66
+ ]
67
+ });
68
+ }
69
+ export { SecretPrompt };
@@ -0,0 +1,196 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { Input } from "../../../components/ui/input.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ function question(t) {
7
+ let r = t.content;
8
+ return typeof r?.question == "string" ? r.question : "Input required";
9
+ }
10
+ function TextPrompt(s) {
11
+ let l = c(26), { view: u, submit: d, isSubmitting: f } = s, [p, m] = useState(""), h;
12
+ l[0] !== p || l[1] !== d ? (h = () => {
13
+ p.trim() && d({ answer: p.trim() });
14
+ }, l[0] = p, l[1] = d, l[2] = h) : h = l[2];
15
+ let g = h, _;
16
+ l[3] === u ? _ = l[4] : (_ = question(u), l[3] = u, l[4] = _);
17
+ let v;
18
+ l[5] === _ ? v = l[6] : (v = /* @__PURE__ */ jsx("p", {
19
+ className: "text-sm font-medium",
20
+ children: _
21
+ }), l[5] = _, l[6] = v);
22
+ let y;
23
+ l[7] === Symbol.for("react.memo_cache_sentinel") ? (y = (t) => m(t.target.value), l[7] = y) : y = l[7];
24
+ let b;
25
+ l[8] === g ? b = l[9] : (b = (t) => t.key === "Enter" && g(), l[8] = g, l[9] = b);
26
+ let x;
27
+ l[10] !== p || l[11] !== f || l[12] !== b ? (x = /* @__PURE__ */ jsx(Input, {
28
+ value: p,
29
+ onChange: y,
30
+ onKeyDown: b,
31
+ placeholder: "Your answer…",
32
+ disabled: f,
33
+ autoFocus: !0
34
+ }), l[10] = p, l[11] = f, l[12] = b, l[13] = x) : x = l[13];
35
+ let S;
36
+ l[14] !== p || l[15] !== f ? (S = f || !p.trim(), l[14] = p, l[15] = f, l[16] = S) : S = l[16];
37
+ let C;
38
+ l[17] !== g || l[18] !== S ? (C = /* @__PURE__ */ jsx(Button, {
39
+ onClick: g,
40
+ disabled: S,
41
+ children: "Send"
42
+ }), l[17] = g, l[18] = S, l[19] = C) : C = l[19];
43
+ let w;
44
+ l[20] !== x || l[21] !== C ? (w = /* @__PURE__ */ jsxs("div", {
45
+ className: "flex gap-2",
46
+ children: [x, C]
47
+ }), l[20] = x, l[21] = C, l[22] = w) : w = l[22];
48
+ let T;
49
+ return l[23] !== v || l[24] !== w ? (T = /* @__PURE__ */ jsxs("div", {
50
+ className: "space-y-2",
51
+ children: [v, w]
52
+ }), l[23] = v, l[24] = w, l[25] = T) : T = l[25], T;
53
+ }
54
+ function ConfirmPrompt(r) {
55
+ let i = c(20), { view: s, submit: l, isSubmitting: u } = r, d;
56
+ i[0] === s ? d = i[1] : (d = question(s), i[0] = s, i[1] = d);
57
+ let f;
58
+ i[2] === d ? f = i[3] : (f = /* @__PURE__ */ jsx("p", {
59
+ className: "text-sm font-medium",
60
+ children: d
61
+ }), i[2] = d, i[3] = f);
62
+ let p;
63
+ i[4] === l ? p = i[5] : (p = () => l({ answer: "yes" }), i[4] = l, i[5] = p);
64
+ let m;
65
+ i[6] !== u || i[7] !== p ? (m = /* @__PURE__ */ jsx(Button, {
66
+ className: "flex-1",
67
+ onClick: p,
68
+ disabled: u,
69
+ children: "Yes"
70
+ }), i[6] = u, i[7] = p, i[8] = m) : m = i[8];
71
+ let h;
72
+ i[9] === l ? h = i[10] : (h = () => l({ answer: "no" }), i[9] = l, i[10] = h);
73
+ let g;
74
+ i[11] !== u || i[12] !== h ? (g = /* @__PURE__ */ jsx(Button, {
75
+ variant: "outline",
76
+ className: "flex-1",
77
+ onClick: h,
78
+ disabled: u,
79
+ children: "No"
80
+ }), i[11] = u, i[12] = h, i[13] = g) : g = i[13];
81
+ let _;
82
+ i[14] !== m || i[15] !== g ? (_ = /* @__PURE__ */ jsxs("div", {
83
+ className: "flex gap-2",
84
+ children: [m, g]
85
+ }), i[14] = m, i[15] = g, i[16] = _) : _ = i[16];
86
+ let v;
87
+ return i[17] !== f || i[18] !== _ ? (v = /* @__PURE__ */ jsxs("div", {
88
+ className: "space-y-2",
89
+ children: [f, _]
90
+ }), i[17] = f, i[18] = _, i[19] = v) : v = i[19], v;
91
+ }
92
+ function ChoicesPrompt(s) {
93
+ let l = c(24), { view: u, submit: d, isSubmitting: f } = s, p = u.content, m;
94
+ l[0] === p ? m = l[1] : (m = Array.isArray(p?.options) ? p.options : [], l[0] = p, l[1] = m);
95
+ let h = m, [g, _] = useState(""), v;
96
+ l[2] === u ? v = l[3] : (v = question(u), l[2] = u, l[3] = v);
97
+ let y;
98
+ l[4] === v ? y = l[5] : (y = /* @__PURE__ */ jsx("p", {
99
+ className: "text-sm font-medium",
100
+ children: v
101
+ }), l[4] = v, l[5] = y);
102
+ let b;
103
+ if (l[6] !== f || l[7] !== h || l[8] !== d) {
104
+ let r;
105
+ l[10] !== f || l[11] !== d ? (r = (r) => /* @__PURE__ */ jsx(Button, {
106
+ variant: "outline",
107
+ className: "w-full",
108
+ onClick: () => d({ answer: r }),
109
+ disabled: f,
110
+ children: r
111
+ }, r), l[10] = f, l[11] = d, l[12] = r) : r = l[12], b = h.map(r), l[6] = f, l[7] = h, l[8] = d, l[9] = b;
112
+ } else b = l[9];
113
+ let x;
114
+ l[13] === b ? x = l[14] : (x = /* @__PURE__ */ jsx("div", {
115
+ className: "flex flex-col gap-2",
116
+ children: b
117
+ }), l[13] = b, l[14] = x);
118
+ let S;
119
+ l[15] !== p?.allowCustomAnswer || l[16] !== g || l[17] !== f || l[18] !== d ? (S = p?.allowCustomAnswer === !0 && /* @__PURE__ */ jsxs("div", {
120
+ className: "flex gap-2",
121
+ children: [/* @__PURE__ */ jsx(Input, {
122
+ value: g,
123
+ onChange: (t) => _(t.target.value),
124
+ onKeyDown: (t) => t.key === "Enter" && g.trim() && d({ answer: g.trim() }),
125
+ placeholder: "Custom answer…",
126
+ disabled: f
127
+ }), /* @__PURE__ */ jsx(Button, {
128
+ onClick: () => d({ answer: g.trim() }),
129
+ disabled: f || !g.trim(),
130
+ children: "Send"
131
+ })]
132
+ }), l[15] = p?.allowCustomAnswer, l[16] = g, l[17] = f, l[18] = d, l[19] = S) : S = l[19];
133
+ let C;
134
+ return l[20] !== y || l[21] !== x || l[22] !== S ? (C = /* @__PURE__ */ jsxs("div", {
135
+ className: "space-y-2",
136
+ children: [
137
+ y,
138
+ x,
139
+ S
140
+ ]
141
+ }), l[20] = y, l[21] = x, l[22] = S, l[23] = C) : C = l[23], C;
142
+ }
143
+ function PromptInput(o) {
144
+ let s = c(20), { view: l, submit: u, isSubmitting: d } = o, [f, p] = useState(""), m = typeof l.options?.label == "string" ? l.options.label : "Message", h;
145
+ s[0] !== f || s[1] !== u ? (h = () => {
146
+ f.trim() && (u(f.trim()), p(""));
147
+ }, s[0] = f, s[1] = u, s[2] = h) : h = s[2];
148
+ let g = h, _;
149
+ s[3] === Symbol.for("react.memo_cache_sentinel") ? (_ = (t) => p(t.target.value), s[3] = _) : _ = s[3];
150
+ let v;
151
+ s[4] === g ? v = s[5] : (v = (t) => t.key === "Enter" && g(), s[4] = g, s[5] = v);
152
+ let y = `${m}…`, b;
153
+ s[6] !== d || s[7] !== f || s[8] !== v || s[9] !== y ? (b = /* @__PURE__ */ jsx(Input, {
154
+ value: f,
155
+ onChange: _,
156
+ onKeyDown: v,
157
+ placeholder: y,
158
+ disabled: d,
159
+ autoFocus: !0
160
+ }), s[6] = d, s[7] = f, s[8] = v, s[9] = y, s[10] = b) : b = s[10];
161
+ let x;
162
+ s[11] !== d || s[12] !== f ? (x = d || !f.trim(), s[11] = d, s[12] = f, s[13] = x) : x = s[13];
163
+ let S;
164
+ s[14] !== g || s[15] !== x ? (S = /* @__PURE__ */ jsx(Button, {
165
+ onClick: g,
166
+ disabled: x,
167
+ children: "Send"
168
+ }), s[14] = g, s[15] = x, s[16] = S) : S = s[16];
169
+ let C;
170
+ return s[17] !== b || s[18] !== S ? (C = /* @__PURE__ */ jsxs("div", {
171
+ className: "flex gap-2",
172
+ children: [b, S]
173
+ }), s[17] = b, s[18] = S, s[19] = C) : C = s[19], C;
174
+ }
175
+ function ActionButton(r) {
176
+ let i = c(6), { view: a, submit: o, isSubmitting: s } = r, l = typeof a.options?.label == "string" ? a.options.label : a.defaultTransition ?? "Continue", u;
177
+ i[0] === o ? u = i[1] : (u = () => o({}), i[0] = o, i[1] = u);
178
+ let d;
179
+ return i[2] !== s || i[3] !== l || i[4] !== u ? (d = /* @__PURE__ */ jsx(Button, {
180
+ onClick: u,
181
+ disabled: s,
182
+ children: l
183
+ }), i[2] = s, i[3] = l, i[4] = u, i[5] = d) : d = i[5], d;
184
+ }
185
+ function FullWidthActionButton(r) {
186
+ let i = c(6), { view: a, submit: o, isSubmitting: s } = r, l = typeof a.options?.label == "string" ? a.options.label : a.defaultTransition ?? "Continue", u;
187
+ i[0] === o ? u = i[1] : (u = () => o({}), i[0] = o, i[1] = u);
188
+ let d;
189
+ return i[2] !== s || i[3] !== l || i[4] !== u ? (d = /* @__PURE__ */ jsx(Button, {
190
+ className: "w-full",
191
+ onClick: u,
192
+ disabled: s,
193
+ children: l
194
+ }), i[2] = s, i[3] = l, i[4] = u, i[5] = d) : d = i[5], d;
195
+ }
196
+ export { ActionButton, ChoicesPrompt, ConfirmPrompt, FullWidthActionButton, PromptInput, TextPrompt };
@@ -0,0 +1,90 @@
1
+ import { Button } from "../../../components/ui/button.js";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { AlertCircle, RefreshCw } from "lucide-react";
5
+ function NotSupportedCard(e) {
6
+ let i = c(2), { view: a } = e, o;
7
+ return i[0] === a.widget ? o = i[1] : (o = /* @__PURE__ */ jsxs("div", {
8
+ className: "text-muted-foreground rounded-md border border-dashed p-3 text-sm",
9
+ children: [
10
+ "Input of type ",
11
+ /* @__PURE__ */ jsx("code", {
12
+ className: "font-mono",
13
+ children: a.widget
14
+ }),
15
+ " is not yet supported in the run view."
16
+ ]
17
+ }), i[0] = a.widget, i[1] = o), o;
18
+ }
19
+ function BareWaitCard(e) {
20
+ let i = c(4), { view: a } = e, o;
21
+ i[0] === a.transitions ? o = i[1] : (o = a.transitions.join(", ") || "—", i[0] = a.transitions, i[1] = o);
22
+ let s;
23
+ return i[2] === o ? s = i[3] : (s = /* @__PURE__ */ jsxs("div", {
24
+ className: "text-muted-foreground rounded-md border border-dashed p-3 text-sm",
25
+ children: [
26
+ "Waiting on ",
27
+ /* @__PURE__ */ jsx("code", {
28
+ className: "font-mono",
29
+ children: o
30
+ }),
31
+ " — nothing to show."
32
+ ]
33
+ }), i[2] = o, i[3] = s), s;
34
+ }
35
+ function FailedRunCard(o) {
36
+ let s = c(13), { workflowName: l, errorMessage: u, onRetry: d, isRetrying: f } = o, p;
37
+ s[0] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ jsx(AlertCircle, { className: "text-destructive h-4 w-4 shrink-0" }), s[0] = p) : p = s[0];
38
+ let m;
39
+ s[1] === l ? m = s[2] : (m = /* @__PURE__ */ jsx("span", {
40
+ className: "font-medium",
41
+ children: l
42
+ }), s[1] = l, s[2] = m);
43
+ let h = u ? `: ${u}` : ".", g;
44
+ s[3] !== m || s[4] !== h ? (g = /* @__PURE__ */ jsxs("p", {
45
+ className: "flex items-center gap-2 text-sm",
46
+ children: [p, /* @__PURE__ */ jsxs("span", { children: [
47
+ m,
48
+ " failed",
49
+ h
50
+ ] })]
51
+ }), s[3] = m, s[4] = h, s[5] = g) : g = s[5];
52
+ let _;
53
+ s[6] === Symbol.for("react.memo_cache_sentinel") ? (_ = /* @__PURE__ */ jsx(RefreshCw, { className: "mr-2 h-3.5 w-3.5" }), s[6] = _) : _ = s[6];
54
+ let v;
55
+ s[7] !== f || s[8] !== d ? (v = /* @__PURE__ */ jsxs(Button, {
56
+ variant: "outline",
57
+ size: "sm",
58
+ onClick: d,
59
+ disabled: f,
60
+ children: [_, "Retry"]
61
+ }), s[7] = f, s[8] = d, s[9] = v) : v = s[9];
62
+ let y;
63
+ return s[10] !== g || s[11] !== v ? (y = /* @__PURE__ */ jsxs("div", {
64
+ className: "border-destructive/40 space-y-2 rounded-md border p-3",
65
+ children: [g, v]
66
+ }), s[10] = g, s[11] = v, s[12] = y) : y = s[12], y;
67
+ }
68
+ function InertPromptEntry(e) {
69
+ let i = c(10), { document: a } = e, o;
70
+ i[0] === a.content ? o = i[1] : (o = a.content ?? {}, i[0] = a.content, i[1] = o);
71
+ let s = o, l = typeof s.question == "string" ? s.question : typeof s.markdown == "string" ? s.markdown : void 0, u = s.answer !== void 0, f;
72
+ i[2] === l ? f = i[3] : (f = l && /* @__PURE__ */ jsx("p", {
73
+ className: "font-medium",
74
+ children: l
75
+ }), i[2] = l, i[3] = f);
76
+ let p;
77
+ i[4] !== u || i[5] !== s.answer ? (p = u && /* @__PURE__ */ jsxs("p", {
78
+ className: "text-muted-foreground mt-1",
79
+ children: ["Answered: ", formatAnswer(s.answer)]
80
+ }), i[4] = u, i[5] = s.answer, i[6] = p) : p = i[6];
81
+ let m;
82
+ return i[7] !== f || i[8] !== p ? (m = /* @__PURE__ */ jsxs("div", {
83
+ className: "rounded-md border p-3 text-sm",
84
+ children: [f, p]
85
+ }), i[7] = f, i[8] = p, i[9] = m) : m = i[9], m;
86
+ }
87
+ function formatAnswer(e) {
88
+ return typeof e == "string" ? e : typeof e == "boolean" ? e ? "yes" : "no" : JSON.stringify(e);
89
+ }
90
+ export { BareWaitCard, FailedRunCard, InertPromptEntry, NotSupportedCard };
@@ -0,0 +1,16 @@
1
+ import { FormPrompt } from "./FormPrompt.js";
2
+ import { OAuthPrompt } from "./OAuthPrompt.js";
3
+ import { SecretPrompt } from "./SecretPrompt.js";
4
+ import { ActionButton, ChoicesPrompt, ConfirmPrompt, FullWidthActionButton, PromptInput, TextPrompt } from "./SimplePrompts.js";
5
+ const promptRegistry = new Map([
6
+ ["text-prompt", TextPrompt],
7
+ ["confirm-prompt", ConfirmPrompt],
8
+ ["choices", ChoicesPrompt],
9
+ ["form", FormPrompt],
10
+ ["secret-input", SecretPrompt],
11
+ ["oauth-prompt", OAuthPrompt],
12
+ ["prompt-input", PromptInput],
13
+ ["button", ActionButton],
14
+ ["button-full-w", FullWidthActionButton]
15
+ ]);
16
+ export { promptRegistry };
@@ -0,0 +1,24 @@
1
+ function composeTranscript(e, t) {
2
+ let n = e.flatMap((e) => e.documents.map((t) => ({
3
+ document: t,
4
+ depth: e.depth
5
+ })));
6
+ n.sort((e, t) => new Date(e.document.createdAt).getTime() - new Date(t.document.createdAt).getTime() || e.document.index - t.document.index);
7
+ let r = new Set(e.filter((e) => e.depth === 0).map((e) => e.workflowId)), i = [];
8
+ for (let { document: e, depth: a } of n) {
9
+ if (a > 0 && !r.has(e.workflowId)) continue;
10
+ let n = t(e.documentName);
11
+ if (n === "link") {
12
+ let t = e.content?.workflowId;
13
+ typeof t == "string" && r.add(t);
14
+ continue;
15
+ }
16
+ i.push({
17
+ document: e,
18
+ depth: a,
19
+ widget: n
20
+ });
21
+ }
22
+ return i;
23
+ }
24
+ export { composeTranscript };