@arbidocs/blocks 0.4.135 → 0.4.137
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/agents/index.cjs +422 -367
- package/dist/agents/index.js +8 -9
- package/dist/agents/skills/index.d.ts +2 -0
- package/dist/agents/skills/skillFiles.d.ts +65 -0
- package/dist/agents/skills/skillImport.d.ts +36 -0
- package/dist/agents/workflows/WorkflowDocumentsField.d.ts +42 -5
- package/dist/agents/workflows/index.d.ts +3 -3
- package/dist/agents/workflows/workflow.d.ts +19 -0
- package/dist/agents/workflows/workspaceScope.d.ts +12 -0
- package/dist/chat/index.cjs +138 -138
- package/dist/chat/index.js +3 -3
- package/dist/chunk-2KUCVSFF.js +51 -0
- package/dist/chunk-2KUCVSFF.js.map +1 -0
- package/dist/{chunk-GDBDHOI4.js → chunk-3RJN2VTL.js} +36 -6
- package/dist/chunk-3RJN2VTL.js.map +1 -0
- package/dist/{chunk-6AALMYPS.cjs → chunk-6F7SZCVL.cjs} +23 -2
- package/dist/chunk-6F7SZCVL.cjs.map +1 -0
- package/dist/{chunk-PUCY3UXN.js → chunk-7M4C6CK7.js} +3 -3
- package/dist/{chunk-PUCY3UXN.js.map → chunk-7M4C6CK7.js.map} +1 -1
- package/dist/{chunk-2PNNCEPH.js → chunk-ATJUVHVB.js} +1545 -8
- package/dist/chunk-ATJUVHVB.js.map +1 -0
- package/dist/{chunk-4S5IDT5F.cjs → chunk-BUNZWOPX.cjs} +5 -5
- package/dist/{chunk-4S5IDT5F.cjs.map → chunk-BUNZWOPX.cjs.map} +1 -1
- package/dist/{chunk-KYDRUFWT.cjs → chunk-C3ZRLULA.cjs} +5 -5
- package/dist/{chunk-KYDRUFWT.cjs.map → chunk-C3ZRLULA.cjs.map} +1 -1
- package/dist/{chunk-SARREDFP.cjs → chunk-CHVCTKF4.cjs} +1620 -47
- package/dist/chunk-CHVCTKF4.cjs.map +1 -0
- package/dist/chunk-CQCC7LE7.js +210 -0
- package/dist/chunk-CQCC7LE7.js.map +1 -0
- package/dist/{chunk-4UMXQPNA.js → chunk-E5OYHJMU.js} +3 -3
- package/dist/{chunk-4UMXQPNA.js.map → chunk-E5OYHJMU.js.map} +1 -1
- package/dist/{chunk-PJJY6CYL.cjs → chunk-EHOPZBAX.cjs} +11 -11
- package/dist/{chunk-PJJY6CYL.cjs.map → chunk-EHOPZBAX.cjs.map} +1 -1
- package/dist/{chunk-4QIIDXLF.cjs → chunk-HDYWXEQU.cjs} +8 -8
- package/dist/{chunk-4QIIDXLF.cjs.map → chunk-HDYWXEQU.cjs.map} +1 -1
- package/dist/{chunk-GZPTWHP5.cjs → chunk-HLB4DIYV.cjs} +5 -5
- package/dist/{chunk-GZPTWHP5.cjs.map → chunk-HLB4DIYV.cjs.map} +1 -1
- package/dist/{chunk-TT6XV6WM.cjs → chunk-JY73DJOS.cjs} +78 -1274
- package/dist/chunk-JY73DJOS.cjs.map +1 -0
- package/dist/{chunk-ARDHLU73.cjs → chunk-KDUGTKVI.cjs} +21 -2
- package/dist/chunk-KDUGTKVI.cjs.map +1 -0
- package/dist/{chunk-UMIY4SQS.js → chunk-KMNZ2RVO.js} +17 -1191
- package/dist/chunk-KMNZ2RVO.js.map +1 -0
- package/dist/{chunk-6S5FLMWG.js → chunk-KSHKTOY2.js} +203 -7
- package/dist/chunk-KSHKTOY2.js.map +1 -0
- package/dist/{chunk-4RLCRFZS.js → chunk-L2PAPOZ5.js} +21 -3
- package/dist/chunk-L2PAPOZ5.js.map +1 -0
- package/dist/{chunk-QYTYW74G.js → chunk-L3T7OJRX.js} +4 -4
- package/dist/{chunk-QYTYW74G.js.map → chunk-L3T7OJRX.js.map} +1 -1
- package/dist/{chunk-ENDP7JER.js → chunk-M33QUNFH.js} +3 -3
- package/dist/{chunk-ENDP7JER.js.map → chunk-M33QUNFH.js.map} +1 -1
- package/dist/chunk-RFIBUWLF.cjs +232 -0
- package/dist/chunk-RFIBUWLF.cjs.map +1 -0
- package/dist/{chunk-N26CXGXC.cjs → chunk-RQ2Y7USX.cjs} +201 -3
- package/dist/chunk-RQ2Y7USX.cjs.map +1 -0
- package/dist/chunk-UUHUQHXR.cjs +56 -0
- package/dist/chunk-UUHUQHXR.cjs.map +1 -0
- package/dist/{chunk-SZX44LCT.js → chunk-VMESMX7N.js} +3 -3
- package/dist/{chunk-SZX44LCT.js.map → chunk-VMESMX7N.js.map} +1 -1
- package/dist/{chunk-QDEODGXE.cjs → chunk-WS5EX7DN.cjs} +37 -6
- package/dist/chunk-WS5EX7DN.cjs.map +1 -0
- package/dist/{chunk-2DFDFOM7.js → chunk-YOMPLCP6.js} +22 -3
- package/dist/chunk-YOMPLCP6.js.map +1 -0
- package/dist/connect/docx.cjs +4 -4
- package/dist/connect/docx.js +3 -3
- package/dist/connect/index.cjs +463 -97
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +5 -2
- package/dist/connect/index.js +387 -49
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedSkillUpload.d.ts +26 -2
- package/dist/connection/ConnectedWorkflowBuilder.d.ts +24 -12
- package/dist/connection/ConnectedWorkflowLauncher.d.ts +35 -0
- package/dist/connection/ConnectedWorkflowsTable.d.ts +62 -0
- package/dist/connection/ConnectionProvider.d.ts +17 -0
- package/dist/connection/workspaceData.d.ts +45 -0
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +1 -1
- package/dist/files/index.js +1 -1
- package/dist/home/index.cjs +20 -21
- package/dist/home/index.cjs.map +1 -1
- package/dist/home/index.js +2 -3
- package/dist/home/index.js.map +1 -1
- package/dist/index.cjs +610 -555
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/settings/index.cjs +11 -11
- package/dist/settings/index.js +2 -2
- package/dist/shell/index.cjs +1 -1
- package/dist/shell/index.js +1 -1
- package/dist/site/index.cjs +5 -5
- package/dist/site/index.js +1 -1
- package/dist/studio/index.cjs +7 -7
- package/dist/studio/index.js +5 -5
- package/dist/workflow-canvas/index.cjs +122 -96
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/index.d.ts +1 -1
- package/dist/workflow-canvas/index.js +73 -48
- package/dist/workflow-canvas/index.js.map +1 -1
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +4 -4
- package/dist/chunk-2DFDFOM7.js.map +0 -1
- package/dist/chunk-2PNNCEPH.js.map +0 -1
- package/dist/chunk-4RLCRFZS.js.map +0 -1
- package/dist/chunk-4XJZ6AAY.js +0 -407
- package/dist/chunk-4XJZ6AAY.js.map +0 -1
- package/dist/chunk-6AALMYPS.cjs.map +0 -1
- package/dist/chunk-6S5FLMWG.js.map +0 -1
- package/dist/chunk-7D737FLE.cjs +0 -43
- package/dist/chunk-7D737FLE.cjs.map +0 -1
- package/dist/chunk-ARDHLU73.cjs.map +0 -1
- package/dist/chunk-GDBDHOI4.js.map +0 -1
- package/dist/chunk-N26CXGXC.cjs.map +0 -1
- package/dist/chunk-QDEODGXE.cjs.map +0 -1
- package/dist/chunk-S5HZBXZA.cjs +0 -430
- package/dist/chunk-S5HZBXZA.cjs.map +0 -1
- package/dist/chunk-SARREDFP.cjs.map +0 -1
- package/dist/chunk-TT6XV6WM.cjs.map +0 -1
- package/dist/chunk-UMIY4SQS.js.map +0 -1
- package/dist/chunk-XD2M6LIG.js +0 -41
- package/dist/chunk-XD2M6LIG.js.map +0 -1
package/dist/chat/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { AssistantToaster, BranchControls, ComposerAccessories, ComposerTools, ContextActionButton, ContextCheckRow, ContextPanelContent, ContextPanelFooter, ContextPanelTabs, ContextPickerList, ContextPickerRow, ContextSearchInput, ContextSelectList, ContextSelectRow, Conversation, ConversationBody, ConversationFilter, ConversationHeader, ConversationHeaderActions, ConversationHistoryPane, ConversationLoading, ConversationMain, ConversationRoot, ConversationSearchView, ConversationSettingsButton, DEFAULT_BRANCH_CONTROLS_LABELS, DEFAULT_CONVERSATION_LAYOUT_LABELS, DEFAULT_CONVERSATION_PARTS_LABELS, DEFAULT_CONVERSATION_SEARCH_LABELS, DEFAULT_DRAFTING_DOC_CHIP_LABELS, DEFAULT_LABEL_PIN_ROW_LABELS, DEFAULT_MODEL_PRICING_TIP_LABELS, DEFAULT_PENDING_ANSWER_BAR_LABELS, DEFAULT_PINNED_DOC_CHIP_LABELS, DEFAULT_SLASH_MENU_LABELS, DEFAULT_THREAD_MAP_LABELS, DEFAULT_THREAD_VISUALIZER_LABELS, DraftingDocChip, LabelPinRow, ModelAutoIcon, ModelConfigureButton, ModelDot, ModelMenuDivider, ModelMenuMessage, ModelOption, ModelOptionLabel, ModelPickerPopover, ModelPickerTrigger, ModelPricingTip, ModelTierIcon, ModelTierOption, ModelTriggerContent, NewChatButton, NewPaChatButton, PaModeBadge, PendingAnswerBar, PinnedDocChip, ProvisionalTranscriptLine, SlashMenu, ThreadMap, ThreadMapDiagram, ThreadMapError, ThreadMapLoading, ThreadVisualizer, TranscriptLine, buildThreadDiagram, flashMessage, getParticipantTints, hasMessageBody, isLongPastedText, threadForNode, transcriptRuns, useDismissibleCard, useLongPaste, useRecipientDraft } from '../chunk-
|
|
2
|
+
export { AssistantToaster, BranchControls, ComposerAccessories, ComposerTools, ContextActionButton, ContextCheckRow, ContextPanelContent, ContextPanelFooter, ContextPanelTabs, ContextPickerList, ContextPickerRow, ContextSearchInput, ContextSelectList, ContextSelectRow, Conversation, ConversationBody, ConversationFilter, ConversationHeader, ConversationHeaderActions, ConversationHistoryPane, ConversationLoading, ConversationMain, ConversationRoot, ConversationSearchView, ConversationSettingsButton, DEFAULT_BRANCH_CONTROLS_LABELS, DEFAULT_CONVERSATION_LAYOUT_LABELS, DEFAULT_CONVERSATION_PARTS_LABELS, DEFAULT_CONVERSATION_SEARCH_LABELS, DEFAULT_DRAFTING_DOC_CHIP_LABELS, DEFAULT_LABEL_PIN_ROW_LABELS, DEFAULT_MODEL_PRICING_TIP_LABELS, DEFAULT_PENDING_ANSWER_BAR_LABELS, DEFAULT_PINNED_DOC_CHIP_LABELS, DEFAULT_SLASH_MENU_LABELS, DEFAULT_THREAD_MAP_LABELS, DEFAULT_THREAD_VISUALIZER_LABELS, DraftingDocChip, LabelPinRow, ModelAutoIcon, ModelConfigureButton, ModelDot, ModelMenuDivider, ModelMenuMessage, ModelOption, ModelOptionLabel, ModelPickerPopover, ModelPickerTrigger, ModelPricingTip, ModelTierIcon, ModelTierOption, ModelTriggerContent, NewChatButton, NewPaChatButton, PaModeBadge, PendingAnswerBar, PinnedDocChip, ProvisionalTranscriptLine, SlashMenu, ThreadMap, ThreadMapDiagram, ThreadMapError, ThreadMapLoading, ThreadVisualizer, TranscriptLine, buildThreadDiagram, flashMessage, getParticipantTints, hasMessageBody, isLongPastedText, threadForNode, transcriptRuns, useDismissibleCard, useLongPaste, useRecipientDraft } from '../chunk-VMESMX7N.js';
|
|
3
3
|
import '../chunk-OKERRHLH.js';
|
|
4
|
-
export { AssistantDock, AssistantDockToggle, AssistantModeToggle, ChatDocuments, ChatMessageContent, ChatPage, ChatThreadList, ChatThreadSelect, CitationMark, Composer, ComposerBranchingNotice, ComposerContainer, ComposerDock, ComposerFrame, ComposerInput, ComposerRoot, ComposerSend, ComposerToolbar, ComposerVoiceButton, ContextChip, ConversationEmpty, DEFAULT_ASSISTANT_MODE_TOGGLE_LABELS, DEFAULT_CHAT_PAGE_LABELS, DEFAULT_COMPOSER_LABELS, DEFAULT_CONVERSATION_EMPTY_LABELS, DEFAULT_MESSAGE_ALERT_LABELS, DEFAULT_MESSAGE_LABELS, DEFAULT_MESSAGE_LIST_LABELS, DEFAULT_WORKFLOW_STEP_CHIP_LABELS, Message, MessageActionButton, MessageActionMenu, MessageAlert, MessageAuthor, MessageBody, MessageBubble, MessageByline, MessageContent, MessageFooter, MessageList, MessageListBanner, MessageListEmpty, MessageListRoot, MessageListRow, MessageListRows, MessageListStatus, MessageListTail, MessageNarration, MessageRoot, MessageSources, MessageSubagentBadge, ScrollToBottom, SourceChip, WorkflowStepChip, toSpeakableText, useAssistantDock, useChatSurface, useRegisterEmbeddedChat, useStreamAnnouncement } from '../chunk-
|
|
4
|
+
export { AssistantDock, AssistantDockToggle, AssistantModeToggle, ChatDocuments, ChatMessageContent, ChatPage, ChatThreadList, ChatThreadSelect, CitationMark, Composer, ComposerBranchingNotice, ComposerContainer, ComposerDock, ComposerFrame, ComposerInput, ComposerRoot, ComposerSend, ComposerToolbar, ComposerVoiceButton, ContextChip, ConversationEmpty, DEFAULT_ASSISTANT_MODE_TOGGLE_LABELS, DEFAULT_CHAT_PAGE_LABELS, DEFAULT_COMPOSER_LABELS, DEFAULT_CONVERSATION_EMPTY_LABELS, DEFAULT_MESSAGE_ALERT_LABELS, DEFAULT_MESSAGE_LABELS, DEFAULT_MESSAGE_LIST_LABELS, DEFAULT_WORKFLOW_STEP_CHIP_LABELS, Message, MessageActionButton, MessageActionMenu, MessageAlert, MessageAuthor, MessageBody, MessageBubble, MessageByline, MessageContent, MessageFooter, MessageList, MessageListBanner, MessageListEmpty, MessageListRoot, MessageListRow, MessageListRows, MessageListStatus, MessageListTail, MessageNarration, MessageRoot, MessageSources, MessageSubagentBadge, ScrollToBottom, SourceChip, WorkflowStepChip, toSpeakableText, useAssistantDock, useChatSurface, useRegisterEmbeddedChat, useStreamAnnouncement } from '../chunk-7M4C6CK7.js';
|
|
5
5
|
import '../chunk-7XF5SFJ2.js';
|
|
6
6
|
export { savedDocumentIdFor, takeOpenDocumentForTurn, useOpenDocumentId, useRegisterOpenDocument } from '../chunk-YBLIKTJK.js';
|
|
7
|
-
export { useMentionAutocomplete } from '../chunk-
|
|
7
|
+
export { useMentionAutocomplete } from '../chunk-YOMPLCP6.js';
|
|
8
8
|
import '../chunk-AUS3KBHJ.js';
|
|
9
9
|
export { DEFAULT_MENTION_LABELS, MENTION_HREF_PREFIX, MentionChip, MentionMenu, extractMentions, filterMentionCandidates, findMentionQuery, insertMention, linkMentions, mentionFromHref, toMessageMentions, useListKeyNav } from '../chunk-AA3PT6KR.js';
|
|
10
10
|
import '../chunk-SLSBJRWW.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useConnectedWorkspace } from './chunk-L2PAPOZ5.js';
|
|
3
|
+
import { createContext, useMemo, useContext } from 'react';
|
|
4
|
+
import { useDocuments, useTags, useConversations } from '@arbidocs/react';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var WorkspaceDataContext = createContext({});
|
|
8
|
+
function ConnectedWorkspaceDataProvider({
|
|
9
|
+
documents,
|
|
10
|
+
tags,
|
|
11
|
+
conversations,
|
|
12
|
+
children
|
|
13
|
+
}) {
|
|
14
|
+
const value = useMemo(
|
|
15
|
+
() => ({ documents, tags, conversations }),
|
|
16
|
+
[documents, tags, conversations]
|
|
17
|
+
);
|
|
18
|
+
return /* @__PURE__ */ jsx(WorkspaceDataContext.Provider, { value, children });
|
|
19
|
+
}
|
|
20
|
+
var EMPTY = [];
|
|
21
|
+
function useList(hosted, own) {
|
|
22
|
+
const source = hosted ?? own;
|
|
23
|
+
const data = source.data ?? EMPTY;
|
|
24
|
+
const refetch = hosted ? hosted.refetch : own.refetch;
|
|
25
|
+
return useMemo(
|
|
26
|
+
() => ({ data, loaded: source.isFetched, refetch }),
|
|
27
|
+
[data, source.isFetched, refetch]
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function useConnectedDocuments() {
|
|
31
|
+
const hosted = useContext(WorkspaceDataContext).documents;
|
|
32
|
+
const { workspaceId } = useConnectedWorkspace();
|
|
33
|
+
const own = useDocuments(workspaceId ?? void 0, { enabled: !hosted });
|
|
34
|
+
return useList(hosted, own);
|
|
35
|
+
}
|
|
36
|
+
function useConnectedTags() {
|
|
37
|
+
const hosted = useContext(WorkspaceDataContext).tags;
|
|
38
|
+
const { workspaceId } = useConnectedWorkspace();
|
|
39
|
+
const own = useTags(workspaceId ?? void 0, { enabled: !hosted });
|
|
40
|
+
return useList(hosted, own);
|
|
41
|
+
}
|
|
42
|
+
function useConnectedConversations(options) {
|
|
43
|
+
const hosted = useContext(WorkspaceDataContext).conversations;
|
|
44
|
+
const { workspaceId } = useConnectedWorkspace();
|
|
45
|
+
const own = useConversations(workspaceId ?? void 0, { enabled: !hosted, live: options?.live });
|
|
46
|
+
return useList(hosted, own);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ConnectedWorkspaceDataProvider, useConnectedConversations, useConnectedDocuments, useConnectedTags };
|
|
50
|
+
//# sourceMappingURL=chunk-2KUCVSFF.js.map
|
|
51
|
+
//# sourceMappingURL=chunk-2KUCVSFF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/connection/workspaceData.tsx"],"names":[],"mappings":";;;;;AA+BA,IAAM,oBAAA,GAAuB,aAAA,CAAsC,EAAE,CAAA;AAE9D,SAAS,8BAAA,CAA+B;AAAA,EAC7C,SAAA;AAAA,EACA,IAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAA,EAAqD;AACnD,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO,EAAE,SAAA,EAAW,IAAA,EAAM,aAAA,EAAc,CAAA;AAAA,IACxC,CAAC,SAAA,EAAW,IAAA,EAAM,aAAa;AAAA,GACjC;AACA,EAAA,uBAAO,GAAA,CAAC,oBAAA,CAAqB,QAAA,EAArB,EAA8B,OAAe,QAAA,EAAS,CAAA;AAChE;AASA,IAAM,QAAiB,EAAC;AAExB,SAAS,OAAA,CACP,QACA,GAAA,EACwB;AACxB,EAAA,MAAM,SAAS,MAAA,IAAU,GAAA;AACzB,EAAA,MAAM,IAAA,GAAO,OAAO,IAAA,IAAS,KAAA;AAC7B,EAAA,MAAM,OAAA,GAAU,MAAA,GAAS,MAAA,CAAO,OAAA,GAAU,GAAA,CAAI,OAAA;AAC9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default each kit reads them\n * through the `@arbidocs/react` hooks. A host that already keeps these lists live in its own cache\n * (the ARBI app, with its progressive loader and WebSocket patches) passes them once through\n * `ConnectedWorkspaceDataProvider`, so the kits show the same list and nothing is fetched twice.\n */\n\nimport { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useConversations, useDocuments, useTags } from '@arbidocs/react'\nimport { useConnectedWorkspace } from './ConnectionProvider'\n\nexport type ConnectedDocument = NonNullable<ReturnType<typeof useDocuments>['data']>[number]\nexport type ConnectedTag = NonNullable<ReturnType<typeof useTags>['data']>[number]\nexport type ConnectedConversation = NonNullable<ReturnType<typeof useConversations>['data']>[number]\n\n/**\n * A list the host keeps: its rows, whether it has arrived, and how to read it again (absent: the\n * host keeps it current itself, so a kit never re-reads it).\n */\nexport interface ConnectedList<T> {\n data: T[] | undefined\n isFetched: boolean\n refetch?: () => unknown\n}\n\nexport interface ConnectedWorkspaceData {\n documents?: ConnectedList<ConnectedDocument>\n tags?: ConnectedList<ConnectedTag>\n conversations?: ConnectedList<ConnectedConversation>\n}\n\nconst WorkspaceDataContext = createContext<ConnectedWorkspaceData>({})\n\nexport function ConnectedWorkspaceDataProvider({\n documents,\n tags,\n conversations,\n children,\n}: ConnectedWorkspaceData & { children: ReactNode }) {\n const value = useMemo(\n () => ({ documents, tags, conversations }),\n [documents, tags, conversations]\n )\n return <WorkspaceDataContext.Provider value={value}>{children}</WorkspaceDataContext.Provider>\n}\n\nexport interface ConnectedListResult<T> {\n data: T[]\n loaded: boolean\n /** Read the list again after a change made here; absent when the host keeps it current. */\n refetch?: () => unknown\n}\n\nconst EMPTY: never[] = []\n\nfunction useList<T>(\n hosted: ConnectedList<T> | undefined,\n own: { data?: T[]; isFetched: boolean; refetch: () => unknown }\n): ConnectedListResult<T> {\n const source = hosted ?? own\n const data = source.data ?? (EMPTY as T[])\n const refetch = hosted ? hosted.refetch : own.refetch\n return useMemo(\n () => ({ data, loaded: source.isFetched, refetch }),\n [data, source.isFetched, refetch]\n )\n}\n\n/** The open workspace's documents: the host's list when it gives one, else read here. */\nexport function useConnectedDocuments(): ConnectedListResult<ConnectedDocument> {\n const hosted = useContext(WorkspaceDataContext).documents\n const { workspaceId } = useConnectedWorkspace()\n const own = useDocuments(workspaceId ?? undefined, { enabled: !hosted })\n return useList(hosted, own)\n}\n\n/** The open workspace's tags: the host's list when it gives one, else read here. */\nexport function useConnectedTags(): ConnectedListResult<ConnectedTag> {\n const hosted = useContext(WorkspaceDataContext).tags\n const { workspaceId } = useConnectedWorkspace()\n const own = useTags(workspaceId ?? undefined, { enabled: !hosted })\n return useList(hosted, own)\n}\n\n/**\n * The open workspace's conversations (threads and tasks): the host's list when it gives one, else\n * read here (`live`: re-read while shown, as a run moves on by itself).\n */\nexport function useConnectedConversations(options?: {\n live?: boolean\n}): ConnectedListResult<ConnectedConversation> {\n const hosted = useContext(WorkspaceDataContext).conversations\n const { workspaceId } = useConnectedWorkspace()\n const own = useConversations(workspaceId ?? undefined, { enabled: !hosted, live: options?.live })\n return useList(hosted, own)\n}\n"]}
|
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ActionLink } from './chunk-444XKG46.js';
|
|
3
|
-
import { FoldSection } from './chunk-XD2M6LIG.js';
|
|
4
3
|
import { observeResize } from './chunk-NPLYHR2E.js';
|
|
5
4
|
import { testIdOr, prefixedTestId } from './chunk-7F6CBP3Z.js';
|
|
6
5
|
import { formatCount } from './chunk-OXF2IFXG.js';
|
|
7
|
-
import { FolderPlus, Check, FileCheck2, Plus, Minus } from 'lucide-react';
|
|
6
|
+
import { ChevronDown, FolderPlus, Check, FileCheck2, Plus, Minus } from 'lucide-react';
|
|
7
|
+
import { Collapsible, CollapsibleTrigger, cn, CollapsibleContent, DialogHeader, DialogTitle, DialogDescription } from '@arbidocs/react/ui';
|
|
8
8
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
import { DialogHeader, DialogTitle, DialogDescription, cn } from '@arbidocs/react/ui';
|
|
10
9
|
import { useMemo, useState, useRef, useEffect } from 'react';
|
|
11
10
|
|
|
11
|
+
function FoldSection({
|
|
12
|
+
label,
|
|
13
|
+
count = 0,
|
|
14
|
+
hint,
|
|
15
|
+
open,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
testId,
|
|
18
|
+
children
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ jsxs(Collapsible, { open, onOpenChange, "data-slot": "fold-section", children: [
|
|
21
|
+
/* @__PURE__ */ jsxs(
|
|
22
|
+
CollapsibleTrigger,
|
|
23
|
+
{
|
|
24
|
+
className: "mb-1.5 flex w-full items-center gap-1.5 rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&:hover]:text-muted-foreground pointer-coarse:min-h-11",
|
|
25
|
+
"data-testid": testId,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
ChevronDown,
|
|
29
|
+
{
|
|
30
|
+
className: cn("size-4 shrink-0 transition-transform", !open && "-rotate-90")
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
34
|
+
count > 0 && /* @__PURE__ */ jsx("span", { className: "text-xs tabular-nums text-muted-foreground", children: count }),
|
|
35
|
+
hint && !open && /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-xs font-normal text-muted-foreground", children: hint })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { children })
|
|
40
|
+
] });
|
|
41
|
+
}
|
|
12
42
|
var DEFAULT_ADD_FILES_FIRST_LABELS = {
|
|
13
43
|
heading: "Add files first"
|
|
14
44
|
};
|
|
@@ -473,6 +503,6 @@ function StartTiles({ items, caption, captionTestId, className, testId }) {
|
|
|
473
503
|
);
|
|
474
504
|
}
|
|
475
505
|
|
|
476
|
-
export { AddFilesFirst, DEFAULT_ADD_FILES_FIRST_LABELS, DEFAULT_SCOPE_PICKER_LABELS, EmptyStrip, QuickActionDialogHeader, ScopePicker, SectionHeader, SectionLabel, StartTiles, useScopeSelection };
|
|
477
|
-
//# sourceMappingURL=chunk-
|
|
478
|
-
//# sourceMappingURL=chunk-
|
|
506
|
+
export { AddFilesFirst, DEFAULT_ADD_FILES_FIRST_LABELS, DEFAULT_SCOPE_PICKER_LABELS, EmptyStrip, FoldSection, QuickActionDialogHeader, ScopePicker, SectionHeader, SectionLabel, StartTiles, useScopeSelection };
|
|
507
|
+
//# sourceMappingURL=chunk-3RJN2VTL.js.map
|
|
508
|
+
//# sourceMappingURL=chunk-3RJN2VTL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/home/FoldSection.tsx","../src/home/AddFilesFirst.tsx","../src/home/QuickActionDialogHeader.tsx","../src/lib/useScopeSelection.ts","../src/home/ScopePicker.tsx","../src/home/sections.tsx","../src/lib/balanced-columns.ts","../src/home/StartTiles.tsx"],"names":["jsxs","jsx","cn","useMemo","useState"],"mappings":";;;;;;;;;AAsBO,SAAS,WAAA,CAAY;AAAA,EAC1B,KAAA;AAAA,EACA,KAAA,GAAQ,CAAA;AAAA,EACR,IAAA;AAAA,EACA,IAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAAqB;AACnB,EAAA,uBACE,IAAA,CAAC,WAAA,EAAA,EAAY,IAAA,EAAY,YAAA,EAA4B,aAAU,cAAA,EAC7D,QAAA,EAAA;AAAA,oBAAA,IAAA;AAAA,MAAC,kBAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAU,wMAAA;AAAA,QACV,aAAA,EAAa,MAAA;AAAA,QAEb,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,WAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,EAAA,CAAG,sCAAA,EAAwC,CAAC,QAAQ,YAAY;AAAA;AAAA,WAC7E;AAAA,0BACA,GAAA,C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f,KAAA,EAAO,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,cAAA,GAAiB,MAAA;AAAA,kBAC7C,SAAA,EAAWE,EAAAA;AAAA,oBACT,iEAAA;AAAA,oBACA,kGAAA;AAAA,oBACA,yEAAA;AAAA,oBACA,iGAAA;AAAA,oBACA;AAAA,mBACF;AAAA,kBACA,WAAA,EAAU,YAAA;AAAA,kBACV,eAAa,IAAA,CAAK,MAAA;AAAA,kBAEjB,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAK,2BACJD,GAAAA,CAAC,UAAK,SAAA,EAAU,qCAAA,EAAsC,eAAY,MAAA,EAC/D,QAAA,EAAA,IAAA,CAAK,QAAA,EACR,CAAA,GAEA,wBAAQA,GAAAA,CAAC,QAAK,SAAA,EAAU,6BAAA,EAA8B,eAAY,MAAA,EAAO,CAAA;AAAA,oCAE3ED,IAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EACd,QAAA,EAAA;AAAA,sCAAAC,GAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,6CAAA,EAA+C,eAAK,KAAA,EAAM,CAAA;AAAA,sCAC1EA,GAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,uDAAA,EACb,QAAA,EAAA,IAAA,CAAK,QAAA,IAAY,IAAA,CAAK,cAAA,GAAiB,IAAA,CAAK,cAAA,GAAiB,IAAA,CAAK,WAAA,EACrE;AAAA,qBAAA,EACF;AAAA;AAAA,iBAAA;AAAA,gBA3BK,IAAA,CAAK;AAAA,eA4BZ;AAAA,YAEJ,CAAC;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAEJ","file":"chunk-3RJN2VTL.js","sourcesContent":["import type { ReactNode } from 'react'\nimport { ChevronDown } from 'lucide-react'\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger, cn } from '@arbidocs/react/ui'\n\nexport interface FoldSectionProps {\n label: string\n /** Shown as plain muted text beside the name; omit or pass 0 to hide. */\n count?: number\n /** A word or two of state for sections a count cannot summarise (shown while shut). */\n hint?: string\n open: boolean\n onOpenChange: (open: boolean) => void\n /** Trigger test id; the caller owns the naming. */\n testId: string\n children: ReactNode\n}\n\n/**\n * One foldable block of a dialog. The chevron and the name are the whole hit\n * target (44px on touch), and the count keeps the selection readable while the\n * section is shut, so you need not re-open it to check.\n */\nexport function FoldSection({\n label,\n count = 0,\n hint,\n open,\n onOpenChange,\n testId,\n children,\n}: FoldSectionProps) {\n return (\n <Collapsible open={open} onOpenChange={onOpenChange} data-slot=\"fold-section\">\n <CollapsibleTrigger\n className=\"mb-1.5 flex w-full items-center gap-1.5 rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&:hover]:text-muted-foreground pointer-coarse:min-h-11\"\n data-testid={testId}\n >\n <ChevronDown\n className={cn('size-4 shrink-0 transition-transform', !open && '-rotate-90')}\n />\n <span>{label}</span>\n {count > 0 && <span className=\"text-xs tabular-nums text-muted-foreground\">{count}</span>}\n {hint && !open && (\n <span className=\"min-w-0 truncate text-xs font-normal text-muted-foreground\">{hint}</span>\n )}\n </CollapsibleTrigger>\n <CollapsibleContent>{children}</CollapsibleContent>\n </Collapsible>\n )\n}\n","import type { ReactNode } from 'react'\nimport { FolderPlus } from 'lucide-react'\n\n/** Fixed strings of the empty-files state. */\nexport interface AddFilesFirstLabels {\n heading: string\n}\n\nexport const DEFAULT_ADD_FILES_FIRST_LABELS: AddFilesFirstLabels = {\n heading: 'Add files first',\n}\n\nexport interface AddFilesFirstProps {\n /** Why this action needs files, in the action's own words. */\n reason: string\n /** The host's own \"Add\" control. */\n action: ReactNode\n testId?: string\n labels?: Partial<AddFilesFirstLabels>\n}\n\n/**\n * What a quick-action dialog shows when the workspace has no files yet.\n *\n * Greying the action out says you cannot do it without saying how to get\n * there. Offering the same \"Add\" menu the Files view carries turns the dead\n * end into the first step: add files here, then run the action.\n */\nexport function AddFilesFirst({ reason, action, testId, labels }: AddFilesFirstProps) {\n const l = { ...DEFAULT_ADD_FILES_FIRST_LABELS, ...labels }\n return (\n <div\n className=\"flex flex-col items-center gap-3 rounded-lg border border-border bg-card shadow-xs px-4 py-8 text-center\"\n data-slot=\"add-files-first\"\n data-testid={testId}\n >\n <span className=\"flex size-11 items-center justify-center rounded-full bg-ai-soft text-ai-ink\">\n <FolderPlus className=\"size-5\" aria-hidden=\"true\" />\n </span>\n <div className=\"flex flex-col gap-1\">\n <p className=\"text-sm font-semibold text-foreground\">{l.heading}</p>\n <p className=\"text-xs leading-relaxed text-muted-foreground\">{reason}</p>\n </div>\n {action}\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { DialogDescription, DialogHeader, DialogTitle } from '@arbidocs/react/ui'\n\nexport interface QuickActionDialogHeaderProps {\n /** The tile's glyph, sized by the caller at `size-5`. */\n icon: ReactNode\n title: string\n /** One sentence on what the dialog does. Keep it to a line or two. */\n description: ReactNode\n /** Test id for the description, where a test asserts on the copy. */\n descriptionTestId?: string\n}\n\n/**\n * The header every \"Start\" quick-action dialog wears: the tile's own mark in\n * its disc, the action's name, and one line saying what the dialog will do.\n *\n * - The disc centres on the TITLE row, so it reads as the title's mark.\n * - The description keeps the title's left edge (`pl-13` = disc + gap), so the\n * header is one text column beside the mark rather than an L.\n * - `max-w-prose` + `text-pretty` cap the measure and stop two-word orphans.\n * - `pr-8` keeps the copy clear of the close button.\n */\nexport function QuickActionDialogHeader({\n icon,\n title,\n description,\n descriptionTestId,\n}: QuickActionDialogHeaderProps) {\n return (\n <DialogHeader className=\"space-y-0 text-left\" data-slot=\"quick-action-dialog-header\">\n <div className=\"flex items-center gap-3 pr-8\">\n <div className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-ai-soft text-ai-ink\">\n {icon}\n </div>\n <DialogTitle className=\"text-xl font-semibold leading-tight\">{title}</DialogTitle>\n </div>\n <DialogDescription\n className=\"mt-2 max-w-prose pl-13 pr-8 text-sm leading-relaxed text-pretty\"\n data-testid={descriptionTestId}\n >\n {description}\n </DialogDescription>\n </DialogHeader>\n )\n}\n","import { useMemo } from 'react'\n\n/** Which folders and labels a run is limited to. Empty = everything. */\nexport interface DocumentScope {\n /** Folder paths; `''` is the \"unfiled\" bucket. */\n folders: string[]\n /** Label (tag) ids. */\n labels: string[]\n}\n\nexport interface UseScopeSelectionOptions {\n /** Every folder path in the tree (not including the unfiled bucket). */\n folderPaths: string[]\n /** Whether the unfiled bucket is shown as a row. */\n hasUnfiled: boolean\n scope: DocumentScope\n onScopeChange: (scope: DocumentScope) => void\n}\n\n/**\n * Headless selection logic for a folder + label scope picker.\n *\n * Folders use hierarchical selection: ticking \"contracts\" also ticks\n * \"contracts/2024\", and unticking removes the whole subtree. \"All\" ticks every\n * row, which is NOT the same as an empty scope: empty means \"the whole\n * workspace, whatever lands in it later\", all-ticked means \"these folders, as\n * they are now\".\n */\nexport function useScopeSelection({\n folderPaths,\n hasUnfiled,\n scope,\n onScopeChange,\n}: UseScopeSelectionOptions) {\n const selectedFolders = useMemo(() => new Set(scope.folders), [scope.folders])\n const selectedLabels = useMemo(() => new Set(scope.labels), [scope.labels])\n\n /** Every row the folder list shows, \"unfiled\" included. */\n const allRowPaths = useMemo(\n () => [...(hasUnfiled ? [''] : []), ...folderPaths],\n [folderPaths, hasUnfiled]\n )\n const allSelected = allRowPaths.length > 0 && allRowPaths.every((p) => selectedFolders.has(p))\n const someSelected = selectedFolders.size > 0 && !allSelected\n\n const descendants = (path: string) => folderPaths.filter((p) => p.startsWith(path + '/'))\n\n const toggleFolder = (path: string) => {\n const next = new Set(selectedFolders)\n const family = [path, ...descendants(path)]\n if (next.has(path)) for (const p of family) next.delete(p)\n else for (const p of family) next.add(p)\n onScopeChange({ folders: [...next], labels: scope.labels })\n }\n\n const toggleAllFolders = () => {\n onScopeChange({ folders: allSelected ? [] : allRowPaths, labels: scope.labels })\n }\n\n const toggleLabel = (labelId: string) => {\n const next = new Set(selectedLabels)\n if (next.has(labelId)) next.delete(labelId)\n else next.add(labelId)\n onScopeChange({ folders: scope.folders, labels: [...next] })\n }\n\n return {\n selectedFolders,\n selectedLabels,\n allSelected,\n someSelected,\n hasSelection: scope.folders.length > 0 || scope.labels.length > 0,\n toggleFolder,\n toggleAllFolders,\n toggleLabel,\n }\n}\n","import { useMemo, useState } from 'react'\nimport { Check, FileCheck2, Minus } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport { useScopeSelection, type DocumentScope } from '../lib/useScopeSelection'\nimport { formatCount } from '../lib/format'\nimport { FoldSection } from './FoldSection'\n\n/**\n * Fixed strings of the picker. Passed as `uiLabels`: the `labels` prop is already the list of\n * document labels to scope by.\n */\nexport interface ScopePickerLabels {\n folders: string\n /** The Labels section heading. */\n labelsHeading: string\n all: string\n unfiled: string\n noFoldersYet: string\n noLabelsYet: string\n filesToInclude: string\n /** \"3 of 10 files\". */\n matchedOfTotal: (matched: number, total: number) => string\n selectedSuffix: string\n folderCount: (count: number) => string\n labelCount: (count: number) => string\n left: (count: number) => string\n /** \"All 10 files\". */\n allFiles: (total: number) => string\n includedSuffix: string\n}\n\nconst pluralize = (n: number, word: string) => `${n} ${word}${n !== 1 ? 's' : ''}`\n\nexport const DEFAULT_SCOPE_PICKER_LABELS: ScopePickerLabels = {\n folders: 'Folders',\n labelsHeading: 'Labels',\n all: 'All',\n unfiled: 'Unfiled',\n noFoldersYet: 'No folders yet',\n noLabelsYet: 'No labels yet — label files from the Files page to scope by them here.',\n filesToInclude: 'Files to include',\n matchedOfTotal: (matched, total) =>\n `${matched} of ${formatCount(total, { one: 'file', other: 'files' })}`,\n selectedSuffix: ' selected',\n folderCount: (count) => pluralize(count, 'folder'),\n labelCount: (count) => pluralize(count, 'label'),\n left: (count) => `${count} left`,\n allFiles: (total) => `All ${pluralize(total, 'file')}`,\n includedSuffix: ' in the workspace will be included',\n}\n\nexport interface ScopeFolder {\n /** Full path, e.g. `contracts/2024`. */\n path: string\n /** Last segment, shown. */\n label: string\n /** Documents under this folder. */\n count: number\n depth: number\n}\n\nexport interface ScopeLabel {\n id: string\n name: string\n /** Any CSS colour for the dot. */\n color: string\n /** Documents carrying this label. */\n count: number\n}\n\nexport interface ScopePickerProps {\n folders: ScopeFolder[]\n /** Documents with no folder; the \"Unfiled\" row is hidden at 0. */\n unfiledCount: number\n labels: ScopeLabel[]\n /** All documents the picker is scoping. */\n totalCount: number\n /** Documents the current scope matches (computed by the caller). */\n matchedCount: number\n scope: DocumentScope\n onScopeChange: (scope: DocumentScope) => void\n /** Reword the picker's fixed strings. */\n uiLabels?: Partial<ScopePickerLabels>\n /** Sub-element ids; defaults are the current ids. `labelChip` is a prefix (`<prefix>-<label id>`). */\n testIds?: Partial<\n Record<'foldersToggle' | 'labelsToggle' | 'noLabels' | 'labelChip' | 'summary', string>\n >\n}\n\ninterface FolderRowProps {\n label: string\n count: number\n depth: number\n isActive: boolean\n indeterminate?: boolean\n muted?: boolean\n onToggle: () => void\n}\n\n/** A checkbox row: the row is the checkbox (a nested real one would swallow the click). */\nfunction FolderRow({\n label,\n count,\n depth,\n isActive,\n indeterminate,\n muted,\n onToggle,\n}: FolderRowProps) {\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : isActive}\n style={{ paddingLeft: `${4 + depth * 14}px` }}\n className={cn(\n 'flex w-full items-center gap-1 rounded-sm py-1 pr-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&:hover]:bg-accent pointer-coarse:min-h-11',\n isActive && 'bg-primary/10',\n muted && !isActive && 'text-muted-foreground'\n )}\n data-slot=\"scope-folder-row\"\n >\n <span className=\"flex w-4 shrink-0 items-center justify-center\">\n <span\n className={cn(\n 'flex size-3.5 items-center justify-center rounded-[3px] border transition-colors',\n isActive || indeterminate\n ? 'border-primary bg-primary text-primary-foreground'\n : 'border-muted-foreground/40'\n )}\n >\n {indeterminate ? (\n <Minus className=\"size-2.5\" />\n ) : (\n isActive && <Check className=\"size-2.5\" />\n )}\n </span>\n </span>\n {label !== '' && (\n <span className={cn('min-w-0 truncate', isActive && 'font-semibold text-primary')}>\n {label}\n </span>\n )}\n <span className=\"ml-auto pl-2 text-sm font-semibold text-muted-foreground\">{count}</span>\n </button>\n )\n}\n\n/**\n * Pick a folder + label scope for a run over documents. Controlled: the caller\n * owns the scope and computes `matchedCount`, so the submit button lives with\n * the caller. Both sections start shut: the default (every file) is what most\n * runs want, and the summary states it plainly.\n */\nexport function ScopePicker({\n folders,\n unfiledCount,\n labels,\n totalCount,\n matchedCount,\n scope,\n onScopeChange,\n uiLabels,\n testIds,\n}: ScopePickerProps) {\n const l = { ...DEFAULT_SCOPE_PICKER_LABELS, ...uiLabels }\n const [foldersOpen, setFoldersOpen] = useState(false)\n const [labelsOpen, setLabelsOpen] = useState(false)\n\n const folderPaths = useMemo(() => folders.map((f) => f.path), [folders])\n const selection = useScopeSelection({\n folderPaths,\n hasUnfiled: unfiledCount > 0,\n scope,\n onScopeChange,\n })\n const hasRows = folders.length > 0 || unfiledCount > 0\n\n return (\n <div className=\"flex flex-col gap-4\" data-slot=\"scope-picker\">\n <FoldSection\n label={l.folders}\n count={scope.folders.length}\n open={foldersOpen}\n onOpenChange={setFoldersOpen}\n testId={testIdOr(testIds?.foldersToggle, { testId: 'scope-picker-folders-toggle' })}\n >\n <div className=\"max-h-[180px] overflow-y-auto rounded-md border border-border p-1\">\n {hasRows && (\n <>\n <FolderRow\n label={l.all}\n count={totalCount}\n depth={0}\n isActive={selection.allSelected}\n indeterminate={selection.someSelected}\n onToggle={selection.toggleAllFolders}\n />\n <div className=\"my-1 border-t border-border\" />\n </>\n )}\n {unfiledCount > 0 && (\n <>\n <FolderRow\n label={l.unfiled}\n count={unfiledCount}\n depth={0}\n isActive={selection.selectedFolders.has('')}\n muted\n onToggle={() => selection.toggleFolder('')}\n />\n {folders.length > 0 && <div className=\"my-1 border-t border-border\" />}\n </>\n )}\n {folders.map((folder) => (\n <FolderRow\n key={folder.path}\n label={folder.label}\n count={folder.count}\n depth={folder.depth}\n isActive={selection.selectedFolders.has(folder.path)}\n onToggle={() => selection.toggleFolder(folder.path)}\n />\n ))}\n {!hasRows && <p className=\"px-2 py-1 text-sm text-muted-foreground\">{l.noFoldersYet}</p>}\n </div>\n </FoldSection>\n\n {/* Always present, like Folders: a workspace with no labels yet reads as\n \"you have not labelled anything\", not \"this cannot scope by label\". */}\n <FoldSection\n label={l.labelsHeading}\n count={scope.labels.length}\n open={labelsOpen}\n onOpenChange={setLabelsOpen}\n testId={testIdOr(testIds?.labelsToggle, { testId: 'scope-picker-labels-toggle' })}\n >\n {labels.length === 0 ? (\n <p\n className=\"px-2 py-1 text-sm text-muted-foreground\"\n data-testid={testIdOr(testIds?.noLabels, { testId: 'scope-picker-no-labels' })}\n >\n {l.noLabelsYet}\n </p>\n ) : (\n <div className=\"flex flex-wrap gap-1.5\">\n {labels.map((label) => {\n const isActive = selection.selectedLabels.has(label.id)\n return (\n <button\n key={label.id}\n type=\"button\"\n onClick={() => selection.toggleLabel(label.id)}\n aria-pressed={isActive}\n data-testid={prefixedTestId(testIds?.labelChip, label.id, {\n testId: `scope-picker-label-chip-${label.id}`,\n })}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:min-h-11',\n isActive\n ? 'border-primary/40 bg-primary/10 text-primary'\n : 'border-border [&:hover]:bg-accent [&:hover]:text-accent-foreground'\n )}\n >\n <span\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: label.color }}\n />\n <span className=\"truncate\">{label.name}</span>\n <span className=\"shrink-0 text-xs text-muted-foreground\">({label.count})</span>\n {isActive && <Check className=\"size-3.5 shrink-0\" />}\n </button>\n )\n })}\n </div>\n )}\n </FoldSection>\n\n <div\n className=\"rounded-lg bg-muted p-3\"\n data-testid={testIdOr(testIds?.summary, { testId: 'scope-picker-summary' })}\n >\n <div className=\"mb-2 flex items-center gap-1.5 text-xs font-medium text-muted-foreground\">\n <FileCheck2 className=\"size-4\" />\n {l.filesToInclude}\n </div>\n {selection.hasSelection ? (\n <div className=\"text-sm text-muted-foreground\">\n <span className=\"text-base font-semibold text-foreground\">\n {l.matchedOfTotal(matchedCount, totalCount)}\n </span>\n {l.selectedSuffix}\n {scope.folders.length > 0 && <span> — {l.folderCount(scope.folders.length)}</span>}\n {scope.folders.length > 0 && scope.labels.length > 0 && <span>, </span>}\n {scope.labels.length > 0 && <span>{l.labelCount(scope.labels.length)}</span>}\n <span className=\"text-xs\">\n {' · '}\n {l.left(totalCount - matchedCount)}\n </span>\n </div>\n ) : (\n <div className=\"text-sm text-muted-foreground\">\n <span className=\"text-base font-semibold text-foreground\">\n {l.allFiles(totalCount)}\n </span>\n {l.includedSuffix}\n </div>\n )}\n </div>\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { Plus, type LucideIcon } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\n\n/** The small label that names a band of a page (\"Start\", \"Recent\"). */\nexport function SectionLabel({\n children,\n className,\n testId,\n}: {\n children: ReactNode\n className?: string\n testId?: string\n}) {\n return (\n <p\n className={cn(\n 'flex items-center gap-3 text-sm font-semibold text-foreground after:h-px after:flex-1 after:bg-border',\n className\n )}\n data-slot=\"section-label\"\n data-testid={testId}\n >\n {children}\n </p>\n )\n}\n\nexport interface SectionHeaderProps {\n icon?: LucideIcon\n title: string\n count?: number\n /** Makes the title a button (open the full list). Omit for a static title. */\n onOpen?: () => void\n /** Real link target of the title; `onOpen` still fires on a plain click. */\n openHref?: string\n /** Test id of the title button. */\n openTestId?: string\n /** The section's one quiet action, rendered at the trailing edge. */\n action?: ReactNode\n className?: string\n}\n\n/** Title + count + one quiet action: the head of a list section. */\nexport function SectionHeader({\n icon: Icon,\n title,\n count,\n onOpen,\n openHref,\n openTestId,\n action,\n className,\n}: SectionHeaderProps) {\n return (\n <div\n className={cn('flex items-center justify-between gap-2', className)}\n data-slot=\"section-header\"\n >\n <ActionLink\n href={openHref}\n onSelect={onOpen}\n disabled={!onOpen && !openHref}\n className=\"flex min-w-0 cursor-pointer items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:hover:text-foreground pointer-coarse:min-h-11\"\n data-testid={openTestId}\n >\n {Icon && <Icon className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />}\n <span className=\"whitespace-nowrap text-sm font-semibold text-foreground\">{title}</span>\n {count !== undefined && (\n <span className=\"text-sm tabular-nums text-muted-foreground\">{count}</span>\n )}\n </ActionLink>\n {action && <div className=\"shrink-0\">{action}</div>}\n </div>\n )\n}\n\nexport interface EmptyStripProps {\n icon?: LucideIcon\n label: ReactNode\n description?: ReactNode\n onSelect?: () => void\n testId?: string\n}\n\n/** One tonal strip that stands in for an empty section: an invitation, not a void. */\nexport function EmptyStrip({\n icon: Icon = Plus,\n label,\n description,\n onSelect,\n testId,\n}: EmptyStripProps) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n disabled={!onSelect}\n className=\"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left border border-border bg-card shadow-xs transition-colors hover:border-ring/50 hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:hover:bg-card disabled:hover:border-border pointer-coarse:min-h-11\"\n data-slot=\"empty-strip\"\n data-testid={testId}\n >\n <Icon className=\"size-5 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-sm font-semibold text-foreground\">{label}</span>\n {description && (\n <span className=\"block text-sm leading-snug text-muted-foreground\">{description}</span>\n )}\n </span>\n </button>\n )\n}\n","/**\n * The column count for a grid of `count` equal tiles in `width` pixels, chosen so the last row is\n * never left with a lone orphan: of the counts that fit (each column at least `minTile` wide),\n * take the one that leaves the fewest empty cells in the last row, preferring more columns on a\n * tie (never fewer than two columns when two fit). Four tiles resolve to 2x2 where three would fit\n * and 4 across when there is room for four; six resolve to 3x2.\n */\nexport function balancedColumns(count: number, width: number, minTile = 200, gap = 12): number {\n if (count <= 1) return 1\n const fit = Math.max(1, Math.min(count, Math.floor((width + gap) / (minTile + gap))))\n if (fit < 2) return 1\n let best = 2\n let bestEmpty = Number.POSITIVE_INFINITY\n for (let columns = 2; columns <= fit; columns++) {\n const empty = (columns - (count % columns)) % columns\n if (empty < bestEmpty || (empty === bestEmpty && columns > best)) {\n best = columns\n bestEmpty = empty\n }\n }\n return best\n}\n","import { useEffect, useRef, useState, type ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\nimport { balancedColumns } from '../lib/balanced-columns'\nimport { observeResize } from '../lib/observe-resize'\nimport { SectionLabel } from './sections'\n\n/** One \"start something\" tile: an AI-driven action, one click from underway. */\nexport interface StartTile {\n id: string\n /** A Lucide glyph; `iconNode` wins when both are given. */\n icon?: LucideIcon\n /** A ready-made mark (host icon maps), wearing the same AI ink. */\n iconNode?: ReactNode\n title: string\n description: string\n onSelect: () => void\n /** Real link target (ctrl-click / new tab, in-SPA through `BlocksProvider`'s `linkComponent`). `onSelect` still fires on a plain click. */\n href?: string\n /** Rendered non-interactive and dimmed; `disabledReason` replaces the description. */\n disabled?: boolean\n disabledReason?: string\n testId?: string\n}\n\nexport interface StartTilesProps {\n items: StartTile[]\n /** Optional band label above the tiles (\"Start\"). */\n caption?: string\n captionTestId?: string\n className?: string\n testId?: string\n}\n\n/**\n * A band of tonal action tiles. The glyph wears the AI ink, because these are\n * the AI-driven starts. Nothing is hover-only: tiles are always rendered, hover\n * only nudges tone, and touch targets are at least 44px.\n */\nexport function StartTiles({ items, caption, captionTestId, className, testId }: StartTilesProps) {\n // The tiles reflow by their own container width (a docked tablet sidebar narrows it without\n // changing the viewport), choosing a column count that never leaves one tile alone on a row.\n const gridRef = useRef<HTMLDivElement>(null)\n const [columns, setColumns] = useState<number | null>(null)\n const count = items.length\n useEffect(() => {\n const grid = gridRef.current\n if (!grid || count === 0) return\n const measure = () => setColumns(balancedColumns(count, grid.clientWidth))\n measure()\n return observeResize(grid, measure)\n }, [count])\n\n if (count === 0) return null\n return (\n <section\n className={cn('flex flex-col gap-3', className)}\n data-slot=\"start-tiles\"\n data-testid={testId}\n >\n {caption && <SectionLabel testId={captionTestId}>{caption}</SectionLabel>}\n <div\n ref={gridRef}\n data-slot=\"start-tiles-grid\"\n data-columns={columns ?? undefined}\n className=\"grid gap-3\"\n style={{\n gridTemplateColumns:\n columns === null\n ? 'repeat(auto-fit, minmax(200px, 1fr))'\n : `repeat(${columns}, minmax(0, 1fr))`,\n }}\n >\n {items.map((item) => {\n const Icon = item.icon\n return (\n <ActionLink\n key={item.id}\n href={item.href}\n onSelect={item.onSelect}\n disabled={item.disabled}\n title={item.disabled ? item.disabledReason : undefined}\n className={cn(\n 'flex h-full flex-col items-start gap-3 rounded-lg p-4 text-left',\n 'border border-border bg-card shadow-xs transition-colors hover:border-ring/50 hover:bg-accent/40',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n 'disabled:cursor-default disabled:opacity-55 disabled:hover:bg-card disabled:hover:border-border',\n 'pointer-coarse:min-h-11'\n )}\n data-slot=\"start-tile\"\n data-testid={item.testId}\n >\n {item.iconNode ? (\n <span className=\"shrink-0 text-ai-ink [&>svg]:size-5\" aria-hidden=\"true\">\n {item.iconNode}\n </span>\n ) : (\n Icon && <Icon className=\"size-5 shrink-0 text-ai-ink\" aria-hidden=\"true\" />\n )}\n <span className=\"min-w-0\">\n <span className=\"block text-sm font-semibold text-foreground\">{item.title}</span>\n <span className=\"mt-1 block text-sm leading-snug text-muted-foreground\">\n {item.disabled && item.disabledReason ? item.disabledReason : item.description}\n </span>\n </span>\n </ActionLink>\n )\n })}\n </div>\n </section>\n )\n}\n"]}
|
|
@@ -171,6 +171,25 @@ function skillToWorkflow(skill) {
|
|
|
171
171
|
schedulable: true
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
+
function skillTitle(name) {
|
|
175
|
+
if (!/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(name)) return name;
|
|
176
|
+
const words = name.replace(/[-_]+/g, " ");
|
|
177
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
178
|
+
}
|
|
179
|
+
function mergeSkillWorkflows(host, listings) {
|
|
180
|
+
const hostIds = new Set(host.map((w) => w.id));
|
|
181
|
+
const skills = listings.filter((s) => !(s.visibility === "builtin" && hostIds.has(s.slug))).map((s) => ({
|
|
182
|
+
...skillToWorkflow({
|
|
183
|
+
name: skillTitle(s.name || s.slug),
|
|
184
|
+
slug: s.slug,
|
|
185
|
+
description: s.description ?? void 0,
|
|
186
|
+
arg_hint: s.arg_hint ?? void 0
|
|
187
|
+
}),
|
|
188
|
+
icon: "skill"
|
|
189
|
+
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
190
|
+
const shadowed = new Set(skills.map((w) => w.id));
|
|
191
|
+
return { host: host.filter((w) => !shadowed.has(w.id)), skills };
|
|
192
|
+
}
|
|
174
193
|
var FIELD_TYPES = [
|
|
175
194
|
"text",
|
|
176
195
|
"longtext",
|
|
@@ -939,6 +958,7 @@ exports.isPersonStep = isPersonStep;
|
|
|
939
958
|
exports.isRunFinished = isRunFinished;
|
|
940
959
|
exports.isSteppedWorkflow = isSteppedWorkflow;
|
|
941
960
|
exports.isWorkflowScope = isWorkflowScope;
|
|
961
|
+
exports.mergeSkillWorkflows = mergeSkillWorkflows;
|
|
942
962
|
exports.nextAction = nextAction;
|
|
943
963
|
exports.orderSteps = orderSteps;
|
|
944
964
|
exports.promptFieldName = promptFieldName;
|
|
@@ -949,6 +969,7 @@ exports.runFieldsOf = runFieldsOf;
|
|
|
949
969
|
exports.runThreadTitle = runThreadTitle;
|
|
950
970
|
exports.sendBackTargets = sendBackTargets;
|
|
951
971
|
exports.shownValue = shownValue;
|
|
972
|
+
exports.skillTitle = skillTitle;
|
|
952
973
|
exports.skillToWorkflow = skillToWorkflow;
|
|
953
974
|
exports.splitDocRef = splitDocRef;
|
|
954
975
|
exports.stepConfigProblems = stepConfigProblems;
|
|
@@ -972,5 +993,5 @@ exports.workflowFromFrontmatter = workflowFromFrontmatter;
|
|
|
972
993
|
exports.workflowSteps = workflowSteps;
|
|
973
994
|
exports.workflowsAccepting = workflowsAccepting;
|
|
974
995
|
exports.workflowsForHost = workflowsForHost;
|
|
975
|
-
//# sourceMappingURL=chunk-
|
|
976
|
-
//# sourceMappingURL=chunk-
|
|
996
|
+
//# sourceMappingURL=chunk-6F7SZCVL.cjs.map
|
|
997
|
+
//# sourceMappingURL=chunk-6F7SZCVL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents/workflows/types.ts","../src/agents/workflows/workflow.ts","../src/agents/workflows/run.ts","../src/agents/workflows/StepDocuments.tsx","../src/agents/workflows/stepKinds.ts","../src/chat/useMentionAutocomplete.ts","../src/agents/workflows/StepChip.tsx","../src/lib/useElementSize.ts"],"names":["isTone","str","before","waiting","finished","jsxs","jsx","FileText","Button","cn","FileInput","Upload","Bot","ClipboardCheck","PenLine","Mail","Table2","useState","useEffect","useMemo","findMentionQuery","filterMentionCandidates","useCallback","insertMention","useListKeyNav","Fragment","Check","Loader2","Hourglass","AlertTriangle","MinusCircle","forwardRef","StepChip","useLayoutEffect","observeResize"],"mappings":";;;;;;;;;;;AA4CO,IAAM,uBAAsC,EAAE,OAAA,EAAS,EAAC,EAAG,MAAA,EAAQ,EAAC;;;AC7BpE,IAAM,kBAAkB,CAAC,KAAA,KAC9B,OAAO,KAAA,KAAU,YACjB,KAAA,KAAU,IAAA,IACV,KAAA,CAAM,OAAA,CAAS,MAAwB,OAAO,CAAA,IAC9C,KAAA,CAAM,OAAA,CAAS,MAAwB,MAAM;AAExC,IAAM,oB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: a skill with a declared input schema. Everything launchable (a quick\n * action, a slash skill, a task body, an agent's job) is a `WorkflowDefinition`.\n *\n * The shape maps 1:1 onto future SKILL.md frontmatter (`inputs:` etc., snake_case on disk; see\n * `workflowFromFrontmatter`), so the backend can adopt it without a UI change. Blocks hold no\n * domain wording: titles, labels and prompt text are data supplied by the host.\n */\n\nimport type { Tone } from '../../components/tones'\n\nexport type WorkflowFieldType =\n | 'text'\n | 'longtext'\n | 'boolean'\n | 'select'\n | 'number'\n | 'date'\n | 'scope'\n | 'documents'\n /** A workspace member (`usr-…` / `agt-…`): what a step's assignee or a signer can name. */\n | 'person'\n\n/**\n * What a launching surface can hand a workflow without asking the user: the files it is looking at\n * (`documents`), the text the user selected (`selection`), or the image on screen (`image`, a file\n * id). A field binds to one with `context`; a surface offers a workflow when it can supply one of\n * the kinds the workflow declares (`workflowAccepts`).\n */\nexport type WorkflowContextKind = 'documents' | 'selection' | 'image'\n\n/** Where the user ends up after launching. `current-chat` sends into the chat already on screen. */\nexport type WorkflowLanding = 'chat' | 'current-chat' | 'files'\n\n/** Which files a run is limited to. Empty folders and labels = every file. */\nexport interface WorkflowScope {\n /** Folder paths; `''` is the unfiled bucket. */\n folders: string[]\n /** Label (tag) ids. */\n labels: string[]\n /** Exactly these files (ids). When present it wins over folders and labels: a `documents` field or a context launch. */\n documents?: string[]\n}\n\nexport const EMPTY_WORKFLOW_SCOPE: WorkflowScope = { folders: [], labels: [] }\n\nexport type WorkflowInputValue = string | number | boolean | WorkflowScope\n\nexport interface WorkflowFieldOption {\n value: string\n label: string\n description?: string\n /** Prompt fragment substituted for `{{name}}` when chosen (falls back to the label). */\n text?: string\n /** Key into the host's icon map. */\n icon?: string\n /**\n * Colours the option's choice tile (e.g. a risk rating: low `success`, medium `warning`, high\n * `danger`), chosen or not. The label always shows, so the tone is never the only cue.\n */\n tone?: Tone\n}\n\nexport interface WorkflowField {\n /** Key in `inputs`; also the `{{placeholder}}` in the prompt template. */\n name: string\n type: WorkflowFieldType\n label: string\n description?: string\n placeholder?: string\n required?: boolean\n default?: WorkflowInputValue\n /** `select` only. */\n options?: WorkflowFieldOption[]\n /** `number` only. */\n min?: number\n max?: number\n /** `boolean`: prompt fragments substituted for `{{name}}`. */\n trueText?: string\n falseText?: string\n /** Fold behind a disclosure: advanced wording the common run does not need. */\n advanced?: boolean\n /** `scope` only: which dimensions are offered. Default both. */\n by?: Array<'folders' | 'labels'>\n /** `documents` only: what kind of file is offered; `max` is how many may be picked (default 1). */\n accept?: 'image'\n /** Prefilled by a launching surface that supplies this kind of context (see `WorkflowContextKind`). */\n context?: WorkflowContextKind\n}\n\nexport type WorkflowRun =\n /** Compose a message from `promptTemplate` and send it. */\n | { kind: 'prompt'; promptTemplate: string }\n /** The host performs it (bound by workflow id), e.g. create a label then generate. */\n | { kind: 'operation' }\n /**\n * A guided run of named steps that form a graph. A run is a work thread on the server: the\n * thread's plan carries the steps (`toPlanSteps`), its activity log records each step's progress,\n * and the work runner starts each agent step as a turn in the thread. A person does the form,\n * upload and review steps (`useWorkflowThread` / `WorkflowRunner`). Not schedulable from a single\n * form: a workflow (automation) carries the steps and its trigger (`WorkflowBuilder`).\n */\n | {\n kind: 'steps'\n /** The run thread's title, a template over the run's inputs; defaults to the workflow's. */\n threadTitle?: string\n /** In dependency order: a step only waits for steps listed before it (`orderSteps`). */\n steps: WorkflowStep[]\n completion?: WorkflowCompletion\n /** Where each step sits on the builder's canvas, by step id. */\n layout?: Record<string, { x: number; y: number }>\n }\n\n/* ------------------------------- steps ------------------------------- */\n\n/**\n * When a step's signal is raised, tested against the step's outcome once it is done (a skipped or\n * failed step never signals): a form field equals a value (case-insensitive text), the agent's\n * answer contains a phrase or matches a regex, or a review is approved. Absent = whenever it is done.\n */\nexport type WorkflowSignalWhen =\n | { field: string; equals: string | number | boolean }\n | { contains: string }\n | { matches: string }\n | { approved: true }\n\n/**\n * A named signal a step raises when it is done and its condition holds. Another workflow starts on\n * it (\"When a step signals\") as its own thread linked to this one, so the if/then between\n * workflows lives in the link and each workflow stays short.\n */\nexport interface WorkflowSignal {\n /** A slug (`[a-z0-9][a-z0-9_.-]*`), e.g. `risk-high`: what a linked workflow listens for. */\n name: string\n when?: WorkflowSignalWhen\n}\n\ninterface WorkflowStepBase {\n /** Unique within the workflow (`[a-z][a-z0-9_-]*`): the thread's progress is keyed by it. */\n id: string\n /** The step's name: the stepper and the thread's top bar show it. */\n title: string\n /** One line under the step's heading. */\n description?: string\n /** Key into the host's icon map. */\n icon?: string\n /**\n * The host commits this step before the run moves on (`commit[id]`), e.g. creates the record\n * later steps work in. Once committed the step's inputs are locked.\n */\n commit?: boolean\n /** Primary button text while on this step (until it is committed); defaults to \"Continue\". */\n nextLabel?: string\n /**\n * The steps this one waits for. Absent: the step before it in the list, so a plain list is a\n * sequence. `[]`: it starts with the run. A step waiting for several waits for them all.\n */\n after?: string[]\n /** Signals the step raises when it is done and their condition holds. */\n signals?: WorkflowSignal[]\n /**\n * Who the step is for (a person step, or a signature or email step): they are told when it is\n * ready, and only they (or the run's owner) can do it. Absent: whoever is on the run.\n */\n assignee?: WorkflowAssignee\n /** A person step left this many hours is announced again (once). */\n remindAfterHours?: number\n}\n\n/**\n * Who a step is for: a named member (`usr-…` / `agt-…`), whoever started the run, the person a\n * form's `person` field names (`input`: its name), or the project's lead.\n */\nexport type WorkflowAssignee =\n { user: string } | { runOwner: true } | { input: string } | { projectLead: true }\n\n/**\n * A document a step works on, named by where it comes from: what an earlier step produced or was\n * given (an upload's files, an agent's draft, a signed copy, an edited version), what a run input\n * names (a document pick), or one document by id (`doc-…`, optionally `@v<n>`).\n */\nexport type WorkflowDocumentRef = { step: string } | { input: string } | { id: string }\n\n/** Ask people to e-sign a document. The step waits until every signer has signed. */\nexport interface WorkflowSignAction {\n type: 'sign'\n document?: WorkflowDocumentRef\n signers: WorkflowAssignee[]\n /** Shown to the signers. */\n message?: string\n /** Unsigned this long after it starts, the step fails. */\n expiresAfterHours?: number\n}\n\n/**\n * Prepare an email in native mail, never sent by itself: its person sends it, and the step is done\n * when they say so (or send it). Every text is a template over the run (`{{field}}`,\n * `{{step.answer}}`).\n */\nexport interface WorkflowEmailDraftAction {\n type: 'email_draft'\n to: string[]\n cc?: string[]\n subject: string\n body: string\n attachments?: WorkflowDocumentRef[]\n}\n\n/** Run review columns (labels with instructions) over documents, then open the grid. */\nexport interface WorkflowTabularReviewAction {\n type: 'tabular_review'\n /** Label (tag) ids: the columns. */\n tags: string[]\n /** Every file the run's uploads took, every document of the workspace, or these documents. */\n documents: 'run_uploads' | 'workspace' | WorkflowDocumentRef[]\n /** Fill cells that already have a value again. */\n overwrite?: boolean\n}\n\nexport type WorkflowAction =\n WorkflowSignAction | WorkflowEmailDraftAction | WorkflowTabularReviewAction\nexport type WorkflowActionType = WorkflowAction['type']\n\n/** Ask for inputs. Every step's fields share the run's one input namespace (`{{name}}`). */\nexport interface WorkflowFormStep extends WorkflowStepBase {\n kind: 'form'\n inputs: WorkflowField[]\n}\n\n/** Add files to the run's workspace. Skippable unless `required`. */\nexport interface WorkflowUploadStep extends WorkflowStepBase {\n kind: 'upload'\n required?: boolean\n /** `accept` of the file picker, e.g. `.pdf,.docx`. */\n accept?: string\n /** Small muted line under the drop target. */\n hint?: string\n}\n\n/**\n * A turn the assistant takes in the run's thread. It runs a skill or another workflow\n * (`workflow`, its inputs filled from `with`) or its own `run`. It continues the thread's main\n * line, so it sees everything before it; a `branch` step runs off the main line instead and\n * delivers only its result back to it.\n */\nexport interface WorkflowAgentStep extends WorkflowStepBase {\n kind: 'agent'\n /** Id of the skill or workflow this step runs; its inputs come from `with`. */\n workflow?: string\n /**\n * The named workflow's inputs, each a template over the run's inputs: `{{client}}`, with\n * `{{a || b}}` falling back to `b` when `a` is blank. A bare `{{name}}` passes the value as is.\n */\n with?: Record<string, string>\n /** Used when no `workflow` is named. `operation`: the host composes the prompt (`compose`). */\n run?: Extract<WorkflowRun, { kind: 'prompt' } | { kind: 'operation' }>\n /** What the step shows: the answer (default) or the drafted document. */\n output?: 'answer' | 'artifact'\n /** Runs off the thread's main line and delivers only its result to it. */\n branch?: boolean\n /**\n * Edit this Word document with tracked changes (the instruction says what to change); the\n * edited copy is its next version, to accept or reject change by change. Main line only.\n */\n editDocument?: WorkflowDocumentRef\n}\n\n/** A person's review or approval: whoever completes it on the thread approves it. */\nexport interface WorkflowReviewStep extends WorkflowStepBase {\n kind: 'review'\n /** What to review, a template over the run's inputs. */\n instructions?: string\n /** What the approver fills in when approving (e.g. a rating): they join the run's inputs. */\n fields?: WorkflowField[]\n}\n\n/**\n * A step that uses a platform feature rather than producing text: an e-signature, an email draft\n * or a tabular review. It starts by itself; a signature and an email then wait for their people.\n */\nexport interface WorkflowActionStep extends WorkflowStepBase {\n kind: 'action'\n action: WorkflowAction\n}\n\nexport type WorkflowStep =\n | WorkflowFormStep\n | WorkflowUploadStep\n | WorkflowAgentStep\n | WorkflowReviewStep\n | WorkflowActionStep\n\n/** The finish screen of a stepped run. */\nexport interface WorkflowCompletion {\n title: string\n description?: string\n icon?: string\n}\n\n/**\n * Where a step of a run is, as the thread records it: not reached yet (`pending`), `running`,\n * `waiting` (an action step waiting on its signers or on its email being sent), `done`,\n * `skipped`, or `failed` (it can be retried or skipped).\n */\nexport type WorkflowStepStatus = 'pending' | 'running' | 'waiting' | 'done' | 'skipped' | 'failed'\n\n/** What a waiting step waits on (ids only), as its latest event says. */\nexport interface WorkflowActionWaiting {\n /** An agent step: the documents to finish processing before its turn starts. */\n documents?: string[]\n /** A signature: the document and version to sign, who signs, who has signed. */\n doc_ext_id?: string\n version?: number\n signers?: string[]\n signed?: string[]\n expires_at?: string\n /** An email: the draft in native mail and whose mailbox it is in. */\n draft_id?: string\n mailbox?: string\n [key: string]: unknown\n}\n\n/** What a review recorded it approved: each step it waited for, as it stood then. */\nexport interface WorkflowApprovalEvidence {\n step: string\n status: string\n /** That step's answer (a message in the thread). */\n response_id?: string\n /** The document versions it had (`doc-…@v<n>`). */\n documents?: string[]\n output?: Record<string, unknown>\n}\n\nexport interface WorkflowStepState {\n status: WorkflowStepStatus\n /** The step's answer in the thread (an agent step), or the result a branch delivered. */\n responseId?: string | null\n /** The answer's text, once read. */\n text?: string\n error?: string | null\n /**\n * Skipped while it stood failed (`error` keeps why it failed): what waits for it goes on\n * without its result.\n */\n skippedAfterFailure?: boolean\n /** When it started running (ISO), for the elapsed time while it runs. */\n startedAt?: string\n /** An action step's type, once it has started. */\n action?: WorkflowActionType\n /** What a `waiting` step waits on (an action step's people, an agent step's documents). */\n waiting?: WorkflowActionWaiting\n /** What a done action step produced (ids: the signed version, the draft, the reviewed labels). */\n output?: Record<string, unknown>\n /** The document versions the step produced or was given (`doc-…@v<n>`). */\n documents?: string[]\n /** Reopened by a send-back to this step and not touched since (`hasNote`: with a note). */\n sentBack?: boolean\n hasNote?: boolean\n /** Who was told the step is ready (`usr-…` / `agt-…`), since it last changed. */\n announcedTo?: string | null\n /** Who finished it (completed, approved, skipped, declined). */\n by?: string | null\n /** When it finished (ISO). */\n at?: string\n /** A review: what it approved. */\n approved?: WorkflowApprovalEvidence[]\n /** A declined signature: who declined. */\n declinedBy?: string\n}\n\nexport interface WorkflowDefinition {\n /** Execute a document operation directly, without creating a chat. */\n documentAction?: 'annotate_documents' | 'email_documents'\n\n /** The skill slug. */\n id: string\n title: string\n /** One line: the tile text and the task picker's hint. */\n description: string\n /** Longer explanation shown in the dialog header; defaults to `description`. */\n details?: string\n /** Key into the host's icon map. */\n icon?: string\n /** Primary button text; defaults to the dialog's generic \"Start\". */\n startLabel?: string\n /** Shipped with the app/deployment (pinned, not deletable, forkable into the user's own skills). */\n builtin?: boolean\n /** Backed by a server skill (its slug): a task runs it as a skill rather than as a prompt. */\n skill?: string\n inputs: WorkflowField[]\n run: WorkflowRun\n /** Where the user ends up after launching by default; a launch may override it. */\n landing: WorkflowLanding\n /** A model this run asks for (a run option the host applies, e.g. a stronger one for summaries). */\n model?: string\n /** Only offered by this host (e.g. `'word'`); absent = offered everywhere. */\n host?: string\n /** Needs workspace files to make sense: the dialog offers the host's add-files slot when none. */\n requiresFiles?: boolean\n /** Default agent; absent = the user's own assistant. */\n defaultAgentId?: string\n /** A free-form entry (\"my own instruction\", \"remind me\"), not a named skill: it does not name the dialog. */\n generic?: boolean\n /** Can be the body of a task (unattended). `action` workflows are not. */\n schedulable?: boolean\n /** Run options the form offers (all shown by default). */\n options?: { agent?: boolean }\n}\n\n/** What `onLaunch` receives. The host performs the launch (chat, scoping, send). */\nexport interface WorkflowLaunch {\n workflow: WorkflowDefinition\n inputs: Record<string, WorkflowInputValue>\n /** The first `scope` field's value, hoisted: the host scopes documents with it. */\n scope: WorkflowScope\n /** `undefined` = the user's own assistant, in this chat. */\n agentId?: string\n /** Overrides `workflow.landing` for this launch (the empty chat sends in place). */\n landing?: WorkflowLanding\n}\n\nexport type OnWorkflowLaunch = (launch: WorkflowLaunch) => void | Promise<void>\n\nexport type WorkflowInputs = Record<string, WorkflowInputValue>\n\n/** Validation problem of one field: the dialog maps the code to a label. */\nexport type WorkflowFieldError = 'required' | 'min' | 'max' | 'number'\nexport type WorkflowErrors = Record<string, WorkflowFieldError>\n","import { isTone } from '../../components/tones'\nimport {\n EMPTY_WORKFLOW_SCOPE,\n type WorkflowDefinition,\n type WorkflowErrors,\n type WorkflowField,\n type WorkflowFieldOption,\n type WorkflowContextKind,\n type WorkflowFieldType,\n type WorkflowInputs,\n type WorkflowInputValue,\n type WorkflowLaunch,\n type WorkflowScope,\n} from './types'\n\nexport const isWorkflowScope = (value: unknown): value is WorkflowScope =>\n typeof value === 'object' &&\n value !== null &&\n Array.isArray((value as WorkflowScope).folders) &&\n Array.isArray((value as WorkflowScope).labels)\n\nexport const isEmptyWorkflowScope = (scope: WorkflowScope): boolean =>\n scope.folders.length === 0 && scope.labels.length === 0 && !scope.documents?.length\n\n/** A field that selects files: a folder/label scope or an explicit pick. */\nconst isFileField = (field: WorkflowField): boolean =>\n field.type === 'scope' || field.type === 'documents'\n\nfunction emptyValue(field: WorkflowField): WorkflowInputValue {\n switch (field.type) {\n case 'boolean':\n return false\n case 'scope':\n return { folders: [], labels: [] }\n case 'documents':\n return { folders: [], labels: [], documents: [] }\n default:\n return ''\n }\n}\n\n/** The inputs a fresh form starts with: each field's default, else an empty value of its type. */\nexport function defaultInputs(workflow: WorkflowDefinition): WorkflowInputs {\n const inputs: WorkflowInputs = {}\n for (const field of workflow.inputs) {\n const d = field.default\n inputs[field.name] =\n d === undefined\n ? emptyValue(field)\n : isWorkflowScope(d)\n ? { ...d }\n : (d as WorkflowInputValue)\n }\n return inputs\n}\n\n/** Required-field and range problems, keyed by field name. Empty object = launchable. */\nexport function validateInputs(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs\n): WorkflowErrors {\n const errors: WorkflowErrors = {}\n for (const field of workflow.inputs) {\n const value = inputs[field.name]\n if (field.type === 'number') {\n const blank = value === '' || value === undefined\n if (blank) {\n if (field.required) errors[field.name] = 'required'\n continue\n }\n const n = Number(value)\n if (Number.isNaN(n)) errors[field.name] = 'number'\n else if (field.min !== undefined && n < field.min) errors[field.name] = 'min'\n else if (field.max !== undefined && n > field.max) errors[field.name] = 'max'\n continue\n }\n if (!field.required) continue\n if (field.type === 'documents') {\n if (!isWorkflowScope(value) || !value.documents?.length) errors[field.name] = 'required'\n continue\n }\n if (field.type === 'boolean' || field.type === 'scope') continue\n if (typeof value !== 'string' || value.trim() === '') errors[field.name] = 'required'\n }\n return errors\n}\n\n/**\n * The field that holds what the user asks for: the first common (not folded away) free-text field.\n * Text typed after a slash pre-fills it; the form puts the cursor in it when it comes first.\n */\nexport function promptFieldName(workflow: WorkflowDefinition): string | undefined {\n return workflow.inputs.find((f) => !f.advanced && (f.type === 'text' || f.type === 'longtext'))\n ?.name\n}\n\n/** What the host knows that the inputs alone do not: file ids resolved to names for the wording. */\nexport interface WorkflowComposeContext {\n documentTitles?: Record<string, string>\n}\n\nconst quoteList = (names: string[]): string => {\n const quoted = names.map((n) => `\"${n}\"`)\n return quoted.length <= 1\n ? (quoted[0] ?? '')\n : `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n}\n\nfunction fragment(\n field: WorkflowField,\n value: WorkflowInputValue | undefined,\n ctx: WorkflowComposeContext | undefined\n): string {\n switch (field.type) {\n case 'documents': {\n // The quoted file name(s): \"the document <name>\" reads the same whichever file was picked.\n const ids = isWorkflowScope(value) ? (value.documents ?? []) : []\n const names = ids.flatMap((id) => {\n const title = ctx?.documentTitles?.[id]\n return title ? [title] : []\n })\n return quoteList(names)\n }\n case 'boolean':\n return value ? (field.trueText ?? 'yes') : (field.falseText ?? 'no')\n case 'select': {\n const option = field.options?.find((o) => o.value === value)\n return option ? (option.text ?? option.label) : String(value ?? '')\n }\n case 'scope':\n // The scope decides WHICH files the run is given; naming it in the wording only churns it.\n return ''\n default:\n return typeof value === 'string' ? value.trim() : String(value ?? '')\n }\n}\n\n/**\n * The single place a prompt string is composed from (workflow, inputs): `{{name}}` placeholders in\n * the template are replaced by each field's text. Whitespace left by empty fragments is tidied.\n */\nexport function composeWorkflowPrompt(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n ctx?: WorkflowComposeContext\n): string {\n if (workflow.run.kind !== 'prompt') return ''\n const byName = new Map(workflow.inputs.map((f) => [f.name, f]))\n const template = workflow.run.promptTemplate\n // Whitespace left by empty fragments is tidied in the template's own text only: what the user\n // typed or selected (tabs, runs of spaces) reaches the prompt exactly as it was.\n let out = ''\n let last = 0\n const append = (text: string, isValue: boolean) => {\n let t = text\n if (!isValue) {\n t = t.replace(/[ \\t]{2,}/g, ' ')\n if (/[ \\t]$/.test(out)) t = t.replace(/^[ \\t]+/, '')\n }\n out += t\n }\n for (const m of template.matchAll(/\\{\\{\\s*([a-z][a-z0-9_]*)\\s*\\}\\}/gi)) {\n append(template.slice(last, m.index), false)\n const field = byName.get(m[1])\n append(field ? fragment(field, inputs[m[1]], ctx) : '', true)\n last = m.index + m[0].length\n }\n append(template.slice(last), false)\n return out.trim()\n}\n\n/** Assemble the launch the host receives: inputs, the hoisted scope and the chosen agent. */\nexport function buildLaunch(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n agentId?: string\n): WorkflowLaunch {\n const scopeField = workflow.inputs.find(isFileField)\n const raw = scopeField ? inputs[scopeField.name] : undefined\n const scope = isWorkflowScope(raw) ? raw : { ...EMPTY_WORKFLOW_SCOPE }\n return { workflow, inputs, scope, agentId: agentId || workflow.defaultAgentId || undefined }\n}\n\n/* --------------------------- context launch --------------------------- */\n\n/** What a surface hands a workflow: the files in view, the selected text, the image on screen. */\nexport interface WorkflowContext {\n documents?: string[]\n selection?: string\n /** A file id. */\n image?: string\n}\n\n/** The kinds of context a workflow declares it can be started from. */\nexport function workflowAccepts(workflow: WorkflowDefinition): WorkflowContextKind[] {\n const kinds = new Set<WorkflowContextKind>()\n for (const field of workflow.inputs) if (field.context) kinds.add(field.context)\n return [...kinds]\n}\n\n/** Workflows a surface can offer: those that accept at least one kind of context it supplies. */\nexport function workflowsAccepting(\n workflows: WorkflowDefinition[],\n supplied: WorkflowContextKind[]\n): WorkflowDefinition[] {\n return workflows.filter((w) => workflowAccepts(w).some((k) => supplied.includes(k)))\n}\n\n/** Workflows a host offers: its own plus every one that is not tied to another host. */\nexport function workflowsForHost(\n workflows: WorkflowDefinition[],\n host: string\n): WorkflowDefinition[] {\n return workflows.filter((w) => !w.host || w.host === host)\n}\n\n/**\n * The inputs a context pre-fills: each field bound to a kind the surface supplied. Fields it does\n * not supply are left to the form's defaults, so the dialog still asks for them.\n */\nexport function inputsFromContext(\n workflow: WorkflowDefinition,\n context: WorkflowContext\n): WorkflowInputs {\n const inputs: WorkflowInputs = {}\n for (const field of workflow.inputs) {\n if (!field.context) continue\n if (field.context === 'selection') {\n if (context.selection) inputs[field.name] = context.selection\n continue\n }\n const ids =\n field.context === 'image' ? (context.image ? [context.image] : []) : context.documents\n if (ids?.length && isFileField(field)) {\n inputs[field.name] = { folders: [], labels: [], documents: ids.slice(0, field.max ?? 1) }\n }\n }\n return inputs\n}\n\n/* ------------------------------ skills ------------------------------- */\n\n/** The slice of a skill listing row the model needs (`SkillSummaryResponse`). */\nexport interface SkillLike {\n name: string\n slug: string\n description?: string\n arg_hint?: string\n}\n\n/** The prompt field's label when a skill brings none of its own. */\nexport const SKILL_PROMPT_LABEL = 'What should it work on?'\nexport const SKILL_PROMPT_FALLBACK_PLACEHOLDER = 'Describe what you want'\n\n/** `<prompt>` / `[topic]` becomes `prompt` / `topic`: a hint reads as a placeholder, not syntax. */\nconst plainHint = (hint: string): string => hint.replace(/^[<[]\\s*|\\s*[>\\]]$/g, '').trim()\n\n/**\n * A skill is run WITH a prompt, so it always gets a one-field form: a required free-text field\n * (`args`) whose placeholder is the skill's `arg_hint` (brackets removed). Starting one with\n * nothing is never offered; text typed after the slash pre-fills the field.\n */\nexport function skillToWorkflow(skill: SkillLike): WorkflowDefinition {\n const hint = plainHint((skill.arg_hint ?? '').trim())\n const inputs: WorkflowField[] = [\n {\n name: 'args',\n type: 'longtext',\n label: SKILL_PROMPT_LABEL,\n placeholder: hint || SKILL_PROMPT_FALLBACK_PLACEHOLDER,\n required: true,\n },\n ]\n return {\n id: skill.slug,\n skill: skill.slug,\n title: skill.name || skill.slug,\n description: skill.description ?? '',\n inputs,\n run: { kind: 'prompt', promptTemplate: `/${skill.slug} {{args}}` },\n landing: 'chat',\n schedulable: true,\n }\n}\n\n/** A skill named like its slug (\"deep-research\") reads as a title (\"Deep research\"); a written name is kept. */\nexport function skillTitle(name: string): string {\n if (!/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(name)) return name\n const words = name.replace(/[-_]+/g, ' ')\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/** A skill as the skills list returns it (`GET /v1/assistant/skills`). */\nexport interface SkillListing extends Omit<SkillLike, 'arg_hint' | 'description'> {\n description?: string | null\n arg_hint?: string | null\n /** `builtin` ships with ARBI; `mine` and `global` are documents someone uploaded. */\n visibility?: string | null\n}\n\n/**\n * The host's own workflows together with the skills the user can run, as one list of workflows:\n * `host` (in its order) and `skills` (by slug, each a one-field form, icon `skill`). An uploaded skill with a\n * host workflow's id replaces it (your own copy is used instead of the original); a built-in skill\n * the host already offers keeps the host's richer form, so nothing is listed twice.\n */\nexport function mergeSkillWorkflows(\n host: WorkflowDefinition[],\n listings: SkillListing[]\n): { host: WorkflowDefinition[]; skills: WorkflowDefinition[] } {\n const hostIds = new Set(host.map((w) => w.id))\n const skills = listings\n .filter((s) => !(s.visibility === 'builtin' && hostIds.has(s.slug)))\n .map((s) => ({\n ...skillToWorkflow({\n name: skillTitle(s.name || s.slug),\n slug: s.slug,\n description: s.description ?? undefined,\n arg_hint: s.arg_hint ?? undefined,\n }),\n icon: 'skill',\n }))\n .sort((a, b) => a.id.localeCompare(b.id))\n const shadowed = new Set(skills.map((w) => w.id))\n return { host: host.filter((w) => !shadowed.has(w.id)), skills }\n}\n\nconst FIELD_TYPES: WorkflowFieldType[] = [\n 'text',\n 'longtext',\n 'boolean',\n 'select',\n 'number',\n 'date',\n 'scope',\n 'documents',\n]\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' ? v : undefined)\nconst num = (v: unknown): number | undefined => (typeof v === 'number' ? v : undefined)\nconst bool = (v: unknown): boolean | undefined => (typeof v === 'boolean' ? v : undefined)\n\nfunction fieldFromFrontmatter(raw: unknown): WorkflowField | null {\n if (typeof raw !== 'object' || raw === null) return null\n const r = raw as Record<string, unknown>\n const name = str(r.name)\n const type = FIELD_TYPES.find((t) => t === r.type)\n if (!name || !/^[a-z][a-z0-9_]*$/.test(name) || !type) return null\n const options = Array.isArray(r.options)\n ? r.options.flatMap((o): WorkflowFieldOption[] => {\n const ro = o as Record<string, unknown>\n const value = str(ro?.value)\n const label = str(ro?.label)\n return value && label\n ? [\n {\n value,\n label,\n description: str(ro.description),\n text: str(ro.text),\n icon: str(ro.icon),\n tone: isTone(ro.tone) ? ro.tone : undefined,\n },\n ]\n : []\n })\n : undefined\n return {\n name,\n type,\n label: str(r.label) ?? name,\n description: str(r.description),\n placeholder: str(r.placeholder),\n required: bool(r.required),\n default: r.default as WorkflowInputValue | undefined,\n options,\n min: num(r.min),\n max: num(r.max),\n trueText: str(r.true_text),\n falseText: str(r.false_text),\n advanced: bool(r.advanced),\n accept: r.accept === 'image' ? 'image' : undefined,\n context:\n r.context === 'documents' || r.context === 'selection' || r.context === 'image'\n ? r.context\n : undefined,\n by: Array.isArray(r.by)\n ? (r.by.filter((b) => b === 'folders' || b === 'labels') as Array<'folders' | 'labels'>)\n : undefined,\n }\n}\n\n/**\n * Build a workflow from parsed SKILL.md frontmatter (snake_case keys) and its body (the prompt\n * template). The inverse of what the backend will publish; seeded workflows use the same shape.\n */\nexport function workflowFromFrontmatter(\n id: string,\n frontmatter: Record<string, unknown>,\n body: string\n): WorkflowDefinition {\n const inputs = Array.isArray(frontmatter.inputs)\n ? frontmatter.inputs.flatMap((f) => {\n const field = fieldFromFrontmatter(f)\n return field ? [field] : []\n })\n : []\n return {\n id,\n title: str(frontmatter.name) ?? id,\n description: str(frontmatter.description) ?? '',\n icon: str(frontmatter.icon),\n inputs,\n run: { kind: 'prompt', promptTemplate: body.trim() },\n landing: frontmatter.landing === 'files' ? 'files' : 'chat',\n requiresFiles: bool(frontmatter.requires_files),\n schedulable: bool(frontmatter.schedulable) ?? true,\n }\n}\n\n/** snake_case keys of the on-disk form of a field (what `workflowFromFrontmatter` reads). */\nexport function fieldToFrontmatter(field: WorkflowField): Record<string, unknown> {\n return compact({\n name: field.name,\n type: field.type,\n label: field.label,\n description: field.description,\n placeholder: field.placeholder,\n required: field.required,\n default: field.default,\n options: field.options?.map((o) =>\n compact({\n value: o.value,\n label: o.label,\n description: o.description,\n text: o.text,\n icon: o.icon,\n tone: o.tone,\n })\n ),\n min: field.min,\n max: field.max,\n true_text: field.trueText,\n false_text: field.falseText,\n advanced: field.advanced,\n by: field.by,\n accept: field.accept,\n context: field.context,\n })\n}\n\nconst compact = (o: Record<string, unknown>): Record<string, unknown> =>\n Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined))\n","/**\n * The model of a stepped workflow (`run: { kind: 'steps' }`): the steps form a graph (each waits\n * for the steps in its `after`), and a run's progress is each step's `WorkflowStepState`, as the\n * run's thread records it (`stepStatesFromActivity`). Pure functions, shared by the thread runner\n * (`useWorkflowThread`), the builder's preview and the thread's top bar.\n */\n\nimport type {\n WorkflowActionStep,\n WorkflowActionType,\n WorkflowAgentStep,\n WorkflowAssignee,\n WorkflowDocumentRef,\n WorkflowField,\n WorkflowDefinition,\n WorkflowErrors,\n WorkflowInputs,\n WorkflowInputValue,\n WorkflowReviewStep,\n WorkflowStep,\n WorkflowStepState,\n WorkflowStepStatus,\n} from './types'\nimport { composeWorkflowPrompt, defaultInputs, validateInputs } from './workflow'\n\n/** A stepped workflow's steps; empty for a single-run one. */\nexport function workflowSteps(workflow: WorkflowDefinition): WorkflowStep[] {\n return workflow.run.kind === 'steps' ? workflow.run.steps : []\n}\n\nexport const isSteppedWorkflow = (workflow: WorkflowDefinition): boolean =>\n workflow.run.kind === 'steps'\n\n/* ------------------------------- graph ------------------------------- */\n\n/** What a step waits for: its `after`, else the step before it in the list (a sequence). */\nexport function stepDependencies(steps: WorkflowStep[], id: string): string[] {\n const i = steps.findIndex((s) => s.id === id)\n if (i < 0) return []\n return steps[i].after ?? (i > 0 ? [steps[i - 1].id] : [])\n}\n\n/** `a` waits for `b`, directly or through other steps. */\nexport function dependsOn(steps: WorkflowStep[], a: string, b: string): boolean {\n const seen = new Set<string>()\n const stack = [...stepDependencies(steps, a)]\n while (stack.length) {\n const id = stack.pop() as string\n if (id === b) return true\n if (seen.has(id)) continue\n seen.add(id)\n stack.push(...stepDependencies(steps, id))\n }\n return false\n}\n\n/**\n * The steps in dependency order, keeping the given order wherever the graph allows (a stable\n * topological sort). Every implicit dependency is written out as `after` first, so reordering\n * never changes what a step waits for. Steps in a cycle keep their place at the end; validation\n * reports them.\n */\nexport function orderSteps(steps: WorkflowStep[]): WorkflowStep[] {\n const explicit = steps.map((s) => ({ ...s, after: stepDependencies(steps, s.id) }))\n const known = new Set(explicit.map((s) => s.id))\n const placed = new Set<string>()\n const out: WorkflowStep[] = []\n let progress = true\n while (out.length < explicit.length && progress) {\n progress = false\n for (const s of explicit) {\n if (placed.has(s.id)) continue\n if (s.after.every((d) => placed.has(d) || !known.has(d))) {\n out.push(s)\n placed.add(s.id)\n progress = true\n break\n }\n }\n }\n return [...out, ...explicit.filter((s) => !placed.has(s.id))]\n}\n\nexport type WorkflowGraphProblem =\n | { code: 'duplicate'; step: string }\n | { code: 'unknown'; step: string; dependency: string }\n | { code: 'cycle'; step: string }\n | { code: 'order'; step: string; dependency: string }\n\n/** What makes a stepped workflow unrunnable. Empty = valid. */\nexport function validateWorkflowGraph(steps: WorkflowStep[]): WorkflowGraphProblem[] {\n const problems: WorkflowGraphProblem[] = []\n const ids = new Set<string>()\n for (const s of steps) {\n if (ids.has(s.id)) problems.push({ code: 'duplicate', step: s.id })\n ids.add(s.id)\n }\n steps.forEach((s, i) => {\n for (const d of stepDependencies(steps, s.id)) {\n if (!ids.has(d)) problems.push({ code: 'unknown', step: s.id, dependency: d })\n else if (d === s.id || dependsOn(steps, d, s.id)) problems.push({ code: 'cycle', step: s.id })\n else if (steps.findIndex((x) => x.id === d) > i)\n problems.push({ code: 'order', step: s.id, dependency: d })\n }\n })\n return problems\n}\n\n/**\n * The steps by depth (the longest chain before each): what the stepper shows side by side.\n * A sequence is one step per level.\n */\nexport function stepLevels(steps: WorkflowStep[]): WorkflowStep[][] {\n const depth = new Map<string, number>()\n for (const s of steps) {\n const deps = stepDependencies(steps, s.id).filter((d) => depth.has(d))\n depth.set(s.id, deps.length ? Math.max(...deps.map((d) => depth.get(d) as number)) + 1 : 0)\n }\n const levels: WorkflowStep[][] = []\n for (const s of steps) (levels[depth.get(s.id) as number] ??= []).push(s)\n return levels.filter(Boolean)\n}\n\n/* ----------------------------- progress ----------------------------- */\n\n/** One entry of a thread's activity log, as far as steps are concerned. */\nexport interface WorkflowActivityEvent {\n kind: string\n detail?: Record<string, unknown> | null\n actor_ext_id?: string | null\n created_at?: string\n}\n\nconst STEP_EVENTS: Record<string, WorkflowStepStatus> = {\n step_started: 'running',\n step_waiting: 'waiting',\n step_done: 'done',\n step_skipped: 'skipped',\n step_failed: 'failed',\n}\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' && v ? v : undefined)\nconst ACTION_TYPES: readonly WorkflowActionType[] = ['sign', 'email_draft', 'tabular_review']\nconst asAction = (v: unknown): WorkflowActionType | undefined =>\n ACTION_TYPES.includes(v as WorkflowActionType) ? (v as WorkflowActionType) : undefined\nconst asRecord = (v: unknown): Record<string, unknown> | undefined =>\n v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : undefined\nconst asStrings = (v: unknown): string[] | undefined =>\n Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : undefined\n\n/**\n * The documents (ids) a `waiting` step waits on to finish processing before its turn starts\n * (`waiting.documents`, from `step_waiting` and then `step_progress` as the set shrinks); none for\n * any other step. Action steps wait on people, not documents.\n */\nexport function waitingDocuments(state: WorkflowStepState | undefined): string[] {\n return state?.status === 'waiting' ? (asStrings(state.waiting?.documents) ?? []) : []\n}\n\n/** The documents a `step_waiting` / `step_progress` event names, if it names any. */\nexport function eventWaitingDocuments(detail: Record<string, unknown> | null | undefined) {\n return asStrings(asRecord(detail?.waiting)?.documents)\n}\n\n/** \"Waiting for 3 documents to finish processing\" (one: \"1 document\"). */\nexport function waitingForDocumentsText(count: number): string {\n return `Waiting for ${count} ${count === 1 ? 'document' : 'documents'} to finish processing`\n}\n\n/** The steps a `step_sent_back` reopens: its `reopened` list, else the one it went `to`. */\nfunction reopenedBy(detail: Record<string, unknown>): string[] {\n const to = str(detail.to)\n return asStrings(detail.reopened) ?? (to ? [to] : [])\n}\n\n/**\n * Each step's state from the thread's activity log (oldest first): its latest step event wins.\n * A send-back reopens the steps it lists as pending (only the one it went `to` is `sentBack`); a\n * `step_ready` records who was told and a `step_progress` what a waiting step now waits on, until\n * the step's next change. Mirrors the server (`workflow_steps.progress`).\n */\nexport function stepStatesFromActivity(\n events: WorkflowActivityEvent[]\n): Record<string, WorkflowStepState> {\n const states: Record<string, WorkflowStepState> = {}\n for (const e of events) {\n const detail = e.detail ?? {}\n const step = str(detail.step)\n if (!step) continue\n if (e.kind === 'step_sent_back') {\n const to = str(detail.to)\n for (const id of reopenedBy(detail))\n states[id] =\n id === to\n ? {\n status: 'pending',\n sentBack: true,\n hasNote: typeof detail.note_encrypted === 'string',\n }\n : { status: 'pending' }\n continue\n }\n if (e.kind === 'step_ready') {\n states[step] = { ...(states[step] ?? { status: 'pending' }), announcedTo: str(detail.to) }\n continue\n }\n if (e.kind === 'step_progress') {\n const before = states[step]\n const waiting = asRecord(detail.waiting)\n if (before?.status === 'waiting' && waiting) states[step] = { ...before, waiting }\n continue\n }\n const status = STEP_EVENTS[e.kind]\n if (!status) continue\n const before = states[step]\n const responseId = str(detail.response_id) ?? before?.responseId ?? null\n const startedAt = status === 'running' ? e.created_at : before?.startedAt\n const action = asAction(detail.action) ?? before?.action\n const documents = asStrings(detail.documents) ?? before?.documents\n const waiting = status === 'waiting' ? asRecord(detail.waiting) : undefined\n const output = status === 'done' ? asRecord(detail.output) : undefined\n const approved = Array.isArray(detail.approved)\n ? (detail.approved.filter(asRecord) as WorkflowStepState['approved'])\n : undefined\n const finished = status === 'done' || status === 'skipped' || status === 'failed'\n const declinedBy = str(detail.declined_by)\n // Skipped while it stood failed: what waits for it goes on without its result, and says so.\n const afterFailure =\n status === 'skipped' && (before?.status === 'failed' || !!before?.skippedAfterFailure)\n states[step] = {\n status,\n responseId,\n error: str(detail.error) ?? (afterFailure ? (before?.error ?? null) : null),\n ...(afterFailure ? { skippedAfterFailure: true } : {}),\n ...(startedAt ? { startedAt } : {}),\n ...(action ? { action } : {}),\n ...(documents?.length ? { documents } : {}),\n ...(waiting ? { waiting } : {}),\n ...(output ? { output } : {}),\n ...(approved ? { approved } : {}),\n ...(finished ? { by: e.actor_ext_id ?? null } : {}),\n ...(finished && e.created_at ? { at: e.created_at } : {}),\n ...(declinedBy ? { declinedBy } : {}),\n }\n }\n return states\n}\n\n/** The fields a person fills in on a step: a form's inputs, a review's fields. */\nexport function stepFields(step: WorkflowStep): WorkflowField[] {\n return step.kind === 'form' ? step.inputs : step.kind === 'review' ? (step.fields ?? []) : []\n}\n\n/** The fields the steps ask for (forms and reviews), in plan order. */\nexport const runFieldsOf = (steps: WorkflowStep[]): WorkflowField[] => steps.flatMap(stepFields)\n\n/** Every field the run asks for: the launch form's, then each form's and review's. */\nexport function runFields(workflow: WorkflowDefinition): WorkflowField[] {\n return [...workflow.inputs, ...workflowSteps(workflow).flatMap(stepFields)]\n}\n\n/** A fresh run's inputs: every field at its default, then the prefills. */\nexport function initialRunInputs(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs = {}\n): WorkflowInputs {\n return { ...defaultInputs({ ...workflow, inputs: runFields(workflow) }), ...inputs }\n}\n\nconst finished = (s: WorkflowStepState | undefined): boolean =>\n s?.status === 'done' || s?.status === 'skipped'\n\n/**\n * Where a step stands: `blocked` until everything it waits for has finished (done or skipped),\n * then `ready`, then its own status (`waiting`: an action step waiting on its people).\n */\nexport type WorkflowStepPhase =\n 'blocked' | 'ready' | 'running' | 'waiting' | 'done' | 'skipped' | 'failed'\n\nexport function stepPhase(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n id: string\n): WorkflowStepPhase {\n const s = states[id]\n if (s && s.status !== 'pending') return s.status\n return stepDependencies(steps, id).every((d) => finished(states[d])) ? 'ready' : 'blocked'\n}\n\nexport const isRunFinished = (\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>\n): boolean => steps.length > 0 && steps.every((s) => finished(states[s.id]))\n\n/** A step a person does (form, upload, review); agent and action steps start by themselves. */\nexport const isPersonStep = (step: WorkflowStep): boolean =>\n step.kind !== 'agent' && step.kind !== 'action'\n\n/** An action step whose waiting phase is a person's: signing, sending the email. */\nexport const isPersonAction = (step: WorkflowStep): step is WorkflowActionStep =>\n step.kind === 'action' && (step.action.type === 'sign' || step.action.type === 'email_draft')\n\n/** A step that can have an assignee and a reminder: a person step, or a signature or email. */\nexport const canAssign = (step: WorkflowStep): boolean => isPersonStep(step) || isPersonAction(step)\n\n/**\n * What the primary button does on the step in view:\n * - `complete`: finish this form, upload or review (approve) and move on;\n * - `move`: view the next step: this one is finished, or the next does not wait for it;\n * - `start`: start this agent or action step: it is ready but no run is under way to start it\n * (the run has no thread yet, or the server could not start it);\n * - `retry`: run this failed step again (what waits for it needs its result; skipping it is the\n * person's explicit choice, never the primary button);\n * - `finish`: show the completion (every step has finished);\n * - `wait`: nothing yet (this step is under way and the next waits for it, or it is blocked).\n */\nexport type WorkflowNextAction = 'complete' | 'move' | 'start' | 'retry' | 'finish' | 'wait'\n\nexport interface NextActionOptions {\n /**\n * No run is under way to start a ready agent or action step: the run's thread does not exist\n * yet (a run whose first open step is an agent step), or the server is not running it.\n */\n needsStart?: boolean\n /** The host can run a failed step again. */\n canRetry?: boolean\n}\n\nexport function nextAction(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n current: string | null,\n { needsStart = false, canRetry = false }: NextActionOptions = {}\n): WorkflowNextAction {\n const i = steps.findIndex((s) => s.id === current)\n const step = steps[i]\n if (!step) return 'wait'\n const phase = stepPhase(steps, states, step.id)\n if (phase === 'blocked') return 'wait'\n const following = steps[i + 1]\n const independentNext = !!following && !dependsOn(steps, following.id, step.id)\n if (phase === 'done' || phase === 'skipped') {\n if (following) return 'move'\n return isRunFinished(steps, states) ? 'finish' : 'wait'\n }\n if (isPersonStep(step)) return 'complete'\n // An email draft is done when its person says it is sent; a signature, when its signers sign.\n if (phase === 'waiting' && step.kind === 'action' && step.action.type === 'email_draft')\n return 'complete'\n // Ready, but nothing will start it unless the person does (no thread yet, or no run under way).\n if (phase === 'ready' && needsStart) return 'start'\n // An agent step on its way (about to start, or running): look ahead if nothing there waits for it.\n if (phase !== 'failed') return independentNext ? 'move' : 'wait'\n // A failed step is never passed over by the primary button: what waits for it needs its result.\n // Retry it; skipping it anyway is a separate, explicit choice.\n const waitedFor = steps.slice(i + 1).some((s) => dependsOn(steps, s.id, step.id))\n if (!waitedFor && following) return 'move'\n return canRetry ? 'retry' : 'wait'\n}\n\n/**\n * The steps `id` waits for (directly or through others) that failed: still failed (so `id` is\n * blocked until they are retried), or skipped after failing (so `id` goes on without their\n * result). In plan order.\n */\nexport function failedUpstream(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n id: string\n): Array<{ step: WorkflowStep; state: WorkflowStepState }> {\n return upstreamSteps(steps, id).flatMap((s) => {\n const state = states[s.id]\n return state && (state.status === 'failed' || state.skippedAfterFailure)\n ? [{ step: s, state }]\n : []\n })\n}\n\n/** A form's or a fielded review's problems (empty = it can move on); other steps have none. */\nexport function validateStep(step: WorkflowStep, inputs: WorkflowInputs): WorkflowErrors {\n const fields = stepFields(step)\n if (!fields.length) return {}\n return validateInputs(\n {\n id: step.id,\n title: step.title,\n description: '',\n inputs: fields,\n run: { kind: 'operation' },\n landing: 'chat',\n },\n inputs\n )\n}\n\n/* --------------------------- people and documents --------------------------- */\n\n/** Every step `id` waits for, directly or through others, in plan order. */\nexport function upstreamSteps(steps: WorkflowStep[], id: string): WorkflowStep[] {\n return steps.filter((s) => s.id !== id && dependsOn(steps, id, s.id))\n}\n\n/**\n * Where a ready step can send the work back to: an earlier step it waits for that has something\n * to redo (done, skipped or failed), nearest first.\n */\nexport function sendBackTargets(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n id: string\n): WorkflowStep[] {\n return upstreamSteps(steps, id)\n .filter((s) => ['done', 'skipped', 'failed'].includes(states[s.id]?.status ?? 'pending'))\n .reverse()\n}\n\n/** Something a step still needs before it can run, for the builder to point out. */\nexport interface WorkflowStepProblem {\n step: string\n missing: 'document' | 'signers' | 'recipients' | 'tags' | 'documents'\n}\n\nconst isBlankRef = (ref: WorkflowDocumentRef): boolean =>\n 'step' in ref ? !ref.step : 'input' in ref ? !ref.input : !ref.id.trim()\n\n/** What the steps still need before they can run: an action's document, signers, … */\nexport function stepConfigProblems(steps: WorkflowStep[]): WorkflowStepProblem[] {\n const out: WorkflowStepProblem[] = []\n for (const s of steps) {\n if (s.kind === 'action') {\n const a = s.action\n if (a.type === 'sign') {\n if (!a.document || isBlankRef(a.document)) out.push({ step: s.id, missing: 'document' })\n if (!a.signers.length) out.push({ step: s.id, missing: 'signers' })\n } else if (a.type === 'email_draft') {\n if (!a.to.some((t) => t.trim())) out.push({ step: s.id, missing: 'recipients' })\n } else {\n if (!a.tags.length) out.push({ step: s.id, missing: 'tags' })\n if (Array.isArray(a.documents) && !a.documents.length)\n out.push({ step: s.id, missing: 'documents' })\n }\n }\n if (s.kind === 'agent' && s.editDocument && isBlankRef(s.editDocument))\n out.push({ step: s.id, missing: 'document' })\n }\n return out\n}\n\n/** A document version id (`doc-…@v3`) split into the document and its version. */\nexport function splitDocRef(ref: string): { id: string; version?: number } {\n const m = /^(doc-[A-Za-z0-9]+)(?:@v(\\d+))?$/.exec(ref)\n return m ? { id: m[1], ...(m[2] ? { version: Number(m[2]) } : {}) } : { id: ref }\n}\n\n/** How an assignee that names no one directly is described. */\nexport interface AssigneeWording {\n runOwner: string\n projectLead: string\n /** `{field}`: the person field's label. */\n input: string\n}\n\nexport const DEFAULT_ASSIGNEE_WORDING: AssigneeWording = {\n runOwner: 'whoever started the run',\n projectLead: 'the project lead',\n input: 'the person in “{field}”',\n}\n\n/**\n * Who a step is for, in words: the person it was announced to, the member it names, the person a\n * form field holds (each through `nameOf`), else its role. Undefined when it names no one.\n */\nexport function assigneeName(\n assignee: WorkflowAssignee | undefined,\n options: {\n nameOf?: (id: string) => string | undefined\n inputs?: WorkflowInputs\n fields?: WorkflowField[]\n /** Who the server told (the assignee resolved): wins over a role. */\n announcedTo?: string | null\n wording?: Partial<AssigneeWording>\n } = {}\n): string | undefined {\n const w = { ...DEFAULT_ASSIGNEE_WORDING, ...options.wording }\n const name = (id: string) => options.nameOf?.(id) ?? id\n const told = options.announcedTo ? options.nameOf?.(options.announcedTo) : undefined\n if (told) return told\n if (!assignee) return undefined\n if ('user' in assignee) return name(assignee.user)\n if ('input' in assignee) {\n const value = options.inputs?.[assignee.input]\n if (typeof value === 'string' && value) return name(value)\n const label = options.fields?.find((f) => f.name === assignee.input)?.label ?? assignee.input\n return w.input.replace('{field}', label)\n }\n if ('runOwner' in assignee) return w.runOwner\n return w.projectLead\n}\n\n/* ----------------------------- composing ----------------------------- */\n\nconst asText = (value: WorkflowInputValue | undefined): string =>\n typeof value === 'string' ? value.trim() : typeof value === 'number' ? String(value) : ''\n\n/**\n * Fill a step's `with` templates from the run's inputs: `{{a}}`, `{{a || b}}` (first non-blank).\n * A template that is exactly one bare reference passes the value through untouched.\n */\nexport function fillStepInputs(\n templates: Record<string, string> | undefined,\n inputs: WorkflowInputs\n): WorkflowInputs {\n const out: WorkflowInputs = {}\n for (const [name, template] of Object.entries(templates ?? {})) {\n const bare = /^\\{\\{\\s*([a-z][a-z0-9_]*)\\s*\\}\\}$/i.exec(template)\n if (bare) {\n out[name] = inputs[bare[1]] ?? ''\n continue\n }\n out[name] = fillRunText(template, inputs)\n }\n return out\n}\n\n/** A template over the run's inputs, as text (`{{a}}`, `{{a || b}}`). */\nexport function fillRunText(template: string, inputs: WorkflowInputs): string {\n return template\n .replace(/\\{\\{([^}]*)\\}\\}/g, (_, expr: string) => {\n for (const ref of expr.split('||')) {\n const text = asText(inputs[ref.trim()])\n if (text) return text\n }\n return ''\n })\n .trim()\n}\n\n/** The run thread's title: the workflow's `threadTitle` template, else its title. */\nexport function runThreadTitle(workflow: WorkflowDefinition, inputs: WorkflowInputs): string {\n const template = workflow.run.kind === 'steps' ? workflow.run.threadTitle : undefined\n return (template && fillRunText(template, inputs)) || workflow.title\n}\n\n/** What a review asks for: its instructions filled from the run, else its title. */\nexport function reviewInstructions(step: WorkflowReviewStep, inputs: WorkflowInputs): string {\n return (step.instructions && fillRunText(step.instructions, inputs)) || step.title\n}\n\nexport interface StepComposeOptions {\n /** Looks up the workflow a step names (`step.workflow`). */\n resolveWorkflow?: (id: string) => WorkflowDefinition | undefined\n /**\n * The host's wording for `operation` runs: the named workflow's id (or the step's own id when it\n * runs inline), its filled inputs, and the whole run's inputs (e.g. to ground it in the record).\n */\n compose?: (id: string, inputs: WorkflowInputs, runInputs: WorkflowInputs) => string | undefined\n}\n\n/** The prompt an agent step of `workflow` sends; '' when nothing could compose it (no binding). */\nexport function composeStepPrompt(\n workflow: WorkflowDefinition,\n step: WorkflowAgentStep,\n runInputs: WorkflowInputs,\n { resolveWorkflow, compose }: StepComposeOptions = {}\n): string {\n if (step.workflow) {\n const target = resolveWorkflow?.(step.workflow)\n if (!target) return ''\n const inputs = { ...defaultInputs(target), ...fillStepInputs(step.with, runInputs) }\n return target.run.kind === 'prompt'\n ? composeWorkflowPrompt(target, inputs)\n : (compose?.(target.id, inputs, runInputs) ?? '')\n }\n if (step.run?.kind === 'prompt') {\n return composeWorkflowPrompt(\n { ...workflow, inputs: runFields(workflow), run: step.run },\n runInputs\n )\n }\n return compose?.(step.id, runInputs, runInputs) ?? ''\n}\n","/**\n * The documents a step is about — what most steps of real work hand on, review and approve is a\n * document, not a message in the chat. A drafting step's are the versions it produced; an approval's\n * are the drafts it approves (the versions of the steps it waits for while it is open, exactly the\n * versions it recorded once approved). `StepDocumentCards` shows them as cards to open, and\n * `StepRecord` what a finished step recorded: who did it, when, and its answers.\n */\n\nimport { FileText } from 'lucide-react'\nimport { Button, cn } from '@arbidocs/react/ui'\nimport { splitDocRef, stepDependencies, stepFields } from './run'\nimport type { WorkflowField, WorkflowStep, WorkflowStepState } from './types'\n\n/** The document versions (`doc-…@v<n>`) a step is about, newest last, each once. */\nexport function stepDocuments(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n id: string\n): string[] {\n const step = steps.find((s) => s.id === id)\n const state = states[id]\n if (!step) return []\n const own = [\n ...(state?.documents ?? []),\n ...((state?.output?.doc_ext_ids as string[] | undefined) ?? []),\n ]\n const refs =\n step.kind !== 'review'\n ? own\n : state?.status === 'done' && state.approved?.length\n ? state.approved.flatMap((e) => e.documents ?? [])\n : stepDependencies(steps, id).flatMap((dep) => states[dep]?.documents ?? [])\n return [...new Set(refs)]\n}\n\nexport interface StepDocumentLabels {\n open: string\n /** An approval's documents, before it is done. */\n toApprove: string\n approved: string\n produced: string\n /** `{version}` is replaced. */\n version: string\n}\n\nexport const DEFAULT_STEP_DOCUMENT_LABELS: StepDocumentLabels = {\n open: 'Open',\n toApprove: 'To approve',\n approved: 'Approved',\n produced: 'Drafted in this step',\n version: 'v{version}',\n}\n\n/** A step's documents as cards: the name, the version, and Open (the host's viewer or editor). */\nexport function StepDocumentCards({\n refs,\n heading,\n nameOfDoc,\n onOpen,\n labels,\n testId,\n}: {\n refs: string[]\n heading: string\n nameOfDoc?: (id: string) => string | undefined\n onOpen?: (ref: string) => void\n labels?: Partial<StepDocumentLabels>\n testId: string\n}) {\n const l = { ...DEFAULT_STEP_DOCUMENT_LABELS, ...labels }\n if (!refs.length) return null\n return (\n <div className=\"space-y-1\" data-testid={testId}>\n <p className=\"px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground\">\n {heading}\n </p>\n {refs.map((ref) => {\n const { id, version } = splitDocRef(ref)\n return (\n <div\n key={ref}\n className=\"flex items-center gap-2 rounded-md border border-border bg-card px-2 py-1.5\"\n data-testid={`${testId}-${id}`}\n >\n <span className=\"wf-badge flex size-7 shrink-0 items-center justify-center rounded-md\">\n <FileText className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span\n className=\"line-clamp-2 block break-words text-sm font-medium leading-snug\"\n title={nameOfDoc?.(id) ?? id}\n >\n {nameOfDoc?.(id) ?? id}\n </span>\n {version && (\n <span className=\"block text-[11px] text-muted-foreground\">\n {l.version.replace('{version}', String(version))}\n </span>\n )}\n </span>\n {onOpen && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"h-7 shrink-0 px-2 text-xs\"\n onClick={() => onOpen(ref)}\n data-testid={`${testId}-${id}-open`}\n >\n {l.open}\n </Button>\n )}\n </div>\n )\n })}\n </div>\n )\n}\n\nexport interface StepRecordLabels {\n /** `{name}` is replaced. */\n doneBy: string\n approvedBy: string\n someone: string\n}\n\nexport const DEFAULT_STEP_RECORD_LABELS: StepRecordLabels = {\n doneBy: 'Done by {name}',\n approvedBy: 'Approved by {name}',\n someone: 'someone',\n}\n\n/** A recorded time, in the reader's locale. */\nexport const formatDate = (iso: string | undefined): string => {\n const t = iso ? Date.parse(iso) : NaN\n return Number.isNaN(t)\n ? ''\n : new Date(t).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })\n}\n\n/** A recorded answer as text: a person's name, an option's label, a tick… */\nexport const shownValue = (\n v: unknown,\n field: WorkflowField,\n nameOf?: (id: string) => string | undefined\n) => {\n if (v === undefined || v === null || v === '') return '—'\n if (typeof v === 'boolean') return v ? '✓' : '✗'\n if (field.type === 'person' && typeof v === 'string') return nameOf?.(v) ?? v\n if (field.type === 'select') return field.options?.find((o) => o.value === v)?.label ?? String(v)\n return typeof v === 'object' ? JSON.stringify(v) : String(v)\n}\n\n/** What a finished step recorded: who did it (approved it) and when, and the answers it took. */\nexport function StepRecord({\n step,\n state,\n inputs,\n nameOf,\n labels,\n className,\n testId,\n}: {\n step: WorkflowStep\n state: WorkflowStepState | undefined\n inputs: Record<string, unknown>\n nameOf?: (id: string) => string | undefined\n labels?: Partial<StepRecordLabels>\n className?: string\n testId: string\n}) {\n const l = { ...DEFAULT_STEP_RECORD_LABELS, ...labels }\n if (state?.status !== 'done') return null\n const who = state.by ? (nameOf?.(state.by) ?? l.someone) : undefined\n const fields = stepFields(step)\n if (!who && !fields.length) return null\n return (\n <div className={cn('space-y-1 px-1', className)} data-testid={testId}>\n {who && (\n <p className=\"text-xs\">\n {(step.kind === 'review' ? l.approvedBy : l.doneBy).replace('{name}', who)}\n {state.at && <span className=\"text-muted-foreground\"> · {formatDate(state.at)}</span>}\n </p>\n )}\n {fields.length > 0 && (\n <dl className=\"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs\">\n {fields.map((f) => (\n <div key={f.name} className=\"contents\">\n <dt className=\"text-muted-foreground\">{f.label}</dt>\n <dd className=\"min-w-0 break-words\" data-testid={`${testId}-field-${f.name}`}>\n {shownValue(inputs[f.name], f, nameOf)}\n </dd>\n </div>\n ))}\n </dl>\n )}\n </div>\n )\n}\n\n/**\n * A step's document, one click from its chip: a button joined to the chip's right that opens the\n * latest version — the drafted letter, or the draft an approval is for. Icon-only where room is\n * short (the thread's bar), with the document's name in the chat.\n */\nexport function StepDocumentButton({\n kind,\n name,\n onOpen,\n showName = false,\n label = 'Open {name}',\n testId,\n}: {\n kind: string\n name: string\n onOpen: () => void\n showName?: boolean\n /** Its accessible name; `{name}` is replaced. */\n label?: string\n testId?: string\n}) {\n const text = label.replace('{name}', name)\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n title={text}\n aria-label={text}\n className={cn(\n `wf-kind-${kind}`,\n showName ? 'min-w-0 shrink' : 'shrink-0',\n '-ml-px flex h-8 items-center gap-1.5 rounded-r-lg border border-border bg-card px-2 text-xs font-medium shadow-sm hover:border-[hsl(var(--wf-accent)/0.55)] hover:text-[hsl(var(--wf-accent))]'\n )}\n data-testid={testId}\n >\n <FileText className=\"wf-kind-text size-3.5 shrink-0\" aria-hidden />\n {showName && <span className=\"max-w-[14rem] truncate\">{name}</span>}\n </button>\n )\n}\n","/**\n * The kinds of step, as every view of a workflow shows them: the builder's canvas, the runner's\n * stepper, a thread's top bar and the threads list. Each kind has one icon here and one colour in\n * `blocks.css` (`.wf-kind-<kind>`, on the `--wf-*` variables), so a step looks the same wherever\n * it appears.\n */\n\nimport { Bot, ClipboardCheck, FileInput, Mail, PenLine, Table2, Upload } from 'lucide-react'\nimport type { WorkflowStep } from './types'\n\n/** Each kind of step, with each platform action (an `action` step) as a kind of its own. */\nexport type WorkflowStepKind =\n 'form' | 'upload' | 'agent' | 'review' | 'sign' | 'email_draft' | 'tabular_review'\n\n/** Every kind, in the order the add menus list them. */\nexport const WORKFLOW_STEP_KINDS: readonly WorkflowStepKind[] = [\n 'form',\n 'upload',\n 'agent',\n 'review',\n 'sign',\n 'email_draft',\n 'tabular_review',\n]\n\n/** A step's kind: an action step is its action's type. */\nexport const stepKindOf = (step: WorkflowStep): WorkflowStepKind =>\n step.kind === 'action' ? step.action.type : step.kind\n\nexport const STEP_KIND_ICONS = {\n form: FileInput,\n upload: Upload,\n agent: Bot,\n review: ClipboardCheck,\n sign: PenLine,\n email_draft: Mail,\n tabular_review: Table2,\n} as const\n\n/** Each kind's name, as the canvas cards and the thread bar label a step. */\nexport const DEFAULT_STEP_KIND_LABELS: Record<WorkflowStepKind, string> = {\n form: 'Form',\n upload: 'Upload',\n agent: 'AI step',\n review: 'Approval',\n sign: 'Sign',\n email_draft: 'Email draft',\n tabular_review: 'Tabular review',\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useState,\n type RefObject,\n type SyntheticEvent,\n} from 'react'\nimport { useListKeyNav, type UseListKeyNav } from '../lib/useListKeyNav'\nimport {\n filterMentionCandidates,\n findMentionQuery,\n insertMention,\n type MentionCandidate,\n} from './mentions'\n\nexport interface UseMentionAutocompleteOptions {\n /** The draft. */\n value: string\n /** Writes the draft (the same setter the composer uses). */\n onValueChange: (next: string) => void\n /** Who can be mentioned: workspace members and the assistant. */\n candidates: ReadonlyArray<MentionCandidate>\n /** The composer textarea; read for the caret and refocused after a pick. */\n textareaRef: RefObject<HTMLTextAreaElement | null>\n}\n\nexport interface UseMentionAutocomplete {\n isOpen: boolean\n /** Filtered candidates for the `@query` at the caret. */\n items: MentionCandidate[]\n /** Keyboard navigation; call `nav.handleKeyDown` first in the textarea's `onKeyDown`. */\n nav: UseListKeyNav\n /** Insert a candidate in place of the `@query`. */\n pick: (candidate: MentionCandidate) => void\n /** Wrap the composer's `onValueChange` with this so the caret is tracked as the user types. */\n onValueChange: (next: string) => void\n /** Spread onto the textarea (via `textareaProps`): tracks caret moves (clicks, arrows). */\n textareaProps: { onSelect: (event: SyntheticEvent<HTMLTextAreaElement>) => void }\n}\n\n/**\n * Headless `@mention` autocomplete for a textarea: finds the `@query` at the caret, filters the\n * candidates, and on pick replaces the query with `@<label> `. Pair with {@link MentionMenu}.\n */\nexport function useMentionAutocomplete({\n value,\n onValueChange,\n candidates,\n textareaRef,\n}: UseMentionAutocompleteOptions): UseMentionAutocomplete {\n const [caret, setCaret] = useState<number | null>(null)\n // Escape dismisses the menu for the `@` it was opened at, until the user starts another one.\n const [dismissedAt, setDismissedAt] = useState<number | null>(null)\n\n // The draft can change from outside (cleared on send, restored on error): once the dismissed\n // `@` is gone, re-arm so the next `@` there opens the menu again.\n useEffect(() => {\n if (dismissedAt !== null && value[dismissedAt] !== '@') setDismissedAt(null)\n }, [value, dismissedAt])\n\n const match = useMemo(() => {\n if (caret === null) return null\n const query = findMentionQuery(value, Math.min(caret, value.length))\n // A completed recipient followed by a space is no longer an autocomplete query.\n return query && candidates.some((candidate) => query.query === `${candidate.label} `)\n ? null\n : query\n }, [value, caret, candidates])\n const items = useMemo(\n () => (match ? filterMentionCandidates(candidates, match.query) : []),\n [match, candidates]\n )\n const isOpen = !!match && items.length > 0 && dismissedAt !== match.start\n\n const readCaret = useCallback(() => {\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : null)\n }, [textareaRef])\n\n const pick = useCallback(\n (candidate: MentionCandidate) => {\n if (!match || caret === null) return\n const next = insertMention(value, match.start, Math.min(caret, value.length), candidate.label)\n onValueChange(next.text)\n setCaret(next.caret)\n // The inserted `@<label> ` is complete: keep the menu shut for this `@`.\n setDismissedAt(match.start)\n requestAnimationFrame(() => {\n const ta = textareaRef.current\n if (!ta) return\n ta.focus()\n ta.setSelectionRange(next.caret, next.caret)\n })\n },\n [match, caret, value, onValueChange, textareaRef]\n )\n\n const nav = useListKeyNav({\n open: isOpen,\n items,\n onPick: pick,\n onDismiss: () => setDismissedAt(match?.start ?? null),\n resetKey: match?.query,\n })\n\n const handleValueChange = useCallback(\n (next: string) => {\n onValueChange(next)\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : next.length)\n // Deleting text (or the `@` itself) re-arms the menu: the user is editing that mention.\n if (dismissedAt !== null && (next.length < value.length || next[dismissedAt] !== '@')) {\n setDismissedAt(null)\n }\n },\n [onValueChange, textareaRef, dismissedAt, value]\n )\n\n return {\n isOpen,\n items,\n nav,\n pick,\n onValueChange: handleValueChange,\n textareaProps: { onSelect: readCaret },\n }\n}\n","/**\n * A step on a bar — the runner's stepper, a thread's top bar, the threads list — drawn as the\n * builder's canvas card in miniature (`.wf-chip` in `blocks.css`): its kind's accent and icon, its\n * phase in the badge (a filled check once done, a spinner while running, an hourglass while it\n * waits), and, for the step in view, the kind's name and what it waits on above its title, as a\n * canvas card heads itself. A button, so it can open a popover (`PopoverTrigger asChild`).\n */\n\nimport { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react'\nimport { AlertTriangle, Check, Hourglass, Loader2, MinusCircle } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport type { WorkflowStepPhase } from './run'\n\n/**\n * What the badge shows: the kind's icon (filled in once done, as the canvas marks a done card), or\n * the phase while the step moves or when it went wrong.\n */\nexport function StepBadgeMark({ phase, icon }: { phase: WorkflowStepPhase; icon?: ReactNode }) {\n if (phase === 'done') return icon ? <>{icon}</> : <Check strokeWidth={3} />\n if (phase === 'running') return <Loader2 className=\"animate-spin\" />\n if (phase === 'waiting') return <Hourglass />\n if (phase === 'failed') return <AlertTriangle />\n if (phase === 'skipped') return <MinusCircle />\n return icon ? <>{icon}</> : <span className=\"size-1.5 rounded-full bg-current opacity-60\" />\n}\n\nexport interface StepChipProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The kind (`form`, `agent`…, `start`, `adhoc`): its accent. */\n kind: string\n phase: WorkflowStepPhase\n /** The kind's icon (or the host's icon for the step). */\n icon?: ReactNode\n label: string\n /** The step in view: ringed, and headed with `heading` above its label. */\n current?: boolean\n /** The current chip's top line: the kind's name, and what the step waits on. */\n heading?: ReactNode\n /** The label's classes (how it gives up room on a crowded bar). */\n labelClassName?: string\n labelTestId?: string\n /** After the label: who acted in the step, a sent-back mark… */\n children?: ReactNode\n /** A static chip (the completion marker): not a button. */\n inert?: boolean\n}\n\nexport const StepChip = forwardRef<HTMLButtonElement, StepChipProps>(function StepChip(\n {\n kind,\n phase,\n icon,\n label,\n current,\n heading,\n labelClassName,\n labelTestId,\n children,\n inert,\n className,\n ...rest\n },\n ref\n) {\n const body = (\n <>\n <span className=\"wf-badge\" aria-hidden>\n <StepBadgeMark phase={phase} icon={icon} />\n </span>\n {current && heading ? (\n <span className=\"flex min-w-0 flex-col text-left\">\n <span className=\"wf-kind-text truncate text-[9px] font-semibold uppercase leading-3 tracking-wider\">\n {heading}\n </span>\n <span\n className={cn('wf-chip-label font-semibold', labelClassName)}\n data-testid={labelTestId}\n >\n {label}\n </span>\n </span>\n ) : (\n <span className={cn('wf-chip-label', labelClassName)} data-testid={labelTestId}>\n {label}\n </span>\n )}\n {children}\n </>\n )\n const classes = cn('wf-chip', `wf-kind-${kind}`, className)\n if (inert)\n return (\n <span\n className={classes}\n data-phase={phase}\n aria-current={current ? 'step' : undefined}\n {...(rest as Record<string, unknown>)}\n >\n {body}\n </span>\n )\n return (\n <button\n ref={ref}\n type=\"button\"\n className={classes}\n data-phase={phase}\n aria-current={current ? 'step' : undefined}\n {...rest}\n >\n {body}\n </button>\n )\n})\n","import { useLayoutEffect, useState, type RefObject } from 'react'\nimport { observeResize } from './observe-resize'\n\nexport interface ElementSize {\n width: number\n height: number\n}\n\n/**\n * The border-box size of an element, kept current with a ResizeObserver. It is measured before\n * the first paint (layout effect), so a layout that depends on it never flashes the wrong mode.\n * Window resize is listened to as well (a no-ResizeObserver engine, jsdom, still re-measures).\n */\nexport function useElementSize<T extends HTMLElement>(ref: RefObject<T | null>): ElementSize {\n const [size, setSize] = useState<ElementSize>({ width: 0, height: 0 })\n useLayoutEffect(() => {\n const el = ref.current\n if (!el) return\n const measure = () => {\n const rect = el.getBoundingClientRect()\n setSize((prev) =>\n prev.width === rect.width && prev.height === rect.height\n ? prev\n : { width: rect.width, height: rect.height }\n )\n }\n measure()\n window.addEventListener('resize', measure)\n const stopObserving = observeResize(el, measure)\n return () => {\n window.removeEventListener('resize', measure)\n stopObserving()\n }\n }, [ref])\n return size\n}\n\n/** The root font size in px (what `rem` means), 16 when it cannot be read. */\nexport function rootFontSizePx(): number {\n if (typeof document === 'undefined') return 16\n const size = parseFloat(getComputedStyle(document.documentElement).fontSize)\n return Number.isFinite(size) && size > 0 ? size : 16\n}\n"]}
|