devglide 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +338 -0
- package/bin/claude-md-template.js +94 -0
- package/bin/devglide.js +387 -0
- package/package.json +85 -0
- package/pnpm-workspace.yaml +3 -0
- package/src/apps/coder/.turbo/turbo-lint.log +5 -0
- package/src/apps/coder/package.json +16 -0
- package/src/apps/coder/public/favicon.svg +7 -0
- package/src/apps/coder/public/page.css +275 -0
- package/src/apps/coder/public/page.js +528 -0
- package/src/apps/coder/server.js +3 -0
- package/src/apps/documentation/public/page.css +597 -0
- package/src/apps/documentation/public/page.js +609 -0
- package/src/apps/kanban/.turbo/turbo-lint.log +97 -0
- package/src/apps/kanban/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/kanban/package.json +32 -0
- package/src/apps/kanban/public/favicon.svg +7 -0
- package/src/apps/kanban/public/page.css +1010 -0
- package/src/apps/kanban/public/page.js +1730 -0
- package/src/apps/kanban/public/vendor/marked.min.js +6 -0
- package/src/apps/kanban/public/vendor/sortable.min.js +2 -0
- package/src/apps/kanban/src/db.ts +319 -0
- package/src/apps/kanban/src/index.ts +14 -0
- package/src/apps/kanban/src/mcp-helpers.test.ts +88 -0
- package/src/apps/kanban/src/mcp-helpers.ts +60 -0
- package/src/apps/kanban/src/mcp.ts +59 -0
- package/src/apps/kanban/src/routes/attachments.ts +161 -0
- package/src/apps/kanban/src/routes/features.ts +233 -0
- package/src/apps/kanban/src/routes/issues.ts +373 -0
- package/src/apps/kanban/src/tools/feature-tools.ts +164 -0
- package/src/apps/kanban/src/tools/item-tools.ts +307 -0
- package/src/apps/kanban/src/tools/versioned-entry-tools.ts +72 -0
- package/src/apps/kanban/tsconfig.check.json +9 -0
- package/src/apps/kanban/tsconfig.json +9 -0
- package/src/apps/keymap/.turbo/turbo-lint.log +5 -0
- package/src/apps/keymap/package.json +16 -0
- package/src/apps/keymap/public/page.css +275 -0
- package/src/apps/keymap/public/page.js +294 -0
- package/src/apps/keymap/server.js +25 -0
- package/src/apps/log/.turbo/turbo-build.log +5 -0
- package/src/apps/log/.turbo/turbo-lint.log +45 -0
- package/src/apps/log/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/log/node_modules/.bin/tsc +21 -0
- package/src/apps/log/node_modules/.bin/tsserver +21 -0
- package/src/apps/log/node_modules/.bin/tsx +21 -0
- package/src/apps/log/package.json +36 -0
- package/src/apps/log/public/console-sniffer.js +221 -0
- package/src/apps/log/public/favicon.svg +7 -0
- package/src/apps/log/public/page.css +322 -0
- package/src/apps/log/public/page.js +463 -0
- package/src/apps/log/src/index.ts +9 -0
- package/src/apps/log/src/mcp.ts +122 -0
- package/src/apps/log/src/routes/log.ts +333 -0
- package/src/apps/log/src/routes/status.ts +25 -0
- package/src/apps/log/src/server-sniffer.ts +118 -0
- package/src/apps/log/src/services/file-patterns.ts +39 -0
- package/src/apps/log/src/services/file-tailer.ts +228 -0
- package/src/apps/log/src/services/line-parser.ts +94 -0
- package/src/apps/log/src/services/log-writer.ts +39 -0
- package/src/apps/log/tsconfig.json +8 -0
- package/src/apps/prompts/.turbo/turbo-build.log +5 -0
- package/src/apps/prompts/.turbo/turbo-lint.log +24 -0
- package/src/apps/prompts/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/prompts/mcp.ts +175 -0
- package/src/apps/prompts/node_modules/.bin/tsc +21 -0
- package/src/apps/prompts/node_modules/.bin/tsserver +21 -0
- package/src/apps/prompts/node_modules/.bin/tsx +21 -0
- package/src/apps/prompts/package.json +25 -0
- package/src/apps/prompts/public/page.css +315 -0
- package/src/apps/prompts/public/page.js +541 -0
- package/src/apps/prompts/services/prompt-store.ts +212 -0
- package/src/apps/prompts/src/index.ts +9 -0
- package/src/apps/prompts/tsconfig.json +8 -0
- package/src/apps/prompts/types.ts +27 -0
- package/src/apps/shell/.turbo/turbo-build.log +5 -0
- package/src/apps/shell/.turbo/turbo-lint.log +34 -0
- package/src/apps/shell/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/shell/package.json +35 -0
- package/src/apps/shell/public/favicon.svg +7 -0
- package/src/apps/shell/public/page.css +407 -0
- package/src/apps/shell/public/page.js +1577 -0
- package/src/apps/shell/src/index.ts +150 -0
- package/src/apps/shell/src/mcp.ts +398 -0
- package/src/apps/shell/src/shell-types.ts +41 -0
- package/src/apps/shell/tsconfig.json +8 -0
- package/src/apps/test/.turbo/turbo-build.log +5 -0
- package/src/apps/test/.turbo/turbo-lint.log +27 -0
- package/src/apps/test/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/test/node_modules/.bin/tsc +21 -0
- package/src/apps/test/node_modules/.bin/tsserver +21 -0
- package/src/apps/test/node_modules/.bin/tsx +21 -0
- package/src/apps/test/node_modules/.bin/uuid +21 -0
- package/src/apps/test/package.json +35 -0
- package/src/apps/test/public/favicon.svg +7 -0
- package/src/apps/test/public/page.css +499 -0
- package/src/apps/test/public/page.js +417 -0
- package/src/apps/test/public/scenario-runner.js +450 -0
- package/src/apps/test/src/index.ts +9 -0
- package/src/apps/test/src/mcp.ts +192 -0
- package/src/apps/test/src/routes/trigger.ts +285 -0
- package/src/apps/test/src/services/scenario-broadcaster.ts +60 -0
- package/src/apps/test/src/services/scenario-manager.ts +361 -0
- package/src/apps/test/src/services/scenario-store.ts +145 -0
- package/src/apps/test/tsconfig.json +8 -0
- package/src/apps/vocabulary/.turbo/turbo-build.log +5 -0
- package/src/apps/vocabulary/.turbo/turbo-lint.log +25 -0
- package/src/apps/vocabulary/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/vocabulary/mcp.ts +173 -0
- package/src/apps/vocabulary/node_modules/.bin/tsc +21 -0
- package/src/apps/vocabulary/node_modules/.bin/tsserver +21 -0
- package/src/apps/vocabulary/node_modules/.bin/tsx +21 -0
- package/src/apps/vocabulary/package.json +25 -0
- package/src/apps/vocabulary/public/page.css +247 -0
- package/src/apps/vocabulary/public/page.js +444 -0
- package/src/apps/vocabulary/services/vocabulary-store.ts +179 -0
- package/src/apps/vocabulary/src/index.ts +10 -0
- package/src/apps/vocabulary/tsconfig.json +8 -0
- package/src/apps/vocabulary/types.ts +22 -0
- package/src/apps/voice/.turbo/turbo-build.log +5 -0
- package/src/apps/voice/.turbo/turbo-lint.log +43 -0
- package/src/apps/voice/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/voice/node_modules/.bin/openai +21 -0
- package/src/apps/voice/node_modules/.bin/tsc +21 -0
- package/src/apps/voice/node_modules/.bin/tsserver +21 -0
- package/src/apps/voice/node_modules/.bin/tsx +21 -0
- package/src/apps/voice/package.json +35 -0
- package/src/apps/voice/public/favicon.svg +7 -0
- package/src/apps/voice/public/page.css +388 -0
- package/src/apps/voice/public/page.js +718 -0
- package/src/apps/voice/src/index.ts +10 -0
- package/src/apps/voice/src/mcp.ts +70 -0
- package/src/apps/voice/src/providers/index.ts +85 -0
- package/src/apps/voice/src/providers/openai-compatible.ts +94 -0
- package/src/apps/voice/src/providers/types.ts +27 -0
- package/src/apps/voice/src/routes/config.ts +118 -0
- package/src/apps/voice/src/routes/transcribe.ts +90 -0
- package/src/apps/voice/src/services/config-store.ts +129 -0
- package/src/apps/voice/src/services/stats.ts +108 -0
- package/src/apps/voice/src/transcribe.ts +11 -0
- package/src/apps/voice/src/utils/mime.ts +16 -0
- package/src/apps/voice/tsconfig.json +8 -0
- package/src/apps/workflow/.turbo/turbo-build.log +5 -0
- package/src/apps/workflow/.turbo/turbo-lint.log +96 -0
- package/src/apps/workflow/.turbo/turbo-typecheck.log +5 -0
- package/src/apps/workflow/engine/executors/decision-executor.ts +87 -0
- package/src/apps/workflow/engine/executors/file-executor.ts +90 -0
- package/src/apps/workflow/engine/executors/git-executor.ts +137 -0
- package/src/apps/workflow/engine/executors/http-executor.ts +65 -0
- package/src/apps/workflow/engine/executors/index.ts +28 -0
- package/src/apps/workflow/engine/executors/kanban-executor.ts +154 -0
- package/src/apps/workflow/engine/executors/llm-executor.ts +46 -0
- package/src/apps/workflow/engine/executors/log-executor.ts +62 -0
- package/src/apps/workflow/engine/executors/loop-executor.ts +14 -0
- package/src/apps/workflow/engine/executors/shell-executor.ts +107 -0
- package/src/apps/workflow/engine/executors/sub-workflow-executor.ts +61 -0
- package/src/apps/workflow/engine/executors/test-executor.ts +73 -0
- package/src/apps/workflow/engine/executors/trigger-executor.ts +39 -0
- package/src/apps/workflow/engine/expression-evaluator.ts +117 -0
- package/src/apps/workflow/engine/graph-runner.ts +438 -0
- package/src/apps/workflow/engine/node-executor.ts +104 -0
- package/src/apps/workflow/engine/node-registry.ts +15 -0
- package/src/apps/workflow/engine/variable-resolver.ts +109 -0
- package/src/apps/workflow/mcp.ts +223 -0
- package/src/apps/workflow/node_modules/.bin/tsc +21 -0
- package/src/apps/workflow/node_modules/.bin/tsserver +21 -0
- package/src/apps/workflow/node_modules/.bin/tsx +21 -0
- package/src/apps/workflow/package.json +25 -0
- package/src/apps/workflow/public/editor/canvas.js +366 -0
- package/src/apps/workflow/public/editor/drag-manager.js +326 -0
- package/src/apps/workflow/public/editor/edge-renderer.js +235 -0
- package/src/apps/workflow/public/editor/history-manager.js +147 -0
- package/src/apps/workflow/public/editor/layout-engine.js +159 -0
- package/src/apps/workflow/public/editor/node-renderer.js +199 -0
- package/src/apps/workflow/public/editor/selection-manager.js +193 -0
- package/src/apps/workflow/public/favicon.svg +7 -0
- package/src/apps/workflow/public/models/node-types.js +300 -0
- package/src/apps/workflow/public/models/workflow-model.js +257 -0
- package/src/apps/workflow/public/page.css +406 -0
- package/src/apps/workflow/public/page.js +658 -0
- package/src/apps/workflow/public/panels/inspector.js +360 -0
- package/src/apps/workflow/public/panels/palette.js +106 -0
- package/src/apps/workflow/public/panels/run-view.js +275 -0
- package/src/apps/workflow/public/panels/toolbar.js +232 -0
- package/src/apps/workflow/public/panels/workflow-list.js +237 -0
- package/src/apps/workflow/public/state/store.js +47 -0
- package/src/apps/workflow/services/custom-node-loader.ts +48 -0
- package/src/apps/workflow/services/legacy-converter.ts +72 -0
- package/src/apps/workflow/services/run-manager.ts +190 -0
- package/src/apps/workflow/services/workflow-store.ts +424 -0
- package/src/apps/workflow/services/workflow-validator.test.ts +103 -0
- package/src/apps/workflow/services/workflow-validator.ts +98 -0
- package/src/apps/workflow/src/index.ts +10 -0
- package/src/apps/workflow/templates/ci-pipeline.json +18 -0
- package/src/apps/workflow/templates/code-review.json +22 -0
- package/src/apps/workflow/templates/kanban-testing.json +24 -0
- package/src/apps/workflow/tsconfig.json +8 -0
- package/src/apps/workflow/types.ts +268 -0
- package/src/packages/auth-middleware.ts +14 -0
- package/src/packages/design-tokens/.turbo/turbo-build.log +10 -0
- package/src/packages/design-tokens/STYLEGUIDE.md +414 -0
- package/src/packages/design-tokens/build.js +413 -0
- package/src/packages/design-tokens/demo/index.html +1367 -0
- package/src/packages/design-tokens/demo/proposition-a.html +717 -0
- package/src/packages/design-tokens/demo/proposition-b.html +1239 -0
- package/src/packages/design-tokens/demo/proposition-c.html +1049 -0
- package/src/packages/design-tokens/dist/tailwind-preset.js +115 -0
- package/src/packages/design-tokens/dist/tokens.css +345 -0
- package/src/packages/design-tokens/dist/tokens.d.ts +229 -0
- package/src/packages/design-tokens/dist/tokens.js +386 -0
- package/src/packages/design-tokens/package.json +25 -0
- package/src/packages/design-tokens/tokens.json +228 -0
- package/src/packages/devtools-middleware.ts +22 -0
- package/src/packages/eslint-config/index.js +63 -0
- package/src/packages/eslint-config/node_modules/.bin/eslint +21 -0
- package/src/packages/eslint-config/package.json +18 -0
- package/src/packages/json-file-store.ts +232 -0
- package/src/packages/mcp-utils/.turbo/turbo-build.log +5 -0
- package/src/packages/mcp-utils/dist/index.d.ts +33 -0
- package/src/packages/mcp-utils/dist/index.d.ts.map +1 -0
- package/src/packages/mcp-utils/dist/index.js +126 -0
- package/src/packages/mcp-utils/dist/index.js.map +1 -0
- package/src/packages/mcp-utils/node_modules/.bin/tsc +21 -0
- package/src/packages/mcp-utils/node_modules/.bin/tsserver +21 -0
- package/src/packages/mcp-utils/package.json +32 -0
- package/src/packages/mcp-utils/src/index.ts +171 -0
- package/src/packages/mcp-utils/tsconfig.json +9 -0
- package/src/packages/paths.ts +18 -0
- package/src/packages/project-context/index.js +55 -0
- package/src/packages/project-context/package.json +13 -0
- package/src/packages/project-store.ts +127 -0
- package/src/packages/server-sniffer.ts +132 -0
- package/src/packages/shared-assets/favicon.svg +7 -0
- package/src/packages/shared-assets/keymap-registry.js +512 -0
- package/src/packages/shared-assets/logo.svg +6 -0
- package/src/packages/shared-assets/package.json +11 -0
- package/src/packages/shared-assets/ui-utils.js +48 -0
- package/src/packages/shared-assets/voice-widget.d.ts +37 -0
- package/src/packages/shared-assets/voice-widget.js +695 -0
- package/src/packages/shared-types/.turbo/turbo-build.log +5 -0
- package/src/packages/shared-types/dist/index.d.ts +39 -0
- package/src/packages/shared-types/dist/index.d.ts.map +1 -0
- package/src/packages/shared-types/node_modules/.bin/tsc +21 -0
- package/src/packages/shared-types/node_modules/.bin/tsserver +21 -0
- package/src/packages/shared-types/package.json +25 -0
- package/src/packages/shared-types/src/index.ts +41 -0
- package/src/packages/shared-types/tsconfig.json +11 -0
- package/src/packages/tsconfig/base.json +15 -0
- package/src/packages/tsconfig/next.json +14 -0
- package/src/packages/tsconfig/node.json +11 -0
- package/src/packages/tsconfig/package.json +10 -0
- package/turbo.json +25 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// ── Workflow Editor — Node Type Registry ────────────────────────────────
|
|
2
|
+
// Defines all 12 node types with config fields, icons, colors, and defaults.
|
|
3
|
+
// Config field schemas mirror the TypeScript interfaces in types.ts.
|
|
4
|
+
|
|
5
|
+
export const NODE_CATEGORIES = [
|
|
6
|
+
{ id: 'triggers', label: 'Triggers', color: '#f59e0b' },
|
|
7
|
+
{ id: 'actions', label: 'Actions', color: '#6366f1' },
|
|
8
|
+
{ id: 'control', label: 'Control Flow', color: '#ec4899' },
|
|
9
|
+
{ id: 'steps', label: 'Steps', color: '#64748b' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const NODE_TYPES = {
|
|
13
|
+
// ── Triggers ────────────────────────────────────────────────────────────
|
|
14
|
+
'trigger': {
|
|
15
|
+
label: 'Trigger',
|
|
16
|
+
category: 'triggers',
|
|
17
|
+
icon: '\u26A1',
|
|
18
|
+
color: '#f59e0b',
|
|
19
|
+
ports: { in: 0, out: 1 },
|
|
20
|
+
configFields: [
|
|
21
|
+
{ key: 'triggerType', label: 'Trigger Type', type: 'select',
|
|
22
|
+
options: ['manual', 'prompt', 'voice', 'webhook', 'schedule', 'git-event', 'log-pattern', 'kanban-move'] },
|
|
23
|
+
{ key: 'cron', label: 'Cron Expression', type: 'text',
|
|
24
|
+
showWhen: { triggerType: 'schedule' } },
|
|
25
|
+
{ key: 'gitEvent', label: 'Git Event', type: 'select',
|
|
26
|
+
options: ['commit', 'push', 'branch-create', 'tag'],
|
|
27
|
+
showWhen: { triggerType: 'git-event' } },
|
|
28
|
+
{ key: 'gitBranch', label: 'Branch Filter', type: 'text',
|
|
29
|
+
showWhen: { triggerType: 'git-event' } },
|
|
30
|
+
{ key: 'logPattern', label: 'Log Pattern (regex)', type: 'text',
|
|
31
|
+
showWhen: { triggerType: 'log-pattern' } },
|
|
32
|
+
{ key: 'kanbanTargetColumn', label: 'Target Column', type: 'text',
|
|
33
|
+
showWhen: { triggerType: 'kanban-move' } },
|
|
34
|
+
],
|
|
35
|
+
defaultConfig: { nodeType: 'trigger', triggerType: 'manual' },
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// ── Actions ─────────────────────────────────────────────────────────────
|
|
39
|
+
'action:shell': {
|
|
40
|
+
label: 'Shell',
|
|
41
|
+
category: 'actions',
|
|
42
|
+
icon: '\u{1F4BB}',
|
|
43
|
+
color: '#22c55e',
|
|
44
|
+
ports: { in: 1, out: 1 },
|
|
45
|
+
configFields: [
|
|
46
|
+
{ key: 'command', label: 'Command', type: 'textarea' },
|
|
47
|
+
{ key: 'cwd', label: 'Working Directory', type: 'text' },
|
|
48
|
+
{ key: 'captureOutput', label: 'Capture Output', type: 'checkbox' },
|
|
49
|
+
{ key: 'outputVariable', label: 'Output Variable', type: 'text' },
|
|
50
|
+
],
|
|
51
|
+
defaultConfig: { nodeType: 'action:shell', command: '', captureOutput: true },
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
'action:kanban': {
|
|
55
|
+
label: 'Kanban',
|
|
56
|
+
category: 'actions',
|
|
57
|
+
icon: '\u{1F4CB}',
|
|
58
|
+
color: '#3b82f6',
|
|
59
|
+
ports: { in: 1, out: 1 },
|
|
60
|
+
configFields: [
|
|
61
|
+
{ key: 'operation', label: 'Operation', type: 'select',
|
|
62
|
+
options: ['create', 'move', 'update', 'append-work-log', 'append-review', 'list'] },
|
|
63
|
+
{ key: 'featureId', label: 'Feature ID', type: 'text' },
|
|
64
|
+
{ key: 'itemId', label: 'Item ID', type: 'text' },
|
|
65
|
+
{ key: 'columnName', label: 'Column Name', type: 'text',
|
|
66
|
+
showWhen: { operation: 'move' } },
|
|
67
|
+
{ key: 'title', label: 'Title', type: 'text',
|
|
68
|
+
showWhen: { operation: 'create' } },
|
|
69
|
+
{ key: 'description', label: 'Description', type: 'textarea',
|
|
70
|
+
showWhen: { operation: 'create' } },
|
|
71
|
+
{ key: 'content', label: 'Content', type: 'textarea' },
|
|
72
|
+
],
|
|
73
|
+
defaultConfig: { nodeType: 'action:kanban', operation: 'create' },
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
'action:git': {
|
|
77
|
+
label: 'Git',
|
|
78
|
+
category: 'actions',
|
|
79
|
+
icon: '\u{1F500}',
|
|
80
|
+
color: '#f97316',
|
|
81
|
+
ports: { in: 1, out: 1 },
|
|
82
|
+
configFields: [
|
|
83
|
+
{ key: 'operation', label: 'Operation', type: 'select',
|
|
84
|
+
options: ['status', 'diff', 'commit', 'push', 'branch-create', 'checkout', 'add'] },
|
|
85
|
+
{ key: 'message', label: 'Commit Message', type: 'text',
|
|
86
|
+
showWhen: { operation: 'commit' } },
|
|
87
|
+
{ key: 'branch', label: 'Branch', type: 'text' },
|
|
88
|
+
{ key: 'files', label: 'Files (one per line)', type: 'textarea' },
|
|
89
|
+
],
|
|
90
|
+
defaultConfig: { nodeType: 'action:git', operation: 'status' },
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
'action:llm': {
|
|
94
|
+
label: 'LLM',
|
|
95
|
+
category: 'actions',
|
|
96
|
+
icon: '\u{1F9E0}',
|
|
97
|
+
color: '#8b5cf6',
|
|
98
|
+
ports: { in: 1, out: 1 },
|
|
99
|
+
configFields: [
|
|
100
|
+
{ key: 'promptSource', label: 'Prompt Source', type: 'select',
|
|
101
|
+
options: ['inline', 'file'] },
|
|
102
|
+
{ key: 'prompt', label: 'Prompt', type: 'textarea',
|
|
103
|
+
showWhen: { promptSource: 'inline' } },
|
|
104
|
+
{ key: 'promptFile', label: 'Prompt File', type: 'text',
|
|
105
|
+
showWhen: { promptSource: 'file' } },
|
|
106
|
+
{ key: 'model', label: 'Model', type: 'text' },
|
|
107
|
+
{ key: 'temperature', label: 'Temperature', type: 'number' },
|
|
108
|
+
{ key: 'maxTokens', label: 'Max Tokens', type: 'number' },
|
|
109
|
+
],
|
|
110
|
+
defaultConfig: { nodeType: 'action:llm', promptSource: 'inline', prompt: '' },
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
'action:test': {
|
|
114
|
+
label: 'Test',
|
|
115
|
+
category: 'actions',
|
|
116
|
+
icon: '\u{1F9EA}',
|
|
117
|
+
color: '#06b6d4',
|
|
118
|
+
ports: { in: 1, out: 1 },
|
|
119
|
+
configFields: [
|
|
120
|
+
{ key: 'operation', label: 'Operation', type: 'select',
|
|
121
|
+
options: ['run-scenario', 'run-saved', 'save-scenario', 'list-saved'] },
|
|
122
|
+
{ key: 'scenarioId', label: 'Scenario ID', type: 'text' },
|
|
123
|
+
{ key: 'target', label: 'Target URL', type: 'text',
|
|
124
|
+
showWhen: { operation: 'run-scenario' } },
|
|
125
|
+
{ key: 'linkedItemId', label: 'Linked Item ID', type: 'text' },
|
|
126
|
+
],
|
|
127
|
+
defaultConfig: { nodeType: 'action:test', operation: 'run-saved' },
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
'action:log': {
|
|
131
|
+
label: 'Log',
|
|
132
|
+
category: 'actions',
|
|
133
|
+
icon: '\u{1F4DD}',
|
|
134
|
+
color: '#64748b',
|
|
135
|
+
ports: { in: 1, out: 1 },
|
|
136
|
+
configFields: [
|
|
137
|
+
{ key: 'operation', label: 'Operation', type: 'select',
|
|
138
|
+
options: ['write', 'read', 'clear'] },
|
|
139
|
+
{ key: 'targetPath', label: 'Target Path', type: 'text' },
|
|
140
|
+
{ key: 'type', label: 'Log Type', type: 'text',
|
|
141
|
+
showWhen: { operation: 'write' } },
|
|
142
|
+
{ key: 'message', label: 'Message', type: 'textarea',
|
|
143
|
+
showWhen: { operation: 'write' } },
|
|
144
|
+
{ key: 'lines', label: 'Lines to Read', type: 'number',
|
|
145
|
+
showWhen: { operation: 'read' } },
|
|
146
|
+
],
|
|
147
|
+
defaultConfig: { nodeType: 'action:log', operation: 'write' },
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
'action:file': {
|
|
151
|
+
label: 'File',
|
|
152
|
+
category: 'actions',
|
|
153
|
+
icon: '\u{1F4C1}',
|
|
154
|
+
color: '#14b8a6',
|
|
155
|
+
ports: { in: 1, out: 1 },
|
|
156
|
+
configFields: [
|
|
157
|
+
{ key: 'operation', label: 'Operation', type: 'select',
|
|
158
|
+
options: ['read', 'write', 'append', 'exists', 'tree'] },
|
|
159
|
+
{ key: 'path', label: 'Path', type: 'text' },
|
|
160
|
+
{ key: 'content', label: 'Content', type: 'textarea',
|
|
161
|
+
showWhen: { operation: 'write' } },
|
|
162
|
+
],
|
|
163
|
+
defaultConfig: { nodeType: 'action:file', operation: 'read', path: '' },
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
'action:http': {
|
|
167
|
+
label: 'HTTP',
|
|
168
|
+
category: 'actions',
|
|
169
|
+
icon: '\u{1F310}',
|
|
170
|
+
color: '#e11d48',
|
|
171
|
+
ports: { in: 1, out: 1 },
|
|
172
|
+
configFields: [
|
|
173
|
+
{ key: 'method', label: 'Method', type: 'select',
|
|
174
|
+
options: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'] },
|
|
175
|
+
{ key: 'url', label: 'URL', type: 'text' },
|
|
176
|
+
{ key: 'headers', label: 'Headers (JSON)', type: 'textarea' },
|
|
177
|
+
{ key: 'body', label: 'Body', type: 'textarea' },
|
|
178
|
+
],
|
|
179
|
+
defaultConfig: { nodeType: 'action:http', method: 'GET', url: '' },
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
// ── Control Flow ────────────────────────────────────────────────────────
|
|
183
|
+
'decision': {
|
|
184
|
+
label: 'Decision',
|
|
185
|
+
category: 'control',
|
|
186
|
+
icon: '\u{1F500}',
|
|
187
|
+
color: '#ec4899',
|
|
188
|
+
ports: { in: 1, out: 'dynamic' },
|
|
189
|
+
configFields: [
|
|
190
|
+
{ key: 'conditionType', label: 'Condition Type', type: 'select',
|
|
191
|
+
options: ['exit-code', 'variable', 'expression'] },
|
|
192
|
+
{ key: 'variable', label: 'Variable', type: 'text',
|
|
193
|
+
showWhen: { conditionType: 'variable' } },
|
|
194
|
+
{ key: 'expression', label: 'Expression', type: 'text',
|
|
195
|
+
showWhen: { conditionType: 'expression' } },
|
|
196
|
+
],
|
|
197
|
+
defaultConfig: { nodeType: 'decision', conditionType: 'expression', ports: [] },
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
'loop': {
|
|
201
|
+
label: 'Loop',
|
|
202
|
+
category: 'control',
|
|
203
|
+
icon: '\u{1F504}',
|
|
204
|
+
color: '#d946ef',
|
|
205
|
+
ports: { in: 1, out: 1 },
|
|
206
|
+
configFields: [
|
|
207
|
+
{ key: 'loopType', label: 'Loop Type', type: 'select',
|
|
208
|
+
options: ['count', 'while', 'for-each'] },
|
|
209
|
+
{ key: 'count', label: 'Count', type: 'number',
|
|
210
|
+
showWhen: { loopType: 'count' } },
|
|
211
|
+
{ key: 'condition', label: 'Condition', type: 'text',
|
|
212
|
+
showWhen: { loopType: 'while' } },
|
|
213
|
+
{ key: 'collection', label: 'Collection Variable', type: 'text',
|
|
214
|
+
showWhen: { loopType: 'for-each' } },
|
|
215
|
+
{ key: 'itemVariable', label: 'Item Variable', type: 'text',
|
|
216
|
+
showWhen: { loopType: 'for-each' } },
|
|
217
|
+
{ key: 'maxIterations', label: 'Max Iterations', type: 'number' },
|
|
218
|
+
],
|
|
219
|
+
defaultConfig: { nodeType: 'loop', loopType: 'count', count: 1 },
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
'sub-workflow': {
|
|
223
|
+
label: 'Sub-Workflow',
|
|
224
|
+
category: 'control',
|
|
225
|
+
icon: '\u{1F4E6}',
|
|
226
|
+
color: '#a855f7',
|
|
227
|
+
ports: { in: 1, out: 1 },
|
|
228
|
+
configFields: [
|
|
229
|
+
{ key: 'workflowId', label: 'Workflow ID', type: 'text' },
|
|
230
|
+
],
|
|
231
|
+
defaultConfig: { nodeType: 'sub-workflow', workflowId: '' },
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// ── Steps (backward compat) ─────────────────────────────────────────────
|
|
235
|
+
'step': {
|
|
236
|
+
label: 'Step',
|
|
237
|
+
category: 'steps',
|
|
238
|
+
icon: '\u{1F4CB}',
|
|
239
|
+
color: '#64748b',
|
|
240
|
+
ports: { in: 1, out: 1 },
|
|
241
|
+
configFields: [
|
|
242
|
+
{ key: 'instructions', label: 'Instructions', type: 'textarea' },
|
|
243
|
+
{ key: 'instructionFile', label: 'Instruction File (.md)', type: 'text' },
|
|
244
|
+
],
|
|
245
|
+
defaultConfig: { nodeType: 'step', instructions: '', instructionFile: '' },
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get the node type definition for a given type key.
|
|
251
|
+
* @param {string} type
|
|
252
|
+
* @returns {object|null}
|
|
253
|
+
*/
|
|
254
|
+
export function getNodeType(type) {
|
|
255
|
+
return NODE_TYPES[type] ?? null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Get all node types within a category.
|
|
260
|
+
* @param {string} categoryId
|
|
261
|
+
* @returns {Array<[string, object]>}
|
|
262
|
+
*/
|
|
263
|
+
export function getNodesByCategory(categoryId) {
|
|
264
|
+
return Object.entries(NODE_TYPES).filter(([, def]) => def.category === categoryId);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Resolve the concrete output ports for a node.
|
|
269
|
+
* For static ports (out: N), returns N port descriptors with ids 'out-0', 'out-1', ...
|
|
270
|
+
* For dynamic ports (decision nodes), reads config.ports array.
|
|
271
|
+
* Always returns at least one output port.
|
|
272
|
+
* @param {object} node - { type, config }
|
|
273
|
+
* @returns {Array<{ id: string, label: string }>}
|
|
274
|
+
*/
|
|
275
|
+
export function resolveOutputPorts(node) {
|
|
276
|
+
const typeDef = NODE_TYPES[node.type];
|
|
277
|
+
const portsDef = typeDef?.ports?.out ?? 1;
|
|
278
|
+
|
|
279
|
+
if (portsDef === 'dynamic') {
|
|
280
|
+
const configPorts = node.config?.ports;
|
|
281
|
+
if (Array.isArray(configPorts) && configPorts.length > 0) {
|
|
282
|
+
return configPorts.map(p => ({ id: p.id, label: p.label ?? p.id }));
|
|
283
|
+
}
|
|
284
|
+
// Fallback: single default output so the node is still connectable
|
|
285
|
+
return [{ id: 'out-0', label: 'default' }];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const count = typeof portsDef === 'number' ? portsDef : 1;
|
|
289
|
+
return Array.from({ length: count }, (_, i) => ({ id: `out-${i}`, label: `out-${i}` }));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Resolve the number of input ports for a node.
|
|
294
|
+
* @param {object} node - { type }
|
|
295
|
+
* @returns {number}
|
|
296
|
+
*/
|
|
297
|
+
export function resolveInputPortCount(node) {
|
|
298
|
+
const typeDef = NODE_TYPES[node.type];
|
|
299
|
+
return typeDef?.ports?.in ?? 1;
|
|
300
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// ── Workflow Editor — Graph Data Model ──────────────────────────────────
|
|
2
|
+
// Manages the workflow graph: nodes, edges, and structural queries.
|
|
3
|
+
|
|
4
|
+
import { store } from '../state/store.js';
|
|
5
|
+
import { NODE_TYPES } from './node-types.js';
|
|
6
|
+
|
|
7
|
+
function uid() {
|
|
8
|
+
return crypto.randomUUID();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function markDirty() {
|
|
12
|
+
store.set('isDirty', true);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function emitWorkflow() {
|
|
16
|
+
// Re-set to trigger listeners even though the reference may be the same
|
|
17
|
+
store.set('workflow', store.get('workflow'));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const WorkflowModel = {
|
|
21
|
+
/**
|
|
22
|
+
* Load a workflow object into the store.
|
|
23
|
+
* @param {object} workflow - { id, name, description, nodes, edges, ... }
|
|
24
|
+
*/
|
|
25
|
+
load(workflow) {
|
|
26
|
+
const wf = {
|
|
27
|
+
id: workflow.id,
|
|
28
|
+
name: workflow.name ?? 'Untitled Workflow',
|
|
29
|
+
description: workflow.description ?? '',
|
|
30
|
+
nodes: (workflow.nodes ?? []).map(n => ({ ...n })),
|
|
31
|
+
edges: (workflow.edges ?? []).map(e => ({ ...e })),
|
|
32
|
+
enabled: workflow.enabled ?? true,
|
|
33
|
+
global: workflow.global ?? false,
|
|
34
|
+
createdAt: workflow.createdAt ?? new Date().toISOString(),
|
|
35
|
+
updatedAt: workflow.updatedAt ?? new Date().toISOString(),
|
|
36
|
+
};
|
|
37
|
+
store.set('workflow', wf);
|
|
38
|
+
store.set('isDirty', false);
|
|
39
|
+
store.set('selectedNodeIds', new Set());
|
|
40
|
+
store.set('selectedEdgeIds', new Set());
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Return a serializable workflow object from the current store state.
|
|
45
|
+
* @returns {object|null}
|
|
46
|
+
*/
|
|
47
|
+
save() {
|
|
48
|
+
const wf = store.get('workflow');
|
|
49
|
+
if (!wf) return null;
|
|
50
|
+
return {
|
|
51
|
+
id: wf.id,
|
|
52
|
+
name: wf.name,
|
|
53
|
+
description: wf.description,
|
|
54
|
+
enabled: wf.enabled,
|
|
55
|
+
global: wf.global,
|
|
56
|
+
nodes: wf.nodes.map(n => ({ ...n, position: { ...n.position }, config: { ...n.config } })),
|
|
57
|
+
edges: wf.edges.map(e => ({ ...e })),
|
|
58
|
+
createdAt: wf.createdAt,
|
|
59
|
+
updatedAt: new Date().toISOString(),
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Add a node to the workflow.
|
|
65
|
+
* @param {string} type - Node type key (e.g. 'action:shell')
|
|
66
|
+
* @param {string} label - Display label
|
|
67
|
+
* @param {{ x: number, y: number }} position
|
|
68
|
+
* @param {object} [config={}] - Node-specific config
|
|
69
|
+
* @returns {object} The created node
|
|
70
|
+
*/
|
|
71
|
+
addNode(type, label, position, config = {}) {
|
|
72
|
+
const wf = store.get('workflow');
|
|
73
|
+
if (!wf) return null;
|
|
74
|
+
|
|
75
|
+
const typeDef = NODE_TYPES[type];
|
|
76
|
+
const node = {
|
|
77
|
+
id: uid(),
|
|
78
|
+
type,
|
|
79
|
+
label: label || typeDef?.label || type,
|
|
80
|
+
position: { x: position.x, y: position.y },
|
|
81
|
+
config: { ...(typeDef?.defaultConfig ?? {}), ...config },
|
|
82
|
+
};
|
|
83
|
+
wf.nodes.push(node);
|
|
84
|
+
markDirty();
|
|
85
|
+
emitWorkflow();
|
|
86
|
+
return node;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Remove a node and all connected edges.
|
|
91
|
+
* @param {string} id
|
|
92
|
+
*/
|
|
93
|
+
removeNode(id) {
|
|
94
|
+
const wf = store.get('workflow');
|
|
95
|
+
if (!wf) return;
|
|
96
|
+
|
|
97
|
+
wf.nodes = wf.nodes.filter(n => n.id !== id);
|
|
98
|
+
wf.edges = wf.edges.filter(e => e.source !== id && e.target !== id);
|
|
99
|
+
|
|
100
|
+
// Remove from selection
|
|
101
|
+
const sel = store.get('selectedNodeIds');
|
|
102
|
+
if (sel.has(id)) {
|
|
103
|
+
sel.delete(id);
|
|
104
|
+
store.set('selectedNodeIds', new Set(sel));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
markDirty();
|
|
108
|
+
emitWorkflow();
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Partial-update a node.
|
|
113
|
+
* @param {string} id
|
|
114
|
+
* @param {object} updates - Merged into the node
|
|
115
|
+
*/
|
|
116
|
+
updateNode(id, updates) {
|
|
117
|
+
const wf = store.get('workflow');
|
|
118
|
+
if (!wf) return;
|
|
119
|
+
const node = wf.nodes.find(n => n.id === id);
|
|
120
|
+
if (!node) return;
|
|
121
|
+
|
|
122
|
+
if (updates.config) {
|
|
123
|
+
node.config = { ...node.config, ...updates.config };
|
|
124
|
+
delete updates.config;
|
|
125
|
+
}
|
|
126
|
+
Object.assign(node, updates);
|
|
127
|
+
markDirty();
|
|
128
|
+
emitWorkflow();
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Move a node to a new position.
|
|
133
|
+
* @param {string} id
|
|
134
|
+
* @param {number} x
|
|
135
|
+
* @param {number} y
|
|
136
|
+
*/
|
|
137
|
+
moveNode(id, x, y) {
|
|
138
|
+
const wf = store.get('workflow');
|
|
139
|
+
if (!wf) return;
|
|
140
|
+
const node = wf.nodes.find(n => n.id === id);
|
|
141
|
+
if (!node) return;
|
|
142
|
+
node.position = { x, y };
|
|
143
|
+
markDirty();
|
|
144
|
+
emitWorkflow();
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Add an edge between two nodes.
|
|
149
|
+
* @param {string} source - Source node ID
|
|
150
|
+
* @param {string} target - Target node ID
|
|
151
|
+
* @param {string} [sourcePort] - Port identifier (for multi-output nodes)
|
|
152
|
+
* @param {string} [condition] - Edge label / condition text
|
|
153
|
+
* @returns {object} The created edge
|
|
154
|
+
*/
|
|
155
|
+
addEdge(source, target, sourcePort, condition) {
|
|
156
|
+
const wf = store.get('workflow');
|
|
157
|
+
if (!wf) return null;
|
|
158
|
+
|
|
159
|
+
// Prevent duplicate edges
|
|
160
|
+
const exists = wf.edges.some(
|
|
161
|
+
e => e.source === source && e.target === target && (e.sourcePort ?? '') === (sourcePort ?? '')
|
|
162
|
+
);
|
|
163
|
+
if (exists) return null;
|
|
164
|
+
|
|
165
|
+
// Prevent self-loops
|
|
166
|
+
if (source === target) return null;
|
|
167
|
+
|
|
168
|
+
const edge = {
|
|
169
|
+
id: uid(),
|
|
170
|
+
source,
|
|
171
|
+
target,
|
|
172
|
+
sourcePort: sourcePort ?? null,
|
|
173
|
+
condition: condition ?? null,
|
|
174
|
+
};
|
|
175
|
+
wf.edges.push(edge);
|
|
176
|
+
markDirty();
|
|
177
|
+
emitWorkflow();
|
|
178
|
+
return edge;
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Remove an edge.
|
|
183
|
+
* @param {string} id
|
|
184
|
+
*/
|
|
185
|
+
removeEdge(id) {
|
|
186
|
+
const wf = store.get('workflow');
|
|
187
|
+
if (!wf) return;
|
|
188
|
+
wf.edges = wf.edges.filter(e => e.id !== id);
|
|
189
|
+
|
|
190
|
+
const sel = store.get('selectedEdgeIds');
|
|
191
|
+
if (sel.has(id)) {
|
|
192
|
+
sel.delete(id);
|
|
193
|
+
store.set('selectedEdgeIds', new Set(sel));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
markDirty();
|
|
197
|
+
emitWorkflow();
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get a node by ID.
|
|
202
|
+
* @param {string} id
|
|
203
|
+
* @returns {object|null}
|
|
204
|
+
*/
|
|
205
|
+
getNode(id) {
|
|
206
|
+
const wf = store.get('workflow');
|
|
207
|
+
return wf?.nodes.find(n => n.id === id) ?? null;
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get an edge by ID.
|
|
212
|
+
* @param {string} id
|
|
213
|
+
* @returns {object|null}
|
|
214
|
+
*/
|
|
215
|
+
getEdge(id) {
|
|
216
|
+
const wf = store.get('workflow');
|
|
217
|
+
return wf?.edges.find(e => e.id === id) ?? null;
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get all nodes of a given type.
|
|
222
|
+
* @param {string} type
|
|
223
|
+
* @returns {Array<object>}
|
|
224
|
+
*/
|
|
225
|
+
getNodesOfType(type) {
|
|
226
|
+
const wf = store.get('workflow');
|
|
227
|
+
return wf?.nodes.filter(n => n.type === type) ?? [];
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Get all edges targeting a given node.
|
|
232
|
+
* @param {string} nodeId
|
|
233
|
+
* @returns {Array<object>}
|
|
234
|
+
*/
|
|
235
|
+
getIncomingEdges(nodeId) {
|
|
236
|
+
const wf = store.get('workflow');
|
|
237
|
+
return wf?.edges.filter(e => e.target === nodeId) ?? [];
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get all edges originating from a given node.
|
|
242
|
+
* @param {string} nodeId
|
|
243
|
+
* @returns {Array<object>}
|
|
244
|
+
*/
|
|
245
|
+
getOutgoingEdges(nodeId) {
|
|
246
|
+
const wf = store.get('workflow');
|
|
247
|
+
return wf?.edges.filter(e => e.source === nodeId) ?? [];
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Serialize the workflow as a plain JSON-friendly object.
|
|
252
|
+
* @returns {object|null}
|
|
253
|
+
*/
|
|
254
|
+
toJSON() {
|
|
255
|
+
return this.save();
|
|
256
|
+
},
|
|
257
|
+
};
|