@arbidocs/blocks 0.4.80 → 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 (65) hide show
  1. package/dist/agents/index.cjs +280 -280
  2. package/dist/agents/index.js +5 -5
  3. package/dist/agents/workflows/WorkflowRunner.d.ts +35 -3
  4. package/dist/agents/workflows/run.d.ts +10 -0
  5. package/dist/agents/workflows/types.d.ts +4 -2
  6. package/dist/chat/index.cjs +125 -125
  7. package/dist/chat/index.js +3 -3
  8. package/dist/{chunk-MFDGNUKX.cjs → chunk-B3WCKBJ7.cjs} +3 -3
  9. package/dist/{chunk-MFDGNUKX.cjs.map → chunk-B3WCKBJ7.cjs.map} +1 -1
  10. package/dist/{chunk-2FEQGDW2.cjs → chunk-BX7JWZWE.cjs} +97 -5
  11. package/dist/chunk-BX7JWZWE.cjs.map +1 -0
  12. package/dist/{chunk-P5ST47VY.js → chunk-DDF5GPIJ.js} +3 -3
  13. package/dist/{chunk-P5ST47VY.js.map → chunk-DDF5GPIJ.js.map} +1 -1
  14. package/dist/{chunk-PFA43QNX.js → chunk-EWSEQEPL.js} +3 -3
  15. package/dist/{chunk-PFA43QNX.js.map → chunk-EWSEQEPL.js.map} +1 -1
  16. package/dist/{chunk-LGDX34UR.cjs → chunk-F5WIETZY.cjs} +66 -51
  17. package/dist/chunk-F5WIETZY.cjs.map +1 -0
  18. package/dist/{chunk-E367ZUHE.js → chunk-GJV2G4FC.js} +3 -3
  19. package/dist/{chunk-E367ZUHE.js.map → chunk-GJV2G4FC.js.map} +1 -1
  20. package/dist/{chunk-A5WCK6ZG.js → chunk-I56ORHPY.js} +28 -13
  21. package/dist/chunk-I56ORHPY.js.map +1 -0
  22. package/dist/{chunk-LBE36YNZ.js → chunk-ICBAFX5B.js} +3 -3
  23. package/dist/{chunk-LBE36YNZ.js.map → chunk-ICBAFX5B.js.map} +1 -1
  24. package/dist/{chunk-C3DRLFU7.cjs → chunk-IF6VAYIA.cjs} +5 -5
  25. package/dist/{chunk-C3DRLFU7.cjs.map → chunk-IF6VAYIA.cjs.map} +1 -1
  26. package/dist/{chunk-O5NDG4EA.cjs → chunk-MP6FK43E.cjs} +3 -3
  27. package/dist/{chunk-O5NDG4EA.cjs.map → chunk-MP6FK43E.cjs.map} +1 -1
  28. package/dist/{chunk-QFA3NCWL.js → chunk-THCFZKTM.js} +95 -6
  29. package/dist/chunk-THCFZKTM.js.map +1 -0
  30. package/dist/{chunk-HUJLKDWX.cjs → chunk-XMBYDLZQ.cjs} +4 -4
  31. package/dist/{chunk-HUJLKDWX.cjs.map → chunk-XMBYDLZQ.cjs.map} +1 -1
  32. package/dist/{chunk-WDD255XQ.js → chunk-XQDM6T6C.js} +3 -3
  33. package/dist/{chunk-WDD255XQ.js.map → chunk-XQDM6T6C.js.map} +1 -1
  34. package/dist/{chunk-ZV3BKLFY.cjs → chunk-Z5VUZ6YD.cjs} +3 -3
  35. package/dist/{chunk-ZV3BKLFY.cjs.map → chunk-Z5VUZ6YD.cjs.map} +1 -1
  36. package/dist/connect/index.cjs +154 -75
  37. package/dist/connect/index.cjs.map +1 -1
  38. package/dist/connect/index.js +106 -27
  39. package/dist/connect/index.js.map +1 -1
  40. package/dist/connection/ConnectedWorkflowRunner.d.ts +16 -5
  41. package/dist/facts/index.cjs +2 -2
  42. package/dist/facts/index.js +2 -2
  43. package/dist/files/index.cjs +2 -2
  44. package/dist/files/index.js +2 -2
  45. package/dist/home/index.cjs +18 -18
  46. package/dist/home/index.js +4 -4
  47. package/dist/index.cjs +503 -503
  48. package/dist/index.js +9 -9
  49. package/dist/retrieval/index.cjs +1 -1
  50. package/dist/retrieval/index.js +1 -1
  51. package/dist/settings/index.cjs +35 -35
  52. package/dist/settings/index.js +2 -2
  53. package/dist/shell/index.cjs +1 -1
  54. package/dist/shell/index.js +1 -1
  55. package/dist/studio/index.cjs +5 -5
  56. package/dist/studio/index.js +4 -4
  57. package/dist/workflow-canvas/index.cjs +48 -48
  58. package/dist/workflow-canvas/index.js +5 -5
  59. package/dist/workspaces/index.cjs +2 -2
  60. package/dist/workspaces/index.js +2 -2
  61. package/package.json +4 -4
  62. package/dist/chunk-2FEQGDW2.cjs.map +0 -1
  63. package/dist/chunk-A5WCK6ZG.js.map +0 -1
  64. package/dist/chunk-LGDX34UR.cjs.map +0 -1
  65. package/dist/chunk-QFA3NCWL.js.map +0 -1
@@ -1,26 +1,26 @@
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-E367ZUHE.js';
3
- import { useWorkspaceDocs } from '../chunk-WDD255XQ.js';
4
- export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-WDD255XQ.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
+ import { useWorkspaceDocs } from '../chunk-XQDM6T6C.js';
4
+ export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-XQDM6T6C.js';
5
5
  import { ConnectedNativeDocxEditor } from '../chunk-A24C6BNA.js';
6
6
  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
10
  import { TagMatrix, tagMatrixMarkdown } from '../chunk-SWSVPQNB.js';
11
- import { splitDocRef, WorkflowStepBar, stepLevels, WorkflowRunner, initialRunInputs, workflowSteps, fromPlanSteps, stepStatesFromActivity, toPlanSteps, runThreadTitle, useWorkflowView, stepFields } from '../chunk-QFA3NCWL.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 { ChatPage } from '../chunk-PFA43QNX.js';
16
+ import { ChatPage } from '../chunk-EWSEQEPL.js';
17
17
  import '../chunk-KZJAG7T3.js';
18
18
  import '../chunk-HOXKR26S.js';
19
19
  import '../chunk-AA3PT6KR.js';
20
20
  import '../chunk-NPLYHR2E.js';
21
+ import { initials } from '../chunk-OXF2IFXG.js';
21
22
  import { ModalScaffold } from '../chunk-TX2ZICS7.js';
22
23
  import '../chunk-7F6CBP3Z.js';
23
- import { initials } from '../chunk-OXF2IFXG.js';
24
24
  import '../chunk-VUNV25KB.js';
25
25
  import { lazy, useState, Suspense, useEffect, useRef, useCallback, useMemo } from 'react';
26
26
  import { QueryClient, QueryClientProvider, useQueryClient, useQuery } from '@tanstack/react-query';
@@ -593,6 +593,7 @@ function ConnectedWorkflowRunner({
593
593
  emptyHint,
594
594
  connectedLabels,
595
595
  onOpenDocument,
596
+ onOpenCitation,
596
597
  onOpenDraft,
597
598
  onOpenMessage,
598
599
  actions: hostActions,
@@ -608,8 +609,9 @@ function ConnectedWorkflowRunner({
608
609
  const { ensureWorkspaceOpen, user } = useConnection();
609
610
  const { wsId } = useWorkspaceDocs();
610
611
  const { data: docs = [], refetch } = useDocuments(wsId);
611
- const [uploading, setUploading] = useState(false);
612
+ const [sending, setSending] = useState([]);
612
613
  const [added, setAdded] = useState({});
614
+ const [addedNames, setAddedNames] = useState({});
613
615
  const addedRef = useRef(added);
614
616
  addedRef.current = added;
615
617
  const { view, conversationId, people } = useWorkflowThread(workflow, {
@@ -643,24 +645,86 @@ function ConnectedWorkflowRunner({
643
645
  }),
644
646
  [user?.externalId, onOpenDocument, onOpenDraft, onOpenMessage, hostActions, nameOfDoc, inThread]
645
647
  );
646
- const onUpload = useCallback(
647
- async (files2, step) => {
648
- if (!files2.length) return;
649
- 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
+ ]);
650
669
  try {
651
670
  await ensureWorkspaceOpen();
652
- for (const f of files2) {
653
- const { doc_ext_ids = [] } = await arbi.documents.uploadFile(f, f.name) ?? {};
654
- 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) });
655
690
  }
656
- await refetch();
657
- } finally {
658
- setUploading(false);
659
691
  }
692
+ await refetch();
660
693
  },
661
694
  [arbi, ensureWorkspaceOpen, refetch]
662
695
  );
663
- const files = runnerFiles(docs, added, fileFilter);
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
+ ];
664
728
  const reading = files.some((f) => f.addedFor && f.status === "processing");
665
729
  useEffect(() => {
666
730
  if (!reading) return;
@@ -729,8 +793,10 @@ function ConnectedWorkflowRunner({
729
793
  }
730
794
  ) : null,
731
795
  onUpload,
732
- uploading,
796
+ uploading: sending.some((p) => p.status === "uploading"),
733
797
  files,
798
+ onRetryUpload,
799
+ onRemoveUpload,
734
800
  actions,
735
801
  nameOfDoc,
736
802
  testIdPrefix,
@@ -772,6 +838,7 @@ function ConnectedWorkflowRunner({
772
838
  workspaceId: wsId,
773
839
  stepTitle: (id) => view.steps.find((s) => s.id === id)?.title,
774
840
  targetMessageId: target,
841
+ onOpenCitation: openCitation,
775
842
  labels: { workflows: l.currentStep },
776
843
  aside: runner(true)
777
844
  }
@@ -800,13 +867,25 @@ function ConnectedWorkflowRunner({
800
867
  ] });
801
868
  }
802
869
  var READ_POLL_MS = 3e3;
803
- function runnerFiles(docs, added, fileFilter) {
804
- return docs.filter((d) => !fileFilter || added[d.external_id] || fileFilter(d)).map((d) => ({
805
- id: d.external_id,
806
- name: d.file_name ?? d.external_id,
807
- status: fileStatus(d.status),
808
- addedFor: added[d.external_id]
809
- }));
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
+ ];
810
889
  }
811
890
  function fileStatus(status) {
812
891
  const s = status?.toLowerCase();