tachibot-mcp 2.0.2

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 (214) hide show
  1. package/.env.example +260 -0
  2. package/CHANGELOG.md +54 -0
  3. package/CODE_OF_CONDUCT.md +56 -0
  4. package/CONTRIBUTING.md +54 -0
  5. package/Dockerfile +36 -0
  6. package/LICENSE +644 -0
  7. package/README.md +201 -0
  8. package/SECURITY.md +95 -0
  9. package/dist/personality/komaai-expressions.js +12 -0
  10. package/dist/profiles/balanced.json +33 -0
  11. package/dist/profiles/code_focus.json +33 -0
  12. package/dist/profiles/full.json +33 -0
  13. package/dist/profiles/minimal.json +33 -0
  14. package/dist/profiles/research_power.json +33 -0
  15. package/dist/scripts/build-profiles.js +46 -0
  16. package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
  17. package/dist/src/application/services/focus/FocusTool.service.js +109 -0
  18. package/dist/src/application/services/focus/ModeRegistry.js +46 -0
  19. package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
  20. package/dist/src/application/services/focus/modes/status.mode.js +50 -0
  21. package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
  22. package/dist/src/collaborative-orchestrator.js +391 -0
  23. package/dist/src/config/model-constants.js +188 -0
  24. package/dist/src/config/model-defaults.js +57 -0
  25. package/dist/src/config/model-preferences.js +382 -0
  26. package/dist/src/config/timeout-config.js +130 -0
  27. package/dist/src/config.js +173 -0
  28. package/dist/src/domain/interfaces/IFocusMode.js +5 -0
  29. package/dist/src/domain/interfaces/IProvider.js +6 -0
  30. package/dist/src/domain/interfaces/ITool.js +5 -0
  31. package/dist/src/focus-deep.js +245 -0
  32. package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
  33. package/dist/src/mcp-client.js +90 -0
  34. package/dist/src/memory/index.js +17 -0
  35. package/dist/src/memory/memory-config.js +135 -0
  36. package/dist/src/memory/memory-interface.js +174 -0
  37. package/dist/src/memory/memory-manager.js +383 -0
  38. package/dist/src/memory/providers/devlog-provider.js +385 -0
  39. package/dist/src/memory/providers/hybrid-provider.js +399 -0
  40. package/dist/src/memory/providers/local-provider.js +388 -0
  41. package/dist/src/memory/providers/mem0-provider.js +337 -0
  42. package/dist/src/modes/architect.js +477 -0
  43. package/dist/src/modes/auditor.js +362 -0
  44. package/dist/src/modes/challenger.js +841 -0
  45. package/dist/src/modes/code-reviewer.js +382 -0
  46. package/dist/src/modes/commit-guardian.js +424 -0
  47. package/dist/src/modes/documentation-writer.js +572 -0
  48. package/dist/src/modes/scout.js +587 -0
  49. package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
  50. package/dist/src/modes/shared/helpers/index.js +17 -0
  51. package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
  52. package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
  53. package/dist/src/modes/test-architect.js +767 -0
  54. package/dist/src/modes/verifier.js +378 -0
  55. package/dist/src/monitoring/performance-monitor.js +435 -0
  56. package/dist/src/optimization/batch-executor.js +121 -0
  57. package/dist/src/optimization/context-pruner.js +196 -0
  58. package/dist/src/optimization/cost-monitor.js +338 -0
  59. package/dist/src/optimization/index.js +65 -0
  60. package/dist/src/optimization/model-router.js +264 -0
  61. package/dist/src/optimization/result-cache.js +114 -0
  62. package/dist/src/optimization/token-optimizer.js +257 -0
  63. package/dist/src/optimization/token-tracker.js +118 -0
  64. package/dist/src/orchestrator-instructions.js +128 -0
  65. package/dist/src/orchestrator-lite.js +139 -0
  66. package/dist/src/orchestrator.js +191 -0
  67. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
  68. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
  69. package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
  70. package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
  71. package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
  72. package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
  73. package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
  74. package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
  75. package/dist/src/profiles/balanced.js +37 -0
  76. package/dist/src/profiles/code_focus.js +37 -0
  77. package/dist/src/profiles/debug_intensive.js +59 -0
  78. package/dist/src/profiles/full.js +37 -0
  79. package/dist/src/profiles/minimal.js +37 -0
  80. package/dist/src/profiles/research_code.js +59 -0
  81. package/dist/src/profiles/research_power.js +37 -0
  82. package/dist/src/profiles/types.js +5 -0
  83. package/dist/src/profiles/workflow_builder.js +53 -0
  84. package/dist/src/prompt-engineer-lite.js +78 -0
  85. package/dist/src/prompt-engineer.js +399 -0
  86. package/dist/src/reasoning-chain.js +508 -0
  87. package/dist/src/sequential-thinking.js +291 -0
  88. package/dist/src/server-diagnostic.js +74 -0
  89. package/dist/src/server-raw.js +158 -0
  90. package/dist/src/server-simple.js +58 -0
  91. package/dist/src/server.js +514 -0
  92. package/dist/src/session/session-logger.js +617 -0
  93. package/dist/src/session/session-manager.js +571 -0
  94. package/dist/src/session/session-tools.js +400 -0
  95. package/dist/src/tools/advanced-modes.js +200 -0
  96. package/dist/src/tools/claude-integration.js +356 -0
  97. package/dist/src/tools/consolidated/ai-router.js +174 -0
  98. package/dist/src/tools/consolidated/ai-tool.js +48 -0
  99. package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
  100. package/dist/src/tools/consolidated/environment-detector.js +80 -0
  101. package/dist/src/tools/consolidated/index.js +50 -0
  102. package/dist/src/tools/consolidated/search-tool.js +110 -0
  103. package/dist/src/tools/consolidated/workflow-tool.js +238 -0
  104. package/dist/src/tools/gemini-tools.js +329 -0
  105. package/dist/src/tools/grok-enhanced.js +376 -0
  106. package/dist/src/tools/grok-tools.js +299 -0
  107. package/dist/src/tools/lmstudio-tools.js +223 -0
  108. package/dist/src/tools/openai-tools.js +498 -0
  109. package/dist/src/tools/openrouter-tools.js +317 -0
  110. package/dist/src/tools/optimized-wrapper.js +204 -0
  111. package/dist/src/tools/perplexity-tools.js +294 -0
  112. package/dist/src/tools/pingpong-tool.js +343 -0
  113. package/dist/src/tools/qwen-wrapper.js +74 -0
  114. package/dist/src/tools/tool-router.js +444 -0
  115. package/dist/src/tools/unified-ai-provider.js +260 -0
  116. package/dist/src/tools/workflow-runner.js +425 -0
  117. package/dist/src/tools/workflow-validator-tool.js +107 -0
  118. package/dist/src/types.js +23 -0
  119. package/dist/src/utils/input-validator.js +130 -0
  120. package/dist/src/utils/model-router.js +91 -0
  121. package/dist/src/utils/progress-stream.js +255 -0
  122. package/dist/src/utils/provider-router.js +88 -0
  123. package/dist/src/utils/smart-api-client.js +146 -0
  124. package/dist/src/utils/table-builder.js +218 -0
  125. package/dist/src/utils/timestamp-formatter.js +134 -0
  126. package/dist/src/utils/tool-compressor.js +257 -0
  127. package/dist/src/utils/tool-config.js +201 -0
  128. package/dist/src/validators/dependency-graph-validator.js +147 -0
  129. package/dist/src/validators/interpolation-validator.js +222 -0
  130. package/dist/src/validators/output-usage-validator.js +151 -0
  131. package/dist/src/validators/syntax-validator.js +102 -0
  132. package/dist/src/validators/tool-registry-validator.js +123 -0
  133. package/dist/src/validators/tool-types.js +97 -0
  134. package/dist/src/validators/types.js +8 -0
  135. package/dist/src/validators/workflow-validator.js +134 -0
  136. package/dist/src/visualizer-lite.js +42 -0
  137. package/dist/src/visualizer.js +179 -0
  138. package/dist/src/workflows/circuit-breaker.js +199 -0
  139. package/dist/src/workflows/custom-workflows.js +451 -0
  140. package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
  141. package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
  142. package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
  143. package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
  144. package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
  145. package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
  146. package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
  147. package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
  148. package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
  149. package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
  150. package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
  151. package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
  152. package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
  153. package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
  154. package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
  155. package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
  156. package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
  157. package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
  158. package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
  159. package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
  160. package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
  161. package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
  162. package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
  163. package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
  164. package/dist/src/workflows/fallback-strategies.js +373 -0
  165. package/dist/src/workflows/message-queue.js +455 -0
  166. package/dist/src/workflows/model-router.js +189 -0
  167. package/dist/src/workflows/orchestrator-examples.js +174 -0
  168. package/dist/src/workflows/orchestrator-integration.js +200 -0
  169. package/dist/src/workflows/self-healing.js +524 -0
  170. package/dist/src/workflows/tool-mapper.js +407 -0
  171. package/dist/src/workflows/tool-orchestrator.js +796 -0
  172. package/dist/src/workflows/workflow-engine.js +573 -0
  173. package/dist/src/workflows/workflow-parser.js +283 -0
  174. package/dist/src/workflows/workflow-types.js +95 -0
  175. package/dist/src/workflows.js +568 -0
  176. package/dist/test-workflow-file-output.js +93 -0
  177. package/docs/API_KEYS.md +570 -0
  178. package/docs/CLAUDE_CODE_SETUP.md +181 -0
  179. package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
  180. package/docs/CONFIGURATION.md +745 -0
  181. package/docs/FOCUS_MODES.md +240 -0
  182. package/docs/INSTALLATION_BOTH.md +145 -0
  183. package/docs/TERMS.md +352 -0
  184. package/docs/TOOLS_REFERENCE.md +1622 -0
  185. package/docs/TOOL_PARAMETERS.md +496 -0
  186. package/docs/TOOL_PROFILES.md +236 -0
  187. package/docs/WORKFLOWS.md +987 -0
  188. package/docs/WORKFLOW_OUTPUT.md +198 -0
  189. package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
  190. package/docs/workflows/design-brainstorm.md +335 -0
  191. package/package.json +97 -0
  192. package/profiles/balanced.json +37 -0
  193. package/profiles/code_focus.json +37 -0
  194. package/profiles/debug_intensive.json +34 -0
  195. package/profiles/full.json +37 -0
  196. package/profiles/minimal.json +37 -0
  197. package/profiles/research_power.json +37 -0
  198. package/profiles/workflow_builder.json +37 -0
  199. package/smithery.yaml +66 -0
  200. package/start.sh +8 -0
  201. package/tools.config.json +81 -0
  202. package/tsconfig.json +18 -0
  203. package/workflows/accessibility-code-audit.yaml +92 -0
  204. package/workflows/code-architecture-review.yaml +202 -0
  205. package/workflows/code-review.yaml +142 -0
  206. package/workflows/core/iterative-problem-solver.yaml +283 -0
  207. package/workflows/creative-brainstorm-yaml.yaml +215 -0
  208. package/workflows/pingpong.yaml +141 -0
  209. package/workflows/system/README.md +412 -0
  210. package/workflows/system/challenger.yaml +175 -0
  211. package/workflows/system/scout.yaml +164 -0
  212. package/workflows/system/verifier.yaml +133 -0
  213. package/workflows/ultra-creative-brainstorm.yaml +318 -0
  214. package/workflows/ux-research-flow.yaml +92 -0
@@ -0,0 +1,283 @@
1
+ import * as yaml from 'js-yaml';
2
+ import * as fs from 'fs/promises';
3
+ import * as path from 'path';
4
+ import * as os from 'os';
5
+ export class WorkflowParser {
6
+ constructor() {
7
+ this.defaultWorkflows = null;
8
+ }
9
+ async parse(input) {
10
+ try {
11
+ const parsed = yaml.load(input);
12
+ if (parsed.workflows) {
13
+ const config = parsed;
14
+ const firstWorkflow = Object.values(config.workflows)[0];
15
+ return this.validateWorkflowInternal(firstWorkflow);
16
+ }
17
+ return this.validateWorkflowInternal(parsed);
18
+ }
19
+ catch (error) {
20
+ throw new Error(`Failed to parse workflow: ${error}`);
21
+ }
22
+ }
23
+ async loadConfig(configPath) {
24
+ try {
25
+ const content = await fs.readFile(configPath, 'utf-8');
26
+ return yaml.load(content);
27
+ }
28
+ catch (error) {
29
+ throw new Error(`Failed to load workflow config: ${error}`);
30
+ }
31
+ }
32
+ async loadDefaultWorkflows() {
33
+ if (this.defaultWorkflows) {
34
+ return this.defaultWorkflows;
35
+ }
36
+ const defaultPath = path.join(__dirname, '../../config/default-workflows.yaml');
37
+ this.defaultWorkflows = await this.loadConfig(defaultPath);
38
+ return this.defaultWorkflows;
39
+ }
40
+ async loadCustomWorkflows(projectPath) {
41
+ // Load workflows from multiple sources and merge them
42
+ const mergedConfig = {
43
+ version: '1.0',
44
+ defaults: {},
45
+ workflows: {}
46
+ };
47
+ // Define directories to scan for workflow files
48
+ const dirs = [];
49
+ // Project-specific
50
+ if (projectPath) {
51
+ dirs.push(path.join(projectPath, '.focus'));
52
+ dirs.push(path.join(projectPath, '.focus', 'workflows'));
53
+ }
54
+ // Current directory
55
+ dirs.push(path.join(process.cwd(), '.focus'));
56
+ dirs.push(path.join(process.cwd(), '.focus', 'workflows'));
57
+ // User home
58
+ dirs.push(path.join(os.homedir(), '.focus'));
59
+ dirs.push(path.join(os.homedir(), '.focus', 'workflows'));
60
+ // Built-in config directory
61
+ dirs.push(path.join(__dirname, '../../config'));
62
+ let hasLoadedAny = false;
63
+ for (const dir of dirs) {
64
+ try {
65
+ const files = await this.findWorkflowFiles(dir);
66
+ for (const file of files) {
67
+ try {
68
+ const config = await this.loadConfig(file);
69
+ console.error(`Loaded workflows from: ${file}`);
70
+ // Merge defaults
71
+ if (config.defaults) {
72
+ mergedConfig.defaults = {
73
+ ...mergedConfig.defaults,
74
+ ...config.defaults
75
+ };
76
+ }
77
+ // Merge workflows (later files override earlier ones)
78
+ if (config.workflows) {
79
+ mergedConfig.workflows = {
80
+ ...mergedConfig.workflows,
81
+ ...config.workflows
82
+ };
83
+ }
84
+ hasLoadedAny = true;
85
+ }
86
+ catch (error) {
87
+ console.warn(`Failed to load workflow file ${file}:`, error);
88
+ }
89
+ }
90
+ }
91
+ catch {
92
+ // Directory doesn't exist, skip
93
+ }
94
+ }
95
+ return hasLoadedAny ? mergedConfig : null;
96
+ }
97
+ async findWorkflowFiles(dir) {
98
+ const workflowFiles = [];
99
+ try {
100
+ const entries = await fs.readdir(dir);
101
+ for (const entry of entries) {
102
+ const fullPath = path.join(dir, entry);
103
+ const stat = await fs.stat(fullPath);
104
+ if (stat.isFile()) {
105
+ // Check if it's a YAML workflow file
106
+ if (entry.endsWith('.yaml') || entry.endsWith('.yml')) {
107
+ // Include files with 'workflow' in name or specific known files
108
+ if (entry.includes('workflow') ||
109
+ entry === 'config.yaml' ||
110
+ entry === 'config.yml' ||
111
+ entry.startsWith('custom-') ||
112
+ entry.startsWith('project-')) {
113
+ workflowFiles.push(fullPath);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ catch {
120
+ // Directory doesn't exist or not readable
121
+ }
122
+ return workflowFiles;
123
+ }
124
+ async mergeWorkflows(projectPath) {
125
+ const defaultWorkflows = await this.loadDefaultWorkflows();
126
+ const customWorkflows = await this.loadCustomWorkflows(projectPath);
127
+ if (!customWorkflows) {
128
+ return defaultWorkflows;
129
+ }
130
+ // Merge custom workflows with defaults
131
+ // Custom workflows override defaults with the same name
132
+ return {
133
+ version: customWorkflows.version || defaultWorkflows.version,
134
+ defaults: {
135
+ ...defaultWorkflows.defaults,
136
+ ...customWorkflows.defaults
137
+ },
138
+ workflows: {
139
+ ...defaultWorkflows.workflows,
140
+ ...customWorkflows.workflows // Custom overrides default
141
+ }
142
+ };
143
+ }
144
+ async validateWorkflow(workflow) {
145
+ const errors = [];
146
+ try {
147
+ this.validateWorkflowInternal(workflow);
148
+ return { valid: true, errors: [] };
149
+ }
150
+ catch (error) {
151
+ errors.push(error.message);
152
+ return { valid: false, errors };
153
+ }
154
+ }
155
+ async getWorkflowSources(projectPath) {
156
+ const sources = [];
157
+ // Get all directories
158
+ const dirs = [];
159
+ if (projectPath) {
160
+ dirs.push(path.join(projectPath, '.focus'));
161
+ dirs.push(path.join(projectPath, '.focus', 'workflows'));
162
+ }
163
+ dirs.push(path.join(process.cwd(), '.focus'));
164
+ dirs.push(path.join(process.cwd(), '.focus', 'workflows'));
165
+ dirs.push(path.join(os.homedir(), '.focus'));
166
+ dirs.push(path.join(os.homedir(), '.focus', 'workflows'));
167
+ dirs.push(path.join(__dirname, '../../config'));
168
+ for (const dir of dirs) {
169
+ try {
170
+ const files = await this.findWorkflowFiles(dir);
171
+ for (const file of files) {
172
+ try {
173
+ const config = await this.loadConfig(file);
174
+ if (config.workflows) {
175
+ sources.push({
176
+ file: path.relative(process.cwd(), file),
177
+ workflows: Object.keys(config.workflows)
178
+ });
179
+ }
180
+ }
181
+ catch {
182
+ // Skip invalid files
183
+ }
184
+ }
185
+ }
186
+ catch {
187
+ // Skip non-existent directories
188
+ }
189
+ }
190
+ return sources;
191
+ }
192
+ async getWorkflow(name, projectPath) {
193
+ const merged = await this.mergeWorkflows(projectPath);
194
+ return merged.workflows[name] || null;
195
+ }
196
+ async listAvailableWorkflows(projectPath) {
197
+ const merged = await this.mergeWorkflows(projectPath);
198
+ return Object.keys(merged.workflows);
199
+ }
200
+ validateWorkflowInternal(workflow) {
201
+ if (!workflow.name) {
202
+ throw new Error('Workflow must have a name');
203
+ }
204
+ if (!workflow.steps || workflow.steps.length === 0) {
205
+ throw new Error('Workflow must have at least one step');
206
+ }
207
+ for (const step of workflow.steps) {
208
+ this.validateStep(step);
209
+ }
210
+ this.validateDependencies(workflow.steps);
211
+ return workflow;
212
+ }
213
+ validateStep(step) {
214
+ if (!step.id) {
215
+ throw new Error('Step must have an id');
216
+ }
217
+ if (!step.mode) {
218
+ throw new Error(`Step ${step.id} must have a mode`);
219
+ }
220
+ const validModes = [
221
+ 'verifier', 'challenger', 'auditor',
222
+ 'scout', 'commit_guardian', 'architect', 'synthesis'
223
+ ];
224
+ if (!validModes.includes(step.mode)) {
225
+ throw new Error(`Invalid mode ${step.mode} in step ${step.id}`);
226
+ }
227
+ if (step.maxTokens && step.maxTokens < 100) {
228
+ throw new Error(`Max tokens too low in step ${step.id}`);
229
+ }
230
+ if (step.temperature !== undefined && (step.temperature < 0 || step.temperature > 2)) {
231
+ throw new Error(`Invalid temperature in step ${step.id}`);
232
+ }
233
+ }
234
+ validateDependencies(steps) {
235
+ const stepIds = new Set(steps.map(s => s.id));
236
+ for (const step of steps) {
237
+ if (step.dependsOn) {
238
+ for (const dep of step.dependsOn) {
239
+ if (!stepIds.has(dep)) {
240
+ throw new Error(`Step ${step.id} depends on non-existent step ${dep}`);
241
+ }
242
+ }
243
+ }
244
+ if (step.contextFrom) {
245
+ const stepId = step.contextFrom.split('.')[0];
246
+ if (!stepIds.has(stepId)) {
247
+ throw new Error(`Step ${step.id} references non-existent step ${stepId}`);
248
+ }
249
+ }
250
+ }
251
+ }
252
+ expandShorthand(shorthand) {
253
+ if (typeof shorthand === 'string') {
254
+ return {
255
+ id: shorthand,
256
+ mode: shorthand
257
+ };
258
+ }
259
+ if (typeof shorthand === 'object' && !shorthand.id) {
260
+ const mode = Object.keys(shorthand)[0];
261
+ return {
262
+ id: mode,
263
+ mode,
264
+ ...shorthand[mode]
265
+ };
266
+ }
267
+ return shorthand;
268
+ }
269
+ mergeWithDefaults(workflow, defaults) {
270
+ return {
271
+ ...workflow,
272
+ defaults: {
273
+ ...defaults,
274
+ ...workflow.defaults
275
+ },
276
+ steps: workflow.steps.map((step) => ({
277
+ maxTokens: defaults.maxTokens,
278
+ temperature: defaults.temperature,
279
+ ...step
280
+ }))
281
+ };
282
+ }
283
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Workflow Type Definitions
3
+ * Extracted from custom-workflows.ts to break circular dependencies
4
+ */
5
+ import { z } from "zod";
6
+ // ═══════════════════════════════════════════════════════════════════════════
7
+ // Workflow Step Schema
8
+ // ═══════════════════════════════════════════════════════════════════════════
9
+ export const WorkflowStepSchema = z.object({
10
+ name: z.string(),
11
+ tool: z.string(), // Tool name or model name
12
+ input: z
13
+ .union([
14
+ z.string(),
15
+ z.record(z.any()), // Allow any object with any fields
16
+ ])
17
+ .optional(),
18
+ model: z.string().optional(), // Override model selection (supports ${variable})
19
+ maxTokens: z.union([z.number(), z.string()]).optional(), // Accepts number OR "${variable}"
20
+ temperature: z.union([z.number(), z.string()]).optional(), // Accepts number OR "${variable}"
21
+ condition: z
22
+ .object({
23
+ if: z.string().optional(), // Condition expression
24
+ skip: z.boolean().optional(),
25
+ failOnError: z.boolean().optional(),
26
+ })
27
+ .optional(),
28
+ parallel: z.boolean().optional(), // Run in parallel with next step
29
+ dependsOn: z.array(z.string()).optional(), // Step dependencies for parallel execution
30
+ retry: z
31
+ .object({
32
+ attempts: z.number().default(3),
33
+ backoff: z.number().default(1000),
34
+ })
35
+ .optional(),
36
+ output: z
37
+ .object({
38
+ save: z.boolean().optional(),
39
+ format: z.enum(["text", "json", "markdown"]).optional(),
40
+ variable: z.string().optional(), // Save to variable for later use
41
+ })
42
+ .optional(),
43
+ saveToFile: z.boolean().optional(), // Save step output to file
44
+ loadFiles: z.array(z.string()).optional(), // Load previous step files
45
+ promptTechnique: z.string().optional(), // Prompt engineering technique to apply
46
+ });
47
+ // ═══════════════════════════════════════════════════════════════════════════
48
+ // Complete Workflow Schema
49
+ // ═══════════════════════════════════════════════════════════════════════════
50
+ export const WorkflowSchema = z.object({
51
+ name: z.string(),
52
+ description: z.string().optional(),
53
+ version: z.string().default("1.0"),
54
+ // Global settings
55
+ settings: z
56
+ .object({
57
+ maxCost: z.number().optional(), // Max cost in dollars
58
+ maxTime: z.number().optional(), // Max time in seconds
59
+ defaultModel: z.string().optional(),
60
+ optimization: z
61
+ .object({
62
+ enabled: z.boolean().default(true),
63
+ cacheResults: z.boolean().default(true),
64
+ compressPrompts: z.boolean().default(true),
65
+ smartRouting: z.boolean().default(true),
66
+ })
67
+ .optional(),
68
+ autoSynthesis: z
69
+ .object({
70
+ enabled: z.boolean().default(false),
71
+ tokenThreshold: z.number().optional(),
72
+ synthesisTool: z.string().optional(),
73
+ synthesisMaxTokens: z.number().optional(),
74
+ checkpointInterval: z.number().optional(),
75
+ maxRetries: z.number().optional(),
76
+ logLevel: z.enum(['silent', 'error', 'info']).optional(),
77
+ })
78
+ .optional(),
79
+ })
80
+ .optional(),
81
+ // Variables that can be used in steps
82
+ variables: z.record(z.any()).optional(),
83
+ // The workflow steps
84
+ steps: z.array(WorkflowStepSchema),
85
+ // Post-processing
86
+ output: z
87
+ .object({
88
+ format: z.enum(["summary", "detailed", "json"]).default("summary"),
89
+ saveToFile: z.string().optional(),
90
+ notifications: z.array(z.string()).optional(),
91
+ truncateSteps: z.boolean().optional(),
92
+ maxStepTokens: z.number().optional(),
93
+ })
94
+ .optional(),
95
+ });