@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
@@ -6,78 +6,78 @@ import { createContext, useCallback, useContext, useMemo, useState } from "react
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { useQueryClient } from "@tanstack/react-query";
8
8
  var FileExplorerContext = createContext(null);
9
- function FileExplorerProvider(u) {
10
- let d = c(37), { variant: f, workspaceId: p, enabled: m, children: h } = u, g = m === void 0 ? !0 : m, _ = useLoopstackClient(), v = useQueryClient(), y;
11
- d[0] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ new Set(), d[0] = y) : y = d[0];
9
+ function FileExplorerProvider(l) {
10
+ let u = c(37), { variant: d, workspaceId: f, slotId: p, enabled: m, children: h } = l, g = m === void 0 ? !0 : m, _ = useLoopstackClient(), v = useQueryClient(), y;
11
+ u[0] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ new Set(), u[0] = y) : y = u[0];
12
12
  let [b, x] = useState(y), S;
13
- d[1] === Symbol.for("react.memo_cache_sentinel") ? (S = [], d[1] = S) : S = d[1];
14
- let [C, w] = useState(S), [T, E] = useState(null), D = useFileTree(f, p, g), O = useFileContent(f, p, T?.type === "file" ? T.path : void 0, g), k;
15
- d[2] === Symbol.for("react.memo_cache_sentinel") ? (k = (e) => {
16
- x((o) => {
17
- let s = new Set(o);
18
- return s.has(e) ? s.delete(e) : s.add(e), s;
13
+ u[1] === Symbol.for("react.memo_cache_sentinel") ? (S = [], u[1] = S) : S = u[1];
14
+ let [C, w] = useState(S), [T, E] = useState(null), D = useFileTree(d, f, p, g), O = useFileContent(d, f, T?.type === "file" ? T.path : void 0, p, g), k;
15
+ u[2] === Symbol.for("react.memo_cache_sentinel") ? (k = (e) => {
16
+ x((a) => {
17
+ let o = new Set(a);
18
+ return o.has(e) ? o.delete(e) : o.add(e), o;
19
19
  });
20
- }, d[2] = k) : k = d[2];
20
+ }, u[2] = k) : k = u[2];
21
21
  let A = k, j;
22
- d[3] === Symbol.for("react.memo_cache_sentinel") ? (j = (e) => {
23
- e.type === "file" && (E(e), w((o) => o.some((o) => o.path === e.path) ? o : [...o, e]));
24
- }, d[3] = j) : j = d[3];
22
+ u[3] === Symbol.for("react.memo_cache_sentinel") ? (j = (e) => {
23
+ e.type === "file" && (E(e), w((a) => a.some((a) => a.path === e.path) ? a : [...a, e]));
24
+ }, u[3] = j) : j = u[3];
25
25
  let M = j, N;
26
- d[4] === T?.path ? N = d[5] : (N = (e) => {
27
- w((o) => {
28
- let s = o.filter((o) => o.path !== e.path);
29
- if (T?.path === e.path) if (s.length > 0) {
30
- let l = o.findIndex((o) => o.path === e.path);
31
- E(s[Math.max(0, l - 1)]);
26
+ u[4] === T?.path ? N = u[5] : (N = (e) => {
27
+ w((a) => {
28
+ let o = a.filter((a) => a.path !== e.path);
29
+ if (T?.path === e.path) if (o.length > 0) {
30
+ let s = a.findIndex((a) => a.path === e.path);
31
+ E(o[Math.max(0, s - 1)]);
32
32
  } else E(null);
33
- return s;
33
+ return o;
34
34
  });
35
- }, d[4] = T?.path, d[5] = N);
35
+ }, u[4] = T?.path, u[5] = N);
36
36
  let P = N, F;
37
- d[6] === T ? F = d[7] : (F = () => {
37
+ u[6] === T ? F = u[7] : (F = () => {
38
38
  T && w((e) => {
39
- let o = e.filter((e) => e.path !== T.path);
40
- if (o.length > 0) {
41
- let s = e.findIndex((e) => e.path === T.path);
42
- E(o[Math.max(0, s - 1)]);
39
+ let a = e.filter((e) => e.path !== T.path);
40
+ if (a.length > 0) {
41
+ let o = e.findIndex((e) => e.path === T.path);
42
+ E(a[Math.max(0, o - 1)]);
43
43
  } else E(null);
44
- return o;
44
+ return a;
45
45
  });
46
- }, d[6] = T, d[7] = F);
46
+ }, u[6] = T, u[7] = F);
47
47
  let I = F, L;
48
- d[8] === Symbol.for("react.memo_cache_sentinel") ? (L = () => {
48
+ u[8] === Symbol.for("react.memo_cache_sentinel") ? (L = () => {
49
49
  w([]), E(null);
50
- }, d[8] = L) : L = d[8];
50
+ }, u[8] = L) : L = u[8];
51
51
  let R = L, z;
52
- d[9] === Symbol.for("react.memo_cache_sentinel") ? (z = (e) => {
52
+ u[9] === Symbol.for("react.memo_cache_sentinel") ? (z = (e) => {
53
53
  w([e]), E(e);
54
- }, d[9] = z) : z = d[9];
54
+ }, u[9] = z) : z = u[9];
55
55
  let B = z, V;
56
- d[10] === T ? V = d[11] : (V = (e) => {
57
- w((o) => {
58
- let s = o.findIndex((o) => o.path === e.path);
59
- if (s <= 0) return o;
60
- let l = o.slice(s);
61
- return T && o.findIndex((e) => e.path === T.path) < s && E(e), l;
56
+ u[10] === T ? V = u[11] : (V = (e) => {
57
+ w((a) => {
58
+ let o = a.findIndex((a) => a.path === e.path);
59
+ if (o <= 0) return a;
60
+ let s = a.slice(o);
61
+ return T && a.findIndex((e) => e.path === T.path) < o && E(e), s;
62
62
  });
63
- }, d[10] = T, d[11] = V);
63
+ }, u[10] = T, u[11] = V);
64
64
  let H = V, U;
65
- d[12] === T ? U = d[13] : (U = (e) => {
66
- w((o) => {
67
- let s = o.findIndex((o) => o.path === e.path);
68
- if (s < 0 || s >= o.length - 1) return o;
69
- let l = o.slice(0, s + 1);
70
- return T && o.findIndex((e) => e.path === T.path) > s && E(e), l;
65
+ u[12] === T ? U = u[13] : (U = (e) => {
66
+ w((a) => {
67
+ let o = a.findIndex((a) => a.path === e.path);
68
+ if (o < 0 || o >= a.length - 1) return a;
69
+ let s = a.slice(0, o + 1);
70
+ return T && a.findIndex((e) => e.path === T.path) > o && E(e), s;
71
71
  });
72
- }, d[12] = T, d[13] = U);
72
+ }, u[12] = T, u[13] = U);
73
73
  let W = U, G;
74
- d[14] !== _.envKey || d[15] !== v ? (G = () => {
74
+ u[14] !== _.envKey || u[15] !== v ? (G = () => {
75
75
  v.invalidateQueries({ queryKey: fileTreeKey(_.envKey) });
76
- }, d[14] = _.envKey, d[15] = v, d[16] = G) : G = d[16];
76
+ }, u[14] = _.envKey, u[15] = v, u[16] = G) : G = u[16];
77
77
  let K = G, q;
78
- d[17] === D.data ? q = d[18] : (q = D.data ?? [], d[17] = D.data, d[18] = q);
78
+ u[17] === D.data ? q = u[18] : (q = D.data ?? [], u[17] = D.data, u[18] = q);
79
79
  let J = D.isLoading && !D.data, Y = O.data?.content ?? null, X = O.isLoading && !!T, Z;
80
- d[19] !== I || d[20] !== P || d[21] !== H || d[22] !== W || d[23] !== b || d[24] !== C || d[25] !== K || d[26] !== T || d[27] !== q || d[28] !== J || d[29] !== Y || d[30] !== X || d[31] !== D.error || d[32] !== D.isFetching ? (Z = {
80
+ u[19] !== I || u[20] !== P || u[21] !== H || u[22] !== W || u[23] !== b || u[24] !== C || u[25] !== K || u[26] !== T || u[27] !== q || u[28] !== J || u[29] !== Y || u[30] !== X || u[31] !== D.error || u[32] !== D.isFetching ? (Z = {
81
81
  nodes: q,
82
82
  isTreeLoading: J,
83
83
  treeError: D.error,
@@ -96,12 +96,12 @@ function FileExplorerProvider(u) {
96
96
  closeToRight: W,
97
97
  clearSelection: I,
98
98
  refreshTree: K
99
- }, d[19] = I, d[20] = P, d[21] = H, d[22] = W, d[23] = b, d[24] = C, d[25] = K, d[26] = T, d[27] = q, d[28] = J, d[29] = Y, d[30] = X, d[31] = D.error, d[32] = D.isFetching, d[33] = Z) : Z = d[33];
99
+ }, u[19] = I, u[20] = P, u[21] = H, u[22] = W, u[23] = b, u[24] = C, u[25] = K, u[26] = T, u[27] = q, u[28] = J, u[29] = Y, u[30] = X, u[31] = D.error, u[32] = D.isFetching, u[33] = Z) : Z = u[33];
100
100
  let Q = Z, $;
101
- return d[34] !== h || d[35] !== Q ? ($ = /* @__PURE__ */ jsx(FileExplorerContext.Provider, {
101
+ return u[34] !== h || u[35] !== Q ? ($ = /* @__PURE__ */ jsx(FileExplorerContext.Provider, {
102
102
  value: Q,
103
103
  children: h
104
- }), d[34] = h, d[35] = Q, d[36] = $) : $ = d[36], $;
104
+ }), u[34] = h, u[35] = Q, u[36] = $) : $ = u[36], $;
105
105
  }
106
106
  function useFileExplorer() {
107
107
  let e = useContext(FileExplorerContext);
@@ -5,6 +5,7 @@ import "../../../hooks/useProcessor.js";
5
5
  import { useWorkbenchLayout } from "../../workbench/providers/WorkbenchLayoutProvider.js";
6
6
  import { SidebarPanel } from "../../workbench/components/SidebarPanel.js";
7
7
  import "../../workbench/index.js";
8
+ import { EnvironmentSelector } from "../../workbench/components/EnvironmentSelector.js";
8
9
  import { useGitInvalidation, useGitLog, useGitRemote, useGitStatus, useRemoveGitRemote } from "../hooks/useGit.js";
9
10
  import { GitBranchBadge } from "./GitBranchBadge.js";
10
11
  import { GitCommitList } from "./GitCommitList.js";
@@ -12,31 +13,33 @@ import { GitRemoteStatus } from "./GitRemoteStatus.js";
12
13
  import { c } from "react/compiler-runtime";
13
14
  import { jsx, jsxs } from "react/jsx-runtime";
14
15
  import { GitBranch, Loader2 } from "lucide-react";
15
- function WorkbenchGitPanel(y) {
16
- let b = c(20), { workspaceId: x } = y, { panelSize: S, setPanelSize: C, closePanel: w } = useWorkbenchLayout(), { router: T } = useStudio(), { data: E, isLoading: D } = useGitStatus(x), { data: O, isLoading: k } = useGitLog(x), { data: A } = useGitRemote(x);
17
- useGitInvalidation(x);
18
- let j = useCreateWorkflow(), M = useRunWorkflow(), N = useRemoveGitRemote(), P = j.isPending || M.isPending, F;
19
- b[0] !== j || b[1] !== T || b[2] !== M || b[3] !== x ? (F = () => {
20
- x && j.mutate({
16
+ function WorkbenchGitPanel(b) {
17
+ let x = c(21), { workspaceId: S } = b, { panelSize: C, setPanelSize: w, closePanel: T, selectedSlotId: E } = useWorkbenchLayout(), { router: D } = useStudio(), { data: O, isLoading: k } = useGitStatus(S, E), { data: A, isLoading: j } = useGitLog(S, 50, E), { data: M } = useGitRemote(S, E);
18
+ useGitInvalidation(S);
19
+ let N = useCreateWorkflow(), P = useRunWorkflow(), F = useRemoveGitRemote(), I = N.isPending || P.isPending, L;
20
+ x[0] !== N || x[1] !== D || x[2] !== P || x[3] !== S ? (L = () => {
21
+ S && N.mutate({
21
22
  workflowName: "connectGitHub",
22
23
  title: null,
23
- workspaceId: x,
24
+ workspaceId: S,
24
25
  transition: null,
25
26
  args: {}
26
27
  }, { onSuccess: (t) => {
27
- M.mutate({ workflowId: t.id }, { onSuccess: () => {
28
- T.navigateToWorkflow(t.id);
28
+ P.mutate({ workflowId: t.id }, { onSuccess: () => {
29
+ D.navigateToWorkflow(t.id);
29
30
  } });
30
31
  } });
31
- }, b[0] = j, b[1] = T, b[2] = M, b[3] = x, b[4] = F) : F = b[4];
32
- let I = F, L = D || k, R;
33
- b[5] === Symbol.for("react.memo_cache_sentinel") ? (R = /* @__PURE__ */ jsx(GitBranch, { className: "h-4 w-4" }), b[5] = R) : R = b[5];
34
- let z;
35
- b[6] !== I || b[7] !== P || b[8] !== L || b[9] !== O?.commits || b[10] !== A || b[11] !== N || b[12] !== E || b[13] !== x ? (z = /* @__PURE__ */ jsx("div", {
32
+ }, x[0] = N, x[1] = D, x[2] = P, x[3] = S, x[4] = L) : L = x[4];
33
+ let R = L, z = k || j, B;
34
+ x[5] === Symbol.for("react.memo_cache_sentinel") ? (B = /* @__PURE__ */ jsx(GitBranch, { className: "h-4 w-4" }), x[5] = B) : B = x[5];
35
+ let V;
36
+ x[6] === Symbol.for("react.memo_cache_sentinel") ? (V = /* @__PURE__ */ jsx(EnvironmentSelector, {}), x[6] = V) : V = x[6];
37
+ let H;
38
+ x[7] !== R || x[8] !== I || x[9] !== z || x[10] !== A?.commits || x[11] !== M || x[12] !== F || x[13] !== O || x[14] !== S ? (H = /* @__PURE__ */ jsxs("div", {
36
39
  className: "flex h-full flex-col",
37
- children: /* @__PURE__ */ jsx("div", {
40
+ children: [V, /* @__PURE__ */ jsx("div", {
38
41
  className: "flex-1 overflow-y-auto px-4 py-3",
39
- children: L ? /* @__PURE__ */ jsxs("div", {
42
+ children: z ? /* @__PURE__ */ jsxs("div", {
40
43
  className: "flex items-center gap-2 py-4",
41
44
  children: [/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ jsx("span", {
42
45
  className: "text-muted-foreground text-sm",
@@ -45,34 +48,34 @@ function WorkbenchGitPanel(y) {
45
48
  }) : /* @__PURE__ */ jsxs("div", {
46
49
  className: "space-y-4",
47
50
  children: [
48
- E && /* @__PURE__ */ jsx(GitBranchBadge, { status: E }),
51
+ O && /* @__PURE__ */ jsx(GitBranchBadge, { status: O }),
49
52
  /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h4", {
50
53
  className: "mb-2 text-xs font-medium uppercase text-muted-foreground",
51
54
  children: "Remote"
52
55
  }), /* @__PURE__ */ jsx(GitRemoteStatus, {
53
- remote: A,
54
- onConnect: I,
55
- isConnecting: P,
56
- onRemove: x ? () => N.mutate({ workspaceId: x }) : void 0,
57
- isRemoving: N.isPending
56
+ remote: M,
57
+ onConnect: R,
58
+ isConnecting: I,
59
+ onRemove: S ? () => F.mutate({ workspaceId: S }) : void 0,
60
+ isRemoving: F.isPending
58
61
  })] }),
59
62
  /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h4", {
60
63
  className: "mb-2 text-xs font-medium uppercase text-muted-foreground",
61
64
  children: "Recent Commits"
62
- }), /* @__PURE__ */ jsx(GitCommitList, { commits: O?.commits ?? [] })] })
65
+ }), /* @__PURE__ */ jsx(GitCommitList, { commits: A?.commits ?? [] })] })
63
66
  ]
64
67
  })
65
- })
66
- }), b[6] = I, b[7] = P, b[8] = L, b[9] = O?.commits, b[10] = A, b[11] = N, b[12] = E, b[13] = x, b[14] = z) : z = b[14];
67
- let B;
68
- return b[15] !== w || b[16] !== S || b[17] !== C || b[18] !== z ? (B = /* @__PURE__ */ jsx(SidebarPanel, {
69
- icon: R,
68
+ })]
69
+ }), x[7] = R, x[8] = I, x[9] = z, x[10] = A?.commits, x[11] = M, x[12] = F, x[13] = O, x[14] = S, x[15] = H) : H = x[15];
70
+ let U;
71
+ return x[16] !== T || x[17] !== C || x[18] !== w || x[19] !== H ? (U = /* @__PURE__ */ jsx(SidebarPanel, {
72
+ icon: B,
70
73
  title: "Git",
71
74
  description: "Source control for this workspace.",
72
- size: S,
73
- onSizeChange: C,
74
- onClose: w,
75
- children: z
76
- }), b[15] = w, b[16] = S, b[17] = C, b[18] = z, b[19] = B) : B = b[19], B;
75
+ size: C,
76
+ onSizeChange: w,
77
+ onClose: T,
78
+ children: H
79
+ }), x[16] = T, x[17] = C, x[18] = w, x[19] = H, x[20] = U) : U = x[20], U;
77
80
  }
78
81
  export { WorkbenchGitPanel };
@@ -6,47 +6,50 @@ import { c } from "react/compiler-runtime";
6
6
  import { useEffect } from "react";
7
7
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
8
8
  var gitPath = (e) => `/api/v1/workspaces/${e}/git`;
9
- function useGitStatus(r) {
10
- let i = c(10), o = useLoopstackClient(), l;
11
- i[0] !== o.envKey || i[1] !== r ? (l = queryKeys.gitStatus(o.envKey, r), i[0] = o.envKey, i[1] = r, i[2] = l) : l = i[2];
12
- let u;
13
- i[3] !== o.http || i[4] !== r ? (u = () => o.http.get(`${gitPath(r)}/status`), i[3] = o.http, i[4] = r, i[5] = u) : u = i[5];
14
- let d = !!r, f;
15
- return i[6] !== l || i[7] !== u || i[8] !== d ? (f = {
16
- queryKey: l,
17
- queryFn: u,
18
- enabled: d,
9
+ function useGitStatus(r, i) {
10
+ let o = c(12), l = useLoopstackClient(), u;
11
+ o[0] !== l.envKey || o[1] !== i || o[2] !== r ? (u = [...queryKeys.gitStatus(l.envKey, r), i ?? ""], o[0] = l.envKey, o[1] = i, o[2] = r, o[3] = u) : u = o[3];
12
+ let d;
13
+ o[4] !== l.http || o[5] !== i || o[6] !== r ? (d = () => l.http.get(`${gitPath(r)}/status`, i ? { slotId: i } : void 0), o[4] = l.http, o[5] = i, o[6] = r, o[7] = d) : d = o[7];
14
+ let f = !!r, p;
15
+ return o[8] !== u || o[9] !== d || o[10] !== f ? (p = {
16
+ queryKey: u,
17
+ queryFn: d,
18
+ enabled: f,
19
19
  staleTime: 3e4,
20
20
  retry: !1
21
- }, i[6] = l, i[7] = u, i[8] = d, i[9] = f) : f = i[9], useQuery(f);
21
+ }, o[8] = u, o[9] = d, o[10] = f, o[11] = p) : p = o[11], useQuery(p);
22
22
  }
23
- function useGitLog(r, i) {
24
- let o = c(11), l = i === void 0 ? 50 : i, u = useLoopstackClient(), d;
25
- o[0] !== u.envKey || o[1] !== r ? (d = queryKeys.gitLog(u.envKey, r), o[0] = u.envKey, o[1] = r, o[2] = d) : d = o[2];
26
- let f;
27
- o[3] !== u.http || o[4] !== l || o[5] !== r ? (f = () => u.http.get(`${gitPath(r)}/log`, { limit: l }), o[3] = u.http, o[4] = l, o[5] = r, o[6] = f) : f = o[6];
28
- let p = !!r, m;
29
- return o[7] !== d || o[8] !== f || o[9] !== p ? (m = {
30
- queryKey: d,
31
- queryFn: f,
32
- enabled: p,
23
+ function useGitLog(r, i, o) {
24
+ let l = c(13), u = i === void 0 ? 50 : i, d = useLoopstackClient(), f;
25
+ l[0] !== d.envKey || l[1] !== o || l[2] !== r ? (f = [...queryKeys.gitLog(d.envKey, r), o ?? ""], l[0] = d.envKey, l[1] = o, l[2] = r, l[3] = f) : f = l[3];
26
+ let p;
27
+ l[4] !== d.http || l[5] !== u || l[6] !== o || l[7] !== r ? (p = () => d.http.get(`${gitPath(r)}/log`, {
28
+ limit: u,
29
+ ...o ? { slotId: o } : {}
30
+ }), l[4] = d.http, l[5] = u, l[6] = o, l[7] = r, l[8] = p) : p = l[8];
31
+ let m = !!r, h;
32
+ return l[9] !== f || l[10] !== p || l[11] !== m ? (h = {
33
+ queryKey: f,
34
+ queryFn: p,
35
+ enabled: m,
33
36
  staleTime: 3e4,
34
37
  retry: !1
35
- }, o[7] = d, o[8] = f, o[9] = p, o[10] = m) : m = o[10], useQuery(m);
38
+ }, l[9] = f, l[10] = p, l[11] = m, l[12] = h) : h = l[12], useQuery(h);
36
39
  }
37
- function useGitRemote(r) {
38
- let i = c(10), o = useLoopstackClient(), l;
39
- i[0] !== o.envKey || i[1] !== r ? (l = queryKeys.gitRemote(o.envKey, r), i[0] = o.envKey, i[1] = r, i[2] = l) : l = i[2];
40
- let u;
41
- i[3] !== o.http || i[4] !== r ? (u = () => o.http.get(`${gitPath(r)}/remote`), i[3] = o.http, i[4] = r, i[5] = u) : u = i[5];
42
- let d = !!r, f;
43
- return i[6] !== l || i[7] !== u || i[8] !== d ? (f = {
44
- queryKey: l,
45
- queryFn: u,
46
- enabled: d,
40
+ function useGitRemote(r, i) {
41
+ let o = c(12), l = useLoopstackClient(), u;
42
+ o[0] !== l.envKey || o[1] !== i || o[2] !== r ? (u = [...queryKeys.gitRemote(l.envKey, r), i ?? ""], o[0] = l.envKey, o[1] = i, o[2] = r, o[3] = u) : u = o[3];
43
+ let d;
44
+ o[4] !== l.http || o[5] !== i || o[6] !== r ? (d = () => l.http.get(`${gitPath(r)}/remote`, i ? { slotId: i } : void 0), o[4] = l.http, o[5] = i, o[6] = r, o[7] = d) : d = o[7];
45
+ let f = !!r, p;
46
+ return o[8] !== u || o[9] !== d || o[10] !== f ? (p = {
47
+ queryKey: u,
48
+ queryFn: d,
49
+ enabled: f,
47
50
  staleTime: 6e4,
48
51
  retry: !1
49
- }, i[6] = l, i[7] = u, i[8] = d, i[9] = f) : f = i[9], useQuery(f);
52
+ }, o[8] = u, o[9] = d, o[10] = f, o[11] = p) : p = o[11], useQuery(p);
50
53
  }
51
54
  function useGitInvalidation(i) {
52
55
  let a = c(5), s = useLoopstackClient(), l = useQueryClient(), u, d;
@@ -1,2 +1,4 @@
1
+ import "../../packages/client/dist/index.js";
2
+ import "../../config.js";
1
3
  import React, { useEffect, useState } from "react";
2
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -0,0 +1,153 @@
1
+ import { useRunWorkflow } from "../../packages/react/dist/hooks/mutations.js";
2
+ import "../../packages/react/dist/index.js";
3
+ import { useDocumentConfigs } from "../../hooks/useConfig.js";
4
+ import { BareWaitCard, FailedRunCard, NotSupportedCard } from "./prompts/cards.js";
5
+ import { Transcript } from "./Transcript.js";
6
+ import { SandboxRunButton } from "./prompts/SandboxRunButton.js";
7
+ import { promptRegistry } from "./prompts/registry.js";
8
+ import { composeTranscript } from "./transcript.js";
9
+ import { useRunPrompts } from "./useRunPrompts.js";
10
+ import { useRunTree } from "./useRunTree.js";
11
+ import { useStreamingNodes } from "./useTreeLlmStreams.js";
12
+ import { c } from "react/compiler-runtime";
13
+ import { useMemo } from "react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ function resolveWidgetName(t) {
16
+ let m = t;
17
+ return m?.widgets?.[0]?.widget ?? m?.form?.widget;
18
+ }
19
+ function RunView(g) {
20
+ let _ = c(68), { workflowId: v, settings: y } = g, { nodes: b, isLoading: x } = useRunTree(v), S = useRunPrompts(b), C = useDocumentConfigs(), w = useRunWorkflow(), T = useStreamingNodes(b);
21
+ y?.showFullMessageHistory;
22
+ let E;
23
+ if (_[0] !== C || _[1] !== y?.showFullMessageHistory || _[2] !== T) {
24
+ let t;
25
+ _[4] === y?.showFullMessageHistory ? t = _[5] : (t = (t) => ({
26
+ workflowId: t.workflowId,
27
+ depth: t.depth,
28
+ documents: y?.showFullMessageHistory ? t.documents : t.documents.filter(_temp)
29
+ }), _[4] = y?.showFullMessageHistory, _[5] = t);
30
+ let m = T.map(t), h;
31
+ _[6] === C ? h = _[7] : (h = (t) => resolveWidgetName(C.get(t)?.ui), _[6] = C, _[7] = h), E = composeTranscript(m, h), _[0] = C, _[1] = y?.showFullMessageHistory, _[2] = T, _[3] = E;
32
+ } else E = _[3];
33
+ let D = E, O;
34
+ _[8] === b ? O = _[9] : (O = new Map(b.map(_temp2)), _[8] = b, _[9] = O);
35
+ let k = O, A;
36
+ bb0: {
37
+ let t = S.picked?.candidate.document?.content;
38
+ if (!t) {
39
+ A = D;
40
+ break bb0;
41
+ }
42
+ let m;
43
+ if (_[10] !== D || _[11] !== t) {
44
+ let h;
45
+ _[13] === t ? h = _[14] : (h = (m) => m.document.content !== t, _[13] = t, _[14] = h), m = D.filter(h), _[10] = D, _[11] = t, _[12] = m;
46
+ } else m = _[12];
47
+ A = m;
48
+ }
49
+ let j = A, M = S.picked, N;
50
+ _[15] === M ? N = _[16] : (N = M?.view.widget ? promptRegistry.get(M.view.widget) : void 0, _[15] = M, _[16] = N);
51
+ let P = N, F = S.idlePrompt, I;
52
+ _[17] === F ? I = _[18] : (I = F?.view.widget ? promptRegistry.get(F.view.widget) : void 0, _[17] = F, _[18] = I);
53
+ let L = I, R;
54
+ _[19] !== b || _[20] !== M || _[21] !== S.blocked ? (R = !M && !S.blocked ? b.find(_temp3) : void 0, _[19] = b, _[20] = M, _[21] = S.blocked, _[22] = R) : R = _[22];
55
+ let z = R, B;
56
+ _[23] !== M || _[24] !== w ? (B = (t, m) => {
57
+ if (!M) return;
58
+ let h = m ?? M.view.defaultTransition;
59
+ h && w.mutate({
60
+ workflowId: M.view.workflowId,
61
+ payload: { transition: {
62
+ id: h,
63
+ workflowId: M.view.workflowId,
64
+ payload: t
65
+ } }
66
+ });
67
+ }, _[23] = M, _[24] = w, _[25] = B) : B = _[25];
68
+ let V = B, H;
69
+ _[26] === x ? H = _[27] : (H = x && /* @__PURE__ */ jsx("p", {
70
+ className: "text-muted-foreground text-sm",
71
+ children: "Loading run…"
72
+ }), _[26] = x, _[27] = H);
73
+ let U = b[0]?.workflow, W = y?.enableDebugMode, G;
74
+ _[28] !== W || _[29] !== U || _[30] !== j || _[31] !== k ? (G = /* @__PURE__ */ jsx(Transcript, {
75
+ entries: j,
76
+ workflows: k,
77
+ rootWorkflow: U,
78
+ debug: W
79
+ }), _[28] = W, _[29] = U, _[30] = j, _[31] = k, _[32] = G) : G = _[32];
80
+ let K;
81
+ _[33] === S.sandboxSlots ? K = _[34] : (K = S.sandboxSlots.length > 0 && /* @__PURE__ */ jsx("div", {
82
+ className: "flex justify-end gap-2",
83
+ children: S.sandboxSlots.map(_temp4)
84
+ }), _[33] = S.sandboxSlots, _[34] = K);
85
+ let q;
86
+ _[35] !== P || _[36] !== b[0]?.workflow || _[37] !== M || _[38] !== w || _[39] !== V ? (q = M && P && /* @__PURE__ */ jsx("div", {
87
+ className: "bg-background rounded-lg border p-4 shadow-sm",
88
+ children: /* @__PURE__ */ jsx(P, {
89
+ view: M.view,
90
+ submit: V,
91
+ isSubmitting: w.isPending,
92
+ workspaceId: b[0]?.workflow.workspaceId
93
+ })
94
+ }), _[35] = P, _[36] = b[0]?.workflow, _[37] = M, _[38] = w, _[39] = V, _[40] = q) : q = _[40];
95
+ let J;
96
+ _[41] !== L || _[42] !== F || _[43] !== M ? (J = !M && F && L && /* @__PURE__ */ jsx("div", {
97
+ className: "bg-background rounded-lg border p-4 opacity-70 shadow-sm",
98
+ children: /* @__PURE__ */ jsx(L, {
99
+ view: F.view,
100
+ submit: _temp5,
101
+ isSubmitting: !0
102
+ })
103
+ }), _[41] = L, _[42] = F, _[43] = M, _[44] = J) : J = _[44];
104
+ let Y;
105
+ _[45] !== M || _[46] !== S.blocked ? (Y = !M && S.blocked && /* @__PURE__ */ jsx(NotSupportedCard, { view: S.blocked.view }), _[45] = M, _[46] = S.blocked, _[47] = Y) : Y = _[47];
106
+ let X;
107
+ _[48] !== z || _[49] !== w ? (X = z && /* @__PURE__ */ jsx(FailedRunCard, {
108
+ workflowName: z.workflow.title ?? z.workflow.workflowName,
109
+ errorMessage: z.workflow.errorMessage,
110
+ onRetry: () => w.mutate({ workflowId: z.workflowId }),
111
+ isRetrying: w.isPending
112
+ }), _[48] = z, _[49] = w, _[50] = X) : X = _[50];
113
+ let Z;
114
+ _[51] !== z || _[52] !== F || _[53] !== M || _[54] !== S.blocked || _[55] !== S.fallback ? (Z = !M && !F && !S.blocked && !z && S.fallback && /* @__PURE__ */ jsx(BareWaitCard, { view: S.fallback.view }), _[51] = z, _[52] = F, _[53] = M, _[54] = S.blocked, _[55] = S.fallback, _[56] = Z) : Z = _[56];
115
+ let Q;
116
+ _[57] !== K || _[58] !== q || _[59] !== J || _[60] !== Y || _[61] !== X || _[62] !== Z ? (Q = /* @__PURE__ */ jsxs("div", {
117
+ className: "mt-6 space-y-2",
118
+ children: [
119
+ K,
120
+ q,
121
+ J,
122
+ Y,
123
+ X,
124
+ Z
125
+ ]
126
+ }), _[57] = K, _[58] = q, _[59] = J, _[60] = Y, _[61] = X, _[62] = Z, _[63] = Q) : Q = _[63];
127
+ let $;
128
+ return _[64] !== G || _[65] !== Q || _[66] !== H ? ($ = /* @__PURE__ */ jsxs("div", {
129
+ className: "w-full max-w-3xl",
130
+ children: [
131
+ H,
132
+ G,
133
+ Q
134
+ ]
135
+ }), _[64] = G, _[65] = Q, _[66] = H, _[67] = $) : $ = _[67], $;
136
+ }
137
+ function _temp5() {}
138
+ function _temp4(t) {
139
+ return /* @__PURE__ */ jsx(SandboxRunButton, {
140
+ slotId: t.slotId,
141
+ label: t.label
142
+ }, t.slotId ?? "default");
143
+ }
144
+ function _temp3(t) {
145
+ return t.workflow.hasError && t.workflow.status === "failed";
146
+ }
147
+ function _temp2(t) {
148
+ return [t.workflowId, t.workflow];
149
+ }
150
+ function _temp(t) {
151
+ return !t.tags?.includes("internal");
152
+ }
153
+ export { RunView };
@@ -0,0 +1,127 @@
1
+ import { useFeatureRegistry } from "../feature-registry/FeatureRegistryProvider.js";
2
+ import "../feature-registry/index.js";
3
+ import AiMessage_default from "../documents/renderers/AiMessage.js";
4
+ import DocumentDebugRenderer_default from "../documents/renderers/DocumentDebugRenderer.js";
5
+ import DocumentFormRenderer_default from "../documents/renderers/DocumentFormRenderer.js";
6
+ import DocumentMessageRenderer_default from "../documents/renderers/DocumentMessageRenderer.js";
7
+ import ErrorMessageRenderer_default from "../documents/renderers/ErrorMessageRenderer.js";
8
+ import LlmMessage_default from "../documents/renderers/LlmMessage.js";
9
+ import MarkdownMessageRenderer_default from "../documents/renderers/MarkdownMessageRenderer.js";
10
+ import PlainMessageRenderer_default from "../documents/renderers/PlainMessageRenderer.js";
11
+ import { InertPromptEntry } from "./prompts/cards.js";
12
+ import { c } from "react/compiler-runtime";
13
+ import { useMemo } from "react";
14
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
+ var displayRenderers = new Map([
16
+ ["ai-message", (e, a) => /* @__PURE__ */ jsx(AiMessage_default, {
17
+ document: e,
18
+ isLastItem: a
19
+ })],
20
+ ["llm-message", (e, i) => /* @__PURE__ */ jsx(LlmMessage_default, {
21
+ document: e,
22
+ isLastItem: i
23
+ })],
24
+ ["message", (e) => /* @__PURE__ */ jsx(DocumentMessageRenderer_default, { document: e })],
25
+ ["error", (e) => /* @__PURE__ */ jsx(ErrorMessageRenderer_default, { document: e })],
26
+ ["plain", (e) => /* @__PURE__ */ jsx(PlainMessageRenderer_default, { document: e })],
27
+ ["markdown", (e) => /* @__PURE__ */ jsx(MarkdownMessageRenderer_default, { document: e })],
28
+ ["debug", (e) => /* @__PURE__ */ jsx(DocumentDebugRenderer_default, { document: e })]
29
+ ]);
30
+ function TranscriptDocument(e) {
31
+ let i = c(26), { entry: a, isLastItem: s, featureRenderers: l, workflows: u, rootWorkflow: d } = e, f;
32
+ if (i[0] !== a.document || i[1] !== a.widget || i[2] !== s) {
33
+ f = Symbol.for("react.early_return_sentinel");
34
+ bb0: {
35
+ let e = a.widget ? displayRenderers.get(a.widget) : void 0;
36
+ if (e) {
37
+ f = /* @__PURE__ */ jsx(Fragment$1, { children: e(a.document, s) });
38
+ break bb0;
39
+ }
40
+ }
41
+ i[0] = a.document, i[1] = a.widget, i[2] = s, i[3] = f;
42
+ } else f = i[3];
43
+ if (f !== Symbol.for("react.early_return_sentinel")) return f;
44
+ let m;
45
+ i[4] !== a.document.workflowId || i[5] !== u ? (m = u.get(a.document.workflowId), i[4] = a.document.workflowId, i[5] = u, i[6] = m) : m = i[6];
46
+ let g = m;
47
+ if (a.widget === "form" && g) {
48
+ let e = d ?? g, s = a.document, l;
49
+ return i[7] !== e || i[8] !== s || i[9] !== g ? (l = /* @__PURE__ */ jsx("div", {
50
+ className: "rounded-md border p-3",
51
+ children: /* @__PURE__ */ jsx(DocumentFormRenderer_default, {
52
+ parentWorkflow: e,
53
+ workflow: g,
54
+ document: s,
55
+ enabled: !1,
56
+ viewOnly: !0
57
+ })
58
+ }), i[7] = e, i[8] = s, i[9] = g, i[10] = l) : l = i[10], l;
59
+ }
60
+ let _;
61
+ i[11] !== a.widget || i[12] !== l ? (_ = a.widget ? l.get(a.widget) : void 0, i[11] = a.widget, i[12] = l, i[13] = _) : _ = i[13];
62
+ let v = _;
63
+ if (v && g) {
64
+ let e = d ?? g, o = a.document, l;
65
+ return i[14] !== v || i[15] !== s || i[16] !== e || i[17] !== o || i[18] !== g ? (l = /* @__PURE__ */ jsx(v, {
66
+ parentWorkflow: e,
67
+ workflow: g,
68
+ document: o,
69
+ isActive: !1,
70
+ isLastItem: s
71
+ }), i[14] = v, i[15] = s, i[16] = e, i[17] = o, i[18] = g, i[19] = l) : l = i[19], l;
72
+ }
73
+ if (a.widget) {
74
+ let e;
75
+ return i[20] === a.document ? e = i[21] : (e = /* @__PURE__ */ jsx(InertPromptEntry, { document: a.document }), i[20] = a.document, i[21] = e), e;
76
+ }
77
+ let y;
78
+ i[22] === a.document.content ? y = i[23] : (y = JSON.stringify(a.document.content, null, 2), i[22] = a.document.content, i[23] = y);
79
+ let b;
80
+ return i[24] === y ? b = i[25] : (b = /* @__PURE__ */ jsx("pre", {
81
+ className: "bg-muted/50 overflow-x-auto rounded-md p-3 font-mono text-xs",
82
+ children: y
83
+ }), i[24] = y, i[25] = b), b;
84
+ }
85
+ function DebugMeta(e) {
86
+ let i = c(8), { entry: a } = e, o = a.widget ?? "no widget", s = `place: ${a.document.place ?? "—"}`, l = `index: ${a.document.index}`, u;
87
+ i[0] !== a.document.documentName || i[1] !== a.document.isInvalidated || i[2] !== o || i[3] !== s || i[4] !== l ? (u = [
88
+ a.document.documentName,
89
+ o,
90
+ s,
91
+ l
92
+ ], a.document.isInvalidated && u.push("invalidated"), i[0] = a.document.documentName, i[1] = a.document.isInvalidated, i[2] = o, i[3] = s, i[4] = l, i[5] = u) : u = i[5];
93
+ let d = u.join(" · "), f;
94
+ return i[6] === d ? f = i[7] : (f = /* @__PURE__ */ jsx("p", {
95
+ className: "text-muted-foreground font-mono text-[10px]",
96
+ children: d
97
+ }), i[6] = d, i[7] = f), f;
98
+ }
99
+ function Transcript(i) {
100
+ let a = c(16), { entries: o, workflows: s, rootWorkflow: l, debug: u } = i, d = useFeatureRegistry(), f;
101
+ if (a[0] !== d) {
102
+ f = /* @__PURE__ */ new Map();
103
+ for (let e of d) for (let [i, a] of Object.entries(e.documentRenderers ?? {})) f.set(i, a);
104
+ a[0] = d, a[1] = f;
105
+ } else f = a[1];
106
+ let p = f, m;
107
+ if (a[2] !== u || a[3] !== o || a[4] !== p || a[5] !== l || a[6] !== s) {
108
+ let e;
109
+ a[8] !== u || a[9] !== o.length || a[10] !== p || a[11] !== l || a[12] !== s ? (e = (e, i) => /* @__PURE__ */ jsxs("div", {
110
+ style: e.depth > 0 ? { marginLeft: e.depth * 20 } : void 0,
111
+ className: e.depth > 0 ? "border-muted border-l-2 pl-3" : void 0,
112
+ children: [u && /* @__PURE__ */ jsx(DebugMeta, { entry: e }), /* @__PURE__ */ jsx(TranscriptDocument, {
113
+ entry: e,
114
+ isLastItem: i === o.length - 1,
115
+ featureRenderers: p,
116
+ workflows: s,
117
+ rootWorkflow: l
118
+ })]
119
+ }, e.document.id), a[8] = u, a[9] = o.length, a[10] = p, a[11] = l, a[12] = s, a[13] = e) : e = a[13], m = o.map(e), a[2] = u, a[3] = o, a[4] = p, a[5] = l, a[6] = s, a[7] = m;
120
+ } else m = a[7];
121
+ let h;
122
+ return a[14] === m ? h = a[15] : (h = /* @__PURE__ */ jsx("div", {
123
+ className: "space-y-3",
124
+ children: m
125
+ }), a[14] = m, a[15] = h), h;
126
+ }
127
+ export { Transcript };