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