@rubytech/create-maxy-code 0.1.411 → 0.1.414

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/__tests__/installer-cwd-pin-and-auth-verify.test.js +82 -0
  2. package/dist/index.js +44 -5
  3. package/package.json +1 -1
  4. package/payload/platform/lib/account-scope/dist/index.d.ts +27 -0
  5. package/payload/platform/lib/account-scope/dist/index.d.ts.map +1 -0
  6. package/payload/platform/lib/account-scope/dist/index.js +33 -0
  7. package/payload/platform/lib/account-scope/dist/index.js.map +1 -0
  8. package/payload/platform/lib/account-scope/src/index.ts +43 -0
  9. package/payload/platform/lib/account-scope/tsconfig.json +5 -0
  10. package/payload/platform/package.json +2 -2
  11. package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
  12. package/payload/platform/plugins/admin/hooks/lib/maxy-mcp-plugins.txt +1 -0
  13. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +37 -1
  14. package/payload/platform/plugins/business-assistant/skills/e-sign/SKILL.md +2 -0
  15. package/payload/platform/plugins/docs/references/cross-account-authority.md +25 -0
  16. package/payload/platform/plugins/docs/references/memory-guide.md +6 -0
  17. package/payload/platform/plugins/filesystem/.claude-plugin/plugin.json +21 -0
  18. package/payload/platform/plugins/filesystem/PLUGIN.md +63 -0
  19. package/payload/platform/plugins/filesystem/lib/mcp-spawn-tee/index.js +193 -0
  20. package/payload/platform/plugins/filesystem/lib/mcp-spawn-tee/package.json +3 -0
  21. package/payload/platform/plugins/filesystem/mcp/dist/index.d.ts +2 -0
  22. package/payload/platform/plugins/filesystem/mcp/dist/index.d.ts.map +1 -0
  23. package/payload/platform/plugins/filesystem/mcp/dist/index.js +91 -0
  24. package/payload/platform/plugins/filesystem/mcp/dist/index.js.map +1 -0
  25. package/payload/platform/plugins/filesystem/mcp/dist/lib/__tests__/scope.test.d.ts +2 -0
  26. package/payload/platform/plugins/filesystem/mcp/dist/lib/__tests__/scope.test.d.ts.map +1 -0
  27. package/payload/platform/plugins/filesystem/mcp/dist/lib/__tests__/scope.test.js +89 -0
  28. package/payload/platform/plugins/filesystem/mcp/dist/lib/__tests__/scope.test.js.map +1 -0
  29. package/payload/platform/plugins/filesystem/mcp/dist/lib/result.d.ts +12 -0
  30. package/payload/platform/plugins/filesystem/mcp/dist/lib/result.d.ts.map +1 -0
  31. package/payload/platform/plugins/filesystem/mcp/dist/lib/result.js +6 -0
  32. package/payload/platform/plugins/filesystem/mcp/dist/lib/result.js.map +1 -0
  33. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.d.ts +45 -0
  34. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.d.ts.map +1 -0
  35. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.js +86 -0
  36. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.js.map +1 -0
  37. package/payload/platform/plugins/filesystem/mcp/dist/lib/walk.d.ts +11 -0
  38. package/payload/platform/plugins/filesystem/mcp/dist/lib/walk.d.ts.map +1 -0
  39. package/payload/platform/plugins/filesystem/mcp/dist/lib/walk.js +64 -0
  40. package/payload/platform/plugins/filesystem/mcp/dist/lib/walk.js.map +1 -0
  41. package/payload/platform/plugins/filesystem/mcp/dist/tools/__tests__/handlers.test.d.ts +2 -0
  42. package/payload/platform/plugins/filesystem/mcp/dist/tools/__tests__/handlers.test.d.ts.map +1 -0
  43. package/payload/platform/plugins/filesystem/mcp/dist/tools/__tests__/handlers.test.js +94 -0
  44. package/payload/platform/plugins/filesystem/mcp/dist/tools/__tests__/handlers.test.js.map +1 -0
  45. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-edit.d.ts +8 -0
  46. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-edit.d.ts.map +1 -0
  47. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-edit.js +40 -0
  48. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-edit.js.map +1 -0
  49. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-glob.d.ts +6 -0
  50. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-glob.d.ts.map +1 -0
  51. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-glob.js +13 -0
  52. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-glob.js.map +1 -0
  53. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-grep.d.ts +7 -0
  54. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-grep.d.ts.map +1 -0
  55. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-grep.js +71 -0
  56. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-grep.js.map +1 -0
  57. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-list.d.ts +6 -0
  58. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-list.d.ts.map +1 -0
  59. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-list.js +26 -0
  60. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-list.js.map +1 -0
  61. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-read.d.ts +6 -0
  62. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-read.d.ts.map +1 -0
  63. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-read.js +28 -0
  64. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-read.js.map +1 -0
  65. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-write.d.ts +7 -0
  66. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-write.d.ts.map +1 -0
  67. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-write.js +25 -0
  68. package/payload/platform/plugins/filesystem/mcp/dist/tools/file-write.js.map +1 -0
  69. package/payload/platform/plugins/filesystem/mcp/package.json +21 -0
  70. package/payload/platform/plugins/filesystem/mcp/vitest.config.ts +8 -0
  71. package/payload/platform/plugins/memory/PLUGIN.md +8 -0
  72. package/payload/platform/plugins/memory/mcp/dist/index-testable.d.ts +34 -0
  73. package/payload/platform/plugins/memory/mcp/dist/index-testable.d.ts.map +1 -0
  74. package/payload/platform/plugins/memory/mcp/dist/index-testable.js +60 -0
  75. package/payload/platform/plugins/memory/mcp/dist/index-testable.js.map +1 -0
  76. package/payload/platform/plugins/memory/mcp/dist/index.js +327 -146
  77. package/payload/platform/plugins/memory/mcp/dist/index.js.map +1 -1
  78. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-owner-userid.d.ts +15 -0
  79. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-owner-userid.d.ts.map +1 -0
  80. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-owner-userid.js +29 -0
  81. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-owner-userid.js.map +1 -0
  82. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/cross-account.test.d.ts +2 -0
  83. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/cross-account.test.d.ts.map +1 -0
  84. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/cross-account.test.js +74 -0
  85. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/cross-account.test.js.map +1 -0
  86. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-owner-userid.test.d.ts +2 -0
  87. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-owner-userid.test.d.ts.map +1 -0
  88. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-owner-userid.test.js +40 -0
  89. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-owner-userid.test.js.map +1 -0
  90. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-tool-account.test.d.ts +2 -0
  91. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-tool-account.test.d.ts.map +1 -0
  92. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-tool-account.test.js +54 -0
  93. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/resolve-tool-account.test.js.map +1 -0
  94. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts +11 -0
  95. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts.map +1 -1
  96. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js +13 -1
  97. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js.map +1 -1
  98. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +2 -0
  99. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  100. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +7 -0
  101. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  102. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.d.ts.map +1 -1
  103. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js +6 -1
  104. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js.map +1 -1
  105. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.d.ts +7 -1
  106. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.d.ts.map +1 -1
  107. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.js +7 -2
  108. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.js.map +1 -1
  109. package/payload/platform/services/claude-session-manager/dist/config.d.ts +37 -0
  110. package/payload/platform/services/claude-session-manager/dist/config.d.ts.map +1 -1
  111. package/payload/platform/services/claude-session-manager/dist/config.js +34 -1
  112. package/payload/platform/services/claude-session-manager/dist/config.js.map +1 -1
  113. package/payload/platform/services/claude-session-manager/dist/cross-account-census.d.ts +34 -0
  114. package/payload/platform/services/claude-session-manager/dist/cross-account-census.d.ts.map +1 -0
  115. package/payload/platform/services/claude-session-manager/dist/cross-account-census.js +98 -0
  116. package/payload/platform/services/claude-session-manager/dist/cross-account-census.js.map +1 -0
  117. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  118. package/payload/platform/services/claude-session-manager/dist/http-server.js +10 -0
  119. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  120. package/payload/platform/services/claude-session-manager/dist/index.js +17 -0
  121. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  122. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  123. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +25 -0
  124. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  125. package/payload/platform/services/claude-session-manager/dist/session-sidecar.d.ts +7 -0
  126. package/payload/platform/services/claude-session-manager/dist/session-sidecar.d.ts.map +1 -1
  127. package/payload/platform/services/claude-session-manager/dist/session-sidecar.js +8 -0
  128. package/payload/platform/services/claude-session-manager/dist/session-sidecar.js.map +1 -1
  129. package/payload/server/{chunk-ZYS5V5QG.js → chunk-3Z5WE53X.js} +4 -0
  130. package/payload/server/maxy-edge.js +1 -1
  131. package/payload/server/public/assets/{AdminLoginScreens-BRQgI2lW.js → AdminLoginScreens-CYPTMmTk.js} +1 -1
  132. package/payload/server/public/assets/{AdminShell-By9n5icG.js → AdminShell-CZH_EZIy.js} +1 -1
  133. package/payload/server/public/assets/{Checkbox-DjEWgYu1.js → Checkbox-B0pbYJDQ.js} +1 -1
  134. package/payload/server/public/assets/{Transcript-BejWvOaO.js → Transcript-CYaAPBFX.js} +1 -1
  135. package/payload/server/public/assets/{admin-BFEMryQm.js → admin-BKDMSRto.js} +1 -1
  136. package/payload/server/public/assets/{browser-CMJMEUz6.js → browser-CxeMDDZA.js} +1 -1
  137. package/payload/server/public/assets/{calendar-C6ZGlHEP.js → calendar-DiIiTY9-.js} +1 -1
  138. package/payload/server/public/assets/chat-C56Oqvt1.js +1 -0
  139. package/payload/server/public/assets/chevron-left-Da-iZGi_.js +1 -0
  140. package/payload/server/public/assets/data-ZUdT44Ba.js +1 -0
  141. package/payload/server/public/assets/{graph-DIrXtPLv.js → graph-DC3dwnMZ.js} +1 -1
  142. package/payload/server/public/assets/{graph-labels-BtPf1Jom.js → graph-labels-Csnovm_c.js} +1 -1
  143. package/payload/server/public/assets/{maximize-2-DeJ4K8kL.js → maximize-2-WRUJsg5n.js} +1 -1
  144. package/payload/server/public/assets/{operator-B8QhqzLI.js → operator-BpzeHTAw.js} +1 -1
  145. package/payload/server/public/assets/{page-iFOy0dFx.js → page-8jJOxx6y.js} +1 -1
  146. package/payload/server/public/assets/{page-Df6KYkf4.js → page-IQDLdebG.js} +1 -1
  147. package/payload/server/public/assets/{public-BrUIRQZd.js → public-Dqg7jwjq.js} +1 -1
  148. package/payload/server/public/assets/{rotate-ccw-CYfntpwu.js → rotate-ccw-BayMWwfc.js} +1 -1
  149. package/payload/server/public/assets/{useSubAccountSwitcher-Cvnc_fwQ.css → useSubAccountSwitcher-CRZfyJXR.css} +1 -1
  150. package/payload/server/public/browser.html +4 -4
  151. package/payload/server/public/calendar.html +5 -5
  152. package/payload/server/public/chat.html +9 -9
  153. package/payload/server/public/data.html +8 -8
  154. package/payload/server/public/graph.html +9 -9
  155. package/payload/server/public/index.html +11 -11
  156. package/payload/server/public/operator.html +11 -11
  157. package/payload/server/public/public.html +9 -9
  158. package/payload/server/server.js +72 -15
  159. package/payload/server/public/assets/chat-B7s62Nnp.js +0 -1
  160. package/payload/server/public/assets/chevron-left-Dfjcaiyr.js +0 -1
  161. package/payload/server/public/assets/data-741ZbBwR.js +0 -1
  162. /package/payload/server/public/assets/{useSubAccountSwitcher-BK_KfOLC.js → useSubAccountSwitcher-C9aLg8yI.js} +0 -0
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * MCP spawn-tee — in-process stderr capture + lifecycle observability.
5
+ *
6
+ * Claude Code spawns each MCP server itself; the platform never holds a
7
+ * ChildProcess handle. This shim sits between Claude Code and the real MCP
8
+ * server: Claude Code runs `node <this> <real-entry>`, and the shim runs the
9
+ * real entry IN ITS OWN PROCESS via dynamic import() — one node runtime, not
10
+ * two. Before importing, it replaces process.stderr.write with a tee so every
11
+ * stderr byte the server writes is mirrored to the log sinks; stdin and stdout
12
+ * (the JSON-RPC channel) are never touched.
13
+ *
14
+ * Claude Code CLI → shim (this file) = node running <real-entry> in-process
15
+ * stdin/stdout : untouched (JSON-RPC channel)
16
+ * stderr : process.stderr.write teed → per-date + per-session + passthrough
17
+ *
18
+ * Destinations (Task 706) — unchanged:
19
+ * - `${LOG_DIR}/mcp-<name>-stderr-<date>.log` — per-date raw (back-compat;
20
+ * the in-process mcp-stderr-tee and the [mcp-init-error] probe read it).
21
+ * - `${LOG_DIR}/mcp-<name>-<SESSION_ID>.log` — per-session raw + lifecycle
22
+ * lines. Authoritative sink. Absent when SESSION_ID is unset (enumeration
23
+ * spawn) — then the per-date file is the fallback.
24
+ * - `server.log` via the loopback log-ingest route — best-effort mirror of
25
+ * the [mcp-helper] lifecycle lines.
26
+ *
27
+ * Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
28
+ * [mcp-helper] op=spawn ... pid= entry=
29
+ * [mcp-helper] op=boot ... head=<first stderr bytes>
30
+ * [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
31
+ *
32
+ * Process model (Task 989): the shim IS the server's process. op=exit fires
33
+ * from process.on("exit"), so it covers a normal exit, a non-zero exit, an
34
+ * uncaught throw (code 1), and a catchable-signal exit (SIGTERM/SIGINT/SIGHUP,
35
+ * whose handlers record the signal name). An external SIGKILL is uncatchable
36
+ * and leaves no op=exit line — the per-session stderr tail already on disk and
37
+ * Claude Code's own transport-drop are the evidence for that death mode.
38
+ *
39
+ * The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
40
+ */
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ const node_fs_1 = require("node:fs");
43
+ const node_path_1 = require("node:path");
44
+ const node_url_1 = require("node:url");
45
+ const SERVER_NAME = process.env.MCP_SPAWN_TEE_NAME ?? "unknown";
46
+ const LOG_DIR = process.env.LOG_DIR;
47
+ const SESSION_ID = process.env.SESSION_ID;
48
+ const PLATFORM_PORT = process.env.PLATFORM_PORT;
49
+ const ENTRY = process.argv[2];
50
+ const SESSION_ID8 = SESSION_ID ? SESSION_ID.slice(0, 8) : "—";
51
+ const spawnStamp = Date.now();
52
+ // Per-session raw + lifecycle log (Task 706). Empty SESSION_ID (enumeration
53
+ // spawn) → undefined, and the per-date file is the fallback.
54
+ const perSessionPath = LOG_DIR && SESSION_ID
55
+ ? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-${SESSION_ID}.log`)
56
+ : undefined;
57
+ const perDatePath = LOG_DIR
58
+ ? (0, node_path_1.resolve)(LOG_DIR, `mcp-${SERVER_NAME}-stderr-${new Date(spawnStamp).toISOString().slice(0, 10)}.log`)
59
+ : undefined;
60
+ // Rolling tail of entry stderr for op=exit. Capped so a chatty server cannot
61
+ // grow the buffer without bound.
62
+ const TAIL_CAP = 2048;
63
+ let stderrTail = "";
64
+ let bootEmitted = false;
65
+ let exitEmitted = false;
66
+ let exitSignal;
67
+ // The real stderr writer, captured before the tee replaces it. Lifecycle lines
68
+ // and stderr passthrough both go through this so they are never re-teed into
69
+ // the per-date sink nor recursed back into the patched writer.
70
+ const rawStderrWrite = process.stderr.write.bind(process.stderr);
71
+ // LOG_DIR is created once, lazily, on the first successful append — not per
72
+ // chunk. teeWrite runs on the server's own stderr hot path now, so a per-call
73
+ // mkdirSync would be two syscalls per log line for nothing.
74
+ let logDirReady = false;
75
+ function appendSafe(path, data) {
76
+ if (!path || !LOG_DIR)
77
+ return;
78
+ try {
79
+ if (!logDirReady) {
80
+ (0, node_fs_1.mkdirSync)(LOG_DIR, { recursive: true });
81
+ logDirReady = true;
82
+ }
83
+ (0, node_fs_1.appendFileSync)(path, data);
84
+ }
85
+ catch {
86
+ /* unwritable destination — never mask primary output */
87
+ }
88
+ }
89
+ // Best-effort mirror of a lifecycle line to server.log via the loopback
90
+ // log-ingest route. Fire-and-forget: the per-session file is authoritative, so
91
+ // a dropped POST loses nothing. On the "exit" event the loop is stopping, so
92
+ // the op=exit mirror may not flush — the per-session line, written sync, holds.
93
+ function postToServerLog(suffix, level) {
94
+ if (!PLATFORM_PORT)
95
+ return;
96
+ try {
97
+ const ctrl = new AbortController();
98
+ const t = setTimeout(() => ctrl.abort(), 500);
99
+ t.unref?.(); // never let the abort timer keep the shim's event loop alive
100
+ void fetch(`http://127.0.0.1:${PLATFORM_PORT}/api/admin/log-ingest`, {
101
+ method: "POST",
102
+ headers: { "content-type": "application/json" },
103
+ body: JSON.stringify({ tag: "mcp-helper", level, line: suffix }),
104
+ signal: ctrl.signal,
105
+ }).then(() => clearTimeout(t)).catch(() => clearTimeout(t));
106
+ }
107
+ catch {
108
+ /* fetch threw synchronously — best-effort only */
109
+ }
110
+ }
111
+ // Emit one [mcp-helper] lifecycle line: authoritative per-session file (sync,
112
+ // survives process.exit), the shim's own stderr via the RAW writer (journald /
113
+ // Claude Code visibility, never re-teed), and a best-effort server.log mirror.
114
+ // `suffix` is the line body after the tag and carries no newline (the
115
+ // log-ingest route rejects newlines).
116
+ function emitLifecycle(suffix, level) {
117
+ const line = `[mcp-helper] ${suffix}\n`;
118
+ appendSafe(perSessionPath, line);
119
+ try {
120
+ rawStderrWrite(line);
121
+ }
122
+ catch { /* stderr closed */ }
123
+ postToServerLog(suffix, level);
124
+ }
125
+ if (!ENTRY) {
126
+ emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
127
+ process.exit(2);
128
+ }
129
+ // Replace process.stderr.write with a tee: mirror every server stderr byte to
130
+ // the per-date and per-session sinks, keep a rolling tail for op=exit, emit
131
+ // op=boot on the first bytes, then pass the write through to the real stderr.
132
+ const teeWrite = ((...args) => {
133
+ const chunk = args[0];
134
+ appendSafe(perDatePath, chunk); // per-date raw (back-compat)
135
+ appendSafe(perSessionPath, chunk); // per-session raw (Task 706)
136
+ const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
137
+ stderrTail = (stderrTail + text).slice(-TAIL_CAP);
138
+ if (!bootEmitted) {
139
+ bootEmitted = true;
140
+ const head = text.split("\n")[0].slice(0, 200);
141
+ emitLifecycle(`op=boot session=${SESSION_ID8} server=${SERVER_NAME} head=${JSON.stringify(head)}`, "info");
142
+ }
143
+ return rawStderrWrite(...args); // passthrough
144
+ });
145
+ process.stderr.write = teeWrite;
146
+ // Catchable-signal handling. The shim drives the exit ONLY when it is the sole
147
+ // listener for the signal — i.e. the imported entry installed no handler of its
148
+ // own. In that case it records the signal (so op=exit carries signal=<sig>) and
149
+ // exits with 128+signum, mirroring the prior wrapper's exit-status convention.
150
+ //
151
+ // When the entry DID install a handler, the shim defers entirely and records
152
+ // nothing: the entry's handler decides the exit code, and op=exit reflects that
153
+ // exit verbatim. This matches the prior two-process model, where a child that
154
+ // caught the signal and exited cleanly was observed as code=0 signal=— (a clean
155
+ // self-exit), not as a signal death. Setting exitSignal here unconditionally
156
+ // would mislabel every graceful signal-driven shutdown as a signal kill.
157
+ function onSignal(sig, code) {
158
+ return () => {
159
+ if (process.listenerCount(sig) === 1) {
160
+ exitSignal = sig;
161
+ process.exit(code);
162
+ }
163
+ };
164
+ }
165
+ process.on("SIGTERM", onSignal("SIGTERM", 143));
166
+ process.on("SIGINT", onSignal("SIGINT", 130));
167
+ process.on("SIGHUP", onSignal("SIGHUP", 129));
168
+ // op=exit, emitted once from the process "exit" event. Sync-only — the loop is
169
+ // stopping. When a catchable signal caused the exit, report code=— signal=<sig>
170
+ // to match the prior wrapper's format; otherwise code=<exit code> signal=—.
171
+ process.on("exit", (code) => {
172
+ if (exitEmitted)
173
+ return;
174
+ exitEmitted = true;
175
+ const lifetimeMs = Date.now() - spawnStamp;
176
+ const tail = stderrTail.slice(-200);
177
+ const codeField = exitSignal ? "—" : String(code);
178
+ const level = exitSignal || code !== 0 ? "error" : "info";
179
+ emitLifecycle(`op=exit session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} ` +
180
+ `code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level);
181
+ });
182
+ emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
183
+ // Run the real MCP server in THIS process. Dynamic import() (not top-level
184
+ // await — this file compiles to CommonJS) loads the ESM entry; a load-time
185
+ // failure mirrors the old child spawn-error path (op=error, exit 127). The
186
+ // op=exit handler is suppressed on this path so op=error stays the sole record.
187
+ import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
188
+ const msg = err instanceof Error ? err.message : String(err);
189
+ exitEmitted = true;
190
+ emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
191
+ process.exit(127);
192
+ });
193
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,91 @@
1
+ import { initStderrTee } from "../../../../lib/mcp-stderr-tee/dist/index.js";
2
+ initStderrTee("filesystem");
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { eagerTool } from "../../../../lib/mcp-eager/dist/index.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { z } from "zod";
7
+ import { resolve } from "node:path";
8
+ import { readPluginHouseScope } from "./lib/scope.js";
9
+ import { fileRead } from "./tools/file-read.js";
10
+ import { fileWrite } from "./tools/file-write.js";
11
+ import { fileEdit } from "./tools/file-edit.js";
12
+ import { fileList } from "./tools/file-list.js";
13
+ import { fileGlob } from "./tools/file-glob.js";
14
+ import { fileGrep } from "./tools/file-grep.js";
15
+ // Cast to `any` to avoid TS2589 — the same accumulation limit the other
16
+ // plugins hit when registering several typed tool signatures.
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const server = new McpServer({ name: "maxy-filesystem", version: "0.1.0" });
19
+ // Plugin-system boot tolerance: module-init must never throw; plugin-system
20
+ // spawn enumerates tools/list before ACCOUNT_ID is set. Per-call refusal
21
+ // preserves account isolation.
22
+ const ownAccountId = process.env.ACCOUNT_ID ?? null;
23
+ // Fail-closed read of the boundary — see readPluginHouseScope. Never trusts a
24
+ // literal ${HOUSE_ADMIN_SCOPE} placeholder or an empty value as a real scope.
25
+ const houseScope = readPluginHouseScope(process.env);
26
+ const platformRoot = process.env.PLATFORM_ROOT ?? "";
27
+ process.stderr.write(`[filesystem] boot accountId=${ownAccountId ?? "null"} houseScope=${houseScope ? "set" : "null"}\n`);
28
+ function refuseNoAccount(toolName) {
29
+ process.stderr.write(`[filesystem] tool=${toolName} refuse reason=no-account-context\n`);
30
+ return {
31
+ content: [
32
+ {
33
+ type: "text",
34
+ text: `${toolName} cannot execute: this MCP instance was launched without ACCOUNT_ID/PLATFORM_ROOT (plugin-system metadata-only mode).`,
35
+ },
36
+ ],
37
+ isError: true,
38
+ };
39
+ }
40
+ /** Build the per-call context once from the spawn env. Null when the metadata-
41
+ * only boot left ACCOUNT_ID/PLATFORM_ROOT unset. `accountsDir` mirrors
42
+ * account.ts's `ACCOUNTS_DIR = resolve(PLATFORM_ROOT, "..", "data/accounts")`. */
43
+ function ctx() {
44
+ if (!ownAccountId || !platformRoot)
45
+ return null;
46
+ return { ownAccountId, houseScope, accountsDir: resolve(platformRoot, "..", "data/accounts") };
47
+ }
48
+ const targetArg = z
49
+ .string()
50
+ .optional()
51
+ .describe("House admin only: a sub-account ID to operate on. Omit to operate on your own account. A non-house session that passes this is denied (cross-account-denied).");
52
+ eagerTool(server, "file-read", "Read a UTF-8 file under the account directory. Pass a path relative to the account root; pass targetAccountId (house admin only) to read a sub-account's file.", { path: z.string().describe("Path relative to the account directory"), targetAccountId: targetArg }, async (a) => {
53
+ const c = ctx();
54
+ return c ? fileRead(a, c) : refuseNoAccount("file-read");
55
+ });
56
+ eagerTool(server, "file-write", "Write (create or overwrite) a UTF-8 file under the account directory, creating parent directories as needed.", {
57
+ path: z.string().describe("Path relative to the account directory"),
58
+ content: z.string().describe("Full file contents to write"),
59
+ targetAccountId: targetArg,
60
+ }, async (a) => {
61
+ const c = ctx();
62
+ return c ? fileWrite(a, c) : refuseNoAccount("file-write");
63
+ });
64
+ eagerTool(server, "file-edit", "Replace a single unique occurrence of oldString with newString in a file under the account directory. Fails if oldString is absent or matches more than once.", {
65
+ path: z.string().describe("Path relative to the account directory"),
66
+ oldString: z.string().describe("Exact text to replace (must occur exactly once)"),
67
+ newString: z.string().describe("Replacement text"),
68
+ targetAccountId: targetArg,
69
+ }, async (a) => {
70
+ const c = ctx();
71
+ return c ? fileEdit(a, c) : refuseNoAccount("file-edit");
72
+ });
73
+ eagerTool(server, "file-list", "List the entries of a directory under the account directory (name + type). Omit path to list the account root.", { path: z.string().optional().describe("Directory relative to the account root"), targetAccountId: targetArg }, async (a) => {
74
+ const c = ctx();
75
+ return c ? fileList(a, c) : refuseNoAccount("file-list");
76
+ });
77
+ eagerTool(server, "file-glob", "List files under the account directory matching a glob (**, *, ?), returned as paths relative to the account root.", { pattern: z.string().describe("Glob pattern, e.g. **/*.md"), targetAccountId: targetArg }, async (a) => {
78
+ const c = ctx();
79
+ return c ? fileGlob(a, c) : refuseNoAccount("file-glob");
80
+ });
81
+ eagerTool(server, "file-grep", "Search file contents under the account directory for a JavaScript regular expression, returning file:line:preview matches. Omit path to search the whole account.", {
82
+ pattern: z.string().describe("JavaScript regular expression"),
83
+ path: z.string().optional().describe("Subdirectory (relative) to limit the search"),
84
+ targetAccountId: targetArg,
85
+ }, async (a) => {
86
+ const c = ctx();
87
+ return c ? fileGrep(a, c) : refuseNoAccount("file-grep");
88
+ });
89
+ const transport = new StdioServerTransport();
90
+ await server.connect(transport);
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings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,MAAM,EACN,WAAW,EACX,oHAAoH,EACpH,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,EAC1F,KAAK,EAAE,CAAgD,EAAE,EAAE;IACzD,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC,CACF,CAAC;AAEF,SAAS,CACP,MAAM,EACN,WAAW,EACX,mKAAmK,EACnK;IACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC7D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IACnF,eAAe,EAAE,SAAS;CAC3B,EACD,KAAK,EAAE,CAA+D,EAAE,EAAE;IACxE,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC,CACF,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAO,MAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scope.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/scope.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdtempSync, mkdirSync, writeFileSync, symlinkSync, rmSync, realpathSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join, resolve } from "node:path";
5
+ import { resolveRoot, containedPath, readPluginHouseScope } from "../scope.js";
6
+ // enumerateValidAccountIds only counts UUID-named dirs with a parseable
7
+ // account.json, so the fixtures use real UUIDs.
8
+ const HOUSE = "11111111-1111-4111-8111-111111111111";
9
+ const CLIENT = "22222222-2222-4222-8222-222222222222";
10
+ const GHOST = "33333333-3333-4333-8333-333333333333";
11
+ let accountsDir;
12
+ let outsideDir;
13
+ beforeEach(() => {
14
+ accountsDir = mkdtempSync(join(tmpdir(), "xacct-accounts-"));
15
+ outsideDir = mkdtempSync(join(tmpdir(), "xacct-outside-"));
16
+ for (const id of [HOUSE, CLIENT]) {
17
+ mkdirSync(join(accountsDir, id), { recursive: true });
18
+ writeFileSync(join(accountsDir, id, "account.json"), JSON.stringify({ accountId: id }));
19
+ }
20
+ writeFileSync(join(outsideDir, "secret.txt"), "secret");
21
+ });
22
+ afterEach(() => {
23
+ rmSync(accountsDir, { recursive: true, force: true });
24
+ rmSync(outsideDir, { recursive: true, force: true });
25
+ });
26
+ const houseCtx = () => ({ ownAccountId: HOUSE, houseScope: HOUSE, accountsDir });
27
+ const clientCtx = () => ({ ownAccountId: CLIENT, houseScope: null, accountsDir });
28
+ describe("resolveRoot — fail-closed gate", () => {
29
+ it("no target → own account root", () => {
30
+ const r = resolveRoot(houseCtx(), undefined, "file-read");
31
+ expect(r).toEqual({ root: resolve(accountsDir, HOUSE), resolved: HOUSE });
32
+ });
33
+ it("house scope + valid target → target root", () => {
34
+ const r = resolveRoot(houseCtx(), CLIENT, "file-read");
35
+ expect(r).toEqual({ root: resolve(accountsDir, CLIENT), resolved: CLIENT });
36
+ });
37
+ it("non-house session + target → cross-account-denied", () => {
38
+ const r = resolveRoot(clientCtx(), HOUSE, "file-read");
39
+ expect(r).toEqual({ reject: "cross-account-denied" });
40
+ });
41
+ it("house scope + unknown target → cross-account-invalid-target", () => {
42
+ const r = resolveRoot(houseCtx(), GHOST, "file-read");
43
+ expect(r).toEqual({ reject: "cross-account-invalid-target" });
44
+ });
45
+ it("house scope + target == own → own root (self allowed)", () => {
46
+ const r = resolveRoot(houseCtx(), HOUSE, "file-read");
47
+ expect(r).toEqual({ root: resolve(accountsDir, HOUSE), resolved: HOUSE });
48
+ });
49
+ });
50
+ describe("readPluginHouseScope — fail-closed against loader substitution", () => {
51
+ it("returns the scope when a real value is set", () => {
52
+ expect(readPluginHouseScope({ HOUSE_ADMIN_SCOPE: HOUSE })).toBe(HOUSE);
53
+ });
54
+ it("returns null when absent (non-house session)", () => {
55
+ expect(readPluginHouseScope({})).toBeNull();
56
+ });
57
+ it("returns null when empty", () => {
58
+ expect(readPluginHouseScope({ HOUSE_ADMIN_SCOPE: "" })).toBeNull();
59
+ });
60
+ it("returns null for an unsubstituted ${...} placeholder (the escalation guard)", () => {
61
+ expect(readPluginHouseScope({ HOUSE_ADMIN_SCOPE: "${HOUSE_ADMIN_SCOPE}" })).toBeNull();
62
+ });
63
+ });
64
+ describe("containedPath — traversal guard", () => {
65
+ it("allows a legitimate file directly under root", () => {
66
+ const root = resolve(accountsDir, HOUSE);
67
+ const realRoot = realpathSync(root); // macOS resolves /var → /private/var
68
+ expect(containedPath(root, "SOUL.md")).toBe(join(realRoot, "SOUL.md"));
69
+ });
70
+ it("allows a nested not-yet-existing (create) path under root", () => {
71
+ const root = resolve(accountsDir, HOUSE);
72
+ const realRoot = realpathSync(root);
73
+ expect(containedPath(root, "agents/x/new.txt")).toBe(join(realRoot, "agents/x/new.txt"));
74
+ });
75
+ it("rejects ../ escape to a sibling account", () => {
76
+ const root = resolve(accountsDir, HOUSE);
77
+ expect(() => containedPath(root, `../${CLIENT}/account.json`)).toThrow("path-escape");
78
+ });
79
+ it("rejects an absolute path outside the account dir", () => {
80
+ const root = resolve(accountsDir, HOUSE);
81
+ expect(() => containedPath(root, "/etc/passwd")).toThrow("path-escape");
82
+ });
83
+ it("rejects a symlink that escapes the account dir", () => {
84
+ const root = resolve(accountsDir, HOUSE);
85
+ symlinkSync(outsideDir, join(root, "escape"));
86
+ expect(() => containedPath(root, "escape/secret.txt")).toThrow("path-escape");
87
+ });
88
+ });
89
+ //# sourceMappingURL=scope.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/scope.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAoB,EAAY,MAAM,aAAa,CAAC;AAEzF,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,KAAK,GAAG,sCAAsC,CAAC;AACrD,MAAM,MAAM,GAAG,sCAAsC,CAAC;AACtD,MAAM,KAAK,GAAG,sCAAsC,CAAC;AAErD,IAAI,WAAmB,CAAC;AACxB,IAAI,UAAkB,CAAC;AAEvB,UAAU,CAAC,GAAG,EAAE;IACd,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC7D,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC3D,KAAK,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,aAAa,CAAC,IAA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AAE;QACjD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,MAAM,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface ToolResult {
2
+ content: {
3
+ type: "text";
4
+ text: string;
5
+ }[];
6
+ /** Present and true only on error results, so `.isError` is well-typed on the
7
+ * ok|err union that handlers return. */
8
+ isError?: true;
9
+ }
10
+ export declare const ok: (text: string) => ToolResult;
11
+ export declare const err: (text: string) => ToolResult;
12
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/lib/result.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C;6CACyC;IACzC,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,eAAO,MAAM,EAAE,GAAI,MAAM,MAAM,KAAG,UAAqD,CAAC;AACxF,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,UAGjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const ok = (text) => ({ content: [{ type: "text", text }] });
2
+ export const err = (text) => ({
3
+ content: [{ type: "text", text }],
4
+ isError: true,
5
+ });
6
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/lib/result.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,CAAC;IAChD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjC,OAAO,EAAE,IAAI;CACd,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Read HOUSE_ADMIN_SCOPE for the plugin, fail-closed. HOUSE_ADMIN_SCOPE is the
3
+ * whole boundary: it is present in the spawn env ONLY for a house role:admin
4
+ * session (Task 1440). This plugin's PLUGIN.md also declares the key with a
5
+ * `${HOUSE_ADMIN_SCOPE}` placeholder so the value flows on loaders that pass
6
+ * only declared env keys — but an UNSET placeholder is substituted
7
+ * differently across spawn loaders: some yield empty, some leave the literal
8
+ * `${HOUSE_ADMIN_SCOPE}` string (which is truthy). Treating a literal
9
+ * placeholder or an empty value as "no scope" makes a non-house session
10
+ * deterministically fail-closed regardless of loader behaviour — the read
11
+ * never trusts a value it did not receive as a real scope. (This is why the
12
+ * plugin does not call the shared `readHouseAdminScope`, whose truthy test
13
+ * would accept the literal placeholder.)
14
+ */
15
+ export declare function readPluginHouseScope(env: NodeJS.ProcessEnv): string | null;
16
+ export interface Ctx {
17
+ /** The session's own account (spawn env ACCOUNT_ID). */
18
+ ownAccountId: string;
19
+ /** HOUSE_ADMIN_SCOPE from the spawn env; null for any non-house session. */
20
+ houseScope: string | null;
21
+ /** `<install>/data/accounts` — the root that all account dirs live under. */
22
+ accountsDir: string;
23
+ }
24
+ export type ResolveRootResult = {
25
+ root: string;
26
+ resolved: string;
27
+ } | {
28
+ reject: "cross-account-denied" | "cross-account-invalid-target";
29
+ };
30
+ /**
31
+ * Resolve the account directory a tool call acts on, gated fail-closed. Emits
32
+ * the standing [xacct] decision line for every call and op=fs-root on allow.
33
+ * `root` is `<accountsDir>/<resolved>` — the strict filesystem root the caller
34
+ * must contain every path within.
35
+ */
36
+ export declare function resolveRoot(ctx: Ctx, targetAccountId: string | undefined, tool: string): ResolveRootResult;
37
+ /**
38
+ * Resolve `relPath` against the account `root` and prove it stays inside.
39
+ * Lexical containment rejects `../` and absolute-path escapes; a realpath check
40
+ * on the deepest EXISTING ancestor rejects symlink escapes and still permits a
41
+ * not-yet-existing (create) target. Throws Error("path-escape") after emitting
42
+ * op=path-escape-reject; the caller surfaces it as an isError tool result.
43
+ */
44
+ export declare function containedPath(root: string, relPath: string): string;
45
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/lib/scope.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAK1E;AAED,MAAM,WAAW,GAAG;IAClB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,sBAAsB,GAAG,8BAA8B,CAAA;CAAE,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,GACX,iBAAiB,CAqBnB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAenE"}
@@ -0,0 +1,86 @@
1
+ // scope.ts — the security core of the `filesystem` plugin.
2
+ //
3
+ // Every file tool routes through here. `resolveRoot` runs the ONE landed
4
+ // fail-closed resolver (account-scope) with a valid-account check over
5
+ // `enumerateValidAccountIds`, emitting the [xacct] per-call decision line and
6
+ // the op=fs-root line BEFORE any fs op. `containedPath` roots every path under
7
+ // the resolved account dir and rejects traversal (../, absolute escape) and
8
+ // symlink escapes, emitting op=path-escape-reject.
9
+ //
10
+ // The fail-closed backbone is structural, not conventional: HOUSE_ADMIN_SCOPE
11
+ // is stamped into the spawn env ONLY for a non-specialist role:admin session on
12
+ // the house account (Task 1440), so a sub-account, specialist, or public
13
+ // session's plugin process carries houseScope=null and any targetAccountId it
14
+ // passes resolves to cross-account-denied.
15
+ import { resolve, dirname, sep } from "node:path";
16
+ import { realpathSync, existsSync } from "node:fs";
17
+ import { resolveEffectiveAccountCore } from "../../../../../lib/account-scope/dist/index.js";
18
+ import { enumerateValidAccountIds } from "../../../../../lib/account-enumeration/dist/index.js";
19
+ const short = (id) => id.slice(0, 8);
20
+ /**
21
+ * Read HOUSE_ADMIN_SCOPE for the plugin, fail-closed. HOUSE_ADMIN_SCOPE is the
22
+ * whole boundary: it is present in the spawn env ONLY for a house role:admin
23
+ * session (Task 1440). This plugin's PLUGIN.md also declares the key with a
24
+ * `${HOUSE_ADMIN_SCOPE}` placeholder so the value flows on loaders that pass
25
+ * only declared env keys — but an UNSET placeholder is substituted
26
+ * differently across spawn loaders: some yield empty, some leave the literal
27
+ * `${HOUSE_ADMIN_SCOPE}` string (which is truthy). Treating a literal
28
+ * placeholder or an empty value as "no scope" makes a non-house session
29
+ * deterministically fail-closed regardless of loader behaviour — the read
30
+ * never trusts a value it did not receive as a real scope. (This is why the
31
+ * plugin does not call the shared `readHouseAdminScope`, whose truthy test
32
+ * would accept the literal placeholder.)
33
+ */
34
+ export function readPluginHouseScope(env) {
35
+ const raw = env.HOUSE_ADMIN_SCOPE;
36
+ if (!raw)
37
+ return null;
38
+ if (raw.startsWith("${"))
39
+ return null;
40
+ return raw;
41
+ }
42
+ /**
43
+ * Resolve the account directory a tool call acts on, gated fail-closed. Emits
44
+ * the standing [xacct] decision line for every call and op=fs-root on allow.
45
+ * `root` is `<accountsDir>/<resolved>` — the strict filesystem root the caller
46
+ * must contain every path within.
47
+ */
48
+ export function resolveRoot(ctx, targetAccountId, tool) {
49
+ const isValidAccountId = (id) => enumerateValidAccountIds(ctx.accountsDir).includes(id);
50
+ const eff = resolveEffectiveAccountCore({ ownAccountId: ctx.ownAccountId, houseScope: ctx.houseScope, targetAccountId }, isValidAccountId);
51
+ const targetField = targetAccountId ? short(targetAccountId) : "self";
52
+ const houseField = ctx.houseScope ? "true" : "false";
53
+ if ("reject" in eff) {
54
+ process.stderr.write(`[xacct] op=call tool=${tool} caller=${short(ctx.ownAccountId)} target=${targetField} houseScope=${houseField} decision=deny reason=${eff.reject}\n`);
55
+ return { reject: eff.reject };
56
+ }
57
+ process.stderr.write(`[xacct] op=call tool=${tool} caller=${short(ctx.ownAccountId)} target=${targetField} houseScope=${houseField} decision=allow reason=none\n`);
58
+ const root = resolve(ctx.accountsDir, eff.accountId);
59
+ process.stderr.write(`[xacct] op=fs-root root=data/accounts/${short(eff.accountId)}/\n`);
60
+ return { root, resolved: eff.accountId };
61
+ }
62
+ /**
63
+ * Resolve `relPath` against the account `root` and prove it stays inside.
64
+ * Lexical containment rejects `../` and absolute-path escapes; a realpath check
65
+ * on the deepest EXISTING ancestor rejects symlink escapes and still permits a
66
+ * not-yet-existing (create) target. Throws Error("path-escape") after emitting
67
+ * op=path-escape-reject; the caller surfaces it as an isError tool result.
68
+ */
69
+ export function containedPath(root, relPath) {
70
+ const realRoot = realpathSync(root);
71
+ const abs = resolve(realRoot, relPath);
72
+ const escape = () => {
73
+ process.stderr.write(`[xacct] op=path-escape-reject path=${relPath} resolved=${short(realRoot.split(sep).pop() ?? "")}\n`);
74
+ throw new Error("path-escape");
75
+ };
76
+ if (abs !== realRoot && !abs.startsWith(realRoot + sep))
77
+ escape();
78
+ let ancestor = abs;
79
+ while (!existsSync(ancestor))
80
+ ancestor = dirname(ancestor);
81
+ const realAncestor = realpathSync(ancestor);
82
+ if (realAncestor !== realRoot && !realAncestor.startsWith(realRoot + sep))
83
+ escape();
84
+ return abs;
85
+ }
86
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/lib/scope.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,mDAAmD;AACnD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,yEAAyE;AACzE,8EAA8E;AAC9E,2CAA2C;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,sDAAsD,CAAC;AAEhG,MAAM,KA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AQ,GAAG,GAAG,CAAC;QAAE,MAAM,EAAE,CAAC;IACpF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * List regular files under `root`, returning paths RELATIVE to root with "/"
3
+ * separators. Symlinked entries are skipped (no escape). Stops at `cap` files.
4
+ */
5
+ export declare function walkFiles(root: string, cap: number): string[];
6
+ /**
7
+ * Translate a glob (`**`, `*`, `?`) to an anchored RegExp over "/"-joined
8
+ * relative paths. `*` and `?` do not cross "/"; `**` crosses any depth.
9
+ */
10
+ export declare function globToRegExp(glob: string): RegExp;
11
+ //# sourceMappingURL=walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/lib/walk.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAoB7D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBjD"}