@blackbelt-technology/pi-dashboard-mcp-client-plugin 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/src/core/types.ts DELETED
@@ -1,200 +0,0 @@
1
- /**
2
- * mcp-client-plugin · CORE types.
3
- *
4
- * Shared vocabulary for the config writer, effective-view reader, live-state
5
- * reader and the `mcp-client.config` service — all over pi's built-in MCP
6
- * config (`~/.pi/agent/mcp.json` + trusted `<cwd>/.pi/mcp.json`). `./core`
7
- * carries NO host, pi or React imports so the hostless `apple-tools`
8
- * installer can consume it.
9
- *
10
- * See change: migrate-mcp-to-pi-builtin (D3); earlier: extract-mcp-client-plugin.
11
- */
12
-
13
- import type { AuthMode } from "./pi-rules.js";
14
-
15
- export type { AuthMode };
16
-
17
- /** pi's MCP server entry (1.0.0). Unknown keys are preserved, never dropped. */
18
- export interface ServerEntry {
19
- type?: "stdio" | "http" | "streamable-http" | string;
20
- description?: string;
21
- command?: string;
22
- args?: string[];
23
- env?: Record<string, string>;
24
- cwd?: string;
25
- url?: string;
26
- headers?: Record<string, string>;
27
- oauth?: {
28
- clientId?: string;
29
- clientSecret?: string;
30
- callbackPort?: number;
31
- callbackUrl?: string;
32
- scope?: string;
33
- clientName?: string;
34
- authServerMetadataUrl?: string;
35
- [k: string]: unknown;
36
- };
37
- auth?: { provider: string; [k: string]: unknown };
38
- exposure?: string;
39
- toolExposure?: Record<string, string>;
40
- timeout?: number;
41
- enabled?: boolean;
42
- [k: string]: unknown;
43
- }
44
-
45
- /** Which Pi layer a read/write targets. */
46
- export type Scope = { kind: "global" } | { kind: "project"; cwd: string };
47
-
48
- /** Injected filesystem surface. `readFile` returns null when the file is absent. */
49
- export interface ConfigIO {
50
- readFile: (path: string) => string | null;
51
- /**
52
- * Atomic, hardened write (exclusive random temp file mode 0600, fsync, rename).
53
- * Throws an Error whose `.code` may be EACCES / ENOSPC / ENOENT.
54
- */
55
- writeFileAtomic: (path: string, content: string) => void;
56
- }
57
-
58
- /** The closed refusal set shared by every write path AND by `checkConfigFiles`. */
59
- export type ConfigRefusalCode =
60
- | "unparseable"
61
- | "entry-not-object"
62
- | "invalid-name"
63
- | "name-collision"
64
- | "transport-conflict"
65
- | "invalid-entry"
66
- | "write-failed";
67
-
68
- export interface ConfigRefusal {
69
- code: ConfigRefusalCode;
70
- message: string;
71
- /** The offending file, when the refusal is file-scoped. */
72
- path?: string;
73
- /** For `write-failed`: the IO error code (EACCES / ENOSPC / ENOENT / ...). */
74
- ioCode?: string;
75
- /** For `transport-conflict`: the transport fields the resulting entry carries. */
76
- fields?: string[];
77
- /** For `name-collision`: the colliding server and where it is defined. */
78
- conflict?: { name: string; path: string };
79
- }
80
-
81
- export type ConfigWriteResult = { ok: true } | { ok: false; refusal: ConfigRefusal };
82
-
83
- export type RemoveResult =
84
- | { ok: true; removed: ServerEntry | undefined }
85
- | { ok: false; refusal: ConfigRefusal };
86
-
87
- /**
88
- * `written` — the layer now carries the requested state. `omitted` lists the
89
- * secret-bearing fields a folder-scope DISABLE copy left out.
90
- * `needs-choice` — an ENABLE of a folder copy that lacks the global entry's
91
- * secrets: nothing is written; the caller offers "remove the folder entry" or
92
- * "re-enter the omitted values".
93
- */
94
- export type SetEnabledResult =
95
- | { ok: true; action: "written"; omitted?: string[] }
96
- | { ok: true; action: "needs-choice"; omitted: string[] }
97
- | { ok: false; refusal: ConfigRefusal };
98
-
99
- /** Parse status of one config file (write-suppressed). */
100
- export interface ParseStatus {
101
- path: string;
102
- ok: boolean;
103
- /** Present iff `ok` is false: the parser error message. */
104
- message?: string;
105
- }
106
-
107
- export type Provenance = "pi-global" | "pi-folder";
108
-
109
- export type InactiveReason = "disabled" | "project-not-trusted" | "invalid-entry" | "name-collision" | "global-only-auth";
110
-
111
- export interface EffectiveServerView {
112
- name: string;
113
- provenance: Provenance;
114
- /** A folder entry that replaces the global entry of the same name. */
115
- overridesGlobal?: boolean;
116
- /**
117
- * The entry as written. In a project view, a GLOBAL entry's secret values
118
- * (`headers`, `env` → `{redacted, keys}`; `oauth.clientSecret` →
119
- * `{redacted}`) are redacted server-side; own-layer entries are verbatim.
120
- */
121
- entry: Record<string, unknown>;
122
- transport: "stdio" | "http";
123
- enabled: boolean;
124
- /** Exposure for display (alias resolved, default `codemode`). */
125
- exposure: string;
126
- /** Whether pi loads this entry for the view's directory. */
127
- active: boolean;
128
- inactiveReason?: InactiveReason;
129
- /** pi's own message when it would reject or drop the entry. */
130
- piError?: string;
131
- /** Keys pi ignores on this entry (adapter leftovers, losing dual-transport key). */
132
- ignoredKeys: string[];
133
- /** The adapter-only subset of `ignoredKeys`; non-empty → "convert" is offered. */
134
- adapterLeftovers: string[];
135
- authMode?: AuthMode;
136
- }
137
-
138
- export interface LayerStatus {
139
- layer: Provenance;
140
- path: string;
141
- exists: boolean;
142
- ok: boolean;
143
- /** Present iff `ok` is false — pi skips the whole file. */
144
- message?: string;
145
- }
146
-
147
- export interface EffectiveView {
148
- scope: "global" | "project";
149
- cwd?: string;
150
- /** Project views only: pi's trust decision for `cwd` (predicate absent → false). */
151
- trusted?: boolean;
152
- servers: EffectiveServerView[];
153
- layers: LayerStatus[];
154
- }
155
-
156
- /** One server's live state as `pi mcp list --json` reports it. */
157
- export interface LiveServerState {
158
- state: string;
159
- tools: number;
160
- error?: string;
161
- }
162
-
163
- export type LiveState =
164
- | { ok: true; servers: Record<string, LiveServerState>; errors: string[]; note?: string }
165
- | { ok: false; reason: "spawn-failed" | "timeout" | "unparseable"; message: string };
166
-
167
- /**
168
- * Runs `pi mcp list --json` in `cwd`. Resolves with stdout + exit code
169
- * whatever the code; rejects only when the process cannot run. Must kill the
170
- * child when `signal` aborts.
171
- */
172
- export type PiMcpListRunner = (cwd: string, signal: AbortSignal) => Promise<{ stdout: string; code: number | null }>;
173
-
174
- /** The in-process service provided as `mcp-client.config`. */
175
- export interface McpClientConfigService {
176
- /** The file a scope's write lands in. Throws `NotAllowedCwdError` for an unknown cwd. */
177
- targetPath(scope: Scope): string;
178
- /** The raw entry in the scope's layer (no merge), or undefined. */
179
- readServerEntry(name: string, scope: Scope): ServerEntry | undefined;
180
- getEffectiveView(scope: Scope): EffectiveView;
181
- /** Merge `fields` over the existing layer entry (or create it), then validate. */
182
- ensureServerEntry(name: string, fields: Partial<ServerEntry>, scope: Scope): ConfigWriteResult;
183
- /**
184
- * Replace the whole entry. `previousName` renames (the old key is removed);
185
- * `create` refuses when the name already exists. Neither ever replaces
186
- * another entry.
187
- */
188
- saveServer(
189
- name: string,
190
- entry: ServerEntry,
191
- scope: Scope,
192
- opts?: { previousName?: string; create?: boolean },
193
- ): ConfigWriteResult;
194
- removeServer(name: string, scope: Scope): RemoveResult;
195
- setEnabled(name: string, enabled: boolean, scope: Scope): SetEnabledResult;
196
- /** `disabled: true` → `enabled: false`; drop every adapter-only key. */
197
- convertAdapterLeftovers(name: string, scope: Scope): ConfigWriteResult;
198
- /** Write-suppressed parse + (optional) dry run of `ensureServerEntry` at global scope. */
199
- checkConfigFiles(opts?: { serverName?: string; fields?: Partial<ServerEntry> }): { mcpJson: ParseStatus };
200
- }