@arbidocs/blocks 0.5.184 → 0.5.185
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.
- package/dist/{ConnectedCallDock-CF7KF5KM.cjs → ConnectedCallDock-CKJUL7HZ.cjs} +6 -6
- package/dist/{ConnectedCallDock-CF7KF5KM.cjs.map → ConnectedCallDock-CKJUL7HZ.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-NQOE2RYD.cjs → ConnectedCallRoom-CDOGHVES.cjs} +6 -6
- package/dist/{ConnectedCallRoom-NQOE2RYD.cjs.map → ConnectedCallRoom-CDOGHVES.cjs.map} +1 -1
- package/dist/{ConnectedMailInviteCard-DDGB4LLC.cjs → ConnectedMailInviteCard-ZNBHPFKF.cjs} +8 -8
- package/dist/{ConnectedMailInviteCard-DDGB4LLC.cjs.map → ConnectedMailInviteCard-ZNBHPFKF.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-2YMF257D.cjs → ConnectedNativeDocxComparison-YP7SASIP.cjs} +9 -9
- package/dist/{ConnectedNativeDocxComparison-2YMF257D.cjs.map → ConnectedNativeDocxComparison-YP7SASIP.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-LNDESKYE.cjs → ConnectedPresentation-RFUH3MXL.cjs} +10 -10
- package/dist/{ConnectedPresentation-LNDESKYE.cjs.map → ConnectedPresentation-RFUH3MXL.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-SYDDGJWM.cjs → ConnectedSlidesTab-CCJWFSCX.cjs} +10 -10
- package/dist/{ConnectedSlidesTab-SYDDGJWM.cjs.map → ConnectedSlidesTab-CCJWFSCX.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-3K5WTQMZ.cjs → ConnectedStreamedWordArtifact-GVVIWKFH.cjs} +9 -9
- package/dist/{ConnectedStreamedWordArtifact-3K5WTQMZ.cjs.map → ConnectedStreamedWordArtifact-GVVIWKFH.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-3NNHDWG3.cjs → DocumentReviewCard-QD6VVDAE.cjs} +15 -15
- package/dist/{DocumentReviewCard-3NNHDWG3.cjs.map → DocumentReviewCard-QD6VVDAE.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-OKLWGMIO.cjs → FilesViewerDialog-S5KRHOFU.cjs} +27 -27
- package/dist/{FilesViewerDialog-OKLWGMIO.cjs.map → FilesViewerDialog-S5KRHOFU.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-LGDLG3TX.cjs → WorkspaceTableView-TPL6EWXL.cjs} +8 -8
- package/dist/{WorkspaceTableView-LGDLG3TX.cjs.map → WorkspaceTableView-TPL6EWXL.cjs.map} +1 -1
- package/dist/agents/index.cjs +177 -177
- package/dist/{ai-CTJWECJ5.cjs → ai-6K5DTBLO.cjs} +16 -16
- package/dist/ai-6K5DTBLO.cjs.map +1 -0
- package/dist/{avatar-renderer-OZKS2BSF.cjs → avatar-renderer-FTY24TKC.cjs} +97 -62
- package/dist/avatar-renderer-FTY24TKC.cjs.map +1 -0
- package/dist/calls/connected/CallAvatarMedia.d.ts +1 -1
- package/dist/calls/connected/CallAvatarMedia.js +9 -4
- package/dist/calls/connected/CallAvatarMedia.js.map +2 -2
- package/dist/calls/connected/CallPeoplePicker.js +5 -2
- package/dist/calls/connected/CallPeoplePicker.js.map +2 -2
- package/dist/calls/connected/ConnectedCallRoom.js +24 -0
- package/dist/calls/connected/ConnectedCallRoom.js.map +2 -2
- package/dist/calls/connected/DmCallButton.d.ts +2 -1
- package/dist/calls/connected/DmCallButton.js +10 -3
- package/dist/calls/connected/DmCallButton.js.map +2 -2
- package/dist/calls/connected/OwnedAgentCallButton.d.ts +2 -1
- package/dist/calls/connected/OwnedAgentCallButton.js +5 -2
- package/dist/calls/connected/OwnedAgentCallButton.js.map +2 -2
- package/dist/calls/connected/avatar-framing.d.ts +6 -1
- package/dist/calls/connected/avatar-framing.js +39 -11
- package/dist/calls/connected/avatar-framing.js.map +3 -3
- package/dist/calls/connected/avatar-renderer.js +21 -9
- package/dist/calls/connected/avatar-renderer.js.map +2 -2
- package/dist/calls/connected/call-media-state.js +1 -1
- package/dist/calls/connected/call-media-state.js.map +2 -2
- package/dist/calls/connected/call-people.d.ts +2 -1
- package/dist/calls/connected/call-people.js +11 -1
- package/dist/calls/connected/call-people.js.map +2 -2
- package/dist/calls/index.cjs +23 -23
- package/dist/chat/index.cjs +5 -5
- package/dist/{chunk-HUAABZ2C.cjs → chunk-26KJYXYH.cjs} +3 -3
- package/dist/{chunk-HUAABZ2C.cjs.map → chunk-26KJYXYH.cjs.map} +1 -1
- package/dist/{chunk-HH5MKRBL.cjs → chunk-2EDVEP2X.cjs} +6 -6
- package/dist/{chunk-HH5MKRBL.cjs.map → chunk-2EDVEP2X.cjs.map} +1 -1
- package/dist/{chunk-OQWJXM4V.cjs → chunk-6IABKQKX.cjs} +7 -7
- package/dist/{chunk-OQWJXM4V.cjs.map → chunk-6IABKQKX.cjs.map} +1 -1
- package/dist/{chunk-UVMOUOFD.cjs → chunk-6VIS6B3O.cjs} +28 -28
- package/dist/{chunk-UVMOUOFD.cjs.map → chunk-6VIS6B3O.cjs.map} +1 -1
- package/dist/{chunk-UXWPJ6I5.cjs → chunk-7ARRFRQR.cjs} +36 -36
- package/dist/{chunk-UXWPJ6I5.cjs.map → chunk-7ARRFRQR.cjs.map} +1 -1
- package/dist/{chunk-OHWYQI3B.cjs → chunk-7KUTY4N5.cjs} +9 -9
- package/dist/{chunk-OHWYQI3B.cjs.map → chunk-7KUTY4N5.cjs.map} +1 -1
- package/dist/{chunk-H4N6BZNU.cjs → chunk-A7MGQMOV.cjs} +3 -3
- package/dist/{chunk-H4N6BZNU.cjs.map → chunk-A7MGQMOV.cjs.map} +1 -1
- package/dist/{chunk-HHZDURXN.cjs → chunk-AS2FZ2T7.cjs} +3 -3
- package/dist/{chunk-HHZDURXN.cjs.map → chunk-AS2FZ2T7.cjs.map} +1 -1
- package/dist/{chunk-K2XLEOGQ.cjs → chunk-CF3WPB7T.cjs} +4 -4
- package/dist/{chunk-K2XLEOGQ.cjs.map → chunk-CF3WPB7T.cjs.map} +1 -1
- package/dist/{chunk-LQ5XVFLV.cjs → chunk-EEB63QUE.cjs} +59 -59
- package/dist/{chunk-LQ5XVFLV.cjs.map → chunk-EEB63QUE.cjs.map} +1 -1
- package/dist/{chunk-QTGWH6Z2.cjs → chunk-EYOZNVQK.cjs} +4 -4
- package/dist/{chunk-QTGWH6Z2.cjs.map → chunk-EYOZNVQK.cjs.map} +1 -1
- package/dist/{chunk-ER55JOJV.cjs → chunk-FAFA56ZL.cjs} +4 -4
- package/dist/{chunk-ER55JOJV.cjs.map → chunk-FAFA56ZL.cjs.map} +1 -1
- package/dist/{chunk-QCFX535U.cjs → chunk-H3C5BY2H.cjs} +4 -4
- package/dist/{chunk-QCFX535U.cjs.map → chunk-H3C5BY2H.cjs.map} +1 -1
- package/dist/{chunk-XKXKEVHH.cjs → chunk-HPIB5YRV.cjs} +5 -5
- package/dist/{chunk-XKXKEVHH.cjs.map → chunk-HPIB5YRV.cjs.map} +1 -1
- package/dist/{chunk-E4CSBOXP.cjs → chunk-HS626TSS.cjs} +31 -31
- package/dist/{chunk-E4CSBOXP.cjs.map → chunk-HS626TSS.cjs.map} +1 -1
- package/dist/{chunk-EBRD3IUG.cjs → chunk-J4X3LYGC.cjs} +4 -4
- package/dist/{chunk-EBRD3IUG.cjs.map → chunk-J4X3LYGC.cjs.map} +1 -1
- package/dist/{chunk-6AFAYGJW.cjs → chunk-L3MYUPSH.cjs} +5 -5
- package/dist/{chunk-6AFAYGJW.cjs.map → chunk-L3MYUPSH.cjs.map} +1 -1
- package/dist/{chunk-QYPCNB7P.cjs → chunk-L6WEKQTV.cjs} +35 -35
- package/dist/{chunk-QYPCNB7P.cjs.map → chunk-L6WEKQTV.cjs.map} +1 -1
- package/dist/{chunk-ZVTLEBFG.cjs → chunk-LIAC6O7W.cjs} +4 -4
- package/dist/{chunk-ZVTLEBFG.cjs.map → chunk-LIAC6O7W.cjs.map} +1 -1
- package/dist/{chunk-3EIO4ZH5.cjs → chunk-LUOL7TEY.cjs} +6 -6
- package/dist/{chunk-3EIO4ZH5.cjs.map → chunk-LUOL7TEY.cjs.map} +1 -1
- package/dist/{chunk-JEHGTPS2.cjs → chunk-LYDSETR7.cjs} +3 -3
- package/dist/{chunk-JEHGTPS2.cjs.map → chunk-LYDSETR7.cjs.map} +1 -1
- package/dist/{chunk-LRBX4VIG.cjs → chunk-PDKTW4L2.cjs} +5 -5
- package/dist/{chunk-LRBX4VIG.cjs.map → chunk-PDKTW4L2.cjs.map} +1 -1
- package/dist/{chunk-PUCYBYBY.cjs → chunk-QU3OCUVF.cjs} +8 -8
- package/dist/{chunk-PUCYBYBY.cjs.map → chunk-QU3OCUVF.cjs.map} +1 -1
- package/dist/{chunk-7GVKG3G4.cjs → chunk-R27P7TYW.cjs} +4 -4
- package/dist/{chunk-7GVKG3G4.cjs.map → chunk-R27P7TYW.cjs.map} +1 -1
- package/dist/{chunk-Q6DU3DZC.cjs → chunk-RDEUBZ3Z.cjs} +10 -10
- package/dist/{chunk-Q6DU3DZC.cjs.map → chunk-RDEUBZ3Z.cjs.map} +1 -1
- package/dist/{chunk-6RYDZ2PS.cjs → chunk-SFAAOEQE.cjs} +3 -3
- package/dist/{chunk-6RYDZ2PS.cjs.map → chunk-SFAAOEQE.cjs.map} +1 -1
- package/dist/{chunk-MZPBZSKS.cjs → chunk-TW5AGCHR.cjs} +32 -10
- package/dist/chunk-TW5AGCHR.cjs.map +1 -0
- package/dist/{chunk-5FSULBPE.cjs → chunk-U2T66I7C.cjs} +3 -3
- package/dist/{chunk-5FSULBPE.cjs.map → chunk-U2T66I7C.cjs.map} +1 -1
- package/dist/{chunk-3J4R2QFL.cjs → chunk-WQMIBHSQ.cjs} +7 -7
- package/dist/{chunk-3J4R2QFL.cjs.map → chunk-WQMIBHSQ.cjs.map} +1 -1
- package/dist/{chunk-TX7Y4A6T.cjs → chunk-X5PH6PM7.cjs} +38 -9
- package/dist/chunk-X5PH6PM7.cjs.map +1 -0
- package/dist/{chunk-7YALMXGZ.cjs → chunk-ZKXZKIPE.cjs} +14 -14
- package/dist/{chunk-7YALMXGZ.cjs.map → chunk-ZKXZKIPE.cjs.map} +1 -1
- package/dist/connect/docx.cjs +12 -12
- package/dist/connect/index.cjs +1154 -1146
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +17 -17
- package/dist/connection/ConnectedAgentChatPanel.js +1 -1
- package/dist/connection/ConnectedAgentChatPanel.js.map +2 -2
- package/dist/connection/ConnectedAgentCreator.js +12 -4
- package/dist/connection/ConnectedAgentCreator.js.map +2 -2
- package/dist/connection/messenger/ConnectedChatThread.js +1 -1
- package/dist/connection/messenger/ConnectedChatThread.js.map +2 -2
- package/dist/connection/settings-page/featuresSection.js +1 -1
- package/dist/connection/settings-page/featuresSection.js.map +1 -1
- package/dist/databases/index.cjs +71 -71
- package/dist/embed/index.cjs +24 -24
- package/dist/facts/index.cjs +8 -8
- package/dist/files/index.cjs +220 -220
- package/dist/home/index.cjs +9 -9
- package/dist/index.cjs +792 -792
- package/dist/pages/index.cjs +30 -30
- package/dist/settings/index.cjs +145 -145
- package/dist/studio/index.cjs +8 -8
- package/dist/workflow-canvas/index.cjs +31 -31
- package/dist/workspaces/index.cjs +5 -5
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/record/render-take.py +5 -0
- package/dist/ai-CTJWECJ5.cjs.map +0 -1
- package/dist/avatar-renderer-OZKS2BSF.cjs.map +0 -1
- package/dist/chunk-MZPBZSKS.cjs.map +0 -1
- package/dist/chunk-TX7Y4A6T.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","composeWorkflowPrompt","isEmptyWorkflowScope","useHost","renderWorkflowIcon","jsx","ConnectedWorkflowLauncher","jsxs","TriangleAlert"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAC,MAAA,KAAqC;AACzD,EAAA,MAAM,QAAQ,MAAA,CAAO,UAAA;AACrB,EAAA,OAAO,KAAA,EAAO,aAAa,EAAC;AAC9B,CAAA;AAEO,IAAM,eAAA,GAAiD;AAAA,EAC5D,CAACA,mCAAiB,GAAG;AAAA,IACnB,WAAA,EAAa,KAAA;AAAA,IACb,KAAA,EAAO,CAAC,MAAA,KAAW;AACjB,MAAA,MAAM,cAAc,OAAO,MAAA,CAAO,YAAA,KAAiB,QAAA,GAAW,OAAO,YAAA,GAAe,EAAA;AACpF,MAAA,OAAO;AAAA,QACL,eAAA,EAAiBC,+BAAA,CAAwB,EAAE,CAAA;AAAA,QAC3C,sBAAA,EAAwBC,qCAAA,CAA8B,YAAA,CAAa,MAAM,CAAC,CAAA;AAAA,QAC1E,GAAI,WAAA,IAAe,WAAA,KAAgBC,mCAAA,GAC/B;AAAA,UACE,gBAAA,EAAkB;AAAA,YAChB,IAAA,EAAM,kBAAA;AAAA,YACN,WAAA,EAAa,kBAAA;AAAA,YACb,SAAA,EAAW,EAAE,YAAA,EAAc,WAAA,EAAY;AAAA,YACvC,gBAAgB;AAAC;AACnB,YAEF;AAAC,OACP;AAAA,IACF;AAAA;AAEJ;ACQA,IAAM,IAAA,GAAO,CAAC,MAAA,EAAwB,IAAA,KAAyB;AAC7D,EAAA,MAAM,CAAA,GAAI,OAAO,IAAI,CAAA;AACrB,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,GAA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AI,CAAC,UAAU,OAAO,IAAA;AACtB,QAAA,uBACEW,eAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,mIAAA;AAAA,YACV,IAAA,EAAK,QAAA;AAAA,YACL,aAAA,EAAY,iCAAA;AAAA,YAEZ,QAAA,EAAA;AAAA,8BAAAF,cAAA,CAACG,yBAAA,EAAA,EAAc,WAAU,uCAAA,EAAwC,CAAA;AAAA,8CAChE,MAAA,EAAA,EAAK,QAAA,EAAA;AAAA,gBAAA,uBAAA;AAAA,gCACiBH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-OHWYQI3B.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n /** The band's layout: reflowing columns (default) or one sideways-scrolling row (a carousel). */\n tilesLayout?: 'grid' | 'carousel'\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","composeWorkflowPrompt","isEmptyWorkflowScope","useHost","renderWorkflowIcon","jsx","ConnectedWorkflowLauncher","jsxs","TriangleAlert"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAC,MAAA,KAAqC;AACzD,EAAA,MAAM,QAAQ,MAAA,CAA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AAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-7KUTY4N5.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n /** The band's layout: reflowing columns (default) or one sideways-scrolling row (a carousel). */\n tilesLayout?: 'grid' | 'carousel'\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
|
|
5
4
|
var chunkE23H6FJR_cjs = require('./chunk-E23H6FJR.cjs');
|
|
5
|
+
var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
|
|
6
6
|
var chunk75BNMCUX_cjs = require('./chunk-75BNMCUX.cjs');
|
|
7
7
|
var chunk5OD6DRG7_cjs = require('./chunk-5OD6DRG7.cjs');
|
|
8
8
|
var chunkPIKTGP55_cjs = require('./chunk-PIKTGP55.cjs');
|
|
@@ -512,5 +512,5 @@ exports.MermaidDiagram = MermaidDiagram;
|
|
|
512
512
|
exports.WorkspaceDocumentReference = WorkspaceDocumentReference;
|
|
513
513
|
exports.openEntityReference = openEntityReference;
|
|
514
514
|
exports.useDocumentWorkspace = useDocumentWorkspace;
|
|
515
|
-
//# sourceMappingURL=chunk-
|
|
516
|
-
//# sourceMappingURL=chunk-
|
|
515
|
+
//# sourceMappingURL=chunk-A7MGQMOV.cjs.map
|
|
516
|
+
//# sourceMappingURL=chunk-A7MGQMOV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/chat/mermaid-normalize.ts","../src/connection/conversation/download-mermaid.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/open-entity-reference.ts","../src/connection/conversation/EntityReference.tsx","../src/connection/conversation/ConnectedMarkdown.tsx"],"names":["createContext","useContext","hrefFor","useBlocksEnvironment","jsx","EntityPill","FileText","useArbiHost","useReferencedDocuments","getDocumentTitle","useState","useId","useEffect","jsxs","Button","Download","DATABASES_OPEN_VIEW","CalendarDays","Phone","MessagesSquare","Folder","Workflow","LayoutDashboard","Database","Table2","StickyNote","Tags","User","useArbiSessionState","useEntityReferenceTitle","useArbiSessionStore","parseHref","parseCallFragment","openCall","EntityIcon","React","useArbiSession","MentionChip","QuietLink","workspaceDocIdFromHref","Fragment","useDocument","DocumentEntity","Mail","mentionFromHref","MarkdownLink","MarkdownStreamingContext","ENTITY_ID","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcO,IAAM,wBAAA,GAA2BA,oBAA6B,IAAI;AAClE,IAAM,oBAAA,GAAuB,MAAMC,gBAAA,CAAW,wBAAwB;AAG7E,SAAS,qBAAA,CAAsB;AAAA,EAC7B,WAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA,GAAY;AACd,CAAA,EAOG;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,OAAA,EAAAC,QAAAA,KAAYC,sCAAA,EAAqB;AAEvD,EAAA,MAAM,OACJD,QAAAA,CAAQ,EAAE,MAAM,UAAA,EAAY,UAAA,EAAY,OAAO,WAAA,EAAa,CAAA,IAC5DA,yBAAA,CAAe,EAAE,IAAA,EAAM,UAAA,EAAY,YAAY,KAAA,EAAO,WAAA,EAAa,CAAA,IACnE,QAAA;AACF,EAAA,MAAM,IAAA,GAAO,MAAO,WAAA,GAAc,YAAA,CAAa,KAAA,EAAO,EAAE,WAAA,EAAa,CAAA,GAAI,YAAA,CAAa,KAAK,CAAA;AAC3F,EAAA,IAAI,CAAC,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA;AACnC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,EAA2B;AACpF,EAAA,MAAM,MAAA,GAASC,aAAA;AAAA,IACb,MACE,UAAA,GACI,EAAE,GAAG,8BAAA,EAAgC,GAAG,YAAW,GACnD,8BAAA;AAAA,IACN,CAAC,UAAU;AAAA,GACb;AACA,EAAA,uBACE9C,eAAC+C,mBAAA,EAAA,EAAqB,GAAG,OAAO,UAAA,EAAY,MAAA,EAAQ,eAAe,yBAAA,EAA2B,CAAA;AAElG;AAEO,IAAM,iBAAA,GAAoBhB,sBAAA,CAAM,IAAA,CAAK,0BAA0B","file":"chunk-H4N6BZNU.cjs","sourcesContent":["/**\n * The workspace a conversation's document references belong to, when it is not the open one: an\n * agent's direct-message thread runs in the agent's workspace, so the documents it names are there.\n * A reference then opens that workspace first (`openDocument(id, { workspaceId })`).\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useArbiHost, useReferencedDocuments } from '@arbidocs/react'\nimport { EntityPill, getDocumentTitle } from '@arbidocs/react/ui'\nimport { FileText } from 'lucide-react'\nimport { hrefFor as defaultHrefFor } from '../../lib/routes'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\n/** The workspace of the documents referenced inside it (null: the open workspace). */\nexport const DocumentWorkspaceContext = createContext<string | null>(null)\nexport const useDocumentWorkspace = () => useContext(DocumentWorkspaceContext)\n\n/** A reference to a document of another workspace: opening it opens that workspace first. */\nfunction DocumentReferenceView({\n workspaceId,\n docId,\n children,\n label,\n copyHref,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId?: string | null\n docId: string\n children?: ReactNode\n label?: string\n copyHref?: string\n className?: string\n}) {\n const { openDocument, hrefFor } = useBlocksEnvironment()\n\n const link =\n hrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n defaultHrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n copyHref\n const open = () => (workspaceId ? openDocument(docId, { workspaceId }) : openDocument(docId))\n if (!children || typeof children === 'string')\n return (\n <EntityPill\n icon={<FileText className=\"h-3.5 w-3.5 shrink-0\" />}\n label={label || (typeof children === 'string' ? children : 'File')}\n copyHref={link}\n onClick={open}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <button type=\"button\" className={className} onClick={open}>\n {children ?? docId}\n </button>\n )\n}\n\ntype ReferenceProps = Parameters<typeof DocumentReferenceView>[0]\nexport function WorkspaceDocumentReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi && props.workspaceId && !props.children && !props.label ? (\n <ResolvedDocumentReference {...props} workspaceId={props.workspaceId} />\n ) : (\n <DocumentReferenceView {...props} />\n )\n}\nfunction ResolvedDocumentReference(props: ReferenceProps & { workspaceId: string }) {\n const { data } = useReferencedDocuments(props.workspaceId)\n const doc = data?.find((d) => d.external_id === props.docId)\n return <DocumentReferenceView {...props} label={getDocumentTitle(doc)} />\n}\n","/**\n * Defensive normalizer for single-line `graph` / `flowchart` Mermaid source.\n *\n * Some LLMs emit the entire diagram on one line. Mermaid's parser splits\n * statements on newlines, so a single-line graph fails outright. This helper\n * inserts newlines on safe statement boundaries so the diagram has a chance\n * of parsing. Only attempts normalization when:\n * 1. The source has no embedded newlines (i.e. is genuinely single-line), and\n * 2. The first directive is `graph` or `flowchart`.\n *\n * Other diagram types (sequenceDiagram, classDiagram, gantt, …) have very\n * different syntaxes — applying these heuristics to them would corrupt valid\n * input, so they're left untouched.\n *\n * Boundaries we split on:\n * - After the diagram-type header (`graph TD`, `flowchart LR`, …).\n * - Before each `style` / `classDef` / `class` / `linkStyle` / `click`\n * / `subgraph` keyword.\n * - Before/after `end` (closes a subgraph block).\n * - After a `]` (label close) that's followed by another node identifier\n * starting a new edge or node declaration.\n */\nexport function normalizeMermaidGraph(source: string): string {\n // Already multi-line — assume it's well-formed; don't touch it.\n if (/\\n/.test(source)) return source\n\n const headerMatch = source.match(/^\\s*(graph|flowchart)\\s+\\w+\\s+/)\n if (!headerMatch) return source\n\n const header = headerMatch[0].trimEnd()\n let body = source.slice(headerMatch[0].length)\n\n // Insert newline before keywords that always start a new statement.\n body = body.replace(/\\s+(style|classDef|class|linkStyle|click|subgraph)\\s/g, '\\n$1 ')\n\n // `end` closes a subgraph: put it on its own line, with a break after it\n // too so any trailing statements don't stay attached.\n body = body.replace(/\\s+end\\b\\s*/g, '\\nend\\n')\n\n // After a label close (`]`), if the next token looks like a Mermaid node id\n // followed by another `[` or `-->`, that's a new statement starting.\n body = body.replace(/\\]\\s+(?=[A-Za-z_][\\w-]*\\s*(?:\\[|-->))/g, ']\\n')\n\n // Collapse any accidental runs of blank lines we may have produced.\n body = body.replace(/\\n{2,}/g, '\\n')\n\n return `${header}\\n${body.trimStart()}`\n}\n","/** Save the rendered graphic, including Mermaid's styles, as a standalone image. */\nexport function downloadMermaidSvg(rendered: string): void {\n const doc = new DOMParser().parseFromString(rendered, 'image/svg+xml')\n const svg = doc.documentElement\n if (svg.localName !== 'svg' || doc.querySelector('parsererror'))\n throw new Error('The diagram did not produce a valid SVG image')\n svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n const box = svg\n .getAttribute('viewBox')\n ?.trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {\n svg.setAttribute('width', String(Math.ceil(box[2])))\n svg.setAttribute('height', String(Math.ceil(box[3])))\n }\n const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml' })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = 'diagram.svg'\n document.body.append(link)\n try {\n link.click()\n } finally {\n link.remove()\n // Let the browser consume the download before releasing the image URL.\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n }\n}\n","/**\n * MermaidDiagram Component\n *\n * Renders a Mermaid diagram from source code.\n * Used inside MarkdownRenderer to handle ```mermaid code blocks.\n * Lazy-loads the mermaid library to avoid bloating the initial bundle.\n */\n\nimport { useState, useEffect, useId } from 'react'\nimport { Download } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\nimport { downloadMermaidSvg } from './download-mermaid'\n\ninterface MermaidDiagramProps {\n /** Mermaid diagram source code */\n chart: string\n}\n\n// Lazy-load and initialize mermaid once\nlet mermaidInstance: typeof import('mermaid').default | null = null\nlet mermaidLoadPromise: Promise<typeof import('mermaid').default> | null = null\n\nasync function getMermaid() {\n if (mermaidInstance) return mermaidInstance\n if (!mermaidLoadPromise) {\n mermaidLoadPromise = import('mermaid').then((mod) => {\n const m = mod.default\n m.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n flowchart: { useMaxWidth: true, curve: 'basis' },\n })\n mermaidInstance = m\n return m\n })\n }\n return mermaidLoadPromise\n}\n\nexport function MermaidDiagram({ chart }: MermaidDiagramProps) {\n const [svg, setSvg] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const uniqueId = useId().replace(/:/g, '-')\n\n useEffect(() => {\n let cancelled = false\n\n async function render() {\n const mermaid = await getMermaid()\n const diagramId = `mermaid${uniqueId}`\n\n // Validate with parse() before render(). In Mermaid v11 a render() with\n // bad source can return a \"Syntax error in text\" bomb SVG instead of\n // throwing — and it appends DOM side-effects of its own — so a try/catch\n // around render() doesn't reliably catch failures and the bomb leaks\n // into the page (especially under React StrictMode where effects run\n // twice). parse() throws cleanly with no DOM side-effects.\n //\n // Defensive rescue: some LLMs emit single-line `graph`/`flowchart`\n // source. If the original parse fails, try a normalized variant. The\n // normalizer is a no-op on already-multi-line source and on non-graph\n // diagram types, so this only helps the bad-source case and never\n // corrupts valid input.\n let validSource: string | null = null\n let firstErr: unknown\n try {\n await mermaid.parse(chart)\n validSource = chart\n } catch (err) {\n firstErr = err\n const normalized = normalizeMermaidGraph(chart)\n if (normalized !== chart) {\n try {\n await mermaid.parse(normalized)\n validSource = normalized\n } catch (retryErr) {\n console.warn('Mermaid normalized parse also failed', retryErr)\n }\n }\n }\n\n if (cancelled) return\n\n if (!validSource) {\n console.warn('Mermaid parse failed, showing source', firstErr)\n setError('Failed to render diagram')\n setSvg(null)\n return\n }\n\n try {\n const { svg: renderedSvg } = await mermaid.render(diagramId, validSource)\n if (!cancelled) {\n setSvg(renderedSvg)\n setError(null)\n }\n } catch (renderErr) {\n if (!cancelled) {\n console.warn('Mermaid render failed despite parse success', renderErr)\n setError('Failed to render diagram')\n setSvg(null)\n }\n }\n }\n\n render()\n return () => {\n cancelled = true\n }\n }, [chart, uniqueId])\n\n if (error) {\n // Fall back to showing the raw source in a code block\n return (\n <div className=\"code-block\" data-testid=\"mermaid-error\">\n <div className=\"text-sm text-muted-foreground mb-1\">{error}</div>\n <code className=\"language-mermaid\">{chart}</code>\n </div>\n )\n }\n\n if (!svg) {\n return (\n <div\n className=\"flex items-center justify-center py-8 text-muted-foreground text-sm\"\n data-testid=\"mermaid-loading\"\n >\n Rendering diagram...\n </div>\n )\n }\n\n return (\n <div\n className=\"mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4\"\n data-testid=\"mermaid-diagram\"\n >\n <div className=\"mb-2 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => downloadMermaidSvg(svg)}>\n <Download className=\"mr-2 size-4\" aria-hidden=\"true\" />\n Download SVG\n </Button>\n </div>\n <div dangerouslySetInnerHTML={{ __html: svg }} />\n </div>\n )\n}\n","import { DATABASES_OPEN_VIEW, type ArbiSessionStore } from '@arbidocs/react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { BlocksEnvironment } from '../../provider/environment'\n\n/** Navigation intents shared by copied entity links and inline entity menus. */\nexport async function openEntityReference(\n id: string,\n session: ArbiSessionStore,\n env: BlocksEnvironment,\n arbi?: Arbi\n) {\n const prefix = id.split('-')[0]\n switch (prefix) {\n case 'pag':\n session.setViewValue('pages.open', id)\n session.setPage('pages')\n break\n case 'dbs':\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: id })\n session.setPage('databases')\n break\n case 'fct':\n env.openFacts?.({ focusId: id })\n break\n case 'tag':\n session.setPage('tags')\n session.setTransientView('tags.focus', id)\n break\n case 'viw': {\n if (!arbi) return\n const workspace = session.getState().workspaceId\n if (!workspace) return\n const view = await arbi.readInWorkspace(workspace, () => arbi.views.get(id))\n if (session.getState().workspaceId !== workspace) return\n if (view.target === 'documents') {\n session.setTransientView('documents.openView', id)\n session.setPage('documents')\n } else {\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: view.target, viewId: id })\n session.setPage('databases')\n }\n break\n }\n case 'wfl':\n env.openWorkflow?.(id)\n break\n case 'prj':\n env.openProject(id)\n break\n case 'usr':\n case 'agt':\n env.openDirectChat?.(id)\n break\n case 'cht':\n env.openChat?.(id)\n break\n case 'cal':\n env.openCalendar()\n break\n }\n}\n","import {\n useArbiHost,\n useArbiSessionState,\n useArbiSessionStore,\n openCall,\n useEntityReferenceTitle,\n} from '@arbidocs/react'\nimport { EntityPill, EntityIcon } from '@arbidocs/react/ui'\nimport {\n CalendarDays,\n Phone,\n Database,\n LayoutDashboard,\n Workflow,\n StickyNote,\n Table2,\n Tags,\n User,\n MessagesSquare,\n Folder,\n} from 'lucide-react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useDocumentWorkspace } from './DocumentWorkspaceContext'\nimport { hrefFor, parseHref } from '../../lib/routes'\nimport { openEntityReference } from './open-entity-reference'\nimport { parseCallFragment } from '@arbidocs/client'\n\nconst kinds = {\n evt: ['Appointment', CalendarDays],\n call: ['Call', Phone],\n con: ['Thread', MessagesSquare],\n wrk: ['Workspace', Folder],\n prj: ['Project', Folder],\n wfl: ['Workflow', Workflow],\n pag: ['Page', LayoutDashboard],\n dbs: ['Database', Database],\n viw: ['Saved view', Table2],\n fct: ['Fact', StickyNote],\n tag: ['Tag', Tags],\n usr: ['Person', User],\n agt: ['Agent', User],\n cht: ['Chat', MessagesSquare],\n cal: ['Calendar', CalendarDays],\n} as const\n\n/** A permission-aware reference, shared by main conversations and encrypted DMs. */\nfunction ConnectedEntityReference({\n id,\n href,\n title,\n workspaceId: explicitWorkspace,\n}: {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}) {\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const metadata = useEntityReferenceTitle(\n id,\n workspaceId,\n global || prefix === 'con' || workspaceId === selected\n )\n return (\n <EntityReferenceView id={id} href={href} title={metadata || title} workspaceId={workspaceId} />\n )\n}\n\ninterface ReferenceProps {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}\nexport function EntityReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi ? <ConnectedEntityReference {...props} /> : <EntityReferenceView {...props} />\n}\nfunction EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }: ReferenceProps) {\n const arbi = useArbiHost().arbi\n const env = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const [kind, Icon] = kinds[prefix] ?? ['Entity', Folder]\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const target =\n prefix === 'con'\n ? hrefFor({ kind: 'conversation', conversationId: id, workspaceId })\n : prefix === 'evt'\n ? hrefFor({ kind: 'calendar', eventId: id })\n : prefix === 'call'\n ? hrefFor({ kind: 'call', callId: id })\n : prefix === 'wrk'\n ? hrefFor({ kind: 'workspace', workspaceId: id })\n : hrefFor({\n kind: 'entity',\n entityId: id,\n workspaceId: global ? undefined : workspaceId,\n })\n const link = href ?? target\n const open = () => {\n if (prefix === 'con') {\n const route = href ? parseHref(href) : null\n env.openConversation(id, {\n workspaceId: workspaceId ?? undefined,\n messageId: route?.kind === 'conversation' ? route.messageId : undefined,\n })\n } else if (prefix === 'evt') env.openCalendar({ event: { id } })\n else if (prefix === 'call') {\n const fragment = href ? parseCallFragment(new URL(href, window.location.href).hash) : null\n if (arbi)\n void openCall(arbi, {\n callExtId: id,\n key: fragment?.key,\n linkVersion: fragment?.linkVersion,\n })\n else if (link) env.navigate(link)\n } else if (prefix === 'wrk') env.openWorkspace(id)\n else if (workspaceId && workspaceId !== selected && link) env.navigate(link)\n else\n void openEntityReference(id, session, env, arbi).catch(() =>\n env.notify('Unable to open content.', 'error')\n )\n }\n return (\n <EntityPill\n icon={\n prefix === 'con' ? (\n <EntityIcon entityType=\"CONVERSATION\" className=\"h-3.5 w-3.5 shrink-0\" />\n ) : (\n <Icon className=\"h-3.5 w-3.5 shrink-0\" />\n )\n }\n label={title || kind}\n copyHref={link}\n onClick={open}\n tooltipContent={`${kind}: ${title || id}`}\n labelMaxWidth=\"max-w-[min(20rem,65vw)]\"\n data-testid={`entity-reference-${id}`}\n />\n )\n}\n","import { EntityReference } from './EntityReference'\nimport { ENTITY_ID } from './entity-references'\nimport { parseHref } from '../../lib/routes'\n/**\n * The conversation's markdown: the kit's `MarkdownRenderer` (`@arbidocs/react`: sanitised HTML,\n * slugs, lazy KaTeX, streaming blocks, tables, code) with what a conversation adds: @mention chips,\n * workspace documents opening in the viewer, quiet external links, document and email pills (the\n * host's chips, `ArbiChatHost.renderDocumentChip` / `renderMailChip`) and Mermaid diagrams.\n */\nimport { useArbiHost, useArbiSession, useArbiSessionState, useDocument } from '@arbidocs/react'\nimport { mentionFromHref, type MentionKind } from '@arbidocs/react/shell'\nimport {\n EntityPill,\n MarkdownCode,\n MarkdownLink,\n MarkdownRenderer as KitMarkdownRenderer,\n MarkdownStreamingContext,\n type MarkdownRendererProps as KitMarkdownRendererProps,\n DocumentEntity,\n} from '@arbidocs/react/ui'\nimport React, { useContext, useMemo } from 'react'\nimport { FileText, Mail } from 'lucide-react'\n\n/** The markdown element overrides, as the kit's renderer takes them. */\ntype Components = NonNullable<KitMarkdownRendererProps['components']>\nimport { MentionChip } from '../../chat/MentionMenu'\nimport { QuietLink } from '../../citations/QuietMarks'\nimport { rehypeDocEntityPills } from '../../chat/rehype-doc-entity-pills'\nimport { workspaceDocIdFromHref } from '../../chat/doc-links'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { MermaidDiagram } from './MermaidDiagram'\nimport { useDocumentWorkspace, WorkspaceDocumentReference } from './DocumentWorkspaceContext'\n\n/** Plain text of a link's children (the `@Label` of a mention link). */\nfunction childrenText(children: React.ReactNode): string {\n return React.Children.toArray(children)\n .map((child) =>\n typeof child === 'string' || typeof child === 'number'\n ? String(child)\n : React.isValidElement<{ children?: React.ReactNode }>(child)\n ? childrenText(child.props.children)\n : ''\n )\n .join('')\n}\n\n/** Text labels may be formatted; a non-text leaf (such as an image) needs the rich-child path. */\nfunction plainLinkText(children: React.ReactNode): string | null {\n const parts = React.Children.toArray(children).map((child): string | null => {\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n if (\n React.isValidElement<{ children?: React.ReactNode }>(child) &&\n child.props.children != null\n ) {\n return plainLinkText(child.props.children)\n }\n return null\n })\n return parts.includes(null) ? null : parts.join('')\n}\n\n/** A mention chip; a mention of the reader stands out. */\nfunction MentionLink({ kind, id, text }: { kind: MentionKind; id: string; text: string }) {\n const currentUserId = useArbiSession().user?.external_id\n return (\n <MentionChip\n kind={kind}\n id={id}\n label={text.replace(/^@/, '')}\n isSelf={kind === 'user' && id === currentUserId}\n />\n )\n}\n\n/**\n * A link to elsewhere, as quiet text. Its menu (Open link / Copy link) is the deliberate step\n * the old confirmation dialog used to be; nothing opens until the menu's primary row is chosen.\n */\nexport function ExternalLink({ href, children }: React.ComponentPropsWithoutRef<'a'>) {\n return (\n <QuietLink href={href} kind=\"external\">\n {children}\n </QuietLink>\n )\n}\n\n/**\n * A workspace document referenced by a link's href rather than by its text.\n *\n * `rehypeDocEntityPills` turns a bare `doc-…` id into a pill, but it only walks\n * TEXT nodes — so `[NVDA DCF Valuation Report](…doc-abc12345…)`, which is how an\n * answer links an artifact it just saved, keeps the id in the href where the\n * plugin never looks. The link then fell through to `ExternalLink`, and opening\n * your own workspace document asked you to confirm an \"external link\" and\n * launched a new tab. It opens in the document viewer, like the pill and the\n * artifact card already do.\n */\nexport function InternalDocLink({\n docId,\n href,\n children,\n}: React.ComponentPropsWithoutRef<'a'> & { docId: string }) {\n const { runtimeConfig } = useBlocksEnvironment()\n const conversationWorkspace = useDocumentWorkspace()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n // A delegated reference can target a different workspace than its Home DM. Only trust the\n // route after the same origin/deployment check used by the markdown adapters.\n const route =\n href && workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId\n ? parseHref(href)\n : null\n const workspaceId =\n (route?.kind === 'document' ? route.workspaceId : null) ??\n conversationWorkspace ??\n selectedWorkspace\n const text = plainLinkText(children)?.trim()\n const isAddress = !text || text === href || text === docId\n\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} copyHref={href}>\n {text === undefined ? children : isAddress ? undefined : text}\n </WorkspaceDocumentReference>\n )\n}\n\n/** A document of the workspace, as a pill: the host's chip, else the document entity. */\nexport function DocumentChip({ docId }: { docId: string }) {\n const render = useArbiHost().chat?.renderDocumentChip\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) return <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} />\n return render ? <>{render(docId)}</> : <DefaultDocumentChip docId={docId} />\n}\n\nfunction DefaultDocumentChip({ docId }: { docId: string }) {\n const { data: doc } = useDocument(docId)\n const { openDocument, hrefFor } = useBlocksEnvironment()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n const copyHref = hrefFor({ kind: 'document', documentId: docId, workspaceId: selectedWorkspace })\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"File\"\n copyHref={copyHref}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity\n doc={doc}\n copyHref={copyHref}\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nfunction MailChip({ mailId }: { mailId: string }) {\n const render = useArbiHost().chat?.renderMailChip\n if (render) return <>{render(mailId)}</>\n return (\n <EntityPill\n icon={<Mail className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"Email\"\n size=\"sm\"\n data-testid=\"mail-entity-pill\"\n />\n )\n}\n\n/**\n * The conversation's overrides, layered on the kit's defaults. Module scope, so the reference is stable\n * and memoised markdown blocks do not re-parse.\n */\nconst conversationMarkdownComponents: Partial<Components> = {\n a: function ConversationMarkdownLink({\n href,\n children,\n ...props\n }: React.ComponentPropsWithoutRef<'a'>) {\n const deploymentDomain = useBlocksEnvironment().runtimeConfig.deploymentDomain\n // @mentions: `linkMentions` turned them into `#mention-<id>` links; draw them as chips.\n const mention = mentionFromHref(href)\n if (mention) {\n return <MentionLink kind={mention.kind} id={mention.id} text={childrenText(children)} />\n }\n // Bookmarks: in-page anchors are near-invisible text; the menu jumps or copies the place.\n if (href?.startsWith('#') && !href.startsWith('#cite-')) {\n return (\n <QuietLink href={href} kind=\"anchor\">\n {children}\n </QuietLink>\n )\n }\n // Citations, `cite:` references and bare links: the kit's link.\n if (!href || href.startsWith('#') || href.startsWith('cite:')) {\n return (\n <MarkdownLink href={href} {...props}>\n {children}\n </MarkdownLink>\n )\n }\n // A workspace document is not an external link, wherever it is hosted: it opens in the viewer.\n const docId = workspaceDocIdFromHref(href, deploymentDomain)\n if (docId) {\n return (\n <InternalDocLink docId={docId} href={href} {...props}>\n {children}\n </InternalDocLink>\n )\n }\n const route = parseHref(href)\n const reference =\n route?.kind === 'entity'\n ? route.entityId\n : route?.kind === 'conversation'\n ? route.conversationId\n : route?.kind === 'workspace'\n ? route.workspaceId\n : route?.kind === 'call'\n ? route.callId\n : route?.kind === 'calendar'\n ? route.eventId\n : undefined\n if (reference && !reference.startsWith('doc-')) {\n const url = new URL(href, window.location.href)\n const trusted =\n url.origin === window.location.origin ||\n (url.protocol === 'https:' && url.hostname === deploymentDomain)\n if (trusted)\n return (\n <EntityReference\n id={reference}\n href={href}\n title={childrenText(children) === href ? undefined : childrenText(children)}\n workspaceId={url.pathname.match(/\\b(wrk-[a-zA-Z0-9]{8})\\b/)?.[1]}\n />\n )\n }\n return (\n <ExternalLink href={href} {...props}>\n {children}\n </ExternalLink>\n )\n },\n code: function ConversationMarkdownCode(\n props: React.ComponentPropsWithoutRef<'code'> & { inline?: boolean }\n ) {\n const isStreaming = useContext(MarkdownStreamingContext)\n const { className, children } = props\n const language = /language-(\\w+)/.exec(className || '')?.[1]\n if (!language) {\n // Answers often backtick a bare doc id (`doc-f7b3eeb5`). The text-node pass skips code, so\n // the id would stay monospace text; show it as the document pill. Only a whole id (eight\n // alphanumerics): while streaming, a partial one (\"doc-e\") would be looked up and 404.\n const codeText = typeof children === 'string' ? children.trim() : ''\n if (/^doc-[a-zA-Z0-9]{8}$/.test(codeText)) return <DocumentChip docId={codeText} />\n if (/^eml-[a-zA-Z0-9]{8}$/.test(codeText)) return <MailChip mailId={codeText} />\n if (ENTITY_ID.test(codeText)) return <EntityReference id={codeText} />\n }\n // Mermaid lazy-loads its own bundle and re-renders SVG on every change. While streaming the\n // fence is almost always partial, so it stays a code block until generation completes.\n if (language === 'mermaid' && !isStreaming) {\n return <MermaidDiagram chart={String(children).replace(/\\n$/, '')} />\n }\n return <MarkdownCode {...props} />\n },\n span: ({ children, className, ...props }: React.ComponentPropsWithoutRef<'span'>) => {\n const entityId = (props as Record<string, unknown>)['data-entity-id'] as string | undefined\n if (entityId) return <EntityReference id={entityId} />\n const docId = (props as Record<string, unknown>)['data-doc-id'] as string | undefined\n if (docId) return <DocumentChip docId={docId} />\n const mailId = (props as Record<string, unknown>)['data-mail-id'] as string | undefined\n if (mailId) return <MailChip mailId={mailId} />\n return (\n <span className={className} {...props}>\n {children}\n </span>\n )\n },\n}\n\n/** Bare `doc-…` / `eml-…` ids in text become `<span data-doc-id>` / `<span data-mail-id>` pills. */\nconst conversationRehypePlugins = [rehypeDocEntityPills]\n\nexport type ConnectedMarkdownProps = Omit<\n KitMarkdownRendererProps,\n 'rehypePlugins' | 'allowHtml' | 'renderCitation'\n>\n\n/**\n * The kit's renderer with the conversation's overrides; a caller's `components` (e.g. the citation\n * core's) still win over both.\n */\nfunction ConnectedMarkdownComponent({ components, ...props }: ConnectedMarkdownProps) {\n const merged = useMemo(\n () =>\n components\n ? { ...conversationMarkdownComponents, ...components }\n : conversationMarkdownComponents,\n [components]\n )\n return (\n <KitMarkdownRenderer {...props} components={merged} rehypePlugins={conversationRehypePlugins} />\n )\n}\n\nexport const ConnectedMarkdown = React.memo(ConnectedMarkdownComponent)\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/chat/mermaid-normalize.ts","../src/connection/conversation/download-mermaid.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/open-entity-reference.ts","../src/connection/conversation/EntityReference.tsx","../src/connection/conversation/ConnectedMarkdown.tsx"],"names":["createContext","useContext","hrefFor","useBlocksEnvironment","jsx","EntityPill","FileText","useArbiHost","useReferencedDocuments","getDocumentTitle","useState","useId","useEffect","jsxs","Button","Download","DATABASES_OPEN_VIEW","CalendarDays","Phone","MessagesSquare","Folder","Workflow","LayoutDashboard","Database","Table2","StickyNote","Tags","User","useArbiSessionState","useEntityReferenceTitle","useArbiSessionStore","parseHref","parseCallFragment","openCall","EntityIcon","React","useArbiSession","MentionChip","QuietLink","workspaceDocIdFromHref","Fragment","useDocument","DocumentEntity","Mail","mentionFromHref","MarkdownLink","MarkdownStreamingContext","ENTITY_ID","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer"],"mappings":";;;;;;;;;;;;;;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,KAAA,EAAO,CAAA;AAAA,EAClC,CAAA;AAAA,EACA,MAAM,CAAC,EAAE,UAAU,SAAA,EAAW,GAAG,OAAM,KAA8C;AACnF,IAAA,MAAM,QAAA,GAAY,MAAkC,gBAAgB,CAAA;AACpE,IAAA,IAAI,UAAU,uBAAO5C,cAAAA,CAAC,eAAA,EAAA,EAAgB,IAAI,QAAA,EAAU,CAAA;AACpD,IAAA,MAAM,KAAA,GAAS,MAAkC,aAAa,CAAA;AAC9D,IAAA,IAAI,KAAA,EAAO,uBAAOA,cAAAA,CAAC,gBAAa,KAAA,EAAc,CAAA;AAC9C,IAAA,MAAM,MAAA,GAAU,MAAkC,cAAc,CAAA;AAChE,IAAA,IAAI,MAAA,EAAQ,uBAAOA,cAAAA,CAAC,YAAS,MAAA,EAAgB,CAAA;AAC7C,IAAA,uBACEA,cAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAuB,GAAG,OAC7B,QAAA,EACH,CAAA;AAAA,EAEJ;AACF,CAAA;AAGA,IAAM,yBAAA,GAA4B,CAAC6C,sCAAoB,CAAA;AAWvD,SAAS,0BAAA,CAA2B,EAAE,UAAA,EAAY,GAAG,OAAM,EAA2B;AACpF,EAAA,MAAM,MAAA,GAASC,aAAA;AAAA,IACb,MACE,UAAA,GACI,EAAE,GAAG,8BAAA,EAAgC,GAAG,YAAW,GACnD,8BAAA;AAAA,IACN,CAAC,UAAU;AAAA,GACb;AACA,EAAA,uBACE9C,eAAC+C,mBAAA,EAAA,EAAqB,GAAG,OAAO,UAAA,EAAY,MAAA,EAAQ,eAAe,yBAAA,EAA2B,CAAA;AAElG;AAEO,IAAM,iBAAA,GAAoBhB,sBAAA,CAAM,IAAA,CAAK,0BAA0B","file":"chunk-A7MGQMOV.cjs","sourcesContent":["/**\n * The workspace a conversation's document references belong to, when it is not the open one: an\n * agent's direct-message thread runs in the agent's workspace, so the documents it names are there.\n * A reference then opens that workspace first (`openDocument(id, { workspaceId })`).\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useArbiHost, useReferencedDocuments } from '@arbidocs/react'\nimport { EntityPill, getDocumentTitle } from '@arbidocs/react/ui'\nimport { FileText } from 'lucide-react'\nimport { hrefFor as defaultHrefFor } from '../../lib/routes'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\n/** The workspace of the documents referenced inside it (null: the open workspace). */\nexport const DocumentWorkspaceContext = createContext<string | null>(null)\nexport const useDocumentWorkspace = () => useContext(DocumentWorkspaceContext)\n\n/** A reference to a document of another workspace: opening it opens that workspace first. */\nfunction DocumentReferenceView({\n workspaceId,\n docId,\n children,\n label,\n copyHref,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId?: string | null\n docId: string\n children?: ReactNode\n label?: string\n copyHref?: string\n className?: string\n}) {\n const { openDocument, hrefFor } = useBlocksEnvironment()\n\n const link =\n hrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n defaultHrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n copyHref\n const open = () => (workspaceId ? openDocument(docId, { workspaceId }) : openDocument(docId))\n if (!children || typeof children === 'string')\n return (\n <EntityPill\n icon={<FileText className=\"h-3.5 w-3.5 shrink-0\" />}\n label={label || (typeof children === 'string' ? children : 'File')}\n copyHref={link}\n onClick={open}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <button type=\"button\" className={className} onClick={open}>\n {children ?? docId}\n </button>\n )\n}\n\ntype ReferenceProps = Parameters<typeof DocumentReferenceView>[0]\nexport function WorkspaceDocumentReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi && props.workspaceId && !props.children && !props.label ? (\n <ResolvedDocumentReference {...props} workspaceId={props.workspaceId} />\n ) : (\n <DocumentReferenceView {...props} />\n )\n}\nfunction ResolvedDocumentReference(props: ReferenceProps & { workspaceId: string }) {\n const { data } = useReferencedDocuments(props.workspaceId)\n const doc = data?.find((d) => d.external_id === props.docId)\n return <DocumentReferenceView {...props} label={getDocumentTitle(doc)} />\n}\n","/**\n * Defensive normalizer for single-line `graph` / `flowchart` Mermaid source.\n *\n * Some LLMs emit the entire diagram on one line. Mermaid's parser splits\n * statements on newlines, so a single-line graph fails outright. This helper\n * inserts newlines on safe statement boundaries so the diagram has a chance\n * of parsing. Only attempts normalization when:\n * 1. The source has no embedded newlines (i.e. is genuinely single-line), and\n * 2. The first directive is `graph` or `flowchart`.\n *\n * Other diagram types (sequenceDiagram, classDiagram, gantt, …) have very\n * different syntaxes — applying these heuristics to them would corrupt valid\n * input, so they're left untouched.\n *\n * Boundaries we split on:\n * - After the diagram-type header (`graph TD`, `flowchart LR`, …).\n * - Before each `style` / `classDef` / `class` / `linkStyle` / `click`\n * / `subgraph` keyword.\n * - Before/after `end` (closes a subgraph block).\n * - After a `]` (label close) that's followed by another node identifier\n * starting a new edge or node declaration.\n */\nexport function normalizeMermaidGraph(source: string): string {\n // Already multi-line — assume it's well-formed; don't touch it.\n if (/\\n/.test(source)) return source\n\n const headerMatch = source.match(/^\\s*(graph|flowchart)\\s+\\w+\\s+/)\n if (!headerMatch) return source\n\n const header = headerMatch[0].trimEnd()\n let body = source.slice(headerMatch[0].length)\n\n // Insert newline before keywords that always start a new statement.\n body = body.replace(/\\s+(style|classDef|class|linkStyle|click|subgraph)\\s/g, '\\n$1 ')\n\n // `end` closes a subgraph: put it on its own line, with a break after it\n // too so any trailing statements don't stay attached.\n body = body.replace(/\\s+end\\b\\s*/g, '\\nend\\n')\n\n // After a label close (`]`), if the next token looks like a Mermaid node id\n // followed by another `[` or `-->`, that's a new statement starting.\n body = body.replace(/\\]\\s+(?=[A-Za-z_][\\w-]*\\s*(?:\\[|-->))/g, ']\\n')\n\n // Collapse any accidental runs of blank lines we may have produced.\n body = body.replace(/\\n{2,}/g, '\\n')\n\n return `${header}\\n${body.trimStart()}`\n}\n","/** Save the rendered graphic, including Mermaid's styles, as a standalone image. */\nexport function downloadMermaidSvg(rendered: string): void {\n const doc = new DOMParser().parseFromString(rendered, 'image/svg+xml')\n const svg = doc.documentElement\n if (svg.localName !== 'svg' || doc.querySelector('parsererror'))\n throw new Error('The diagram did not produce a valid SVG image')\n svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n const box = svg\n .getAttribute('viewBox')\n ?.trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {\n svg.setAttribute('width', String(Math.ceil(box[2])))\n svg.setAttribute('height', String(Math.ceil(box[3])))\n }\n const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml' })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = 'diagram.svg'\n document.body.append(link)\n try {\n link.click()\n } finally {\n link.remove()\n // Let the browser consume the download before releasing the image URL.\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n }\n}\n","/**\n * MermaidDiagram Component\n *\n * Renders a Mermaid diagram from source code.\n * Used inside MarkdownRenderer to handle ```mermaid code blocks.\n * Lazy-loads the mermaid library to avoid bloating the initial bundle.\n */\n\nimport { useState, useEffect, useId } from 'react'\nimport { Download } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\nimport { downloadMermaidSvg } from './download-mermaid'\n\ninterface MermaidDiagramProps {\n /** Mermaid diagram source code */\n chart: string\n}\n\n// Lazy-load and initialize mermaid once\nlet mermaidInstance: typeof import('mermaid').default | null = null\nlet mermaidLoadPromise: Promise<typeof import('mermaid').default> | null = null\n\nasync function getMermaid() {\n if (mermaidInstance) return mermaidInstance\n if (!mermaidLoadPromise) {\n mermaidLoadPromise = import('mermaid').then((mod) => {\n const m = mod.default\n m.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n flowchart: { useMaxWidth: true, curve: 'basis' },\n })\n mermaidInstance = m\n return m\n })\n }\n return mermaidLoadPromise\n}\n\nexport function MermaidDiagram({ chart }: MermaidDiagramProps) {\n const [svg, setSvg] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const uniqueId = useId().replace(/:/g, '-')\n\n useEffect(() => {\n let cancelled = false\n\n async function render() {\n const mermaid = await getMermaid()\n const diagramId = `mermaid${uniqueId}`\n\n // Validate with parse() before render(). In Mermaid v11 a render() with\n // bad source can return a \"Syntax error in text\" bomb SVG instead of\n // throwing — and it appends DOM side-effects of its own — so a try/catch\n // around render() doesn't reliably catch failures and the bomb leaks\n // into the page (especially under React StrictMode where effects run\n // twice). parse() throws cleanly with no DOM side-effects.\n //\n // Defensive rescue: some LLMs emit single-line `graph`/`flowchart`\n // source. If the original parse fails, try a normalized variant. The\n // normalizer is a no-op on already-multi-line source and on non-graph\n // diagram types, so this only helps the bad-source case and never\n // corrupts valid input.\n let validSource: string | null = null\n let firstErr: unknown\n try {\n await mermaid.parse(chart)\n validSource = chart\n } catch (err) {\n firstErr = err\n const normalized = normalizeMermaidGraph(chart)\n if (normalized !== chart) {\n try {\n await mermaid.parse(normalized)\n validSource = normalized\n } catch (retryErr) {\n console.warn('Mermaid normalized parse also failed', retryErr)\n }\n }\n }\n\n if (cancelled) return\n\n if (!validSource) {\n console.warn('Mermaid parse failed, showing source', firstErr)\n setError('Failed to render diagram')\n setSvg(null)\n return\n }\n\n try {\n const { svg: renderedSvg } = await mermaid.render(diagramId, validSource)\n if (!cancelled) {\n setSvg(renderedSvg)\n setError(null)\n }\n } catch (renderErr) {\n if (!cancelled) {\n console.warn('Mermaid render failed despite parse success', renderErr)\n setError('Failed to render diagram')\n setSvg(null)\n }\n }\n }\n\n render()\n return () => {\n cancelled = true\n }\n }, [chart, uniqueId])\n\n if (error) {\n // Fall back to showing the raw source in a code block\n return (\n <div className=\"code-block\" data-testid=\"mermaid-error\">\n <div className=\"text-sm text-muted-foreground mb-1\">{error}</div>\n <code className=\"language-mermaid\">{chart}</code>\n </div>\n )\n }\n\n if (!svg) {\n return (\n <div\n className=\"flex items-center justify-center py-8 text-muted-foreground text-sm\"\n data-testid=\"mermaid-loading\"\n >\n Rendering diagram...\n </div>\n )\n }\n\n return (\n <div\n className=\"mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4\"\n data-testid=\"mermaid-diagram\"\n >\n <div className=\"mb-2 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => downloadMermaidSvg(svg)}>\n <Download className=\"mr-2 size-4\" aria-hidden=\"true\" />\n Download SVG\n </Button>\n </div>\n <div dangerouslySetInnerHTML={{ __html: svg }} />\n </div>\n )\n}\n","import { DATABASES_OPEN_VIEW, type ArbiSessionStore } from '@arbidocs/react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { BlocksEnvironment } from '../../provider/environment'\n\n/** Navigation intents shared by copied entity links and inline entity menus. */\nexport async function openEntityReference(\n id: string,\n session: ArbiSessionStore,\n env: BlocksEnvironment,\n arbi?: Arbi\n) {\n const prefix = id.split('-')[0]\n switch (prefix) {\n case 'pag':\n session.setViewValue('pages.open', id)\n session.setPage('pages')\n break\n case 'dbs':\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: id })\n session.setPage('databases')\n break\n case 'fct':\n env.openFacts?.({ focusId: id })\n break\n case 'tag':\n session.setPage('tags')\n session.setTransientView('tags.focus', id)\n break\n case 'viw': {\n if (!arbi) return\n const workspace = session.getState().workspaceId\n if (!workspace) return\n const view = await arbi.readInWorkspace(workspace, () => arbi.views.get(id))\n if (session.getState().workspaceId !== workspace) return\n if (view.target === 'documents') {\n session.setTransientView('documents.openView', id)\n session.setPage('documents')\n } else {\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: view.target, viewId: id })\n session.setPage('databases')\n }\n break\n }\n case 'wfl':\n env.openWorkflow?.(id)\n break\n case 'prj':\n env.openProject(id)\n break\n case 'usr':\n case 'agt':\n env.openDirectChat?.(id)\n break\n case 'cht':\n env.openChat?.(id)\n break\n case 'cal':\n env.openCalendar()\n break\n }\n}\n","import {\n useArbiHost,\n useArbiSessionState,\n useArbiSessionStore,\n openCall,\n useEntityReferenceTitle,\n} from '@arbidocs/react'\nimport { EntityPill, EntityIcon } from '@arbidocs/react/ui'\nimport {\n CalendarDays,\n Phone,\n Database,\n LayoutDashboard,\n Workflow,\n StickyNote,\n Table2,\n Tags,\n User,\n MessagesSquare,\n Folder,\n} from 'lucide-react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useDocumentWorkspace } from './DocumentWorkspaceContext'\nimport { hrefFor, parseHref } from '../../lib/routes'\nimport { openEntityReference } from './open-entity-reference'\nimport { parseCallFragment } from '@arbidocs/client'\n\nconst kinds = {\n evt: ['Appointment', CalendarDays],\n call: ['Call', Phone],\n con: ['Thread', MessagesSquare],\n wrk: ['Workspace', Folder],\n prj: ['Project', Folder],\n wfl: ['Workflow', Workflow],\n pag: ['Page', LayoutDashboard],\n dbs: ['Database', Database],\n viw: ['Saved view', Table2],\n fct: ['Fact', StickyNote],\n tag: ['Tag', Tags],\n usr: ['Person', User],\n agt: ['Agent', User],\n cht: ['Chat', MessagesSquare],\n cal: ['Calendar', CalendarDays],\n} as const\n\n/** A permission-aware reference, shared by main conversations and encrypted DMs. */\nfunction ConnectedEntityReference({\n id,\n href,\n title,\n workspaceId: explicitWorkspace,\n}: {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}) {\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const metadata = useEntityReferenceTitle(\n id,\n workspaceId,\n global || prefix === 'con' || workspaceId === selected\n )\n return (\n <EntityReferenceView id={id} href={href} title={metadata || title} workspaceId={workspaceId} />\n )\n}\n\ninterface ReferenceProps {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}\nexport function EntityReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi ? <ConnectedEntityReference {...props} /> : <EntityReferenceView {...props} />\n}\nfunction EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }: ReferenceProps) {\n const arbi = useArbiHost().arbi\n const env = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const [kind, Icon] = kinds[prefix] ?? ['Entity', Folder]\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const target =\n prefix === 'con'\n ? hrefFor({ kind: 'conversation', conversationId: id, workspaceId })\n : prefix === 'evt'\n ? hrefFor({ kind: 'calendar', eventId: id })\n : prefix === 'call'\n ? hrefFor({ kind: 'call', callId: id })\n : prefix === 'wrk'\n ? hrefFor({ kind: 'workspace', workspaceId: id })\n : hrefFor({\n kind: 'entity',\n entityId: id,\n workspaceId: global ? undefined : workspaceId,\n })\n const link = href ?? target\n const open = () => {\n if (prefix === 'con') {\n const route = href ? parseHref(href) : null\n env.openConversation(id, {\n workspaceId: workspaceId ?? undefined,\n messageId: route?.kind === 'conversation' ? route.messageId : undefined,\n })\n } else if (prefix === 'evt') env.openCalendar({ event: { id } })\n else if (prefix === 'call') {\n const fragment = href ? parseCallFragment(new URL(href, window.location.href).hash) : null\n if (arbi)\n void openCall(arbi, {\n callExtId: id,\n key: fragment?.key,\n linkVersion: fragment?.linkVersion,\n })\n else if (link) env.navigate(link)\n } else if (prefix === 'wrk') env.openWorkspace(id)\n else if (workspaceId && workspaceId !== selected && link) env.navigate(link)\n else\n void openEntityReference(id, session, env, arbi).catch(() =>\n env.notify('Unable to open content.', 'error')\n )\n }\n return (\n <EntityPill\n icon={\n prefix === 'con' ? (\n <EntityIcon entityType=\"CONVERSATION\" className=\"h-3.5 w-3.5 shrink-0\" />\n ) : (\n <Icon className=\"h-3.5 w-3.5 shrink-0\" />\n )\n }\n label={title || kind}\n copyHref={link}\n onClick={open}\n tooltipContent={`${kind}: ${title || id}`}\n labelMaxWidth=\"max-w-[min(20rem,65vw)]\"\n data-testid={`entity-reference-${id}`}\n />\n )\n}\n","import { EntityReference } from './EntityReference'\nimport { ENTITY_ID } from './entity-references'\nimport { parseHref } from '../../lib/routes'\n/**\n * The conversation's markdown: the kit's `MarkdownRenderer` (`@arbidocs/react`: sanitised HTML,\n * slugs, lazy KaTeX, streaming blocks, tables, code) with what a conversation adds: @mention chips,\n * workspace documents opening in the viewer, quiet external links, document and email pills (the\n * host's chips, `ArbiChatHost.renderDocumentChip` / `renderMailChip`) and Mermaid diagrams.\n */\nimport { useArbiHost, useArbiSession, useArbiSessionState, useDocument } from '@arbidocs/react'\nimport { mentionFromHref, type MentionKind } from '@arbidocs/react/shell'\nimport {\n EntityPill,\n MarkdownCode,\n MarkdownLink,\n MarkdownRenderer as KitMarkdownRenderer,\n MarkdownStreamingContext,\n type MarkdownRendererProps as KitMarkdownRendererProps,\n DocumentEntity,\n} from '@arbidocs/react/ui'\nimport React, { useContext, useMemo } from 'react'\nimport { FileText, Mail } from 'lucide-react'\n\n/** The markdown element overrides, as the kit's renderer takes them. */\ntype Components = NonNullable<KitMarkdownRendererProps['components']>\nimport { MentionChip } from '../../chat/MentionMenu'\nimport { QuietLink } from '../../citations/QuietMarks'\nimport { rehypeDocEntityPills } from '../../chat/rehype-doc-entity-pills'\nimport { workspaceDocIdFromHref } from '../../chat/doc-links'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { MermaidDiagram } from './MermaidDiagram'\nimport { useDocumentWorkspace, WorkspaceDocumentReference } from './DocumentWorkspaceContext'\n\n/** Plain text of a link's children (the `@Label` of a mention link). */\nfunction childrenText(children: React.ReactNode): string {\n return React.Children.toArray(children)\n .map((child) =>\n typeof child === 'string' || typeof child === 'number'\n ? String(child)\n : React.isValidElement<{ children?: React.ReactNode }>(child)\n ? childrenText(child.props.children)\n : ''\n )\n .join('')\n}\n\n/** Text labels may be formatted; a non-text leaf (such as an image) needs the rich-child path. */\nfunction plainLinkText(children: React.ReactNode): string | null {\n const parts = React.Children.toArray(children).map((child): string | null => {\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n if (\n React.isValidElement<{ children?: React.ReactNode }>(child) &&\n child.props.children != null\n ) {\n return plainLinkText(child.props.children)\n }\n return null\n })\n return parts.includes(null) ? null : parts.join('')\n}\n\n/** A mention chip; a mention of the reader stands out. */\nfunction MentionLink({ kind, id, text }: { kind: MentionKind; id: string; text: string }) {\n const currentUserId = useArbiSession().user?.external_id\n return (\n <MentionChip\n kind={kind}\n id={id}\n label={text.replace(/^@/, '')}\n isSelf={kind === 'user' && id === currentUserId}\n />\n )\n}\n\n/**\n * A link to elsewhere, as quiet text. Its menu (Open link / Copy link) is the deliberate step\n * the old confirmation dialog used to be; nothing opens until the menu's primary row is chosen.\n */\nexport function ExternalLink({ href, children }: React.ComponentPropsWithoutRef<'a'>) {\n return (\n <QuietLink href={href} kind=\"external\">\n {children}\n </QuietLink>\n )\n}\n\n/**\n * A workspace document referenced by a link's href rather than by its text.\n *\n * `rehypeDocEntityPills` turns a bare `doc-…` id into a pill, but it only walks\n * TEXT nodes — so `[NVDA DCF Valuation Report](…doc-abc12345…)`, which is how an\n * answer links an artifact it just saved, keeps the id in the href where the\n * plugin never looks. The link then fell through to `ExternalLink`, and opening\n * your own workspace document asked you to confirm an \"external link\" and\n * launched a new tab. It opens in the document viewer, like the pill and the\n * artifact card already do.\n */\nexport function InternalDocLink({\n docId,\n href,\n children,\n}: React.ComponentPropsWithoutRef<'a'> & { docId: string }) {\n const { runtimeConfig } = useBlocksEnvironment()\n const conversationWorkspace = useDocumentWorkspace()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n // A delegated reference can target a different workspace than its Home DM. Only trust the\n // route after the same origin/deployment check used by the markdown adapters.\n const route =\n href && workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId\n ? parseHref(href)\n : null\n const workspaceId =\n (route?.kind === 'document' ? route.workspaceId : null) ??\n conversationWorkspace ??\n selectedWorkspace\n const text = plainLinkText(children)?.trim()\n const isAddress = !text || text === href || text === docId\n\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} copyHref={href}>\n {text === undefined ? children : isAddress ? undefined : text}\n </WorkspaceDocumentReference>\n )\n}\n\n/** A document of the workspace, as a pill: the host's chip, else the document entity. */\nexport function DocumentChip({ docId }: { docId: string }) {\n const render = useArbiHost().chat?.renderDocumentChip\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) return <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} />\n return render ? <>{render(docId)}</> : <DefaultDocumentChip docId={docId} />\n}\n\nfunction DefaultDocumentChip({ docId }: { docId: string }) {\n const { data: doc } = useDocument(docId)\n const { openDocument, hrefFor } = useBlocksEnvironment()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n const copyHref = hrefFor({ kind: 'document', documentId: docId, workspaceId: selectedWorkspace })\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"File\"\n copyHref={copyHref}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity\n doc={doc}\n copyHref={copyHref}\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nfunction MailChip({ mailId }: { mailId: string }) {\n const render = useArbiHost().chat?.renderMailChip\n if (render) return <>{render(mailId)}</>\n return (\n <EntityPill\n icon={<Mail className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"Email\"\n size=\"sm\"\n data-testid=\"mail-entity-pill\"\n />\n )\n}\n\n/**\n * The conversation's overrides, layered on the kit's defaults. Module scope, so the reference is stable\n * and memoised markdown blocks do not re-parse.\n */\nconst conversationMarkdownComponents: Partial<Components> = {\n a: function ConversationMarkdownLink({\n href,\n children,\n ...props\n }: React.ComponentPropsWithoutRef<'a'>) {\n const deploymentDomain = useBlocksEnvironment().runtimeConfig.deploymentDomain\n // @mentions: `linkMentions` turned them into `#mention-<id>` links; draw them as chips.\n const mention = mentionFromHref(href)\n if (mention) {\n return <MentionLink kind={mention.kind} id={mention.id} text={childrenText(children)} />\n }\n // Bookmarks: in-page anchors are near-invisible text; the menu jumps or copies the place.\n if (href?.startsWith('#') && !href.startsWith('#cite-')) {\n return (\n <QuietLink href={href} kind=\"anchor\">\n {children}\n </QuietLink>\n )\n }\n // Citations, `cite:` references and bare links: the kit's link.\n if (!href || href.startsWith('#') || href.startsWith('cite:')) {\n return (\n <MarkdownLink href={href} {...props}>\n {children}\n </MarkdownLink>\n )\n }\n // A workspace document is not an external link, wherever it is hosted: it opens in the viewer.\n const docId = workspaceDocIdFromHref(href, deploymentDomain)\n if (docId) {\n return (\n <InternalDocLink docId={docId} href={href} {...props}>\n {children}\n </InternalDocLink>\n )\n }\n const route = parseHref(href)\n const reference =\n route?.kind === 'entity'\n ? route.entityId\n : route?.kind === 'conversation'\n ? route.conversationId\n : route?.kind === 'workspace'\n ? route.workspaceId\n : route?.kind === 'call'\n ? route.callId\n : route?.kind === 'calendar'\n ? route.eventId\n : undefined\n if (reference && !reference.startsWith('doc-')) {\n const url = new URL(href, window.location.href)\n const trusted =\n url.origin === window.location.origin ||\n (url.protocol === 'https:' && url.hostname === deploymentDomain)\n if (trusted)\n return (\n <EntityReference\n id={reference}\n href={href}\n title={childrenText(children) === href ? undefined : childrenText(children)}\n workspaceId={url.pathname.match(/\\b(wrk-[a-zA-Z0-9]{8})\\b/)?.[1]}\n />\n )\n }\n return (\n <ExternalLink href={href} {...props}>\n {children}\n </ExternalLink>\n )\n },\n code: function ConversationMarkdownCode(\n props: React.ComponentPropsWithoutRef<'code'> & { inline?: boolean }\n ) {\n const isStreaming = useContext(MarkdownStreamingContext)\n const { className, children } = props\n const language = /language-(\\w+)/.exec(className || '')?.[1]\n if (!language) {\n // Answers often backtick a bare doc id (`doc-f7b3eeb5`). The text-node pass skips code, so\n // the id would stay monospace text; show it as the document pill. Only a whole id (eight\n // alphanumerics): while streaming, a partial one (\"doc-e\") would be looked up and 404.\n const codeText = typeof children === 'string' ? children.trim() : ''\n if (/^doc-[a-zA-Z0-9]{8}$/.test(codeText)) return <DocumentChip docId={codeText} />\n if (/^eml-[a-zA-Z0-9]{8}$/.test(codeText)) return <MailChip mailId={codeText} />\n if (ENTITY_ID.test(codeText)) return <EntityReference id={codeText} />\n }\n // Mermaid lazy-loads its own bundle and re-renders SVG on every change. While streaming the\n // fence is almost always partial, so it stays a code block until generation completes.\n if (language === 'mermaid' && !isStreaming) {\n return <MermaidDiagram chart={String(children).replace(/\\n$/, '')} />\n }\n return <MarkdownCode {...props} />\n },\n span: ({ children, className, ...props }: React.ComponentPropsWithoutRef<'span'>) => {\n const entityId = (props as Record<string, unknown>)['data-entity-id'] as string | undefined\n if (entityId) return <EntityReference id={entityId} />\n const docId = (props as Record<string, unknown>)['data-doc-id'] as string | undefined\n if (docId) return <DocumentChip docId={docId} />\n const mailId = (props as Record<string, unknown>)['data-mail-id'] as string | undefined\n if (mailId) return <MailChip mailId={mailId} />\n return (\n <span className={className} {...props}>\n {children}\n </span>\n )\n },\n}\n\n/** Bare `doc-…` / `eml-…` ids in text become `<span data-doc-id>` / `<span data-mail-id>` pills. */\nconst conversationRehypePlugins = [rehypeDocEntityPills]\n\nexport type ConnectedMarkdownProps = Omit<\n KitMarkdownRendererProps,\n 'rehypePlugins' | 'allowHtml' | 'renderCitation'\n>\n\n/**\n * The kit's renderer with the conversation's overrides; a caller's `components` (e.g. the citation\n * core's) still win over both.\n */\nfunction ConnectedMarkdownComponent({ components, ...props }: ConnectedMarkdownProps) {\n const merged = useMemo(\n () =>\n components\n ? { ...conversationMarkdownComponents, ...components }\n : conversationMarkdownComponents,\n [components]\n )\n return (\n <KitMarkdownRenderer {...props} components={merged} rehypePlugins={conversationRehypePlugins} />\n )\n}\n\nexport const ConnectedMarkdown = React.memo(ConnectedMarkdownComponent)\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.cjs');
|
|
4
5
|
var chunkF3QHSUUO_cjs = require('./chunk-F3QHSUUO.cjs');
|
|
5
6
|
var chunkQUMUAJ2P_cjs = require('./chunk-QUMUAJ2P.cjs');
|
|
6
|
-
var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.cjs');
|
|
7
7
|
var react$1 = require('react');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
9
|
var ui = require('@arbidocs/react/ui');
|
|
@@ -132,5 +132,5 @@ function ConnectedMailInviteCard({
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
exports.ConnectedMailInviteCard = ConnectedMailInviteCard;
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-AS2FZ2T7.cjs.map
|
|
136
|
+
//# sourceMappingURL=chunk-AS2FZ2T7.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/calendar/ConnectedMailInviteCard.tsx"],"names":["useBlocksEnvironment","isCalendarAttachment","useCalendarSettings","safeZone","detectTimeZone","useMailAttachmentText","parseIcsInvite","useCalendarEventByUid","useRespondToEvent","useState","useEffect","formatEventWhen","isQueuedCalendarWrite","jsxs","jsx","CalendarDays","cn","Fragment","Button"],"mappings":";;;;;;;;;;;AAkCA,IAAM,aAAA,GAAwC;AAAA,EAC5C,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU,cAAA;AAAA,EACV,SAAA,EAAW,gBAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAEO,SAAS,uBAAA,CAAwB;AAAA,EACtC,SAAA;AAAA,EACA,SAAA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MAAM,WAAA,CAAY,EAAE,EAAA,EAAI,KAAA,CAAM,IAAI,CAAA;AAAA,gBAC3C,aAAA,EAAY,kBAAA;AAAA,gBACb,QAAA,EAAA;AAAA;AAAA;AAED,WAAA,EAEJ;AAAA,SAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-HHZDURXN.cjs","sourcesContent":["/**\n * Invitation card in the Mail message view: when the message carries an iCalendar part, show the event\n * (parsed client-side) and, if it is in my calendar (GET /lookup?uid=), Accept / Maybe / Decline and\n * Open in calendar. Self-contained so the mail view only mounts it.\n */\nimport { useEffect, useState } from 'react'\nimport { CalendarDays } from 'lucide-react'\nimport { Button, cn } from '@arbidocs/react/ui'\nimport {\n isQueuedCalendarWrite,\n useCalendarEventByUid,\n useCalendarSettings,\n useMailAttachmentText,\n useRespondToEvent,\n type MailAttachment,\n} from '@arbidocs/react'\nimport {\n detectTimeZone,\n formatEventWhen,\n isCalendarAttachment,\n parseIcsInvite,\n safeZone,\n} from '../../calendar'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\nexport interface ConnectedMailInviteCardProps {\n accountId: string\n messageId: string\n attachments: MailAttachment[]\n isOnline: boolean\n /** Open the event in the host's calendar (\"Open in calendar\"); without it the button is hidden. */\n onOpenEvent?: (event: { id: string }) => void\n}\n\nconst PARTSTAT_TEXT: Record<string, string> = {\n accepted: 'You accepted',\n declined: 'You declined',\n tentative: 'You said maybe',\n needs_action: 'Not answered yet',\n}\n\nexport function ConnectedMailInviteCard({\n accountId,\n messageId,\n attachments,\n isOnline,\n onOpenEvent,\n}: ConnectedMailInviteCardProps) {\n const { notify } = useBlocksEnvironment()\n const part = attachments.find(isCalendarAttachment)\n const { data: settings } = useCalendarSettings(!!part)\n const zone = safeZone(settings?.time_zone, detectTimeZone())\n const { data: ics } = useMailAttachmentText(accountId, messageId, part, { enabled: isOnline })\n const invite = ics ? parseIcsInvite(ics, zone) : null\n const lookup = useCalendarEventByUid(invite?.uid && invite.method !== 'REPLY' ? invite.uid : null)\n const respond = useRespondToEvent()\n const [partstat, setPartstat] = useState<string | null>(null)\n const event = lookup.data ?? null\n useEffect(() => setPartstat(event?.my_partstat ?? null), [event?.my_partstat])\n\n if (!part || !invite) return null\n const cancelled = invite.method === 'CANCEL' || invite.status === 'CANCELLED'\n const when =\n invite.startUtc && invite.endUtc\n ? formatEventWhen(\n {\n all_day: invite.allDay,\n start_utc: invite.startUtc,\n end_utc: invite.endUtc,\n start: { date: invite.startDate },\n end: { date: invite.endDate },\n },\n zone\n )\n : ''\n const canRespond = !!event && !event.is_organizer && event.my_partstat != null && !cancelled\n\n const answer = (p: 'accepted' | 'tentative' | 'declined') =>\n event &&\n respond.mutate(\n { id: event.id, partstat: p },\n {\n onSuccess: (updated) =>\n setPartstat(isQueuedCalendarWrite(updated) ? p : (updated.my_partstat ?? p)),\n onError: (err) => notify(`Could not send your response: ${err.message}`, 'error'),\n }\n )\n\n return (\n <div\n className=\"mb-4 flex gap-3 rounded-lg border border-border bg-muted/20 p-3\"\n data-testid=\"mail-invite-card\"\n >\n <CalendarDays className=\"mt-0.5 size-5 shrink-0 text-primary\" aria-hidden />\n <div className=\"min-w-0 flex-1 space-y-1.5\">\n <div\n className={cn('font-medium', cancelled && 'line-through')}\n data-testid=\"mail-invite-title\"\n >\n {invite.title || 'Untitled event'}\n </div>\n <div className=\"text-sm text-muted-foreground\">{when}</div>\n {invite.location && <div className=\"text-sm text-muted-foreground\">{invite.location}</div>}\n {invite.organizer && (\n <div className=\"text-xs text-muted-foreground\">\n Organiser: {invite.organizer.name || invite.organizer.email}\n </div>\n )}\n {cancelled && <div className=\"text-sm text-destructive\">This event was cancelled.</div>}\n {invite.method === 'REPLY' && (\n <div className=\"text-sm text-muted-foreground\">A guest replied to your invitation.</div>\n )}\n {!cancelled && invite.method !== 'REPLY' && !lookup.isLoading && !event && isOnline && (\n <div className=\"text-xs text-muted-foreground\">Not in your calendar yet.</div>\n )}\n {canRespond && partstat && (\n <div className=\"text-xs text-muted-foreground\" data-testid=\"mail-invite-status\">\n {PARTSTAT_TEXT[partstat] ?? partstat}\n </div>\n )}\n <div className=\"flex flex-wrap gap-1.5 pt-1\">\n {canRespond && (\n <>\n <Button\n size=\"sm\"\n variant={partstat === 'accepted' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('accepted')}\n data-testid=\"mail-invite-accept\"\n >\n Accept\n </Button>\n <Button\n size=\"sm\"\n variant={partstat === 'tentative' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('tentative')}\n >\n Maybe\n </Button>\n <Button\n size=\"sm\"\n variant={partstat === 'declined' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('declined')}\n >\n Decline\n </Button>\n </>\n )}\n {event && onOpenEvent && (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => onOpenEvent({ id: event.id })}\n data-testid=\"mail-invite-open\"\n >\n Open in calendar\n </Button>\n )}\n </div>\n </div>\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/calendar/ConnectedMailInviteCard.tsx"],"names":["useBlocksEnvironment","isCalendarAttachment","useCalendarSettings","safeZone","detectTimeZone","useMailAttachmentText","parseIcsInvite","useCalendarEventByUid","useRespondToEvent","useState","useEffect","formatEventWhen","isQueuedCalendarWrite","jsxs","jsx","CalendarDays","cn","Fragment","Button"],"mappings":";;;;;;;;;;;AAkCA,IAAM,aAAA,GAAwC;AAAA,EAC5C,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU,cAAA;AAAA,EACV,SAAA,EAAW,gBAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAEO,SAAS,uBAAA,CAAwB;AAAA,EACtC,SAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAiC;AAC/B,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIA,sCAAA,EAAqB;AACxC,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;AAED,WAAA,EAEJ;AAAA,SAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-AS2FZ2T7.cjs","sourcesContent":["/**\n * Invitation card in the Mail message view: when the message carries an iCalendar part, show the event\n * (parsed client-side) and, if it is in my calendar (GET /lookup?uid=), Accept / Maybe / Decline and\n * Open in calendar. Self-contained so the mail view only mounts it.\n */\nimport { useEffect, useState } from 'react'\nimport { CalendarDays } from 'lucide-react'\nimport { Button, cn } from '@arbidocs/react/ui'\nimport {\n isQueuedCalendarWrite,\n useCalendarEventByUid,\n useCalendarSettings,\n useMailAttachmentText,\n useRespondToEvent,\n type MailAttachment,\n} from '@arbidocs/react'\nimport {\n detectTimeZone,\n formatEventWhen,\n isCalendarAttachment,\n parseIcsInvite,\n safeZone,\n} from '../../calendar'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\nexport interface ConnectedMailInviteCardProps {\n accountId: string\n messageId: string\n attachments: MailAttachment[]\n isOnline: boolean\n /** Open the event in the host's calendar (\"Open in calendar\"); without it the button is hidden. */\n onOpenEvent?: (event: { id: string }) => void\n}\n\nconst PARTSTAT_TEXT: Record<string, string> = {\n accepted: 'You accepted',\n declined: 'You declined',\n tentative: 'You said maybe',\n needs_action: 'Not answered yet',\n}\n\nexport function ConnectedMailInviteCard({\n accountId,\n messageId,\n attachments,\n isOnline,\n onOpenEvent,\n}: ConnectedMailInviteCardProps) {\n const { notify } = useBlocksEnvironment()\n const part = attachments.find(isCalendarAttachment)\n const { data: settings } = useCalendarSettings(!!part)\n const zone = safeZone(settings?.time_zone, detectTimeZone())\n const { data: ics } = useMailAttachmentText(accountId, messageId, part, { enabled: isOnline })\n const invite = ics ? parseIcsInvite(ics, zone) : null\n const lookup = useCalendarEventByUid(invite?.uid && invite.method !== 'REPLY' ? invite.uid : null)\n const respond = useRespondToEvent()\n const [partstat, setPartstat] = useState<string | null>(null)\n const event = lookup.data ?? null\n useEffect(() => setPartstat(event?.my_partstat ?? null), [event?.my_partstat])\n\n if (!part || !invite) return null\n const cancelled = invite.method === 'CANCEL' || invite.status === 'CANCELLED'\n const when =\n invite.startUtc && invite.endUtc\n ? formatEventWhen(\n {\n all_day: invite.allDay,\n start_utc: invite.startUtc,\n end_utc: invite.endUtc,\n start: { date: invite.startDate },\n end: { date: invite.endDate },\n },\n zone\n )\n : ''\n const canRespond = !!event && !event.is_organizer && event.my_partstat != null && !cancelled\n\n const answer = (p: 'accepted' | 'tentative' | 'declined') =>\n event &&\n respond.mutate(\n { id: event.id, partstat: p },\n {\n onSuccess: (updated) =>\n setPartstat(isQueuedCalendarWrite(updated) ? p : (updated.my_partstat ?? p)),\n onError: (err) => notify(`Could not send your response: ${err.message}`, 'error'),\n }\n )\n\n return (\n <div\n className=\"mb-4 flex gap-3 rounded-lg border border-border bg-muted/20 p-3\"\n data-testid=\"mail-invite-card\"\n >\n <CalendarDays className=\"mt-0.5 size-5 shrink-0 text-primary\" aria-hidden />\n <div className=\"min-w-0 flex-1 space-y-1.5\">\n <div\n className={cn('font-medium', cancelled && 'line-through')}\n data-testid=\"mail-invite-title\"\n >\n {invite.title || 'Untitled event'}\n </div>\n <div className=\"text-sm text-muted-foreground\">{when}</div>\n {invite.location && <div className=\"text-sm text-muted-foreground\">{invite.location}</div>}\n {invite.organizer && (\n <div className=\"text-xs text-muted-foreground\">\n Organiser: {invite.organizer.name || invite.organizer.email}\n </div>\n )}\n {cancelled && <div className=\"text-sm text-destructive\">This event was cancelled.</div>}\n {invite.method === 'REPLY' && (\n <div className=\"text-sm text-muted-foreground\">A guest replied to your invitation.</div>\n )}\n {!cancelled && invite.method !== 'REPLY' && !lookup.isLoading && !event && isOnline && (\n <div className=\"text-xs text-muted-foreground\">Not in your calendar yet.</div>\n )}\n {canRespond && partstat && (\n <div className=\"text-xs text-muted-foreground\" data-testid=\"mail-invite-status\">\n {PARTSTAT_TEXT[partstat] ?? partstat}\n </div>\n )}\n <div className=\"flex flex-wrap gap-1.5 pt-1\">\n {canRespond && (\n <>\n <Button\n size=\"sm\"\n variant={partstat === 'accepted' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('accepted')}\n data-testid=\"mail-invite-accept\"\n >\n Accept\n </Button>\n <Button\n size=\"sm\"\n variant={partstat === 'tentative' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('tentative')}\n >\n Maybe\n </Button>\n <Button\n size=\"sm\"\n variant={partstat === 'declined' ? 'default' : 'outline'}\n disabled={!isOnline || respond.isPending}\n onClick={() => answer('declined')}\n >\n Decline\n </Button>\n </>\n )}\n {event && onOpenEvent && (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => onOpenEvent({ id: event.id })}\n data-testid=\"mail-invite-open\"\n >\n Open in calendar\n </Button>\n )}\n </div>\n </div>\n </div>\n )\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkTBDQGSFI_cjs = require('./chunk-TBDQGSFI.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkWQMIBHSQ_cjs = require('./chunk-WQMIBHSQ.cjs');
|
|
6
6
|
var react = require('@arbidocs/react');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ function ConnectedNativeDocxComparison({
|
|
|
10
10
|
fontBaseUrl,
|
|
11
11
|
...props
|
|
12
12
|
}) {
|
|
13
|
-
const adapter =
|
|
13
|
+
const adapter = chunkWQMIBHSQ_cjs.useConnectedNativeDocxAdapter(fontBaseUrl);
|
|
14
14
|
const { data: documents, isLoading } = react.useDocuments();
|
|
15
15
|
const morePages = react.useDocumentsLoading();
|
|
16
16
|
if (isLoading || morePages)
|
|
@@ -27,5 +27,5 @@ function ConnectedNativeDocxComparison({
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
exports.ConnectedNativeDocxComparison = ConnectedNativeDocxComparison;
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-CF3WPB7T.cjs.map
|
|
31
|
+
//# sourceMappingURL=chunk-CF3WPB7T.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/docx/ConnectedNativeDocxComparison.tsx"],"names":["useConnectedNativeDocxAdapter","useDocuments","useDocumentsLoading","jsx","NativeDocxComparison"],"mappings":";;;;;;;AAYO,SAAS,6BAAA,CAA8B;AAAA,EAC5C,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEG;AACD,EAAA,MAAM,OAAA,GAAUA,gDAA8B,WAAW,CAAA;AACzD,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,EAAW,SAAA,KAAcC,kBAAA,EAAa;AAEpD,EAAA,MAAM,YAAYC,yBAAA,EAAoB;AAEtC,EAAA,IAAI,SAAA,IAAa,SAAA;AACf,IAAA,sCACG,KAAA,EAAA,EAAI,SAAA,EAAU,mBAAA,EAAoB,IAAA,EAAK,UAAS,QAAA,EAAA,gCAAA,EAEjD,CAAA;AAEJ,EAAA,uBACEC,cAAA;AAAA,IAACC,sCAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,OAAA;AAAA,MACA,SAAA;AAAA,MACA,YAAY,OAAA,CAAQ;AAAA;AAAA,GACtB;AAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/connection/docx/ConnectedNativeDocxComparison.tsx"],"names":["useConnectedNativeDocxAdapter","useDocuments","useDocumentsLoading","jsx","NativeDocxComparison"],"mappings":";;;;;;;AAYO,SAAS,6BAAA,CAA8B;AAAA,EAC5C,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEG;AACD,EAAA,MAAM,OAAA,GAAUA,gDAA8B,WAAW,CAAA;AACzD,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,EAAW,SAAA,KAAcC,kBAAA,EAAa;AAEpD,EAAA,MAAM,YAAYC,yBAAA,EAAoB;AAEtC,EAAA,IAAI,SAAA,IAAa,SAAA;AACf,IAAA,sCACG,KAAA,EAAA,EAAI,SAAA,EAAU,mBAAA,EAAoB,IAAA,EAAK,UAAS,QAAA,EAAA,gCAAA,EAEjD,CAAA;AAEJ,EAAA,uBACEC,cAAA;AAAA,IAACC,sCAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,OAAA;AAAA,MACA,SAAA;AAAA,MACA,YAAY,OAAA,CAAQ;AAAA;AAAA,GACtB;AAEJ","file":"chunk-CF3WPB7T.cjs","sourcesContent":["import { useDocuments, useDocumentsLoading } from '@arbidocs/react'\nimport {\n NativeDocxComparison,\n type NativeDocxComparisonProps,\n} from '../../docx/NativeDocxComparison'\nimport { useConnectedNativeDocxAdapter } from './ConnectedNativeDocxEditor'\n\n/**\n * The Word redline of two documents or versions, on the signed-in session. The unedited redline\n * saved earlier from the same versions is opened again (found in the workspace's documents, once\n * all their pages are read), so opening a comparison saves at most one.\n */\nexport function ConnectedNativeDocxComparison({\n fontBaseUrl,\n ...props\n}: Omit<NativeDocxComparisonProps, 'adapter' | 'onCompared' | 'documents'> & {\n fontBaseUrl?: string\n}) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n const { data: documents, isLoading } = useDocuments()\n // Every page: the first holds only the oldest documents, and a redline is often newer.\n const morePages = useDocumentsLoading()\n // Until the documents are read, a saved redline can't be found: wait rather than save another.\n if (isLoading || morePages)\n return (\n <div className=\"native-docx-error\" role=\"status\">\n Comparing Word documents…\n </div>\n )\n return (\n <NativeDocxComparison\n {...props}\n adapter={adapter}\n documents={documents}\n onCompared={adapter.onVersionSaved}\n />\n )\n}\n"]}
|