@dxos/plugin-routine 0.0.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 +105 -0
- package/PLUGIN.mdl +475 -0
- package/README.md +15 -0
- package/dist/lib/neutral/RoutineArticle-UNTMV4CC.mjs +95 -0
- package/dist/lib/neutral/RoutineArticle-UNTMV4CC.mjs.map +7 -0
- package/dist/lib/neutral/RoutineCompanion-ZZ6WMY7I.mjs +249 -0
- package/dist/lib/neutral/RoutineCompanion-ZZ6WMY7I.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.mjs +10 -0
- package/dist/lib/neutral/RoutinePlugin.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.node.mjs +1133 -0
- package/dist/lib/neutral/RoutinePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.workerd.mjs +36 -0
- package/dist/lib/neutral/RoutinePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/RoutineSettings-ZJOM4F3S.mjs +48 -0
- package/dist/lib/neutral/RoutineSettings-ZJOM4F3S.mjs.map +7 -0
- package/dist/lib/neutral/RoutineTraceCompanion-5U6R7LJE.mjs +236 -0
- package/dist/lib/neutral/RoutineTraceCompanion-5U6R7LJE.mjs.map +7 -0
- package/dist/lib/neutral/SkillArticle-WWDNKW2Z.mjs +27 -0
- package/dist/lib/neutral/SkillArticle-WWDNKW2Z.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-FALWLZTI.mjs +90 -0
- package/dist/lib/neutral/app-graph-builder-FALWLZTI.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-674LDIUJ.mjs +9 -0
- package/dist/lib/neutral/chunk-674LDIUJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CNYAPXUW.mjs +65 -0
- package/dist/lib/neutral/chunk-CNYAPXUW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HLO4LYXT.mjs +44 -0
- package/dist/lib/neutral/chunk-HLO4LYXT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ODQDVFMZ.mjs +8 -0
- package/dist/lib/neutral/chunk-ODQDVFMZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R7J2MU2M.mjs +263 -0
- package/dist/lib/neutral/chunk-R7J2MU2M.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WLNL77C7.mjs +14 -0
- package/dist/lib/neutral/chunk-WLNL77C7.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +1921 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +17 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-V23KVDMJ.mjs +25 -0
- package/dist/lib/neutral/create-object-V23KVDMJ.mjs.map +7 -0
- package/dist/lib/neutral/create-routine-I67BYJA2.mjs +38 -0
- package/dist/lib/neutral/create-routine-I67BYJA2.mjs.map +7 -0
- package/dist/lib/neutral/create-trigger-from-template-U3KNS77V.mjs +70 -0
- package/dist/lib/neutral/create-trigger-from-template-U3KNS77V.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 +27 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/layer-specs-ADQCTTRT.mjs +135 -0
- package/dist/lib/neutral/layer-specs-ADQCTTRT.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/navigation-resolver-KQIWUH6F.mjs +18 -0
- package/dist/lib/neutral/navigation-resolver-KQIWUH6F.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-QKLJSDCQ.mjs +13 -0
- package/dist/lib/neutral/operation-handler-QKLJSDCQ.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-GMO7I7YE.mjs +67 -0
- package/dist/lib/neutral/react-surface-GMO7I7YE.mjs.map +7 -0
- package/dist/lib/neutral/registry-sync-PHBU6CH2.mjs +86 -0
- package/dist/lib/neutral/registry-sync-PHBU6CH2.mjs.map +7 -0
- package/dist/lib/neutral/run-routine-HJWXIWLJ.mjs +37 -0
- package/dist/lib/neutral/run-routine-HJWXIWLJ.mjs.map +7 -0
- package/dist/lib/neutral/templates-IIUCEBAX.mjs +49 -0
- package/dist/lib/neutral/templates-IIUCEBAX.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +115 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/trigger-runtime-controller-7FOTH2NP.mjs +77 -0
- package/dist/lib/neutral/trigger-runtime-controller-7FOTH2NP.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.node.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.node.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.test.d.ts +2 -0
- package/dist/types/src/RoutinePlugin.test.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.workerd.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +5 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +5 -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 +12 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/layer-specs.d.ts +5 -0
- package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts +5 -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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- 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 +5 -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 +13 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts +15 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts +13 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/CreateRoutinePanel/CreateRoutinePanel.d.ts +14 -0
- package/dist/types/src/components/CreateRoutinePanel/CreateRoutinePanel.d.ts.map +1 -0
- package/dist/types/src/components/CreateRoutinePanel/index.d.ts +2 -0
- package/dist/types/src/components/CreateRoutinePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.d.ts +16 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.stories.d.ts +17 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/index.d.ts +2 -0
- package/dist/types/src/components/InstructionsEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.d.ts +51 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.stories.d.ts +16 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.stories.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/index.d.ts +2 -0
- package/dist/types/src/components/MasterDetail/index.d.ts.map +1 -0
- package/dist/types/src/components/RoutineForm/RoutineForm.d.ts +25 -0
- package/dist/types/src/components/RoutineForm/RoutineForm.d.ts.map +1 -0
- package/dist/types/src/components/RoutineForm/index.d.ts +2 -0
- package/dist/types/src/components/RoutineForm/index.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/Schedule.d.ts +80 -0
- package/dist/types/src/components/Schedule/Schedule.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/Schedule.stories.d.ts +23 -0
- package/dist/types/src/components/Schedule/Schedule.stories.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/cron.d.ts +44 -0
- package/dist/types/src/components/Schedule/cron.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/cron.test.d.ts +2 -0
- package/dist/types/src/components/Schedule/cron.test.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/index.d.ts +4 -0
- package/dist/types/src/components/Schedule/index.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/types.d.ts +66 -0
- package/dist/types/src/components/Schedule/types.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +13 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +19 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +21 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +16 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts +18 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +24 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +25 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.d.ts +15 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.stories.d.ts +15 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.stories.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts +2 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +8 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts +14 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts +20 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.d.ts +17 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/RoutineCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineSettings/RoutineSettings.d.ts +10 -0
- package/dist/types/src/containers/RoutineSettings/RoutineSettings.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineSettings/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.d.ts +9 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineTraceCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.d.ts +34 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.test.d.ts +2 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.test.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/useRoutineRuns.d.ts +11 -0
- package/dist/types/src/containers/RoutineTraceCompanion/useRoutineRuns.d.ts.map +1 -0
- package/dist/types/src/containers/SkillArticle/SkillArticle.d.ts +6 -0
- package/dist/types/src/containers/SkillArticle/SkillArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SkillArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SkillArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +12 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +33 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/operations/create-routine.d.ts +5 -0
- package/dist/types/src/operations/create-routine.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/operations/run-routine.d.ts +5 -0
- package/dist/types/src/operations/run-routine.d.ts.map +1 -0
- package/dist/types/src/paths.d.ts +5 -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 +11 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +328 -0
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- 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 +3 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/Routine.d.ts +55 -0
- package/dist/types/src/types/Routine.d.ts.map +1 -0
- package/dist/types/src/types/Routine.test.d.ts +2 -0
- package/dist/types/src/types/Routine.test.d.ts.map +1 -0
- package/dist/types/src/types/RoutineCapabilities.d.ts +44 -0
- package/dist/types/src/types/RoutineCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/RoutineOperation.d.ts +45 -0
- package/dist/types/src/types/RoutineOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +33 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/routines-for-object.d.ts +22 -0
- package/dist/types/src/util/routines-for-object.d.ts.map +1 -0
- package/dist/types/src/util/routines-for-object.test.d.ts +2 -0
- package/dist/types/src/util/routines-for-object.test.d.ts.map +1 -0
- package/dist/types/src/util/run-instructions.d.ts +5 -0
- package/dist/types/src/util/run-instructions.d.ts.map +1 -0
- package/dist/types/src/util/run-instructions.test.d.ts +2 -0
- package/dist/types/src/util/run-instructions.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +33 -0
- package/package.json +196 -0
- package/src/RoutinePlugin.node.ts +48 -0
- package/src/RoutinePlugin.test.ts +27 -0
- package/src/RoutinePlugin.tsx +58 -0
- package/src/RoutinePlugin.workerd.ts +24 -0
- package/src/capabilities/app-graph-builder.ts +80 -0
- package/src/capabilities/create-object.test.ts +18 -0
- package/src/capabilities/create-object.ts +26 -0
- package/src/capabilities/index.ts +22 -0
- package/src/capabilities/layer-specs.ts +190 -0
- package/src/capabilities/navigation-resolver.ts +21 -0
- package/src/capabilities/node.ts +19 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +66 -0
- 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 +278 -0
- package/src/commands/trigger/update/timer.ts +194 -0
- package/src/commands/trigger/util.ts +412 -0
- package/src/components/CreateRoutinePanel/CreateRoutinePanel.tsx +68 -0
- package/src/components/CreateRoutinePanel/index.ts +5 -0
- package/src/components/InstructionsEditor/InstructionsEditor.stories.tsx +69 -0
- package/src/components/InstructionsEditor/InstructionsEditor.tsx +107 -0
- package/src/components/InstructionsEditor/index.ts +5 -0
- package/src/components/MasterDetail/MasterDetail.stories.tsx +100 -0
- package/src/components/MasterDetail/MasterDetail.tsx +175 -0
- package/src/components/MasterDetail/index.ts +5 -0
- package/src/components/RoutineForm/RoutineForm.tsx +293 -0
- package/src/components/RoutineForm/index.ts +5 -0
- package/src/components/Schedule/Schedule.stories.tsx +73 -0
- package/src/components/Schedule/Schedule.tsx +527 -0
- package/src/components/Schedule/cron.test.ts +230 -0
- package/src/components/Schedule/cron.ts +337 -0
- package/src/components/Schedule/index.ts +8 -0
- package/src/components/Schedule/types.ts +124 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +93 -0
- package/src/components/TemplateEditor/TemplateEditor.tsx +77 -0
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +76 -0
- package/src/components/TemplateEditor/TemplateForm.tsx +204 -0
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/TemplateEditor/index.ts +5 -0
- package/src/components/TemplateEditor/types.tsx +28 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +122 -0
- package/src/components/TriggerEditor/TriggerEditor.tsx +365 -0
- package/src/components/TriggerEditor/TriggerKindSelector.stories.tsx +42 -0
- package/src/components/TriggerEditor/TriggerKindSelector.tsx +87 -0
- package/src/components/TriggerEditor/index.ts +5 -0
- package/src/components/index.ts +11 -0
- package/src/containers/RoutineArticle/RoutineArticle.stories.tsx +146 -0
- package/src/containers/RoutineArticle/RoutineArticle.tsx +109 -0
- package/src/containers/RoutineArticle/index.ts +5 -0
- package/src/containers/RoutineCompanion/RoutineCompanion.stories.tsx +82 -0
- package/src/containers/RoutineCompanion/RoutineCompanion.tsx +342 -0
- package/src/containers/RoutineCompanion/index.ts +6 -0
- package/src/containers/RoutineSettings/RoutineSettings.tsx +65 -0
- package/src/containers/RoutineSettings/index.ts +5 -0
- package/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.tsx +133 -0
- package/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.tsx +125 -0
- package/src/containers/RoutineTraceCompanion/index.ts +5 -0
- package/src/containers/RoutineTraceCompanion/runs.test.ts +140 -0
- package/src/containers/RoutineTraceCompanion/runs.ts +135 -0
- package/src/containers/RoutineTraceCompanion/useRoutineRuns.ts +50 -0
- package/src/containers/SkillArticle/SkillArticle.tsx +29 -0
- package/src/containers/SkillArticle/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useTriggerRuntimeControls.ts +70 -0
- package/src/index.ts +7 -0
- package/src/meta.ts +9 -0
- package/src/operations/create-routine.ts +39 -0
- package/src/operations/create-trigger-from-template.ts +68 -0
- package/src/operations/index.ts +11 -0
- package/src/operations/run-routine.ts +45 -0
- package/src/paths.ts +18 -0
- package/src/plugin.ts +11 -0
- package/src/templates/index.ts +48 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/test-functions.ts +76 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +125 -0
- package/src/types/Routine.test.ts +51 -0
- package/src/types/Routine.ts +144 -0
- package/src/types/RoutineCapabilities.ts +51 -0
- package/src/types/RoutineOperation.ts +104 -0
- package/src/types/index.ts +9 -0
- package/src/types/schema.ts +31 -0
- package/src/util/index.ts +6 -0
- package/src/util/routines-for-object.test.ts +109 -0
- package/src/util/routines-for-object.ts +89 -0
- package/src/util/run-instructions.test.ts +23 -0
- package/src/util/run-instructions.ts +12 -0
- package/src/vite-env.d.ts +10 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
export const MinutelySpec = Schema.Struct({
|
|
8
|
+
frequency: Schema.Literal('minutely').annotations({ title: 'Frequency' }),
|
|
9
|
+
interval: Schema.Number.pipe(Schema.int(), Schema.between(1, 59)).annotations({
|
|
10
|
+
title: 'Every (minutes)',
|
|
11
|
+
description: '1–59',
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const HourlySpec = Schema.Struct({
|
|
16
|
+
frequency: Schema.Literal('hourly').annotations({ title: 'Frequency' }),
|
|
17
|
+
interval: Schema.Number.pipe(Schema.int(), Schema.between(1, 23)).annotations({
|
|
18
|
+
title: 'Every (hours)',
|
|
19
|
+
description: '1–23',
|
|
20
|
+
}),
|
|
21
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
22
|
+
title: 'At minute',
|
|
23
|
+
description: '0–59',
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const DailySpec = Schema.Struct({
|
|
28
|
+
frequency: Schema.Literal('daily').annotations({ title: 'Frequency' }),
|
|
29
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
30
|
+
title: 'Hour',
|
|
31
|
+
description: '0–23',
|
|
32
|
+
}),
|
|
33
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
34
|
+
title: 'Minute',
|
|
35
|
+
description: '0–59',
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Named day-of-week literals for UX clarity; cron.ts maps them to numeric DOW values.
|
|
40
|
+
export const DayOfWeek = Schema.Literal('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
|
|
41
|
+
export type DayOfWeek = Schema.Schema.Type<typeof DayOfWeek>;
|
|
42
|
+
|
|
43
|
+
export const WeeklySpec = Schema.Struct({
|
|
44
|
+
frequency: Schema.Literal('weekly').annotations({ title: 'Frequency' }),
|
|
45
|
+
daysOfWeek: Schema.Array(DayOfWeek.annotations({ title: 'Day' })).annotations({ title: 'Days of week' }),
|
|
46
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
47
|
+
title: 'Hour',
|
|
48
|
+
description: '0–23',
|
|
49
|
+
}),
|
|
50
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
51
|
+
title: 'Minute',
|
|
52
|
+
description: '0–59',
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const MonthlySpec = Schema.Struct({
|
|
57
|
+
frequency: Schema.Literal('monthly').annotations({ title: 'Frequency' }),
|
|
58
|
+
daysOfMonth: Schema.Array(
|
|
59
|
+
Schema.Number.pipe(Schema.int(), Schema.between(1, 31)).annotations({ title: 'Day' }),
|
|
60
|
+
).annotations({
|
|
61
|
+
title: 'Days of month',
|
|
62
|
+
}),
|
|
63
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
64
|
+
title: 'Hour',
|
|
65
|
+
description: '0–23',
|
|
66
|
+
}),
|
|
67
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
68
|
+
title: 'Minute',
|
|
69
|
+
description: '0–59',
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const CustomSpec = Schema.Struct({
|
|
74
|
+
frequency: Schema.Literal('custom').annotations({ title: 'Frequency' }),
|
|
75
|
+
cronExpression: Schema.String.annotations({
|
|
76
|
+
title: 'Cron expression',
|
|
77
|
+
description: 'e.g. 0 9 * * MON-FRI',
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const CronSpec = Schema.Union(
|
|
82
|
+
MinutelySpec,
|
|
83
|
+
HourlySpec,
|
|
84
|
+
DailySpec,
|
|
85
|
+
WeeklySpec,
|
|
86
|
+
MonthlySpec,
|
|
87
|
+
CustomSpec,
|
|
88
|
+
).annotations({ title: '' });
|
|
89
|
+
|
|
90
|
+
export type CronSpecType = Schema.Schema.Type<typeof CronSpec>;
|
|
91
|
+
export type Frequency = CronSpecType['frequency'];
|
|
92
|
+
|
|
93
|
+
export const FrequencyDefaults: { [K in Frequency]: Extract<CronSpecType, { frequency: K }> } = {
|
|
94
|
+
minutely: {
|
|
95
|
+
frequency: 'minutely',
|
|
96
|
+
interval: 15,
|
|
97
|
+
},
|
|
98
|
+
hourly: {
|
|
99
|
+
frequency: 'hourly',
|
|
100
|
+
interval: 1,
|
|
101
|
+
minute: 0,
|
|
102
|
+
},
|
|
103
|
+
daily: {
|
|
104
|
+
frequency: 'daily',
|
|
105
|
+
hour: 9,
|
|
106
|
+
minute: 0,
|
|
107
|
+
},
|
|
108
|
+
weekly: {
|
|
109
|
+
frequency: 'weekly',
|
|
110
|
+
daysOfWeek: ['mon'],
|
|
111
|
+
hour: 9,
|
|
112
|
+
minute: 0,
|
|
113
|
+
},
|
|
114
|
+
monthly: {
|
|
115
|
+
frequency: 'monthly',
|
|
116
|
+
daysOfMonth: [1],
|
|
117
|
+
hour: 9,
|
|
118
|
+
minute: 0,
|
|
119
|
+
},
|
|
120
|
+
custom: {
|
|
121
|
+
frequency: 'custom',
|
|
122
|
+
cronExpression: '* * * * *',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createSystemPrompt } from '@dxos/assistant';
|
|
9
|
+
import { Skill, Template } from '@dxos/compute';
|
|
10
|
+
import { useClient } from '@dxos/react-client';
|
|
11
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { trim } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { translations } from '#translations';
|
|
16
|
+
|
|
17
|
+
import { TemplateEditor, type TemplateEditorProps } from './TemplateEditor';
|
|
18
|
+
|
|
19
|
+
const FENCE = '```';
|
|
20
|
+
|
|
21
|
+
const TEMPLATE = trim`
|
|
22
|
+
{{! System Prompt }}
|
|
23
|
+
|
|
24
|
+
You are an expert chess player.
|
|
25
|
+
The move history of the current game is: {{history}}.
|
|
26
|
+
If asked to suggest a move explain why it is a good move.
|
|
27
|
+
|
|
28
|
+
{{#each artifacts}}
|
|
29
|
+
{{this}}
|
|
30
|
+
{{/each}}
|
|
31
|
+
|
|
32
|
+
Reponse in the format: <suggestion>SUGGESTION</suggestion>
|
|
33
|
+
|
|
34
|
+
@echo://B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ/01K24XPK464FSCKVQJAB2H662M
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
${FENCE}ts
|
|
39
|
+
const x = 100;
|
|
40
|
+
${FENCE}
|
|
41
|
+
|
|
42
|
+
{{input}}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const DefaultStory = ({ source }: TemplateEditorProps & { source: string }) => {
|
|
46
|
+
const client = useClient();
|
|
47
|
+
const [skill] = useState(() => {
|
|
48
|
+
const space = client.spaces.get()[0];
|
|
49
|
+
return space.db.add(
|
|
50
|
+
Skill.make({
|
|
51
|
+
key: 'com.example.skill.test',
|
|
52
|
+
name: 'Test',
|
|
53
|
+
instructions: Template.make({ source }),
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return <TemplateEditor classNames='dx-document bg-base-surface' id={skill.id} source={skill.instructions.source} />;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const meta = {
|
|
62
|
+
title: 'plugins/plugin-routine/components/TemplateEditor',
|
|
63
|
+
component: TemplateEditor as any,
|
|
64
|
+
render: DefaultStory,
|
|
65
|
+
decorators: [
|
|
66
|
+
withTheme(),
|
|
67
|
+
withLayout({ layout: 'column' }),
|
|
68
|
+
withClientProvider({
|
|
69
|
+
types: [Skill.Skill],
|
|
70
|
+
createIdentity: true,
|
|
71
|
+
createSpace: true,
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
parameters: {
|
|
75
|
+
translations,
|
|
76
|
+
},
|
|
77
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
78
|
+
|
|
79
|
+
export default meta;
|
|
80
|
+
|
|
81
|
+
type Story = StoryObj<typeof meta>;
|
|
82
|
+
|
|
83
|
+
export const Default: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
source: TEMPLATE,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const System: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
source: createSystemPrompt({}),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
|
6
|
+
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { type Ref } from '@dxos/echo';
|
|
10
|
+
import { Doc } from '@dxos/echo-doc';
|
|
11
|
+
import { useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { composable, composableProps } from '@dxos/react-ui';
|
|
13
|
+
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
14
|
+
import { type Text } from '@dxos/schema';
|
|
15
|
+
import {
|
|
16
|
+
createBasicExtensions,
|
|
17
|
+
createDataExtensions,
|
|
18
|
+
createMarkdownExtensions,
|
|
19
|
+
createThemeExtensions,
|
|
20
|
+
decorateMarkdown,
|
|
21
|
+
} from '@dxos/ui-editor';
|
|
22
|
+
import { isNonNullable } from '@dxos/util';
|
|
23
|
+
|
|
24
|
+
import { meta } from '#meta';
|
|
25
|
+
|
|
26
|
+
import { handlebars, xmlDecorator } from './extensions';
|
|
27
|
+
|
|
28
|
+
export type TemplateEditorProps = {
|
|
29
|
+
id: string;
|
|
30
|
+
/** Markdown + Handlebars source text. */
|
|
31
|
+
source?: Ref.Ref<Text.Text>;
|
|
32
|
+
lineNumbers?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const TemplateEditor = composable<HTMLDivElement, TemplateEditorProps>(
|
|
36
|
+
({ classNames, id, source, lineNumbers = true, ...props }, forwardedRef) => {
|
|
37
|
+
const { t } = useTranslation(meta.profile.key);
|
|
38
|
+
const { themeMode } = useThemeContext();
|
|
39
|
+
const { parentRef } = useTextEditor(() => {
|
|
40
|
+
const target = source?.target;
|
|
41
|
+
if (!target) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
initialValue: target.content ?? '',
|
|
47
|
+
extensions: [
|
|
48
|
+
createDataExtensions({ id, text: Doc.createAccessor(target, ['content']) }),
|
|
49
|
+
createBasicExtensions({
|
|
50
|
+
bracketMatching: false,
|
|
51
|
+
lineNumbers,
|
|
52
|
+
lineWrapping: true,
|
|
53
|
+
placeholder: t('template.placeholder'),
|
|
54
|
+
}),
|
|
55
|
+
createThemeExtensions({ themeMode }),
|
|
56
|
+
createMarkdownExtensions(),
|
|
57
|
+
decorateMarkdown(),
|
|
58
|
+
handlebars(),
|
|
59
|
+
// xml(),
|
|
60
|
+
// NOTE: Since we're using markdown only HTML nodes are parsed.
|
|
61
|
+
xmlDecorator(),
|
|
62
|
+
syntaxHighlighting(defaultHighlightStyle),
|
|
63
|
+
].filter(isNonNullable),
|
|
64
|
+
};
|
|
65
|
+
}, [themeMode, source?.target, lineNumbers]);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
{...composableProps(props, {
|
|
70
|
+
role: 'none',
|
|
71
|
+
classNames: ['h-full overflow-hidden', classNames],
|
|
72
|
+
})}
|
|
73
|
+
ref={composeRefs(parentRef, forwardedRef)}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta } from '@storybook/react-vite';
|
|
6
|
+
import React, { useCallback, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Skill, Template } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { useClient } from '@dxos/react-client';
|
|
12
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
14
|
+
import { trim } from '@dxos/util';
|
|
15
|
+
|
|
16
|
+
import { translations } from '#translations';
|
|
17
|
+
|
|
18
|
+
import { type TemplateChangeCallback, TemplateForm } from './TemplateForm';
|
|
19
|
+
|
|
20
|
+
const TEMPLATE = trim`
|
|
21
|
+
You are a machine that is an expert chess player.
|
|
22
|
+
The move history of the current game is: {{history}}
|
|
23
|
+
If asked to suggest a move explain why it is a good move.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
{{input}},
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const DefaultStory = () => {
|
|
31
|
+
const client = useClient();
|
|
32
|
+
const [skill] = useState(() => {
|
|
33
|
+
const space = client.spaces.get()[0];
|
|
34
|
+
invariant(space, 'TemplateForm story requires at least one space');
|
|
35
|
+
return space.db.add(
|
|
36
|
+
Skill.make({
|
|
37
|
+
key: 'com.example.skill.test',
|
|
38
|
+
name: 'Test',
|
|
39
|
+
instructions: Template.make({ source: TEMPLATE }),
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const handleChange: TemplateChangeCallback = useCallback(
|
|
45
|
+
(mutate) => {
|
|
46
|
+
Obj.update(skill, (skill) => mutate(skill.instructions));
|
|
47
|
+
},
|
|
48
|
+
[skill],
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return <TemplateForm id={skill.id} template={skill.instructions} onChange={handleChange} />;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const meta = {
|
|
55
|
+
title: 'plugins/plugin-routine/components/TemplateForm',
|
|
56
|
+
component: TemplateForm,
|
|
57
|
+
render: DefaultStory,
|
|
58
|
+
decorators: [
|
|
59
|
+
withTheme(),
|
|
60
|
+
withLayout({ layout: 'column' }),
|
|
61
|
+
withClientProvider({
|
|
62
|
+
types: [Skill.Skill],
|
|
63
|
+
createIdentity: true,
|
|
64
|
+
createSpace: true,
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
parameters: {
|
|
68
|
+
translations,
|
|
69
|
+
},
|
|
70
|
+
} satisfies Meta<typeof TemplateForm>;
|
|
71
|
+
|
|
72
|
+
export default meta;
|
|
73
|
+
|
|
74
|
+
type Story = Meta<typeof TemplateForm>;
|
|
75
|
+
|
|
76
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { Fragment, useCallback, useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type Template } from '@dxos/compute';
|
|
9
|
+
import { type Obj } from '@dxos/echo';
|
|
10
|
+
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { isNonNullable } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
import { meta } from '#meta';
|
|
14
|
+
|
|
15
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Callback type for mutating template within a parent object's Obj.update context.
|
|
19
|
+
*/
|
|
20
|
+
export type TemplateChangeCallback = (mutate: (template: Obj.Mutable<Template.Template>) => void) => void;
|
|
21
|
+
|
|
22
|
+
export type TemplateFormProps = {
|
|
23
|
+
id: string;
|
|
24
|
+
template: Template.Template;
|
|
25
|
+
schema?: Schema.Schema<any, any, any>;
|
|
26
|
+
/**
|
|
27
|
+
* Callback to mutate the template. Should wrap mutations in parent's Obj.update.
|
|
28
|
+
* If not provided, the component is read-only.
|
|
29
|
+
*/
|
|
30
|
+
onChange?: TemplateChangeCallback;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const TemplateForm = ({ id, template, onChange }: TemplateFormProps) => {
|
|
34
|
+
const { t } = useTranslation(meta.profile.key);
|
|
35
|
+
usePromptInputs(template, onChange);
|
|
36
|
+
|
|
37
|
+
const handleInputKindChange = useCallback(
|
|
38
|
+
(inputName: string, kind: Template.InputKind) => {
|
|
39
|
+
onChange?.((draft) => {
|
|
40
|
+
const input = draft.inputs?.find((i) => i?.name === inputName);
|
|
41
|
+
if (input) {
|
|
42
|
+
input.kind = kind;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
[onChange],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const handleInputDefaultChange = useCallback(
|
|
50
|
+
(inputName: string, value: string) => {
|
|
51
|
+
onChange?.((draft) => {
|
|
52
|
+
const input = draft.inputs?.find((i) => i?.name === inputName);
|
|
53
|
+
if (input) {
|
|
54
|
+
input.default = value;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
[onChange],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className='flex flex-col w-full overflow-hidden gap-4'>
|
|
63
|
+
<TemplateEditor id={id} source={template.source} classNames='bg-base-surface min-h-[120px]' />
|
|
64
|
+
|
|
65
|
+
{(template.inputs?.length ?? 0) > 0 && (
|
|
66
|
+
<div className='grid grid-cols-[10rem_10rem_1fr] gap-1 items-center'>
|
|
67
|
+
{template.inputs?.filter(isNonNullable).map((input) => (
|
|
68
|
+
<Fragment key={input.name}>
|
|
69
|
+
<div className='ps-3 text-blue-text'>{input.name}</div>
|
|
70
|
+
|
|
71
|
+
<Input.Root>
|
|
72
|
+
<Select.Root
|
|
73
|
+
value={input.kind}
|
|
74
|
+
onValueChange={(kind) => handleInputKindChange(input.name, kind as Template.InputKind)}
|
|
75
|
+
>
|
|
76
|
+
<Select.TriggerButton placeholder='Type' classNames='w-full' />
|
|
77
|
+
<Select.Portal>
|
|
78
|
+
<Select.Content>
|
|
79
|
+
<Select.Viewport>
|
|
80
|
+
{inputs.map(({ kind, label }) => (
|
|
81
|
+
<Select.Option key={kind} value={kind}>
|
|
82
|
+
{label}
|
|
83
|
+
</Select.Option>
|
|
84
|
+
))}
|
|
85
|
+
</Select.Viewport>
|
|
86
|
+
<Select.Arrow />
|
|
87
|
+
</Select.Content>
|
|
88
|
+
</Select.Portal>
|
|
89
|
+
</Select.Root>
|
|
90
|
+
</Input.Root>
|
|
91
|
+
|
|
92
|
+
<div>
|
|
93
|
+
{input.kind === 'value' && (
|
|
94
|
+
<Input.Root>
|
|
95
|
+
<Input.TextInput
|
|
96
|
+
placeholder={t('command.placeholder')}
|
|
97
|
+
classNames='w-full bg-transparent'
|
|
98
|
+
value={input.default ?? ''}
|
|
99
|
+
onChange={(event) => handleInputDefaultChange(input.name, event.target.value)}
|
|
100
|
+
/>
|
|
101
|
+
</Input.Root>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
</Fragment>
|
|
105
|
+
))}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// TODO(burdon): Translations.
|
|
113
|
+
const inputs: { kind: Template.InputKind; label: string }[] = [
|
|
114
|
+
{
|
|
115
|
+
kind: 'value',
|
|
116
|
+
label: 'Value',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
kind: 'operation',
|
|
120
|
+
label: 'Operation',
|
|
121
|
+
},
|
|
122
|
+
// {
|
|
123
|
+
// kind: 'pass-through',
|
|
124
|
+
// label: 'Pass through',
|
|
125
|
+
// },
|
|
126
|
+
// {
|
|
127
|
+
// kind: 'retriever',
|
|
128
|
+
// label: 'Retriever',
|
|
129
|
+
// },
|
|
130
|
+
// {
|
|
131
|
+
// kind: 'query',
|
|
132
|
+
// label: 'Query',
|
|
133
|
+
// },
|
|
134
|
+
// {
|
|
135
|
+
// kind: 'resolver',
|
|
136
|
+
// label: 'Resolver',
|
|
137
|
+
// },
|
|
138
|
+
// {
|
|
139
|
+
// kind: 'context',
|
|
140
|
+
// label: 'Context',
|
|
141
|
+
// },
|
|
142
|
+
// {
|
|
143
|
+
// kind: 'schema',
|
|
144
|
+
// label: 'Schema',
|
|
145
|
+
// },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
export const NAME_REGEXP = /\{\{([\w-]+)\}\}/;
|
|
149
|
+
|
|
150
|
+
const usePromptInputs = (template: Template.Template, onChange?: TemplateChangeCallback) => {
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!onChange) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const text = template.source ?? '';
|
|
157
|
+
|
|
158
|
+
const regex = new RegExp(NAME_REGEXP, 'g');
|
|
159
|
+
const variables = new Set<string>([...(text.target?.content.matchAll(regex) ?? [])].map((m) => m[1]));
|
|
160
|
+
|
|
161
|
+
// Create map of unclaimed inputs.
|
|
162
|
+
const unclaimed = new Map<string, Template.Input>(
|
|
163
|
+
template.inputs?.filter(isNonNullable).map((input) => [input.name, input]),
|
|
164
|
+
);
|
|
165
|
+
const missing: string[] = [];
|
|
166
|
+
Array.from(variables.values()).forEach((name) => {
|
|
167
|
+
if (unclaimed.has(name)) {
|
|
168
|
+
unclaimed.delete(name);
|
|
169
|
+
} else {
|
|
170
|
+
missing.push(name);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Match or create new inputs.
|
|
175
|
+
const values = unclaimed.values();
|
|
176
|
+
onChange((draft) => {
|
|
177
|
+
if (!draft.inputs) {
|
|
178
|
+
draft.inputs = [];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
missing.forEach((name) => {
|
|
182
|
+
const next = values.next().value;
|
|
183
|
+
if (next) {
|
|
184
|
+
// Find the input in the mutable draft and update it.
|
|
185
|
+
const inputIndex = draft.inputs!.findIndex((i) => i?.name === next.name);
|
|
186
|
+
if (inputIndex !== -1) {
|
|
187
|
+
draft.inputs![inputIndex].name = name;
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
draft.inputs!.push({ name, kind: 'value' });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Remove unclaimed (deleted) inputs.
|
|
195
|
+
// TODO(burdon): If user types incorrect name value, it will be deleted. Garbage collect?
|
|
196
|
+
for (const input of values) {
|
|
197
|
+
const inputIndex = draft.inputs!.findIndex((i) => i?.name === input.name);
|
|
198
|
+
if (inputIndex !== -1) {
|
|
199
|
+
draft.inputs!.splice(inputIndex, 1);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}, [template.source, onChange]);
|
|
204
|
+
};
|