@arbidocs/blocks 0.4.76 → 0.4.77

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 (97) hide show
  1. package/dist/agents/index.cjs +331 -255
  2. package/dist/agents/index.js +2 -2
  3. package/dist/agents/tasks/TaskActivityTimeline.d.ts +1 -1
  4. package/dist/agents/tasks/WorkflowThreadStrip.d.ts +7 -1
  5. package/dist/agents/workflows/SchemaForm.d.ts +6 -1
  6. package/dist/agents/workflows/StepParts.d.ts +109 -0
  7. package/dist/agents/workflows/WorkflowRunner.d.ts +11 -2
  8. package/dist/agents/workflows/index.d.ts +3 -2
  9. package/dist/agents/workflows/planSteps.d.ts +8 -1
  10. package/dist/agents/workflows/run.d.ts +61 -8
  11. package/dist/agents/workflows/types.d.ts +133 -4
  12. package/dist/agents/workflows/useWorkflowPreview.d.ts +2 -1
  13. package/dist/agents/workflows/useWorkflowView.d.ts +19 -0
  14. package/dist/chat/ChatPage.d.ts +1 -1
  15. package/dist/chat/WorkflowStepChip.d.ts +24 -0
  16. package/dist/chat/chat-page-types.d.ts +4 -0
  17. package/dist/chat/index.cjs +130 -122
  18. package/dist/chat/index.d.ts +1 -0
  19. package/dist/chat/index.js +2 -2
  20. package/dist/{chunk-22P5KNIM.js → chunk-34UW6XUQ.js} +928 -38
  21. package/dist/chunk-34UW6XUQ.js.map +1 -0
  22. package/dist/{chunk-VYRKO3XU.cjs → chunk-3XR3IEGU.cjs} +944 -35
  23. package/dist/chunk-3XR3IEGU.cjs.map +1 -0
  24. package/dist/{chunk-ZWA7UUZL.cjs → chunk-7YUFMNFW.cjs} +2 -54
  25. package/dist/chunk-7YUFMNFW.cjs.map +1 -0
  26. package/dist/chunk-A24C6BNA.js +92 -0
  27. package/dist/chunk-A24C6BNA.js.map +1 -0
  28. package/dist/chunk-AINNADMT.cjs +62 -0
  29. package/dist/chunk-AINNADMT.cjs.map +1 -0
  30. package/dist/{chunk-7CVF3DK2.cjs → chunk-EKIUMNCN.cjs} +5 -5
  31. package/dist/{chunk-7CVF3DK2.cjs.map → chunk-EKIUMNCN.cjs.map} +1 -1
  32. package/dist/chunk-FE4ULGOR.js +151 -0
  33. package/dist/chunk-FE4ULGOR.js.map +1 -0
  34. package/dist/chunk-FT5FFXSJ.js +60 -0
  35. package/dist/chunk-FT5FFXSJ.js.map +1 -0
  36. package/dist/{chunk-HITAN7JF.cjs → chunk-GTXOV7IJ.cjs} +4 -4
  37. package/dist/{chunk-HITAN7JF.cjs.map → chunk-GTXOV7IJ.cjs.map} +1 -1
  38. package/dist/{chunk-TKB7TVMW.js → chunk-HEVVT6IT.js} +78 -14
  39. package/dist/chunk-HEVVT6IT.js.map +1 -0
  40. package/dist/{chunk-IPGKTUF7.cjs → chunk-HOD6OM7L.cjs} +68 -3
  41. package/dist/chunk-HOD6OM7L.cjs.map +1 -0
  42. package/dist/{chunk-7FKARMA3.cjs → chunk-JFUN4D7D.cjs} +101 -37
  43. package/dist/chunk-JFUN4D7D.cjs.map +1 -0
  44. package/dist/{chunk-UIWLDSTF.js → chunk-NIP5BOP7.js} +68 -5
  45. package/dist/chunk-NIP5BOP7.js.map +1 -0
  46. package/dist/{chunk-MK6NJQGF.js → chunk-OEM5ARVM.js} +3 -3
  47. package/dist/{chunk-MK6NJQGF.js.map → chunk-OEM5ARVM.js.map} +1 -1
  48. package/dist/{chunk-5EBGRG3X.js → chunk-OPA2Y6YZ.js} +3 -54
  49. package/dist/chunk-OPA2Y6YZ.js.map +1 -0
  50. package/dist/chunk-TZR36PPP.cjs +95 -0
  51. package/dist/chunk-TZR36PPP.cjs.map +1 -0
  52. package/dist/{chunk-WJEKRSPH.js → chunk-UEU23PTW.js} +3 -3
  53. package/dist/{chunk-WJEKRSPH.js.map → chunk-UEU23PTW.js.map} +1 -1
  54. package/dist/chunk-ZVBPRMHJ.cjs +153 -0
  55. package/dist/chunk-ZVBPRMHJ.cjs.map +1 -0
  56. package/dist/connect/docx.cjs +10 -88
  57. package/dist/connect/docx.cjs.map +1 -1
  58. package/dist/connect/docx.js +6 -86
  59. package/dist/connect/docx.js.map +1 -1
  60. package/dist/connect/index.cjs +293 -30
  61. package/dist/connect/index.cjs.map +1 -1
  62. package/dist/connect/index.js +278 -15
  63. package/dist/connect/index.js.map +1 -1
  64. package/dist/connection/ConnectedWorkflowRunner.d.ts +16 -2
  65. package/dist/connection/WorkflowRunnerDialogs.d.ts +37 -0
  66. package/dist/connection/useWorkflowThread.d.ts +12 -0
  67. package/dist/document-tools/index.cjs +7 -143
  68. package/dist/document-tools/index.cjs.map +1 -1
  69. package/dist/document-tools/index.js +5 -144
  70. package/dist/document-tools/index.js.map +1 -1
  71. package/dist/docx/index.cjs +18 -17
  72. package/dist/docx/index.cjs.map +1 -1
  73. package/dist/docx/index.js +3 -2
  74. package/dist/docx/index.js.map +1 -1
  75. package/dist/index.cjs +467 -383
  76. package/dist/index.js +5 -5
  77. package/dist/studio/index.cjs +3 -3
  78. package/dist/studio/index.js +2 -2
  79. package/dist/workflow-canvas/StepActionSettings.d.ts +132 -0
  80. package/dist/workflow-canvas/StepInspector.d.ts +25 -2
  81. package/dist/workflow-canvas/WorkflowBuilder.d.ts +11 -3
  82. package/dist/workflow-canvas/WorkflowCanvas.d.ts +27 -2
  83. package/dist/workflow-canvas/edit.d.ts +9 -1
  84. package/dist/workflow-canvas/index.cjs +879 -99
  85. package/dist/workflow-canvas/index.cjs.map +1 -1
  86. package/dist/workflow-canvas/index.js +846 -66
  87. package/dist/workflow-canvas/index.js.map +1 -1
  88. package/package.json +4 -4
  89. package/src/workflow-canvas/canvas.css +9 -0
  90. package/dist/chunk-22P5KNIM.js.map +0 -1
  91. package/dist/chunk-5EBGRG3X.js.map +0 -1
  92. package/dist/chunk-7FKARMA3.cjs.map +0 -1
  93. package/dist/chunk-IPGKTUF7.cjs.map +0 -1
  94. package/dist/chunk-TKB7TVMW.js.map +0 -1
  95. package/dist/chunk-UIWLDSTF.js.map +0 -1
  96. package/dist/chunk-VYRKO3XU.cjs.map +0 -1
  97. package/dist/chunk-ZWA7UUZL.cjs.map +0 -1
@@ -2,20 +2,23 @@
2
2
  'use strict';
3
3
 
4
4
  var chunkB3WCKBJ7_cjs = require('../chunk-B3WCKBJ7.cjs');
5
- var chunkHITAN7JF_cjs = require('../chunk-HITAN7JF.cjs');
5
+ var chunkGTXOV7IJ_cjs = require('../chunk-GTXOV7IJ.cjs');
6
+ var chunkTZR36PPP_cjs = require('../chunk-TZR36PPP.cjs');
6
7
  var chunkMUMH3Z6K_cjs = require('../chunk-MUMH3Z6K.cjs');
7
- var chunkVYRKO3XU_cjs = require('../chunk-VYRKO3XU.cjs');
8
+ var chunkZVBPRMHJ_cjs = require('../chunk-ZVBPRMHJ.cjs');
9
+ require('../chunk-7YUFMNFW.cjs');
10
+ var chunk3XR3IEGU_cjs = require('../chunk-3XR3IEGU.cjs');
8
11
  require('../chunk-DETZZBG2.cjs');
9
12
  require('../chunk-7D737FLE.cjs');
10
13
  var chunkQVBZESYQ_cjs = require('../chunk-QVBZESYQ.cjs');
11
14
  require('../chunk-ADOKTJHV.cjs');
12
- var chunkIPGKTUF7_cjs = require('../chunk-IPGKTUF7.cjs');
15
+ var chunkHOD6OM7L_cjs = require('../chunk-HOD6OM7L.cjs');
13
16
  require('../chunk-VGOFFCMT.cjs');
14
17
  require('../chunk-B4SRYJLM.cjs');
15
18
  require('../chunk-7UTB4PHM.cjs');
16
19
  require('../chunk-PPCATBOY.cjs');
17
20
  var chunkKDG6FER6_cjs = require('../chunk-KDG6FER6.cjs');
18
- require('../chunk-ULWRNGGE.cjs');
21
+ var chunkULWRNGGE_cjs = require('../chunk-ULWRNGGE.cjs');
19
22
  require('../chunk-MHVNT4J3.cjs');
20
23
  require('../chunk-DES3K4SD.cjs');
21
24
  var react = require('react');
@@ -25,6 +28,7 @@ var jsxRuntime = require('react/jsx-runtime');
25
28
  var ui = require('@arbidocs/react/ui');
26
29
  var artifacts = require('@arbidocs/react/artifacts');
27
30
  var lucideReact = require('lucide-react');
31
+ var documentTools = require('@arbidocs/react/document-tools');
28
32
  var shell = require('@arbidocs/react/shell');
29
33
 
30
34
  function ConnectionBoundWebSocket({ children }) {
@@ -185,8 +189,15 @@ function StreamedArtifact({
185
189
  }
186
190
  var STARTING = /* @__PURE__ */ new Set(["pending", "running"]);
187
191
  function formValues(step, inputs) {
188
- if (step.kind !== "form") return void 0;
189
- return Object.fromEntries(step.inputs.map((f) => [f.name, inputs[f.name] ?? ""]));
192
+ const fields = chunk3XR3IEGU_cjs.stepFields(step);
193
+ if (!fields.length) return void 0;
194
+ if (step.kind === "form")
195
+ return Object.fromEntries(fields.map((f) => [f.name, inputs[f.name] ?? ""]));
196
+ const given = fields.flatMap((f) => {
197
+ const v = inputs[f.name];
198
+ return v === void 0 || v === "" ? [] : [[f.name, v]];
199
+ });
200
+ return given.length ? Object.fromEntries(given) : void 0;
190
201
  }
191
202
  var ANSWER_RETRY_CAP = 16;
192
203
  function answerRetryDelay(attempt) {
@@ -212,29 +223,40 @@ function useAnswerRetry(missing, refetch) {
212
223
  }
213
224
  function useWorkflowThread(workflow, options = {}) {
214
225
  const arbi = react$1.useArbi();
215
- const { ensureWorkspaceOpen } = chunkMUMH3Z6K_cjs.useConnection();
216
- const { wsId } = chunkHITAN7JF_cjs.useWorkspaceDocs();
226
+ const { ensureWorkspaceOpen, status } = chunkMUMH3Z6K_cjs.useConnection();
227
+ const { wsId } = chunkGTXOV7IJ_cjs.useWorkspaceDocs();
217
228
  const [threadId, setThreadId] = react.useState(options.conversationId);
218
229
  const [localInputs, setLocalInputs] = react.useState(
219
- () => chunkVYRKO3XU_cjs.initialRunInputs(workflow, options.initialInputs)
230
+ () => chunk3XR3IEGU_cjs.initialRunInputs(workflow, options.initialInputs)
220
231
  );
221
232
  const [edits, setEdits] = react.useState({});
222
233
  const [localStates, setLocalStates] = react.useState({});
223
234
  const createWork = react$1.useCreateWork();
224
235
  const actOnStep = react$1.useActOnStep();
225
236
  const conversations = react$1.useConversations(wsId, { enabled: !!threadId, live: true });
237
+ const members = react$1.useWorkspaceUsers(wsId, {
238
+ enabled: status === "authenticated" && !!wsId,
239
+ beforeFetch: ensureWorkspaceOpen
240
+ });
241
+ const nameOf = react.useCallback(
242
+ (id) => {
243
+ const u = members.data?.find((m) => m.user.external_id === id)?.user;
244
+ return u ? [u.given_name, u.family_name].filter(Boolean).join(" ") || u.email : void 0;
245
+ },
246
+ [members.data]
247
+ );
226
248
  const conversation = conversations.data?.find((c) => c.external_id === threadId);
227
249
  const steps = react.useMemo(
228
- () => chunkVYRKO3XU_cjs.workflowSteps(workflow).length > 0 ? chunkVYRKO3XU_cjs.workflowSteps(workflow) : chunkVYRKO3XU_cjs.fromPlanSteps(conversation?.plan?.steps ?? []),
250
+ () => chunk3XR3IEGU_cjs.workflowSteps(workflow).length > 0 ? chunk3XR3IEGU_cjs.workflowSteps(workflow) : chunk3XR3IEGU_cjs.fromPlanSteps(conversation?.plan?.steps ?? []),
229
251
  [workflow, conversation?.plan?.steps]
230
252
  );
231
253
  const activity = react$1.useConversationActivity(threadId, { live: !!threadId });
232
254
  const serverStates = react.useMemo(
233
- () => chunkVYRKO3XU_cjs.stepStatesFromActivity(activity.data ?? []),
255
+ () => chunk3XR3IEGU_cjs.stepStatesFromActivity(activity.data ?? []),
234
256
  [activity.data]
235
257
  );
236
258
  const working = steps.some(
237
- (s) => s.kind === "agent" && STARTING.has(serverStates[s.id]?.status ?? "pending")
259
+ (s) => (s.kind === "agent" || s.kind === "action") && STARTING.has(serverStates[s.id]?.status ?? "pending")
238
260
  );
239
261
  const threads = react$1.useConversationThreads(wsId, threadId, { enabled: !!threadId, live: working });
240
262
  const answers = react.useMemo(() => {
@@ -282,7 +304,7 @@ function useWorkflowThread(workflow, options = {}) {
282
304
  if (!id) {
283
305
  await ensureWorkspaceOpen();
284
306
  const created = await createWork.mutateAsync({
285
- title: chunkVYRKO3XU_cjs.runThreadTitle(workflow, values).slice(0, 60),
307
+ title: chunk3XR3IEGU_cjs.runThreadTitle(workflow, values).slice(0, 60),
286
308
  description: workflow.description || null,
287
309
  prompt: null,
288
310
  skill_ref: null,
@@ -294,7 +316,7 @@ function useWorkflowThread(workflow, options = {}) {
294
316
  criteria: [],
295
317
  max_passes: 3,
296
318
  documents: [],
297
- steps: chunkVYRKO3XU_cjs.toPlanSteps(workflow, {
319
+ steps: chunk3XR3IEGU_cjs.toPlanSteps(workflow, {
298
320
  inputs: values,
299
321
  resolveWorkflow: options.resolveWorkflow,
300
322
  compose: options.compose
@@ -306,7 +328,13 @@ function useWorkflowThread(workflow, options = {}) {
306
328
  setLocalStates((s) => ({ ...s, [step.id]: { status: "done" } }));
307
329
  options.onStarted?.(id);
308
330
  }
309
- await act(id, { step: step.id, action: "complete", inputs: formValues(step, values) });
331
+ const documents = step.kind === "upload" ? options.documentsFor?.(step.id) : void 0;
332
+ await act(id, {
333
+ step: step.id,
334
+ action: "complete",
335
+ inputs: formValues(step, values),
336
+ ...documents?.length ? { documents } : {}
337
+ });
310
338
  },
311
339
  [inputs, options, localStates, threadId, ensureWorkspaceOpen, createWork, workflow, act]
312
340
  );
@@ -328,7 +356,22 @@ function useWorkflowThread(workflow, options = {}) {
328
356
  },
329
357
  [arbi, threadId, refresh]
330
358
  );
331
- const view = chunkVYRKO3XU_cjs.useWorkflowView({
359
+ const sendBack = react.useCallback(
360
+ async (stepId, to, note) => {
361
+ if (!threadId) return;
362
+ await act(threadId, { step: stepId, action: "send_back", to, ...note ? { note } : {} });
363
+ },
364
+ [threadId, act]
365
+ );
366
+ const decline = react.useCallback(
367
+ async (stepId, note) => {
368
+ if (!threadId) return;
369
+ await act(threadId, { step: stepId, action: "decline", ...note ? { note } : {} });
370
+ },
371
+ [threadId, act]
372
+ );
373
+ const loaded = !options.conversationId || activity.isSuccess || activity.isError;
374
+ const view = chunk3XR3IEGU_cjs.useWorkflowView({
332
375
  steps,
333
376
  states,
334
377
  inputs,
@@ -336,9 +379,171 @@ function useWorkflowThread(workflow, options = {}) {
336
379
  complete,
337
380
  skip,
338
381
  retry,
382
+ sendBack,
383
+ decline,
384
+ nameOf,
385
+ loaded,
339
386
  isLocked: (id) => states[id]?.status === "done"
340
387
  });
341
- return { view, conversationId: threadId, conversation };
388
+ const people = react.useMemo(
389
+ () => (members.data ?? []).filter((m) => !m.user.external_id.startsWith("agt-")).map((m) => ({
390
+ value: m.user.external_id,
391
+ label: nameOf(m.user.external_id) ?? m.user.external_id
392
+ })),
393
+ [members.data, nameOf]
394
+ );
395
+ return { view, conversationId: threadId, conversation, nameOf, people };
396
+ }
397
+ var DEFAULT_WORKFLOW_RUNNER_DIALOG_LABELS = {
398
+ loadingDocument: "Opening the document\u2026",
399
+ documentFailed: "The document could not be opened.",
400
+ reviewTitle: "Review",
401
+ reviewDescription: "Each document against each review column.",
402
+ document: "Document",
403
+ empty: "\u2014",
404
+ wordTitle: "Tracked changes"
405
+ };
406
+ function WorkflowSignDialog({
407
+ docRef,
408
+ onClose,
409
+ labels
410
+ }) {
411
+ const arbi = react$1.useArbi();
412
+ const { user, ensureWorkspaceOpen } = chunkMUMH3Z6K_cjs.useConnection();
413
+ const tools = documentTools.useOptionalDocumentTools();
414
+ const { id, version } = chunk3XR3IEGU_cjs.splitDocRef(docRef);
415
+ const [pdf, setPdf] = react.useState(null);
416
+ const [failed, setFailed] = react.useState(false);
417
+ react.useEffect(() => {
418
+ let live = true;
419
+ void (async () => {
420
+ try {
421
+ await ensureWorkspaceOpen();
422
+ const res = await arbi.documents.download(id, version);
423
+ if (!res.ok) throw new Error(String(res.status));
424
+ const blob = await res.blob();
425
+ if (live) setPdf(blob);
426
+ } catch {
427
+ if (live) setFailed(true);
428
+ }
429
+ })();
430
+ return () => {
431
+ live = false;
432
+ };
433
+ }, [arbi, id, version, ensureWorkspaceOpen]);
434
+ if (!pdf)
435
+ return /* @__PURE__ */ jsxRuntime.jsx(
436
+ chunkULWRNGGE_cjs.ModalScaffold,
437
+ {
438
+ open: true,
439
+ onOpenChange: (o) => !o && onClose(),
440
+ title: labels.loadingDocument,
441
+ size: "sm",
442
+ testId: "workflow-sign-loading",
443
+ children: /* @__PURE__ */ jsxRuntime.jsx(chunkULWRNGGE_cjs.ModalScaffold.Body, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: failed ? labels.documentFailed : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
444
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }),
445
+ " ",
446
+ labels.loadingDocument
447
+ ] }) }) })
448
+ }
449
+ );
450
+ const dialog = /* @__PURE__ */ jsxRuntime.jsx(chunkZVBPRMHJ_cjs.SignDocumentDialog, { open: true, onOpenChange: (o) => !o && onClose(), documentId: id, pdfBlob: pdf });
451
+ return tools ? dialog : /* @__PURE__ */ jsxRuntime.jsx(
452
+ documentTools.DocumentToolsProvider,
453
+ {
454
+ client: arbi.getClient().fetch,
455
+ user: user ? { name: user.name, email: user.email } : null,
456
+ children: dialog
457
+ }
458
+ );
459
+ }
460
+ function WorkflowWordDialog({
461
+ docRef,
462
+ title,
463
+ onClose,
464
+ labels
465
+ }) {
466
+ const { id } = chunk3XR3IEGU_cjs.splitDocRef(docRef);
467
+ return /* @__PURE__ */ jsxRuntime.jsx(
468
+ chunkULWRNGGE_cjs.ModalScaffold,
469
+ {
470
+ open: true,
471
+ onOpenChange: (o) => !o && onClose(),
472
+ title: title ?? labels.wordTitle,
473
+ size: "xl",
474
+ testId: "workflow-word-dialog",
475
+ children: /* @__PURE__ */ jsxRuntime.jsx(chunkULWRNGGE_cjs.ModalScaffold.Body, { className: "h-[70dvh] p-0", children: /* @__PURE__ */ jsxRuntime.jsx(chunkTZR36PPP_cjs.ConnectedNativeDocxEditor, { documentId: id, title: title ?? labels.wordTitle }) })
476
+ }
477
+ );
478
+ }
479
+ function WorkflowReviewGridDialog({
480
+ tags,
481
+ documents,
482
+ onClose,
483
+ onOpenDocument,
484
+ labels
485
+ }) {
486
+ const { workspaceId } = chunkMUMH3Z6K_cjs.useConnection();
487
+ const allTags = react$1.useTags(workspaceId ?? void 0);
488
+ const all = react$1.useDocuments(workspaceId ?? void 0);
489
+ const docs = {
490
+ isLoading: all.isLoading,
491
+ data: (all.data ?? []).filter((d) => documents.includes(d.external_id))
492
+ };
493
+ const columns = react.useMemo(
494
+ () => tags.map((id) => ({
495
+ id,
496
+ name: allTags.data?.find((t) => t.external_id === id)?.name ?? id
497
+ })),
498
+ [tags, allTags.data]
499
+ );
500
+ return /* @__PURE__ */ jsxRuntime.jsx(
501
+ chunkULWRNGGE_cjs.ModalScaffold,
502
+ {
503
+ open: true,
504
+ onOpenChange: (o) => !o && onClose(),
505
+ title: labels.reviewTitle,
506
+ description: labels.reviewDescription,
507
+ showDescription: true,
508
+ size: "xl",
509
+ testId: "workflow-review-grid",
510
+ children: /* @__PURE__ */ jsxRuntime.jsx(chunkULWRNGGE_cjs.ModalScaffold.Body, { className: "overflow-auto", children: docs.isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
511
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }),
512
+ " ",
513
+ labels.loadingDocument
514
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full border-collapse text-sm", children: [
515
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
516
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "sticky left-0 border-b border-border bg-card p-2 text-left font-medium", children: labels.document }),
517
+ columns.map((c) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: "border-b border-border p-2 text-left font-medium", children: c.name }, c.id))
518
+ ] }) }),
519
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: (docs.data ?? []).map((d) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { "data-testid": `workflow-review-grid-row-${d.external_id}`, children: [
520
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "sticky left-0 max-w-56 border-b border-border bg-card p-2 align-top", children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { onClick: onOpenDocument && (() => onOpenDocument(d.external_id)), children: d.file_name ?? d.external_id }) }),
521
+ columns.map((c) => {
522
+ const note = d.doctags?.find((t) => t.tag_ext_id === c.id)?.note;
523
+ return /* @__PURE__ */ jsxRuntime.jsx(
524
+ "td",
525
+ {
526
+ className: "max-w-72 border-b border-border p-2 align-top text-muted-foreground",
527
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-4 whitespace-pre-line", children: note || labels.empty })
528
+ },
529
+ c.id
530
+ );
531
+ })
532
+ ] }, d.external_id)) })
533
+ ] }) })
534
+ }
535
+ );
536
+ }
537
+ function Cell({ onClick, children }) {
538
+ return onClick ? /* @__PURE__ */ jsxRuntime.jsx(
539
+ "button",
540
+ {
541
+ type: "button",
542
+ onClick,
543
+ className: "truncate text-left font-medium text-primary hover:underline",
544
+ children
545
+ }
546
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children });
342
547
  }
343
548
  var DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS = {
344
549
  notify: "Ask to approve",
@@ -352,17 +557,52 @@ function ConnectedWorkflowRunner({
352
557
  onOpenConversation,
353
558
  emptyHint,
354
559
  connectedLabels,
560
+ onOpenDocument,
561
+ onOpenDraft,
562
+ onOpenMessage,
563
+ actions: hostActions,
564
+ dialogLabels,
355
565
  testIdPrefix = "workflow-run",
356
566
  ...runnerProps
357
567
  }) {
358
568
  const l = { ...DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS, ...connectedLabels };
569
+ const dl = { ...DEFAULT_WORKFLOW_RUNNER_DIALOG_LABELS, ...dialogLabels };
359
570
  const arbi = react$1.useArbi();
360
- const { ensureWorkspaceOpen } = chunkMUMH3Z6K_cjs.useConnection();
361
- const { wsId } = chunkHITAN7JF_cjs.useWorkspaceDocs();
571
+ const { ensureWorkspaceOpen, user } = chunkMUMH3Z6K_cjs.useConnection();
572
+ const { wsId } = chunkGTXOV7IJ_cjs.useWorkspaceDocs();
362
573
  const { data: docs = [], refetch } = react$1.useDocuments(wsId);
363
574
  const [uploading, setUploading] = react.useState(false);
364
- const { view, conversationId } = useWorkflowThread(workflow, options);
365
575
  const [added, setAdded] = react.useState({});
576
+ const addedRef = react.useRef(added);
577
+ addedRef.current = added;
578
+ const { view, conversationId, people } = useWorkflowThread(workflow, {
579
+ ...options,
580
+ // An upload step records exactly the files added on it (else the server's guess).
581
+ documentsFor: options?.documentsFor ?? ((stepId) => Object.entries(addedRef.current).flatMap(([doc, step]) => step === stepId ? [doc] : []))
582
+ });
583
+ const [dialog, setDialog] = react.useState(null);
584
+ const nameOfDoc = react.useCallback(
585
+ (id) => docs.find((d) => d.external_id === id)?.file_name ?? void 0,
586
+ [docs]
587
+ );
588
+ const actions = react.useMemo(
589
+ () => ({
590
+ me: user?.externalId,
591
+ openDocument: onOpenDocument && ((ref) => {
592
+ const { id, version } = chunk3XR3IEGU_cjs.splitDocRef(ref);
593
+ onOpenDocument(id, version);
594
+ }),
595
+ openDraft: onOpenDraft && ((draftId) => onOpenDraft(draftId)),
596
+ openMessage: onOpenMessage,
597
+ sign: hostActions?.sign ?? ((_step, state) => {
598
+ const w = state.waiting;
599
+ if (w?.doc_ext_id) setDialog({ kind: "sign", docRef: w.doc_ext_id });
600
+ }),
601
+ openRedline: hostActions?.openRedline ?? ((ref) => setDialog({ kind: "word", docRef: ref, title: nameOfDoc(chunk3XR3IEGU_cjs.splitDocRef(ref).id) ?? "" })),
602
+ openReview: hostActions?.openReview ?? ((tags, documents) => setDialog({ kind: "review", tags, documents }))
603
+ }),
604
+ [user?.externalId, onOpenDocument, onOpenDraft, onOpenMessage, hostActions, nameOfDoc]
605
+ );
366
606
  const onUpload = react.useCallback(
367
607
  async (files2, step) => {
368
608
  if (!files2.length) return;
@@ -435,8 +675,9 @@ function ConnectedWorkflowRunner({
435
675
  }
436
676
  ) }),
437
677
  /* @__PURE__ */ jsxRuntime.jsx(
438
- chunkVYRKO3XU_cjs.WorkflowRunner,
678
+ chunk3XR3IEGU_cjs.WorkflowRunner,
439
679
  {
680
+ people,
440
681
  ...runnerProps,
441
682
  workflow,
442
683
  run: view,
@@ -453,8 +694,30 @@ function ConnectedWorkflowRunner({
453
694
  onUpload,
454
695
  uploading,
455
696
  files,
697
+ actions,
698
+ nameOfDoc,
456
699
  testIdPrefix
457
700
  }
701
+ ),
702
+ dialog?.kind === "sign" && /* @__PURE__ */ jsxRuntime.jsx(WorkflowSignDialog, { docRef: dialog.docRef, onClose: () => setDialog(null), labels: dl }),
703
+ dialog?.kind === "word" && /* @__PURE__ */ jsxRuntime.jsx(
704
+ WorkflowWordDialog,
705
+ {
706
+ docRef: dialog.docRef,
707
+ title: dialog.title || void 0,
708
+ onClose: () => setDialog(null),
709
+ labels: dl
710
+ }
711
+ ),
712
+ dialog?.kind === "review" && /* @__PURE__ */ jsxRuntime.jsx(
713
+ WorkflowReviewGridDialog,
714
+ {
715
+ tags: dialog.tags,
716
+ documents: dialog.documents,
717
+ onClose: () => setDialog(null),
718
+ onOpenDocument: onOpenDocument && ((id) => onOpenDocument(id)),
719
+ labels: dl
720
+ }
458
721
  )
459
722
  ] });
460
723
  }
@@ -1068,7 +1331,7 @@ function mapWorkNotification(note) {
1068
1331
  function ActiveChat({ agentId, workspaceId }) {
1069
1332
  const chat = react$1.useArbiChat({ agentId, workspaceId });
1070
1333
  return /* @__PURE__ */ jsxRuntime.jsx(
1071
- chunkIPGKTUF7_cjs.ChatPage,
1334
+ chunkHOD6OM7L_cjs.ChatPage,
1072
1335
  {
1073
1336
  chat: { ...chat, assistantMode: void 0, setAssistantMode: void 0 },
1074
1337
  documentsRequired: false,
@@ -1130,35 +1393,35 @@ function ConnectedAgentChatPanel({
1130
1393
 
1131
1394
  Object.defineProperty(exports, "ConnectedAssistantDock", {
1132
1395
  enumerable: true,
1133
- get: function () { return chunkHITAN7JF_cjs.ConnectedAssistantDock; }
1396
+ get: function () { return chunkGTXOV7IJ_cjs.ConnectedAssistantDock; }
1134
1397
  });
1135
1398
  Object.defineProperty(exports, "redlineStats", {
1136
1399
  enumerable: true,
1137
- get: function () { return chunkHITAN7JF_cjs.redlineStats; }
1400
+ get: function () { return chunkGTXOV7IJ_cjs.redlineStats; }
1138
1401
  });
1139
1402
  Object.defineProperty(exports, "textToArtifact", {
1140
1403
  enumerable: true,
1141
- get: function () { return chunkHITAN7JF_cjs.textToArtifact; }
1404
+ get: function () { return chunkGTXOV7IJ_cjs.textToArtifact; }
1142
1405
  });
1143
1406
  Object.defineProperty(exports, "toRedlineMarkdown", {
1144
1407
  enumerable: true,
1145
- get: function () { return chunkHITAN7JF_cjs.toRedlineMarkdown; }
1408
+ get: function () { return chunkGTXOV7IJ_cjs.toRedlineMarkdown; }
1146
1409
  });
1147
1410
  Object.defineProperty(exports, "useConnectedAiTask", {
1148
1411
  enumerable: true,
1149
- get: function () { return chunkHITAN7JF_cjs.useConnectedAiTask; }
1412
+ get: function () { return chunkGTXOV7IJ_cjs.useConnectedAiTask; }
1150
1413
  });
1151
1414
  Object.defineProperty(exports, "useConnectedChat", {
1152
1415
  enumerable: true,
1153
- get: function () { return chunkHITAN7JF_cjs.useConnectedChat; }
1416
+ get: function () { return chunkGTXOV7IJ_cjs.useConnectedChat; }
1154
1417
  });
1155
1418
  Object.defineProperty(exports, "useSemanticSearch", {
1156
1419
  enumerable: true,
1157
- get: function () { return chunkHITAN7JF_cjs.useSemanticSearch; }
1420
+ get: function () { return chunkGTXOV7IJ_cjs.useSemanticSearch; }
1158
1421
  });
1159
1422
  Object.defineProperty(exports, "useWorkspaceDocs", {
1160
1423
  enumerable: true,
1161
- get: function () { return chunkHITAN7JF_cjs.useWorkspaceDocs; }
1424
+ get: function () { return chunkGTXOV7IJ_cjs.useWorkspaceDocs; }
1162
1425
  });
1163
1426
  Object.defineProperty(exports, "ConnectionProvider", {
1164
1427
  enumerable: true,