@arbidocs/blocks 0.5.177 → 0.5.179
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-KD5LWW2E.cjs → ConnectedCallDock-JY3LGQGP.cjs} +20 -20
- package/dist/{ConnectedCallDock-KD5LWW2E.cjs.map → ConnectedCallDock-JY3LGQGP.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-GSMF7ZUE.cjs → ConnectedCallRoom-GTH4J55D.cjs} +13 -13
- package/dist/{ConnectedCallRoom-GSMF7ZUE.cjs.map → ConnectedCallRoom-GTH4J55D.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs → ConnectedNativeDocxComparison-2NBAE7EI.cjs} +18 -18
- package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs.map → ConnectedNativeDocxComparison-2NBAE7EI.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-LNDESKYE.cjs → ConnectedPresentation-VEMVDFI5.cjs} +17 -17
- package/dist/{ConnectedPresentation-LNDESKYE.cjs.map → ConnectedPresentation-VEMVDFI5.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-SHDI7KP6.cjs → ConnectedProductionSetDialog-BKDYMRPF.cjs} +6 -6
- package/dist/{ConnectedProductionSetDialog-SHDI7KP6.cjs.map → ConnectedProductionSetDialog-BKDYMRPF.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-LEA5OW75.cjs → ConnectedSlidesTab-GT5TQPWW.cjs} +15 -15
- package/dist/{ConnectedSlidesTab-LEA5OW75.cjs.map → ConnectedSlidesTab-GT5TQPWW.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs → ConnectedStreamedWordArtifact-S7RQFGL5.cjs} +18 -18
- package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs.map → ConnectedStreamedWordArtifact-S7RQFGL5.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-RPHIQZ2Y.cjs → DocumentReviewCard-3HOUMATK.cjs} +17 -17
- package/dist/{DocumentReviewCard-RPHIQZ2Y.cjs.map → DocumentReviewCard-3HOUMATK.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-JIV4VGYQ.cjs → FilesViewerDialog-CH5RO64O.cjs} +49 -49
- package/dist/{FilesViewerDialog-JIV4VGYQ.cjs.map → FilesViewerDialog-CH5RO64O.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-QT63XYII.cjs → WorkspaceTableView-HWZU2KWQ.cjs} +9 -9
- package/dist/{WorkspaceTableView-QT63XYII.cjs.map → WorkspaceTableView-HWZU2KWQ.cjs.map} +1 -1
- package/dist/agents/definitions/AgentCreator.d.ts +8 -1
- package/dist/agents/definitions/AgentCreator.js +30 -0
- package/dist/agents/definitions/AgentCreator.js.map +2 -2
- package/dist/agents/index.cjs +286 -286
- package/dist/{ai-XIT4MY3S.cjs → ai-6JEFW4U6.cjs} +25 -25
- package/dist/ai-6JEFW4U6.cjs.map +1 -0
- package/dist/auth/index.cjs +12 -12
- package/dist/avatar-renderer-O25E5KUY.cjs +325 -0
- package/dist/avatar-renderer-O25E5KUY.cjs.map +1 -0
- package/dist/avatar-wireframe-LM2NL4EY.cjs +55 -0
- package/dist/avatar-wireframe-LM2NL4EY.cjs.map +1 -0
- package/dist/calls/composite-canvas.js +7 -3
- package/dist/calls/composite-canvas.js.map +2 -2
- package/dist/calls/connected/CallAvatarMedia.d.ts +12 -0
- package/dist/calls/connected/CallAvatarMedia.js +105 -0
- package/dist/calls/connected/CallAvatarMedia.js.map +7 -0
- package/dist/calls/connected/CallRecording.js +7 -2
- package/dist/calls/connected/CallRecording.js.map +2 -2
- package/dist/calls/connected/ConnectedCallRoom.js +29 -14
- package/dist/calls/connected/ConnectedCallRoom.js.map +2 -2
- package/dist/calls/connected/avatar-framing.d.ts +21 -0
- package/dist/calls/connected/avatar-framing.js +67 -0
- package/dist/calls/connected/avatar-framing.js.map +7 -0
- package/dist/calls/connected/avatar-materials.d.ts +12 -0
- package/dist/calls/connected/avatar-materials.js +79 -0
- package/dist/calls/connected/avatar-materials.js.map +7 -0
- package/dist/calls/connected/avatar-renderer.d.ts +17 -0
- package/dist/calls/connected/avatar-renderer.js +169 -0
- package/dist/calls/connected/avatar-renderer.js.map +7 -0
- package/dist/calls/connected/avatar-wireframe.d.ts +6 -0
- package/dist/calls/connected/avatar-wireframe.js +31 -0
- package/dist/calls/connected/avatar-wireframe.js.map +7 -0
- package/dist/calls/connected/call-media-state.d.ts +8 -0
- package/dist/calls/connected/call-media-state.js +24 -0
- package/dist/calls/connected/call-media-state.js.map +7 -0
- package/dist/calls/index.cjs +126 -126
- package/dist/{chunk-DKKW7GOJ.cjs → chunk-2N64TSHL.cjs} +4 -4
- package/dist/{chunk-DKKW7GOJ.cjs.map → chunk-2N64TSHL.cjs.map} +1 -1
- package/dist/{chunk-5OD6DRG7.cjs → chunk-3P6KGC46.cjs} +3 -3
- package/dist/{chunk-5OD6DRG7.cjs.map → chunk-3P6KGC46.cjs.map} +1 -1
- package/dist/{chunk-GAHGZBBM.cjs → chunk-3S6HBOHG.cjs} +257 -136
- package/dist/chunk-3S6HBOHG.cjs.map +1 -0
- package/dist/{chunk-MZ7IUHQA.cjs → chunk-54YKEVLX.cjs} +36 -36
- package/dist/{chunk-MZ7IUHQA.cjs.map → chunk-54YKEVLX.cjs.map} +1 -1
- package/dist/{chunk-VDHBLDQC.cjs → chunk-6N7QT2DH.cjs} +3 -3
- package/dist/{chunk-VDHBLDQC.cjs.map → chunk-6N7QT2DH.cjs.map} +1 -1
- package/dist/{chunk-UC6Z7E6C.cjs → chunk-6SN5KCE5.cjs} +6 -6
- package/dist/{chunk-UC6Z7E6C.cjs.map → chunk-6SN5KCE5.cjs.map} +1 -1
- package/dist/{chunk-VDT7TEAH.cjs → chunk-6ZJBUMNK.cjs} +3 -3
- package/dist/{chunk-VDT7TEAH.cjs.map → chunk-6ZJBUMNK.cjs.map} +1 -1
- package/dist/{chunk-LYDSETR7.cjs → chunk-AHUEBRLX.cjs} +4 -4
- package/dist/{chunk-LYDSETR7.cjs.map → chunk-AHUEBRLX.cjs.map} +1 -1
- package/dist/{chunk-5FSULBPE.cjs → chunk-B5AOYT4U.cjs} +3 -3
- package/dist/{chunk-5FSULBPE.cjs.map → chunk-B5AOYT4U.cjs.map} +1 -1
- package/dist/{chunk-RMRJ5KVE.cjs → chunk-B6HWZMRE.cjs} +67 -67
- package/dist/{chunk-RMRJ5KVE.cjs.map → chunk-B6HWZMRE.cjs.map} +1 -1
- package/dist/{chunk-3EIO4ZH5.cjs → chunk-BJRQHR7R.cjs} +6 -6
- package/dist/{chunk-3EIO4ZH5.cjs.map → chunk-BJRQHR7R.cjs.map} +1 -1
- package/dist/{chunk-I5LXJLO5.cjs → chunk-CR7QX5OA.cjs} +10 -10
- package/dist/{chunk-I5LXJLO5.cjs.map → chunk-CR7QX5OA.cjs.map} +1 -1
- package/dist/{chunk-BCU65RJM.cjs → chunk-DJ7LSKBJ.cjs} +10 -6
- package/dist/chunk-DJ7LSKBJ.cjs.map +1 -0
- package/dist/{chunk-L3MYUPSH.cjs → chunk-EG3DPKXM.cjs} +5 -5
- package/dist/{chunk-L3MYUPSH.cjs.map → chunk-EG3DPKXM.cjs.map} +1 -1
- package/dist/{chunk-TH3G7FZE.cjs → chunk-FHAUX6CD.cjs} +58 -28
- package/dist/chunk-FHAUX6CD.cjs.map +1 -0
- package/dist/{chunk-TUURH4NE.cjs → chunk-GZH52C4A.cjs} +4 -4
- package/dist/{chunk-TUURH4NE.cjs.map → chunk-GZH52C4A.cjs.map} +1 -1
- package/dist/{chunk-HX5SALXN.cjs → chunk-H3GJQSA5.cjs} +18 -18
- package/dist/{chunk-HX5SALXN.cjs.map → chunk-H3GJQSA5.cjs.map} +1 -1
- package/dist/{chunk-TQATDAJV.cjs → chunk-INVL4BE7.cjs} +4 -4
- package/dist/{chunk-TQATDAJV.cjs.map → chunk-INVL4BE7.cjs.map} +1 -1
- package/dist/{chunk-OHWYQI3B.cjs → chunk-IPSR2PUU.cjs} +12 -12
- package/dist/{chunk-OHWYQI3B.cjs.map → chunk-IPSR2PUU.cjs.map} +1 -1
- package/dist/{chunk-AWWGV5LL.cjs → chunk-IRYVRCKU.cjs} +28 -28
- package/dist/{chunk-AWWGV5LL.cjs.map → chunk-IRYVRCKU.cjs.map} +1 -1
- package/dist/{chunk-VSX4CD7P.cjs → chunk-IYN6Q5SZ.cjs} +61 -61
- package/dist/{chunk-VSX4CD7P.cjs.map → chunk-IYN6Q5SZ.cjs.map} +1 -1
- package/dist/{chunk-SMGUXRO5.cjs → chunk-J3LWRFYO.cjs} +50 -50
- package/dist/{chunk-SMGUXRO5.cjs.map → chunk-J3LWRFYO.cjs.map} +1 -1
- package/dist/{chunk-KQJUY2OE.cjs → chunk-JGU6YLIA.cjs} +11 -11
- package/dist/{chunk-KQJUY2OE.cjs.map → chunk-JGU6YLIA.cjs.map} +1 -1
- package/dist/{chunk-GLFMRQBT.cjs → chunk-K4UR3U7K.cjs} +10 -10
- package/dist/{chunk-GLFMRQBT.cjs.map → chunk-K4UR3U7K.cjs.map} +1 -1
- package/dist/{chunk-ER2MRSLT.cjs → chunk-LJTHFTQQ.cjs} +3 -3
- package/dist/{chunk-ER2MRSLT.cjs.map → chunk-LJTHFTQQ.cjs.map} +1 -1
- package/dist/{chunk-A7MGQMOV.cjs → chunk-LSFGSQHS.cjs} +9 -9
- package/dist/{chunk-A7MGQMOV.cjs.map → chunk-LSFGSQHS.cjs.map} +1 -1
- package/dist/{chunk-7GVKG3G4.cjs → chunk-M3HYFFCK.cjs} +13 -13
- package/dist/{chunk-7GVKG3G4.cjs.map → chunk-M3HYFFCK.cjs.map} +1 -1
- package/dist/{chunk-CYMAF656.cjs → chunk-P3Q2XFEJ.cjs} +13 -13
- package/dist/{chunk-CYMAF656.cjs.map → chunk-P3Q2XFEJ.cjs.map} +1 -1
- package/dist/{chunk-4AT2LJ2H.cjs → chunk-QSAW7XLZ.cjs} +4 -4
- package/dist/{chunk-4AT2LJ2H.cjs.map → chunk-QSAW7XLZ.cjs.map} +1 -1
- package/dist/{chunk-3YUC23EC.cjs → chunk-RRVNBO53.cjs} +4 -4
- package/dist/{chunk-3YUC23EC.cjs.map → chunk-RRVNBO53.cjs.map} +1 -1
- package/dist/{chunk-XKXKEVHH.cjs → chunk-TPYOXG5S.cjs} +6 -6
- package/dist/{chunk-XKXKEVHH.cjs.map → chunk-TPYOXG5S.cjs.map} +1 -1
- package/dist/{chunk-OIYKKUAN.cjs → chunk-TU46WKTN.cjs} +3 -3
- package/dist/{chunk-OIYKKUAN.cjs.map → chunk-TU46WKTN.cjs.map} +1 -1
- package/dist/{chunk-2K5DLB7B.cjs → chunk-VNUBBRJM.cjs} +3 -3
- package/dist/{chunk-2K5DLB7B.cjs.map → chunk-VNUBBRJM.cjs.map} +1 -1
- package/dist/{chunk-TLIZD6DV.cjs → chunk-W7TSEN3J.cjs} +6 -6
- package/dist/{chunk-TLIZD6DV.cjs.map → chunk-W7TSEN3J.cjs.map} +1 -1
- package/dist/{chunk-FUKN3PI5.cjs → chunk-WQQ6C2ML.cjs} +3 -3
- package/dist/{chunk-FUKN3PI5.cjs.map → chunk-WQQ6C2ML.cjs.map} +1 -1
- package/dist/{chunk-QSY2VW7V.cjs → chunk-WXRAU2FF.cjs} +6 -6
- package/dist/{chunk-QSY2VW7V.cjs.map → chunk-WXRAU2FF.cjs.map} +1 -1
- package/dist/{chunk-LYJFE37D.cjs → chunk-X6TSOKEP.cjs} +3 -3
- package/dist/{chunk-LYJFE37D.cjs.map → chunk-X6TSOKEP.cjs.map} +1 -1
- package/dist/{chunk-63D67ZGG.cjs → chunk-YHM3OAFN.cjs} +9 -9
- package/dist/{chunk-63D67ZGG.cjs.map → chunk-YHM3OAFN.cjs.map} +1 -1
- package/dist/{chunk-2D5GZMSK.cjs → chunk-YZ6SFKUO.cjs} +4 -4
- package/dist/{chunk-2D5GZMSK.cjs.map → chunk-YZ6SFKUO.cjs.map} +1 -1
- package/dist/{chunk-HH5MKRBL.cjs → chunk-ZSZI576U.cjs} +7 -7
- package/dist/{chunk-HH5MKRBL.cjs.map → chunk-ZSZI576U.cjs.map} +1 -1
- package/dist/connect/docx.cjs +21 -21
- package/dist/connect/index.cjs +1167 -1136
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +37 -37
- package/dist/connection/ConnectedAgentCreator.js +25 -2
- package/dist/connection/ConnectedAgentCreator.js.map +2 -2
- package/dist/connection/messenger/ConnectedChatThread.js +5 -1
- package/dist/connection/messenger/ConnectedChatThread.js.map +2 -2
- package/dist/connection/settings-page/featuresSection.js +7 -0
- package/dist/connection/settings-page/featuresSection.js.map +2 -2
- package/dist/dashboards/index.cjs +1 -1
- package/dist/embed/index.cjs +43 -43
- package/dist/facts/index.cjs +43 -43
- package/dist/files/index.cjs +228 -228
- package/dist/index.cjs +1749 -1749
- 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 +28 -28
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +60 -60
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +8 -5
- package/dist/ai-XIT4MY3S.cjs.map +0 -1
- package/dist/chunk-BCU65RJM.cjs.map +0 -1
- package/dist/chunk-GAHGZBBM.cjs.map +0 -1
- package/dist/chunk-TH3G7FZE.cjs.map +0 -1
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkJKTUL4L3_cjs = require('./chunk-JKTUL4L3.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkK4UR3U7K_cjs = require('./chunk-K4UR3U7K.cjs');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
8
|
function ConnectedStreamedWordArtifact({
|
|
9
9
|
fontBaseUrl,
|
|
10
10
|
...props
|
|
11
11
|
}) {
|
|
12
|
-
const adapter =
|
|
12
|
+
const adapter = chunkK4UR3U7K_cjs.useConnectedNativeDocxAdapter(fontBaseUrl);
|
|
13
13
|
return /* @__PURE__ */ jsxRuntime.jsx(chunkJKTUL4L3_cjs.StreamedWordArtifact, { ...props, adapter });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
exports.ConnectedStreamedWordArtifact = ConnectedStreamedWordArtifact;
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-GZH52C4A.cjs.map
|
|
18
|
+
//# sourceMappingURL=chunk-GZH52C4A.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/docx/ConnectedStreamedWordArtifact.tsx"],"names":["useConnectedNativeDocxAdapter","jsx","StreamedWordArtifact"],"mappings":";;;;;;AAMO,SAAS,6BAAA,CAA8B;AAAA,EAC5C,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA0E;AACxE,EAAA,MAAM,OAAA,GAAUA,gDAA8B,WAAW,CAAA;AACzD,EAAA,uBAAOC,cAAA,CAACC,sCAAA,EAAA,EAAsB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AAC5D","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/connection/docx/ConnectedStreamedWordArtifact.tsx"],"names":["useConnectedNativeDocxAdapter","jsx","StreamedWordArtifact"],"mappings":";;;;;;AAMO,SAAS,6BAAA,CAA8B;AAAA,EAC5C,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA0E;AACxE,EAAA,MAAM,OAAA,GAAUA,gDAA8B,WAAW,CAAA;AACzD,EAAA,uBAAOC,cAAA,CAACC,sCAAA,EAAA,EAAsB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AAC5D","file":"chunk-GZH52C4A.cjs","sourcesContent":["import { useConnectedNativeDocxAdapter } from './ConnectedNativeDocxEditor'\nimport {\n StreamedWordArtifact,\n type StreamedWordArtifactProps,\n} from '../../docx/StreamedWordArtifact'\n\nexport function ConnectedStreamedWordArtifact({\n fontBaseUrl,\n ...props\n}: Omit<StreamedWordArtifactProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <StreamedWordArtifact {...props} adapter={adapter} />\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk2N64TSHL_cjs = require('./chunk-2N64TSHL.cjs');
|
|
5
5
|
var chunkSOT7NPIB_cjs = require('./chunk-SOT7NPIB.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var chunkY3GJBLAI_cjs = require('./chunk-Y3GJBLAI.cjs');
|
|
9
|
-
var chunkLYJFE37D_cjs = require('./chunk-LYJFE37D.cjs');
|
|
6
|
+
var chunkVNUBBRJM_cjs = require('./chunk-VNUBBRJM.cjs');
|
|
7
|
+
var chunkX6TSOKEP_cjs = require('./chunk-X6TSOKEP.cjs');
|
|
10
8
|
var chunkZ574BY3H_cjs = require('./chunk-Z574BY3H.cjs');
|
|
11
9
|
var chunkVWSOHZK2_cjs = require('./chunk-VWSOHZK2.cjs');
|
|
10
|
+
var chunkPIJPM5RA_cjs = require('./chunk-PIJPM5RA.cjs');
|
|
11
|
+
var chunkY3GJBLAI_cjs = require('./chunk-Y3GJBLAI.cjs');
|
|
12
12
|
var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.cjs');
|
|
13
13
|
var ui = require('@arbidocs/react/ui');
|
|
14
14
|
var lucideReact = require('lucide-react');
|
|
@@ -48,16 +48,16 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
48
48
|
const assistantCopy = shell.useAssistantCopy();
|
|
49
49
|
const workspaceExtId = react.useArbiSessionState((s) => s.workspaceId);
|
|
50
50
|
const task = conversations.find((c) => c.external_id === conversationId);
|
|
51
|
-
const latestMessageAt =
|
|
51
|
+
const latestMessageAt = chunkVNUBBRJM_cjs.latestMessageTime(messageHistory);
|
|
52
52
|
const events = (activity.data ?? []).filter(
|
|
53
|
-
(event) => !
|
|
53
|
+
(event) => !chunkVNUBBRJM_cjs.isSupersededStop(event, latestMessageAt)
|
|
54
54
|
);
|
|
55
55
|
const personName = (extId) => {
|
|
56
56
|
const person = members.find((m) => m.user.external_id === extId)?.user;
|
|
57
57
|
return person ? ui.getUserDisplayName(person) : "someone";
|
|
58
58
|
};
|
|
59
|
-
const planSteps =
|
|
60
|
-
const entries =
|
|
59
|
+
const planSteps = chunkVNUBBRJM_cjs.fromPlanSteps(task?.plan?.steps ?? []);
|
|
60
|
+
const entries = chunkVNUBBRJM_cjs.compactThreadActivity(events, (id) => planSteps.find((s) => s.id === id)?.title);
|
|
61
61
|
const items = entries.map(({ event, label, recipients }) => {
|
|
62
62
|
const messageActivity = [
|
|
63
63
|
"created",
|
|
@@ -83,7 +83,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
83
83
|
const messageId = sourceMessage ?? [...messageHistory].reverse().find((message) => Date.parse(message.created_at ?? "") <= Date.parse(event.created_at))?.external_id ?? messageHistory[0]?.external_id;
|
|
84
84
|
const doc = docId ? docs.find((d) => d.external_id === docId) : void 0;
|
|
85
85
|
const mailDraftId = event.kind === "notified" && event.detail?.event === "mail_draft_ready" && typeof event.detail?.mail_id === "string" ? event.detail.mail_id : void 0;
|
|
86
|
-
const missed = event.kind === "notified" && recipients.length ?
|
|
86
|
+
const missed = event.kind === "notified" && recipients.length ? chunkVNUBBRJM_cjs.unnotifiedMentions(
|
|
87
87
|
messageHistory.find((message) => message.external_id === sourceMessage)?.mentions,
|
|
88
88
|
recipients,
|
|
89
89
|
event.actor_ext_id
|
|
@@ -98,7 +98,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
98
98
|
step: typeof event.detail?.step === "string" ? event.detail.step : void 0,
|
|
99
99
|
createdAt: event.created_at,
|
|
100
100
|
card: callDetail ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
-
|
|
101
|
+
chunkX6TSOKEP_cjs.ThreadCallLogCard,
|
|
102
102
|
{
|
|
103
103
|
detail: callDetail,
|
|
104
104
|
name: personName,
|
|
@@ -106,7 +106,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
106
106
|
time: ui.formatRelativeTime(event.created_at, { style: "short" })
|
|
107
107
|
}
|
|
108
108
|
) : recordingCall ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
-
|
|
109
|
+
chunkX6TSOKEP_cjs.RecordingCard,
|
|
110
110
|
{
|
|
111
111
|
callExtId: recordingCall,
|
|
112
112
|
recordingExtId: recordingId,
|
|
@@ -116,7 +116,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
116
116
|
) : void 0,
|
|
117
117
|
docId,
|
|
118
118
|
docTitle: doc ? ui.getDocumentTitle(doc) : void 0,
|
|
119
|
-
label: mailDraftId ? "Left a draft email" : event.kind === "notified" && recipients.length ?
|
|
119
|
+
label: mailDraftId ? "Left a draft email" : event.kind === "notified" && recipients.length ? chunkVNUBBRJM_cjs.notifiedLabel(recipients.map(personName), missed.map(personName)) : label,
|
|
120
120
|
description: [
|
|
121
121
|
name,
|
|
122
122
|
label,
|
|
@@ -130,7 +130,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
130
130
|
stepChip: eventStep ? stepChipOf(eventStep, event.kind, stepDocument) : void 0,
|
|
131
131
|
// No avatar tooltip: the entry is already a button (or titled row) that carries the same
|
|
132
132
|
// details, and a tooltip trigger inside it would be a nested <button>.
|
|
133
|
-
avatar: assistant ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
avatar: assistant ? /* @__PURE__ */ jsxRuntime.jsx(chunkVNUBBRJM_cjs.AssistantEntity, { variant: "icon", size: 20, showTooltip: false }) : member ? /* @__PURE__ */ jsxRuntime.jsx(chunk2N64TSHL_cjs.DocumentUser, { user: member, tooltip: false }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "size-4 text-muted-foreground" }),
|
|
134
134
|
time: ui.formatRelativeTime(event.created_at, { style: "short" }),
|
|
135
135
|
exactTime: ui.formatFriendlyDate(event.created_at),
|
|
136
136
|
onOpenDocument: docId && doc ? () => openDocument(docId) : void 0,
|
|
@@ -179,7 +179,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
179
179
|
onSelect: () => navigateToConversation(source)
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
const links =
|
|
182
|
+
const links = chunkVNUBBRJM_cjs.linkedRunsFromActivity(activity.data);
|
|
183
183
|
const threadName = (id, workflowId) => conversations.find((c) => c.external_id === id)?.title || workflows.find((w) => w.external_id === workflowId)?.name || "Linked thread";
|
|
184
184
|
const signals = links.raised.map((raised) => ({
|
|
185
185
|
step: raised.step,
|
|
@@ -194,7 +194,7 @@ function useConnectedThreadActivity(conversationId) {
|
|
|
194
194
|
if (links.startedBy) {
|
|
195
195
|
const { conversationId: parentId, step, signal } = links.startedBy;
|
|
196
196
|
const parent = conversations.find((c) => c.external_id === parentId);
|
|
197
|
-
const parentSteps =
|
|
197
|
+
const parentSteps = chunkVNUBBRJM_cjs.fromPlanSteps(parent?.plan?.steps ?? []);
|
|
198
198
|
startedBy = {
|
|
199
199
|
stepTitle: parentSteps.find((s) => s.id === step)?.title ?? step ?? "a step",
|
|
200
200
|
threadTitle: parent?.title || "another thread",
|
|
@@ -218,5 +218,5 @@ function useSelectWorkspace() {
|
|
|
218
218
|
|
|
219
219
|
exports.useConnectedThreadActivity = useConnectedThreadActivity;
|
|
220
220
|
exports.useSelectWorkspace = useSelectWorkspace;
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
222
|
-
//# sourceMappingURL=chunk-
|
|
221
|
+
//# sourceMappingURL=chunk-H3GJQSA5.cjs.map
|
|
222
|
+
//# sourceMappingURL=chunk-H3GJQSA5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/tasks/useConnectedThreadActivity.tsx","../src/connection/useSelectWorkspace.ts"],"names":["stepKindOf","STEP_KIND_ICONS","jsx","useWorkflows","useConversationItems","useWorkspaceUsers","useDocuments","useConversationActivity","useConversationData","useBlocksEnvironment","useOpenWorkflow","useAssistantCopy","useArbiSessionState","latestMessageTime","isSupersededStop","getUserDisplayName","fromPlanSteps","compactThreadActivity","splitDocRef","getDocumentTitle","unnotifiedMentions","parseCallLogDetail","ThreadCallLogCard","formatRelativeTime","RecordingCard","notifiedLabel","AssistantEntity","DocumentUser","Clock","formatFriendlyDate","linkedRunsFromActivity","useOptionalConnection","useSwitchWorkspace","useCallback"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA,IAAM,iBAAA,GAAuD;AAAA;AAAA,EAE3D,YAAA,EAAc,OAAA;AAAA,EACd,YAAA,EAAc,SAAA;AAAA,EACd,aAAA,EAAe,SAAA;AAAA,EACf,SAAA,EAAW,MAAA;AAAA,EACX,YAAA,EAAc,SAAA;AAAA,EACd,WAAA,EAAa,QAAA;AAAA,EACb,cAAA,EAAgB;AAClB,CAAA;AAGA,SAAS,UAAA,CACP,IAAA,EACA,SAAA,EACA,QAAA,EACA;AACA,EAAA,MAAM,KAAA,GAAQ,kBAAkB,SAAS,CAAA;AACzC,EAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,EAAA,MAAM,IAAA,GAAOA,6BAAW,IAAI,CAAA;AAC5B,EAAA,MAAM,QAAA,GAAWC,kCAAgB,IAAI,CAAA;AACrC,EAAA,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,sBAAMC,cAAA,CAAC,QAAA,EAAA,EAAS,GAAI,QAAA,EAAS;AACrD;AAQO,SAAS,2BAA2B,cAAA,EAA2C;AACpF,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,GAAY,EAAC,KAAMC,kBAAA,EAAa;AAC9C,EAAA,MAAM,EAAE,aAAA,EAAc,GAAIC,0BAAA,EAAqB;AAC/C,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,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,IAAI,CAAA,EAAG,KAAA,IAAS,IAAA,IAAQ,QAAA;AAAA,MACpE,WAAA,EAAa,QAAQ,KAAA,IAAS,gBAAA;AAAA,MAC9B,MAAA;AAAA,MACA,QAAA,EAAU,MAAM,sBAAA,CAAuB,QAAQ;AAAA,KACjD;AAAA,EACF;AACA,EAAA,OAAO,EAAE,QAAA,EAAU,KAAA,EAAO,OAAA,EAAS,SAAS,SAAA,EAAU;AACxD;AC1SO,SAAS,kBAAA,GAAoD;AAClE,EAAA,MAAM,aAAae,uCAAA,EAAsB;AACzC,EAAA,MAAM,EAAE,eAAA,EAAgB,GAAIC,wBAAA,EAAmB;AAC/C,EAAA,OAAOC,mBAAA;AAAA,IACL,OAAO,EAAA,KAAe;AACpB,MAAA,IAAI,UAAA,EAAY,OAAO,UAAA,CAAW,YAAA,CAAa,EAAE,CAAA;AACjD,MAAA,IAAI,CAAE,MAAM,eAAA,CAAgB,EAAE,EAAA,EAAI,CAAA,EAAI,MAAM,IAAI,KAAA,CAAM,8BAA8B,CAAA;AAAA,IACtF,CAAA;AAAA,IACA,CAAC,YAAY,eAAe;AAAA,GAC9B;AACF","file":"chunk-HX5SALXN.cjs","sourcesContent":["import {\n formatFriendlyDate,\n getDocumentTitle,\n getUserDisplayName,\n formatRelativeTime,\n} from '@arbidocs/react/ui'\nimport { Clock } from 'lucide-react'\nimport {\n useConversationActivity,\n useWorkflows,\n useDocuments,\n useWorkspaceUsers,\n useArbiSessionState,\n useConversationData,\n useConversationItems,\n} from '@arbidocs/react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { STEP_KIND_ICONS, stepKindOf } from '../../agents/workflows/stepKinds'\nimport { compactThreadActivity } from '../../agents/tasks/compact-thread-activity'\nimport { fromPlanSteps, type TaskPlanStep } from '../../agents/workflows/planSteps'\nimport { splitDocRef, type WorkflowStepPhase } from '../../agents/workflows/run'\nimport { type WorkflowStep } from '../../agents/workflows/types'\nimport { linkedRunsFromActivity } from '../../agents/tasks/linkedRuns'\nimport { type TaskActivityEvent } from '../../agents/tasks/TaskActivityTimeline'\nimport {\n type WorkflowThreadOrigin,\n type WorkflowThreadSignal,\n} from '../../agents/tasks/WorkflowThreadStrip'\nimport { ThreadCallLogCard } from '../../calls/connected/ThreadCallLogCard'\nimport { RecordingCard } from '../../calls/connected/RecordingCard'\nimport { parseCallLogDetail } from '../../calls/call-cards'\nimport { AssistantEntity } from '../../agents/tasks/AssistantEntity'\nimport {\n isSupersededStop,\n latestMessageTime,\n notifiedLabel,\n unnotifiedMentions,\n} from '../../agents/tasks/taskHelpers'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useOpenWorkflow } from '../workflows/useOpenWorkflow'\nimport { DocumentUser } from '../files/fields/DocumentUser'\n\n/** The phase a step event puts its step in, for its chip in the transcript. */\nconst STEP_EVENT_PHASES: Record<string, WorkflowStepPhase> = {\n // A past \"started\" is not still running: the step's own chip (on the bar) says where it is now.\n step_started: 'ready',\n step_waiting: 'waiting',\n step_progress: 'waiting',\n step_done: 'done',\n step_skipped: 'skipped',\n step_failed: 'failed',\n step_sent_back: 'ready',\n}\n\n/** A step event's chip in the transcript: its step's kind and icon, the phase the event set. */\nfunction stepChipOf(\n step: WorkflowStep,\n eventKind: string,\n document?: { name: string; onOpen: () => void }\n) {\n const phase = STEP_EVENT_PHASES[eventKind]\n if (!phase) return undefined\n const kind = stepKindOf(step)\n const KindIcon = STEP_KIND_ICONS[kind]\n return { kind, phase, icon: <KindIcon />, document }\n}\n\n/**\n * A thread's persisted history, as its top bar's ribbon and its transcript show it: each entry with\n * its actor, its step chip, the document or email it is about and where a click goes; the threads\n * linked to it (what started it, what it starts); the signals its steps raised. Documents,\n * threads, email drafts and workflows open through the host's environment.\n */\nexport function useConnectedThreadActivity(conversationId: string | null | undefined) {\n const { data: workflows = [] } = useWorkflows()\n const { conversations } = useConversationItems()\n const { data: members = [] } = useWorkspaceUsers()\n const { data: docs = [] } = useDocuments()\n const activity = useConversationActivity(conversationId ?? undefined, { live: true })\n const { messageHistory } = useConversationData()\n const environment = useBlocksEnvironment()\n const { openDocument, openMail } = environment\n const navigateToConversation = (id: string, messageId?: string) =>\n environment.openConversation(id, messageId ? { messageId } : undefined)\n // The host's Workflows page, while it has one (absent: a workflow has nowhere to open).\n const openWorkflow = useOpenWorkflow()\n const assistantCopy = useAssistantCopy()\n const workspaceExtId = useArbiSessionState((s) => s.workspaceId)\n const task = conversations.find((c) => c.external_id === conversationId)\n const latestMessageAt = latestMessageTime(messageHistory)\n const events = ((activity.data ?? []) as TaskActivityEvent[]).filter(\n (event) => !isSupersededStop(event, latestMessageAt)\n )\n const personName = (extId: string) => {\n const person = members.find((m) => m.user.external_id === extId)?.user\n return person ? getUserDisplayName(person) : 'someone'\n }\n // The run's steps, from its plan: step events are named after their step and drawn as its chip.\n const planSteps = fromPlanSteps((task?.plan?.steps ?? []) as TaskPlanStep[])\n const entries = compactThreadActivity(events, (id) => planSteps.find((s) => s.id === id)?.title)\n const items = entries.map(({ event, label, recipients }) => {\n const messageActivity = [\n 'created',\n 'participant_joined',\n 'assistant_responded',\n 'assistant_stopped',\n ].includes(event.kind)\n // A stop is about the assistant's turn (the event names no actor), so it is shown as ARBI's.\n const eventStep =\n event.kind.startsWith('step_') && typeof event.detail?.step === 'string'\n ? planSteps.find((s) => s.id === event.detail?.step)\n : undefined\n // A finished step's document (its latest version), one click from its chip in the transcript.\n const stepDocRef =\n event.kind === 'step_done' && Array.isArray(event.detail?.documents)\n ? (event.detail.documents as string[]).at(-1)\n : undefined\n const stepDocId = stepDocRef ? splitDocRef(stepDocRef).id : undefined\n const stepDocRecord = stepDocId ? docs.find((d) => d.external_id === stepDocId) : undefined\n const stepDocument = stepDocId\n ? {\n name: stepDocRecord ? getDocumentTitle(stepDocRecord) : stepDocId,\n onOpen: () => openDocument(stepDocId),\n }\n : undefined\n // An AI step's progress is ARBI's, whoever started the run.\n const assistant =\n event.kind === 'assistant_responded' ||\n event.kind === 'assistant_stopped' ||\n event.detail?.assistant === true ||\n eventStep?.kind === 'agent'\n const member = members.find(\n (m) =>\n m.user.external_id ===\n (event.actor_ext_id ?? (event.kind === 'created' ? task?.created_by_ext_id : undefined))\n )?.user\n const name = assistant ? assistantCopy.name : member ? getUserDisplayName(member) : 'System'\n const docId = typeof event.detail?.doc_ext_id === 'string' ? event.detail.doc_ext_id : undefined\n const sourceMessage =\n typeof event.detail?.message_ext_id === 'string' ? event.detail.message_ext_id : undefined\n const messageId =\n sourceMessage ??\n [...messageHistory]\n .reverse()\n .find((message) => Date.parse(message.created_at ?? '') <= Date.parse(event.created_at))\n ?.external_id ??\n messageHistory[0]?.external_id\n const doc = docId ? docs.find((d) => d.external_id === docId) : undefined\n // A draft email an agent left in the user's native mailbox: the entry opens it in Mail.\n const mailDraftId =\n event.kind === 'notified' &&\n event.detail?.event === 'mail_draft_ready' &&\n typeof event.detail?.mail_id === 'string'\n ? event.detail.mail_id\n : undefined\n // Say who a batch reached, and name any @mentioned person it did not, so nobody has to guess.\n const missed =\n event.kind === 'notified' && recipients.length\n ? unnotifiedMentions(\n messageHistory.find((message) => message.external_id === sourceMessage)?.mentions,\n recipients,\n event.actor_ext_id\n )\n : []\n // A thread call: the server's log card (live → Join, ended → summary + meeting chat).\n const callDetail = event.kind === 'call' ? parseCallLogDetail(event.detail) : null\n // A recording of the thread's call stopped: its Recording card (in a meeting thread).\n const recordingCall =\n event.kind === 'recording' && typeof event.detail?.call_ext_id === 'string'\n ? event.detail.call_ext_id\n : null\n const recordingId =\n typeof event.detail?.recording_ext_id === 'string' ? event.detail.recording_ext_id : null\n return {\n id: event.external_id,\n kind: event.kind,\n // A workflow step event: the step it is about (the thread's step strip places entries by it).\n step: typeof event.detail?.step === 'string' ? event.detail.step : undefined,\n createdAt: event.created_at,\n card: callDetail ? (\n <ThreadCallLogCard\n detail={callDetail}\n name={personName}\n workspaceExtId={workspaceExtId}\n time={formatRelativeTime(event.created_at, { style: 'short' })}\n />\n ) : recordingCall ? (\n <RecordingCard\n callExtId={recordingCall}\n recordingExtId={recordingId}\n title={task?.title}\n time={formatRelativeTime(event.created_at, { style: 'short' })}\n />\n ) : undefined,\n docId,\n docTitle: doc ? getDocumentTitle(doc) : undefined,\n label: mailDraftId\n ? 'Left a draft email'\n : event.kind === 'notified' && recipients.length\n ? notifiedLabel(recipients.map(personName), missed.map(personName))\n : label,\n description: [\n name,\n label,\n ...recipients.map((id) => {\n const person = members.find((m) => m.user.external_id === id)?.user\n return person ? getUserDisplayName(person) : id\n }),\n doc ? getDocumentTitle(doc) : null,\n ]\n .filter(Boolean)\n .join(' · '),\n actor: assistant ? 'assistant' : (member?.external_id ?? 'system'),\n stepChip: eventStep ? stepChipOf(eventStep, event.kind, stepDocument) : undefined,\n // No avatar tooltip: the entry is already a button (or titled row) that carries the same\n // details, and a tooltip trigger inside it would be a nested <button>.\n avatar: assistant ? (\n <AssistantEntity variant=\"icon\" size={20} showTooltip={false} />\n ) : member ? (\n <DocumentUser user={member} tooltip={false} />\n ) : (\n <Clock className=\"size-4 text-muted-foreground\" />\n ),\n time: formatRelativeTime(event.created_at, { style: 'short' }),\n exactTime: formatFriendlyDate(event.created_at),\n onOpenDocument: docId && doc ? () => openDocument(docId) : undefined,\n onSelect: () => {\n if (mailDraftId && openMail) {\n openMail({ draftId: mailDraftId })\n return\n }\n const target = messageActivity ? messageId : event.external_id\n // The deep link selects the thread the message is on (useConversationData).\n if (target) navigateToConversation(conversationId!, target)\n },\n }\n })\n const related = workflows\n .filter((workflow) => workflow.after_conversation_ext_id === conversationId)\n .map((workflow) => {\n const next = conversations.find(\n (conversation) => conversation.workflow_ext_id === workflow.external_id\n )\n return {\n id: workflow.external_id,\n label: next?.title || workflow.name,\n title: 'Starts when this thread is done',\n onSelect: () => {\n if (next) navigateToConversation(next.external_id)\n else openWorkflow?.(workflow.external_id)\n },\n }\n })\n // The run's workflow, opened in the builder: the same steps, as designed. Only where Workflows\n // is on (otherwise there is no page to open it on).\n const origin = openWorkflow\n ? workflows.find((workflow) => workflow.external_id === task?.workflow_ext_id)\n : undefined\n if (origin && openWorkflow)\n related.unshift({\n id: `origin-${origin.external_id}`,\n label: origin.name,\n title: 'Open the workflow in the builder',\n onSelect: () => openWorkflow(origin.external_id),\n })\n const source = workflows.find(\n (workflow) => workflow.external_id === task?.workflow_ext_id\n )?.after_conversation_ext_id\n if (source) {\n const before = conversations.find((conversation) => conversation.external_id === source)\n if (before)\n related.unshift({\n id: source,\n label: before.title || 'Previous thread',\n title: 'Started when this thread was done',\n onSelect: () => navigateToConversation(source),\n })\n }\n // Linked runs: the signals this thread's steps raised and the threads they started, and, for a\n // thread a signal started, the step and thread it came from.\n const links = linkedRunsFromActivity(activity.data as TaskActivityEvent[] | undefined)\n const threadName = (id: string, workflowId?: string) =>\n conversations.find((c) => c.external_id === id)?.title ||\n workflows.find((w) => w.external_id === workflowId)?.name ||\n 'Linked thread'\n const signals: WorkflowThreadSignal[] = links.raised.map((raised) => ({\n step: raised.step,\n signal: raised.signal,\n runs: raised.runs.map((run) => ({\n id: run.conversationId,\n label: threadName(run.conversationId, run.workflowId),\n onSelect: () => navigateToConversation(run.conversationId),\n })),\n }))\n let startedBy: WorkflowThreadOrigin | undefined\n if (links.startedBy) {\n const { conversationId: parentId, step, signal } = links.startedBy\n const parent = conversations.find((c) => c.external_id === parentId)\n const parentSteps = fromPlanSteps((parent?.plan?.steps ?? []) as TaskPlanStep[])\n startedBy = {\n stepTitle: parentSteps.find((s) => s.id === step)?.title ?? step ?? 'a step',\n threadTitle: parent?.title || 'another thread',\n signal,\n onSelect: () => navigateToConversation(parentId),\n }\n }\n return { activity, items, related, signals, startedBy }\n}\n","import { useCallback } from 'react'\nimport { useSwitchWorkspace } from '@arbidocs/react'\nimport { useOptionalConnection } from './ConnectionProvider'\n\n/**\n * Select a workspace in place, through the sign-in layer when there is one (else the host's own\n * session switch): the page on screen stays, unlike `openWorkspace`, which also shows the\n * workspace. Rejects when it could not be opened.\n */\nexport function useSelectWorkspace(): (id: string) => Promise<void> {\n const connection = useOptionalConnection()\n const { switchWorkspace } = useSwitchWorkspace()\n return useCallback(\n async (id: string) => {\n if (connection) return connection.setWorkspace(id)\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n },\n [connection, switchWorkspace]\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/tasks/useConnectedThreadActivity.tsx","../src/connection/useSelectWorkspace.ts"],"names":["stepKindOf","STEP_KIND_ICONS","jsx","useWorkflows","useConversationItems","useWorkspaceUsers","useDocuments","useConversationActivity","useConversationData","useBlocksEnvironment","useOpenWorkflow","useAssistantCopy","useArbiSessionState","latestMessageTime","isSupersededStop","getUserDisplayName","fromPlanSteps","compactThreadActivity","splitDocRef","getDocumentTitle","unnotifiedMentions","parseCallLogDetail","ThreadCallLogCard","formatRelativeTime","RecordingCard","notifiedLabel","AssistantEntity","DocumentUser","Clock","formatFriendlyDate","linkedRunsFromActivity","useOptionalConnection","useSwitchWorkspace","useCallback"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA,IAAM,iBAAA,GAAuD;AAAA;AAAA,EAE3D,YAAA,EAAc,OAAA;AAAA,EACd,YAAA,EAAc,SAAA;AAAA,EACd,aAAA,EAAe,SAAA;AAAA,EACf,SAAA,EAAW,MAAA;AAAA,EACX,YAAA,EAAc,SAAA;AAAA,EACd,WAAA,EAAa,QAAA;AAAA,EACb,cAAA,EAAgB;AAClB,CAAA;AAGA,SAAS,UAAA,CACP,IAAA,EACA,SAAA,EACA,QAAA,EACA;AACA,EAAA,MAAM,KAAA,GAAQ,kBAAkB,SAAS,CAAA;AACzC,EAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,EAAA,MAAM,IAAA,GAAOA,6BAAW,IAAI,CAAA;AAC5B,EAAA,MAAM,QAAA,GAAWC,kCAAgB,IAAI,CAAA;AACrC,EAAA,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,sBAAMC,cA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S,aAAA,CAAc,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,gBAAgB,QAAQ,CAAA;AACnE,IAAA,MAAM,cAAcd,+BAAA,CAAe,MAAA,EAAQ,IAAA,EAAM,KAAA,IAAS,EAAqB,CAAA;AAC/E,IAAA,SAAA,GAAY;AAAA,MACV,SAAA,EAAW,WAAA,CAAY,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,IAAI,CAAA,EAAG,KAAA,IAAS,IAAA,IAAQ,QAAA;AAAA,MACpE,WAAA,EAAa,QAAQ,KAAA,IAAS,gBAAA;AAAA,MAC9B,MAAA;AAAA,MACA,QAAA,EAAU,MAAM,sBAAA,CAAuB,QAAQ;AAAA,KACjD;AAAA,EACF;AACA,EAAA,OAAO,EAAE,QAAA,EAAU,KAAA,EAAO,OAAA,EAAS,SAAS,SAAA,EAAU;AACxD;AC1SO,SAAS,kBAAA,GAAoD;AAClE,EAAA,MAAM,aAAae,uCAAA,EAAsB;AACzC,EAAA,MAAM,EAAE,eAAA,EAAgB,GAAIC,wBAAA,EAAmB;AAC/C,EAAA,OAAOC,mBAAA;AAAA,IACL,OAAO,EAAA,KAAe;AACpB,MAAA,IAAI,UAAA,EAAY,OAAO,UAAA,CAAW,YAAA,CAAa,EAAE,CAAA;AACjD,MAAA,IAAI,CAAE,MAAM,eAAA,CAAgB,EAAE,EAAA,EAAI,CAAA,EAAI,MAAM,IAAI,KAAA,CAAM,8BAA8B,CAAA;AAAA,IACtF,CAAA;AAAA,IACA,CAAC,YAAY,eAAe;AAAA,GAC9B;AACF","file":"chunk-H3GJQSA5.cjs","sourcesContent":["import {\n formatFriendlyDate,\n getDocumentTitle,\n getUserDisplayName,\n formatRelativeTime,\n} from '@arbidocs/react/ui'\nimport { Clock } from 'lucide-react'\nimport {\n useConversationActivity,\n useWorkflows,\n useDocuments,\n useWorkspaceUsers,\n useArbiSessionState,\n useConversationData,\n useConversationItems,\n} from '@arbidocs/react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { STEP_KIND_ICONS, stepKindOf } from '../../agents/workflows/stepKinds'\nimport { compactThreadActivity } from '../../agents/tasks/compact-thread-activity'\nimport { fromPlanSteps, type TaskPlanStep } from '../../agents/workflows/planSteps'\nimport { splitDocRef, type WorkflowStepPhase } from '../../agents/workflows/run'\nimport { type WorkflowStep } from '../../agents/workflows/types'\nimport { linkedRunsFromActivity } from '../../agents/tasks/linkedRuns'\nimport { type TaskActivityEvent } from '../../agents/tasks/TaskActivityTimeline'\nimport {\n type WorkflowThreadOrigin,\n type WorkflowThreadSignal,\n} from '../../agents/tasks/WorkflowThreadStrip'\nimport { ThreadCallLogCard } from '../../calls/connected/ThreadCallLogCard'\nimport { RecordingCard } from '../../calls/connected/RecordingCard'\nimport { parseCallLogDetail } from '../../calls/call-cards'\nimport { AssistantEntity } from '../../agents/tasks/AssistantEntity'\nimport {\n isSupersededStop,\n latestMessageTime,\n notifiedLabel,\n unnotifiedMentions,\n} from '../../agents/tasks/taskHelpers'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useOpenWorkflow } from '../workflows/useOpenWorkflow'\nimport { DocumentUser } from '../files/fields/DocumentUser'\n\n/** The phase a step event puts its step in, for its chip in the transcript. */\nconst STEP_EVENT_PHASES: Record<string, WorkflowStepPhase> = {\n // A past \"started\" is not still running: the step's own chip (on the bar) says where it is now.\n step_started: 'ready',\n step_waiting: 'waiting',\n step_progress: 'waiting',\n step_done: 'done',\n step_skipped: 'skipped',\n step_failed: 'failed',\n step_sent_back: 'ready',\n}\n\n/** A step event's chip in the transcript: its step's kind and icon, the phase the event set. */\nfunction stepChipOf(\n step: WorkflowStep,\n eventKind: string,\n document?: { name: string; onOpen: () => void }\n) {\n const phase = STEP_EVENT_PHASES[eventKind]\n if (!phase) return undefined\n const kind = stepKindOf(step)\n const KindIcon = STEP_KIND_ICONS[kind]\n return { kind, phase, icon: <KindIcon />, document }\n}\n\n/**\n * A thread's persisted history, as its top bar's ribbon and its transcript show it: each entry with\n * its actor, its step chip, the document or email it is about and where a click goes; the threads\n * linked to it (what started it, what it starts); the signals its steps raised. Documents,\n * threads, email drafts and workflows open through the host's environment.\n */\nexport function useConnectedThreadActivity(conversationId: string | null | undefined) {\n const { data: workflows = [] } = useWorkflows()\n const { conversations } = useConversationItems()\n const { data: members = [] } = useWorkspaceUsers()\n const { data: docs = [] } = useDocuments()\n const activity = useConversationActivity(conversationId ?? undefined, { live: true })\n const { messageHistory } = useConversationData()\n const environment = useBlocksEnvironment()\n const { openDocument, openMail } = environment\n const navigateToConversation = (id: string, messageId?: string) =>\n environment.openConversation(id, messageId ? { messageId } : undefined)\n // The host's Workflows page, while it has one (absent: a workflow has nowhere to open).\n const openWorkflow = useOpenWorkflow()\n const assistantCopy = useAssistantCopy()\n const workspaceExtId = useArbiSessionState((s) => s.workspaceId)\n const task = conversations.find((c) => c.external_id === conversationId)\n const latestMessageAt = latestMessageTime(messageHistory)\n const events = ((activity.data ?? []) as TaskActivityEvent[]).filter(\n (event) => !isSupersededStop(event, latestMessageAt)\n )\n const personName = (extId: string) => {\n const person = members.find((m) => m.user.external_id === extId)?.user\n return person ? getUserDisplayName(person) : 'someone'\n }\n // The run's steps, from its plan: step events are named after their step and drawn as its chip.\n const planSteps = fromPlanSteps((task?.plan?.steps ?? []) as TaskPlanStep[])\n const entries = compactThreadActivity(events, (id) => planSteps.find((s) => s.id === id)?.title)\n const items = entries.map(({ event, label, recipients }) => {\n const messageActivity = [\n 'created',\n 'participant_joined',\n 'assistant_responded',\n 'assistant_stopped',\n ].includes(event.kind)\n // A stop is about the assistant's turn (the event names no actor), so it is shown as ARBI's.\n const eventStep =\n event.kind.startsWith('step_') && typeof event.detail?.step === 'string'\n ? planSteps.find((s) => s.id === event.detail?.step)\n : undefined\n // A finished step's document (its latest version), one click from its chip in the transcript.\n const stepDocRef =\n event.kind === 'step_done' && Array.isArray(event.detail?.documents)\n ? (event.detail.documents as string[]).at(-1)\n : undefined\n const stepDocId = stepDocRef ? splitDocRef(stepDocRef).id : undefined\n const stepDocRecord = stepDocId ? docs.find((d) => d.external_id === stepDocId) : undefined\n const stepDocument = stepDocId\n ? {\n name: stepDocRecord ? getDocumentTitle(stepDocRecord) : stepDocId,\n onOpen: () => openDocument(stepDocId),\n }\n : undefined\n // An AI step's progress is ARBI's, whoever started the run.\n const assistant =\n event.kind === 'assistant_responded' ||\n event.kind === 'assistant_stopped' ||\n event.detail?.assistant === true ||\n eventStep?.kind === 'agent'\n const member = members.find(\n (m) =>\n m.user.external_id ===\n (event.actor_ext_id ?? (event.kind === 'created' ? task?.created_by_ext_id : undefined))\n )?.user\n const name = assistant ? assistantCopy.name : member ? getUserDisplayName(member) : 'System'\n const docId = typeof event.detail?.doc_ext_id === 'string' ? event.detail.doc_ext_id : undefined\n const sourceMessage =\n typeof event.detail?.message_ext_id === 'string' ? event.detail.message_ext_id : undefined\n const messageId =\n sourceMessage ??\n [...messageHistory]\n .reverse()\n .find((message) => Date.parse(message.created_at ?? '') <= Date.parse(event.created_at))\n ?.external_id ??\n messageHistory[0]?.external_id\n const doc = docId ? docs.find((d) => d.external_id === docId) : undefined\n // A draft email an agent left in the user's native mailbox: the entry opens it in Mail.\n const mailDraftId =\n event.kind === 'notified' &&\n event.detail?.event === 'mail_draft_ready' &&\n typeof event.detail?.mail_id === 'string'\n ? event.detail.mail_id\n : undefined\n // Say who a batch reached, and name any @mentioned person it did not, so nobody has to guess.\n const missed =\n event.kind === 'notified' && recipients.length\n ? unnotifiedMentions(\n messageHistory.find((message) => message.external_id === sourceMessage)?.mentions,\n recipients,\n event.actor_ext_id\n )\n : []\n // A thread call: the server's log card (live → Join, ended → summary + meeting chat).\n const callDetail = event.kind === 'call' ? parseCallLogDetail(event.detail) : null\n // A recording of the thread's call stopped: its Recording card (in a meeting thread).\n const recordingCall =\n event.kind === 'recording' && typeof event.detail?.call_ext_id === 'string'\n ? event.detail.call_ext_id\n : null\n const recordingId =\n typeof event.detail?.recording_ext_id === 'string' ? event.detail.recording_ext_id : null\n return {\n id: event.external_id,\n kind: event.kind,\n // A workflow step event: the step it is about (the thread's step strip places entries by it).\n step: typeof event.detail?.step === 'string' ? event.detail.step : undefined,\n createdAt: event.created_at,\n card: callDetail ? (\n <ThreadCallLogCard\n detail={callDetail}\n name={personName}\n workspaceExtId={workspaceExtId}\n time={formatRelativeTime(event.created_at, { style: 'short' })}\n />\n ) : recordingCall ? (\n <RecordingCard\n callExtId={recordingCall}\n recordingExtId={recordingId}\n title={task?.title}\n time={formatRelativeTime(event.created_at, { style: 'short' })}\n />\n ) : undefined,\n docId,\n docTitle: doc ? getDocumentTitle(doc) : undefined,\n label: mailDraftId\n ? 'Left a draft email'\n : event.kind === 'notified' && recipients.length\n ? notifiedLabel(recipients.map(personName), missed.map(personName))\n : label,\n description: [\n name,\n label,\n ...recipients.map((id) => {\n const person = members.find((m) => m.user.external_id === id)?.user\n return person ? getUserDisplayName(person) : id\n }),\n doc ? getDocumentTitle(doc) : null,\n ]\n .filter(Boolean)\n .join(' · '),\n actor: assistant ? 'assistant' : (member?.external_id ?? 'system'),\n stepChip: eventStep ? stepChipOf(eventStep, event.kind, stepDocument) : undefined,\n // No avatar tooltip: the entry is already a button (or titled row) that carries the same\n // details, and a tooltip trigger inside it would be a nested <button>.\n avatar: assistant ? (\n <AssistantEntity variant=\"icon\" size={20} showTooltip={false} />\n ) : member ? (\n <DocumentUser user={member} tooltip={false} />\n ) : (\n <Clock className=\"size-4 text-muted-foreground\" />\n ),\n time: formatRelativeTime(event.created_at, { style: 'short' }),\n exactTime: formatFriendlyDate(event.created_at),\n onOpenDocument: docId && doc ? () => openDocument(docId) : undefined,\n onSelect: () => {\n if (mailDraftId && openMail) {\n openMail({ draftId: mailDraftId })\n return\n }\n const target = messageActivity ? messageId : event.external_id\n // The deep link selects the thread the message is on (useConversationData).\n if (target) navigateToConversation(conversationId!, target)\n },\n }\n })\n const related = workflows\n .filter((workflow) => workflow.after_conversation_ext_id === conversationId)\n .map((workflow) => {\n const next = conversations.find(\n (conversation) => conversation.workflow_ext_id === workflow.external_id\n )\n return {\n id: workflow.external_id,\n label: next?.title || workflow.name,\n title: 'Starts when this thread is done',\n onSelect: () => {\n if (next) navigateToConversation(next.external_id)\n else openWorkflow?.(workflow.external_id)\n },\n }\n })\n // The run's workflow, opened in the builder: the same steps, as designed. Only where Workflows\n // is on (otherwise there is no page to open it on).\n const origin = openWorkflow\n ? workflows.find((workflow) => workflow.external_id === task?.workflow_ext_id)\n : undefined\n if (origin && openWorkflow)\n related.unshift({\n id: `origin-${origin.external_id}`,\n label: origin.name,\n title: 'Open the workflow in the builder',\n onSelect: () => openWorkflow(origin.external_id),\n })\n const source = workflows.find(\n (workflow) => workflow.external_id === task?.workflow_ext_id\n )?.after_conversation_ext_id\n if (source) {\n const before = conversations.find((conversation) => conversation.external_id === source)\n if (before)\n related.unshift({\n id: source,\n label: before.title || 'Previous thread',\n title: 'Started when this thread was done',\n onSelect: () => navigateToConversation(source),\n })\n }\n // Linked runs: the signals this thread's steps raised and the threads they started, and, for a\n // thread a signal started, the step and thread it came from.\n const links = linkedRunsFromActivity(activity.data as TaskActivityEvent[] | undefined)\n const threadName = (id: string, workflowId?: string) =>\n conversations.find((c) => c.external_id === id)?.title ||\n workflows.find((w) => w.external_id === workflowId)?.name ||\n 'Linked thread'\n const signals: WorkflowThreadSignal[] = links.raised.map((raised) => ({\n step: raised.step,\n signal: raised.signal,\n runs: raised.runs.map((run) => ({\n id: run.conversationId,\n label: threadName(run.conversationId, run.workflowId),\n onSelect: () => navigateToConversation(run.conversationId),\n })),\n }))\n let startedBy: WorkflowThreadOrigin | undefined\n if (links.startedBy) {\n const { conversationId: parentId, step, signal } = links.startedBy\n const parent = conversations.find((c) => c.external_id === parentId)\n const parentSteps = fromPlanSteps((parent?.plan?.steps ?? []) as TaskPlanStep[])\n startedBy = {\n stepTitle: parentSteps.find((s) => s.id === step)?.title ?? step ?? 'a step',\n threadTitle: parent?.title || 'another thread',\n signal,\n onSelect: () => navigateToConversation(parentId),\n }\n }\n return { activity, items, related, signals, startedBy }\n}\n","import { useCallback } from 'react'\nimport { useSwitchWorkspace } from '@arbidocs/react'\nimport { useOptionalConnection } from './ConnectionProvider'\n\n/**\n * Select a workspace in place, through the sign-in layer when there is one (else the host's own\n * session switch): the page on screen stays, unlike `openWorkspace`, which also shows the\n * workspace. Rejects when it could not be opened.\n */\nexport function useSelectWorkspace(): (id: string) => Promise<void> {\n const connection = useOptionalConnection()\n const { switchWorkspace } = useSwitchWorkspace()\n return useCallback(\n async (id: string) => {\n if (connection) return connection.setWorkspace(id)\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n },\n [connection, switchWorkspace]\n )\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkYZ6SFKUO_cjs = require('./chunk-YZ6SFKUO.cjs');
|
|
5
5
|
var zustand = require('zustand');
|
|
6
6
|
var middleware = require('zustand/middleware');
|
|
7
7
|
|
|
@@ -50,7 +50,7 @@ var useFilesPrefs = zustand.create()(
|
|
|
50
50
|
(state) => state.viewModes[prefsKey] === viewMode ? state : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }
|
|
51
51
|
),
|
|
52
52
|
// New users start at the compact minimum (more rows at once).
|
|
53
|
-
rowHeight:
|
|
53
|
+
rowHeight: chunkYZ6SFKUO_cjs.DOCUMENTS_ROW_HEIGHT_INITIAL,
|
|
54
54
|
setRowHeight: (rowHeight) => set({ rowHeight })
|
|
55
55
|
}),
|
|
56
56
|
{
|
|
@@ -121,5 +121,5 @@ exports.useFilesGridStates = useFilesGridStates;
|
|
|
121
121
|
exports.useFilesPrefs = useFilesPrefs;
|
|
122
122
|
exports.useFilesStore = useFilesStore;
|
|
123
123
|
exports.usePendingFolders = usePendingFolders;
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-INVL4BE7.cjs.map
|
|
125
|
+
//# sourceMappingURL=chunk-INVL4BE7.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/files/store.ts"],"names":["create","persist","createJSONStorage","DOCUMENTS_ROW_HEIGHT_INITIAL"],"mappings":";;;;;;AAmBO,IAAM,gBAAgBA,cAAA,EAAmB;AAAA,EAC9CC,kBAAA;AAAA,IACE,CAAC,GAAA,MAAS;AAAA,MACR,gBAAgB,EAAC;AAAA,MACjB,kBAAkB,CAAC,WAAA,EAAa,IAAA,KAC9B,GAAA,CAAI,CAAC,KAAA,KAAU;AACb,QAAA,MAAM,OAAA,GAAU,KAAA,CAAM,cAAA,CAAe,WAAW,KAAK,EAAC;AACtD,QAAA,IAAI,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,EAAG,OAAO,KAAA;AACnC,QAAA,OAAO,EAAE,cAAA,EAAgB,EAAE,GAAG,MAAM,cAAA,EAAgB,CAAC,WAAW,GAAG,CAAC,GAAG,OAAA,EAAS,IAAI,GAAE,EAAE;AAAA,MAC1F,CAAC,CAAA;AAAA,MACH,qBAAqB,CAAC,WAAA,EAAa,IAAA,KACjC,GAAA,CAAI,CAAC,KAAA,KAAU;AACb,QAAA,MAAM,OAAA,GAAU,KAAA,CAAM,cAAA,CAAe,WAAW,KAAK,EAAC;AACtD,QAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,IAAI,GAAG,OAAO,KAAA;AACpC,QAAA,OAAO;AAAA,UACL,cAAA,EAAgB;AAAA,YACd,GAAG,KAAA,CAAM,cAAA;AAAA,YACT,CAAC,WAAW,GAAG,OAAA,CAAQ,OAAO,CAAC,CAAA,KAAM,MAAM,IAAI;AAAA;AACjD,SACF;AAAA,MACF,CAAC;AAAA,KACL,CAAA;AAAA,IACA;AAAA,MACE,IAAA,EAAM,+BAAA;AAAA,MACN,OAAA,EAASC,4BAAA,CAAkB,MAAM,cAAc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A;AAC/B,IAAA,OAAO,EAAE,GAAA,EAAK,EAAE,GAAG,GAAA,EAAK,cAAA,EAAgB,CAAC,GAAG,QAAA,EAAU,GAAG,KAAK,CAAA,EAAE,EAAE;AAAA,EACpE,CAAC;AACL,CAAA,CAAE;AASK,IAAM,qBAAqBA,cAAA,EAAwB;AAAA,EACxDC,kBAAA;AAAA,IACE,CAAC,GAAA,MAAS;AAAA,MACR,YAAY,EAAC;AAAA,MACb,cAAc,CAAC,MAAA,EAAQ,UACrB,GAAA,CAAI,CAAC,aAAa,EAAE,UAAA,EAAY,EAAE,GAAG,QAAQ,UAAA,EAAY,CAAC,MAAM,GAAG,KAAA,IAAQ,CAAE;AAAA,KACjF,CAAA;AAAA,IACA,EAAE,IAAA,EAAM,kBAAA,EAAoB,SAASC,4BAAA,CAAkB,MAAM,YAAY,CAAA;AAAE;AAE/E;AA0BO,IAAM,eAAA,GAAkBF,cAAA,EAA0B,CAAE,CAAC,GAAA,MAAS;AAAA,EACnE,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,CAAC,MAAA,GAAS,IAAA,KAAS,GAAA,CAAI,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO,EAAG,CAAA;AAAA,EACrD,WAAW,MAAM,GAAA,CAAI,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,EACnC,YAAA,EAAc,KAAA;AAAA,EACd,iBAAiB,CAAC,YAAA,KAAiB,GAAA,CAAI,EAAE,cAAc,CAAA;AAAA,EACvD,aAAA,EAAe,IAAA;AAAA,EACf,eAAe,CAAC,aAAA,KAAkB,GAAA,CAAI,EAAE,eAAe,CAAA;AAAA,EACvD,UAAA,EAAY,KAAA;AAAA,EACZ,eAAe,CAAC,UAAA,KAAe,GAAA,CAAI,EAAE,YAAY;AACnD,CAAA,CAAE","file":"chunk-TQATDAJV.cjs","sourcesContent":["/**\n * The Files kits' own state: empty folders the user created (a folder exists only through its\n * documents, so a new one is a placeholder until something is moved into it), per workspace, for\n * the session (kept in `sessionStorage`, so a reload keeps them).\n */\n\nimport type { GridState } from 'ag-grid-community'\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { DOCUMENTS_ROW_HEIGHT_INITIAL } from '../../files/documentColumns'\nimport type { ExplorerFolder } from '../../files/folders/folderPaths'\n\ninterface FilesState {\n /** Placeholder folder paths per workspace. */\n pendingFolders: Readonly<Record<string, readonly string[]>>\n addPendingFolder: (workspaceId: string, path: string) => void\n removePendingFolder: (workspaceId: string, path: string) => void\n}\n\nexport const useFilesStore = create<FilesState>()(\n persist(\n (set) => ({\n pendingFolders: {},\n addPendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (current.includes(path)) return state\n return { pendingFolders: { ...state.pendingFolders, [workspaceId]: [...current, path] } }\n }),\n removePendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (!current.includes(path)) return state\n return {\n pendingFolders: {\n ...state.pendingFolders,\n [workspaceId]: current.filter((p) => p !== path),\n },\n }\n }),\n }),\n {\n name: 'arbi_explorer_pending_folders',\n storage: createJSONStorage(() => sessionStorage),\n partialize: (state) => ({ pendingFolders: state.pendingFolders }),\n }\n )\n)\n\nconst NONE: readonly string[] = []\n\n/** A workspace's placeholder folders. */\nexport function usePendingFolders(workspaceId: string | null | undefined): readonly string[] {\n return useFilesStore(\n (state) => (workspaceId ? state.pendingFolders[workspaceId] : undefined) ?? NONE\n )\n}\n\n/** How the files page shows the documents: a table, the explorer, review one by one, or search. */\nexport type FilesViewMode = 'grid' | 'explorer' | 'navigator' | 'search'\n\n/** The files page's own preferences key (`ConnectedFilesPage` `prefsKey`). */\nexport const FILES_PREFS_KEY = 'files'\nconst DEFAULT_VIEW_MODE: FilesViewMode = 'explorer'\n\ninterface FilesPrefsState {\n /** The documents list's tri-state filters (filter id → include / exclude / off). */\n documentFilters: Readonly<Record<string, 'include' | 'exclude' | null>>\n setDocumentFilters: (filters: Record<string, 'include' | 'exclude' | null>) => void\n /**\n * Each files page's view, by its `prefsKey` (a page that is the same kit in another role, e.g.\n * a tabular review in the table view, keeps its own). Absent: that page's default.\n */\n viewModes: Readonly<Record<string, FilesViewMode>>\n /** Set a page's view (default: the files page's). */\n setViewMode: (mode: FilesViewMode, prefsKey?: string) => void\n /** The table's row height (density). */\n rowHeight: number\n setRowHeight: (height: number) => void\n}\n\n/** The Files kits' preferences, kept on this device (`localStorage`) across sessions. */\nexport const useFilesPrefs = create<FilesPrefsState>()(\n persist(\n (set) => ({\n documentFilters: {},\n setDocumentFilters: (documentFilters) => set({ documentFilters }),\n viewModes: {},\n setViewMode: (viewMode, prefsKey = FILES_PREFS_KEY) =>\n set((state) =>\n state.viewModes[prefsKey] === viewMode\n ? state\n : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }\n ),\n // New users start at the compact minimum (more rows at once).\n rowHeight: DOCUMENTS_ROW_HEIGHT_INITIAL,\n setRowHeight: (rowHeight) => set({ rowHeight }),\n }),\n {\n name: 'arbi_files_prefs',\n storage: createJSONStorage(() => localStorage),\n version: 1,\n // Version 0 kept one view for every files page: it becomes the files page's own.\n migrate: (persisted, version) => {\n const state = (persisted ?? {}) as Record<string, unknown>\n if (version >= 1) return state as Partial<FilesPrefsState>\n const { viewMode, ...rest } = state\n return {\n ...rest,\n viewModes: viewMode ? { [FILES_PREFS_KEY]: viewMode as FilesViewMode } : {},\n } as Partial<FilesPrefsState>\n },\n partialize: (state) => ({\n documentFilters: state.documentFilters,\n viewModes: state.viewModes,\n rowHeight: state.rowHeight,\n }),\n }\n )\n)\n\n/** A files page's view (`prefsKey`, default the files page's), else its `defaultViewMode`. */\nexport function filesViewMode(\n state: Pick<FilesPrefsState, 'viewModes'>,\n prefsKey: string = FILES_PREFS_KEY,\n defaultViewMode: FilesViewMode = DEFAULT_VIEW_MODE\n): FilesViewMode {\n return state.viewModes[prefsKey] ?? defaultViewMode\n}\n\n/** An AI review run: the fields, the documents, and which of them the server finished. */\nexport interface AiReviewRun {\n tags: { id: string; name: string }[]\n docIds: string[]\n /** The documents the server finished (a finished cell with no value will not fill). */\n finishedDocIds?: string[]\n /** It replaces values already there: a cell shows its new value only once finished. */\n replacing?: boolean\n}\n\ninterface AiReviewState {\n /** The AI review dialog is open. */\n open: boolean\n /** The run on screen, kept after closing so \"View results\" can bring the answers back. */\n run: AiReviewRun | null\n setOpen: (open: boolean) => void\n setRun: (run: AiReviewRun | null) => void\n /** The server finished these documents of the run (with or without a value). */\n markFinished: (docIds: string[]) => void\n}\n\n/** The AI review dialog and its run, reachable from outside React (a finished-run notice). */\nexport const useAiReviewStore = create<AiReviewState>()((set) => ({\n open: false,\n run: null,\n setOpen: (open) => set({ open }),\n setRun: (run) => set({ run }),\n markFinished: (docIds) =>\n set((state) => {\n const run = state.run\n if (!run) return state\n const finished = new Set(run.finishedDocIds ?? [])\n const added = docIds.filter((id) => run.docIds.includes(id) && !finished.has(id))\n if (added.length === 0) return state\n return { run: { ...run, finishedDocIds: [...finished, ...added] } }\n }),\n}))\n\ninterface GridStatesState {\n /** AG Grid's saved state (columns, widths, sort) per grid id. */\n gridStates: Readonly<Record<string, GridState>>\n setGridState: (gridId: string, state: GridState) => void\n}\n\n/** The Files grids' saved state, kept on this device, for hosts that keep none of their own. */\nexport const useFilesGridStates = create<GridStatesState>()(\n persist(\n (set) => ({\n gridStates: {},\n setGridState: (gridId, state) =>\n set((current) => ({ gridStates: { ...current.gridStates, [gridId]: state } })),\n }),\n { name: 'arbi_files_grids', storage: createJSONStorage(() => localStorage) }\n )\n)\n\n/** A document the Delete confirmation asks about. */\nexport interface DeleteRequestDocument {\n external_id: string\n file_name?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\ninterface FilesDialogsState {\n /** Move the selection (or `folder`) to a folder. */\n move: { folder: ExplorerFolder | null } | null\n openMove: (folder?: ExplorerFolder | null) => void\n closeMove: () => void\n /** Edit the selection's labels and fields. */\n bulkTagsOpen: boolean\n setBulkTagsOpen: (open: boolean) => void\n /** Confirm deleting one document. */\n deleteRequest: DeleteRequestDocument | null\n requestDelete: (doc: DeleteRequestDocument | null) => void\n /** Export, copy or move the selection (the page's own dialog, when the host has none). */\n exportOpen: boolean\n setExportOpen: (open: boolean) => void\n}\n\n/** The files page's dialogs, also opened from outside it (commands, the viewer's related files). */\nexport const useFilesDialogs = create<FilesDialogsState>()((set) => ({\n move: null,\n openMove: (folder = null) => set({ move: { folder } }),\n closeMove: () => set({ move: null }),\n bulkTagsOpen: false,\n setBulkTagsOpen: (bulkTagsOpen) => set({ bulkTagsOpen }),\n deleteRequest: null,\n requestDelete: (deleteRequest) => set({ deleteRequest }),\n exportOpen: false,\n setExportOpen: (exportOpen) => set({ exportOpen }),\n}))\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/files/store.ts"],"names":["create","persist","createJSONStorage","DOCUMENTS_ROW_HEIGHT_INITIAL"],"mappings":";;;;;;AAmBO,IAAM,gBAAgBA,cAAA,EAAmB;AAAA,EAC9CC,kBAAA;AAAA,IACE,CAAC,GAAA,MAAS;AAAA,MACR,gBAAgB,EAAC;AAAA,MACjB,kBAAkB,CAAC,WAAA,EAAa,IAAA,KAC9B,GAAA,CAAI,CAAC,KAAA,KAAU;AACb,QAAA,MAAM,OAAA,GAAU,KAAA,CAAM,cAAA,CAAe,WAAW,KAAK,EAAC;AACtD,QAAA,IAAI,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,EAAG,OAAO,KAAA;AACnC,QAAA,OAAO,EAAE,cAAA,EAAgB,EAAE,GAAG,MAAM,cAAA,EAAgB,CAAC,WAAW,GAAG,CAAC,GAAG,OAAA,EAAS,IAAI,GAAE,EAAE;AAAA,MAC1F,CAAC,CAAA;AAAA,MACH,qBAAqB,CAAC,WAAA,EAAa,IAAA,KACjC,GAAA,CAAI,CAAC,KAAA,KAAU;AACb,QAAA,MAAM,OAAA,GAAU,KAAA,CAAM,cAAA,CAAe,WAAW,KAAK,EAAC;AACtD,QAAA,IA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B,GAAA,CAAI,EAAE,cAAc,CAAA;AAAA,EACvD,aAAA,EAAe,IAAA;AAAA,EACf,eAAe,CAAC,aAAA,KAAkB,GAAA,CAAI,EAAE,eAAe,CAAA;AAAA,EACvD,UAAA,EAAY,KAAA;AAAA,EACZ,eAAe,CAAC,UAAA,KAAe,GAAA,CAAI,EAAE,YAAY;AACnD,CAAA,CAAE","file":"chunk-INVL4BE7.cjs","sourcesContent":["/**\n * The Files kits' own state: empty folders the user created (a folder exists only through its\n * documents, so a new one is a placeholder until something is moved into it), per workspace, for\n * the session (kept in `sessionStorage`, so a reload keeps them).\n */\n\nimport type { GridState } from 'ag-grid-community'\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { DOCUMENTS_ROW_HEIGHT_INITIAL } from '../../files/documentColumns'\nimport type { ExplorerFolder } from '../../files/folders/folderPaths'\n\ninterface FilesState {\n /** Placeholder folder paths per workspace. */\n pendingFolders: Readonly<Record<string, readonly string[]>>\n addPendingFolder: (workspaceId: string, path: string) => void\n removePendingFolder: (workspaceId: string, path: string) => void\n}\n\nexport const useFilesStore = create<FilesState>()(\n persist(\n (set) => ({\n pendingFolders: {},\n addPendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (current.includes(path)) return state\n return { pendingFolders: { ...state.pendingFolders, [workspaceId]: [...current, path] } }\n }),\n removePendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (!current.includes(path)) return state\n return {\n pendingFolders: {\n ...state.pendingFolders,\n [workspaceId]: current.filter((p) => p !== path),\n },\n }\n }),\n }),\n {\n name: 'arbi_explorer_pending_folders',\n storage: createJSONStorage(() => sessionStorage),\n partialize: (state) => ({ pendingFolders: state.pendingFolders }),\n }\n )\n)\n\nconst NONE: readonly string[] = []\n\n/** A workspace's placeholder folders. */\nexport function usePendingFolders(workspaceId: string | null | undefined): readonly string[] {\n return useFilesStore(\n (state) => (workspaceId ? state.pendingFolders[workspaceId] : undefined) ?? NONE\n )\n}\n\n/** How the files page shows the documents: a table, the explorer, review one by one, or search. */\nexport type FilesViewMode = 'grid' | 'explorer' | 'navigator' | 'search'\n\n/** The files page's own preferences key (`ConnectedFilesPage` `prefsKey`). */\nexport const FILES_PREFS_KEY = 'files'\nconst DEFAULT_VIEW_MODE: FilesViewMode = 'explorer'\n\ninterface FilesPrefsState {\n /** The documents list's tri-state filters (filter id → include / exclude / off). */\n documentFilters: Readonly<Record<string, 'include' | 'exclude' | null>>\n setDocumentFilters: (filters: Record<string, 'include' | 'exclude' | null>) => void\n /**\n * Each files page's view, by its `prefsKey` (a page that is the same kit in another role, e.g.\n * a tabular review in the table view, keeps its own). Absent: that page's default.\n */\n viewModes: Readonly<Record<string, FilesViewMode>>\n /** Set a page's view (default: the files page's). */\n setViewMode: (mode: FilesViewMode, prefsKey?: string) => void\n /** The table's row height (density). */\n rowHeight: number\n setRowHeight: (height: number) => void\n}\n\n/** The Files kits' preferences, kept on this device (`localStorage`) across sessions. */\nexport const useFilesPrefs = create<FilesPrefsState>()(\n persist(\n (set) => ({\n documentFilters: {},\n setDocumentFilters: (documentFilters) => set({ documentFilters }),\n viewModes: {},\n setViewMode: (viewMode, prefsKey = FILES_PREFS_KEY) =>\n set((state) =>\n state.viewModes[prefsKey] === viewMode\n ? state\n : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }\n ),\n // New users start at the compact minimum (more rows at once).\n rowHeight: DOCUMENTS_ROW_HEIGHT_INITIAL,\n setRowHeight: (rowHeight) => set({ rowHeight }),\n }),\n {\n name: 'arbi_files_prefs',\n storage: createJSONStorage(() => localStorage),\n version: 1,\n // Version 0 kept one view for every files page: it becomes the files page's own.\n migrate: (persisted, version) => {\n const state = (persisted ?? {}) as Record<string, unknown>\n if (version >= 1) return state as Partial<FilesPrefsState>\n const { viewMode, ...rest } = state\n return {\n ...rest,\n viewModes: viewMode ? { [FILES_PREFS_KEY]: viewMode as FilesViewMode } : {},\n } as Partial<FilesPrefsState>\n },\n partialize: (state) => ({\n documentFilters: state.documentFilters,\n viewModes: state.viewModes,\n rowHeight: state.rowHeight,\n }),\n }\n )\n)\n\n/** A files page's view (`prefsKey`, default the files page's), else its `defaultViewMode`. */\nexport function filesViewMode(\n state: Pick<FilesPrefsState, 'viewModes'>,\n prefsKey: string = FILES_PREFS_KEY,\n defaultViewMode: FilesViewMode = DEFAULT_VIEW_MODE\n): FilesViewMode {\n return state.viewModes[prefsKey] ?? defaultViewMode\n}\n\n/** An AI review run: the fields, the documents, and which of them the server finished. */\nexport interface AiReviewRun {\n tags: { id: string; name: string }[]\n docIds: string[]\n /** The documents the server finished (a finished cell with no value will not fill). */\n finishedDocIds?: string[]\n /** It replaces values already there: a cell shows its new value only once finished. */\n replacing?: boolean\n}\n\ninterface AiReviewState {\n /** The AI review dialog is open. */\n open: boolean\n /** The run on screen, kept after closing so \"View results\" can bring the answers back. */\n run: AiReviewRun | null\n setOpen: (open: boolean) => void\n setRun: (run: AiReviewRun | null) => void\n /** The server finished these documents of the run (with or without a value). */\n markFinished: (docIds: string[]) => void\n}\n\n/** The AI review dialog and its run, reachable from outside React (a finished-run notice). */\nexport const useAiReviewStore = create<AiReviewState>()((set) => ({\n open: false,\n run: null,\n setOpen: (open) => set({ open }),\n setRun: (run) => set({ run }),\n markFinished: (docIds) =>\n set((state) => {\n const run = state.run\n if (!run) return state\n const finished = new Set(run.finishedDocIds ?? [])\n const added = docIds.filter((id) => run.docIds.includes(id) && !finished.has(id))\n if (added.length === 0) return state\n return { run: { ...run, finishedDocIds: [...finished, ...added] } }\n }),\n}))\n\ninterface GridStatesState {\n /** AG Grid's saved state (columns, widths, sort) per grid id. */\n gridStates: Readonly<Record<string, GridState>>\n setGridState: (gridId: string, state: GridState) => void\n}\n\n/** The Files grids' saved state, kept on this device, for hosts that keep none of their own. */\nexport const useFilesGridStates = create<GridStatesState>()(\n persist(\n (set) => ({\n gridStates: {},\n setGridState: (gridId, state) =>\n set((current) => ({ gridStates: { ...current.gridStates, [gridId]: state } })),\n }),\n { name: 'arbi_files_grids', storage: createJSONStorage(() => localStorage) }\n )\n)\n\n/** A document the Delete confirmation asks about. */\nexport interface DeleteRequestDocument {\n external_id: string\n file_name?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\ninterface FilesDialogsState {\n /** Move the selection (or `folder`) to a folder. */\n move: { folder: ExplorerFolder | null } | null\n openMove: (folder?: ExplorerFolder | null) => void\n closeMove: () => void\n /** Edit the selection's labels and fields. */\n bulkTagsOpen: boolean\n setBulkTagsOpen: (open: boolean) => void\n /** Confirm deleting one document. */\n deleteRequest: DeleteRequestDocument | null\n requestDelete: (doc: DeleteRequestDocument | null) => void\n /** Export, copy or move the selection (the page's own dialog, when the host has none). */\n exportOpen: boolean\n setExportOpen: (open: boolean) => void\n}\n\n/** The files page's dialogs, also opened from outside it (commands, the viewer's related files). */\nexport const useFilesDialogs = create<FilesDialogsState>()((set) => ({\n move: null,\n openMove: (folder = null) => set({ move: { folder } }),\n closeMove: () => set({ move: null }),\n bulkTagsOpen: false,\n setBulkTagsOpen: (bulkTagsOpen) => set({ bulkTagsOpen }),\n deleteRequest: null,\n requestDelete: (deleteRequest) => set({ deleteRequest }),\n exportOpen: false,\n setExportOpen: (exportOpen) => set({ exportOpen }),\n}))\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkLJTHFTQQ_cjs = require('./chunk-LJTHFTQQ.cjs');
|
|
5
|
+
var chunkBJRQHR7R_cjs = require('./chunk-BJRQHR7R.cjs');
|
|
6
6
|
var chunkM55XUF4L_cjs = require('./chunk-M55XUF4L.cjs');
|
|
7
|
-
var
|
|
8
|
-
var chunkSQCCQU3K_cjs = require('./chunk-SQCCQU3K.cjs');
|
|
7
|
+
var chunkB5AOYT4U_cjs = require('./chunk-B5AOYT4U.cjs');
|
|
9
8
|
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
9
|
+
var chunkSQCCQU3K_cjs = require('./chunk-SQCCQU3K.cjs');
|
|
10
10
|
var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.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(() => chunkB5AOYT4U_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 } = chunkLJTHFTQQ_cjs.useWorkflowTasks();
|
|
57
57
|
const applyModel = react.useApplyChatModel();
|
|
58
58
|
const session = react.useArbiSessionStore();
|
|
59
59
|
const { notify, openFiles, openNewConversation } = chunkHN56WWBR_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") || chunkM55XUF4L_cjs.deriveAnnotationName(description);
|
|
64
|
-
const matching =
|
|
64
|
+
const matching = chunkB5AOYT4U_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 && !chunkSQCCQU3K_cjs.isEmptyWorkflowScope(scope)) {
|
|
164
|
-
const ids =
|
|
164
|
+
const ids = chunkB5AOYT4U_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 } = chunkHN56WWBR_cjs.useBlocksEnvironment();
|
|
217
217
|
const { data: workspaceTags = [] } = react.useTags();
|
|
218
|
-
const tags = react$1.useMemo(() =>
|
|
218
|
+
const tags = react$1.useMemo(() => chunkB5AOYT4U_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
|
|
219
219
|
const fieldPlaceholder = react$1.useCallback(
|
|
220
220
|
(field, inputs, workflow) => {
|
|
221
221
|
if (workflow.id !== chunkM55XUF4L_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
|
+
chunkBJRQHR7R_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-IPSR2PUU.cjs.map
|
|
269
|
+
//# sourceMappingURL=chunk-IPSR2PUU.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":";;;;;;;;;;;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAC,MAAA,KAAqC;AACzD,EAAA,MAAM,QAAQ,MAAA,CAAO,UAAA;AACrB,EAAA,OAAO,KAAA,EAAO,aAAa,EAAC;AAC9B,CAAA;AAEO,IAAM,eAAA,GAAiD;AAAA,EAC5D,CAACA,mCAAiB,GAAG;AAAA,IACnB,WAAA,EAAa,KAAA;AAAA,IACb,KAAA,EAAO,CAAC,MAAA,KAAW;AACjB,MAAA,MAAM,cAAc,OAAO,MAAA,CAAO,YAAA,KAAiB,QAAA,GAAW,OAAO,YAAA,GAAe,EAAA;AACpF,MAAA,OAAO;AAAA,QACL,eAAA,EAAiBC,+BAAA,CAAwB,EAAE,CAAA;AAAA,QAC3C,sBAAA,EAAwBC,qCAAA,CAA8B,YAAA,CAAa,MAAM,CAAC,CAAA;AAAA,QAC1E,GAAI,WAAA,IAAe,WAAA,KAAgBC,mCAAA,GAC/B;AAAA,UACE,gBAAA,EAAkB;AAAA,YAChB,IAAA,EAAM,kBAAA;AAAA,YACN,WAAA,EAAa,kBAAA;AAAA,YACb,SAAA,EAAW,EAAE,YAAA,EAAc,WAAA,EAAY;AAAA,YACvC,gBAAgB;AAAC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AE,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-OHWYQI3B.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n /** The band's layout: reflowing columns (default) or one sideways-scrolling row (a carousel). */\n tilesLayout?: 'grid' | 'carousel'\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDoc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AEZ,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-IPSR2PUU.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n /** The band's layout: reflowing columns (default) or one sideways-scrolling row (a carousel). */\n tilesLayout?: 'grid' | 'carousel'\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
|