@dxos/plugin-assistant 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs +31 -0
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs.map +7 -0
- package/dist/lib/browser/ChatCompanion-GFSJZTOT.mjs +153 -0
- package/dist/lib/browser/ChatCompanion-GFSJZTOT.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-IHAPBIZE.mjs +72 -0
- package/dist/lib/browser/ChatContainer-IHAPBIZE.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-EGRMPCTL.mjs +85 -0
- package/dist/lib/browser/ChatDialog-EGRMPCTL.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs +53 -0
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs.map +7 -0
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs +21 -0
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs +212 -0
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs +14 -0
- package/dist/lib/browser/blueprints/index.mjs +12 -0
- package/dist/lib/browser/chunk-A75V4MOQ.mjs +1832 -0
- package/dist/lib/browser/chunk-A75V4MOQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7ZJIXQ2Y.mjs → chunk-DKQMSMBN.mjs} +54 -63
- package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WBG5PTSX.mjs → chunk-EXVT7D4B.mjs} +1 -1
- package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2BOE3OTW.mjs → chunk-ML3QCFKA.mjs} +23 -20
- package/dist/lib/browser/chunk-ML3QCFKA.mjs.map +7 -0
- package/dist/lib/browser/chunk-MRJVYGLU.mjs +208 -0
- package/dist/lib/browser/chunk-MRJVYGLU.mjs.map +7 -0
- package/dist/lib/browser/chunk-V772AMZM.mjs +250 -0
- package/dist/lib/browser/chunk-V772AMZM.mjs.map +7 -0
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs +41 -0
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs +20 -0
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +156 -174
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs +19 -0
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs +132 -0
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-ECKZNDSU.mjs → react-surface-S7SBFOSW.mjs} +41 -30
- package/dist/lib/browser/react-surface-S7SBFOSW.mjs.map +7 -0
- package/dist/lib/browser/{repair-3MZXLUHO.mjs → repair-6QGAKOVM.mjs} +23 -13
- package/dist/lib/browser/repair-6QGAKOVM.mjs.map +7 -0
- package/dist/lib/browser/settings-4ZDLUMYE.mjs +32 -0
- package/dist/lib/browser/settings-4ZDLUMYE.mjs.map +7 -0
- package/dist/lib/browser/state-AN6336ZX.mjs +26 -0
- package/dist/lib/browser/state-AN6336ZX.mjs.map +7 -0
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs +18 -0
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +8 -4
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs +32 -0
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs.map +7 -0
- package/dist/lib/node-esm/ChatCompanion-UR7DXZ54.mjs +154 -0
- package/dist/lib/node-esm/ChatCompanion-UR7DXZ54.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-YMLLGOZK.mjs +73 -0
- package/dist/lib/node-esm/ChatContainer-YMLLGOZK.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-D24WJPK4.mjs +86 -0
- package/dist/lib/node-esm/ChatDialog-D24WJPK4.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs +54 -0
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs +22 -0
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs +213 -0
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-RDCLLIQH.mjs → blueprint-definition-SEMDEIYG.mjs} +6 -4
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +13 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-355W5B27.mjs +251 -0
- package/dist/lib/node-esm/chunk-355W5B27.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4BERCIES.mjs +1833 -0
- package/dist/lib/node-esm/chunk-4BERCIES.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CKW4IYLY.mjs → chunk-75PHXBN3.mjs} +54 -63
- package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs +209 -0
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs +42 -0
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WE6KTH72.mjs → chunk-POWB2BPC.mjs} +1 -1
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3Q22TTXW.mjs → chunk-ZRIPP7YF.mjs} +23 -20
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs.map +7 -0
- package/dist/lib/node-esm/{edge-model-resolver-2ARXDOYS.mjs → edge-model-resolver-G5KMODPO.mjs} +9 -7
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +156 -174
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs +20 -0
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs +133 -0
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-NLIG5VAI.mjs → react-surface-ZR6FXGLF.mjs} +41 -30
- package/dist/lib/node-esm/react-surface-ZR6FXGLF.mjs.map +7 -0
- package/dist/lib/node-esm/{repair-RER5H7Y6.mjs → repair-QJ7CQDKU.mjs} +23 -13
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs.map +7 -0
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs +33 -0
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs.map +7 -0
- package/dist/lib/node-esm/state-HDON4REW.mjs +27 -0
- package/dist/lib/node-esm/state-HDON4REW.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs +19 -0
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +8 -4
- package/dist/types/src/AssistantPlugin.d.ts +2 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/assistant-blueprint.d.ts +209 -0
- package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +7 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
- package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +21 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +4 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +6 -0
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +10 -12
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +12 -0
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/repair/index.d.ts +3 -0
- package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
- package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +15 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +17 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +11 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +13 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -2
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +9 -10
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +1 -1
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +2 -2
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +10 -5
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +4 -3
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/PromptArticle.d.ts +1 -1
- package/dist/types/src/components/PromptArticle.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +11 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -1
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +3 -3
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -5
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/index.d.ts +2 -0
- package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +10 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +1 -1
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/functions/object-list.d.ts +1 -1
- package/dist/types/src/functions/object-list.d.ts.map +1 -1
- package/dist/types/src/functions/object-load.d.ts.map +1 -1
- package/dist/types/src/functions/object-search.d.ts +10 -0
- package/dist/types/src/functions/object-search.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -5
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +3 -3
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextObjects.d.ts +7 -7
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
- package/dist/types/src/hooks/useFilteredTypes.d.ts +2 -3
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +10 -9
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts.map +1 -1
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +3 -2
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +16 -19
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +88 -122
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +33 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +11 -260
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +113 -92
- package/src/AssistantPlugin.tsx +62 -90
- package/src/blueprints/assistant-blueprint.ts +62 -0
- package/src/blueprints/index.ts +12 -0
- package/src/capabilities/ai-service/ai-service.ts +29 -0
- package/src/capabilities/ai-service/index.ts +7 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +180 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +60 -0
- package/src/capabilities/blueprint-definition/index.ts +8 -0
- package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +32 -0
- package/src/capabilities/edge-model-resolver/index.ts +7 -0
- package/src/capabilities/index.ts +10 -15
- package/src/capabilities/local-model-resolver/index.ts +7 -0
- package/src/capabilities/local-model-resolver/local-model-resolver.ts +37 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +110 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +95 -0
- package/src/capabilities/repair/index.ts +7 -0
- package/src/capabilities/{repair.ts → repair/repair.ts} +23 -9
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +30 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +27 -0
- package/src/capabilities/toolkit/index.ts +7 -0
- package/src/capabilities/toolkit/toolkit.ts +26 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +13 -5
- package/src/components/BlueprintArticle.tsx +4 -4
- package/src/components/Chat/Chat.tsx +68 -68
- package/src/components/Chat/events.ts +1 -1
- package/src/components/ChatCompanion.tsx +125 -117
- package/src/components/ChatContainer.tsx +19 -19
- package/src/components/ChatDialog.tsx +6 -7
- package/src/components/ChatProgress/ChatProgress.tsx +3 -16
- package/src/components/ChatPrompt/ChatActions.tsx +1 -1
- package/src/components/ChatPrompt/ChatOptions.tsx +62 -58
- package/src/components/ChatPrompt/ChatReferences.tsx +5 -6
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +10 -8
- package/src/components/ChatThread/ChatThread.tsx +1 -1
- package/src/components/ChatThread/Link.tsx +2 -2
- package/src/components/ChatThread/registry.tsx +2 -2
- package/src/components/ChatThread/sync.test.ts +12 -5
- package/src/components/ChatThread/sync.ts +8 -2
- package/src/components/PromptArticle.tsx +8 -9
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateEditor.tsx +7 -4
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +14 -6
- package/src/components/TemplateEditor/TemplateForm.tsx +75 -28
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +10 -5
- package/src/components/ToolBlock/ToolBlock.tsx +6 -6
- package/src/components/Toolbox/Toolbox.stories.tsx +8 -9
- package/src/components/Toolbox/Toolbox.tsx +14 -15
- package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
- package/src/components/Typewriter/Typewriter.stories.tsx +83 -0
- package/src/components/Typewriter/Typewriter.tsx +54 -0
- package/src/components/Typewriter/assistant-extension.tsx +144 -0
- package/src/components/Typewriter/index.ts +5 -0
- package/src/functions/index.ts +1 -1
- package/src/functions/object-list.ts +4 -3
- package/src/functions/object-load.ts +6 -4
- package/src/functions/object-search.ts +46 -0
- package/src/hooks/useBlueprintRegistry.ts +30 -20
- package/src/hooks/useChatProcessor.ts +5 -2
- package/src/hooks/useChatServices.ts +11 -15
- package/src/hooks/useChatToolbarActions.ts +24 -25
- package/src/hooks/useContextBinder.ts +4 -2
- package/src/hooks/useContextObjects.ts +13 -25
- package/src/hooks/useFilteredTypes.ts +6 -7
- package/src/hooks/useReferencesProvider.ts +6 -6
- package/src/index.ts +0 -1
- package/src/meta.ts +2 -2
- package/src/processor/processor.test.ts +3 -2
- package/src/processor/processor.ts +23 -25
- package/src/processor/update-name.ts +4 -1
- package/src/queue-logger.ts +4 -1
- package/src/testing/test-generator.ts +4 -3
- package/src/testing/test-services.ts +8 -6
- package/src/types/Assistant.ts +5 -6
- package/src/types/AssistantAction.ts +58 -62
- package/src/types/capabilities.ts +27 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +3 -1
- package/src/types/service.ts +10 -7
- package/dist/lib/browser/BlueprintArticle-BWSLH6LG.mjs +0 -36
- package/dist/lib/browser/BlueprintArticle-BWSLH6LG.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-OSZZZSWV.mjs +0 -158
- package/dist/lib/browser/ChatCompanion-OSZZZSWV.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-2W6FNSJD.mjs +0 -77
- package/dist/lib/browser/ChatContainer-2W6FNSJD.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-XQ3KDYWE.mjs +0 -90
- package/dist/lib/browser/ChatDialog-XQ3KDYWE.mjs.map +0 -7
- package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs +0 -59
- package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs.map +0 -7
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +0 -19
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-LM6GVHQO.mjs +0 -199
- package/dist/lib/browser/app-graph-builder-LM6GVHQO.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-VBEOXNBS.mjs +0 -12
- package/dist/lib/browser/chunk-2BOE3OTW.mjs.map +0 -7
- package/dist/lib/browser/chunk-5JZRYQZL.mjs +0 -229
- package/dist/lib/browser/chunk-5JZRYQZL.mjs.map +0 -7
- package/dist/lib/browser/chunk-7ZJIXQ2Y.mjs.map +0 -7
- package/dist/lib/browser/chunk-LRE4VEZV.mjs +0 -16
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +0 -7
- package/dist/lib/browser/chunk-NC2QNMBF.mjs +0 -176
- package/dist/lib/browser/chunk-NC2QNMBF.mjs.map +0 -7
- package/dist/lib/browser/chunk-PWSTPQUY.mjs +0 -1929
- package/dist/lib/browser/chunk-PWSTPQUY.mjs.map +0 -7
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +0 -18
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-EEYS2GJF.mjs +0 -143
- package/dist/lib/browser/intent-resolver-EEYS2GJF.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +0 -17
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ECKZNDSU.mjs.map +0 -7
- package/dist/lib/browser/repair-3MZXLUHO.mjs.map +0 -7
- package/dist/lib/browser/settings-HD5WA24I.mjs +0 -23
- package/dist/lib/browser/settings-HD5WA24I.mjs.map +0 -7
- package/dist/lib/browser/state-GG7Z3NB7.mjs +0 -25
- package/dist/lib/browser/state-GG7Z3NB7.mjs.map +0 -7
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs +0 -17
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs +0 -37
- package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-IUMU7WRQ.mjs +0 -159
- package/dist/lib/node-esm/ChatCompanion-IUMU7WRQ.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-CTUNUEU3.mjs +0 -78
- package/dist/lib/node-esm/ChatContainer-CTUNUEU3.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-X42ASXQD.mjs +0 -91
- package/dist/lib/node-esm/ChatDialog-X42ASXQD.mjs.map +0 -7
- package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs +0 -60
- package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +0 -20
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-6XUAGTRS.mjs +0 -200
- package/dist/lib/node-esm/app-graph-builder-6XUAGTRS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-25GMMNY5.mjs +0 -178
- package/dist/lib/node-esm/chunk-25GMMNY5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CKW4IYLY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs +0 -230
- package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs +0 -17
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z37USO4K.mjs +0 -1930
- package/dist/lib/node-esm/chunk-Z37USO4K.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-4SRYLDK5.mjs +0 -144
- package/dist/lib/node-esm/intent-resolver-4SRYLDK5.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +0 -18
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NLIG5VAI.mjs.map +0 -7
- package/dist/lib/node-esm/repair-RER5H7Y6.mjs.map +0 -7
- package/dist/lib/node-esm/settings-YJQVKHH5.mjs +0 -24
- package/dist/lib/node-esm/settings-YJQVKHH5.mjs.map +0 -7
- package/dist/lib/node-esm/state-FSUHFMDM.mjs +0 -26
- package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +0 -18
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +0 -7
- package/dist/types/src/capabilities/ai-service.d.ts +0 -4
- package/dist/types/src/capabilities/ai-service.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -7
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -10
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +0 -10
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair.d.ts +0 -4
- package/dist/types/src/capabilities/repair.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -4
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit.d.ts +0 -4
- package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/functions/analysis.d.ts +0 -5
- package/dist/types/src/functions/analysis.d.ts.map +0 -1
- package/src/capabilities/ai-service.ts +0 -27
- package/src/capabilities/app-graph-builder.ts +0 -210
- package/src/capabilities/blueprint-definition.ts +0 -66
- package/src/capabilities/capabilities.ts +0 -17
- package/src/capabilities/edge-model-resolver.ts +0 -25
- package/src/capabilities/intent-resolver.ts +0 -135
- package/src/capabilities/local-model-resolver.ts +0 -30
- package/src/capabilities/react-surface.tsx +0 -87
- package/src/capabilities/settings.ts +0 -19
- package/src/capabilities/state.ts +0 -22
- package/src/capabilities/toolkit.ts +0 -17
- package/src/events.ts +0 -11
- package/src/functions/analysis.ts +0 -22
- /package/dist/lib/browser/{blueprint-definition-VBEOXNBS.mjs.map → blueprint-definition-DGHH7MUU.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-RDCLLIQH.mjs.map → browser/blueprints/index.mjs.map} +0 -0
|
@@ -1,1929 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AiChatProcessor,
|
|
3
|
-
AiServicePresets
|
|
4
|
-
} from "./chunk-2BOE3OTW.mjs";
|
|
5
|
-
import {
|
|
6
|
-
AssistantAction_exports,
|
|
7
|
-
Assistant_exports,
|
|
8
|
-
LLM_PROVIDERS,
|
|
9
|
-
ServiceType
|
|
10
|
-
} from "./chunk-5JZRYQZL.mjs";
|
|
11
|
-
import {
|
|
12
|
-
meta
|
|
13
|
-
} from "./chunk-WBG5PTSX.mjs";
|
|
14
|
-
|
|
15
|
-
// src/components/AssistantSettings/AssistantSettings.tsx
|
|
16
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
17
|
-
import React from "react";
|
|
18
|
-
import { DEFAULT_EDGE_MODELS, DEFAULT_OLLAMA_MODELS } from "@dxos/ai";
|
|
19
|
-
import { Input, Select, useTranslation } from "@dxos/react-ui";
|
|
20
|
-
import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
21
|
-
var DEFAULT_VALUE = "__default";
|
|
22
|
-
var LLM_PROVIDER_LABELS = {
|
|
23
|
-
edge: "DXOS",
|
|
24
|
-
ollama: "Ollama",
|
|
25
|
-
lmstudio: "LM Studio"
|
|
26
|
-
};
|
|
27
|
-
var AssistantSettings = ({ settings }) => {
|
|
28
|
-
var _effect = _useSignals();
|
|
29
|
-
try {
|
|
30
|
-
const { t } = useTranslation(meta.id);
|
|
31
|
-
return /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
|
|
32
|
-
title: t("settings title", {
|
|
33
|
-
ns: meta.id
|
|
34
|
-
})
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(ControlGroup, null, /* @__PURE__ */ React.createElement(ControlItemInput, {
|
|
36
|
-
title: t("settings custom prompts label")
|
|
37
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
38
|
-
checked: !!settings.customPrompts,
|
|
39
|
-
onCheckedChange: (checked) => settings.customPrompts = checked
|
|
40
|
-
})), /* @__PURE__ */ React.createElement(ControlItemInput, {
|
|
41
|
-
title: t("settings llm provider label")
|
|
42
|
-
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
43
|
-
value: settings.llmProvider ?? "edge",
|
|
44
|
-
onValueChange: (value) => {
|
|
45
|
-
settings.llmProvider = value === DEFAULT_VALUE ? void 0 : value;
|
|
46
|
-
}
|
|
47
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
48
|
-
placeholder: t("settings llm provider label")
|
|
49
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
|
|
50
|
-
value: DEFAULT_VALUE
|
|
51
|
-
}, t("settings default label")), LLM_PROVIDERS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
52
|
-
key: model,
|
|
53
|
-
value: model
|
|
54
|
-
}, LLM_PROVIDER_LABELS[model]))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))), /* @__PURE__ */ React.createElement(ControlItemInput, {
|
|
55
|
-
title: t("settings edge llm model label")
|
|
56
|
-
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
57
|
-
value: settings.edgeModel ?? DEFAULT_VALUE,
|
|
58
|
-
onValueChange: (value) => {
|
|
59
|
-
settings.edgeModel = value === DEFAULT_VALUE ? void 0 : value;
|
|
60
|
-
}
|
|
61
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
62
|
-
placeholder: t("settings default llm model label")
|
|
63
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
|
|
64
|
-
value: DEFAULT_VALUE
|
|
65
|
-
}, t("settings default label")), DEFAULT_EDGE_MODELS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
66
|
-
key: model,
|
|
67
|
-
value: model
|
|
68
|
-
}, model))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))), /* @__PURE__ */ React.createElement(ControlItemInput, {
|
|
69
|
-
title: t("settings ollama llm model label")
|
|
70
|
-
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
71
|
-
value: settings.ollamaModel ?? DEFAULT_VALUE,
|
|
72
|
-
onValueChange: (value) => {
|
|
73
|
-
settings.ollamaModel = value === DEFAULT_VALUE ? void 0 : value;
|
|
74
|
-
}
|
|
75
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
76
|
-
placeholder: t("settings default llm model label")
|
|
77
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, /* @__PURE__ */ React.createElement(Select.Option, {
|
|
78
|
-
value: DEFAULT_VALUE
|
|
79
|
-
}, t("settings default label")), DEFAULT_OLLAMA_MODELS.map((model) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
80
|
-
key: model,
|
|
81
|
-
value: model
|
|
82
|
-
}, model))), /* @__PURE__ */ React.createElement(Select.Arrow, null))))))));
|
|
83
|
-
} finally {
|
|
84
|
-
_effect.f();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// src/hooks/useBlueprintRegistry.ts
|
|
89
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
90
|
-
import { useSignalEffect } from "@preact/signals-react";
|
|
91
|
-
import { useCallback, useMemo, useState } from "react";
|
|
92
|
-
import { Capabilities } from "@dxos/app-framework";
|
|
93
|
-
import { useCapabilities } from "@dxos/app-framework/react";
|
|
94
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
95
|
-
import { Filter, Obj, Ref } from "@dxos/echo";
|
|
96
|
-
import { useQuery } from "@dxos/react-client/echo";
|
|
97
|
-
import { distinctBy, isNonNullable } from "@dxos/util";
|
|
98
|
-
var useBlueprintRegistry = () => {
|
|
99
|
-
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
100
|
-
return useMemo(() => new Blueprint.Registry(blueprints), [
|
|
101
|
-
blueprints
|
|
102
|
-
]);
|
|
103
|
-
};
|
|
104
|
-
var useBlueprints = ({ blueprintRegistry, space }) => {
|
|
105
|
-
const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
|
|
106
|
-
blueprintRegistry
|
|
107
|
-
]);
|
|
108
|
-
const spaceBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
|
|
109
|
-
return useMemo(() => {
|
|
110
|
-
const blueprints = distinctBy([
|
|
111
|
-
...staticBlueprints,
|
|
112
|
-
...spaceBlueprints
|
|
113
|
-
], (b) => b.key);
|
|
114
|
-
blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
115
|
-
return blueprints;
|
|
116
|
-
}, [
|
|
117
|
-
staticBlueprints,
|
|
118
|
-
spaceBlueprints
|
|
119
|
-
]);
|
|
120
|
-
};
|
|
121
|
-
var useActiveBlueprints = ({ context }) => {
|
|
122
|
-
var _effect = _useSignals2();
|
|
123
|
-
try {
|
|
124
|
-
const [active, setActive] = useState(/* @__PURE__ */ new Map());
|
|
125
|
-
useSignalEffect(() => {
|
|
126
|
-
const refs = [
|
|
127
|
-
...context?.blueprints.value ?? []
|
|
128
|
-
];
|
|
129
|
-
const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
|
|
130
|
-
setActive(new Map(blueprints.map((blueprint) => [
|
|
131
|
-
blueprint.key,
|
|
132
|
-
blueprint
|
|
133
|
-
])));
|
|
134
|
-
});
|
|
135
|
-
return active;
|
|
136
|
-
} finally {
|
|
137
|
-
_effect.f();
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
|
|
141
|
-
const onUpdateBlueprint = useCallback(async (key, checked) => {
|
|
142
|
-
if (!context || !blueprintRegistry) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
146
|
-
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
147
|
-
if (checked) {
|
|
148
|
-
if (!storedBlueprint) {
|
|
149
|
-
const blueprint = blueprintRegistry.getByKey(key);
|
|
150
|
-
if (!blueprint) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
154
|
-
}
|
|
155
|
-
await context.bind({
|
|
156
|
-
blueprints: [
|
|
157
|
-
Ref.make(storedBlueprint)
|
|
158
|
-
]
|
|
159
|
-
});
|
|
160
|
-
} else if (storedBlueprint) {
|
|
161
|
-
await context.unbind({
|
|
162
|
-
blueprints: [
|
|
163
|
-
Ref.make(storedBlueprint)
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}, [
|
|
168
|
-
space,
|
|
169
|
-
context,
|
|
170
|
-
blueprintRegistry
|
|
171
|
-
]);
|
|
172
|
-
return {
|
|
173
|
-
onUpdateBlueprint
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// src/hooks/useChatProcessor.ts
|
|
178
|
-
import { RegistryContext } from "@effect-atom/atom-react";
|
|
179
|
-
import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
|
|
180
|
-
import { AiConversation } from "@dxos/assistant";
|
|
181
|
-
import { log } from "@dxos/log";
|
|
182
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
183
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
184
|
-
var useChatProcessor = ({ space, chat, preset, services, blueprintRegistry, settings }) => {
|
|
185
|
-
const observableRegistry = useContext(RegistryContext);
|
|
186
|
-
const [conversation, setConversation] = useState2();
|
|
187
|
-
useAsyncEffect(async () => {
|
|
188
|
-
if (!space || !chat) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const queue = space.queues.get(chat.queue.dxn);
|
|
192
|
-
const conversation2 = new AiConversation(queue);
|
|
193
|
-
await conversation2.open();
|
|
194
|
-
setConversation(conversation2);
|
|
195
|
-
return () => {
|
|
196
|
-
void conversation2.close();
|
|
197
|
-
setConversation(void 0);
|
|
198
|
-
};
|
|
199
|
-
}, [
|
|
200
|
-
space,
|
|
201
|
-
chat?.queue.dxn.toString()
|
|
202
|
-
]);
|
|
203
|
-
const processor = useMemo2(() => {
|
|
204
|
-
if (!services || !conversation) {
|
|
205
|
-
return void 0;
|
|
206
|
-
}
|
|
207
|
-
log("creating processor", {
|
|
208
|
-
preset,
|
|
209
|
-
model: preset?.model,
|
|
210
|
-
settings
|
|
211
|
-
}, {
|
|
212
|
-
F: __dxlog_file,
|
|
213
|
-
L: 65,
|
|
214
|
-
S: void 0,
|
|
215
|
-
C: (f, a) => f(...a)
|
|
216
|
-
});
|
|
217
|
-
return new AiChatProcessor(conversation, services, {
|
|
218
|
-
observableRegistry,
|
|
219
|
-
blueprintRegistry,
|
|
220
|
-
model: preset?.model
|
|
221
|
-
});
|
|
222
|
-
}, [
|
|
223
|
-
services,
|
|
224
|
-
conversation,
|
|
225
|
-
blueprintRegistry,
|
|
226
|
-
preset
|
|
227
|
-
]);
|
|
228
|
-
return processor;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// src/hooks/useChatServices.ts
|
|
232
|
-
import * as Effect from "effect/Effect";
|
|
233
|
-
import { useMemo as useMemo3 } from "react";
|
|
234
|
-
import { useCapability } from "@dxos/app-framework/react";
|
|
235
|
-
import { TracingService } from "@dxos/functions";
|
|
236
|
-
import { TracingServiceExt } from "@dxos/functions-runtime";
|
|
237
|
-
import { AutomationCapabilities } from "@dxos/plugin-automation";
|
|
238
|
-
import { useClient } from "@dxos/react-client";
|
|
239
|
-
var useChatServices = ({ space, chat }) => {
|
|
240
|
-
const client = useClient();
|
|
241
|
-
space ??= client.spaces.default;
|
|
242
|
-
const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
243
|
-
return useMemo3(() => {
|
|
244
|
-
const runtime2 = runtimeResolver.getRuntime(space.id);
|
|
245
|
-
return () => runtime2.runPromise(Effect.gen(function* () {
|
|
246
|
-
return yield* Effect.runtime().pipe(Effect.provide(chat?.traceQueue?.target ? TracingServiceExt.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
|
|
247
|
-
}));
|
|
248
|
-
}, [
|
|
249
|
-
space,
|
|
250
|
-
chat?.traceQueue?.target
|
|
251
|
-
]);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// src/hooks/useChatToolbarActions.ts
|
|
255
|
-
import { Atom } from "@effect-atom/atom-react";
|
|
256
|
-
import * as Effect2 from "effect/Effect";
|
|
257
|
-
import { useMemo as useMemo10 } from "react";
|
|
258
|
-
import { createIntent } from "@dxos/app-framework";
|
|
259
|
-
import { useIntentDispatcher } from "@dxos/app-framework/react";
|
|
260
|
-
import { Filter as Filter5, Obj as Obj6, Query } from "@dxos/echo";
|
|
261
|
-
import { invariant } from "@dxos/invariant";
|
|
262
|
-
import { useQuery as useQuery4 } from "@dxos/react-client/echo";
|
|
263
|
-
import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
|
|
264
|
-
|
|
265
|
-
// src/components/index.ts
|
|
266
|
-
import { lazy } from "react";
|
|
267
|
-
|
|
268
|
-
// src/components/Chat/Chat.tsx
|
|
269
|
-
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
270
|
-
import { Prec } from "@codemirror/state";
|
|
271
|
-
import { keymap } from "@codemirror/view";
|
|
272
|
-
import { useAtomValue } from "@effect-atom/atom-react";
|
|
273
|
-
import { createContext } from "@radix-ui/react-context";
|
|
274
|
-
import * as Array2 from "effect/Array";
|
|
275
|
-
import * as Option2 from "effect/Option";
|
|
276
|
-
import React10, { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState11 } from "react";
|
|
277
|
-
import { Event } from "@dxos/async";
|
|
278
|
-
import { Obj as Obj5 } from "@dxos/echo";
|
|
279
|
-
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
280
|
-
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
281
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
282
|
-
import { Input as Input2, useDynamicRef, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
283
|
-
import { ChatEditor } from "@dxos/react-ui-chat";
|
|
284
|
-
import { MenuProvider, ToolbarMenu } from "@dxos/react-ui-menu";
|
|
285
|
-
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
286
|
-
import { Message } from "@dxos/types";
|
|
287
|
-
import { isTruthy } from "@dxos/util";
|
|
288
|
-
|
|
289
|
-
// src/hooks/useContextBinder.ts
|
|
290
|
-
import { useState as useState3 } from "react";
|
|
291
|
-
import { AiContextBinder } from "@dxos/assistant";
|
|
292
|
-
import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
|
|
293
|
-
var useContextBinder = (queue) => {
|
|
294
|
-
const [binder, setBinder] = useState3();
|
|
295
|
-
useAsyncEffect2(async () => {
|
|
296
|
-
if (!queue) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const binder2 = new AiContextBinder(queue);
|
|
300
|
-
await binder2.open();
|
|
301
|
-
setBinder(binder2);
|
|
302
|
-
return () => {
|
|
303
|
-
void binder2.close();
|
|
304
|
-
};
|
|
305
|
-
}, [
|
|
306
|
-
queue
|
|
307
|
-
]);
|
|
308
|
-
return binder;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// src/hooks/useContextObjects.ts
|
|
312
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
313
|
-
import { useCallback as useCallback2 } from "react";
|
|
314
|
-
import { Ref as Ref2 } from "@dxos/echo";
|
|
315
|
-
import { log as log2 } from "@dxos/log";
|
|
316
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
317
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
|
|
318
|
-
var useContextObjects = ({ space, context }) => {
|
|
319
|
-
var _effect = _useSignals3();
|
|
320
|
-
try {
|
|
321
|
-
const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
|
|
322
|
-
const handleUpdateObject = useCallback2(async (dxn, checked) => {
|
|
323
|
-
if (!space || !context) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
const id = dxn.asEchoDXN();
|
|
327
|
-
const object = id && space.db.getObjectById(id.echoId);
|
|
328
|
-
if (!object) {
|
|
329
|
-
log2.warn("Object not found", {
|
|
330
|
-
dxn,
|
|
331
|
-
id
|
|
332
|
-
}, {
|
|
333
|
-
F: __dxlog_file2,
|
|
334
|
-
L: 40,
|
|
335
|
-
S: void 0,
|
|
336
|
-
C: (f, a) => f(...a)
|
|
337
|
-
});
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const ref = Ref2.fromDXN(dxn);
|
|
341
|
-
if (checked) {
|
|
342
|
-
await context.bind({
|
|
343
|
-
objects: [
|
|
344
|
-
ref
|
|
345
|
-
]
|
|
346
|
-
});
|
|
347
|
-
} else {
|
|
348
|
-
await context.unbind({
|
|
349
|
-
objects: [
|
|
350
|
-
ref
|
|
351
|
-
]
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}, [
|
|
355
|
-
space,
|
|
356
|
-
context
|
|
357
|
-
]);
|
|
358
|
-
return {
|
|
359
|
-
objects,
|
|
360
|
-
onUpdateObject: handleUpdateObject
|
|
361
|
-
};
|
|
362
|
-
} finally {
|
|
363
|
-
_effect.f();
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
// src/hooks/useFilteredTypes.ts
|
|
368
|
-
import * as Option from "effect/Option";
|
|
369
|
-
import { useEffect, useState as useState4 } from "react";
|
|
370
|
-
import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
|
|
371
|
-
var useFilteredTypes = (space) => {
|
|
372
|
-
const [types, setTypes] = useState4([]);
|
|
373
|
-
useEffect(() => {
|
|
374
|
-
if (!space) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
return space.db.schemaRegistry.query().subscribe((query) => {
|
|
378
|
-
const types2 = Array.from(new Set([
|
|
379
|
-
...space.db.graph.schemaRegistry.schemas,
|
|
380
|
-
...query.results
|
|
381
|
-
].filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => SystemTypeAnnotation.get(schema).pipe(Option.getOrElse(() => false)))));
|
|
382
|
-
setTypes(types2);
|
|
383
|
-
}, {
|
|
384
|
-
fire: true
|
|
385
|
-
});
|
|
386
|
-
}, [
|
|
387
|
-
space
|
|
388
|
-
]);
|
|
389
|
-
return types;
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
// src/hooks/useFlush.ts
|
|
393
|
-
import { useCallback as useCallback3, useRef, useState as useState5 } from "react";
|
|
394
|
-
var useFlush = (space) => {
|
|
395
|
-
const [state, setState] = useState5("idle");
|
|
396
|
-
const resetTimer = useRef(null);
|
|
397
|
-
const handleFlush = useCallback3(() => {
|
|
398
|
-
if (!space) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
queueMicrotask(async () => {
|
|
402
|
-
if (resetTimer.current) {
|
|
403
|
-
clearTimeout(resetTimer.current);
|
|
404
|
-
}
|
|
405
|
-
setState("flushing");
|
|
406
|
-
await space.db.flush();
|
|
407
|
-
setState("flushed");
|
|
408
|
-
resetTimer.current = setTimeout(() => {
|
|
409
|
-
setState("idle");
|
|
410
|
-
resetTimer.current = null;
|
|
411
|
-
}, 1e3);
|
|
412
|
-
});
|
|
413
|
-
}, [
|
|
414
|
-
space
|
|
415
|
-
]);
|
|
416
|
-
return {
|
|
417
|
-
state,
|
|
418
|
-
handleFlush
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
// src/hooks/useOnline.ts
|
|
423
|
-
import { useState as useState6 } from "react";
|
|
424
|
-
var useOnline = () => {
|
|
425
|
-
const [online, setOnline] = useState6(true);
|
|
426
|
-
return [
|
|
427
|
-
online,
|
|
428
|
-
setOnline
|
|
429
|
-
];
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
// src/hooks/usePresets.ts
|
|
433
|
-
import { useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo4, useState as useState7 } from "react";
|
|
434
|
-
var usePresets = (online) => {
|
|
435
|
-
const [preset, setPreset] = useState7();
|
|
436
|
-
const presets = useMemo4(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
437
|
-
online
|
|
438
|
-
]);
|
|
439
|
-
const presetOptions = useMemo4(() => presets.map(({ id, model, label }) => ({
|
|
440
|
-
id,
|
|
441
|
-
label: label ?? model
|
|
442
|
-
})), [
|
|
443
|
-
presets
|
|
444
|
-
]);
|
|
445
|
-
useEffect2(() => {
|
|
446
|
-
setPreset(presets[0]);
|
|
447
|
-
}, [
|
|
448
|
-
presets
|
|
449
|
-
]);
|
|
450
|
-
const handlePresetChange = useCallback4((id) => {
|
|
451
|
-
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
452
|
-
if (preset2) {
|
|
453
|
-
setPreset(preset2);
|
|
454
|
-
}
|
|
455
|
-
}, [
|
|
456
|
-
presets
|
|
457
|
-
]);
|
|
458
|
-
return {
|
|
459
|
-
preset,
|
|
460
|
-
presets: presetOptions,
|
|
461
|
-
onPresetChange: handlePresetChange
|
|
462
|
-
};
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
// src/hooks/useReferencesProvider.ts
|
|
466
|
-
import { useMemo as useMemo5 } from "react";
|
|
467
|
-
import { Capabilities as Capabilities2 } from "@dxos/app-framework";
|
|
468
|
-
import { useCapabilities as useCapabilities2 } from "@dxos/app-framework/react";
|
|
469
|
-
import { Filter as Filter2, Obj as Obj2 } from "@dxos/echo";
|
|
470
|
-
var useReferencesProvider = (space) => {
|
|
471
|
-
const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
|
|
472
|
-
return useMemo5(() => {
|
|
473
|
-
if (!space) {
|
|
474
|
-
return void 0;
|
|
475
|
-
}
|
|
476
|
-
return {
|
|
477
|
-
getReferences: async ({ query }) => {
|
|
478
|
-
const { objects } = await space.db.query(Filter2.everything()).run();
|
|
479
|
-
return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
|
|
480
|
-
uri: Obj2.getDXN(object).toString(),
|
|
481
|
-
label: Obj2.getLabel(object) ?? ""
|
|
482
|
-
}));
|
|
483
|
-
},
|
|
484
|
-
resolveReference: async ({ uri }) => {
|
|
485
|
-
const object = await space.db.query(Filter2.ids(uri)).first();
|
|
486
|
-
return {
|
|
487
|
-
uri,
|
|
488
|
-
label: Obj2.getLabel(object) ?? ""
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
}, [
|
|
493
|
-
space,
|
|
494
|
-
blueprints
|
|
495
|
-
]);
|
|
496
|
-
};
|
|
497
|
-
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
498
|
-
|
|
499
|
-
// src/components/ChatPrompt/ChatActions.tsx
|
|
500
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
501
|
-
import React2 from "react";
|
|
502
|
-
import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
503
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
504
|
-
var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
|
|
505
|
-
var _effect = _useSignals4();
|
|
506
|
-
try {
|
|
507
|
-
const { t } = useTranslation2(meta.id);
|
|
508
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
509
|
-
className: mx("flex items-center mie-1", classNames)
|
|
510
|
-
}, children, /* @__PURE__ */ React2.createElement(IconButton, {
|
|
511
|
-
disabled: !processing,
|
|
512
|
-
variant: "ghost",
|
|
513
|
-
icon: "ph--x--regular",
|
|
514
|
-
iconOnly: true,
|
|
515
|
-
label: t("cancel processing button"),
|
|
516
|
-
onClick: () => onEvent?.({
|
|
517
|
-
type: "cancel"
|
|
518
|
-
})
|
|
519
|
-
}), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
520
|
-
disabled: !processing,
|
|
521
|
-
classNames: mx(recording && "bg-primary-500"),
|
|
522
|
-
variant: "ghost",
|
|
523
|
-
icon: "ph--microphone--regular",
|
|
524
|
-
iconOnly: true,
|
|
525
|
-
noTooltip: true,
|
|
526
|
-
label: t("microphone button"),
|
|
527
|
-
onMouseDown: () => onEvent?.({
|
|
528
|
-
type: "record-start"
|
|
529
|
-
}),
|
|
530
|
-
onMouseUp: () => onEvent?.({
|
|
531
|
-
type: "record-stop"
|
|
532
|
-
}),
|
|
533
|
-
onTouchStart: () => onEvent?.({
|
|
534
|
-
type: "record-start"
|
|
535
|
-
}),
|
|
536
|
-
onTouchEnd: () => onEvent?.({
|
|
537
|
-
type: "record-stop"
|
|
538
|
-
})
|
|
539
|
-
}));
|
|
540
|
-
} finally {
|
|
541
|
-
_effect.f();
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
// src/components/ChatPrompt/ChatOptions.tsx
|
|
546
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
547
|
-
import React3, { useMemo as useMemo6, useState as useState8 } from "react";
|
|
548
|
-
import { Filter as Filter3, Obj as Obj3, Type } from "@dxos/echo";
|
|
549
|
-
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
550
|
-
import { Icon, IconButton as IconButton2, Popover, Select as Select2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
551
|
-
import { Listbox, SearchList } from "@dxos/react-ui-searchlist";
|
|
552
|
-
import { Tabs } from "@dxos/react-ui-tabs";
|
|
553
|
-
var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-72 max-is-[--text-content]";
|
|
554
|
-
var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
|
|
555
|
-
var _effect = _useSignals5();
|
|
556
|
-
try {
|
|
557
|
-
const { t } = useTranslation3(meta.id);
|
|
558
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
559
|
-
role: "none",
|
|
560
|
-
className: "flex p-2"
|
|
561
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
562
|
-
asChild: true
|
|
563
|
-
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
564
|
-
variant: "ghost",
|
|
565
|
-
icon: "ph--plus--regular",
|
|
566
|
-
iconOnly: true,
|
|
567
|
-
label: t("context objects button")
|
|
568
|
-
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
569
|
-
side: "top",
|
|
570
|
-
classNames: panelClassNames
|
|
571
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
|
|
572
|
-
space,
|
|
573
|
-
context
|
|
574
|
-
})), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
575
|
-
asChild: true
|
|
576
|
-
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
577
|
-
variant: "ghost",
|
|
578
|
-
icon: "ph--sliders-horizontal--regular",
|
|
579
|
-
iconOnly: true,
|
|
580
|
-
label: t("context settings button")
|
|
581
|
-
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
582
|
-
side: "top",
|
|
583
|
-
classNames: panelClassNames
|
|
584
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(Tabs.Root, {
|
|
585
|
-
orientation: "horizontal",
|
|
586
|
-
defaultValue: "blueprints",
|
|
587
|
-
defaultActivePart: "list",
|
|
588
|
-
tabIndex: -1
|
|
589
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
|
|
590
|
-
classNames: 'max-bs-[--radix-popover-content-available-height] grid grid-rows-[1fr_min-content] [&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content] [&_[role="listbox"]]:min-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'
|
|
591
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
|
|
592
|
-
value: "blueprints",
|
|
593
|
-
tabIndex: -1,
|
|
594
|
-
classNames: "dx-focus-ring-inset"
|
|
595
|
-
}, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
|
|
596
|
-
blueprintRegistry,
|
|
597
|
-
space,
|
|
598
|
-
context
|
|
599
|
-
})), /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
|
|
600
|
-
value: "model",
|
|
601
|
-
tabIndex: -1,
|
|
602
|
-
classNames: "dx-focus-ring-inset !pli-0"
|
|
603
|
-
}, /* @__PURE__ */ React3.createElement(ModelsPanel, {
|
|
604
|
-
presets,
|
|
605
|
-
preset,
|
|
606
|
-
onPresetChange
|
|
607
|
-
})), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
|
|
608
|
-
classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
|
|
609
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
610
|
-
value: "blueprints",
|
|
611
|
-
icon: "ph--blueprint--regular",
|
|
612
|
-
label: t("blueprints in context title")
|
|
613
|
-
}), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
614
|
-
value: "model",
|
|
615
|
-
label: t("chat model title"),
|
|
616
|
-
icon: "ph--cpu--regular"
|
|
617
|
-
}))))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
|
|
618
|
-
} finally {
|
|
619
|
-
_effect.f();
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
|
|
623
|
-
var _effect = _useSignals5();
|
|
624
|
-
try {
|
|
625
|
-
const { t } = useTranslation3(meta.id);
|
|
626
|
-
const blueprints = useBlueprints({
|
|
627
|
-
blueprintRegistry,
|
|
628
|
-
space
|
|
629
|
-
});
|
|
630
|
-
const activeBlueprints = useActiveBlueprints({
|
|
631
|
-
context
|
|
632
|
-
});
|
|
633
|
-
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
634
|
-
space,
|
|
635
|
-
context,
|
|
636
|
-
blueprintRegistry
|
|
637
|
-
});
|
|
638
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Root, null, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
639
|
-
classNames: "plb-cardSpacingChrome"
|
|
640
|
-
}, blueprints.map((blueprint) => {
|
|
641
|
-
const isActive = activeBlueprints.has(blueprint.key);
|
|
642
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
643
|
-
classNames: "flex items-center overflow-hidden",
|
|
644
|
-
key: blueprint.key,
|
|
645
|
-
value: blueprint.name,
|
|
646
|
-
onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
|
|
647
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
648
|
-
className: "grow truncate"
|
|
649
|
-
}, blueprint.name), /* @__PURE__ */ React3.createElement(Icon, {
|
|
650
|
-
icon: "ph--check--regular",
|
|
651
|
-
classNames: [
|
|
652
|
-
!isActive && "invisible"
|
|
653
|
-
]
|
|
654
|
-
}));
|
|
655
|
-
})), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
656
|
-
placeholder: t("search placeholder"),
|
|
657
|
-
classNames: "mbe-cardSpacingChrome",
|
|
658
|
-
autoFocus: true
|
|
659
|
-
}));
|
|
660
|
-
} finally {
|
|
661
|
-
_effect.f();
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
var ModelsPanel = ({ presets, preset, onPresetChange }) => {
|
|
665
|
-
var _effect = _useSignals5();
|
|
666
|
-
try {
|
|
667
|
-
return /* @__PURE__ */ React3.createElement(Listbox.Root, {
|
|
668
|
-
value: preset,
|
|
669
|
-
onValueChange: onPresetChange,
|
|
670
|
-
autoFocus: true
|
|
671
|
-
}, presets?.map(({ id, label }) => {
|
|
672
|
-
return /* @__PURE__ */ React3.createElement(Listbox.Option, {
|
|
673
|
-
key: id,
|
|
674
|
-
value: id
|
|
675
|
-
}, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null));
|
|
676
|
-
}));
|
|
677
|
-
} finally {
|
|
678
|
-
_effect.f();
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
var ANY = "__any__";
|
|
682
|
-
var ObjectsPanel = ({ space, context }) => {
|
|
683
|
-
var _effect = _useSignals5();
|
|
684
|
-
try {
|
|
685
|
-
const { t } = useTranslation3(meta.id);
|
|
686
|
-
const types = useFilteredTypes(space);
|
|
687
|
-
const typenames = useMemo6(() => {
|
|
688
|
-
const typenames2 = types.map((type) => {
|
|
689
|
-
const typename2 = Type.getTypename(type);
|
|
690
|
-
return {
|
|
691
|
-
typename: typename2,
|
|
692
|
-
label: t("typename label", {
|
|
693
|
-
ns: typename2,
|
|
694
|
-
defaultValue: typename2
|
|
695
|
-
})
|
|
696
|
-
};
|
|
697
|
-
});
|
|
698
|
-
typenames2.sort((a, b) => a.label.localeCompare(b.label));
|
|
699
|
-
return typenames2;
|
|
700
|
-
}, [
|
|
701
|
-
types
|
|
702
|
-
]);
|
|
703
|
-
const [typename, setTypename] = useState8(ANY);
|
|
704
|
-
const anyFilter = useMemo6(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
|
|
705
|
-
typenames
|
|
706
|
-
]);
|
|
707
|
-
const objects = useQuery2(space, typename === ANY ? anyFilter : Filter3.typename(typename));
|
|
708
|
-
const { objects: contextObjects, onUpdateObject } = useContextObjects({
|
|
709
|
-
space,
|
|
710
|
-
context
|
|
711
|
-
});
|
|
712
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Root, null, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
713
|
-
classNames: "p-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
|
|
714
|
-
}, objects.length ? objects.map((object) => {
|
|
715
|
-
const label = Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id;
|
|
716
|
-
const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
|
|
717
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
718
|
-
classNames: "flex items-center overflow-hidden",
|
|
719
|
-
key: object.id,
|
|
720
|
-
value: object.id,
|
|
721
|
-
onSelect: () => onUpdateObject?.(Obj3.getDXN(object), !isActive)
|
|
722
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
723
|
-
className: "grow truncate"
|
|
724
|
-
}, label), /* @__PURE__ */ React3.createElement(Icon, {
|
|
725
|
-
icon: "ph--check--regular",
|
|
726
|
-
classNames: [
|
|
727
|
-
!isActive && "invisible"
|
|
728
|
-
]
|
|
729
|
-
}));
|
|
730
|
-
}) : /* @__PURE__ */ React3.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React3.createElement("div", {
|
|
731
|
-
role: "none",
|
|
732
|
-
className: "grid grid-cols-[min-content_1fr] gap-2 pli-cardSpacingChrome mbe-cardSpacingChrome"
|
|
733
|
-
}, /* @__PURE__ */ React3.createElement(Select2.Root, {
|
|
734
|
-
value: typename === ANY ? void 0 : typename,
|
|
735
|
-
onValueChange: setTypename
|
|
736
|
-
}, /* @__PURE__ */ React3.createElement(Select2.TriggerButton, {
|
|
737
|
-
density: "fine",
|
|
738
|
-
placeholder: t("type filter placeholder")
|
|
739
|
-
}), /* @__PURE__ */ React3.createElement(Select2.Portal, null, /* @__PURE__ */ React3.createElement(Select2.Content, null, /* @__PURE__ */ React3.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select2.Viewport, null, /* @__PURE__ */ React3.createElement(Select2.Option, {
|
|
740
|
-
value: ANY
|
|
741
|
-
}, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select2.Option, {
|
|
742
|
-
key: typename2,
|
|
743
|
-
value: typename2
|
|
744
|
-
}, label))), /* @__PURE__ */ React3.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select2.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
745
|
-
placeholder: t("search placeholder"),
|
|
746
|
-
classNames: "mbe-0",
|
|
747
|
-
autoFocus: true
|
|
748
|
-
})));
|
|
749
|
-
} finally {
|
|
750
|
-
_effect.f();
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
// src/components/ChatPrompt/ChatPresets.tsx
|
|
755
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
756
|
-
import React4 from "react";
|
|
757
|
-
import { Select as Select3 } from "@dxos/react-ui";
|
|
758
|
-
|
|
759
|
-
// src/components/ChatPrompt/ChatReferences.tsx
|
|
760
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
761
|
-
import React5 from "react";
|
|
762
|
-
import { Obj as Obj4 } from "@dxos/echo";
|
|
763
|
-
import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
764
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
765
|
-
var ChatReferences = ({ classNames, context, space }) => {
|
|
766
|
-
var _effect = _useSignals7();
|
|
767
|
-
try {
|
|
768
|
-
const { t } = useTranslation4(meta.id);
|
|
769
|
-
const { objects, onUpdateObject } = useContextObjects({
|
|
770
|
-
space,
|
|
771
|
-
context
|
|
772
|
-
});
|
|
773
|
-
return /* @__PURE__ */ React5.createElement("ul", {
|
|
774
|
-
className: mx2("flex", classNames)
|
|
775
|
-
}, objects.map((obj) => {
|
|
776
|
-
const dxn = Obj4.getDXN(obj);
|
|
777
|
-
const typename = Obj4.getTypename(obj);
|
|
778
|
-
const label = Obj4.getLabel(obj) ?? (typename ? [
|
|
779
|
-
"object name placeholder",
|
|
780
|
-
{
|
|
781
|
-
ns: typename
|
|
782
|
-
}
|
|
783
|
-
] : obj.id);
|
|
784
|
-
return /* @__PURE__ */ React5.createElement("li", {
|
|
785
|
-
key: dxn.toString(),
|
|
786
|
-
className: "dx-tag plb-0 pis-2 flex items-center",
|
|
787
|
-
"data-hue": "neutral"
|
|
788
|
-
}, toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
789
|
-
icon: "ph--x--bold",
|
|
790
|
-
iconOnly: true,
|
|
791
|
-
variant: "ghost",
|
|
792
|
-
label: t("remove object in context label"),
|
|
793
|
-
classNames: "p-0 hover:bg-transparent",
|
|
794
|
-
size: 3,
|
|
795
|
-
onClick: () => onUpdateObject?.(dxn, false)
|
|
796
|
-
}));
|
|
797
|
-
}));
|
|
798
|
-
} finally {
|
|
799
|
-
_effect.f();
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
804
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
805
|
-
import React6, { useEffect as useEffect3, useState as useState9 } from "react";
|
|
806
|
-
import { Tooltip, useTimeout } from "@dxos/react-ui";
|
|
807
|
-
import { Spinner } from "@dxos/react-ui-sfx";
|
|
808
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
809
|
-
var period = 3e3;
|
|
810
|
-
var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
|
|
811
|
-
var _effect = _useSignals8();
|
|
812
|
-
try {
|
|
813
|
-
const [init, setInit] = useState9(false);
|
|
814
|
-
useEffect3(() => setInit(false), [
|
|
815
|
-
preset
|
|
816
|
-
]);
|
|
817
|
-
useTimeout(async () => {
|
|
818
|
-
setInit(true);
|
|
819
|
-
}, period / 2, [
|
|
820
|
-
preset
|
|
821
|
-
]);
|
|
822
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
823
|
-
role: "none",
|
|
824
|
-
className: mx3("relative flex", classNames)
|
|
825
|
-
}, /* @__PURE__ */ React6.createElement(Spinner, {
|
|
826
|
-
duration: period,
|
|
827
|
-
state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
|
|
828
|
-
...props
|
|
829
|
-
}), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
830
|
-
asChild: true,
|
|
831
|
-
content: error.message
|
|
832
|
-
}, /* @__PURE__ */ React6.createElement("div", {
|
|
833
|
-
className: "absolute inset-0"
|
|
834
|
-
})));
|
|
835
|
-
} finally {
|
|
836
|
-
_effect.f();
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
841
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
842
|
-
import React9, { forwardRef, useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo8 } from "react";
|
|
843
|
-
import { PublicKey } from "@dxos/keys";
|
|
844
|
-
import { useForwardedRef } from "@dxos/react-ui";
|
|
845
|
-
import { MarkdownStream } from "@dxos/react-ui-components";
|
|
846
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
847
|
-
import { keyToFallback } from "@dxos/util";
|
|
848
|
-
|
|
849
|
-
// src/components/ChatThread/registry.tsx
|
|
850
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
851
|
-
import React8 from "react";
|
|
852
|
-
import { log as log3 } from "@dxos/log";
|
|
853
|
-
import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
|
|
854
|
-
import { getXmlTextChild } from "@dxos/react-ui-editor";
|
|
855
|
-
import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
|
|
856
|
-
import { ContentBlock } from "@dxos/types";
|
|
857
|
-
|
|
858
|
-
// src/components/ToolBlock/ToolBlock.tsx
|
|
859
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
860
|
-
import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
|
|
861
|
-
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
862
|
-
import { NumericTabs, TextCrawl, ToggleContainer } from "@dxos/react-ui-components";
|
|
863
|
-
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
864
|
-
import { isNonNullable as isNonNullable3, safeParseJson } from "@dxos/util";
|
|
865
|
-
var ToolBlock = ({ view, blocks = [] }) => {
|
|
866
|
-
var _effect = _useSignals9();
|
|
867
|
-
try {
|
|
868
|
-
const { t } = useTranslation5(meta.id);
|
|
869
|
-
const items = useMemo7(() => {
|
|
870
|
-
let lastToolCall;
|
|
871
|
-
const tools = [];
|
|
872
|
-
return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
|
|
873
|
-
switch (block._tag) {
|
|
874
|
-
case "toolCall": {
|
|
875
|
-
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
876
|
-
return null;
|
|
877
|
-
}
|
|
878
|
-
const tool = tools.find((tool2) => tool2.name === block.name);
|
|
879
|
-
lastToolCall = {
|
|
880
|
-
tool,
|
|
881
|
-
block
|
|
882
|
-
};
|
|
883
|
-
return {
|
|
884
|
-
title: tool?.description ?? [
|
|
885
|
-
t("tool call label"),
|
|
886
|
-
tool?.name
|
|
887
|
-
].join(" "),
|
|
888
|
-
content: {
|
|
889
|
-
...block,
|
|
890
|
-
input: safeParseJson(block.input)
|
|
891
|
-
}
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
case "toolResult": {
|
|
895
|
-
if (block.error) {
|
|
896
|
-
return {
|
|
897
|
-
title: t("tool error label"),
|
|
898
|
-
content: block
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
const title = lastToolCall?.tool?.description ?? [
|
|
902
|
-
t("tool result label"),
|
|
903
|
-
lastToolCall?.tool?.name
|
|
904
|
-
].join(" ");
|
|
905
|
-
lastToolCall = void 0;
|
|
906
|
-
return {
|
|
907
|
-
title,
|
|
908
|
-
content: {
|
|
909
|
-
...block,
|
|
910
|
-
result: safeParseJson(block.result)
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
case "summary": {
|
|
915
|
-
if (!lastToolCall) {
|
|
916
|
-
return null;
|
|
917
|
-
}
|
|
918
|
-
return {
|
|
919
|
-
title: t("summary label"),
|
|
920
|
-
content: block
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}).filter(isNonNullable3);
|
|
925
|
-
}, [
|
|
926
|
-
blocks
|
|
927
|
-
]);
|
|
928
|
-
const handleChangeOpen = useCallback5(() => {
|
|
929
|
-
setTimeout(() => {
|
|
930
|
-
view?.requestMeasure();
|
|
931
|
-
}, 1e3);
|
|
932
|
-
}, [
|
|
933
|
-
view
|
|
934
|
-
]);
|
|
935
|
-
if (!items.length) {
|
|
936
|
-
return null;
|
|
937
|
-
}
|
|
938
|
-
return /* @__PURE__ */ React7.createElement(ToolContainer, {
|
|
939
|
-
items,
|
|
940
|
-
onChangeOpen: handleChangeOpen
|
|
941
|
-
});
|
|
942
|
-
} finally {
|
|
943
|
-
_effect.f();
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
ToolBlock.displayName = "ToolBlock";
|
|
947
|
-
var ToolContainer = ({ items, onChangeOpen }) => {
|
|
948
|
-
var _effect = _useSignals9();
|
|
949
|
-
try {
|
|
950
|
-
const tabsRef = useRef2(null);
|
|
951
|
-
const [selected, setSelected] = useState10(0);
|
|
952
|
-
const [open, setOpen] = useState10(false);
|
|
953
|
-
useEffect4(() => {
|
|
954
|
-
onChangeOpen?.(open);
|
|
955
|
-
if (open) {
|
|
956
|
-
tabsRef.current?.focus();
|
|
957
|
-
}
|
|
958
|
-
}, [
|
|
959
|
-
open,
|
|
960
|
-
onChangeOpen
|
|
961
|
-
]);
|
|
962
|
-
const handleSelect = (index) => {
|
|
963
|
-
setSelected(index);
|
|
964
|
-
};
|
|
965
|
-
return /* @__PURE__ */ React7.createElement(ToggleContainer.Root, {
|
|
966
|
-
classNames: "mbs-2 is-full rounded-sm",
|
|
967
|
-
open,
|
|
968
|
-
onChangeOpen: setOpen
|
|
969
|
-
}, /* @__PURE__ */ React7.createElement(ToggleContainer.Header, {
|
|
970
|
-
classNames: "text-sm text-placeholder"
|
|
971
|
-
}, /* @__PURE__ */ React7.createElement(TextCrawl, {
|
|
972
|
-
key: "status-roll",
|
|
973
|
-
lines: items.map((item) => item.title),
|
|
974
|
-
autoAdvance: true,
|
|
975
|
-
greedy: true
|
|
976
|
-
})), /* @__PURE__ */ React7.createElement(ToggleContainer.Content, {
|
|
977
|
-
classNames: "grid grid-cols-[32px_1fr]"
|
|
978
|
-
}, /* @__PURE__ */ React7.createElement(NumericTabs, {
|
|
979
|
-
ref: tabsRef,
|
|
980
|
-
classNames: "p-1",
|
|
981
|
-
length: items.length,
|
|
982
|
-
selected,
|
|
983
|
-
onSelect: handleSelect
|
|
984
|
-
}), /* @__PURE__ */ React7.createElement(Json, {
|
|
985
|
-
data: items[selected]?.content,
|
|
986
|
-
classNames: "p-1 text-xs bg-transparent",
|
|
987
|
-
replacer: {
|
|
988
|
-
maxDepth: 3,
|
|
989
|
-
maxArrayLen: 10,
|
|
990
|
-
maxStringLen: 128
|
|
991
|
-
}
|
|
992
|
-
})));
|
|
993
|
-
} finally {
|
|
994
|
-
_effect.f();
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
// src/components/ChatThread/registry.tsx
|
|
999
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
|
|
1000
|
-
var Fallback = ({ _tag, ...props }) => {
|
|
1001
|
-
var _effect = _useSignals10();
|
|
1002
|
-
try {
|
|
1003
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2.Root, {
|
|
1004
|
-
classNames: "rounded-sm"
|
|
1005
|
-
}, /* @__PURE__ */ React8.createElement(ToggleContainer2.Header, {
|
|
1006
|
-
classNames: "bg-groupSurface"
|
|
1007
|
-
}, _tag), /* @__PURE__ */ React8.createElement(ToggleContainer2.Content, {
|
|
1008
|
-
classNames: "bg-modalSurface"
|
|
1009
|
-
}, /* @__PURE__ */ React8.createElement(Json2, {
|
|
1010
|
-
classNames: "!p-2 text-sm",
|
|
1011
|
-
data: props
|
|
1012
|
-
})));
|
|
1013
|
-
} finally {
|
|
1014
|
-
_effect.f();
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
var componentRegistry = {
|
|
1018
|
-
//
|
|
1019
|
-
// Widgets
|
|
1020
|
-
//
|
|
1021
|
-
["prompt"]: {
|
|
1022
|
-
block: true,
|
|
1023
|
-
factory: ({ children }) => {
|
|
1024
|
-
const text = getXmlTextChild(children);
|
|
1025
|
-
return text ? new PromptWidget(text) : null;
|
|
1026
|
-
}
|
|
1027
|
-
},
|
|
1028
|
-
["reference"]: {
|
|
1029
|
-
block: false,
|
|
1030
|
-
factory: ({ children, ref }) => {
|
|
1031
|
-
const text = getXmlTextChild(children);
|
|
1032
|
-
return text && ref ? new ReferenceWidget(text, ref) : null;
|
|
1033
|
-
}
|
|
1034
|
-
},
|
|
1035
|
-
["select"]: {
|
|
1036
|
-
block: true,
|
|
1037
|
-
factory: ({ children }) => {
|
|
1038
|
-
const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
|
|
1039
|
-
return options?.length ? new SelectWidget(options) : null;
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
["suggestion"]: {
|
|
1043
|
-
block: true,
|
|
1044
|
-
factory: ({ children }) => {
|
|
1045
|
-
const text = getXmlTextChild(children);
|
|
1046
|
-
return text ? new SuggestionWidget(text) : null;
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
["summary"]: {
|
|
1050
|
-
block: true,
|
|
1051
|
-
factory: ({ children }) => {
|
|
1052
|
-
const text = getXmlTextChild(children);
|
|
1053
|
-
return text ? new SummaryWidget(text) : null;
|
|
1054
|
-
}
|
|
1055
|
-
},
|
|
1056
|
-
//
|
|
1057
|
-
// React
|
|
1058
|
-
//
|
|
1059
|
-
["toolCall"]: {
|
|
1060
|
-
block: true,
|
|
1061
|
-
Component: ToolBlock
|
|
1062
|
-
},
|
|
1063
|
-
["toolResult"]: {
|
|
1064
|
-
block: true,
|
|
1065
|
-
Component: Fallback
|
|
1066
|
-
},
|
|
1067
|
-
["toolkit"]: {
|
|
1068
|
-
block: true,
|
|
1069
|
-
Component: Fallback
|
|
1070
|
-
},
|
|
1071
|
-
//
|
|
1072
|
-
// Fallback
|
|
1073
|
-
//
|
|
1074
|
-
["json"]: {
|
|
1075
|
-
block: true,
|
|
1076
|
-
Component: Fallback
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
|
-
var blockToMarkdown = (context, message, block) => {
|
|
1080
|
-
let str = blockToMarkdownImpl(context, message, block);
|
|
1081
|
-
if (str && !block.pending) {
|
|
1082
|
-
return str += "\n";
|
|
1083
|
-
}
|
|
1084
|
-
return str;
|
|
1085
|
-
};
|
|
1086
|
-
var blockToMarkdownImpl = (context, message, block) => {
|
|
1087
|
-
log3("blockToMarkdown", {
|
|
1088
|
-
block: JSON.stringify(block)
|
|
1089
|
-
}, {
|
|
1090
|
-
F: __dxlog_file3,
|
|
1091
|
-
L: 125,
|
|
1092
|
-
S: void 0,
|
|
1093
|
-
C: (f, a) => f(...a)
|
|
1094
|
-
});
|
|
1095
|
-
switch (block._tag) {
|
|
1096
|
-
case "text": {
|
|
1097
|
-
if (message.sender.role === "user") {
|
|
1098
|
-
return `<prompt>${block.text}</prompt>`;
|
|
1099
|
-
} else {
|
|
1100
|
-
const text = block.text.trim();
|
|
1101
|
-
if (text.length > 0) {
|
|
1102
|
-
return text;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
case "reference": {
|
|
1108
|
-
const dxn = block.reference.dxn;
|
|
1109
|
-
return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
|
|
1110
|
-
}
|
|
1111
|
-
case "suggestion": {
|
|
1112
|
-
if (block.pending) {
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
return `<suggestion>${block.text}</suggestion>`;
|
|
1116
|
-
}
|
|
1117
|
-
case "select": {
|
|
1118
|
-
if (block.pending || block.options.length === 0) {
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
|
|
1122
|
-
}
|
|
1123
|
-
case "toolCall": {
|
|
1124
|
-
context.updateWidget(block.toolCallId, {
|
|
1125
|
-
blocks: [
|
|
1126
|
-
block
|
|
1127
|
-
]
|
|
1128
|
-
});
|
|
1129
|
-
return `<toolCall id="${block.toolCallId}" />`;
|
|
1130
|
-
}
|
|
1131
|
-
case "toolResult": {
|
|
1132
|
-
context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
|
|
1133
|
-
blocks: [
|
|
1134
|
-
...blocks,
|
|
1135
|
-
block
|
|
1136
|
-
]
|
|
1137
|
-
}));
|
|
1138
|
-
break;
|
|
1139
|
-
}
|
|
1140
|
-
case "summary": {
|
|
1141
|
-
return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
|
|
1142
|
-
}
|
|
1143
|
-
default: {
|
|
1144
|
-
return `<json id="${message.id}">
|
|
1145
|
-
${JSON.stringify(block)}
|
|
1146
|
-
</json>`;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
// src/components/ChatThread/sync.ts
|
|
1152
|
-
import { log as log4 } from "@dxos/log";
|
|
1153
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
|
|
1154
|
-
var MessageThreadContext = class {
|
|
1155
|
-
_widgetState;
|
|
1156
|
-
constructor(_widgetState) {
|
|
1157
|
-
this._widgetState = _widgetState;
|
|
1158
|
-
}
|
|
1159
|
-
updateWidget(id, value) {
|
|
1160
|
-
this._widgetState?.updateWidget(id, value);
|
|
1161
|
-
}
|
|
1162
|
-
// TODO(burdon): Resolve from hypergraph.
|
|
1163
|
-
getObjectLabel(_id) {
|
|
1164
|
-
return "Object";
|
|
1165
|
-
}
|
|
1166
|
-
};
|
|
1167
|
-
var MessageSyncer = class {
|
|
1168
|
-
_model;
|
|
1169
|
-
_blockRenderer;
|
|
1170
|
-
_initialMessageId;
|
|
1171
|
-
_currentMessageIndex = 0;
|
|
1172
|
-
_currentBlockIndex = 0;
|
|
1173
|
-
_currentBlockContent;
|
|
1174
|
-
_context;
|
|
1175
|
-
constructor(_model, _blockRenderer) {
|
|
1176
|
-
this._model = _model;
|
|
1177
|
-
this._blockRenderer = _blockRenderer;
|
|
1178
|
-
this._context = new MessageThreadContext(this._model);
|
|
1179
|
-
}
|
|
1180
|
-
get context() {
|
|
1181
|
-
return this._context;
|
|
1182
|
-
}
|
|
1183
|
-
reset() {
|
|
1184
|
-
log4("reset", void 0, {
|
|
1185
|
-
F: __dxlog_file4,
|
|
1186
|
-
L: 64,
|
|
1187
|
-
S: this,
|
|
1188
|
-
C: (f, a) => f(...a)
|
|
1189
|
-
});
|
|
1190
|
-
this._initialMessageId = void 0;
|
|
1191
|
-
this._currentMessageIndex = 0;
|
|
1192
|
-
this._currentBlockIndex = 0;
|
|
1193
|
-
this._currentBlockContent = void 0;
|
|
1194
|
-
void this._model.reset("");
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Syncs messages with the editor.
|
|
1198
|
-
*/
|
|
1199
|
-
append(messages, flush = false) {
|
|
1200
|
-
if (this._initialMessageId !== messages[0]?.id) {
|
|
1201
|
-
this.reset();
|
|
1202
|
-
this._initialMessageId = messages[0]?.id;
|
|
1203
|
-
}
|
|
1204
|
-
if (flush && this._model.view?.state.doc.length === 0) {
|
|
1205
|
-
const buffer = [];
|
|
1206
|
-
this.process(messages, (content2) => {
|
|
1207
|
-
buffer.push(content2);
|
|
1208
|
-
});
|
|
1209
|
-
const content = buffer.join("");
|
|
1210
|
-
this._model.view?.dispatch({
|
|
1211
|
-
changes: [
|
|
1212
|
-
{
|
|
1213
|
-
from: 0,
|
|
1214
|
-
to: this._model.view?.state.doc.length ?? 0,
|
|
1215
|
-
insert: content
|
|
1216
|
-
}
|
|
1217
|
-
],
|
|
1218
|
-
selection: {
|
|
1219
|
-
anchor: content.length
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
return true;
|
|
1223
|
-
} else {
|
|
1224
|
-
this.process(messages, (content) => {
|
|
1225
|
-
void this._model.append(content);
|
|
1226
|
-
});
|
|
1227
|
-
return false;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
process(messages, append) {
|
|
1231
|
-
log4("sync", {
|
|
1232
|
-
doc: this._model.view?.state.doc.length,
|
|
1233
|
-
messages: messages.map((message) => message.blocks.length),
|
|
1234
|
-
currentMessageIndex: this._currentMessageIndex,
|
|
1235
|
-
currentBlockIndex: this._currentBlockIndex,
|
|
1236
|
-
currentBlockContent: this._currentBlockContent
|
|
1237
|
-
}, {
|
|
1238
|
-
F: __dxlog_file4,
|
|
1239
|
-
L: 105,
|
|
1240
|
-
S: this,
|
|
1241
|
-
C: (f, a) => f(...a)
|
|
1242
|
-
});
|
|
1243
|
-
let i = this._currentMessageIndex;
|
|
1244
|
-
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
1245
|
-
if (i > this._currentMessageIndex) {
|
|
1246
|
-
this._currentBlockIndex = 0;
|
|
1247
|
-
}
|
|
1248
|
-
this._currentMessageIndex = i;
|
|
1249
|
-
let j = this._currentBlockIndex;
|
|
1250
|
-
for (const block of message.blocks.slice(this._currentBlockIndex)) {
|
|
1251
|
-
this._currentBlockIndex = j;
|
|
1252
|
-
const currentBlockContent = this._blockRenderer(this._context, message, block);
|
|
1253
|
-
if (currentBlockContent) {
|
|
1254
|
-
let content = "";
|
|
1255
|
-
if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
|
|
1256
|
-
content = currentBlockContent.slice(this._currentBlockContent.length);
|
|
1257
|
-
} else {
|
|
1258
|
-
content = currentBlockContent;
|
|
1259
|
-
}
|
|
1260
|
-
log4("append", {
|
|
1261
|
-
message: i,
|
|
1262
|
-
block: j,
|
|
1263
|
-
content
|
|
1264
|
-
}, {
|
|
1265
|
-
F: __dxlog_file4,
|
|
1266
|
-
L: 132,
|
|
1267
|
-
S: this,
|
|
1268
|
-
C: (f, a) => f(...a)
|
|
1269
|
-
});
|
|
1270
|
-
this._currentBlockContent = currentBlockContent;
|
|
1271
|
-
append(content);
|
|
1272
|
-
}
|
|
1273
|
-
if (block.pending) {
|
|
1274
|
-
return;
|
|
1275
|
-
} else {
|
|
1276
|
-
this._currentBlockContent = void 0;
|
|
1277
|
-
this._currentBlockIndex++;
|
|
1278
|
-
}
|
|
1279
|
-
j++;
|
|
1280
|
-
}
|
|
1281
|
-
i++;
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1287
|
-
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent }, forwardedRef) => {
|
|
1288
|
-
var _effect = _useSignals11();
|
|
1289
|
-
try {
|
|
1290
|
-
const controllerRef = useForwardedRef(forwardedRef);
|
|
1291
|
-
const controller = controllerRef.current;
|
|
1292
|
-
const userHue = useMemo8(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
|
|
1293
|
-
identity
|
|
1294
|
-
]);
|
|
1295
|
-
useEffect5(() => {
|
|
1296
|
-
controller?.scrollToBottom();
|
|
1297
|
-
}, [
|
|
1298
|
-
controller,
|
|
1299
|
-
error
|
|
1300
|
-
]);
|
|
1301
|
-
const syncer = useMemo8(() => controller && new MessageSyncer(controller, blockToMarkdown), [
|
|
1302
|
-
controller
|
|
1303
|
-
]);
|
|
1304
|
-
useEffect5(() => {
|
|
1305
|
-
const reset = syncer?.append(messages, true);
|
|
1306
|
-
if (reset) {
|
|
1307
|
-
controller?.scrollToBottom("instant");
|
|
1308
|
-
}
|
|
1309
|
-
}, [
|
|
1310
|
-
syncer,
|
|
1311
|
-
messages
|
|
1312
|
-
]);
|
|
1313
|
-
const handleEvent = useCallback6(({ type, value }) => {
|
|
1314
|
-
switch (type) {
|
|
1315
|
-
case "submit": {
|
|
1316
|
-
value && onEvent?.({
|
|
1317
|
-
type,
|
|
1318
|
-
text: value
|
|
1319
|
-
});
|
|
1320
|
-
break;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
}, [
|
|
1324
|
-
onEvent
|
|
1325
|
-
]);
|
|
1326
|
-
return /* @__PURE__ */ React9.createElement("div", {
|
|
1327
|
-
role: "none",
|
|
1328
|
-
className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
|
|
1329
|
-
style: {
|
|
1330
|
-
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1331
|
-
}
|
|
1332
|
-
}, /* @__PURE__ */ React9.createElement(MarkdownStream, {
|
|
1333
|
-
ref: controllerRef,
|
|
1334
|
-
registry: componentRegistry,
|
|
1335
|
-
cursor,
|
|
1336
|
-
fadeIn,
|
|
1337
|
-
debug,
|
|
1338
|
-
onEvent: handleEvent
|
|
1339
|
-
}));
|
|
1340
|
-
} finally {
|
|
1341
|
-
_effect.f();
|
|
1342
|
-
}
|
|
1343
|
-
});
|
|
1344
|
-
|
|
1345
|
-
// src/components/Chat/Chat.tsx
|
|
1346
|
-
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1347
|
-
var ChatRoot = ({ children, chat, processor, onEvent, ...props }) => {
|
|
1348
|
-
var _effect = _useSignals12();
|
|
1349
|
-
try {
|
|
1350
|
-
const [debug, setDebug] = useState11(false);
|
|
1351
|
-
const pending = useAtomValue(processor.messages);
|
|
1352
|
-
const streaming = useAtomValue(processor.streaming);
|
|
1353
|
-
const lastPrompt = useRef3(void 0);
|
|
1354
|
-
const queue = useQueue(chat?.queue.dxn);
|
|
1355
|
-
const messages = useMemo9(() => {
|
|
1356
|
-
const queueMessages = queue?.objects?.filter(Obj5.instanceOf(Message.Message)) ?? [];
|
|
1357
|
-
return Array2.dedupeWith([
|
|
1358
|
-
...queueMessages,
|
|
1359
|
-
...pending
|
|
1360
|
-
], ({ id: a }, { id: b }) => a === b);
|
|
1361
|
-
}, [
|
|
1362
|
-
queue?.objects,
|
|
1363
|
-
pending
|
|
1364
|
-
]);
|
|
1365
|
-
const event = useMemo9(() => new Event(), []);
|
|
1366
|
-
useEffect6(() => {
|
|
1367
|
-
return event.on((ev) => {
|
|
1368
|
-
switch (ev.type) {
|
|
1369
|
-
case "toggle-debug": {
|
|
1370
|
-
setDebug((current) => !current);
|
|
1371
|
-
break;
|
|
1372
|
-
}
|
|
1373
|
-
case "submit": {
|
|
1374
|
-
const text = ev.text.trim();
|
|
1375
|
-
if (!streaming && text.length) {
|
|
1376
|
-
lastPrompt.current = ev.text;
|
|
1377
|
-
void processor.request({
|
|
1378
|
-
message: text
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
break;
|
|
1382
|
-
}
|
|
1383
|
-
case "retry": {
|
|
1384
|
-
if (!streaming) {
|
|
1385
|
-
void processor.retry();
|
|
1386
|
-
}
|
|
1387
|
-
break;
|
|
1388
|
-
}
|
|
1389
|
-
case "cancel": {
|
|
1390
|
-
if (streaming) {
|
|
1391
|
-
void processor.cancel();
|
|
1392
|
-
if (lastPrompt.current) {
|
|
1393
|
-
event.emit({
|
|
1394
|
-
type: "update-prompt",
|
|
1395
|
-
text: lastPrompt.current
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
break;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
onEvent?.(ev);
|
|
1403
|
-
});
|
|
1404
|
-
}, [
|
|
1405
|
-
event,
|
|
1406
|
-
processor,
|
|
1407
|
-
streaming,
|
|
1408
|
-
onEvent
|
|
1409
|
-
]);
|
|
1410
|
-
const space = props.space ?? getSpace(chat);
|
|
1411
|
-
return /* @__PURE__ */ React10.createElement(ChatContextProvider, {
|
|
1412
|
-
debug,
|
|
1413
|
-
event,
|
|
1414
|
-
space,
|
|
1415
|
-
chat,
|
|
1416
|
-
messages,
|
|
1417
|
-
processor,
|
|
1418
|
-
...props
|
|
1419
|
-
}, children);
|
|
1420
|
-
} finally {
|
|
1421
|
-
_effect.f();
|
|
1422
|
-
}
|
|
1423
|
-
};
|
|
1424
|
-
ChatRoot.displayName = "Chat.Root";
|
|
1425
|
-
var ChatViewport = ({ classNames, children }) => {
|
|
1426
|
-
var _effect = _useSignals12();
|
|
1427
|
-
try {
|
|
1428
|
-
return /* @__PURE__ */ React10.createElement("div", {
|
|
1429
|
-
role: "none",
|
|
1430
|
-
className: mx5("flex flex-col bs-full is-full", classNames)
|
|
1431
|
-
}, children);
|
|
1432
|
-
} finally {
|
|
1433
|
-
_effect.f();
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1436
|
-
var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
|
|
1437
|
-
var _effect = _useSignals12();
|
|
1438
|
-
try {
|
|
1439
|
-
const { t } = useTranslation6(meta.id);
|
|
1440
|
-
const { space, processor, event } = useChatContext(ChatPrompt.displayName);
|
|
1441
|
-
const error = useAtomValue(processor.error).pipe(Option2.getOrUndefined);
|
|
1442
|
-
const streaming = useAtomValue(processor.streaming);
|
|
1443
|
-
const active = useAtomValue(processor.active);
|
|
1444
|
-
const activeRef = useDynamicRef(active);
|
|
1445
|
-
const editorRef = useRef3(null);
|
|
1446
|
-
const [recordingState, setRecordingState] = useState11(false);
|
|
1447
|
-
useEffect6(() => {
|
|
1448
|
-
return event.on((event2) => {
|
|
1449
|
-
switch (event2.type) {
|
|
1450
|
-
case "update-prompt":
|
|
1451
|
-
if (!editorRef.current?.getText()?.length) {
|
|
1452
|
-
editorRef.current?.setText(event2.text);
|
|
1453
|
-
editorRef.current?.focus();
|
|
1454
|
-
}
|
|
1455
|
-
break;
|
|
1456
|
-
case "record-start":
|
|
1457
|
-
setRecordingState(true);
|
|
1458
|
-
break;
|
|
1459
|
-
case "record-stop":
|
|
1460
|
-
setRecordingState(false);
|
|
1461
|
-
break;
|
|
1462
|
-
}
|
|
1463
|
-
});
|
|
1464
|
-
}, [
|
|
1465
|
-
event
|
|
1466
|
-
]);
|
|
1467
|
-
const { recording } = useVoiceInput({
|
|
1468
|
-
active: recordingState,
|
|
1469
|
-
onUpdate: (text) => {
|
|
1470
|
-
editorRef.current?.setText(text);
|
|
1471
|
-
editorRef.current?.focus();
|
|
1472
|
-
}
|
|
1473
|
-
});
|
|
1474
|
-
const extensions = useMemo9(() => {
|
|
1475
|
-
return [
|
|
1476
|
-
Prec.highest(keymap.of([
|
|
1477
|
-
{
|
|
1478
|
-
key: "Mod-d",
|
|
1479
|
-
preventDefault: true,
|
|
1480
|
-
run: () => {
|
|
1481
|
-
event.emit({
|
|
1482
|
-
type: "toggle-debug"
|
|
1483
|
-
});
|
|
1484
|
-
return true;
|
|
1485
|
-
}
|
|
1486
|
-
},
|
|
1487
|
-
{
|
|
1488
|
-
key: "Mod-ArrowUp",
|
|
1489
|
-
preventDefault: true,
|
|
1490
|
-
run: () => {
|
|
1491
|
-
event.emit({
|
|
1492
|
-
type: "nav-previous"
|
|
1493
|
-
});
|
|
1494
|
-
return true;
|
|
1495
|
-
},
|
|
1496
|
-
shift: () => {
|
|
1497
|
-
event.emit({
|
|
1498
|
-
type: "thread-open"
|
|
1499
|
-
});
|
|
1500
|
-
return true;
|
|
1501
|
-
}
|
|
1502
|
-
},
|
|
1503
|
-
{
|
|
1504
|
-
key: "Mod-ArrowDown",
|
|
1505
|
-
preventDefault: true,
|
|
1506
|
-
run: () => {
|
|
1507
|
-
event.emit({
|
|
1508
|
-
type: "nav-next"
|
|
1509
|
-
});
|
|
1510
|
-
return true;
|
|
1511
|
-
},
|
|
1512
|
-
shift: () => {
|
|
1513
|
-
event.emit({
|
|
1514
|
-
type: "thread-close"
|
|
1515
|
-
});
|
|
1516
|
-
return true;
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
]))
|
|
1520
|
-
].filter(isTruthy);
|
|
1521
|
-
}, [
|
|
1522
|
-
event,
|
|
1523
|
-
expandable
|
|
1524
|
-
]);
|
|
1525
|
-
const handleSubmit = useCallback7((text) => {
|
|
1526
|
-
if (!activeRef.current) {
|
|
1527
|
-
event.emit({
|
|
1528
|
-
type: "submit",
|
|
1529
|
-
text
|
|
1530
|
-
});
|
|
1531
|
-
return true;
|
|
1532
|
-
}
|
|
1533
|
-
}, [
|
|
1534
|
-
event
|
|
1535
|
-
]);
|
|
1536
|
-
const handleEvent = useCallback7((ev) => {
|
|
1537
|
-
event.emit(ev);
|
|
1538
|
-
}, [
|
|
1539
|
-
event
|
|
1540
|
-
]);
|
|
1541
|
-
return /* @__PURE__ */ React10.createElement("div", {
|
|
1542
|
-
role: "group",
|
|
1543
|
-
className: mx5("flex flex-col is-full density-fine", outline && "bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded", classNames)
|
|
1544
|
-
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1545
|
-
role: "none",
|
|
1546
|
-
className: "flex p-2 gap-2"
|
|
1547
|
-
}, /* @__PURE__ */ React10.createElement(ChatStatusIndicator, {
|
|
1548
|
-
classNames: "p-1",
|
|
1549
|
-
preset,
|
|
1550
|
-
error,
|
|
1551
|
-
processing: streaming
|
|
1552
|
-
}), /* @__PURE__ */ React10.createElement(ChatEditor, {
|
|
1553
|
-
ref: editorRef,
|
|
1554
|
-
autoFocus: true,
|
|
1555
|
-
lineWrapping: true,
|
|
1556
|
-
classNames: "col-span-2 pbs-0.5",
|
|
1557
|
-
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1558
|
-
extensions,
|
|
1559
|
-
onSubmit: handleSubmit
|
|
1560
|
-
})), space && settings && /* @__PURE__ */ React10.createElement("div", {
|
|
1561
|
-
role: "none",
|
|
1562
|
-
className: "flex items-center overflow-hidden"
|
|
1563
|
-
}, /* @__PURE__ */ React10.createElement(ChatOptions, {
|
|
1564
|
-
space,
|
|
1565
|
-
blueprintRegistry: processor.blueprintRegistry,
|
|
1566
|
-
context: processor.context,
|
|
1567
|
-
preset,
|
|
1568
|
-
presets,
|
|
1569
|
-
onPresetChange
|
|
1570
|
-
}), /* @__PURE__ */ React10.createElement("div", {
|
|
1571
|
-
role: "none",
|
|
1572
|
-
className: "flex grow overflow-x-auto scrollbar-none"
|
|
1573
|
-
}, /* @__PURE__ */ React10.createElement(ChatReferences, {
|
|
1574
|
-
space,
|
|
1575
|
-
context: processor.context
|
|
1576
|
-
})), /* @__PURE__ */ React10.createElement(ChatActions, {
|
|
1577
|
-
classNames: "col-span-2",
|
|
1578
|
-
microphone: true,
|
|
1579
|
-
recording,
|
|
1580
|
-
processing: streaming,
|
|
1581
|
-
onEvent: handleEvent
|
|
1582
|
-
}, online !== void 0 && /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Label, {
|
|
1583
|
-
srOnly: true
|
|
1584
|
-
}, t("online switch label")), /* @__PURE__ */ React10.createElement(Input2.Switch, {
|
|
1585
|
-
classNames: "mli-2",
|
|
1586
|
-
checked: online,
|
|
1587
|
-
onCheckedChange: onOnlineChange
|
|
1588
|
-
})))));
|
|
1589
|
-
} finally {
|
|
1590
|
-
_effect.f();
|
|
1591
|
-
}
|
|
1592
|
-
};
|
|
1593
|
-
ChatPrompt.displayName = "Chat.Prompt";
|
|
1594
|
-
var ChatThread2 = (props) => {
|
|
1595
|
-
var _effect = _useSignals12();
|
|
1596
|
-
try {
|
|
1597
|
-
const { debug, event, messages, processor } = useChatContext(ChatThread2.displayName);
|
|
1598
|
-
const identity = useIdentity();
|
|
1599
|
-
const error = useAtomValue(processor.error).pipe(Option2.getOrUndefined);
|
|
1600
|
-
const controllerRef = useRef3(null);
|
|
1601
|
-
useEffect6(() => {
|
|
1602
|
-
return event.on((event2) => {
|
|
1603
|
-
switch (event2.type) {
|
|
1604
|
-
case "submit":
|
|
1605
|
-
case "scroll-to-bottom":
|
|
1606
|
-
controllerRef.current?.scrollToBottom();
|
|
1607
|
-
break;
|
|
1608
|
-
case "nav-previous":
|
|
1609
|
-
controllerRef.current?.navigatePrevious();
|
|
1610
|
-
break;
|
|
1611
|
-
case "nav-next":
|
|
1612
|
-
controllerRef.current?.navigateNext();
|
|
1613
|
-
break;
|
|
1614
|
-
}
|
|
1615
|
-
});
|
|
1616
|
-
}, [
|
|
1617
|
-
event
|
|
1618
|
-
]);
|
|
1619
|
-
const handleEvent = useCallback7((ev) => {
|
|
1620
|
-
event.emit(ev);
|
|
1621
|
-
}, [
|
|
1622
|
-
event
|
|
1623
|
-
]);
|
|
1624
|
-
if (!identity) {
|
|
1625
|
-
return null;
|
|
1626
|
-
}
|
|
1627
|
-
return /* @__PURE__ */ React10.createElement(ChatThread, {
|
|
1628
|
-
...props,
|
|
1629
|
-
identity,
|
|
1630
|
-
messages,
|
|
1631
|
-
error,
|
|
1632
|
-
debug,
|
|
1633
|
-
onEvent: handleEvent,
|
|
1634
|
-
ref: controllerRef
|
|
1635
|
-
});
|
|
1636
|
-
} finally {
|
|
1637
|
-
_effect.f();
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
ChatThread2.displayName = "Chat.Thread";
|
|
1641
|
-
var ChatToolbar = ({ classNames, companionTo }) => {
|
|
1642
|
-
var _effect = _useSignals12();
|
|
1643
|
-
try {
|
|
1644
|
-
const { chat } = useChatContext(ChatToolbar.displayName);
|
|
1645
|
-
const menu = useChatToolbarActions({
|
|
1646
|
-
chat,
|
|
1647
|
-
companionTo
|
|
1648
|
-
});
|
|
1649
|
-
return /* @__PURE__ */ React10.createElement(MenuProvider, {
|
|
1650
|
-
...menu,
|
|
1651
|
-
attendableId: companionTo ? Obj5.getDXN(companionTo).toString() : chat ? Obj5.getDXN(chat).toString() : ""
|
|
1652
|
-
}, /* @__PURE__ */ React10.createElement(ToolbarMenu, {
|
|
1653
|
-
classNames,
|
|
1654
|
-
textBlockWidth: true
|
|
1655
|
-
}));
|
|
1656
|
-
} finally {
|
|
1657
|
-
_effect.f();
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
ChatToolbar.displayName = "Chat.Toolbar";
|
|
1661
|
-
var Chat = {
|
|
1662
|
-
Root: ChatRoot,
|
|
1663
|
-
Viewport: ChatViewport,
|
|
1664
|
-
Prompt: ChatPrompt,
|
|
1665
|
-
Thread: ChatThread2,
|
|
1666
|
-
Toolbar: ChatToolbar
|
|
1667
|
-
};
|
|
1668
|
-
|
|
1669
|
-
// src/components/Toolbox/Toolbox.tsx
|
|
1670
|
-
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
1671
|
-
import React11, { Fragment, useEffect as useEffect7, useState as useState12 } from "react";
|
|
1672
|
-
import { Function } from "@dxos/functions";
|
|
1673
|
-
import { log as log5 } from "@dxos/log";
|
|
1674
|
-
import { Filter as Filter4, useQuery as useQuery3 } from "@dxos/react-client/echo";
|
|
1675
|
-
import { useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1676
|
-
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1677
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1678
|
-
var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
|
|
1679
|
-
var _effect = _useSignals13();
|
|
1680
|
-
try {
|
|
1681
|
-
const { t } = useTranslation7(meta.id);
|
|
1682
|
-
return /* @__PURE__ */ React11.createElement("div", {
|
|
1683
|
-
className: mx6("flex flex-col overflow-y-auto box-content", classNames)
|
|
1684
|
-
}, blueprints && blueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
|
|
1685
|
-
title: "Blueprints",
|
|
1686
|
-
items: blueprints.map(({ target }) => ({
|
|
1687
|
-
name: target?.name ?? "",
|
|
1688
|
-
description: target?.description ?? "",
|
|
1689
|
-
subitems: target?.tools.map((toolId) => ({
|
|
1690
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
1691
|
-
}))
|
|
1692
|
-
}))
|
|
1693
|
-
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
|
|
1694
|
-
title: "Blueprints",
|
|
1695
|
-
items: activeBlueprints.map(({ target }) => ({
|
|
1696
|
-
name: target?.name ?? "",
|
|
1697
|
-
description: target?.description ?? "",
|
|
1698
|
-
subitems: target?.tools.map((toolId) => ({
|
|
1699
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
1700
|
-
}))
|
|
1701
|
-
}))
|
|
1702
|
-
}), services && services.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
|
|
1703
|
-
title: "Services",
|
|
1704
|
-
items: services.map(({ service: { serviceId, name, description } }) => ({
|
|
1705
|
-
name: name ?? serviceId,
|
|
1706
|
-
description
|
|
1707
|
-
}))
|
|
1708
|
-
}), functions && functions.length > 0 && /* @__PURE__ */ React11.createElement(Section, {
|
|
1709
|
-
title: "Functions",
|
|
1710
|
-
items: functions.map(({ name, description }) => ({
|
|
1711
|
-
name,
|
|
1712
|
-
description
|
|
1713
|
-
}))
|
|
1714
|
-
}));
|
|
1715
|
-
} finally {
|
|
1716
|
-
_effect.f();
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
|
-
var Section = ({ title, items, striped }) => {
|
|
1720
|
-
var _effect = _useSignals13();
|
|
1721
|
-
try {
|
|
1722
|
-
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
1723
|
-
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
1724
|
-
const subGridClassNames = mx6("col-span-full grid grid-cols-subgrid text-xs pli-2", striped && stripeClassNames);
|
|
1725
|
-
return /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement("h1", {
|
|
1726
|
-
className: "pli-2 text-sm"
|
|
1727
|
-
}, title), /* @__PURE__ */ React11.createElement("div", {
|
|
1728
|
-
className: gridClassNames
|
|
1729
|
-
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React11.createElement(Fragment, {
|
|
1730
|
-
key: i
|
|
1731
|
-
}, name && /* @__PURE__ */ React11.createElement("div", {
|
|
1732
|
-
className: subGridClassNames
|
|
1733
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1734
|
-
className: "truncate text-primary-500"
|
|
1735
|
-
}, name), /* @__PURE__ */ React11.createElement("div", {
|
|
1736
|
-
className: "line-clamp-2"
|
|
1737
|
-
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React11.createElement("div", {
|
|
1738
|
-
key: i2,
|
|
1739
|
-
className: mx6(subGridClassNames, striped && stripeClassNames)
|
|
1740
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1741
|
-
className: "truncate"
|
|
1742
|
-
}, name2), /* @__PURE__ */ React11.createElement("div", {
|
|
1743
|
-
className: "line-clamp-3 text-subdued"
|
|
1744
|
-
}, description2)))))));
|
|
1745
|
-
} finally {
|
|
1746
|
-
_effect.f();
|
|
1747
|
-
}
|
|
1748
|
-
};
|
|
1749
|
-
var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
1750
|
-
var _effect = _useSignals13();
|
|
1751
|
-
try {
|
|
1752
|
-
const services = useQuery3(space, Filter4.type(ServiceType));
|
|
1753
|
-
const [serviceTools, setServiceTools] = useState12([]);
|
|
1754
|
-
useEffect7(() => {
|
|
1755
|
-
log5("creating service tools...", {
|
|
1756
|
-
services: services.length
|
|
1757
|
-
}, {
|
|
1758
|
-
F: __dxlog_file5,
|
|
1759
|
-
L: 117,
|
|
1760
|
-
S: void 0,
|
|
1761
|
-
C: (f, a) => f(...a)
|
|
1762
|
-
});
|
|
1763
|
-
queueMicrotask(async () => {
|
|
1764
|
-
});
|
|
1765
|
-
}, [
|
|
1766
|
-
services
|
|
1767
|
-
]);
|
|
1768
|
-
const functions = useQuery3(space, Filter4.type(Function.Function));
|
|
1769
|
-
return /* @__PURE__ */ React11.createElement(Toolbox, {
|
|
1770
|
-
classNames,
|
|
1771
|
-
blueprints: processor?.context.blueprints.value,
|
|
1772
|
-
services: serviceTools,
|
|
1773
|
-
functions
|
|
1774
|
-
});
|
|
1775
|
-
} finally {
|
|
1776
|
-
_effect.f();
|
|
1777
|
-
}
|
|
1778
|
-
};
|
|
1779
|
-
var safeToolId = (name) => {
|
|
1780
|
-
return name.split("_").pop();
|
|
1781
|
-
};
|
|
1782
|
-
|
|
1783
|
-
// src/components/index.ts
|
|
1784
|
-
var BlueprintArticle = lazy(() => import("./BlueprintArticle-BWSLH6LG.mjs"));
|
|
1785
|
-
var ChatCompanion = lazy(() => import("./ChatCompanion-OSZZZSWV.mjs"));
|
|
1786
|
-
var ChatContainer = lazy(() => import("./ChatContainer-2W6FNSJD.mjs"));
|
|
1787
|
-
var ChatDialog = lazy(() => import("./ChatDialog-XQ3KDYWE.mjs"));
|
|
1788
|
-
var PromptArticle = lazy(() => import("./PromptArticle-Q7JYGFQV.mjs"));
|
|
1789
|
-
|
|
1790
|
-
// src/hooks/useChatToolbarActions.ts
|
|
1791
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
|
|
1792
|
-
var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
1793
|
-
const { dispatch } = useIntentDispatcher();
|
|
1794
|
-
const { space } = useChatContext("useChatToolbarActions");
|
|
1795
|
-
const query = companionTo ? Query.select(Filter5.ids(companionTo.id)).targetOf(Assistant_exports.CompanionTo).source() : Query.select(Filter5.nothing());
|
|
1796
|
-
const chats = useQuery4(space, query);
|
|
1797
|
-
return useMenuActions(useMemo10(() => {
|
|
1798
|
-
return Atom.make(() => {
|
|
1799
|
-
const builder = MenuBuilder.make().root({
|
|
1800
|
-
label: [
|
|
1801
|
-
"chat toolbar title",
|
|
1802
|
-
{
|
|
1803
|
-
ns: meta.id
|
|
1804
|
-
}
|
|
1805
|
-
]
|
|
1806
|
-
}).action("new", {
|
|
1807
|
-
label: [
|
|
1808
|
-
"new thread button",
|
|
1809
|
-
{
|
|
1810
|
-
ns: meta.id
|
|
1811
|
-
}
|
|
1812
|
-
],
|
|
1813
|
-
icon: "ph--plus--regular",
|
|
1814
|
-
type: "new"
|
|
1815
|
-
}, () => dispatch(createIntent(AssistantAction_exports.SetCurrentChat, {
|
|
1816
|
-
companionTo,
|
|
1817
|
-
chat: void 0
|
|
1818
|
-
})).pipe(Effect2.runPromise)).action("rename", {
|
|
1819
|
-
label: [
|
|
1820
|
-
"rename thread button",
|
|
1821
|
-
{
|
|
1822
|
-
ns: meta.id
|
|
1823
|
-
}
|
|
1824
|
-
],
|
|
1825
|
-
icon: "ph--magic-wand--regular",
|
|
1826
|
-
type: "rename",
|
|
1827
|
-
disabled: !chat
|
|
1828
|
-
}, () => Effect2.gen(function* () {
|
|
1829
|
-
invariant(chat, void 0, {
|
|
1830
|
-
F: __dxlog_file6,
|
|
1831
|
-
L: 68,
|
|
1832
|
-
S: this,
|
|
1833
|
-
A: [
|
|
1834
|
-
"chat",
|
|
1835
|
-
""
|
|
1836
|
-
]
|
|
1837
|
-
});
|
|
1838
|
-
yield* dispatch(createIntent(AssistantAction_exports.UpdateChatName, {
|
|
1839
|
-
chat
|
|
1840
|
-
}));
|
|
1841
|
-
}).pipe(Effect2.runPromise)).action("branch", {
|
|
1842
|
-
label: [
|
|
1843
|
-
"button branch thread",
|
|
1844
|
-
{
|
|
1845
|
-
ns: meta.id
|
|
1846
|
-
}
|
|
1847
|
-
],
|
|
1848
|
-
icon: "ph--git-branch--regular",
|
|
1849
|
-
type: "branch",
|
|
1850
|
-
disabled: true
|
|
1851
|
-
}, () => {
|
|
1852
|
-
});
|
|
1853
|
-
if (chats.length > 0) {
|
|
1854
|
-
builder.group("chats", {
|
|
1855
|
-
label: [
|
|
1856
|
-
"chat history label",
|
|
1857
|
-
{
|
|
1858
|
-
ns: meta.id
|
|
1859
|
-
}
|
|
1860
|
-
],
|
|
1861
|
-
icon: "ph--clock-counter-clockwise--regular",
|
|
1862
|
-
selectCardinality: "single",
|
|
1863
|
-
variant: "dropdownMenu"
|
|
1864
|
-
}, (builder2) => {
|
|
1865
|
-
chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
|
|
1866
|
-
builder2.action(chat2.id, {
|
|
1867
|
-
label: Obj6.getLabel(chat2) ?? [
|
|
1868
|
-
"object name placeholder",
|
|
1869
|
-
{
|
|
1870
|
-
ns: Assistant_exports.Chat.typename
|
|
1871
|
-
}
|
|
1872
|
-
]
|
|
1873
|
-
}, () => Effect2.gen(function* () {
|
|
1874
|
-
invariant(companionTo, void 0, {
|
|
1875
|
-
F: __dxlog_file6,
|
|
1876
|
-
L: 104,
|
|
1877
|
-
S: this,
|
|
1878
|
-
A: [
|
|
1879
|
-
"companionTo",
|
|
1880
|
-
""
|
|
1881
|
-
]
|
|
1882
|
-
});
|
|
1883
|
-
yield* dispatch(createIntent(AssistantAction_exports.SetCurrentChat, {
|
|
1884
|
-
companionTo,
|
|
1885
|
-
chat: chat2
|
|
1886
|
-
}));
|
|
1887
|
-
}).pipe(Effect2.runPromise));
|
|
1888
|
-
});
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
return builder.build();
|
|
1892
|
-
});
|
|
1893
|
-
}, [
|
|
1894
|
-
chats.length,
|
|
1895
|
-
space?.id,
|
|
1896
|
-
companionTo?.id,
|
|
1897
|
-
chat?.id,
|
|
1898
|
-
dispatch
|
|
1899
|
-
]));
|
|
1900
|
-
};
|
|
1901
|
-
|
|
1902
|
-
export {
|
|
1903
|
-
AssistantSettings,
|
|
1904
|
-
useBlueprintRegistry,
|
|
1905
|
-
useBlueprints,
|
|
1906
|
-
useActiveBlueprints,
|
|
1907
|
-
useBlueprintHandlers,
|
|
1908
|
-
useChatProcessor,
|
|
1909
|
-
useChatServices,
|
|
1910
|
-
useChatToolbarActions,
|
|
1911
|
-
useContextBinder,
|
|
1912
|
-
useContextObjects,
|
|
1913
|
-
useFilteredTypes,
|
|
1914
|
-
useFlush,
|
|
1915
|
-
useOnline,
|
|
1916
|
-
usePresets,
|
|
1917
|
-
useReferencesProvider,
|
|
1918
|
-
ChatContextProvider,
|
|
1919
|
-
useChatContext,
|
|
1920
|
-
Chat,
|
|
1921
|
-
Toolbox,
|
|
1922
|
-
ToolboxContainer,
|
|
1923
|
-
BlueprintArticle,
|
|
1924
|
-
ChatCompanion,
|
|
1925
|
-
ChatContainer,
|
|
1926
|
-
ChatDialog,
|
|
1927
|
-
PromptArticle
|
|
1928
|
-
};
|
|
1929
|
-
//# sourceMappingURL=chunk-PWSTPQUY.mjs.map
|