leakshield 0.3.1 → 0.5.0

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 (112) hide show
  1. package/README.md +144 -546
  2. package/README.zh-TW.md +143 -520
  3. package/dist/adapters/claude-code/capabilities.d.ts +14 -0
  4. package/dist/adapters/claude-code/capabilities.js +47 -0
  5. package/dist/adapters/claude-code/cli.d.ts +10 -0
  6. package/dist/adapters/claude-code/cli.js +51 -0
  7. package/dist/adapters/claude-code/doctor.d.ts +19 -0
  8. package/dist/adapters/claude-code/doctor.js +177 -0
  9. package/dist/adapters/claude-code/proxy.d.ts +47 -0
  10. package/dist/adapters/claude-code/proxy.js +348 -0
  11. package/dist/adapters/opencode/capabilities.d.ts +10 -0
  12. package/dist/adapters/opencode/capabilities.js +48 -0
  13. package/dist/adapters/opencode/doctor.d.ts +67 -0
  14. package/dist/{doctor.js → adapters/opencode/doctor.js} +26 -44
  15. package/dist/adapters/opencode/env-queries.d.ts +133 -0
  16. package/dist/adapters/opencode/env-tools.d.ts +20 -0
  17. package/dist/adapters/opencode/hooks.d.ts +4 -0
  18. package/dist/adapters/opencode/plugin.d.ts +12 -0
  19. package/dist/{opencode.js → adapters/opencode/plugin.js} +43 -14
  20. package/dist/adapters/opencode/tool-policy.d.ts +2 -0
  21. package/dist/adapters/opencode/tool-policy.js +23 -0
  22. package/dist/adapters/opencode/transparent-aisdk.d.ts +6 -0
  23. package/dist/{opencode-transparent-aisdk.js → adapters/opencode/transparent-aisdk.js} +1 -1
  24. package/dist/adapters/opencode/transparent.d.ts +70 -0
  25. package/dist/adapters/opencode/transparent.js +242 -0
  26. package/dist/adapters/opencode/v2.d.ts +23 -0
  27. package/dist/{opencode-v2.js → adapters/opencode/v2.js} +13 -8
  28. package/dist/adapters/pi/capabilities.d.ts +10 -0
  29. package/dist/adapters/pi/capabilities.js +50 -0
  30. package/dist/adapters/pi/doctor.d.ts +26 -0
  31. package/dist/adapters/pi/doctor.js +276 -0
  32. package/dist/adapters/pi/extension.d.ts +28 -0
  33. package/dist/adapters/pi/extension.js +109 -0
  34. package/dist/adapters/pi/guard.d.ts +33 -0
  35. package/dist/adapters/pi/guard.js +154 -0
  36. package/dist/adapters/pi/persistence.d.ts +9 -0
  37. package/dist/adapters/pi/persistence.js +69 -0
  38. package/dist/adapters/pi/settings.d.ts +51 -0
  39. package/dist/adapters/pi/settings.js +136 -0
  40. package/dist/adapters/pi/tool-policy.d.ts +11 -0
  41. package/dist/adapters/pi/tool-policy.js +114 -0
  42. package/dist/cli.d.ts +18 -0
  43. package/dist/cli.js +17 -6
  44. package/dist/config/loader.d.ts +70 -0
  45. package/dist/config/loader.js +8 -0
  46. package/dist/config/plain-object.d.ts +2 -0
  47. package/dist/core/index.d.ts +9 -0
  48. package/dist/core/index.js +9 -0
  49. package/dist/core/session-guard.d.ts +62 -0
  50. package/dist/{opencode-transparent.js → core/session-guard.js} +56 -713
  51. package/dist/core/sse-recovery.d.ts +6 -0
  52. package/dist/core/tool-restore-policy.d.ts +153 -0
  53. package/dist/core/tool-restore-policy.js +453 -0
  54. package/dist/core/wire.d.ts +213 -0
  55. package/dist/{opencode-transparent-http.js → core/wire.js} +125 -42
  56. package/dist/core/ws.d.ts +26 -0
  57. package/dist/{opencode-transparent-ws.js → core/ws.js} +1 -1
  58. package/dist/decision/deidentify.d.ts +63 -0
  59. package/dist/decision/ingress.d.ts +40 -0
  60. package/dist/decision/mapping-key.d.ts +91 -0
  61. package/dist/decision/mapping-store.d.ts +166 -0
  62. package/dist/decision/model.d.ts +41 -0
  63. package/dist/decision/pseudonymization.d.ts +176 -0
  64. package/dist/decision/redaction.d.ts +56 -0
  65. package/dist/decision/redaction.js +3 -0
  66. package/dist/decision/schema-strings.d.ts +23 -0
  67. package/dist/decision/schema-strings.js +2 -2
  68. package/dist/decision/value-search.d.ts +39 -0
  69. package/dist/doctor-capabilities.d.ts +21 -0
  70. package/dist/doctor-capabilities.js +58 -0
  71. package/dist/doctor-hosts.d.ts +18 -0
  72. package/dist/doctor-hosts.js +144 -0
  73. package/dist/doctor-report.d.ts +45 -0
  74. package/dist/doctor-report.js +111 -0
  75. package/dist/forget.d.ts +18 -0
  76. package/dist/guard-options.d.ts +45 -0
  77. package/dist/{plugin-options.js → guard-options.js} +8 -6
  78. package/dist/help.d.ts +2 -0
  79. package/dist/help.js +15 -1
  80. package/dist/i18n/en.d.ts +65 -0
  81. package/dist/i18n/index.d.ts +15 -0
  82. package/dist/i18n/zh-TW.d.ts +65 -0
  83. package/dist/index.d.ts +13 -0
  84. package/dist/index.js +1 -1
  85. package/dist/rules/builtin.d.ts +4 -0
  86. package/dist/rules/builtin.js +75 -2
  87. package/dist/rules/dynamic.d.ts +33 -0
  88. package/dist/scanner/allowlist.d.ts +22 -0
  89. package/dist/scanner/cidr.d.ts +39 -0
  90. package/dist/scanner/encoding.d.ts +87 -0
  91. package/dist/scanner/engine.d.ts +43 -0
  92. package/dist/scanner/exact-values.d.ts +11 -0
  93. package/dist/scanner/redaction-verifier.d.ts +24 -0
  94. package/dist/scanner/remotes.d.ts +29 -0
  95. package/dist/scanner/unicode.d.ts +57 -0
  96. package/dist/scanner/utils.d.ts +22 -0
  97. package/dist/transports/cli.d.ts +27 -0
  98. package/dist/transports/web-ui.d.ts +1 -0
  99. package/dist/transports/web-ui.js +1 -1
  100. package/dist/transports/web.d.ts +4 -0
  101. package/dist/types/capabilities.d.ts +67 -0
  102. package/dist/types/capabilities.js +133 -0
  103. package/dist/types.d.ts +149 -0
  104. package/dist/types.js +3 -0
  105. package/dist/utils/files.d.ts +3 -0
  106. package/dist/utils/path-security.d.ts +18 -0
  107. package/dist/utils/win-encoding.d.ts +16 -0
  108. package/package.json +15 -3
  109. /package/dist/{env-queries.js → adapters/opencode/env-queries.js} +0 -0
  110. /package/dist/{opencode-env-tools.js → adapters/opencode/env-tools.js} +0 -0
  111. /package/dist/{opencode-hooks.js → adapters/opencode/hooks.js} +0 -0
  112. /package/dist/{opencode-transparent-stream.js → core/sse-recovery.js} +0 -0
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Claude Code's declared coverage, printed by `leakshield --doctor`.
3
+ *
4
+ * The proxy routes by endpoint, so every Messages request that reaches
5
+ * ANTHROPIC_BASE_URL is masked regardless of why Claude Code sent it. Traffic
6
+ * that never reaches the base URL (Bedrock, Vertex, Foundry, cloud sessions,
7
+ * WebFetch's domain check) has no interception point: that is `outside`, and
8
+ * the doctor warns about it. Tool-argument restoration does not exist yet,
9
+ * background requests and WebSocket traffic have no transport-level probe, so
10
+ * those rows stay `unknown` rather than claiming a coverage or an absence the
11
+ * evidence does not carry.
12
+ */
13
+ import type { HostCapabilities } from "../../types/capabilities.js";
14
+ export declare const CLAUDE_CODE_CAPABILITIES: HostCapabilities;
@@ -0,0 +1,47 @@
1
+ export const CLAUDE_CODE_CAPABILITIES = {
2
+ host: "claude-code",
3
+ verifiedVersion: "2.1.321",
4
+ interception: "loopback-proxy",
5
+ transports: {
6
+ http: {
7
+ state: "protected",
8
+ mechanism: "core.onHttpRequest / onHttpResponse on POST /v1/messages and /v1/messages/count_tokens",
9
+ evidence: "tests/claude-code-proxy.test.ts",
10
+ note: "Anthropic Messages only. A body on another route is blocked, not forwarded.",
11
+ },
12
+ websocket: {
13
+ state: "unknown",
14
+ mechanism: "no WS traffic has been observed, but no transport-level probe has looked for it",
15
+ note: "The 2026-11-21 record covers one stub-backed HTTP scenario only and leaves interactive mode unverified (#113). Not claimed as not-present without a probe.",
16
+ },
17
+ nonFetch: {
18
+ state: "outside",
19
+ mechanism: "none: Bedrock, Vertex and Foundry, and Claude Code cloud sessions, do not use ANTHROPIC_BASE_URL",
20
+ note: "The host offers no hook on these paths. The doctor warns when a provider or host-managed setting is enabled.",
21
+ },
22
+ },
23
+ surfaces: {
24
+ toolArgs: {
25
+ state: "unknown",
26
+ mechanism: "no tool gate yet: tool_use input keeps placeholders, and a tool receives the placeholder",
27
+ note: "Restoration at tool execution through Claude Code hooks is issue #91.",
28
+ },
29
+ replyDisplay: {
30
+ state: "protected",
31
+ mechanism: "core.onHttpResponse restores assistant text in JSON and SSE replies, including a split placeholder",
32
+ evidence: "tests/claude-code-proxy.test.ts",
33
+ },
34
+ background: {
35
+ state: "unknown",
36
+ mechanism: "compaction and summaries travel on /v1/messages, the same route the proxy masks",
37
+ note: "No separate probe has been run (#111), so the row is not claimed as protected.",
38
+ },
39
+ },
40
+ credentials: "separated",
41
+ persistence: "none",
42
+ residuals: [
43
+ "transports.nonFetch: Bedrock, Vertex, Foundry and Claude Code cloud sessions bypass the base URL entirely.",
44
+ "transports.http: WebFetch's domain check sends the hostname, without the path, straight to api.anthropic.com; set skipWebFetchPreflight to turn it off.",
45
+ "surfaces.replyDisplay: after a proxy restart, assistant history is masked under new placeholders and old ones can no longer be restored.",
46
+ ],
47
+ };
@@ -0,0 +1,10 @@
1
+ export interface ClaudeCodeProxyArgs {
2
+ port: number;
3
+ upstream: string;
4
+ configPath?: string;
5
+ attachments: "block" | "allow";
6
+ }
7
+ export declare function parseClaudeCodeProxyArgs(args: readonly string[]): ClaudeCodeProxyArgs | {
8
+ error: string;
9
+ };
10
+ export declare function runClaudeCodeProxy(args: readonly string[]): Promise<number>;
@@ -0,0 +1,51 @@
1
+ import { loadConfig } from "../../config/loader.js";
2
+ import { DEFAULT_PROXY_PORT, DEFAULT_UPSTREAM, startClaudeCodeProxy } from "./proxy.js";
3
+ export function parseClaudeCodeProxyArgs(args) {
4
+ const valueOf = (flag) => {
5
+ const index = args.indexOf(flag);
6
+ return index !== -1 && index + 1 < args.length ? args[index + 1] : undefined;
7
+ };
8
+ const rawPort = valueOf("--port");
9
+ const port = rawPort === undefined ? DEFAULT_PROXY_PORT : Number(rawPort);
10
+ if (!Number.isInteger(port) || port < 0 || port > 65535)
11
+ return { error: "--port must be an integer from 0 to 65535" };
12
+ const attachments = valueOf("--attachments") ?? "block";
13
+ if (attachments !== "block" && attachments !== "allow")
14
+ return { error: '--attachments must be "block" or "allow"' };
15
+ return { port, upstream: valueOf("--upstream") ?? DEFAULT_UPSTREAM, configPath: valueOf("--config"), attachments };
16
+ }
17
+ // Same forced setting as the OpenCode plugin entry, so both hosts detect the
18
+ // same encoded values.
19
+ function withEncodingDetection(config) {
20
+ return { ...config, settings: { ...config.settings, encoding_detection: true } };
21
+ }
22
+ export async function runClaudeCodeProxy(args) {
23
+ const parsed = parseClaudeCodeProxyArgs(args);
24
+ if ("error" in parsed) {
25
+ console.error(`leakshield: ${parsed.error}`);
26
+ return 2;
27
+ }
28
+ let running;
29
+ try {
30
+ const config = withEncodingDetection(loadConfig(parsed.configPath, process.cwd()));
31
+ running = await startClaudeCodeProxy({
32
+ config,
33
+ port: parsed.port,
34
+ upstream: parsed.upstream,
35
+ attachments: parsed.attachments,
36
+ });
37
+ }
38
+ catch (error) {
39
+ console.error(`leakshield: could not start the Claude Code proxy: ${error instanceof Error ? error.message : String(error)}`);
40
+ return 1;
41
+ }
42
+ console.log(`LeakShield Claude Code proxy listening on ${running.url} -> ${parsed.upstream}`);
43
+ console.log(`Point Claude Code at it: export ANTHROPIC_BASE_URL=${running.url}`);
44
+ const stop = () => {
45
+ void running.close().then(() => process.exit(0));
46
+ };
47
+ process.once("SIGINT", stop);
48
+ process.once("SIGTERM", stop);
49
+ await new Promise(() => { });
50
+ return 0;
51
+ }
@@ -0,0 +1,19 @@
1
+ import type { DoctorCheck } from "../../doctor-report.js";
2
+ export type ProxyProbe = {
3
+ ok: true;
4
+ upstream: string | null;
5
+ } | {
6
+ ok: false;
7
+ reason: "unreachable" | "not-leakshield";
8
+ };
9
+ export interface ClaudeCodeDoctorDeps {
10
+ claudeVersion(): string | null;
11
+ readIfExists(filePath: string): string | null;
12
+ probeProxy(baseUrl: string): Promise<ProxyProbe>;
13
+ env: Readonly<Record<string, string | undefined>>;
14
+ cwd: string;
15
+ home: string;
16
+ }
17
+ export declare function createClaudeCodeDoctorDeps(): ClaudeCodeDoctorDeps;
18
+ /** Claude Code checks, independent of the OpenCode checks and their status. */
19
+ export declare function runClaudeCodeDoctor(deps: ClaudeCodeDoctorDeps): Promise<DoctorCheck[]>;
@@ -0,0 +1,177 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { DEFAULT_PROXY_HOST, DEFAULT_PROXY_PORT, HEALTH_PATH, HEALTH_SERVICE } from "./proxy.js";
6
+ const PROXY_URL = `http://${DEFAULT_PROXY_HOST}:${DEFAULT_PROXY_PORT}`;
7
+ const ALTERNATE_PROVIDERS = ["CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CODE_USE_FOUNDRY"];
8
+ export function createClaudeCodeDoctorDeps() {
9
+ return {
10
+ claudeVersion() {
11
+ try {
12
+ const r = spawnSync("claude", ["--version"], { encoding: "utf8", timeout: 4000 });
13
+ if (r.error || (r.status !== null && r.status !== 0))
14
+ return null;
15
+ return (r.stdout || "").trim() || null;
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ },
21
+ readIfExists(filePath) {
22
+ try {
23
+ return fs.readFileSync(filePath, "utf8");
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ },
29
+ async probeProxy(baseUrl) {
30
+ try {
31
+ const response = await fetch(new URL(HEALTH_PATH, baseUrl), { signal: AbortSignal.timeout(2000) });
32
+ const body = await response.json().catch(() => null);
33
+ if (response.ok && typeof body === "object" && body !== null && body.service === HEALTH_SERVICE) {
34
+ const upstream = body.upstream;
35
+ return { ok: true, upstream: typeof upstream === "string" ? upstream : null };
36
+ }
37
+ return { ok: false, reason: "not-leakshield" };
38
+ }
39
+ catch {
40
+ return { ok: false, reason: "unreachable" };
41
+ }
42
+ },
43
+ env: process.env,
44
+ cwd: process.cwd(),
45
+ home: os.homedir(),
46
+ };
47
+ }
48
+ /**
49
+ * Claude Code applies settings `env` over the shell, and among settings files
50
+ * the more specific one wins: project local, then project, then user.
51
+ * Returned highest precedence first.
52
+ */
53
+ function envSources(deps) {
54
+ const configDir = deps.env.CLAUDE_CONFIG_DIR || path.join(deps.home, ".claude");
55
+ const files = [
56
+ path.join(deps.cwd, ".claude", "settings.local.json"),
57
+ path.join(deps.cwd, ".claude", "settings.json"),
58
+ path.join(configDir, "settings.json"),
59
+ ];
60
+ const sources = [];
61
+ const broken = [];
62
+ for (const file of files) {
63
+ const raw = deps.readIfExists(file);
64
+ if (raw === null)
65
+ continue;
66
+ try {
67
+ const parsed = JSON.parse(raw);
68
+ const env = typeof parsed === "object" && parsed !== null ? parsed.env : undefined;
69
+ if (typeof env === "object" && env !== null && !Array.isArray(env)) {
70
+ sources.push({ label: file, env: env });
71
+ }
72
+ }
73
+ catch {
74
+ broken.push(file);
75
+ }
76
+ }
77
+ sources.push({ label: "shell environment of this doctor run", env: { ...deps.env } });
78
+ return { sources, broken };
79
+ }
80
+ function effective(sources, key) {
81
+ for (const source of sources) {
82
+ const value = source.env[key];
83
+ if (typeof value === "string" && value.length > 0)
84
+ return { value, source: source.label };
85
+ }
86
+ return null;
87
+ }
88
+ function isLoopbackUrl(raw) {
89
+ try {
90
+ const host = new URL(raw).hostname;
91
+ return host === "127.0.0.1" || host === "localhost" || host === "[::1]";
92
+ }
93
+ catch {
94
+ return false;
95
+ }
96
+ }
97
+ /** Claude Code checks, independent of the OpenCode checks and their status. */
98
+ export async function runClaudeCodeDoctor(deps) {
99
+ const checks = [];
100
+ const version = deps.claudeVersion();
101
+ if (version === null) {
102
+ checks.push({ id: "claude-code", state: "skip", detail: "claude binary not found on PATH; Claude Code checks skipped." });
103
+ return checks;
104
+ }
105
+ checks.push({ id: "claude-code", state: "ok", detail: version });
106
+ const { sources, broken } = envSources(deps);
107
+ for (const file of broken) {
108
+ checks.push({
109
+ id: "claude-code-settings",
110
+ state: "warn",
111
+ detail: `${file} is not valid JSON; its env block was not read.`,
112
+ fix: "Fix the syntax, then rerun this doctor.",
113
+ });
114
+ }
115
+ const provider = ALTERNATE_PROVIDERS.map((key) => effective(sources, key)).find((hit) => hit !== null && hit.value !== "0" && hit.value !== "false");
116
+ if (provider) {
117
+ checks.push({
118
+ id: "claude-code-provider",
119
+ state: "warn",
120
+ detail: `A Bedrock/Vertex/Foundry provider is enabled (from ${provider.source}); those requests bypass ANTHROPIC_BASE_URL and the LeakShield proxy.`,
121
+ fix: "Unset it to send Claude Code through the Anthropic API and the proxy.",
122
+ });
123
+ }
124
+ if (deps.env.CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST) {
125
+ checks.push({
126
+ id: "claude-code-host-managed",
127
+ state: "warn",
128
+ detail: "CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST is set in this shell; Claude Code then ignores ANTHROPIC_BASE_URL from settings files, and the embedding app decides the endpoint.",
129
+ fix: "Set ANTHROPIC_BASE_URL in the environment that launches Claude Code, or check the embedding app's provider settings.",
130
+ });
131
+ }
132
+ const baseUrl = effective(sources, "ANTHROPIC_BASE_URL");
133
+ if (baseUrl === null) {
134
+ checks.push({
135
+ id: "claude-code-proxy",
136
+ state: "warn",
137
+ detail: "ANTHROPIC_BASE_URL is not set, so Claude Code talks to Anthropic directly and is not protected.",
138
+ fix: `Run \`leakshield --claude-code-proxy\`, then set ANTHROPIC_BASE_URL=${PROXY_URL} in your shell or in the "env" block of ~/.claude/settings.json.`,
139
+ });
140
+ return checks;
141
+ }
142
+ const probe = await deps.probeProxy(baseUrl.value);
143
+ if (probe.ok) {
144
+ checks.push({
145
+ id: "claude-code-proxy",
146
+ state: "ok",
147
+ detail: `ANTHROPIC_BASE_URL=${baseUrl.value} (from ${baseUrl.source}) is the LeakShield proxy${probe.upstream ? `, forwarding to ${probe.upstream}` : ""}.`,
148
+ });
149
+ }
150
+ else if (probe.reason === "unreachable" && isLoopbackUrl(baseUrl.value)) {
151
+ checks.push({
152
+ id: "claude-code-proxy",
153
+ state: "fail",
154
+ detail: `ANTHROPIC_BASE_URL=${baseUrl.value} (from ${baseUrl.source}) points at a local address where nothing answers; Claude Code requests will fail until the proxy runs.`,
155
+ fix: "Start it with `leakshield --claude-code-proxy` (add `--port` if you changed the port).",
156
+ });
157
+ }
158
+ else {
159
+ checks.push({
160
+ id: "claude-code-proxy",
161
+ state: "warn",
162
+ detail: `ANTHROPIC_BASE_URL=${baseUrl.value} (from ${baseUrl.source}) is not the LeakShield proxy, so Claude Code is not protected.`,
163
+ fix: `Run \`leakshield --claude-code-proxy\` and set ANTHROPIC_BASE_URL=${PROXY_URL}.`,
164
+ });
165
+ }
166
+ if (sources.length > 1 && baseUrl.source !== sources[sources.length - 1].label) {
167
+ const shell = sources[sources.length - 1].env.ANTHROPIC_BASE_URL;
168
+ if (typeof shell === "string" && shell.length > 0 && shell !== baseUrl.value) {
169
+ checks.push({
170
+ id: "claude-code-env",
171
+ state: "warn",
172
+ detail: `This shell sets ANTHROPIC_BASE_URL=${shell}, but ${baseUrl.source} overrides it inside Claude Code.`,
173
+ });
174
+ }
175
+ }
176
+ return checks;
177
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Claude Code host adapter (issue #86): a loopback HTTP proxy that Claude Code
3
+ * reaches through `ANTHROPIC_BASE_URL`. Anthropic Messages requests are masked
4
+ * by the host-independent core before they leave the machine, and assistant
5
+ * text in JSON and SSE replies is restored before Claude Code shows it.
6
+ *
7
+ * Fail closed: a request the proxy cannot mask (unknown route with a body,
8
+ * unrecognised body shape, masking error) is answered locally with a 400
9
+ * Anthropic-style error and nothing is forwarded. Bodyless GET/HEAD probes
10
+ * (Claude Code sends `HEAD /api/hello`) are forwarded when their URL carries
11
+ * no finding.
12
+ *
13
+ * Not covered here: tool-execution restoration (tool_use input stays
14
+ * tokenized, so Claude Code's tools receive placeholders), and anything
15
+ * Claude Code sends outside the base URL.
16
+ */
17
+ import { type Server } from "node:http";
18
+ import type { GuardConfig } from "../../types.js";
19
+ export declare const DEFAULT_PROXY_HOST = "127.0.0.1";
20
+ export declare const DEFAULT_PROXY_PORT = 8787;
21
+ export declare const DEFAULT_UPSTREAM = "https://api.anthropic.com";
22
+ export declare const HEALTH_PATH = "/__leakshield/health";
23
+ export declare const HEALTH_SERVICE = "leakshield-claude-code-proxy";
24
+ export interface ClaudeCodeProxyOptions {
25
+ config: GuardConfig;
26
+ upstream?: string;
27
+ attachments?: "block" | "allow";
28
+ fetch?: typeof fetch;
29
+ log?: (line: string) => void;
30
+ }
31
+ export interface ClaudeCodeProxy {
32
+ readonly upstream: string;
33
+ handle(request: Request, signal?: AbortSignal): Promise<Response>;
34
+ dispose(): void;
35
+ }
36
+ /** Plain http is accepted only for a loopback upstream (a local stub or gateway). */
37
+ export declare function parseUpstream(raw: string): URL;
38
+ export declare function createClaudeCodeProxy(options: ClaudeCodeProxyOptions): ClaudeCodeProxy;
39
+ export interface RunningClaudeCodeProxy {
40
+ readonly url: string;
41
+ readonly server: Server;
42
+ close(): Promise<void>;
43
+ }
44
+ export declare function startClaudeCodeProxy(options: ClaudeCodeProxyOptions & {
45
+ port?: number;
46
+ host?: string;
47
+ }): Promise<RunningClaudeCodeProxy>;