@yawlabs/mcp 0.75.2 → 0.76.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to `@yawlabs/mcp` (formerly `@yawlabs/mcph`) are documented here. This project uses [semantic versioning](https://semver.org) and a script-gated release flow: `./release.sh <version>` runs lint + typecheck + tests + build, bumps, tags, publishes to npm, and publishes `server.json` to the MCP registry.
4
4
 
5
+ ## 0.75.5 -- the oam floor moves to 0.11.0, and three oam facts get re-measured
6
+
7
+ **Changed -- the oam floor moves to 0.11.0**
8
+
9
+ `MIN_OAM_VERSION` tracks the latest oam release as policy, and v0.11.0 is now current (published 2026-08-22). Three of the releases between the old 0.9.0 floor and this one fix things this workload sits directly on top of, so this is not only policy: 0.10.1 fixed a live `kill()` on an extra-fd child being a silent no-op on Unix -- a CDP browser child could not be terminated at all -- and a failed extra-fd spawn emitting `error` with no `close`, which stalled a driver probing for a browser binary that is not installed. 0.11.0 scoped Windows child handle inheritance with a `PROC_THREAD_ATTRIBUTE_HANDLE_LIST`; without it a concurrent spawn could leak one child's pipe ends into an unrelated child, and pre-warm activates servers three at a time.
10
+
11
+ A machine below the floor falls back to node/npx with one warning naming both versions and the command that fixes it (`oam self-update`), exactly as before.
12
+
13
+ **Changed -- the native-addon note says what was measured instead of declining to guess**
14
+
15
+ The compat note in `oam-spawn.ts` recorded native addons (ssh2) as UNVERIFIED. Measured against oam 0.11.0: oam refuses to dlopen a `.node` addon by default and throws a CATCHABLE error carrying `OAM-NATIVE0001`, and that refusal is deliberate -- it exists so the universal `try { require(native) } catch { pure-JS fallback }` pattern keeps working, which is also why oam omits `process.versions.modules`/`napi` so addon loaders do not try in the first place. With a compiled `sshcrypto.node` on disk, ssh2 loads and its Client and kex layers behave identically to the node control, because its binding require is try/catch-wrapped and it degrades to the pure-JS cipher path. The addon is refused; the sidecar is not. `OAM_ENABLE_NATIVE_ADDONS=1` would not change that outcome either -- that addon is NAN/node-gyp and oam's alpha N-API loader rejects it for a missing `napi_register_module_v1`.
16
+
17
+ The residual risk is narrower than "native addons are broken", and the note now says so: a package that requires a `.node` with NO fallback, LAZILY at first tool call, would fail past the boot-scoped downgrade. That case is still untested, and it is the one worth writing down.
18
+
19
+ The bundled-browser measurement was re-run at the same time. Both browser servers now serve a real `tools/call` navigate hosted on oam, not just an initialize handshake.
20
+
21
+ **Added -- an oam heap-cap death names the one variable that fixes it**
22
+
23
+ Since oam 0.9.2 the runtime caps its V8 heap (4 GiB unless `OAM_MAX_HEAP_MB` says otherwise) and turns what node renders as an ungraceful "Ineffective mark-compacts near heap limit" abort into a deterministic exit 134 with `error[OAM-RT-OOM]` on stderr, stdout left clean so the protocol channel is not corrupted on the way out. That is a better death than node's -- bounded, self-describing, not mistakable for a crash -- but only if something reads it. Unrecognized, it landed inside a 500-character stderr tail under a generic "failed to start", and the lever that fixes it was never mentioned to the person who needed it. The activation error now leads with the cause and names both escape hatches: `OAM_MAX_HEAP_MB` for the server's env, or `"runtime": "node"` for that server in `bundles.json`.
24
+
25
+ The failure CATEGORY is deliberately unchanged. An OOM really is "exited non-zero before handshake", so `install_failure` is already correct and the boot-probe downgrade needs no new branch -- inventing a category for it would have made a node respawn look like a different failure and pinned the server to node on evidence that never implicated the runtime.
26
+
27
+ **Fixed -- `install` and `doctor` no longer offer an installer that cannot run**
28
+
29
+ oam ships five assets: windows x64/arm64, macos x64/arm64, and linux x64. There is no `aarch64-unknown-linux-gnu` build, and `install.sh` refuses outright rather than degrading. Both surfaces branched on OS alone, so on Linux/arm64 they printed the curl one-liner as the fix -- a command that exits non-zero for a runtime the user never needed, since node is already a full fallback. They now report the platform and point at building from source instead.
30
+
31
+ The gate answers only for the CURRENT machine, deliberately. `doctor` and `install` both take an `--os` override, and a report asked about a different OS carries no arch with it; assuming this machine's arch for it would turn "I do not know" into a confident claim about a platform we cannot see.
32
+
33
+ **Fixed -- two stale citations**
34
+
35
+ `doctor`'s comment explaining the unparseable-version line quoted a floor two bumps old, and the prerelease-ranking test described itself as running "against a 0.8.3 floor" while asserting against whatever `MIN_OAM_VERSION` currently is. Both now read floor-agnostically, so the next bump cannot strand them again. Relatedly, `upstream.test.ts`'s `oam-spawn` mock listed its two exports by hand, so importing one more thing from that module in `upstream.ts` broke every test in the file with an error that surfaced as an unrelated redaction failure; it spreads the real module now and overrides only the spawn and probe entry points.
36
+
5
37
  ## 0.74.3 -- an absent oam says how to install it, and bundled browsers turn out to be hostable
6
38
 
7
39
  **Added -- the two surfaces that reported an absent oam now say what to do about it**
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ detectRunningInstallPrefix,
4
+ maybeAutoUpgrade,
5
+ quoteShellArgIfNeeded
6
+ } from "./chunk-SP5LWLFP.js";
7
+ import "./chunk-C3AQHLOR.js";
8
+ export {
9
+ detectRunningInstallPrefix,
10
+ maybeAutoUpgrade,
11
+ quoteShellArgIfNeeded
12
+ };
@@ -1,47 +1,266 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ log
4
+ } from "./chunk-C3AQHLOR.js";
2
5
 
3
6
  // src/oam-spawn.ts
4
7
  import { spawn } from "child_process";
5
8
  import { accessSync, constants, existsSync, readdirSync, readFileSync, statSync } from "fs";
6
- import { homedir as homedir2 } from "os";
7
- import { dirname, isAbsolute, join, sep } from "path";
9
+ import { homedir as homedir3 } from "os";
10
+ import { dirname, isAbsolute as isAbsolute2, join as join2, sep } from "path";
8
11
  import { fileURLToPath } from "url";
9
12
 
10
- // src/logger.ts
11
- var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
12
- var minLevel = LOG_LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LOG_LEVELS.info;
13
- function log(level, msg, data) {
14
- if (LOG_LEVELS[level] < minLevel) return;
15
- const entry = JSON.stringify({ ...data, level, msg, ts: (/* @__PURE__ */ new Date()).toISOString() });
16
- process.stderr.write(`${entry}
17
- `);
13
+ // src/install-targets.ts
14
+ import { homedir } from "os";
15
+ import { isAbsolute, join, resolve } from "path";
16
+ var CURRENT_OS = process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : "linux";
17
+ var INSTALL_TARGETS = [
18
+ {
19
+ clientId: "claude-code",
20
+ label: "Claude Code",
21
+ jsonShape: "mcpServers",
22
+ availableOn: ["macos", "linux", "windows"],
23
+ scopes: [
24
+ {
25
+ scope: "user",
26
+ label: "User (global)",
27
+ description: "Private to this machine; applies to every project.",
28
+ requiresProjectDir: false
29
+ },
30
+ {
31
+ scope: "project",
32
+ label: "Project",
33
+ description: "Commit to share with your team.",
34
+ requiresProjectDir: true
35
+ },
36
+ {
37
+ scope: "local",
38
+ label: "Local",
39
+ description: "Per-project override; typically gitignored.",
40
+ requiresProjectDir: true
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ clientId: "claude-desktop",
46
+ label: "Claude Desktop",
47
+ jsonShape: "mcpServers",
48
+ availableOn: ["macos", "windows"],
49
+ notes: "Claude Desktop reads one file per OS \u2014 no project scope. Restart the app after editing.",
50
+ scopes: [
51
+ {
52
+ scope: "user",
53
+ label: "User",
54
+ description: "The only config file Claude Desktop reads.",
55
+ requiresProjectDir: false
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ clientId: "cursor",
61
+ label: "Cursor",
62
+ jsonShape: "mcpServers",
63
+ availableOn: ["macos", "linux", "windows"],
64
+ scopes: [
65
+ {
66
+ scope: "user",
67
+ label: "User (global)",
68
+ description: "Private to this machine; applies to every Cursor project.",
69
+ requiresProjectDir: false
70
+ },
71
+ {
72
+ scope: "project",
73
+ label: "Project",
74
+ description: "Commit to share with your team.",
75
+ requiresProjectDir: true
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ clientId: "vscode",
81
+ label: "VS Code",
82
+ jsonShape: "servers",
83
+ availableOn: ["macos", "linux", "windows"],
84
+ notes: "VS Code uses `servers` (not `mcpServers`) as the top-level key in .vscode/mcp.json.",
85
+ scopes: [
86
+ {
87
+ scope: "project",
88
+ label: "Workspace",
89
+ description: "Per-project config; commit to share.",
90
+ requiresProjectDir: true
91
+ }
92
+ ]
93
+ }
94
+ ];
95
+ function resolveInstallPath(opts) {
96
+ const home = opts.home ?? homedir();
97
+ const appData = opts.appData ?? process.env.APPDATA ?? join(home, "AppData", "Roaming");
98
+ const { clientId, scope, os, projectDir, claudeConfigDir } = opts;
99
+ const target = INSTALL_TARGETS.find((t) => t.clientId === clientId);
100
+ if (!target) throw new Error(`Unknown client: ${clientId}`);
101
+ const scopeSpec = target.scopes.find((s) => s.scope === scope);
102
+ if (!scopeSpec) throw new Error(`Client ${clientId} does not support scope ${scope}`);
103
+ if (!target.availableOn.includes(os)) {
104
+ throw new Error(`${target.label} is not available on ${os}`);
105
+ }
106
+ if (scopeSpec.requiresProjectDir && !projectDir) {
107
+ throw new Error(`Scope ${scope} for ${clientId} requires a project directory`);
108
+ }
109
+ const absoluteProjectDir = projectDir && !isAbsolute(projectDir) ? resolve(projectDir) : projectDir;
110
+ const p = pathFor(clientId, scope, os, {
111
+ home,
112
+ appData,
113
+ projectDir: absoluteProjectDir ?? "",
114
+ claudeConfigDir: claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : void 0
115
+ });
116
+ return p;
117
+ }
118
+ function claudeCodeProjectKey(projectDir) {
119
+ return /^(?:[A-Za-z]:[\\/]|\\\\)/.test(projectDir) ? projectDir.replace(/\\/g, "/") : projectDir;
120
+ }
121
+ function pathFor(client, scope, os, base) {
122
+ const { home, appData, projectDir, claudeConfigDir } = base;
123
+ const sep2 = os === "windows" ? "\\" : "/";
124
+ const joinPath = (...parts) => parts.join(sep2);
125
+ if (client === "claude-code") {
126
+ if (scope === "user") {
127
+ if (claudeConfigDir) {
128
+ const absolute = join(claudeConfigDir, ".claude.json");
129
+ return { absolute, display: absolute, containerPath: ["mcpServers"] };
130
+ }
131
+ const display = os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json";
132
+ return { absolute: join(home, ".claude.json"), display, containerPath: ["mcpServers"] };
133
+ }
134
+ if (scope === "project") {
135
+ return {
136
+ absolute: join(projectDir, ".mcp.json"),
137
+ display: joinPath("<project folder>", ".mcp.json"),
138
+ containerPath: ["mcpServers"]
139
+ };
140
+ }
141
+ const projectKey = claudeCodeProjectKey(projectDir);
142
+ if (claudeConfigDir) {
143
+ const absolute = join(claudeConfigDir, ".claude.json");
144
+ return { absolute, display: absolute, containerPath: ["projects", projectKey, "mcpServers"] };
145
+ }
146
+ return {
147
+ absolute: join(home, ".claude.json"),
148
+ display: os === "windows" ? "%USERPROFILE%\\.claude.json" : "~/.claude.json",
149
+ containerPath: ["projects", projectKey, "mcpServers"]
150
+ };
151
+ }
152
+ if (client === "claude-desktop") {
153
+ if (os === "macos") {
154
+ return {
155
+ absolute: join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"),
156
+ display: "~/Library/Application Support/Claude/claude_desktop_config.json",
157
+ containerPath: ["mcpServers"]
158
+ };
159
+ }
160
+ if (os === "windows") {
161
+ return {
162
+ absolute: join(appData, "Claude", "claude_desktop_config.json"),
163
+ display: "%APPDATA%\\Claude\\claude_desktop_config.json",
164
+ containerPath: ["mcpServers"]
165
+ };
166
+ }
167
+ throw new Error("Claude Desktop is not available on Linux");
168
+ }
169
+ if (client === "cursor") {
170
+ if (scope === "user") {
171
+ const display = os === "windows" ? "%USERPROFILE%\\.cursor\\mcp.json" : "~/.cursor/mcp.json";
172
+ return { absolute: join(home, ".cursor", "mcp.json"), display, containerPath: ["mcpServers"] };
173
+ }
174
+ return {
175
+ absolute: join(projectDir, ".cursor", "mcp.json"),
176
+ display: joinPath("<project folder>", ".cursor", "mcp.json"),
177
+ containerPath: ["mcpServers"]
178
+ };
179
+ }
180
+ if (client === "vscode") {
181
+ return {
182
+ absolute: join(projectDir, ".vscode", "mcp.json"),
183
+ display: joinPath("<project folder>", ".vscode", "mcp.json"),
184
+ containerPath: ["servers"]
185
+ };
186
+ }
187
+ throw new Error(`Unhandled client: ${client}`);
188
+ }
189
+ var CMD_METACHARS = /[&|<>^()]/g;
190
+ function escapeCmdArg(arg) {
191
+ if (/[ \t"]/.test(arg)) return arg;
192
+ return arg.replace(CMD_METACHARS, "^$&");
193
+ }
194
+ function buildLaunchEntry(opts) {
195
+ if (opts.upstream) {
196
+ const { command, args, env } = opts.upstream;
197
+ if (opts.os === "windows") {
198
+ const wrapped = {
199
+ command: "cmd",
200
+ args: ["/c", escapeCmdArg(command), ...args.map(escapeCmdArg)]
201
+ };
202
+ if (env && Object.keys(env).length > 0) wrapped.env = { ...env };
203
+ return wrapped;
204
+ }
205
+ const entry = { command, args: [...args] };
206
+ if (env && Object.keys(env).length > 0) entry.env = { ...env };
207
+ return entry;
208
+ }
209
+ const pkg = opts.pkg ?? "@yawlabs/mcp@latest";
210
+ if (opts.oamBinPath && isAbsolute(opts.oamBinPath) && opts.oamEntry && !opts.pkg) {
211
+ return { command: opts.oamBinPath, args: ["run", "--no-check", opts.oamEntry] };
212
+ }
213
+ return opts.os === "windows" ? { command: "cmd", args: ["/c", "npx", "-y", pkg] } : { command: "npx", args: ["-y", pkg] };
214
+ }
215
+ function isProjectLocalEntry(entryPath, cwd) {
216
+ const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
217
+ const entry = norm(entryPath);
218
+ const here = norm(cwd);
219
+ const idx = entry.indexOf("/node_modules/");
220
+ if (idx <= 0) return false;
221
+ const root = entry.slice(0, idx);
222
+ return here === root || here.startsWith(`${root}/`);
223
+ }
224
+ var ENTRY_NAME = "mcp";
225
+ var LEGACY_ENTRY_NAMES = ["mcp.hosting", "mcph", "yaw-mcp"];
226
+ function findLegacyEntry(container) {
227
+ return LEGACY_ENTRY_NAMES.find((n) => n in container) ?? null;
228
+ }
229
+ var CLAUDE_CODE_ALLOW_PATTERN = "mcp__mcp__*";
230
+ function resolveClaudeCodeSettingsPath(scope, opts) {
231
+ const { home, projectDir, claudeConfigDir } = opts;
232
+ const cfgDir = claudeConfigDir && claudeConfigDir.length > 0 ? claudeConfigDir : null;
233
+ if (scope === "user") return cfgDir ? join(cfgDir, "settings.json") : join(home, ".claude", "settings.json");
234
+ if (scope === "project" && projectDir) return join(projectDir, ".claude", "settings.json");
235
+ if (scope === "local" && projectDir) return join(projectDir, ".claude", "settings.local.json");
236
+ return null;
18
237
  }
19
238
 
20
239
  // src/paths.ts
21
- import { access } from "fs/promises";
22
- import { homedir } from "os";
240
+ import { access, stat } from "fs/promises";
241
+ import { homedir as homedir2 } from "os";
23
242
  import path from "path";
24
243
  function cacheDir() {
25
244
  if (process.platform === "win32") {
26
245
  const localAppData = process.env.LOCALAPPDATA;
27
- const base = localAppData && localAppData.length > 0 ? localAppData : path.join(homedir(), "AppData", "Local");
246
+ const base = localAppData && localAppData.length > 0 ? localAppData : path.join(homedir2(), "AppData", "Local");
28
247
  return path.join(base, "yaw-mcp", "Cache");
29
248
  }
30
249
  if (process.platform === "darwin") {
31
- return path.join(homedir(), "Library", "Caches", "yaw-mcp");
250
+ return path.join(homedir2(), "Library", "Caches", "yaw-mcp");
32
251
  }
33
252
  const xdg = process.env.XDG_CACHE_HOME;
34
- return path.join(xdg && xdg.length > 0 ? xdg : path.join(homedir(), ".cache"), "yaw-mcp");
253
+ return path.join(xdg && xdg.length > 0 ? xdg : path.join(homedir2(), ".cache"), "yaw-mcp");
35
254
  }
36
255
  var CONFIG_DIRNAME = ".yaw-mcp";
37
256
  var SIDECARS_DIRNAME = "sidecars";
38
- function sidecarsRoot(home = homedir()) {
257
+ function sidecarsRoot(home = homedir2()) {
39
258
  return path.join(userConfigDir(home), SIDECARS_DIRNAME);
40
259
  }
41
- function sidecarsNodeModules(home = homedir()) {
260
+ function sidecarsNodeModules(home = homedir2()) {
42
261
  return path.join(sidecarsRoot(home), "node_modules");
43
262
  }
44
- function userConfigDir(home = homedir()) {
263
+ function userConfigDir(home = homedir2()) {
45
264
  return path.join(home, CONFIG_DIRNAME);
46
265
  }
47
266
  function normalizeForCompare(p) {
@@ -56,17 +275,29 @@ function isUnderHome(dir, homeResolved) {
56
275
  const relNorm = normalizeForCompare(rel);
57
276
  return relNorm !== ".." && !relNorm.startsWith(`..${path.sep}`);
58
277
  }
59
- async function findProjectConfigDir(start, home = homedir()) {
60
- const homeFallback = home && home.length > 0 ? home : process.env.USERPROFILE || homedir();
278
+ async function ownedByCurrentUser(candidate) {
279
+ const geteuid = process.geteuid;
280
+ if (typeof geteuid !== "function") return true;
281
+ try {
282
+ const st = await stat(candidate);
283
+ return typeof st.uid === "number" && st.uid === geteuid.call(process);
284
+ } catch {
285
+ return false;
286
+ }
287
+ }
288
+ async function findProjectConfigDir(start, home = homedir2()) {
289
+ const homeFallback = home && home.length > 0 ? home : process.env.USERPROFILE || homedir2();
61
290
  const homeResolved = path.resolve(homeFallback);
62
291
  let dir = path.resolve(start);
292
+ const boundedByHome = isUnderHome(dir, homeResolved) || normalizeForCompare(dir) === normalizeForCompare(homeResolved);
63
293
  let prev = "";
64
294
  while (dir !== prev) {
65
- if (!isUnderHome(dir, homeResolved)) return null;
295
+ if (boundedByHome && !isUnderHome(dir, homeResolved)) return null;
66
296
  const candidate = path.join(dir, CONFIG_DIRNAME);
67
297
  try {
68
298
  await access(candidate);
69
- return candidate;
299
+ if (boundedByHome || await ownedByCurrentUser(candidate)) return candidate;
300
+ log("warn", "Skipping a .yaw-mcp/ dir not owned by the current user", { candidate });
70
301
  } catch {
71
302
  }
72
303
  prev = dir;
@@ -111,12 +342,31 @@ function npxSpec(args) {
111
342
  const spec = args[idx];
112
343
  return spec.startsWith("-") ? null : spec;
113
344
  }
114
- var MIN_OAM_VERSION = "0.9.0";
345
+ var MIN_OAM_VERSION = "0.11.0";
115
346
  var OAM_INSTALL_SH = "curl -fsSL https://oamjs.org/install.sh | sh";
116
347
  var OAM_INSTALL_PS1 = "irm https://oamjs.org/install.ps1 | iex";
117
348
  function oamInstallCommand(os) {
118
349
  return os === "windows" ? OAM_INSTALL_PS1 : OAM_INSTALL_SH;
119
350
  }
351
+ function oamPublishesBinaryFor(platform, arch) {
352
+ if (platform === "win32" || platform === "darwin") return arch === "x64" || arch === "arm64";
353
+ if (platform === "linux") return arch === "x64";
354
+ return false;
355
+ }
356
+ function oamPublishesBinaryForThisMachine() {
357
+ return oamPublishesBinaryFor(process.platform, process.arch);
358
+ }
359
+ function oamNoBinaryReason() {
360
+ return `no published oam binary for ${process.platform}-${process.arch} yet \u2014 build from source at https://oamjs.org`;
361
+ }
362
+ function oamInstallAdvice(os) {
363
+ if (os === CURRENT_OS && !oamPublishesBinaryForThisMachine()) return oamNoBinaryReason();
364
+ return oamInstallCommand(os);
365
+ }
366
+ function oamHeapOomHint(stderr) {
367
+ if (!stderr.includes("OAM-RT-OOM")) return null;
368
+ return `The oam-hosted child hit its V8 heap cap (oam defaults to 4 GiB). Raise it with OAM_MAX_HEAP_MB=<mb> in this server's env, or set "runtime": "node" for this server in bundles.json.`;
369
+ }
120
370
  var warnedOamUnavailable = false;
121
371
  function oamFailureLabel(failure) {
122
372
  if (failure === "timeout") return "`oam --version` did not answer in time";
@@ -183,7 +433,7 @@ function isExecutableFile(candidate, platform) {
183
433
  }
184
434
  }
185
435
  function resolveBinAbsolute(bin, env = process.env, platform = process.platform) {
186
- if (isAbsolute(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
436
+ if (isAbsolute2(bin)) return isExecutableFile(bin, platform) ? winNormalize(bin, platform) : null;
187
437
  const pathVar = env.PATH ?? env.Path ?? env.path ?? "";
188
438
  if (!pathVar) return null;
189
439
  const dirs = pathVar.split(platform === "win32" ? ";" : ":").filter(Boolean);
@@ -191,8 +441,8 @@ function resolveBinAbsolute(bin, env = process.env, platform = process.platform)
191
441
  for (const dir of dirs) {
192
442
  const clean = dir.replace(/^"|"$/g, "");
193
443
  for (const ext of exts) {
194
- const candidate = join(clean, bin + ext);
195
- if (!isAbsolute(candidate)) continue;
444
+ const candidate = join2(clean, bin + ext);
445
+ if (!isAbsolute2(candidate)) continue;
196
446
  if (isExecutableFile(candidate, platform)) return winNormalize(candidate, platform);
197
447
  }
198
448
  }
@@ -232,7 +482,7 @@ function createProbeCollector(max = OAM_PROBE_MAX_OUTPUT) {
232
482
  };
233
483
  }
234
484
  function spawnVersionProbe(bin) {
235
- return new Promise((resolve, reject) => {
485
+ return new Promise((resolve2, reject) => {
236
486
  let settled = false;
237
487
  let timer;
238
488
  const settle = (fn) => {
@@ -261,7 +511,7 @@ function spawnVersionProbe(bin) {
261
511
  "close",
262
512
  (code, signal) => settle(() => {
263
513
  if (code === 0) {
264
- resolve(collector.result());
514
+ resolve2(collector.result());
265
515
  return;
266
516
  }
267
517
  const err = new Error(`oam exited ${code ?? signal}`);
@@ -444,7 +694,7 @@ function npxCacheNodeModules(fromUrl = import.meta.url) {
444
694
  if (idx === -1) return [];
445
695
  const npxRoot = here.slice(0, idx + NPX_CACHE_MARKER.length - sep.length);
446
696
  try {
447
- return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join(npxRoot, e.name, "node_modules"));
697
+ return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join2(npxRoot, e.name, "node_modules"));
448
698
  } catch {
449
699
  return [];
450
700
  }
@@ -492,7 +742,7 @@ function npmrcCache(file) {
492
742
  if (!m) continue;
493
743
  const value = npmrcValue(m[1]);
494
744
  if (!value) continue;
495
- return value.startsWith("~/") ? join(homedir2(), value.slice(2)) : value;
745
+ return value.startsWith("~/") ? join2(homedir3(), value.slice(2)) : value;
496
746
  }
497
747
  return null;
498
748
  }
@@ -510,36 +760,36 @@ function resetNpmCacheDir() {
510
760
  function resolveNpmCacheDir(fromUrl) {
511
761
  const fromEnv = process.env.npm_config_cache;
512
762
  if (fromEnv) return fromEnv;
513
- const candidates = [join(homedir2(), ".npmrc")];
763
+ const candidates = [join2(homedir3(), ".npmrc")];
514
764
  for (const nodeModules of ownNodeModules(fromUrl)) {
515
765
  candidates.push(
516
- join(dirname(nodeModules), "etc", "npmrc"),
766
+ join2(dirname(nodeModules), "etc", "npmrc"),
517
767
  // <prefix>/node_modules (Windows)
518
- join(dirname(dirname(nodeModules)), "etc", "npmrc"),
768
+ join2(dirname(dirname(nodeModules)), "etc", "npmrc"),
519
769
  // <prefix>/lib/node_modules (POSIX)
520
- join(nodeModules, "npm", "npmrc")
770
+ join2(nodeModules, "npm", "npmrc")
521
771
  // builtin, beside npm itself
522
772
  );
523
773
  }
524
774
  const nodeDir = dirname(process.execPath);
525
775
  candidates.push(
526
- join(nodeDir, "node_modules", "npm", "npmrc"),
776
+ join2(nodeDir, "node_modules", "npm", "npmrc"),
527
777
  // Windows layout
528
- join(nodeDir, "..", "lib", "node_modules", "npm", "npmrc")
778
+ join2(nodeDir, "..", "lib", "node_modules", "npm", "npmrc")
529
779
  // POSIX layout
530
780
  );
531
781
  for (const file of candidates) {
532
782
  const cache = npmrcCache(file);
533
783
  if (cache) return cache;
534
784
  }
535
- const fallback = process.platform === "win32" ? process.env.LOCALAPPDATA && join(process.env.LOCALAPPDATA, "npm-cache") : join(homedir2(), ".npm");
785
+ const fallback = process.platform === "win32" ? process.env.LOCALAPPDATA && join2(process.env.LOCALAPPDATA, "npm-cache") : join2(homedir3(), ".npm");
536
786
  return fallback && existsSync(fallback) ? fallback : null;
537
787
  }
538
788
  function npmCacheNpxNodeModules(cacheDir2) {
539
789
  if (!cacheDir2) return [];
540
- const npxRoot = join(cacheDir2, "_npx");
790
+ const npxRoot = join2(cacheDir2, "_npx");
541
791
  try {
542
- return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join(npxRoot, e.name, "node_modules"));
792
+ return readdirSync(npxRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join2(npxRoot, e.name, "node_modules"));
543
793
  } catch {
544
794
  return [];
545
795
  }
@@ -557,7 +807,7 @@ function ownNodeModules(fromUrl = import.meta.url) {
557
807
  return [here.slice(0, idx + seg.length - sep.length)];
558
808
  }
559
809
  function packageEntry(pkgDir, pkg) {
560
- const pjPath = join(pkgDir, "package.json");
810
+ const pjPath = join2(pkgDir, "package.json");
561
811
  if (!existsSync(pjPath)) return null;
562
812
  let j;
563
813
  try {
@@ -574,7 +824,7 @@ function packageEntry(pkgDir, pkg) {
574
824
  }
575
825
  if (!rel && typeof j.main === "string") rel = j.main;
576
826
  if (!rel) return null;
577
- const entry = isAbsolute(rel) ? rel : join(pkgDir, rel);
827
+ const entry = isAbsolute2(rel) ? rel : join2(pkgDir, rel);
578
828
  if (!existsSync(entry)) return null;
579
829
  return {
580
830
  entry,
@@ -596,7 +846,7 @@ function resolveNpmEntry(pkg, fromUrl = import.meta.url, npmCache = npmCacheDir(
596
846
  }))
597
847
  ];
598
848
  for (const { nodeModules, source } of durable) {
599
- const hit = packageEntry(join(nodeModules, ...parts), pkg);
849
+ const hit = packageEntry(join2(nodeModules, ...parts), pkg);
600
850
  if (!hit) continue;
601
851
  if (wantVersion !== null && !satisfiesExactPin(hit.version, wantVersion)) continue;
602
852
  notePinnedSidecar(pkg, hit.version, source, nodeModules);
@@ -607,7 +857,7 @@ function resolveNpmEntry(pkg, fromUrl = import.meta.url, npmCache = npmCacheDir(
607
857
  let bestRoot = null;
608
858
  let bestParsed = null;
609
859
  for (const nodeModules of roots) {
610
- const hit = packageEntry(join(nodeModules, ...parts), pkg);
860
+ const hit = packageEntry(join2(nodeModules, ...parts), pkg);
611
861
  if (!hit) continue;
612
862
  if (wantVersion !== null && !satisfiesExactPin(hit.version, wantVersion)) continue;
613
863
  const parsed = hit.version === null ? null : parseSemver(hit.version);
@@ -624,7 +874,16 @@ function resolveNpmEntry(pkg, fromUrl = import.meta.url, npmCache = npmCacheDir(
624
874
  var REFRESH_COMMAND = {
625
875
  managed: () => "yaw-mcp sidecars install",
626
876
  durable: (pkg) => `npm install ${pkg}@latest`,
627
- "npx-cache": (pkg) => `npx -y ${pkg}@latest --help`
877
+ // No trailing flag. `npx -y <pkg>@latest` re-resolves the tag and refreshes
878
+ // the cache tree BEFORE it execs the binary, which is all the refresh
879
+ // needs -- and stdio MCP servers ignore flags like `--help` and simply
880
+ // start, so tacking one on turns "runs briefly" into "hangs the terminal
881
+ // on a server waiting for stdin" (measured on
882
+ // @modelcontextprotocol/server-memory). `npm cache add` is no substitute:
883
+ // it only fills _cacache, never the _npx install tree this resolver reads.
884
+ // The `#` comment is valid in both sh and PowerShell, so the line stays
885
+ // copy-paste runnable while telling the user how to get their prompt back.
886
+ "npx-cache": (pkg) => `npx -y ${pkg}@latest # then Ctrl-C -- the cache is refreshed before the server starts`
628
887
  };
629
888
  var pinnedReported = /* @__PURE__ */ new Set();
630
889
  function resetPinnedSidecarLog() {
@@ -652,7 +911,7 @@ function notePinnedSidecar(pkg, version, source, from) {
652
911
  function resolveStableNpmEntry(pkg, fromUrl = import.meta.url) {
653
912
  for (const nodeModules of ownNodeModules(fromUrl)) {
654
913
  if (nodeModules.includes(NPX_CACHE_MARKER)) continue;
655
- const hit = packageEntry(join(nodeModules, ...pkg.split("/")), pkg);
914
+ const hit = packageEntry(join2(nodeModules, ...pkg.split("/")), pkg);
656
915
  if (hit) return hit.entry;
657
916
  }
658
917
  return null;
@@ -715,14 +974,24 @@ function isOamLaunch(command, args = []) {
715
974
  }
716
975
 
717
976
  export {
718
- log,
719
977
  cacheDir,
720
978
  CONFIG_DIRNAME,
721
979
  sidecarsRoot,
722
980
  sidecarsNodeModules,
723
981
  userConfigDir,
982
+ isUnderHome,
724
983
  findProjectConfigDir,
725
984
  guidePath,
985
+ CURRENT_OS,
986
+ INSTALL_TARGETS,
987
+ resolveInstallPath,
988
+ buildLaunchEntry,
989
+ isProjectLocalEntry,
990
+ ENTRY_NAME,
991
+ LEGACY_ENTRY_NAMES,
992
+ findLegacyEntry,
993
+ CLAUDE_CODE_ALLOW_PATTERN,
994
+ resolveClaudeCodeSettingsPath,
726
995
  packageName,
727
996
  specConstraint,
728
997
  isRegistrySpec,
@@ -732,6 +1001,11 @@ export {
732
1001
  OAM_INSTALL_SH,
733
1002
  OAM_INSTALL_PS1,
734
1003
  oamInstallCommand,
1004
+ oamPublishesBinaryFor,
1005
+ oamPublishesBinaryForThisMachine,
1006
+ oamNoBinaryReason,
1007
+ oamInstallAdvice,
1008
+ oamHeapOomHint,
735
1009
  oamFailureLabel,
736
1010
  parseOamVersion,
737
1011
  compareVersions,
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/logger.ts
4
+ var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
5
+ var minLevel = LOG_LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LOG_LEVELS.info;
6
+ function log(level, msg, data) {
7
+ if (LOG_LEVELS[level] < minLevel) return;
8
+ const entry = JSON.stringify({ ...data, level, msg, ts: (/* @__PURE__ */ new Date()).toISOString() });
9
+ process.stderr.write(`${entry}
10
+ `);
11
+ }
12
+
13
+ export {
14
+ log
15
+ };