glasspane-mcp 1.29.0 → 1.30.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 +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/http-gateway-cli.js +60 -30
- package/dist/http-gateway.d.ts +14 -0
- package/dist/http-gateway.js +61 -30
- package/dist/index.js +47 -30
- package/dist/io.d.ts +18 -7
- package/dist/stdio-session.d.ts +1 -1
- package/dist/stdio-session.js +47 -30
- package/package.json +1 -1
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.30.0";
|
|
30
30
|
};
|
|
31
31
|
export declare const PARSE_ERROR = -32700;
|
|
32
32
|
export declare const INVALID_REQUEST = -32600;
|
package/dist/errors.d.ts
CHANGED
|
@@ -155,5 +155,18 @@ export interface ToolErrorText {
|
|
|
155
155
|
*/
|
|
156
156
|
export declare function formatToolError(code: string, message: string, remedy: string): string;
|
|
157
157
|
export declare function formatToolErrorShape(error: ToolErrorText): string;
|
|
158
|
+
/**
|
|
159
|
+
* 一道 `GP_E_BAD_PARAMS` 的出路,两个门面共用同一句话(候选 E,2026-11-05)。
|
|
160
|
+
*
|
|
161
|
+
* 缺陷形状:zod 校验失败时,stdio 那一侧写的是 `check the tool's input schema; <issues>`,
|
|
162
|
+
* 而 HTTP 那一侧(`http-gateway.ts` 的 `spec.validate` 失败支)把 `<issues>` **裸着**当成整条
|
|
163
|
+
* remedy 发出去。zod 的原话是对模式失败的描述("Invalid input: expected string, received
|
|
164
|
+
* number at …"),不是一条做得动的动作——curl 的调用方拿到的是一个对问题的复述,而不是下一步。
|
|
165
|
+
* 本仓对 remedy 的口径一直是"agent 照着敲就得做得动",而这条口径不能只在一道门上成立。
|
|
166
|
+
*
|
|
167
|
+
* 放在 `errors.ts` 而不是任一门面的文件里:这一层住的就是"对外怎么措辞",两个门面都从这里取
|
|
168
|
+
* (`tools.ts` 与 `http-gateway.ts` 都已 import 本文件),抄第二份就又是一条事实两种拼写。
|
|
169
|
+
*/
|
|
170
|
+
export declare function badParamsRemedy(issues: string): string;
|
|
158
171
|
export declare function quoteShellArg(value: string): string;
|
|
159
172
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/http-gateway-cli.js
CHANGED
|
@@ -46,17 +46,28 @@ var LineReader = class {
|
|
|
46
46
|
this.sink = sink;
|
|
47
47
|
}
|
|
48
48
|
sink;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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). */
|
|
53
64
|
bytes = 0;
|
|
54
65
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
55
66
|
discarding = false;
|
|
56
67
|
/**
|
|
57
68
|
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
58
|
-
* {@link LineSink.onLine}; a string is
|
|
59
|
-
*
|
|
69
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
70
|
+
* stays a byte count either way.
|
|
60
71
|
*/
|
|
61
72
|
push(chunk) {
|
|
62
73
|
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8");
|
|
@@ -73,36 +84,33 @@ var LineReader = class {
|
|
|
73
84
|
}
|
|
74
85
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
75
86
|
pendingText() {
|
|
76
|
-
return this.
|
|
87
|
+
return this.chunks.length === 0 ? "" : Buffer.concat(this.chunks).toString("utf8");
|
|
77
88
|
}
|
|
78
89
|
consume(segment) {
|
|
79
90
|
const segmentBytes = segment.length;
|
|
80
91
|
if (segmentBytes === 0 && !this.discarding) {
|
|
81
92
|
return;
|
|
82
93
|
}
|
|
83
|
-
const text = segment.toString("utf8");
|
|
84
94
|
if (this.discarding) {
|
|
85
95
|
this.bytes += segmentBytes;
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
98
|
if (this.bytes + segmentBytes > MAX_FRAME_BYTES) {
|
|
89
99
|
this.discarding = true;
|
|
90
|
-
|
|
91
|
-
this.
|
|
100
|
+
const head = Buffer.concat([...this.chunks, segment]).subarray(0, OVERSIZE_PREFIX_BYTES);
|
|
101
|
+
this.chunks = [head];
|
|
92
102
|
this.bytes += segmentBytes;
|
|
93
103
|
return;
|
|
94
104
|
}
|
|
95
|
-
this.
|
|
96
|
-
this.rawChunks.push(Buffer.from(segment));
|
|
105
|
+
this.chunks.push(Buffer.from(segment));
|
|
97
106
|
this.bytes += segmentBytes;
|
|
98
107
|
}
|
|
99
108
|
deliver() {
|
|
100
|
-
const
|
|
109
|
+
const raw = this.chunks.length === 0 ? void 0 : Buffer.concat(this.chunks);
|
|
110
|
+
const line = raw === void 0 ? "" : raw.toString("utf8");
|
|
101
111
|
const bytes = this.bytes;
|
|
102
112
|
const oversize = this.discarding;
|
|
103
|
-
|
|
104
|
-
this.buffer = "";
|
|
105
|
-
this.rawChunks = [];
|
|
113
|
+
this.chunks = [];
|
|
106
114
|
this.bytes = 0;
|
|
107
115
|
this.discarding = false;
|
|
108
116
|
if (oversize) {
|
|
@@ -176,6 +184,9 @@ var StreamLineIo = class {
|
|
|
176
184
|
bufferedBytes() {
|
|
177
185
|
return this.output.writableLength;
|
|
178
186
|
}
|
|
187
|
+
// 注册侧的签名从前只收 `(line)`,而 `LineIo` 接口与内部 `messageHandler` 都带 `raw`:
|
|
188
|
+
// 于是 #16 那句"sha256 of the exact bytes this transport received"在 socket 这一路永远是
|
|
189
|
+
// 拿不到真字节的那一支(2026-11-04 候选 D)。签名与实际传的东西必须一致。
|
|
179
190
|
onMessage(handler) {
|
|
180
191
|
this.messageHandler = handler;
|
|
181
192
|
}
|
|
@@ -213,6 +224,9 @@ function formatToolError(code, message, remedy) {
|
|
|
213
224
|
function formatToolErrorShape(error) {
|
|
214
225
|
return formatToolError(error.code, error.message, error.remedy);
|
|
215
226
|
}
|
|
227
|
+
function badParamsRemedy(issues) {
|
|
228
|
+
return `check the tool's input schema; ${issues}`;
|
|
229
|
+
}
|
|
216
230
|
var SHELL_INERT_WORD = /^[A-Za-z0-9@%+=:,./_-]+$/;
|
|
217
231
|
function quoteShellArg(value) {
|
|
218
232
|
return SHELL_INERT_WORD.test(value) && !value.startsWith("-") ? value : `'${value.split("'").join("'\\''")}'`;
|
|
@@ -516,7 +530,7 @@ var EngineJsonRpcClient = class {
|
|
|
516
530
|
this.callerCeilingMs = callerCeilingMs;
|
|
517
531
|
this.surface = surface;
|
|
518
532
|
this.expectedDaemonMethods = expectedDaemonMethods;
|
|
519
|
-
this.io.onMessage((line) => this.handleMessage(line));
|
|
533
|
+
this.io.onMessage((line, raw) => this.handleMessage(line, raw));
|
|
520
534
|
this.io.onError((error) => {
|
|
521
535
|
if (error instanceof OversizeFrameError) {
|
|
522
536
|
this.failOversizedReply(error);
|
|
@@ -902,7 +916,7 @@ var EngineJsonRpcClient = class {
|
|
|
902
916
|
const byOrder = inferred ? " (attributed by arrival order: this frame echoed no request id, so nothing here confirms that guess \u2014 this is the oldest request this client still tracks, and the daemon answers in the order it received them; a frame matched to a request that way is recorded as inferred, never as verified)" : "";
|
|
903
917
|
if (frame.error) {
|
|
904
918
|
this.report(
|
|
905
|
-
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${
|
|
919
|
+
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${shortFieldValue(frame.error)}): an error answer names no operationId, so nothing can be recorded in the trail for it${byOrder}`
|
|
906
920
|
);
|
|
907
921
|
return;
|
|
908
922
|
}
|
|
@@ -1114,6 +1128,9 @@ var ReconnectingSocketIo = class {
|
|
|
1114
1128
|
bufferedBytes() {
|
|
1115
1129
|
return this.inner?.bufferedBytes() ?? 0;
|
|
1116
1130
|
}
|
|
1131
|
+
// `LineIo` 声明的是 `(line, raw?)`。这一侧从前只收 `(line)`,TypeScript 的参数双变性
|
|
1132
|
+
// 让窄一点的那个覆盖合法,于是 `raw` 在生产传输上被剪掉而类型检查一声不响(2026-11-04
|
|
1133
|
+
// 候选 D 修的是 `StreamLineIo`,这一枚是同一件事的另一半)。签名与转发的实参都要跟着接口。
|
|
1117
1134
|
onMessage(handler) {
|
|
1118
1135
|
this.messageHandler = handler;
|
|
1119
1136
|
}
|
|
@@ -1145,7 +1162,7 @@ var ReconnectingSocketIo = class {
|
|
|
1145
1162
|
}
|
|
1146
1163
|
const socket = this.open(this.socketPath);
|
|
1147
1164
|
const io = new StreamLineIo(socket, socket);
|
|
1148
|
-
io.onMessage((line) => this.messageHandler?.(line));
|
|
1165
|
+
io.onMessage((line, raw) => this.messageHandler?.(line, raw));
|
|
1149
1166
|
io.onError((error) => {
|
|
1150
1167
|
if (!(error instanceof OversizeFrameError) && this.inner === io) {
|
|
1151
1168
|
this.inner = null;
|
|
@@ -1184,6 +1201,8 @@ function unixSocketEngineClient(socketPath, options = {}) {
|
|
|
1184
1201
|
import http from "node:http";
|
|
1185
1202
|
import { createHash as createHash3, timingSafeEqual } from "node:crypto";
|
|
1186
1203
|
import { isIP } from "node:net";
|
|
1204
|
+
import os3 from "node:os";
|
|
1205
|
+
import path4 from "node:path";
|
|
1187
1206
|
import { URL } from "node:url";
|
|
1188
1207
|
|
|
1189
1208
|
// ../node_modules/iterate-kernel/dist/dimension-context.js
|
|
@@ -2282,7 +2301,7 @@ function refusedStateRootMessage(raw, defect) {
|
|
|
2282
2301
|
suggested = `${stripFirmlink(path3.posix.normalize(systemHome()))}/.glasspane`;
|
|
2283
2302
|
} catch {
|
|
2284
2303
|
}
|
|
2285
|
-
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 ? "
|
|
2304
|
+
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.`;
|
|
2286
2305
|
}
|
|
2287
2306
|
function daemonProjectsPath(daemonStateRoot) {
|
|
2288
2307
|
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
@@ -2361,7 +2380,7 @@ function refusedProjectsFileOverride(raw, defect) {
|
|
|
2361
2380
|
return new ProjectRegistryError(
|
|
2362
2381
|
GP_E_STATE_ROOT_REFUSED,
|
|
2363
2382
|
`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.`,
|
|
2364
|
-
`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:
|
|
2383
|
+
`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`
|
|
2365
2384
|
);
|
|
2366
2385
|
}
|
|
2367
2386
|
function loadRegistry(filePath) {
|
|
@@ -2571,7 +2590,7 @@ function saveProjects(filePath, entries) {
|
|
|
2571
2590
|
// The refusal above already names the two commands that make the modes true, so the
|
|
2572
2591
|
// remedy transcribes them instead of sending the reader to repair a file nobody
|
|
2573
2592
|
// called damaged (B5). Nothing here is a judgement about the registry's contents.
|
|
2574
|
-
`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
|
|
2593
|
+
`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`
|
|
2575
2594
|
);
|
|
2576
2595
|
}
|
|
2577
2596
|
const errno = error?.code ?? "unknown";
|
|
@@ -2722,7 +2741,7 @@ function reloadSentence(changed) {
|
|
|
2722
2741
|
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";
|
|
2723
2742
|
}
|
|
2724
2743
|
function rootDiscriminator() {
|
|
2725
|
-
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:
|
|
2744
|
+
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.";
|
|
2726
2745
|
}
|
|
2727
2746
|
function restartCommand() {
|
|
2728
2747
|
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()}`;
|
|
@@ -3693,19 +3712,19 @@ function passedThroughRegistryError(error) {
|
|
|
3693
3712
|
}
|
|
3694
3713
|
function projectErrorRemedy(code) {
|
|
3695
3714
|
if (code === GP_E_PROJECT_LIMIT) {
|
|
3696
|
-
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:
|
|
3715
|
+
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`;
|
|
3697
3716
|
}
|
|
3698
3717
|
if (code === GP_E_NOT_FOUND) {
|
|
3699
3718
|
return "check the projectId; use gp_project_list to view available projects";
|
|
3700
3719
|
}
|
|
3701
3720
|
if (code === GP_E_REGISTRY_DRIFT) {
|
|
3702
|
-
return
|
|
3721
|
+
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.';
|
|
3703
3722
|
}
|
|
3704
3723
|
if (code === GP_E_NO_USER_RECORD) {
|
|
3705
3724
|
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";
|
|
3706
3725
|
}
|
|
3707
3726
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
3708
|
-
return
|
|
3727
|
+
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';
|
|
3709
3728
|
}
|
|
3710
3729
|
if (code === GP_E_INTERNAL) {
|
|
3711
3730
|
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.`;
|
|
@@ -4002,7 +4021,7 @@ function mapAuditError(error, engineMethod = "last_evidence") {
|
|
|
4002
4021
|
}
|
|
4003
4022
|
|
|
4004
4023
|
// src/dispatch.ts
|
|
4005
|
-
var SERVER_INFO = { name: "glasspane-mcp", version: "1.
|
|
4024
|
+
var SERVER_INFO = { name: "glasspane-mcp", version: "1.30.0" };
|
|
4006
4025
|
|
|
4007
4026
|
// src/http-gateway.ts
|
|
4008
4027
|
var GLASSPANE_HTTP_TOKEN_ENV = "GLASSPANE_HTTP_TOKEN";
|
|
@@ -4543,7 +4562,7 @@ async function handleToolForward(name, req, client, res, bodyReadTimeoutMs = DEF
|
|
|
4543
4562
|
400,
|
|
4544
4563
|
GP_E_BAD_PARAMS,
|
|
4545
4564
|
`invalid arguments for '${name}'`,
|
|
4546
|
-
checked.issues
|
|
4565
|
+
badParamsRemedy(checked.issues)
|
|
4547
4566
|
);
|
|
4548
4567
|
return;
|
|
4549
4568
|
}
|
|
@@ -4575,13 +4594,24 @@ async function handleToolForward(name, req, client, res, bodyReadTimeoutMs = DEF
|
|
|
4575
4594
|
await failEngine(res, error, spec, engineBody(checked.value));
|
|
4576
4595
|
}
|
|
4577
4596
|
}
|
|
4597
|
+
function daemonCliCommand(...flags) {
|
|
4598
|
+
const installed = path4.join(
|
|
4599
|
+
os3.homedir(),
|
|
4600
|
+
"Applications",
|
|
4601
|
+
"GlassPane Daemon.app",
|
|
4602
|
+
"Contents",
|
|
4603
|
+
"MacOS",
|
|
4604
|
+
"glasspaned"
|
|
4605
|
+
);
|
|
4606
|
+
return [quoteShellArg(installed), ...flags].join(" ");
|
|
4607
|
+
}
|
|
4578
4608
|
function handleEvidenceStats(res) {
|
|
4579
4609
|
fail(
|
|
4580
4610
|
res,
|
|
4581
4611
|
501,
|
|
4582
4612
|
HTTP_NOT_PROVIDED,
|
|
4583
4613
|
"evidence statistics are not exposed over this daemon's socket protocol in this build",
|
|
4584
|
-
|
|
4614
|
+
`run \`${daemonCliCommand("--evidence-stats")}\` against the same --state-dir this socket serves to get count/totalBytes/listFailure/dir`
|
|
4585
4615
|
);
|
|
4586
4616
|
}
|
|
4587
4617
|
async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_READ_TIMEOUT_MS) {
|
|
@@ -4616,7 +4646,7 @@ async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_R
|
|
|
4616
4646
|
501,
|
|
4617
4647
|
HTTP_NOT_PROVIDED,
|
|
4618
4648
|
"recipe validation is not exposed over this daemon's socket protocol in this build",
|
|
4619
|
-
|
|
4649
|
+
`run \`${daemonCliCommand("--recipe-validate", "<recipe.json-path>")}\`; this build provides no socket method for it`
|
|
4620
4650
|
);
|
|
4621
4651
|
}
|
|
4622
4652
|
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
|
package/dist/http-gateway.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import http from "node:http";
|
|
3
3
|
import { createHash as createHash3, timingSafeEqual } from "node:crypto";
|
|
4
4
|
import { isIP } from "node:net";
|
|
5
|
+
import os3 from "node:os";
|
|
6
|
+
import path4 from "node:path";
|
|
5
7
|
import { URL } from "node:url";
|
|
6
8
|
|
|
7
9
|
// src/engine-client.ts
|
|
@@ -20,17 +22,28 @@ var LineReader = class {
|
|
|
20
22
|
this.sink = sink;
|
|
21
23
|
}
|
|
22
24
|
sink;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Bytes of the line in progress, in arrival order. Decoding happens ONCE, at delivery.
|
|
27
|
+
*
|
|
28
|
+
* The previous version decoded every segment on its own (`segment.toString("utf8")`) and
|
|
29
|
+
* concatenated the results into a string. A chunk boundary that lands inside a multi-byte
|
|
30
|
+
* UTF-8 sequence is normal for frames larger than a socket read: the left half ends the
|
|
31
|
+
* segment, the right half starts the next one, and `toString` replaces both with U+FFFD.
|
|
32
|
+
* `JSON.parse` still succeeded, so a daemon reply carrying screen text (`observe`,
|
|
33
|
+
* `last_evidence`) reached the agent and the report renderer with that text silently
|
|
34
|
+
* rewritten, while `bytes`/`raw` stayed correct — the shape looked fine, only the content
|
|
35
|
+
* had been edited. Measured 2026-11-04: feeding `{"title":"数据"}\n` (19 bytes) split at
|
|
36
|
+
* each of its 18 positions corrupts the title at 4 of them.
|
|
37
|
+
*/
|
|
38
|
+
chunks = [];
|
|
39
|
+
/** UTF-8 bytes seen for the line in progress (counted past the cap, never all retained). */
|
|
27
40
|
bytes = 0;
|
|
28
41
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
29
42
|
discarding = false;
|
|
30
43
|
/**
|
|
31
44
|
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
32
|
-
* {@link LineSink.onLine}; a string is
|
|
33
|
-
*
|
|
45
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
46
|
+
* stays a byte count either way.
|
|
34
47
|
*/
|
|
35
48
|
push(chunk) {
|
|
36
49
|
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8");
|
|
@@ -47,36 +60,33 @@ var LineReader = class {
|
|
|
47
60
|
}
|
|
48
61
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
49
62
|
pendingText() {
|
|
50
|
-
return this.
|
|
63
|
+
return this.chunks.length === 0 ? "" : Buffer.concat(this.chunks).toString("utf8");
|
|
51
64
|
}
|
|
52
65
|
consume(segment) {
|
|
53
66
|
const segmentBytes = segment.length;
|
|
54
67
|
if (segmentBytes === 0 && !this.discarding) {
|
|
55
68
|
return;
|
|
56
69
|
}
|
|
57
|
-
const text = segment.toString("utf8");
|
|
58
70
|
if (this.discarding) {
|
|
59
71
|
this.bytes += segmentBytes;
|
|
60
72
|
return;
|
|
61
73
|
}
|
|
62
74
|
if (this.bytes + segmentBytes > MAX_FRAME_BYTES) {
|
|
63
75
|
this.discarding = true;
|
|
64
|
-
|
|
65
|
-
this.
|
|
76
|
+
const head = Buffer.concat([...this.chunks, segment]).subarray(0, OVERSIZE_PREFIX_BYTES);
|
|
77
|
+
this.chunks = [head];
|
|
66
78
|
this.bytes += segmentBytes;
|
|
67
79
|
return;
|
|
68
80
|
}
|
|
69
|
-
this.
|
|
70
|
-
this.rawChunks.push(Buffer.from(segment));
|
|
81
|
+
this.chunks.push(Buffer.from(segment));
|
|
71
82
|
this.bytes += segmentBytes;
|
|
72
83
|
}
|
|
73
84
|
deliver() {
|
|
74
|
-
const
|
|
85
|
+
const raw = this.chunks.length === 0 ? void 0 : Buffer.concat(this.chunks);
|
|
86
|
+
const line = raw === void 0 ? "" : raw.toString("utf8");
|
|
75
87
|
const bytes = this.bytes;
|
|
76
88
|
const oversize = this.discarding;
|
|
77
|
-
|
|
78
|
-
this.buffer = "";
|
|
79
|
-
this.rawChunks = [];
|
|
89
|
+
this.chunks = [];
|
|
80
90
|
this.bytes = 0;
|
|
81
91
|
this.discarding = false;
|
|
82
92
|
if (oversize) {
|
|
@@ -150,6 +160,9 @@ var StreamLineIo = class {
|
|
|
150
160
|
bufferedBytes() {
|
|
151
161
|
return this.output.writableLength;
|
|
152
162
|
}
|
|
163
|
+
// 注册侧的签名从前只收 `(line)`,而 `LineIo` 接口与内部 `messageHandler` 都带 `raw`:
|
|
164
|
+
// 于是 #16 那句"sha256 of the exact bytes this transport received"在 socket 这一路永远是
|
|
165
|
+
// 拿不到真字节的那一支(2026-11-04 候选 D)。签名与实际传的东西必须一致。
|
|
153
166
|
onMessage(handler) {
|
|
154
167
|
this.messageHandler = handler;
|
|
155
168
|
}
|
|
@@ -187,6 +200,9 @@ function formatToolError(code, message, remedy) {
|
|
|
187
200
|
function formatToolErrorShape(error) {
|
|
188
201
|
return formatToolError(error.code, error.message, error.remedy);
|
|
189
202
|
}
|
|
203
|
+
function badParamsRemedy(issues) {
|
|
204
|
+
return `check the tool's input schema; ${issues}`;
|
|
205
|
+
}
|
|
190
206
|
var SHELL_INERT_WORD = /^[A-Za-z0-9@%+=:,./_-]+$/;
|
|
191
207
|
function quoteShellArg(value) {
|
|
192
208
|
return SHELL_INERT_WORD.test(value) && !value.startsWith("-") ? value : `'${value.split("'").join("'\\''")}'`;
|
|
@@ -470,7 +486,7 @@ var EngineJsonRpcClient = class {
|
|
|
470
486
|
this.callerCeilingMs = callerCeilingMs;
|
|
471
487
|
this.surface = surface;
|
|
472
488
|
this.expectedDaemonMethods = expectedDaemonMethods;
|
|
473
|
-
this.io.onMessage((line) => this.handleMessage(line));
|
|
489
|
+
this.io.onMessage((line, raw) => this.handleMessage(line, raw));
|
|
474
490
|
this.io.onError((error) => {
|
|
475
491
|
if (error instanceof OversizeFrameError) {
|
|
476
492
|
this.failOversizedReply(error);
|
|
@@ -856,7 +872,7 @@ var EngineJsonRpcClient = class {
|
|
|
856
872
|
const byOrder = inferred ? " (attributed by arrival order: this frame echoed no request id, so nothing here confirms that guess \u2014 this is the oldest request this client still tracks, and the daemon answers in the order it received them; a frame matched to a request that way is recorded as inferred, never as verified)" : "";
|
|
857
873
|
if (frame.error) {
|
|
858
874
|
this.report(
|
|
859
|
-
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${
|
|
875
|
+
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${shortFieldValue(frame.error)}): an error answer names no operationId, so nothing can be recorded in the trail for it${byOrder}`
|
|
860
876
|
);
|
|
861
877
|
return;
|
|
862
878
|
}
|
|
@@ -1068,6 +1084,9 @@ var ReconnectingSocketIo = class {
|
|
|
1068
1084
|
bufferedBytes() {
|
|
1069
1085
|
return this.inner?.bufferedBytes() ?? 0;
|
|
1070
1086
|
}
|
|
1087
|
+
// `LineIo` 声明的是 `(line, raw?)`。这一侧从前只收 `(line)`,TypeScript 的参数双变性
|
|
1088
|
+
// 让窄一点的那个覆盖合法,于是 `raw` 在生产传输上被剪掉而类型检查一声不响(2026-11-04
|
|
1089
|
+
// 候选 D 修的是 `StreamLineIo`,这一枚是同一件事的另一半)。签名与转发的实参都要跟着接口。
|
|
1071
1090
|
onMessage(handler) {
|
|
1072
1091
|
this.messageHandler = handler;
|
|
1073
1092
|
}
|
|
@@ -1099,7 +1118,7 @@ var ReconnectingSocketIo = class {
|
|
|
1099
1118
|
}
|
|
1100
1119
|
const socket = this.open(this.socketPath);
|
|
1101
1120
|
const io = new StreamLineIo(socket, socket);
|
|
1102
|
-
io.onMessage((line) => this.messageHandler?.(line));
|
|
1121
|
+
io.onMessage((line, raw) => this.messageHandler?.(line, raw));
|
|
1103
1122
|
io.onError((error) => {
|
|
1104
1123
|
if (!(error instanceof OversizeFrameError) && this.inner === io) {
|
|
1105
1124
|
this.inner = null;
|
|
@@ -2230,7 +2249,7 @@ function refusedStateRootMessage(raw, defect) {
|
|
|
2230
2249
|
suggested = `${stripFirmlink(path3.posix.normalize(systemHome()))}/.glasspane`;
|
|
2231
2250
|
} catch {
|
|
2232
2251
|
}
|
|
2233
|
-
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 ? "
|
|
2252
|
+
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.`;
|
|
2234
2253
|
}
|
|
2235
2254
|
function daemonProjectsPath(daemonStateRoot) {
|
|
2236
2255
|
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
@@ -2309,7 +2328,7 @@ function refusedProjectsFileOverride(raw, defect) {
|
|
|
2309
2328
|
return new ProjectRegistryError(
|
|
2310
2329
|
GP_E_STATE_ROOT_REFUSED,
|
|
2311
2330
|
`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.`,
|
|
2312
|
-
`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:
|
|
2331
|
+
`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`
|
|
2313
2332
|
);
|
|
2314
2333
|
}
|
|
2315
2334
|
function loadRegistry(filePath) {
|
|
@@ -2519,7 +2538,7 @@ function saveProjects(filePath, entries) {
|
|
|
2519
2538
|
// The refusal above already names the two commands that make the modes true, so the
|
|
2520
2539
|
// remedy transcribes them instead of sending the reader to repair a file nobody
|
|
2521
2540
|
// called damaged (B5). Nothing here is a judgement about the registry's contents.
|
|
2522
|
-
`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
|
|
2541
|
+
`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`
|
|
2523
2542
|
);
|
|
2524
2543
|
}
|
|
2525
2544
|
const errno = error?.code ?? "unknown";
|
|
@@ -2670,7 +2689,7 @@ function reloadSentence(changed) {
|
|
|
2670
2689
|
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";
|
|
2671
2690
|
}
|
|
2672
2691
|
function rootDiscriminator() {
|
|
2673
|
-
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:
|
|
2692
|
+
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.";
|
|
2674
2693
|
}
|
|
2675
2694
|
function restartCommand() {
|
|
2676
2695
|
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()}`;
|
|
@@ -3641,19 +3660,19 @@ function passedThroughRegistryError(error) {
|
|
|
3641
3660
|
}
|
|
3642
3661
|
function projectErrorRemedy(code) {
|
|
3643
3662
|
if (code === GP_E_PROJECT_LIMIT) {
|
|
3644
|
-
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:
|
|
3663
|
+
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`;
|
|
3645
3664
|
}
|
|
3646
3665
|
if (code === GP_E_NOT_FOUND) {
|
|
3647
3666
|
return "check the projectId; use gp_project_list to view available projects";
|
|
3648
3667
|
}
|
|
3649
3668
|
if (code === GP_E_REGISTRY_DRIFT) {
|
|
3650
|
-
return
|
|
3669
|
+
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.';
|
|
3651
3670
|
}
|
|
3652
3671
|
if (code === GP_E_NO_USER_RECORD) {
|
|
3653
3672
|
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";
|
|
3654
3673
|
}
|
|
3655
3674
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
3656
|
-
return
|
|
3675
|
+
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';
|
|
3657
3676
|
}
|
|
3658
3677
|
if (code === GP_E_INTERNAL) {
|
|
3659
3678
|
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.`;
|
|
@@ -3950,7 +3969,7 @@ function mapAuditError(error, engineMethod = "last_evidence") {
|
|
|
3950
3969
|
}
|
|
3951
3970
|
|
|
3952
3971
|
// src/dispatch.ts
|
|
3953
|
-
var SERVER_INFO = { name: "glasspane-mcp", version: "1.
|
|
3972
|
+
var SERVER_INFO = { name: "glasspane-mcp", version: "1.30.0" };
|
|
3954
3973
|
|
|
3955
3974
|
// src/http-gateway.ts
|
|
3956
3975
|
var GLASSPANE_HTTP_TOKEN_ENV = "GLASSPANE_HTTP_TOKEN";
|
|
@@ -4491,7 +4510,7 @@ async function handleToolForward(name, req, client, res, bodyReadTimeoutMs = DEF
|
|
|
4491
4510
|
400,
|
|
4492
4511
|
GP_E_BAD_PARAMS,
|
|
4493
4512
|
`invalid arguments for '${name}'`,
|
|
4494
|
-
checked.issues
|
|
4513
|
+
badParamsRemedy(checked.issues)
|
|
4495
4514
|
);
|
|
4496
4515
|
return;
|
|
4497
4516
|
}
|
|
@@ -4523,13 +4542,24 @@ async function handleToolForward(name, req, client, res, bodyReadTimeoutMs = DEF
|
|
|
4523
4542
|
await failEngine(res, error, spec, engineBody(checked.value));
|
|
4524
4543
|
}
|
|
4525
4544
|
}
|
|
4545
|
+
function daemonCliCommand(...flags) {
|
|
4546
|
+
const installed = path4.join(
|
|
4547
|
+
os3.homedir(),
|
|
4548
|
+
"Applications",
|
|
4549
|
+
"GlassPane Daemon.app",
|
|
4550
|
+
"Contents",
|
|
4551
|
+
"MacOS",
|
|
4552
|
+
"glasspaned"
|
|
4553
|
+
);
|
|
4554
|
+
return [quoteShellArg(installed), ...flags].join(" ");
|
|
4555
|
+
}
|
|
4526
4556
|
function handleEvidenceStats(res) {
|
|
4527
4557
|
fail(
|
|
4528
4558
|
res,
|
|
4529
4559
|
501,
|
|
4530
4560
|
HTTP_NOT_PROVIDED,
|
|
4531
4561
|
"evidence statistics are not exposed over this daemon's socket protocol in this build",
|
|
4532
|
-
|
|
4562
|
+
`run \`${daemonCliCommand("--evidence-stats")}\` against the same --state-dir this socket serves to get count/totalBytes/listFailure/dir`
|
|
4533
4563
|
);
|
|
4534
4564
|
}
|
|
4535
4565
|
async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_READ_TIMEOUT_MS) {
|
|
@@ -4564,7 +4594,7 @@ async function handleRecipeValidate(req, res, bodyReadTimeoutMs = DEFAULT_BODY_R
|
|
|
4564
4594
|
501,
|
|
4565
4595
|
HTTP_NOT_PROVIDED,
|
|
4566
4596
|
"recipe validation is not exposed over this daemon's socket protocol in this build",
|
|
4567
|
-
|
|
4597
|
+
`run \`${daemonCliCommand("--recipe-validate", "<recipe.json-path>")}\`; this build provides no socket method for it`
|
|
4568
4598
|
);
|
|
4569
4599
|
}
|
|
4570
4600
|
function authorized(req, expected) {
|
|
@@ -4853,6 +4883,7 @@ export {
|
|
|
4853
4883
|
assertLoopbackHost,
|
|
4854
4884
|
assertTokenPolicy,
|
|
4855
4885
|
createHttpGateway,
|
|
4886
|
+
daemonCliCommand,
|
|
4856
4887
|
isLoopbackHost,
|
|
4857
4888
|
setGatewayReportSink
|
|
4858
4889
|
};
|
package/dist/index.js
CHANGED
|
@@ -815,6 +815,9 @@ function formatToolError(code, message, remedy) {
|
|
|
815
815
|
function formatToolErrorShape(error) {
|
|
816
816
|
return formatToolError(error.code, error.message, error.remedy);
|
|
817
817
|
}
|
|
818
|
+
function badParamsRemedy(issues) {
|
|
819
|
+
return `check the tool's input schema; ${issues}`;
|
|
820
|
+
}
|
|
818
821
|
var SHELL_INERT_WORD = /^[A-Za-z0-9@%+=:,./_-]+$/;
|
|
819
822
|
function quoteShellArg(value) {
|
|
820
823
|
return SHELL_INERT_WORD.test(value) && !value.startsWith("-") ? value : `'${value.split("'").join("'\\''")}'`;
|
|
@@ -1473,17 +1476,28 @@ var LineReader = class {
|
|
|
1473
1476
|
this.sink = sink;
|
|
1474
1477
|
}
|
|
1475
1478
|
sink;
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1479
|
+
/**
|
|
1480
|
+
* Bytes of the line in progress, in arrival order. Decoding happens ONCE, at delivery.
|
|
1481
|
+
*
|
|
1482
|
+
* The previous version decoded every segment on its own (`segment.toString("utf8")`) and
|
|
1483
|
+
* concatenated the results into a string. A chunk boundary that lands inside a multi-byte
|
|
1484
|
+
* UTF-8 sequence is normal for frames larger than a socket read: the left half ends the
|
|
1485
|
+
* segment, the right half starts the next one, and `toString` replaces both with U+FFFD.
|
|
1486
|
+
* `JSON.parse` still succeeded, so a daemon reply carrying screen text (`observe`,
|
|
1487
|
+
* `last_evidence`) reached the agent and the report renderer with that text silently
|
|
1488
|
+
* rewritten, while `bytes`/`raw` stayed correct — the shape looked fine, only the content
|
|
1489
|
+
* had been edited. Measured 2026-11-04: feeding `{"title":"数据"}\n` (19 bytes) split at
|
|
1490
|
+
* each of its 18 positions corrupts the title at 4 of them.
|
|
1491
|
+
*/
|
|
1492
|
+
chunks = [];
|
|
1493
|
+
/** UTF-8 bytes seen for the line in progress (counted past the cap, never all retained). */
|
|
1480
1494
|
bytes = 0;
|
|
1481
1495
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
1482
1496
|
discarding = false;
|
|
1483
1497
|
/**
|
|
1484
1498
|
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
1485
|
-
* {@link LineSink.onLine}; a string is
|
|
1486
|
-
*
|
|
1499
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
1500
|
+
* stays a byte count either way.
|
|
1487
1501
|
*/
|
|
1488
1502
|
push(chunk) {
|
|
1489
1503
|
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8");
|
|
@@ -1500,36 +1514,33 @@ var LineReader = class {
|
|
|
1500
1514
|
}
|
|
1501
1515
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
1502
1516
|
pendingText() {
|
|
1503
|
-
return this.
|
|
1517
|
+
return this.chunks.length === 0 ? "" : Buffer.concat(this.chunks).toString("utf8");
|
|
1504
1518
|
}
|
|
1505
1519
|
consume(segment) {
|
|
1506
1520
|
const segmentBytes = segment.length;
|
|
1507
1521
|
if (segmentBytes === 0 && !this.discarding) {
|
|
1508
1522
|
return;
|
|
1509
1523
|
}
|
|
1510
|
-
const text = segment.toString("utf8");
|
|
1511
1524
|
if (this.discarding) {
|
|
1512
1525
|
this.bytes += segmentBytes;
|
|
1513
1526
|
return;
|
|
1514
1527
|
}
|
|
1515
1528
|
if (this.bytes + segmentBytes > MAX_FRAME_BYTES) {
|
|
1516
1529
|
this.discarding = true;
|
|
1517
|
-
|
|
1518
|
-
this.
|
|
1530
|
+
const head = Buffer.concat([...this.chunks, segment]).subarray(0, OVERSIZE_PREFIX_BYTES);
|
|
1531
|
+
this.chunks = [head];
|
|
1519
1532
|
this.bytes += segmentBytes;
|
|
1520
1533
|
return;
|
|
1521
1534
|
}
|
|
1522
|
-
this.
|
|
1523
|
-
this.rawChunks.push(Buffer.from(segment));
|
|
1535
|
+
this.chunks.push(Buffer.from(segment));
|
|
1524
1536
|
this.bytes += segmentBytes;
|
|
1525
1537
|
}
|
|
1526
1538
|
deliver() {
|
|
1527
|
-
const
|
|
1539
|
+
const raw = this.chunks.length === 0 ? void 0 : Buffer.concat(this.chunks);
|
|
1540
|
+
const line = raw === void 0 ? "" : raw.toString("utf8");
|
|
1528
1541
|
const bytes = this.bytes;
|
|
1529
1542
|
const oversize = this.discarding;
|
|
1530
|
-
|
|
1531
|
-
this.buffer = "";
|
|
1532
|
-
this.rawChunks = [];
|
|
1543
|
+
this.chunks = [];
|
|
1533
1544
|
this.bytes = 0;
|
|
1534
1545
|
this.discarding = false;
|
|
1535
1546
|
if (oversize) {
|
|
@@ -1603,6 +1614,9 @@ var StreamLineIo = class {
|
|
|
1603
1614
|
bufferedBytes() {
|
|
1604
1615
|
return this.output.writableLength;
|
|
1605
1616
|
}
|
|
1617
|
+
// 注册侧的签名从前只收 `(line)`,而 `LineIo` 接口与内部 `messageHandler` 都带 `raw`:
|
|
1618
|
+
// 于是 #16 那句"sha256 of the exact bytes this transport received"在 socket 这一路永远是
|
|
1619
|
+
// 拿不到真字节的那一支(2026-11-04 候选 D)。签名与实际传的东西必须一致。
|
|
1606
1620
|
onMessage(handler) {
|
|
1607
1621
|
this.messageHandler = handler;
|
|
1608
1622
|
}
|
|
@@ -2045,7 +2059,7 @@ var EngineJsonRpcClient = class {
|
|
|
2045
2059
|
this.callerCeilingMs = callerCeilingMs;
|
|
2046
2060
|
this.surface = surface;
|
|
2047
2061
|
this.expectedDaemonMethods = expectedDaemonMethods;
|
|
2048
|
-
this.io.onMessage((line) => this.handleMessage(line));
|
|
2062
|
+
this.io.onMessage((line, raw) => this.handleMessage(line, raw));
|
|
2049
2063
|
this.io.onError((error) => {
|
|
2050
2064
|
if (error instanceof OversizeFrameError) {
|
|
2051
2065
|
this.failOversizedReply(error);
|
|
@@ -2431,7 +2445,7 @@ var EngineJsonRpcClient = class {
|
|
|
2431
2445
|
const byOrder = inferred ? " (attributed by arrival order: this frame echoed no request id, so nothing here confirms that guess \u2014 this is the oldest request this client still tracks, and the daemon answers in the order it received them; a frame matched to a request that way is recorded as inferred, never as verified)" : "";
|
|
2432
2446
|
if (frame.error) {
|
|
2433
2447
|
this.report(
|
|
2434
|
-
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${
|
|
2448
|
+
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${shortFieldValue(frame.error)}): an error answer names no operationId, so nothing can be recorded in the trail for it${byOrder}`
|
|
2435
2449
|
);
|
|
2436
2450
|
return;
|
|
2437
2451
|
}
|
|
@@ -2643,6 +2657,9 @@ var ReconnectingSocketIo = class {
|
|
|
2643
2657
|
bufferedBytes() {
|
|
2644
2658
|
return this.inner?.bufferedBytes() ?? 0;
|
|
2645
2659
|
}
|
|
2660
|
+
// `LineIo` 声明的是 `(line, raw?)`。这一侧从前只收 `(line)`,TypeScript 的参数双变性
|
|
2661
|
+
// 让窄一点的那个覆盖合法,于是 `raw` 在生产传输上被剪掉而类型检查一声不响(2026-11-04
|
|
2662
|
+
// 候选 D 修的是 `StreamLineIo`,这一枚是同一件事的另一半)。签名与转发的实参都要跟着接口。
|
|
2646
2663
|
onMessage(handler) {
|
|
2647
2664
|
this.messageHandler = handler;
|
|
2648
2665
|
}
|
|
@@ -2674,7 +2691,7 @@ var ReconnectingSocketIo = class {
|
|
|
2674
2691
|
}
|
|
2675
2692
|
const socket = this.open(this.socketPath);
|
|
2676
2693
|
const io = new StreamLineIo(socket, socket);
|
|
2677
|
-
io.onMessage((line) => this.messageHandler?.(line));
|
|
2694
|
+
io.onMessage((line, raw) => this.messageHandler?.(line, raw));
|
|
2678
2695
|
io.onError((error) => {
|
|
2679
2696
|
if (!(error instanceof OversizeFrameError) && this.inner === io) {
|
|
2680
2697
|
this.inner = null;
|
|
@@ -3026,7 +3043,7 @@ function refusedStateRootMessage(raw, defect) {
|
|
|
3026
3043
|
suggested = `${stripFirmlink(path4.posix.normalize(systemHome()))}/.glasspane`;
|
|
3027
3044
|
} catch {
|
|
3028
3045
|
}
|
|
3029
|
-
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 ? "
|
|
3046
|
+
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.`;
|
|
3030
3047
|
}
|
|
3031
3048
|
function daemonProjectsPath(daemonStateRoot) {
|
|
3032
3049
|
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
@@ -3105,7 +3122,7 @@ function refusedProjectsFileOverride(raw, defect) {
|
|
|
3105
3122
|
return new ProjectRegistryError(
|
|
3106
3123
|
GP_E_STATE_ROOT_REFUSED,
|
|
3107
3124
|
`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.`,
|
|
3108
|
-
`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:
|
|
3125
|
+
`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`
|
|
3109
3126
|
);
|
|
3110
3127
|
}
|
|
3111
3128
|
function loadRegistry(filePath) {
|
|
@@ -3315,7 +3332,7 @@ function saveProjects(filePath, entries) {
|
|
|
3315
3332
|
// The refusal above already names the two commands that make the modes true, so the
|
|
3316
3333
|
// remedy transcribes them instead of sending the reader to repair a file nobody
|
|
3317
3334
|
// called damaged (B5). Nothing here is a judgement about the registry's contents.
|
|
3318
|
-
`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
|
|
3335
|
+
`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`
|
|
3319
3336
|
);
|
|
3320
3337
|
}
|
|
3321
3338
|
const errno = error?.code ?? "unknown";
|
|
@@ -3466,7 +3483,7 @@ function reloadSentence(changed) {
|
|
|
3466
3483
|
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";
|
|
3467
3484
|
}
|
|
3468
3485
|
function rootDiscriminator() {
|
|
3469
|
-
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:
|
|
3486
|
+
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.";
|
|
3470
3487
|
}
|
|
3471
3488
|
function restartCommand() {
|
|
3472
3489
|
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()}`;
|
|
@@ -4319,7 +4336,7 @@ async function executeTool(spec, args, engine, session, stdoutDroppedFrames) {
|
|
|
4319
4336
|
content: [{ type: "text", text: formatToolError(
|
|
4320
4337
|
GP_E_BAD_PARAMS,
|
|
4321
4338
|
`invalid arguments for ${spec.name}`,
|
|
4322
|
-
|
|
4339
|
+
badParamsRemedy(checked.issues)
|
|
4323
4340
|
) }],
|
|
4324
4341
|
isError: true
|
|
4325
4342
|
};
|
|
@@ -4707,19 +4724,19 @@ function passedThroughRegistryError(error) {
|
|
|
4707
4724
|
}
|
|
4708
4725
|
function projectErrorRemedy(code) {
|
|
4709
4726
|
if (code === GP_E_PROJECT_LIMIT) {
|
|
4710
|
-
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:
|
|
4727
|
+
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`;
|
|
4711
4728
|
}
|
|
4712
4729
|
if (code === GP_E_NOT_FOUND) {
|
|
4713
4730
|
return "check the projectId; use gp_project_list to view available projects";
|
|
4714
4731
|
}
|
|
4715
4732
|
if (code === GP_E_REGISTRY_DRIFT) {
|
|
4716
|
-
return
|
|
4733
|
+
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.';
|
|
4717
4734
|
}
|
|
4718
4735
|
if (code === GP_E_NO_USER_RECORD) {
|
|
4719
4736
|
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";
|
|
4720
4737
|
}
|
|
4721
4738
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
4722
|
-
return
|
|
4739
|
+
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';
|
|
4723
4740
|
}
|
|
4724
4741
|
if (code === GP_E_INTERNAL) {
|
|
4725
4742
|
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.`;
|
|
@@ -5046,7 +5063,7 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
|
5046
5063
|
"2025-03-26",
|
|
5047
5064
|
MCP_PROTOCOL_VERSION
|
|
5048
5065
|
];
|
|
5049
|
-
var SERVER_INFO = { name: "glasspane-mcp", version: "1.
|
|
5066
|
+
var SERVER_INFO = { name: "glasspane-mcp", version: "1.30.0" };
|
|
5050
5067
|
var PARSE_ERROR = -32700;
|
|
5051
5068
|
var INVALID_REQUEST = -32600;
|
|
5052
5069
|
var METHOD_NOT_FOUND = -32601;
|
|
@@ -5355,8 +5372,8 @@ Socket, in the order this shell resolves it:
|
|
|
5355
5372
|
2. GLASSPANE_ENGINE_SOCK=<path>
|
|
5356
5373
|
3. $HOME/.glasspane/engine.sock \u2014 a guess read from this process's HOME, not
|
|
5357
5374
|
the daemon's rule: glasspaned's own default is the home folder the system
|
|
5358
|
-
reports, which a HOME you export does not move, and
|
|
5359
|
-
<dir> serves <dir>/daemon.sock instead.
|
|
5375
|
+
reports, which a HOME you export does not move, and a daemon started with
|
|
5376
|
+
--state-dir <dir> serves <dir>/daemon.sock instead.
|
|
5360
5377
|
|
|
5361
5378
|
So "nothing is listening on the default path" means this shell guessed a
|
|
5362
5379
|
different directory, not that the daemon is dead. Connect to the socket the
|
package/dist/io.d.ts
CHANGED
|
@@ -64,18 +64,29 @@ export interface LineSink {
|
|
|
64
64
|
*/
|
|
65
65
|
export declare class LineReader {
|
|
66
66
|
private readonly sink;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Bytes of the line in progress, in arrival order. Decoding happens ONCE, at delivery.
|
|
69
|
+
*
|
|
70
|
+
* The previous version decoded every segment on its own (`segment.toString("utf8")`) and
|
|
71
|
+
* concatenated the results into a string. A chunk boundary that lands inside a multi-byte
|
|
72
|
+
* UTF-8 sequence is normal for frames larger than a socket read: the left half ends the
|
|
73
|
+
* segment, the right half starts the next one, and `toString` replaces both with U+FFFD.
|
|
74
|
+
* `JSON.parse` still succeeded, so a daemon reply carrying screen text (`observe`,
|
|
75
|
+
* `last_evidence`) reached the agent and the report renderer with that text silently
|
|
76
|
+
* rewritten, while `bytes`/`raw` stayed correct — the shape looked fine, only the content
|
|
77
|
+
* had been edited. Measured 2026-11-04: feeding `{"title":"数据"}\n` (19 bytes) split at
|
|
78
|
+
* each of its 18 positions corrupts the title at 4 of them.
|
|
79
|
+
*/
|
|
80
|
+
private chunks;
|
|
81
|
+
/** UTF-8 bytes seen for the line in progress (counted past the cap, never all retained). */
|
|
71
82
|
private bytes;
|
|
72
83
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
73
84
|
private discarding;
|
|
74
85
|
constructor(sink: LineSink);
|
|
75
86
|
/**
|
|
76
87
|
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
77
|
-
* {@link LineSink.onLine}; a string is
|
|
78
|
-
*
|
|
88
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
89
|
+
* stays a byte count either way.
|
|
79
90
|
*/
|
|
80
91
|
push(chunk: string | Buffer): void;
|
|
81
92
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
@@ -154,7 +165,7 @@ export declare class StreamLineIo implements LineIo {
|
|
|
154
165
|
constructor(input: Readable, output: Writable);
|
|
155
166
|
writeLine(line: string, onHandedOff?: () => void): void;
|
|
156
167
|
bufferedBytes(): number;
|
|
157
|
-
onMessage(handler: (line: string) => void): void;
|
|
168
|
+
onMessage(handler: (line: string, raw?: Buffer) => void): void;
|
|
158
169
|
onClose(handler: () => void): void;
|
|
159
170
|
onError(handler: (error: Error) => void): void;
|
|
160
171
|
close(): void;
|
package/dist/stdio-session.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface CliOptions {
|
|
|
29
29
|
* a daemon started with `--state-dir` binds `<state-dir>/daemon.sock` where no
|
|
30
30
|
* `HOME` value points. `defaultSocketPath` carries the full reason.
|
|
31
31
|
*/
|
|
32
|
-
export declare const USAGE = "usage: glasspane-mcp [--socket-path <path>]\n\nBridges an AI agent (MCP stdio) to the GlassPane engine daemon.\n\nSocket, in the order this shell resolves it:\n 1. --socket-path <path>\n 2. GLASSPANE_ENGINE_SOCK=<path>\n 3. $HOME/.glasspane/engine.sock \u2014 a guess read from this process's HOME, not\n the daemon's rule: glasspaned's own default is the home folder the system\n reports, which a HOME you export does not move, and
|
|
32
|
+
export declare const USAGE = "usage: glasspane-mcp [--socket-path <path>]\n\nBridges an AI agent (MCP stdio) to the GlassPane engine daemon.\n\nSocket, in the order this shell resolves it:\n 1. --socket-path <path>\n 2. GLASSPANE_ENGINE_SOCK=<path>\n 3. $HOME/.glasspane/engine.sock \u2014 a guess read from this process's HOME, not\n the daemon's rule: glasspaned's own default is the home folder the system\n reports, which a HOME you export does not move, and a daemon started with\n --state-dir <dir> serves <dir>/daemon.sock instead.\n\nSo \"nothing is listening on the default path\" means this shell guessed a\ndifferent directory, not that the daemon is dead. Connect to the socket the\ndaemon is really on \u2014 read it, do not re-derive it:\n launchctl print gui/$(id -u)/com.glasspane.daemon # the installed job's --socket-path value\n glasspane-mcp --socket-path <that path> # or, equivalently:\n GLASSPANE_ENGINE_SOCK=<that path> glasspane-mcp\nA daemon started by hand with --state-dir has no launchd job to read: pass it\n<state-dir>/daemon.sock.\n";
|
|
33
33
|
export declare function parseArgs(argv: readonly string[]): CliOptions;
|
|
34
34
|
/**
|
|
35
35
|
* JSON-RPC answer to a request frame that could not be framed at all.
|
package/dist/stdio-session.js
CHANGED
|
@@ -810,6 +810,9 @@ function formatToolError(code, message, remedy) {
|
|
|
810
810
|
function formatToolErrorShape(error) {
|
|
811
811
|
return formatToolError(error.code, error.message, error.remedy);
|
|
812
812
|
}
|
|
813
|
+
function badParamsRemedy(issues) {
|
|
814
|
+
return `check the tool's input schema; ${issues}`;
|
|
815
|
+
}
|
|
813
816
|
var SHELL_INERT_WORD = /^[A-Za-z0-9@%+=:,./_-]+$/;
|
|
814
817
|
function quoteShellArg(value) {
|
|
815
818
|
return SHELL_INERT_WORD.test(value) && !value.startsWith("-") ? value : `'${value.split("'").join("'\\''")}'`;
|
|
@@ -1468,17 +1471,28 @@ var LineReader = class {
|
|
|
1468
1471
|
this.sink = sink;
|
|
1469
1472
|
}
|
|
1470
1473
|
sink;
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1474
|
+
/**
|
|
1475
|
+
* Bytes of the line in progress, in arrival order. Decoding happens ONCE, at delivery.
|
|
1476
|
+
*
|
|
1477
|
+
* The previous version decoded every segment on its own (`segment.toString("utf8")`) and
|
|
1478
|
+
* concatenated the results into a string. A chunk boundary that lands inside a multi-byte
|
|
1479
|
+
* UTF-8 sequence is normal for frames larger than a socket read: the left half ends the
|
|
1480
|
+
* segment, the right half starts the next one, and `toString` replaces both with U+FFFD.
|
|
1481
|
+
* `JSON.parse` still succeeded, so a daemon reply carrying screen text (`observe`,
|
|
1482
|
+
* `last_evidence`) reached the agent and the report renderer with that text silently
|
|
1483
|
+
* rewritten, while `bytes`/`raw` stayed correct — the shape looked fine, only the content
|
|
1484
|
+
* had been edited. Measured 2026-11-04: feeding `{"title":"数据"}\n` (19 bytes) split at
|
|
1485
|
+
* each of its 18 positions corrupts the title at 4 of them.
|
|
1486
|
+
*/
|
|
1487
|
+
chunks = [];
|
|
1488
|
+
/** UTF-8 bytes seen for the line in progress (counted past the cap, never all retained). */
|
|
1475
1489
|
bytes = 0;
|
|
1476
1490
|
/** The line in progress already blew the cap; only the head is retained. */
|
|
1477
1491
|
discarding = false;
|
|
1478
1492
|
/**
|
|
1479
1493
|
* @param chunk a fragment from the stream. A `Buffer` keeps the wire bytes for
|
|
1480
|
-
* {@link LineSink.onLine}; a string is
|
|
1481
|
-
*
|
|
1494
|
+
* {@link LineSink.onLine}; a string is encoded to UTF-8 first, so the byte count
|
|
1495
|
+
* stays a byte count either way.
|
|
1482
1496
|
*/
|
|
1483
1497
|
push(chunk) {
|
|
1484
1498
|
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8");
|
|
@@ -1495,36 +1509,33 @@ var LineReader = class {
|
|
|
1495
1509
|
}
|
|
1496
1510
|
/** Partial line so far; only the retained head while a line is discarded. */
|
|
1497
1511
|
pendingText() {
|
|
1498
|
-
return this.
|
|
1512
|
+
return this.chunks.length === 0 ? "" : Buffer.concat(this.chunks).toString("utf8");
|
|
1499
1513
|
}
|
|
1500
1514
|
consume(segment) {
|
|
1501
1515
|
const segmentBytes = segment.length;
|
|
1502
1516
|
if (segmentBytes === 0 && !this.discarding) {
|
|
1503
1517
|
return;
|
|
1504
1518
|
}
|
|
1505
|
-
const text = segment.toString("utf8");
|
|
1506
1519
|
if (this.discarding) {
|
|
1507
1520
|
this.bytes += segmentBytes;
|
|
1508
1521
|
return;
|
|
1509
1522
|
}
|
|
1510
1523
|
if (this.bytes + segmentBytes > MAX_FRAME_BYTES) {
|
|
1511
1524
|
this.discarding = true;
|
|
1512
|
-
|
|
1513
|
-
this.
|
|
1525
|
+
const head = Buffer.concat([...this.chunks, segment]).subarray(0, OVERSIZE_PREFIX_BYTES);
|
|
1526
|
+
this.chunks = [head];
|
|
1514
1527
|
this.bytes += segmentBytes;
|
|
1515
1528
|
return;
|
|
1516
1529
|
}
|
|
1517
|
-
this.
|
|
1518
|
-
this.rawChunks.push(Buffer.from(segment));
|
|
1530
|
+
this.chunks.push(Buffer.from(segment));
|
|
1519
1531
|
this.bytes += segmentBytes;
|
|
1520
1532
|
}
|
|
1521
1533
|
deliver() {
|
|
1522
|
-
const
|
|
1534
|
+
const raw = this.chunks.length === 0 ? void 0 : Buffer.concat(this.chunks);
|
|
1535
|
+
const line = raw === void 0 ? "" : raw.toString("utf8");
|
|
1523
1536
|
const bytes = this.bytes;
|
|
1524
1537
|
const oversize = this.discarding;
|
|
1525
|
-
|
|
1526
|
-
this.buffer = "";
|
|
1527
|
-
this.rawChunks = [];
|
|
1538
|
+
this.chunks = [];
|
|
1528
1539
|
this.bytes = 0;
|
|
1529
1540
|
this.discarding = false;
|
|
1530
1541
|
if (oversize) {
|
|
@@ -1598,6 +1609,9 @@ var StreamLineIo = class {
|
|
|
1598
1609
|
bufferedBytes() {
|
|
1599
1610
|
return this.output.writableLength;
|
|
1600
1611
|
}
|
|
1612
|
+
// 注册侧的签名从前只收 `(line)`,而 `LineIo` 接口与内部 `messageHandler` 都带 `raw`:
|
|
1613
|
+
// 于是 #16 那句"sha256 of the exact bytes this transport received"在 socket 这一路永远是
|
|
1614
|
+
// 拿不到真字节的那一支(2026-11-04 候选 D)。签名与实际传的东西必须一致。
|
|
1601
1615
|
onMessage(handler) {
|
|
1602
1616
|
this.messageHandler = handler;
|
|
1603
1617
|
}
|
|
@@ -2040,7 +2054,7 @@ var EngineJsonRpcClient = class {
|
|
|
2040
2054
|
this.callerCeilingMs = callerCeilingMs;
|
|
2041
2055
|
this.surface = surface;
|
|
2042
2056
|
this.expectedDaemonMethods = expectedDaemonMethods;
|
|
2043
|
-
this.io.onMessage((line) => this.handleMessage(line));
|
|
2057
|
+
this.io.onMessage((line, raw) => this.handleMessage(line, raw));
|
|
2044
2058
|
this.io.onError((error) => {
|
|
2045
2059
|
if (error instanceof OversizeFrameError) {
|
|
2046
2060
|
this.failOversizedReply(error);
|
|
@@ -2426,7 +2440,7 @@ var EngineJsonRpcClient = class {
|
|
|
2426
2440
|
const byOrder = inferred ? " (attributed by arrival order: this frame echoed no request id, so nothing here confirms that guess \u2014 this is the oldest request this client still tracks, and the daemon answers in the order it received them; a frame matched to a request that way is recorded as inferred, never as verified)" : "";
|
|
2427
2441
|
if (frame.error) {
|
|
2428
2442
|
this.report(
|
|
2429
|
-
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${
|
|
2443
|
+
`late engine reply for '${entry.method}' (id ${entry.id}), ${entry.deadlineMs}ms deadline already reported, is an error frame (${shortFieldValue(frame.error)}): an error answer names no operationId, so nothing can be recorded in the trail for it${byOrder}`
|
|
2430
2444
|
);
|
|
2431
2445
|
return;
|
|
2432
2446
|
}
|
|
@@ -2638,6 +2652,9 @@ var ReconnectingSocketIo = class {
|
|
|
2638
2652
|
bufferedBytes() {
|
|
2639
2653
|
return this.inner?.bufferedBytes() ?? 0;
|
|
2640
2654
|
}
|
|
2655
|
+
// `LineIo` 声明的是 `(line, raw?)`。这一侧从前只收 `(line)`,TypeScript 的参数双变性
|
|
2656
|
+
// 让窄一点的那个覆盖合法,于是 `raw` 在生产传输上被剪掉而类型检查一声不响(2026-11-04
|
|
2657
|
+
// 候选 D 修的是 `StreamLineIo`,这一枚是同一件事的另一半)。签名与转发的实参都要跟着接口。
|
|
2641
2658
|
onMessage(handler) {
|
|
2642
2659
|
this.messageHandler = handler;
|
|
2643
2660
|
}
|
|
@@ -2669,7 +2686,7 @@ var ReconnectingSocketIo = class {
|
|
|
2669
2686
|
}
|
|
2670
2687
|
const socket = this.open(this.socketPath);
|
|
2671
2688
|
const io = new StreamLineIo(socket, socket);
|
|
2672
|
-
io.onMessage((line) => this.messageHandler?.(line));
|
|
2689
|
+
io.onMessage((line, raw) => this.messageHandler?.(line, raw));
|
|
2673
2690
|
io.onError((error) => {
|
|
2674
2691
|
if (!(error instanceof OversizeFrameError) && this.inner === io) {
|
|
2675
2692
|
this.inner = null;
|
|
@@ -3021,7 +3038,7 @@ function refusedStateRootMessage(raw, defect) {
|
|
|
3021
3038
|
suggested = `${stripFirmlink(path4.posix.normalize(systemHome()))}/.glasspane`;
|
|
3022
3039
|
} catch {
|
|
3023
3040
|
}
|
|
3024
|
-
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 ? "
|
|
3041
|
+
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.`;
|
|
3025
3042
|
}
|
|
3026
3043
|
function daemonProjectsPath(daemonStateRoot) {
|
|
3027
3044
|
const named2 = typeof daemonStateRoot === "string" ? daemonStateRoot.trim() : "";
|
|
@@ -3100,7 +3117,7 @@ function refusedProjectsFileOverride(raw, defect) {
|
|
|
3100
3117
|
return new ProjectRegistryError(
|
|
3101
3118
|
GP_E_STATE_ROOT_REFUSED,
|
|
3102
3119
|
`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.`,
|
|
3103
|
-
`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:
|
|
3120
|
+
`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`
|
|
3104
3121
|
);
|
|
3105
3122
|
}
|
|
3106
3123
|
function loadRegistry(filePath) {
|
|
@@ -3310,7 +3327,7 @@ function saveProjects(filePath, entries) {
|
|
|
3310
3327
|
// The refusal above already names the two commands that make the modes true, so the
|
|
3311
3328
|
// remedy transcribes them instead of sending the reader to repair a file nobody
|
|
3312
3329
|
// called damaged (B5). Nothing here is a judgement about the registry's contents.
|
|
3313
|
-
`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
|
|
3330
|
+
`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`
|
|
3314
3331
|
);
|
|
3315
3332
|
}
|
|
3316
3333
|
const errno = error?.code ?? "unknown";
|
|
@@ -3461,7 +3478,7 @@ function reloadSentence(changed) {
|
|
|
3461
3478
|
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";
|
|
3462
3479
|
}
|
|
3463
3480
|
function rootDiscriminator() {
|
|
3464
|
-
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:
|
|
3481
|
+
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.";
|
|
3465
3482
|
}
|
|
3466
3483
|
function restartCommand() {
|
|
3467
3484
|
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()}`;
|
|
@@ -4314,7 +4331,7 @@ async function executeTool(spec, args, engine, session, stdoutDroppedFrames) {
|
|
|
4314
4331
|
content: [{ type: "text", text: formatToolError(
|
|
4315
4332
|
GP_E_BAD_PARAMS,
|
|
4316
4333
|
`invalid arguments for ${spec.name}`,
|
|
4317
|
-
|
|
4334
|
+
badParamsRemedy(checked.issues)
|
|
4318
4335
|
) }],
|
|
4319
4336
|
isError: true
|
|
4320
4337
|
};
|
|
@@ -4702,19 +4719,19 @@ function passedThroughRegistryError(error) {
|
|
|
4702
4719
|
}
|
|
4703
4720
|
function projectErrorRemedy(code) {
|
|
4704
4721
|
if (code === GP_E_PROJECT_LIMIT) {
|
|
4705
|
-
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:
|
|
4722
|
+
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`;
|
|
4706
4723
|
}
|
|
4707
4724
|
if (code === GP_E_NOT_FOUND) {
|
|
4708
4725
|
return "check the projectId; use gp_project_list to view available projects";
|
|
4709
4726
|
}
|
|
4710
4727
|
if (code === GP_E_REGISTRY_DRIFT) {
|
|
4711
|
-
return
|
|
4728
|
+
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.';
|
|
4712
4729
|
}
|
|
4713
4730
|
if (code === GP_E_NO_USER_RECORD) {
|
|
4714
4731
|
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";
|
|
4715
4732
|
}
|
|
4716
4733
|
if (code === GP_E_STATE_ROOT_REFUSED) {
|
|
4717
|
-
return
|
|
4734
|
+
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';
|
|
4718
4735
|
}
|
|
4719
4736
|
if (code === GP_E_INTERNAL) {
|
|
4720
4737
|
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.`;
|
|
@@ -5041,7 +5058,7 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
|
5041
5058
|
"2025-03-26",
|
|
5042
5059
|
MCP_PROTOCOL_VERSION
|
|
5043
5060
|
];
|
|
5044
|
-
var SERVER_INFO = { name: "glasspane-mcp", version: "1.
|
|
5061
|
+
var SERVER_INFO = { name: "glasspane-mcp", version: "1.30.0" };
|
|
5045
5062
|
var PARSE_ERROR = -32700;
|
|
5046
5063
|
var INVALID_REQUEST = -32600;
|
|
5047
5064
|
var METHOD_NOT_FOUND = -32601;
|
|
@@ -5350,8 +5367,8 @@ Socket, in the order this shell resolves it:
|
|
|
5350
5367
|
2. GLASSPANE_ENGINE_SOCK=<path>
|
|
5351
5368
|
3. $HOME/.glasspane/engine.sock \u2014 a guess read from this process's HOME, not
|
|
5352
5369
|
the daemon's rule: glasspaned's own default is the home folder the system
|
|
5353
|
-
reports, which a HOME you export does not move, and
|
|
5354
|
-
<dir> serves <dir>/daemon.sock instead.
|
|
5370
|
+
reports, which a HOME you export does not move, and a daemon started with
|
|
5371
|
+
--state-dir <dir> serves <dir>/daemon.sock instead.
|
|
5355
5372
|
|
|
5356
5373
|
So "nothing is listening on the default path" means this shell guessed a
|
|
5357
5374
|
different directory, not that the daemon is dead. Connect to the socket the
|
package/package.json
CHANGED