@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.
Files changed (125) hide show
  1. package/dist/bundle.d.ts +43 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +202 -0
  4. package/dist/bundle.js.map +1 -0
  5. package/dist/config.d.ts +33 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +27 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/costs.d.ts +182 -0
  10. package/dist/costs.d.ts.map +1 -0
  11. package/dist/costs.js +464 -0
  12. package/dist/costs.js.map +1 -0
  13. package/dist/credentials.d.ts +162 -0
  14. package/dist/credentials.d.ts.map +1 -0
  15. package/dist/credentials.js +646 -0
  16. package/dist/credentials.js.map +1 -0
  17. package/dist/engine.d.ts +137 -0
  18. package/dist/engine.d.ts.map +1 -0
  19. package/dist/engine.js +514 -0
  20. package/dist/engine.js.map +1 -0
  21. package/dist/env.d.ts +59 -0
  22. package/dist/env.d.ts.map +1 -0
  23. package/dist/env.js +256 -0
  24. package/dist/env.js.map +1 -0
  25. package/dist/failover.d.ts +43 -0
  26. package/dist/failover.d.ts.map +1 -0
  27. package/dist/failover.js +53 -0
  28. package/dist/failover.js.map +1 -0
  29. package/dist/filewatcher.d.ts +32 -0
  30. package/dist/filewatcher.d.ts.map +1 -0
  31. package/dist/filewatcher.js +92 -0
  32. package/dist/filewatcher.js.map +1 -0
  33. package/dist/index.d.ts +36 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +69 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/logging.d.ts +62 -0
  38. package/dist/logging.d.ts.map +1 -0
  39. package/dist/logging.js +211 -0
  40. package/dist/logging.js.map +1 -0
  41. package/dist/mcp-loader.d.ts +29 -0
  42. package/dist/mcp-loader.d.ts.map +1 -0
  43. package/dist/mcp-loader.js +60 -0
  44. package/dist/mcp-loader.js.map +1 -0
  45. package/dist/metrics.d.ts +19 -0
  46. package/dist/metrics.d.ts.map +1 -0
  47. package/dist/metrics.js +65 -0
  48. package/dist/metrics.js.map +1 -0
  49. package/dist/models.d.ts +419 -0
  50. package/dist/models.d.ts.map +1 -0
  51. package/dist/models.js +111 -0
  52. package/dist/models.js.map +1 -0
  53. package/dist/parser.d.ts +40 -0
  54. package/dist/parser.d.ts.map +1 -0
  55. package/dist/parser.js +287 -0
  56. package/dist/parser.js.map +1 -0
  57. package/dist/plugins.d.ts +105 -0
  58. package/dist/plugins.d.ts.map +1 -0
  59. package/dist/plugins.js +182 -0
  60. package/dist/plugins.js.map +1 -0
  61. package/dist/queue.d.ts +114 -0
  62. package/dist/queue.d.ts.map +1 -0
  63. package/dist/queue.js +385 -0
  64. package/dist/queue.js.map +1 -0
  65. package/dist/rollback.d.ts +117 -0
  66. package/dist/rollback.d.ts.map +1 -0
  67. package/dist/rollback.js +374 -0
  68. package/dist/rollback.js.map +1 -0
  69. package/dist/routing.d.ts +144 -0
  70. package/dist/routing.d.ts.map +1 -0
  71. package/dist/routing.js +457 -0
  72. package/dist/routing.js.map +1 -0
  73. package/dist/scheduler.d.ts +91 -0
  74. package/dist/scheduler.d.ts.map +1 -0
  75. package/dist/scheduler.js +259 -0
  76. package/dist/scheduler.js.map +1 -0
  77. package/dist/script-tool.d.ts +22 -0
  78. package/dist/script-tool.d.ts.map +1 -0
  79. package/dist/script-tool.js +90 -0
  80. package/dist/script-tool.js.map +1 -0
  81. package/dist/sdk-registry.d.ts +81 -0
  82. package/dist/sdk-registry.d.ts.map +1 -0
  83. package/dist/sdk-registry.js +264 -0
  84. package/dist/sdk-registry.js.map +1 -0
  85. package/dist/security.d.ts +155 -0
  86. package/dist/security.d.ts.map +1 -0
  87. package/dist/security.js +362 -0
  88. package/dist/security.js.map +1 -0
  89. package/dist/state.d.ts +67 -0
  90. package/dist/state.d.ts.map +1 -0
  91. package/dist/state.js +276 -0
  92. package/dist/state.js.map +1 -0
  93. package/dist/templates.d.ts +70 -0
  94. package/dist/templates.d.ts.map +1 -0
  95. package/dist/templates.js +244 -0
  96. package/dist/templates.js.map +1 -0
  97. package/dist/tool-base.d.ts +54 -0
  98. package/dist/tool-base.d.ts.map +1 -0
  99. package/dist/tool-base.js +43 -0
  100. package/dist/tool-base.js.map +1 -0
  101. package/dist/tool-registry.d.ts +24 -0
  102. package/dist/tool-registry.d.ts.map +1 -0
  103. package/dist/tool-registry.js +164 -0
  104. package/dist/tool-registry.js.map +1 -0
  105. package/dist/tools/custom-tool.d.ts +16 -0
  106. package/dist/tools/custom-tool.d.ts.map +1 -0
  107. package/dist/tools/custom-tool.js +85 -0
  108. package/dist/tools/custom-tool.js.map +1 -0
  109. package/dist/tools/mcp-tool.d.ts +16 -0
  110. package/dist/tools/mcp-tool.d.ts.map +1 -0
  111. package/dist/tools/mcp-tool.js +98 -0
  112. package/dist/tools/mcp-tool.js.map +1 -0
  113. package/dist/tools/openapi-tool.d.ts +17 -0
  114. package/dist/tools/openapi-tool.d.ts.map +1 -0
  115. package/dist/tools/openapi-tool.js +165 -0
  116. package/dist/tools/openapi-tool.js.map +1 -0
  117. package/dist/trigger-manager.d.ts +26 -0
  118. package/dist/trigger-manager.d.ts.map +1 -0
  119. package/dist/trigger-manager.js +107 -0
  120. package/dist/trigger-manager.js.map +1 -0
  121. package/dist/webhook.d.ts +95 -0
  122. package/dist/webhook.d.ts.map +1 -0
  123. package/dist/webhook.js +261 -0
  124. package/dist/webhook.js.map +1 -0
  125. package/package.json +60 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Tool base types for marktoflow.
3
+ */
4
+ export declare enum ToolType {
5
+ MCP = "mcp",
6
+ OPENAPI = "openapi",
7
+ CUSTOM = "custom"
8
+ }
9
+ export declare enum ToolCompatibility {
10
+ NATIVE = "native",
11
+ SUPPORTED = "supported",
12
+ VIA_BRIDGE = "via_bridge",
13
+ NOT_SUPPORTED = "not_supported"
14
+ }
15
+ export interface ToolImplementation {
16
+ type: ToolType;
17
+ priority: number;
18
+ configPath?: string;
19
+ specPath?: string;
20
+ specUrl?: string;
21
+ adapterPath?: string;
22
+ packageName?: string;
23
+ agentCompatibility?: Record<string, string>;
24
+ }
25
+ export interface ToolAuth {
26
+ type: string;
27
+ tokenEnv?: string;
28
+ scopes?: string[];
29
+ provider?: string;
30
+ extra?: Record<string, unknown>;
31
+ }
32
+ export interface ToolDefinition {
33
+ name: string;
34
+ description?: string;
35
+ category?: string;
36
+ implementations: ToolImplementation[];
37
+ authentication?: ToolAuth;
38
+ rateLimits?: Record<string, unknown>;
39
+ }
40
+ export declare abstract class Tool {
41
+ readonly definition: ToolDefinition;
42
+ readonly implementation: ToolImplementation;
43
+ protected initialized: boolean;
44
+ constructor(definition: ToolDefinition, implementation: ToolImplementation);
45
+ get name(): string;
46
+ get toolType(): ToolType;
47
+ abstract initialize(): Promise<void>;
48
+ abstract execute(operation: string, params: Record<string, unknown>): Promise<unknown>;
49
+ abstract listOperations(): string[];
50
+ abstract getOperationSchema(operation: string): Record<string, unknown>;
51
+ shutdown(): Promise<void>;
52
+ toFunctionSchema(operation: string): Record<string, unknown>;
53
+ }
54
+ //# sourceMappingURL=tool-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-base.d.ts","sourceRoot":"","sources":["../src/tool-base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,QAAQ;IAClB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,aAAa,kBAAkB;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WA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I,OAAO,CAAC,IAAI,CAAC;IAI/B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQ7D"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Tool base types for marktoflow.
3
+ */
4
+ export var ToolType;
5
+ (function (ToolType) {
6
+ ToolType["MCP"] = "mcp";
7
+ ToolType["OPENAPI"] = "openapi";
8
+ ToolType["CUSTOM"] = "custom";
9
+ })(ToolType || (ToolType = {}));
10
+ export var ToolCompatibility;
11
+ (function (ToolCompatibility) {
12
+ ToolCompatibility["NATIVE"] = "native";
13
+ ToolCompatibility["SUPPORTED"] = "supported";
14
+ ToolCompatibility["VIA_BRIDGE"] = "via_bridge";
15
+ ToolCompatibility["NOT_SUPPORTED"] = "not_supported";
16
+ })(ToolCompatibility || (ToolCompatibility = {}));
17
+ export class Tool {
18
+ definition;
19
+ implementation;
20
+ initialized = false;
21
+ constructor(definition, implementation) {
22
+ this.definition = definition;
23
+ this.implementation = implementation;
24
+ }
25
+ get name() {
26
+ return this.definition.name;
27
+ }
28
+ get toolType() {
29
+ return this.implementation.type;
30
+ }
31
+ async shutdown() {
32
+ this.initialized = false;
33
+ }
34
+ toFunctionSchema(operation) {
35
+ const schema = this.getOperationSchema(operation);
36
+ return {
37
+ name: `${this.name}.${operation}`,
38
+ description: schema?.description ?? '',
39
+ parameters: schema?.parameters ?? {},
40
+ };
41
+ }
42
+ }
43
+ //# sourceMappingURL=tool-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-base.js","sourceRoot":"","sources":["../src/tool-base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;AACnB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;IACzB,oDAA+B,CAAA;AACjC,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AA8BD,MAAM,OAAgB,IAAI;IAGI;IAA4C;IAF9D,WAAW,GAAG,KAAK,CAAC;IAE9B,YAA4B,UAA0B,EAAkB,cAAkC;QAA9E,eAAU,GAAV,UAAU,CAAgB;QAAkB,mBAAc,GAAd,cAAc,CAAoB;IAAG,CAAC;IAE9G,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IAClC,CAAC;IAOD,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,gBAAgB,CAAC,SAAiB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAQ,CAAC;QACzD,OAAO;YACL,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE;YACjC,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE;YACtC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,EAAE;SACrC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Tool registry for marktoflow.
3
+ *
4
+ * Manages tool discovery, registration, and selection based on agent compatibility.
5
+ */
6
+ import { Tool, ToolDefinition } from './tool-base.js';
7
+ export declare class ToolRegistry {
8
+ private definitions;
9
+ private tools;
10
+ private registryPath;
11
+ constructor(registryPath?: string);
12
+ loadRegistry(path: string): void;
13
+ private parseToolDefinition;
14
+ register(definition: ToolDefinition): void;
15
+ hasTool(name: string, agent?: string): boolean;
16
+ getTool(name: string, agent: string): Tool | null;
17
+ listTools(): string[];
18
+ listCompatibleTools(agent: string): string[];
19
+ getDefinition(name: string): ToolDefinition | null;
20
+ getAllFunctionSchemas(agent: string): Array<Record<string, unknown>>;
21
+ private getBestImplementation;
22
+ private createTool;
23
+ }
24
+ //# sourceMappingURL=tool-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../src/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACL,IAAI,EACJ,cAAc,EAKf,MAAM,gBAAgB,CAAC;AAKxB,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,YAAY,CAAqB;gBAE7B,YAAY,CAAC,EAAE,MAAM;IAOjC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAShC,OAAO,CAAC,mBAAmB;IAyC3B,QAAQ,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;IAI1C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAO9C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAgBjD,SAAS,IAAI,MAAM,EAAE;IAIrB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAU5C,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAIlD,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAYpE,OAAO,CAAC,qBAAqB;IAyB7B,OAAO,CAAC,UAAU;CASnB"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Tool registry for marktoflow.
3
+ *
4
+ * Manages tool discovery, registration, and selection based on agent compatibility.
5
+ */
6
+ import { readFileSync } from 'node:fs';
7
+ import { resolve } from 'node:path';
8
+ import { parse } from 'yaml';
9
+ import { ToolCompatibility, ToolType, } from './tool-base.js';
10
+ import { OpenAPITool } from './tools/openapi-tool.js';
11
+ import { CustomTool } from './tools/custom-tool.js';
12
+ import { MCPTool } from './tools/mcp-tool.js';
13
+ export class ToolRegistry {
14
+ definitions = new Map();
15
+ tools = new Map();
16
+ registryPath;
17
+ constructor(registryPath) {
18
+ this.registryPath = registryPath ? resolve(registryPath) : undefined;
19
+ if (this.registryPath) {
20
+ this.loadRegistry(this.registryPath);
21
+ }
22
+ }
23
+ loadRegistry(path) {
24
+ const content = readFileSync(path, 'utf8');
25
+ const data = parse(content);
26
+ for (const toolData of data.tools ?? []) {
27
+ const definition = this.parseToolDefinition(toolData);
28
+ this.definitions.set(definition.name, definition);
29
+ }
30
+ }
31
+ parseToolDefinition(data) {
32
+ const implementations = data.implementations ?? [];
33
+ const parsedImplementations = implementations.map((impl) => {
34
+ const result = {
35
+ type: impl.type ?? ToolType.CUSTOM,
36
+ priority: impl.priority ?? 1,
37
+ agentCompatibility: impl.agent_compatibility ?? {},
38
+ };
39
+ if (impl.config_path)
40
+ result.configPath = impl.config_path;
41
+ if (impl.spec_path)
42
+ result.specPath = impl.spec_path;
43
+ if (impl.spec_url)
44
+ result.specUrl = impl.spec_url;
45
+ if (impl.adapter_path)
46
+ result.adapterPath = impl.adapter_path;
47
+ if (impl.package)
48
+ result.packageName = impl.package;
49
+ return result;
50
+ });
51
+ const authData = data.authentication ?? {};
52
+ let auth;
53
+ if (authData && Object.keys(authData).length) {
54
+ auth = {
55
+ type: authData.type ?? 'none',
56
+ scopes: authData.scopes ?? [],
57
+ extra: authData.extra ?? {},
58
+ };
59
+ if (authData.token_env)
60
+ auth.tokenEnv = authData.token_env;
61
+ if (authData.provider)
62
+ auth.provider = authData.provider;
63
+ }
64
+ const result = {
65
+ name: data.name ?? '',
66
+ implementations: parsedImplementations,
67
+ rateLimits: data.rate_limits ?? {},
68
+ };
69
+ if (data.description)
70
+ result.description = data.description;
71
+ if (data.category)
72
+ result.category = data.category;
73
+ if (auth)
74
+ result.authentication = auth;
75
+ return result;
76
+ }
77
+ register(definition) {
78
+ this.definitions.set(definition.name, definition);
79
+ }
80
+ hasTool(name, agent) {
81
+ const definition = this.definitions.get(name);
82
+ if (!definition)
83
+ return false;
84
+ if (!agent)
85
+ return true;
86
+ return this.getBestImplementation(definition, agent) !== null;
87
+ }
88
+ getTool(name, agent) {
89
+ const cached = this.tools.get(name)?.get(agent);
90
+ if (cached)
91
+ return cached;
92
+ const definition = this.definitions.get(name);
93
+ if (!definition)
94
+ return null;
95
+ const implementation = this.getBestImplementation(definition, agent);
96
+ if (!implementation)
97
+ return null;
98
+ const tool = this.createTool(definition, implementation);
99
+ if (!this.tools.has(name))
100
+ this.tools.set(name, new Map());
101
+ this.tools.get(name).set(agent, tool);
102
+ return tool;
103
+ }
104
+ listTools() {
105
+ return Array.from(this.definitions.keys());
106
+ }
107
+ listCompatibleTools(agent) {
108
+ const compatible = [];
109
+ for (const [name, definition] of this.definitions.entries()) {
110
+ if (this.getBestImplementation(definition, agent)) {
111
+ compatible.push(name);
112
+ }
113
+ }
114
+ return compatible;
115
+ }
116
+ getDefinition(name) {
117
+ return this.definitions.get(name) ?? null;
118
+ }
119
+ getAllFunctionSchemas(agent) {
120
+ const schemas = [];
121
+ for (const name of this.listCompatibleTools(agent)) {
122
+ const tool = this.getTool(name, agent);
123
+ if (!tool)
124
+ continue;
125
+ for (const op of tool.listOperations()) {
126
+ schemas.push(tool.toFunctionSchema(op));
127
+ }
128
+ }
129
+ return schemas;
130
+ }
131
+ getBestImplementation(definition, agent) {
132
+ const compatible = definition.implementations.filter((impl) => {
133
+ const compat = impl.agentCompatibility?.[agent] ?? 'supported';
134
+ return !['not_supported', 'none'].includes(compat);
135
+ });
136
+ if (compatible.length === 0)
137
+ return null;
138
+ const compatOrder = {
139
+ [ToolCompatibility.NATIVE]: 0,
140
+ [ToolCompatibility.SUPPORTED]: 1,
141
+ [ToolCompatibility.VIA_BRIDGE]: 2,
142
+ };
143
+ compatible.sort((a, b) => {
144
+ const aCompat = a.agentCompatibility?.[agent] ?? ToolCompatibility.SUPPORTED;
145
+ const bCompat = b.agentCompatibility?.[agent] ?? ToolCompatibility.SUPPORTED;
146
+ const aScore = compatOrder[aCompat] ?? 3;
147
+ const bScore = compatOrder[bCompat] ?? 3;
148
+ if (a.priority !== b.priority)
149
+ return a.priority - b.priority;
150
+ return aScore - bScore;
151
+ });
152
+ return compatible[0];
153
+ }
154
+ createTool(definition, implementation) {
155
+ if (implementation.type === ToolType.MCP) {
156
+ return new MCPTool(definition, implementation);
157
+ }
158
+ if (implementation.type === ToolType.OPENAPI) {
159
+ return new OpenAPITool(definition, implementation);
160
+ }
161
+ return new CustomTool(definition, implementation);
162
+ }
163
+ }
164
+ //# sourceMappingURL=tool-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../src/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAIL,iBAAiB,EACjB,QAAQ,GAET,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,OAAO,YAAY;IACf,WAAW,GAAG,IAAI,GAAG,EAA0B,CAAC;IAChD,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC7C,YAAY,CAAqB;IAEzC,YAAY,YAAqB;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrE,IAAI,IAAI,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;QACD,OAAO,IAAI,UAAU,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Custom tool implementation using JS/TS adapters.
3
+ */
4
+ import { Tool, ToolDefinition, ToolImplementation } from '../tool-base.js';
5
+ export declare class CustomTool extends Tool {
6
+ private adapter;
7
+ private operations;
8
+ constructor(definition: ToolDefinition, implementation: ToolImplementation);
9
+ initialize(): Promise<void>;
10
+ private discoverOperations;
11
+ execute(operation: string, params: Record<string, unknown>): Promise<unknown>;
12
+ listOperations(): string[];
13
+ getOperationSchema(operation: string): Record<string, unknown>;
14
+ }
15
+ export declare function operation<T extends (...args: any[]) => any>(fn: T): T;
16
+ //# sourceMappingURL=custom-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-tool.d.ts","sourceRoot":"","sources":["../../src/tools/custom-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,UAAU,CAAgF;gBAEtF,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB;IAIpE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBjC,OAAO,CAAC,kBAAkB;IAoBpB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAUnF,cAAc,IAAI,MAAM,EAAE;IAI1B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAY/D;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAGrE"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Custom tool implementation using JS/TS adapters.
3
+ */
4
+ import { pathToFileURL } from 'node:url';
5
+ import { resolve } from 'node:path';
6
+ import { Tool } from '../tool-base.js';
7
+ export class CustomTool extends Tool {
8
+ adapter = null;
9
+ operations = {};
10
+ constructor(definition, implementation) {
11
+ super(definition, implementation);
12
+ }
13
+ async initialize() {
14
+ if (this.initialized)
15
+ return;
16
+ if (!this.implementation.adapterPath) {
17
+ throw new Error(`Custom tool requires adapterPath for ${this.definition.name}`);
18
+ }
19
+ const adapterPath = resolve(this.implementation.adapterPath);
20
+ const module = await import(pathToFileURL(adapterPath).href);
21
+ if (module.Adapter) {
22
+ this.adapter = new module.Adapter();
23
+ }
24
+ else if (module.default) {
25
+ this.adapter = module.default;
26
+ }
27
+ else {
28
+ this.adapter = module;
29
+ }
30
+ this.discoverOperations();
31
+ this.initialized = true;
32
+ }
33
+ discoverOperations() {
34
+ if (!this.adapter)
35
+ return;
36
+ for (const name of Object.getOwnPropertyNames(Object.getPrototypeOf(this.adapter))) {
37
+ if (name === 'constructor')
38
+ continue;
39
+ if (name.startsWith('op_')) {
40
+ const method = this.adapter[name].bind(this.adapter);
41
+ this.operations[name.slice(3)] = { method, description: method.description ?? '' };
42
+ }
43
+ else if (this.adapter[name]?._isOperation) {
44
+ const method = this.adapter[name].bind(this.adapter);
45
+ this.operations[name] = { method, description: method.description ?? '' };
46
+ }
47
+ }
48
+ if (this.adapter.operations && typeof this.adapter.operations === 'object') {
49
+ for (const [name, method] of Object.entries(this.adapter.operations)) {
50
+ this.operations[name] = { method: method, description: method?.description ?? '' };
51
+ }
52
+ }
53
+ }
54
+ async execute(operation, params) {
55
+ if (!this.initialized)
56
+ await this.initialize();
57
+ const op = this.operations[operation];
58
+ if (!op) {
59
+ throw new Error(`Unknown operation: ${operation}`);
60
+ }
61
+ const result = op.method(params);
62
+ return await Promise.resolve(result);
63
+ }
64
+ listOperations() {
65
+ return Object.keys(this.operations);
66
+ }
67
+ getOperationSchema(operation) {
68
+ const op = this.operations[operation];
69
+ if (!op)
70
+ return {};
71
+ return {
72
+ description: op.description ?? '',
73
+ parameters: {
74
+ type: 'object',
75
+ properties: {},
76
+ required: [],
77
+ },
78
+ };
79
+ }
80
+ }
81
+ export function operation(fn) {
82
+ fn._isOperation = true;
83
+ return fn;
84
+ }
85
+ //# sourceMappingURL=custom-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-tool.js","sourceRoot":"","sources":["../../src/tools/custom-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAsC,MAAM,iBAAiB,CAAC;AAE3E,MAAM,OAAO,UAAW,SAAQ,IAAI;IAC1B,OAAO,GAAQ,IAAI,CAAC;IACpB,UAAU,GAA6E,EAAE,CAAC;IAElG,YAAY,UAA0B,EAAE,cAAkC;QACxE,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAC7B,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,CAA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C,EAAK;IAC/D,EAAU,CAAC,YAAY,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * MCP tool implementation (minimal adapter).
3
+ */
4
+ import { Tool, ToolDefinition, ToolImplementation } from '../tool-base.js';
5
+ export declare class MCPTool extends Tool {
6
+ private operations;
7
+ private client;
8
+ private loader;
9
+ constructor(definition: ToolDefinition, implementation: ToolImplementation);
10
+ initialize(): Promise<void>;
11
+ execute(operation: string, params: Record<string, unknown>): Promise<unknown>;
12
+ listOperations(): string[];
13
+ getOperationSchema(operation: string): Record<string, unknown>;
14
+ private buildConfig;
15
+ }
16
+ //# sourceMappingURL=mcp-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tool.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAU3E,qBAAa,OAAQ,SAAQ,IAAI;IAC/B,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAmB;gBAErB,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB;IAIpE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B3B,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAcnF,cAAc,IAAI,MAAM,EAAE;IAI1B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAS9D,OAAO,CAAC,WAAW;CA6BpB"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * MCP tool implementation (minimal adapter).
3
+ */
4
+ import { readFileSync, existsSync } from 'node:fs';
5
+ import { parse } from 'yaml';
6
+ import { Tool } from '../tool-base.js';
7
+ import { McpLoader } from '../mcp-loader.js';
8
+ export class MCPTool extends Tool {
9
+ operations = {};
10
+ client = null;
11
+ loader = new McpLoader();
12
+ constructor(definition, implementation) {
13
+ super(definition, implementation);
14
+ }
15
+ async initialize() {
16
+ if (this.initialized)
17
+ return;
18
+ if (this.implementation.packageName) {
19
+ const config = this.buildConfig();
20
+ const client = await this.loader.loadNative(this.implementation.packageName, config);
21
+ const tools = await client.listTools?.();
22
+ if (Array.isArray(tools)) {
23
+ for (const tool of tools) {
24
+ this.operations[tool.name] = {
25
+ name: tool.name,
26
+ description: tool.description,
27
+ input_schema: tool.inputSchema ?? tool.input_schema ?? {},
28
+ };
29
+ }
30
+ }
31
+ this.client = client;
32
+ }
33
+ else if (this.implementation.specPath) {
34
+ const content = readFileSync(this.implementation.specPath, 'utf8');
35
+ const data = parse(content);
36
+ for (const tool of data.tools ?? []) {
37
+ this.operations[tool.name] = tool;
38
+ }
39
+ }
40
+ this.initialized = true;
41
+ }
42
+ async execute(operation, params) {
43
+ if (!this.initialized)
44
+ await this.initialize();
45
+ if (!this.operations[operation]) {
46
+ throw new Error(`Unknown MCP operation: ${operation}`);
47
+ }
48
+ if (!this.client) {
49
+ throw new Error('MCP client is not initialized. Provide packageName in tool implementation.');
50
+ }
51
+ return await this.client.callTool({
52
+ name: operation,
53
+ arguments: params,
54
+ });
55
+ }
56
+ listOperations() {
57
+ return Object.keys(this.operations);
58
+ }
59
+ getOperationSchema(operation) {
60
+ const op = this.operations[operation];
61
+ if (!op)
62
+ return {};
63
+ return {
64
+ description: op.description ?? '',
65
+ parameters: op.input_schema ?? { type: 'object', properties: {} },
66
+ };
67
+ }
68
+ buildConfig() {
69
+ let options = {};
70
+ if (this.implementation.configPath && existsSync(this.implementation.configPath)) {
71
+ const content = readFileSync(this.implementation.configPath, 'utf8');
72
+ try {
73
+ options = parse(content);
74
+ }
75
+ catch {
76
+ try {
77
+ options = JSON.parse(content);
78
+ }
79
+ catch {
80
+ options = {};
81
+ }
82
+ }
83
+ }
84
+ const auth = {};
85
+ if (this.definition.authentication?.tokenEnv) {
86
+ const token = process.env[this.definition.authentication.tokenEnv];
87
+ if (token) {
88
+ auth.token = token;
89
+ }
90
+ }
91
+ return {
92
+ sdk: this.implementation.packageName ?? '',
93
+ auth: Object.keys(auth).length ? auth : undefined,
94
+ options,
95
+ };
96
+ }
97
+ }
98
+ //# sourceMappingURL=mcp-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tool.js","sourceRoot":"","sources":["../../src/tools/mcp-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAsC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAS7C,MAAM,OAAO,OAAQ,SAAQ,IAAI;IACvB,UAAU,GAAgC,EAAE,CAAC;IAC7C,MAAM,GAAQ,IAAI,CAAC;IACnB,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAEjC,YAAY,UAA0B,EAAE,cAAkC;QACxE,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAC7B,IAAI,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACrF,MAAM,KAAK,GAAG,MAAO,MAAc,CAAC,SAAS,EAAE,EAAE,CAAC;YA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C,QAAQ,CAAC,CAAC;YACnE,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW,IAAI,EAAE;YAC1C,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACjD,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * OpenAPI tool implementation.
3
+ */
4
+ import { Tool, ToolDefinition, ToolImplementation } from '../tool-base.js';
5
+ export declare class OpenAPITool extends Tool {
6
+ private spec;
7
+ private operations;
8
+ private baseUrl;
9
+ constructor(definition: ToolDefinition, implementation: ToolImplementation);
10
+ initialize(): Promise<void>;
11
+ private parseSpec;
12
+ private normalizeOperationId;
13
+ execute(operation: string, params: Record<string, unknown>): Promise<unknown>;
14
+ listOperations(): string[];
15
+ getOperationSchema(operation: string): Record<string, unknown>;
16
+ }
17
+ //# sourceMappingURL=openapi-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-tool.d.ts","sourceRoot":"","sources":["../../src/tools/openapi-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,qBAAa,WAAY,SAAQ,IAAI;IACnC,OAAO,CAAC,IAAI,CAA2B;IACvC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAAM;gBAET,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB;IAIpE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,oBAAoB;IAStB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAuEnF,cAAc,IAAI,MAAM,EAAE;IAI1B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAkC/D"}