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