@uvl000/claude-trace 3.0.13-workflowexp.1

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 (258) hide show
  1. package/README.md +477 -0
  2. package/README.zh-CN.md +477 -0
  3. package/dist/adapt/api-format.d.ts +41 -0
  4. package/dist/adapt/api-format.d.ts.map +1 -0
  5. package/dist/adapt/api-format.js +132 -0
  6. package/dist/adapt/api-format.js.map +1 -0
  7. package/dist/adapt/openai-adapter.d.ts +123 -0
  8. package/dist/adapt/openai-adapter.d.ts.map +1 -0
  9. package/dist/adapt/openai-adapter.js +628 -0
  10. package/dist/adapt/openai-adapter.js.map +1 -0
  11. package/dist/cli/cli-common.d.ts +73 -0
  12. package/dist/cli/cli-common.d.ts.map +1 -0
  13. package/dist/cli/cli-common.js +189 -0
  14. package/dist/cli/cli-common.js.map +1 -0
  15. package/dist/cli/cli.d.ts +23 -0
  16. package/dist/cli/cli.d.ts.map +1 -0
  17. package/dist/cli/cli.js +175 -0
  18. package/dist/cli/cli.js.map +1 -0
  19. package/dist/cli/codex-cli.d.ts +24 -0
  20. package/dist/cli/codex-cli.d.ts.map +1 -0
  21. package/dist/cli/codex-cli.js +146 -0
  22. package/dist/cli/codex-cli.js.map +1 -0
  23. package/dist/cli/opencode-cli.d.ts +23 -0
  24. package/dist/cli/opencode-cli.d.ts.map +1 -0
  25. package/dist/cli/opencode-cli.js +156 -0
  26. package/dist/cli/opencode-cli.js.map +1 -0
  27. package/dist/cli/trace-runner.d.ts +21 -0
  28. package/dist/cli/trace-runner.d.ts.map +1 -0
  29. package/dist/cli/trace-runner.js +282 -0
  30. package/dist/cli/trace-runner.js.map +1 -0
  31. package/dist/cli/validate-trace.d.ts +30 -0
  32. package/dist/cli/validate-trace.d.ts.map +1 -0
  33. package/dist/cli/validate-trace.js +230 -0
  34. package/dist/cli/validate-trace.js.map +1 -0
  35. package/dist/cli/verify-offline-bundle.d.ts +13 -0
  36. package/dist/cli/verify-offline-bundle.d.ts.map +1 -0
  37. package/dist/cli/verify-offline-bundle.js +89 -0
  38. package/dist/cli/verify-offline-bundle.js.map +1 -0
  39. package/dist/cli/vibe-coding-proxy-cli.d.ts +12 -0
  40. package/dist/cli/vibe-coding-proxy-cli.d.ts.map +1 -0
  41. package/dist/cli/vibe-coding-proxy-cli.js +218 -0
  42. package/dist/cli/vibe-coding-proxy-cli.js.map +1 -0
  43. package/dist/config/claude-config-overlay.d.ts +69 -0
  44. package/dist/config/claude-config-overlay.d.ts.map +1 -0
  45. package/dist/config/claude-config-overlay.js +229 -0
  46. package/dist/config/claude-config-overlay.js.map +1 -0
  47. package/dist/config/codex-config-overlay.d.ts +122 -0
  48. package/dist/config/codex-config-overlay.d.ts.map +1 -0
  49. package/dist/config/codex-config-overlay.js +352 -0
  50. package/dist/config/codex-config-overlay.js.map +1 -0
  51. package/dist/index.d.ts +15 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +37 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/intercept/forward-proxy.d.ts +77 -0
  56. package/dist/intercept/forward-proxy.d.ts.map +1 -0
  57. package/dist/intercept/forward-proxy.js +368 -0
  58. package/dist/intercept/forward-proxy.js.map +1 -0
  59. package/dist/intercept/header-redaction.d.ts +7 -0
  60. package/dist/intercept/header-redaction.d.ts.map +1 -0
  61. package/dist/intercept/header-redaction.js +28 -0
  62. package/dist/intercept/header-redaction.js.map +1 -0
  63. package/dist/intercept/interceptor-loader.js +26 -0
  64. package/dist/intercept/interceptor.d.ts +164 -0
  65. package/dist/intercept/interceptor.d.ts.map +1 -0
  66. package/dist/intercept/interceptor.js +496 -0
  67. package/dist/intercept/interceptor.js.map +1 -0
  68. package/dist/intercept/mitm-cert.d.ts +53 -0
  69. package/dist/intercept/mitm-cert.d.ts.map +1 -0
  70. package/dist/intercept/mitm-cert.js +259 -0
  71. package/dist/intercept/mitm-cert.js.map +1 -0
  72. package/dist/intercept/proxy-log-writer.d.ts +77 -0
  73. package/dist/intercept/proxy-log-writer.d.ts.map +1 -0
  74. package/dist/intercept/proxy-log-writer.js +323 -0
  75. package/dist/intercept/proxy-log-writer.js.map +1 -0
  76. package/dist/intercept/proxy-targets.d.ts +69 -0
  77. package/dist/intercept/proxy-targets.d.ts.map +1 -0
  78. package/dist/intercept/proxy-targets.js +129 -0
  79. package/dist/intercept/proxy-targets.js.map +1 -0
  80. package/dist/intercept/reverse-proxy.d.ts +191 -0
  81. package/dist/intercept/reverse-proxy.d.ts.map +1 -0
  82. package/dist/intercept/reverse-proxy.js +807 -0
  83. package/dist/intercept/reverse-proxy.js.map +1 -0
  84. package/dist/intercept/token-extractor.js +28 -0
  85. package/dist/report/html-generator.d.ts +96 -0
  86. package/dist/report/html-generator.d.ts.map +1 -0
  87. package/dist/report/html-generator.js +225 -0
  88. package/dist/report/html-generator.js.map +1 -0
  89. package/dist/report/index-generator.d.ts +89 -0
  90. package/dist/report/index-generator.d.ts.map +1 -0
  91. package/dist/report/index-generator.js +319 -0
  92. package/dist/report/index-generator.js.map +1 -0
  93. package/dist/report/shared-conversation-processor.d.ts +200 -0
  94. package/dist/report/shared-conversation-processor.d.ts.map +1 -0
  95. package/dist/report/shared-conversation-processor.js +720 -0
  96. package/dist/report/shared-conversation-processor.js.map +1 -0
  97. package/dist/routing/codex-routing.d.ts +40 -0
  98. package/dist/routing/codex-routing.d.ts.map +1 -0
  99. package/dist/routing/codex-routing.js +96 -0
  100. package/dist/routing/codex-routing.js.map +1 -0
  101. package/dist/routing/proxy-routing.d.ts +48 -0
  102. package/dist/routing/proxy-routing.d.ts.map +1 -0
  103. package/dist/routing/proxy-routing.js +113 -0
  104. package/dist/routing/proxy-routing.js.map +1 -0
  105. package/dist/tools/binary-utils.d.ts +29 -0
  106. package/dist/tools/binary-utils.d.ts.map +1 -0
  107. package/dist/tools/binary-utils.js +134 -0
  108. package/dist/tools/binary-utils.js.map +1 -0
  109. package/dist/tools/claude.d.ts +61 -0
  110. package/dist/tools/claude.d.ts.map +1 -0
  111. package/dist/tools/claude.js +449 -0
  112. package/dist/tools/claude.js.map +1 -0
  113. package/dist/tools/codex.d.ts +70 -0
  114. package/dist/tools/codex.d.ts.map +1 -0
  115. package/dist/tools/codex.js +492 -0
  116. package/dist/tools/codex.js.map +1 -0
  117. package/dist/tools/opencode.d.ts +85 -0
  118. package/dist/tools/opencode.d.ts.map +1 -0
  119. package/dist/tools/opencode.js +401 -0
  120. package/dist/tools/opencode.js.map +1 -0
  121. package/dist/tools/types.d.ts +91 -0
  122. package/dist/tools/types.d.ts.map +1 -0
  123. package/dist/tools/types.js +11 -0
  124. package/dist/tools/types.js.map +1 -0
  125. package/dist/types.d.ts +158 -0
  126. package/dist/types.d.ts.map +1 -0
  127. package/dist/types.js +12 -0
  128. package/dist/types.js.map +1 -0
  129. package/frontend/dist/index.global.js +1551 -0
  130. package/frontend/dist/styles.css +1027 -0
  131. package/frontend/template.html +19 -0
  132. package/node_modules/agent-base/LICENSE +22 -0
  133. package/node_modules/agent-base/README.md +69 -0
  134. package/node_modules/agent-base/dist/helpers.d.ts +15 -0
  135. package/node_modules/agent-base/dist/helpers.d.ts.map +1 -0
  136. package/node_modules/agent-base/dist/helpers.js +66 -0
  137. package/node_modules/agent-base/dist/helpers.js.map +1 -0
  138. package/node_modules/agent-base/dist/index.d.ts +41 -0
  139. package/node_modules/agent-base/dist/index.d.ts.map +1 -0
  140. package/node_modules/agent-base/dist/index.js +178 -0
  141. package/node_modules/agent-base/dist/index.js.map +1 -0
  142. package/node_modules/agent-base/package.json +46 -0
  143. package/node_modules/debug/LICENSE +20 -0
  144. package/node_modules/debug/README.md +481 -0
  145. package/node_modules/debug/package.json +64 -0
  146. package/node_modules/debug/src/browser.js +272 -0
  147. package/node_modules/debug/src/common.js +292 -0
  148. package/node_modules/debug/src/index.js +10 -0
  149. package/node_modules/debug/src/node.js +263 -0
  150. package/node_modules/http-proxy-agent/LICENSE +22 -0
  151. package/node_modules/http-proxy-agent/README.md +44 -0
  152. package/node_modules/http-proxy-agent/dist/index.d.ts +44 -0
  153. package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -0
  154. package/node_modules/http-proxy-agent/dist/index.js +148 -0
  155. package/node_modules/http-proxy-agent/dist/index.js.map +1 -0
  156. package/node_modules/http-proxy-agent/package.json +47 -0
  157. package/node_modules/https-proxy-agent/LICENSE +22 -0
  158. package/node_modules/https-proxy-agent/README.md +70 -0
  159. package/node_modules/https-proxy-agent/dist/index.d.ts +47 -0
  160. package/node_modules/https-proxy-agent/dist/index.d.ts.map +1 -0
  161. package/node_modules/https-proxy-agent/dist/index.js +180 -0
  162. package/node_modules/https-proxy-agent/dist/index.js.map +1 -0
  163. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +15 -0
  164. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts.map +1 -0
  165. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +101 -0
  166. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
  167. package/node_modules/https-proxy-agent/package.json +50 -0
  168. package/node_modules/ms/index.js +162 -0
  169. package/node_modules/ms/license.md +21 -0
  170. package/node_modules/ms/package.json +38 -0
  171. package/node_modules/ms/readme.md +59 -0
  172. package/node_modules/node-forge/LICENSE +331 -0
  173. package/node_modules/node-forge/README.md +2071 -0
  174. package/node_modules/node-forge/dist/forge.all.min.js +2 -0
  175. package/node_modules/node-forge/dist/forge.all.min.js.map +1 -0
  176. package/node_modules/node-forge/dist/forge.min.js +2 -0
  177. package/node_modules/node-forge/dist/forge.min.js.map +1 -0
  178. package/node_modules/node-forge/dist/prime.worker.min.js +2 -0
  179. package/node_modules/node-forge/dist/prime.worker.min.js.map +1 -0
  180. package/node_modules/node-forge/flash/swf/SocketPool.swf +0 -0
  181. package/node_modules/node-forge/lib/aes.js +1091 -0
  182. package/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
  183. package/node_modules/node-forge/lib/asn1-validator.js +91 -0
  184. package/node_modules/node-forge/lib/asn1.js +1503 -0
  185. package/node_modules/node-forge/lib/baseN.js +186 -0
  186. package/node_modules/node-forge/lib/cipher.js +230 -0
  187. package/node_modules/node-forge/lib/cipherModes.js +999 -0
  188. package/node_modules/node-forge/lib/des.js +496 -0
  189. package/node_modules/node-forge/lib/ed25519.js +1091 -0
  190. package/node_modules/node-forge/lib/forge.js +13 -0
  191. package/node_modules/node-forge/lib/form.js +149 -0
  192. package/node_modules/node-forge/lib/hmac.js +146 -0
  193. package/node_modules/node-forge/lib/http.js +1346 -0
  194. package/node_modules/node-forge/lib/index.all.js +16 -0
  195. package/node_modules/node-forge/lib/index.js +33 -0
  196. package/node_modules/node-forge/lib/jsbn.js +1294 -0
  197. package/node_modules/node-forge/lib/kem.js +168 -0
  198. package/node_modules/node-forge/lib/log.js +319 -0
  199. package/node_modules/node-forge/lib/md.all.js +13 -0
  200. package/node_modules/node-forge/lib/md.js +11 -0
  201. package/node_modules/node-forge/lib/md5.js +289 -0
  202. package/node_modules/node-forge/lib/mgf.js +12 -0
  203. package/node_modules/node-forge/lib/mgf1.js +57 -0
  204. package/node_modules/node-forge/lib/oids.js +180 -0
  205. package/node_modules/node-forge/lib/pbe.js +1023 -0
  206. package/node_modules/node-forge/lib/pbkdf2.js +211 -0
  207. package/node_modules/node-forge/lib/pem.js +237 -0
  208. package/node_modules/node-forge/lib/pkcs1.js +276 -0
  209. package/node_modules/node-forge/lib/pkcs12.js +1078 -0
  210. package/node_modules/node-forge/lib/pkcs7.js +1260 -0
  211. package/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
  212. package/node_modules/node-forge/lib/pki.js +102 -0
  213. package/node_modules/node-forge/lib/prime.js +297 -0
  214. package/node_modules/node-forge/lib/prime.worker.js +168 -0
  215. package/node_modules/node-forge/lib/prng.js +419 -0
  216. package/node_modules/node-forge/lib/pss.js +241 -0
  217. package/node_modules/node-forge/lib/random.js +191 -0
  218. package/node_modules/node-forge/lib/rc2.js +410 -0
  219. package/node_modules/node-forge/lib/rsa.js +1968 -0
  220. package/node_modules/node-forge/lib/sha1.js +319 -0
  221. package/node_modules/node-forge/lib/sha256.js +327 -0
  222. package/node_modules/node-forge/lib/sha512.js +561 -0
  223. package/node_modules/node-forge/lib/socket.js +287 -0
  224. package/node_modules/node-forge/lib/ssh.js +236 -0
  225. package/node_modules/node-forge/lib/tls.js +4282 -0
  226. package/node_modules/node-forge/lib/tlssocket.js +249 -0
  227. package/node_modules/node-forge/lib/util.js +2652 -0
  228. package/node_modules/node-forge/lib/x509.js +3251 -0
  229. package/node_modules/node-forge/lib/xhr.js +738 -0
  230. package/node_modules/node-forge/package.json +123 -0
  231. package/node_modules/smol-toml/LICENSE +24 -0
  232. package/node_modules/smol-toml/README.md +239 -0
  233. package/node_modules/smol-toml/dist/date.d.ts +41 -0
  234. package/node_modules/smol-toml/dist/date.js +127 -0
  235. package/node_modules/smol-toml/dist/error.d.ts +38 -0
  236. package/node_modules/smol-toml/dist/error.js +63 -0
  237. package/node_modules/smol-toml/dist/extract.d.ts +30 -0
  238. package/node_modules/smol-toml/dist/extract.js +100 -0
  239. package/node_modules/smol-toml/dist/index.cjs +897 -0
  240. package/node_modules/smol-toml/dist/index.d.ts +43 -0
  241. package/node_modules/smol-toml/dist/index.js +33 -0
  242. package/node_modules/smol-toml/dist/parse.d.ts +37 -0
  243. package/node_modules/smol-toml/dist/parse.js +148 -0
  244. package/node_modules/smol-toml/dist/primitive.d.ts +31 -0
  245. package/node_modules/smol-toml/dist/primitive.js +179 -0
  246. package/node_modules/smol-toml/dist/stringify.d.ts +31 -0
  247. package/node_modules/smol-toml/dist/stringify.js +167 -0
  248. package/node_modules/smol-toml/dist/struct.d.ts +32 -0
  249. package/node_modules/smol-toml/dist/struct.js +184 -0
  250. package/node_modules/smol-toml/dist/util.d.ts +42 -0
  251. package/node_modules/smol-toml/dist/util.js +111 -0
  252. package/node_modules/smol-toml/package.json +54 -0
  253. package/offline/bin/claude-trace +6 -0
  254. package/offline/bin/claude-wrapper +13 -0
  255. package/offline/bin/install-agent +14 -0
  256. package/offline/bin/validate-trace +6 -0
  257. package/offline/bin/verify-bundle +7 -0
  258. package/package.json +103 -0
@@ -0,0 +1,496 @@
1
+ "use strict";
2
+ /**
3
+ * @file Runtime fetch/HTTP interceptor for Claude Code V1 (Node.js script mode).
4
+ *
5
+ * Patches `global.fetch` and Node's `http`/`https` modules to capture Anthropic
6
+ * Messages API traffic (and optionally AWS Bedrock) before it reaches the upstream.
7
+ * Used when Claude Code is launched as a Node.js script via `--require interceptor-loader.js`.
8
+ * Native V2+ binaries use {@link ReverseProxyServer} instead.
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ClaudeTrafficLogger = void 0;
15
+ exports.initializeInterceptor = initializeInterceptor;
16
+ exports.getLogger = getLogger;
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
+ const child_process_1 = require("child_process");
20
+ const html_generator_1 = require("../report/html-generator");
21
+ const header_redaction_1 = require("./header-redaction");
22
+ /**
23
+ * Captures Claude API request/response pairs by monkey-patching fetch and Node HTTP.
24
+ *
25
+ * Writes append-only JSONL logs and optionally regenerates a self-contained HTML
26
+ * report after each exchange. Sensitive headers are redacted by default.
27
+ */
28
+ class ClaudeTrafficLogger {
29
+ /**
30
+ * Initializes log paths, creates the log directory, and clears the JSONL file.
31
+ *
32
+ * @param config - Logger configuration; sensible defaults are applied.
33
+ */
34
+ constructor(config = {}) {
35
+ /** In-flight requests awaiting a matching response (keyed by generated request id). */
36
+ this.pendingRequests = new Map();
37
+ /** Completed request/response pairs held in memory for HTML regeneration. */
38
+ this.pairs = [];
39
+ const logDirectory = config.logDirectory || process.env.CLAUDE_TRACE_LOG_DIR || ".claude-trace";
40
+ if (process.env.CLAUDE_TRACE_LOG_DIR && !path_1.default.isAbsolute(logDirectory)) {
41
+ throw new Error("CLAUDE_TRACE_LOG_DIR must be an absolute path");
42
+ }
43
+ this.config = {
44
+ logDirectory,
45
+ enableRealTimeHTML: true,
46
+ logLevel: "info",
47
+ ...config,
48
+ };
49
+ this.logDir = this.config.logDirectory;
50
+ if (!fs_1.default.existsSync(this.logDir)) {
51
+ fs_1.default.mkdirSync(this.logDir, { recursive: true });
52
+ }
53
+ // Prefer explicit config, then env override, then timestamped default.
54
+ const logBaseName = config?.logBaseName || process.env.CLAUDE_TRACE_LOG_NAME;
55
+ const fileBaseName = logBaseName || `log-${new Date().toISOString().replace(/[:.]/g, "-").replace("T", "-").slice(0, -5)}`;
56
+ this.logFile = path_1.default.join(this.logDir, `${fileBaseName}.jsonl`);
57
+ this.htmlFile = path_1.default.join(this.logDir, `${fileBaseName}.html`);
58
+ this.htmlGenerator = new html_generator_1.HTMLGenerator();
59
+ fs_1.default.writeFileSync(this.logFile, "");
60
+ console.log(`Logs will be written to:`);
61
+ console.log(` JSONL: ${path_1.default.resolve(this.logFile)}`);
62
+ console.log(` HTML: ${path_1.default.resolve(this.htmlFile)}`);
63
+ }
64
+ /**
65
+ * Returns true when a URL targets the Claude Messages API (or all Anthropic/Bedrock
66
+ * traffic when `CLAUDE_TRACE_INCLUDE_ALL_REQUESTS=true`).
67
+ *
68
+ * Respects `ANTHROPIC_BASE_URL` for custom proxy endpoints.
69
+ *
70
+ * @param url - Request URL as a string or `URL` object.
71
+ */
72
+ isClaudeAPI(url) {
73
+ const urlString = typeof url === "string" ? url : url.toString();
74
+ const includeAllRequests = process.env.CLAUDE_TRACE_INCLUDE_ALL_REQUESTS === "true";
75
+ // Support custom ANTHROPIC_BASE_URL (e.g. when already pointing at a local proxy).
76
+ const baseUrl = process.env.ANTHROPIC_BASE_URL || "https://api.anthropic.com";
77
+ const apiHost = new URL(baseUrl).hostname;
78
+ const isAnthropicAPI = urlString.includes(apiHost);
79
+ // AWS Bedrock uses a different host pattern but the same Messages API shape.
80
+ const isBedrockAPI = urlString.includes("bedrock-runtime.") && urlString.includes(".amazonaws.com");
81
+ if (includeAllRequests) {
82
+ return isAnthropicAPI || isBedrockAPI;
83
+ }
84
+ return (isAnthropicAPI && urlString.includes("/v1/messages")) || isBedrockAPI;
85
+ }
86
+ /** Generates a unique correlation id for pairing requests with responses. */
87
+ generateRequestId() {
88
+ return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
89
+ }
90
+ /**
91
+ * Redacts sensitive header values by truncating to prefix/suffix.
92
+ *
93
+ * @param headers - Flat header map from fetch or Node HTTP options.
94
+ * @returns Copy of headers with sensitive values partially redacted.
95
+ */
96
+ redactSensitiveHeaders(headers) {
97
+ return (0, header_redaction_1.processHeaders)(headers);
98
+ }
99
+ /** Clones a fetch Response so the body can be read for logging without consuming it. */
100
+ async cloneResponse(response) {
101
+ return response.clone();
102
+ }
103
+ /**
104
+ * Normalizes request body into a log-friendly value.
105
+ *
106
+ * Parses JSON strings, expands FormData entries, and passes through other types.
107
+ *
108
+ * @param body - Raw request body from fetch `init.body` or Node `req.write` chunks.
109
+ */
110
+ async parseRequestBody(body) {
111
+ if (!body)
112
+ return null;
113
+ if (typeof body === "string") {
114
+ try {
115
+ return JSON.parse(body);
116
+ }
117
+ catch {
118
+ return body;
119
+ }
120
+ }
121
+ if (body instanceof FormData) {
122
+ const formObject = {};
123
+ for (const [key, value] of body.entries()) {
124
+ formObject[key] = value;
125
+ }
126
+ return formObject;
127
+ }
128
+ return body;
129
+ }
130
+ /**
131
+ * Reads and classifies a fetch Response body for logging.
132
+ *
133
+ * JSON responses are parsed; SSE and text responses are stored as raw strings.
134
+ *
135
+ * @param response - Cloned fetch Response (safe to consume).
136
+ */
137
+ async parseResponseBody(response) {
138
+ const contentType = response.headers.get("content-type") || "";
139
+ try {
140
+ if (contentType.includes("application/json")) {
141
+ const body = await response.json();
142
+ return { body };
143
+ }
144
+ else if (contentType.includes("text/event-stream")) {
145
+ const body_raw = await response.text();
146
+ return { body_raw };
147
+ }
148
+ else if (contentType.includes("text/")) {
149
+ const body_raw = await response.text();
150
+ return { body_raw };
151
+ }
152
+ else {
153
+ const body_raw = await response.text();
154
+ return { body_raw };
155
+ }
156
+ }
157
+ catch (error) {
158
+ // Swallow parse errors so instrumentation never breaks the client request.
159
+ return {};
160
+ }
161
+ }
162
+ /** Installs both fetch and Node HTTP instrumentation. */
163
+ instrumentAll() {
164
+ this.instrumentFetch();
165
+ this.instrumentNodeHTTP();
166
+ }
167
+ /**
168
+ * Patches `global.fetch` to intercept Claude API calls.
169
+ *
170
+ * Idempotent: skips if already marked with `__claudeTraceInstrumented`.
171
+ * Non-Claude URLs pass through to the original fetch unchanged.
172
+ */
173
+ instrumentFetch() {
174
+ if (!global.fetch) {
175
+ return;
176
+ }
177
+ // Prevent double-patching when the loader or hot-reload re-enters initialization.
178
+ if (global.fetch.__claudeTraceInstrumented) {
179
+ return;
180
+ }
181
+ const originalFetch = global.fetch;
182
+ const logger = this;
183
+ global.fetch = async function (input, init = {}) {
184
+ const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
185
+ if (!logger.isClaudeAPI(url)) {
186
+ return originalFetch(input, init);
187
+ }
188
+ const requestId = logger.generateRequestId();
189
+ const requestTimestamp = Date.now();
190
+ const requestData = {
191
+ // Seconds since epoch to match Python claude-trace log format.
192
+ timestamp: requestTimestamp / 1000,
193
+ method: init.method || "GET",
194
+ url: url,
195
+ headers: logger.redactSensitiveHeaders(Object.fromEntries(new Headers(init.headers || {}).entries())),
196
+ body: await logger.parseRequestBody(init.body),
197
+ };
198
+ logger.pendingRequests.set(requestId, requestData);
199
+ try {
200
+ const response = await originalFetch(input, init);
201
+ const responseTimestamp = Date.now();
202
+ const clonedResponse = await logger.cloneResponse(response);
203
+ const responseBodyData = await logger.parseResponseBody(clonedResponse);
204
+ const responseData = {
205
+ timestamp: responseTimestamp / 1000,
206
+ status_code: response.status,
207
+ headers: logger.redactSensitiveHeaders(Object.fromEntries(response.headers.entries())),
208
+ ...responseBodyData,
209
+ };
210
+ const pair = {
211
+ request: requestData,
212
+ response: responseData,
213
+ logged_at: new Date().toISOString(),
214
+ };
215
+ logger.pendingRequests.delete(requestId);
216
+ logger.pairs.push(pair);
217
+ await logger.writePairToLog(pair);
218
+ if (logger.config.enableRealTimeHTML) {
219
+ await logger.generateHTML();
220
+ }
221
+ return response;
222
+ }
223
+ catch (error) {
224
+ logger.pendingRequests.delete(requestId);
225
+ throw error;
226
+ }
227
+ };
228
+ global.fetch.__claudeTraceInstrumented = true;
229
+ }
230
+ /**
231
+ * Patches Node's `http` and `https` `request`/`get` methods.
232
+ *
233
+ * Some Claude Code versions use Node HTTP instead of fetch for API calls.
234
+ * Each method is patched at most once via a `__claudeTraceInstrumented` marker.
235
+ */
236
+ instrumentNodeHTTP() {
237
+ try {
238
+ const http = require("http");
239
+ const https = require("https");
240
+ const logger = this;
241
+ if (http.request && !http.request.__claudeTraceInstrumented) {
242
+ const originalHttpRequest = http.request;
243
+ http.request = function (options, callback) {
244
+ return logger.interceptNodeRequest(originalHttpRequest, options, callback, false);
245
+ };
246
+ http.request.__claudeTraceInstrumented = true;
247
+ }
248
+ if (http.get && !http.get.__claudeTraceInstrumented) {
249
+ const originalHttpGet = http.get;
250
+ http.get = function (options, callback) {
251
+ return logger.interceptNodeRequest(originalHttpGet, options, callback, false);
252
+ };
253
+ http.get.__claudeTraceInstrumented = true;
254
+ }
255
+ if (https.request && !https.request.__claudeTraceInstrumented) {
256
+ const originalHttpsRequest = https.request;
257
+ https.request = function (options, callback) {
258
+ return logger.interceptNodeRequest(originalHttpsRequest, options, callback, true);
259
+ };
260
+ https.request.__claudeTraceInstrumented = true;
261
+ }
262
+ if (https.get && !https.get.__claudeTraceInstrumented) {
263
+ const originalHttpsGet = https.get;
264
+ https.get = function (options, callback) {
265
+ return logger.interceptNodeRequest(originalHttpsGet, options, callback, true);
266
+ };
267
+ https.get.__claudeTraceInstrumented = true;
268
+ }
269
+ }
270
+ catch (error) {
271
+ // http/https may be unavailable in some embedded runtimes; fail silently.
272
+ }
273
+ }
274
+ /**
275
+ * Wraps a Node HTTP(S) request to capture body and response for Claude API URLs.
276
+ *
277
+ * Intercepts `req.write` to accumulate the request body, then logs on `res.end`.
278
+ *
279
+ * @param originalRequest - Unpatched `http.request` or `https.request`.
280
+ * @param options - Request options or URL string.
281
+ * @param callback - Optional response callback passed to the original request.
282
+ * @param isHttps - Whether the underlying module is `https`.
283
+ * @returns The outbound `ClientRequest` with wrapped `write`.
284
+ */
285
+ interceptNodeRequest(originalRequest, options, callback, isHttps) {
286
+ const url = this.parseNodeRequestURL(options, isHttps);
287
+ if (!this.isClaudeAPI(url)) {
288
+ return originalRequest.call(this, options, callback);
289
+ }
290
+ const requestTimestamp = Date.now();
291
+ let requestBody = "";
292
+ const req = originalRequest.call(this, options, (res) => {
293
+ const responseTimestamp = Date.now();
294
+ let responseBody = "";
295
+ res.on("data", (chunk) => {
296
+ responseBody += chunk;
297
+ });
298
+ res.on("end", async () => {
299
+ const requestData = {
300
+ timestamp: requestTimestamp / 1000,
301
+ method: options.method || "GET",
302
+ url: url,
303
+ headers: this.redactSensitiveHeaders(options.headers || {}),
304
+ body: requestBody ? await this.parseRequestBody(requestBody) : null,
305
+ };
306
+ const responseData = {
307
+ timestamp: responseTimestamp / 1000,
308
+ status_code: res.statusCode,
309
+ headers: this.redactSensitiveHeaders(res.headers || {}),
310
+ ...(await this.parseResponseBodyFromString(responseBody, res.headers["content-type"])),
311
+ };
312
+ const pair = {
313
+ request: requestData,
314
+ response: responseData,
315
+ logged_at: new Date().toISOString(),
316
+ };
317
+ this.pairs.push(pair);
318
+ await this.writePairToLog(pair);
319
+ if (this.config.enableRealTimeHTML) {
320
+ await this.generateHTML();
321
+ }
322
+ });
323
+ if (callback) {
324
+ callback(res);
325
+ }
326
+ });
327
+ // Node HTTP does not expose the body until write/end; wrap write to capture it.
328
+ const originalWrite = req.write;
329
+ req.write = function (chunk) {
330
+ if (chunk) {
331
+ requestBody += chunk;
332
+ }
333
+ return originalWrite.call(this, chunk);
334
+ };
335
+ return req;
336
+ }
337
+ /**
338
+ * Reconstructs a full URL string from Node HTTP request options.
339
+ *
340
+ * @param options - URL string or options object with host/path fields.
341
+ * @param isHttps - Whether the caller is the `https` module.
342
+ */
343
+ parseNodeRequestURL(options, isHttps) {
344
+ if (typeof options === "string") {
345
+ return options;
346
+ }
347
+ const protocol = isHttps ? "https:" : "http:";
348
+ const hostname = options.hostname || options.host || "localhost";
349
+ const port = options.port ? `:${options.port}` : "";
350
+ const path = options.path || "/";
351
+ return `${protocol}//${hostname}${port}${path}`;
352
+ }
353
+ /**
354
+ * Parses a raw response body string based on Content-Type (Node HTTP path).
355
+ *
356
+ * @param body - Accumulated response body from `res.on("data")`.
357
+ * @param contentType - Value of the `content-type` response header, if any.
358
+ */
359
+ async parseResponseBodyFromString(body, contentType) {
360
+ try {
361
+ if (contentType && contentType.includes("application/json")) {
362
+ return { body: JSON.parse(body) };
363
+ }
364
+ else if (contentType && contentType.includes("text/event-stream")) {
365
+ return { body_raw: body };
366
+ }
367
+ else {
368
+ return { body_raw: body };
369
+ }
370
+ }
371
+ catch (error) {
372
+ return { body_raw: body };
373
+ }
374
+ }
375
+ /** Appends a single JSONL line for one request/response pair. */
376
+ async writePairToLog(pair) {
377
+ try {
378
+ const jsonLine = JSON.stringify(pair) + "\n";
379
+ fs_1.default.appendFileSync(this.logFile, jsonLine);
380
+ }
381
+ catch (error) {
382
+ // Swallow write errors so logging never crashes the instrumented process.
383
+ }
384
+ }
385
+ /** Regenerates the self-contained HTML report from all logged pairs. */
386
+ async generateHTML() {
387
+ try {
388
+ const includeAllRequests = process.env.CLAUDE_TRACE_INCLUDE_ALL_REQUESTS === "true";
389
+ await this.htmlGenerator.generateHTML(this.pairs, this.htmlFile, {
390
+ timestamp: new Date().toISOString().replace("T", " ").slice(0, -5),
391
+ includeAllRequests,
392
+ tool: "claude",
393
+ });
394
+ }
395
+ catch (error) {
396
+ // HTML generation is best-effort; failures should not affect the client.
397
+ }
398
+ }
399
+ /**
400
+ * Flushes orphaned pending requests and optionally opens the HTML report.
401
+ *
402
+ * Called on process exit via {@link initializeInterceptor}. Requests that never
403
+ * received a response are logged with a `ORPHANED_REQUEST` note.
404
+ */
405
+ cleanup() {
406
+ console.log("Cleaning up orphaned requests...");
407
+ for (const [, requestData] of this.pendingRequests.entries()) {
408
+ const orphanedPair = {
409
+ request: requestData,
410
+ response: null,
411
+ note: "ORPHANED_REQUEST - No matching response received",
412
+ logged_at: new Date().toISOString(),
413
+ };
414
+ try {
415
+ const jsonLine = JSON.stringify(orphanedPair) + "\n";
416
+ fs_1.default.appendFileSync(this.logFile, jsonLine);
417
+ }
418
+ catch (error) {
419
+ console.log(`Error writing orphaned request: ${error}`);
420
+ }
421
+ }
422
+ this.pendingRequests.clear();
423
+ console.log(`Cleanup complete. Logged ${this.pairs.length} pairs`);
424
+ const shouldOpenBrowser = process.env.CLAUDE_TRACE_OPEN_BROWSER === "true";
425
+ if (shouldOpenBrowser && fs_1.default.existsSync(this.htmlFile)) {
426
+ try {
427
+ (0, child_process_1.spawn)("open", [this.htmlFile], { detached: true, stdio: "ignore" }).unref();
428
+ console.log(`Opening ${this.htmlFile} in browser`);
429
+ }
430
+ catch (error) {
431
+ console.log(`Failed to open browser: ${error}`);
432
+ }
433
+ }
434
+ }
435
+ /**
436
+ * Returns current logging statistics and output file paths.
437
+ *
438
+ * @returns Snapshot of pair count, pending request count, and log file paths.
439
+ */
440
+ getStats() {
441
+ return {
442
+ totalPairs: this.pairs.length,
443
+ pendingRequests: this.pendingRequests.size,
444
+ logFile: this.logFile,
445
+ htmlFile: this.htmlFile,
446
+ };
447
+ }
448
+ }
449
+ exports.ClaudeTrafficLogger = ClaudeTrafficLogger;
450
+ /** Singleton logger instance shared across the process. */
451
+ let globalLogger = null;
452
+ /** Guards against registering duplicate process exit handlers. */
453
+ let eventListenersSetup = false;
454
+ /**
455
+ * Creates and activates the global traffic logger (singleton).
456
+ *
457
+ * Patches fetch/HTTP immediately and registers cleanup handlers for
458
+ * `exit`, `SIGINT`, `SIGTERM`, and `uncaughtException`.
459
+ *
460
+ * @param config - Optional logger configuration.
461
+ * @returns The active {@link ClaudeTrafficLogger} instance.
462
+ */
463
+ function initializeInterceptor(config) {
464
+ if (globalLogger) {
465
+ console.warn("Interceptor already initialized");
466
+ return globalLogger;
467
+ }
468
+ globalLogger = new ClaudeTrafficLogger(config);
469
+ globalLogger.instrumentAll();
470
+ if (!eventListenersSetup) {
471
+ const cleanup = () => {
472
+ if (globalLogger) {
473
+ globalLogger.cleanup();
474
+ }
475
+ };
476
+ process.on("exit", cleanup);
477
+ process.on("SIGINT", cleanup);
478
+ process.on("SIGTERM", cleanup);
479
+ process.on("uncaughtException", (error) => {
480
+ console.error("Uncaught exception:", error);
481
+ cleanup();
482
+ process.exit(1);
483
+ });
484
+ eventListenersSetup = true;
485
+ }
486
+ return globalLogger;
487
+ }
488
+ /**
489
+ * Returns the active logger instance, or `null` if not yet initialized.
490
+ *
491
+ * @returns Global {@link ClaudeTrafficLogger} or `null`.
492
+ */
493
+ function getLogger() {
494
+ return globalLogger;
495
+ }
496
+ //# sourceMappingURL=interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../src/intercept/interceptor.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;AAshBH,sDA6BC;AAOD,8BAEC;AA1jBD,4CAAoB;AACpB,gDAAwB;AACxB,iDAAsC;AAEtC,6DAAyD;AACzD,yDAAoD;AAcpD;;;;;GAKG;AACH,MAAa,mBAAmB;IAgB/B;;;;OAIG;IACH,YAAY,SAA4B,EAAE;QAd1C,uFAAuF;QAC/E,oBAAe,GAAqB,IAAI,GAAG,EAAE,CAAC;QACtD,6EAA6E;QACrE,UAAK,GAAc,EAAE,CAAC;QAY7B,MAAM,YAAY,GACjB,MAAM,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,eAAe,CAAC;QAC5E,IAAI,OAAO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,CAAC;IAC/C,YAAY,CAAC,aAAa,EAAE,CAAC;IAE7B,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,YAAY,EAAE,CAAC;gBAClB,YAAY,CAAC,OAAO,EAAE,CAAC;YACxB,CAAC;QACF,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;YAC5C,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,mBAAmB,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,SAAgB,SAAS;IACxB,OAAO,YAAY,CAAC;AACrB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file mitm-cert.ts
3
+ * @description Local CA and leaf certificate management for HTTPS MITM proxying.
4
+ *
5
+ * vibe-coding-proxy only decrypts HTTPS traffic for explicitly allowlisted model
6
+ * API hosts. This module creates a reusable local certificate authority and
7
+ * caches per-host leaf certificates signed by that CA. It never installs the CA
8
+ * into the system trust store; users must opt in by trusting the printed CA path.
9
+ */
10
+ /** PEM-encoded certificate and key pair used by Node TLS servers. */
11
+ export interface MitmCertificatePair {
12
+ /** PEM private key for the generated leaf certificate. */
13
+ key: string;
14
+ /** PEM certificate signed by the local CA. */
15
+ cert: string;
16
+ }
17
+ /** Paths and PEM contents for the local CA. */
18
+ export interface MitmAuthorityInfo {
19
+ /** Absolute path to the CA certificate users must trust. */
20
+ certPath: string;
21
+ /** Absolute path to the CA private key used for leaf signing. */
22
+ keyPath: string;
23
+ /** PEM-encoded CA certificate. */
24
+ certPem: string;
25
+ }
26
+ /**
27
+ * Creates, loads, and reuses local MITM certificates for allowlisted hosts.
28
+ */
29
+ export declare class MitmCertificateAuthority {
30
+ private readonly caDir;
31
+ private readonly caKeyPath;
32
+ private readonly caCertPath;
33
+ private authority;
34
+ /**
35
+ * @param caDir - Directory used to persist CA and cached leaf certificates.
36
+ */
37
+ constructor(caDir?: string);
38
+ /**
39
+ * Ensure the local CA exists and return its user-facing paths.
40
+ * @returns CA certificate path and PEM content.
41
+ */
42
+ ensureAuthority(): MitmAuthorityInfo;
43
+ /**
44
+ * Return a cached or newly generated leaf certificate for `hostname`.
45
+ * @param hostname - DNS name from the CONNECT target.
46
+ */
47
+ getCertificateForHost(hostname: string): MitmCertificatePair;
48
+ /** Load persisted CA material or create it on first use. */
49
+ private loadOrCreateAuthority;
50
+ }
51
+ /** @returns Default persistent CA directory under the user's home directory. */
52
+ export declare function defaultCaDir(): string;
53
+ //# sourceMappingURL=mitm-cert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mitm-cert.d.ts","sourceRoot":"","sources":["../../src/intercept/mitm-cert.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IACnC,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;CACb;AAED,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IACjC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,wBAAwB;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,SAAS,CAAgG;IAEjH;;OAEG;gBACS,KAAK,GAAE,MAAuB;IAM1C;;;OAGG;IACH,eAAe,IAAI,iBAAiB;IASpC;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB;IAyD5D,4DAA4D;IAC5D,OAAO,CAAC,qBAAqB;CAkD7B;AAED,gFAAgF;AAChF,wBAAgB,YAAY,IAAI,MAAM,CAErC"}