@aiwg/cli 2026.10.3 → 2026.10.4

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 (279) hide show
  1. package/README.md +2 -2
  2. package/agentic/code/providers/model-capabilities.v1.json +96 -4
  3. package/bin/aiwg.mjs +50 -27
  4. package/dist/src/agents/grounding/knowledge-base.js +54 -6
  5. package/dist/src/artifacts/browser-export.js +6 -0
  6. package/dist/src/artifacts/checksum-manifest.js +1 -0
  7. package/dist/src/artifacts/citation-parser.js +173 -92
  8. package/dist/src/artifacts/citation-table-schema.js +59 -0
  9. package/dist/src/artifacts/cli.js +57 -18
  10. package/dist/src/artifacts/corpus-tools/snapshot.js +1 -1
  11. package/dist/src/artifacts/corpus-tools/vision-extract.js +2 -0
  12. package/dist/src/artifacts/corpus-views/ref-parser.js +3 -1
  13. package/dist/src/artifacts/corpus-views/renderers.js +3 -3
  14. package/dist/src/artifacts/discovery-eval.js +6 -4
  15. package/dist/src/artifacts/fortemi-core-query-adapter.js +36 -3
  16. package/dist/src/artifacts/fortemi-core-sync.js +166 -40
  17. package/dist/src/artifacts/framework-capabilities.js +171 -0
  18. package/dist/src/artifacts/framework-index-paths.js +73 -0
  19. package/dist/src/artifacts/framework-source-digest.js +75 -0
  20. package/dist/src/artifacts/index-builder.js +285 -131
  21. package/dist/src/artifacts/index-files.js +132 -18
  22. package/dist/src/artifacts/index-preparation.js +65 -0
  23. package/dist/src/artifacts/index-refresh.js +576 -0
  24. package/dist/src/artifacts/index-worker.mjs +9 -0
  25. package/dist/src/artifacts/prebuilt-build-lock.js +47 -4
  26. package/dist/src/artifacts/prebuilt-deployment.js +46 -0
  27. package/dist/src/artifacts/prebuilt-relations.js +80 -0
  28. package/dist/src/artifacts/query-engine.js +410 -88
  29. package/dist/src/artifacts/relations-builder.js +168 -0
  30. package/dist/src/artifacts/relations.js +148 -0
  31. package/dist/src/artifacts/stats.js +5 -2
  32. package/dist/src/artifacts/types.js +30 -10
  33. package/dist/src/artifacts/watcher.js +1 -1
  34. package/dist/src/auth/credential-store.js +2 -1
  35. package/dist/src/catalog/cli.d.mts +5 -0
  36. package/dist/src/channel/manager.d.mts +20 -0
  37. package/dist/src/channel/manager.mjs +19 -2
  38. package/dist/src/cli/command-log.js +2 -3
  39. package/dist/src/cli/handlers/artifacts.js +3 -0
  40. package/dist/src/cli/handlers/auth.js +3 -0
  41. package/dist/src/cli/handlers/decision.js +19 -12
  42. package/dist/src/cli/handlers/diagnose.js +4 -3
  43. package/dist/src/cli/handlers/effect.js +4 -2
  44. package/dist/src/cli/handlers/evidence.js +3 -0
  45. package/dist/src/cli/handlers/help.js +1 -0
  46. package/dist/src/cli/handlers/index.js +3 -1
  47. package/dist/src/cli/handlers/init.js +4 -1
  48. package/dist/src/cli/handlers/lint.js +5 -0
  49. package/dist/src/cli/handlers/models.js +104 -8
  50. package/dist/src/cli/handlers/ralph-launcher.js +2 -0
  51. package/dist/src/cli/handlers/refresh.js +12 -0
  52. package/dist/src/cli/handlers/resource-versions.js +3 -0
  53. package/dist/src/cli/handlers/rules.js +195 -0
  54. package/dist/src/cli/handlers/run.js +4 -0
  55. package/dist/src/cli/handlers/runtime-info.js +1 -2
  56. package/dist/src/cli/handlers/script-runner.js +3 -2
  57. package/dist/src/cli/handlers/session.js +19 -9
  58. package/dist/src/cli/handlers/sessions.js +98 -37
  59. package/dist/src/cli/handlers/setup-manifest.js +39 -44
  60. package/dist/src/cli/handlers/setup.js +41 -0
  61. package/dist/src/cli/handlers/steward.js +11 -0
  62. package/dist/src/cli/handlers/subcommands.js +57 -2
  63. package/dist/src/cli/handlers/uhp.js +3 -0
  64. package/dist/src/cli/handlers/use.js +294 -55
  65. package/dist/src/cli/handlers/utilities.js +26 -10
  66. package/dist/src/cli/handlers/version.js +8 -0
  67. package/dist/src/cli/router.js +15 -1
  68. package/dist/src/cli/services/deployment-verification.js +19 -9
  69. package/dist/src/cli/services/provider-prepare-coordinator.js +24 -0
  70. package/dist/src/cli/skill-usage.js +2 -3
  71. package/dist/src/config/aiwg-config.js +87 -37
  72. package/dist/src/config/cli.js +111 -5
  73. package/dist/src/config/decision-config.js +106 -0
  74. package/dist/src/config/dispatch-thresholds-runtime.d.mts +8 -0
  75. package/dist/src/config/gitignore.js +50 -0
  76. package/dist/src/config/index-graph-overrides.js +36 -0
  77. package/dist/src/config/project-artifacts-health.d.mts +37 -0
  78. package/dist/src/config/project-artifacts-runtime.d.mts +16 -0
  79. package/dist/src/config/user-config-dir.d.mts +9 -0
  80. package/dist/src/config/user-config.js +2 -1
  81. package/dist/src/config/user-registry.js +23 -15
  82. package/dist/src/config/user-state.js +7 -0
  83. package/dist/src/decision/ask.js +203 -43
  84. package/dist/src/decision/context-live-qualification.js +2 -2
  85. package/dist/src/decision/driver.js +13 -8
  86. package/dist/src/decision/ensemble/aggregate.js +23 -10
  87. package/dist/src/decision/ensemble-study/multifact-study.js +6 -2
  88. package/dist/src/decision/entry.js +2 -15
  89. package/dist/src/decision/graph-live-qualification.js +1 -1
  90. package/dist/src/decision/graph-run.js +9 -0
  91. package/dist/src/decision/heldout/collector.js +5 -13
  92. package/dist/src/decision/heldout/contract.js +30 -7
  93. package/dist/src/decision/jev-credentials.js +15 -1
  94. package/dist/src/decision/ledger.js +131 -28
  95. package/dist/src/decision/offload-activation.js +137 -0
  96. package/dist/src/decision/offload.js +550 -0
  97. package/dist/src/decision/qualification/load.js +4 -6
  98. package/dist/src/decision/savings.js +28 -0
  99. package/dist/src/effects/types.js +5 -1
  100. package/dist/src/effects/verifiers/git.js +2 -1
  101. package/dist/src/effects/verifiers/tracker.js +26 -14
  102. package/dist/src/extensions/commands/definitions.js +19 -0
  103. package/dist/src/extensions/project-local-remove.js +36 -1
  104. package/dist/src/gates/providers/loader.js +61 -17
  105. package/dist/src/installation/manager-command.d.mts +18 -0
  106. package/dist/src/installation/manager-command.mjs +14 -2
  107. package/dist/src/installation/manager.d.mts +49 -0
  108. package/dist/src/installation/manager.mjs +78 -3
  109. package/dist/src/issues/cli.js +4 -4
  110. package/dist/src/issues/local.js +24 -5
  111. package/dist/src/jobs/runner.js +1 -1
  112. package/dist/src/lint/cli.js +27 -1
  113. package/dist/src/lint/loader.js +2 -1
  114. package/dist/src/lint/reporters.js +25 -1
  115. package/dist/src/lint/rule-activation.js +43 -0
  116. package/dist/src/lint/runner.js +137 -62
  117. package/dist/src/mcp/adapters/codex-runtime.js +7 -1
  118. package/dist/src/mcp/claude-install.d.mts +4 -0
  119. package/dist/src/mcp/claude-install.mjs +41 -0
  120. package/dist/src/mcp/cli.d.mts +1 -0
  121. package/dist/src/mcp/cli.mjs +36 -11
  122. package/dist/src/mcp/config-file.d.mts +28 -0
  123. package/dist/src/mcp/config-layers.d.mts +36 -0
  124. package/dist/src/mcp/credentials.d.mts +51 -0
  125. package/dist/src/mcp/grok-build-config.d.mts +6 -0
  126. package/dist/src/mcp/grok-build-config.mjs +1 -1
  127. package/dist/src/mcp/helpers.mjs +3 -2
  128. package/dist/src/mcp/muse-native-config.d.mts +13 -0
  129. package/dist/src/mcp/muse-native-config.mjs +1 -0
  130. package/dist/src/mcp/omp-config.d.mts +4 -0
  131. package/dist/src/mcp/registry.js +3 -93
  132. package/dist/src/mcp/registry.mjs +3 -87
  133. package/dist/src/mcp/server-config.d.mts +3 -0
  134. package/dist/src/mcp/server-config.mjs +89 -0
  135. package/dist/src/mcp/server.mjs +37 -375
  136. package/dist/src/mcp/test-simple.mjs +2 -1
  137. package/dist/src/mcp/toml-editor.d.mts +4 -0
  138. package/dist/src/mcp/toml-string.d.mts +1 -0
  139. package/dist/src/mcp/toml-strip-mcp.d.mts +1 -0
  140. package/dist/src/mcp/tool-filters.d.mts +46 -0
  141. package/dist/src/mcp/tools/decision.mjs +12 -11
  142. package/dist/src/mcp/tools/discovery.mjs +62 -55
  143. package/dist/src/mcp/tools/orchestration.mjs +12 -2
  144. package/dist/src/mcp/tools/worker-invoke.mjs +1340 -23
  145. package/dist/src/mcp/tools/worker-shell-control.mjs +52 -21
  146. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +3 -3
  147. package/dist/src/mission-protocol/codecs.js +8 -0
  148. package/dist/src/models/config-loader.js +7 -2
  149. package/dist/src/models/model-capabilities.v1.json +96 -4
  150. package/dist/src/models/model-discovery.js +76 -11
  151. package/dist/src/models/provider-policy.js +101 -7
  152. package/dist/src/models/qualification-digest.d.mts +2 -0
  153. package/dist/src/models/resolver.js +12 -10
  154. package/dist/src/models/worker-direct-readiness.js +65 -44
  155. package/dist/src/models/worker-dispatch-offer.js +3 -3
  156. package/dist/src/models/worker-health-readiness.js +16 -3
  157. package/dist/src/models/worker-installation.d.mts +39 -0
  158. package/dist/src/models/worker-installation.mjs +135 -28
  159. package/dist/src/process/bounded-child-process.d.mts +84 -0
  160. package/dist/src/process/bounded-child-process.mjs +43 -0
  161. package/dist/src/process/cli-command.d.mts +16 -0
  162. package/dist/src/process/signal-child.d.mts +6 -0
  163. package/dist/src/process/signal-child.mjs +7 -0
  164. package/dist/src/providers/deployed-skill-roots.js +20 -0
  165. package/dist/src/providers/grok-build-acp.js +3 -2
  166. package/dist/src/providers/grok-build-headless.js +12 -4
  167. package/dist/src/providers/grok-build-inspect.js +1 -0
  168. package/dist/src/providers/omp-agent.d.mts +8 -0
  169. package/dist/src/providers/omp-diagnostics.d.mts +1 -0
  170. package/dist/src/providers/omp-paths.d.mts +13 -0
  171. package/dist/src/providers/skill-ownership.d.mts +9 -0
  172. package/dist/src/providers/skill-ownership.mjs +88 -0
  173. package/dist/src/rules/activation.d.mts +21 -0
  174. package/dist/src/rules/activation.mjs +62 -0
  175. package/dist/src/rules/inline-budget.d.mts +26 -0
  176. package/dist/src/rules/inline-budget.mjs +66 -0
  177. package/dist/src/rules/inventory.js +129 -0
  178. package/dist/src/rules/pin-state.js +73 -0
  179. package/dist/src/rules/pins.d.mts +14 -0
  180. package/dist/src/rules/pins.mjs +112 -0
  181. package/dist/src/rules/rule-frontmatter.schema.json +197 -0
  182. package/dist/src/serve/mission-conductor.js +38 -12
  183. package/dist/src/serve/worker-invocation.js +30 -10
  184. package/dist/src/serve/worker-stdin-frame.d.mts +10 -0
  185. package/dist/src/sessions/adapter-registry.js +23 -19
  186. package/dist/src/sessions/adapters/claude.js +39 -54
  187. package/dist/src/sessions/adapters/codex.js +82 -67
  188. package/dist/src/sessions/adapters/copilot.js +4 -4
  189. package/dist/src/sessions/adapters/cursor.js +40 -57
  190. package/dist/src/sessions/adapters/deepseek-harness.js +15 -12
  191. package/dist/src/sessions/adapters/factory.js +31 -27
  192. package/dist/src/sessions/adapters/generic.js +10 -10
  193. package/dist/src/sessions/adapters/grok-build.js +11 -11
  194. package/dist/src/sessions/adapters/grokbot.js +24 -13
  195. package/dist/src/sessions/adapters/hermes.js +27 -29
  196. package/dist/src/sessions/adapters/muse-workspace-scan.js +31 -11
  197. package/dist/src/sessions/adapters/muse.js +150 -93
  198. package/dist/src/sessions/adapters/omp.js +28 -14
  199. package/dist/src/sessions/adapters/openclaw.js +89 -79
  200. package/dist/src/sessions/adapters/opencode.js +27 -24
  201. package/dist/src/sessions/adapters/openhuman.js +18 -60
  202. package/dist/src/sessions/adapters/pi.js +29 -14
  203. package/dist/src/sessions/adapters/warp.js +3 -3
  204. package/dist/src/sessions/adapters/windsurf.js +19 -48
  205. package/dist/src/sessions/batch-contracts.js +16 -8
  206. package/dist/src/sessions/batch-import.js +51 -11
  207. package/dist/src/sessions/contracts.js +40 -2
  208. package/dist/src/sessions/coverage-preflight.js +1 -1
  209. package/dist/src/sessions/export-plan.js +4 -3
  210. package/dist/src/sessions/import-exclusions.js +72 -0
  211. package/dist/src/sessions/import-lease.js +34 -18
  212. package/dist/src/sessions/import-limits.js +37 -0
  213. package/dist/src/sessions/importer.js +60 -38
  214. package/dist/src/sessions/lifecycle.js +45 -0
  215. package/dist/src/sessions/policy.js +133 -25
  216. package/dist/src/sessions/readers.js +106 -53
  217. package/dist/src/sessions/refresh.js +106 -0
  218. package/dist/src/sessions/repository.js +147 -52
  219. package/dist/src/sessions/workspace-discovery.js +221 -56
  220. package/dist/src/sessions/workspace-matching.js +107 -0
  221. package/dist/src/skills/importer.js +1 -0
  222. package/dist/src/smiths/context-pipeline/aiwg-md.js +11 -0
  223. package/dist/src/smiths/context-pipeline/claude-hook.js +3 -26
  224. package/dist/src/smiths/context-pipeline/finalization.js +6 -5
  225. package/dist/src/smiths/context-pipeline/generator.js +21 -4
  226. package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -15
  227. package/dist/src/smiths/mcpsmith/generator.js +1 -1
  228. package/dist/src/smiths/toolsmith/runtime-discovery.d.mts +10 -0
  229. package/dist/src/smiths/toolsmith/runtime-discovery.mjs +76 -18
  230. package/dist/src/storage/backends/fs.js +18 -76
  231. package/dist/src/storage/backends/obsidian.js +1 -0
  232. package/dist/src/tracker/forge-http.js +2 -1
  233. package/dist/src/update/checker.d.mts +2 -0
  234. package/dist/src/update/service.d.mts +22 -0
  235. package/dist/src/utils/contained-filesystem.d.mts +37 -0
  236. package/dist/src/utils/contained-filesystem.mjs +683 -0
  237. package/dist/src/utils/temporary-directory.js +36 -0
  238. package/dist/src/writing/example-generator.js +1 -1
  239. package/package.json +15 -2
  240. package/schemas/models/model-catalog.v1.schema.json +1 -1
  241. package/schemas/models/provider-model-capabilities.v1.schema.json +6 -0
  242. package/tools/_resolve-impl.mjs +13 -15
  243. package/tools/agents/deploy-agents.mjs +49 -21
  244. package/tools/agents/providers/base.mjs +104 -134
  245. package/tools/agents/providers/claude.mjs +8 -24
  246. package/tools/agents/providers/codex.mjs +18 -11
  247. package/tools/agents/providers/cursor.mjs +19 -18
  248. package/tools/agents/providers/grok-build.mjs +3 -1
  249. package/tools/agents/providers/hermes.mjs +57 -47
  250. package/tools/agents/providers/openclaw.mjs +9 -4
  251. package/tools/agents/providers/pi.mjs +5 -0
  252. package/tools/agents/providers/provider-prepare-channel.mjs +5 -0
  253. package/tools/agents/providers/provider-prepare-coordinator.mjs +247 -0
  254. package/tools/agents/providers/provider-prepare-worker.mjs +84 -0
  255. package/tools/agents/providers/rule-delivery.mjs +1270 -0
  256. package/tools/agents/providers/warp.mjs +20 -26
  257. package/tools/cli/decision-offload-report.mjs +40 -0
  258. package/tools/cli/workspace-status.mjs +862 -0
  259. package/tools/plugin/package-plugins.mjs +186 -8
  260. package/tools/plugin/plugin-links.mjs +114 -0
  261. package/tools/providers/antigravity-transport.mjs +3 -1
  262. package/tools/providers/deepseek-harness-transport.mjs +6 -4
  263. package/tools/providers/omp-transport.mjs +4 -2
  264. package/tools/ralph-external/lib/consecutive-failure-circuit-breaker.mjs +1748 -0
  265. package/tools/ralph-external/lib/launcher-recovery-evidence.mjs +55 -0
  266. package/tools/ralph-external/lib/omp-adapter.mjs +1 -1
  267. package/tools/ralph-external/lib/pi-adapter.mjs +0 -4
  268. package/tools/ralph-external/lib/provider-adapter.mjs +59 -1
  269. package/tools/ralph-external/lib/recovery-probe.mjs +72 -0
  270. package/tools/ralph-external/lib/session-environment.mjs +28 -0
  271. package/tools/ralph-external/lib/systemd-client.mjs +49 -0
  272. package/tools/ralph-external/lib/worker-health.mjs +1 -1
  273. package/tools/ralph-external/lib/worker-isolation.mjs +717 -0
  274. package/tools/ralph-external/lib/worker-overflow.mjs +50 -0
  275. package/tools/ralph-external/process-monitor.mjs +1017 -0
  276. package/tools/ralph-external/session-launcher.mjs +5057 -0
  277. package/tools/scripts/resource-preflight.mjs +541 -0
  278. package/tools/skills/deploy-skills-codex.mjs +2 -1
  279. package/vscode-extension/schemas/aiwg.config.v1.json +1194 -231
@@ -0,0 +1,41 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ import { assertConfigDestination, assertConfigObject } from './config-file.mjs';
5
+
6
+ /** Desktop is a user-level surface, independent of the Code project config. */
7
+ export function claudeDesktopConfigPath(platform = process.platform, env = process.env) {
8
+ const home = env.HOME || env.USERPROFILE || os.homedir();
9
+ const base = platform === 'darwin' ? path.join(home, 'Library', 'Application Support')
10
+ : platform === 'win32' ? (env.APPDATA || path.join(home, 'AppData', 'Roaming'))
11
+ : path.join(home, '.config');
12
+ return path.join(base, 'Claude', 'claude_desktop_config.json');
13
+ }
14
+
15
+ export function resolveClaudeInstallTarget(target, scope, env = process.env) {
16
+ if (target !== 'claude') return target;
17
+ return scope === 'user' || env.CLAUDECODE || env.CLAUDE_CODE_ENTRYPOINT || env.CLAUDE_CODE_DESKTOP_APP_VERSION
18
+ ? 'claude-code' : 'claude-desktop';
19
+ }
20
+
21
+ /** Plan removal only of the exact legacy built-in stanza, never custom servers. */
22
+ export async function legacyClaudeMigration(projectDir) {
23
+ const file = path.resolve(projectDir, '.claude/settings.local.json');
24
+ await assertConfigDestination(file, projectDir);
25
+ let settings;
26
+ try {
27
+ settings = JSON.parse(await fs.readFile(file, 'utf8'));
28
+ } catch (error) {
29
+ if (error.code === 'ENOENT') return [];
30
+ throw error;
31
+ }
32
+ assertConfigObject(settings, 'mcpServers');
33
+ const server = settings.mcpServers?.aiwg;
34
+ if (!server || server.command !== 'aiwg' || JSON.stringify(server.args) !== '["mcp","serve"]'
35
+ || Object.keys(server).some(key => !['command', 'args', 'env'].includes(key))
36
+ || (server.env !== undefined && (!server.env || typeof server.env !== 'object' || Array.isArray(server.env)
37
+ || Object.keys(server.env).some(key => key !== 'AIWG_ROOT')))) return [];
38
+ delete settings.mcpServers.aiwg;
39
+ if (Object.keys(settings.mcpServers).length === 0) delete settings.mcpServers;
40
+ return [{ file, content: JSON.stringify(settings, null, 2), options: { projectRoot: projectDir } }];
41
+ }
@@ -0,0 +1 @@
1
+ export function main(args?: string[]): Promise<void>;
@@ -31,6 +31,7 @@ import {
31
31
  import { assertCredentialPolicy, CREDENTIAL_POLICIES, installPolicyCheckedServer, redactCredentialArgs, redactCredentialText, redactCredentialRecord, resolveCredentialPolicy } from './credentials.mjs';
32
32
  import { getMcpInjectionDefinition } from '../providers/provider-definitions.mjs';
33
33
  import { manageOmpMcp } from './omp-config.mjs';
34
+ import { claudeDesktopConfigPath, resolveClaudeInstallTarget, legacyClaudeMigration } from './claude-install.mjs';
34
35
  import { unmanageGrokBuildMcp } from './grok-build-config.mjs';
35
36
 
36
37
  /**
@@ -197,6 +198,9 @@ Inject Options:
197
198
  Serve Options:
198
199
  --transport <type> Transport type: stdio (default), http
199
200
  --port <number> Port for HTTP transport (default: 3100)
201
+ --toolsets <csv> Opt-in toolsets: flows, missions, memory, kb, research,
202
+ activity-log, index, ralph, mc, ops, sandbox, decision, workers
203
+ all excludes workers; enable explicitly with --toolsets all,workers
200
204
 
201
205
  Examples:
202
206
  # Define MCP servers
@@ -222,7 +226,8 @@ Examples:
222
226
  aiwg mcp remove fortemi
223
227
 
224
228
  # Install AIWG's own MCP server
225
- aiwg mcp install claude
229
+ aiwg mcp install claude-code
230
+ aiwg mcp install claude-desktop
226
231
  aiwg mcp serve
227
232
  aiwg mcp info
228
233
  `);
@@ -235,7 +240,11 @@ async function generateConfig(target, projectDir = '.', scope = 'project') {
235
240
  const homeDir = process.env.HOME || process.env.USERPROFILE;
236
241
 
237
242
  const configs = {
238
- claude: {
243
+ 'claude-desktop': {
244
+ path: claudeDesktopConfigPath(),
245
+ content: { mcpServers: { aiwg: { command: 'aiwg', args: ['mcp', 'serve'] } } },
246
+ },
247
+ 'claude-code': {
239
248
  path: scope === 'user' ? path.join(homeDir, '.claude.json') : path.join(projectDir, '.mcp.json'),
240
249
  userScope: scope === 'user',
241
250
  content: {
@@ -552,7 +561,7 @@ enabled_tools = [
552
561
  // other target's `configs[...]` entry above is a fixed `aiwg mcp serve`
553
562
  // stdio/TOML stanza with no env/headers field, so there is nothing further
554
563
  // for assertProjectCredentials to check there.
555
- if (target === 'claude' && scope !== 'user') {
564
+ if (target === 'claude-code' && scope !== 'user') {
556
565
  assertProjectCredentials(Object.entries(config.content.mcpServers).map(([name, server]) => ({ name, ...server })), config.path);
557
566
  }
558
567
 
@@ -568,7 +577,13 @@ enabled_tools = [
568
577
  }
569
578
  };
570
579
 
571
- await writeConfigAtomic(config.path, JSON.stringify(merged, null, 2), { userScope, projectRoot });
580
+ const migration = ['claude-code', 'claude-desktop'].includes(target)
581
+ ? await legacyClaudeMigration(projectDir) : [];
582
+ await writeConfigTransaction([
583
+ { file: config.path, content: JSON.stringify(merged, null, 2), options: { userScope, projectRoot } },
584
+ ...migration,
585
+ ]);
586
+ if (migration.length) console.log('Removed legacy AIWG MCP entry from .claude/settings.local.json');
572
587
  console.log(`MCP configuration written to: ${config.path}`);
573
588
  console.log(`\nTo use AIWG MCP server with ${target}:`);
574
589
  console.log(` 1. Restart ${target}`);
@@ -589,20 +604,22 @@ POSITIONING:
589
604
  MCP is optional and provider-agnostic. Baseline AIWG reachability is file
590
605
  deployment plus CLI discovery: aiwg discover / aiwg show <type> <name>.
591
606
 
592
- CORE TOOLS (15, always registered):
607
+ CORE TOOLS (17, always registered):
593
608
  discover Cross-type ranked catalog search
594
609
  skill-list / skill-show Skill catalog and SKILL.md body fetch
595
610
  command-list / command-show CLI command catalog and command spec fetch
611
+ rule-inventory Scoped rule activation and binding inventory
596
612
  rule-list / rule-show Rule catalog and rule body fetch
597
613
  agent-list / agent-show Agent catalog and agent definition fetch
598
614
  template-list / template-show Template catalog and raw template fetch
599
615
  template-render Render AIWG template with variables
600
616
  command-run Allow-listed CLI dispatch; confirmation-gated when needed
601
617
  artifact-read / artifact-write Project .aiwg/ artifact IO
618
+ ask-user Structured user question via elicitation or Markdown
602
619
 
603
- OPT-IN TOOLSETS (60 additional tools):
620
+ OPT-IN TOOLSETS (71 additional tools, including explicit workers):
604
621
  flows flow-list / flow-show / flow-run
605
- missions mission-guide / mission-dispatch / mission-status
622
+ missions mission-guide / mission-dispatch / mission-status / worker-resolve
606
623
  memory memory-* and reflections-* storage operations
607
624
  kb kb-* storage operations
608
625
  research provenance-* and research-store-* storage operations
@@ -612,10 +629,13 @@ OPT-IN TOOLSETS (60 additional tools):
612
629
  mc start / dispatch / status / stop / list
613
630
  ops status / list / use / push
614
631
  sandbox fleet inventory / mutation / reconciliation and governed activity
632
+ decision validation / evaluation / rules / features / calibration
633
+ workers worker-invoke (explicit opt-in; all excludes workers)
615
634
 
616
635
  Enable opt-in tools:
617
636
  AIWG_MCP_TOOLSETS=flows,missions,memory,kb,ralph,sandbox aiwg mcp serve
618
- aiwg mcp serve --toolsets=all
637
+ aiwg mcp serve --toolsets all
638
+ aiwg mcp serve --toolsets all,workers # explicitly enable worker-invoke
619
639
 
620
640
  RESOURCES:
621
641
  aiwg://prompts/catalog List of prompt templates
@@ -636,7 +656,7 @@ TRANSPORTS:
636
656
 
637
657
  ENVIRONMENT:
638
658
  AIWG_ROOT Path to AIWG installation (default: ~/.local/share/ai-writing-guide)
639
- AIWG_MCP_TOOLSETS Comma-separated opt-in toolsets; use all for every toolset
659
+ AIWG_MCP_TOOLSETS Comma-separated opt-in toolsets; all excludes workers
640
660
  AIWG_SANDBOX_MANAGEMENT_URL Sandbox management API origin (HTTPS except loopback)
641
661
  AIWG_SANDBOX_MANAGEMENT_TOKEN_FILE Mode-0600 management bearer file for sandbox tools
642
662
 
@@ -1627,7 +1647,11 @@ export async function main(args = process.argv.slice(2)) {
1627
1647
  const scope = parseFlag(args, '--scope') || 'project';
1628
1648
  if (!['project', 'user'].includes(scope)) throw new Error('Scope must be project or user');
1629
1649
  const installArgs = args.slice(1).filter((a, index, rest) => !a.startsWith('--') && !['--scope', '--project'].includes(rest[index - 1]));
1630
- const target = installArgs[0] || 'claude';
1650
+ const requestedTarget = installArgs[0] || 'claude';
1651
+ const target = resolveClaudeInstallTarget(requestedTarget, scope);
1652
+ if (requestedTarget === 'claude') {
1653
+ console.warn(`Deprecated MCP install target "claude" selected ${target}; use "aiwg mcp install ${target}" explicitly.`);
1654
+ }
1631
1655
  const projectDir = parseFlag(args, '--project') || installArgs[1] || '.';
1632
1656
 
1633
1657
  // Check for --dry-run flag
@@ -1636,7 +1660,8 @@ export async function main(args = process.argv.slice(2)) {
1636
1660
  console.log(`[DRY RUN] Would generate MCP config for: ${target}`);
1637
1661
  console.log(`[DRY RUN] Target directory: ${projectDir}`);
1638
1662
  const configPaths = {
1639
- claude: scope === 'user' ? path.join(homeDir, '.claude.json') : path.join(projectDir, '.mcp.json'),
1663
+ 'claude-desktop': claudeDesktopConfigPath(),
1664
+ 'claude-code': scope === 'user' ? path.join(homeDir, '.claude.json') : path.join(projectDir, '.mcp.json'),
1640
1665
  cursor: '.cursor/mcp.json',
1641
1666
  factory: (projectDir === '.' || projectDir === 'global')
1642
1667
  ? path.join(homeDir, '.factory/mcp.json')
@@ -0,0 +1,28 @@
1
+ import type { Stats } from 'node:fs';
2
+
3
+ export function assertNoSymlinkParents(file: string, configRoot?: string): Promise<void>;
4
+ export function assertConfigDestination(file: string, projectRoot?: string): Promise<Stats | null>;
5
+ export function isUserMcpScope(provider: string, scope?: string): boolean;
6
+ export function isPathInsideDir(file: string, dir: string): boolean;
7
+ export function assertSupportedScope(provider: string, scope: string | undefined, configPath: string, projectDir?: string): void;
8
+ export function classifyMcpDestination(provider: string, scope: string | undefined, configPath: string, projectDir?: string): { userScope: boolean; projectRoot: string | undefined };
9
+ export function projectCredentialRemedy(provider: string, projectDir?: string): string;
10
+ export function assertProjectCredentials(servers: Array<{ name: string; url?: string; args?: string[]; env?: Record<string, unknown>; headers?: Record<string, unknown>; auth?: Record<string, unknown>; oauth?: Record<string, unknown> }>, configPath: string, remedy?: string): void;
11
+ export function assertConfigObject(config: unknown, serversKey: string): void;
12
+ export interface ConfigWriteOptions {
13
+ userScope?: boolean;
14
+ rejectSymlinkParents?: boolean;
15
+ symlinkRoot?: string;
16
+ projectRoot?: string;
17
+ newFileMode?: number;
18
+ mode?: number;
19
+ }
20
+ export interface ConfigWrite {
21
+ file: string;
22
+ content: string | Uint8Array;
23
+ options?: ConfigWriteOptions;
24
+ }
25
+ export function writeConfigAtomic(file: string, content: string | Uint8Array, options?: ConfigWriteOptions): Promise<void>;
26
+ export function canonicalConfigPath(file: string): Promise<string>;
27
+ export function prepareConfigWrite(file: string, options?: ConfigWriteOptions): Promise<void>;
28
+ export function writeConfigTransaction(writes: ConfigWrite[]): Promise<void>;
@@ -0,0 +1,36 @@
1
+ export interface Layering {
2
+ lowerPolicy?: import('./credentials.mjs').McpCredentialPolicy;
3
+ /** Config file of the lower layer that set `lowerPolicy`, for diagnostics. */
4
+ lowerPolicySource?: string;
5
+ ownPolicy?: import('./credentials.mjs').McpCredentialPolicy;
6
+ effectivePolicy?: import('./credentials.mjs').McpCredentialPolicy;
7
+ lower: Map<string, string>;
8
+ own: Set<string>;
9
+ lowerFields: Map<string, string>;
10
+ ownFields: Set<string>;
11
+ }
12
+
13
+ export function resolveConfigLayers(
14
+ configDirOverride?: string,
15
+ env?: Record<string, string | undefined>,
16
+ options?: { platform?: string },
17
+ ): string[] | null;
18
+ export function loadLayered<T extends object>(
19
+ layers: string[],
20
+ filename: string,
21
+ collection: string,
22
+ defaults: T,
23
+ ): Promise<{ data: T; layering: Layering }>;
24
+ export function isLowerLayerEntry(layering: Layering, name: string): boolean;
25
+ export function lowerEntryQualified(layering: Layering, name: string): boolean;
26
+ export function writeLayerData<T extends object>(data: T, collection: string, layering: Layering, explicitPolicy?: boolean): T;
27
+ export function resolveProfileExtends<P extends {
28
+ extends?: string[];
29
+ servers?: string[];
30
+ providerOverrides?: Record<string, { toolDeny?: string[]; toolAllow?: string[] }>;
31
+ }>(name: string, profiles: Record<string, P>, seen?: string[]): P & { servers: string[] };
32
+
33
+ export function assertLayerWriteDestination(layers: string[], filename: string): Promise<void>;
34
+ export function saveLayerData(file: string, data: object, collection: string, layers: string[] | null, layering: Layering | null, explicitPolicy?: boolean): Promise<void>;
35
+
36
+ export function isCaseInsensitivePath(path: string): Promise<boolean>;
@@ -0,0 +1,51 @@
1
+ export type McpCredentialPolicy = 'literal' | 'references' | 'none';
2
+
3
+ interface CredentialBearingServer {
4
+ name: string;
5
+ url?: string;
6
+ args?: string[];
7
+ env?: Record<string, string>;
8
+ headers?: Record<string, string>;
9
+ headerEnv?: Record<string, string>;
10
+ envFrom?: Record<string, string>;
11
+ auth?: { clientSecret?: string; tokenUrl?: string; redirectUri?: string; resource?: string };
12
+ oauth?: { clientSecret?: string; tokenUrl?: string; redirectUri?: string; resource?: string };
13
+ }
14
+
15
+ export const ENV_REFERENCE_SYNTAX: Readonly<Record<string, string | null>>;
16
+ export const CREDENTIAL_POLICIES: readonly McpCredentialPolicy[];
17
+ export function urlCarriesUserinfo(url?: string): boolean;
18
+ export function credentialLikeQueryParams(url?: string, options?: { includeReferences?: boolean }): string[];
19
+ export function credentialLikeFragmentParams(url?: string, options?: { includeReferences?: boolean }): string[];
20
+ export function isCredentialReferenceValue(value: unknown): boolean;
21
+ export function credentialLikeArgs(args?: string[], options?: { includeReferences?: boolean }): string[];
22
+ export function redactCredentialArgs(args?: string[]): string[] | undefined;
23
+ export function validateEnvReferenceName(name: string): void;
24
+ export function renderCredentialMaps(
25
+ server: CredentialBearingServer,
26
+ provider: string,
27
+ ): { env?: Record<string, string>; headers?: Record<string, string> };
28
+ export function credentialPolicyViolations(server: CredentialBearingServer, policy?: McpCredentialPolicy): string[];
29
+ export function assertCredentialPolicy(servers: CredentialBearingServer[], policy?: McpCredentialPolicy): void;
30
+ export function resolveCredentialPolicy(options?: {
31
+ flag?: string;
32
+ registryPolicy?: string;
33
+ floorPolicy?: string;
34
+ floorSource?: string;
35
+ env?: Record<string, string | undefined>;
36
+ }): McpCredentialPolicy;
37
+
38
+ export function stricterCredentialPolicy(
39
+ a: McpCredentialPolicy | undefined,
40
+ b: McpCredentialPolicy | undefined,
41
+ ): McpCredentialPolicy | undefined;
42
+
43
+ export function warnCredentialPolicyRelaxation(candidate: McpCredentialPolicy, floor: McpCredentialPolicy, source?: string): void;
44
+ export function warnDroppedOverlayPolicy(candidate: McpCredentialPolicy, floor: McpCredentialPolicy, source?: string): void;
45
+ export function resetCredentialPolicyWarnings(): void;
46
+
47
+ export const INSTALL_POLICY_EXEMPT_ENV: Readonly<Record<string, readonly string[]>>;
48
+ export function installPolicyCheckedServer(name: string, server: CredentialBearingServer): CredentialBearingServer;
49
+
50
+ export function redactCredentialText(value: string): string;
51
+ export function redactCredentialRecord<T>(value: T): T;
@@ -0,0 +1,6 @@
1
+ export function renderGrokMcpServer(server: any): string;
2
+ export function mergeGrokMcpServers(text: string, servers: any[]): string;
3
+ export function removeGrokMcpServers(text: string, names: string[]): { text: string; removed: string[] };
4
+ export function manageGrokBuildMcp(configPath: string, servers: any[], options?: any): Promise<any>;
5
+ export function unmanageGrokBuildMcp(configPath: string, names: string[], options?: any): Promise<any>;
6
+ export function inspectGrokBuildNative(options?: any): Promise<any>;
@@ -144,7 +144,7 @@ export async function unmanageGrokBuildMcp(configPath, names, options = {}) {
144
144
  }
145
145
 
146
146
  function runJson(binary, args, cwd, env) {
147
- const run = spawnSync(binary, args, { cwd, env, encoding: 'utf8', timeout: 30_000 });
147
+ const run = spawnSync(binary, args, { cwd, env, encoding: 'utf8', timeout: 30_000, killSignal: 'SIGKILL' });
148
148
  if (run.error || run.status !== 0) return { ok: false, detail: run.error?.message || run.stderr || `exit ${run.status}` };
149
149
  try { return { ok: true, value: JSON.parse(run.stdout || '{}') }; }
150
150
  catch { return { ok: false, detail: 'Grok returned malformed JSON' }; }
@@ -5,6 +5,7 @@
5
5
  * @issues #1311 (scope split), #1312 (command-run), #1313 (discover + pairs)
6
6
  */
7
7
 
8
+ import { signalChild } from '../process/signal-child.mjs';
8
9
  import { spawn } from 'node:child_process';
9
10
  import { StringDecoder } from 'node:string_decoder';
10
11
  import fs from 'node:fs/promises';
@@ -287,11 +288,11 @@ export function runAiwgCli(args, { cwd, env, timeoutMs = 120_000, input } = {})
287
288
  // owned child one second to exit gracefully, then escalate cleanup.
288
289
  reject(err);
289
290
  killTimer = setTimeout(() => {
290
- try { proc.kill('SIGKILL'); } catch { /* child may already have exited */ }
291
+ try { signalChild(proc, 'SIGKILL'); } catch { /* child may already have exited */ }
291
292
  }, 1000);
292
293
  killTimer.unref?.();
293
294
  // Install cleanup first: kill() can synchronously trigger close in an adapter.
294
- try { proc.kill('SIGTERM'); } catch { /* retain the original failure */ }
295
+ try { signalChild(proc, 'SIGTERM'); } catch { /* retain the original failure */ }
295
296
  };
296
297
  const timer = setTimeout(() => {
297
298
  rejectAndTerminate(new Error(`aiwg ${args[0] || ''} timed out after ${timeoutMs}ms`));
@@ -0,0 +1,13 @@
1
+ export type MuseNativeInspection = {
2
+ cli: string;
3
+ hooks: 'absent' | 'managed' | 'operator-only';
4
+ mcp: 'absent' | 'configured' | 'unreadable';
5
+ };
6
+
7
+ export function inspectMuseNative(options?: {
8
+ projectDir?: string;
9
+ env?: Record<string, string | undefined>;
10
+ userHome?: string;
11
+ }): Promise<MuseNativeInspection>;
12
+
13
+ export function isMuseDeployedProject(projectDir?: string): Promise<boolean>;
@@ -50,6 +50,7 @@ function inspectMuseCli(env) {
50
50
  env,
51
51
  encoding: 'utf8',
52
52
  timeout: MUSE_VERSION_TIMEOUT_MS,
53
+ killSignal: 'SIGKILL',
53
54
  });
54
55
  if (result.error?.code === 'ENOENT') return 'absent';
55
56
  if (result.error?.code === 'ETIMEDOUT') return 'present (version timeout)';
@@ -0,0 +1,4 @@
1
+ export function ompServerConfig(server: Record<string, any>): Record<string, any>;
2
+ export function manageOmpMcp(configPath: string, servers: Array<{name: string; [key: string]: any}>, options?: {dryRun?: boolean; remove?: string[]; userScope?: boolean; projectRoot?: string}): Promise<{
3
+ configPath: string; serversInjected: string[]; alreadyPresent: string[]; removed: string[];
4
+ }>;
@@ -1,4 +1,5 @@
1
1
  import { tomlString } from './toml-string.mjs';
2
+ import { buildServerConfig as renderServerConfig } from './server-config.mjs';
2
3
  import { isLowerLayerEntry, loadLayered, lowerEntryQualified, resolveConfigLayers, saveLayerData } from './config-layers.mjs';
3
4
  import { assertConfigDestination, assertProjectCredentials, classifyMcpDestination, projectCredentialRemedy, writeConfigAtomic, writeConfigTransaction } from './config-file.mjs';
4
5
  import { manageOmpMcp } from './omp-config.mjs';
@@ -6,7 +7,7 @@ import { manageGrokBuildMcp } from './grok-build-config.mjs';
6
7
  import { replaceServer } from './toml-editor.mjs';
7
8
  import { resolveOmpPaths } from '../providers/omp-paths.mjs';
8
9
  import { applyJsonToolFilterPlan, claudeSettingsPath, prepareClaudePermissions, planToolFilters } from './tool-filters.mjs';
9
- import { assertCredentialPolicy, resolveCredentialPolicy, renderCredentialMaps, validateEnvReferenceName } from './credentials.mjs';
10
+ import { assertCredentialPolicy, resolveCredentialPolicy, validateEnvReferenceName } from './credentials.mjs';
10
11
  /**
11
12
  * MCP Server Registry
12
13
  *
@@ -22,7 +23,6 @@ import { qualifyWorkerInvocationProfile, requiredWorkerControls } from '../model
22
23
  import { dirname, isAbsolute, resolve } from 'path';
23
24
  import { homedir } from 'os';
24
25
  import { resolveConfigDir } from '../config/user-config.js';
25
- import { getProviderDefinition } from '../providers/provider-definitions.js';
26
26
  // ============================================
27
27
  // Registry
28
28
  // ============================================
@@ -314,97 +314,7 @@ export class McpServerRegistry {
314
314
  * Build the MCP config block for a single server in a given provider's format.
315
315
  */
316
316
  export function buildServerConfig(server, provider) {
317
- const adapter = getProviderDefinition(provider)?.adapters.mcpInjection;
318
- const { env, headers } = adapter && adapter !== 'codex'
319
- ? renderCredentialMaps(server, adapter)
320
- : { env: server.env, headers: server.headers };
321
- switch (adapter) {
322
- case 'antigravity': {
323
- if (server.type === 'stdio') {
324
- return { command: server.command, args: server.args || [], ...(env ? { env } : {}) };
325
- }
326
- return { serverUrl: server.url, ...(headers ? { headers } : {}) };
327
- }
328
- case 'claude-code': {
329
- if (server.type === 'stdio') {
330
- return {
331
- command: server.command,
332
- args: server.args || [],
333
- ...(env ? { env } : {}),
334
- };
335
- }
336
- // Claude Code skips a url entry that has no type.
337
- return {
338
- type: server.type,
339
- url: server.url,
340
- ...(headers ? { headers } : {}),
341
- };
342
- }
343
- case 'cursor': {
344
- if (server.type === 'stdio') {
345
- return {
346
- command: server.command,
347
- args: server.args || [],
348
- ...(env ? { env } : {}),
349
- };
350
- }
351
- return {
352
- url: server.url,
353
- ...(headers ? { headers } : {}),
354
- };
355
- }
356
- case 'factory': {
357
- if (server.type === 'stdio') {
358
- return {
359
- type: 'stdio',
360
- command: server.command,
361
- args: server.args || [],
362
- disabled: false,
363
- ...(env ? { env } : {}),
364
- };
365
- }
366
- return {
367
- type: server.type,
368
- url: server.url,
369
- disabled: false,
370
- ...(headers ? { headers } : {}),
371
- };
372
- }
373
- case 'opencode': {
374
- if (server.type === 'stdio') {
375
- return {
376
- type: 'local',
377
- command: [server.command, ...(server.args || [])],
378
- // opencode names a local server's variables `environment`.
379
- ...(env ? { environment: env } : {}),
380
- };
381
- }
382
- return {
383
- type: 'remote',
384
- url: server.url,
385
- ...(headers ? { headers } : {}),
386
- };
387
- }
388
- case 'windsurf':
389
- case 'warp': {
390
- if (server.type === 'stdio') {
391
- return {
392
- command: server.command,
393
- args: server.args || [],
394
- ...(env ? { env } : {}),
395
- };
396
- }
397
- return {
398
- url: server.url,
399
- ...(headers ? { headers } : {}),
400
- };
401
- }
402
- case 'codex':
403
- // TOML format handled separately
404
- return {};
405
- default:
406
- return {};
407
- }
317
+ return renderServerConfig(server, provider);
408
318
  }
409
319
  function tomlKey(value) {
410
320
  return typeof value === 'string' && /^[A-Za-z0-9_-]+$/.test(value) ? value : tomlString(value);
@@ -1,4 +1,6 @@
1
1
  import { tomlString } from './toml-string.mjs';
2
+ import { buildServerConfig } from './server-config.mjs';
3
+ export { buildServerConfig } from './server-config.mjs';
2
4
  import { isLowerLayerEntry, loadLayered, lowerEntryQualified, resolveConfigLayers, saveLayerData } from './config-layers.mjs';
3
5
  import { assertConfigDestination, assertProjectCredentials, classifyMcpDestination, projectCredentialRemedy, writeConfigAtomic, writeConfigTransaction } from './config-file.mjs';
4
6
  import { manageOmpMcp } from './omp-config.mjs';
@@ -6,7 +8,7 @@ import { manageGrokBuildMcp } from './grok-build-config.mjs';
6
8
  import { replaceServer } from './toml-editor.mjs';
7
9
  import { resolveOmpPaths } from '../providers/omp-paths.mjs';
8
10
  import { applyJsonToolFilterPlan, claudeSettingsPath, prepareClaudePermissions, planToolFilters } from './tool-filters.mjs';
9
- import { assertCredentialPolicy, resolveCredentialPolicy, renderCredentialMaps, validateEnvReferenceName } from './credentials.mjs';
11
+ import { assertCredentialPolicy, resolveCredentialPolicy, validateEnvReferenceName } from './credentials.mjs';
10
12
  /**
11
13
  * MCP Server Registry (Runtime ESM)
12
14
  *
@@ -292,92 +294,6 @@ export class McpServerRegistry {
292
294
  // Provider injection logic
293
295
  // ============================================
294
296
 
295
- export function buildServerConfig(server, provider) {
296
- const mcpDefinition = getMcpInjectionDefinition(provider);
297
- // TOML providers render references through their own named keys in
298
- // buildServerToml; unconditional interpolation would refuse them here even
299
- // though the TOML writer handles them.
300
- const { env, headers } = mcpDefinition?.serverConfigFormat === 'toml'
301
- ? {}
302
- : renderCredentialMaps(server, normalizeRuntimeProviderId(provider) || provider);
303
-
304
- switch (mcpDefinition?.serverConfigFormat) {
305
- case 'claude-code': {
306
- if (server.type === 'stdio') {
307
- return {
308
- command: server.command,
309
- args: server.args || [],
310
- ...(env ? { env } : {}),
311
- };
312
- }
313
- // Claude Code skips a url entry that has no type.
314
- return {
315
- type: server.type,
316
- url: server.url,
317
- ...(headers ? { headers } : {}),
318
- };
319
- }
320
- case 'antigravity': {
321
- if (server.type === 'stdio') {
322
- return { command: server.command, args: server.args || [], ...(env ? { env } : {}) };
323
- }
324
- return { serverUrl: server.url, ...(headers ? { headers } : {}) };
325
- }
326
- case 'standard': {
327
- if (server.type === 'stdio') {
328
- return {
329
- command: server.command,
330
- args: server.args || [],
331
- ...(env ? { env } : {}),
332
- };
333
- }
334
- return {
335
- url: server.url,
336
- ...(headers ? { headers } : {}),
337
- };
338
- }
339
-
340
- case 'factory': {
341
- if (server.type === 'stdio') {
342
- return {
343
- type: 'stdio',
344
- command: server.command,
345
- args: server.args || [],
346
- disabled: false,
347
- ...(env ? { env } : {}),
348
- };
349
- }
350
- return {
351
- type: server.type,
352
- url: server.url,
353
- disabled: false,
354
- ...(headers ? { headers } : {}),
355
- };
356
- }
357
-
358
- case 'opencode': {
359
- if (server.type === 'stdio') {
360
- // opencode names a local server's variables `environment`.
361
- return {
362
- type: 'local',
363
- command: [server.command, ...(server.args || [])],
364
- ...(env ? { environment: env } : {}),
365
- };
366
- }
367
- return {
368
- type: 'remote',
369
- url: server.url,
370
- ...(headers ? { headers } : {}),
371
- };
372
- }
373
-
374
- case 'toml':
375
- return {};
376
-
377
- default:
378
- return {};
379
- }
380
- }
381
297
 
382
298
  function tomlKey(value) {
383
299
  return typeof value === 'string' && /^[A-Za-z0-9_-]+$/.test(value) ? value : tomlString(value);
@@ -0,0 +1,3 @@
1
+ import type { InjectProvider, McpServerDefinition } from './registry.js';
2
+
3
+ export function buildServerConfig(server: McpServerDefinition, provider: InjectProvider): Record<string, unknown>;