mcp-agent-foundry 1.0.0

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 (315) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +477 -0
  3. package/dist/cli/install-skills.d.ts +11 -0
  4. package/dist/cli/install-skills.d.ts.map +1 -0
  5. package/dist/cli/install-skills.js +143 -0
  6. package/dist/cli/install-skills.js.map +1 -0
  7. package/dist/cli/recovery-commands.d.ts +41 -0
  8. package/dist/cli/recovery-commands.d.ts.map +1 -0
  9. package/dist/cli/recovery-commands.js +241 -0
  10. package/dist/cli/recovery-commands.js.map +1 -0
  11. package/dist/cli/setup-wizard.d.ts +25 -0
  12. package/dist/cli/setup-wizard.d.ts.map +1 -0
  13. package/dist/cli/setup-wizard.js +1417 -0
  14. package/dist/cli/setup-wizard.js.map +1 -0
  15. package/dist/cli/test-connection.d.ts +45 -0
  16. package/dist/cli/test-connection.d.ts.map +1 -0
  17. package/dist/cli/test-connection.js +317 -0
  18. package/dist/cli/test-connection.js.map +1 -0
  19. package/dist/cli.d.ts +75 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +704 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/config/defaults.d.ts +57 -0
  24. package/dist/config/defaults.d.ts.map +1 -0
  25. package/dist/config/defaults.js +99 -0
  26. package/dist/config/defaults.js.map +1 -0
  27. package/dist/config/index.d.ts +14 -0
  28. package/dist/config/index.d.ts.map +1 -0
  29. package/dist/config/index.js +22 -0
  30. package/dist/config/index.js.map +1 -0
  31. package/dist/config/manager.d.ts +184 -0
  32. package/dist/config/manager.d.ts.map +1 -0
  33. package/dist/config/manager.js +347 -0
  34. package/dist/config/manager.js.map +1 -0
  35. package/dist/config/merger.d.ts +76 -0
  36. package/dist/config/merger.d.ts.map +1 -0
  37. package/dist/config/merger.js +189 -0
  38. package/dist/config/merger.js.map +1 -0
  39. package/dist/config/schema.d.ts +20 -0
  40. package/dist/config/schema.d.ts.map +1 -0
  41. package/dist/config/schema.js +20 -0
  42. package/dist/config/schema.js.map +1 -0
  43. package/dist/config/validator.d.ts +254 -0
  44. package/dist/config/validator.d.ts.map +1 -0
  45. package/dist/config/validator.js +363 -0
  46. package/dist/config/validator.js.map +1 -0
  47. package/dist/config/worktree-defaults.d.ts +23 -0
  48. package/dist/config/worktree-defaults.d.ts.map +1 -0
  49. package/dist/config/worktree-defaults.js +78 -0
  50. package/dist/config/worktree-defaults.js.map +1 -0
  51. package/dist/index.d.ts +8 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +44 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/mcp/tools/compare-agents.d.ts +25 -0
  56. package/dist/mcp/tools/compare-agents.d.ts.map +1 -0
  57. package/dist/mcp/tools/compare-agents.js +177 -0
  58. package/dist/mcp/tools/compare-agents.js.map +1 -0
  59. package/dist/mcp/tools/critique-plan.d.ts +26 -0
  60. package/dist/mcp/tools/critique-plan.d.ts.map +1 -0
  61. package/dist/mcp/tools/critique-plan.js +162 -0
  62. package/dist/mcp/tools/critique-plan.js.map +1 -0
  63. package/dist/mcp/tools/design-feedback.d.ts +26 -0
  64. package/dist/mcp/tools/design-feedback.d.ts.map +1 -0
  65. package/dist/mcp/tools/design-feedback.js +216 -0
  66. package/dist/mcp/tools/design-feedback.js.map +1 -0
  67. package/dist/mcp/tools/index.d.ts +50 -0
  68. package/dist/mcp/tools/index.d.ts.map +1 -0
  69. package/dist/mcp/tools/index.js +191 -0
  70. package/dist/mcp/tools/index.js.map +1 -0
  71. package/dist/mcp/tools/invoke-agent.d.ts +25 -0
  72. package/dist/mcp/tools/invoke-agent.d.ts.map +1 -0
  73. package/dist/mcp/tools/invoke-agent.js +141 -0
  74. package/dist/mcp/tools/invoke-agent.js.map +1 -0
  75. package/dist/mcp/tools/review-code.d.ts +25 -0
  76. package/dist/mcp/tools/review-code.d.ts.map +1 -0
  77. package/dist/mcp/tools/review-code.js +170 -0
  78. package/dist/mcp/tools/review-code.js.map +1 -0
  79. package/dist/mcp/tools/tasks/claim-next-task.d.ts +22 -0
  80. package/dist/mcp/tools/tasks/claim-next-task.d.ts.map +1 -0
  81. package/dist/mcp/tools/tasks/claim-next-task.js +203 -0
  82. package/dist/mcp/tools/tasks/claim-next-task.js.map +1 -0
  83. package/dist/mcp/tools/tasks/create-routed-task.d.ts +17 -0
  84. package/dist/mcp/tools/tasks/create-routed-task.d.ts.map +1 -0
  85. package/dist/mcp/tools/tasks/create-routed-task.js +178 -0
  86. package/dist/mcp/tools/tasks/create-routed-task.js.map +1 -0
  87. package/dist/mcp/tools/tasks/execute-pipeline.d.ts +22 -0
  88. package/dist/mcp/tools/tasks/execute-pipeline.d.ts.map +1 -0
  89. package/dist/mcp/tools/tasks/execute-pipeline.js +401 -0
  90. package/dist/mcp/tools/tasks/execute-pipeline.js.map +1 -0
  91. package/dist/mcp/tools/tasks/execute-task.d.ts +32 -0
  92. package/dist/mcp/tools/tasks/execute-task.d.ts.map +1 -0
  93. package/dist/mcp/tools/tasks/execute-task.js +284 -0
  94. package/dist/mcp/tools/tasks/execute-task.js.map +1 -0
  95. package/dist/mcp/tools/tasks/get-pipeline-status.d.ts +26 -0
  96. package/dist/mcp/tools/tasks/get-pipeline-status.d.ts.map +1 -0
  97. package/dist/mcp/tools/tasks/get-pipeline-status.js +460 -0
  98. package/dist/mcp/tools/tasks/get-pipeline-status.js.map +1 -0
  99. package/dist/mcp/tools/tasks/index.d.ts +36 -0
  100. package/dist/mcp/tools/tasks/index.d.ts.map +1 -0
  101. package/dist/mcp/tools/tasks/index.js +66 -0
  102. package/dist/mcp/tools/tasks/index.js.map +1 -0
  103. package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts +17 -0
  104. package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts.map +1 -0
  105. package/dist/mcp/tools/worktree/cleanup-worktrees.js +147 -0
  106. package/dist/mcp/tools/worktree/cleanup-worktrees.js.map +1 -0
  107. package/dist/mcp/tools/worktree/get-worktree-status.d.ts +17 -0
  108. package/dist/mcp/tools/worktree/get-worktree-status.d.ts.map +1 -0
  109. package/dist/mcp/tools/worktree/get-worktree-status.js +123 -0
  110. package/dist/mcp/tools/worktree/get-worktree-status.js.map +1 -0
  111. package/dist/mcp/tools/worktree/index.d.ts +41 -0
  112. package/dist/mcp/tools/worktree/index.d.ts.map +1 -0
  113. package/dist/mcp/tools/worktree/index.js +69 -0
  114. package/dist/mcp/tools/worktree/index.js.map +1 -0
  115. package/dist/mcp/tools/worktree/list-worktrees.d.ts +17 -0
  116. package/dist/mcp/tools/worktree/list-worktrees.d.ts.map +1 -0
  117. package/dist/mcp/tools/worktree/list-worktrees.js +136 -0
  118. package/dist/mcp/tools/worktree/list-worktrees.js.map +1 -0
  119. package/dist/mcp/tools/worktree/resolve-conflicts.d.ts +19 -0
  120. package/dist/mcp/tools/worktree/resolve-conflicts.d.ts.map +1 -0
  121. package/dist/mcp/tools/worktree/resolve-conflicts.js +228 -0
  122. package/dist/mcp/tools/worktree/resolve-conflicts.js.map +1 -0
  123. package/dist/mcp/transport/stdio.d.ts +13 -0
  124. package/dist/mcp/transport/stdio.d.ts.map +1 -0
  125. package/dist/mcp/transport/stdio.js +15 -0
  126. package/dist/mcp/transport/stdio.js.map +1 -0
  127. package/dist/observability/logger.d.ts +137 -0
  128. package/dist/observability/logger.d.ts.map +1 -0
  129. package/dist/observability/logger.js +235 -0
  130. package/dist/observability/logger.js.map +1 -0
  131. package/dist/observability/metrics.d.ts +250 -0
  132. package/dist/observability/metrics.d.ts.map +1 -0
  133. package/dist/observability/metrics.js +364 -0
  134. package/dist/observability/metrics.js.map +1 -0
  135. package/dist/persistence/index.d.ts +9 -0
  136. package/dist/persistence/index.d.ts.map +1 -0
  137. package/dist/persistence/index.js +9 -0
  138. package/dist/persistence/index.js.map +1 -0
  139. package/dist/persistence/state-schema.d.ts +116 -0
  140. package/dist/persistence/state-schema.d.ts.map +1 -0
  141. package/dist/persistence/state-schema.js +28 -0
  142. package/dist/persistence/state-schema.js.map +1 -0
  143. package/dist/persistence/state-store.d.ts +111 -0
  144. package/dist/persistence/state-store.d.ts.map +1 -0
  145. package/dist/persistence/state-store.js +291 -0
  146. package/dist/persistence/state-store.js.map +1 -0
  147. package/dist/providers/anthropic.d.ts +164 -0
  148. package/dist/providers/anthropic.d.ts.map +1 -0
  149. package/dist/providers/anthropic.js +500 -0
  150. package/dist/providers/anthropic.js.map +1 -0
  151. package/dist/providers/base.d.ts +151 -0
  152. package/dist/providers/base.d.ts.map +1 -0
  153. package/dist/providers/base.js +227 -0
  154. package/dist/providers/base.js.map +1 -0
  155. package/dist/providers/gemini.d.ts +85 -0
  156. package/dist/providers/gemini.d.ts.map +1 -0
  157. package/dist/providers/gemini.js +414 -0
  158. package/dist/providers/gemini.js.map +1 -0
  159. package/dist/providers/kimi.d.ts +19 -0
  160. package/dist/providers/kimi.d.ts.map +1 -0
  161. package/dist/providers/kimi.js +20 -0
  162. package/dist/providers/kimi.js.map +1 -0
  163. package/dist/providers/manager.d.ts +160 -0
  164. package/dist/providers/manager.d.ts.map +1 -0
  165. package/dist/providers/manager.js +264 -0
  166. package/dist/providers/manager.js.map +1 -0
  167. package/dist/providers/ollama.d.ts +83 -0
  168. package/dist/providers/ollama.d.ts.map +1 -0
  169. package/dist/providers/ollama.js +453 -0
  170. package/dist/providers/ollama.js.map +1 -0
  171. package/dist/providers/openai.d.ts +96 -0
  172. package/dist/providers/openai.d.ts.map +1 -0
  173. package/dist/providers/openai.js +457 -0
  174. package/dist/providers/openai.js.map +1 -0
  175. package/dist/providers/zai.d.ts +19 -0
  176. package/dist/providers/zai.d.ts.map +1 -0
  177. package/dist/providers/zai.js +20 -0
  178. package/dist/providers/zai.js.map +1 -0
  179. package/dist/router/context-manager.d.ts +2 -0
  180. package/dist/router/context-manager.d.ts.map +1 -0
  181. package/dist/router/context-manager.js +3 -0
  182. package/dist/router/context-manager.js.map +1 -0
  183. package/dist/router/engine.d.ts +169 -0
  184. package/dist/router/engine.d.ts.map +1 -0
  185. package/dist/router/engine.js +435 -0
  186. package/dist/router/engine.js.map +1 -0
  187. package/dist/router/pattern-executor.d.ts +317 -0
  188. package/dist/router/pattern-executor.d.ts.map +1 -0
  189. package/dist/router/pattern-executor.js +571 -0
  190. package/dist/router/pattern-executor.js.map +1 -0
  191. package/dist/router/role-resolver.d.ts +59 -0
  192. package/dist/router/role-resolver.d.ts.map +1 -0
  193. package/dist/router/role-resolver.js +95 -0
  194. package/dist/router/role-resolver.js.map +1 -0
  195. package/dist/server.d.ts +32 -0
  196. package/dist/server.d.ts.map +1 -0
  197. package/dist/server.js +223 -0
  198. package/dist/server.js.map +1 -0
  199. package/dist/startup.d.ts +78 -0
  200. package/dist/startup.d.ts.map +1 -0
  201. package/dist/startup.js +107 -0
  202. package/dist/startup.js.map +1 -0
  203. package/dist/tasks/coordinator.d.ts +141 -0
  204. package/dist/tasks/coordinator.d.ts.map +1 -0
  205. package/dist/tasks/coordinator.js +331 -0
  206. package/dist/tasks/coordinator.js.map +1 -0
  207. package/dist/tasks/index.d.ts +13 -0
  208. package/dist/tasks/index.d.ts.map +1 -0
  209. package/dist/tasks/index.js +13 -0
  210. package/dist/tasks/index.js.map +1 -0
  211. package/dist/tasks/persistent-state-coordinator.d.ts +89 -0
  212. package/dist/tasks/persistent-state-coordinator.d.ts.map +1 -0
  213. package/dist/tasks/persistent-state-coordinator.js +371 -0
  214. package/dist/tasks/persistent-state-coordinator.js.map +1 -0
  215. package/dist/tasks/pipeline-manager.d.ts +103 -0
  216. package/dist/tasks/pipeline-manager.d.ts.map +1 -0
  217. package/dist/tasks/pipeline-manager.js +358 -0
  218. package/dist/tasks/pipeline-manager.js.map +1 -0
  219. package/dist/tasks/state-coordinator.d.ts +79 -0
  220. package/dist/tasks/state-coordinator.d.ts.map +1 -0
  221. package/dist/tasks/state-coordinator.js +200 -0
  222. package/dist/tasks/state-coordinator.js.map +1 -0
  223. package/dist/tasks/worker-mode.d.ts +65 -0
  224. package/dist/tasks/worker-mode.d.ts.map +1 -0
  225. package/dist/tasks/worker-mode.js +208 -0
  226. package/dist/tasks/worker-mode.js.map +1 -0
  227. package/dist/translation/errors.d.ts +203 -0
  228. package/dist/translation/errors.d.ts.map +1 -0
  229. package/dist/translation/errors.js +477 -0
  230. package/dist/translation/errors.js.map +1 -0
  231. package/dist/translation/index.d.ts +12 -0
  232. package/dist/translation/index.d.ts.map +1 -0
  233. package/dist/translation/index.js +32 -0
  234. package/dist/translation/index.js.map +1 -0
  235. package/dist/translation/messages.d.ts +295 -0
  236. package/dist/translation/messages.d.ts.map +1 -0
  237. package/dist/translation/messages.js +557 -0
  238. package/dist/translation/messages.js.map +1 -0
  239. package/dist/translation/streaming.d.ts +226 -0
  240. package/dist/translation/streaming.d.ts.map +1 -0
  241. package/dist/translation/streaming.js +520 -0
  242. package/dist/translation/streaming.js.map +1 -0
  243. package/dist/translation/tools.d.ts +209 -0
  244. package/dist/translation/tools.d.ts.map +1 -0
  245. package/dist/translation/tools.js +331 -0
  246. package/dist/translation/tools.js.map +1 -0
  247. package/dist/types.d.ts +747 -0
  248. package/dist/types.d.ts.map +1 -0
  249. package/dist/types.js +86 -0
  250. package/dist/types.js.map +1 -0
  251. package/dist/utils/circuit-breaker.d.ts +175 -0
  252. package/dist/utils/circuit-breaker.d.ts.map +1 -0
  253. package/dist/utils/circuit-breaker.js +315 -0
  254. package/dist/utils/circuit-breaker.js.map +1 -0
  255. package/dist/utils/env.d.ts +2 -0
  256. package/dist/utils/env.d.ts.map +1 -0
  257. package/dist/utils/env.js +3 -0
  258. package/dist/utils/env.js.map +1 -0
  259. package/dist/utils/git.d.ts +58 -0
  260. package/dist/utils/git.d.ts.map +1 -0
  261. package/dist/utils/git.js +197 -0
  262. package/dist/utils/git.js.map +1 -0
  263. package/dist/utils/index.d.ts +9 -0
  264. package/dist/utils/index.d.ts.map +1 -0
  265. package/dist/utils/index.js +9 -0
  266. package/dist/utils/index.js.map +1 -0
  267. package/dist/utils/merge-ordering.d.ts +45 -0
  268. package/dist/utils/merge-ordering.d.ts.map +1 -0
  269. package/dist/utils/merge-ordering.js +128 -0
  270. package/dist/utils/merge-ordering.js.map +1 -0
  271. package/dist/utils/retry.d.ts +106 -0
  272. package/dist/utils/retry.d.ts.map +1 -0
  273. package/dist/utils/retry.js +188 -0
  274. package/dist/utils/retry.js.map +1 -0
  275. package/dist/worktrees/branch-manager.d.ts +55 -0
  276. package/dist/worktrees/branch-manager.d.ts.map +1 -0
  277. package/dist/worktrees/branch-manager.js +129 -0
  278. package/dist/worktrees/branch-manager.js.map +1 -0
  279. package/dist/worktrees/conflict-handler.d.ts +72 -0
  280. package/dist/worktrees/conflict-handler.d.ts.map +1 -0
  281. package/dist/worktrees/conflict-handler.js +287 -0
  282. package/dist/worktrees/conflict-handler.js.map +1 -0
  283. package/dist/worktrees/conflict-parser.d.ts +28 -0
  284. package/dist/worktrees/conflict-parser.d.ts.map +1 -0
  285. package/dist/worktrees/conflict-parser.js +140 -0
  286. package/dist/worktrees/conflict-parser.js.map +1 -0
  287. package/dist/worktrees/index.d.ts +20 -0
  288. package/dist/worktrees/index.d.ts.map +1 -0
  289. package/dist/worktrees/index.js +20 -0
  290. package/dist/worktrees/index.js.map +1 -0
  291. package/dist/worktrees/instructions.d.ts +20 -0
  292. package/dist/worktrees/instructions.d.ts.map +1 -0
  293. package/dist/worktrees/instructions.js +84 -0
  294. package/dist/worktrees/instructions.js.map +1 -0
  295. package/dist/worktrees/manager.d.ts +76 -0
  296. package/dist/worktrees/manager.d.ts.map +1 -0
  297. package/dist/worktrees/manager.js +277 -0
  298. package/dist/worktrees/manager.js.map +1 -0
  299. package/dist/worktrees/pipeline-merge-orchestrator.d.ts +55 -0
  300. package/dist/worktrees/pipeline-merge-orchestrator.d.ts.map +1 -0
  301. package/dist/worktrees/pipeline-merge-orchestrator.js +221 -0
  302. package/dist/worktrees/pipeline-merge-orchestrator.js.map +1 -0
  303. package/dist/worktrees/pool.d.ts +95 -0
  304. package/dist/worktrees/pool.d.ts.map +1 -0
  305. package/dist/worktrees/pool.js +271 -0
  306. package/dist/worktrees/pool.js.map +1 -0
  307. package/dist/worktrees/recovery.d.ts +94 -0
  308. package/dist/worktrees/recovery.d.ts.map +1 -0
  309. package/dist/worktrees/recovery.js +371 -0
  310. package/dist/worktrees/recovery.js.map +1 -0
  311. package/dist/worktrees/resource-manager.d.ts +74 -0
  312. package/dist/worktrees/resource-manager.d.ts.map +1 -0
  313. package/dist/worktrees/resource-manager.js +228 -0
  314. package/dist/worktrees/resource-manager.js.map +1 -0
  315. package/package.json +88 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Tool Schema Translation
3
+ *
4
+ * Translates tool/function schemas between different LLM provider formats.
5
+ * Each provider has different conventions for defining tools that models can use.
6
+ *
7
+ * Format Comparison:
8
+ * | Feature | Anthropic | OpenAI | Gemini |
9
+ * |-----------------|------------------|---------------------|---------------------|
10
+ * | Schema key | input_schema | parameters | parameters |
11
+ * | Wrapper | none | function: { } | functionDeclarations|
12
+ * | Description | description | function.description| description |
13
+ */
14
+ import { type Tool } from '../types.js';
15
+ /**
16
+ * Anthropic tool format.
17
+ * Tools are defined at the top level with input_schema for parameters.
18
+ */
19
+ export interface AnthropicTool {
20
+ name: string;
21
+ description: string;
22
+ input_schema: {
23
+ type: 'object';
24
+ properties: Record<string, unknown>;
25
+ required?: string[];
26
+ };
27
+ }
28
+ /**
29
+ * OpenAI tool format.
30
+ * Tools are wrapped in a function object with type: "function".
31
+ */
32
+ export interface OpenAITool {
33
+ type: 'function';
34
+ function: {
35
+ name: string;
36
+ description: string;
37
+ parameters: {
38
+ type: 'object';
39
+ properties: Record<string, unknown>;
40
+ required?: string[];
41
+ };
42
+ };
43
+ }
44
+ /**
45
+ * OpenAI function definition (inner part of OpenAITool).
46
+ * Used when providers expect just the function definition.
47
+ */
48
+ export interface OpenAIFunction {
49
+ name: string;
50
+ description: string;
51
+ parameters: {
52
+ type: 'object';
53
+ properties: Record<string, unknown>;
54
+ required?: string[];
55
+ };
56
+ }
57
+ /**
58
+ * Gemini function declaration.
59
+ * Used inside the functionDeclarations array.
60
+ */
61
+ export interface GeminiFunctionDeclaration {
62
+ name: string;
63
+ description: string;
64
+ parameters: {
65
+ type: 'object';
66
+ properties: Record<string, unknown>;
67
+ required?: string[];
68
+ };
69
+ }
70
+ /**
71
+ * Gemini tool format.
72
+ * Tools are wrapped in a functionDeclarations array.
73
+ */
74
+ export interface GeminiTool {
75
+ functionDeclarations: GeminiFunctionDeclaration[];
76
+ }
77
+ /**
78
+ * Translate tools to Anthropic format.
79
+ *
80
+ * Anthropic uses a straightforward format where tools are defined with:
81
+ * - name: The tool name
82
+ * - description: Human-readable description
83
+ * - input_schema: JSON Schema for parameters
84
+ *
85
+ * Since our internal Tool type follows the Anthropic format,
86
+ * this is essentially a pass-through with validation.
87
+ *
88
+ * @param tools - Array of tools in internal format
89
+ * @returns Array of tools in Anthropic format
90
+ * @throws TranslationError if validation fails
91
+ *
92
+ * @example
93
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
94
+ * const anthropicTools = toAnthropicTools(tools);
95
+ * // Returns: [{ name: "search", description: "Search the web", input_schema: {...} }]
96
+ */
97
+ export declare function toAnthropicTools(tools: Tool[]): AnthropicTool[];
98
+ /**
99
+ * Translate tools to OpenAI format.
100
+ *
101
+ * OpenAI wraps tools in a specific structure:
102
+ * - type: "function" (indicates it's a function tool)
103
+ * - function: Object containing name, description, and parameters
104
+ *
105
+ * The main difference from Anthropic is:
106
+ * - Uses `parameters` instead of `input_schema`
107
+ * - Wraps everything in a `function` object
108
+ * - Adds `type: "function"` at the top level
109
+ *
110
+ * @param tools - Array of tools in internal format
111
+ * @returns Array of tools in OpenAI format
112
+ * @throws TranslationError if validation fails
113
+ *
114
+ * @example
115
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
116
+ * const openaiTools = toOpenAITools(tools);
117
+ * // Returns: [{ type: "function", function: { name: "search", description: "...", parameters: {...} } }]
118
+ */
119
+ export declare function toOpenAITools(tools: Tool[]): OpenAITool[];
120
+ /**
121
+ * Translate tools to OpenAI function format (without wrapper).
122
+ *
123
+ * Some OpenAI-compatible APIs expect just the function definitions
124
+ * without the { type: "function", function: {...} } wrapper.
125
+ *
126
+ * @param tools - Array of tools in internal format
127
+ * @returns Array of function definitions
128
+ * @throws TranslationError if validation fails
129
+ */
130
+ export declare function toOpenAIFunctions(tools: Tool[]): OpenAIFunction[];
131
+ /**
132
+ * Translate tools to Gemini format.
133
+ *
134
+ * Gemini uses a different structure where all function declarations
135
+ * are grouped into a single object:
136
+ * - functionDeclarations: Array of function definitions
137
+ *
138
+ * Each function declaration contains:
139
+ * - name: Function name
140
+ * - description: Human-readable description
141
+ * - parameters: JSON Schema for parameters
142
+ *
143
+ * Note: Gemini expects a single tool object containing all functions,
144
+ * not an array of tool objects.
145
+ *
146
+ * @param tools - Array of tools in internal format
147
+ * @returns Single Gemini tool object containing all function declarations
148
+ * @throws TranslationError if validation fails
149
+ *
150
+ * @example
151
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
152
+ * const geminiTools = toGeminiTools(tools);
153
+ * // Returns: { functionDeclarations: [{ name: "search", description: "...", parameters: {...} }] }
154
+ */
155
+ export declare function toGeminiTools(tools: Tool[]): GeminiTool;
156
+ /**
157
+ * Translate tools to Gemini format as an array (for API compatibility).
158
+ *
159
+ * Some Gemini API versions expect an array containing the tool object.
160
+ * This is a convenience wrapper around toGeminiTools.
161
+ *
162
+ * @param tools - Array of tools in internal format
163
+ * @returns Array containing a single Gemini tool object
164
+ * @throws TranslationError if validation fails
165
+ */
166
+ export declare function toGeminiToolsArray(tools: Tool[]): GeminiTool[];
167
+ /**
168
+ * Translate Anthropic tools to internal format.
169
+ *
170
+ * Since our internal format matches Anthropic, this is essentially a pass-through
171
+ * with validation.
172
+ *
173
+ * @param tools - Array of Anthropic tools
174
+ * @returns Array of tools in internal format
175
+ * @throws TranslationError if validation fails
176
+ */
177
+ export declare function fromAnthropicTools(tools: AnthropicTool[]): Tool[];
178
+ /**
179
+ * Translate OpenAI tools to internal format.
180
+ *
181
+ * Unwraps the function object and converts parameters to input_schema.
182
+ *
183
+ * @param tools - Array of OpenAI tools
184
+ * @returns Array of tools in internal format
185
+ * @throws TranslationError if validation fails
186
+ */
187
+ export declare function fromOpenAITools(tools: OpenAITool[]): Tool[];
188
+ /**
189
+ * Translate Gemini tools to internal format.
190
+ *
191
+ * Extracts function declarations from the Gemini tool object.
192
+ *
193
+ * @param tool - Gemini tool object containing function declarations
194
+ * @returns Array of tools in internal format
195
+ * @throws TranslationError if validation fails
196
+ */
197
+ export declare function fromGeminiTools(tool: GeminiTool): Tool[];
198
+ /**
199
+ * Translate tools to a specific provider format.
200
+ *
201
+ * Convenience function for dynamic provider selection.
202
+ *
203
+ * @param tools - Array of tools in internal format
204
+ * @param provider - Target provider name
205
+ * @returns Tools in the appropriate provider format
206
+ * @throws TranslationError if the provider is unknown
207
+ */
208
+ export declare function translateTools(tools: Tool[], provider: 'anthropic' | 'openai' | 'google' | 'gemini' | 'ollama' | 'openrouter' | 'zai'): AnthropicTool[] | OpenAITool[] | GeminiTool;
209
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/translation/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,IAAI,EAAoB,MAAM,aAAa,CAAC;AAM1D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC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;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,UAAU,CAoBvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,CAM9D;AAMD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAwBjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,CAkC3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,CAwBxD;AA+DD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GACvF,aAAa,EAAE,GAAG,UAAU,EAAE,GAAG,UAAU,CAqB7C"}
@@ -0,0 +1,331 @@
1
+ /**
2
+ * Tool Schema Translation
3
+ *
4
+ * Translates tool/function schemas between different LLM provider formats.
5
+ * Each provider has different conventions for defining tools that models can use.
6
+ *
7
+ * Format Comparison:
8
+ * | Feature | Anthropic | OpenAI | Gemini |
9
+ * |-----------------|------------------|---------------------|---------------------|
10
+ * | Schema key | input_schema | parameters | parameters |
11
+ * | Wrapper | none | function: { } | functionDeclarations|
12
+ * | Description | description | function.description| description |
13
+ */
14
+ import { TranslationError } from '../types.js';
15
+ // ============================================================================
16
+ // Translation Functions
17
+ // ============================================================================
18
+ /**
19
+ * Translate tools to Anthropic format.
20
+ *
21
+ * Anthropic uses a straightforward format where tools are defined with:
22
+ * - name: The tool name
23
+ * - description: Human-readable description
24
+ * - input_schema: JSON Schema for parameters
25
+ *
26
+ * Since our internal Tool type follows the Anthropic format,
27
+ * this is essentially a pass-through with validation.
28
+ *
29
+ * @param tools - Array of tools in internal format
30
+ * @returns Array of tools in Anthropic format
31
+ * @throws TranslationError if validation fails
32
+ *
33
+ * @example
34
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
35
+ * const anthropicTools = toAnthropicTools(tools);
36
+ * // Returns: [{ name: "search", description: "Search the web", input_schema: {...} }]
37
+ */
38
+ export function toAnthropicTools(tools) {
39
+ if (!tools || tools.length === 0) {
40
+ return [];
41
+ }
42
+ return tools.map((tool, index) => {
43
+ validateTool(tool, index);
44
+ return {
45
+ name: tool.name,
46
+ description: tool.description,
47
+ input_schema: {
48
+ type: 'object',
49
+ properties: tool.input_schema.properties,
50
+ ...(tool.input_schema.required && { required: tool.input_schema.required }),
51
+ },
52
+ };
53
+ });
54
+ }
55
+ /**
56
+ * Translate tools to OpenAI format.
57
+ *
58
+ * OpenAI wraps tools in a specific structure:
59
+ * - type: "function" (indicates it's a function tool)
60
+ * - function: Object containing name, description, and parameters
61
+ *
62
+ * The main difference from Anthropic is:
63
+ * - Uses `parameters` instead of `input_schema`
64
+ * - Wraps everything in a `function` object
65
+ * - Adds `type: "function"` at the top level
66
+ *
67
+ * @param tools - Array of tools in internal format
68
+ * @returns Array of tools in OpenAI format
69
+ * @throws TranslationError if validation fails
70
+ *
71
+ * @example
72
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
73
+ * const openaiTools = toOpenAITools(tools);
74
+ * // Returns: [{ type: "function", function: { name: "search", description: "...", parameters: {...} } }]
75
+ */
76
+ export function toOpenAITools(tools) {
77
+ if (!tools || tools.length === 0) {
78
+ return [];
79
+ }
80
+ return tools.map((tool, index) => {
81
+ validateTool(tool, index);
82
+ return {
83
+ type: 'function',
84
+ function: {
85
+ name: tool.name,
86
+ description: tool.description,
87
+ parameters: {
88
+ type: 'object',
89
+ properties: tool.input_schema.properties,
90
+ ...(tool.input_schema.required && { required: tool.input_schema.required }),
91
+ },
92
+ },
93
+ };
94
+ });
95
+ }
96
+ /**
97
+ * Translate tools to OpenAI function format (without wrapper).
98
+ *
99
+ * Some OpenAI-compatible APIs expect just the function definitions
100
+ * without the { type: "function", function: {...} } wrapper.
101
+ *
102
+ * @param tools - Array of tools in internal format
103
+ * @returns Array of function definitions
104
+ * @throws TranslationError if validation fails
105
+ */
106
+ export function toOpenAIFunctions(tools) {
107
+ if (!tools || tools.length === 0) {
108
+ return [];
109
+ }
110
+ return tools.map((tool, index) => {
111
+ validateTool(tool, index);
112
+ return {
113
+ name: tool.name,
114
+ description: tool.description,
115
+ parameters: {
116
+ type: 'object',
117
+ properties: tool.input_schema.properties,
118
+ ...(tool.input_schema.required && { required: tool.input_schema.required }),
119
+ },
120
+ };
121
+ });
122
+ }
123
+ /**
124
+ * Translate tools to Gemini format.
125
+ *
126
+ * Gemini uses a different structure where all function declarations
127
+ * are grouped into a single object:
128
+ * - functionDeclarations: Array of function definitions
129
+ *
130
+ * Each function declaration contains:
131
+ * - name: Function name
132
+ * - description: Human-readable description
133
+ * - parameters: JSON Schema for parameters
134
+ *
135
+ * Note: Gemini expects a single tool object containing all functions,
136
+ * not an array of tool objects.
137
+ *
138
+ * @param tools - Array of tools in internal format
139
+ * @returns Single Gemini tool object containing all function declarations
140
+ * @throws TranslationError if validation fails
141
+ *
142
+ * @example
143
+ * const tools = [{ name: "search", description: "Search the web", input_schema: {...} }];
144
+ * const geminiTools = toGeminiTools(tools);
145
+ * // Returns: { functionDeclarations: [{ name: "search", description: "...", parameters: {...} }] }
146
+ */
147
+ export function toGeminiTools(tools) {
148
+ if (!tools || tools.length === 0) {
149
+ return { functionDeclarations: [] };
150
+ }
151
+ const functionDeclarations = tools.map((tool, index) => {
152
+ validateTool(tool, index);
153
+ return {
154
+ name: tool.name,
155
+ description: tool.description,
156
+ parameters: {
157
+ type: 'object',
158
+ properties: tool.input_schema.properties,
159
+ ...(tool.input_schema.required && { required: tool.input_schema.required }),
160
+ },
161
+ };
162
+ });
163
+ return { functionDeclarations };
164
+ }
165
+ /**
166
+ * Translate tools to Gemini format as an array (for API compatibility).
167
+ *
168
+ * Some Gemini API versions expect an array containing the tool object.
169
+ * This is a convenience wrapper around toGeminiTools.
170
+ *
171
+ * @param tools - Array of tools in internal format
172
+ * @returns Array containing a single Gemini tool object
173
+ * @throws TranslationError if validation fails
174
+ */
175
+ export function toGeminiToolsArray(tools) {
176
+ if (!tools || tools.length === 0) {
177
+ return [];
178
+ }
179
+ return [toGeminiTools(tools)];
180
+ }
181
+ // ============================================================================
182
+ // Reverse Translation (From Provider Format to Internal)
183
+ // ============================================================================
184
+ /**
185
+ * Translate Anthropic tools to internal format.
186
+ *
187
+ * Since our internal format matches Anthropic, this is essentially a pass-through
188
+ * with validation.
189
+ *
190
+ * @param tools - Array of Anthropic tools
191
+ * @returns Array of tools in internal format
192
+ * @throws TranslationError if validation fails
193
+ */
194
+ export function fromAnthropicTools(tools) {
195
+ if (!tools || tools.length === 0) {
196
+ return [];
197
+ }
198
+ return tools.map((tool, index) => {
199
+ if (!tool.name || typeof tool.name !== 'string') {
200
+ throw new TranslationError(`Anthropic tool at index ${index} is missing a valid name`, 'anthropic', 'internal');
201
+ }
202
+ return {
203
+ name: tool.name,
204
+ description: tool.description || '',
205
+ input_schema: {
206
+ type: 'object',
207
+ properties: tool.input_schema?.properties || {},
208
+ ...(tool.input_schema?.required && { required: tool.input_schema.required }),
209
+ },
210
+ };
211
+ });
212
+ }
213
+ /**
214
+ * Translate OpenAI tools to internal format.
215
+ *
216
+ * Unwraps the function object and converts parameters to input_schema.
217
+ *
218
+ * @param tools - Array of OpenAI tools
219
+ * @returns Array of tools in internal format
220
+ * @throws TranslationError if validation fails
221
+ */
222
+ export function fromOpenAITools(tools) {
223
+ if (!tools || tools.length === 0) {
224
+ return [];
225
+ }
226
+ return tools.map((tool, index) => {
227
+ if (tool.type !== 'function' || !tool.function) {
228
+ throw new TranslationError(`OpenAI tool at index ${index} is not a function tool or is missing function definition`, 'openai', 'internal');
229
+ }
230
+ const func = tool.function;
231
+ if (!func.name || typeof func.name !== 'string') {
232
+ throw new TranslationError(`OpenAI tool at index ${index} is missing a valid function name`, 'openai', 'internal');
233
+ }
234
+ return {
235
+ name: func.name,
236
+ description: func.description || '',
237
+ input_schema: {
238
+ type: 'object',
239
+ properties: func.parameters?.properties || {},
240
+ ...(func.parameters?.required && { required: func.parameters.required }),
241
+ },
242
+ };
243
+ });
244
+ }
245
+ /**
246
+ * Translate Gemini tools to internal format.
247
+ *
248
+ * Extracts function declarations from the Gemini tool object.
249
+ *
250
+ * @param tool - Gemini tool object containing function declarations
251
+ * @returns Array of tools in internal format
252
+ * @throws TranslationError if validation fails
253
+ */
254
+ export function fromGeminiTools(tool) {
255
+ if (!tool?.functionDeclarations || tool.functionDeclarations.length === 0) {
256
+ return [];
257
+ }
258
+ return tool.functionDeclarations.map((func, index) => {
259
+ if (!func.name || typeof func.name !== 'string') {
260
+ throw new TranslationError(`Gemini function declaration at index ${index} is missing a valid name`, 'gemini', 'internal');
261
+ }
262
+ return {
263
+ name: func.name,
264
+ description: func.description || '',
265
+ input_schema: {
266
+ type: 'object',
267
+ properties: func.parameters?.properties || {},
268
+ ...(func.parameters?.required && { required: func.parameters.required }),
269
+ },
270
+ };
271
+ });
272
+ }
273
+ // ============================================================================
274
+ // Helper Functions
275
+ // ============================================================================
276
+ /**
277
+ * Validate a tool definition.
278
+ *
279
+ * @param tool - Tool to validate
280
+ * @param index - Index in the array (for error messages)
281
+ * @throws TranslationError if the tool is invalid
282
+ */
283
+ function validateTool(tool, index) {
284
+ if (!tool) {
285
+ throw new TranslationError(`Tool at index ${index} is null or undefined`, 'internal', 'provider');
286
+ }
287
+ if (!tool.name || typeof tool.name !== 'string') {
288
+ throw new TranslationError(`Tool at index ${index} is missing a valid name`, 'internal', 'provider');
289
+ }
290
+ if (!tool.description || typeof tool.description !== 'string') {
291
+ throw new TranslationError(`Tool "${tool.name}" at index ${index} is missing a valid description`, 'internal', 'provider');
292
+ }
293
+ if (!tool.input_schema || typeof tool.input_schema !== 'object') {
294
+ throw new TranslationError(`Tool "${tool.name}" at index ${index} is missing input_schema`, 'internal', 'provider');
295
+ }
296
+ if (tool.input_schema.type !== 'object') {
297
+ throw new TranslationError(`Tool "${tool.name}" at index ${index} has invalid input_schema type (expected "object")`, 'internal', 'provider');
298
+ }
299
+ if (!tool.input_schema.properties || typeof tool.input_schema.properties !== 'object') {
300
+ throw new TranslationError(`Tool "${tool.name}" at index ${index} is missing input_schema.properties`, 'internal', 'provider');
301
+ }
302
+ }
303
+ /**
304
+ * Translate tools to a specific provider format.
305
+ *
306
+ * Convenience function for dynamic provider selection.
307
+ *
308
+ * @param tools - Array of tools in internal format
309
+ * @param provider - Target provider name
310
+ * @returns Tools in the appropriate provider format
311
+ * @throws TranslationError if the provider is unknown
312
+ */
313
+ export function translateTools(tools, provider) {
314
+ switch (provider) {
315
+ case 'anthropic':
316
+ return toAnthropicTools(tools);
317
+ case 'openai':
318
+ case 'openrouter':
319
+ case 'zai':
320
+ return toOpenAITools(tools);
321
+ case 'google':
322
+ case 'gemini':
323
+ return toGeminiTools(tools);
324
+ case 'ollama':
325
+ // Ollama uses OpenAI-compatible format
326
+ return toOpenAITools(tools);
327
+ default:
328
+ throw new TranslationError(`Unknown provider: ${provider}`, 'internal', provider);
329
+ }
330
+ }
331
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/translation/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAyE1D,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;I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