glasspane-mcp 1.28.0 → 1.29.1
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 +1 -1
- package/dist/engine-client.d.ts +1 -1
- package/dist/http-gateway-cli.js +90 -52
- package/dist/http-gateway.d.ts +14 -0
- package/dist/http-gateway.js +91 -52
- package/dist/index.js +80 -58
- package/dist/io.d.ts +31 -6
- package/dist/project-registry.d.ts +4 -2
- package/dist/stdio-session.d.ts +1 -1
- package/dist/stdio-session.js +80 -58
- 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.29.1";
|
|
30
30
|
};
|
|
31
31
|
export declare const PARSE_ERROR = -32700;
|
|
32
32
|
export declare const INVALID_REQUEST = -32600;
|
package/dist/engine-client.d.ts
CHANGED
|
@@ -684,7 +684,7 @@ export declare class EngineJsonRpcClient {
|
|
|
684
684
|
*
|
|
685
685
|
* The reverse mutation is to interpolate the frame back into any of those seven lines.
|
|
686
686
|
*/
|
|
687
|
-
export declare function frameBodyNotLoggedNote(serializedFrame: string): string;
|
|
687
|
+
export declare function frameBodyNotLoggedNote(serializedFrame: string, wireBytes?: Buffer): string;
|
|
688
688
|
/**
|
|
689
689
|
* A single frame *field* quoted into a log line, bounded.
|
|
690
690
|
*
|
package/dist/http-gateway-cli.js
CHANGED
|
@@ -46,57 +46,77 @@ var LineReader = class {
|
|
|
46
46
|
this.sink = sink;
|
|
47
47
|
}
|
|
48
48
|
sink;
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Bytes of the line in progress, in arrival order. Decoding happens ONCE, at delivery.
|
|
51
|
+
*
|
|
52
|
+
* The previous version decoded every segment on its own (`segment.toString("utf8")`) and
|
|
53
|
+
* concatenated the results into a string. A chunk boundary that lands inside a multi-byte
|
|
54
|
+
* UTF-8 sequence is normal for frames larger than a socket read: the left half ends the
|
|
55
|
+
* segment, the right half starts the next one, and `toString` replaces both with U+FFFD.
|
|
56
|
+
* `JSON.parse` still succeeded, so a daemon reply carrying screen text (`observe`,
|
|
57
|
+
* `last_evidence`) reached the agent and the report renderer with that text silently
|
|
58
|
+
* rewritten, while `bytes`/`raw` stayed correct — the shape looked fine, only the content
|
|
59
|
+
* had been edited. Measured 2026-11-04: feeding `{"title":"数据"}\n` (19 bytes) split at
|
|
60
|
+
* each of its 18 positions corrupts the title at 4 of them.
|
|
61
|
+
*/
|
|
62
|
+
chunks = [];
|
|
63
|
+
/** UTF-8 bytes seen for the line in progress (counted past the cap, never all retained). */
|
|
51
64
|
bytes = 0;
|
|
52
65
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
53
66
|
discarding = false;
|
|
54
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
69
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
70
|
+
* stays a byte count either way.
|
|
71
|
+
*/
|
|
55
72
|
push(chunk) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8");
|
|
74
|
+
let start = 0;
|
|
75
|
+
while (start < bytes.length) {
|
|
76
|
+
const nl = bytes.indexOf(10, start);
|
|
77
|
+
const segment = nl === -1 ? bytes.subarray(start) : bytes.subarray(start, nl);
|
|
78
|
+
this.consume(segment);
|
|
79
|
+
if (nl === -1) break;
|
|
80
|
+
this.deliver();
|
|
81
|
+
start = nl + 1;
|
|
65
82
|
}
|
|
83
|
+
if (bytes.length === 0) this.consume(bytes);
|
|
66
84
|
}
|
|
67
85
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
68
86
|
pendingText() {
|
|
69
|
-
return this.
|
|
87
|
+
return this.chunks.length === 0 ? "" : Buffer.concat(this.chunks).toString("utf8");
|
|
70
88
|
}
|
|
71
89
|
consume(segment) {
|
|
72
|
-
|
|
90
|
+
const segmentBytes = segment.length;
|
|
91
|
+
if (segmentBytes === 0 && !this.discarding) {
|
|
73
92
|
return;
|
|
74
93
|
}
|
|
75
|
-
const segmentBytes = Buffer.byteLength(segment, "utf8");
|
|
76
94
|
if (this.discarding) {
|
|
77
95
|
this.bytes += segmentBytes;
|
|
78
96
|
return;
|
|
79
97
|
}
|
|
80
98
|
if (this.bytes + segmentBytes > MAX_FRAME_BYTES) {
|
|
81
99
|
this.discarding = true;
|
|
82
|
-
|
|
100
|
+
const head = Buffer.concat([...this.chunks, segment]).subarray(0, OVERSIZE_PREFIX_BYTES);
|
|
101
|
+
this.chunks = [head];
|
|
83
102
|
this.bytes += segmentBytes;
|
|
84
103
|
return;
|
|
85
104
|
}
|
|
86
|
-
this.
|
|
105
|
+
this.chunks.push(Buffer.from(segment));
|
|
87
106
|
this.bytes += segmentBytes;
|
|
88
107
|
}
|
|
89
108
|
deliver() {
|
|
90
|
-
const
|
|
109
|
+
const raw = this.chunks.length === 0 ? void 0 : Buffer.concat(this.chunks);
|
|
110
|
+
const line = raw === void 0 ? "" : raw.toString("utf8");
|
|
91
111
|
const bytes = this.bytes;
|
|
92
112
|
const oversize = this.discarding;
|
|
93
|
-
this.
|
|
113
|
+
this.chunks = [];
|
|
94
114
|
this.bytes = 0;
|
|
95
115
|
this.discarding = false;
|
|
96
116
|
if (oversize) {
|
|
97
117
|
this.sink.onOversize(bytes, line);
|
|
98
118
|
} else {
|
|
99
|
-
this.sink.onLine(line);
|
|
119
|
+
this.sink.onLine(line, raw);
|
|
100
120
|
}
|
|
101
121
|
}
|
|
102
122
|
};
|
|
@@ -136,10 +156,9 @@ var StreamLineIo = class {
|
|
|
136
156
|
this.input = input;
|
|
137
157
|
this.output = output;
|
|
138
158
|
this.reader = new LineReader({
|
|
139
|
-
onLine: (line) => this.messageHandler?.(line),
|
|
159
|
+
onLine: (line, raw) => this.messageHandler?.(line, raw),
|
|
140
160
|
onOversize: (bytes, prefix) => this.errorHandler?.(new OversizeFrameError(bytes, prefix))
|
|
141
161
|
});
|
|
142
|
-
input.setEncoding("utf8");
|
|
143
162
|
input.on("data", (chunk) => this.reader.push(chunk));
|
|
144
163
|
input.on("close", () => this.closeHandler?.());
|
|
145
164
|
input.on("error", (error) => this.errorHandler?.(error));
|
|
@@ -732,16 +751,16 @@ var EngineJsonRpcClient = class {
|
|
|
732
751
|
this.pending.delete(evicted.id);
|
|
733
752
|
this.report(`dropped late-reply tracking for '${evicted.method}' (id ${evicted.id}): retention cap ${LATE_REPLY_RETENTION} reached`);
|
|
734
753
|
}
|
|
735
|
-
handleMessage(line) {
|
|
754
|
+
handleMessage(line, raw) {
|
|
736
755
|
let parsed;
|
|
737
756
|
try {
|
|
738
757
|
parsed = JSON.parse(line);
|
|
739
758
|
} catch {
|
|
740
|
-
this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line)}`);
|
|
759
|
+
this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line, raw)}`);
|
|
741
760
|
return;
|
|
742
761
|
}
|
|
743
762
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
744
|
-
this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line)}`);
|
|
763
|
+
this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line, raw)}`);
|
|
745
764
|
return;
|
|
746
765
|
}
|
|
747
766
|
const frame = parsed;
|
|
@@ -752,7 +771,7 @@ var EngineJsonRpcClient = class {
|
|
|
752
771
|
const tracked = [...this.pending.values()];
|
|
753
772
|
const held = tracked.length === 0 ? "nothing is tracked now" : `this client still tracks ${tracked.length} request(s): ` + tracked.map((kept) => "'" + kept.method + "' id " + kept.id + (kept.settled ? " (caller already answered)" : "")).join(", ");
|
|
754
773
|
this.report(
|
|
755
|
-
`engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line)
|
|
774
|
+
`engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line, raw)
|
|
756
775
|
);
|
|
757
776
|
return;
|
|
758
777
|
}
|
|
@@ -779,13 +798,13 @@ var EngineJsonRpcClient = class {
|
|
|
779
798
|
this.retainForLateReply();
|
|
780
799
|
return;
|
|
781
800
|
}
|
|
782
|
-
this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line)}`);
|
|
801
|
+
this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line, raw)}`);
|
|
783
802
|
return;
|
|
784
803
|
}
|
|
785
|
-
this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line)}`);
|
|
804
|
+
this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line, raw)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line, raw)}`);
|
|
786
805
|
return;
|
|
787
806
|
}
|
|
788
|
-
this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line)}`);
|
|
807
|
+
this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line, raw)}`);
|
|
789
808
|
}
|
|
790
809
|
settleFromFrame(entry, frame) {
|
|
791
810
|
if (frame.error) {
|
|
@@ -1049,10 +1068,11 @@ function attribute(error, entry, inferred = true) {
|
|
|
1049
1068
|
error.remedy
|
|
1050
1069
|
);
|
|
1051
1070
|
}
|
|
1052
|
-
function frameBodyNotLoggedNote(serializedFrame) {
|
|
1053
|
-
const
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1071
|
+
function frameBodyNotLoggedNote(serializedFrame, wireBytes) {
|
|
1072
|
+
const source = wireBytes ?? Buffer.from(serializedFrame, "utf8");
|
|
1073
|
+
const bytes = source.length;
|
|
1074
|
+
const digest = createHash("sha256").update(source).digest("hex").slice(0, 12);
|
|
1075
|
+
return `a ${bytes}-byte frame (sha256 ${digest}, ${wireBytes ? "of the exact bytes this transport received" : "of the frame text as this transport decoded it"}) whose text is not written to this log: on this socket a frame body is on-screen accessibility content \u2014 element titles and values, sometimes a document's text \u2014 and this log's sink is a file this product never sets the mode of, so the state root's 0700 does not cover it. Anything the daemon did record is in its evidence archive under the state root, read back with gp_last_evidence {operationId} or gp_export_evidence {operationId}`;
|
|
1056
1076
|
}
|
|
1057
1077
|
function shortFieldValue(value) {
|
|
1058
1078
|
const text = JSON.stringify(value) ?? String(value);
|
|
@@ -1172,6 +1192,8 @@ function unixSocketEngineClient(socketPath, options = {}) {
|
|
|
1172
1192
|
import http from "node:http";
|
|
1173
1193
|
import { createHash as createHash3, timingSafeEqual } from "node:crypto";
|
|
1174
1194
|
import { isIP } from "node:net";
|
|
1195
|
+
import os3 from "node:os";
|
|
1196
|
+
import path4 from "node:path";
|
|
1175
1197
|
import { URL } from "node:url";
|
|
1176
1198
|
|
|
1177
1199
|
// ../node_modules/iterate-kernel/dist/dimension-context.js
|
|
@@ -2270,7 +2292,7 @@ function refusedStateRootMessage(raw, defect) {
|
|
|
2270
2292
|
suggested = `${stripFirmlink(path3.posix.normalize(systemHome()))}/.glasspane`;
|
|
2271
2293
|
} catch {
|
|
2272
2294
|
}
|
|
2273
|
-
return `the background service's self-reported state root ${defect}, so this shell refuses to use it: ${quoteShellArg(raw)}. That value is not a choice this process made \u2014 it is the \`stateRoot\` field of the \`hello\` frame the daemon answered, and the engine socket has no peer authentication (SECURITY.md: any process running as this user may answer one), so a reply can name a directory this install does not own. \`gp_project_*\` would have created that directory and re-permissioned it to 0700 before writing projects.json into it, which is the daemon's own \`--state-dir\` guard arriving one step late: \`StateRoot.notADedicatedRoot\` rejects the same two shapes at the argument precisely so that nothing is ever touched. This shell will not create or re-permission that path, and it will NOT quietly fall back to the home default instead \u2014 writing a different file while reporting success is the failure this registry refuses by design. Nothing was read and nothing was written: no directory was created, no permission was changed, no projects.json was opened, listed or saved. Move the service onto a directory this install owns: start it as ` + (suggested === null ? "
|
|
2295
|
+
return `the background service's self-reported state root ${defect}, so this shell refuses to use it: ${quoteShellArg(raw)}. That value is not a choice this process made \u2014 it is the \`stateRoot\` field of the \`hello\` frame the daemon answered, and the engine socket has no peer authentication (SECURITY.md: any process running as this user may answer one), so a reply can name a directory this install does not own. \`gp_project_*\` would have created that directory and re-permissioned it to 0700 before writing projects.json into it, which is the daemon's own \`--state-dir\` guard arriving one step late: \`StateRoot.notADedicatedRoot\` rejects the same two shapes at the argument precisely so that nothing is ever touched. This shell will not create or re-permission that path, and it will NOT quietly fall back to the home default instead \u2014 writing a different file while reporting success is the failure this registry refuses by design. Nothing was read and nothing was written: no directory was created, no permission was changed, no projects.json was opened, listed or saved. Move the service onto a directory this install owns: start it as ` + (suggested === null ? "`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --state-dir <a directory this install owns>` " : `\`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --state-dir <a directory this install owns>\` (the daemon's own suggested form is \`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --state-dir ${quoteShellArg(suggested)}\`) `) + `then reconnect so a fresh hello reports the new root, and repeat the call. If the reported root is not one you configured, treat the answer to that handshake as untrusted: another process on this account replied to it.`;
|
|
2274
2296
|
}
|
|
2275
2297
|
function daemonProjectsPath(daemonStateRoot) {
|
|
2276
2298
|
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
@@ -2349,7 +2371,7 @@ function refusedProjectsFileOverride(raw, defect) {
|
|
|
2349
2371
|
return new ProjectRegistryError(
|
|
2350
2372
|
GP_E_STATE_ROOT_REFUSED,
|
|
2351
2373
|
`the ${PROJECTS_FILE_ENV} override this shell was started with ${defect}, so this shell refuses to use it: ${quoteShellArg(raw)}. This is the override slot of **this process**, not a root the background service reported about itself \u2014 the daemon never reads ${PROJECTS_FILE_ENV} (R7-14), so the value being judged is one an environment, a wrapper, or an agent set for the MCP shell alone. It is not a harmless pointer either: \`gp_project_set\` would have created that directory and re-permissioned it to 0700, then written the project registry \u2014 bundle ids, pids and storage paths \u2014 into it, which is the same authority this module refuses a self-reported root over (\`StateRoot.notADedicatedRoot\`) and refuses an agent-named evidence archive over (\`refuseCandidate\`). Nothing was read and nothing was written by this call: no directory was created, no permission was changed, no projects.json was opened, listed or saved.`,
|
|
2352
|
-
`this shell's own override is what is configured, not your arguments and not a damaged file: \`unset ${PROJECTS_FILE_ENV}\` for this MCP server process and repeat gp_project_set \u2014 it then writes the projects file of the root the running daemon named in its hello, or the home default \`${quoteShellArg(defaultFile)}\` when it named none. Alternatively point the override at one of those two paths; do not point it at a tree this shell will not create or re-permission, and do not repair a projects file for this refusal \u2014 the refusal names a directory, and no path under it was touched. If the service really is running on a root this shell cannot accept, move the service instead:
|
|
2374
|
+
`this shell's own override is what is configured, not your arguments and not a damaged file: \`unset ${PROJECTS_FILE_ENV}\` for this MCP server process and repeat gp_project_set \u2014 it then writes the projects file of the root the running daemon named in its hello, or the home default \`${quoteShellArg(defaultFile)}\` when it named none. Alternatively point the override at one of those two paths; do not point it at a tree this shell will not create or re-permission, and do not repair a projects file for this refusal \u2014 the refusal names a directory, and no path under it was touched. If the service really is running on a root this shell cannot accept, move the service instead: \`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --state-dir <a directory this install owns>\`, then reconnect so a fresh hello reports it`
|
|
2353
2375
|
);
|
|
2354
2376
|
}
|
|
2355
2377
|
function loadRegistry(filePath) {
|
|
@@ -2559,7 +2581,7 @@ function saveProjects(filePath, entries) {
|
|
|
2559
2581
|
// The refusal above already names the two commands that make the modes true, so the
|
|
2560
2582
|
// remedy transcribes them instead of sending the reader to repair a file nobody
|
|
2561
2583
|
// called damaged (B5). Nothing here is a judgement about the registry's contents.
|
|
2562
|
-
`the mode this shell asked for did not stick, so nothing was published: bring it to the daemon's own modes yourself \u2014 \`chmod 700 ${quoteShellArg(dir)}\` and \`chmod 600 ${quoteShellArg(filePath)}\` \u2014 read them back with \`stat -f '%Sp %N' ${quoteShellArg(dir)} ${quoteShellArg(filePath)}\`, and repeat gp_project_set once they say 700 and 600. If chmod answers success and the mode stays loose, the volume ignores permissions: find out with \`ls -lO ${quoteShellArg(dir)}\` (an immutable flag) and \`diskutil info -live ${quoteShellArg(dir)}\` (a read-only or remote mount), and move the service onto a volume that honours them
|
|
2584
|
+
`the mode this shell asked for did not stick, so nothing was published: bring it to the daemon's own modes yourself \u2014 \`chmod 700 ${quoteShellArg(dir)}\` and \`chmod 600 ${quoteShellArg(filePath)}\` \u2014 read them back with \`stat -f '%Sp %N' ${quoteShellArg(dir)} ${quoteShellArg(filePath)}\`, and repeat gp_project_set once they say 700 and 600. If chmod answers success and the mode stays loose, the volume ignores permissions: find out with \`ls -lO ${quoteShellArg(dir)}\` (an immutable flag) and \`diskutil info -live ${quoteShellArg(dir)}\` (a read-only or remote mount), and move the service onto a volume that honours them \`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --state-dir <a directory this install owns>\`). Do not repair or overwrite projects.json for this one, and do not set ${FORCE_OVERWRITE_ENV}: the fault is the mode, not the bytes in the file`
|
|
2563
2585
|
);
|
|
2564
2586
|
}
|
|
2565
2587
|
const errno = error?.code ?? "unknown";
|
|
@@ -2710,7 +2732,7 @@ function reloadSentence(changed) {
|
|
|
2710
2732
|
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";
|
|
2711
2733
|
}
|
|
2712
2734
|
function rootDiscriminator() {
|
|
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:
|
|
2735
|
+
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: `$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/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.";
|
|
2714
2736
|
}
|
|
2715
2737
|
function restartCommand() {
|
|
2716
2738
|
return `run \`launchctl kickstart -k gui/${currentUid()}/com.glasspane.daemon\` \u2014 if that reports the service was not found, the launchd job was never bootstrapped, so ${daemonUnreachableRemedy()}`;
|
|
@@ -2866,11 +2888,9 @@ function generateProjectId() {
|
|
|
2866
2888
|
const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
2867
2889
|
const body = [];
|
|
2868
2890
|
const bytes = new Uint8Array(26);
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
}
|
|
2872
|
-
for (let i = 0; i < 26; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
2873
|
-
}
|
|
2891
|
+
randomBytes(26).forEach((byte, index) => {
|
|
2892
|
+
bytes[index] = byte;
|
|
2893
|
+
});
|
|
2874
2894
|
for (let i = 0; i < 26; i++) {
|
|
2875
2895
|
const byte = bytes[i];
|
|
2876
2896
|
body.push(CROCKFORD.charAt(byte % 32));
|
|
@@ -3266,7 +3286,7 @@ var TOOL_SPECS = [
|
|
|
3266
3286
|
additionalProperties: false,
|
|
3267
3287
|
properties: {
|
|
3268
3288
|
projectId: { type: "string", pattern: "^prj_[0-9A-HJKMNP-TV-Z]{26}$" },
|
|
3269
|
-
displayName: { type: "string", minLength: 1, maxLength:
|
|
3289
|
+
displayName: { type: "string", minLength: 1, maxLength: MAX_DISPLAY_NAME_LENGTH },
|
|
3270
3290
|
// `null` clears the field on update, so these mirror
|
|
3271
3291
|
// ProjectSetArgs' `.nullish()` rather than the old optional-string form.
|
|
3272
3292
|
// The ceiling is `gp_attach`'s, from the daemon's own bound — the identity a
|
|
@@ -3276,9 +3296,9 @@ var TOOL_SPECS = [
|
|
|
3276
3296
|
// the daemon stores (an out-of-range pid made Swift fail to decode the
|
|
3277
3297
|
// whole registry file, which then got rewritten as an empty table).
|
|
3278
3298
|
pid: { type: ["integer", "null"], minimum: 1, maximum: PID_INT32_MAX },
|
|
3279
|
-
recipeConfigPath: { type: ["string", "null"], maxLength:
|
|
3280
|
-
calibrationAssetsPath: { type: ["string", "null"], maxLength:
|
|
3281
|
-
evidenceStoragePath: { type: ["string", "null"], maxLength:
|
|
3299
|
+
recipeConfigPath: { type: ["string", "null"], maxLength: MAX_FIELD_LENGTH },
|
|
3300
|
+
calibrationAssetsPath: { type: ["string", "null"], maxLength: MAX_FIELD_LENGTH },
|
|
3301
|
+
evidenceStoragePath: { type: ["string", "null"], maxLength: MAX_FIELD_LENGTH }
|
|
3282
3302
|
},
|
|
3283
3303
|
required: ["displayName"],
|
|
3284
3304
|
// Exactly one of bundleId/pid must identify the app *after* an update is
|
|
@@ -3683,19 +3703,19 @@ function passedThroughRegistryError(error) {
|
|
|
3683
3703
|
}
|
|
3684
3704
|
function projectErrorRemedy(code) {
|
|
3685
3705
|
if (code === GP_E_PROJECT_LIMIT) {
|
|
3686
|
-
return `the limit (${MAX_PROJECTS}) counts the entries stored in the projects file named above, so a new registration cannot be made to fit by changing an existing one: gp_project_set with an existing projectId patches that entry and leaves the count where it is. See what is stored with gp_project_list, then free a slot with a removal this product does implement:
|
|
3706
|
+
return `the limit (${MAX_PROJECTS}) counts the entries stored in the projects file named above, so a new registration cannot be made to fit by changing an existing one: gp_project_set with an existing projectId patches that entry and leaves the count where it is. See what is stored with gp_project_list, then free a slot with a removal this product does implement: \`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --project-remove <projectId>\` removes exactly one registration, and \`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --project-prune\` removes only the engine's own test residue \u2014 both take \`--dry-run\` to preview and print JSON, and an unknown id exits 3. A running daemon keeps its own copy of the table, so the removal only sticks after it is restarted (the reply's requiresDaemonRestart says whether one is pending; \`launchctl kickstart -k gui/$(id -u)/com.glasspane.daemon\`). Do NOT hand-edit the projects file: the next daemon save overwrites it. To read the same set without this shell: $HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --list-projects prints the file the service loads by default`;
|
|
3687
3707
|
}
|
|
3688
3708
|
if (code === GP_E_NOT_FOUND) {
|
|
3689
3709
|
return "check the projectId; use gp_project_list to view available projects";
|
|
3690
3710
|
}
|
|
3691
3711
|
if (code === GP_E_REGISTRY_DRIFT) {
|
|
3692
|
-
return "the projects file changed between the read that produced this reply and the write it attempted, so nothing was written: re-run the same gp_project_set \u2014 what this refusal wants is a second read, not different arguments. If it repeats, another writer owns that file (the daemon's maintenance CLI and the settings panel both rewrite it): read the table with
|
|
3712
|
+
return "the projects file changed between the read that produced this reply and the write it attempted, so nothing was written: re-run the same gp_project_set \u2014 what this refusal wants is a second read, not different arguments. If it repeats, another writer owns that file (the daemon's maintenance CLI and the settings panel both rewrite it): read the table with `$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/glasspaned --list-projects`, and remember a removal only sticks after the daemon restarts. `GLASSPANE_PROJECTS_FORCE_OVERWRITE=1` moves a file aside before writing, and nothing is overwritten without it.";
|
|
3693
3713
|
}
|
|
3694
3714
|
if (code === GP_E_NO_USER_RECORD) {
|
|
3695
3715
|
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";
|
|
3696
3716
|
}
|
|
3697
3717
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
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
|
|
3718
|
+
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 `$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/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 (`$HOME/Applications/GlassPane Daemon.app/Contents/MacOS/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";
|
|
3699
3719
|
}
|
|
3700
3720
|
if (code === GP_E_INTERNAL) {
|
|
3701
3721
|
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.`;
|
|
@@ -3991,6 +4011,9 @@ function mapAuditError(error, engineMethod = "last_evidence") {
|
|
|
3991
4011
|
};
|
|
3992
4012
|
}
|
|
3993
4013
|
|
|
4014
|
+
// src/dispatch.ts
|
|
4015
|
+
var SERVER_INFO = { name: "glasspane-mcp", version: "1.29.1" };
|
|
4016
|
+
|
|
3994
4017
|
// src/http-gateway.ts
|
|
3995
4018
|
var GLASSPANE_HTTP_TOKEN_ENV = "GLASSPANE_HTTP_TOKEN";
|
|
3996
4019
|
var DEFAULT_GATEWAY_PORT = 8787;
|
|
@@ -4066,7 +4089,11 @@ function createHttpGateway(options) {
|
|
|
4066
4089
|
}
|
|
4067
4090
|
});
|
|
4068
4091
|
setGatewayReportSink(report);
|
|
4069
|
-
const client = options.connectController !== void 0 ? options.connectController(options.socketPath) : unixSocketEngineClient(options.socketPath, {
|
|
4092
|
+
const client = options.connectController !== void 0 ? options.connectController(options.socketPath) : unixSocketEngineClient(options.socketPath, {
|
|
4093
|
+
identity: { version: SERVER_INFO.version },
|
|
4094
|
+
expectedDaemonMethods: DAEMON_FORWARDED_METHODS,
|
|
4095
|
+
surface: "http"
|
|
4096
|
+
});
|
|
4070
4097
|
client.onEngineNote?.((note) => report(`engine: ${note}`));
|
|
4071
4098
|
client.onLateReply?.(({ method, result }) => {
|
|
4072
4099
|
report(`late engine reply to '${method}': the engine did answer, ${lateReplyBodyNote(stringifyReply(result), result?.operationId)}`);
|
|
@@ -4558,13 +4585,24 @@ async function handleToolForward(name, req, client, res, bodyReadTimeoutMs = DEF
|
|
|
4558
4585
|
await failEngine(res, error, spec, engineBody(checked.value));
|
|
4559
4586
|
}
|
|
4560
4587
|
}
|
|
4588
|
+
function daemonCliCommand(...flags) {
|
|
4589
|
+
const installed = path4.join(
|
|
4590
|
+
os3.homedir(),
|
|
4591
|
+
"Applications",
|
|
4592
|
+
"GlassPane Daemon.app",
|
|
4593
|
+
"Contents",
|
|
4594
|
+
"MacOS",
|
|
4595
|
+
"glasspaned"
|
|
4596
|
+
);
|
|
4597
|
+
return [quoteShellArg(installed), ...flags].join(" ");
|
|
4598
|
+
}
|
|
4561
4599
|
function handleEvidenceStats(res) {
|
|
4562
4600
|
fail(
|
|
4563
4601
|
res,
|
|
4564
4602
|
501,
|
|
4565
4603
|
HTTP_NOT_PROVIDED,
|
|
4566
4604
|
"evidence statistics are not exposed over this daemon's socket protocol in this build",
|
|
4567
|
-
|
|
4605
|
+
`run \`${daemonCliCommand("--evidence-stats")}\` against the same --state-dir this socket serves to get count/totalBytes/listFailure/dir`
|
|
4568
4606
|
);
|
|
4569
4607
|
}
|
|
4570
4608
|
async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_READ_TIMEOUT_MS) {
|
|
@@ -4599,7 +4637,7 @@ async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_R
|
|
|
4599
4637
|
501,
|
|
4600
4638
|
HTTP_NOT_PROVIDED,
|
|
4601
4639
|
"recipe validation is not exposed over this daemon's socket protocol in this build",
|
|
4602
|
-
|
|
4640
|
+
`run \`${daemonCliCommand("--recipe-validate", "<recipe.json-path>")}\`; this build provides no socket method for it`
|
|
4603
4641
|
);
|
|
4604
4642
|
}
|
|
4605
4643
|
function authorized(req, expected) {
|
package/dist/http-gateway.d.ts
CHANGED
|
@@ -165,6 +165,20 @@ export declare function assertTokenPolicy(token: string): void;
|
|
|
165
165
|
/** Install the sink. Exported for the gateway factory; a caller that replaces it gets
|
|
166
166
|
* the last writer, which is what a single-process gateway already is. */
|
|
167
167
|
export declare function setGatewayReportSink(sink: (note: string) => void): void;
|
|
168
|
+
/**
|
|
169
|
+
* The daemon CLI, spelled the way a caller on THIS machine can actually run it.
|
|
170
|
+
*
|
|
171
|
+
* `glasspaned` is not on PATH (measured 2026-11-04: `command -v glasspaned` answers nothing, and
|
|
172
|
+
* no npm package declares that bin), so a remedy printing the bare name promises a repair and
|
|
173
|
+
* delivers `command not found` (127). The installed bundle is where `installer/cli.js` puts the
|
|
174
|
+
* daemon, and it is the same location `project-registry.ts` names. The directory contains a space,
|
|
175
|
+
* so the path must be ONE shell word — otherwise the copy-paste lands on `.../GlassPane` and hands
|
|
176
|
+
* `Daemon.app/...` to the next argv slot. Swift's half of this rule is
|
|
177
|
+
* `engine/Sources/GlassPaneEngine/DaemonInvocation.swift`; the gate that keeps both honest is
|
|
178
|
+
* `test/daily-20261104-bare-daemon-name.test.mjs`, because this list has been short of the next
|
|
179
|
+
* site five times running.
|
|
180
|
+
*/
|
|
181
|
+
export declare function daemonCliCommand(...flags: string[]): string;
|
|
168
182
|
/** How long one request body may take, when the caller did not choose (see {@link HttpGatewayOptions.bodyReadTimeoutMs}). */
|
|
169
183
|
export declare const DEFAULT_BODY_READ_TIMEOUT_MS = 15000;
|
|
170
184
|
//# sourceMappingURL=http-gateway.d.ts.map
|