@dxos/plugin-assistant 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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/{BlueprintArticle-WP3G5GLG.mjs → BlueprintArticle-6SP2ZWJ2.mjs} +2 -3
- package/dist/lib/browser/BlueprintArticle-6SP2ZWJ2.mjs.map +7 -0
- package/dist/lib/browser/{ChatCompanion-GFSJZTOT.mjs → ChatCompanion-KGPU4DLI.mjs} +67 -20
- package/dist/lib/browser/ChatCompanion-KGPU4DLI.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-IHAPBIZE.mjs → ChatContainer-IHPTKMDK.mjs} +7 -6
- package/dist/lib/browser/ChatContainer-IHPTKMDK.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-EGRMPCTL.mjs → ChatDialog-VALCOM3W.mjs} +5 -5
- package/dist/lib/browser/{ChatDialog-EGRMPCTL.mjs.map → ChatDialog-VALCOM3W.mjs.map} +2 -2
- package/dist/lib/browser/InitiativeContainer-LQHJLTPE.mjs +264 -0
- package/dist/lib/browser/InitiativeContainer-LQHJLTPE.mjs.map +7 -0
- package/dist/lib/browser/{PromptArticle-K362ZPAE.mjs → PromptArticle-YJ5E2YYE.mjs} +21 -9
- package/dist/lib/browser/PromptArticle-YJ5E2YYE.mjs.map +7 -0
- package/dist/lib/browser/{ai-service-5GUDOEWF.mjs → ai-service-CY2BYPH6.mjs} +5 -4
- package/dist/lib/browser/ai-service-CY2BYPH6.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-DSNH2OMY.mjs → app-graph-builder-MUZGUQSC.mjs} +43 -21
- package/dist/lib/browser/app-graph-builder-MUZGUQSC.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-4D42KBDM.mjs +33 -0
- package/dist/lib/browser/blueprint-definition-4D42KBDM.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +3 -7
- package/dist/lib/browser/{chunk-V772AMZM.mjs → chunk-6BVCG5SJ.mjs} +17 -37
- package/dist/lib/browser/chunk-6BVCG5SJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ML3QCFKA.mjs → chunk-JYY5AD65.mjs} +50 -29
- package/dist/lib/browser/chunk-JYY5AD65.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MRJVYGLU.mjs → chunk-MEM7ET2A.mjs} +34 -68
- package/dist/lib/browser/chunk-MEM7ET2A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-A75V4MOQ.mjs → chunk-THZPCE3E.mjs} +228 -92
- package/dist/lib/browser/chunk-THZPCE3E.mjs.map +7 -0
- package/dist/lib/browser/{edge-model-resolver-26BOY6HY.mjs → edge-model-resolver-YTMFQEN5.mjs} +4 -3
- package/dist/lib/browser/edge-model-resolver-YTMFQEN5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +97 -52
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{local-model-resolver-ZFIM6GGV.mjs → local-model-resolver-CGRQH37T.mjs} +4 -3
- 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-7XJLBRQY.mjs → operation-resolver-MB7OQBPT.mjs} +21 -23
- package/dist/lib/browser/operation-resolver-MB7OQBPT.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-S7SBFOSW.mjs → react-surface-UHDDX6N3.mjs} +37 -21
- package/dist/lib/browser/react-surface-UHDDX6N3.mjs.map +7 -0
- package/dist/lib/browser/{repair-6QGAKOVM.mjs → repair-IRXDYF4R.mjs} +4 -7
- package/dist/lib/browser/repair-IRXDYF4R.mjs.map +7 -0
- package/dist/lib/browser/{settings-4ZDLUMYE.mjs → settings-XF6GKHCG.mjs} +5 -4
- package/dist/lib/browser/settings-XF6GKHCG.mjs.map +7 -0
- package/dist/lib/browser/{state-AN6336ZX.mjs → state-OYDPWLKA.mjs} +2 -2
- package/dist/lib/browser/toolkit-IDXQCSTX.mjs +19 -0
- package/dist/lib/browser/toolkit-IDXQCSTX.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{BlueprintArticle-WZ76E2C4.mjs → BlueprintArticle-7LI6UXKZ.mjs} +2 -3
- package/dist/lib/node-esm/BlueprintArticle-7LI6UXKZ.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatCompanion-UR7DXZ54.mjs → ChatCompanion-XY3MAAKH.mjs} +67 -20
- package/dist/lib/node-esm/ChatCompanion-XY3MAAKH.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-YMLLGOZK.mjs → ChatContainer-3YXC4HOK.mjs} +7 -6
- package/dist/lib/node-esm/ChatContainer-3YXC4HOK.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-D24WJPK4.mjs → ChatDialog-UAYXP3UM.mjs} +5 -5
- package/dist/lib/node-esm/{ChatDialog-D24WJPK4.mjs.map → ChatDialog-UAYXP3UM.mjs.map} +2 -2
- package/dist/lib/node-esm/InitiativeContainer-EAUOSH36.mjs +265 -0
- package/dist/lib/node-esm/InitiativeContainer-EAUOSH36.mjs.map +7 -0
- package/dist/lib/node-esm/{PromptArticle-D4HAIIC6.mjs → PromptArticle-U2IYPLFR.mjs} +21 -9
- package/dist/lib/node-esm/PromptArticle-U2IYPLFR.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-service-PXKKCFIF.mjs → ai-service-ZI3A6RVG.mjs} +5 -4
- package/dist/lib/node-esm/ai-service-ZI3A6RVG.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-TJCUEXW5.mjs → app-graph-builder-4QN5M6PD.mjs} +43 -21
- package/dist/lib/node-esm/app-graph-builder-4QN5M6PD.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-EJOAZFY5.mjs +34 -0
- package/dist/lib/node-esm/blueprint-definition-EJOAZFY5.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +3 -7
- package/dist/lib/node-esm/{chunk-4BERCIES.mjs → chunk-3DG7AJES.mjs} +228 -92
- package/dist/lib/node-esm/chunk-3DG7AJES.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DCA5QWQT.mjs → chunk-CTHGEJJA.mjs} +34 -67
- package/dist/lib/node-esm/chunk-CTHGEJJA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZRIPP7YF.mjs → chunk-JMBYVUD6.mjs} +50 -29
- package/dist/lib/node-esm/chunk-JMBYVUD6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-355W5B27.mjs → chunk-LB72WG6R.mjs} +17 -37
- package/dist/lib/node-esm/chunk-LB72WG6R.mjs.map +7 -0
- package/dist/lib/node-esm/{edge-model-resolver-G5KMODPO.mjs → edge-model-resolver-CMJ3KNLQ.mjs} +4 -3
- package/dist/lib/node-esm/edge-model-resolver-CMJ3KNLQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +97 -52
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{local-model-resolver-KDZLYI7Y.mjs → local-model-resolver-FFDAKOXN.mjs} +4 -3
- 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-SX4WMNA7.mjs → operation-resolver-VWNTUHQQ.mjs} +21 -23
- package/dist/lib/node-esm/operation-resolver-VWNTUHQQ.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-ZR6FXGLF.mjs → react-surface-DTOXFPWM.mjs} +37 -21
- package/dist/lib/node-esm/react-surface-DTOXFPWM.mjs.map +7 -0
- package/dist/lib/node-esm/{repair-QJ7CQDKU.mjs → repair-DMI55PON.mjs} +4 -7
- package/dist/lib/node-esm/repair-DMI55PON.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-CQEOHR3R.mjs → settings-NGGZA7S7.mjs} +5 -4
- package/dist/lib/node-esm/settings-NGGZA7S7.mjs.map +7 -0
- package/dist/lib/node-esm/{state-HDON4REW.mjs → state-VSCPGN7R.mjs} +2 -2
- package/dist/lib/node-esm/{toolkit-OWGCEKOO.mjs → toolkit-JPRJRDDB.mjs} +6 -5
- package/dist/lib/node-esm/toolkit-JPRJRDDB.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -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/functions/index.d.ts +25 -0
- package/dist/types/src/blueprints/assistant/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/{functions → blueprints/assistant/functions}/object-load.d.ts +1 -1
- package/dist/types/src/blueprints/assistant/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/functions/object-search.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 +1 -6
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts +3 -2
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service/index.d.ts +1 -1
- package/dist/types/src/capabilities/ai-service/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +4 -19
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +1 -2
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +3 -2
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +3 -2
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/repair/repair.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings/index.d.ts +1 -1
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +3 -2
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit/index.d.ts +1 -1
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +3 -2
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +6 -3
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +2 -2
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +4 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts +2 -2
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +2 -2
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +115 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/InitiativeContainer/InitiativeContainer.d.ts +7 -0
- package/dist/types/src/components/InitiativeContainer/InitiativeContainer.d.ts.map +1 -0
- package/dist/types/src/components/InitiativeContainer/index.d.ts +3 -0
- package/dist/types/src/components/InitiativeContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/PromptArticle.d.ts +1 -1
- package/dist/types/src/components/PromptArticle.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +114 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +114 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +114 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts +4 -0
- package/dist/types/src/components/TriggerStatus/TriggerStatus.d.ts.map +1 -0
- package/dist/types/src/components/TriggerStatus/index.d.ts +2 -0
- package/dist/types/src/components/TriggerStatus/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +10 -11
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +2 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +2 -2
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +2 -2
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +7 -3
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts +2 -2
- package/dist/types/src/processor/update-name.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +114 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +5 -27
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +3 -1
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +94 -91
- package/src/AssistantPlugin.tsx +62 -29
- package/src/blueprints/assistant/blueprint.ts +34 -0
- package/src/blueprints/assistant/functions/index.ts +13 -0
- package/src/{functions → blueprints/assistant/functions}/object-list.ts +2 -2
- package/src/{functions → blueprints/assistant/functions}/object-load.ts +9 -12
- package/src/{functions → blueprints/assistant/functions}/object-search.ts +1 -1
- package/src/blueprints/assistant/index.ts +5 -0
- package/src/blueprints/index.ts +1 -8
- package/src/capabilities/ai-service/ai-service.ts +4 -3
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +37 -17
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +28 -42
- package/src/capabilities/blueprint-definition/index.ts +0 -1
- package/src/capabilities/edge-model-resolver/edge-model-resolver.ts +4 -3
- package/src/capabilities/local-model-resolver/local-model-resolver.ts +4 -3
- package/src/capabilities/operation-resolver/operation-resolver.ts +17 -15
- package/src/capabilities/react-surface/react-surface.tsx +35 -19
- package/src/capabilities/repair/repair.ts +3 -4
- package/src/capabilities/settings/settings.ts +3 -2
- package/src/capabilities/toolkit/toolkit.ts +5 -4
- package/src/components/AssistantSettings/AssistantSettings.tsx +15 -15
- package/src/components/BlueprintArticle.tsx +2 -3
- package/src/components/Chat/Chat.tsx +41 -14
- package/src/components/ChatCompanion.tsx +81 -18
- package/src/components/ChatContainer.tsx +20 -13
- package/src/components/ChatDialog.tsx +4 -3
- package/src/components/ChatProgress/ChatProgress.tsx +2 -3
- package/src/components/ChatPrompt/ChatActions.tsx +8 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +3 -3
- package/src/components/ChatThread/ChatThread.tsx +13 -4
- package/src/components/ChatThread/Link.tsx +1 -1
- package/src/components/ChatThread/registry.tsx +18 -1
- package/src/components/ChatThread/sync.test.ts +2 -1
- package/src/components/ChatThread/sync.ts +14 -8
- package/src/components/InitiativeContainer/InitiativeContainer.tsx +340 -0
- package/src/components/InitiativeContainer/index.ts +6 -0
- package/src/components/PromptArticle.tsx +21 -13
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +1 -1
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +1 -1
- package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
- package/src/components/Toolbox/Toolbox.tsx +41 -42
- package/src/components/TriggerStatus/TriggerStatus.tsx +142 -0
- package/src/components/TriggerStatus/index.ts +5 -0
- package/src/components/index.ts +11 -2
- package/src/hooks/useBlueprintRegistry.ts +7 -4
- package/src/hooks/useChatProcessor.ts +2 -1
- package/src/hooks/useChatServices.ts +3 -3
- package/src/hooks/useChatToolbarActions.ts +6 -5
- package/src/hooks/useReferencesProvider.ts +1 -5
- package/src/index.ts +1 -0
- package/src/processor/processor.test.ts +7 -7
- package/src/processor/processor.ts +47 -26
- package/src/processor/update-name.ts +2 -3
- package/src/translations.ts +23 -2
- package/src/types/Assistant.ts +4 -38
- package/src/types/AssistantAction.ts +6 -5
- package/src/types/index.ts +3 -0
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-GFSJZTOT.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-IHAPBIZE.mjs.map +0 -7
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs.map +0 -7
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs +0 -14
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs.map +0 -7
- package/dist/lib/browser/chunk-A75V4MOQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ML3QCFKA.mjs.map +0 -7
- package/dist/lib/browser/chunk-MRJVYGLU.mjs.map +0 -7
- package/dist/lib/browser/chunk-V772AMZM.mjs.map +0 -7
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs +0 -41
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-S7SBFOSW.mjs.map +0 -7
- package/dist/lib/browser/repair-6QGAKOVM.mjs.map +0 -7
- package/dist/lib/browser/settings-4ZDLUMYE.mjs.map +0 -7
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs +0 -18
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-UR7DXZ54.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-YMLLGOZK.mjs.map +0 -7
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs +0 -15
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-355W5B27.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4BERCIES.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs +0 -42
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ZR6FXGLF.mjs.map +0 -7
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs.map +0 -7
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs.map +0 -7
- package/dist/types/src/blueprints/assistant-blueprint.d.ts +0 -209
- package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +0 -40
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/object-list.d.ts.map +0 -1
- package/dist/types/src/functions/object-load.d.ts.map +0 -1
- package/dist/types/src/functions/object-search.d.ts.map +0 -1
- package/src/blueprints/assistant-blueprint.ts +0 -62
- package/src/components/ChatThread/reducers.ts +0 -151
- package/src/functions/index.ts +0 -7
- /package/dist/lib/browser/{state-AN6336ZX.mjs.map → state-OYDPWLKA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{state-HDON4REW.mjs.map → state-VSCPGN7R.mjs.map} +0 -0
- /package/dist/types/src/{functions → blueprints/assistant/functions}/object-list.d.ts +0 -0
- /package/dist/types/src/{functions → blueprints/assistant/functions}/object-search.d.ts +0 -0
|
@@ -10,10 +10,11 @@ import * as Array from 'effect/Array';
|
|
|
10
10
|
import * as Option from 'effect/Option';
|
|
11
11
|
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
12
|
|
|
13
|
+
import { type Chat as ChatModule } from '@dxos/assistant-toolkit';
|
|
13
14
|
import { Event } from '@dxos/async';
|
|
14
|
-
import { type Database, Obj } from '@dxos/echo';
|
|
15
|
+
import { type Database, Filter, Obj } from '@dxos/echo';
|
|
15
16
|
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
16
|
-
import {
|
|
17
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
17
18
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
18
19
|
import { Input, type ThemedClassName, useDynamicRef, useTranslation } from '@dxos/react-ui';
|
|
19
20
|
import { ChatEditor, type ChatEditorController, type ChatEditorProps } from '@dxos/react-ui-chat';
|
|
@@ -26,7 +27,6 @@ import { isTruthy } from '@dxos/util';
|
|
|
26
27
|
import { useChatToolbarActions } from '../../hooks';
|
|
27
28
|
import { meta } from '../../meta';
|
|
28
29
|
import { type AiChatProcessor } from '../../processor';
|
|
29
|
-
import { type Assistant } from '../../types';
|
|
30
30
|
import {
|
|
31
31
|
ChatActions,
|
|
32
32
|
type ChatActionsProps,
|
|
@@ -49,7 +49,7 @@ type ChatContextValue = {
|
|
|
49
49
|
debug?: boolean;
|
|
50
50
|
event: Event<ChatEvent>;
|
|
51
51
|
db?: Database.Database;
|
|
52
|
-
chat?:
|
|
52
|
+
chat?: ChatModule.Chat;
|
|
53
53
|
messages: Message.Message[];
|
|
54
54
|
processor: AiChatProcessor;
|
|
55
55
|
};
|
|
@@ -73,11 +73,10 @@ const ChatRoot = ({ children, chat, processor, onEvent, ...props }: ChatRootProp
|
|
|
73
73
|
const lastPrompt = useRef<string | undefined>(undefined);
|
|
74
74
|
|
|
75
75
|
// Messages.
|
|
76
|
-
const
|
|
76
|
+
const storedMessages = useQuery(chat?.queue?.target, Filter.type(Message.Message));
|
|
77
77
|
const messages = useMemo(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, [queue?.objects, pending]);
|
|
78
|
+
return Array.dedupeWith([...storedMessages, ...pending], ({ id: a }, { id: b }) => a === b);
|
|
79
|
+
}, [storedMessages, pending]);
|
|
81
80
|
|
|
82
81
|
// Events.
|
|
83
82
|
const event = useMemo(() => new Event<ChatEvent>(), []);
|
|
@@ -86,6 +85,24 @@ const ChatRoot = ({ children, chat, processor, onEvent, ...props }: ChatRootProp
|
|
|
86
85
|
switch (ev.type) {
|
|
87
86
|
case 'toggle-debug': {
|
|
88
87
|
setDebug((current) => !current);
|
|
88
|
+
// Dump state to console.
|
|
89
|
+
queueMicrotask(async () => {
|
|
90
|
+
const objects = processor.context.getObjects();
|
|
91
|
+
const blueprints = processor.context.getBlueprints();
|
|
92
|
+
const tools = await processor.getTools();
|
|
93
|
+
const system = await processor.getSystemPrompt();
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.log('Chat processor state:', { objects, blueprints });
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.log(`
|
|
98
|
+
==== System Prompt ====
|
|
99
|
+
${system}
|
|
100
|
+
==== Tools ====
|
|
101
|
+
${Object.values(tools)
|
|
102
|
+
.map((tool) => JSON.stringify(tool, null, 2))
|
|
103
|
+
.join('\n')}
|
|
104
|
+
`);
|
|
105
|
+
});
|
|
89
106
|
break;
|
|
90
107
|
}
|
|
91
108
|
|
|
@@ -143,6 +160,8 @@ ChatRoot.displayName = 'Chat.Root';
|
|
|
143
160
|
// Viewport
|
|
144
161
|
//
|
|
145
162
|
|
|
163
|
+
const CHAT_VIEWPORT_NAME = 'Chat.Viewport';
|
|
164
|
+
|
|
146
165
|
type ChatViewportProps = ThemedClassName<PropsWithChildren>;
|
|
147
166
|
|
|
148
167
|
const ChatViewport = ({ classNames, children }: ChatViewportProps) => {
|
|
@@ -153,14 +172,18 @@ const ChatViewport = ({ classNames, children }: ChatViewportProps) => {
|
|
|
153
172
|
);
|
|
154
173
|
};
|
|
155
174
|
|
|
175
|
+
ChatViewport.displayName = CHAT_VIEWPORT_NAME;
|
|
176
|
+
|
|
156
177
|
//
|
|
157
178
|
// Thread
|
|
158
179
|
//
|
|
159
180
|
|
|
181
|
+
const CHAT_THREAD_NAME = 'Chat.Thread';
|
|
182
|
+
|
|
160
183
|
type ChatThreadProps = Omit<NaturalChatThreadProps, 'identity' | 'messages' | 'tools'>;
|
|
161
184
|
|
|
162
185
|
const ChatThread = (props: ChatThreadProps) => {
|
|
163
|
-
const { debug, event, messages, processor } = useChatContext(
|
|
186
|
+
const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
|
|
164
187
|
const identity = useIdentity();
|
|
165
188
|
const error = useAtomValue(processor.error).pipe(Option.getOrUndefined);
|
|
166
189
|
|
|
@@ -206,12 +229,14 @@ const ChatThread = (props: ChatThreadProps) => {
|
|
|
206
229
|
);
|
|
207
230
|
};
|
|
208
231
|
|
|
209
|
-
ChatThread.displayName =
|
|
232
|
+
ChatThread.displayName = CHAT_THREAD_NAME;
|
|
210
233
|
|
|
211
234
|
//
|
|
212
235
|
// Prompt
|
|
213
236
|
//
|
|
214
237
|
|
|
238
|
+
const CHAT_PROMPT_NAME = 'Chat.Prompt';
|
|
239
|
+
|
|
215
240
|
type ChatPromptProps = ThemedClassName<
|
|
216
241
|
{
|
|
217
242
|
outline?: boolean;
|
|
@@ -238,7 +263,7 @@ const ChatPrompt = ({
|
|
|
238
263
|
onOnlineChange,
|
|
239
264
|
}: ChatPromptProps) => {
|
|
240
265
|
const { t } = useTranslation(meta.id);
|
|
241
|
-
const { db, processor, event } = useChatContext(
|
|
266
|
+
const { db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
|
|
242
267
|
|
|
243
268
|
const error = useAtomValue(processor.error).pipe(Option.getOrUndefined);
|
|
244
269
|
const streaming = useAtomValue(processor.streaming);
|
|
@@ -392,16 +417,18 @@ const ChatPrompt = ({
|
|
|
392
417
|
);
|
|
393
418
|
};
|
|
394
419
|
|
|
395
|
-
ChatPrompt.displayName =
|
|
420
|
+
ChatPrompt.displayName = CHAT_PROMPT_NAME;
|
|
396
421
|
|
|
397
422
|
//
|
|
398
423
|
// Toolbar
|
|
399
424
|
//
|
|
400
425
|
|
|
426
|
+
const CHAT_TOOLBAR_NAME = 'Chat.Toolbar';
|
|
427
|
+
|
|
401
428
|
type ChatToolbarProps = ThemedClassName<{ companionTo?: Obj.Unknown }>;
|
|
402
429
|
|
|
403
430
|
const ChatToolbar = ({ classNames, companionTo }: ChatToolbarProps) => {
|
|
404
|
-
const { chat } = useChatContext(
|
|
431
|
+
const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
|
|
405
432
|
const menu = useChatToolbarActions({ chat, companionTo });
|
|
406
433
|
|
|
407
434
|
return (
|
|
@@ -414,7 +441,7 @@ const ChatToolbar = ({ classNames, companionTo }: ChatToolbarProps) => {
|
|
|
414
441
|
);
|
|
415
442
|
};
|
|
416
443
|
|
|
417
|
-
ChatToolbar.displayName =
|
|
444
|
+
ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
|
|
418
445
|
|
|
419
446
|
//
|
|
420
447
|
// Chat
|
|
@@ -5,25 +5,26 @@
|
|
|
5
5
|
import * as Array from 'effect/Array';
|
|
6
6
|
import * as Function from 'effect/Function';
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
|
-
import React, { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useAtomCapability, useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
11
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
12
|
+
import { Chat } from '@dxos/assistant-toolkit';
|
|
12
13
|
import { Blueprint } from '@dxos/blueprints';
|
|
13
14
|
import { getSpace } from '@dxos/client/echo';
|
|
14
|
-
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
15
|
+
import { DXN, Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
15
16
|
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
16
17
|
import { useQuery } from '@dxos/react-client/echo';
|
|
17
18
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
18
19
|
|
|
19
20
|
import { ChatContainer, type ChatEvent } from '../components';
|
|
20
21
|
import { useBlueprintRegistry, useContextBinder } from '../hooks';
|
|
21
|
-
import { Assistant, AssistantOperation } from '../types';
|
|
22
|
+
import { Assistant, AssistantCapabilities, AssistantOperation } from '../types';
|
|
22
23
|
|
|
23
24
|
export type ChatCompanionProps = {
|
|
24
25
|
role?: string;
|
|
25
26
|
data: {
|
|
26
|
-
subject:
|
|
27
|
+
subject: Chat.Chat | 'assistant-chat';
|
|
27
28
|
companionTo: Obj.Unknown;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
@@ -36,9 +37,49 @@ export const ChatCompanion = forwardRef<HTMLDivElement, ChatCompanionProps>(
|
|
|
36
37
|
|
|
37
38
|
const space = getSpace(companionTo);
|
|
38
39
|
const [chat, setChat] = useState(data.subject === 'assistant-chat' ? undefined : data.subject);
|
|
40
|
+
|
|
41
|
+
// Watch the state atom directly to detect when plus button clears the chat selection.
|
|
42
|
+
const state = useAtomCapability(AssistantCapabilities.State);
|
|
43
|
+
const companionToId = Obj.getDXN(companionTo).toString();
|
|
44
|
+
const currentChatState = state?.currentChat[companionToId];
|
|
45
|
+
|
|
46
|
+
// Track if initial setup has been done (to distinguish initial mount from plus button click).
|
|
47
|
+
// Reset when companionTo changes.
|
|
48
|
+
const initialSetupDoneRef = useRef(false);
|
|
49
|
+
const prevCompanionToIdRef = useRef(companionToId);
|
|
50
|
+
if (prevCompanionToIdRef.current !== companionToId) {
|
|
51
|
+
initialSetupDoneRef.current = false;
|
|
52
|
+
prevCompanionToIdRef.current = companionToId;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Sync local chat state with the state atom.
|
|
56
|
+
// When currentChatState is undefined (plus button clicked), reset local chat.
|
|
57
|
+
// When data.subject is a Chat object, use it directly.
|
|
58
|
+
// When currentChatState is a different chat, fetch and set it.
|
|
39
59
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
// If state says no chat selected AND current chat is persisted, reset local state (handles plus button click).
|
|
61
|
+
// Don't reset in-memory chats - they're expected to have currentChatState === undefined.
|
|
62
|
+
if (!currentChatState && chat && getSpace(chat)) {
|
|
63
|
+
setChat(undefined);
|
|
64
|
+
} else if (data.subject !== 'assistant-chat') {
|
|
65
|
+
// If data.subject is a Chat object (resolved from graph), use it.
|
|
66
|
+
setChat(data.subject);
|
|
67
|
+
} else if (currentChatState && space) {
|
|
68
|
+
// currentChatState is set but graph couldn't resolve it - fetch manually.
|
|
69
|
+
const currentChatDxnStr = chat ? Obj.getDXN(chat).toString() : undefined;
|
|
70
|
+
if (currentChatState !== currentChatDxnStr) {
|
|
71
|
+
// Parse DXN and fetch the chat object from the database.
|
|
72
|
+
const parsedDxn = DXN.tryParse(currentChatState);
|
|
73
|
+
if (parsedDxn) {
|
|
74
|
+
const chatRef = space.db.makeRef(parsedDxn);
|
|
75
|
+
const resolvedChat = chatRef?.target;
|
|
76
|
+
if (Obj.instanceOf(Assistant.Chat, resolvedChat)) {
|
|
77
|
+
setChat(resolvedChat);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, [currentChatState, data.subject, space, chat]);
|
|
42
83
|
|
|
43
84
|
const chatQueue = space && chat ? space.queues.get(chat.queue.dxn) : undefined;
|
|
44
85
|
const binder = useContextBinder(chatQueue);
|
|
@@ -49,19 +90,41 @@ export const ChatCompanion = forwardRef<HTMLDivElement, ChatCompanionProps>(
|
|
|
49
90
|
return;
|
|
50
91
|
}
|
|
51
92
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
93
|
+
// Only query for existing chats on initial mount, not when plus button is clicked.
|
|
94
|
+
if (!initialSetupDoneRef.current) {
|
|
95
|
+
// Query for existing companion chats linked to this object.
|
|
96
|
+
const existingChats = await space.db
|
|
97
|
+
.query(Query.select(Filter.id(companionTo.id)).targetOf(Chat.CompanionTo).source())
|
|
98
|
+
.run();
|
|
99
|
+
|
|
100
|
+
initialSetupDoneRef.current = true;
|
|
101
|
+
|
|
102
|
+
// Use existing chat if found on initial mount.
|
|
103
|
+
if (existingChats.length > 0) {
|
|
104
|
+
const existingChat = existingChats.at(-1) as Assistant.Chat;
|
|
105
|
+
setChat(existingChat);
|
|
106
|
+
await invokePromise(AssistantOperation.SetCurrentChat, { companionTo, chat: existingChat });
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Create chat in-memory only - it will be added to space on first message.
|
|
112
|
+
const { data: createResult } = await invokePromise(AssistantOperation.CreateChat, {
|
|
113
|
+
db: space.db,
|
|
114
|
+
addToSpace: false,
|
|
115
|
+
});
|
|
116
|
+
setChat(createResult?.object);
|
|
117
|
+
}, [chat, space, companionTo, invokePromise]);
|
|
55
118
|
|
|
56
|
-
// Add chat to space when user submits the first message.
|
|
119
|
+
// Add chat to space and create relation when user submits the first message.
|
|
57
120
|
const handleEvent = useCallback(
|
|
58
121
|
async (event: ChatEvent) => {
|
|
59
|
-
|
|
60
|
-
if (chatInSpace || !chat || !space) {
|
|
122
|
+
if (!chat || !space) {
|
|
61
123
|
return;
|
|
62
124
|
}
|
|
63
125
|
|
|
64
|
-
|
|
126
|
+
// If chat is not in space yet, persist it on first submit.
|
|
127
|
+
if (event.type === 'submit' && !getSpace(chat)) {
|
|
65
128
|
await invokePromise(SpaceOperation.AddObject, {
|
|
66
129
|
object: chat,
|
|
67
130
|
target: space.db,
|
|
@@ -69,7 +132,7 @@ export const ChatCompanion = forwardRef<HTMLDivElement, ChatCompanionProps>(
|
|
|
69
132
|
});
|
|
70
133
|
await invokePromise(SpaceOperation.AddRelation, {
|
|
71
134
|
db: space.db,
|
|
72
|
-
schema:
|
|
135
|
+
schema: Chat.CompanionTo,
|
|
73
136
|
source: chat,
|
|
74
137
|
target: companionTo,
|
|
75
138
|
});
|
|
@@ -82,7 +145,7 @@ export const ChatCompanion = forwardRef<HTMLDivElement, ChatCompanionProps>(
|
|
|
82
145
|
[chat, space, companionTo, invokePromise],
|
|
83
146
|
);
|
|
84
147
|
|
|
85
|
-
const metadata = useCapabilities(
|
|
148
|
+
const metadata = useCapabilities(AppCapabilities.Metadata);
|
|
86
149
|
const blueprintKeys = useMemo(
|
|
87
150
|
() =>
|
|
88
151
|
Function.pipe(
|
|
@@ -125,7 +188,7 @@ export const ChatCompanion = forwardRef<HTMLDivElement, ChatCompanionProps>(
|
|
|
125
188
|
continue;
|
|
126
189
|
}
|
|
127
190
|
|
|
128
|
-
space.db.add(Obj.clone(blueprint));
|
|
191
|
+
space.db.add(Obj.clone(blueprint, { deep: true }));
|
|
129
192
|
}
|
|
130
193
|
}, [space, blueprintRegistry, blueprintKeys]);
|
|
131
194
|
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { forwardRef } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useAtomCapability } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { type Space, getSpace } from '@dxos/client/echo';
|
|
9
10
|
import { type Obj } from '@dxos/echo';
|
|
10
|
-
import { Layout } from '@dxos/react-ui
|
|
11
|
+
import { Layout } from '@dxos/react-ui';
|
|
11
12
|
|
|
12
13
|
import { useBlueprintRegistry, useChatProcessor, useChatServices, useOnline, usePresets } from '../hooks';
|
|
13
|
-
import { type
|
|
14
|
+
import { AssistantCapabilities, type ChatType } from '../types';
|
|
14
15
|
|
|
15
|
-
import { Chat, type ChatRootProps } from './Chat';
|
|
16
|
+
import { Chat as ChatComponent, type ChatRootProps } from './Chat';
|
|
16
17
|
|
|
17
18
|
export type ChatContainerProps = SurfaceComponentProps<
|
|
18
|
-
|
|
19
|
+
ChatType.Chat | undefined,
|
|
19
20
|
{
|
|
20
21
|
space?: Space;
|
|
21
22
|
companionTo?: Obj.Unknown;
|
|
@@ -44,16 +45,22 @@ export const ChatContainer = forwardRef<HTMLDivElement, ChatContainerProps>((pro
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
return (
|
|
47
|
-
<Layout.Main role={role} ref={forwardedRef}>
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
<
|
|
48
|
+
<Layout.Main toolbar role={role} ref={forwardedRef}>
|
|
49
|
+
<ChatComponent.Root db={space?.db} chat={chat} processor={processor} onEvent={onEvent}>
|
|
50
|
+
<ChatComponent.Toolbar companionTo={companionTo} />
|
|
51
|
+
<ChatComponent.Viewport classNames='container-max-width'>
|
|
52
|
+
<ChatComponent.Thread />
|
|
52
53
|
<div role='none' className='p-4'>
|
|
53
|
-
<
|
|
54
|
+
<ChatComponent.Prompt
|
|
55
|
+
{...chatProps}
|
|
56
|
+
outline
|
|
57
|
+
preset={preset?.id}
|
|
58
|
+
online={online}
|
|
59
|
+
onOnlineChange={setOnline}
|
|
60
|
+
/>
|
|
54
61
|
</div>
|
|
55
|
-
</
|
|
56
|
-
</
|
|
62
|
+
</ChatComponent.Viewport>
|
|
63
|
+
</ChatComponent.Root>
|
|
57
64
|
</Layout.Main>
|
|
58
65
|
);
|
|
59
66
|
});
|
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useAtomCapability } from '@dxos/app-framework/
|
|
7
|
+
import { useAtomCapability } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type Chat as ChatTypes } from '@dxos/assistant-toolkit';
|
|
8
9
|
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
11
|
import { ChatDialog as NaturalChatDialog } from '@dxos/react-ui-chat';
|
|
11
12
|
|
|
12
13
|
import { useBlueprintRegistry, useChatProcessor, useChatServices, useOnline, usePresets } from '../hooks';
|
|
13
14
|
import { meta } from '../meta';
|
|
14
|
-
import {
|
|
15
|
+
import { AssistantCapabilities } from '../types';
|
|
15
16
|
|
|
16
17
|
import { Chat, type ChatRootProps } from './Chat';
|
|
17
18
|
|
|
18
19
|
export type ChatDialogProps = {
|
|
19
|
-
chat?:
|
|
20
|
+
chat?: ChatTypes.Chat;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export const ChatDialog = ({ chat }: ChatDialogProps) => {
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type Chat } from '@dxos/assistant-toolkit';
|
|
7
8
|
import { addEventListener } from '@dxos/async';
|
|
8
9
|
import { ProgressBar, type ProgressBarProps, TextCrawl, useExecutionGraph } from '@dxos/react-ui-components';
|
|
9
10
|
|
|
10
|
-
import { type Assistant } from '../../types';
|
|
11
|
-
|
|
12
11
|
export type ChatProgressProps = {
|
|
13
|
-
chat:
|
|
12
|
+
chat: Chat.Chat;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export const ChatProgress = ({ chat }: ChatProgressProps) => {
|
|
@@ -50,6 +50,14 @@ export const ChatActions = ({ classNames, children, microphone, recording, proce
|
|
|
50
50
|
onTouchEnd={() => onEvent?.({ type: 'record-stop' })}
|
|
51
51
|
/>
|
|
52
52
|
)}
|
|
53
|
+
|
|
54
|
+
<IconButton
|
|
55
|
+
variant='ghost'
|
|
56
|
+
icon='ph--wrench--regular'
|
|
57
|
+
iconOnly
|
|
58
|
+
label={t('debug button')}
|
|
59
|
+
onClick={() => onEvent?.({ type: 'toggle-debug' })}
|
|
60
|
+
/>
|
|
53
61
|
</div>
|
|
54
62
|
);
|
|
55
63
|
};
|
|
@@ -56,7 +56,7 @@ const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: StoryProps)
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
setDone(true);
|
|
59
|
-
}).pipe(Effect.provide(Layer.mergeAll(Database.
|
|
59
|
+
}).pipe(Effect.provide(Layer.mergeAll(Database.layer(space.db), ContextQueueService.layer(queue)))),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
return () => {
|
|
@@ -69,7 +69,7 @@ const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: StoryProps)
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
|
-
<EditorPreviewProvider onLookup={async ({
|
|
72
|
+
<EditorPreviewProvider onLookup={async ({ dxn, label }) => ({ label, text: dxn })}>
|
|
73
73
|
<ChatThread {...props} messages={queue?.objects} />
|
|
74
74
|
<PreviewCard />
|
|
75
75
|
</EditorPreviewProvider>
|
|
@@ -99,7 +99,7 @@ const meta = {
|
|
|
99
99
|
component: ChatThread,
|
|
100
100
|
render: render(DefaultStory),
|
|
101
101
|
decorators: [
|
|
102
|
-
withTheme,
|
|
102
|
+
withTheme(),
|
|
103
103
|
withLayout({ layout: 'column' }),
|
|
104
104
|
withClientProvider({
|
|
105
105
|
createIdentity: true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { type Identity } from '@dxos/react-client/halo';
|
|
@@ -27,13 +27,22 @@ export type ChatThreadProps = ThemedClassName<
|
|
|
27
27
|
>;
|
|
28
28
|
|
|
29
29
|
// TODO(burdon): Memo thread position.
|
|
30
|
-
export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
30
|
+
export const ChatThread = forwardRef<MarkdownStreamController | null, ChatThreadProps>(
|
|
31
31
|
(
|
|
32
32
|
{ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent },
|
|
33
33
|
forwardedRef,
|
|
34
34
|
) => {
|
|
35
35
|
const controllerRef = useForwardedRef(forwardedRef);
|
|
36
|
-
const controller =
|
|
36
|
+
const [controller, setController] = useState<MarkdownStreamController | null>(null);
|
|
37
|
+
|
|
38
|
+
// Callback ref to capture when MarkdownStream is mounted and trigger re-render.
|
|
39
|
+
const refCallback = useCallback(
|
|
40
|
+
(node: MarkdownStreamController | null) => {
|
|
41
|
+
controllerRef.current = node;
|
|
42
|
+
setController(node);
|
|
43
|
+
},
|
|
44
|
+
[controllerRef],
|
|
45
|
+
);
|
|
37
46
|
|
|
38
47
|
const userHue = useMemo(
|
|
39
48
|
() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue,
|
|
@@ -74,7 +83,7 @@ export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
|
74
83
|
style={{ '--user-fill': `var(--dx-${userHue}Fill)` } as CSSProperties}
|
|
75
84
|
>
|
|
76
85
|
<MarkdownStream
|
|
77
|
-
ref={
|
|
86
|
+
ref={refCallback}
|
|
78
87
|
registry={componentRegistry}
|
|
79
88
|
cursor={cursor}
|
|
80
89
|
fadeIn={fadeIn}
|
|
@@ -19,7 +19,7 @@ export const ObjectLink = ({ space, dxn }: ObjectLinkProps) => {
|
|
|
19
19
|
|
|
20
20
|
const title = (ref.target && Entity.getLabel(ref.target)) ?? ref.target?.id ?? ref.dxn.toString();
|
|
21
21
|
return (
|
|
22
|
-
<DxAnchor rootclassname='dx-tag--anchor'
|
|
22
|
+
<DxAnchor rootclassname='dx-tag--anchor' dxn={dxn.toString()}>
|
|
23
23
|
{title}
|
|
24
24
|
</DxAnchor>
|
|
25
25
|
);
|
|
@@ -8,6 +8,7 @@ import { log } from '@dxos/log';
|
|
|
8
8
|
import { ToggleContainer } from '@dxos/react-ui-components';
|
|
9
9
|
import {
|
|
10
10
|
PromptWidget,
|
|
11
|
+
ReasoningWidget,
|
|
11
12
|
ReferenceWidget,
|
|
12
13
|
SelectWidget,
|
|
13
14
|
SuggestionWidget,
|
|
@@ -47,6 +48,13 @@ export const componentRegistry: XmlWidgetRegistry = {
|
|
|
47
48
|
return text ? new PromptWidget(text) : null;
|
|
48
49
|
},
|
|
49
50
|
},
|
|
51
|
+
['reasoning' as const]: {
|
|
52
|
+
block: true,
|
|
53
|
+
factory: ({ children }) => {
|
|
54
|
+
const text = getXmlTextChild(children);
|
|
55
|
+
return text ? new ReasoningWidget(text) : null;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
50
58
|
['reference' as const]: {
|
|
51
59
|
block: false,
|
|
52
60
|
factory: ({ children, ref }) => {
|
|
@@ -158,7 +166,8 @@ const blockToMarkdownImpl = (context: MessageThreadContext, message: Message.Mes
|
|
|
158
166
|
return `<toolCall id="${block.toolCallId}" />`;
|
|
159
167
|
}
|
|
160
168
|
case 'toolResult': {
|
|
161
|
-
|
|
169
|
+
// TODO(dmaretskyi): the parameter could be undefined, perhaps tool blocks are not arriving in order.
|
|
170
|
+
context.updateWidget<{ blocks: ContentBlock.Any[] }>(block.toolCallId, ({ blocks = [] } = { blocks: [] }) => ({
|
|
162
171
|
blocks: [...blocks, block],
|
|
163
172
|
}));
|
|
164
173
|
break;
|
|
@@ -166,6 +175,14 @@ const blockToMarkdownImpl = (context: MessageThreadContext, message: Message.Mes
|
|
|
166
175
|
case 'summary': {
|
|
167
176
|
return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
|
|
168
177
|
}
|
|
178
|
+
case 'reasoning': {
|
|
179
|
+
const text = block.reasoningText ?? block.redactedText;
|
|
180
|
+
if (!text) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// TODO(dmaretskyi): The mixed Markdown/XML parser does not support parsing multi-line XML tags.
|
|
184
|
+
return `<reasoning>${text.replace(/\n/g, ' ').trim()}</reasoning>`;
|
|
185
|
+
}
|
|
169
186
|
default: {
|
|
170
187
|
// TODO(burdon): Needs stable ID.
|
|
171
188
|
return `<json id="${message.id}">\n${JSON.stringify(block)}\n</json>`;
|
|
@@ -7,6 +7,7 @@ import { describe, it } from '@effect/vitest';
|
|
|
7
7
|
import * as Effect from 'effect/Effect';
|
|
8
8
|
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
10
11
|
import { type ContentBlock } from '@dxos/types';
|
|
11
12
|
|
|
12
13
|
import { createMessage } from '../../testing';
|
|
@@ -78,7 +79,7 @@ describe('reducers', () => {
|
|
|
78
79
|
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!'].join('\n'));
|
|
79
80
|
|
|
80
81
|
Obj.change(messages[1], (m) => {
|
|
81
|
-
const block = m.blocks[0] as ContentBlock.Text
|
|
82
|
+
const block = m.blocks[0] as Mutable<ContentBlock.Text>;
|
|
82
83
|
block.text = 'Hi there! How are you?';
|
|
83
84
|
block.pending = false;
|
|
84
85
|
});
|
|
@@ -73,6 +73,12 @@ export class MessageSyncer {
|
|
|
73
73
|
* Syncs messages with the editor.
|
|
74
74
|
*/
|
|
75
75
|
append(messages: Message.Message[], flush = false): boolean {
|
|
76
|
+
// TODO(dmaretskyi): MarkdownStream currently does not support streaming XML tags, so we need to remove pending non-text blocks.
|
|
77
|
+
messages = messages.map((message) => ({
|
|
78
|
+
...message,
|
|
79
|
+
blocks: message.blocks.filter((block) => !block.pending || block._tag === 'text'),
|
|
80
|
+
}));
|
|
81
|
+
|
|
76
82
|
// Check if new set of messages.
|
|
77
83
|
if (this._initialMessageId !== messages[0]?.id) {
|
|
78
84
|
this.reset();
|
|
@@ -108,13 +114,13 @@ export class MessageSyncer {
|
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
private process(messages: Message.Message[], append: (content: string) => void) {
|
|
111
|
-
log('sync', {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
117
|
+
// console.log('sync', {
|
|
118
|
+
// doc: this._model.view?.state.doc.length,
|
|
119
|
+
// messages: messages.map((message) => message.blocks.length),
|
|
120
|
+
// currentMessageIndex: this._currentMessageIndex,
|
|
121
|
+
// currentBlockIndex: this._currentBlockIndex,
|
|
122
|
+
// currentBlockContent: this._currentBlockContent,
|
|
123
|
+
// });
|
|
118
124
|
|
|
119
125
|
let i = this._currentMessageIndex;
|
|
120
126
|
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
@@ -135,7 +141,7 @@ export class MessageSyncer {
|
|
|
135
141
|
content = currentBlockContent;
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
log('append', { message: i, block: j, content });
|
|
144
|
+
// console.log('append', { message: i, block: j, content });
|
|
139
145
|
this._currentBlockContent = currentBlockContent;
|
|
140
146
|
append(content);
|
|
141
147
|
}
|