glasspane-mcp 0.1.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/audit-session.d.ts +22 -0
  4. package/dist/audit-session.d.ts.map +1 -0
  5. package/dist/audit-session.js +64 -0
  6. package/dist/audit-session.js.map +1 -0
  7. package/dist/canonical.d.ts +7 -0
  8. package/dist/canonical.d.ts.map +1 -0
  9. package/dist/canonical.js +23 -0
  10. package/dist/canonical.js.map +1 -0
  11. package/dist/dispatch.d.ts +47 -0
  12. package/dist/dispatch.d.ts.map +1 -0
  13. package/dist/dispatch.js +122 -0
  14. package/dist/dispatch.js.map +1 -0
  15. package/dist/engine-client.d.ts +54 -0
  16. package/dist/engine-client.d.ts.map +1 -0
  17. package/dist/engine-client.js +135 -0
  18. package/dist/engine-client.js.map +1 -0
  19. package/dist/errors.d.ts +23 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +22 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/evidence-report.d.ts +30 -0
  24. package/dist/evidence-report.d.ts.map +1 -0
  25. package/dist/evidence-report.js +161 -0
  26. package/dist/evidence-report.js.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +1476 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/io.d.ts +51 -0
  32. package/dist/io.d.ts.map +1 -0
  33. package/dist/io.js +74 -0
  34. package/dist/io.js.map +1 -0
  35. package/dist/project-registry.d.ts +76 -0
  36. package/dist/project-registry.d.ts.map +1 -0
  37. package/dist/project-registry.js +144 -0
  38. package/dist/project-registry.js.map +1 -0
  39. package/dist/tools.d.ts +255 -0
  40. package/dist/tools.d.ts.map +1 -0
  41. package/dist/tools.js +556 -0
  42. package/dist/tools.js.map +1 -0
  43. package/package.json +51 -0
  44. package/schemas/decision-log-entry.schema.json +45 -0
  45. package/schemas/evidence-pack.schema.json +359 -0
  46. package/schemas/recipe-config.schema.json +36 -0
  47. package/schemas/schemas/decision-log-entry.schema.json +45 -0
  48. package/schemas/schemas/evidence-pack.schema.json +359 -0
  49. package/schemas/schemas/recipe-config.schema.json +36 -0
package/dist/tools.js ADDED
@@ -0,0 +1,556 @@
1
+ import { z } from "zod";
2
+ import { SelectorSchema, ActionSchema, AssertionPropertySchema, parseEvidencePack, KernelSchemaError, } from "@iterate/kernel";
3
+ import { canonicalJson } from "./canonical.js";
4
+ import { EngineCallError } from "./engine-client.js";
5
+ import { formatToolError, formatToolErrorShape, GP_E_BAD_PARAMS, GP_E_INTERNAL, GP_E_NO_EVIDENCE, GP_E_NOT_FOUND, GP_E_PROJECT_LIMIT } from "./errors.js";
6
+ import { EvidenceAuditSession } from "./audit-session.js";
7
+ import { renderHTML, renderMarkdown, escapeHTML } from "./evidence-report.js";
8
+ import { ProjectListArgs, ProjectSetArgs, ProjectGetArgs, projectList, projectSet, projectGet, ProjectRegistryError, } from "./project-registry.js";
9
+ /* ------------------------------------------------------------------ *
10
+ * Tool‑argument validation schemas (spec §6.2). The engine validates
11
+ * daemon‑side too; this shell pre‑validates so bad args surface as
12
+ * isError without touching the engine. <selector> reuses kernel rule.
13
+ * ------------------------------------------------------------------ */
14
+ const OptionalUintSchema = z.number().int().nonnegative().optional();
15
+ const OptionalDepthSchema = z.number().int().min(1).max(10).optional();
16
+ const OptionalRoleSchema = z.string().max(128).optional();
17
+ const OptionalBundleIdSchema = z.string().max(256).optional();
18
+ const OptionalOperationIdSchema = z.string().regex(/^op_[0-9A-HJKMNP-TV-Z]{26}$/).optional();
19
+ const OptionalProjectIdSchema = z.string().regex(/^prj_[0-9A-HJKMNP-TV-Z]{26}$/).optional();
20
+ const ExpectSchema = z.union([z.string().max(512), z.boolean()]);
21
+ /** Crockford base32 body shared by op_/snap_ ids (P0 §4.1 / P1 v1.1 §1.2). */
22
+ const SnapshotIdSchema = z.string().regex(/^snap_[0-9A-HJKMNP-TV-Z]{26}$/);
23
+ const ActStepSchema = z.strictObject({
24
+ selector: SelectorSchema,
25
+ action: ActionSchema,
26
+ });
27
+ const RestoreStepsSchema = z.array(ActStepSchema).min(1).max(64).optional();
28
+ const RestoreModeSchema = z.string().max(32).optional();
29
+ export const AttachArgs = z.strictObject({
30
+ bundleId: OptionalBundleIdSchema,
31
+ pid: OptionalUintSchema,
32
+ projectId: OptionalProjectIdSchema,
33
+ }).refine((v) => v.bundleId !== undefined || v.pid !== undefined, {
34
+ message: "attach requires either bundleId or pid",
35
+ });
36
+ export const ObserveArgs = z.strictObject({
37
+ maxDepth: OptionalDepthSchema,
38
+ role: OptionalRoleSchema,
39
+ });
40
+ export const ActArgs = z.strictObject({
41
+ selector: SelectorSchema,
42
+ action: ActionSchema,
43
+ degrade: z.boolean().optional(),
44
+ });
45
+ export const AssertElementArgs = z.strictObject({
46
+ selector: SelectorSchema,
47
+ property: AssertionPropertySchema,
48
+ expected: ExpectSchema,
49
+ });
50
+ export const DiagnoseArgs = z.strictObject({
51
+ operationId: OptionalOperationIdSchema,
52
+ });
53
+ export const LastEvidenceArgs = z.strictObject({
54
+ operationId: OptionalOperationIdSchema,
55
+ });
56
+ export const SnapshotArgs = z.strictObject({
57
+ maxDepth: OptionalDepthSchema,
58
+ });
59
+ export const RestoreArgs = z.strictObject({
60
+ snapshotId: SnapshotIdSchema,
61
+ steps: RestoreStepsSchema,
62
+ mode: RestoreModeSchema,
63
+ });
64
+ /** P6 §5.4: probe connectivity query takes no arguments. */
65
+ export const ProbeStatusArgs = z.strictObject({});
66
+ /** Report format selector shared by the two audit tools (spec v1.3 §10.3). */
67
+ const ReportFormatSchema = z.enum(["html", "markdown"]).default("markdown");
68
+ export const ExportEvidenceArgs = z.strictObject({
69
+ operationId: z.string().regex(/^op_[0-9A-HJKMNP-TV-Z]{26}$/),
70
+ format: ReportFormatSchema,
71
+ });
72
+ export const RecentReportsArgs = z.strictObject({
73
+ limit: z.number().int().min(1).max(20).default(5),
74
+ format: ReportFormatSchema,
75
+ });
76
+ function zodIssueText(error) {
77
+ return error.issues
78
+ .map((issue) => `${issue.path.join(".")}: ${issue.message}`)
79
+ .join("; ");
80
+ }
81
+ function zodBridge(schema) {
82
+ return (raw) => {
83
+ const parsed = schema.safeParse(raw);
84
+ if (parsed.success) {
85
+ return { ok: true, value: parsed.data };
86
+ }
87
+ return { ok: false, issues: zodIssueText(parsed.error) };
88
+ };
89
+ }
90
+ /* Hand-written JSON Schemas (draft 2020-12) for tools/list. Kept minimal
91
+ * but faithful to the zod rules above. `$schema` omitted for brevity; the
92
+ * spec only asserts the "要点" (outline) of each input schema (§6.2). */
93
+ const selectorJsonSchema = {
94
+ type: "object",
95
+ additionalProperties: false,
96
+ properties: {
97
+ role: { type: "string", maxLength: 512 },
98
+ title: { type: "string", maxLength: 512 },
99
+ identifier: { type: "string", maxLength: 512 },
100
+ },
101
+ required: ["role"],
102
+ };
103
+ export const TOOL_SPECS = [
104
+ {
105
+ name: "gp_attach",
106
+ description: "Attach the engine to a running app by bundleId or pid.",
107
+ engineMethod: "attach",
108
+ inputSchema: {
109
+ type: "object",
110
+ additionalProperties: false,
111
+ properties: {
112
+ bundleId: { type: "string", maxLength: 256 },
113
+ pid: { type: "integer", minimum: 0 },
114
+ projectId: { type: "string", pattern: "^prj_[0-9A-HJKMNP-TV-Z]{26}$" },
115
+ },
116
+ oneOf: [
117
+ { required: ["bundleId"] },
118
+ { required: ["pid"] },
119
+ ],
120
+ },
121
+ validate: zodBridge(AttachArgs),
122
+ },
123
+ {
124
+ name: "gp_observe",
125
+ description: "Snapshot the attached app's accessibility tree.",
126
+ engineMethod: "observe",
127
+ inputSchema: {
128
+ type: "object",
129
+ additionalProperties: false,
130
+ properties: {
131
+ maxDepth: { type: "integer", minimum: 1, maximum: 10 },
132
+ role: { type: "string", maxLength: 128 },
133
+ },
134
+ },
135
+ validate: zodBridge(ObserveArgs),
136
+ },
137
+ {
138
+ name: "gp_act",
139
+ description: "Perform a UI action on the attached app and confirm it. " +
140
+ "If the daemon reports GP_E_BUSY_INPUT (real user input is contaminating the window), retry later, " +
141
+ "or set degrade: true to proceed immediately with the contamination recorded in evidence " +
142
+ "(attribution becomes weak + contaminated=true) — never silently clean.",
143
+ engineMethod: "act",
144
+ inputSchema: {
145
+ type: "object",
146
+ additionalProperties: false,
147
+ properties: {
148
+ selector: selectorJsonSchema,
149
+ action: {
150
+ type: "string",
151
+ enum: ["press", "increment", "decrement", "showMenu", "confirm", "cancel", "pick"],
152
+ },
153
+ degrade: { type: "boolean" },
154
+ },
155
+ required: ["selector", "action"],
156
+ },
157
+ validate: zodBridge(ActArgs),
158
+ },
159
+ {
160
+ name: "gp_assert_element",
161
+ description: "Assert a property of an element in the attached app.",
162
+ engineMethod: "assert_element",
163
+ inputSchema: {
164
+ type: "object",
165
+ additionalProperties: false,
166
+ properties: {
167
+ selector: selectorJsonSchema,
168
+ property: { type: "string", enum: ["title", "value", "role", "enabled", "focused"] },
169
+ expected: { oneOf: [{ type: "string", maxLength: 512 }, { type: "boolean" }] },
170
+ },
171
+ required: ["selector", "property", "expected"],
172
+ },
173
+ validate: zodBridge(AssertElementArgs),
174
+ },
175
+ {
176
+ name: "gp_diagnose",
177
+ description: "Diagnose the most recent (or the given) operation.",
178
+ engineMethod: "diagnose",
179
+ inputSchema: {
180
+ type: "object",
181
+ additionalProperties: false,
182
+ properties: {
183
+ operationId: { type: "string", pattern: "^op_[0-9A-HJKMNP-TV-Z]{26}$" },
184
+ },
185
+ },
186
+ validate: zodBridge(DiagnoseArgs),
187
+ },
188
+ {
189
+ name: "gp_last_evidence",
190
+ description: "Return the full evidence pack for the most recent (or given) operation.",
191
+ engineMethod: "last_evidence",
192
+ inputSchema: {
193
+ type: "object",
194
+ additionalProperties: false,
195
+ properties: {
196
+ operationId: { type: "string", pattern: "^op_[0-9A-HJKMNP-TV-Z]{26}$" },
197
+ },
198
+ },
199
+ validate: zodBridge(LastEvidenceArgs),
200
+ },
201
+ {
202
+ name: "gp_snapshot",
203
+ description: "Capture a digest-only baseline of the attached app's AX tree for later restore.",
204
+ engineMethod: "snapshot",
205
+ inputSchema: {
206
+ type: "object",
207
+ additionalProperties: false,
208
+ properties: {
209
+ maxDepth: { type: "integer", minimum: 1, maximum: 10 },
210
+ },
211
+ },
212
+ validate: zodBridge(SnapshotArgs),
213
+ },
214
+ {
215
+ name: "gp_restore",
216
+ description: "Restore from a snapshot: replay act steps over the baseline (tier-2 ffwd), or compare the current tree against it when steps are omitted.",
217
+ engineMethod: "restore",
218
+ inputSchema: {
219
+ type: "object",
220
+ additionalProperties: false,
221
+ properties: {
222
+ snapshotId: { type: "string", pattern: "^snap_[0-9A-HJKMNP-TV-Z]{26}$" },
223
+ steps: {
224
+ type: "array",
225
+ minItems: 1,
226
+ maxItems: 64,
227
+ items: {
228
+ type: "object",
229
+ additionalProperties: false,
230
+ properties: {
231
+ selector: selectorJsonSchema,
232
+ action: {
233
+ type: "string",
234
+ enum: ["press", "increment", "decrement", "showMenu", "confirm", "cancel", "pick"],
235
+ },
236
+ },
237
+ required: ["selector", "action"],
238
+ },
239
+ },
240
+ mode: { type: "string", maxLength: 32 },
241
+ },
242
+ required: ["snapshotId"],
243
+ },
244
+ validate: zodBridge(RestoreArgs),
245
+ },
246
+ {
247
+ name: "gp_probe_status",
248
+ description: "List GlassPaneProbe connections (pid, capabilities, events seen) and whether the attached app has a live probe — probe presence is what makes T4/T5/T7/T8 verdicts and tier-1 checkpoint restores decidable.",
249
+ engineMethod: "probe_status",
250
+ inputSchema: {
251
+ type: "object",
252
+ additionalProperties: false,
253
+ properties: {},
254
+ },
255
+ validate: zodBridge(ProbeStatusArgs),
256
+ },
257
+ {
258
+ name: "gp_export_evidence",
259
+ description: "Render one operation's evidence pack as a human-readable report (HTML or Markdown) for the developer audit view.",
260
+ engineMethod: "export_evidence",
261
+ inputSchema: {
262
+ type: "object",
263
+ additionalProperties: false,
264
+ properties: {
265
+ operationId: { type: "string", pattern: "^op_[0-9A-HJKMNP-TV-Z]{26}$" },
266
+ format: { type: "string", enum: ["html", "markdown"] },
267
+ },
268
+ required: ["operationId"],
269
+ },
270
+ validate: zodBridge(ExportEvidenceArgs),
271
+ execute: exportEvidence,
272
+ },
273
+ {
274
+ name: "gp_recent_reports",
275
+ description: "Aggregate the most recent operations' four-section reports (HTML or Markdown) into one audit view.",
276
+ engineMethod: "recent_reports",
277
+ inputSchema: {
278
+ type: "object",
279
+ additionalProperties: false,
280
+ properties: {
281
+ limit: { type: "integer", minimum: 1, maximum: 20 },
282
+ format: { type: "string", enum: ["html", "markdown"] },
283
+ },
284
+ },
285
+ validate: zodBridge(RecentReportsArgs),
286
+ execute: recentReports,
287
+ },
288
+ {
289
+ name: "gp_project_list",
290
+ description: "List all registered GlassPane projects (P1 spec v1.4).",
291
+ engineMethod: "project_list",
292
+ inputSchema: {
293
+ type: "object",
294
+ additionalProperties: false,
295
+ properties: {},
296
+ },
297
+ validate: zodBridge(ProjectListArgs),
298
+ execute: projectListTool,
299
+ },
300
+ {
301
+ name: "gp_project_set",
302
+ description: "Create or update a GlassPane project. Omit projectId to register a new project; include it to update an existing one.",
303
+ engineMethod: "project_set",
304
+ inputSchema: {
305
+ type: "object",
306
+ additionalProperties: false,
307
+ properties: {
308
+ projectId: { type: "string", pattern: "^prj_[0-9A-HJKMNP-TV-Z]{26}$" },
309
+ displayName: { type: "string", minLength: 1, maxLength: 256 },
310
+ bundleId: { type: "string", maxLength: 256 },
311
+ pid: { type: "integer", minimum: 0 },
312
+ recipeConfigPath: { type: "string", maxLength: 1024 },
313
+ calibrationAssetsPath: { type: "string", maxLength: 1024 },
314
+ evidenceStoragePath: { type: "string", maxLength: 1024 },
315
+ },
316
+ required: ["displayName"],
317
+ oneOf: [
318
+ { required: ["bundleId"] },
319
+ { required: ["pid"] },
320
+ ],
321
+ },
322
+ validate: zodBridge(ProjectSetArgs),
323
+ execute: projectSetTool,
324
+ },
325
+ {
326
+ name: "gp_project_get",
327
+ description: "Fetch one GlassPane project by its project ID.",
328
+ engineMethod: "project_get",
329
+ inputSchema: {
330
+ type: "object",
331
+ additionalProperties: false,
332
+ properties: {
333
+ projectId: { type: "string", pattern: "^prj_[0-9A-HJKMNP-TV-Z]{26}$" },
334
+ },
335
+ required: ["projectId"],
336
+ },
337
+ validate: zodBridge(ProjectGetArgs),
338
+ execute: projectGetTool,
339
+ },
340
+ ];
341
+ export const TOOL_BY_NAME = new Map(TOOL_SPECS.map((spec) => [spec.name, spec]));
342
+ /* ------------------------------------------------------------------ *
343
+ * Tools/call execution (spec §6.2): pre-validate -> forward -> map error.
344
+ * ------------------------------------------------------------------ */
345
+ /**
346
+ * Execute a tool against the engine client. Validates arguments against
347
+ * the tool's zod schema (isError + GP_E_BAD_PARAMS on failure), then either
348
+ * runs the tool's own `execute` (orchestrated tools) or forwards the method
349
+ * to the engine and maps engine/connection errors to agent-facing errors.
350
+ */
351
+ export async function executeTool(spec, args, engine, session = new EvidenceAuditSession()) {
352
+ const checked = spec.validate(args);
353
+ if (!checked.ok) {
354
+ return {
355
+ content: [{ type: "text", text: formatToolError(GP_E_BAD_PARAMS, `invalid arguments for ${spec.name}`, `check the tool's input schema; ${checked.issues}`) }],
356
+ isError: true,
357
+ };
358
+ }
359
+ if (spec.execute !== undefined) {
360
+ return spec.execute(checked.value, { engine, session });
361
+ }
362
+ try {
363
+ const raw = await engine.call(spec.engineMethod, checked.value);
364
+ if (spec.name === "gp_attach") {
365
+ // A successful attach invalidates the daemon's evidence history, so
366
+ // the session trail starts fresh (spec v1.3 §10.3).
367
+ session.reset();
368
+ }
369
+ // Spec §6.3: evidence packs are passed through a strong validation via
370
+ // the kernel schema before surfacing to the agent, so a Swift↔TS drift
371
+ // (assertion C35) fails here as a tool error instead of corrupt JSON.
372
+ if (spec.engineMethod === "last_evidence") {
373
+ parseEvidenceFrame(raw);
374
+ }
375
+ session.record(raw);
376
+ return {
377
+ content: [{ type: "text", text: canonicalJson(raw) }],
378
+ isError: false,
379
+ };
380
+ }
381
+ catch (error) {
382
+ if (error instanceof EngineCallError) {
383
+ return {
384
+ content: [{ type: "text", text: formatToolErrorShape(error.toBody()) }],
385
+ isError: true,
386
+ };
387
+ }
388
+ if (error instanceof KernelSchemaError) {
389
+ return {
390
+ content: [{ type: "text", text: formatToolError(GP_E_INTERNAL, `engine returned an invalid evidence pack: ${error.message}`, "engine and kernel schema drifted; fix the common fixtures (assertion C35)") }],
391
+ isError: true,
392
+ };
393
+ }
394
+ return {
395
+ content: [{ type: "text", text: formatToolError(GP_E_INTERNAL, `internal shell error: ${String(error)}`, "see the MCP server logs and retry") }],
396
+ isError: true,
397
+ };
398
+ }
399
+ }
400
+ /**
401
+ * Strongly validates the engine's last_evidence result (§6.3) and returns
402
+ * the parsed pack. The engine frame is `{evidencePack: {…}}`; the kernel
403
+ * validator consumes the pack body directly and throws on any violation.
404
+ */
405
+ function parseEvidenceFrame(raw) {
406
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
407
+ throw new KernelSchemaError("evidence pack", [{
408
+ path: "evidencePack",
409
+ message: "expected an object frame with a nested evidencePack field",
410
+ }]);
411
+ }
412
+ const frame = raw;
413
+ if (typeof frame.evidencePack !== "object" || frame.evidencePack === null) {
414
+ throw new KernelSchemaError("evidence pack", [{
415
+ path: "evidencePack",
416
+ message: "missing evidencePack field in last_evidence result",
417
+ }]);
418
+ }
419
+ return parseEvidencePack(frame.evidencePack);
420
+ }
421
+ /* ------------------------------------------------------------------ *
422
+ * Project tools (spec v1.4 §4): operate on the shared projects.json at
423
+ * the MCP layer — no socket methods are added ("不改变 socket 协议方法表").
424
+ * ------------------------------------------------------------------ */
425
+ async function projectListTool() {
426
+ const projects = projectList();
427
+ return {
428
+ content: [{ type: "text", text: canonicalJson({ projects }) }],
429
+ isError: false,
430
+ };
431
+ }
432
+ async function projectSetTool(args) {
433
+ try {
434
+ const entry = projectSet(args);
435
+ return { content: [{ type: "text", text: canonicalJson({ project: entry }) }], isError: false };
436
+ }
437
+ catch (error) {
438
+ return mapProjectError(error);
439
+ }
440
+ }
441
+ async function projectGetTool(args) {
442
+ const argv = args;
443
+ const entry = projectGet(argv.projectId);
444
+ if (entry === undefined) {
445
+ return {
446
+ content: [{ type: "text", text: formatToolError("GP_E_NOT_FOUND", `unknown project ${argv.projectId}`, "check the projectId; use gp_project_list to view available projects") }],
447
+ isError: true,
448
+ };
449
+ }
450
+ return { content: [{ type: "text", text: canonicalJson({ project: entry }) }], isError: false };
451
+ }
452
+ function mapProjectError(error) {
453
+ if (error instanceof ProjectRegistryError) {
454
+ return {
455
+ content: [{ type: "text", text: formatToolError(error.code, error.message, error.code === GP_E_PROJECT_LIMIT
456
+ ? "delete unused projects first, then retry"
457
+ : error.code === GP_E_NOT_FOUND
458
+ ? "check the projectId; use gp_project_list to view available projects"
459
+ : "check the tool's input schema and retry") }],
460
+ isError: true,
461
+ };
462
+ }
463
+ return {
464
+ content: [{ type: "text", text: formatToolError(GP_E_INTERNAL, `internal shell error in project registry: ${String(error)}`, "see the MCP server logs and retry") }],
465
+ isError: true,
466
+ };
467
+ }
468
+ /* ------------------------------------------------------------------ *
469
+ * Audit tools (spec v1.3 §10.3): fetch-centred renderers over the frozen
470
+ * daemon method table — `last_evidence {operationId}` (no new daemon method,
471
+ * no schema change). Shared rendering with the Swift engine mirror keeps the
472
+ * HTML/Markdown contract under one golden test set.
473
+ * ------------------------------------------------------------------ */
474
+ async function exportEvidence(args, context) {
475
+ const argv = args;
476
+ const render = argv.format === "html" ? renderHTML : renderMarkdown;
477
+ try {
478
+ const raw = await context.engine.call("last_evidence", { operationId: argv.operationId });
479
+ const pack = parseEvidenceFrame(raw);
480
+ context.session.record(raw);
481
+ return { content: [{ type: "text", text: render(pack, undefined) }], isError: false };
482
+ }
483
+ catch (error) {
484
+ return mapAuditError(error);
485
+ }
486
+ }
487
+ async function recentReports(args, context) {
488
+ const argv = args;
489
+ const ids = context.session.recentIds(argv.limit);
490
+ if (ids.length === 0) {
491
+ return {
492
+ content: [{ type: "text", text: formatToolError(GP_E_NO_EVIDENCE, "no operations recorded in this session", "run gp_act / gp_assert_element first, then retry gp_recent_reports") }],
493
+ isError: true,
494
+ };
495
+ }
496
+ // Fetch each trail id; the daemon's bounded history may have evicted it or
497
+ // the engine may have restarted, so per-item misses are skipped with a
498
+ // note instead of failing the whole report.
499
+ const packs = [];
500
+ const skipped = [];
501
+ for (const id of ids) {
502
+ try {
503
+ const raw = await context.engine.call("last_evidence", { operationId: id });
504
+ packs.push({ id, pack: parseEvidenceFrame(raw) });
505
+ }
506
+ catch (error) {
507
+ if (error instanceof EngineCallError && error.code === GP_E_NO_EVIDENCE) {
508
+ skipped.push(id);
509
+ }
510
+ else {
511
+ return mapAuditError(error);
512
+ }
513
+ }
514
+ }
515
+ if (packs.length === 0) {
516
+ return {
517
+ content: [{ type: "text", text: formatToolError(GP_E_NO_EVIDENCE, "no recent evidence is reachable in the daemon history", "the engine may have restarted; re-run gp_act / gp_assert_element to regenerate evidence") }],
518
+ isError: true,
519
+ };
520
+ }
521
+ const render = argv.format === "html" ? renderHTML : renderMarkdown;
522
+ const header = argv.format === "html"
523
+ ? `<h1>GlassPane recent reports (${packs.length})</h1>`
524
+ : `# GlassPane recent reports (${packs.length})`;
525
+ const skipNote = skipped.length === 0 ? "" : argv.format === "html"
526
+ ? `<p class="gp-skipped">skipped ${skipped.length} unreachable ${skipped.length === 1 ? "entry" : "entries"}: ${escapeHTML(skipped.join(", "))}</p>`
527
+ : `> skipped ${skipped.length} unreachable ${skipped.length === 1 ? "entry" : "entries"}: ${skipped.join(", ")}`;
528
+ const separator = argv.format === "html" ? "\n<hr>\n" : "\n\n---\n";
529
+ const body = packs.map(({ pack }) => render(pack, undefined)).join(separator);
530
+ const sections = [header];
531
+ if (skipNote !== "") {
532
+ sections.push(skipNote);
533
+ }
534
+ sections.push(body);
535
+ return { content: [{ type: "text", text: sections.join("\n") }], isError: false };
536
+ }
537
+ /** Error mapping shared by the audit tools (spec v1.3 §10.3 / P0 §3.4). */
538
+ function mapAuditError(error) {
539
+ if (error instanceof EngineCallError) {
540
+ return {
541
+ content: [{ type: "text", text: formatToolErrorShape(error.toBody()) }],
542
+ isError: true,
543
+ };
544
+ }
545
+ if (error instanceof KernelSchemaError) {
546
+ return {
547
+ content: [{ type: "text", text: formatToolError(GP_E_INTERNAL, `engine returned an invalid evidence pack: ${error.message}`, "engine and kernel schema drifted; fix the common fixtures (assertion C35)") }],
548
+ isError: true,
549
+ };
550
+ }
551
+ return {
552
+ content: [{ type: "text", text: formatToolError(GP_E_INTERNAL, `internal shell error: ${String(error)}`, "see the MCP server logs and retry") }],
553
+ isError: true,
554
+ };
555
+ }
556
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,GAKlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAuB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC1J,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,WAAW,EACX,UAAU,EACV,UAAU,EACV,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B;;;;wEAIwE;AAExE,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,E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D,2EAA2E,CAC5E,EAAE,CAAC;YACJ,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAC7C,aAAa,EACb,yBAAyB,MAAM,CAAC,KAAK,CAAC,EAAE,EACxC,mCAAmC,CACpC,EAAE,CAAC;QACJ,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "glasspane-mcp",
3
+ "version": "0.1.0",
4
+ "description": "GlassPane MCP stdio shell: JSON-RPC 2.0 over stdio bridging an AI agent to the glasspane engine daemon",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "glasspane-mcp": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "schemas",
14
+ "LICENSE",
15
+ "README.md"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.json",
28
+ "bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node18 --external:zod --outfile=dist/index.js && cp -R ../kernel/schemas schemas",
29
+ "test": "npm run build && node --test test/*.test.mjs",
30
+ "prepublishOnly": "npm run build && npm run bundle"
31
+ },
32
+ "license": "MIT",
33
+ "author": "jingzhao-l",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/jingzhao-l/GlassPane.git",
37
+ "directory": "mcp-shell"
38
+ },
39
+ "bugs": { "url": "https://github.com/jingzhao-l/GlassPane/issues" },
40
+ "homepage": "https://github.com/jingzhao-l/GlassPane/tree/main/mcp-shell#readme",
41
+ "keywords": ["mcp", "model-context-protocol", "macos", "accessibility", "verification", "ai-agents"],
42
+ "dependencies": {
43
+ "zod": "3.25.76"
44
+ },
45
+ "devDependencies": {
46
+ "@iterate/kernel": "file:../kernel",
47
+ "@types/node": "26.5.1",
48
+ "esbuild": "^0.28.2",
49
+ "typescript": "5.9.3"
50
+ }
51
+ }