@dxos/plugin-assistant 0.8.2-staging.7ac8446 → 0.8.2
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/browser/ChatContainer-QTO4LE2C.mjs.map +7 -0
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs +28 -0
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs.map +7 -0
- package/dist/lib/browser/{ai-client-CDZLSNXE.mjs → ai-client-COXVUC6V.mjs} +6 -6
- package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-YH4EGNBC.mjs +206 -0
- 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-FMB7RGMP.mjs → chunk-QTW7KVDO.mjs} +1669 -1515
- 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 +35 -18
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-WJGLKKVO.mjs → intent-resolver-63EAHENI.mjs} +10 -14
- 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-U6UFQX32.mjs → settings-SHNQ4XXP.mjs} +5 -5
- package/dist/lib/browser/settings-SHNQ4XXP.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -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-ZJ5JXF6A.cjs → ChatContainer-5CLHJOIQ.cjs} +25 -19
- package/dist/lib/node/ChatContainer-5CLHJOIQ.cjs.map +7 -0
- package/dist/lib/node/TemplateContainer-CTG2MB4W.cjs +58 -0
- package/dist/lib/node/TemplateContainer-CTG2MB4W.cjs.map +7 -0
- package/dist/lib/node/{ai-client-URCCYU6B.cjs → ai-client-R2CGEYZW.cjs} +13 -13
- package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-PSHIOW3Q.cjs +216 -0
- 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-RPBKMP2E.cjs → chunk-H4A42LNR.cjs} +1504 -1343
- 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 +79 -63
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-R3OSTIMH.cjs → intent-resolver-66F7WLW6.cjs} +13 -17
- 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-TXGRCYAL.cjs → settings-ERKLO6IO.cjs} +9 -9
- package/dist/lib/node/settings-ERKLO6IO.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +17 -13
- 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/node-esm/ChatContainer-QTC5NYE2.mjs.map +7 -0
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs +29 -0
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-client-WMHS5EGV.mjs → ai-client-I5LXHMOZ.mjs} +6 -6
- package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-Z3GMMJMD.mjs +207 -0
- 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-MVDAY3CZ.mjs → chunk-SI5LOQEO.mjs} +1669 -1515
- 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 +35 -18
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-H32TL4X6.mjs → intent-resolver-X3PWH7KM.mjs} +10 -14
- 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-DZU5PNXM.mjs → settings-IVQRZUCU.mjs} +5 -5
- package/dist/lib/node-esm/settings-IVQRZUCU.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +3 -3
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- 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 +3 -179
- 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/AssistantSettings/AssistantSettings.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/ChatContainer.d.ts +4 -3
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- 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/Prompt/references.d.ts.map +1 -1
- package/dist/types/src/components/PromptSettings.d.ts +6 -0
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -0
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.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/Thread.stories.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 +3 -2
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -6
- 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/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- 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/useContextProvider.d.ts +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +11 -10
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/hooks/useServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextInputEvents.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 +6 -0
- 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/service.d.ts +96 -95
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts +52 -52
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +25 -20
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -61
- package/src/AssistantPlugin.tsx +7 -6
- package/src/capabilities/ai-client.ts +5 -6
- package/src/capabilities/app-graph-builder.ts +173 -135
- package/src/capabilities/capabilities.ts +1 -1
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +7 -9
- package/src/capabilities/react-surface.tsx +63 -16
- package/src/capabilities/settings.ts +2 -2
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +2 -2
- package/src/components/AmbientDialog/AmbientDialog.tsx +27 -13
- package/src/components/AssistantDialog.tsx +1 -1
- package/src/components/AssistantSettings/AssistantSettings.tsx +29 -7
- 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/ChatContainer.tsx +6 -8
- 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 -88
- package/src/components/Prompt/autocomplete.ts +14 -8
- package/src/components/Prompt/references.ts +3 -3
- package/src/components/PromptSettings.tsx +91 -0
- package/src/components/TemplateContainer.tsx +3 -79
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +4 -4
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +3 -3
- package/src/components/TemplateEditor/TemplateForm.tsx +2 -2
- package/src/components/Thread/Thread.stories.tsx +14 -17
- package/src/components/Thread/Thread.tsx +2 -2
- package/src/components/Thread/ThreadContainer.stories.tsx +83 -62
- package/src/components/Thread/ThreadContainer.tsx +26 -5
- package/src/components/Thread/ThreadMessage.tsx +49 -11
- package/src/components/Thread/ToolInvocations.tsx +9 -7
- package/src/components/Thread/reducer.ts +1 -1
- package/src/components/Toolbox/Toolbox.stories.tsx +4 -4
- package/src/components/Toolbox/Toolbox.tsx +5 -4
- package/src/components/index.ts +3 -1
- package/src/experimental/transcription/index.ts +3 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/processor.ts +68 -8
- package/src/hooks/useChatProcessor.tsx +12 -11
- package/src/hooks/useContextProvider.ts +21 -17
- package/src/hooks/useMessageQueue.ts +5 -5
- 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/testing/test-services.ts +6 -6
- package/src/tools/function.ts +11 -12
- package/src/tools/openapi.test.ts +18 -19
- package/src/tools/openapi.ts +24 -17
- package/src/translations.ts +9 -6
- package/src/types/chat.ts +27 -4
- package/src/types/service.ts +39 -37
- package/src/types/template.ts +27 -25
- package/src/types/types.ts +22 -17
- package/dist/lib/browser/AssistantDialog-YSHMAHW5.mjs +0 -117
- package/dist/lib/browser/AssistantDialog-YSHMAHW5.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-V5GP7DYF.mjs +0 -33
- package/dist/lib/browser/ChatContainer-V5GP7DYF.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-K4EJNGIL.mjs +0 -78
- package/dist/lib/browser/TemplateContainer-K4EJNGIL.mjs.map +0 -7
- package/dist/lib/browser/ai-client-CDZLSNXE.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-MF5EVDWW.mjs +0 -209
- package/dist/lib/browser/app-graph-builder-MF5EVDWW.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMB7RGMP.mjs.map +0 -7
- package/dist/lib/browser/chunk-IAMR2FAE.mjs +0 -183
- package/dist/lib/browser/chunk-IAMR2FAE.mjs.map +0 -7
- package/dist/lib/browser/chunk-KYMKVE6M.mjs +0 -128
- package/dist/lib/browser/chunk-KYMKVE6M.mjs.map +0 -7
- package/dist/lib/browser/chunk-NFUHCW2J.mjs +0 -81
- package/dist/lib/browser/chunk-TXJWGWJ7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WJGLKKVO.mjs.map +0 -7
- package/dist/lib/browser/react-surface-57VRDOQT.mjs +0 -90
- package/dist/lib/browser/react-surface-57VRDOQT.mjs.map +0 -7
- package/dist/lib/browser/settings-U6UFQX32.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-YI2BSGSX.cjs +0 -141
- package/dist/lib/node/AssistantDialog-YI2BSGSX.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-ZJ5JXF6A.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-XWFYJB4T.cjs +0 -104
- package/dist/lib/node/TemplateContainer-XWFYJB4T.cjs.map +0 -7
- package/dist/lib/node/ai-client-URCCYU6B.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-N5ZUUI2Z.cjs +0 -220
- package/dist/lib/node/app-graph-builder-N5ZUUI2Z.cjs.map +0 -7
- package/dist/lib/node/chunk-APRU3QWK.cjs +0 -206
- package/dist/lib/node/chunk-APRU3QWK.cjs.map +0 -7
- package/dist/lib/node/chunk-GBUNQ257.cjs.map +0 -7
- package/dist/lib/node/chunk-RPBKMP2E.cjs.map +0 -7
- package/dist/lib/node/chunk-ZKOC4ZFY.cjs +0 -152
- package/dist/lib/node/chunk-ZKOC4ZFY.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-R3OSTIMH.cjs.map +0 -7
- package/dist/lib/node/react-surface-NUQTM6MS.cjs +0 -106
- package/dist/lib/node/react-surface-NUQTM6MS.cjs.map +0 -7
- package/dist/lib/node/settings-TXGRCYAL.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-U2FQX5TD.mjs +0 -118
- package/dist/lib/node-esm/AssistantDialog-U2FQX5TD.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-QW3OOXTT.mjs +0 -34
- package/dist/lib/node-esm/ChatContainer-QW3OOXTT.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-EUM2X65J.mjs +0 -79
- package/dist/lib/node-esm/TemplateContainer-EUM2X65J.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-WMHS5EGV.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-DWBNIMHM.mjs +0 -210
- package/dist/lib/node-esm/app-graph-builder-DWBNIMHM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JK5HEUQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GBBXIW5F.mjs +0 -129
- package/dist/lib/node-esm/chunk-GBBXIW5F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MVDAY3CZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs +0 -184
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-H32TL4X6.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-JBVZF6CP.mjs +0 -91
- package/dist/lib/node-esm/react-surface-JBVZF6CP.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DZU5PNXM.mjs.map +0 -7
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -49
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -76
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/hooks/invocation-handler.ts +0 -107
- package/src/hooks/useLocalTriggerManager.ts +0 -82
|
@@ -26,263 +26,672 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_H4A42LNR_exports = {};
|
|
30
|
+
__export(chunk_H4A42LNR_exports, {
|
|
31
31
|
AiClient: () => AiClient,
|
|
32
32
|
AppGraphBuilder: () => AppGraphBuilder,
|
|
33
|
-
AssistantSettings: () => AssistantSettings,
|
|
34
33
|
IntentResolver: () => IntentResolver,
|
|
34
|
+
Prompt: () => Prompt,
|
|
35
|
+
PromptBar: () => PromptBar,
|
|
35
36
|
ReactSurface: () => ReactSurface,
|
|
37
|
+
Settings: () => Settings,
|
|
36
38
|
Thread: () => Thread,
|
|
37
39
|
ThreadContainer: () => ThreadContainer,
|
|
38
40
|
Toolbox: () => Toolbox,
|
|
39
|
-
ToolboxContainer: () => ToolboxContainer
|
|
40
|
-
useServices: () => useServices
|
|
41
|
+
ToolboxContainer: () => ToolboxContainer
|
|
41
42
|
});
|
|
42
|
-
module.exports = __toCommonJS(
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
43
|
+
module.exports = __toCommonJS(chunk_H4A42LNR_exports);
|
|
44
|
+
var import_chunk_TS3H5OSX = require("./chunk-TS3H5OSX.cjs");
|
|
45
|
+
var import_chunk_RXPA2C2A = require("./chunk-RXPA2C2A.cjs");
|
|
46
|
+
var import_chunk_P74TWGMG = require("./chunk-P74TWGMG.cjs");
|
|
47
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
48
|
+
var import_state = require("@codemirror/state");
|
|
46
49
|
var import_react = __toESM(require("react"));
|
|
50
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
51
|
+
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
52
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
53
|
+
var import_util = require("@dxos/util");
|
|
54
|
+
var import_state2 = require("@codemirror/state");
|
|
55
|
+
var import_view = require("@codemirror/view");
|
|
56
|
+
var import_autocomplete = require("@codemirror/autocomplete");
|
|
57
|
+
var import_state3 = require("@codemirror/state");
|
|
58
|
+
var import_view2 = require("@codemirror/view");
|
|
59
|
+
var import_async = require("@dxos/async");
|
|
60
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
61
|
+
var import_react2 = __toESM(require("react"));
|
|
62
|
+
var import_plugin_transcription = require("@dxos/plugin-transcription");
|
|
63
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
64
|
+
var import_react_ui_sfx = require("@dxos/react-ui-sfx");
|
|
65
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
66
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
67
|
+
var import_react3 = __toESM(require("react"));
|
|
68
|
+
var import_ai = require("@dxos/ai");
|
|
47
69
|
var import_app_framework = require("@dxos/app-framework");
|
|
48
|
-
var
|
|
49
|
-
var import_types = require("@dxos/functions/types");
|
|
70
|
+
var import_functions = require("@dxos/functions");
|
|
50
71
|
var import_log = require("@dxos/log");
|
|
51
72
|
var import_echo = require("@dxos/react-client/echo");
|
|
52
|
-
var
|
|
53
|
-
var
|
|
73
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
74
|
+
var import_ai2 = require("@dxos/ai");
|
|
54
75
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
55
|
-
var
|
|
76
|
+
var import_functions2 = require("@dxos/functions");
|
|
56
77
|
var import_log2 = require("@dxos/log");
|
|
57
78
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
79
|
+
var import_effect = require("effect");
|
|
58
80
|
var import_jsonpointer = __toESM(require("jsonpointer"));
|
|
59
|
-
var
|
|
81
|
+
var import_ai3 = require("@dxos/ai");
|
|
60
82
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
61
83
|
var import_invariant = require("@dxos/invariant");
|
|
62
84
|
var import_log3 = require("@dxos/log");
|
|
63
|
-
var
|
|
64
|
-
var
|
|
85
|
+
var import_util2 = require("@dxos/util");
|
|
86
|
+
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
87
|
+
var import_react4 = __toESM(require("react"));
|
|
65
88
|
var import_halo = require("@dxos/react-client/halo");
|
|
66
89
|
var import_react_ui_components = require("@dxos/react-ui-components");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
90
|
+
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
91
|
+
var import_util3 = require("@dxos/util");
|
|
92
|
+
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
93
|
+
var import_react5 = __toESM(require("react"));
|
|
94
|
+
var import_app_framework2 = require("@dxos/app-framework");
|
|
70
95
|
var import_invariant2 = require("@dxos/invariant");
|
|
71
|
-
var
|
|
96
|
+
var import_react_ui3 = require("@dxos/react-ui");
|
|
72
97
|
var import_react_ui_components2 = require("@dxos/react-ui-components");
|
|
73
98
|
var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
99
|
+
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
100
|
+
var import_util4 = require("@dxos/util");
|
|
101
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
102
|
+
var import_react6 = __toESM(require("react"));
|
|
77
103
|
var import_log4 = require("@dxos/log");
|
|
78
104
|
var import_react_ui_components3 = require("@dxos/react-ui-components");
|
|
79
105
|
var import_react_ui_syntax_highlighter2 = require("@dxos/react-ui-syntax-highlighter");
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var import_react5 = __toESM(require("react"));
|
|
83
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
84
|
-
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
85
|
-
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
86
|
-
var import_state2 = require("@codemirror/state");
|
|
87
|
-
var import_view = require("@codemirror/view");
|
|
88
|
-
var import_autocomplete = require("@codemirror/autocomplete");
|
|
89
|
-
var import_state3 = require("@codemirror/state");
|
|
90
|
-
var import_view2 = require("@codemirror/view");
|
|
91
|
-
var import_async = require("@dxos/async");
|
|
92
|
-
var import_react6 = __toESM(require("react"));
|
|
93
|
-
var import_plugin_transcription = require("@dxos/plugin-transcription");
|
|
94
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
95
|
-
var import_react_ui_sfx = require("@dxos/react-ui-sfx");
|
|
96
|
-
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
106
|
+
var import_util5 = require("@dxos/util");
|
|
107
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
97
108
|
var import_react7 = __toESM(require("react"));
|
|
109
|
+
var import_app_framework3 = require("@dxos/app-framework");
|
|
98
110
|
var import_invariant3 = require("@dxos/invariant");
|
|
111
|
+
var import_keys = require("@dxos/keys");
|
|
112
|
+
var import_live_object = require("@dxos/live-object");
|
|
99
113
|
var import_log5 = require("@dxos/log");
|
|
100
114
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
101
115
|
var import_signals_core = require("@preact/signals-core");
|
|
116
|
+
var import_ai4 = require("@dxos/ai");
|
|
102
117
|
var import_assistant = require("@dxos/assistant");
|
|
103
118
|
var import_invariant4 = require("@dxos/invariant");
|
|
104
119
|
var import_log6 = require("@dxos/log");
|
|
120
|
+
var import_echo4 = require("@dxos/react-client/echo");
|
|
121
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
105
122
|
var import_react8 = require("react");
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var
|
|
123
|
+
var import_ai5 = require("@dxos/ai");
|
|
124
|
+
var import_app_framework4 = require("@dxos/app-framework");
|
|
125
|
+
var import_artifact = require("@dxos/artifact");
|
|
126
|
+
var import_functions3 = require("@dxos/functions");
|
|
110
127
|
var import_log7 = require("@dxos/log");
|
|
111
128
|
var import_react_client = require("@dxos/react-client");
|
|
112
|
-
var import_echo4 = require("@dxos/react-client/echo");
|
|
113
|
-
var import_util5 = require("@dxos/util");
|
|
114
|
-
var import_app_framework3 = require("@dxos/app-framework");
|
|
115
|
-
var import_react9 = require("react");
|
|
116
|
-
var import_async2 = require("@dxos/async");
|
|
117
|
-
var import_context = require("@dxos/context");
|
|
118
|
-
var import_functions = require("@dxos/functions");
|
|
119
|
-
var import_types4 = require("@dxos/functions/types");
|
|
120
|
-
var import_invariant5 = require("@dxos/invariant");
|
|
121
|
-
var import_log8 = require("@dxos/log");
|
|
122
|
-
var import_react_client2 = require("@dxos/react-client");
|
|
123
129
|
var import_echo5 = require("@dxos/react-client/echo");
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
127
|
-
var
|
|
128
|
-
var import_keys = require("@dxos/keys");
|
|
129
|
-
var import_log9 = require("@dxos/log");
|
|
130
|
-
var import_react10 = require("react");
|
|
131
|
-
var import_keys2 = require("@dxos/keys");
|
|
130
|
+
var import_util6 = require("@dxos/util");
|
|
131
|
+
var import_app_framework5 = require("@dxos/app-framework");
|
|
132
|
+
var import_react9 = require("react");
|
|
133
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
132
134
|
var import_echo6 = require("@dxos/react-client/echo");
|
|
135
|
+
var import_react10 = require("react");
|
|
136
|
+
var import_testing = require("@dxos/ai/testing");
|
|
137
|
+
var import_assistant2 = require("@dxos/assistant");
|
|
138
|
+
var import_schema = require("@dxos/schema");
|
|
139
|
+
var import_util7 = require("@dxos/util");
|
|
140
|
+
var import_ai6 = require("@dxos/ai");
|
|
141
|
+
var import_artifact2 = require("@dxos/artifact");
|
|
142
|
+
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
143
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
133
144
|
var import_react11 = require("react");
|
|
134
|
-
var import_artifact5 = require("@dxos/artifact");
|
|
135
|
-
var import_assistant3 = require("@dxos/assistant");
|
|
136
|
-
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
137
145
|
var import_react12 = require("react");
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
var import_app_framework6 = require("@dxos/app-framework");
|
|
147
|
+
var import_echo7 = require("@dxos/client/echo");
|
|
148
|
+
var import_echo8 = require("@dxos/echo");
|
|
149
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
150
|
+
var import_log8 = require("@dxos/log");
|
|
151
|
+
var autocompleteExtension = ({ onSubmit, onSuggest, onCancel }) => {
|
|
152
|
+
const suggest = import_view.ViewPlugin.fromClass(class {
|
|
153
|
+
constructor(view) {
|
|
154
|
+
this._currentSuggestion = null;
|
|
155
|
+
this._decorations = this.computeDecorations(view);
|
|
156
|
+
}
|
|
157
|
+
update(update) {
|
|
158
|
+
if (update.docChanged || update.selectionSet) {
|
|
159
|
+
this._decorations = this.computeDecorations(update.view);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
computeDecorations(view) {
|
|
163
|
+
const text = view.state.doc.toString();
|
|
164
|
+
const suggestions = onSuggest?.(text) ?? [];
|
|
165
|
+
if (!suggestions.length) {
|
|
166
|
+
this._currentSuggestion = null;
|
|
167
|
+
return import_view.Decoration.none;
|
|
168
|
+
}
|
|
169
|
+
this._currentSuggestion = suggestions[0];
|
|
170
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
171
|
+
if (!suffix) {
|
|
172
|
+
return import_view.Decoration.none;
|
|
173
|
+
}
|
|
174
|
+
return import_view.Decoration.set([
|
|
175
|
+
import_view.Decoration.widget({
|
|
176
|
+
widget: new InlineSuggestionWidget(suffix),
|
|
177
|
+
side: 1
|
|
178
|
+
}).range(view.state.doc.length)
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
completeSuggestion(view) {
|
|
182
|
+
if (!this._currentSuggestion) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const text = view.state.doc.toString();
|
|
186
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
187
|
+
if (!suffix) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
view.dispatch({
|
|
191
|
+
changes: {
|
|
192
|
+
from: view.state.doc.length,
|
|
193
|
+
insert: suffix
|
|
174
194
|
},
|
|
175
|
-
|
|
195
|
+
selection: {
|
|
196
|
+
anchor: view.state.doc.length + suffix.length
|
|
197
|
+
}
|
|
176
198
|
});
|
|
177
|
-
return
|
|
199
|
+
return true;
|
|
178
200
|
}
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
182
|
-
var createToolsFromService = async (service) => {
|
|
183
|
-
(0, import_invariant.invariant)(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
184
|
-
F: __dxlog_file2,
|
|
185
|
-
L: 22,
|
|
186
|
-
S: void 0,
|
|
187
|
-
A: [
|
|
188
|
-
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
189
|
-
""
|
|
190
|
-
]
|
|
191
|
-
});
|
|
192
|
-
const iface = service.interfaces[0];
|
|
193
|
-
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
194
|
-
F: __dxlog_file2,
|
|
195
|
-
L: 24,
|
|
196
|
-
S: void 0,
|
|
197
|
-
A: [
|
|
198
|
-
"iface.schemaUrl",
|
|
199
|
-
""
|
|
200
|
-
]
|
|
201
|
-
});
|
|
202
|
-
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
203
|
-
F: __dxlog_file2,
|
|
204
|
-
L: 25,
|
|
205
|
-
S: void 0,
|
|
206
|
-
A: [
|
|
207
|
-
"iface.schemaUrl",
|
|
208
|
-
""
|
|
209
|
-
]
|
|
210
|
-
});
|
|
211
|
-
return createToolsFromApi(iface.schemaUrl, {
|
|
212
|
-
authorization: iface.authorization
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
var createToolsFromApi = async (url, options) => {
|
|
216
|
-
const res = await fetch(url);
|
|
217
|
-
const spec = await res.json();
|
|
218
|
-
(0, import_log3.log)("spec", {
|
|
219
|
-
spec
|
|
220
201
|
}, {
|
|
221
|
-
|
|
222
|
-
L: 32,
|
|
223
|
-
S: void 0,
|
|
224
|
-
C: (f, a) => f(...a)
|
|
202
|
+
decorations: (v) => v._decorations
|
|
225
203
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const { ...methods } = pathItem;
|
|
232
|
-
for (const [method, m] of Object.entries(methods)) {
|
|
233
|
-
const methodItem = m;
|
|
234
|
-
(0, import_log3.log)("methodItem", {
|
|
235
|
-
path,
|
|
236
|
-
method,
|
|
237
|
-
methodItem
|
|
238
|
-
}, {
|
|
239
|
-
F: __dxlog_file2,
|
|
240
|
-
L: 44,
|
|
241
|
-
S: void 0,
|
|
242
|
-
C: (f, a) => f(...a)
|
|
243
|
-
});
|
|
244
|
-
const parametersResolved = methodItem.parameters?.map((parameter) => {
|
|
245
|
-
const resolved = resolveJsonSchema(parameter, spec);
|
|
246
|
-
return resolved;
|
|
247
|
-
}) ?? [];
|
|
248
|
-
const inputSchema = {
|
|
249
|
-
type: "object",
|
|
250
|
-
properties: {}
|
|
251
|
-
};
|
|
252
|
-
const endpointParameters = [];
|
|
253
|
-
for (const parameter of parametersResolved) {
|
|
254
|
-
(0, import_log3.log)("parameter", {
|
|
255
|
-
parameter
|
|
256
|
-
}, {
|
|
257
|
-
F: __dxlog_file2,
|
|
258
|
-
L: 59,
|
|
259
|
-
S: void 0,
|
|
260
|
-
C: (f, a) => f(...a)
|
|
261
|
-
});
|
|
262
|
-
if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
endpointParameters.push(parameter);
|
|
266
|
-
if (parameter.schema) {
|
|
267
|
-
inputSchema.properties[parameter.name] = (0, import_echo_schema2.normalizeSchema)(parameter.schema);
|
|
268
|
-
} else if (typeof parameter.type === "string") {
|
|
269
|
-
const { name, in: _in, required, ...schema } = parameter;
|
|
270
|
-
inputSchema.properties[name] = (0, import_echo_schema2.normalizeSchema)(schema);
|
|
271
|
-
if (required) {
|
|
272
|
-
inputSchema.required ??= [];
|
|
273
|
-
inputSchema.required.push(name);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
204
|
+
return [
|
|
205
|
+
suggest,
|
|
206
|
+
import_view.EditorView.theme({
|
|
207
|
+
".cm-inline-suggestion": {
|
|
208
|
+
opacity: 0.4
|
|
276
209
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
210
|
+
}),
|
|
211
|
+
import_state2.Prec.highest(import_view.keymap.of([
|
|
212
|
+
{
|
|
213
|
+
key: "Tab",
|
|
214
|
+
preventDefault: true,
|
|
215
|
+
run: (view) => {
|
|
216
|
+
const plugin = view.plugin(suggest);
|
|
217
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "ArrowRight",
|
|
222
|
+
preventDefault: true,
|
|
223
|
+
run: (view) => {
|
|
224
|
+
if (view.state.selection.main.head !== view.state.doc.length) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const plugin = view.plugin(suggest);
|
|
228
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: "Enter",
|
|
233
|
+
preventDefault: true,
|
|
234
|
+
run: (view) => {
|
|
235
|
+
const text = view.state.doc.toString().trim();
|
|
236
|
+
if (text.length > 0 && onSubmit) {
|
|
237
|
+
const reset = onSubmit(text);
|
|
238
|
+
if (reset) {
|
|
239
|
+
view.dispatch({
|
|
240
|
+
changes: {
|
|
241
|
+
from: 0,
|
|
242
|
+
to: view.state.doc.length,
|
|
243
|
+
insert: ""
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
key: "Shift-Enter",
|
|
253
|
+
preventDefault: true,
|
|
254
|
+
run: (view) => {
|
|
255
|
+
view.dispatch({
|
|
256
|
+
changes: {
|
|
257
|
+
from: view.state.selection.main.head,
|
|
258
|
+
insert: "\n"
|
|
259
|
+
},
|
|
260
|
+
selection: {
|
|
261
|
+
anchor: view.state.selection.main.head + 1,
|
|
262
|
+
head: view.state.selection.main.head + 1
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
key: "Escape",
|
|
270
|
+
preventDefault: true,
|
|
271
|
+
run: (view) => {
|
|
272
|
+
view.dispatch({
|
|
273
|
+
changes: {
|
|
274
|
+
from: 0,
|
|
275
|
+
to: view.state.doc.length,
|
|
276
|
+
insert: ""
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
onCancel?.();
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
]))
|
|
284
|
+
];
|
|
285
|
+
};
|
|
286
|
+
var InlineSuggestionWidget = class extends import_view.WidgetType {
|
|
287
|
+
constructor(suffix) {
|
|
288
|
+
super(), this.suffix = suffix;
|
|
289
|
+
}
|
|
290
|
+
toDOM() {
|
|
291
|
+
const span = document.createElement("span");
|
|
292
|
+
span.textContent = this.suffix;
|
|
293
|
+
span.className = "cm-inline-suggestion";
|
|
294
|
+
return span;
|
|
295
|
+
}
|
|
296
|
+
eq(other) {
|
|
297
|
+
return other.suffix === this.suffix;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
|
|
301
|
+
if (triggerCharacter.length !== 1) {
|
|
302
|
+
throw new Error("triggerCharacter must be a single character");
|
|
303
|
+
}
|
|
304
|
+
const decorationField = import_view2.ViewPlugin.fromClass(class ReferenceView {
|
|
305
|
+
constructor(view) {
|
|
306
|
+
this._mutex = new import_async.Mutex();
|
|
307
|
+
this.decorations = import_view2.Decoration.set([]);
|
|
308
|
+
queueMicrotask(async () => {
|
|
309
|
+
const guard = await this._mutex.acquire();
|
|
310
|
+
try {
|
|
311
|
+
this.decorations = await this._computeDecorations(view);
|
|
312
|
+
} finally {
|
|
313
|
+
guard.release();
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
update(update) {
|
|
318
|
+
if (update.docChanged) {
|
|
319
|
+
queueMicrotask(async () => {
|
|
320
|
+
const guard = await this._mutex.acquire();
|
|
321
|
+
try {
|
|
322
|
+
this.decorations = await this._computeDecorations(update.view);
|
|
323
|
+
} finally {
|
|
324
|
+
guard.release();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async _computeDecorations(view) {
|
|
330
|
+
const text = view.state.doc.toString();
|
|
331
|
+
const references = text.matchAll(new RegExp(`${triggerCharacter}[a-zA-Z0-9@:]+\\s`, "g"));
|
|
332
|
+
const decorations = [];
|
|
333
|
+
for (const match of references) {
|
|
334
|
+
const reference = match[0];
|
|
335
|
+
const uri = reference.slice(1, -1);
|
|
336
|
+
const data = await provider.resolveReference({
|
|
337
|
+
uri
|
|
338
|
+
});
|
|
339
|
+
if (data) {
|
|
340
|
+
decorations.push(import_view2.Decoration.replace({
|
|
341
|
+
widget: new ReferenceWidget(data)
|
|
342
|
+
}).range(match.index, match.index + reference.length));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return import_view2.Decoration.set(decorations);
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
decorations: (v) => v.decorations,
|
|
349
|
+
provide: (plugin) => [
|
|
350
|
+
import_view2.EditorView.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? import_state3.RangeSet.empty)
|
|
351
|
+
]
|
|
352
|
+
});
|
|
353
|
+
return [
|
|
354
|
+
decorationField,
|
|
355
|
+
import_view2.EditorView.theme({
|
|
356
|
+
".cm-reference-pill": {
|
|
357
|
+
borderRadius: "0.25rem",
|
|
358
|
+
borderWidth: "1px",
|
|
359
|
+
marginRight: "0.25rem",
|
|
360
|
+
marginLeft: "0.25rem"
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
(0, import_autocomplete.autocompletion)({
|
|
364
|
+
activateOnTyping: true,
|
|
365
|
+
override: [
|
|
366
|
+
async (context) => {
|
|
367
|
+
const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
|
|
368
|
+
if (!match || match?.to === match?.from) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
const query = match.text.slice(1);
|
|
372
|
+
const references = await provider.getReferences({
|
|
373
|
+
query
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
from: match.from,
|
|
377
|
+
filter: false,
|
|
378
|
+
options: references.map((reference) => ({
|
|
379
|
+
label: reference.label,
|
|
380
|
+
apply: `${triggerCharacter}${reference.uri} `
|
|
381
|
+
}))
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
],
|
|
385
|
+
closeOnBlur: !debug,
|
|
386
|
+
tooltipClass: () => "shadow rounded",
|
|
387
|
+
aboveCursor: true
|
|
388
|
+
}),
|
|
389
|
+
import_view2.keymap.of(import_autocomplete.completionKeymap)
|
|
390
|
+
];
|
|
391
|
+
};
|
|
392
|
+
var ReferenceWidget = class extends import_view2.WidgetType {
|
|
393
|
+
constructor(data) {
|
|
394
|
+
super(), this.data = data;
|
|
395
|
+
}
|
|
396
|
+
toDOM() {
|
|
397
|
+
const span = document.createElement("span");
|
|
398
|
+
span.textContent = `@ ${this.data.label}`;
|
|
399
|
+
span.className = "cm-reference-pill";
|
|
400
|
+
return span;
|
|
401
|
+
}
|
|
402
|
+
eq(other) {
|
|
403
|
+
return other.data.uri === this.data.uri;
|
|
404
|
+
}
|
|
405
|
+
ignoreEvent() {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var Prompt = /* @__PURE__ */ (0, import_react.forwardRef)(({ classNames, extensions, references, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onCancel, onOpenChange }, forwardRef3) => {
|
|
410
|
+
var _effect = (0, import_tracking.useSignals)();
|
|
411
|
+
try {
|
|
412
|
+
const { themeMode } = (0, import_react_ui.useThemeContext)();
|
|
413
|
+
const { parentRef, view } = (0, import_react_ui_editor.useTextEditor)({
|
|
414
|
+
debug: true,
|
|
415
|
+
autoFocus,
|
|
416
|
+
extensions: [
|
|
417
|
+
autocompleteExtension({
|
|
418
|
+
onSubmit,
|
|
419
|
+
onSuggest,
|
|
420
|
+
onCancel
|
|
421
|
+
}),
|
|
422
|
+
(0, import_react_ui_editor.createBasicExtensions)({
|
|
423
|
+
bracketMatching: false,
|
|
424
|
+
lineWrapping,
|
|
425
|
+
placeholder
|
|
426
|
+
}),
|
|
427
|
+
(0, import_react_ui_editor.createThemeExtensions)({
|
|
428
|
+
themeMode
|
|
429
|
+
}),
|
|
430
|
+
references ? promptReferences({
|
|
431
|
+
provider: references
|
|
432
|
+
}) : [],
|
|
433
|
+
import_state.Prec.highest(import_react_ui_editor.keymap.of([
|
|
434
|
+
{
|
|
435
|
+
key: "cmd-ArrowUp",
|
|
436
|
+
preventDefault: true,
|
|
437
|
+
run: () => {
|
|
438
|
+
onOpenChange?.(true);
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
key: "cmd-ArrowDown",
|
|
444
|
+
preventDefault: true,
|
|
445
|
+
run: () => {
|
|
446
|
+
onOpenChange?.(false);
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
])),
|
|
451
|
+
extensions
|
|
452
|
+
].filter(import_util.isNonNullable)
|
|
453
|
+
}, [
|
|
454
|
+
themeMode,
|
|
455
|
+
extensions,
|
|
456
|
+
onSubmit,
|
|
457
|
+
onSuggest
|
|
458
|
+
]);
|
|
459
|
+
(0, import_react.useImperativeHandle)(forwardRef3, () => {
|
|
460
|
+
return {
|
|
461
|
+
focus: () => {
|
|
462
|
+
view?.focus();
|
|
463
|
+
},
|
|
464
|
+
setText: (text) => {
|
|
465
|
+
view?.dispatch({
|
|
466
|
+
changes: {
|
|
467
|
+
from: 0,
|
|
468
|
+
to: view.state.doc.length,
|
|
469
|
+
insert: text
|
|
470
|
+
},
|
|
471
|
+
selection: {
|
|
472
|
+
anchor: text.length,
|
|
473
|
+
head: text.length
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}, [
|
|
479
|
+
view,
|
|
480
|
+
onSubmit
|
|
481
|
+
]);
|
|
482
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
483
|
+
ref: parentRef,
|
|
484
|
+
className: (0, import_react_ui_theme.mx)("w-full", classNames)
|
|
485
|
+
});
|
|
486
|
+
} finally {
|
|
487
|
+
_effect.f();
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
var PromptBar = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, placeholder, processing, error, microphone, references, onCancel, ...props }, forwardedRef) => {
|
|
491
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
492
|
+
try {
|
|
493
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_P74TWGMG.ASSISTANT_PLUGIN);
|
|
494
|
+
const promptRef = (0, import_react_ui2.useForwardedRef)(forwardedRef);
|
|
495
|
+
const [active, setActive] = (0, import_react2.useState)(false);
|
|
496
|
+
const { recording } = (0, import_plugin_transcription.useVoiceInput)({
|
|
497
|
+
active,
|
|
498
|
+
onUpdate: (text) => {
|
|
499
|
+
promptRef.current?.setText(text);
|
|
500
|
+
promptRef.current?.focus();
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
504
|
+
className: (0, import_react_ui_theme2.mx)("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
|
|
505
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
506
|
+
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
507
|
+
}, error && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
508
|
+
content: error.message,
|
|
509
|
+
delayDuration: 0
|
|
510
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Icon, {
|
|
511
|
+
icon: "ph--warning-circle--regular",
|
|
512
|
+
classNames: import_react_ui_theme2.errorText,
|
|
513
|
+
size: 5
|
|
514
|
+
})) || /* @__PURE__ */ import_react2.default.createElement(import_react_ui_sfx.Spinner, {
|
|
515
|
+
active: processing
|
|
516
|
+
})), /* @__PURE__ */ import_react2.default.createElement(Prompt, {
|
|
517
|
+
ref: promptRef,
|
|
518
|
+
autoFocus: true,
|
|
519
|
+
classNames: "pbs-2",
|
|
520
|
+
lineWrapping: true,
|
|
521
|
+
placeholder: placeholder ?? t("prompt placeholder"),
|
|
522
|
+
references,
|
|
523
|
+
onCancel,
|
|
524
|
+
...props
|
|
525
|
+
}), (onCancel || microphone) && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
526
|
+
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
527
|
+
}, processing && onCancel && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.IconButton, {
|
|
528
|
+
classNames: "px-1.5",
|
|
529
|
+
variant: "ghost",
|
|
530
|
+
size: 5,
|
|
531
|
+
icon: "ph--x--regular",
|
|
532
|
+
iconOnly: true,
|
|
533
|
+
label: t("cancel processing button"),
|
|
534
|
+
onClick: onCancel
|
|
535
|
+
}), !processing && microphone && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.IconButton, {
|
|
536
|
+
classNames: (0, import_react_ui_theme2.mx)("px-1.5", recording && "bg-primary-500"),
|
|
537
|
+
variant: "ghost",
|
|
538
|
+
size: 5,
|
|
539
|
+
icon: "ph--microphone--regular",
|
|
540
|
+
iconOnly: true,
|
|
541
|
+
noTooltip: true,
|
|
542
|
+
label: t("microphone button"),
|
|
543
|
+
onMouseDown: () => setActive(true),
|
|
544
|
+
onMouseUp: () => setActive(false),
|
|
545
|
+
onTouchStart: () => setActive(true),
|
|
546
|
+
onTouchEnd: () => setActive(false)
|
|
547
|
+
})));
|
|
548
|
+
} finally {
|
|
549
|
+
_effect.f();
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
553
|
+
var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
554
|
+
if (!fn.description || !fn.inputSchema) {
|
|
555
|
+
return void 0;
|
|
556
|
+
}
|
|
557
|
+
const existingFunctionUrl = (0, import_functions2.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
|
|
558
|
+
if (!existingFunctionUrl) {
|
|
559
|
+
return void 0;
|
|
560
|
+
}
|
|
561
|
+
const url = (0, import_functions2.getInvocationUrl)(existingFunctionUrl, edgeUrl, {
|
|
562
|
+
spaceId
|
|
563
|
+
});
|
|
564
|
+
return (0, import_ai2.createTool)("user-function", {
|
|
565
|
+
name: fn.name,
|
|
566
|
+
description: fn.description,
|
|
567
|
+
schema: (0, import_echo_schema.toEffectSchema)(fn.inputSchema),
|
|
568
|
+
execute: async (input) => {
|
|
569
|
+
import_log2.log.info("execute function tool", {
|
|
570
|
+
name: fn.name,
|
|
571
|
+
url,
|
|
572
|
+
input
|
|
573
|
+
}, {
|
|
574
|
+
F: __dxlog_file,
|
|
575
|
+
L: 34,
|
|
576
|
+
S: void 0,
|
|
283
577
|
C: (f, a) => f(...a)
|
|
284
578
|
});
|
|
285
|
-
|
|
579
|
+
const response = await fetch(url, {
|
|
580
|
+
method: "POST",
|
|
581
|
+
headers: {
|
|
582
|
+
"Content-Type": "application/json"
|
|
583
|
+
},
|
|
584
|
+
body: JSON.stringify(input)
|
|
585
|
+
});
|
|
586
|
+
return import_ai2.ToolResult.Success(await response.text());
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
591
|
+
var createToolsFromService = async (service) => {
|
|
592
|
+
(0, import_invariant.invariant)(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
593
|
+
F: __dxlog_file2,
|
|
594
|
+
L: 23,
|
|
595
|
+
S: void 0,
|
|
596
|
+
A: [
|
|
597
|
+
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
598
|
+
""
|
|
599
|
+
]
|
|
600
|
+
});
|
|
601
|
+
const iface = service.interfaces[0];
|
|
602
|
+
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
603
|
+
F: __dxlog_file2,
|
|
604
|
+
L: 25,
|
|
605
|
+
S: void 0,
|
|
606
|
+
A: [
|
|
607
|
+
"iface.schemaUrl",
|
|
608
|
+
""
|
|
609
|
+
]
|
|
610
|
+
});
|
|
611
|
+
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
612
|
+
F: __dxlog_file2,
|
|
613
|
+
L: 26,
|
|
614
|
+
S: void 0,
|
|
615
|
+
A: [
|
|
616
|
+
"iface.schemaUrl",
|
|
617
|
+
""
|
|
618
|
+
]
|
|
619
|
+
});
|
|
620
|
+
return createToolsFromApi(iface.schemaUrl, {
|
|
621
|
+
authorization: iface.authorization
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
var createToolsFromApi = async (url, options) => {
|
|
625
|
+
const res = await fetch(url);
|
|
626
|
+
const spec = await res.json();
|
|
627
|
+
(0, import_log3.log)("spec", {
|
|
628
|
+
spec
|
|
629
|
+
}, {
|
|
630
|
+
F: __dxlog_file2,
|
|
631
|
+
L: 36,
|
|
632
|
+
S: void 0,
|
|
633
|
+
C: (f, a) => f(...a)
|
|
634
|
+
});
|
|
635
|
+
const tools = [];
|
|
636
|
+
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
637
|
+
if (typeof pathItem !== "object") {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const { ...methods } = pathItem;
|
|
641
|
+
for (const [method, m] of Object.entries(methods)) {
|
|
642
|
+
const methodItem = m;
|
|
643
|
+
(0, import_log3.log)("methodItem", {
|
|
644
|
+
path,
|
|
645
|
+
method,
|
|
646
|
+
methodItem
|
|
647
|
+
}, {
|
|
648
|
+
F: __dxlog_file2,
|
|
649
|
+
L: 47,
|
|
650
|
+
S: void 0,
|
|
651
|
+
C: (f, a) => f(...a)
|
|
652
|
+
});
|
|
653
|
+
const parametersResolved = methodItem.parameters?.map((parameter) => {
|
|
654
|
+
const resolved = resolveJsonSchema(parameter, spec);
|
|
655
|
+
return resolved;
|
|
656
|
+
}) ?? [];
|
|
657
|
+
const inputSchema = {
|
|
658
|
+
type: "object",
|
|
659
|
+
properties: {}
|
|
660
|
+
};
|
|
661
|
+
const endpointParameters = [];
|
|
662
|
+
for (const parameter of parametersResolved) {
|
|
663
|
+
(0, import_log3.log)("parameter", {
|
|
664
|
+
parameter
|
|
665
|
+
}, {
|
|
666
|
+
F: __dxlog_file2,
|
|
667
|
+
L: 63,
|
|
668
|
+
S: void 0,
|
|
669
|
+
C: (f, a) => f(...a)
|
|
670
|
+
});
|
|
671
|
+
if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
endpointParameters.push(parameter);
|
|
675
|
+
if (parameter.schema) {
|
|
676
|
+
inputSchema.properties[parameter.name] = (0, import_echo_schema2.normalizeSchema)(parameter.schema);
|
|
677
|
+
} else if (typeof parameter.type === "string") {
|
|
678
|
+
const { name, in: _in, required, ...schema } = parameter;
|
|
679
|
+
inputSchema.properties[name] = (0, import_echo_schema2.normalizeSchema)(schema);
|
|
680
|
+
if (required) {
|
|
681
|
+
inputSchema.required ??= [];
|
|
682
|
+
inputSchema.required.push(name);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
(0, import_log3.log)("inputSchema", {
|
|
687
|
+
inputSchema
|
|
688
|
+
}, {
|
|
689
|
+
F: __dxlog_file2,
|
|
690
|
+
L: 88,
|
|
691
|
+
S: void 0,
|
|
692
|
+
C: (f, a) => f(...a)
|
|
693
|
+
});
|
|
694
|
+
import_effect.Schema.validateSync(import_echo_schema2.JsonSchemaType)(inputSchema);
|
|
286
695
|
const description = methodItem.description ?? methodItem.summary;
|
|
287
696
|
if (!description) {
|
|
288
697
|
import_log3.log.warn("no description", {
|
|
@@ -290,7 +699,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
290
699
|
method
|
|
291
700
|
}, {
|
|
292
701
|
F: __dxlog_file2,
|
|
293
|
-
L:
|
|
702
|
+
L: 93,
|
|
294
703
|
S: void 0,
|
|
295
704
|
C: (f, a) => f(...a)
|
|
296
705
|
});
|
|
@@ -303,17 +712,20 @@ var createToolsFromApi = async (url, options) => {
|
|
|
303
712
|
parameters: endpointParameters,
|
|
304
713
|
authorization: options?.authorization
|
|
305
714
|
};
|
|
306
|
-
tools.push(
|
|
307
|
-
|
|
308
|
-
|
|
715
|
+
tools.push(
|
|
716
|
+
// TODO(burdon): Namespace?
|
|
717
|
+
(0, import_ai3.createRawTool)("openapi", {
|
|
718
|
+
name: getToolName(path, method, methodItem),
|
|
719
|
+
description: options?.instructions ? `${options.instructions}
|
|
309
720
|
|
|
310
721
|
${description}` : description,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
722
|
+
parameters: inputSchema,
|
|
723
|
+
execute: async (input) => {
|
|
724
|
+
const response = await callApiEndpoint(endpoint, input);
|
|
725
|
+
return import_ai3.ToolResult.Success(response);
|
|
726
|
+
}
|
|
727
|
+
})
|
|
728
|
+
);
|
|
317
729
|
}
|
|
318
730
|
}
|
|
319
731
|
return tools;
|
|
@@ -366,7 +778,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
366
778
|
input
|
|
367
779
|
}, {
|
|
368
780
|
F: __dxlog_file2,
|
|
369
|
-
L:
|
|
781
|
+
L: 180,
|
|
370
782
|
S: void 0,
|
|
371
783
|
C: (f, a) => f(...a)
|
|
372
784
|
});
|
|
@@ -395,7 +807,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
395
807
|
case "body": {
|
|
396
808
|
const value = input[parameter.name];
|
|
397
809
|
const effectSchema = (0, import_echo_schema2.toEffectSchema)(parameter.schema);
|
|
398
|
-
|
|
810
|
+
import_effect.Schema.validateSync(effectSchema)(value);
|
|
399
811
|
if (body) {
|
|
400
812
|
throw new Error(`Duplicate body parameter: ${parameter.name}`);
|
|
401
813
|
}
|
|
@@ -425,7 +837,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
425
837
|
request
|
|
426
838
|
}, {
|
|
427
839
|
F: __dxlog_file2,
|
|
428
|
-
L:
|
|
840
|
+
L: 243,
|
|
429
841
|
S: void 0,
|
|
430
842
|
C: (f, a) => f(...a)
|
|
431
843
|
});
|
|
@@ -436,7 +848,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
436
848
|
statusText: response.statusText
|
|
437
849
|
}, {
|
|
438
850
|
F: __dxlog_file2,
|
|
439
|
-
L:
|
|
851
|
+
L: 246,
|
|
440
852
|
S: void 0,
|
|
441
853
|
C: (f, a) => f(...a)
|
|
442
854
|
});
|
|
@@ -460,7 +872,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
460
872
|
error
|
|
461
873
|
}, {
|
|
462
874
|
F: __dxlog_file2,
|
|
463
|
-
L:
|
|
875
|
+
L: 264,
|
|
464
876
|
S: void 0,
|
|
465
877
|
C: (f, a) => f(...a)
|
|
466
878
|
});
|
|
@@ -469,969 +881,657 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
469
881
|
const error = await response.text();
|
|
470
882
|
import_log3.log.error("error", {
|
|
471
883
|
error
|
|
472
|
-
}, {
|
|
473
|
-
F: __dxlog_file2,
|
|
474
|
-
L:
|
|
475
|
-
S: void 0,
|
|
476
|
-
C: (f, a) => f(...a)
|
|
477
|
-
});
|
|
478
|
-
throw new Error(error);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
var getEndpointUrl = (endpoint) => {
|
|
483
|
-
let url = "";
|
|
484
|
-
if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
|
|
485
|
-
url = endpoint.document.servers[0].url;
|
|
486
|
-
} else {
|
|
487
|
-
(0, import_invariant.invariant)(!isV3_1(endpoint.document), void 0, {
|
|
488
|
-
F: __dxlog_file2,
|
|
489
|
-
L: 272,
|
|
490
|
-
S: void 0,
|
|
491
|
-
A: [
|
|
492
|
-
"!isV3_1(endpoint.document)",
|
|
493
|
-
""
|
|
494
|
-
]
|
|
495
|
-
});
|
|
496
|
-
url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
|
|
497
|
-
}
|
|
498
|
-
if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
|
|
499
|
-
url += endpoint.document.basePath;
|
|
500
|
-
}
|
|
501
|
-
url += endpoint.path;
|
|
502
|
-
return url;
|
|
503
|
-
};
|
|
504
|
-
var resolveAuthorization = async (authorization) => {
|
|
505
|
-
switch (authorization.type) {
|
|
506
|
-
case "api-key": {
|
|
507
|
-
(0, import_invariant.invariant)(authorization.placement.type === "authorization-header", void 0, {
|
|
508
|
-
F: __dxlog_file2,
|
|
509
|
-
L: 288,
|
|
510
|
-
S: void 0,
|
|
511
|
-
A: [
|
|
512
|
-
"authorization.placement.type === 'authorization-header'",
|
|
513
|
-
""
|
|
514
|
-
]
|
|
515
|
-
});
|
|
516
|
-
return `Bearer ${authorization.key}`;
|
|
517
|
-
}
|
|
518
|
-
case "oauth": {
|
|
519
|
-
const response = await fetch(authorization.tokenUrl, {
|
|
520
|
-
method: "POST",
|
|
521
|
-
headers: {
|
|
522
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
523
|
-
},
|
|
524
|
-
body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
|
|
525
|
-
});
|
|
526
|
-
const data = await response.json();
|
|
527
|
-
return `Bearer ${data.access_token}`;
|
|
528
|
-
}
|
|
529
|
-
default: {
|
|
530
|
-
throw new Error(`Unknown authorization type: ${authorization.type}`);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
var resolveJsonSchema = (schema, base) => {
|
|
535
|
-
return (0, import_util.deepMapValues)(schema, (value, recurse) => {
|
|
536
|
-
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
537
|
-
if (value.$ref.startsWith("#")) {
|
|
538
|
-
const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
|
|
539
|
-
if (resolved) {
|
|
540
|
-
return recurse(resolved);
|
|
541
|
-
} else {
|
|
542
|
-
import_log3.log.warn("unresolved", {
|
|
543
|
-
ref: value.$ref,
|
|
544
|
-
base
|
|
545
|
-
}, {
|
|
546
|
-
F: __dxlog_file2,
|
|
547
|
-
L: 321,
|
|
548
|
-
S: void 0,
|
|
549
|
-
C: (f, a) => f(...a)
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return recurse(value);
|
|
555
|
-
});
|
|
556
|
-
};
|
|
557
|
-
var isV3_1 = (document2) => {
|
|
558
|
-
return document2.openapi === "3.0.1";
|
|
559
|
-
};
|
|
560
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
561
|
-
var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
|
|
562
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
563
|
-
className: (0, import_react_ui_theme.mx)("flex flex-col overflow-y-auto box-content", classNames)
|
|
564
|
-
}, artifacts && artifacts.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
|
|
565
|
-
title: "Artifacts",
|
|
566
|
-
items: artifacts.map(({ name, description, tools }) => ({
|
|
567
|
-
name,
|
|
568
|
-
description,
|
|
569
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
570
|
-
name: `\u2219 ${(0, import_artifact.parseToolName)(name2)}`,
|
|
571
|
-
description: description2
|
|
572
|
-
}))
|
|
573
|
-
}))
|
|
574
|
-
}), services && services.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
|
|
575
|
-
title: "Services",
|
|
576
|
-
items: services.map(({ service: { serviceId, name, description }, tools }) => ({
|
|
577
|
-
name: name ?? serviceId,
|
|
578
|
-
description,
|
|
579
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
580
|
-
name: `\u2219 ${name2}`,
|
|
581
|
-
description: description2
|
|
582
|
-
}))
|
|
583
|
-
}))
|
|
584
|
-
}), functions && functions.length > 0 && /* @__PURE__ */ import_react.default.createElement(Section, {
|
|
585
|
-
title: "Functions",
|
|
586
|
-
items: functions.map(({ name, description }) => ({
|
|
587
|
-
name,
|
|
588
|
-
description
|
|
589
|
-
}))
|
|
590
|
-
}));
|
|
591
|
-
};
|
|
592
|
-
var Section = ({ title, items, striped }) => {
|
|
593
|
-
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
594
|
-
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
595
|
-
const subGridClassNames = (0, import_react_ui_theme.mx)("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
596
|
-
return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h1", {
|
|
597
|
-
className: "px-2 text-sm"
|
|
598
|
-
}, title), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
599
|
-
className: gridClassNames
|
|
600
|
-
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, {
|
|
601
|
-
key: i
|
|
602
|
-
}, name && /* @__PURE__ */ import_react.default.createElement("div", {
|
|
603
|
-
className: subGridClassNames
|
|
604
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
605
|
-
className: "truncate text-primary-500"
|
|
606
|
-
}, name), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
607
|
-
className: "line-clamp-2"
|
|
608
|
-
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ import_react.default.createElement("div", {
|
|
609
|
-
key: i2,
|
|
610
|
-
className: (0, import_react_ui_theme.mx)(subGridClassNames, striped && stripeClassNames)
|
|
611
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
612
|
-
className: "truncate"
|
|
613
|
-
}, name2), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
614
|
-
className: "line-clamp-3 text-subdued"
|
|
615
|
-
}, description2)))))));
|
|
616
|
-
};
|
|
617
|
-
var ToolboxContainer = ({ classNames, space }) => {
|
|
618
|
-
const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
|
|
619
|
-
const services = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_chunk_APRU3QWK.ServiceType));
|
|
620
|
-
const [serviceTools, setServiceTools] = (0, import_react.useState)([]);
|
|
621
|
-
(0, import_react.useEffect)(() => {
|
|
622
|
-
(0, import_log.log)("creating service tools...", {
|
|
623
|
-
services: services.length
|
|
624
|
-
}, {
|
|
625
|
-
F: __dxlog_file3,
|
|
626
|
-
L: 99,
|
|
627
|
-
S: void 0,
|
|
628
|
-
C: (f, a) => f(...a)
|
|
629
|
-
});
|
|
630
|
-
queueMicrotask(async () => {
|
|
631
|
-
const tools = await Promise.all(services.map(async (service) => ({
|
|
632
|
-
service,
|
|
633
|
-
tools: await createToolsFromService(service)
|
|
634
|
-
})));
|
|
635
|
-
setServiceTools(tools);
|
|
636
|
-
});
|
|
637
|
-
}, [
|
|
638
|
-
services
|
|
639
|
-
]);
|
|
640
|
-
const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.FunctionType));
|
|
641
|
-
return /* @__PURE__ */ import_react.default.createElement(Toolbox, {
|
|
642
|
-
classNames,
|
|
643
|
-
artifacts: artifactDefinitions,
|
|
644
|
-
services: serviceTools,
|
|
645
|
-
functions
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
|
|
649
|
-
var isToolMessage = (message) => {
|
|
650
|
-
return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
651
|
-
};
|
|
652
|
-
var getToolName2 = (tool) => {
|
|
653
|
-
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
654
|
-
};
|
|
655
|
-
var getToolCaption = (tool) => {
|
|
656
|
-
if (!tool) {
|
|
657
|
-
return "Calling tool...";
|
|
658
|
-
}
|
|
659
|
-
return tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
660
|
-
};
|
|
661
|
-
var ToolBlock = ({ classNames, message, tools }) => {
|
|
662
|
-
const { content = [] } = message;
|
|
663
|
-
let request;
|
|
664
|
-
const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
665
|
-
const items = blocks.map((block) => {
|
|
666
|
-
switch (block.type) {
|
|
667
|
-
case "tool_use": {
|
|
668
|
-
if (block.pending && request?.block.id === block.id) {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
671
|
-
request = {
|
|
672
|
-
tool: tools?.find((tool) => tool.name === block.name),
|
|
673
|
-
block
|
|
674
|
-
};
|
|
675
|
-
return {
|
|
676
|
-
title: getToolCaption(request.tool),
|
|
677
|
-
block
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
case "tool_result": {
|
|
681
|
-
if (!request) {
|
|
682
|
-
import_log4.log.warn("unexpected message", {
|
|
683
|
-
block
|
|
684
|
-
}, {
|
|
685
|
-
F: __dxlog_file4,
|
|
686
|
-
L: 52,
|
|
687
|
-
S: void 0,
|
|
688
|
-
C: (f, a) => f(...a)
|
|
689
|
-
});
|
|
690
|
-
return {
|
|
691
|
-
title: "Error",
|
|
692
|
-
block
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
return {
|
|
696
|
-
title: `${getToolCaption(request.tool)} (Success)`,
|
|
697
|
-
block
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
default: {
|
|
701
|
-
request = void 0;
|
|
702
|
-
return {
|
|
703
|
-
title: "Error",
|
|
704
|
-
block
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}).filter(import_util4.isNonNullable);
|
|
709
|
-
return /* @__PURE__ */ import_react4.default.createElement(ToolContainer, {
|
|
710
|
-
classNames,
|
|
711
|
-
items
|
|
712
|
-
});
|
|
713
|
-
};
|
|
714
|
-
var ToolContainer = ({ classNames, items }) => {
|
|
715
|
-
const tabsRef = (0, import_react4.useRef)(null);
|
|
716
|
-
const [selected, setSelected] = (0, import_react4.useState)(0);
|
|
717
|
-
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
718
|
-
(0, import_react4.useEffect)(() => {
|
|
719
|
-
if (open) {
|
|
720
|
-
tabsRef.current?.focus();
|
|
721
|
-
}
|
|
722
|
-
}, [
|
|
723
|
-
open
|
|
724
|
-
]);
|
|
725
|
-
const handleSelect = (index) => {
|
|
726
|
-
if (index === selected) {
|
|
727
|
-
setOpen(false);
|
|
728
|
-
} else {
|
|
729
|
-
setSelected(index);
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
const title = (0, import_react4.useMemo)(() => {
|
|
733
|
-
const lines = items.map((item) => item.title).filter(import_util4.isNotFalsy);
|
|
734
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.StatusRoll, {
|
|
735
|
-
key: "status-roll",
|
|
736
|
-
lines,
|
|
737
|
-
duration: 1e3,
|
|
738
|
-
autoAdvance: true
|
|
739
|
-
});
|
|
740
|
-
}, [
|
|
741
|
-
items
|
|
742
|
-
]);
|
|
743
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.ToggleContainer, {
|
|
744
|
-
classNames: [
|
|
745
|
-
"flex flex-col",
|
|
746
|
-
classNames
|
|
747
|
-
],
|
|
748
|
-
title,
|
|
749
|
-
open,
|
|
750
|
-
onChangeOpen: setOpen
|
|
751
|
-
}, /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
752
|
-
className: "grid grid-cols-[32px_1fr]"
|
|
753
|
-
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components3.NumericTabs, {
|
|
754
|
-
ref: tabsRef,
|
|
755
|
-
length: items.length,
|
|
756
|
-
selected,
|
|
757
|
-
onSelect: handleSelect
|
|
758
|
-
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_syntax_highlighter2.Json, {
|
|
759
|
-
data: items[selected].block,
|
|
760
|
-
classNames: "!p-1 text-xs"
|
|
761
|
-
})));
|
|
762
|
-
};
|
|
763
|
-
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
|
|
764
|
-
var panelClassNames = "flex flex-col w-full px-2 bg-groupSurface rounded-md";
|
|
765
|
-
var userClassNames = "bg-[--user-fill] text-inverse";
|
|
766
|
-
var ToggleContainer2 = (props) => {
|
|
767
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_components2.ToggleContainer, {
|
|
768
|
-
...props,
|
|
769
|
-
classNames: (0, import_react_ui_theme3.mx)(panelClassNames, props.classNames)
|
|
770
|
-
});
|
|
771
|
-
};
|
|
772
|
-
var MessageContainer = ({ children, classNames, user }) => {
|
|
773
|
-
if (!children) {
|
|
774
|
-
return null;
|
|
775
|
-
}
|
|
776
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
777
|
-
role: "list-item",
|
|
778
|
-
className: (0, import_react_ui_theme3.mx)("flex w-full", user && "justify-end", classNames)
|
|
779
|
-
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
780
|
-
className: (0, import_react_ui_theme3.mx)(user ? [
|
|
781
|
-
"px-2 py-1 rounded-md",
|
|
782
|
-
userClassNames
|
|
783
|
-
] : "w-full")
|
|
784
|
-
}, children));
|
|
785
|
-
};
|
|
786
|
-
var ThreadMessage = ({ classNames, space, message, tools, onPrompt }) => {
|
|
787
|
-
const { role, content = [] } = message;
|
|
788
|
-
if (isToolMessage(message)) {
|
|
789
|
-
return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
|
|
790
|
-
classNames: (0, import_react_ui_theme3.mx)(classNames, "animate-[fadeIn_0.5s]")
|
|
791
|
-
}, /* @__PURE__ */ import_react3.default.createElement(ToolBlock, {
|
|
792
|
-
space,
|
|
793
|
-
classNames: panelClassNames,
|
|
794
|
-
message,
|
|
795
|
-
tools
|
|
796
|
-
}));
|
|
797
|
-
}
|
|
798
|
-
return content.map((block, idx) => {
|
|
799
|
-
if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
800
|
-
return null;
|
|
884
|
+
}, {
|
|
885
|
+
F: __dxlog_file2,
|
|
886
|
+
L: 268,
|
|
887
|
+
S: void 0,
|
|
888
|
+
C: (f, a) => f(...a)
|
|
889
|
+
});
|
|
890
|
+
throw new Error(error);
|
|
801
891
|
}
|
|
802
|
-
|
|
803
|
-
return /* @__PURE__ */ import_react3.default.createElement(MessageContainer, {
|
|
804
|
-
key: idx,
|
|
805
|
-
classNames: (0, import_react_ui_theme3.mx)(classNames, "animate-[fadeIn_0.5s]"),
|
|
806
|
-
user: block.type === "text" && role === "user"
|
|
807
|
-
}, /* @__PURE__ */ import_react3.default.createElement(Component, {
|
|
808
|
-
space,
|
|
809
|
-
block,
|
|
810
|
-
onPrompt
|
|
811
|
-
}));
|
|
812
|
-
});
|
|
892
|
+
}
|
|
813
893
|
};
|
|
814
|
-
var
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
(0,
|
|
820
|
-
F:
|
|
821
|
-
L:
|
|
894
|
+
var getEndpointUrl = (endpoint) => {
|
|
895
|
+
let url = "";
|
|
896
|
+
if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
|
|
897
|
+
url = endpoint.document.servers[0].url;
|
|
898
|
+
} else {
|
|
899
|
+
(0, import_invariant.invariant)(!isV3_1(endpoint.document), void 0, {
|
|
900
|
+
F: __dxlog_file2,
|
|
901
|
+
L: 279,
|
|
822
902
|
S: void 0,
|
|
823
903
|
A: [
|
|
824
|
-
"
|
|
904
|
+
"!isV3_1(endpoint.document)",
|
|
825
905
|
""
|
|
826
906
|
]
|
|
827
907
|
});
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
908
|
+
url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
|
|
909
|
+
}
|
|
910
|
+
if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
|
|
911
|
+
url += endpoint.document.basePath;
|
|
912
|
+
}
|
|
913
|
+
url += endpoint.path;
|
|
914
|
+
return url;
|
|
915
|
+
};
|
|
916
|
+
var resolveAuthorization = async (authorization) => {
|
|
917
|
+
switch (authorization.type) {
|
|
918
|
+
case "api-key": {
|
|
919
|
+
(0, import_invariant.invariant)(authorization.placement.type === "authorization-header", void 0, {
|
|
920
|
+
F: __dxlog_file2,
|
|
921
|
+
L: 295,
|
|
922
|
+
S: void 0,
|
|
923
|
+
A: [
|
|
924
|
+
"authorization.placement.type === 'authorization-header'",
|
|
925
|
+
""
|
|
926
|
+
]
|
|
833
927
|
});
|
|
928
|
+
return `Bearer ${authorization.key}`;
|
|
834
929
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
content: block.text,
|
|
846
|
-
classNames: [
|
|
847
|
-
"pbe-2",
|
|
848
|
-
block.disposition === "cot" && "text-sm text-subdued"
|
|
849
|
-
]
|
|
850
|
-
}));
|
|
851
|
-
},
|
|
852
|
-
//
|
|
853
|
-
// JSON
|
|
854
|
-
//
|
|
855
|
-
["json"]: ({ space, block, onPrompt }) => {
|
|
856
|
-
(0, import_invariant2.invariant)(block.type === "json", void 0, {
|
|
857
|
-
F: __dxlog_file5,
|
|
858
|
-
L: 128,
|
|
859
|
-
S: void 0,
|
|
860
|
-
A: [
|
|
861
|
-
"block.type === 'json'",
|
|
862
|
-
""
|
|
863
|
-
]
|
|
864
|
-
});
|
|
865
|
-
switch (block.disposition) {
|
|
866
|
-
case "tool_list": {
|
|
867
|
-
return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
|
|
868
|
-
title: titles[block.disposition],
|
|
869
|
-
defaultOpen: true
|
|
870
|
-
}, /* @__PURE__ */ import_react3.default.createElement(ToolboxContainer, {
|
|
871
|
-
space,
|
|
872
|
-
classNames: "pbe-2"
|
|
873
|
-
}));
|
|
874
|
-
}
|
|
875
|
-
case "suggest": {
|
|
876
|
-
const { text = "" } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
|
|
877
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui.IconButton, {
|
|
878
|
-
icon: "ph--lightning--regular",
|
|
879
|
-
label: text,
|
|
880
|
-
onClick: () => onPrompt?.(text)
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
case "select": {
|
|
884
|
-
const { options = [] } = (0, import_util3.safeParseJson)(block.json ?? "{}") ?? {};
|
|
885
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
886
|
-
className: "flex flex-wrap gap-1"
|
|
887
|
-
}, options.map((option, idx) => /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Button, {
|
|
888
|
-
classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
|
|
889
|
-
key: option,
|
|
890
|
-
onClick: () => onPrompt?.(option)
|
|
891
|
-
}, option)));
|
|
892
|
-
}
|
|
893
|
-
default: {
|
|
894
|
-
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
895
|
-
return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
|
|
896
|
-
title: title ?? "JSON"
|
|
897
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
898
|
-
data: (0, import_util3.safeParseJson)(block.json ?? block),
|
|
899
|
-
classNames: "!p-1 text-xs"
|
|
900
|
-
}));
|
|
901
|
-
}
|
|
930
|
+
case "oauth": {
|
|
931
|
+
const response = await fetch(authorization.tokenUrl, {
|
|
932
|
+
method: "POST",
|
|
933
|
+
headers: {
|
|
934
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
935
|
+
},
|
|
936
|
+
body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
|
|
937
|
+
});
|
|
938
|
+
const data = await response.json();
|
|
939
|
+
return `Bearer ${data.access_token}`;
|
|
902
940
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
// Default
|
|
906
|
-
//
|
|
907
|
-
default: ({ block }) => {
|
|
908
|
-
let title = titles[block.type];
|
|
909
|
-
if (block.type === "tool_use") {
|
|
910
|
-
title = `Tool [${block.name}]`;
|
|
941
|
+
default: {
|
|
942
|
+
throw new Error(`Unknown authorization type: ${authorization.type}`);
|
|
911
943
|
}
|
|
912
|
-
return /* @__PURE__ */ import_react3.default.createElement(ToggleContainer2, {
|
|
913
|
-
title: title ?? "JSON"
|
|
914
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
915
|
-
data: block,
|
|
916
|
-
classNames: "!p-1 text-xs"
|
|
917
|
-
}));
|
|
918
944
|
}
|
|
919
945
|
};
|
|
920
|
-
var
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
var messageReducer = ({ current, messages }, message) => {
|
|
928
|
-
let i = 0;
|
|
929
|
-
for (const block of message.content) {
|
|
930
|
-
switch (block.type) {
|
|
931
|
-
case "tool_use":
|
|
932
|
-
case "tool_result": {
|
|
933
|
-
if (current) {
|
|
934
|
-
current.content.push(block);
|
|
946
|
+
var resolveJsonSchema = (schema, base) => {
|
|
947
|
+
return (0, import_util2.deepMapValues)(schema, (value, recurse) => {
|
|
948
|
+
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
949
|
+
if (value.$ref.startsWith("#")) {
|
|
950
|
+
const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
|
|
951
|
+
if (resolved) {
|
|
952
|
+
return recurse(resolved);
|
|
935
953
|
} else {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
};
|
|
946
|
-
messages.push(current);
|
|
954
|
+
import_log3.log.warn("unresolved", {
|
|
955
|
+
ref: value.$ref,
|
|
956
|
+
base
|
|
957
|
+
}, {
|
|
958
|
+
F: __dxlog_file2,
|
|
959
|
+
L: 328,
|
|
960
|
+
S: void 0,
|
|
961
|
+
C: (f, a) => f(...a)
|
|
962
|
+
});
|
|
947
963
|
}
|
|
948
|
-
break;
|
|
949
|
-
}
|
|
950
|
-
case "text":
|
|
951
|
-
default: {
|
|
952
|
-
current = void 0;
|
|
953
|
-
messages.push({
|
|
954
|
-
id: [
|
|
955
|
-
message.id,
|
|
956
|
-
i
|
|
957
|
-
].join("_"),
|
|
958
|
-
role: message.role,
|
|
959
|
-
content: [
|
|
960
|
-
block
|
|
961
|
-
]
|
|
962
|
-
});
|
|
963
|
-
break;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
i++;
|
|
967
|
-
}
|
|
968
|
-
return {
|
|
969
|
-
current,
|
|
970
|
-
messages
|
|
971
|
-
};
|
|
972
|
-
};
|
|
973
|
-
var createAutocompleteExtension = ({ onSubmit, onSuggest }) => {
|
|
974
|
-
const suggestionPlugin = import_view.ViewPlugin.fromClass(class {
|
|
975
|
-
constructor(view) {
|
|
976
|
-
this._currentSuggestion = null;
|
|
977
|
-
this._decorations = this.computeDecorations(view);
|
|
978
|
-
}
|
|
979
|
-
update(update) {
|
|
980
|
-
if (update.docChanged || update.selectionSet) {
|
|
981
|
-
this._decorations = this.computeDecorations(update.view);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
computeDecorations(view) {
|
|
985
|
-
const text = view.state.doc.toString();
|
|
986
|
-
const suggestions = onSuggest?.(text) ?? [];
|
|
987
|
-
if (!suggestions.length) {
|
|
988
|
-
this._currentSuggestion = null;
|
|
989
|
-
return import_view.Decoration.none;
|
|
990
|
-
}
|
|
991
|
-
this._currentSuggestion = suggestions[0];
|
|
992
|
-
const suffix = this._currentSuggestion.slice(text.length);
|
|
993
|
-
if (!suffix) {
|
|
994
|
-
return import_view.Decoration.none;
|
|
995
|
-
}
|
|
996
|
-
return import_view.Decoration.set([
|
|
997
|
-
import_view.Decoration.widget({
|
|
998
|
-
widget: new InlineSuggestionWidget(suffix),
|
|
999
|
-
side: 1
|
|
1000
|
-
}).range(view.state.doc.length)
|
|
1001
|
-
]);
|
|
1002
|
-
}
|
|
1003
|
-
completeSuggestion(view) {
|
|
1004
|
-
if (!this._currentSuggestion) {
|
|
1005
|
-
return false;
|
|
1006
|
-
}
|
|
1007
|
-
const text = view.state.doc.toString();
|
|
1008
|
-
const suffix = this._currentSuggestion.slice(text.length);
|
|
1009
|
-
if (!suffix) {
|
|
1010
|
-
return false;
|
|
1011
964
|
}
|
|
1012
|
-
view.dispatch({
|
|
1013
|
-
changes: {
|
|
1014
|
-
from: view.state.doc.length,
|
|
1015
|
-
insert: suffix
|
|
1016
|
-
},
|
|
1017
|
-
selection: {
|
|
1018
|
-
anchor: view.state.doc.length + suffix.length
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
return true;
|
|
1022
965
|
}
|
|
1023
|
-
|
|
1024
|
-
decorations: (v) => v._decorations
|
|
966
|
+
return recurse(value);
|
|
1025
967
|
});
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
968
|
+
};
|
|
969
|
+
var isV3_1 = (document2) => {
|
|
970
|
+
return document2.openapi === "3.0.1";
|
|
971
|
+
};
|
|
972
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
973
|
+
var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
|
|
974
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
975
|
+
try {
|
|
976
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
977
|
+
className: (0, import_react_ui_theme3.mx)("flex flex-col overflow-y-auto box-content", classNames)
|
|
978
|
+
}, artifacts && artifacts.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
|
|
979
|
+
title: "Artifacts",
|
|
980
|
+
items: artifacts.map(({ name, description, tools }) => ({
|
|
981
|
+
name,
|
|
982
|
+
description,
|
|
983
|
+
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
984
|
+
name: `\u2219 ${(0, import_ai.parseToolName)(name2)}`,
|
|
985
|
+
description: description2
|
|
986
|
+
}))
|
|
987
|
+
}))
|
|
988
|
+
}), services && services.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
|
|
989
|
+
title: "Services",
|
|
990
|
+
items: services.map(({ service: { serviceId, name, description }, tools }) => ({
|
|
991
|
+
name: name ?? serviceId,
|
|
992
|
+
description,
|
|
993
|
+
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
994
|
+
name: `\u2219 ${name2}`,
|
|
995
|
+
description: description2
|
|
996
|
+
}))
|
|
997
|
+
}))
|
|
998
|
+
}), functions && functions.length > 0 && /* @__PURE__ */ import_react3.default.createElement(Section, {
|
|
999
|
+
title: "Functions",
|
|
1000
|
+
items: functions.map(({ name, description }) => ({
|
|
1001
|
+
name,
|
|
1002
|
+
description
|
|
1003
|
+
}))
|
|
1004
|
+
}));
|
|
1005
|
+
} finally {
|
|
1006
|
+
_effect.f();
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
var Section = ({ title, items, striped }) => {
|
|
1010
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
1011
|
+
try {
|
|
1012
|
+
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
1013
|
+
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
1014
|
+
const subGridClassNames = (0, import_react_ui_theme3.mx)("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
1015
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement("h1", {
|
|
1016
|
+
className: "px-2 text-sm"
|
|
1017
|
+
}, title), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1018
|
+
className: gridClassNames
|
|
1019
|
+
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ import_react3.default.createElement(import_react3.Fragment, {
|
|
1020
|
+
key: i
|
|
1021
|
+
}, name && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1022
|
+
className: subGridClassNames
|
|
1023
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1024
|
+
className: "truncate text-primary-500"
|
|
1025
|
+
}, name), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1026
|
+
className: "line-clamp-2"
|
|
1027
|
+
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1028
|
+
key: i2,
|
|
1029
|
+
className: (0, import_react_ui_theme3.mx)(subGridClassNames, striped && stripeClassNames)
|
|
1030
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1031
|
+
className: "truncate"
|
|
1032
|
+
}, name2), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1033
|
+
className: "line-clamp-3 text-subdued"
|
|
1034
|
+
}, description2)))))));
|
|
1035
|
+
} finally {
|
|
1036
|
+
_effect.f();
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
var ToolboxContainer = ({ classNames, space }) => {
|
|
1040
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
1041
|
+
try {
|
|
1042
|
+
const artifactDefinitions = (0, import_app_framework.useCapabilities)(import_app_framework.Capabilities.ArtifactDefinition);
|
|
1043
|
+
const services = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_chunk_RXPA2C2A.ServiceType));
|
|
1044
|
+
const [serviceTools, setServiceTools] = (0, import_react3.useState)([]);
|
|
1045
|
+
(0, import_react3.useEffect)(() => {
|
|
1046
|
+
(0, import_log.log)("creating service tools...", {
|
|
1047
|
+
services: services.length
|
|
1048
|
+
}, {
|
|
1049
|
+
F: __dxlog_file3,
|
|
1050
|
+
L: 100,
|
|
1051
|
+
S: void 0,
|
|
1052
|
+
C: (f, a) => f(...a)
|
|
1053
|
+
});
|
|
1054
|
+
queueMicrotask(async () => {
|
|
1055
|
+
const tools = await Promise.all(services.map(async (service) => ({
|
|
1056
|
+
service,
|
|
1057
|
+
tools: await createToolsFromService(service)
|
|
1058
|
+
})));
|
|
1059
|
+
setServiceTools(tools);
|
|
1060
|
+
});
|
|
1061
|
+
}, [
|
|
1062
|
+
services
|
|
1063
|
+
]);
|
|
1064
|
+
const functions = (0, import_echo.useQuery)(space, import_echo.Filter.type(import_functions.FunctionType));
|
|
1065
|
+
return /* @__PURE__ */ import_react3.default.createElement(Toolbox, {
|
|
1066
|
+
classNames,
|
|
1067
|
+
artifacts: artifactDefinitions,
|
|
1068
|
+
services: serviceTools,
|
|
1069
|
+
functions
|
|
1070
|
+
});
|
|
1071
|
+
} finally {
|
|
1072
|
+
_effect.f();
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
|
|
1076
|
+
var isToolMessage = (message) => {
|
|
1077
|
+
return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
1078
|
+
};
|
|
1079
|
+
var getToolName2 = (tool) => {
|
|
1080
|
+
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
1081
|
+
};
|
|
1082
|
+
var getToolCaption = (tool, status) => {
|
|
1083
|
+
if (!tool) {
|
|
1084
|
+
return "Calling tool...";
|
|
1085
|
+
}
|
|
1086
|
+
return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
1087
|
+
};
|
|
1088
|
+
var ToolBlock = ({ classNames, message, tools }) => {
|
|
1089
|
+
var _effect = (0, import_tracking6.useSignals)();
|
|
1090
|
+
try {
|
|
1091
|
+
const { content = [] } = message;
|
|
1092
|
+
let request;
|
|
1093
|
+
const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
1094
|
+
const items = blocks.map((block) => {
|
|
1095
|
+
switch (block.type) {
|
|
1096
|
+
case "tool_use": {
|
|
1097
|
+
if (block.pending && request?.block.id === block.id) {
|
|
1098
|
+
return null;
|
|
1049
1099
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1100
|
+
import_log4.log.info("tool_use", {
|
|
1101
|
+
tool: request?.tool,
|
|
1102
|
+
status: block.currentStatus
|
|
1103
|
+
}, {
|
|
1104
|
+
F: __dxlog_file4,
|
|
1105
|
+
L: 46,
|
|
1106
|
+
S: void 0,
|
|
1107
|
+
C: (f, a) => f(...a)
|
|
1108
|
+
});
|
|
1109
|
+
request = {
|
|
1110
|
+
tool: tools?.find((tool) => tool.name === block.name),
|
|
1111
|
+
block
|
|
1112
|
+
};
|
|
1113
|
+
return {
|
|
1114
|
+
title: getToolCaption(request.tool, block.currentStatus),
|
|
1115
|
+
block
|
|
1116
|
+
};
|
|
1052
1117
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1118
|
+
case "tool_result": {
|
|
1119
|
+
if (!request) {
|
|
1120
|
+
import_log4.log.warn("unexpected message", {
|
|
1121
|
+
block
|
|
1122
|
+
}, {
|
|
1123
|
+
F: __dxlog_file4,
|
|
1124
|
+
L: 54,
|
|
1125
|
+
S: void 0,
|
|
1126
|
+
C: (f, a) => f(...a)
|
|
1127
|
+
});
|
|
1128
|
+
return {
|
|
1129
|
+
title: "Error",
|
|
1130
|
+
block
|
|
1131
|
+
};
|
|
1070
1132
|
}
|
|
1071
|
-
return
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
key: "Shift-Enter",
|
|
1076
|
-
preventDefault: true,
|
|
1077
|
-
run: (view) => {
|
|
1078
|
-
view.dispatch({
|
|
1079
|
-
changes: {
|
|
1080
|
-
from: view.state.selection.main.head,
|
|
1081
|
-
insert: "\n"
|
|
1082
|
-
},
|
|
1083
|
-
selection: {
|
|
1084
|
-
anchor: view.state.selection.main.head + 1,
|
|
1085
|
-
head: view.state.selection.main.head + 1
|
|
1086
|
-
}
|
|
1087
|
-
});
|
|
1088
|
-
return true;
|
|
1133
|
+
return {
|
|
1134
|
+
title: `${getToolCaption(request.tool, void 0)} (Success)`,
|
|
1135
|
+
block
|
|
1136
|
+
};
|
|
1089
1137
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
changes: {
|
|
1097
|
-
from: 0,
|
|
1098
|
-
to: view.state.doc.length,
|
|
1099
|
-
insert: ""
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
return true;
|
|
1138
|
+
default: {
|
|
1139
|
+
request = void 0;
|
|
1140
|
+
return {
|
|
1141
|
+
title: "Error",
|
|
1142
|
+
block
|
|
1143
|
+
};
|
|
1103
1144
|
}
|
|
1104
1145
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1146
|
+
}).filter(import_util5.isNonNullable);
|
|
1147
|
+
return /* @__PURE__ */ import_react6.default.createElement(ToolContainer, {
|
|
1148
|
+
classNames,
|
|
1149
|
+
items
|
|
1150
|
+
});
|
|
1151
|
+
} finally {
|
|
1152
|
+
_effect.f();
|
|
1153
|
+
}
|
|
1107
1154
|
};
|
|
1108
|
-
var
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1155
|
+
var ToolContainer = ({ classNames, items }) => {
|
|
1156
|
+
var _effect = (0, import_tracking6.useSignals)();
|
|
1157
|
+
try {
|
|
1158
|
+
const tabsRef = (0, import_react6.useRef)(null);
|
|
1159
|
+
const [selected, setSelected] = (0, import_react6.useState)(0);
|
|
1160
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1161
|
+
(0, import_react6.useEffect)(() => {
|
|
1162
|
+
if (open) {
|
|
1163
|
+
tabsRef.current?.focus();
|
|
1164
|
+
}
|
|
1165
|
+
}, [
|
|
1166
|
+
open
|
|
1167
|
+
]);
|
|
1168
|
+
const handleSelect = (index) => {
|
|
1169
|
+
if (index === selected) {
|
|
1170
|
+
setOpen(false);
|
|
1171
|
+
} else {
|
|
1172
|
+
setSelected(index);
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
const title = (0, import_react6.useMemo)(() => {
|
|
1176
|
+
const lines = items.map((item) => item.title).filter(import_util5.isNotFalsy);
|
|
1177
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.StatusRoll, {
|
|
1178
|
+
key: "status-roll",
|
|
1179
|
+
lines,
|
|
1180
|
+
duration: 1e3,
|
|
1181
|
+
autoAdvance: true
|
|
1182
|
+
});
|
|
1183
|
+
}, [
|
|
1184
|
+
items
|
|
1185
|
+
]);
|
|
1186
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.ToggleContainer, {
|
|
1187
|
+
classNames: [
|
|
1188
|
+
"flex flex-col",
|
|
1189
|
+
classNames
|
|
1190
|
+
],
|
|
1191
|
+
title,
|
|
1192
|
+
open,
|
|
1193
|
+
onChangeOpen: setOpen
|
|
1194
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1195
|
+
className: "grid grid-cols-[32px_1fr]"
|
|
1196
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_components3.NumericTabs, {
|
|
1197
|
+
ref: tabsRef,
|
|
1198
|
+
length: items.length,
|
|
1199
|
+
selected,
|
|
1200
|
+
onSelect: handleSelect
|
|
1201
|
+
}), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_syntax_highlighter2.Json, {
|
|
1202
|
+
data: items[selected].block,
|
|
1203
|
+
classNames: "!p-1 text-xs"
|
|
1204
|
+
})));
|
|
1205
|
+
} finally {
|
|
1206
|
+
_effect.f();
|
|
1112
1207
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1208
|
+
};
|
|
1209
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
|
|
1210
|
+
var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-md";
|
|
1211
|
+
var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
|
|
1212
|
+
var ToggleContainer2 = (props) => {
|
|
1213
|
+
var _effect = (0, import_tracking5.useSignals)();
|
|
1214
|
+
try {
|
|
1215
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.ToggleContainer, {
|
|
1216
|
+
...props,
|
|
1217
|
+
classNames: (0, import_react_ui_theme5.mx)(panelClassNames, props.classNames)
|
|
1218
|
+
});
|
|
1219
|
+
} finally {
|
|
1220
|
+
_effect.f();
|
|
1118
1221
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1222
|
+
};
|
|
1223
|
+
var MessageContainer = ({ children, classNames, user }) => {
|
|
1224
|
+
var _effect = (0, import_tracking5.useSignals)();
|
|
1225
|
+
try {
|
|
1226
|
+
if (!children) {
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1230
|
+
role: "list-item",
|
|
1231
|
+
className: (0, import_react_ui_theme5.mx)("flex w-full", user && "justify-end", classNames)
|
|
1232
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1233
|
+
className: (0, import_react_ui_theme5.mx)(user ? [
|
|
1234
|
+
"px-2 py-1 rounded-md",
|
|
1235
|
+
userClassNames
|
|
1236
|
+
] : "w-full")
|
|
1237
|
+
}, children));
|
|
1238
|
+
} finally {
|
|
1239
|
+
_effect.f();
|
|
1121
1240
|
}
|
|
1122
1241
|
};
|
|
1123
|
-
var
|
|
1124
|
-
|
|
1125
|
-
|
|
1242
|
+
var ThreadMessage = ({ classNames, space, message, tools, onPrompt, onAddToGraph }) => {
|
|
1243
|
+
var _effect = (0, import_tracking5.useSignals)();
|
|
1244
|
+
try {
|
|
1245
|
+
const { role, content = [] } = message;
|
|
1246
|
+
if (isToolMessage(message)) {
|
|
1247
|
+
return /* @__PURE__ */ import_react5.default.createElement(MessageContainer, {
|
|
1248
|
+
classNames: (0, import_react_ui_theme5.mx)(classNames, "animate-[fadeIn_0.5s]")
|
|
1249
|
+
}, /* @__PURE__ */ import_react5.default.createElement(ToolBlock, {
|
|
1250
|
+
space,
|
|
1251
|
+
classNames: panelClassNames,
|
|
1252
|
+
message,
|
|
1253
|
+
tools
|
|
1254
|
+
}));
|
|
1255
|
+
}
|
|
1256
|
+
return content.map((block, idx) => {
|
|
1257
|
+
if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
1258
|
+
return null;
|
|
1259
|
+
}
|
|
1260
|
+
const Component = components[block.type] ?? components.default;
|
|
1261
|
+
return /* @__PURE__ */ import_react5.default.createElement(MessageContainer, {
|
|
1262
|
+
key: idx,
|
|
1263
|
+
classNames: (0, import_react_ui_theme5.mx)(classNames, "animate-[fadeIn_0.5s]"),
|
|
1264
|
+
user: block.type === "text" && role === "user"
|
|
1265
|
+
}, /* @__PURE__ */ import_react5.default.createElement(Component, {
|
|
1266
|
+
space,
|
|
1267
|
+
block,
|
|
1268
|
+
onPrompt,
|
|
1269
|
+
onAddToGraph
|
|
1270
|
+
}));
|
|
1271
|
+
});
|
|
1272
|
+
} finally {
|
|
1273
|
+
_effect.f();
|
|
1126
1274
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1275
|
+
};
|
|
1276
|
+
var components = {
|
|
1277
|
+
//
|
|
1278
|
+
// Text
|
|
1279
|
+
//
|
|
1280
|
+
["text"]: ({ block }) => {
|
|
1281
|
+
(0, import_invariant2.invariant)(block.type === "text", void 0, {
|
|
1282
|
+
F: __dxlog_file5,
|
|
1283
|
+
L: 105,
|
|
1284
|
+
S: void 0,
|
|
1285
|
+
A: [
|
|
1286
|
+
"block.type === 'text'",
|
|
1287
|
+
""
|
|
1288
|
+
]
|
|
1289
|
+
});
|
|
1290
|
+
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
1291
|
+
if (!title) {
|
|
1292
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
|
|
1293
|
+
classNames: "[&>p]:animate-[fadeIn_0.5s]",
|
|
1294
|
+
content: block.text
|
|
1138
1295
|
});
|
|
1139
1296
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1297
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
1298
|
+
// open={open}
|
|
1299
|
+
defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
|
|
1300
|
+
title,
|
|
1301
|
+
icon: block.pending ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Icon, {
|
|
1302
|
+
icon: "ph--circle-notch--regular",
|
|
1303
|
+
classNames: "text-subdued ml-2 animate-spin",
|
|
1304
|
+
size: 4
|
|
1305
|
+
}) : void 0
|
|
1306
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
|
|
1307
|
+
content: block.text,
|
|
1308
|
+
classNames: [
|
|
1309
|
+
"pbe-2",
|
|
1310
|
+
systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
|
|
1311
|
+
]
|
|
1312
|
+
}));
|
|
1313
|
+
},
|
|
1314
|
+
//
|
|
1315
|
+
// JSON
|
|
1316
|
+
//
|
|
1317
|
+
["json"]: ({ space, block, onPrompt, onAddToGraph }) => {
|
|
1318
|
+
(0, import_invariant2.invariant)(block.type === "json", void 0, {
|
|
1319
|
+
F: __dxlog_file5,
|
|
1320
|
+
L: 143,
|
|
1321
|
+
S: void 0,
|
|
1322
|
+
A: [
|
|
1323
|
+
"block.type === 'json'",
|
|
1324
|
+
""
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1327
|
+
switch (block.disposition) {
|
|
1328
|
+
case "tool_list": {
|
|
1329
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
1330
|
+
title: titles[block.disposition],
|
|
1331
|
+
defaultOpen: true
|
|
1332
|
+
}, /* @__PURE__ */ import_react5.default.createElement(ToolboxContainer, {
|
|
1333
|
+
space,
|
|
1334
|
+
classNames: "pbe-2"
|
|
1335
|
+
}));
|
|
1150
1336
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
const reference = match[0];
|
|
1158
|
-
const uri = reference.slice(1, -1);
|
|
1159
|
-
const data = await provider.resolveReference({
|
|
1160
|
-
uri
|
|
1337
|
+
case "suggest": {
|
|
1338
|
+
const { text = "" } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
|
|
1339
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.IconButton, {
|
|
1340
|
+
icon: "ph--lightning--regular",
|
|
1341
|
+
label: text,
|
|
1342
|
+
onClick: () => onPrompt?.(text)
|
|
1161
1343
|
});
|
|
1162
|
-
if (data) {
|
|
1163
|
-
decorations.push(import_view2.Decoration.replace({
|
|
1164
|
-
widget: new ReferenceWidget(data)
|
|
1165
|
-
}).range(match.index, match.index + reference.length));
|
|
1166
|
-
}
|
|
1167
1344
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1345
|
+
case "select": {
|
|
1346
|
+
const { options = [] } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
|
|
1347
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1348
|
+
className: "flex flex-wrap gap-1"
|
|
1349
|
+
}, options.map((option, idx) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Button, {
|
|
1350
|
+
classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
|
|
1351
|
+
key: option,
|
|
1352
|
+
onClick: () => onPrompt?.(option)
|
|
1353
|
+
}, option)));
|
|
1354
|
+
}
|
|
1355
|
+
case "graph": {
|
|
1356
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1357
|
+
className: "flex flex-wrap gap-1"
|
|
1358
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_app_framework2.Surface, {
|
|
1359
|
+
role: "card",
|
|
1360
|
+
data: {
|
|
1361
|
+
subject: JSON.parse(block.json ?? "{}")
|
|
1362
|
+
},
|
|
1363
|
+
limit: 1,
|
|
1364
|
+
fallback: /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1365
|
+
className: "font-mono text-xs text-pre"
|
|
1366
|
+
}, block.json)
|
|
1367
|
+
}), onAddToGraph && /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.IconButton, {
|
|
1368
|
+
icon: "ph--plus--regular",
|
|
1369
|
+
label: "Add to graph",
|
|
1370
|
+
onClick: () => onAddToGraph?.(JSON.parse(block.json ?? "{}"))
|
|
1371
|
+
}));
|
|
1184
1372
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
aboveCursor: true
|
|
1211
|
-
}),
|
|
1212
|
-
import_view2.keymap.of(import_autocomplete.completionKeymap)
|
|
1213
|
-
];
|
|
1214
|
-
};
|
|
1215
|
-
var ReferenceWidget = class extends import_view2.WidgetType {
|
|
1216
|
-
constructor(data) {
|
|
1217
|
-
super();
|
|
1218
|
-
this.data = data;
|
|
1219
|
-
}
|
|
1220
|
-
toDOM() {
|
|
1221
|
-
const span = document.createElement("span");
|
|
1222
|
-
span.textContent = `@ ${this.data.label}`;
|
|
1223
|
-
span.className = "cm-reference-pill";
|
|
1224
|
-
return span;
|
|
1225
|
-
}
|
|
1226
|
-
eq(other) {
|
|
1227
|
-
return other.data.uri === this.data.uri;
|
|
1228
|
-
}
|
|
1229
|
-
ignoreEvent() {
|
|
1230
|
-
return true;
|
|
1373
|
+
default: {
|
|
1374
|
+
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
1375
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
1376
|
+
title: title ?? "JSON"
|
|
1377
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
1378
|
+
data: (0, import_util4.safeParseJson)(block.json ?? block),
|
|
1379
|
+
classNames: "!p-1 text-xs"
|
|
1380
|
+
}));
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
//
|
|
1385
|
+
// Default
|
|
1386
|
+
//
|
|
1387
|
+
default: ({ block }) => {
|
|
1388
|
+
let title = titles[block.type];
|
|
1389
|
+
if (block.type === "tool_use") {
|
|
1390
|
+
title = `Tool [${block.name}]`;
|
|
1391
|
+
}
|
|
1392
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
1393
|
+
title: title ?? "JSON"
|
|
1394
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
1395
|
+
data: block,
|
|
1396
|
+
classNames: "!p-1 text-xs"
|
|
1397
|
+
}));
|
|
1231
1398
|
}
|
|
1232
1399
|
};
|
|
1233
|
-
var
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
preventDefault: true,
|
|
1266
|
-
run: (view2) => {
|
|
1267
|
-
onOpenChange?.(false);
|
|
1268
|
-
return true;
|
|
1269
|
-
}
|
|
1400
|
+
var titles = {
|
|
1401
|
+
["cot"]: "Chain of thought",
|
|
1402
|
+
["artifact"]: "Artifact",
|
|
1403
|
+
["tool_use"]: "Tool request",
|
|
1404
|
+
["tool_result"]: "Tool result",
|
|
1405
|
+
["tool_list"]: "Tools",
|
|
1406
|
+
["artifact-update"]: "Artifact(s) changed"
|
|
1407
|
+
};
|
|
1408
|
+
var systemDispositions = [
|
|
1409
|
+
"cot",
|
|
1410
|
+
"artifact-update"
|
|
1411
|
+
];
|
|
1412
|
+
var messageReducer = ({ current, messages }, message) => {
|
|
1413
|
+
let i = 0;
|
|
1414
|
+
for (const block of message.content) {
|
|
1415
|
+
switch (block.type) {
|
|
1416
|
+
case "tool_use":
|
|
1417
|
+
case "tool_result": {
|
|
1418
|
+
if (current) {
|
|
1419
|
+
current.content.push(block);
|
|
1420
|
+
} else {
|
|
1421
|
+
current = {
|
|
1422
|
+
id: [
|
|
1423
|
+
message.id,
|
|
1424
|
+
i
|
|
1425
|
+
].join("_"),
|
|
1426
|
+
role: message.role,
|
|
1427
|
+
content: [
|
|
1428
|
+
block
|
|
1429
|
+
]
|
|
1430
|
+
};
|
|
1431
|
+
messages.push(current);
|
|
1270
1432
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
changes: {
|
|
1286
|
-
from: 0,
|
|
1287
|
-
to: view.state.doc.length,
|
|
1288
|
-
insert: text
|
|
1289
|
-
},
|
|
1290
|
-
selection: {
|
|
1291
|
-
anchor: text.length,
|
|
1292
|
-
head: text.length
|
|
1293
|
-
}
|
|
1433
|
+
break;
|
|
1434
|
+
}
|
|
1435
|
+
case "text":
|
|
1436
|
+
default: {
|
|
1437
|
+
current = void 0;
|
|
1438
|
+
messages.push({
|
|
1439
|
+
id: [
|
|
1440
|
+
message.id,
|
|
1441
|
+
i
|
|
1442
|
+
].join("_"),
|
|
1443
|
+
role: message.role,
|
|
1444
|
+
content: [
|
|
1445
|
+
block
|
|
1446
|
+
]
|
|
1294
1447
|
});
|
|
1448
|
+
break;
|
|
1295
1449
|
}
|
|
1296
|
-
};
|
|
1297
|
-
}, [
|
|
1298
|
-
view,
|
|
1299
|
-
onSubmit
|
|
1300
|
-
]);
|
|
1301
|
-
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1302
|
-
ref: parentRef,
|
|
1303
|
-
className: (0, import_react_ui_theme4.mx)("w-full", classNames)
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1306
|
-
var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, references, ...props }) => {
|
|
1307
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_Q5XWEMHB.ASSISTANT_PLUGIN);
|
|
1308
|
-
const promptRef = (0, import_react6.useRef)(null);
|
|
1309
|
-
const [active, setActive] = (0, import_react6.useState)(false);
|
|
1310
|
-
const { recording } = (0, import_plugin_transcription.useVoiceInput)({
|
|
1311
|
-
active,
|
|
1312
|
-
onUpdate: (text) => {
|
|
1313
|
-
promptRef.current?.setText(text);
|
|
1314
|
-
promptRef.current?.focus();
|
|
1315
1450
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
delayDuration: 0
|
|
1323
|
-
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Icon, {
|
|
1324
|
-
icon: "ph--warning-circle--regular",
|
|
1325
|
-
classNames: import_react_ui_theme5.errorText,
|
|
1326
|
-
size: 5
|
|
1327
|
-
})), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, null, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1328
|
-
className: (0, import_react_ui_theme5.mx)("text-sm", import_react_ui_theme5.errorMessageColors)
|
|
1329
|
-
}, error.message), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null)))) || /* @__PURE__ */ import_react6.default.createElement(import_react_ui_sfx.Spinner, {
|
|
1330
|
-
active: processing
|
|
1331
|
-
})), /* @__PURE__ */ import_react6.default.createElement(Prompt, {
|
|
1332
|
-
ref: promptRef,
|
|
1333
|
-
autoFocus: true,
|
|
1334
|
-
classNames: "pbs-2",
|
|
1335
|
-
lineWrapping: true,
|
|
1336
|
-
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1337
|
-
references,
|
|
1338
|
-
...props
|
|
1339
|
-
}), (onCancel || microphone) && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1340
|
-
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
1341
|
-
}, processing && onCancel && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
|
|
1342
|
-
classNames: "px-1.5",
|
|
1343
|
-
variant: "ghost",
|
|
1344
|
-
size: 5,
|
|
1345
|
-
icon: "ph--x--regular",
|
|
1346
|
-
iconOnly: true,
|
|
1347
|
-
label: t("cancel processing button"),
|
|
1348
|
-
onClick: onCancel
|
|
1349
|
-
}), !processing && microphone && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
|
|
1350
|
-
classNames: (0, import_react_ui_theme5.mx)("px-1.5", recording && "bg-primary-500"),
|
|
1351
|
-
variant: "ghost",
|
|
1352
|
-
size: 5,
|
|
1353
|
-
icon: "ph--microphone--regular",
|
|
1354
|
-
iconOnly: true,
|
|
1355
|
-
noTooltip: true,
|
|
1356
|
-
label: t("microphone button"),
|
|
1357
|
-
onMouseDown: () => setActive(true),
|
|
1358
|
-
onMouseUp: () => setActive(false),
|
|
1359
|
-
onTouchStart: () => setActive(true),
|
|
1360
|
-
onTouchEnd: () => setActive(false)
|
|
1361
|
-
})));
|
|
1451
|
+
i++;
|
|
1452
|
+
}
|
|
1453
|
+
return {
|
|
1454
|
+
current,
|
|
1455
|
+
messages
|
|
1456
|
+
};
|
|
1362
1457
|
};
|
|
1363
1458
|
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1459
|
+
var _effect = (0, import_tracking4.useSignals)();
|
|
1460
|
+
try {
|
|
1461
|
+
const scroller = (0, import_react4.useRef)(null);
|
|
1462
|
+
const identity = (0, import_halo.useIdentity)();
|
|
1463
|
+
const fallbackValue = (0, import_util3.keyToFallback)(identity.identityKey);
|
|
1464
|
+
const userHue = identity.profile?.data?.hue || fallbackValue.hue;
|
|
1465
|
+
const handleSubmit = (0, import_react4.useCallback)((value) => {
|
|
1466
|
+
onSubmit?.(value);
|
|
1467
|
+
scroller.current?.scrollToBottom();
|
|
1468
|
+
return true;
|
|
1469
|
+
}, [
|
|
1470
|
+
onSubmit
|
|
1471
|
+
]);
|
|
1472
|
+
const { messages: filteredMessages = [] } = (0, import_react4.useMemo)(() => {
|
|
1473
|
+
if (collapse) {
|
|
1474
|
+
return (messages ?? []).reduce(messageReducer, {
|
|
1475
|
+
messages: []
|
|
1476
|
+
});
|
|
1477
|
+
} else {
|
|
1478
|
+
return {
|
|
1479
|
+
messages: messages ?? []
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
}, [
|
|
1483
|
+
messages,
|
|
1484
|
+
collapse
|
|
1485
|
+
]);
|
|
1486
|
+
const references = (0, import_react4.useMemo)(() => {
|
|
1487
|
+
if (!contextProvider) {
|
|
1488
|
+
return void 0;
|
|
1489
|
+
}
|
|
1381
1490
|
return {
|
|
1382
|
-
|
|
1491
|
+
getReferences: async ({ query }) => contextProvider.query({
|
|
1492
|
+
query
|
|
1493
|
+
}),
|
|
1494
|
+
resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
|
|
1495
|
+
uri
|
|
1496
|
+
})
|
|
1383
1497
|
};
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
key: message.id,
|
|
1418
|
-
classNames: "px-4 pbe-4",
|
|
1419
|
-
space,
|
|
1420
|
-
message,
|
|
1421
|
-
...props
|
|
1422
|
-
})))), onSubmit && /* @__PURE__ */ import_react2.default.createElement(PromptBar, {
|
|
1423
|
-
microphone: transcription,
|
|
1424
|
-
processing,
|
|
1425
|
-
error,
|
|
1426
|
-
onSubmit: handleSubmit,
|
|
1427
|
-
onCancel,
|
|
1428
|
-
onOpenChange,
|
|
1429
|
-
references
|
|
1430
|
-
}));
|
|
1498
|
+
}, [
|
|
1499
|
+
contextProvider
|
|
1500
|
+
]);
|
|
1501
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
1502
|
+
role: "none",
|
|
1503
|
+
className: (0, import_react_ui_theme4.mx)("flex flex-col grow overflow-hidden", classNames)
|
|
1504
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_components.ScrollContainer, {
|
|
1505
|
+
ref: scroller,
|
|
1506
|
+
fade: true
|
|
1507
|
+
}, /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
1508
|
+
role: "none",
|
|
1509
|
+
className: (0, import_react_ui_theme4.mx)(filteredMessages.length > 0 && "pbs-6 pbe-6"),
|
|
1510
|
+
style: {
|
|
1511
|
+
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1512
|
+
}
|
|
1513
|
+
}, filteredMessages.map((message) => /* @__PURE__ */ import_react4.default.createElement(ThreadMessage, {
|
|
1514
|
+
key: message.id,
|
|
1515
|
+
classNames: "px-4 pbe-4",
|
|
1516
|
+
space,
|
|
1517
|
+
message,
|
|
1518
|
+
...props
|
|
1519
|
+
})))), onSubmit && /* @__PURE__ */ import_react4.default.createElement(PromptBar, {
|
|
1520
|
+
microphone: transcription,
|
|
1521
|
+
processing,
|
|
1522
|
+
error,
|
|
1523
|
+
onSubmit: handleSubmit,
|
|
1524
|
+
onCancel,
|
|
1525
|
+
onOpenChange,
|
|
1526
|
+
references
|
|
1527
|
+
}));
|
|
1528
|
+
} finally {
|
|
1529
|
+
_effect.f();
|
|
1530
|
+
}
|
|
1431
1531
|
};
|
|
1432
1532
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/processor.ts";
|
|
1433
1533
|
var defaultOptions = {
|
|
1434
|
-
model:
|
|
1534
|
+
model: import_ai4.DEFAULT_EDGE_MODEL,
|
|
1435
1535
|
systemPrompt: "you are a helpful assistant"
|
|
1436
1536
|
};
|
|
1437
1537
|
var ChatProcessor = class {
|
|
@@ -1453,7 +1553,7 @@ var ChatProcessor = class {
|
|
|
1453
1553
|
const current = messages.pop();
|
|
1454
1554
|
(0, import_invariant4.invariant)(current, void 0, {
|
|
1455
1555
|
F: __dxlog_file6,
|
|
1456
|
-
L:
|
|
1556
|
+
L: 79,
|
|
1457
1557
|
S: this,
|
|
1458
1558
|
A: [
|
|
1459
1559
|
"current",
|
|
@@ -1472,6 +1572,24 @@ var ChatProcessor = class {
|
|
|
1472
1572
|
}
|
|
1473
1573
|
return messages;
|
|
1474
1574
|
});
|
|
1575
|
+
this._artifactDiffResolver = async (artifacts) => {
|
|
1576
|
+
const space = this._extensions?.space;
|
|
1577
|
+
if (!space) {
|
|
1578
|
+
return /* @__PURE__ */ new Map();
|
|
1579
|
+
}
|
|
1580
|
+
const versions = /* @__PURE__ */ new Map();
|
|
1581
|
+
await Promise.all(artifacts.map(async (artifact) => {
|
|
1582
|
+
const { objects: [object] } = await space.db.query(import_echo4.Filter.ids(artifact.id)).run();
|
|
1583
|
+
if (!object) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
versions.set(artifact.id, {
|
|
1587
|
+
version: (0, import_echo4.getVersion)(object),
|
|
1588
|
+
diff: `Current state: ${JSON.stringify(object)}`
|
|
1589
|
+
});
|
|
1590
|
+
}));
|
|
1591
|
+
return versions;
|
|
1592
|
+
};
|
|
1475
1593
|
}
|
|
1476
1594
|
get tools() {
|
|
1477
1595
|
return this._tools;
|
|
@@ -1487,7 +1605,7 @@ var ChatProcessor = class {
|
|
|
1487
1605
|
*/
|
|
1488
1606
|
async request(message, options = {}) {
|
|
1489
1607
|
this._session = new import_assistant.AISession({
|
|
1490
|
-
operationModel: "
|
|
1608
|
+
operationModel: "configured"
|
|
1491
1609
|
});
|
|
1492
1610
|
this._session.message.on((message2) => {
|
|
1493
1611
|
(0, import_signals_core.batch)(() => {
|
|
@@ -1509,24 +1627,55 @@ var ChatProcessor = class {
|
|
|
1509
1627
|
message2
|
|
1510
1628
|
];
|
|
1511
1629
|
});
|
|
1630
|
+
this._session.toolStatusReport.on(({ message: message2, status }) => {
|
|
1631
|
+
const msg = this._pending.peek().find((m) => m.id === message2.id);
|
|
1632
|
+
const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
|
|
1633
|
+
if (!toolUse) {
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
|
|
1637
|
+
if (block) {
|
|
1638
|
+
this._pending.value = this._pending.value.map((m) => {
|
|
1639
|
+
if (m.id === message2.id) {
|
|
1640
|
+
return {
|
|
1641
|
+
...m,
|
|
1642
|
+
content: m.content.map((b) => b.type === "tool_use" && b.id === toolUse.id ? {
|
|
1643
|
+
...b,
|
|
1644
|
+
currentStatus: status
|
|
1645
|
+
} : b)
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
return m;
|
|
1649
|
+
});
|
|
1650
|
+
} else {
|
|
1651
|
+
import_log6.log.warn("no block for status report", void 0, {
|
|
1652
|
+
F: __dxlog_file6,
|
|
1653
|
+
L: 155,
|
|
1654
|
+
S: this,
|
|
1655
|
+
C: (f, a) => f(...a)
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1512
1659
|
try {
|
|
1513
1660
|
const messages = await this._session.run({
|
|
1514
1661
|
client: this._ai,
|
|
1515
1662
|
history: options.history ?? [],
|
|
1516
1663
|
artifacts: this._artifacts ?? [],
|
|
1664
|
+
requiredArtifactIds: this._artifacts?.map((artifact) => artifact.id) ?? [],
|
|
1517
1665
|
tools: this._tools ?? [],
|
|
1518
1666
|
prompt: message,
|
|
1519
1667
|
systemPrompt: this._options.systemPrompt,
|
|
1520
1668
|
extensions: this._extensions,
|
|
1669
|
+
artifactDiffResolver: this._artifactDiffResolver,
|
|
1521
1670
|
generationOptions: {
|
|
1522
1671
|
model: this._options.model
|
|
1523
1672
|
}
|
|
1524
1673
|
});
|
|
1525
|
-
import_log6.log
|
|
1674
|
+
(0, import_log6.log)("completed", {
|
|
1526
1675
|
messages
|
|
1527
1676
|
}, {
|
|
1528
1677
|
F: __dxlog_file6,
|
|
1529
|
-
L:
|
|
1678
|
+
L: 175,
|
|
1530
1679
|
S: this,
|
|
1531
1680
|
C: (f, a) => f(...a)
|
|
1532
1681
|
});
|
|
@@ -1534,7 +1683,7 @@ var ChatProcessor = class {
|
|
|
1534
1683
|
} catch (err) {
|
|
1535
1684
|
import_log6.log.catch(err, void 0, {
|
|
1536
1685
|
F: __dxlog_file6,
|
|
1537
|
-
L:
|
|
1686
|
+
L: 178,
|
|
1538
1687
|
S: this,
|
|
1539
1688
|
C: (f, a) => f(...a)
|
|
1540
1689
|
});
|
|
@@ -1559,7 +1708,7 @@ var ChatProcessor = class {
|
|
|
1559
1708
|
async cancel() {
|
|
1560
1709
|
import_log6.log.info("cancelling...", void 0, {
|
|
1561
1710
|
F: __dxlog_file6,
|
|
1562
|
-
L:
|
|
1711
|
+
L: 196,
|
|
1563
1712
|
S: this,
|
|
1564
1713
|
C: (f, a) => f(...a)
|
|
1565
1714
|
});
|
|
@@ -1581,120 +1730,123 @@ var AIServiceOverloadedError = class extends Error {
|
|
|
1581
1730
|
this.code = "AI_SERVICE_OVERLOADED";
|
|
1582
1731
|
}
|
|
1583
1732
|
};
|
|
1584
|
-
var AiClient = (0,
|
|
1585
|
-
var AppGraphBuilder = (0,
|
|
1586
|
-
var IntentResolver = (0,
|
|
1587
|
-
var ReactSurface = (0,
|
|
1588
|
-
var
|
|
1733
|
+
var AiClient = (0, import_app_framework5.lazy)(() => import("./ai-client-R2CGEYZW.cjs"));
|
|
1734
|
+
var AppGraphBuilder = (0, import_app_framework5.lazy)(() => import("./app-graph-builder-PSHIOW3Q.cjs"));
|
|
1735
|
+
var IntentResolver = (0, import_app_framework5.lazy)(() => import("./intent-resolver-66F7WLW6.cjs"));
|
|
1736
|
+
var ReactSurface = (0, import_app_framework5.lazy)(() => import("./react-surface-TASAPRPQ.cjs"));
|
|
1737
|
+
var Settings = (0, import_app_framework5.lazy)(() => import("./settings-ERKLO6IO.cjs"));
|
|
1589
1738
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
|
|
1590
|
-
var useChatProcessor = ({
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
});
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1739
|
+
var useChatProcessor = ({
|
|
1740
|
+
chat,
|
|
1741
|
+
space,
|
|
1742
|
+
settings,
|
|
1743
|
+
// part = 'deck',
|
|
1744
|
+
part,
|
|
1745
|
+
associatedArtifact
|
|
1746
|
+
}) => {
|
|
1747
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
1748
|
+
try {
|
|
1749
|
+
const aiClient = (0, import_app_framework4.useCapability)(import_chunk_TS3H5OSX.AssistantCapabilities.AiClient);
|
|
1750
|
+
const globalTools = (0, import_app_framework4.useCapabilities)(import_app_framework4.Capabilities.Tools);
|
|
1751
|
+
const artifactDefinitions = (0, import_app_framework4.useCapabilities)(import_app_framework4.Capabilities.ArtifactDefinition);
|
|
1752
|
+
const { dispatchPromise: dispatch } = (0, import_app_framework4.useIntentDispatcher)();
|
|
1753
|
+
const services = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_chunk_RXPA2C2A.ServiceType));
|
|
1754
|
+
const [serviceTools, setServiceTools] = (0, import_react8.useState)([]);
|
|
1755
|
+
(0, import_react8.useEffect)(() => {
|
|
1756
|
+
(0, import_log7.log)("creating service tools...", void 0, {
|
|
1757
|
+
F: __dxlog_file7,
|
|
1758
|
+
L: 49,
|
|
1759
|
+
S: void 0,
|
|
1760
|
+
C: (f, a) => f(...a)
|
|
1761
|
+
});
|
|
1762
|
+
queueMicrotask(async () => {
|
|
1763
|
+
const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
1764
|
+
setServiceTools(tools2.flat());
|
|
1765
|
+
});
|
|
1766
|
+
}, [
|
|
1767
|
+
services
|
|
1768
|
+
]);
|
|
1769
|
+
const config = (0, import_react_client.useConfig)();
|
|
1770
|
+
const functions = (0, import_echo5.useQuery)(space, import_echo5.Filter.type(import_functions3.FunctionType));
|
|
1771
|
+
const chatId = (0, import_react8.useMemo)(() => chat ? (0, import_echo5.fullyQualifiedId)(chat) : void 0, [
|
|
1772
|
+
chat
|
|
1773
|
+
]);
|
|
1774
|
+
const [tools, extensions] = (0, import_react8.useMemo)(() => {
|
|
1775
|
+
(0, import_log7.log)("creating tools...", void 0, {
|
|
1776
|
+
F: __dxlog_file7,
|
|
1777
|
+
L: 61,
|
|
1778
|
+
S: void 0,
|
|
1779
|
+
C: (f, a) => f(...a)
|
|
1780
|
+
});
|
|
1781
|
+
const tools2 = [
|
|
1782
|
+
...globalTools.flat(),
|
|
1783
|
+
...serviceTools,
|
|
1784
|
+
...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(import_util6.isNonNullable)
|
|
1785
|
+
];
|
|
1786
|
+
const extensions2 = {
|
|
1787
|
+
space,
|
|
1788
|
+
dispatch,
|
|
1789
|
+
pivotId: chatId,
|
|
1790
|
+
part
|
|
1791
|
+
};
|
|
1792
|
+
return [
|
|
1793
|
+
tools2,
|
|
1794
|
+
extensions2
|
|
1795
|
+
];
|
|
1796
|
+
}, [
|
|
1630
1797
|
dispatch,
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
dispatch,
|
|
1640
|
-
globalTools,
|
|
1641
|
-
space,
|
|
1642
|
-
chatId,
|
|
1643
|
-
serviceTools,
|
|
1644
|
-
functions
|
|
1645
|
-
]);
|
|
1646
|
-
const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact4.createSystemPrompt)({
|
|
1647
|
-
artifacts: artifactDefinitions.map((definition) => `${definition.name}
|
|
1798
|
+
globalTools,
|
|
1799
|
+
space,
|
|
1800
|
+
chatId,
|
|
1801
|
+
serviceTools,
|
|
1802
|
+
functions
|
|
1803
|
+
]);
|
|
1804
|
+
const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact.createSystemPrompt)({
|
|
1805
|
+
artifacts: artifactDefinitions.map((definition) => `${definition.name}
|
|
1648
1806
|
${definition.instructions}`),
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1807
|
+
associatedArtifact
|
|
1808
|
+
}), [
|
|
1809
|
+
artifactDefinitions,
|
|
1810
|
+
associatedArtifact
|
|
1811
|
+
]);
|
|
1812
|
+
const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? import_ai5.DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? import_ai5.DEFAULT_EDGE_MODEL;
|
|
1813
|
+
const processor = (0, import_react8.useMemo)(() => {
|
|
1814
|
+
(0, import_log7.log)("creating processor...", {
|
|
1815
|
+
settings
|
|
1816
|
+
}, {
|
|
1817
|
+
F: __dxlog_file7,
|
|
1818
|
+
L: 92,
|
|
1819
|
+
S: void 0,
|
|
1820
|
+
C: (f, a) => f(...a)
|
|
1821
|
+
});
|
|
1822
|
+
return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
|
|
1823
|
+
model,
|
|
1824
|
+
systemPrompt
|
|
1825
|
+
});
|
|
1826
|
+
}, [
|
|
1827
|
+
aiClient.value,
|
|
1828
|
+
tools,
|
|
1829
|
+
artifactDefinitions,
|
|
1830
|
+
extensions,
|
|
1665
1831
|
model,
|
|
1666
1832
|
systemPrompt
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
model,
|
|
1673
|
-
systemPrompt
|
|
1674
|
-
]);
|
|
1675
|
-
return processor;
|
|
1833
|
+
]);
|
|
1834
|
+
return processor;
|
|
1835
|
+
} finally {
|
|
1836
|
+
_effect.f();
|
|
1837
|
+
}
|
|
1676
1838
|
};
|
|
1677
|
-
var registerTriggersMutex = new import_async2.Mutex();
|
|
1678
1839
|
var useMessageQueue = (chat) => {
|
|
1679
1840
|
const space = (0, import_echo6.getSpace)(chat);
|
|
1680
|
-
const queueDxn = (0,
|
|
1681
|
-
const dxn = space && chat?.
|
|
1682
|
-
return dxn ?
|
|
1683
|
-
import_keys2.QueueSubspaceTags.DATA,
|
|
1684
|
-
space.id,
|
|
1685
|
-
dxn.parts.at(-1)
|
|
1686
|
-
]) : void 0;
|
|
1841
|
+
const queueDxn = (0, import_react9.useMemo)(() => {
|
|
1842
|
+
const dxn = space && chat?.queue.dxn;
|
|
1843
|
+
return dxn ? (0, import_echo_schema3.createQueueDxn)(space.id, dxn.parts.at(-1)) : void 0;
|
|
1687
1844
|
}, [
|
|
1688
1845
|
space,
|
|
1689
|
-
chat?.
|
|
1846
|
+
chat?.queue.dxn
|
|
1690
1847
|
]);
|
|
1691
1848
|
return (0, import_echo6.useQueue)(queueDxn);
|
|
1692
1849
|
};
|
|
1693
|
-
var MockServiceRegistry = class {
|
|
1694
|
-
async queryServices(query) {
|
|
1695
|
-
return TEST_SERVICES;
|
|
1696
|
-
}
|
|
1697
|
-
};
|
|
1698
1850
|
var AMADEUS_AUTH = {
|
|
1699
1851
|
type: "oauth",
|
|
1700
1852
|
clientId: "BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG",
|
|
@@ -1711,7 +1863,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
|
|
|
1711
1863
|
}
|
|
1712
1864
|
};
|
|
1713
1865
|
var TEST_SERVICES = [
|
|
1714
|
-
(0,
|
|
1866
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1715
1867
|
serviceId: "amadeus.com/service/FlightSearch",
|
|
1716
1868
|
name: "Amadeus Flight Search",
|
|
1717
1869
|
description: "Search for local and international flights.",
|
|
@@ -1724,7 +1876,7 @@ var TEST_SERVICES = [
|
|
|
1724
1876
|
}
|
|
1725
1877
|
]
|
|
1726
1878
|
}),
|
|
1727
|
-
(0,
|
|
1879
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1728
1880
|
serviceId: "amadeus.com/service/HotelSearch",
|
|
1729
1881
|
name: "Amadeus Hotel Search",
|
|
1730
1882
|
description: "Search for local and international hotels.",
|
|
@@ -1737,7 +1889,7 @@ var TEST_SERVICES = [
|
|
|
1737
1889
|
}
|
|
1738
1890
|
]
|
|
1739
1891
|
}),
|
|
1740
|
-
(0,
|
|
1892
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1741
1893
|
serviceId: "visualcrossing.com/service/Weather",
|
|
1742
1894
|
name: "Visual Crossing Weather",
|
|
1743
1895
|
description: "Search for global weather forecasts.",
|
|
@@ -1751,7 +1903,7 @@ var TEST_SERVICES = [
|
|
|
1751
1903
|
]
|
|
1752
1904
|
}),
|
|
1753
1905
|
// TODO(burdon): Needs auth.
|
|
1754
|
-
(0,
|
|
1906
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1755
1907
|
serviceId: "abstractapi.com/service/GeoLocation",
|
|
1756
1908
|
name: "Abstract GeoLocation",
|
|
1757
1909
|
description: "Get the location of any IP address.",
|
|
@@ -1768,11 +1920,11 @@ var TEST_SERVICES = [
|
|
|
1768
1920
|
//
|
|
1769
1921
|
...Array.from({
|
|
1770
1922
|
length: 20
|
|
1771
|
-
}, (_, i) => (0,
|
|
1923
|
+
}, (_, i) => (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1772
1924
|
serviceId: `example.com/service/test-${i}`,
|
|
1773
1925
|
name: `Test ${i}`,
|
|
1774
1926
|
description: `Test ${i}`,
|
|
1775
|
-
category: Object.keys(
|
|
1927
|
+
category: Object.keys(import_chunk_RXPA2C2A.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_RXPA2C2A.categoryIcons).length)],
|
|
1776
1928
|
interfaces: [
|
|
1777
1929
|
{
|
|
1778
1930
|
kind: "api",
|
|
@@ -1781,56 +1933,39 @@ var TEST_SERVICES = [
|
|
|
1781
1933
|
]
|
|
1782
1934
|
}))
|
|
1783
1935
|
];
|
|
1784
|
-
var useServices = (space, query) => {
|
|
1785
|
-
const registry = (0, import_react11.useMemo)(() => new MockServiceRegistry(), []);
|
|
1786
|
-
const [services, setServices] = (0, import_react11.useState)([]);
|
|
1787
|
-
(0, import_react11.useEffect)(() => {
|
|
1788
|
-
const t = setTimeout(async () => {
|
|
1789
|
-
const services2 = await registry.queryServices(query);
|
|
1790
|
-
setServices(services2);
|
|
1791
|
-
});
|
|
1792
|
-
return () => clearTimeout(t);
|
|
1793
|
-
}, [
|
|
1794
|
-
query,
|
|
1795
|
-
registry
|
|
1796
|
-
]);
|
|
1797
|
-
return services;
|
|
1798
|
-
};
|
|
1799
1936
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts";
|
|
1800
1937
|
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
1801
1938
|
var useContextProvider = (space) => {
|
|
1802
|
-
const artifactDefinitions = (0,
|
|
1803
|
-
return (0,
|
|
1939
|
+
const artifactDefinitions = (0, import_app_framework6.useCapabilities)(import_app_framework6.Capabilities.ArtifactDefinition);
|
|
1940
|
+
return (0, import_react12.useMemo)(() => {
|
|
1804
1941
|
if (!space) {
|
|
1805
1942
|
return void 0;
|
|
1806
1943
|
}
|
|
1807
1944
|
return {
|
|
1808
1945
|
query: async ({ query }) => {
|
|
1809
1946
|
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
1810
|
-
const { objects } = await space.db.query(import_echo7.Filter.or(...artifactSchemas.map((schema) => import_echo7.Filter.
|
|
1947
|
+
const { objects } = await space.db.query(import_echo7.Filter.or(...artifactSchemas.map((schema) => import_echo7.Filter.type(schema)))).run();
|
|
1811
1948
|
return objects.map((object) => {
|
|
1812
|
-
|
|
1949
|
+
import_log8.log.info("object", {
|
|
1813
1950
|
object,
|
|
1814
|
-
label: (0,
|
|
1951
|
+
label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object)
|
|
1815
1952
|
}, {
|
|
1816
1953
|
F: __dxlog_file8,
|
|
1817
|
-
L:
|
|
1954
|
+
L: 38,
|
|
1818
1955
|
S: void 0,
|
|
1819
1956
|
C: (f, a) => f(...a)
|
|
1820
1957
|
});
|
|
1821
1958
|
return object;
|
|
1822
|
-
}).filter((object) => stringMatch(query, (0,
|
|
1823
|
-
uri: (0,
|
|
1824
|
-
label: (0,
|
|
1959
|
+
}).filter((object) => stringMatch(query, (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? "")).filter((object) => !!(0, import_echo_schema5.getDXN)(object)).map((object) => ({
|
|
1960
|
+
uri: (0, import_echo_schema5.getDXN)(object).toString(),
|
|
1961
|
+
label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? ""
|
|
1825
1962
|
}));
|
|
1826
1963
|
},
|
|
1827
1964
|
resolveMetadata: async ({ uri }) => {
|
|
1828
|
-
const object = await space.db.query(
|
|
1829
|
-
id: uri
|
|
1830
|
-
}).first();
|
|
1965
|
+
const object = await space.db.query(import_echo7.Filter.ids(uri)).first();
|
|
1831
1966
|
return {
|
|
1832
1967
|
uri,
|
|
1833
|
-
label: (0,
|
|
1968
|
+
label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? ""
|
|
1834
1969
|
};
|
|
1835
1970
|
}
|
|
1836
1971
|
};
|
|
@@ -1841,85 +1976,111 @@ var useContextProvider = (space) => {
|
|
|
1841
1976
|
};
|
|
1842
1977
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
|
|
1843
1978
|
var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, onOpenChange, ...props }) => {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1979
|
+
var _effect = (0, import_tracking7.useSignals)();
|
|
1980
|
+
try {
|
|
1981
|
+
const space = (0, import_echo3.getSpace)(chat);
|
|
1982
|
+
const contextProvider = useContextProvider(space);
|
|
1983
|
+
const processor = useChatProcessor({
|
|
1984
|
+
chat,
|
|
1985
|
+
space,
|
|
1986
|
+
settings,
|
|
1987
|
+
part,
|
|
1988
|
+
associatedArtifact
|
|
1989
|
+
});
|
|
1990
|
+
const messageQueue = useMessageQueue(chat);
|
|
1991
|
+
const { dispatchPromise: dispatch } = (0, import_app_framework3.useIntentDispatcher)();
|
|
1992
|
+
const messages = [
|
|
1993
|
+
...messageQueue?.objects ?? [],
|
|
1994
|
+
...processor.messages.value
|
|
1995
|
+
];
|
|
1996
|
+
(0, import_react7.useEffect)(() => {
|
|
1997
|
+
if (!processor.streaming.value && messageQueue?.objects) {
|
|
1998
|
+
const message = messageQueue.objects[messageQueue.objects.length - 1];
|
|
1999
|
+
if (space && chat && message && dispatch && associatedArtifact) {
|
|
2000
|
+
void dispatch((0, import_app_framework3.createIntent)(import_app_framework3.CollaborationActions.InsertContent, {
|
|
2001
|
+
target: associatedArtifact,
|
|
2002
|
+
object: (0, import_live_object.refFromDXN)(new import_keys.DXN(import_keys.DXN.kind.QUEUE, [
|
|
2003
|
+
...chat.queue.dxn.parts,
|
|
2004
|
+
message.id
|
|
2005
|
+
])),
|
|
2006
|
+
label: "View proposal"
|
|
2007
|
+
}));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}, [
|
|
2011
|
+
messageQueue,
|
|
2012
|
+
associatedArtifact,
|
|
2013
|
+
processor.streaming.value
|
|
2014
|
+
]);
|
|
2015
|
+
const handleSubmit = (0, import_react7.useCallback)((text) => {
|
|
2016
|
+
if (processor.streaming.value) {
|
|
2017
|
+
import_log5.log.warn("ignoring submit; still processing.", void 0, {
|
|
2018
|
+
F: __dxlog_file9,
|
|
2019
|
+
L: 65,
|
|
2020
|
+
S: void 0,
|
|
2021
|
+
C: (f, a) => f(...a)
|
|
2022
|
+
});
|
|
2023
|
+
return false;
|
|
2024
|
+
}
|
|
2025
|
+
onOpenChange?.(true);
|
|
2026
|
+
(0, import_invariant3.invariant)(messageQueue, void 0, {
|
|
1861
2027
|
F: __dxlog_file9,
|
|
1862
|
-
L:
|
|
2028
|
+
L: 71,
|
|
1863
2029
|
S: void 0,
|
|
1864
|
-
|
|
2030
|
+
A: [
|
|
2031
|
+
"messageQueue",
|
|
2032
|
+
""
|
|
2033
|
+
]
|
|
1865
2034
|
});
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
messageQueue.append(messages2);
|
|
2035
|
+
void processor.request(text, {
|
|
2036
|
+
history: messageQueue.objects,
|
|
2037
|
+
onComplete: (messages2) => {
|
|
2038
|
+
messageQueue.append(messages2);
|
|
2039
|
+
}
|
|
2040
|
+
});
|
|
2041
|
+
return true;
|
|
2042
|
+
}, [
|
|
2043
|
+
processor,
|
|
2044
|
+
messageQueue,
|
|
2045
|
+
onOpenChange
|
|
2046
|
+
]);
|
|
2047
|
+
const handleCancel = (0, import_react7.useCallback)(() => {
|
|
2048
|
+
if (processor.streaming.value) {
|
|
2049
|
+
void processor.cancel();
|
|
1882
2050
|
}
|
|
2051
|
+
}, [
|
|
2052
|
+
processor
|
|
2053
|
+
]);
|
|
2054
|
+
return /* @__PURE__ */ import_react7.default.createElement(Thread, {
|
|
2055
|
+
classNames,
|
|
2056
|
+
space,
|
|
2057
|
+
messages,
|
|
2058
|
+
processing: processor.streaming.value,
|
|
2059
|
+
error: processor.error.value,
|
|
2060
|
+
tools: processor.tools,
|
|
2061
|
+
contextProvider,
|
|
2062
|
+
onSubmit: handleSubmit,
|
|
2063
|
+
onCancel: handleCancel,
|
|
2064
|
+
onPrompt: handleSubmit,
|
|
2065
|
+
onOpenChange,
|
|
2066
|
+
...props
|
|
1883
2067
|
});
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
messageQueue,
|
|
1888
|
-
onOpenChange
|
|
1889
|
-
]);
|
|
1890
|
-
const handleCancel = (0, import_react7.useCallback)(() => {
|
|
1891
|
-
if (processor.streaming.value) {
|
|
1892
|
-
void processor.cancel();
|
|
1893
|
-
}
|
|
1894
|
-
}, [
|
|
1895
|
-
processor
|
|
1896
|
-
]);
|
|
1897
|
-
return /* @__PURE__ */ import_react7.default.createElement(Thread, {
|
|
1898
|
-
classNames,
|
|
1899
|
-
space,
|
|
1900
|
-
messages,
|
|
1901
|
-
processing: processor.streaming.value,
|
|
1902
|
-
error: processor.error.value,
|
|
1903
|
-
tools: processor.tools,
|
|
1904
|
-
onSubmit: handleSubmit,
|
|
1905
|
-
onCancel: handleCancel,
|
|
1906
|
-
onPrompt: handleSubmit,
|
|
1907
|
-
onOpenChange,
|
|
1908
|
-
contextProvider,
|
|
1909
|
-
...props
|
|
1910
|
-
});
|
|
2068
|
+
} finally {
|
|
2069
|
+
_effect.f();
|
|
2070
|
+
}
|
|
1911
2071
|
};
|
|
1912
2072
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1913
2073
|
0 && (module.exports = {
|
|
1914
2074
|
AiClient,
|
|
1915
2075
|
AppGraphBuilder,
|
|
1916
|
-
AssistantSettings,
|
|
1917
2076
|
IntentResolver,
|
|
2077
|
+
Prompt,
|
|
2078
|
+
PromptBar,
|
|
1918
2079
|
ReactSurface,
|
|
2080
|
+
Settings,
|
|
1919
2081
|
Thread,
|
|
1920
2082
|
ThreadContainer,
|
|
1921
2083
|
Toolbox,
|
|
1922
|
-
ToolboxContainer
|
|
1923
|
-
useServices
|
|
2084
|
+
ToolboxContainer
|
|
1924
2085
|
});
|
|
1925
|
-
//# sourceMappingURL=chunk-
|
|
2086
|
+
//# sourceMappingURL=chunk-H4A42LNR.cjs.map
|