@crewhaus/target-crew 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -7
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -326,26 +326,49 @@ function renderMcpServers(ir) {
|
|
|
326
326
|
if (entries.length === 0) {
|
|
327
327
|
return { imports: [], bootBlock: "", hasAny: false };
|
|
328
328
|
}
|
|
329
|
+
// #406 — servers the spec marked `required: false` degrade at boot instead
|
|
330
|
+
// of exiting. The crew's tool list (`__mcpTools`) is frozen at wire-once
|
|
331
|
+
// boot, so the optional path is degrade-only (`retry: false`): tools absent
|
|
332
|
+
// until restart, no background banner mid-run.
|
|
333
|
+
const requiredEntries = entries.filter(([, cfg]) => cfg.required !== false);
|
|
334
|
+
const optionalEntries = entries.filter(([, cfg]) => cfg.required === false);
|
|
329
335
|
const imports = [
|
|
330
336
|
`import { McpHost, resolveMcpServerConfig } from "@crewhaus/mcp-host";`,
|
|
331
|
-
`import {
|
|
337
|
+
`import { ${[
|
|
338
|
+
...(requiredEntries.length > 0 ? ["registerMcpServer"] : []),
|
|
339
|
+
...(optionalEntries.length > 0 ? ["registerOptionalMcpServer"] : []),
|
|
340
|
+
].join(", ")} } from "@crewhaus/tool-mcp";`,
|
|
332
341
|
];
|
|
333
|
-
|
|
342
|
+
// Optional entries are NOT added here: their config resolution + addServer
|
|
343
|
+
// run inside registerOptionalMcpServer's never-throw boundary (an unset env
|
|
344
|
+
// var on an optional peer must degrade, not kill the boot).
|
|
345
|
+
const addLines = requiredEntries
|
|
334
346
|
.map(([name, cfg]) => ` mcpHost.addServer(${escapeJsonString(name)}, resolveMcpServerConfig(${JSON.stringify(cfg)}, { name: ${escapeJsonString(name)} }));`)
|
|
335
347
|
.join("\n");
|
|
336
|
-
const registerLines =
|
|
348
|
+
const registerLines = requiredEntries
|
|
337
349
|
.map(([name]) => ` registerMcpServer(mcpHost, ${escapeJsonString(name)}, __mcpCatalog, { onRegister: ({ fullName }) => process.stderr.write(\`[mcp] registered \${fullName}\\n\`) }),`)
|
|
338
350
|
.join("\n");
|
|
351
|
+
const optionalLines = optionalEntries
|
|
352
|
+
.map(([name, cfg]) => {
|
|
353
|
+
// The wire config only — `required` is an EMIT-time decision (which
|
|
354
|
+
// registration call), not something mcp-host's config knows.
|
|
355
|
+
const { required: _requiredFlag, ...wireCfg } = cfg;
|
|
356
|
+
return `\n await registerOptionalMcpServer(mcpHost, ${escapeJsonString(name)}, __mcpCatalog, { retry: false, config: () => resolveMcpServerConfig(${JSON.stringify(wireCfg)}, { name: ${escapeJsonString(name)} }), log: (line) => process.stderr.write(line), onRegister: ({ fullName }) => process.stderr.write(\`[mcp] registered \${fullName}\\n\`) }).firstAttempt;`;
|
|
357
|
+
})
|
|
358
|
+
.join("");
|
|
359
|
+
const registerBlock = requiredEntries.length > 0
|
|
360
|
+
? `
|
|
361
|
+
await Promise.all([
|
|
362
|
+
${registerLines}
|
|
363
|
+
]);`
|
|
364
|
+
: "";
|
|
339
365
|
const bootBlock = `
|
|
340
366
|
// Loop contract 0.4 (Batch A, G05) — MCP servers, wired ONCE: every
|
|
341
367
|
// role's turns see the remote tools through the orchestrator's crew-wide
|
|
342
368
|
// extraTools; the daemon disconnects the shared host on shutdown.
|
|
343
369
|
const mcpHost = new McpHost();
|
|
344
370
|
${addLines}
|
|
345
|
-
const __mcpCatalog = new ToolCatalog()
|
|
346
|
-
await Promise.all([
|
|
347
|
-
${registerLines}
|
|
348
|
-
]);
|
|
371
|
+
const __mcpCatalog = new ToolCatalog();${registerBlock}${optionalLines}
|
|
349
372
|
const __mcpTools = __mcpCatalog.list();`;
|
|
350
373
|
return { imports, bootBlock, hasAny: true };
|
|
351
374
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/target-crew",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Codegen for the CRW target — emits a daemon + per-role agent files driven by crew-orchestrator (Section 22)",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"test": "bun test src"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@crewhaus/errors": "0.5.
|
|
19
|
-
"@crewhaus/gateway-protocol": "0.5.
|
|
20
|
-
"@crewhaus/infra-utils": "0.5.
|
|
21
|
-
"@crewhaus/ir": "0.5.
|
|
22
|
-
"@crewhaus/memory-service": "0.5.
|
|
18
|
+
"@crewhaus/errors": "0.5.6",
|
|
19
|
+
"@crewhaus/gateway-protocol": "0.5.6",
|
|
20
|
+
"@crewhaus/infra-utils": "0.5.6",
|
|
21
|
+
"@crewhaus/ir": "0.5.6",
|
|
22
|
+
"@crewhaus/memory-service": "0.5.6"
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"author": {
|