@blackbelt-technology/pi-dashboard-apple-tools 0.7.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 +68 -0
- package/README.md +61 -0
- package/config.schema.json +13 -0
- package/package.json +93 -0
- package/src/bin/install.ts +31 -0
- package/src/client/index.tsx +202 -0
- package/src/detect.ts +83 -0
- package/src/doctor.ts +50 -0
- package/src/env.ts +146 -0
- package/src/install.ts +244 -0
- package/src/mcp-config.ts +285 -0
- package/src/reconcile.ts +29 -0
- package/src/server/index.ts +200 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: apple-tools
|
|
3
|
+
description: Reach Apple PIM data (Calendar, Contacts, Reminders, Messages, Location, Maps, Weather) from a pi session via iMCP + pi-mcp-adapter on macOS. Use when the user asks to read/search their Apple Calendar, Contacts, Reminders, iMessages, current Location, Maps, or Weather. Does NOT cover Apple Mail — iMCP exposes no Mail service; use apple-mail-fast-export for email.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# apple-tools (iMCP)
|
|
7
|
+
|
|
8
|
+
Access Apple personal-information-management data on **macOS** through
|
|
9
|
+
[iMCP](https://github.com/mattt/iMCP), a menu-bar app that brokers the OS
|
|
10
|
+
permission grants, reached over MCP by `pi-mcp-adapter`.
|
|
11
|
+
|
|
12
|
+
## Reachable services (seven)
|
|
13
|
+
|
|
14
|
+
Calendar · Contacts · Location · Maps · Messages · Reminders · Weather
|
|
15
|
+
|
|
16
|
+
- **Messages** here means **iMessage / SMS** — it is NOT email.
|
|
17
|
+
- There is **no Mail service**. iMCP exposes no Apple Mail access.
|
|
18
|
+
|
|
19
|
+
## Mail is out of scope — redirect
|
|
20
|
+
|
|
21
|
+
If the user asks to read, search, or summarize **Apple Mail / email**:
|
|
22
|
+
|
|
23
|
+
- iMCP exposes **no Mail service**; do not attempt an iMCP/adapter tool call for Mail.
|
|
24
|
+
- Use the **`apple-mail-fast-export`** skill instead — it exports `.eml` files
|
|
25
|
+
directly from the on-disk Apple Mail store.
|
|
26
|
+
|
|
27
|
+
"Messages" satisfying an email request is a category error: Messages is
|
|
28
|
+
iMessage/SMS only.
|
|
29
|
+
|
|
30
|
+
## Access pattern — search then invoke via the adapter
|
|
31
|
+
|
|
32
|
+
The agent reaches iMCP tools through **`pi-mcp-adapter`**, not by spawning the
|
|
33
|
+
server. Do **not** run `imcp-server` directly. Use the adapter's MCP tool
|
|
34
|
+
surface (search the available tools, then invoke).
|
|
35
|
+
|
|
36
|
+
## Provisioning check (run at load)
|
|
37
|
+
|
|
38
|
+
This skill runs the installer's `--check` traversal on load (one `sw_vers` plus
|
|
39
|
+
a few `stat` calls; short-circuits instantly on non-macOS). If iMCP is not
|
|
40
|
+
provisioned it reports the gap and names the fix:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
pi-apple-tools-install
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Terminal states mirror the CLI and the dashboard panel:
|
|
47
|
+
`UNSUPPORTED_PLATFORM`, `OS_VERSION_UNKNOWN`, `OS_TOO_OLD`, `NO_INSTALL_METHOD`,
|
|
48
|
+
`INSTALL_FAILED`, `CONFIG_UNPARSEABLE`, `CONFIG_WRITE_FAILED`,
|
|
49
|
+
`READY_PENDING_GRANTS`.
|
|
50
|
+
|
|
51
|
+
`READY` is NOT one of them. It is a live-access result — reachable only by a
|
|
52
|
+
successful tool round-trip through the adapter, never by the provisioning
|
|
53
|
+
traversal, which cannot know whether the TCC grants were given.
|
|
54
|
+
|
|
55
|
+
If the state is anything other than `READY_PENDING_GRANTS`, do NOT attempt
|
|
56
|
+
Apple-data tool calls — report the gap and the `pi-apple-tools-install`
|
|
57
|
+
command first.
|
|
58
|
+
|
|
59
|
+
## Permission grants are manual and out-of-band
|
|
60
|
+
|
|
61
|
+
The final step — granting Calendar/Contacts/… permissions — happens in the
|
|
62
|
+
**iMCP menu-bar app** and **cannot be automated** (Apple's TCC security model
|
|
63
|
+
has no API).
|
|
64
|
+
|
|
65
|
+
- The load-time check **cannot detect a revoked grant** ahead of a call.
|
|
66
|
+
- A permission-class failure at call time means the grant was **revoked or never
|
|
67
|
+
given** → the fix is **menu-bar remediation**, NOT re-running the installer.
|
|
68
|
+
Re-running `pi-apple-tools-install` will not restore a TCC grant.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @blackbelt-technology/pi-dashboard-apple-tools
|
|
2
|
+
|
|
3
|
+
Provision and surface **iMCP** — Apple PIM (Calendar, Contacts, Reminders,
|
|
4
|
+
Messages, Location, Maps, Weather) — for a pi session on **macOS**, reached
|
|
5
|
+
through [`pi-mcp-adapter`](https://www.npmjs.com/package/pi-mcp-adapter).
|
|
6
|
+
|
|
7
|
+
> **macOS only. No Apple Mail.** iMCP exposes no Mail service; "Messages" is
|
|
8
|
+
> iMessage/SMS, not email. For email use the `apple-mail-fast-export` skill.
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
Three moving parts must line up before a single Apple tool call works:
|
|
13
|
+
|
|
14
|
+
1. **iMCP.app installed** — `brew install --cask mattt/tap/iMCP`
|
|
15
|
+
2. **`pi-mcp-adapter` loaded** — an entry in `~/.pi/agent/settings.json` `packages[]`
|
|
16
|
+
3. **`mcp.json` entry present** — `mcpServers.iMCP.command` in `~/.pi/agent/mcp.json`
|
|
17
|
+
4. **TCC grants** — **manual**, in the iMCP menu-bar app (Apple's security model
|
|
18
|
+
has no API; this step cannot be automated)
|
|
19
|
+
|
|
20
|
+
Steps 1–3 are automated by this package. Step 4 is a documented manual click.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pi install npm:@blackbelt-technology/pi-dashboard-apple-tools
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Installing the package does nothing on its own (no `postinstall`). Provisioning
|
|
29
|
+
is **opt-in**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pi-apple-tools-install # provision (writes mcp.json + settings.json)
|
|
33
|
+
pi-apple-tools-install --check # report the state without changing anything
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Provisioning states
|
|
37
|
+
|
|
38
|
+
A closed nine-member enum, identical across the CLI, the dashboard panel, and
|
|
39
|
+
the `doctor` probe:
|
|
40
|
+
|
|
41
|
+
`UNSUPPORTED_PLATFORM` · `OS_VERSION_UNKNOWN` · `OS_TOO_OLD` ·
|
|
42
|
+
`NO_INSTALL_METHOD` · `INSTALL_FAILED` · `CONFIG_UNPARSEABLE` ·
|
|
43
|
+
`CONFIG_WRITE_FAILED` · `READY_PENDING_GRANTS` · `READY`
|
|
44
|
+
|
|
45
|
+
`READY_PENDING_GRANTS` means everything is wired but you still need to grant
|
|
46
|
+
permissions in the iMCP menu-bar app. Minimum macOS: **15.3**.
|
|
47
|
+
|
|
48
|
+
## Manual grant step
|
|
49
|
+
|
|
50
|
+
After `READY_PENDING_GRANTS`, open the **iMCP menu-bar app** and grant each Apple
|
|
51
|
+
service you need. Grants can be **revoked out of band** at any time and cannot be
|
|
52
|
+
detected ahead of a call — a permission-class failure means **menu-bar
|
|
53
|
+
remediation**, not re-running the installer.
|
|
54
|
+
|
|
55
|
+
## Dashboard panel
|
|
56
|
+
|
|
57
|
+
The plugin contributes a settings section under its own row in the Plugins tab:
|
|
58
|
+
status readout, **Run installer**, `imcp-server` path override, `directTools`
|
|
59
|
+
selection, and a server enable/disable toggle (writes a `disabled` override to
|
|
60
|
+
the project-local `.pi/mcp.json`). It has **no per-service toggles** — those are
|
|
61
|
+
menu-bar only.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Apple Tools (iMCP) plugin config",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"properties": {
|
|
7
|
+
"imcpServerPath": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Absolute path to the iMCP server binary. Defaults to the canonical /Applications location; the paths requirement interpolates this key.",
|
|
10
|
+
"default": "/Applications/iMCP.app/Contents/MacOS/imcp-server"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackbelt-technology/pi-dashboard-apple-tools",
|
|
3
|
+
"version": "0.7.0",
|
|
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
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
|
|
13
|
+
"directory": "packages/apple-tools"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pi",
|
|
17
|
+
"pi-dashboard-plugin",
|
|
18
|
+
"imcp",
|
|
19
|
+
"mcp",
|
|
20
|
+
"apple",
|
|
21
|
+
"calendar",
|
|
22
|
+
"contacts",
|
|
23
|
+
"reminders",
|
|
24
|
+
"macos"
|
|
25
|
+
],
|
|
26
|
+
"bin": {
|
|
27
|
+
"pi-apple-tools-install": "src/bin/install.ts"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./src/client/index.tsx",
|
|
32
|
+
"default": "./src/client/index.tsx"
|
|
33
|
+
},
|
|
34
|
+
"./client": {
|
|
35
|
+
"types": "./src/client/index.tsx",
|
|
36
|
+
"default": "./src/client/index.tsx"
|
|
37
|
+
},
|
|
38
|
+
"./server": {
|
|
39
|
+
"types": "./src/server/index.ts",
|
|
40
|
+
"default": "./src/server/index.ts"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"src/",
|
|
45
|
+
"config.schema.json",
|
|
46
|
+
".pi/",
|
|
47
|
+
"!**/__tests__",
|
|
48
|
+
"!**/*.test.ts",
|
|
49
|
+
"!**/*.test.tsx"
|
|
50
|
+
],
|
|
51
|
+
"pi": {
|
|
52
|
+
"skills": [
|
|
53
|
+
".pi/skills/apple-tools"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"pi-dashboard-plugin": {
|
|
57
|
+
"id": "apple-tools",
|
|
58
|
+
"displayName": "Apple Tools",
|
|
59
|
+
"priority": 100,
|
|
60
|
+
"client": "./src/client/index.tsx",
|
|
61
|
+
"server": "./src/server/index.ts",
|
|
62
|
+
"configSchema": "./config.schema.json",
|
|
63
|
+
"requires": {
|
|
64
|
+
"piExtensions": [
|
|
65
|
+
"pi-mcp-adapter"
|
|
66
|
+
],
|
|
67
|
+
"paths": [
|
|
68
|
+
"${imcpServerPath}"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"claims": [
|
|
72
|
+
{
|
|
73
|
+
"slot": "settings-section",
|
|
74
|
+
"component": "AppleToolsSettings"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"react": ">=18.0.0",
|
|
80
|
+
"react-dom": ">=18.0.0"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.7.0",
|
|
84
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.7.0",
|
|
85
|
+
"pi-mcp-adapter": "^2.19.0"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@types/react": "^19.0.0",
|
|
89
|
+
"@types/react-dom": "^19.0.0",
|
|
90
|
+
"react": "^19.0.0",
|
|
91
|
+
"react-dom": "^19.0.0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `pi-apple-tools-install [--check]` — opt-in CLI entry for iMCP provisioning.
|
|
4
|
+
*
|
|
5
|
+
* Never runs implicitly (no postinstall). Writes exactly two files in write
|
|
6
|
+
* mode (`~/.pi/agent/mcp.json`, `~/.pi/agent/settings.json`) and NEVER touches
|
|
7
|
+
* the server-owned plugin config store. `--check` reports the terminal state
|
|
8
|
+
* without mutating anything.
|
|
9
|
+
*
|
|
10
|
+
* See change: add-apple-tools-imcp-plugin.
|
|
11
|
+
*/
|
|
12
|
+
import { createInstallerEnv } from "../env.js";
|
|
13
|
+
import { runInstaller } from "../install.js";
|
|
14
|
+
|
|
15
|
+
function main(argv: string[]): number {
|
|
16
|
+
const check = argv.includes("--check");
|
|
17
|
+
const overrideIdx = argv.indexOf("--path");
|
|
18
|
+
const overridePath =
|
|
19
|
+
overrideIdx >= 0 && argv[overrideIdx + 1] ? argv[overrideIdx + 1] : undefined;
|
|
20
|
+
|
|
21
|
+
const env = createInstallerEnv({ ...(overridePath ? { overridePath } : {}) });
|
|
22
|
+
const result = runInstaller(env, { check });
|
|
23
|
+
|
|
24
|
+
const label = check ? "[check]" : "[install]";
|
|
25
|
+
const stream = result.exitCode === 0 ? process.stdout : process.stderr;
|
|
26
|
+
stream.write(`${label} ${result.state}\n${result.message}\n`);
|
|
27
|
+
if (result.resolvedPath) stream.write(`imcp-server: ${result.resolvedPath}\n`);
|
|
28
|
+
return result.exitCode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
process.exit(main(process.argv.slice(2)));
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apple-tools · CLIENT entry.
|
|
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], 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).
|
|
11
|
+
*
|
|
12
|
+
* See change: add-apple-tools-imcp-plugin (Decision 5).
|
|
13
|
+
*/
|
|
14
|
+
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
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
|
+
}
|
package/src/detect.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, injectable environment probes for the iMCP provisioning traversal.
|
|
3
|
+
*
|
|
4
|
+
* Every probe is a plain function over injected inputs so the whole installer
|
|
5
|
+
* suite runs deterministically on Linux CI — no probe touches a real
|
|
6
|
+
* `/Applications` path, spawns a real `sw_vers`, or invokes a real `brew`.
|
|
7
|
+
*
|
|
8
|
+
* See change: add-apple-tools-imcp-plugin.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Minimum supported macOS version (inclusive floor). */
|
|
12
|
+
export const MIN_MACOS = "15.3";
|
|
13
|
+
|
|
14
|
+
/** Canonical, ordered candidate locations for the iMCP server binary. */
|
|
15
|
+
export const IMCP_RELATIVE = "iMCP.app/Contents/MacOS/imcp-server";
|
|
16
|
+
|
|
17
|
+
/** iMCP direct-download page, surfaced when no install method is available. */
|
|
18
|
+
export const IMCP_DOWNLOAD_URL = "https://github.com/mattt/iMCP/releases/latest";
|
|
19
|
+
|
|
20
|
+
/** Homebrew cask reference for iMCP. */
|
|
21
|
+
export const IMCP_BREW_CASK = "mattt/tap/iMCP";
|
|
22
|
+
|
|
23
|
+
/** Parse a dotted version string into numeric components; null if unparseable. */
|
|
24
|
+
export function parseVersion(raw: string | null | undefined): number[] | null {
|
|
25
|
+
if (typeof raw !== "string") return null;
|
|
26
|
+
const trimmed = raw.trim();
|
|
27
|
+
if (trimmed === "") return null;
|
|
28
|
+
const parts = trimmed.split(".");
|
|
29
|
+
const nums: number[] = [];
|
|
30
|
+
for (const p of parts) {
|
|
31
|
+
if (!/^\d+$/.test(p)) return null;
|
|
32
|
+
nums.push(Number(p));
|
|
33
|
+
}
|
|
34
|
+
return nums.length > 0 ? nums : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Numeric (not lexical) version compare. Returns <0, 0, or >0.
|
|
39
|
+
* Guards against the `"15.10" < "15.3"` string-compare bug.
|
|
40
|
+
*/
|
|
41
|
+
export function compareVersions(a: number[], b: number[]): number {
|
|
42
|
+
const len = Math.max(a.length, b.length);
|
|
43
|
+
for (let i = 0; i < len; i++) {
|
|
44
|
+
const x = a[i] ?? 0;
|
|
45
|
+
const y = b[i] ?? 0;
|
|
46
|
+
if (x !== y) return x - y;
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** True when `version` (e.g. "15.10") is >= the inclusive floor `min`. */
|
|
52
|
+
export function meetsMinimum(version: string, min: string = MIN_MACOS): boolean {
|
|
53
|
+
const v = parseVersion(version);
|
|
54
|
+
const m = parseVersion(min);
|
|
55
|
+
if (!v || !m) return false;
|
|
56
|
+
return compareVersions(v, m) >= 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The standard, ordered install locations for the imcp-server binary (an
|
|
61
|
+
* operator override is consulted before these, see {@link discoverServer}).
|
|
62
|
+
*/
|
|
63
|
+
export function candidatePaths(homedir: string): string[] {
|
|
64
|
+
return [`/Applications/${IMCP_RELATIVE}`, `${homedir}/Applications/${IMCP_RELATIVE}`];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Discover imcp-server against the candidate list. When an override is set and
|
|
69
|
+
* EXISTS, it wins and the rest of the list is not consulted (E12). When the
|
|
70
|
+
* override is set but absent, discovery falls through to the standard
|
|
71
|
+
* candidates (E13).
|
|
72
|
+
*/
|
|
73
|
+
export function discoverServer(
|
|
74
|
+
homedir: string,
|
|
75
|
+
pathExists: (p: string) => boolean,
|
|
76
|
+
override?: string,
|
|
77
|
+
): string | null {
|
|
78
|
+
if (override && override.trim() !== "" && pathExists(override)) return override;
|
|
79
|
+
for (const p of candidatePaths(homedir)) {
|
|
80
|
+
if (pathExists(p)) return p;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
package/src/doctor.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor probe for iMCP provisioning. Derives its verdict from the SAME
|
|
3
|
+
* write-suppressed checker the CLI `--check` and the settings panel use, so all
|
|
4
|
+
* surfaces agree. Read-only: it never writes config and never installs.
|
|
5
|
+
*
|
|
6
|
+
* See change: add-apple-tools-imcp-plugin.
|
|
7
|
+
*/
|
|
8
|
+
import { type InstallerEnv, runInstaller, type TerminalState } from "./install.js";
|
|
9
|
+
|
|
10
|
+
export interface DoctorProbeResult {
|
|
11
|
+
/** Whether the apple-tools package itself is present on the host. */
|
|
12
|
+
packagePresent: boolean;
|
|
13
|
+
/** Whether the platform supports iMCP at all (macOS). */
|
|
14
|
+
supported: boolean;
|
|
15
|
+
/** Terminal provisioning state (identical vocabulary to the CLI). */
|
|
16
|
+
state: TerminalState;
|
|
17
|
+
/**
|
|
18
|
+
* Whether iMCP.app is actually on disk. When false, `state` is a PREDICTION
|
|
19
|
+
* of what running the installer would reach — not an observation.
|
|
20
|
+
*/
|
|
21
|
+
appPresent: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the operator must act. Always false on a non-macOS host — an
|
|
24
|
+
* unsupported platform is not a fault to remediate (#X19). True whenever the
|
|
25
|
+
* app is absent, even though the predicted state is a healthy one: a host
|
|
26
|
+
* without iMCP installed genuinely needs action.
|
|
27
|
+
*/
|
|
28
|
+
requiresRemediation: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const HEALTHY: readonly TerminalState[] = ["READY", "READY_PENDING_GRANTS"];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Run the read-only provisioning probe. `packagePresent` is injected by the
|
|
35
|
+
* caller (the doctor skill), which knows whether apple-tools is installed.
|
|
36
|
+
*/
|
|
37
|
+
export function doctorProbe(env: InstallerEnv, packagePresent: boolean): DoctorProbeResult {
|
|
38
|
+
const result = runInstaller(env, { check: true });
|
|
39
|
+
const supported = env.platform === "darwin";
|
|
40
|
+
return {
|
|
41
|
+
packagePresent,
|
|
42
|
+
supported,
|
|
43
|
+
state: result.state,
|
|
44
|
+
appPresent: result.appPresent,
|
|
45
|
+
// Non-macOS is never a remediation item. Otherwise the operator must act
|
|
46
|
+
// when the state is unhealthy OR the app simply isn't installed yet (the
|
|
47
|
+
// predicted-healthy case — caught by QA on a real host with brew but no iMCP).
|
|
48
|
+
requiresRemediation: supported && (!HEALTHY.includes(result.state) || !result.appPresent),
|
|
49
|
+
};
|
|
50
|
+
}
|