@rubytech/create-maxy-code 0.1.58 → 0.1.60
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.
- package/package.json +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/turn-completed-graph-write.test.sh +30 -19
- package/payload/platform/plugins/admin/hooks/turn-completed-graph-write.sh +35 -90
- package/payload/platform/plugins/docs/references/admin-session.md +17 -16
- package/payload/platform/plugins/docs/references/platform.md +3 -3
- package/payload/platform/plugins/docs/references/plugins-guide.md +1 -1
- package/payload/platform/plugins/loop/PLUGIN.md +13 -1
- package/payload/platform/plugins/loop/mcp/dist/index.js +8 -7
- package/payload/platform/plugins/loop/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js +165 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
- package/payload/platform/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/platform/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js +11 -28
- package/payload/platform/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/platform/plugins/loop/mcp/src/index.ts +10 -7
- package/payload/platform/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
- package/payload/platform/plugins/loop/mcp/src/lib/key-store.ts +221 -0
- package/payload/platform/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
- package/payload/platform/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
- package/payload/platform/plugins/loop/mcp/src/tools/key-register.ts +14 -39
- package/payload/platform/plugins/preval/.claude-plugin/plugin.json +8 -0
- package/payload/platform/plugins/preval/PLUGIN.md +39 -0
- package/payload/platform/plugins/preval/skills/property-preval/SKILL.md +78 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/render.py +265 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/template-inputs.schema.json +143 -0
- package/payload/platform/plugins/preval/skills/property-preval/references/template.html +253 -0
- package/payload/platform/plugins/property-data/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/property-data/PLUGIN.md +60 -2
- package/payload/platform/plugins/property-data/mcp/dist/index.js +95 -12
- package/payload/platform/plugins/property-data/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
- package/payload/platform/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.d.ts +10 -0
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js +15 -2
- package/payload/platform/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
- package/payload/platform/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/platform/plugins/property-data/mcp/src/__tests__/endpoints.test.ts +252 -0
- package/payload/platform/plugins/property-data/mcp/src/__tests__/schema-parity.test.ts +16 -2
- package/payload/platform/plugins/property-data/mcp/src/index.ts +171 -11
- package/payload/platform/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
- package/payload/platform/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
- package/payload/platform/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
- package/payload/platform/plugins/property-data/mcp/src/tools/endpoints.ts +22 -2
- package/payload/platform/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
- package/payload/platform/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
- package/payload/platform/plugins/property-data/skills/property-data/SKILL.md +19 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +25 -260
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts +3 -7
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js +6 -32
- package/payload/platform/services/claude-session-manager/dist/jsonl-enumerator.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +6 -24
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +18 -91
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/reaper.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/reaper.js +0 -11
- package/payload/platform/services/claude-session-manager/dist/reaper.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts +0 -21
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-store.js.map +1 -1
- package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
- package/payload/platform/templates/agents/admin/SOUL.md +1 -1
- package/payload/premium-plugins/real-agent/BUNDLE.md +5 -3
- package/payload/premium-plugins/real-agent/agents/negotiator.md +1 -1
- package/payload/premium-plugins/real-agent/agents/valuer.md +1 -1
- package/payload/premium-plugins/real-agent/plugins/.claude-plugin/marketplace.json +5 -0
- package/payload/premium-plugins/real-agent/plugins/loop/PLUGIN.md +13 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js +8 -7
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/index.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js +48 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts +22 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js +165 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js +4 -39
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/lib/loop-api.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js +11 -28
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/index.ts +10 -7
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/file-crypto.ts +54 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/key-store.ts +221 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/lib/loop-api.ts +5 -42
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-deregister.ts +5 -20
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/tools/key-register.ts +14 -39
- package/payload/premium-plugins/real-agent/plugins/preval/.claude-plugin/plugin.json +8 -0
- package/payload/premium-plugins/real-agent/plugins/preval/PLUGIN.md +39 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/SKILL.md +78 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/render.py +265 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template-inputs.schema.json +143 -0
- package/payload/premium-plugins/real-agent/plugins/preval/skills/property-preval/references/template.html +253 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/.claude-plugin/plugin.json +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/PLUGIN.md +60 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js +95 -12
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/index.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts +3 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js +49 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/file-crypto.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts +15 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js +135 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/key-store.js.map +1 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts +0 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js +11 -22
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/lib/propertydata-api.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.d.ts +10 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js +15 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/endpoints.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js +5 -15
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-deregister.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.d.ts.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js +30 -23
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/dist/tools/key-register.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/__tests__/endpoints.test.ts +252 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/__tests__/schema-parity.test.ts +16 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/index.ts +171 -11
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/file-crypto.ts +55 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/key-store.ts +181 -0
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/lib/propertydata-api.ts +9 -24
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/endpoints.ts +22 -2
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-deregister.ts +5 -17
- package/payload/premium-plugins/real-agent/plugins/property-data/mcp/src/tools/key-register.ts +29 -33
- package/payload/premium-plugins/real-agent/plugins/property-data/skills/property-data/SKILL.md +19 -0
- package/payload/server/public/assets/{admin-2ZJmzJ_g.js → admin-Bp-BjBCX.js} +51 -51
- package/payload/server/public/assets/{data-DlmoKxmN.js → data-BGUAGVkV.js} +1 -1
- package/payload/server/public/assets/{graph-BVvcFSEQ.js → graph-MvYxZOBF.js} +1 -1
- package/payload/server/public/assets/{graph-labels-cCvgu38Y.js → graph-labels-D865qb3K.js} +1 -1
- package/payload/server/public/assets/{page-BnAxPkmg.js → page--hOVRrgN.js} +1 -1
- package/payload/server/public/assets/{page-BnaN3u86.js → page-C2b1nlOc.js} +1 -1
- package/payload/server/public/data.html +3 -3
- package/payload/server/public/graph.html +3 -3
- package/payload/server/public/index.html +4 -4
- package/payload/server/server.js +18 -83
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js +0 -196
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js.map +0 -1
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/package.json +0 -7
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Data — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/data-
|
|
8
|
+
<script type="module" crossorigin src="/assets/data-BGUAGVkV.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/brand-BWCtpG7_.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/page
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-D865qb3K.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/page--hOVRrgN.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/brand-BDASZqMG.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Graph — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/graph-
|
|
8
|
+
<script type="module" crossorigin src="/assets/graph-MvYxZOBF.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/brand-BWCtpG7_.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-D865qb3K.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/page-C2b1nlOc.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/brand-BDASZqMG.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-Bp-BjBCX.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/brand-BWCtpG7_.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-D865qb3K.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/device-url-actions-CPoz5fqz.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/page
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/page--hOVRrgN.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/page-C2b1nlOc.js">
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/brand-BDASZqMG.css">
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/admin-CWMpccrR.css">
|
|
17
17
|
<link rel="stylesheet" href="/brand-defaults.css">
|
package/payload/server/server.js
CHANGED
|
@@ -8064,12 +8064,12 @@ async function performSpawnWithInitialMessage(args) {
|
|
|
8064
8064
|
permissionMode: args.permissionMode,
|
|
8065
8065
|
hidden: args.hidden,
|
|
8066
8066
|
specialist: args.specialist,
|
|
8067
|
+
model: args.model,
|
|
8067
8068
|
aboutOwner,
|
|
8068
8069
|
dormantPlugins,
|
|
8069
8070
|
activePlugins,
|
|
8070
8071
|
specialistDomains,
|
|
8071
|
-
tunnelUrl
|
|
8072
|
-
originatingSessionId: args.originatingSessionId
|
|
8072
|
+
tunnelUrl
|
|
8073
8073
|
});
|
|
8074
8074
|
console.log(`${TAG18} forward-spawn-start managerBase=${managerBase2()} bytes=${upstreamPayload.length} hidden=${args.hidden} specialist=${args.specialist ?? "none"}`);
|
|
8075
8075
|
const forwardStart = Date.now();
|
|
@@ -8104,15 +8104,11 @@ async function performSpawnWithInitialMessage(args) {
|
|
|
8104
8104
|
return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
|
|
8105
8105
|
}
|
|
8106
8106
|
var requireAdminSessionUnlessLoopbackSpawn = async (c, next) => {
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
if (isLoopback && !xffPresent) {
|
|
8113
|
-
console.log(`${TAG18} loopback-spawn-bypass remoteAddr=${remoteAddr} xff=absent`);
|
|
8114
|
-
return next();
|
|
8115
|
-
}
|
|
8107
|
+
const remoteAddr = c.env?.incoming?.socket?.remoteAddress ?? "";
|
|
8108
|
+
const isLoopback = remoteAddr === "127.0.0.1" || remoteAddr === "::1" || remoteAddr === "::ffff:127.0.0.1";
|
|
8109
|
+
const hasForwardedFor = !!c.req.header("x-forwarded-for");
|
|
8110
|
+
if (isLoopback && !hasForwardedFor && c.req.method === "POST" && c.req.path === "/api/admin/claude-sessions") {
|
|
8111
|
+
return next();
|
|
8116
8112
|
}
|
|
8117
8113
|
return requireAdminSession(c, next);
|
|
8118
8114
|
};
|
|
@@ -8127,8 +8123,6 @@ app14.post("/", async (c) => {
|
|
|
8127
8123
|
}
|
|
8128
8124
|
let senderId;
|
|
8129
8125
|
let userId;
|
|
8130
|
-
let specialist;
|
|
8131
|
-
let originatingSessionId;
|
|
8132
8126
|
let authSurface;
|
|
8133
8127
|
if (cacheKey) {
|
|
8134
8128
|
authSurface = "cookie";
|
|
@@ -8138,42 +8132,31 @@ app14.post("/", async (c) => {
|
|
|
8138
8132
|
return c.json({ error: "admin-account-not-resolved" }, 500);
|
|
8139
8133
|
}
|
|
8140
8134
|
userId = getUserIdForSession(cacheKey) ?? void 0;
|
|
8141
|
-
specialist = void 0;
|
|
8142
|
-
originatingSessionId = void 0;
|
|
8143
8135
|
} else {
|
|
8144
8136
|
authSurface = "loopback";
|
|
8145
|
-
if (typeof body.
|
|
8146
|
-
|
|
8147
|
-
return c.json({ error: "originating-session-id-required" }, 400);
|
|
8137
|
+
if (typeof body.adminSessionId !== "string" || !UUID_PATTERN.test(body.adminSessionId)) {
|
|
8138
|
+
return c.json({ error: "admin-session-id-required" }, 400);
|
|
8148
8139
|
}
|
|
8149
|
-
|
|
8140
|
+
const lookupSessionId = body.adminSessionId;
|
|
8150
8141
|
const operatorMeta = await fetch(
|
|
8151
|
-
`${managerBase2()}/${encodeURIComponent(
|
|
8142
|
+
`${managerBase2()}/${encodeURIComponent(lookupSessionId)}/meta`
|
|
8152
8143
|
).then((r) => r.ok ? r.json() : null).catch((err) => {
|
|
8153
8144
|
console.error(`${TAG18} fetch-failed op=operator-meta-lookup message=${err instanceof Error ? err.message : String(err)}`);
|
|
8154
8145
|
return null;
|
|
8155
8146
|
});
|
|
8156
8147
|
const operatorSenderId = operatorMeta && typeof operatorMeta.senderId === "string" && operatorMeta.senderId.length > 0 ? operatorMeta.senderId : null;
|
|
8157
8148
|
if (!operatorSenderId) {
|
|
8158
|
-
|
|
8159
|
-
`[turn-recorder] spawn-failed sessionId=${originatingSessionId} reason=originating-session-not-found`
|
|
8160
|
-
);
|
|
8161
|
-
return c.json({ error: "originating-session-not-found" }, 404);
|
|
8149
|
+
return c.json({ error: "admin-session-not-found" }, 404);
|
|
8162
8150
|
}
|
|
8163
8151
|
senderId = operatorSenderId;
|
|
8164
8152
|
userId = void 0;
|
|
8165
|
-
specialist = typeof body.specialist === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(body.specialist) ? body.specialist : "database-operator";
|
|
8166
8153
|
}
|
|
8167
8154
|
const channel = typeof body.channel === "string" ? body.channel : "browser";
|
|
8168
8155
|
const initialMessage = typeof body.initialMessage === "string" && body.initialMessage.trim() ? body.initialMessage : null;
|
|
8169
|
-
const initialMessageBytes = initialMessage ? Buffer.byteLength(initialMessage, "utf8") : 0;
|
|
8170
8156
|
const permissionMode = typeof body.permissionMode === "string" ? body.permissionMode : void 0;
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
}
|
|
8174
|
-
console.log(`[turn-recorder] spawn-request sessionId=${originatingSessionId} specialist=${specialist ?? "none"} initialMessageBytes=${initialMessageBytes}`);
|
|
8175
|
-
}
|
|
8176
|
-
const t0 = Date.now();
|
|
8157
|
+
const specialist = typeof body.specialist === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(body.specialist) ? body.specialist : void 0;
|
|
8158
|
+
const model = typeof body.model === "string" && /^[A-Za-z0-9._-]{1,64}$/.test(body.model) ? body.model : void 0;
|
|
8159
|
+
console.log(`${TAG18} spawn-request-in surface=${authSurface} accountId=${senderId.slice(0, 8)} userId=${userId ? userId.slice(0, 8) : "absent"} channel=${channel} permissionMode=${permissionMode ?? "default"} specialist=${specialist ?? "none"} model=${model ?? "default"} initialMessage=${initialMessage ? "yes" : "no"}`);
|
|
8177
8160
|
const response = await performSpawnWithInitialMessage({
|
|
8178
8161
|
senderId,
|
|
8179
8162
|
userId,
|
|
@@ -8182,41 +8165,10 @@ app14.post("/", async (c) => {
|
|
|
8182
8165
|
permissionMode,
|
|
8183
8166
|
hidden: false,
|
|
8184
8167
|
specialist,
|
|
8185
|
-
|
|
8186
|
-
|
|
8168
|
+
model,
|
|
8169
|
+
initialMessage
|
|
8187
8170
|
});
|
|
8188
|
-
|
|
8189
|
-
const respText = await response.text().catch(() => "");
|
|
8190
|
-
const respStatus = response.status;
|
|
8191
|
-
const replay = new Response(respText, { status: respStatus, headers: response.headers });
|
|
8192
|
-
let parsed = null;
|
|
8193
|
-
try {
|
|
8194
|
-
parsed = JSON.parse(respText);
|
|
8195
|
-
} catch {
|
|
8196
|
-
parsed = null;
|
|
8197
|
-
}
|
|
8198
|
-
if (respStatus >= 200 && respStatus < 300 && parsed && typeof parsed.sessionId === "string") {
|
|
8199
|
-
const recorderSessionId = parsed.sessionId;
|
|
8200
|
-
console.log(
|
|
8201
|
-
`[turn-recorder] spawn-success sessionId=${originatingSessionId} recorderSessionId=${recorderSessionId} pid=${parsed.pid ?? 0} latency-ms=${Date.now() - t0}`
|
|
8202
|
-
);
|
|
8203
|
-
if (initialMessage) {
|
|
8204
|
-
console.log(
|
|
8205
|
-
`[turn-recorder] input-delivered sessionId=${originatingSessionId} recorderSessionId=${recorderSessionId} bytes=${initialMessageBytes} multiline=${initialMessage.includes("\n")}`
|
|
8206
|
-
);
|
|
8207
|
-
}
|
|
8208
|
-
} else {
|
|
8209
|
-
const reasonRaw = parsed && typeof parsed.error === "string" ? parsed.error : "unknown";
|
|
8210
|
-
if (reasonRaw !== "tool-surface-missing" && reasonRaw !== "missing-originating-session-id") {
|
|
8211
|
-
const detail = parsed && typeof parsed.detail === "string" ? parsed.detail.slice(0, 200) : "";
|
|
8212
|
-
console.log(
|
|
8213
|
-
`[turn-recorder] spawn-failed sessionId=${originatingSessionId} reason=manager-spawn http=${respStatus} err=${JSON.stringify(detail || reasonRaw)}`
|
|
8214
|
-
);
|
|
8215
|
-
}
|
|
8216
|
-
}
|
|
8217
|
-
return replay;
|
|
8218
|
-
}
|
|
8219
|
-
console.log(`${TAG18} route-done surface=cookie status=${response.status} route-ms=${Date.now() - routeStart}`);
|
|
8171
|
+
console.log(`${TAG18} route-done surface=${authSurface} status=${response.status} route-ms=${Date.now() - routeStart}`);
|
|
8220
8172
|
return response;
|
|
8221
8173
|
});
|
|
8222
8174
|
app14.get("/events", async (c) => {
|
|
@@ -8343,23 +8295,6 @@ app14.get("/:sessionId/meta", async (c) => {
|
|
|
8343
8295
|
if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
|
|
8344
8296
|
return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
|
|
8345
8297
|
});
|
|
8346
|
-
app14.patch("/:sessionId", async (c) => {
|
|
8347
|
-
const sessionId = c.req.param("sessionId");
|
|
8348
|
-
const body = await c.req.text();
|
|
8349
|
-
const upstream = await fetch(
|
|
8350
|
-
`${managerBase2()}/${encodeURIComponent(sessionId)}`,
|
|
8351
|
-
{
|
|
8352
|
-
method: "PATCH",
|
|
8353
|
-
headers: { "content-type": "application/json" },
|
|
8354
|
-
body
|
|
8355
|
-
}
|
|
8356
|
-
).catch((err) => {
|
|
8357
|
-
console.error(`${TAG18} fetch-failed op=patch message=${err instanceof Error ? err.message : String(err)}`);
|
|
8358
|
-
return null;
|
|
8359
|
-
});
|
|
8360
|
-
if (!upstream) return c.json({ error: "manager-unreachable" }, 503);
|
|
8361
|
-
return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
|
|
8362
|
-
});
|
|
8363
8298
|
app14.post("/:sessionId/input", async (c) => {
|
|
8364
8299
|
const sessionId = c.req.param("sessionId");
|
|
8365
8300
|
const rawBody = await c.req.text();
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP server stderr tee — dual-destination log capture.
|
|
3
|
-
*
|
|
4
|
-
* Claude Code spawns MCP servers as child processes and consumes their stderr
|
|
5
|
-
* internally. The platform cannot intercept at the spawn level. Each server
|
|
6
|
-
* must tee its own stderr so diagnostic output is retrievable.
|
|
7
|
-
*
|
|
8
|
-
* ┌─────────────────────────┐
|
|
9
|
-
* │ MCP server process │
|
|
10
|
-
* │ │
|
|
11
|
-
* │ console.error("[x] ..") │
|
|
12
|
-
* │ │ │
|
|
13
|
-
* │ ▼ │
|
|
14
|
-
* │ patched stderr.write() │
|
|
15
|
-
* │ │ │
|
|
16
|
-
* │ ├──► original stderr (consumed by Claude Code — opaque)
|
|
17
|
-
* │ │
|
|
18
|
-
* │ ├──► mcp-{name}-stderr-{YYYY-MM-DD}.log (raw chunks, per-plugin)
|
|
19
|
-
* │ │
|
|
20
|
-
* │ └──► $STREAM_LOG_PATH (per-line, prefixed)
|
|
21
|
-
* │ "[<iso>] [mcp:{name}] <line>"
|
|
22
|
-
* └─────────────────────────┘
|
|
23
|
-
*
|
|
24
|
-
* $STREAM_LOG_PATH is set by the spawner (`getMcpServers` in `claude-agent.ts`)
|
|
25
|
-
* to the per-conversation stream log file. The MCP server code itself knows
|
|
26
|
-
* nothing about conversations — it just trusts the spawner's path. This is
|
|
27
|
-
* the scope boundary introduced: the tee is attached per spawn,
|
|
28
|
-
* not per MCP-server process lifetime. Servers spawned for conversation A
|
|
29
|
-
* write to conversation A's file; servers for B write to B's file.
|
|
30
|
-
*
|
|
31
|
-
* Every decision is logged via `[mcp-tee-*]` markers on both the target file
|
|
32
|
-
* and the original stderr so an investigator can confirm from the stream log
|
|
33
|
-
* which tees were wired up, which were skipped, and why.
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Patch process.stderr.write to tee to:
|
|
37
|
-
* 1. Per-server raw log (`mcp-<serverName>-stderr-<date>.log` under LOG_DIR).
|
|
38
|
-
* 2. The per-conversation stream log at `STREAM_LOG_PATH` — per-line, prefixed.
|
|
39
|
-
* 3. The original stderr (consumed by Claude Code) — always preserved.
|
|
40
|
-
*
|
|
41
|
-
* LOG_DIR absent → skip per-server raw file (dev mode / tool discovery).
|
|
42
|
-
* STREAM_LOG_PATH absent → skip stream-log destination (older spawner or
|
|
43
|
-
* standalone invocation). In both absent cases, stderr works unchanged —
|
|
44
|
-
* a `[mcp-tee-skip]` marker is written to original stderr so the skip is
|
|
45
|
-
* visible to journalctl-level readers.
|
|
46
|
-
*
|
|
47
|
-
* Safe to call once at MCP server module load. Refused on second call to
|
|
48
|
-
* prevent stacking patches.
|
|
49
|
-
*/
|
|
50
|
-
export declare function initStderrTee(serverName: string): void;
|
|
51
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAeH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CA8ItD"}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MCP server stderr tee — dual-destination log capture.
|
|
4
|
-
*
|
|
5
|
-
* Claude Code spawns MCP servers as child processes and consumes their stderr
|
|
6
|
-
* internally. The platform cannot intercept at the spawn level. Each server
|
|
7
|
-
* must tee its own stderr so diagnostic output is retrievable.
|
|
8
|
-
*
|
|
9
|
-
* ┌─────────────────────────┐
|
|
10
|
-
* │ MCP server process │
|
|
11
|
-
* │ │
|
|
12
|
-
* │ console.error("[x] ..") │
|
|
13
|
-
* │ │ │
|
|
14
|
-
* │ ▼ │
|
|
15
|
-
* │ patched stderr.write() │
|
|
16
|
-
* │ │ │
|
|
17
|
-
* │ ├──► original stderr (consumed by Claude Code — opaque)
|
|
18
|
-
* │ │
|
|
19
|
-
* │ ├──► mcp-{name}-stderr-{YYYY-MM-DD}.log (raw chunks, per-plugin)
|
|
20
|
-
* │ │
|
|
21
|
-
* │ └──► $STREAM_LOG_PATH (per-line, prefixed)
|
|
22
|
-
* │ "[<iso>] [mcp:{name}] <line>"
|
|
23
|
-
* └─────────────────────────┘
|
|
24
|
-
*
|
|
25
|
-
* $STREAM_LOG_PATH is set by the spawner (`getMcpServers` in `claude-agent.ts`)
|
|
26
|
-
* to the per-conversation stream log file. The MCP server code itself knows
|
|
27
|
-
* nothing about conversations — it just trusts the spawner's path. This is
|
|
28
|
-
* the scope boundary introduced: the tee is attached per spawn,
|
|
29
|
-
* not per MCP-server process lifetime. Servers spawned for conversation A
|
|
30
|
-
* write to conversation A's file; servers for B write to B's file.
|
|
31
|
-
*
|
|
32
|
-
* Every decision is logged via `[mcp-tee-*]` markers on both the target file
|
|
33
|
-
* and the original stderr so an investigator can confirm from the stream log
|
|
34
|
-
* which tees were wired up, which were skipped, and why.
|
|
35
|
-
*/
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.initStderrTee = initStderrTee;
|
|
38
|
-
const node_fs_1 = require("node:fs");
|
|
39
|
-
const node_path_1 = require("node:path");
|
|
40
|
-
const node_string_decoder_1 = require("node:string_decoder");
|
|
41
|
-
// Marker on process.stderr.write so repeat calls to initStderrTee() are
|
|
42
|
-
// detected at runtime, not just warned about in the docstring. A second
|
|
43
|
-
// call would stack patches and double-log every chunk.
|
|
44
|
-
const INIT_MARKER = Symbol.for("maxy.mcpStderrTee.installed");
|
|
45
|
-
/**
|
|
46
|
-
* Patch process.stderr.write to tee to:
|
|
47
|
-
* 1. Per-server raw log (`mcp-<serverName>-stderr-<date>.log` under LOG_DIR).
|
|
48
|
-
* 2. The per-conversation stream log at `STREAM_LOG_PATH` — per-line, prefixed.
|
|
49
|
-
* 3. The original stderr (consumed by Claude Code) — always preserved.
|
|
50
|
-
*
|
|
51
|
-
* LOG_DIR absent → skip per-server raw file (dev mode / tool discovery).
|
|
52
|
-
* STREAM_LOG_PATH absent → skip stream-log destination (older spawner or
|
|
53
|
-
* standalone invocation). In both absent cases, stderr works unchanged —
|
|
54
|
-
* a `[mcp-tee-skip]` marker is written to original stderr so the skip is
|
|
55
|
-
* visible to journalctl-level readers.
|
|
56
|
-
*
|
|
57
|
-
* Safe to call once at MCP server module load. Refused on second call to
|
|
58
|
-
* prevent stacking patches.
|
|
59
|
-
*/
|
|
60
|
-
function initStderrTee(serverName) {
|
|
61
|
-
const logDir = process.env.LOG_DIR;
|
|
62
|
-
const streamLogPath = process.env.STREAM_LOG_PATH;
|
|
63
|
-
// Refuse repeat patches — stacking them would double-log every chunk
|
|
64
|
-
// and corrupt the re-entrancy guard (originalWrite would capture the
|
|
65
|
-
// already-patched function on the second call).
|
|
66
|
-
if (process.stderr.write[INIT_MARKER])
|
|
67
|
-
return;
|
|
68
|
-
// Keep a direct reference to the unpatched writer. All diagnostic output
|
|
69
|
-
// from inside this module MUST go through originalWrite to avoid
|
|
70
|
-
// re-entering the patched writer (which would recurse on a tee failure).
|
|
71
|
-
const originalWrite = process.stderr.write.bind(process.stderr);
|
|
72
|
-
const tsPrefix = () => `[${new Date().toISOString()}]`;
|
|
73
|
-
const skipTee = (reason, destination) => {
|
|
74
|
-
originalWrite(`${tsPrefix()} [platform] [mcp-tee-skip] server=${serverName} destination=${destination} reason=${JSON.stringify(reason)}\n`);
|
|
75
|
-
};
|
|
76
|
-
// --- Destination 1: per-server raw file (optional, existing behaviour)
|
|
77
|
-
let perServerStream;
|
|
78
|
-
if (logDir) {
|
|
79
|
-
try {
|
|
80
|
-
(0, node_fs_1.mkdirSync)(logDir, { recursive: true });
|
|
81
|
-
const date = new Date().toISOString().slice(0, 10);
|
|
82
|
-
perServerStream = (0, node_fs_1.createWriteStream)((0, node_path_1.resolve)(logDir, `mcp-${serverName}-stderr-${date}.log`), { flags: "a" });
|
|
83
|
-
perServerStream.on("error", (err) => {
|
|
84
|
-
originalWrite(`${tsPrefix()} [platform] [mcp-tee-error] server=${serverName} destination=per-server reason=${JSON.stringify(err.message)}\n`);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
89
|
-
skipTee(msg, "per-server");
|
|
90
|
-
perServerStream = undefined;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
skipTee("LOG_DIR not set", "per-server");
|
|
95
|
-
}
|
|
96
|
-
// --- Destination 2: per-conversation stream log
|
|
97
|
-
let streamLogStream;
|
|
98
|
-
if (streamLogPath) {
|
|
99
|
-
try {
|
|
100
|
-
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(streamLogPath), { recursive: true });
|
|
101
|
-
const s = (0, node_fs_1.createWriteStream)(streamLogPath, { flags: "a" });
|
|
102
|
-
s.on("error", (err) => {
|
|
103
|
-
originalWrite(`${tsPrefix()} [platform] [mcp-tee-error] server=${serverName} destination=stream-log reason=${JSON.stringify(err.message)}\n`);
|
|
104
|
-
});
|
|
105
|
-
streamLogStream = s;
|
|
106
|
-
// Attach marker lands in the stream log itself so investigators can
|
|
107
|
-
// confirm per-conversation the tee was wired up.
|
|
108
|
-
s.write(`${tsPrefix()} [platform] [mcp-tee-attach] server=${serverName} streamLogPath=${streamLogPath}\n`);
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
112
|
-
skipTee(msg, "stream-log");
|
|
113
|
-
streamLogStream = undefined;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
skipTee("STREAM_LOG_PATH not set", "stream-log");
|
|
118
|
-
}
|
|
119
|
-
// If neither tee target is available, leave stderr untouched — patching
|
|
120
|
-
// the writer to a no-op tee would still consume event-loop cycles on
|
|
121
|
-
// every write for zero observability gain.
|
|
122
|
-
if (!perServerStream && !streamLogStream) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// Line buffer — accumulates characters written to stderr so complete
|
|
126
|
-
// newline-terminated lines can be prefixed and emitted to the stream log.
|
|
127
|
-
// Partial chunks are held until a newline arrives (or beforeExit flushes).
|
|
128
|
-
let lineBuffer = "";
|
|
129
|
-
// StringDecoder buffers trailing UTF-8 continuation bytes across chunks.
|
|
130
|
-
// Without it, a multi-byte codepoint that straddles a write boundary would
|
|
131
|
-
// render as two U+FFFD replacement characters in the stream log. Only
|
|
132
|
-
// matters when a caller writes Uint8Array chunks directly — console.error
|
|
133
|
-
// produces strings — but plugins piping child-process stderr can hit this.
|
|
134
|
-
const utf8 = new node_string_decoder_1.StringDecoder("utf8");
|
|
135
|
-
const emitCompleteLinesToStreamLog = (chunk) => {
|
|
136
|
-
if (!streamLogStream)
|
|
137
|
-
return;
|
|
138
|
-
lineBuffer += chunk;
|
|
139
|
-
let newlineIndex;
|
|
140
|
-
// eslint-disable-next-line no-cond-assign
|
|
141
|
-
while ((newlineIndex = lineBuffer.indexOf("\n")) !== -1) {
|
|
142
|
-
const line = lineBuffer.slice(0, newlineIndex);
|
|
143
|
-
lineBuffer = lineBuffer.slice(newlineIndex + 1);
|
|
144
|
-
if (line.length === 0)
|
|
145
|
-
continue; // skip blank lines
|
|
146
|
-
if (streamLogStream.destroyed || streamLogStream.writableEnded)
|
|
147
|
-
continue;
|
|
148
|
-
streamLogStream.write(`${tsPrefix()} [mcp:${serverName}] ${line}\n`);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
process.stderr.write = (chunk, ...args) => {
|
|
152
|
-
// 1. Per-server raw file — behaviour (no prefix).
|
|
153
|
-
if (perServerStream && !perServerStream.destroyed) {
|
|
154
|
-
perServerStream.write(chunk);
|
|
155
|
-
}
|
|
156
|
-
// 2. Stream log — per-line, prefixed.
|
|
157
|
-
if (streamLogStream) {
|
|
158
|
-
try {
|
|
159
|
-
const text = typeof chunk === "string"
|
|
160
|
-
? chunk
|
|
161
|
-
: utf8.write(Buffer.from(chunk));
|
|
162
|
-
emitCompleteLinesToStreamLog(text);
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
166
|
-
originalWrite(`${tsPrefix()} [platform] [mcp-tee-emit-error] server=${serverName} reason=${JSON.stringify(msg)}\n`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
// 3. Original stderr — Claude Code still gets what it's always got.
|
|
170
|
-
return originalWrite(chunk, ...args);
|
|
171
|
-
};
|
|
172
|
-
// Mark the patch so a second initStderrTee() call is refused at the top.
|
|
173
|
-
process.stderr.write[INIT_MARKER] = true;
|
|
174
|
-
// Flush any trailing unterminated segment on graceful event-loop drain.
|
|
175
|
-
// `beforeExit` can fire repeatedly: each async write to `streamLogStream`
|
|
176
|
-
// schedules I/O that keeps the event loop alive, which drains, which fires
|
|
177
|
-
// `beforeExit` again. With N MCP servers attached, the handler can emit
|
|
178
|
-
// thousands of detach lines per second. The `detached` flag gates the
|
|
179
|
-
// drain+detach emission to a single invocation; subsequent firings are
|
|
180
|
-
// no-ops. Buffer flushing also runs only once — partial-line state at true
|
|
181
|
-
// process exit doesn't change across re-fires.
|
|
182
|
-
let detached = false;
|
|
183
|
-
process.on("beforeExit", () => {
|
|
184
|
-
if (detached)
|
|
185
|
-
return;
|
|
186
|
-
detached = true;
|
|
187
|
-
if (streamLogStream && !streamLogStream.destroyed && !streamLogStream.writableEnded) {
|
|
188
|
-
if (lineBuffer.length > 0) {
|
|
189
|
-
streamLogStream.write(`${tsPrefix()} [mcp:${serverName}] ${lineBuffer}\n`);
|
|
190
|
-
}
|
|
191
|
-
streamLogStream.write(`${tsPrefix()} [platform] [mcp-tee-detach] server=${serverName} reason=process-before-exit\n`);
|
|
192
|
-
}
|
|
193
|
-
lineBuffer = "";
|
|
194
|
-
});
|
|
195
|
-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