@rizom/brain 0.2.0-alpha.870 → 0.2.0-alpha.872

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.
Files changed (54) hide show
  1. package/dist/brain.js +4 -4
  2. package/dist/chunks/{app-azfgxymb.js → app-99rkqqg5.js} +2 -2
  3. package/dist/chunks/{index-6hk82m34.js → index-722vsjfh.js} +2 -2
  4. package/dist/chunks/{index-t5wazpn2.js → index-sz6zwm79.js} +3 -3
  5. package/dist/chunks/{index-t5wazpn2.js.map → index-sz6zwm79.js.map} +1 -1
  6. package/dist/chunks/{package-pe2bpk2z.js → package-bv30wgfz.js} +3 -3
  7. package/dist/chunks/{package-pe2bpk2z.js.map → package-bv30wgfz.js.map} +1 -1
  8. package/dist/model.js +4 -4
  9. package/dist/model.js.map +1 -1
  10. package/dist/testing.js +1 -1
  11. package/dist/ui/{studio-app-dx99m4vs.js → studio-app-1edp4r57.js} +49 -49
  12. package/dist/ui/{studio-app-dx99m4vs.js.map → studio-app-1edp4r57.js.map} +4 -4
  13. package/dist/ui/studio-asset-manifest.json +37 -37
  14. package/dist/ui/studio-chunks/account-view-j9wkxck6.js +3 -0
  15. package/dist/ui/studio-chunks/{account-view-pf71e4d1.js.map → account-view-j9wkxck6.js.map} +2 -2
  16. package/dist/ui/studio-chunks/{chat-db7d7t9x.js → chat-cph4j688.js} +2 -2
  17. package/dist/ui/studio-chunks/{chat-db7d7t9x.js.map → chat-cph4j688.js.map} +1 -1
  18. package/dist/ui/studio-chunks/{highlighted-body-OFNGDK62-4dbebe14.js → highlighted-body-OFNGDK62-64y2m0dm.js} +2 -2
  19. package/dist/ui/studio-chunks/{highlighted-body-OFNGDK62-4dbebe14.js.map → highlighted-body-OFNGDK62-64y2m0dm.js.map} +1 -1
  20. package/dist/ui/studio-chunks/main-6qe1jp8h.js +6 -0
  21. package/dist/ui/studio-chunks/{main-eh2baz0t.js.map → main-6qe1jp8h.js.map} +4 -4
  22. package/dist/ui/studio-chunks/{main-4qxa4jpx.js → main-7fyr0wv3.js} +3 -3
  23. package/dist/ui/studio-chunks/{main-4qxa4jpx.js.map → main-7fyr0wv3.js.map} +1 -1
  24. package/dist/ui/studio-chunks/{main-fdxmnsj6.js → main-cjvg98dr.js} +2 -2
  25. package/dist/ui/studio-chunks/{main-fdxmnsj6.js.map → main-cjvg98dr.js.map} +1 -1
  26. package/dist/ui/studio-chunks/{main-e098kfma.js → main-d5szcfbq.js} +3 -3
  27. package/dist/ui/studio-chunks/{main-e098kfma.js.map → main-d5szcfbq.js.map} +1 -1
  28. package/dist/ui/studio-chunks/{main-s8r820px.js → main-f886snck.js} +2 -2
  29. package/dist/ui/studio-chunks/{main-s8r820px.js.map → main-f886snck.js.map} +1 -1
  30. package/dist/ui/studio-chunks/{main-j4wezmkn.js → main-fqzf25fv.js} +3 -3
  31. package/dist/ui/studio-chunks/{main-j4wezmkn.js.map → main-fqzf25fv.js.map} +1 -1
  32. package/dist/ui/studio-chunks/{main-8zx47tjg.js → main-ggcgvxym.js} +3 -3
  33. package/dist/ui/studio-chunks/{main-8zx47tjg.js.map → main-ggcgvxym.js.map} +1 -1
  34. package/dist/ui/studio-chunks/{main-g15rdsa4.js → main-pqx64crr.js} +3 -3
  35. package/dist/ui/studio-chunks/{main-g15rdsa4.js.map → main-pqx64crr.js.map} +1 -1
  36. package/dist/ui/studio-chunks/{main-ecwfbj4t.js → main-rt6yh800.js} +3 -3
  37. package/dist/ui/studio-chunks/{main-ecwfbj4t.js.map → main-rt6yh800.js.map} +1 -1
  38. package/dist/ui/studio-chunks/{main-eakaz9w9.js → main-t14ef5wt.js} +5 -5
  39. package/dist/ui/studio-chunks/{main-eakaz9w9.js.map → main-t14ef5wt.js.map} +1 -1
  40. package/dist/ui/studio-chunks/{main-2vaawyz9.js → main-y9skwxac.js} +3 -3
  41. package/dist/ui/studio-chunks/{main-2vaawyz9.js.map → main-y9skwxac.js.map} +1 -1
  42. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-nb261ktq.js +3 -0
  43. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-nb261ktq.js.map +9 -0
  44. package/dist/ui/studio-chunks/{studio-ask-panel-cgmkp80w.js → studio-ask-panel-njthpfwq.js} +2 -2
  45. package/dist/ui/studio-chunks/{studio-ask-panel-cgmkp80w.js.map → studio-ask-panel-njthpfwq.js.map} +1 -1
  46. package/dist/ui/studio-chunks/{studio-chat-workspace-c3xe9bre.js → studio-chat-workspace-jw3pye8a.js} +2 -2
  47. package/dist/ui/studio-chunks/{studio-chat-workspace-c3xe9bre.js.map → studio-chat-workspace-jw3pye8a.js.map} +1 -1
  48. package/package.json +1 -1
  49. package/dist/ui/studio-chunks/account-view-pf71e4d1.js +0 -3
  50. package/dist/ui/studio-chunks/main-eh2baz0t.js +0 -6
  51. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-taaxh7ab.js +0 -3
  52. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-taaxh7ab.js.map +0 -9
  53. /package/dist/chunks/{app-azfgxymb.js.map → app-99rkqqg5.js.map} +0 -0
  54. /package/dist/chunks/{index-6hk82m34.js.map → index-722vsjfh.js.map} +0 -0
@@ -5,6 +5,6 @@
5
5
  "/** @jsxImportSource react */\nimport * as stylex from \"@stylexjs/stylex\";\nimport { Button, NativeSelect, useAppFetch, useFollowTail } from \"@brains/app-ui-react\";\nimport { createChatClient, type ChatHistoryMessage, type ChatUploadResponse } from \"@brains/contracts/chat\";\nimport { STUDIO_ENTRY_CONTEXT_SOURCE, studioEntryContextItemId } from \"@brains/contracts/studio-entry-context\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useMemo, useRef, useState, type FormEvent, type ReactElement } from \"react\";\nimport type { AgentTarget } from \"./api\";\nimport { ASK_STARTERS, askPlaceholder, asksRewrite, peerPassage, type AskSelection } from \"./ask-panel-model\";\nimport type { Proposal, ProposalField } from \"./chat-proposals\";\nimport { askStyles as s } from \"./studio-ask-panel.styles\";\nimport { Composer } from \"./studio-chat-composer\";\nimport type { StudioChatDraftStore } from \"./studio-chat-drafts\";\nimport { chatClass, chatLayout } from \"./studio-chat-layout.styles\";\nimport { ChatTurn, type ChatTurnProposals } from \"./studio-chat-thread\";\nimport { useStudioApi } from \"./studio-api-context\";\nimport { errorMessage } from \"./ui-utils\";\nimport { useChatDraft } from \"./use-chat-draft\";\nimport { useChatStream } from \"./use-chat-stream\";\nimport { useChatThread } from \"./use-chat-thread\";\n\n/** The upload a selected passage goes to this brain as. */\nconst SELECTION_FILENAME = \"selection.md\";\nconst isSelectionUpload = (upload: ChatUploadResponse): boolean => upload.filename === SELECTION_FILENAME;\n\n/** A question put to a connected brain, which answers outside Chat. */\ninterface PeerTurn {\n id: string;\n at: string;\n question: string;\n agent: AgentTarget;\n rewrite: boolean;\n selection: AskSelection | null;\n answer?: string;\n error?: string;\n}\nexport interface StudioAskPanelProps {\n chatApiPath: string;\n draftStore: StudioChatDraftStore;\n entityType: string;\n entityId: string;\n title: string;\n typeLabel: string;\n /** The saved body, which this brain and a connected one both read. */\n savedBody: string;\n /** The draft differs from the saved entry, which is what Ask reads. */\n unsaved: boolean;\n /** The passage selected in the body, which the panel is then about. */\n selection: AskSelection | null;\n onClearSelection: () => void;\n /** The fields an answer may propose text for. */\n fields: readonly ProposalField[];\n /** Brains this one is connected to, which can be asked directly. */\n agents: readonly AgentTarget[];\n /**\n * Put a proposal in the open draft; the selection is the one it was asked\n * about. Answers why it could not, or null when it did.\n */\n onApply: (proposal: Proposal, selection: AskSelection | null) => string | null;\n onClose: () => void;\n}\n\n/**\n * Ask, docked beside the editor. Asking this brain is the entry's own Chat\n * conversation, which full-page Chat shows too; a connected brain is asked\n * directly, as the rewrite bar did. A proposal goes into the draft, never\n * straight into the stored entry.\n */\nexport function StudioAskPanel(props: StudioAskPanelProps): ReactElement {\n const queryClient = useQueryClient();\n const appFetch = useAppFetch();\n const api = useStudioApi();\n const chatClient = useMemo(() => createChatClient({\n apiPath: props.chatApiPath,\n fetch: appFetch\n }), [props.chatApiPath, appFetch]);\n const [sessionId, setSessionId] = useState<string | null>(null);\n const [opening, setOpening] = useState<\"opening\" | \"open\" | \"failed\">(\"opening\");\n const [attempt, setAttempt] = useState(0);\n const [whoId, setWhoId] = useState<string>(\"\");\n const [peerTurns, setPeerTurns] = useState<PeerTurn[]>([]);\n const [notice, setNotice] = useState<string | null>(null);\n // The selection being uploaded; sending waits until it is attached.\n const [uploadingText, setUploadingText] = useState<string | null>(null);\n const uploading = uploadingText !== null;\n const mountedRef = useRef(false);\n const adoptedSessionRef = useRef<string | null>(null);\n const attachedRef = useRef<{\n text: string;\n upload: ChatUploadResponse;\n }>(null);\n const askedSelectionRef = useRef<AskSelection | null>(null);\n const who = props.agents.find(agent => agent.id === whoId) ?? null;\n\n // The conversation about this entry: one per person and entry, kept.\n useEffect(() => {\n let current = true;\n setOpening(\"opening\");\n chatClient.openContextSession({\n version: 1,\n sourceId: STUDIO_ENTRY_CONTEXT_SOURCE,\n itemId: studioEntryContextItemId(props.entityType, props.entityId),\n titleSeed: (props.title.trim() || props.typeLabel).slice(0, 160)\n }).then(({\n conversationId\n }) => {\n if (!current) return;\n setSessionId(conversationId);\n setOpening(\"open\");\n }).catch(() => {\n if (current) setOpening(\"failed\");\n });\n return (): void => {\n current = false;\n };\n // The title seeds a new conversation only; renaming must not reopen it.\n }, [chatClient, props.entityType, props.entityId, attempt]);\n const {\n draftStore,\n draftKey,\n currentDraftKey,\n draft,\n uploads,\n setDraft,\n setUploads\n } = useChatDraft({\n draftStore: props.draftStore,\n apiPath: props.chatApiPath,\n sessionId\n });\n const {\n pendingMessages,\n stream,\n sending,\n error,\n submitPrompt,\n respondToApproval,\n runSuggestedAction,\n hasActiveStream,\n stopActiveStream,\n abortActiveStream\n } = useChatStream({\n chatClient,\n queryClient,\n sessionId,\n apiPath: props.chatApiPath,\n draftStore,\n draftKey,\n currentDraftKey,\n mountedRef,\n adoptedSessionRef,\n uploads,\n uploading,\n uploadAttemptCount: 0,\n navigateToSession: conversationId => {\n if (conversationId) setSessionId(conversationId);\n }\n });\n const {\n visibleMessages,\n historyFailed,\n retryHistory\n } = useChatThread({\n chatClient,\n sessionId,\n sending,\n pendingMessages,\n stream\n });\n useEffect(() => {\n mountedRef.current = true;\n return (): void => {\n mountedRef.current = false;\n abortActiveStream();\n };\n }, [abortActiveStream]);\n\n // The selection goes to this brain as a file beside the question, and stays\n // attached for as long as the panel is about it.\n const selectionText = props.selection?.text ?? null;\n const selectionAttached = uploads.some(isSelectionUpload);\n const latestSelectionRef = useRef(selectionText);\n latestSelectionRef.current = selectionText;\n useEffect(() => {\n // Uploads belong to the conversation's draft, so wait until it is open.\n if (!sessionId) return;\n if (!selectionText) {\n if (selectionAttached) setUploads(current => current.filter(u => !isSelectionUpload(u)));\n return;\n }\n const attached = attachedRef.current;\n if (attached?.text === selectionText) {\n if (!selectionAttached) setUploads(current => [...current, attached.upload]);\n return;\n }\n if (uploadingText === selectionText) return;\n setUploadingText(selectionText);\n chatClient.upload(new Blob([selectionText], {\n type: \"text/markdown\"\n }), SELECTION_FILENAME).then(upload => {\n attachedRef.current = {\n text: selectionText,\n upload\n };\n // A newer selection replaces this one when its own upload lands.\n if (!mountedRef.current || latestSelectionRef.current !== selectionText) return;\n setUploads(existing => [...existing.filter(u => !isSelectionUpload(u)), upload]);\n }).catch(() => {\n if (mountedRef.current) setNotice(\"The selection could not be attached.\");\n }).finally(() => {\n if (mountedRef.current) setUploadingText(current => current === selectionText ? null : current);\n });\n }, [chatClient, sessionId, selectionText, selectionAttached, uploadingText, setUploads]);\n const askPeer = useCallback((agent: AgentTarget, question: string): void => {\n const selection = props.selection;\n const passage = peerPassage(props.savedBody, selection);\n if (!passage.trim()) {\n setNotice(`There is nothing in this ${props.typeLabel} to ask about yet.`);\n return;\n }\n const turn: PeerTurn = {\n id: crypto.randomUUID(),\n at: new Date().toISOString(),\n question,\n agent,\n rewrite: asksRewrite(question) && selection !== null,\n selection\n };\n setPeerTurns(current => [...current, turn]);\n setDraft(\"\");\n api.requestAgentAnswer({\n entityType: props.entityType,\n id: props.entityId,\n agent: agent.id,\n instruction: question,\n selection: passage\n }).then(({\n response\n }) => setPeerTurns(current => current.map(t => t.id === turn.id ? {\n ...t,\n answer: response\n } : t))).catch((failure: unknown) => {\n // A connected brain reads the saved entry, as this one does.\n const message = errorMessage(failure);\n const error = /no longer matches/i.test(message) ? \"the selection is not saved yet. Save, then ask again.\" : message;\n setPeerTurns(current => current.map(t => t.id === turn.id ? {\n ...t,\n error\n } : t));\n });\n }, [api, props.savedBody, props.entityId, props.entityType, props.selection, props.typeLabel, setDraft]);\n const ask = useCallback((question: string): void => {\n const text = question.trim();\n if (!text) return;\n setNotice(null);\n askedSelectionRef.current = props.selection;\n if (who) {\n askPeer(who, text);\n return;\n }\n void submitPrompt(text);\n }, [askPeer, props.selection, submitPrompt, who]);\n const submit = (event: FormEvent<HTMLFormElement>): void => {\n event.preventDefault();\n ask(draft);\n };\n const apply = (proposal: Proposal, selection: AskSelection | null): void => {\n const refusal = props.onApply(proposal, selection);\n setNotice(refusal ?? (proposal.field === \"selection\" ? \"Replaced in the draft. Save to keep it.\" : `Put in the draft’s ${proposal.label.toLowerCase()}. Save to keep it.`));\n };\n const proposalsFor = (selection: AskSelection | null): ChatTurnProposals => ({\n fields: props.fields,\n onApply: (proposal: Proposal): void => apply(proposal, selection),\n onTryAnother: (proposal: Proposal): void => ask(`Try another ${proposal.label.toLowerCase()}.`)\n });\n\n // Chat's turns and the connected brains' answers, in the order they came.\n const turns = [...visibleMessages.map(message => ({\n at: typeof message[\"timestamp\"] === \"string\" ? message[\"timestamp\"] : \"\",\n key: message.id,\n node: <ChatTurn key={message.id} message={message} client={chatClient} disabled={sending} speaker=\"Your brain\" onAction={runSuggestedAction} onApproval={respondToApproval} proposals={proposalsFor(askedSelectionRef.current)} />\n })), ...peerTurns.map(turn => ({\n at: turn.at,\n key: turn.id,\n node: <PeerExchange key={turn.id} turn={turn} client={chatClient} proposals={proposalsFor(turn.selection)} onRetry={() => askPeer(turn.agent, turn.question)} />\n }))].sort((a, b) => a.at && b.at ? a.at.localeCompare(b.at) : 0);\n\n // The newest answer stays in view as it arrives, unless the reader scrolled up.\n const {\n ref: threadRef,\n onScroll: onThreadScroll\n } = useFollowTail({\n resetKey: sessionId,\n contentKey: `${turns.length}:${stream?.text.length ?? -1}:${peerTurns.filter(t => t.answer !== undefined || t.error !== undefined).length}:${notice ?? \"\"}`\n });\n const about = props.selection ? \"About the selection\" : `About this ${props.typeLabel}`;\n return <aside {...stylex.props(s.panel)} aria-label=\"Ask\" data-studio-ask-panel=\"\">\n <header {...stylex.props(s.head)}>\n <h2 {...stylex.props(s.title)}>Ask</h2>\n <span {...stylex.props(s.about)} data-studio-ask-about=\"\">\n {about}\n {props.selection && <button type=\"button\" {...stylex.props(s.clear)} aria-label={`Ask about the whole ${props.typeLabel}`} onClick={props.onClearSelection}>\n ×\n </button>}\n </span>\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" xstyle={s.close} aria-label=\"Close Ask\" aria-keyshortcuts=\"Control+j Meta+j\" onClick={props.onClose}>\n ×\n </Button>\n </header>\n {props.agents.length > 0 && <div {...stylex.props(s.who)}>\n <label htmlFor=\"studio-ask-who\">Asking</label>\n <NativeSelect id=\"studio-ask-who\" xstyle={s.whoSelect} value={whoId} onChange={event => setWhoId(event.currentTarget.value)}>\n <option value=\"\">Your brain</option>\n {props.agents.map(agent => <option key={agent.id} value={agent.id}>\n {agent.label}\n </option>)}\n </NativeSelect>\n </div>}\n <div ref={threadRef} onScroll={onThreadScroll} {...stylex.props(s.thread)} role=\"log\" aria-label=\"Ask conversation\" aria-live=\"polite\">\n {opening === \"failed\" ? <p {...stylex.props(s.notice)}>\n Chat could not open a conversation about this {props.typeLabel}.{\" \"}\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={() => setAttempt(n => n + 1)}>\n Try again\n </Button>\n </p> : historyFailed ? <p {...stylex.props(s.notice)}>\n The conversation could not be read.{\" \"}\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={retryHistory}>\n Try again\n </Button>\n </p> : turns.length === 0 ? <p {...stylex.props(s.notice)}>\n {props.selection ? \"Ask about the selected passage, or have it rewritten.\" : `Ask about this ${props.typeLabel}. Select a passage to ask about it alone.`}\n </p> : turns.map(turn => turn.node)}\n {props.unsaved && turns.length > 0 && <p {...stylex.props(s.notice)}>\n Ask reads the saved version of this {props.typeLabel}.\n </p>}\n {(error ?? notice) && <p {...stylex.props(s.notice)} role=\"status\">\n {error ?? notice}\n </p>}\n </div>\n {props.selection && <div {...stylex.props(s.starters)} aria-label=\"Starters\">\n {ASK_STARTERS.map(starter => <button key={starter.label} type=\"button\" {...stylex.props(s.starter)} onClick={() => setDraft(starter.instruction)}>\n {starter.label}\n </button>)}\n </div>}\n <Composer draft={draft} sending={sending} uploading={uploading} uploads={uploads.filter(upload => !isSelectionUpload(upload))} uploadAttempts={[]} onRetryUpload={() => {}} onDismissUpload={() => {}} onDraft={setDraft} locked={opening !== \"open\"} onRemoveUpload={id => setUploads(current => current.filter(upload => upload.id !== id))} onFiles={async () => {}} allowFiles={false} onSubmit={submit} onStop={hasActiveStream() ? stopActiveStream : undefined} placeholder={askPlaceholder({\n who: who?.label ?? null,\n selected: props.selection !== null,\n typeLabel: props.typeLabel\n })} />\n </aside>;\n}\n\n/** A question to a connected brain and its answer, as Chat turns show them. */\nfunction PeerExchange(props: {\n turn: PeerTurn;\n client: ReturnType<typeof createChatClient>;\n proposals: ChatTurnProposals;\n onRetry: () => void;\n}): ReactElement {\n const {\n turn\n } = props;\n const question: ChatHistoryMessage = {\n id: `${turn.id}-question`,\n role: \"user\",\n content: turn.question,\n timestamp: turn.at\n };\n // A rewrite of the selection is a proposal to replace it.\n const content = turn.answer === undefined ? \"\" : turn.rewrite ? `\\`\\`\\`proposal selection\\n${turn.answer.trim()}\\n\\`\\`\\`` : turn.answer;\n const answer: ChatHistoryMessage = {\n id: `${turn.id}-answer`,\n role: \"assistant\",\n content,\n timestamp: turn.at\n };\n const noAction = async (): Promise<void> => {};\n return <>\n <ChatTurn message={question} client={props.client} disabled={false} onAction={noAction} onApproval={noAction} />\n {turn.error ? <p className={chatClass(\"\", chatLayout.error)} role=\"alert\">\n {turn.agent.label} did not answer: {turn.error}{\" \"}\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={props.onRetry}>\n Ask again\n </Button>\n </p> : turn.answer === undefined ? <p className={chatClass(\"\", chatLayout.empty)}>\n Asking {turn.agent.label}…\n </p> : <ChatTurn message={answer} client={props.client} disabled={false} speaker={turn.agent.label} onAction={noAction} onApproval={noAction} proposals={turn.rewrite ? props.proposals : undefined} />}\n </>;\n}"
6
6
  ],
7
7
  "mappings": "8dAMA,gCAgBM,GAAqB,eACrB,EAAoB,CAAC,IAAwC,EAAO,WAAa,GA6ChF,SAAS,EAAc,CAAC,EAA0C,CACvE,IAAM,EAAc,GAAe,EAC7B,EAAW,GAAY,EACvB,EAAM,GAAa,EACnB,EAAa,UAAQ,IAAM,GAAiB,CAChD,QAAS,EAAM,YACf,MAAO,CACT,CAAC,EAAG,CAAC,EAAM,YAAa,CAAQ,CAAC,GAC1B,EAAW,GAAgB,WAAwB,IAAI,GACvD,EAAS,GAAc,WAAwC,SAAS,GACxE,GAAS,IAAc,WAAS,CAAC,GACjC,EAAO,IAAY,WAAiB,EAAE,GACtC,EAAW,GAAgB,WAAqB,CAAC,CAAC,GAClD,EAAQ,GAAa,WAAwB,IAAI,GAEjD,EAAe,GAAoB,WAAwB,IAAI,EAChE,EAAY,IAAkB,KAC9B,EAAa,SAAO,EAAK,EACzB,GAAoB,SAAsB,IAAI,EAC9C,EAAc,SAGjB,IAAI,EACD,EAAoB,SAA4B,IAAI,EACpD,EAAM,EAAM,OAAO,KAAK,KAAS,EAAM,KAAO,CAAK,GAAK,KAG9D,YAAU,IAAM,CACd,IAAI,EAAU,GAgBd,OAfA,EAAW,SAAS,EACpB,EAAW,mBAAmB,CA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AAG,KAAK,QAApD,SAKV,CAJC,EAAK,MAAM,MADF,oBAC0B,EAAK,MAAO,IAChD,SAEE,EAFF,CAAQ,KAAK,SAAS,QAAQ,QAAQ,KAAK,KAAK,QAAS,EAAM,QAA/D,2CAEE,IAJQ,qBAKV,EAAK,EAAK,SAAW,OAAY,SAEjC,IAFiC,CAAG,UAAW,EAAU,GAAI,EAAW,KAAK,EAA5C,SAEjC,CAFiC,UACzB,EAAK,MAAM,MADc,2BAEjC,EAAK,SAAC,EAAD,CAAU,QAAS,EAAQ,OAAQ,EAAM,OAAQ,SAAU,GAAO,QAAS,EAAK,MAAM,MAAO,SAAU,EAAU,WAAY,EAAU,UAAW,EAAK,QAAU,EAAM,UAAY,QAAnL,qBAA8L,IATpM,qBAUH",
8
- "debugId": "2A8F8D725FA9CD0A64756E2164756E21",
8
+ "debugId": "9BA77FF417E4A9C764756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,3 +1,3 @@
1
- import{A as st,B as Je,Ba as ct,C as ze,aa as it,ba as at,ca as ne,da as ue,ea as rt,fa as lt}from"./main-eh2baz0t.js";import{Ea as n,Fa as i,Ga as Le,Ha as q,Ia as ut,Ja as mt,Ka as ft,La as ht,Ma as pt,Na as vt,Oa as Y,Pa as yt,Qa as gt}from"./main-ecwfbj4t.js";import{Mb as Ve,_a as et,bb as Ke,gc as dt,hb as Oe,kb as de,mb as Fe}from"./main-e098kfma.js";import"./main-eakaz9w9.js";import{Gc as Z}from"./main-8zx47tjg.js";import{Nc as H,Pc as R,Qc as Ee,Rc as Ge,Uc as Be,Vc as He,Xc as qe,de as X,kd as tt,ld as nt,wd as Ae,xd as Ne,zd as xe}from"./main-g15rdsa4.js";import{Pf as ot}from"./main-4qxa4jpx.js";import{Qf as L}from"./main-2vaawyz9.js";import{wg as I}from"./main-s8r820px.js";var Q=I(L(),1);var O=I(H(),1),qt={stopped:"Stopped",disconnected:"Connection lost",failed:"Response failed"};function ke(e){let{interrupted:t}=e;return O.jsxDEV("section",{className:i("studio-chat-interruption",n.empty),role:t.kind==="stopped"?"status":"alert","aria-atomic":"true",children:[O.jsxDEV("strong",{children:qt[t.kind]},void 0,!1,void 0,this),O.jsxDEV("p",{children:"Any received text is kept here. Stopping the response does not undo completed actions; the server may still be working."},void 0,!1,void 0,this),t.detail&&O.jsxDEV("p",{children:t.detail},void 0,!1,void 0,this),t.retry&&O.jsxDEV(O.Fragment,{children:[O.jsxDEV("p",{children:"Sending again may repeat completed actions. Review the request before sending."},void 0,!1,void 0,this),O.jsxDEV(R,{type:"button",variant:"ghost",disabled:e.restoreBlocked||e.draftPending,onClick:()=>{if(!t.retry||e.draftPending)return;e.onRestore(t.retry)},children:"Review retry in composer"},void 0,!1,void 0,this),e.draftPending&&O.jsxDEV("p",{children:"Your composer draft is unchanged. Send or clear it before restoring this request."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var _=I(L(),1);var x=I(H(),1);function we(e){return x.jsxDEV("aside",{className:i("studio-chat-context",n.contextBody),tabIndex:0,"aria-label":"Conversation sources and attachments",children:x.jsxDEV("div",{className:i("studio-chat-context-list",n.cards),children:[e.session?.contextHandoff?x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Linked context"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:e.session.contextHandoff.titleSeed},void 0,!1,void 0,this),x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[e.session.contextHandoff.sourceId," ·"," ",e.session.contextHandoff.itemId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,e.cards.length===0&&e.progress.length===0?x.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"No sources or attachments in this conversation yet."},void 0,!1,void 0,this):null,e.cards.map((t,o)=>x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:t.kind==="sources"?"Sources":"Artifact"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:t.kind==="sources"?t.title??`${t.sources.length} consulted`:t.kind==="attachment"?t.title:"Conversation context"},void 0,!1,void 0,this),t.kind==="sources"?x.jsxDEV(x.Fragment,{children:[x.jsxDEV("ul",{children:t.sources.slice(0,5).map((s)=>x.jsxDEV("li",{children:s.title??s.source},s.id,!1,void 0,this))},void 0,!1,void 0,this),t.sources.length>5?x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[t.sources.length-5," more sources in the conversation."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):t.kind==="attachment"&&t.description?x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.description},void 0,!1,void 0,this):null]},`${t.kind}-${t.id}-${o}`,!0,void 0,this)),e.progress.map((t,o)=>x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Durable job"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:t.operationTarget??t.operationType},void 0,!1,void 0,this),x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.message??t.status},void 0,!1,void 0,this)]},`${t.type}-${o}`,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ot=86400000;function Ie(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function Lt(e,t){return Math.round((Date.parse(t)-Date.parse(e))/Ot)}function De(e,t,o){let s=Lt(Ie(e,o),Ie(t,o));if(s<=0)return"Today";if(s===1)return"Yesterday";if(s<7)return"This week";return"Earlier"}function Re(e,t,o){let s=[...e].sort((r,a)=>a.lastActiveAt.localeCompare(r.lastActiveAt));return["Today","Yesterday","This week","Earlier"].map((r)=>({label:r,sessions:s.filter((a)=>De(Date.parse(a.lastActiveAt),t,o)===r)})).filter((r)=>r.sessions.length>0)}function le(e){let t=e.contextHandoff;if(t?.sourceId!==Ne)return null;let o=xe(t.itemId);return o?{...o,title:t.titleSeed}:null}function Te(e,t,o){let s=le(e);if(s)return{kind:"entry",text:s.title};let r=Date.parse(e.lastActiveAt);if(Number.isNaN(r))return{kind:"time",text:""};let a=Math.floor((t-r)/60000),l=De(r,t,o);if(l==="Today"){if(a<1)return{kind:"time",text:"Just now"};if(a<60)return{kind:"time",text:`${a} ${a===1?"minute":"minutes"} ago`};let f=Math.floor(a/60);return{kind:"time",text:`${f} ${f===1?"hour":"hours"} ago`}}if(l==="Yesterday")return{kind:"time",text:"Yesterday"};if(l==="This week")return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:o}).format(r)};return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",timeZone:o}).format(r)}}var P=I(L(),1);var A=I(H(),1);function Pe(e){let[t,o]=P.useState(!1),[s,r]=P.useState(e.title),[a,l]=P.useState(!1),[f,d]=P.useState(null),u=P.useRef(!1),p=P.useRef(!1),b=P.useRef(null);P.useEffect(()=>{if(t)b.current?.focus()},[t]);let y=P.useRef(null);P.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);let N=()=>{o(!1),d(null),requestAnimationFrame(()=>y.current?.querySelector("button")?.focus())},g=async()=>{if(p.current||!s.trim())return;p.current=!0,l(!0),d(null);try{if(await e.onRename(s.trim()),u.current)N()}catch(m){if(u.current)d(Ae(m,"Rename failed. Your proposed title is kept.")||"Rename failed. Your proposed title is kept.")}finally{if(p.current=!1,u.current)l(!1)}};return A.jsxDEV(A.Fragment,{children:[A.jsxDEV("span",{ref:y,children:A.jsxDEV(R,{type:"button",variant:"ghost","aria-expanded":t,disabled:t,onClick:()=>{r(e.title),o(!0)},children:"Rename"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t&&A.jsxDEV("form",{className:i("studio-chat-rename",n.sessionControls),onSubmit:(m)=>{m.preventDefault(),g()},children:[A.jsxDEV("label",{children:["Conversation title",A.jsxDEV(Ee,{ref:b,xstyle:n.sessionFilterSelect,value:s,onChange:(m)=>r(m.target.value),required:!0,maxLength:48,disabled:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.jsxDEV("div",{className:i("",n.actions),children:[A.jsxDEV(R,{type:"submit",disabled:a||!s.trim(),children:a?"Renaming…":"Save title"},void 0,!1,void 0,this),A.jsxDEV(R,{type:"button",variant:"ghost",disabled:a,onClick:N,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&A.jsxDEV("p",{role:"alert",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var c=I(H(),1);function Ue(e){let{currentSession:t,archivedSession:o,setConversationsOpen:s,detailsOpen:r,setDetailsOpen:a,renameCurrent:l}=e.sessions,f=_.useRef(null),d=_.useId(),u=e.draftPending?"Send or clear the draft before archiving or deleting.":void 0,p=t?le(t):null,b=p?.title??t?.contextHandoff?.titleSeed??void 0,y=p?e.entryHref(p.entityType,p.entityId):void 0,N=t?.title??(e.sessionId?"Conversation":"New conversation"),g=(v)=>y!==void 0?c.jsxDEV("a",{href:y,className:i("studio-chat-open-entry",n.openEntry,v&&n.openEntryIcon),"aria-label":v?"Open entry":void 0,onClick:(k)=>{if(!Oe(k))return;k.preventDefault(),e.onOpenEntry(y)},children:v?c.jsxDEV("span",{"aria-hidden":"true",children:"↗"},void 0,!1,void 0,this):"Open entry ↗"},void 0,!1,void 0,this):null,m=c.jsxDEV(R,{type:"button",variant:"ghost",xstyle:n.toolbarButton,"aria-label":"Conversation details and options","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>a(!0),children:"•••"},void 0,!1,void 0,this),[w]=_.useState(()=>Symbol("chat thread"));return Z(w,e.phoneShown?{title:N,back:{label:"Conversations",onBack:()=>s(!0)},action:c.jsxDEV(c.Fragment,{children:[g(!0),m]},void 0,!0,void 0,this)}:null),c.jsxDEV(c.Fragment,{children:[c.jsxDEV("header",{className:i("studio-chat-thread-head",n.threadHead,n.phoneGoneFlex),children:[c.jsxDEV("h1",{className:i("studio-chat-session-heading",n.title),title:t?.title,children:N},void 0,!1,void 0,this),b&&c.jsxDEV("span",{className:i("studio-chat-about",n.about),"data-studio-chat-about":"",children:["About: ",b]},void 0,!0,void 0,this),c.jsxDEV("div",{className:i("studio-chat-head-actions",n.toolbar),children:[g(!1),c.jsxDEV("span",{ref:f,children:m},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV(Be,{open:r,onOpenChange:(v)=>{if(a(v),!v)e.deletion.cancelDelete()},children:c.jsxDEV(He,{"aria-describedby":void 0,onCloseAutoFocus:(v)=>{v.preventDefault(),([...document.querySelectorAll('[aria-label="Conversation details and options"]')].find((D)=>D.offsetParent!==null)??f.current?.querySelector("button"))?.focus()},children:[c.jsxDEV(qe,{children:"Conversation details"},void 0,!1,void 0,this),c.jsxDEV("div",{className:i("studio-chat-details",n.details),children:[c.jsxDEV("p",{children:t?.title??"New conversation"},void 0,!1,void 0,this),c.jsxDEV("div",{className:i("studio-chat-session-actions",n.actions),children:[t&&c.jsxDEV(Pe,{title:t.title,onRename:l},t.id,!1,void 0,this),o&&c.jsxDEV("p",{role:"status",children:"Archived conversation. New messages here remain archived."},void 0,!1,void 0,this),e.sessionId&&!o?c.jsxDEV(R,{className:"studio-chat-header-action",variant:"ghost",type:"button",onClick:e.onArchive,disabled:e.archiveBlocked,"aria-describedby":u?d:void 0,children:e.archiving?"Archiving…":"Archive"},void 0,!1,void 0,this):null,e.sessionId&&(e.deletion.confirming?c.jsxDEV("section",{role:"group","aria-label":"Confirm conversation deletion",children:[c.jsxDEV("p",{children:"Delete this conversation permanently? This cannot be undone."},void 0,!1,void 0,this),c.jsxDEV("p",{children:"Deleting history does not undo completed actions or guarantee that remote work has stopped."},void 0,!1,void 0,this),e.deletion.deleteError&&c.jsxDEV("p",{role:"alert",children:e.deletion.deleteError},void 0,!1,void 0,this),c.jsxDEV(R,{type:"button",variant:"ghost",autoFocus:!0,"aria-label":"Cancel conversation deletion",disabled:e.deletion.deleting,onClick:e.deletion.cancelDelete,children:"Cancel"},void 0,!1,void 0,this),c.jsxDEV(R,{type:"button",variant:"danger","aria-label":"Permanently delete conversation",disabled:e.archiveBlocked,onClick:()=>void e.deletion.confirmDelete(),children:e.deletion.deleting?"Deleting…":"Delete permanently"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):c.jsxDEV(R,{type:"button",variant:"danger","aria-label":"Delete conversation",disabled:e.archiveBlocked,"aria-describedby":u?d:void 0,onClick:e.deletion.requestDelete,children:"Delete conversation"},void 0,!1,void 0,this)),u&&c.jsxDEV("p",{id:d,children:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV("details",{children:[c.jsxDEV("summary",{children:"Sources and attachments"},void 0,!1,void 0,this),c.jsxDEV(we,{cards:e.contextCards,progress:e.progress,session:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV("details",{children:[c.jsxDEV("summary",{children:"File types and limits"},void 0,!1,void 0,this),c.jsxDEV("p",{id:"studio-chat-upload-guidance",children:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var U=I(L(),1);var Ut=250;function Me(e){let{chatClient:t,queryClient:o,sessionId:s,studioBasePath:r,navigate:a}=e,[l,f]=U.useState(s===null),[d,u]=U.useState(!1),[p,b]=U.useState(""),[y,N]=U.useState({query:"",archived:!1,offset:0});U.useEffect(()=>{let E=window.setTimeout(()=>N((T)=>T.query===p.trim()?T:{...T,query:p.trim(),offset:0}),Ut);return()=>window.clearTimeout(E)},[p]);let g=Ke({queryKey:[...q.sessions,y],queryFn:()=>t.listSessions(y)}),m=g.data??[],w=m.find((E)=>E.id===s)??o.getQueriesData({queryKey:q.sessions}).flatMap(([,E])=>E??[]).find((E)=>E.id===s),v=U.useCallback(()=>{u(!1)},[]),k=U.useCallback((E,T=!1)=>{a(Fe(r,E),{preserveWork:T}),f(!1),v()},[a,r,v]),D=async(E)=>{if(!w)return;let T=await t.renameSession(w.id,E);if(!T.renamed)throw Error("The conversation could not be renamed.");o.setQueriesData({queryKey:q.sessions},(V)=>V?.map((W)=>W.id===w.id?{...W,title:T.title}:W)),o.invalidateQueries({queryKey:q.sessions})};return{sessions:m,currentSession:w,archivedSession:w?.archived===!0,sessionControls:{search:p,view:y,error:g.error?"Sessions could not be loaded.":null,onRetry:()=>{g.refetch()},onSearch:b,onView:N},sessionsLoading:g.isPending,navigateToSession:k,conversationsOpen:l,setConversationsOpen:f,detailsOpen:d,setDetailsOpen:u,closeDisclosures:v,renameCurrent:D}}var K=I(L(),1);function Qe(e){let{chatClient:t,draftKey:o,currentDraftKey:s,setUploads:r}=e,[a,l]=K.useState(!1),[f,d]=K.useState([]),u=K.useRef(null),p=K.useCallback(async(g)=>{if(u.current||g.length===0)return;let m=Symbol();if(u.current=m,l(!0),d((w)=>[...w.filter((v)=>!g.some((k)=>k.id===v.id)),...g.map((v)=>({id:v.id,file:v.file,status:"uploading"}))]),await Promise.all(g.map(async(w)=>{try{let v=await t.upload(w.file,w.file.name);if(u.current!==m||s.current!==o)return;r((k)=>[...k,v]),d((k)=>k.filter((D)=>D.id!==w.id))}catch(v){if(u.current!==m||s.current!==o)return;d((k)=>k.map((D)=>D.id===w.id?{...D,status:"failed",error:Y(v,"Upload failed")}:D))}})),u.current===m)u.current=null,l(!1)},[t,o,s,r]),b=K.useCallback(async(g)=>{let m=Array.from(g.target.files??[]);g.target.value="",await p(m.map((w)=>({id:crypto.randomUUID(),file:w,status:"uploading"})))},[p]),y=K.useCallback((g)=>{d((m)=>m.filter((w)=>w.id!==g))},[]),N=K.useCallback(()=>{u.current=null,l(!1),d([])},[]);return{uploading:a,uploadAttempts:f,runUploads:p,uploadFiles:b,dismissAttempt:y,reset:N}}var G=I(L(),1);function We(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,setError:u,navigateToSession:p}=e,[b,y]=G.useState(!1),N=G.useCallback(async()=>{if(!s||f)return;d(!0),y(!0);try{if(await t.archiveSession(s),await o.invalidateQueries({queryKey:q.sessions}),l.current&&a.current===r)p(void 0,!0)}catch(m){if(l.current&&a.current===r)u(Y(m,"Conversation could not be archived"))}finally{if(l.current&&a.current===r)d(!1),y(!1)}},[t,o,s,r,a,l,f,d,u,p]),g=G.useCallback(()=>y(!1),[]);return{archiving:b,archiveCurrent:N,reset:g}}var M=I(L(),1);function $e(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,navigateToSession:u}=e,[p,b]=M.useState(null),[y,N]=M.useState(!1),[g,m]=M.useState(null),w=M.useRef(0),v=M.useRef(!1),k=p===r,D=M.useCallback(()=>{w.current++,v.current=!1,b(null),N(!1),m(null)},[]);return{confirming:k,deleting:y,deleteError:g,requestDelete:()=>{if(!s||f||v.current)return;m(null),b(r)},cancelDelete:()=>{if(!v.current)b(null)},confirmDelete:async()=>{if(!s||!k||f||v.current)return;let W=w.current,B=()=>l.current&&a.current===r&&w.current===W;v.current=!0,N(!0),d(!0),m(null);try{if(!(await t.deleteSession(s)).deleted)throw Error("Deletion was not acknowledged");if(await o.cancelQueries({queryKey:q.messages(s)}),o.removeQueries({queryKey:q.messages(s)}),o.setQueriesData({queryKey:q.sessions},(J)=>J?.filter((z)=>z.id!==s)),o.invalidateQueries({queryKey:q.sessions}),B())b(null),u(void 0,!0)}catch{if(B())m("Deletion could not be confirmed. The conversation may already be deleted. Check history before trying again.")}finally{if(B())v.current=!1,N(!1),d(!1)}},reset:D}}var ee=I(L(),1);function _e(e){let{chatClient:t,handoff:o,sessionId:s,apiPath:r,draftStore:a,draftKey:l,currentDraftKey:f,mountedRef:d,setDraft:u,setError:p,navigateToSession:b}=e,y=ee.useRef(null);ee.useEffect(()=>{if(!o||s)return;let N=`${o.sourceId}\x00${o.itemId}`;if(y.current===N)return;y.current=N,u(o.prompt),p(null);let g=()=>d.current===!0&&f.current===l&&y.current===N;t.openContextSession({version:1,sourceId:o.sourceId,itemId:o.itemId,titleSeed:o.label}).then(({conversationId:m})=>{if(!g())return;a.adopt(l,Ve(r,m)),b(m,!0)}).catch((m)=>{if(!g())return;y.current=null,p(Y(m,"Context could not be attached"))})},[t,o,s,r,a,l,f,d,u,p,b])}var te=I(L(),1);function Ye(e){let{question:t,sessionId:o,setDraft:s}=e,r=te.useRef(null);te.useEffect(()=>{if(!t||o)return;if(r.current===t)return;r.current=t,s(t)},[t,o,s])}var ce=I(L(),1);function je(e){let{onChange:t,draft:o,uploadCount:s,uploadAttemptCount:r,sending:a,uploading:l}=e;ce.useEffect(()=>{t?.({hasDraft:Boolean(o||s||r),busy:a||l})},[o,s,r,a,l,t]),ce.useEffect(()=>()=>t?.({hasDraft:!1,busy:!1}),[t])}var Xe=I(L(),1);var S=I(H(),1);function Ze(e){let t=Date.now(),o=e.sessions.length>0||e.search!==""||e.view.query!==""||e.view.archived||e.view.offset>0,s=S.jsxDEV(R,{className:"studio-chat-new",type:"button",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this),[r]=Xe.useState(()=>Symbol("conversations"));return Z(r,e.phoneHidden===!0?null:{title:"Conversations",action:s}),S.jsxDEV("aside",{className:i("studio-chat-session-picker",n.conversations,e.phoneHidden===!0&&n.conversationsHidden),"aria-label":"Conversations",children:[S.jsxDEV("div",{className:i("studio-chat-session-controls",n.sessionControls),children:[S.jsxDEV("div",{className:i("",n.railHead,n.phoneGoneFlex),children:[S.jsxDEV("h2",{className:i("",n.railTitle),children:"Conversations"},void 0,!1,void 0,this),S.jsxDEV(R,{className:"studio-chat-new",type:"button",variant:"secondary",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&S.jsxDEV(Je,{label:"Conversation search and filters",searchLabel:"Search conversations",search:e.search,onSearch:e.onSearch,filterLabel:"Filter",filterCount:e.view.archived?1:0,filtered:Boolean(e.view.query)||e.view.archived,onClear:()=>{e.onSearch(""),e.onView({...e.view,query:"",archived:!1,offset:0})},children:S.jsxDEV(Ge,{"aria-label":"Show conversations",value:e.view.archived?"archived":"active",onChange:(a)=>e.onView({...e.view,archived:a.target.value==="archived",offset:0}),children:[S.jsxDEV("option",{value:"active",children:"Active conversations"},void 0,!1,void 0,this),S.jsxDEV("option",{value:"archived",children:"Archived conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.error&&S.jsxDEV("p",{role:"alert",children:[e.error," ",S.jsxDEV(R,{type:"button",variant:"ghost",onClick:e.onRetry,children:"Retry sessions"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S.jsxDEV("div",{className:i("studio-chat-session-list",n.sessionList),children:[e.loading?S.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:"Loading conversations…"},void 0,!1,void 0,this):null,!e.loading&&!e.error&&e.sessions.length===0?S.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:e.view.query?"No conversations match this search.":e.view.offset>0?"No more conversations.":e.view.archived?"No archived conversations.":"No conversations yet."},void 0,!1,void 0,this):null,Re(e.sessions,t).map((a)=>S.jsxDEV("section",{"aria-label":a.label,children:[S.jsxDEV("h3",{className:i("",n.dayLabel),children:a.label},void 0,!1,void 0,this),a.sessions.map((l)=>{let f=l.id===e.activeSessionId,d=Te(l,t);return S.jsxDEV("button",{className:i("studio-chat-session",n.session,f&&n.activeSession),"data-active":f?"true":"false","aria-current":f?"true":void 0,type:"button",onClick:()=>e.onSelect(l.id),children:[S.jsxDEV("strong",{className:i("studio-chat-session-title",n.sessionTitle),children:l.title},void 0,!1,void 0,this),S.jsxDEV("small",{className:i("studio-chat-session-note",n.sessionNote),"data-note":d.kind,children:d.kind==="entry"?S.jsxDEV(S.Fragment,{children:[S.jsxDEV("span",{"aria-hidden":"true",className:i("",n.brainMark)},void 0,!1,void 0,this),d.text]},void 0,!0,void 0,this):S.jsxDEV("time",{dateTime:l.lastActiveAt,title:l.lastActiveAt,children:d.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},l.id,!0,void 0,this)})]},a.label,!0,void 0,this)),(e.view.offset>0||e.sessions.length>=25)&&S.jsxDEV(ze,{label:"Conversation pages",offset:e.view.offset,count:e.sessions.length,loading:e.loading,hasNext:e.sessions.length>=25,onPrevious:()=>e.onView({...e.view,offset:Math.max(0,e.view.offset-25)}),onNext:()=>e.onView({...e.view,offset:e.view.offset+25})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var h=I(H(),1);function Kt(e,t,o){return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}function io(e){let t=et(),o=tt(),s=Q.useMemo(()=>ot({apiPath:e.apiPath,fetch:o}),[e.apiPath,o]),{draftStore:r,draftKey:a,currentDraftKey:l,draft:f,uploads:d,setDraft:u,setUploads:p}=vt({draftStore:e.draftStore,apiPath:e.apiPath,sessionId:e.sessionId}),{uploading:b,uploadAttempts:y,runUploads:N,uploadFiles:g,dismissAttempt:m,reset:w}=Qe({chatClient:s,draftKey:a,currentDraftKey:l,setUploads:p}),v=at(),k=Me({chatClient:s,queryClient:t,sessionId:e.sessionId,studioBasePath:e.studioBasePath,navigate:e.navigate}),{navigateToSession:D,closeDisclosures:E}=k,T=Q.useRef(!1),V=Q.useRef(null),{pendingMessages:W,stream:B,sending:F,error:J,interrupted:z,setSending:me,setError:fe,submitPrompt:Ct,respondToApproval:he,runSuggestedAction:St,hasActiveStream:bt,stopActiveStream:kt,abortActiveStream:pe,reset:wt}=yt({chatClient:s,queryClient:t,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,adoptedSessionRef:V,uploads:d,uploading:b,uploadAttemptCount:y.length,navigateToSession:D});_e({chatClient:s,handoff:e.handoff,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,setDraft:u,setError:fe,navigateToSession:D}),Ye({question:e.question,sessionId:e.sessionId,setDraft:u});let ve=Boolean(f)||d.length>0,ye=ve||y.length>0,oe=F||b||ye,{archiving:ge,archiveCurrent:It,reset:Nt}=We({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,setError:fe,navigateToSession:D}),se=$e({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,navigateToSession:D});Q.useEffect(()=>(T.current=!0,()=>{T.current=!1,pe()}),[pe]),je({onChange:e.onNavigationStateChange,draft:f,uploadCount:d.length,uploadAttemptCount:y.length,sending:F,uploading:b});let{visibleMessages:j,contextCards:xt,historyFailed:ie,historyOpening:ae,historyReading:Dt,hasStoredHistory:Rt,retryHistory:Tt}=gt({chatClient:s,sessionId:e.sessionId,sending:F,pendingMessages:W,stream:B}),{ref:Ce,onScroll:Et,awayFromLatest:At,jumpToLatest:Pt}=nt({resetKey:e.sessionId,contentKey:`${j.length}:${B?.text.length??-1}`});Q.useEffect(()=>{if(E(),e.sessionId&&V.current===e.sessionId){V.current=null;return}wt(),w(),Nt(),se.reset()},[e.sessionId]);let Bt=(C)=>{C.preventDefault(),Ct(f)},Se=ct(e.workspaces),be=!ie&&(!e.sessionId||!ae)&&j.length===0?mt({types:e.types.map((C)=>C.entityType),workspaces:e.workspaces.map((C)=>C.id)}):[];return h.jsxDEV(dt,{value:(C)=>e.navigate(C),children:h.jsxDEV("div",{className:i("studio",st.frame,n.root,it.space),"data-view":"chat","data-studio-shell":"",children:[h.jsxDEV(lt,{contextLabel:"Chat",navigation:{types:e.types,workspaces:e.workspaces,activeEntityType:null,activeWorkspaceId:de,workspaceBadges:Se,selectEntityType:e.selectEntityType,selectWorkspace:e.selectWorkspace}},void 0,!1,void 0,this),h.jsxDEV("div",{className:ue("studio-chat-shell",n.shell,ne.shell,v&&ne.shellCollapsed),children:[h.jsxDEV("aside",{className:ue("rail studio-chat-studio-rail",ne.rail),children:h.jsxDEV(rt,{renderMode:"desktop",types:e.types,active:null,onSelect:e.selectEntityType,workspaces:e.workspaces,activeWorkspace:de,workspaceBadges:Se,onSelectWorkspace:e.selectWorkspace},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.jsxDEV("main",{className:i("studio-chat-workspace",n.frame),children:h.jsxDEV("div",{className:i("studio-chat-room",n.room),children:[h.jsxDEV(Ze,{...k.sessionControls,activeSessionId:e.sessionId,loading:k.sessionsLoading,sessions:k.sessions,onNew:()=>D(),onSelect:D,phoneHidden:!k.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("section",{className:i("studio-chat-thread",n.thread,k.conversationsOpen&&n.threadHidden),"aria-label":"Conversation",children:[h.jsxDEV(Ue,{sessionId:e.sessionId,sessions:k,archiving:ge,archiveBlocked:oe,draftPending:ye,onArchive:()=>void It(),deletion:se,contextCards:xt,progress:B?.progress??[],entryHref:(C,re)=>Kt(e.studioBasePath,C,re),onOpenEntry:(C)=>e.navigate(C),phoneShown:!k.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("div",{ref:Ce,tabIndex:0,role:"region","aria-label":"Conversation messages",onScroll:Et,className:i("studio-chat-thread-scroll",n.threadScroll),children:h.jsxDEV("div",{className:i("studio-chat-manuscript",n.manuscript),children:[ie&&h.jsxDEV("section",{role:"alert",children:[h.jsxDEV("p",{children:[Rt?"Showing previously loaded messages. ":"","Conversation could not be loaded."]},void 0,!0,void 0,this),h.jsxDEV(R,{type:"button",variant:"ghost",disabled:Dt,onClick:Tt,children:"Retry conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ae&&e.sessionId&&j.length===0?h.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"Opening conversation…"},void 0,!1,void 0,this):null,!ie&&(!e.sessionId||!ae)&&j.length===0?h.jsxDEV(ft,{},void 0,!1,void 0,this):null,j.map((C)=>h.jsxDEV(ht,{message:C,client:s,disabled:F,speaker:"Your brain",reading:"manuscript",onAction:St,onApproval:he},C.id,!1,void 0,this)),B?.approvals.map((C)=>h.jsxDEV(pt,{approval:C,disabled:F,onDecision:he},C.approvalId,!1,void 0,this)),B&&B.progress.length>0&&h.jsxDEV("details",{className:i("studio-chat-progress",n.card),children:[h.jsxDEV("summary",{children:["Activity · ",B.progress.length," updates"]},void 0,!0,void 0,this),h.jsxDEV("pre",{className:i("",n.source),children:JSON.stringify(B.progress,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?h.jsxDEV("p",{className:i("studio-chat-stream-status",n.empty),role:"status",children:"Responding…"},void 0,!1,void 0,this):null,z&&h.jsxDEV(ke,{interrupted:z,draftPending:ve,restoreBlocked:F||b,onRestore:(C)=>{u(C.text),p([...C.uploads]),Ce.current?.closest(".studio-chat-thread")?.querySelector("textarea")?.focus()}},void 0,!1,void 0,this),J?h.jsxDEV("p",{className:i("studio-chat-error",n.empty,n.error),role:"alert",children:J},void 0,!1,void 0,this):null,h.jsxDEV("div",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h.jsxDEV(ut,{above:be.length>0?h.jsxDEV("div",{"data-studio-chat-starters":"",className:i("studio-chat-starters",n.starters),"aria-label":"Ways to start",children:be.map((C)=>h.jsxDEV("button",{type:"button",className:i("",n.starter),onClick:()=>u(C),children:C},C,!1,void 0,this))},void 0,!1,void 0,this):void 0,onJumpToLatest:At?Pt:void 0,draft:f,sending:F,uploading:b,uploads:d,uploadAttempts:y,onRetryUpload:(C)=>void N([C]),onDismissUpload:m,onDraft:u,locked:ge||se.deleting,onRemoveUpload:(C)=>p((re)=>re.filter((Ht)=>Ht.id!==C)),onFiles:g,onSubmit:Bt,onStop:bt()?kt:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{io as StudioChatWorkspace};
1
+ import{A as st,B as Je,C as ze,Ca as ct,aa as it,ba as at,ca as ne,da as ue,ea as rt,fa as lt}from"./main-6qe1jp8h.js";import{Fa as n,Ga as i,Ha as Le,Ia as q,Ja as ut,Ka as mt,La as ft,Ma as ht,Na as pt,Oa as vt,Pa as Y,Qa as yt,Ra as gt}from"./main-rt6yh800.js";import{$a as et,Nb as Ve,cb as Ke,hc as dt,ib as Oe,lb as de,nb as Fe}from"./main-d5szcfbq.js";import"./main-t14ef5wt.js";import{Hc as Z}from"./main-ggcgvxym.js";import{Ad as xe,Oc as H,Qc as R,Rc as Ee,Sc as Ge,Vc as Be,Wc as He,Yc as qe,ee as X,ld as tt,md as nt,xd as Ae,yd as Ne}from"./main-pqx64crr.js";import{Qf as ot}from"./main-7fyr0wv3.js";import{Rf as L}from"./main-y9skwxac.js";import{xg as I}from"./main-f886snck.js";var Q=I(L(),1);var O=I(H(),1),qt={stopped:"Stopped",disconnected:"Connection lost",failed:"Response failed"};function ke(e){let{interrupted:t}=e;return O.jsxDEV("section",{className:i("studio-chat-interruption",n.empty),role:t.kind==="stopped"?"status":"alert","aria-atomic":"true",children:[O.jsxDEV("strong",{children:qt[t.kind]},void 0,!1,void 0,this),O.jsxDEV("p",{children:"Any received text is kept here. Stopping the response does not undo completed actions; the server may still be working."},void 0,!1,void 0,this),t.detail&&O.jsxDEV("p",{children:t.detail},void 0,!1,void 0,this),t.retry&&O.jsxDEV(O.Fragment,{children:[O.jsxDEV("p",{children:"Sending again may repeat completed actions. Review the request before sending."},void 0,!1,void 0,this),O.jsxDEV(R,{type:"button",variant:"ghost",disabled:e.restoreBlocked||e.draftPending,onClick:()=>{if(!t.retry||e.draftPending)return;e.onRestore(t.retry)},children:"Review retry in composer"},void 0,!1,void 0,this),e.draftPending&&O.jsxDEV("p",{children:"Your composer draft is unchanged. Send or clear it before restoring this request."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var _=I(L(),1);var x=I(H(),1);function we(e){return x.jsxDEV("aside",{className:i("studio-chat-context",n.contextBody),tabIndex:0,"aria-label":"Conversation sources and attachments",children:x.jsxDEV("div",{className:i("studio-chat-context-list",n.cards),children:[e.session?.contextHandoff?x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Linked context"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:e.session.contextHandoff.titleSeed},void 0,!1,void 0,this),x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[e.session.contextHandoff.sourceId," ·"," ",e.session.contextHandoff.itemId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,e.cards.length===0&&e.progress.length===0?x.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"No sources or attachments in this conversation yet."},void 0,!1,void 0,this):null,e.cards.map((t,o)=>x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:t.kind==="sources"?"Sources":"Artifact"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:t.kind==="sources"?t.title??`${t.sources.length} consulted`:t.kind==="attachment"?t.title:"Conversation context"},void 0,!1,void 0,this),t.kind==="sources"?x.jsxDEV(x.Fragment,{children:[x.jsxDEV("ul",{children:t.sources.slice(0,5).map((s)=>x.jsxDEV("li",{children:s.title??s.source},s.id,!1,void 0,this))},void 0,!1,void 0,this),t.sources.length>5?x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[t.sources.length-5," more sources in the conversation."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):t.kind==="attachment"&&t.description?x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.description},void 0,!1,void 0,this):null]},`${t.kind}-${t.id}-${o}`,!0,void 0,this)),e.progress.map((t,o)=>x.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[x.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Durable job"},void 0,!1,void 0,this),x.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,X.section),children:t.operationTarget??t.operationType},void 0,!1,void 0,this),x.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.message??t.status},void 0,!1,void 0,this)]},`${t.type}-${o}`,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ot=86400000;function Ie(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function Lt(e,t){return Math.round((Date.parse(t)-Date.parse(e))/Ot)}function De(e,t,o){let s=Lt(Ie(e,o),Ie(t,o));if(s<=0)return"Today";if(s===1)return"Yesterday";if(s<7)return"This week";return"Earlier"}function Re(e,t,o){let s=[...e].sort((r,a)=>a.lastActiveAt.localeCompare(r.lastActiveAt));return["Today","Yesterday","This week","Earlier"].map((r)=>({label:r,sessions:s.filter((a)=>De(Date.parse(a.lastActiveAt),t,o)===r)})).filter((r)=>r.sessions.length>0)}function le(e){let t=e.contextHandoff;if(t?.sourceId!==Ne)return null;let o=xe(t.itemId);return o?{...o,title:t.titleSeed}:null}function Te(e,t,o){let s=le(e);if(s)return{kind:"entry",text:s.title};let r=Date.parse(e.lastActiveAt);if(Number.isNaN(r))return{kind:"time",text:""};let a=Math.floor((t-r)/60000),l=De(r,t,o);if(l==="Today"){if(a<1)return{kind:"time",text:"Just now"};if(a<60)return{kind:"time",text:`${a} ${a===1?"minute":"minutes"} ago`};let f=Math.floor(a/60);return{kind:"time",text:`${f} ${f===1?"hour":"hours"} ago`}}if(l==="Yesterday")return{kind:"time",text:"Yesterday"};if(l==="This week")return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:o}).format(r)};return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",timeZone:o}).format(r)}}var P=I(L(),1);var A=I(H(),1);function Pe(e){let[t,o]=P.useState(!1),[s,r]=P.useState(e.title),[a,l]=P.useState(!1),[f,d]=P.useState(null),u=P.useRef(!1),p=P.useRef(!1),b=P.useRef(null);P.useEffect(()=>{if(t)b.current?.focus()},[t]);let y=P.useRef(null);P.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);let N=()=>{o(!1),d(null),requestAnimationFrame(()=>y.current?.querySelector("button")?.focus())},g=async()=>{if(p.current||!s.trim())return;p.current=!0,l(!0),d(null);try{if(await e.onRename(s.trim()),u.current)N()}catch(m){if(u.current)d(Ae(m,"Rename failed. Your proposed title is kept.")||"Rename failed. Your proposed title is kept.")}finally{if(p.current=!1,u.current)l(!1)}};return A.jsxDEV(A.Fragment,{children:[A.jsxDEV("span",{ref:y,children:A.jsxDEV(R,{type:"button",variant:"ghost","aria-expanded":t,disabled:t,onClick:()=>{r(e.title),o(!0)},children:"Rename"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t&&A.jsxDEV("form",{className:i("studio-chat-rename",n.sessionControls),onSubmit:(m)=>{m.preventDefault(),g()},children:[A.jsxDEV("label",{children:["Conversation title",A.jsxDEV(Ee,{ref:b,xstyle:n.sessionFilterSelect,value:s,onChange:(m)=>r(m.target.value),required:!0,maxLength:48,disabled:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.jsxDEV("div",{className:i("",n.actions),children:[A.jsxDEV(R,{type:"submit",disabled:a||!s.trim(),children:a?"Renaming…":"Save title"},void 0,!1,void 0,this),A.jsxDEV(R,{type:"button",variant:"ghost",disabled:a,onClick:N,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&A.jsxDEV("p",{role:"alert",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var c=I(H(),1);function Ue(e){let{currentSession:t,archivedSession:o,setConversationsOpen:s,detailsOpen:r,setDetailsOpen:a,renameCurrent:l}=e.sessions,f=_.useRef(null),d=_.useId(),u=e.draftPending?"Send or clear the draft before archiving or deleting.":void 0,p=t?le(t):null,b=p?.title??t?.contextHandoff?.titleSeed??void 0,y=p?e.entryHref(p.entityType,p.entityId):void 0,N=t?.title??(e.sessionId?"Conversation":"New conversation"),g=(v)=>y!==void 0?c.jsxDEV("a",{href:y,className:i("studio-chat-open-entry",n.openEntry,v&&n.openEntryIcon),"aria-label":v?"Open entry":void 0,onClick:(k)=>{if(!Oe(k))return;k.preventDefault(),e.onOpenEntry(y)},children:v?c.jsxDEV("span",{"aria-hidden":"true",children:"↗"},void 0,!1,void 0,this):"Open entry ↗"},void 0,!1,void 0,this):null,m=c.jsxDEV(R,{type:"button",variant:"ghost",xstyle:n.toolbarButton,"aria-label":"Conversation details and options","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>a(!0),children:"•••"},void 0,!1,void 0,this),[w]=_.useState(()=>Symbol("chat thread"));return Z(w,e.phoneShown?{title:N,back:{label:"Conversations",onBack:()=>s(!0)},action:c.jsxDEV(c.Fragment,{children:[g(!0),m]},void 0,!0,void 0,this)}:null),c.jsxDEV(c.Fragment,{children:[c.jsxDEV("header",{className:i("studio-chat-thread-head",n.threadHead,n.phoneGoneFlex),children:[c.jsxDEV("h1",{className:i("studio-chat-session-heading",n.title),title:t?.title,children:N},void 0,!1,void 0,this),b&&c.jsxDEV("span",{className:i("studio-chat-about",n.about),"data-studio-chat-about":"",children:["About: ",b]},void 0,!0,void 0,this),c.jsxDEV("div",{className:i("studio-chat-head-actions",n.toolbar),children:[g(!1),c.jsxDEV("span",{ref:f,children:m},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV(Be,{open:r,onOpenChange:(v)=>{if(a(v),!v)e.deletion.cancelDelete()},children:c.jsxDEV(He,{"aria-describedby":void 0,onCloseAutoFocus:(v)=>{v.preventDefault(),([...document.querySelectorAll('[aria-label="Conversation details and options"]')].find((D)=>D.offsetParent!==null)??f.current?.querySelector("button"))?.focus()},children:[c.jsxDEV(qe,{children:"Conversation details"},void 0,!1,void 0,this),c.jsxDEV("div",{className:i("studio-chat-details",n.details),children:[c.jsxDEV("p",{children:t?.title??"New conversation"},void 0,!1,void 0,this),c.jsxDEV("div",{className:i("studio-chat-session-actions",n.actions),children:[t&&c.jsxDEV(Pe,{title:t.title,onRename:l},t.id,!1,void 0,this),o&&c.jsxDEV("p",{role:"status",children:"Archived conversation. New messages here remain archived."},void 0,!1,void 0,this),e.sessionId&&!o?c.jsxDEV(R,{className:"studio-chat-header-action",variant:"ghost",type:"button",onClick:e.onArchive,disabled:e.archiveBlocked,"aria-describedby":u?d:void 0,children:e.archiving?"Archiving…":"Archive"},void 0,!1,void 0,this):null,e.sessionId&&(e.deletion.confirming?c.jsxDEV("section",{role:"group","aria-label":"Confirm conversation deletion",children:[c.jsxDEV("p",{children:"Delete this conversation permanently? This cannot be undone."},void 0,!1,void 0,this),c.jsxDEV("p",{children:"Deleting history does not undo completed actions or guarantee that remote work has stopped."},void 0,!1,void 0,this),e.deletion.deleteError&&c.jsxDEV("p",{role:"alert",children:e.deletion.deleteError},void 0,!1,void 0,this),c.jsxDEV(R,{type:"button",variant:"ghost",autoFocus:!0,"aria-label":"Cancel conversation deletion",disabled:e.deletion.deleting,onClick:e.deletion.cancelDelete,children:"Cancel"},void 0,!1,void 0,this),c.jsxDEV(R,{type:"button",variant:"danger","aria-label":"Permanently delete conversation",disabled:e.archiveBlocked,onClick:()=>void e.deletion.confirmDelete(),children:e.deletion.deleting?"Deleting…":"Delete permanently"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):c.jsxDEV(R,{type:"button",variant:"danger","aria-label":"Delete conversation",disabled:e.archiveBlocked,"aria-describedby":u?d:void 0,onClick:e.deletion.requestDelete,children:"Delete conversation"},void 0,!1,void 0,this)),u&&c.jsxDEV("p",{id:d,children:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV("details",{children:[c.jsxDEV("summary",{children:"Sources and attachments"},void 0,!1,void 0,this),c.jsxDEV(we,{cards:e.contextCards,progress:e.progress,session:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV("details",{children:[c.jsxDEV("summary",{children:"File types and limits"},void 0,!1,void 0,this),c.jsxDEV("p",{id:"studio-chat-upload-guidance",children:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var U=I(L(),1);var Ut=250;function Me(e){let{chatClient:t,queryClient:o,sessionId:s,studioBasePath:r,navigate:a}=e,[l,f]=U.useState(s===null),[d,u]=U.useState(!1),[p,b]=U.useState(""),[y,N]=U.useState({query:"",archived:!1,offset:0});U.useEffect(()=>{let E=window.setTimeout(()=>N((T)=>T.query===p.trim()?T:{...T,query:p.trim(),offset:0}),Ut);return()=>window.clearTimeout(E)},[p]);let g=Ke({queryKey:[...q.sessions,y],queryFn:()=>t.listSessions(y)}),m=g.data??[],w=m.find((E)=>E.id===s)??o.getQueriesData({queryKey:q.sessions}).flatMap(([,E])=>E??[]).find((E)=>E.id===s),v=U.useCallback(()=>{u(!1)},[]),k=U.useCallback((E,T=!1)=>{a(Fe(r,E),{preserveWork:T}),f(!1),v()},[a,r,v]),D=async(E)=>{if(!w)return;let T=await t.renameSession(w.id,E);if(!T.renamed)throw Error("The conversation could not be renamed.");o.setQueriesData({queryKey:q.sessions},(V)=>V?.map((W)=>W.id===w.id?{...W,title:T.title}:W)),o.invalidateQueries({queryKey:q.sessions})};return{sessions:m,currentSession:w,archivedSession:w?.archived===!0,sessionControls:{search:p,view:y,error:g.error?"Sessions could not be loaded.":null,onRetry:()=>{g.refetch()},onSearch:b,onView:N},sessionsLoading:g.isPending,navigateToSession:k,conversationsOpen:l,setConversationsOpen:f,detailsOpen:d,setDetailsOpen:u,closeDisclosures:v,renameCurrent:D}}var K=I(L(),1);function Qe(e){let{chatClient:t,draftKey:o,currentDraftKey:s,setUploads:r}=e,[a,l]=K.useState(!1),[f,d]=K.useState([]),u=K.useRef(null),p=K.useCallback(async(g)=>{if(u.current||g.length===0)return;let m=Symbol();if(u.current=m,l(!0),d((w)=>[...w.filter((v)=>!g.some((k)=>k.id===v.id)),...g.map((v)=>({id:v.id,file:v.file,status:"uploading"}))]),await Promise.all(g.map(async(w)=>{try{let v=await t.upload(w.file,w.file.name);if(u.current!==m||s.current!==o)return;r((k)=>[...k,v]),d((k)=>k.filter((D)=>D.id!==w.id))}catch(v){if(u.current!==m||s.current!==o)return;d((k)=>k.map((D)=>D.id===w.id?{...D,status:"failed",error:Y(v,"Upload failed")}:D))}})),u.current===m)u.current=null,l(!1)},[t,o,s,r]),b=K.useCallback(async(g)=>{let m=Array.from(g.target.files??[]);g.target.value="",await p(m.map((w)=>({id:crypto.randomUUID(),file:w,status:"uploading"})))},[p]),y=K.useCallback((g)=>{d((m)=>m.filter((w)=>w.id!==g))},[]),N=K.useCallback(()=>{u.current=null,l(!1),d([])},[]);return{uploading:a,uploadAttempts:f,runUploads:p,uploadFiles:b,dismissAttempt:y,reset:N}}var G=I(L(),1);function We(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,setError:u,navigateToSession:p}=e,[b,y]=G.useState(!1),N=G.useCallback(async()=>{if(!s||f)return;d(!0),y(!0);try{if(await t.archiveSession(s),await o.invalidateQueries({queryKey:q.sessions}),l.current&&a.current===r)p(void 0,!0)}catch(m){if(l.current&&a.current===r)u(Y(m,"Conversation could not be archived"))}finally{if(l.current&&a.current===r)d(!1),y(!1)}},[t,o,s,r,a,l,f,d,u,p]),g=G.useCallback(()=>y(!1),[]);return{archiving:b,archiveCurrent:N,reset:g}}var M=I(L(),1);function $e(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,navigateToSession:u}=e,[p,b]=M.useState(null),[y,N]=M.useState(!1),[g,m]=M.useState(null),w=M.useRef(0),v=M.useRef(!1),k=p===r,D=M.useCallback(()=>{w.current++,v.current=!1,b(null),N(!1),m(null)},[]);return{confirming:k,deleting:y,deleteError:g,requestDelete:()=>{if(!s||f||v.current)return;m(null),b(r)},cancelDelete:()=>{if(!v.current)b(null)},confirmDelete:async()=>{if(!s||!k||f||v.current)return;let W=w.current,B=()=>l.current&&a.current===r&&w.current===W;v.current=!0,N(!0),d(!0),m(null);try{if(!(await t.deleteSession(s)).deleted)throw Error("Deletion was not acknowledged");if(await o.cancelQueries({queryKey:q.messages(s)}),o.removeQueries({queryKey:q.messages(s)}),o.setQueriesData({queryKey:q.sessions},(J)=>J?.filter((z)=>z.id!==s)),o.invalidateQueries({queryKey:q.sessions}),B())b(null),u(void 0,!0)}catch{if(B())m("Deletion could not be confirmed. The conversation may already be deleted. Check history before trying again.")}finally{if(B())v.current=!1,N(!1),d(!1)}},reset:D}}var ee=I(L(),1);function _e(e){let{chatClient:t,handoff:o,sessionId:s,apiPath:r,draftStore:a,draftKey:l,currentDraftKey:f,mountedRef:d,setDraft:u,setError:p,navigateToSession:b}=e,y=ee.useRef(null);ee.useEffect(()=>{if(!o||s)return;let N=`${o.sourceId}\x00${o.itemId}`;if(y.current===N)return;y.current=N,u(o.prompt),p(null);let g=()=>d.current===!0&&f.current===l&&y.current===N;t.openContextSession({version:1,sourceId:o.sourceId,itemId:o.itemId,titleSeed:o.label}).then(({conversationId:m})=>{if(!g())return;a.adopt(l,Ve(r,m)),b(m,!0)}).catch((m)=>{if(!g())return;y.current=null,p(Y(m,"Context could not be attached"))})},[t,o,s,r,a,l,f,d,u,p,b])}var te=I(L(),1);function Ye(e){let{question:t,sessionId:o,setDraft:s}=e,r=te.useRef(null);te.useEffect(()=>{if(!t||o)return;if(r.current===t)return;r.current=t,s(t)},[t,o,s])}var ce=I(L(),1);function je(e){let{onChange:t,draft:o,uploadCount:s,uploadAttemptCount:r,sending:a,uploading:l}=e;ce.useEffect(()=>{t?.({hasDraft:Boolean(o||s||r),busy:a||l})},[o,s,r,a,l,t]),ce.useEffect(()=>()=>t?.({hasDraft:!1,busy:!1}),[t])}var Xe=I(L(),1);var S=I(H(),1);function Ze(e){let t=Date.now(),o=e.sessions.length>0||e.search!==""||e.view.query!==""||e.view.archived||e.view.offset>0,s=S.jsxDEV(R,{className:"studio-chat-new",type:"button",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this),[r]=Xe.useState(()=>Symbol("conversations"));return Z(r,e.phoneHidden===!0?null:{title:"Conversations",action:s}),S.jsxDEV("aside",{className:i("studio-chat-session-picker",n.conversations,e.phoneHidden===!0&&n.conversationsHidden),"aria-label":"Conversations",children:[S.jsxDEV("div",{className:i("studio-chat-session-controls",n.sessionControls),children:[S.jsxDEV("div",{className:i("",n.railHead,n.phoneGoneFlex),children:[S.jsxDEV("h2",{className:i("",n.railTitle),children:"Conversations"},void 0,!1,void 0,this),S.jsxDEV(R,{className:"studio-chat-new",type:"button",variant:"secondary",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&S.jsxDEV(Je,{label:"Conversation search and filters",searchLabel:"Search conversations",search:e.search,onSearch:e.onSearch,filterLabel:"Filter",filterCount:e.view.archived?1:0,filtered:Boolean(e.view.query)||e.view.archived,onClear:()=>{e.onSearch(""),e.onView({...e.view,query:"",archived:!1,offset:0})},children:S.jsxDEV(Ge,{"aria-label":"Show conversations",value:e.view.archived?"archived":"active",onChange:(a)=>e.onView({...e.view,archived:a.target.value==="archived",offset:0}),children:[S.jsxDEV("option",{value:"active",children:"Active conversations"},void 0,!1,void 0,this),S.jsxDEV("option",{value:"archived",children:"Archived conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.error&&S.jsxDEV("p",{role:"alert",children:[e.error," ",S.jsxDEV(R,{type:"button",variant:"ghost",onClick:e.onRetry,children:"Retry sessions"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S.jsxDEV("div",{className:i("studio-chat-session-list",n.sessionList),children:[e.loading?S.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:"Loading conversations…"},void 0,!1,void 0,this):null,!e.loading&&!e.error&&e.sessions.length===0?S.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:e.view.query?"No conversations match this search.":e.view.offset>0?"No more conversations.":e.view.archived?"No archived conversations.":"No conversations yet."},void 0,!1,void 0,this):null,Re(e.sessions,t).map((a)=>S.jsxDEV("section",{"aria-label":a.label,children:[S.jsxDEV("h3",{className:i("",n.dayLabel),children:a.label},void 0,!1,void 0,this),a.sessions.map((l)=>{let f=l.id===e.activeSessionId,d=Te(l,t);return S.jsxDEV("button",{className:i("studio-chat-session",n.session,f&&n.activeSession),"data-active":f?"true":"false","aria-current":f?"true":void 0,type:"button",onClick:()=>e.onSelect(l.id),children:[S.jsxDEV("strong",{className:i("studio-chat-session-title",n.sessionTitle),children:l.title},void 0,!1,void 0,this),S.jsxDEV("small",{className:i("studio-chat-session-note",n.sessionNote),"data-note":d.kind,children:d.kind==="entry"?S.jsxDEV(S.Fragment,{children:[S.jsxDEV("span",{"aria-hidden":"true",className:i("",n.brainMark)},void 0,!1,void 0,this),d.text]},void 0,!0,void 0,this):S.jsxDEV("time",{dateTime:l.lastActiveAt,title:l.lastActiveAt,children:d.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},l.id,!0,void 0,this)})]},a.label,!0,void 0,this)),(e.view.offset>0||e.sessions.length>=25)&&S.jsxDEV(ze,{label:"Conversation pages",offset:e.view.offset,count:e.sessions.length,loading:e.loading,hasNext:e.sessions.length>=25,onPrevious:()=>e.onView({...e.view,offset:Math.max(0,e.view.offset-25)}),onNext:()=>e.onView({...e.view,offset:e.view.offset+25})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var h=I(H(),1);function Kt(e,t,o){return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}function io(e){let t=et(),o=tt(),s=Q.useMemo(()=>ot({apiPath:e.apiPath,fetch:o}),[e.apiPath,o]),{draftStore:r,draftKey:a,currentDraftKey:l,draft:f,uploads:d,setDraft:u,setUploads:p}=vt({draftStore:e.draftStore,apiPath:e.apiPath,sessionId:e.sessionId}),{uploading:b,uploadAttempts:y,runUploads:N,uploadFiles:g,dismissAttempt:m,reset:w}=Qe({chatClient:s,draftKey:a,currentDraftKey:l,setUploads:p}),v=at(),k=Me({chatClient:s,queryClient:t,sessionId:e.sessionId,studioBasePath:e.studioBasePath,navigate:e.navigate}),{navigateToSession:D,closeDisclosures:E}=k,T=Q.useRef(!1),V=Q.useRef(null),{pendingMessages:W,stream:B,sending:F,error:J,interrupted:z,setSending:me,setError:fe,submitPrompt:Ct,respondToApproval:he,runSuggestedAction:St,hasActiveStream:bt,stopActiveStream:kt,abortActiveStream:pe,reset:wt}=yt({chatClient:s,queryClient:t,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,adoptedSessionRef:V,uploads:d,uploading:b,uploadAttemptCount:y.length,navigateToSession:D});_e({chatClient:s,handoff:e.handoff,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,setDraft:u,setError:fe,navigateToSession:D}),Ye({question:e.question,sessionId:e.sessionId,setDraft:u});let ve=Boolean(f)||d.length>0,ye=ve||y.length>0,oe=F||b||ye,{archiving:ge,archiveCurrent:It,reset:Nt}=We({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,setError:fe,navigateToSession:D}),se=$e({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,navigateToSession:D});Q.useEffect(()=>(T.current=!0,()=>{T.current=!1,pe()}),[pe]),je({onChange:e.onNavigationStateChange,draft:f,uploadCount:d.length,uploadAttemptCount:y.length,sending:F,uploading:b});let{visibleMessages:j,contextCards:xt,historyFailed:ie,historyOpening:ae,historyReading:Dt,hasStoredHistory:Rt,retryHistory:Tt}=gt({chatClient:s,sessionId:e.sessionId,sending:F,pendingMessages:W,stream:B}),{ref:Ce,onScroll:Et,awayFromLatest:At,jumpToLatest:Pt}=nt({resetKey:e.sessionId,contentKey:`${j.length}:${B?.text.length??-1}`});Q.useEffect(()=>{if(E(),e.sessionId&&V.current===e.sessionId){V.current=null;return}wt(),w(),Nt(),se.reset()},[e.sessionId]);let Bt=(C)=>{C.preventDefault(),Ct(f)},Se=ct(e.workspaces),be=!ie&&(!e.sessionId||!ae)&&j.length===0?mt({types:e.types.map((C)=>C.entityType),workspaces:e.workspaces.map((C)=>C.id)}):[];return h.jsxDEV(dt,{value:(C)=>e.navigate(C),children:h.jsxDEV("div",{className:i("studio",st.frame,n.root,it.space),"data-view":"chat","data-studio-shell":"",children:[h.jsxDEV(lt,{contextLabel:"Chat",navigation:{types:e.types,workspaces:e.workspaces,activeEntityType:null,activeWorkspaceId:de,workspaceBadges:Se,selectEntityType:e.selectEntityType,selectWorkspace:e.selectWorkspace}},void 0,!1,void 0,this),h.jsxDEV("div",{className:ue("studio-chat-shell",n.shell,ne.shell,v&&ne.shellCollapsed),children:[h.jsxDEV("aside",{className:ue("rail studio-chat-studio-rail",ne.rail),children:h.jsxDEV(rt,{renderMode:"desktop",types:e.types,active:null,onSelect:e.selectEntityType,workspaces:e.workspaces,activeWorkspace:de,workspaceBadges:Se,onSelectWorkspace:e.selectWorkspace},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.jsxDEV("main",{className:i("studio-chat-workspace",n.frame),children:h.jsxDEV("div",{className:i("studio-chat-room",n.room),children:[h.jsxDEV(Ze,{...k.sessionControls,activeSessionId:e.sessionId,loading:k.sessionsLoading,sessions:k.sessions,onNew:()=>D(),onSelect:D,phoneHidden:!k.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("section",{className:i("studio-chat-thread",n.thread,k.conversationsOpen&&n.threadHidden),"aria-label":"Conversation",children:[h.jsxDEV(Ue,{sessionId:e.sessionId,sessions:k,archiving:ge,archiveBlocked:oe,draftPending:ye,onArchive:()=>void It(),deletion:se,contextCards:xt,progress:B?.progress??[],entryHref:(C,re)=>Kt(e.studioBasePath,C,re),onOpenEntry:(C)=>e.navigate(C),phoneShown:!k.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("div",{ref:Ce,tabIndex:0,role:"region","aria-label":"Conversation messages",onScroll:Et,className:i("studio-chat-thread-scroll",n.threadScroll),children:h.jsxDEV("div",{className:i("studio-chat-manuscript",n.manuscript),children:[ie&&h.jsxDEV("section",{role:"alert",children:[h.jsxDEV("p",{children:[Rt?"Showing previously loaded messages. ":"","Conversation could not be loaded."]},void 0,!0,void 0,this),h.jsxDEV(R,{type:"button",variant:"ghost",disabled:Dt,onClick:Tt,children:"Retry conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ae&&e.sessionId&&j.length===0?h.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"Opening conversation…"},void 0,!1,void 0,this):null,!ie&&(!e.sessionId||!ae)&&j.length===0?h.jsxDEV(ft,{},void 0,!1,void 0,this):null,j.map((C)=>h.jsxDEV(ht,{message:C,client:s,disabled:F,speaker:"Your brain",reading:"manuscript",onAction:St,onApproval:he},C.id,!1,void 0,this)),B?.approvals.map((C)=>h.jsxDEV(pt,{approval:C,disabled:F,onDecision:he},C.approvalId,!1,void 0,this)),B&&B.progress.length>0&&h.jsxDEV("details",{className:i("studio-chat-progress",n.card),children:[h.jsxDEV("summary",{children:["Activity · ",B.progress.length," updates"]},void 0,!0,void 0,this),h.jsxDEV("pre",{className:i("",n.source),children:JSON.stringify(B.progress,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?h.jsxDEV("p",{className:i("studio-chat-stream-status",n.empty),role:"status",children:"Responding…"},void 0,!1,void 0,this):null,z&&h.jsxDEV(ke,{interrupted:z,draftPending:ve,restoreBlocked:F||b,onRestore:(C)=>{u(C.text),p([...C.uploads]),Ce.current?.closest(".studio-chat-thread")?.querySelector("textarea")?.focus()}},void 0,!1,void 0,this),J?h.jsxDEV("p",{className:i("studio-chat-error",n.empty,n.error),role:"alert",children:J},void 0,!1,void 0,this):null,h.jsxDEV("div",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h.jsxDEV(ut,{above:be.length>0?h.jsxDEV("div",{"data-studio-chat-starters":"",className:i("studio-chat-starters",n.starters),"aria-label":"Ways to start",children:be.map((C)=>h.jsxDEV("button",{type:"button",className:i("",n.starter),onClick:()=>u(C),children:C},C,!1,void 0,this))},void 0,!1,void 0,this):void 0,onJumpToLatest:At?Pt:void 0,draft:f,sending:F,uploading:b,uploads:d,uploadAttempts:y,onRetryUpload:(C)=>void N([C]),onDismissUpload:m,onDraft:u,locked:ge||se.deleting,onRemoveUpload:(C)=>p((re)=>re.filter((Ht)=>Ht.id!==C)),onFiles:g,onSubmit:Bt,onStop:bt()?kt:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{io as StudioChatWorkspace};
2
2
 
3
- //# debugId=4BFA9551EB39C99D64756E2164756E21
3
+ //# debugId=F653EF7BE547482964756E2164756E21
@@ -18,6 +18,6 @@
18
18
  "/** @jsxImportSource react */\nimport { Button, NativeSelect } from \"@brains/app-ui-react\";\nimport { chatClass, chatLayout } from \"./studio-chat-layout.styles\";\nimport { type ChatSession } from \"@brains/contracts/chat\";\nimport { useState, type ReactElement } from \"react\";\nimport { usePublishPhoneBar } from \"./phone-bar\";\nimport {\n StudioCollectionBar,\n StudioCollectionPager,\n} from \"./studio-collection-controls\";\nimport type { SessionView } from \"./studio-chat-contracts\";\nimport { conversationNote, groupConversations } from \"./chat-conversations\";\n\n/**\n * The conversations beside the open one, by the day each was last active. A\n * conversation about an entry carries the entry's title under its own.\n */\nexport function SessionRail(props: {\n sessions: ChatSession[];\n activeSessionId: string | null;\n loading: boolean;\n search: string;\n view: SessionView;\n error: string | null;\n onRetry: () => void;\n onSearch: (search: string) => void;\n onView: (view: SessionView) => void;\n onNew: () => void;\n onSelect: (id: string) => void;\n /** Hidden on a phone while a conversation is open over it. */\n phoneHidden?: boolean | undefined;\n}): ReactElement {\n // Read once per render: the browser's clock and zone, as the reader has them.\n const now = Date.now();\n const searchable =\n props.sessions.length > 0 ||\n props.search !== \"\" ||\n props.view.query !== \"\" ||\n props.view.archived ||\n props.view.offset > 0;\n const newButton = (\n <Button\n className=\"studio-chat-new\"\n type=\"button\"\n size=\"sm\"\n aria-label=\"New conversation\"\n onClick={props.onNew}\n >\n New\n </Button>\n );\n // On a phone, while the conversations are the screen, the top bar is theirs.\n const [owner] = useState(() => Symbol(\"conversations\"));\n usePublishPhoneBar(\n owner,\n props.phoneHidden === true\n ? null\n : { title: \"Conversations\", action: newButton },\n );\n return (\n <aside\n className={chatClass(\n \"studio-chat-session-picker\",\n chatLayout.conversations,\n props.phoneHidden === true && chatLayout.conversationsHidden,\n )}\n aria-label=\"Conversations\"\n >\n <div\n className={chatClass(\n \"studio-chat-session-controls\",\n chatLayout.sessionControls,\n )}\n >\n <div\n className={chatClass(\n \"\",\n chatLayout.railHead,\n chatLayout.phoneGoneFlex,\n )}\n >\n <h2 className={chatClass(\"\", chatLayout.railTitle)}>Conversations</h2>\n <Button\n className=\"studio-chat-new\"\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n aria-label=\"New conversation\"\n onClick={props.onNew}\n >\n New\n </Button>\n </div>\n {/* Nothing to search until there is a conversation, or a search or\n filter is already in play. */}\n {searchable && (\n <StudioCollectionBar\n label=\"Conversation search and filters\"\n searchLabel=\"Search conversations\"\n search={props.search}\n onSearch={props.onSearch}\n filterLabel=\"Filter\"\n filterCount={props.view.archived ? 1 : 0}\n filtered={Boolean(props.view.query) || props.view.archived}\n onClear={() => {\n props.onSearch(\"\");\n props.onView({\n ...props.view,\n query: \"\",\n archived: false,\n offset: 0,\n });\n }}\n >\n <NativeSelect\n aria-label=\"Show conversations\"\n value={props.view.archived ? \"archived\" : \"active\"}\n onChange={(event) =>\n props.onView({\n ...props.view,\n archived: event.target.value === \"archived\",\n offset: 0,\n })\n }\n >\n <option value=\"active\">Active conversations</option>\n <option value=\"archived\">Archived conversations</option>\n </NativeSelect>\n </StudioCollectionBar>\n )}\n {props.error && (\n <p role=\"alert\">\n {props.error}{\" \"}\n <Button type=\"button\" variant=\"ghost\" onClick={props.onRetry}>\n Retry sessions\n </Button>\n </p>\n )}\n </div>\n <div\n className={chatClass(\n \"studio-chat-session-list\",\n chatLayout.sessionList,\n )}\n >\n {props.loading ? (\n <p className={chatClass(\"studio-chat-empty\", chatLayout.railEmpty)}>\n Loading conversations…\n </p>\n ) : null}\n {!props.loading && !props.error && props.sessions.length === 0 ? (\n <p className={chatClass(\"studio-chat-empty\", chatLayout.railEmpty)}>\n {props.view.query\n ? \"No conversations match this search.\"\n : props.view.offset > 0\n ? \"No more conversations.\"\n : props.view.archived\n ? \"No archived conversations.\"\n : \"No conversations yet.\"}\n </p>\n ) : null}\n {groupConversations(props.sessions, now).map((group) => (\n <section key={group.label} aria-label={group.label}>\n <h3 className={chatClass(\"\", chatLayout.dayLabel)}>\n {group.label}\n </h3>\n {group.sessions.map((session) => {\n const active = session.id === props.activeSessionId;\n const note = conversationNote(session, now);\n return (\n <button\n className={chatClass(\n \"studio-chat-session\",\n chatLayout.session,\n active && chatLayout.activeSession,\n )}\n data-active={active ? \"true\" : \"false\"}\n aria-current={active ? \"true\" : undefined}\n type=\"button\"\n key={session.id}\n onClick={() => props.onSelect(session.id)}\n >\n <strong\n className={chatClass(\n \"studio-chat-session-title\",\n chatLayout.sessionTitle,\n )}\n >\n {session.title}\n </strong>\n <small\n className={chatClass(\n \"studio-chat-session-note\",\n chatLayout.sessionNote,\n )}\n data-note={note.kind}\n >\n {note.kind === \"entry\" ? (\n <>\n <span\n aria-hidden=\"true\"\n className={chatClass(\"\", chatLayout.brainMark)}\n />\n {note.text}\n </>\n ) : (\n <time\n dateTime={session.lastActiveAt}\n title={session.lastActiveAt}\n >\n {note.text}\n </time>\n )}\n </small>\n </button>\n );\n })}\n </section>\n ))}\n {(props.view.offset > 0 || props.sessions.length >= 25) && (\n <StudioCollectionPager\n label=\"Conversation pages\"\n offset={props.view.offset}\n count={props.sessions.length}\n loading={props.loading}\n hasNext={props.sessions.length >= 25}\n onPrevious={() =>\n props.onView({\n ...props.view,\n offset: Math.max(0, props.view.offset - 25),\n })\n }\n onNext={() =>\n props.onView({ ...props.view, offset: props.view.offset + 25 })\n }\n />\n )}\n </div>\n </aside>\n );\n}\n"
19
19
  ],
20
20
  "mappings": "qrBAWA,8BCLM,GAAmE,CACvE,QAAS,UACT,aAAc,kBACd,OAAQ,iBACV,EAMO,SAAS,EAAsB,CAAC,EAOtB,CACf,IAAQ,eAAgB,EACxB,OACE,SAoCE,UApCF,CACE,UAAW,EAAU,2BAA4B,EAAW,KAAK,EACjE,KAAM,EAAY,OAAS,UAAY,SAAW,QAClD,cAAY,OAHd,SAoCE,CA/BA,SAAiD,SAAjD,UAAS,GAAoB,EAAY,OAAzC,qBAAiD,EACjD,SAGE,IAHF,0JAGE,EACD,EAAY,QAAU,SAAyB,IAAzB,UAAI,EAAY,QAAhB,qBAAyB,EAC/C,EAAY,OACX,8BAsBE,CArBA,SAGE,IAHF,iHAGE,EACF,SAUE,EAVF,CACE,KAAK,SACL,QAAQ,QACR,SAAU,EAAM,gBAAkB,EAAM,aACxC,QAAS,IAAM,CACb,GAAI,CAAC,EAAY,OAAS,EAAM,aAAc,OAC9C,EAAM,UAAU,EAAY,K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F7BE547482964756E2164756E21",
22
22
  "names": []
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rizom/brain",
3
- "version": "0.2.0-alpha.870",
3
+ "version": "0.2.0-alpha.872",
4
4
  "description": "Brain runtime + CLI — scaffold, run, and manage AI brain instances",
5
5
  "keywords": [
6
6
  "brain",
@@ -1,3 +0,0 @@
1
- import{Ac as we,qc as c,rc as o,sc as d,uc as me,vc as $e,wc as Me,xc as Le,yc as ve}from"./main-j4wezmkn.js";import{Dc as Ve,Hc as ze,Ic as Je}from"./main-8zx47tjg.js";import{$c as Ke,Bd as H,Cd as F,Nc as x,Pc as y,Qc as J,Tc as te,Wd as Ce,Zc as He,ad as Ye,bd as M,cd as L,ce as qe,de as ee,pd as ke,ud as X,vd as A,wd as je}from"./main-g15rdsa4.js";import{Ee as i}from"./main-4qxa4jpx.js";import{Qf as ne}from"./main-2vaawyz9.js";import{wg as b}from"./main-s8r820px.js";var K=b(ne(),1);var We=i.object({displayName:i.string(),role:i.enum(["admin","trusted","public"]),profileEntityId:i.string().optional(),passkeys:i.array(i.object({id:i.string(),transports:i.array(i.string()).optional(),credentialDeviceType:i.string().optional(),credentialBackedUp:i.boolean(),createdAt:i.number(),updatedAt:i.number()})),appPasswords:i.array(i.object({id:i.string(),username:i.string(),label:i.string(),access:i.enum(["read","write"]),createdAt:i.number(),expiresAt:i.number(),lastUsedAt:i.number().optional()})),connectedChannels:i.array(i.object({type:i.string(),label:i.string(),verifiedAt:i.number()})),pluginSettings:i.array(i.object({id:i.string(),title:i.string(),description:i.string().optional(),configured:i.boolean(),revision:i.number().nullable(),fields:i.array(i.object({name:i.string(),label:i.string(),control:i.enum(["text","url","number","checkbox"]),secret:i.boolean(),required:i.boolean(),value:i.union([i.string(),i.number(),i.boolean(),i.null()]).optional(),set:i.boolean().optional()}))})),sessions:i.array(i.object({id:i.string(),current:i.boolean(),createdAt:i.number(),expiresAt:i.number()}))});function Ge(e){return We.safeParse(e).success}var ge=i.custom(Ge,{message:"Invalid account response"}),ie=i.object({account:ge}),Ze=i.object({account:ge.optional(),appPassword:i.object({username:i.string(),password:i.string()}).optional(),revoked:i.object({sessions:i.number(),refreshTokens:i.number().optional()}).optional(),signedOut:i.boolean().optional()});function Qe(e){return Ze.safeParse(e).success}var Xe=i.custom(Qe,{message:"Invalid account mutation response"}),et=i.custom((e)=>{if(!X(e))return!1;return typeof e.challenge==="string"&&X(e.rp)&&X(e.user)&&Array.isArray(e.pubKeyCredParams)},{message:"Invalid passkey registration options"});class he extends Error{status;constructor(e,t){super(e);this.name="AccountApiError",this.status=t}}async function V(e,t){let n;try{n=await e.json()}catch{n={}}if(!e.ok){let a=typeof n==="object"&&n!==null&&"error"in n&&typeof n.error==="string"?n.error:"Account request failed";throw new he(a,e.status)}return t.parse(n)}function se(e){let t=e.replaceAll("-","+").replaceAll("_","/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),(n)=>n.charCodeAt(0)).buffer}function re(e){let t=new Uint8Array(e),n="";for(let a of t)n+=String.fromCharCode(a);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function tt(e){return{challenge:se(e.challenge),rp:e.rp,user:{...e.user,id:se(e.user.id)},pubKeyCredParams:e.pubKeyCredParams,...e.timeout!==void 0?{timeout:e.timeout}:{},...e.excludeCredentials?{excludeCredentials:e.excludeCredentials.map((t)=>({...t,id:se(t.id)}))}:{},...e.authenticatorSelection?{authenticatorSelection:e.authenticatorSelection}:{},...e.attestation?{attestation:e.attestation}:{},...e.extensions?{extensions:e.extensions}:{}}}var nt=(e,t)=>fetch(e,t);class ce{fetchFn;constructor(e={}){this.fetchFn=e.fetch??nt}async fetchAccount(){return(await V(await this.fetchFn("/auth/account",{credentials:"same-origin",cache:"no-store"}),ie)).account}async mutatePluginSettings(e){return(await V(await this.fetchFn("/auth/account/plugin-settings",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),ie)).account}async mutateAccount(e){return V(await this.fetchFn("/auth/account/mutations",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),Xe)}async registerPasskey(){let e=await V(await this.fetchFn("/auth/account/passkeys/options",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"}),et),t=await navigator.credentials.create({publicKey:tt(e)});if(!(t instanceof PublicKeyCredential))throw Error("Passkey registration was cancelled");if(!(t.response instanceof AuthenticatorAttestationResponse))throw Error("Authenticator returned an invalid passkey response");let n=t.response,a={id:t.id,rawId:re(t.rawId),type:t.type,...t.authenticatorAttachment?{authenticatorAttachment:t.authenticatorAttachment}:{},clientExtensionResults:t.getClientExtensionResults(),response:{clientDataJSON:re(n.clientDataJSON),attestationObject:re(n.attestationObject),transports:typeof n.getTransports==="function"?n.getTransports():[]}};return(await V(await this.fetchFn("/auth/account/passkeys/verify",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),ie.extend({verified:i.literal(!0)}))).account}}function ye(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map((t)=>t.slice(0,1).toUpperCase()).join("")}function Ae(e,t){let n=t.indexOf("/");if(n<=0||n===t.length-1)return;let a=t.slice(0,n),s=t.slice(n+1);return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(a)}/${encodeURIComponent(s)}`}function j(e,t=!1){return new Date(t?e:e*1000).toISOString()}var R=b(x(),1);function z(e){return R.jsxDEV(y,{variant:e.tone==="danger"?"danger":e.tone==="primary"?"primary":"outline",type:e.type??"button",onClick:e.onClick,disabled:e.disabled,children:e.children},void 0,!1,void 0,this)}function U(e){return R.jsxDEV("div",{className:o("account-access-item",c.access),children:[R.jsxDEV(ve,{density:"comfortable",title:e.kind,description:e.description,metadata:e.metadata??[]},void 0,!1,void 0,this),e.action]},void 0,!0,void 0,this)}function C(e){return R.jsxDEV("section",{className:o("account-detail-section",c.section),children:[R.jsxDEV("div",{className:"account-section-label",children:[R.jsxDEV("h3",{className:o("",c.heading,ee.section,e.titleHidden===!0&&c.headingHidden),children:e.title},void 0,!1,void 0,this),e.description?R.jsxDEV("p",{className:o("",c.description),children:e.description},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),R.jsxDEV("div",{className:o("people-stack",c.stack),children:e.children},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function be(e,t){let n=Object.fromEntries(t.entries());for(let a of e)if(a.control==="checkbox")n[a.name]=t.has(a.name);else if(a.control==="number"&&typeof n[a.name]==="string"&&n[a.name]!=="")n[a.name]=Number(n[a.name]);return n}function Se(e){if(e.secret)return"password";if(e.control==="url"||e.control==="number")return e.control;return"text"}var r=b(x(),1);function Ne(e){let{account:t,actions:n,title:a,studioPath:s}=e,g=t.role,h=t.profileEntityId?Ae(s,t.profileEntityId):void 0;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV(C,{title:"Profile",titleHidden:!0,children:[r.jsxDEV("div",{className:o("account-identity",c.identity),children:r.jsxDEV("div",{className:o("people-detail-person",c.person),children:[r.jsxDEV("span",{className:o("people-avatar people-avatar--large",c.avatar),children:ye(a)},void 0,!1,void 0,this),r.jsxDEV("span",{className:o("",c.personCopy),children:[r.jsxDEV("span",{className:o("people-detail-name",c.name,ee.secondaryDisplay),children:a},void 0,!1,void 0,this),r.jsxDEV("span",{"data-account-role":g,className:o("account-role",c.role),children:ke(g)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t.profileEntityId?r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:o("account-profile-note",c.description),children:"Managed by the Anchor profile — your account name follows the published profile."},void 0,!1,void 0,this),r.jsxDEV(U,{kind:"Anchor profile",description:a,action:h?r.jsxDEV(y,{asChild:!0,variant:"link",children:r.jsxDEV("a",{href:h,children:"Edit Anchor Profile →"},void 0,!1,void 0,this)},void 0,!1,void 0,this):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this):r.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(O)=>{O.preventDefault(),n.saveName()},children:[r.jsxDEV("label",{className:o("",c.formLabel),htmlFor:"display-name",children:"Display name"},void 0,!1,void 0,this),r.jsxDEV(J,{id:"display-name",maxLength:200,autoComplete:"name",required:!0,value:n.displayName,onChange:(O)=>n.setDisplayName(O.target.value)},void 0,!1,void 0,this),r.jsxDEV(z,{type:"submit",disabled:n.busy,children:"Save name"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV("p",{className:o("",c.description),children:"Your role controls access to this brain. An administrator manages access in Administration."},void 0,!1,void 0,this),g==="admin"&&r.jsxDEV(y,{asChild:!0,variant:"outline",children:r.jsxDEV("a",{href:Ce(s,"admin:administration"),children:"Manage people in Administration →"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Te(e){let t=e.account.connectedChannels;return r.jsxDEV(C,{title:"Linked identities",titleHidden:!0,description:"How this brain recognizes messages from you. These are your identities, not services configured for the whole brain.",children:t.length===0?r.jsxDEV("p",{className:o("people-empty",c.empty),children:"No linked identities."},void 0,!1,void 0,this):t.map((n)=>r.jsxDEV(U,{kind:n.type,description:n.label,metadata:[`Verified: ${j(n.verifiedAt,!0)}`]},`${n.type}:${n.label}`,!1,void 0,this))},void 0,!1,void 0,this)}function Pe(e){let{account:t,actions:n}=e;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:o("",c.description),children:"Settings for your account only. These do not configure shared services for the brain."},void 0,!1,void 0,this),t.pluginSettings.map((a)=>r.jsxDEV(we,{label:a.title,density:"comfortable",presentation:"disclosure",children:[r.jsxDEV("p",{className:o("account-settings-description",c.description),children:a.description??"Private settings for this account."},void 0,!1,void 0,this),r.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(s)=>{s.preventDefault(),n.saveSettings(a,new FormData(s.currentTarget))},children:[a.fields.map((s)=>r.jsxDEV("label",{htmlFor:`setting-${a.id}-${s.name}`,className:o("",c.field),children:[r.jsxDEV("span",{className:o("",c.formLabel),children:s.label},void 0,!1,void 0,this),s.control==="checkbox"?r.jsxDEV(te,{id:`setting-${a.id}-${s.name}`,name:s.name,defaultChecked:s.value===!0},void 0,!1,void 0,this):r.jsxDEV(J,{id:`setting-${a.id}-${s.name}`,name:s.name,type:Se(s),required:s.required&&(!a.configured||s.secret)&&!s.set,defaultValue:s.secret?"":typeof s.value==="string"||typeof s.value==="number"?s.value:"",placeholder:s.secret&&s.set?"Stored — leave blank to keep":void 0,autoComplete:"off"},void 0,!1,void 0,this)]},s.name,!0,void 0,this)),r.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:[r.jsxDEV(z,{type:"submit",tone:"primary",disabled:n.busy,children:"Save settings"},void 0,!1,void 0,this),a.configured?r.jsxDEV(y,{variant:"danger",disabled:n.busy,type:"button",onClick:()=>n.removeSettings(a),children:"Remove"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},`${a.id}:${a.revision??"unset"}`,!0,void 0,this)]},a.id,!0,void 0,this))]},void 0,!0,void 0,this)}function xe(e){let{account:t,actions:n}=e,{busy:a}=n;return r.jsxDEV("div",{className:o("",c.column),children:[r.jsxDEV(C,{title:"Sign-in",description:"Passkeys used to access this account. Your final passkey is protected from revocation.",children:[t.passkeys.map((s)=>r.jsxDEV(U,{kind:s.credentialBackedUp?"Synced passkey":"Device passkey",metadata:[`Added: ${j(s.createdAt,!0)}`],action:t.passkeys.length>1?r.jsxDEV(y,{variant:"danger",disabled:a,type:"button",onClick:()=>n.revokePasskey(s.id),children:"Revoke"},void 0,!1,void 0,this):void 0},s.id,!1,void 0,this)),r.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:r.jsxDEV(y,{variant:"outline",disabled:a,type:"button",onClick:n.addPasskey,children:"Add passkey"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV(C,{title:"Signed-in sessions",children:t.sessions.map((s)=>r.jsxDEV(U,{kind:s.current?"This session":"Browser session",metadata:[`Started: ${j(s.createdAt)}`,...s.current?["Current browser"]:[]],action:!s.current?r.jsxDEV(y,{variant:"danger",disabled:a,type:"button",onClick:()=>n.revokeSession(s.id),children:"End"},void 0,!1,void 0,this):void 0},s.id,!1,void 0,this))},void 0,!1,void 0,this),r.jsxDEV("footer",{className:o("account-session-actions",c.footer),children:[r.jsxDEV("small",{children:"Access changes require an Admin."},void 0,!1,void 0,this),r.jsxDEV("div",{className:o("",c.actions),children:[r.jsxDEV(z,{disabled:a||t.sessions.every((s)=>s.current),onClick:n.revokeOtherSessions,children:"End other sessions"},void 0,!1,void 0,this),r.jsxDEV(z,{tone:"danger",disabled:a,onClick:n.revokeAllSessions,children:"Sign out everywhere"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Ee=b(ne(),1);function de(e){return new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function le(e){return JSON.stringify(e,null,2)}function Oe(e,t,n){return["Already have servers there? Add only the ",{code:`"${n}"`}," entry inside ",{code:`"${t}"`},` of ${e}.`]}function Re(e){let t=de(e),n="Sign in with your passkey when asked.";return[{id:"claude",group:"primary",name:"Claude",note:["Desktop app and claude.ai."],steps:[["Open Settings → Connectors → Add custom connector."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when asked."]]},{id:"chatgpt",group:"primary",name:"ChatGPT",steps:[["Open Settings → Apps & Connectors → Advanced and turn on Developer mode."],["Choose Create, name it ",{code:t},", paste your brain’s address and pick OAuth."],["Sign in with your passkey when asked."]]},{id:"claude-code",group:"developer",name:"Claude Code",lead:[["Add the server in your terminal:"]],snippet:{label:"Claude Code command",code:`claude mcp add --transport http ${t} ${e}`},after:[["Then start Claude Code, run ",{code:"/mcp"},", choose ",{code:t}," and sign in with your passkey."]]},{id:"cursor",group:"developer",name:"Cursor",steps:[["Open Cursor Settings → MCP → Add new global MCP server."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when Cursor asks."]],lead:[["Or add it to ",{code:"~/.cursor/mcp.json"},":"]],snippet:{label:"Cursor configuration",code:le({mcpServers:{[t]:{url:e}}})},after:[Oe("the file","mcpServers",t)]},{id:"vscode",group:"developer",name:"VS Code",steps:[["Open the Command Palette and run ",{code:"MCP: Add Server"},"."],["Choose HTTP, paste your brain’s address and name it ",{code:t},"."],["Choose Global, then sign in with your passkey when asked."]],lead:[["Or run ",{code:"MCP: Open User Configuration"}," and add:"]],snippet:{label:"VS Code configuration",code:le({servers:{[t]:{type:"http",url:e}}})},after:[Oe("your user configuration","servers",t)]},{id:"other",group:"developer",name:"Any other MCP client",inlineName:"any other MCP client",note:["Look for “add MCP server”, “connector” or “integration” in the tool’s settings and fill in:"],fields:[{label:"Name",value:[{code:t}]},{label:"Type",value:["Remote server, Streamable HTTP — not stdio, not SSE"]},{label:"URL",value:[{code:e}]},{label:"Authentication",value:["OAuth. Leave API key, token, client ID and secret empty; the tool registers itself."]}],lead:[["When you connect, your browser opens “Authorize <tool>?” on your brain. Approve MCP access with your passkey. The tool then has two tools: ",{code:"chat"},", to ask your brain anything as you would in chat, and ",{code:"confirm"},", to approve changes when the brain asks."],["Tool only takes local (stdio) servers, or insists on an API key? Bridge it with ",{code:"mcp-remote"},", which handles the sign-in:"]],snippet:{label:"mcp-remote bridge configuration",code:le({mcpServers:{[t]:{command:"npx",args:["-y","mcp-remote",e]}}})}}]}var u=b(x(),1);function W(e){return u.jsxDEV(u.Fragment,{children:e.text.map((t,n)=>typeof t==="string"?t:u.jsxDEV("code",{className:o("",d.code),children:t.code},n,!1,void 0,this))},void 0,!1,void 0,this)}function _(e){let[t,n]=Ee.useState("idle"),a=async()=>{try{await navigator.clipboard.writeText(e.code),n("copied")}catch{n("unavailable")}};return u.jsxDEV("div",{className:o("ai-tools-snippet",d.snippet),children:[u.jsxDEV("pre",{className:o("",d.snippetCode),"aria-label":e.label,children:e.code},void 0,!1,void 0,this),u.jsxDEV(y,{variant:"outline",size:"sm",onClick:()=>void a(),"aria-label":`Copy ${e.label}`,children:t==="copied"?"Copied":t==="unavailable"?"Select to copy":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function G(e){let{client:t}=e;return u.jsxDEV("article",{className:o("ai-tools-client",d.client),children:[u.jsxDEV("h4",{className:o("",d.clientName),children:t.name},void 0,!1,void 0,this),t.note?u.jsxDEV("p",{className:o("",d.text),children:u.jsxDEV(W,{text:t.note},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,t.steps?u.jsxDEV("ol",{className:o("",d.steps),children:t.steps.map((n,a)=>u.jsxDEV("li",{children:u.jsxDEV(W,{text:n},void 0,!1,void 0,this)},a,!1,void 0,this))},void 0,!1,void 0,this):null,t.fields?u.jsxDEV("dl",{className:o("",d.fields),children:t.fields.map((n)=>u.jsxDEV("div",{className:o("",d.field),children:[u.jsxDEV("dt",{className:o("",d.fieldLabel),children:n.label},void 0,!1,void 0,this),u.jsxDEV("dd",{className:o("",d.fieldValue),children:u.jsxDEV(W,{text:n.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},n.label,!0,void 0,this))},void 0,!1,void 0,this):null,t.lead?.map((n,a)=>u.jsxDEV("p",{className:o("",d.text),children:u.jsxDEV(W,{text:n},void 0,!1,void 0,this)},`lead-${a}`,!1,void 0,this)),t.snippet?u.jsxDEV(_,{...t.snippet},void 0,!1,void 0,this):null,t.after?.map((n,a)=>u.jsxDEV("p",{className:o("",d.text),children:u.jsxDEV(W,{text:n},void 0,!1,void 0,this)},`after-${a}`,!1,void 0,this))]},void 0,!0,void 0,this)}function ot(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function De(e){let t=Re(e.mcpUrl),n=t.filter((s)=>s.group==="primary"),a=t.filter((s)=>s.group==="developer");return u.jsxDEV(C,{title:"AI tools",description:"Connect AI tools you already use to this brain. A connected tool talks to the brain as you do in chat — asking, saving and updating within your access — after you sign in with your passkey.",children:[u.jsxDEV("article",{className:o("ai-tools-address",d.client),children:[u.jsxDEV("h4",{className:o("",d.clientName),children:"Your brain’s address"},void 0,!1,void 0,this),u.jsxDEV(_,{label:"brain address",code:e.mcpUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("div",{className:o("ai-tools-clients",d.clients),children:n.map((s)=>u.jsxDEV(G,{client:s},s.id,!1,void 0,this))},void 0,!1,void 0,this),u.jsxDEV("details",{className:o("ai-tools-developer",d.developer),children:[u.jsxDEV("summary",{className:o("",d.developerSummary),children:["Developer tools and other clients",u.jsxDEV("span",{className:o("",d.developerHint),children:ot(a.map((s)=>s.inlineName??s.name))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("div",{className:o("ai-tools-clients",d.clients,d.developerClients),children:a.map((s)=>u.jsxDEV(G,{client:s},s.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Z=b(ne(),1);var ue="Enter the username and password of an app password from this page.";function Ie(e){let t=new URL(e),n=`${t.protocol==="https:"?"davs":"dav"}://${t.host}${t.pathname}`,a=de(e);return[{id:"macos",group:"file-manager",name:"macOS",note:["Finder, on any Mac."],steps:[["In Finder, choose Go → Connect to Server (⌘K)."],["Paste the address below and click Connect."],["Choose Registered User. ",ue]],snippet:{label:"macOS address",code:e}},{id:"windows",group:"file-manager",name:"Windows",note:["File Explorer, on Windows 10 and 11."],steps:[["In File Explorer, open This PC and choose Map network drive."],["Paste the address below as the folder, tick Connect using different credentials, and click Finish."],[ue]],snippet:{label:"Windows address",code:e}},{id:"gnome-files",group:"file-manager",name:"GNOME Files",note:["The file manager on Ubuntu, Fedora and other GNOME desktops."],steps:[["Open Files → Other Locations (or Network)."],["Under Connect to Server, enter the address below and connect."],[ue]],snippet:{label:"GNOME Files address",code:n}},{id:"rclone",group:"command-line",name:"rclone",note:["Linux, macOS and Windows, from a terminal."],lead:[["Store the drive as a remote, with your app password’s username and password:"]],snippet:{label:"rclone remote command",code:`rclone config create ${a} webdav url=${e} vendor=other user=YOUR_USERNAME pass=YOUR_PASSWORD --obscure`},after:[["Then mount it on an empty folder: ",{code:`rclone mount ${a}: ~/Brain --vfs-cache-mode writes`},"."]]}]}var l=b(x(),1),oe="app-password-label",Ue="app-password-write";function pe(e){return j(e).slice(0,10)}function at(e,t){return[`Created: ${pe(e.createdAt)}`,`${e.expiresAt<=t?"Expired":"Expires"}: ${pe(e.expiresAt)}`,e.lastUsedAt===void 0?"Never used":`Last used: ${pe(e.lastUsedAt)}`]}function Fe(e){let{account:t,actions:n,connect:a}=e,{busy:s,createdAppPassword:g}=n,[h,O]=Z.useState(void 0),v=a!==void 0&&h!==void 0?$e(g,h,t.appPasswords,me(a)):null;Z.useEffect(()=>{if(a&&v)Me(a,v)},[a,v]);let N=Math.floor(Date.now()/1000),[T,S]=Z.useState(!1),D=Ie(e.davUrl),I=D.filter((f)=>f.group==="file-manager"),E=D.filter((f)=>f.group==="command-line");return l.jsxDEV("div",{className:o("",c.column),children:[l.jsxDEV(C,{title:"Drive",description:"Mount this brain as a network drive. It shows the notes, posts and files you can see here, as folders and files, to open and edit on your computer.",children:[a?l.jsxDEV(Le,{connect:a,created:v,busy:s||h!==void 0&&v===null,onConnect:()=>{O(g?.username??null),n.createAppPassword(me(a),"write")}},void 0,!1,void 0,this):null,l.jsxDEV("article",{className:o("drive-address",d.client),children:[l.jsxDEV("h4",{className:o("",d.clientName),children:"Your brain’s drive address"},void 0,!1,void 0,this),l.jsxDEV(_,{label:"drive address",code:e.davUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV(C,{title:"App passwords",description:"A mount signs in with an app password instead of your passkey. It works only for the drive, expires after a year and can be revoked here. It can only read unless you allow saving changes.",children:[g&&g!==v?l.jsxDEV("article",{"data-app-password-reveal":!0,className:o("drive-reveal",d.client),children:[l.jsxDEV("h4",{className:o("",d.clientName),children:"Your new app password"},void 0,!1,void 0,this),l.jsxDEV("p",{className:o("",d.text),children:"Copy both now. The password is shown only once."},void 0,!1,void 0,this),l.jsxDEV(_,{label:"username",code:g.username},void 0,!1,void 0,this),l.jsxDEV(_,{label:"password",code:g.password},void 0,!1,void 0,this),l.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:l.jsxDEV(y,{variant:"outline",type:"button",onClick:n.dismissCreatedAppPassword,children:"Done"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,t.appPasswords.length===0?l.jsxDEV("p",{className:o("",d.text),children:"No app passwords yet."},void 0,!1,void 0,this):t.appPasswords.map((f)=>l.jsxDEV(U,{kind:f.label,description:`${f.username} · ${f.access==="write"?"Read and write":"Read-only"}`,metadata:at(f,N),action:l.jsxDEV(y,{variant:"danger",disabled:s,type:"button",onClick:()=>n.revokeAppPassword(f.id),children:"Revoke"},void 0,!1,void 0,this)},f.id,!1,void 0,this)),l.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(f)=>{f.preventDefault();let Y=f.currentTarget,P=String(new FormData(Y).get(oe)??"");if(P.trim()==="")return;n.createAppPassword(P.trim(),T?"write":"read"),Y.reset(),S(!1)},children:[l.jsxDEV("label",{htmlFor:oe,className:o("",c.field),children:[l.jsxDEV("span",{className:o("",c.formLabel),children:"Name it after the computer it is for"},void 0,!1,void 0,this),l.jsxDEV(J,{id:oe,name:oe,type:"text",required:!0,maxLength:100,placeholder:"Laptop",autoComplete:"off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("label",{htmlFor:Ue,className:o("",c.field),children:[l.jsxDEV("span",{className:o("",c.formLabel),children:"Allow saving changes"},void 0,!1,void 0,this),l.jsxDEV(te,{id:Ue,"aria-label":"Allow saving changes",checked:T,onCheckedChange:S},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:l.jsxDEV(y,{variant:"outline",disabled:s,type:"submit",children:"New app password"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV(C,{title:"Use it in Obsidian",description:"Keep an Obsidian vault on your computer in step with your brain. Obsidian stays fast and works offline; notes and images sync in the background.",children:l.jsxDEV("article",{className:o("drive-obsidian",d.client),children:[l.jsxDEV("h4",{className:o("",d.clientName),children:"Rizom Brain"},void 0,!1,void 0,this),l.jsxDEV("ol",{className:o("",d.steps),children:[l.jsxDEV("li",{children:"Install the Rizom Brain plugin in Obsidian and turn it on."},void 0,!1,void 0,this),l.jsxDEV("li",{children:["In its settings, enter your brain’s address:"," ",l.jsxDEV("code",{children:new URL(e.davUrl).host},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("li",{children:"Choose Connect, and confirm on the page that opens here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),l.jsxDEV(C,{title:"Connect your computer",description:"Use your computer’s own file manager. The brain then appears as a drive beside your other folders.",children:[l.jsxDEV("div",{className:o("drive-clients",d.clients),children:I.map((f)=>l.jsxDEV(G,{client:f},f.id,!1,void 0,this))},void 0,!1,void 0,this),l.jsxDEV("details",{className:o("drive-command-line",d.developer),children:[l.jsxDEV("summary",{className:o("",d.developerSummary),children:["Command line",l.jsxDEV("span",{className:o("",d.developerHint),children:E.map((f)=>f.name).join(", ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:o("drive-command-line-clients",d.clients,d.developerClients),children:E.map((f)=>l.jsxDEV(G,{client:f},f.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var w=b(ne(),1);var ae={revokePasskey:{title:"Revoke this passkey?",message:"You will not be able to use this passkey again.",confirmLabel:"Revoke passkey",pending:"Revoking passkey…",complete:"Passkey revoked."},revokeSession:{title:"End this browser session?",message:"That browser will need a passkey to sign in again.",confirmLabel:"End session",pending:"Ending session…",complete:"Session ended."},revokeAppPassword:{title:"Revoke this app password?",message:"Anything mounted with it stops working at once. Its password cannot be recovered.",confirmLabel:"Revoke app password",pending:"Revoking app password…",complete:"App password revoked."},revokeOtherSessions:{title:"End every other browser session?",message:"Your current browser will remain signed in.",confirmLabel:"End other sessions",pending:"Ending other sessions…",complete:"Other sessions ended."}};function Be(e){return je(e,"Account request failed")}function _e(e){let{client:t,initialAccount:n}=e,[a,s]=w.useState(n),[g,h]=w.useState(n?.displayName??e.initialDisplayName),[O,v]=w.useState(""),[N,T]=w.useState(!1),[S,D]=w.useState(!1),[I,E]=w.useState(null),[f,Y]=w.useState(null);w.useEffect(()=>{if(n)return;let p=!1;return t.fetchAccount().then((k)=>{if(p)return;s(k),h(k.displayName)}).catch((k)=>{if(p)return;T(!0),v(Be(k))}),()=>{p=!0}},[t,n]);let P=w.useCallback(async(p,k,B)=>{D(!0),T(!1),v(p);try{let q=await B();if(q)s(q),h(q.displayName);v(k)}catch(q){T(!0),v(Be(q))}finally{D(!1)}},[]),fe=async(p)=>(await t.mutateAccount(p)).account,Q=(p,k)=>E({title:p.title,message:p.message,confirmLabel:p.confirmLabel,action:()=>{P(p.pending,p.complete,()=>fe(k))}});return{account:a,displayName:g,setDisplayName:h,status:O,error:N,busy:S,confirmation:I,cancelConfirmation:()=>E(null),confirm:()=>{if(!I)return;E(null),I.action()},saveName:()=>{P("Saving…","Display name updated.",()=>fe({action:A.updateDisplayName,confirmation:A.updateDisplayName,displayName:g}))},addPasskey:()=>{P("Waiting for your authenticator…","Passkey added.",()=>t.registerPasskey())},revokePasskey:(p)=>Q(ae.revokePasskey,{action:A.revokePasskey,confirmation:A.revokePasskey,credentialId:p}),revokeSession:(p)=>Q(ae.revokeSession,{action:A.revokeSession,confirmation:A.revokeSession,sessionId:p}),revokeOtherSessions:()=>Q(ae.revokeOtherSessions,{action:A.revokeOtherSessions,confirmation:A.revokeOtherSessions}),revokeAllSessions:()=>E({title:"Sign out everywhere?",message:"This ends every session, including this one. You will need your passkey to return.",confirmLabel:"Sign out everywhere",action:()=>{P("Signing out everywhere…","Signed out.",async()=>{await t.mutateAccount({action:A.revokeAllSessions,confirmation:A.revokeAllSessions}),window.location.assign(`/login?return_to=${encodeURIComponent(e.routePath)}`);return})}}),saveSettings:(p,k)=>{let B=be(p.fields,k);P(`Saving ${p.title}…`,`${p.title} updated.`,()=>t.mutatePluginSettings({action:"save",definitionId:p.id,values:B}))},createdAppPassword:f,createAppPassword:(p,k)=>{P("Creating app password…","App password created.",async()=>{let B=await t.mutateAccount({action:A.createAppPassword,confirmation:A.createAppPassword,label:p,...k==="write"?{access:k}:{}});return Y(B.appPassword??null),B.account})},dismissCreatedAppPassword:()=>Y(null),revokeAppPassword:(p)=>Q(ae.revokeAppPassword,{action:A.revokeAppPassword,confirmation:A.revokeAppPassword,appPasswordId:p}),removeSettings:(p)=>E({title:`Remove ${p.title}?`,message:"The stored settings for this integration will be removed from your account only.",confirmLabel:"Remove settings",action:()=>{P(`Removing ${p.title}…`,`${p.title} removed.`,()=>t.mutatePluginSettings({action:"delete",definitionId:p.id}))}})}}var m=b(x(),1),it=["profile","security","identities","settings",H,F];function st(e){let t=e.connect?F:it.find((n)=>n===e.initialSection);if(!t||t===H&&!e.mcpUrl||t===F&&!e.davUrl)return"profile";return t}function rt(e){let t=["your profile","sign-in security","linked identities",...e.settings?["personal settings"]:[],...e.aiTools?["AI tools"]:[],...e.drive?["your drive"]:[]];return`Your account on this brain. Manage ${`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`} here—not shared services or other people’s access.`}function cn({bootstrap:e,initialAccount:t,client:n}){let a=qe(),s=K.useMemo(()=>n??new ce({fetch:a.fetch}),[n,a]),g=_e({client:s,initialAccount:t,initialDisplayName:e.displayName,routePath:e.routePath}),{account:h,status:O,error:v,busy:N,confirmation:T}=g,[S,D]=K.useState(()=>st(e));K.useEffect(()=>{document.querySelector('.account-tabs [role="tab"][aria-selected="true"]')?.scrollIntoView({block:"nearest",inline:"nearest"})},[S]);let I=h?.displayName??e.displayName;return m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:o("account-shell",c.shell,Ve.inset),children:[m.jsxDEV(Je,{model:{access:ze("public"),title:"Your account",totals:[]}},void 0,!1,void 0,this),m.jsxDEV("p",{className:o("account-scope",c.description),children:rt({settings:(h?.pluginSettings.length??0)>0,aiTools:Boolean(e.mcpUrl),drive:Boolean(e.davUrl)})},void 0,!1,void 0,this),m.jsxDEV("p",{className:o(`account-status${v?" is-error":""}`,c.feedback,v&&c.feedbackError),role:"status","aria-live":"polite",children:O},void 0,!1,void 0,this),!h?m.jsxDEV("p",{className:o("account-loading",c.loading),children:"Reading your account…"},void 0,!1,void 0,this):m.jsxDEV(Ke,{className:"account-details",value:S,onValueChange:D,children:[m.jsxDEV(Ye,{"aria-label":"Account sections",className:o("account-tabs",c.tabs),children:[m.jsxDEV(M,{value:"profile",disabled:N,children:"Profile"},void 0,!1,void 0,this),m.jsxDEV(M,{value:"security",disabled:N,children:"Sign-in & sessions"},void 0,!1,void 0,this),m.jsxDEV(M,{value:"identities",disabled:N,children:"Linked identities"},void 0,!1,void 0,this),h.pluginSettings.length>0&&m.jsxDEV(M,{value:"settings",disabled:N,children:"Personal settings"},void 0,!1,void 0,this),e.mcpUrl&&m.jsxDEV(M,{value:H,disabled:N,children:"AI tools"},void 0,!1,void 0,this),e.davUrl&&m.jsxDEV(M,{value:F,disabled:N,children:"Drive"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV(L,{value:"profile",forceMount:!0,hidden:S!=="profile",className:o("account-detail-sections",c.tabPanel),children:m.jsxDEV(Ne,{account:h,actions:g,title:I,studioPath:e.studioPath},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV(L,{value:"identities",forceMount:!0,hidden:S!=="identities",className:o("",c.tabPanel),children:m.jsxDEV(Te,{account:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.pluginSettings.length>0&&m.jsxDEV(L,{value:"settings",forceMount:!0,hidden:S!=="settings",className:o("",c.tabPanel),children:m.jsxDEV(Pe,{account:h,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV(L,{value:"security",forceMount:!0,hidden:S!=="security",className:o("",c.tabPanel),children:m.jsxDEV(xe,{account:h,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.mcpUrl&&m.jsxDEV(L,{value:H,forceMount:!0,hidden:S!==H,className:o("",c.tabPanel),children:m.jsxDEV(De,{mcpUrl:e.mcpUrl},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.davUrl&&m.jsxDEV(L,{value:F,forceMount:!0,hidden:S!==F,className:o("",c.tabPanel),children:m.jsxDEV(Fe,{davUrl:e.davUrl,account:h,actions:g,connect:e.connect},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T&&m.jsxDEV(He,{mark:"!",title:T.title,titleId:"account-confirmation-title",cancelLabel:"Cancel",confirmLabel:T.confirmLabel,confirmVariant:"danger",pending:N,onCancel:g.cancelConfirmation,onConfirm:g.confirm,children:m.jsxDEV("p",{children:T.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{cn as AccountApp};
2
-
3
- //# debugId=BFBE14544609986064756E2164756E21