@dxos/plugin-assistant 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
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/AssistantSettings-2LFAG5OQ.mjs +93 -0
- package/dist/lib/browser/AssistantSettings-2LFAG5OQ.mjs.map +7 -0
- package/dist/lib/browser/BlueprintArticle-CCS25MNW.mjs +36 -0
- package/dist/lib/browser/BlueprintArticle-CCS25MNW.mjs.map +7 -0
- package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs +202 -0
- package/dist/lib/browser/ChatCompanion-UGD4V34A.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-ZGRSZ5EU.mjs +12 -0
- package/dist/lib/browser/ChatContainer-ZGRSZ5EU.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-AET7GVIB.mjs +85 -0
- package/dist/lib/browser/ChatDialog-AET7GVIB.mjs.map +7 -0
- package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs +91 -0
- package/dist/lib/browser/ProjectArticle-QDBTIFNE.mjs.map +7 -0
- package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs +194 -0
- package/dist/lib/browser/ProjectSettings-R6RRARLO.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-USQO4WX6.mjs +71 -0
- package/dist/lib/browser/PromptArticle-USQO4WX6.mjs.map +7 -0
- package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs +122 -0
- package/dist/lib/browser/TriggerStatus-65X3EUSN.mjs.map +7 -0
- package/dist/lib/browser/ai-service-CY2BYPH6.mjs +22 -0
- package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs +234 -0
- package/dist/lib/browser/app-graph-builder-SFYYUKTT.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-RB5RHZZM.mjs +34 -0
- package/dist/lib/browser/blueprint-definition-RB5RHZZM.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-7DXYAXLZ.mjs +230 -0
- package/dist/lib/browser/chunk-7DXYAXLZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-EXVT7D4B.mjs +23 -0
- package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-JYY5AD65.mjs +286 -0
- package/dist/lib/browser/chunk-JYY5AD65.mjs.map +7 -0
- package/dist/lib/browser/chunk-LEXIQDXZ.mjs +26 -0
- package/dist/lib/browser/chunk-LEXIQDXZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-RU4G5NY4.mjs +69 -0
- package/dist/lib/browser/chunk-RU4G5NY4.mjs.map +7 -0
- package/dist/lib/browser/chunk-UUA6GNGG.mjs +2125 -0
- package/dist/lib/browser/chunk-UUA6GNGG.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs +21 -0
- package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +299 -161
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs +20 -0
- package/dist/lib/browser/local-model-resolver-CGRQH37T.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs +136 -0
- package/dist/lib/browser/operation-resolver-ELXDQZEG.mjs.map +7 -0
- package/dist/lib/browser/react-surface-KYQSZO2I.mjs +144 -0
- package/dist/lib/browser/react-surface-KYQSZO2I.mjs.map +7 -0
- package/dist/lib/browser/repair-ZFZWZALX.mjs +52 -0
- package/dist/lib/browser/repair-ZFZWZALX.mjs.map +7 -0
- package/dist/lib/browser/settings-YREVQAZ5.mjs +33 -0
- package/dist/lib/browser/settings-YREVQAZ5.mjs.map +7 -0
- package/dist/lib/browser/state-MPG42ZO4.mjs +26 -0
- package/dist/lib/browser/state-MPG42ZO4.mjs.map +7 -0
- package/dist/lib/browser/toolkit-XRSBBB3L.mjs +16 -0
- package/dist/lib/browser/toolkit-XRSBBB3L.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +11 -4
- package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs +94 -0
- package/dist/lib/node-esm/AssistantSettings-QWFEMJG7.mjs.map +7 -0
- package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs +37 -0
- package/dist/lib/node-esm/BlueprintArticle-SNEN6LOY.mjs.map +7 -0
- package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs +203 -0
- package/dist/lib/node-esm/ChatCompanion-NP4R5BFE.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-IFHDIFJH.mjs +13 -0
- package/dist/lib/node-esm/ChatContainer-IFHDIFJH.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs +86 -0
- package/dist/lib/node-esm/ChatDialog-UZNQBTKZ.mjs.map +7 -0
- package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs +92 -0
- package/dist/lib/node-esm/ProjectArticle-BCIBESJN.mjs.map +7 -0
- package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs +195 -0
- package/dist/lib/node-esm/ProjectSettings-Q5QY6BYS.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs +72 -0
- package/dist/lib/node-esm/PromptArticle-PGMJMQK7.mjs.map +7 -0
- package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs +123 -0
- package/dist/lib/node-esm/TriggerStatus-UR5S7PXJ.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs +23 -0
- package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs +235 -0
- package/dist/lib/node-esm/app-graph-builder-E25JXI34.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-L7XKRYIW.mjs +35 -0
- package/dist/lib/node-esm/blueprint-definition-L7XKRYIW.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3QBVFAYO.mjs +28 -0
- package/dist/lib/node-esm/chunk-3QBVFAYO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6NCLKQCL.mjs +70 -0
- package/dist/lib/node-esm/chunk-6NCLKQCL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs +2126 -0
- package/dist/lib/node-esm/chunk-GZ4ERNT2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JMBYVUD6.mjs +288 -0
- package/dist/lib/node-esm/chunk-JMBYVUD6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MWYYLALM.mjs +231 -0
- package/dist/lib/node-esm/chunk-MWYYLALM.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs +25 -0
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs +22 -0
- package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +299 -161
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs +21 -0
- package/dist/lib/node-esm/local-model-resolver-FFDAKOXN.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs +137 -0
- package/dist/lib/node-esm/operation-resolver-Q5GNP2GH.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs +145 -0
- package/dist/lib/node-esm/react-surface-JJRGVGKD.mjs.map +7 -0
- package/dist/lib/node-esm/repair-LXFVOK4B.mjs +53 -0
- package/dist/lib/node-esm/repair-LXFVOK4B.mjs.map +7 -0
- package/dist/lib/node-esm/settings-N452OW6Y.mjs +34 -0
- package/dist/lib/node-esm/settings-N452OW6Y.mjs.map +7 -0
- package/dist/lib/node-esm/state-WHZFKIEL.mjs +27 -0
- package/dist/lib/node-esm/state-WHZFKIEL.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs +17 -0
- package/dist/lib/node-esm/toolkit-5IWGLUF4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +11 -4
- package/dist/types/src/AssistantPlugin.d.ts +2 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts +6 -0
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-service/index.d.ts +3 -0
- package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +7 -0
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +11 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +13 -0
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/repair/index.d.ts +3 -0
- package/dist/types/src/capabilities/repair/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/repair/repair.d.ts +6 -0
- package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +15 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +18 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +11 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +13 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +6 -0
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +39 -22
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +10 -1
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +5 -6
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +13 -11
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +285 -71
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +3 -6
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +431 -7
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +13 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +428 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +21 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +9 -15
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +432 -5
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/index.d.ts +2 -0
- package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -8
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts +8 -0
- package/dist/types/src/containers/AssistantSettings/AssistantSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AssistantSettings/index.d.ts +3 -0
- package/dist/types/src/containers/AssistantSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts +3 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +12 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +18 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts +3 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
- package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts +3 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/Project/ProjectArticle.d.ts +7 -0
- package/dist/types/src/containers/Project/ProjectArticle.d.ts.map +1 -0
- package/dist/types/src/containers/Project/ProjectSettings.d.ts +6 -0
- package/dist/types/src/containers/Project/ProjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/Project/index.d.ts +7 -0
- package/dist/types/src/containers/Project/index.d.ts.map +1 -0
- package/dist/types/src/containers/Project/triggers.d.ts +6 -0
- package/dist/types/src/containers/Project/triggers.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts +3 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +10 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +8 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +10 -20
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +7 -8
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +4 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +3 -3
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +79 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- package/dist/types/src/processor/update-name.d.ts +10 -0
- package/dist/types/src/processor/update-name.d.ts.map +1 -0
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +8 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +2 -2
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +376 -37
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +20 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +93 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +33 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +6 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +14 -213
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +125 -96
- package/src/AssistantPlugin.tsx +162 -88
- package/src/blueprints/assistant/blueprint.conversations.json +1 -0
- package/src/blueprints/assistant/blueprint.test.ts +48 -0
- package/src/blueprints/assistant/blueprint.ts +27 -0
- package/src/blueprints/assistant/index.ts +5 -0
- package/src/{components/SequenceEditor → blueprints}/index.ts +1 -1
- package/src/capabilities/ai-service/ai-service.ts +30 -0
- package/src/capabilities/ai-service/index.ts +7 -0
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +198 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +48 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +33 -0
- package/src/capabilities/edge-model-resolver/index.ts +7 -0
- package/src/capabilities/index.ts +11 -6
- package/src/capabilities/local-model-resolver/index.ts +7 -0
- package/src/capabilities/local-model-resolver/local-model-resolver.ts +38 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +121 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +121 -0
- package/src/capabilities/repair/index.ts +7 -0
- package/src/capabilities/repair/repair.ts +69 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +31 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +27 -0
- package/src/capabilities/toolkit/index.ts +7 -0
- package/src/capabilities/toolkit/toolkit.ts +15 -0
- package/src/components/Chat/Chat.tsx +278 -198
- package/src/components/Chat/events.ts +14 -1
- package/src/components/ChatProgress/ChatProgress.tsx +53 -0
- package/src/components/ChatProgress/index.ts +5 -0
- package/src/components/ChatPrompt/ChatActions.tsx +20 -28
- package/src/components/ChatPrompt/ChatOptions.tsx +258 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +42 -38
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +124 -117
- package/src/components/ChatThread/ChatThread.tsx +75 -36
- package/src/components/ChatThread/Link.tsx +26 -0
- package/src/components/ChatThread/registry.tsx +207 -0
- package/src/components/ChatThread/sync.test.ts +99 -0
- package/src/components/ChatThread/sync.ts +160 -0
- package/src/components/ChatThread/testing/thread.md +37 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +41 -20
- package/src/components/TemplateEditor/TemplateEditor.tsx +33 -52
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +30 -17
- package/src/components/TemplateEditor/TemplateForm.tsx +85 -36
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/ToolBlock/ToolBlock.tsx +143 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +19 -29
- package/src/components/Toolbox/Toolbox.tsx +68 -100
- package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
- package/src/components/Typewriter/Typewriter.stories.tsx +86 -0
- package/src/components/Typewriter/Typewriter.tsx +54 -0
- package/src/components/Typewriter/assistant-extension.tsx +142 -0
- package/src/components/Typewriter/index.ts +5 -0
- package/src/components/index.ts +0 -13
- package/src/containers/AssistantSettings/AssistantSettings.tsx +120 -0
- package/src/containers/AssistantSettings/index.ts +7 -0
- package/src/containers/BlueprintArticle/BlueprintArticle.tsx +30 -0
- package/src/containers/BlueprintArticle/index.ts +7 -0
- package/src/containers/ChatCompanion/ChatCompanion.tsx +225 -0
- package/src/containers/ChatCompanion/index.ts +7 -0
- package/src/containers/ChatContainer/ChatContainer.tsx +69 -0
- package/src/containers/ChatContainer/index.ts +7 -0
- package/src/containers/ChatDialog/ChatDialog.tsx +72 -0
- package/src/containers/ChatDialog/index.ts +7 -0
- package/src/containers/Project/ProjectArticle.tsx +117 -0
- package/src/containers/Project/ProjectSettings.tsx +118 -0
- package/src/containers/Project/index.ts +16 -0
- package/src/containers/Project/triggers.ts +131 -0
- package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
- package/src/containers/PromptArticle/index.ts +7 -0
- package/src/containers/TriggerStatus/TriggerStatus.tsx +150 -0
- package/src/containers/TriggerStatus/index.ts +7 -0
- package/src/containers/index.ts +15 -0
- package/src/hooks/index.ts +8 -4
- package/src/hooks/useBlueprintRegistry.ts +108 -0
- package/src/hooks/useChatProcessor.ts +40 -105
- package/src/hooks/useChatServices.ts +31 -75
- package/src/hooks/useChatToolbarActions.ts +122 -0
- package/src/hooks/useContextBinder.ts +32 -0
- package/src/hooks/useContextObjects.ts +46 -0
- package/src/hooks/useFilteredTypes.ts +37 -0
- package/src/hooks/useFlush.ts +35 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +44 -0
- package/src/hooks/useReferencesProvider.ts +12 -13
- package/src/index.ts +3 -1
- package/src/meta.ts +11 -8
- package/src/processor/index.ts +7 -0
- package/src/{hooks → processor}/presets.ts +16 -8
- package/src/processor/processor.test.ts +73 -0
- package/src/processor/processor.ts +296 -0
- package/src/processor/update-name.ts +58 -0
- package/src/queue-logger.ts +17 -18
- package/src/testing/index.ts +1 -1
- package/src/testing/test-generator.ts +262 -0
- package/src/testing/test-sequence.ts +5 -30
- package/src/testing/test-services.ts +10 -14
- package/src/translations.ts +71 -28
- package/src/types/Assistant.ts +28 -0
- package/src/types/AssistantAction.ts +76 -0
- package/src/types/capabilities.ts +27 -0
- package/src/types/defs.ts +5 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +9 -1
- package/src/types/service.ts +27 -16
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs +0 -54
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs +0 -72
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +0 -162
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs +0 -27
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs +0 -223
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +0 -7
- package/dist/lib/browser/chunk-AEAEKWOC.mjs +0 -98
- package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +0 -7
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs +0 -108
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-FDCJSQYF.mjs.map +0 -7
- package/dist/lib/browser/chunk-JQBVLTM5.mjs +0 -158
- package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OWY4CUQY.mjs +0 -2245
- package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +0 -60
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-66VY37YQ.mjs +0 -150
- package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +0 -7
- package/dist/lib/browser/settings-2DGP3UTS.mjs +0 -22
- package/dist/lib/browser/settings-2DGP3UTS.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +0 -55
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs +0 -73
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +0 -163
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs +0 -28
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs +0 -224
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs +0 -99
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs +0 -159
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs +0 -109
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs +0 -2246
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +0 -61
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs +0 -151
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +0 -7
- package/dist/lib/node-esm/settings-47RYZOU4.mjs +0 -23
- package/dist/lib/node-esm/settings-47RYZOU4.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +0 -6
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +0 -1
- package/dist/types/src/components/AssistantSettings/index.d.ts +0 -2
- package/dist/types/src/components/AssistantSettings/index.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts +0 -11
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
- package/dist/types/src/components/PromptSettings.d.ts +0 -6
- package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
- package/dist/types/src/components/SequenceContainer.d.ts +0 -8
- package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -8
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/TemplateContainer.d.ts +0 -8
- package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.d.ts +0 -86
- package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/presets.d.ts.map +0 -1
- package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/stories/Chat.stories.d.ts +0 -249
- package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -3
- package/dist/types/src/testing/test-functions.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -88
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -253
- package/src/capabilities/intent-resolver.ts +0 -58
- package/src/capabilities/react-surface.tsx +0 -138
- package/src/capabilities/settings.ts +0 -19
- package/src/components/AssistantSettings/AssistantSettings.tsx +0 -105
- package/src/components/AssistantSettings/index.ts +0 -5
- package/src/components/ChatContainer.tsx +0 -45
- package/src/components/ChatDialog.tsx +0 -64
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/ChatThread/ChatMessage.tsx +0 -268
- package/src/components/ChatThread/ToolBlock.tsx +0 -121
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/components/PromptSettings.tsx +0 -89
- package/src/components/SequenceContainer.tsx +0 -132
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/components/TemplateContainer.tsx +0 -24
- package/src/events.ts +0 -11
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/chat-processor.ts +0 -314
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -81
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/stories/Chat.stories.tsx +0 -378
- package/src/testing/test-functions.ts +0 -11
- package/src/tools/function.ts +0 -46
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -217
- package/src/tools/openapi.ts +0 -338
- package/src/types/schema.ts +0 -95
- package/src/typings.d.ts +0 -9
|
@@ -2,61 +2,97 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import React, { Fragment, useEffect } from 'react';
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { Fragment, useCallback, useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type Template } from '@dxos/blueprints';
|
|
9
|
+
import { type Obj } from '@dxos/echo';
|
|
9
10
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { attentionSurface, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
11
11
|
import { isNonNullable } from '@dxos/util';
|
|
12
12
|
|
|
13
|
-
import { TemplateEditor } from './TemplateEditor';
|
|
14
13
|
import { meta } from '../../meta';
|
|
15
14
|
|
|
15
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Callback type for mutating template within a parent object's Obj.change context.
|
|
19
|
+
*/
|
|
20
|
+
export type TemplateChangeCallback = (mutate: (template: Obj.Mutable<Template.Template>) => void) => void;
|
|
21
|
+
|
|
16
22
|
export type TemplateFormProps = {
|
|
23
|
+
id: string;
|
|
17
24
|
template: Template.Template;
|
|
18
25
|
schema?: Schema.Schema<any, any, any>;
|
|
19
26
|
commandEditable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Callback to mutate the template. Should wrap mutations in parent's Obj.change.
|
|
29
|
+
* If not provided, the component is read-only.
|
|
30
|
+
*/
|
|
31
|
+
onChange?: TemplateChangeCallback;
|
|
20
32
|
};
|
|
21
33
|
|
|
22
|
-
export const TemplateForm = ({ template, commandEditable = true }: TemplateFormProps) => {
|
|
34
|
+
export const TemplateForm = ({ id, template, commandEditable = true, onChange }: TemplateFormProps) => {
|
|
23
35
|
const { t } = useTranslation(meta.id);
|
|
24
|
-
usePromptInputs(template);
|
|
36
|
+
usePromptInputs(template, onChange);
|
|
37
|
+
|
|
38
|
+
const handleInputKindChange = useCallback(
|
|
39
|
+
(inputName: string, kind: Template.InputKind) => {
|
|
40
|
+
onChange?.((t) => {
|
|
41
|
+
const input = t.inputs?.find((i) => i?.name === inputName);
|
|
42
|
+
if (input) {
|
|
43
|
+
input.kind = kind;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
[onChange],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const handleInputDefaultChange = useCallback(
|
|
51
|
+
(inputName: string, value: string) => {
|
|
52
|
+
onChange?.((t) => {
|
|
53
|
+
const input = t.inputs?.find((i) => i?.name === inputName);
|
|
54
|
+
if (input) {
|
|
55
|
+
input.default = value;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
[onChange],
|
|
60
|
+
);
|
|
25
61
|
|
|
26
62
|
return (
|
|
27
|
-
<div className=
|
|
63
|
+
<div className='flex flex-col w-full overflow-hidden gap-4'>
|
|
28
64
|
{/* {commandEditable && (
|
|
29
65
|
<div className='flex items-center pl-4'>
|
|
30
66
|
<span className='text-neutral-500'>/</span>
|
|
31
67
|
<Input.Root>
|
|
32
68
|
<Input.TextInput
|
|
33
69
|
placeholder={t('command placeholder')}
|
|
34
|
-
classNames='
|
|
70
|
+
classNames='w-full bg-transparent m-2'
|
|
35
71
|
value={template.command ?? ''}
|
|
36
72
|
onChange={(event) => {
|
|
37
|
-
|
|
73
|
+
onChange?.((t) => {
|
|
74
|
+
t.command = event.target.value.replace(/\w/g, '');
|
|
75
|
+
});
|
|
38
76
|
}}
|
|
39
77
|
/>
|
|
40
78
|
</Input.Root>
|
|
41
79
|
</div>
|
|
42
80
|
)} */}
|
|
43
81
|
|
|
44
|
-
<TemplateEditor template={template} classNames=
|
|
82
|
+
<TemplateEditor id={id} template={template} classNames='bg-base-surface min-h-[120px]' />
|
|
45
83
|
|
|
46
84
|
{(template.inputs?.length ?? 0) > 0 && (
|
|
47
85
|
<div className='grid grid-cols-[10rem_10rem_1fr] gap-1 items-center'>
|
|
48
86
|
{template.inputs?.filter(isNonNullable).map((input) => (
|
|
49
87
|
<Fragment key={input.name}>
|
|
50
|
-
<div className='
|
|
88
|
+
<div className='ps-3 text-blue-text'>{input.name}</div>
|
|
51
89
|
|
|
52
90
|
<Input.Root>
|
|
53
91
|
<Select.Root
|
|
54
92
|
value={input.kind}
|
|
55
|
-
onValueChange={(kind) =>
|
|
56
|
-
input.kind = kind as Template.InputKind;
|
|
57
|
-
}}
|
|
93
|
+
onValueChange={(kind) => handleInputKindChange(input.name, kind as Template.InputKind)}
|
|
58
94
|
>
|
|
59
|
-
<Select.TriggerButton placeholder='Type' classNames='
|
|
95
|
+
<Select.TriggerButton placeholder='Type' classNames='w-full' />
|
|
60
96
|
<Select.Portal>
|
|
61
97
|
<Select.Content>
|
|
62
98
|
<Select.Viewport>
|
|
@@ -66,6 +102,7 @@ export const TemplateForm = ({ template, commandEditable = true }: TemplateFormP
|
|
|
66
102
|
</Select.Option>
|
|
67
103
|
))}
|
|
68
104
|
</Select.Viewport>
|
|
105
|
+
<Select.Arrow />
|
|
69
106
|
</Select.Content>
|
|
70
107
|
</Select.Portal>
|
|
71
108
|
</Select.Root>
|
|
@@ -77,11 +114,9 @@ export const TemplateForm = ({ template, commandEditable = true }: TemplateFormP
|
|
|
77
114
|
<Input.Root>
|
|
78
115
|
<Input.TextInput
|
|
79
116
|
placeholder={t('command placeholder')}
|
|
80
|
-
classNames='
|
|
117
|
+
classNames='w-full bg-transparent'
|
|
81
118
|
value={input.default ?? ''}
|
|
82
|
-
onChange={(event) =>
|
|
83
|
-
input.default = event.target.value;
|
|
84
|
-
}}
|
|
119
|
+
onChange={(event) => handleInputDefaultChange(input.name, event.target.value)}
|
|
85
120
|
/>
|
|
86
121
|
</Input.Root>
|
|
87
122
|
</div>
|
|
@@ -133,13 +168,14 @@ const inputs: { kind: Template.InputKind; label: string }[] = [
|
|
|
133
168
|
|
|
134
169
|
export const NAME_REGEXP = /\{\{([\w-]+)\}\}/;
|
|
135
170
|
|
|
136
|
-
const usePromptInputs = (template: Template.Template) => {
|
|
171
|
+
const usePromptInputs = (template: Template.Template, onChange?: TemplateChangeCallback) => {
|
|
137
172
|
useEffect(() => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
template.inputs = []; // TODO(burdon): Required?
|
|
173
|
+
if (!onChange) {
|
|
174
|
+
return;
|
|
141
175
|
}
|
|
142
176
|
|
|
177
|
+
const text = template.source ?? '';
|
|
178
|
+
|
|
143
179
|
const regex = new RegExp(NAME_REGEXP, 'g');
|
|
144
180
|
const variables = new Set<string>([...(text.target?.content.matchAll(regex) ?? [])].map((m) => m[1]));
|
|
145
181
|
|
|
@@ -158,19 +194,32 @@ const usePromptInputs = (template: Template.Template) => {
|
|
|
158
194
|
|
|
159
195
|
// Match or create new inputs.
|
|
160
196
|
const values = unclaimed.values();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
next.name = name;
|
|
165
|
-
} else {
|
|
166
|
-
template.inputs?.push({ name });
|
|
197
|
+
onChange((t) => {
|
|
198
|
+
if (!t.inputs) {
|
|
199
|
+
t.inputs = [];
|
|
167
200
|
}
|
|
168
|
-
});
|
|
169
201
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
missing.forEach((name) => {
|
|
203
|
+
const next = values.next().value;
|
|
204
|
+
if (next) {
|
|
205
|
+
// Find the input in the mutable draft and update it.
|
|
206
|
+
const inputIndex = t.inputs!.findIndex((i) => i?.name === next.name);
|
|
207
|
+
if (inputIndex !== -1) {
|
|
208
|
+
t.inputs![inputIndex].name = name;
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
t.inputs!.push({ name });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Remove unclaimed (deleted) inputs.
|
|
216
|
+
// TODO(burdon): If user types incorrect name value, it will be deleted. Garbage collect?
|
|
217
|
+
for (const input of values) {
|
|
218
|
+
const inputIndex = t.inputs!.findIndex((i) => i?.name === input.name);
|
|
219
|
+
if (inputIndex !== -1) {
|
|
220
|
+
t.inputs!.splice(inputIndex, 1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}, [template.source, onChange]);
|
|
176
225
|
};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type CompletionContext,
|
|
7
|
+
type CompletionResult,
|
|
8
|
+
autocompletion,
|
|
9
|
+
completionKeymap,
|
|
10
|
+
} from '@codemirror/autocomplete';
|
|
11
|
+
import { type Extension, RangeSetBuilder } from '@codemirror/state';
|
|
12
|
+
import {
|
|
13
|
+
Decoration,
|
|
14
|
+
type DecorationSet,
|
|
15
|
+
type EditorView,
|
|
16
|
+
ViewPlugin,
|
|
17
|
+
type ViewUpdate,
|
|
18
|
+
WidgetType,
|
|
19
|
+
keymap,
|
|
20
|
+
} from '@codemirror/view';
|
|
21
|
+
|
|
22
|
+
import { Domino, mx } from '@dxos/ui';
|
|
23
|
+
|
|
24
|
+
export type HandlebarsOptions = {};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Simple Handlebars plugin for CodeMirror.
|
|
28
|
+
* Supports:
|
|
29
|
+
* - Comments: {{! comment }}
|
|
30
|
+
* - Commands: {{#command}} {{/command}}
|
|
31
|
+
* - Variables: {{var}}
|
|
32
|
+
* - Commands with variables: {{#each items}} {{/each}}
|
|
33
|
+
*/
|
|
34
|
+
export const handlebars = (_: HandlebarsOptions = {}): Extension => {
|
|
35
|
+
return [
|
|
36
|
+
handlebarsHighlightPlugin,
|
|
37
|
+
autocompletion({
|
|
38
|
+
activateOnTyping: true,
|
|
39
|
+
aboveCursor: true,
|
|
40
|
+
closeOnBlur: true,
|
|
41
|
+
override: [handlebarsCompletions],
|
|
42
|
+
}),
|
|
43
|
+
keymap.of(completionKeymap),
|
|
44
|
+
];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const regex = {
|
|
48
|
+
// {{! comment }}
|
|
49
|
+
comment: /\{\{!\s*[^}]*\}\}/g,
|
|
50
|
+
|
|
51
|
+
// {{var}}
|
|
52
|
+
brackets: /\{\{[^}]*\}\}/g,
|
|
53
|
+
|
|
54
|
+
// {{#command}} {{/command}}
|
|
55
|
+
command: /\{\{[#/]([^}]+)\}\}/g,
|
|
56
|
+
|
|
57
|
+
// {{var}}
|
|
58
|
+
var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
|
|
59
|
+
|
|
60
|
+
// @dxn:queue:data:xxx
|
|
61
|
+
dxn: /@?dxn:[\w@:]+/g,
|
|
62
|
+
|
|
63
|
+
// dxos.org/type/xxx
|
|
64
|
+
url: /[\w.-]+\.[\w.-]+\/[\w/]+/g,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const tagPadding = 'mx-0.5 px-1 rounded-xs';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* ViewPlugin that decorates Handlebars syntax.
|
|
71
|
+
*/
|
|
72
|
+
const handlebarsHighlightPlugin = ViewPlugin.fromClass(
|
|
73
|
+
class {
|
|
74
|
+
decorations: DecorationSet;
|
|
75
|
+
|
|
76
|
+
constructor(view: EditorView) {
|
|
77
|
+
this.decorations = this.buildDecorations(view);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
update(update: ViewUpdate) {
|
|
81
|
+
if (update.docChanged || update.viewportChanged || update.selectionSet) {
|
|
82
|
+
this.decorations = this.buildDecorations(update.view);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// NOTE: Decorations may clash with other extensions (e.g., markdown).
|
|
87
|
+
buildDecorations(view: EditorView) {
|
|
88
|
+
const selection = view.state.selection.main;
|
|
89
|
+
const decorations: Array<{
|
|
90
|
+
from: number;
|
|
91
|
+
to: number;
|
|
92
|
+
decoration: Decoration;
|
|
93
|
+
}> = [];
|
|
94
|
+
|
|
95
|
+
for (const { from, to } of view.visibleRanges) {
|
|
96
|
+
const text = view.state.doc.sliceString(from, to);
|
|
97
|
+
|
|
98
|
+
// Match DXN.
|
|
99
|
+
{
|
|
100
|
+
let match;
|
|
101
|
+
while ((match = regex.dxn.exec(text)) !== null) {
|
|
102
|
+
const start = from + match.index;
|
|
103
|
+
const end = start + match[0].length;
|
|
104
|
+
// Only show widget if selection doesn't overlap with the match range.
|
|
105
|
+
const overlaps = selection.to > start && selection.from <= end;
|
|
106
|
+
if (!overlaps) {
|
|
107
|
+
decorations.push({
|
|
108
|
+
from: start,
|
|
109
|
+
to: end,
|
|
110
|
+
decoration: Decoration.widget({
|
|
111
|
+
widget: new DXNWidget(match[0]),
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Match URLs.
|
|
119
|
+
{
|
|
120
|
+
let match;
|
|
121
|
+
while ((match = regex.url.exec(text)) !== null) {
|
|
122
|
+
const start = from + match.index;
|
|
123
|
+
const end = start + match[0].length;
|
|
124
|
+
decorations.push({
|
|
125
|
+
from: start,
|
|
126
|
+
to: end,
|
|
127
|
+
decoration: Decoration.mark({
|
|
128
|
+
class: mx('dx-tag--blue', tagPadding),
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Match brackets: {{ and }}.
|
|
135
|
+
{
|
|
136
|
+
let match;
|
|
137
|
+
while ((match = regex.brackets.exec(text)) !== null) {
|
|
138
|
+
const start = from + match.index;
|
|
139
|
+
const end = start + match[0].length;
|
|
140
|
+
decorations.push({
|
|
141
|
+
from: start,
|
|
142
|
+
to: end,
|
|
143
|
+
decoration: Decoration.mark({ class: 'text-subdued' }),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Match commands: {{#command}} and {{/command}}.
|
|
149
|
+
{
|
|
150
|
+
let match;
|
|
151
|
+
while ((match = regex.command.exec(text)) !== null) {
|
|
152
|
+
const start = from + match.index + 2;
|
|
153
|
+
let end = start + match[0].length - 4;
|
|
154
|
+
const text = view.state.doc.sliceString(start, end);
|
|
155
|
+
const parts = text.split(/\s+/);
|
|
156
|
+
if (parts.length > 1) {
|
|
157
|
+
const idx = start + parts[0].length;
|
|
158
|
+
decorations.push({
|
|
159
|
+
from: idx,
|
|
160
|
+
to: end,
|
|
161
|
+
decoration: Decoration.mark({ class: 'text-green-text' }),
|
|
162
|
+
});
|
|
163
|
+
end = idx;
|
|
164
|
+
}
|
|
165
|
+
decorations.push({
|
|
166
|
+
from: start,
|
|
167
|
+
to: end,
|
|
168
|
+
decoration: Decoration.mark({ class: 'text-blue-text' }),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Match variables: {{var}}.
|
|
174
|
+
{
|
|
175
|
+
let match;
|
|
176
|
+
while ((match = regex.var.exec(text)) !== null) {
|
|
177
|
+
const start = from + match.index + 2;
|
|
178
|
+
const end = start + match[0].length - 4;
|
|
179
|
+
decorations.push({
|
|
180
|
+
from: start,
|
|
181
|
+
to: end,
|
|
182
|
+
decoration: Decoration.mark({ class: 'text-green-text' }),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Sort decorations by position to satisfy RangeSetBuilder requirements.
|
|
189
|
+
decorations.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
190
|
+
|
|
191
|
+
// Add sorted decorations to builder.
|
|
192
|
+
const builder = new RangeSetBuilder<Decoration>();
|
|
193
|
+
for (const { from, to, decoration } of decorations) {
|
|
194
|
+
builder.add(from, to, decoration);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return builder.finish();
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
decorations: (v) => v.decorations,
|
|
202
|
+
},
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
class DXNWidget extends WidgetType {
|
|
206
|
+
constructor(private readonly _identifier: string) {
|
|
207
|
+
super();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
override ignoreEvent() {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
override eq(other: this) {
|
|
215
|
+
return this._identifier === other._identifier;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
override toDOM() {
|
|
219
|
+
const text = this._identifier
|
|
220
|
+
.split(':')
|
|
221
|
+
.map((part) => {
|
|
222
|
+
const len = 16;
|
|
223
|
+
const plen = 4;
|
|
224
|
+
if (part.length > len) {
|
|
225
|
+
return `[${part.slice(0, plen)}…${part.slice(-plen)}]`;
|
|
226
|
+
}
|
|
227
|
+
return part;
|
|
228
|
+
})
|
|
229
|
+
.join(':');
|
|
230
|
+
return Domino.of('span').classNames(mx('font-mono dx-tag--blue', tagPadding)).text(text).root;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// TODO(burdon): Pass in variables.
|
|
235
|
+
const variables = ['this'];
|
|
236
|
+
const commands = ['this', 'each', 'if', 'unless', 'with'];
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Provides completions for Handlebars variables.
|
|
240
|
+
*/
|
|
241
|
+
function handlebarsCompletions(context: CompletionContext): CompletionResult | null {
|
|
242
|
+
const match = context.matchBefore(/\{\{[^}]*/);
|
|
243
|
+
if (!match || match.from === match.to) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
let type = 'variable';
|
|
248
|
+
let text = match.text.slice(2);
|
|
249
|
+
let from = match.from + 2;
|
|
250
|
+
let matches = [];
|
|
251
|
+
if (text.startsWith('#') || text.startsWith('/')) {
|
|
252
|
+
const idx = text.lastIndexOf(' ');
|
|
253
|
+
if (idx !== -1) {
|
|
254
|
+
type = 'variable';
|
|
255
|
+
matches = variables;
|
|
256
|
+
text = text.slice(idx + 1);
|
|
257
|
+
from += idx + 1;
|
|
258
|
+
} else {
|
|
259
|
+
type = 'command';
|
|
260
|
+
text = text.slice(1);
|
|
261
|
+
matches = commands;
|
|
262
|
+
from += 1;
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
type = 'variable';
|
|
266
|
+
matches = variables;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const options = matches.filter((name) => name.startsWith(text)).map((name) => ({ type, label: name }));
|
|
270
|
+
return {
|
|
271
|
+
from,
|
|
272
|
+
options,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { syntaxTree } from '@codemirror/language';
|
|
6
|
+
import { type Extension, RangeSetBuilder } from '@codemirror/state';
|
|
7
|
+
import { Decoration, type DecorationSet, type EditorView, ViewPlugin, type ViewUpdate } from '@codemirror/view';
|
|
8
|
+
|
|
9
|
+
export type XmlOptions = {};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* XML decorator plugin for CodeMirror.
|
|
13
|
+
* Decorates XML tags with monospace font using the XML language grammar.
|
|
14
|
+
*/
|
|
15
|
+
export const xmlDecorator = (_: XmlOptions = {}): Extension => {
|
|
16
|
+
return [xmlDecoratorPlugin];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ViewPlugin that decorates XML tags using syntax tree.
|
|
21
|
+
*/
|
|
22
|
+
const xmlDecoratorPlugin = ViewPlugin.fromClass(
|
|
23
|
+
class {
|
|
24
|
+
decorations: DecorationSet;
|
|
25
|
+
|
|
26
|
+
constructor(view: EditorView) {
|
|
27
|
+
this.decorations = this.buildDecorations(view);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update(update: ViewUpdate) {
|
|
31
|
+
if (update.docChanged || update.viewportChanged) {
|
|
32
|
+
this.decorations = this.buildDecorations(update.view);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
buildDecorations(view: EditorView) {
|
|
37
|
+
const builder = new RangeSetBuilder<Decoration>();
|
|
38
|
+
|
|
39
|
+
for (const { from, to } of view.visibleRanges) {
|
|
40
|
+
syntaxTree(view.state).iterate({
|
|
41
|
+
from,
|
|
42
|
+
to,
|
|
43
|
+
enter: (node) => {
|
|
44
|
+
// Decorate XML elements (opening tags, closing tags, self-closing tags).
|
|
45
|
+
if (
|
|
46
|
+
node.name === 'HTMLTag' ||
|
|
47
|
+
node.name === 'OpenTag' ||
|
|
48
|
+
node.name === 'CloseTag' ||
|
|
49
|
+
node.name === 'SelfClosingTag' ||
|
|
50
|
+
node.name === 'Element'
|
|
51
|
+
) {
|
|
52
|
+
builder.add(node.from, node.to, Decoration.mark({ class: 'font-mono text-subdued' }));
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return builder.finish();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
decorations: (v) => v.decorations,
|
|
63
|
+
},
|
|
64
|
+
);
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Tool from '@effect/ai/Tool';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { NumericTabs, TextCrawl, ToggleContainer, type ToggleContainerRootProps } from '@dxos/react-ui-components';
|
|
10
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
11
|
+
import { type ContentBlock, type Message } from '@dxos/types';
|
|
12
|
+
import { type XmlWidgetProps } from '@dxos/ui-editor';
|
|
13
|
+
import { isNonNullable, safeParseJson } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { meta } from '../../meta';
|
|
16
|
+
|
|
17
|
+
export const isToolMessage = (message: Message.Message) => {
|
|
18
|
+
return message.blocks.some((block: ContentBlock.Any) => block._tag === 'toolCall' || block._tag === 'toolResult');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ToolBlockProps = XmlWidgetProps<{
|
|
22
|
+
blocks: ContentBlock.Any[];
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export const ToolBlock = ({ view, blocks = [] }: ToolBlockProps) => {
|
|
26
|
+
const { t } = useTranslation(meta.id);
|
|
27
|
+
|
|
28
|
+
const items = useMemo<ToolContainerProps['items']>(() => {
|
|
29
|
+
let lastToolCall: { tool: Tool.Any | undefined; block: ContentBlock.ToolCall } | undefined;
|
|
30
|
+
// TODO(burdon): Get from context?
|
|
31
|
+
const tools: Tool.Any[] = []; //processor.conversation.toolkit?.tools ?? [];
|
|
32
|
+
return blocks
|
|
33
|
+
.filter((block) => block._tag === 'toolCall' || block._tag === 'toolResult' || block._tag === 'stats')
|
|
34
|
+
.map((block) => {
|
|
35
|
+
switch (block._tag) {
|
|
36
|
+
case 'toolCall': {
|
|
37
|
+
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const tool = tools.find((tool) => tool.name === block.name);
|
|
42
|
+
lastToolCall = { tool, block };
|
|
43
|
+
return {
|
|
44
|
+
title: tool?.description ?? [t('tool call label'), tool?.name].join(' '),
|
|
45
|
+
content: {
|
|
46
|
+
...block,
|
|
47
|
+
input: safeParseJson(block.input),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 'toolResult': {
|
|
53
|
+
// TODO(burdon): Parse error type.
|
|
54
|
+
if (block.error) {
|
|
55
|
+
return {
|
|
56
|
+
title: t('tool error label'),
|
|
57
|
+
content: block,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const title =
|
|
62
|
+
lastToolCall?.tool?.description ?? [t('tool result label'), lastToolCall?.tool?.name].join(' ');
|
|
63
|
+
lastToolCall = undefined;
|
|
64
|
+
return {
|
|
65
|
+
title,
|
|
66
|
+
content: {
|
|
67
|
+
...block,
|
|
68
|
+
result: safeParseJson(block.result),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case 'stats': {
|
|
74
|
+
if (!lastToolCall) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
title: t('stats label'),
|
|
80
|
+
content: block,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.filter(isNonNullable);
|
|
86
|
+
}, [blocks]);
|
|
87
|
+
|
|
88
|
+
const handleChangeOpen = useCallback(() => {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
// Measure after animation.
|
|
91
|
+
view?.requestMeasure();
|
|
92
|
+
}, 1_000);
|
|
93
|
+
}, [view]);
|
|
94
|
+
|
|
95
|
+
if (!items.length) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return <ToolContainer items={items} onChangeOpen={handleChangeOpen} />;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
ToolBlock.displayName = 'ToolBlock';
|
|
103
|
+
|
|
104
|
+
type ToolContainerProps = {
|
|
105
|
+
items: { title: string; content: any }[];
|
|
106
|
+
} & Pick<ToggleContainerRootProps, 'onChangeOpen'>;
|
|
107
|
+
|
|
108
|
+
export const ToolContainer = ({ items, onChangeOpen }: ToolContainerProps) => {
|
|
109
|
+
const tabsRef = useRef<HTMLDivElement>(null);
|
|
110
|
+
const [selected, setSelected] = useState(0);
|
|
111
|
+
const [open, setOpen] = useState(false);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
onChangeOpen?.(open);
|
|
115
|
+
if (open) {
|
|
116
|
+
tabsRef.current?.focus();
|
|
117
|
+
}
|
|
118
|
+
}, [open, onChangeOpen]);
|
|
119
|
+
|
|
120
|
+
const handleSelect = useCallback((index: number) => {
|
|
121
|
+
setSelected(index);
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<ToggleContainer.Root classNames='mt-2 w-full rounded-xs' open={open} onChangeOpen={setOpen}>
|
|
126
|
+
<ToggleContainer.Header classNames='text-sm text-placeholder'>
|
|
127
|
+
<TextCrawl key='status-roll' lines={items.map((item) => item.title)} autoAdvance greedy />
|
|
128
|
+
</ToggleContainer.Header>
|
|
129
|
+
<ToggleContainer.Content classNames='grid grid-cols-[32px_1fr]'>
|
|
130
|
+
<NumericTabs ref={tabsRef} classNames='p-1' length={items.length} selected={selected} onSelect={handleSelect} />
|
|
131
|
+
<Json
|
|
132
|
+
data={items[selected]?.content}
|
|
133
|
+
classNames='p-1 text-xs bg-transparent'
|
|
134
|
+
replacer={{
|
|
135
|
+
maxDepth: 3,
|
|
136
|
+
maxArrayLen: 10,
|
|
137
|
+
maxStringLen: 128,
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
</ToggleContainer.Content>
|
|
141
|
+
</ToggleContainer.Root>
|
|
142
|
+
);
|
|
143
|
+
};
|