@dxos/plugin-assistant 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea
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/{BlueprintContainer-OWUSKPRK.mjs → BlueprintContainer-GMSYKGSO.mjs} +13 -6
- package/dist/lib/browser/BlueprintContainer-GMSYKGSO.mjs.map +7 -0
- package/dist/lib/browser/{ChatCompanion-FRCVSLPP.mjs → ChatCompanion-M3FDKTQM.mjs} +39 -14
- package/dist/lib/browser/ChatCompanion-M3FDKTQM.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-YBJBIVUZ.mjs → ChatContainer-KAH7XITI.mjs} +10 -11
- package/dist/lib/browser/ChatContainer-KAH7XITI.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-MTPJLEHM.mjs → ChatDialog-ZWRGABW6.mjs} +8 -10
- package/dist/lib/browser/ChatDialog-ZWRGABW6.mjs.map +7 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-7AAWTWGA.mjs → app-graph-builder-R5T7BJPC.mjs} +41 -11
- package/dist/lib/browser/app-graph-builder-R5T7BJPC.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-AGTDXTXO.mjs +13 -0
- package/dist/lib/browser/chunk-357IHWQL.mjs +1519 -0
- package/dist/lib/browser/chunk-357IHWQL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6QMISAU6.mjs → chunk-A2NVNXPL.mjs} +15 -12
- package/dist/lib/browser/chunk-A2NVNXPL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-V5H5CCZA.mjs → chunk-CQW6UPJM.mjs} +24 -43
- package/dist/lib/browser/chunk-CQW6UPJM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SMIVXXAI.mjs → chunk-GNI6HL6G.mjs} +37 -20
- package/dist/lib/browser/chunk-GNI6HL6G.mjs.map +7 -0
- package/dist/lib/browser/chunk-GXHZTOWJ.mjs +378 -0
- package/dist/lib/browser/chunk-GXHZTOWJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-L5OA5OGS.mjs +262 -0
- package/dist/lib/browser/chunk-L5OA5OGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OYFQS7JM.mjs → chunk-MEN5WTLA.mjs} +64 -39
- package/dist/lib/browser/chunk-MEN5WTLA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CFXXQM25.mjs → chunk-PUG24BEC.mjs} +118 -23
- package/dist/lib/browser/chunk-PUG24BEC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IJAJRAR7.mjs → chunk-SJJV3HEX.mjs} +2 -4
- package/dist/lib/browser/chunk-SJJV3HEX.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +85 -51
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-BQO5SVGI.mjs → intent-resolver-3C5TABOX.mjs} +38 -14
- package/dist/lib/browser/intent-resolver-3C5TABOX.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs +17 -0
- package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-VNCD2H7C.mjs → react-surface-EYKA5IFU.mjs} +11 -30
- package/dist/lib/browser/react-surface-EYKA5IFU.mjs.map +7 -0
- package/dist/lib/browser/{settings-36V3VUMW.mjs → settings-VMVBYZLN.mjs} +5 -5
- package/dist/lib/browser/{settings-36V3VUMW.mjs.map → settings-VMVBYZLN.mjs.map} +1 -1
- package/dist/lib/browser/{state-D5IVKNYG.mjs → state-CFREPBB6.mjs} +5 -5
- package/dist/lib/browser/{state-D5IVKNYG.mjs.map → state-CFREPBB6.mjs.map} +1 -1
- package/dist/lib/browser/toolkit-F3NQ7TSI.mjs +21 -0
- package/dist/lib/browser/toolkit-F3NQ7TSI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{BlueprintContainer-UFVWCRN6.mjs → BlueprintContainer-6GBLMK4Z.mjs} +13 -6
- package/dist/lib/node-esm/BlueprintContainer-6GBLMK4Z.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatCompanion-ZNRZEKH5.mjs → ChatCompanion-OV426GCP.mjs} +39 -14
- package/dist/lib/node-esm/ChatCompanion-OV426GCP.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-TUCITJJW.mjs → ChatContainer-UKY7NHFY.mjs} +10 -11
- package/dist/lib/node-esm/ChatContainer-UKY7NHFY.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-JLM7RDZQ.mjs → ChatDialog-2BDQIEXH.mjs} +8 -10
- package/dist/lib/node-esm/ChatDialog-2BDQIEXH.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-PNAFQUYT.mjs → app-graph-builder-I52RYVWH.mjs} +41 -11
- package/dist/lib/node-esm/app-graph-builder-I52RYVWH.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-275J3XL2.mjs → blueprint-definition-CFCUD2VC.mjs} +5 -4
- package/dist/lib/node-esm/{chunk-CAQKGW3B.mjs → chunk-2CAETDW2.mjs} +63 -39
- package/dist/lib/node-esm/chunk-2CAETDW2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RLBN4RNR.mjs → chunk-4J5FYNNM.mjs} +15 -12
- package/dist/lib/node-esm/chunk-4J5FYNNM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7YOGZI66.mjs → chunk-5ARE4R2I.mjs} +37 -20
- package/dist/lib/node-esm/chunk-5ARE4R2I.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7ZYOYW7F.mjs +264 -0
- package/dist/lib/node-esm/chunk-7ZYOYW7F.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HJPIYMWD.mjs +1520 -0
- package/dist/lib/node-esm/chunk-HJPIYMWD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UWUUZQWJ.mjs → chunk-O36P4LN5.mjs} +24 -43
- package/dist/lib/node-esm/chunk-O36P4LN5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs +25 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-FNZJJL7G.mjs → chunk-XM4BVQQR.mjs} +118 -23
- package/dist/lib/node-esm/chunk-XM4BVQQR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YPXEA46Q.mjs → chunk-XQBL2SBL.mjs} +2 -4
- package/dist/lib/node-esm/chunk-XQBL2SBL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YIO5MEPR.mjs +380 -0
- package/dist/lib/node-esm/chunk-YIO5MEPR.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +85 -51
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-FIS3T5KP.mjs → intent-resolver-HQ27YALS.mjs} +38 -14
- package/dist/lib/node-esm/intent-resolver-HQ27YALS.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs +18 -0
- package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-4NLRKNBU.mjs → react-surface-UOC3CBPH.mjs} +11 -30
- package/dist/lib/node-esm/react-surface-UOC3CBPH.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-7ZCZ6AS5.mjs → settings-7AUVNDM2.mjs} +5 -5
- package/dist/lib/node-esm/{settings-7ZCZ6AS5.mjs.map → settings-7AUVNDM2.mjs.map} +1 -1
- package/dist/lib/node-esm/{state-4VLKPLW3.mjs → state-XXND44OW.mjs} +5 -5
- package/dist/lib/node-esm/{state-4VLKPLW3.mjs.map → state-XXND44OW.mjs.map} +1 -1
- package/dist/lib/node-esm/toolkit-7CH5UNSQ.mjs +22 -0
- package/dist/lib/node-esm/toolkit-7CH5UNSQ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AssistantPlugin.d.ts +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +2 -3
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -8
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +4 -3
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +10 -5
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +35 -26
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/ChatToolbar/ChatToolbar.d.ts +6 -0
- package/dist/types/src/components/ChatToolbar/ChatToolbar.d.ts.map +1 -0
- package/dist/types/src/components/ChatToolbar/index.d.ts +2 -0
- package/dist/types/src/components/ChatToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar → ChatToolbar}/useChatToolbarActions.d.ts +1 -3
- package/dist/types/src/components/ChatToolbar/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +21 -14
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +21 -14
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -2
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +21 -14
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +2 -2
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/functions/{list.d.ts → object-list.d.ts} +1 -1
- package/dist/types/src/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +1 -1
- package/dist/types/src/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +0 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +2 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +2 -2
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +2 -2
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +1 -0
- package/dist/types/src/processor/index.d.ts.map +1 -1
- package/dist/types/src/processor/presets.d.ts +1 -1
- package/dist/types/src/processor/presets.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +11 -17
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts +10 -0
- package/dist/types/src/processor/update-name.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-services.d.ts +2 -2
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/toolkits/AssistantToolkit.d.ts +21 -0
- package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +1 -0
- package/dist/types/src/toolkits/SystemToolkit.d.ts +69 -0
- package/dist/types/src/toolkits/SystemToolkit.d.ts.map +1 -0
- package/dist/types/src/toolkits/index.d.ts +3 -0
- package/dist/types/src/toolkits/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +6 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +15 -9
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +18 -6
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +12 -12
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +93 -110
- package/src/AssistantPlugin.tsx +140 -129
- package/src/capabilities/ai-service.ts +6 -7
- package/src/capabilities/app-graph-builder.ts +36 -4
- package/src/capabilities/blueprint-definition.ts +39 -15
- package/src/capabilities/capabilities.ts +0 -13
- package/src/capabilities/edge-model-resolver.ts +5 -7
- package/src/capabilities/intent-resolver.ts +33 -6
- package/src/capabilities/local-model-resolver.ts +6 -8
- package/src/capabilities/react-surface.tsx +1 -21
- package/src/capabilities/toolkit.ts +10 -154
- package/src/components/BlueprintContainer.tsx +8 -2
- package/src/components/Chat/Chat.tsx +72 -70
- package/src/components/ChatCompanion.tsx +33 -8
- package/src/components/ChatContainer.tsx +4 -4
- package/src/components/ChatDialog.tsx +8 -8
- package/src/components/ChatProgress/ChatProgress.tsx +2 -3
- package/src/components/ChatPrompt/ChatOptions.tsx +17 -25
- package/src/components/ChatThread/ChatThread.stories.tsx +75 -229
- package/src/components/ChatThread/ChatThread.tsx +64 -46
- package/src/components/ChatThread/Link.tsx +11 -8
- package/src/components/ChatThread/registry.tsx +184 -0
- package/src/components/ChatThread/sync.test.ts +81 -0
- package/src/components/ChatThread/sync.ts +113 -0
- package/src/components/{Toolbar/Toolbar.tsx → ChatToolbar/ChatToolbar.tsx} +5 -2
- package/src/components/{Toolbar → ChatToolbar}/index.ts +1 -1
- package/src/components/{Toolbar → ChatToolbar}/useChatToolbarActions.ts +2 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +5 -5
- package/src/components/TemplateEditor/TemplateEditor.tsx +18 -10
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +3 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
- package/src/components/TemplateEditor/handlebars-extension.ts +12 -11
- package/src/components/{ChatThread → ToolBlock}/ToolBlock.tsx +31 -26
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +4 -7
- package/src/components/Toolbox/Toolbox.tsx +3 -3
- package/src/components/index.ts +1 -3
- package/src/functions/analysis.ts +4 -2
- package/src/functions/index.ts +2 -2
- package/src/functions/{list.ts → object-list.ts} +6 -4
- package/src/functions/{load.ts → object-load.ts} +9 -7
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useBlueprintRegistry.ts +17 -3
- package/src/hooks/useChatProcessor.ts +13 -5
- package/src/hooks/useChatServices.ts +26 -42
- package/src/hooks/useContextBinder.ts +17 -5
- package/src/hooks/useItemTypes.ts +1 -1
- package/src/index.ts +2 -0
- package/src/meta.ts +9 -6
- package/src/processor/index.ts +1 -0
- package/src/processor/presets.ts +1 -1
- package/src/processor/processor.test.ts +21 -17
- package/src/processor/processor.ts +30 -57
- package/src/processor/update-name.ts +57 -0
- package/src/queue-logger.ts +5 -5
- package/src/testing/index.ts +1 -2
- package/src/testing/test-generator.ts +261 -0
- package/src/testing/test-services.ts +2 -8
- package/src/toolkits/AssistantToolkit.ts +55 -0
- package/src/toolkits/SystemToolkit.ts +292 -0
- package/src/toolkits/index.ts +6 -0
- package/src/translations.ts +6 -5
- package/src/types/Assistant.ts +10 -8
- package/src/types/AssistantAction.ts +10 -2
- package/src/types/service.ts +17 -9
- package/dist/lib/browser/BlueprintContainer-OWUSKPRK.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-FRCVSLPP.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-YBJBIVUZ.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-MTPJLEHM.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs +0 -150
- package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs.map +0 -7
- package/dist/lib/browser/ai-service-NRZPTUHO.mjs +0 -22
- package/dist/lib/browser/ai-service-NRZPTUHO.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-7AAWTWGA.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-CRZPIA5A.mjs +0 -12
- package/dist/lib/browser/chunk-6QMISAU6.mjs.map +0 -7
- package/dist/lib/browser/chunk-CFXXQM25.mjs.map +0 -7
- package/dist/lib/browser/chunk-IJAJRAR7.mjs.map +0 -7
- package/dist/lib/browser/chunk-O4LUJEDV.mjs +0 -20
- package/dist/lib/browser/chunk-O4LUJEDV.mjs.map +0 -7
- package/dist/lib/browser/chunk-OYFQS7JM.mjs.map +0 -7
- package/dist/lib/browser/chunk-SMIVXXAI.mjs.map +0 -7
- package/dist/lib/browser/chunk-V5H5CCZA.mjs.map +0 -7
- package/dist/lib/browser/chunk-XL557TXF.mjs +0 -2332
- package/dist/lib/browser/chunk-XL557TXF.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-E5M3CC46.mjs +0 -22
- package/dist/lib/browser/edge-model-resolver-E5M3CC46.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BQO5SVGI.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-VZ5WZQIC.mjs +0 -21
- package/dist/lib/browser/local-model-resolver-VZ5WZQIC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VNCD2H7C.mjs.map +0 -7
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs +0 -191
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-UFVWCRN6.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-ZNRZEKH5.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-TUCITJJW.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-JLM7RDZQ.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs +0 -151
- package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-UDEPIPTO.mjs +0 -23
- package/dist/lib/node-esm/ai-service-UDEPIPTO.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-PNAFQUYT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2X6VEO32.mjs +0 -2333
- package/dist/lib/node-esm/chunk-2X6VEO32.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7YOGZI66.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CAQKGW3B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FNZJJL7G.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RLBN4RNR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UWUUZQWJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VFY2JG62.mjs +0 -22
- package/dist/lib/node-esm/chunk-VFY2JG62.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YPXEA46Q.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-SZHDLXCT.mjs +0 -23
- package/dist/lib/node-esm/edge-model-resolver-SZHDLXCT.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FIS3T5KP.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-2KCBKMYA.mjs +0 -22
- package/dist/lib/node-esm/local-model-resolver-2KCBKMYA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4NLRKNBU.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-2F2OL6WB.mjs +0 -192
- package/dist/lib/node-esm/toolkit-2F2OL6WB.mjs.map +0 -7
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -33
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/PromptSettings.d.ts +0 -6
- package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
- package/dist/types/src/components/SequenceContainer.d.ts +0 -8
- package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -263
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -4
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
- package/dist/types/src/execution-graph/execution-graph.d.ts +0 -21
- package/dist/types/src/execution-graph/execution-graph.d.ts.map +0 -1
- package/dist/types/src/execution-graph/index.d.ts +0 -2
- package/dist/types/src/execution-graph/index.d.ts.map +0 -1
- package/dist/types/src/functions/list.d.ts.map +0 -1
- package/dist/types/src/functions/load.d.ts.map +0 -1
- package/dist/types/src/hooks/useExecutionGraph.d.ts +0 -7
- package/dist/types/src/hooks/useExecutionGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useMatcherExtension.d.ts +0 -3
- package/dist/types/src/hooks/useMatcherExtension.d.ts.map +0 -1
- package/dist/types/src/hooks/useResolveRef.d.ts +0 -4
- package/dist/types/src/hooks/useResolveRef.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/stories/Chat.stories.d.ts +0 -26
- package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +0 -4
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/ChatContainer.d.ts +0 -4
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/CommentsContainer.d.ts +0 -4
- package/dist/types/src/stories/components/CommentsContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/GraphContainer.d.ts +0 -6
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/LoggingContainer.d.ts +0 -4
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/MessageContainer.d.ts +0 -4
- package/dist/types/src/stories/components/MessageContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +0 -8
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/TasksContainer.d.ts +0 -4
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts +0 -3
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/index.d.ts +0 -11
- package/dist/types/src/stories/components/index.d.ts.map +0 -1
- package/dist/types/src/stories/components/types.d.ts +0 -7
- package/dist/types/src/stories/components/types.d.ts.map +0 -1
- package/dist/types/src/stories/testing/data.d.ts +0 -5
- package/dist/types/src/stories/testing/data.d.ts.map +0 -1
- package/dist/types/src/stories/testing/index.d.ts +0 -3
- package/dist/types/src/stories/testing/index.d.ts.map +0 -1
- package/dist/types/src/stories/testing/testing.d.ts +0 -44
- package/dist/types/src/stories/testing/testing.d.ts.map +0 -1
- package/dist/types/src/testing/test-data.d.ts +0 -4
- package/dist/types/src/testing/test-data.d.ts.map +0 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -6
- package/dist/types/src/testing/test-functions.d.ts.map +0 -1
- package/src/components/ChatThread/ChatMessage.tsx +0 -334
- package/src/components/PromptSettings.tsx +0 -90
- package/src/components/SequenceContainer.tsx +0 -131
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -33
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/components/SequenceEditor/index.ts +0 -5
- package/src/execution-graph/execution-graph.ts +0 -211
- package/src/execution-graph/index.ts +0 -5
- package/src/hooks/useExecutionGraph.ts +0 -20
- package/src/hooks/useMatcherExtension.ts +0 -45
- package/src/hooks/useResolveRef.ts +0 -33
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -76
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -36
- package/src/stories/Chat.stories.tsx +0 -469
- package/src/stories/components/BlueprintContainer.tsx +0 -32
- package/src/stories/components/ChatContainer.tsx +0 -57
- package/src/stories/components/CommentsContainer.tsx +0 -25
- package/src/stories/components/GraphContainer.tsx +0 -118
- package/src/stories/components/LoggingContainer.tsx +0 -21
- package/src/stories/components/MessageContainer.tsx +0 -27
- package/src/stories/components/SurfaceContainer.tsx +0 -52
- package/src/stories/components/TasksContainer.tsx +0 -49
- package/src/stories/components/TokenManagerContainer.tsx +0 -14
- package/src/stories/components/index.ts +0 -15
- package/src/stories/components/types.ts +0 -11
- package/src/stories/testing/data.ts +0 -142
- package/src/stories/testing/index.ts +0 -6
- package/src/stories/testing/testing.tsx +0 -254
- package/src/testing/test-data.ts +0 -109
- package/src/testing/test-functions.ts +0 -16
- /package/dist/lib/browser/{blueprint-definition-CRZPIA5A.mjs.map → blueprint-definition-AGTDXTXO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-275J3XL2.mjs.map → blueprint-definition-CFCUD2VC.mjs.map} +0 -0
|
@@ -0,0 +1,1519 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AiChatProcessor,
|
|
3
|
+
AiServicePresets
|
|
4
|
+
} from "./chunk-L5OA5OGS.mjs";
|
|
5
|
+
import {
|
|
6
|
+
meta
|
|
7
|
+
} from "./chunk-WBG5PTSX.mjs";
|
|
8
|
+
|
|
9
|
+
// src/hooks/useBlueprintRegistry.ts
|
|
10
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
11
|
+
import { useSignalEffect } from "@preact/signals-react";
|
|
12
|
+
import { useCallback, useMemo, useState } from "react";
|
|
13
|
+
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
14
|
+
import { Blueprint } from "@dxos/blueprints";
|
|
15
|
+
import { Filter, Obj, Ref } from "@dxos/echo";
|
|
16
|
+
import { useQuery } from "@dxos/react-client/echo";
|
|
17
|
+
import { distinctBy, isNonNullable } from "@dxos/util";
|
|
18
|
+
var useBlueprintRegistry = () => {
|
|
19
|
+
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
20
|
+
return useMemo(() => new Blueprint.Registry(blueprints), [
|
|
21
|
+
blueprints
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
var useBlueprints = ({ blueprintRegistry, space }) => {
|
|
25
|
+
const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
|
|
26
|
+
blueprintRegistry
|
|
27
|
+
]);
|
|
28
|
+
const spaceBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
|
|
29
|
+
return useMemo(() => {
|
|
30
|
+
const blueprints = distinctBy([
|
|
31
|
+
...staticBlueprints,
|
|
32
|
+
...spaceBlueprints
|
|
33
|
+
], (b) => b.key);
|
|
34
|
+
blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
35
|
+
return blueprints;
|
|
36
|
+
}, [
|
|
37
|
+
staticBlueprints,
|
|
38
|
+
spaceBlueprints
|
|
39
|
+
]);
|
|
40
|
+
};
|
|
41
|
+
var useActiveBlueprints = ({ context }) => {
|
|
42
|
+
var _effect = _useSignals();
|
|
43
|
+
try {
|
|
44
|
+
const [active, setActive] = useState(/* @__PURE__ */ new Map());
|
|
45
|
+
useSignalEffect(() => {
|
|
46
|
+
const refs = [
|
|
47
|
+
...context?.blueprints.value ?? []
|
|
48
|
+
];
|
|
49
|
+
const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
|
|
50
|
+
setActive(new Map(blueprints.map((blueprint) => [
|
|
51
|
+
blueprint.key,
|
|
52
|
+
blueprint
|
|
53
|
+
])));
|
|
54
|
+
});
|
|
55
|
+
return active;
|
|
56
|
+
} finally {
|
|
57
|
+
_effect.f();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
|
|
61
|
+
const onUpdateBlueprint = useCallback(async (key, checked) => {
|
|
62
|
+
if (!context || !blueprintRegistry) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
66
|
+
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
67
|
+
if (checked) {
|
|
68
|
+
if (!storedBlueprint) {
|
|
69
|
+
const blueprint = blueprintRegistry.getByKey(key);
|
|
70
|
+
if (!blueprint) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
74
|
+
}
|
|
75
|
+
await context.bind({
|
|
76
|
+
blueprints: [
|
|
77
|
+
Ref.make(storedBlueprint)
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
} else if (storedBlueprint) {
|
|
81
|
+
await context.unbind({
|
|
82
|
+
blueprints: [
|
|
83
|
+
Ref.make(storedBlueprint)
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
space,
|
|
89
|
+
context,
|
|
90
|
+
blueprintRegistry
|
|
91
|
+
]);
|
|
92
|
+
return {
|
|
93
|
+
onUpdateBlueprint
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/hooks/useChatProcessor.ts
|
|
98
|
+
import { RegistryContext } from "@effect-rx/rx-react";
|
|
99
|
+
import { useContext, useMemo as useMemo2, useState as useState2 } from "react";
|
|
100
|
+
import { AiConversation } from "@dxos/assistant";
|
|
101
|
+
import { log } from "@dxos/log";
|
|
102
|
+
import { useAsyncEffect } from "@dxos/react-ui";
|
|
103
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
104
|
+
var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
|
|
105
|
+
const observableRegistry = useContext(RegistryContext);
|
|
106
|
+
const [conversation, setConversation] = useState2();
|
|
107
|
+
useAsyncEffect(async () => {
|
|
108
|
+
if (!chat?.queue.target) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const conversation2 = new AiConversation(chat.queue.target);
|
|
112
|
+
await conversation2.open();
|
|
113
|
+
setConversation(conversation2);
|
|
114
|
+
return () => {
|
|
115
|
+
void conversation2.close();
|
|
116
|
+
};
|
|
117
|
+
}, [
|
|
118
|
+
chat?.queue.target
|
|
119
|
+
]);
|
|
120
|
+
const processor = useMemo2(() => {
|
|
121
|
+
if (!services || !conversation) {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
log("creating processor", {
|
|
125
|
+
preset,
|
|
126
|
+
model: preset?.model,
|
|
127
|
+
settings
|
|
128
|
+
}, {
|
|
129
|
+
F: __dxlog_file,
|
|
130
|
+
L: 60,
|
|
131
|
+
S: void 0,
|
|
132
|
+
C: (f, a) => f(...a)
|
|
133
|
+
});
|
|
134
|
+
return new AiChatProcessor(conversation, services, {
|
|
135
|
+
observableRegistry,
|
|
136
|
+
blueprintRegistry,
|
|
137
|
+
model: preset?.model
|
|
138
|
+
});
|
|
139
|
+
}, [
|
|
140
|
+
services,
|
|
141
|
+
conversation,
|
|
142
|
+
blueprintRegistry,
|
|
143
|
+
preset
|
|
144
|
+
]);
|
|
145
|
+
return processor;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/hooks/useChatServices.ts
|
|
149
|
+
import * as Effect from "effect/Effect";
|
|
150
|
+
import { useMemo as useMemo3 } from "react";
|
|
151
|
+
import { useCapability } from "@dxos/app-framework";
|
|
152
|
+
import { TracingService } from "@dxos/functions";
|
|
153
|
+
import { AutomationCapabilities } from "@dxos/plugin-automation";
|
|
154
|
+
import { useClient } from "@dxos/react-client";
|
|
155
|
+
var useChatServices = ({ space, chat }) => {
|
|
156
|
+
const client = useClient();
|
|
157
|
+
space ??= client.spaces.default;
|
|
158
|
+
const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
159
|
+
return useMemo3(() => {
|
|
160
|
+
const runtime2 = runtimeResolver.getRuntime(space.id);
|
|
161
|
+
return () => runtime2.runPromise(Effect.gen(function* () {
|
|
162
|
+
return yield* Effect.runtime().pipe(Effect.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
|
|
163
|
+
}));
|
|
164
|
+
}, [
|
|
165
|
+
space,
|
|
166
|
+
chat?.traceQueue?.target
|
|
167
|
+
]);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/hooks/useContextBinder.ts
|
|
171
|
+
import { useState as useState3 } from "react";
|
|
172
|
+
import { AiContextBinder } from "@dxos/assistant";
|
|
173
|
+
import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
|
|
174
|
+
var useContextBinder = (chat) => {
|
|
175
|
+
const [binder, setBinder] = useState3();
|
|
176
|
+
useAsyncEffect2(async () => {
|
|
177
|
+
if (!chat?.queue.target) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const binder2 = new AiContextBinder(chat.queue.target);
|
|
181
|
+
await binder2.open();
|
|
182
|
+
setBinder(binder2);
|
|
183
|
+
return () => {
|
|
184
|
+
void binder2.close();
|
|
185
|
+
};
|
|
186
|
+
}, [
|
|
187
|
+
chat?.queue.target
|
|
188
|
+
]);
|
|
189
|
+
return binder;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// src/hooks/useContextObjects.ts
|
|
193
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
194
|
+
import { useCallback as useCallback2 } from "react";
|
|
195
|
+
import { Ref as Ref2 } from "@dxos/echo";
|
|
196
|
+
import { log as log2 } from "@dxos/log";
|
|
197
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
198
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
|
|
199
|
+
var useContextObjects = ({ space, context }) => {
|
|
200
|
+
var _effect = _useSignals2();
|
|
201
|
+
try {
|
|
202
|
+
const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
|
|
203
|
+
const handleUpdateObject = useCallback2(async (dxn, checked) => {
|
|
204
|
+
if (!space || !context) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const id = dxn.asEchoDXN();
|
|
208
|
+
const object = id && await space.db.getObjectById(id.echoId);
|
|
209
|
+
if (!object) {
|
|
210
|
+
log2.warn("Object not found", {
|
|
211
|
+
dxn,
|
|
212
|
+
id
|
|
213
|
+
}, {
|
|
214
|
+
F: __dxlog_file2,
|
|
215
|
+
L: 40,
|
|
216
|
+
S: void 0,
|
|
217
|
+
C: (f, a) => f(...a)
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const ref = Ref2.fromDXN(dxn);
|
|
222
|
+
if (checked) {
|
|
223
|
+
await context.bind({
|
|
224
|
+
objects: [
|
|
225
|
+
ref
|
|
226
|
+
]
|
|
227
|
+
});
|
|
228
|
+
} else {
|
|
229
|
+
await context.unbind({
|
|
230
|
+
objects: [
|
|
231
|
+
ref
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}, [
|
|
236
|
+
space,
|
|
237
|
+
context
|
|
238
|
+
]);
|
|
239
|
+
return {
|
|
240
|
+
objects,
|
|
241
|
+
onUpdateObject: handleUpdateObject
|
|
242
|
+
};
|
|
243
|
+
} finally {
|
|
244
|
+
_effect.f();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// src/hooks/useFlush.ts
|
|
249
|
+
import { useCallback as useCallback3, useRef, useState as useState4 } from "react";
|
|
250
|
+
var useFlush = (space) => {
|
|
251
|
+
const [state, setState] = useState4("idle");
|
|
252
|
+
const resetTimer = useRef(null);
|
|
253
|
+
const handleFlush = useCallback3(() => {
|
|
254
|
+
if (!space) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
queueMicrotask(async () => {
|
|
258
|
+
if (resetTimer.current) {
|
|
259
|
+
clearTimeout(resetTimer.current);
|
|
260
|
+
}
|
|
261
|
+
setState("flushing");
|
|
262
|
+
await space.db.flush();
|
|
263
|
+
setState("flushed");
|
|
264
|
+
resetTimer.current = setTimeout(() => {
|
|
265
|
+
setState("idle");
|
|
266
|
+
resetTimer.current = null;
|
|
267
|
+
}, 1e3);
|
|
268
|
+
});
|
|
269
|
+
}, [
|
|
270
|
+
space
|
|
271
|
+
]);
|
|
272
|
+
return {
|
|
273
|
+
state,
|
|
274
|
+
handleFlush
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// src/hooks/useItemTypes.ts
|
|
279
|
+
import * as Option from "effect/Option";
|
|
280
|
+
import { useEffect, useState as useState5 } from "react";
|
|
281
|
+
import { ItemAnnotation } from "@dxos/schema";
|
|
282
|
+
var useItemTypes = (space) => {
|
|
283
|
+
const [types, setTypes] = useState5([]);
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
if (!space) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
return space.db.schemaRegistry.query().subscribe((query) => {
|
|
289
|
+
const types2 = Array.from(new Set([
|
|
290
|
+
...space.db.graph.schemaRegistry.schemas,
|
|
291
|
+
...query.results
|
|
292
|
+
].filter((type) => Option.isSome(ItemAnnotation.get(type)))));
|
|
293
|
+
setTypes(types2);
|
|
294
|
+
}, {
|
|
295
|
+
fire: true
|
|
296
|
+
});
|
|
297
|
+
}, [
|
|
298
|
+
space
|
|
299
|
+
]);
|
|
300
|
+
return types;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/hooks/useOnline.ts
|
|
304
|
+
import { useState as useState6 } from "react";
|
|
305
|
+
var useOnline = () => {
|
|
306
|
+
const [online, setOnline] = useState6(true);
|
|
307
|
+
return [
|
|
308
|
+
online,
|
|
309
|
+
setOnline
|
|
310
|
+
];
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// src/hooks/usePresets.ts
|
|
314
|
+
import { useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo4, useState as useState7 } from "react";
|
|
315
|
+
var usePresets = (online) => {
|
|
316
|
+
const [preset, setPreset] = useState7();
|
|
317
|
+
const presets = useMemo4(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
318
|
+
online
|
|
319
|
+
]);
|
|
320
|
+
const presetOptions = useMemo4(() => presets.map(({ id, model, label }) => ({
|
|
321
|
+
id,
|
|
322
|
+
label: label ?? model
|
|
323
|
+
})), [
|
|
324
|
+
presets
|
|
325
|
+
]);
|
|
326
|
+
useEffect2(() => {
|
|
327
|
+
setPreset(presets[0]);
|
|
328
|
+
}, [
|
|
329
|
+
presets
|
|
330
|
+
]);
|
|
331
|
+
const handlePresetChange = useCallback4((id) => {
|
|
332
|
+
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
333
|
+
if (preset2) {
|
|
334
|
+
setPreset(preset2);
|
|
335
|
+
}
|
|
336
|
+
}, [
|
|
337
|
+
presets
|
|
338
|
+
]);
|
|
339
|
+
return {
|
|
340
|
+
preset,
|
|
341
|
+
presets: presetOptions,
|
|
342
|
+
onPresetChange: handlePresetChange
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// src/hooks/useReferencesProvider.ts
|
|
347
|
+
import { useMemo as useMemo5 } from "react";
|
|
348
|
+
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
|
|
349
|
+
import { Filter as Filter2, Obj as Obj2 } from "@dxos/echo";
|
|
350
|
+
var useReferencesProvider = (space) => {
|
|
351
|
+
const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
|
|
352
|
+
return useMemo5(() => {
|
|
353
|
+
if (!space) {
|
|
354
|
+
return void 0;
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
getReferences: async ({ query }) => {
|
|
358
|
+
const { objects } = await space.db.query(Filter2.everything()).run();
|
|
359
|
+
return objects.filter((object) => stringMatch(query, Obj2.getLabel(object) ?? "")).filter((object) => !!Obj2.getDXN(object)).map((object) => ({
|
|
360
|
+
uri: Obj2.getDXN(object).toString(),
|
|
361
|
+
label: Obj2.getLabel(object) ?? ""
|
|
362
|
+
}));
|
|
363
|
+
},
|
|
364
|
+
resolveReference: async ({ uri }) => {
|
|
365
|
+
const object = await space.db.query(Filter2.ids(uri)).first();
|
|
366
|
+
return {
|
|
367
|
+
uri,
|
|
368
|
+
label: Obj2.getLabel(object) ?? ""
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}, [
|
|
373
|
+
space,
|
|
374
|
+
blueprints
|
|
375
|
+
]);
|
|
376
|
+
};
|
|
377
|
+
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
378
|
+
|
|
379
|
+
// src/components/Chat/Chat.tsx
|
|
380
|
+
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
381
|
+
import { Prec } from "@codemirror/state";
|
|
382
|
+
import { keymap } from "@codemirror/view";
|
|
383
|
+
import { useRxValue } from "@effect-rx/rx-react";
|
|
384
|
+
import { createContext } from "@radix-ui/react-context";
|
|
385
|
+
import * as Array2 from "effect/Array";
|
|
386
|
+
import * as Option2 from "effect/Option";
|
|
387
|
+
import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef3, useState as useState12 } from "react";
|
|
388
|
+
import { Event } from "@dxos/async";
|
|
389
|
+
import { Obj as Obj5 } from "@dxos/echo";
|
|
390
|
+
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
391
|
+
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
392
|
+
import { useIdentity } from "@dxos/react-client/halo";
|
|
393
|
+
import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
394
|
+
import { ChatEditor, references } from "@dxos/react-ui-chat";
|
|
395
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
396
|
+
import { DataType } from "@dxos/schema";
|
|
397
|
+
import { isTruthy } from "@dxos/util";
|
|
398
|
+
|
|
399
|
+
// src/components/ChatPrompt/ChatActions.tsx
|
|
400
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
401
|
+
import React from "react";
|
|
402
|
+
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
403
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
404
|
+
var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
|
|
405
|
+
var _effect = _useSignals3();
|
|
406
|
+
try {
|
|
407
|
+
const { t } = useTranslation(meta.id);
|
|
408
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
409
|
+
className: mx("flex items-center mie-1", classNames)
|
|
410
|
+
}, children, /* @__PURE__ */ React.createElement(IconButton, {
|
|
411
|
+
disabled: !processing,
|
|
412
|
+
variant: "ghost",
|
|
413
|
+
size: 5,
|
|
414
|
+
icon: "ph--x--regular",
|
|
415
|
+
iconOnly: true,
|
|
416
|
+
label: t("button cancel processing"),
|
|
417
|
+
onClick: () => onEvent?.({
|
|
418
|
+
type: "cancel"
|
|
419
|
+
})
|
|
420
|
+
}), microphone && /* @__PURE__ */ React.createElement(IconButton, {
|
|
421
|
+
disabled: !processing,
|
|
422
|
+
classNames: mx(recording && "bg-primary-500"),
|
|
423
|
+
variant: "ghost",
|
|
424
|
+
size: 5,
|
|
425
|
+
icon: "ph--microphone--regular",
|
|
426
|
+
iconOnly: true,
|
|
427
|
+
noTooltip: true,
|
|
428
|
+
label: t("button microphone"),
|
|
429
|
+
onMouseDown: () => onEvent?.({
|
|
430
|
+
type: "record-start"
|
|
431
|
+
}),
|
|
432
|
+
onMouseUp: () => onEvent?.({
|
|
433
|
+
type: "record-stop"
|
|
434
|
+
}),
|
|
435
|
+
onTouchStart: () => onEvent?.({
|
|
436
|
+
type: "record-start"
|
|
437
|
+
}),
|
|
438
|
+
onTouchEnd: () => onEvent?.({
|
|
439
|
+
type: "record-stop"
|
|
440
|
+
})
|
|
441
|
+
}));
|
|
442
|
+
} finally {
|
|
443
|
+
_effect.f();
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/components/ChatPrompt/ChatOptions.tsx
|
|
448
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
449
|
+
import React2, { useMemo as useMemo6, useState as useState8 } from "react";
|
|
450
|
+
import { Filter as Filter3, Obj as Obj3, Type } from "@dxos/echo";
|
|
451
|
+
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
452
|
+
import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
453
|
+
import { Listbox, SearchList } from "@dxos/react-ui-searchlist";
|
|
454
|
+
import { Tabs } from "@dxos/react-ui-tabs";
|
|
455
|
+
var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-72 max-is-[--text-content]";
|
|
456
|
+
var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
|
|
457
|
+
var _effect = _useSignals4();
|
|
458
|
+
try {
|
|
459
|
+
const { t } = useTranslation2(meta.id);
|
|
460
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
461
|
+
role: "none",
|
|
462
|
+
className: "flex gap-0.5"
|
|
463
|
+
}, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
464
|
+
asChild: true
|
|
465
|
+
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
466
|
+
variant: "ghost",
|
|
467
|
+
icon: "ph--plus--regular",
|
|
468
|
+
iconOnly: true,
|
|
469
|
+
size: 5,
|
|
470
|
+
label: t("button context objects")
|
|
471
|
+
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
472
|
+
side: "top",
|
|
473
|
+
classNames: panelClassNames
|
|
474
|
+
}, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
|
|
475
|
+
space,
|
|
476
|
+
context
|
|
477
|
+
}), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
478
|
+
asChild: true
|
|
479
|
+
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
480
|
+
variant: "ghost",
|
|
481
|
+
icon: "ph--sliders-horizontal--regular",
|
|
482
|
+
iconOnly: true,
|
|
483
|
+
size: 5,
|
|
484
|
+
label: t("button context settings")
|
|
485
|
+
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
486
|
+
side: "top",
|
|
487
|
+
classNames: panelClassNames
|
|
488
|
+
}, /* @__PURE__ */ React2.createElement(Tabs.Root, {
|
|
489
|
+
orientation: "horizontal",
|
|
490
|
+
defaultValue: "blueprints",
|
|
491
|
+
defaultActivePart: "list",
|
|
492
|
+
tabIndex: -1
|
|
493
|
+
}, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
|
|
494
|
+
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'
|
|
495
|
+
}, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
|
|
496
|
+
value: "blueprints",
|
|
497
|
+
tabIndex: -1,
|
|
498
|
+
classNames: "dx-focus-ring-inset"
|
|
499
|
+
}, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
|
|
500
|
+
blueprintRegistry,
|
|
501
|
+
space,
|
|
502
|
+
context
|
|
503
|
+
})), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
|
|
504
|
+
value: "model",
|
|
505
|
+
tabIndex: -1,
|
|
506
|
+
classNames: "dx-focus-ring-inset !pli-0"
|
|
507
|
+
}, /* @__PURE__ */ React2.createElement(ModelsPanel, {
|
|
508
|
+
presets,
|
|
509
|
+
preset,
|
|
510
|
+
onPresetChange
|
|
511
|
+
})), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
|
|
512
|
+
classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
|
|
513
|
+
}, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
|
|
514
|
+
value: "blueprints",
|
|
515
|
+
icon: "ph--blueprint--regular",
|
|
516
|
+
label: t("blueprints in context title")
|
|
517
|
+
}), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
|
|
518
|
+
value: "model",
|
|
519
|
+
label: t("chat model title"),
|
|
520
|
+
icon: "ph--cpu--regular"
|
|
521
|
+
})))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
|
|
522
|
+
} finally {
|
|
523
|
+
_effect.f();
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
|
|
527
|
+
var _effect = _useSignals4();
|
|
528
|
+
try {
|
|
529
|
+
const { t } = useTranslation2(meta.id);
|
|
530
|
+
const blueprints = useBlueprints({
|
|
531
|
+
blueprintRegistry,
|
|
532
|
+
space
|
|
533
|
+
});
|
|
534
|
+
const activeBlueprints = useActiveBlueprints({
|
|
535
|
+
context
|
|
536
|
+
});
|
|
537
|
+
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
538
|
+
space,
|
|
539
|
+
context,
|
|
540
|
+
blueprintRegistry
|
|
541
|
+
});
|
|
542
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
543
|
+
classNames: "plb-cardSpacingChrome"
|
|
544
|
+
}, blueprints.map((blueprint) => {
|
|
545
|
+
const isActive = activeBlueprints.has(blueprint.key);
|
|
546
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
547
|
+
classNames: "flex items-center overflow-hidden",
|
|
548
|
+
key: blueprint.key,
|
|
549
|
+
value: blueprint.name,
|
|
550
|
+
onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
|
|
551
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
552
|
+
className: "grow truncate"
|
|
553
|
+
}, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
|
|
554
|
+
icon: "ph--check--regular",
|
|
555
|
+
classNames: [
|
|
556
|
+
!isActive && "invisible"
|
|
557
|
+
]
|
|
558
|
+
}));
|
|
559
|
+
})), /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
560
|
+
placeholder: t("search placeholder"),
|
|
561
|
+
classNames: "mbe-cardSpacingChrome",
|
|
562
|
+
autoFocus: true
|
|
563
|
+
}));
|
|
564
|
+
} finally {
|
|
565
|
+
_effect.f();
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
var ModelsPanel = ({ presets, preset, onPresetChange }) => {
|
|
569
|
+
var _effect = _useSignals4();
|
|
570
|
+
try {
|
|
571
|
+
return /* @__PURE__ */ React2.createElement(Listbox.Root, {
|
|
572
|
+
value: preset,
|
|
573
|
+
onValueChange: onPresetChange,
|
|
574
|
+
autoFocus: true
|
|
575
|
+
}, presets?.map(({ id, label }) => {
|
|
576
|
+
return /* @__PURE__ */ React2.createElement(Listbox.Option, {
|
|
577
|
+
key: id,
|
|
578
|
+
value: id
|
|
579
|
+
}, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
|
|
580
|
+
}));
|
|
581
|
+
} finally {
|
|
582
|
+
_effect.f();
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var ANY = "__any__";
|
|
586
|
+
var ObjectsPanel = ({ space, context }) => {
|
|
587
|
+
var _effect = _useSignals4();
|
|
588
|
+
try {
|
|
589
|
+
const { t } = useTranslation2(meta.id);
|
|
590
|
+
const types = useItemTypes(space);
|
|
591
|
+
const typenames = useMemo6(() => {
|
|
592
|
+
const typenames2 = types.map((type) => {
|
|
593
|
+
const typename2 = Type.getTypename(type);
|
|
594
|
+
return {
|
|
595
|
+
typename: typename2,
|
|
596
|
+
label: t("typename label", {
|
|
597
|
+
ns: typename2,
|
|
598
|
+
defaultValue: typename2
|
|
599
|
+
})
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
typenames2.sort((a, b) => a.label.localeCompare(b.label));
|
|
603
|
+
return typenames2;
|
|
604
|
+
}, [
|
|
605
|
+
types
|
|
606
|
+
]);
|
|
607
|
+
const [typename, setTypename] = useState8(ANY);
|
|
608
|
+
const anyFilter = useMemo6(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
|
|
609
|
+
typenames
|
|
610
|
+
]);
|
|
611
|
+
const objects = useQuery2(space, typename === ANY ? anyFilter : Filter3.typename(typename));
|
|
612
|
+
const { objects: contextObjects, onUpdateObject } = useContextObjects({
|
|
613
|
+
space,
|
|
614
|
+
context
|
|
615
|
+
});
|
|
616
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
617
|
+
classNames: "p-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
|
|
618
|
+
}, objects.length ? objects.map((object) => {
|
|
619
|
+
const label = Obj3.getLabel(object) ?? Obj3.getTypename(object) ?? object.id;
|
|
620
|
+
const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
|
|
621
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
622
|
+
classNames: "flex items-center overflow-hidden",
|
|
623
|
+
key: object.id,
|
|
624
|
+
value: object.id,
|
|
625
|
+
onSelect: () => onUpdateObject?.(Obj3.getDXN(object), !isActive)
|
|
626
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
627
|
+
className: "grow truncate"
|
|
628
|
+
}, label), /* @__PURE__ */ React2.createElement(Icon, {
|
|
629
|
+
icon: "ph--check--regular",
|
|
630
|
+
classNames: [
|
|
631
|
+
!isActive && "invisible"
|
|
632
|
+
]
|
|
633
|
+
}));
|
|
634
|
+
}) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
|
|
635
|
+
role: "none",
|
|
636
|
+
className: "grid grid-cols-[min-content_1fr] gap-2 pli-cardSpacingChrome mbe-cardSpacingChrome"
|
|
637
|
+
}, /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
638
|
+
value: typename === ANY ? void 0 : typename,
|
|
639
|
+
onValueChange: setTypename
|
|
640
|
+
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
641
|
+
density: "fine",
|
|
642
|
+
placeholder: t("type filter placeholder")
|
|
643
|
+
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
644
|
+
value: ANY
|
|
645
|
+
}, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
646
|
+
key: typename2,
|
|
647
|
+
value: typename2
|
|
648
|
+
}, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
649
|
+
placeholder: t("search placeholder"),
|
|
650
|
+
classNames: "mbe-0",
|
|
651
|
+
autoFocus: true
|
|
652
|
+
})));
|
|
653
|
+
} finally {
|
|
654
|
+
_effect.f();
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/components/ChatPrompt/ChatPresets.tsx
|
|
659
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
660
|
+
import React3 from "react";
|
|
661
|
+
import { Select as Select2 } from "@dxos/react-ui";
|
|
662
|
+
|
|
663
|
+
// src/components/ChatPrompt/ChatReferences.tsx
|
|
664
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
665
|
+
import React4 from "react";
|
|
666
|
+
import { Obj as Obj4 } from "@dxos/echo";
|
|
667
|
+
import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
668
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
669
|
+
var ChatReferences = ({ classNames, context, space }) => {
|
|
670
|
+
var _effect = _useSignals6();
|
|
671
|
+
try {
|
|
672
|
+
const { t } = useTranslation3(meta.id);
|
|
673
|
+
const { objects, onUpdateObject } = useContextObjects({
|
|
674
|
+
space,
|
|
675
|
+
context
|
|
676
|
+
});
|
|
677
|
+
return /* @__PURE__ */ React4.createElement("ul", {
|
|
678
|
+
className: mx2("flex flex-wrap", classNames)
|
|
679
|
+
}, objects.map((obj) => {
|
|
680
|
+
const dxn = Obj4.getDXN(obj);
|
|
681
|
+
const typename = Obj4.getTypename(obj);
|
|
682
|
+
const label = Obj4.getLabel(obj) ?? (typename ? [
|
|
683
|
+
"object name placeholder",
|
|
684
|
+
{
|
|
685
|
+
ns: typename
|
|
686
|
+
}
|
|
687
|
+
] : obj.id);
|
|
688
|
+
return /* @__PURE__ */ React4.createElement("li", {
|
|
689
|
+
key: dxn.toString(),
|
|
690
|
+
className: "dx-tag plb-0 pis-2 flex items-center",
|
|
691
|
+
"data-hue": "neutral"
|
|
692
|
+
}, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
|
|
693
|
+
iconOnly: true,
|
|
694
|
+
variant: "ghost",
|
|
695
|
+
label: t("remove object in context label"),
|
|
696
|
+
classNames: "p-0 hover:bg-transparent",
|
|
697
|
+
size: 3,
|
|
698
|
+
icon: "ph--x--bold",
|
|
699
|
+
onClick: () => onUpdateObject?.(dxn, false)
|
|
700
|
+
}));
|
|
701
|
+
}));
|
|
702
|
+
} finally {
|
|
703
|
+
_effect.f();
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
708
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
709
|
+
import React5, { useEffect as useEffect3, useState as useState9 } from "react";
|
|
710
|
+
import { Tooltip, useTimeout } from "@dxos/react-ui";
|
|
711
|
+
import { Spinner } from "@dxos/react-ui-sfx";
|
|
712
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
713
|
+
var period = 3e3;
|
|
714
|
+
var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
|
|
715
|
+
var _effect = _useSignals7();
|
|
716
|
+
try {
|
|
717
|
+
const [init, setInit] = useState9(false);
|
|
718
|
+
useEffect3(() => setInit(false), [
|
|
719
|
+
preset
|
|
720
|
+
]);
|
|
721
|
+
useTimeout(async () => {
|
|
722
|
+
setInit(true);
|
|
723
|
+
}, period / 2, [
|
|
724
|
+
preset
|
|
725
|
+
]);
|
|
726
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
727
|
+
role: "none",
|
|
728
|
+
className: mx3("relative flex", classNames)
|
|
729
|
+
}, /* @__PURE__ */ React5.createElement(Spinner, {
|
|
730
|
+
duration: period,
|
|
731
|
+
state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
|
|
732
|
+
...props
|
|
733
|
+
}), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
|
|
734
|
+
asChild: true,
|
|
735
|
+
content: error.message
|
|
736
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
737
|
+
className: "absolute inset-0"
|
|
738
|
+
})));
|
|
739
|
+
} finally {
|
|
740
|
+
_effect.f();
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
// src/components/ChatThread/ChatThread.tsx
|
|
745
|
+
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
746
|
+
import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo8, useState as useState11 } from "react";
|
|
747
|
+
import { PublicKey } from "@dxos/keys";
|
|
748
|
+
import { MarkdownStream } from "@dxos/react-ui-components";
|
|
749
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
750
|
+
import { keyToFallback } from "@dxos/util";
|
|
751
|
+
|
|
752
|
+
// src/components/ChatThread/registry.tsx
|
|
753
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
754
|
+
import React7 from "react";
|
|
755
|
+
import { log as log3 } from "@dxos/log";
|
|
756
|
+
import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
|
|
757
|
+
import { getXmlTextChild } from "@dxos/react-ui-editor";
|
|
758
|
+
import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
|
|
759
|
+
import { ContentBlock } from "@dxos/schema";
|
|
760
|
+
|
|
761
|
+
// src/components/ToolBlock/ToolBlock.tsx
|
|
762
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
763
|
+
import React6, { useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState10 } from "react";
|
|
764
|
+
import { useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
765
|
+
import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
|
|
766
|
+
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
767
|
+
import { isNonNullable as isNonNullable3, safeParseJson } from "@dxos/util";
|
|
768
|
+
var ToolBlock = ({ blocks = [] }) => {
|
|
769
|
+
var _effect = _useSignals8();
|
|
770
|
+
try {
|
|
771
|
+
const { t } = useTranslation4(meta.id);
|
|
772
|
+
const getToolCaption = (tool, status) => {
|
|
773
|
+
if (!tool) {
|
|
774
|
+
return t("calling tool label");
|
|
775
|
+
}
|
|
776
|
+
return status?.message ?? tool.description ?? [
|
|
777
|
+
t("calling label"),
|
|
778
|
+
tool.name
|
|
779
|
+
].join(" ");
|
|
780
|
+
};
|
|
781
|
+
const items = useMemo7(() => {
|
|
782
|
+
let lastToolCall;
|
|
783
|
+
const tools = [];
|
|
784
|
+
return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
|
|
785
|
+
switch (block._tag) {
|
|
786
|
+
case "toolCall": {
|
|
787
|
+
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
const tool = tools.find((tool2) => tool2.name === block.name);
|
|
791
|
+
lastToolCall = {
|
|
792
|
+
tool,
|
|
793
|
+
block
|
|
794
|
+
};
|
|
795
|
+
return {
|
|
796
|
+
title: getToolCaption(lastToolCall?.tool),
|
|
797
|
+
content: {
|
|
798
|
+
...block,
|
|
799
|
+
input: safeParseJson(block.input)
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
case "toolResult": {
|
|
804
|
+
if (block.error) {
|
|
805
|
+
return {
|
|
806
|
+
title: t("error label"),
|
|
807
|
+
content: block
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
|
|
811
|
+
lastToolCall = void 0;
|
|
812
|
+
return {
|
|
813
|
+
title,
|
|
814
|
+
content: {
|
|
815
|
+
...block,
|
|
816
|
+
result: safeParseJson(block.result)
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
case "summary": {
|
|
821
|
+
if (!lastToolCall) {
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
return {
|
|
825
|
+
title: t("summary label"),
|
|
826
|
+
content: block
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}).filter(isNonNullable3);
|
|
831
|
+
}, [
|
|
832
|
+
blocks
|
|
833
|
+
]);
|
|
834
|
+
if (!items.length) {
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
return /* @__PURE__ */ React6.createElement(ToolContainer, {
|
|
838
|
+
items
|
|
839
|
+
});
|
|
840
|
+
} finally {
|
|
841
|
+
_effect.f();
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
ToolBlock.displayName = "ToolBlock";
|
|
845
|
+
var ToolContainer = ({ items }) => {
|
|
846
|
+
var _effect = _useSignals8();
|
|
847
|
+
try {
|
|
848
|
+
const tabsRef = useRef2(null);
|
|
849
|
+
const [selected, setSelected] = useState10(0);
|
|
850
|
+
const [open, setOpen] = useState10(false);
|
|
851
|
+
useEffect4(() => {
|
|
852
|
+
if (open) {
|
|
853
|
+
tabsRef.current?.focus();
|
|
854
|
+
}
|
|
855
|
+
}, [
|
|
856
|
+
open
|
|
857
|
+
]);
|
|
858
|
+
const handleSelect = (index) => {
|
|
859
|
+
setSelected(index);
|
|
860
|
+
};
|
|
861
|
+
const data = items[selected]?.content;
|
|
862
|
+
return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
|
|
863
|
+
classNames: chatMessagePanel,
|
|
864
|
+
open,
|
|
865
|
+
onChangeOpen: setOpen
|
|
866
|
+
}, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
|
|
867
|
+
classNames: chatMessagePanelHeader
|
|
868
|
+
}, /* @__PURE__ */ React6.createElement(TextCrawl, {
|
|
869
|
+
key: "status-roll",
|
|
870
|
+
lines: items.map((item) => item.title)
|
|
871
|
+
})), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
|
|
872
|
+
classNames: [
|
|
873
|
+
"grid grid-cols-[32px_1fr]",
|
|
874
|
+
chatMessagePanelContent
|
|
875
|
+
]
|
|
876
|
+
}, /* @__PURE__ */ React6.createElement(NumericTabs, {
|
|
877
|
+
ref: tabsRef,
|
|
878
|
+
classNames: "p-1",
|
|
879
|
+
length: items.length,
|
|
880
|
+
selected,
|
|
881
|
+
onSelect: handleSelect
|
|
882
|
+
}), /* @__PURE__ */ React6.createElement(Json, {
|
|
883
|
+
data,
|
|
884
|
+
classNames: chatMessageJson,
|
|
885
|
+
replacer: {
|
|
886
|
+
maxDepth: 3,
|
|
887
|
+
maxArrayLen: 10,
|
|
888
|
+
maxStringLen: 128
|
|
889
|
+
}
|
|
890
|
+
})));
|
|
891
|
+
} finally {
|
|
892
|
+
_effect.f();
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// src/components/ChatThread/registry.tsx
|
|
897
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
|
|
898
|
+
var Fallback = ({ _tag, ...props }) => {
|
|
899
|
+
var _effect = _useSignals9();
|
|
900
|
+
try {
|
|
901
|
+
return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
|
|
902
|
+
classNames: "rounded-sm"
|
|
903
|
+
}, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
|
|
904
|
+
classNames: "bg-groupSurface"
|
|
905
|
+
}, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
|
|
906
|
+
classNames: "bg-modalSurface"
|
|
907
|
+
}, /* @__PURE__ */ React7.createElement(Json2, {
|
|
908
|
+
classNames: "!p-2 text-sm",
|
|
909
|
+
data: props
|
|
910
|
+
})));
|
|
911
|
+
} finally {
|
|
912
|
+
_effect.f();
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
var componentRegistry = {
|
|
916
|
+
//
|
|
917
|
+
// Widgets
|
|
918
|
+
//
|
|
919
|
+
["prompt"]: {
|
|
920
|
+
block: true,
|
|
921
|
+
factory: (props) => {
|
|
922
|
+
const text = getXmlTextChild(props.children);
|
|
923
|
+
return text ? new PromptWidget(text) : null;
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
["reference"]: {
|
|
927
|
+
block: false,
|
|
928
|
+
factory: (props) => {
|
|
929
|
+
const text = getXmlTextChild(props.children);
|
|
930
|
+
return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
["select"]: {
|
|
934
|
+
block: true,
|
|
935
|
+
factory: (props) => {
|
|
936
|
+
const options = props.children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
|
|
937
|
+
return options?.length ? new SelectWidget(options) : null;
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
["suggestion"]: {
|
|
941
|
+
block: true,
|
|
942
|
+
factory: (props) => {
|
|
943
|
+
const text = getXmlTextChild(props.children);
|
|
944
|
+
return text ? new SuggestionWidget(text) : null;
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
["summary"]: {
|
|
948
|
+
block: true,
|
|
949
|
+
factory: (props) => {
|
|
950
|
+
const text = getXmlTextChild(props.children);
|
|
951
|
+
return text ? new SummaryWidget(text) : null;
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
//
|
|
955
|
+
// React
|
|
956
|
+
//
|
|
957
|
+
["toolCall"]: {
|
|
958
|
+
block: true,
|
|
959
|
+
Component: ToolBlock
|
|
960
|
+
},
|
|
961
|
+
["toolResult"]: {
|
|
962
|
+
block: true,
|
|
963
|
+
Component: Fallback
|
|
964
|
+
},
|
|
965
|
+
["toolkit"]: {
|
|
966
|
+
block: true,
|
|
967
|
+
Component: Fallback
|
|
968
|
+
},
|
|
969
|
+
//
|
|
970
|
+
// Fallback
|
|
971
|
+
//
|
|
972
|
+
["json"]: {
|
|
973
|
+
block: true,
|
|
974
|
+
Component: Fallback
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
var blockToMarkdown = (context, message, block) => {
|
|
978
|
+
let str = _blockToMarkdown(context, message, block);
|
|
979
|
+
if (str && !block.pending) {
|
|
980
|
+
return str += "\n";
|
|
981
|
+
}
|
|
982
|
+
return str;
|
|
983
|
+
};
|
|
984
|
+
var _blockToMarkdown = (context, message, block) => {
|
|
985
|
+
log3("blockToMarkdown", {
|
|
986
|
+
block: JSON.stringify(block)
|
|
987
|
+
}, {
|
|
988
|
+
F: __dxlog_file3,
|
|
989
|
+
L: 125,
|
|
990
|
+
S: void 0,
|
|
991
|
+
C: (f, a) => f(...a)
|
|
992
|
+
});
|
|
993
|
+
switch (block._tag) {
|
|
994
|
+
case "text": {
|
|
995
|
+
if (message.sender.role === "user") {
|
|
996
|
+
return `
|
|
997
|
+
<prompt>${block.text}</prompt>
|
|
998
|
+
`;
|
|
999
|
+
} else {
|
|
1000
|
+
const text = block.text.trim();
|
|
1001
|
+
if (text.length > 0) {
|
|
1002
|
+
return text;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
case "suggestion": {
|
|
1008
|
+
if (block.pending) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
return `<suggestion>${block.text}</suggestion>`;
|
|
1012
|
+
}
|
|
1013
|
+
case "select": {
|
|
1014
|
+
if (block.pending || block.options.length === 0) {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
|
|
1018
|
+
}
|
|
1019
|
+
// TODO(burdon): Need label.
|
|
1020
|
+
case "reference": {
|
|
1021
|
+
return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
|
|
1022
|
+
}
|
|
1023
|
+
// case 'toolkit': {
|
|
1024
|
+
// return `<toolkit />`;
|
|
1025
|
+
// }
|
|
1026
|
+
case "toolCall": {
|
|
1027
|
+
context.updateWidget(block.toolCallId, {
|
|
1028
|
+
blocks: [
|
|
1029
|
+
block
|
|
1030
|
+
]
|
|
1031
|
+
});
|
|
1032
|
+
return `<toolCall id="${block.toolCallId}" />`;
|
|
1033
|
+
}
|
|
1034
|
+
case "toolResult": {
|
|
1035
|
+
context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
|
|
1036
|
+
blocks: [
|
|
1037
|
+
...blocks,
|
|
1038
|
+
block
|
|
1039
|
+
]
|
|
1040
|
+
}));
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
case "summary": {
|
|
1044
|
+
return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
|
|
1045
|
+
}
|
|
1046
|
+
// TODO(burdon): Need stable ID.
|
|
1047
|
+
default: {
|
|
1048
|
+
return `<json id="${message.id}">
|
|
1049
|
+
${JSON.stringify(block)}
|
|
1050
|
+
</json>`;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
// src/components/ChatThread/sync.ts
|
|
1056
|
+
import { log as log4 } from "@dxos/log";
|
|
1057
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
|
|
1058
|
+
var MessageThreadContext = class {
|
|
1059
|
+
_widgetState;
|
|
1060
|
+
constructor(_widgetState) {
|
|
1061
|
+
this._widgetState = _widgetState;
|
|
1062
|
+
}
|
|
1063
|
+
updateWidget(id, value) {
|
|
1064
|
+
this._widgetState?.updateWidget(id, value);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
var MessageSyncer = class {
|
|
1068
|
+
_model;
|
|
1069
|
+
_blockRenderer;
|
|
1070
|
+
_initialMessageId;
|
|
1071
|
+
_currentMessageIndex = 0;
|
|
1072
|
+
_currentBlockIndex = 0;
|
|
1073
|
+
_currentBlockContent;
|
|
1074
|
+
_context;
|
|
1075
|
+
constructor(_model, _blockRenderer) {
|
|
1076
|
+
this._model = _model;
|
|
1077
|
+
this._blockRenderer = _blockRenderer;
|
|
1078
|
+
this._context = new MessageThreadContext(this._model);
|
|
1079
|
+
}
|
|
1080
|
+
get context() {
|
|
1081
|
+
return this._context;
|
|
1082
|
+
}
|
|
1083
|
+
reset() {
|
|
1084
|
+
log4("reset", void 0, {
|
|
1085
|
+
F: __dxlog_file4,
|
|
1086
|
+
L: 58,
|
|
1087
|
+
S: this,
|
|
1088
|
+
C: (f, a) => f(...a)
|
|
1089
|
+
});
|
|
1090
|
+
this._initialMessageId = void 0;
|
|
1091
|
+
this._currentMessageIndex = 0;
|
|
1092
|
+
this._currentBlockIndex = 0;
|
|
1093
|
+
this._currentBlockContent = void 0;
|
|
1094
|
+
void this._model.reset("");
|
|
1095
|
+
}
|
|
1096
|
+
sync(messages) {
|
|
1097
|
+
log4("sync", {
|
|
1098
|
+
messages: messages.map((message) => message.blocks.length),
|
|
1099
|
+
currentMessageIndex: this._currentMessageIndex,
|
|
1100
|
+
currentBlockIndex: this._currentBlockIndex,
|
|
1101
|
+
currentBlockContent: this._currentBlockContent
|
|
1102
|
+
}, {
|
|
1103
|
+
F: __dxlog_file4,
|
|
1104
|
+
L: 67,
|
|
1105
|
+
S: this,
|
|
1106
|
+
C: (f, a) => f(...a)
|
|
1107
|
+
});
|
|
1108
|
+
if (this._initialMessageId !== messages[0]?.id) {
|
|
1109
|
+
this.reset();
|
|
1110
|
+
this._initialMessageId = messages[0]?.id;
|
|
1111
|
+
}
|
|
1112
|
+
let i = this._currentMessageIndex;
|
|
1113
|
+
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
1114
|
+
if (i > this._currentMessageIndex) {
|
|
1115
|
+
this._currentBlockIndex = 0;
|
|
1116
|
+
}
|
|
1117
|
+
this._currentMessageIndex = i;
|
|
1118
|
+
let j = this._currentBlockIndex;
|
|
1119
|
+
for (const block of message.blocks.slice(this._currentBlockIndex)) {
|
|
1120
|
+
this._currentBlockIndex = j;
|
|
1121
|
+
const currentBlockContent = this._blockRenderer(this._context, message, block);
|
|
1122
|
+
if (currentBlockContent) {
|
|
1123
|
+
let content = "";
|
|
1124
|
+
if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
|
|
1125
|
+
content = currentBlockContent.slice(this._currentBlockContent.length);
|
|
1126
|
+
} else {
|
|
1127
|
+
content = currentBlockContent;
|
|
1128
|
+
}
|
|
1129
|
+
void this._model.append(content);
|
|
1130
|
+
this._currentBlockContent = currentBlockContent;
|
|
1131
|
+
log4("append", {
|
|
1132
|
+
message: i,
|
|
1133
|
+
block: j,
|
|
1134
|
+
content
|
|
1135
|
+
}, {
|
|
1136
|
+
F: __dxlog_file4,
|
|
1137
|
+
L: 99,
|
|
1138
|
+
S: this,
|
|
1139
|
+
C: (f, a) => f(...a)
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
if (block.pending) {
|
|
1143
|
+
return;
|
|
1144
|
+
} else {
|
|
1145
|
+
this._currentBlockContent = void 0;
|
|
1146
|
+
this._currentBlockIndex++;
|
|
1147
|
+
}
|
|
1148
|
+
j++;
|
|
1149
|
+
}
|
|
1150
|
+
i++;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// src/components/ChatThread/ChatThread.tsx
|
|
1156
|
+
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, overscroll, onEvent }, forwardedRef) => {
|
|
1157
|
+
var _effect = _useSignals10();
|
|
1158
|
+
try {
|
|
1159
|
+
const userHue = useMemo8(() => {
|
|
1160
|
+
return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
|
|
1161
|
+
}, [
|
|
1162
|
+
identity
|
|
1163
|
+
]);
|
|
1164
|
+
const [controller, setController] = useState11(null);
|
|
1165
|
+
useImperativeHandle(forwardedRef, () => controller ? controller : null, [
|
|
1166
|
+
controller
|
|
1167
|
+
]);
|
|
1168
|
+
useEffect5(() => {
|
|
1169
|
+
controller?.scrollToBottom();
|
|
1170
|
+
}, [
|
|
1171
|
+
controller,
|
|
1172
|
+
error
|
|
1173
|
+
]);
|
|
1174
|
+
const syncer = useMemo8(() => controller && new MessageSyncer(controller, blockToMarkdown), [
|
|
1175
|
+
controller
|
|
1176
|
+
]);
|
|
1177
|
+
useEffect5(() => {
|
|
1178
|
+
syncer?.sync(messages);
|
|
1179
|
+
}, [
|
|
1180
|
+
syncer,
|
|
1181
|
+
messages
|
|
1182
|
+
]);
|
|
1183
|
+
const handleEvent = useCallback5((ev) => {
|
|
1184
|
+
switch (ev.type) {
|
|
1185
|
+
case "submit": {
|
|
1186
|
+
ev.value && onEvent?.({
|
|
1187
|
+
type: "submit",
|
|
1188
|
+
text: ev.value
|
|
1189
|
+
});
|
|
1190
|
+
break;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}, [
|
|
1194
|
+
onEvent
|
|
1195
|
+
]);
|
|
1196
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1197
|
+
className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
|
|
1198
|
+
style: {
|
|
1199
|
+
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1200
|
+
}
|
|
1201
|
+
}, /* @__PURE__ */ React8.createElement(MarkdownStream, {
|
|
1202
|
+
ref: setController,
|
|
1203
|
+
registry: componentRegistry,
|
|
1204
|
+
cursor,
|
|
1205
|
+
fadeIn,
|
|
1206
|
+
overscroll,
|
|
1207
|
+
onEvent: handleEvent
|
|
1208
|
+
}));
|
|
1209
|
+
} finally {
|
|
1210
|
+
_effect.f();
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
// src/components/Chat/Chat.tsx
|
|
1215
|
+
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1216
|
+
var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
|
|
1217
|
+
var _effect = _useSignals11();
|
|
1218
|
+
try {
|
|
1219
|
+
const [debug, setDebug] = useState12(false);
|
|
1220
|
+
const space = getSpace(chat);
|
|
1221
|
+
const queue = useQueue(chat?.queue.dxn);
|
|
1222
|
+
const pending = useRxValue(processor.messages);
|
|
1223
|
+
const streaming = useRxValue(processor.streaming);
|
|
1224
|
+
const lastPrompt = useRef3(void 0);
|
|
1225
|
+
const messages = useMemo9(() => {
|
|
1226
|
+
const queueMessages = queue?.objects?.filter(Obj5.instanceOf(DataType.Message)) ?? [];
|
|
1227
|
+
return Array2.dedupeWith([
|
|
1228
|
+
...queueMessages,
|
|
1229
|
+
...pending
|
|
1230
|
+
], (a, b) => a.id === b.id);
|
|
1231
|
+
}, [
|
|
1232
|
+
queue?.objects,
|
|
1233
|
+
pending
|
|
1234
|
+
]);
|
|
1235
|
+
const event = useMemo9(() => new Event(), []);
|
|
1236
|
+
useEffect6(() => {
|
|
1237
|
+
return event.on((ev) => {
|
|
1238
|
+
switch (ev.type) {
|
|
1239
|
+
case "toggle-debug": {
|
|
1240
|
+
setDebug((current) => !current);
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
case "submit": {
|
|
1244
|
+
const text = ev.text.trim();
|
|
1245
|
+
if (!streaming && text.length) {
|
|
1246
|
+
lastPrompt.current = ev.text;
|
|
1247
|
+
void processor.request({
|
|
1248
|
+
message: text
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
case "retry": {
|
|
1254
|
+
if (!streaming) {
|
|
1255
|
+
void processor.retry();
|
|
1256
|
+
}
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
case "cancel": {
|
|
1260
|
+
if (streaming) {
|
|
1261
|
+
void processor.cancel();
|
|
1262
|
+
if (lastPrompt.current) {
|
|
1263
|
+
event.emit({
|
|
1264
|
+
type: "update-prompt",
|
|
1265
|
+
text: lastPrompt.current
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
default: {
|
|
1272
|
+
onEvent?.(ev);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
}, [
|
|
1277
|
+
event,
|
|
1278
|
+
processor,
|
|
1279
|
+
streaming,
|
|
1280
|
+
onEvent
|
|
1281
|
+
]);
|
|
1282
|
+
if (!space) {
|
|
1283
|
+
return null;
|
|
1284
|
+
}
|
|
1285
|
+
return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
|
|
1286
|
+
debug,
|
|
1287
|
+
event,
|
|
1288
|
+
chat,
|
|
1289
|
+
space,
|
|
1290
|
+
messages,
|
|
1291
|
+
processor,
|
|
1292
|
+
...props
|
|
1293
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1294
|
+
role: "none",
|
|
1295
|
+
className: mx5("flex flex-col bs-full is-full", classNames)
|
|
1296
|
+
}, children));
|
|
1297
|
+
} finally {
|
|
1298
|
+
_effect.f();
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
ChatRoot.displayName = "Chat.Root";
|
|
1302
|
+
var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
|
|
1303
|
+
var _effect = _useSignals11();
|
|
1304
|
+
try {
|
|
1305
|
+
const { t } = useTranslation5(meta.id);
|
|
1306
|
+
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
1307
|
+
const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
|
|
1308
|
+
const streaming = useRxValue(processor.streaming);
|
|
1309
|
+
const active = useRxValue(processor.active);
|
|
1310
|
+
const activeRef = useDynamicRef(active);
|
|
1311
|
+
const editorRef = useRef3(null);
|
|
1312
|
+
const [recordingState, setRecordingState] = useState12(false);
|
|
1313
|
+
useEffect6(() => {
|
|
1314
|
+
return event.on((event2) => {
|
|
1315
|
+
switch (event2.type) {
|
|
1316
|
+
case "update-prompt":
|
|
1317
|
+
if (!editorRef.current?.getText()?.length) {
|
|
1318
|
+
editorRef.current?.setText(event2.text);
|
|
1319
|
+
editorRef.current?.focus();
|
|
1320
|
+
}
|
|
1321
|
+
break;
|
|
1322
|
+
case "record-start":
|
|
1323
|
+
setRecordingState(true);
|
|
1324
|
+
break;
|
|
1325
|
+
case "record-stop":
|
|
1326
|
+
setRecordingState(false);
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
}, [
|
|
1331
|
+
event
|
|
1332
|
+
]);
|
|
1333
|
+
const { recording } = useVoiceInput({
|
|
1334
|
+
active: recordingState,
|
|
1335
|
+
onUpdate: (text) => {
|
|
1336
|
+
editorRef.current?.setText(text);
|
|
1337
|
+
editorRef.current?.focus();
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
const referencesProvider = useReferencesProvider(space);
|
|
1341
|
+
const extensions = useMemo9(() => {
|
|
1342
|
+
return [
|
|
1343
|
+
referencesProvider && references({
|
|
1344
|
+
provider: referencesProvider
|
|
1345
|
+
}),
|
|
1346
|
+
Prec.highest(keymap.of([
|
|
1347
|
+
{
|
|
1348
|
+
key: "cmd-d",
|
|
1349
|
+
preventDefault: true,
|
|
1350
|
+
run: () => {
|
|
1351
|
+
event.emit({
|
|
1352
|
+
type: "toggle-debug"
|
|
1353
|
+
});
|
|
1354
|
+
return true;
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
expandable && {
|
|
1358
|
+
key: "cmd-ArrowUp",
|
|
1359
|
+
preventDefault: true,
|
|
1360
|
+
run: () => {
|
|
1361
|
+
event.emit({
|
|
1362
|
+
type: "thread-open"
|
|
1363
|
+
});
|
|
1364
|
+
return true;
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
expandable && {
|
|
1368
|
+
key: "cmd-ArrowDown",
|
|
1369
|
+
preventDefault: true,
|
|
1370
|
+
run: () => {
|
|
1371
|
+
event.emit({
|
|
1372
|
+
type: "thread-close"
|
|
1373
|
+
});
|
|
1374
|
+
return true;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
].filter(isTruthy)))
|
|
1378
|
+
].filter(isTruthy);
|
|
1379
|
+
}, [
|
|
1380
|
+
event,
|
|
1381
|
+
expandable,
|
|
1382
|
+
referencesProvider
|
|
1383
|
+
]);
|
|
1384
|
+
const handleSubmit = useCallback6((text) => {
|
|
1385
|
+
if (!activeRef.current) {
|
|
1386
|
+
event.emit({
|
|
1387
|
+
type: "submit",
|
|
1388
|
+
text
|
|
1389
|
+
});
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
}, [
|
|
1393
|
+
event
|
|
1394
|
+
]);
|
|
1395
|
+
const handleEvent = useCallback6((ev) => {
|
|
1396
|
+
event.emit(ev);
|
|
1397
|
+
}, [
|
|
1398
|
+
event
|
|
1399
|
+
]);
|
|
1400
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1401
|
+
role: "group",
|
|
1402
|
+
className: mx5("flex flex-col is-full density-fine", outline && [
|
|
1403
|
+
"p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
|
|
1404
|
+
], classNames)
|
|
1405
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1406
|
+
role: "none",
|
|
1407
|
+
className: "flex gap-2"
|
|
1408
|
+
}, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
|
|
1409
|
+
classNames: "p-1",
|
|
1410
|
+
preset,
|
|
1411
|
+
error,
|
|
1412
|
+
processing: streaming
|
|
1413
|
+
}), /* @__PURE__ */ React9.createElement(ChatEditor, {
|
|
1414
|
+
ref: editorRef,
|
|
1415
|
+
autoFocus: true,
|
|
1416
|
+
lineWrapping: true,
|
|
1417
|
+
classNames: "col-span-2 pbs-0.5",
|
|
1418
|
+
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1419
|
+
extensions,
|
|
1420
|
+
onSubmit: handleSubmit
|
|
1421
|
+
})), settings && /* @__PURE__ */ React9.createElement("div", {
|
|
1422
|
+
role: "none",
|
|
1423
|
+
className: "flex pbs-2 items-center"
|
|
1424
|
+
}, /* @__PURE__ */ React9.createElement(ChatOptions, {
|
|
1425
|
+
space,
|
|
1426
|
+
blueprintRegistry: processor.blueprintRegistry,
|
|
1427
|
+
context: processor.context,
|
|
1428
|
+
preset,
|
|
1429
|
+
presets,
|
|
1430
|
+
onPresetChange
|
|
1431
|
+
}), /* @__PURE__ */ React9.createElement("div", {
|
|
1432
|
+
role: "none",
|
|
1433
|
+
className: "pli-cardSpacingChrome grow"
|
|
1434
|
+
}, /* @__PURE__ */ React9.createElement(ChatReferences, {
|
|
1435
|
+
space,
|
|
1436
|
+
context: processor.context
|
|
1437
|
+
})), /* @__PURE__ */ React9.createElement(ChatActions, {
|
|
1438
|
+
classNames: "col-span-2",
|
|
1439
|
+
microphone: true,
|
|
1440
|
+
recording,
|
|
1441
|
+
processing: streaming,
|
|
1442
|
+
onEvent: handleEvent
|
|
1443
|
+
}, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Label, {
|
|
1444
|
+
srOnly: true
|
|
1445
|
+
}, t("online switch label")), /* @__PURE__ */ React9.createElement(Input.Switch, {
|
|
1446
|
+
classNames: "mis-2 mie-2",
|
|
1447
|
+
checked: online,
|
|
1448
|
+
onCheckedChange: onOnlineChange
|
|
1449
|
+
})))));
|
|
1450
|
+
} finally {
|
|
1451
|
+
_effect.f();
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
ChatPrompt.displayName = "Chat.Prompt";
|
|
1455
|
+
var ChatThread2 = (props) => {
|
|
1456
|
+
var _effect = _useSignals11();
|
|
1457
|
+
try {
|
|
1458
|
+
const { event, messages, processor } = useChatContext(ChatThread2.displayName);
|
|
1459
|
+
const identity = useIdentity();
|
|
1460
|
+
const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
|
|
1461
|
+
const scrollerRef = useRef3(null);
|
|
1462
|
+
useEffect6(() => {
|
|
1463
|
+
return event.on((event2) => {
|
|
1464
|
+
switch (event2.type) {
|
|
1465
|
+
case "submit":
|
|
1466
|
+
case "scroll-to-bottom":
|
|
1467
|
+
scrollerRef.current?.scrollToBottom();
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
}, [
|
|
1472
|
+
event
|
|
1473
|
+
]);
|
|
1474
|
+
const handleEvent = useCallback6((ev) => {
|
|
1475
|
+
event.emit(ev);
|
|
1476
|
+
}, [
|
|
1477
|
+
event
|
|
1478
|
+
]);
|
|
1479
|
+
if (!identity) {
|
|
1480
|
+
return null;
|
|
1481
|
+
}
|
|
1482
|
+
return /* @__PURE__ */ React9.createElement(ChatThread, {
|
|
1483
|
+
...props,
|
|
1484
|
+
ref: scrollerRef,
|
|
1485
|
+
identity,
|
|
1486
|
+
messages,
|
|
1487
|
+
error,
|
|
1488
|
+
onEvent: handleEvent
|
|
1489
|
+
});
|
|
1490
|
+
} finally {
|
|
1491
|
+
_effect.f();
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
ChatThread2.displayName = "Chat.Thread";
|
|
1495
|
+
var Chat = {
|
|
1496
|
+
Root: ChatRoot,
|
|
1497
|
+
Prompt: ChatPrompt,
|
|
1498
|
+
Thread: ChatThread2
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1501
|
+
export {
|
|
1502
|
+
useBlueprintRegistry,
|
|
1503
|
+
useBlueprints,
|
|
1504
|
+
useActiveBlueprints,
|
|
1505
|
+
useBlueprintHandlers,
|
|
1506
|
+
useChatProcessor,
|
|
1507
|
+
useChatServices,
|
|
1508
|
+
useContextBinder,
|
|
1509
|
+
useContextObjects,
|
|
1510
|
+
useFlush,
|
|
1511
|
+
useItemTypes,
|
|
1512
|
+
useOnline,
|
|
1513
|
+
usePresets,
|
|
1514
|
+
useReferencesProvider,
|
|
1515
|
+
ChatContextProvider,
|
|
1516
|
+
useChatContext,
|
|
1517
|
+
Chat
|
|
1518
|
+
};
|
|
1519
|
+
//# sourceMappingURL=chunk-357IHWQL.mjs.map
|