glasspane-mcp 1.24.1 → 1.25.2

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.
@@ -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.24.1";
29
+ readonly version: "1.25.2";
30
30
  };
31
31
  export declare const PARSE_ERROR = -32700;
32
32
  export declare const INVALID_REQUEST = -32600;
@@ -342,8 +342,6 @@ export declare function writeBacklogRemedy(backlogBytes: number, limitBytes: num
342
342
  * effect.
343
343
  */
344
344
  export declare function slowEngineRemedy(method: string, surface?: ShellSurface): string;
345
- /** Log ceiling for a frame body; excess is marked, never silently cut. */
346
- export declare const LOG_BODY_CHARS: number;
347
345
  /**
348
346
  * How a reply frame was matched to the request it is reported for.
349
347
  *
@@ -589,7 +587,38 @@ export declare class EngineJsonRpcClient {
589
587
  private handshake;
590
588
  private verifyIdentity;
591
589
  }
592
- export declare function truncate(text: string): string;
590
+ /**
591
+ * The one sentence every unattributable-frame arm says about the bytes it refused to log.
592
+ *
593
+ * `handleMessage` has seven arms that drop a frame the client cannot attribute — not JSON, not
594
+ * an object, an id it never issued, an id-less answer, a non-numeric id. Each of them still has
595
+ * to be diagnosable, and none of them may copy the frame: a reply on this socket is observe /
596
+ * assert content (element titles and values, sometimes a document's text), while the report
597
+ * sink — stderr, or whatever supervises the process — is a file this product never sets the
598
+ * mode of. Copying the body there exports screen content past the 0700 state root, which is
599
+ * exactly what `lateReplyBodyNote` was authored to prevent on the late-reply path; the two
600
+ * surfaces cannot be allowed to hold opposite rules about the same bytes (review 2026-10-09
601
+ * finding 3, F3 on 2026-10-27, and this round's finding that the seven arms were never moved).
602
+ *
603
+ * So the note keeps the facts that survive redaction and are recomputable from the frame
604
+ * itself: the byte length and a short deterministic SHA-256 digest of the exact bytes this
605
+ * transport received. Unlike a *reply* to a request this client still tracks, a frame that
606
+ * belongs to no request may have no archive entry at all, so the note names where content the
607
+ * daemon did record lives, and says how to read it back, without promising this frame is in it.
608
+ *
609
+ * The reverse mutation is to interpolate the frame back into any of those seven lines.
610
+ */
611
+ export declare function frameBodyNotLoggedNote(serializedFrame: string): string;
612
+ /**
613
+ * A single frame *field* quoted into a log line, bounded.
614
+ *
615
+ * A normal request id is a number or a short string, so it is printed exactly as it came —
616
+ * editing the daemon's words would be its own dishonesty. The bound is for the other case: a
617
+ * peer on this socket path that answers with an id-shaped field holding several kilobytes of
618
+ * text would otherwise put that text in the log through the one clause this file still trusted.
619
+ * Over the bound the value is reported by size and digest, the same shape as the frame note.
620
+ */
621
+ export declare function shortFieldValue(value: unknown): string;
593
622
  export declare function lateReplyBodyNote(serializedBody: string, operationId?: unknown): string;
594
623
  /** How a transport stream is opened; injectable so tests need no socket. */
595
624
  export type EngineTransportOpener = (socketPath: string) => Duplex;
@@ -423,7 +423,7 @@ function slowEngineRemedy(method, surface = "mcp") {
423
423
  return `${poll}. The daemon serves one request at a time and is still working on this one, so ${reIssueGuidance(surface)}; a restart is authorised only by ${restarted}`;
424
424
  }
425
425
  var LATE_REPLY_RETENTION = 16;
426
- var LOG_BODY_CHARS = 64 * 1024;
426
+ var LOG_FIELD_CHARS = 120;
427
427
  var EngineJsonRpcClient = class {
428
428
  constructor(io, timeoutMs, identity = null, callerCeilingMs = CALLER_VISIBLE_CEILING_MS, surface = "mcp", expectedDaemonMethods = []) {
429
429
  this.io = io;
@@ -650,11 +650,11 @@ var EngineJsonRpcClient = class {
650
650
  try {
651
651
  parsed = JSON.parse(line);
652
652
  } catch {
653
- this.report(`engine sent a non-JSON frame, dropped: ${truncate(line)}`);
653
+ this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line)}`);
654
654
  return;
655
655
  }
656
656
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
657
- this.report(`engine sent a frame that is not a JSON object, dropped: ${truncate(line)}`);
657
+ this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line)}`);
658
658
  return;
659
659
  }
660
660
  const frame = parsed;
@@ -665,7 +665,7 @@ var EngineJsonRpcClient = class {
665
665
  const tracked = [...this.pending.values()];
666
666
  const held = tracked.length === 0 ? "nothing is tracked now" : `this client still tracks ${tracked.length} request(s): ` + tracked.map((kept) => "'" + kept.method + "' id " + kept.id + (kept.settled ? " (caller already answered)" : "")).join(", ");
667
667
  this.report(
668
- `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + truncate(line)
668
+ `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line)
669
669
  );
670
670
  return;
671
671
  }
@@ -692,13 +692,13 @@ var EngineJsonRpcClient = class {
692
692
  this.retainForLateReply();
693
693
  return;
694
694
  }
695
- this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${truncate(line)}`);
695
+ this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line)}`);
696
696
  return;
697
697
  }
698
- this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${truncate(line)}` : `engine sent an id-less frame with no request in flight: ${truncate(line)}`);
698
+ this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line)}`);
699
699
  return;
700
700
  }
701
- this.report(`engine sent a frame with a non-numeric request id (${jsonOrString(id)}), which this client never issues: ${truncate(line)}`);
701
+ this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line)}`);
702
702
  }
703
703
  settleFromFrame(entry, frame) {
704
704
  if (frame.error) {
@@ -955,8 +955,17 @@ function attribute(error, entry, inferred = true) {
955
955
  error.remedy
956
956
  );
957
957
  }
958
- function truncate(text) {
959
- return text.length <= LOG_BODY_CHARS ? text : `${text.slice(0, LOG_BODY_CHARS)}\u2026 [+${text.length - LOG_BODY_CHARS} chars not logged]`;
958
+ function frameBodyNotLoggedNote(serializedFrame) {
959
+ const bytes = Buffer.byteLength(serializedFrame, "utf8");
960
+ const digest = createHash("sha256").update(serializedFrame, "utf8").digest("hex").slice(0, 12);
961
+ return `a ${bytes}-byte frame (sha256 ${digest}) whose text is not written to this log: on this socket a frame body is on-screen accessibility content \u2014 element titles and values, sometimes a document's text \u2014 and this log's sink is a file this product never sets the mode of, so the state root's 0700 does not cover it. Anything the daemon did record is in its evidence archive under the state root, read back with gp_last_evidence {operationId} or gp_export_evidence {operationId}`;
962
+ }
963
+ function shortFieldValue(value) {
964
+ const text = JSON.stringify(value) ?? String(value);
965
+ if (text.length <= LOG_FIELD_CHARS) return text;
966
+ const bytes = Buffer.byteLength(text, "utf8");
967
+ const digest = createHash("sha256").update(text, "utf8").digest("hex").slice(0, 12);
968
+ return `${text.length}-char value (sha256 ${digest}, ${bytes} bytes) not quoted here`;
960
969
  }
961
970
  var ARCHIVE_OPERATION_ID = /^op_[0-9A-HJKMNP-TV-Z]{26}$/;
962
971
  function lateReplyBodyNote(serializedBody, operationId) {
@@ -3914,6 +3923,7 @@ function createHttpGateway(options) {
3914
3923
  } catch {
3915
3924
  }
3916
3925
  });
3926
+ setGatewayReportSink(report);
3917
3927
  const client = options.connectController !== void 0 ? options.connectController(options.socketPath) : unixSocketEngineClient(options.socketPath, { surface: "http" });
3918
3928
  client.onEngineNote?.((note) => report(`engine: ${note}`));
3919
3929
  client.onLateReply?.(({ method, result }) => {
@@ -3923,7 +3933,14 @@ function createHttpGateway(options) {
3923
3933
  const bodyReadTimeoutMs = options.bodyReadTimeoutMs ?? DEFAULT_BODY_READ_TIMEOUT_MS;
3924
3934
  const server = http.createServer((req, res) => {
3925
3935
  handleHttp(req, res, client, expectedToken, bodyReadTimeoutMs).catch((error) => {
3926
- fail(res, 500, GP_E_INTERNAL, `internal gateway error: ${String(error)}`, gatewayFaultAdvice());
3936
+ report(`internal gateway error for ${req.method} ${req.url}: ${String(error)}`);
3937
+ fail(
3938
+ res,
3939
+ 500,
3940
+ GP_E_INTERNAL,
3941
+ `internal gateway error of type ${errorTypeName(error)}; its own description names files this frame does not publish`,
3942
+ gatewayFaultAdvice()
3943
+ );
3927
3944
  });
3928
3945
  });
3929
3946
  server.listen(port, host);
@@ -3994,6 +4011,33 @@ function assertTokenPolicy(token) {
3994
4011
  );
3995
4012
  }
3996
4013
  }
4014
+ function errorTypeName(error) {
4015
+ if (error instanceof Error) {
4016
+ const name = error.constructor?.name;
4017
+ return typeof name === "string" && name.length > 0 ? name : "Error";
4018
+ }
4019
+ if (error === null) return "null";
4020
+ if (error === void 0) return "undefined";
4021
+ return typeof error;
4022
+ }
4023
+ var gatewayReportSink = reportToFallbackStderr;
4024
+ function setGatewayReportSink(sink) {
4025
+ gatewayReportSink = sink;
4026
+ }
4027
+ function reportToFallbackStderr(note) {
4028
+ try {
4029
+ process.stderr.write(`${note}
4030
+ `);
4031
+ } catch {
4032
+ }
4033
+ }
4034
+ function wireCause(where, error) {
4035
+ const type = errorTypeName(error);
4036
+ gatewayReportSink(
4037
+ `${where}: internal ${type} \u2014 ${String(error)} (withheld from the HTTP frame: a description of an internal failure names files this frame does not publish)`
4038
+ );
4039
+ return `an internal ${type} failure inside this gateway, at ${where}; its own description is on the gateway's stderr, not in this frame`;
4040
+ }
3997
4041
  function stringifyReply(result) {
3998
4042
  try {
3999
4043
  const text = JSON.stringify(result);
@@ -4204,7 +4248,7 @@ async function handleEvidenceAggregate(url, client, res) {
4204
4248
  operationId,
4205
4249
  kind: "frame",
4206
4250
  error,
4207
- line: `${GP_E_INTERNAL}: the daemon returned a last_evidence frame this gateway cannot render (no parseable evidencePack for ${operationId}: ${boundedCause(describeCause(error))})`
4251
+ line: `${GP_E_INTERNAL}: the daemon returned a last_evidence frame this gateway cannot render (no parseable evidencePack for ${operationId}: ${wireCause("the last_evidence fan-out", error)})`
4208
4252
  };
4209
4253
  notFetched.push(...ids.slice(index + 1));
4210
4254
  break;
@@ -4485,17 +4529,11 @@ function makeNotFetchedNote(notFetched, format) {
4485
4529
  return format === "html" ? `<p class="gp-not-fetched">${escapeHTML(sentence)}</p>` : `> ${sentence}`;
4486
4530
  }
4487
4531
  var CAUSE_MAX_CHARS = 400;
4488
- function describeCause(error) {
4489
- if (error instanceof Error) {
4490
- return error.message.trim() === "" ? error.name : error.message;
4491
- }
4492
- return String(error);
4493
- }
4494
4532
  function boundedCause(text) {
4495
4533
  return text.length <= CAUSE_MAX_CHARS ? text : `${text.slice(0, CAUSE_MAX_CHARS)}\u2026 [+${text.length - CAUSE_MAX_CHARS} chars not shown]`;
4496
4534
  }
4497
4535
  function engineFailureLine(error) {
4498
- return error instanceof EngineCallError ? `${error.code}: ${boundedCause(error.message)}` : `${GP_E_INTERNAL}: ${boundedCause(describeCause(error))}`;
4536
+ return error instanceof EngineCallError ? `${error.code}: ${boundedCause(error.message)}` : `${GP_E_INTERNAL}: ${wireCause("an engine call inside the partial report", error)}`;
4499
4537
  }
4500
4538
  function notFetchedTail(notFetched) {
4501
4539
  if (notFetched.length === 0) {
@@ -4597,7 +4635,7 @@ async function failEngine(res, error, spec, params, tail = "") {
4597
4635
  res,
4598
4636
  500,
4599
4637
  GP_E_INTERNAL,
4600
- `this gateway could not complete the request: ${String(error)}${tail}`,
4638
+ `this gateway could not complete the request: ${wireCause(`the ${spec?.name ?? "tool"} route handler`, error)}${tail}`,
4601
4639
  gatewayFaultAdvice(spec)
4602
4640
  );
4603
4641
  }
@@ -4633,7 +4671,7 @@ function failEvidenceFrameShape(res, error, operationId, tail = "") {
4633
4671
  res,
4634
4672
  502,
4635
4673
  GP_E_INTERNAL,
4636
- `the daemon returned a last_evidence frame that does not match the engine contract (no parseable evidencePack${operationId === void 0 ? "" : ` for ${operationId}`}: ${String(error)})${tail}`,
4674
+ `the daemon returned a last_evidence frame that does not match the engine contract (no parseable evidencePack${operationId === void 0 ? "" : ` for ${operationId}`}: ${wireCause("the last_evidence frame parser", error)})${tail}`,
4637
4675
  "the daemon answered this request, so the transport is up and restarting it changes nothing here; this gateway validates a pack before rendering or forwarding it, so GET /v1/evidence/<operationId> and POST /v1/tools/last_evidence {operationId} will both refuse this frame for the same reason. Read what the attached app is doing now without performing anything: POST /v1/tools/observe, POST /v1/tools/assert_element or POST /v1/tools/probe_status. Producing a fresh pack for this operation means acting again, which is a decision this read cannot make for you."
4638
4676
  );
4639
4677
  }
@@ -162,6 +162,9 @@ export declare function isLoopbackHost(value: string): boolean;
162
162
  export declare function assertLoopbackHost(host: string): string;
163
163
  /** Refuse an empty token, and one too short or too uniform to be a credential. */
164
164
  export declare function assertTokenPolicy(token: string): void;
165
+ /** Install the sink. Exported for the gateway factory; a caller that replaces it gets
166
+ * the last writer, which is what a single-process gateway already is. */
167
+ export declare function setGatewayReportSink(sink: (note: string) => void): void;
165
168
  /** How long one request body may take, when the caller did not choose (see {@link HttpGatewayOptions.bodyReadTimeoutMs}). */
166
169
  export declare const DEFAULT_BODY_READ_TIMEOUT_MS = 15000;
167
170
  //# sourceMappingURL=http-gateway.d.ts.map
@@ -375,7 +375,7 @@ function slowEngineRemedy(method, surface = "mcp") {
375
375
  return `${poll}. The daemon serves one request at a time and is still working on this one, so ${reIssueGuidance(surface)}; a restart is authorised only by ${restarted}`;
376
376
  }
377
377
  var LATE_REPLY_RETENTION = 16;
378
- var LOG_BODY_CHARS = 64 * 1024;
378
+ var LOG_FIELD_CHARS = 120;
379
379
  var EngineJsonRpcClient = class {
380
380
  constructor(io, timeoutMs, identity = null, callerCeilingMs = CALLER_VISIBLE_CEILING_MS, surface = "mcp", expectedDaemonMethods = []) {
381
381
  this.io = io;
@@ -602,11 +602,11 @@ var EngineJsonRpcClient = class {
602
602
  try {
603
603
  parsed = JSON.parse(line);
604
604
  } catch {
605
- this.report(`engine sent a non-JSON frame, dropped: ${truncate(line)}`);
605
+ this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line)}`);
606
606
  return;
607
607
  }
608
608
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
609
- this.report(`engine sent a frame that is not a JSON object, dropped: ${truncate(line)}`);
609
+ this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line)}`);
610
610
  return;
611
611
  }
612
612
  const frame = parsed;
@@ -617,7 +617,7 @@ var EngineJsonRpcClient = class {
617
617
  const tracked = [...this.pending.values()];
618
618
  const held = tracked.length === 0 ? "nothing is tracked now" : `this client still tracks ${tracked.length} request(s): ` + tracked.map((kept) => "'" + kept.method + "' id " + kept.id + (kept.settled ? " (caller already answered)" : "")).join(", ");
619
619
  this.report(
620
- `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + truncate(line)
620
+ `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line)
621
621
  );
622
622
  return;
623
623
  }
@@ -644,13 +644,13 @@ var EngineJsonRpcClient = class {
644
644
  this.retainForLateReply();
645
645
  return;
646
646
  }
647
- this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${truncate(line)}`);
647
+ this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line)}`);
648
648
  return;
649
649
  }
650
- this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${truncate(line)}` : `engine sent an id-less frame with no request in flight: ${truncate(line)}`);
650
+ this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line)}`);
651
651
  return;
652
652
  }
653
- this.report(`engine sent a frame with a non-numeric request id (${jsonOrString(id)}), which this client never issues: ${truncate(line)}`);
653
+ this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line)}`);
654
654
  }
655
655
  settleFromFrame(entry, frame) {
656
656
  if (frame.error) {
@@ -907,8 +907,17 @@ function attribute(error, entry, inferred = true) {
907
907
  error.remedy
908
908
  );
909
909
  }
910
- function truncate(text) {
911
- return text.length <= LOG_BODY_CHARS ? text : `${text.slice(0, LOG_BODY_CHARS)}\u2026 [+${text.length - LOG_BODY_CHARS} chars not logged]`;
910
+ function frameBodyNotLoggedNote(serializedFrame) {
911
+ const bytes = Buffer.byteLength(serializedFrame, "utf8");
912
+ const digest = createHash("sha256").update(serializedFrame, "utf8").digest("hex").slice(0, 12);
913
+ return `a ${bytes}-byte frame (sha256 ${digest}) whose text is not written to this log: on this socket a frame body is on-screen accessibility content \u2014 element titles and values, sometimes a document's text \u2014 and this log's sink is a file this product never sets the mode of, so the state root's 0700 does not cover it. Anything the daemon did record is in its evidence archive under the state root, read back with gp_last_evidence {operationId} or gp_export_evidence {operationId}`;
914
+ }
915
+ function shortFieldValue(value) {
916
+ const text = JSON.stringify(value) ?? String(value);
917
+ if (text.length <= LOG_FIELD_CHARS) return text;
918
+ const bytes = Buffer.byteLength(text, "utf8");
919
+ const digest = createHash("sha256").update(text, "utf8").digest("hex").slice(0, 12);
920
+ return `${text.length}-char value (sha256 ${digest}, ${bytes} bytes) not quoted here`;
912
921
  }
913
922
  var ARCHIVE_OPERATION_ID = /^op_[0-9A-HJKMNP-TV-Z]{26}$/;
914
923
  function lateReplyBodyNote(serializedBody, operationId) {
@@ -3860,6 +3869,7 @@ function createHttpGateway(options) {
3860
3869
  } catch {
3861
3870
  }
3862
3871
  });
3872
+ setGatewayReportSink(report);
3863
3873
  const client = options.connectController !== void 0 ? options.connectController(options.socketPath) : unixSocketEngineClient(options.socketPath, { surface: "http" });
3864
3874
  client.onEngineNote?.((note) => report(`engine: ${note}`));
3865
3875
  client.onLateReply?.(({ method, result }) => {
@@ -3869,7 +3879,14 @@ function createHttpGateway(options) {
3869
3879
  const bodyReadTimeoutMs = options.bodyReadTimeoutMs ?? DEFAULT_BODY_READ_TIMEOUT_MS;
3870
3880
  const server = http.createServer((req, res) => {
3871
3881
  handleHttp(req, res, client, expectedToken, bodyReadTimeoutMs).catch((error) => {
3872
- fail(res, 500, GP_E_INTERNAL, `internal gateway error: ${String(error)}`, gatewayFaultAdvice());
3882
+ report(`internal gateway error for ${req.method} ${req.url}: ${String(error)}`);
3883
+ fail(
3884
+ res,
3885
+ 500,
3886
+ GP_E_INTERNAL,
3887
+ `internal gateway error of type ${errorTypeName(error)}; its own description names files this frame does not publish`,
3888
+ gatewayFaultAdvice()
3889
+ );
3873
3890
  });
3874
3891
  });
3875
3892
  server.listen(port, host);
@@ -3940,6 +3957,33 @@ function assertTokenPolicy(token) {
3940
3957
  );
3941
3958
  }
3942
3959
  }
3960
+ function errorTypeName(error) {
3961
+ if (error instanceof Error) {
3962
+ const name = error.constructor?.name;
3963
+ return typeof name === "string" && name.length > 0 ? name : "Error";
3964
+ }
3965
+ if (error === null) return "null";
3966
+ if (error === void 0) return "undefined";
3967
+ return typeof error;
3968
+ }
3969
+ var gatewayReportSink = reportToFallbackStderr;
3970
+ function setGatewayReportSink(sink) {
3971
+ gatewayReportSink = sink;
3972
+ }
3973
+ function reportToFallbackStderr(note) {
3974
+ try {
3975
+ process.stderr.write(`${note}
3976
+ `);
3977
+ } catch {
3978
+ }
3979
+ }
3980
+ function wireCause(where, error) {
3981
+ const type = errorTypeName(error);
3982
+ gatewayReportSink(
3983
+ `${where}: internal ${type} \u2014 ${String(error)} (withheld from the HTTP frame: a description of an internal failure names files this frame does not publish)`
3984
+ );
3985
+ return `an internal ${type} failure inside this gateway, at ${where}; its own description is on the gateway's stderr, not in this frame`;
3986
+ }
3943
3987
  function stringifyReply(result) {
3944
3988
  try {
3945
3989
  const text = JSON.stringify(result);
@@ -4150,7 +4194,7 @@ async function handleEvidenceAggregate(url, client, res) {
4150
4194
  operationId,
4151
4195
  kind: "frame",
4152
4196
  error,
4153
- line: `${GP_E_INTERNAL}: the daemon returned a last_evidence frame this gateway cannot render (no parseable evidencePack for ${operationId}: ${boundedCause(describeCause(error))})`
4197
+ line: `${GP_E_INTERNAL}: the daemon returned a last_evidence frame this gateway cannot render (no parseable evidencePack for ${operationId}: ${wireCause("the last_evidence fan-out", error)})`
4154
4198
  };
4155
4199
  notFetched.push(...ids.slice(index + 1));
4156
4200
  break;
@@ -4431,17 +4475,11 @@ function makeNotFetchedNote(notFetched, format) {
4431
4475
  return format === "html" ? `<p class="gp-not-fetched">${escapeHTML(sentence)}</p>` : `> ${sentence}`;
4432
4476
  }
4433
4477
  var CAUSE_MAX_CHARS = 400;
4434
- function describeCause(error) {
4435
- if (error instanceof Error) {
4436
- return error.message.trim() === "" ? error.name : error.message;
4437
- }
4438
- return String(error);
4439
- }
4440
4478
  function boundedCause(text) {
4441
4479
  return text.length <= CAUSE_MAX_CHARS ? text : `${text.slice(0, CAUSE_MAX_CHARS)}\u2026 [+${text.length - CAUSE_MAX_CHARS} chars not shown]`;
4442
4480
  }
4443
4481
  function engineFailureLine(error) {
4444
- return error instanceof EngineCallError ? `${error.code}: ${boundedCause(error.message)}` : `${GP_E_INTERNAL}: ${boundedCause(describeCause(error))}`;
4482
+ return error instanceof EngineCallError ? `${error.code}: ${boundedCause(error.message)}` : `${GP_E_INTERNAL}: ${wireCause("an engine call inside the partial report", error)}`;
4445
4483
  }
4446
4484
  function notFetchedTail(notFetched) {
4447
4485
  if (notFetched.length === 0) {
@@ -4543,7 +4581,7 @@ async function failEngine(res, error, spec, params, tail = "") {
4543
4581
  res,
4544
4582
  500,
4545
4583
  GP_E_INTERNAL,
4546
- `this gateway could not complete the request: ${String(error)}${tail}`,
4584
+ `this gateway could not complete the request: ${wireCause(`the ${spec?.name ?? "tool"} route handler`, error)}${tail}`,
4547
4585
  gatewayFaultAdvice(spec)
4548
4586
  );
4549
4587
  }
@@ -4579,7 +4617,7 @@ function failEvidenceFrameShape(res, error, operationId, tail = "") {
4579
4617
  res,
4580
4618
  502,
4581
4619
  GP_E_INTERNAL,
4582
- `the daemon returned a last_evidence frame that does not match the engine contract (no parseable evidencePack${operationId === void 0 ? "" : ` for ${operationId}`}: ${String(error)})${tail}`,
4620
+ `the daemon returned a last_evidence frame that does not match the engine contract (no parseable evidencePack${operationId === void 0 ? "" : ` for ${operationId}`}: ${wireCause("the last_evidence frame parser", error)})${tail}`,
4583
4621
  "the daemon answered this request, so the transport is up and restarting it changes nothing here; this gateway validates a pack before rendering or forwarding it, so GET /v1/evidence/<operationId> and POST /v1/tools/last_evidence {operationId} will both refuse this frame for the same reason. Read what the attached app is doing now without performing anything: POST /v1/tools/observe, POST /v1/tools/assert_element or POST /v1/tools/probe_status. Producing a fresh pack for this operation means acting again, which is a decision this read cannot make for you."
4584
4622
  );
4585
4623
  }
@@ -4650,5 +4688,6 @@ export {
4650
4688
  assertLoopbackHost,
4651
4689
  assertTokenPolicy,
4652
4690
  createHttpGateway,
4653
- isLoopbackHost
4691
+ isLoopbackHost,
4692
+ setGatewayReportSink
4654
4693
  };
package/dist/index.js CHANGED
@@ -1683,7 +1683,7 @@ function slowEngineRemedy(method, surface = "mcp") {
1683
1683
  return `${poll}. The daemon serves one request at a time and is still working on this one, so ${reIssueGuidance(surface)}; a restart is authorised only by ${restarted}`;
1684
1684
  }
1685
1685
  var LATE_REPLY_RETENTION = 16;
1686
- var LOG_BODY_CHARS = 64 * 1024;
1686
+ var LOG_FIELD_CHARS = 120;
1687
1687
  var EngineJsonRpcClient = class {
1688
1688
  constructor(io, timeoutMs, identity = null, callerCeilingMs = CALLER_VISIBLE_CEILING_MS, surface = "mcp", expectedDaemonMethods = []) {
1689
1689
  this.io = io;
@@ -1910,11 +1910,11 @@ var EngineJsonRpcClient = class {
1910
1910
  try {
1911
1911
  parsed = JSON.parse(line);
1912
1912
  } catch {
1913
- this.report(`engine sent a non-JSON frame, dropped: ${truncate(line)}`);
1913
+ this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line)}`);
1914
1914
  return;
1915
1915
  }
1916
1916
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1917
- this.report(`engine sent a frame that is not a JSON object, dropped: ${truncate(line)}`);
1917
+ this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line)}`);
1918
1918
  return;
1919
1919
  }
1920
1920
  const frame = parsed;
@@ -1925,7 +1925,7 @@ var EngineJsonRpcClient = class {
1925
1925
  const tracked = [...this.pending.values()];
1926
1926
  const held = tracked.length === 0 ? "nothing is tracked now" : `this client still tracks ${tracked.length} request(s): ` + tracked.map((kept) => "'" + kept.method + "' id " + kept.id + (kept.settled ? " (caller already answered)" : "")).join(", ");
1927
1927
  this.report(
1928
- `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + truncate(line)
1928
+ `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line)
1929
1929
  );
1930
1930
  return;
1931
1931
  }
@@ -1952,13 +1952,13 @@ var EngineJsonRpcClient = class {
1952
1952
  this.retainForLateReply();
1953
1953
  return;
1954
1954
  }
1955
- this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${truncate(line)}`);
1955
+ this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line)}`);
1956
1956
  return;
1957
1957
  }
1958
- this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${truncate(line)}` : `engine sent an id-less frame with no request in flight: ${truncate(line)}`);
1958
+ this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line)}`);
1959
1959
  return;
1960
1960
  }
1961
- this.report(`engine sent a frame with a non-numeric request id (${jsonOrString(id)}), which this client never issues: ${truncate(line)}`);
1961
+ this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line)}`);
1962
1962
  }
1963
1963
  settleFromFrame(entry, frame) {
1964
1964
  if (frame.error) {
@@ -2215,8 +2215,17 @@ function attribute(error, entry, inferred = true) {
2215
2215
  error.remedy
2216
2216
  );
2217
2217
  }
2218
- function truncate(text) {
2219
- return text.length <= LOG_BODY_CHARS ? text : `${text.slice(0, LOG_BODY_CHARS)}\u2026 [+${text.length - LOG_BODY_CHARS} chars not logged]`;
2218
+ function frameBodyNotLoggedNote(serializedFrame) {
2219
+ const bytes = Buffer.byteLength(serializedFrame, "utf8");
2220
+ const digest = createHash("sha256").update(serializedFrame, "utf8").digest("hex").slice(0, 12);
2221
+ return `a ${bytes}-byte frame (sha256 ${digest}) whose text is not written to this log: on this socket a frame body is on-screen accessibility content \u2014 element titles and values, sometimes a document's text \u2014 and this log's sink is a file this product never sets the mode of, so the state root's 0700 does not cover it. Anything the daemon did record is in its evidence archive under the state root, read back with gp_last_evidence {operationId} or gp_export_evidence {operationId}`;
2222
+ }
2223
+ function shortFieldValue(value) {
2224
+ const text = JSON.stringify(value) ?? String(value);
2225
+ if (text.length <= LOG_FIELD_CHARS) return text;
2226
+ const bytes = Buffer.byteLength(text, "utf8");
2227
+ const digest = createHash("sha256").update(text, "utf8").digest("hex").slice(0, 12);
2228
+ return `${text.length}-char value (sha256 ${digest}, ${bytes} bytes) not quoted here`;
2220
2229
  }
2221
2230
  var ARCHIVE_OPERATION_ID = /^op_[0-9A-HJKMNP-TV-Z]{26}$/;
2222
2231
  function lateReplyBodyNote(serializedBody, operationId) {
@@ -4837,7 +4846,7 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
4837
4846
  "2025-03-26",
4838
4847
  MCP_PROTOCOL_VERSION
4839
4848
  ];
4840
- var SERVER_INFO = { name: "glasspane-mcp", version: "1.24.1" };
4849
+ var SERVER_INFO = { name: "glasspane-mcp", version: "1.25.2" };
4841
4850
  var PARSE_ERROR = -32700;
4842
4851
  var INVALID_REQUEST = -32600;
4843
4852
  var METHOD_NOT_FOUND = -32601;
@@ -1678,7 +1678,7 @@ function slowEngineRemedy(method, surface = "mcp") {
1678
1678
  return `${poll}. The daemon serves one request at a time and is still working on this one, so ${reIssueGuidance(surface)}; a restart is authorised only by ${restarted}`;
1679
1679
  }
1680
1680
  var LATE_REPLY_RETENTION = 16;
1681
- var LOG_BODY_CHARS = 64 * 1024;
1681
+ var LOG_FIELD_CHARS = 120;
1682
1682
  var EngineJsonRpcClient = class {
1683
1683
  constructor(io, timeoutMs, identity = null, callerCeilingMs = CALLER_VISIBLE_CEILING_MS, surface = "mcp", expectedDaemonMethods = []) {
1684
1684
  this.io = io;
@@ -1905,11 +1905,11 @@ var EngineJsonRpcClient = class {
1905
1905
  try {
1906
1906
  parsed = JSON.parse(line);
1907
1907
  } catch {
1908
- this.report(`engine sent a non-JSON frame, dropped: ${truncate(line)}`);
1908
+ this.report(`engine sent a non-JSON frame, dropped: ${frameBodyNotLoggedNote(line)}`);
1909
1909
  return;
1910
1910
  }
1911
1911
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1912
- this.report(`engine sent a frame that is not a JSON object, dropped: ${truncate(line)}`);
1912
+ this.report(`engine sent a frame that is not a JSON object, dropped: ${frameBodyNotLoggedNote(line)}`);
1913
1913
  return;
1914
1914
  }
1915
1915
  const frame = parsed;
@@ -1920,7 +1920,7 @@ var EngineJsonRpcClient = class {
1920
1920
  const tracked = [...this.pending.values()];
1921
1921
  const held = tracked.length === 0 ? "nothing is tracked now" : `this client still tracks ${tracked.length} request(s): ` + tracked.map((kept) => "'" + kept.method + "' id " + kept.id + (kept.settled ? " (caller already answered)" : "")).join(", ");
1922
1922
  this.report(
1923
- `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + truncate(line)
1923
+ `engine sent a frame for request id ${id}, which this client never issued (or already gave up on); ` + held + ": " + frameBodyNotLoggedNote(line)
1924
1924
  );
1925
1925
  return;
1926
1926
  }
@@ -1947,13 +1947,13 @@ var EngineJsonRpcClient = class {
1947
1947
  this.retainForLateReply();
1948
1948
  return;
1949
1949
  }
1950
- this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${truncate(line)}`);
1950
+ this.report(`engine sent an id-less frame with a result while '${target.method}' (id ${target.id}) is still waiting for its answer; an id-less answer from this daemon is an error frame, so this one was not delivered to any caller: ${frameBodyNotLoggedNote(line)}`);
1951
1951
  return;
1952
1952
  }
1953
- this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${truncate(line)}` : `engine sent an id-less frame with no request in flight: ${truncate(line)}`);
1953
+ this.report(frame.error ? `engine reported ${this.engineError(frame.error, null).code} with no request in flight: ${frameBodyNotLoggedNote(line)}` : `engine sent an id-less frame with no request in flight: ${frameBodyNotLoggedNote(line)}`);
1954
1954
  return;
1955
1955
  }
1956
- this.report(`engine sent a frame with a non-numeric request id (${jsonOrString(id)}), which this client never issues: ${truncate(line)}`);
1956
+ this.report(`engine sent a frame with a non-numeric request id (${shortFieldValue(id)}), which this client never issues: ${frameBodyNotLoggedNote(line)}`);
1957
1957
  }
1958
1958
  settleFromFrame(entry, frame) {
1959
1959
  if (frame.error) {
@@ -2210,8 +2210,17 @@ function attribute(error, entry, inferred = true) {
2210
2210
  error.remedy
2211
2211
  );
2212
2212
  }
2213
- function truncate(text) {
2214
- return text.length <= LOG_BODY_CHARS ? text : `${text.slice(0, LOG_BODY_CHARS)}\u2026 [+${text.length - LOG_BODY_CHARS} chars not logged]`;
2213
+ function frameBodyNotLoggedNote(serializedFrame) {
2214
+ const bytes = Buffer.byteLength(serializedFrame, "utf8");
2215
+ const digest = createHash("sha256").update(serializedFrame, "utf8").digest("hex").slice(0, 12);
2216
+ return `a ${bytes}-byte frame (sha256 ${digest}) whose text is not written to this log: on this socket a frame body is on-screen accessibility content \u2014 element titles and values, sometimes a document's text \u2014 and this log's sink is a file this product never sets the mode of, so the state root's 0700 does not cover it. Anything the daemon did record is in its evidence archive under the state root, read back with gp_last_evidence {operationId} or gp_export_evidence {operationId}`;
2217
+ }
2218
+ function shortFieldValue(value) {
2219
+ const text = JSON.stringify(value) ?? String(value);
2220
+ if (text.length <= LOG_FIELD_CHARS) return text;
2221
+ const bytes = Buffer.byteLength(text, "utf8");
2222
+ const digest = createHash("sha256").update(text, "utf8").digest("hex").slice(0, 12);
2223
+ return `${text.length}-char value (sha256 ${digest}, ${bytes} bytes) not quoted here`;
2215
2224
  }
2216
2225
  var ARCHIVE_OPERATION_ID = /^op_[0-9A-HJKMNP-TV-Z]{26}$/;
2217
2226
  function lateReplyBodyNote(serializedBody, operationId) {
@@ -4832,7 +4841,7 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
4832
4841
  "2025-03-26",
4833
4842
  MCP_PROTOCOL_VERSION
4834
4843
  ];
4835
- var SERVER_INFO = { name: "glasspane-mcp", version: "1.24.1" };
4844
+ var SERVER_INFO = { name: "glasspane-mcp", version: "1.25.2" };
4836
4845
  var PARSE_ERROR = -32700;
4837
4846
  var INVALID_REQUEST = -32600;
4838
4847
  var METHOD_NOT_FOUND = -32601;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glasspane-mcp",
3
- "version": "1.24.1",
3
+ "version": "1.25.2",
4
4
  "description": "GlassPane MCP stdio shell: JSON-RPC 2.0 over stdio bridging an AI agent to the glasspane engine daemon",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",