@ulpi/cli 0.1.5 → 0.1.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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{auth-PN7TMQHV-2W4ICG64.js → auth-FWM7MM4Q-VZC3U2XZ.js} +1 -1
  3. package/dist/{auth-BFFBUJUC.js → auth-HDK7ECJL.js} +2 -1
  4. package/dist/{chunk-RJIRWQJD.js → chunk-3BCW6ABU.js} +402 -142
  5. package/dist/{chunk-L3PWNHSA.js → chunk-3WB5CXH4.js} +180 -5
  6. package/dist/{chunk-K4OVPFY2.js → chunk-4UCJIAOU.js} +2 -2
  7. package/dist/chunk-4XTHZVDS.js +109 -0
  8. package/dist/chunk-4ZPOZULQ.js +6522 -0
  9. package/dist/{chunk-SIAQVRKG.js → chunk-5MI5GIXM.js} +48 -2
  10. package/dist/{chunk-KLEASXUR.js → chunk-6ZL6NXMV.js} +1 -1
  11. package/dist/{chunk-AV5RB3N2.js → chunk-76D3BYJD.js} +48 -0
  12. package/dist/{chunk-DOIKS6C5.js → chunk-AWOSRA5F.js} +1 -1
  13. package/dist/{chunk-UCMT5OKP.js → chunk-BFEKZZHM.js} +274 -57
  14. package/dist/chunk-C7CLUQI6.js +1286 -0
  15. package/dist/{chunk-ELTGWMDE.js → chunk-E3B5NROU.js} +7 -7
  16. package/dist/chunk-EJ7TW77N.js +1418 -0
  17. package/dist/{chunk-6OURRFP7.js → chunk-IV6MWETF.js} +383 -168
  18. package/dist/chunk-IZPJHSPX.js +1478 -0
  19. package/dist/chunk-JLHNLM3C.js +228 -0
  20. package/dist/{chunk-P2RESJRN.js → chunk-KYYI23AQ.js} +2 -2
  21. package/dist/chunk-S6ANCSYO.js +1271 -0
  22. package/dist/chunk-SEU7WWNQ.js +1251 -0
  23. package/dist/chunk-SNQ7NAIS.js +453 -0
  24. package/dist/{ulpi-RMMCUAGP-EWYUE7RU.js → chunk-TSLDGT5O.js} +73 -35
  25. package/dist/{chunk-EIWYSP3A.js → chunk-UXHCHOWQ.js} +83 -62
  26. package/dist/chunk-V2H5D6Y3.js +146 -0
  27. package/dist/{chunk-5SCG7UYM.js → chunk-VVEDXI7E.js} +1 -1
  28. package/dist/chunk-VXH5Y4FO.js +6761 -0
  29. package/dist/chunk-WED4LM5N.js +322 -0
  30. package/dist/{chunk-74WVVWJ4.js → chunk-YOKL7RB5.js} +184 -15
  31. package/dist/chunk-Z53CAR7G.js +298 -0
  32. package/dist/{ci-JQ56YIKC.js → ci-X3U2W4HC.js} +124 -26
  33. package/dist/cloud-2F3NLVHN.js +274 -0
  34. package/dist/{codemap-HMYBXJL2.js → codemap-XNGMAF3F.js} +37 -37
  35. package/dist/codex-MB5YTMRT.js +132 -0
  36. package/dist/{config-YYWEN7U2.js → config-OOELBYTH.js} +1 -1
  37. package/dist/dist-2BJYR5EI.js +59 -0
  38. package/dist/dist-3EIQTZHT.js +1380 -0
  39. package/dist/{dist-WAMAQVPK.js → dist-4U5L2X2C.js} +2 -2
  40. package/dist/{dist-4XTJ6HLM.js → dist-54KAMNLO.js} +16 -15
  41. package/dist/dist-6M4MZWZW.js +58 -0
  42. package/dist/dist-6X576SU2.js +27 -0
  43. package/dist/dist-7QOEYLFX.js +103 -0
  44. package/dist/dist-AYBGHEDY.js +2541 -0
  45. package/dist/dist-EK45QNEM.js +45 -0
  46. package/dist/{dist-U7ZIJMZD.js → dist-FKFEJRPX.js} +16 -15
  47. package/dist/dist-GTEJUBBT.js +66 -0
  48. package/dist/dist-HA74OKJZ.js +40 -0
  49. package/dist/{dist-XG2GG5SD.js → dist-HU5RZAON.js} +14 -2
  50. package/dist/dist-IYE3OBRB.js +374 -0
  51. package/dist/{dist-7WLLPWWB.js → dist-JLU26AB6.js} +12 -9
  52. package/dist/{dist-6G7JC2RA.js → dist-KUCI6JFE.js} +49 -9
  53. package/dist/dist-NUEMFZFL.js +33 -0
  54. package/dist/{dist-GWGTAHNM.js → dist-NUXMDXZ3.js} +31 -3
  55. package/dist/{dist-5R4RYNQO.js → dist-YCNWHSLN.js} +15 -5
  56. package/dist/{dist-6MFVWIFF.js → dist-YFFG2ZD6.js} +9 -16
  57. package/dist/dist-ZG4OKCSR.js +15 -0
  58. package/dist/doctor-SI4LLLDZ.js +345 -0
  59. package/dist/{export-import-4A5MWLIA.js → export-import-JFQH4KSJ.js} +1 -1
  60. package/dist/{history-RNUWO4JZ.js → history-5NE46ZAH.js} +7 -7
  61. package/dist/{hooks-installer-K2JXEBNN.js → hooks-installer-UN5JZLDQ.js} +2 -2
  62. package/dist/index.js +394 -618
  63. package/dist/{init-NQWFZPKO.js → init-5FK3VKRT.js} +76 -10
  64. package/dist/job-HIDMAFW2.js +376 -0
  65. package/dist/jobs.memory-PLMMSFHB-VBECCTHN.js +33 -0
  66. package/dist/kiro-VMUHDFGK.js +153 -0
  67. package/dist/{launchd-OYXUAVW6.js → launchd-6AWT54HR.js} +9 -17
  68. package/dist/mcp-PDUD7SGP.js +249 -0
  69. package/dist/mcp-installer-PQU3XOGO.js +259 -0
  70. package/dist/mcp-setup-OA7IB3H3.js +263 -0
  71. package/dist/{memory-D6ZFFCI2.js → memory-ZNAEAK3B.js} +17 -17
  72. package/dist/{ollama-3XCUZMZT-FYKHW4TZ.js → ollama-3XCUZMZT-4JMH6B7P.js} +1 -1
  73. package/dist/{openai-E7G2YAHU-IG33BFYF.js → openai-E7G2YAHU-T3HMBPH7.js} +2 -2
  74. package/dist/portal-JYWVHXDU.js +210 -0
  75. package/dist/prd-Q4J5NVAR.js +408 -0
  76. package/dist/repos-WWZXNN3P.js +271 -0
  77. package/dist/review-integration-5WHEJU2A.js +14 -0
  78. package/dist/{rules-3OFGWHP4.js → rules-Y4VSOY5Y.js} +3 -3
  79. package/dist/run-VPNXEIBY.js +687 -0
  80. package/dist/server-COL4AXKU-P7S7NNF6.js +11 -0
  81. package/dist/server-KKSETHDV-XSSLEENT.js +20 -0
  82. package/dist/{skills-GY2CTPWN.js → skills-QEYU2N27.js} +4 -2
  83. package/dist/start-JYOEL7AJ.js +303 -0
  84. package/dist/{status-SE43TIFJ.js → status-BHQYYGAL.js} +2 -2
  85. package/dist/{templates-O2XDKB5R.js → templates-CBRUJ66V.js} +6 -5
  86. package/dist/tui-DP7736EX.js +61 -0
  87. package/dist/ulpi-5EN6JCAS-LFE3WSL4.js +10 -0
  88. package/dist/{uninstall-KWGSGZTI.js → uninstall-ICUV6DDV.js} +3 -3
  89. package/dist/{update-QYZA4D23.js → update-7ZMAYRBH.js} +3 -3
  90. package/dist/{version-checker-MVB74DEX.js → version-checker-4ZFMZA7Y.js} +2 -2
  91. package/package.json +39 -31
  92. package/dist/chunk-26LLDX2T.js +0 -553
  93. package/dist/chunk-DDRLI6JU.js +0 -331
  94. package/dist/chunk-IFATANHR.js +0 -453
  95. package/dist/chunk-JWUUVXIV.js +0 -13694
  96. package/dist/chunk-LD52XG3X.js +0 -4273
  97. package/dist/chunk-MIAQVCFW.js +0 -39
  98. package/dist/chunk-YYZOFYS6.js +0 -415
  99. package/dist/dist-XD4YI27T.js +0 -26
  100. package/dist/mcp-installer-TOYDP77X.js +0 -124
  101. package/dist/projects-COUJP4ZC.js +0 -271
  102. package/dist/review-KMGP2S25.js +0 -152
  103. package/dist/server-USLHY6GH-F4JSXCWA.js +0 -18
  104. package/dist/server-X5P6WH2M-ULZF5WHZ.js +0 -11
  105. package/dist/skills/ulpi-generate-guardian/SKILL.md +0 -750
  106. package/dist/skills/ulpi-generate-guardian/references/framework-rules.md +0 -849
  107. package/dist/skills/ulpi-generate-guardian/references/language-rules.md +0 -591
  108. package/dist/ui-4SM2SUI6.js +0 -167
  109. package/dist/ui.html +0 -698
@@ -0,0 +1,45 @@
1
+ import {
2
+ addToLibrary,
3
+ collectProjectSignals,
4
+ disableMcp,
5
+ enableMcp,
6
+ getActivation,
7
+ getCatalogEntry,
8
+ getLibraryEntry,
9
+ listActivations,
10
+ listLibrary,
11
+ loadActivations,
12
+ loadCatalog,
13
+ loadLibrary,
14
+ removeFromLibrary,
15
+ saveActivations,
16
+ saveLibrary,
17
+ searchCatalog,
18
+ suggestMcps,
19
+ updateActivationConfig
20
+ } from "./chunk-JLHNLM3C.js";
21
+ import "./chunk-4ZPOZULQ.js";
22
+ import "./chunk-C7CLUQI6.js";
23
+ import "./chunk-YOKL7RB5.js";
24
+ import "./chunk-KIKPIH6N.js";
25
+ import "./chunk-4VNS5WPM.js";
26
+ export {
27
+ addToLibrary,
28
+ collectProjectSignals,
29
+ disableMcp,
30
+ enableMcp,
31
+ getActivation,
32
+ getCatalogEntry,
33
+ getLibraryEntry,
34
+ listActivations,
35
+ listLibrary,
36
+ loadActivations,
37
+ loadCatalog,
38
+ loadLibrary,
39
+ removeFromLibrary,
40
+ saveActivations,
41
+ saveLibrary,
42
+ searchCatalog,
43
+ suggestMcps,
44
+ updateActivationConfig
45
+ };
@@ -1,9 +1,3 @@
1
- import {
2
- CallToolRequestSchema,
3
- ListToolsRequestSchema,
4
- Server,
5
- StdioServerTransport
6
- } from "./chunk-JWUUVXIV.js";
7
1
  import {
8
2
  generateMemoryId,
9
3
  getMemoryStats,
@@ -15,19 +9,26 @@ import {
15
9
  removeEntry,
16
10
  searchMemory,
17
11
  updateEntry
18
- } from "./chunk-UCMT5OKP.js";
19
- import "./chunk-6OURRFP7.js";
20
- import "./chunk-K4OVPFY2.js";
21
- import "./chunk-KLEASXUR.js";
22
- import "./chunk-L3PWNHSA.js";
23
- import "./chunk-26LLDX2T.js";
24
- import "./chunk-74WVVWJ4.js";
12
+ } from "./chunk-BFEKZZHM.js";
13
+ import "./chunk-IV6MWETF.js";
14
+ import "./chunk-4UCJIAOU.js";
15
+ import "./chunk-6ZL6NXMV.js";
16
+ import "./chunk-TSLDGT5O.js";
17
+ import "./chunk-AWOSRA5F.js";
18
+ import "./chunk-3WB5CXH4.js";
19
+ import "./chunk-SEU7WWNQ.js";
20
+ import "./chunk-C7CLUQI6.js";
21
+ import "./chunk-YOKL7RB5.js";
25
22
  import "./chunk-KIKPIH6N.js";
26
- import "./chunk-DOIKS6C5.js";
27
- import "./chunk-DDRLI6JU.js";
28
23
  import "./chunk-4VNS5WPM.js";
29
24
 
30
25
  // ../../packages/memory-mcp/dist/index.js
26
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
27
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
28
+ import {
29
+ ListToolsRequestSchema,
30
+ CallToolRequestSchema
31
+ } from "@modelcontextprotocol/sdk/types.js";
31
32
  var searchMemoryTool = {
32
33
  name: "search_memory",
33
34
  description: "Search project memories by semantic similarity. Returns memories ranked by relevance, importance, and access frequency. Memories include decisions, patterns, bug root causes, preferences, constraints, context, lessons, and relationships.",
@@ -0,0 +1,66 @@
1
+ import {
2
+ EventResponseConfigSchema,
3
+ HookEventSchema,
4
+ NotifyChannelSchema,
5
+ PermissionDecisionSchema,
6
+ PermissionRuleInputSchema,
7
+ PipelineOnFailureSchema,
8
+ PipelineRuleInputSchema,
9
+ PipelineStepSchema,
10
+ PostconditionRuleInputSchema,
11
+ PreconditionRuleInputSchema,
12
+ ResponseConfigSchema,
13
+ ReviewSettingsConfigSchema,
14
+ RuleSourceSchema,
15
+ RulesConfigSchema,
16
+ SessionStateFlagSchema,
17
+ StackConfigSchema,
18
+ buildPermissionOutput,
19
+ checkPipelinePrereqs,
20
+ checkPrecondition,
21
+ collectPostconditions,
22
+ evaluatePermission,
23
+ evaluateRules,
24
+ isDangerousCommand,
25
+ loadRulesSync,
26
+ matchesCommand,
27
+ matchesFilePattern,
28
+ matchesTool,
29
+ normalizePath,
30
+ parseRules,
31
+ resolveVariables
32
+ } from "./chunk-5MI5GIXM.js";
33
+ import "./chunk-KIKPIH6N.js";
34
+ import "./chunk-4VNS5WPM.js";
35
+ export {
36
+ EventResponseConfigSchema,
37
+ HookEventSchema,
38
+ NotifyChannelSchema,
39
+ PermissionDecisionSchema,
40
+ PermissionRuleInputSchema,
41
+ PipelineOnFailureSchema,
42
+ PipelineRuleInputSchema,
43
+ PipelineStepSchema,
44
+ PostconditionRuleInputSchema,
45
+ PreconditionRuleInputSchema,
46
+ ResponseConfigSchema,
47
+ ReviewSettingsConfigSchema,
48
+ RuleSourceSchema,
49
+ RulesConfigSchema,
50
+ SessionStateFlagSchema,
51
+ StackConfigSchema,
52
+ buildPermissionOutput,
53
+ checkPipelinePrereqs,
54
+ checkPrecondition,
55
+ collectPostconditions,
56
+ evaluatePermission,
57
+ evaluateRules,
58
+ isDangerousCommand,
59
+ loadRulesSync,
60
+ matchesCommand,
61
+ matchesFilePattern,
62
+ matchesTool,
63
+ normalizePath,
64
+ parseRules,
65
+ resolveVariables
66
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ ADAPTABLE_SKILLS,
3
+ CLAUDE_ONLY_SKILLS,
4
+ adaptContentForCodex,
5
+ adaptContentForKiro,
6
+ appendTomlSection,
7
+ convertClaudeAgentsToCodex,
8
+ convertClaudeAgentsToKiro,
9
+ convertClaudeSkillsToCodex,
10
+ convertClaudeSkillsToKiro,
11
+ copyDirRecursive,
12
+ extractCodexMcpServers,
13
+ extractKiroMcpServers,
14
+ inferSandboxMode,
15
+ mapClaudeModelToCodex,
16
+ mapClaudeToolsToKiro,
17
+ parseClaudeAgentFrontmatter,
18
+ serializeTomlTable
19
+ } from "./chunk-SNQ7NAIS.js";
20
+ import "./chunk-C7CLUQI6.js";
21
+ import "./chunk-4VNS5WPM.js";
22
+ export {
23
+ ADAPTABLE_SKILLS,
24
+ CLAUDE_ONLY_SKILLS,
25
+ adaptContentForCodex,
26
+ adaptContentForKiro,
27
+ appendTomlSection,
28
+ convertClaudeAgentsToCodex,
29
+ convertClaudeAgentsToKiro,
30
+ convertClaudeSkillsToCodex,
31
+ convertClaudeSkillsToKiro,
32
+ copyDirRecursive,
33
+ extractCodexMcpServers,
34
+ extractKiroMcpServers,
35
+ inferSandboxMode,
36
+ mapClaudeModelToCodex,
37
+ mapClaudeToolsToKiro,
38
+ parseClaudeAgentFrontmatter,
39
+ serializeTomlTable
40
+ };
@@ -1,36 +1,48 @@
1
1
  import {
2
2
  BUNDLED_SKILLS,
3
+ clearPromptCache,
3
4
  composeTemplates,
4
5
  deleteUserTemplate,
5
6
  exportUserTemplate,
7
+ getBuiltinPromptTemplate,
6
8
  getBundledSkillInfo,
7
9
  getBundledTemplate,
8
10
  importUserTemplate,
9
11
  injectSkill,
12
+ listBuiltinPromptTemplates,
10
13
  listUserTemplates,
11
14
  loadBundledTemplates,
15
+ loadMcpCatalog,
12
16
  loadSkillSync,
13
17
  loadTemplates,
14
18
  loadUserTemplate,
19
+ renderPrompt,
15
20
  resolveTemplate,
16
21
  saveUserTemplate
17
- } from "./chunk-IFATANHR.js";
18
- import "./chunk-DDRLI6JU.js";
22
+ } from "./chunk-4ZPOZULQ.js";
23
+ import "./chunk-C7CLUQI6.js";
24
+ import "./chunk-YOKL7RB5.js";
25
+ import "./chunk-KIKPIH6N.js";
19
26
  import "./chunk-4VNS5WPM.js";
20
27
  export {
21
28
  BUNDLED_SKILLS,
29
+ clearPromptCache,
22
30
  composeTemplates,
23
31
  deleteUserTemplate,
24
32
  exportUserTemplate,
33
+ getBuiltinPromptTemplate,
25
34
  getBundledSkillInfo,
26
35
  getBundledTemplate,
27
36
  importUserTemplate,
28
37
  injectSkill,
38
+ listBuiltinPromptTemplates,
29
39
  listUserTemplates,
30
40
  loadBundledTemplates,
41
+ loadMcpCatalog,
31
42
  loadSkillSync,
32
43
  loadTemplates,
33
44
  loadUserTemplate,
45
+ renderPrompt as renderPromptTemplate,
34
46
  resolveTemplate,
35
47
  saveUserTemplate
36
48
  };
@@ -0,0 +1,374 @@
1
+ import {
2
+ loadActivations,
3
+ loadLibrary
4
+ } from "./chunk-JLHNLM3C.js";
5
+ import "./chunk-4ZPOZULQ.js";
6
+ import {
7
+ projectMcpsFile
8
+ } from "./chunk-C7CLUQI6.js";
9
+ import "./chunk-YOKL7RB5.js";
10
+ import "./chunk-KIKPIH6N.js";
11
+ import "./chunk-4VNS5WPM.js";
12
+
13
+ // ../../packages/mcp-gateway/dist/index.js
14
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
15
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
16
+ import {
17
+ ListToolsRequestSchema,
18
+ CallToolRequestSchema
19
+ } from "@modelcontextprotocol/sdk/types.js";
20
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
21
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
22
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
23
+ import * as fs from "fs";
24
+ function resolveEnabledMcps(projectDir) {
25
+ const library = loadLibrary();
26
+ const activations = loadActivations(projectDir);
27
+ const resolved = [];
28
+ for (const [name, activation] of Object.entries(activations.mcps)) {
29
+ if (!activation.enabled) continue;
30
+ const definition = library.mcps[name];
31
+ if (!definition) {
32
+ process.stderr.write(`[mcp-gateway] Warning: MCP "${name}" enabled in repo but not found in library -- skipping
33
+ `);
34
+ continue;
35
+ }
36
+ const resolvedEnv = {};
37
+ for (const [key, value] of Object.entries(activation.config)) {
38
+ if (typeof value === "string" && value.startsWith("env:")) {
39
+ const envName = value.slice(4);
40
+ const envValue = process.env[envName];
41
+ if (envValue !== void 0) {
42
+ resolvedEnv[envName] = envValue;
43
+ } else {
44
+ process.stderr.write(`[mcp-gateway] Warning: env var "${envName}" not set for MCP "${name}" config key "${key}"
45
+ `);
46
+ }
47
+ }
48
+ }
49
+ resolved.push({ name, definition, activation, resolvedEnv });
50
+ }
51
+ return resolved;
52
+ }
53
+ var CONNECT_TIMEOUT_MS = 3e4;
54
+ var MAX_BACKENDS = 20;
55
+ var MAX_CRASH_RETRIES = 1;
56
+ var BackendManager = class {
57
+ backends = /* @__PURE__ */ new Map();
58
+ get size() {
59
+ return this.backends.size;
60
+ }
61
+ getBackend(name) {
62
+ return this.backends.get(name);
63
+ }
64
+ getAllBackends() {
65
+ return Array.from(this.backends.values());
66
+ }
67
+ getAllTools() {
68
+ const tools = [];
69
+ for (const backend of this.backends.values()) {
70
+ if (backend.status === "running") {
71
+ tools.push(...backend.tools);
72
+ }
73
+ }
74
+ return tools;
75
+ }
76
+ /**
77
+ * Spawn and connect to a backend MCP server.
78
+ */
79
+ async startBackend(mcp) {
80
+ if (this.backends.size >= MAX_BACKENDS) {
81
+ throw new Error(`Maximum backend limit reached (${MAX_BACKENDS})`);
82
+ }
83
+ const entry = {
84
+ name: mcp.name,
85
+ definition: mcp.definition,
86
+ activation: mcp.activation,
87
+ client: null,
88
+ transport: null,
89
+ status: "starting",
90
+ tools: [],
91
+ crashCount: 0
92
+ };
93
+ this.backends.set(mcp.name, entry);
94
+ try {
95
+ await this.connectBackend(entry, mcp);
96
+ } catch (err) {
97
+ entry.status = "crashed";
98
+ entry.error = err instanceof Error ? err.message : String(err);
99
+ process.stderr.write(`[mcp-gateway] Failed to start backend "${mcp.name}": ${entry.error}
100
+ `);
101
+ }
102
+ return entry;
103
+ }
104
+ async connectBackend(entry, mcp) {
105
+ const { definition } = mcp;
106
+ const isHttp = definition.transport === "http" || definition.transport === "sse";
107
+ if (isHttp) {
108
+ process.stderr.write(`[mcp-gateway] Connecting to HTTP backend "${mcp.name}" (${definition.command})
109
+ `);
110
+ } else {
111
+ process.stderr.write(`[mcp-gateway] Starting backend "${mcp.name}" (${definition.command} ${definition.args.join(" ")})
112
+ `);
113
+ }
114
+ let transport;
115
+ if (isHttp) {
116
+ const headers = {};
117
+ const authHeader = mcp.resolvedEnv.AUTHORIZATION ?? mcp.resolvedEnv.Authorization;
118
+ if (authHeader) {
119
+ headers["Authorization"] = authHeader;
120
+ }
121
+ transport = new StreamableHTTPClientTransport(
122
+ new URL(definition.command),
123
+ { requestInit: { headers } }
124
+ );
125
+ } else {
126
+ const childEnv = {};
127
+ for (const [k, v] of Object.entries(process.env)) {
128
+ if (v !== void 0) childEnv[k] = v;
129
+ }
130
+ Object.assign(childEnv, mcp.resolvedEnv);
131
+ transport = new StdioClientTransport({
132
+ command: definition.command,
133
+ args: definition.args,
134
+ env: childEnv
135
+ });
136
+ }
137
+ const client = new Client(
138
+ { name: `ulpi-gateway-${mcp.name}`, version: "0.1.0" },
139
+ { capabilities: {} }
140
+ );
141
+ entry.transport = transport;
142
+ entry.client = client;
143
+ transport.onclose = () => {
144
+ if (entry.status === "running") {
145
+ entry.status = "crashed";
146
+ process.stderr.write(`[mcp-gateway] Backend "${mcp.name}" ${isHttp ? "disconnected" : "crashed"}
147
+ `);
148
+ }
149
+ };
150
+ const connectPromise = client.connect(transport);
151
+ const timeoutPromise = new Promise(
152
+ (_, reject) => setTimeout(() => reject(new Error(`Connection timeout after ${CONNECT_TIMEOUT_MS}ms`)), CONNECT_TIMEOUT_MS)
153
+ );
154
+ await Promise.race([connectPromise, timeoutPromise]);
155
+ const toolsResult = await client.listTools();
156
+ const tools = (toolsResult.tools ?? []).map((tool) => ({
157
+ namespacedName: `${mcp.name}__${tool.name}`,
158
+ originalName: tool.name,
159
+ backendName: mcp.name,
160
+ definition: {
161
+ name: `${mcp.name}__${tool.name}`,
162
+ description: tool.description ? `[${mcp.definition.display_name ?? mcp.name}] ${tool.description}` : void 0,
163
+ inputSchema: tool.inputSchema ?? { type: "object" }
164
+ }
165
+ }));
166
+ entry.tools = tools;
167
+ entry.status = "running";
168
+ process.stderr.write(`[mcp-gateway] Backend "${mcp.name}" connected (${tools.length} tools)
169
+ `);
170
+ }
171
+ /**
172
+ * Call a tool on a specific backend.
173
+ * Handles crash recovery (one retry).
174
+ */
175
+ async callTool(backendName, toolName, args) {
176
+ const entry = this.backends.get(backendName);
177
+ if (!entry) {
178
+ return { content: [{ type: "text", text: `Unknown MCP server: ${backendName}` }], isError: true };
179
+ }
180
+ if (entry.status === "crashed" && entry.crashCount < MAX_CRASH_RETRIES) {
181
+ entry.crashCount++;
182
+ process.stderr.write(`[mcp-gateway] Attempting to restart backend "${backendName}" (retry ${entry.crashCount}/${MAX_CRASH_RETRIES})
183
+ `);
184
+ try {
185
+ await this.connectBackend(entry, {
186
+ name: entry.name,
187
+ definition: entry.definition,
188
+ activation: entry.activation,
189
+ resolvedEnv: {}
190
+ });
191
+ } catch {
192
+ return { content: [{ type: "text", text: `[${backendName}] MCP server crashed and could not be restarted` }], isError: true };
193
+ }
194
+ }
195
+ if (entry.status !== "running" || !entry.client) {
196
+ return { content: [{ type: "text", text: `[${backendName}] MCP server is not running` }], isError: true };
197
+ }
198
+ const startTime = Date.now();
199
+ try {
200
+ const resultPromise = entry.client.callTool({ name: toolName, arguments: args });
201
+ const timeoutPromise = new Promise(
202
+ (_, reject) => setTimeout(() => reject(new Error("timeout")), 6e4)
203
+ );
204
+ const result = await Promise.race([resultPromise, timeoutPromise]);
205
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
206
+ process.stderr.write(`[mcp-gateway] Tool call: ${backendName}__${toolName} (${elapsed}s)
207
+ `);
208
+ return result;
209
+ } catch (err) {
210
+ if (err instanceof Error && err.message === "timeout") {
211
+ return { content: [{ type: "text", text: `[${backendName}] Tool call timed out after 60s` }], isError: true };
212
+ }
213
+ const message = err instanceof Error ? err.message : String(err);
214
+ return { content: [{ type: "text", text: `[${backendName}] ${message}` }], isError: true };
215
+ }
216
+ }
217
+ /**
218
+ * Stop a specific backend.
219
+ */
220
+ async stopBackend(name) {
221
+ const entry = this.backends.get(name);
222
+ if (!entry) return;
223
+ entry.status = "stopped";
224
+ try {
225
+ if (entry.transport && typeof entry.transport.close === "function") {
226
+ await entry.transport.close();
227
+ }
228
+ } catch {
229
+ }
230
+ this.backends.delete(name);
231
+ }
232
+ /**
233
+ * Stop all backends.
234
+ */
235
+ async stopAll() {
236
+ const names = Array.from(this.backends.keys());
237
+ await Promise.allSettled(names.map((name) => this.stopBackend(name)));
238
+ }
239
+ };
240
+ function parseToolName(namespacedName) {
241
+ const idx = namespacedName.indexOf("__");
242
+ if (idx <= 0) return null;
243
+ return {
244
+ backend: namespacedName.slice(0, idx),
245
+ tool: namespacedName.slice(idx + 2)
246
+ };
247
+ }
248
+ function buildToolList(tools) {
249
+ return tools.map((t) => t.definition);
250
+ }
251
+ function watchMcpsConfig(projectDir, callback) {
252
+ const filePath = projectMcpsFile(projectDir);
253
+ let debounceTimer = null;
254
+ let watcher = null;
255
+ try {
256
+ const dir = filePath.substring(0, filePath.lastIndexOf("/"));
257
+ if (!fs.existsSync(dir)) {
258
+ return { close: () => {
259
+ } };
260
+ }
261
+ watcher = fs.watch(dir, (_eventType, filename) => {
262
+ if (filename && filename.endsWith("mcps.yml")) {
263
+ if (debounceTimer) clearTimeout(debounceTimer);
264
+ debounceTimer = setTimeout(() => {
265
+ process.stderr.write("[mcp-gateway] Config change detected: reloading mcps.yml\n");
266
+ callback();
267
+ }, 500);
268
+ }
269
+ });
270
+ watcher.on("error", () => {
271
+ });
272
+ } catch {
273
+ return { close: () => {
274
+ } };
275
+ }
276
+ return {
277
+ close: () => {
278
+ if (debounceTimer) clearTimeout(debounceTimer);
279
+ if (watcher) watcher.close();
280
+ }
281
+ };
282
+ }
283
+ function createGateway(options) {
284
+ const manager = new BackendManager();
285
+ let initialized = false;
286
+ const server = new Server(
287
+ { name: "tools", version: "0.1.0" },
288
+ { capabilities: { tools: {} } }
289
+ );
290
+ async function initBackends() {
291
+ const mcps = resolveEnabledMcps(options.projectDir);
292
+ if (mcps.length === 0) {
293
+ process.stderr.write("[mcp-gateway] No MCPs enabled for this repo\n");
294
+ return;
295
+ }
296
+ process.stderr.write(`[mcp-gateway] Starting ${mcps.length} backend(s)
297
+ `);
298
+ await Promise.allSettled(
299
+ mcps.map((mcp) => manager.startBackend(mcp))
300
+ );
301
+ initialized = true;
302
+ }
303
+ async function handleConfigChange() {
304
+ const mcps = resolveEnabledMcps(options.projectDir);
305
+ const enabledNames = new Set(mcps.map((m) => m.name));
306
+ const runningNames = new Set(manager.getAllBackends().map((b) => b.name));
307
+ for (const name of runningNames) {
308
+ if (!enabledNames.has(name)) {
309
+ process.stderr.write(`[mcp-gateway] Stopping disabled backend "${name}"
310
+ `);
311
+ await manager.stopBackend(name);
312
+ }
313
+ }
314
+ for (const mcp of mcps) {
315
+ if (!runningNames.has(mcp.name)) {
316
+ process.stderr.write(`[mcp-gateway] Starting newly enabled backend "${mcp.name}"
317
+ `);
318
+ await manager.startBackend(mcp);
319
+ }
320
+ }
321
+ try {
322
+ await server.sendToolListChanged();
323
+ } catch {
324
+ }
325
+ }
326
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
327
+ if (!initialized) {
328
+ await initBackends();
329
+ }
330
+ const tools = buildToolList(manager.getAllTools());
331
+ return { tools };
332
+ });
333
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
334
+ const { name, arguments: args } = request.params;
335
+ const parsed = parseToolName(name);
336
+ if (!parsed) {
337
+ return {
338
+ content: [{ type: "text", text: `Invalid tool name format: ${name}. Expected: {mcpName}__{toolName}` }],
339
+ isError: true
340
+ };
341
+ }
342
+ const result = await manager.callTool(parsed.backend, parsed.tool, args ?? {});
343
+ return result;
344
+ });
345
+ const watcher = watchMcpsConfig(options.projectDir, () => {
346
+ void handleConfigChange();
347
+ });
348
+ const shutdownHandler = async () => {
349
+ process.stderr.write("[mcp-gateway] Shutting down...\n");
350
+ watcher.close();
351
+ await manager.stopAll();
352
+ process.exit(0);
353
+ };
354
+ process.on("SIGTERM", () => void shutdownHandler());
355
+ process.on("SIGINT", () => void shutdownHandler());
356
+ const forceKill = () => {
357
+ setTimeout(() => {
358
+ process.stderr.write("[mcp-gateway] Force killing after timeout\n");
359
+ process.exit(1);
360
+ }, 5e3).unref();
361
+ };
362
+ process.on("SIGTERM", forceKill);
363
+ process.on("SIGINT", forceKill);
364
+ return server;
365
+ }
366
+ async function startGateway(options) {
367
+ const server = createGateway(options);
368
+ const transport = new StdioServerTransport();
369
+ await server.connect(transport);
370
+ }
371
+ export {
372
+ createGateway,
373
+ startGateway
374
+ };
@@ -7,6 +7,7 @@ import {
7
7
  buildClassificationPrompt,
8
8
  buildClassificationWindows,
9
9
  buildSingleClassificationPrompt,
10
+ captureJobForClassification,
10
11
  classifySession,
11
12
  classifySinglePrompt,
12
13
  classifyWindow,
@@ -49,16 +50,17 @@ import {
49
50
  updateEntry,
50
51
  writeClassifyBatchProgress,
51
52
  writeMemoryStats
52
- } from "./chunk-UCMT5OKP.js";
53
- import "./chunk-6OURRFP7.js";
54
- import "./chunk-K4OVPFY2.js";
55
- import "./chunk-KLEASXUR.js";
56
- import "./chunk-L3PWNHSA.js";
57
- import "./chunk-26LLDX2T.js";
58
- import "./chunk-74WVVWJ4.js";
53
+ } from "./chunk-BFEKZZHM.js";
54
+ import "./chunk-IV6MWETF.js";
55
+ import "./chunk-4UCJIAOU.js";
56
+ import "./chunk-6ZL6NXMV.js";
57
+ import "./chunk-TSLDGT5O.js";
58
+ import "./chunk-AWOSRA5F.js";
59
+ import "./chunk-3WB5CXH4.js";
60
+ import "./chunk-SEU7WWNQ.js";
61
+ import "./chunk-C7CLUQI6.js";
62
+ import "./chunk-YOKL7RB5.js";
59
63
  import "./chunk-KIKPIH6N.js";
60
- import "./chunk-DOIKS6C5.js";
61
- import "./chunk-DDRLI6JU.js";
62
64
  import "./chunk-4VNS5WPM.js";
63
65
  export {
64
66
  DEFAULT_MEMORY_CONFIG,
@@ -69,6 +71,7 @@ export {
69
71
  buildClassificationPrompt,
70
72
  buildClassificationWindows,
71
73
  buildSingleClassificationPrompt,
74
+ captureJobForClassification,
72
75
  classifySession,
73
76
  classifySinglePrompt,
74
77
  classifyWindow,