@arbidocs/blocks 0.4.79 → 0.4.81

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 (46) hide show
  1. package/dist/agents/index.cjs +278 -278
  2. package/dist/agents/index.js +3 -3
  3. package/dist/agents/workflows/StepBarFrame.d.ts +8 -2
  4. package/dist/agents/workflows/WorkflowRunner.d.ts +35 -3
  5. package/dist/agents/workflows/run.d.ts +10 -0
  6. package/dist/agents/workflows/stepWindow.d.ts +7 -0
  7. package/dist/agents/workflows/types.d.ts +4 -2
  8. package/dist/{chunk-5XVWGJ2H.cjs → chunk-B3WCKBJ7.cjs} +3 -3
  9. package/dist/{chunk-5XVWGJ2H.cjs.map → chunk-B3WCKBJ7.cjs.map} +1 -1
  10. package/dist/{chunk-YGUKTFKW.cjs → chunk-BX7JWZWE.cjs} +122 -14
  11. package/dist/chunk-BX7JWZWE.cjs.map +1 -0
  12. package/dist/{chunk-3YET6D5E.cjs → chunk-F5WIETZY.cjs} +58 -43
  13. package/dist/chunk-F5WIETZY.cjs.map +1 -0
  14. package/dist/{chunk-O35LRB3P.js → chunk-GJV2G4FC.js} +3 -3
  15. package/dist/{chunk-O35LRB3P.js.map → chunk-GJV2G4FC.js.map} +1 -1
  16. package/dist/{chunk-BMOL5DN6.js → chunk-I56ORHPY.js} +27 -12
  17. package/dist/chunk-I56ORHPY.js.map +1 -0
  18. package/dist/{chunk-CWAZNXC5.js → chunk-SWSVPQNB.js} +30 -8
  19. package/dist/chunk-SWSVPQNB.js.map +1 -0
  20. package/dist/{chunk-6GXF62XN.js → chunk-THCFZKTM.js} +118 -15
  21. package/dist/chunk-THCFZKTM.js.map +1 -0
  22. package/dist/{chunk-MLAHDAN5.cjs → chunk-UA2AMDR6.cjs} +30 -8
  23. package/dist/chunk-UA2AMDR6.cjs.map +1 -0
  24. package/dist/connect/index.cjs +145 -62
  25. package/dist/connect/index.cjs.map +1 -1
  26. package/dist/connect/index.d.ts +1 -1
  27. package/dist/connect/index.js +106 -23
  28. package/dist/connect/index.js.map +1 -1
  29. package/dist/connection/ConnectedWorkflowRunner.d.ts +30 -4
  30. package/dist/files/index.cjs +2 -2
  31. package/dist/files/index.js +2 -2
  32. package/dist/index.cjs +467 -467
  33. package/dist/index.js +7 -7
  34. package/dist/settings/index.cjs +35 -35
  35. package/dist/settings/index.js +3 -3
  36. package/dist/workflow-canvas/index.cjs +46 -46
  37. package/dist/workflow-canvas/index.js +3 -3
  38. package/dist/workspaces/index.cjs +1 -1
  39. package/dist/workspaces/index.js +1 -1
  40. package/package.json +4 -4
  41. package/dist/chunk-3YET6D5E.cjs.map +0 -1
  42. package/dist/chunk-6GXF62XN.js.map +0 -1
  43. package/dist/chunk-BMOL5DN6.js.map +0 -1
  44. package/dist/chunk-CWAZNXC5.js.map +0 -1
  45. package/dist/chunk-MLAHDAN5.cjs.map +0 -1
  46. package/dist/chunk-YGUKTFKW.cjs.map +0 -1
@@ -9,7 +9,7 @@ export { ConnectedTaskAccessRequest } from '../connection/ConnectedTaskAccessReq
9
9
  export { ConnectedSkillUpload } from '../connection/ConnectedSkillUpload';
10
10
  export { useConnectedAiTask, useConnectedChat, ConnectedAssistantDock, useWorkspaceDocs, useSemanticSearch, toRedlineMarkdown, redlineStats, textToArtifact, type AiTaskStatus, type AiRunOptions, type SearchChunk, type ArtifactEvent, } from '../connection/ai';
11
11
  export { StreamedArtifact, type StreamedArtifactProps } from '../connection/StreamedArtifact';
12
- export { ConnectedWorkflowRunner, DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS, type ConnectedWorkflowRunnerProps, type ConnectedWorkflowRunnerLabels, } from '../connection/ConnectedWorkflowRunner';
12
+ export { ConnectedWorkflowRunner, DEFAULT_CONNECTED_WORKFLOW_RUNNER_LABELS, type ConnectedWorkflowRunnerProps, type ConnectedWorkflowRunnerLabels, type WorkflowRunnerDocument, } from '../connection/ConnectedWorkflowRunner';
13
13
  export { WorkflowRunThread, type WorkflowRunThreadProps } from '../connection/WorkflowRunThread';
14
14
  export { ConnectedTagMatrix, type ConnectedTagMatrixProps } from '../connection/ConnectedTagMatrix';
15
15
  export { useConnectedShellWorkspaces, type UseConnectedShellWorkspacesOptions, } from '../connection/useConnectedShellWorkspaces';
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { SettingsSection, ProfileCard, AvatarPicker, IdentityVerificationCard, IdentityVerificationDialog, RequireVerified, SettingsCard, SettingsActionRow, PasswordChangeDialog, EMAIL_NOTIFICATION_KEYS, EMAIL_NOTIFICATION_CATEGORIES, NotificationCategoryList, toNotificationCategories, toActiveSessionViews, SettingsRow, ActiveSessionsDialog, LogoutDialog, toLogoutSessionViews, SettingsDangerZone, DeleteAccountDialog, toDeleteBlockerViews } from '../chunk-O35LRB3P.js';
2
+ import { SettingsSection, ProfileCard, AvatarPicker, IdentityVerificationCard, IdentityVerificationDialog, RequireVerified, SettingsCard, SettingsActionRow, PasswordChangeDialog, EMAIL_NOTIFICATION_KEYS, EMAIL_NOTIFICATION_CATEGORIES, NotificationCategoryList, toNotificationCategories, toActiveSessionViews, SettingsRow, ActiveSessionsDialog, LogoutDialog, toLogoutSessionViews, SettingsDangerZone, DeleteAccountDialog, toDeleteBlockerViews } from '../chunk-GJV2G4FC.js';
3
3
  import { useWorkspaceDocs } from '../chunk-XQDM6T6C.js';
4
4
  export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-XQDM6T6C.js';
5
5
  import { ConnectedNativeDocxEditor } from '../chunk-A24C6BNA.js';
@@ -7,19 +7,19 @@ import { ConnectionProvider, useConnection } from '../chunk-OYMWV45N.js';
7
7
  export { ConnectionProvider, SESSION_EXPIRED_MESSAGE, isAuthenticated, useConnection } from '../chunk-OYMWV45N.js';
8
8
  import { SignDocumentDialog } from '../chunk-FE4ULGOR.js';
9
9
  import '../chunk-OPA2Y6YZ.js';
10
- import { TagMatrix, tagMatrixMarkdown } from '../chunk-CWAZNXC5.js';
11
- import { splitDocRef, WorkflowStepBar, stepLevels, WorkflowRunner, initialRunInputs, workflowSteps, fromPlanSteps, stepStatesFromActivity, toPlanSteps, runThreadTitle, useWorkflowView, stepFields } from '../chunk-6GXF62XN.js';
10
+ import { TagMatrix, tagMatrixMarkdown } from '../chunk-SWSVPQNB.js';
11
+ import { StreamedArtifactFrame } from '../chunk-LOJVUGBJ.js';
12
+ import { splitDocRef, WorkflowStepBar, stepLevels, WorkflowRunner, initialRunInputs, workflowSteps, fromPlanSteps, stepStatesFromActivity, toPlanSteps, runThreadTitle, useWorkflowView, stepFields } from '../chunk-THCFZKTM.js';
12
13
  import '../chunk-EVUEIBNU.js';
13
14
  import '../chunk-XD2M6LIG.js';
14
- import { StreamedArtifactFrame } from '../chunk-LOJVUGBJ.js';
15
15
  import '../chunk-VILAPTCB.js';
16
- import { ModalScaffold } from '../chunk-TX2ZICS7.js';
17
16
  import { ChatPage } from '../chunk-EWSEQEPL.js';
18
17
  import '../chunk-KZJAG7T3.js';
19
18
  import '../chunk-HOXKR26S.js';
20
19
  import '../chunk-AA3PT6KR.js';
21
20
  import '../chunk-NPLYHR2E.js';
22
21
  import { initials } from '../chunk-OXF2IFXG.js';
22
+ import { ModalScaffold } from '../chunk-TX2ZICS7.js';
23
23
  import '../chunk-7F6CBP3Z.js';
24
24
  import '../chunk-VUNV25KB.js';
25
25
  import { lazy, useState, Suspense, useEffect, useRef, useCallback, useMemo } from 'react';
@@ -593,11 +593,13 @@ function ConnectedWorkflowRunner({
593
593
  emptyHint,
594
594
  connectedLabels,
595
595
  onOpenDocument,
596
+ onOpenCitation,
596
597
  onOpenDraft,
597
598
  onOpenMessage,
598
599
  actions: hostActions,
599
600
  dialogLabels,
600
601
  layout = "thread",
602
+ fileFilter,
601
603
  testIdPrefix = "workflow-run",
602
604
  ...runnerProps
603
605
  }) {
@@ -607,8 +609,9 @@ function ConnectedWorkflowRunner({
607
609
  const { ensureWorkspaceOpen, user } = useConnection();
608
610
  const { wsId } = useWorkspaceDocs();
609
611
  const { data: docs = [], refetch } = useDocuments(wsId);
610
- const [uploading, setUploading] = useState(false);
612
+ const [sending, setSending] = useState([]);
611
613
  const [added, setAdded] = useState({});
614
+ const [addedNames, setAddedNames] = useState({});
612
615
  const addedRef = useRef(added);
613
616
  addedRef.current = added;
614
617
  const { view, conversationId, people } = useWorkflowThread(workflow, {
@@ -642,29 +645,86 @@ function ConnectedWorkflowRunner({
642
645
  }),
643
646
  [user?.externalId, onOpenDocument, onOpenDraft, onOpenMessage, hostActions, nameOfDoc, inThread]
644
647
  );
645
- const onUpload = useCallback(
646
- async (files2, step) => {
647
- if (!files2.length) return;
648
- setUploading(true);
648
+ const openCitation = useMemo(
649
+ () => onOpenCitation ?? (onOpenDocument && ((t) => {
650
+ const docId = t.documentId ?? t.passage?.documentId;
651
+ if (docId) onOpenDocument(docId, void 0, t.page ?? t.passage?.page ?? void 0);
652
+ })),
653
+ [onOpenCitation, onOpenDocument]
654
+ );
655
+ const uploadSeq = useRef(0);
656
+ const sendingRef = useRef(sending);
657
+ sendingRef.current = sending;
658
+ const send = useCallback(
659
+ async (batch) => {
660
+ if (!batch.length) return;
661
+ const keys = new Set(batch.map((p) => p.key));
662
+ const mark = (key, patch) => setSending(
663
+ (all) => patch === null ? all.filter((p) => p.key !== key) : all.map((p) => p.key === key ? { ...p, ...patch } : p)
664
+ );
665
+ setSending((all) => [
666
+ ...all.filter((p) => !keys.has(p.key)),
667
+ ...batch.map((p) => ({ ...p, status: "uploading", error: void 0 }))
668
+ ]);
649
669
  try {
650
670
  await ensureWorkspaceOpen();
651
- for (const f of files2) {
652
- const { doc_ext_ids = [] } = await arbi.documents.uploadFile(f, f.name) ?? {};
653
- setAdded((a) => ({ ...a, ...Object.fromEntries(doc_ext_ids.map((id) => [id, step.id])) }));
671
+ } catch (e) {
672
+ for (const p of batch) mark(p.key, { status: "failed", error: uploadError(e) });
673
+ return;
674
+ }
675
+ for (const p of batch) {
676
+ try {
677
+ const { doc_ext_ids = [] } = await arbi.documents.uploadFile(p.file, p.file.name) ?? {};
678
+ if (!doc_ext_ids.length) throw new Error("No document came back");
679
+ setAdded((a) => ({
680
+ ...a,
681
+ ...Object.fromEntries(doc_ext_ids.map((id) => [id, p.stepId]))
682
+ }));
683
+ setAddedNames((n) => ({
684
+ ...n,
685
+ ...Object.fromEntries(doc_ext_ids.map((id) => [id, p.file.name]))
686
+ }));
687
+ mark(p.key, null);
688
+ } catch (e) {
689
+ mark(p.key, { status: "failed", error: uploadError(e) });
654
690
  }
655
- await refetch();
656
- } finally {
657
- setUploading(false);
658
691
  }
692
+ await refetch();
659
693
  },
660
694
  [arbi, ensureWorkspaceOpen, refetch]
661
695
  );
662
- const files = docs.map((d) => ({
663
- id: d.external_id,
664
- name: d.file_name ?? d.external_id,
665
- status: fileStatus(d.status),
666
- addedFor: added[d.external_id]
667
- }));
696
+ const onUpload = useCallback(
697
+ (files2, step) => send(
698
+ files2.map((file) => ({
699
+ key: `upload-${++uploadSeq.current}`,
700
+ file,
701
+ stepId: step.id,
702
+ status: "uploading"
703
+ }))
704
+ ),
705
+ [send]
706
+ );
707
+ const onRetryUpload = useCallback(
708
+ (file) => {
709
+ const p = sendingRef.current.find((x) => x.key === file.id);
710
+ if (p) void send([p]);
711
+ },
712
+ [send]
713
+ );
714
+ const onRemoveUpload = useCallback(
715
+ (file) => setSending((all) => all.filter((p) => p.key !== file.id)),
716
+ []
717
+ );
718
+ const files = [
719
+ ...sending.map((p) => ({
720
+ id: p.key,
721
+ name: p.file.name,
722
+ status: p.status === "failed" ? "upload-failed" : "uploading",
723
+ error: p.error,
724
+ addedFor: p.stepId
725
+ })),
726
+ ...runnerFiles(docs, added, fileFilter, addedNames)
727
+ ];
668
728
  const reading = files.some((f) => f.addedFor && f.status === "processing");
669
729
  useEffect(() => {
670
730
  if (!reading) return;
@@ -733,8 +793,10 @@ function ConnectedWorkflowRunner({
733
793
  }
734
794
  ) : null,
735
795
  onUpload,
736
- uploading,
796
+ uploading: sending.some((p) => p.status === "uploading"),
737
797
  files,
798
+ onRetryUpload,
799
+ onRemoveUpload,
738
800
  actions,
739
801
  nameOfDoc,
740
802
  testIdPrefix,
@@ -776,6 +838,7 @@ function ConnectedWorkflowRunner({
776
838
  workspaceId: wsId,
777
839
  stepTitle: (id) => view.steps.find((s) => s.id === id)?.title,
778
840
  targetMessageId: target,
841
+ onOpenCitation: openCitation,
779
842
  labels: { workflows: l.currentStep },
780
843
  aside: runner(true)
781
844
  }
@@ -804,6 +867,26 @@ function ConnectedWorkflowRunner({
804
867
  ] });
805
868
  }
806
869
  var READ_POLL_MS = 3e3;
870
+ function uploadError(e) {
871
+ return e instanceof Error && e.message ? e.message : String(e || "Upload failed");
872
+ }
873
+ function runnerFiles(docs, added, fileFilter, names = {}) {
874
+ const listed = new Set(docs.map((d) => d.external_id));
875
+ return [
876
+ ...docs.filter((d) => !fileFilter || added[d.external_id] || fileFilter(d)).map((d) => ({
877
+ id: d.external_id,
878
+ name: d.file_name ?? d.external_id,
879
+ status: fileStatus(d.status),
880
+ addedFor: added[d.external_id]
881
+ })),
882
+ ...Object.entries(added).filter(([id]) => !listed.has(id)).map(([id, stepId]) => ({
883
+ id,
884
+ name: names[id] ?? id,
885
+ status: "processing",
886
+ addedFor: stepId
887
+ }))
888
+ ];
889
+ }
807
890
  function fileStatus(status) {
808
891
  const s = status?.toLowerCase();
809
892
  if (!s) return void 0;