@arbidocs/blocks 0.5.121 → 0.5.122
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/{ClippingMediaViewer-B6WG7Q64.cjs → ClippingMediaViewer-IEIBT74X.cjs} +8 -8
- package/dist/{ClippingMediaViewer-B6WG7Q64.cjs.map → ClippingMediaViewer-IEIBT74X.cjs.map} +1 -1
- package/dist/{ClippingPdfViewer-6GCVTV3V.cjs → ClippingPdfViewer-OGYLMVCE.cjs} +5 -5
- package/dist/{ClippingPdfViewer-6GCVTV3V.cjs.map → ClippingPdfViewer-OGYLMVCE.cjs.map} +1 -1
- package/dist/{ConnectedCallDock-DC5V5OUJ.cjs → ConnectedCallDock-XJOYVVAH.cjs} +21 -21
- package/dist/{ConnectedCallDock-DC5V5OUJ.cjs.map → ConnectedCallDock-XJOYVVAH.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-FQLXWTFB.cjs → ConnectedCallRoom-CUDYAPQK.cjs} +14 -14
- package/dist/{ConnectedCallRoom-FQLXWTFB.cjs.map → ConnectedCallRoom-CUDYAPQK.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-4Q5S7VLD.cjs → ConnectedNativeDocxComparison-QKHCYD6W.cjs} +16 -16
- package/dist/{ConnectedNativeDocxComparison-4Q5S7VLD.cjs.map → ConnectedNativeDocxComparison-QKHCYD6W.cjs.map} +1 -1
- package/dist/ConnectedPresentation-AU25OW25.cjs +321 -0
- package/dist/ConnectedPresentation-AU25OW25.cjs.map +1 -0
- package/dist/{ConnectedProductionSetDialog-4EAY6KAZ.cjs → ConnectedProductionSetDialog-LHB4VQWC.cjs} +3 -3
- package/dist/{ConnectedProductionSetDialog-4EAY6KAZ.cjs.map → ConnectedProductionSetDialog-LHB4VQWC.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-7QDE2CZD.cjs → ConnectedSlidesTab-I75LKKN7.cjs} +40 -38
- package/dist/ConnectedSlidesTab-I75LKKN7.cjs.map +1 -0
- package/dist/{ConnectedStreamedWordArtifact-FFOQJBOI.cjs → ConnectedStreamedWordArtifact-AG62232A.cjs} +16 -16
- package/dist/{ConnectedStreamedWordArtifact-FFOQJBOI.cjs.map → ConnectedStreamedWordArtifact-AG62232A.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-SNWVEZ7S.cjs → DocumentReviewCard-M53XFLI2.cjs} +15 -15
- package/dist/{DocumentReviewCard-SNWVEZ7S.cjs.map → DocumentReviewCard-M53XFLI2.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-IZI63FOV.cjs → FilesViewerDialog-4352KIOG.cjs} +50 -49
- package/dist/FilesViewerDialog-4352KIOG.cjs.map +1 -0
- package/dist/{WorkspaceTableView-TEIRB6VJ.cjs → WorkspaceTableView-3XYAV4BV.cjs} +8 -8
- package/dist/{WorkspaceTableView-TEIRB6VJ.cjs.map → WorkspaceTableView-3XYAV4BV.cjs.map} +1 -1
- package/dist/agents/index.cjs +297 -297
- package/dist/{ai-KBYNRNZ6.cjs → ai-IEIR7SC2.cjs} +25 -25
- package/dist/ai-IEIR7SC2.cjs.map +1 -0
- package/dist/calls/index.cjs +121 -121
- package/dist/chat/index.cjs +1 -1
- package/dist/{chunk-NLOETJCB.cjs → chunk-2F57IO7S.cjs} +12 -12
- package/dist/{chunk-NLOETJCB.cjs.map → chunk-2F57IO7S.cjs.map} +1 -1
- package/dist/chunk-2RLA6QO2.cjs +174 -0
- package/dist/chunk-2RLA6QO2.cjs.map +1 -0
- package/dist/{chunk-Q6DQGGP4.cjs → chunk-325GVZE6.cjs} +3 -3
- package/dist/{chunk-Q6DQGGP4.cjs.map → chunk-325GVZE6.cjs.map} +1 -1
- package/dist/{chunk-XTR26TNE.cjs → chunk-4TTX6ZNS.cjs} +20 -4
- package/dist/chunk-4TTX6ZNS.cjs.map +1 -0
- package/dist/{chunk-BVAT4EVC.cjs → chunk-5QERK4PK.cjs} +35 -35
- package/dist/{chunk-BVAT4EVC.cjs.map → chunk-5QERK4PK.cjs.map} +1 -1
- package/dist/{chunk-GX2EBMJW.cjs → chunk-6OK7ESTL.cjs} +7 -6
- package/dist/chunk-6OK7ESTL.cjs.map +1 -0
- package/dist/{chunk-C2OICDMI.cjs → chunk-7557LDAN.cjs} +10 -10
- package/dist/{chunk-C2OICDMI.cjs.map → chunk-7557LDAN.cjs.map} +1 -1
- package/dist/{chunk-474GPLCM.cjs → chunk-7L4X6QN2.cjs} +6 -6
- package/dist/{chunk-474GPLCM.cjs.map → chunk-7L4X6QN2.cjs.map} +1 -1
- package/dist/{chunk-52KGMAO5.cjs → chunk-7NLO7ASW.cjs} +15 -15
- package/dist/{chunk-52KGMAO5.cjs.map → chunk-7NLO7ASW.cjs.map} +1 -1
- package/dist/{chunk-H5OLHP2U.cjs → chunk-7OPOPYV6.cjs} +3 -3
- package/dist/{chunk-H5OLHP2U.cjs.map → chunk-7OPOPYV6.cjs.map} +1 -1
- package/dist/{chunk-W6B3RYTX.cjs → chunk-7PN3YENO.cjs} +4 -4
- package/dist/{chunk-W6B3RYTX.cjs.map → chunk-7PN3YENO.cjs.map} +1 -1
- package/dist/{chunk-734NPQNR.cjs → chunk-ADDQKZ5I.cjs} +4 -4
- package/dist/{chunk-734NPQNR.cjs.map → chunk-ADDQKZ5I.cjs.map} +1 -1
- package/dist/{chunk-JQLWKNJO.cjs → chunk-ALK3PUUB.cjs} +4 -4
- package/dist/{chunk-JQLWKNJO.cjs.map → chunk-ALK3PUUB.cjs.map} +1 -1
- package/dist/{chunk-4VZZWYEC.cjs → chunk-BQ5RIWWT.cjs} +3 -3
- package/dist/{chunk-4VZZWYEC.cjs.map → chunk-BQ5RIWWT.cjs.map} +1 -1
- package/dist/{chunk-ENGL7P3I.cjs → chunk-CQQQIZU4.cjs} +27 -27
- package/dist/{chunk-ENGL7P3I.cjs.map → chunk-CQQQIZU4.cjs.map} +1 -1
- package/dist/{chunk-3SCNXNHI.cjs → chunk-E3L5DB5F.cjs} +5 -5
- package/dist/{chunk-3SCNXNHI.cjs.map → chunk-E3L5DB5F.cjs.map} +1 -1
- package/dist/{chunk-VJ5ZLRBD.cjs → chunk-GFUOCGY6.cjs} +8 -3
- package/dist/chunk-GFUOCGY6.cjs.map +1 -0
- package/dist/{chunk-RYVZDFVO.cjs → chunk-JJZOL5MG.cjs} +3 -3
- package/dist/{chunk-RYVZDFVO.cjs.map → chunk-JJZOL5MG.cjs.map} +1 -1
- package/dist/{chunk-QFXILJMJ.cjs → chunk-K4763GD5.cjs} +17 -174
- package/dist/chunk-K4763GD5.cjs.map +1 -0
- package/dist/{chunk-EHP6OH5D.cjs → chunk-KA3F6TIH.cjs} +11 -11
- package/dist/{chunk-EHP6OH5D.cjs.map → chunk-KA3F6TIH.cjs.map} +1 -1
- package/dist/{chunk-UUENH4BJ.cjs → chunk-KXIRVKCJ.cjs} +3 -3
- package/dist/{chunk-UUENH4BJ.cjs.map → chunk-KXIRVKCJ.cjs.map} +1 -1
- package/dist/{chunk-4RBQ44RY.cjs → chunk-MLA2BJ2Y.cjs} +28 -28
- package/dist/{chunk-4RBQ44RY.cjs.map → chunk-MLA2BJ2Y.cjs.map} +1 -1
- package/dist/{chunk-DR2AH7JL.cjs → chunk-NG2EE7HR.cjs} +48 -48
- package/dist/{chunk-DR2AH7JL.cjs.map → chunk-NG2EE7HR.cjs.map} +1 -1
- package/dist/{chunk-4NPCDS2X.cjs → chunk-NY3YUCOW.cjs} +3 -3
- package/dist/{chunk-4NPCDS2X.cjs.map → chunk-NY3YUCOW.cjs.map} +1 -1
- package/dist/{chunk-JZEYHDWJ.cjs → chunk-OHHKBURG.cjs} +76 -76
- package/dist/chunk-OHHKBURG.cjs.map +1 -0
- package/dist/{chunk-AY6EZSZB.cjs → chunk-QG2U2JGX.cjs} +4 -4
- package/dist/{chunk-AY6EZSZB.cjs.map → chunk-QG2U2JGX.cjs.map} +1 -1
- package/dist/{chunk-5534FYXP.cjs → chunk-SDRYSLOX.cjs} +4 -4
- package/dist/{chunk-5534FYXP.cjs.map → chunk-SDRYSLOX.cjs.map} +1 -1
- package/dist/{chunk-2W5E62EY.cjs → chunk-SGYSDABK.cjs} +6 -6
- package/dist/{chunk-2W5E62EY.cjs.map → chunk-SGYSDABK.cjs.map} +1 -1
- package/dist/{chunk-EATIFPKP.cjs → chunk-T73BHNQX.cjs} +4 -4
- package/dist/{chunk-EATIFPKP.cjs.map → chunk-T73BHNQX.cjs.map} +1 -1
- package/dist/{chunk-4IOYQLKG.cjs → chunk-TP5PGWIO.cjs} +3 -3
- package/dist/{chunk-4IOYQLKG.cjs.map → chunk-TP5PGWIO.cjs.map} +1 -1
- package/dist/{chunk-GKVE5JGB.cjs → chunk-UFT22LAB.cjs} +3 -3
- package/dist/{chunk-GKVE5JGB.cjs.map → chunk-UFT22LAB.cjs.map} +1 -1
- package/dist/{chunk-Q3XJUXID.cjs → chunk-USNTRL22.cjs} +215 -199
- package/dist/chunk-USNTRL22.cjs.map +1 -0
- package/dist/{chunk-7VUJGHMY.cjs → chunk-UTJ223TI.cjs} +178 -82
- package/dist/chunk-UTJ223TI.cjs.map +1 -0
- package/dist/{chunk-FKFQCK3C.cjs → chunk-V6MW7B4B.cjs} +4 -4
- package/dist/{chunk-FKFQCK3C.cjs.map → chunk-V6MW7B4B.cjs.map} +1 -1
- package/dist/{chunk-2PZT3J34.cjs → chunk-VWBYE3XY.cjs} +6 -6
- package/dist/{chunk-2PZT3J34.cjs.map → chunk-VWBYE3XY.cjs.map} +1 -1
- package/dist/{chunk-GQXPNIRE.cjs → chunk-WAV762GP.cjs} +6 -6
- package/dist/{chunk-GQXPNIRE.cjs.map → chunk-WAV762GP.cjs.map} +1 -1
- package/dist/{chunk-5LTIZ44D.cjs → chunk-WFMWKPGY.cjs} +14 -7
- package/dist/chunk-WFMWKPGY.cjs.map +1 -0
- package/dist/{chunk-KP5AITQ4.cjs → chunk-WRLGLZIA.cjs} +7 -7
- package/dist/{chunk-KP5AITQ4.cjs.map → chunk-WRLGLZIA.cjs.map} +1 -1
- package/dist/{chunk-MZ2KZXNU.cjs → chunk-WXUU3COI.cjs} +3 -3
- package/dist/{chunk-MZ2KZXNU.cjs.map → chunk-WXUU3COI.cjs.map} +1 -1
- package/dist/{chunk-NAJN32MF.cjs → chunk-XF355M7O.cjs} +13 -13
- package/dist/{chunk-NAJN32MF.cjs.map → chunk-XF355M7O.cjs.map} +1 -1
- package/dist/{chunk-GPX5VC57.cjs → chunk-XGM4VVNV.cjs} +50 -50
- package/dist/{chunk-GPX5VC57.cjs.map → chunk-XGM4VVNV.cjs.map} +1 -1
- package/dist/connect/docx.cjs +19 -19
- package/dist/connect/index.cjs +996 -995
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +38 -37
- package/dist/connection/conversation/ConnectedMessage.js +1 -1
- package/dist/connection/conversation/ConnectedMessage.js.map +2 -2
- package/dist/connection/presentation/ConnectedSlidesTab.js +5 -3
- package/dist/connection/presentation/ConnectedSlidesTab.js.map +2 -2
- package/dist/connection/presentation/PresentationPill.js +3 -8
- package/dist/connection/presentation/PresentationPill.js.map +2 -2
- package/dist/connection/presentation/requests.d.ts +5 -0
- package/dist/connection/presentation/requests.js +8 -1
- package/dist/connection/presentation/requests.js.map +2 -2
- package/dist/connection/viewer/ViewerPdfPane.js +4 -1
- package/dist/connection/viewer/ViewerPdfPane.js.map +2 -2
- package/dist/connection/viewer/documentPlace.d.ts +5 -4
- package/dist/connection/viewer/documentPlace.js +2 -2
- package/dist/connection/viewer/documentPlace.js.map +2 -2
- package/dist/connection/viewer/pdf/PdfClipOutlines.d.ts +11 -0
- package/dist/connection/viewer/pdf/PdfClipOutlines.js +42 -0
- package/dist/connection/viewer/pdf/PdfClipOutlines.js.map +7 -0
- package/dist/connection/viewer/pdf/clipOutlines.d.ts +17 -0
- package/dist/connection/viewer/pdf/clipOutlines.js +24 -0
- package/dist/connection/viewer/pdf/clipOutlines.js.map +7 -0
- package/dist/connection/viewer/pdf/passageHighlights.d.ts +2 -0
- package/dist/connection/viewer/pdf/passageHighlights.js +12 -1
- package/dist/connection/viewer/pdf/passageHighlights.js.map +2 -2
- package/dist/connection/viewer/pdf/usePdfClipOutlines.d.ts +7 -0
- package/dist/connection/viewer/pdf/usePdfClipOutlines.js +36 -0
- package/dist/connection/viewer/pdf/usePdfClipOutlines.js.map +7 -0
- package/dist/connection/viewer/pdf/usePdfPassageHighlights.js +11 -2
- package/dist/connection/viewer/pdf/usePdfPassageHighlights.js.map +2 -2
- package/dist/dashboards/index.cjs +1 -1
- package/dist/embed/index.cjs +39 -39
- package/dist/files/index.cjs +224 -224
- package/dist/index.cjs +1597 -1596
- package/dist/index.cjs.map +1 -1
- package/dist/presentation/PresentControls.d.ts +11 -0
- package/dist/presentation/PresentControls.js +117 -0
- package/dist/presentation/PresentControls.js.map +7 -0
- package/dist/presentation/PresenterView.js +36 -5
- package/dist/presentation/PresenterView.js.map +2 -2
- package/dist/presentation/SlidesEditor.js +17 -1
- package/dist/presentation/SlidesEditor.js.map +2 -2
- package/dist/presentation/panel-id.d.ts +12 -2
- package/dist/presentation/panel-id.js +6 -1
- package/dist/presentation/panel-id.js.map +2 -2
- package/dist/presentation/slide-layout.d.ts +5 -1
- package/dist/presentation/slide-layout.js +16 -0
- package/dist/presentation/slide-layout.js.map +2 -2
- package/dist/settings/index.cjs +146 -146
- package/dist/shell/PanelPortal.js +13 -4
- package/dist/shell/PanelPortal.js.map +2 -2
- package/dist/shell/index.cjs +92 -91
- package/dist/shell/panel-windows.js +1 -0
- package/dist/shell/panel-windows.js.map +2 -2
- package/dist/studio/index.cjs +28 -28
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +53 -53
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ConnectedPresentation-4HLDZDWV.cjs +0 -183
- package/dist/ConnectedPresentation-4HLDZDWV.cjs.map +0 -1
- package/dist/ConnectedSlidesTab-7QDE2CZD.cjs.map +0 -1
- package/dist/FilesViewerDialog-IZI63FOV.cjs.map +0 -1
- package/dist/ai-KBYNRNZ6.cjs.map +0 -1
- package/dist/chunk-5LTIZ44D.cjs.map +0 -1
- package/dist/chunk-7VUJGHMY.cjs.map +0 -1
- package/dist/chunk-GX2EBMJW.cjs.map +0 -1
- package/dist/chunk-JZEYHDWJ.cjs.map +0 -1
- package/dist/chunk-Q3XJUXID.cjs.map +0 -1
- package/dist/chunk-QFXILJMJ.cjs.map +0 -1
- package/dist/chunk-VJ5ZLRBD.cjs.map +0 -1
- package/dist/chunk-XTR26TNE.cjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkUFT22LAB_cjs = require('./chunk-UFT22LAB.cjs');
|
|
5
|
+
var chunkWAV762GP_cjs = require('./chunk-WAV762GP.cjs');
|
|
6
6
|
var chunk7JLJH5CW_cjs = require('./chunk-7JLJH5CW.cjs');
|
|
7
|
-
var
|
|
8
|
-
var chunkQRAQZTJE_cjs = require('./chunk-QRAQZTJE.cjs');
|
|
7
|
+
var chunkWXUU3COI_cjs = require('./chunk-WXUU3COI.cjs');
|
|
9
8
|
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
9
|
+
var chunkQRAQZTJE_cjs = require('./chunk-QRAQZTJE.cjs');
|
|
10
10
|
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
11
11
|
var browser = require('@arbidocs/sdk/browser');
|
|
12
12
|
var react = require('@arbidocs/react');
|
|
@@ -49,11 +49,11 @@ function useLaunchWorkflow({
|
|
|
49
49
|
} = {}) {
|
|
50
50
|
const { data: documents = [] } = react.useDocuments();
|
|
51
51
|
const { data: workspaceTags = [] } = react.useTags();
|
|
52
|
-
const tags = react$1.useMemo(() =>
|
|
52
|
+
const tags = react$1.useMemo(() => chunkWXUU3COI_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
|
|
53
53
|
const createTag = react.useCreateTag();
|
|
54
54
|
const updateTag = react.useUpdateTag();
|
|
55
55
|
const generate = react.useGenerateDocTags();
|
|
56
|
-
const { create: createTask } =
|
|
56
|
+
const { create: createTask } = chunkUFT22LAB_cjs.useWorkflowTasks();
|
|
57
57
|
const applyModel = react.useApplyChatModel();
|
|
58
58
|
const session = react.useArbiSessionStore();
|
|
59
59
|
const { notify, openFiles, openNewConversation } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
@@ -61,7 +61,7 @@ function useLaunchWorkflow({
|
|
|
61
61
|
async ({ inputs, scope }) => {
|
|
62
62
|
const description = text(inputs, "description");
|
|
63
63
|
const name = text(inputs, "name") || chunk7JLJH5CW_cjs.deriveAnnotationName(description);
|
|
64
|
-
const matching =
|
|
64
|
+
const matching = chunkWXUU3COI_cjs.matchWorkflowScope(documents, scope);
|
|
65
65
|
if (!name || !description || matching.length === 0) return;
|
|
66
66
|
try {
|
|
67
67
|
const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase());
|
|
@@ -161,7 +161,7 @@ function useLaunchWorkflow({
|
|
|
161
161
|
const binding = PROMPT_BINDINGS[workflow.id];
|
|
162
162
|
const prepare = () => {
|
|
163
163
|
if (binding?.attachScope !== false && !chunkQRAQZTJE_cjs.isEmptyWorkflowScope(scope)) {
|
|
164
|
-
const ids =
|
|
164
|
+
const ids = chunkWXUU3COI_cjs.matchWorkflowScope(documents, scope).map((d) => d.external_id);
|
|
165
165
|
if (ids.length > 0) {
|
|
166
166
|
session.setConversationDocuments(
|
|
167
167
|
inPlace ? session.getState().conversationId ?? "new" : "new",
|
|
@@ -215,7 +215,7 @@ function ConnectedWorkflowStart({
|
|
|
215
215
|
);
|
|
216
216
|
const { openUpload } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
217
217
|
const { data: workspaceTags = [] } = react.useTags();
|
|
218
|
-
const tags = react$1.useMemo(() =>
|
|
218
|
+
const tags = react$1.useMemo(() => chunkWXUU3COI_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
|
|
219
219
|
const fieldPlaceholder = react$1.useCallback(
|
|
220
220
|
(field, inputs, workflow) => {
|
|
221
221
|
if (workflow.id !== chunk7JLJH5CW_cjs.ANNOTATE_ID || field.name !== "name") return void 0;
|
|
@@ -225,7 +225,7 @@ function ConnectedWorkflowStart({
|
|
|
225
225
|
[]
|
|
226
226
|
);
|
|
227
227
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
228
|
-
|
|
228
|
+
chunkWAV762GP_cjs.ConnectedWorkflowLauncher,
|
|
229
229
|
{
|
|
230
230
|
...rest,
|
|
231
231
|
workflows,
|
|
@@ -265,5 +265,5 @@ function ConnectedWorkflowStart({
|
|
|
265
265
|
exports.ConnectedWorkflowStart = ConnectedWorkflowStart;
|
|
266
266
|
exports.PROMPT_BINDINGS = PROMPT_BINDINGS;
|
|
267
267
|
exports.useLaunchWorkflow = useLaunchWorkflow;
|
|
268
|
-
//# sourceMappingURL=chunk-
|
|
269
|
-
//# sourceMappingURL=chunk-
|
|
268
|
+
//# sourceMappingURL=chunk-2F57IO7S.cjs.map
|
|
269
|
+
//# sourceMappingURL=chunk-2F57IO7S.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","composeWorkflowPrompt","isEmptyWorkflowScope","useHost","renderWorkflowIcon","jsx","ConnectedWorkflowLauncher","jsxs","TriangleAlert"],"mappings":";;;;;;;;;;;;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EAAK,QAAA,EAAA;AAAA,gBAAA,uBAAA;AAAA,gCACiBH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-NLOETJCB.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","composeWorkflowPrompt","isEmptyWorkflowScope","useHost","renderWorkflowIcon","jsx","ConnectedWorkflowLauncher","jsxs","TriangleAlert"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAC,MAAA,KAAqC;AACzD,EAAA,MAAM,QAAQ,MAAA,CAAO,UAAA;AACrB,EAAA,OAAO,KAAA,EAAO,aAAa,EAAC;AAC9B,CAAA;AAEO,IAAM,eAAA,GAAiD;AAAA,EAC5D,CAACA,mCAAiB,GAAG;AAAA,IACnB,WAAA,EAAa,KAAA;AAAA,IACb,KAAA,EAAO,CAAC,MAAA,KAAW;AACjB,MAAA,MAAM,cAAc,OAAO,MAAA,CAAO,YAAA,KAAiB,QAAA,GAAW,OAAO,YAAA,GAAe,EAAA;AACpF,MAAA,OAAO;AAAA,QACL,eAAA,EAAiBC,+BAAA,CAAwB,EAAE,CAAA;AAAA,QAC3C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AAA,MAEN,YAAA,EAAc,CAAC,EAAE,QAAA,EAAU,QAAO,KAAM;AACtC,QAAA,IAAI,QAAA,CAAS,EAAA,KAAOA,6BAAA,EAAa,OAAO,IAAA;AAGxC,QAAA,MAAM,IAAA,GACJ,MAAA,CAAO,MAAA,CAAO,IAAA,IAAQ,EAAE,CAAA,CAAE,IAAA,EAAK,IAAKF,sCAAA,CAAqB,MAAA,CAAO,MAAA,CAAO,WAAA,IAAe,EAAE,CAAC,CAAA;AAC3F,QAAA,MAAM,QAAA,GAAW,IAAA,GACb,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,CAAK,WAAA,EAAY,KAAM,IAAA,CAAK,WAAA,EAAa,CAAA,GAC5D,MAAA;AACJ,QAAA,IAAI,CAAC,UAAU,OAAO,IAAA;AACtB,QAAA,uBACEW,eAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,mIAAA;AAAA,YACV,IAAA,EAAK,QAAA;AAAA,YACL,aAAA,EAAY,iCAAA;AAAA,YAEZ,QAAA,EAAA;AAAA,8BAAAF,cAAA,CAACG,yBAAA,EAAA,EAAc,WAAU,uCAAA,EAAwC,CAAA;AAAA,8CAChE,MAAA,EAAA,EAAK,QAAA,EAAA;AAAA,gBAAA,uBAAA;AAAA,gCACiBH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-2F57IO7S.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
5
|
+
|
|
6
|
+
// src/shell/panel-windows.ts
|
|
7
|
+
var PanelWindowManager = class {
|
|
8
|
+
constructor(defaultTitle = "Panel") {
|
|
9
|
+
this.defaultTitle = defaultTitle;
|
|
10
|
+
}
|
|
11
|
+
defaultTitle;
|
|
12
|
+
windows = /* @__PURE__ */ new Map();
|
|
13
|
+
/** Counts the windows opened, for their browser names. */
|
|
14
|
+
opened = 0;
|
|
15
|
+
createPopupWindow(panelId, onClose, title) {
|
|
16
|
+
const windowId = `panel-window-${panelId}`;
|
|
17
|
+
if (this.windows.has(windowId)) {
|
|
18
|
+
const existing = this.windows.get(windowId);
|
|
19
|
+
if (existing && !existing.window.closed) {
|
|
20
|
+
if (onClose) existing.onClose = onClose;
|
|
21
|
+
existing.window.focus();
|
|
22
|
+
return windowId;
|
|
23
|
+
} else {
|
|
24
|
+
this.windows.delete(windowId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const currentWidth = window.outerWidth;
|
|
28
|
+
const currentHeight = window.outerHeight;
|
|
29
|
+
const currentLeft = window.screenX ?? window.screenLeft ?? 0;
|
|
30
|
+
const currentTop = window.screenY ?? window.screenTop ?? 0;
|
|
31
|
+
const halfWidth = Math.floor(currentWidth / 2);
|
|
32
|
+
const popupWidth = halfWidth;
|
|
33
|
+
const popupHeight = currentHeight;
|
|
34
|
+
const left = currentLeft + halfWidth;
|
|
35
|
+
const top = currentTop;
|
|
36
|
+
const popup = window.open(
|
|
37
|
+
"",
|
|
38
|
+
// A browser window name of its own: one closed a moment ago (a panel remounted, as React's
|
|
39
|
+
// StrictMode does) may still be closing, and reusing its name would hand back that window.
|
|
40
|
+
`${windowId}-${++this.opened}`,
|
|
41
|
+
`width=${popupWidth},height=${popupHeight},left=${left},top=${top},scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no,status=no`
|
|
42
|
+
);
|
|
43
|
+
if (!popup) {
|
|
44
|
+
console.error("Failed to create popup window - popup blocked?");
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const mainDocument = document;
|
|
48
|
+
const stylesheets = Array.from(
|
|
49
|
+
mainDocument.head.querySelectorAll('link[rel="stylesheet"], style')
|
|
50
|
+
).map((el) => el.outerHTML).join("\n");
|
|
51
|
+
popup.document.write(`
|
|
52
|
+
<!DOCTYPE html>
|
|
53
|
+
<html lang="en">
|
|
54
|
+
<head>
|
|
55
|
+
<meta charset="UTF-8">
|
|
56
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
57
|
+
<title></title>
|
|
58
|
+
<!-- about:blank has no base, so copied @font-face / asset URLs (e.g.
|
|
59
|
+
/assets/font.woff2) would resolve against nothing and render as
|
|
60
|
+
tofu squares. Anchor relative URLs to the app origin. -->
|
|
61
|
+
<base href="${window.location.origin}/">
|
|
62
|
+
${stylesheets}
|
|
63
|
+
<style>
|
|
64
|
+
body {
|
|
65
|
+
margin: 0;
|
|
66
|
+
padding: 0;
|
|
67
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
68
|
+
}
|
|
69
|
+
#panel-root {
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: 100vh;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
}
|
|
74
|
+
* {
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
78
|
+
</head>
|
|
79
|
+
<body>
|
|
80
|
+
<div id="panel-root"></div>
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
|
83
|
+
`);
|
|
84
|
+
popup.document.close();
|
|
85
|
+
popup.document.title = title || this.defaultTitle;
|
|
86
|
+
try {
|
|
87
|
+
mainDocument.fonts.forEach((font) => {
|
|
88
|
+
try {
|
|
89
|
+
popup.document.fonts.add(font);
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
const rootElement = popup.document.getElementById("panel-root");
|
|
96
|
+
const popupWindow = {
|
|
97
|
+
id: windowId,
|
|
98
|
+
window: popup,
|
|
99
|
+
panelId,
|
|
100
|
+
rootElement,
|
|
101
|
+
onClose
|
|
102
|
+
};
|
|
103
|
+
this.windows.set(windowId, popupWindow);
|
|
104
|
+
const closeCheckInterval = setInterval(() => {
|
|
105
|
+
if (popup.closed) {
|
|
106
|
+
clearInterval(closeCheckInterval);
|
|
107
|
+
const entry = this.windows.get(windowId);
|
|
108
|
+
if (entry?.window !== popup) return;
|
|
109
|
+
this.windows.delete(windowId);
|
|
110
|
+
entry.onClose?.();
|
|
111
|
+
}
|
|
112
|
+
}, 200);
|
|
113
|
+
return windowId;
|
|
114
|
+
}
|
|
115
|
+
getWindow(windowId) {
|
|
116
|
+
const popup = this.windows.get(windowId);
|
|
117
|
+
return popup && !popup.window.closed ? popup.window : null;
|
|
118
|
+
}
|
|
119
|
+
getRootElement(windowId) {
|
|
120
|
+
const popup = this.windows.get(windowId);
|
|
121
|
+
return popup && !popup.window.closed ? popup.rootElement : null;
|
|
122
|
+
}
|
|
123
|
+
/** Focus the popup window for a given panel ID. Returns true if focused. */
|
|
124
|
+
focusPanelWindow(panelId) {
|
|
125
|
+
const windowId = `panel-window-panel-${panelId}`;
|
|
126
|
+
const popup = this.windows.get(windowId);
|
|
127
|
+
if (popup && !popup.window.closed) {
|
|
128
|
+
popup.window.focus();
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
/** Remove the onClose callback so it won't fire when the window is closed programmatically. */
|
|
134
|
+
clearOnClose(windowId) {
|
|
135
|
+
const popup = this.windows.get(windowId);
|
|
136
|
+
if (popup) {
|
|
137
|
+
popup.onClose = void 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
closeWindow(windowId) {
|
|
141
|
+
const popup = this.windows.get(windowId);
|
|
142
|
+
if (popup && !popup.window.closed) {
|
|
143
|
+
popup.window.close();
|
|
144
|
+
}
|
|
145
|
+
this.windows.delete(windowId);
|
|
146
|
+
}
|
|
147
|
+
closeAllWindows() {
|
|
148
|
+
for (const [, popup] of this.windows) {
|
|
149
|
+
if (!popup.window.closed) {
|
|
150
|
+
popup.window.close();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
this.windows.clear();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
function createPanelWindowManager(options = {}) {
|
|
157
|
+
return new PanelWindowManager(options.defaultTitle);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/shell/panel-host.ts
|
|
161
|
+
var defaultWindows = createPanelWindowManager();
|
|
162
|
+
var titleOnly = (title) => title;
|
|
163
|
+
function usePanelHostSupport() {
|
|
164
|
+
const { panels } = chunk3YZKDCWY_cjs.useHost();
|
|
165
|
+
return {
|
|
166
|
+
windows: panels?.windows ?? defaultWindows,
|
|
167
|
+
popoutTitle: panels?.popoutTitle ?? titleOnly
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exports.createPanelWindowManager = createPanelWindowManager;
|
|
172
|
+
exports.usePanelHostSupport = usePanelHostSupport;
|
|
173
|
+
//# sourceMappingURL=chunk-2RLA6QO2.cjs.map
|
|
174
|
+
//# sourceMappingURL=chunk-2RLA6QO2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shell/panel-windows.ts","../src/shell/panel-host.ts"],"names":["useHost"],"mappings":";;;;;AAyBA,IAAM,qBAAN,MAAiD;AAAA,EAC/C,WAAA,CAA6B,eAAe,OAAA,EAAS;AAAxB,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAAA,EAAyB;AAAA,EAAzB,YAAA;AAAA,EACrB,OAAA,uBAAc,GAAA,EAAyB;AAAA;AAAA,EAEvC,MAAA,GAAS,CAAA;AAAA,EAEjB,iBAAA,CAAkB,OAAA,EAAiB,OAAA,EAAsB,KAAA,EAA+B;AACtF,IAAA,MAAM,QAAA,GAAW,gBAAgB,OAAO,CAAA,CAAA;AAGxC,IAAA,IAAI,IAAA,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AAAA,IAC5B,WAAA,EAAa,QAAQ,WAAA,IAAe;AAAA,GACtC;AACF","file":"chunk-2RLA6QO2.cjs","sourcesContent":["/**\n * Window Manager for Pop-out Panels\n *\n * Handles creating, managing, and communicating with popup windows\n */\n\ninterface PopupWindow {\n id: string\n window: Window\n panelId: string\n rootElement: HTMLElement | null\n onClose?: () => void\n}\n\n/** Window lifecycle port; hosts may share or replace the browser implementation. */\nexport interface PanelWindows {\n createPopupWindow(panelId: string, onClose?: () => void, title?: string): string | null\n getWindow(windowId: string): Window | null\n getRootElement(windowId: string): HTMLElement | null\n focusPanelWindow(panelId: string): boolean\n clearOnClose(windowId: string): void\n closeWindow(windowId: string): void\n closeAllWindows(): void\n}\n\nclass PanelWindowManager implements PanelWindows {\n constructor(private readonly defaultTitle = 'Panel') {}\n private windows = new Map<string, PopupWindow>()\n /** Counts the windows opened, for their browser names. */\n private opened = 0\n\n createPopupWindow(panelId: string, onClose?: () => void, title?: string): string | null {\n const windowId = `panel-window-${panelId}`\n\n // Check if window already exists\n if (this.windows.has(windowId)) {\n const existing = this.windows.get(windowId)\n if (existing && !existing.window.closed) {\n // Opened ahead in a click (so the browser lets it open); the panel adopts it.\n if (onClose) existing.onClose = onClose\n existing.window.focus()\n return windowId\n } else {\n // Clean up closed window\n this.windows.delete(windowId)\n }\n }\n\n // Position popup in the right half of the screen\n const currentWidth = window.outerWidth\n const currentHeight = window.outerHeight\n const currentLeft = window.screenX ?? window.screenLeft ?? 0\n const currentTop = window.screenY ?? window.screenTop ?? 0\n\n // Calculate popup position (right half)\n const halfWidth = Math.floor(currentWidth / 2)\n const popupWidth = halfWidth\n const popupHeight = currentHeight\n const left = currentLeft + halfWidth\n const top = currentTop\n\n const popup = window.open(\n '',\n // A browser window name of its own: one closed a moment ago (a panel remounted, as React's\n // StrictMode does) may still be closing, and reusing its name would hand back that window.\n `${windowId}-${++this.opened}`,\n `width=${popupWidth},height=${popupHeight},left=${left},top=${top},scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no,status=no`\n )\n\n if (!popup) {\n console.error('Failed to create popup window - popup blocked?')\n return null\n }\n\n // Set up the popup window HTML with proper CSS links\n const mainDocument = document\n const stylesheets = Array.from(\n mainDocument.head.querySelectorAll('link[rel=\"stylesheet\"], style')\n )\n .map((el) => el.outerHTML)\n .join('\\n')\n\n popup.document.write(`\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title></title>\n <!-- about:blank has no base, so copied @font-face / asset URLs (e.g.\n /assets/font.woff2) would resolve against nothing and render as\n tofu squares. Anchor relative URLs to the app origin. -->\n <base href=\"${window.location.origin}/\">\n ${stylesheets}\n <style>\n body {\n margin: 0;\n padding: 0;\n font-family: system-ui, -apple-system, sans-serif;\n }\n #panel-root {\n width: 100%;\n height: 100vh;\n overflow: hidden;\n }\n * {\n box-sizing: border-box;\n }\n </style>\n </head>\n <body>\n <div id=\"panel-root\"></div>\n </body>\n </html>\n `)\n popup.document.close()\n // A host title is text, even when it contains HTML delimiters.\n popup.document.title = title || this.defaultTitle\n\n // Belt-and-suspenders: re-register the parent's already-loaded web fonts in\n // the popup's FontFaceSet, so glyphs render even if a copied @font-face\n // doesn't re-fetch. Best-effort — engines that reject a cross-document add\n // just fall back to the <base>-anchored @font-face rules above.\n try {\n mainDocument.fonts.forEach((font) => {\n try {\n popup.document.fonts.add(font)\n } catch {\n /* ignore per-font failures */\n }\n })\n } catch {\n /* FontFaceSet unavailable — ignore */\n }\n\n // Get root element after DOM is ready\n const rootElement = popup.document.getElementById('panel-root')\n\n // Store window reference\n const popupWindow: PopupWindow = {\n id: windowId,\n window: popup,\n panelId,\n rootElement,\n onClose,\n }\n this.windows.set(windowId, popupWindow)\n\n // Handle window close — read onClose from the map entry so clearOnClose() works\n const closeCheckInterval = setInterval(() => {\n if (popup.closed) {\n clearInterval(closeCheckInterval)\n const entry = this.windows.get(windowId)\n // The panel may have a newer window by now (closed and reopened): leave that one be.\n if (entry?.window !== popup) return\n this.windows.delete(windowId)\n entry.onClose?.()\n }\n }, 200)\n\n return windowId\n }\n\n getWindow(windowId: string): Window | null {\n const popup = this.windows.get(windowId)\n return popup && !popup.window.closed ? popup.window : null\n }\n\n getRootElement(windowId: string): HTMLElement | null {\n const popup = this.windows.get(windowId)\n return popup && !popup.window.closed ? popup.rootElement : null\n }\n\n /** Focus the popup window for a given panel ID. Returns true if focused. */\n focusPanelWindow(panelId: string): boolean {\n const windowId = `panel-window-panel-${panelId}`\n const popup = this.windows.get(windowId)\n if (popup && !popup.window.closed) {\n popup.window.focus()\n return true\n }\n return false\n }\n\n /** Remove the onClose callback so it won't fire when the window is closed programmatically. */\n clearOnClose(windowId: string): void {\n const popup = this.windows.get(windowId)\n if (popup) {\n popup.onClose = undefined\n }\n }\n\n closeWindow(windowId: string): void {\n const popup = this.windows.get(windowId)\n if (popup && !popup.window.closed) {\n popup.window.close()\n }\n this.windows.delete(windowId)\n }\n\n closeAllWindows(): void {\n for (const [, popup] of this.windows) {\n if (!popup.window.closed) {\n popup.window.close()\n }\n }\n this.windows.clear()\n }\n}\n\n/** A window registry shared by the host's panel controls and portal layer. */\nexport function createPanelWindowManager(options: { defaultTitle?: string } = {}) {\n return new PanelWindowManager(options.defaultTitle)\n}\n","import { useHost } from '../provider/host'\nimport { createPanelWindowManager, type PanelWindows } from './panel-windows'\n\n/** Browser windows and site-specific titles shared by a host's panel controls. */\nexport interface PanelHostSupport {\n windows?: PanelWindows\n popoutTitle?: (title: string) => string\n}\n\nconst defaultWindows = createPanelWindowManager()\nconst titleOnly = (title: string) => title\n\n/** Panel support from the existing ArbiHost; standalone panels share the browser defaults. */\nexport function usePanelHostSupport(): Required<PanelHostSupport> {\n const { panels } = useHost()\n return {\n windows: panels?.windows ?? defaultWindows,\n popoutTitle: panels?.popoutTitle ?? titleOnly,\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var chunkYZSQ7F5K_cjs = require('./chunk-YZSQ7F5K.cjs');
|
|
5
4
|
var chunkJV5TVUOU_cjs = require('./chunk-JV5TVUOU.cjs');
|
|
5
|
+
var chunkYZSQ7F5K_cjs = require('./chunk-YZSQ7F5K.cjs');
|
|
6
6
|
var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var ui = require('@arbidocs/react/ui');
|
|
@@ -621,5 +621,5 @@ exports.SidebarBadgeRow = SidebarBadgeRow;
|
|
|
621
621
|
exports.SidebarRowHoverContext = SidebarRowHoverContext;
|
|
622
622
|
exports.useShellStartInset = useShellStartInset;
|
|
623
623
|
exports.useSidebarContext = useSidebarContext;
|
|
624
|
-
//# sourceMappingURL=chunk-
|
|
625
|
-
//# sourceMappingURL=chunk-
|
|
624
|
+
//# sourceMappingURL=chunk-325GVZE6.cjs.map
|
|
625
|
+
//# sourceMappingURL=chunk-325GVZE6.cjs.map
|