@50arms/platform-mcp 0.1.574 → 0.1.576
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/checkout-docs-root.js +2 -4
- package/dist/hidden-process.d.mts +42 -0
- package/dist/hidden-process.mjs +93 -0
- package/dist/machine-daemon/autostart.js +2 -3
- package/dist/machine-daemon/leftovers.js +1 -1
- package/dist/machine-daemon.js +58 -16
- package/dist/machine-toolkit.js +30 -12
- package/dist/mini-app-build.js +1 -3
- package/dist/mini-app-checkout.js +6 -4
- package/dist/version-floor.js +1 -1
- package/package.json +5 -5
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Only `owner/name` leaves this machine, never the remote URL, which can carry a credential.
|
|
8
8
|
*/
|
|
9
|
-
import { execFile } from "node:child_process";
|
|
10
9
|
import { existsSync } from "node:fs";
|
|
11
10
|
import { join } from "node:path";
|
|
12
|
-
import {
|
|
13
|
-
const execFileAsync = promisify(execFile);
|
|
11
|
+
import { execFileAsync } from "./hidden-process.mjs";
|
|
14
12
|
/** The folder every detector checks (`DETECTED_DOCS_ROOT` in `src/issues/docs-root-detection.ts`). */
|
|
15
13
|
const DOCS_ROOT = "docs/pages";
|
|
16
14
|
/** `owner/name` of a GitHub remote, an SSH host alias (`git@github.com-work:owner/name.git`) included, or null for any other remote. */
|
|
@@ -18,7 +16,7 @@ export function githubSlugOf(remote) {
|
|
|
18
16
|
const match = /^(?:[a-z+]+:\/\/)?(?:[^@/]+@)?([^/:]*github[^/:]*)[/:]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(remote.trim());
|
|
19
17
|
return match === null ? null : `${match[2]}/${match[3]}`;
|
|
20
18
|
}
|
|
21
|
-
const runGit = async (cwd, args) => (await execFileAsync("git", [...args], { cwd
|
|
19
|
+
const runGit = async (cwd, args) => (await execFileAsync("git", [...args], { cwd })).stdout.trim();
|
|
22
20
|
/** DX-6888: `owner/name` of the GitHub repo `cwd`'s checkout was cloned from, or null for a folder with no checkout, no `origin`, or a remote that is not on GitHub. Sent with the session's sign-in request so the guide and the approver can name the repo. */
|
|
23
21
|
export async function readCheckoutRepo(cwd, git = runGit) {
|
|
24
22
|
try {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Generated from src/util/hidden-process.d.mts by src/util/hidden-process-copies.mjs (DX-7918). Never edit it and never commit it: the package's build writes it.
|
|
2
|
+
import type * as cp from "node:child_process";
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
ChildProcess,
|
|
6
|
+
ChildProcessWithoutNullStreams,
|
|
7
|
+
ExecFileException,
|
|
8
|
+
ExecFileOptions,
|
|
9
|
+
ExecFileSyncOptions,
|
|
10
|
+
ExecOptions,
|
|
11
|
+
ExecSyncOptions,
|
|
12
|
+
ForkOptions,
|
|
13
|
+
SpawnOptions,
|
|
14
|
+
SpawnSyncOptions,
|
|
15
|
+
SpawnSyncOptionsWithStringEncoding,
|
|
16
|
+
SpawnSyncReturns,
|
|
17
|
+
StdioOptions,
|
|
18
|
+
} from "node:child_process";
|
|
19
|
+
|
|
20
|
+
/** Node's `child_process.spawn`, with `windowsHide: true` forced on. */
|
|
21
|
+
export const spawn: typeof cp.spawn;
|
|
22
|
+
export const spawnSync: typeof cp.spawnSync;
|
|
23
|
+
export const execFile: typeof cp.execFile;
|
|
24
|
+
export const execFileSync: typeof cp.execFileSync;
|
|
25
|
+
export const exec: typeof cp.exec;
|
|
26
|
+
export const execSync: typeof cp.execSync;
|
|
27
|
+
export const fork: typeof cp.fork;
|
|
28
|
+
/** `promisify(execFile)`: resolves `{ stdout, stderr }`. */
|
|
29
|
+
export const execFileAsync: (
|
|
30
|
+
file: string,
|
|
31
|
+
args?: readonly string[] | null,
|
|
32
|
+
options?: cp.ExecFileOptions,
|
|
33
|
+
) => Promise<{ stdout: string; stderr: string }>;
|
|
34
|
+
export const execAsync: (
|
|
35
|
+
command: string,
|
|
36
|
+
options?: cp.ExecOptions,
|
|
37
|
+
) => Promise<{ stdout: string; stderr: string }>;
|
|
38
|
+
export function withWindowsHidden(
|
|
39
|
+
args: readonly unknown[],
|
|
40
|
+
optionsAfterArgs: boolean,
|
|
41
|
+
): unknown[];
|
|
42
|
+
export function hideWindowsOfChildProcesses(target?: typeof cp): void;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Generated from src/util/hidden-process.mjs by src/util/hidden-process-copies.mjs (DX-7918). Never edit it and never commit it: the package's build writes it.
|
|
2
|
+
/**
|
|
3
|
+
* DX-7917 - the ONE way host code starts a child process.
|
|
4
|
+
*
|
|
5
|
+
* On Windows a console program (git, docker, node) started by a process with no console gets a visible console
|
|
6
|
+
* window that steals focus, and under load fails with 0xC0000142 (CLAUDE.md "No command ever opens a window").
|
|
7
|
+
* Every function here is node's own `child_process` function with the same signature, except that `windowsHide: true`
|
|
8
|
+
* is set AFTER the caller's options, so no caller can turn it off. `hidden-process-preload.mjs` applies the same
|
|
9
|
+
* rule to raw `child_process` calls a wrapper import missed.
|
|
10
|
+
*
|
|
11
|
+
* Plain `.mjs` (typed by `hidden-process.d.mts`) so the preload and standalone scripts can load it with no build step.
|
|
12
|
+
* Every `child_process` binding is read at call time, never at import time, so a test that mocks `node:child_process`
|
|
13
|
+
* with only the functions it uses still loads this module.
|
|
14
|
+
*/
|
|
15
|
+
import * as cp from "node:child_process";
|
|
16
|
+
import { promisify } from "node:util";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* `args` with `windowsHide: true` forced into its options object, found by node's argument rules: `(file, args?, options?, callback?)`
|
|
20
|
+
* when `optionsAfterArgs` (spawn family, execFile, fork), else `(command, options?, callback?)` (exec family).
|
|
21
|
+
*/
|
|
22
|
+
export function withWindowsHidden(args, optionsAfterArgs) {
|
|
23
|
+
const out = [...args];
|
|
24
|
+
let at = 1;
|
|
25
|
+
// Node reads `(file, undefined | null, options)` as no args with the options in slot 2.
|
|
26
|
+
if (
|
|
27
|
+
optionsAfterArgs &&
|
|
28
|
+
(Array.isArray(out[1]) ||
|
|
29
|
+
((out[1] === undefined || out[1] === null) &&
|
|
30
|
+
out.length > 2 &&
|
|
31
|
+
typeof out[2] !== "function"))
|
|
32
|
+
) {
|
|
33
|
+
at = 2;
|
|
34
|
+
}
|
|
35
|
+
const given = out[at];
|
|
36
|
+
if (given === undefined || given === null) out[at] = { windowsHide: true };
|
|
37
|
+
else if (typeof given === "function")
|
|
38
|
+
out.splice(at, 0, { windowsHide: true });
|
|
39
|
+
else out[at] = { ...given, windowsHide: true };
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const spawn = (...args) => cp.spawn(...withWindowsHidden(args, true));
|
|
44
|
+
export const spawnSync = (...args) =>
|
|
45
|
+
cp.spawnSync(...withWindowsHidden(args, true));
|
|
46
|
+
export const execFileSync = (...args) =>
|
|
47
|
+
cp.execFileSync(...withWindowsHidden(args, true));
|
|
48
|
+
export const execSync = (...args) =>
|
|
49
|
+
cp.execSync(...withWindowsHidden(args, false));
|
|
50
|
+
export const fork = (...args) => cp.fork(...withWindowsHidden(args, true));
|
|
51
|
+
|
|
52
|
+
/** Promisified `execFile`: resolves `{ stdout, stderr }`, rejects with node's error (carrying `stdout`, `stderr`, `code`). */
|
|
53
|
+
export const execFileAsync = (...args) =>
|
|
54
|
+
promisify(cp.execFile)(...withWindowsHidden(args, true));
|
|
55
|
+
/** Promisified `exec`, the same way. */
|
|
56
|
+
export const execAsync = (...args) =>
|
|
57
|
+
promisify(cp.exec)(...withWindowsHidden(args, false));
|
|
58
|
+
|
|
59
|
+
export const execFile = (...args) =>
|
|
60
|
+
cp.execFile(...withWindowsHidden(args, true));
|
|
61
|
+
export const exec = (...args) => cp.exec(...withWindowsHidden(args, false));
|
|
62
|
+
// `promisify(execFile)` keeps resolving `{ stdout, stderr }`, as it does for node's own.
|
|
63
|
+
execFile[promisify.custom] = execFileAsync;
|
|
64
|
+
exec[promisify.custom] = execAsync;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Patch the live `node:child_process` so every call gets `windowsHide: true`, whoever made it
|
|
68
|
+
* (the preload's job). Idempotent: a function already patched is left alone.
|
|
69
|
+
*/
|
|
70
|
+
export function hideWindowsOfChildProcesses(target = cp) {
|
|
71
|
+
const patches = {
|
|
72
|
+
spawn: [spawn, true],
|
|
73
|
+
spawnSync: [spawnSync, true],
|
|
74
|
+
execFile: [execFile, true],
|
|
75
|
+
execFileSync: [execFileSync, true],
|
|
76
|
+
exec: [exec, false],
|
|
77
|
+
execSync: [execSync, false],
|
|
78
|
+
fork: [fork, true],
|
|
79
|
+
};
|
|
80
|
+
for (const [name, [, optionsAfterArgs]] of Object.entries(patches)) {
|
|
81
|
+
const original = target[name];
|
|
82
|
+
if (original.__windowsHidden) continue;
|
|
83
|
+
const patched = (...args) =>
|
|
84
|
+
original(...withWindowsHidden(args, optionsAfterArgs));
|
|
85
|
+
patched.__windowsHidden = true;
|
|
86
|
+
const custom = original[promisify.custom];
|
|
87
|
+
if (custom !== undefined) {
|
|
88
|
+
patched[promisify.custom] = (...args) =>
|
|
89
|
+
custom(...withWindowsHidden(args, optionsAfterArgs));
|
|
90
|
+
}
|
|
91
|
+
target[name] = patched;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
* A daemon whose bearer the dashboard refused stops on purpose and disables its entry (`disableAutostart`), so neither the
|
|
17
17
|
* repeating trigger nor the next logon starts it into the same refusal; `install-daemon` enables it again.
|
|
18
18
|
*
|
|
19
|
-
* Every child process is started
|
|
19
|
+
* Every child process is started through `../hidden-process.mjs` (a window is never opened). The XML, unit and plist text are pure functions so the tests pin them.
|
|
20
20
|
* The task XML is UTF-16: `schtasks /XML` reads no other encoding (a UTF-8 file is refused "unable to switch the encoding").
|
|
21
21
|
*/
|
|
22
|
-
import { execFileSync } from "node:child_process";
|
|
23
22
|
import { mkdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
24
23
|
import { homedir } from "node:os";
|
|
25
24
|
import { join } from "node:path";
|
|
25
|
+
import { execFileSync } from "../hidden-process.mjs";
|
|
26
26
|
export const TASK_NAME = "danxbot-machine-daemon";
|
|
27
27
|
export const UNIT_NAME = "danxbot-machine-daemon.service";
|
|
28
28
|
export const LAUNCH_AGENT_LABEL = "ai.50arms.danxbot-machine-daemon";
|
|
@@ -126,7 +126,6 @@ export function currentUid() {
|
|
|
126
126
|
export function runHidden(file, args) {
|
|
127
127
|
return execFileSync(file, args, {
|
|
128
128
|
encoding: "utf8",
|
|
129
|
-
windowsHide: true,
|
|
130
129
|
stdio: ["ignore", "pipe", "pipe"],
|
|
131
130
|
});
|
|
132
131
|
}
|
|
@@ -123,7 +123,7 @@ foreach ($id in @(${pids.join(",")})) {
|
|
|
123
123
|
}
|
|
124
124
|
`;
|
|
125
125
|
const SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
126
|
-
/** Reads `CLAUDE_CODE_SESSION_ID` out of each process's environment; a pid that answers nothing is absent from the map. `run` is the same injectable command runner the listings use (
|
|
126
|
+
/** Reads `CLAUDE_CODE_SESSION_ID` out of each process's environment; a pid that answers nothing is absent from the map. `run` is the same injectable command runner the listings use (started with no window there). */
|
|
127
127
|
export async function readSessionsFromEnvironment(pids, run = runCommand) {
|
|
128
128
|
const found = new Map();
|
|
129
129
|
if (pids.length === 0)
|
package/dist/machine-daemon.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/machine-daemon/run.ts
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
2
|
import { existsSync as existsSync3 } from "node:fs";
|
|
4
3
|
import { homedir as homedir3 } from "node:os";
|
|
5
4
|
|
|
@@ -11,7 +10,32 @@ import {
|
|
|
11
10
|
totalmem,
|
|
12
11
|
platform as osPlatform
|
|
13
12
|
} from "node:os";
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
// ../../src/util/hidden-process.mjs
|
|
15
|
+
import * as cp from "node:child_process";
|
|
16
|
+
import { promisify } from "node:util";
|
|
17
|
+
function withWindowsHidden(args, optionsAfterArgs) {
|
|
18
|
+
const out = [...args];
|
|
19
|
+
let at = 1;
|
|
20
|
+
if (optionsAfterArgs && (Array.isArray(out[1]) || (out[1] === void 0 || out[1] === null) && out.length > 2 && typeof out[2] !== "function")) {
|
|
21
|
+
at = 2;
|
|
22
|
+
}
|
|
23
|
+
const given = out[at];
|
|
24
|
+
if (given === void 0 || given === null) out[at] = { windowsHide: true };
|
|
25
|
+
else if (typeof given === "function")
|
|
26
|
+
out.splice(at, 0, { windowsHide: true });
|
|
27
|
+
else out[at] = { ...given, windowsHide: true };
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
var execFileSync2 = (...args) => cp.execFileSync(...withWindowsHidden(args, true));
|
|
31
|
+
var execFileAsync = (...args) => promisify(cp.execFile)(...withWindowsHidden(args, true));
|
|
32
|
+
var execAsync = (...args) => promisify(cp.exec)(...withWindowsHidden(args, false));
|
|
33
|
+
var execFile2 = (...args) => cp.execFile(...withWindowsHidden(args, true));
|
|
34
|
+
var exec2 = (...args) => cp.exec(...withWindowsHidden(args, false));
|
|
35
|
+
execFile2[promisify.custom] = execFileAsync;
|
|
36
|
+
exec2[promisify.custom] = execAsync;
|
|
37
|
+
|
|
38
|
+
// ../machine-vitals/src/probes.ts
|
|
15
39
|
function readDisk(path, statfs = statfsSync) {
|
|
16
40
|
const stats = statfs(path);
|
|
17
41
|
return {
|
|
@@ -104,10 +128,10 @@ function readSwap(deps = {}) {
|
|
|
104
128
|
);
|
|
105
129
|
}
|
|
106
130
|
if (platform === "win32") {
|
|
107
|
-
const run = deps.runPowerShell ?? ((script) =>
|
|
131
|
+
const run = deps.runPowerShell ?? ((script) => execFileSync2(
|
|
108
132
|
"powershell.exe",
|
|
109
133
|
["-NoProfile", "-NonInteractive", "-Command", script],
|
|
110
|
-
{ encoding: "utf8"
|
|
134
|
+
{ encoding: "utf8" }
|
|
111
135
|
));
|
|
112
136
|
return parsePageFileJson(run(PAGEFILE_SCRIPT).trim() || "[]");
|
|
113
137
|
}
|
|
@@ -137,8 +161,32 @@ function createMachineVitalsCollector(deps) {
|
|
|
137
161
|
};
|
|
138
162
|
}
|
|
139
163
|
|
|
164
|
+
// src/hidden-process.mjs
|
|
165
|
+
import * as cp2 from "node:child_process";
|
|
166
|
+
import { promisify as promisify2 } from "node:util";
|
|
167
|
+
function withWindowsHidden2(args, optionsAfterArgs) {
|
|
168
|
+
const out = [...args];
|
|
169
|
+
let at = 1;
|
|
170
|
+
if (optionsAfterArgs && (Array.isArray(out[1]) || (out[1] === void 0 || out[1] === null) && out.length > 2 && typeof out[2] !== "function")) {
|
|
171
|
+
at = 2;
|
|
172
|
+
}
|
|
173
|
+
const given = out[at];
|
|
174
|
+
if (given === void 0 || given === null) out[at] = { windowsHide: true };
|
|
175
|
+
else if (typeof given === "function")
|
|
176
|
+
out.splice(at, 0, { windowsHide: true });
|
|
177
|
+
else out[at] = { ...given, windowsHide: true };
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
var spawn3 = (...args) => cp2.spawn(...withWindowsHidden2(args, true));
|
|
181
|
+
var execFileSync4 = (...args) => cp2.execFileSync(...withWindowsHidden2(args, true));
|
|
182
|
+
var execFileAsync2 = (...args) => promisify2(cp2.execFile)(...withWindowsHidden2(args, true));
|
|
183
|
+
var execAsync2 = (...args) => promisify2(cp2.exec)(...withWindowsHidden2(args, false));
|
|
184
|
+
var execFile4 = (...args) => cp2.execFile(...withWindowsHidden2(args, true));
|
|
185
|
+
var exec4 = (...args) => cp2.exec(...withWindowsHidden2(args, false));
|
|
186
|
+
execFile4[promisify2.custom] = execFileAsync2;
|
|
187
|
+
exec4[promisify2.custom] = execAsync2;
|
|
188
|
+
|
|
140
189
|
// src/machine-daemon/autostart.ts
|
|
141
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
142
190
|
var TASK_NAME = "danxbot-machine-daemon";
|
|
143
191
|
var UNIT_NAME = "danxbot-machine-daemon.service";
|
|
144
192
|
var LAUNCH_AGENT_LABEL = "ai.50arms.danxbot-machine-daemon";
|
|
@@ -153,9 +201,8 @@ function currentUid() {
|
|
|
153
201
|
return process.getuid?.() ?? null;
|
|
154
202
|
}
|
|
155
203
|
function runHidden(file, args) {
|
|
156
|
-
return
|
|
204
|
+
return execFileSync4(file, args, {
|
|
157
205
|
encoding: "utf8",
|
|
158
|
-
windowsHide: true,
|
|
159
206
|
stdio: ["ignore", "pipe", "pipe"]
|
|
160
207
|
});
|
|
161
208
|
}
|
|
@@ -288,9 +335,6 @@ import { join } from "node:path";
|
|
|
288
335
|
var LEFTOVER_REMINDER_TTL_MS = 10 * 60 * 1e3;
|
|
289
336
|
var LEFTOVER_COMMAND_MAX_CHARS = 140;
|
|
290
337
|
|
|
291
|
-
// src/machine-toolkit/processes.ts
|
|
292
|
-
import { execFile } from "node:child_process";
|
|
293
|
-
|
|
294
338
|
// src/machine-toolkit/errors.ts
|
|
295
339
|
function errorCode(err) {
|
|
296
340
|
const failure = err;
|
|
@@ -348,13 +392,12 @@ function parseWslListing(stdout, now) {
|
|
|
348
392
|
return rows;
|
|
349
393
|
}
|
|
350
394
|
var runCommand = (file, args, timeoutMs, signal) => new Promise((resolve, reject) => {
|
|
351
|
-
|
|
395
|
+
execFile2(
|
|
352
396
|
file,
|
|
353
397
|
args,
|
|
354
398
|
{
|
|
355
399
|
timeout: timeoutMs,
|
|
356
400
|
maxBuffer: LISTING_MAX_BUFFER_BYTES,
|
|
357
|
-
windowsHide: true,
|
|
358
401
|
signal
|
|
359
402
|
},
|
|
360
403
|
(err, stdout) => err ? reject(err) : resolve(stdout)
|
|
@@ -979,7 +1022,6 @@ function runRefreshChild(opts) {
|
|
|
979
1022
|
"npx",
|
|
980
1023
|
["-y", "@50arms/platform-mcp@latest", "refresh-daemon"],
|
|
981
1024
|
{
|
|
982
|
-
windowsHide: true,
|
|
983
1025
|
shell: process.platform === "win32",
|
|
984
1026
|
stdio: "ignore"
|
|
985
1027
|
}
|
|
@@ -1206,7 +1248,7 @@ function runHealthChild(opts) {
|
|
|
1206
1248
|
const child = opts.spawnFn(
|
|
1207
1249
|
opts.nodePath,
|
|
1208
1250
|
[opts.toolkitPath, "health", "--json"],
|
|
1209
|
-
{
|
|
1251
|
+
{ stdio: ["ignore", "pipe", "ignore"] }
|
|
1210
1252
|
);
|
|
1211
1253
|
cancel = schedule(() => {
|
|
1212
1254
|
child.kill();
|
|
@@ -1471,12 +1513,12 @@ async function runDaemonProcess() {
|
|
|
1471
1513
|
reporter: createReporter({
|
|
1472
1514
|
config,
|
|
1473
1515
|
runHealth: () => runHealthChild({
|
|
1474
|
-
spawnFn:
|
|
1516
|
+
spawnFn: spawn3,
|
|
1475
1517
|
nodePath: process.execPath,
|
|
1476
1518
|
toolkitPath: toolkitBundlePath()
|
|
1477
1519
|
}),
|
|
1478
1520
|
fetchFn,
|
|
1479
|
-
refresh: (needs) => refreshBundles({ needs, now: now(), spawnFn:
|
|
1521
|
+
refresh: (needs) => refreshBundles({ needs, now: now(), spawnFn: spawn3, log }),
|
|
1480
1522
|
leftovers: createSystemLeftoverTracker(log),
|
|
1481
1523
|
writeStatus: status.report,
|
|
1482
1524
|
log,
|
package/dist/machine-toolkit.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
// src/machine-toolkit/cli.ts
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
2
|
import { realpathSync } from "node:fs";
|
|
4
3
|
import { pathToFileURL } from "node:url";
|
|
5
4
|
|
|
5
|
+
// ../../src/util/hidden-process.mjs
|
|
6
|
+
import * as cp from "node:child_process";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
function withWindowsHidden(args, optionsAfterArgs) {
|
|
9
|
+
const out = [...args];
|
|
10
|
+
let at = 1;
|
|
11
|
+
if (optionsAfterArgs && (Array.isArray(out[1]) || (out[1] === void 0 || out[1] === null) && out.length > 2 && typeof out[2] !== "function")) {
|
|
12
|
+
at = 2;
|
|
13
|
+
}
|
|
14
|
+
const given = out[at];
|
|
15
|
+
if (given === void 0 || given === null) out[at] = { windowsHide: true };
|
|
16
|
+
else if (typeof given === "function")
|
|
17
|
+
out.splice(at, 0, { windowsHide: true });
|
|
18
|
+
else out[at] = { ...given, windowsHide: true };
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
var spawn2 = (...args) => cp.spawn(...withWindowsHidden(args, true));
|
|
22
|
+
var execFileSync2 = (...args) => cp.execFileSync(...withWindowsHidden(args, true));
|
|
23
|
+
var execFileAsync = (...args) => promisify(cp.execFile)(...withWindowsHidden(args, true));
|
|
24
|
+
var execAsync = (...args) => promisify(cp.exec)(...withWindowsHidden(args, false));
|
|
25
|
+
var execFile2 = (...args) => cp.execFile(...withWindowsHidden(args, true));
|
|
26
|
+
var exec2 = (...args) => cp.exec(...withWindowsHidden(args, false));
|
|
27
|
+
execFile2[promisify.custom] = execFileAsync;
|
|
28
|
+
exec2[promisify.custom] = execAsync;
|
|
29
|
+
|
|
6
30
|
// src/machine-toolkit/contract.ts
|
|
7
31
|
var CONTRACT_VERSION = 3;
|
|
8
32
|
var EXIT = {
|
|
@@ -248,7 +272,6 @@ import { join as join4 } from "node:path";
|
|
|
248
272
|
import { performance } from "node:perf_hooks";
|
|
249
273
|
|
|
250
274
|
// src/machine-toolkit/machine-home.mjs
|
|
251
|
-
import { execFileSync } from "node:child_process";
|
|
252
275
|
import { existsSync } from "node:fs";
|
|
253
276
|
import { homedir, release } from "node:os";
|
|
254
277
|
import { join as join3 } from "node:path";
|
|
@@ -257,8 +280,7 @@ function isWsl(kernelRelease = release(), platform = process.platform, hasDrvFs
|
|
|
257
280
|
}
|
|
258
281
|
var WSL_CALL_TIMEOUT_MS = 1e4;
|
|
259
282
|
function windowsHomeFromWsl() {
|
|
260
|
-
const raw =
|
|
261
|
-
windowsHide: true,
|
|
283
|
+
const raw = execFileSync2("cmd.exe", ["/c", "echo %USERPROFILE%"], {
|
|
262
284
|
encoding: "utf8",
|
|
263
285
|
stdio: ["ignore", "pipe", "ignore"],
|
|
264
286
|
timeout: WSL_CALL_TIMEOUT_MS
|
|
@@ -267,8 +289,7 @@ function windowsHomeFromWsl() {
|
|
|
267
289
|
throw new Error(
|
|
268
290
|
`could not resolve the Windows home from cmd.exe (it said '${raw}')`
|
|
269
291
|
);
|
|
270
|
-
const path =
|
|
271
|
-
windowsHide: true,
|
|
292
|
+
const path = execFileSync2("wslpath", ["-u", raw], {
|
|
272
293
|
encoding: "utf8",
|
|
273
294
|
stdio: ["ignore", "pipe", "ignore"],
|
|
274
295
|
timeout: WSL_CALL_TIMEOUT_MS
|
|
@@ -288,7 +309,6 @@ function machineHome() {
|
|
|
288
309
|
}
|
|
289
310
|
|
|
290
311
|
// src/machine-toolkit/processes.ts
|
|
291
|
-
import { execFile } from "node:child_process";
|
|
292
312
|
var ORPHAN_MIN_AGE_MS = 10 * 60 * 1e3;
|
|
293
313
|
var COMMAND_LINE_MAX_CHARS = 140;
|
|
294
314
|
var PROCESS_LISTING_TIMEOUT_MS = 2e4;
|
|
@@ -370,13 +390,12 @@ function parseWslListing(stdout, now) {
|
|
|
370
390
|
return rows;
|
|
371
391
|
}
|
|
372
392
|
var runCommand = (file, args, timeoutMs, signal) => new Promise((resolve, reject) => {
|
|
373
|
-
|
|
393
|
+
execFile2(
|
|
374
394
|
file,
|
|
375
395
|
args,
|
|
376
396
|
{
|
|
377
397
|
timeout: timeoutMs,
|
|
378
398
|
maxBuffer: LISTING_MAX_BUFFER_BYTES,
|
|
379
|
-
windowsHide: true,
|
|
380
399
|
signal
|
|
381
400
|
},
|
|
382
401
|
(err, stdout) => err ? reject(err) : resolve(stdout)
|
|
@@ -491,7 +510,6 @@ function probeProcessStart(opts) {
|
|
|
491
510
|
return new Promise((resolve, reject) => {
|
|
492
511
|
const startedAt = nowMs();
|
|
493
512
|
const child = opts.spawnFn(file, args, {
|
|
494
|
-
windowsHide: true,
|
|
495
513
|
stdio: "ignore",
|
|
496
514
|
signal: opts.signal
|
|
497
515
|
});
|
|
@@ -612,7 +630,7 @@ var readOwnManifest = () => JSON.parse(
|
|
|
612
630
|
readFileSync(new URL("../../package.json", import.meta.url), "utf8")
|
|
613
631
|
).version;
|
|
614
632
|
var TOOLKIT_VERSION = resolveToolkitVersion(
|
|
615
|
-
false ? void 0 : "0.1.
|
|
633
|
+
false ? void 0 : "0.1.576",
|
|
616
634
|
readOwnManifest
|
|
617
635
|
);
|
|
618
636
|
function envelope(now) {
|
|
@@ -751,7 +769,7 @@ function collectFromThisMachine() {
|
|
|
751
769
|
dataDisk: () => readDockerDataDisk(),
|
|
752
770
|
orphans: (now, signal) => reportOrphanProcesses(now, void 0, void 0, signal, "when-running"),
|
|
753
771
|
compactionWindowOpen: () => compactionWindowOpen(),
|
|
754
|
-
processStartMs: (signal) => probeProcessStart({ spawnFn:
|
|
772
|
+
processStartMs: (signal) => probeProcessStart({ spawnFn: spawn2, signal }),
|
|
755
773
|
kernelTokenCount: (signal) => readKernelTokenCount({ signal })
|
|
756
774
|
});
|
|
757
775
|
}
|
package/dist/mini-app-build.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* This module carries no validator for the document it produces: that the document is self-contained is checked by exactly ONE
|
|
11
11
|
* validator, the dashboard's own parse5 check on the revision route, whose 400 comes back to the caller verbatim.
|
|
12
12
|
*/
|
|
13
|
-
import { spawn } from "node:child_process";
|
|
14
13
|
import { randomBytes } from "node:crypto";
|
|
15
14
|
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
16
15
|
import os from "node:os";
|
|
17
16
|
import path from "node:path";
|
|
17
|
+
import { spawn } from "./hidden-process.mjs";
|
|
18
18
|
import { foldBuildOutput } from "./mini-app-output.js";
|
|
19
19
|
/** A build id unique per call, so two publishes never share a local page. */
|
|
20
20
|
export function newBuildId() {
|
|
@@ -42,7 +42,6 @@ async function killProcessTree(pid, child) {
|
|
|
42
42
|
if (process.platform === "win32") {
|
|
43
43
|
const status = await new Promise((resolve) => {
|
|
44
44
|
const killer = spawn("taskkill", ["/T", "/F", "/PID", String(pid)], {
|
|
45
|
-
windowsHide: true,
|
|
46
45
|
stdio: "ignore",
|
|
47
46
|
});
|
|
48
47
|
killer.once("error", () => resolve(null));
|
|
@@ -74,7 +73,6 @@ export async function runBuildCommand(input, timeoutMs = BUILD_TIMEOUT_MS, pipeG
|
|
|
74
73
|
cwd: input.repoRoot,
|
|
75
74
|
shell: false,
|
|
76
75
|
stdio: ["ignore", "pipe", "pipe"],
|
|
77
|
-
windowsHide: true,
|
|
78
76
|
detached: process.platform !== "win32",
|
|
79
77
|
});
|
|
80
78
|
let text = "";
|
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
* module only checks them against the filesystem and git, which are facts of a checkout, not a setting. It never reads `.danxbot/` or any
|
|
7
7
|
* `config.yml`.
|
|
8
8
|
*/
|
|
9
|
-
import { execFile } from "node:child_process";
|
|
10
9
|
import { readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
11
10
|
import path from "node:path";
|
|
12
|
-
import {
|
|
13
|
-
const execFileAsync = promisify(execFile);
|
|
11
|
+
import { execFileAsync } from "./hidden-process.mjs";
|
|
14
12
|
/** The two keys of the one canonical target shape (no version field, no repair of a row missing one). */
|
|
15
13
|
export const MINI_APP_TARGET_KEYS = ["name", "command"];
|
|
16
14
|
/**
|
|
@@ -72,7 +70,11 @@ export function relativePosix(base, p) {
|
|
|
72
70
|
/** Run `git -C <repoDir> <args>` (no shell); a non-zero exit is data (`ls-files --error-unmatch`, `diff --quiet` and `check-ignore -q` answer through it). */
|
|
73
71
|
async function git(repoDir, args) {
|
|
74
72
|
try {
|
|
75
|
-
const { stdout, stderr } = await execFileAsync("git", [
|
|
73
|
+
const { stdout, stderr } = await execFileAsync("git", [
|
|
74
|
+
"-C",
|
|
75
|
+
repoDir,
|
|
76
|
+
...args,
|
|
77
|
+
]);
|
|
76
78
|
return { code: 0, stdout, stderr };
|
|
77
79
|
}
|
|
78
80
|
catch (err) {
|
package/dist/version-floor.js
CHANGED
|
@@ -75,7 +75,7 @@ export const MCP_STREAM_MIN_VERSION_HEADER = "X-Danx-Stream-Min-Version";
|
|
|
75
75
|
export const MCP_PACKAGE_NAME = "@50arms/platform-mcp";
|
|
76
76
|
/**
|
|
77
77
|
* Numeric-dotted version compare (major.minor.patch, ...) — mirrors
|
|
78
|
-
* `compareMcpVersions` in danxbot's `src/mcp-
|
|
78
|
+
* `compareMcpVersions` in danxbot's `src/mcp-version-compare.ts` behavior
|
|
79
79
|
* byte-for-byte (duplicated, not imported — see module doc). Both sides of
|
|
80
80
|
* this contract have only ever used plain numeric dotted versions, so this
|
|
81
81
|
* throws rather than silently falling back to a lexical compare, which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@50arms/platform-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.576",
|
|
4
4
|
"description": "Stdio MCP server fronting the 50 Arms dashboard API for agents (operator sessions and dispatched workers alike): the generic 50arms_api/50arms_api_list/50arms_api_spec tools reach any route the caller's credential may call, plus dedicated agent-specific tools (session_connect, request_permission, attach_file, and 50arms_slack_reply) (DX-3465, PLN-11 R-25).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"prepublishOnly": "bash ../../scripts/assert-tree-contains-origin-main.sh @50arms/platform-mcp",
|
|
30
30
|
"generate": "tsx ../../scripts/ensure-platform-mcp-generated.ts ../..",
|
|
31
|
-
"build": "npm run generate && node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/index.js', 0o755)\" && node scripts/build-machine-daemon.mjs",
|
|
32
|
-
"prepack": "node scripts/build-machine-daemon.mjs",
|
|
31
|
+
"build": "npm run generate && node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node ../../src/util/hidden-process-copies.mjs dist && node -e \"require('fs').chmodSync('dist/index.js', 0o755)\" && node scripts/build-machine-daemon.mjs",
|
|
32
|
+
"prepack": "node ../../src/util/hidden-process-copies.mjs src && node scripts/build-machine-daemon.mjs",
|
|
33
33
|
"verify:boot": "bash scripts/verify-boot.sh",
|
|
34
34
|
"start": "node dist/index.js",
|
|
35
|
-
"dev": "tsx src/index.ts",
|
|
36
|
-
"gen-tool-defs": "tsx scripts/gen-tool-defs.ts",
|
|
35
|
+
"dev": "node ../../src/util/hidden-process-copies.mjs src && tsx src/index.ts",
|
|
36
|
+
"gen-tool-defs": "node ../../src/util/hidden-process-copies.mjs src && tsx scripts/gen-tool-defs.ts",
|
|
37
37
|
"pretest": "npm run generate",
|
|
38
38
|
"test": "vitest run",
|
|
39
39
|
"test:watch": "vitest"
|