@marktoflow/core 2.0.0-alpha.3
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/bundle.d.ts +43 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +202 -0
- package/dist/bundle.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +27 -0
- package/dist/config.js.map +1 -0
- package/dist/costs.d.ts +182 -0
- package/dist/costs.d.ts.map +1 -0
- package/dist/costs.js +464 -0
- package/dist/costs.js.map +1 -0
- package/dist/credentials.d.ts +162 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +646 -0
- package/dist/credentials.js.map +1 -0
- package/dist/engine.d.ts +137 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +514 -0
- package/dist/engine.js.map +1 -0
- package/dist/env.d.ts +59 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +256 -0
- package/dist/env.js.map +1 -0
- package/dist/failover.d.ts +43 -0
- package/dist/failover.d.ts.map +1 -0
- package/dist/failover.js +53 -0
- package/dist/failover.js.map +1 -0
- package/dist/filewatcher.d.ts +32 -0
- package/dist/filewatcher.d.ts.map +1 -0
- package/dist/filewatcher.js +92 -0
- package/dist/filewatcher.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +62 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +211 -0
- package/dist/logging.js.map +1 -0
- package/dist/mcp-loader.d.ts +29 -0
- package/dist/mcp-loader.d.ts.map +1 -0
- package/dist/mcp-loader.js +60 -0
- package/dist/mcp-loader.js.map +1 -0
- package/dist/metrics.d.ts +19 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +65 -0
- package/dist/metrics.js.map +1 -0
- package/dist/models.d.ts +419 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +111 -0
- package/dist/models.js.map +1 -0
- package/dist/parser.d.ts +40 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +287 -0
- package/dist/parser.js.map +1 -0
- package/dist/plugins.d.ts +105 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +182 -0
- package/dist/plugins.js.map +1 -0
- package/dist/queue.d.ts +114 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +385 -0
- package/dist/queue.js.map +1 -0
- package/dist/rollback.d.ts +117 -0
- package/dist/rollback.d.ts.map +1 -0
- package/dist/rollback.js +374 -0
- package/dist/rollback.js.map +1 -0
- package/dist/routing.d.ts +144 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +457 -0
- package/dist/routing.js.map +1 -0
- package/dist/scheduler.d.ts +91 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +259 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/script-tool.d.ts +22 -0
- package/dist/script-tool.d.ts.map +1 -0
- package/dist/script-tool.js +90 -0
- package/dist/script-tool.js.map +1 -0
- package/dist/sdk-registry.d.ts +81 -0
- package/dist/sdk-registry.d.ts.map +1 -0
- package/dist/sdk-registry.js +264 -0
- package/dist/sdk-registry.js.map +1 -0
- package/dist/security.d.ts +155 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +362 -0
- package/dist/security.js.map +1 -0
- package/dist/state.d.ts +67 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +276 -0
- package/dist/state.js.map +1 -0
- package/dist/templates.d.ts +70 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +244 -0
- package/dist/templates.js.map +1 -0
- package/dist/tool-base.d.ts +54 -0
- package/dist/tool-base.d.ts.map +1 -0
- package/dist/tool-base.js +43 -0
- package/dist/tool-base.js.map +1 -0
- package/dist/tool-registry.d.ts +24 -0
- package/dist/tool-registry.d.ts.map +1 -0
- package/dist/tool-registry.js +164 -0
- package/dist/tool-registry.js.map +1 -0
- package/dist/tools/custom-tool.d.ts +16 -0
- package/dist/tools/custom-tool.d.ts.map +1 -0
- package/dist/tools/custom-tool.js +85 -0
- package/dist/tools/custom-tool.js.map +1 -0
- package/dist/tools/mcp-tool.d.ts +16 -0
- package/dist/tools/mcp-tool.d.ts.map +1 -0
- package/dist/tools/mcp-tool.js +98 -0
- package/dist/tools/mcp-tool.js.map +1 -0
- package/dist/tools/openapi-tool.d.ts +17 -0
- package/dist/tools/openapi-tool.d.ts.map +1 -0
- package/dist/tools/openapi-tool.js +165 -0
- package/dist/tools/openapi-tool.js.map +1 -0
- package/dist/trigger-manager.d.ts +26 -0
- package/dist/trigger-manager.d.ts.map +1 -0
- package/dist/trigger-manager.js +107 -0
- package/dist/trigger-manager.js.map +1 -0
- package/dist/webhook.d.ts +95 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +261 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @marktoflow/core
|
|
3
|
+
*
|
|
4
|
+
* Core engine for marktoflow v2.0 - parser, executor, state management.
|
|
5
|
+
*/
|
|
6
|
+
export { StepStatus, WorkflowStatus, TriggerType, WorkflowMetadataSchema, ToolConfigSchema, ErrorHandlingSchema, WorkflowStepSchema, TriggerSchema, WorkflowInputSchema, WorkflowSchema, type WorkflowMetadata, type ToolConfig, type ErrorHandling, type WorkflowStep, type Trigger, type WorkflowInput, type Workflow, type ExecutionContext, type StepResult, type WorkflowResult, createExecutionContext, createStepResult, } from './models.js';
|
|
7
|
+
export { findEnvFiles, findProjectRoot, loadEnv, ensureEnvLoaded, getEnv, getEnvBool, getEnvInt, getEnvFloat, getEnvList, EnvConfig, config, } from './env.js';
|
|
8
|
+
export { EncryptionBackend, CredentialType, EncryptionError, KeyNotFoundError, CredentialNotFoundError, FernetEncryptor, AgeEncryptor, GPGEncryptor, InMemoryCredentialStore, SQLiteCredentialStore, CredentialManager, KeyManager, createCredentialManager, getAvailableBackends, type Credential, type Encryptor, type CredentialStore, } from './credentials.js';
|
|
9
|
+
export { parseFile, parseContent, extractVariableReferences, validateVariableReferences, ParseError, type ParseResult, type ParseOptions, } from './parser.js';
|
|
10
|
+
export { WorkflowEngine, RetryPolicy, CircuitBreaker, resolveTemplates, type EngineConfig, type EngineEvents, type StepExecutor, type CircuitState, } from './engine.js';
|
|
11
|
+
export { ToolRegistry, } from './tool-registry.js';
|
|
12
|
+
export { ToolType, ToolCompatibility, type ToolImplementation, type ToolAuth, type ToolDefinition, type Tool, } from './tool-base.js';
|
|
13
|
+
export { OpenAPITool } from './tools/openapi-tool.js';
|
|
14
|
+
export { CustomTool, operation as customOperation } from './tools/custom-tool.js';
|
|
15
|
+
export { MCPTool } from './tools/mcp-tool.js';
|
|
16
|
+
export { WorkflowBundle, BundleToolRegistry, loadBundleConfig, type BundleConfig, } from './bundle.js';
|
|
17
|
+
export { SDKRegistry, defaultSDKLoader, defaultInitializers, createSDKStepExecutor, type SDKInstance, type SDKLoader, type SDKInitializer, } from './sdk-registry.js';
|
|
18
|
+
export { StateStore, type ExecutionRecord, type StepCheckpoint, type ExecutionStats, } from './state.js';
|
|
19
|
+
export { LogLevel, ExecutionLogger, createExecutionLog, addLogEntry, completeLog, logToMarkdown, type LogEntry, type ExecutionLog, } from './logging.js';
|
|
20
|
+
export { Scheduler, CronParser, createJob, type ScheduledJob, type CronFields, type JobCallback, } from './scheduler.js';
|
|
21
|
+
export { WebhookReceiver, verifyGitHubSignature, verifyHmacSignature, verifySlackSignature, generateSignature, createEndpoint, parseWebhookBody, type WebhookEndpoint, type WebhookEvent, type WebhookHandler, type WebhookResponse, type WebhookReceiverOptions, } from './webhook.js';
|
|
22
|
+
export { McpLoader, type McpModule, } from './mcp-loader.js';
|
|
23
|
+
export { ScriptTool, type ScriptOperation, type ScriptToolConfig, } from './script-tool.js';
|
|
24
|
+
export { FileWatcher, type FileWatcherOptions, type FileEvent, type FileEventHandler, } from './filewatcher.js';
|
|
25
|
+
export { MessagePriority, MessageStatus, MessageQueue, InMemoryQueue, RedisQueue, RabbitMQQueue, WorkflowQueueManager, type QueueMessage, type QueueConfig, type MessageHandler, } from './queue.js';
|
|
26
|
+
export { Permission, RBACManager, ApprovalStatus, ApprovalManager, AuditEventType, AuditLogger, SQLiteAuditStore, InMemoryAuditStore, type Role, type User, type ApprovalRequest, type ApprovalHandler, type AuditEvent, type AuditStore, } from './security.js';
|
|
27
|
+
export { DEFAULT_PRICING, CostStore, CostTracker, PersistentCostTracker, PricingRegistry, WorkflowCostEstimator, LoggingAlertHandler, CallbackAlertHandler, CostAlertLevel, CostUnit, type ModelPricing, type TokenUsage, type CostRecord, type CostSummary, type CostLimit, type CostAlert, type CostAlertHandler, } from './costs.js';
|
|
28
|
+
export { MetricsCollector, } from './metrics.js';
|
|
29
|
+
export { SelectionStrategy, RoutingDecision, AgentSelector, AgentRouter, BudgetTracker, PREDEFINED_PROFILES, createDefaultSelector, createCostOptimizedSelector, createQualityOptimizedSelector, type AgentProfile, type AgentScore, type RoutingContext, type RoutingResult, type BudgetConfig, type LoadInfo, } from './routing.js';
|
|
30
|
+
export { FailoverReason, AgentHealthTracker, DEFAULT_FAILOVER_CONFIG, type AgentHealth, type FailoverConfig, type FailoverEvent, } from './failover.js';
|
|
31
|
+
export { TriggerManager, type TriggerDefinition, type TriggerHandler, } from './trigger-manager.js';
|
|
32
|
+
export { PluginState, HookType, HookRegistry, PluginManager, LoggingPlugin, MetricsPlugin, type PluginMetadata, type HookContext, type HookResult, type HookCallback, type Plugin, type PluginInfo, } from './plugins.js';
|
|
33
|
+
export { TemplateCategory, TemplateRegistry, WorkflowTemplate, HELLO_TEMPLATE, BUILTIN_TEMPLATES, type TemplateMetadata, type TemplateVariable, } from './templates.js';
|
|
34
|
+
export { loadConfig, type MarktoflowConfig } from './config.js';
|
|
35
|
+
export { RollbackStrategy, RollbackStatus, RollbackRegistry, DefaultCompensationHandler, TransactionContext, FileCompensationHandler, GitCompensationHandler, type RollbackAction, type RollbackResult, type CompensationHandler, } from './rollback.js';
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,UAAU,EACV,cAAc,EACd,WAAW,EAEX,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,cAAc,EAEd,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,OAAO,EACP,eAAe,EACf,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,yBAAyB,EACzB,0BAA0B,EAC1B,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,cAAc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KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,QAAQ,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @marktoflow/core
|
|
3
|
+
*
|
|
4
|
+
* Core engine for marktoflow v2.0 - parser, executor, state management.
|
|
5
|
+
*/
|
|
6
|
+
// Models
|
|
7
|
+
export {
|
|
8
|
+
// Enums
|
|
9
|
+
StepStatus, WorkflowStatus, TriggerType,
|
|
10
|
+
// Schemas (for validation)
|
|
11
|
+
WorkflowMetadataSchema, ToolConfigSchema, ErrorHandlingSchema, WorkflowStepSchema, TriggerSchema, WorkflowInputSchema, WorkflowSchema,
|
|
12
|
+
// Helpers
|
|
13
|
+
createExecutionContext, createStepResult, } from './models.js';
|
|
14
|
+
// Env
|
|
15
|
+
export { findEnvFiles, findProjectRoot, loadEnv, ensureEnvLoaded, getEnv, getEnvBool, getEnvInt, getEnvFloat, getEnvList, EnvConfig, config, } from './env.js';
|
|
16
|
+
// Credentials
|
|
17
|
+
export { EncryptionBackend, CredentialType, EncryptionError, KeyNotFoundError, CredentialNotFoundError, FernetEncryptor, AgeEncryptor, GPGEncryptor, InMemoryCredentialStore, SQLiteCredentialStore, CredentialManager, KeyManager, createCredentialManager, getAvailableBackends, } from './credentials.js';
|
|
18
|
+
// Parser
|
|
19
|
+
export { parseFile, parseContent, extractVariableReferences, validateVariableReferences, ParseError, } from './parser.js';
|
|
20
|
+
// Engine
|
|
21
|
+
export { WorkflowEngine, RetryPolicy, CircuitBreaker, resolveTemplates, } from './engine.js';
|
|
22
|
+
// Tool Registry
|
|
23
|
+
export { ToolRegistry, } from './tool-registry.js';
|
|
24
|
+
export { ToolType, ToolCompatibility, } from './tool-base.js';
|
|
25
|
+
// Tool Implementations
|
|
26
|
+
export { OpenAPITool } from './tools/openapi-tool.js';
|
|
27
|
+
export { CustomTool, operation as customOperation } from './tools/custom-tool.js';
|
|
28
|
+
export { MCPTool } from './tools/mcp-tool.js';
|
|
29
|
+
// Bundle support
|
|
30
|
+
export { WorkflowBundle, BundleToolRegistry, loadBundleConfig, } from './bundle.js';
|
|
31
|
+
// SDK Registry
|
|
32
|
+
export { SDKRegistry, defaultSDKLoader, defaultInitializers, createSDKStepExecutor, } from './sdk-registry.js';
|
|
33
|
+
// State Persistence
|
|
34
|
+
export { StateStore, } from './state.js';
|
|
35
|
+
// Execution Logging
|
|
36
|
+
export { LogLevel, ExecutionLogger, createExecutionLog, addLogEntry, completeLog, logToMarkdown, } from './logging.js';
|
|
37
|
+
// Scheduler
|
|
38
|
+
export { Scheduler, CronParser, createJob, } from './scheduler.js';
|
|
39
|
+
// Webhook Receiver
|
|
40
|
+
export { WebhookReceiver, verifyGitHubSignature, verifyHmacSignature, verifySlackSignature, generateSignature, createEndpoint, parseWebhookBody, } from './webhook.js';
|
|
41
|
+
// MCP Loader
|
|
42
|
+
export { McpLoader, } from './mcp-loader.js';
|
|
43
|
+
// Script Tool
|
|
44
|
+
export { ScriptTool, } from './script-tool.js';
|
|
45
|
+
// File Watcher Trigger
|
|
46
|
+
export { FileWatcher, } from './filewatcher.js';
|
|
47
|
+
// Queue Integration
|
|
48
|
+
export { MessagePriority, MessageStatus, MessageQueue, InMemoryQueue, RedisQueue, RabbitMQQueue, WorkflowQueueManager, } from './queue.js';
|
|
49
|
+
// Security (RBAC, Approval, Audit)
|
|
50
|
+
export { Permission, RBACManager, ApprovalStatus, ApprovalManager, AuditEventType, AuditLogger, SQLiteAuditStore, InMemoryAuditStore, } from './security.js';
|
|
51
|
+
// Cost Tracking
|
|
52
|
+
export { DEFAULT_PRICING, CostStore, CostTracker, PersistentCostTracker, PricingRegistry, WorkflowCostEstimator, LoggingAlertHandler, CallbackAlertHandler, CostAlertLevel, CostUnit, } from './costs.js';
|
|
53
|
+
// Metrics
|
|
54
|
+
export { MetricsCollector, } from './metrics.js';
|
|
55
|
+
// Routing
|
|
56
|
+
export { SelectionStrategy, RoutingDecision, AgentSelector, AgentRouter, BudgetTracker, PREDEFINED_PROFILES, createDefaultSelector, createCostOptimizedSelector, createQualityOptimizedSelector, } from './routing.js';
|
|
57
|
+
// Failover
|
|
58
|
+
export { FailoverReason, AgentHealthTracker, DEFAULT_FAILOVER_CONFIG, } from './failover.js';
|
|
59
|
+
// Trigger Manager
|
|
60
|
+
export { TriggerManager, } from './trigger-manager.js';
|
|
61
|
+
// Plugins
|
|
62
|
+
export { PluginState, HookType, HookRegistry, PluginManager, LoggingPlugin, MetricsPlugin, } from './plugins.js';
|
|
63
|
+
// Templates
|
|
64
|
+
export { TemplateCategory, TemplateRegistry, WorkflowTemplate, HELLO_TEMPLATE, BUILTIN_TEMPLATES, } from './templates.js';
|
|
65
|
+
// Config
|
|
66
|
+
export { loadConfig } from './config.js';
|
|
67
|
+
// Rollback
|
|
68
|
+
export { RollbackStrategy, RollbackStatus, RollbackRegistry, DefaultCompensationHandler, TransactionContext, FileCompensationHandler, GitCompensationHandler, } from './rollback.js';
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS;AACT,OAAO;AACL,QAAQ;AACR,UAAU,EACV,cAAc,EACd,WAAW;AACX,2BAA2B;AAC3B,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,cAAc;AAYd,UAAU;AACV,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,MAAM;AACN,OAAO,EACL,YAAY,EACZ,eAAe,EACf,OAAO,EACP,eAAe,EACf,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,cAAc;AACd,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,uBAAuB,EACvB,oBAAoB,GAIrB,MAAM,kBAAkB,CAAC;AAE1B,SAAS;AACT,OAAO,EACL,SAAS,EACT,YAAY,EACZ,yBAAyB,EACzB,0BAA0B,EAC1B,UAAU,GAGX,MAAM,aAAa,CAAC;AAErB,SAAS;AACT,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,gB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
|
|
2
|
+
* Execution logging for marktoflow v2.0
|
|
3
|
+
*
|
|
4
|
+
* Provides structured markdown logging for workflow executions.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LogLevel: {
|
|
7
|
+
readonly DEBUG: "debug";
|
|
8
|
+
readonly INFO: "info";
|
|
9
|
+
readonly WARNING: "warning";
|
|
10
|
+
readonly ERROR: "error";
|
|
11
|
+
readonly CRITICAL: "critical";
|
|
12
|
+
};
|
|
13
|
+
export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
14
|
+
export interface LogEntry {
|
|
15
|
+
timestamp: Date;
|
|
16
|
+
level: LogLevel;
|
|
17
|
+
message: string;
|
|
18
|
+
stepName: string | undefined;
|
|
19
|
+
stepIndex: number | undefined;
|
|
20
|
+
details: Record<string, unknown> | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface ExecutionLog {
|
|
23
|
+
runId: string;
|
|
24
|
+
workflowId: string;
|
|
25
|
+
workflowName: string;
|
|
26
|
+
startedAt: Date;
|
|
27
|
+
completedAt: Date | null;
|
|
28
|
+
entries: LogEntry[];
|
|
29
|
+
success: boolean | null;
|
|
30
|
+
error: string | null;
|
|
31
|
+
inputs: Record<string, unknown> | null;
|
|
32
|
+
outputs: Record<string, unknown> | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function createExecutionLog(runId: string, workflowId: string, workflowName: string, inputs?: Record<string, unknown>): ExecutionLog;
|
|
35
|
+
export declare function addLogEntry(log: ExecutionLog, level: LogLevel, message: string, options?: {
|
|
36
|
+
stepName?: string;
|
|
37
|
+
stepIndex?: number;
|
|
38
|
+
details?: Record<string, unknown>;
|
|
39
|
+
}): void;
|
|
40
|
+
export declare function completeLog(log: ExecutionLog, success: boolean, outputs?: Record<string, unknown>, error?: string): void;
|
|
41
|
+
export declare function logToMarkdown(log: ExecutionLog): string;
|
|
42
|
+
export declare class ExecutionLogger {
|
|
43
|
+
private logsDir;
|
|
44
|
+
private activeLogs;
|
|
45
|
+
constructor(logsDir?: string);
|
|
46
|
+
private ensureDir;
|
|
47
|
+
startLog(runId: string, workflowId: string, workflowName: string, inputs?: Record<string, unknown>): ExecutionLog;
|
|
48
|
+
getLog(runId: string): ExecutionLog | undefined;
|
|
49
|
+
log(runId: string, level: LogLevel, message: string, options?: {
|
|
50
|
+
stepName?: string;
|
|
51
|
+
stepIndex?: number;
|
|
52
|
+
details?: Record<string, unknown>;
|
|
53
|
+
}): void;
|
|
54
|
+
finishLog(runId: string, success: boolean, outputs?: Record<string, unknown>, error?: string): Promise<string | null>;
|
|
55
|
+
listLogs(options?: {
|
|
56
|
+
workflowId?: string;
|
|
57
|
+
limit?: number;
|
|
58
|
+
}): Promise<string[]>;
|
|
59
|
+
readLog(filepath: string): Promise<string>;
|
|
60
|
+
cleanupLogs(retentionDays?: number): Promise<number>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,eAAO,MAAM,QAAQ;;;;;;CAMX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAEhE,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI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EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,YAAY;IASf,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI/C,GAAG,CACD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,GACA,IAAI;IAOD,SAAS,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA2BnB,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAoBf,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C,WAAW,CAAC,aAAa,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CA4B/D"}
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution logging for marktoflow v2.0
|
|
3
|
+
*
|
|
4
|
+
* Provides structured markdown logging for workflow executions.
|
|
5
|
+
*/
|
|
6
|
+
import { writeFile, mkdir, readdir, readFile, unlink } from 'node:fs/promises';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Types
|
|
11
|
+
// ============================================================================
|
|
12
|
+
export const LogLevel = {
|
|
13
|
+
DEBUG: 'debug',
|
|
14
|
+
INFO: 'info',
|
|
15
|
+
WARNING: 'warning',
|
|
16
|
+
ERROR: 'error',
|
|
17
|
+
CRITICAL: 'critical',
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Log Entry Formatting
|
|
21
|
+
// ============================================================================
|
|
22
|
+
const LEVEL_ICONS = {
|
|
23
|
+
[LogLevel.DEBUG]: '🔍',
|
|
24
|
+
[LogLevel.INFO]: 'ℹ️',
|
|
25
|
+
[LogLevel.WARNING]: '⚠️',
|
|
26
|
+
[LogLevel.ERROR]: '❌',
|
|
27
|
+
[LogLevel.CRITICAL]: '🔥',
|
|
28
|
+
};
|
|
29
|
+
function formatLogEntry(entry) {
|
|
30
|
+
const timeStr = entry.timestamp.toTimeString().slice(0, 8);
|
|
31
|
+
const icon = LEVEL_ICONS[entry.level] || '•';
|
|
32
|
+
let line = `- \`${timeStr}\` ${icon} `;
|
|
33
|
+
if (entry.stepName) {
|
|
34
|
+
line += `**[${entry.stepName}]** `;
|
|
35
|
+
}
|
|
36
|
+
line += entry.message;
|
|
37
|
+
if (entry.details) {
|
|
38
|
+
line += '\n';
|
|
39
|
+
for (const [key, value] of Object.entries(entry.details)) {
|
|
40
|
+
line += ` - ${key}: \`${JSON.stringify(value)}\`\n`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return line;
|
|
44
|
+
}
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// ExecutionLog Implementation
|
|
47
|
+
// ============================================================================
|
|
48
|
+
export function createExecutionLog(runId, workflowId, workflowName, inputs) {
|
|
49
|
+
return {
|
|
50
|
+
runId,
|
|
51
|
+
workflowId,
|
|
52
|
+
workflowName,
|
|
53
|
+
startedAt: new Date(),
|
|
54
|
+
completedAt: null,
|
|
55
|
+
entries: [],
|
|
56
|
+
success: null,
|
|
57
|
+
error: null,
|
|
58
|
+
inputs: inputs || null,
|
|
59
|
+
outputs: null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function addLogEntry(log, level, message, options) {
|
|
63
|
+
log.entries.push({
|
|
64
|
+
timestamp: new Date(),
|
|
65
|
+
level,
|
|
66
|
+
message,
|
|
67
|
+
stepName: options?.stepName,
|
|
68
|
+
stepIndex: options?.stepIndex,
|
|
69
|
+
details: options?.details,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function completeLog(log, success, outputs, error) {
|
|
73
|
+
log.completedAt = new Date();
|
|
74
|
+
log.success = success;
|
|
75
|
+
log.outputs = outputs || null;
|
|
76
|
+
log.error = error || null;
|
|
77
|
+
}
|
|
78
|
+
export function logToMarkdown(log) {
|
|
79
|
+
const lines = [];
|
|
80
|
+
// Header
|
|
81
|
+
lines.push(`# Execution Log: ${log.workflowName}`);
|
|
82
|
+
lines.push('');
|
|
83
|
+
lines.push(`**Run ID:** \`${log.runId}\``);
|
|
84
|
+
lines.push(`**Workflow:** \`${log.workflowId}\``);
|
|
85
|
+
lines.push(`**Started:** ${log.startedAt.toISOString()}`);
|
|
86
|
+
if (log.completedAt) {
|
|
87
|
+
lines.push(`**Completed:** ${log.completedAt.toISOString()}`);
|
|
88
|
+
const duration = log.completedAt.getTime() - log.startedAt.getTime();
|
|
89
|
+
lines.push(`**Duration:** ${duration}ms`);
|
|
90
|
+
}
|
|
91
|
+
if (log.success !== null) {
|
|
92
|
+
lines.push(`**Status:** ${log.success ? '✅ Success' : '❌ Failed'}`);
|
|
93
|
+
}
|
|
94
|
+
if (log.error) {
|
|
95
|
+
lines.push(`**Error:** ${log.error}`);
|
|
96
|
+
}
|
|
97
|
+
lines.push('');
|
|
98
|
+
// Inputs
|
|
99
|
+
if (log.inputs && Object.keys(log.inputs).length > 0) {
|
|
100
|
+
lines.push('## Inputs');
|
|
101
|
+
lines.push('');
|
|
102
|
+
lines.push('```json');
|
|
103
|
+
lines.push(JSON.stringify(log.inputs, null, 2));
|
|
104
|
+
lines.push('```');
|
|
105
|
+
lines.push('');
|
|
106
|
+
}
|
|
107
|
+
// Log entries
|
|
108
|
+
lines.push('## Execution Log');
|
|
109
|
+
lines.push('');
|
|
110
|
+
for (const entry of log.entries) {
|
|
111
|
+
lines.push(formatLogEntry(entry));
|
|
112
|
+
}
|
|
113
|
+
lines.push('');
|
|
114
|
+
// Outputs
|
|
115
|
+
if (log.outputs && Object.keys(log.outputs).length > 0) {
|
|
116
|
+
lines.push('## Outputs');
|
|
117
|
+
lines.push('');
|
|
118
|
+
lines.push('```json');
|
|
119
|
+
lines.push(JSON.stringify(log.outputs, null, 2));
|
|
120
|
+
lines.push('```');
|
|
121
|
+
lines.push('');
|
|
122
|
+
}
|
|
123
|
+
return lines.join('\n');
|
|
124
|
+
}
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// ExecutionLogger (File-based)
|
|
127
|
+
// ============================================================================
|
|
128
|
+
export class ExecutionLogger {
|
|
129
|
+
logsDir;
|
|
130
|
+
activeLogs = new Map();
|
|
131
|
+
constructor(logsDir = '.marktoflow/state/execution-logs') {
|
|
132
|
+
this.logsDir = logsDir;
|
|
133
|
+
}
|
|
134
|
+
async ensureDir() {
|
|
135
|
+
if (!existsSync(this.logsDir)) {
|
|
136
|
+
await mkdir(this.logsDir, { recursive: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
startLog(runId, workflowId, workflowName, inputs) {
|
|
140
|
+
const log = createExecutionLog(runId, workflowId, workflowName, inputs);
|
|
141
|
+
this.activeLogs.set(runId, log);
|
|
142
|
+
addLogEntry(log, LogLevel.INFO, 'Workflow execution started');
|
|
143
|
+
return log;
|
|
144
|
+
}
|
|
145
|
+
getLog(runId) {
|
|
146
|
+
return this.activeLogs.get(runId);
|
|
147
|
+
}
|
|
148
|
+
log(runId, level, message, options) {
|
|
149
|
+
const log = this.activeLogs.get(runId);
|
|
150
|
+
if (log) {
|
|
151
|
+
addLogEntry(log, level, message, options);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async finishLog(runId, success, outputs, error) {
|
|
155
|
+
const log = this.activeLogs.get(runId);
|
|
156
|
+
if (!log) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
addLogEntry(log, success ? LogLevel.INFO : LogLevel.ERROR, success ? 'Workflow execution completed successfully' : `Workflow execution failed: ${error}`);
|
|
160
|
+
completeLog(log, success, outputs, error);
|
|
161
|
+
// Save to file
|
|
162
|
+
await this.ensureDir();
|
|
163
|
+
const filename = `${log.workflowId}_${runId}_${log.startedAt.toISOString().replace(/[:.]/g, '-')}.md`;
|
|
164
|
+
const filepath = join(this.logsDir, filename);
|
|
165
|
+
const markdown = logToMarkdown(log);
|
|
166
|
+
await writeFile(filepath, markdown, 'utf-8');
|
|
167
|
+
this.activeLogs.delete(runId);
|
|
168
|
+
return filepath;
|
|
169
|
+
}
|
|
170
|
+
async listLogs(options) {
|
|
171
|
+
await this.ensureDir();
|
|
172
|
+
let files = await readdir(this.logsDir);
|
|
173
|
+
files = files.filter((f) => f.endsWith('.md'));
|
|
174
|
+
if (options?.workflowId) {
|
|
175
|
+
files = files.filter((f) => f.startsWith(options.workflowId + '_'));
|
|
176
|
+
}
|
|
177
|
+
// Sort by date (newest first)
|
|
178
|
+
files.sort().reverse();
|
|
179
|
+
if (options?.limit) {
|
|
180
|
+
files = files.slice(0, options.limit);
|
|
181
|
+
}
|
|
182
|
+
return files.map((f) => join(this.logsDir, f));
|
|
183
|
+
}
|
|
184
|
+
async readLog(filepath) {
|
|
185
|
+
return readFile(filepath, 'utf-8');
|
|
186
|
+
}
|
|
187
|
+
async cleanupLogs(retentionDays = 30) {
|
|
188
|
+
await this.ensureDir();
|
|
189
|
+
const cutoffDate = new Date();
|
|
190
|
+
cutoffDate.setDate(cutoffDate.getDate() - retentionDays);
|
|
191
|
+
const files = await readdir(this.logsDir);
|
|
192
|
+
let deleted = 0;
|
|
193
|
+
for (const file of files) {
|
|
194
|
+
if (!file.endsWith('.md'))
|
|
195
|
+
continue;
|
|
196
|
+
const filepath = join(this.logsDir, file);
|
|
197
|
+
const content = await readFile(filepath, 'utf-8');
|
|
198
|
+
// Extract started date from content
|
|
199
|
+
const match = content.match(/\*\*Started:\*\* (.+)/);
|
|
200
|
+
if (match) {
|
|
201
|
+
const startedAt = new Date(match[1]);
|
|
202
|
+
if (startedAt < cutoffDate) {
|
|
203
|
+
await unlink(filepath);
|
|
204
|
+
deleted++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return deleted;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CACZ,CAAC;AA0BX,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,WAAW,GAA6B;IAC5C,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI;IACtB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI;IACrB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI;IACxB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG;IACrB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI;CAC1B,CAAC;AAEF,SAAS,cAAc,CAAC,KAAe;IACrC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AC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC;QAEzD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,SAAS;YAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAElD,oCAAoC;YACpC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACrD,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrC,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;oBAC3B,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACvB,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Loader for marktoflow v2.0
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and connection to MCP servers (both native/in-memory and stdio).
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { ToolConfig } from "./models.js";
|
|
9
|
+
export interface McpModule {
|
|
10
|
+
createMcpServer(config?: Record<string, unknown>): McpServer | Promise<McpServer>;
|
|
11
|
+
}
|
|
12
|
+
export type ModuleLoader = (name: string) => Promise<any>;
|
|
13
|
+
export declare class McpLoader {
|
|
14
|
+
private moduleLoader;
|
|
15
|
+
constructor(moduleLoader?: ModuleLoader);
|
|
16
|
+
/**
|
|
17
|
+
* Connect to a loaded MCP module.
|
|
18
|
+
*/
|
|
19
|
+
connectModule(module: any, config: ToolConfig): Promise<Client>;
|
|
20
|
+
/**
|
|
21
|
+
* Load a native MCP module and connect to it in-memory.
|
|
22
|
+
*/
|
|
23
|
+
loadNative(packageName: string, config: ToolConfig): Promise<Client>;
|
|
24
|
+
/**
|
|
25
|
+
* Connect to an external MCP server via Stdio.
|
|
26
|
+
*/
|
|
27
|
+
connectStdio(command: string, args: string[]): Promise<Client>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=mcp-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-loader.d.ts","sourceRoot":"","sources":["../src/mcp-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,SAAS;IACxB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACnF;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE1D,qBAAa,SAAS;IACpB,OAAO,CAAC,YAAY,CAAe;gBAEvB,YAAY,CAAC,EAAE,YAAY;IAIvC;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBrE;;OAEG;IACG,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAY1E;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAerE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Loader for marktoflow v2.0
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and connection to MCP servers (both native/in-memory and stdio).
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
7
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
8
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
9
|
+
export class McpLoader {
|
|
10
|
+
moduleLoader;
|
|
11
|
+
constructor(moduleLoader) {
|
|
12
|
+
this.moduleLoader = moduleLoader || ((name) => import(name));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Connect to a loaded MCP module.
|
|
16
|
+
*/
|
|
17
|
+
async connectModule(module, config) {
|
|
18
|
+
// Check if it follows the Native MCP Module contract
|
|
19
|
+
if (typeof module.createMcpServer !== 'function') {
|
|
20
|
+
throw new Error(`Module does not export 'createMcpServer' function.`);
|
|
21
|
+
}
|
|
22
|
+
// Create the server instance
|
|
23
|
+
const server = await module.createMcpServer(config.options || {});
|
|
24
|
+
// Create linked in-memory transports
|
|
25
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
26
|
+
// Connect server to transport
|
|
27
|
+
await server.connect(serverTransport);
|
|
28
|
+
// Create and connect client
|
|
29
|
+
const client = new Client({ name: "marktoflow-core", version: "2.0.0" }, { capabilities: {} });
|
|
30
|
+
await client.connect(clientTransport);
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Load a native MCP module and connect to it in-memory.
|
|
35
|
+
*/
|
|
36
|
+
async loadNative(packageName, config) {
|
|
37
|
+
let module;
|
|
38
|
+
try {
|
|
39
|
+
// Dynamic import of the package
|
|
40
|
+
module = await this.moduleLoader(packageName);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new Error(`Failed to import native MCP module '${packageName}': ${error}`);
|
|
44
|
+
}
|
|
45
|
+
return this.connectModule(module, config);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Connect to an external MCP server via Stdio.
|
|
49
|
+
*/
|
|
50
|
+
async connectStdio(command, args) {
|
|
51
|
+
const transport = new StdioClientTransport({
|
|
52
|
+
command,
|
|
53
|
+
args,
|
|
54
|
+
});
|
|
55
|
+
const client = new Client({ name: "marktoflow-core", version: "2.0.0" }, { capabilities: {} });
|
|
56
|
+
await client.connect(transport);
|
|
57
|
+
return client;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=mcp-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-loader.js","sourceRoot":"","sources":["../src/mcp-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAWjF,MAAM,OAAO,SAAS;IACZ,YAAY,CAAe;IAEnC,YAAY,YAA2B;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,MAAW,EAAE,MAAkB;QACjD,qDAAqD;QACrD,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,oDA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CACrB,CAAC;QAEF,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEhC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics collection for marktoflow framework.
|
|
3
|
+
*
|
|
4
|
+
* Provides Prometheus-compatible metrics.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MetricsCollector {
|
|
7
|
+
private registry;
|
|
8
|
+
private workflowsTotal;
|
|
9
|
+
private runningWorkflows;
|
|
10
|
+
private workflowDuration;
|
|
11
|
+
private stepsTotal;
|
|
12
|
+
private stepDuration;
|
|
13
|
+
constructor();
|
|
14
|
+
getMetrics(): Promise<string>;
|
|
15
|
+
workflowStarted(workflowId: string): void;
|
|
16
|
+
workflowCompleted(workflowId: string, status: 'completed' | 'failed', durationMs: number): void;
|
|
17
|
+
stepCompleted(workflowId: string, stepId: string, status: 'completed' | 'failed' | 'skipped', durationMs: number): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAW;IAG3B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAY;;IA0C1B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIzC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAM/F,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;CAIxH"}
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics collection for marktoflow framework.
|
|
3
|
+
*
|
|
4
|
+
* Provides Prometheus-compatible metrics.
|
|
5
|
+
*/
|
|
6
|
+
import { Registry, Counter, Gauge, Histogram, collectDefaultMetrics } from 'prom-client';
|
|
7
|
+
export class MetricsCollector {
|
|
8
|
+
registry;
|
|
9
|
+
// Metrics
|
|
10
|
+
workflowsTotal;
|
|
11
|
+
runningWorkflows;
|
|
12
|
+
workflowDuration;
|
|
13
|
+
stepsTotal;
|
|
14
|
+
stepDuration;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.registry = new Registry();
|
|
17
|
+
collectDefaultMetrics({ register: this.registry, prefix: 'marktoflow_' });
|
|
18
|
+
this.workflowsTotal = new Counter({
|
|
19
|
+
name: 'marktoflow_workflows_total',
|
|
20
|
+
help: 'Total number of workflow executions',
|
|
21
|
+
labelNames: ['workflow_id', 'status'],
|
|
22
|
+
registers: [this.registry],
|
|
23
|
+
});
|
|
24
|
+
this.runningWorkflows = new Gauge({
|
|
25
|
+
name: 'marktoflow_running_workflows',
|
|
26
|
+
help: 'Number of currently running workflows',
|
|
27
|
+
labelNames: ['workflow_id'],
|
|
28
|
+
registers: [this.registry],
|
|
29
|
+
});
|
|
30
|
+
this.workflowDuration = new Histogram({
|
|
31
|
+
name: 'marktoflow_workflow_duration_seconds',
|
|
32
|
+
help: 'Workflow execution duration in seconds',
|
|
33
|
+
labelNames: ['workflow_id', 'status'],
|
|
34
|
+
registers: [this.registry],
|
|
35
|
+
});
|
|
36
|
+
this.stepsTotal = new Counter({
|
|
37
|
+
name: 'marktoflow_steps_total',
|
|
38
|
+
help: 'Total number of step executions',
|
|
39
|
+
labelNames: ['workflow_id', 'step_id', 'status'],
|
|
40
|
+
registers: [this.registry],
|
|
41
|
+
});
|
|
42
|
+
this.stepDuration = new Histogram({
|
|
43
|
+
name: 'marktoflow_step_duration_seconds',
|
|
44
|
+
help: 'Step execution duration in seconds',
|
|
45
|
+
labelNames: ['workflow_id', 'step_id'],
|
|
46
|
+
registers: [this.registry],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async getMetrics() {
|
|
50
|
+
return this.registry.metrics();
|
|
51
|
+
}
|
|
52
|
+
workflowStarted(workflowId) {
|
|
53
|
+
this.runningWorkflows.inc({ workflow_id: workflowId });
|
|
54
|
+
}
|
|
55
|
+
workflowCompleted(workflowId, status, durationMs) {
|
|
56
|
+
this.workflowsTotal.inc({ workflow_id: workflowId, status });
|
|
57
|
+
this.runningWorkflows.dec({ workflow_id: workflowId });
|
|
58
|
+
this.workflowDuration.observe({ workflow_id: workflowId, status }, durationMs / 1000);
|
|
59
|
+
}
|
|
60
|
+
stepCompleted(workflowId, stepId, status, durationMs) {
|
|
61
|
+
this.stepsTotal.inc({ workflow_id: workflowId, step_id: stepId, status });
|
|
62
|
+
this.stepDuration.observe({ workflow_id: workflowId, step_id: stepId }, durationMs / 1000);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzF,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAW;IAE3B,UAAU;IACF,cAAc,CAAU;IACxB,gBAAgB,CAAQ;IACxB,gBAAgB,CAAY;IAC5B,UAAU,CAAU;IACpB,YAAY,CAAY;IAEhC;QACE,IAAI,CAAC,QAAQ,GAAG,I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