@dxos/plugin-assistant 0.8.2-main.f11618f → 0.8.2-staging.42af850
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AssistantDialog-K6POM23O.mjs +46 -0
- package/dist/lib/browser/AssistantDialog-K6POM23O.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-QTO4LE2C.mjs +39 -0
- package/dist/lib/{node-esm/ChatContainer-XPNXNPSW.mjs.map → browser/ChatContainer-QTO4LE2C.mjs.map} +1 -1
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs +28 -0
- package/dist/lib/{node-esm/TemplateContainer-3LEBT5ZC.mjs.map → browser/TemplateContainer-AKUYL4AV.mjs.map} +1 -1
- package/dist/lib/browser/{ai-client-OK5SMYJC.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-7CAHKTZQ.mjs → chunk-QTW7KVDO.mjs} +1665 -1547
- package/dist/lib/browser/chunk-QTW7KVDO.mjs.map +7 -0
- package/dist/lib/browser/chunk-USJBRB3H.mjs +155 -0
- package/dist/lib/browser/chunk-USJBRB3H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3HCI5FIL.mjs → chunk-XOZ7YMO3.mjs} +3 -3
- package/dist/lib/browser/{chunk-3HCI5FIL.mjs.map → chunk-XOZ7YMO3.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +24 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-W6XREK5F.mjs → intent-resolver-63EAHENI.mjs} +7 -11
- 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-LAJZQI4H.mjs → settings-SHNQ4XXP.mjs} +3 -3
- package/dist/lib/browser/types/index.mjs +4 -2
- package/dist/lib/node/AssistantDialog-FDATKYE5.cjs +72 -0
- package/dist/lib/node/AssistantDialog-FDATKYE5.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-U6AVMAHY.cjs → ChatContainer-5CLHJOIQ.cjs} +25 -19
- package/dist/lib/node/{ChatContainer-U6AVMAHY.cjs.map → ChatContainer-5CLHJOIQ.cjs.map} +1 -1
- package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs → TemplateContainer-CTG2MB4W.cjs} +18 -12
- package/dist/lib/node/{TemplateContainer-EQXKHWTF.cjs.map → TemplateContainer-CTG2MB4W.cjs.map} +1 -1
- package/dist/lib/node/{ai-client-3EVTLXTT.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-CWHFK36A.cjs → chunk-H4A42LNR.cjs} +1154 -1030
- package/dist/lib/node/chunk-H4A42LNR.cjs.map +7 -0
- package/dist/lib/node/chunk-HRNIUYVQ.cjs +128 -0
- package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +7 -0
- package/dist/lib/node/{chunk-Q5XWEMHB.cjs → chunk-P74TWGMG.cjs} +6 -6
- package/dist/lib/node/{chunk-Q5XWEMHB.cjs.map → chunk-P74TWGMG.cjs.map} +1 -1
- package/dist/lib/node/chunk-RXPA2C2A.cjs +230 -0
- package/dist/lib/node/chunk-RXPA2C2A.cjs.map +7 -0
- package/dist/lib/node/{chunk-GBUNQ257.cjs → chunk-TS3H5OSX.cjs} +7 -7
- package/dist/lib/node/chunk-TS3H5OSX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +72 -59
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-MUJMV7II.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-NPXTE6ND.cjs → settings-ERKLO6IO.cjs} +8 -8
- package/dist/lib/node/types/index.cjs +16 -14
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs +47 -0
- package/dist/lib/node-esm/AssistantDialog-PIMYK774.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-QTC5NYE2.mjs +40 -0
- package/dist/lib/{browser/ChatContainer-GAYN3FEF.mjs.map → node-esm/ChatContainer-QTC5NYE2.mjs.map} +1 -1
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs +29 -0
- package/dist/lib/{browser/TemplateContainer-WKU5XFSO.mjs.map → node-esm/TemplateContainer-IVDQ4XQG.mjs.map} +1 -1
- package/dist/lib/node-esm/{ai-client-LYCBXZI7.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-XFUXN5QU.mjs → chunk-SI5LOQEO.mjs} +1665 -1547
- package/dist/lib/node-esm/chunk-SI5LOQEO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZKBACPIW.mjs +206 -0
- package/dist/lib/node-esm/chunk-ZKBACPIW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +24 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-DZY2O2DG.mjs → intent-resolver-X3PWH7KM.mjs} +7 -11
- 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-K3JDH2I5.mjs → settings-IVQRZUCU.mjs} +3 -3
- package/dist/lib/node-esm/types/index.mjs +4 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +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 +2 -178
- 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/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.map +1 -1
- 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 +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/experimental/transcription/index.d.ts +1 -0
- package/dist/types/src/experimental/transcription/index.d.ts.map +1 -0
- package/dist/types/src/hooks/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 -7
- 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 +3 -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 +24 -21
- 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 +5 -4
- package/src/capabilities/ai-client.ts +5 -5
- package/src/capabilities/app-graph-builder.ts +179 -109
- package/src/capabilities/capabilities.ts +1 -1
- package/src/capabilities/intent-resolver.ts +4 -6
- package/src/capabilities/react-surface.tsx +58 -13
- 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 +1 -1
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +32 -0
- package/src/components/BlueprintEditor/BlueprintEditor.tsx +41 -0
- package/src/components/BlueprintEditor/index.ts +5 -0
- package/src/components/Prompt/Prompt.stories.tsx +59 -52
- package/src/components/Prompt/Prompt.tsx +24 -10
- package/src/components/Prompt/PromptBar.stories.tsx +68 -0
- package/src/components/Prompt/PromptBar.tsx +82 -88
- package/src/components/Prompt/autocomplete.ts +14 -8
- package/src/components/Prompt/references.ts +3 -3
- package/src/components/PromptSettings.tsx +2 -2
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +1 -1
- 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 +79 -49
- package/src/components/Thread/ThreadContainer.tsx +8 -9
- package/src/components/Thread/ThreadMessage.tsx +44 -9
- package/src/components/Thread/ToolInvocations.tsx +9 -7
- package/src/components/Thread/reducer.ts +1 -1
- package/src/components/Toolbox/Toolbox.stories.tsx +3 -3
- package/src/components/Toolbox/Toolbox.tsx +5 -4
- package/src/components/index.ts +2 -0
- package/src/experimental/transcription/index.ts +3 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/processor.ts +65 -27
- package/src/hooks/useChatProcessor.tsx +9 -9
- 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/tools/function.ts +11 -12
- package/src/tools/openapi.test.ts +18 -19
- package/src/tools/openapi.ts +24 -17
- package/src/translations.ts +4 -2
- 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 +20 -18
- package/dist/lib/browser/AssistantDialog-I47GUXWR.mjs +0 -117
- package/dist/lib/browser/AssistantDialog-I47GUXWR.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-GAYN3FEF.mjs +0 -33
- package/dist/lib/browser/TemplateContainer-WKU5XFSO.mjs +0 -22
- package/dist/lib/browser/ai-client-OK5SMYJC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-ZXKGE3H5.mjs +0 -179
- package/dist/lib/browser/app-graph-builder-ZXKGE3H5.mjs.map +0 -7
- package/dist/lib/browser/chunk-7CAHKTZQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-BGMQ2YYP.mjs +0 -143
- package/dist/lib/browser/chunk-BGMQ2YYP.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7BN4QKP.mjs +0 -190
- package/dist/lib/browser/chunk-E7BN4QKP.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-W6XREK5F.mjs.map +0 -7
- package/dist/lib/browser/react-surface-QMI5KG4H.mjs +0 -90
- package/dist/lib/browser/react-surface-QMI5KG4H.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-SDS2TE5L.cjs +0 -141
- package/dist/lib/node/AssistantDialog-SDS2TE5L.cjs.map +0 -7
- package/dist/lib/node/ai-client-3EVTLXTT.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-TXHPXIIC.cjs +0 -190
- package/dist/lib/node/app-graph-builder-TXHPXIIC.cjs.map +0 -7
- package/dist/lib/node/chunk-5UELRDHQ.cjs +0 -214
- package/dist/lib/node/chunk-5UELRDHQ.cjs.map +0 -7
- package/dist/lib/node/chunk-CWHFK36A.cjs.map +0 -7
- package/dist/lib/node/chunk-GBUNQ257.cjs.map +0 -7
- package/dist/lib/node/chunk-XBJO453B.cjs +0 -169
- package/dist/lib/node/chunk-XBJO453B.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-MUJMV7II.cjs.map +0 -7
- package/dist/lib/node/react-surface-SAJF4XBB.cjs +0 -106
- package/dist/lib/node/react-surface-SAJF4XBB.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-KGA5HBFO.mjs +0 -118
- package/dist/lib/node-esm/AssistantDialog-KGA5HBFO.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-XPNXNPSW.mjs +0 -34
- package/dist/lib/node-esm/TemplateContainer-3LEBT5ZC.mjs +0 -23
- package/dist/lib/node-esm/ai-client-LYCBXZI7.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-SV4WC2E2.mjs +0 -180
- package/dist/lib/node-esm/app-graph-builder-SV4WC2E2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JK5HEUQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECYNZYEG.mjs +0 -191
- package/dist/lib/node-esm/chunk-ECYNZYEG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-R7Q3OHWG.mjs +0 -144
- package/dist/lib/node-esm/chunk-R7Q3OHWG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XFUXN5QU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DZY2O2DG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-R43NHNMC.mjs +0 -91
- package/dist/lib/node-esm/react-surface-R43NHNMC.mjs.map +0 -7
- 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/hooks/invocation-handler.ts +0 -107
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- /package/dist/lib/browser/{settings-LAJZQI4H.mjs.map → settings-SHNQ4XXP.mjs.map} +0 -0
- /package/dist/lib/node/{settings-NPXTE6ND.cjs.map → settings-ERKLO6IO.cjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-K3JDH2I5.mjs.map → settings-IVQRZUCU.mjs.map} +0 -0
|
@@ -26,11 +26,13 @@ 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
33
|
IntentResolver: () => IntentResolver,
|
|
34
|
+
Prompt: () => Prompt,
|
|
35
|
+
PromptBar: () => PromptBar,
|
|
34
36
|
ReactSurface: () => ReactSurface,
|
|
35
37
|
Settings: () => Settings,
|
|
36
38
|
Thread: () => Thread,
|
|
@@ -38,124 +40,528 @@ __export(chunk_CWHFK36A_exports, {
|
|
|
38
40
|
Toolbox: () => Toolbox,
|
|
39
41
|
ToolboxContainer: () => ToolboxContainer
|
|
40
42
|
});
|
|
41
|
-
module.exports = __toCommonJS(
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
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");
|
|
45
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");
|
|
46
69
|
var import_app_framework = require("@dxos/app-framework");
|
|
47
|
-
var
|
|
48
|
-
var import_types = require("@dxos/functions/types");
|
|
70
|
+
var import_functions = require("@dxos/functions");
|
|
49
71
|
var import_log = require("@dxos/log");
|
|
50
72
|
var import_echo = require("@dxos/react-client/echo");
|
|
51
|
-
var
|
|
52
|
-
var
|
|
73
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
74
|
+
var import_ai2 = require("@dxos/ai");
|
|
53
75
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
54
|
-
var
|
|
76
|
+
var import_functions2 = require("@dxos/functions");
|
|
55
77
|
var import_log2 = require("@dxos/log");
|
|
56
78
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
79
|
+
var import_effect = require("effect");
|
|
57
80
|
var import_jsonpointer = __toESM(require("jsonpointer"));
|
|
58
|
-
var
|
|
81
|
+
var import_ai3 = require("@dxos/ai");
|
|
59
82
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
60
83
|
var import_invariant = require("@dxos/invariant");
|
|
61
84
|
var import_log3 = require("@dxos/log");
|
|
62
|
-
var
|
|
63
|
-
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"));
|
|
64
88
|
var import_halo = require("@dxos/react-client/halo");
|
|
65
89
|
var import_react_ui_components = require("@dxos/react-ui-components");
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
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");
|
|
69
95
|
var import_invariant2 = require("@dxos/invariant");
|
|
70
|
-
var
|
|
96
|
+
var import_react_ui3 = require("@dxos/react-ui");
|
|
71
97
|
var import_react_ui_components2 = require("@dxos/react-ui-components");
|
|
72
98
|
var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
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"));
|
|
76
103
|
var import_log4 = require("@dxos/log");
|
|
77
104
|
var import_react_ui_components3 = require("@dxos/react-ui-components");
|
|
78
105
|
var import_react_ui_syntax_highlighter2 = require("@dxos/react-ui-syntax-highlighter");
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
var import_react5 = __toESM(require("react"));
|
|
82
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
83
|
-
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
84
|
-
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
85
|
-
var import_state2 = require("@codemirror/state");
|
|
86
|
-
var import_view = require("@codemirror/view");
|
|
87
|
-
var import_autocomplete = require("@codemirror/autocomplete");
|
|
88
|
-
var import_state3 = require("@codemirror/state");
|
|
89
|
-
var import_view2 = require("@codemirror/view");
|
|
90
|
-
var import_async = require("@dxos/async");
|
|
91
|
-
var import_react6 = __toESM(require("react"));
|
|
92
|
-
var import_plugin_transcription = require("@dxos/plugin-transcription");
|
|
93
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
94
|
-
var import_react_ui_sfx = require("@dxos/react-ui-sfx");
|
|
95
|
-
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");
|
|
96
108
|
var import_react7 = __toESM(require("react"));
|
|
97
|
-
var
|
|
109
|
+
var import_app_framework3 = require("@dxos/app-framework");
|
|
98
110
|
var import_invariant3 = require("@dxos/invariant");
|
|
99
111
|
var import_keys = require("@dxos/keys");
|
|
100
112
|
var import_live_object = require("@dxos/live-object");
|
|
101
113
|
var import_log5 = require("@dxos/log");
|
|
102
114
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
103
115
|
var import_signals_core = require("@preact/signals-core");
|
|
116
|
+
var import_ai4 = require("@dxos/ai");
|
|
104
117
|
var import_assistant = require("@dxos/assistant");
|
|
105
118
|
var import_invariant4 = require("@dxos/invariant");
|
|
106
119
|
var import_log6 = require("@dxos/log");
|
|
107
120
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
121
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
108
122
|
var import_react8 = require("react");
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
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");
|
|
113
127
|
var import_log7 = require("@dxos/log");
|
|
114
128
|
var import_react_client = require("@dxos/react-client");
|
|
115
129
|
var import_echo5 = require("@dxos/react-client/echo");
|
|
116
|
-
var
|
|
117
|
-
var
|
|
130
|
+
var import_util6 = require("@dxos/util");
|
|
131
|
+
var import_app_framework5 = require("@dxos/app-framework");
|
|
118
132
|
var import_react9 = require("react");
|
|
119
|
-
var
|
|
120
|
-
var import_context = require("@dxos/context");
|
|
121
|
-
var import_functions = require("@dxos/functions");
|
|
122
|
-
var import_types4 = require("@dxos/functions/types");
|
|
123
|
-
var import_invariant5 = require("@dxos/invariant");
|
|
124
|
-
var import_log8 = require("@dxos/log");
|
|
125
|
-
var import_react_client2 = require("@dxos/react-client");
|
|
133
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
126
134
|
var import_echo6 = require("@dxos/react-client/echo");
|
|
127
|
-
var import_async3 = require("@dxos/async");
|
|
128
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
129
|
-
var import_types5 = require("@dxos/functions/types");
|
|
130
|
-
var import_invariant6 = require("@dxos/invariant");
|
|
131
|
-
var import_keys2 = require("@dxos/keys");
|
|
132
|
-
var import_log9 = require("@dxos/log");
|
|
133
135
|
var import_react10 = require("react");
|
|
134
|
-
var
|
|
135
|
-
var
|
|
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");
|
|
136
144
|
var import_react11 = require("react");
|
|
137
|
-
var import_artifact5 = require("@dxos/artifact");
|
|
138
|
-
var import_assistant3 = require("@dxos/assistant");
|
|
139
|
-
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
140
145
|
var import_react12 = require("react");
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
var
|
|
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
|
|
194
|
+
},
|
|
195
|
+
selection: {
|
|
196
|
+
anchor: view.state.doc.length + suffix.length
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
decorations: (v) => v._decorations
|
|
203
|
+
});
|
|
204
|
+
return [
|
|
205
|
+
suggest,
|
|
206
|
+
import_view.EditorView.theme({
|
|
207
|
+
".cm-inline-suggestion": {
|
|
208
|
+
opacity: 0.4
|
|
209
|
+
}
|
|
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
|
+
});
|
|
146
552
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
147
|
-
var
|
|
553
|
+
var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
148
554
|
if (!fn.description || !fn.inputSchema) {
|
|
149
555
|
return void 0;
|
|
150
556
|
}
|
|
151
|
-
const existingFunctionUrl = (0,
|
|
557
|
+
const existingFunctionUrl = (0, import_functions2.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
|
|
152
558
|
if (!existingFunctionUrl) {
|
|
153
559
|
return void 0;
|
|
154
560
|
}
|
|
155
|
-
const url = (0,
|
|
561
|
+
const url = (0, import_functions2.getInvocationUrl)(existingFunctionUrl, edgeUrl, {
|
|
156
562
|
spaceId
|
|
157
563
|
});
|
|
158
|
-
return (0,
|
|
564
|
+
return (0, import_ai2.createTool)("user-function", {
|
|
159
565
|
name: fn.name,
|
|
160
566
|
description: fn.description,
|
|
161
567
|
schema: (0, import_echo_schema.toEffectSchema)(fn.inputSchema),
|
|
@@ -166,7 +572,7 @@ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
|
166
572
|
input
|
|
167
573
|
}, {
|
|
168
574
|
F: __dxlog_file,
|
|
169
|
-
L:
|
|
575
|
+
L: 34,
|
|
170
576
|
S: void 0,
|
|
171
577
|
C: (f, a) => f(...a)
|
|
172
578
|
});
|
|
@@ -177,7 +583,7 @@ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
|
177
583
|
},
|
|
178
584
|
body: JSON.stringify(input)
|
|
179
585
|
});
|
|
180
|
-
return
|
|
586
|
+
return import_ai2.ToolResult.Success(await response.text());
|
|
181
587
|
}
|
|
182
588
|
});
|
|
183
589
|
};
|
|
@@ -185,7 +591,7 @@ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assista
|
|
|
185
591
|
var createToolsFromService = async (service) => {
|
|
186
592
|
(0, import_invariant.invariant)(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
187
593
|
F: __dxlog_file2,
|
|
188
|
-
L:
|
|
594
|
+
L: 23,
|
|
189
595
|
S: void 0,
|
|
190
596
|
A: [
|
|
191
597
|
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
@@ -195,7 +601,7 @@ var createToolsFromService = async (service) => {
|
|
|
195
601
|
const iface = service.interfaces[0];
|
|
196
602
|
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
197
603
|
F: __dxlog_file2,
|
|
198
|
-
L:
|
|
604
|
+
L: 25,
|
|
199
605
|
S: void 0,
|
|
200
606
|
A: [
|
|
201
607
|
"iface.schemaUrl",
|
|
@@ -204,7 +610,7 @@ var createToolsFromService = async (service) => {
|
|
|
204
610
|
});
|
|
205
611
|
(0, import_invariant.invariant)(iface.schemaUrl, void 0, {
|
|
206
612
|
F: __dxlog_file2,
|
|
207
|
-
L:
|
|
613
|
+
L: 26,
|
|
208
614
|
S: void 0,
|
|
209
615
|
A: [
|
|
210
616
|
"iface.schemaUrl",
|
|
@@ -222,7 +628,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
222
628
|
spec
|
|
223
629
|
}, {
|
|
224
630
|
F: __dxlog_file2,
|
|
225
|
-
L:
|
|
631
|
+
L: 36,
|
|
226
632
|
S: void 0,
|
|
227
633
|
C: (f, a) => f(...a)
|
|
228
634
|
});
|
|
@@ -240,7 +646,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
240
646
|
methodItem
|
|
241
647
|
}, {
|
|
242
648
|
F: __dxlog_file2,
|
|
243
|
-
L:
|
|
649
|
+
L: 47,
|
|
244
650
|
S: void 0,
|
|
245
651
|
C: (f, a) => f(...a)
|
|
246
652
|
});
|
|
@@ -258,7 +664,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
258
664
|
parameter
|
|
259
665
|
}, {
|
|
260
666
|
F: __dxlog_file2,
|
|
261
|
-
L:
|
|
667
|
+
L: 63,
|
|
262
668
|
S: void 0,
|
|
263
669
|
C: (f, a) => f(...a)
|
|
264
670
|
});
|
|
@@ -281,11 +687,11 @@ var createToolsFromApi = async (url, options) => {
|
|
|
281
687
|
inputSchema
|
|
282
688
|
}, {
|
|
283
689
|
F: __dxlog_file2,
|
|
284
|
-
L:
|
|
690
|
+
L: 88,
|
|
285
691
|
S: void 0,
|
|
286
692
|
C: (f, a) => f(...a)
|
|
287
693
|
});
|
|
288
|
-
|
|
694
|
+
import_effect.Schema.validateSync(import_echo_schema2.JsonSchemaType)(inputSchema);
|
|
289
695
|
const description = methodItem.description ?? methodItem.summary;
|
|
290
696
|
if (!description) {
|
|
291
697
|
import_log3.log.warn("no description", {
|
|
@@ -293,7 +699,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
293
699
|
method
|
|
294
700
|
}, {
|
|
295
701
|
F: __dxlog_file2,
|
|
296
|
-
L:
|
|
702
|
+
L: 93,
|
|
297
703
|
S: void 0,
|
|
298
704
|
C: (f, a) => f(...a)
|
|
299
705
|
});
|
|
@@ -306,17 +712,20 @@ var createToolsFromApi = async (url, options) => {
|
|
|
306
712
|
parameters: endpointParameters,
|
|
307
713
|
authorization: options?.authorization
|
|
308
714
|
};
|
|
309
|
-
tools.push(
|
|
310
|
-
|
|
311
|
-
|
|
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}
|
|
312
720
|
|
|
313
721
|
${description}` : description,
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
722
|
+
parameters: inputSchema,
|
|
723
|
+
execute: async (input) => {
|
|
724
|
+
const response = await callApiEndpoint(endpoint, input);
|
|
725
|
+
return import_ai3.ToolResult.Success(response);
|
|
726
|
+
}
|
|
727
|
+
})
|
|
728
|
+
);
|
|
320
729
|
}
|
|
321
730
|
}
|
|
322
731
|
return tools;
|
|
@@ -369,7 +778,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
369
778
|
input
|
|
370
779
|
}, {
|
|
371
780
|
F: __dxlog_file2,
|
|
372
|
-
L:
|
|
781
|
+
L: 180,
|
|
373
782
|
S: void 0,
|
|
374
783
|
C: (f, a) => f(...a)
|
|
375
784
|
});
|
|
@@ -398,7 +807,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
398
807
|
case "body": {
|
|
399
808
|
const value = input[parameter.name];
|
|
400
809
|
const effectSchema = (0, import_echo_schema2.toEffectSchema)(parameter.schema);
|
|
401
|
-
|
|
810
|
+
import_effect.Schema.validateSync(effectSchema)(value);
|
|
402
811
|
if (body) {
|
|
403
812
|
throw new Error(`Duplicate body parameter: ${parameter.name}`);
|
|
404
813
|
}
|
|
@@ -428,7 +837,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
428
837
|
request
|
|
429
838
|
}, {
|
|
430
839
|
F: __dxlog_file2,
|
|
431
|
-
L:
|
|
840
|
+
L: 243,
|
|
432
841
|
S: void 0,
|
|
433
842
|
C: (f, a) => f(...a)
|
|
434
843
|
});
|
|
@@ -439,7 +848,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
439
848
|
statusText: response.statusText
|
|
440
849
|
}, {
|
|
441
850
|
F: __dxlog_file2,
|
|
442
|
-
L:
|
|
851
|
+
L: 246,
|
|
443
852
|
S: void 0,
|
|
444
853
|
C: (f, a) => f(...a)
|
|
445
854
|
});
|
|
@@ -463,7 +872,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
463
872
|
error
|
|
464
873
|
}, {
|
|
465
874
|
F: __dxlog_file2,
|
|
466
|
-
L:
|
|
875
|
+
L: 264,
|
|
467
876
|
S: void 0,
|
|
468
877
|
C: (f, a) => f(...a)
|
|
469
878
|
});
|
|
@@ -474,7 +883,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
474
883
|
error
|
|
475
884
|
}, {
|
|
476
885
|
F: __dxlog_file2,
|
|
477
|
-
L:
|
|
886
|
+
L: 268,
|
|
478
887
|
S: void 0,
|
|
479
888
|
C: (f, a) => f(...a)
|
|
480
889
|
});
|
|
@@ -489,7 +898,7 @@ var getEndpointUrl = (endpoint) => {
|
|
|
489
898
|
} else {
|
|
490
899
|
(0, import_invariant.invariant)(!isV3_1(endpoint.document), void 0, {
|
|
491
900
|
F: __dxlog_file2,
|
|
492
|
-
L:
|
|
901
|
+
L: 279,
|
|
493
902
|
S: void 0,
|
|
494
903
|
A: [
|
|
495
904
|
"!isV3_1(endpoint.document)",
|
|
@@ -509,7 +918,7 @@ var resolveAuthorization = async (authorization) => {
|
|
|
509
918
|
case "api-key": {
|
|
510
919
|
(0, import_invariant.invariant)(authorization.placement.type === "authorization-header", void 0, {
|
|
511
920
|
F: __dxlog_file2,
|
|
512
|
-
L:
|
|
921
|
+
L: 295,
|
|
513
922
|
S: void 0,
|
|
514
923
|
A: [
|
|
515
924
|
"authorization.placement.type === 'authorization-header'",
|
|
@@ -535,7 +944,7 @@ var resolveAuthorization = async (authorization) => {
|
|
|
535
944
|
}
|
|
536
945
|
};
|
|
537
946
|
var resolveJsonSchema = (schema, base) => {
|
|
538
|
-
return (0,
|
|
947
|
+
return (0, import_util2.deepMapValues)(schema, (value, recurse) => {
|
|
539
948
|
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
540
949
|
if (value.$ref.startsWith("#")) {
|
|
541
950
|
const resolved = import_jsonpointer.default.get(base, value.$ref.slice(1));
|
|
@@ -547,7 +956,7 @@ var resolveJsonSchema = (schema, base) => {
|
|
|
547
956
|
base
|
|
548
957
|
}, {
|
|
549
958
|
F: __dxlog_file2,
|
|
550
|
-
L:
|
|
959
|
+
L: 328,
|
|
551
960
|
S: void 0,
|
|
552
961
|
C: (f, a) => f(...a)
|
|
553
962
|
});
|
|
@@ -562,91 +971,106 @@ var isV3_1 = (document2) => {
|
|
|
562
971
|
};
|
|
563
972
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
564
973
|
var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
description,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
description: description2
|
|
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
|
+
}))
|
|
575
987
|
}))
|
|
576
|
-
})
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
+
}))
|
|
585
997
|
}))
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}))
|
|
593
|
-
}
|
|
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
|
+
}
|
|
594
1008
|
};
|
|
595
1009
|
var Section = ({ title, items, striped }) => {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
+
}
|
|
619
1038
|
};
|
|
620
1039
|
var ToolboxContainer = ({ classNames, space }) => {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
(0,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
tools
|
|
637
|
-
|
|
638
|
-
|
|
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
|
|
639
1070
|
});
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.FunctionType));
|
|
644
|
-
return /* @__PURE__ */ import_react.default.createElement(Toolbox, {
|
|
645
|
-
classNames,
|
|
646
|
-
artifacts: artifactDefinitions,
|
|
647
|
-
services: serviceTools,
|
|
648
|
-
functions
|
|
649
|
-
});
|
|
1071
|
+
} finally {
|
|
1072
|
+
_effect.f();
|
|
1073
|
+
}
|
|
650
1074
|
};
|
|
651
1075
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
|
|
652
1076
|
var isToolMessage = (message) => {
|
|
@@ -655,164 +1079,199 @@ var isToolMessage = (message) => {
|
|
|
655
1079
|
var getToolName2 = (tool) => {
|
|
656
1080
|
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
657
1081
|
};
|
|
658
|
-
var getToolCaption = (tool) => {
|
|
1082
|
+
var getToolCaption = (tool, status) => {
|
|
659
1083
|
if (!tool) {
|
|
660
1084
|
return "Calling tool...";
|
|
661
1085
|
}
|
|
662
|
-
return tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
1086
|
+
return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
663
1087
|
};
|
|
664
1088
|
var ToolBlock = ({ classNames, message, tools }) => {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
title: getToolCaption(request.tool),
|
|
680
|
-
block
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
case "tool_result": {
|
|
684
|
-
if (!request) {
|
|
685
|
-
import_log4.log.warn("unexpected message", {
|
|
686
|
-
block
|
|
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;
|
|
1099
|
+
}
|
|
1100
|
+
import_log4.log.info("tool_use", {
|
|
1101
|
+
tool: request?.tool,
|
|
1102
|
+
status: block.currentStatus
|
|
687
1103
|
}, {
|
|
688
1104
|
F: __dxlog_file4,
|
|
689
|
-
L:
|
|
1105
|
+
L: 46,
|
|
690
1106
|
S: void 0,
|
|
691
1107
|
C: (f, a) => f(...a)
|
|
692
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
|
+
};
|
|
1117
|
+
}
|
|
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
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
return {
|
|
1134
|
+
title: `${getToolCaption(request.tool, void 0)} (Success)`,
|
|
1135
|
+
block
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
default: {
|
|
1139
|
+
request = void 0;
|
|
693
1140
|
return {
|
|
694
1141
|
title: "Error",
|
|
695
1142
|
block
|
|
696
1143
|
};
|
|
697
1144
|
}
|
|
698
|
-
return {
|
|
699
|
-
title: `${getToolCaption(request.tool)} (Success)`,
|
|
700
|
-
block
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
default: {
|
|
704
|
-
request = void 0;
|
|
705
|
-
return {
|
|
706
|
-
title: "Error",
|
|
707
|
-
block
|
|
708
|
-
};
|
|
709
1145
|
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
1146
|
+
}).filter(import_util5.isNonNullable);
|
|
1147
|
+
return /* @__PURE__ */ import_react6.default.createElement(ToolContainer, {
|
|
1148
|
+
classNames,
|
|
1149
|
+
items
|
|
1150
|
+
});
|
|
1151
|
+
} finally {
|
|
1152
|
+
_effect.f();
|
|
1153
|
+
}
|
|
716
1154
|
};
|
|
717
1155
|
var ToolContainer = ({ classNames, items }) => {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
classNames
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
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();
|
|
1207
|
+
}
|
|
765
1208
|
};
|
|
766
1209
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
|
|
767
|
-
var panelClassNames = "flex flex-col w-full px-2 bg-
|
|
768
|
-
var userClassNames = "bg-[--user-fill] text-
|
|
1210
|
+
var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-md";
|
|
1211
|
+
var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
|
|
769
1212
|
var ToggleContainer2 = (props) => {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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();
|
|
1221
|
+
}
|
|
774
1222
|
};
|
|
775
1223
|
var MessageContainer = ({ children, classNames, user }) => {
|
|
776
|
-
|
|
777
|
-
|
|
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();
|
|
778
1240
|
}
|
|
779
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
780
|
-
role: "list-item",
|
|
781
|
-
className: (0, import_react_ui_theme3.mx)("flex w-full", user && "justify-end", classNames)
|
|
782
|
-
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
783
|
-
className: (0, import_react_ui_theme3.mx)(user ? [
|
|
784
|
-
"px-2 py-1 rounded-md",
|
|
785
|
-
userClassNames
|
|
786
|
-
] : "w-full")
|
|
787
|
-
}, children));
|
|
788
1241
|
};
|
|
789
|
-
var ThreadMessage = ({ classNames, space, message, tools, onPrompt }) => {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
803
|
-
return null;
|
|
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
|
+
}));
|
|
804
1255
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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();
|
|
1274
|
+
}
|
|
816
1275
|
};
|
|
817
1276
|
var components = {
|
|
818
1277
|
//
|
|
@@ -821,7 +1280,7 @@ var components = {
|
|
|
821
1280
|
["text"]: ({ block }) => {
|
|
822
1281
|
(0, import_invariant2.invariant)(block.type === "text", void 0, {
|
|
823
1282
|
F: __dxlog_file5,
|
|
824
|
-
L:
|
|
1283
|
+
L: 105,
|
|
825
1284
|
S: void 0,
|
|
826
1285
|
A: [
|
|
827
1286
|
"block.type === 'text'",
|
|
@@ -830,21 +1289,21 @@ var components = {
|
|
|
830
1289
|
});
|
|
831
1290
|
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
832
1291
|
if (!title) {
|
|
833
|
-
return /* @__PURE__ */
|
|
1292
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
|
|
834
1293
|
classNames: "[&>p]:animate-[fadeIn_0.5s]",
|
|
835
1294
|
content: block.text
|
|
836
1295
|
});
|
|
837
1296
|
}
|
|
838
|
-
return /* @__PURE__ */
|
|
1297
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
839
1298
|
// open={open}
|
|
840
1299
|
defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
|
|
841
1300
|
title,
|
|
842
|
-
icon: block.pending ? /* @__PURE__ */
|
|
1301
|
+
icon: block.pending ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Icon, {
|
|
843
1302
|
icon: "ph--circle-notch--regular",
|
|
844
1303
|
classNames: "text-subdued ml-2 animate-spin",
|
|
845
1304
|
size: 4
|
|
846
1305
|
}) : void 0
|
|
847
|
-
}, /* @__PURE__ */
|
|
1306
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_components2.MarkdownViewer, {
|
|
848
1307
|
content: block.text,
|
|
849
1308
|
classNames: [
|
|
850
1309
|
"pbe-2",
|
|
@@ -855,10 +1314,10 @@ var components = {
|
|
|
855
1314
|
//
|
|
856
1315
|
// JSON
|
|
857
1316
|
//
|
|
858
|
-
["json"]: ({ space, block, onPrompt }) => {
|
|
1317
|
+
["json"]: ({ space, block, onPrompt, onAddToGraph }) => {
|
|
859
1318
|
(0, import_invariant2.invariant)(block.type === "json", void 0, {
|
|
860
1319
|
F: __dxlog_file5,
|
|
861
|
-
L:
|
|
1320
|
+
L: 143,
|
|
862
1321
|
S: void 0,
|
|
863
1322
|
A: [
|
|
864
1323
|
"block.type === 'json'",
|
|
@@ -867,38 +1326,56 @@ var components = {
|
|
|
867
1326
|
});
|
|
868
1327
|
switch (block.disposition) {
|
|
869
1328
|
case "tool_list": {
|
|
870
|
-
return /* @__PURE__ */
|
|
1329
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
871
1330
|
title: titles[block.disposition],
|
|
872
1331
|
defaultOpen: true
|
|
873
|
-
}, /* @__PURE__ */
|
|
1332
|
+
}, /* @__PURE__ */ import_react5.default.createElement(ToolboxContainer, {
|
|
874
1333
|
space,
|
|
875
1334
|
classNames: "pbe-2"
|
|
876
1335
|
}));
|
|
877
1336
|
}
|
|
878
1337
|
case "suggest": {
|
|
879
|
-
const { text = "" } = (0,
|
|
880
|
-
return /* @__PURE__ */
|
|
1338
|
+
const { text = "" } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
|
|
1339
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.IconButton, {
|
|
881
1340
|
icon: "ph--lightning--regular",
|
|
882
1341
|
label: text,
|
|
883
1342
|
onClick: () => onPrompt?.(text)
|
|
884
1343
|
});
|
|
885
1344
|
}
|
|
886
1345
|
case "select": {
|
|
887
|
-
const { options = [] } = (0,
|
|
888
|
-
return /* @__PURE__ */
|
|
1346
|
+
const { options = [] } = (0, import_util4.safeParseJson)(block.json ?? "{}") ?? {};
|
|
1347
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
889
1348
|
className: "flex flex-wrap gap-1"
|
|
890
|
-
}, options.map((option, idx) => /* @__PURE__ */
|
|
1349
|
+
}, options.map((option, idx) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Button, {
|
|
891
1350
|
classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
|
|
892
1351
|
key: option,
|
|
893
1352
|
onClick: () => onPrompt?.(option)
|
|
894
1353
|
}, option)));
|
|
895
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
|
+
}));
|
|
1372
|
+
}
|
|
896
1373
|
default: {
|
|
897
1374
|
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
898
|
-
return /* @__PURE__ */
|
|
1375
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
899
1376
|
title: title ?? "JSON"
|
|
900
|
-
}, /* @__PURE__ */
|
|
901
|
-
data: (0,
|
|
1377
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
1378
|
+
data: (0, import_util4.safeParseJson)(block.json ?? block),
|
|
902
1379
|
classNames: "!p-1 text-xs"
|
|
903
1380
|
}));
|
|
904
1381
|
}
|
|
@@ -912,9 +1389,9 @@ var components = {
|
|
|
912
1389
|
if (block.type === "tool_use") {
|
|
913
1390
|
title = `Tool [${block.name}]`;
|
|
914
1391
|
}
|
|
915
|
-
return /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ import_react5.default.createElement(ToggleContainer2, {
|
|
916
1393
|
title: title ?? "JSON"
|
|
917
|
-
}, /* @__PURE__ */
|
|
1394
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_syntax_highlighter.Json, {
|
|
918
1395
|
data: block,
|
|
919
1396
|
classNames: "!p-1 text-xs"
|
|
920
1397
|
}));
|
|
@@ -951,495 +1428,110 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
951
1428
|
block
|
|
952
1429
|
]
|
|
953
1430
|
};
|
|
954
|
-
messages.push(current);
|
|
955
|
-
}
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
case "text":
|
|
959
|
-
default: {
|
|
960
|
-
current = void 0;
|
|
961
|
-
messages.push({
|
|
962
|
-
id: [
|
|
963
|
-
message.id,
|
|
964
|
-
i
|
|
965
|
-
].join("_"),
|
|
966
|
-
role: message.role,
|
|
967
|
-
content: [
|
|
968
|
-
block
|
|
969
|
-
]
|
|
970
|
-
});
|
|
971
|
-
break;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
i++;
|
|
975
|
-
}
|
|
976
|
-
return {
|
|
977
|
-
current,
|
|
978
|
-
messages
|
|
979
|
-
};
|
|
980
|
-
};
|
|
981
|
-
var createAutocompleteExtension = ({ onSubmit, onSuggest }) => {
|
|
982
|
-
const suggestionPlugin = import_view.ViewPlugin.fromClass(class {
|
|
983
|
-
constructor(view) {
|
|
984
|
-
this._currentSuggestion = null;
|
|
985
|
-
this._decorations = this.computeDecorations(view);
|
|
986
|
-
}
|
|
987
|
-
update(update) {
|
|
988
|
-
if (update.docChanged || update.selectionSet) {
|
|
989
|
-
this._decorations = this.computeDecorations(update.view);
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
computeDecorations(view) {
|
|
993
|
-
const text = view.state.doc.toString();
|
|
994
|
-
const suggestions = onSuggest?.(text) ?? [];
|
|
995
|
-
if (!suggestions.length) {
|
|
996
|
-
this._currentSuggestion = null;
|
|
997
|
-
return import_view.Decoration.none;
|
|
998
|
-
}
|
|
999
|
-
this._currentSuggestion = suggestions[0];
|
|
1000
|
-
const suffix = this._currentSuggestion.slice(text.length);
|
|
1001
|
-
if (!suffix) {
|
|
1002
|
-
return import_view.Decoration.none;
|
|
1003
|
-
}
|
|
1004
|
-
return import_view.Decoration.set([
|
|
1005
|
-
import_view.Decoration.widget({
|
|
1006
|
-
widget: new InlineSuggestionWidget(suffix),
|
|
1007
|
-
side: 1
|
|
1008
|
-
}).range(view.state.doc.length)
|
|
1009
|
-
]);
|
|
1010
|
-
}
|
|
1011
|
-
completeSuggestion(view) {
|
|
1012
|
-
if (!this._currentSuggestion) {
|
|
1013
|
-
return false;
|
|
1014
|
-
}
|
|
1015
|
-
const text = view.state.doc.toString();
|
|
1016
|
-
const suffix = this._currentSuggestion.slice(text.length);
|
|
1017
|
-
if (!suffix) {
|
|
1018
|
-
return false;
|
|
1019
|
-
}
|
|
1020
|
-
view.dispatch({
|
|
1021
|
-
changes: {
|
|
1022
|
-
from: view.state.doc.length,
|
|
1023
|
-
insert: suffix
|
|
1024
|
-
},
|
|
1025
|
-
selection: {
|
|
1026
|
-
anchor: view.state.doc.length + suffix.length
|
|
1027
|
-
}
|
|
1028
|
-
});
|
|
1029
|
-
return true;
|
|
1030
|
-
}
|
|
1031
|
-
}, {
|
|
1032
|
-
decorations: (v) => v._decorations
|
|
1033
|
-
});
|
|
1034
|
-
return [
|
|
1035
|
-
suggestionPlugin,
|
|
1036
|
-
import_view.EditorView.theme({
|
|
1037
|
-
".cm-inline-suggestion": {
|
|
1038
|
-
opacity: 0.4
|
|
1039
|
-
}
|
|
1040
|
-
}),
|
|
1041
|
-
// Accept the current suggestion.
|
|
1042
|
-
import_state2.Prec.highest(import_view.keymap.of([
|
|
1043
|
-
{
|
|
1044
|
-
key: "Tab",
|
|
1045
|
-
preventDefault: true,
|
|
1046
|
-
run: (view) => {
|
|
1047
|
-
const plugin = view.plugin(suggestionPlugin);
|
|
1048
|
-
return plugin?.completeSuggestion(view) ?? false;
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
key: "ArrowRight",
|
|
1053
|
-
preventDefault: true,
|
|
1054
|
-
run: (view) => {
|
|
1055
|
-
if (view.state.selection.main.head !== view.state.doc.length) {
|
|
1056
|
-
return false;
|
|
1057
|
-
}
|
|
1058
|
-
const plugin = view.plugin(suggestionPlugin);
|
|
1059
|
-
return plugin?.completeSuggestion(view) ?? false;
|
|
1060
|
-
}
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
key: "Enter",
|
|
1064
|
-
preventDefault: true,
|
|
1065
|
-
run: (view) => {
|
|
1066
|
-
const text = view.state.doc.toString().trim();
|
|
1067
|
-
if (text.length > 0 && onSubmit) {
|
|
1068
|
-
const reset = onSubmit(text);
|
|
1069
|
-
if (reset) {
|
|
1070
|
-
view.dispatch({
|
|
1071
|
-
changes: {
|
|
1072
|
-
from: 0,
|
|
1073
|
-
to: view.state.doc.length,
|
|
1074
|
-
insert: ""
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
return true;
|
|
1080
|
-
}
|
|
1081
|
-
},
|
|
1082
|
-
{
|
|
1083
|
-
key: "Shift-Enter",
|
|
1084
|
-
preventDefault: true,
|
|
1085
|
-
run: (view) => {
|
|
1086
|
-
view.dispatch({
|
|
1087
|
-
changes: {
|
|
1088
|
-
from: view.state.selection.main.head,
|
|
1089
|
-
insert: "\n"
|
|
1090
|
-
},
|
|
1091
|
-
selection: {
|
|
1092
|
-
anchor: view.state.selection.main.head + 1,
|
|
1093
|
-
head: view.state.selection.main.head + 1
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
return true;
|
|
1097
|
-
}
|
|
1098
|
-
},
|
|
1099
|
-
{
|
|
1100
|
-
key: "Escape",
|
|
1101
|
-
preventDefault: true,
|
|
1102
|
-
run: (view) => {
|
|
1103
|
-
view.dispatch({
|
|
1104
|
-
changes: {
|
|
1105
|
-
from: 0,
|
|
1106
|
-
to: view.state.doc.length,
|
|
1107
|
-
insert: ""
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
return true;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
]))
|
|
1114
|
-
];
|
|
1115
|
-
};
|
|
1116
|
-
var InlineSuggestionWidget = class extends import_view.WidgetType {
|
|
1117
|
-
constructor(suffix) {
|
|
1118
|
-
super();
|
|
1119
|
-
this.suffix = suffix;
|
|
1120
|
-
}
|
|
1121
|
-
toDOM() {
|
|
1122
|
-
const span = document.createElement("span");
|
|
1123
|
-
span.textContent = this.suffix;
|
|
1124
|
-
span.className = "cm-inline-suggestion";
|
|
1125
|
-
return span;
|
|
1126
|
-
}
|
|
1127
|
-
eq(other) {
|
|
1128
|
-
return other.suffix === this.suffix;
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
|
|
1132
|
-
if (triggerCharacter.length !== 1) {
|
|
1133
|
-
throw new Error("triggerCharacter must be a single character");
|
|
1134
|
-
}
|
|
1135
|
-
const decorationField = import_view2.ViewPlugin.fromClass(class ReferenceView {
|
|
1136
|
-
constructor(view) {
|
|
1137
|
-
this._mutex = new import_async.Mutex();
|
|
1138
|
-
this.decorations = import_view2.Decoration.set([]);
|
|
1139
|
-
queueMicrotask(async () => {
|
|
1140
|
-
const guard = await this._mutex.acquire();
|
|
1141
|
-
try {
|
|
1142
|
-
this.decorations = await this._computeDecorations(view);
|
|
1143
|
-
} finally {
|
|
1144
|
-
guard.release();
|
|
1431
|
+
messages.push(current);
|
|
1145
1432
|
}
|
|
1146
|
-
|
|
1147
|
-
}
|
|
1148
|
-
update(update) {
|
|
1149
|
-
if (update.docChanged) {
|
|
1150
|
-
queueMicrotask(async () => {
|
|
1151
|
-
const guard = await this._mutex.acquire();
|
|
1152
|
-
try {
|
|
1153
|
-
this.decorations = await this._computeDecorations(update.view);
|
|
1154
|
-
} finally {
|
|
1155
|
-
guard.release();
|
|
1156
|
-
}
|
|
1157
|
-
});
|
|
1433
|
+
break;
|
|
1158
1434
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
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
|
+
]
|
|
1169
1447
|
});
|
|
1170
|
-
|
|
1171
|
-
decorations.push(import_view2.Decoration.replace({
|
|
1172
|
-
widget: new ReferenceWidget(data)
|
|
1173
|
-
}).range(match.index, match.index + reference.length));
|
|
1174
|
-
}
|
|
1448
|
+
break;
|
|
1175
1449
|
}
|
|
1176
|
-
return import_view2.Decoration.set(decorations);
|
|
1177
1450
|
}
|
|
1178
|
-
|
|
1179
|
-
decorations: (v) => v.decorations,
|
|
1180
|
-
provide: (plugin) => [
|
|
1181
|
-
import_view2.EditorView.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? import_state3.RangeSet.empty)
|
|
1182
|
-
]
|
|
1183
|
-
});
|
|
1184
|
-
return [
|
|
1185
|
-
decorationField,
|
|
1186
|
-
import_view2.EditorView.theme({
|
|
1187
|
-
".cm-reference-pill": {
|
|
1188
|
-
borderRadius: "0.25rem",
|
|
1189
|
-
borderWidth: "1px",
|
|
1190
|
-
marginRight: "0.25rem",
|
|
1191
|
-
marginLeft: "0.25rem"
|
|
1192
|
-
}
|
|
1193
|
-
}),
|
|
1194
|
-
(0, import_autocomplete.autocompletion)({
|
|
1195
|
-
activateOnTyping: true,
|
|
1196
|
-
override: [
|
|
1197
|
-
async (context) => {
|
|
1198
|
-
const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
|
|
1199
|
-
if (!match || match?.to === match?.from) {
|
|
1200
|
-
return null;
|
|
1201
|
-
}
|
|
1202
|
-
const query = match.text.slice(1);
|
|
1203
|
-
const references = await provider.getReferences({
|
|
1204
|
-
query
|
|
1205
|
-
});
|
|
1206
|
-
return {
|
|
1207
|
-
from: match.from,
|
|
1208
|
-
filter: false,
|
|
1209
|
-
options: references.map((reference) => ({
|
|
1210
|
-
label: reference.label,
|
|
1211
|
-
apply: `${triggerCharacter}${reference.uri} `
|
|
1212
|
-
}))
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
],
|
|
1216
|
-
closeOnBlur: !debug,
|
|
1217
|
-
tooltipClass: () => "shadow rounded",
|
|
1218
|
-
aboveCursor: true
|
|
1219
|
-
}),
|
|
1220
|
-
import_view2.keymap.of(import_autocomplete.completionKeymap)
|
|
1221
|
-
];
|
|
1222
|
-
};
|
|
1223
|
-
var ReferenceWidget = class extends import_view2.WidgetType {
|
|
1224
|
-
constructor(data) {
|
|
1225
|
-
super();
|
|
1226
|
-
this.data = data;
|
|
1227
|
-
}
|
|
1228
|
-
toDOM() {
|
|
1229
|
-
const span = document.createElement("span");
|
|
1230
|
-
span.textContent = `@ ${this.data.label}`;
|
|
1231
|
-
span.className = "cm-reference-pill";
|
|
1232
|
-
return span;
|
|
1233
|
-
}
|
|
1234
|
-
eq(other) {
|
|
1235
|
-
return other.data.uri === this.data.uri;
|
|
1236
|
-
}
|
|
1237
|
-
ignoreEvent() {
|
|
1238
|
-
return true;
|
|
1451
|
+
i++;
|
|
1239
1452
|
}
|
|
1453
|
+
return {
|
|
1454
|
+
current,
|
|
1455
|
+
messages
|
|
1456
|
+
};
|
|
1240
1457
|
};
|
|
1241
|
-
var
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
onSubmit,
|
|
1260
|
-
onSuggest
|
|
1261
|
-
}),
|
|
1262
|
-
import_state.Prec.highest(import_react_ui_editor.keymap.of([
|
|
1263
|
-
{
|
|
1264
|
-
key: "cmd-ArrowUp",
|
|
1265
|
-
preventDefault: true,
|
|
1266
|
-
run: (view2) => {
|
|
1267
|
-
onOpenChange?.(true);
|
|
1268
|
-
return true;
|
|
1269
|
-
}
|
|
1270
|
-
},
|
|
1271
|
-
{
|
|
1272
|
-
key: "cmd-ArrowDown",
|
|
1273
|
-
preventDefault: true,
|
|
1274
|
-
run: (view2) => {
|
|
1275
|
-
onOpenChange?.(false);
|
|
1276
|
-
return true;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
]))
|
|
1280
|
-
]
|
|
1281
|
-
}, [
|
|
1282
|
-
themeMode,
|
|
1283
|
-
onSubmit,
|
|
1284
|
-
onSuggest
|
|
1285
|
-
]);
|
|
1286
|
-
(0, import_react5.useImperativeHandle)(forwardRef2, () => {
|
|
1287
|
-
return {
|
|
1288
|
-
focus: () => {
|
|
1289
|
-
view?.focus();
|
|
1290
|
-
},
|
|
1291
|
-
setText: (text) => {
|
|
1292
|
-
view?.dispatch({
|
|
1293
|
-
changes: {
|
|
1294
|
-
from: 0,
|
|
1295
|
-
to: view.state.doc.length,
|
|
1296
|
-
insert: text
|
|
1297
|
-
},
|
|
1298
|
-
selection: {
|
|
1299
|
-
anchor: text.length,
|
|
1300
|
-
head: text.length
|
|
1301
|
-
}
|
|
1458
|
+
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
|
|
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: []
|
|
1302
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;
|
|
1303
1489
|
}
|
|
1304
|
-
};
|
|
1305
|
-
}, [
|
|
1306
|
-
view,
|
|
1307
|
-
onSubmit
|
|
1308
|
-
]);
|
|
1309
|
-
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
1310
|
-
ref: parentRef,
|
|
1311
|
-
className: (0, import_react_ui_theme4.mx)("w-full", classNames)
|
|
1312
|
-
});
|
|
1313
|
-
});
|
|
1314
|
-
var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, references, ...props }) => {
|
|
1315
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_Q5XWEMHB.ASSISTANT_PLUGIN);
|
|
1316
|
-
const promptRef = (0, import_react6.useRef)(null);
|
|
1317
|
-
const [active, setActive] = (0, import_react6.useState)(false);
|
|
1318
|
-
const { recording } = (0, import_plugin_transcription.useVoiceInput)({
|
|
1319
|
-
active,
|
|
1320
|
-
onUpdate: (text) => {
|
|
1321
|
-
promptRef.current?.setText(text);
|
|
1322
|
-
promptRef.current?.focus();
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
1325
|
-
return /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1326
|
-
className: (0, import_react_ui_theme5.mx)("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
|
|
1327
|
-
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1328
|
-
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
1329
|
-
}, error && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, {
|
|
1330
|
-
delayDuration: 0
|
|
1331
|
-
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Icon, {
|
|
1332
|
-
icon: "ph--warning-circle--regular",
|
|
1333
|
-
classNames: import_react_ui_theme5.errorText,
|
|
1334
|
-
size: 5
|
|
1335
|
-
})), /* @__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", {
|
|
1336
|
-
className: (0, import_react_ui_theme5.mx)("text-sm", import_react_ui_theme5.errorMessageColors)
|
|
1337
|
-
}, error.message), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null)))) || /* @__PURE__ */ import_react6.default.createElement(import_react_ui_sfx.Spinner, {
|
|
1338
|
-
active: processing
|
|
1339
|
-
})), /* @__PURE__ */ import_react6.default.createElement(Prompt, {
|
|
1340
|
-
ref: promptRef,
|
|
1341
|
-
autoFocus: true,
|
|
1342
|
-
classNames: "pbs-2",
|
|
1343
|
-
lineWrapping: true,
|
|
1344
|
-
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1345
|
-
references,
|
|
1346
|
-
...props
|
|
1347
|
-
}), (onCancel || microphone) && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1348
|
-
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
1349
|
-
}, processing && onCancel && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
|
|
1350
|
-
classNames: "px-1.5",
|
|
1351
|
-
variant: "ghost",
|
|
1352
|
-
size: 5,
|
|
1353
|
-
icon: "ph--x--regular",
|
|
1354
|
-
iconOnly: true,
|
|
1355
|
-
label: t("cancel processing button"),
|
|
1356
|
-
onClick: onCancel
|
|
1357
|
-
}), !processing && microphone && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.IconButton, {
|
|
1358
|
-
classNames: (0, import_react_ui_theme5.mx)("px-1.5", recording && "bg-primary-500"),
|
|
1359
|
-
variant: "ghost",
|
|
1360
|
-
size: 5,
|
|
1361
|
-
icon: "ph--microphone--regular",
|
|
1362
|
-
iconOnly: true,
|
|
1363
|
-
noTooltip: true,
|
|
1364
|
-
label: t("microphone button"),
|
|
1365
|
-
onMouseDown: () => setActive(true),
|
|
1366
|
-
onMouseUp: () => setActive(false),
|
|
1367
|
-
onTouchStart: () => setActive(true),
|
|
1368
|
-
onTouchEnd: () => setActive(false)
|
|
1369
|
-
})));
|
|
1370
|
-
};
|
|
1371
|
-
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
|
|
1372
|
-
const scroller = (0, import_react2.useRef)(null);
|
|
1373
|
-
const identity = (0, import_halo.useIdentity)();
|
|
1374
|
-
const fallbackValue = (0, import_util2.keyToFallback)(identity.identityKey);
|
|
1375
|
-
const userHue = identity.profile?.data?.hue || fallbackValue.hue;
|
|
1376
|
-
const handleSubmit = (0, import_react2.useCallback)((value) => {
|
|
1377
|
-
onSubmit?.(value);
|
|
1378
|
-
scroller.current?.scrollToBottom();
|
|
1379
|
-
return true;
|
|
1380
|
-
}, [
|
|
1381
|
-
onSubmit
|
|
1382
|
-
]);
|
|
1383
|
-
const { messages: filteredMessages = [] } = (0, import_react2.useMemo)(() => {
|
|
1384
|
-
if (collapse) {
|
|
1385
|
-
return (messages ?? []).reduce(messageReducer, {
|
|
1386
|
-
messages: []
|
|
1387
|
-
});
|
|
1388
|
-
} else {
|
|
1389
1490
|
return {
|
|
1390
|
-
|
|
1491
|
+
getReferences: async ({ query }) => contextProvider.query({
|
|
1492
|
+
query
|
|
1493
|
+
}),
|
|
1494
|
+
resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
|
|
1495
|
+
uri
|
|
1496
|
+
})
|
|
1391
1497
|
};
|
|
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
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
key: message.id,
|
|
1426
|
-
classNames: "px-4 pbe-4",
|
|
1427
|
-
space,
|
|
1428
|
-
message,
|
|
1429
|
-
...props
|
|
1430
|
-
})))), onSubmit && /* @__PURE__ */ import_react2.default.createElement(PromptBar, {
|
|
1431
|
-
microphone: transcription,
|
|
1432
|
-
processing,
|
|
1433
|
-
error,
|
|
1434
|
-
onSubmit: handleSubmit,
|
|
1435
|
-
onCancel,
|
|
1436
|
-
onOpenChange,
|
|
1437
|
-
references
|
|
1438
|
-
}));
|
|
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
|
+
}
|
|
1439
1531
|
};
|
|
1440
1532
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/processor.ts";
|
|
1441
1533
|
var defaultOptions = {
|
|
1442
|
-
model:
|
|
1534
|
+
model: import_ai4.DEFAULT_EDGE_MODEL,
|
|
1443
1535
|
systemPrompt: "you are a helpful assistant"
|
|
1444
1536
|
};
|
|
1445
1537
|
var ChatProcessor = class {
|
|
@@ -1461,7 +1553,7 @@ var ChatProcessor = class {
|
|
|
1461
1553
|
const current = messages.pop();
|
|
1462
1554
|
(0, import_invariant4.invariant)(current, void 0, {
|
|
1463
1555
|
F: __dxlog_file6,
|
|
1464
|
-
L:
|
|
1556
|
+
L: 79,
|
|
1465
1557
|
S: this,
|
|
1466
1558
|
A: [
|
|
1467
1559
|
"current",
|
|
@@ -1480,6 +1572,24 @@ var ChatProcessor = class {
|
|
|
1480
1572
|
}
|
|
1481
1573
|
return messages;
|
|
1482
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
|
+
};
|
|
1483
1593
|
}
|
|
1484
1594
|
get tools() {
|
|
1485
1595
|
return this._tools;
|
|
@@ -1517,6 +1627,35 @@ var ChatProcessor = class {
|
|
|
1517
1627
|
message2
|
|
1518
1628
|
];
|
|
1519
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
|
+
});
|
|
1520
1659
|
try {
|
|
1521
1660
|
const messages = await this._session.run({
|
|
1522
1661
|
client: this._ai,
|
|
@@ -1527,26 +1666,7 @@ var ChatProcessor = class {
|
|
|
1527
1666
|
prompt: message,
|
|
1528
1667
|
systemPrompt: this._options.systemPrompt,
|
|
1529
1668
|
extensions: this._extensions,
|
|
1530
|
-
artifactDiffResolver:
|
|
1531
|
-
const space = this._extensions?.space;
|
|
1532
|
-
if (!space) {
|
|
1533
|
-
return /* @__PURE__ */ new Map();
|
|
1534
|
-
}
|
|
1535
|
-
const versions = /* @__PURE__ */ new Map();
|
|
1536
|
-
await Promise.all(artifacts.map(async (artifact) => {
|
|
1537
|
-
const { objects: [object] } = await space.db.query({
|
|
1538
|
-
id: artifact.id
|
|
1539
|
-
}).run();
|
|
1540
|
-
if (!object) {
|
|
1541
|
-
return;
|
|
1542
|
-
}
|
|
1543
|
-
versions.set(artifact.id, {
|
|
1544
|
-
version: (0, import_echo4.getVersion)(object),
|
|
1545
|
-
diff: `Current state: ${JSON.stringify(object)}`
|
|
1546
|
-
});
|
|
1547
|
-
}));
|
|
1548
|
-
return versions;
|
|
1549
|
-
},
|
|
1669
|
+
artifactDiffResolver: this._artifactDiffResolver,
|
|
1550
1670
|
generationOptions: {
|
|
1551
1671
|
model: this._options.model
|
|
1552
1672
|
}
|
|
@@ -1555,7 +1675,7 @@ var ChatProcessor = class {
|
|
|
1555
1675
|
messages
|
|
1556
1676
|
}, {
|
|
1557
1677
|
F: __dxlog_file6,
|
|
1558
|
-
L:
|
|
1678
|
+
L: 175,
|
|
1559
1679
|
S: this,
|
|
1560
1680
|
C: (f, a) => f(...a)
|
|
1561
1681
|
});
|
|
@@ -1563,7 +1683,7 @@ var ChatProcessor = class {
|
|
|
1563
1683
|
} catch (err) {
|
|
1564
1684
|
import_log6.log.catch(err, void 0, {
|
|
1565
1685
|
F: __dxlog_file6,
|
|
1566
|
-
L:
|
|
1686
|
+
L: 178,
|
|
1567
1687
|
S: this,
|
|
1568
1688
|
C: (f, a) => f(...a)
|
|
1569
1689
|
});
|
|
@@ -1588,7 +1708,7 @@ var ChatProcessor = class {
|
|
|
1588
1708
|
async cancel() {
|
|
1589
1709
|
import_log6.log.info("cancelling...", void 0, {
|
|
1590
1710
|
F: __dxlog_file6,
|
|
1591
|
-
L:
|
|
1711
|
+
L: 196,
|
|
1592
1712
|
S: this,
|
|
1593
1713
|
C: (f, a) => f(...a)
|
|
1594
1714
|
});
|
|
@@ -1610,11 +1730,11 @@ var AIServiceOverloadedError = class extends Error {
|
|
|
1610
1730
|
this.code = "AI_SERVICE_OVERLOADED";
|
|
1611
1731
|
}
|
|
1612
1732
|
};
|
|
1613
|
-
var AiClient = (0,
|
|
1614
|
-
var AppGraphBuilder = (0,
|
|
1615
|
-
var IntentResolver = (0,
|
|
1616
|
-
var ReactSurface = (0,
|
|
1617
|
-
var Settings = (0,
|
|
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"));
|
|
1618
1738
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
|
|
1619
1739
|
var useChatProcessor = ({
|
|
1620
1740
|
chat,
|
|
@@ -1624,108 +1744,108 @@ var useChatProcessor = ({
|
|
|
1624
1744
|
part,
|
|
1625
1745
|
associatedArtifact
|
|
1626
1746
|
}) => {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
(0,
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
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
|
+
}, [
|
|
1666
1797
|
dispatch,
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
dispatch,
|
|
1676
|
-
globalTools,
|
|
1677
|
-
space,
|
|
1678
|
-
chatId,
|
|
1679
|
-
serviceTools,
|
|
1680
|
-
functions
|
|
1681
|
-
]);
|
|
1682
|
-
const systemPrompt = (0, import_react8.useMemo)(() => (0, import_artifact4.createSystemPrompt)({
|
|
1683
|
-
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}
|
|
1684
1806
|
${definition.instructions}`),
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
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,
|
|
1701
1831
|
model,
|
|
1702
1832
|
systemPrompt
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
extensions,
|
|
1709
|
-
model,
|
|
1710
|
-
systemPrompt
|
|
1711
|
-
]);
|
|
1712
|
-
return processor;
|
|
1833
|
+
]);
|
|
1834
|
+
return processor;
|
|
1835
|
+
} finally {
|
|
1836
|
+
_effect.f();
|
|
1837
|
+
}
|
|
1713
1838
|
};
|
|
1714
|
-
var registerTriggersMutex = new import_async2.Mutex();
|
|
1715
1839
|
var useMessageQueue = (chat) => {
|
|
1716
|
-
const space = (0,
|
|
1717
|
-
const queueDxn = (0,
|
|
1718
|
-
const dxn = space && chat?.
|
|
1719
|
-
return dxn ?
|
|
1720
|
-
import_keys3.QueueSubspaceTags.DATA,
|
|
1721
|
-
space.id,
|
|
1722
|
-
dxn.parts.at(-1)
|
|
1723
|
-
]) : void 0;
|
|
1840
|
+
const space = (0, import_echo6.getSpace)(chat);
|
|
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;
|
|
1724
1844
|
}, [
|
|
1725
1845
|
space,
|
|
1726
|
-
chat?.
|
|
1846
|
+
chat?.queue.dxn
|
|
1727
1847
|
]);
|
|
1728
|
-
return (0,
|
|
1848
|
+
return (0, import_echo6.useQueue)(queueDxn);
|
|
1729
1849
|
};
|
|
1730
1850
|
var AMADEUS_AUTH = {
|
|
1731
1851
|
type: "oauth",
|
|
@@ -1743,7 +1863,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
|
|
|
1743
1863
|
}
|
|
1744
1864
|
};
|
|
1745
1865
|
var TEST_SERVICES = [
|
|
1746
|
-
(0,
|
|
1866
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1747
1867
|
serviceId: "amadeus.com/service/FlightSearch",
|
|
1748
1868
|
name: "Amadeus Flight Search",
|
|
1749
1869
|
description: "Search for local and international flights.",
|
|
@@ -1756,7 +1876,7 @@ var TEST_SERVICES = [
|
|
|
1756
1876
|
}
|
|
1757
1877
|
]
|
|
1758
1878
|
}),
|
|
1759
|
-
(0,
|
|
1879
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1760
1880
|
serviceId: "amadeus.com/service/HotelSearch",
|
|
1761
1881
|
name: "Amadeus Hotel Search",
|
|
1762
1882
|
description: "Search for local and international hotels.",
|
|
@@ -1769,7 +1889,7 @@ var TEST_SERVICES = [
|
|
|
1769
1889
|
}
|
|
1770
1890
|
]
|
|
1771
1891
|
}),
|
|
1772
|
-
(0,
|
|
1892
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1773
1893
|
serviceId: "visualcrossing.com/service/Weather",
|
|
1774
1894
|
name: "Visual Crossing Weather",
|
|
1775
1895
|
description: "Search for global weather forecasts.",
|
|
@@ -1783,7 +1903,7 @@ var TEST_SERVICES = [
|
|
|
1783
1903
|
]
|
|
1784
1904
|
}),
|
|
1785
1905
|
// TODO(burdon): Needs auth.
|
|
1786
|
-
(0,
|
|
1906
|
+
(0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1787
1907
|
serviceId: "abstractapi.com/service/GeoLocation",
|
|
1788
1908
|
name: "Abstract GeoLocation",
|
|
1789
1909
|
description: "Get the location of any IP address.",
|
|
@@ -1800,11 +1920,11 @@ var TEST_SERVICES = [
|
|
|
1800
1920
|
//
|
|
1801
1921
|
...Array.from({
|
|
1802
1922
|
length: 20
|
|
1803
|
-
}, (_, i) => (0,
|
|
1923
|
+
}, (_, i) => (0, import_echo_schema4.create)(import_chunk_RXPA2C2A.ServiceType, {
|
|
1804
1924
|
serviceId: `example.com/service/test-${i}`,
|
|
1805
1925
|
name: `Test ${i}`,
|
|
1806
1926
|
description: `Test ${i}`,
|
|
1807
|
-
category: Object.keys(
|
|
1927
|
+
category: Object.keys(import_chunk_RXPA2C2A.categoryIcons)[Math.floor(Math.random() * Object.keys(import_chunk_RXPA2C2A.categoryIcons).length)],
|
|
1808
1928
|
interfaces: [
|
|
1809
1929
|
{
|
|
1810
1930
|
kind: "api",
|
|
@@ -1816,38 +1936,36 @@ var TEST_SERVICES = [
|
|
|
1816
1936
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts";
|
|
1817
1937
|
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
1818
1938
|
var useContextProvider = (space) => {
|
|
1819
|
-
const artifactDefinitions = (0,
|
|
1820
|
-
return (0,
|
|
1939
|
+
const artifactDefinitions = (0, import_app_framework6.useCapabilities)(import_app_framework6.Capabilities.ArtifactDefinition);
|
|
1940
|
+
return (0, import_react12.useMemo)(() => {
|
|
1821
1941
|
if (!space) {
|
|
1822
1942
|
return void 0;
|
|
1823
1943
|
}
|
|
1824
1944
|
return {
|
|
1825
1945
|
query: async ({ query }) => {
|
|
1826
1946
|
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
1827
|
-
const { objects } = await space.db.query(
|
|
1947
|
+
const { objects } = await space.db.query(import_echo7.Filter.or(...artifactSchemas.map((schema) => import_echo7.Filter.type(schema)))).run();
|
|
1828
1948
|
return objects.map((object) => {
|
|
1829
|
-
|
|
1949
|
+
import_log8.log.info("object", {
|
|
1830
1950
|
object,
|
|
1831
|
-
label: (0,
|
|
1951
|
+
label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object)
|
|
1832
1952
|
}, {
|
|
1833
1953
|
F: __dxlog_file8,
|
|
1834
|
-
L:
|
|
1954
|
+
L: 38,
|
|
1835
1955
|
S: void 0,
|
|
1836
1956
|
C: (f, a) => f(...a)
|
|
1837
1957
|
});
|
|
1838
1958
|
return object;
|
|
1839
|
-
}).filter((object) => stringMatch(query, (0,
|
|
1840
|
-
uri: (0,
|
|
1841
|
-
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) ?? ""
|
|
1842
1962
|
}));
|
|
1843
1963
|
},
|
|
1844
1964
|
resolveMetadata: async ({ uri }) => {
|
|
1845
|
-
const object = await space.db.query(
|
|
1846
|
-
id: uri
|
|
1847
|
-
}).first();
|
|
1965
|
+
const object = await space.db.query(import_echo7.Filter.ids(uri)).first();
|
|
1848
1966
|
return {
|
|
1849
1967
|
uri,
|
|
1850
|
-
label: (0,
|
|
1968
|
+
label: (0, import_echo_schema5.getLabel)(import_echo8.Obj.getSchema(object), object) ?? ""
|
|
1851
1969
|
};
|
|
1852
1970
|
}
|
|
1853
1971
|
};
|
|
@@ -1858,100 +1976,106 @@ var useContextProvider = (space) => {
|
|
|
1858
1976
|
};
|
|
1859
1977
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
|
|
1860
1978
|
var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, onOpenChange, ...props }) => {
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
if (
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
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
|
+
}
|
|
1889
2009
|
}
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
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, {
|
|
1899
2027
|
F: __dxlog_file9,
|
|
1900
|
-
L:
|
|
2028
|
+
L: 71,
|
|
1901
2029
|
S: void 0,
|
|
1902
|
-
|
|
2030
|
+
A: [
|
|
2031
|
+
"messageQueue",
|
|
2032
|
+
""
|
|
2033
|
+
]
|
|
1903
2034
|
});
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
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();
|
|
1920
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
|
|
1921
2067
|
});
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
messageQueue,
|
|
1926
|
-
onOpenChange
|
|
1927
|
-
]);
|
|
1928
|
-
const handleCancel = (0, import_react7.useCallback)(() => {
|
|
1929
|
-
if (processor.streaming.value) {
|
|
1930
|
-
void processor.cancel();
|
|
1931
|
-
}
|
|
1932
|
-
}, [
|
|
1933
|
-
processor
|
|
1934
|
-
]);
|
|
1935
|
-
return /* @__PURE__ */ import_react7.default.createElement(Thread, {
|
|
1936
|
-
classNames,
|
|
1937
|
-
space,
|
|
1938
|
-
messages,
|
|
1939
|
-
processing: processor.streaming.value,
|
|
1940
|
-
error: processor.error.value,
|
|
1941
|
-
tools: processor.tools,
|
|
1942
|
-
contextProvider,
|
|
1943
|
-
onSubmit: handleSubmit,
|
|
1944
|
-
onCancel: handleCancel,
|
|
1945
|
-
onPrompt: handleSubmit,
|
|
1946
|
-
onOpenChange,
|
|
1947
|
-
...props
|
|
1948
|
-
});
|
|
2068
|
+
} finally {
|
|
2069
|
+
_effect.f();
|
|
2070
|
+
}
|
|
1949
2071
|
};
|
|
1950
2072
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1951
2073
|
0 && (module.exports = {
|
|
1952
2074
|
AiClient,
|
|
1953
2075
|
AppGraphBuilder,
|
|
1954
2076
|
IntentResolver,
|
|
2077
|
+
Prompt,
|
|
2078
|
+
PromptBar,
|
|
1955
2079
|
ReactSurface,
|
|
1956
2080
|
Settings,
|
|
1957
2081
|
Thread,
|
|
@@ -1959,4 +2083,4 @@ var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, o
|
|
|
1959
2083
|
Toolbox,
|
|
1960
2084
|
ToolboxContainer
|
|
1961
2085
|
});
|
|
1962
|
-
//# sourceMappingURL=chunk-
|
|
2086
|
+
//# sourceMappingURL=chunk-H4A42LNR.cjs.map
|