@corbits/react-ui 0.1.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 (255) hide show
  1. package/LICENSE +501 -0
  2. package/README.md +125 -0
  3. package/dist/blocks/login/auth-layout.d.ts +38 -0
  4. package/dist/blocks/login/auth-layout.js +52 -0
  5. package/dist/blocks/login/login-form.d.ts +60 -0
  6. package/dist/blocks/login/login-form.js +151 -0
  7. package/dist/hooks/use-command-palette-navigation.d.ts +25 -0
  8. package/dist/hooks/use-command-palette-navigation.js +52 -0
  9. package/dist/hooks/use-controllable-state.d.ts +28 -0
  10. package/dist/hooks/use-controllable-state.js +44 -0
  11. package/dist/hooks/use-delayed-autofocus.d.ts +9 -0
  12. package/dist/hooks/use-delayed-autofocus.js +20 -0
  13. package/dist/hooks/use-dismissable-popover.d.ts +37 -0
  14. package/dist/hooks/use-dismissable-popover.js +64 -0
  15. package/dist/hooks/use-list-selection.d.ts +66 -0
  16. package/dist/hooks/use-list-selection.js +147 -0
  17. package/dist/hooks/use-prefers-reduced-motion.d.ts +13 -0
  18. package/dist/hooks/use-prefers-reduced-motion.js +28 -0
  19. package/dist/hooks/use-scroll-current-into-view.d.ts +19 -0
  20. package/dist/hooks/use-scroll-current-into-view.js +33 -0
  21. package/dist/index.d.ts +122 -0
  22. package/dist/index.js +131 -0
  23. package/dist/lib/artifact.d.ts +72 -0
  24. package/dist/lib/artifact.js +67 -0
  25. package/dist/lib/chart-geometry.d.ts +62 -0
  26. package/dist/lib/chart-geometry.js +86 -0
  27. package/dist/lib/chart-palette.d.ts +76 -0
  28. package/dist/lib/chart-palette.js +92 -0
  29. package/dist/lib/chat-message.d.ts +115 -0
  30. package/dist/lib/chat-message.js +41 -0
  31. package/dist/lib/chat-parts.d.ts +64 -0
  32. package/dist/lib/chat-parts.js +16 -0
  33. package/dist/lib/csv.d.ts +60 -0
  34. package/dist/lib/csv.js +108 -0
  35. package/dist/lib/metrics.d.ts +70 -0
  36. package/dist/lib/metrics.js +101 -0
  37. package/dist/lib/now-item.d.ts +65 -0
  38. package/dist/lib/now-item.js +59 -0
  39. package/dist/lib/relative-time.d.ts +9 -0
  40. package/dist/lib/relative-time.js +47 -0
  41. package/dist/lib/theme.d.ts +30 -0
  42. package/dist/lib/theme.js +77 -0
  43. package/dist/lib/url.d.ts +26 -0
  44. package/dist/lib/url.js +37 -0
  45. package/dist/lib/utils.d.ts +2 -0
  46. package/dist/lib/utils.js +5 -0
  47. package/dist/lib/workflow-display-flow.d.ts +83 -0
  48. package/dist/lib/workflow-display-flow.js +104 -0
  49. package/dist/lib/workflow-registry.d.ts +90 -0
  50. package/dist/lib/workflow-registry.js +56 -0
  51. package/dist/lib/workflow-run-error.d.ts +31 -0
  52. package/dist/lib/workflow-run-error.js +105 -0
  53. package/dist/lib/workflow-run-progress.d.ts +97 -0
  54. package/dist/lib/workflow-run-progress.js +135 -0
  55. package/dist/lib/workflow-run.d.ts +43 -0
  56. package/dist/lib/workflow-run.js +56 -0
  57. package/dist/styles.css +3080 -0
  58. package/dist/test/render-hook.d.ts +14 -0
  59. package/dist/test/render-hook.js +38 -0
  60. package/dist/theme.css +628 -0
  61. package/dist/ui/agent-turn.d.ts +26 -0
  62. package/dist/ui/agent-turn.js +60 -0
  63. package/dist/ui/animated-number.d.ts +25 -0
  64. package/dist/ui/animated-number.js +63 -0
  65. package/dist/ui/approval-card.d.ts +46 -0
  66. package/dist/ui/approval-card.js +116 -0
  67. package/dist/ui/artifact-body.d.ts +26 -0
  68. package/dist/ui/artifact-body.js +170 -0
  69. package/dist/ui/artifact-notice.d.ts +21 -0
  70. package/dist/ui/artifact-notice.js +36 -0
  71. package/dist/ui/avatar.d.ts +37 -0
  72. package/dist/ui/avatar.js +73 -0
  73. package/dist/ui/badge.d.ts +10 -0
  74. package/dist/ui/badge.js +35 -0
  75. package/dist/ui/bar-chart.d.ts +38 -0
  76. package/dist/ui/bar-chart.js +118 -0
  77. package/dist/ui/block-card.d.ts +29 -0
  78. package/dist/ui/block-card.js +66 -0
  79. package/dist/ui/boot-screen.d.ts +23 -0
  80. package/dist/ui/boot-screen.js +49 -0
  81. package/dist/ui/bulk-action-bar.d.ts +37 -0
  82. package/dist/ui/bulk-action-bar.js +64 -0
  83. package/dist/ui/button.d.ts +12 -0
  84. package/dist/ui/button.js +73 -0
  85. package/dist/ui/card.d.ts +6 -0
  86. package/dist/ui/card.js +37 -0
  87. package/dist/ui/category-bars.d.ts +20 -0
  88. package/dist/ui/category-bars.js +69 -0
  89. package/dist/ui/chart-frame.d.ts +54 -0
  90. package/dist/ui/chart-frame.js +108 -0
  91. package/dist/ui/chat-composer.d.ts +24 -0
  92. package/dist/ui/chat-composer.js +32 -0
  93. package/dist/ui/chat-dock-timing.d.ts +15 -0
  94. package/dist/ui/chat-dock-timing.js +11 -0
  95. package/dist/ui/chat-input.d.ts +38 -0
  96. package/dist/ui/chat-input.js +138 -0
  97. package/dist/ui/chat-panel.d.ts +20 -0
  98. package/dist/ui/chat-panel.js +56 -0
  99. package/dist/ui/chat-thread.d.ts +28 -0
  100. package/dist/ui/chat-thread.js +61 -0
  101. package/dist/ui/checkbox.d.ts +25 -0
  102. package/dist/ui/checkbox.js +63 -0
  103. package/dist/ui/command-palette.d.ts +100 -0
  104. package/dist/ui/command-palette.js +341 -0
  105. package/dist/ui/compare-body.d.ts +52 -0
  106. package/dist/ui/compare-body.js +140 -0
  107. package/dist/ui/confirm-button.d.ts +29 -0
  108. package/dist/ui/confirm-button.js +41 -0
  109. package/dist/ui/corbits-mark.d.ts +29 -0
  110. package/dist/ui/corbits-mark.js +33 -0
  111. package/dist/ui/csv-table.d.ts +22 -0
  112. package/dist/ui/csv-table.js +85 -0
  113. package/dist/ui/dialog.d.ts +37 -0
  114. package/dist/ui/dialog.js +105 -0
  115. package/dist/ui/dictation-status-line.d.ts +20 -0
  116. package/dist/ui/dictation-status-line.js +38 -0
  117. package/dist/ui/dither-canvas.d.ts +31 -0
  118. package/dist/ui/dither-canvas.js +169 -0
  119. package/dist/ui/embed-body.d.ts +30 -0
  120. package/dist/ui/embed-body.js +92 -0
  121. package/dist/ui/empty-state.d.ts +26 -0
  122. package/dist/ui/empty-state.js +42 -0
  123. package/dist/ui/file-input.d.ts +25 -0
  124. package/dist/ui/file-input.js +66 -0
  125. package/dist/ui/filter-bar.d.ts +42 -0
  126. package/dist/ui/filter-bar.js +95 -0
  127. package/dist/ui/filter-chip.d.ts +14 -0
  128. package/dist/ui/filter-chip.js +23 -0
  129. package/dist/ui/gate-block.d.ts +16 -0
  130. package/dist/ui/gate-block.js +37 -0
  131. package/dist/ui/horizontal-stepper.d.ts +13 -0
  132. package/dist/ui/horizontal-stepper.js +65 -0
  133. package/dist/ui/input.d.ts +2 -0
  134. package/dist/ui/input.js +14 -0
  135. package/dist/ui/inspector-shell.d.ts +47 -0
  136. package/dist/ui/inspector-shell.js +98 -0
  137. package/dist/ui/intake-form.d.ts +39 -0
  138. package/dist/ui/intake-form.js +119 -0
  139. package/dist/ui/kind-card-grid.d.ts +23 -0
  140. package/dist/ui/kind-card-grid.js +43 -0
  141. package/dist/ui/library-page-header.d.ts +20 -0
  142. package/dist/ui/library-page-header.js +43 -0
  143. package/dist/ui/list-detail.d.ts +28 -0
  144. package/dist/ui/list-detail.js +55 -0
  145. package/dist/ui/live-run-banner.d.ts +13 -0
  146. package/dist/ui/live-run-banner.js +23 -0
  147. package/dist/ui/live-status-line.d.ts +22 -0
  148. package/dist/ui/live-status-line.js +37 -0
  149. package/dist/ui/menu.d.ts +18 -0
  150. package/dist/ui/menu.js +45 -0
  151. package/dist/ui/message-bubble.d.ts +24 -0
  152. package/dist/ui/message-bubble.js +64 -0
  153. package/dist/ui/mic-button.d.ts +35 -0
  154. package/dist/ui/mic-button.js +61 -0
  155. package/dist/ui/mic-permission-dialog.d.ts +20 -0
  156. package/dist/ui/mic-permission-dialog.js +50 -0
  157. package/dist/ui/notifications-bell.d.ts +28 -0
  158. package/dist/ui/notifications-bell.js +69 -0
  159. package/dist/ui/now-cards.d.ts +37 -0
  160. package/dist/ui/now-cards.js +116 -0
  161. package/dist/ui/page-panel.d.ts +37 -0
  162. package/dist/ui/page-panel.js +23 -0
  163. package/dist/ui/page-shell.d.ts +21 -0
  164. package/dist/ui/page-shell.js +26 -0
  165. package/dist/ui/parts-renderer.d.ts +22 -0
  166. package/dist/ui/parts-renderer.js +234 -0
  167. package/dist/ui/profile-card.d.ts +39 -0
  168. package/dist/ui/profile-card.js +124 -0
  169. package/dist/ui/progress-checklist.d.ts +25 -0
  170. package/dist/ui/progress-checklist.js +70 -0
  171. package/dist/ui/provider-mark.d.ts +32 -0
  172. package/dist/ui/provider-mark.js +31 -0
  173. package/dist/ui/quick-reply-chips.d.ts +14 -0
  174. package/dist/ui/quick-reply-chips.js +24 -0
  175. package/dist/ui/quote-card.d.ts +39 -0
  176. package/dist/ui/quote-card.js +66 -0
  177. package/dist/ui/reasoning-block.d.ts +35 -0
  178. package/dist/ui/reasoning-block.js +60 -0
  179. package/dist/ui/research-body.d.ts +70 -0
  180. package/dist/ui/research-body.js +270 -0
  181. package/dist/ui/rich-empty-state.d.ts +35 -0
  182. package/dist/ui/rich-empty-state.js +65 -0
  183. package/dist/ui/run-now-button.d.ts +23 -0
  184. package/dist/ui/run-now-button.js +42 -0
  185. package/dist/ui/section.d.ts +20 -0
  186. package/dist/ui/section.js +48 -0
  187. package/dist/ui/select.d.ts +2 -0
  188. package/dist/ui/select.js +22 -0
  189. package/dist/ui/selection-checkbox.d.ts +42 -0
  190. package/dist/ui/selection-checkbox.js +54 -0
  191. package/dist/ui/settings-panel.d.ts +35 -0
  192. package/dist/ui/settings-panel.js +68 -0
  193. package/dist/ui/shimmer-text.d.ts +19 -0
  194. package/dist/ui/shimmer-text.js +20 -0
  195. package/dist/ui/sidebar-item-row.d.ts +40 -0
  196. package/dist/ui/sidebar-item-row.js +64 -0
  197. package/dist/ui/sidebar-panel.d.ts +25 -0
  198. package/dist/ui/sidebar-panel.js +56 -0
  199. package/dist/ui/sidebar.d.ts +46 -0
  200. package/dist/ui/sidebar.js +111 -0
  201. package/dist/ui/skeleton.d.ts +13 -0
  202. package/dist/ui/skeleton.js +20 -0
  203. package/dist/ui/sortable-table.d.ts +43 -0
  204. package/dist/ui/sortable-table.js +103 -0
  205. package/dist/ui/sparkline.d.ts +27 -0
  206. package/dist/ui/sparkline.js +68 -0
  207. package/dist/ui/stat-grid.d.ts +55 -0
  208. package/dist/ui/stat-grid.js +87 -0
  209. package/dist/ui/status-dot.d.ts +13 -0
  210. package/dist/ui/status-dot.js +51 -0
  211. package/dist/ui/step-list.d.ts +21 -0
  212. package/dist/ui/step-list.js +77 -0
  213. package/dist/ui/switch.d.ts +23 -0
  214. package/dist/ui/switch.js +29 -0
  215. package/dist/ui/table.d.ts +8 -0
  216. package/dist/ui/table.js +48 -0
  217. package/dist/ui/tabs.d.ts +44 -0
  218. package/dist/ui/tabs.js +101 -0
  219. package/dist/ui/textarea.d.ts +8 -0
  220. package/dist/ui/textarea.js +32 -0
  221. package/dist/ui/theme-provider.d.ts +36 -0
  222. package/dist/ui/theme-provider.js +126 -0
  223. package/dist/ui/theme-toggle.d.ts +11 -0
  224. package/dist/ui/theme-toggle.js +32 -0
  225. package/dist/ui/thinking-indicator.d.ts +7 -0
  226. package/dist/ui/thinking-indicator.js +19 -0
  227. package/dist/ui/thinking-label.d.ts +19 -0
  228. package/dist/ui/thinking-label.js +54 -0
  229. package/dist/ui/thinking-mark.d.ts +10 -0
  230. package/dist/ui/thinking-mark.js +153 -0
  231. package/dist/ui/time-series-chart.d.ts +55 -0
  232. package/dist/ui/time-series-chart.js +249 -0
  233. package/dist/ui/toast.d.ts +16 -0
  234. package/dist/ui/toast.js +41 -0
  235. package/dist/ui/token-mosaic.d.ts +22 -0
  236. package/dist/ui/token-mosaic.js +65 -0
  237. package/dist/ui/tool-block.d.ts +54 -0
  238. package/dist/ui/tool-block.js +170 -0
  239. package/dist/ui/tool-narrative.d.ts +22 -0
  240. package/dist/ui/tool-narrative.js +77 -0
  241. package/dist/ui/tool-picker.d.ts +44 -0
  242. package/dist/ui/tool-picker.js +200 -0
  243. package/dist/ui/tooltip.d.ts +21 -0
  244. package/dist/ui/tooltip.js +48 -0
  245. package/dist/ui/top-bar.d.ts +53 -0
  246. package/dist/ui/top-bar.js +98 -0
  247. package/dist/ui/trace-waterfall.d.ts +38 -0
  248. package/dist/ui/trace-waterfall.js +121 -0
  249. package/dist/ui/typing-indicator.d.ts +9 -0
  250. package/dist/ui/typing-indicator.js +25 -0
  251. package/dist/ui/view-toggle.d.ts +17 -0
  252. package/dist/ui/view-toggle.js +46 -0
  253. package/dist/ui/voice-waveform.d.ts +16 -0
  254. package/dist/ui/voice-waveform.js +23 -0
  255. package/package.json +583 -0
@@ -0,0 +1,83 @@
1
+ import type { StepDisplayStatus, StepListItem } from "./workflow-registry.js";
2
+ /**
3
+ * How a display step behaves at runtime — a renderer-facing vocabulary for
4
+ * drawing a gate differently from a sleep differently from a child-workflow
5
+ * spawn, independent of whatever primitive-kind enum the host's workflow
6
+ * engine uses internally.
7
+ */
8
+ export type DisplayStepCharacter = "deterministic" | "reasoning" | "gate" | "await" | "action" | "sleep" | "child" | "other";
9
+ /** One display step derived from a single runtime primitive. `after` is
10
+ * carried through unmodified so a renderer can lay out parallel branches
11
+ * honestly instead of flattening the DAG into a single line. */
12
+ export type DisplayFlowStep = {
13
+ readonly stepId: string;
14
+ readonly label: string;
15
+ readonly character: DisplayStepCharacter;
16
+ readonly after: readonly string[];
17
+ };
18
+ /** The full derived display model for one workflow definition, already in
19
+ * run order. */
20
+ export type DisplayFlow = {
21
+ readonly steps: readonly DisplayFlowStep[];
22
+ };
23
+ /**
24
+ * What `deriveDisplayFlow` needs to know about one runtime primitive. The
25
+ * host's workflow engine owns the real primitive-kind enum and any
26
+ * author-tagging convention for a friendlier label or a deterministic flag —
27
+ * this shape asks the host to resolve those once, at the boundary, rather
28
+ * than importing the host's tag vocabulary in here.
29
+ */
30
+ export type WorkflowStepPrimitive = {
31
+ readonly stepId: string;
32
+ readonly kind: "step" | "map" | "gate" | "awaitSignal" | "escalation" | "sleep" | "childWorkflow" | "action" | "other";
33
+ /** Already-humanised label. The step id is used verbatim when omitted. */
34
+ readonly label?: string;
35
+ readonly after?: readonly string[];
36
+ /** True for a `step`/`map` primitive the host tags as deterministic tool
37
+ * work rather than a model call — everything else defaults to `reasoning`. */
38
+ readonly deterministic?: boolean;
39
+ };
40
+ /**
41
+ * Projects a workflow's runtime primitives into one display step per
42
+ * primitive, in the order given. The host resolves each primitive's label
43
+ * and deterministic flag before calling this — that keeps any
44
+ * author-tagging convention (a legacy tag, a metadata field) out of a
45
+ * published library, where the tag vocabulary would become part of the
46
+ * public surface.
47
+ */
48
+ export declare function deriveDisplayFlow(primitives: readonly WorkflowStepPrimitive[]): DisplayFlow;
49
+ /** A curated group of runtime steps, as declared by whoever authored the
50
+ * curation (a workflow author, a preview overlay). */
51
+ export type DisplayOverlayGroup = {
52
+ readonly key: string;
53
+ readonly label: string;
54
+ readonly steps: readonly string[];
55
+ readonly activityLabel?: string;
56
+ };
57
+ export type DisplayOverlay = {
58
+ readonly groups: readonly DisplayOverlayGroup[];
59
+ };
60
+ /** One curated group after applying a `DisplayOverlay` to a `DisplayFlow`. */
61
+ export type OverlaidDisplayStep = {
62
+ readonly key: string;
63
+ readonly label: string;
64
+ readonly character: DisplayStepCharacter;
65
+ readonly stepIds: readonly string[];
66
+ readonly activityLabel?: string;
67
+ };
68
+ export type OverlaidDisplayFlow = {
69
+ readonly groups: readonly OverlaidDisplayStep[];
70
+ };
71
+ /**
72
+ * Curates a derived `DisplayFlow` into an author's declared groups. Every
73
+ * group's `steps` is validated against the flow's actual step ids — an
74
+ * unknown id throws immediately rather than silently producing an empty or
75
+ * partial group.
76
+ */
77
+ export declare function applyDisplayOverlay(flow: DisplayFlow, overlay: DisplayOverlay): OverlaidDisplayFlow;
78
+ /**
79
+ * Maps pure display-flow steps into `StepList` items, all `pending` unless a
80
+ * status lookup is given — the host overlays real run state on top once it
81
+ * has any.
82
+ */
83
+ export declare function stepListFromDisplayFlow(steps: readonly DisplayFlowStep[], statusById?: ReadonlyMap<string, StepDisplayStatus> | Record<string, StepDisplayStatus>): StepListItem[];
@@ -0,0 +1,104 @@
1
+ function characterOf(primitive) {
2
+ switch(primitive.kind){
3
+ case "step":
4
+ case "map":
5
+ return primitive.deterministic === true ? "deterministic" : "reasoning";
6
+ case "gate":
7
+ return "gate";
8
+ case "awaitSignal":
9
+ case "escalation":
10
+ return "await";
11
+ case "sleep":
12
+ return "sleep";
13
+ case "childWorkflow":
14
+ return "child";
15
+ case "action":
16
+ return "action";
17
+ default:
18
+ return "other";
19
+ }
20
+ }
21
+ /**
22
+ * Projects a workflow's runtime primitives into one display step per
23
+ * primitive, in the order given. The host resolves each primitive's label
24
+ * and deterministic flag before calling this — that keeps any
25
+ * author-tagging convention (a legacy tag, a metadata field) out of a
26
+ * published library, where the tag vocabulary would become part of the
27
+ * public surface.
28
+ */ export function deriveDisplayFlow(primitives) {
29
+ return {
30
+ steps: primitives.map((primitive)=>({
31
+ stepId: primitive.stepId,
32
+ label: primitive.label ?? primitive.stepId,
33
+ character: characterOf(primitive),
34
+ after: primitive.after ?? []
35
+ }))
36
+ };
37
+ }
38
+ /**
39
+ * Aggregation priority when a curated group clusters several runtime steps
40
+ * with different characters — the strongest signal wins so a group never
41
+ * under-represents itself (a group containing one human `await` step reads
42
+ * as `await` even if every other step in it is `deterministic`).
43
+ */ const CHARACTER_PRIORITY = [
44
+ "await",
45
+ "gate",
46
+ "child",
47
+ "action",
48
+ "reasoning",
49
+ "sleep",
50
+ "deterministic",
51
+ "other"
52
+ ];
53
+ function aggregateCharacter(characters) {
54
+ for (const candidate of CHARACTER_PRIORITY){
55
+ if (characters.includes(candidate)) return candidate;
56
+ }
57
+ return "other";
58
+ }
59
+ /**
60
+ * Curates a derived `DisplayFlow` into an author's declared groups. Every
61
+ * group's `steps` is validated against the flow's actual step ids — an
62
+ * unknown id throws immediately rather than silently producing an empty or
63
+ * partial group.
64
+ */ export function applyDisplayOverlay(flow, overlay) {
65
+ const byId = new Map(flow.steps.map((step)=>[
66
+ step.stepId,
67
+ step
68
+ ]));
69
+ const groups = overlay.groups.map((group)=>{
70
+ const characters = [];
71
+ for (const stepId of group.steps){
72
+ const step = byId.get(stepId);
73
+ if (step === undefined) {
74
+ throw new Error(`display overlay group ${JSON.stringify(group.key)} references unknown step ${JSON.stringify(stepId)}`);
75
+ }
76
+ characters.push(step.character);
77
+ }
78
+ return {
79
+ key: group.key,
80
+ label: group.label,
81
+ character: aggregateCharacter(characters),
82
+ stepIds: group.steps,
83
+ ...group.activityLabel !== undefined ? {
84
+ activityLabel: group.activityLabel
85
+ } : {}
86
+ };
87
+ });
88
+ return {
89
+ groups
90
+ };
91
+ }
92
+ /**
93
+ * Maps pure display-flow steps into `StepList` items, all `pending` unless a
94
+ * status lookup is given — the host overlays real run state on top once it
95
+ * has any.
96
+ */ export function stepListFromDisplayFlow(steps, statusById) {
97
+ const lookup = statusById instanceof Map ? (id)=>statusById.get(id) : statusById !== undefined ? (id)=>statusById[id] : ()=>undefined;
98
+ return steps.map((step)=>({
99
+ id: step.stepId,
100
+ name: step.label,
101
+ status: lookup(step.stepId) ?? "pending",
102
+ character: step.character
103
+ }));
104
+ }
@@ -0,0 +1,90 @@
1
+ import type { BadgeTone } from "../ui/badge.js";
2
+ import type { StatusDotTone } from "../ui/status-dot.js";
3
+ import type { DisplayStepCharacter } from "./workflow-display-flow.js";
4
+ /**
5
+ * Shapes for the unified workflows registry surface: a combined list of live
6
+ * runs and schedules, plus the inspector and picker that sit next to it.
7
+ *
8
+ * `WorkflowScope` and `WorkflowStatusTone` are a coarser vocabulary than
9
+ * `RunStatus` in `workflow-run.ts` — that module models one run's lifecycle
10
+ * (`provisioning` through `stopped`) for the active-runs dock; this module
11
+ * models the tone a *list row or inspector chip* renders, which collapses a
12
+ * schedule's paused/active state and a run's phase onto the same five tones.
13
+ * They are deliberately not merged: a dock strip and a combined registry list
14
+ * answer different questions about the same underlying runs.
15
+ */
16
+ export type WorkflowScope = "personal" | "tenant";
17
+ export type WorkflowStatusTone = "running" | "awaiting" | "done" | "paused" | "fail";
18
+ export declare const WORKFLOW_STATUS_LABEL: Record<WorkflowStatusTone, string>;
19
+ /** Badge tone for a status chip composed as `<Badge tone={...}><StatusDot .../>{label}</Badge>`. */
20
+ export declare const WORKFLOW_STATUS_BADGE_TONE: Record<WorkflowStatusTone, BadgeTone>;
21
+ /** Dot tone for the same chip — see `status-dot.tsx` for why only three exist. */
22
+ export declare const WORKFLOW_STATUS_DOT_TONE: Record<WorkflowStatusTone, StatusDotTone>;
23
+ /** Whether a status tone's dot pulses by default — the two tones that are
24
+ * still moving or still waiting on someone. A caller composing `Badge` +
25
+ * `StatusDot` directly (there is no `StatusChip` component) passes this as
26
+ * `StatusDot`'s `live` prop unless it has a more specific signal. */
27
+ export declare function workflowStatusLive(tone: WorkflowStatusTone): boolean;
28
+ export declare function workflowScopeLabel(scope: WorkflowScope): string;
29
+ /** Badge tone for a workflow's scope. `tenant` gets the info tone so it reads
30
+ * as shared infrastructure; `personal` gets the accent tone that marks
31
+ * "yours" everywhere else in the registry. */
32
+ export declare const WORKFLOW_SCOPE_BADGE_TONE: Record<WorkflowScope, BadgeTone>;
33
+ /** A live run's phase as an inspector or list row reports it — a coarser
34
+ * vocabulary than `RunStatus` in `workflow-run.ts` (no `provisioning`), for
35
+ * surfaces that only distinguish what a reader can act on. */
36
+ export type LiveRunPhase = "running" | "awaiting" | "completed" | "failed" | "cancelled";
37
+ export declare const LIVE_RUN_PHASE_TONE: Record<LiveRunPhase, WorkflowStatusTone>;
38
+ export declare const LIVE_RUN_PHASE_LABEL: Record<LiveRunPhase, string>;
39
+ export type WorkflowListItemKind = "run" | "schedule";
40
+ /** One dense row in the combined live-runs-and-schedules list. */
41
+ export type WorkflowListItem = {
42
+ readonly id: string;
43
+ readonly itemKind: WorkflowListItemKind;
44
+ /** Primary label — the workflow's kind, already humanised. */
45
+ readonly title: string;
46
+ /** Secondary line under the title: an alias, an origin tag. */
47
+ readonly subtitle?: string;
48
+ /** The "when" column: origin phrase for a run, cadence for a schedule. */
49
+ readonly when: string;
50
+ readonly scope: WorkflowScope;
51
+ readonly statusTone: WorkflowStatusTone;
52
+ readonly statusLabel: string;
53
+ /** Next-fire or elapsed text, already formatted by the caller. */
54
+ readonly nextOrElapsed: string;
55
+ /** Highlights `nextOrElapsed` — the next fire is close, or the run is fresh. */
56
+ readonly nextSoon?: boolean;
57
+ /** A live run parked on a human decision gets a subtle accent stripe. */
58
+ readonly needsYou?: boolean;
59
+ };
60
+ export type GateKind = "reviewList" | "choice" | "form" | "multiSelect";
61
+ export declare const GATE_KIND_LABEL: Record<GateKind, string>;
62
+ /** Shell model for a pending gate; the interactive payload is the caller's. */
63
+ export type GateShellModel = {
64
+ readonly kind: GateKind;
65
+ readonly title: string;
66
+ readonly prompt?: string;
67
+ };
68
+ /** One offering in a workflow-kind picker (distinct from `WorkflowOffering` in
69
+ * `workflow-catalog.tsx`, which drives the run-once grid): this shape adds
70
+ * category grouping and an "already on" badge for a picker that lists kinds
71
+ * to attach to a schedule or an automation rather than to run once. */
72
+ export type KindPickerItem = {
73
+ readonly id: string;
74
+ readonly label: string;
75
+ readonly description: string;
76
+ /** Grouping key. Omit when every item shares one category. */
77
+ readonly category?: string;
78
+ readonly categoryLabel?: string;
79
+ readonly alreadyOn?: boolean;
80
+ readonly alreadyOnLabel?: string;
81
+ };
82
+ export type StepDisplayStatus = "pending" | "active" | "done" | "failed";
83
+ /** One step row in the live inspector's step list. */
84
+ export type StepListItem = {
85
+ readonly id: string;
86
+ readonly name: string;
87
+ readonly status: StepDisplayStatus;
88
+ readonly meta?: string;
89
+ readonly character?: DisplayStepCharacter;
90
+ };
@@ -0,0 +1,56 @@
1
+ export const WORKFLOW_STATUS_LABEL = {
2
+ running: "Running",
3
+ awaiting: "Needs you",
4
+ done: "Done",
5
+ paused: "Paused",
6
+ fail: "Failed"
7
+ };
8
+ /** Badge tone for a status chip composed as `<Badge tone={...}><StatusDot .../>{label}</Badge>`. */ export const WORKFLOW_STATUS_BADGE_TONE = {
9
+ running: "info",
10
+ awaiting: "accent",
11
+ done: "success",
12
+ paused: "neutral",
13
+ fail: "danger"
14
+ };
15
+ /** Dot tone for the same chip — see `status-dot.tsx` for why only three exist. */ export const WORKFLOW_STATUS_DOT_TONE = {
16
+ running: "emphasis",
17
+ awaiting: "emphasis",
18
+ done: "neutral",
19
+ paused: "neutral",
20
+ fail: "danger"
21
+ };
22
+ /** Whether a status tone's dot pulses by default — the two tones that are
23
+ * still moving or still waiting on someone. A caller composing `Badge` +
24
+ * `StatusDot` directly (there is no `StatusChip` component) passes this as
25
+ * `StatusDot`'s `live` prop unless it has a more specific signal. */ export function workflowStatusLive(tone) {
26
+ return tone === "running" || tone === "awaiting";
27
+ }
28
+ export function workflowScopeLabel(scope) {
29
+ return scope === "tenant" ? "Everyone" : "Just me";
30
+ }
31
+ /** Badge tone for a workflow's scope. `tenant` gets the info tone so it reads
32
+ * as shared infrastructure; `personal` gets the accent tone that marks
33
+ * "yours" everywhere else in the registry. */ export const WORKFLOW_SCOPE_BADGE_TONE = {
34
+ tenant: "info",
35
+ personal: "accent"
36
+ };
37
+ export const LIVE_RUN_PHASE_TONE = {
38
+ running: "running",
39
+ awaiting: "awaiting",
40
+ completed: "done",
41
+ failed: "fail",
42
+ cancelled: "fail"
43
+ };
44
+ export const LIVE_RUN_PHASE_LABEL = {
45
+ running: "Running",
46
+ awaiting: "Needs you",
47
+ completed: "Done",
48
+ failed: "Failed",
49
+ cancelled: "Cancelled"
50
+ };
51
+ export const GATE_KIND_LABEL = {
52
+ reviewList: "Needs you · review",
53
+ choice: "Needs you · choice",
54
+ form: "Needs you · form",
55
+ multiSelect: "Needs you · select"
56
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Classification/sanitization boundary for a failed step's raw error text.
3
+ *
4
+ * A step's own thrown error can carry internal identifiers, stack fragments
5
+ * or internal hostnames, and nothing user-facing may render it as-is.
6
+ * `classifyRunError` maps the known-safe shapes — a `"<Provider> API error:
7
+ * <status> …"` tool-package convention, a network-level failure — to
8
+ * plain-language messages, and defaults everything unrecognized to a
9
+ * generic-but-honest internal message. The raw text survives on the result
10
+ * for an operator surface or a log; it must never reach an end-user panel.
11
+ */
12
+ export type RunErrorKind = "external-auth" | "external-rate-limit" | "external-unavailable" | "external-rejected" | "network" | "internal";
13
+ export type ClassifiedRunError = {
14
+ readonly kind: RunErrorKind;
15
+ /** Plain-language message safe to render to end users. */
16
+ readonly userMessage: string;
17
+ /** The original error text — operator surfaces and logs only. */
18
+ readonly raw: string;
19
+ };
20
+ export declare function classifyRunError(raw: string): ClassifiedRunError;
21
+ /**
22
+ * Plain-language line for a step's live inference issue — a still-running
23
+ * step reporting itself as stalled-but-alive rather than dead. The input is
24
+ * whatever fixed category enum the host's runtime already classifies
25
+ * inference failures into (a timeout, a quota hit, a bad credential), passed
26
+ * through as a plain string so this module carries no dependency on the
27
+ * runtime's error types. The step keeps running for every category except
28
+ * `context_overflow`, where the input itself must shrink before a retry can
29
+ * help — its message is the one that omits the retry claim.
30
+ */
31
+ export declare function describeLiveInferenceIssue(category: string): string;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Classification/sanitization boundary for a failed step's raw error text.
3
+ *
4
+ * A step's own thrown error can carry internal identifiers, stack fragments
5
+ * or internal hostnames, and nothing user-facing may render it as-is.
6
+ * `classifyRunError` maps the known-safe shapes — a `"<Provider> API error:
7
+ * <status> …"` tool-package convention, a network-level failure — to
8
+ * plain-language messages, and defaults everything unrecognized to a
9
+ * generic-but-honest internal message. The raw text survives on the result
10
+ * for an operator surface or a log; it must never reach an end-user panel.
11
+ */ const PROVIDER_API_ERROR = /^([A-Za-z][A-Za-z0-9]*(?: [A-Za-z0-9]+){0,2}) API error: (\d{3})/;
12
+ const ANY_API_ERROR = /\bAPI error: (\d{3})/;
13
+ const GENERIC_PROVIDER_LABEL = "An external service";
14
+ const NETWORK_PATTERNS = [
15
+ /\bfetch failed\b/i,
16
+ /\bECONN(REFUSED|RESET|ABORTED)\b/,
17
+ /\bENOTFOUND\b/,
18
+ /\bETIMEDOUT\b/,
19
+ /\bEAI_AGAIN\b/,
20
+ /\bsocket\b.*\b(closed|hang ?up|reset)\b/i,
21
+ /\b(request|fetch|connect(?:ion)?|socket)\b.*\btimed out\b/i,
22
+ /\bnetwork (error|request failed)\b/i
23
+ ];
24
+ const INTERNAL_MESSAGE = "Something went wrong inside this workflow run. Try running it again; if it keeps failing, contact your workspace admin.";
25
+ const NETWORK_MESSAGE = "A service this workflow depends on couldn't be reached. Try running it again in a moment.";
26
+ function classifyProviderError(provider, status, raw) {
27
+ const credentialRef = provider === GENERIC_PROVIDER_LABEL ? "credential's" : `${provider} credential's`;
28
+ if (status === 401 || status === 403) {
29
+ return {
30
+ kind: "external-auth",
31
+ userMessage: `${provider} declined the request (${status}). Check the connected ${credentialRef} access and try again.`,
32
+ raw
33
+ };
34
+ }
35
+ if (status === 429) {
36
+ return {
37
+ kind: "external-rate-limit",
38
+ userMessage: `${provider} is rate-limiting requests right now. Wait a few minutes and run this again.`,
39
+ raw
40
+ };
41
+ }
42
+ if (status >= 500) {
43
+ return {
44
+ kind: "external-unavailable",
45
+ userMessage: `${provider} had a problem on its end (${status}). Try running this again shortly.`,
46
+ raw
47
+ };
48
+ }
49
+ return {
50
+ kind: "external-rejected",
51
+ userMessage: `${provider} rejected the request (${status}). Try again, and contact your workspace admin if it keeps failing.`,
52
+ raw
53
+ };
54
+ }
55
+ export function classifyRunError(raw) {
56
+ const providerMatch = PROVIDER_API_ERROR.exec(raw);
57
+ if (providerMatch?.[1] !== undefined && providerMatch[2] !== undefined) {
58
+ return classifyProviderError(providerMatch[1], Number(providerMatch[2]), raw);
59
+ }
60
+ const anyApiErrorMatch = ANY_API_ERROR.exec(raw);
61
+ if (anyApiErrorMatch?.[1] !== undefined) {
62
+ return classifyProviderError(GENERIC_PROVIDER_LABEL, Number(anyApiErrorMatch[1]), raw);
63
+ }
64
+ if (NETWORK_PATTERNS.some((pattern)=>pattern.test(raw))) {
65
+ return {
66
+ kind: "network",
67
+ userMessage: NETWORK_MESSAGE,
68
+ raw
69
+ };
70
+ }
71
+ return {
72
+ kind: "internal",
73
+ userMessage: INTERNAL_MESSAGE,
74
+ raw
75
+ };
76
+ }
77
+ /**
78
+ * Plain-language line for a step's live inference issue — a still-running
79
+ * step reporting itself as stalled-but-alive rather than dead. The input is
80
+ * whatever fixed category enum the host's runtime already classifies
81
+ * inference failures into (a timeout, a quota hit, a bad credential), passed
82
+ * through as a plain string so this module carries no dependency on the
83
+ * runtime's error types. The step keeps running for every category except
84
+ * `context_overflow`, where the input itself must shrink before a retry can
85
+ * help — its message is the one that omits the retry claim.
86
+ */ export function describeLiveInferenceIssue(category) {
87
+ switch(category){
88
+ case "timeout":
89
+ return "Model provider timed out — retrying";
90
+ case "retryable":
91
+ return "Model provider had a transient error — retrying";
92
+ case "quota_exhausted":
93
+ return "Model provider is rate-limiting requests — retrying";
94
+ case "credential_failure":
95
+ return "Model provider rejected the credential — retrying";
96
+ case "context_overflow":
97
+ return "Input is too large for the model";
98
+ case "protocol_mismatch":
99
+ return "Model provider returned an unexpected response — retrying";
100
+ case "aborted":
101
+ return "The step was interrupted — retrying";
102
+ default:
103
+ return "Model provider had a problem — retrying";
104
+ }
105
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Shared run-progress reasoning for a stepper or sidebar rendering a
3
+ * workflow's live progress.
4
+ *
5
+ * `RunProgress` is a plain, generic snapshot — a phase and a step-id-to-phase
6
+ * map — rather than the host's own run-state type. A step is only marked
7
+ * `"completed"` once the host's runtime actually resolves its output, and
8
+ * that resolution can lag behind a gate's own phase (an `awaiting-signal`
9
+ * step's completion event can be missing from a projection for a beat), so a
10
+ * gate's own phase is not a reliable "done" signal on its own. The robust
11
+ * rule encoded here: a step counts as passed once its own phase is completed
12
+ * OR any later step has progressed at all.
13
+ */
14
+ export type StepPhase = "pending" | "in-flight" | "awaiting-signal" | "awaiting-timer" | "completed" | "failed";
15
+ export type RunPhase = "pending" | "in-flight" | "completed" | "failed";
16
+ export type RunStepSnapshot = {
17
+ readonly phase: StepPhase;
18
+ /** Sanitizable raw error text — pass through `classifyRunError` before display. */
19
+ readonly lastErrorMessage?: string;
20
+ };
21
+ export type RunProgress = {
22
+ readonly phase: RunPhase;
23
+ readonly steps: ReadonlyMap<string, RunStepSnapshot>;
24
+ };
25
+ export type WorkflowStepStatus = "completed" | "current" | "pending" | "failed";
26
+ /** A single step descriptor for a stepper or sidebar. */
27
+ export type WorkflowStep = {
28
+ readonly number: number;
29
+ readonly label: string;
30
+ readonly status: WorkflowStepStatus;
31
+ };
32
+ /** Label colour for a step's status, shared by every stepper/sidebar rendering. */
33
+ export declare function workflowStepLabelClass(status: WorkflowStepStatus): string;
34
+ /** Mark glyph for a step's status: a checkmark, an exclamation, or its number. */
35
+ export declare function workflowStepGlyph(status: WorkflowStepStatus, number: number): string;
36
+ /**
37
+ * A stepper entry backed by one or more runtime step ids, in run order. A
38
+ * linear workflow maps one runtime id per display step; a clustered one
39
+ * (a multi-source research phase, say) groups several. The group's *last* id
40
+ * is its terminal step — the group only reads `completed` once that one does.
41
+ */
42
+ export type DisplayStep = {
43
+ readonly key: string;
44
+ readonly label: string;
45
+ readonly stepIds: readonly string[];
46
+ /** Present-progress verb shown on a live status line while this step is
47
+ * in-flight (e.g. "Saving to workbench"). Omit for a human gate or an
48
+ * intake step — an unlabeled active step shows no line rather than
49
+ * inventing one. */
50
+ readonly activityLabel?: string;
51
+ };
52
+ export declare function getStepPhase(progress: RunProgress | null, stepId: string): StepPhase | undefined;
53
+ export declare function isStepRunning(phase: StepPhase | undefined): boolean;
54
+ /** The aggregate phase of a display step from its runtime steps. */
55
+ export declare function displayStepPhase(progress: RunProgress | null, stepIds: readonly string[]): StepPhase | undefined;
56
+ /**
57
+ * Index of the display step the run is currently on. A step whose own phase
58
+ * is `failed` is never treated as passed even when a later, independently
59
+ * running branch has progressed — independent steps can run concurrently, so
60
+ * a later step's progress says nothing about whether this one failed.
61
+ * Returns the last index once every step is complete.
62
+ */
63
+ export declare function activeDisplayStepIndex(progress: RunProgress | null, steps: readonly DisplayStep[]): number;
64
+ export declare function buildStepperSteps(progress: RunProgress | null, steps: readonly DisplayStep[]): WorkflowStep[];
65
+ /** The active display step, or `null` while the run is terminal. */
66
+ export declare function activeDisplayStep(progress: RunProgress | null, steps: readonly DisplayStep[]): DisplayStep | null;
67
+ /**
68
+ * The "what's happening now" verb for a live status line, taken from the
69
+ * active step's `activityLabel`. Returns `null` — showing no line — once the
70
+ * run is terminal, while the first step owns its own loading UI, once the
71
+ * active group is done or parked on a human gate, or when the active step
72
+ * carries no `activityLabel` at all (a gate or intake step): silence there is
73
+ * correct, never a stepper noun standing in for it.
74
+ */
75
+ export declare function liveStatusLabel(progress: RunProgress | null, steps: readonly DisplayStep[]): string | null;
76
+ /** Label of the first display step whose aggregate phase is `failed`. Does
77
+ * not require `progress.phase === "failed"` — a caller flagging failure from
78
+ * a single failed step ahead of the run's own phase flip still gets a name. */
79
+ export declare function failedDisplayStepLabel(progress: RunProgress | null, steps: readonly DisplayStep[]): string | null;
80
+ /** The sanitized end-user message from whichever step failed the run, or
81
+ * `null` if the run has not failed or no step carries an error. Uses the
82
+ * first error found in map-iteration order — a run design that attaches an
83
+ * error to more than one step at once is a design this cannot disambiguate. */
84
+ export declare function failedRunErrorMessage(progress: RunProgress | null): string | null;
85
+ /**
86
+ * True only for a genuine never-started run: a non-null progress with an
87
+ * empty step map, where that emptiness came from an event log that was
88
+ * actually read. `logRead` distinguishes that from a log-unavailable fallback
89
+ * (a legacy run, or a read error) that can synthesize the same empty-step
90
+ * shape regardless of phase — in that case whether it started is unknown, so
91
+ * this returns `false` rather than making a false "never started" claim.
92
+ */
93
+ export declare function runNeverStarted(progress: RunProgress | null, logRead: boolean): boolean;
94
+ /** Honest copy for the pre-interactive window before a run's first step has
95
+ * recorded any activity: queued (`pending`, or no progress yet) reads
96
+ * differently from a runtime already booting that first step. */
97
+ export declare function runStartLabel(progress: RunProgress | null): string;