@rubytech/create-realagent-code 0.1.614 → 0.1.616

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 (197) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/aeo-llms-txt-writer/dist/__tests__/write-llms-txt.test.d.ts +2 -0
  3. package/payload/platform/lib/aeo-llms-txt-writer/dist/__tests__/write-llms-txt.test.d.ts.map +1 -0
  4. package/payload/platform/lib/aeo-llms-txt-writer/dist/__tests__/write-llms-txt.test.js +291 -0
  5. package/payload/platform/lib/aeo-llms-txt-writer/dist/__tests__/write-llms-txt.test.js.map +1 -0
  6. package/payload/platform/lib/aeo-llms-txt-writer/dist/index.d.ts +13 -1
  7. package/payload/platform/lib/aeo-llms-txt-writer/dist/index.d.ts.map +1 -1
  8. package/payload/platform/lib/aeo-llms-txt-writer/dist/index.js +127 -18
  9. package/payload/platform/lib/aeo-llms-txt-writer/dist/index.js.map +1 -1
  10. package/payload/platform/lib/aeo-llms-txt-writer/src/__tests__/write-llms-txt.test.ts +391 -0
  11. package/payload/platform/lib/aeo-llms-txt-writer/src/index.ts +156 -19
  12. package/payload/platform/lib/aeo-llms-txt-writer/vitest.config.ts +10 -0
  13. package/payload/platform/lib/mcp-spawn-tee/dist/index.d.ts +15 -1
  14. package/payload/platform/lib/mcp-spawn-tee/dist/index.d.ts.map +1 -1
  15. package/payload/platform/lib/mcp-spawn-tee/dist/index.js +129 -7
  16. package/payload/platform/lib/mcp-spawn-tee/dist/index.js.map +1 -1
  17. package/payload/platform/lib/mcp-spawn-tee/src/__tests__/spawn-tee.test.ts +227 -0
  18. package/payload/platform/lib/mcp-spawn-tee/src/index.ts +133 -6
  19. package/payload/platform/plugins/admin/lib/mcp-spawn-tee/index.js +129 -7
  20. package/payload/platform/plugins/admin/mcp/dist/index.js +11 -3
  21. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  22. package/payload/platform/plugins/admin/mcp/dist/tools/publish-site.d.ts +3 -0
  23. package/payload/platform/plugins/admin/mcp/dist/tools/publish-site.d.ts.map +1 -1
  24. package/payload/platform/plugins/admin/mcp/dist/tools/publish-site.js +38 -20
  25. package/payload/platform/plugins/admin/mcp/dist/tools/publish-site.js.map +1 -1
  26. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +6 -5
  27. package/payload/platform/plugins/admin/skills/publish-site/SKILL.md +3 -0
  28. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +13 -0
  29. package/payload/platform/plugins/aeo/PLUGIN.md +1 -1
  30. package/payload/platform/plugins/aeo/lib/mcp-spawn-tee/index.js +129 -7
  31. package/payload/platform/plugins/aeo/mcp/dist/index.js +17 -10
  32. package/payload/platform/plugins/aeo/mcp/dist/index.js.map +1 -1
  33. package/payload/platform/plugins/browser/PLUGIN.md +1 -1
  34. package/payload/platform/plugins/browser/lib/mcp-spawn-tee/index.js +129 -7
  35. package/payload/platform/plugins/connector/lib/mcp-spawn-tee/index.js +129 -7
  36. package/payload/platform/plugins/contacts/lib/mcp-spawn-tee/index.js +129 -7
  37. package/payload/platform/plugins/dispatch/lib/mcp-spawn-tee/index.js +129 -7
  38. package/payload/platform/plugins/docs/references/aeo.md +4 -3
  39. package/payload/platform/plugins/docs/references/plugins-guide.md +1 -1
  40. package/payload/platform/plugins/email/lib/mcp-spawn-tee/index.js +129 -7
  41. package/payload/platform/plugins/filesystem/lib/mcp-spawn-tee/index.js +129 -7
  42. package/payload/platform/plugins/google/lib/mcp-spawn-tee/index.js +129 -7
  43. package/payload/platform/plugins/graph-viewer/lib/mcp-spawn-tee/index.js +129 -7
  44. package/payload/platform/plugins/inventory/lib/mcp-spawn-tee/index.js +129 -7
  45. package/payload/platform/plugins/ledger/lib/mcp-spawn-tee/index.js +129 -7
  46. package/payload/platform/plugins/memory/lib/mcp-spawn-tee/index.js +129 -7
  47. package/payload/platform/plugins/outlook/lib/mcp-spawn-tee/index.js +129 -7
  48. package/payload/platform/plugins/quickbooks/lib/mcp-spawn-tee/index.js +129 -7
  49. package/payload/platform/plugins/replicate/lib/mcp-spawn-tee/index.js +129 -7
  50. package/payload/platform/plugins/scheduling/PLUGIN.md +3 -4
  51. package/payload/platform/plugins/scheduling/lib/mcp-spawn-tee/index.js +129 -7
  52. package/payload/platform/plugins/scheduling/mcp/dist/index.js +0 -6
  53. package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
  54. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.js +65 -20
  55. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-audits.test.js.map +1 -1
  56. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.js +20 -0
  57. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/gate-classification.test.js.map +1 -1
  58. package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts +12 -4
  59. package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.d.ts.map +1 -1
  60. package/payload/platform/plugins/scheduling/mcp/dist/lib/gate.js.map +1 -1
  61. package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.d.ts.map +1 -1
  62. package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.js +39 -6
  63. package/payload/platform/plugins/scheduling/mcp/dist/lib/schedule-audit.js.map +1 -1
  64. package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js +21 -6
  65. package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/gate-dispatch-wiring.test.js.map +1 -1
  66. package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js +26 -5
  67. package/payload/platform/plugins/scheduling/mcp/dist/scripts/check-due-events.js.map +1 -1
  68. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.js +17 -51
  69. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-waiver.test.js.map +1 -1
  70. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.js +6 -4
  71. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-gate-write.test.js.map +1 -1
  72. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js +113 -1
  73. package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/scheduling-gate.test.js.map +1 -1
  74. package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts +8 -18
  75. package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.d.ts.map +1 -1
  76. package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js +14 -27
  77. package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-event.js.map +1 -1
  78. package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.d.ts.map +1 -1
  79. package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js +125 -56
  80. package/payload/platform/plugins/scheduling/mcp/dist/tools/scheduling-gate.js.map +1 -1
  81. package/payload/platform/plugins/storage-broker/lib/mcp-spawn-tee/index.js +129 -7
  82. package/payload/platform/plugins/url-get/lib/mcp-spawn-tee/index.js +129 -7
  83. package/payload/platform/plugins/voice-mirror/lib/mcp-spawn-tee/index.js +129 -7
  84. package/payload/platform/plugins/whatsapp/lib/mcp-spawn-tee/index.js +129 -7
  85. package/payload/platform/plugins/work/lib/mcp-spawn-tee/index.js +129 -7
  86. package/payload/platform/plugins/workflows/lib/mcp-spawn-tee/index.js +129 -7
  87. package/payload/platform/scripts/__tests__/vnc-cdp-liveness.test.sh +270 -19
  88. package/payload/platform/scripts/vnc.sh +174 -71
  89. package/payload/platform/services/claude-session-manager/dist/index.js +17 -0
  90. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  91. package/payload/platform/services/claude-session-manager/dist/mcp-helper-census.d.ts +80 -0
  92. package/payload/platform/services/claude-session-manager/dist/mcp-helper-census.d.ts.map +1 -0
  93. package/payload/platform/services/claude-session-manager/dist/mcp-helper-census.js +201 -0
  94. package/payload/platform/services/claude-session-manager/dist/mcp-helper-census.js.map +1 -0
  95. package/payload/premium-plugins/real-agent/plugins/buyers/lib/mcp-spawn-tee/index.js +129 -7
  96. package/payload/premium-plugins/real-agent/plugins/estate-sales/lib/mcp-spawn-tee/index.js +129 -7
  97. package/payload/premium-plugins/real-agent/plugins/loop/PLUGIN.md +12 -0
  98. package/payload/premium-plugins/real-agent/plugins/loop/lib/mcp-spawn-tee/index.js +129 -7
  99. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js +13 -0
  100. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js.map +1 -1
  101. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/field-census.d.ts +22 -0
  102. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/field-census.d.ts.map +1 -0
  103. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/field-census.js +81 -0
  104. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/field-census.js.map +1 -0
  105. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts +17 -5
  106. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
  107. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js +90 -17
  108. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
  109. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-schema-keys.d.ts +2 -0
  110. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-schema-keys.d.ts.map +1 -0
  111. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-schema-keys.js +1010 -0
  112. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-schema-keys.js.map +1 -0
  113. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/auto-responder.js +2 -2
  114. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/auto-responder.js.map +1 -1
  115. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/customer-preferences.js +3 -3
  116. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/customer-preferences.js.map +1 -1
  117. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/feedback.d.ts +1 -0
  118. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/feedback.d.ts.map +1 -1
  119. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/feedback.js +5 -5
  120. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/feedback.js.map +1 -1
  121. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match-batch.d.ts +1 -0
  122. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match-batch.d.ts.map +1 -1
  123. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match-batch.js +2 -2
  124. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match-batch.js.map +1 -1
  125. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match.d.ts +1 -0
  126. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match.d.ts.map +1 -1
  127. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match.js +4 -4
  128. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/marketing-match.js.map +1 -1
  129. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-detail.d.ts +1 -0
  130. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-detail.d.ts.map +1 -1
  131. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-detail.js +3 -3
  132. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-detail.js.map +1 -1
  133. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-search.d.ts +1 -0
  134. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-search.d.ts.map +1 -1
  135. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-search.js +3 -3
  136. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/people-search.js.map +1 -1
  137. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-detail.d.ts +1 -0
  138. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-detail.d.ts.map +1 -1
  139. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-detail.js +13 -6
  140. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-detail.js.map +1 -1
  141. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-listed.d.ts +1 -0
  142. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-listed.d.ts.map +1 -1
  143. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-listed.js +3 -3
  144. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-listed.js.map +1 -1
  145. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-search.d.ts +1 -0
  146. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-search.d.ts.map +1 -1
  147. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-search.js +3 -3
  148. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-search.js.map +1 -1
  149. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-sold.d.ts +1 -0
  150. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-sold.d.ts.map +1 -1
  151. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-sold.js +3 -3
  152. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/property-sold.js.map +1 -1
  153. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/supplier.js +4 -4
  154. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/supplier.js.map +1 -1
  155. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-availability.d.ts +1 -0
  156. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-availability.d.ts.map +1 -1
  157. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-availability.js +3 -3
  158. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-availability.js.map +1 -1
  159. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-info.d.ts +1 -0
  160. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-info.d.ts.map +1 -1
  161. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-info.js +3 -3
  162. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/team-info.js.map +1 -1
  163. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-detail.d.ts +1 -0
  164. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-detail.d.ts.map +1 -1
  165. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-detail.js +3 -3
  166. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-detail.js.map +1 -1
  167. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-search.d.ts +1 -0
  168. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-search.d.ts.map +1 -1
  169. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-search.js +3 -3
  170. package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/viewing-search.js.map +1 -1
  171. package/payload/premium-plugins/real-agent/plugins/loop/mcp/package.json +2 -1
  172. package/payload/premium-plugins/real-agent/plugins/loop/mcp/scripts/generate-loop-schema-keys.mjs +87 -0
  173. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/__tests__/new-tool-shape.test.ts +1 -1
  174. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/__tests__/read-fidelity.test.ts +303 -0
  175. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/__tests__/swagger-write-coverage.test.ts +6 -6
  176. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/index.ts +13 -0
  177. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/field-census.ts +86 -0
  178. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/loop-api.ts +116 -17
  179. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/loop-schema-keys.ts +1010 -0
  180. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/auto-responder.ts +2 -2
  181. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/customer-preferences.ts +3 -3
  182. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/feedback.ts +6 -4
  183. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/marketing-match-batch.ts +4 -2
  184. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/marketing-match.ts +6 -4
  185. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/people-detail.ts +5 -3
  186. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/people-search.ts +5 -3
  187. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/property-detail.ts +17 -7
  188. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/property-listed.ts +5 -3
  189. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/property-search.ts +5 -3
  190. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/property-sold.ts +5 -3
  191. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/supplier.ts +4 -4
  192. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/team-availability.ts +5 -3
  193. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/team-info.ts +6 -3
  194. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/viewing-detail.ts +5 -3
  195. package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/viewing-search.ts +5 -3
  196. package/payload/premium-plugins/real-agent/plugins/property-data/lib/mcp-spawn-tee/index.js +129 -7
  197. package/payload/server/server.js +422 -251
@@ -25,10 +25,13 @@
25
25
  * - `server.log` via the loopback log-ingest route — best-effort mirror of
26
26
  * the [mcp-helper] lifecycle lines.
27
27
  *
28
- * Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
28
+ * Lifecycle lines, correlation key `session=<id8> server=<name>`:
29
29
  * [mcp-helper] op=spawn ... pid= entry=
30
30
  * [mcp-helper] op=boot ... head=<first stderr bytes>
31
31
  * [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
32
+ * [mcp-helper] op=fatal ... kind=uncaught|rejection deferred=yes|no
33
+ * disposition=survived|exit error=
34
+ * preceded by an `op=fatal-stack` block carrying the full stack (Task 2787).
32
35
  *
33
36
  * Process model (Task 989): the shim IS the server's process. op=exit fires
34
37
  * from process.on("exit"), so it covers a normal exit, a non-zero exit, an
@@ -37,6 +40,17 @@
37
40
  * and leaves no op=exit line — the per-session stderr tail already on disk and
38
41
  * Claude Code's own transport-drop are the evidence for that death mode.
39
42
  *
43
+ * op=exit records THAT a fatal killed the process; it never records WHICH one,
44
+ * because Node's fatal printer writes beneath the tee (Task 2787). The op=fatal
45
+ * pair is what names the error.
46
+ *
47
+ * Task 2788 — a fatal no longer always kills. `disposition=` says what the guard
48
+ * did: the shim exits 1 only when it is the sole listener for the event AND no
49
+ * stdio transport is connected. A fatal on a connected transport is recorded
50
+ * and survived, because Claude Code's policy after a helper dies is one
51
+ * reconnect then stop, so killing a live server removes its whole tool surface
52
+ * for the rest of the session.
53
+ *
40
54
  * The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
41
55
  */
42
56
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -114,14 +128,22 @@ function postToServerLog(suffix, level) {
114
128
  // Claude Code visibility, never re-teed), and a best-effort server.log mirror.
115
129
  // `suffix` is the line body after the tag and carries no newline (the
116
130
  // log-ingest route rejects newlines).
117
- function emitLifecycle(suffix, level) {
131
+ //
132
+ // Task 2787 — `mirror` is false for op=exit and op=fatal. Both fire while the
133
+ // loop is stopping, so the async fetch cannot flush: server.log held 2 op=exit
134
+ // lines against 160 op=spawn and 135 op=boot. The sync raw sink is the
135
+ // authoritative carrier for those two; posting them was a near-total loss
136
+ // dressed as a mirror. op=spawn/op=boot/op=error keep it — they fire while the
137
+ // loop is live and land.
138
+ function emitLifecycle(suffix, level, mirror = true) {
118
139
  const line = `[mcp-helper] ${suffix}\n`;
119
140
  appendSafe(rawSinkPath, line);
120
141
  try {
121
142
  rawStderrWrite(line);
122
143
  }
123
144
  catch { /* stderr closed */ }
124
- postToServerLog(suffix, level);
145
+ if (mirror)
146
+ postToServerLog(suffix, level);
125
147
  }
126
148
  if (!ENTRY) {
127
149
  emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
@@ -165,6 +187,97 @@ function onSignal(sig, code) {
165
187
  process.on("SIGTERM", onSignal("SIGTERM", 143));
166
188
  process.on("SIGINT", onSignal("SIGINT", 130));
167
189
  process.on("SIGHUP", onSignal("SIGHUP", 129));
190
+ // Task 2787 — the fatal guard. Three measured facts drove it here rather than
191
+ // into the 26 plugin entries: Node's default fatal printer writes to fd 2
192
+ // BENEATH the JS `process.stderr.write` the tee replaces, so on both 18 Aug
193
+ // deaths the stack reached neither the raw sink nor Claude Code's own
194
+ // `Server stderr:` capture; the shim is the single seam every entry already
195
+ // loads through; and 26 copies would have to stay in step for ever.
196
+ //
197
+ // The stack is written through appendSafe and rawStderrWrite directly, never
198
+ // through teeWrite — the tee is the thing that was blind to it.
199
+ /** The three fields a fatal contributes. A rejection reason need not be an
200
+ * Error, in which case there is no stack and the stringified reason stands in
201
+ * for all three. */
202
+ function describeFatal(err) {
203
+ if (err instanceof Error) {
204
+ return { name: err.name, message: err.message, stack: err.stack ?? `${err.name}: ${err.message}` };
205
+ }
206
+ const s = String(err);
207
+ return { name: typeof err, message: s, stack: s };
208
+ }
209
+ /** Write a fatal's full stack as its own block, before the lifecycle line that
210
+ * summarises it. Multi-line by nature, which is why it is not a field on that
211
+ * line. Goes through appendSafe and the RAW writer — never teeWrite, which is
212
+ * the thing Node's own fatal printer writes beneath. */
213
+ function writeFatalStack(kind, stack) {
214
+ const block = `[mcp-helper] op=fatal-stack session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind}\n${stack}\n`;
215
+ appendSafe(rawSinkPath, block);
216
+ try {
217
+ rawStderrWrite(block);
218
+ }
219
+ catch { /* stderr closed */ }
220
+ }
221
+ /** Task 2788 — has a stdio transport connected in this process?
222
+ *
223
+ * `server.connect(transport)` calls `StdioServerTransport.start()`, whose body
224
+ * is `this._stdin.on("data", …)`. So a stdin `data` listener exists if and only
225
+ * if a stdio transport has started, and `close()` removes it again — a fatal
226
+ * after the transport closed correctly reads as not connected.
227
+ *
228
+ * Read at the moment of the fatal rather than latched at first connect, so a
229
+ * transport that has since closed is not remembered as live. Nothing is
230
+ * patched: all 26 plugin entries construct a StdioServerTransport and none
231
+ * reads stdin itself, so this listener has exactly one source. The three
232
+ * channel services carry no stdio transport, so every fatal in them still
233
+ * exits — unchanged from before this task. */
234
+ function transportConnected() {
235
+ return process.stdin.listenerCount("data") > 0;
236
+ }
237
+ // Task 2788 — the disposition. `disposition=` names what THIS guard did with
238
+ // the process: `exit` means it called process.exit(1); `survived` means it
239
+ // returned and left the process running.
240
+ //
241
+ // Claude Code owns the spawn (Task 706: no ChildProcess handle; Task 989: the
242
+ // shim IS the server process) and its post-failure policy is one reconnect then
243
+ // stop — measured on 18 Aug, when the retry died the same way 2.6s in and the
244
+ // CLI never spawned again, leaving that session with `No such tool available`
245
+ // for the rest of its life. Nothing in this tree can change that policy, so not
246
+ // dying is the only mechanism available.
247
+ //
248
+ // The boundary is the connect, not a time window, because that is the fact that
249
+ // separates "a live server hit a bad request" from "this server never came up".
250
+ // Masking the second as the first would replace a visible outage with a silent
251
+ // one.
252
+ //
253
+ // * another listener present -> record and STAND DOWN, exactly as before. The
254
+ // email plugin installs its own pair (plugins/email/mcp/src/lib/setup-probe.ts)
255
+ // and deliberately survives errors it attributes to imapflow/nodemailer.
256
+ // The guard does not exit, so disposition=survived; if that handler then
257
+ // exits, the op=exit line that follows is the death record, and the census
258
+ // reads it as dark on its own terms.
259
+ // * sole listener, transport connected -> record and keep serving.
260
+ // * sole listener, no transport -> exit 1, which is Node's own default for an
261
+ // uncaught throw and (Node >= 15) for an unhandled rejection.
262
+ //
263
+ // The stack is written either way: surviving must not cost the diagnosis, which
264
+ // is what Task 2787 exists to preserve.
265
+ function onFatal(event, kind) {
266
+ return (err) => {
267
+ const sole = process.listenerCount(event) === 1;
268
+ const exiting = sole && !transportConnected();
269
+ const d = describeFatal(err);
270
+ // The stack first, so it is on disk before anything else can fail.
271
+ writeFatalStack(kind, d.stack);
272
+ emitLifecycle(`op=fatal session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind} ` +
273
+ `deferred=${sole ? "no" : "yes"} disposition=${exiting ? "exit" : "survived"} ` +
274
+ `error=${JSON.stringify(JSON.stringify({ name: d.name, message: d.message }))}`, "error", false);
275
+ if (exiting)
276
+ process.exit(1);
277
+ };
278
+ }
279
+ process.on("uncaughtException", onFatal("uncaughtException", "uncaught"));
280
+ process.on("unhandledRejection", onFatal("unhandledRejection", "rejection"));
168
281
  // op=exit, emitted once from the process "exit" event. Sync-only — the loop is
169
282
  // stopping. When a catchable signal caused the exit, report code=— signal=<sig>
170
283
  // to match the prior wrapper's format; otherwise code=<exit code> signal=—.
@@ -177,7 +290,7 @@ process.on("exit", (code) => {
177
290
  const codeField = exitSignal ? "—" : String(code);
178
291
  const level = exitSignal || code !== 0 ? "error" : "info";
179
292
  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);
293
+ `code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level, false);
181
294
  });
182
295
  emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
183
296
  // Task 2356 — present argv as a direct `node <entry>` invocation before the
@@ -194,11 +307,20 @@ process.argv = [process.argv[0], ENTRY, ...process.argv.slice(3)];
194
307
  // Run the real MCP server in THIS process. Dynamic import() (not top-level
195
308
  // await — this file compiles to CommonJS) loads the ESM entry; a load-time
196
309
  // failure mirrors the old child spawn-error path (op=error, exit 127). The
197
- // op=exit handler is suppressed on this path so op=error stays the sole record.
310
+ // op=exit handler is suppressed on this path so op=error stays the sole
311
+ // lifecycle record.
312
+ //
313
+ // Task 2787 — this .catch() settles the rejection, so a throw during the
314
+ // entry's module EVALUATION never reaches the uncaughtException guard above.
315
+ // The stack is written here explicitly; without it a boot-time death leaves
316
+ // its message on the op=error line and nothing else — no type, no frames. The
317
+ // op=error line itself is unchanged: `describeFatal().message` is the same
318
+ // value the old inline expression produced.
198
319
  import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
199
- const msg = err instanceof Error ? err.message : String(err);
320
+ const d = describeFatal(err);
200
321
  exitEmitted = true;
201
- emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
322
+ writeFatalStack("import", d.stack);
323
+ emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${d.message}`)}`, "error");
202
324
  process.exit(127);
203
325
  });
204
326
  //# sourceMappingURL=index.js.map
@@ -21,7 +21,7 @@ Returns the parsed JSON-LD object and a ready-to-inline script block string. Inl
21
21
 
22
22
  ### `aeo-write-llms-txt`
23
23
 
24
- Generates the `llms.txt` / `llms-full.txt` pair for the account. Source is every `KnowledgeDocument` for the account that has a `url` property. Returns both files as strings plus a count of pages skipped because they had no URL.
24
+ Generates the `llms.txt` / `llms-full.txt` pair for one site. Pass `siteOrigin` (e.g. `https://maxy.institute`); source is every `KnowledgeDocument` for the account whose `url` starts with it. `llms-full.txt` carries each page's prose from its `:Section` chain, in reading order. Returns both files as strings, plus counts of pages skipped for having no URL, pages skipped as belonging to another site, and pages that carried no full text. If no page carried full text, `llms.txt` is written and `llms-full.txt` is refused rather than filled with the index's own summaries.
25
25
 
26
26
  Wire the output to your site host. Convention: `/llms.txt` (index) and `/llms-full.txt` (concatenated content), served as `text/plain`. Format follows the current draft at `https://llmstxt.org/`.
27
27
 
@@ -68,7 +68,9 @@ Pass `persist: true` plus `targetKnowledgeDocumentId` to write the result as an
68
68
  Every tool emits a single log line per invocation:
69
69
 
70
70
  - `[aeo-emit-jsonld] entityId=… schemaType=… source=graph|inline`
71
- - `[aeo-llms-txt] site=… pages=… skippedNoUrl=… indexBytes=… fullBytes=…`
71
+ - `[aeo-llms-txt] site=… origin=… pages=… skippedNoUrl=… skippedOtherSite=… pagesWithFullText=… pagesWithoutFullText=… sections=… indexBytes=… fullBytes=…`
72
+ - `[aeo-llms-txt] WARN op=full-text-missing pages=… shown=… urls=[…]` — pages that reached the file with only a summary behind them.
73
+ - `[aeo-llms-txt] refuse op=write-full reason=no-full-text-any-page site=…` — `llms-full.txt` was left untouched.
72
74
  - `[aeo-audit] target=… score=… fails=… warns=…`
73
75
 
74
76
  Diagnostic path: `grep -E '^\[aeo-' platform-logs/*.log | grep <urlOrEntityId>`.
@@ -77,7 +79,6 @@ Diagnostic path: `grep -E '^\[aeo-' platform-logs/*.log | grep <urlOrEntityId>`.
77
79
 
78
80
  - **No citation monitor — out of scope.** Tracking whether your brand is cited by Claude / ChatGPT / Perplexity / Gemini would require multi-engine answer harvesting that doesn't fit maxy-code's no-API-key architecture. Archived without sprinting. Check citation manually when needed.
79
81
  - **No auto-emission on page render.** `aeo-emit-jsonld` is callable on demand. Wiring it into the platform's page-generator render path is per-renderer work, filed as a follow-up.
80
- - **No publish-hook regeneration of `llms.txt`.** The tool runs on demand. Hooking it into the publish event is a follow-up.
81
82
 
82
83
  ## See also
83
84
 
@@ -89,7 +89,7 @@ There is no per-account purchase record; the brand decides the shipping set.
89
89
  | Plugin | Type | What it does | Public agent |
90
90
  |--------|------|-------------|-------------|
91
91
  | `teaching` | Skills | Interactive tutoring, lesson planning, and study pack generation from your knowledge base | Yes — all 3 skills serve students and parents |
92
- | `real-agent` | Bundle (13 sub-plugins) | UK estate agency skills — sales, listings, vendor management, buyer management, lead generation, coaching, business operations, teaching, Loop CRM (five value pillars: auto-respond, viewing lifecycle, pipeline mining, listings prospecting, maintenance & preferences), PropertyData market analytics (valuation, sold prices, £/sqft baselines, £/sqft growth, demand-rent, area risk, planning precedent, UPRN matching, property-type distribution), gov.uk EPC floor-area lookup, property brochures, social-share image cards, A4 market reports, and single-address preval packs (full UK address → 4-page A4 PDF covering valuation, area, and demand). 3 specialist roles (negotiator, valuer, compliance) | 4 sub-plugins (estate-sales, buyers, estate-coaching, estate-teaching) |
92
+ | `real-agent` | Bundle (13 sub-plugins) | UK estate agency skills — sales, listings, vendor management, buyer management, lead generation, coaching, business operations, teaching, Loop CRM (five value pillars: auto-respond, viewing lifecycle, pipeline mining, listings prospecting, maintenance & preferences; every read states which Loop API version it reached and can return the raw field set received from Loop, so a figure of zero is never mistaken for one nobody entered), PropertyData market analytics (valuation, sold prices, £/sqft baselines, £/sqft growth, demand-rent, area risk, planning precedent, UPRN matching, property-type distribution), gov.uk EPC floor-area lookup, property brochures, social-share image cards, A4 market reports, and single-address preval packs (full UK address → 4-page A4 PDF covering valuation, area, and demand). 3 specialist roles (negotiator, valuer, compliance) | 4 sub-plugins (estate-sales, buyers, estate-coaching, estate-teaching) |
93
93
  | `writer-craft` | Skills + Agent | Manuscript review and writing craft — story architecture, reader engagement, prose craft, editorial practice, and multi-level review | No — writing craft serves the author |
94
94
  | `venture-studio` | Skills + Agent | Founding-a-business workflow — office-hours discovery, brand pack, zero-to-prototype validation, the full investor data room (business plan, prospectus, term sheet, deck blueprint, A4 print pipeline), and a `legal-essentials` skill that drafts an NDA and a UK-GDPR/PECR privacy policy. Carries citation-routed method references for market sizing (TAM/SAM/SOM), pricing, monetization, competitor analysis, battlecards, strategy frameworks (SWOT/PESTLE/Porter's/Ansoff), and a pre-fundraise strategy red-team. Pre-seeds a `Project` with one `Task` per artefact so nothing gets forgotten. | No — founder-facing only |
95
95
  | `management-consulting` | Skills | 21 MBB-style strategy skills for client engagements — situation assessment, growth-barrier and assumption diagnosis, market mapping, competitive intel, segmentation, profit-pool analysis, strategic options, pricing, business cases, portfolio review, operating-model design, initiative prioritization, transformation roadmaps, war-gaming, risk registers, KPI design, value realization, stakeholder alignment, executive narrative, and decision memos. No MCP server. | No — consultant-facing only |
@@ -25,10 +25,13 @@
25
25
  * - `server.log` via the loopback log-ingest route — best-effort mirror of
26
26
  * the [mcp-helper] lifecycle lines.
27
27
  *
28
- * Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
28
+ * Lifecycle lines, correlation key `session=<id8> server=<name>`:
29
29
  * [mcp-helper] op=spawn ... pid= entry=
30
30
  * [mcp-helper] op=boot ... head=<first stderr bytes>
31
31
  * [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
32
+ * [mcp-helper] op=fatal ... kind=uncaught|rejection deferred=yes|no
33
+ * disposition=survived|exit error=
34
+ * preceded by an `op=fatal-stack` block carrying the full stack (Task 2787).
32
35
  *
33
36
  * Process model (Task 989): the shim IS the server's process. op=exit fires
34
37
  * from process.on("exit"), so it covers a normal exit, a non-zero exit, an
@@ -37,6 +40,17 @@
37
40
  * and leaves no op=exit line — the per-session stderr tail already on disk and
38
41
  * Claude Code's own transport-drop are the evidence for that death mode.
39
42
  *
43
+ * op=exit records THAT a fatal killed the process; it never records WHICH one,
44
+ * because Node's fatal printer writes beneath the tee (Task 2787). The op=fatal
45
+ * pair is what names the error.
46
+ *
47
+ * Task 2788 — a fatal no longer always kills. `disposition=` says what the guard
48
+ * did: the shim exits 1 only when it is the sole listener for the event AND no
49
+ * stdio transport is connected. A fatal on a connected transport is recorded
50
+ * and survived, because Claude Code's policy after a helper dies is one
51
+ * reconnect then stop, so killing a live server removes its whole tool surface
52
+ * for the rest of the session.
53
+ *
40
54
  * The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
41
55
  */
42
56
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -114,14 +128,22 @@ function postToServerLog(suffix, level) {
114
128
  // Claude Code visibility, never re-teed), and a best-effort server.log mirror.
115
129
  // `suffix` is the line body after the tag and carries no newline (the
116
130
  // log-ingest route rejects newlines).
117
- function emitLifecycle(suffix, level) {
131
+ //
132
+ // Task 2787 — `mirror` is false for op=exit and op=fatal. Both fire while the
133
+ // loop is stopping, so the async fetch cannot flush: server.log held 2 op=exit
134
+ // lines against 160 op=spawn and 135 op=boot. The sync raw sink is the
135
+ // authoritative carrier for those two; posting them was a near-total loss
136
+ // dressed as a mirror. op=spawn/op=boot/op=error keep it — they fire while the
137
+ // loop is live and land.
138
+ function emitLifecycle(suffix, level, mirror = true) {
118
139
  const line = `[mcp-helper] ${suffix}\n`;
119
140
  appendSafe(rawSinkPath, line);
120
141
  try {
121
142
  rawStderrWrite(line);
122
143
  }
123
144
  catch { /* stderr closed */ }
124
- postToServerLog(suffix, level);
145
+ if (mirror)
146
+ postToServerLog(suffix, level);
125
147
  }
126
148
  if (!ENTRY) {
127
149
  emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
@@ -165,6 +187,97 @@ function onSignal(sig, code) {
165
187
  process.on("SIGTERM", onSignal("SIGTERM", 143));
166
188
  process.on("SIGINT", onSignal("SIGINT", 130));
167
189
  process.on("SIGHUP", onSignal("SIGHUP", 129));
190
+ // Task 2787 — the fatal guard. Three measured facts drove it here rather than
191
+ // into the 26 plugin entries: Node's default fatal printer writes to fd 2
192
+ // BENEATH the JS `process.stderr.write` the tee replaces, so on both 18 Aug
193
+ // deaths the stack reached neither the raw sink nor Claude Code's own
194
+ // `Server stderr:` capture; the shim is the single seam every entry already
195
+ // loads through; and 26 copies would have to stay in step for ever.
196
+ //
197
+ // The stack is written through appendSafe and rawStderrWrite directly, never
198
+ // through teeWrite — the tee is the thing that was blind to it.
199
+ /** The three fields a fatal contributes. A rejection reason need not be an
200
+ * Error, in which case there is no stack and the stringified reason stands in
201
+ * for all three. */
202
+ function describeFatal(err) {
203
+ if (err instanceof Error) {
204
+ return { name: err.name, message: err.message, stack: err.stack ?? `${err.name}: ${err.message}` };
205
+ }
206
+ const s = String(err);
207
+ return { name: typeof err, message: s, stack: s };
208
+ }
209
+ /** Write a fatal's full stack as its own block, before the lifecycle line that
210
+ * summarises it. Multi-line by nature, which is why it is not a field on that
211
+ * line. Goes through appendSafe and the RAW writer — never teeWrite, which is
212
+ * the thing Node's own fatal printer writes beneath. */
213
+ function writeFatalStack(kind, stack) {
214
+ const block = `[mcp-helper] op=fatal-stack session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind}\n${stack}\n`;
215
+ appendSafe(rawSinkPath, block);
216
+ try {
217
+ rawStderrWrite(block);
218
+ }
219
+ catch { /* stderr closed */ }
220
+ }
221
+ /** Task 2788 — has a stdio transport connected in this process?
222
+ *
223
+ * `server.connect(transport)` calls `StdioServerTransport.start()`, whose body
224
+ * is `this._stdin.on("data", …)`. So a stdin `data` listener exists if and only
225
+ * if a stdio transport has started, and `close()` removes it again — a fatal
226
+ * after the transport closed correctly reads as not connected.
227
+ *
228
+ * Read at the moment of the fatal rather than latched at first connect, so a
229
+ * transport that has since closed is not remembered as live. Nothing is
230
+ * patched: all 26 plugin entries construct a StdioServerTransport and none
231
+ * reads stdin itself, so this listener has exactly one source. The three
232
+ * channel services carry no stdio transport, so every fatal in them still
233
+ * exits — unchanged from before this task. */
234
+ function transportConnected() {
235
+ return process.stdin.listenerCount("data") > 0;
236
+ }
237
+ // Task 2788 — the disposition. `disposition=` names what THIS guard did with
238
+ // the process: `exit` means it called process.exit(1); `survived` means it
239
+ // returned and left the process running.
240
+ //
241
+ // Claude Code owns the spawn (Task 706: no ChildProcess handle; Task 989: the
242
+ // shim IS the server process) and its post-failure policy is one reconnect then
243
+ // stop — measured on 18 Aug, when the retry died the same way 2.6s in and the
244
+ // CLI never spawned again, leaving that session with `No such tool available`
245
+ // for the rest of its life. Nothing in this tree can change that policy, so not
246
+ // dying is the only mechanism available.
247
+ //
248
+ // The boundary is the connect, not a time window, because that is the fact that
249
+ // separates "a live server hit a bad request" from "this server never came up".
250
+ // Masking the second as the first would replace a visible outage with a silent
251
+ // one.
252
+ //
253
+ // * another listener present -> record and STAND DOWN, exactly as before. The
254
+ // email plugin installs its own pair (plugins/email/mcp/src/lib/setup-probe.ts)
255
+ // and deliberately survives errors it attributes to imapflow/nodemailer.
256
+ // The guard does not exit, so disposition=survived; if that handler then
257
+ // exits, the op=exit line that follows is the death record, and the census
258
+ // reads it as dark on its own terms.
259
+ // * sole listener, transport connected -> record and keep serving.
260
+ // * sole listener, no transport -> exit 1, which is Node's own default for an
261
+ // uncaught throw and (Node >= 15) for an unhandled rejection.
262
+ //
263
+ // The stack is written either way: surviving must not cost the diagnosis, which
264
+ // is what Task 2787 exists to preserve.
265
+ function onFatal(event, kind) {
266
+ return (err) => {
267
+ const sole = process.listenerCount(event) === 1;
268
+ const exiting = sole && !transportConnected();
269
+ const d = describeFatal(err);
270
+ // The stack first, so it is on disk before anything else can fail.
271
+ writeFatalStack(kind, d.stack);
272
+ emitLifecycle(`op=fatal session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind} ` +
273
+ `deferred=${sole ? "no" : "yes"} disposition=${exiting ? "exit" : "survived"} ` +
274
+ `error=${JSON.stringify(JSON.stringify({ name: d.name, message: d.message }))}`, "error", false);
275
+ if (exiting)
276
+ process.exit(1);
277
+ };
278
+ }
279
+ process.on("uncaughtException", onFatal("uncaughtException", "uncaught"));
280
+ process.on("unhandledRejection", onFatal("unhandledRejection", "rejection"));
168
281
  // op=exit, emitted once from the process "exit" event. Sync-only — the loop is
169
282
  // stopping. When a catchable signal caused the exit, report code=— signal=<sig>
170
283
  // to match the prior wrapper's format; otherwise code=<exit code> signal=—.
@@ -177,7 +290,7 @@ process.on("exit", (code) => {
177
290
  const codeField = exitSignal ? "—" : String(code);
178
291
  const level = exitSignal || code !== 0 ? "error" : "info";
179
292
  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);
293
+ `code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level, false);
181
294
  });
182
295
  emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
183
296
  // Task 2356 — present argv as a direct `node <entry>` invocation before the
@@ -194,11 +307,20 @@ process.argv = [process.argv[0], ENTRY, ...process.argv.slice(3)];
194
307
  // Run the real MCP server in THIS process. Dynamic import() (not top-level
195
308
  // await — this file compiles to CommonJS) loads the ESM entry; a load-time
196
309
  // failure mirrors the old child spawn-error path (op=error, exit 127). The
197
- // op=exit handler is suppressed on this path so op=error stays the sole record.
310
+ // op=exit handler is suppressed on this path so op=error stays the sole
311
+ // lifecycle record.
312
+ //
313
+ // Task 2787 — this .catch() settles the rejection, so a throw during the
314
+ // entry's module EVALUATION never reaches the uncaughtException guard above.
315
+ // The stack is written here explicitly; without it a boot-time death leaves
316
+ // its message on the op=error line and nothing else — no type, no frames. The
317
+ // op=error line itself is unchanged: `describeFatal().message` is the same
318
+ // value the old inline expression produced.
198
319
  import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
199
- const msg = err instanceof Error ? err.message : String(err);
320
+ const d = describeFatal(err);
200
321
  exitEmitted = true;
201
- emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
322
+ writeFatalStack("import", d.stack);
323
+ emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${d.message}`)}`, "error");
202
324
  process.exit(127);
203
325
  });
204
326
  //# sourceMappingURL=index.js.map
@@ -25,10 +25,13 @@
25
25
  * - `server.log` via the loopback log-ingest route — best-effort mirror of
26
26
  * the [mcp-helper] lifecycle lines.
27
27
  *
28
- * Lifecycle lines, correlation key `session=<id8> server=<name>` — unchanged:
28
+ * Lifecycle lines, correlation key `session=<id8> server=<name>`:
29
29
  * [mcp-helper] op=spawn ... pid= entry=
30
30
  * [mcp-helper] op=boot ... head=<first stderr bytes>
31
31
  * [mcp-helper] op=exit ... code= signal= lifetimeMs= stderr-tail=
32
+ * [mcp-helper] op=fatal ... kind=uncaught|rejection deferred=yes|no
33
+ * disposition=survived|exit error=
34
+ * preceded by an `op=fatal-stack` block carrying the full stack (Task 2787).
32
35
  *
33
36
  * Process model (Task 989): the shim IS the server's process. op=exit fires
34
37
  * from process.on("exit"), so it covers a normal exit, a non-zero exit, an
@@ -37,6 +40,17 @@
37
40
  * and leaves no op=exit line — the per-session stderr tail already on disk and
38
41
  * Claude Code's own transport-drop are the evidence for that death mode.
39
42
  *
43
+ * op=exit records THAT a fatal killed the process; it never records WHICH one,
44
+ * because Node's fatal printer writes beneath the tee (Task 2787). The op=fatal
45
+ * pair is what names the error.
46
+ *
47
+ * Task 2788 — a fatal no longer always kills. `disposition=` says what the guard
48
+ * did: the shim exits 1 only when it is the sole listener for the event AND no
49
+ * stdio transport is connected. A fatal on a connected transport is recorded
50
+ * and survived, because Claude Code's policy after a helper dies is one
51
+ * reconnect then stop, so killing a live server removes its whole tool surface
52
+ * for the rest of the session.
53
+ *
40
54
  * The shim never writes to fd 1 (stdout) — that is the JSON-RPC channel.
41
55
  */
42
56
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -114,14 +128,22 @@ function postToServerLog(suffix, level) {
114
128
  // Claude Code visibility, never re-teed), and a best-effort server.log mirror.
115
129
  // `suffix` is the line body after the tag and carries no newline (the
116
130
  // log-ingest route rejects newlines).
117
- function emitLifecycle(suffix, level) {
131
+ //
132
+ // Task 2787 — `mirror` is false for op=exit and op=fatal. Both fire while the
133
+ // loop is stopping, so the async fetch cannot flush: server.log held 2 op=exit
134
+ // lines against 160 op=spawn and 135 op=boot. The sync raw sink is the
135
+ // authoritative carrier for those two; posting them was a near-total loss
136
+ // dressed as a mirror. op=spawn/op=boot/op=error keep it — they fire while the
137
+ // loop is live and land.
138
+ function emitLifecycle(suffix, level, mirror = true) {
118
139
  const line = `[mcp-helper] ${suffix}\n`;
119
140
  appendSafe(rawSinkPath, line);
120
141
  try {
121
142
  rawStderrWrite(line);
122
143
  }
123
144
  catch { /* stderr closed */ }
124
- postToServerLog(suffix, level);
145
+ if (mirror)
146
+ postToServerLog(suffix, level);
125
147
  }
126
148
  if (!ENTRY) {
127
149
  emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason="no entry given (argv[2] missing)"`, "error");
@@ -165,6 +187,97 @@ function onSignal(sig, code) {
165
187
  process.on("SIGTERM", onSignal("SIGTERM", 143));
166
188
  process.on("SIGINT", onSignal("SIGINT", 130));
167
189
  process.on("SIGHUP", onSignal("SIGHUP", 129));
190
+ // Task 2787 — the fatal guard. Three measured facts drove it here rather than
191
+ // into the 26 plugin entries: Node's default fatal printer writes to fd 2
192
+ // BENEATH the JS `process.stderr.write` the tee replaces, so on both 18 Aug
193
+ // deaths the stack reached neither the raw sink nor Claude Code's own
194
+ // `Server stderr:` capture; the shim is the single seam every entry already
195
+ // loads through; and 26 copies would have to stay in step for ever.
196
+ //
197
+ // The stack is written through appendSafe and rawStderrWrite directly, never
198
+ // through teeWrite — the tee is the thing that was blind to it.
199
+ /** The three fields a fatal contributes. A rejection reason need not be an
200
+ * Error, in which case there is no stack and the stringified reason stands in
201
+ * for all three. */
202
+ function describeFatal(err) {
203
+ if (err instanceof Error) {
204
+ return { name: err.name, message: err.message, stack: err.stack ?? `${err.name}: ${err.message}` };
205
+ }
206
+ const s = String(err);
207
+ return { name: typeof err, message: s, stack: s };
208
+ }
209
+ /** Write a fatal's full stack as its own block, before the lifecycle line that
210
+ * summarises it. Multi-line by nature, which is why it is not a field on that
211
+ * line. Goes through appendSafe and the RAW writer — never teeWrite, which is
212
+ * the thing Node's own fatal printer writes beneath. */
213
+ function writeFatalStack(kind, stack) {
214
+ const block = `[mcp-helper] op=fatal-stack session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind}\n${stack}\n`;
215
+ appendSafe(rawSinkPath, block);
216
+ try {
217
+ rawStderrWrite(block);
218
+ }
219
+ catch { /* stderr closed */ }
220
+ }
221
+ /** Task 2788 — has a stdio transport connected in this process?
222
+ *
223
+ * `server.connect(transport)` calls `StdioServerTransport.start()`, whose body
224
+ * is `this._stdin.on("data", …)`. So a stdin `data` listener exists if and only
225
+ * if a stdio transport has started, and `close()` removes it again — a fatal
226
+ * after the transport closed correctly reads as not connected.
227
+ *
228
+ * Read at the moment of the fatal rather than latched at first connect, so a
229
+ * transport that has since closed is not remembered as live. Nothing is
230
+ * patched: all 26 plugin entries construct a StdioServerTransport and none
231
+ * reads stdin itself, so this listener has exactly one source. The three
232
+ * channel services carry no stdio transport, so every fatal in them still
233
+ * exits — unchanged from before this task. */
234
+ function transportConnected() {
235
+ return process.stdin.listenerCount("data") > 0;
236
+ }
237
+ // Task 2788 — the disposition. `disposition=` names what THIS guard did with
238
+ // the process: `exit` means it called process.exit(1); `survived` means it
239
+ // returned and left the process running.
240
+ //
241
+ // Claude Code owns the spawn (Task 706: no ChildProcess handle; Task 989: the
242
+ // shim IS the server process) and its post-failure policy is one reconnect then
243
+ // stop — measured on 18 Aug, when the retry died the same way 2.6s in and the
244
+ // CLI never spawned again, leaving that session with `No such tool available`
245
+ // for the rest of its life. Nothing in this tree can change that policy, so not
246
+ // dying is the only mechanism available.
247
+ //
248
+ // The boundary is the connect, not a time window, because that is the fact that
249
+ // separates "a live server hit a bad request" from "this server never came up".
250
+ // Masking the second as the first would replace a visible outage with a silent
251
+ // one.
252
+ //
253
+ // * another listener present -> record and STAND DOWN, exactly as before. The
254
+ // email plugin installs its own pair (plugins/email/mcp/src/lib/setup-probe.ts)
255
+ // and deliberately survives errors it attributes to imapflow/nodemailer.
256
+ // The guard does not exit, so disposition=survived; if that handler then
257
+ // exits, the op=exit line that follows is the death record, and the census
258
+ // reads it as dark on its own terms.
259
+ // * sole listener, transport connected -> record and keep serving.
260
+ // * sole listener, no transport -> exit 1, which is Node's own default for an
261
+ // uncaught throw and (Node >= 15) for an unhandled rejection.
262
+ //
263
+ // The stack is written either way: surviving must not cost the diagnosis, which
264
+ // is what Task 2787 exists to preserve.
265
+ function onFatal(event, kind) {
266
+ return (err) => {
267
+ const sole = process.listenerCount(event) === 1;
268
+ const exiting = sole && !transportConnected();
269
+ const d = describeFatal(err);
270
+ // The stack first, so it is on disk before anything else can fail.
271
+ writeFatalStack(kind, d.stack);
272
+ emitLifecycle(`op=fatal session=${SESSION_ID8} server=${SERVER_NAME} kind=${kind} ` +
273
+ `deferred=${sole ? "no" : "yes"} disposition=${exiting ? "exit" : "survived"} ` +
274
+ `error=${JSON.stringify(JSON.stringify({ name: d.name, message: d.message }))}`, "error", false);
275
+ if (exiting)
276
+ process.exit(1);
277
+ };
278
+ }
279
+ process.on("uncaughtException", onFatal("uncaughtException", "uncaught"));
280
+ process.on("unhandledRejection", onFatal("unhandledRejection", "rejection"));
168
281
  // op=exit, emitted once from the process "exit" event. Sync-only — the loop is
169
282
  // stopping. When a catchable signal caused the exit, report code=— signal=<sig>
170
283
  // to match the prior wrapper's format; otherwise code=<exit code> signal=—.
@@ -177,7 +290,7 @@ process.on("exit", (code) => {
177
290
  const codeField = exitSignal ? "—" : String(code);
178
291
  const level = exitSignal || code !== 0 ? "error" : "info";
179
292
  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);
293
+ `code=${codeField} signal=${exitSignal ?? "—"} lifetimeMs=${lifetimeMs} stderr-tail=${JSON.stringify(tail)}`, level, false);
181
294
  });
182
295
  emitLifecycle(`op=spawn session=${SESSION_ID8} server=${SERVER_NAME} pid=${process.pid} entry=${ENTRY}`, "info");
183
296
  // Task 2356 — present argv as a direct `node <entry>` invocation before the
@@ -194,11 +307,20 @@ process.argv = [process.argv[0], ENTRY, ...process.argv.slice(3)];
194
307
  // Run the real MCP server in THIS process. Dynamic import() (not top-level
195
308
  // await — this file compiles to CommonJS) loads the ESM entry; a load-time
196
309
  // failure mirrors the old child spawn-error path (op=error, exit 127). The
197
- // op=exit handler is suppressed on this path so op=error stays the sole record.
310
+ // op=exit handler is suppressed on this path so op=error stays the sole
311
+ // lifecycle record.
312
+ //
313
+ // Task 2787 — this .catch() settles the rejection, so a throw during the
314
+ // entry's module EVALUATION never reaches the uncaughtException guard above.
315
+ // The stack is written here explicitly; without it a boot-time death leaves
316
+ // its message on the op=error line and nothing else — no type, no frames. The
317
+ // op=error line itself is unchanged: `describeFatal().message` is the same
318
+ // value the old inline expression produced.
198
319
  import((0, node_url_1.pathToFileURL)(ENTRY).href).catch((err) => {
199
- const msg = err instanceof Error ? err.message : String(err);
320
+ const d = describeFatal(err);
200
321
  exitEmitted = true;
201
- emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${msg}`)}`, "error");
322
+ writeFatalStack("import", d.stack);
323
+ emitLifecycle(`op=error session=${SESSION_ID8} server=${SERVER_NAME} reason=${JSON.stringify(`import error: ${d.message}`)}`, "error");
202
324
  process.exit(127);
203
325
  });
204
326
  //# sourceMappingURL=index.js.map