@arbidocs/blocks 0.5.179 → 0.5.181
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-JY3LGQGP.cjs → ConnectedCallDock-JIA2YTO5.cjs} +21 -21
- package/dist/{ConnectedCallDock-JY3LGQGP.cjs.map → ConnectedCallDock-JIA2YTO5.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-GTH4J55D.cjs → ConnectedCallRoom-6HBC4RQ2.cjs} +14 -14
- package/dist/{ConnectedCallRoom-GTH4J55D.cjs.map → ConnectedCallRoom-6HBC4RQ2.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-2NBAE7EI.cjs → ConnectedNativeDocxComparison-3MRTTNR2.cjs} +18 -18
- package/dist/{ConnectedNativeDocxComparison-2NBAE7EI.cjs.map → ConnectedNativeDocxComparison-3MRTTNR2.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-VEMVDFI5.cjs → ConnectedPresentation-LNDESKYE.cjs} +17 -17
- package/dist/{ConnectedPresentation-VEMVDFI5.cjs.map → ConnectedPresentation-LNDESKYE.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-BKDYMRPF.cjs → ConnectedProductionSetDialog-SHDI7KP6.cjs} +6 -6
- package/dist/{ConnectedProductionSetDialog-BKDYMRPF.cjs.map → ConnectedProductionSetDialog-SHDI7KP6.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-GT5TQPWW.cjs → ConnectedSlidesTab-LEA5OW75.cjs} +15 -15
- package/dist/{ConnectedSlidesTab-GT5TQPWW.cjs.map → ConnectedSlidesTab-LEA5OW75.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-S7RQFGL5.cjs → ConnectedStreamedWordArtifact-HNTS6HS4.cjs} +18 -18
- package/dist/{ConnectedStreamedWordArtifact-S7RQFGL5.cjs.map → ConnectedStreamedWordArtifact-HNTS6HS4.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-3HOUMATK.cjs → DocumentReviewCard-RPHIQZ2Y.cjs} +17 -17
- package/dist/{DocumentReviewCard-3HOUMATK.cjs.map → DocumentReviewCard-RPHIQZ2Y.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-CH5RO64O.cjs → FilesViewerDialog-PZ5H435S.cjs} +50 -50
- package/dist/{FilesViewerDialog-CH5RO64O.cjs.map → FilesViewerDialog-PZ5H435S.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-HWZU2KWQ.cjs → WorkspaceTableView-QT63XYII.cjs} +9 -9
- package/dist/{WorkspaceTableView-HWZU2KWQ.cjs.map → WorkspaceTableView-QT63XYII.cjs.map} +1 -1
- package/dist/agents/index.cjs +287 -287
- package/dist/{ai-6JEFW4U6.cjs → ai-XIT4MY3S.cjs} +25 -25
- package/dist/ai-XIT4MY3S.cjs.map +1 -0
- package/dist/auth/index.cjs +12 -12
- package/dist/{avatar-renderer-O25E5KUY.cjs → avatar-renderer-SM466IFS.cjs} +108 -48
- package/dist/avatar-renderer-SM466IFS.cjs.map +1 -0
- package/dist/calls/connected/avatar-eyes.d.ts +5 -0
- package/dist/calls/connected/avatar-eyes.js +56 -0
- package/dist/calls/connected/avatar-eyes.js.map +7 -0
- package/dist/calls/connected/avatar-materials.d.ts +1 -1
- package/dist/calls/connected/avatar-materials.js +11 -7
- package/dist/calls/connected/avatar-materials.js.map +2 -2
- package/dist/calls/connected/avatar-renderer.js +7 -0
- package/dist/calls/connected/avatar-renderer.js.map +2 -2
- package/dist/calls/index.cjs +126 -126
- package/dist/chat/index.cjs +5 -5
- package/dist/{chunk-YZ6SFKUO.cjs → chunk-2D5GZMSK.cjs} +4 -4
- package/dist/{chunk-YZ6SFKUO.cjs.map → chunk-2D5GZMSK.cjs.map} +1 -1
- package/dist/{chunk-VNUBBRJM.cjs → chunk-2K5DLB7B.cjs} +3 -3
- package/dist/{chunk-VNUBBRJM.cjs.map → chunk-2K5DLB7B.cjs.map} +1 -1
- package/dist/{chunk-BJRQHR7R.cjs → chunk-3EIO4ZH5.cjs} +6 -6
- package/dist/{chunk-BJRQHR7R.cjs.map → chunk-3EIO4ZH5.cjs.map} +1 -1
- package/dist/{chunk-QSAW7XLZ.cjs → chunk-4AT2LJ2H.cjs} +4 -4
- package/dist/{chunk-QSAW7XLZ.cjs.map → chunk-4AT2LJ2H.cjs.map} +1 -1
- package/dist/{chunk-FHAUX6CD.cjs → chunk-4H5DPHZ2.cjs} +29 -29
- package/dist/{chunk-FHAUX6CD.cjs.map → chunk-4H5DPHZ2.cjs.map} +1 -1
- package/dist/{chunk-B5AOYT4U.cjs → chunk-5FSULBPE.cjs} +3 -3
- package/dist/{chunk-B5AOYT4U.cjs.map → chunk-5FSULBPE.cjs.map} +1 -1
- package/dist/{chunk-3P6KGC46.cjs → chunk-5OD6DRG7.cjs} +3 -3
- package/dist/{chunk-3P6KGC46.cjs.map → chunk-5OD6DRG7.cjs.map} +1 -1
- package/dist/{chunk-M3HYFFCK.cjs → chunk-7GVKG3G4.cjs} +13 -13
- package/dist/{chunk-M3HYFFCK.cjs.map → chunk-7GVKG3G4.cjs.map} +1 -1
- package/dist/{chunk-RRVNBO53.cjs → chunk-A4HOEGDI.cjs} +4 -4
- package/dist/{chunk-RRVNBO53.cjs.map → chunk-A4HOEGDI.cjs.map} +1 -1
- package/dist/{chunk-LSFGSQHS.cjs → chunk-A7MGQMOV.cjs} +9 -9
- package/dist/{chunk-LSFGSQHS.cjs.map → chunk-A7MGQMOV.cjs.map} +1 -1
- package/dist/{chunk-IRYVRCKU.cjs → chunk-AWWGV5LL.cjs} +28 -28
- package/dist/{chunk-IRYVRCKU.cjs.map → chunk-AWWGV5LL.cjs.map} +1 -1
- package/dist/{chunk-P3Q2XFEJ.cjs → chunk-CYMAF656.cjs} +13 -13
- package/dist/{chunk-P3Q2XFEJ.cjs.map → chunk-CYMAF656.cjs.map} +1 -1
- package/dist/{chunk-2N64TSHL.cjs → chunk-DKKW7GOJ.cjs} +4 -4
- package/dist/{chunk-2N64TSHL.cjs.map → chunk-DKKW7GOJ.cjs.map} +1 -1
- package/dist/{chunk-LJTHFTQQ.cjs → chunk-ER2MRSLT.cjs} +3 -3
- package/dist/{chunk-LJTHFTQQ.cjs.map → chunk-ER2MRSLT.cjs.map} +1 -1
- package/dist/{chunk-WQQ6C2ML.cjs → chunk-FUKN3PI5.cjs} +3 -3
- package/dist/{chunk-WQQ6C2ML.cjs.map → chunk-FUKN3PI5.cjs.map} +1 -1
- package/dist/{chunk-K4UR3U7K.cjs → chunk-GLFMRQBT.cjs} +10 -10
- package/dist/{chunk-K4UR3U7K.cjs.map → chunk-GLFMRQBT.cjs.map} +1 -1
- package/dist/{chunk-ZSZI576U.cjs → chunk-HH5MKRBL.cjs} +7 -7
- package/dist/{chunk-ZSZI576U.cjs.map → chunk-HH5MKRBL.cjs.map} +1 -1
- package/dist/{chunk-H3GJQSA5.cjs → chunk-HX5SALXN.cjs} +18 -18
- package/dist/{chunk-H3GJQSA5.cjs.map → chunk-HX5SALXN.cjs.map} +1 -1
- package/dist/{chunk-CR7QX5OA.cjs → chunk-I5LXJLO5.cjs} +10 -10
- package/dist/{chunk-CR7QX5OA.cjs.map → chunk-I5LXJLO5.cjs.map} +1 -1
- package/dist/{chunk-JGU6YLIA.cjs → chunk-KQJUY2OE.cjs} +11 -11
- package/dist/{chunk-JGU6YLIA.cjs.map → chunk-KQJUY2OE.cjs.map} +1 -1
- package/dist/{chunk-EG3DPKXM.cjs → chunk-L3MYUPSH.cjs} +5 -5
- package/dist/{chunk-EG3DPKXM.cjs.map → chunk-L3MYUPSH.cjs.map} +1 -1
- package/dist/{chunk-AHUEBRLX.cjs → chunk-LYDSETR7.cjs} +4 -4
- package/dist/{chunk-AHUEBRLX.cjs.map → chunk-LYDSETR7.cjs.map} +1 -1
- package/dist/{chunk-X6TSOKEP.cjs → chunk-LYJFE37D.cjs} +3 -3
- package/dist/{chunk-X6TSOKEP.cjs.map → chunk-LYJFE37D.cjs.map} +1 -1
- package/dist/{chunk-54YKEVLX.cjs → chunk-MZ7IUHQA.cjs} +36 -36
- package/dist/{chunk-54YKEVLX.cjs.map → chunk-MZ7IUHQA.cjs.map} +1 -1
- package/dist/{chunk-IPSR2PUU.cjs → chunk-OHWYQI3B.cjs} +12 -12
- package/dist/{chunk-IPSR2PUU.cjs.map → chunk-OHWYQI3B.cjs.map} +1 -1
- package/dist/{chunk-TU46WKTN.cjs → chunk-OIYKKUAN.cjs} +3 -3
- package/dist/{chunk-TU46WKTN.cjs.map → chunk-OIYKKUAN.cjs.map} +1 -1
- package/dist/{chunk-WXRAU2FF.cjs → chunk-QSY2VW7V.cjs} +6 -6
- package/dist/{chunk-WXRAU2FF.cjs.map → chunk-QSY2VW7V.cjs.map} +1 -1
- package/dist/{chunk-B6HWZMRE.cjs → chunk-S4KKJX3G.cjs} +68 -68
- package/dist/{chunk-B6HWZMRE.cjs.map → chunk-S4KKJX3G.cjs.map} +1 -1
- package/dist/{chunk-W7TSEN3J.cjs → chunk-TLIZD6DV.cjs} +6 -6
- package/dist/{chunk-W7TSEN3J.cjs.map → chunk-TLIZD6DV.cjs.map} +1 -1
- package/dist/{chunk-INVL4BE7.cjs → chunk-TQATDAJV.cjs} +4 -4
- package/dist/{chunk-INVL4BE7.cjs.map → chunk-TQATDAJV.cjs.map} +1 -1
- package/dist/{chunk-GZH52C4A.cjs → chunk-TUURH4NE.cjs} +4 -4
- package/dist/{chunk-GZH52C4A.cjs.map → chunk-TUURH4NE.cjs.map} +1 -1
- package/dist/{chunk-6SN5KCE5.cjs → chunk-UC6Z7E6C.cjs} +6 -6
- package/dist/{chunk-6SN5KCE5.cjs.map → chunk-UC6Z7E6C.cjs.map} +1 -1
- package/dist/{chunk-6N7QT2DH.cjs → chunk-VDHBLDQC.cjs} +3 -3
- package/dist/{chunk-6N7QT2DH.cjs.map → chunk-VDHBLDQC.cjs.map} +1 -1
- package/dist/{chunk-6ZJBUMNK.cjs → chunk-VDT7TEAH.cjs} +3 -3
- package/dist/{chunk-6ZJBUMNK.cjs.map → chunk-VDT7TEAH.cjs.map} +1 -1
- package/dist/{chunk-TPYOXG5S.cjs → chunk-XKXKEVHH.cjs} +6 -6
- package/dist/{chunk-TPYOXG5S.cjs.map → chunk-XKXKEVHH.cjs.map} +1 -1
- package/dist/{chunk-DJ7LSKBJ.cjs → chunk-XQPJWPWE.cjs} +3 -3
- package/dist/{chunk-DJ7LSKBJ.cjs.map → chunk-XQPJWPWE.cjs.map} +1 -1
- package/dist/{chunk-YHM3OAFN.cjs → chunk-YBDHWNFZ.cjs} +9 -9
- package/dist/{chunk-YHM3OAFN.cjs.map → chunk-YBDHWNFZ.cjs.map} +1 -1
- package/dist/{chunk-IYN6Q5SZ.cjs → chunk-YC72ZCV4.cjs} +61 -61
- package/dist/{chunk-IYN6Q5SZ.cjs.map → chunk-YC72ZCV4.cjs.map} +1 -1
- package/dist/{chunk-J3LWRFYO.cjs → chunk-YHABS4UE.cjs} +50 -50
- package/dist/{chunk-J3LWRFYO.cjs.map → chunk-YHABS4UE.cjs.map} +1 -1
- package/dist/{chunk-3S6HBOHG.cjs → chunk-ZBH466OU.cjs} +49 -49
- package/dist/{chunk-3S6HBOHG.cjs.map → chunk-ZBH466OU.cjs.map} +1 -1
- package/dist/connect/docx.cjs +21 -21
- package/dist/connect/index.cjs +1187 -1187
- package/dist/connect/viewer.cjs +38 -38
- package/dist/dashboards/index.cjs +1 -1
- package/dist/embed/index.cjs +44 -44
- package/dist/facts/index.cjs +43 -43
- package/dist/files/index.cjs +228 -228
- package/dist/home/index.cjs +9 -9
- package/dist/index.cjs +1778 -1778
- package/dist/pages/index.cjs +32 -32
- package/dist/settings/index.cjs +138 -138
- package/dist/shell/index.cjs +81 -81
- package/dist/studio/index.cjs +29 -29
- package/dist/workflow-canvas/index.cjs +61 -61
- package/dist/workspaces/index.cjs +5 -5
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/record/SKILL.md +16 -0
- package/record/render-take.py +36 -17
- package/dist/ai-6JEFW4U6.cjs.map +0 -1
- package/dist/avatar-renderer-O25E5KUY.cjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var chunkM55XUF4L_cjs = require('./chunk-M55XUF4L.cjs');
|
|
4
|
+
var chunkOHWYQI3B_cjs = require('./chunk-OHWYQI3B.cjs');
|
|
5
|
+
var chunkER2MRSLT_cjs = require('./chunk-ER2MRSLT.cjs');
|
|
7
6
|
var chunk5F4DCIHS_cjs = require('./chunk-5F4DCIHS.cjs');
|
|
7
|
+
var chunkM55XUF4L_cjs = require('./chunk-M55XUF4L.cjs');
|
|
8
8
|
var chunkSQCCQU3K_cjs = require('./chunk-SQCCQU3K.cjs');
|
|
9
9
|
var react$1 = require('react');
|
|
10
10
|
var react = require('@arbidocs/react');
|
|
@@ -19,7 +19,7 @@ function canOpenSkill(workflow, skillsEnabled) {
|
|
|
19
19
|
return workflow.run.kind === "prompt" && (skillsEnabled || chunkM55XUF4L_cjs.isSkillPackWorkflow(workflow));
|
|
20
20
|
}
|
|
21
21
|
function useSlashSkillWorkflows({ landing, send }) {
|
|
22
|
-
const { skills, skillsEnabled } =
|
|
22
|
+
const { skills, skillsEnabled } = chunkER2MRSLT_cjs.useWorkflowDefinitions();
|
|
23
23
|
const { commands } = react.useBuiltinCommands();
|
|
24
24
|
const [active, setActive] = react$1.useState(null);
|
|
25
25
|
const open = react$1.useCallback(
|
|
@@ -67,7 +67,7 @@ function useSlashSkillWorkflows({ landing, send }) {
|
|
|
67
67
|
return field && active.text ? { [field]: active.text } : void 0;
|
|
68
68
|
};
|
|
69
69
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
-
|
|
70
|
+
chunkOHWYQI3B_cjs.ConnectedWorkflowStart,
|
|
71
71
|
{
|
|
72
72
|
workflows: skills,
|
|
73
73
|
showTiles: false,
|
|
@@ -83,11 +83,11 @@ function useSlashSkillWorkflows({ landing, send }) {
|
|
|
83
83
|
}
|
|
84
84
|
var NO_SKILLS = [];
|
|
85
85
|
function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
86
|
-
const hostSkills =
|
|
87
|
-
const listings =
|
|
88
|
-
const skillsEnabled =
|
|
86
|
+
const hostSkills = chunkER2MRSLT_cjs.useHostSkills();
|
|
87
|
+
const listings = chunkER2MRSLT_cjs.useUsableSkillListings(hostSkills);
|
|
88
|
+
const skillsEnabled = chunkER2MRSLT_cjs.useSkillsEnabled();
|
|
89
89
|
const { commands } = react.useBuiltinCommands();
|
|
90
|
-
const builtins =
|
|
90
|
+
const builtins = chunkER2MRSLT_cjs.useNamedWorkflows(builtinSkills);
|
|
91
91
|
const items = react$1.useMemo(() => {
|
|
92
92
|
const packSlugs = new Set(hostSkills.map((w) => w.id));
|
|
93
93
|
return chunk5F4DCIHS_cjs.buildSlashItems(
|
|
@@ -98,7 +98,7 @@ function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
|
98
98
|
kind: "command"
|
|
99
99
|
})),
|
|
100
100
|
[
|
|
101
|
-
...hostSkills.map(
|
|
101
|
+
...hostSkills.map(chunkER2MRSLT_cjs.hostSkillItem),
|
|
102
102
|
...skillsEnabled ? skillItems(
|
|
103
103
|
builtins.filter((w) => !packSlugs.has(w.id)),
|
|
104
104
|
listings
|
|
@@ -106,7 +106,7 @@ function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
|
106
106
|
]
|
|
107
107
|
);
|
|
108
108
|
}, [commands, hostSkills, listings, skillsEnabled, builtins]);
|
|
109
|
-
return { items, canBrowseSkills:
|
|
109
|
+
return { items, canBrowseSkills: chunkER2MRSLT_cjs.useCanBrowseSkills() };
|
|
110
110
|
}
|
|
111
111
|
function useSlashItems(text, builtinSkills = NO_SKILLS) {
|
|
112
112
|
const { items, canBrowseSkills } = useSlashMenuItems(builtinSkills);
|
|
@@ -150,5 +150,5 @@ exports.parseTypedSkill = parseTypedSkill;
|
|
|
150
150
|
exports.useSlashItems = useSlashItems;
|
|
151
151
|
exports.useSlashMenuItems = useSlashMenuItems;
|
|
152
152
|
exports.useSlashSkillWorkflows = useSlashSkillWorkflows;
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-7GVKG3G4.cjs.map
|
|
154
|
+
//# sourceMappingURL=chunk-7GVKG3G4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/workflows/useSlashSkillWorkflows.tsx","../src/connection/conversation/useSlashItems.ts"],"names":["isSkillPackWorkflow","useWorkflowDefinitions","useBuiltinCommands","useState","useCallback","useMemo","promptFieldName","jsx","ConnectedWorkflowStart","useHostSkills","useUsableSkillListings","useSkillsEnabled","useNamedWorkflows","buildSlashItems","hostSkillItem","useCanBrowseSkills","parseSlashTokenInProgress","filterSlashItems","mergeSkillWorkflows"],"mappings":";;;;;;;;;;;AAiCA,IAAM,WAAA,GAAc,qDAAA;AAGb,SAAS,gBAAgB,KAAA,EAAsD;AACpF,EAAA,MAAM,CAAA,GAAI,WAAA,CAAY,IAAA,CAAK,KAAK,CAAA;AAChC,EAAA,OAAO,CAAA,GAAI,EAAE,IAAA,EAAM,CAAA,CAAE,CAAC,CAAA,CAAE,WAAA,EAAY,EAAG,IAAA,EAAA,CAAO,EAAE,CAAC,CAAA,IAAK,EAAA,EAAI,IAAA,IAAO,GAAI,IAAA;AACvE;AAMO,SAAS,YAAA,CAAa,UAA8B,aAAA,EAAiC;AAC1F,EAAA,OAAO,SAAS,GAAA,CAAI,IAAA,KAAS,QAAA,KAAa,aAAA,IAAiBA,sCAAoB,QAAQ,CAAA,CAAA;AACzF;AAQO,SAAS,sBAAA,CAAuB,EAAE,OAAA,EAAS,IAAA,EAAK,EAiBrD;AACA,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAA,EAAc,GAAIC,wCAAA,EAA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AE,KAAA,GAAQ,EAAA,CAAA;AAAA,QAC7D,OAAA,EAAS,GAAG,QAAA,IAAY,EAAA;AAAA,QACxB,UAAA,EAAY,CAAA,EAAG,UAAA,KAAe,QAAA,GAAW,QAAA,GAAW,MAAA;AAAA,QACpD,IAAA,EAAM;AAAA,OACR;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"chunk-M3HYFFCK.cjs","sourcesContent":["/**\n * Slash skills are launched prompt-first, through the one workflow launcher.\n *\n * A skill (or a prompt-style built-in such as Deep research) is run WITH a prompt, so it never\n * just executes:\n * - picking it in the slash menu opens its form (the prompt field first, focused, required);\n * - typing `/slug` and pressing Enter opens the same form with the field empty;\n * - typing `/slug some text` and pressing Enter opens it with the text already in the field.\n * The rule is the same for any recognised skill slug as the FIRST token of the draft; a backend\n * command (`/goal`, `/compact`, ...) is never a skill and is sent as typed. Nothing is sent from\n * the composer until the user starts it in the form. Without skills enabled (`show_skills`) this\n * applies to the host's skill packs only (`host.workflows.skillPacks`): the menu lists no other\n * skills and any other `/text` is sent as typed.\n *\n * The run lands where the surface says (`landing`), through the one launch handler. A chat that\n * is not the session's conversation (`ChatPage`, the document ask) passes `send`: the composed\n * prompt then goes to its own send, as a typed message would.\n */\n\nimport { useCallback, useMemo, useState, type ReactNode } from 'react'\nimport { promptFieldName } from '../../agents/workflows/workflow'\nimport { isSkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport { type SlashMenuItem } from '../../chat/SlashMenu'\nimport {\n type WorkflowDefinition,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { useBuiltinCommands } from '@arbidocs/react'\nimport { ConnectedWorkflowStart } from './ConnectedWorkflowStart'\nimport { useWorkflowDefinitions } from './useWorkflowDefinitions'\n\n/** `/slug` or `/slug rest of the line`: the first token and the text after it. */\nconst TYPED_SKILL = /^\\s*\\/([a-zA-Z0-9][a-zA-Z0-9_-]*)(?:\\s+([\\s\\S]*))?$/\n\n/** What the typed draft names: its slug (lower-cased) and the text after it (trimmed). */\nexport function parseTypedSkill(draft: string): { slug: string; text: string } | null {\n const m = TYPED_SKILL.exec(draft)\n return m ? { slug: m[1].toLowerCase(), text: (m[2] ?? '').trim() } : null\n}\n\n/**\n * Whether a skill opens its form from a menu (the `/` menus, the command palette): a prompt skill,\n * and with skills switched off (`show_skills`) only the host's packs. The one gate both share.\n */\nexport function canOpenSkill(workflow: WorkflowDefinition, skillsEnabled: boolean): boolean {\n return workflow.run.kind === 'prompt' && (skillsEnabled || isSkillPackWorkflow(workflow))\n}\n\nexport interface UseSlashSkillWorkflowsOptions {\n landing: WorkflowLanding\n /** Where the composed prompt goes, for a chat that is not the session's conversation. */\n send?: (prompt: string) => void\n}\n\nexport function useSlashSkillWorkflows({ landing, send }: UseSlashSkillWorkflowsOptions): {\n /** Opens the launcher for a picked menu item. True when it did (the caller then clears the draft). */\n openFor: (item: SlashMenuItem) => boolean\n /**\n * Opens the launcher for a typed `/slug text` draft, text pre-filled. True when the draft names\n * a skill (the caller then clears the draft and sends nothing).\n */\n openForDraft: (draft: string) => boolean\n /**\n * Opens the launcher for a skill by id (a surface listing the skills itself, the command\n * palette). True when it is a skill this person may run here.\n */\n openSkill: (id: string) => boolean\n /** The skills this person may open here: the host's packs, and the rest with `show_skills`. */\n openable: WorkflowDefinition[]\n /** Render once, anywhere in the surface that hosts the slash menu. */\n launcher: ReactNode\n} {\n const { skills, skillsEnabled } = useWorkflowDefinitions()\n const { commands } = useBuiltinCommands()\n const [active, setActive] = useState<{ id: string; text: string } | null>(null)\n\n // Stable while the lists are, so a surface can memoise what it builds on them.\n const open = useCallback(\n (workflow: WorkflowDefinition | undefined, text: string): boolean => {\n if (!workflow || !canOpenSkill(workflow, skillsEnabled)) return false\n setActive({ id: workflow.id, text })\n return true\n },\n [skillsEnabled]\n )\n\n const openFor = useCallback(\n (item: SlashMenuItem): boolean =>\n item.kind === 'skill' &&\n open(\n skills.find((w) => w.id === item.name),\n ''\n ),\n [open, skills]\n )\n\n const openSkill = useCallback(\n (id: string): boolean =>\n open(\n skills.find((w) => w.id === id),\n ''\n ),\n [open, skills]\n )\n\n const openable = useMemo(\n () => skills.filter((w) => canOpenSkill(w, skillsEnabled)),\n [skills, skillsEnabled]\n )\n\n const openForDraft = useCallback(\n (draft: string): boolean => {\n const typed = parseTypedSkill(draft)\n if (!typed) return false\n // A backend command wins a name collision, as in the menu: it is sent as typed.\n if (commands.some((c) => c.name.toLowerCase() === typed.slug)) return false\n return open(\n skills.find((w) => w.id.toLowerCase() === typed.slug),\n typed.text\n )\n },\n [open, skills, commands]\n )\n\n // Mounted only while a workflow is open: the ask bar lives in every page's topbar, so the\n // launcher's data hooks (files, agents, tasks) must not run until it is needed.\n const launcher = useMemo(() => {\n if (active === null) return null\n const initialInputsFor = (\n workflow: WorkflowDefinition\n ): Partial<WorkflowInputs> | undefined => {\n const field = promptFieldName(workflow)\n return field && active.text ? { [field]: active.text } : undefined\n }\n return (\n <ConnectedWorkflowStart\n workflows={skills}\n showTiles={false}\n landing={landing}\n send={send}\n activeId={active.id}\n onActiveIdChange={(id) => id === null && setActive(null)}\n initialInputsFor={initialInputsFor}\n />\n )\n }, [active, skills, landing, send])\n\n return { openFor, openForDraft, openSkill, openable, launcher }\n}\n","/**\n * The slash menu's data, in one place for every surface that hosts it (the chat composers, the\n * workspace ask bar, the document ask and `ChatPage`): the backend's built-in commands, the host's\n * skill packs and the user's skills, filtered by the slash token in progress. Commands and the\n * user's skills are typed `/<slug>` and dispatched by the backend; a skill opens its form\n * (`useSlashSkillWorkflows`).\n */\n\nimport { useMemo } from 'react'\nimport { useBuiltinCommands } from '@arbidocs/react'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { buildSlashItems, filterSlashItems, parseSlashToken } from '../../chat/slash-menu-helpers'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\nimport { useCanBrowseSkills, useSkillsEnabled } from '../workflows/useSkillsEnabled'\nimport { hostSkillItem, useHostSkills } from '../workflows/useHostSkills'\nimport { useUsableSkillListings } from '../workflows/useWorkflowDefinitions'\nimport { useNamedWorkflows } from '../workflows/useNamedWorkflows'\n\nconst NO_SKILLS: ReadonlyArray<WorkflowDefinition> = []\n\n/**\n * Every row of the menu, unfiltered: commands, then the host's packs (always: the host offers\n * them), then, for skills users (`show_skills`), the built-in skills and the user's own.\n *\n * @param builtinSkills The built-in skills to offer (prompt workflows offered as `/slug`), for a\n * surface that can open their form; default none.\n */\nexport function useSlashMenuItems(builtinSkills: ReadonlyArray<WorkflowDefinition> = NO_SKILLS): {\n items: SlashMenuItem[]\n /** The menu's \"Browse all\" footer opens the Skills browser: skills users, never guests. */\n canBrowseSkills: boolean\n} {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const skillsEnabled = useSkillsEnabled()\n const { commands } = useBuiltinCommands()\n const builtins = useNamedWorkflows(builtinSkills)\n const items = useMemo<SlashMenuItem[]>(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n return buildSlashItems(\n commands.map((c) => ({\n name: c.name,\n description: c.description,\n argHint: c.arg_hint,\n kind: 'command' as const,\n })),\n [\n ...hostSkills.map(hostSkillItem),\n ...(skillsEnabled\n ? skillItems(\n builtins.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n : []),\n ]\n )\n }, [commands, hostSkills, listings, skillsEnabled, builtins])\n return { items, canBrowseSkills: useCanBrowseSkills() }\n}\n\n/**\n * @param text The draft.\n * @param builtinSkills The built-in skills (prompt workflows offered as `/slug`).\n */\nexport function useSlashItems(\n text: string,\n builtinSkills: ReadonlyArray<WorkflowDefinition> = NO_SKILLS\n) {\n const { items, canBrowseSkills } = useSlashMenuItems(builtinSkills)\n const slashToken = parseSlashToken(text)\n const filteredItems = useMemo(\n () => (slashToken !== null ? filterSlashItems(items, slashToken) : []),\n [items, slashToken]\n )\n return {\n slashToken,\n filteredItems,\n isOpen: slashToken !== null && filteredItems.length > 0,\n canBrowseSkills,\n }\n}\n\ntype SkillListings = ReturnType<typeof useUsableSkillListings>\n\n/**\n * Built-in skills share the list and the `/slug` path; a same-slug skill of the user's own shadows\n * the built-in, as on the backend.\n */\nfunction skillItems(\n builtinSkills: ReadonlyArray<WorkflowDefinition>,\n listings: SkillListings\n): SlashMenuItem[] {\n const { host, skills } = mergeSkillWorkflows([...builtinSkills], listings)\n const listing = new Map(listings.map((s) => [s.slug, s]))\n return [\n ...host.map((w): SlashMenuItem => ({\n name: w.id,\n description: w.description,\n argHint: w.inputs[0]?.label ?? '',\n visibility: 'global',\n kind: 'skill',\n })),\n ...skills.map((w): SlashMenuItem => {\n const s = listing.get(w.id)\n return {\n name: w.id,\n description: s?.description || (w.title !== w.id ? w.title : ''),\n argHint: s?.arg_hint ?? '',\n visibility: s?.visibility === 'global' ? 'global' : 'mine',\n kind: 'skill',\n }\n }),\n ]\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/workflows/useSlashSkillWorkflows.tsx","../src/connection/conversation/useSlashItems.ts"],"names":["isSkillPackWorkflow","useWorkflowDefinitions","useBuiltinCommands","useState","useCallback","useMemo","promptFieldName","jsx","ConnectedWorkflowStart","useHostSkills","useUsableSkillListings","useSkillsEnabled","useNamedWorkflows","buildSlashItems","hostSkillItem","useCanBrowseSkills","parseSlashTokenInProgress","filterSlashItems","mergeSkillWorkflows"],"mappings":";;;;;;;;;;;AAiCA,IAAM,WAAA,GAAc,qDAAA;AAGb,SAAS,gBAAgB,KAAA,EAAsD;AACpF,EAAA,MAAM,CAAA,GAAI,WAAA,CAAY,IAAA,CAAK,KAAK,CAAA;AAChC,EAAA,OAAO,CAAA,GAAI,EAAE,IAAA,EAAM,CAAA,CAAE,CAAC,CAAA,CAAE,WAAA,EAAY,EAAG,IAAA,EAAA,CAAO,EAAE,CAAC,CAAA,IAAK,EAAA,EAAI,IAAA,IAAO,GAAI,IAAA;AACvE;AAMO,SAAS,YAAA,CAAa,UAA8B,aAAA,EAAiC;AAC1F,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CAAA,KAAqB;AAClC,MAAA,MAAM,CAAA,GAAI,OAAA,CAAQ,GAAA,CAAI,CAAA,CAAE,EAAE,CAAA;AAC1B,MAAA,OAAO;AAAA,QACL,MAAM,CAAA,CAAE,EAAA;AAAA,QACR,WAAA,EAAa,GAAG,WAAA,KAAgB,CAAA,CAAE,UAAU,CAAA,CAAE,EAAA,GAAK,EAAE,KAAA,GAAQ,EAAA,CAAA;AAAA,QAC7D,OAAA,EAAS,GAAG,QAAA,IAAY,EAAA;AAAA,QACxB,UAAA,EAAY,CAAA,EAAG,UAAA,KAAe,QAAA,GAAW,QAAA,GAAW,MAAA;AAAA,QACpD,IAAA,EAAM;AAAA,OACR;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"chunk-7GVKG3G4.cjs","sourcesContent":["/**\n * Slash skills are launched prompt-first, through the one workflow launcher.\n *\n * A skill (or a prompt-style built-in such as Deep research) is run WITH a prompt, so it never\n * just executes:\n * - picking it in the slash menu opens its form (the prompt field first, focused, required);\n * - typing `/slug` and pressing Enter opens the same form with the field empty;\n * - typing `/slug some text` and pressing Enter opens it with the text already in the field.\n * The rule is the same for any recognised skill slug as the FIRST token of the draft; a backend\n * command (`/goal`, `/compact`, ...) is never a skill and is sent as typed. Nothing is sent from\n * the composer until the user starts it in the form. Without skills enabled (`show_skills`) this\n * applies to the host's skill packs only (`host.workflows.skillPacks`): the menu lists no other\n * skills and any other `/text` is sent as typed.\n *\n * The run lands where the surface says (`landing`), through the one launch handler. A chat that\n * is not the session's conversation (`ChatPage`, the document ask) passes `send`: the composed\n * prompt then goes to its own send, as a typed message would.\n */\n\nimport { useCallback, useMemo, useState, type ReactNode } from 'react'\nimport { promptFieldName } from '../../agents/workflows/workflow'\nimport { isSkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport { type SlashMenuItem } from '../../chat/SlashMenu'\nimport {\n type WorkflowDefinition,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { useBuiltinCommands } from '@arbidocs/react'\nimport { ConnectedWorkflowStart } from './ConnectedWorkflowStart'\nimport { useWorkflowDefinitions } from './useWorkflowDefinitions'\n\n/** `/slug` or `/slug rest of the line`: the first token and the text after it. */\nconst TYPED_SKILL = /^\\s*\\/([a-zA-Z0-9][a-zA-Z0-9_-]*)(?:\\s+([\\s\\S]*))?$/\n\n/** What the typed draft names: its slug (lower-cased) and the text after it (trimmed). */\nexport function parseTypedSkill(draft: string): { slug: string; text: string } | null {\n const m = TYPED_SKILL.exec(draft)\n return m ? { slug: m[1].toLowerCase(), text: (m[2] ?? '').trim() } : null\n}\n\n/**\n * Whether a skill opens its form from a menu (the `/` menus, the command palette): a prompt skill,\n * and with skills switched off (`show_skills`) only the host's packs. The one gate both share.\n */\nexport function canOpenSkill(workflow: WorkflowDefinition, skillsEnabled: boolean): boolean {\n return workflow.run.kind === 'prompt' && (skillsEnabled || isSkillPackWorkflow(workflow))\n}\n\nexport interface UseSlashSkillWorkflowsOptions {\n landing: WorkflowLanding\n /** Where the composed prompt goes, for a chat that is not the session's conversation. */\n send?: (prompt: string) => void\n}\n\nexport function useSlashSkillWorkflows({ landing, send }: UseSlashSkillWorkflowsOptions): {\n /** Opens the launcher for a picked menu item. True when it did (the caller then clears the draft). */\n openFor: (item: SlashMenuItem) => boolean\n /**\n * Opens the launcher for a typed `/slug text` draft, text pre-filled. True when the draft names\n * a skill (the caller then clears the draft and sends nothing).\n */\n openForDraft: (draft: string) => boolean\n /**\n * Opens the launcher for a skill by id (a surface listing the skills itself, the command\n * palette). True when it is a skill this person may run here.\n */\n openSkill: (id: string) => boolean\n /** The skills this person may open here: the host's packs, and the rest with `show_skills`. */\n openable: WorkflowDefinition[]\n /** Render once, anywhere in the surface that hosts the slash menu. */\n launcher: ReactNode\n} {\n const { skills, skillsEnabled } = useWorkflowDefinitions()\n const { commands } = useBuiltinCommands()\n const [active, setActive] = useState<{ id: string; text: string } | null>(null)\n\n // Stable while the lists are, so a surface can memoise what it builds on them.\n const open = useCallback(\n (workflow: WorkflowDefinition | undefined, text: string): boolean => {\n if (!workflow || !canOpenSkill(workflow, skillsEnabled)) return false\n setActive({ id: workflow.id, text })\n return true\n },\n [skillsEnabled]\n )\n\n const openFor = useCallback(\n (item: SlashMenuItem): boolean =>\n item.kind === 'skill' &&\n open(\n skills.find((w) => w.id === item.name),\n ''\n ),\n [open, skills]\n )\n\n const openSkill = useCallback(\n (id: string): boolean =>\n open(\n skills.find((w) => w.id === id),\n ''\n ),\n [open, skills]\n )\n\n const openable = useMemo(\n () => skills.filter((w) => canOpenSkill(w, skillsEnabled)),\n [skills, skillsEnabled]\n )\n\n const openForDraft = useCallback(\n (draft: string): boolean => {\n const typed = parseTypedSkill(draft)\n if (!typed) return false\n // A backend command wins a name collision, as in the menu: it is sent as typed.\n if (commands.some((c) => c.name.toLowerCase() === typed.slug)) return false\n return open(\n skills.find((w) => w.id.toLowerCase() === typed.slug),\n typed.text\n )\n },\n [open, skills, commands]\n )\n\n // Mounted only while a workflow is open: the ask bar lives in every page's topbar, so the\n // launcher's data hooks (files, agents, tasks) must not run until it is needed.\n const launcher = useMemo(() => {\n if (active === null) return null\n const initialInputsFor = (\n workflow: WorkflowDefinition\n ): Partial<WorkflowInputs> | undefined => {\n const field = promptFieldName(workflow)\n return field && active.text ? { [field]: active.text } : undefined\n }\n return (\n <ConnectedWorkflowStart\n workflows={skills}\n showTiles={false}\n landing={landing}\n send={send}\n activeId={active.id}\n onActiveIdChange={(id) => id === null && setActive(null)}\n initialInputsFor={initialInputsFor}\n />\n )\n }, [active, skills, landing, send])\n\n return { openFor, openForDraft, openSkill, openable, launcher }\n}\n","/**\n * The slash menu's data, in one place for every surface that hosts it (the chat composers, the\n * workspace ask bar, the document ask and `ChatPage`): the backend's built-in commands, the host's\n * skill packs and the user's skills, filtered by the slash token in progress. Commands and the\n * user's skills are typed `/<slug>` and dispatched by the backend; a skill opens its form\n * (`useSlashSkillWorkflows`).\n */\n\nimport { useMemo } from 'react'\nimport { useBuiltinCommands } from '@arbidocs/react'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { buildSlashItems, filterSlashItems, parseSlashToken } from '../../chat/slash-menu-helpers'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\nimport { useCanBrowseSkills, useSkillsEnabled } from '../workflows/useSkillsEnabled'\nimport { hostSkillItem, useHostSkills } from '../workflows/useHostSkills'\nimport { useUsableSkillListings } from '../workflows/useWorkflowDefinitions'\nimport { useNamedWorkflows } from '../workflows/useNamedWorkflows'\n\nconst NO_SKILLS: ReadonlyArray<WorkflowDefinition> = []\n\n/**\n * Every row of the menu, unfiltered: commands, then the host's packs (always: the host offers\n * them), then, for skills users (`show_skills`), the built-in skills and the user's own.\n *\n * @param builtinSkills The built-in skills to offer (prompt workflows offered as `/slug`), for a\n * surface that can open their form; default none.\n */\nexport function useSlashMenuItems(builtinSkills: ReadonlyArray<WorkflowDefinition> = NO_SKILLS): {\n items: SlashMenuItem[]\n /** The menu's \"Browse all\" footer opens the Skills browser: skills users, never guests. */\n canBrowseSkills: boolean\n} {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const skillsEnabled = useSkillsEnabled()\n const { commands } = useBuiltinCommands()\n const builtins = useNamedWorkflows(builtinSkills)\n const items = useMemo<SlashMenuItem[]>(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n return buildSlashItems(\n commands.map((c) => ({\n name: c.name,\n description: c.description,\n argHint: c.arg_hint,\n kind: 'command' as const,\n })),\n [\n ...hostSkills.map(hostSkillItem),\n ...(skillsEnabled\n ? skillItems(\n builtins.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n : []),\n ]\n )\n }, [commands, hostSkills, listings, skillsEnabled, builtins])\n return { items, canBrowseSkills: useCanBrowseSkills() }\n}\n\n/**\n * @param text The draft.\n * @param builtinSkills The built-in skills (prompt workflows offered as `/slug`).\n */\nexport function useSlashItems(\n text: string,\n builtinSkills: ReadonlyArray<WorkflowDefinition> = NO_SKILLS\n) {\n const { items, canBrowseSkills } = useSlashMenuItems(builtinSkills)\n const slashToken = parseSlashToken(text)\n const filteredItems = useMemo(\n () => (slashToken !== null ? filterSlashItems(items, slashToken) : []),\n [items, slashToken]\n )\n return {\n slashToken,\n filteredItems,\n isOpen: slashToken !== null && filteredItems.length > 0,\n canBrowseSkills,\n }\n}\n\ntype SkillListings = ReturnType<typeof useUsableSkillListings>\n\n/**\n * Built-in skills share the list and the `/slug` path; a same-slug skill of the user's own shadows\n * the built-in, as on the backend.\n */\nfunction skillItems(\n builtinSkills: ReadonlyArray<WorkflowDefinition>,\n listings: SkillListings\n): SlashMenuItem[] {\n const { host, skills } = mergeSkillWorkflows([...builtinSkills], listings)\n const listing = new Map(listings.map((s) => [s.slug, s]))\n return [\n ...host.map((w): SlashMenuItem => ({\n name: w.id,\n description: w.description,\n argHint: w.inputs[0]?.label ?? '',\n visibility: 'global',\n kind: 'skill',\n })),\n ...skills.map((w): SlashMenuItem => {\n const s = listing.get(w.id)\n return {\n name: w.id,\n description: s?.description || (w.title !== w.id ? w.title : ''),\n argHint: s?.arg_hint ?? '',\n visibility: s?.visibility === 'global' ? 'global' : 'mine',\n kind: 'skill',\n }\n }),\n ]\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk4H5DPHZ2_cjs = require('./chunk-4H5DPHZ2.cjs');
|
|
5
5
|
var chunkY3GJBLAI_cjs = require('./chunk-Y3GJBLAI.cjs');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ function useWorkflowPreview(workflow, { answer = "{prompt}", delayMs = 400, reso
|
|
|
45
45
|
}, delayMs)
|
|
46
46
|
);
|
|
47
47
|
}, [states, steps, workflow]);
|
|
48
|
-
return
|
|
48
|
+
return chunk4H5DPHZ2_cjs.useWorkflowView({
|
|
49
49
|
steps,
|
|
50
50
|
states,
|
|
51
51
|
inputs,
|
|
@@ -58,5 +58,5 @@ function useWorkflowPreview(workflow, { answer = "{prompt}", delayMs = 400, reso
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
exports.useWorkflowPreview = useWorkflowPreview;
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-A4HOEGDI.cjs.map
|
|
62
|
+
//# sourceMappingURL=chunk-A4HOEGDI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agents/workflows/useWorkflowPreview.ts"],"names":["workflowSteps","useState","initialRunInputs","useRef","useEffect","stepPhase","composeStepPrompt","useWorkflowView"],"mappings":";;;;;;AAwBO,SAAS,kBAAA,CACd,QAAA,EACA,EAAE,MAAA,GAAS,UAAA,EAAY,OAAA,GAAU,GAAA,EAAK,eAAA,EAAiB,OAAA,EAAQ,GAA+B,EAAC,EAC9E;AACjB,EAAA,MAAM,KAAA,GAAQA,gCAAc,QAAQ,CAAA;AACpC,EAAA,MAAM,CAAC,QAAQ,SAAS,CAAA,GAAIC,eAAyB,MAAMC,kCAAA,CAAiB,QAAQ,CAAC,CAAA;AACrF,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAID,cAAA,CAA4C,EAAE,CAAA;AAC1E,EAAA,MAAM,GAAA,GAAM,CAAC,EAAA,EAAY,KAAA,KAA6B,UAAU,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,EAAE,GAAG,OAAM,CAAE,CAAA;AAI9F,EAAA,MAAM,MAAA,GAASE,YAAA,iBAAO,IAAI,GAAA,EAA4C,CAAA;AACtE,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,MAAA,CAAO,OAAA;AACvB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,OAAA,CAAQ,MAA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A;AAAA,MACb,IAAA,CAAK,EAAA;AAAA,MACL,WAAW,MAAM;AACf,QAAA,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,IAAA,CAAK,EAAE,CAAA;AAC7B,QAAA,GAAA;AAAA,UACE,IAAA,CAAK,EAAA;AAAA,UACL,IAAA,CAAK,IAAA,KAAS,OAAA,GACV,EAAE,QAAQ,MAAA,EAAQ,IAAA,EAAM,MAAA,CAAO,OAAA,CAAQ,YAAY,MAAM,CAAA,EAAE,GAC3D,EAAE,QAAQ,MAAA;AAAO,SACvB;AAAA,MACF,GAAG,OAAO;AAAA,KACZ;AAAA,EAGF,CAAA,EAAG,CAAC,MAAA,EAAQ,KAAA,EAAO,QAAQ,CAAC,CAAA;AAE5B,EAAA,OAAOC,iCAAA,CAAgB;AAAA,IACrB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,IAAA,EAAM,KAAA,KAAU,UAAU,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,IAAI,GAAG,OAAM,CAAE,CAAA;AAAA,IACrE,QAAA,EAAU,OAAO,IAAA,KAAS,GAAA,CAAI,KAAK,EAAA,EAAI,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACzD,IAAA,EAAM,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IACjD,KAAA,EAAO,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IAClD,UAAU,CAAC,EAAA,KAAO,MAAA,CAAO,EAAE,GAAG,MAAA,KAAW;AAAA,GAC1C,CAAA;AACH","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/agents/workflows/useWorkflowPreview.ts"],"names":["workflowSteps","useState","initialRunInputs","useRef","useEffect","stepPhase","composeStepPrompt","useWorkflowView"],"mappings":";;;;;;AAwBO,SAAS,kBAAA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,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,IAAA,EAAM,KAAA,KAAU,UAAU,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,IAAI,GAAG,OAAM,CAAE,CAAA;AAAA,IACrE,QAAA,EAAU,OAAO,IAAA,KAAS,GAAA,CAAI,KAAK,EAAA,EAAI,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACzD,IAAA,EAAM,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IACjD,KAAA,EAAO,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IAClD,UAAU,CAAC,EAAA,KAAO,MAAA,CAAO,EAAE,GAAG,MAAA,KAAW;AAAA,GAC1C,CAAA;AACH","file":"chunk-A4HOEGDI.cjs","sourcesContent":["/**\n * A stepped workflow run on screen only (the builder's preview): agent steps run one at a time,\n * the way the server does, and answer with the prompt they would send; action steps just finish.\n * No thread, no agent.\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport {\n composeStepPrompt,\n initialRunInputs,\n stepPhase,\n workflowSteps,\n type StepComposeOptions,\n} from './run'\nimport type { WorkflowDefinition, WorkflowInputs, WorkflowStepState } from './types'\nimport { useWorkflowView, type WorkflowRunView } from './useWorkflowView'\n\nexport interface UseWorkflowPreviewOptions extends StepComposeOptions {\n /** What a stand-in agent step answers; `{prompt}` is replaced with the prompt it would send. */\n answer?: string\n /** How long a stand-in step takes. */\n delayMs?: number\n}\n\nexport function useWorkflowPreview(\n workflow: WorkflowDefinition,\n { answer = '{prompt}', delayMs = 400, resolveWorkflow, compose }: UseWorkflowPreviewOptions = {}\n): WorkflowRunView {\n const steps = workflowSteps(workflow)\n const [inputs, setInputs] = useState<WorkflowInputs>(() => initialRunInputs(workflow))\n const [states, setStates] = useState<Record<string, WorkflowStepState>>({})\n const set = (id: string, state: WorkflowStepState) => setStates((s) => ({ ...s, [id]: state }))\n\n // A stand-in step's timer outlives the re-render its start causes; it is cleared on unmount, and\n // a step it cut short starts again (StrictMode mounts twice).\n const timers = useRef(new Map<string, ReturnType<typeof setTimeout>>())\n useEffect(() => {\n const pending = timers.current\n return () => {\n for (const t of pending.values()) clearTimeout(t)\n pending.clear()\n setStates((s) =>\n Object.fromEntries(\n Object.entries(s).map(([id, v]) => [\n id,\n v.status === 'running' ? { status: 'pending' } : v,\n ])\n )\n )\n }\n }, [])\n\n // One turn at a time: start the first ready agent step when nothing is running.\n useEffect(() => {\n if (Object.values(states).some((s) => s.status === 'running')) return\n // An action step (a signature, an email, a review) stands in the same way, with no answer.\n const next = steps.find(\n (s) =>\n (s.kind === 'agent' || s.kind === 'action') && stepPhase(steps, states, s.id) === 'ready'\n )\n if (!next || (next.kind !== 'agent' && next.kind !== 'action')) return\n const prompt =\n next.kind === 'agent'\n ? composeStepPrompt(workflow, next, inputs, { resolveWorkflow, compose })\n : ''\n set(next.id, { status: 'running', startedAt: new Date().toISOString() })\n timers.current.set(\n next.id,\n setTimeout(() => {\n timers.current.delete(next.id)\n set(\n next.id,\n next.kind === 'agent'\n ? { status: 'done', text: answer.replace('{prompt}', prompt) }\n : { status: 'done' }\n )\n }, delayMs)\n )\n // `inputs` are read when a step starts, not watched.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [states, steps, workflow])\n\n return useWorkflowView({\n steps,\n states,\n inputs,\n setInput: (name, value) => setInputs((i) => ({ ...i, [name]: value })),\n complete: async (step) => set(step.id, { status: 'done' }),\n skip: async (id) => set(id, { status: 'skipped' }),\n retry: async (id) => set(id, { status: 'pending' }),\n isLocked: (id) => states[id]?.status === 'done',\n })\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
|
|
5
|
-
var chunk3P6KGC46_cjs = require('./chunk-3P6KGC46.cjs');
|
|
6
4
|
var chunkE23H6FJR_cjs = require('./chunk-E23H6FJR.cjs');
|
|
5
|
+
var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
|
|
7
6
|
var chunk75BNMCUX_cjs = require('./chunk-75BNMCUX.cjs');
|
|
7
|
+
var chunk5OD6DRG7_cjs = require('./chunk-5OD6DRG7.cjs');
|
|
8
8
|
var chunkPIKTGP55_cjs = require('./chunk-PIKTGP55.cjs');
|
|
9
9
|
var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.cjs');
|
|
10
10
|
var React = require('react');
|
|
@@ -30,7 +30,7 @@ function DocumentReferenceView({
|
|
|
30
30
|
className = "inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted"
|
|
31
31
|
}) {
|
|
32
32
|
const { openDocument, hrefFor: hrefFor2 } = chunkHN56WWBR_cjs.useBlocksEnvironment();
|
|
33
|
-
const link = hrefFor2({ kind: "document", documentId: docId, workspaceId }) ??
|
|
33
|
+
const link = hrefFor2({ kind: "document", documentId: docId, workspaceId }) ?? chunk5OD6DRG7_cjs.hrefFor({ kind: "document", documentId: docId, workspaceId }) ?? copyHref;
|
|
34
34
|
const open = () => workspaceId ? openDocument(docId, { workspaceId }) : openDocument(docId);
|
|
35
35
|
if (!children || typeof children === "string")
|
|
36
36
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -297,7 +297,7 @@ function EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }
|
|
|
297
297
|
const prefix = id.split("-")[0];
|
|
298
298
|
const [kind, Icon] = kinds[prefix] ?? ["Entity", lucideReact.Folder];
|
|
299
299
|
const global = ["evt", "call", "cal", "usr", "agt", "prj", "cht"].includes(prefix);
|
|
300
|
-
const target = prefix === "con" ?
|
|
300
|
+
const target = prefix === "con" ? chunk5OD6DRG7_cjs.hrefFor({ kind: "conversation", conversationId: id, workspaceId }) : prefix === "evt" ? chunk5OD6DRG7_cjs.hrefFor({ kind: "calendar", eventId: id }) : prefix === "call" ? chunk5OD6DRG7_cjs.hrefFor({ kind: "call", callId: id }) : prefix === "wrk" ? chunk5OD6DRG7_cjs.hrefFor({ kind: "workspace", workspaceId: id }) : chunk5OD6DRG7_cjs.hrefFor({
|
|
301
301
|
kind: "entity",
|
|
302
302
|
entityId: id,
|
|
303
303
|
workspaceId: global ? void 0 : workspaceId
|
|
@@ -305,7 +305,7 @@ function EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }
|
|
|
305
305
|
const link = href ?? target;
|
|
306
306
|
const open = () => {
|
|
307
307
|
if (prefix === "con") {
|
|
308
|
-
const route = href ?
|
|
308
|
+
const route = href ? chunk5OD6DRG7_cjs.parseHref(href) : null;
|
|
309
309
|
env.openConversation(id, {
|
|
310
310
|
workspaceId: workspaceId ?? void 0,
|
|
311
311
|
messageId: route?.kind === "conversation" ? route.messageId : void 0
|
|
@@ -378,7 +378,7 @@ function InternalDocLink({
|
|
|
378
378
|
const { runtimeConfig } = chunkHN56WWBR_cjs.useBlocksEnvironment();
|
|
379
379
|
const conversationWorkspace = useDocumentWorkspace();
|
|
380
380
|
const selectedWorkspace = react.useArbiSessionState((s) => s.workspaceId);
|
|
381
|
-
const route = href && chunkE23H6FJR_cjs.workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId ?
|
|
381
|
+
const route = href && chunkE23H6FJR_cjs.workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId ? chunk5OD6DRG7_cjs.parseHref(href) : null;
|
|
382
382
|
const workspaceId = (route?.kind === "document" ? route.workspaceId : null) ?? conversationWorkspace ?? selectedWorkspace;
|
|
383
383
|
const text = plainLinkText(children)?.trim();
|
|
384
384
|
const isAddress = !text || text === href || text === docId;
|
|
@@ -451,7 +451,7 @@ var conversationMarkdownComponents = {
|
|
|
451
451
|
if (docId) {
|
|
452
452
|
return /* @__PURE__ */ jsxRuntime.jsx(InternalDocLink, { docId, href, ...props, children });
|
|
453
453
|
}
|
|
454
|
-
const route =
|
|
454
|
+
const route = chunk5OD6DRG7_cjs.parseHref(href);
|
|
455
455
|
const reference = route?.kind === "entity" ? route.entityId : route?.kind === "conversation" ? route.conversationId : route?.kind === "workspace" ? route.workspaceId : route?.kind === "call" ? route.callId : route?.kind === "calendar" ? route.eventId : void 0;
|
|
456
456
|
if (reference && !reference.startsWith("doc-")) {
|
|
457
457
|
const url = new URL(href, window.location.href);
|
|
@@ -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","reh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ACA,IAAA,uBAAOA,cAAAA,CAAC4C,eAAA,EAAA,EAAc,GAAG,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-LSFGSQHS.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":";;;;;;;;;;;;;;;;;;;;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,yBAA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AAQ,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"]}
|