glasspane-mcp 1.26.0 → 1.28.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/dist/dispatch.d.ts +40 -3
- package/dist/engine-client.d.ts +85 -3
- package/dist/errors.d.ts +18 -0
- package/dist/http-gateway-cli.js +148 -22
- package/dist/http-gateway.js +151 -23
- package/dist/index.js +681 -444
- package/dist/project-registry.d.ts +62 -10
- package/dist/stdio-session.js +681 -444
- package/dist/tools.d.ts +35 -0
- package/dist/update-state.d.ts +16 -0
- package/package.json +2 -2
package/dist/dispatch.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const MCP_PROTOCOL_VERSION: "2025-06-18";
|
|
|
26
26
|
export declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
|
|
27
27
|
export declare const SERVER_INFO: {
|
|
28
28
|
readonly name: "glasspane-mcp";
|
|
29
|
-
readonly version: "1.
|
|
29
|
+
readonly version: "1.28.0";
|
|
30
30
|
};
|
|
31
31
|
export declare const PARSE_ERROR = -32700;
|
|
32
32
|
export declare const INVALID_REQUEST = -32600;
|
|
@@ -89,6 +89,21 @@ export declare class McpServer {
|
|
|
89
89
|
*/
|
|
90
90
|
private negotiateProtocolVersion;
|
|
91
91
|
private callTool;
|
|
92
|
+
/**
|
|
93
|
+
* The name the fault remedy should be written about: the **engine method**, when the frame
|
|
94
|
+
* names a tool this server publishes.
|
|
95
|
+
*
|
|
96
|
+
* `shellFaultRemedy` branches on the engine method (`act` / `restore` / `attach` are the
|
|
97
|
+
* replay-unsafe ones — see `REPLAY_UNSAFE_REASONS` in engine-client.ts), and a tool name is
|
|
98
|
+
* not an engine method: `gp_act` is not in that table, so handing it over answered a fault
|
|
99
|
+
* inside `gp_act` with "sending this tool again is a real option — do that once". That is
|
|
100
|
+
* the one sentence this product refuses to print for an action that may still be performing
|
|
101
|
+
* a change on the user's screen, so the domain conversion happens here, at the only call
|
|
102
|
+
* site. An unknown name is not a method either, and the caller's own bytes must not be
|
|
103
|
+
* echoed unbounded into the remedy, so that arm falls back to the protocol method — bounded
|
|
104
|
+
* and control-neutralised, the same rule {@link echoForeign} states.
|
|
105
|
+
*/
|
|
106
|
+
private callTargetName;
|
|
92
107
|
private asParams;
|
|
93
108
|
private isRequestBody;
|
|
94
109
|
private result;
|
|
@@ -97,10 +112,32 @@ export declare class McpServer {
|
|
|
97
112
|
* actually answers. A JSON-RPC reader cannot open a source symbol, and an example naming a
|
|
98
113
|
* tool this surface does not publish would be a second refusal waiting to happen — so the
|
|
99
114
|
* preference is a published tool that is legal to call with an empty `arguments`.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* "Legal with an empty arguments" is measured by running the same `validate` the call path
|
|
117
|
+
* runs (`executeTool(spec, params.arguments ?? {}, …)`), not by reading `required` off the
|
|
118
|
+
* advertised JSON Schema. Those two are not the same question: `gp_attach` publishes
|
|
119
|
+
* `oneOf: [{required:[bundleId]}, {required:[pid]}]` with no top-level `required` key, so the
|
|
120
|
+
* schema read called it "takes nothing" while its own refinement refuses `{}` — and measured
|
|
121
|
+
* on the delivered artifact, the remedy this sentence prints sent the agent to a call answered
|
|
122
|
+
* `GP_E_BAD_PARAMS: attach takes exactly one of bundleId or pid`. An example the caller is
|
|
123
|
+
* guaranteed to fail is worse than no example, which is the rule `publishedNamesNear` below
|
|
124
|
+
* already states for the *name* half of the same sentence.
|
|
125
|
+
* `test/dispatch.test.mjs` checks every name in this sentence against `tools/list`, checks it
|
|
126
|
+
* again on a server deliberately built with a one-tool list, and now checks that the named
|
|
127
|
+
* tool really answers `arguments: {}` without a params refusal.
|
|
102
128
|
*/
|
|
103
129
|
private callShapeRemedy;
|
|
130
|
+
/**
|
|
131
|
+
* Caller-authored text that rides a protocol error frame: bounded in length, neutralised
|
|
132
|
+
* for terminal control. The same product escapes a daemon-authored id with
|
|
133
|
+
* `renderForeign` and a report body with `escapeTerminalControl`, because an ESC can move
|
|
134
|
+
* the cursor and overwrite what the frame just said. Protocol-level text arrives from
|
|
135
|
+
* whoever wrote the frame — an MCP client, or anything that can reach the HTTP body — so
|
|
136
|
+
* the same rule applies before it is echoed back inside `Unknown tool: …`. Without a
|
|
137
|
+
* length bound, a 4 MB `params.name` is copied verbatim into the stdout frame, and one
|
|
138
|
+
* frame on a shared stdout is not a place to park whatever the caller typed.
|
|
139
|
+
*/
|
|
140
|
+
private echoForeign;
|
|
104
141
|
/**
|
|
105
142
|
* The names this server actually answers with, nearest the caller's guess first. Every
|
|
106
143
|
* name offered here is one `tools/list` just advertised: a suggestion the caller cannot
|
package/dist/engine-client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import { Duplex } from "node:stream";
|
|
2
3
|
import { LineIo } from "./io.js";
|
|
3
4
|
/**
|
|
@@ -19,6 +20,8 @@ import { LineIo } from "./io.js";
|
|
|
19
20
|
export declare function daemonUnreachableRemedy(): string;
|
|
20
21
|
/** Env override for the daemon socket path (default below). */
|
|
21
22
|
export declare const ENGINE_SOCKET_ENV = "GLASSPANE_ENGINE_SOCK";
|
|
23
|
+
/** The launchd job this product installs — remedies name it so an agent can read the running job. */
|
|
24
|
+
export declare const LAUNCHD_JOB_LABEL = "com.glasspane.daemon";
|
|
22
25
|
/**
|
|
23
26
|
* Where this shell connects when nothing was named, in order: `GLASSPANE_ENGINE_SOCK`
|
|
24
27
|
* (the env var {@link ENGINE_SOCKET_ENV} spells), then the explicit
|
|
@@ -83,6 +86,16 @@ export declare const ENGINE_SOCKET_ENV = "GLASSPANE_ENGINE_SOCK";
|
|
|
83
86
|
* choose (`index.ts`, `http-gateway-cli.ts`).
|
|
84
87
|
*/
|
|
85
88
|
export declare function defaultSocketPath(): string;
|
|
89
|
+
/**
|
|
90
|
+
* The socket the engine binds when *nothing* names one — the home default, read straight from
|
|
91
|
+
* the passwd-independent `os.homedir()` guess the daemon falls back to.
|
|
92
|
+
*
|
|
93
|
+
* Separate from `defaultSocketPath()` because a remedy that says "the default is X" must name
|
|
94
|
+
* the default even while `GLASSPANE_ENGINE_SOCK` is set to something else: echoing the override
|
|
95
|
+
* back as the default would tell the reader its own mistake is the engine's behaviour. This is
|
|
96
|
+
* also the one place `$HOME` is spelled for the socket, which `engine-client.test.mjs` counts.
|
|
97
|
+
*/
|
|
98
|
+
export declare function homeDefaultSocketPath(): string;
|
|
86
99
|
/**
|
|
87
100
|
* The env override that actually names a socket, or `null` when it names nothing.
|
|
88
101
|
*
|
|
@@ -115,6 +128,46 @@ export declare function socketOverride(value: string | undefined): string | null
|
|
|
115
128
|
* is the ENOENT this shell already reports, not a usage error invented here.
|
|
116
129
|
*/
|
|
117
130
|
export declare function refuseEmptySocketPath(value: string, flag: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* The stat facts {@link trustSocket} needs, as a type so a test can hand it a real
|
|
133
|
+
* socket it made unreachable-by-permission without needing a second account.
|
|
134
|
+
*/
|
|
135
|
+
export type SocketEvidence = Pick<fs.Stats, "uid" | "mode" | "isSocket">;
|
|
136
|
+
/**
|
|
137
|
+
* May this path carry the engine's word? `null` means yes; anything else is a
|
|
138
|
+
* three-field refusal to be handed to the caller before a single byte is written.
|
|
139
|
+
*
|
|
140
|
+
* Why this exists at all: the engine socket is owner-only (`chmod 0600`) and carries **no peer
|
|
141
|
+
* authentication** (SECURITY.md — same uid = full authority), so the socket *path* is what makes
|
|
142
|
+
* a reply mean anything. `GLASSPANE_ENGINE_SOCK` therefore is a trust root, not just a location:
|
|
143
|
+
* whatever this function lets through is a thing whose answers this shell renders as the engine's
|
|
144
|
+
* verified word, evidence pack included. Four facts disqualify a path:
|
|
145
|
+
* - the runtime cannot say which account it is running as, so ownership is unaskable;
|
|
146
|
+
* - the leaf is not a socket — a plain file planted there must be named as such instead of
|
|
147
|
+
* producing a connect error that reads like "the daemon is down";
|
|
148
|
+
* - the leaf or the directory holding it belongs to another uid, so this account did not place
|
|
149
|
+
* it there;
|
|
150
|
+
* - either carries a **write** bit for group or other. Write is the bit that matters: on a
|
|
151
|
+
* socket it grants the ability to send, on a directory the ability to create or replace the
|
|
152
|
+
* entry. Execute-only for others (`0755` — which is what a listener created by node itself
|
|
153
|
+
* carries before any chmod, measured on this machine) lets a reader look, not talk, so the
|
|
154
|
+
* daemon's own socket passes. A listener granting `0666` is advertising itself to the machine.
|
|
155
|
+
*
|
|
156
|
+
* `ENOENT` deliberately returns `null`: no file at the path is the daemon-not-running case, which
|
|
157
|
+
* the transport already renders as `GP_E_ENGINE_UNREACHABLE` with the restart command. Turning it
|
|
158
|
+
* into a trust refusal here would rename a known condition and break the remedy an agent is
|
|
159
|
+
* supposed to copy. A stat that fails for any **other** reason is a refusal, because "could not
|
|
160
|
+
* ask" is not evidence of trust.
|
|
161
|
+
*
|
|
162
|
+
* `read` and `euid` are seams, not abstractions: the other-account branches cannot be produced by
|
|
163
|
+
* an unprivileged test process, and a check whose only exercised path is the friendly one has not
|
|
164
|
+
* been checked. Everything else runs against a real socket on a real filesystem.
|
|
165
|
+
*/
|
|
166
|
+
export declare function trustSocket(target: string, read?: (p: string) => SocketEvidence, euid?: number | null): {
|
|
167
|
+
code: string;
|
|
168
|
+
message: string;
|
|
169
|
+
remedy: string;
|
|
170
|
+
} | null;
|
|
118
171
|
/** Fallback deadline for a method missing from the table below. */
|
|
119
172
|
export declare const ENGINE_TIMEOUT_MS = 10000;
|
|
120
173
|
/**
|
|
@@ -325,7 +378,26 @@ export declare function livenessProbeDecision(outcome: LivenessProbeOutcome): st
|
|
|
325
378
|
* the state it really has (R8b-高3).
|
|
326
379
|
*/
|
|
327
380
|
export type ShellSurface = "mcp" | "http";
|
|
328
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* Where the answer to a timed-out request can be found, per surface.
|
|
383
|
+
*
|
|
384
|
+
* The HTTP arm is written against the line the gateway actually prints, because
|
|
385
|
+
* an exit a caller cannot walk is not an exit: it used to promise the reply "is
|
|
386
|
+
* written to this gateway's stderr **with its body**, so the operationId it
|
|
387
|
+
* carries can be read off that line". The real sink refuses exactly that — the
|
|
388
|
+
* body of a late reply is on-screen accessibility content, and `http-gateway.ts`
|
|
389
|
+
* hands it to `lateReplyBodyNote`, which writes a byte count plus a SHA-256
|
|
390
|
+
* digest and says in words that the text is not written (review 2026-10-09
|
|
391
|
+
* finding 3, F3 on 2026-10-27). So the sentence pointed a caller at bytes the
|
|
392
|
+
* product has decided do not exist on that path, and the id it told the caller
|
|
393
|
+
* to read is printed only when the reply's `operationId` matches the archive
|
|
394
|
+
* grammar. The wording below transcribes what the line really says; flipping the
|
|
395
|
+
* other way — making the note write the body — would break the trust boundary
|
|
396
|
+
* that keeps screen content out of a log file whose mode this product never
|
|
397
|
+
* sets, so it is not the fix. `test/daily-20261031-late-reply-route-shape.test.mjs`
|
|
398
|
+
* compares this sentence with a line the real gateway wrote, rather than testing
|
|
399
|
+
* each of them alone.
|
|
400
|
+
*/
|
|
329
401
|
export declare function lateReplyRoute(surface: ShellSurface): string;
|
|
330
402
|
/**
|
|
331
403
|
* 背压闸的出路。两条禁令各由一条现场证据撑着:探针本身也要过一次 `call()`,会被
|
|
@@ -440,8 +512,12 @@ export declare class EngineJsonRpcClient {
|
|
|
440
512
|
expectedDaemonMethods?: readonly string[]);
|
|
441
513
|
/**
|
|
442
514
|
* The state root the daemon named in its own `hello` (additive since 1.15.0), or null
|
|
443
|
-
* when no handshake
|
|
444
|
-
*
|
|
515
|
+
* when no handshake *on the connection this transport currently holds* answered that key.
|
|
516
|
+
* `null` means "this daemon does not report it" — never "therefore it is the home
|
|
517
|
+
* default", and never "therefore it is what the daemon before this one said"; the field is
|
|
518
|
+
* cleared when a connection opens, which is the only way a reconnecting transport can
|
|
519
|
+
* answer "not measured" about a producer it has just replaced. Callers say which of the
|
|
520
|
+
* two they used.
|
|
445
521
|
*/
|
|
446
522
|
private helloStateRoot;
|
|
447
523
|
get reportedStateRoot(): string | null;
|
|
@@ -634,6 +710,12 @@ export declare function unixSocketEngineClient(socketPath: string, options?: {
|
|
|
634
710
|
surface?: ShellSurface;
|
|
635
711
|
/** Daemon methods this shell forwards; see {@link EngineJsonRpcClient}'s last parameter. */
|
|
636
712
|
expectedDaemonMethods?: readonly string[];
|
|
713
|
+
/** Seam for {@link trustSocket}; production callers never pass it — the real stat is the default. */
|
|
714
|
+
trust?: (target: string) => {
|
|
715
|
+
code: string;
|
|
716
|
+
message: string;
|
|
717
|
+
remedy: string;
|
|
718
|
+
} | null;
|
|
637
719
|
}): EngineJsonRpcClient;
|
|
638
720
|
/**
|
|
639
721
|
* Build a client over an existing LineIo (used by tests with a fake
|
package/dist/errors.d.ts
CHANGED
|
@@ -103,6 +103,24 @@ export declare const GP_E_NO_USER_RECORD = "GP_E_NO_USER_RECORD";
|
|
|
103
103
|
* 而不是 4xx。
|
|
104
104
|
*/
|
|
105
105
|
export declare const GP_E_STATE_ROOT_REFUSED = "GP_E_STATE_ROOT_REFUSED";
|
|
106
|
+
/**
|
|
107
|
+
* Shell-only: the socket this shell is about to write into is not one it can call the
|
|
108
|
+
* engine's. The engine socket is `chmod 0600` with **no peer authentication** (SECURITY.md:
|
|
109
|
+
* same uid = full authority), so the path is a trust root, not just a location: a leaf another
|
|
110
|
+
* account created, a leaf any other account may write to, or a directory any other account may
|
|
111
|
+
* replace the entry in all mean the bytes this shell reads back are not evidence of what the
|
|
112
|
+
* engine said — and every verdict this product publishes is built from those bytes.
|
|
113
|
+
*
|
|
114
|
+
* The judgement is made before the first byte leaves this process, so a refusal carries no
|
|
115
|
+
* claim that anything was executed. It deliberately does NOT reuse `GP_E_ENGINE_UNREACHABLE`:
|
|
116
|
+
* that code's remedy names a daemon restart, and restarting a service that is mid-`act` on the
|
|
117
|
+
* user's screen is an action this measurement does not license — the thing listening there may
|
|
118
|
+
* be running perfectly well, just not as the engine.
|
|
119
|
+
*
|
|
120
|
+
* It is also not in `SHELL_REQUEST_REFUSAL_CODES` below: this is not the caller's argument, so
|
|
121
|
+
* the HTTP surface answers it as 503 like the other infrastructure codes.
|
|
122
|
+
*/
|
|
123
|
+
export declare const GP_E_SOCKET_TRUST = "GP_E_SOCKET_TRUST";
|
|
106
124
|
/**
|
|
107
125
|
* Shell-only: a declared review dimension is malformed. The daemon has no dimension
|
|
108
126
|
* vocabulary at all — a dimension is the harness's annotation on a call, never an engine
|
package/dist/http-gateway-cli.js
CHANGED
|
@@ -194,6 +194,7 @@ var GP_E_ENGINE_BACKLOG = "GP_E_ENGINE_BACKLOG";
|
|
|
194
194
|
var GP_E_UNKNOWN = "GP_E_UNKNOWN";
|
|
195
195
|
var GP_E_NO_USER_RECORD = "GP_E_NO_USER_RECORD";
|
|
196
196
|
var GP_E_STATE_ROOT_REFUSED = "GP_E_STATE_ROOT_REFUSED";
|
|
197
|
+
var GP_E_SOCKET_TRUST = "GP_E_SOCKET_TRUST";
|
|
197
198
|
var GP_E_DIMENSION = "GP_E_DIMENSION";
|
|
198
199
|
function formatToolError(code, message, remedy) {
|
|
199
200
|
return `${code}: ${message} | remedy: ${remedy}`;
|
|
@@ -219,13 +220,17 @@ function daemonUnreachableRemedy() {
|
|
|
219
220
|
return `${daemonRestoreCommand()}, then retry`;
|
|
220
221
|
}
|
|
221
222
|
var ENGINE_SOCKET_ENV = "GLASSPANE_ENGINE_SOCK";
|
|
223
|
+
var LAUNCHD_JOB_LABEL = "com.glasspane.daemon";
|
|
222
224
|
function defaultSocketPath() {
|
|
223
225
|
const named2 = socketOverride(process.env[ENGINE_SOCKET_ENV]);
|
|
224
226
|
if (named2 === null) {
|
|
225
|
-
return
|
|
227
|
+
return homeDefaultSocketPath();
|
|
226
228
|
}
|
|
227
229
|
return named2;
|
|
228
230
|
}
|
|
231
|
+
function homeDefaultSocketPath() {
|
|
232
|
+
return path.join(os.homedir(), ".glasspane", "engine.sock");
|
|
233
|
+
}
|
|
229
234
|
function socketOverride(value) {
|
|
230
235
|
if (value === void 0 || value.trim() === "") {
|
|
231
236
|
return null;
|
|
@@ -239,6 +244,65 @@ function refuseEmptySocketPath(value, flag) {
|
|
|
239
244
|
);
|
|
240
245
|
}
|
|
241
246
|
}
|
|
247
|
+
function trustSocket(target, read = (p) => fs2.statSync(p), euid = process.geteuid?.() ?? null) {
|
|
248
|
+
const refusal = (message, remedy) => ({ code: GP_E_SOCKET_TRUST, message, remedy });
|
|
249
|
+
const job = "`launchctl print gui/$(id -u)/" + LAUNCHD_JOB_LABEL + "`";
|
|
250
|
+
if (euid === null) {
|
|
251
|
+
return refusal(
|
|
252
|
+
`this runtime answers no geteuid(), so it cannot say whether the engine socket at ${target} belongs to the account running it`,
|
|
253
|
+
'run this shell under node on macOS (the platform this product ships on); the check is `node -e "console.log(process.geteuid())"` \u2014 it must print a number'
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
let socket;
|
|
257
|
+
try {
|
|
258
|
+
socket = read(target);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (error.code === "ENOENT") return null;
|
|
261
|
+
return refusal(
|
|
262
|
+
`the engine socket at ${target} could not be inspected (${error.code ?? "unknown error"}), so this process cannot say whether the thing listening there is the engine`,
|
|
263
|
+
`make the path stat-able (\`ls -ld ${quoteShellArg(target)}\`); ${job} reads the running job's own arguments, which is how to find the socket the engine actually bound \u2014 nothing is restarted by this answer`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
if (!socket.isSocket()) {
|
|
267
|
+
return refusal(
|
|
268
|
+
`${target} is not a socket, so nothing can answer as the engine from it`,
|
|
269
|
+
`see what is really at that path with \`ls -l ${quoteShellArg(target)}\`, then point ${ENGINE_SOCKET_ENV} at the socket the engine binds (default ${homeDefaultSocketPath()}); ${job} reads the running job's arguments and is the way to check that root without restarting anything`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const directory = path.dirname(target);
|
|
273
|
+
let dir;
|
|
274
|
+
try {
|
|
275
|
+
dir = read(directory);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
return refusal(
|
|
278
|
+
`the directory holding the engine socket (${directory}) could not be inspected (${error.code ?? "unknown error"}), so this process cannot say who may replace ${target}`,
|
|
279
|
+
`make it readable with \`ls -ld ${quoteShellArg(directory)}\`; ${job} prints the root the job really runs under, and this answer authorises no restart`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
for (const [entry, place, kind] of [
|
|
283
|
+
[socket, target, "socket"],
|
|
284
|
+
[dir, directory, "directory"]
|
|
285
|
+
]) {
|
|
286
|
+
if (entry.uid === euid) continue;
|
|
287
|
+
return refusal(
|
|
288
|
+
`the engine ${kind} ${place} belongs to uid ${entry.uid}, not to this process (uid ${euid}), so whatever listens there was not placed there by this account`,
|
|
289
|
+
`run this shell as the account that owns \`glasspaned\`, or point ${ENGINE_SOCKET_ENV} at the socket that account bound (default ${homeDefaultSocketPath()}); check the owner with \`ls -ld ${quoteShellArg(place)}\``
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
if (socket.mode & 18) {
|
|
293
|
+
return refusal(
|
|
294
|
+
`the engine socket ${target} carries mode ${(socket.mode & 4095).toString(8)}, which lets another account send requests to it \u2014 an answer from there is not evidence of what the engine said`,
|
|
295
|
+
`tighten it to owner-only with \`chmod 600 ${quoteShellArg(target)}\` \u2014 that is the mode the engine binds with; to confirm the socket belongs to the service rather than to someone else, read \`ls -l ${quoteShellArg(target)}\``
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
if (dir.mode & 18) {
|
|
299
|
+
return refusal(
|
|
300
|
+
`the directory holding the engine socket (${directory}) carries mode ${(dir.mode & 4095).toString(8)}, so another account can create or replace ${target}; this process cannot tell the engine's socket from one planted next to it`,
|
|
301
|
+
`make it owner-only with \`chmod 700 ${quoteShellArg(directory)}\`; ${job} prints the state root the job really uses, and no restart is authorised by this answer`
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
242
306
|
var ENGINE_TIMEOUT_MS = 1e4;
|
|
243
307
|
var CALLER_VISIBLE_CEILING_MS = 5e4;
|
|
244
308
|
var ENGINE_DEADLINES_MS = {
|
|
@@ -372,7 +436,7 @@ function livenessProbeGuide() {
|
|
|
372
436
|
return LIVENESS_PROBE_OUTCOMES.map((outcome) => `${outcome} \u2014 ${livenessProbeDecision(outcome)}`).join("; ");
|
|
373
437
|
}
|
|
374
438
|
function lateReplyRoute(surface) {
|
|
375
|
-
return surface === "mcp" ? "the original reply, when it lands, is written to this server's log (stderr) *and* its operationId is recorded in this session's trail, so a later gp_recent_reports lists the operation that ran instead of telling you to run it again \u2014 **while this server still tracks the request**: the window is bounded (" + LATE_REPLY_RETENTION + " timed-out requests, and an eviction is logged), a re-attach in between supersedes it (also logged, with the operationIds it dropped), a transport that ends first is logged the same way with the requests it stopped tracking, and if this process has exited nothing will be recorded at all" : "the original reply, when it lands, is written to this gateway's stderr
|
|
439
|
+
return surface === "mcp" ? "the original reply, when it lands, is written to this server's log (stderr) *and* its operationId is recorded in this session's trail, so a later gp_recent_reports lists the operation that ran instead of telling you to run it again \u2014 **while this server still tracks the request**: the window is bounded (" + LATE_REPLY_RETENTION + " timed-out requests, and an eviction is logged), a re-attach in between supersedes it (also logged, with the operationIds it dropped), a transport that ends first is logged the same way with the requests it stopped tracking, and if this process has exited nothing will be recorded at all" : "the original reply, when it lands, is written to this gateway's stderr as a fact about the frame and never as its text: the line reads `late engine reply to '<method>': the engine did answer, with a <N>-byte body (sha256 <12 hex>)` and then states that the body is on-screen accessibility content whose text is not written to this log. The operationId is on that line only when the reply carries one this shell's archive grammar accepts, printed as `, for <operationId>` right after the digest \u2014 read it there and fetch that pack with GET /v1/evidence/<operationId> or POST /v1/tools/last_evidence {operationId}; a reply that names no archive-shaped id leaves nothing on the line to read off, and the digest is then the only correlation this surface can offer. The bytes themselves stay in the daemon's evidence archive under the state root, which this gateway does not copy \u2014 the tracking window is bounded (" + LATE_REPLY_RETENTION + " timed-out requests, and an eviction is logged, as is a transport that ends before the reply lands), and this gateway keeps no operation trail of its own";
|
|
376
440
|
}
|
|
377
441
|
var NARROWING_AUTHORITY = {
|
|
378
442
|
mcp: "the gp_* tool that took this call publishes its own parameters, and their floors, in the schema shown beside that tool \u2014 read it there, not here",
|
|
@@ -462,6 +526,8 @@ var EngineJsonRpcClient = class {
|
|
|
462
526
|
for (const entry of this.pending.values()) {
|
|
463
527
|
entry.handedOff = true;
|
|
464
528
|
}
|
|
529
|
+
this.helloStateRoot = null;
|
|
530
|
+
this.helloVersion = null;
|
|
465
531
|
this.handshake();
|
|
466
532
|
});
|
|
467
533
|
}
|
|
@@ -499,8 +565,12 @@ var EngineJsonRpcClient = class {
|
|
|
499
565
|
pending = /* @__PURE__ */ new Map();
|
|
500
566
|
/**
|
|
501
567
|
* The state root the daemon named in its own `hello` (additive since 1.15.0), or null
|
|
502
|
-
* when no handshake
|
|
503
|
-
*
|
|
568
|
+
* when no handshake *on the connection this transport currently holds* answered that key.
|
|
569
|
+
* `null` means "this daemon does not report it" — never "therefore it is the home
|
|
570
|
+
* default", and never "therefore it is what the daemon before this one said"; the field is
|
|
571
|
+
* cleared when a connection opens, which is the only way a reconnecting transport can
|
|
572
|
+
* answer "not measured" about a producer it has just replaced. Callers say which of the
|
|
573
|
+
* two they used.
|
|
504
574
|
*/
|
|
505
575
|
helloStateRoot = null;
|
|
506
576
|
get reportedStateRoot() {
|
|
@@ -608,6 +678,10 @@ var EngineJsonRpcClient = class {
|
|
|
608
678
|
}
|
|
609
679
|
} catch (error) {
|
|
610
680
|
this.pending.delete(id);
|
|
681
|
+
if (error instanceof EngineCallError) {
|
|
682
|
+
this.reject(entry, error);
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
611
685
|
this.reject(entry, new EngineCallError(
|
|
612
686
|
GP_E_ENGINE_UNREACHABLE,
|
|
613
687
|
`cannot send '${method}' to the engine daemon: ${error.message}`,
|
|
@@ -938,9 +1012,9 @@ var EngineJsonRpcClient = class {
|
|
|
938
1012
|
if (version !== "") {
|
|
939
1013
|
this.helloVersion = version;
|
|
940
1014
|
}
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
943
|
-
this.helloStateRoot =
|
|
1015
|
+
const reportedRoot2 = typeof report.stateRoot === "string" ? report.stateRoot.trim() : "";
|
|
1016
|
+
if (reportedRoot2 !== "") {
|
|
1017
|
+
this.helloStateRoot = reportedRoot2;
|
|
944
1018
|
}
|
|
945
1019
|
const protocol = typeof report.protocolVersion === "string" ? report.protocolVersion : null;
|
|
946
1020
|
if (protocol === null) {
|
|
@@ -1008,12 +1082,14 @@ function operationIdOf(result) {
|
|
|
1008
1082
|
return typeof result === "object" && result !== null ? result.operationId : void 0;
|
|
1009
1083
|
}
|
|
1010
1084
|
var ReconnectingSocketIo = class {
|
|
1011
|
-
constructor(socketPath, open) {
|
|
1085
|
+
constructor(socketPath, open, trust = trustSocket) {
|
|
1012
1086
|
this.socketPath = socketPath;
|
|
1013
1087
|
this.open = open;
|
|
1088
|
+
this.trust = trust;
|
|
1014
1089
|
}
|
|
1015
1090
|
socketPath;
|
|
1016
1091
|
open;
|
|
1092
|
+
trust;
|
|
1017
1093
|
inner = null;
|
|
1018
1094
|
closed = false;
|
|
1019
1095
|
messageHandler = null;
|
|
@@ -1051,6 +1127,10 @@ var ReconnectingSocketIo = class {
|
|
|
1051
1127
|
if (this.inner) {
|
|
1052
1128
|
return this.inner;
|
|
1053
1129
|
}
|
|
1130
|
+
const untrusted = this.trust(this.socketPath);
|
|
1131
|
+
if (untrusted) {
|
|
1132
|
+
throw new EngineCallError(untrusted.code, untrusted.message, untrusted.remedy);
|
|
1133
|
+
}
|
|
1054
1134
|
const socket = this.open(this.socketPath);
|
|
1055
1135
|
const io = new StreamLineIo(socket, socket);
|
|
1056
1136
|
io.onMessage((line) => this.messageHandler?.(line));
|
|
@@ -1079,7 +1159,7 @@ var ReconnectingSocketIo = class {
|
|
|
1079
1159
|
function unixSocketEngineClient(socketPath, options = {}) {
|
|
1080
1160
|
const open = options.open ?? ((target) => net.createConnection(target));
|
|
1081
1161
|
return new EngineJsonRpcClient(
|
|
1082
|
-
new ReconnectingSocketIo(socketPath, open),
|
|
1162
|
+
new ReconnectingSocketIo(socketPath, open, options.trust ?? trustSocket),
|
|
1083
1163
|
void 0,
|
|
1084
1164
|
options.identity ?? null,
|
|
1085
1165
|
options.callerCeilingMs ?? CALLER_VISIBLE_CEILING_MS,
|
|
@@ -2102,6 +2182,7 @@ var CA_ROOTS_STATUSES = ["ok", "probe-failed", "empty", "unavailable", "write-un
|
|
|
2102
2182
|
var KNOWN_CA_ROOTS_STATUSES = new Set(CA_ROOTS_STATUSES);
|
|
2103
2183
|
var RUNTIME_STATUSES = ["refreshed", "failed", "kept", "skipped"];
|
|
2104
2184
|
var KNOWN_RUNTIME_STATUSES = new Set(RUNTIME_STATUSES);
|
|
2185
|
+
var UPDATE_STATE_MAX_BYTES = 1 << 20;
|
|
2105
2186
|
|
|
2106
2187
|
// src/audit-session.ts
|
|
2107
2188
|
var ARRIVAL_ORDER_MECHANISM = "which request it answers is inferred from arrival order (the daemon answers in the order it received them) and could not be confirmed by an echoed id";
|
|
@@ -2451,7 +2532,11 @@ function saveProjects(filePath, entries) {
|
|
|
2451
2532
|
try {
|
|
2452
2533
|
fs4.mkdirSync(dir, { recursive: true, mode: STATE_DIR_MODE });
|
|
2453
2534
|
tightenMode(dir, STATE_DIR_MODE, "directory");
|
|
2454
|
-
const fd = fs4.openSync(
|
|
2535
|
+
const fd = fs4.openSync(
|
|
2536
|
+
tmpPath,
|
|
2537
|
+
fs4.constants.O_WRONLY | fs4.constants.O_CREAT | fs4.constants.O_EXCL | fs4.constants.O_NOFOLLOW,
|
|
2538
|
+
STATE_FILE_MODE
|
|
2539
|
+
);
|
|
2455
2540
|
try {
|
|
2456
2541
|
fs4.writeFileSync(fd, JSON.stringify(entries, null, 2), "utf8");
|
|
2457
2542
|
fs4.fsyncSync(fd);
|
|
@@ -2512,6 +2597,7 @@ function projectSet(args, daemonStateRoot) {
|
|
|
2512
2597
|
const snapshot = loadRegistry(filePath);
|
|
2513
2598
|
const { projects, discarded, baseline: openedAs } = requireUsableRegistry(filePath, snapshot);
|
|
2514
2599
|
let entry;
|
|
2600
|
+
let changedByThisCall = true;
|
|
2515
2601
|
const projectId = args.projectId;
|
|
2516
2602
|
if (projectId) {
|
|
2517
2603
|
const existing = projects.find((p) => p.projectId === projectId);
|
|
@@ -2519,6 +2605,7 @@ function projectSet(args, daemonStateRoot) {
|
|
|
2519
2605
|
throw new ProjectRegistryError(GP_E_NOT_FOUND, `unknown projectId ${projectId}`);
|
|
2520
2606
|
}
|
|
2521
2607
|
entry = applyPatch(existing, args);
|
|
2608
|
+
changedByThisCall = canonicalJson2(existing) !== canonicalJson2(entry);
|
|
2522
2609
|
assertSingleIdentity(entry, args, existing, filePath);
|
|
2523
2610
|
projects[projects.indexOf(existing)] = entry;
|
|
2524
2611
|
} else {
|
|
@@ -2540,8 +2627,8 @@ function projectSet(args, daemonStateRoot) {
|
|
|
2540
2627
|
saveProjects(filePath, projects);
|
|
2541
2628
|
return {
|
|
2542
2629
|
...entry,
|
|
2543
|
-
requiresDaemonRestart:
|
|
2544
|
-
daemonRestartNotice: daemonRestartNotice(filePath, daemonStateRoot),
|
|
2630
|
+
requiresDaemonRestart: daemonRestartPending({ filePath, daemonStateRoot, changed: changedByThisCall }),
|
|
2631
|
+
daemonRestartNotice: daemonRestartNotice(filePath, daemonStateRoot, changedByThisCall),
|
|
2545
2632
|
...discarded !== void 0 ? { discardedUnreadableFile: discarded } : {}
|
|
2546
2633
|
};
|
|
2547
2634
|
}
|
|
@@ -2591,17 +2678,36 @@ function damagedStoredIdentityMessage(entry, args, filePath) {
|
|
|
2591
2678
|
const fromCall = args.bundleId !== void 0 && args.pid !== void 0 ? "this call named both bundleId and pid" : args.bundleId !== void 0 ? `this call named only bundleId (${args.bundleId})` : args.pid !== void 0 ? `this call named only pid (${args.pid})` : "this call named neither bundleId nor pid";
|
|
2592
2679
|
return `projects.json at ${filePath} already stored two identities on projectId ${entry.projectId} \u2014 bundleId (${entry.bundleId}) and pid (${entry.pid}) \u2014 and ${fromCall}, so this call did not create that shape, it inherited it. Nothing was written: the entry stays as the other writer left it. The damage is a rule about the *combination*, which the daemon enforces on its own create()/update() and the file's shape check cannot see, so it survives a load and reaches the first call that tries to save the entry again. Two identities on one projectId means \`gp_attach\` would match that project against two different apps. Put the entry back with the one write that is accepted here: gp_project_set with projectId ${entry.projectId}, its current displayName, and null for the half that is not this app (pid: null keeps bundleId, bundleId: null keeps pid) \u2014 naming the half to keep is not required, clearing one is enough. Check which half the app actually runs as first: gp_project_list shows both, \`ps -p <pid> -o comm=\` names the process a stored pid points at (nothing back means that process is gone, which is the usual sign of a stale pair), and a bundle id is the app's own identifier. Do not hand-edit the file: the running service holds its own copy of the table and rewrites it, so a hand repair disappears at its next save.`;
|
|
2593
2680
|
}
|
|
2594
|
-
function
|
|
2595
|
-
const named2 = typeof daemonStateRoot === "string"
|
|
2681
|
+
function reportedRoot(daemonStateRoot) {
|
|
2682
|
+
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
2683
|
+
return named2 === "" ? null : named2;
|
|
2684
|
+
}
|
|
2685
|
+
function daemonRestartPending(facts) {
|
|
2686
|
+
if (!facts.changed) {
|
|
2687
|
+
return false;
|
|
2688
|
+
}
|
|
2689
|
+
const named2 = reportedRoot(facts.daemonStateRoot);
|
|
2690
|
+
if (named2 === null) {
|
|
2691
|
+
return null;
|
|
2692
|
+
}
|
|
2693
|
+
return path3.resolve(facts.filePath) === path3.resolve(daemonProjectsPath(named2));
|
|
2694
|
+
}
|
|
2695
|
+
function daemonRestartNotice(filePath, daemonStateRoot, changed = true) {
|
|
2696
|
+
const named2 = reportedRoot(daemonStateRoot);
|
|
2596
2697
|
const daemonPath = daemonProjectsPath(named2);
|
|
2698
|
+
const pending = daemonRestartPending({ filePath, daemonStateRoot, changed });
|
|
2699
|
+
const paired = ` The field and this sentence are the same measurement: this reply carries \`requiresDaemonRestart: ${JSON.stringify(pending)}\`, computed from these two facts (which file this write reached, and which root the service named for itself) rather than asserted.`;
|
|
2597
2700
|
const authority = named2 === null ? "its default root is the folder under this user's home record (where a service started with no --state-dir looks)" : `its root is the one the running daemon named in its hello (${named2})`;
|
|
2598
2701
|
if (path3.resolve(filePath) !== path3.resolve(daemonPath)) {
|
|
2599
|
-
return `Saved in ${filePath}. The background service does not read this path because of anything in its own configuration: ${authority}. It loads ${daemonPath} once when it starts, and ${PROJECTS_FILE_ENV} \u2014 the variable that pointed this write here \u2014 is honoured by this MCP shell only, so as far as the service's own configuration goes it never reads that file, and no restart of the service will make it load this one. ${rootDiscriminator()} To land the entry where that root looks: unset ${PROJECTS_FILE_ENV} for this shell (or point it at ${daemonPath}) and repeat gp_project_set, then restart the background service so it reloads \u2014 ${restartCommand()}`;
|
|
2702
|
+
return `Saved in ${filePath}. The background service does not read this path because of anything in its own configuration: ${authority}. It loads ${daemonPath} once when it starts, and ${PROJECTS_FILE_ENV} \u2014 the variable that pointed this write here \u2014 is honoured by this MCP shell only, so as far as the service's own configuration goes it never reads that file, and no restart of the service will make it load this one. ${rootDiscriminator()} To land the entry where that root looks: unset ${PROJECTS_FILE_ENV} for this shell (or point it at ${daemonPath}) and repeat gp_project_set, then restart the background service so it reloads \u2014 ${restartCommand()}.${paired}`;
|
|
2600
2703
|
}
|
|
2601
2704
|
if (named2 !== null) {
|
|
2602
|
-
return `Saved in ${filePath} \u2014 the projects file of the state root the running daemon reported in its own hello (${named2}), so this is the file that service loads.
|
|
2705
|
+
return `Saved in ${filePath} \u2014 the projects file of the state root the running daemon reported in its own hello (${named2}), so this is the file that service loads. ${reloadSentence(changed)}: ${restartCommand()}.${paired}`;
|
|
2603
2706
|
}
|
|
2604
|
-
return `Saved in ${filePath}, the projects file under the home record this user's state root defaults to. If this is the root the service was started on \u2014 which is not knowable from here, because this daemon's hello reported no stateRoot \u2014 then
|
|
2707
|
+
return `Saved in ${filePath}, the projects file under the home record this user's state root defaults to. If this is the root the service was started on \u2014 which is not knowable from here, because this daemon's hello reported no stateRoot \u2014 then ${reloadSentence(changed)}: ${restartCommand()}. ${rootDiscriminator()}${paired}`;
|
|
2708
|
+
}
|
|
2709
|
+
function reloadSentence(changed) {
|
|
2710
|
+
return changed ? "the running background service loaded that file once when it started, so gp_attach will keep returning GP_E_NOT_FOUND for this projectId until the service restarts" : "this call rewrote the entry that file already held, field for field, so it left no new registration for the service to pick up \u2014 restarting changes nothing about an entry that was already there";
|
|
2605
2711
|
}
|
|
2606
2712
|
function rootDiscriminator() {
|
|
2607
2713
|
return 'Tell the two cases apart with the service\'s own answer: gp_project_list reads the file this call wrote, so an entry it lists is on disk, and gp_attach {projectId} is answered by the running service \u2014 an entry the list shows plus an attach that answers GP_E_NOT_FOUND means the service is loading a different projects.json than the one this write reached, not that the write failed. Which file the running service loads is not something this shell guesses from $HOME: `glasspaned --state-dir <root>` moves it to <root>/projects.json, and the daemon reports the root it resolved \u2014 `hello` names the state root under its `stateRoot` key. A daemon predating 1.15.0 omits the key, and an omitted key means "that daemon does not report it", never "so it must be the home default": for those binaries the discriminator below is the only read. Cross-check either way \u2014 `launchctl print gui/' + currentUid() + "/com.glasspane.daemon` prints the arguments the job was started with. If those arguments name a --state-dir, the entry has to go into that root's projects.json (repeat gp_project_set with " + PROJECTS_FILE_ENV + " pointed at <that root>/projects.json \u2014 this shell judges that override with the same path gates it judges every root it writes, because writing there means creating the directory and bringing it to 0700, so a shared scratch tree, a directory this user does not own, or a world-writable one is refused with " + GP_E_STATE_ROOT_REFUSED + " and nothing is written; such a service root is not a place this surface can register into, and the fix is to run the service on a root both sides accept): no restart of the service will make it read anywhere else, so restarting again changes nothing. If they name no --state-dir, the service is on the default root and simply predates this write, and one restart with the command in this notice is what surfaces it.";
|
|
@@ -3099,7 +3205,7 @@ var TOOL_SPECS = [
|
|
|
3099
3205
|
},
|
|
3100
3206
|
{
|
|
3101
3207
|
name: "gp_probe_status",
|
|
3102
|
-
description: "List GlassPaneProbe connections and whether the attached app has a live probe \u2014 probe presence is what makes T4/T5/T7/T8 verdicts and tier-1 checkpoint restores decidable. `attachedHasProbe` is that yes/no for the attached app; `probes` holds **live** registrations only (every row `connected: true`), so a probe that dropped is absent from it rather than flagged inside it: read `recentDisconnections` for that history (`pid`, `disconnectReason`, `disconnectedAt`, per-pid `drops`), and `disconnections` is just the total count since start. Each live row can also carry the frame-accounting that makes a zero verdict readable: `stateFramesUnmappedSource` (daemon-side, per pid), and `droppedEvents` / `droppedWrites` / `rejectedKeys` / `droppedInboundFrames` / `droppedInboundLines` as the probe itself reported them \u2014 those are **absent when unreported**, which is not the same as zero, and `unmapableStateFrames` is the daemon-side total that survives a disconnect. Two more daemon-side losses are readable here: `ringEvictedEvents` on a live row (that pid's events dropped when its 512-event ring overflowed) and `ringEvictedEventsTotal` for the process \u2014 a nonzero one means that window's `hitCount` and `handlers` are a **lower bound**, not a complete measurement, and the archived pack carries the same caveat under `circuitBreaker.reason`. A duration the probe read but this wire cannot carry is the fourth loss with its own reading: `durationOverflowFrames` on a live row counts the `handlerDurationOverflow` frames this daemon ingested for that pid, `durationOverflowCount` on the same row is the probe's own lifetime figure (**absent when the probe never reported one**, which is not a measured zero), and `durationOverflowFramesTotal` is the process-wide count that survives the disconnect. Those frames are lost readings, not protocol violations: they never enter the event ring, so they never raise `hitCount`, and they are counted apart from the daemon's malformed frames \u2014 a `hitCount` of 0 beside a nonzero overflow count means the slow call happened and only its duration was unreadable. The same reply is where the T9 degradation watch is readable without performing an action, under `degradation` (absent when this daemon runs without T9 wired): `tier` is `healthy` / `watch` / `degrading`, and `judged` says whether that tier is a measurement at all \u2014 `judged: false` with `tier: healthy` means the window was too thin or too short to read, **not** that the app is clean; `basis` spells out which of those it is with the numbers, alongside `samples`/`minimumSamples` and `spanSeconds`/`minimumSpanSeconds`. `longSession` marks the window spanning at least the long-session threshold; it is context for the trend, and it never changes `tier` by itself. `drivers` appears only when something is trending, and `slopes` carries only the channels that produced one (`pingMsPerSec`, `memoryBytesPerSec`, `handlesPerSec`) \u2014 a channel missing from `slopes` was never read, which is not a rate of zero.",
|
|
3208
|
+
description: "List GlassPaneProbe connections and whether the attached app has a live probe \u2014 probe presence is what makes T4/T5/T7/T8 verdicts and tier-1 checkpoint restores decidable. `probeListener` says whether this daemon process has a socket that could accept a probe at all: `live`, or `absent` with the reason the launcher declared (`absent (--no-probe)`, `absent (name owned by another listener)`, `absent (no probe listener in this process)`). Read it FIRST: with the surface absent, an empty `probes` list is not \"the app has no probe\" \u2014 instrumenting the app would attach it to some other engine's socket, and the evidence that engine records is not the pack this reply answers about. `attachedHasProbe` is that yes/no for the attached app; `probes` holds **live** registrations only (every row `connected: true`), so a probe that dropped is absent from it rather than flagged inside it: read `recentDisconnections` for that history (`pid`, `disconnectReason`, `disconnectedAt`, per-pid `drops`), and `disconnections` is just the total count since start. Each live row can also carry the frame-accounting that makes a zero verdict readable: `stateFramesUnmappedSource` (daemon-side, per pid), and `droppedEvents` / `droppedWrites` / `rejectedKeys` / `droppedInboundFrames` / `droppedInboundLines` as the probe itself reported them \u2014 those are **absent when unreported**, which is not the same as zero, and `unmapableStateFrames` is the daemon-side total that survives a disconnect. Two more daemon-side losses are readable here: `ringEvictedEvents` on a live row (that pid's events dropped when its 512-event ring overflowed) and `ringEvictedEventsTotal` for the process \u2014 a nonzero one means that window's `hitCount` and `handlers` are a **lower bound**, not a complete measurement, and the archived pack carries the same caveat under `circuitBreaker.reason`. A duration the probe read but this wire cannot carry is the fourth loss with its own reading: `durationOverflowFrames` on a live row counts the `handlerDurationOverflow` frames this daemon ingested for that pid, `durationOverflowCount` on the same row is the probe's own lifetime figure (**absent when the probe never reported one**, which is not a measured zero), and `durationOverflowFramesTotal` is the process-wide count that survives the disconnect. Those frames are lost readings, not protocol violations: they never enter the event ring, so they never raise `hitCount`, and they are counted apart from the daemon's malformed frames \u2014 a `hitCount` of 0 beside a nonzero overflow count means the slow call happened and only its duration was unreadable. The same reply is where the T9 degradation watch is readable without performing an action, under `degradation` (absent when this daemon runs without T9 wired): `tier` is `healthy` / `watch` / `degrading`, and `judged` says whether that tier is a measurement at all \u2014 `judged: false` with `tier: healthy` means the window was too thin or too short to read, **not** that the app is clean; `basis` spells out which of those it is with the numbers, alongside `samples`/`minimumSamples` and `spanSeconds`/`minimumSpanSeconds`. `longSession` marks the window spanning at least the long-session threshold; it is context for the trend, and it never changes `tier` by itself. `drivers` appears only when something is trending, and `slopes` carries only the channels that produced one (`pingMsPerSec`, `memoryBytesPerSec`, `handlesPerSec`) \u2014 a channel missing from `slopes` was never read, which is not a rate of zero.",
|
|
3103
3209
|
engineMethod: "probe_status",
|
|
3104
3210
|
inputSchema: {
|
|
3105
3211
|
type: "object",
|
|
@@ -3349,6 +3455,22 @@ async function readTrail(session, turn, limit) {
|
|
|
3349
3455
|
turn.release();
|
|
3350
3456
|
}
|
|
3351
3457
|
}
|
|
3458
|
+
function internalFaultAccount(where, error, surface = "tool") {
|
|
3459
|
+
const type = error instanceof Error ? error.constructor?.name ?? "Error" : typeof error;
|
|
3460
|
+
return {
|
|
3461
|
+
wire: `internal shell error (failure type ${type}; the message is on this process's stderr, not on this frame)`,
|
|
3462
|
+
detail: `[glasspane-mcp] ${where}: internal ${type} \u2014 ${String(error)} (withheld from the ${surface} frame: a description of an internal failure names files and symbols this frame does not publish; the line above is the one to hand over)`
|
|
3463
|
+
};
|
|
3464
|
+
}
|
|
3465
|
+
function reportInternalFault(where, error, surface = "tool") {
|
|
3466
|
+
const account = internalFaultAccount(where, error, surface);
|
|
3467
|
+
try {
|
|
3468
|
+
process.stderr.write(`${account.detail}
|
|
3469
|
+
`);
|
|
3470
|
+
} catch {
|
|
3471
|
+
}
|
|
3472
|
+
return { wire: account.wire };
|
|
3473
|
+
}
|
|
3352
3474
|
function shellFaultRemedy(engineMethod) {
|
|
3353
3475
|
const readRoute = "read what happened instead of performing it again: gp_recent_reports lists the operations this session recorded, gp_last_evidence {operationId} returns one in full, and gp_probe_status reads the daemon's own self-report on this same connection \u2014 all three are requests this shell does not treat as unsafe to repeat";
|
|
3354
3476
|
const reportRoute = "this fault was raised inside the MCP shell, so it is in no daemon log: this process's stderr belongs to whoever started this server, and that line is the only text naming the failure, so hand it to them verbatim. A daemon restart is not authorised by an answer the daemon never made";
|
|
@@ -3461,7 +3583,7 @@ async function captureView(args, context) {
|
|
|
3461
3583
|
return {
|
|
3462
3584
|
content: [{ type: "text", text: formatToolError(
|
|
3463
3585
|
GP_E_INTERNAL,
|
|
3464
|
-
|
|
3586
|
+
reportInternalFault("the capture_view route", error).wire,
|
|
3465
3587
|
shellFaultRemedy("capture_view")
|
|
3466
3588
|
) }],
|
|
3467
3589
|
isError: true
|
|
@@ -3544,7 +3666,7 @@ function mapProjectError(error) {
|
|
|
3544
3666
|
return {
|
|
3545
3667
|
content: [{ type: "text", text: formatToolError(
|
|
3546
3668
|
GP_E_INTERNAL,
|
|
3547
|
-
|
|
3669
|
+
reportInternalFault("a project-registry write", error).wire,
|
|
3548
3670
|
projectErrorRemedy(GP_E_INTERNAL)
|
|
3549
3671
|
) }],
|
|
3550
3672
|
isError: true
|
|
@@ -3573,7 +3695,7 @@ function projectErrorRemedy(code) {
|
|
|
3573
3695
|
return "this process has no entry in the password database, so neither it nor the daemon can know which user's state directory is meant; run the shell as a user that has one (`id -u` / `dscl . -read /Users/<name> NFSHomeDirectory`). Nothing in ~/.glasspane needs repairing for this";
|
|
3574
3696
|
}
|
|
3575
3697
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
3576
|
-
return "the running service named a state root this shell will not create or re-permission, so nothing was read or written by this call:
|
|
3698
|
+
return "the running service named a state root this shell will not create or re-permission, so nothing was read or written by this call: the refused root is named in the message above, so nothing has to be asked again. To see which root the job really starts with, run `launchctl print gui/$(id -u)/com.glasspane.daemon` (read-only \u2014 it prints the job's own arguments), and `glasspaned --state-dir <path> --evidence-stats` echoes that run's `dir` under the root it resolved, which is how to confirm a candidate without writing anything. Then start the service with a directory this install owns (`glasspaned --state-dir <path>`). Do not repair projects.json for this one \u2014 the refusal names a root, not a file, and no path under that root was touched";
|
|
3577
3699
|
}
|
|
3578
3700
|
if (code === GP_E_INTERNAL) {
|
|
3579
3701
|
return `the projects file is the problem, not your arguments: the message above names its path, so read it with ${registryReaders("<that path>")}; repair or restore the damaged entry, and retry \u2014 or set ${FORCE_OVERWRITE_ENV}=1 and call gp_project_set to rebuild the registry from scratch (the unloadable file is moved aside as <path>.unreadable-<id>, never deleted, and every entry still in it is lost). Do not retry the same read-only call unchanged: it will keep failing.`;
|
|
@@ -3862,7 +3984,7 @@ function mapAuditError(error, engineMethod = "last_evidence") {
|
|
|
3862
3984
|
return {
|
|
3863
3985
|
content: [{ type: "text", text: formatToolError(
|
|
3864
3986
|
GP_E_INTERNAL,
|
|
3865
|
-
`
|
|
3987
|
+
reportInternalFault(`an engine call for ${engineMethod}`, error).wire,
|
|
3866
3988
|
shellFaultRemedy(engineMethod)
|
|
3867
3989
|
) }],
|
|
3868
3990
|
isError: true
|
|
@@ -4626,6 +4748,10 @@ function httpStatusForEngineCode(code) {
|
|
|
4626
4748
|
return 504;
|
|
4627
4749
|
case GP_E_REGISTRY_DRIFT:
|
|
4628
4750
|
return 503;
|
|
4751
|
+
// 2026-10-30: an untrusted engine socket is this gateway's own transport judgement —
|
|
4752
|
+
// the HTTP caller's arguments were never the question, so 4xx would send curl back to
|
|
4753
|
+
// a body that is not at fault. Same family as GP_E_ENGINE_UNREACHABLE's 503.
|
|
4754
|
+
case GP_E_SOCKET_TRUST:
|
|
4629
4755
|
case GP_E_STATE_ROOT_REFUSED:
|
|
4630
4756
|
return 503;
|
|
4631
4757
|
case GP_E_PAYLOAD_TOO_LARGE:
|