@loopstack/loopstack-studio 0.29.5 → 0.31.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 (122) hide show
  1. package/dist/_virtual/rolldown_runtime.js +3 -1
  2. package/dist/api/config.js +5 -4
  3. package/dist/api/environments.js +5 -1
  4. package/dist/api/processor.js +4 -1
  5. package/dist/app/EnvironmentEmbedRoot.js +22 -30
  6. package/dist/components/ai-elements/code-block.js +4 -4
  7. package/dist/components/dynamic-form/CodeContent.js +1 -1
  8. package/dist/components/dynamic-form/FormBody.js +1 -1
  9. package/dist/components/layout/StudioSidebar.js +116 -131
  10. package/dist/components/lists/ListView.js +46 -46
  11. package/dist/components/motion/FadeIn.js +72 -0
  12. package/dist/components/motion/StreamingText.js +49 -0
  13. package/dist/components/ui/accordion.js +2 -2
  14. package/dist/components/ui-widgets/UiWidget.js +11 -10
  15. package/dist/components/ui-widgets/widgets/AiPromptInput.js +31 -28
  16. package/dist/events/sse-client-events.js +7 -1
  17. package/dist/features/code-explorer/components/FileContentViewer.js +2 -2
  18. package/dist/features/dashboard/AppLauncher.js +84 -0
  19. package/dist/features/debug/components/WorkflowFlowViewer.js +49 -51
  20. package/dist/features/documents/DocumentRenderer.js +18 -17
  21. package/dist/features/documents/components/DocumentItem.js +42 -20
  22. package/dist/features/documents/components/DocumentList.js +34 -36
  23. package/dist/features/documents/components/DocumentMetadataPills.js +102 -49
  24. package/dist/features/documents/document-details/DocumentDetails.js +577 -377
  25. package/dist/features/documents/document-details/PromptDetails.js +118 -130
  26. package/dist/features/documents/document-details/document-debug-utils.js +100 -0
  27. package/dist/features/documents/renderers/ChoicesRenderer.js +41 -38
  28. package/dist/features/documents/renderers/ConfirmPromptRenderer.js +31 -28
  29. package/dist/features/documents/renderers/DocumentFormRenderer.js +62 -70
  30. package/dist/features/documents/renderers/LlmMessage.js +52 -47
  31. package/dist/features/documents/renderers/TextPromptRenderer.js +32 -29
  32. package/dist/features/documents/renderers/useDocumentTransition.js +4 -4
  33. package/dist/features/feature-registry/FeatureRegistryProvider.js +32 -10
  34. package/dist/features/feature-registry/available-features.js +12 -0
  35. package/dist/features/feature-registry/index.js +2 -1
  36. package/dist/features/file-explorer/components/FileExplorerPanel.js +55 -51
  37. package/dist/features/git/components/GitBranchBadge.js +31 -0
  38. package/dist/features/git/components/GitCommitList.js +46 -0
  39. package/dist/features/git/components/GitRemoteStatus.js +84 -0
  40. package/dist/features/git/components/WorkbenchGitPanel.js +81 -0
  41. package/dist/features/git/git-feature.js +12 -0
  42. package/dist/features/git/hooks/useGit.js +78 -0
  43. package/dist/features/git/index.js +1 -0
  44. package/dist/features/oauth/OAuthPromptRenderer.js +137 -142
  45. package/dist/features/runs/Runs.js +73 -73
  46. package/dist/features/secrets/components/WorkbenchSecretsPanel.js +1 -1
  47. package/dist/features/secrets/renderers/SecretInputRenderer.js +30 -29
  48. package/dist/features/workbench/Workbench.js +25 -33
  49. package/dist/features/workbench/WorkflowItem.js +9 -9
  50. package/dist/features/workbench/WorkflowList.js +61 -62
  51. package/dist/features/workbench/components/NewRunDialog.js +237 -209
  52. package/dist/features/workbench/components/RecentRunItem.js +3 -3
  53. package/dist/features/workbench/components/WorkbenchEnvironmentPanel.js +8 -8
  54. package/dist/features/workbench/components/WorkbenchIconSidebar.js +74 -109
  55. package/dist/features/workbench/components/WorkbenchSidebarShell.js +3 -3
  56. package/dist/features/workbench/components/WorkflowForms.js +11 -10
  57. package/dist/features/workbench/components/WorkflowHistoryItem.js +16 -36
  58. package/dist/features/workbench/components/WorkflowHistoryList.js +19 -17
  59. package/dist/features/workbench/components/buttons/WorkflowButtons.js +3 -3
  60. package/dist/features/workbench/hooks/useLlmStreamingDocuments.js +159 -0
  61. package/dist/features/workbench/hooks/useWorkflowData.js +58 -31
  62. package/dist/features/workbench/index.js +2 -2
  63. package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +53 -53
  64. package/dist/features/workspaces/Workspaces.js +166 -136
  65. package/dist/features/workspaces/components/CreateWorkspace.js +115 -107
  66. package/dist/features/workspaces/components/ExecutionTimeline.js +2 -2
  67. package/dist/features/workspaces/components/WorkflowRunForm.js +127 -104
  68. package/dist/features/workspaces/components/WorkspaceHomePage.js +6 -89
  69. package/dist/features/workspaces/components/workflow-form/ArgumentsView.js +1 -1
  70. package/dist/features/workspaces/components/workflow-form/SelectionView.js +15 -15
  71. package/dist/hooks/index.js +3 -2
  72. package/dist/hooks/query-keys.js +43 -30
  73. package/dist/hooks/useConfig.js +28 -22
  74. package/dist/hooks/useEnvironments.js +27 -2
  75. package/dist/hooks/useProcessor.js +14 -1
  76. package/dist/hooks/useWorkflows.js +4 -4
  77. package/dist/index.d.ts +119 -18
  78. package/dist/index.js +10 -9
  79. package/dist/node_modules/d3/src/index.js +13 -13
  80. package/dist/node_modules/d3-scale/src/continuous.js +16 -16
  81. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/architectureDiagram-3BPJPVTR.js +43 -43
  82. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/blockDiagram-GPEHLZMM.js +270 -270
  83. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAUBKEIU.js +90 -90
  84. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-3OPIFGDE.js +458 -458
  85. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-55IACEB6.js +3 -3
  86. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-5ZQYHXKU.js +37 -37
  87. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-727SXJPM.js +208 -208
  88. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-KSCS5N6A.js +145 -145
  89. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ND2GUHAM.js +7 -7
  90. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-O5CBEL6O.js +41 -41
  91. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-WU5MYG2G.js +3 -3
  92. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/cose-bilkent-S5V4N54A.js +6 -6
  93. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/diagram-KO2AKTUF.js +30 -30
  94. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/diagram-OG6HWLK6.js +82 -82
  95. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/erDiagram-TEJ5UH35.js +65 -65
  96. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-I6XJVG4X.js +227 -227
  97. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-6RSMTGT7.js +104 -104
  98. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/gitGraphDiagram-PVQCEYII.js +104 -104
  99. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/journeyDiagram-JHISSGLW.js +49 -49
  100. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/quadrantDiagram-W4KKPZXB.js +101 -101
  101. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sankeyDiagram-5OEKKPKP.js +20 -20
  102. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-3UESZ5HK.js +354 -354
  103. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-AJRCARHV.js +53 -53
  104. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/timeline-definition-PNZ67QCA.js +113 -113
  105. package/dist/node_modules/mermaid/dist/chunks/mermaid.core/vennDiagram-CIIHVFJN.js +90 -90
  106. package/dist/node_modules/mermaid/dist/mermaid.core.js +156 -156
  107. package/dist/node_modules/motion/dist/es/react.js +9 -2
  108. package/dist/pages/DashboardPage.js +20 -74
  109. package/dist/pages/DebugWorkflowDetailsPage.js +2 -2
  110. package/dist/pages/DebugWorkflowsPage.js +76 -106
  111. package/dist/pages/EmbedWorkbenchPage.js +1 -1
  112. package/dist/pages/PreviewWorkbenchPage.js +6 -6
  113. package/dist/pages/WorkbenchPage.js +43 -47
  114. package/dist/pages/WorkflowDebugPage.js +6 -12
  115. package/dist/pages/WorkspacePage.js +40 -66
  116. package/dist/pages/WorkspaceRunsPage.js +24 -31
  117. package/dist/routing/LocalRouter.js +1 -1
  118. package/package.json +2 -2
  119. package/dist/features/dashboard/Dashboard.js +0 -125
  120. package/dist/features/dashboard/RunItem.js +0 -78
  121. package/dist/features/dashboard/RunList.js +0 -32
  122. package/dist/hooks/useDashboard.js +0 -16
@@ -1,146 +1,134 @@
1
1
  import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../../../components/ui/accordion.js";
2
- import { Card, CardContent, CardHeader, CardTitle } from "../../../components/ui/card.js";
3
- import CompletionMessagePaper_default from "../../../components/messages/CompletionMessagePaper.js";
2
+ import { Badge } from "../../../components/ui/badge.js";
3
+ import { formatNumber } from "./document-debug-utils.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import React from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- var PromptDetails_default = (p) => {
8
- let m = c(40), { promptData: h } = p;
9
- if (!h) return null;
10
- let { messages: g, response: _, cache: v } = h, y;
11
- m[0] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ jsx(CardHeader, {
12
- className: "pb-3",
13
- children: /* @__PURE__ */ jsx(CardTitle, {
14
- className: "text-lg",
15
- children: "Cache"
16
- })
17
- }), m[0] = y) : y = m[0];
18
- let b = v?.hit ? "Yes" : "No", x;
19
- m[1] === b ? x = m[2] : (x = /* @__PURE__ */ jsxs("p", {
20
- className: "text-sm",
21
- children: ["Hit: ", b]
22
- }), m[1] = b, m[2] = x);
23
- let S = v?.hash, C;
24
- m[3] === S ? C = m[4] : (C = /* @__PURE__ */ jsxs("p", {
25
- className: "text-sm",
26
- children: ["Hash: ", S]
27
- }), m[3] = S, m[4] = C);
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ var DetailRow = (n) => {
8
+ let s = c(7), { label: l, children: u } = n, d;
9
+ s[0] === l ? d = s[1] : (d = /* @__PURE__ */ jsx("span", {
10
+ className: "text-muted-foreground font-medium",
11
+ children: l
12
+ }), s[0] = l, s[1] = d);
13
+ let f;
14
+ s[2] === u ? f = s[3] : (f = /* @__PURE__ */ jsx("span", {
15
+ className: "min-w-0 wrap-break-word",
16
+ children: u
17
+ }), s[2] = u, s[3] = f);
18
+ let p;
19
+ return s[4] !== d || s[5] !== f ? (p = /* @__PURE__ */ jsxs("div", {
20
+ className: "grid min-w-0 grid-cols-[7.5rem_1fr] gap-x-3 gap-y-0.5 text-sm",
21
+ children: [d, f]
22
+ }), s[4] = d, s[5] = f, s[6] = p) : p = s[6], p;
23
+ }, PromptDetails_default = (d) => {
24
+ let p = c(32), { promptData: m } = d;
25
+ if (!m) return null;
26
+ let { messages: h, response: g, cache: _ } = m, v = g?.metadata, y = v?.prompt_token != null && v?.completion_token != null ? v.prompt_token + v.completion_token : void 0, b;
27
+ p[0] === Symbol.for("react.memo_cache_sentinel") ? (b = ["summary", "messages"], p[0] = b) : b = p[0];
28
+ let x;
29
+ p[1] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ jsx(AccordionTrigger, {
30
+ className: "py-3 text-sm font-semibold",
31
+ children: "Request summary"
32
+ }), p[1] = x) : x = p[1];
33
+ let S = h?.length ?? 0, C;
34
+ p[2] === S ? C = p[3] : (C = /* @__PURE__ */ jsx(DetailRow, {
35
+ label: "Messages",
36
+ children: S
37
+ }), p[2] = S, p[3] = C);
28
38
  let w;
29
- m[5] !== x || m[6] !== C ? (w = /* @__PURE__ */ jsxs(Card, { children: [y, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("div", {
30
- className: "ml-4 space-y-1",
31
- children: [x, C]
32
- }) })] }), m[5] = x, m[6] = C, m[7] = w) : w = m[7];
39
+ p[4] === _ ? w = p[5] : (w = _ && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(DetailRow, {
40
+ label: "Cache hit",
41
+ children: _.hit ? "Yes" : "No"
42
+ }), _.hash && /* @__PURE__ */ jsx(DetailRow, {
43
+ label: "Cache hash",
44
+ children: _.hash
45
+ })] }), p[4] = _, p[5] = w);
33
46
  let T;
34
- m[8] === Symbol.for("react.memo_cache_sentinel") ? (T = /* @__PURE__ */ jsx(AccordionTrigger, {
35
- className: "text-lg font-semibold",
36
- children: "Request Messages"
37
- }), m[8] = T) : T = m[8];
47
+ p[6] === v ? T = p[7] : (T = v?.model && /* @__PURE__ */ jsx(DetailRow, {
48
+ label: "Model",
49
+ children: v.model
50
+ }), p[6] = v, p[7] = T);
38
51
  let E;
39
- m[9] === g ? E = m[10] : (E = g?.map(_temp), m[9] = g, m[10] = E);
52
+ p[8] === v ? E = p[9] : (E = v?.prompt_id && /* @__PURE__ */ jsx(DetailRow, {
53
+ label: "Prompt ID",
54
+ children: v.prompt_id
55
+ }), p[8] = v, p[9] = E);
40
56
  let D;
41
- m[11] === E ? D = m[12] : (D = /* @__PURE__ */ jsx(Accordion, {
42
- type: "single",
43
- collapsible: !0,
44
- defaultValue: "messages",
45
- children: /* @__PURE__ */ jsxs(AccordionItem, {
46
- value: "messages",
47
- children: [T, /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsx("div", {
48
- className: "space-y-2",
49
- children: E
50
- }) })]
51
- })
52
- }), m[11] = E, m[12] = D);
57
+ p[10] === v ? D = p[11] : (D = v?.response_time != null && /* @__PURE__ */ jsxs(DetailRow, {
58
+ label: "Response time",
59
+ children: [v.response_time, " ms"]
60
+ }), p[10] = v, p[11] = D);
53
61
  let O;
54
- m[13] === Symbol.for("react.memo_cache_sentinel") ? (O = /* @__PURE__ */ jsx(AccordionTrigger, {
55
- className: "text-lg font-semibold",
56
- children: "Response"
57
- }), m[13] = O) : O = m[13];
58
- let k = _?.data, A;
59
- m[14] === k ? A = m[15] : (A = /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, {
60
- className: "p-4",
61
- children: /* @__PURE__ */ jsx("pre", {
62
- className: "font-mono text-xs wrap-break-word whitespace-pre-wrap",
63
- children: k
64
- })
65
- }) }), m[14] = k, m[15] = A);
62
+ p[12] === v ? O = p[13] : (O = v?.prompt_token != null && /* @__PURE__ */ jsx(DetailRow, {
63
+ label: "Prompt tokens",
64
+ children: formatNumber(v.prompt_token)
65
+ }), p[12] = v, p[13] = O);
66
+ let k;
67
+ p[14] === v ? k = p[15] : (k = v?.completion_token != null && /* @__PURE__ */ jsx(DetailRow, {
68
+ label: "Completion tokens",
69
+ children: formatNumber(v.completion_token)
70
+ }), p[14] = v, p[15] = k);
71
+ let A;
72
+ p[16] === y ? A = p[17] : (A = y != null && /* @__PURE__ */ jsx(DetailRow, {
73
+ label: "Total tokens",
74
+ children: formatNumber(y)
75
+ }), p[16] = y, p[17] = A);
66
76
  let j;
67
- m[16] === Symbol.for("react.memo_cache_sentinel") ? (j = /* @__PURE__ */ jsx(CardHeader, {
68
- className: "pb-3",
69
- children: /* @__PURE__ */ jsx(CardTitle, {
70
- className: "text-base",
71
- children: "Metadata"
72
- })
73
- }), m[16] = j) : j = m[16];
74
- let M = _?.metadata?.model, N;
75
- m[17] === M ? N = m[18] : (N = /* @__PURE__ */ jsxs("p", {
76
- className: "text-sm",
77
- children: ["Model: ", M]
78
- }), m[17] = M, m[18] = N);
79
- let P = _?.metadata?.prompt_id, F;
80
- m[19] === P ? F = m[20] : (F = /* @__PURE__ */ jsxs("p", {
81
- className: "text-sm",
82
- children: ["Prompt ID: ", P]
83
- }), m[19] = P, m[20] = F);
84
- let I = _?.metadata?.response_time, L;
85
- m[21] === I ? L = m[22] : (L = /* @__PURE__ */ jsxs("p", {
86
- className: "text-sm",
87
- children: [
88
- "Response Time: ",
89
- I,
90
- " ms"
91
- ]
92
- }), m[21] = I, m[22] = L);
93
- let R = _?.metadata?.prompt_token, z;
94
- m[23] === R ? z = m[24] : (z = /* @__PURE__ */ jsxs("p", {
95
- className: "text-sm",
96
- children: ["Prompt Tokens: ", R]
97
- }), m[23] = R, m[24] = z);
98
- let B = _?.metadata?.completion_token, V;
99
- m[25] === B ? V = m[26] : (V = /* @__PURE__ */ jsxs("p", {
100
- className: "text-sm",
101
- children: ["Completion Tokens: ", B]
102
- }), m[25] = B, m[26] = V);
103
- let H;
104
- m[27] !== N || m[28] !== F || m[29] !== L || m[30] !== z || m[31] !== V ? (H = /* @__PURE__ */ jsxs(Card, {
105
- className: "bg-gray-50",
106
- children: [j, /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("div", {
107
- className: "ml-4 space-y-1",
77
+ p[18] !== k || p[19] !== A || p[20] !== C || p[21] !== w || p[22] !== T || p[23] !== E || p[24] !== D || p[25] !== O ? (j = /* @__PURE__ */ jsxs(AccordionItem, {
78
+ value: "summary",
79
+ children: [x, /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", {
80
+ className: "space-y-2 pb-1",
108
81
  children: [
109
- N,
110
- F,
111
- L,
112
- z,
113
- V
82
+ C,
83
+ w,
84
+ T,
85
+ E,
86
+ D,
87
+ O,
88
+ k,
89
+ A
114
90
  ]
115
91
  }) })]
116
- }), m[27] = N, m[28] = F, m[29] = L, m[30] = z, m[31] = V, m[32] = H) : H = m[32];
117
- let U;
118
- m[33] !== A || m[34] !== H ? (U = /* @__PURE__ */ jsx(Accordion, {
119
- type: "single",
120
- collapsible: !0,
121
- defaultValue: "response",
122
- children: /* @__PURE__ */ jsxs(AccordionItem, {
123
- value: "response",
124
- children: [O, /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", {
125
- className: "space-y-4",
126
- children: [A, H]
127
- }) })]
92
+ }), p[18] = k, p[19] = A, p[20] = C, p[21] = w, p[22] = T, p[23] = E, p[24] = D, p[25] = O, p[26] = j) : j = p[26];
93
+ let M;
94
+ p[27] === h ? M = p[28] : (M = h && h.length > 0 && /* @__PURE__ */ jsxs(AccordionItem, {
95
+ value: "messages",
96
+ children: [/* @__PURE__ */ jsx(AccordionTrigger, {
97
+ className: "py-3 text-sm font-semibold",
98
+ children: "Request messages"
99
+ }), /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsx("div", {
100
+ className: "space-y-2",
101
+ children: h.map(_temp)
102
+ }) })]
103
+ }), p[27] = h, p[28] = M);
104
+ let N;
105
+ return p[29] !== j || p[30] !== M ? (N = /* @__PURE__ */ jsx("div", {
106
+ className: "min-w-0 space-y-3",
107
+ children: /* @__PURE__ */ jsxs(Accordion, {
108
+ type: "multiple",
109
+ defaultValue: b,
110
+ className: "min-w-0 space-y-1",
111
+ children: [j, M]
128
112
  })
129
- }), m[33] = A, m[34] = H, m[35] = U) : U = m[35];
130
- let W;
131
- return m[36] !== U || m[37] !== w || m[38] !== D ? (W = /* @__PURE__ */ jsxs("div", {
132
- className: "mt-4 space-y-4",
133
- children: [
134
- w,
135
- D,
136
- U
137
- ]
138
- }), m[36] = U, m[37] = w, m[38] = D, m[39] = W) : W = m[39], W;
113
+ }), p[29] = j, p[30] = M, p[31] = N) : N = p[31], N;
139
114
  };
140
- function _temp(t, f) {
141
- return /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
142
- role: t.role,
143
- children: t.content
144
- }, f);
115
+ function _temp(n, s) {
116
+ return /* @__PURE__ */ jsxs("div", {
117
+ className: "min-w-0 rounded-md border p-3",
118
+ children: [/* @__PURE__ */ jsxs("div", {
119
+ className: "mb-2 flex items-center gap-2",
120
+ children: [/* @__PURE__ */ jsx(Badge, {
121
+ variant: "outline",
122
+ className: "text-xs capitalize",
123
+ children: n.role
124
+ }), /* @__PURE__ */ jsxs("span", {
125
+ className: "text-muted-foreground text-xs",
126
+ children: [n.content.length, " chars"]
127
+ })]
128
+ }), /* @__PURE__ */ jsx("pre", {
129
+ className: "max-h-48 min-w-0 max-w-full overflow-x-auto overflow-y-auto font-mono text-xs whitespace-pre-wrap",
130
+ children: n.content
131
+ })]
132
+ }, s);
145
133
  }
146
134
  export { PromptDetails_default as default };
@@ -0,0 +1,100 @@
1
+ function summarizeDocumentContent(e) {
2
+ if (e == null) return { kind: "null" };
3
+ if (typeof e == "string") return {
4
+ kind: "string",
5
+ charCount: e.length
6
+ };
7
+ if (Array.isArray(e)) return {
8
+ kind: "array",
9
+ itemCount: e.length
10
+ };
11
+ if (typeof e != "object") return { kind: "unknown" };
12
+ let t = e;
13
+ if ("role" in t && "content" in t) {
14
+ let e = String(t.role), n = typeof t.id == "string" ? t.id : void 0, r = typeof t.stopReason == "string" ? t.stopReason : void 0, i = t.content;
15
+ if (typeof i == "string") return {
16
+ kind: "ui-message",
17
+ role: e,
18
+ messageId: n,
19
+ stopReason: r,
20
+ charCount: i.length
21
+ };
22
+ if (Array.isArray(i)) {
23
+ let t = i, a = /* @__PURE__ */ new Map();
24
+ for (let e of t) {
25
+ let t = a.get(e.type) ?? {
26
+ count: 0,
27
+ labels: []
28
+ };
29
+ t.count += 1, (e.type === "tool_call" || e.type === "server_tool_use") && t.labels.push(e.name), a.set(e.type, t);
30
+ }
31
+ return {
32
+ kind: "ui-message",
33
+ role: e,
34
+ messageId: n,
35
+ stopReason: r,
36
+ charCount: t.reduce((e, t) => t.type === "text" || t.type === "thinking" ? e + t.text.length : t.type === "tool_result" ? e + t.content.length : e, 0),
37
+ blocks: [...a.entries()].map(([e, { count: t, labels: n }]) => ({
38
+ type: e,
39
+ count: t,
40
+ labels: n.length > 0 ? n : void 0
41
+ }))
42
+ };
43
+ }
44
+ }
45
+ return {
46
+ kind: "object",
47
+ topLevelKeys: Object.keys(t),
48
+ charCount: JSON.stringify(e).length
49
+ };
50
+ }
51
+ function extractApiResponseInfo(e) {
52
+ if (!e || typeof e != "object") return {};
53
+ let t = e;
54
+ if (t.usage && typeof t.usage == "object") {
55
+ let e = t.usage;
56
+ return {
57
+ model: typeof t.model == "string" ? t.model : void 0,
58
+ id: typeof t.id == "string" ? t.id : void 0,
59
+ stopReason: typeof t.stop_reason == "string" ? t.stop_reason : void 0,
60
+ usage: {
61
+ input: e.input_tokens,
62
+ output: e.output_tokens,
63
+ cacheRead: e.cache_read_input_tokens,
64
+ cacheWrite: e.cache_creation_input_tokens
65
+ }
66
+ };
67
+ }
68
+ if (Array.isArray(t.choices)) {
69
+ let e = t.choices[0], n = t.usage, r = n?.prompt_tokens_details;
70
+ return {
71
+ model: typeof t.model == "string" ? t.model : void 0,
72
+ id: typeof t.id == "string" ? t.id : void 0,
73
+ stopReason: typeof e?.finish_reason == "string" ? e.finish_reason : void 0,
74
+ usage: n ? {
75
+ input: n.prompt_tokens,
76
+ output: n.completion_tokens,
77
+ cacheRead: r?.cached_tokens,
78
+ reasoning: n.reasoning_tokens
79
+ } : void 0
80
+ };
81
+ }
82
+ return {};
83
+ }
84
+ function formatRelativeTime(e) {
85
+ let t = new Date(e).getTime();
86
+ if (Number.isNaN(t)) return String(e);
87
+ let n = Date.now() - t, r = Math.round(n / 1e3);
88
+ if (r < 60) return `${r}s ago`;
89
+ let i = Math.round(r / 60);
90
+ if (i < 60) return `${i}m ago`;
91
+ let a = Math.round(i / 60);
92
+ return a < 48 ? `${a}h ago` : `${Math.round(a / 24)}d ago`;
93
+ }
94
+ function formatDurationMs(e) {
95
+ return e < 1e3 ? `${e}ms` : e < 6e4 ? `${(e / 1e3).toFixed(1)}s` : `${Math.round(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
96
+ }
97
+ function formatNumber(e) {
98
+ return e == null ? "—" : e.toLocaleString();
99
+ }
100
+ export { extractApiResponseInfo, formatDurationMs, formatNumber, formatRelativeTime, summarizeDocumentContent };
@@ -1,3 +1,4 @@
1
+ import { useDocumentConfigs } from "../../../hooks/useConfig.js";
1
2
  import { Button } from "../../../components/ui/button.js";
2
3
  import { Label } from "../../../components/ui/label.js";
3
4
  import { RadioGroup, RadioGroupItem } from "../../../components/ui/radio-group.js";
@@ -9,29 +10,31 @@ import { c } from "react/compiler-runtime";
9
10
  import React, { useState } from "react";
10
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
12
  import { Loader2 } from "lucide-react";
12
- var ChoicesRenderer_default = (g) => {
13
- let _ = c(26), { parentWorkflow: v, workflow: y, document: b, isActive: x } = g, S = b.content, { submit: C, canSubmit: w, isLoading: T } = useDocumentTransition(v, y, b.ui), [E, D] = useState(S.answer ?? ""), [O, k] = useState(""), A = E === "__custom__", j = !!S.answer, M;
14
- _[0] !== O || _[1] !== A || _[2] !== E || _[3] !== C ? (M = () => {
15
- let t = A ? O.trim() : E;
16
- t && C({ answer: t });
17
- }, _[0] = O, _[1] = A, _[2] = E, _[3] = C, _[4] = M) : M = _[4];
18
- let N = M, P = !x || !w || j, F;
19
- _[5] === b.createdAt ? F = _[6] : (F = new Date(b.createdAt), _[5] = b.createdAt, _[6] = F);
20
- let I;
21
- _[7] === S.question ? I = _[8] : (I = /* @__PURE__ */ jsx(MarkdownContent_default, { content: S.question }), _[7] = S.question, _[8] = I);
22
- let L;
23
- _[9] !== S.allowCustomAnswer || _[10] !== S.answer || _[11] !== S.options || _[12] !== O || _[13] !== P || _[14] !== N || _[15] !== j || _[16] !== A || _[17] !== T || _[18] !== E ? (L = j ? /* @__PURE__ */ jsxs("div", {
13
+ var ChoicesRenderer_default = (_) => {
14
+ let v = c(29), { parentWorkflow: y, workflow: b, document: x, isActive: S } = _, C = x.content, w = useDocumentConfigs(), T;
15
+ v[0] !== x.documentName || v[1] !== w ? (T = w.get(x.documentName), v[0] = x.documentName, v[1] = w, v[2] = T) : T = v[2];
16
+ let { submit: E, canSubmit: D, isLoading: O } = useDocumentTransition(y, b, T), [k, A] = useState(C.answer ?? ""), [j, M] = useState(""), N = k === "__custom__", P = !!C.answer, F;
17
+ v[3] !== j || v[4] !== N || v[5] !== k || v[6] !== E ? (F = () => {
18
+ let t = N ? j.trim() : k;
19
+ t && E({ answer: t });
20
+ }, v[3] = j, v[4] = N, v[5] = k, v[6] = E, v[7] = F) : F = v[7];
21
+ let I = F, L = !S || !D || P, R;
22
+ v[8] === x.createdAt ? R = v[9] : (R = new Date(x.createdAt), v[8] = x.createdAt, v[9] = R);
23
+ let z;
24
+ v[10] === C.question ? z = v[11] : (z = /* @__PURE__ */ jsx(MarkdownContent_default, { content: C.question }), v[10] = C.question, v[11] = z);
25
+ let B;
26
+ v[12] !== C.allowCustomAnswer || v[13] !== C.answer || v[14] !== C.options || v[15] !== j || v[16] !== L || v[17] !== I || v[18] !== P || v[19] !== N || v[20] !== O || v[21] !== k ? (B = P ? /* @__PURE__ */ jsxs("div", {
24
27
  className: "text-muted-foreground text-sm",
25
28
  children: ["Answered: ", /* @__PURE__ */ jsx("span", {
26
29
  className: "text-foreground font-medium",
27
- children: S.answer
30
+ children: C.answer
28
31
  })]
29
32
  }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
30
33
  /* @__PURE__ */ jsxs(RadioGroup, {
31
- value: E,
32
- onValueChange: D,
33
- disabled: P,
34
- children: [S.options.map(_temp), S.allowCustomAnswer && /* @__PURE__ */ jsxs("div", {
34
+ value: k,
35
+ onValueChange: A,
36
+ disabled: L,
37
+ children: [C.options.map(_temp), C.allowCustomAnswer && /* @__PURE__ */ jsxs("div", {
35
38
  className: "flex items-center gap-3",
36
39
  children: [/* @__PURE__ */ jsx(RadioGroupItem, {
37
40
  value: "__custom__",
@@ -43,11 +46,11 @@ var ChoicesRenderer_default = (g) => {
43
46
  })]
44
47
  })]
45
48
  }),
46
- A && /* @__PURE__ */ jsx(Textarea, {
49
+ N && /* @__PURE__ */ jsx(Textarea, {
47
50
  placeholder: "Type your answer...",
48
- value: O,
49
- onChange: (t) => k(t.target.value),
50
- disabled: P,
51
+ value: j,
52
+ onChange: (t) => M(t.target.value),
53
+ disabled: L,
51
54
  className: "min-h-10",
52
55
  rows: 2
53
56
  }),
@@ -56,37 +59,37 @@ var ChoicesRenderer_default = (g) => {
56
59
  children: /* @__PURE__ */ jsxs(Button, {
57
60
  type: "button",
58
61
  variant: "default",
59
- disabled: P || T || !E || A && !O.trim(),
60
- onClick: N,
62
+ disabled: L || O || !k || N && !j.trim(),
63
+ onClick: I,
61
64
  className: "w-48",
62
- children: [T && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "Submit"]
65
+ children: [O && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "Submit"]
63
66
  })
64
67
  })
65
- ] }), _[9] = S.allowCustomAnswer, _[10] = S.answer, _[11] = S.options, _[12] = O, _[13] = P, _[14] = N, _[15] = j, _[16] = A, _[17] = T, _[18] = E, _[19] = L) : L = _[19];
66
- let R;
67
- _[20] !== I || _[21] !== L ? (R = /* @__PURE__ */ jsxs("div", {
68
+ ] }), v[12] = C.allowCustomAnswer, v[13] = C.answer, v[14] = C.options, v[15] = j, v[16] = L, v[17] = I, v[18] = P, v[19] = N, v[20] = O, v[21] = k, v[22] = B) : B = v[22];
69
+ let V;
70
+ v[23] !== z || v[24] !== B ? (V = /* @__PURE__ */ jsxs("div", {
68
71
  className: "flex flex-col gap-4 p-1",
69
- children: [I, L]
70
- }), _[20] = I, _[21] = L, _[22] = R) : R = _[22];
71
- let z;
72
- return _[23] !== F || _[24] !== R ? (z = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
72
+ children: [z, B]
73
+ }), v[23] = z, v[24] = B, v[25] = V) : V = v[25];
74
+ let H;
75
+ return v[26] !== R || v[27] !== V ? (H = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
73
76
  role: "document",
74
77
  fullWidth: !0,
75
- timestamp: F,
76
- children: R
77
- }), _[23] = F, _[24] = R, _[25] = z) : z = _[25], z;
78
+ timestamp: R,
79
+ children: V
80
+ }), v[26] = R, v[27] = V, v[28] = H) : H = v[28], H;
78
81
  };
79
- function _temp(t, h) {
82
+ function _temp(t, g) {
80
83
  return /* @__PURE__ */ jsxs("div", {
81
84
  className: "flex items-center gap-3",
82
85
  children: [/* @__PURE__ */ jsx(RadioGroupItem, {
83
86
  value: t,
84
- id: `option-${h}`
87
+ id: `option-${g}`
85
88
  }), /* @__PURE__ */ jsx(Label, {
86
- htmlFor: `option-${h}`,
89
+ htmlFor: `option-${g}`,
87
90
  className: "cursor-pointer text-sm font-normal",
88
91
  children: t
89
92
  })]
90
- }, h);
93
+ }, g);
91
94
  }
92
95
  export { ChoicesRenderer_default as default };
@@ -1,3 +1,4 @@
1
+ import { useDocumentConfigs } from "../../../hooks/useConfig.js";
1
2
  import { Button } from "../../../components/ui/button.js";
2
3
  import CompletionMessagePaper_default from "../../../components/messages/CompletionMessagePaper.js";
3
4
  import MarkdownContent_default from "../../../components/dynamic-form/MarkdownContent.js";
@@ -6,51 +7,53 @@ import { c } from "react/compiler-runtime";
6
7
  import React from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { Loader2 } from "lucide-react";
9
- var ConfirmPromptRenderer_default = (l) => {
10
- let u = c(18), { parentWorkflow: d, workflow: f, document: p, isActive: m } = l, h = p.content, { submit: g, canSubmit: _, isLoading: v } = useDocumentTransition(d, f, p.ui), y = !!h.answer, b = !m || !_ || y, x;
11
- u[0] === g ? x = u[1] : (x = (t) => {
12
- g({ answer: t });
13
- }, u[0] = g, u[1] = x);
14
- let S = x, C;
15
- u[2] === p.createdAt ? C = u[3] : (C = new Date(p.createdAt), u[2] = p.createdAt, u[3] = C);
16
- let w;
17
- u[4] === h.question ? w = u[5] : (w = /* @__PURE__ */ jsx(MarkdownContent_default, { content: h.question }), u[4] = h.question, u[5] = w);
18
- let T;
19
- u[6] !== h.answer || u[7] !== b || u[8] !== S || u[9] !== y || u[10] !== v ? (T = y ? /* @__PURE__ */ jsxs("div", {
10
+ var ConfirmPromptRenderer_default = (u) => {
11
+ let d = c(21), { parentWorkflow: f, workflow: p, document: m, isActive: h } = u, g = m.content, _ = useDocumentConfigs(), v;
12
+ d[0] !== m.documentName || d[1] !== _ ? (v = _.get(m.documentName), d[0] = m.documentName, d[1] = _, d[2] = v) : v = d[2];
13
+ let { submit: y, canSubmit: b, isLoading: x } = useDocumentTransition(f, p, v), S = !!g.answer, C = !h || !b || S, w;
14
+ d[3] === y ? w = d[4] : (w = (t) => {
15
+ y({ answer: t });
16
+ }, d[3] = y, d[4] = w);
17
+ let T = w, E;
18
+ d[5] === m.createdAt ? E = d[6] : (E = new Date(m.createdAt), d[5] = m.createdAt, d[6] = E);
19
+ let D;
20
+ d[7] === g.question ? D = d[8] : (D = /* @__PURE__ */ jsx(MarkdownContent_default, { content: g.question }), d[7] = g.question, d[8] = D);
21
+ let O;
22
+ d[9] !== g.answer || d[10] !== C || d[11] !== T || d[12] !== S || d[13] !== x ? (O = S ? /* @__PURE__ */ jsxs("div", {
20
23
  className: "text-muted-foreground text-sm",
21
24
  children: ["Answered: ", /* @__PURE__ */ jsx("span", {
22
25
  className: "text-foreground font-medium",
23
- children: h.answer === "yes" ? "Yes" : "No"
26
+ children: g.answer === "yes" ? "Yes" : "No"
24
27
  })]
25
28
  }) : /* @__PURE__ */ jsxs("div", {
26
29
  className: "flex justify-end gap-3",
27
30
  children: [/* @__PURE__ */ jsxs(Button, {
28
31
  type: "button",
29
32
  variant: "outline",
30
- disabled: b || v,
31
- onClick: () => S("no"),
33
+ disabled: C || x,
34
+ onClick: () => T("no"),
32
35
  className: "w-32",
33
- children: [v && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "No"]
36
+ children: [x && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "No"]
34
37
  }), /* @__PURE__ */ jsxs(Button, {
35
38
  type: "button",
36
39
  variant: "default",
37
- disabled: b || v,
38
- onClick: () => S("yes"),
40
+ disabled: C || x,
41
+ onClick: () => T("yes"),
39
42
  className: "w-32",
40
- children: [v && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "Yes"]
43
+ children: [x && /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "Yes"]
41
44
  })]
42
- }), u[6] = h.answer, u[7] = b, u[8] = S, u[9] = y, u[10] = v, u[11] = T) : T = u[11];
43
- let E;
44
- u[12] !== w || u[13] !== T ? (E = /* @__PURE__ */ jsxs("div", {
45
+ }), d[9] = g.answer, d[10] = C, d[11] = T, d[12] = S, d[13] = x, d[14] = O) : O = d[14];
46
+ let k;
47
+ d[15] !== D || d[16] !== O ? (k = /* @__PURE__ */ jsxs("div", {
45
48
  className: "flex flex-col gap-4 p-1",
46
- children: [w, T]
47
- }), u[12] = w, u[13] = T, u[14] = E) : E = u[14];
48
- let D;
49
- return u[15] !== C || u[16] !== E ? (D = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
49
+ children: [D, O]
50
+ }), d[15] = D, d[16] = O, d[17] = k) : k = d[17];
51
+ let A;
52
+ return d[18] !== E || d[19] !== k ? (A = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
50
53
  role: "document",
51
54
  fullWidth: !0,
52
- timestamp: C,
53
- children: E
54
- }), u[15] = C, u[16] = E, u[17] = D) : D = u[17], D;
55
+ timestamp: E,
56
+ children: k
57
+ }), d[18] = E, d[19] = k, d[20] = A) : A = d[20], A;
55
58
  };
56
59
  export { ConfirmPromptRenderer_default as default };