@blackbelt-technology/pi-dashboard-apple-tools 0.8.0 → 0.10.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/.pi/skills/apple-tools/SKILL.md +8 -7
- package/README.md +16 -11
- package/package.json +11 -8
- package/src/bin/install.ts +4 -4
- package/src/client/AppleToolsSettings.tsx +403 -0
- package/src/client/index.tsx +7 -198
- package/src/env.ts +26 -76
- package/src/install.ts +38 -33
- package/src/server/index.ts +68 -109
- package/src/mcp-config.ts +0 -285
package/src/client/index.tsx
CHANGED
|
@@ -1,202 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* apple-tools · CLIENT entry.
|
|
2
|
+
* apple-tools · CLIENT entry (intentionally empty).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* [Run installer], a path override, directTools selection, and a server
|
|
9
|
-
* enable/disable toggle — but NO per-Apple-service toggles (TCC is menu-bar
|
|
10
|
-
* only, no API).
|
|
4
|
+
* The only claim — the `AppleToolsSettings` settings-section — loads lazily
|
|
5
|
+
* from `./AppleToolsSettings.tsx` via the manifest `module` field, keeping the
|
|
6
|
+
* settings UI out of the cold-landing chunk. Do NOT re-export it here: the
|
|
7
|
+
* registry generator rejects a main entry that also exports a lazy component.
|
|
11
8
|
*
|
|
12
|
-
* See change:
|
|
9
|
+
* See change: lazy-plugin-claim-modules.
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
import { useEffect, useState } from "react";
|
|
16
|
-
|
|
17
|
-
const PLUGIN_ID = "apple-tools";
|
|
18
|
-
const DEFAULT_PATH = "/Applications/iMCP.app/Contents/MacOS/imcp-server";
|
|
19
|
-
|
|
20
|
-
interface AppleToolsConfig {
|
|
21
|
-
imcpServerPath?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface StatusReadout {
|
|
25
|
-
platform: string;
|
|
26
|
-
state: string;
|
|
27
|
-
message: string;
|
|
28
|
-
resolvedPath?: string;
|
|
29
|
-
imcpServerPath: string;
|
|
30
|
-
/** Adapter-owned, read server-side from ~/.pi/agent/mcp.json. */
|
|
31
|
-
directTools: string[];
|
|
32
|
-
disabled: boolean;
|
|
33
|
-
/** False when iMCP.app is absent — provisioning must go through the CLI. */
|
|
34
|
-
appPresent: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function AppleToolsSettings() {
|
|
38
|
-
const config = usePluginConfig<AppleToolsConfig>();
|
|
39
|
-
const send = usePluginSend();
|
|
40
|
-
const [status, setStatus] = useState<StatusReadout | null>(null);
|
|
41
|
-
const [fetchError, setFetchError] = useState<string | null>(null);
|
|
42
|
-
const [pathDraft, setPathDraft] = useState(config?.imcpServerPath ?? DEFAULT_PATH);
|
|
43
|
-
const [directToolsDraft, setDirectToolsDraft] = useState("");
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
setPathDraft(config?.imcpServerPath ?? DEFAULT_PATH);
|
|
47
|
-
}, [config?.imcpServerPath]);
|
|
48
|
-
|
|
49
|
-
// directTools + disabled live in ~/.pi/agent/mcp.json (adapter-owned), so the
|
|
50
|
-
// server status readout — not our plugin config — is their source of truth.
|
|
51
|
-
// Key on the VALUE, not the status object identity: re-seeding on every poll
|
|
52
|
-
// would wipe an edit the operator is still typing.
|
|
53
|
-
const serverDirectTools = status?.directTools.join(", ") ?? null;
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (serverDirectTools !== null) setDirectToolsDraft(serverDirectTools);
|
|
56
|
-
}, [serverDirectTools]);
|
|
57
|
-
|
|
58
|
-
async function refresh(): Promise<void> {
|
|
59
|
-
try {
|
|
60
|
-
const res = await fetch(`/api/${PLUGIN_ID}/status`);
|
|
61
|
-
// A 404/500 body is not a StatusReadout — storing it would render garbage.
|
|
62
|
-
if (!res.ok) {
|
|
63
|
-
setFetchError(`status request failed (${res.status})`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
setStatus((await res.json()) as StatusReadout);
|
|
67
|
-
setFetchError(null);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
setFetchError(e instanceof Error ? e.message : String(e));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: mount-only refresh
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
void refresh();
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
const isMac = status ? status.platform === "darwin" : true;
|
|
79
|
-
const disabled = status?.disabled === true;
|
|
80
|
-
// #F11: disabled folds into the readout — never READY_PENDING_GRANTS + disabled simultaneously.
|
|
81
|
-
const displayState = disabled ? "DISABLED" : (status?.state ?? "…");
|
|
82
|
-
|
|
83
|
-
function saveConfig(partial: AppleToolsConfig): void {
|
|
84
|
-
void send({ type: "plugin_config_write", id: PLUGIN_ID, config: { ...config, ...partial } });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** Fire a plugin action, then re-read the status so the panel converges. */
|
|
88
|
-
function act(action: string, payload: Record<string, unknown> = {}): void {
|
|
89
|
-
void send({ type: "plugin_action", pluginId: PLUGIN_ID, action, payload });
|
|
90
|
-
setTimeout(() => void refresh(), 500);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<section
|
|
95
|
-
data-testid="apple-tools-settings"
|
|
96
|
-
style={{
|
|
97
|
-
padding: "12px",
|
|
98
|
-
border: "1px solid rgba(82, 82, 91, 0.5)",
|
|
99
|
-
borderRadius: "6px",
|
|
100
|
-
marginBottom: "12px",
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
<div style={{ display: "flex", justifyContent: "space-between", marginBottom: "8px" }}>
|
|
104
|
-
<h3 style={{ fontSize: "13px", fontWeight: 600, margin: 0 }}>Apple Tools (iMCP)</h3>
|
|
105
|
-
<span style={{ fontSize: "10px", color: "#71717a" }}>apple-tools</span>
|
|
106
|
-
</div>
|
|
107
|
-
|
|
108
|
-
<div
|
|
109
|
-
data-testid="apple-tools-status"
|
|
110
|
-
style={{ fontSize: "12px", marginBottom: "8px", fontFamily: "monospace" }}
|
|
111
|
-
>
|
|
112
|
-
{displayState}
|
|
113
|
-
</div>
|
|
114
|
-
{status?.message && (
|
|
115
|
-
<p style={{ fontSize: "11px", color: "#a1a1aa", margin: "0 0 10px 0" }}>{status.message}</p>
|
|
116
|
-
)}
|
|
117
|
-
{fetchError && (
|
|
118
|
-
<p
|
|
119
|
-
data-testid="apple-tools-error"
|
|
120
|
-
style={{ fontSize: "11px", color: "#f87171", margin: "0 0 10px 0" }}
|
|
121
|
-
>
|
|
122
|
-
Could not read provisioning status: {fetchError}
|
|
123
|
-
</p>
|
|
124
|
-
)}
|
|
125
|
-
|
|
126
|
-
{!isMac ? (
|
|
127
|
-
<p data-testid="apple-tools-unsupported" style={{ fontSize: "11px", color: "#fbbf24" }}>
|
|
128
|
-
iMCP is macOS-only. Nothing to provision on this platform.
|
|
129
|
-
</p>
|
|
130
|
-
) : (
|
|
131
|
-
<>
|
|
132
|
-
{status && !status.appPresent ? (
|
|
133
|
-
// The dashboard performs only the fast config-write half of
|
|
134
|
-
// provisioning; the long `brew install --cask` runs from the CLI so
|
|
135
|
-
// a click can never block the server. Tell the operator that here
|
|
136
|
-
// rather than offering a button that would refuse.
|
|
137
|
-
<p
|
|
138
|
-
data-testid="apple-tools-needs-cli"
|
|
139
|
-
style={{ fontSize: "11px", color: "#fbbf24", margin: "0 0 10px 0" }}
|
|
140
|
-
>
|
|
141
|
-
iMCP is not installed. Run <code>pi-apple-tools-install</code> in a terminal to
|
|
142
|
-
install it, then reload this panel.
|
|
143
|
-
</p>
|
|
144
|
-
) : (
|
|
145
|
-
<button
|
|
146
|
-
data-testid="apple-tools-run-installer"
|
|
147
|
-
onClick={() => act("run-installer")}
|
|
148
|
-
style={{ fontSize: "11px", padding: "3px 10px", marginBottom: "10px" }}
|
|
149
|
-
>
|
|
150
|
-
Run installer
|
|
151
|
-
</button>
|
|
152
|
-
)}
|
|
153
|
-
|
|
154
|
-
<label style={{ display: "block", fontSize: "11px", marginBottom: "6px" }}>
|
|
155
|
-
imcp-server path override
|
|
156
|
-
<input
|
|
157
|
-
data-testid="apple-tools-path"
|
|
158
|
-
value={pathDraft}
|
|
159
|
-
onChange={(e) => setPathDraft(e.target.value)}
|
|
160
|
-
onBlur={() => saveConfig({ imcpServerPath: pathDraft })}
|
|
161
|
-
style={{ display: "block", width: "100%", fontSize: "11px", fontFamily: "monospace" }}
|
|
162
|
-
/>
|
|
163
|
-
</label>
|
|
164
|
-
|
|
165
|
-
<label style={{ display: "block", fontSize: "11px", marginBottom: "6px" }}>
|
|
166
|
-
directTools (comma-separated)
|
|
167
|
-
<input
|
|
168
|
-
data-testid="apple-tools-direct-tools"
|
|
169
|
-
value={directToolsDraft}
|
|
170
|
-
onChange={(e) => setDirectToolsDraft(e.target.value)}
|
|
171
|
-
onBlur={() =>
|
|
172
|
-
act("set-direct-tools", {
|
|
173
|
-
tools: directToolsDraft
|
|
174
|
-
.split(",")
|
|
175
|
-
.map((s) => s.trim())
|
|
176
|
-
.filter(Boolean),
|
|
177
|
-
})
|
|
178
|
-
}
|
|
179
|
-
style={{ display: "block", width: "100%", fontSize: "11px" }}
|
|
180
|
-
/>
|
|
181
|
-
</label>
|
|
182
|
-
|
|
183
|
-
<label style={{ display: "flex", gap: "6px", alignItems: "center", fontSize: "11px" }}>
|
|
184
|
-
<input
|
|
185
|
-
data-testid="apple-tools-disabled"
|
|
186
|
-
type="checkbox"
|
|
187
|
-
checked={disabled}
|
|
188
|
-
onChange={(e) => act("set-disabled", { scope: "global", disabled: e.target.checked })}
|
|
189
|
-
/>
|
|
190
|
-
Disable the iMCP server globally (writes `disabled` to ~/.pi/agent/mcp.json; a project
|
|
191
|
-
can override this in its own .pi/mcp.json. Menu-bar grants are unaffected.)
|
|
192
|
-
</label>
|
|
193
|
-
|
|
194
|
-
<p style={{ fontSize: "10px", color: "#71717a", marginTop: "10px" }}>
|
|
195
|
-
Apple service permissions (Calendar, Contacts, …) are granted only in the iMCP menu-bar
|
|
196
|
-
app and cannot be automated. This panel does not toggle individual services.
|
|
197
|
-
</p>
|
|
198
|
-
</>
|
|
199
|
-
)}
|
|
200
|
-
</section>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
11
|
+
export {};
|
package/src/env.ts
CHANGED
|
@@ -3,30 +3,28 @@
|
|
|
3
3
|
* that touches the real OS — every probe and side effect is concentrated here
|
|
4
4
|
* so the state machine (`install.ts`) stays pure and Linux-testable.
|
|
5
5
|
*
|
|
6
|
+
* Config paths and the hardened atomic write live in the `mcp-client`
|
|
7
|
+
* plugin's `./core`: this factory only builds the `mcp-client.config` service
|
|
8
|
+
* with the real filesystem IO, so the target path is pi's built-in MCP file
|
|
9
|
+
* and honours `PI_CODING_AGENT_DIR` (a hard-coded `~/.pi/agent` would not).
|
|
10
|
+
* See change: migrate-mcp-to-pi-builtin (D4).
|
|
11
|
+
*
|
|
6
12
|
* Security discipline (see change: add-apple-tools-imcp-plugin, Decision 4):
|
|
7
13
|
* - `brew` is invoked with an argv array via execFileSync — never a shell,
|
|
8
14
|
* so no probed value (path, sw_vers output) can reach a shell string.
|
|
9
|
-
* - config writes are temp-file + atomic rename.
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
closeSync,
|
|
15
|
-
existsSync,
|
|
16
|
-
fsyncSync,
|
|
17
|
-
mkdirSync,
|
|
18
|
-
openSync,
|
|
19
|
-
readFileSync,
|
|
20
|
-
renameSync,
|
|
21
|
-
unlinkSync,
|
|
22
|
-
writeSync,
|
|
23
|
-
} from "node:fs";
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
24
18
|
import { homedir } from "node:os";
|
|
25
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
type ConfigIO,
|
|
21
|
+
createMcpClientConfigService,
|
|
22
|
+
createRealConfigIO,
|
|
23
|
+
type LayerPaths,
|
|
24
|
+
} from "@blackbelt-technology/pi-dashboard-mcp-client-plugin/core";
|
|
26
25
|
import { execFileSync } from "@blackbelt-technology/pi-dashboard-shared/platform/exec.js";
|
|
27
26
|
import { IMCP_BREW_CASK } from "./detect.js";
|
|
28
27
|
import type { BrewResult, InstallerEnv } from "./install.js";
|
|
29
|
-
import type { ConfigIO } from "./mcp-config.js";
|
|
30
28
|
|
|
31
29
|
/** 10-minute cap on the brew cask install (design X4). */
|
|
32
30
|
export const BREW_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -68,79 +66,31 @@ function runBrewCask(brew: string): BrewResult {
|
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
/**
|
|
72
|
-
* Atomic write: temp file in the target dir, fsync, then rename over the
|
|
73
|
-
* destination. Hardened per the security pass:
|
|
74
|
-
* - `wx` + a random name: never follow or clobber a pre-planted symlink.
|
|
75
|
-
* - mode 0600: a rename carries the temp file's mode onto the destination, so
|
|
76
|
-
* a default-umask temp would silently widen a 0600 user config that may hold
|
|
77
|
-
* another server's credential `env` block.
|
|
78
|
-
* - fsync before rename: a rename over unflushed data can surface as a
|
|
79
|
-
* zero-length config after a crash — the truncation this exists to prevent.
|
|
80
|
-
* - unlink the temp on failure: no leftovers on ENOSPC/EACCES.
|
|
81
|
-
*/
|
|
82
|
-
function writeFileAtomic(path: string, content: string): void {
|
|
83
|
-
const dir = dirname(path);
|
|
84
|
-
mkdirSync(dir, { recursive: true });
|
|
85
|
-
const tmp = join(dir, `.${randomBytes(8).toString("hex")}.tmp`);
|
|
86
|
-
const fd = openSync(tmp, "wx", 0o600);
|
|
87
|
-
try {
|
|
88
|
-
// writeSync may perform a partial write; loop until the buffer is drained
|
|
89
|
-
// rather than assuming one call consumes it all.
|
|
90
|
-
const buf = Buffer.from(content, "utf8");
|
|
91
|
-
let off = 0;
|
|
92
|
-
while (off < buf.length) {
|
|
93
|
-
off += writeSync(fd, buf, off, buf.length - off);
|
|
94
|
-
}
|
|
95
|
-
fsyncSync(fd);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
closeSync(fd);
|
|
98
|
-
try {
|
|
99
|
-
unlinkSync(tmp);
|
|
100
|
-
} catch {
|
|
101
|
-
/* best effort */
|
|
102
|
-
}
|
|
103
|
-
throw e;
|
|
104
|
-
}
|
|
105
|
-
closeSync(fd);
|
|
106
|
-
try {
|
|
107
|
-
renameSync(tmp, path);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
try {
|
|
110
|
-
unlinkSync(tmp);
|
|
111
|
-
} catch {
|
|
112
|
-
/* best effort */
|
|
113
|
-
}
|
|
114
|
-
throw e;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const realConfigIO: ConfigIO = {
|
|
119
|
-
readFile: (p) => (existsSync(p) ? readFileSync(p, "utf8") : null),
|
|
120
|
-
writeFileAtomic,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
69
|
export interface CreateEnvOptions {
|
|
124
70
|
/** Operator override for the imcp-server path. */
|
|
125
71
|
overridePath?: string;
|
|
126
|
-
/**
|
|
127
|
-
|
|
72
|
+
/** Test seam: inject config IO (defaults to the real filesystem). */
|
|
73
|
+
configIO?: ConfigIO;
|
|
74
|
+
/** Test seam: inject the layer paths (defaults to pi's built-in MCP paths). */
|
|
75
|
+
paths?: LayerPaths;
|
|
128
76
|
}
|
|
129
77
|
|
|
130
78
|
/** Build a real InstallerEnv wired to the current host. */
|
|
131
79
|
export function createInstallerEnv(opts: CreateEnvOptions = {}): InstallerEnv {
|
|
132
|
-
const home = homedir();
|
|
133
|
-
const agentHome = opts.piAgentHome ?? join(home, ".pi", "agent");
|
|
134
80
|
return {
|
|
135
81
|
platform: process.platform,
|
|
136
|
-
homedir:
|
|
82
|
+
homedir: homedir(),
|
|
137
83
|
probeOsVersion,
|
|
138
84
|
pathExists: existsSync,
|
|
139
85
|
brewPath,
|
|
140
86
|
runBrewCask,
|
|
141
87
|
...(opts.overridePath ? { overridePath: opts.overridePath } : {}),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
88
|
+
// Global scope only — the CLI never writes a project layer, so the
|
|
89
|
+
// known-cwd admission set is empty.
|
|
90
|
+
mcps: createMcpClientConfigService({
|
|
91
|
+
configIO: opts.configIO ?? createRealConfigIO(),
|
|
92
|
+
knownCwds: () => [],
|
|
93
|
+
...(opts.paths ? { paths: opts.paths } : {}),
|
|
94
|
+
}),
|
|
145
95
|
};
|
|
146
|
-
}
|
|
96
|
+
}
|
package/src/install.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* See change: add-apple-tools-imcp-plugin (Decision 2).
|
|
8
8
|
*/
|
|
9
|
+
import type {
|
|
10
|
+
ConfigRefusal,
|
|
11
|
+
McpClientConfigService,
|
|
12
|
+
} from "@blackbelt-technology/pi-dashboard-mcp-client-plugin/core";
|
|
9
13
|
import {
|
|
10
14
|
discoverServer,
|
|
11
15
|
IMCP_BREW_CASK,
|
|
@@ -14,13 +18,6 @@ import {
|
|
|
14
18
|
MIN_MACOS,
|
|
15
19
|
meetsMinimum,
|
|
16
20
|
} from "./detect.js";
|
|
17
|
-
import {
|
|
18
|
-
type ConfigIO,
|
|
19
|
-
type ConfigWriteResult,
|
|
20
|
-
ensureAdapterPackage,
|
|
21
|
-
ensureMcpEntry,
|
|
22
|
-
validateConfigShape,
|
|
23
|
-
} from "./mcp-config.js";
|
|
24
21
|
|
|
25
22
|
/** Closed, nine-member terminal-state enum. All three surfaces render these. */
|
|
26
23
|
export type TerminalState =
|
|
@@ -67,12 +64,12 @@ export interface InstallerEnv {
|
|
|
67
64
|
runBrewCask: (brew: string) => BrewResult;
|
|
68
65
|
/** Operator override for the imcp-server path (`imcpServerPath` config key). */
|
|
69
66
|
overridePath?: string;
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The `mcp-client.config` service. Owns every target path (honouring
|
|
69
|
+
* `PI_CODING_AGENT_DIR`) and the hardened atomic write, so this module needs
|
|
70
|
+
* no `ConfigIO` / hard-coded `~/.pi/agent` paths of its own.
|
|
71
|
+
*/
|
|
72
|
+
mcps: McpClientConfigService;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
export interface InstallResult {
|
|
@@ -186,18 +183,21 @@ export function runInstaller(env: InstallerEnv, opts: RunOptions = {}): InstallR
|
|
|
186
183
|
|
|
187
184
|
// 5. Config writes (suppressed in check mode).
|
|
188
185
|
if (!check) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
// Merge-only: `command` is refreshed; operator-set `enabled` / `exposure`
|
|
187
|
+
// / `toolExposure` survive. pi's built-in MCP needs no package entry, so
|
|
188
|
+
// `settings.json` is never touched (a `pi-mcp-adapter` package entry would
|
|
189
|
+
// DISABLE the built-in). See change: migrate-mcp-to-pi-builtin (D4).
|
|
190
|
+
const mcp = env.mcps.ensureServerEntry("iMCP", { command: resolved }, { kind: "global" });
|
|
191
|
+
if (!mcp.ok) return relayConfigFailure(mcp.refusal);
|
|
193
192
|
} else {
|
|
194
|
-
// Predict a config failure the write would hit (unparseable existing file
|
|
195
|
-
|
|
193
|
+
// Predict a config failure the write would hit (unparseable existing file
|
|
194
|
+
// or a malformed post-patch entry).
|
|
195
|
+
const predicted = predictConfigWritability(env, resolved);
|
|
196
196
|
if (predicted) return predicted;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
// 6. Terminal success. The installer never claims READY — only a live
|
|
200
|
-
// round-trip (a granted tool call) can distinguish READY from pending.
|
|
199
|
+
// 6. Terminal success. The installer never claims READY — only a live
|
|
200
|
+
// round-trip through pi's built-in MCP (a granted tool call) can distinguish READY from pending.
|
|
201
201
|
//
|
|
202
202
|
// In check mode with the app absent, `state` is a PREDICTION of what a
|
|
203
203
|
// write run would reach. Reporting it as "provisioned", or naming the
|
|
@@ -224,21 +224,26 @@ export function runInstaller(env: InstallerEnv, opts: RunOptions = {}): InstallR
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
function relayConfigFailure(r:
|
|
228
|
-
|
|
227
|
+
function relayConfigFailure(r: ConfigRefusal): InstallResult {
|
|
228
|
+
// The 9-member TerminalState enum is unchanged: a write IO fault is
|
|
229
|
+
// CONFIG_WRITE_FAILED, every structural refusal (unparseable, entry-not-object,
|
|
230
|
+
// invalid-name, transport-conflict) is CONFIG_UNPARSEABLE.
|
|
231
|
+
return fail(r.code === "write-failed" ? "CONFIG_WRITE_FAILED" : "CONFIG_UNPARSEABLE", r.message);
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
/**
|
|
232
|
-
* Check-mode dry predicate. Delegates to the
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* (EACCES/ENOSPC) remain unpredictable without attempting a write.
|
|
235
|
+
* Check-mode dry predicate. Delegates to the service's own check path so check
|
|
236
|
+
* and write agree: a config the write would refuse must never be reported as
|
|
237
|
+
* healthy by `--check`. Write-permission failures (EACCES/ENOSPC) remain
|
|
238
|
+
* unpredictable without attempting a write.
|
|
237
239
|
*/
|
|
238
|
-
function predictConfigWritability(env: InstallerEnv): InstallResult | null {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
function predictConfigWritability(env: InstallerEnv, resolvedPath: string): InstallResult | null {
|
|
241
|
+
const status = env.mcps.checkConfigFiles({
|
|
242
|
+
serverName: "iMCP",
|
|
243
|
+
fields: { command: resolvedPath },
|
|
244
|
+
});
|
|
245
|
+
if (!status.mcpJson.ok) {
|
|
246
|
+
return fail("CONFIG_UNPARSEABLE", status.mcpJson.message ?? "mcp.json would be refused");
|
|
247
|
+
}
|
|
243
248
|
return null;
|
|
244
249
|
}
|