@dxos/plugin-thread 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/ChannelArticle-UJHPOUWA.mjs +28 -0
- package/dist/lib/neutral/ChannelArticle-UJHPOUWA.mjs.map +7 -0
- package/dist/lib/neutral/ChannelChat-LZEDFJVD.mjs +10 -0
- package/dist/lib/neutral/CommentsCompanion-3H3ZVIBH.mjs +208 -0
- package/dist/lib/neutral/CommentsCompanion-3H3ZVIBH.mjs.map +7 -0
- package/dist/lib/neutral/ThreadContainer-QWB6WRMI.mjs +61 -0
- package/dist/lib/neutral/ThreadContainer-QWB6WRMI.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.mjs +96 -0
- package/dist/lib/neutral/ThreadPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.node.mjs +40 -0
- package/dist/lib/neutral/ThreadPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.workerd.mjs +24 -0
- package/dist/lib/neutral/ThreadPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/ThreadSettings-5MKTDK3A.mjs +15 -0
- package/dist/lib/neutral/ThreadSettings-5MKTDK3A.mjs.map +7 -0
- package/dist/lib/neutral/add-message-DATVSMVU.mjs +122 -0
- package/dist/lib/neutral/add-message-DATVSMVU.mjs.map +7 -0
- package/dist/lib/neutral/agent-runner-JK2Y4RU3.mjs +244 -0
- package/dist/lib/neutral/agent-runner-JK2Y4RU3.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-ACCHZXZA.mjs +120 -0
- package/dist/lib/neutral/app-graph-builder-ACCHZXZA.mjs.map +7 -0
- package/dist/lib/neutral/append-channel-message-4ACLATZY.mjs +40 -0
- package/dist/lib/neutral/append-channel-message-4ACLATZY.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-S3EBOH4R.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-S3EBOH4R.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +27 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5T5LPLBN.mjs +36 -0
- package/dist/lib/neutral/chunk-5T5LPLBN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6HC3NAXD.mjs +164 -0
- package/dist/lib/neutral/chunk-6HC3NAXD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BHEZLLXG.mjs +55 -0
- package/dist/lib/neutral/chunk-BHEZLLXG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-D3SCNWLT.mjs +335 -0
- package/dist/lib/neutral/chunk-D3SCNWLT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/{browser/chunk-CP7E2HRE.mjs → neutral/chunk-JLY4NVTA.mjs} +12 -5
- package/dist/lib/neutral/chunk-JLY4NVTA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QFDT33VT.mjs +69 -0
- package/dist/lib/neutral/chunk-QFDT33VT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TT6PWRR5.mjs +8 -0
- package/dist/lib/neutral/chunk-TT6PWRR5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WMP3QCOR.mjs +46 -0
- package/dist/lib/neutral/chunk-WMP3QCOR.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +541 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +15 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-2NJDD73M.mjs +61 -0
- package/dist/lib/neutral/create-2NJDD73M.mjs.map +7 -0
- package/dist/lib/neutral/create-channel-RYSV44N3.mjs +19 -0
- package/dist/lib/neutral/create-channel-RYSV44N3.mjs.map +7 -0
- package/dist/lib/neutral/create-object-D5XEG7MQ.mjs +28 -0
- package/dist/lib/neutral/create-object-D5XEG7MQ.mjs.map +7 -0
- package/dist/lib/neutral/create-proposals-7UZYZ32V.mjs +56 -0
- package/dist/lib/neutral/create-proposals-7UZYZ32V.mjs.map +7 -0
- package/dist/lib/neutral/delete-JVGAPD46.mjs +57 -0
- package/dist/lib/neutral/delete-JVGAPD46.mjs.map +7 -0
- package/dist/lib/neutral/delete-message-5EGR3HWH.mjs +54 -0
- package/dist/lib/neutral/delete-message-5EGR3HWH.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +10 -0
- package/dist/lib/neutral/index.mjs +32 -0
- package/dist/lib/neutral/markdown-B6RNVR2H.mjs +83 -0
- package/dist/lib/neutral/markdown-B6RNVR2H.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/on-create-space-ZQF55KSO.mjs +23 -0
- package/dist/lib/neutral/on-create-space-ZQF55KSO.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-RU6K2S4L.mjs +13 -0
- package/dist/lib/neutral/operation-handler-RU6K2S4L.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-ZSIQHN5P.mjs +76 -0
- package/dist/lib/neutral/react-surface-ZSIQHN5P.mjs.map +7 -0
- package/dist/lib/neutral/respond-to-thread-LVLDZON3.mjs +32 -0
- package/dist/lib/neutral/respond-to-thread-LVLDZON3.mjs.map +7 -0
- package/dist/lib/neutral/restore-Z5PYV7I2.mjs +32 -0
- package/dist/lib/neutral/restore-Z5PYV7I2.mjs.map +7 -0
- package/dist/lib/neutral/restore-message-B263PLUH.mjs +33 -0
- package/dist/lib/neutral/restore-message-B263PLUH.mjs.map +7 -0
- package/dist/lib/neutral/select-GXDEAH5D.mjs +24 -0
- package/dist/lib/neutral/select-GXDEAH5D.mjs.map +7 -0
- package/dist/lib/neutral/set-agent-config-7HHS6KZZ.mjs +20 -0
- package/dist/lib/neutral/set-agent-config-7HHS6KZZ.mjs.map +7 -0
- package/dist/lib/neutral/settings-HK4EB6TF.mjs +30 -0
- package/dist/lib/neutral/settings-HK4EB6TF.mjs.map +7 -0
- package/dist/lib/neutral/state-UU7VEAKV.mjs +22 -0
- package/dist/lib/neutral/state-UU7VEAKV.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +58 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/toggle-resolved-LBVNAVVF.mjs +36 -0
- package/dist/lib/neutral/toggle-resolved-LBVNAVVF.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +91 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +16 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/undo-mappings-HOKL2L3M.mjs +54 -0
- package/dist/lib/neutral/undo-mappings-HOKL2L3M.mjs.map +7 -0
- package/dist/types/src/ThreadPlugin.d.ts +3 -1
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/ThreadPlugin.node.d.ts +4 -0
- package/dist/types/src/ThreadPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ThreadPlugin.test.d.ts +2 -0
- package/dist/types/src/ThreadPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ThreadPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ThreadPlugin.workerd.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/blueprints/thread-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/thread-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/agent-runner.d.ts +22 -0
- package/dist/types/src/capabilities/agent-runner.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +16 -15
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +3 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +5 -5
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +51 -0
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +2 -0
- package/dist/types/src/components/Chat/index.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.d.ts +13 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.stories.d.ts +160 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.stories.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/CommentsThread.d.ts +14 -0
- package/dist/types/src/components/CommentsPanel/CommentsThread.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/index.d.ts +3 -0
- package/dist/types/src/components/CommentsPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/MessagePanel/MessagePanel.d.ts +15 -0
- package/dist/types/src/components/MessagePanel/MessagePanel.d.ts.map +1 -0
- package/dist/types/src/components/MessagePanel/index.d.ts +2 -0
- package/dist/types/src/components/MessagePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.d.ts +6 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.d.ts.map +1 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.stories.d.ts +161 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ThreadSettings/index.d.ts +2 -0
- package/dist/types/src/components/ThreadSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -10
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.d.ts +13 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.stories.d.ts +162 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChannelArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelChat/ChannelChat.d.ts +20 -0
- package/dist/types/src/containers/ChannelChat/ChannelChat.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelChat/index.d.ts +4 -0
- package/dist/types/src/containers/ChannelChat/index.d.ts.map +1 -0
- package/dist/types/src/containers/CommentsCompanion/CommentsCompanion.d.ts +11 -0
- package/dist/types/src/containers/CommentsCompanion/CommentsCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/CommentsCompanion/CommentsCompanion.stories.d.ts +198 -0
- package/dist/types/src/containers/CommentsCompanion/CommentsCompanion.stories.d.ts.map +1 -0
- package/dist/types/src/containers/CommentsCompanion/index.d.ts +2 -0
- package/dist/types/src/containers/CommentsCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadContainer/ThreadContainer.d.ts +20 -0
- package/dist/types/src/containers/ThreadContainer/ThreadContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadContainer/ThreadContainer.stories.d.ts +162 -0
- package/dist/types/src/containers/ThreadContainer/ThreadContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadContainer/index.d.ts +4 -0
- package/dist/types/src/containers/ThreadContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +6 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/{components/command-extension.d.ts → extensions/command.d.ts} +1 -1
- package/dist/types/src/extensions/command.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +1 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/threads.d.ts +9 -4
- package/dist/types/src/extensions/threads.d.ts.map +1 -1
- package/dist/types/src/hooks/analytics.d.ts +2 -3
- package/dist/types/src/hooks/analytics.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useStatus.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/add-message.d.ts +5 -0
- package/dist/types/src/operations/add-message.d.ts.map +1 -0
- package/dist/types/src/operations/append-channel-message.d.ts +5 -0
- package/dist/types/src/operations/append-channel-message.d.ts.map +1 -0
- package/dist/types/src/operations/create-channel.d.ts +5 -0
- package/dist/types/src/operations/create-channel.d.ts.map +1 -0
- package/dist/types/src/operations/create-proposals.d.ts +5 -0
- package/dist/types/src/operations/create-proposals.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/delete-message.d.ts +5 -0
- package/dist/types/src/operations/delete-message.d.ts.map +1 -0
- package/dist/types/src/operations/delete.d.ts +5 -0
- package/dist/types/src/operations/delete.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/on-create-space.d.ts +5 -0
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
- package/dist/types/src/operations/respond-to-thread.d.ts +5 -0
- package/dist/types/src/operations/respond-to-thread.d.ts.map +1 -0
- package/dist/types/src/operations/restore-message.d.ts +5 -0
- package/dist/types/src/operations/restore-message.d.ts.map +1 -0
- package/dist/types/src/operations/restore.d.ts +5 -0
- package/dist/types/src/operations/restore.d.ts.map +1 -0
- package/dist/types/src/operations/select.d.ts +5 -0
- package/dist/types/src/operations/select.d.ts.map +1 -0
- package/dist/types/src/operations/set-agent-config.d.ts +5 -0
- package/dist/types/src/operations/set-agent-config.d.ts.map +1 -0
- package/dist/types/src/operations/toggle-resolved.d.ts +5 -0
- package/dist/types/src/operations/toggle-resolved.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/should-trigger-agent.d.ts +22 -0
- package/dist/types/src/should-trigger-agent.d.ts.map +1 -0
- package/dist/types/src/should-trigger-agent.test.d.ts +2 -0
- package/dist/types/src/should-trigger-agent.test.d.ts.map +1 -0
- package/dist/types/src/{components/testing.d.ts → testing/data.d.ts} +4 -4
- package/dist/types/src/testing/data.d.ts.map +1 -0
- 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/translations.d.ts +142 -74
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/AgentIdentity.d.ts +27 -0
- package/dist/types/src/types/AgentIdentity.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +5 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/ThreadCapabilities.d.ts +34 -0
- package/dist/types/src/types/ThreadCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/ThreadOperation.d.ts +2409 -0
- package/dist/types/src/types/ThreadOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -458
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +6 -3
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +156 -85
- package/src/ThreadPlugin.node.ts +39 -0
- package/src/ThreadPlugin.test.ts +37 -0
- package/src/ThreadPlugin.tsx +58 -125
- package/src/ThreadPlugin.workerd.ts +20 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/thread-blueprint.ts +36 -0
- package/src/capabilities/agent-runner.ts +291 -0
- package/src/capabilities/app-graph-builder.ts +124 -165
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/index.ts +16 -12
- package/src/capabilities/markdown.ts +53 -36
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +64 -78
- package/src/capabilities/settings.ts +26 -12
- package/src/capabilities/state.ts +14 -18
- package/src/capabilities/undo-mappings.ts +46 -0
- package/src/components/Chat/Chat.tsx +259 -0
- package/src/components/Chat/index.ts +5 -0
- package/src/components/CommentsPanel/CommentsPanel.stories.tsx +94 -0
- package/src/components/CommentsPanel/CommentsPanel.tsx +71 -0
- package/src/components/CommentsPanel/CommentsThread.tsx +176 -0
- package/src/components/CommentsPanel/index.ts +6 -0
- package/src/components/{MessageContainer.tsx → MessagePanel/MessagePanel.tsx} +83 -47
- package/src/components/MessagePanel/index.ts +5 -0
- package/src/components/ThreadSettings/ThreadSettings.stories.tsx +32 -0
- package/src/components/ThreadSettings/ThreadSettings.tsx +19 -0
- package/src/components/ThreadSettings/index.ts +5 -0
- package/src/components/index.ts +5 -12
- package/src/containers/ChannelArticle/ChannelArticle.stories.tsx +105 -0
- package/src/containers/ChannelArticle/ChannelArticle.tsx +42 -0
- package/src/containers/ChannelArticle/index.ts +5 -0
- package/src/containers/ChannelChat/ChannelChat.tsx +75 -0
- package/src/containers/ChannelChat/index.ts +8 -0
- package/src/containers/CommentsCompanion/CommentsCompanion.stories.tsx +339 -0
- package/src/containers/CommentsCompanion/CommentsCompanion.tsx +216 -0
- package/src/containers/CommentsCompanion/index.ts +5 -0
- package/src/containers/ThreadContainer/ThreadContainer.stories.tsx +86 -0
- package/src/containers/ThreadContainer/ThreadContainer.tsx +75 -0
- package/src/containers/ThreadContainer/index.ts +8 -0
- package/src/containers/index.ts +10 -0
- package/src/{components/command-extension.ts → extensions/command.ts} +3 -3
- package/src/extensions/index.ts +1 -0
- package/src/extensions/threads.ts +88 -43
- package/src/hooks/analytics.ts +22 -21
- package/src/hooks/index.ts +0 -4
- package/src/index.ts +4 -4
- package/src/meta.ts +37 -7
- package/src/operations/add-message.ts +94 -0
- package/src/operations/append-channel-message.ts +37 -0
- package/src/operations/create-channel.ts +20 -0
- package/src/operations/create-proposals.ts +49 -0
- package/src/operations/create.ts +63 -0
- package/src/operations/delete-message.ts +53 -0
- package/src/operations/delete.ts +63 -0
- package/src/operations/index.ts +22 -0
- package/src/operations/on-create-space.ts +27 -0
- package/src/operations/respond-to-thread.ts +32 -0
- package/src/operations/restore-message.ts +38 -0
- package/src/operations/restore.ts +38 -0
- package/src/operations/select.ts +24 -0
- package/src/operations/set-agent-config.ts +24 -0
- package/src/operations/toggle-resolved.ts +41 -0
- package/src/plugin.ts +11 -0
- package/src/should-trigger-agent.test.ts +72 -0
- package/src/should-trigger-agent.ts +50 -0
- package/src/testing/data.ts +49 -0
- package/src/testing/index.ts +1 -1
- package/src/translations.ts +75 -75
- package/src/types/AgentIdentity.ts +35 -0
- package/src/types/Settings.ts +10 -0
- package/src/types/ThreadCapabilities.ts +46 -0
- package/src/types/ThreadOperation.ts +217 -0
- package/src/types/index.ts +5 -1
- package/src/types/types.ts +4 -109
- package/src/util.ts +37 -5
- package/dist/lib/browser/ChannelContainer-BGDGZHV4.mjs +0 -16
- package/dist/lib/browser/ChatContainer-75KJZ4XR.mjs +0 -15
- package/dist/lib/browser/app-graph-builder-ODKIAXR7.mjs +0 -171
- package/dist/lib/browser/app-graph-builder-ODKIAXR7.mjs.map +0 -7
- package/dist/lib/browser/call-manager-BCKLI4QD.mjs +0 -24
- package/dist/lib/browser/call-manager-BCKLI4QD.mjs.map +0 -7
- package/dist/lib/browser/chunk-2MUYQOQE.mjs +0 -23
- package/dist/lib/browser/chunk-2MUYQOQE.mjs.map +0 -7
- package/dist/lib/browser/chunk-B7YQ7QR2.mjs +0 -376
- package/dist/lib/browser/chunk-B7YQ7QR2.mjs.map +0 -7
- package/dist/lib/browser/chunk-CMCVHULC.mjs +0 -986
- package/dist/lib/browser/chunk-CMCVHULC.mjs.map +0 -7
- package/dist/lib/browser/chunk-CP7E2HRE.mjs.map +0 -7
- package/dist/lib/browser/chunk-HDEQRBOC.mjs +0 -181
- package/dist/lib/browser/chunk-HDEQRBOC.mjs.map +0 -7
- package/dist/lib/browser/chunk-L326LSNS.mjs +0 -18
- package/dist/lib/browser/chunk-L326LSNS.mjs.map +0 -7
- package/dist/lib/browser/chunk-T4KJ5JR4.mjs +0 -15
- package/dist/lib/browser/chunk-T4KJ5JR4.mjs.map +0 -7
- package/dist/lib/browser/chunk-VJMKS4CZ.mjs +0 -619
- package/dist/lib/browser/chunk-VJMKS4CZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-VTYX3SIM.mjs +0 -147
- package/dist/lib/browser/chunk-VTYX3SIM.mjs.map +0 -7
- package/dist/lib/browser/chunk-XYUJXHYV.mjs +0 -106
- package/dist/lib/browser/chunk-XYUJXHYV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZCEU5K23.mjs +0 -1890
- package/dist/lib/browser/chunk-ZCEU5K23.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -312
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-VOQD3TQ2.mjs +0 -427
- package/dist/lib/browser/intent-resolver-VOQD3TQ2.mjs.map +0 -7
- package/dist/lib/browser/markdown-R6MGRIA6.mjs +0 -169
- package/dist/lib/browser/markdown-R6MGRIA6.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-root-UMSBTN6H.mjs +0 -28
- package/dist/lib/browser/react-root-UMSBTN6H.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SXMQEWKE.mjs +0 -109
- package/dist/lib/browser/react-surface-SXMQEWKE.mjs.map +0 -7
- package/dist/lib/browser/settings-TCNF54PN.mjs +0 -22
- package/dist/lib/browser/settings-TCNF54PN.mjs.map +0 -7
- package/dist/lib/browser/state-ZQ4IPOJT.mjs +0 -34
- package/dist/lib/browser/state-ZQ4IPOJT.mjs.map +0 -7
- package/dist/lib/browser/toolkit-JF4B4QIO.mjs +0 -84
- package/dist/lib/browser/toolkit-JF4B4QIO.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -16
- package/dist/lib/node-esm/ChannelContainer-OXC6BTU7.mjs +0 -17
- package/dist/lib/node-esm/ChatContainer-SH6LTFQL.mjs +0 -16
- package/dist/lib/node-esm/app-graph-builder-DMPT3MY6.mjs +0 -172
- package/dist/lib/node-esm/app-graph-builder-DMPT3MY6.mjs.map +0 -7
- package/dist/lib/node-esm/call-manager-Q7RY2YP4.mjs +0 -25
- package/dist/lib/node-esm/call-manager-Q7RY2YP4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2KZ4ODHU.mjs +0 -987
- package/dist/lib/node-esm/chunk-2KZ4ODHU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2MMJF7DW.mjs +0 -182
- package/dist/lib/node-esm/chunk-2MMJF7DW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2V3WSLUZ.mjs +0 -108
- package/dist/lib/node-esm/chunk-2V3WSLUZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ABUFOZVX.mjs +0 -33
- package/dist/lib/node-esm/chunk-ABUFOZVX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BAMZXJS4.mjs +0 -148
- package/dist/lib/node-esm/chunk-BAMZXJS4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BTGKI5IK.mjs +0 -377
- package/dist/lib/node-esm/chunk-BTGKI5IK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GZ4WL2IS.mjs +0 -25
- package/dist/lib/node-esm/chunk-GZ4WL2IS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LCHTNRK7.mjs +0 -19
- package/dist/lib/node-esm/chunk-LCHTNRK7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NHSIAEDW.mjs +0 -620
- package/dist/lib/node-esm/chunk-NHSIAEDW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OBVAURUU.mjs +0 -17
- package/dist/lib/node-esm/chunk-OBVAURUU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TIPIOH2J.mjs +0 -1891
- package/dist/lib/node-esm/chunk-TIPIOH2J.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -313
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-AKVH66PH.mjs +0 -428
- package/dist/lib/node-esm/intent-resolver-AKVH66PH.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-MYGTDXT6.mjs +0 -170
- package/dist/lib/node-esm/markdown-MYGTDXT6.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-root-W6AVTL5M.mjs +0 -29
- package/dist/lib/node-esm/react-root-W6AVTL5M.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NLSZJGMO.mjs +0 -110
- package/dist/lib/node-esm/react-surface-NLSZJGMO.mjs.map +0 -7
- package/dist/lib/node-esm/settings-ZQHGVFBY.mjs +0 -23
- package/dist/lib/node-esm/settings-ZQHGVFBY.mjs.map +0 -7
- package/dist/lib/node-esm/state-FSLLJ5TZ.mjs +0 -35
- package/dist/lib/node-esm/state-FSLLJ5TZ.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-DHPKJITO.mjs +0 -85
- package/dist/lib/node-esm/toolkit-DHPKJITO.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -17
- package/dist/types/src/calls/call-manager.d.ts +0 -77
- package/dist/types/src/calls/call-manager.d.ts.map +0 -1
- package/dist/types/src/calls/call-swarm-synchronizer.d.ts +0 -66
- package/dist/types/src/calls/call-swarm-synchronizer.d.ts.map +0 -1
- package/dist/types/src/calls/index.d.ts +0 -7
- package/dist/types/src/calls/index.d.ts.map +0 -1
- package/dist/types/src/calls/media-manager.d.ts +0 -60
- package/dist/types/src/calls/media-manager.d.ts.map +0 -1
- package/dist/types/src/calls/speaking-monitor.d.ts +0 -24
- package/dist/types/src/calls/speaking-monitor.d.ts.map +0 -1
- package/dist/types/src/calls/types.d.ts +0 -45
- package/dist/types/src/calls/types.d.ts.map +0 -1
- package/dist/types/src/calls/util/audio.d.ts +0 -6
- package/dist/types/src/calls/util/audio.d.ts.map +0 -1
- package/dist/types/src/calls/util/calls-service.d.ts +0 -77
- package/dist/types/src/calls/util/calls-service.d.ts.map +0 -1
- package/dist/types/src/calls/util/history-cache.d.ts +0 -11
- package/dist/types/src/calls/util/history-cache.d.ts.map +0 -1
- package/dist/types/src/calls/util/index.d.ts +0 -5
- package/dist/types/src/calls/util/index.d.ts.map +0 -1
- package/dist/types/src/calls/util/media.d.ts +0 -6
- package/dist/types/src/calls/util/media.d.ts.map +0 -1
- package/dist/types/src/calls/util/stub-media-streams.d.ts +0 -18
- package/dist/types/src/calls/util/stub-media-streams.d.ts.map +0 -1
- package/dist/types/src/calls/util/task-scheduling.d.ts +0 -17
- package/dist/types/src/calls/util/task-scheduling.d.ts.map +0 -1
- package/dist/types/src/calls-service.stories.d.ts +0 -23
- package/dist/types/src/calls-service.stories.d.ts.map +0 -1
- package/dist/types/src/capabilities/call-manager.d.ts +0 -5
- package/dist/types/src/capabilities/call-manager.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -27
- package/dist/types/src/capabilities/capabilities.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-root.d.ts +0 -7
- package/dist/types/src/capabilities/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit.d.ts +0 -6
- package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
- package/dist/types/src/components/Call/Call.d.ts +0 -17
- package/dist/types/src/components/Call/Call.d.ts.map +0 -1
- package/dist/types/src/components/Call/Toolbar.d.ts +0 -16
- package/dist/types/src/components/Call/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Call/index.d.ts +0 -3
- package/dist/types/src/components/Call/index.d.ts.map +0 -1
- package/dist/types/src/components/CallDebugPanel.d.ts +0 -15
- package/dist/types/src/components/CallDebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/CallSidebar.d.ts +0 -4
- package/dist/types/src/components/CallSidebar.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.d.ts +0 -14
- package/dist/types/src/components/ChannelContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.stories.d.ts +0 -93
- package/dist/types/src/components/ChannelContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chat.stories.d.ts +0 -93
- package/dist/types/src/components/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts +0 -17
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/Comments.stories.d.ts +0 -158
- package/dist/types/src/components/Comments.stories.d.ts.map +0 -1
- package/dist/types/src/components/CommentsContainer.d.ts +0 -13
- package/dist/types/src/components/CommentsContainer.d.ts.map +0 -1
- package/dist/types/src/components/CommentsThreadContainer.d.ts +0 -14
- package/dist/types/src/components/CommentsThreadContainer.d.ts.map +0 -1
- package/dist/types/src/components/Lobby/Lobby.d.ts +0 -15
- package/dist/types/src/components/Lobby/Lobby.d.ts.map +0 -1
- package/dist/types/src/components/Lobby/index.d.ts +0 -2
- package/dist/types/src/components/Lobby/index.d.ts.map +0 -1
- package/dist/types/src/components/Media/AudioStream.d.ts +0 -6
- package/dist/types/src/components/Media/AudioStream.d.ts.map +0 -1
- package/dist/types/src/components/Media/VideoObject.d.ts +0 -15
- package/dist/types/src/components/Media/VideoObject.d.ts.map +0 -1
- package/dist/types/src/components/Media/VideoObject.stories.d.ts +0 -22
- package/dist/types/src/components/Media/VideoObject.stories.d.ts.map +0 -1
- package/dist/types/src/components/Media/index.d.ts +0 -3
- package/dist/types/src/components/Media/index.d.ts.map +0 -1
- package/dist/types/src/components/MessageContainer.d.ts +0 -14
- package/dist/types/src/components/MessageContainer.d.ts.map +0 -1
- package/dist/types/src/components/Participant/Participant.d.ts +0 -6
- package/dist/types/src/components/Participant/Participant.d.ts.map +0 -1
- package/dist/types/src/components/Participant/ParticipantGrid.d.ts +0 -11
- package/dist/types/src/components/Participant/ParticipantGrid.d.ts.map +0 -1
- package/dist/types/src/components/Participant/index.d.ts +0 -3
- package/dist/types/src/components/Participant/index.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.d.ts +0 -12
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts +0 -162
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.d.ts +0 -32
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts +0 -176
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGridItem.d.ts +0 -21
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGridItem.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/index.d.ts +0 -4
- package/dist/types/src/components/ResponsiveGrid/index.d.ts.map +0 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +0 -5
- package/dist/types/src/components/ThreadComplementary.d.ts.map +0 -1
- package/dist/types/src/components/ThreadSettings.d.ts +0 -6
- package/dist/types/src/components/ThreadSettings.d.ts.map +0 -1
- package/dist/types/src/components/command-extension.d.ts.map +0 -1
- package/dist/types/src/components/testing.d.ts.map +0 -1
- package/dist/types/src/hooks/useBlackCanvasStreamTrack.d.ts +0 -2
- package/dist/types/src/hooks/useBlackCanvasStreamTrack.d.ts.map +0 -1
- package/dist/types/src/hooks/useDebugMode.d.ts +0 -2
- package/dist/types/src/hooks/useDebugMode.d.ts.map +0 -1
- package/dist/types/src/hooks/useInaudibleAudioStreamTrack.d.ts +0 -2
- package/dist/types/src/hooks/useInaudibleAudioStreamTrack.d.ts.map +0 -1
- package/dist/types/src/hooks/useVideoStreamTrack.d.ts +0 -3
- package/dist/types/src/hooks/useVideoStreamTrack.d.ts.map +0 -1
- package/dist/types/src/testing/stories.d.ts +0 -2
- package/dist/types/src/testing/stories.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -179
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/calls/call-manager.ts +0 -246
- package/src/calls/call-swarm-synchronizer.ts +0 -350
- package/src/calls/index.ts +0 -10
- package/src/calls/media-manager.ts +0 -375
- package/src/calls/speaking-monitor.ts +0 -85
- package/src/calls/types.ts +0 -74
- package/src/calls/util/audio.ts +0 -58
- package/src/calls/util/calls-service.ts +0 -581
- package/src/calls/util/history-cache.ts +0 -27
- package/src/calls/util/index.ts +0 -8
- package/src/calls/util/media.ts +0 -52
- package/src/calls/util/stub-media-streams.ts +0 -127
- package/src/calls/util/task-scheduling.ts +0 -92
- package/src/calls-service.stories.tsx +0 -229
- package/src/capabilities/call-manager.ts +0 -20
- package/src/capabilities/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -348
- package/src/capabilities/react-root.tsx +0 -17
- package/src/capabilities/toolkit.ts +0 -82
- package/src/components/Call/Call.tsx +0 -89
- package/src/components/Call/Toolbar.tsx +0 -182
- package/src/components/Call/index.ts +0 -6
- package/src/components/CallDebugPanel.tsx +0 -174
- package/src/components/CallSidebar.tsx +0 -18
- package/src/components/ChannelContainer.stories.tsx +0 -59
- package/src/components/ChannelContainer.tsx +0 -201
- package/src/components/Chat.stories.tsx +0 -91
- package/src/components/ChatContainer.tsx +0 -145
- package/src/components/Comments.stories.tsx +0 -91
- package/src/components/CommentsContainer.tsx +0 -72
- package/src/components/CommentsThreadContainer.tsx +0 -169
- package/src/components/Lobby/Lobby.tsx +0 -119
- package/src/components/Lobby/index.ts +0 -5
- package/src/components/Media/AudioStream.tsx +0 -67
- package/src/components/Media/VideoObject.stories.tsx +0 -60
- package/src/components/Media/VideoObject.tsx +0 -58
- package/src/components/Media/index.ts +0 -6
- package/src/components/Participant/Participant.tsx +0 -63
- package/src/components/Participant/ParticipantGrid.tsx +0 -89
- package/src/components/Participant/index.ts +0 -6
- package/src/components/ResponsiveGrid/ResponsiveContainer.stories.tsx +0 -54
- package/src/components/ResponsiveGrid/ResponsiveContainer.tsx +0 -31
- package/src/components/ResponsiveGrid/ResponsiveGrid.stories.tsx +0 -158
- package/src/components/ResponsiveGrid/ResponsiveGrid.tsx +0 -341
- package/src/components/ResponsiveGrid/ResponsiveGridItem.tsx +0 -131
- package/src/components/ResponsiveGrid/index.ts +0 -7
- package/src/components/ThreadComplementary.tsx +0 -181
- package/src/components/ThreadSettings.tsx +0 -16
- package/src/components/testing.ts +0 -51
- package/src/hooks/useBlackCanvasStreamTrack.tsx +0 -27
- package/src/hooks/useDebugMode.ts +0 -25
- package/src/hooks/useInaudibleAudioStreamTrack.tsx +0 -27
- package/src/hooks/useVideoStreamTrack.tsx +0 -36
- package/src/testing/stories.ts +0 -54
- package/src/types/schema.ts +0 -33
- package/src/typings/peermetrics-webrtc-stats.d.ts +0 -46
- package/src/typings.d.ts +0 -8
- /package/dist/lib/{browser/ChannelContainer-BGDGZHV4.mjs.map → neutral/ChannelChat-LZEDFJVD.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser/ChatContainer-75KJZ4XR.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/hooks}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/ChannelContainer-OXC6BTU7.mjs.map → neutral/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/ChatContainer-SH6LTFQL.mjs.map → neutral/meta.mjs.map} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
|
|
9
|
+
import { computeDiffsWithCursors } from '@dxos/assistant';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Database, Obj, Ref, Relation } from '@dxos/echo';
|
|
12
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
13
|
+
import { AnchoredTo, Message, Thread } from '@dxos/types';
|
|
14
|
+
|
|
15
|
+
import { ThreadOperation } from '../types';
|
|
16
|
+
|
|
17
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.CreateProposals> = ThreadOperation.CreateProposals.pipe(
|
|
18
|
+
Operation.withHandler(
|
|
19
|
+
Effect.fn(function* ({ doc, diffs }) {
|
|
20
|
+
const object = yield* Database.load(doc);
|
|
21
|
+
const content = yield* Effect.promise(() => object.content.load());
|
|
22
|
+
const accessor = createDocAccessor(content, ['content']);
|
|
23
|
+
|
|
24
|
+
yield* Function.pipe(
|
|
25
|
+
computeDiffsWithCursors(accessor, diffs),
|
|
26
|
+
Array.map(
|
|
27
|
+
Effect.fnUntraced(function* ({ cursor, text }) {
|
|
28
|
+
const proposal = Obj.make(Message.Message, {
|
|
29
|
+
created: new Date().toISOString(),
|
|
30
|
+
sender: { role: 'assistant' },
|
|
31
|
+
blocks: [{ _tag: 'proposal', text }],
|
|
32
|
+
});
|
|
33
|
+
const thread = Thread.make({ name: 'Proposal', messages: [Ref.make(proposal)], status: 'active' });
|
|
34
|
+
const relation = Relation.make(AnchoredTo.AnchoredTo, {
|
|
35
|
+
[Relation.Source]: thread,
|
|
36
|
+
[Relation.Target]: object,
|
|
37
|
+
anchor: cursor,
|
|
38
|
+
});
|
|
39
|
+
yield* Database.add(thread);
|
|
40
|
+
yield* Database.add(relation);
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
Effect.allWith({ concurrency: 'unbounded' }),
|
|
44
|
+
);
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export default handler;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
10
|
+
import { Obj, Relation } from '@dxos/echo';
|
|
11
|
+
import { Markdown, MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
12
|
+
import { linkedSegment } from '@dxos/react-ui-attention';
|
|
13
|
+
import { AnchoredTo, Thread } from '@dxos/types';
|
|
14
|
+
|
|
15
|
+
import { ThreadCapabilities } from '../types';
|
|
16
|
+
import { ThreadOperation } from '../types';
|
|
17
|
+
|
|
18
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.Create> = ThreadOperation.Create.pipe(
|
|
19
|
+
Operation.withHandler(
|
|
20
|
+
Effect.fnUntraced(function* ({ name, anchor: _anchor, subject }) {
|
|
21
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
22
|
+
const stateAtom = yield* Capability.get(ThreadCapabilities.State);
|
|
23
|
+
const subjectId = Obj.getURI(subject);
|
|
24
|
+
|
|
25
|
+
// Inherit the markdown plugin's `commentAgentMode` setting when the
|
|
26
|
+
// subject is a Markdown.Document, so new comment threads on docs are
|
|
27
|
+
// opted-in (or not) based on the user's preference. Non-markdown
|
|
28
|
+
// subjects always get an un-opted thread (no agent).
|
|
29
|
+
const markdownSettingsAtoms = yield* Capability.getAll(MarkdownCapabilities.Settings);
|
|
30
|
+
const markdownSettingsAtom = markdownSettingsAtoms[0];
|
|
31
|
+
const commentAgentMode =
|
|
32
|
+
markdownSettingsAtom && Obj.instanceOf(Markdown.Document, subject)
|
|
33
|
+
? registry.get(markdownSettingsAtom).commentAgentMode
|
|
34
|
+
: undefined;
|
|
35
|
+
const agent =
|
|
36
|
+
commentAgentMode && commentAgentMode !== 'off' ? { enabled: true, mode: commentAgentMode } : undefined;
|
|
37
|
+
|
|
38
|
+
const thread = Thread.make({ name, agent });
|
|
39
|
+
const anchor = Relation.make(AnchoredTo.AnchoredTo, {
|
|
40
|
+
[Relation.Source]: thread,
|
|
41
|
+
[Relation.Target]: subject,
|
|
42
|
+
anchor: _anchor,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const state = registry.get(stateAtom);
|
|
46
|
+
const existingDrafts = state.drafts[subjectId];
|
|
47
|
+
registry.set(stateAtom, {
|
|
48
|
+
...state,
|
|
49
|
+
drafts: {
|
|
50
|
+
...state.drafts,
|
|
51
|
+
[subjectId]: existingDrafts ? [...existingDrafts, anchor] : [anchor],
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
yield* Operation.invoke(ThreadOperation.Select, { current: Obj.getURI(thread) });
|
|
56
|
+
yield* Operation.invoke(LayoutOperation.UpdateCompanion, {
|
|
57
|
+
subject: linkedSegment('comments'),
|
|
58
|
+
});
|
|
59
|
+
}),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export default handler;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Obj, Relation } from '@dxos/echo';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability';
|
|
11
|
+
import { Thread } from '@dxos/types';
|
|
12
|
+
|
|
13
|
+
import { ThreadOperation } from '../types';
|
|
14
|
+
|
|
15
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.DeleteMessage> = ThreadOperation.DeleteMessage.pipe(
|
|
16
|
+
Operation.withHandler(
|
|
17
|
+
Effect.fnUntraced(function* ({ subject, anchor, messageId }) {
|
|
18
|
+
const thread = Relation.getSource(anchor) as Thread.Thread;
|
|
19
|
+
const db = Obj.getDatabase(subject);
|
|
20
|
+
invariant(db, 'Database not found');
|
|
21
|
+
|
|
22
|
+
const msgIndex = thread.messages.findIndex((ref) => ref.target?.id === messageId);
|
|
23
|
+
const msg = thread.messages[msgIndex]?.target;
|
|
24
|
+
if (!msg) {
|
|
25
|
+
return { messageIndex: -1 };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (msgIndex === 0 && thread.messages.length === 1) {
|
|
29
|
+
// TODO(wittjosiah): This doesn't support restoring the thread.
|
|
30
|
+
yield* Operation.invoke(ThreadOperation.Delete, { subject, anchor });
|
|
31
|
+
return { messageIndex: -1 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Obj.update(thread, (thread) => {
|
|
35
|
+
thread.messages.splice(msgIndex, 1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
yield* Operation.schedule(ObservabilityOperation.SendEvent, {
|
|
39
|
+
name: 'threads.message.delete',
|
|
40
|
+
properties: {
|
|
41
|
+
spaceId: db.spaceId,
|
|
42
|
+
threadId: thread.id,
|
|
43
|
+
threadLength: thread.messages.length,
|
|
44
|
+
messageId,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { message: msg, messageIndex: msgIndex };
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export default handler;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { sleep } from '@dxos/async';
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
10
|
+
import { Obj, Relation } from '@dxos/echo';
|
|
11
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability';
|
|
12
|
+
import { Thread } from '@dxos/types';
|
|
13
|
+
|
|
14
|
+
import { ThreadCapabilities } from '../types';
|
|
15
|
+
import { ThreadOperation } from '../types';
|
|
16
|
+
|
|
17
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.Delete> = ThreadOperation.Delete.pipe(
|
|
18
|
+
Operation.withHandler(
|
|
19
|
+
Effect.fnUntraced(function* ({ subject, anchor, thread: _thread }) {
|
|
20
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
21
|
+
const stateAtom = yield* Capability.get(ThreadCapabilities.State);
|
|
22
|
+
const thread = _thread ?? (Relation.getSource(anchor) as Thread.Thread);
|
|
23
|
+
const subjectId = Obj.getURI(subject);
|
|
24
|
+
const state = registry.get(stateAtom);
|
|
25
|
+
const draft = state.drafts[subjectId];
|
|
26
|
+
if (draft) {
|
|
27
|
+
const index = draft.findIndex((a: { id: string }) => a.id === anchor.id);
|
|
28
|
+
if (index !== -1) {
|
|
29
|
+
registry.set(stateAtom, {
|
|
30
|
+
...state,
|
|
31
|
+
drafts: {
|
|
32
|
+
...state.drafts,
|
|
33
|
+
[subjectId]: state.drafts[subjectId]?.filter((_, i) => i !== index),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const db = Obj.getDatabase(thread);
|
|
41
|
+
if (!db) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// TODO(wittjosiah): Without sleep, rendering crashes at `Relation.setSource(anchor)`.
|
|
46
|
+
db.remove(anchor);
|
|
47
|
+
yield* Effect.promise(() => sleep(100));
|
|
48
|
+
db.remove(thread);
|
|
49
|
+
|
|
50
|
+
yield* Operation.schedule(ObservabilityOperation.SendEvent, {
|
|
51
|
+
name: 'threads.delete',
|
|
52
|
+
properties: {
|
|
53
|
+
spaceId: db.spaceId,
|
|
54
|
+
threadId: thread.id,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return { thread, anchor };
|
|
59
|
+
}),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export default handler;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
|
+
|
|
7
|
+
export const ThreadOperationHandlerSet = OperationHandlerSet.lazy(
|
|
8
|
+
() => import('./add-message'),
|
|
9
|
+
() => import('./append-channel-message'),
|
|
10
|
+
() => import('./create'),
|
|
11
|
+
() => import('./create-channel'),
|
|
12
|
+
() => import('./create-proposals'),
|
|
13
|
+
() => import('./delete'),
|
|
14
|
+
() => import('./delete-message'),
|
|
15
|
+
() => import('./on-create-space'),
|
|
16
|
+
() => import('./respond-to-thread'),
|
|
17
|
+
() => import('./restore'),
|
|
18
|
+
() => import('./restore-message'),
|
|
19
|
+
() => import('./select'),
|
|
20
|
+
() => import('./set-agent-config'),
|
|
21
|
+
() => import('./toggle-resolved'),
|
|
22
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
|
|
9
|
+
import { ThreadOperation } from '../types';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.OnCreateSpace> = ThreadOperation.OnCreateSpace.pipe(
|
|
12
|
+
Operation.withHandler(
|
|
13
|
+
Effect.fnUntraced(function* ({ space, isDefault }) {
|
|
14
|
+
if (isDefault) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { object: channel } = yield* Operation.invoke(ThreadOperation.CreateChannel, {
|
|
19
|
+
name: 'General',
|
|
20
|
+
spaceId: space.id,
|
|
21
|
+
});
|
|
22
|
+
space.db.add(channel);
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export default handler;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Database } from '@dxos/echo';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
import { ThreadCapabilities, ThreadOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.RespondToThread> = ThreadOperation.RespondToThread.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ thread: threadRef, subject: subjectRef }) {
|
|
17
|
+
const runner = yield* Capability.get(ThreadCapabilities.AgentRunner);
|
|
18
|
+
const thread = yield* Database.load(threadRef);
|
|
19
|
+
const subject = yield* Database.load(subjectRef);
|
|
20
|
+
|
|
21
|
+
yield* runner.run({ thread, subject }).pipe(
|
|
22
|
+
Effect.catchAll((error) =>
|
|
23
|
+
Effect.sync(() => {
|
|
24
|
+
log.warn('comment-thread agent failed', { threadId: thread.id, error });
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export default handler;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Obj, Ref, Relation } from '@dxos/echo';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability';
|
|
11
|
+
import { Thread } from '@dxos/types';
|
|
12
|
+
|
|
13
|
+
import { ThreadOperation } from '../types';
|
|
14
|
+
|
|
15
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.RestoreMessage> = ThreadOperation.RestoreMessage.pipe(
|
|
16
|
+
Operation.withHandler(
|
|
17
|
+
Effect.fnUntraced(function* ({ anchor, message, messageIndex }) {
|
|
18
|
+
const thread = Relation.getSource(anchor) as Thread.Thread;
|
|
19
|
+
const db = Obj.getDatabase(thread);
|
|
20
|
+
invariant(db, 'Database not found');
|
|
21
|
+
|
|
22
|
+
Obj.update(thread, (thread) => {
|
|
23
|
+
thread.messages.splice(messageIndex, 0, Ref.make(message));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
yield* Operation.schedule(ObservabilityOperation.SendEvent, {
|
|
27
|
+
name: 'threads.message.undo-delete',
|
|
28
|
+
properties: {
|
|
29
|
+
spaceId: db.spaceId,
|
|
30
|
+
threadId: thread.id,
|
|
31
|
+
messageId: message.id,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default handler;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { sleep } from '@dxos/async';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability';
|
|
11
|
+
|
|
12
|
+
import { ThreadOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.Restore> = ThreadOperation.Restore.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ thread, anchor }) {
|
|
17
|
+
const db = Obj.getDatabase(thread);
|
|
18
|
+
if (!db) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// TODO(wittjosiah): Without sleep, rendering crashes at `Relation.setSource(anchor)`.
|
|
23
|
+
db.add(thread);
|
|
24
|
+
yield* Effect.promise(() => sleep(100));
|
|
25
|
+
db.add(anchor);
|
|
26
|
+
|
|
27
|
+
yield* Operation.schedule(ObservabilityOperation.SendEvent, {
|
|
28
|
+
name: 'threads.undo-delete',
|
|
29
|
+
properties: {
|
|
30
|
+
spaceId: db.spaceId,
|
|
31
|
+
threadId: thread.id,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default handler;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { ThreadCapabilities } from '../types';
|
|
11
|
+
import { ThreadOperation } from '../types';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.Select> = ThreadOperation.Select.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fnUntraced(function* (input) {
|
|
16
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
17
|
+
const stateAtom = yield* Capability.get(ThreadCapabilities.State);
|
|
18
|
+
const current = registry.get(stateAtom);
|
|
19
|
+
registry.set(stateAtom, { ...current, current: input.current });
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default handler;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Database, Obj } from '@dxos/echo';
|
|
9
|
+
import { type Thread } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
import { ThreadOperation } from '../types';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.SetAgentConfig> = ThreadOperation.SetAgentConfig.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fnUntraced(function* ({ thread: threadRef, config }) {
|
|
16
|
+
const thread = yield* Database.load(threadRef);
|
|
17
|
+
Obj.update(thread, (thread) => {
|
|
18
|
+
(thread as Obj.Mutable<Thread.Thread>).agent = config;
|
|
19
|
+
});
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default handler;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability';
|
|
11
|
+
|
|
12
|
+
import { ThreadOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ThreadOperation.ToggleResolved> = ThreadOperation.ToggleResolved.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* (input) {
|
|
17
|
+
const thread = input.thread;
|
|
18
|
+
|
|
19
|
+
Obj.update(thread, (thread) => {
|
|
20
|
+
if (thread.status === 'active' || thread.status === undefined) {
|
|
21
|
+
thread.status = 'resolved';
|
|
22
|
+
} else if (thread.status === 'resolved') {
|
|
23
|
+
thread.status = 'active';
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const db = Obj.getDatabase(thread);
|
|
28
|
+
invariant(db, 'Database not found');
|
|
29
|
+
|
|
30
|
+
yield* Operation.schedule(ObservabilityOperation.SendEvent, {
|
|
31
|
+
name: 'threads.toggle-resolved',
|
|
32
|
+
properties: {
|
|
33
|
+
spaceId: db.spaceId,
|
|
34
|
+
threadId: thread.id,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export default handler;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const ThreadPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { ThreadOperationHandlerSet } from './operations';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { type Message, type Thread } from '@dxos/types';
|
|
8
|
+
|
|
9
|
+
import { shouldTriggerAgent } from './should-trigger-agent';
|
|
10
|
+
|
|
11
|
+
// `shouldTriggerAgent` is a pure predicate over the schema shapes — these tests
|
|
12
|
+
// build plain object literals shaped like Message/Thread to avoid the ECHO proxy's
|
|
13
|
+
// `Obj.update`-only mutation guard.
|
|
14
|
+
const makeMessage = (role: 'user' | 'assistant' | undefined, text: string): Message.Message =>
|
|
15
|
+
({
|
|
16
|
+
created: new Date().toISOString(),
|
|
17
|
+
sender: role ? { role } : {},
|
|
18
|
+
blocks: [{ _tag: 'text', text }],
|
|
19
|
+
}) as unknown as Message.Message;
|
|
20
|
+
|
|
21
|
+
const makeThread = (overrides: Partial<Thread.Thread> = {}): Thread.Thread =>
|
|
22
|
+
({
|
|
23
|
+
status: 'active',
|
|
24
|
+
messages: [],
|
|
25
|
+
...overrides,
|
|
26
|
+
}) as unknown as Thread.Thread;
|
|
27
|
+
|
|
28
|
+
describe('shouldTriggerAgent', () => {
|
|
29
|
+
test('returns false when agent is undefined', ({ expect }) => {
|
|
30
|
+
expect(shouldTriggerAgent(makeThread(), makeMessage('user', 'hi'), 'echo')).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('returns false when agent is disabled', ({ expect }) => {
|
|
34
|
+
const thread = makeThread({ agent: { enabled: false, mode: 'auto' } });
|
|
35
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'hi'), 'echo')).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('returns false on assistant-authored messages (self-loop guard)', ({ expect }) => {
|
|
39
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'auto' } });
|
|
40
|
+
expect(shouldTriggerAgent(thread, makeMessage('assistant', 'hi'), 'echo')).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('treats messages with no role as user messages (current CommentsCompanion pattern)', ({ expect }) => {
|
|
44
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'auto' } });
|
|
45
|
+
expect(shouldTriggerAgent(thread, makeMessage(undefined, 'hi'), 'echo')).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('returns false on resolved threads even when enabled', ({ expect }) => {
|
|
49
|
+
const thread = makeThread({ status: 'resolved', agent: { enabled: true, mode: 'auto' } });
|
|
50
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'hi'), 'echo')).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('auto mode fires on any user message', ({ expect }) => {
|
|
54
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'auto' } });
|
|
55
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'anything goes'), 'echo')).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('mention mode does not fire without @name', ({ expect }) => {
|
|
59
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'mention' } });
|
|
60
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'hello world'), 'echo')).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('mention mode fires on @name match (case-insensitive)', ({ expect }) => {
|
|
64
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'mention' } });
|
|
65
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'hey @Echo check this'), 'echo')).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('mention mode requires the @ sigil, not just the name', ({ expect }) => {
|
|
69
|
+
const thread = makeThread({ agent: { enabled: true, mode: 'mention' } });
|
|
70
|
+
expect(shouldTriggerAgent(thread, makeMessage('user', 'echo location'), 'echo')).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Message, type Thread } from '@dxos/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the concatenated text of all 'text' blocks on a message.
|
|
9
|
+
*
|
|
10
|
+
* Proposal blocks (assistant-authored markdown diffs) are intentionally
|
|
11
|
+
* excluded — gating mentions off a proposal text would be meaningless.
|
|
12
|
+
*/
|
|
13
|
+
export const textOf = (message: Message.Message | undefined): string => {
|
|
14
|
+
if (!message) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
return message.blocks
|
|
18
|
+
.filter((block): block is Extract<Message.Message['blocks'][number], { _tag: 'text' }> => block._tag === 'text')
|
|
19
|
+
.map((block) => block.text)
|
|
20
|
+
.join('\n');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Trigger gate for the comment-thread agent.
|
|
25
|
+
*
|
|
26
|
+
* Returns true iff the agent should respond to the latest message. All of:
|
|
27
|
+
* - `thread.agent` exists and `enabled === true`
|
|
28
|
+
* - `message.sender.role !== 'assistant'` (structural self-loop guard).
|
|
29
|
+
* Note: user-authored messages typically have NO role set; only assistant
|
|
30
|
+
* messages carry an explicit role.
|
|
31
|
+
* - `thread.status !== 'resolved'`
|
|
32
|
+
* - Either mode === 'auto', OR text contains an `@{agentName}` mention
|
|
33
|
+
* (case-insensitive substring match; v1 — promote to a parser later).
|
|
34
|
+
*/
|
|
35
|
+
export const shouldTriggerAgent = (thread: Thread.Thread, message: Message.Message, agentName: string): boolean => {
|
|
36
|
+
if (!thread.agent?.enabled) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (message.sender.role === 'assistant') {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (thread.status === 'resolved') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (thread.agent.mode === 'auto') {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const needle = '@' + agentName.toLowerCase();
|
|
49
|
+
return textOf(message).toLowerCase().includes(needle);
|
|
50
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Obj, Ref } from '@dxos/echo';
|
|
6
|
+
import { IdentityDid } from '@dxos/keys';
|
|
7
|
+
import { random } from '@dxos/random';
|
|
8
|
+
import { type Identity } from '@dxos/react-client/halo';
|
|
9
|
+
import { Message, Thread } from '@dxos/types';
|
|
10
|
+
|
|
11
|
+
export const createCommentThread = (identity: Identity): Thread.Thread => {
|
|
12
|
+
return Thread.make({
|
|
13
|
+
name: 'Comment',
|
|
14
|
+
messages: random.helpers.multiple(
|
|
15
|
+
() =>
|
|
16
|
+
Ref.make(
|
|
17
|
+
Obj.make(Message.Message, {
|
|
18
|
+
created: new Date().toISOString(),
|
|
19
|
+
sender: {
|
|
20
|
+
identityDid: random.datatype.boolean() ? identity.did : IdentityDid.random(),
|
|
21
|
+
},
|
|
22
|
+
blocks: [{ _tag: 'text', text: random.lorem.sentences(3) }],
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
{ count: { min: 2, max: 3 } },
|
|
26
|
+
),
|
|
27
|
+
status: 'active',
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const createProposalThread = (identity: Identity): Thread.Thread => {
|
|
32
|
+
return Thread.make({
|
|
33
|
+
name: 'Proposal',
|
|
34
|
+
messages: random.helpers.multiple(
|
|
35
|
+
() =>
|
|
36
|
+
Ref.make(
|
|
37
|
+
Obj.make(Message.Message, {
|
|
38
|
+
created: new Date().toISOString(),
|
|
39
|
+
sender: {
|
|
40
|
+
identityDid: random.datatype.boolean() ? identity.did : IdentityDid.random(),
|
|
41
|
+
},
|
|
42
|
+
blocks: [{ _tag: 'proposal', text: random.lorem.sentences(3) }],
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
{ count: { min: 1, max: 1 } },
|
|
46
|
+
),
|
|
47
|
+
status: 'active',
|
|
48
|
+
});
|
|
49
|
+
};
|
package/src/testing/index.ts
CHANGED