xaq-cli 0.1.0-nightly.93 → 0.1.0-nightly.94

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.
@@ -74,7 +74,7 @@ Example:
74
74
  const { openAdminChannel } = await import("./admin-DbJXEo2d.js");
75
75
  const { TerminalPrompter } = await import("./prompt-BEH311I7.js");
76
76
  const { connectAgentMcp } = await import("./agent-B8a-Ivyd.js");
77
- const { SmokeRun } = await import("./run-zakbVgQR.js");
77
+ const { SmokeRun } = await import("./run-BQB8DwLB.js");
78
78
  const { renderReport } = await import("./report-D2D_6E5O.js");
79
79
  if (!o.scratch) throw new Error("smoke google-workspace runs live on the connected Google account: it reads existing files and mail, and writes only into a new scratch folder and ONE draft to the account itself, which it removes again. Pass --scratch to run it.");
80
80
  const out = safeWriter(o.json ? process.stderr : process.stdout);
@@ -123,4 +123,4 @@ Example:
123
123
  //#endregion
124
124
  export { registerSmokeCommands };
125
125
 
126
- //# sourceMappingURL=cli-Wp2ejVBT.js.map
126
+ //# sourceMappingURL=cli-BBSYW5Pe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-Wp2ejVBT.js","names":[],"sources":["../server/smoke/cli.ts"],"sourcesContent":["// `xaq smoke google-workspace --scratch`: run on xaq's machine, through the daemon's admin API over the local admin\n// channel (server/connections-cli/admin.ts) and /mcp as a temporary agent. See run.ts for what it does.\n\nimport type { Command } from \"commander\";\nimport { LEGACY_PRODUCT } from \"../brand.ts\";\nimport { resolveDataDir } from \"../config.ts\";\nimport { NPX } from \"../listen/version.ts\";\nimport type { SmokeFlags } from \"./run.ts\";\n\nconst GROUP = \"MCP connections (on xaq's machine):\";\n\n/**\n * A line printer that can't kill the run: once the stream fails (EIO or EPIPE from a terminal that went away, e.g.\n * after SIGHUP), later lines are dropped instead of throwing or crashing on an unhandled 'error'.\n */\nexport function safeWriter(stream: NodeJS.WritableStream): { print: (line?: string) => void; dispose: () => void } {\n let dead = false;\n const onError = () => {\n dead = true;\n };\n stream.on(\"error\", onError);\n return {\n print(line = \"\") {\n if (dead) return;\n try {\n stream.write(`${line}\\n`, (err) => {\n if (err) dead = true;\n });\n } catch {\n dead = true;\n }\n },\n dispose: () => stream.removeListener(\"error\", onError),\n };\n}\n\nexport interface SmokeSignalOptions {\n print: (line: string) => void;\n exit: (code: number) => void;\n /** The second Ctrl-C: the quick part of cleanup (agent, attachmentDirs), bounded. */\n fastCleanup: () => Promise<void>;\n /** What may still be there, in a sentence. */\n leftovers: () => string;\n /** Upper bound on the second Ctrl-C's cleanup before quitting anyway (default 8 s). */\n quitWithinMs?: number;\n}\n\n/**\n * Signals during a run. SIGTERM and SIGHUP (a closed terminal, a stopped service) always act like the first Ctrl-C:\n * no new step starts and the run's full cleanup runs. The first Ctrl-C does the same; a second one runs the quick\n * cleanup (delete the agent, restore attachmentDirs) with a short timeout, says what may be left and quits.\n * Returns the remover.\n */\nexport function installSmokeSignals(controller: AbortController, opts: SmokeSignalOptions): () => void {\n let interrupts = 0;\n let quitting = false;\n const stop = (why: string) => {\n if (controller.signal.aborted) return;\n opts.print(`\\n${why}: stopping after the current call, then cleaning up.${why === \"Ctrl-C\" ? \" Press Ctrl-C again to quit sooner (only the agent and attachmentDirs are cleaned up then).\" : \"\"}`);\n controller.abort();\n };\n const onInt = () => {\n interrupts++;\n if (interrupts === 1) return stop(\"Ctrl-C\");\n if (quitting) return;\n quitting = true;\n opts.print(\"\\nQuitting: deleting the temporary agent and restoring attachmentDirs first…\");\n const deadline = new Promise<void>((r) => setTimeout(r, opts.quitWithinMs ?? 8000).unref?.());\n void Promise.race([opts.fastCleanup().catch(() => {}), deadline]).then(() => {\n opts.print(`Quit before the cleanup finished. ${opts.leftovers()}`);\n opts.exit(130);\n });\n };\n const onTerm = () => stop(\"SIGTERM\");\n const onHup = () => stop(\"SIGHUP\");\n process.on(\"SIGINT\", onInt);\n process.on(\"SIGTERM\", onTerm);\n process.on(\"SIGHUP\", onHup);\n return () => {\n process.removeListener(\"SIGINT\", onInt);\n process.removeListener(\"SIGTERM\", onTerm);\n process.removeListener(\"SIGHUP\", onHup);\n };\n}\n\nexport function registerSmokeCommands(program: Command): void {\n const smoke = program\n .command(\"smoke\")\n .description(\"live end-to-end checks against the connected accounts, safe by construction\")\n .summary(\"live end-to-end check of a connection\")\n .helpGroup(GROUP);\n\n smoke\n .command(\"google-workspace\")\n .description(\"check Gmail attachments and the google-workspace extension end to end on the real account: reads anything, writes only into a new scratch folder and ONE draft to itself, cleans up\")\n .option(\"--scratch\", \"required: confirms the run may create its scratch folder, its draft and its temporary agent (all removed again)\")\n .option(\"--account <email>\", \"the Gmail account (default: the only one, or the one the Workspace connection is signed in as)\")\n .option(\"--connection <slug>\", \"the google-workspace connection (default: the only one)\")\n .option(\"--json\", \"print the result table as JSON on stdout (progress goes to stderr)\")\n .option(\"-y, --yes\", \"don't ask before running\")\n .option(\"-d, --data <dir>\", `xaq's data directory (default ~/.xaq, or an existing ~/.${LEGACY_PRODUCT}; env XAQ_DATA)`)\n .addHelpText(\n \"after\",\n `\nPrints the plan first and asks (or --yes). Exit code 0 only when every step passes and nothing is left behind.\n\nExample:\n ${NPX} smoke google-workspace --scratch`,\n )\n .action(async (o: SmokeFlags & { data?: string }) => {\n const { openAdminChannel } = await import(\"../connections-cli/admin.ts\");\n const { TerminalPrompter } = await import(\"../connections-cli/prompt.ts\");\n const { connectAgentMcp } = await import(\"./agent.ts\");\n const { SmokeRun } = await import(\"./run.ts\");\n const { renderReport } = await import(\"./report.ts\");\n if (!o.scratch) {\n throw new Error(\n \"smoke google-workspace runs live on the connected Google account: it reads existing files and mail, and writes only into a new scratch folder and ONE draft to the account itself, which it removes again. Pass --scratch to run it.\",\n );\n }\n const out = safeWriter(o.json ? process.stderr : process.stdout);\n const err = o.json ? out : safeWriter(process.stderr);\n const json = o.json ? safeWriter(process.stdout) : null;\n const channel = openAdminChannel({ dataDir: resolveDataDir(o.data, { quiet: true }) });\n const prompter = new TerminalPrompter(!!o.yes, { input: process.stdin, output: o.json ? process.stderr : process.stdout });\n const controller = new AbortController();\n const run = new SmokeRun(o, {\n admin: channel,\n connectMcp: (key) => connectAgentMcp(channel.baseUrl, key),\n print: out.print,\n confirm: (q) => prompter.confirm(q, false),\n signal: controller.signal,\n });\n const remove = installSmokeSignals(controller, {\n print: (l) => err.print(l),\n fastCleanup: () => run.fastCleanup(3000),\n exit: (code) => {\n channel.close();\n process.exit(code);\n },\n leftovers: () => {\n const left = run.pendingLeftovers();\n return left.length ? `These may be left: ${left.join(\"; \")}. The next run removes the agent and the attachmentDirs entry and lists the rest.` : \"Nothing was left.\";\n },\n });\n try {\n const report = await run.run();\n if (json) json.print(JSON.stringify(report, null, 2));\n else for (const l of [\"\", ...renderReport(report)]) out.print(l);\n process.exitCode = report.ok ? 0 : report.interrupted ? 130 : 1;\n } finally {\n remove();\n prompter.close();\n channel.close();\n out.dispose();\n if (err !== out) err.dispose();\n json?.dispose();\n }\n });\n}\n"],"mappings":";;;;;AASA,MAAM,QAAQ;;;;;AAMd,SAAgB,WAAW,QAAwF;CACjH,IAAI,OAAO;CACX,MAAM,gBAAgB;EACpB,OAAO;CACT;CACA,OAAO,GAAG,SAAS,OAAO;CAC1B,OAAO;EACL,MAAM,OAAO,IAAI;GACf,IAAI,MAAM;GACV,IAAI;IACF,OAAO,MAAM,GAAG,KAAK,MAAM,QAAQ;KACjC,IAAI,KAAK,OAAO;IAClB,CAAC;GACH,QAAQ;IACN,OAAO;GACT;EACF;EACA,eAAe,OAAO,eAAe,SAAS,OAAO;CACvD;AACF;;;;;;;AAmBA,SAAgB,oBAAoB,YAA6B,MAAsC;CACrG,IAAI,aAAa;CACjB,IAAI,WAAW;CACf,MAAM,QAAQ,QAAgB;EAC5B,IAAI,WAAW,OAAO,SAAS;EAC/B,KAAK,MAAM,KAAK,IAAI,sDAAsD,QAAQ,WAAW,gGAAgG,IAAI;EACjM,WAAW,MAAM;CACnB;CACA,MAAM,cAAc;EAClB;EACA,IAAI,eAAe,GA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AAM,CAAC;GAC/D,QAAQ,WAAW,OAAO,KAAK,IAAI,OAAO,cAAc,MAAM;EAChE,UAAU;GACR,OAAO;GACP,SAAS,MAAM;GACf,QAAQ,MAAM;GACd,IAAI,QAAQ;GACZ,IAAI,QAAQ,KAAK,IAAI,QAAQ;GAC7B,MAAM,QAAQ;EAChB;CACF,CAAC;AACL"}
1
+ {"version":3,"file":"cli-BBSYW5Pe.js","names":[],"sources":["../server/smoke/cli.ts"],"sourcesContent":["// `xaq smoke google-workspace --scratch`: run on xaq's machine, through the daemon's admin API over the local admin\n// channel (server/connections-cli/admin.ts) and /mcp as a temporary agent. See run.ts for what it does.\n\nimport type { Command } from \"commander\";\nimport { LEGACY_PRODUCT } from \"../brand.ts\";\nimport { resolveDataDir } from \"../config.ts\";\nimport { NPX } from \"../listen/version.ts\";\nimport type { SmokeFlags } from \"./run.ts\";\n\nconst GROUP = \"MCP connections (on xaq's machine):\";\n\n/**\n * A line printer that can't kill the run: once the stream fails (EIO or EPIPE from a terminal that went away, e.g.\n * after SIGHUP), later lines are dropped instead of throwing or crashing on an unhandled 'error'.\n */\nexport function safeWriter(stream: NodeJS.WritableStream): { print: (line?: string) => void; dispose: () => void } {\n let dead = false;\n const onError = () => {\n dead = true;\n };\n stream.on(\"error\", onError);\n return {\n print(line = \"\") {\n if (dead) return;\n try {\n stream.write(`${line}\\n`, (err) => {\n if (err) dead = true;\n });\n } catch {\n dead = true;\n }\n },\n dispose: () => stream.removeListener(\"error\", onError),\n };\n}\n\nexport interface SmokeSignalOptions {\n print: (line: string) => void;\n exit: (code: number) => void;\n /** The second Ctrl-C: the quick part of cleanup (agent, attachmentDirs), bounded. */\n fastCleanup: () => Promise<void>;\n /** What may still be there, in a sentence. */\n leftovers: () => string;\n /** Upper bound on the second Ctrl-C's cleanup before quitting anyway (default 8 s). */\n quitWithinMs?: number;\n}\n\n/**\n * Signals during a run. SIGTERM and SIGHUP (a closed terminal, a stopped service) always act like the first Ctrl-C:\n * no new step starts and the run's full cleanup runs. The first Ctrl-C does the same; a second one runs the quick\n * cleanup (delete the agent, restore attachmentDirs) with a short timeout, says what may be left and quits.\n * Returns the remover.\n */\nexport function installSmokeSignals(controller: AbortController, opts: SmokeSignalOptions): () => void {\n let interrupts = 0;\n let quitting = false;\n const stop = (why: string) => {\n if (controller.signal.aborted) return;\n opts.print(`\\n${why}: stopping after the current call, then cleaning up.${why === \"Ctrl-C\" ? \" Press Ctrl-C again to quit sooner (only the agent and attachmentDirs are cleaned up then).\" : \"\"}`);\n controller.abort();\n };\n const onInt = () => {\n interrupts++;\n if (interrupts === 1) return stop(\"Ctrl-C\");\n if (quitting) return;\n quitting = true;\n opts.print(\"\\nQuitting: deleting the temporary agent and restoring attachmentDirs first…\");\n const deadline = new Promise<void>((r) => setTimeout(r, opts.quitWithinMs ?? 8000).unref?.());\n void Promise.race([opts.fastCleanup().catch(() => {}), deadline]).then(() => {\n opts.print(`Quit before the cleanup finished. ${opts.leftovers()}`);\n opts.exit(130);\n });\n };\n const onTerm = () => stop(\"SIGTERM\");\n const onHup = () => stop(\"SIGHUP\");\n process.on(\"SIGINT\", onInt);\n process.on(\"SIGTERM\", onTerm);\n process.on(\"SIGHUP\", onHup);\n return () => {\n process.removeListener(\"SIGINT\", onInt);\n process.removeListener(\"SIGTERM\", onTerm);\n process.removeListener(\"SIGHUP\", onHup);\n };\n}\n\nexport function registerSmokeCommands(program: Command): void {\n const smoke = program\n .command(\"smoke\")\n .description(\"live end-to-end checks against the connected accounts, safe by construction\")\n .summary(\"live end-to-end check of a connection\")\n .helpGroup(GROUP);\n\n smoke\n .command(\"google-workspace\")\n .description(\"check Gmail attachments and the google-workspace extension end to end on the real account: reads anything, writes only into a new scratch folder and ONE draft to itself, cleans up\")\n .option(\"--scratch\", \"required: confirms the run may create its scratch folder, its draft and its temporary agent (all removed again)\")\n .option(\"--account <email>\", \"the Gmail account (default: the only one, or the one the Workspace connection is signed in as)\")\n .option(\"--connection <slug>\", \"the google-workspace connection (default: the only one)\")\n .option(\"--json\", \"print the result table as JSON on stdout (progress goes to stderr)\")\n .option(\"-y, --yes\", \"don't ask before running\")\n .option(\"-d, --data <dir>\", `xaq's data directory (default ~/.xaq, or an existing ~/.${LEGACY_PRODUCT}; env XAQ_DATA)`)\n .addHelpText(\n \"after\",\n `\nPrints the plan first and asks (or --yes). Exit code 0 only when every step passes and nothing is left behind.\n\nExample:\n ${NPX} smoke google-workspace --scratch`,\n )\n .action(async (o: SmokeFlags & { data?: string }) => {\n const { openAdminChannel } = await import(\"../connections-cli/admin.ts\");\n const { TerminalPrompter } = await import(\"../connections-cli/prompt.ts\");\n const { connectAgentMcp } = await import(\"./agent.ts\");\n const { SmokeRun } = await import(\"./run.ts\");\n const { renderReport } = await import(\"./report.ts\");\n if (!o.scratch) {\n throw new Error(\n \"smoke google-workspace runs live on the connected Google account: it reads existing files and mail, and writes only into a new scratch folder and ONE draft to the account itself, which it removes again. Pass --scratch to run it.\",\n );\n }\n const out = safeWriter(o.json ? process.stderr : process.stdout);\n const err = o.json ? out : safeWriter(process.stderr);\n const json = o.json ? safeWriter(process.stdout) : null;\n const channel = openAdminChannel({ dataDir: resolveDataDir(o.data, { quiet: true }) });\n const prompter = new TerminalPrompter(!!o.yes, { input: process.stdin, output: o.json ? process.stderr : process.stdout });\n const controller = new AbortController();\n const run = new SmokeRun(o, {\n admin: channel,\n connectMcp: (key) => connectAgentMcp(channel.baseUrl, key),\n print: out.print,\n confirm: (q) => prompter.confirm(q, false),\n signal: controller.signal,\n });\n const remove = installSmokeSignals(controller, {\n print: (l) => err.print(l),\n fastCleanup: () => run.fastCleanup(3000),\n exit: (code) => {\n channel.close();\n process.exit(code);\n },\n leftovers: () => {\n const left = run.pendingLeftovers();\n return left.length ? `These may be left: ${left.join(\"; \")}. The next run removes the agent and the attachmentDirs entry and lists the rest.` : \"Nothing was left.\";\n },\n });\n try {\n const report = await run.run();\n if (json) json.print(JSON.stringify(report, null, 2));\n else for (const l of [\"\", ...renderReport(report)]) out.print(l);\n process.exitCode = report.ok ? 0 : report.interrupted ? 130 : 1;\n } finally {\n remove();\n prompter.close();\n channel.close();\n out.dispose();\n if (err !== out) err.dispose();\n json?.dispose();\n }\n });\n}\n"],"mappings":";;;;;AASA,MAAM,QAAQ;;;;;AAMd,SAAgB,WAAW,QAAwF;CACjH,IAAI,OAAO;CACX,MAAM,gBAAgB;EACpB,OAAO;CACT;CACA,OAAO,GAAG,SAAS,OAAO;CAC1B,OAAO;EACL,MAAM,OAAO,IAAI;GACf,IAAI,MAAM;GACV,IAAI;IACF,OAAO,MAAM,GAAG,KAAK,MAAM,QAAQ;KACjC,IAAI,KAAK,OAAO;IAClB,CAAC;GACH,QAAQ;IACN,OAAO;GACT;EACF;EACA,eAAe,OAAO,eAAe,SAAS,OAAO;CACvD;AACF;;;;;;;AAmBA,SAAgB,oBAAoB,YAA6B,MAAsC;CACrG,IAAI,aAAa;CACjB,IAAI,WAAW;CACf,MAAM,QAAQ,QAAgB;EAC5B,IAAI,WAAW,OAAO,SAAS;EAC/B,KAAK,MAAM,KAAK,IAAI,sDAAsD,QAAQ,WAAW,gGAAgG,IAAI;EACjM,WAAW,MAAM;CACnB;CACA,MAAM,cAAc;EAClB;EACA,IAAI,eAAe,GAAG,OAAO,KAAK,QAAQ;EAC1C,IAAI,UAAU;EACd,WAAW;EACX,KAAK,MAAM,8EAA8E;EACzF,MAAM,WAAW,IAAI,SAAe,MAAM,WAAW,GAAG,KAAK,gBAAgB,GAAI,CAAC,CAAC,QAAQ,CAAC;EAC5F,QAAa,KAAK,CAAC,KAAK,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW;GAC3E,KAAK,MAAM,qCAAqC,KAAK,UAAU,GAAG;GAClE,KAAK,KAAK,GAAG;EACf,CAAC;CACH;CACA,MAAM,eAAe,KAAK,SAAS;CACnC,MAAM,cAAc,KAAK,QAAQ;CACjC,QAAQ,GAAG,UAAU,KAAK;CAC1B,QAAQ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AQ;GAAO,QAAQ,EAAE,OAAO,QAAQ,SAAS,QAAQ;EAAO,CAAC;EACzH,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,MAAM,IAAI,SAAS,GAAG;GAC1B,OAAO;GACP,aAAa,QAAQ,gBAAgB,QAAQ,SAAS,GAAG;GACzD,OAAO,IAAI;GACX,UAAU,MAAM,SAAS,QAAQ,GAAG,KAAK;GACzC,QAAQ,WAAW;EACrB,CAAC;EACD,MAAM,SAAS,oBAAoB,YAAY;GAC7C,QAAQ,MAAM,IAAI,MAAM,CAAC;GACzB,mBAAmB,IAAI,YAAY,GAAI;GACvC,OAAO,SAAS;IACd,QAAQ,MAAM;IACd,QAAQ,KAAK,IAAI;GACnB;GACA,iBAAiB;IACf,MAAM,OAAO,IAAI,iBAAiB;IAClC,OAAO,KAAK,SAAS,sBAAsB,KAAK,KAAK,IAAI,EAAE,qFAAqF;GAClJ;EACF,CAAC;EACD,IAAI;GACF,MAAM,SAAS,MAAM,IAAI,IAAI;GAC7B,IAAI,MAAM,KAAK,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;QAC/C,KAAK,MAAM,KAAK,CAAC,IAAI,GAAG,aAAa,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC;GAC/D,QAAQ,WAAW,OAAO,KAAK,IAAI,OAAO,cAAc,MAAM;EAChE,UAAU;GACR,OAAO;GACP,SAAS,MAAM;GACf,QAAQ,MAAM;GACd,IAAI,QAAQ;GACZ,IAAI,QAAQ,KAAK,IAAI,QAAQ;GAC7B,MAAM,QAAQ;EAChB;CACF,CAAC;AACL"}
package/dist/cli.js CHANGED
@@ -144,7 +144,7 @@ const { registerConnectionsCommands } = await import("./commands-CgmkYCYG.js");
144
144
  registerConnectionsCommands(program);
145
145
  const { registerExtensionCommands } = await import("./cli-B8cuKWiS.js");
146
146
  registerExtensionCommands(program);
147
- const { registerSmokeCommands } = await import("./cli-Wp2ejVBT.js");
147
+ const { registerSmokeCommands } = await import("./cli-BBSYW5Pe.js");
148
148
  registerSmokeCommands(program);
149
149
  const { registerSettingsCommands } = await import("./settings-cli-DfWc-yWJ.js");
150
150
  registerSettingsCommands(program);
@@ -1182,13 +1182,16 @@ var SmokeRun = class {
1182
1182
  if (!(await this.driveFacts(folder.id)).trashed) throw new Error("approved, but the folder isn't in the trash");
1183
1183
  return `pending, approved (${approved}), in the trash`;
1184
1184
  });
1185
+ let folderTrashed = false;
1185
1186
  for (const [id, f] of [[folder.id, {
1186
1187
  kind: "folder",
1187
1188
  name: folder.name
1188
1189
  }], ...this.ledger.files]) {
1189
1190
  reported.add(id);
1190
1191
  try {
1191
- if (!(await this.driveFacts(id)).trashed) this.leftBehind.push(`Drive ${f.kind} "${f.name}" (${id}) is not in the trash.`);
1192
+ const facts = await this.driveFacts(id);
1193
+ if (id === folder.id) folderTrashed = facts.trashed;
1194
+ if (!(facts.trashed || folderTrashed && facts.parents.includes(folder.id))) this.leftBehind.push(`Drive ${f.kind} "${f.name}" (${id}) is not in the trash.`);
1192
1195
  } catch (err) {
1193
1196
  this.leftBehind.push(`Drive ${f.kind} "${f.name}" (${id}): couldn't check it (${errText(err)}).`);
1194
1197
  }
@@ -1252,4 +1255,4 @@ var SmokeRun = class {
1252
1255
  //#endregion
1253
1256
  export { SmokeRun };
1254
1257
 
1255
- //# sourceMappingURL=run-zakbVgQR.js.map
1258
+ //# sourceMappingURL=run-BQB8DwLB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-zakbVgQR.js","names":[],"sources":["../server/smoke/guards.ts","../server/smoke/png.ts","../server/smoke/run.ts"],"sourcesContent":["// The smoke run's guards, in code: every write the run makes goes through ScratchGuard.checkWrite first, and the\n// draft through checkDraft. They work from the ledger (what this run created) and from drive_get (where a file\n// really is), so a bug elsewhere in the run, or an extension that answers with the wrong id, can't turn into a\n// write on an existing file or a mail to anyone but the account itself.\n\nimport { resolve, sep } from \"node:path\";\n\nexport class GuardError extends Error {\n constructor(message: string) {\n super(`guard refused: ${message}`);\n this.name = \"GuardError\";\n }\n}\n\n/** What the run created, so cleanup and the leftover check work from facts, not from the step list. */\nexport interface Ledger {\n /** The run's marker (xaq-smoke-<ts>): the folder's and the agent's name, the draft subject's prefix. */\n marker: string;\n folder: { id: string; name: string } | null;\n /** Files created in the scratch folder (checked with drive_get before they were recorded). */\n files: Map<string, { kind: string; name: string }>;\n /** Files a create call reported that turned out NOT to be in the scratch folder: never written to again, reported. */\n strays: Map<string, { kind: string; name: string }>;\n drafts: Map<string, { deleted: boolean }>;\n /** mcp.call approvals the run approved (its own calls only). */\n approvals: string[];\n agent: { id: string; name: string } | null;\n tempDir: string | null;\n}\n\nexport function newLedger(marker: string): Ledger {\n return { marker, folder: null, files: new Map(), strays: new Map(), drafts: new Map(), approvals: [], agent: null, tempDir: null };\n}\n\n/**\n * Every Workspace write the run makes (upstream tool names), and where its target ids are:\n * - `folder`: the argument must be the scratch folder itself (create-in-folder calls, and the final drive_trash);\n * - `file`: the argument, when given, must be a file this run created whose parents include the scratch folder.\n * drive_create_folder is special: once, named after the marker, at the top of My Drive (it makes the folder).\n */\nexport const WRITE_TARGETS: Readonly<Record<string, { folder?: readonly string[]; file?: readonly string[] }>> = {\n drive_create_folder: {},\n drive_upload: { folder: [\"folderId\"] },\n drive_trash: { folder: [\"fileId\"] },\n docs_create: { folder: [\"folderId\"] },\n docs_append: { file: [\"documentId\"] },\n docs_replace_text: { file: [\"documentId\"] },\n docs_comment_add: { file: [\"documentId\"] },\n sheets_create: { folder: [\"folderId\"] },\n sheets_write: { file: [\"spreadsheetId\"] },\n sheets_append_rows: { file: [\"spreadsheetId\"] },\n slides_create: { folder: [\"folderId\"] },\n slides_add_slide: { file: [\"presentationId\"] },\n slides_replace_text: { file: [\"presentationId\"] },\n slides_insert_image: { file: [\"presentationId\", \"driveFileId\"] },\n slides_delete_slide: { file: [\"presentationId\"] },\n};\n\n/** The Workspace reads the run makes. Anything in neither list is refused. */\nexport const READ_TOOLS: ReadonlySet<string> = new Set([\n \"drive_search\",\n \"drive_list_folder\",\n \"drive_get\",\n \"drive_export\",\n \"docs_read\",\n \"docs_comments_list\",\n \"sheets_read\",\n \"slides_read\",\n]);\n\n/** drive_get's answer, as far as the guards need it. */\nexport interface DriveFacts {\n id: string;\n name: string;\n parents: string[];\n trashed: boolean;\n}\n\nexport type DriveGet = (fileId: string) => Promise<DriveFacts>;\n\n/** File arguments that may be left out (the tool takes another source instead). */\nconst OPTIONAL_FILE_ARGS: ReadonlySet<string> = new Set([\"driveFileId\"]);\n/** create_draft attachment sources (writer A1): an item has exactly one. */\nconst SOURCE_KEYS = [\"path\", \"drive_file_id\", \"content_base64\", \"message_id\"] as const;\n/** Other keys an attachment item may carry (attachment_id goes with message_id). */\nconst ITEM_KEYS: ReadonlySet<string> = new Set([\"export_as\", \"filename\", \"mime_type\", \"attachment_id\"]);\n\nexport class ScratchGuard {\n constructor(\n private readonly ledger: Ledger,\n private readonly driveGet: DriveGet,\n ) {}\n\n /** Throws GuardError unless `tool(args)` writes only inside the scratch folder. Call before EVERY write. */\n async checkWrite(tool: string, args: Record<string, unknown>): Promise<void> {\n const spec = WRITE_TARGETS[tool];\n if (!spec) throw new GuardError(`${tool} isn't one of the writes the smoke run makes`);\n if (tool === \"drive_create_folder\") {\n if (this.ledger.folder) throw new GuardError(\"the scratch folder already exists; the run makes exactly one\");\n if (args.name !== this.ledger.marker) throw new GuardError(`the scratch folder must be named ${this.ledger.marker}`);\n if (args.parentId !== undefined) throw new GuardError(\"the scratch folder goes at the top of My Drive\");\n return;\n }\n const folder = this.ledger.folder;\n if (!folder) throw new GuardError(`${tool}: there is no scratch folder, so nothing may be written`);\n for (const key of spec.folder ?? []) {\n const value = args[key];\n if (value !== folder.id) throw new GuardError(`${tool}: ${key} must be the scratch folder ${folder.id}`);\n const f = await this.driveGet(folder.id);\n if (f.id !== folder.id || f.name !== folder.name) throw new GuardError(`${tool}: ${folder.id} isn't the scratch folder ${folder.name} any more`);\n }\n for (const key of spec.file ?? []) {\n const value = args[key];\n // Every file argument is required, except slides_insert_image's driveFileId (it may take imageUrl instead).\n if (value === undefined && OPTIONAL_FILE_ARGS.has(key)) continue;\n await this.checkFile(tool, key, value);\n }\n }\n\n /** A file argument: one this run created, and drive_get says it's in the scratch folder. */\n async checkFile(tool: string, key: string, value: unknown): Promise<void> {\n const folder = this.ledger.folder;\n if (!folder) throw new GuardError(`${tool}: there is no scratch folder`);\n if (typeof value !== \"string\" || !value) throw new GuardError(`${tool}: ${key} must be a file id`);\n if (!this.ledger.files.has(value)) throw new GuardError(`${tool}: ${key} ${value} isn't a file this run created`);\n const f = await this.driveGet(value);\n if (f.id !== value || !f.parents.includes(folder.id)) throw new GuardError(`${tool}: ${key} ${value} isn't in the scratch folder ${folder.name}`);\n if (f.trashed) throw new GuardError(`${tool}: ${key} ${value} is in the trash`);\n }\n\n /**\n * The draft: addressed to exactly the account's own address (no Cc, no Bcc, not a reply), its attachments only a\n * file in the run's temp dir or a file in the scratch folder.\n */\n async checkDraft(args: Record<string, unknown>, own: string): Promise<void> {\n const me = own.trim().toLowerCase();\n const to = args.to;\n if (!Array.isArray(to) || to.length !== 1 || typeof to[0] !== \"string\" || to[0].trim().toLowerCase() !== me) {\n throw new GuardError(`create_draft: the draft must be addressed to exactly ${own}, the account's own address`);\n }\n for (const key of [\"cc\", \"bcc\", \"thread_id\"]) if (args[key] !== undefined) throw new GuardError(`create_draft: no ${key}`);\n const atts = args.attachments;\n if (!Array.isArray(atts)) return;\n for (const a of atts as Record<string, unknown>[]) {\n if (!a || typeof a !== \"object\" || Array.isArray(a)) throw new GuardError(\"create_draft: an attachment must be an object\");\n // Exactly one source per item (message_id + attachment_id together count as one), and no keys beyond it.\n const sources = SOURCE_KEYS.filter((k) => a[k] !== undefined);\n if (sources.length !== 1) throw new GuardError(`create_draft: each attachment needs exactly one source, not ${sources.length ? sources.join(\" + \") : \"none\"}`);\n const extra = Object.keys(a).filter((k) => !(SOURCE_KEYS as readonly string[]).includes(k) && !ITEM_KEYS.has(k));\n if (extra.length) throw new GuardError(`create_draft: unexpected attachment keys ${extra.join(\", \")}`);\n if (typeof a.path === \"string\") {\n const dir = this.ledger.tempDir;\n const abs = resolve(a.path);\n if (!dir || !abs.startsWith(resolve(dir) + sep)) throw new GuardError(\"create_draft: a local attachment must be in the run's temp dir\");\n } else if (typeof a.drive_file_id === \"string\") {\n await this.checkFile(\"create_draft\", \"drive_file_id\", a.drive_file_id);\n } else {\n throw new GuardError(\"create_draft: attachments are a temp-dir file or a scratch-folder file only\");\n }\n }\n }\n}\n","// A small solid-colour PNG, built here so the smoke run uploads an image it made itself (the Drive-thumbnail path of\n// slides_insert_image) without shipping a binary file.\n\nimport { crc32, deflateSync } from \"node:zlib\";\n\nfunction chunk(type: string, data: Buffer): Buffer {\n const len = Buffer.alloc(4);\n len.writeUInt32BE(data.length);\n const body = Buffer.concat([Buffer.from(type, \"ascii\"), data]);\n const crc = Buffer.alloc(4);\n crc.writeUInt32BE(crc32(body) >>> 0);\n return Buffer.concat([len, body, crc]);\n}\n\n/** A `size`×`size` RGB PNG in one colour. */\nexport function solidPng(size = 64, rgb: [number, number, number] = [26, 115, 232]): Buffer {\n const ihdr = Buffer.alloc(13);\n ihdr.writeUInt32BE(size, 0);\n ihdr.writeUInt32BE(size, 4);\n ihdr[8] = 8; // bit depth\n ihdr[9] = 2; // truecolour\n const row = Buffer.alloc(1 + size * 3);\n for (let x = 0; x < size; x++) row.set(rgb, 1 + x * 3);\n const raw = Buffer.concat(Array.from({ length: size }, () => row));\n return Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), chunk(\"IHDR\", ihdr), chunk(\"IDAT\", deflateSync(raw)), chunk(\"IEND\", Buffer.alloc(0))]);\n}\n","// `xaq smoke google-workspace --scratch`: a live end-to-end check of Gmail attachments and the google-workspace\n// extension on a real account, safe by construction (docs/reference.md, \"Live check\").\n//\n// - First, earlier runs' leftovers are swept: their agents deleted, their temp dirs taken out of attachmentDirs, and\n// their drafts and Drive folders reported for the owner to check.\n// - Reads anywhere: a few existing Drive files (newest Doc, Sheet, Slides) and ONE email with attachments. Only\n// names, the subject, kinds and sizes are printed, never content. Only attachments get_attachment can show inline\n// are extracted, with format \"inline\" (which never saves): a password-protected or encrypted file passes as\n// \"couldn't read (<reason>)\", any other parse failure fails, and a saved copy anyway fails the step and is listed.\n// - Every write goes into ONE new Drive folder named after the run (xaq-smoke-<UTC timestamp>), through\n// ScratchGuard (guards.ts): the target must be that folder or a file this run created whose drive_get parents\n// include it. The only mail is ONE draft to the account's own address, deleted again; nothing is ever sent.\n// - Tool calls go through /mcp as a temporary agent (mail read + draft, the Workspace connection at \"ask\"), so risky\n// calls really come back pending; the command approves its own calls (checked: agent, tool, exact arguments)\n// through the admin API.\n// - Cleanup always runs (also on a failed step, Ctrl-C, SIGTERM or SIGHUP): the draft deleted, the folder trashed\n// (drive_trash, approved), the agent deleted, attachmentDirs restored, the temp dir removed. Then the leftover\n// check. A second Ctrl-C runs fastCleanup (agent and attachmentDirs only, bounded) and quits.\n\nimport { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, join } from \"node:path\";\nimport type { Account, AgentWithKey, ConnectionView, McpCallApprovalView } from \"../../shared/types.ts\";\nimport { SMOKE_NAME_RE, SMOKE_TEMP_RE, type SmokeDraftView, type SmokeLeftovers, type SmokeSweep, smokeName, smokeSubjectPrefix } from \"../../shared/smoke.ts\";\nimport type { AdminChannel } from \"../connections-cli/admin.ts\";\nimport { NPX } from \"../listen/version.ts\";\nimport { MAX_ATTACHMENT_BYTES } from \"../mail/agent.ts\";\nimport { cleanLine } from \"../mail/content.ts\";\nimport { PARSE_LIMITS } from \"../mail/extract/types.ts\";\nimport { attachmentKind } from \"../mcp/attachments.ts\";\nimport { type AgentMcp, type CallOutcome } from \"./agent.ts\";\nimport { type DriveFacts, GuardError, type Ledger, newLedger, READ_TOOLS, ScratchGuard, WRITE_TARGETS } from \"./guards.ts\";\nimport { solidPng } from \"./png.ts\";\nimport { finish, type SmokeReport, type StepResult } from \"./report.ts\";\n\n/** The extension's id (its manifest name): the preset of its connections. */\nexport const WORKSPACE_PRESET = \"google-workspace\";\n/** The scopes the extension asks Google for; a sign-in missing one makes some tools fail. */\nexport const WORKSPACE_SCOPES = [\n \"https://www.googleapis.com/auth/documents\",\n \"https://www.googleapis.com/auth/spreadsheets\",\n \"https://www.googleapis.com/auth/presentations\",\n \"https://www.googleapis.com/auth/drive.file\",\n \"https://www.googleapis.com/auth/drive.readonly\",\n];\n/** Mail tools the run calls (native, not prefixed). */\nexport const MAIL_TOOLS = [\"search_threads\", \"get_thread\", \"get_message\", \"list_attachments\", \"get_attachment\", \"create_draft\"] as const;\n/** A fixed public https image (Google's own logo), for slides_insert_image's imageUrl path. */\nexport const PUBLIC_IMAGE_URL = \"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\";\n\n/**\n * What get_attachment (server/mcp/attachments.ts) can show inline, from its own rules: attachmentKind() on the listed\n * type and name, images under MAX_ATTACHMENT_BYTES, PDF/DOCX/XLSX/PPTX/CSV under PARSE_LIMITS.inputBytes, text and\n * HTML at any size (it reads the first part). The run asks with format \"inline\", which never saves; for anything\n * else that would only download the owner's file to answer \"not shown\", so the run doesn't ask. The bytes aren't\n * known here: attachmentKind's content sniff (a PDF sent as octet-stream without an extension) sees an empty buffer\n * and says \"other\", which skips the file.\n */\nexport const SKIPPED_NOT_INLINE = \"skipped (can't be shown inline)\";\n\nexport interface ListedAttachment {\n id: string;\n filename: string;\n mimeType: string;\n /** Bytes; NaN when the listing didn't say. */\n size: number;\n}\n\n/** The kind get_attachment would show inline, or null when it would save the file to disk (so the run skips it). */\nexport function inlineKind(a: Pick<ListedAttachment, \"filename\" | \"mimeType\" | \"size\">): string | null {\n const kind = attachmentKind(a.mimeType, a.filename, Buffer.alloc(0));\n const known = Number.isFinite(a.size) && a.size >= 0;\n if (kind === \"other\") return null;\n if (kind === \"text\" || kind === \"html\") return kind;\n if (kind === \"image\") return known && a.size < MAX_ATTACHMENT_BYTES ? kind : null;\n return known && a.size < PARSE_LIMITS.inputBytes ? kind : null;\n}\n\nexport interface SmokeFlags {\n scratch?: boolean;\n yes?: boolean;\n account?: string;\n connection?: string;\n json?: boolean;\n}\n\nexport interface SmokeDeps {\n admin: Pick<AdminChannel, \"request\" | \"baseUrl\">;\n /** An MCP client on /mcp with this key (default: the SDK client on admin.baseUrl). */\n connectMcp: (apiKey: string) => Promise<AgentMcp>;\n /** Progress and the plan (stderr with --json). May throw (a dead terminal): the run ignores that. */\n print: (line?: string) => void;\n /** Asked once, after the plan; --yes answers it. */\n confirm: (question: string) => Promise<boolean>;\n /** Ctrl-C, SIGTERM, SIGHUP: no new step starts, cleanup runs. */\n signal: AbortSignal;\n now?: () => Date;\n /**\n * The directory under which the run keeps its private (0700) `xaq-smoke` directory for the draft's local file.\n * Default $XDG_CACHE_HOME or ~/.cache: never the shared /tmp.\n */\n tmpRoot?: string;\n imageUrl?: string;\n /** get_call_status polling while an approved call runs. */\n pollMs?: number;\n}\n\n/** Setup problems found before anything is created: printed as they are, exit 1. */\nexport class SmokeSetupError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SmokeSetupError\";\n }\n}\n\nclass Skip extends Error {}\nclass Interrupted extends Error {\n constructor() {\n super(\"interrupted (Ctrl-C)\");\n }\n}\n\ninterface SettingsView {\n publicUrl: string;\n brokerUpstreams?: boolean;\n /** Directories create_draft may attach local files from. */\n attachmentDirs?: string[];\n}\n\n/** The Google account the connection is signed in as (ConnectionView `google.email`), or null. */\nexport function boundAccountEmail(c: ConnectionView): string | null {\n const email = c.google?.email;\n return typeof email === \"string\" && email ? email : null;\n}\n\n/** Scopes the extension needs that the connection's sign-in lacks: `google.missing`, else from grantedScopes. */\nfunction missingScopes(c: ConnectionView): string[] {\n if (c.google && Array.isArray(c.google.missing)) return c.google.missing.map((m) => m.scope);\n if (c.preset === WORKSPACE_PRESET && c.grantedScopes) return WORKSPACE_SCOPES.filter((s) => !c.grantedScopes!.includes(s));\n return [];\n}\n\n/** Picks the account and the connection (flags, else the only one) and checks both are usable. */\nexport function chooseTargets(\n flags: SmokeFlags,\n accounts: Account[],\n connections: ConnectionView[],\n publicUrl: string,\n): { account: Account; connection: ConnectionView } {\n const base = publicUrl.replace(/\\/+$/, \"\");\n let connection: ConnectionView | undefined;\n if (flags.connection) {\n connection = connections.find((c) => c.slug === flags.connection);\n if (!connection) throw new SmokeSetupError(`No connection \"${flags.connection}\". There are: ${connections.map((c) => c.slug).join(\", \") || \"none\"}.`);\n } else {\n const ws = connections.filter((c) => c.preset === WORKSPACE_PRESET);\n if (!ws.length) {\n throw new SmokeSetupError(\n `Google Workspace isn't connected. Install it (${NPX} ext add ${WORKSPACE_PRESET}), then connect it in the console: ${base}/connections`,\n );\n }\n if (ws.length > 1) throw new SmokeSetupError(`There are ${ws.length} Google Workspace connections (${ws.map((c) => c.slug).join(\", \")}): pick one with --connection <slug>.`);\n connection = ws[0]!;\n }\n const fix = `${base}/connections/${connection.id}`;\n if (connection.status !== \"active\") throw new SmokeSetupError(`${connection.name} is ${connection.status.replace(\"_\", \" \")}${connection.statusReason ? ` (${connection.statusReason})` : \"\"}. Fix it in the console: ${fix}`);\n const missing = missingScopes(connection);\n if (missing.length) {\n throw new SmokeSetupError(`${connection.name} is missing Google permissions: ${missing.map((s) => s.split(\"/\").pop()).join(\", \")}. Reconnect it and approve all of them: ${fix}`);\n }\n const bound = boundAccountEmail(connection);\n const want = flags.account ?? bound;\n let account: Account | undefined;\n if (want) {\n account = accounts.find((a) => a.email.toLowerCase() === want.toLowerCase());\n if (!account) throw new SmokeSetupError(`No Gmail account ${want} in xaq. There are: ${accounts.map((a) => a.email).join(\", \") || \"none\"}. Add it in the console: ${base}/accounts`);\n } else {\n if (!accounts.length) throw new SmokeSetupError(`No Gmail account is connected. Add one in the console: ${base}/accounts`);\n if (accounts.length > 1) throw new SmokeSetupError(`There are ${accounts.length} Gmail accounts (${accounts.map((a) => a.email).join(\", \")}): pick one with --account <email>.`);\n account = accounts[0]!;\n }\n if (bound && bound.toLowerCase() !== account.email.toLowerCase()) {\n throw new SmokeSetupError(`${connection.name} is signed in as ${bound}, not ${account.email}: pass --account ${bound}, or pick another connection.`);\n }\n if (account.status !== \"active\") throw new SmokeSetupError(`${account.email} is ${account.status.replace(\"_\", \" \")}. Fix it in the console: ${base}/accounts`);\n return { account, connection };\n}\n\n/** The plan, printed before anything happens. */\nexport function planLines(marker: string, account: string, connection: ConnectionView): string[] {\n return [\n `xaq smoke google-workspace will run as a temporary agent ${marker}, through /mcp:`,\n \"\",\n \"First: earlier smoke runs' agents are deleted and their temp dirs taken out of attachmentDirs; their drafts\",\n \"and Drive folders are listed for you to check.\",\n \"Reads (existing files and mail, read only; prints names, the subject, kinds and sizes, never content):\",\n \" - Drive: search the newest Doc, Sheet and Slides file, list the top of My Drive, get, read and export each\",\n \" - Gmail: ONE email with attachments: list its attachments and extract each one get_attachment shows\",\n \" inline, asking it never to save a copy (anything it can't show inline is skipped)\",\n `Writes (only inside a new Drive folder \"${marker}\" at the top of My Drive; every write is checked first):`,\n \" - Docs: create a doc from markdown, append, find and replace (count checked), comment, read back\",\n \" - Sheets: create a sheet, write a range, append rows, read back\",\n \" - Slides: create a deck from an outline, add a slide, replace text, upload a PNG and insert it (Drive\",\n \" thumbnail path: a private image must be refused), insert a public https image, read back, delete a\",\n \" slide through the approval path\",\n ` - Gmail: ONE draft to ${account} only, with a local file and a scratch-folder file attached; checked, then`,\n \" deleted. Nothing is ever sent.\",\n \"Cleanup, also on failure, Ctrl-C, SIGTERM or SIGHUP: the folder goes to the Drive trash (drive_trash, approved\",\n \"here), the draft is deleted, the agent is deleted, attachmentDirs is restored. Temporary changes until then:\",\n `the agent (mail read and draft on ${account}, ${connection.slug} at \"ask\") and a private temp dir in attachmentDirs.`,\n ];\n}\n\nconst errText = (err: unknown) => (err instanceof Error ? err.message : String(err)).replace(/\\s+/g, \" \").slice(0, 300);\n\n/** Canonical JSON (sorted keys): the approval's stored arguments must be exactly the call the run made. */\nfunction canonical(v: unknown): string {\n if (Array.isArray(v)) return `[${v.map(canonical).join(\",\")}]`;\n if (v && typeof v === \"object\") {\n return `{${Object.keys(v as object)\n .sort()\n .map((k) => `${JSON.stringify(k)}:${canonical((v as Record<string, unknown>)[k])}`)\n .join(\",\")}}`;\n }\n return JSON.stringify(v);\n}\n\n/** \"2.5 KB\" (server/mail/content.ts formatSize) → bytes; NaN when it can't be read. */\nfunction sizeOf(text: string): number {\n const m = /^([\\d.]+)\\s*(B|KB|MB|GB)$/i.exec(text.trim());\n if (!m) return Number.NaN;\n const unit = { B: 1, KB: 1024, MB: 1024 ** 2, GB: 1024 ** 3 }[m[2]!.toUpperCase() as \"B\"]!;\n return Math.ceil(Number(m[1]) * unit);\n}\n\n/**\n * Attachments from list_attachments: its structured list (A2: attachmentId, filename, mimeType, size), else the\n * `name (type, size, … attachment_id: x …)` lines.\n */\nexport function parseAttachmentList(out: CallOutcome): ListedAttachment[] {\n const s = out.structured?.attachments;\n if (Array.isArray(s)) {\n return s\n .map((a: Record<string, unknown>) => ({\n id: String(a.attachmentId ?? a.attachment_id ?? a.id ?? \"\"),\n filename: String(a.filename ?? a.name ?? \"\"),\n mimeType: String(a.mimeType ?? a.mime_type ?? \"\"),\n size: typeof a.size === \"number\" ? a.size : Number.NaN,\n }))\n .filter((a) => a.id);\n }\n const found: ListedAttachment[] = [];\n for (const segment of out.text.split(/;|\\n/)) {\n // \"name (type, size, attachment_id: X)\" (get_message) or \"- name (type, size) · message_id: … · attachment_id: X\" (A2).\n const m = /^\\s*(?:Attachments:\\s*)?(?:[-*]|\\d+\\.)?\\s*(.+?) \\(([^,()]+), ([^,()]+?)(?:,[^()]*?)?(?:\\)[^()]*?)?attachment_id: ([^)\\s;·]+)/.exec(segment);\n if (m) found.push({ filename: m[1]!.trim(), mimeType: m[2]!.trim(), size: sizeOf(m[3]!), id: m[4]! });\n }\n return found;\n}\n\n/** What get_attachment returned, as the report may say it: a kind and a size, never the content. */\nexport function describeExtraction(out: CallOutcome): string {\n const blocks = out.content;\n const image = blocks.find((b) => b.type === \"image\");\n if (image) return `image, ${image.data?.length ?? 0} chars (base64)`;\n const res = blocks.find((b) => b.type === \"resource\");\n if (res?.resource?.blob !== undefined) return `binary, ${res.resource.blob.length} chars (base64)`;\n // Text: the first line is the header (\"Attachment <name> (<type>, <size>) …\"); the rest is the content.\n const text = blocks.filter((b) => b.type === \"text\").map((b) => b.text ?? \"\");\n const body = text.join(\"\\n\").split(\"\\n\").slice(1).join(\"\\n\");\n return `text, ${body.length} chars`;\n}\n\n/**\n * Parse failures that are the file's own doing: the smoke passes them as \"couldn't read (…)\". Every other one (corrupt,\n * a parser that's missing, crashed, timed out, busy, …) may be xaq's fault, and this run is what would notice.\n */\nexport const FILE_OWN_PARSE_FAILURES: ReadonlySet<string> = new Set([\"password\", \"encrypted\"]);\n\n/**\n * A format \"inline\" answer that didn't show the file (structuredContent.attachment.notShown): its code, the parser's\n * failure code when it couldn't read it, and the reason without a closing period. The reason is xaq's own words (the\n * parser's fixed messages), never the file's content, unless the parser child is subverted (it's cleaned anyway).\n */\nexport function notShownOf(out: CallOutcome): { code: string; parseFailure: string | null; reason: string } | null {\n const a = out.structured?.attachment as { notShown?: unknown; parseFailure?: unknown; reason?: unknown } | undefined;\n if (!a || typeof a.notShown !== \"string\" || !a.notShown) return null;\n const reason = typeof a.reason === \"string\" ? cleanLine(a.reason, 200).replace(/\\.$/, \"\") : \"\";\n const parseFailure = typeof a.parseFailure === \"string\" && a.parseFailure ? cleanLine(a.parseFailure, 40) : null;\n return { code: cleanLine(a.notShown, 40), parseFailure, reason: reason || \"no reason given\" };\n}\n\n/** A get_attachment answer that saved the file to disk (A2: structuredContent.attachment.savedPath). */\nexport function savedPathOf(out: CallOutcome): string | null {\n const a = out.structured?.attachment as { savedPath?: unknown } | undefined;\n return a && typeof a.savedPath === \"string\" && a.savedPath ? a.savedPath : null;\n}\n\n/**\n * The run's private directory for the draft's local file: `<root>/xaq-smoke`, mode 0700, a real directory this user\n * owns (never a symlink, never the shared /tmp). Created when missing; its mode is reset when it exists.\n */\nexport function privateSmokeDir(root?: string): string {\n const base = root ?? (process.env.XDG_CACHE_HOME?.startsWith(\"/\") ? process.env.XDG_CACHE_HOME : join(homedir(), \".cache\"));\n const dir = join(base, \"xaq-smoke\");\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n const st = lstatSync(dir);\n if (!st.isDirectory() || st.isSymbolicLink()) throw new Error(`${dir} isn't a plain directory; remove it and run again.`);\n if (typeof process.getuid === \"function\" && st.uid !== process.getuid()) throw new Error(`${dir} belongs to another user; remove it and run again.`);\n chmodSync(dir, 0o700);\n return dir;\n}\n\n/** Waits for `p` at most `ms`; the timeout wins silently. */\nconst within = <T>(p: Promise<T>, ms: number): Promise<T | undefined> =>\n Promise.race([\n p,\n new Promise<undefined>((r) => {\n setTimeout(() => r(undefined), ms).unref?.();\n }),\n ]);\n\nexport class SmokeRun {\n readonly marker: string;\n readonly ledger: Ledger;\n private readonly steps: StepResult[] = [];\n private readonly leftBehind: string[] = [];\n /** Earlier runs' leftovers the owner should check (not this run's: they don't fail it). */\n private readonly earlier: string[] = [];\n private readonly guard: ScratchGuard;\n private mcp: AgentMcp | null = null;\n private account: Account | null = null;\n private connection: ConnectionView | null = null;\n private previousDirs: string[] | null = null;\n private dirsChanged = false;\n private agentDeleted = false;\n private cleaning = false;\n private interrupted = false;\n private readonly stamp: string;\n\n constructor(\n private readonly flags: SmokeFlags,\n private readonly deps: SmokeDeps,\n ) {\n this.marker = smokeName((deps.now ?? (() => new Date()))());\n this.stamp = this.marker.slice(\"xaq-smoke-\".length);\n this.ledger = newLedger(this.marker);\n this.guard = new ScratchGuard(this.ledger, (id) => this.driveFacts(id));\n }\n\n // ───────────── Plumbing ─────────────\n\n /** Printing never stops the run (or its cleanup): a closed terminal (EIO, EPIPE) is ignored. */\n private print(line = \"\"): void {\n try {\n this.deps.print(line);\n } catch {\n // The terminal went away; the report is still returned.\n }\n }\n\n private record(tool: string, step: string, status: StepResult[\"status\"], detail: string): void {\n this.steps.push({ tool, step, status, detail });\n this.print(` ${status.padEnd(4)} ${tool} · ${step}${detail ? ` · ${detail}` : \"\"}`);\n }\n\n /** Runs one step; a thrown Skip is SKIP, anything else FAIL. Returns whether it passed. */\n private async step(tool: string, step: string, fn: () => Promise<string>): Promise<boolean> {\n if (!this.cleaning && this.deps.signal.aborted) {\n this.interrupted = true;\n return false;\n }\n try {\n this.record(tool, step, \"PASS\", await fn());\n return true;\n } catch (err) {\n if (err instanceof Interrupted) {\n this.interrupted = true;\n this.record(tool, step, \"SKIP\", \"interrupted (Ctrl-C)\");\n } else if (err instanceof Skip) this.record(tool, step, \"SKIP\", err.message);\n else this.record(tool, step, \"FAIL\", errText(err));\n return false;\n }\n }\n\n private need<T>(value: T | null | undefined, what: string): T {\n if (value === null || value === undefined) throw new Skip(`needs ${what}, which an earlier step didn't produce`);\n return value;\n }\n\n /** `force`: bookkeeping reads (drive_get for the guards and the ledger) still run after Ctrl-C. */\n private async rawCall(name: string, args: Record<string, unknown>, force = false): Promise<CallOutcome> {\n if (!force && !this.cleaning && this.deps.signal.aborted) throw new Interrupted();\n if (!this.mcp) throw new Skip(\"no MCP session (the temporary agent wasn't created)\");\n return this.mcp.call(name, args);\n }\n\n private exposed(tool: string): string {\n return `${this.connection!.slug}__${tool}`;\n }\n\n /**\n * A Workspace tool call. Reads go straight through; writes are checked by the guard first. A write that comes back\n * pending is approved here (its own call only); `approved` says which approval ran it.\n */\n private async ws(tool: string, args: Record<string, unknown>, force = false): Promise<{ out: CallOutcome; approved: string | null }> {\n const write = tool in WRITE_TARGETS;\n if (write) await this.guard.checkWrite(tool, args);\n else if (!READ_TOOLS.has(tool)) throw new GuardError(`${tool} isn't one of the calls the smoke run makes`);\n const out = await this.rawCall(this.exposed(tool), args, force && !write);\n const pending = /^pending_approval:/.test(out.text) ? /approval_id: (apr_[A-Za-z0-9_-]+)/.exec(out.text)?.[1] : undefined;\n if (pending) {\n if (!write) throw new Error(`${tool} is a read, but it came back pending approval`);\n return { out: await this.approveOwn(pending, tool, args), approved: pending };\n }\n if (out.isError) throw new Error(`${tool}: ${out.text}`);\n return { out, approved: null };\n }\n\n private async read(tool: string, args: Record<string, unknown>, force = false): Promise<CallOutcome> {\n return (await this.ws(tool, args, force)).out;\n }\n\n /** Approves a pending call after checking it is exactly this run's: its agent, connection, tool and arguments. */\n private async approveOwn(approvalId: string, tool: string, args: Record<string, unknown>): Promise<CallOutcome> {\n const view = await this.deps.admin.request<McpCallApprovalView>(\"GET\", `/api/approvals/${encodeURIComponent(approvalId)}`);\n const mine =\n view.approval.agentId === this.ledger.agent?.id &&\n view.connection?.id === this.connection?.id &&\n view.tool?.name === tool &&\n view.argsIntact &&\n canonical(JSON.parse(view.argsDisplay)) === canonical(args);\n if (!mine) throw new GuardError(`approval ${approvalId} isn't exactly this run's ${tool} call, so it wasn't approved`);\n await this.deps.admin.request(\"POST\", `/api/approvals/${encodeURIComponent(approvalId)}/approve`, { note: `${this.marker}: approved by xaq smoke` });\n this.ledger.approvals.push(approvalId);\n for (let i = 0; ; i++) {\n const status = await this.rawCall(\"get_call_status\", { approval_id: approvalId });\n if (/^running:/.test(status.text) && i < 60) {\n await new Promise((r) => setTimeout(r, this.deps.pollMs ?? 1000));\n continue;\n }\n if (status.isError || !/^done:/.test(status.text)) throw new Error(`${tool} after approval: ${status.text}`);\n return status;\n }\n }\n\n /** drive_get, as the guards and the leftover check read it. */\n private async driveFacts(fileId: string): Promise<DriveFacts> {\n const out = await this.read(\"drive_get\", { fileId }, true);\n const s = out.structured;\n if (!s || typeof s.id !== \"string\") throw new GuardError(`drive_get gave no details for ${fileId}`);\n return { id: s.id, name: typeof s.name === \"string\" ? s.name : \"\", parents: Array.isArray(s.parents) ? s.parents.map(String) : [], trashed: s.trashed === true };\n }\n\n /** A file a create call made: recorded in the ledger once drive_get says it's in the scratch folder. */\n private async recordCreated(kind: string, id: unknown, name: string): Promise<string> {\n if (typeof id !== \"string\" || !id) throw new Error(`the ${kind} create call returned no id`);\n const folder = this.ledger.folder!;\n const f = await this.driveFacts(id);\n if (!f.parents.includes(folder.id)) {\n // Its real name (it may be an existing file the extension answered with by mistake).\n this.ledger.strays.set(id, { kind, name: f.name || name });\n throw new GuardError(`the new ${kind} ${id} isn't in the scratch folder, so nothing more is written to it`);\n }\n this.ledger.files.set(id, { kind, name });\n return id;\n }\n\n // ───────────── The run ─────────────\n\n async run(): Promise<SmokeReport> {\n if (!this.flags.scratch) {\n throw new SmokeSetupError(\n \"smoke google-workspace runs live on the connected Google account. It only reads existing files and mail, and writes only into a new scratch folder and ONE draft to the account itself, which it removes again. Pass --scratch to run it.\",\n );\n }\n const settings = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n if (settings.brokerUpstreams !== true) throw new SmokeSetupError(`Connections are turned off in this xaq. Turn them on in the console: ${settings.publicUrl.replace(/\\/+$/, \"\")}/settings`);\n if (!Array.isArray(settings.attachmentDirs)) {\n throw new SmokeSetupError(\"This xaq has no attachmentDirs setting, which the draft's local attachment needs. Update xaq, then run this again.\");\n }\n const accounts = await this.deps.admin.request<Account[]>(\"GET\", \"/api/accounts\");\n const connections = await this.deps.admin.request<ConnectionView[]>(\"GET\", \"/api/connections\");\n const { account, connection } = chooseTargets(this.flags, accounts, connections, settings.publicUrl);\n this.account = account;\n this.connection = connection;\n\n for (const l of planLines(this.marker, account.email, connection)) this.print(l);\n this.print();\n if (!(await this.deps.confirm(\"Run it?\"))) throw new SmokeSetupError(\"Nothing was done.\");\n\n this.print();\n try {\n await this.main();\n } finally {\n this.cleaning = true;\n await this.cleanup();\n }\n if (this.deps.signal.aborted) this.interrupted = true;\n return finish({\n marker: this.marker,\n account: account.email,\n connection: connection.slug,\n steps: this.steps,\n leftBehind: this.leftBehind,\n earlier: this.earlier,\n interrupted: this.interrupted,\n });\n }\n\n private async main(): Promise<void> {\n const account = this.account!;\n const connection = this.connection!;\n await this.sweep();\n const created = await this.step(\"xaq\", \"create the temporary agent\", async () => {\n const r = await this.deps.admin.request<AgentWithKey>(\"POST\", \"/api/smoke/agents\", { name: this.marker, accountId: account.id, connectionId: connection.id });\n this.ledger.agent = { id: r.agent.id, name: r.agent.name };\n this.mcp = await this.deps.connectMcp(r.apiKey);\n return `${r.agent.name}: ${account.email} read + draft, ${connection.slug} at \"ask\"`;\n });\n if (!created) return;\n const tools = await this.step(\"xaq\", \"tools/list has every tool the run uses\", async () => {\n const listed = new Set(await this.mcp!.listTools());\n const wanted = [...[...READ_TOOLS, ...Object.keys(WRITE_TARGETS)].map((t) => this.exposed(t)), \"get_call_status\", ...MAIL_TOOLS];\n const missing = wanted.filter((t) => !listed.has(t));\n if (missing.length) throw new Error(`missing: ${missing.join(\", \")} (update xaq and the ${WORKSPACE_PRESET} extension)`);\n return `${wanted.length} tools`;\n });\n if (!tools) return;\n await this.earlierFolders();\n\n await this.driveReads();\n await this.mailReads();\n if (!(await this.createFolder())) {\n this.record(\"xaq\", \"writes\", \"SKIP\", \"no scratch folder: nothing was written\");\n return;\n }\n const doc = await this.docs();\n await this.sheets();\n await this.slides();\n await this.draft(doc);\n }\n\n // ───────────── Earlier runs ─────────────\n\n /** Daemon side: earlier runs' agents deleted, their temp dirs out of attachmentDirs, their drafts listed. */\n private async sweep(): Promise<void> {\n await this.step(\"xaq\", \"sweep earlier runs' leftovers\", async () => {\n const s = await this.deps.admin.request<SmokeSweep>(\"POST\", \"/api/smoke/sweep\", {});\n for (const d of s.drafts) this.earlier.push(`An earlier run's (${d.agent}) draft ${d.draftId} is still in ${d.account}: check it in Gmail (Drafts) and delete it.`);\n // Their temp dirs on disk: only ever inside this user's private smoke directory.\n let removed = 0;\n try {\n const mine = privateSmokeDir(this.deps.tmpRoot);\n for (const name of readdirSync(mine)) {\n if (!SMOKE_TEMP_RE.test(name)) continue;\n rmSync(join(mine, name), { recursive: true, force: true });\n removed++;\n }\n } catch {\n // Nothing there, or not ours to remove: the run makes its own later.\n }\n const parts = [\n `${s.deletedAgents.length} agent(s) deleted${s.deletedAgents.length ? ` (${s.deletedAgents.map((a) => a.name).join(\", \")})` : \"\"}`,\n `${s.removedDirs.length} attachmentDirs entr${s.removedDirs.length === 1 ? \"y\" : \"ies\"} removed`,\n `${removed} temp dir(s) removed`,\n `${s.drafts.length} draft(s) to check`,\n ];\n return parts.join(\", \");\n });\n }\n\n /** Earlier runs' scratch folders still out of the trash: listed for the owner (they're not this run's). */\n private async earlierFolders(): Promise<void> {\n await this.step(\"drive_search\", \"earlier runs' scratch folders\", async () => {\n const out = await this.read(\"drive_search\", { name: \"xaq-smoke-\", type: \"folder\", pageSize: 50 });\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string }[];\n const old = files.filter((f) => SMOKE_NAME_RE.test(f.name) && f.name !== this.marker);\n for (const f of old) this.earlier.push(`An earlier run's Drive folder \"${f.name}\" (${f.id}) isn't in the trash: check it and trash it.`);\n return `${old.length} to check`;\n });\n }\n\n // ───────────── Reads ─────────────\n\n private async driveReads(): Promise<void> {\n const picks: { kind: \"doc\" | \"sheet\" | \"slides\"; id: string; name: string }[] = [];\n for (const kind of [\"doc\", \"sheet\", \"slides\"] as const) {\n await this.step(\"drive_search\", `newest ${kind}`, async () => {\n const out = await this.read(\"drive_search\", { type: kind, pageSize: 5 });\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string; modifiedTime?: string; shortcutTo?: unknown }[];\n const real = files.filter((f) => f.id && !f.shortcutTo).sort((a, b) => String(b.modifiedTime ?? \"\").localeCompare(String(a.modifiedTime ?? \"\")));\n if (!real.length) throw new Skip(`no ${kind} files in this Drive`);\n picks.push({ kind, id: real[0]!.id, name: real[0]!.name });\n return `${files.length} found; newest \"${real[0]!.name}\"`;\n });\n }\n await this.step(\"drive_list_folder\", \"top of My Drive\", async () => {\n const out = await this.read(\"drive_list_folder\", { folderId: \"root\", pageSize: 10 });\n const files = Array.isArray(out.structured?.files) ? out.structured.files : [];\n return `${files.length} items`;\n });\n const formats = { doc: \"markdown\", sheet: \"csv\", slides: \"text\" } as const;\n for (const p of picks) {\n await this.step(\"drive_get\", `${p.kind} details`, async () => {\n const f = await this.driveFacts(p.id);\n return `\"${f.name}\"`;\n });\n await this.step(p.kind === \"doc\" ? \"docs_read\" : p.kind === \"sheet\" ? \"sheets_read\" : \"slides_read\", `read the ${p.kind}`, async () => {\n if (p.kind === \"doc\") {\n const out = await this.read(\"docs_read\", { documentId: p.id });\n return `text, ${Number(out.structured?.totalChars ?? out.text.length)} chars`;\n }\n if (p.kind === \"sheet\") {\n const out = await this.read(\"sheets_read\", { spreadsheetId: p.id, range: \"A1:Z50\" });\n const rows = Array.isArray(out.structured?.rows) ? out.structured.rows.length : 0;\n return `${rows} rows, ${out.text.length} chars`;\n }\n const out = await this.read(\"slides_read\", { presentationId: p.id });\n return `${Number(out.structured?.slideCount ?? 0)} slides, ${out.text.length} chars`;\n });\n await this.step(\"drive_export\", `export the ${p.kind} as ${formats[p.kind]}`, async () => {\n const out = await this.read(\"drive_export\", { fileId: p.id, format: formats[p.kind] });\n return `${formats[p.kind]}, ${Number(out.structured?.totalChars ?? out.text.length)} chars`;\n });\n }\n }\n\n private async mailReads(): Promise<void> {\n const account = this.account!.email;\n let threadIds: string[] = [];\n let message: { id: string; subject: string } | null = null;\n await this.step(\"search_threads\", \"find an email with attachments\", async () => {\n const out = await this.rawCall(\"search_threads\", { account, query: \"has:attachment -in:drafts -in:chats\", max_results: 5 });\n if (out.isError) throw new Error(out.text);\n threadIds = [...out.text.matchAll(/^\\s+thread_id: (\\S+)/gm)].map((m) => m[1]!);\n if (!threadIds.length) throw new Skip(\"no email with attachments in this mailbox\");\n return `${threadIds.length} threads`;\n });\n await this.step(\"get_thread\", \"pick ONE message with attachments\", async () => {\n const threadId = this.need(threadIds[0], \"a thread\");\n const out = await this.rawCall(\"get_thread\", { account, thread_id: threadId });\n if (out.isError) throw new Error(out.text);\n const ids = [...out.text.matchAll(/^Message (\\S+) \\(thread /gm)].map((m) => m[1]!);\n for (const id of ids.slice(0, 5)) {\n const m = await this.rawCall(\"get_message\", { account, message_id: id });\n if (m.isError) continue;\n const head = m.text.split(/<email_content /)[0] ?? m.text;\n if (/^Attachments: /m.test(head)) {\n message = { id, subject: /^Subject: (.*)$/m.exec(head)?.[1]?.trim() ?? \"(no subject)\" };\n return `subject \"${message.subject}\"`;\n }\n }\n throw new Skip(\"the thread's messages have no attachments\");\n });\n let attachments: ListedAttachment[] = [];\n await this.step(\"list_attachments\", \"list its attachments\", async () => {\n const m = this.need(message as { id: string; subject: string } | null, \"a message with attachments\");\n const out = await this.rawCall(\"list_attachments\", { account, message_id: m.id });\n if (out.isError) throw new Error(out.text);\n attachments = parseAttachmentList(out);\n if (!attachments.length) throw new Error(\"listed no attachments\");\n return attachments.map((a) => `\"${a.filename}\"`).join(\", \");\n });\n for (const a of attachments.slice(0, 10)) {\n await this.step(\"get_attachment\", `extract \"${a.filename}\"`, async () => {\n // format \"inline\" never saves (a copy of the owner's file on this machine, under a quota that may delete\n // older saved files). What it can't show isn't even downloaded: inlineKind skips it from the listing.\n const kind = inlineKind(a);\n if (!kind) return SKIPPED_NOT_INLINE;\n const m = message as { id: string; subject: string } | null;\n const out = await this.rawCall(\"get_attachment\", { account, message_id: m!.id, attachment_id: a.id, format: \"inline\" });\n const saved = savedPathOf(out);\n if (saved) {\n this.leftBehind.push(`A copy of the email attachment \"${a.filename}\" was saved at ${saved}: delete it.`);\n throw new Error(`get_attachment saved \"${a.filename}\" to disk (${saved}) instead of showing it`);\n }\n if (out.isError) throw new Error(out.text);\n const not = notShownOf(out);\n if (not?.code === \"unreadable\") {\n // A password-protected or encrypted file: xaq answered correctly and saved nothing. Anything else (a corrupt\n // file, or the parser missing, crashing, timing out) fails: this run is the only check that would see it.\n if (not.parseFailure && FILE_OWN_PARSE_FAILURES.has(not.parseFailure)) return `${kind}: couldn't read (${not.reason})`;\n throw new Error(`get_attachment couldn't read \"${a.filename}\" (${not.parseFailure ?? \"no failure code\"}: ${not.reason})`);\n }\n if (not) return `${kind}: not shown inline (${not.reason})`;\n return `${kind}: ${describeExtraction(out)}`;\n });\n }\n }\n\n // ───────────── Writes ─────────────\n\n private async createFolder(): Promise<boolean> {\n return this.step(\"drive_create_folder\", `create the scratch folder ${this.marker}`, async () => {\n const { out } = await this.ws(\"drive_create_folder\", { name: this.marker });\n const id = out.structured?.folderId;\n if (typeof id !== \"string\" || !id) throw new Error(\"drive_create_folder returned no folder id\");\n // Recorded at once: from here on cleanup trashes it.\n this.ledger.folder = { id, name: this.marker };\n const f = await this.driveFacts(id);\n if (f.name !== this.marker || f.trashed) {\n this.ledger.folder = null;\n this.leftBehind.push(`Drive item ${id}: drive_create_folder returned it, but it isn't a live folder named ${this.marker}. Check Drive.`);\n throw new Error(`folder ${id} isn't the scratch folder`);\n }\n return `folder ${id}`;\n });\n }\n\n private async docs(): Promise<string | null> {\n let doc: string | null = null;\n const title = `${this.marker} doc`;\n const old = `REPLACE-ME-${this.stamp}`;\n const fresh = `REPLACED-${this.stamp}`;\n await this.step(\"docs_create\", \"create a doc from markdown in the folder\", async () => {\n const markdown = `# ${this.marker}\\n\\nDOC-MARKER-A, written by xaq smoke.\\n\\n- ${old}\\n- ${old}\\n`;\n const { out } = await this.ws(\"docs_create\", { title, markdown, folderId: this.ledger.folder!.id });\n doc = await this.recordCreated(\"doc\", out.structured?.documentId, title);\n return `doc ${doc}`;\n });\n await this.step(\"docs_append\", \"append\", async () => {\n await this.ws(\"docs_append\", { documentId: this.need(doc, \"the doc\"), markdown: \"DOC-MARKER-B, appended by xaq smoke.\" });\n return \"appended\";\n });\n await this.step(\"docs_replace_text\", \"find and replace (2 matches)\", async () => {\n const { out } = await this.ws(\"docs_replace_text\", { documentId: this.need(doc, \"the doc\"), find: old, replace: fresh });\n const n = Number(out.structured?.occurrencesChanged);\n if (n !== 2) throw new Error(`changed ${n} occurrences, expected 2`);\n return \"2 occurrences changed\";\n });\n let comment: string | null = null;\n await this.step(\"docs_comment_add\", \"add a comment\", async () => {\n const { out } = await this.ws(\"docs_comment_add\", { documentId: this.need(doc, \"the doc\"), text: `${this.marker}: a comment from xaq smoke` });\n comment = typeof out.structured?.commentId === \"string\" ? out.structured.commentId : null;\n if (!comment) throw new Error(\"no comment id returned\");\n return `comment ${comment}`;\n });\n await this.step(\"docs_read\", \"read back: markers, replacements\", async () => {\n const out = await this.read(\"docs_read\", { documentId: this.need(doc, \"the doc\") });\n const t = out.text;\n const problems = [\n !t.includes(\"DOC-MARKER-A\") && \"the created text\",\n !t.includes(\"DOC-MARKER-B\") && \"the appended text\",\n t.split(fresh).length - 1 !== 2 && \"2 replacements\",\n t.includes(old) && \"no text left to replace\",\n ].filter(Boolean);\n if (problems.length) throw new Error(`missing: ${problems.join(\", \")}`);\n return \"all markers present\";\n });\n await this.step(\"docs_comments_list\", \"the comment is there\", async () => {\n const out = await this.read(\"docs_comments_list\", { documentId: this.need(doc, \"the doc\") });\n const list = (Array.isArray(out.structured?.comments) ? out.structured.comments : []) as { id?: string }[];\n if (!list.some((c) => c.id === this.need(comment, \"the comment\"))) throw new Error(\"the comment isn't listed\");\n return `${list.length} comment(s)`;\n });\n return doc;\n }\n\n private async sheets(): Promise<void> {\n let sheet: string | null = null;\n const title = `${this.marker} sheet`;\n const written = [\n [\"name\", \"kind\", \"marker\"],\n [\"alpha\", \"write\", this.stamp],\n ];\n const appended = [\n [\"beta\", \"append\", this.stamp],\n [\"gamma\", \"append\", this.stamp],\n ];\n await this.step(\"sheets_create\", \"create a sheet in the folder\", async () => {\n const { out } = await this.ws(\"sheets_create\", { title, folderId: this.ledger.folder!.id });\n sheet = await this.recordCreated(\"sheet\", out.structured?.spreadsheetId, title);\n return `sheet ${sheet}`;\n });\n await this.step(\"sheets_write\", \"write A1:C2\", async () => {\n const { out } = await this.ws(\"sheets_write\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A1:C2\", values: written, input: \"RAW\" });\n if (Number(out.structured?.updatedCells) !== 6) throw new Error(`updated ${String(out.structured?.updatedCells)} cells, expected 6`);\n return \"6 cells\";\n });\n await this.step(\"sheets_append_rows\", \"append 2 rows\", async () => {\n const { out } = await this.ws(\"sheets_append_rows\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A:C\", rows: appended, input: \"RAW\" });\n if (Number(out.structured?.updatedRows) !== 2) throw new Error(`appended ${String(out.structured?.updatedRows)} rows, expected 2`);\n return \"2 rows\";\n });\n await this.step(\"sheets_read\", \"read back and compare\", async () => {\n const out = await this.read(\"sheets_read\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A1:C4\" });\n const rows = out.structured?.rows;\n if (canonical(rows) !== canonical([...written, ...appended])) throw new Error(\"the cells differ from what was written\");\n return \"4 rows match\";\n });\n }\n\n private async slides(): Promise<void> {\n let deck: string | null = null;\n let first: string | null = null;\n let extra: string | null = null;\n let png: string | null = null;\n const title = `${this.marker} deck`;\n const old = `SLIDE-MARKER-${this.stamp}`;\n const fresh = `SLIDE-REPLACED-${this.stamp}`;\n await this.step(\"slides_create\", \"create a deck from an outline in the folder\", async () => {\n const { out } = await this.ws(\"slides_create\", {\n title,\n slides: [\n { title: \"Smoke one\", bullets: [old] },\n { title: \"Smoke two\", bullets: [old] },\n ],\n folderId: this.ledger.folder!.id,\n });\n deck = await this.recordCreated(\"deck\", out.structured?.presentationId, title);\n const made = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; title?: string }[];\n first = made.find((s) => s.title === \"Smoke one\")?.slideId ?? null;\n return `deck ${deck}, ${made.length} slides`;\n });\n await this.step(\"slides_add_slide\", \"add a slide\", async () => {\n const { out } = await this.ws(\"slides_add_slide\", { presentationId: this.need(deck, \"the deck\"), title: \"Smoke: deleted through approval\", bullets: [\"xaq smoke deletes this slide\"] });\n extra = typeof out.structured?.slideId === \"string\" ? out.structured.slideId : null;\n if (!extra) throw new Error(\"no slide id returned\");\n return `slide ${extra}`;\n });\n await this.step(\"slides_replace_text\", \"replace text (2 matches)\", async () => {\n const { out } = await this.ws(\"slides_replace_text\", { presentationId: this.need(deck, \"the deck\"), find: old, replace: fresh });\n const n = Number(out.structured?.occurrencesChanged);\n if (n !== 2) throw new Error(`changed ${n} occurrences, expected 2`);\n return \"2 occurrences changed\";\n });\n await this.step(\"drive_upload\", \"upload a PNG into the folder\", async () => {\n const name = `${this.marker}.png`;\n const { out } = await this.ws(\"drive_upload\", { name, folderId: this.ledger.folder!.id, mimeType: \"image/png\", content_base64: solidPng().toString(\"base64\") });\n png = await this.recordCreated(\"image\", out.structured?.fileId, name);\n return `image ${png}`;\n });\n // Slides fetches a Drive image without credentials, so only an image shared \"anyone with the link\" works, and\n // the extension never changes sharing. The run's own PNG is private: the tool must refuse it and leave the deck\n // as it was. An insert would mean the file got shared somehow, which is a failure.\n const imagesOnFirst = async () => {\n const out = await this.read(\"slides_read\", { presentationId: deck! });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; images?: number }[];\n return slides.find((s) => s.slideId === first)?.images ?? 0;\n };\n await this.step(\"slides_insert_image\", \"Drive image (private)\", async () => {\n const args = { presentationId: this.need(deck, \"the deck\"), slideId: this.need(first, \"the first slide\"), driveFileId: this.need(png, \"the PNG\") };\n const before = await imagesOnFirst();\n let refusal: string | null = null;\n try {\n await this.ws(\"slides_insert_image\", args);\n } catch (err) {\n if (err instanceof GuardError || err instanceof Interrupted) throw err;\n refusal = errText(err);\n }\n if (refusal === null) throw new Error(\"inserted a private Drive image: check the PNG's sharing in Drive\");\n if (!/shared publicly/i.test(refusal)) throw new Error(refusal);\n if ((await imagesOnFirst()) !== before) throw new Error(\"refused, but the deck changed\");\n return \"refused as expected\";\n });\n await this.step(\"slides_insert_image\", \"insert a public https image\", async () => {\n const { out } = await this.ws(\"slides_insert_image\", { presentationId: this.need(deck, \"the deck\"), slideId: this.need(first, \"the first slide\"), imageUrl: this.deps.imageUrl ?? PUBLIC_IMAGE_URL });\n return `image ${String(out.structured?.imageId ?? \"?\")}`;\n });\n await this.step(\"slides_read\", \"read back: text replaced, the image there\", async () => {\n const out = await this.read(\"slides_read\", { presentationId: this.need(deck, \"the deck\") });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; images?: number }[];\n const problems = [\n out.text.split(fresh).length - 1 !== 2 && \"2 replacements\",\n out.text.includes(old) && \"no text left to replace\",\n (slides.find((s) => s.slideId === first)?.images ?? 0) !== 1 && \"the public image on the first slide\",\n !slides.some((s) => s.slideId === extra) && \"the added slide\",\n ].filter(Boolean);\n if (problems.length) throw new Error(`missing: ${problems.join(\", \")}`);\n return `${slides.length} slides`;\n });\n await this.step(\"slides_delete_slide\", \"delete a slide through the approval path\", async () => {\n const slideId = this.need(extra, \"the added slide\");\n const { approved } = await this.ws(\"slides_delete_slide\", { presentationId: this.need(deck, \"the deck\"), slideId });\n if (!approved) throw new Error(\"the call wasn't held for approval (the connection should be at \\\"ask\\\")\");\n const out = await this.read(\"slides_read\", { presentationId: deck! });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string }[];\n if (slides.some((s) => s.slideId === slideId)) throw new Error(\"approved, but the slide is still there\");\n return `pending, approved (${approved}), gone`;\n });\n }\n\n private async draft(doc: string | null): Promise<void> {\n const own = this.account!.email;\n let local: { path: string; size: number } | null = null;\n let draftId: string | null = null;\n await this.step(\"xaq\", \"allow a private temp dir in attachmentDirs\", async () => {\n const dir = mkdtempSync(join(privateSmokeDir(this.deps.tmpRoot), `${this.marker}-`));\n this.ledger.tempDir = dir;\n const path = join(dir, `${this.marker}.txt`);\n const bytes = Buffer.from(`${this.marker}\\nA local file attached by xaq smoke google-workspace.\\n${\"0123456789abcdef\".repeat(64)}\\n`);\n writeFileSync(path, bytes, { mode: 0o600 });\n local = { path, size: bytes.length };\n const settings = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n this.previousDirs = [...(settings.attachmentDirs ?? [])];\n await this.deps.admin.request(\"PATCH\", \"/api/settings\", { attachmentDirs: [...this.previousDirs, dir] });\n this.dirsChanged = true;\n return `${basename(path)} (${bytes.length} bytes)`;\n });\n const subject = `${smokeSubjectPrefix(this.marker)} attachments check, never sent`;\n await this.step(\"create_draft\", `ONE draft to ${own}, 2 attachments`, async () => {\n const file = this.need(local as { path: string; size: number } | null, \"the local file\");\n const args = {\n account: own,\n to: [own],\n subject,\n body: \"Created by `xaq smoke google-workspace`, which deletes this draft again. Nothing is sent.\",\n attachments: [{ path: file.path }, { drive_file_id: this.need(doc, \"the scratch doc\"), export_as: \"pdf\" }],\n };\n await this.guard.checkDraft(args, own);\n const out = await this.rawCall(\"create_draft\", args);\n if (out.isError) throw new Error(out.text);\n const r = JSON.parse(out.text) as { status?: string; draftId?: string };\n if (r.status !== \"draft_created\" || !r.draftId) throw new Error(`expected a draft, got ${r.status ?? \"nothing\"}`);\n draftId = r.draftId;\n this.ledger.drafts.set(r.draftId, { deleted: false });\n return `draft ${r.draftId}`;\n });\n await this.step(\"xaq\", \"check the draft: recipient, 2 attachments, names, sizes\", async () => {\n const id = this.need(draftId, \"the draft\");\n const file = local as { path: string; size: number } | null;\n const v = await this.deps.admin.request<SmokeDraftView>(\"POST\", \"/api/smoke/drafts/inspect\", this.draftInput(id));\n if (v.recipients.length !== 1 || v.recipients[0] !== own.toLowerCase()) throw new Error(`recipients ${v.recipients.join(\", \")}, expected only ${own}`);\n if (v.attachments.length !== 2) throw new Error(`${v.attachments.length} attachments, expected 2`);\n const name = basename(file!.path);\n const a = v.attachments.find((x) => x.filename === name);\n if (!a || a.size !== file!.size) throw new Error(`the local file ${name} isn't attached at ${file!.size} bytes`);\n const docTitle = this.ledger.files.get(doc!)?.name ?? \"\";\n const d = v.attachments.find((x) => x !== a);\n if (!d || !d.filename.startsWith(docTitle) || d.size <= 0) throw new Error(`the scratch doc \"${docTitle}\" isn't attached`);\n return `\"${a.filename}\" ${a.size} B, \"${d.filename}\" ${d.size} B`;\n });\n await this.step(\"xaq\", \"delete the draft\", async () => {\n await this.deleteDraft(this.need(draftId, \"the draft\"));\n return \"deleted\";\n });\n }\n\n private draftInput(draftId: string) {\n return { agentId: this.ledger.agent!.id, accountId: this.account!.id, draftId, ledger: [...this.ledger.drafts.keys()] };\n }\n\n private async deleteDraft(id: string): Promise<void> {\n await this.deps.admin.request(\"POST\", \"/api/smoke/drafts/delete\", this.draftInput(id));\n this.ledger.drafts.set(id, { deleted: true });\n }\n\n // ───────────── Cleanup and the leftover check ─────────────\n\n private async deleteAgent(): Promise<void> {\n const agent = this.ledger.agent;\n if (!agent || this.agentDeleted) return;\n await this.deps.admin.request(\"DELETE\", `/api/agents/${encodeURIComponent(agent.id)}`);\n this.agentDeleted = true;\n }\n\n private async restoreDirs(): Promise<void> {\n if (!this.dirsChanged || !this.previousDirs) return;\n await this.deps.admin.request(\"PATCH\", \"/api/settings\", { attachmentDirs: this.previousDirs });\n this.dirsChanged = false;\n }\n\n private removeTempDir(): void {\n if (this.ledger.tempDir) rmSync(this.ledger.tempDir, { recursive: true, force: true });\n }\n\n /**\n * The second Ctrl-C: only what matters most and is quick (the agent's key stops working, attachmentDirs is back,\n * the temp file goes), each bounded by `timeoutMs`. The Drive folder and a draft stay; the caller lists them.\n */\n async fastCleanup(timeoutMs = 3000): Promise<void> {\n await within(\n this.deleteAgent().catch(() => {}),\n timeoutMs,\n );\n await within(\n this.restoreDirs().catch(() => {}),\n timeoutMs,\n );\n try {\n this.removeTempDir();\n } catch {\n // Listed by the caller.\n }\n }\n\n /** What may still be there right now (the second Ctrl-C prints it). */\n pendingLeftovers(): string[] {\n const l = this.ledger;\n return [\n l.agent && !this.agentDeleted ? `the agent ${l.agent.name}` : null,\n l.folder ? `the Drive folder ${l.folder.name} (${l.folder.id})` : null,\n ...[...l.drafts].filter(([, d]) => !d.deleted).map(([id]) => `the draft ${id}`),\n this.dirsChanged && l.tempDir ? `attachmentDirs still lists ${l.tempDir}` : null,\n l.tempDir && existsSync(l.tempDir) ? `the temp dir ${l.tempDir}` : null,\n ].filter((x): x is string => !!x);\n }\n\n private async cleanup(): Promise<void> {\n if (this.deps.signal.aborted) this.print(\"Interrupted: cleaning up (this takes a moment)…\");\n const agent = this.ledger.agent;\n for (const [id, d] of this.ledger.drafts) {\n if (d.deleted) continue;\n await this.step(\"xaq\", \"cleanup: delete the draft\", async () => {\n await this.deleteDraft(id);\n return `draft ${id}`;\n });\n }\n const folder = this.ledger.folder;\n const reported = new Set<string>();\n if (folder) {\n await this.step(\"drive_trash\", \"cleanup: trash the scratch folder through the approval path\", async () => {\n const { approved } = await this.ws(\"drive_trash\", { fileId: folder.id });\n if (!approved) throw new Error(\"the call wasn't held for approval (the connection should be at \\\"ask\\\")\");\n const f = await this.driveFacts(folder.id);\n if (!f.trashed) throw new Error(\"approved, but the folder isn't in the trash\");\n return `pending, approved (${approved}), in the trash`;\n });\n // The leftover check on Drive, while the agent can still look.\n for (const [id, f] of [[folder.id, { kind: \"folder\", name: folder.name }] as const, ...this.ledger.files]) {\n reported.add(id);\n try {\n if (!(await this.driveFacts(id)).trashed) this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}) is not in the trash.`);\n } catch (err) {\n this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}): couldn't check it (${errText(err)}).`);\n }\n }\n }\n for (const [id, f] of this.ledger.strays) {\n reported.add(id);\n this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}) came back from a create call but isn't in the scratch folder. It may be an existing file: check it before removing anything.`);\n }\n // Creates the ledger never recorded (a lost answer): anything carrying the run's name and not in the trash.\n if (this.mcp) {\n try {\n const out = await this.read(\"drive_search\", { name: this.marker, pageSize: 50 }, true);\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string; type?: string }[];\n for (const f of files) {\n if (reported.has(f.id)) continue;\n this.leftBehind.push(`Drive ${f.type ?? \"file\"} \"${f.name}\" (${f.id}) carries this run's name and isn't in the trash: check it and trash it.`);\n }\n } catch (err) {\n this.leftBehind.push(`Couldn't search Drive for files named ${this.marker}: ${errText(err)}`);\n }\n }\n\n await this.mcp?.close().catch(() => {});\n this.mcp = null;\n if (agent && !this.agentDeleted) {\n await this.step(\"xaq\", \"cleanup: delete the temporary agent\", async () => {\n await this.deleteAgent();\n return agent.name;\n });\n }\n if (this.dirsChanged && this.previousDirs) {\n await this.step(\"xaq\", \"cleanup: restore attachmentDirs\", async () => {\n await this.restoreDirs();\n return `${this.previousDirs!.length} dir(s), as before`;\n });\n }\n try {\n this.removeTempDir();\n } catch {\n // Reported by the leftover check.\n }\n await this.leftovers();\n }\n\n private async leftovers(): Promise<void> {\n const agent = this.ledger.agent;\n if (this.ledger.tempDir && existsSync(this.ledger.tempDir)) this.leftBehind.push(`The temp dir ${this.ledger.tempDir} still exists.`);\n try {\n if (this.account) {\n // Always asked, also when the agent was never created: other smoke agents are listed either way, and the\n // daemon adds every draft the agent created according to the audit log (one the ledger missed included).\n const l = await this.deps.admin.request<SmokeLeftovers>(\"POST\", \"/api/smoke/leftovers\", {\n agentId: agent?.id ?? null,\n accountId: this.account.id,\n draftIds: [...this.ledger.drafts.keys()],\n });\n if (agent && l.agent) this.leftBehind.push(`The temporary agent ${agent.name} (${agent.id}) still exists: delete it in the console (Agents).`);\n if (l.agentSettings) this.leftBehind.push(`The temporary agent's settings (tool mode) are still stored.`);\n for (const d of l.drafts) this.leftBehind.push(`The draft ${d} still exists in ${this.account.email}: delete it in Gmail (Drafts).`);\n for (const a of l.otherSmokeAgents) this.leftBehind.push(`Another smoke run's agent ${a.name} (${a.id}) exists: delete it in the console (Agents).`);\n }\n if (this.previousDirs) {\n const s = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n if (canonical(s.attachmentDirs ?? []) !== canonical(this.previousDirs)) this.leftBehind.push(`attachmentDirs isn't back to what it was (${this.previousDirs.join(\", \") || \"empty\"}).`);\n }\n }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AAE,OAAO,KAAK,WAAW,KAAK,uBAAuB,MAAM,KAAK,IAAI,MAAM,GAAG,mDAAmD;IAC7I,IAAI,EAAE,eAAe,KAAK,WAAW,KAAK,8DAA8D;IACxG,KAAK,MAAM,KAAK,EAAE,QAAQ,KAAK,WAAW,KAAK,aAAa,EAAE,mBAAmB,KAAK,QAAQ,MAAM,+BAA+B;IACnI,KAAK,MAAM,KAAK,EAAE,kBAAkB,KAAK,WAAW,KAAK,6BAA6B,EAAE,KAAK,IAAI,EAAE,GAAG,6CAA6C;GACrJ;GACA,IAAI,KAAK,cAEH;QAAA,WAAU,MADE,KAAK,KAAK,MAAM,QAAsB,OAAO,eAAe,EAAA,CAC5D,kBAAkB,CAAC,CAAC,MAAM,UAAU,KAAK,YAAY,GAAG,KAAK,WAAW,KAAK,6CAA6C,KAAK,aAAa,KAAK,IAAI,KAAK,QAAQ,GAAG;GAAA;EAEzL,SAAS,KAAK;GACZ,KAAK,WAAW,KAAK,uCAAuC,QAAQ,GAAG,GAAG;EAC5E;CACF;AACF"}
1
+ {"version":3,"file":"run-BQB8DwLB.js","names":[],"sources":["../server/smoke/guards.ts","../server/smoke/png.ts","../server/smoke/run.ts"],"sourcesContent":["// The smoke run's guards, in code: every write the run makes goes through ScratchGuard.checkWrite first, and the\n// draft through checkDraft. They work from the ledger (what this run created) and from drive_get (where a file\n// really is), so a bug elsewhere in the run, or an extension that answers with the wrong id, can't turn into a\n// write on an existing file or a mail to anyone but the account itself.\n\nimport { resolve, sep } from \"node:path\";\n\nexport class GuardError extends Error {\n constructor(message: string) {\n super(`guard refused: ${message}`);\n this.name = \"GuardError\";\n }\n}\n\n/** What the run created, so cleanup and the leftover check work from facts, not from the step list. */\nexport interface Ledger {\n /** The run's marker (xaq-smoke-<ts>): the folder's and the agent's name, the draft subject's prefix. */\n marker: string;\n folder: { id: string; name: string } | null;\n /** Files created in the scratch folder (checked with drive_get before they were recorded). */\n files: Map<string, { kind: string; name: string }>;\n /** Files a create call reported that turned out NOT to be in the scratch folder: never written to again, reported. */\n strays: Map<string, { kind: string; name: string }>;\n drafts: Map<string, { deleted: boolean }>;\n /** mcp.call approvals the run approved (its own calls only). */\n approvals: string[];\n agent: { id: string; name: string } | null;\n tempDir: string | null;\n}\n\nexport function newLedger(marker: string): Ledger {\n return { marker, folder: null, files: new Map(), strays: new Map(), drafts: new Map(), approvals: [], agent: null, tempDir: null };\n}\n\n/**\n * Every Workspace write the run makes (upstream tool names), and where its target ids are:\n * - `folder`: the argument must be the scratch folder itself (create-in-folder calls, and the final drive_trash);\n * - `file`: the argument, when given, must be a file this run created whose parents include the scratch folder.\n * drive_create_folder is special: once, named after the marker, at the top of My Drive (it makes the folder).\n */\nexport const WRITE_TARGETS: Readonly<Record<string, { folder?: readonly string[]; file?: readonly string[] }>> = {\n drive_create_folder: {},\n drive_upload: { folder: [\"folderId\"] },\n drive_trash: { folder: [\"fileId\"] },\n docs_create: { folder: [\"folderId\"] },\n docs_append: { file: [\"documentId\"] },\n docs_replace_text: { file: [\"documentId\"] },\n docs_comment_add: { file: [\"documentId\"] },\n sheets_create: { folder: [\"folderId\"] },\n sheets_write: { file: [\"spreadsheetId\"] },\n sheets_append_rows: { file: [\"spreadsheetId\"] },\n slides_create: { folder: [\"folderId\"] },\n slides_add_slide: { file: [\"presentationId\"] },\n slides_replace_text: { file: [\"presentationId\"] },\n slides_insert_image: { file: [\"presentationId\", \"driveFileId\"] },\n slides_delete_slide: { file: [\"presentationId\"] },\n};\n\n/** The Workspace reads the run makes. Anything in neither list is refused. */\nexport const READ_TOOLS: ReadonlySet<string> = new Set([\n \"drive_search\",\n \"drive_list_folder\",\n \"drive_get\",\n \"drive_export\",\n \"docs_read\",\n \"docs_comments_list\",\n \"sheets_read\",\n \"slides_read\",\n]);\n\n/** drive_get's answer, as far as the guards need it. */\nexport interface DriveFacts {\n id: string;\n name: string;\n parents: string[];\n trashed: boolean;\n}\n\nexport type DriveGet = (fileId: string) => Promise<DriveFacts>;\n\n/** File arguments that may be left out (the tool takes another source instead). */\nconst OPTIONAL_FILE_ARGS: ReadonlySet<string> = new Set([\"driveFileId\"]);\n/** create_draft attachment sources (writer A1): an item has exactly one. */\nconst SOURCE_KEYS = [\"path\", \"drive_file_id\", \"content_base64\", \"message_id\"] as const;\n/** Other keys an attachment item may carry (attachment_id goes with message_id). */\nconst ITEM_KEYS: ReadonlySet<string> = new Set([\"export_as\", \"filename\", \"mime_type\", \"attachment_id\"]);\n\nexport class ScratchGuard {\n constructor(\n private readonly ledger: Ledger,\n private readonly driveGet: DriveGet,\n ) {}\n\n /** Throws GuardError unless `tool(args)` writes only inside the scratch folder. Call before EVERY write. */\n async checkWrite(tool: string, args: Record<string, unknown>): Promise<void> {\n const spec = WRITE_TARGETS[tool];\n if (!spec) throw new GuardError(`${tool} isn't one of the writes the smoke run makes`);\n if (tool === \"drive_create_folder\") {\n if (this.ledger.folder) throw new GuardError(\"the scratch folder already exists; the run makes exactly one\");\n if (args.name !== this.ledger.marker) throw new GuardError(`the scratch folder must be named ${this.ledger.marker}`);\n if (args.parentId !== undefined) throw new GuardError(\"the scratch folder goes at the top of My Drive\");\n return;\n }\n const folder = this.ledger.folder;\n if (!folder) throw new GuardError(`${tool}: there is no scratch folder, so nothing may be written`);\n for (const key of spec.folder ?? []) {\n const value = args[key];\n if (value !== folder.id) throw new GuardError(`${tool}: ${key} must be the scratch folder ${folder.id}`);\n const f = await this.driveGet(folder.id);\n if (f.id !== folder.id || f.name !== folder.name) throw new GuardError(`${tool}: ${folder.id} isn't the scratch folder ${folder.name} any more`);\n }\n for (const key of spec.file ?? []) {\n const value = args[key];\n // Every file argument is required, except slides_insert_image's driveFileId (it may take imageUrl instead).\n if (value === undefined && OPTIONAL_FILE_ARGS.has(key)) continue;\n await this.checkFile(tool, key, value);\n }\n }\n\n /** A file argument: one this run created, and drive_get says it's in the scratch folder. */\n async checkFile(tool: string, key: string, value: unknown): Promise<void> {\n const folder = this.ledger.folder;\n if (!folder) throw new GuardError(`${tool}: there is no scratch folder`);\n if (typeof value !== \"string\" || !value) throw new GuardError(`${tool}: ${key} must be a file id`);\n if (!this.ledger.files.has(value)) throw new GuardError(`${tool}: ${key} ${value} isn't a file this run created`);\n const f = await this.driveGet(value);\n if (f.id !== value || !f.parents.includes(folder.id)) throw new GuardError(`${tool}: ${key} ${value} isn't in the scratch folder ${folder.name}`);\n if (f.trashed) throw new GuardError(`${tool}: ${key} ${value} is in the trash`);\n }\n\n /**\n * The draft: addressed to exactly the account's own address (no Cc, no Bcc, not a reply), its attachments only a\n * file in the run's temp dir or a file in the scratch folder.\n */\n async checkDraft(args: Record<string, unknown>, own: string): Promise<void> {\n const me = own.trim().toLowerCase();\n const to = args.to;\n if (!Array.isArray(to) || to.length !== 1 || typeof to[0] !== \"string\" || to[0].trim().toLowerCase() !== me) {\n throw new GuardError(`create_draft: the draft must be addressed to exactly ${own}, the account's own address`);\n }\n for (const key of [\"cc\", \"bcc\", \"thread_id\"]) if (args[key] !== undefined) throw new GuardError(`create_draft: no ${key}`);\n const atts = args.attachments;\n if (!Array.isArray(atts)) return;\n for (const a of atts as Record<string, unknown>[]) {\n if (!a || typeof a !== \"object\" || Array.isArray(a)) throw new GuardError(\"create_draft: an attachment must be an object\");\n // Exactly one source per item (message_id + attachment_id together count as one), and no keys beyond it.\n const sources = SOURCE_KEYS.filter((k) => a[k] !== undefined);\n if (sources.length !== 1) throw new GuardError(`create_draft: each attachment needs exactly one source, not ${sources.length ? sources.join(\" + \") : \"none\"}`);\n const extra = Object.keys(a).filter((k) => !(SOURCE_KEYS as readonly string[]).includes(k) && !ITEM_KEYS.has(k));\n if (extra.length) throw new GuardError(`create_draft: unexpected attachment keys ${extra.join(\", \")}`);\n if (typeof a.path === \"string\") {\n const dir = this.ledger.tempDir;\n const abs = resolve(a.path);\n if (!dir || !abs.startsWith(resolve(dir) + sep)) throw new GuardError(\"create_draft: a local attachment must be in the run's temp dir\");\n } else if (typeof a.drive_file_id === \"string\") {\n await this.checkFile(\"create_draft\", \"drive_file_id\", a.drive_file_id);\n } else {\n throw new GuardError(\"create_draft: attachments are a temp-dir file or a scratch-folder file only\");\n }\n }\n }\n}\n","// A small solid-colour PNG, built here so the smoke run uploads an image it made itself (the Drive-thumbnail path of\n// slides_insert_image) without shipping a binary file.\n\nimport { crc32, deflateSync } from \"node:zlib\";\n\nfunction chunk(type: string, data: Buffer): Buffer {\n const len = Buffer.alloc(4);\n len.writeUInt32BE(data.length);\n const body = Buffer.concat([Buffer.from(type, \"ascii\"), data]);\n const crc = Buffer.alloc(4);\n crc.writeUInt32BE(crc32(body) >>> 0);\n return Buffer.concat([len, body, crc]);\n}\n\n/** A `size`×`size` RGB PNG in one colour. */\nexport function solidPng(size = 64, rgb: [number, number, number] = [26, 115, 232]): Buffer {\n const ihdr = Buffer.alloc(13);\n ihdr.writeUInt32BE(size, 0);\n ihdr.writeUInt32BE(size, 4);\n ihdr[8] = 8; // bit depth\n ihdr[9] = 2; // truecolour\n const row = Buffer.alloc(1 + size * 3);\n for (let x = 0; x < size; x++) row.set(rgb, 1 + x * 3);\n const raw = Buffer.concat(Array.from({ length: size }, () => row));\n return Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), chunk(\"IHDR\", ihdr), chunk(\"IDAT\", deflateSync(raw)), chunk(\"IEND\", Buffer.alloc(0))]);\n}\n","// `xaq smoke google-workspace --scratch`: a live end-to-end check of Gmail attachments and the google-workspace\n// extension on a real account, safe by construction (docs/reference.md, \"Live check\").\n//\n// - First, earlier runs' leftovers are swept: their agents deleted, their temp dirs taken out of attachmentDirs, and\n// their drafts and Drive folders reported for the owner to check.\n// - Reads anywhere: a few existing Drive files (newest Doc, Sheet, Slides) and ONE email with attachments. Only\n// names, the subject, kinds and sizes are printed, never content. Only attachments get_attachment can show inline\n// are extracted, with format \"inline\" (which never saves): a password-protected or encrypted file passes as\n// \"couldn't read (<reason>)\", any other parse failure fails, and a saved copy anyway fails the step and is listed.\n// - Every write goes into ONE new Drive folder named after the run (xaq-smoke-<UTC timestamp>), through\n// ScratchGuard (guards.ts): the target must be that folder or a file this run created whose drive_get parents\n// include it. The only mail is ONE draft to the account's own address, deleted again; nothing is ever sent.\n// - Tool calls go through /mcp as a temporary agent (mail read + draft, the Workspace connection at \"ask\"), so risky\n// calls really come back pending; the command approves its own calls (checked: agent, tool, exact arguments)\n// through the admin API.\n// - Cleanup always runs (also on a failed step, Ctrl-C, SIGTERM or SIGHUP): the draft deleted, the folder trashed\n// (drive_trash, approved), the agent deleted, attachmentDirs restored, the temp dir removed. Then the leftover\n// check. A second Ctrl-C runs fastCleanup (agent and attachmentDirs only, bounded) and quits.\n\nimport { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, join } from \"node:path\";\nimport type { Account, AgentWithKey, ConnectionView, McpCallApprovalView } from \"../../shared/types.ts\";\nimport { SMOKE_NAME_RE, SMOKE_TEMP_RE, type SmokeDraftView, type SmokeLeftovers, type SmokeSweep, smokeName, smokeSubjectPrefix } from \"../../shared/smoke.ts\";\nimport type { AdminChannel } from \"../connections-cli/admin.ts\";\nimport { NPX } from \"../listen/version.ts\";\nimport { MAX_ATTACHMENT_BYTES } from \"../mail/agent.ts\";\nimport { cleanLine } from \"../mail/content.ts\";\nimport { PARSE_LIMITS } from \"../mail/extract/types.ts\";\nimport { attachmentKind } from \"../mcp/attachments.ts\";\nimport { type AgentMcp, type CallOutcome } from \"./agent.ts\";\nimport { type DriveFacts, GuardError, type Ledger, newLedger, READ_TOOLS, ScratchGuard, WRITE_TARGETS } from \"./guards.ts\";\nimport { solidPng } from \"./png.ts\";\nimport { finish, type SmokeReport, type StepResult } from \"./report.ts\";\n\n/** The extension's id (its manifest name): the preset of its connections. */\nexport const WORKSPACE_PRESET = \"google-workspace\";\n/** The scopes the extension asks Google for; a sign-in missing one makes some tools fail. */\nexport const WORKSPACE_SCOPES = [\n \"https://www.googleapis.com/auth/documents\",\n \"https://www.googleapis.com/auth/spreadsheets\",\n \"https://www.googleapis.com/auth/presentations\",\n \"https://www.googleapis.com/auth/drive.file\",\n \"https://www.googleapis.com/auth/drive.readonly\",\n];\n/** Mail tools the run calls (native, not prefixed). */\nexport const MAIL_TOOLS = [\"search_threads\", \"get_thread\", \"get_message\", \"list_attachments\", \"get_attachment\", \"create_draft\"] as const;\n/** A fixed public https image (Google's own logo), for slides_insert_image's imageUrl path. */\nexport const PUBLIC_IMAGE_URL = \"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\";\n\n/**\n * What get_attachment (server/mcp/attachments.ts) can show inline, from its own rules: attachmentKind() on the listed\n * type and name, images under MAX_ATTACHMENT_BYTES, PDF/DOCX/XLSX/PPTX/CSV under PARSE_LIMITS.inputBytes, text and\n * HTML at any size (it reads the first part). The run asks with format \"inline\", which never saves; for anything\n * else that would only download the owner's file to answer \"not shown\", so the run doesn't ask. The bytes aren't\n * known here: attachmentKind's content sniff (a PDF sent as octet-stream without an extension) sees an empty buffer\n * and says \"other\", which skips the file.\n */\nexport const SKIPPED_NOT_INLINE = \"skipped (can't be shown inline)\";\n\nexport interface ListedAttachment {\n id: string;\n filename: string;\n mimeType: string;\n /** Bytes; NaN when the listing didn't say. */\n size: number;\n}\n\n/** The kind get_attachment would show inline, or null when it would save the file to disk (so the run skips it). */\nexport function inlineKind(a: Pick<ListedAttachment, \"filename\" | \"mimeType\" | \"size\">): string | null {\n const kind = attachmentKind(a.mimeType, a.filename, Buffer.alloc(0));\n const known = Number.isFinite(a.size) && a.size >= 0;\n if (kind === \"other\") return null;\n if (kind === \"text\" || kind === \"html\") return kind;\n if (kind === \"image\") return known && a.size < MAX_ATTACHMENT_BYTES ? kind : null;\n return known && a.size < PARSE_LIMITS.inputBytes ? kind : null;\n}\n\nexport interface SmokeFlags {\n scratch?: boolean;\n yes?: boolean;\n account?: string;\n connection?: string;\n json?: boolean;\n}\n\nexport interface SmokeDeps {\n admin: Pick<AdminChannel, \"request\" | \"baseUrl\">;\n /** An MCP client on /mcp with this key (default: the SDK client on admin.baseUrl). */\n connectMcp: (apiKey: string) => Promise<AgentMcp>;\n /** Progress and the plan (stderr with --json). May throw (a dead terminal): the run ignores that. */\n print: (line?: string) => void;\n /** Asked once, after the plan; --yes answers it. */\n confirm: (question: string) => Promise<boolean>;\n /** Ctrl-C, SIGTERM, SIGHUP: no new step starts, cleanup runs. */\n signal: AbortSignal;\n now?: () => Date;\n /**\n * The directory under which the run keeps its private (0700) `xaq-smoke` directory for the draft's local file.\n * Default $XDG_CACHE_HOME or ~/.cache: never the shared /tmp.\n */\n tmpRoot?: string;\n imageUrl?: string;\n /** get_call_status polling while an approved call runs. */\n pollMs?: number;\n}\n\n/** Setup problems found before anything is created: printed as they are, exit 1. */\nexport class SmokeSetupError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SmokeSetupError\";\n }\n}\n\nclass Skip extends Error {}\nclass Interrupted extends Error {\n constructor() {\n super(\"interrupted (Ctrl-C)\");\n }\n}\n\ninterface SettingsView {\n publicUrl: string;\n brokerUpstreams?: boolean;\n /** Directories create_draft may attach local files from. */\n attachmentDirs?: string[];\n}\n\n/** The Google account the connection is signed in as (ConnectionView `google.email`), or null. */\nexport function boundAccountEmail(c: ConnectionView): string | null {\n const email = c.google?.email;\n return typeof email === \"string\" && email ? email : null;\n}\n\n/** Scopes the extension needs that the connection's sign-in lacks: `google.missing`, else from grantedScopes. */\nfunction missingScopes(c: ConnectionView): string[] {\n if (c.google && Array.isArray(c.google.missing)) return c.google.missing.map((m) => m.scope);\n if (c.preset === WORKSPACE_PRESET && c.grantedScopes) return WORKSPACE_SCOPES.filter((s) => !c.grantedScopes!.includes(s));\n return [];\n}\n\n/** Picks the account and the connection (flags, else the only one) and checks both are usable. */\nexport function chooseTargets(\n flags: SmokeFlags,\n accounts: Account[],\n connections: ConnectionView[],\n publicUrl: string,\n): { account: Account; connection: ConnectionView } {\n const base = publicUrl.replace(/\\/+$/, \"\");\n let connection: ConnectionView | undefined;\n if (flags.connection) {\n connection = connections.find((c) => c.slug === flags.connection);\n if (!connection) throw new SmokeSetupError(`No connection \"${flags.connection}\". There are: ${connections.map((c) => c.slug).join(\", \") || \"none\"}.`);\n } else {\n const ws = connections.filter((c) => c.preset === WORKSPACE_PRESET);\n if (!ws.length) {\n throw new SmokeSetupError(\n `Google Workspace isn't connected. Install it (${NPX} ext add ${WORKSPACE_PRESET}), then connect it in the console: ${base}/connections`,\n );\n }\n if (ws.length > 1) throw new SmokeSetupError(`There are ${ws.length} Google Workspace connections (${ws.map((c) => c.slug).join(\", \")}): pick one with --connection <slug>.`);\n connection = ws[0]!;\n }\n const fix = `${base}/connections/${connection.id}`;\n if (connection.status !== \"active\") throw new SmokeSetupError(`${connection.name} is ${connection.status.replace(\"_\", \" \")}${connection.statusReason ? ` (${connection.statusReason})` : \"\"}. Fix it in the console: ${fix}`);\n const missing = missingScopes(connection);\n if (missing.length) {\n throw new SmokeSetupError(`${connection.name} is missing Google permissions: ${missing.map((s) => s.split(\"/\").pop()).join(\", \")}. Reconnect it and approve all of them: ${fix}`);\n }\n const bound = boundAccountEmail(connection);\n const want = flags.account ?? bound;\n let account: Account | undefined;\n if (want) {\n account = accounts.find((a) => a.email.toLowerCase() === want.toLowerCase());\n if (!account) throw new SmokeSetupError(`No Gmail account ${want} in xaq. There are: ${accounts.map((a) => a.email).join(\", \") || \"none\"}. Add it in the console: ${base}/accounts`);\n } else {\n if (!accounts.length) throw new SmokeSetupError(`No Gmail account is connected. Add one in the console: ${base}/accounts`);\n if (accounts.length > 1) throw new SmokeSetupError(`There are ${accounts.length} Gmail accounts (${accounts.map((a) => a.email).join(\", \")}): pick one with --account <email>.`);\n account = accounts[0]!;\n }\n if (bound && bound.toLowerCase() !== account.email.toLowerCase()) {\n throw new SmokeSetupError(`${connection.name} is signed in as ${bound}, not ${account.email}: pass --account ${bound}, or pick another connection.`);\n }\n if (account.status !== \"active\") throw new SmokeSetupError(`${account.email} is ${account.status.replace(\"_\", \" \")}. Fix it in the console: ${base}/accounts`);\n return { account, connection };\n}\n\n/** The plan, printed before anything happens. */\nexport function planLines(marker: string, account: string, connection: ConnectionView): string[] {\n return [\n `xaq smoke google-workspace will run as a temporary agent ${marker}, through /mcp:`,\n \"\",\n \"First: earlier smoke runs' agents are deleted and their temp dirs taken out of attachmentDirs; their drafts\",\n \"and Drive folders are listed for you to check.\",\n \"Reads (existing files and mail, read only; prints names, the subject, kinds and sizes, never content):\",\n \" - Drive: search the newest Doc, Sheet and Slides file, list the top of My Drive, get, read and export each\",\n \" - Gmail: ONE email with attachments: list its attachments and extract each one get_attachment shows\",\n \" inline, asking it never to save a copy (anything it can't show inline is skipped)\",\n `Writes (only inside a new Drive folder \"${marker}\" at the top of My Drive; every write is checked first):`,\n \" - Docs: create a doc from markdown, append, find and replace (count checked), comment, read back\",\n \" - Sheets: create a sheet, write a range, append rows, read back\",\n \" - Slides: create a deck from an outline, add a slide, replace text, upload a PNG and insert it (Drive\",\n \" thumbnail path: a private image must be refused), insert a public https image, read back, delete a\",\n \" slide through the approval path\",\n ` - Gmail: ONE draft to ${account} only, with a local file and a scratch-folder file attached; checked, then`,\n \" deleted. Nothing is ever sent.\",\n \"Cleanup, also on failure, Ctrl-C, SIGTERM or SIGHUP: the folder goes to the Drive trash (drive_trash, approved\",\n \"here), the draft is deleted, the agent is deleted, attachmentDirs is restored. Temporary changes until then:\",\n `the agent (mail read and draft on ${account}, ${connection.slug} at \"ask\") and a private temp dir in attachmentDirs.`,\n ];\n}\n\nconst errText = (err: unknown) => (err instanceof Error ? err.message : String(err)).replace(/\\s+/g, \" \").slice(0, 300);\n\n/** Canonical JSON (sorted keys): the approval's stored arguments must be exactly the call the run made. */\nfunction canonical(v: unknown): string {\n if (Array.isArray(v)) return `[${v.map(canonical).join(\",\")}]`;\n if (v && typeof v === \"object\") {\n return `{${Object.keys(v as object)\n .sort()\n .map((k) => `${JSON.stringify(k)}:${canonical((v as Record<string, unknown>)[k])}`)\n .join(\",\")}}`;\n }\n return JSON.stringify(v);\n}\n\n/** \"2.5 KB\" (server/mail/content.ts formatSize) → bytes; NaN when it can't be read. */\nfunction sizeOf(text: string): number {\n const m = /^([\\d.]+)\\s*(B|KB|MB|GB)$/i.exec(text.trim());\n if (!m) return Number.NaN;\n const unit = { B: 1, KB: 1024, MB: 1024 ** 2, GB: 1024 ** 3 }[m[2]!.toUpperCase() as \"B\"]!;\n return Math.ceil(Number(m[1]) * unit);\n}\n\n/**\n * Attachments from list_attachments: its structured list (A2: attachmentId, filename, mimeType, size), else the\n * `name (type, size, … attachment_id: x …)` lines.\n */\nexport function parseAttachmentList(out: CallOutcome): ListedAttachment[] {\n const s = out.structured?.attachments;\n if (Array.isArray(s)) {\n return s\n .map((a: Record<string, unknown>) => ({\n id: String(a.attachmentId ?? a.attachment_id ?? a.id ?? \"\"),\n filename: String(a.filename ?? a.name ?? \"\"),\n mimeType: String(a.mimeType ?? a.mime_type ?? \"\"),\n size: typeof a.size === \"number\" ? a.size : Number.NaN,\n }))\n .filter((a) => a.id);\n }\n const found: ListedAttachment[] = [];\n for (const segment of out.text.split(/;|\\n/)) {\n // \"name (type, size, attachment_id: X)\" (get_message) or \"- name (type, size) · message_id: … · attachment_id: X\" (A2).\n const m = /^\\s*(?:Attachments:\\s*)?(?:[-*]|\\d+\\.)?\\s*(.+?) \\(([^,()]+), ([^,()]+?)(?:,[^()]*?)?(?:\\)[^()]*?)?attachment_id: ([^)\\s;·]+)/.exec(segment);\n if (m) found.push({ filename: m[1]!.trim(), mimeType: m[2]!.trim(), size: sizeOf(m[3]!), id: m[4]! });\n }\n return found;\n}\n\n/** What get_attachment returned, as the report may say it: a kind and a size, never the content. */\nexport function describeExtraction(out: CallOutcome): string {\n const blocks = out.content;\n const image = blocks.find((b) => b.type === \"image\");\n if (image) return `image, ${image.data?.length ?? 0} chars (base64)`;\n const res = blocks.find((b) => b.type === \"resource\");\n if (res?.resource?.blob !== undefined) return `binary, ${res.resource.blob.length} chars (base64)`;\n // Text: the first line is the header (\"Attachment <name> (<type>, <size>) …\"); the rest is the content.\n const text = blocks.filter((b) => b.type === \"text\").map((b) => b.text ?? \"\");\n const body = text.join(\"\\n\").split(\"\\n\").slice(1).join(\"\\n\");\n return `text, ${body.length} chars`;\n}\n\n/**\n * Parse failures that are the file's own doing: the smoke passes them as \"couldn't read (…)\". Every other one (corrupt,\n * a parser that's missing, crashed, timed out, busy, …) may be xaq's fault, and this run is what would notice.\n */\nexport const FILE_OWN_PARSE_FAILURES: ReadonlySet<string> = new Set([\"password\", \"encrypted\"]);\n\n/**\n * A format \"inline\" answer that didn't show the file (structuredContent.attachment.notShown): its code, the parser's\n * failure code when it couldn't read it, and the reason without a closing period. The reason is xaq's own words (the\n * parser's fixed messages), never the file's content, unless the parser child is subverted (it's cleaned anyway).\n */\nexport function notShownOf(out: CallOutcome): { code: string; parseFailure: string | null; reason: string } | null {\n const a = out.structured?.attachment as { notShown?: unknown; parseFailure?: unknown; reason?: unknown } | undefined;\n if (!a || typeof a.notShown !== \"string\" || !a.notShown) return null;\n const reason = typeof a.reason === \"string\" ? cleanLine(a.reason, 200).replace(/\\.$/, \"\") : \"\";\n const parseFailure = typeof a.parseFailure === \"string\" && a.parseFailure ? cleanLine(a.parseFailure, 40) : null;\n return { code: cleanLine(a.notShown, 40), parseFailure, reason: reason || \"no reason given\" };\n}\n\n/** A get_attachment answer that saved the file to disk (A2: structuredContent.attachment.savedPath). */\nexport function savedPathOf(out: CallOutcome): string | null {\n const a = out.structured?.attachment as { savedPath?: unknown } | undefined;\n return a && typeof a.savedPath === \"string\" && a.savedPath ? a.savedPath : null;\n}\n\n/**\n * The run's private directory for the draft's local file: `<root>/xaq-smoke`, mode 0700, a real directory this user\n * owns (never a symlink, never the shared /tmp). Created when missing; its mode is reset when it exists.\n */\nexport function privateSmokeDir(root?: string): string {\n const base = root ?? (process.env.XDG_CACHE_HOME?.startsWith(\"/\") ? process.env.XDG_CACHE_HOME : join(homedir(), \".cache\"));\n const dir = join(base, \"xaq-smoke\");\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n const st = lstatSync(dir);\n if (!st.isDirectory() || st.isSymbolicLink()) throw new Error(`${dir} isn't a plain directory; remove it and run again.`);\n if (typeof process.getuid === \"function\" && st.uid !== process.getuid()) throw new Error(`${dir} belongs to another user; remove it and run again.`);\n chmodSync(dir, 0o700);\n return dir;\n}\n\n/** Waits for `p` at most `ms`; the timeout wins silently. */\nconst within = <T>(p: Promise<T>, ms: number): Promise<T | undefined> =>\n Promise.race([\n p,\n new Promise<undefined>((r) => {\n setTimeout(() => r(undefined), ms).unref?.();\n }),\n ]);\n\nexport class SmokeRun {\n readonly marker: string;\n readonly ledger: Ledger;\n private readonly steps: StepResult[] = [];\n private readonly leftBehind: string[] = [];\n /** Earlier runs' leftovers the owner should check (not this run's: they don't fail it). */\n private readonly earlier: string[] = [];\n private readonly guard: ScratchGuard;\n private mcp: AgentMcp | null = null;\n private account: Account | null = null;\n private connection: ConnectionView | null = null;\n private previousDirs: string[] | null = null;\n private dirsChanged = false;\n private agentDeleted = false;\n private cleaning = false;\n private interrupted = false;\n private readonly stamp: string;\n\n constructor(\n private readonly flags: SmokeFlags,\n private readonly deps: SmokeDeps,\n ) {\n this.marker = smokeName((deps.now ?? (() => new Date()))());\n this.stamp = this.marker.slice(\"xaq-smoke-\".length);\n this.ledger = newLedger(this.marker);\n this.guard = new ScratchGuard(this.ledger, (id) => this.driveFacts(id));\n }\n\n // ───────────── Plumbing ─────────────\n\n /** Printing never stops the run (or its cleanup): a closed terminal (EIO, EPIPE) is ignored. */\n private print(line = \"\"): void {\n try {\n this.deps.print(line);\n } catch {\n // The terminal went away; the report is still returned.\n }\n }\n\n private record(tool: string, step: string, status: StepResult[\"status\"], detail: string): void {\n this.steps.push({ tool, step, status, detail });\n this.print(` ${status.padEnd(4)} ${tool} · ${step}${detail ? ` · ${detail}` : \"\"}`);\n }\n\n /** Runs one step; a thrown Skip is SKIP, anything else FAIL. Returns whether it passed. */\n private async step(tool: string, step: string, fn: () => Promise<string>): Promise<boolean> {\n if (!this.cleaning && this.deps.signal.aborted) {\n this.interrupted = true;\n return false;\n }\n try {\n this.record(tool, step, \"PASS\", await fn());\n return true;\n } catch (err) {\n if (err instanceof Interrupted) {\n this.interrupted = true;\n this.record(tool, step, \"SKIP\", \"interrupted (Ctrl-C)\");\n } else if (err instanceof Skip) this.record(tool, step, \"SKIP\", err.message);\n else this.record(tool, step, \"FAIL\", errText(err));\n return false;\n }\n }\n\n private need<T>(value: T | null | undefined, what: string): T {\n if (value === null || value === undefined) throw new Skip(`needs ${what}, which an earlier step didn't produce`);\n return value;\n }\n\n /** `force`: bookkeeping reads (drive_get for the guards and the ledger) still run after Ctrl-C. */\n private async rawCall(name: string, args: Record<string, unknown>, force = false): Promise<CallOutcome> {\n if (!force && !this.cleaning && this.deps.signal.aborted) throw new Interrupted();\n if (!this.mcp) throw new Skip(\"no MCP session (the temporary agent wasn't created)\");\n return this.mcp.call(name, args);\n }\n\n private exposed(tool: string): string {\n return `${this.connection!.slug}__${tool}`;\n }\n\n /**\n * A Workspace tool call. Reads go straight through; writes are checked by the guard first. A write that comes back\n * pending is approved here (its own call only); `approved` says which approval ran it.\n */\n private async ws(tool: string, args: Record<string, unknown>, force = false): Promise<{ out: CallOutcome; approved: string | null }> {\n const write = tool in WRITE_TARGETS;\n if (write) await this.guard.checkWrite(tool, args);\n else if (!READ_TOOLS.has(tool)) throw new GuardError(`${tool} isn't one of the calls the smoke run makes`);\n const out = await this.rawCall(this.exposed(tool), args, force && !write);\n const pending = /^pending_approval:/.test(out.text) ? /approval_id: (apr_[A-Za-z0-9_-]+)/.exec(out.text)?.[1] : undefined;\n if (pending) {\n if (!write) throw new Error(`${tool} is a read, but it came back pending approval`);\n return { out: await this.approveOwn(pending, tool, args), approved: pending };\n }\n if (out.isError) throw new Error(`${tool}: ${out.text}`);\n return { out, approved: null };\n }\n\n private async read(tool: string, args: Record<string, unknown>, force = false): Promise<CallOutcome> {\n return (await this.ws(tool, args, force)).out;\n }\n\n /** Approves a pending call after checking it is exactly this run's: its agent, connection, tool and arguments. */\n private async approveOwn(approvalId: string, tool: string, args: Record<string, unknown>): Promise<CallOutcome> {\n const view = await this.deps.admin.request<McpCallApprovalView>(\"GET\", `/api/approvals/${encodeURIComponent(approvalId)}`);\n const mine =\n view.approval.agentId === this.ledger.agent?.id &&\n view.connection?.id === this.connection?.id &&\n view.tool?.name === tool &&\n view.argsIntact &&\n canonical(JSON.parse(view.argsDisplay)) === canonical(args);\n if (!mine) throw new GuardError(`approval ${approvalId} isn't exactly this run's ${tool} call, so it wasn't approved`);\n await this.deps.admin.request(\"POST\", `/api/approvals/${encodeURIComponent(approvalId)}/approve`, { note: `${this.marker}: approved by xaq smoke` });\n this.ledger.approvals.push(approvalId);\n for (let i = 0; ; i++) {\n const status = await this.rawCall(\"get_call_status\", { approval_id: approvalId });\n if (/^running:/.test(status.text) && i < 60) {\n await new Promise((r) => setTimeout(r, this.deps.pollMs ?? 1000));\n continue;\n }\n if (status.isError || !/^done:/.test(status.text)) throw new Error(`${tool} after approval: ${status.text}`);\n return status;\n }\n }\n\n /** drive_get, as the guards and the leftover check read it. */\n private async driveFacts(fileId: string): Promise<DriveFacts> {\n const out = await this.read(\"drive_get\", { fileId }, true);\n const s = out.structured;\n if (!s || typeof s.id !== \"string\") throw new GuardError(`drive_get gave no details for ${fileId}`);\n return { id: s.id, name: typeof s.name === \"string\" ? s.name : \"\", parents: Array.isArray(s.parents) ? s.parents.map(String) : [], trashed: s.trashed === true };\n }\n\n /** A file a create call made: recorded in the ledger once drive_get says it's in the scratch folder. */\n private async recordCreated(kind: string, id: unknown, name: string): Promise<string> {\n if (typeof id !== \"string\" || !id) throw new Error(`the ${kind} create call returned no id`);\n const folder = this.ledger.folder!;\n const f = await this.driveFacts(id);\n if (!f.parents.includes(folder.id)) {\n // Its real name (it may be an existing file the extension answered with by mistake).\n this.ledger.strays.set(id, { kind, name: f.name || name });\n throw new GuardError(`the new ${kind} ${id} isn't in the scratch folder, so nothing more is written to it`);\n }\n this.ledger.files.set(id, { kind, name });\n return id;\n }\n\n // ───────────── The run ─────────────\n\n async run(): Promise<SmokeReport> {\n if (!this.flags.scratch) {\n throw new SmokeSetupError(\n \"smoke google-workspace runs live on the connected Google account. It only reads existing files and mail, and writes only into a new scratch folder and ONE draft to the account itself, which it removes again. Pass --scratch to run it.\",\n );\n }\n const settings = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n if (settings.brokerUpstreams !== true) throw new SmokeSetupError(`Connections are turned off in this xaq. Turn them on in the console: ${settings.publicUrl.replace(/\\/+$/, \"\")}/settings`);\n if (!Array.isArray(settings.attachmentDirs)) {\n throw new SmokeSetupError(\"This xaq has no attachmentDirs setting, which the draft's local attachment needs. Update xaq, then run this again.\");\n }\n const accounts = await this.deps.admin.request<Account[]>(\"GET\", \"/api/accounts\");\n const connections = await this.deps.admin.request<ConnectionView[]>(\"GET\", \"/api/connections\");\n const { account, connection } = chooseTargets(this.flags, accounts, connections, settings.publicUrl);\n this.account = account;\n this.connection = connection;\n\n for (const l of planLines(this.marker, account.email, connection)) this.print(l);\n this.print();\n if (!(await this.deps.confirm(\"Run it?\"))) throw new SmokeSetupError(\"Nothing was done.\");\n\n this.print();\n try {\n await this.main();\n } finally {\n this.cleaning = true;\n await this.cleanup();\n }\n if (this.deps.signal.aborted) this.interrupted = true;\n return finish({\n marker: this.marker,\n account: account.email,\n connection: connection.slug,\n steps: this.steps,\n leftBehind: this.leftBehind,\n earlier: this.earlier,\n interrupted: this.interrupted,\n });\n }\n\n private async main(): Promise<void> {\n const account = this.account!;\n const connection = this.connection!;\n await this.sweep();\n const created = await this.step(\"xaq\", \"create the temporary agent\", async () => {\n const r = await this.deps.admin.request<AgentWithKey>(\"POST\", \"/api/smoke/agents\", { name: this.marker, accountId: account.id, connectionId: connection.id });\n this.ledger.agent = { id: r.agent.id, name: r.agent.name };\n this.mcp = await this.deps.connectMcp(r.apiKey);\n return `${r.agent.name}: ${account.email} read + draft, ${connection.slug} at \"ask\"`;\n });\n if (!created) return;\n const tools = await this.step(\"xaq\", \"tools/list has every tool the run uses\", async () => {\n const listed = new Set(await this.mcp!.listTools());\n const wanted = [...[...READ_TOOLS, ...Object.keys(WRITE_TARGETS)].map((t) => this.exposed(t)), \"get_call_status\", ...MAIL_TOOLS];\n const missing = wanted.filter((t) => !listed.has(t));\n if (missing.length) throw new Error(`missing: ${missing.join(\", \")} (update xaq and the ${WORKSPACE_PRESET} extension)`);\n return `${wanted.length} tools`;\n });\n if (!tools) return;\n await this.earlierFolders();\n\n await this.driveReads();\n await this.mailReads();\n if (!(await this.createFolder())) {\n this.record(\"xaq\", \"writes\", \"SKIP\", \"no scratch folder: nothing was written\");\n return;\n }\n const doc = await this.docs();\n await this.sheets();\n await this.slides();\n await this.draft(doc);\n }\n\n // ───────────── Earlier runs ─────────────\n\n /** Daemon side: earlier runs' agents deleted, their temp dirs out of attachmentDirs, their drafts listed. */\n private async sweep(): Promise<void> {\n await this.step(\"xaq\", \"sweep earlier runs' leftovers\", async () => {\n const s = await this.deps.admin.request<SmokeSweep>(\"POST\", \"/api/smoke/sweep\", {});\n for (const d of s.drafts) this.earlier.push(`An earlier run's (${d.agent}) draft ${d.draftId} is still in ${d.account}: check it in Gmail (Drafts) and delete it.`);\n // Their temp dirs on disk: only ever inside this user's private smoke directory.\n let removed = 0;\n try {\n const mine = privateSmokeDir(this.deps.tmpRoot);\n for (const name of readdirSync(mine)) {\n if (!SMOKE_TEMP_RE.test(name)) continue;\n rmSync(join(mine, name), { recursive: true, force: true });\n removed++;\n }\n } catch {\n // Nothing there, or not ours to remove: the run makes its own later.\n }\n const parts = [\n `${s.deletedAgents.length} agent(s) deleted${s.deletedAgents.length ? ` (${s.deletedAgents.map((a) => a.name).join(\", \")})` : \"\"}`,\n `${s.removedDirs.length} attachmentDirs entr${s.removedDirs.length === 1 ? \"y\" : \"ies\"} removed`,\n `${removed} temp dir(s) removed`,\n `${s.drafts.length} draft(s) to check`,\n ];\n return parts.join(\", \");\n });\n }\n\n /** Earlier runs' scratch folders still out of the trash: listed for the owner (they're not this run's). */\n private async earlierFolders(): Promise<void> {\n await this.step(\"drive_search\", \"earlier runs' scratch folders\", async () => {\n const out = await this.read(\"drive_search\", { name: \"xaq-smoke-\", type: \"folder\", pageSize: 50 });\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string }[];\n const old = files.filter((f) => SMOKE_NAME_RE.test(f.name) && f.name !== this.marker);\n for (const f of old) this.earlier.push(`An earlier run's Drive folder \"${f.name}\" (${f.id}) isn't in the trash: check it and trash it.`);\n return `${old.length} to check`;\n });\n }\n\n // ───────────── Reads ─────────────\n\n private async driveReads(): Promise<void> {\n const picks: { kind: \"doc\" | \"sheet\" | \"slides\"; id: string; name: string }[] = [];\n for (const kind of [\"doc\", \"sheet\", \"slides\"] as const) {\n await this.step(\"drive_search\", `newest ${kind}`, async () => {\n const out = await this.read(\"drive_search\", { type: kind, pageSize: 5 });\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string; modifiedTime?: string; shortcutTo?: unknown }[];\n const real = files.filter((f) => f.id && !f.shortcutTo).sort((a, b) => String(b.modifiedTime ?? \"\").localeCompare(String(a.modifiedTime ?? \"\")));\n if (!real.length) throw new Skip(`no ${kind} files in this Drive`);\n picks.push({ kind, id: real[0]!.id, name: real[0]!.name });\n return `${files.length} found; newest \"${real[0]!.name}\"`;\n });\n }\n await this.step(\"drive_list_folder\", \"top of My Drive\", async () => {\n const out = await this.read(\"drive_list_folder\", { folderId: \"root\", pageSize: 10 });\n const files = Array.isArray(out.structured?.files) ? out.structured.files : [];\n return `${files.length} items`;\n });\n const formats = { doc: \"markdown\", sheet: \"csv\", slides: \"text\" } as const;\n for (const p of picks) {\n await this.step(\"drive_get\", `${p.kind} details`, async () => {\n const f = await this.driveFacts(p.id);\n return `\"${f.name}\"`;\n });\n await this.step(p.kind === \"doc\" ? \"docs_read\" : p.kind === \"sheet\" ? \"sheets_read\" : \"slides_read\", `read the ${p.kind}`, async () => {\n if (p.kind === \"doc\") {\n const out = await this.read(\"docs_read\", { documentId: p.id });\n return `text, ${Number(out.structured?.totalChars ?? out.text.length)} chars`;\n }\n if (p.kind === \"sheet\") {\n const out = await this.read(\"sheets_read\", { spreadsheetId: p.id, range: \"A1:Z50\" });\n const rows = Array.isArray(out.structured?.rows) ? out.structured.rows.length : 0;\n return `${rows} rows, ${out.text.length} chars`;\n }\n const out = await this.read(\"slides_read\", { presentationId: p.id });\n return `${Number(out.structured?.slideCount ?? 0)} slides, ${out.text.length} chars`;\n });\n await this.step(\"drive_export\", `export the ${p.kind} as ${formats[p.kind]}`, async () => {\n const out = await this.read(\"drive_export\", { fileId: p.id, format: formats[p.kind] });\n return `${formats[p.kind]}, ${Number(out.structured?.totalChars ?? out.text.length)} chars`;\n });\n }\n }\n\n private async mailReads(): Promise<void> {\n const account = this.account!.email;\n let threadIds: string[] = [];\n let message: { id: string; subject: string } | null = null;\n await this.step(\"search_threads\", \"find an email with attachments\", async () => {\n const out = await this.rawCall(\"search_threads\", { account, query: \"has:attachment -in:drafts -in:chats\", max_results: 5 });\n if (out.isError) throw new Error(out.text);\n threadIds = [...out.text.matchAll(/^\\s+thread_id: (\\S+)/gm)].map((m) => m[1]!);\n if (!threadIds.length) throw new Skip(\"no email with attachments in this mailbox\");\n return `${threadIds.length} threads`;\n });\n await this.step(\"get_thread\", \"pick ONE message with attachments\", async () => {\n const threadId = this.need(threadIds[0], \"a thread\");\n const out = await this.rawCall(\"get_thread\", { account, thread_id: threadId });\n if (out.isError) throw new Error(out.text);\n const ids = [...out.text.matchAll(/^Message (\\S+) \\(thread /gm)].map((m) => m[1]!);\n for (const id of ids.slice(0, 5)) {\n const m = await this.rawCall(\"get_message\", { account, message_id: id });\n if (m.isError) continue;\n const head = m.text.split(/<email_content /)[0] ?? m.text;\n if (/^Attachments: /m.test(head)) {\n message = { id, subject: /^Subject: (.*)$/m.exec(head)?.[1]?.trim() ?? \"(no subject)\" };\n return `subject \"${message.subject}\"`;\n }\n }\n throw new Skip(\"the thread's messages have no attachments\");\n });\n let attachments: ListedAttachment[] = [];\n await this.step(\"list_attachments\", \"list its attachments\", async () => {\n const m = this.need(message as { id: string; subject: string } | null, \"a message with attachments\");\n const out = await this.rawCall(\"list_attachments\", { account, message_id: m.id });\n if (out.isError) throw new Error(out.text);\n attachments = parseAttachmentList(out);\n if (!attachments.length) throw new Error(\"listed no attachments\");\n return attachments.map((a) => `\"${a.filename}\"`).join(\", \");\n });\n for (const a of attachments.slice(0, 10)) {\n await this.step(\"get_attachment\", `extract \"${a.filename}\"`, async () => {\n // format \"inline\" never saves (a copy of the owner's file on this machine, under a quota that may delete\n // older saved files). What it can't show isn't even downloaded: inlineKind skips it from the listing.\n const kind = inlineKind(a);\n if (!kind) return SKIPPED_NOT_INLINE;\n const m = message as { id: string; subject: string } | null;\n const out = await this.rawCall(\"get_attachment\", { account, message_id: m!.id, attachment_id: a.id, format: \"inline\" });\n const saved = savedPathOf(out);\n if (saved) {\n this.leftBehind.push(`A copy of the email attachment \"${a.filename}\" was saved at ${saved}: delete it.`);\n throw new Error(`get_attachment saved \"${a.filename}\" to disk (${saved}) instead of showing it`);\n }\n if (out.isError) throw new Error(out.text);\n const not = notShownOf(out);\n if (not?.code === \"unreadable\") {\n // A password-protected or encrypted file: xaq answered correctly and saved nothing. Anything else (a corrupt\n // file, or the parser missing, crashing, timing out) fails: this run is the only check that would see it.\n if (not.parseFailure && FILE_OWN_PARSE_FAILURES.has(not.parseFailure)) return `${kind}: couldn't read (${not.reason})`;\n throw new Error(`get_attachment couldn't read \"${a.filename}\" (${not.parseFailure ?? \"no failure code\"}: ${not.reason})`);\n }\n if (not) return `${kind}: not shown inline (${not.reason})`;\n return `${kind}: ${describeExtraction(out)}`;\n });\n }\n }\n\n // ───────────── Writes ─────────────\n\n private async createFolder(): Promise<boolean> {\n return this.step(\"drive_create_folder\", `create the scratch folder ${this.marker}`, async () => {\n const { out } = await this.ws(\"drive_create_folder\", { name: this.marker });\n const id = out.structured?.folderId;\n if (typeof id !== \"string\" || !id) throw new Error(\"drive_create_folder returned no folder id\");\n // Recorded at once: from here on cleanup trashes it.\n this.ledger.folder = { id, name: this.marker };\n const f = await this.driveFacts(id);\n if (f.name !== this.marker || f.trashed) {\n this.ledger.folder = null;\n this.leftBehind.push(`Drive item ${id}: drive_create_folder returned it, but it isn't a live folder named ${this.marker}. Check Drive.`);\n throw new Error(`folder ${id} isn't the scratch folder`);\n }\n return `folder ${id}`;\n });\n }\n\n private async docs(): Promise<string | null> {\n let doc: string | null = null;\n const title = `${this.marker} doc`;\n const old = `REPLACE-ME-${this.stamp}`;\n const fresh = `REPLACED-${this.stamp}`;\n await this.step(\"docs_create\", \"create a doc from markdown in the folder\", async () => {\n const markdown = `# ${this.marker}\\n\\nDOC-MARKER-A, written by xaq smoke.\\n\\n- ${old}\\n- ${old}\\n`;\n const { out } = await this.ws(\"docs_create\", { title, markdown, folderId: this.ledger.folder!.id });\n doc = await this.recordCreated(\"doc\", out.structured?.documentId, title);\n return `doc ${doc}`;\n });\n await this.step(\"docs_append\", \"append\", async () => {\n await this.ws(\"docs_append\", { documentId: this.need(doc, \"the doc\"), markdown: \"DOC-MARKER-B, appended by xaq smoke.\" });\n return \"appended\";\n });\n await this.step(\"docs_replace_text\", \"find and replace (2 matches)\", async () => {\n const { out } = await this.ws(\"docs_replace_text\", { documentId: this.need(doc, \"the doc\"), find: old, replace: fresh });\n const n = Number(out.structured?.occurrencesChanged);\n if (n !== 2) throw new Error(`changed ${n} occurrences, expected 2`);\n return \"2 occurrences changed\";\n });\n let comment: string | null = null;\n await this.step(\"docs_comment_add\", \"add a comment\", async () => {\n const { out } = await this.ws(\"docs_comment_add\", { documentId: this.need(doc, \"the doc\"), text: `${this.marker}: a comment from xaq smoke` });\n comment = typeof out.structured?.commentId === \"string\" ? out.structured.commentId : null;\n if (!comment) throw new Error(\"no comment id returned\");\n return `comment ${comment}`;\n });\n await this.step(\"docs_read\", \"read back: markers, replacements\", async () => {\n const out = await this.read(\"docs_read\", { documentId: this.need(doc, \"the doc\") });\n const t = out.text;\n const problems = [\n !t.includes(\"DOC-MARKER-A\") && \"the created text\",\n !t.includes(\"DOC-MARKER-B\") && \"the appended text\",\n t.split(fresh).length - 1 !== 2 && \"2 replacements\",\n t.includes(old) && \"no text left to replace\",\n ].filter(Boolean);\n if (problems.length) throw new Error(`missing: ${problems.join(\", \")}`);\n return \"all markers present\";\n });\n await this.step(\"docs_comments_list\", \"the comment is there\", async () => {\n const out = await this.read(\"docs_comments_list\", { documentId: this.need(doc, \"the doc\") });\n const list = (Array.isArray(out.structured?.comments) ? out.structured.comments : []) as { id?: string }[];\n if (!list.some((c) => c.id === this.need(comment, \"the comment\"))) throw new Error(\"the comment isn't listed\");\n return `${list.length} comment(s)`;\n });\n return doc;\n }\n\n private async sheets(): Promise<void> {\n let sheet: string | null = null;\n const title = `${this.marker} sheet`;\n const written = [\n [\"name\", \"kind\", \"marker\"],\n [\"alpha\", \"write\", this.stamp],\n ];\n const appended = [\n [\"beta\", \"append\", this.stamp],\n [\"gamma\", \"append\", this.stamp],\n ];\n await this.step(\"sheets_create\", \"create a sheet in the folder\", async () => {\n const { out } = await this.ws(\"sheets_create\", { title, folderId: this.ledger.folder!.id });\n sheet = await this.recordCreated(\"sheet\", out.structured?.spreadsheetId, title);\n return `sheet ${sheet}`;\n });\n await this.step(\"sheets_write\", \"write A1:C2\", async () => {\n const { out } = await this.ws(\"sheets_write\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A1:C2\", values: written, input: \"RAW\" });\n if (Number(out.structured?.updatedCells) !== 6) throw new Error(`updated ${String(out.structured?.updatedCells)} cells, expected 6`);\n return \"6 cells\";\n });\n await this.step(\"sheets_append_rows\", \"append 2 rows\", async () => {\n const { out } = await this.ws(\"sheets_append_rows\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A:C\", rows: appended, input: \"RAW\" });\n if (Number(out.structured?.updatedRows) !== 2) throw new Error(`appended ${String(out.structured?.updatedRows)} rows, expected 2`);\n return \"2 rows\";\n });\n await this.step(\"sheets_read\", \"read back and compare\", async () => {\n const out = await this.read(\"sheets_read\", { spreadsheetId: this.need(sheet, \"the sheet\"), range: \"A1:C4\" });\n const rows = out.structured?.rows;\n if (canonical(rows) !== canonical([...written, ...appended])) throw new Error(\"the cells differ from what was written\");\n return \"4 rows match\";\n });\n }\n\n private async slides(): Promise<void> {\n let deck: string | null = null;\n let first: string | null = null;\n let extra: string | null = null;\n let png: string | null = null;\n const title = `${this.marker} deck`;\n const old = `SLIDE-MARKER-${this.stamp}`;\n const fresh = `SLIDE-REPLACED-${this.stamp}`;\n await this.step(\"slides_create\", \"create a deck from an outline in the folder\", async () => {\n const { out } = await this.ws(\"slides_create\", {\n title,\n slides: [\n { title: \"Smoke one\", bullets: [old] },\n { title: \"Smoke two\", bullets: [old] },\n ],\n folderId: this.ledger.folder!.id,\n });\n deck = await this.recordCreated(\"deck\", out.structured?.presentationId, title);\n const made = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; title?: string }[];\n first = made.find((s) => s.title === \"Smoke one\")?.slideId ?? null;\n return `deck ${deck}, ${made.length} slides`;\n });\n await this.step(\"slides_add_slide\", \"add a slide\", async () => {\n const { out } = await this.ws(\"slides_add_slide\", { presentationId: this.need(deck, \"the deck\"), title: \"Smoke: deleted through approval\", bullets: [\"xaq smoke deletes this slide\"] });\n extra = typeof out.structured?.slideId === \"string\" ? out.structured.slideId : null;\n if (!extra) throw new Error(\"no slide id returned\");\n return `slide ${extra}`;\n });\n await this.step(\"slides_replace_text\", \"replace text (2 matches)\", async () => {\n const { out } = await this.ws(\"slides_replace_text\", { presentationId: this.need(deck, \"the deck\"), find: old, replace: fresh });\n const n = Number(out.structured?.occurrencesChanged);\n if (n !== 2) throw new Error(`changed ${n} occurrences, expected 2`);\n return \"2 occurrences changed\";\n });\n await this.step(\"drive_upload\", \"upload a PNG into the folder\", async () => {\n const name = `${this.marker}.png`;\n const { out } = await this.ws(\"drive_upload\", { name, folderId: this.ledger.folder!.id, mimeType: \"image/png\", content_base64: solidPng().toString(\"base64\") });\n png = await this.recordCreated(\"image\", out.structured?.fileId, name);\n return `image ${png}`;\n });\n // Slides fetches a Drive image without credentials, so only an image shared \"anyone with the link\" works, and\n // the extension never changes sharing. The run's own PNG is private: the tool must refuse it and leave the deck\n // as it was. An insert would mean the file got shared somehow, which is a failure.\n const imagesOnFirst = async () => {\n const out = await this.read(\"slides_read\", { presentationId: deck! });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; images?: number }[];\n return slides.find((s) => s.slideId === first)?.images ?? 0;\n };\n await this.step(\"slides_insert_image\", \"Drive image (private)\", async () => {\n const args = { presentationId: this.need(deck, \"the deck\"), slideId: this.need(first, \"the first slide\"), driveFileId: this.need(png, \"the PNG\") };\n const before = await imagesOnFirst();\n let refusal: string | null = null;\n try {\n await this.ws(\"slides_insert_image\", args);\n } catch (err) {\n if (err instanceof GuardError || err instanceof Interrupted) throw err;\n refusal = errText(err);\n }\n if (refusal === null) throw new Error(\"inserted a private Drive image: check the PNG's sharing in Drive\");\n if (!/shared publicly/i.test(refusal)) throw new Error(refusal);\n if ((await imagesOnFirst()) !== before) throw new Error(\"refused, but the deck changed\");\n return \"refused as expected\";\n });\n await this.step(\"slides_insert_image\", \"insert a public https image\", async () => {\n const { out } = await this.ws(\"slides_insert_image\", { presentationId: this.need(deck, \"the deck\"), slideId: this.need(first, \"the first slide\"), imageUrl: this.deps.imageUrl ?? PUBLIC_IMAGE_URL });\n return `image ${String(out.structured?.imageId ?? \"?\")}`;\n });\n await this.step(\"slides_read\", \"read back: text replaced, the image there\", async () => {\n const out = await this.read(\"slides_read\", { presentationId: this.need(deck, \"the deck\") });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string; images?: number }[];\n const problems = [\n out.text.split(fresh).length - 1 !== 2 && \"2 replacements\",\n out.text.includes(old) && \"no text left to replace\",\n (slides.find((s) => s.slideId === first)?.images ?? 0) !== 1 && \"the public image on the first slide\",\n !slides.some((s) => s.slideId === extra) && \"the added slide\",\n ].filter(Boolean);\n if (problems.length) throw new Error(`missing: ${problems.join(\", \")}`);\n return `${slides.length} slides`;\n });\n await this.step(\"slides_delete_slide\", \"delete a slide through the approval path\", async () => {\n const slideId = this.need(extra, \"the added slide\");\n const { approved } = await this.ws(\"slides_delete_slide\", { presentationId: this.need(deck, \"the deck\"), slideId });\n if (!approved) throw new Error(\"the call wasn't held for approval (the connection should be at \\\"ask\\\")\");\n const out = await this.read(\"slides_read\", { presentationId: deck! });\n const slides = (Array.isArray(out.structured?.slides) ? out.structured.slides : []) as { slideId?: string }[];\n if (slides.some((s) => s.slideId === slideId)) throw new Error(\"approved, but the slide is still there\");\n return `pending, approved (${approved}), gone`;\n });\n }\n\n private async draft(doc: string | null): Promise<void> {\n const own = this.account!.email;\n let local: { path: string; size: number } | null = null;\n let draftId: string | null = null;\n await this.step(\"xaq\", \"allow a private temp dir in attachmentDirs\", async () => {\n const dir = mkdtempSync(join(privateSmokeDir(this.deps.tmpRoot), `${this.marker}-`));\n this.ledger.tempDir = dir;\n const path = join(dir, `${this.marker}.txt`);\n const bytes = Buffer.from(`${this.marker}\\nA local file attached by xaq smoke google-workspace.\\n${\"0123456789abcdef\".repeat(64)}\\n`);\n writeFileSync(path, bytes, { mode: 0o600 });\n local = { path, size: bytes.length };\n const settings = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n this.previousDirs = [...(settings.attachmentDirs ?? [])];\n await this.deps.admin.request(\"PATCH\", \"/api/settings\", { attachmentDirs: [...this.previousDirs, dir] });\n this.dirsChanged = true;\n return `${basename(path)} (${bytes.length} bytes)`;\n });\n const subject = `${smokeSubjectPrefix(this.marker)} attachments check, never sent`;\n await this.step(\"create_draft\", `ONE draft to ${own}, 2 attachments`, async () => {\n const file = this.need(local as { path: string; size: number } | null, \"the local file\");\n const args = {\n account: own,\n to: [own],\n subject,\n body: \"Created by `xaq smoke google-workspace`, which deletes this draft again. Nothing is sent.\",\n attachments: [{ path: file.path }, { drive_file_id: this.need(doc, \"the scratch doc\"), export_as: \"pdf\" }],\n };\n await this.guard.checkDraft(args, own);\n const out = await this.rawCall(\"create_draft\", args);\n if (out.isError) throw new Error(out.text);\n const r = JSON.parse(out.text) as { status?: string; draftId?: string };\n if (r.status !== \"draft_created\" || !r.draftId) throw new Error(`expected a draft, got ${r.status ?? \"nothing\"}`);\n draftId = r.draftId;\n this.ledger.drafts.set(r.draftId, { deleted: false });\n return `draft ${r.draftId}`;\n });\n await this.step(\"xaq\", \"check the draft: recipient, 2 attachments, names, sizes\", async () => {\n const id = this.need(draftId, \"the draft\");\n const file = local as { path: string; size: number } | null;\n const v = await this.deps.admin.request<SmokeDraftView>(\"POST\", \"/api/smoke/drafts/inspect\", this.draftInput(id));\n if (v.recipients.length !== 1 || v.recipients[0] !== own.toLowerCase()) throw new Error(`recipients ${v.recipients.join(\", \")}, expected only ${own}`);\n if (v.attachments.length !== 2) throw new Error(`${v.attachments.length} attachments, expected 2`);\n const name = basename(file!.path);\n const a = v.attachments.find((x) => x.filename === name);\n if (!a || a.size !== file!.size) throw new Error(`the local file ${name} isn't attached at ${file!.size} bytes`);\n const docTitle = this.ledger.files.get(doc!)?.name ?? \"\";\n const d = v.attachments.find((x) => x !== a);\n if (!d || !d.filename.startsWith(docTitle) || d.size <= 0) throw new Error(`the scratch doc \"${docTitle}\" isn't attached`);\n return `\"${a.filename}\" ${a.size} B, \"${d.filename}\" ${d.size} B`;\n });\n await this.step(\"xaq\", \"delete the draft\", async () => {\n await this.deleteDraft(this.need(draftId, \"the draft\"));\n return \"deleted\";\n });\n }\n\n private draftInput(draftId: string) {\n return { agentId: this.ledger.agent!.id, accountId: this.account!.id, draftId, ledger: [...this.ledger.drafts.keys()] };\n }\n\n private async deleteDraft(id: string): Promise<void> {\n await this.deps.admin.request(\"POST\", \"/api/smoke/drafts/delete\", this.draftInput(id));\n this.ledger.drafts.set(id, { deleted: true });\n }\n\n // ───────────── Cleanup and the leftover check ─────────────\n\n private async deleteAgent(): Promise<void> {\n const agent = this.ledger.agent;\n if (!agent || this.agentDeleted) return;\n await this.deps.admin.request(\"DELETE\", `/api/agents/${encodeURIComponent(agent.id)}`);\n this.agentDeleted = true;\n }\n\n private async restoreDirs(): Promise<void> {\n if (!this.dirsChanged || !this.previousDirs) return;\n await this.deps.admin.request(\"PATCH\", \"/api/settings\", { attachmentDirs: this.previousDirs });\n this.dirsChanged = false;\n }\n\n private removeTempDir(): void {\n if (this.ledger.tempDir) rmSync(this.ledger.tempDir, { recursive: true, force: true });\n }\n\n /**\n * The second Ctrl-C: only what matters most and is quick (the agent's key stops working, attachmentDirs is back,\n * the temp file goes), each bounded by `timeoutMs`. The Drive folder and a draft stay; the caller lists them.\n */\n async fastCleanup(timeoutMs = 3000): Promise<void> {\n await within(\n this.deleteAgent().catch(() => {}),\n timeoutMs,\n );\n await within(\n this.restoreDirs().catch(() => {}),\n timeoutMs,\n );\n try {\n this.removeTempDir();\n } catch {\n // Listed by the caller.\n }\n }\n\n /** What may still be there right now (the second Ctrl-C prints it). */\n pendingLeftovers(): string[] {\n const l = this.ledger;\n return [\n l.agent && !this.agentDeleted ? `the agent ${l.agent.name}` : null,\n l.folder ? `the Drive folder ${l.folder.name} (${l.folder.id})` : null,\n ...[...l.drafts].filter(([, d]) => !d.deleted).map(([id]) => `the draft ${id}`),\n this.dirsChanged && l.tempDir ? `attachmentDirs still lists ${l.tempDir}` : null,\n l.tempDir && existsSync(l.tempDir) ? `the temp dir ${l.tempDir}` : null,\n ].filter((x): x is string => !!x);\n }\n\n private async cleanup(): Promise<void> {\n if (this.deps.signal.aborted) this.print(\"Interrupted: cleaning up (this takes a moment)…\");\n const agent = this.ledger.agent;\n for (const [id, d] of this.ledger.drafts) {\n if (d.deleted) continue;\n await this.step(\"xaq\", \"cleanup: delete the draft\", async () => {\n await this.deleteDraft(id);\n return `draft ${id}`;\n });\n }\n const folder = this.ledger.folder;\n const reported = new Set<string>();\n if (folder) {\n await this.step(\"drive_trash\", \"cleanup: trash the scratch folder through the approval path\", async () => {\n const { approved } = await this.ws(\"drive_trash\", { fileId: folder.id });\n if (!approved) throw new Error(\"the call wasn't held for approval (the connection should be at \\\"ask\\\")\");\n const f = await this.driveFacts(folder.id);\n if (!f.trashed) throw new Error(\"approved, but the folder isn't in the trash\");\n return `pending, approved (${approved}), in the trash`;\n });\n // The leftover check on Drive, while the agent can still look. Drive trashes a folder's children asynchronously:\n // for a while after the folder is in the trash, a file inside it still reads trashed: false. A file whose parent is\n // the scratch folder, once that folder is confirmed in the trash, goes with it.\n let folderTrashed = false;\n for (const [id, f] of [[folder.id, { kind: \"folder\", name: folder.name }] as const, ...this.ledger.files]) {\n reported.add(id);\n try {\n const facts = await this.driveFacts(id);\n if (id === folder.id) folderTrashed = facts.trashed;\n const gone = facts.trashed || (folderTrashed && facts.parents.includes(folder.id));\n if (!gone) this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}) is not in the trash.`);\n } catch (err) {\n this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}): couldn't check it (${errText(err)}).`);\n }\n }\n }\n for (const [id, f] of this.ledger.strays) {\n reported.add(id);\n this.leftBehind.push(`Drive ${f.kind} \"${f.name}\" (${id}) came back from a create call but isn't in the scratch folder. It may be an existing file: check it before removing anything.`);\n }\n // Creates the ledger never recorded (a lost answer): anything carrying the run's name and not in the trash.\n if (this.mcp) {\n try {\n const out = await this.read(\"drive_search\", { name: this.marker, pageSize: 50 }, true);\n const files = (Array.isArray(out.structured?.files) ? out.structured.files : []) as { id: string; name: string; type?: string }[];\n for (const f of files) {\n if (reported.has(f.id)) continue;\n this.leftBehind.push(`Drive ${f.type ?? \"file\"} \"${f.name}\" (${f.id}) carries this run's name and isn't in the trash: check it and trash it.`);\n }\n } catch (err) {\n this.leftBehind.push(`Couldn't search Drive for files named ${this.marker}: ${errText(err)}`);\n }\n }\n\n await this.mcp?.close().catch(() => {});\n this.mcp = null;\n if (agent && !this.agentDeleted) {\n await this.step(\"xaq\", \"cleanup: delete the temporary agent\", async () => {\n await this.deleteAgent();\n return agent.name;\n });\n }\n if (this.dirsChanged && this.previousDirs) {\n await this.step(\"xaq\", \"cleanup: restore attachmentDirs\", async () => {\n await this.restoreDirs();\n return `${this.previousDirs!.length} dir(s), as before`;\n });\n }\n try {\n this.removeTempDir();\n } catch {\n // Reported by the leftover check.\n }\n await this.leftovers();\n }\n\n private async leftovers(): Promise<void> {\n const agent = this.ledger.agent;\n if (this.ledger.tempDir && existsSync(this.ledger.tempDir)) this.leftBehind.push(`The temp dir ${this.ledger.tempDir} still exists.`);\n try {\n if (this.account) {\n // Always asked, also when the agent was never created: other smoke agents are listed either way, and the\n // daemon adds every draft the agent created according to the audit log (one the ledger missed included).\n const l = await this.deps.admin.request<SmokeLeftovers>(\"POST\", \"/api/smoke/leftovers\", {\n agentId: agent?.id ?? null,\n accountId: this.account.id,\n draftIds: [...this.ledger.drafts.keys()],\n });\n if (agent && l.agent) this.leftBehind.push(`The temporary agent ${agent.name} (${agent.id}) still exists: delete it in the console (Agents).`);\n if (l.agentSettings) this.leftBehind.push(`The temporary agent's settings (tool mode) are still stored.`);\n for (const d of l.drafts) this.leftBehind.push(`The draft ${d} still exists in ${this.account.email}: delete it in Gmail (Drafts).`);\n for (const a of l.otherSmokeAgents) this.leftBehind.push(`Another smoke run's agent ${a.name} (${a.id}) exists: delete it in the console (Agents).`);\n }\n if (this.previousDirs) {\n const s = await this.deps.admin.request<SettingsView>(\"GET\", \"/api/settings\");\n if (canonical(s.attachmentDirs ?? []) !== canonical(this.previousDirs)) this.leftBehind.push(`attachmentDirs isn't back to what it was (${this.previousDirs.join(\", \") || \"empty\"}).`);\n }\n } catch (err) {\n this.leftBehind.push(`The leftover check couldn't finish: ${errText(err)}`);\n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CAAC,GAAG,KAAK,OAAO,OAAO,KAAK,CAAC;IACzC,CAAC;IACD,IAAI,SAAS,EAAE,OAAO,KAAK,WAAW,KAAK,uBAAuB,MAAM,KAAK,IAAI,MAAM,GAAG,mDAAmD;IAC7I,IAAI,EAAE,eAAe,KAAK,WAAW,KAAK,8DAA8D;IACxG,KAAK,MAAM,KAAK,EAAE,QAAQ,KAAK,WAAW,KAAK,aAAa,EAAE,mBAAmB,KAAK,QAAQ,MAAM,+BAA+B;IACnI,KAAK,MAAM,KAAK,EAAE,kBAAkB,KAAK,WAAW,KAAK,6BAA6B,EAAE,KAAK,IAAI,EAAE,GAAG,6CAA6C;GACrJ;GACA,IAAI,KAAK,cAEH;QAAA,WAAU,MADE,KAAK,KAAK,MAAM,QAAsB,OAAO,eAAe,EAAA,CAC5D,kBAAkB,CAAC,CAAC,MAAM,UAAU,KAAK,YAAY,GAAG,KAAK,WAAW,KAAK,6CAA6C,KAAK,aAAa,KAAK,IAAI,KAAK,QAAQ,GAAG;GAAA;EAEzL,SAAS,KAAK;GACZ,KAAK,WAAW,KAAK,uCAAuC,QAAQ,GAAG,GAAG;EAC5E;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xaq-cli",
3
- "version": "0.1.0-nightly.93",
3
+ "version": "0.1.0-nightly.94",
4
4
  "description": "Self-hosted Gmail broker for AI agents (formerly agentinbox): one place for credentials, MCP tools, real-time webhooks, guardrails, and a web console.",
5
5
  "license": "MIT",
6
6
  "type": "module",