@dxos/plugin-automation 0.8.4-main.fffef41 → 0.9.0
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/PLUGIN.mdl +428 -0
- package/README.md +1 -1
- package/dist/lib/neutral/AutomationArticle-GN36NUX2.mjs +17 -0
- package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs +165 -0
- package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.mjs +10 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs +1132 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.workerd.mjs +36 -0
- package/dist/lib/neutral/AutomationPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs +27 -0
- package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs.map +7 -0
- package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
- package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs +102 -0
- package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +25 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +19 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-24JKY6NU.mjs +21 -0
- package/dist/lib/neutral/chunk-24JKY6NU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs +36 -0
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FE7YFBX7.mjs +486 -0
- package/dist/lib/neutral/chunk-FE7YFBX7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GARB7S5R.mjs +157 -0
- package/dist/lib/neutral/chunk-GARB7S5R.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HPUHQ3L6.mjs +64 -0
- package/dist/lib/neutral/chunk-HPUHQ3L6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-SONGOJRB.mjs +8 -0
- package/dist/lib/neutral/chunk-SONGOJRB.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +48 -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-automation-OE3TNXYE.mjs +41 -0
- package/dist/lib/neutral/create-automation-OE3TNXYE.mjs.map +7 -0
- package/dist/lib/neutral/create-object-MEJOWGMH.mjs +25 -0
- package/dist/lib/neutral/create-object-MEJOWGMH.mjs.map +7 -0
- package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs +68 -0
- package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +47 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +22 -0
- package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs +137 -0
- package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs +14 -0
- package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-IBRWUKPC.mjs +54 -0
- package/dist/lib/neutral/react-surface-IBRWUKPC.mjs.map +7 -0
- package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs +86 -0
- package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs.map +7 -0
- package/dist/lib/neutral/templates-ETXVD3VE.mjs +16 -0
- package/dist/lib/neutral/templates-ETXVD3VE.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/translations.mjs +64 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs +77 -0
- package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +18 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts +3 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/AutomationPlugin.node.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
- package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.workerd.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.workerd.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/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.test.d.ts +2 -0
- package/dist/types/src/capabilities/create-object.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +16 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/layer-specs.d.ts +6 -0
- package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts +6 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/node.d.ts +9 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- 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/registry-sync.d.ts +21 -0
- package/dist/types/src/capabilities/registry-sync.d.ts.map +1 -0
- package/dist/types/src/capabilities/templates.d.ts +6 -0
- package/dist/types/src/capabilities/templates.d.ts.map +1 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.d.ts +5 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.d.ts.map +1 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts +2 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts.map +1 -0
- package/dist/types/src/commands/index.d.ts +2 -0
- package/dist/types/src/commands/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/options.d.ts +10 -0
- package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts +11 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/util.d.ts +85 -0
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts +14 -0
- package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts.map +1 -0
- package/dist/types/src/components/CreateAutomationPanel/index.d.ts +2 -0
- package/dist/types/src/components/CreateAutomationPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -7
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts +35 -0
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationArticle/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts +13 -0
- package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +10 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerSettings/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/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +5 -4
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -5
- 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/create-automation.d.ts +5 -0
- package/dist/types/src/operations/create-automation.d.ts.map +1 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
- package/dist/types/src/operations/create-trigger-from-template.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/paths.d.ts +3 -0
- package/dist/types/src/paths.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/templates/index.d.ts +10 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +318 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +90 -31
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Automation.d.ts +41 -0
- package/dist/types/src/types/Automation.d.ts.map +1 -0
- package/dist/types/src/types/Automation.test.d.ts +2 -0
- package/dist/types/src/types/Automation.test.d.ts.map +1 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts +42 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AutomationOperation.d.ts +31 -0
- package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
- package/dist/types/src/types/Runnable.d.ts +14 -0
- package/dist/types/src/types/Runnable.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +13 -5
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/automations-for-object.d.ts +20 -0
- package/dist/types/src/util/automations-for-object.d.ts.map +1 -0
- package/dist/types/src/util/automations-for-object.test.d.ts +2 -0
- package/dist/types/src/util/automations-for-object.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +136 -71
- package/src/AutomationPlugin.node.ts +48 -0
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +47 -35
- package/src/AutomationPlugin.workerd.ts +24 -0
- package/src/capabilities/app-graph-builder.ts +81 -78
- package/src/capabilities/create-object.test.ts +18 -0
- package/src/capabilities/create-object.ts +26 -0
- package/src/capabilities/index.ts +17 -7
- package/src/capabilities/layer-specs.ts +196 -0
- package/src/capabilities/navigation-resolver.ts +19 -0
- package/src/capabilities/node.ts +19 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +45 -46
- package/src/capabilities/registry-sync.ts +114 -0
- package/src/capabilities/templates.ts +17 -0
- package/src/capabilities/trigger-runtime-controller.test.ts +107 -0
- package/src/capabilities/trigger-runtime-controller.ts +126 -0
- package/src/commands/index.ts +5 -0
- package/src/commands/trigger/create/index.ts +14 -0
- package/src/commands/trigger/create/queue.ts +87 -0
- package/src/commands/trigger/create/subscription.ts +126 -0
- package/src/commands/trigger/create/timer.ts +90 -0
- package/src/commands/trigger/index.ts +16 -0
- package/src/commands/trigger/list.ts +69 -0
- package/src/commands/trigger/options.ts +47 -0
- package/src/commands/trigger/remove.ts +45 -0
- package/src/commands/trigger/update/index.ts +14 -0
- package/src/commands/trigger/update/queue.ts +191 -0
- package/src/commands/trigger/update/subscription.ts +279 -0
- package/src/commands/trigger/update/timer.ts +195 -0
- package/src/commands/trigger/util.ts +410 -0
- package/src/components/CreateAutomationPanel/CreateAutomationPanel.tsx +68 -0
- package/src/components/CreateAutomationPanel/index.ts +5 -0
- package/src/components/index.ts +1 -8
- package/src/containers/AutomationArticle/AutomationArticle.tsx +586 -0
- package/src/containers/AutomationArticle/index.ts +6 -0
- package/src/containers/AutomationCompanion/AutomationCompanion.tsx +183 -0
- package/src/containers/AutomationCompanion/index.ts +6 -0
- package/src/containers/AutomationSettings/AutomationSettings.tsx +34 -0
- package/src/containers/AutomationSettings/index.ts +5 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +10 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useTriggerRuntimeControls.ts +38 -19
- package/src/index.ts +1 -6
- package/src/meta.ts +23 -7
- package/src/operations/create-automation.ts +38 -0
- package/src/operations/create-trigger-from-template.ts +70 -0
- package/src/operations/index.ts +10 -0
- package/src/paths.ts +13 -0
- package/src/plugin.ts +11 -0
- package/src/templates/index.ts +22 -0
- package/src/testing/test-functions.ts +43 -9
- package/src/testing.ts +7 -0
- package/src/translations.ts +49 -33
- package/src/types/Automation.test.ts +37 -0
- package/src/types/Automation.ts +45 -0
- package/src/types/AutomationCapabilities.ts +52 -0
- package/src/types/AutomationOperation.ts +61 -0
- package/src/types/Runnable.ts +14 -0
- package/src/types/index.ts +5 -0
- package/src/types/schema.ts +6 -6
- package/src/util/automations-for-object.test.ts +86 -0
- package/src/util/automations-for-object.ts +72 -0
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/AutomationPanel-7OECLR5N.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs +0 -68
- package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs +0 -151
- package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-CRW6SJUN.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs +0 -81
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +0 -7
- package/dist/lib/browser/chunk-EPEXQP45.mjs +0 -14
- package/dist/lib/browser/chunk-EPEXQP45.mjs.map +0 -7
- package/dist/lib/browser/chunk-JW7XSPYW.mjs +0 -267
- package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZQFZO3B.mjs +0 -17
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-NAPXRXTY.mjs +0 -100
- package/dist/lib/browser/chunk-NAPXRXTY.mjs.map +0 -7
- package/dist/lib/browser/chunk-QKFBHAGN.mjs +0 -184
- package/dist/lib/browser/chunk-QKFBHAGN.mjs.map +0 -7
- package/dist/lib/browser/chunk-TWWFNOIR.mjs +0 -109
- package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +0 -7
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs +0 -15
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +0 -7
- package/dist/lib/browser/chunk-YBPJCY3F.mjs +0 -38
- package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs +0 -113
- package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs.map +0 -7
- package/dist/lib/browser/hooks/index.mjs +0 -13
- package/dist/lib/browser/index.mjs +0 -130
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs +0 -77
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-YQW7WCFW.mjs +0 -64
- package/dist/lib/browser/react-surface-YQW7WCFW.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -8
- package/dist/lib/node-esm/AutomationPanel-HCVFNHGQ.mjs +0 -12
- package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs +0 -69
- package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs +0 -152
- package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-RVVCS6VH.mjs +0 -11
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs +0 -82
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6YRKST6M.mjs +0 -185
- package/dist/lib/node-esm/chunk-6YRKST6M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs +0 -19
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CPP35BE6.mjs +0 -16
- package/dist/lib/node-esm/chunk-CPP35BE6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs +0 -39
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs +0 -16
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PICJ2REN.mjs +0 -101
- package/dist/lib/node-esm/chunk-PICJ2REN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs +0 -110
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs +0 -268
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-URROOC34.mjs +0 -114
- package/dist/lib/node-esm/compute-runtime-URROOC34.mjs.map +0 -7
- package/dist/lib/node-esm/hooks/index.mjs +0 -14
- package/dist/lib/node-esm/index.mjs +0 -131
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs +0 -78
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs +0 -65
- package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -9
- package/dist/types/src/capabilities/capabilities.d.ts +0 -20
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
- package/dist/types/src/capabilities/compute-runtime.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/components/AutomationPanel/AutomationPanel.d.ts +0 -13
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +0 -50
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts +0 -4
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AutomationSettings.d.ts +0 -5
- package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +0 -7
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsPanel/index.d.ts +0 -4
- package/dist/types/src/components/FunctionsPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +0 -8
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +0 -2
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +0 -12
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +0 -5
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +0 -13
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +0 -51
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/index.d.ts +0 -2
- package/dist/types/src/components/TriggerEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +0 -12
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -41
- package/src/capabilities/compute-runtime.ts +0 -127
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +0 -56
- package/src/components/AutomationPanel/AutomationPanel.tsx +0 -223
- package/src/components/AutomationPanel/index.ts +0 -9
- package/src/components/AutomationSettings.tsx +0 -30
- package/src/components/FunctionsContainer.tsx +0 -36
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +0 -116
- package/src/components/FunctionsPanel/index.ts +0 -8
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +0 -135
- package/src/components/FunctionsRegistry/index.ts +0 -5
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +0 -84
- package/src/components/TriggerEditor/SpecSelector.tsx +0 -65
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +0 -121
- package/src/components/TriggerEditor/TriggerEditor.tsx +0 -127
- package/src/components/TriggerEditor/index.ts +0 -5
- package/src/components/TriggerSettings.tsx +0 -25
- package/src/events.ts +0 -11
- package/src/hooks/useComputeRuntimeCallback.ts +0 -68
- /package/dist/lib/{browser/AutomationPanel-7OECLR5N.mjs.map → neutral/AutomationArticle-GN36NUX2.mjs.map} +0 -0
- /package/dist/lib/{browser/FunctionsPanel-CRW6SJUN.mjs.map → neutral/AutomationPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser/hooks/index.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/hooks → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-HCVFNHGQ.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/FunctionsPanel-RVVCS6VH.mjs.map → neutral/testing.mjs.map} +0 -0
- /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { type ReactNode, useCallback, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { Operation, Routine, Trigger } from '@dxos/compute';
|
|
10
|
+
import { type Database, Entity, Feed, Filter, JsonSchema, Obj, Query, Ref, Scope, Type } from '@dxos/echo';
|
|
11
|
+
import { DXN } from '@dxos/keys';
|
|
12
|
+
import { useObject, useQuery } from '@dxos/react-client/echo';
|
|
13
|
+
import { Button, Icon, Input, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import {
|
|
15
|
+
Form,
|
|
16
|
+
type FormFieldComponentProps,
|
|
17
|
+
type FormFieldMap,
|
|
18
|
+
RefField,
|
|
19
|
+
SelectField,
|
|
20
|
+
Settings,
|
|
21
|
+
} from '@dxos/react-ui-form';
|
|
22
|
+
import { ParentLabelAnnotation } from '@dxos/schema';
|
|
23
|
+
|
|
24
|
+
import { meta } from '#meta';
|
|
25
|
+
import { Automation } from '#types';
|
|
26
|
+
|
|
27
|
+
const RUN_ROUTINE_DXN = 'org.dxos.function.prompt';
|
|
28
|
+
|
|
29
|
+
export type AutomationArticleProps = AppSurface.ObjectArticleProps<Automation.Automation>;
|
|
30
|
+
|
|
31
|
+
export const AutomationArticle = ({ role, subject }: AutomationArticleProps) => {
|
|
32
|
+
const { t } = useTranslation(meta.id);
|
|
33
|
+
const db = Obj.getDatabase(subject);
|
|
34
|
+
const trigger = usePrimaryTrigger(subject);
|
|
35
|
+
|
|
36
|
+
if (!db) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Settings.Viewport>
|
|
42
|
+
<Settings.Section title={t('general.title')} description={t('general.description')}>
|
|
43
|
+
<Settings.Panel>
|
|
44
|
+
<GeneralSection automation={subject} trigger={trigger} />
|
|
45
|
+
</Settings.Panel>
|
|
46
|
+
</Settings.Section>
|
|
47
|
+
|
|
48
|
+
<Settings.Section title={t('trigger-picker.title')} description={t('trigger-picker.description')}>
|
|
49
|
+
<Settings.Panel>
|
|
50
|
+
<TriggerSection db={db} automation={subject} trigger={trigger} />
|
|
51
|
+
</Settings.Panel>
|
|
52
|
+
</Settings.Section>
|
|
53
|
+
|
|
54
|
+
<Settings.Section title={t('action.title')} description={t('action.description')}>
|
|
55
|
+
<Settings.Panel>
|
|
56
|
+
<ActionSection db={db} automation={subject} trigger={trigger} />
|
|
57
|
+
</Settings.Panel>
|
|
58
|
+
</Settings.Section>
|
|
59
|
+
</Settings.Viewport>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
// General (name + enabled)
|
|
65
|
+
//
|
|
66
|
+
|
|
67
|
+
const GeneralForm = Schema.Struct({
|
|
68
|
+
name: Schema.String.pipe(Schema.annotations({ title: 'Name' }), Schema.optional),
|
|
69
|
+
enabled: Schema.Boolean.annotations({ title: 'Enabled' }),
|
|
70
|
+
});
|
|
71
|
+
type GeneralFormValues = Schema.Schema.Type<typeof GeneralForm>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Top-level metadata: name plus the enabled toggle. The automation has no `enabled` field of its own —
|
|
75
|
+
* enabling it toggles its trigger's `enabled` (the flag the dispatcher reads), so the switch is disabled
|
|
76
|
+
* until both a trigger and an action exist.
|
|
77
|
+
*/
|
|
78
|
+
export const GeneralSection = ({
|
|
79
|
+
automation,
|
|
80
|
+
trigger,
|
|
81
|
+
}: {
|
|
82
|
+
automation: Automation.Automation;
|
|
83
|
+
trigger?: Trigger.Trigger;
|
|
84
|
+
}) => {
|
|
85
|
+
const { defaultValues, fieldMap, handleValuesChanged } = useGeneralForm(automation, trigger);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Form.Root
|
|
89
|
+
key={trigger?.id ?? 'new'}
|
|
90
|
+
schema={GeneralForm}
|
|
91
|
+
defaultValues={defaultValues}
|
|
92
|
+
fieldMap={fieldMap}
|
|
93
|
+
onValuesChanged={handleValuesChanged}
|
|
94
|
+
>
|
|
95
|
+
<Form.Content>
|
|
96
|
+
<Form.FieldSet />
|
|
97
|
+
</Form.Content>
|
|
98
|
+
</Form.Root>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** Enabled switch field; disabled (with a hint) until the automation has both a trigger and an action. */
|
|
103
|
+
const EnabledField = ({
|
|
104
|
+
canEnable,
|
|
105
|
+
messageKey,
|
|
106
|
+
...props
|
|
107
|
+
}: FormFieldComponentProps & { canEnable: boolean; messageKey?: string }) => {
|
|
108
|
+
const { t } = useTranslation(meta.id);
|
|
109
|
+
return (
|
|
110
|
+
<div className='flex items-center gap-2 pt-form-padding'>
|
|
111
|
+
<Input.Root>
|
|
112
|
+
<Input.Switch
|
|
113
|
+
disabled={!canEnable}
|
|
114
|
+
checked={Boolean(props.getValue()) && canEnable}
|
|
115
|
+
onCheckedChange={(checked) => props.onValueChange(props.type, checked)}
|
|
116
|
+
/>
|
|
117
|
+
</Input.Root>
|
|
118
|
+
<span className='text-sm'>{props.label}</span>
|
|
119
|
+
{!canEnable && messageKey && <span className='text-sm text-description'>{t(messageKey)}</span>}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//
|
|
125
|
+
// Action
|
|
126
|
+
//
|
|
127
|
+
|
|
128
|
+
// Two-part action form: pick a kind (operation | routine), then the specific object (a RefField object
|
|
129
|
+
// picker for that type). Modeled as a top-level discriminated union so the Form renders the kind select and
|
|
130
|
+
// the chosen kind's picker as one flat field set (no nested, bordered sub-fieldset). Selecting a routine
|
|
131
|
+
// binds it as input to the "Run Routine" (AgentPrompt) operation, so the runnable a trigger points at is
|
|
132
|
+
// always an Operation.
|
|
133
|
+
const OperationAction = Schema.Struct({
|
|
134
|
+
kind: Schema.Literal('operation'),
|
|
135
|
+
operation: Ref.Ref(Operation.PersistentOperation).pipe(Schema.annotations({ title: 'Operation' }), Schema.optional),
|
|
136
|
+
});
|
|
137
|
+
const RoutineAction = Schema.Struct({
|
|
138
|
+
kind: Schema.Literal('routine'),
|
|
139
|
+
routine: Ref.Ref(Routine.Routine).pipe(Schema.annotations({ title: 'Routine' }), Schema.optional),
|
|
140
|
+
});
|
|
141
|
+
const ActionForm = Schema.Union(OperationAction, RoutineAction);
|
|
142
|
+
type ActionFormValues = Schema.Schema.Type<typeof ActionForm>;
|
|
143
|
+
|
|
144
|
+
// Flat view of the form values (see `TriggerFormInput`): reach the variant fields that `Partial<T>` drops.
|
|
145
|
+
type ActionFormInput = {
|
|
146
|
+
readonly kind?: 'operation' | 'routine';
|
|
147
|
+
readonly operation?: Ref.Ref<Operation.PersistentOperation>;
|
|
148
|
+
readonly routine?: Ref.Ref<Routine.Routine>;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const ActionSection = ({
|
|
152
|
+
db,
|
|
153
|
+
automation,
|
|
154
|
+
trigger,
|
|
155
|
+
}: {
|
|
156
|
+
db: Database.Database;
|
|
157
|
+
automation: Automation.Automation;
|
|
158
|
+
trigger?: Trigger.Trigger;
|
|
159
|
+
}) => {
|
|
160
|
+
const { defaultValues, fieldMap, handleValuesChanged, selectedOperation } = useActionForm(db, automation, trigger);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div className='flex flex-col gap-2'>
|
|
164
|
+
<Form.Root
|
|
165
|
+
// Remount when the bound trigger changes so the uncontrolled form picks up its action.
|
|
166
|
+
key={trigger?.id ?? 'new'}
|
|
167
|
+
schema={ActionForm}
|
|
168
|
+
defaultValues={defaultValues}
|
|
169
|
+
db={db}
|
|
170
|
+
fieldMap={fieldMap}
|
|
171
|
+
onValuesChanged={handleValuesChanged}
|
|
172
|
+
>
|
|
173
|
+
<Form.Content>
|
|
174
|
+
<Form.FieldSet />
|
|
175
|
+
</Form.Content>
|
|
176
|
+
</Form.Root>
|
|
177
|
+
|
|
178
|
+
{/* Bind the operation's inputs (e.g. an object ref) once a trigger exists — input lives on the trigger;
|
|
179
|
+
a ref set here is what associates a non-feed object via `automationsForObject`. */}
|
|
180
|
+
{trigger && selectedOperation && <ActionInputEditor db={db} operation={selectedOperation} trigger={trigger} />}
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const ActionInputEditor = ({
|
|
186
|
+
db,
|
|
187
|
+
operation,
|
|
188
|
+
trigger,
|
|
189
|
+
}: {
|
|
190
|
+
db: Database.Database;
|
|
191
|
+
operation: Operation.PersistentOperation;
|
|
192
|
+
trigger: Trigger.Trigger;
|
|
193
|
+
}) => {
|
|
194
|
+
const { t } = useTranslation(meta.id);
|
|
195
|
+
const effectSchema = useMemo(
|
|
196
|
+
() => (operation.inputSchema ? JsonSchema.toEffectSchema(operation.inputSchema) : undefined),
|
|
197
|
+
[operation.inputSchema],
|
|
198
|
+
);
|
|
199
|
+
const propertyCount = operation.inputSchema?.properties ? Object.keys(operation.inputSchema.properties).length : 0;
|
|
200
|
+
// Read the current input once per operation (key remounts the uncontrolled Form when the action changes).
|
|
201
|
+
const defaultValues = useMemo(
|
|
202
|
+
() => ({ ...((trigger.input as Record<string, unknown>) ?? {}) }),
|
|
203
|
+
[operation.id, trigger],
|
|
204
|
+
);
|
|
205
|
+
const handleValuesChanged = useCallback(
|
|
206
|
+
(values: Record<string, unknown>) => {
|
|
207
|
+
Obj.update(trigger, (trigger) => {
|
|
208
|
+
trigger.input = values;
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
[trigger],
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
if (!effectSchema || propertyCount === 0) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<>
|
|
220
|
+
<Form.Label label={t('action-input.label')} asChild />
|
|
221
|
+
<Form.Root
|
|
222
|
+
key={operation.id}
|
|
223
|
+
schema={effectSchema}
|
|
224
|
+
defaultValues={defaultValues}
|
|
225
|
+
db={db}
|
|
226
|
+
onValuesChanged={handleValuesChanged}
|
|
227
|
+
>
|
|
228
|
+
<Form.FieldSet />
|
|
229
|
+
</Form.Root>
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
//
|
|
235
|
+
// Trigger
|
|
236
|
+
//
|
|
237
|
+
|
|
238
|
+
// Scoped trigger form: timer (cron) or feed, modeled as a top-level discriminated union so the Form renders
|
|
239
|
+
// the kind select and the chosen kind's field as one flat field set (no nested, bordered sub-fieldset). The
|
|
240
|
+
// feed field carries ParentLabelAnnotation so the built-in RefField labels feed options by their parent
|
|
241
|
+
// object (e.g. the mailbox) — configured per field via the annotation rather than a hard-coded option mapper.
|
|
242
|
+
const TimerSpecForm = Schema.Struct({
|
|
243
|
+
kind: Schema.Literal('timer'),
|
|
244
|
+
cron: Schema.String.pipe(Schema.annotations({ title: 'Schedule (cron)' }), Schema.optional),
|
|
245
|
+
});
|
|
246
|
+
const FeedSpecForm = Schema.Struct({
|
|
247
|
+
kind: Schema.Literal('feed'),
|
|
248
|
+
feed: Ref.Ref(Feed.Feed).pipe(
|
|
249
|
+
ParentLabelAnnotation.set(true),
|
|
250
|
+
Schema.annotations({ title: 'Feed' }),
|
|
251
|
+
Schema.optional,
|
|
252
|
+
),
|
|
253
|
+
});
|
|
254
|
+
const TriggerForm = Schema.Union(TimerSpecForm, FeedSpecForm);
|
|
255
|
+
type TriggerFormValues = Schema.Schema.Type<typeof TriggerForm>;
|
|
256
|
+
|
|
257
|
+
// Flat view of the form values: `Partial<TriggerFormValues>` collapses a discriminated union to its common
|
|
258
|
+
// key alone (`kind`), so reach the variant fields through this all-optional shape instead. `Partial<T>` is
|
|
259
|
+
// assignable to it, so handlers/helpers can accept the Form's value verbatim and still read `cron`/`feed`.
|
|
260
|
+
type TriggerFormInput = {
|
|
261
|
+
readonly kind?: 'timer' | 'feed';
|
|
262
|
+
readonly cron?: string;
|
|
263
|
+
readonly feed?: Ref.Ref<Feed.Feed>;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/** Project a trigger spec onto the form's discriminated-union members. */
|
|
267
|
+
const triggerFormValues = (spec?: Trigger.Spec): TriggerFormInput =>
|
|
268
|
+
spec?.kind === 'feed'
|
|
269
|
+
? { kind: 'feed', feed: spec.feed }
|
|
270
|
+
: { kind: 'timer', cron: spec?.kind === 'timer' ? spec.cron : '' };
|
|
271
|
+
|
|
272
|
+
// Build a trigger spec from the form's values. Returned as just the two specs we construct (not the full
|
|
273
|
+
// `Trigger.Spec` union) so the subscription spec's deep readonly query AST never enters the type and the
|
|
274
|
+
// result stays assignable to the mutable `trigger.spec`.
|
|
275
|
+
const triggerFormSpec = (values: TriggerFormInput): Trigger.TimerSpec | Trigger.FeedSpec =>
|
|
276
|
+
values.kind === 'feed' ? { kind: 'feed', feed: values.feed } : Trigger.specTimer(values.cron ?? '');
|
|
277
|
+
|
|
278
|
+
export const TriggerSection = ({
|
|
279
|
+
db,
|
|
280
|
+
automation,
|
|
281
|
+
trigger,
|
|
282
|
+
}: {
|
|
283
|
+
db: Database.Database;
|
|
284
|
+
automation: Automation.Automation;
|
|
285
|
+
trigger?: Trigger.Trigger;
|
|
286
|
+
}) => {
|
|
287
|
+
const { t } = useTranslation(meta.id);
|
|
288
|
+
const { defaultValues, fieldMap, handleValuesChanged, handleRemove } = useTriggerForm(db, automation, trigger);
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<div className='flex flex-col gap-2'>
|
|
292
|
+
<Form.Root
|
|
293
|
+
// Remount when the bound trigger changes so the uncontrolled form picks up its spec.
|
|
294
|
+
key={trigger?.id ?? 'new'}
|
|
295
|
+
schema={TriggerForm}
|
|
296
|
+
defaultValues={defaultValues}
|
|
297
|
+
db={db}
|
|
298
|
+
fieldMap={fieldMap}
|
|
299
|
+
onValuesChanged={handleValuesChanged}
|
|
300
|
+
>
|
|
301
|
+
<Form.Content>
|
|
302
|
+
<Form.FieldSet />
|
|
303
|
+
</Form.Content>
|
|
304
|
+
</Form.Root>
|
|
305
|
+
{trigger && (
|
|
306
|
+
<Button variant='ghost' classNames='gap-1 self-start' onClick={handleRemove}>
|
|
307
|
+
<Icon icon='ph--trash--regular' size={4} />
|
|
308
|
+
<span>{t('remove-trigger.label')}</span>
|
|
309
|
+
</Button>
|
|
310
|
+
)}
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
//
|
|
316
|
+
// Inline form (companion)
|
|
317
|
+
//
|
|
318
|
+
|
|
319
|
+
/** Compact section heading for the inline form — just a small title, no description (cf. Settings.Section). */
|
|
320
|
+
const InlineSection = ({ title, children }: { title: string; children: ReactNode }) => (
|
|
321
|
+
<div className='flex flex-col gap-1'>
|
|
322
|
+
<h3 className='pli-1 text-sm font-medium text-description'>{title}</h3>
|
|
323
|
+
<Settings.Panel>{children}</Settings.Panel>
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Compact inline view used in the Automation companion. Renders the same three sections as the full article
|
|
329
|
+
* (General / Trigger / Action) with condensed headings and no descriptions or scrolling Settings.Viewport.
|
|
330
|
+
*/
|
|
331
|
+
export const AutomationInlineForm = ({
|
|
332
|
+
automation,
|
|
333
|
+
db,
|
|
334
|
+
}: {
|
|
335
|
+
automation: Automation.Automation;
|
|
336
|
+
db: Database.Database;
|
|
337
|
+
}) => {
|
|
338
|
+
const { t } = useTranslation(meta.id);
|
|
339
|
+
const trigger = usePrimaryTrigger(automation);
|
|
340
|
+
|
|
341
|
+
return (
|
|
342
|
+
<div className='flex flex-col gap-3'>
|
|
343
|
+
<InlineSection title={t('general.title')}>
|
|
344
|
+
<GeneralSection automation={automation} trigger={trigger} />
|
|
345
|
+
</InlineSection>
|
|
346
|
+
<InlineSection title={t('trigger-picker.title')}>
|
|
347
|
+
<TriggerSection db={db} automation={automation} trigger={trigger} />
|
|
348
|
+
</InlineSection>
|
|
349
|
+
<InlineSection title={t('action.title')}>
|
|
350
|
+
<ActionSection db={db} automation={automation} trigger={trigger} />
|
|
351
|
+
</InlineSection>
|
|
352
|
+
</div>
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
//
|
|
357
|
+
// Hooks
|
|
358
|
+
//
|
|
359
|
+
|
|
360
|
+
/** Subscribe to the automation and derive its primary (first) trigger. */
|
|
361
|
+
const usePrimaryTrigger = (automation: Automation.Automation): Trigger.Trigger | undefined => {
|
|
362
|
+
const [snapshot] = useObject(automation);
|
|
363
|
+
return useMemo(() => {
|
|
364
|
+
for (const ref of snapshot.triggers) {
|
|
365
|
+
const target = ref.target;
|
|
366
|
+
if (Obj.instanceOf(Trigger.Trigger, target)) {
|
|
367
|
+
return target;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return undefined;
|
|
371
|
+
}, [snapshot.triggers]);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/** Form state for the General section: the name plus an enabled toggle that writes through to the trigger. */
|
|
375
|
+
const useGeneralForm = (automation: Automation.Automation, trigger?: Trigger.Trigger) => {
|
|
376
|
+
const [auto, updateAuto] = useObject(automation);
|
|
377
|
+
const canEnable = Boolean(trigger && auto.runnable);
|
|
378
|
+
const messageKey = !trigger
|
|
379
|
+
? 'add-trigger-first.message'
|
|
380
|
+
: !auto.runnable
|
|
381
|
+
? 'select-action-first.message'
|
|
382
|
+
: undefined;
|
|
383
|
+
|
|
384
|
+
const fieldMap = useMemo<FormFieldMap>(
|
|
385
|
+
() => ({ enabled: (props) => <EnabledField {...props} canEnable={canEnable} messageKey={messageKey} /> }),
|
|
386
|
+
[canEnable, messageKey],
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
// Read once per trigger identity; the uncontrolled form owns edits after mount.
|
|
390
|
+
const defaultValues = useMemo<Partial<GeneralFormValues>>(
|
|
391
|
+
() => ({ name: auto.name, enabled: (trigger?.enabled ?? false) && canEnable }),
|
|
392
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
393
|
+
[automation, trigger],
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
const handleValuesChanged = useCallback(
|
|
397
|
+
(values: Partial<GeneralFormValues>) => {
|
|
398
|
+
updateAuto((automation) => {
|
|
399
|
+
automation.name = values.name;
|
|
400
|
+
});
|
|
401
|
+
if (trigger && canEnable) {
|
|
402
|
+
Obj.update(trigger, (trigger) => {
|
|
403
|
+
trigger.enabled = values.enabled ?? false;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
[updateAuto, trigger, canEnable],
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
return { defaultValues, fieldMap, handleValuesChanged };
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
/** Form state for the Action section: pick an operation|routine and bind it to the trigger's function/input. */
|
|
414
|
+
const useActionForm = (db: Database.Database, automation: Automation.Automation, trigger?: Trigger.Trigger) => {
|
|
415
|
+
const { t } = useTranslation(meta.id);
|
|
416
|
+
const [auto, updateAuto] = useObject(automation);
|
|
417
|
+
// Query by typename DXN so results stay untyped (`Entity.Any[]`), as RefField.useResults expects.
|
|
418
|
+
const operations = useQuery(
|
|
419
|
+
db,
|
|
420
|
+
// Include registry operations (built-in / plugin-provided) alongside space-resident ones.
|
|
421
|
+
Query.select(Filter.type(DXN.make(Type.getTypename(Operation.PersistentOperation)))).from(
|
|
422
|
+
Scope.space(),
|
|
423
|
+
Scope.registry(),
|
|
424
|
+
),
|
|
425
|
+
);
|
|
426
|
+
const routines = useQuery(
|
|
427
|
+
db,
|
|
428
|
+
Query.select(Filter.type(DXN.make(Type.getTypename(Routine.Routine)))).from(Scope.space(), Scope.registry()),
|
|
429
|
+
);
|
|
430
|
+
const runRoutineOp = useMemo(() => findRunRoutineOp(operations), [operations]);
|
|
431
|
+
const boundRoutine = getBoundRoutine(trigger);
|
|
432
|
+
const runnableTarget = auto.runnable?.target;
|
|
433
|
+
|
|
434
|
+
const kindOptions = useMemo(
|
|
435
|
+
() => [
|
|
436
|
+
{ value: 'operation', label: t('action-kind.operation.label') },
|
|
437
|
+
{ value: 'routine', label: t('action-kind.routine.label') },
|
|
438
|
+
],
|
|
439
|
+
[t],
|
|
440
|
+
);
|
|
441
|
+
const fieldMap = useMemo<FormFieldMap>(
|
|
442
|
+
() => ({
|
|
443
|
+
kind: (props) => <SelectField {...props} options={kindOptions} />,
|
|
444
|
+
// Custom useResults so pickers draw from the already-queried sets (space + registry for
|
|
445
|
+
// operations; space-only for routines) rather than RefField's default typename query.
|
|
446
|
+
operation: (props) => <RefField {...props} db={db} useResults={() => operations} />,
|
|
447
|
+
routine: (props) => <RefField {...props} db={db} useResults={() => routines} />,
|
|
448
|
+
}),
|
|
449
|
+
[kindOptions, operations, routines, db],
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
// Read the current action once per trigger identity (the uncontrolled form owns edits after mount).
|
|
453
|
+
const defaultValues = useMemo<Partial<ActionFormValues>>(() => {
|
|
454
|
+
if (boundRoutine) {
|
|
455
|
+
return { kind: 'routine', routine: Ref.make(boundRoutine) };
|
|
456
|
+
}
|
|
457
|
+
if (auto.runnable && Obj.instanceOf(Operation.PersistentOperation, runnableTarget)) {
|
|
458
|
+
return { kind: 'operation', operation: auto.runnable };
|
|
459
|
+
}
|
|
460
|
+
return { kind: 'operation' };
|
|
461
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
462
|
+
}, [automation, trigger]);
|
|
463
|
+
|
|
464
|
+
const handleValuesChanged = useCallback(
|
|
465
|
+
(values: Partial<ActionFormValues>) => {
|
|
466
|
+
const action: ActionFormInput = values;
|
|
467
|
+
if (action.kind === 'routine') {
|
|
468
|
+
const routineRef = action.routine;
|
|
469
|
+
if (!routineRef || !runRoutineOp) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
updateAuto((automation) => {
|
|
473
|
+
automation.runnable = Ref.make(runRoutineOp);
|
|
474
|
+
});
|
|
475
|
+
if (trigger) {
|
|
476
|
+
Obj.update(trigger, (trigger) => {
|
|
477
|
+
trigger.function = Ref.make(runRoutineOp);
|
|
478
|
+
trigger.input = { prompt: routineRef, input: {} };
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
} else if (action.kind === 'operation' && action.operation) {
|
|
482
|
+
const operationRef = action.operation;
|
|
483
|
+
updateAuto((automation) => {
|
|
484
|
+
automation.runnable = operationRef;
|
|
485
|
+
});
|
|
486
|
+
if (trigger) {
|
|
487
|
+
Obj.update(trigger, (trigger) => {
|
|
488
|
+
trigger.function = operationRef;
|
|
489
|
+
trigger.input = undefined;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
[runRoutineOp, trigger, updateAuto],
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
// The directly-selected operation (not the routine-bound AgentPrompt case); its input schema drives the editor.
|
|
498
|
+
const selectedOperation =
|
|
499
|
+
!boundRoutine && Obj.instanceOf(Operation.PersistentOperation, runnableTarget) ? runnableTarget : undefined;
|
|
500
|
+
|
|
501
|
+
return { defaultValues, fieldMap, handleValuesChanged, selectedOperation };
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
/** Form state for the Trigger section: the timer|feed spec, plus create-on-first-edit and remove handlers. */
|
|
505
|
+
const useTriggerForm = (db: Database.Database, automation: Automation.Automation, trigger?: Trigger.Trigger) => {
|
|
506
|
+
const { t } = useTranslation(meta.id);
|
|
507
|
+
const kindOptions = useMemo(
|
|
508
|
+
() => [
|
|
509
|
+
{ value: 'timer', label: t('trigger-kind.timer.label') },
|
|
510
|
+
{ value: 'feed', label: t('trigger-kind.feed.label') },
|
|
511
|
+
],
|
|
512
|
+
[t],
|
|
513
|
+
);
|
|
514
|
+
const fieldMap = useMemo<FormFieldMap>(
|
|
515
|
+
() => ({ kind: (props) => <SelectField {...props} options={kindOptions} /> }),
|
|
516
|
+
[kindOptions],
|
|
517
|
+
);
|
|
518
|
+
// Read once per trigger identity (uncontrolled Form); default to an empty timer spec.
|
|
519
|
+
const defaultValues = useMemo<Partial<TriggerFormValues>>(
|
|
520
|
+
() => triggerFormValues(trigger?.spec),
|
|
521
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
522
|
+
[trigger],
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
const handleValuesChanged = useCallback(
|
|
526
|
+
(values: Partial<TriggerFormValues>) => {
|
|
527
|
+
const spec = triggerFormSpec(values);
|
|
528
|
+
if (trigger) {
|
|
529
|
+
Obj.update(trigger, (trigger) => {
|
|
530
|
+
trigger.spec = spec;
|
|
531
|
+
});
|
|
532
|
+
} else {
|
|
533
|
+
// Create the trigger on first edit; `function` is wired by the action section, and it stays disabled
|
|
534
|
+
// until an action is set, so a function-less trigger never dispatches. The trigger is owned by the
|
|
535
|
+
// automation (it is only reachable via it), so it is parented and cascade-deletes with the automation.
|
|
536
|
+
const created = db.add(Trigger.make({ function: automation.runnable, enabled: false, spec }));
|
|
537
|
+
Obj.setParent(created, automation);
|
|
538
|
+
Obj.update(automation, (automation) => {
|
|
539
|
+
automation.triggers = [...automation.triggers, Ref.make(created)];
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
[db, automation, trigger],
|
|
544
|
+
);
|
|
545
|
+
|
|
546
|
+
const handleRemove = useCallback(() => {
|
|
547
|
+
if (!trigger) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
Obj.update(automation, (automation) => {
|
|
551
|
+
automation.triggers = automation.triggers.filter((ref) => ref.target?.id !== trigger.id);
|
|
552
|
+
});
|
|
553
|
+
db.remove(trigger);
|
|
554
|
+
}, [db, automation, trigger]);
|
|
555
|
+
|
|
556
|
+
return { defaultValues, fieldMap, handleValuesChanged, handleRemove };
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
//
|
|
560
|
+
// Helpers
|
|
561
|
+
//
|
|
562
|
+
|
|
563
|
+
/** Read back the routine bound into a trigger's AgentPrompt input, if any. */
|
|
564
|
+
const getBoundRoutine = (trigger?: Trigger.Trigger): Routine.Routine | undefined => {
|
|
565
|
+
const prompt = (trigger?.input as { prompt?: Ref.Ref<unknown> } | undefined)?.prompt;
|
|
566
|
+
const target = Ref.isRef(prompt) ? prompt.target : undefined;
|
|
567
|
+
return Obj.instanceOf(Routine.Routine, target) ? target : undefined;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
/** Find the persisted "Run Routine" (AgentPrompt) operation by its DXN, avoiding a hard assistant-toolkit dep. */
|
|
571
|
+
const findRunRoutineOp = (operations: Entity.Any[]): Operation.PersistentOperation | undefined => {
|
|
572
|
+
for (const op of operations) {
|
|
573
|
+
if (!Obj.instanceOf(Operation.PersistentOperation, op)) {
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
// Control-flow narrowed: op is Entity.Any & Operation.PersistentOperation.
|
|
577
|
+
try {
|
|
578
|
+
if (Operation.deserialize(op).meta.key.toString().includes(RUN_ROUTINE_DXN)) {
|
|
579
|
+
return op;
|
|
580
|
+
}
|
|
581
|
+
} catch {
|
|
582
|
+
// Not a valid/deserializable operation or key does not match.
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return undefined;
|
|
586
|
+
};
|