@arbidocs/blocks 0.4.82 → 0.4.84

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 (72) hide show
  1. package/dist/agents/index.cjs +279 -279
  2. package/dist/agents/index.js +4 -4
  3. package/dist/agents/workflows/StepBarFrame.d.ts +12 -4
  4. package/dist/{chunk-FE4ULGOR.js → chunk-2YOVK524.js} +28 -5
  5. package/dist/chunk-2YOVK524.js.map +1 -0
  6. package/dist/{chunk-5XVWGJ2H.cjs → chunk-B3WCKBJ7.cjs} +3 -3
  7. package/dist/{chunk-5XVWGJ2H.cjs.map → chunk-B3WCKBJ7.cjs.map} +1 -1
  8. package/dist/{chunk-THCFZKTM.js → chunk-CONIA2ZA.js} +8 -8
  9. package/dist/chunk-CONIA2ZA.js.map +1 -0
  10. package/dist/{chunk-O35LRB3P.js → chunk-GJV2G4FC.js} +3 -3
  11. package/dist/{chunk-O35LRB3P.js.map → chunk-GJV2G4FC.js.map} +1 -1
  12. package/dist/{chunk-ZVBPRMHJ.cjs → chunk-JH6JTI76.cjs} +27 -4
  13. package/dist/chunk-JH6JTI76.cjs.map +1 -0
  14. package/dist/{chunk-COP6GVKN.js → chunk-RSKSXEPW.js} +57 -19
  15. package/dist/chunk-RSKSXEPW.js.map +1 -0
  16. package/dist/{chunk-IRG5LPDP.js → chunk-RX35SMPR.js} +6 -6
  17. package/dist/{chunk-IRG5LPDP.js.map → chunk-RX35SMPR.js.map} +1 -1
  18. package/dist/{chunk-BX7JWZWE.cjs → chunk-RYYYHPFU.cjs} +8 -8
  19. package/dist/chunk-RYYYHPFU.cjs.map +1 -0
  20. package/dist/{chunk-VWK24TEY.cjs → chunk-XA5S4776.cjs} +45 -45
  21. package/dist/chunk-XA5S4776.cjs.map +1 -0
  22. package/dist/{chunk-LRRJ2HBW.cjs → chunk-ZQYE7J3J.cjs} +54 -14
  23. package/dist/chunk-ZQYE7J3J.cjs.map +1 -0
  24. package/dist/connect/index.cjs +81 -51
  25. package/dist/connect/index.cjs.map +1 -1
  26. package/dist/connect/index.js +43 -13
  27. package/dist/connect/index.js.map +1 -1
  28. package/dist/connection/ConnectedWorkflowBuilder.d.ts +9 -2
  29. package/dist/connection/WorkflowRunnerDialogs.d.ts +12 -1
  30. package/dist/document-tools/SignDocumentDialog.d.ts +9 -2
  31. package/dist/document-tools/index.cjs +2 -2
  32. package/dist/document-tools/index.js +1 -1
  33. package/dist/facts/index.cjs +1 -1
  34. package/dist/facts/index.js +1 -1
  35. package/dist/files/index.cjs +22 -3
  36. package/dist/files/index.cjs.map +1 -1
  37. package/dist/files/index.js +22 -4
  38. package/dist/files/index.js.map +1 -1
  39. package/dist/files/views/TagFormParts.d.ts +8 -0
  40. package/dist/files/views/index.d.ts +1 -1
  41. package/dist/home/index.cjs +1 -1
  42. package/dist/home/index.js +1 -1
  43. package/dist/index.cjs +891 -609
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.js +283 -12
  46. package/dist/index.js.map +1 -1
  47. package/dist/settings/index.cjs +35 -35
  48. package/dist/settings/index.js +3 -3
  49. package/dist/shell/index.cjs +1 -1
  50. package/dist/shell/index.js +1 -1
  51. package/dist/studio/index.cjs +1 -1
  52. package/dist/studio/index.js +1 -1
  53. package/dist/tags/TagDetail.d.ts +38 -0
  54. package/dist/tags/TagMatrix.d.ts +27 -8
  55. package/dist/tags/TagsNav.d.ts +44 -0
  56. package/dist/tags/index.d.ts +8 -3
  57. package/dist/tags/tagMatrixDocx.d.ts +4 -1
  58. package/dist/tags/tagMatrixModel.d.ts +10 -6
  59. package/dist/workflow-canvas/index.cjs +82 -64
  60. package/dist/workflow-canvas/index.cjs.map +1 -1
  61. package/dist/workflow-canvas/index.js +40 -22
  62. package/dist/workflow-canvas/index.js.map +1 -1
  63. package/dist/workspaces/index.cjs +1 -1
  64. package/dist/workspaces/index.js +1 -1
  65. package/package.json +4 -4
  66. package/dist/chunk-BX7JWZWE.cjs.map +0 -1
  67. package/dist/chunk-COP6GVKN.js.map +0 -1
  68. package/dist/chunk-FE4ULGOR.js.map +0 -1
  69. package/dist/chunk-LRRJ2HBW.cjs.map +0 -1
  70. package/dist/chunk-THCFZKTM.js.map +0 -1
  71. package/dist/chunk-VWK24TEY.cjs.map +0 -1
  72. package/dist/chunk-ZVBPRMHJ.cjs.map +0 -1
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The side navigation of a Tags page: the workspace's tags grouped by kind (labels, annotations,
3
+ * issues, people, organisations, searches), each group with its count, each tag with how much
4
+ * carries it, and nested tags (an issue list's issues) under their parent. A group heading selects
5
+ * the whole kind; a tag selects that tag. Data-free: the host passes the groups.
6
+ */
7
+ import { type ReactNode } from 'react';
8
+ export interface TagsNavItem {
9
+ id: string;
10
+ name: string;
11
+ /** How many documents and facts carry it. */
12
+ count?: number;
13
+ /** A swatch colour (any CSS colour). */
14
+ color?: string;
15
+ /** Nested tags (e.g. an issue list's issues). */
16
+ children?: TagsNavItem[];
17
+ }
18
+ export interface TagsNavGroup {
19
+ id: string;
20
+ label: string;
21
+ icon?: ReactNode;
22
+ items: TagsNavItem[];
23
+ }
24
+ /** What is selected: a whole group, or one tag of it. */
25
+ export type TagsNavSelection = {
26
+ groupId: string;
27
+ itemId?: string;
28
+ };
29
+ export interface TagsNavLabels {
30
+ filter: string;
31
+ clearFilter: string;
32
+ empty: string;
33
+ noMatch: string;
34
+ }
35
+ export declare const DEFAULT_TAGS_NAV_LABELS: TagsNavLabels;
36
+ export interface TagsNavProps {
37
+ groups: TagsNavGroup[];
38
+ selected: TagsNavSelection | null;
39
+ onSelect: (selection: TagsNavSelection) => void;
40
+ labels?: Partial<TagsNavLabels>;
41
+ className?: string;
42
+ testId?: string;
43
+ }
44
+ export declare function TagsNav({ groups, selected, onSelect, labels, className, testId, }: TagsNavProps): import("react").JSX.Element;
@@ -1,4 +1,9 @@
1
- /** A label's children as an editable matrix with their evidence (`TagMatrix`). */
2
- export { TagMatrix, DEFAULT_TAG_MATRIX_LABELS, type TagMatrixProps, type TagMatrixLabels, } from './TagMatrix';
3
- export { tagMatrixColumns, tagMatrixMarkdown, cellValue, cellText, parseCell, isGap, type TagMatrixData, type TagMatrixRowData, type TagMatrixField, type TagMatrixFieldType, type TagMatrixMarkdownOptions, } from './tagMatrixModel';
1
+ /**
2
+ * Tags: a set of tags as an editable matrix with their evidence (`TagMatrix`), one tag in full
3
+ * (`TagDetail`), and the kind-grouped navigation of a Tags page (`TagsNav`).
4
+ */
5
+ export { TagMatrix, TagMatrixCell, DEFAULT_TAG_MATRIX_LABELS, type TagMatrixProps, type TagMatrixLabels, } from './TagMatrix';
6
+ export { TagDetail, DEFAULT_TAG_DETAIL_LABELS, type TagDetailProps, type TagDetailLabels, } from './TagDetail';
7
+ export { TagsNav, DEFAULT_TAGS_NAV_LABELS, type TagsNavProps, type TagsNavLabels, type TagsNavGroup, type TagsNavItem, type TagsNavSelection, } from './TagsNav';
8
+ export { tagMatrixColumns, tagMatrixMarkdown, cellValue, rowFieldId, cellText, parseCell, isGap, type TagMatrixData, type TagMatrixRowData, type TagMatrixField, type TagMatrixFieldType, type TagMatrixMarkdownOptions, } from './tagMatrixModel';
4
9
  export { tagMatrixDocx, tagMatrixDocumentXml, DEFAULT_TAG_MATRIX_DOCX_LABELS, TAG_MATRIX_DOCX_LANDSCAPE_AFTER, type TagMatrixDocxLabels, type TagMatrixDocxOptions, } from './tagMatrixDocx';
@@ -16,7 +16,7 @@ export interface TagMatrixDocxLabels {
16
16
  gaps: string;
17
17
  /** `{at}` is the snapshot time, `YYYY-MM-DD HH:MM UTC`. */
18
18
  takenAt: string;
19
- /** A row with no linked document and no fact. */
19
+ /** A row with no linked document, fact or thread. */
20
20
  noEvidence: string;
21
21
  /** `{fields}`: the row's empty fields. */
22
22
  missing: string;
@@ -26,6 +26,9 @@ export interface TagMatrixDocxLabels {
26
26
  documents: string;
27
27
  fact: string;
28
28
  facts: string;
29
+ thread: string;
30
+ threads: string;
31
+ untitledThread: string;
29
32
  empty: string;
30
33
  }
31
34
  export declare const DEFAULT_TAG_MATRIX_DOCX_LABELS: TagMatrixDocxLabels;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The tag matrix as data: a parent label's child labels are the rows, the fields they share (the
3
- * parent's, then any a row adds) the columns, and each row's linked documents and facts its
4
- * evidence. Pure helpers for `TagMatrix`: the columns, a row's value, the gaps, and the snapshot
2
+ * The tag matrix as data: a parent label's child labels (or every tag of a kind) are the rows, the
3
+ * fields they share (the parent's, then any a row adds) the columns, and each row's linked
4
+ * documents, facts and threads its evidence. Pure helpers for `TagMatrix`: the columns, a row's value, the gaps, and the snapshot
5
5
  * as a Markdown document.
6
6
  */
7
7
  import type { components } from '@arbidocs/client';
@@ -10,13 +10,17 @@ export type TagMatrixRowData = components['schemas']['TagMatrixRow'];
10
10
  export type TagMatrixField = components['schemas']['TagField'];
11
11
  export type TagMatrixFieldType = TagMatrixField['type'];
12
12
  /**
13
- * The columns: the parent's fields (shared by every row), then fields only some rows define,
14
- * each once, in the order first seen. Mirrors the SDK's `tagMatrixColumns`.
13
+ * The columns: the parent's fields (shared by every row), then fields only some rows define, in
14
+ * the order first seen. Rows that each define the same field share one column — every person has
15
+ * its own "Role", and a matrix of people has one Role column (the SDK's `tagMatrixColumns` keeps
16
+ * one column per field id).
15
17
  */
16
18
  export declare function tagMatrixColumns(matrix: TagMatrixData | null | undefined): TagMatrixField[];
19
+ /** The id of a row's field behind a column: the column's own, or the row's field of that name. */
20
+ export declare function rowFieldId(row: TagMatrixRowData, column: TagMatrixField): string;
17
21
  /** A row's value for a column (values are keyed by field id). */
18
22
  export declare const cellValue: (row: TagMatrixRowData, column: TagMatrixField) => unknown;
19
- /** A row with nothing behind it: no linked document and no fact. */
23
+ /** A row with nothing behind it: no linked document, fact or thread. */
20
24
  export declare const isGap: (row: TagMatrixRowData) => boolean;
21
25
  /** A value as text (a person by name, a checkbox as yes or no, blank as empty). */
22
26
  export declare function cellText(value: unknown, column: Pick<TagMatrixField, 'type'>, nameOf?: (id: string) => string | undefined): string;
@@ -2,10 +2,10 @@
2
2
  'use strict';
3
3
 
4
4
  var chunkMUMH3Z6K_cjs = require('../chunk-MUMH3Z6K.cjs');
5
- var chunkVWK24TEY_cjs = require('../chunk-VWK24TEY.cjs');
5
+ var chunkXA5S4776_cjs = require('../chunk-XA5S4776.cjs');
6
6
  require('../chunk-YJQVLVBJ.cjs');
7
7
  require('../chunk-ZW6FPIFC.cjs');
8
- var chunkBX7JWZWE_cjs = require('../chunk-BX7JWZWE.cjs');
8
+ var chunkRYYYHPFU_cjs = require('../chunk-RYYYHPFU.cjs');
9
9
  require('../chunk-7RGLTF76.cjs');
10
10
  require('../chunk-3AFWGEDJ.cjs');
11
11
  require('../chunk-VFUWWH52.cjs');
@@ -16,13 +16,13 @@ require('../chunk-IXALYQT7.cjs');
16
16
  require('../chunk-Z5VUZ6YD.cjs');
17
17
  require('../chunk-7D737FLE.cjs');
18
18
  require('../chunk-OB5F4577.cjs');
19
- require('../chunk-C54XEN5T.cjs');
20
- require('../chunk-ULWRNGGE.cjs');
21
19
  require('../chunk-B4SRYJLM.cjs');
22
20
  require('../chunk-7UTB4PHM.cjs');
23
21
  require('../chunk-FX3K6LNZ.cjs');
24
22
  require('../chunk-PPCATBOY.cjs');
23
+ require('../chunk-C54XEN5T.cjs');
25
24
  require('../chunk-KDG6FER6.cjs');
25
+ require('../chunk-ULWRNGGE.cjs');
26
26
  require('../chunk-MHVNT4J3.cjs');
27
27
  require('../chunk-DES3K4SD.cjs');
28
28
  var react = require('react');
@@ -58,11 +58,11 @@ function withSteps(workflow, steps, layout) {
58
58
  const run = workflow.run.kind === "steps" ? workflow.run : { kind: "steps", steps: [] };
59
59
  return {
60
60
  ...workflow,
61
- run: { ...run, steps: chunkBX7JWZWE_cjs.orderSteps(steps), layout: layout ?? run.layout }
61
+ run: { ...run, steps: chunkRYYYHPFU_cjs.orderSteps(steps), layout: layout ?? run.layout }
62
62
  };
63
63
  }
64
64
  var layoutOf = (workflow) => workflow.run.kind === "steps" && workflow.run.layout || {};
65
- var explicit = (steps) => steps.map((s) => ({ ...s, after: chunkBX7JWZWE_cjs.stepDependencies(steps, s.id) }));
65
+ var explicit = (steps) => steps.map((s) => ({ ...s, after: chunkRYYYHPFU_cjs.stepDependencies(steps, s.id) }));
66
66
  function stepIdFor(steps, title) {
67
67
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/^[^a-z]+/, "") || "step";
68
68
  const taken = new Set(steps.map((s) => s.id));
@@ -109,7 +109,7 @@ function blankStep(kind, id, title) {
109
109
  }
110
110
  }
111
111
  function addStep(workflow, kind, options = {}) {
112
- const steps = explicit(chunkBX7JWZWE_cjs.workflowSteps(workflow));
112
+ const steps = explicit(chunkRYYYHPFU_cjs.workflowSteps(workflow));
113
113
  const title = options.title ?? DEFAULT_TITLES[kind];
114
114
  const id = stepIdFor(steps, title);
115
115
  const step = { ...blankStep(kind, id, title), after: options.after ? [options.after] : [] };
@@ -118,7 +118,7 @@ function addStep(workflow, kind, options = {}) {
118
118
  return { workflow: withSteps(workflow, [...steps, step], layout), id };
119
119
  }
120
120
  function removeStep(workflow, id) {
121
- const steps = explicit(chunkBX7JWZWE_cjs.workflowSteps(workflow));
121
+ const steps = explicit(chunkRYYYHPFU_cjs.workflowSteps(workflow));
122
122
  const removed = steps.find((s) => s.id === id);
123
123
  if (!removed) return workflow;
124
124
  const bridged = steps.filter((s) => s.id !== id).map(
@@ -131,8 +131,8 @@ function removeStep(workflow, id) {
131
131
  return withSteps(workflow, bridged, layout);
132
132
  }
133
133
  function connectSteps(workflow, from, to) {
134
- const steps = explicit(chunkBX7JWZWE_cjs.workflowSteps(workflow));
135
- if (from === to || !steps.some((s) => s.id === from) || chunkBX7JWZWE_cjs.dependsOn(steps, from, to)) {
134
+ const steps = explicit(chunkRYYYHPFU_cjs.workflowSteps(workflow));
135
+ if (from === to || !steps.some((s) => s.id === from) || chunkRYYYHPFU_cjs.dependsOn(steps, from, to)) {
136
136
  return workflow;
137
137
  }
138
138
  return withSteps(
@@ -142,16 +142,16 @@ function connectSteps(workflow, from, to) {
142
142
  )
143
143
  );
144
144
  }
145
- var wouldCycle = (workflow, from, to) => from === to || chunkBX7JWZWE_cjs.dependsOn(chunkBX7JWZWE_cjs.workflowSteps(workflow), from, to);
145
+ var wouldCycle = (workflow, from, to) => from === to || chunkRYYYHPFU_cjs.dependsOn(chunkRYYYHPFU_cjs.workflowSteps(workflow), from, to);
146
146
  function disconnectSteps(workflow, from, to) {
147
- const steps = explicit(chunkBX7JWZWE_cjs.workflowSteps(workflow));
147
+ const steps = explicit(chunkRYYYHPFU_cjs.workflowSteps(workflow));
148
148
  return withSteps(
149
149
  workflow,
150
150
  steps.map((s) => s.id === to ? { ...s, after: (s.after ?? []).filter((d) => d !== from) } : s)
151
151
  );
152
152
  }
153
153
  function updateStep(workflow, id, patch) {
154
- const steps = explicit(chunkBX7JWZWE_cjs.workflowSteps(workflow));
154
+ const steps = explicit(chunkRYYYHPFU_cjs.workflowSteps(workflow));
155
155
  return withSteps(
156
156
  workflow,
157
157
  steps.map(
@@ -165,7 +165,7 @@ var renameIn = (text, from, to) => text.replace(
165
165
  );
166
166
  function renameInput(workflow, from, to) {
167
167
  if (from === to) return workflow;
168
- const steps = chunkBX7JWZWE_cjs.workflowSteps(workflow).map((s) => {
168
+ const steps = chunkRYYYHPFU_cjs.workflowSteps(workflow).map((s) => {
169
169
  if (s.kind === "agent")
170
170
  return {
171
171
  ...s,
@@ -214,13 +214,13 @@ function renameInput(workflow, from, to) {
214
214
  var renamePerson = (a, from, to) => "input" in a && a.input === from ? { input: to } : a;
215
215
  var renameRef = (r, from, to) => "input" in r && r.input === from ? { input: to } : r;
216
216
  function moveStep(workflow, id, position) {
217
- return withSteps(workflow, chunkBX7JWZWE_cjs.workflowSteps(workflow), { ...layoutOf(workflow), [id]: position });
217
+ return withSteps(workflow, chunkRYYYHPFU_cjs.workflowSteps(workflow), { ...layoutOf(workflow), [id]: position });
218
218
  }
219
219
  var COLUMN = 300;
220
220
  var ROW = 140;
221
221
  function autoLayout(steps) {
222
222
  const layout = {};
223
- chunkBX7JWZWE_cjs.stepLevels(steps).forEach(
223
+ chunkRYYYHPFU_cjs.stepLevels(steps).forEach(
224
224
  (level, x) => level.forEach((s, y) => {
225
225
  layout[s.id] = { x: x * COLUMN, y: (y - (level.length - 1) / 2) * ROW };
226
226
  })
@@ -228,7 +228,7 @@ function autoLayout(steps) {
228
228
  return layout;
229
229
  }
230
230
  function layoutWithDefaults(workflow) {
231
- const auto = autoLayout(chunkBX7JWZWE_cjs.workflowSteps(workflow));
231
+ const auto = autoLayout(chunkRYYYHPFU_cjs.workflowSteps(workflow));
232
232
  return { ...auto, ...layoutOf(workflow) };
233
233
  }
234
234
  var DEFAULT_SIGNALS_EDITOR_LABELS = {
@@ -325,9 +325,9 @@ function SignalsEditor({
325
325
  {
326
326
  className: ui.cn(
327
327
  "space-y-1.5 rounded-md border p-2",
328
- chunkBX7JWZWE_cjs.isIncompleteSignal(signal) ? "border-destructive/50" : "border-border"
328
+ chunkRYYYHPFU_cjs.isIncompleteSignal(signal) ? "border-destructive/50" : "border-border"
329
329
  ),
330
- "data-incomplete": chunkBX7JWZWE_cjs.isIncompleteSignal(signal) || void 0,
330
+ "data-incomplete": chunkRYYYHPFU_cjs.isIncompleteSignal(signal) || void 0,
331
331
  "data-testid": `${testId}-${i}`,
332
332
  children: [
333
333
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
@@ -1042,7 +1042,7 @@ function StepInspector({
1042
1042
  testId = "step-inspector"
1043
1043
  }) {
1044
1044
  const l = { ...DEFAULT_STEP_INSPECTOR_LABELS, ...labels };
1045
- const steps = chunkBX7JWZWE_cjs.workflowSteps(workflow);
1045
+ const steps = chunkRYYYHPFU_cjs.workflowSteps(workflow);
1046
1046
  const step = steps.find((s) => s.id === stepId);
1047
1047
  const run = workflow.run.kind === "steps" ? workflow.run : void 0;
1048
1048
  if (!step || !run) {
@@ -1069,8 +1069,8 @@ function StepInspector({
1069
1069
  const patch = (p) => onChange(updateStep(workflow, step.id, p));
1070
1070
  const al = { ...DEFAULT_STEP_ACTION_SETTINGS_LABELS, ...actionLabels };
1071
1071
  const ctx = {
1072
- earlier: chunkBX7JWZWE_cjs.upstreamSteps(steps, step.id),
1073
- fields: chunkBX7JWZWE_cjs.runFields(workflow),
1072
+ earlier: chunkRYYYHPFU_cjs.upstreamSteps(steps, step.id),
1073
+ fields: chunkRYYYHPFU_cjs.runFields(workflow),
1074
1074
  people,
1075
1075
  tags,
1076
1076
  documents
@@ -1091,7 +1091,7 @@ function StepInspector({
1091
1091
  )
1092
1092
  );
1093
1093
  };
1094
- const deps = chunkBX7JWZWE_cjs.stepDependencies(steps, step.id);
1094
+ const deps = chunkRYYYHPFU_cjs.stepDependencies(steps, step.id);
1095
1095
  const titleOf = (id) => steps.find((s) => s.id === id)?.title ?? id;
1096
1096
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", "data-testid": `${testId}-step`, children: [
1097
1097
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
@@ -1171,7 +1171,7 @@ function StepInspector({
1171
1171
  {
1172
1172
  step,
1173
1173
  workflows,
1174
- fields: chunkBX7JWZWE_cjs.runFields(workflow).map((f) => f.name),
1174
+ fields: chunkRYYYHPFU_cjs.runFields(workflow).map((f) => f.name),
1175
1175
  patch,
1176
1176
  l,
1177
1177
  testId
@@ -1231,7 +1231,7 @@ function StepInspector({
1231
1231
  testId: `${testId}-review-grid`
1232
1232
  }
1233
1233
  ),
1234
- chunkBX7JWZWE_cjs.canAssign(step) && /* @__PURE__ */ jsxRuntime.jsx(AssigneeSettings, { step, patch, ctx, l: al, testId }),
1234
+ chunkRYYYHPFU_cjs.canAssign(step) && /* @__PURE__ */ jsxRuntime.jsx(AssigneeSettings, { step, patch, ctx, l: al, testId }),
1235
1235
  /* @__PURE__ */ jsxRuntime.jsx(
1236
1236
  SignalsEditor,
1237
1237
  {
@@ -1487,7 +1487,7 @@ function triggerFields(trigger, clearOthers) {
1487
1487
  return {
1488
1488
  timezone: trigger.timezone,
1489
1489
  rrule: trigger.start === "repeat" ? trigger.rrule.trim() : none,
1490
- run_at: trigger.start === "once" ? chunkVWK24TEY_cjs.localInputToIso(trigger.runAt) : none,
1490
+ run_at: trigger.start === "once" ? chunkXA5S4776_cjs.localInputToIso(trigger.runAt) : none,
1491
1491
  event_kind: trigger.start === "event" ? trigger.eventKind.trim() : none,
1492
1492
  // A step signal is `workflow_signal` narrowed to one signal name.
1493
1493
  event_filter: filter ?? none,
@@ -1503,7 +1503,7 @@ function plan(value, options) {
1503
1503
  criteria: [],
1504
1504
  max_passes: 3,
1505
1505
  documents: [],
1506
- steps: chunkBX7JWZWE_cjs.toPlanSteps(value.workflow, options)
1506
+ steps: chunkRYYYHPFU_cjs.toPlanSteps(value.workflow, options)
1507
1507
  };
1508
1508
  }
1509
1509
  function builderToWorkflowRequest(value, workspaceId, options = {}) {
@@ -1538,7 +1538,7 @@ function builderToWorkflowUpdate(value, options = {}) {
1538
1538
  }
1539
1539
  function workflowRecordToBuilder(record) {
1540
1540
  const planned = record.plan?.steps ?? [];
1541
- const steps = planned.length ? chunkBX7JWZWE_cjs.fromPlanSteps(planned) : record.prompt || record.skill_ref ? [
1541
+ const steps = planned.length ? chunkRYYYHPFU_cjs.fromPlanSteps(planned) : record.prompt || record.skill_ref ? [
1542
1542
  {
1543
1543
  id: "work",
1544
1544
  kind: "agent",
@@ -1546,7 +1546,7 @@ function workflowRecordToBuilder(record) {
1546
1546
  ...record.skill_ref ? { workflow: record.skill_ref } : { run: { kind: "prompt", promptTemplate: record.prompt } }
1547
1547
  }
1548
1548
  ] : [];
1549
- const when = chunkVWK24TEY_cjs.workflowWhen(record);
1549
+ const when = chunkXA5S4776_cjs.workflowWhen(record);
1550
1550
  return {
1551
1551
  workflow: {
1552
1552
  id: record.external_id,
@@ -1555,12 +1555,12 @@ function workflowRecordToBuilder(record) {
1555
1555
  inputs: [],
1556
1556
  landing: "chat",
1557
1557
  schedulable: false,
1558
- run: { kind: "steps", steps, layout: chunkBX7JWZWE_cjs.layoutFromPlanSteps(planned ?? []) }
1558
+ run: { kind: "steps", steps, layout: chunkRYYYHPFU_cjs.layoutFromPlanSteps(planned ?? []) }
1559
1559
  },
1560
1560
  trigger: {
1561
1561
  ...DEFAULT_WORKFLOW_TRIGGER,
1562
1562
  start: when === "now" ? "manual" : when,
1563
- runAt: chunkVWK24TEY_cjs.isoToLocalInput(record.run_at),
1563
+ runAt: chunkXA5S4776_cjs.isoToLocalInput(record.run_at),
1564
1564
  rrule: record.rrule ?? "",
1565
1565
  timezone: record.timezone || DEFAULT_WORKFLOW_TRIGGER.timezone,
1566
1566
  eventKind: record.event_kind ?? "",
@@ -1616,7 +1616,7 @@ function triggerSummary(trigger, options = {}) {
1616
1616
  case "once":
1617
1617
  return trigger.runAt ? new Date(trigger.runAt).toLocaleString() : l.starts.once;
1618
1618
  case "repeat":
1619
- return trigger.rrule ? chunkVWK24TEY_cjs.describeRRule(trigger.rrule) : l.starts.repeat;
1619
+ return trigger.rrule ? chunkXA5S4776_cjs.describeRRule(trigger.rrule) : l.starts.repeat;
1620
1620
  case "event":
1621
1621
  if (isSignalTrigger(trigger))
1622
1622
  return trigger.signal ? l.signalSummary.replace("{signal}", trigger.signal) : l.stepSignals;
@@ -1675,7 +1675,7 @@ function TriggerInspector({
1675
1675
  }
1676
1676
  )
1677
1677
  ] }),
1678
- trigger.start === "repeat" && /* @__PURE__ */ jsxRuntime.jsx(chunkVWK24TEY_cjs.RecurrenceBuilder, { rrule: trigger.rrule, onChange: (rrule) => set({ rrule }) }),
1678
+ trigger.start === "repeat" && /* @__PURE__ */ jsxRuntime.jsx(chunkXA5S4776_cjs.RecurrenceBuilder, { rrule: trigger.rrule, onChange: (rrule) => set({ rrule }) }),
1679
1679
  trigger.start === "event" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
1680
1680
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "text-xs", children: l.event }),
1681
1681
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1727,7 +1727,7 @@ function TriggerInspector({
1727
1727
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
1728
1728
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "text-xs", children: l.agent }),
1729
1729
  /* @__PURE__ */ jsxRuntime.jsx(
1730
- chunkVWK24TEY_cjs.AgentSelect,
1730
+ chunkXA5S4776_cjs.AgentSelect,
1731
1731
  {
1732
1732
  agents,
1733
1733
  value: trigger.agentId,
@@ -2037,12 +2037,12 @@ function WorkflowCanvas({
2037
2037
  testId = "workflow-canvas"
2038
2038
  }) {
2039
2039
  const l = react.useMemo(() => ({ ...DEFAULT_WORKFLOW_CANVAS_LABELS, ...labels }), [labels]);
2040
- const steps = chunkBX7JWZWE_cjs.workflowSteps(workflow);
2040
+ const steps = chunkRYYYHPFU_cjs.workflowSteps(workflow);
2041
2041
  const editable = !!onChange;
2042
2042
  const built = react.useMemo(() => {
2043
2043
  const layout = layoutWithDefaults(workflow);
2044
- const all = chunkBX7JWZWE_cjs.workflowSteps(workflow);
2045
- const roots = all.filter((s) => chunkBX7JWZWE_cjs.stepDependencies(all, s.id).length === 0);
2044
+ const all = chunkRYYYHPFU_cjs.workflowSteps(workflow);
2045
+ const roots = all.filter((s) => chunkRYYYHPFU_cjs.stepDependencies(all, s.id).length === 0);
2046
2046
  const triggerNode = trigger ? [
2047
2047
  {
2048
2048
  id: TRIGGER_NODE,
@@ -2091,7 +2091,7 @@ function WorkflowCanvas({
2091
2091
  react.useEffect(() => setNodes(built), [built]);
2092
2092
  const edges = react.useMemo(
2093
2093
  () => steps.flatMap((s) => {
2094
- const deps = chunkBX7JWZWE_cjs.stepDependencies(steps, s.id);
2094
+ const deps = chunkRYYYHPFU_cjs.stepDependencies(steps, s.id);
2095
2095
  const from = deps.length ? deps : trigger ? [TRIGGER_NODE] : [];
2096
2096
  return from.map((d) => ({
2097
2097
  id: `${d}->${s.id}`,
@@ -2342,12 +2342,12 @@ function WorkflowBuilder({
2342
2342
  const [mode, setMode] = react.useState("design");
2343
2343
  const [adding, setAdding] = react.useState(false);
2344
2344
  const { workflow, trigger } = value;
2345
- const steps = chunkBX7JWZWE_cjs.workflowSteps(workflow);
2346
- const problems = chunkBX7JWZWE_cjs.validateWorkflowGraph(steps);
2347
- const missing = chunkBX7JWZWE_cjs.stepConfigProblems(steps);
2345
+ const steps = chunkRYYYHPFU_cjs.workflowSteps(workflow);
2346
+ const problems = chunkRYYYHPFU_cjs.validateWorkflowGraph(steps);
2347
+ const missing = chunkRYYYHPFU_cjs.stepConfigProblems(steps);
2348
2348
  const nameOf = (id) => people.find((p) => p.value === id)?.label;
2349
- const fields = chunkBX7JWZWE_cjs.runFields(workflow);
2350
- const assigneeOf = (step) => chunkBX7JWZWE_cjs.canAssign(step) ? chunkBX7JWZWE_cjs.assigneeName(step.assignee, { nameOf, fields }) : void 0;
2349
+ const fields = chunkRYYYHPFU_cjs.runFields(workflow);
2350
+ const assigneeOf = (step) => chunkRYYYHPFU_cjs.canAssign(step) ? chunkRYYYHPFU_cjs.assigneeName(step.assignee, { nameOf, fields }) : void 0;
2351
2351
  const titles = react.useMemo(() => new Map(workflows.map((w) => [w.id, w.title])), [workflows]);
2352
2352
  const setWorkflow = (next) => onChange({ ...value, workflow: next });
2353
2353
  const addAfter = (from, kind) => {
@@ -2578,13 +2578,13 @@ function WorkflowPreview({
2578
2578
  renderIcon,
2579
2579
  testId
2580
2580
  }) {
2581
- const run = chunkVWK24TEY_cjs.useWorkflowPreview(workflow, {
2581
+ const run = chunkXA5S4776_cjs.useWorkflowPreview(workflow, {
2582
2582
  resolveWorkflow: (id) => workflows.find((w) => w.id === id),
2583
2583
  compose,
2584
2584
  answer
2585
2585
  });
2586
2586
  return /* @__PURE__ */ jsxRuntime.jsx(
2587
- chunkBX7JWZWE_cjs.WorkflowRunner,
2587
+ chunkRYYYHPFU_cjs.WorkflowRunner,
2588
2588
  {
2589
2589
  workflow,
2590
2590
  run,
@@ -2606,7 +2606,9 @@ var DEFAULT_CONNECTED_WORKFLOW_BUILDER_LABELS = {
2606
2606
  saving: "Saving\u2026",
2607
2607
  runNow: "Run now",
2608
2608
  saved: "Saved.",
2609
- needTrigger: "Finish setting when it starts."
2609
+ needTrigger: "Finish setting when it starts.",
2610
+ running: "Starting\u2026",
2611
+ failed: "Something went wrong."
2610
2612
  };
2611
2613
  var DEFAULT_WORKFLOW_EVENT_KINDS = [
2612
2614
  { value: "conversation_done", label: "A task is marked done" },
@@ -2656,6 +2658,8 @@ function ConnectedWorkflowBuilder({
2656
2658
  const [id, setId] = react.useState(workflowId);
2657
2659
  const [value, setValue] = react.useState(initial);
2658
2660
  const [message, setMessage] = react.useState(null);
2661
+ const [error, setError] = react.useState(null);
2662
+ const [pending, setPending] = react.useState();
2659
2663
  const record = saved.data?.find((w) => w.external_id === id);
2660
2664
  const [loaded, setLoaded] = react.useState(void 0);
2661
2665
  react.useEffect(() => {
@@ -2668,7 +2672,7 @@ function ConnectedWorkflowBuilder({
2668
2672
  () => [
2669
2673
  ...hostWorkflows,
2670
2674
  ...(skills.data ?? []).map(
2671
- (s) => chunkBX7JWZWE_cjs.skillToWorkflow({
2675
+ (s) => chunkRYYYHPFU_cjs.skillToWorkflow({
2672
2676
  name: s.name,
2673
2677
  slug: s.slug,
2674
2678
  description: s.description,
@@ -2684,18 +2688,37 @@ function ConnectedWorkflowBuilder({
2684
2688
  }));
2685
2689
  const tasks = (conversations.data ?? []).filter((c) => c.status && c.status !== "done").map((c) => ({ value: c.external_id, label: c.title || c.external_id }));
2686
2690
  const options = { resolveWorkflow: (wid) => workflows.find((w) => w.id === wid), compose };
2687
- const problem = triggerProblem(value.trigger) ?? (chunkBX7JWZWE_cjs.validateWorkflowGraph(chunkBX7JWZWE_cjs.workflowSteps(value.workflow)).length || chunkBX7JWZWE_cjs.stepConfigProblems(chunkBX7JWZWE_cjs.workflowSteps(value.workflow)).length ? "graph" : null);
2688
- const busy = create.isPending || update.isPending || run.isPending;
2691
+ const problem = triggerProblem(value.trigger) ?? (chunkRYYYHPFU_cjs.validateWorkflowGraph(chunkRYYYHPFU_cjs.workflowSteps(value.workflow)).length || chunkRYYYHPFU_cjs.stepConfigProblems(chunkRYYYHPFU_cjs.workflowSteps(value.workflow)).length ? "graph" : null);
2692
+ const busy = !!pending || create.isPending || update.isPending || run.isPending;
2689
2693
  const save = async () => {
2690
2694
  if (!workspaceId) return void 0;
2691
- setMessage(null);
2692
2695
  const result = id ? await update.mutateAsync({ workflowId: id, patch: builderToWorkflowUpdate(value, options) }) : await create.mutateAsync(builderToWorkflowRequest(value, workspaceId, options));
2693
2696
  setId(result.external_id);
2694
2697
  setLoaded(result.external_id);
2695
- setMessage(l.saved);
2696
- onSaved?.(result.external_id);
2698
+ await onSaved?.(result.external_id, value);
2697
2699
  return result.external_id;
2698
2700
  };
2701
+ const attempt = async (andRun) => {
2702
+ setMessage(null);
2703
+ setError(null);
2704
+ setPending({ action: andRun ? "run" : "save", phase: "saving" });
2705
+ try {
2706
+ const savedId = await save();
2707
+ if (!savedId) return;
2708
+ if (!andRun) {
2709
+ setMessage(l.saved);
2710
+ return;
2711
+ }
2712
+ setPending({ action: "run", phase: "running" });
2713
+ const started = await run.mutateAsync(savedId);
2714
+ if (started.error) throw new Error(started.error);
2715
+ onRun?.(started.conversation_ext_id ?? void 0);
2716
+ } catch (e) {
2717
+ setError(e instanceof Error && e.message ? e.message : l.failed);
2718
+ } finally {
2719
+ setPending(void 0);
2720
+ }
2721
+ };
2699
2722
  return /* @__PURE__ */ jsxRuntime.jsx(
2700
2723
  WorkflowBuilder,
2701
2724
  {
@@ -2715,6 +2738,7 @@ function ConnectedWorkflowBuilder({
2715
2738
  actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2716
2739
  actions,
2717
2740
  message && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: message }),
2741
+ error && /* @__PURE__ */ jsxRuntime.jsx("span", { role: "alert", className: "text-xs text-destructive", "data-testid": `${testId}-error`, children: error }),
2718
2742
  problem && problem !== "graph" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-destructive", children: l.needTrigger }),
2719
2743
  /* @__PURE__ */ jsxRuntime.jsxs(
2720
2744
  ui.Button,
@@ -2722,17 +2746,11 @@ function ConnectedWorkflowBuilder({
2722
2746
  variant: "outline",
2723
2747
  size: "sm",
2724
2748
  disabled: !!problem || busy || !workspaceId,
2725
- onClick: async () => {
2726
- const saved2 = await save();
2727
- if (!saved2) return;
2728
- const started = await run.mutateAsync(saved2);
2729
- onRun?.(started.conversation_ext_id ?? void 0);
2730
- },
2749
+ onClick: () => void attempt(true),
2731
2750
  "data-testid": `${testId}-run`,
2732
2751
  children: [
2733
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "size-4" }),
2734
- " ",
2735
- l.runNow
2752
+ pending?.action === "run" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "size-4" }),
2753
+ pending?.action === "run" ? pending.phase === "saving" ? l.saving : l.running : l.runNow
2736
2754
  ]
2737
2755
  }
2738
2756
  ),
@@ -2741,11 +2759,11 @@ function ConnectedWorkflowBuilder({
2741
2759
  {
2742
2760
  size: "sm",
2743
2761
  disabled: !!problem || busy || !workspaceId,
2744
- onClick: () => void save(),
2762
+ onClick: () => void attempt(false),
2745
2763
  "data-testid": `${testId}-save`,
2746
2764
  children: [
2747
- create.isPending || update.isPending ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "size-4" }),
2748
- create.isPending || update.isPending ? l.saving : l.save
2765
+ pending?.action === "save" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "size-4" }),
2766
+ pending?.action === "save" ? l.saving : l.save
2749
2767
  ]
2750
2768
  }
2751
2769
  )