@arbidocs/blocks 0.5.112 → 0.5.114
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-KUF6RX76.cjs → ConnectedCallDock-2KXEQENS.cjs} +26 -26
- package/dist/{ConnectedCallDock-KUF6RX76.cjs.map → ConnectedCallDock-2KXEQENS.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-ZKIYB2JG.cjs → ConnectedCallRoom-MU3NPNXF.cjs} +18 -18
- package/dist/{ConnectedCallRoom-ZKIYB2JG.cjs.map → ConnectedCallRoom-MU3NPNXF.cjs.map} +1 -1
- package/dist/{ConnectedMailInviteCard-P65MQM6J.cjs → ConnectedMailInviteCard-EINB3THA.cjs} +5 -5
- package/dist/{ConnectedMailInviteCard-P65MQM6J.cjs.map → ConnectedMailInviteCard-EINB3THA.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-S4RKDH2A.cjs → ConnectedNativeDocxComparison-VH3I65H6.cjs} +21 -21
- package/dist/{ConnectedNativeDocxComparison-S4RKDH2A.cjs.map → ConnectedNativeDocxComparison-VH3I65H6.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-HX4HTQ3Z.cjs → ConnectedProductionSetDialog-4EAY6KAZ.cjs} +8 -8
- package/dist/{ConnectedProductionSetDialog-HX4HTQ3Z.cjs.map → ConnectedProductionSetDialog-4EAY6KAZ.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-A2A7Z3TT.cjs → ConnectedStreamedWordArtifact-KQSHCA75.cjs} +21 -21
- package/dist/{ConnectedStreamedWordArtifact-A2A7Z3TT.cjs.map → ConnectedStreamedWordArtifact-KQSHCA75.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-4A7NF474.cjs → DocumentReviewCard-OCPFVMLD.cjs} +22 -22
- package/dist/{DocumentReviewCard-4A7NF474.cjs.map → DocumentReviewCard-OCPFVMLD.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-PKCBZXDG.cjs → FilesViewerDialog-BAGOEMXW.cjs} +54 -54
- package/dist/{FilesViewerDialog-PKCBZXDG.cjs.map → FilesViewerDialog-BAGOEMXW.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-J3C6VH4T.cjs → WorkspaceTableView-IMAZICIZ.cjs} +9 -9
- package/dist/{WorkspaceTableView-J3C6VH4T.cjs.map → WorkspaceTableView-IMAZICIZ.cjs.map} +1 -1
- package/dist/agents/index.cjs +298 -298
- package/dist/{ai-OYTFPMXI.cjs → ai-7U4B4CVF.cjs} +27 -27
- package/dist/ai-7U4B4CVF.cjs.map +1 -0
- package/dist/calls/index.cjs +147 -147
- package/dist/chat/index.cjs +29 -29
- package/dist/{chunk-37JPFCCU.cjs → chunk-2W5E62EY.cjs} +6 -6
- package/dist/{chunk-37JPFCCU.cjs.map → chunk-2W5E62EY.cjs.map} +1 -1
- package/dist/{chunk-N6AZYEYL.cjs → chunk-3ODEWSRO.cjs} +4 -4
- package/dist/{chunk-N6AZYEYL.cjs.map → chunk-3ODEWSRO.cjs.map} +1 -1
- package/dist/{chunk-VDFYMVMP.cjs → chunk-3R6YHJ3G.cjs} +4 -4
- package/dist/{chunk-VDFYMVMP.cjs.map → chunk-3R6YHJ3G.cjs.map} +1 -1
- package/dist/{chunk-5RCCZYAE.cjs → chunk-3U36VYMD.cjs} +36 -36
- package/dist/{chunk-5RCCZYAE.cjs.map → chunk-3U36VYMD.cjs.map} +1 -1
- package/dist/{chunk-A4FGU6YC.cjs → chunk-436I7PQL.cjs} +7 -7
- package/dist/{chunk-A4FGU6YC.cjs.map → chunk-436I7PQL.cjs.map} +1 -1
- package/dist/{chunk-J2RXQVVF.cjs → chunk-4EK7TAP7.cjs} +5 -5
- package/dist/{chunk-J2RXQVVF.cjs.map → chunk-4EK7TAP7.cjs.map} +1 -1
- package/dist/{chunk-TP5PGWIO.cjs → chunk-4IOYQLKG.cjs} +3 -3
- package/dist/{chunk-TP5PGWIO.cjs.map → chunk-4IOYQLKG.cjs.map} +1 -1
- package/dist/{chunk-ZQLRWA3Y.cjs → chunk-4NPCDS2X.cjs} +4 -4
- package/dist/{chunk-ZQLRWA3Y.cjs.map → chunk-4NPCDS2X.cjs.map} +1 -1
- package/dist/{chunk-ZEQEIFZJ.cjs → chunk-57EE6CMW.cjs} +24 -24
- package/dist/{chunk-ZEQEIFZJ.cjs.map → chunk-57EE6CMW.cjs.map} +1 -1
- package/dist/{chunk-NMT4UZQM.cjs → chunk-57NHXEU2.cjs} +5 -5
- package/dist/{chunk-NMT4UZQM.cjs.map → chunk-57NHXEU2.cjs.map} +1 -1
- package/dist/{chunk-4QTQS4LS.cjs → chunk-5QUL5BZO.cjs} +5 -5
- package/dist/{chunk-4QTQS4LS.cjs.map → chunk-5QUL5BZO.cjs.map} +1 -1
- package/dist/{chunk-MUA5PJGX.cjs → chunk-5SKHK3BG.cjs} +4 -4
- package/dist/{chunk-MUA5PJGX.cjs.map → chunk-5SKHK3BG.cjs.map} +1 -1
- package/dist/{chunk-AFXDLDPU.cjs → chunk-5UYFLFNR.cjs} +4 -4
- package/dist/{chunk-AFXDLDPU.cjs.map → chunk-5UYFLFNR.cjs.map} +1 -1
- package/dist/{chunk-FJXJ43JO.cjs → chunk-6DCIZA3X.cjs} +101 -101
- package/dist/{chunk-FJXJ43JO.cjs.map → chunk-6DCIZA3X.cjs.map} +1 -1
- package/dist/{chunk-G5TRBLKF.cjs → chunk-7TEUGFIL.cjs} +4 -4
- package/dist/{chunk-G5TRBLKF.cjs.map → chunk-7TEUGFIL.cjs.map} +1 -1
- package/dist/{chunk-ZNZGYSVB.cjs → chunk-7X3FS5HQ.cjs} +39 -39
- package/dist/{chunk-ZNZGYSVB.cjs.map → chunk-7X3FS5HQ.cjs.map} +1 -1
- package/dist/{chunk-DZDARC3V.cjs → chunk-7XT5B2DZ.cjs} +70 -70
- package/dist/{chunk-DZDARC3V.cjs.map → chunk-7XT5B2DZ.cjs.map} +1 -1
- package/dist/{chunk-5UMKMUB5.cjs → chunk-AHT6DQNI.cjs} +68 -68
- package/dist/{chunk-5UMKMUB5.cjs.map → chunk-AHT6DQNI.cjs.map} +1 -1
- package/dist/{chunk-SRET7LYT.cjs → chunk-BW5MF464.cjs} +4 -4
- package/dist/{chunk-SRET7LYT.cjs.map → chunk-BW5MF464.cjs.map} +1 -1
- package/dist/{chunk-NP4EWPIP.cjs → chunk-CJYWHUZR.cjs} +6 -6
- package/dist/{chunk-NP4EWPIP.cjs.map → chunk-CJYWHUZR.cjs.map} +1 -1
- package/dist/{chunk-NTD7VSHO.cjs → chunk-CMGNRMPA.cjs} +4 -4
- package/dist/{chunk-NTD7VSHO.cjs.map → chunk-CMGNRMPA.cjs.map} +1 -1
- package/dist/{chunk-Z3VNKPPH.cjs → chunk-E3Y7RI3J.cjs} +4 -4
- package/dist/{chunk-Z3VNKPPH.cjs.map → chunk-E3Y7RI3J.cjs.map} +1 -1
- package/dist/{chunk-TDO5UWXF.cjs → chunk-E4BLRF2L.cjs} +5 -5
- package/dist/{chunk-TDO5UWXF.cjs.map → chunk-E4BLRF2L.cjs.map} +1 -1
- package/dist/{chunk-WT7CCCIN.cjs → chunk-GNX3FBBX.cjs} +4 -4
- package/dist/{chunk-WT7CCCIN.cjs.map → chunk-GNX3FBBX.cjs.map} +1 -1
- package/dist/{chunk-3NEI27QQ.cjs → chunk-GQXPNIRE.cjs} +14 -14
- package/dist/{chunk-3NEI27QQ.cjs.map → chunk-GQXPNIRE.cjs.map} +1 -1
- package/dist/{chunk-7OPOPYV6.cjs → chunk-H5OLHP2U.cjs} +3 -3
- package/dist/{chunk-7OPOPYV6.cjs.map → chunk-H5OLHP2U.cjs.map} +1 -1
- package/dist/{chunk-IIWJQEBC.cjs → chunk-H7PHOTX2.cjs} +10 -10
- package/dist/{chunk-IIWJQEBC.cjs.map → chunk-H7PHOTX2.cjs.map} +1 -1
- package/dist/{chunk-LQHXUSWZ.cjs → chunk-HQDR43JC.cjs} +6 -6
- package/dist/{chunk-LQHXUSWZ.cjs.map → chunk-HQDR43JC.cjs.map} +1 -1
- package/dist/{chunk-6LQN4BMX.cjs → chunk-IDCD5TEZ.cjs} +5 -5
- package/dist/{chunk-6LQN4BMX.cjs.map → chunk-IDCD5TEZ.cjs.map} +1 -1
- package/dist/{chunk-6YOZKXV6.cjs → chunk-JR2YSBD5.cjs} +4 -4
- package/dist/{chunk-6YOZKXV6.cjs.map → chunk-JR2YSBD5.cjs.map} +1 -1
- package/dist/{chunk-3GYOWDNM.cjs → chunk-JSQQV23D.cjs} +5 -5
- package/dist/{chunk-3GYOWDNM.cjs.map → chunk-JSQQV23D.cjs.map} +1 -1
- package/dist/{chunk-ZFKWCGA5.cjs → chunk-JV5TVUOU.cjs} +4 -4
- package/dist/{chunk-ZFKWCGA5.cjs.map → chunk-JV5TVUOU.cjs.map} +1 -1
- package/dist/{chunk-TXFZAA3R.cjs → chunk-LFRNBT2I.cjs} +23 -23
- package/dist/{chunk-TXFZAA3R.cjs.map → chunk-LFRNBT2I.cjs.map} +1 -1
- package/dist/{chunk-R7CJEIA5.cjs → chunk-LYTIQQQ2.cjs} +3 -3
- package/dist/{chunk-R7CJEIA5.cjs.map → chunk-LYTIQQQ2.cjs.map} +1 -1
- package/dist/{chunk-6UYTG2YG.cjs → chunk-MC4F2URI.cjs} +28 -28
- package/dist/{chunk-6UYTG2YG.cjs.map → chunk-MC4F2URI.cjs.map} +1 -1
- package/dist/{chunk-NNG34ONS.cjs → chunk-MGQSLMTC.cjs} +78 -78
- package/dist/{chunk-NNG34ONS.cjs.map → chunk-MGQSLMTC.cjs.map} +1 -1
- package/dist/{chunk-3Q5L7XVI.cjs → chunk-MZ2KZXNU.cjs} +9 -9
- package/dist/{chunk-3Q5L7XVI.cjs.map → chunk-MZ2KZXNU.cjs.map} +1 -1
- package/dist/{chunk-PJ762EO2.cjs → chunk-NHHEMBXQ.cjs} +24 -24
- package/dist/{chunk-PJ762EO2.cjs.map → chunk-NHHEMBXQ.cjs.map} +1 -1
- package/dist/{chunk-ENUZ35NR.cjs → chunk-P5AQYC4D.cjs} +4 -4
- package/dist/{chunk-ENUZ35NR.cjs.map → chunk-P5AQYC4D.cjs.map} +1 -1
- package/dist/{chunk-5I2VUNZR.cjs → chunk-PGJYD67F.cjs} +6 -6
- package/dist/{chunk-5I2VUNZR.cjs.map → chunk-PGJYD67F.cjs.map} +1 -1
- package/dist/{chunk-BYN7UMC5.cjs → chunk-PL7HUTM3.cjs} +8 -8
- package/dist/{chunk-BYN7UMC5.cjs.map → chunk-PL7HUTM3.cjs.map} +1 -1
- package/dist/{chunk-NOYQ23I7.cjs → chunk-Q6DQGGP4.cjs} +6 -6
- package/dist/{chunk-NOYQ23I7.cjs.map → chunk-Q6DQGGP4.cjs.map} +1 -1
- package/dist/{chunk-T7J352JD.cjs → chunk-QMIHLJMH.cjs} +6 -6
- package/dist/{chunk-T7J352JD.cjs.map → chunk-QMIHLJMH.cjs.map} +1 -1
- package/dist/{chunk-LTEXVRCH.cjs → chunk-SBWIA4PL.cjs} +21 -21
- package/dist/{chunk-LTEXVRCH.cjs.map → chunk-SBWIA4PL.cjs.map} +1 -1
- package/dist/{chunk-ZH7LDZJX.cjs → chunk-TDN33HSK.cjs} +14 -14
- package/dist/{chunk-ZH7LDZJX.cjs.map → chunk-TDN33HSK.cjs.map} +1 -1
- package/dist/{chunk-U5T46QCS.cjs → chunk-TKHCIHE2.cjs} +3 -3
- package/dist/chunk-TKHCIHE2.cjs.map +1 -0
- package/dist/{chunk-WIAWHETB.cjs → chunk-ULPTSXXO.cjs} +4 -4
- package/dist/{chunk-WIAWHETB.cjs.map → chunk-ULPTSXXO.cjs.map} +1 -1
- package/dist/{chunk-GTWEWDIZ.cjs → chunk-UNDQYTRF.cjs} +8 -8
- package/dist/{chunk-GTWEWDIZ.cjs.map → chunk-UNDQYTRF.cjs.map} +1 -1
- package/dist/{chunk-OKHKJ5ML.cjs → chunk-UUENH4BJ.cjs} +11 -11
- package/dist/{chunk-OKHKJ5ML.cjs.map → chunk-UUENH4BJ.cjs.map} +1 -1
- package/dist/{chunk-K5MYEWD5.cjs → chunk-UZHWXKS6.cjs} +7 -7
- package/dist/{chunk-K5MYEWD5.cjs.map → chunk-UZHWXKS6.cjs.map} +1 -1
- package/dist/{chunk-QVHP4R7T.cjs → chunk-V5IMYLYK.cjs} +29 -29
- package/dist/{chunk-QVHP4R7T.cjs.map → chunk-V5IMYLYK.cjs.map} +1 -1
- package/dist/{chunk-XW524KUX.cjs → chunk-VJCSEMXT.cjs} +4 -4
- package/dist/{chunk-XW524KUX.cjs.map → chunk-VJCSEMXT.cjs.map} +1 -1
- package/dist/{chunk-B5442TKX.cjs → chunk-VRK3IQAP.cjs} +4 -4
- package/dist/{chunk-B5442TKX.cjs.map → chunk-VRK3IQAP.cjs.map} +1 -1
- package/dist/{chunk-MYRKL3JO.cjs → chunk-VWTOIGX4.cjs} +4 -4
- package/dist/{chunk-MYRKL3JO.cjs.map → chunk-VWTOIGX4.cjs.map} +1 -1
- package/dist/{chunk-Q7DB5S7N.cjs → chunk-WW6LXQY6.cjs} +12 -12
- package/dist/{chunk-Q7DB5S7N.cjs.map → chunk-WW6LXQY6.cjs.map} +1 -1
- package/dist/{chunk-NJCK6V6U.cjs → chunk-XKDUPU7B.cjs} +4 -4
- package/dist/{chunk-NJCK6V6U.cjs.map → chunk-XKDUPU7B.cjs.map} +1 -1
- package/dist/{chunk-YAPXIANR.cjs → chunk-YVCOQHCE.cjs} +5 -5
- package/dist/{chunk-YAPXIANR.cjs.map → chunk-YVCOQHCE.cjs.map} +1 -1
- package/dist/{chunk-TOM2P3MA.cjs → chunk-ZZA756I4.cjs} +4 -4
- package/dist/{chunk-TOM2P3MA.cjs.map → chunk-ZZA756I4.cjs.map} +1 -1
- package/dist/citations/index.cjs +8 -8
- package/dist/connect/docx.cjs +24 -24
- package/dist/connect/index.cjs +1489 -1433
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +40 -40
- package/dist/connection/ConnectedWorkflowBuilder.d.ts +11 -0
- package/dist/connection/ConnectedWorkflowBuilder.js +42 -3
- package/dist/connection/ConnectedWorkflowBuilder.js.map +2 -2
- package/dist/connection/conversation/ConnectedConversationPage.js +36 -2
- package/dist/connection/conversation/ConnectedConversationPage.js.map +2 -2
- package/dist/connection/report-problem/ReportProblemDialog.d.ts +2 -2
- package/dist/connection/report-problem/ReportProblemDialog.js +51 -19
- package/dist/connection/report-problem/ReportProblemDialog.js.map +2 -2
- package/dist/connection/workflows/ConnectedWorkflowsPage.js +10 -3
- package/dist/connection/workflows/ConnectedWorkflowsPage.js.map +2 -2
- package/dist/connection/workflows/useWorkflowsPageState.d.ts +1 -0
- package/dist/connection/workflows/useWorkflowsPageState.js.map +2 -2
- package/dist/dashboards/index.cjs +23 -23
- package/dist/embed/index.cjs +49 -49
- package/dist/facts/index.cjs +45 -45
- package/dist/files/index.cjs +225 -225
- package/dist/home/index.cjs +32 -32
- package/dist/index.cjs +1750 -1750
- package/dist/provider/environment.d.ts +5 -0
- package/dist/provider/environment.js +1 -1
- package/dist/provider/environment.js.map +2 -2
- package/dist/provider/requests.d.ts +2 -0
- package/dist/provider/requests.js.map +2 -2
- package/dist/retrieval/index.cjs +4 -4
- package/dist/settings/index.cjs +148 -148
- package/dist/shell/index.cjs +91 -91
- package/dist/site/index.cjs +5 -5
- package/dist/studio/index.cjs +43 -43
- package/dist/workflow-canvas/index.cjs +114 -72
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workspaces/index.cjs +18 -18
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ai-OYTFPMXI.cjs.map +0 -1
- package/dist/chunk-U5T46QCS.cjs.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
6
6
|
var chunkJDFBEGQO_cjs = require('./chunk-JDFBEGQO.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var react$1 = require('@arbidocs/react');
|
|
@@ -345,7 +345,7 @@ function useConnectedWorkspace() {
|
|
|
345
345
|
const live = connection ? connection.status === "authenticated" : arbi.isLoggedIn;
|
|
346
346
|
const user = connection ? connection.user : live ? sessionUser(arbi) : null;
|
|
347
347
|
const userKey = `${user?.externalId ?? ""}|${user?.name ?? ""}|${user?.email ?? ""}`;
|
|
348
|
-
const { openWorkspace: showWorkspace } =
|
|
348
|
+
const { openWorkspace: showWorkspace } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
349
349
|
return react.useMemo(
|
|
350
350
|
() => ({
|
|
351
351
|
workspaceId: connection ? connection.workspaceId ?? connection.fallbackWorkspaceId ?? null : sessionWorkspaceId,
|
|
@@ -371,5 +371,5 @@ exports.useConnectedWorkspace = useConnectedWorkspace;
|
|
|
371
371
|
exports.useConnection = useConnection;
|
|
372
372
|
exports.useConnectionUser = useConnectionUser;
|
|
373
373
|
exports.useOptionalConnection = useOptionalConnection;
|
|
374
|
-
//# sourceMappingURL=chunk-
|
|
375
|
-
//# sourceMappingURL=chunk-
|
|
374
|
+
//# sourceMappingURL=chunk-JR2YSBD5.cjs.map
|
|
375
|
+
//# sourceMappingURL=chunk-JR2YSBD5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/ConnectionProvider.tsx"],"names":["createContext","useArbi","useArbiSessionStore","useSwitchWorkspace","useState","useArbiSessionState","useRef","useEffect","closeAllDialogs","useCallback","login","clearSealedDrafts","clearChatArtifacts","wipeOfflineMail","useMemo","jsx","ArbiHost","arbiAccountClient","toProfileView","useContext","useBlocksEnvironment"],"mappings":";;;;;;;;;;AA8EA,IAAM,iBAAA,GAAoBA,oBAAsC,IAAI,CAAA;AAQpE,IAAM,wBAAA,GAA2B,wBAAA;AACjC,IAAM,m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,WAAW,CAAA;AACzD,QAAA,aAAA,CAAc,aAAa,OAAO,CAAA;AAAA,MACpC;AAAA,KACF,CAAA;AAAA;AAAA;AAAA,IAGA,CAAC,UAAA,EAAY,kBAAA,EAAoB,IAAA,EAAM,SAAS,aAAa;AAAA,GAC/D;AACF","file":"chunk-6YOZKXV6.cjs","sourcesContent":["/**\n * The demo/live connection layer for a host app. Holds auth + workspace\n * selection state and exposes it via {@link useConnection}, so every surface\n * works identically whether it's talking to a live ARBI backend or the seeded\n * demo workspace. Host-specific values (backend URL, demo identity, default\n * workspace/assistant ids) arrive once through {@link ArbiConnectionConfig}.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport {\n arbiAccountClient,\n clearSealedDrafts,\n wipeOfflineMail,\n toProfileView,\n useArbi,\n useArbiSessionState,\n useArbiSessionStore,\n useSwitchWorkspace,\n type AccountClient,\n type LoginProfile,\n type ProfileView,\n} from '@arbidocs/react'\nimport { clearChatArtifacts } from '@arbidocs/react/shell'\nimport type { ArbiMode, ArbiUser, ConnectionStatus, ArbiConnectionConfig } from './types'\nimport { useBlocksEnvironment } from '../provider/environment'\nimport { ArbiHost } from '../provider/host'\nimport { closeAllDialogs } from '../provider/dialog-registry'\n\ninterface ConnectionValue {\n mode: ArbiMode\n status: ConnectionStatus\n user: ArbiUser | null\n /** The selected workspace: the session state's (`useArbiSessionState`), set by `setWorkspace`. */\n workspaceId: string | null\n apiConfigured: boolean\n apiUrl: string\n /**\n * The deployment domain the user's keys are derived for (`arbi.getDeploymentDomain()`), for the\n * document tools' e-signing. `undefined` in demo mode.\n */\n deploymentDomain: string | undefined\n error: string | null\n /** Default assistant config ext_id (for the AI hooks). */\n assistantConfig?: string\n /**\n * The demo's workspace when none is selected. Never set signed in to a live backend: there the\n * selection is the only workspace (none while a switch is in flight), never a remembered one.\n */\n fallbackWorkspaceId?: string\n /** Authenticate. Live login when a backend is configured, otherwise the demo workspace. */\n login: (email: string, password: string) => Promise<void>\n /** One-click demo entry (no backend required). */\n enterDemo: () => void\n logout: () => void\n /**\n * Affirmatively select a workspace: opens it on the server (via the SDK),\n * updates the app-wide state, and persists the choice so it survives future\n * logins. This is the single entry point for \"the user is now in workspace X\".\n */\n setWorkspace: (id: string) => Promise<void>\n /**\n * Re-assert the selected workspace on the server session (idempotent `/open`).\n * Call before a workspace-scoped write when the session may have lost its open\n * workspace (token re-login, backend restart, session expiry) — the server\n * resolves the workspace from the session, so a dropped `/open` yields\n * \"No active workspace\" until it's re-opened.\n */\n ensureWorkspaceOpen: () => Promise<void>\n}\n\nconst ConnectionContext = createContext<ConnectionValue | null>(null)\n\n/**\n * Persist the affirmatively-selected workspace per backend AND per signed-in user, so a returning\n * user lands back in the workspace they last chose, while the next person on a shared browser\n * never starts from someone else's workspace id. Namespaced by apiUrl so distinct deployments\n * (and the demo workspace) don't clobber each other. Cleared on logout.\n */\nconst WORKSPACE_STORAGE_PREFIX = 'arbi:selectedWorkspace'\nconst normalizeUserKey = (email: string) => email.trim().toLowerCase()\n\n/** Exported for tests. */\nexport const workspaceStorageKey = (apiUrl: string, userKey: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}:${normalizeUserKey(userKey)}`\n\n/** The pre-isolation key (apiUrl only). Never read: removed so it cannot leak across users. */\nconst legacyWorkspaceStorageKey = (apiUrl: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}`\n\nfunction readPersistedWorkspace(apiUrl: string, userKey: string | null): string | null {\n if (!userKey) return null\n try {\n return window.localStorage.getItem(workspaceStorageKey(apiUrl, userKey))\n } catch {\n return null\n }\n}\n\nfunction persistWorkspace(apiUrl: string, userKey: string | null, id: string | null): void {\n if (!userKey) return\n try {\n if (id) window.localStorage.setItem(workspaceStorageKey(apiUrl, userKey), id)\n else window.localStorage.removeItem(workspaceStorageKey(apiUrl, userKey))\n window.localStorage.removeItem(legacyWorkspaceStorageKey(apiUrl))\n } catch {\n // Storage unavailable (private mode, SSR) — selection stays in-memory only.\n }\n}\n\n/** Shown on the sign-in screen after the session could not be recovered. */\nexport const SESSION_EXPIRED_MESSAGE = 'Your session expired. Sign in again.'\n\n/** The connection user for a profile: its full name, falling back to the email local part. */\nfunction userFromProfile(profile: LoginProfile, externalId?: string): ArbiUser {\n const fullName = [profile.givenName, profile.familyName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ')\n return {\n name: fullName || profile.email.split('@')[0],\n email: profile.email,\n externalId,\n picture: profile.picture,\n }\n}\n\n/**\n * The sign-in layer of a blocks-only site, mounted by its host (`defaultHost`): login, demo mode\n * and the selected workspace, over the host's session state (the selected workspace lives there,\n * so every block reads one value). Its account client is the host's `account` below it.\n */\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\n const session = useArbiSessionStore()\n const { switchWorkspace, openSelectedWorkspace, settled } = useSwitchWorkspace()\n const isLiveConfigured = config.apiUrl.length > 0\n const demoWorkspaceId = config.demoWorkspaceId ?? 'demo-workspace'\n\n const [status, setStatus] = useState<ConnectionStatus>(\n isLiveConfigured ? 'connecting' : 'disconnected'\n )\n const [user, setUser] = useState<ArbiUser | null>(null)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const selectWorkspaceId = session.setWorkspaceId\n const [mode, setMode] = useState<ArbiMode>('demo')\n const [error, setError] = useState<string | null>(null)\n // Dialogs belong to the signed-in session. A first signed-out mount may carry an invitation\n // intent, so clear only after an authenticated (or demo) session actually ends. A workspace\n // switch / sign-in can pass through `connecting` without ending that session.\n const hadDialogSession = useRef(false)\n useEffect(() => {\n if (status === 'authenticated' || status === 'demo') {\n hadDialogSession.current = true\n } else if (status !== 'connecting' && hadDialogSession.current) {\n hadDialogSession.current = false\n closeAllDialogs()\n }\n }, [status])\n // Who the persisted workspace belongs to; set at sign-in, cleared at logout.\n const storageUserRef = useRef<string | null>(null)\n // Moves at each logout: a sign-in still finishing from before it does not sign back in.\n const sessionRun = useRef(0)\n\n // The SDK could not recover the session (token refused, workspace not re-openable): drop to\n // 'disconnected' with a plain message, so the host's gate sends the user to sign in instead of\n // every call failing with a raw backend error. The remembered workspace is kept for next login.\n useEffect(\n () =>\n arbi.onSessionExpired?.(() => {\n storageUserRef.current = null\n setUser(null)\n selectWorkspaceId(null)\n setStatus('disconnected')\n setError(SESSION_EXPIRED_MESSAGE)\n }),\n [arbi, selectWorkspaceId]\n )\n\n // A saved name, picture or email reaches every surface reading `useConnection().user`.\n useEffect(\n () =>\n arbi.user.onProfileChange?.((profile) =>\n setUser((current) => (current ? userFromProfile(profile, current.externalId) : current))\n ),\n [arbi]\n )\n\n const enterDemo = useCallback(() => {\n setMode('demo')\n setStatus('demo')\n setError(null)\n setUser({ name: config.demoUser.name, email: config.demoUser.email })\n selectWorkspaceId(demoWorkspaceId)\n }, [config.demoUser.name, config.demoUser.email, demoWorkspaceId, selectWorkspaceId])\n\n /**\n * The session signed in, by whatever path (`login` below, a sign-in page on the host's `Arbi`,\n * a restored session): open the user's workspace and resolve who they are.\n */\n const completeSignIn = useCallback(\n async (email: string) => {\n const run = sessionRun.current\n const signedOut = () => run !== sessionRun.current\n setMode('live')\n setStatus('connecting')\n setError(null)\n try {\n storageUserRef.current = normalizeUserKey(email)\n const workspaces = await arbi.workspaces.list()\n if (workspaces?.length) {\n // Prefer the workspace the user last affirmatively selected (persisted),\n // then the configured workspace (there may be several — e.g. a\n // marketing/KM workspace), then whichever happens to be first. Ternary\n // (not `&&`) so an empty value can't leak `\"\"` into `target`.\n const persisted = readPersistedWorkspace(config.apiUrl, storageUserRef.current)\n const preferred = persisted ?? config.workspaceId\n const target =\n (preferred ? workspaces.find((w) => w.external_id === preferred) : undefined) ??\n (config.requireWorkspaceSelection ? undefined : workspaces[0])\n if (target) {\n selectWorkspaceId(target.external_id)\n if (!(await openSelectedWorkspace()))\n throw new Error('Could not open your workspace. Try signing in again.')\n persistWorkspace(config.apiUrl, storageUserRef.current, target.external_id)\n }\n }\n // The profile (name + avatar) comes with the login response. A session restored without\n // a login has none, so fall back to finding ourselves in the workspace roster; the email\n // local part is only the last resort, never the answer when a profile name exists.\n let resolved: ArbiUser = { name: email.split('@')[0], email }\n const me = arbi.user.identity()\n const profile = arbi.user.profile?.()\n if (profile) {\n resolved = userFromProfile(profile, me?.externalId)\n } else {\n try {\n const members = await arbi.workspaces.listUsers()\n const self = members.find((m) => m.user.external_id === me?.externalId)?.user\n if (self) {\n const fullName = [self.given_name, self.family_name].filter(Boolean).join(' ').trim()\n resolved = {\n name: fullName || email.split('@')[0],\n email: self.email || email,\n externalId: self.external_id,\n picture: self.picture ?? null,\n }\n } else if (me?.externalId) {\n resolved.externalId = me.externalId\n }\n } catch {\n // Roster not available (e.g. no workspace) — keep the fallback identity.\n }\n }\n if (signedOut()) return\n setUser(resolved)\n setStatus('authenticated')\n } catch (e) {\n if (signedOut()) return\n // Surface the real error — no silent fallback to a fake session.\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [\n arbi,\n config.workspaceId,\n config.apiUrl,\n config.requireWorkspaceSelection,\n selectWorkspaceId,\n openSelectedWorkspace,\n ]\n )\n\n // Every sign-in on the host's `Arbi` lands here, whichever page or kit made it.\n const signingIn = useRef<Promise<void>>(Promise.resolve())\n useEffect(\n () =>\n arbi.onSignedIn?.((login) => {\n signingIn.current = completeSignIn(\n login.profile?.email ??\n arbi.session?.getState().userEmail ??\n arbi.user.identity()?.email ??\n ''\n )\n }),\n [arbi, completeSignIn]\n )\n\n /** Authenticate: a live login when a backend is configured, otherwise the demo workspace. */\n const login = useCallback(\n async (email: string, password: string) => {\n setError(null)\n if (!isLiveConfigured) {\n enterDemo()\n return\n }\n setStatus('connecting')\n setMode('live')\n try {\n // Signed in: `completeSignIn` follows (onSignedIn); done once it is.\n await arbi.login(email, password)\n await signingIn.current\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, enterDemo, isLiveConfigured]\n )\n\n // The session kept on this device signs in again (no password; the key stays encrypted on the\n // device). Run once even under StrictMode.\n const restoreStarted = useRef(false)\n useEffect(() => {\n if (restoreStarted.current || !isLiveConfigured) return\n restoreStarted.current = true\n arbi\n .restore()\n .catch(() => false)\n .then(async (restored) => {\n if (restored) await signingIn.current\n else setStatus('disconnected')\n })\n }, [arbi, isLiveConfigured])\n\n // Signing out: resolves once the mail kept on this device is gone too (the account client's\n // `signOut` waits for it); `logout` starts it.\n const signOutConnection = useCallback(async () => {\n sessionRun.current++\n // The SDK stops the session's work (requests, re-logins, opens, the queries in flight) before\n // the server revokes the token.\n if (mode === 'live') {\n void arbi.logout?.()\n }\n // What was typed never outlives the session (it is sealed, but kept for no one now).\n clearSealedDrafts()\n // Nor do the documents its chats were writing in this tab.\n clearChatArtifacts()\n setUser(null)\n selectWorkspaceId(null)\n persistWorkspace(config.apiUrl, storageUserRef.current, null)\n storageUserRef.current = null\n setStatus('disconnected')\n setError(null)\n // Nor does the mail kept on this device (the per-device choices stay, #2187). The sign-out is\n // done once it is gone.\n await wipeOfflineMail().catch(() => {})\n }, [arbi, mode, config.apiUrl, selectWorkspaceId])\n const logout = useCallback(() => {\n void signOutConnection()\n }, [signOutConnection])\n\n // Affirmative selection: the shared workspace switch (live), then remember it so the next\n // login lands there too. This provider IS the host's navigation, so it alone (with sign-in and\n // ensureWorkspaceOpen, which re-open the host's own selection) changes the workspace; kits reach\n // another workspace with `arbi.workspaces.open`.\n const setWorkspace = useCallback(\n async (id: string) => {\n if (mode === 'live' && arbi.isLoggedIn) {\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n } else {\n selectWorkspaceId(id)\n }\n persistWorkspace(config.apiUrl, storageUserRef.current, id)\n },\n [arbi, mode, config.apiUrl, selectWorkspaceId, switchWorkspace]\n )\n\n // Re-open the selected workspace on the session if the server may have dropped it. Idempotent.\n // A switch in flight is waited out first, then only the selection as of then is opened (none:\n // nothing). Never a remembered or configured workspace: kits call this before reading, and\n // opening another workspace than the selected one would leave the server session in it.\n const ensureWorkspaceOpen = useCallback(async () => {\n if (mode !== 'live' || !arbi.isLoggedIn) return\n await settled()\n if (!session.getState().workspaceId) return\n await openSelectedWorkspace()\n }, [arbi, session, mode, settled, openSelectedWorkspace])\n\n const value = useMemo<ConnectionValue>(\n () => ({\n mode,\n status,\n user,\n workspaceId,\n apiConfigured: isLiveConfigured,\n apiUrl: config.apiUrl,\n deploymentDomain: isLiveConfigured ? arbi.getDeploymentDomain() : undefined,\n error,\n assistantConfig: config.assistantConfig,\n fallbackWorkspaceId: mode === 'live' ? undefined : config.workspaceId,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n }),\n [\n mode,\n status,\n user,\n workspaceId,\n isLiveConfigured,\n config.apiUrl,\n arbi,\n config.assistantConfig,\n config.workspaceId,\n error,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n ]\n )\n\n const account = useConnectionAccount(arbi, user, signOutConnection)\n const authenticated = status === 'authenticated'\n const host = useMemo(\n () => ({ account: { client: account, useEnabled: () => authenticated } }),\n [account, authenticated]\n )\n\n return (\n <ConnectionContext.Provider value={value}>\n <ArbiHost config={host}>{children}</ArbiHost>\n </ConnectionContext.Provider>\n )\n}\n\n/**\n * The account client of the settings blocks below: the SDK's, with sign-out going through this\n * connection (so its state is cleared too) and, for a session restored without a login (no SDK\n * profile), the connection user as the profile.\n */\nfunction useConnectionAccount(\n arbi: ReturnType<typeof useArbi>,\n user: ArbiUser | null,\n logout: () => Promise<void>\n): AccountClient {\n const userRef = useRef(user)\n const logoutRef = useRef(logout)\n logoutRef.current = logout\n const listeners = useRef(new Set<() => void>())\n useEffect(() => {\n userRef.current = user\n listeners.current.forEach((listener) => listener())\n }, [user])\n return useMemo(() => {\n const base = arbiAccountClient(arbi)\n return {\n ...base,\n profile: (): ProfileView | null => {\n const own = base.profile()\n const fallback = userRef.current\n if (own || !fallback) return own\n return {\n ...toProfileView({\n givenName: '',\n familyName: null,\n picture: fallback.picture ?? null,\n email: fallback.email,\n isSso: false,\n }),\n fullName: fallback.name,\n }\n },\n onProfileChange: (listener) => {\n listeners.current.add(listener)\n const off = base.onProfileChange(listener)\n return () => {\n listeners.current.delete(listener)\n off()\n }\n },\n signOut: async ({ everywhere } = {}) => {\n try {\n if (everywhere) await arbi.sessions.logoutAll()\n } finally {\n await logoutRef.current()\n }\n },\n }\n }, [arbi])\n}\n\n/** The sign-in layer of `defaultHost`, or null under a host that keeps its own session. */\nexport function useOptionalConnection(): ConnectionValue | null {\n return useContext(ConnectionContext)\n}\n\nexport function useConnection(): ConnectionValue {\n const ctx = useContext(ConnectionContext)\n if (!ctx) throw new Error('useConnection needs the sign-in layer of `defaultHost` above it')\n return ctx\n}\n\n/** The sign-in layer's person (a demo session's identity too); none without `defaultHost`. */\nexport function useConnectionUser(): ArbiUser | null {\n return useContext(ConnectionContext)?.user ?? null\n}\n\nexport const isAuthenticated = (s: ConnectionStatus) => s === 'demo' || s === 'authenticated'\n\n/** The open workspace as the connected kits see it, whoever hosts them. */\nexport interface ConnectedWorkspace {\n /** The selected workspace (the session state's; with a connection, else its fallback). */\n workspaceId: string | null\n /** Signed in to a live backend: workspace-scoped queries may run. */\n live: boolean\n /** The signed-in user (their name and email, e.g. to sign a document). */\n user: ArbiUser | null\n /** The signed-in user's external id. */\n userId: string | undefined\n /** Re-assert the workspace on the server session before a workspace-scoped write. */\n ensureWorkspaceOpen: () => Promise<void>\n /**\n * Go into a workspace: select it (with a connection) and show it (`BlocksEnvironment.\n * openWorkspace`, where a host without a connection also switches its session).\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => Promise<void>\n}\n\nconst keptOpenByHost = async () => {}\n\n/** The signed-in user of a host's own session, from its login profile. */\nfunction sessionUser(arbi: ReturnType<typeof useArbi>): ArbiUser | null {\n if (!arbi.isLoggedIn) return null\n const me = arbi.user.identity()\n const profile = arbi.user.profile()\n if (!me) return null\n return profile\n ? userFromProfile(profile, me.externalId)\n : { name: (me.email ?? '').split('@')[0], email: me.email ?? '', externalId: me.externalId }\n}\n\n/**\n * The workspace for a connected kit: the sign-in layer's (`defaultHost`) when there is one, else the\n * host's own session (an app whose host config has its `arbi` and `session` and keeps its\n * workspace open itself). So a kit runs the same in Clarum and in the ARBI app.\n */\nexport function useConnectedWorkspace(): ConnectedWorkspace {\n const connection = useContext(ConnectionContext)\n const arbi = useArbi()\n const sessionWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const live = connection ? connection.status === 'authenticated' : arbi.isLoggedIn\n const user = connection ? connection.user : live ? sessionUser(arbi) : null\n const userKey = `${user?.externalId ?? ''}|${user?.name ?? ''}|${user?.email ?? ''}`\n const { openWorkspace: showWorkspace } = useBlocksEnvironment()\n return useMemo(\n () => ({\n workspaceId: connection\n ? (connection.workspaceId ?? connection.fallbackWorkspaceId ?? null)\n : sessionWorkspaceId,\n live,\n user,\n userId: user?.externalId,\n ensureWorkspaceOpen: connection?.ensureWorkspaceOpen ?? keptOpenByHost,\n openWorkspace: async (workspaceId: string, options?: { name?: string }) => {\n if (connection) await connection.setWorkspace(workspaceId)\n showWorkspace(workspaceId, options)\n },\n }),\n // `user` is rebuilt each render without a connection: its key says when it changed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [connection, sessionWorkspaceId, live, userKey, showWorkspace]\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/ConnectionProvider.tsx"],"names":["createContext","useArbi","useArbiSessionStore","useSwitchWorkspace","useState","useArbiSessionState","useRef","useEffect","closeAllDialogs","useCallback","login","clearSealedDrafts","clearChatArtifacts","wipeOfflineMail","useMemo","jsx","ArbiHost","arbiAccountClient","toProfileView","useContext","useBlocksEnvironment"],"mappings":";;;;;;;;;;AA8EA,IAAM,iBAAA,GAAoBA,oBAAsC,IAAI,CAAA;AAQpE,IAAM,wBAAA,GAA2B,wBAAA;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W,YAAA,CAAa,WAAW,CAAA;AACzD,QAAA,aAAA,CAAc,aAAa,OAAO,CAAA;AAAA,MACpC;AAAA,KACF,CAAA;AAAA;AAAA;AAAA,IAGA,CAAC,UAAA,EAAY,kBAAA,EAAoB,IAAA,EAAM,SAAS,aAAa;AAAA,GAC/D;AACF","file":"chunk-JR2YSBD5.cjs","sourcesContent":["/**\n * The demo/live connection layer for a host app. Holds auth + workspace\n * selection state and exposes it via {@link useConnection}, so every surface\n * works identically whether it's talking to a live ARBI backend or the seeded\n * demo workspace. Host-specific values (backend URL, demo identity, default\n * workspace/assistant ids) arrive once through {@link ArbiConnectionConfig}.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport {\n arbiAccountClient,\n clearSealedDrafts,\n wipeOfflineMail,\n toProfileView,\n useArbi,\n useArbiSessionState,\n useArbiSessionStore,\n useSwitchWorkspace,\n type AccountClient,\n type LoginProfile,\n type ProfileView,\n} from '@arbidocs/react'\nimport { clearChatArtifacts } from '@arbidocs/react/shell'\nimport type { ArbiMode, ArbiUser, ConnectionStatus, ArbiConnectionConfig } from './types'\nimport { useBlocksEnvironment } from '../provider/environment'\nimport { ArbiHost } from '../provider/host'\nimport { closeAllDialogs } from '../provider/dialog-registry'\n\ninterface ConnectionValue {\n mode: ArbiMode\n status: ConnectionStatus\n user: ArbiUser | null\n /** The selected workspace: the session state's (`useArbiSessionState`), set by `setWorkspace`. */\n workspaceId: string | null\n apiConfigured: boolean\n apiUrl: string\n /**\n * The deployment domain the user's keys are derived for (`arbi.getDeploymentDomain()`), for the\n * document tools' e-signing. `undefined` in demo mode.\n */\n deploymentDomain: string | undefined\n error: string | null\n /** Default assistant config ext_id (for the AI hooks). */\n assistantConfig?: string\n /**\n * The demo's workspace when none is selected. Never set signed in to a live backend: there the\n * selection is the only workspace (none while a switch is in flight), never a remembered one.\n */\n fallbackWorkspaceId?: string\n /** Authenticate. Live login when a backend is configured, otherwise the demo workspace. */\n login: (email: string, password: string) => Promise<void>\n /** One-click demo entry (no backend required). */\n enterDemo: () => void\n logout: () => void\n /**\n * Affirmatively select a workspace: opens it on the server (via the SDK),\n * updates the app-wide state, and persists the choice so it survives future\n * logins. This is the single entry point for \"the user is now in workspace X\".\n */\n setWorkspace: (id: string) => Promise<void>\n /**\n * Re-assert the selected workspace on the server session (idempotent `/open`).\n * Call before a workspace-scoped write when the session may have lost its open\n * workspace (token re-login, backend restart, session expiry) — the server\n * resolves the workspace from the session, so a dropped `/open` yields\n * \"No active workspace\" until it's re-opened.\n */\n ensureWorkspaceOpen: () => Promise<void>\n}\n\nconst ConnectionContext = createContext<ConnectionValue | null>(null)\n\n/**\n * Persist the affirmatively-selected workspace per backend AND per signed-in user, so a returning\n * user lands back in the workspace they last chose, while the next person on a shared browser\n * never starts from someone else's workspace id. Namespaced by apiUrl so distinct deployments\n * (and the demo workspace) don't clobber each other. Cleared on logout.\n */\nconst WORKSPACE_STORAGE_PREFIX = 'arbi:selectedWorkspace'\nconst normalizeUserKey = (email: string) => email.trim().toLowerCase()\n\n/** Exported for tests. */\nexport const workspaceStorageKey = (apiUrl: string, userKey: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}:${normalizeUserKey(userKey)}`\n\n/** The pre-isolation key (apiUrl only). Never read: removed so it cannot leak across users. */\nconst legacyWorkspaceStorageKey = (apiUrl: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}`\n\nfunction readPersistedWorkspace(apiUrl: string, userKey: string | null): string | null {\n if (!userKey) return null\n try {\n return window.localStorage.getItem(workspaceStorageKey(apiUrl, userKey))\n } catch {\n return null\n }\n}\n\nfunction persistWorkspace(apiUrl: string, userKey: string | null, id: string | null): void {\n if (!userKey) return\n try {\n if (id) window.localStorage.setItem(workspaceStorageKey(apiUrl, userKey), id)\n else window.localStorage.removeItem(workspaceStorageKey(apiUrl, userKey))\n window.localStorage.removeItem(legacyWorkspaceStorageKey(apiUrl))\n } catch {\n // Storage unavailable (private mode, SSR) — selection stays in-memory only.\n }\n}\n\n/** Shown on the sign-in screen after the session could not be recovered. */\nexport const SESSION_EXPIRED_MESSAGE = 'Your session expired. Sign in again.'\n\n/** The connection user for a profile: its full name, falling back to the email local part. */\nfunction userFromProfile(profile: LoginProfile, externalId?: string): ArbiUser {\n const fullName = [profile.givenName, profile.familyName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ')\n return {\n name: fullName || profile.email.split('@')[0],\n email: profile.email,\n externalId,\n picture: profile.picture,\n }\n}\n\n/**\n * The sign-in layer of a blocks-only site, mounted by its host (`defaultHost`): login, demo mode\n * and the selected workspace, over the host's session state (the selected workspace lives there,\n * so every block reads one value). Its account client is the host's `account` below it.\n */\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\n const session = useArbiSessionStore()\n const { switchWorkspace, openSelectedWorkspace, settled } = useSwitchWorkspace()\n const isLiveConfigured = config.apiUrl.length > 0\n const demoWorkspaceId = config.demoWorkspaceId ?? 'demo-workspace'\n\n const [status, setStatus] = useState<ConnectionStatus>(\n isLiveConfigured ? 'connecting' : 'disconnected'\n )\n const [user, setUser] = useState<ArbiUser | null>(null)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const selectWorkspaceId = session.setWorkspaceId\n const [mode, setMode] = useState<ArbiMode>('demo')\n const [error, setError] = useState<string | null>(null)\n // Dialogs belong to the signed-in session. A first signed-out mount may carry an invitation\n // intent, so clear only after an authenticated (or demo) session actually ends. A workspace\n // switch / sign-in can pass through `connecting` without ending that session.\n const hadDialogSession = useRef(false)\n useEffect(() => {\n if (status === 'authenticated' || status === 'demo') {\n hadDialogSession.current = true\n } else if (status !== 'connecting' && hadDialogSession.current) {\n hadDialogSession.current = false\n closeAllDialogs()\n }\n }, [status])\n // Who the persisted workspace belongs to; set at sign-in, cleared at logout.\n const storageUserRef = useRef<string | null>(null)\n // Moves at each logout: a sign-in still finishing from before it does not sign back in.\n const sessionRun = useRef(0)\n\n // The SDK could not recover the session (token refused, workspace not re-openable): drop to\n // 'disconnected' with a plain message, so the host's gate sends the user to sign in instead of\n // every call failing with a raw backend error. The remembered workspace is kept for next login.\n useEffect(\n () =>\n arbi.onSessionExpired?.(() => {\n storageUserRef.current = null\n setUser(null)\n selectWorkspaceId(null)\n setStatus('disconnected')\n setError(SESSION_EXPIRED_MESSAGE)\n }),\n [arbi, selectWorkspaceId]\n )\n\n // A saved name, picture or email reaches every surface reading `useConnection().user`.\n useEffect(\n () =>\n arbi.user.onProfileChange?.((profile) =>\n setUser((current) => (current ? userFromProfile(profile, current.externalId) : current))\n ),\n [arbi]\n )\n\n const enterDemo = useCallback(() => {\n setMode('demo')\n setStatus('demo')\n setError(null)\n setUser({ name: config.demoUser.name, email: config.demoUser.email })\n selectWorkspaceId(demoWorkspaceId)\n }, [config.demoUser.name, config.demoUser.email, demoWorkspaceId, selectWorkspaceId])\n\n /**\n * The session signed in, by whatever path (`login` below, a sign-in page on the host's `Arbi`,\n * a restored session): open the user's workspace and resolve who they are.\n */\n const completeSignIn = useCallback(\n async (email: string) => {\n const run = sessionRun.current\n const signedOut = () => run !== sessionRun.current\n setMode('live')\n setStatus('connecting')\n setError(null)\n try {\n storageUserRef.current = normalizeUserKey(email)\n const workspaces = await arbi.workspaces.list()\n if (workspaces?.length) {\n // Prefer the workspace the user last affirmatively selected (persisted),\n // then the configured workspace (there may be several — e.g. a\n // marketing/KM workspace), then whichever happens to be first. Ternary\n // (not `&&`) so an empty value can't leak `\"\"` into `target`.\n const persisted = readPersistedWorkspace(config.apiUrl, storageUserRef.current)\n const preferred = persisted ?? config.workspaceId\n const target =\n (preferred ? workspaces.find((w) => w.external_id === preferred) : undefined) ??\n (config.requireWorkspaceSelection ? undefined : workspaces[0])\n if (target) {\n selectWorkspaceId(target.external_id)\n if (!(await openSelectedWorkspace()))\n throw new Error('Could not open your workspace. Try signing in again.')\n persistWorkspace(config.apiUrl, storageUserRef.current, target.external_id)\n }\n }\n // The profile (name + avatar) comes with the login response. A session restored without\n // a login has none, so fall back to finding ourselves in the workspace roster; the email\n // local part is only the last resort, never the answer when a profile name exists.\n let resolved: ArbiUser = { name: email.split('@')[0], email }\n const me = arbi.user.identity()\n const profile = arbi.user.profile?.()\n if (profile) {\n resolved = userFromProfile(profile, me?.externalId)\n } else {\n try {\n const members = await arbi.workspaces.listUsers()\n const self = members.find((m) => m.user.external_id === me?.externalId)?.user\n if (self) {\n const fullName = [self.given_name, self.family_name].filter(Boolean).join(' ').trim()\n resolved = {\n name: fullName || email.split('@')[0],\n email: self.email || email,\n externalId: self.external_id,\n picture: self.picture ?? null,\n }\n } else if (me?.externalId) {\n resolved.externalId = me.externalId\n }\n } catch {\n // Roster not available (e.g. no workspace) — keep the fallback identity.\n }\n }\n if (signedOut()) return\n setUser(resolved)\n setStatus('authenticated')\n } catch (e) {\n if (signedOut()) return\n // Surface the real error — no silent fallback to a fake session.\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [\n arbi,\n config.workspaceId,\n config.apiUrl,\n config.requireWorkspaceSelection,\n selectWorkspaceId,\n openSelectedWorkspace,\n ]\n )\n\n // Every sign-in on the host's `Arbi` lands here, whichever page or kit made it.\n const signingIn = useRef<Promise<void>>(Promise.resolve())\n useEffect(\n () =>\n arbi.onSignedIn?.((login) => {\n signingIn.current = completeSignIn(\n login.profile?.email ??\n arbi.session?.getState().userEmail ??\n arbi.user.identity()?.email ??\n ''\n )\n }),\n [arbi, completeSignIn]\n )\n\n /** Authenticate: a live login when a backend is configured, otherwise the demo workspace. */\n const login = useCallback(\n async (email: string, password: string) => {\n setError(null)\n if (!isLiveConfigured) {\n enterDemo()\n return\n }\n setStatus('connecting')\n setMode('live')\n try {\n // Signed in: `completeSignIn` follows (onSignedIn); done once it is.\n await arbi.login(email, password)\n await signingIn.current\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, enterDemo, isLiveConfigured]\n )\n\n // The session kept on this device signs in again (no password; the key stays encrypted on the\n // device). Run once even under StrictMode.\n const restoreStarted = useRef(false)\n useEffect(() => {\n if (restoreStarted.current || !isLiveConfigured) return\n restoreStarted.current = true\n arbi\n .restore()\n .catch(() => false)\n .then(async (restored) => {\n if (restored) await signingIn.current\n else setStatus('disconnected')\n })\n }, [arbi, isLiveConfigured])\n\n // Signing out: resolves once the mail kept on this device is gone too (the account client's\n // `signOut` waits for it); `logout` starts it.\n const signOutConnection = useCallback(async () => {\n sessionRun.current++\n // The SDK stops the session's work (requests, re-logins, opens, the queries in flight) before\n // the server revokes the token.\n if (mode === 'live') {\n void arbi.logout?.()\n }\n // What was typed never outlives the session (it is sealed, but kept for no one now).\n clearSealedDrafts()\n // Nor do the documents its chats were writing in this tab.\n clearChatArtifacts()\n setUser(null)\n selectWorkspaceId(null)\n persistWorkspace(config.apiUrl, storageUserRef.current, null)\n storageUserRef.current = null\n setStatus('disconnected')\n setError(null)\n // Nor does the mail kept on this device (the per-device choices stay, #2187). The sign-out is\n // done once it is gone.\n await wipeOfflineMail().catch(() => {})\n }, [arbi, mode, config.apiUrl, selectWorkspaceId])\n const logout = useCallback(() => {\n void signOutConnection()\n }, [signOutConnection])\n\n // Affirmative selection: the shared workspace switch (live), then remember it so the next\n // login lands there too. This provider IS the host's navigation, so it alone (with sign-in and\n // ensureWorkspaceOpen, which re-open the host's own selection) changes the workspace; kits reach\n // another workspace with `arbi.workspaces.open`.\n const setWorkspace = useCallback(\n async (id: string) => {\n if (mode === 'live' && arbi.isLoggedIn) {\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n } else {\n selectWorkspaceId(id)\n }\n persistWorkspace(config.apiUrl, storageUserRef.current, id)\n },\n [arbi, mode, config.apiUrl, selectWorkspaceId, switchWorkspace]\n )\n\n // Re-open the selected workspace on the session if the server may have dropped it. Idempotent.\n // A switch in flight is waited out first, then only the selection as of then is opened (none:\n // nothing). Never a remembered or configured workspace: kits call this before reading, and\n // opening another workspace than the selected one would leave the server session in it.\n const ensureWorkspaceOpen = useCallback(async () => {\n if (mode !== 'live' || !arbi.isLoggedIn) return\n await settled()\n if (!session.getState().workspaceId) return\n await openSelectedWorkspace()\n }, [arbi, session, mode, settled, openSelectedWorkspace])\n\n const value = useMemo<ConnectionValue>(\n () => ({\n mode,\n status,\n user,\n workspaceId,\n apiConfigured: isLiveConfigured,\n apiUrl: config.apiUrl,\n deploymentDomain: isLiveConfigured ? arbi.getDeploymentDomain() : undefined,\n error,\n assistantConfig: config.assistantConfig,\n fallbackWorkspaceId: mode === 'live' ? undefined : config.workspaceId,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n }),\n [\n mode,\n status,\n user,\n workspaceId,\n isLiveConfigured,\n config.apiUrl,\n arbi,\n config.assistantConfig,\n config.workspaceId,\n error,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n ]\n )\n\n const account = useConnectionAccount(arbi, user, signOutConnection)\n const authenticated = status === 'authenticated'\n const host = useMemo(\n () => ({ account: { client: account, useEnabled: () => authenticated } }),\n [account, authenticated]\n )\n\n return (\n <ConnectionContext.Provider value={value}>\n <ArbiHost config={host}>{children}</ArbiHost>\n </ConnectionContext.Provider>\n )\n}\n\n/**\n * The account client of the settings blocks below: the SDK's, with sign-out going through this\n * connection (so its state is cleared too) and, for a session restored without a login (no SDK\n * profile), the connection user as the profile.\n */\nfunction useConnectionAccount(\n arbi: ReturnType<typeof useArbi>,\n user: ArbiUser | null,\n logout: () => Promise<void>\n): AccountClient {\n const userRef = useRef(user)\n const logoutRef = useRef(logout)\n logoutRef.current = logout\n const listeners = useRef(new Set<() => void>())\n useEffect(() => {\n userRef.current = user\n listeners.current.forEach((listener) => listener())\n }, [user])\n return useMemo(() => {\n const base = arbiAccountClient(arbi)\n return {\n ...base,\n profile: (): ProfileView | null => {\n const own = base.profile()\n const fallback = userRef.current\n if (own || !fallback) return own\n return {\n ...toProfileView({\n givenName: '',\n familyName: null,\n picture: fallback.picture ?? null,\n email: fallback.email,\n isSso: false,\n }),\n fullName: fallback.name,\n }\n },\n onProfileChange: (listener) => {\n listeners.current.add(listener)\n const off = base.onProfileChange(listener)\n return () => {\n listeners.current.delete(listener)\n off()\n }\n },\n signOut: async ({ everywhere } = {}) => {\n try {\n if (everywhere) await arbi.sessions.logoutAll()\n } finally {\n await logoutRef.current()\n }\n },\n }\n }, [arbi])\n}\n\n/** The sign-in layer of `defaultHost`, or null under a host that keeps its own session. */\nexport function useOptionalConnection(): ConnectionValue | null {\n return useContext(ConnectionContext)\n}\n\nexport function useConnection(): ConnectionValue {\n const ctx = useContext(ConnectionContext)\n if (!ctx) throw new Error('useConnection needs the sign-in layer of `defaultHost` above it')\n return ctx\n}\n\n/** The sign-in layer's person (a demo session's identity too); none without `defaultHost`. */\nexport function useConnectionUser(): ArbiUser | null {\n return useContext(ConnectionContext)?.user ?? null\n}\n\nexport const isAuthenticated = (s: ConnectionStatus) => s === 'demo' || s === 'authenticated'\n\n/** The open workspace as the connected kits see it, whoever hosts them. */\nexport interface ConnectedWorkspace {\n /** The selected workspace (the session state's; with a connection, else its fallback). */\n workspaceId: string | null\n /** Signed in to a live backend: workspace-scoped queries may run. */\n live: boolean\n /** The signed-in user (their name and email, e.g. to sign a document). */\n user: ArbiUser | null\n /** The signed-in user's external id. */\n userId: string | undefined\n /** Re-assert the workspace on the server session before a workspace-scoped write. */\n ensureWorkspaceOpen: () => Promise<void>\n /**\n * Go into a workspace: select it (with a connection) and show it (`BlocksEnvironment.\n * openWorkspace`, where a host without a connection also switches its session).\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => Promise<void>\n}\n\nconst keptOpenByHost = async () => {}\n\n/** The signed-in user of a host's own session, from its login profile. */\nfunction sessionUser(arbi: ReturnType<typeof useArbi>): ArbiUser | null {\n if (!arbi.isLoggedIn) return null\n const me = arbi.user.identity()\n const profile = arbi.user.profile()\n if (!me) return null\n return profile\n ? userFromProfile(profile, me.externalId)\n : { name: (me.email ?? '').split('@')[0], email: me.email ?? '', externalId: me.externalId }\n}\n\n/**\n * The workspace for a connected kit: the sign-in layer's (`defaultHost`) when there is one, else the\n * host's own session (an app whose host config has its `arbi` and `session` and keeps its\n * workspace open itself). So a kit runs the same in Clarum and in the ARBI app.\n */\nexport function useConnectedWorkspace(): ConnectedWorkspace {\n const connection = useContext(ConnectionContext)\n const arbi = useArbi()\n const sessionWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const live = connection ? connection.status === 'authenticated' : arbi.isLoggedIn\n const user = connection ? connection.user : live ? sessionUser(arbi) : null\n const userKey = `${user?.externalId ?? ''}|${user?.name ?? ''}|${user?.email ?? ''}`\n const { openWorkspace: showWorkspace } = useBlocksEnvironment()\n return useMemo(\n () => ({\n workspaceId: connection\n ? (connection.workspaceId ?? connection.fallbackWorkspaceId ?? null)\n : sessionWorkspaceId,\n live,\n user,\n userId: user?.externalId,\n ensureWorkspaceOpen: connection?.ensureWorkspaceOpen ?? keptOpenByHost,\n openWorkspace: async (workspaceId: string, options?: { name?: string }) => {\n if (connection) await connection.setWorkspace(workspaceId)\n showWorkspace(workspaceId, options)\n },\n }),\n // `user` is rebuilt each render without a connection: its key says when it changed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [connection, sessionWorkspaceId, live, userKey, showWorkspace]\n )\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunk7JLJH5CW_cjs = require('./chunk-7JLJH5CW.cjs');
|
|
5
|
-
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
6
5
|
var chunkQRAQZTJE_cjs = require('./chunk-QRAQZTJE.cjs');
|
|
7
|
-
var
|
|
6
|
+
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
7
|
+
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
8
8
|
var react = require('@arbidocs/react');
|
|
9
9
|
var react$1 = require('react');
|
|
10
10
|
var shell = require('@arbidocs/react/shell');
|
|
@@ -90,7 +90,7 @@ function useWorkflowTasks() {
|
|
|
90
90
|
const updateWorkflowMutation = react.useUpdateWorkflow();
|
|
91
91
|
const activeWorkspaceId = react.useArbiSessionState((s) => s.workspaceId);
|
|
92
92
|
const createWork = react.useCreateWork({ workspaceId: activeWorkspaceId });
|
|
93
|
-
const { openFiles } =
|
|
93
|
+
const { openFiles } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
94
94
|
const { mutateAsync: grant } = react.useGrantAgentAccess();
|
|
95
95
|
const grantAgentAccess = react$1.useCallback(
|
|
96
96
|
(agentExtId, workspaceId) => grant({ agentExtId, workspaceId }).then(
|
|
@@ -189,5 +189,5 @@ exports.useUsableSkillListings = useUsableSkillListings;
|
|
|
189
189
|
exports.useWorkflowDefinitions = useWorkflowDefinitions;
|
|
190
190
|
exports.useWorkflowTasks = useWorkflowTasks;
|
|
191
191
|
exports.withoutMarketplace = withoutMarketplace;
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
193
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-JSQQV23D.cjs.map
|
|
193
|
+
//# sourceMappingURL=chunk-JSQQV23D.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/useIsExternalAccount.ts","../src/connection/workflows/useSkillsEnabled.ts","../src/connection/workflows/useHostSkills.ts","../src/connection/workflows/useNamedWorkflows.ts","../src/connection/workflows/useWorkflowDefinitions.ts","../src/connection/workflows/useWorkflowTasks.ts"],"names":["useArbiSession","useUserSettings","useHost","useMemo","skillPackWorkflows","useAssistantCopy","nameBuiltinWorkflows","useSkills","useWorkflowUsage","WEB_WORKFLOWS","DASHBOARD_OPERATIONS","mergeSkillWorkflows","DASHBOARD_PINNED","sortByRecentUse","CUSTOM_TASK","REMIND_TASK","useRunWorkflow","useStartTaskQuery","useCreateWorkflow","useUpdateConversation","useUpdateWorkflow","useArbiSessionState","useCreateWork","useBlocksEnvironment","useGrantAgentAccess","useCallback","useDocuments","getDocumentTitle","taskComposerToCreateRequest","taskComposerToUpdateRequest","composerToWorkflowUpdate"],"mappings":";;;;;;;;;;;AASO,IAAM,iBAAA,GAAoB,CAAC,IAAA,KAChC,CAAC,CAAC,SAAS,IAAA,CAAK,qBAAA,KAA0B,IAAA,IAAQ,IAAA,CAAK,SAAA,KAAc,UAAA;AAMhE,SAAS,oBAAA,GAAgC;AAC9C,EAAA,OAAO,iBAAA,CAAkBA,oBAAA,EAAe,CAAE,IAAI,CAAA;AAChD;AAGO,IAAM,kBAAA,GAAqB,CAA2C,QAAA,KAC3E,QAAA,CAAS,OAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,KAAe,QAAQ;ACZ3C,SAAS,gBAAA,GAA4B;AAC1C,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,EAAa,GAAIC,qBAAA,EAAgB;AAC/C,EAAA,OAAO,cAAc,WAAA,IAAe,KAAA;AACtC;AAMO,SAAS,kBAAA,GAA8B;AAC5C,EAAA,MAAM,gBAAgB,gBAAA,EAAiB;AACvC,EAAA,MAAM,aAAa,oBAAA,EAAqB;AACxC,EAAA,OAAO,iBAAiB,CAAC,UAAA;AAC3B;ACbA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,WAAgC,EAAC;AAEhC,SAAS,aAAA,GAAqC;AACnD,EAAA,MAAM,KAAA,GAAQC,yBAAA,EAAQ,CAAE,SAAA,EAAW,UAAA;AACnC,EAAA,OAAOC,eAAA,CAAQ,MAAO,KAAA,EAAO,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQC,oCAAkB,CAAA,GAAI,QAAA,EAAW,CAAC,KAAK,CAAC,CAAA;AAC9F;AAMO,SAAS,cAAc,QAAA,EAA4C;AACxE,EAAA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gBAAgB,IAAA,EAAM,GAAA,CAAI,IAAA,IAAQ,IAAA,EAAM,CAAA;AAEzF,MAAA,IAAI,QAAA,CAAS,QAAA,KAAa,KAAA,EAAO,OAAO,KAAA,CAAM,MAAA;AAC9C,MAAA,MAAM,WAAA,GAAc,SAAS,gBAAA,IAAoB,iBAAA;AACjD,MAAA,MAAM,OAAA,GAAU,MAAM,sBAAA,CAAuB,WAAA,CAAY;AAAA,QACvD,YAAY,QAAA,CAAS,WAAA;AAAA,QACrB;AAAA,OACD,CAAA;AAED,MAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,YAAA,IAAgB,KAAA,CAAM,gBAAgB,QAAA,CAAS,YAAA;AACvE,MAAA,IACE,QAAQ,SAAA,KAAc,qBAAA,IACtB,CAAC,OAAA,CAAQ,SAAA,IACT,WACA,WAAA,EACA;AACA,QAAA,MAAM,gBAAA,CAAiB,SAAS,WAAW,CAAA;AAAA,MAC7C;AAAA,IACF,CAAA;AAAA,IACA,CAAC,iBAAA,EAAmB,cAAA,EAAgB,gBAAA,EAAkB,sBAAsB;AAAA,GAC9E;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,SAAA,EACE,WAAW,SAAA,IACX,UAAA,CAAW,aACX,cAAA,CAAe,SAAA,IACf,kBAAA,CAAmB,SAAA,IACnB,sBAAA,CAAuB;AAAA,GAC3B;AACF","file":"chunk-3GYOWDNM.cjs","sourcesContent":["import { useArbiSession } from '@arbidocs/react'\n\n/** The account fields that say it is an external one. */\ninterface AccountKind {\n temporary_access_only?: boolean | null\n user_type?: string | null\n}\n\n/** An external account: temporary access to shared workspaces only. */\nexport const isExternalAccount = (user: AccountKind | null | undefined): boolean =>\n !!user && (user.temporary_access_only === true || user.user_type === 'external')\n\n/**\n * Whether the signed-in person is an external guest. They get the built-in skills and the host's\n * skill packs, never the marketplace (the backend enforces it as well).\n */\nexport function useIsExternalAccount(): boolean {\n return isExternalAccount(useArbiSession().user)\n}\n\n/** Skill listings without the marketplace's (`visibility: global`): what an external guest gets. */\nexport const withoutMarketplace = <T extends { visibility?: string | null }>(listings: T[]): T[] =>\n listings.filter((s) => s.visibility !== 'global')\n","/**\n * The one gate for everything skill-shaped in the app: the empty chat's Start list, the skill\n * entries of the slash menu, the sidebar's Skills item, the Skills browser's entry points and the\n * typed `/skill` interception. It is the personal `show_skills` user setting, default off; the\n * switch lives in Settings, Experimental (developers only), so today only developers have it.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\nimport { useIsExternalAccount } from '../useIsExternalAccount'\n\nexport function useSkillsEnabled(): boolean {\n const { data: userSettings } = useUserSettings()\n return userSettings?.show_skills ?? false\n}\n\n/**\n * Whether the Skills browser (the marketplace: \"Browse skills\", the Skills menu entry) is offered:\n * to skills users, never to an external guest (the backend enforces it as well).\n */\nexport function useCanBrowseSkills(): boolean {\n const skillsEnabled = useSkillsEnabled()\n const isExternal = useIsExternalAccount()\n return skillsEnabled && !isExternal\n}\n","/**\n * The host's skill packs (`host.workflows.skillPacks`) as the kit's workflows, and the `/` menu's\n * rows for them: one section per heading (a category, else a pack's label).\n */\nimport { useMemo } from 'react'\nimport { skillPackWorkflows, type SkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { useHost } from '../../provider/host'\n\n/** The section heading of a pack without a label or category. */\nconst DEFAULT_PACK_LABEL = 'Skills from this site'\n\nconst NO_PACKS: SkillPackWorkflow[] = []\n\nexport function useHostSkills(): SkillPackWorkflow[] {\n const packs = useHost().workflows?.skillPacks\n return useMemo(() => (packs?.length ? packs.flatMap(skillPackWorkflows) : NO_PACKS), [packs])\n}\n\n/**\n * A pack skill's `/` menu row. Its section is its heading (its category, else its pack's label), so\n * skills of several packs under one heading share one section.\n */\nexport function hostSkillItem(workflow: SkillPackWorkflow): SlashMenuItem {\n const label = workflow.category ?? workflow.pack.label ?? DEFAULT_PACK_LABEL\n return {\n name: workflow.id,\n description: workflow.description,\n kind: 'skill',\n group: { id: `pack-${label.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`, label },\n }\n}\n","import { useMemo } from 'react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { nameBuiltinWorkflows } from '../../agents/workflows/catalogue/seed'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\n\n/** The seeded workflows in the host's assistant name (`nameBuiltinWorkflows`). */\nexport function useNamedWorkflows(\n workflows: ReadonlyArray<WorkflowDefinition>\n): WorkflowDefinition[] {\n const copy = useAssistantCopy()\n return useMemo(() => nameBuiltinWorkflows(workflows, copy), [workflows, copy])\n}\n","/**\n * The one list of workflows: the seeded ones plus every skill the user can invoke (each degraded\n * to a single-field form from its `arg_hint`). The dashboard tiles, the slash menu, tasks and\n * agents all read this.\n */\n\nimport { useMemo } from 'react'\nimport { useSkills } from '@arbidocs/react'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport {\n CUSTOM_TASK,\n DASHBOARD_OPERATIONS,\n DASHBOARD_PINNED,\n REMIND_TASK,\n} from '../../agents/workflows/catalogue/seed'\nimport { useSkillsEnabled } from './useSkillsEnabled'\nimport { useHostSkills } from './useHostSkills'\nimport { useIsExternalAccount, withoutMarketplace } from '../useIsExternalAccount'\nimport { sortByRecentUse, useWorkflowUsage } from '../../agents/workflows/catalogue/workflow-usage'\nimport { WEB_WORKFLOWS } from '../../agents/workflows/catalogue/registry'\nimport { useNamedWorkflows } from './useNamedWorkflows'\n\nexport interface UseWorkflowDefinitionsResult {\n /**\n * Every skill workflow of this host: built-ins, the host's skill packs, then the user's and the\n * marketplace's (one list).\n */\n skills: WorkflowDefinition[]\n /** The user has skills switched on (`show_skills`): the gate of every skill-shaped surface. */\n skillsEnabled: boolean\n /**\n * The empty chat's Start section: built-ins first (their own order), then the user's own and\n * marketplace skills by recent use, then name. EMPTY for users without skills enabled.\n */\n start: WorkflowDefinition[]\n /** The dashboard Start band: pinned skills in order, then the operation launchers. */\n dashboard: WorkflowDefinition[]\n /** What a task can run: schedulable skills plus a free instruction and a reminder. */\n forTasks: WorkflowDefinition[]\n}\n\n/**\n * The skill listings a person may use from the menus: a host pack's slug is the pack's (an\n * installed copy is the same skill), and an external guest gets no marketplace skills.\n */\nexport function useUsableSkillListings(hostSkills: ReadonlyArray<WorkflowDefinition>) {\n const { data: listings } = useSkills()\n const isExternal = useIsExternalAccount()\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n const usable = (listings ?? []).filter((s) => !packSlugs.has(s.slug))\n return isExternal ? withoutMarketplace(usable) : usable\n }, [listings, hostSkills, isExternal])\n}\n\nexport function useWorkflowDefinitions(): UseWorkflowDefinitionsResult {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const usage = useWorkflowUsage()\n const skillsEnabled = useSkillsEnabled()\n const web = useNamedWorkflows(WEB_WORKFLOWS)\n const operations = useNamedWorkflows(DASHBOARD_OPERATIONS)\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n // An uploaded skill of a built-in's slug is used instead of it.\n const { host: builtins, skills: fromServer } = mergeSkillWorkflows(\n web.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n // The host's packs sit with the built-ins; they are listed in the menus, not in Start.\n const all = [...builtins, ...hostSkills, ...fromServer]\n const byId = new Map(all.map((w) => [w.id, w]))\n const pinned = DASHBOARD_PINNED.flatMap((id) => {\n const w = byId.get(id)\n return w ? [w] : []\n })\n return {\n skills: all,\n skillsEnabled,\n start: skillsEnabled ? [...builtins, ...sortByRecentUse(fromServer, usage)] : [],\n dashboard: [...pinned, ...operations],\n forTasks: [CUSTOM_TASK, ...all.filter((w) => w.schedulable), REMIND_TASK],\n }\n }, [hostSkills, listings, usage, skillsEnabled, web, operations])\n}\n","/**\n * Creating and updating work and workflows from the composer, in one place.\n *\n * \"Now\" is an assistant query with task options (the person's own run: the thread becomes a task); a plain\n * to-do creates work with no run. Any other start (a date, a repeat, an event, after another task) saves a workflow\n * that creates the work when it fires. The request mapping is shared with every host (and tested in\n * blocks): `taskComposerToCreateRequest` decides which.\n *\n * Workspace authorization is a per-run, least-privilege choice (`auth_mode`) composed over the shipped\n * workspace-access-request + grant machinery:\n * - Now -> no tier: the query runs as the person asking, with their own access.\n * - Workflow -> `scheduled_require_auth` by default (asks at run time), or `scheduled_permanent`\n * (\"keep access\"): standing membership so unattended runs can decrypt while the owner\n * is away. Only this tier grants membership.\n */\n\nimport {\n useCreateWorkflow,\n useGrantAgentAccess,\n useRunWorkflow,\n useUpdateWorkflow,\n useDocuments,\n useArbiSessionState,\n useCreateWork,\n useStartTaskQuery,\n useUpdateConversation,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport type { components } from '@arbidocs/client'\nimport { useCallback, useMemo } from 'react'\nimport {\n composerToWorkflowUpdate,\n taskComposerToCreateRequest,\n taskComposerToUpdateRequest,\n} from '../../agents/tasks/taskRequest'\nimport { type TaskComposerValues } from '../../agents/tasks/taskComposerTypes'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport type { TaskPlan } from '../../agents/workflows/planSteps'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\ntype Task = components['schemas']['ConversationResponse']\ntype Workflow = components['schemas']['WorkflowResponse']\n\nexport interface TaskSubmitContext {\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** Goal checklist for agent work, if one was drafted. */\n plan?: TaskPlan | null\n}\n\n/** What a composer submission created. `ran` is null for work no agent runs. */\nexport type CreateOutcome =\n | { kind: 'work'; task: Pick<Task, 'title'> & { external_id?: string }; ran: boolean | null }\n | { kind: 'workflow'; workflow: Workflow }\n\nexport function useWorkflowTasks() {\n const runWorkflow = useRunWorkflow()\n const startQuery = useStartTaskQuery()\n const createWorkflow = useCreateWorkflow()\n const updateConversation = useUpdateConversation()\n const updateWorkflowMutation = useUpdateWorkflow()\n const activeWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const createWork = useCreateWork({ workspaceId: activeWorkspaceId })\n const { openFiles } = useBlocksEnvironment()\n\n // Standing access for a workflow's agent, so its unattended runs can read the workspace. An agent\n // that is already a member makes the server refuse the re-grant: that is no failure here.\n const { mutateAsync: grant } = useGrantAgentAccess()\n const grantAgentAccess = useCallback(\n (agentExtId: string, workspaceId: string) =>\n grant({ agentExtId, workspaceId }).then(\n () => undefined,\n () => undefined\n ),\n [grant]\n )\n // File names for the prompt's wording (\"the document <name>\"): the server is told the ids as well.\n const { data: documents = [] } = useDocuments()\n const documentTitles = useMemo(\n () =>\n Object.fromEntries(documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])),\n [documents]\n )\n\n /**\n * Create work or a workflow. `forceWorkflow` is for the workflow dialog, where even a reminder is\n * saved as a workflow.\n */\n const create = useCallback(\n async (ctx: TaskSubmitContext, forceWorkflow = false): Promise<CreateOutcome> => {\n const request = taskComposerToCreateRequest(\n { ...ctx, documentTitles, plan: ctx.plan ?? null },\n activeWorkspaceId ?? undefined,\n forceWorkflow\n )\n if (request.kind === 'workflow') {\n const workflow = await createWorkflow.mutateAsync(request.body)\n // Keep access: deposit the key for the agent the server assigned (the Assistant when none was\n // picked), while the owner is here, so unattended runs start on their own.\n const workspaceId = workflow.workspace_ext_id ?? request.body.workspace_ext_id\n if (\n workflow.auth_mode === 'scheduled_permanent' &&\n !workflow.on_demand &&\n workflow.agent_ext_id &&\n workspaceId\n ) {\n await grantAgentAccess(workflow.agent_ext_id, workspaceId)\n }\n if (ctx.workflow.documentAction && ctx.values.when === 'now' && !forceWorkflow) {\n const result = await runWorkflow.mutateAsync(workflow.external_id)\n if (result.error) throw new Error(result.error)\n openFiles()\n }\n return { kind: 'workflow', workflow }\n }\n if (request.kind === 'query') {\n // Run now is the person's own assistant query: it makes the thread a task and runs it.\n const { conversationId } = await startQuery.start(request.query)\n return {\n kind: 'work',\n task: { external_id: conversationId, title: request.query.task.title ?? null },\n ran: true,\n }\n }\n // A plain to-do (or reminder): a task with no run.\n const task = await createWork.mutateAsync(request.body)\n return { kind: 'work', task, ran: null }\n },\n [\n activeWorkspaceId,\n createWork,\n createWorkflow,\n documentTitles,\n grantAgentAccess,\n startQuery,\n runWorkflow,\n openFiles,\n ]\n )\n\n /** PATCH the editable fields of a task (the instruction, workspace and agent stay as created). */\n const update = useCallback(\n async (task: Pick<Task, 'external_id'> & { is_owner?: boolean }, ctx: TaskSubmitContext) => {\n const patch = taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null })\n // Who can see a task is its owner's to change: an editor's save leaves it out.\n if (task.is_owner === false) delete patch.shared\n await updateConversation.mutateAsync({ conversationId: task.external_id, patch })\n },\n [updateConversation]\n )\n\n /** PATCH a workflow: its name, trigger and action. */\n const updateWorkflow = useCallback(\n async (\n workflow: Pick<Workflow, 'external_id' | 'agent_ext_id' | 'workspace_ext_id'> & {\n is_owner?: boolean\n },\n ctx: TaskSubmitContext\n ) => {\n const patch = composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null })\n // Sharing a workflow is its owner's: an editor's save leaves it out.\n if (workflow.is_owner === false) delete patch.shared\n const workspaceId = workflow.workspace_ext_id ?? activeWorkspaceId\n const updated = await updateWorkflowMutation.mutateAsync({\n workflowId: workflow.external_id,\n patch,\n })\n // The agent the server keeps (the Assistant when none was picked) gets the key for unattended runs.\n const agentId = updated.agent_ext_id ?? patch.agent_ext_id ?? workflow.agent_ext_id\n if (\n updated.auth_mode === 'scheduled_permanent' &&\n !updated.on_demand &&\n agentId &&\n workspaceId\n ) {\n await grantAgentAccess(agentId, workspaceId)\n }\n },\n [activeWorkspaceId, documentTitles, grantAgentAccess, updateWorkflowMutation]\n )\n\n return {\n create,\n update,\n updateWorkflow,\n isPending:\n createWork.isPending ||\n startQuery.isPending ||\n createWorkflow.isPending ||\n updateConversation.isPending ||\n updateWorkflowMutation.isPending,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/useIsExternalAccount.ts","../src/connection/workflows/useSkillsEnabled.ts","../src/connection/workflows/useHostSkills.ts","../src/connection/workflows/useNamedWorkflows.ts","../src/connection/workflows/useWorkflowDefinitions.ts","../src/connection/workflows/useWorkflowTasks.ts"],"names":["useArbiSession","useUserSettings","useHost","useMemo","skillPackWorkflows","useAssistantCopy","nameBuiltinWorkflows","useSkills","useWorkflowUsage","WEB_WORKFLOWS","DASHBOARD_OPERATIONS","mergeSkillWorkflows","DASHBOARD_PINNED","sortByRecentUse","CUSTOM_TASK","REMIND_TASK","useRunWorkflow","useStartTaskQuery","useCreateWorkflow","useUpdateConversation","useUpdateWorkflow","useArbiSessionState","useCreateWork","useBlocksEnvironment","useGrantAgentAccess","useCallback","useDocuments","getDocumentTitle","taskComposerToCreateRequest","taskComposerToUpdateRequest","composerToWorkflowUpdate"],"mappings":";;;;;;;;;;;AASO,IAAM,iBAAA,GAAoB,CAAC,IAAA,KAChC,CAAC,CAAC,SAAS,IAAA,CAAK,qBAAA,KAA0B,IAAA,IAAQ,IAAA,CAAK,SAAA,KAAc,UAAA;AAMhE,SAAS,oBAAA,GAAgC;AAC9C,EAAA,OAAO,iBAAA,CAAkBA,oBAAA,EAAe,CAAE,IAAI,CAAA;AAChD;AAGO,IAAM,kBAAA,GAAqB,CAA2C,QAAA,KAC3E,QAAA,CAAS,OAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,KAAe,QAAQ;ACZ3C,SAAS,gBAAA,GAA4B;AAC1C,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,EAAa,GAAIC,qBAAA,EAAgB;AAC/C,EAAA,OAAO,cAAc,WAAA,IAAe,KAAA;AACtC;AAMO,SAAS,kBAAA,GAA8B;AAC5C,EAAA,MAAM,gBAAgB,gBAAA,EAAiB;AACvC,EAAA,MAAM,aAAa,oBAAA,EAAqB;AACxC,EAAA,OAAO,iBAAiB,CAAC,UAAA;AAC3B;ACbA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,W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@arbidocs/react'\n\n/** The account fields that say it is an external one. */\ninterface AccountKind {\n temporary_access_only?: boolean | null\n user_type?: string | null\n}\n\n/** An external account: temporary access to shared workspaces only. */\nexport const isExternalAccount = (user: AccountKind | null | undefined): boolean =>\n !!user && (user.temporary_access_only === true || user.user_type === 'external')\n\n/**\n * Whether the signed-in person is an external guest. They get the built-in skills and the host's\n * skill packs, never the marketplace (the backend enforces it as well).\n */\nexport function useIsExternalAccount(): boolean {\n return isExternalAccount(useArbiSession().user)\n}\n\n/** Skill listings without the marketplace's (`visibility: global`): what an external guest gets. */\nexport const withoutMarketplace = <T extends { visibility?: string | null }>(listings: T[]): T[] =>\n listings.filter((s) => s.visibility !== 'global')\n","/**\n * The one gate for everything skill-shaped in the app: the empty chat's Start list, the skill\n * entries of the slash menu, the sidebar's Skills item, the Skills browser's entry points and the\n * typed `/skill` interception. It is the personal `show_skills` user setting, default off; the\n * switch lives in Settings, Experimental (developers only), so today only developers have it.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\nimport { useIsExternalAccount } from '../useIsExternalAccount'\n\nexport function useSkillsEnabled(): boolean {\n const { data: userSettings } = useUserSettings()\n return userSettings?.show_skills ?? false\n}\n\n/**\n * Whether the Skills browser (the marketplace: \"Browse skills\", the Skills menu entry) is offered:\n * to skills users, never to an external guest (the backend enforces it as well).\n */\nexport function useCanBrowseSkills(): boolean {\n const skillsEnabled = useSkillsEnabled()\n const isExternal = useIsExternalAccount()\n return skillsEnabled && !isExternal\n}\n","/**\n * The host's skill packs (`host.workflows.skillPacks`) as the kit's workflows, and the `/` menu's\n * rows for them: one section per heading (a category, else a pack's label).\n */\nimport { useMemo } from 'react'\nimport { skillPackWorkflows, type SkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { useHost } from '../../provider/host'\n\n/** The section heading of a pack without a label or category. */\nconst DEFAULT_PACK_LABEL = 'Skills from this site'\n\nconst NO_PACKS: SkillPackWorkflow[] = []\n\nexport function useHostSkills(): SkillPackWorkflow[] {\n const packs = useHost().workflows?.skillPacks\n return useMemo(() => (packs?.length ? packs.flatMap(skillPackWorkflows) : NO_PACKS), [packs])\n}\n\n/**\n * A pack skill's `/` menu row. Its section is its heading (its category, else its pack's label), so\n * skills of several packs under one heading share one section.\n */\nexport function hostSkillItem(workflow: SkillPackWorkflow): SlashMenuItem {\n const label = workflow.category ?? workflow.pack.label ?? DEFAULT_PACK_LABEL\n return {\n name: workflow.id,\n description: workflow.description,\n kind: 'skill',\n group: { id: `pack-${label.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`, label },\n }\n}\n","import { useMemo } from 'react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { nameBuiltinWorkflows } from '../../agents/workflows/catalogue/seed'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\n\n/** The seeded workflows in the host's assistant name (`nameBuiltinWorkflows`). */\nexport function useNamedWorkflows(\n workflows: ReadonlyArray<WorkflowDefinition>\n): WorkflowDefinition[] {\n const copy = useAssistantCopy()\n return useMemo(() => nameBuiltinWorkflows(workflows, copy), [workflows, copy])\n}\n","/**\n * The one list of workflows: the seeded ones plus every skill the user can invoke (each degraded\n * to a single-field form from its `arg_hint`). The dashboard tiles, the slash menu, tasks and\n * agents all read this.\n */\n\nimport { useMemo } from 'react'\nimport { useSkills } from '@arbidocs/react'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport {\n CUSTOM_TASK,\n DASHBOARD_OPERATIONS,\n DASHBOARD_PINNED,\n REMIND_TASK,\n} from '../../agents/workflows/catalogue/seed'\nimport { useSkillsEnabled } from './useSkillsEnabled'\nimport { useHostSkills } from './useHostSkills'\nimport { useIsExternalAccount, withoutMarketplace } from '../useIsExternalAccount'\nimport { sortByRecentUse, useWorkflowUsage } from '../../agents/workflows/catalogue/workflow-usage'\nimport { WEB_WORKFLOWS } from '../../agents/workflows/catalogue/registry'\nimport { useNamedWorkflows } from './useNamedWorkflows'\n\nexport interface UseWorkflowDefinitionsResult {\n /**\n * Every skill workflow of this host: built-ins, the host's skill packs, then the user's and the\n * marketplace's (one list).\n */\n skills: WorkflowDefinition[]\n /** The user has skills switched on (`show_skills`): the gate of every skill-shaped surface. */\n skillsEnabled: boolean\n /**\n * The empty chat's Start section: built-ins first (their own order), then the user's own and\n * marketplace skills by recent use, then name. EMPTY for users without skills enabled.\n */\n start: WorkflowDefinition[]\n /** The dashboard Start band: pinned skills in order, then the operation launchers. */\n dashboard: WorkflowDefinition[]\n /** What a task can run: schedulable skills plus a free instruction and a reminder. */\n forTasks: WorkflowDefinition[]\n}\n\n/**\n * The skill listings a person may use from the menus: a host pack's slug is the pack's (an\n * installed copy is the same skill), and an external guest gets no marketplace skills.\n */\nexport function useUsableSkillListings(hostSkills: ReadonlyArray<WorkflowDefinition>) {\n const { data: listings } = useSkills()\n const isExternal = useIsExternalAccount()\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n const usable = (listings ?? []).filter((s) => !packSlugs.has(s.slug))\n return isExternal ? withoutMarketplace(usable) : usable\n }, [listings, hostSkills, isExternal])\n}\n\nexport function useWorkflowDefinitions(): UseWorkflowDefinitionsResult {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const usage = useWorkflowUsage()\n const skillsEnabled = useSkillsEnabled()\n const web = useNamedWorkflows(WEB_WORKFLOWS)\n const operations = useNamedWorkflows(DASHBOARD_OPERATIONS)\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n // An uploaded skill of a built-in's slug is used instead of it.\n const { host: builtins, skills: fromServer } = mergeSkillWorkflows(\n web.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n // The host's packs sit with the built-ins; they are listed in the menus, not in Start.\n const all = [...builtins, ...hostSkills, ...fromServer]\n const byId = new Map(all.map((w) => [w.id, w]))\n const pinned = DASHBOARD_PINNED.flatMap((id) => {\n const w = byId.get(id)\n return w ? [w] : []\n })\n return {\n skills: all,\n skillsEnabled,\n start: skillsEnabled ? [...builtins, ...sortByRecentUse(fromServer, usage)] : [],\n dashboard: [...pinned, ...operations],\n forTasks: [CUSTOM_TASK, ...all.filter((w) => w.schedulable), REMIND_TASK],\n }\n }, [hostSkills, listings, usage, skillsEnabled, web, operations])\n}\n","/**\n * Creating and updating work and workflows from the composer, in one place.\n *\n * \"Now\" is an assistant query with task options (the person's own run: the thread becomes a task); a plain\n * to-do creates work with no run. Any other start (a date, a repeat, an event, after another task) saves a workflow\n * that creates the work when it fires. The request mapping is shared with every host (and tested in\n * blocks): `taskComposerToCreateRequest` decides which.\n *\n * Workspace authorization is a per-run, least-privilege choice (`auth_mode`) composed over the shipped\n * workspace-access-request + grant machinery:\n * - Now -> no tier: the query runs as the person asking, with their own access.\n * - Workflow -> `scheduled_require_auth` by default (asks at run time), or `scheduled_permanent`\n * (\"keep access\"): standing membership so unattended runs can decrypt while the owner\n * is away. Only this tier grants membership.\n */\n\nimport {\n useCreateWorkflow,\n useGrantAgentAccess,\n useRunWorkflow,\n useUpdateWorkflow,\n useDocuments,\n useArbiSessionState,\n useCreateWork,\n useStartTaskQuery,\n useUpdateConversation,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport type { components } from '@arbidocs/client'\nimport { useCallback, useMemo } from 'react'\nimport {\n composerToWorkflowUpdate,\n taskComposerToCreateRequest,\n taskComposerToUpdateRequest,\n} from '../../agents/tasks/taskRequest'\nimport { type TaskComposerValues } from '../../agents/tasks/taskComposerTypes'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport type { TaskPlan } from '../../agents/workflows/planSteps'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\ntype Task = components['schemas']['ConversationResponse']\ntype Workflow = components['schemas']['WorkflowResponse']\n\nexport interface TaskSubmitContext {\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** Goal checklist for agent work, if one was drafted. */\n plan?: TaskPlan | null\n}\n\n/** What a composer submission created. `ran` is null for work no agent runs. */\nexport type CreateOutcome =\n | { kind: 'work'; task: Pick<Task, 'title'> & { external_id?: string }; ran: boolean | null }\n | { kind: 'workflow'; workflow: Workflow }\n\nexport function useWorkflowTasks() {\n const runWorkflow = useRunWorkflow()\n const startQuery = useStartTaskQuery()\n const createWorkflow = useCreateWorkflow()\n const updateConversation = useUpdateConversation()\n const updateWorkflowMutation = useUpdateWorkflow()\n const activeWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const createWork = useCreateWork({ workspaceId: activeWorkspaceId })\n const { openFiles } = useBlocksEnvironment()\n\n // Standing access for a workflow's agent, so its unattended runs can read the workspace. An agent\n // that is already a member makes the server refuse the re-grant: that is no failure here.\n const { mutateAsync: grant } = useGrantAgentAccess()\n const grantAgentAccess = useCallback(\n (agentExtId: string, workspaceId: string) =>\n grant({ agentExtId, workspaceId }).then(\n () => undefined,\n () => undefined\n ),\n [grant]\n )\n // File names for the prompt's wording (\"the document <name>\"): the server is told the ids as well.\n const { data: documents = [] } = useDocuments()\n const documentTitles = useMemo(\n () =>\n Object.fromEntries(documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])),\n [documents]\n )\n\n /**\n * Create work or a workflow. `forceWorkflow` is for the workflow dialog, where even a reminder is\n * saved as a workflow.\n */\n const create = useCallback(\n async (ctx: TaskSubmitContext, forceWorkflow = false): Promise<CreateOutcome> => {\n const request = taskComposerToCreateRequest(\n { ...ctx, documentTitles, plan: ctx.plan ?? null },\n activeWorkspaceId ?? undefined,\n forceWorkflow\n )\n if (request.kind === 'workflow') {\n const workflow = await createWorkflow.mutateAsync(request.body)\n // Keep access: deposit the key for the agent the server assigned (the Assistant when none was\n // picked), while the owner is here, so unattended runs start on their own.\n const workspaceId = workflow.workspace_ext_id ?? request.body.workspace_ext_id\n if (\n workflow.auth_mode === 'scheduled_permanent' &&\n !workflow.on_demand &&\n workflow.agent_ext_id &&\n workspaceId\n ) {\n await grantAgentAccess(workflow.agent_ext_id, workspaceId)\n }\n if (ctx.workflow.documentAction && ctx.values.when === 'now' && !forceWorkflow) {\n const result = await runWorkflow.mutateAsync(workflow.external_id)\n if (result.error) throw new Error(result.error)\n openFiles()\n }\n return { kind: 'workflow', workflow }\n }\n if (request.kind === 'query') {\n // Run now is the person's own assistant query: it makes the thread a task and runs it.\n const { conversationId } = await startQuery.start(request.query)\n return {\n kind: 'work',\n task: { external_id: conversationId, title: request.query.task.title ?? null },\n ran: true,\n }\n }\n // A plain to-do (or reminder): a task with no run.\n const task = await createWork.mutateAsync(request.body)\n return { kind: 'work', task, ran: null }\n },\n [\n activeWorkspaceId,\n createWork,\n createWorkflow,\n documentTitles,\n grantAgentAccess,\n startQuery,\n runWorkflow,\n openFiles,\n ]\n )\n\n /** PATCH the editable fields of a task (the instruction, workspace and agent stay as created). */\n const update = useCallback(\n async (task: Pick<Task, 'external_id'> & { is_owner?: boolean }, ctx: TaskSubmitContext) => {\n const patch = taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null })\n // Who can see a task is its owner's to change: an editor's save leaves it out.\n if (task.is_owner === false) delete patch.shared\n await updateConversation.mutateAsync({ conversationId: task.external_id, patch })\n },\n [updateConversation]\n )\n\n /** PATCH a workflow: its name, trigger and action. */\n const updateWorkflow = useCallback(\n async (\n workflow: Pick<Workflow, 'external_id' | 'agent_ext_id' | 'workspace_ext_id'> & {\n is_owner?: boolean\n },\n ctx: TaskSubmitContext\n ) => {\n const patch = composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null })\n // Sharing a workflow is its owner's: an editor's save leaves it out.\n if (workflow.is_owner === false) delete patch.shared\n const workspaceId = workflow.workspace_ext_id ?? activeWorkspaceId\n const updated = await updateWorkflowMutation.mutateAsync({\n workflowId: workflow.external_id,\n patch,\n })\n // The agent the server keeps (the Assistant when none was picked) gets the key for unattended runs.\n const agentId = updated.agent_ext_id ?? patch.agent_ext_id ?? workflow.agent_ext_id\n if (\n updated.auth_mode === 'scheduled_permanent' &&\n !updated.on_demand &&\n agentId &&\n workspaceId\n ) {\n await grantAgentAccess(agentId, workspaceId)\n }\n },\n [activeWorkspaceId, documentTitles, grantAgentAccess, updateWorkflowMutation]\n )\n\n return {\n create,\n update,\n updateWorkflow,\n isPending:\n createWork.isPending ||\n startQuery.isPending ||\n createWorkflow.isPending ||\n updateConversation.isPending ||\n updateWorkflowMutation.isPending,\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ function isModifiedClick(event) {
|
|
|
9
9
|
return event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
10
10
|
}
|
|
11
11
|
var ActionLink = react.forwardRef(function ActionLink2({ href, external = false, onSelect, disabled, children, ...rest }, ref) {
|
|
12
|
-
const { linkComponent: Link } =
|
|
12
|
+
const { linkComponent: Link } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
13
13
|
if (!href || disabled) {
|
|
14
14
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
15
|
"button",
|
|
@@ -49,5 +49,5 @@ var ActionLink = react.forwardRef(function ActionLink2({ href, external = false,
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
exports.ActionLink = ActionLink;
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-JV5TVUOU.cjs.map
|
|
53
|
+
//# sourceMappingURL=chunk-JV5TVUOU.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ActionLink.tsx"],"names":["forwardRef","ActionLink","useBlocksEnvironment","jsx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AA,IAAI,IAAA,EAAM;AACR,IAAA,uBACEA,cAAA,CAAC,QAAM,GAAG,WAAA,EAAc,GAAI,EAAE,GAAA,IAC3B,QAAA,EACH,CAAA;AAAA,EAEJ;AACA,EAAA,uBACEA,cAAA,CAAC,GAAA,EAAA,EAAG,GAAG,WAAA,EAAa,KACjB,QAAA,EACH,CAAA;AAEJ,CAAC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/components/ActionLink.tsx"],"names":["forwardRef","ActionLink","useBlocksEnvironment","jsx"],"mappings":";;;;;;AA8BA,SAAS,gBAAgB,KAAA,EAA4B;AACnD,EAAA,OAAO,KAAA,CAAM,WAAW,CAAA,IAAK,KAAA,CAAM,WAAW,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,QAAA,IAAY,KAAA,CAAM,MAAA;AACzF;AAOO,IAAM,UAAA,GAAaA,gBAAA,CAAyC,SAASC,WAAAA,CAC1E,EAAE,IAAA,EAAM,QAAA,GAAW,KAAA,EAAO,QAAA,EAAU,QAAA,EAAU,QAAA,EAAU,GAAG,IAAA,IAC3D,GAAA,EACA;AACA,EAAA,MAAM,EAAE,aAAA,EAAe,IAAA,EAAK,GAAIC,sCAAA,EAAqB;AAErD,EAAA,IAAI,CAAC,QAAQ,QAAA,EAAU;AACrB,IAAA,uBACEC,cAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACE,GAAG,IAAA;AAAA,QACJ,GAAA;AAAA,QACA,IAAA,EAAK,QAAA;AAAA,QACL,QAAA;AAAA,QACA,OAAA,EAAS,QAAA;AAAA,QAER;AAAA;AAAA,KACH;AAAA,EAEJ;AAEA,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,uBACEA,cAAA;AAAA,MAAC,GAAA;AAAA,MAAA;AAAA,QACE,GAAI,IAAA;AAAA,QACL,GAAA;AAAA,QACA,IAAA;AAAA,QACA,MAAA,EAAO,QAAA;AAAA,QACP,GAAA,EAAI,qBAAA;AAAA,QAEH;AAAA;AAAA,KACH;AAAA,EAEJ;AAEA,EAAA,MAAM,WAAA,GAAc,CAAC,KAAA,KAAyC;AAC5D,IAAA,IAAI,CAAC,QAAA,IAAY,KAAA,CAAM,gBAAA,IAAoB,eAAA,CAAgB,KAAK,CAAA,EAAG;AACnE,IAAA,KAAA,CAAM,cAAA,EAAe;AACrB,IAAA,QAAA,EAAS;AAAA,EACX,CAAA;AACA,EAAA,MAAM,cAAc,EAAE,GAAG,IAAA,EAAM,IAAA,EAAM,SAAS,WAAA,EAAY;AAC1D,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,uBACEA,cAAA,CAAC,QAAM,GAAG,WAAA,EAAc,GAAI,EAAE,GAAA,IAC3B,QAAA,EACH,CAAA;AAAA,EAEJ;AACA,EAAA,uBACEA,cAAA,CAAC,GAAA,EAAA,EAAG,GAAG,WAAA,EAAa,KACjB,QAAA,EACH,CAAA;AAEJ,CAAC","file":"chunk-JV5TVUOU.cjs","sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ReactNode,\n type Ref,\n} from 'react'\nimport { useBlocksEnvironment } from '../provider/environment'\nimport type { BlockLinkRenderProps } from './blockLink'\n\nexport interface ActionLinkProps extends Omit<\n ComponentPropsWithoutRef<'button'>,\n 'onClick' | 'type' | 'children'\n> {\n /**\n * Destination. When set (and not `disabled`) the control is a real anchor, rendered through\n * the host environment's `linkComponent` (plain `<a>` by default), so ctrl/cmd-click and \"open in new\n * tab\" work. Without `onSelect` a plain click navigates through the link; with `onSelect`, a plain\n * click calls it instead (it owns navigation) and modified clicks still use the link.\n */\n href?: string\n /**\n * `href` leaves the site: a plain anchor that opens in a new tab (`rel=\"noopener noreferrer\"`),\n * never through the host's router or `onSelect`.\n */\n external?: boolean\n onSelect?: () => void\n children?: ReactNode\n}\n\nfunction isModifiedClick(event: MouseEvent): boolean {\n return event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey\n}\n\n/**\n * The one \"go somewhere / do something\" control of the link-like blocks: a `<button>` without an\n * `href`, an anchor with one. Forwards its ref and any extra props so it can sit under a\n * tooltip or popover trigger `asChild`.\n */\nexport const ActionLink = forwardRef<HTMLElement, ActionLinkProps>(function ActionLink(\n { href, external = false, onSelect, disabled, children, ...rest },\n ref\n) {\n const { linkComponent: Link } = useBlocksEnvironment()\n\n if (!href || disabled) {\n return (\n <button\n {...rest}\n ref={ref as Ref<HTMLButtonElement>}\n type=\"button\"\n disabled={disabled}\n onClick={onSelect}\n >\n {children}\n </button>\n )\n }\n\n if (external) {\n return (\n <a\n {...(rest as BlockLinkRenderProps)}\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {children}\n </a>\n )\n }\n\n const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {\n if (!onSelect || event.defaultPrevented || isModifiedClick(event)) return\n event.preventDefault()\n onSelect()\n }\n const anchorProps = { ...rest, href, onClick: handleClick } as BlockLinkRenderProps\n if (Link) {\n return (\n <Link {...anchorProps} {...({ ref } as object)}>\n {children}\n </Link>\n )\n }\n return (\n <a {...anchorProps} ref={ref as Ref<HTMLAnchorElement>}>\n {children}\n </a>\n )\n})\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var chunk7JLJH5CW_cjs = require('./chunk-7JLJH5CW.cjs');
|
|
7
|
-
var chunk3Q5L7XVI_cjs = require('./chunk-3Q5L7XVI.cjs');
|
|
8
|
-
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
4
|
+
var chunkJSQQV23D_cjs = require('./chunk-JSQQV23D.cjs');
|
|
5
|
+
var chunkGQXPNIRE_cjs = require('./chunk-GQXPNIRE.cjs');
|
|
9
6
|
var chunk5F4DCIHS_cjs = require('./chunk-5F4DCIHS.cjs');
|
|
7
|
+
var chunk7JLJH5CW_cjs = require('./chunk-7JLJH5CW.cjs');
|
|
8
|
+
var chunkMZ2KZXNU_cjs = require('./chunk-MZ2KZXNU.cjs');
|
|
10
9
|
var chunkQRAQZTJE_cjs = require('./chunk-QRAQZTJE.cjs');
|
|
11
|
-
var
|
|
10
|
+
var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
|
|
11
|
+
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
12
12
|
var browser = require('@arbidocs/sdk/browser');
|
|
13
13
|
var react = require('@arbidocs/react');
|
|
14
14
|
var ui = require('@arbidocs/react/ui');
|
|
@@ -50,19 +50,19 @@ function useLaunchWorkflow({
|
|
|
50
50
|
} = {}) {
|
|
51
51
|
const { data: documents = [] } = react.useDocuments();
|
|
52
52
|
const { data: workspaceTags = [] } = react.useTags();
|
|
53
|
-
const tags = react$1.useMemo(() =>
|
|
53
|
+
const tags = react$1.useMemo(() => chunkMZ2KZXNU_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
|
|
54
54
|
const createTag = react.useCreateTag();
|
|
55
55
|
const updateTag = react.useUpdateTag();
|
|
56
56
|
const generate = react.useGenerateDocTags();
|
|
57
|
-
const { create: createTask } =
|
|
57
|
+
const { create: createTask } = chunkJSQQV23D_cjs.useWorkflowTasks();
|
|
58
58
|
const applyModel = react.useApplyChatModel();
|
|
59
59
|
const session = react.useArbiSessionStore();
|
|
60
|
-
const { notify, openFiles, openNewConversation } =
|
|
60
|
+
const { notify, openFiles, openNewConversation } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
61
61
|
const annotate = react$1.useCallback(
|
|
62
62
|
async ({ inputs, scope }) => {
|
|
63
63
|
const description = text(inputs, "description");
|
|
64
64
|
const name = text(inputs, "name") || chunk7JLJH5CW_cjs.deriveAnnotationName(description);
|
|
65
|
-
const matching =
|
|
65
|
+
const matching = chunkMZ2KZXNU_cjs.matchWorkflowScope(documents, scope);
|
|
66
66
|
if (!name || !description || matching.length === 0) return;
|
|
67
67
|
try {
|
|
68
68
|
const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase());
|
|
@@ -162,7 +162,7 @@ function useLaunchWorkflow({
|
|
|
162
162
|
const binding = PROMPT_BINDINGS[workflow.id];
|
|
163
163
|
const prepare = () => {
|
|
164
164
|
if (binding?.attachScope !== false && !chunkQRAQZTJE_cjs.isEmptyWorkflowScope(scope)) {
|
|
165
|
-
const ids =
|
|
165
|
+
const ids = chunkMZ2KZXNU_cjs.matchWorkflowScope(documents, scope).map((d) => d.external_id);
|
|
166
166
|
if (ids.length > 0) {
|
|
167
167
|
session.setConversationDocuments(
|
|
168
168
|
inPlace ? session.getState().conversationId ?? "new" : "new",
|
|
@@ -211,9 +211,9 @@ function ConnectedWorkflowStart({
|
|
|
211
211
|
(key) => hostIcon?.(key) ?? chunk7JLJH5CW_cjs.renderWorkflowIcon(key) ?? chunk7JLJH5CW_cjs.renderWorkflowIcon("skill"),
|
|
212
212
|
[hostIcon]
|
|
213
213
|
);
|
|
214
|
-
const { openUpload } =
|
|
214
|
+
const { openUpload } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
|
|
215
215
|
const { data: workspaceTags = [] } = react.useTags();
|
|
216
|
-
const tags = react$1.useMemo(() =>
|
|
216
|
+
const tags = react$1.useMemo(() => chunkMZ2KZXNU_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
|
|
217
217
|
const fieldPlaceholder = react$1.useCallback(
|
|
218
218
|
(field, inputs, workflow) => {
|
|
219
219
|
if (workflow.id !== chunk7JLJH5CW_cjs.ANNOTATE_ID || field.name !== "name") return void 0;
|
|
@@ -223,7 +223,7 @@ function ConnectedWorkflowStart({
|
|
|
223
223
|
[]
|
|
224
224
|
);
|
|
225
225
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
226
|
-
|
|
226
|
+
chunkGQXPNIRE_cjs.ConnectedWorkflowLauncher,
|
|
227
227
|
{
|
|
228
228
|
...rest,
|
|
229
229
|
workflows,
|
|
@@ -268,7 +268,7 @@ function canOpenSkill(workflow, skillsEnabled) {
|
|
|
268
268
|
return workflow.run.kind === "prompt" && (skillsEnabled || chunk7JLJH5CW_cjs.isSkillPackWorkflow(workflow));
|
|
269
269
|
}
|
|
270
270
|
function useSlashSkillWorkflows({ landing, send }) {
|
|
271
|
-
const { skills, skillsEnabled } =
|
|
271
|
+
const { skills, skillsEnabled } = chunkJSQQV23D_cjs.useWorkflowDefinitions();
|
|
272
272
|
const { commands } = react.useBuiltinCommands();
|
|
273
273
|
const [active, setActive] = react$1.useState(null);
|
|
274
274
|
const open = react$1.useCallback(
|
|
@@ -332,11 +332,11 @@ function useSlashSkillWorkflows({ landing, send }) {
|
|
|
332
332
|
}
|
|
333
333
|
var NO_SKILLS = [];
|
|
334
334
|
function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
335
|
-
const hostSkills =
|
|
336
|
-
const listings =
|
|
337
|
-
const skillsEnabled =
|
|
335
|
+
const hostSkills = chunkJSQQV23D_cjs.useHostSkills();
|
|
336
|
+
const listings = chunkJSQQV23D_cjs.useUsableSkillListings(hostSkills);
|
|
337
|
+
const skillsEnabled = chunkJSQQV23D_cjs.useSkillsEnabled();
|
|
338
338
|
const { commands } = react.useBuiltinCommands();
|
|
339
|
-
const builtins =
|
|
339
|
+
const builtins = chunkJSQQV23D_cjs.useNamedWorkflows(builtinSkills);
|
|
340
340
|
const items = react$1.useMemo(() => {
|
|
341
341
|
const packSlugs = new Set(hostSkills.map((w) => w.id));
|
|
342
342
|
return chunk5F4DCIHS_cjs.buildSlashItems(
|
|
@@ -347,7 +347,7 @@ function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
|
347
347
|
kind: "command"
|
|
348
348
|
})),
|
|
349
349
|
[
|
|
350
|
-
...hostSkills.map(
|
|
350
|
+
...hostSkills.map(chunkJSQQV23D_cjs.hostSkillItem),
|
|
351
351
|
...skillsEnabled ? skillItems(
|
|
352
352
|
builtins.filter((w) => !packSlugs.has(w.id)),
|
|
353
353
|
listings
|
|
@@ -355,7 +355,7 @@ function useSlashMenuItems(builtinSkills = NO_SKILLS) {
|
|
|
355
355
|
]
|
|
356
356
|
);
|
|
357
357
|
}, [commands, hostSkills, listings, skillsEnabled, builtins]);
|
|
358
|
-
return { items, canBrowseSkills:
|
|
358
|
+
return { items, canBrowseSkills: chunkJSQQV23D_cjs.useCanBrowseSkills() };
|
|
359
359
|
}
|
|
360
360
|
function useSlashItems(text2, builtinSkills = NO_SKILLS) {
|
|
361
361
|
const { items, canBrowseSkills } = useSlashMenuItems(builtinSkills);
|
|
@@ -402,5 +402,5 @@ exports.useLaunchWorkflow = useLaunchWorkflow;
|
|
|
402
402
|
exports.useSlashItems = useSlashItems;
|
|
403
403
|
exports.useSlashMenuItems = useSlashMenuItems;
|
|
404
404
|
exports.useSlashSkillWorkflows = useSlashSkillWorkflows;
|
|
405
|
-
//# sourceMappingURL=chunk-
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
405
|
+
//# sourceMappingURL=chunk-LFRNBT2I.cjs.map
|
|
406
|
+
//# sourceMappingURL=chunk-LFRNBT2I.cjs.map
|