@blackbelt-technology/pi-dashboard-apple-tools 0.9.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/package.json +8 -5
- package/src/client/AppleToolsSettings.tsx +403 -0
- package/src/client/index.tsx +7 -208
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-apple-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Provision and surface iMCP (Apple PIM: Calendar, Contacts, Reminders, Messages, Location, Maps, Weather) for pi. One-command installer, a dashboard provisioning panel, and an agent skill. macOS-only; no Apple Mail.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"claims": [
|
|
74
74
|
{
|
|
75
75
|
"slot": "settings-section",
|
|
76
|
-
"component": "AppleToolsSettings"
|
|
76
|
+
"component": "AppleToolsSettings",
|
|
77
|
+
"module": "./src/client/AppleToolsSettings.tsx"
|
|
77
78
|
}
|
|
78
79
|
]
|
|
79
80
|
},
|
|
@@ -82,9 +83,11 @@
|
|
|
82
83
|
"react-dom": ">=18.0.0"
|
|
83
84
|
},
|
|
84
85
|
"dependencies": {
|
|
85
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
86
|
-
"@blackbelt-technology/pi-dashboard-mcp-client-plugin": "^0.
|
|
87
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
86
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
|
|
87
|
+
"@blackbelt-technology/pi-dashboard-mcp-client-plugin": "^0.10.0",
|
|
88
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.10.0",
|
|
89
|
+
"@mdi/js": "^7.4.47",
|
|
90
|
+
"@mdi/react": "^1.6.1"
|
|
88
91
|
},
|
|
89
92
|
"devDependencies": {
|
|
90
93
|
"@types/react": "^19.0.0",
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apple-tools · CLIENT entry.
|
|
3
|
+
*
|
|
4
|
+
* A settings-section rendered on the plugin's own settings page (no `tab` field —
|
|
5
|
+
* per dashboard-plugin-loader spec it renders only under the owning plugin).
|
|
6
|
+
* A provisioning surface, NOT a service switchboard: it shows the shared
|
|
7
|
+
* checker's terminal state as a word pill (never the raw token) with a notice
|
|
8
|
+
* naming the fix, offers [Run installer] (busy + result notice) and a path
|
|
9
|
+
* override, and links to the mcp-client plugin for server enable/disable +
|
|
10
|
+
* exposure (which live there). No per-Apple-service toggles (TCC is menu-bar
|
|
11
|
+
* only, no API). The host owns identity: no heading or id in the body.
|
|
12
|
+
*
|
|
13
|
+
* The path override is a draft on the host Save bar (`plugin:apple-tools`); the
|
|
14
|
+
* commit sends ONLY `imcpServerPath` (the server merges), so a path the
|
|
15
|
+
* installer reconciles meanwhile is never overwritten by a stale snapshot.
|
|
16
|
+
*
|
|
17
|
+
* A missing `dependsOn: ["mcp-client"]` requirement renders a banner that hides
|
|
18
|
+
* [Run installer] — provisioning would refuse without the service.
|
|
19
|
+
*
|
|
20
|
+
* See changes: add-apple-tools-imcp-plugin (Decision 5), extract-mcp-client-plugin,
|
|
21
|
+
* retro-ux-plugin-settings-wave-2.
|
|
22
|
+
*/
|
|
23
|
+
import {
|
|
24
|
+
SettingsCopyButton,
|
|
25
|
+
SettingsItem,
|
|
26
|
+
SettingsNotice,
|
|
27
|
+
SettingsStatusPill,
|
|
28
|
+
type SettingsStatusTone,
|
|
29
|
+
TextField,
|
|
30
|
+
useSettingsDraftSource,
|
|
31
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
32
|
+
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
33
|
+
import { mdiOpenInNew, mdiRefresh } from "@mdi/js";
|
|
34
|
+
import { Icon } from "@mdi/react";
|
|
35
|
+
import { type ReactNode, useCallback, useEffect, useRef, useState } from "react";
|
|
36
|
+
|
|
37
|
+
const PLUGIN_ID = "apple-tools";
|
|
38
|
+
const DEFAULT_PATH = "/Applications/iMCP.app/Contents/MacOS/imcp-server";
|
|
39
|
+
const INSTALL_COMMAND = "pi-apple-tools-install";
|
|
40
|
+
/** The generic MCP server manager — where enable/disable + exposure live. */
|
|
41
|
+
const MANAGE_MCP_PATH = "/settings/plugins/mcp-client";
|
|
42
|
+
/** Plugins index — the missing-dependency banner's Enable affordance. */
|
|
43
|
+
const PLUGINS_INDEX_PATH = "/settings/plugins";
|
|
44
|
+
|
|
45
|
+
const BTN_BASE =
|
|
46
|
+
"focus-ring inline-flex min-h-[32px] items-center gap-1 rounded-md px-2 text-[12px] font-semibold disabled:cursor-not-allowed disabled:opacity-60";
|
|
47
|
+
const BTN_PRIMARY = `${BTN_BASE} bg-[var(--accent-solid)] text-white hover:opacity-90`;
|
|
48
|
+
const BTN_SECONDARY = `${BTN_BASE} border border-[var(--border-secondary)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)]`;
|
|
49
|
+
const BTN_GHOST = `${BTN_BASE} text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]`;
|
|
50
|
+
|
|
51
|
+
interface AppleToolsConfig {
|
|
52
|
+
imcpServerPath?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface StatusReadout {
|
|
56
|
+
platform: string;
|
|
57
|
+
state: string;
|
|
58
|
+
message: string;
|
|
59
|
+
resolvedPath?: string;
|
|
60
|
+
imcpServerPath: string;
|
|
61
|
+
/** False when iMCP.app is absent — provisioning must go through the CLI. */
|
|
62
|
+
appPresent: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface InstallResult {
|
|
66
|
+
tone: "success" | "info" | "warning";
|
|
67
|
+
text: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface PillSpec {
|
|
71
|
+
tone: SettingsStatusTone;
|
|
72
|
+
word: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Provisioning state → pill word. "Checking" and "Not installed" are UI-only
|
|
77
|
+
* labels: a failure member always wins over `appPresent`.
|
|
78
|
+
*/
|
|
79
|
+
function pillFor(status: StatusReadout | null): PillSpec {
|
|
80
|
+
if (!status) return { tone: "info", word: "Checking" };
|
|
81
|
+
if (status.platform !== "darwin") return { tone: "neutral", word: "Unsupported platform" };
|
|
82
|
+
switch (status.state) {
|
|
83
|
+
case "READY_PENDING_GRANTS":
|
|
84
|
+
case "READY":
|
|
85
|
+
return status.appPresent ? { tone: "success", word: "Installed" } : { tone: "neutral", word: "Not installed" };
|
|
86
|
+
case "OS_TOO_OLD":
|
|
87
|
+
return { tone: "warning", word: "macOS too old" };
|
|
88
|
+
case "OS_VERSION_UNKNOWN":
|
|
89
|
+
return { tone: "warning", word: "macOS version unknown" };
|
|
90
|
+
case "UNSUPPORTED_PLATFORM":
|
|
91
|
+
return { tone: "neutral", word: "Unsupported platform" };
|
|
92
|
+
case "NO_INSTALL_METHOD":
|
|
93
|
+
return { tone: "warning", word: "Can't install automatically" };
|
|
94
|
+
case "INSTALL_FAILED":
|
|
95
|
+
return { tone: "error", word: "Install failed" };
|
|
96
|
+
case "CONFIG_UNPARSEABLE":
|
|
97
|
+
return { tone: "error", word: "Config unreadable" };
|
|
98
|
+
case "CONFIG_WRITE_FAILED":
|
|
99
|
+
return { tone: "error", word: "Config not saved" };
|
|
100
|
+
default:
|
|
101
|
+
return { tone: "neutral", word: "Status unknown" };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** "macOS 14.6.1 is below the minimum supported 15.3." → { running, minimum }. */
|
|
106
|
+
function parseOsVersions(message: string): { running?: string; minimum?: string } {
|
|
107
|
+
const m = /macOS\s+(\S+)\s+is below the minimum supported\s+(\d+(?:\.\d+)*)/.exec(message);
|
|
108
|
+
return m ? { running: m[1], minimum: m[2] } : {};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This plugin's own loader row `missingDeps` (a `dependsOn` gap). Fetched from
|
|
113
|
+
* `GET /api/plugins` because the server's row is the single source of truth for
|
|
114
|
+
* the dependency graph. A fetch failure leaves the list empty rather than
|
|
115
|
+
* blocking the panel.
|
|
116
|
+
*/
|
|
117
|
+
function useMissingDeps(): string[] {
|
|
118
|
+
const [missing, setMissing] = useState<string[]>([]);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
let alive = true;
|
|
121
|
+
void (async () => {
|
|
122
|
+
try {
|
|
123
|
+
const res = await fetch("/api/plugins");
|
|
124
|
+
if (!res.ok) return;
|
|
125
|
+
const body = (await res.json()) as {
|
|
126
|
+
plugins?: Array<{ id?: string; status?: { missingDeps?: string[] } | null }>;
|
|
127
|
+
};
|
|
128
|
+
const row = (body.plugins ?? []).find((p) => p.id === PLUGIN_ID);
|
|
129
|
+
if (alive) setMissing(row?.status?.missingDeps ?? []);
|
|
130
|
+
} catch {
|
|
131
|
+
/* leave empty */
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
return () => {
|
|
135
|
+
alive = false;
|
|
136
|
+
};
|
|
137
|
+
}, []);
|
|
138
|
+
return missing;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function AppleToolsSettings() {
|
|
142
|
+
const config = usePluginConfig<AppleToolsConfig>();
|
|
143
|
+
const send = usePluginSend();
|
|
144
|
+
const [status, setStatus] = useState<StatusReadout | null>(null);
|
|
145
|
+
const [fetchError, setFetchError] = useState<string | null>(null);
|
|
146
|
+
const [checking, setChecking] = useState(false);
|
|
147
|
+
const [busy, setBusy] = useState(false);
|
|
148
|
+
const [result, setResult] = useState<InstallResult | null>(null);
|
|
149
|
+
const missingDeps = useMissingDeps();
|
|
150
|
+
|
|
151
|
+
// Path draft: `null` = untouched (follows the stored value / broadcasts).
|
|
152
|
+
const stored = config?.imcpServerPath ?? DEFAULT_PATH;
|
|
153
|
+
const [pathEdit, setPathEdit] = useState<string | null>(null);
|
|
154
|
+
// A broadcast that now equals the edit settles it, so a stale edit never shadows a later one.
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
setPathEdit((prev) => (prev !== null && prev.trim() === stored ? null : prev));
|
|
157
|
+
}, [stored]);
|
|
158
|
+
const path = pathEdit ?? stored;
|
|
159
|
+
const pathError = path.trim() === "" ? "Enter the path to imcp-server, or reset to the default." : null;
|
|
160
|
+
const isDirty = pathEdit !== null && pathEdit.trim() !== stored;
|
|
161
|
+
|
|
162
|
+
const latest = useRef({ pathEdit, pathError, stored });
|
|
163
|
+
latest.current = { pathEdit, pathError, stored };
|
|
164
|
+
const commit = useCallback(async () => {
|
|
165
|
+
const { pathEdit: edit, pathError: err, stored: current } = latest.current;
|
|
166
|
+
if (err) throw new Error(err);
|
|
167
|
+
if (edit === null || edit.trim() === current) return;
|
|
168
|
+
await send({ type: "plugin_config_write", id: PLUGIN_ID, config: { imcpServerPath: edit.trim() } });
|
|
169
|
+
}, [send]);
|
|
170
|
+
const reset = useCallback(() => setPathEdit(null), []);
|
|
171
|
+
// Typing back the stored path drops the edit (no ghost draft that a later
|
|
172
|
+
// broadcast — e.g. the installer reconciling the path — would turn into an
|
|
173
|
+
// edit that reverts it). doubt-review 4.50 #1.
|
|
174
|
+
const editPath = (v: string) => setPathEdit(v === stored ? null : v);
|
|
175
|
+
useSettingsDraftSource({ id: "plugin:apple-tools", isDirty, commit, reset });
|
|
176
|
+
|
|
177
|
+
const refresh = useCallback(async (): Promise<StatusReadout | null> => {
|
|
178
|
+
try {
|
|
179
|
+
const res = await fetch(`/api/${PLUGIN_ID}/status`);
|
|
180
|
+
// A 404/500 body is not a StatusReadout — storing it would render garbage.
|
|
181
|
+
if (!res.ok) {
|
|
182
|
+
setFetchError(`status request failed (${res.status})`);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const next = (await res.json()) as StatusReadout;
|
|
186
|
+
setStatus(next);
|
|
187
|
+
setFetchError(null);
|
|
188
|
+
return next;
|
|
189
|
+
} catch (e) {
|
|
190
|
+
setFetchError(e instanceof Error ? e.message : String(e));
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
void refresh();
|
|
197
|
+
}, [refresh]);
|
|
198
|
+
|
|
199
|
+
async function checkAgain(): Promise<void> {
|
|
200
|
+
setChecking(true);
|
|
201
|
+
setResult(null);
|
|
202
|
+
await refresh();
|
|
203
|
+
setChecking(false);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Fire the installer action, then re-read the status so the panel converges. */
|
|
207
|
+
async function runInstaller(): Promise<void> {
|
|
208
|
+
setBusy(true);
|
|
209
|
+
setResult(null);
|
|
210
|
+
try {
|
|
211
|
+
await send({ type: "plugin_action", pluginId: PLUGIN_ID, action: "run-installer", payload: {} });
|
|
212
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
213
|
+
const next = await refresh();
|
|
214
|
+
const word = pillFor(next).word;
|
|
215
|
+
setResult(
|
|
216
|
+
next
|
|
217
|
+
? { tone: pillFor(next).tone === "success" ? "success" : "info", text: `Installer finished. iMCP now shows: ${word}.` }
|
|
218
|
+
: { tone: "warning", text: "Installer ran, but iMCP could not be checked afterwards. Try Check again." },
|
|
219
|
+
);
|
|
220
|
+
} finally {
|
|
221
|
+
setBusy(false);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const isMac = status ? status.platform === "darwin" : true;
|
|
226
|
+
const pill = pillFor(fetchError && !status ? null : status);
|
|
227
|
+
const showPill = !(fetchError && !status);
|
|
228
|
+
const notInstalled = pill.word === "Not installed";
|
|
229
|
+
const installed = pill.word === "Installed";
|
|
230
|
+
const noMissing = missingDeps.length === 0;
|
|
231
|
+
|
|
232
|
+
const checkAgainButton = (
|
|
233
|
+
<button type="button" className={BTN_GHOST} disabled={checking} onClick={() => void checkAgain()}>
|
|
234
|
+
<Icon path={mdiRefresh} size={0.55} aria-hidden="true" />
|
|
235
|
+
Check again
|
|
236
|
+
</button>
|
|
237
|
+
);
|
|
238
|
+
const installAction = (
|
|
239
|
+
<SettingsCopyButton text={INSTALL_COMMAND} label="Copy command" />
|
|
240
|
+
);
|
|
241
|
+
const details = status ? `${status.state}: ${status.message}` : null;
|
|
242
|
+
const os = status ? parseOsVersions(status.message) : {};
|
|
243
|
+
|
|
244
|
+
/** Notice for every state except Installed and Checking (those have their own copy). */
|
|
245
|
+
function stateNotice(): ReactNode {
|
|
246
|
+
if (!status || !isMac) return null;
|
|
247
|
+
switch (pill.word) {
|
|
248
|
+
case "Not installed":
|
|
249
|
+
return noMissing ? (
|
|
250
|
+
<SettingsNotice tone="info" testId="apple-tools-needs-cli" actions={<>{installAction}{checkAgainButton}</>}>
|
|
251
|
+
Install iMCP from a terminal on this Mac, then check again: <code className="font-mono text-[12px]">{INSTALL_COMMAND}</code>
|
|
252
|
+
</SettingsNotice>
|
|
253
|
+
) : null;
|
|
254
|
+
case "Installed":
|
|
255
|
+
return (
|
|
256
|
+
<SettingsNotice tone="info" testId="apple-tools-notice">
|
|
257
|
+
Grant Calendar, Contacts and other access in the iMCP menu-bar app. This page cannot do it for you.
|
|
258
|
+
</SettingsNotice>
|
|
259
|
+
);
|
|
260
|
+
case "macOS too old":
|
|
261
|
+
return (
|
|
262
|
+
<SettingsNotice tone="warning" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
263
|
+
{`iMCP needs macOS ${os.minimum ?? "a newer version"}${os.minimum ? " or later" : ""}. ${
|
|
264
|
+
os.running ? `This Mac runs ${os.running}. ` : ""
|
|
265
|
+
}Update macOS, then come back to install iMCP.`}
|
|
266
|
+
</SettingsNotice>
|
|
267
|
+
);
|
|
268
|
+
case "macOS version unknown":
|
|
269
|
+
return (
|
|
270
|
+
<SettingsNotice tone="warning" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
271
|
+
This Mac's macOS version could not be read. Check it under About This Mac, then check again.
|
|
272
|
+
</SettingsNotice>
|
|
273
|
+
);
|
|
274
|
+
case "Can't install automatically":
|
|
275
|
+
return (
|
|
276
|
+
<SettingsNotice tone="warning" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
277
|
+
Homebrew isn't available, so iMCP can't be installed for you. Install Homebrew or iMCP yourself, then check again.
|
|
278
|
+
</SettingsNotice>
|
|
279
|
+
);
|
|
280
|
+
case "Install failed":
|
|
281
|
+
return (
|
|
282
|
+
<SettingsNotice tone="error" testId="apple-tools-notice" details={details} actions={<>{installAction}{checkAgainButton}</>}>
|
|
283
|
+
The iMCP install did not finish. Run <code className="font-mono text-[12px]">{INSTALL_COMMAND}</code> in a terminal to see why, then check again.
|
|
284
|
+
</SettingsNotice>
|
|
285
|
+
);
|
|
286
|
+
case "Config unreadable":
|
|
287
|
+
return (
|
|
288
|
+
<SettingsNotice tone="error" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
289
|
+
The MCP config file could not be read. Fix its JSON syntax, then check again.
|
|
290
|
+
</SettingsNotice>
|
|
291
|
+
);
|
|
292
|
+
case "Config not saved":
|
|
293
|
+
return (
|
|
294
|
+
<SettingsNotice tone="error" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
295
|
+
The MCP config could not be saved. Make sure the file is writable, then check again.
|
|
296
|
+
</SettingsNotice>
|
|
297
|
+
);
|
|
298
|
+
default:
|
|
299
|
+
return (
|
|
300
|
+
<SettingsNotice tone="warning" testId="apple-tools-notice" details={details} actions={checkAgainButton}>
|
|
301
|
+
iMCP reported a state this page does not know. Check again, or run the installer in a terminal.
|
|
302
|
+
</SettingsNotice>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
<div data-testid="apple-tools-settings" className="space-y-3">
|
|
309
|
+
{missingDeps.length > 0 && (
|
|
310
|
+
<SettingsNotice tone="warning" testId="apple-tools-missing-deps">
|
|
311
|
+
Provisioning needs <code className="font-mono text-[12px]">{missingDeps.join(", ")}</code>.{" "}
|
|
312
|
+
<a className="font-semibold text-[var(--link)] underline" href={PLUGINS_INDEX_PATH}>
|
|
313
|
+
Enable it in Plugins
|
|
314
|
+
</a>{" "}
|
|
315
|
+
first.
|
|
316
|
+
</SettingsNotice>
|
|
317
|
+
)}
|
|
318
|
+
|
|
319
|
+
{fetchError && (
|
|
320
|
+
<SettingsNotice
|
|
321
|
+
tone="error"
|
|
322
|
+
testId="apple-tools-error"
|
|
323
|
+
onRetry={() => void checkAgain()}
|
|
324
|
+
retrying={checking}
|
|
325
|
+
details={fetchError}
|
|
326
|
+
>
|
|
327
|
+
Could not check iMCP on this Mac. The dashboard server did not answer.
|
|
328
|
+
</SettingsNotice>
|
|
329
|
+
)}
|
|
330
|
+
|
|
331
|
+
{showPill && (
|
|
332
|
+
<SettingsItem
|
|
333
|
+
title="iMCP"
|
|
334
|
+
subtitle="Apple Calendar, Contacts, Reminders and Messages as MCP tools"
|
|
335
|
+
status={
|
|
336
|
+
<SettingsStatusPill tone={pill.tone} testId="apple-tools-status" status={status?.state}>
|
|
337
|
+
{pill.word}
|
|
338
|
+
</SettingsStatusPill>
|
|
339
|
+
}
|
|
340
|
+
actions={
|
|
341
|
+
isMac && noMissing && status?.appPresent && !notInstalled ? (
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
data-testid="apple-tools-run-installer"
|
|
345
|
+
className={installed ? BTN_SECONDARY : BTN_PRIMARY}
|
|
346
|
+
disabled={busy}
|
|
347
|
+
aria-busy={busy || undefined}
|
|
348
|
+
onClick={() => void runInstaller()}
|
|
349
|
+
>
|
|
350
|
+
{busy ? "Running installer…" : installed ? "Reinstall" : "Run installer"}
|
|
351
|
+
</button>
|
|
352
|
+
) : null
|
|
353
|
+
}
|
|
354
|
+
/>
|
|
355
|
+
)}
|
|
356
|
+
|
|
357
|
+
{!isMac && (
|
|
358
|
+
<SettingsNotice tone="info" testId="apple-tools-unsupported">
|
|
359
|
+
iMCP only runs on macOS, so there is nothing to set up on this computer.
|
|
360
|
+
</SettingsNotice>
|
|
361
|
+
)}
|
|
362
|
+
|
|
363
|
+
{stateNotice()}
|
|
364
|
+
|
|
365
|
+
{result && (
|
|
366
|
+
<SettingsNotice tone={result.tone} role="status" testId="apple-tools-install-result">
|
|
367
|
+
{result.text}
|
|
368
|
+
</SettingsNotice>
|
|
369
|
+
)}
|
|
370
|
+
|
|
371
|
+
{isMac && (
|
|
372
|
+
<>
|
|
373
|
+
<TextField
|
|
374
|
+
label="iMCP server path"
|
|
375
|
+
hint="Change this only if iMCP is installed somewhere other than Applications."
|
|
376
|
+
mono
|
|
377
|
+
value={path}
|
|
378
|
+
onChange={editPath}
|
|
379
|
+
error={pathError}
|
|
380
|
+
state={path === DEFAULT_PATH ? "default" : "changed"}
|
|
381
|
+
onReset={path === DEFAULT_PATH ? undefined : () => editPath(DEFAULT_PATH)}
|
|
382
|
+
testIds={{ control: "apple-tools-path" }}
|
|
383
|
+
/>
|
|
384
|
+
|
|
385
|
+
<SettingsItem
|
|
386
|
+
title="Tools in sessions"
|
|
387
|
+
subtitle="Turn iMCP on or off and choose which tools sessions get in MCP Client."
|
|
388
|
+
actions={
|
|
389
|
+
<a data-testid="apple-tools-manage-mcp" href={MANAGE_MCP_PATH} className={BTN_SECONDARY}>
|
|
390
|
+
Manage MCP servers
|
|
391
|
+
<Icon path={mdiOpenInNew} size={0.55} aria-hidden="true" />
|
|
392
|
+
</a>
|
|
393
|
+
}
|
|
394
|
+
/>
|
|
395
|
+
|
|
396
|
+
<SettingsNotice tone="info" testId="apple-tools-permissions">
|
|
397
|
+
Calendar, Contacts and other Apple permissions are granted in the iMCP menu-bar app. This page cannot change them.
|
|
398
|
+
</SettingsNotice>
|
|
399
|
+
</>
|
|
400
|
+
)}
|
|
401
|
+
</div>
|
|
402
|
+
);
|
|
403
|
+
}
|
package/src/client/index.tsx
CHANGED
|
@@ -1,212 +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] and a path override, and links to the mcp-client plugin for
|
|
9
|
-
* server enable/disable + exposure (which live there). No per-Apple-service
|
|
10
|
-
* toggles (TCC is menu-bar 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
|
-
*
|
|
13
|
-
* [Run installer] — provisioning would refuse without the service.
|
|
14
|
-
*
|
|
15
|
-
* See changes: add-apple-tools-imcp-plugin (Decision 5), extract-mcp-client-plugin.
|
|
16
|
-
*/
|
|
17
|
-
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
18
|
-
import { useEffect, useState } from "react";
|
|
19
|
-
|
|
20
|
-
const PLUGIN_ID = "apple-tools";
|
|
21
|
-
const DEFAULT_PATH = "/Applications/iMCP.app/Contents/MacOS/imcp-server";
|
|
22
|
-
/** The generic MCP server manager — where enable/disable + exposure live. */
|
|
23
|
-
const MANAGE_MCP_PATH = "/settings/plugins/mcp-client";
|
|
24
|
-
/** Plugins index — the missing-dependency banner's Enable affordance. */
|
|
25
|
-
const PLUGINS_INDEX_PATH = "/settings/plugins";
|
|
26
|
-
|
|
27
|
-
interface AppleToolsConfig {
|
|
28
|
-
imcpServerPath?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface StatusReadout {
|
|
32
|
-
platform: string;
|
|
33
|
-
state: string;
|
|
34
|
-
message: string;
|
|
35
|
-
resolvedPath?: string;
|
|
36
|
-
imcpServerPath: string;
|
|
37
|
-
/** False when iMCP.app is absent — provisioning must go through the CLI. */
|
|
38
|
-
appPresent: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* This plugin's own loader row `missingDeps` (a `dependsOn` gap). Fetched from
|
|
43
|
-
* `GET /api/plugins` because the server's row is the single source of truth for
|
|
44
|
-
* the dependency graph. A fetch failure leaves the list empty rather than
|
|
45
|
-
* blocking the panel.
|
|
9
|
+
* See change: lazy-plugin-claim-modules.
|
|
46
10
|
*/
|
|
47
|
-
|
|
48
|
-
const [missing, setMissing] = useState<string[]>([]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
let alive = true;
|
|
51
|
-
void (async () => {
|
|
52
|
-
try {
|
|
53
|
-
const res = await fetch("/api/plugins");
|
|
54
|
-
if (!res.ok) return;
|
|
55
|
-
const body = (await res.json()) as {
|
|
56
|
-
plugins?: Array<{ id?: string; status?: { missingDeps?: string[] } | null }>;
|
|
57
|
-
};
|
|
58
|
-
const row = (body.plugins ?? []).find((p) => p.id === PLUGIN_ID);
|
|
59
|
-
if (alive) setMissing(row?.status?.missingDeps ?? []);
|
|
60
|
-
} catch {
|
|
61
|
-
/* leave empty */
|
|
62
|
-
}
|
|
63
|
-
})();
|
|
64
|
-
return () => {
|
|
65
|
-
alive = false;
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
return missing;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function AppleToolsSettings() {
|
|
72
|
-
const config = usePluginConfig<AppleToolsConfig>();
|
|
73
|
-
const send = usePluginSend();
|
|
74
|
-
const [status, setStatus] = useState<StatusReadout | null>(null);
|
|
75
|
-
const [fetchError, setFetchError] = useState<string | null>(null);
|
|
76
|
-
const [pathDraft, setPathDraft] = useState(config?.imcpServerPath ?? DEFAULT_PATH);
|
|
77
|
-
const missingDeps = useMissingDeps();
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
setPathDraft(config?.imcpServerPath ?? DEFAULT_PATH);
|
|
81
|
-
}, [config?.imcpServerPath]);
|
|
82
|
-
|
|
83
|
-
async function refresh(): Promise<void> {
|
|
84
|
-
try {
|
|
85
|
-
const res = await fetch(`/api/${PLUGIN_ID}/status`);
|
|
86
|
-
// A 404/500 body is not a StatusReadout — storing it would render garbage.
|
|
87
|
-
if (!res.ok) {
|
|
88
|
-
setFetchError(`status request failed (${res.status})`);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
setStatus((await res.json()) as StatusReadout);
|
|
92
|
-
setFetchError(null);
|
|
93
|
-
} catch (e) {
|
|
94
|
-
setFetchError(e instanceof Error ? e.message : String(e));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: mount-only refresh
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
void refresh();
|
|
101
|
-
}, []);
|
|
102
|
-
|
|
103
|
-
const isMac = status ? status.platform === "darwin" : true;
|
|
104
|
-
|
|
105
|
-
function saveConfig(partial: AppleToolsConfig): void {
|
|
106
|
-
void send({ type: "plugin_config_write", id: PLUGIN_ID, config: { ...config, ...partial } });
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Fire a plugin action, then re-read the status so the panel converges. */
|
|
110
|
-
function act(action: string, payload: Record<string, unknown> = {}): void {
|
|
111
|
-
void send({ type: "plugin_action", pluginId: PLUGIN_ID, action, payload });
|
|
112
|
-
setTimeout(() => void refresh(), 500);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<section
|
|
117
|
-
data-testid="apple-tools-settings"
|
|
118
|
-
style={{
|
|
119
|
-
padding: "12px",
|
|
120
|
-
border: "1px solid rgba(82, 82, 91, 0.5)",
|
|
121
|
-
borderRadius: "6px",
|
|
122
|
-
marginBottom: "12px",
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
<div style={{ display: "flex", justifyContent: "space-between", marginBottom: "8px" }}>
|
|
126
|
-
<h3 style={{ fontSize: "13px", fontWeight: 600, margin: 0 }}>Apple Tools (iMCP)</h3>
|
|
127
|
-
<span style={{ fontSize: "10px", color: "#71717a" }}>apple-tools</span>
|
|
128
|
-
</div>
|
|
129
|
-
|
|
130
|
-
{missingDeps.length > 0 && (
|
|
131
|
-
<p
|
|
132
|
-
data-testid="apple-tools-missing-deps"
|
|
133
|
-
style={{ fontSize: "11px", color: "#fbbf24", margin: "0 0 10px 0" }}
|
|
134
|
-
>
|
|
135
|
-
Missing dependency: <code>{missingDeps.join(", ")}</code>. Provisioning needs it.{" "}
|
|
136
|
-
<a href={PLUGINS_INDEX_PATH}>Enable it in Plugins</a> first.
|
|
137
|
-
</p>
|
|
138
|
-
)}
|
|
139
|
-
|
|
140
|
-
<div
|
|
141
|
-
data-testid="apple-tools-status"
|
|
142
|
-
style={{ fontSize: "12px", marginBottom: "8px", fontFamily: "monospace" }}
|
|
143
|
-
>
|
|
144
|
-
{status?.state ?? "…"}
|
|
145
|
-
</div>
|
|
146
|
-
{status?.message && (
|
|
147
|
-
<p style={{ fontSize: "11px", color: "#a1a1aa", margin: "0 0 10px 0" }}>{status.message}</p>
|
|
148
|
-
)}
|
|
149
|
-
{fetchError && (
|
|
150
|
-
<p
|
|
151
|
-
data-testid="apple-tools-error"
|
|
152
|
-
style={{ fontSize: "11px", color: "#f87171", margin: "0 0 10px 0" }}
|
|
153
|
-
>
|
|
154
|
-
Could not read provisioning status: {fetchError}
|
|
155
|
-
</p>
|
|
156
|
-
)}
|
|
157
|
-
|
|
158
|
-
{!isMac ? (
|
|
159
|
-
<p data-testid="apple-tools-unsupported" style={{ fontSize: "11px", color: "#fbbf24" }}>
|
|
160
|
-
iMCP is macOS-only. Nothing to provision on this platform.
|
|
161
|
-
</p>
|
|
162
|
-
) : (
|
|
163
|
-
<>
|
|
164
|
-
{missingDeps.length > 0 ? null : status && !status.appPresent ? (
|
|
165
|
-
// The dashboard performs only the fast config-write half of
|
|
166
|
-
// provisioning; the long `brew install --cask` runs from the CLI so
|
|
167
|
-
// a click can never block the server. Tell the operator that here
|
|
168
|
-
// rather than offering a button that would refuse.
|
|
169
|
-
<p
|
|
170
|
-
data-testid="apple-tools-needs-cli"
|
|
171
|
-
style={{ fontSize: "11px", color: "#fbbf24", margin: "0 0 10px 0" }}
|
|
172
|
-
>
|
|
173
|
-
iMCP is not installed. Run <code>pi-apple-tools-install</code> in a terminal to
|
|
174
|
-
install it, then reload this panel.
|
|
175
|
-
</p>
|
|
176
|
-
) : (
|
|
177
|
-
<button
|
|
178
|
-
data-testid="apple-tools-run-installer"
|
|
179
|
-
onClick={() => act("run-installer")}
|
|
180
|
-
style={{ fontSize: "11px", padding: "3px 10px", marginBottom: "10px" }}
|
|
181
|
-
>
|
|
182
|
-
Run installer
|
|
183
|
-
</button>
|
|
184
|
-
)}
|
|
185
|
-
|
|
186
|
-
<label style={{ display: "block", fontSize: "11px", marginBottom: "6px" }}>
|
|
187
|
-
imcp-server path override
|
|
188
|
-
<input
|
|
189
|
-
data-testid="apple-tools-path"
|
|
190
|
-
value={pathDraft}
|
|
191
|
-
onChange={(e) => setPathDraft(e.target.value)}
|
|
192
|
-
onBlur={() => saveConfig({ imcpServerPath: pathDraft })}
|
|
193
|
-
style={{ display: "block", width: "100%", fontSize: "11px", fontFamily: "monospace" }}
|
|
194
|
-
/>
|
|
195
|
-
</label>
|
|
196
|
-
|
|
197
|
-
<p style={{ fontSize: "11px", margin: "2px 0 10px 0" }}>
|
|
198
|
-
<a data-testid="apple-tools-manage-mcp" href={MANAGE_MCP_PATH}>
|
|
199
|
-
Manage MCP servers
|
|
200
|
-
</a>{" "}
|
|
201
|
-
— enable/disable iMCP and pick its direct tools there.
|
|
202
|
-
</p>
|
|
203
|
-
|
|
204
|
-
<p style={{ fontSize: "10px", color: "#71717a", marginTop: "10px" }}>
|
|
205
|
-
Apple service permissions (Calendar, Contacts, …) are granted only in the iMCP menu-bar
|
|
206
|
-
app and cannot be automated. This panel does not toggle individual services.
|
|
207
|
-
</p>
|
|
208
|
-
</>
|
|
209
|
-
)}
|
|
210
|
-
</section>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
11
|
+
export {};
|