@dxos/plugin-automation 0.8.4-staging.60fe92afc8 → 0.9.1-main.c7dcc2e112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/neutral/{AutomationArticle-GN36NUX2.mjs → AutomationArticle-CG4ZML3C.mjs} +3 -2
- package/dist/lib/neutral/{AutomationCompanion-M26WR6VP.mjs → AutomationCompanion-67LW2WZS.mjs} +12 -13
- package/dist/lib/neutral/AutomationCompanion-67LW2WZS.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.mjs +1 -1
- package/dist/lib/neutral/AutomationPlugin.node.mjs +4 -4
- package/dist/lib/neutral/AutomationPlugin.node.mjs.map +3 -3
- package/dist/lib/neutral/{AutomationSettings-YXUJDRQA.mjs → AutomationSettings-2XCCFX6X.mjs} +5 -5
- package/dist/lib/neutral/{AutomationSettings-YXUJDRQA.mjs.map → AutomationSettings-2XCCFX6X.mjs.map} +3 -3
- package/dist/lib/neutral/{TriggerSettings-XCHIZPOR.mjs → TriggerSettings-ABOTKRUA.mjs} +2 -2
- package/dist/lib/neutral/{app-graph-builder-BTTHS4VK.mjs → app-graph-builder-VX54SXD6.mjs} +6 -6
- package/dist/lib/neutral/app-graph-builder-VX54SXD6.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +3 -3
- package/dist/lib/neutral/capabilities/node.mjs +1 -1
- package/dist/lib/neutral/{chunk-2JP77CMN.mjs → chunk-73DGSL37.mjs} +2 -2
- package/dist/lib/neutral/chunk-73DGSL37.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-HPUHQ3L6.mjs → chunk-77QU5RSC.mjs} +3 -3
- package/dist/lib/neutral/chunk-77QU5RSC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-D4RCXOP4.mjs +13 -0
- package/dist/lib/neutral/chunk-D4RCXOP4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SONGOJRB.mjs → chunk-EJ5J22XS.mjs} +2 -2
- package/dist/lib/neutral/chunk-HHIFH3N3.mjs +45 -0
- package/dist/lib/neutral/chunk-HHIFH3N3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HQU5QWF4.mjs +349 -0
- package/dist/lib/neutral/chunk-HQU5QWF4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-FE7YFBX7.mjs → chunk-LVUL7GIN.mjs} +151 -60
- package/dist/lib/neutral/chunk-LVUL7GIN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-GARB7S5R.mjs → chunk-YHK7FWGV.mjs} +5 -3
- package/dist/lib/neutral/chunk-YHK7FWGV.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +36 -2
- package/dist/lib/neutral/components/index.mjs.map +3 -3
- package/dist/lib/neutral/containers/index.mjs +4 -4
- package/dist/lib/neutral/{create-automation-OE3TNXYE.mjs → create-automation-AGYTF62E.mjs} +5 -9
- package/dist/lib/neutral/create-automation-AGYTF62E.mjs.map +7 -0
- package/dist/lib/neutral/{create-trigger-from-template-TERHKWJM.mjs → create-trigger-from-template-TYGCSR3Z.mjs} +5 -5
- package/dist/lib/neutral/create-trigger-from-template-TYGCSR3Z.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +10 -2
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/meta.mjs +1 -1
- package/dist/lib/neutral/{navigation-resolver-I3L5FHJO.mjs → navigation-resolver-FSJNF3DQ.mjs} +3 -3
- package/dist/lib/neutral/navigation-resolver-FSJNF3DQ.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +2 -2
- package/dist/lib/neutral/{react-surface-IBRWUKPC.mjs → react-surface-W3J3CDHA.mjs} +2 -2
- package/dist/lib/neutral/{react-surface-IBRWUKPC.mjs.map → react-surface-W3J3CDHA.mjs.map} +3 -3
- package/dist/lib/neutral/testing.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +6 -2
- package/dist/lib/neutral/translations.mjs.map +3 -3
- package/dist/lib/neutral/types/index.mjs +1 -1
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -13
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/navigation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +5 -5
- package/dist/types/src/capabilities/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/CronBuilder/CronBuilder.d.ts +16 -0
- package/dist/types/src/components/CronBuilder/CronBuilder.d.ts.map +1 -0
- package/dist/types/src/components/CronBuilder/CronBuilder.stories.d.ts +194 -0
- package/dist/types/src/components/CronBuilder/CronBuilder.stories.d.ts.map +1 -0
- package/dist/types/src/components/CronBuilder/cron.d.ts +17 -0
- package/dist/types/src/components/CronBuilder/cron.d.ts.map +1 -0
- package/dist/types/src/components/CronBuilder/cron.test.d.ts +2 -0
- package/dist/types/src/components/CronBuilder/cron.test.d.ts.map +1 -0
- package/dist/types/src/components/CronBuilder/index.d.ts +4 -0
- package/dist/types/src/components/CronBuilder/index.d.ts.map +1 -0
- package/dist/types/src/components/CronBuilder/schema.d.ts +96 -0
- package/dist/types/src/components/CronBuilder/schema.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts +6 -0
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.stories.d.ts +120 -0
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +28 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/paths.d.ts +2 -0
- package/dist/types/src/paths.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +9 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/AutomationCapabilities.d.ts +6 -1
- package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +34 -0
- package/package.json +40 -38
- package/src/AutomationPlugin.test.ts +1 -1
- package/src/AutomationPlugin.tsx +1 -1
- package/src/capabilities/app-graph-builder.ts +5 -5
- package/src/capabilities/navigation-resolver.ts +2 -2
- package/src/capabilities/react-surface.tsx +1 -1
- package/src/commands/trigger/create/queue.ts +2 -2
- package/src/commands/trigger/update/queue.ts +2 -2
- package/src/components/CreateAutomationPanel/CreateAutomationPanel.tsx +1 -1
- package/src/components/CronBuilder/CronBuilder.stories.tsx +72 -0
- package/src/components/CronBuilder/CronBuilder.tsx +94 -0
- package/src/components/CronBuilder/cron.test.ts +131 -0
- package/src/components/CronBuilder/cron.ts +138 -0
- package/src/components/CronBuilder/index.ts +7 -0
- package/src/components/CronBuilder/schema.ts +119 -0
- package/src/components/index.ts +1 -0
- package/src/containers/AutomationArticle/AutomationArticle.stories.tsx +73 -0
- package/src/containers/AutomationArticle/AutomationArticle.tsx +186 -56
- package/src/containers/AutomationCompanion/AutomationCompanion.tsx +79 -72
- package/src/containers/AutomationSettings/AutomationSettings.tsx +3 -3
- package/src/containers/TriggerSettings/TriggerSettings.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/meta.ts +2 -26
- package/src/operations/create-trigger-from-template.ts +3 -3
- package/src/paths.ts +7 -2
- package/src/translations.ts +7 -2
- package/src/types/AutomationCapabilities.ts +9 -1
- package/src/types/AutomationOperation.ts +1 -1
- package/src/types/schema.ts +1 -1
- package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs +0 -36
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs.map +0 -7
- package/dist/lib/neutral/chunk-FE7YFBX7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GARB7S5R.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HPUHQ3L6.mjs.map +0 -7
- package/dist/lib/neutral/create-automation-OE3TNXYE.mjs.map +0 -7
- package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs.map +0 -7
- package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs.map +0 -7
- /package/dist/lib/neutral/{AutomationArticle-GN36NUX2.mjs.map → AutomationArticle-CG4ZML3C.mjs.map} +0 -0
- /package/dist/lib/neutral/{TriggerSettings-XCHIZPOR.mjs.map → TriggerSettings-ABOTKRUA.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-SONGOJRB.mjs.map → chunk-EJ5J22XS.mjs.map} +0 -0
package/src/paths.ts
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// Copyright 2026 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Paths } from '@dxos/app-toolkit';
|
|
6
6
|
|
|
7
|
+
import { meta } from '#meta';
|
|
7
8
|
import { Automation } from '#types';
|
|
8
9
|
|
|
9
|
-
const { getSectionPath: getAutomationsPath, getObjectPath: getAutomationPath } = createTypeSectionPaths(
|
|
10
|
+
const { getSectionPath: getAutomationsPath, getObjectPath: getAutomationPath } = Paths.createTypeSectionPaths(
|
|
10
11
|
Automation.Automation,
|
|
11
12
|
);
|
|
12
13
|
|
|
14
|
+
/** Path to the automations settings section for a given space. */
|
|
15
|
+
export const getAutomationsSettingsPath = (spaceId: string): string =>
|
|
16
|
+
Paths.getSpacePath(spaceId, 'settings', `${meta.profile.key}.automations`);
|
|
17
|
+
|
|
13
18
|
export { getAutomationsPath, getAutomationPath };
|
package/src/translations.ts
CHANGED
|
@@ -21,7 +21,7 @@ export const translations = [
|
|
|
21
21
|
'rename-object.label': 'Rename automation',
|
|
22
22
|
'delete-object.label': 'Delete automation',
|
|
23
23
|
},
|
|
24
|
-
[meta.
|
|
24
|
+
[meta.profile.key]: {
|
|
25
25
|
'plugin.name': 'Automation',
|
|
26
26
|
'automation-panel.label': 'Automations',
|
|
27
27
|
'create-panel.template.placeholder': 'Search templates...',
|
|
@@ -38,7 +38,7 @@ export const translations = [
|
|
|
38
38
|
'trigger-picker.title': 'Trigger',
|
|
39
39
|
'trigger-picker.description': 'When this automation runs.',
|
|
40
40
|
'trigger-kind.placeholder': 'Select trigger type',
|
|
41
|
-
'trigger-kind.timer.label': 'Schedule
|
|
41
|
+
'trigger-kind.timer.label': 'Schedule',
|
|
42
42
|
'trigger-kind.feed.label': 'Feed',
|
|
43
43
|
'cron.placeholder': '0 0 * * *',
|
|
44
44
|
'feed.placeholder': 'Select a feed',
|
|
@@ -53,6 +53,11 @@ export const translations = [
|
|
|
53
53
|
'automation-not-associated.message': 'Not yet associated with this object.',
|
|
54
54
|
'automation-detached.message': 'No longer associated with this object.',
|
|
55
55
|
|
|
56
|
+
'testing.title': 'Testing',
|
|
57
|
+
'force-run.label': 'Force run',
|
|
58
|
+
'reset-cursor.label': 'Reset feed cursor',
|
|
59
|
+
'reset-cursor-confirm.label': 'Confirm reset feed cursor',
|
|
60
|
+
|
|
56
61
|
'automation-verbose.label': 'Manage automations',
|
|
57
62
|
'automation.description': 'Manage where automations in this space run.',
|
|
58
63
|
|
|
@@ -6,7 +6,7 @@ import type * as Effect from 'effect/Effect';
|
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
8
|
import type { Database, Obj } from '@dxos/echo';
|
|
9
|
-
import {
|
|
9
|
+
import type { CompletionGuard, DelegationStrategy } from '@dxos/functions-runtime';
|
|
10
10
|
|
|
11
11
|
import * as Automation from './Automation';
|
|
12
12
|
|
|
@@ -20,6 +20,14 @@ export const AgentDelegationStrategy = Capability.make<DelegationStrategy>(
|
|
|
20
20
|
'org.dxos.plugin.automation.capability.agentDelegationStrategy',
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Optional plan-completion guard for the agent chat service. When contributed, the agent process
|
|
25
|
+
* runs an ephemeral stop/continue check before succeeding if open plan tasks remain.
|
|
26
|
+
*/
|
|
27
|
+
export const AgentCompletionGuard = Capability.make<CompletionGuard>(
|
|
28
|
+
'org.dxos.plugin.automation.capability.agentCompletionGuard',
|
|
29
|
+
);
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* An automation template contributed by a plugin. The create dialog and the per-object "Automations"
|
|
25
33
|
* companion list contributed templates (`Capability.getAll(AutomationCapabilities.Template)`) and run the
|
|
@@ -19,7 +19,7 @@ import { meta } from '#meta';
|
|
|
19
19
|
import { TriggerTemplate } from './schema';
|
|
20
20
|
export { _EchoURIReference };
|
|
21
21
|
|
|
22
|
-
const makeKey = (name: string) => DXN.make(`${meta.
|
|
22
|
+
const makeKey = (name: string) => DXN.make(`${meta.profile.key}.operation.${name}`);
|
|
23
23
|
|
|
24
24
|
export const CreateTriggerFromTemplate = Operation.make({
|
|
25
25
|
meta: {
|
package/src/types/schema.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const TriggerTemplate = Schema.Union(
|
|
|
15
15
|
|
|
16
16
|
export namespace AutomationAction {
|
|
17
17
|
export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(
|
|
18
|
-
`${meta.
|
|
18
|
+
`${meta.profile.key}.action.create-trigger-from-template`,
|
|
19
19
|
{
|
|
20
20
|
input: Schema.Struct({
|
|
21
21
|
db: Database.Database,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/AutomationCompanion/AutomationCompanion.tsx", "../../../src/util/automations-for-object.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';\nimport { type Database, Filter, Obj, Type } from '@dxos/echo';\nimport { useQuery } from '@dxos/react-client/echo';\nimport { DropdownMenu, Icon, Tooltip, useTranslation } from '@dxos/react-ui';\nimport { Accordion } from '@dxos/react-ui-list';\n\nimport { meta } from '#meta';\nimport { Automation, AutomationCapabilities, AutomationOperation } from '#types';\n\nimport { AutomationInlineForm } from '../../containers/AutomationArticle';\nimport { connectedAutomationsQuery } from '../../util/automations-for-object';\n\nexport type AutomationCompanionProps = {\n db: Database.Database;\n object: Obj.Unknown;\n};\n\n/** Association state of a row relative to the companion's object. */\ntype Status = 'associated' | 'pending' | 'detached';\n\n/**\n * Renders the automations connected to an object as an accordion (see `useConnectedAutomations` for the\n * session-stable list it draws from), flagging non-associated rows with a warning badge. New automations are\n * created from a template dropdown (no dialog).\n */\nexport const AutomationCompanion = ({ db, object }: AutomationCompanionProps) => {\n const { t } = useTranslation(meta.id);\n const templates = useCapabilities(AutomationCapabilities.Template);\n // Only offer templates applicable to this companion's subject (e.g. a CRM template needs a Mailbox).\n const applicableTemplates = useMemo(\n () => templates.filter((template) => template.appliesTo?.(object) ?? true),\n [templates, object],\n );\n const { items, statusFor, open, setOpen, handleCreate } = useConnectedAutomations(db, object);\n\n return (\n <div className='flex flex-col'>\n {items.length === 0 ? (\n <p className='text-sm text-description p-2'>{t('no-automations.message')}</p>\n ) : (\n <Accordion.Root<Automation.Automation> items={items} value={open} onValueChange={setOpen}>\n {({ items }) => (\n <div className='flex flex-col divide-y divide-separator'>\n {items.map((automation) => {\n const status = statusFor(automation.id);\n return (\n <Accordion.Item key={automation.id} item={automation}>\n <Accordion.ItemHeader>\n <Icon icon='ph--lightning--regular' size={4} classNames='mr-2 shrink-0' />\n <span className='flex-1 truncate'>\n {Obj.getLabel(automation) ??\n t('object-name.placeholder', { ns: Type.getTypename(Automation.Automation) })}\n </span>\n {status !== 'associated' && (\n <Tooltip.Trigger\n asChild\n side='bottom'\n content={t(\n status === 'pending' ? 'automation-not-associated.message' : 'automation-detached.message',\n )}\n >\n <Icon icon='ph--warning--regular' size={4} classNames='text-warning-text shrink-0 mr-2' />\n </Tooltip.Trigger>\n )}\n </Accordion.ItemHeader>\n <Accordion.ItemBody>\n <AutomationInlineForm automation={automation} db={db} />\n </Accordion.ItemBody>\n </Accordion.Item>\n );\n })}\n </div>\n )}\n </Accordion.Root>\n )}\n\n <div className='border-t border-separator'>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n {/* Mirror the accordion item header layout (p-2 + icon mr-2) so the icon aligns with the rows above. */}\n <button type='button' className='group flex items-center p-2 dx-focus-ring-inset w-full text-start'>\n <Icon icon='ph--plus--regular' size={4} classNames='mr-2 shrink-0' />\n <span className='flex-1 truncate'>\n {t('add-object.label', { ns: Type.getTypename(Automation.Automation) })}\n </span>\n </button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content>\n <DropdownMenu.Viewport>\n {applicableTemplates.map((template) => (\n <DropdownMenu.Item key={template.id} onClick={() => void handleCreate(template.id)}>\n <Icon icon={template.icon ?? 'ph--lightning--regular'} size={4} />\n <span>{template.label}</span>\n </DropdownMenu.Item>\n ))}\n </DropdownMenu.Viewport>\n <DropdownMenu.Arrow />\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n </div>\n </div>\n );\n};\n\n//\n// Hooks\n//\n\n/**\n * Owns the companion's session-stable automation list. A reactive reverse-ref query supplies the live\n * connected set, accumulated into an append-only ordering so rows never reorder or disappear while mounted;\n * a row that loses its association (or a freshly-created one not yet connected) is surfaced via `statusFor`\n * rather than dropped. Also holds the accordion open state and a create handler that appends the new\n * automation and auto-expands it for immediate configuration.\n */\nconst useConnectedAutomations = (db: Database.Database, object: Obj.Unknown) => {\n const { invokePromise } = useOperationInvoker();\n\n // Live connected set (reactive reverse-ref query) + a by-id map for resolving rows that have left it.\n const connected = useQuery(db, connectedAutomationsQuery(object));\n const all = useQuery(db, Filter.type(Automation.Automation));\n const connectedIds = useMemo(() => new Set(connected.map((automation) => automation.id)), [connected]);\n const byId = useMemo(() => new Map(all.map((automation) => [automation.id, automation])), [all]);\n\n // Session-stable bookkeeping (held for the component lifetime).\n const seenOrder = useRef<string[]>([]);\n const everConnected = useRef<Set<string>>(new Set());\n const [createdIds, setCreatedIds] = useState<ReadonlySet<string>>(() => new Set());\n const [open, setOpen] = useState<string[]>([]);\n\n // Accumulate first-seen order and \"was ever connected\" — append-only, so rows never reorder or drop.\n for (const id of connectedIds) {\n everConnected.current.add(id);\n }\n for (const id of [...connectedIds, ...createdIds]) {\n if (!seenOrder.current.includes(id)) {\n seenOrder.current.push(id);\n }\n }\n\n // Resolve to live objects in stable order, dropping ids whose object was hard-deleted.\n const items = useMemo(\n () =>\n seenOrder.current.flatMap((id) => {\n const automation = byId.get(id);\n return automation ? [automation] : [];\n }),\n [byId, connectedIds, createdIds],\n );\n\n const statusFor = useCallback(\n (id: string): Status =>\n connectedIds.has(id) ? 'associated' : everConnected.current.has(id) ? 'detached' : 'pending',\n [connectedIds],\n );\n\n const handleCreate = useCallback(\n async (templateId: string) => {\n const { data, error } = await invokePromise(AutomationOperation.CreateAutomation, {\n db,\n templateId,\n subject: object,\n });\n if (error || !data) {\n return;\n }\n\n setCreatedIds((prev) => new Set(prev).add(data.object.id));\n setOpen((prev) => (prev.includes(data.object.id) ? prev : [...prev, data.object.id]));\n },\n [invokePromise, db, object],\n );\n\n return { items, statusFor, open, setOpen, handleCreate };\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Trigger } from '@dxos/compute';\nimport { Filter, Obj, Query, Ref } from '@dxos/echo';\n\nimport { Automation } from '#types';\n\n/**\n * Reactive query for the automations connected to an object O — without a stored association field.\n *\n * Association is derived: an automation is connected when one of its triggers references O, either via a\n * `Ref` anywhere in the trigger's `input` (e.g. a magazine passed into AgentPrompt's input) or via a feed\n * trigger whose `spec.feed` resolves to `O.feed` (feed-annotated hosts like mailboxes). Both are reachable\n * by reverse-reference traversal because ECHO's reverse-ref index is structural — it records every ref in a\n * document regardless of schema path (incl. untyped records and union-nested fields). The traversal is two\n * hops: O ← Trigger ← Automation.\n */\nexport const connectedAutomationsQuery = (object: Obj.Unknown): Query.Query<Automation.Automation> => {\n // Triggers referencing O directly (any path, incl. nested in the untyped `input` record).\n const byInput = Query.select(Filter.id(object.id)).referencedBy(Trigger.Trigger);\n // Triggers referencing O's feed; `.reference('feed')` reads the path structurally and is empty for objects\n // without a feed prop, so this branch contributes nothing for non-feed objects.\n const byFeed = Query.select(Filter.id(object.id)).reference('feed').referencedBy(Trigger.Trigger);\n return Query.all(byInput, byFeed).referencedBy(Automation.Automation, 'triggers');\n};\n\n/**\n * Pure predicate equivalent of {@link connectedAutomationsQuery}, over a pre-queried list of automations.\n * Kept for unit tests (asserting the query and predicate agree) and the deferred quick-association check.\n */\nexport const automationsForObject = (\n object: Obj.Unknown,\n automations: Automation.Automation[],\n): Automation.Automation[] => automations.filter((automation) => automationReferencesObject(automation, object));\n\nexport const automationReferencesObject = (automation: Automation.Automation, object: Obj.Unknown): boolean => {\n const objectFeedId = getFeedId(object);\n return automation.triggers.some((ref) => {\n const trigger = ref.target;\n if (!Obj.instanceOf(Trigger.Trigger, trigger)) {\n return false;\n }\n\n if (trigger.spec?.kind === 'feed' && objectFeedId && trigger.spec.feed?.target?.id === objectFeedId) {\n return true;\n }\n\n return trigger.input != null && referencesId(trigger.input, object.id);\n });\n};\n\n/** The feed id a feed-annotated object points at (e.g. `mailbox.feed`), if any. */\nconst getFeedId = (object: Obj.Unknown): string | undefined => {\n const feedRef = (object as { feed?: Ref.Ref<unknown> }).feed;\n return Ref.isRef(feedRef) ? feedRef.target?.id : undefined;\n};\n\n/** Recursively scan a value for a Ref whose target is the given object id. */\nconst referencesId = (value: unknown, id: string): boolean => {\n if (Ref.isRef(value)) {\n return value.target?.id === id;\n }\n if (Array.isArray(value)) {\n return value.some((entry) => referencesId(entry, id));\n }\n if (value && typeof value === 'object') {\n return Object.values(value).some((entry) => referencesId(entry, id));\n }\n return false;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,QAAQC,gBAAgB;AAE9D,SAASC,iBAAiBC,2BAA2B;AACrD,SAAwBC,UAAAA,SAAQC,OAAAA,MAAKC,YAAY;AACjD,SAASC,gBAAgB;AACzB,SAASC,cAAcC,MAAMC,SAASC,sBAAsB;AAC5D,SAASC,iBAAiB;AAE1B,SAASC,YAAY;AACrB,SAASC,cAAAA,aAAYC,wBAAwBC,2BAA2B;;;ACTxE,SAASC,eAAe;AACxB,SAASC,QAAQC,KAAKC,OAAOC,WAAW;AAExC,SAASC,kBAAkB;AAYpB,IAAMC,4BAA4B,CAACC,WAAAA;AAExC,QAAMC,UAAUL,MAAMM,OAAOR,OAAOS,GAAGH,OAAOG,EAAE,CAAA,EAAGC,aAAaX,QAAQA,OAAO;AAG/E,QAAMY,SAAST,MAAMM,OAAOR,OAAOS,GAAGH,OAAOG,EAAE,CAAA,EAAGG,UAAU,MAAA,EAAQF,aAAaX,QAAQA,OAAO;AAChG,SAAOG,MAAMW,IAAIN,SAASI,MAAAA,EAAQD,aAAaN,WAAWA,YAAY,UAAA;AACxE;;;ADKO,IAAMU,sBAAsB,CAAC,EAAEC,IAAIC,OAAM,MAA4B;AAC1E,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAMC,YAAYC,gBAAgBC,uBAAuBC,QAAQ;AAEjE,QAAMC,sBAAsBC,QAC1B,MAAML,UAAUM,OAAO,CAACC,aAAaA,SAASC,YAAYb,MAAAA,KAAW,IAAA,GACrE;IAACK;IAAWL;GAAO;AAErB,QAAM,EAAEc,OAAOC,WAAWC,MAAMC,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ef", "useState", "useCapabilities", "useOperationInvoker", "Filter", "Obj", "Type", "useQuery", "DropdownMenu", "Icon", "Tooltip", "useTranslation", "Accordion", "meta", "Automation", "AutomationCapabilities", "AutomationOperation", "Trigger", "Filter", "Obj", "Query", "Ref", "Automation", "connectedAutomationsQuery", "object", "byInput", "select", "id", "referencedBy", "byFeed", "reference", "all", "AutomationCompanion", "db", "object", "t", "useTranslation", "meta", "id", "templates", "useCapabilities", "AutomationCapabilities", "Template", "applicableTemplates", "useMemo", "filter", "template", "appliesTo", "items", "statusFor", "open", "setOpen", "handleCreate", "useConnectedAutomations", "div", "className", "length", "p", "Accordion", "Root", "value", "onValueChange", "map", "automation", "status", "Item", "key", "item", "ItemHeader", "Icon", "icon", "size", "classNames", "span", "Obj", "getLabel", "ns", "Type", "getTypename", "Automation", "Tooltip", "Trigger", "asChild", "side", "content", "ItemBody", "AutomationInlineForm", "DropdownMenu", "button", "type", "Portal", "Content", "Viewport", "onClick", "label", "Arrow", "invokePromise", "useOperationInvoker", "connected", "useQuery", "connectedAutomationsQuery", "all", "Filter", "connectedIds", "Set", "byId", "Map", "seenOrder", "useRef", "everConnected", "createdIds", "setCreatedIds", "useState", "current", "add", "includes", "push", "flatMap", "get", "useCallback", "has", "templateId", "data", "error", "AutomationOperation", "CreateAutomation", "subject", "prev"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/app-graph-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities, AppNode, LayoutOperation, createTypeSectionExtension } from '@dxos/app-toolkit';\nimport { isSpace } from '@dxos/client/echo';\nimport { Operation } from '@dxos/compute';\nimport { Type } from '@dxos/echo';\nimport { GraphBuilder, Node, NodeMatcher } from '@dxos/plugin-graph';\nimport { SETTINGS_SECTION_TYPE } from '@dxos/plugin-space';\nimport { linkedSegment } from '@dxos/react-ui-attention';\n\nimport { meta } from '#meta';\nimport { Automation, AutomationOperation } from '#types';\n\nimport { blank } from '../templates';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const extensions = yield* Effect.all([\n createTypeSectionExtension(Automation.Automation),\n GraphBuilder.createExtension({\n id: 'automationsSectionActions',\n match: (node) => {\n const space = isSpace(node.properties.space) ? node.properties.space : undefined;\n return node.type === Type.getTypename(Automation.Automation) && space ? Option.some(space) : Option.none();\n },\n actions: (space) =>\n Effect.succeed([\n Node.makeAction({\n id: 'create-automation',\n data: () =>\n Effect.gen(function* () {\n const { subject } = yield* Operation.invoke(\n AutomationOperation.CreateAutomation,\n { db: space.db, templateId: blank.id },\n { spaceId: space.db.spaceId },\n );\n yield* Operation.invoke(\n LayoutOperation.Open,\n { subject: [...subject] },\n { spaceId: space.db.spaceId },\n );\n }),\n properties: {\n label: ['add-object.label', { ns: Type.getTypename(Automation.Automation) }],\n icon: 'ph--plus--regular',\n disposition: 'list-item-primary',\n },\n }),\n ]),\n }),\n GraphBuilder.createExtension({\n id: 'spaceSettingsAutomation',\n match: NodeMatcher.whenNodeType(SETTINGS_SECTION_TYPE),\n connector: () =>\n Effect.succeed([\n AppNode.makeSettingsPanel({\n id: 'automations',\n type: `${meta.id}.space-settings-automation`,\n label: ['automation-panel.label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n iconHue: 'indigo',\n position: 'last',\n }),\n ]),\n }),\n GraphBuilder.createExtension({\n id: 'automationCompanion',\n match: NodeMatcher.whenEchoObjectMatches,\n connector: () =>\n Effect.succeed([\n AppNode.makeCompanion({\n id: linkedSegment('automation'),\n label: ['automation-companion.label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n data: 'automation',\n position: 'last',\n }),\n ]),\n }),\n ]);\n\n return Capability.contributes(AppCapabilities.AppGraphBuilder, extensions);\n }),\n);\n"],
|
|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aC,gBAAgB;MAC3BC,IAAI;MACJC,OAAOgC,YAAYC,aAAaC,qBAAAA;MAChCC,WAAW,MACFvB,eAAQ;QACbwB,QAAQC,kBAAkB;UACxBtC,IAAI;UACJO,MAAM,GAAGgC,KAAKvC,EAAE;UAChB6B,OAAO;YAAC;YAA0B;cAAEC,IAAIS,KAAKvC;YAAG;;UAChD+B,MAAM;UACNS,SAAS;UACTC,UAAU;QACZ,CAAA;OACD;IACL,CAAA;IACA3C,aAAaC,gBAAgB;MAC3BC,IAAI;MACJC,OAAOgC,YAAYS;MACnBN,WAAW,MACFvB,eAAQ;QACbwB,QAAQM,cAAc;UACpB3C,IAAI4C,cAAc,YAAA;UAClBf,OAAO;YAAC;YAA8B;cAAEC,IAAIS,KAAKvC;YAAG;;UACpD+B,MAAM;UACNf,MAAM;UACNyB,UAAU;QACZ,CAAA;OACD;IACL,CAAA;GACD;AAED,SAAOlD,WAAWsD,YAAYC,gBAAgBC,iBAAiBrD,UAAAA;AACjE,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "Option", "Capability", "AppCapabilities", "AppNode", "LayoutOperation", "createTypeSectionExtension", "isSpace", "Operation", "Type", "GraphBuilder", "Node", "NodeMatcher", "SETTINGS_SECTION_TYPE", "linkedSegment", "meta", "Automation", "AutomationOperation", "Capability", "makeModule", "fnUntraced", "extensions", "all", "createTypeSectionExtension", "Automation", "GraphBuilder", "createExtension", "id", "match", "node", "space", "isSpace", "properties", "undefined", "type", "Type", "getTypename", "some", "none", "actions", "succeed", "Node", "makeAction", "data", "gen", "subject", "Operation", "invoke", "AutomationOperation", "CreateAutomation", "db", "templateId", "blank", "spaceId", "LayoutOperation", "Open", "label", "ns", "icon", "disposition", "NodeMatcher", "whenNodeType", "SETTINGS_SECTION_TYPE", "connector", "AppNode", "makeSettingsPanel", "meta", "iconHue", "position", "whenEchoObjectMatches", "makeCompanion", "linkedSegment", "contributes", "AppCapabilities", "AppGraphBuilder"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/TriggerSettings/TriggerSettings.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ComputeEnvironment } from '@dxos/client-protocol';\nimport { useObject } from '@dxos/echo-react';\nimport { type Space } from '@dxos/react-client/echo';\nimport { DropdownMenu, IconButton, useTranslation } from '@dxos/react-ui';\nimport { Settings } from '@dxos/react-ui-form';\n\nimport { meta } from '#meta';\n\nexport const TriggersSettings = ({ space }: { space: Space }) => {\n const { t } = useTranslation(meta.id);\n const [properties, changeProperties] = useObject(space.properties);\n const selected = properties.computeEnvironment ?? 'local';\n\n const handleUpdate = (option: ComputeEnvironment) => {\n changeProperties((draft) => {\n draft.computeEnvironment = option;\n });\n };\n\n return (\n <div className='grid grid-cols-1 md:grid-cols-[1fr_min-content]'>\n <Settings.Item title={t('runtime.label')} description={t('runtime.description')}>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <IconButton iconEnd icon='ph--caret-down--regular' size={4} label={t(`runtime.${selected}.label`)} />\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content side='bottom'>\n <DropdownMenu.Viewport>\n <DropdownMenu.Item onClick={() => handleUpdate('disabled')}>\n {t(`runtime.disabled.label`)}\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => handleUpdate('local')}>{t(`runtime.local.label`)}</DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => handleUpdate('edge')}>{t(`runtime.edge.label`)}</DropdownMenu.Item>\n </DropdownMenu.Viewport>\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n </Settings.Item>\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,OAAOA,WAAW;AAGlB,SAASC,iBAAiB;AAE1B,SAASC,cAAcC,YAAYC,sBAAsB;AACzD,SAASC,gBAAgB;AAEzB,SAASC,YAAY;AAEd,IAAMC,mBAAmB,CAAC,EAAEC,MAAK,MAAoB;AAC1D,QAAM,EAAEC,EAAC,IAAKL,eAAeE,KAAKI,EAAE;AACpC,QAAM,CAACC,YAAYC,gBAAAA,IAAoBX,UAAUO,MAAMG,UAAU;AACjE,QAAME,WAAWF,WAAWG,sBAAsB;AAElD,QAAMC,eAAe,CAACC,WAAAA;AACpBJ,qBAAiB,CAACK,UAAAA;AAChBA,YAAMH,qBAAqBE;IAC7B,CAAA;EACF;AAEA,SACE,sBAAA,cAACE,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACd,SAASe,MAAI;IAACC,OAAOZ,EAAE,eAAA;IAAkBa,aAAab,EAAE,qBAAA;KACvD,sBAAA,cAACP,aAAaqB,MAAI,MAChB,sBAAA,cAACrB,aAAasB,SAAO;IAACC,SAAAA;KACpB,sBAAA,cAACtB,YAAAA;IAAWuB,SAAAA;IAAQC,MAAK;IAA0BC,MAAM;IAAGC,OAAOpB,EAAE,WAAWI,QAAAA,QAAgB;OAElG,sBAAA,cAACX,aAAa4B,QAAM,MAClB,sBAAA,cAAC5B,aAAa6B,SAAO;IAACC,MAAK;KACzB,sBAAA,cAAC9B,aAAa+B,UAAQ,MACpB,sBAAA,cAAC/B,aAAakB,MAAI;IAACc,SAAS,MAAMnB,aAAa,UAAA;KAC5CN,EAAE,wBAAwB,CAAA,GAE7B,sBAAA,cAACP,aAAakB,MAAI;IAACc,SAAS,MAAMnB,aAAa,OAAA;KAAWN,EAAE,qBAAqB,CAAA,GACjF,sBAAA,cAACP,aAAakB,MAAI;IAACc,SAAS,MAAMnB,aAAa,MAAA;KAAUN,EAAE,oBAAoB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAQ/F;",
|
|
6
|
-
"names": ["React", "useObject", "DropdownMenu", "IconButton", "useTranslation", "Settings", "meta", "TriggersSettings", "space", "t", "id", "properties", "changeProperties", "selected", "computeEnvironment", "handleUpdate", "option", "draft", "div", "className", "Item", "title", "description", "Root", "Trigger", "asChild", "iconEnd", "icon", "size", "label", "Portal", "Content", "side", "Viewport", "onClick"]
|
|
7
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
import { Plugin } from "@dxos/app-framework";
|
|
3
|
-
import { DXN } from "@dxos/keys";
|
|
4
|
-
import { trim } from "@dxos/util";
|
|
5
|
-
var meta = Plugin.makeMeta({
|
|
6
|
-
key: DXN.make("org.dxos.plugin.automation"),
|
|
7
|
-
name: "Automation",
|
|
8
|
-
author: "DXOS",
|
|
9
|
-
description: trim`
|
|
10
|
-
Event-driven workflow automation engine for DXOS Composer.
|
|
11
|
-
An Automation is a user-facing object pairing a trigger ("when" — a timer schedule or an
|
|
12
|
-
incoming feed) with an action ("then" — a persistent compute operation or routine), enabling
|
|
13
|
-
automated pipelines that react to changes in real time without manual intervention.
|
|
14
|
-
|
|
15
|
-
Automations are configured in their own article and surfaced on a per-object "Automations"
|
|
16
|
-
companion that lists the automations connected to each object. A per-space TriggerDispatcher
|
|
17
|
-
manages execution: running locally in the browser when computeEnvironment is "local", or
|
|
18
|
-
delegating to the DXOS edge for server-side reliability; the space settings page chooses the
|
|
19
|
-
runtime location.
|
|
20
|
-
|
|
21
|
-
Operation handlers and blueprints contributed by any plugin in the application are
|
|
22
|
-
automatically merged and made available to every space's OperationRegistry, so new
|
|
23
|
-
capabilities registered by other plugins become instantly invocable from automations.
|
|
24
|
-
`,
|
|
25
|
-
icon: "ph--atom--regular",
|
|
26
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation",
|
|
27
|
-
spec: "PLUGIN.mdl",
|
|
28
|
-
tags: [
|
|
29
|
-
"system"
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
meta
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=chunk-DUGOIM7G.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { DXN } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\nexport const meta = Plugin.makeMeta({\n key: DXN.make('org.dxos.plugin.automation'),\n name: 'Automation',\n author: 'DXOS',\n description: trim`\n Event-driven workflow automation engine for DXOS Composer.\n An Automation is a user-facing object pairing a trigger (\"when\" — a timer schedule or an\n incoming feed) with an action (\"then\" — a persistent compute operation or routine), enabling\n automated pipelines that react to changes in real time without manual intervention.\n\n Automations are configured in their own article and surfaced on a per-object \"Automations\"\n companion that lists the automations connected to each object. A per-space TriggerDispatcher\n manages execution: running locally in the browser when computeEnvironment is \"local\", or\n delegating to the DXOS edge for server-side reliability; the space settings page chooses the\n runtime location.\n\n Operation handlers and blueprints contributed by any plugin in the application are\n automatically merged and made available to every space's OperationRegistry, so new\n capabilities registered by other plugins become instantly invocable from automations.\n `,\n icon: 'ph--atom--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n spec: 'PLUGIN.mdl',\n tags: ['system'],\n});\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,WAAW;AACpB,SAASC,YAAY;AAEd,IAAMC,OAAOH,OAAOI,SAAS;EAClCC,KAAKJ,IAAIK,KAAK,4BAAA;EACdC,MAAM;EACNC,QAAQ;EACRC,aAAaP;;;;;;;;;;;;;;;;EAgBbQ,MAAM;EACNC,QAAQ;EACRC,MAAM;EACNC,MAAM;IAAC;;AACT,CAAA;",
|
|
6
|
-
"names": ["Plugin", "DXN", "trim", "meta", "makeMeta", "key", "make", "name", "author", "description", "icon", "source", "spec", "tags"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/AutomationArticle/AutomationArticle.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { type ReactNode, useCallback, useMemo } from 'react';\n\nimport { type AppSurface } from '@dxos/app-toolkit/ui';\nimport { Operation, Routine, Trigger } from '@dxos/compute';\nimport { type Database, Entity, Feed, Filter, JsonSchema, Obj, Query, Ref, Scope, Type } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\nimport { useObject, useQuery } from '@dxos/react-client/echo';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\nimport {\n Form,\n type FormFieldComponentProps,\n type FormFieldMap,\n RefField,\n SelectField,\n Settings,\n} from '@dxos/react-ui-form';\nimport { ParentLabelAnnotation } from '@dxos/schema';\n\nimport { meta } from '#meta';\nimport { Automation } from '#types';\n\nconst RUN_ROUTINE_DXN = 'org.dxos.function.prompt';\n\nexport type AutomationArticleProps = AppSurface.ObjectArticleProps<Automation.Automation>;\n\nexport const AutomationArticle = ({ role, subject }: AutomationArticleProps) => {\n const { t } = useTranslation(meta.id);\n const db = Obj.getDatabase(subject);\n const trigger = usePrimaryTrigger(subject);\n\n if (!db) {\n return null;\n }\n\n return (\n <Settings.Viewport>\n <Settings.Section title={t('general.title')} description={t('general.description')}>\n <Settings.Panel>\n <GeneralSection automation={subject} trigger={trigger} />\n </Settings.Panel>\n </Settings.Section>\n\n <Settings.Section title={t('trigger-picker.title')} description={t('trigger-picker.description')}>\n <Settings.Panel>\n <TriggerSection db={db} automation={subject} trigger={trigger} />\n </Settings.Panel>\n </Settings.Section>\n\n <Settings.Section title={t('action.title')} description={t('action.description')}>\n <Settings.Panel>\n <ActionSection db={db} automation={subject} trigger={trigger} />\n </Settings.Panel>\n </Settings.Section>\n </Settings.Viewport>\n );\n};\n\n//\n// General (name + enabled)\n//\n\nconst GeneralForm = Schema.Struct({\n name: Schema.String.pipe(Schema.annotations({ title: 'Name' }), Schema.optional),\n enabled: Schema.Boolean.annotations({ title: 'Enabled' }),\n});\ntype GeneralFormValues = Schema.Schema.Type<typeof GeneralForm>;\n\n/**\n * Top-level metadata: name plus the enabled toggle. The automation has no `enabled` field of its own —\n * enabling it toggles its trigger's `enabled` (the flag the dispatcher reads), so the switch is disabled\n * until both a trigger and an action exist.\n */\nexport const GeneralSection = ({\n automation,\n trigger,\n}: {\n automation: Automation.Automation;\n trigger?: Trigger.Trigger;\n}) => {\n const { defaultValues, fieldMap, handleValuesChanged } = useGeneralForm(automation, trigger);\n\n return (\n <Form.Root\n key={trigger?.id ?? 'new'}\n schema={GeneralForm}\n defaultValues={defaultValues}\n fieldMap={fieldMap}\n onValuesChanged={handleValuesChanged}\n >\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Root>\n );\n};\n\n/** Enabled switch field; disabled (with a hint) until the automation has both a trigger and an action. */\nconst EnabledField = ({\n canEnable,\n messageKey,\n ...props\n}: FormFieldComponentProps & { canEnable: boolean; messageKey?: string }) => {\n const { t } = useTranslation(meta.id);\n return (\n <div className='flex items-center gap-2 pt-form-padding'>\n <Input.Root>\n <Input.Switch\n disabled={!canEnable}\n checked={Boolean(props.getValue()) && canEnable}\n onCheckedChange={(checked) => props.onValueChange(props.type, checked)}\n />\n </Input.Root>\n <span className='text-sm'>{props.label}</span>\n {!canEnable && messageKey && <span className='text-sm text-description'>{t(messageKey)}</span>}\n </div>\n );\n};\n\n//\n// Action\n//\n\n// Two-part action form: pick a kind (operation | routine), then the specific object (a RefField object\n// picker for that type). Modeled as a top-level discriminated union so the Form renders the kind select and\n// the chosen kind's picker as one flat field set (no nested, bordered sub-fieldset). Selecting a routine\n// binds it as input to the \"Run Routine\" (AgentPrompt) operation, so the runnable a trigger points at is\n// always an Operation.\nconst OperationAction = Schema.Struct({\n kind: Schema.Literal('operation'),\n operation: Ref.Ref(Operation.PersistentOperation).pipe(Schema.annotations({ title: 'Operation' }), Schema.optional),\n});\nconst RoutineAction = Schema.Struct({\n kind: Schema.Literal('routine'),\n routine: Ref.Ref(Routine.Routine).pipe(Schema.annotations({ title: 'Routine' }), Schema.optional),\n});\nconst ActionForm = Schema.Union(OperationAction, RoutineAction);\ntype ActionFormValues = Schema.Schema.Type<typeof ActionForm>;\n\n// Flat view of the form values (see `TriggerFormInput`): reach the variant fields that `Partial<T>` drops.\ntype ActionFormInput = {\n readonly kind?: 'operation' | 'routine';\n readonly operation?: Ref.Ref<Operation.PersistentOperation>;\n readonly routine?: Ref.Ref<Routine.Routine>;\n};\n\nexport const ActionSection = ({\n db,\n automation,\n trigger,\n}: {\n db: Database.Database;\n automation: Automation.Automation;\n trigger?: Trigger.Trigger;\n}) => {\n const { defaultValues, fieldMap, handleValuesChanged, selectedOperation } = useActionForm(db, automation, trigger);\n\n return (\n <div className='flex flex-col gap-2'>\n <Form.Root\n // Remount when the bound trigger changes so the uncontrolled form picks up its action.\n key={trigger?.id ?? 'new'}\n schema={ActionForm}\n defaultValues={defaultValues}\n db={db}\n fieldMap={fieldMap}\n onValuesChanged={handleValuesChanged}\n >\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Root>\n\n {/* Bind the operation's inputs (e.g. an object ref) once a trigger exists — input lives on the trigger;\n a ref set here is what associates a non-feed object via `automationsForObject`. */}\n {trigger && selectedOperation && <ActionInputEditor db={db} operation={selectedOperation} trigger={trigger} />}\n </div>\n );\n};\n\nconst ActionInputEditor = ({\n db,\n operation,\n trigger,\n}: {\n db: Database.Database;\n operation: Operation.PersistentOperation;\n trigger: Trigger.Trigger;\n}) => {\n const { t } = useTranslation(meta.id);\n const effectSchema = useMemo(\n () => (operation.inputSchema ? JsonSchema.toEffectSchema(operation.inputSchema) : undefined),\n [operation.inputSchema],\n );\n const propertyCount = operation.inputSchema?.properties ? Object.keys(operation.inputSchema.properties).length : 0;\n // Read the current input once per operation (key remounts the uncontrolled Form when the action changes).\n const defaultValues = useMemo(\n () => ({ ...((trigger.input as Record<string, unknown>) ?? {}) }),\n [operation.id, trigger],\n );\n const handleValuesChanged = useCallback(\n (values: Record<string, unknown>) => {\n Obj.update(trigger, (trigger) => {\n trigger.input = values;\n });\n },\n [trigger],\n );\n\n if (!effectSchema || propertyCount === 0) {\n return null;\n }\n\n return (\n <>\n <Form.Label label={t('action-input.label')} asChild />\n <Form.Root\n key={operation.id}\n schema={effectSchema}\n defaultValues={defaultValues}\n db={db}\n onValuesChanged={handleValuesChanged}\n >\n <Form.FieldSet />\n </Form.Root>\n </>\n );\n};\n\n//\n// Trigger\n//\n\n// Scoped trigger form: timer (cron) or feed, modeled as a top-level discriminated union so the Form renders\n// the kind select and the chosen kind's field as one flat field set (no nested, bordered sub-fieldset). The\n// feed field carries ParentLabelAnnotation so the built-in RefField labels feed options by their parent\n// object (e.g. the mailbox) — configured per field via the annotation rather than a hard-coded option mapper.\nconst TimerSpecForm = Schema.Struct({\n kind: Schema.Literal('timer'),\n cron: Schema.String.pipe(Schema.annotations({ title: 'Schedule (cron)' }), Schema.optional),\n});\nconst FeedSpecForm = Schema.Struct({\n kind: Schema.Literal('feed'),\n feed: Ref.Ref(Feed.Feed).pipe(\n ParentLabelAnnotation.set(true),\n Schema.annotations({ title: 'Feed' }),\n Schema.optional,\n ),\n});\nconst TriggerForm = Schema.Union(TimerSpecForm, FeedSpecForm);\ntype TriggerFormValues = Schema.Schema.Type<typeof TriggerForm>;\n\n// Flat view of the form values: `Partial<TriggerFormValues>` collapses a discriminated union to its common\n// key alone (`kind`), so reach the variant fields through this all-optional shape instead. `Partial<T>` is\n// assignable to it, so handlers/helpers can accept the Form's value verbatim and still read `cron`/`feed`.\ntype TriggerFormInput = {\n readonly kind?: 'timer' | 'feed';\n readonly cron?: string;\n readonly feed?: Ref.Ref<Feed.Feed>;\n};\n\n/** Project a trigger spec onto the form's discriminated-union members. */\nconst triggerFormValues = (spec?: Trigger.Spec): TriggerFormInput =>\n spec?.kind === 'feed'\n ? { kind: 'feed', feed: spec.feed }\n : { kind: 'timer', cron: spec?.kind === 'timer' ? spec.cron : '' };\n\n// Build a trigger spec from the form's values. Returned as just the two specs we construct (not the full\n// `Trigger.Spec` union) so the subscription spec's deep readonly query AST never enters the type and the\n// result stays assignable to the mutable `trigger.spec`.\nconst triggerFormSpec = (values: TriggerFormInput): Trigger.TimerSpec | Trigger.FeedSpec =>\n values.kind === 'feed' ? { kind: 'feed', feed: values.feed } : Trigger.specTimer(values.cron ?? '');\n\nexport const TriggerSection = ({\n db,\n automation,\n trigger,\n}: {\n db: Database.Database;\n automation: Automation.Automation;\n trigger?: Trigger.Trigger;\n}) => {\n const { t } = useTranslation(meta.id);\n const { defaultValues, fieldMap, handleValuesChanged, handleRemove } = useTriggerForm(db, automation, trigger);\n\n return (\n <div className='flex flex-col gap-2'>\n <Form.Root\n // Remount when the bound trigger changes so the uncontrolled form picks up its spec.\n key={trigger?.id ?? 'new'}\n schema={TriggerForm}\n defaultValues={defaultValues}\n db={db}\n fieldMap={fieldMap}\n onValuesChanged={handleValuesChanged}\n >\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Root>\n {trigger && (\n <Button variant='ghost' classNames='gap-1 self-start' onClick={handleRemove}>\n <Icon icon='ph--trash--regular' size={4} />\n <span>{t('remove-trigger.label')}</span>\n </Button>\n )}\n </div>\n );\n};\n\n//\n// Inline form (companion)\n//\n\n/** Compact section heading for the inline form — just a small title, no description (cf. Settings.Section). */\nconst InlineSection = ({ title, children }: { title: string; children: ReactNode }) => (\n <div className='flex flex-col gap-1'>\n <h3 className='pli-1 text-sm font-medium text-description'>{title}</h3>\n <Settings.Panel>{children}</Settings.Panel>\n </div>\n);\n\n/**\n * Compact inline view used in the Automation companion. Renders the same three sections as the full article\n * (General / Trigger / Action) with condensed headings and no descriptions or scrolling Settings.Viewport.\n */\nexport const AutomationInlineForm = ({\n automation,\n db,\n}: {\n automation: Automation.Automation;\n db: Database.Database;\n}) => {\n const { t } = useTranslation(meta.id);\n const trigger = usePrimaryTrigger(automation);\n\n return (\n <div className='flex flex-col gap-3'>\n <InlineSection title={t('general.title')}>\n <GeneralSection automation={automation} trigger={trigger} />\n </InlineSection>\n <InlineSection title={t('trigger-picker.title')}>\n <TriggerSection db={db} automation={automation} trigger={trigger} />\n </InlineSection>\n <InlineSection title={t('action.title')}>\n <ActionSection db={db} automation={automation} trigger={trigger} />\n </InlineSection>\n </div>\n );\n};\n\n//\n// Hooks\n//\n\n/** Subscribe to the automation and derive its primary (first) trigger. */\nconst usePrimaryTrigger = (automation: Automation.Automation): Trigger.Trigger | undefined => {\n const [snapshot] = useObject(automation);\n return useMemo(() => {\n for (const ref of snapshot.triggers) {\n const target = ref.target;\n if (Obj.instanceOf(Trigger.Trigger, target)) {\n return target;\n }\n }\n return undefined;\n }, [snapshot.triggers]);\n};\n\n/** Form state for the General section: the name plus an enabled toggle that writes through to the trigger. */\nconst useGeneralForm = (automation: Automation.Automation, trigger?: Trigger.Trigger) => {\n const [auto, updateAuto] = useObject(automation);\n const canEnable = Boolean(trigger && auto.runnable);\n const messageKey = !trigger\n ? 'add-trigger-first.message'\n : !auto.runnable\n ? 'select-action-first.message'\n : undefined;\n\n const fieldMap = useMemo<FormFieldMap>(\n () => ({ enabled: (props) => <EnabledField {...props} canEnable={canEnable} messageKey={messageKey} /> }),\n [canEnable, messageKey],\n );\n\n // Read once per trigger identity; the uncontrolled form owns edits after mount.\n const defaultValues = useMemo<Partial<GeneralFormValues>>(\n () => ({ name: auto.name, enabled: (trigger?.enabled ?? false) && canEnable }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [automation, trigger],\n );\n\n const handleValuesChanged = useCallback(\n (values: Partial<GeneralFormValues>) => {\n updateAuto((automation) => {\n automation.name = values.name;\n });\n if (trigger && canEnable) {\n Obj.update(trigger, (trigger) => {\n trigger.enabled = values.enabled ?? false;\n });\n }\n },\n [updateAuto, trigger, canEnable],\n );\n\n return { defaultValues, fieldMap, handleValuesChanged };\n};\n\n/** Form state for the Action section: pick an operation|routine and bind it to the trigger's function/input. */\nconst useActionForm = (db: Database.Database, automation: Automation.Automation, trigger?: Trigger.Trigger) => {\n const { t } = useTranslation(meta.id);\n const [auto, updateAuto] = useObject(automation);\n // Query by typename DXN so results stay untyped (`Entity.Any[]`), as RefField.useResults expects.\n const operations = useQuery(\n db,\n // Include registry operations (built-in / plugin-provided) alongside space-resident ones.\n Query.select(Filter.type(DXN.make(Type.getTypename(Operation.PersistentOperation)))).from(\n Scope.space(),\n Scope.registry(),\n ),\n );\n const routines = useQuery(\n db,\n Query.select(Filter.type(DXN.make(Type.getTypename(Routine.Routine)))).from(Scope.space(), Scope.registry()),\n );\n const runRoutineOp = useMemo(() => findRunRoutineOp(operations), [operations]);\n const boundRoutine = getBoundRoutine(trigger);\n const runnableTarget = auto.runnable?.target;\n\n const kindOptions = useMemo(\n () => [\n { value: 'operation', label: t('action-kind.operation.label') },\n { value: 'routine', label: t('action-kind.routine.label') },\n ],\n [t],\n );\n const fieldMap = useMemo<FormFieldMap>(\n () => ({\n kind: (props) => <SelectField {...props} options={kindOptions} />,\n // Custom useResults so pickers draw from the already-queried sets (space + registry for\n // operations; space-only for routines) rather than RefField's default typename query.\n operation: (props) => <RefField {...props} db={db} useResults={() => operations} />,\n routine: (props) => <RefField {...props} db={db} useResults={() => routines} />,\n }),\n [kindOptions, operations, routines, db],\n );\n\n // Read the current action once per trigger identity (the uncontrolled form owns edits after mount).\n const defaultValues = useMemo<Partial<ActionFormValues>>(() => {\n if (boundRoutine) {\n return { kind: 'routine', routine: Ref.make(boundRoutine) };\n }\n if (auto.runnable && Obj.instanceOf(Operation.PersistentOperation, runnableTarget)) {\n return { kind: 'operation', operation: auto.runnable };\n }\n return { kind: 'operation' };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [automation, trigger]);\n\n const handleValuesChanged = useCallback(\n (values: Partial<ActionFormValues>) => {\n const action: ActionFormInput = values;\n if (action.kind === 'routine') {\n const routineRef = action.routine;\n if (!routineRef || !runRoutineOp) {\n return;\n }\n updateAuto((automation) => {\n automation.runnable = Ref.make(runRoutineOp);\n });\n if (trigger) {\n Obj.update(trigger, (trigger) => {\n trigger.function = Ref.make(runRoutineOp);\n trigger.input = { prompt: routineRef, input: {} };\n });\n }\n } else if (action.kind === 'operation' && action.operation) {\n const operationRef = action.operation;\n updateAuto((automation) => {\n automation.runnable = operationRef;\n });\n if (trigger) {\n Obj.update(trigger, (trigger) => {\n trigger.function = operationRef;\n trigger.input = undefined;\n });\n }\n }\n },\n [runRoutineOp, trigger, updateAuto],\n );\n\n // The directly-selected operation (not the routine-bound AgentPrompt case); its input schema drives the editor.\n const selectedOperation =\n !boundRoutine && Obj.instanceOf(Operation.PersistentOperation, runnableTarget) ? runnableTarget : undefined;\n\n return { defaultValues, fieldMap, handleValuesChanged, selectedOperation };\n};\n\n/** Form state for the Trigger section: the timer|feed spec, plus create-on-first-edit and remove handlers. */\nconst useTriggerForm = (db: Database.Database, automation: Automation.Automation, trigger?: Trigger.Trigger) => {\n const { t } = useTranslation(meta.id);\n const kindOptions = useMemo(\n () => [\n { value: 'timer', label: t('trigger-kind.timer.label') },\n { value: 'feed', label: t('trigger-kind.feed.label') },\n ],\n [t],\n );\n const fieldMap = useMemo<FormFieldMap>(\n () => ({ kind: (props) => <SelectField {...props} options={kindOptions} /> }),\n [kindOptions],\n );\n // Read once per trigger identity (uncontrolled Form); default to an empty timer spec.\n const defaultValues = useMemo<Partial<TriggerFormValues>>(\n () => triggerFormValues(trigger?.spec),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [trigger],\n );\n\n const handleValuesChanged = useCallback(\n (values: Partial<TriggerFormValues>) => {\n const spec = triggerFormSpec(values);\n if (trigger) {\n Obj.update(trigger, (trigger) => {\n trigger.spec = spec;\n });\n } else {\n // Create the trigger on first edit; `function` is wired by the action section, and it stays disabled\n // until an action is set, so a function-less trigger never dispatches. The trigger is owned by the\n // automation (it is only reachable via it), so it is parented and cascade-deletes with the automation.\n const created = db.add(Trigger.make({ function: automation.runnable, enabled: false, spec }));\n Obj.setParent(created, automation);\n Obj.update(automation, (automation) => {\n automation.triggers = [...automation.triggers, Ref.make(created)];\n });\n }\n },\n [db, automation, trigger],\n );\n\n const handleRemove = useCallback(() => {\n if (!trigger) {\n return;\n }\n Obj.update(automation, (automation) => {\n automation.triggers = automation.triggers.filter((ref) => ref.target?.id !== trigger.id);\n });\n db.remove(trigger);\n }, [db, automation, trigger]);\n\n return { defaultValues, fieldMap, handleValuesChanged, handleRemove };\n};\n\n//\n// Helpers\n//\n\n/** Read back the routine bound into a trigger's AgentPrompt input, if any. */\nconst getBoundRoutine = (trigger?: Trigger.Trigger): Routine.Routine | undefined => {\n const prompt = (trigger?.input as { prompt?: Ref.Ref<unknown> } | undefined)?.prompt;\n const target = Ref.isRef(prompt) ? prompt.target : undefined;\n return Obj.instanceOf(Routine.Routine, target) ? target : undefined;\n};\n\n/** Find the persisted \"Run Routine\" (AgentPrompt) operation by its DXN, avoiding a hard assistant-toolkit dep. */\nconst findRunRoutineOp = (operations: Entity.Any[]): Operation.PersistentOperation | undefined => {\n for (const op of operations) {\n if (!Obj.instanceOf(Operation.PersistentOperation, op)) {\n continue;\n }\n // Control-flow narrowed: op is Entity.Any & Operation.PersistentOperation.\n try {\n if (Operation.deserialize(op).meta.key.toString().includes(RUN_ROUTINE_DXN)) {\n return op;\n }\n } catch {\n // Not a valid/deserializable operation or key does not match.\n }\n }\n return undefined;\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,YAAY;AACxB,OAAOC,SAAyBC,aAAaC,eAAe;AAG5D,SAASC,WAAWC,SAASC,eAAe;AAC5C,SAAgCC,MAAMC,QAAQC,YAAYC,KAAKC,OAAOC,KAAKC,OAAOC,YAAY;AAC9F,SAASC,WAAW;AACpB,SAASC,WAAWC,gBAAgB;AACpC,SAASC,QAAQC,MAAMC,OAAOC,sBAAsB;AACpD,SACEC,MAGAC,UACAC,aACAC,gBACK;AACP,SAASC,6BAA6B;AAEtC,SAASC,YAAY;AAGrB,IAAMC,kBAAkB;AAIjB,IA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OAAOzB,SAASnC;AACnD,SAAOtF,IAAI0H,WAAW/H,QAAQA,SAAS8H,MAAAA,IAAUA,SAASnC;AAC5D;AAGA,IAAMiD,mBAAmB,CAACT,eAAAA;AACxB,aAAW4B,MAAM5B,YAAY;AAC3B,QAAI,CAAC9H,IAAI0H,WAAWhI,UAAUiF,qBAAqB+E,EAAAA,GAAK;AACtD;IACF;AAEA,QAAI;AACF,UAAIhK,UAAUiK,YAAYD,EAAAA,EAAIzI,KAAKkC,IAAIyG,SAAQ,EAAGC,SAAS3I,eAAAA,GAAkB;AAC3E,eAAOwI;MACT;IACF,QAAQ;IAER;EACF;AACA,SAAOpE;AACT;",
|
|
6
|
-
"names": ["Schema", "React", "useCallback", "useMemo", "Operation", "Routine", "Trigger", "Feed", "Filter", "JsonSchema", "Obj", "Query", "Ref", "Scope", "Type", "DXN", "useObject", "useQuery", "Button", "Icon", "Input", "useTranslation", "Form", "RefField", "SelectField", "Settings", "ParentLabelAnnotation", "meta", "RUN_ROUTINE_DXN", "AutomationArticle", "role", "subject", "t", "id", "db", "getDatabase", "trigger", "usePrimaryTrigger", "Viewport", "Section", "title", "description", "Panel", "GeneralSection", "automation", "TriggerSection", "ActionSection", "GeneralForm", "Struct", "name", "String", "pipe", "annotations", "optional", "enabled", "Boolean", "defaultValues", "fieldMap", "handleValuesChanged", "useGeneralForm", "Root", "key", "schema", "onValuesChanged", "Content", "FieldSet", "EnabledField", "canEnable", "messageKey", "props", "div", "className", "Switch", "disabled", "checked", "getValue", "onCheckedChange", "onValueChange", "type", "span", "label", "OperationAction", "kind", "Literal", "operation", "PersistentOperation", "RoutineAction", "routine", "ActionForm", "Union", "selectedOperation", "useActionForm", "ActionInputEditor", "effectSchema", "inputSchema", "toEffectSchema", "undefined", "propertyCount", "properties", "Object", "keys", "length", "input", "values", "update", "Label", "asChild", "TimerSpecForm", "cron", "FeedSpecForm", "feed", "set", "TriggerForm", "triggerFormValues", "spec", "triggerFormSpec", "specTimer", "handleRemove", "useTriggerForm", "variant", "classNames", "onClick", "icon", "size", "InlineSection", "children", "h3", "AutomationInlineForm", "snapshot", "ref", "triggers", "target", "instanceOf", "auto", "updateAuto", "runnable", "operations", "select", "make", "getTypename", "from", "space", "registry", "routines", "runRoutineOp", "findRunRoutineOp", "boundRoutine", "getBoundRoutine", "runnableTarget", "kindOptions", "value", "options", "useResults", "action", "routineRef", "function", "prompt", "operationRef", "created", "add", "setParent", "filter", "remove", "isRef", "op", "deserialize", "toString", "includes"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/types/Automation.ts", "../../../src/types/Runnable.ts", "../../../src/types/AutomationCapabilities.ts", "../../../src/types/AutomationOperation.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Database } from '@dxos/echo';\n\nimport { meta } from '#meta';\n\nexport const TriggerTemplate = Schema.Union(\n Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),\n Schema.Struct({ type: Schema.Literal('feed'), feed: Schema.Any }),\n);\n\nexport namespace AutomationAction {\n export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(\n `${meta.id}.action.create-trigger-from-template`,\n {\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n // TODO(wittjosiah): Improve how this lookup is done.\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n },\n ) {}\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Annotation, Obj, Ref, Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo/internal';\n\nimport * as Runnable from './Runnable';\n\n/**\n * User-facing automation: a thin aggregate of an action (`runnable`) and the triggers that fire it.\n * App-level only — EDGE stays unaware of it (triggers point directly at the runnable).\n */\nexport const Automation = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n description: Schema.String.pipe(Schema.optional),\n /**\n * The action to run. A trigger's `function` Ref points directly at this (so EDGE/the dispatcher can run\n * it). `Runnable` is the type seam — currently just Operation; see Runnable.ts.\n */\n runnable: Ref.Ref(Runnable.Runnable).pipe(Schema.optional),\n /**\n * Explicit membership, bi-directional with `trigger.function → runnable`. Required (not derived by query)\n * because the runnable may be a shared registry operation referenced by multiple automations, which would\n * conflate triggers. MVP enforces length <= 1.\n *\n * Typed as `Obj.Unknown` (not `Trigger`) to avoid pulling query-AST types into the emitted declaration —\n * the same reason `Trigger.function` uses `Obj.Unknown`. Resolve and narrow with `Obj.instanceOf(Trigger)`.\n */\n triggers: Schema.Array(Ref.Ref(Obj.Unknown)),\n}).pipe(\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--lightning--regular', hue: 'amber' }),\n Type.makeObject(DXN.make('org.dxos.type.automation', '0.1.0')),\n);\n\nexport type Automation = Type.InstanceType<typeof Automation>;\n\nexport const instanceOf = (value: unknown): value is Automation => Obj.instanceOf(Automation, value);\n\nexport const make = (props: Obj.MakeProps<typeof Automation>) => Obj.make(Automation, props);\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { Operation } from '@dxos/compute';\n\n// TODO(wittjosiah): Currently just Operation. Widen to a union (Operation | ComputeGraph | …) once the\n// dispatcher/EDGE can run non-Operation runnables as a Process; factor down to @dxos/compute once\n// ComputeGraph's type moves there. Routines are NOT a direct member — they run via the AgentPrompt\n// operation (bound as input).\nexport type Runnable = Operation.PersistentOperation;\nexport const Runnable = Operation.PersistentOperation;\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport type { Database, Obj } from '@dxos/echo';\nimport { type DelegationStrategy } from '@dxos/functions-runtime';\n\nimport * as Automation from './Automation';\n\n/**\n * Optional supervisor strategy for the agent chat service. When contributed (by a plugin that knows\n * the agent/plan model, e.g. plugin-assistant), the conversational agent delegates outstanding work\n * to sub-agents and folds their results back into the conversation. Consumed by the AgentService\n * LayerSpec; absent by default (a plain conversational agent).\n */\nexport const AgentDelegationStrategy = Capability.make<DelegationStrategy>(\n 'org.dxos.plugin.automation.capability.agentDelegationStrategy',\n);\n\n/**\n * An automation template contributed by a plugin. The create dialog and the per-object \"Automations\"\n * companion list contributed templates (`Capability.getAll(AutomationCapabilities.Template)`) and run the\n * chosen template's `scaffold` to build the automation.\n */\nexport type Template = {\n /** Stable id (e.g. 'org.dxos.automation.blank'). */\n id: string;\n /** Human-readable label shown in the picker. */\n label: string;\n /** Optional Phosphor icon name. */\n icon?: string;\n /**\n * Whether this template applies to the given companion subject. The subject is the object whose\n * \"Automations\" companion is open, or undefined in the global create dialog. Templates that need a\n * specific subject (e.g. a feed-bearing Mailbox) gate themselves here. Defaults to always-applies.\n */\n appliesTo?: (subject?: Obj.Unknown) => boolean;\n /**\n * Build the Automation from the user's input. The returned Automation is added to the database by the\n * create flow; any auxiliary objects (runnable, triggers) must be added by the scaffold itself via\n * Database.Service. `subject` is set when scaffolding from an object's companion.\n */\n scaffold: (ctx: {\n name?: string;\n subject?: Obj.Unknown;\n }) => Effect.Effect<Automation.Automation, Error, Database.Service>;\n};\n\nexport const Template = Capability.make<Template>('org.dxos.plugin.automation.capability.template');\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Operation } from '@dxos/compute';\nimport { Database, DXN, Obj } from '@dxos/echo';\n// Value-side `EID` import keeps TS declaration emit portable — `TriggerTemplate`\n// references `EID.Schema` and the inferred `CreateTriggerFromTemplate` type\n// otherwise needs a transitive `@dxos/keys` import that's hard for d.ts emit to surface.\nimport { EID as _EchoURIReference } from '@dxos/keys';\n\nimport { meta } from '#meta';\n\nimport { TriggerTemplate } from './schema';\nexport { _EchoURIReference };\n\nconst makeKey = (name: string) => DXN.make(`${meta.id}.operation.${name}`);\n\nexport const CreateTriggerFromTemplate = Operation.make({\n meta: {\n key: makeKey('createTriggerFromTemplate'),\n name: 'Create Trigger From Template',\n icon: 'ph--lightning--regular',\n },\n services: [Capability.Service],\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n});\n\n// The single creation entrypoint for every path (create dialog, companion, sidebar) so placement and\n// ownership are established in one place. Output mirrors `SpaceCapabilities.CreateObjectResult`.\nexport const CreateAutomation = Operation.make({\n meta: {\n key: makeKey('createAutomation'),\n name: 'Create Automation',\n icon: 'ph--lightning--regular',\n },\n services: [Capability.Service],\n input: Schema.Struct({\n db: Database.Database,\n templateId: Schema.String,\n name: Schema.optional(Schema.String),\n subject: Schema.optional(Obj.Unknown),\n }),\n output: Schema.Struct({\n id: Schema.String,\n subject: Schema.Array(Schema.String),\n object: Obj.Unknown,\n }),\n});\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,gBAAgB;AAEzB,SAASC,YAAY;AAEd,IAAMC,kBAAyBC,aAC7BC,cAAO;EAAEC,MAAaC,eAAQ,OAAA;EAAUC,MAAaC;AAAO,CAAA,GAC5DJ,cAAO;EAAEC,MAAaC,eAAQ,MAAA;EAASG,MAAaC;AAAI,CAAA,CAAA;UAGhDC,mBAAAA;EACR,MAAMC,mCAAyCC,mBAAW,EAC/D,GAAGZ,KAAKa,EAAE,wCACV;IACEC,OAAcX,cAAO;MACnBY,IAAIhB,SAASA;MACbiB,UAAUf;MACVgB,SAAgBC,gBAAgBC,cAAO;;MAEvCC,YAAmBF,gBAAgBX,aAAM;MACzCO,OAAcI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IAAMC,UAAU,CAACC,SAAiBC,KAAIC,KAAK,GAAGC,MAAKC,EAAE,cAAcJ,IAAAA,EAAM;AAElE,IAAMK,4BAA4BC,WAAUJ,KAAK;EACtDC,MAAM;IACJI,KAAKR,QAAQ,2BAAA;IACbC,MAAM;IACNQ,MAAM;EACR;EACAC,UAAU;IAACC,YAAWC;;EACtBC,OAAcC,eAAO;IACnBC,IAAIC,UAASA;IACbC,UAAUC;IACVC,SAAgBC,iBAAgBC,eAAO;IACvCC,YAAmBF,iBAAgBG,cAAM;IACzCV,OAAcO,iBAAgBI,eAAO;MAAEhB,KAAYe;MAAQE,OAAcC;IAAI,CAAA,CAAA;EAC/E,CAAA;EACAC,QAAeC;AACjB,CAAA;AAIO,IAAMC,mBAAmBtB,WAAUJ,KAAK;EAC7CC,MAAM;IACJI,KAAKR,QAAQ,kBAAA;IACbC,MAAM;IACNQ,MAAM;EACR;EACAC,UAAU;IAACC,YAAWC;;EACtBC,OAAcC,eAAO;IACnBC,IAAIC,UAASA;IACbc,YAAmBP;IACnBtB,MAAamB,iBAAgBG,cAAM;IACnCQ,SAAgBX,iBAASY,KAAIC,OAAO;EACtC,CAAA;EACAN,QAAeb,eAAO;IACpBT,IAAWkB;IACXQ,SAAgBG,cAAaX,cAAM;IACnCY,QAAQH,KAAIC;EACd,CAAA;AACF,CAAA;",
|
|
6
|
-
"names": ["Schema", "Database", "meta", "TriggerTemplate", "Union", "Struct", "type", "Literal", "cron", "String", "feed", "Any", "AutomationAction", "CreateTriggerFromTemplate", "TaggedClass", "id", "input", "db", "template", "enabled", "optional", "Boolean", "scriptName", "Record", "key", "value", "output", "Void", "Schema", "DXN", "Annotation", "Obj", "Ref", "Type", "LabelAnnotation", "Operation", "Runnable", "PersistentOperation", "Automation", "Struct", "name", "String", "pipe", "optional", "description", "runnable", "Ref", "Runnable", "triggers", "Array", "Obj", "Unknown", "LabelAnnotation", "set", "Annotation", "IconAnnotation", "icon", "hue", "Type", "makeObject", "DXN", "make", "instanceOf", "value", "props", "Capability", "AgentDelegationStrategy", "make", "Template", "Schema", "Capability", "Operation", "Database", "DXN", "Obj", "EID", "_EchoURIReference", "meta", "makeKey", "name", "DXN", "make", "meta", "id", "CreateTriggerFromTemplate", "Operation", "key", "icon", "services", "Capability", "Service", "input", "Struct", "db", "Database", "template", "TriggerTemplate", "enabled", "optional", "Boolean", "scriptName", "String", "Record", "value", "Any", "output", "Void", "CreateAutomation", "templateId", "subject", "Obj", "Unknown", "Array", "object"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/AutomationPlugin.tsx", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-automation/PLUGIN.mdl?raw"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { ActivationEvent, ActivationEvents, Plugin } from '@dxos/app-framework';\nimport { AppPlugin, AppActivationEvents } from '@dxos/app-toolkit';\nimport { Operation, Trace, Trigger } from '@dxos/compute';\nimport { ClientEvents } from '@dxos/plugin-client';\n\nimport {\n AppGraphBuilder,\n CreateObject,\n LayerSpecs,\n NavigationResolver,\n OperationHandler,\n ReactSurface,\n RegistrySync,\n Templates,\n TriggerRuntimeController,\n} from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Automation } from '#types';\n\n// eslint-disable-next-line import/no-relative-packages\nimport pluginSpec from '../PLUGIN.mdl?raw';\n\nexport const AutomationPlugin = Plugin.define(meta).pipe(\n AppPlugin.addAppGraphModule({ activate: AppGraphBuilder }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSchemaModule({\n schema: [Automation.Automation, Operation.PersistentOperation, Trigger.Trigger, Trace.Message],\n }),\n AppPlugin.addCreateObjectModule({ activate: CreateObject }),\n AppPlugin.addNavigationResolverModule({ activate: NavigationResolver }),\n Plugin.addModule({ id: 'automation-templates', activatesOn: AppActivationEvents.SetupSchema, activate: Templates }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n activatesOn: ClientEvents.ClientReady,\n firesBeforeActivation: [ActivationEvents.SetupProcessManager],\n activate: LayerSpecs,\n }),\n Plugin.addModule({\n activatesOn: ClientEvents.ClientReady,\n activate: RegistrySync,\n }),\n Plugin.addModule({\n activatesOn: ActivationEvent.allOf(ActivationEvents.ProcessManagerReady, ClientEvents.SpacesReady),\n activate: TriggerRuntimeController,\n }),\n AppPlugin.addPluginAssetModule({\n asset: { pluginId: meta.id, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },\n }),\n Plugin.make,\n);\n\nexport default AutomationPlugin;\n", "---\nid: org.dxos.plugin.automation\nname: AutomationPlugin\nversion: 0.1.0\n---\n\nA workflow automation engine plugin for DXOS Composer that enables event-driven\npipelines connecting ECHO objects to persistent compute functions.\n\nTriggers listen for ECHO mutations, timer schedules, incoming feeds (email, webhook),\nor data subscriptions and invoke `PersistentOperation` handlers when their conditions\nfire. Each trigger carries optional structured input and is dispatched by a\nper-space `TriggerDispatcher` that runs locally in the browser or is delegated to\nthe DXOS edge when the space `computeEnvironment` is `edge`.\n\nThe plugin integrates with the `@dxos/compute` operation registry and the\n`@dxos/functions-runtime` execution layer. Blueprint, operation-handler, and\ntoolkit contributions from other plugins are gathered at application scope and\nmerged before being offered to space-level operation registries, so any plugin\nthat contributes a `Capabilities.OperationHandler` automatically becomes\ninvocable from an automation trigger.\n\nUsers interact with automations through the `AutomationPanel` settings surface,\nwhich lists active triggers for a space (or for a specific ECHO object) and\nopens the `TriggerEditor` form to create, configure, and enable/disable\nindividual triggers.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|-------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\nExisting types used by this plugin (defined in `@dxos/compute` and `@dxos/functions-runtime`):\n\n| Type | Source | Role in AutomationPlugin |\n|----------------------|---------------------------|--------------------------------------------------------------------|\n| `Trigger` | `@dxos/compute` | Persistent trigger configuration (spec, function ref, input, enabled) |\n| `PersistentOperation`| `@dxos/compute` | Registered compute function callable from a trigger |\n| `Trace.Message` | `@dxos/compute` | Execution trace record appended after each trigger run |\n| `Script` | `@dxos/compute` | Source script that produces one or more `PersistentOperation`s |\n| `Feed` | `@dxos/echo` | Feed object that a `feed`-spec trigger listens to |\n| `ComputeGraph` | `@dxos/conductor` | Visual workflow graph selectable as a trigger function |\n\nNew types defined by this plugin:\n\n```mdl\ntype TriggerTemplate\n desc: |\n Lightweight description of a trigger's spec used when creating a trigger\n from a pre-defined template (e.g. from a Blueprint action).\n literals: timer | feed\n fields:\n type: timer | feed\n cron?: string # required when type === timer; cron expression\n feed?: Feed # required when type === feed; the feed to subscribe to\n```\n\n## Components\n\n```mdl\ncomponent AutomationPanel\n desc: |\n Settings surface that lists all triggers for a space (or filtered to a\n specific ECHO object) and provides inline create / edit / delete via the\n TriggerEditor form. Displayed inside Settings.Panel at the path\n `<spacePath>/settings/org.dxos.plugin.automation.automations`.\n props:\n space: Space\n object?: Obj.Unknown # when set, only triggers matching this object are shown\n initialTrigger?: Trigger # pre-populate TriggerEditor for a new trigger\n onDone?: () => void\n state:\n trigger?: Trigger # trigger currently open in TriggerEditor (undefined = list view)\n selected?: Trigger # the existing trigger being edited (undefined = new)\n slots:\n (none)\n actions:\n handleAdd() # open TriggerEditor with a blank Trigger\n handleSelect(t: Trigger) # open TriggerEditor for an existing trigger\n handleDelete(t: Trigger) # remove trigger from space.db\n handleSave(t: Trigger) # persist new or update selected trigger\n handleCancel()\n handleForceRunTrigger(t: Trigger) # invoke timer trigger immediately\n handleResetCursor(t: Trigger) # clear feed cursor on a feed trigger\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 [list view \u2014 triggers exist] \u2502\n \u2502 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502\n \u2502 \u2502 \u25CB fn-name [\u25B6] [\u2715] \u2502 \u2502\n \u2502 \u2502 \u25CF fn-name [\u21BA] [\u2715] \u2502 \u2502\n \u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\n \u2502 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2502\n \u2502 [+ New Trigger] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 [editor view \u2014 trigger selected] \u2502\n \u2502 Settings.Item \u2502\n \u2502 \u2514\u2500\u2500 TriggerEditor \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent TriggerEditor\n desc: |\n Form-driven editor for a single Trigger. Renders a Form.Root backed by the\n Trigger schema with custom field overrides for function/workflow selection,\n spec kind selector, feed selector, subscription query builder, and\n structured input editor.\n props:\n db: Database\n trigger: Trigger\n types: TypeOption[] # available ECHO types for query builder\n tags: Tag[] # available tags for query builder\n readonlySpec?: boolean # lock spec.kind and spec.query (e.g. editing from an object context)\n onSave: (t: Partial<Trigger>) => void\n onCancel: () => void\n state:\n (managed by Form.Root)\n slots:\n (none)\n```\n\n```mdl\ncomponent FunctionsPanel\n desc: |\n Settings surface listing all PersistentOperation objects in a space.\n Each row shows the function name, optional source script name, a\n \"go to script\" icon button, and a delete button.\n props:\n space: Space\n state:\n functions: PersistentOperation[]\n scripts: Script[]\n slots:\n (none)\n actions:\n handleGoToScript(fn: PersistentOperation) # navigate to source Script\n handleDelete(fn: PersistentOperation) # remove function via SpaceOperation\n```\n\n## Operations\n\n```mdl\nop CreateTriggerFromTemplate\n desc: |\n Creates a new Trigger from a lightweight template, optionally wiring it to\n a named Script's PersistentOperation, and navigates to the automations\n settings panel for the target space.\n input:\n db: Database\n template: TriggerTemplate\n enabled?: boolean # default false\n scriptName?: string # if provided, looks up Script by name and wires function ref\n input?: Record<string, any> # optional structured input forwarded to the trigger\n output: void\n effects: [echo:write, layout:navigate]\n requires: [SpaceOperation.AddObject, LayoutOperation.Open]\n note: |\n Resolves the named Script, finds its linked PersistentOperation, and sets\n trigger.function = Ref.make(fn). Template type determines spec:\n timer \u2192 Trigger.specTimer(cron)\n feed \u2192 Trigger.specFeed(feed)\n Trigger is added as a hidden object so it does not appear in the main graph.\n```\n\n## Features\n\n```mdl\nfeat F-1: Trigger Management\n\n req F-1.1: User can create a Trigger in any space via AutomationPanel.\n req F-1.2: User can edit an existing Trigger's function, spec, and input.\n req F-1.3: User can delete a Trigger; it is removed from space.db.\n req F-1.4: User can enable or disable a Trigger via an inline toggle.\n req F-1.5:\n when: object context provided to AutomationPanel\n then: only triggers matching that object's type or query are shown\n```\n\n```mdl\nfeat F-2: Trigger Dispatch\n\n req F-2.1:\n when: space.properties.computeEnvironment === \"local\"\n then: TriggerDispatcher starts for that space\n\n req F-2.2:\n when: space.properties.computeEnvironment === \"edge\" or \"disabled\"\n then: TriggerDispatcher stops for that space\n\n req F-2.3:\n when: computeEnvironment changes\n then: any in-flight dispatcher transition is cancelled before the new one starts\n\n req F-2.4:\n when: trigger spec.kind === \"timer\" and enabled === true\n then: TriggerDispatcher fires trigger according to cron expression\n\n req F-2.5:\n when: trigger spec.kind === \"feed\"\n then: TriggerDispatcher processes new messages from the linked Feed\n\n req F-2.6:\n when: trigger spec.kind === \"subscription\"\n then: TriggerDispatcher invokes trigger on matching ECHO object mutations\n```\n\n```mdl\nfeat F-3: Force Run and Cursor Reset\n\n req F-3.1:\n when: timer trigger is enabled and computeEnvironment !== \"disabled\"\n then: user can force-run the trigger immediately from AutomationPanel\n\n req F-3.2:\n when: computeEnvironment === \"local\"\n then: force-run invokes TriggerDispatcher.invokeTrigger directly in-process\n\n req F-3.3:\n when: computeEnvironment === \"edge\"\n then: force-run calls FunctionsServiceClient.forceRunCronTrigger via HTTP\n\n req F-3.4:\n when: trigger spec.kind === \"feed\" and a cursor is stored\n then: user can reset the cursor to reprocess the feed from the beginning\n```\n\n```mdl\nfeat F-4: Operation Registry\n\n req F-4.1:\n when: plugin activates\n then: all Capabilities.OperationHandler contributions are merged into a single OperationHandlerProvider\n\n req F-4.2: OperationRegistry per space resolves operations from the merged OperationHandlerProvider.\n req F-4.3: Blueprint registry is populated from AppCapabilities.BlueprintDefinition contributions.\n req F-4.4: OpaqueToolkit aggregates AppCapabilities.Toolkit contributions for agent invocation.\n```\n\n```mdl\nfeat F-5: Trace Sink\n\n req F-5.1:\n when: a trigger executes\n then: execution trace messages are written to the space Feed via FeedTraceSink\n\n req F-5.2: FeedTraceSink is contributed to Capabilities.TraceSink and routed via makeRoutingSink.\n```\n\n```mdl\nfeat F-6: Create Trigger From Template\n\n req F-6.1:\n when: op:CreateTriggerFromTemplate is invoked\n then: a Trigger is created and added as a hidden ECHO object in the target space\n\n req F-6.2:\n when: scriptName is provided\n then: the Trigger.function is wired to the PersistentOperation linked to that Script\n\n req F-6.3:\n when: template.type === \"timer\"\n then: Trigger.spec is set via Trigger.specTimer(template.cron)\n\n req F-6.4:\n when: template.type === \"feed\"\n then: Trigger.spec is set via Trigger.specFeed(template.feed)\n\n req F-6.5:\n when: trigger is created\n then: layout navigates to the automations settings panel for the space\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Create trigger via AutomationPanel\n given: AutomationPanel rendered for a space with no triggers\n when: user clicks \"New Trigger\"\n then:\n - TriggerEditor shown with a blank Trigger\n - selected state is undefined (new trigger mode)\n```\n\n```mdl\ntest T-2: Save new trigger\n given: TriggerEditor open with blank Trigger\n when: user fills in a function and spec, then saves\n then:\n - space.db.add called with a new Trigger\n - list view restored\n - onDone called\n```\n\n```mdl\ntest T-3: Edit existing trigger\n given: AutomationPanel listing one trigger\n when: user clicks the trigger row\n then:\n - TriggerEditor opens pre-populated with that trigger's values\n - selected state holds the original trigger\n - saving calls Obj.update on the original trigger\n```\n\n```mdl\ntest T-4: Enable/disable toggle\n given: AutomationPanel showing trigger with enabled = false\n when: user flips the toggle\n then:\n - Obj.update sets trigger.enabled = true\n - toggle reflects new state immediately\n```\n\n```mdl\ntest T-5: Force run timer trigger (local)\n given: timer trigger enabled, computeEnvironment = \"local\"\n when: user clicks the force-run button\n then:\n - TriggerDispatcher.invokeTrigger called with a TimerEvent\n - no error surfaced to user\n```\n\n```mdl\ntest T-6: Dispatcher lifecycle on environment change\n given: space computeEnvironment = \"local\", dispatcher running\n when: space.properties.computeEnvironment changes to \"edge\"\n then:\n - in-flight transition fiber interrupted\n - TriggerDispatcher.stop() called for that space\n```\n\n```mdl\ntest T-7: CreateTriggerFromTemplate with timer\n given: db contains Script \"daily-summary\", computeEnvironment = \"local\"\n when: op:CreateTriggerFromTemplate invoked with template={type:\"timer\",cron:\"0 8 * * *\"}, scriptName=\"daily-summary\"\n then:\n - Trigger created with spec.kind === \"timer\", spec.cron === \"0 8 * * *\"\n - Trigger.function wired to PersistentOperation linked to \"daily-summary\" script\n - Trigger added as hidden ECHO object\n - layout navigates to automations settings panel\n```\n\n```mdl\ntest T-8: CreateTriggerFromTemplate with feed\n given: db contains a Feed object \"email-feed\"\n when: op:CreateTriggerFromTemplate invoked with template={type:\"feed\",feed:<email-feed>}\n then:\n - Trigger created with spec.kind === \"feed\", spec.feed === Ref to email-feed\n - Trigger added as hidden ECHO object\n```\n\n---\n\n## Appendix: Extension Definitions\n\nExtension block types used in this document are defined below using\nthe core `ext` primitive \u2014 the only construct the base language provides.\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap # name[?]: TypeExpr (# inline comment)\n literals?: UnionList # a | b | c\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self # feat blocks may contain feat blocks\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap # external inputs (immutable inside component)\n state?: FieldMap # internal reactive state\n slots?: FieldMap # named ReactNode injection points\n actions?: ActionMap # methods the component exposes or handles\n emits?: EventMap # events the component raises to its parent\n layout?: CodeBlock # ASCII sketch of visual structure (non-normative)\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap # named input parameters\n output?: TypeExpr # return type\n errors?: ErrorMap # name: Prose (when this error occurs)\n effects?: EffectList # echo:read | echo:write | http | fs | ...\n requires?: ServiceList # injected service dependencies\n note?: Prose # implementation guidance (non-normative)\n```\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,iBAAiBC,kBAAkBC,cAAc;AAC1D,SAASC,WAAWC,2BAA2B;AAC/C,SAASC,WAAWC,OAAOC,eAAe;AAC1C,SAASC,oBAAoB;AAE7B,SACEC,iBACAC,cACAC,YACAC,oBACAC,kBACAC,cACAC,cACAC,WACAC,gCACK;AACP,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,kBAAkB;;;ACtB3B;;;AD2BO,IAAMC,mBAAmBC,OAAOC,OAAOC,IAAAA,EAAMC,KAClDC,UAAUC,kBAAkB;EAAEC,UAAUC;AAAgB,CAAA,GACxDH,UAAUI,0BAA0B;EAAEF,UAAUG;AAAiB,CAAA,GACjEL,UAAUM,gBAAgB;EACxBC,QAAQ;IAACC,WAAWA;IAAYC,UAAUC;IAAqBC,QAAQA;IAASC,MAAMC;;AACxF,CAAA,GACAb,UAAUc,sBAAsB;EAAEZ,UAAUa;AAAa,CAAA,GACzDf,UAAUgB,4BAA4B;EAAEd,UAAUe;AAAmB,CAAA,GACrErB,OAAOsB,UAAU;EAAEC,IAAI;EAAwBC,aAAaC,oBAAoBC;EAAapB,UAAUqB;AAAU,CAAA,GACjHvB,UAAUwB,iBAAiB;EAAEtB,UAAUuB;AAAa,CAAA,GACpDzB,UAAU0B,sBAAsB;EAAEC;AAAa,CAAA,GAC/C/B,OAAOsB,UAAU;EACfE,aAAaQ,aAAaC;EAC1BC,uBAAuB;IAACC,iBAAiBC;;EACzC9B,UAAU+B;AACZ,CAAA,GACArC,OAAOsB,UAAU;EACfE,aAAaQ,aAAaC;EAC1B3B,UAAUgC;AACZ,CAAA,GACAtC,OAAOsB,UAAU;EACfE,aAAae,gBAAgBC,MAAML,iBAAiBM,qBAAqBT,aAAaU,WAAW;EACjGpC,UAAUqC;AACZ,CAAA,GACAvC,UAAUwC,qBAAqB;EAC7BC,OAAO;IAAEC,UAAU5C,KAAKqB;IAAIwB,MAAM;IAAcC,SAASC;IAAYC,UAAU;EAAoB;AACrG,CAAA,GACAlD,OAAOmD,IAAI;AAGb,IAAA,2BAAepD;",
|
|
6
|
-
"names": ["ActivationEvent", "ActivationEvents", "Plugin", "AppPlugin", "AppActivationEvents", "Operation", "Trace", "Trigger", "ClientEvents", "AppGraphBuilder", "CreateObject", "LayerSpecs", "NavigationResolver", "OperationHandler", "ReactSurface", "RegistrySync", "Templates", "TriggerRuntimeController", "meta", "translations", "Automation", "AutomationPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addAppGraphModule", "activate", "AppGraphBuilder", "addOperationHandlerModule", "OperationHandler", "addSchemaModule", "schema", "Automation", "Operation", "PersistentOperation", "Trigger", "Trace", "Message", "addCreateObjectModule", "CreateObject", "addNavigationResolverModule", "NavigationResolver", "addModule", "id", "activatesOn", "AppActivationEvents", "SetupSchema", "Templates", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations", "ClientEvents", "ClientReady", "firesBeforeActivation", "ActivationEvents", "SetupProcessManager", "LayerSpecs", "RegistrySync", "ActivationEvent", "allOf", "ProcessManagerReady", "SpacesReady", "TriggerRuntimeController", "addPluginAssetModule", "asset", "pluginId", "path", "content", "pluginSpec", "mimeType", "make"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/create-automation.ts", "../../../src/paths.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Operation } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceOperation } from '@dxos/plugin-space';\n\nimport { getAutomationsPath } from '../paths';\nimport { AutomationCapabilities, AutomationOperation } from '../types';\n\nconst handler: Operation.WithHandler<typeof AutomationOperation.CreateAutomation> =\n AutomationOperation.CreateAutomation.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ db, templateId, name, subject }) {\n const templates = yield* Capability.getAll(AutomationCapabilities.Template);\n const template = templates.find((entry) => entry.id === templateId);\n invariant(template, `Unknown automation template: ${templateId}`);\n\n const object = yield* template\n .scaffold({ name, subject })\n .pipe(Effect.provideService(Database.Service, Database.makeService(db)));\n\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: db,\n hidden: true,\n targetNodeId: getAutomationsPath(db.spaceId),\n });\n }),\n ),\n );\n\nexport default handler;\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { createTypeSectionPaths } from '@dxos/app-toolkit';\n\nimport { Automation } from '#types';\n\nconst { getSectionPath: getAutomationsPath, getObjectPath: getAutomationPath } = createTypeSectionPaths(\n Automation.Automation,\n);\n\nexport { getAutomationsPath, getAutomationPath };\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;;;ACN/B,SAASC,8BAA8B;AAEvC,SAASC,kBAAkB;AAE3B,IAAM,EAAEC,gBAAgBC,oBAAoBC,eAAeC,kBAAiB,IAAKL,uBAC/EC,WAAWA,UAAU;;;ADMvB,IAAA,eACEK;IAIM,UAAMC,4BAA0B,iBAAmB,KAAKC,UAAAA,YAAAA,kBAAAA,WAAAA,EAAAA,IAAAA,YAAAA,MAAAA,QAAAA,GAAAA;AACxDC,QAAAA,YAAUF,OAAW,WAAA,OAAA,+BAA2C,QAAA;AAEhE,QAAMG,WAAS,UAAOH,KACnBI,CAAAA,UAAS,MAAA,OAAA,UAAA;YAAEC,UAAAA,gCAAAA,UAAAA,IAAAA,EAAAA,YAAAA,YAAAA,GAAAA,cAAAA,GAAAA,IAAAA,GAAAA,MAAAA,GAAAA,CAAAA,YAAAA,8CAAAA,EAAAA,CAAAA;QAAMC,SAAAA,OAAAA,SAAAA,SAAAA;IACjBC;IAEH;UACEJ,sBAAAA,SAAAA,SAAAA,SAAAA,YAAAA,EAAAA,CAAAA,CAAAA;SACAK,OAAQC,UAAAA,OAAAA,eAAAA,WAAAA;IACRC;IACAC,QAAAA;IACF,QAAA;IACF,cAAA,mBAAA,GAAA,OAAA;EAIN,CAAA;;;",
|
|
6
|
-
"names": ["Effect", "Capability", "Operation", "Database", "invariant", "SpaceOperation", "createTypeSectionPaths", "Automation", "getSectionPath", "getAutomationsPath", "getObjectPath", "getAutomationPath", "AutomationOperation", "template", "templateId", "invariant", "object", "scaffold", "name", "subject", "pipe", "target", "db", "hidden", "targetNodeId"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/create-trigger-from-template.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { LayoutOperation, getSpacePath } from '@dxos/app-toolkit';\nimport { Operation, Script, Trigger } from '@dxos/compute';\nimport { type Feed, Filter, Obj, Ref } from '@dxos/echo';\nimport { SpaceOperation } from '@dxos/plugin-space';\n\nimport { meta } from '#meta';\n\nimport { AutomationOperation } from '../types';\n\nconst handler: Operation.WithHandler<typeof AutomationOperation.CreateTriggerFromTemplate> =\n AutomationOperation.CreateTriggerFromTemplate.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ db, template, enabled = false, scriptName, input }) {\n const trigger = Trigger.make({ enabled, input });\n\n // TODO(wittjosiah): Factor out function lookup by script name?\n if (scriptName) {\n const scripts = yield* Effect.promise(() => db.query(Filter.type(Script.Script, { name: scriptName })).run());\n const [script] = scripts;\n if (script) {\n const functions = yield* Effect.promise(() =>\n db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(script) })).run(),\n );\n const [fn] = functions;\n if (fn) {\n Obj.update(trigger, (trigger) => {\n trigger.function = Ref.make(fn);\n });\n }\n }\n }\n\n switch (template.type) {\n case 'timer': {\n Obj.update(trigger, (trigger) => {\n trigger.spec = Trigger.specTimer(template.cron);\n });\n break;\n }\n case 'feed': {\n Obj.update(trigger, (trigger) => {\n trigger.spec = Trigger.specFeed(template.feed as Feed.Feed);\n });\n break;\n }\n default: {\n break;\n }\n }\n\n yield* Operation.invoke(SpaceOperation.AddObject, {\n object: trigger,\n target: db,\n hidden: true,\n });\n yield* Operation.invoke(LayoutOperation.Open, {\n subject: [`${getSpacePath(db.spaceId)}/settings/${meta.id}.automations`],\n workspace: getSpacePath(db.spaceId),\n });\n }),\n ),\n );\n\nexport default handler;\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiBC,oBAAoB;AAC9C,SAASC,WAAWC,QAAQC,eAAe;AAC3C,SAAoBC,QAAQC,KAAKC,WAAW;AAC5C,SAASC,sBAAsB;AAE/B,SAASC,YAAY;AAIrB,IAAMC,UACJC,4BAAoBC,0BAA0BC,KAC5CC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,IAAIC,UAAUC,UAAU,OAAOC,YAAYC,MAAK,GAAE;AAC/E,QAAMC,UAAUC,QAAQC,KAAK;IAAEL;IAASE;EAAM,CAAA;AAG9C,MAAID,YAAY;AACd,UAAMK,UAAU,OAAcC,eAAQ,MAAMT,GAAGU,MAAMC,OAAOC,KAAKC,OAAOA,QAAQ;MAAEC,MAAMX;IAAW,CAAA,CAAA,EAAIY,IAAG,CAAA;AAC1G,UAAM,CAACC,MAAAA,IAAUR;AACjB,QAAIQ,QAAQ;AACV,YAAMC,YAAY,OAAcR,eAAQ,MACtCT,GAAGU,MAAMC,OAAOC,KAAKf,UAAUqB,qBAAqB;QAAEC,QAAQC,IAAIb,KAAKS,MAAAA;MAAQ,CAAA,CAAA,EAAID,IAAG,CAAA;AAExF,YAAM,CAACM,EAAAA,IAAMJ;AACb,UAAII,IAAI;AACNC,YAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,UAAAA,SAAQmB,WAAWJ,IAAIb,KAAKc,EAAAA;QAC9B,CAAA;MACF;IACF;EACF;AAEA,UAAQpB,SAASW,MAAI;IACnB,KAAK,SAAS;AACZU,UAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,QAAAA,SAAQoB,OAAOnB,QAAQoB,UAAUzB,SAAS0B,IAAI;MAChD,CAAA;AACA;IACF;IACA,KAAK,QAAQ;AACXL,UAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,QAAAA,SAAQoB,OAAOnB,QAAQsB,SAAS3B,SAAS4B,IAAI;MAC/C,CAAA;AACA;IACF;IACA,SAAS;AACP;IACF;EACF;AAEA,SAAOhC,UAAUiC,OAAOC,eAAeC,WAAW;IAChDC,QAAQ5B;IACR6B,QAAQlC;IACRmC,QAAQ;EACV,CAAA;AACA,SAAOtC,UAAUiC,OAAOM,gBAAgBC,MAAM;IAC5CC,SAAS;MAAC,GAAGC,aAAavC,GAAGwC,OAAO,CAAA,aAAcC,KAAKC,EAAE;;IACzDC,WAAWJ,aAAavC,GAAGwC,OAAO;EACpC,CAAA;AACF,CAAA,CAAA,CAAA;AAIN,IAAA,uCAAe/C;",
|
|
6
|
-
"names": ["Effect", "LayoutOperation", "getSpacePath", "Operation", "Script", "Trigger", "Filter", "Obj", "Ref", "SpaceOperation", "meta", "handler", "AutomationOperation", "CreateTriggerFromTemplate", "pipe", "Operation", "withHandler", "fnUntraced", "db", "template", "enabled", "scriptName", "input", "trigger", "Trigger", "make", "scripts", "promise", "query", "Filter", "type", "Script", "name", "run", "script", "functions", "PersistentOperation", "source", "Ref", "fn", "Obj", "update", "function", "spec", "specTimer", "cron", "specFeed", "feed", "invoke", "SpaceOperation", "AddObject", "object", "target", "hidden", "LayoutOperation", "Open", "subject", "getSpacePath", "spaceId", "meta", "id", "workspace"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/navigation-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities, createTypeSectionPathResolver } from '@dxos/app-toolkit';\n\nimport { Automation } from '#types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n return Capability.contributes(\n AppCapabilities.NavigationPathResolver,\n createTypeSectionPathResolver(Automation.Automation),\n );\n }),\n);\n"],
|
|
5
|
-
"mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiBC,qCAAqC;AAE/D,SAASC,kBAAkB;AAE3B,IAAA,8BAAeH,WAAWI,WACjBC,kBAAW,aAAA;AAChB,SAAOL,WAAWM,YAChBL,gBAAgBM,wBAChBL,8BAA8BC,WAAWA,UAAU,CAAA;AAEvD,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "Capability", "AppCapabilities", "createTypeSectionPathResolver", "Automation", "makeModule", "fnUntraced", "contributes", "NavigationPathResolver"]
|
|
7
|
-
}
|
/package/dist/lib/neutral/{AutomationArticle-GN36NUX2.mjs.map → AutomationArticle-CG4ZML3C.mjs.map}
RENAMED
|
File without changes
|
/package/dist/lib/neutral/{TriggerSettings-XCHIZPOR.mjs.map → TriggerSettings-ABOTKRUA.mjs.map}
RENAMED
|
File without changes
|
|
File without changes
|