@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
|
@@ -1,2333 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ServiceType
|
|
4
|
-
} from "./chunk-7YOGZI66.mjs";
|
|
5
|
-
import {
|
|
6
|
-
AssistantCapabilities
|
|
7
|
-
} from "./chunk-YPXEA46Q.mjs";
|
|
8
|
-
import {
|
|
9
|
-
meta
|
|
10
|
-
} from "./chunk-VFY2JG62.mjs";
|
|
11
|
-
|
|
12
|
-
// src/hooks/useBlueprintRegistry.ts
|
|
13
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
14
|
-
import { useSignalEffect } from "@preact/signals-react";
|
|
15
|
-
import { useCallback, useMemo, useState } from "react";
|
|
16
|
-
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
17
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
18
|
-
import { Filter, Obj, Ref } from "@dxos/echo";
|
|
19
|
-
import { isNonNullable } from "@dxos/util";
|
|
20
|
-
var useBlueprintRegistry = () => {
|
|
21
|
-
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
22
|
-
return useMemo(() => new Blueprint.Registry(blueprints), [
|
|
23
|
-
blueprints
|
|
24
|
-
]);
|
|
25
|
-
};
|
|
26
|
-
var useBlueprints = ({ blueprintRegistry }) => useMemo(() => blueprintRegistry?.query() ?? [], [
|
|
27
|
-
blueprintRegistry
|
|
28
|
-
]);
|
|
29
|
-
var useActiveBlueprints = ({ context }) => {
|
|
30
|
-
var _effect = _useSignals();
|
|
31
|
-
try {
|
|
32
|
-
const [active, setActive] = useState(/* @__PURE__ */ new Map());
|
|
33
|
-
useSignalEffect(() => {
|
|
34
|
-
const refs = [
|
|
35
|
-
...context?.blueprints.value ?? []
|
|
36
|
-
];
|
|
37
|
-
const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
|
|
38
|
-
setActive(new Map(blueprints.map((blueprint) => [
|
|
39
|
-
blueprint.key,
|
|
40
|
-
blueprint
|
|
41
|
-
])));
|
|
42
|
-
});
|
|
43
|
-
return active;
|
|
44
|
-
} finally {
|
|
45
|
-
_effect.f();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
|
|
49
|
-
const onUpdateBlueprint = useCallback(async (key, checked) => {
|
|
50
|
-
if (!context || !blueprintRegistry) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
54
|
-
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
55
|
-
if (checked) {
|
|
56
|
-
if (!storedBlueprint) {
|
|
57
|
-
const blueprint = blueprintRegistry.getByKey(key);
|
|
58
|
-
if (!blueprint) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
62
|
-
}
|
|
63
|
-
await context.bind({
|
|
64
|
-
blueprints: [
|
|
65
|
-
Ref.make(storedBlueprint)
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
} else if (storedBlueprint) {
|
|
69
|
-
await context.unbind({
|
|
70
|
-
blueprints: [
|
|
71
|
-
Ref.make(storedBlueprint)
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}, [
|
|
76
|
-
space,
|
|
77
|
-
context,
|
|
78
|
-
blueprintRegistry
|
|
79
|
-
]);
|
|
80
|
-
return {
|
|
81
|
-
onUpdateBlueprint
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// src/hooks/useChatProcessor.ts
|
|
86
|
-
import { RegistryContext } from "@effect-rx/rx-react";
|
|
87
|
-
import { useContext, useMemo as useMemo2 } from "react";
|
|
88
|
-
import { AiConversation } from "@dxos/assistant";
|
|
89
|
-
import { log as log2 } from "@dxos/log";
|
|
90
|
-
|
|
91
|
-
// src/processor/presets.ts
|
|
92
|
-
import { Schema } from "effect";
|
|
93
|
-
var ModelProviders = [
|
|
94
|
-
"dxos-local",
|
|
95
|
-
"dxos-remote",
|
|
96
|
-
"lm-studio"
|
|
97
|
-
];
|
|
98
|
-
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
99
|
-
var createModelLabel = (model) => {
|
|
100
|
-
const parts = model.split("/");
|
|
101
|
-
return parts[parts.length - 1];
|
|
102
|
-
};
|
|
103
|
-
var AiServicePresets = [
|
|
104
|
-
{
|
|
105
|
-
provider: "dxos-remote",
|
|
106
|
-
model: "@anthropic/claude-opus-4-0"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
provider: "dxos-remote",
|
|
110
|
-
model: "@anthropic/claude-sonnet-4-0"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
provider: "dxos-remote",
|
|
114
|
-
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
provider: "lm-studio",
|
|
118
|
-
model: "@google/gemma-3-27b"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
provider: "lm-studio",
|
|
122
|
-
model: "@mlx-community/llama-3.2-3b-instruct"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
model: "deepseek-r1:latest",
|
|
126
|
-
provider: "dxos-local"
|
|
127
|
-
}
|
|
128
|
-
].map(({ model, provider }, i) => ({
|
|
129
|
-
id: `preset-${i}`,
|
|
130
|
-
provider,
|
|
131
|
-
model,
|
|
132
|
-
label: createModelLabel(model)
|
|
133
|
-
}));
|
|
134
|
-
|
|
135
|
-
// src/processor/processor.ts
|
|
136
|
-
import { Registry, Rx } from "@effect-rx/rx-react";
|
|
137
|
-
import { Cause, Effect, Exit, Fiber, Layer, Option } from "effect";
|
|
138
|
-
import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
139
|
-
import { AiSession, ArtifactDiffResolver, GenerationObserver, createSystemPrompt } from "@dxos/assistant";
|
|
140
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
141
|
-
import { throwCause } from "@dxos/effect";
|
|
142
|
-
import { log } from "@dxos/log";
|
|
143
|
-
import { DataType } from "@dxos/schema";
|
|
144
|
-
import { trim } from "@dxos/util";
|
|
145
|
-
function _define_property(obj, key, value) {
|
|
146
|
-
if (key in obj) {
|
|
147
|
-
Object.defineProperty(obj, key, {
|
|
148
|
-
value,
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true
|
|
152
|
-
});
|
|
153
|
-
} else {
|
|
154
|
-
obj[key] = value;
|
|
155
|
-
}
|
|
156
|
-
return obj;
|
|
157
|
-
}
|
|
158
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
|
|
159
|
-
var defaultOptions = {
|
|
160
|
-
model: DEFAULT_EDGE_MODEL
|
|
161
|
-
};
|
|
162
|
-
var AiChatProcessor = class {
|
|
163
|
-
get isRunning() {
|
|
164
|
-
return !!this._fiber;
|
|
165
|
-
}
|
|
166
|
-
get context() {
|
|
167
|
-
return this._conversation.context;
|
|
168
|
-
}
|
|
169
|
-
get conversation() {
|
|
170
|
-
return this._conversation;
|
|
171
|
-
}
|
|
172
|
-
get blueprintRegistry() {
|
|
173
|
-
return this._options.blueprintRegistry;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Initiates a new request.
|
|
177
|
-
*/
|
|
178
|
-
async request(requestParam) {
|
|
179
|
-
if (this._fiber) {
|
|
180
|
-
await this.cancel();
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
183
|
-
this._lastRequest = requestParam;
|
|
184
|
-
this._rx.set(this.error, Option.none());
|
|
185
|
-
const request = this._conversation.createRequest({
|
|
186
|
-
system: this._options.system,
|
|
187
|
-
prompt: requestParam.message,
|
|
188
|
-
observer: this._observer
|
|
189
|
-
});
|
|
190
|
-
this._fiber = request.pipe(
|
|
191
|
-
Effect.provide(Layer.provideMerge(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL), this._services)),
|
|
192
|
-
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
193
|
-
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
194
|
-
Effect.asVoid,
|
|
195
|
-
Effect.tapErrorCause((cause) => {
|
|
196
|
-
log.error("request failed", {
|
|
197
|
-
cause
|
|
198
|
-
}, {
|
|
199
|
-
F: __dxlog_file,
|
|
200
|
-
L: 176,
|
|
201
|
-
S: this,
|
|
202
|
-
C: (f, a) => f(...a)
|
|
203
|
-
});
|
|
204
|
-
return Effect.void;
|
|
205
|
-
}),
|
|
206
|
-
Effect.runFork
|
|
207
|
-
);
|
|
208
|
-
const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
|
|
209
|
-
if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
|
|
210
|
-
throwCause(response.cause);
|
|
211
|
-
}
|
|
212
|
-
this._rx.set(this.error, Option.none());
|
|
213
|
-
this._lastRequest = void 0;
|
|
214
|
-
this._fiber = void 0;
|
|
215
|
-
} catch (err) {
|
|
216
|
-
log.error("request failed", {
|
|
217
|
-
err
|
|
218
|
-
}, {
|
|
219
|
-
F: __dxlog_file,
|
|
220
|
-
L: 192,
|
|
221
|
-
S: this,
|
|
222
|
-
C: (f, a) => f(...a)
|
|
223
|
-
});
|
|
224
|
-
this._rx.set(this.error, Option.some(new Error("AI service error", {
|
|
225
|
-
cause: err
|
|
226
|
-
})));
|
|
227
|
-
} finally {
|
|
228
|
-
this._fiber = void 0;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Cancels the current request.
|
|
233
|
-
*/
|
|
234
|
-
async cancel() {
|
|
235
|
-
await Effect.runPromise(Effect.gen(this, function* () {
|
|
236
|
-
if (this._fiber) {
|
|
237
|
-
yield* this._fiber.pipe(Fiber.interrupt);
|
|
238
|
-
}
|
|
239
|
-
}));
|
|
240
|
-
this._fiber = void 0;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Retry last failed request.
|
|
244
|
-
*/
|
|
245
|
-
async retry() {
|
|
246
|
-
if (this._lastRequest) {
|
|
247
|
-
return this.request(this._lastRequest);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Update the current chat's name.
|
|
252
|
-
*/
|
|
253
|
-
async updateName(chat) {
|
|
254
|
-
const system = trim`
|
|
255
|
-
It is extremely important that you respond only with the title and nothing else.
|
|
256
|
-
If you cannot do this effectively respond with "New Chat".
|
|
257
|
-
`;
|
|
258
|
-
const history = await this._conversation.getHistory();
|
|
259
|
-
const fiber = Effect.gen(this, function* () {
|
|
260
|
-
const session = new AiSession();
|
|
261
|
-
return yield* session.run({
|
|
262
|
-
system,
|
|
263
|
-
prompt: "Suggest a name for this chat",
|
|
264
|
-
history
|
|
265
|
-
});
|
|
266
|
-
}).pipe(
|
|
267
|
-
// TODO(burdon): Use simpler model.
|
|
268
|
-
Effect.provide(Layer.provideMerge(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL), this._services)),
|
|
269
|
-
Effect.tap((messages) => {
|
|
270
|
-
const message = messages.find((message2) => message2.sender.role === "assistant");
|
|
271
|
-
const title = message?.blocks.find((b) => b._tag === "text")?.text;
|
|
272
|
-
if (title) {
|
|
273
|
-
chat.name = title;
|
|
274
|
-
}
|
|
275
|
-
}),
|
|
276
|
-
Effect.runFork
|
|
277
|
-
);
|
|
278
|
-
const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
|
|
279
|
-
if (!Exit.isSuccess(response)) {
|
|
280
|
-
throwCause(response.cause);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
constructor(_conversation, _services, _options = defaultOptions) {
|
|
284
|
-
_define_property(this, "_conversation", void 0);
|
|
285
|
-
_define_property(this, "_services", void 0);
|
|
286
|
-
_define_property(this, "_options", void 0);
|
|
287
|
-
_define_property(this, "_rx", void 0);
|
|
288
|
-
_define_property(this, "_observer", void 0);
|
|
289
|
-
_define_property(this, "_fiber", void 0);
|
|
290
|
-
_define_property(this, "_lastRequest", void 0);
|
|
291
|
-
_define_property(this, "_pending", void 0);
|
|
292
|
-
_define_property(this, "_streaming", void 0);
|
|
293
|
-
_define_property(this, "streaming", void 0);
|
|
294
|
-
_define_property(this, "messages", void 0);
|
|
295
|
-
_define_property(this, "error", void 0);
|
|
296
|
-
_define_property(this, "_artifactDiffResolver", void 0);
|
|
297
|
-
_define_property(this, "_onMessage", void 0);
|
|
298
|
-
_define_property(this, "_onBlock", void 0);
|
|
299
|
-
this._conversation = _conversation;
|
|
300
|
-
this._services = _services;
|
|
301
|
-
this._options = _options;
|
|
302
|
-
this._pending = Rx.make([]);
|
|
303
|
-
this._streaming = Rx.make(Option.none());
|
|
304
|
-
this.streaming = Rx.make((get) => Option.isSome(get(this._streaming)));
|
|
305
|
-
this.messages = Rx.make((get) => Option.match(get(this._streaming), {
|
|
306
|
-
onNone: () => get(this._pending),
|
|
307
|
-
onSome: (streaming) => [
|
|
308
|
-
...get(this._pending),
|
|
309
|
-
streaming
|
|
310
|
-
]
|
|
311
|
-
}));
|
|
312
|
-
this.error = Rx.make(Option.none());
|
|
313
|
-
this._artifactDiffResolver = {
|
|
314
|
-
resolve: async (_artifacts) => {
|
|
315
|
-
const versions = /* @__PURE__ */ new Map();
|
|
316
|
-
return versions;
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
this._onMessage = Effect.fn(function* (message) {
|
|
320
|
-
this._rx.set(this._streaming, Option.none());
|
|
321
|
-
this._rx.update(this._pending, (pending) => [
|
|
322
|
-
...pending,
|
|
323
|
-
message
|
|
324
|
-
]);
|
|
325
|
-
}.bind(this));
|
|
326
|
-
this._onBlock = Effect.fn(function* (block) {
|
|
327
|
-
this._rx.update(this._streaming, (streaming) => {
|
|
328
|
-
const blocks = streaming.pipe(Option.map((streaming2) => streaming2.blocks.filter((b) => !b.pending)), Option.getOrElse(() => []));
|
|
329
|
-
return Option.some(Obj2.make(DataType.Message, {
|
|
330
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
331
|
-
sender: {
|
|
332
|
-
role: "assistant"
|
|
333
|
-
},
|
|
334
|
-
blocks: [
|
|
335
|
-
...blocks,
|
|
336
|
-
block
|
|
337
|
-
]
|
|
338
|
-
}));
|
|
339
|
-
});
|
|
340
|
-
}.bind(this));
|
|
341
|
-
this._rx = this._options.observableRegistry ?? Registry.make();
|
|
342
|
-
this._observer = GenerationObserver.make({
|
|
343
|
-
onBlock: this._onBlock,
|
|
344
|
-
onMessage: this._onMessage
|
|
345
|
-
});
|
|
346
|
-
if (this._options.model && !this._options.system) {
|
|
347
|
-
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
348
|
-
this._options.system = createSystemPrompt(capabilities);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// src/hooks/useChatProcessor.ts
|
|
354
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
355
|
-
var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
|
|
356
|
-
const observableRegistry = useContext(RegistryContext);
|
|
357
|
-
const conversation = useMemo2(() => {
|
|
358
|
-
if (!chat?.queue.target) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
return new AiConversation({
|
|
362
|
-
queue: chat.queue.target
|
|
363
|
-
});
|
|
364
|
-
}, [
|
|
365
|
-
chat?.queue.target
|
|
366
|
-
]);
|
|
367
|
-
const processor = useMemo2(() => {
|
|
368
|
-
if (!services || !conversation) {
|
|
369
|
-
return void 0;
|
|
370
|
-
}
|
|
371
|
-
log2("creating processor", {
|
|
372
|
-
preset,
|
|
373
|
-
model: preset?.model,
|
|
374
|
-
settings
|
|
375
|
-
}, {
|
|
376
|
-
F: __dxlog_file2,
|
|
377
|
-
L: 52,
|
|
378
|
-
S: void 0,
|
|
379
|
-
C: (f, a) => f(...a)
|
|
380
|
-
});
|
|
381
|
-
return new AiChatProcessor(conversation, services, {
|
|
382
|
-
observableRegistry,
|
|
383
|
-
blueprintRegistry,
|
|
384
|
-
model: preset?.model
|
|
385
|
-
});
|
|
386
|
-
}, [
|
|
387
|
-
services,
|
|
388
|
-
conversation,
|
|
389
|
-
blueprintRegistry,
|
|
390
|
-
preset
|
|
391
|
-
]);
|
|
392
|
-
return processor;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
// src/hooks/useChatServices.ts
|
|
396
|
-
import { AiToolkit } from "@effect/ai";
|
|
397
|
-
import { Layer as Layer2 } from "effect";
|
|
398
|
-
import { useMemo as useMemo3 } from "react";
|
|
399
|
-
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
|
|
400
|
-
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
401
|
-
import { ComputeEventLogger, CredentialsService, DatabaseService, LocalFunctionExecutionService, QueueService, RemoteFunctionExecutionService, TracingService } from "@dxos/functions";
|
|
402
|
-
|
|
403
|
-
// src/capabilities/index.ts
|
|
404
|
-
import { lazy } from "@dxos/app-framework";
|
|
405
|
-
var AiService2 = lazy(() => import("./ai-service-UDEPIPTO.mjs"));
|
|
406
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-PNAFQUYT.mjs"));
|
|
407
|
-
var AssistantState = lazy(() => import("./state-4VLKPLW3.mjs"));
|
|
408
|
-
var BlueprintDefinition = lazy(() => import("./blueprint-definition-275J3XL2.mjs"));
|
|
409
|
-
var EdgeModelResolver = lazy(() => import("./edge-model-resolver-SZHDLXCT.mjs"));
|
|
410
|
-
var IntentResolver = lazy(() => import("./intent-resolver-FIS3T5KP.mjs"));
|
|
411
|
-
var LocalModelResolver = lazy(() => import("./local-model-resolver-2KCBKMYA.mjs"));
|
|
412
|
-
var ReactSurface = lazy(() => import("./react-surface-4NLRKNBU.mjs"));
|
|
413
|
-
var Settings = lazy(() => import("./settings-7ZCZ6AS5.mjs"));
|
|
414
|
-
var Toolkit = lazy(() => import("./toolkit-2F2OL6WB.mjs"));
|
|
415
|
-
|
|
416
|
-
// src/hooks/useChatServices.ts
|
|
417
|
-
var useChatServices = ({ space, chat }) => {
|
|
418
|
-
const serviceLayer = useCapabilities2(AssistantCapabilities.AiServiceLayer).at(0) ?? Layer2.die("AiService not found");
|
|
419
|
-
const functions = useCapabilities2(Capabilities2.Functions);
|
|
420
|
-
const toolkits = useCapabilities2(Capabilities2.Toolkit);
|
|
421
|
-
const handlers = useCapabilities2(Capabilities2.ToolkitHandler);
|
|
422
|
-
return useMemo3(() => {
|
|
423
|
-
const allFunctions = functions.flat();
|
|
424
|
-
const toolkit = AiToolkit.merge(...toolkits);
|
|
425
|
-
const handlersLayer = Layer2.mergeAll(Layer2.empty, ...handlers);
|
|
426
|
-
return Layer2.mergeAll(serviceLayer, makeToolResolverFromFunctions(allFunctions, toolkit), makeToolExecutionServiceFromFunctions(allFunctions, toolkit, handlersLayer), CredentialsService.layerFromDatabase(), ComputeEventLogger.layerFromTracing).pipe(Layer2.provideMerge(Layer2.mergeAll(space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable, space ? QueueService.layer(space.queues) : QueueService.notAvailable, chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop, LocalFunctionExecutionService.layer, RemoteFunctionExecutionService.mockLayer)));
|
|
427
|
-
}, [
|
|
428
|
-
space,
|
|
429
|
-
functions,
|
|
430
|
-
toolkits,
|
|
431
|
-
handlers,
|
|
432
|
-
chat?.traceQueue?.target
|
|
433
|
-
]);
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
// src/hooks/useContextBinder.ts
|
|
437
|
-
import { useMemo as useMemo4 } from "react";
|
|
438
|
-
import { AiContextBinder } from "@dxos/assistant";
|
|
439
|
-
var useContextBinder = (chat) => {
|
|
440
|
-
const binder = useMemo4(() => {
|
|
441
|
-
const queue = chat?.queue.target;
|
|
442
|
-
return queue && new AiContextBinder(queue);
|
|
443
|
-
}, [
|
|
444
|
-
chat
|
|
445
|
-
]);
|
|
446
|
-
return binder;
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// src/hooks/useOnline.ts
|
|
450
|
-
import { useState as useState2 } from "react";
|
|
451
|
-
var useOnline = () => {
|
|
452
|
-
const [online, setOnline] = useState2(true);
|
|
453
|
-
return [
|
|
454
|
-
online,
|
|
455
|
-
setOnline
|
|
456
|
-
];
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
// src/hooks/usePresets.ts
|
|
460
|
-
import { useCallback as useCallback2, useEffect, useMemo as useMemo5, useState as useState3 } from "react";
|
|
461
|
-
var usePresets = (online) => {
|
|
462
|
-
const [preset, setPreset] = useState3();
|
|
463
|
-
const presets = useMemo5(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
464
|
-
online
|
|
465
|
-
]);
|
|
466
|
-
const presetOptions = useMemo5(() => presets.map(({ id, model, label }) => ({
|
|
467
|
-
id,
|
|
468
|
-
label: label ?? model
|
|
469
|
-
})), [
|
|
470
|
-
presets
|
|
471
|
-
]);
|
|
472
|
-
useEffect(() => {
|
|
473
|
-
setPreset(presets[0]);
|
|
474
|
-
}, [
|
|
475
|
-
presets
|
|
476
|
-
]);
|
|
477
|
-
const handlePresetChange = useCallback2((id) => {
|
|
478
|
-
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
479
|
-
if (preset2) {
|
|
480
|
-
setPreset(preset2);
|
|
481
|
-
}
|
|
482
|
-
}, [
|
|
483
|
-
presets
|
|
484
|
-
]);
|
|
485
|
-
return {
|
|
486
|
-
preset,
|
|
487
|
-
presets: presetOptions,
|
|
488
|
-
onPresetChange: handlePresetChange
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
// src/hooks/useContextObjects.ts
|
|
493
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
494
|
-
import { useCallback as useCallback3 } from "react";
|
|
495
|
-
import { Ref as Ref2 } from "@dxos/echo";
|
|
496
|
-
import { log as log3 } from "@dxos/log";
|
|
497
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
498
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
|
|
499
|
-
var useContextObjects = ({ space, context }) => {
|
|
500
|
-
var _effect = _useSignals2();
|
|
501
|
-
try {
|
|
502
|
-
const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
|
|
503
|
-
const handleUpdateObject = useCallback3(async (dxn, checked) => {
|
|
504
|
-
if (!space || !context) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
const id = dxn.asEchoDXN();
|
|
508
|
-
const object = id && await space.db.getObjectById(id.echoId);
|
|
509
|
-
if (!object) {
|
|
510
|
-
log3.warn("Object not found", {
|
|
511
|
-
dxn,
|
|
512
|
-
id
|
|
513
|
-
}, {
|
|
514
|
-
F: __dxlog_file3,
|
|
515
|
-
L: 40,
|
|
516
|
-
S: void 0,
|
|
517
|
-
C: (f, a) => f(...a)
|
|
518
|
-
});
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
const ref = Ref2.fromDXN(dxn);
|
|
522
|
-
if (checked) {
|
|
523
|
-
await context.bind({
|
|
524
|
-
objects: [
|
|
525
|
-
ref
|
|
526
|
-
]
|
|
527
|
-
});
|
|
528
|
-
} else {
|
|
529
|
-
await context.unbind({
|
|
530
|
-
objects: [
|
|
531
|
-
ref
|
|
532
|
-
]
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
}, [
|
|
536
|
-
space,
|
|
537
|
-
context
|
|
538
|
-
]);
|
|
539
|
-
return {
|
|
540
|
-
objects,
|
|
541
|
-
onUpdateObject: handleUpdateObject
|
|
542
|
-
};
|
|
543
|
-
} finally {
|
|
544
|
-
_effect.f();
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
// src/hooks/useExecutionGraph.ts
|
|
549
|
-
import { useMemo as useMemo6 } from "react";
|
|
550
|
-
import { Obj as Obj4 } from "@dxos/echo";
|
|
551
|
-
import { useQueue } from "@dxos/react-client/echo";
|
|
552
|
-
|
|
553
|
-
// src/execution-graph/execution-graph.ts
|
|
554
|
-
import { AgentStatus } from "@dxos/ai";
|
|
555
|
-
import { Obj as Obj3 } from "@dxos/echo";
|
|
556
|
-
import { MESSAGE_PROPERTY_TOOL_CALL_ID } from "@dxos/functions";
|
|
557
|
-
import { LogLevel } from "@dxos/log";
|
|
558
|
-
import { ContentBlock, DataType as DataType2 } from "@dxos/schema";
|
|
559
|
-
import { isNotFalsy } from "@dxos/util";
|
|
560
|
-
function _define_property2(obj, key, value) {
|
|
561
|
-
if (key in obj) {
|
|
562
|
-
Object.defineProperty(obj, key, {
|
|
563
|
-
value,
|
|
564
|
-
enumerable: true,
|
|
565
|
-
configurable: true,
|
|
566
|
-
writable: true
|
|
567
|
-
});
|
|
568
|
-
} else {
|
|
569
|
-
obj[key] = value;
|
|
570
|
-
}
|
|
571
|
-
return obj;
|
|
572
|
-
}
|
|
573
|
-
var ExecutionGraph = class {
|
|
574
|
-
/**
|
|
575
|
-
* Adds events to the graph.
|
|
576
|
-
*/
|
|
577
|
-
addEvents(events) {
|
|
578
|
-
for (const event of events) {
|
|
579
|
-
if (Obj3.instanceOf(DataType2.Message, event)) {
|
|
580
|
-
const messageCommits = messageToCommit(event);
|
|
581
|
-
this._commits.push(...messageCommits);
|
|
582
|
-
messageCommits.map((c) => c.branch).forEach((branch) => this._branchNames.add(branch));
|
|
583
|
-
} else if (Obj3.instanceOf(AgentStatus, event)) {
|
|
584
|
-
const branch = getBranchName({
|
|
585
|
-
parentMessage: event.parentMessage,
|
|
586
|
-
toolCallId: event.toolCallId
|
|
587
|
-
});
|
|
588
|
-
this._branchNames.add(branch);
|
|
589
|
-
this._commits.push({
|
|
590
|
-
id: event.id,
|
|
591
|
-
branch,
|
|
592
|
-
message: event.message,
|
|
593
|
-
icon: "ph--flag--regular",
|
|
594
|
-
parents: event.parentMessage && event.toolCallId ? [
|
|
595
|
-
getToolCallId(event.parentMessage, event.toolCallId)
|
|
596
|
-
] : void 0
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Returns the current state of the graph.
|
|
603
|
-
*/
|
|
604
|
-
getGraph(lastRequest = false) {
|
|
605
|
-
const idx = lastRequest ? this._commits.findLastIndex((c) => c.tags?.includes("user")) : -1;
|
|
606
|
-
const commits = idx === -1 ? this._commits : this._commits.slice(idx);
|
|
607
|
-
return {
|
|
608
|
-
branches: Array.from(this._branchNames),
|
|
609
|
-
commits
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
constructor() {
|
|
613
|
-
_define_property2(this, "_commits", []);
|
|
614
|
-
_define_property2(this, "_branchNames", /* @__PURE__ */ new Set());
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
var messageToCommit = (message) => {
|
|
618
|
-
return message.blocks.map((block, idx) => {
|
|
619
|
-
const branch = getMessageBranch(message);
|
|
620
|
-
const parent = getParentId(message);
|
|
621
|
-
const parents = parent ? [
|
|
622
|
-
parent
|
|
623
|
-
] : [];
|
|
624
|
-
switch (block._tag) {
|
|
625
|
-
case "text":
|
|
626
|
-
if (!block.text.trim().length) {
|
|
627
|
-
return null;
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
id: getGenericBlockId(message.id, idx),
|
|
631
|
-
branch,
|
|
632
|
-
parents,
|
|
633
|
-
...message.sender.role === "user" ? {
|
|
634
|
-
icon: "ph--user--regular",
|
|
635
|
-
tags: [
|
|
636
|
-
"user"
|
|
637
|
-
],
|
|
638
|
-
message: "Processing request..."
|
|
639
|
-
} : {
|
|
640
|
-
icon: "ph--robot--regular",
|
|
641
|
-
message: `Response (${block.text.split(" ").length} words)`
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
case "toolCall":
|
|
645
|
-
return {
|
|
646
|
-
id: getToolCallId(message.id, block.toolCallId),
|
|
647
|
-
branch,
|
|
648
|
-
parents,
|
|
649
|
-
icon: "ph--wrench--regular",
|
|
650
|
-
level: LogLevel.INFO,
|
|
651
|
-
// TODO(burdon): Lookup tool name/description?
|
|
652
|
-
message: `Calling tool (${block.name})`
|
|
653
|
-
};
|
|
654
|
-
case "toolResult":
|
|
655
|
-
return {
|
|
656
|
-
id: getToolResultId(message.id, block.toolCallId),
|
|
657
|
-
branch,
|
|
658
|
-
parents,
|
|
659
|
-
icon: block.error ? "ph--x-circle--regular" : "ph--check-circle--regular",
|
|
660
|
-
level: block.error ? LogLevel.ERROR : LogLevel.INFO,
|
|
661
|
-
message: block.error ? "Tool error: " + block.error : "Tool call succeeded"
|
|
662
|
-
};
|
|
663
|
-
case "summary":
|
|
664
|
-
return {
|
|
665
|
-
id: getGenericBlockId(message.id, idx),
|
|
666
|
-
branch,
|
|
667
|
-
parents,
|
|
668
|
-
icon: "ph--rocket--regular",
|
|
669
|
-
level: LogLevel.INFO,
|
|
670
|
-
message: ContentBlock.createSummaryMessage(block)
|
|
671
|
-
};
|
|
672
|
-
case "status":
|
|
673
|
-
return {
|
|
674
|
-
id: getGenericBlockId(message.id, idx),
|
|
675
|
-
branch,
|
|
676
|
-
parents,
|
|
677
|
-
message: block.statusText,
|
|
678
|
-
level: LogLevel.INFO,
|
|
679
|
-
icon: "ph--flag--regular"
|
|
680
|
-
};
|
|
681
|
-
case "reasoning":
|
|
682
|
-
return {
|
|
683
|
-
id: getGenericBlockId(message.id, idx),
|
|
684
|
-
branch,
|
|
685
|
-
parents,
|
|
686
|
-
message: block.reasoningText ?? "Thinking...",
|
|
687
|
-
icon: "ph--brain--regular"
|
|
688
|
-
};
|
|
689
|
-
case "reference":
|
|
690
|
-
return {
|
|
691
|
-
id: getGenericBlockId(message.id, idx),
|
|
692
|
-
branch,
|
|
693
|
-
parents,
|
|
694
|
-
icon: "ph--link--regular",
|
|
695
|
-
message: stringifyRef(block.reference)
|
|
696
|
-
};
|
|
697
|
-
default:
|
|
698
|
-
return null;
|
|
699
|
-
}
|
|
700
|
-
}).filter(isNotFalsy);
|
|
701
|
-
};
|
|
702
|
-
var getToolCallId = (messageId, toolCallId) => `${messageId}_toolCall_${toolCallId}`;
|
|
703
|
-
var getToolResultId = (messageId, toolCallId) => `${messageId}_toolResult_${toolCallId}`;
|
|
704
|
-
var getGenericBlockId = (messageId, idx) => `${messageId}_block_${idx}`;
|
|
705
|
-
var getBranchName = (options) => {
|
|
706
|
-
if (options.parentMessage && options.toolCallId) {
|
|
707
|
-
return `${options.parentMessage}_${options.toolCallId}`;
|
|
708
|
-
} else if (options.parentMessage) {
|
|
709
|
-
return options.parentMessage;
|
|
710
|
-
} else {
|
|
711
|
-
return "main";
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
var getMessageBranch = (message) => {
|
|
715
|
-
return getBranchName({
|
|
716
|
-
parentMessage: message.parentMessage,
|
|
717
|
-
toolCallId: message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]
|
|
718
|
-
});
|
|
719
|
-
};
|
|
720
|
-
var getParentId = (message) => {
|
|
721
|
-
if (message.parentMessage && message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]) {
|
|
722
|
-
return getToolCallId(message.parentMessage, message.properties[MESSAGE_PROPERTY_TOOL_CALL_ID]);
|
|
723
|
-
} else {
|
|
724
|
-
return void 0;
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
var stringifyRef = (ref) => {
|
|
728
|
-
if (ref.target) {
|
|
729
|
-
return stringifyObject(ref.target);
|
|
730
|
-
}
|
|
731
|
-
return ref.dxn.asEchoDXN()?.echoId ?? ref.dxn.asQueueDXN()?.objectId ?? "";
|
|
732
|
-
};
|
|
733
|
-
var stringifyObject = (obj) => {
|
|
734
|
-
return Obj3.getLabel(obj) ?? Obj3.getTypename(obj) ?? obj.id;
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// src/hooks/useExecutionGraph.ts
|
|
738
|
-
var useExecutionGraph = (queueRef, lastRequest = false) => {
|
|
739
|
-
const queue = useQueue(queueRef?.dxn);
|
|
740
|
-
return useMemo6(() => {
|
|
741
|
-
const graph = new ExecutionGraph();
|
|
742
|
-
graph.addEvents(queue?.objects.filter(Obj4.isObject) ?? []);
|
|
743
|
-
return graph.getGraph(lastRequest);
|
|
744
|
-
}, [
|
|
745
|
-
queue?.objects,
|
|
746
|
-
lastRequest
|
|
747
|
-
]);
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
// src/hooks/useFlush.ts
|
|
751
|
-
import { useCallback as useCallback4, useRef, useState as useState4 } from "react";
|
|
752
|
-
|
|
753
|
-
// src/hooks/useItemTypes.ts
|
|
754
|
-
import { Option as Option2 } from "effect";
|
|
755
|
-
import { useEffect as useEffect2, useState as useState5 } from "react";
|
|
756
|
-
import { ItemAnnotation } from "@dxos/schema";
|
|
757
|
-
var useItemTypes = (space) => {
|
|
758
|
-
const [types, setTypes] = useState5([]);
|
|
759
|
-
useEffect2(() => {
|
|
760
|
-
if (!space) {
|
|
761
|
-
return;
|
|
762
|
-
}
|
|
763
|
-
return space.db.schemaRegistry.query().subscribe((query) => {
|
|
764
|
-
const types2 = Array.from(new Set([
|
|
765
|
-
...space.db.graph.schemaRegistry.schemas,
|
|
766
|
-
...query.results
|
|
767
|
-
].filter((type) => Option2.isSome(ItemAnnotation.get(type)))));
|
|
768
|
-
setTypes(types2);
|
|
769
|
-
}, {
|
|
770
|
-
fire: true
|
|
771
|
-
});
|
|
772
|
-
}, [
|
|
773
|
-
space
|
|
774
|
-
]);
|
|
775
|
-
return types;
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
// src/hooks/useMatcherExtension.ts
|
|
779
|
-
import { useMemo as useMemo7 } from "react";
|
|
780
|
-
import { Type } from "@dxos/echo";
|
|
781
|
-
import { matchCompletion, staticCompletion, typeahead } from "@dxos/react-ui-editor";
|
|
782
|
-
|
|
783
|
-
// src/hooks/useReferencesProvider.ts
|
|
784
|
-
import { useMemo as useMemo8 } from "react";
|
|
785
|
-
import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
|
|
786
|
-
import { Filter as Filter2, Obj as Obj5 } from "@dxos/echo";
|
|
787
|
-
var useReferencesProvider = (space) => {
|
|
788
|
-
const blueprints = useCapabilities3(Capabilities3.BlueprintDefinition);
|
|
789
|
-
return useMemo8(() => {
|
|
790
|
-
if (!space) {
|
|
791
|
-
return void 0;
|
|
792
|
-
}
|
|
793
|
-
return {
|
|
794
|
-
getReferences: async ({ query }) => {
|
|
795
|
-
const { objects } = await space.db.query(Filter2.everything()).run();
|
|
796
|
-
return objects.filter((object) => stringMatch(query, Obj5.getLabel(object) ?? "")).filter((object) => !!Obj5.getDXN(object)).map((object) => ({
|
|
797
|
-
uri: Obj5.getDXN(object).toString(),
|
|
798
|
-
label: Obj5.getLabel(object) ?? ""
|
|
799
|
-
}));
|
|
800
|
-
},
|
|
801
|
-
resolveReference: async ({ uri }) => {
|
|
802
|
-
const object = await space.db.query(Filter2.ids(uri)).first();
|
|
803
|
-
return {
|
|
804
|
-
uri,
|
|
805
|
-
label: Obj5.getLabel(object) ?? ""
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
}, [
|
|
810
|
-
space,
|
|
811
|
-
blueprints
|
|
812
|
-
]);
|
|
813
|
-
};
|
|
814
|
-
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
815
|
-
|
|
816
|
-
// src/hooks/useResolveRef.ts
|
|
817
|
-
import { useMemo as useMemo9, useSyncExternalStore } from "react";
|
|
818
|
-
var useResolvedRef = (space, ref) => {
|
|
819
|
-
const { subscribe, getSnapshot } = useMemo9(() => {
|
|
820
|
-
const resolver = space.db.graph.createRefResolver({});
|
|
821
|
-
let currentCallback = void 0;
|
|
822
|
-
return {
|
|
823
|
-
subscribe: (cb) => {
|
|
824
|
-
currentCallback = cb;
|
|
825
|
-
return () => {
|
|
826
|
-
if (currentCallback === cb) {
|
|
827
|
-
currentCallback = void 0;
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
},
|
|
831
|
-
getSnapshot: () => resolver?.resolveSync(ref.dxn, true, () => {
|
|
832
|
-
currentCallback?.();
|
|
833
|
-
})
|
|
834
|
-
};
|
|
835
|
-
}, [
|
|
836
|
-
space,
|
|
837
|
-
ref.dxn.toString()
|
|
838
|
-
]);
|
|
839
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// src/components/Toolbox/Toolbox.tsx
|
|
843
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
844
|
-
import React, { Fragment, useEffect as useEffect3, useState as useState6 } from "react";
|
|
845
|
-
import { FunctionType } from "@dxos/functions";
|
|
846
|
-
import { log as log4 } from "@dxos/log";
|
|
847
|
-
import { Filter as Filter3, useQuery } from "@dxos/react-client/echo";
|
|
848
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
849
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
850
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
851
|
-
var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
|
|
852
|
-
var _effect = _useSignals3();
|
|
853
|
-
try {
|
|
854
|
-
const { t } = useTranslation(meta.id);
|
|
855
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
856
|
-
className: mx("flex flex-col overflow-y-auto box-content", classNames)
|
|
857
|
-
}, blueprints && blueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
858
|
-
title: "Blueprints",
|
|
859
|
-
items: blueprints.map(({ target }) => ({
|
|
860
|
-
name: target?.name ?? "",
|
|
861
|
-
description: target?.description ?? "",
|
|
862
|
-
subitems: target?.tools.map((toolId) => ({
|
|
863
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
864
|
-
}))
|
|
865
|
-
}))
|
|
866
|
-
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
867
|
-
title: "Blueprints",
|
|
868
|
-
items: activeBlueprints.map(({ target }) => ({
|
|
869
|
-
name: target?.name ?? "",
|
|
870
|
-
description: target?.description ?? "",
|
|
871
|
-
subitems: target?.tools.map((toolId) => ({
|
|
872
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
873
|
-
}))
|
|
874
|
-
}))
|
|
875
|
-
}), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
876
|
-
title: "Services",
|
|
877
|
-
items: services.map(({ service: { serviceId, name, description } }) => ({
|
|
878
|
-
name: name ?? serviceId,
|
|
879
|
-
description
|
|
880
|
-
}))
|
|
881
|
-
}), functions && functions.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
882
|
-
title: "Functions",
|
|
883
|
-
items: functions.map(({ name, description }) => ({
|
|
884
|
-
name,
|
|
885
|
-
description
|
|
886
|
-
}))
|
|
887
|
-
}));
|
|
888
|
-
} finally {
|
|
889
|
-
_effect.f();
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
var Section = ({ title, items, striped }) => {
|
|
893
|
-
var _effect = _useSignals3();
|
|
894
|
-
try {
|
|
895
|
-
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
896
|
-
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
897
|
-
const subGridClassNames = mx("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
898
|
-
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h1", {
|
|
899
|
-
className: "px-2 text-sm"
|
|
900
|
-
}, title), /* @__PURE__ */ React.createElement("div", {
|
|
901
|
-
className: gridClassNames
|
|
902
|
-
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React.createElement(Fragment, {
|
|
903
|
-
key: i
|
|
904
|
-
}, name && /* @__PURE__ */ React.createElement("div", {
|
|
905
|
-
className: subGridClassNames
|
|
906
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
907
|
-
className: "truncate text-primary-500"
|
|
908
|
-
}, name), /* @__PURE__ */ React.createElement("div", {
|
|
909
|
-
className: "line-clamp-2"
|
|
910
|
-
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React.createElement("div", {
|
|
911
|
-
key: i2,
|
|
912
|
-
className: mx(subGridClassNames, striped && stripeClassNames)
|
|
913
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
914
|
-
className: "truncate"
|
|
915
|
-
}, name2), /* @__PURE__ */ React.createElement("div", {
|
|
916
|
-
className: "line-clamp-3 text-subdued"
|
|
917
|
-
}, description2)))))));
|
|
918
|
-
} finally {
|
|
919
|
-
_effect.f();
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
923
|
-
var _effect = _useSignals3();
|
|
924
|
-
try {
|
|
925
|
-
const services = useQuery(space, Filter3.type(ServiceType));
|
|
926
|
-
const [serviceTools, setServiceTools] = useState6([]);
|
|
927
|
-
useEffect3(() => {
|
|
928
|
-
log4("creating service tools...", {
|
|
929
|
-
services: services.length
|
|
930
|
-
}, {
|
|
931
|
-
F: __dxlog_file4,
|
|
932
|
-
L: 117,
|
|
933
|
-
S: void 0,
|
|
934
|
-
C: (f, a) => f(...a)
|
|
935
|
-
});
|
|
936
|
-
queueMicrotask(async () => {
|
|
937
|
-
});
|
|
938
|
-
}, [
|
|
939
|
-
services
|
|
940
|
-
]);
|
|
941
|
-
const functions = useQuery(space, Filter3.type(FunctionType));
|
|
942
|
-
return /* @__PURE__ */ React.createElement(Toolbox, {
|
|
943
|
-
classNames,
|
|
944
|
-
blueprints: processor?.context.blueprints.value,
|
|
945
|
-
services: serviceTools,
|
|
946
|
-
functions
|
|
947
|
-
});
|
|
948
|
-
} finally {
|
|
949
|
-
_effect.f();
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
var safeToolId = (name) => {
|
|
953
|
-
return name.split("_").pop();
|
|
954
|
-
};
|
|
955
|
-
|
|
956
|
-
// src/components/Chat/Chat.tsx
|
|
957
|
-
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
958
|
-
import { Prec } from "@codemirror/state";
|
|
959
|
-
import { keymap } from "@codemirror/view";
|
|
960
|
-
import { useRxValue } from "@effect-rx/rx-react";
|
|
961
|
-
import { createContext } from "@radix-ui/react-context";
|
|
962
|
-
import { Array as Array2, Option as Option3 } from "effect";
|
|
963
|
-
import React11, { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo14, useRef as useRef3, useState as useState10 } from "react";
|
|
964
|
-
import { Event } from "@dxos/async";
|
|
965
|
-
import { Obj as Obj10 } from "@dxos/echo";
|
|
966
|
-
import { log as log5 } from "@dxos/log";
|
|
967
|
-
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
968
|
-
import { getSpace, useQueue as useQueue2 } from "@dxos/react-client/echo";
|
|
969
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
970
|
-
import { Input, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
971
|
-
import { ChatEditor, references } from "@dxos/react-ui-chat";
|
|
972
|
-
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
973
|
-
import { DataType as DataType3 } from "@dxos/schema";
|
|
974
|
-
import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
|
|
975
|
-
|
|
976
|
-
// src/components/ChatPrompt/ChatActions.tsx
|
|
977
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
978
|
-
import React2 from "react";
|
|
979
|
-
import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
980
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
981
|
-
var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
|
|
982
|
-
var _effect = _useSignals4();
|
|
983
|
-
try {
|
|
984
|
-
const { t } = useTranslation2(meta.id);
|
|
985
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
986
|
-
className: mx2("flex items-center mie-1", classNames)
|
|
987
|
-
}, children, /* @__PURE__ */ React2.createElement(IconButton, {
|
|
988
|
-
disabled: !processing,
|
|
989
|
-
variant: "ghost",
|
|
990
|
-
size: 5,
|
|
991
|
-
icon: "ph--x--regular",
|
|
992
|
-
iconOnly: true,
|
|
993
|
-
label: t("button cancel processing"),
|
|
994
|
-
onClick: () => onEvent?.({
|
|
995
|
-
type: "cancel"
|
|
996
|
-
})
|
|
997
|
-
}), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
998
|
-
disabled: !processing,
|
|
999
|
-
classNames: mx2(recording && "bg-primary-500"),
|
|
1000
|
-
variant: "ghost",
|
|
1001
|
-
size: 5,
|
|
1002
|
-
icon: "ph--microphone--regular",
|
|
1003
|
-
iconOnly: true,
|
|
1004
|
-
noTooltip: true,
|
|
1005
|
-
label: t("button microphone"),
|
|
1006
|
-
onMouseDown: () => onEvent?.({
|
|
1007
|
-
type: "record-start"
|
|
1008
|
-
}),
|
|
1009
|
-
onMouseUp: () => onEvent?.({
|
|
1010
|
-
type: "record-stop"
|
|
1011
|
-
}),
|
|
1012
|
-
onTouchStart: () => onEvent?.({
|
|
1013
|
-
type: "record-start"
|
|
1014
|
-
}),
|
|
1015
|
-
onTouchEnd: () => onEvent?.({
|
|
1016
|
-
type: "record-stop"
|
|
1017
|
-
})
|
|
1018
|
-
}));
|
|
1019
|
-
} finally {
|
|
1020
|
-
_effect.f();
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
// src/components/ChatPrompt/ChatOptions.tsx
|
|
1025
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
1026
|
-
import React3, { useMemo as useMemo10, useState as useState7 } from "react";
|
|
1027
|
-
import { Filter as Filter4, Obj as Obj6, Type as Type2 } from "@dxos/echo";
|
|
1028
|
-
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1029
|
-
import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
1030
|
-
import { SearchList } from "@dxos/react-ui-searchlist";
|
|
1031
|
-
import { Tabs } from "@dxos/react-ui-tabs";
|
|
1032
|
-
var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-[25rem] max-is-[--text-content]";
|
|
1033
|
-
var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
|
|
1034
|
-
var _effect = _useSignals5();
|
|
1035
|
-
try {
|
|
1036
|
-
const { t } = useTranslation3(meta.id);
|
|
1037
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
1038
|
-
role: "none",
|
|
1039
|
-
className: "flex gap-0.5"
|
|
1040
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
1041
|
-
asChild: true
|
|
1042
|
-
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
1043
|
-
variant: "ghost",
|
|
1044
|
-
icon: "ph--plus--regular",
|
|
1045
|
-
iconOnly: true,
|
|
1046
|
-
size: 5,
|
|
1047
|
-
label: t("button context objects")
|
|
1048
|
-
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
1049
|
-
side: "top",
|
|
1050
|
-
classNames: panelClassNames
|
|
1051
|
-
}, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
|
|
1052
|
-
space,
|
|
1053
|
-
context
|
|
1054
|
-
}), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
1055
|
-
asChild: true
|
|
1056
|
-
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
1057
|
-
variant: "ghost",
|
|
1058
|
-
icon: "ph--sliders-horizontal--regular",
|
|
1059
|
-
iconOnly: true,
|
|
1060
|
-
size: 5,
|
|
1061
|
-
label: t("button context settings")
|
|
1062
|
-
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
1063
|
-
side: "top",
|
|
1064
|
-
classNames: panelClassNames
|
|
1065
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.Root, {
|
|
1066
|
-
orientation: "horizontal",
|
|
1067
|
-
defaultValue: "blueprints",
|
|
1068
|
-
defaultActivePart: "list"
|
|
1069
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
|
|
1070
|
-
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'
|
|
1071
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
|
|
1072
|
-
value: "blueprints"
|
|
1073
|
-
}, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
|
|
1074
|
-
blueprintRegistry,
|
|
1075
|
-
space,
|
|
1076
|
-
context
|
|
1077
|
-
})), /* @__PURE__ */ React3.createElement(Tabs.Tabpanel, {
|
|
1078
|
-
value: "model"
|
|
1079
|
-
}, /* @__PURE__ */ React3.createElement(ModelsPanel, {
|
|
1080
|
-
presets,
|
|
1081
|
-
preset,
|
|
1082
|
-
onPresetChange
|
|
1083
|
-
})), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
|
|
1084
|
-
classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
|
|
1085
|
-
}, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
1086
|
-
value: "blueprints",
|
|
1087
|
-
icon: "ph--blueprint--regular",
|
|
1088
|
-
label: t("blueprints in context title")
|
|
1089
|
-
}), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
1090
|
-
value: "model",
|
|
1091
|
-
label: t("chat model title"),
|
|
1092
|
-
icon: "ph--cpu--regular"
|
|
1093
|
-
})))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
|
|
1094
|
-
} finally {
|
|
1095
|
-
_effect.f();
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
|
|
1099
|
-
var _effect = _useSignals5();
|
|
1100
|
-
try {
|
|
1101
|
-
const { t } = useTranslation3(meta.id);
|
|
1102
|
-
const blueprints = useBlueprints({
|
|
1103
|
-
blueprintRegistry
|
|
1104
|
-
});
|
|
1105
|
-
const activeBlueprints = useActiveBlueprints({
|
|
1106
|
-
context
|
|
1107
|
-
});
|
|
1108
|
-
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
1109
|
-
space,
|
|
1110
|
-
context,
|
|
1111
|
-
blueprintRegistry
|
|
1112
|
-
});
|
|
1113
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Root, null, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
1114
|
-
classNames: "plb-cardSpacingChrome"
|
|
1115
|
-
}, blueprints.map((blueprint) => {
|
|
1116
|
-
const isActive = activeBlueprints.has(blueprint.key);
|
|
1117
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
1118
|
-
classNames: "flex items-center overflow-hidden",
|
|
1119
|
-
key: blueprint.key,
|
|
1120
|
-
value: blueprint.name,
|
|
1121
|
-
onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
|
|
1122
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
1123
|
-
className: "grow truncate"
|
|
1124
|
-
}, blueprint.name), /* @__PURE__ */ React3.createElement(Icon, {
|
|
1125
|
-
icon: "ph--check--regular",
|
|
1126
|
-
classNames: [
|
|
1127
|
-
!isActive && "invisible"
|
|
1128
|
-
]
|
|
1129
|
-
}));
|
|
1130
|
-
})), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
1131
|
-
placeholder: t("search placeholder"),
|
|
1132
|
-
classNames: "mbe-cardSpacingChrome"
|
|
1133
|
-
}));
|
|
1134
|
-
} finally {
|
|
1135
|
-
_effect.f();
|
|
1136
|
-
}
|
|
1137
|
-
};
|
|
1138
|
-
var ModelsPanel = ({ presets, preset, onPresetChange }) => {
|
|
1139
|
-
var _effect = _useSignals5();
|
|
1140
|
-
try {
|
|
1141
|
-
return /* @__PURE__ */ React3.createElement("ul", {
|
|
1142
|
-
role: "listbox",
|
|
1143
|
-
className: "plb-cardSpacingChrome"
|
|
1144
|
-
}, presets?.map(({ id, label }) => {
|
|
1145
|
-
const isActive = preset === id;
|
|
1146
|
-
return /* @__PURE__ */ React3.createElement("li", {
|
|
1147
|
-
role: "option",
|
|
1148
|
-
key: id,
|
|
1149
|
-
"aria-selected": isActive,
|
|
1150
|
-
tabIndex: 0,
|
|
1151
|
-
className: "overflow-hidden dx-focus-ring flex gap-2 p-1 pis-2 pie-2 items-center rounded-sm select-none cursor-pointer hover:bg-hoverOverlay",
|
|
1152
|
-
onClick: () => onPresetChange?.(id)
|
|
1153
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
1154
|
-
className: "grow truncate"
|
|
1155
|
-
}, label), /* @__PURE__ */ React3.createElement(Icon, {
|
|
1156
|
-
icon: "ph--check--regular",
|
|
1157
|
-
classNames: [
|
|
1158
|
-
!isActive && "invisible"
|
|
1159
|
-
]
|
|
1160
|
-
}));
|
|
1161
|
-
}));
|
|
1162
|
-
} finally {
|
|
1163
|
-
_effect.f();
|
|
1164
|
-
}
|
|
1165
|
-
};
|
|
1166
|
-
var ANY = "__any__";
|
|
1167
|
-
var ObjectsPanel = ({ space, context }) => {
|
|
1168
|
-
var _effect = _useSignals5();
|
|
1169
|
-
try {
|
|
1170
|
-
const { t } = useTranslation3(meta.id);
|
|
1171
|
-
const types = useItemTypes(space);
|
|
1172
|
-
const typenames = useMemo10(() => {
|
|
1173
|
-
const typenames2 = types.map((type) => {
|
|
1174
|
-
const typename2 = Type2.getTypename(type);
|
|
1175
|
-
return {
|
|
1176
|
-
typename: typename2,
|
|
1177
|
-
label: t("typename label", {
|
|
1178
|
-
ns: typename2,
|
|
1179
|
-
defaultValue: typename2
|
|
1180
|
-
})
|
|
1181
|
-
};
|
|
1182
|
-
});
|
|
1183
|
-
typenames2.sort((a, b) => a.label.localeCompare(b.label));
|
|
1184
|
-
return typenames2;
|
|
1185
|
-
}, [
|
|
1186
|
-
types
|
|
1187
|
-
]);
|
|
1188
|
-
const [typename, setTypename] = useState7(ANY);
|
|
1189
|
-
const anyFilter = useMemo10(() => Filter4.or(...typenames.map(({ typename: typename2 }) => Filter4.typename(typename2))), [
|
|
1190
|
-
typenames
|
|
1191
|
-
]);
|
|
1192
|
-
const objects = useQuery2(space, typename === ANY ? anyFilter : Filter4.typename(typename));
|
|
1193
|
-
const { objects: contextObjects, onUpdateObject } = useContextObjects({
|
|
1194
|
-
space,
|
|
1195
|
-
context
|
|
1196
|
-
});
|
|
1197
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Root, {
|
|
1198
|
-
classNames: "pis-2 pie-2"
|
|
1199
|
-
}, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
1200
|
-
classNames: "plb-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
|
|
1201
|
-
}, objects.length ? objects.map((object) => {
|
|
1202
|
-
const label = Obj6.getLabel(object) ?? Obj6.getTypename(object) ?? object.id;
|
|
1203
|
-
const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
|
|
1204
|
-
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
1205
|
-
classNames: "flex items-center overflow-hidden",
|
|
1206
|
-
key: object.id,
|
|
1207
|
-
value: object.id,
|
|
1208
|
-
onSelect: () => onUpdateObject?.(Obj6.getDXN(object), !isActive)
|
|
1209
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
1210
|
-
className: "grow truncate"
|
|
1211
|
-
}, label), /* @__PURE__ */ React3.createElement(Icon, {
|
|
1212
|
-
icon: "ph--check--regular",
|
|
1213
|
-
classNames: [
|
|
1214
|
-
!isActive && "invisible"
|
|
1215
|
-
]
|
|
1216
|
-
}));
|
|
1217
|
-
}) : /* @__PURE__ */ React3.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React3.createElement("div", {
|
|
1218
|
-
role: "none",
|
|
1219
|
-
className: "grid grid-cols-[min-content_1fr] gap-2 mbe-cardSpacingChrome"
|
|
1220
|
-
}, /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
1221
|
-
value: typename === ANY ? void 0 : typename,
|
|
1222
|
-
onValueChange: setTypename
|
|
1223
|
-
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
1224
|
-
density: "fine",
|
|
1225
|
-
placeholder: t("type filter placeholder")
|
|
1226
|
-
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
1227
|
-
value: ANY
|
|
1228
|
-
}, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
1229
|
-
key: typename2,
|
|
1230
|
-
value: typename2
|
|
1231
|
-
}, label))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
1232
|
-
placeholder: t("search placeholder"),
|
|
1233
|
-
classNames: "mbe-0"
|
|
1234
|
-
})));
|
|
1235
|
-
} finally {
|
|
1236
|
-
_effect.f();
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
|
|
1240
|
-
// src/components/ChatPrompt/ChatPresets.tsx
|
|
1241
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
1242
|
-
import React4 from "react";
|
|
1243
|
-
import { Select as Select2 } from "@dxos/react-ui";
|
|
1244
|
-
|
|
1245
|
-
// src/components/ChatPrompt/ChatReferences.tsx
|
|
1246
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
1247
|
-
import React5 from "react";
|
|
1248
|
-
import { Obj as Obj7 } from "@dxos/echo";
|
|
1249
|
-
import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1250
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
1251
|
-
var ChatReferences = ({ classNames, context, space }) => {
|
|
1252
|
-
var _effect = _useSignals7();
|
|
1253
|
-
try {
|
|
1254
|
-
const { t } = useTranslation4(meta.id);
|
|
1255
|
-
const { objects, onUpdateObject } = useContextObjects({
|
|
1256
|
-
space,
|
|
1257
|
-
context
|
|
1258
|
-
});
|
|
1259
|
-
return /* @__PURE__ */ React5.createElement("ul", {
|
|
1260
|
-
className: mx3("flex flex-wrap", classNames)
|
|
1261
|
-
}, objects.map((obj) => {
|
|
1262
|
-
const dxn = Obj7.getDXN(obj);
|
|
1263
|
-
const typename = Obj7.getTypename(obj);
|
|
1264
|
-
const label = Obj7.getLabel(obj) ?? (typename ? [
|
|
1265
|
-
"object name placeholder",
|
|
1266
|
-
{
|
|
1267
|
-
ns: typename
|
|
1268
|
-
}
|
|
1269
|
-
] : obj.id);
|
|
1270
|
-
return /* @__PURE__ */ React5.createElement("li", {
|
|
1271
|
-
key: dxn.toString(),
|
|
1272
|
-
className: "dx-tag plb-0 pis-2 flex items-center",
|
|
1273
|
-
"data-hue": "neutral"
|
|
1274
|
-
}, toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
1275
|
-
iconOnly: true,
|
|
1276
|
-
variant: "ghost",
|
|
1277
|
-
label: t("remove object in context label"),
|
|
1278
|
-
classNames: "p-0 hover:bg-transparent",
|
|
1279
|
-
size: 3,
|
|
1280
|
-
icon: "ph--x--bold",
|
|
1281
|
-
onClick: () => onUpdateObject?.(dxn, false)
|
|
1282
|
-
}));
|
|
1283
|
-
}));
|
|
1284
|
-
} finally {
|
|
1285
|
-
_effect.f();
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
|
|
1289
|
-
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
1290
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1291
|
-
import React6, { useEffect as useEffect4, useState as useState8 } from "react";
|
|
1292
|
-
import { Tooltip, useTimeout } from "@dxos/react-ui";
|
|
1293
|
-
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1294
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1295
|
-
var period = 3e3;
|
|
1296
|
-
var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
|
|
1297
|
-
var _effect = _useSignals8();
|
|
1298
|
-
try {
|
|
1299
|
-
const [init, setInit] = useState8(false);
|
|
1300
|
-
useEffect4(() => setInit(false), [
|
|
1301
|
-
preset
|
|
1302
|
-
]);
|
|
1303
|
-
useTimeout(async () => {
|
|
1304
|
-
setInit(true);
|
|
1305
|
-
}, period / 2, [
|
|
1306
|
-
preset
|
|
1307
|
-
]);
|
|
1308
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
1309
|
-
role: "none",
|
|
1310
|
-
className: mx4("relative flex", classNames)
|
|
1311
|
-
}, /* @__PURE__ */ React6.createElement(Spinner, {
|
|
1312
|
-
duration: period,
|
|
1313
|
-
state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
|
|
1314
|
-
...props
|
|
1315
|
-
}), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
1316
|
-
asChild: true,
|
|
1317
|
-
content: error.message
|
|
1318
|
-
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1319
|
-
className: "absolute inset-0"
|
|
1320
|
-
})));
|
|
1321
|
-
} finally {
|
|
1322
|
-
_effect.f();
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1327
|
-
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1328
|
-
import React10, { Fragment as Fragment2, forwardRef, useEffect as useEffect6, useMemo as useMemo13 } from "react";
|
|
1329
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1330
|
-
import { PublicKey } from "@dxos/keys";
|
|
1331
|
-
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
1332
|
-
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1333
|
-
import { keyToFallback } from "@dxos/util";
|
|
1334
|
-
|
|
1335
|
-
// src/components/ChatThread/ChatMessage.tsx
|
|
1336
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1337
|
-
import React9, { useMemo as useMemo12 } from "react";
|
|
1338
|
-
import { ErrorBoundary, Surface } from "@dxos/app-framework";
|
|
1339
|
-
import { resolveRef } from "@dxos/client";
|
|
1340
|
-
import { Obj as Obj9 } from "@dxos/echo";
|
|
1341
|
-
import { invariant } from "@dxos/invariant";
|
|
1342
|
-
import { DXN, DXN_ECHO_REGEXP } from "@dxos/keys";
|
|
1343
|
-
import { useClient } from "@dxos/react-client";
|
|
1344
|
-
import { Button, IconButton as IconButton4, Link, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1345
|
-
import { MarkdownViewer, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
|
|
1346
|
-
import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
|
|
1347
|
-
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
1348
|
-
import { ContentBlock as ContentBlock2 } from "@dxos/schema";
|
|
1349
|
-
import { safeParseJson as safeParseJson2 } from "@dxos/util";
|
|
1350
|
-
|
|
1351
|
-
// src/components/ChatThread/Link.tsx
|
|
1352
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1353
|
-
import React7 from "react";
|
|
1354
|
-
import { Obj as Obj8, Ref as Ref3 } from "@dxos/echo";
|
|
1355
|
-
import { DxRefTag } from "@dxos/lit-ui/react";
|
|
1356
|
-
var ObjectLink = ({ space, dxn }) => {
|
|
1357
|
-
var _effect = _useSignals9();
|
|
1358
|
-
try {
|
|
1359
|
-
const object = useResolvedRef(space, Ref3.fromDXN(dxn));
|
|
1360
|
-
const title = Obj8.getLabel(object) ?? object?.id ?? dxn.toString();
|
|
1361
|
-
return /* @__PURE__ */ React7.createElement(DxRefTag, {
|
|
1362
|
-
refid: dxn.toString()
|
|
1363
|
-
}, title);
|
|
1364
|
-
} finally {
|
|
1365
|
-
_effect.f();
|
|
1366
|
-
}
|
|
1367
|
-
};
|
|
1368
|
-
|
|
1369
|
-
// src/components/ChatThread/ToolBlock.tsx
|
|
1370
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1371
|
-
import React8, { useEffect as useEffect5, useMemo as useMemo11, useRef as useRef2, useState as useState9 } from "react";
|
|
1372
|
-
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1373
|
-
import { NumericTabs, TextCrawl, ToggleContainer } from "@dxos/react-ui-components";
|
|
1374
|
-
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
1375
|
-
import { isNonNullable as isNonNullable3, isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
1376
|
-
import { safeParseJson } from "@dxos/util";
|
|
1377
|
-
var isToolMessage = (message) => {
|
|
1378
|
-
return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1379
|
-
};
|
|
1380
|
-
var ToolBlock = ({ message, toolProvider }) => {
|
|
1381
|
-
var _effect = _useSignals10();
|
|
1382
|
-
try {
|
|
1383
|
-
const { t } = useTranslation5(meta.id);
|
|
1384
|
-
const { blocks = [] } = message;
|
|
1385
|
-
const getToolCaption = (tool, status) => {
|
|
1386
|
-
if (!tool) {
|
|
1387
|
-
return t("calling tool label");
|
|
1388
|
-
}
|
|
1389
|
-
return status?.message ?? tool.description ?? [
|
|
1390
|
-
t("calling label"),
|
|
1391
|
-
tool.name
|
|
1392
|
-
].join(" ");
|
|
1393
|
-
};
|
|
1394
|
-
const items = useMemo11(() => {
|
|
1395
|
-
let lastToolCall;
|
|
1396
|
-
const tools = toolProvider();
|
|
1397
|
-
return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
|
|
1398
|
-
switch (block._tag) {
|
|
1399
|
-
case "toolCall": {
|
|
1400
|
-
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
1401
|
-
return null;
|
|
1402
|
-
}
|
|
1403
|
-
const tool = tools.find((tool2) => tool2.name === block.name);
|
|
1404
|
-
lastToolCall = {
|
|
1405
|
-
tool,
|
|
1406
|
-
block
|
|
1407
|
-
};
|
|
1408
|
-
return {
|
|
1409
|
-
title: getToolCaption(lastToolCall?.tool),
|
|
1410
|
-
content: {
|
|
1411
|
-
...block,
|
|
1412
|
-
input: safeParseJson(block.input)
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
case "toolResult": {
|
|
1417
|
-
if (block.error) {
|
|
1418
|
-
return {
|
|
1419
|
-
title: t("error label"),
|
|
1420
|
-
content: block
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
|
|
1424
|
-
lastToolCall = void 0;
|
|
1425
|
-
return {
|
|
1426
|
-
title,
|
|
1427
|
-
content: {
|
|
1428
|
-
...block,
|
|
1429
|
-
result: safeParseJson(block.result)
|
|
1430
|
-
}
|
|
1431
|
-
};
|
|
1432
|
-
}
|
|
1433
|
-
case "summary": {
|
|
1434
|
-
if (!lastToolCall) {
|
|
1435
|
-
return null;
|
|
1436
|
-
}
|
|
1437
|
-
return {
|
|
1438
|
-
title: t("summary label"),
|
|
1439
|
-
content: block
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
}).filter(isNonNullable3);
|
|
1444
|
-
}, [
|
|
1445
|
-
blocks
|
|
1446
|
-
]);
|
|
1447
|
-
return /* @__PURE__ */ React8.createElement(ToolContainer, {
|
|
1448
|
-
items
|
|
1449
|
-
});
|
|
1450
|
-
} finally {
|
|
1451
|
-
_effect.f();
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
var ToolContainer = ({ items }) => {
|
|
1455
|
-
var _effect = _useSignals10();
|
|
1456
|
-
try {
|
|
1457
|
-
const tabsRef = useRef2(null);
|
|
1458
|
-
const [selected, setSelected] = useState9(0);
|
|
1459
|
-
const [open, setOpen] = useState9(false);
|
|
1460
|
-
useEffect5(() => {
|
|
1461
|
-
if (open) {
|
|
1462
|
-
tabsRef.current?.focus();
|
|
1463
|
-
}
|
|
1464
|
-
}, [
|
|
1465
|
-
open
|
|
1466
|
-
]);
|
|
1467
|
-
const handleSelect = (index) => {
|
|
1468
|
-
setSelected(index);
|
|
1469
|
-
};
|
|
1470
|
-
const title = useMemo11(() => {
|
|
1471
|
-
const lines = items.map((item) => item.title).filter(isNotFalsy2);
|
|
1472
|
-
return /* @__PURE__ */ React8.createElement(TextCrawl, {
|
|
1473
|
-
key: "status-roll",
|
|
1474
|
-
lines,
|
|
1475
|
-
autoAdvance: true
|
|
1476
|
-
});
|
|
1477
|
-
}, [
|
|
1478
|
-
items
|
|
1479
|
-
]);
|
|
1480
|
-
const data = items[selected].content;
|
|
1481
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer.Root, {
|
|
1482
|
-
classNames: styles.panel,
|
|
1483
|
-
open,
|
|
1484
|
-
onChangeOpen: setOpen
|
|
1485
|
-
}, /* @__PURE__ */ React8.createElement(ToggleContainer.Header, {
|
|
1486
|
-
classNames: styles.panelHeader,
|
|
1487
|
-
title
|
|
1488
|
-
}), /* @__PURE__ */ React8.createElement(ToggleContainer.Content, {
|
|
1489
|
-
classNames: [
|
|
1490
|
-
"grid grid-cols-[32px_1fr]",
|
|
1491
|
-
styles.panelContent
|
|
1492
|
-
]
|
|
1493
|
-
}, /* @__PURE__ */ React8.createElement(NumericTabs, {
|
|
1494
|
-
ref: tabsRef,
|
|
1495
|
-
classNames: "p-1",
|
|
1496
|
-
length: items.length,
|
|
1497
|
-
selected,
|
|
1498
|
-
onSelect: handleSelect
|
|
1499
|
-
}), /* @__PURE__ */ React8.createElement(Json, {
|
|
1500
|
-
data,
|
|
1501
|
-
classNames: styles.json,
|
|
1502
|
-
replacer: {
|
|
1503
|
-
maxDepth: 3,
|
|
1504
|
-
maxArrayLen: 10,
|
|
1505
|
-
maxStringLen: 128
|
|
1506
|
-
}
|
|
1507
|
-
})));
|
|
1508
|
-
} finally {
|
|
1509
|
-
_effect.f();
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
|
|
1513
|
-
// src/components/ChatThread/ChatMessage.tsx
|
|
1514
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
|
|
1515
|
-
var styles = {
|
|
1516
|
-
margin: "pie-4 pis-4",
|
|
1517
|
-
padding: "pis-2 pie-2 pbs-0.5 pbe-0.5",
|
|
1518
|
-
panel: "is-full rounded-sm",
|
|
1519
|
-
panelHeader: "bg-groupSurface",
|
|
1520
|
-
panelContent: "bg-modalSurface",
|
|
1521
|
-
json: "!p-1 text-xs bg-transparent"
|
|
1522
|
-
};
|
|
1523
|
-
var ChatMessage = ({ classNames, debug, space, message, toolProvider, onEvent, onDelete }) => {
|
|
1524
|
-
var _effect = _useSignals11();
|
|
1525
|
-
try {
|
|
1526
|
-
const { t } = useTranslation6(meta.id);
|
|
1527
|
-
const { sender: { role }, blocks } = message;
|
|
1528
|
-
if (!debug && toolProvider && isToolMessage(message)) {
|
|
1529
|
-
return /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1530
|
-
classNames: [
|
|
1531
|
-
styles.margin,
|
|
1532
|
-
"animate-[fadeIn_0.5s]"
|
|
1533
|
-
]
|
|
1534
|
-
}, /* @__PURE__ */ React9.createElement(ToolBlock, {
|
|
1535
|
-
message,
|
|
1536
|
-
toolProvider
|
|
1537
|
-
}));
|
|
1538
|
-
}
|
|
1539
|
-
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, blocks.map((block, idx) => {
|
|
1540
|
-
if (block._tag === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
1541
|
-
return null;
|
|
1542
|
-
}
|
|
1543
|
-
const Component = components[block._tag] ?? components.default;
|
|
1544
|
-
if (!Component) {
|
|
1545
|
-
return null;
|
|
1546
|
-
}
|
|
1547
|
-
return /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1548
|
-
key: idx,
|
|
1549
|
-
classNames,
|
|
1550
|
-
user: block._tag === "text" && role === "user"
|
|
1551
|
-
}, /* @__PURE__ */ React9.createElement(ErrorBoundary, {
|
|
1552
|
-
data: block
|
|
1553
|
-
}, /* @__PURE__ */ React9.createElement(Component, {
|
|
1554
|
-
space,
|
|
1555
|
-
block,
|
|
1556
|
-
onEvent
|
|
1557
|
-
})));
|
|
1558
|
-
}), onDelete && /* @__PURE__ */ React9.createElement("div", {
|
|
1559
|
-
className: mx5("flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100", styles.margin)
|
|
1560
|
-
}, /* @__PURE__ */ React9.createElement(IconButton4, {
|
|
1561
|
-
classNames: "animate-[fadeIn_0.5s]",
|
|
1562
|
-
icon: "ph--trash--regular",
|
|
1563
|
-
iconOnly: true,
|
|
1564
|
-
label: t("button delete message"),
|
|
1565
|
-
onClick: () => onDelete()
|
|
1566
|
-
})));
|
|
1567
|
-
} finally {
|
|
1568
|
-
_effect.f();
|
|
1569
|
-
}
|
|
1570
|
-
};
|
|
1571
|
-
var components = {
|
|
1572
|
-
//
|
|
1573
|
-
// Text
|
|
1574
|
-
//
|
|
1575
|
-
["text"]: ({ space, block }) => {
|
|
1576
|
-
invariant(block._tag === "text", void 0, {
|
|
1577
|
-
F: __dxlog_file5,
|
|
1578
|
-
L: 122,
|
|
1579
|
-
S: void 0,
|
|
1580
|
-
A: [
|
|
1581
|
-
"block._tag === 'text'",
|
|
1582
|
-
""
|
|
1583
|
-
]
|
|
1584
|
-
});
|
|
1585
|
-
return /* @__PURE__ */ React9.createElement(MarkdownViewer, {
|
|
1586
|
-
content: preprocessTextContent(block.text),
|
|
1587
|
-
components: {
|
|
1588
|
-
a: ({ node: { properties }, children, href, ...props }) => {
|
|
1589
|
-
if (space && typeof properties?.href === "string" && properties?.href?.startsWith("dxn")) {
|
|
1590
|
-
try {
|
|
1591
|
-
const dxn = DXN.parse(properties.href);
|
|
1592
|
-
return /* @__PURE__ */ React9.createElement(ObjectLink, {
|
|
1593
|
-
space,
|
|
1594
|
-
dxn
|
|
1595
|
-
});
|
|
1596
|
-
} catch {
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
return /* @__PURE__ */ React9.createElement(Link, {
|
|
1600
|
-
href,
|
|
1601
|
-
target: "_blank",
|
|
1602
|
-
rel: "noopener noreferrer",
|
|
1603
|
-
...props
|
|
1604
|
-
}, children);
|
|
1605
|
-
},
|
|
1606
|
-
img: ({ node: { properties } }) => {
|
|
1607
|
-
const client = useClient();
|
|
1608
|
-
if (space && typeof properties?.src === "string" && properties?.src?.startsWith("dxn")) {
|
|
1609
|
-
try {
|
|
1610
|
-
const dxn = DXN.parse(properties?.src);
|
|
1611
|
-
const subject = resolveRef(client, dxn, space);
|
|
1612
|
-
const data = useMemo12(() => ({
|
|
1613
|
-
subject
|
|
1614
|
-
}), [
|
|
1615
|
-
subject
|
|
1616
|
-
]);
|
|
1617
|
-
return /* @__PURE__ */ React9.createElement(Surface, {
|
|
1618
|
-
role: "card--transclusion",
|
|
1619
|
-
data,
|
|
1620
|
-
limit: 1
|
|
1621
|
-
});
|
|
1622
|
-
} catch {
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
return /* @__PURE__ */ React9.createElement("img", properties);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
},
|
|
1630
|
-
//
|
|
1631
|
-
// Suggest
|
|
1632
|
-
//
|
|
1633
|
-
["suggestion"]: ({ block, onEvent }) => {
|
|
1634
|
-
invariant(block._tag === "suggestion", void 0, {
|
|
1635
|
-
F: __dxlog_file5,
|
|
1636
|
-
L: 165,
|
|
1637
|
-
S: void 0,
|
|
1638
|
-
A: [
|
|
1639
|
-
"block._tag === 'suggestion'",
|
|
1640
|
-
""
|
|
1641
|
-
]
|
|
1642
|
-
});
|
|
1643
|
-
return /* @__PURE__ */ React9.createElement(IconButton4, {
|
|
1644
|
-
icon: "ph--lightning--regular",
|
|
1645
|
-
label: block.text,
|
|
1646
|
-
classNames: "text-description",
|
|
1647
|
-
onClick: () => onEvent?.({
|
|
1648
|
-
type: "submit",
|
|
1649
|
-
text: block.text
|
|
1650
|
-
})
|
|
1651
|
-
});
|
|
1652
|
-
},
|
|
1653
|
-
//
|
|
1654
|
-
// Select
|
|
1655
|
-
//
|
|
1656
|
-
["select"]: ({ block, onEvent }) => {
|
|
1657
|
-
invariant(block._tag === "select", void 0, {
|
|
1658
|
-
F: __dxlog_file5,
|
|
1659
|
-
L: 181,
|
|
1660
|
-
S: void 0,
|
|
1661
|
-
A: [
|
|
1662
|
-
"block._tag === 'select'",
|
|
1663
|
-
""
|
|
1664
|
-
]
|
|
1665
|
-
});
|
|
1666
|
-
return /* @__PURE__ */ React9.createElement("div", {
|
|
1667
|
-
className: "flex flex-wrap gap-1"
|
|
1668
|
-
}, block.options.map((option, idx) => /* @__PURE__ */ React9.createElement(Button, {
|
|
1669
|
-
classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
|
|
1670
|
-
key: idx,
|
|
1671
|
-
onClick: () => onEvent?.({
|
|
1672
|
-
type: "submit",
|
|
1673
|
-
text: option
|
|
1674
|
-
})
|
|
1675
|
-
}, option)));
|
|
1676
|
-
},
|
|
1677
|
-
//
|
|
1678
|
-
// Toolkit
|
|
1679
|
-
//
|
|
1680
|
-
["toolkit"]: ({ block }) => {
|
|
1681
|
-
invariant(block._tag === "toolkit", void 0, {
|
|
1682
|
-
F: __dxlog_file5,
|
|
1683
|
-
L: 202,
|
|
1684
|
-
S: void 0,
|
|
1685
|
-
A: [
|
|
1686
|
-
"block._tag === 'toolkit'",
|
|
1687
|
-
""
|
|
1688
|
-
]
|
|
1689
|
-
});
|
|
1690
|
-
const { t } = useTranslation6(meta.id);
|
|
1691
|
-
return /* @__PURE__ */ React9.createElement(ToggleContainer2.Root, {
|
|
1692
|
-
classNames: styles.panel,
|
|
1693
|
-
defaultOpen: true
|
|
1694
|
-
}, /* @__PURE__ */ React9.createElement(ToggleContainer2.Header, {
|
|
1695
|
-
classNames: styles.panelHeader,
|
|
1696
|
-
title: t("toolkit label")
|
|
1697
|
-
}), /* @__PURE__ */ React9.createElement(ToggleContainer2.Content, {
|
|
1698
|
-
classNames: styles.panelContent
|
|
1699
|
-
}, /* @__PURE__ */ React9.createElement(Toolbox, null)));
|
|
1700
|
-
},
|
|
1701
|
-
//
|
|
1702
|
-
// Summary
|
|
1703
|
-
//
|
|
1704
|
-
["summary"]: ({ block }) => {
|
|
1705
|
-
invariant(block._tag === "summary", void 0, {
|
|
1706
|
-
F: __dxlog_file5,
|
|
1707
|
-
L: 219,
|
|
1708
|
-
S: void 0,
|
|
1709
|
-
A: [
|
|
1710
|
-
"block._tag === 'summary'",
|
|
1711
|
-
""
|
|
1712
|
-
]
|
|
1713
|
-
});
|
|
1714
|
-
const summary = ContentBlock2.createSummaryMessage(block, false);
|
|
1715
|
-
return /* @__PURE__ */ React9.createElement("div", {
|
|
1716
|
-
className: "text-sm text-subdued"
|
|
1717
|
-
}, summary);
|
|
1718
|
-
},
|
|
1719
|
-
//
|
|
1720
|
-
// JSON
|
|
1721
|
-
//
|
|
1722
|
-
["json"]: ({ block, onEvent }) => {
|
|
1723
|
-
invariant(block._tag === "json", void 0, {
|
|
1724
|
-
F: __dxlog_file5,
|
|
1725
|
-
L: 229,
|
|
1726
|
-
S: void 0,
|
|
1727
|
-
A: [
|
|
1728
|
-
"block._tag === 'json'",
|
|
1729
|
-
""
|
|
1730
|
-
]
|
|
1731
|
-
});
|
|
1732
|
-
switch (block.disposition) {
|
|
1733
|
-
case "graph": {
|
|
1734
|
-
return /* @__PURE__ */ React9.createElement("div", {
|
|
1735
|
-
className: "flex flex-wrap gap-1"
|
|
1736
|
-
}, /* @__PURE__ */ React9.createElement(Surface, {
|
|
1737
|
-
role: "card",
|
|
1738
|
-
data: {
|
|
1739
|
-
subject: JSON.parse(block.data ?? "{}")
|
|
1740
|
-
},
|
|
1741
|
-
limit: 1,
|
|
1742
|
-
fallback: /* @__PURE__ */ React9.createElement("div", {
|
|
1743
|
-
className: "font-mono text-xs text-pre"
|
|
1744
|
-
}, block.data)
|
|
1745
|
-
}), onEvent && /* @__PURE__ */ React9.createElement(IconButton4, {
|
|
1746
|
-
icon: "ph--plus--regular",
|
|
1747
|
-
label: "Add to graph",
|
|
1748
|
-
onClick: () => onEvent?.({
|
|
1749
|
-
type: "add",
|
|
1750
|
-
object: JSON.parse(block.data ?? "{}")
|
|
1751
|
-
})
|
|
1752
|
-
}));
|
|
1753
|
-
}
|
|
1754
|
-
default: {
|
|
1755
|
-
return /* @__PURE__ */ React9.createElement(ToggleContainer2.Root, {
|
|
1756
|
-
classNames: styles.panel
|
|
1757
|
-
}, /* @__PURE__ */ React9.createElement(ToggleContainer2.Header, {
|
|
1758
|
-
classNames: styles.panelHeader,
|
|
1759
|
-
title: block.disposition ?? block._tag
|
|
1760
|
-
}), /* @__PURE__ */ React9.createElement(ToggleContainer2.Content, {
|
|
1761
|
-
classNames: styles.panelContent
|
|
1762
|
-
}, /* @__PURE__ */ React9.createElement(Json2, {
|
|
1763
|
-
data: safeParseJson2(block.data ?? block),
|
|
1764
|
-
classNames: styles.json
|
|
1765
|
-
})));
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
},
|
|
1769
|
-
//
|
|
1770
|
-
// Fallback
|
|
1771
|
-
//
|
|
1772
|
-
default: ({ block }) => {
|
|
1773
|
-
return /* @__PURE__ */ React9.createElement(ToggleContainer2.Root, {
|
|
1774
|
-
classNames: styles.panel
|
|
1775
|
-
}, /* @__PURE__ */ React9.createElement(ToggleContainer2.Header, {
|
|
1776
|
-
classNames: styles.panelHeader,
|
|
1777
|
-
title: block._tag
|
|
1778
|
-
}), /* @__PURE__ */ React9.createElement(ToggleContainer2.Content, {
|
|
1779
|
-
classNames: styles.panelContent
|
|
1780
|
-
}, /* @__PURE__ */ React9.createElement(Json2, {
|
|
1781
|
-
data: block,
|
|
1782
|
-
classNames: styles.json
|
|
1783
|
-
})));
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
var ChatError = ({ error, onEvent }) => {
|
|
1787
|
-
var _effect = _useSignals11();
|
|
1788
|
-
try {
|
|
1789
|
-
const { t } = useTranslation6(meta.id);
|
|
1790
|
-
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(MessageItem, null, /* @__PURE__ */ React9.createElement(ToggleContainer2.Root, {
|
|
1791
|
-
classNames: styles.panel
|
|
1792
|
-
}, /* @__PURE__ */ React9.createElement(ToggleContainer2.Header, {
|
|
1793
|
-
classNames: styles.panelHeader,
|
|
1794
|
-
title: error.message || t("error label")
|
|
1795
|
-
}), /* @__PURE__ */ React9.createElement(ToggleContainer2.Content, {
|
|
1796
|
-
classNames: styles.panelContent
|
|
1797
|
-
}, String(error.cause)))), /* @__PURE__ */ React9.createElement(MessageItem, null, /* @__PURE__ */ React9.createElement(IconButton4, {
|
|
1798
|
-
classNames: "bg-errorSurface text-errorSurfaceText",
|
|
1799
|
-
icon: "ph--lightning--regular",
|
|
1800
|
-
label: t("button retry"),
|
|
1801
|
-
onClick: () => onEvent?.({
|
|
1802
|
-
type: "retry"
|
|
1803
|
-
})
|
|
1804
|
-
})));
|
|
1805
|
-
} finally {
|
|
1806
|
-
_effect.f();
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
|
-
var MessageItem = ({ classNames, children, user }) => {
|
|
1810
|
-
var _effect = _useSignals11();
|
|
1811
|
-
try {
|
|
1812
|
-
if (!children) {
|
|
1813
|
-
return null;
|
|
1814
|
-
}
|
|
1815
|
-
return /* @__PURE__ */ React9.createElement("div", {
|
|
1816
|
-
role: "list-item",
|
|
1817
|
-
className: mx5("flex is-full", user && "justify-end", styles.margin, classNames)
|
|
1818
|
-
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1819
|
-
className: mx5(user ? [
|
|
1820
|
-
"bg-[--user-fill] text-white dark:text-black rounded-sm",
|
|
1821
|
-
styles.padding
|
|
1822
|
-
] : "is-full")
|
|
1823
|
-
}, children));
|
|
1824
|
-
} finally {
|
|
1825
|
-
_effect.f();
|
|
1826
|
-
}
|
|
1827
|
-
};
|
|
1828
|
-
var preprocessTextContent = (content) => content.replaceAll(new RegExp(DXN_ECHO_REGEXP, "g"), (_, dxn) => `<${dxn}>`);
|
|
1829
|
-
|
|
1830
|
-
// src/components/ChatThread/reducers.ts
|
|
1831
|
-
var reduceMessages = ({ messages, current, toolBlock, assistantMessages = [] }, message) => {
|
|
1832
|
-
let assistant = message?.sender.role === "assistant";
|
|
1833
|
-
let i = 0;
|
|
1834
|
-
for (const block of message.blocks) {
|
|
1835
|
-
switch (block._tag) {
|
|
1836
|
-
// TODO(burdon): Preserve call tool title.
|
|
1837
|
-
case "toolCall": {
|
|
1838
|
-
assistant = true;
|
|
1839
|
-
if (!toolBlock) {
|
|
1840
|
-
current = {
|
|
1841
|
-
...message,
|
|
1842
|
-
id: [
|
|
1843
|
-
message.id,
|
|
1844
|
-
i++
|
|
1845
|
-
].join("_"),
|
|
1846
|
-
blocks: [
|
|
1847
|
-
block
|
|
1848
|
-
]
|
|
1849
|
-
};
|
|
1850
|
-
messages.push(current);
|
|
1851
|
-
toolBlock = true;
|
|
1852
|
-
} else {
|
|
1853
|
-
current.blocks.push(block);
|
|
1854
|
-
}
|
|
1855
|
-
break;
|
|
1856
|
-
}
|
|
1857
|
-
case "toolResult": {
|
|
1858
|
-
assistant = true;
|
|
1859
|
-
if (toolBlock) {
|
|
1860
|
-
current.blocks.push(block);
|
|
1861
|
-
}
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1864
|
-
case "summary": {
|
|
1865
|
-
assistant = true;
|
|
1866
|
-
if (toolBlock) {
|
|
1867
|
-
current.blocks.push(block);
|
|
1868
|
-
} else {
|
|
1869
|
-
const summary = reduceSummary([
|
|
1870
|
-
...assistantMessages,
|
|
1871
|
-
message
|
|
1872
|
-
]);
|
|
1873
|
-
current.blocks.push(summary);
|
|
1874
|
-
}
|
|
1875
|
-
break;
|
|
1876
|
-
}
|
|
1877
|
-
default: {
|
|
1878
|
-
assistant = message.sender.role === "assistant";
|
|
1879
|
-
current = {
|
|
1880
|
-
...message,
|
|
1881
|
-
id: [
|
|
1882
|
-
message.id,
|
|
1883
|
-
i++
|
|
1884
|
-
].join("_"),
|
|
1885
|
-
blocks: [
|
|
1886
|
-
block
|
|
1887
|
-
]
|
|
1888
|
-
};
|
|
1889
|
-
messages.push(current);
|
|
1890
|
-
toolBlock = false;
|
|
1891
|
-
break;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
return {
|
|
1896
|
-
messages,
|
|
1897
|
-
current,
|
|
1898
|
-
toolBlock,
|
|
1899
|
-
assistantMessages: assistant ? [
|
|
1900
|
-
...assistantMessages,
|
|
1901
|
-
message
|
|
1902
|
-
] : void 0
|
|
1903
|
-
};
|
|
1904
|
-
};
|
|
1905
|
-
var reduceSummary = (messages) => {
|
|
1906
|
-
let start;
|
|
1907
|
-
return messages.reduce((acc, msg) => {
|
|
1908
|
-
const time = new Date(msg.created).getTime();
|
|
1909
|
-
if (!start) {
|
|
1910
|
-
start = time;
|
|
1911
|
-
}
|
|
1912
|
-
msg.blocks.forEach((block) => {
|
|
1913
|
-
switch (block._tag) {
|
|
1914
|
-
case "toolCall": {
|
|
1915
|
-
acc.toolCalls = (acc.toolCalls ?? 0) + 1;
|
|
1916
|
-
break;
|
|
1917
|
-
}
|
|
1918
|
-
case "summary": {
|
|
1919
|
-
acc.model = block.model;
|
|
1920
|
-
if (block.usage) {
|
|
1921
|
-
acc.message = block.message;
|
|
1922
|
-
acc.usage = {
|
|
1923
|
-
inputTokens: (acc.usage?.inputTokens ?? 0) + (block.usage.inputTokens ?? 0),
|
|
1924
|
-
outputTokens: (acc.usage?.outputTokens ?? 0) + (block.usage.outputTokens ?? 0),
|
|
1925
|
-
totalTokens: (acc.usage?.totalTokens ?? 0) + (block.usage.totalTokens ?? 0)
|
|
1926
|
-
};
|
|
1927
|
-
acc.duration = time - (start ?? time);
|
|
1928
|
-
}
|
|
1929
|
-
break;
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
|
-
return acc;
|
|
1934
|
-
}, {
|
|
1935
|
-
_tag: "summary",
|
|
1936
|
-
duration: 0
|
|
1937
|
-
});
|
|
1938
|
-
};
|
|
1939
|
-
|
|
1940
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1941
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatThread.tsx";
|
|
1942
|
-
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, debug, onEvent, ...props }, forwardedRef) => {
|
|
1943
|
-
var _effect = _useSignals12();
|
|
1944
|
-
try {
|
|
1945
|
-
const userHue = useMemo13(() => {
|
|
1946
|
-
return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
|
|
1947
|
-
}, [
|
|
1948
|
-
identity
|
|
1949
|
-
]);
|
|
1950
|
-
useEffect6(() => {
|
|
1951
|
-
onEvent?.({
|
|
1952
|
-
type: "scroll-to-bottom"
|
|
1953
|
-
});
|
|
1954
|
-
}, [
|
|
1955
|
-
error
|
|
1956
|
-
]);
|
|
1957
|
-
const reducedMessages = useMemo13(() => {
|
|
1958
|
-
if (!debug) {
|
|
1959
|
-
return messages.reduce(reduceMessages, {
|
|
1960
|
-
messages: []
|
|
1961
|
-
}).messages;
|
|
1962
|
-
} else {
|
|
1963
|
-
return messages;
|
|
1964
|
-
}
|
|
1965
|
-
}, [
|
|
1966
|
-
messages,
|
|
1967
|
-
debug
|
|
1968
|
-
]);
|
|
1969
|
-
const getDelta = (idx) => {
|
|
1970
|
-
invariant2(idx > 0, void 0, {
|
|
1971
|
-
F: __dxlog_file6,
|
|
1972
|
-
L: 48,
|
|
1973
|
-
S: void 0,
|
|
1974
|
-
A: [
|
|
1975
|
-
"idx > 0",
|
|
1976
|
-
""
|
|
1977
|
-
]
|
|
1978
|
-
});
|
|
1979
|
-
const prev = new Date(reducedMessages[idx - 1].created).getTime();
|
|
1980
|
-
const current = new Date(reducedMessages[idx].created).getTime();
|
|
1981
|
-
return current - prev;
|
|
1982
|
-
};
|
|
1983
|
-
return /* @__PURE__ */ React10.createElement(ScrollContainer.Root, {
|
|
1984
|
-
pin: true,
|
|
1985
|
-
fade: true,
|
|
1986
|
-
ref: forwardedRef,
|
|
1987
|
-
classNames
|
|
1988
|
-
}, /* @__PURE__ */ React10.createElement(ScrollContainer.Content, {
|
|
1989
|
-
classNames: "relative flex flex-col gap-2 pbs-2 pbe-2",
|
|
1990
|
-
style: {
|
|
1991
|
-
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1992
|
-
}
|
|
1993
|
-
}, reducedMessages.map((message, idx) => /* @__PURE__ */ React10.createElement(Fragment2, {
|
|
1994
|
-
key: message.id
|
|
1995
|
-
}, debug && /* @__PURE__ */ React10.createElement("div", {
|
|
1996
|
-
className: mx6("flex justify-end text-subdued", styles.margin)
|
|
1997
|
-
}, /* @__PURE__ */ React10.createElement("pre", {
|
|
1998
|
-
className: "text-xs"
|
|
1999
|
-
}, JSON.stringify({
|
|
2000
|
-
created: message.created,
|
|
2001
|
-
delta: idx > 0 ? getDelta(idx) : void 0
|
|
2002
|
-
}))), /* @__PURE__ */ React10.createElement(ChatMessage, {
|
|
2003
|
-
message,
|
|
2004
|
-
debug,
|
|
2005
|
-
onEvent,
|
|
2006
|
-
...props
|
|
2007
|
-
}))), error && /* @__PURE__ */ React10.createElement(ChatError, {
|
|
2008
|
-
error,
|
|
2009
|
-
onEvent
|
|
2010
|
-
})), /* @__PURE__ */ React10.createElement(ScrollContainer.ScrollDownButton, null));
|
|
2011
|
-
} finally {
|
|
2012
|
-
_effect.f();
|
|
2013
|
-
}
|
|
2014
|
-
});
|
|
2015
|
-
|
|
2016
|
-
// src/components/Chat/Chat.tsx
|
|
2017
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
|
|
2018
|
-
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
2019
|
-
var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
|
|
2020
|
-
var _effect = _useSignals13();
|
|
2021
|
-
try {
|
|
2022
|
-
const [debug, setDebug] = useState10(false);
|
|
2023
|
-
const space = getSpace(chat);
|
|
2024
|
-
const queue = useQueue2(chat?.queue.dxn);
|
|
2025
|
-
const pending = useRxValue(processor.messages);
|
|
2026
|
-
const streaming = useRxValue(processor.streaming);
|
|
2027
|
-
const lastPrompt = useRef3(void 0);
|
|
2028
|
-
const messages = useMemo14(() => {
|
|
2029
|
-
const queueMessages = queue?.objects?.filter(Obj10.instanceOf(DataType3.Message)) ?? [];
|
|
2030
|
-
return Array2.dedupeWith([
|
|
2031
|
-
...queueMessages,
|
|
2032
|
-
...pending
|
|
2033
|
-
], (a, b) => a.id === b.id);
|
|
2034
|
-
}, [
|
|
2035
|
-
queue?.objects,
|
|
2036
|
-
pending
|
|
2037
|
-
]);
|
|
2038
|
-
const event = useMemo14(() => new Event(), []);
|
|
2039
|
-
useEffect7(() => {
|
|
2040
|
-
return event.on((ev) => {
|
|
2041
|
-
switch (ev.type) {
|
|
2042
|
-
case "toggle-debug": {
|
|
2043
|
-
setDebug((current) => {
|
|
2044
|
-
const debug2 = !current;
|
|
2045
|
-
log5.info("toggle-debug", {
|
|
2046
|
-
debug: debug2
|
|
2047
|
-
}, {
|
|
2048
|
-
F: __dxlog_file7,
|
|
2049
|
-
L: 95,
|
|
2050
|
-
S: void 0,
|
|
2051
|
-
C: (f, a) => f(...a)
|
|
2052
|
-
});
|
|
2053
|
-
return debug2;
|
|
2054
|
-
});
|
|
2055
|
-
break;
|
|
2056
|
-
}
|
|
2057
|
-
case "submit": {
|
|
2058
|
-
if (!streaming) {
|
|
2059
|
-
lastPrompt.current = ev.text;
|
|
2060
|
-
void processor.request({
|
|
2061
|
-
message: ev.text
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
|
-
break;
|
|
2065
|
-
}
|
|
2066
|
-
case "retry": {
|
|
2067
|
-
if (!streaming) {
|
|
2068
|
-
void processor.retry();
|
|
2069
|
-
}
|
|
2070
|
-
break;
|
|
2071
|
-
}
|
|
2072
|
-
case "cancel": {
|
|
2073
|
-
if (streaming) {
|
|
2074
|
-
void processor.cancel();
|
|
2075
|
-
if (lastPrompt.current) {
|
|
2076
|
-
event.emit({
|
|
2077
|
-
type: "update-prompt",
|
|
2078
|
-
text: lastPrompt.current
|
|
2079
|
-
});
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
break;
|
|
2083
|
-
}
|
|
2084
|
-
default: {
|
|
2085
|
-
onEvent?.(ev);
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
});
|
|
2089
|
-
}, [
|
|
2090
|
-
event,
|
|
2091
|
-
processor,
|
|
2092
|
-
streaming,
|
|
2093
|
-
onEvent
|
|
2094
|
-
]);
|
|
2095
|
-
if (!space) {
|
|
2096
|
-
return null;
|
|
2097
|
-
}
|
|
2098
|
-
return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
|
|
2099
|
-
debug,
|
|
2100
|
-
event,
|
|
2101
|
-
chat,
|
|
2102
|
-
space,
|
|
2103
|
-
processor,
|
|
2104
|
-
messages,
|
|
2105
|
-
...props
|
|
2106
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
2107
|
-
role: "none",
|
|
2108
|
-
className: mx7("flex flex-col h-full overflow-hidden", classNames)
|
|
2109
|
-
}, children));
|
|
2110
|
-
} finally {
|
|
2111
|
-
_effect.f();
|
|
2112
|
-
}
|
|
2113
|
-
};
|
|
2114
|
-
ChatRoot.displayName = "Chat.Root";
|
|
2115
|
-
var ChatPrompt = ({ classNames, outline, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
|
|
2116
|
-
var _effect = _useSignals13();
|
|
2117
|
-
try {
|
|
2118
|
-
const { t } = useTranslation7(meta.id);
|
|
2119
|
-
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
2120
|
-
const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
|
|
2121
|
-
const streaming = useRxValue(processor.streaming);
|
|
2122
|
-
const streamingRef = useRef3(streaming);
|
|
2123
|
-
const editorRef = useRef3(null);
|
|
2124
|
-
const [active, setActive] = useState10(false);
|
|
2125
|
-
useEffect7(() => {
|
|
2126
|
-
return event.on((event2) => {
|
|
2127
|
-
switch (event2.type) {
|
|
2128
|
-
case "update-prompt":
|
|
2129
|
-
if (!editorRef.current?.getText()?.length) {
|
|
2130
|
-
editorRef.current?.setText(event2.text);
|
|
2131
|
-
editorRef.current?.focus();
|
|
2132
|
-
}
|
|
2133
|
-
break;
|
|
2134
|
-
case "record-start":
|
|
2135
|
-
setActive(true);
|
|
2136
|
-
break;
|
|
2137
|
-
case "record-stop":
|
|
2138
|
-
setActive(false);
|
|
2139
|
-
break;
|
|
2140
|
-
}
|
|
2141
|
-
});
|
|
2142
|
-
}, [
|
|
2143
|
-
event
|
|
2144
|
-
]);
|
|
2145
|
-
const { recording } = useVoiceInput({
|
|
2146
|
-
active,
|
|
2147
|
-
onUpdate: (text) => {
|
|
2148
|
-
editorRef.current?.setText(text);
|
|
2149
|
-
editorRef.current?.focus();
|
|
2150
|
-
}
|
|
2151
|
-
});
|
|
2152
|
-
const referencesProvider = useReferencesProvider(space);
|
|
2153
|
-
const extensions = useMemo14(() => {
|
|
2154
|
-
return [
|
|
2155
|
-
referencesProvider && references({
|
|
2156
|
-
provider: referencesProvider
|
|
2157
|
-
}),
|
|
2158
|
-
Prec.highest(keymap.of([
|
|
2159
|
-
{
|
|
2160
|
-
key: "cmd-d",
|
|
2161
|
-
preventDefault: true,
|
|
2162
|
-
run: () => {
|
|
2163
|
-
event.emit({
|
|
2164
|
-
type: "toggle-debug"
|
|
2165
|
-
});
|
|
2166
|
-
return true;
|
|
2167
|
-
}
|
|
2168
|
-
},
|
|
2169
|
-
expandable && {
|
|
2170
|
-
key: "cmd-ArrowUp",
|
|
2171
|
-
preventDefault: true,
|
|
2172
|
-
run: () => {
|
|
2173
|
-
event.emit({
|
|
2174
|
-
type: "thread-open"
|
|
2175
|
-
});
|
|
2176
|
-
return true;
|
|
2177
|
-
}
|
|
2178
|
-
},
|
|
2179
|
-
expandable && {
|
|
2180
|
-
key: "cmd-ArrowDown",
|
|
2181
|
-
preventDefault: true,
|
|
2182
|
-
run: () => {
|
|
2183
|
-
event.emit({
|
|
2184
|
-
type: "thread-close"
|
|
2185
|
-
});
|
|
2186
|
-
return true;
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
].filter(isNotFalsy3)))
|
|
2190
|
-
].filter(isNotFalsy3);
|
|
2191
|
-
}, [
|
|
2192
|
-
event,
|
|
2193
|
-
expandable,
|
|
2194
|
-
referencesProvider
|
|
2195
|
-
]);
|
|
2196
|
-
const handleSubmit = useCallback5((text) => {
|
|
2197
|
-
if (!streamingRef.current) {
|
|
2198
|
-
event.emit({
|
|
2199
|
-
type: "submit",
|
|
2200
|
-
text
|
|
2201
|
-
});
|
|
2202
|
-
return true;
|
|
2203
|
-
}
|
|
2204
|
-
}, [
|
|
2205
|
-
event
|
|
2206
|
-
]);
|
|
2207
|
-
const handleEvent = useCallback5((ev) => {
|
|
2208
|
-
event.emit(ev);
|
|
2209
|
-
}, [
|
|
2210
|
-
event
|
|
2211
|
-
]);
|
|
2212
|
-
return /* @__PURE__ */ React11.createElement("div", {
|
|
2213
|
-
className: mx7("is-full flex flex-col density-fine", outline && [
|
|
2214
|
-
"p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
|
|
2215
|
-
], classNames)
|
|
2216
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
2217
|
-
className: "flex gap-2"
|
|
2218
|
-
}, /* @__PURE__ */ React11.createElement(ChatStatusIndicator, {
|
|
2219
|
-
classNames: "p-1",
|
|
2220
|
-
preset,
|
|
2221
|
-
error,
|
|
2222
|
-
processing: streaming
|
|
2223
|
-
}), /* @__PURE__ */ React11.createElement(ChatEditor, {
|
|
2224
|
-
ref: editorRef,
|
|
2225
|
-
autoFocus: true,
|
|
2226
|
-
lineWrapping: true,
|
|
2227
|
-
classNames: "col-span-2 pbs-0.5",
|
|
2228
|
-
placeholder: placeholder ?? t("prompt placeholder"),
|
|
2229
|
-
extensions,
|
|
2230
|
-
onSubmit: handleSubmit
|
|
2231
|
-
})), /* @__PURE__ */ React11.createElement("div", {
|
|
2232
|
-
className: "flex pbs-2 items-center"
|
|
2233
|
-
}, /* @__PURE__ */ React11.createElement(ChatOptions, {
|
|
2234
|
-
space,
|
|
2235
|
-
blueprintRegistry: processor.blueprintRegistry,
|
|
2236
|
-
context: processor.context,
|
|
2237
|
-
preset,
|
|
2238
|
-
presets,
|
|
2239
|
-
onPresetChange
|
|
2240
|
-
}), /* @__PURE__ */ React11.createElement("div", {
|
|
2241
|
-
role: "none",
|
|
2242
|
-
className: "pli-cardSpacingChrome grow"
|
|
2243
|
-
}, /* @__PURE__ */ React11.createElement(ChatReferences, {
|
|
2244
|
-
space,
|
|
2245
|
-
context: processor.context
|
|
2246
|
-
})), /* @__PURE__ */ React11.createElement(ChatActions, {
|
|
2247
|
-
classNames: "col-span-2",
|
|
2248
|
-
microphone: true,
|
|
2249
|
-
recording,
|
|
2250
|
-
processing: streaming,
|
|
2251
|
-
onEvent: handleEvent
|
|
2252
|
-
}, online !== void 0 && /* @__PURE__ */ React11.createElement(Input.Root, null, /* @__PURE__ */ React11.createElement(Input.Switch, {
|
|
2253
|
-
classNames: "mis-2 mie-2",
|
|
2254
|
-
checked: online,
|
|
2255
|
-
onCheckedChange: onOnlineChange
|
|
2256
|
-
})))));
|
|
2257
|
-
} finally {
|
|
2258
|
-
_effect.f();
|
|
2259
|
-
}
|
|
2260
|
-
};
|
|
2261
|
-
ChatPrompt.displayName = "Chat.Prompt";
|
|
2262
|
-
var ChatThread2 = (props) => {
|
|
2263
|
-
var _effect = _useSignals13();
|
|
2264
|
-
try {
|
|
2265
|
-
const { debug, event, space, messages, processor } = useChatContext(ChatThread2.displayName);
|
|
2266
|
-
const identity = useIdentity();
|
|
2267
|
-
const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
|
|
2268
|
-
const toolProvider = useCallback5(() => processor.conversation.toolkit?.tools ?? [], [
|
|
2269
|
-
processor
|
|
2270
|
-
]);
|
|
2271
|
-
const scrollerRef = useRef3(null);
|
|
2272
|
-
useEffect7(() => {
|
|
2273
|
-
return event.on((event2) => {
|
|
2274
|
-
switch (event2.type) {
|
|
2275
|
-
case "submit":
|
|
2276
|
-
case "scroll-to-bottom":
|
|
2277
|
-
scrollerRef.current?.scrollToBottom("smooth");
|
|
2278
|
-
break;
|
|
2279
|
-
}
|
|
2280
|
-
});
|
|
2281
|
-
}, [
|
|
2282
|
-
event
|
|
2283
|
-
]);
|
|
2284
|
-
if (!identity) {
|
|
2285
|
-
return null;
|
|
2286
|
-
}
|
|
2287
|
-
return /* @__PURE__ */ React11.createElement(ChatThread, {
|
|
2288
|
-
...props,
|
|
2289
|
-
ref: scrollerRef,
|
|
2290
|
-
debug,
|
|
2291
|
-
identity,
|
|
2292
|
-
space,
|
|
2293
|
-
messages,
|
|
2294
|
-
error,
|
|
2295
|
-
toolProvider,
|
|
2296
|
-
onEvent: (ev) => event.emit(ev)
|
|
2297
|
-
});
|
|
2298
|
-
} finally {
|
|
2299
|
-
_effect.f();
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
2302
|
-
ChatThread2.displayName = "Chat.Thread";
|
|
2303
|
-
var Chat = {
|
|
2304
|
-
Root: ChatRoot,
|
|
2305
|
-
Prompt: ChatPrompt,
|
|
2306
|
-
Thread: ChatThread2
|
|
2307
|
-
};
|
|
2308
|
-
|
|
2309
|
-
export {
|
|
2310
|
-
useBlueprintRegistry,
|
|
2311
|
-
useChatProcessor,
|
|
2312
|
-
useChatServices,
|
|
2313
|
-
useContextBinder,
|
|
2314
|
-
useExecutionGraph,
|
|
2315
|
-
useOnline,
|
|
2316
|
-
usePresets,
|
|
2317
|
-
Toolbox,
|
|
2318
|
-
ToolboxContainer,
|
|
2319
|
-
ChatContextProvider,
|
|
2320
|
-
useChatContext,
|
|
2321
|
-
Chat,
|
|
2322
|
-
AiService2 as AiService,
|
|
2323
|
-
AppGraphBuilder,
|
|
2324
|
-
AssistantState,
|
|
2325
|
-
BlueprintDefinition,
|
|
2326
|
-
EdgeModelResolver,
|
|
2327
|
-
IntentResolver,
|
|
2328
|
-
LocalModelResolver,
|
|
2329
|
-
ReactSurface,
|
|
2330
|
-
Settings,
|
|
2331
|
-
Toolkit
|
|
2332
|
-
};
|
|
2333
|
-
//# sourceMappingURL=chunk-2X6VEO32.mjs.map
|