@dxos/plugin-assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850
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/AssistantDialog-K6POM23O.mjs +46 -0
- package/dist/lib/browser/AssistantDialog-K6POM23O.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-QTO4LE2C.mjs +39 -0
- package/dist/lib/{node-esm/ChatContainer-FAYGNMQW.mjs.map → browser/ChatContainer-QTO4LE2C.mjs.map} +1 -1
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs +28 -0
- package/dist/lib/{node-esm/TemplateContainer-3LEBT5ZC.mjs.map → browser/TemplateContainer-AKUYL4AV.mjs.map} +1 -1
- package/dist/lib/browser/{ai-client-5PRCXI7N.mjs → ai-client-COXVUC6V.mjs} +4 -4
- package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HTK3HFGM.mjs → app-graph-builder-YH4EGNBC.mjs} +45 -28
- package/dist/lib/browser/app-graph-builder-YH4EGNBC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-TXJWGWJ7.mjs → chunk-3F44MBHU.mjs} +3 -3
- package/dist/lib/browser/chunk-3F44MBHU.mjs.map +7 -0
- package/dist/lib/browser/chunk-IHEBFO5O.mjs +205 -0
- package/dist/lib/browser/chunk-IHEBFO5O.mjs.map +7 -0
- package/dist/lib/browser/chunk-JQFUME3B.mjs +87 -0
- package/dist/lib/{node-esm/chunk-PBZA7XJR.mjs.map → browser/chunk-JQFUME3B.mjs.map} +1 -1
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +96 -0
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OWZHLWW5.mjs → chunk-QTW7KVDO.mjs} +1595 -1452
- package/dist/lib/browser/chunk-QTW7KVDO.mjs.map +7 -0
- package/dist/lib/browser/chunk-USJBRB3H.mjs +155 -0
- package/dist/lib/browser/chunk-USJBRB3H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3HCI5FIL.mjs → chunk-XOZ7YMO3.mjs} +3 -3
- package/dist/lib/browser/{chunk-3HCI5FIL.mjs.map → chunk-XOZ7YMO3.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +24 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-QV5AAVJZ.mjs → intent-resolver-63EAHENI.mjs} +6 -5
- package/dist/lib/browser/intent-resolver-63EAHENI.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-XCV6NR75.mjs +131 -0
- package/dist/lib/browser/react-surface-XCV6NR75.mjs.map +7 -0
- package/dist/lib/browser/{settings-OZX7J65A.mjs → settings-SHNQ4XXP.mjs} +3 -3
- package/dist/lib/browser/types/index.mjs +4 -2
- package/dist/lib/node/AssistantDialog-FDATKYE5.cjs +72 -0
- package/dist/lib/node/AssistantDialog-FDATKYE5.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-WVAAOEOH.cjs → ChatContainer-5CLHJOIQ.cjs} +25 -19
- package/dist/lib/node/{ChatContainer-WVAAOEOH.cjs.map → ChatContainer-5CLHJOIQ.cjs.map} +1 -1
- package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs → TemplateContainer-CTG2MB4W.cjs} +18 -12
- package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs.map → TemplateContainer-CTG2MB4W.cjs.map} +1 -1
- package/dist/lib/node/{ai-client-OUPSRQT7.cjs → ai-client-R2CGEYZW.cjs} +12 -12
- package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-LEO63CZZ.cjs → app-graph-builder-PSHIOW3Q.cjs} +62 -46
- package/dist/lib/node/app-graph-builder-PSHIOW3Q.cjs.map +7 -0
- package/dist/lib/node/{chunk-XI2ARIEO.cjs → chunk-4EEWTDQK.cjs} +45 -39
- package/dist/lib/node/{chunk-XI2ARIEO.cjs.map → chunk-4EEWTDQK.cjs.map} +1 -1
- package/dist/lib/node/chunk-FLJWJ35M.cjs +181 -0
- package/dist/lib/node/chunk-FLJWJ35M.cjs.map +7 -0
- package/dist/lib/node/{chunk-OOHFSPWR.cjs → chunk-H4A42LNR.cjs} +1126 -983
- package/dist/lib/node/chunk-H4A42LNR.cjs.map +7 -0
- package/dist/lib/node/chunk-HRNIUYVQ.cjs +128 -0
- package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +7 -0
- package/dist/lib/node/{chunk-Q5XWEMHB.cjs → chunk-P74TWGMG.cjs} +6 -6
- package/dist/lib/node/{chunk-Q5XWEMHB.cjs.map → chunk-P74TWGMG.cjs.map} +1 -1
- package/dist/lib/node/chunk-RXPA2C2A.cjs +230 -0
- package/dist/lib/node/chunk-RXPA2C2A.cjs.map +7 -0
- package/dist/lib/node/{chunk-GBUNQ257.cjs → chunk-TS3H5OSX.cjs} +7 -7
- package/dist/lib/node/chunk-TS3H5OSX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +72 -59
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-QDGZMWLY.cjs → intent-resolver-66F7WLW6.cjs} +13 -12
- package/dist/lib/node/intent-resolver-66F7WLW6.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-TASAPRPQ.cjs +145 -0
- package/dist/lib/node/react-surface-TASAPRPQ.cjs.map +7 -0
- package/dist/lib/node/{settings-WLTC7XO5.cjs → settings-ERKLO6IO.cjs} +8 -8
- package/dist/lib/node/types/index.cjs +16 -14
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs +47 -0
- package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-QTC5NYE2.mjs +40 -0
- package/dist/lib/{browser/ChatContainer-ZNKENYKZ.mjs.map → node-esm/ChatContainer-QTC5NYE2.mjs.map} +1 -1
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs +29 -0
- package/dist/lib/{browser/TemplateContainer-WKU5XFSO.mjs.map → node-esm/TemplateContainer-IVDQ4XQG.mjs.map} +1 -1
- package/dist/lib/node-esm/{ai-client-RZQWEDUX.mjs → ai-client-I5LXHMOZ.mjs} +4 -4
- package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-WXJNZDYB.mjs → app-graph-builder-Z3GMMJMD.mjs} +45 -28
- package/dist/lib/node-esm/app-graph-builder-Z3GMMJMD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ECRK6TUQ.mjs → chunk-BB2TAT4P.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-ECRK6TUQ.mjs.map → chunk-BB2TAT4P.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs +98 -0
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6JK5HEUQ.mjs → chunk-HLPGKJ7N.mjs} +3 -3
- package/dist/lib/node-esm/chunk-HLPGKJ7N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PBZA7XJR.mjs → chunk-OYN6HLXZ.mjs} +42 -36
- package/dist/lib/{browser/chunk-NFUHCW2J.mjs.map → node-esm/chunk-OYN6HLXZ.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-QU626JMR.mjs +156 -0
- package/dist/lib/node-esm/chunk-QU626JMR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ED55ZE4G.mjs → chunk-SI5LOQEO.mjs} +1595 -1452
- package/dist/lib/node-esm/chunk-SI5LOQEO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZKBACPIW.mjs +206 -0
- package/dist/lib/node-esm/chunk-ZKBACPIW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +24 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-Q3I6S6HN.mjs → intent-resolver-X3PWH7KM.mjs} +6 -5
- package/dist/lib/node-esm/intent-resolver-X3PWH7KM.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-QMIQCXUM.mjs +132 -0
- package/dist/lib/node-esm/react-surface-QMIQCXUM.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-CLE57WEP.mjs → settings-IVQRZUCU.mjs} +3 -3
- package/dist/lib/node-esm/types/index.mjs +4 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +3 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +8 -0
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +1 -0
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +8 -0
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/BlueprintEditor/index.d.ts +2 -0
- package/dist/types/src/components/BlueprintEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +5 -2
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +6 -3
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +9 -4
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +9 -0
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts +5 -1
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.d.ts +2 -2
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +2 -2
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +4 -2
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +1 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -1
- package/dist/types/src/components/Thread/reducer.d.ts +1 -1
- package/dist/types/src/components/Thread/reducer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/experimental/transcription/index.d.ts +1 -0
- package/dist/types/src/experimental/transcription/index.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.d.ts +6 -5
- package/dist/types/src/hooks/processor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +11 -7
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/parser/filter-generator.d.ts +4 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.test.d.ts +2 -0
- package/dist/types/src/parser/filter-generator.test.d.ts.map +1 -0
- package/dist/types/src/parser/index.d.ts +4 -0
- package/dist/types/src/parser/index.d.ts.map +1 -0
- package/dist/types/src/parser/query-parser.d.ts +15 -0
- package/dist/types/src/parser/query-parser.d.ts.map +1 -0
- package/dist/types/src/parser/query-parser.test.d.ts +2 -0
- package/dist/types/src/parser/query-parser.test.d.ts.map +1 -0
- package/dist/types/src/parser/types.d.ts +24 -0
- package/dist/types/src/parser/types.d.ts.map +1 -0
- package/dist/types/src/stories/Prompt.stories.d.ts +8 -0
- package/dist/types/src/stories/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Query.stories.d.ts +19 -0
- package/dist/types/src/stories/Query.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Research.stories.d.ts +15 -0
- package/dist/types/src/stories/Research.stories.d.ts.map +1 -0
- package/dist/types/src/stories/test-data.d.ts +3 -0
- package/dist/types/src/stories/test-data.d.ts.map +1 -0
- package/dist/types/src/stories/testing.d.ts +12 -0
- package/dist/types/src/stories/testing.d.ts.map +1 -0
- package/dist/types/src/testing/blueprint.d.ts +7 -0
- package/dist/types/src/testing/blueprint.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/tools/function.d.ts +4 -4
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts +3 -3
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +63 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/chat.d.ts +18 -8
- package/dist/types/src/types/chat.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +73 -61
- package/src/AssistantPlugin.tsx +5 -4
- package/src/capabilities/ai-client.ts +1 -1
- package/src/capabilities/app-graph-builder.ts +34 -24
- package/src/capabilities/capabilities.ts +1 -1
- package/src/capabilities/intent-resolver.ts +3 -2
- package/src/capabilities/react-surface.tsx +58 -13
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -1
- package/src/components/AmbientDialog/AmbientDialog.tsx +27 -13
- package/src/components/AssistantDialog.tsx +1 -1
- package/src/components/AssistantSettings/AssistantSettings.tsx +1 -1
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +32 -0
- package/src/components/BlueprintEditor/BlueprintEditor.tsx +41 -0
- package/src/components/BlueprintEditor/index.ts +5 -0
- package/src/components/Prompt/Prompt.stories.tsx +59 -52
- package/src/components/Prompt/Prompt.tsx +24 -10
- package/src/components/Prompt/PromptBar.stories.tsx +68 -0
- package/src/components/Prompt/PromptBar.tsx +82 -80
- package/src/components/Prompt/autocomplete.ts +14 -8
- package/src/components/Prompt/references.ts +3 -3
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +1 -1
- package/src/components/Thread/Thread.stories.tsx +2 -2
- package/src/components/Thread/Thread.tsx +2 -2
- package/src/components/Thread/ThreadContainer.stories.tsx +77 -47
- package/src/components/Thread/ThreadContainer.tsx +8 -9
- package/src/components/Thread/ThreadMessage.tsx +43 -8
- package/src/components/Thread/ToolInvocations.tsx +9 -7
- package/src/components/Thread/reducer.ts +1 -1
- package/src/components/Toolbox/Toolbox.stories.tsx +1 -1
- package/src/components/Toolbox/Toolbox.tsx +2 -1
- package/src/components/index.ts +2 -0
- package/src/experimental/transcription/index.ts +3 -0
- package/src/hooks/processor.ts +65 -27
- package/src/hooks/useChatProcessor.tsx +4 -4
- package/src/hooks/useContextProvider.ts +6 -6
- package/src/hooks/useMessageQueue.ts +4 -4
- package/src/meta.ts +2 -2
- package/src/parser/filter-generator.test.ts +32 -0
- package/src/parser/filter-generator.ts +81 -0
- package/src/parser/index.ts +7 -0
- package/src/parser/query-parser.test.ts +139 -0
- package/src/parser/query-parser.ts +199 -0
- package/src/parser/types.ts +34 -0
- package/src/shims.d.ts +8 -0
- package/src/stories/Prompt.stories.tsx +59 -0
- package/src/stories/Query.stories.tsx +448 -0
- package/src/stories/Research.stories.tsx +495 -0
- package/src/stories/test-data.ts +128 -0
- package/src/stories/testing.ts +64 -0
- package/src/testing/blueprint.ts +47 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/test-functions.ts +1 -1
- package/src/tools/function.ts +8 -7
- package/src/tools/openapi.test.ts +18 -19
- package/src/tools/openapi.ts +20 -14
- package/src/translations.ts +4 -2
- package/src/types/chat.ts +27 -4
- package/src/types/types.ts +3 -1
- package/dist/lib/browser/AssistantDialog-DTWVEQBB.mjs +0 -117
- package/dist/lib/browser/AssistantDialog-DTWVEQBB.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-ZNKENYKZ.mjs +0 -33
- package/dist/lib/browser/TemplateContainer-WKU5XFSO.mjs +0 -22
- package/dist/lib/browser/ai-client-5PRCXI7N.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HTK3HFGM.mjs.map +0 -7
- package/dist/lib/browser/chunk-5P7U35RJ.mjs +0 -192
- package/dist/lib/browser/chunk-5P7U35RJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-7VDZP5WX.mjs +0 -143
- package/dist/lib/browser/chunk-7VDZP5WX.mjs.map +0 -7
- package/dist/lib/browser/chunk-NFUHCW2J.mjs +0 -81
- package/dist/lib/browser/chunk-OWZHLWW5.mjs.map +0 -7
- package/dist/lib/browser/chunk-TXJWGWJ7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-QV5AAVJZ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JJPYWEIN.mjs +0 -90
- package/dist/lib/browser/react-surface-JJPYWEIN.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-RJJHZI63.cjs +0 -141
- package/dist/lib/node/AssistantDialog-RJJHZI63.cjs.map +0 -7
- package/dist/lib/node/ai-client-OUPSRQT7.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-LEO63CZZ.cjs.map +0 -7
- package/dist/lib/node/chunk-GBUNQ257.cjs.map +0 -7
- package/dist/lib/node/chunk-GQ3XS5FZ.cjs +0 -169
- package/dist/lib/node/chunk-GQ3XS5FZ.cjs.map +0 -7
- package/dist/lib/node/chunk-OOHFSPWR.cjs.map +0 -7
- package/dist/lib/node/chunk-VG2UQY4S.cjs +0 -216
- package/dist/lib/node/chunk-VG2UQY4S.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-QDGZMWLY.cjs.map +0 -7
- package/dist/lib/node/react-surface-XNEIJJYJ.cjs +0 -106
- package/dist/lib/node/react-surface-XNEIJJYJ.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-D33WZUGR.mjs +0 -118
- package/dist/lib/node-esm/AssistantDialog-D33WZUGR.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-FAYGNMQW.mjs +0 -34
- package/dist/lib/node-esm/TemplateContainer-3LEBT5ZC.mjs +0 -23
- package/dist/lib/node-esm/ai-client-RZQWEDUX.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-WXJNZDYB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JK5HEUQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-74GFINWJ.mjs +0 -144
- package/dist/lib/node-esm/chunk-74GFINWJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ED55ZE4G.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UZWYXNR5.mjs +0 -193
- package/dist/lib/node-esm/chunk-UZWYXNR5.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-Q3I6S6HN.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RI3JONQY.mjs +0 -91
- package/dist/lib/node-esm/react-surface-RI3JONQY.mjs.map +0 -7
- /package/dist/lib/browser/{settings-OZX7J65A.mjs.map → settings-SHNQ4XXP.mjs.map} +0 -0
- /package/dist/lib/node/{settings-WLTC7XO5.cjs.map → settings-ERKLO6IO.cjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-CLE57WEP.mjs.map → settings-IVQRZUCU.mjs.map} +0 -0
|
@@ -7,6 +7,7 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
|
|
10
|
+
import { AIServiceEdgeClient, Message } from '@dxos/ai';
|
|
10
11
|
import {
|
|
11
12
|
Capabilities,
|
|
12
13
|
Events,
|
|
@@ -17,22 +18,22 @@ import {
|
|
|
17
18
|
useIntentDispatcher,
|
|
18
19
|
} from '@dxos/app-framework';
|
|
19
20
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { DXN, Type } from '@dxos/echo';
|
|
24
|
-
import { createQueueDxn, create } from '@dxos/echo-schema';
|
|
21
|
+
import { remoteServiceEndpoints } from '@dxos/artifact-testing';
|
|
22
|
+
import { Type, type Obj } from '@dxos/echo';
|
|
23
|
+
import { createQueueDxn, create, Query, Filter } from '@dxos/echo-schema';
|
|
25
24
|
import { invariant } from '@dxos/invariant';
|
|
26
25
|
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
27
26
|
import { ChessType } from '@dxos/plugin-chess/types';
|
|
28
27
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
29
28
|
import { InboxPlugin } from '@dxos/plugin-inbox';
|
|
30
29
|
import { MapPlugin } from '@dxos/plugin-map';
|
|
30
|
+
import { MarkdownPlugin } from '@dxos/plugin-markdown';
|
|
31
31
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
32
32
|
import { TablePlugin } from '@dxos/plugin-table';
|
|
33
|
-
import {
|
|
33
|
+
import { useClient } from '@dxos/react-client';
|
|
34
|
+
import { useQueue, useQuery } from '@dxos/react-client/echo';
|
|
34
35
|
import { IconButton, Input, Toolbar } from '@dxos/react-ui';
|
|
35
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
36
|
+
import { descriptionMessage, mx } from '@dxos/react-ui-theme';
|
|
36
37
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
37
38
|
|
|
38
39
|
import { Thread, type ThreadProps } from './Thread';
|
|
@@ -40,18 +41,22 @@ import { ChatProcessor } from '../../hooks';
|
|
|
40
41
|
import { createProcessorOptions } from '../../testing';
|
|
41
42
|
import translations from '../../translations';
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
// TODO(burdon): Configure for local with ollama/LM studio.
|
|
45
|
+
// const endpoints = localServiceEndpoints;
|
|
46
|
+
const endpoints = remoteServiceEndpoints;
|
|
44
47
|
|
|
45
48
|
type RenderProps = {
|
|
46
|
-
items?:
|
|
49
|
+
items?: Obj.Any[];
|
|
47
50
|
prompts?: string[];
|
|
48
51
|
} & Pick<ThreadProps, 'debug'>;
|
|
49
52
|
|
|
50
53
|
// TODO(burdon): Use ChatContainer.
|
|
51
54
|
const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) => {
|
|
52
|
-
const
|
|
55
|
+
const client = useClient();
|
|
56
|
+
const space = client.spaces.default;
|
|
57
|
+
|
|
53
58
|
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
54
|
-
const tools =
|
|
59
|
+
const tools = useCapabilities(Capabilities.Tools);
|
|
55
60
|
|
|
56
61
|
const [aiClient] = useState(() => new AIServiceEdgeClient({ endpoint: endpoints.ai }));
|
|
57
62
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
@@ -65,7 +70,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
65
70
|
|
|
66
71
|
return new ChatProcessor(
|
|
67
72
|
aiClient,
|
|
68
|
-
tools,
|
|
73
|
+
tools.flat(),
|
|
69
74
|
artifactDefinitions,
|
|
70
75
|
{
|
|
71
76
|
space,
|
|
@@ -76,11 +81,17 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
76
81
|
}, [aiClient, tools, space, dispatch, artifactDefinitions]);
|
|
77
82
|
|
|
78
83
|
// Queue.
|
|
79
|
-
const [queueDxn, setQueueDxn] = useState<string>(() => createQueueDxn().toString());
|
|
80
|
-
const queue = useQueue<Message>(DXN.tryParse(queueDxn));
|
|
84
|
+
const [queueDxn, setQueueDxn] = useState<string>(() => createQueueDxn(space.id).toString());
|
|
85
|
+
const queue = useQueue<Message>(Type.DXN.tryParse(queueDxn));
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (space) {
|
|
89
|
+
setQueueDxn(createQueueDxn(space.id).toString());
|
|
90
|
+
}
|
|
91
|
+
}, [space]);
|
|
81
92
|
|
|
82
93
|
useEffect(() => {
|
|
83
|
-
if (queue?.
|
|
94
|
+
if (queue?.objects.length === 0 && !queue.isLoading && prompts.length > 0) {
|
|
84
95
|
queue.append([
|
|
85
96
|
create(Message, {
|
|
86
97
|
role: 'assistant',
|
|
@@ -95,38 +106,38 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
95
106
|
}),
|
|
96
107
|
]);
|
|
97
108
|
}
|
|
98
|
-
}, [queueDxn, prompts, queue?.
|
|
109
|
+
}, [queueDxn, prompts, queue?.objects.length, queue?.isLoading]);
|
|
99
110
|
|
|
100
111
|
// State.
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
});
|
|
112
|
+
const query = useMemo(
|
|
113
|
+
() => Query.select(Filter.or(...artifactDefinitions.map((definition) => Filter.type(definition.schema)))),
|
|
114
|
+
[artifactDefinitions],
|
|
115
|
+
);
|
|
116
|
+
const artifactItems = useQuery(space, query);
|
|
117
|
+
const messages = [...(queue?.objects ?? []), ...(processor?.messages.value ?? [])];
|
|
118
|
+
|
|
119
|
+
const handleSubmit = useCallback(
|
|
120
|
+
(message: string) => {
|
|
121
|
+
requestAnimationFrame(async () => {
|
|
122
|
+
if (!processor || !queue) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (processor.streaming.value) {
|
|
127
|
+
await processor.cancel();
|
|
128
|
+
}
|
|
120
129
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
await processor.request(message, {
|
|
131
|
+
history: queue.objects,
|
|
132
|
+
onComplete: (messages) => {
|
|
133
|
+
queue.append(messages);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
});
|
|
124
137
|
|
|
125
|
-
|
|
126
|
-
(text: string) => {
|
|
127
|
-
void handleSubmit?.(text);
|
|
138
|
+
return true;
|
|
128
139
|
},
|
|
129
|
-
[
|
|
140
|
+
[processor, queue],
|
|
130
141
|
);
|
|
131
142
|
|
|
132
143
|
const handleDelete = useCallback(
|
|
@@ -137,6 +148,10 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
137
148
|
[queue],
|
|
138
149
|
);
|
|
139
150
|
|
|
151
|
+
if (!space) {
|
|
152
|
+
return <></>;
|
|
153
|
+
}
|
|
154
|
+
|
|
140
155
|
return (
|
|
141
156
|
<div className='grid grid-cols-2 w-full h-full divide-x divide-separator overflow-hidden'>
|
|
142
157
|
{/* Thread */}
|
|
@@ -159,7 +174,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
159
174
|
iconOnly
|
|
160
175
|
label='Clear history'
|
|
161
176
|
icon='ph--trash--regular'
|
|
162
|
-
onClick={() => setQueueDxn(createQueueDxn().toString())}
|
|
177
|
+
onClick={() => setQueueDxn(createQueueDxn(space.id).toString())}
|
|
163
178
|
/>
|
|
164
179
|
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
165
180
|
</Input.Root>
|
|
@@ -172,7 +187,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
172
187
|
error={processor?.error.value}
|
|
173
188
|
tools={processor?.tools}
|
|
174
189
|
onSubmit={processor ? handleSubmit : undefined}
|
|
175
|
-
onPrompt={processor ?
|
|
190
|
+
onPrompt={processor ? handleSubmit : undefined}
|
|
176
191
|
onDelete={processor ? handleDelete : undefined}
|
|
177
192
|
{...props}
|
|
178
193
|
/>
|
|
@@ -182,7 +197,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
182
197
|
<div className='overflow-hidden grid grid-rows-[2fr_1fr] divide-y divide-separator'>
|
|
183
198
|
{artifactItems.length > 0 && (
|
|
184
199
|
<div className={mx('flex grow overflow-hidden', artifactItems.length === 1 && 'row-span-2')}>
|
|
185
|
-
<Surface role='
|
|
200
|
+
<Surface role='article' limit={1} data={{ subject: artifactItems[0] }} fallback={Fallback} />
|
|
186
201
|
</div>
|
|
187
202
|
)}
|
|
188
203
|
|
|
@@ -190,7 +205,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
190
205
|
<div className='flex shrink-0 overflow-hidden divide-x divide-separator'>
|
|
191
206
|
<div className='flex flex-1 h-full'>
|
|
192
207
|
{artifactItems.slice(1, 3).map((item, idx) => (
|
|
193
|
-
<Surface key={idx} role='
|
|
208
|
+
<Surface key={idx} role='article' limit={1} data={{ subject: item }} fallback={Fallback} />
|
|
194
209
|
))}
|
|
195
210
|
</div>
|
|
196
211
|
</div>
|
|
@@ -201,7 +216,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
201
216
|
};
|
|
202
217
|
|
|
203
218
|
const meta: Meta<typeof DefaultStory> = {
|
|
204
|
-
title: 'plugins/plugin-
|
|
219
|
+
title: 'plugins/plugin-assistant/ThreadContainer',
|
|
205
220
|
render: DefaultStory,
|
|
206
221
|
decorators: [
|
|
207
222
|
withPluginManager({
|
|
@@ -219,6 +234,7 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
219
234
|
ChessPlugin(),
|
|
220
235
|
InboxPlugin(),
|
|
221
236
|
MapPlugin(),
|
|
237
|
+
MarkdownPlugin(),
|
|
222
238
|
TablePlugin(),
|
|
223
239
|
],
|
|
224
240
|
fireEvents: [Events.SetupArtifactDefinition],
|
|
@@ -252,3 +268,17 @@ export const WithInitialItems: Story = {
|
|
|
252
268
|
],
|
|
253
269
|
},
|
|
254
270
|
};
|
|
271
|
+
|
|
272
|
+
const Fallback = ({ error }: { error?: Error }) => {
|
|
273
|
+
const errorString = error?.toString() ?? '';
|
|
274
|
+
return (
|
|
275
|
+
<div role='none' className='overflow-auto p-8 attention-surface grid place-items-center'>
|
|
276
|
+
<p
|
|
277
|
+
role='alert'
|
|
278
|
+
className={mx(descriptionMessage, 'break-words rounded-lg p-8', errorString.length < 256 && 'text-lg')}
|
|
279
|
+
>
|
|
280
|
+
{error ? errorString : 'error'}
|
|
281
|
+
</p>
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
};
|
|
@@ -8,7 +8,7 @@ import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/a
|
|
|
8
8
|
import { type AssociatedArtifact } from '@dxos/artifact';
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { DXN } from '@dxos/keys';
|
|
11
|
-
import {
|
|
11
|
+
import { refFromDXN } from '@dxos/live-object';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
import { getSpace } from '@dxos/react-client/echo';
|
|
14
14
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -22,7 +22,7 @@ export type ThreadContainerProps = {
|
|
|
22
22
|
settings?: AssistantSettingsProps;
|
|
23
23
|
part?: 'deck' | 'dialog';
|
|
24
24
|
associatedArtifact?: AssociatedArtifact;
|
|
25
|
-
} & Pick<ThreadProps, 'debug' | 'transcription' | 'onOpenChange'>;
|
|
25
|
+
} & Pick<ThreadProps, 'debug' | 'transcription' | 'onOpenChange' | 'onAddToGraph'>;
|
|
26
26
|
|
|
27
27
|
// TODO(burdon): Since this only wraps Thread, just separate out hook?
|
|
28
28
|
export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
@@ -40,18 +40,17 @@ export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
|
40
40
|
const messageQueue = useMessageQueue(chat);
|
|
41
41
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
42
42
|
// TODO(thure): This will be referentially new on every render, is it causing overreactivity?
|
|
43
|
-
const messages = [...(messageQueue?.
|
|
43
|
+
const messages = [...(messageQueue?.objects ?? []), ...processor.messages.value];
|
|
44
44
|
|
|
45
45
|
// Post last message to document.
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
if (!processor.streaming.value && messageQueue?.
|
|
48
|
-
const message = messageQueue.
|
|
47
|
+
if (!processor.streaming.value && messageQueue?.objects) {
|
|
48
|
+
const message = messageQueue.objects[messageQueue.objects.length - 1];
|
|
49
49
|
if (space && chat && message && dispatch && associatedArtifact) {
|
|
50
50
|
void dispatch(
|
|
51
51
|
createIntent(CollaborationActions.InsertContent, {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
object: refFromDXN(new DXN(DXN.kind.QUEUE, [...chat.assistantChatQueue.dxn.parts, message.id])),
|
|
52
|
+
target: associatedArtifact,
|
|
53
|
+
object: refFromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
55
54
|
label: 'View proposal',
|
|
56
55
|
}),
|
|
57
56
|
);
|
|
@@ -71,7 +70,7 @@ export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
|
71
70
|
|
|
72
71
|
invariant(messageQueue);
|
|
73
72
|
void processor.request(text, {
|
|
74
|
-
history: messageQueue.
|
|
73
|
+
history: messageQueue.objects,
|
|
75
74
|
onComplete: (messages) => {
|
|
76
75
|
messageQueue.append(messages);
|
|
77
76
|
},
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type
|
|
5
|
+
import React, { type FC, type PropsWithChildren } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type MessageContentBlock, type Message, type
|
|
7
|
+
import { type MessageContentBlock, type Message, type Tool } from '@dxos/ai';
|
|
8
|
+
import { Surface } from '@dxos/app-framework';
|
|
9
|
+
import type { BaseEchoObject } from '@dxos/echo-schema';
|
|
8
10
|
import { invariant } from '@dxos/invariant';
|
|
9
11
|
import { type Space } from '@dxos/react-client/echo';
|
|
10
12
|
import { Button, Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -20,7 +22,7 @@ import { safeParseJson } from '@dxos/util';
|
|
|
20
22
|
import { ToolBlock, isToolMessage } from './ToolInvocations';
|
|
21
23
|
import { ToolboxContainer } from '../Toolbox';
|
|
22
24
|
|
|
23
|
-
const panelClassNames = 'flex flex-col w-full px-2 bg-
|
|
25
|
+
const panelClassNames = 'flex flex-col w-full px-2 bg-activeSurface rounded-md';
|
|
24
26
|
const userClassNames = 'bg-[--user-fill] text-accentSurfaceText';
|
|
25
27
|
|
|
26
28
|
const ToggleContainer = (props: ToggleContainerProps) => {
|
|
@@ -43,12 +45,20 @@ export type ThreadMessageProps = ThemedClassName<{
|
|
|
43
45
|
space?: Space;
|
|
44
46
|
message: Message;
|
|
45
47
|
debug?: boolean;
|
|
46
|
-
tools?:
|
|
48
|
+
tools?: Tool[];
|
|
47
49
|
onPrompt?: (text: string) => void;
|
|
48
50
|
onDelete?: (id: string) => void;
|
|
51
|
+
onAddToGraph?: (object: BaseEchoObject) => void;
|
|
49
52
|
}>;
|
|
50
53
|
|
|
51
|
-
export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
54
|
+
export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
55
|
+
classNames,
|
|
56
|
+
space,
|
|
57
|
+
message,
|
|
58
|
+
tools,
|
|
59
|
+
onPrompt,
|
|
60
|
+
onAddToGraph,
|
|
61
|
+
}) => {
|
|
52
62
|
const { role, content = [] } = message;
|
|
53
63
|
|
|
54
64
|
// TODO(burdon): Restructure types to make check unnecessary.
|
|
@@ -74,13 +84,18 @@ export const ThreadMessage: FC<ThreadMessageProps> = ({ classNames, space, messa
|
|
|
74
84
|
classNames={mx(classNames, 'animate-[fadeIn_0.5s]')}
|
|
75
85
|
user={block.type === 'text' && role === 'user'}
|
|
76
86
|
>
|
|
77
|
-
<Component space={space} block={block} onPrompt={onPrompt} />
|
|
87
|
+
<Component space={space} block={block} onPrompt={onPrompt} onAddToGraph={onAddToGraph} />
|
|
78
88
|
</MessageContainer>
|
|
79
89
|
);
|
|
80
90
|
});
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
type BlockComponent = FC<{
|
|
93
|
+
type BlockComponent = FC<{
|
|
94
|
+
space?: Space;
|
|
95
|
+
block: MessageContentBlock;
|
|
96
|
+
onPrompt?: (text: string) => void;
|
|
97
|
+
onAddToGraph?: (object: BaseEchoObject) => void;
|
|
98
|
+
}>;
|
|
84
99
|
|
|
85
100
|
const components: Record<string, BlockComponent> = {
|
|
86
101
|
//
|
|
@@ -124,7 +139,7 @@ const components: Record<string, BlockComponent> = {
|
|
|
124
139
|
//
|
|
125
140
|
// JSON
|
|
126
141
|
//
|
|
127
|
-
['json' as const]: ({ space, block, onPrompt }) => {
|
|
142
|
+
['json' as const]: ({ space, block, onPrompt, onAddToGraph }) => {
|
|
128
143
|
invariant(block.type === 'json');
|
|
129
144
|
|
|
130
145
|
switch (block.disposition) {
|
|
@@ -158,6 +173,26 @@ const components: Record<string, BlockComponent> = {
|
|
|
158
173
|
);
|
|
159
174
|
}
|
|
160
175
|
|
|
176
|
+
case 'graph': {
|
|
177
|
+
return (
|
|
178
|
+
<div className='flex flex-wrap gap-1'>
|
|
179
|
+
<Surface
|
|
180
|
+
role='card'
|
|
181
|
+
data={{ subject: JSON.parse(block.json ?? '{}') }}
|
|
182
|
+
limit={1}
|
|
183
|
+
fallback={<div className='font-mono text-xs text-pre'>{block.json}</div>}
|
|
184
|
+
/>
|
|
185
|
+
{onAddToGraph && (
|
|
186
|
+
<IconButton
|
|
187
|
+
icon='ph--plus--regular'
|
|
188
|
+
label='Add to graph'
|
|
189
|
+
onClick={() => onAddToGraph?.(JSON.parse(block.json ?? '{}'))}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
161
196
|
default: {
|
|
162
197
|
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
163
198
|
return (
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type FC, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Message, type
|
|
7
|
+
import { type AgentStatus, type Message, type Tool } from '@dxos/ai';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { NumericTabs, StatusRoll, ToggleContainer } from '@dxos/react-ui-components';
|
|
@@ -17,22 +17,22 @@ export const isToolMessage = (message: Message) => {
|
|
|
17
17
|
return message.content.some((block) => block.type === 'tool_use' || block.type === 'tool_result');
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const getToolName = (tool:
|
|
20
|
+
const getToolName = (tool: Tool) => {
|
|
21
21
|
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split('_').pop();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const getToolCaption = (tool:
|
|
24
|
+
const getToolCaption = (tool: Tool | undefined, status: AgentStatus | undefined) => {
|
|
25
25
|
if (!tool) {
|
|
26
26
|
return 'Calling tool...';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return tool.caption ?? `Calling ${getToolName(tool)}...`;
|
|
29
|
+
return status?.message ?? tool.caption ?? `Calling ${getToolName(tool)}...`;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const ToolBlock: FC<ThemedClassName<ThreadMessageProps>> = ({ classNames, message, tools }) => {
|
|
33
33
|
const { content = [] } = message;
|
|
34
34
|
|
|
35
|
-
let request: { tool:
|
|
35
|
+
let request: { tool: Tool | undefined; block: any } | undefined;
|
|
36
36
|
const blocks = content.filter((block) => block.type === 'tool_use' || block.type === 'tool_result');
|
|
37
37
|
const items = blocks
|
|
38
38
|
.map((block) => {
|
|
@@ -43,8 +43,10 @@ export const ToolBlock: FC<ThemedClassName<ThreadMessageProps>> = ({ classNames,
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
log.info('tool_use', { tool: request?.tool, status: block.currentStatus });
|
|
47
|
+
|
|
46
48
|
request = { tool: tools?.find((tool) => tool.name === block.name), block };
|
|
47
|
-
return { title: getToolCaption(request.tool), block };
|
|
49
|
+
return { title: getToolCaption(request.tool, block.currentStatus), block };
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
case 'tool_result': {
|
|
@@ -53,7 +55,7 @@ export const ToolBlock: FC<ThemedClassName<ThreadMessageProps>> = ({ classNames,
|
|
|
53
55
|
return { title: 'Error', block };
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
return { title: `${getToolCaption(request.tool)} (Success)`, block };
|
|
58
|
+
return { title: `${getToolCaption(request.tool, undefined)} (Success)`, block };
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
default: {
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useState, useEffect, Fragment, type FC } from 'react';
|
|
6
6
|
|
|
7
|
+
import { parseToolName, type Tool } from '@dxos/ai';
|
|
7
8
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
-
import {
|
|
9
|
+
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
9
10
|
import { FunctionType } from '@dxos/functions';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
package/src/components/index.ts
CHANGED
package/src/hooks/processor.ts
CHANGED
|
@@ -4,12 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_EDGE_MODEL,
|
|
9
|
+
type ExecutableTool,
|
|
10
|
+
type AIServiceClient,
|
|
11
|
+
type GenerateRequest,
|
|
12
|
+
type Message,
|
|
13
|
+
type MessageContentBlock,
|
|
14
|
+
type ToolUseContentBlock,
|
|
15
|
+
} from '@dxos/ai';
|
|
7
16
|
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type ArtifactDefinition
|
|
9
|
-
import {
|
|
17
|
+
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
18
|
+
import { AISession, type ArtifactDiffResolver } from '@dxos/assistant';
|
|
10
19
|
import { invariant } from '@dxos/invariant';
|
|
11
20
|
import { log } from '@dxos/log';
|
|
12
|
-
import { getVersion, type Space } from '@dxos/react-client/echo';
|
|
21
|
+
import { Filter, getVersion, type Space } from '@dxos/react-client/echo';
|
|
13
22
|
|
|
14
23
|
// TODO(burdon): Factor out.
|
|
15
24
|
declare global {
|
|
@@ -78,7 +87,7 @@ export class ChatProcessor {
|
|
|
78
87
|
|
|
79
88
|
constructor(
|
|
80
89
|
private readonly _ai: AIServiceClient,
|
|
81
|
-
private _tools?:
|
|
90
|
+
private _tools?: ExecutableTool[],
|
|
82
91
|
private _artifacts?: ArtifactDefinition[],
|
|
83
92
|
private readonly _extensions?: ToolContextExtensions,
|
|
84
93
|
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
@@ -91,7 +100,7 @@ export class ChatProcessor {
|
|
|
91
100
|
/**
|
|
92
101
|
* Update tools.
|
|
93
102
|
*/
|
|
94
|
-
setTools(tools:
|
|
103
|
+
setTools(tools: ExecutableTool[]): void {
|
|
95
104
|
this._tools = tools;
|
|
96
105
|
}
|
|
97
106
|
|
|
@@ -120,6 +129,33 @@ export class ChatProcessor {
|
|
|
120
129
|
this._pending.value = [...this._pending.value, message];
|
|
121
130
|
});
|
|
122
131
|
|
|
132
|
+
this._session.toolStatusReport.on(({ message, status }) => {
|
|
133
|
+
const msg = this._pending.peek().find((m) => m.id === message.id);
|
|
134
|
+
const toolUse = msg?.content.find((block) => block.type === 'tool_use');
|
|
135
|
+
if (!toolUse) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const block = msg?.content.find(
|
|
140
|
+
(block): block is ToolUseContentBlock => block.type === 'tool_use' && block.id === toolUse.id,
|
|
141
|
+
);
|
|
142
|
+
if (block) {
|
|
143
|
+
this._pending.value = this._pending.value.map((m) => {
|
|
144
|
+
if (m.id === message.id) {
|
|
145
|
+
return {
|
|
146
|
+
...m,
|
|
147
|
+
content: m.content.map((b) =>
|
|
148
|
+
b.type === 'tool_use' && b.id === toolUse.id ? { ...b, currentStatus: status } : b,
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return m;
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
log.warn('no block for status report');
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
123
159
|
try {
|
|
124
160
|
const messages = await this._session.run({
|
|
125
161
|
client: this._ai,
|
|
@@ -130,28 +166,7 @@ export class ChatProcessor {
|
|
|
130
166
|
prompt: message,
|
|
131
167
|
systemPrompt: this._options.systemPrompt,
|
|
132
168
|
extensions: this._extensions,
|
|
133
|
-
artifactDiffResolver:
|
|
134
|
-
const space = this._extensions?.space;
|
|
135
|
-
if (!space) {
|
|
136
|
-
return new Map();
|
|
137
|
-
}
|
|
138
|
-
const versions = new Map();
|
|
139
|
-
await Promise.all(
|
|
140
|
-
artifacts.map(async (artifact) => {
|
|
141
|
-
const {
|
|
142
|
-
objects: [object],
|
|
143
|
-
} = await space.db.query({ id: artifact.id }).run();
|
|
144
|
-
if (!object) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
versions.set(artifact.id, {
|
|
148
|
-
version: getVersion(object),
|
|
149
|
-
diff: `Current state: ${JSON.stringify(object)}`,
|
|
150
|
-
});
|
|
151
|
-
}),
|
|
152
|
-
);
|
|
153
|
-
return versions;
|
|
154
|
-
},
|
|
169
|
+
artifactDiffResolver: this._artifactDiffResolver,
|
|
155
170
|
generationOptions: {
|
|
156
171
|
model: this._options.model,
|
|
157
172
|
},
|
|
@@ -192,6 +207,29 @@ export class ChatProcessor {
|
|
|
192
207
|
|
|
193
208
|
return messages;
|
|
194
209
|
}
|
|
210
|
+
|
|
211
|
+
private _artifactDiffResolver: ArtifactDiffResolver = async (artifacts) => {
|
|
212
|
+
const space = this._extensions?.space;
|
|
213
|
+
if (!space) {
|
|
214
|
+
return new Map();
|
|
215
|
+
}
|
|
216
|
+
const versions = new Map();
|
|
217
|
+
await Promise.all(
|
|
218
|
+
artifacts.map(async (artifact) => {
|
|
219
|
+
const {
|
|
220
|
+
objects: [object],
|
|
221
|
+
} = await space.db.query(Filter.ids(artifact.id)).run();
|
|
222
|
+
if (!object) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
versions.set(artifact.id, {
|
|
226
|
+
version: getVersion(object),
|
|
227
|
+
diff: `Current state: ${JSON.stringify(object)}`,
|
|
228
|
+
});
|
|
229
|
+
}),
|
|
230
|
+
);
|
|
231
|
+
return versions;
|
|
232
|
+
};
|
|
195
233
|
}
|
|
196
234
|
|
|
197
235
|
// TODO(wittjosiah): Move to ai-service-client.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { DEFAULT_EDGE_MODEL, DEFAULT_OLLAMA_MODEL, type ExecutableTool } from '@dxos/ai';
|
|
7
8
|
import { Capabilities, useCapabilities, useCapability, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type AssociatedArtifact, createSystemPrompt
|
|
9
|
-
import { DEFAULT_EDGE_MODEL, DEFAULT_OLLAMA_MODEL } from '@dxos/assistant';
|
|
9
|
+
import { type AssociatedArtifact, createSystemPrompt } from '@dxos/artifact';
|
|
10
10
|
import { FunctionType } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { useConfig } from '@dxos/react-client';
|
|
@@ -44,7 +44,7 @@ export const useChatProcessor = ({
|
|
|
44
44
|
|
|
45
45
|
// Services.
|
|
46
46
|
const services = useQuery(space, Filter.type(ServiceType));
|
|
47
|
-
const [serviceTools, setServiceTools] = useState<
|
|
47
|
+
const [serviceTools, setServiceTools] = useState<ExecutableTool[]>([]);
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
log('creating service tools...');
|
|
50
50
|
queueMicrotask(async () => {
|
|
@@ -59,7 +59,7 @@ export const useChatProcessor = ({
|
|
|
59
59
|
const chatId = useMemo(() => (chat ? fullyQualifiedId(chat) : undefined), [chat]);
|
|
60
60
|
const [tools, extensions] = useMemo(() => {
|
|
61
61
|
log('creating tools...');
|
|
62
|
-
const tools = [
|
|
62
|
+
const tools: ExecutableTool[] = [
|
|
63
63
|
...globalTools.flat(),
|
|
64
64
|
...serviceTools,
|
|
65
65
|
...functions
|