@marktoflow/core 2.0.0-alpha.12

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.
Files changed (142) hide show
  1. package/README.md +307 -0
  2. package/dist/bundle.d.ts +43 -0
  3. package/dist/bundle.d.ts.map +1 -0
  4. package/dist/bundle.js +202 -0
  5. package/dist/bundle.js.map +1 -0
  6. package/dist/config.d.ts +33 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +27 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/core-tools.d.ts +39 -0
  11. package/dist/core-tools.d.ts.map +1 -0
  12. package/dist/core-tools.js +58 -0
  13. package/dist/core-tools.js.map +1 -0
  14. package/dist/costs.d.ts +182 -0
  15. package/dist/costs.d.ts.map +1 -0
  16. package/dist/costs.js +464 -0
  17. package/dist/costs.js.map +1 -0
  18. package/dist/credentials.d.ts +162 -0
  19. package/dist/credentials.d.ts.map +1 -0
  20. package/dist/credentials.js +646 -0
  21. package/dist/credentials.js.map +1 -0
  22. package/dist/engine.d.ts +243 -0
  23. package/dist/engine.d.ts.map +1 -0
  24. package/dist/engine.js +1453 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/env.d.ts +59 -0
  27. package/dist/env.d.ts.map +1 -0
  28. package/dist/env.js +256 -0
  29. package/dist/env.js.map +1 -0
  30. package/dist/failover.d.ts +43 -0
  31. package/dist/failover.d.ts.map +1 -0
  32. package/dist/failover.js +53 -0
  33. package/dist/failover.js.map +1 -0
  34. package/dist/filewatcher.d.ts +32 -0
  35. package/dist/filewatcher.d.ts.map +1 -0
  36. package/dist/filewatcher.js +92 -0
  37. package/dist/filewatcher.js.map +1 -0
  38. package/dist/index.d.ts +40 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +77 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/logging.d.ts +62 -0
  43. package/dist/logging.d.ts.map +1 -0
  44. package/dist/logging.js +211 -0
  45. package/dist/logging.js.map +1 -0
  46. package/dist/mcp-loader.d.ts +29 -0
  47. package/dist/mcp-loader.d.ts.map +1 -0
  48. package/dist/mcp-loader.js +60 -0
  49. package/dist/mcp-loader.js.map +1 -0
  50. package/dist/metrics.d.ts +19 -0
  51. package/dist/metrics.d.ts.map +1 -0
  52. package/dist/metrics.js +65 -0
  53. package/dist/metrics.js.map +1 -0
  54. package/dist/models.d.ts +1686 -0
  55. package/dist/models.d.ts.map +1 -0
  56. package/dist/models.js +333 -0
  57. package/dist/models.js.map +1 -0
  58. package/dist/parser.d.ts +40 -0
  59. package/dist/parser.d.ts.map +1 -0
  60. package/dist/parser.js +532 -0
  61. package/dist/parser.js.map +1 -0
  62. package/dist/permissions.d.ts +49 -0
  63. package/dist/permissions.d.ts.map +1 -0
  64. package/dist/permissions.js +286 -0
  65. package/dist/permissions.js.map +1 -0
  66. package/dist/plugins.d.ts +105 -0
  67. package/dist/plugins.d.ts.map +1 -0
  68. package/dist/plugins.js +182 -0
  69. package/dist/plugins.js.map +1 -0
  70. package/dist/prompt-loader.d.ts +47 -0
  71. package/dist/prompt-loader.d.ts.map +1 -0
  72. package/dist/prompt-loader.js +268 -0
  73. package/dist/prompt-loader.js.map +1 -0
  74. package/dist/queue.d.ts +114 -0
  75. package/dist/queue.d.ts.map +1 -0
  76. package/dist/queue.js +385 -0
  77. package/dist/queue.js.map +1 -0
  78. package/dist/rollback.d.ts +117 -0
  79. package/dist/rollback.d.ts.map +1 -0
  80. package/dist/rollback.js +374 -0
  81. package/dist/rollback.js.map +1 -0
  82. package/dist/routing.d.ts +144 -0
  83. package/dist/routing.d.ts.map +1 -0
  84. package/dist/routing.js +457 -0
  85. package/dist/routing.js.map +1 -0
  86. package/dist/scheduler.d.ts +91 -0
  87. package/dist/scheduler.d.ts.map +1 -0
  88. package/dist/scheduler.js +259 -0
  89. package/dist/scheduler.js.map +1 -0
  90. package/dist/script-tool.d.ts +22 -0
  91. package/dist/script-tool.d.ts.map +1 -0
  92. package/dist/script-tool.js +90 -0
  93. package/dist/script-tool.js.map +1 -0
  94. package/dist/sdk-registry.d.ts +94 -0
  95. package/dist/sdk-registry.d.ts.map +1 -0
  96. package/dist/sdk-registry.js +328 -0
  97. package/dist/sdk-registry.js.map +1 -0
  98. package/dist/security.d.ts +155 -0
  99. package/dist/security.d.ts.map +1 -0
  100. package/dist/security.js +362 -0
  101. package/dist/security.js.map +1 -0
  102. package/dist/state.d.ts +67 -0
  103. package/dist/state.d.ts.map +1 -0
  104. package/dist/state.js +276 -0
  105. package/dist/state.js.map +1 -0
  106. package/dist/templates.d.ts +70 -0
  107. package/dist/templates.d.ts.map +1 -0
  108. package/dist/templates.js +244 -0
  109. package/dist/templates.js.map +1 -0
  110. package/dist/tool-base.d.ts +54 -0
  111. package/dist/tool-base.d.ts.map +1 -0
  112. package/dist/tool-base.js +43 -0
  113. package/dist/tool-base.js.map +1 -0
  114. package/dist/tool-registry.d.ts +24 -0
  115. package/dist/tool-registry.d.ts.map +1 -0
  116. package/dist/tool-registry.js +164 -0
  117. package/dist/tool-registry.js.map +1 -0
  118. package/dist/tools/custom-tool.d.ts +16 -0
  119. package/dist/tools/custom-tool.d.ts.map +1 -0
  120. package/dist/tools/custom-tool.js +85 -0
  121. package/dist/tools/custom-tool.js.map +1 -0
  122. package/dist/tools/mcp-tool.d.ts +16 -0
  123. package/dist/tools/mcp-tool.d.ts.map +1 -0
  124. package/dist/tools/mcp-tool.js +98 -0
  125. package/dist/tools/mcp-tool.js.map +1 -0
  126. package/dist/tools/openapi-tool.d.ts +17 -0
  127. package/dist/tools/openapi-tool.d.ts.map +1 -0
  128. package/dist/tools/openapi-tool.js +165 -0
  129. package/dist/tools/openapi-tool.js.map +1 -0
  130. package/dist/trigger-manager.d.ts +26 -0
  131. package/dist/trigger-manager.d.ts.map +1 -0
  132. package/dist/trigger-manager.js +107 -0
  133. package/dist/trigger-manager.js.map +1 -0
  134. package/dist/webhook.d.ts +95 -0
  135. package/dist/webhook.d.ts.map +1 -0
  136. package/dist/webhook.js +261 -0
  137. package/dist/webhook.js.map +1 -0
  138. package/dist/workflow-tools.d.ts +102 -0
  139. package/dist/workflow-tools.d.ts.map +1 -0
  140. package/dist/workflow-tools.js +130 -0
  141. package/dist/workflow-tools.js.map +1 -0
  142. package/package.json +62 -0
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ # @marktoflow/core
2
+
3
+ > **Author:** Scott Glover <scottgl@gmail.com>
4
+
5
+ Core engine for marktoflow - parser, executor, and state management.
6
+
7
+ ## Overview
8
+
9
+ `@marktoflow/core` is the foundation of the marktoflow automation framework. It provides the core workflow engine, state management, scheduling, and execution infrastructure.
10
+
11
+ ## Features
12
+
13
+ - **Workflow Parser** - Parse markdown + YAML workflow definitions
14
+ - **Execution Engine** - Step-by-step workflow execution with retry and error handling
15
+ - **State Management** - SQLite-based persistent state tracking
16
+ - **Scheduling** - Cron-based workflow scheduling
17
+ - **Queue System** - Support for Redis, RabbitMQ, and in-memory queues
18
+ - **Webhooks** - HTTP webhook trigger support
19
+ - **File Watching** - Monitor files for changes and trigger workflows
20
+ - **Security** - RBAC, approval workflows, and audit logging
21
+ - **Cost Tracking** - Track and manage API usage costs
22
+ - **Plugin System** - Extensible plugin architecture with 17 hook types
23
+ - **Templates** - Reusable workflow templates with variables
24
+ - **Tool Registry** - Support for MCP, OpenAPI, and custom tools
25
+ - **Agent Routing** - Multi-agent workflow support with routing strategies
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @marktoflow/core
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### Basic Workflow Execution
36
+
37
+ ```typescript
38
+ import { WorkflowParser, WorkflowEngine } from '@marktoflow/core';
39
+
40
+ // Parse workflow
41
+ const parser = new WorkflowParser();
42
+ const workflow = await parser.parseWorkflow('workflow.md');
43
+
44
+ // Execute workflow
45
+ const engine = new WorkflowEngine();
46
+ const result = await engine.execute(workflow, {
47
+ inputs: { message: 'Hello World' },
48
+ });
49
+
50
+ console.log(result);
51
+ ```
52
+
53
+ ### With State Management
54
+
55
+ ```typescript
56
+ import { WorkflowEngine, StateManager } from '@marktoflow/core';
57
+
58
+ // Initialize state manager
59
+ const stateManager = new StateManager({
60
+ dbPath: '.marktoflow/state.db',
61
+ });
62
+
63
+ // Execute workflow with state
64
+ const engine = new WorkflowEngine({ stateManager });
65
+ const result = await engine.execute(workflow);
66
+
67
+ // Query state
68
+ const history = await stateManager.getWorkflowHistory(workflow.id);
69
+ ```
70
+
71
+ ### Scheduling
72
+
73
+ ```typescript
74
+ import { Scheduler } from '@marktoflow/core';
75
+
76
+ // Create scheduler
77
+ const scheduler = new Scheduler();
78
+
79
+ // Schedule workflow (cron format)
80
+ await scheduler.schedule({
81
+ workflowId: 'daily-report',
82
+ cron: '0 9 * * 1-5', // 9 AM weekdays
83
+ workflowPath: './workflows/daily-report.md',
84
+ });
85
+
86
+ // Start scheduler
87
+ await scheduler.start();
88
+ ```
89
+
90
+ ### Webhooks
91
+
92
+ ```typescript
93
+ import { WebhookServer } from '@marktoflow/core';
94
+
95
+ // Create webhook server
96
+ const webhookServer = new WebhookServer({ port: 3000 });
97
+
98
+ // Register webhook
99
+ await webhookServer.registerWebhook({
100
+ path: '/github',
101
+ workflowPath: './workflows/github-pr.md',
102
+ secret: process.env.GITHUB_WEBHOOK_SECRET,
103
+ });
104
+
105
+ // Start server
106
+ await webhookServer.start();
107
+ ```
108
+
109
+ ### Plugin System
110
+
111
+ ```typescript
112
+ import { PluginRegistry } from '@marktoflow/core';
113
+
114
+ // Register plugin
115
+ const registry = new PluginRegistry();
116
+ await registry.register({
117
+ name: 'my-plugin',
118
+ hooks: {
119
+ beforeWorkflowStart: async (context) => {
120
+ console.log('Starting workflow:', context.workflow.id);
121
+ },
122
+ afterStepComplete: async (context) => {
123
+ console.log('Completed step:', context.step.action);
124
+ },
125
+ },
126
+ });
127
+ ```
128
+
129
+ ## Workflow Format
130
+
131
+ Workflows are written in markdown with YAML frontmatter:
132
+
133
+ ```markdown
134
+ ---
135
+ workflow:
136
+ id: example
137
+ name: Example Workflow
138
+
139
+ tools:
140
+ slack:
141
+ sdk: '@slack/web-api'
142
+ auth:
143
+ token: '${SLACK_BOT_TOKEN}'
144
+
145
+ triggers:
146
+ - type: schedule
147
+ cron: '0 9 * * *'
148
+
149
+ inputs:
150
+ message:
151
+ type: string
152
+ required: true
153
+
154
+ outputs:
155
+ result:
156
+ type: string
157
+ ---
158
+
159
+ # Example Workflow
160
+
161
+ This workflow posts a message to Slack.
162
+
163
+ ## Step 1: Post Message
164
+
165
+ \`\`\`yaml
166
+ action: slack.chat.postMessage
167
+ inputs:
168
+ channel: '#general'
169
+ text: '{{ inputs.message }}'
170
+ output_variable: result
171
+ \`\`\`
172
+ ```
173
+
174
+ ## Architecture
175
+
176
+ ### Core Components
177
+
178
+ 1. **Parser** (`parser.ts`) - Parse markdown + YAML workflow definitions
179
+ 2. **Engine** (`engine.ts`) - Execute workflows with retry/circuit breaker
180
+ 3. **State Manager** (`state.ts`) - SQLite-based state persistence
181
+ 4. **Scheduler** (`scheduler.ts`) - Cron-based workflow scheduling
182
+ 5. **Queue** (`queue.ts`) - Redis/RabbitMQ/InMemory queue support
183
+ 6. **Webhook** (`webhook.ts`) - HTTP webhook triggers
184
+ 7. **File Watcher** (`filewatcher.ts`) - File change monitoring
185
+ 8. **Security** (`security.ts`) - RBAC and audit logging
186
+ 9. **Cost Tracker** (`costs.ts`) - API usage cost management
187
+ 10. **Plugin System** (`plugins.ts`) - Extensible hooks
188
+ 11. **Templates** (`templates.ts`) - Reusable workflow patterns
189
+ 12. **Tool Registry** (`tool-registry.ts`) - MCP/OpenAPI/Custom tools
190
+ 13. **Agent Routing** (`routing.ts`) - Multi-agent coordination
191
+
192
+ ### Execution Flow
193
+
194
+ ```
195
+ Parser → Validate → Security Check → Execute Steps → Save State → Output
196
+ ↓ ↓ ↓ ↓
197
+ Schema RBAC Retry/Failover Audit Log
198
+ ```
199
+
200
+ ## Configuration
201
+
202
+ ### Environment Variables
203
+
204
+ ```bash
205
+ # Database
206
+ MARKTOFLOW_DB_PATH=.marktoflow/state.db
207
+
208
+ # Queue (Redis)
209
+ REDIS_HOST=localhost
210
+ REDIS_PORT=6379
211
+
212
+ # Queue (RabbitMQ)
213
+ RABBITMQ_URL=amqp://localhost
214
+
215
+ # Security
216
+ MARKTOFLOW_SECRET_KEY=your-secret-key
217
+ ```
218
+
219
+ ### Configuration File
220
+
221
+ Create `.marktoflow/config.yaml`:
222
+
223
+ ```yaml
224
+ state:
225
+ dbPath: .marktoflow/state.db
226
+
227
+ queue:
228
+ type: redis # redis, rabbitmq, or memory
229
+ redis:
230
+ host: localhost
231
+ port: 6379
232
+
233
+ security:
234
+ rbac:
235
+ enabled: true
236
+ auditLog:
237
+ enabled: true
238
+
239
+ costs:
240
+ budget:
241
+ daily: 100
242
+ monthly: 3000
243
+ alerts:
244
+ - threshold: 50
245
+ emails: [admin@example.com]
246
+ ```
247
+
248
+ ## API Reference
249
+
250
+ ### WorkflowParser
251
+
252
+ ```typescript
253
+ class WorkflowParser {
254
+ parseWorkflow(filePath: string): Promise<Workflow>;
255
+ parseYAML(content: string): Workflow;
256
+ validate(workflow: Workflow): ValidationResult;
257
+ }
258
+ ```
259
+
260
+ ### WorkflowEngine
261
+
262
+ ```typescript
263
+ class WorkflowEngine {
264
+ constructor(options?: EngineOptions);
265
+ execute(workflow: Workflow, context?: ExecutionContext): Promise<WorkflowResult>;
266
+ stop(): Promise<void>;
267
+ }
268
+ ```
269
+
270
+ ### StateManager
271
+
272
+ ```typescript
273
+ class StateManager {
274
+ constructor(options: StateOptions);
275
+ getWorkflowHistory(workflowId: string): Promise<WorkflowRun[]>;
276
+ getWorkflowState(runId: string): Promise<WorkflowState>;
277
+ saveWorkflowState(state: WorkflowState): Promise<void>;
278
+ }
279
+ ```
280
+
281
+ ### Scheduler
282
+
283
+ ```typescript
284
+ class Scheduler {
285
+ schedule(config: ScheduleConfig): Promise<void>;
286
+ unschedule(workflowId: string): Promise<void>;
287
+ start(): Promise<void>;
288
+ stop(): Promise<void>;
289
+ }
290
+ ```
291
+
292
+ ## Testing
293
+
294
+ ```bash
295
+ npm test
296
+ ```
297
+
298
+ ## Links
299
+
300
+ - [Main Repository](https://github.com/marktoflow/marktoflow)
301
+ - [Documentation](https://github.com/marktoflow/marktoflow#readme)
302
+ - [CLI Package](@marktoflow/cli)
303
+ - [Integrations Package](@marktoflow/integrations)
304
+
305
+ ## License
306
+
307
+ Apache-2.0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Workflow bundle support for marktoflow.
3
+ */
4
+ import { Workflow, ToolConfig } from './models.js';
5
+ import { ToolRegistry } from './tool-registry.js';
6
+ import { Tool } from './tool-base.js';
7
+ export interface BundleConfig {
8
+ agent: string;
9
+ fallbackAgent?: string | undefined;
10
+ timeout: number;
11
+ maxRetries: number;
12
+ toolsDir: string;
13
+ inheritGlobalTools: boolean;
14
+ env: Record<string, string>;
15
+ }
16
+ export declare function loadBundleConfig(path: string): BundleConfig;
17
+ export declare class BundleToolRegistry extends ToolRegistry {
18
+ private scriptTools;
19
+ private bundleDir;
20
+ private toolsDir;
21
+ constructor(bundleDir: string, toolsDir?: string, inheritGlobal?: boolean, globalRegistryPath?: string);
22
+ private loadScriptTools;
23
+ getTool(name: string, agent: string): Tool | null;
24
+ listTools(): string[];
25
+ listScriptTools(): string[];
26
+ getScriptToolPaths(): Record<string, string>;
27
+ }
28
+ export declare class WorkflowBundle {
29
+ private globalRegistryPath?;
30
+ readonly path: string;
31
+ private configCache?;
32
+ private workflowCache?;
33
+ private toolRegistryCache?;
34
+ constructor(path: string, globalRegistryPath?: string | undefined);
35
+ get name(): string;
36
+ get config(): BundleConfig;
37
+ get workflowFile(): string | null;
38
+ loadWorkflow(): Promise<Workflow>;
39
+ loadTools(): BundleToolRegistry;
40
+ buildToolConfigs(): Record<string, ToolConfig>;
41
+ loadWorkflowWithBundleTools(): Promise<Workflow>;
42
+ }
43
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 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AC,aAAa,CAAC,CAAW;IACjC,OAAO,CAAC,iBAAiB,CAAC,CAAqB;gBAEnC,IAAI,EAAE,MAAM,EAAU,kBAAkB,CAAC,EAAE,MAAM,YAAA;IAM7D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,MAAM,IAAI,YAAY,CAKzB;IAED,IAAI,YAAY,IAAI,MAAM,GAAG,IAAI,CAShC;IAEK,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC;IASvC,SAAS,IAAI,kBAAkB;IAW/B,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAmBxC,2BAA2B,IAAI,OAAO,CAAC,QAAQ,CAAC;CAYvD"}
package/dist/bundle.js ADDED
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Workflow bundle support for marktoflow.
3
+ */
4
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
5
+ import { join, resolve, extname, basename } from 'node:path';
6
+ import { parse } from 'yaml';
7
+ import { parseFile } from './parser.js';
8
+ import { ScriptTool } from './script-tool.js';
9
+ import { ToolRegistry } from './tool-registry.js';
10
+ import { Tool, ToolType } from './tool-base.js';
11
+ export function loadBundleConfig(path) {
12
+ if (!existsSync(path)) {
13
+ return {
14
+ agent: 'opencode',
15
+ timeout: 300,
16
+ maxRetries: 3,
17
+ toolsDir: 'tools',
18
+ inheritGlobalTools: true,
19
+ env: {},
20
+ };
21
+ }
22
+ const content = readFileSync(path, 'utf8');
23
+ const data = parse(content) ?? {};
24
+ return {
25
+ agent: data.agent ?? 'opencode',
26
+ fallbackAgent: data.fallback_agent ?? undefined,
27
+ timeout: data.timeout ?? 300,
28
+ maxRetries: data.max_retries ?? 3,
29
+ toolsDir: data.tools_dir ?? 'tools',
30
+ inheritGlobalTools: data.inherit_global_tools ?? true,
31
+ env: data.env ?? {},
32
+ };
33
+ }
34
+ class ScriptToolWrapper extends Tool {
35
+ scriptTool;
36
+ operations = [];
37
+ constructor(definition, implementation, toolsDir) {
38
+ super(definition, implementation);
39
+ this.scriptTool = new ScriptTool(implementation.adapterPath ?? '', toolsDir);
40
+ this.operations = this.loadOperations(implementation.adapterPath ?? '', toolsDir);
41
+ }
42
+ async initialize() {
43
+ this.initialized = true;
44
+ }
45
+ loadOperations(scriptPath, toolsDir) {
46
+ const fullPath = resolve(toolsDir, scriptPath);
47
+ const yamlPath = fullPath.replace(/\.[^/.]+$/, '') + '.yaml';
48
+ if (existsSync(yamlPath)) {
49
+ const content = readFileSync(yamlPath, 'utf8');
50
+ const data = parse(content);
51
+ const ops = data?.operations ? Object.keys(data.operations) : [];
52
+ return ops.length > 0 ? ops : ['run'];
53
+ }
54
+ return ['run'];
55
+ }
56
+ async execute(operation, params) {
57
+ return this.scriptTool.execute(operation, params);
58
+ }
59
+ listOperations() {
60
+ return this.operations;
61
+ }
62
+ getOperationSchema(_operation) {
63
+ return { description: '', parameters: { type: 'object', properties: {}, required: [] } };
64
+ }
65
+ }
66
+ export class BundleToolRegistry extends ToolRegistry {
67
+ scriptTools = new Map();
68
+ bundleDir;
69
+ toolsDir;
70
+ constructor(bundleDir, toolsDir = 'tools', inheritGlobal = true, globalRegistryPath) {
71
+ super(inheritGlobal ? globalRegistryPath : undefined);
72
+ this.bundleDir = resolve(bundleDir);
73
+ this.toolsDir = resolve(this.bundleDir, toolsDir);
74
+ this.loadScriptTools();
75
+ }
76
+ loadScriptTools() {
77
+ if (!existsSync(this.toolsDir))
78
+ return;
79
+ const entries = readdirSync(this.toolsDir);
80
+ for (const entry of entries) {
81
+ const ext = extname(entry);
82
+ if (ext === '.yaml' || ext === '.yml')
83
+ continue;
84
+ const toolName = basename(entry, ext);
85
+ const implementation = {
86
+ type: ToolType.CUSTOM,
87
+ priority: 0,
88
+ adapterPath: join(this.toolsDir, entry),
89
+ };
90
+ const definition = {
91
+ name: toolName,
92
+ description: `Script tool ${toolName}`,
93
+ implementations: [implementation],
94
+ };
95
+ const tool = new ScriptToolWrapper(definition, implementation, this.toolsDir);
96
+ this.scriptTools.set(toolName, tool);
97
+ this.register(definition);
98
+ }
99
+ }
100
+ getTool(name, agent) {
101
+ if (this.scriptTools.has(name)) {
102
+ return this.scriptTools.get(name) ?? null;
103
+ }
104
+ return super.getTool(name, agent);
105
+ }
106
+ listTools() {
107
+ const tools = new Set(super.listTools());
108
+ for (const name of this.scriptTools.keys())
109
+ tools.add(name);
110
+ return Array.from(tools).sort();
111
+ }
112
+ listScriptTools() {
113
+ return Array.from(this.scriptTools.keys());
114
+ }
115
+ getScriptToolPaths() {
116
+ const result = {};
117
+ for (const [name, tool] of this.scriptTools.entries()) {
118
+ result[name] = tool.implementation.adapterPath ?? '';
119
+ }
120
+ return result;
121
+ }
122
+ }
123
+ export class WorkflowBundle {
124
+ globalRegistryPath;
125
+ path;
126
+ configCache;
127
+ workflowCache;
128
+ toolRegistryCache;
129
+ constructor(path, globalRegistryPath) {
130
+ this.globalRegistryPath = globalRegistryPath;
131
+ const resolved = resolve(path);
132
+ if (!existsSync(resolved))
133
+ throw new Error(`Bundle directory not found: ${resolved}`);
134
+ this.path = resolved;
135
+ }
136
+ get name() {
137
+ return basename(this.path);
138
+ }
139
+ get config() {
140
+ if (!this.configCache) {
141
+ this.configCache = loadBundleConfig(join(this.path, 'config.yaml'));
142
+ }
143
+ return this.configCache;
144
+ }
145
+ get workflowFile() {
146
+ const candidates = ['workflow.md', 'main.md'];
147
+ for (const candidate of candidates) {
148
+ const full = join(this.path, candidate);
149
+ if (existsSync(full))
150
+ return full;
151
+ }
152
+ const entries = readdirSync(this.path).filter((name) => name.endsWith('.md') && name !== 'README.md');
153
+ if (entries.length === 1)
154
+ return join(this.path, entries[0]);
155
+ return null;
156
+ }
157
+ async loadWorkflow() {
158
+ if (this.workflowCache)
159
+ return this.workflowCache;
160
+ const wfPath = this.workflowFile;
161
+ if (!wfPath)
162
+ throw new Error('No workflow markdown found in bundle');
163
+ const { workflow } = await parseFile(wfPath);
164
+ this.workflowCache = workflow;
165
+ return workflow;
166
+ }
167
+ loadTools() {
168
+ if (this.toolRegistryCache)
169
+ return this.toolRegistryCache;
170
+ this.toolRegistryCache = new BundleToolRegistry(this.path, this.config.toolsDir, this.config.inheritGlobalTools, this.globalRegistryPath);
171
+ return this.toolRegistryCache;
172
+ }
173
+ buildToolConfigs() {
174
+ const registry = this.loadTools();
175
+ const scriptToolPaths = registry.getScriptToolPaths();
176
+ const configs = {};
177
+ for (const [toolName, scriptPath] of Object.entries(scriptToolPaths)) {
178
+ if (!scriptPath)
179
+ continue;
180
+ configs[toolName] = {
181
+ sdk: 'script',
182
+ options: {
183
+ path: scriptPath,
184
+ toolsDir: join(this.path, this.config.toolsDir),
185
+ },
186
+ };
187
+ }
188
+ return configs;
189
+ }
190
+ async loadWorkflowWithBundleTools() {
191
+ const workflow = await this.loadWorkflow();
192
+ const bundleTools = this.buildToolConfigs();
193
+ return {
194
+ ...workflow,
195
+ tools: {
196
+ ...(workflow.tools ?? {}),
197
+ ...bundleTools,
198
+ },
199
+ };
200
+ }
201
+ }
202
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAsC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYpF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,UAAU,CAA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E5C,OAAO;YACL,GAAG,QAAQ;YACX,KAAK,EAAE;gBACL,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;gBACzB,GAAG,WAAW;aACf;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * marktoflow configuration loader.
3
+ */
4
+ export interface MarktoflowConfig {
5
+ agent?: {
6
+ primary?: string;
7
+ fallback?: string | null;
8
+ selectionStrategy?: string;
9
+ };
10
+ runtime?: {
11
+ mode?: string;
12
+ nodeVersion?: string;
13
+ };
14
+ logging?: {
15
+ level?: string;
16
+ destination?: string;
17
+ format?: string;
18
+ logPath?: string;
19
+ };
20
+ tools?: {
21
+ discovery?: string;
22
+ timeout?: string;
23
+ registryPath?: string;
24
+ };
25
+ workflows?: {
26
+ path?: string;
27
+ maxConcurrent?: number;
28
+ defaultTimeout?: string;
29
+ };
30
+ features?: Record<string, string>;
31
+ }
32
+ export declare function loadConfig(cwd?: string): MarktoflowConfig;
33
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAOD,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,gBAAgB,CAcxE"}
package/dist/config.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * marktoflow configuration loader.
3
+ */
4
+ import { readFileSync, existsSync } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ import { parse } from 'yaml';
7
+ import { findProjectRoot } from './env.js';
8
+ const DEFAULT_CONFIG = {
9
+ workflows: { path: '.marktoflow/workflows' },
10
+ tools: { registryPath: '.marktoflow/tools/registry.yaml' },
11
+ };
12
+ export function loadConfig(cwd = process.cwd()) {
13
+ const root = findProjectRoot(cwd);
14
+ const configPath = root ? join(root, 'marktoflow.yaml') : join(cwd, 'marktoflow.yaml');
15
+ if (!existsSync(configPath)) {
16
+ return DEFAULT_CONFIG;
17
+ }
18
+ const contents = readFileSync(configPath, 'utf8');
19
+ const data = parse(contents);
20
+ return {
21
+ ...DEFAULT_CONFIG,
22
+ ...data,
23
+ workflows: { ...DEFAULT_CONFIG.workflows, ...data?.workflows },
24
+ tools: { ...DEFAULT_CONFIG.tools, ...data?.tools },
25
+ };
26
+ }
27
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+B3C,MAAM,cAAc,GAAqB;IACvC,SAAS,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;IAC5C,KAAK,EAAE,EAAE,YAAY,EAAE,iCAAiC,EAAE;CAC3D,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACpD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IACvF,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,MAAM,QAAQ,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAqB,CAAC;IACjD,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,IAAI;QACP,SAAS,EAAE,EAAE,GAAG,cAAc,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE;QAC9D,KAAK,EAAE,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Core built-in tools for marktoflow workflows
3
+ *
4
+ * These tools are always available without needing to be declared in the workflow.
5
+ */
6
+ import { SDKInitializer } from './sdk-registry.js';
7
+ /**
8
+ * Core tools client that provides built-in workflow actions
9
+ */
10
+ export declare class CoreToolsClient {
11
+ constructor();
12
+ /**
13
+ * Log a message during workflow execution
14
+ */
15
+ log(inputs: {
16
+ level: string;
17
+ message: string;
18
+ metadata?: Record<string, unknown>;
19
+ }): Promise<{
20
+ logged: true;
21
+ }>;
22
+ /**
23
+ * Write content to a file
24
+ */
25
+ writeFile(inputs: {
26
+ path: string;
27
+ content: string;
28
+ encoding?: string;
29
+ }): Promise<{
30
+ written: true;
31
+ path: string;
32
+ size: number;
33
+ }>;
34
+ }
35
+ /**
36
+ * Core SDK initializer
37
+ */
38
+ export declare const CoreInitializer: SDKInitializer;
39
+ //# sourceMappingURL=core-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-tools.d.ts","sourceRoot":"","sources":["../src/core-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;GAEG;AACH,qBAAa,eAAe;;IAK1B;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,CAAC;IAkB7B;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAiB3D;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAI7B,CAAC"}