cyrus-edge-worker 0.2.44 → 0.2.45

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 (40) hide show
  1. package/dist/ConfigManager.d.ts.map +1 -1
  2. package/dist/ConfigManager.js +3 -0
  3. package/dist/ConfigManager.js.map +1 -1
  4. package/dist/EdgeWorker.d.ts +28 -0
  5. package/dist/EdgeWorker.d.ts.map +1 -1
  6. package/dist/EdgeWorker.js +189 -5
  7. package/dist/EdgeWorker.js.map +1 -1
  8. package/dist/EgressProxy.d.ts +158 -0
  9. package/dist/EgressProxy.d.ts.map +1 -0
  10. package/dist/EgressProxy.js +699 -0
  11. package/dist/EgressProxy.js.map +1 -0
  12. package/dist/GitService.d.ts +4 -6
  13. package/dist/GitService.d.ts.map +1 -1
  14. package/dist/GitService.js +16 -12
  15. package/dist/GitService.js.map +1 -1
  16. package/dist/McpConfigService.d.ts.map +1 -1
  17. package/dist/McpConfigService.js +8 -1
  18. package/dist/McpConfigService.js.map +1 -1
  19. package/dist/RunnerConfigBuilder.d.ts +12 -1
  20. package/dist/RunnerConfigBuilder.d.ts.map +1 -1
  21. package/dist/RunnerConfigBuilder.js +49 -0
  22. package/dist/RunnerConfigBuilder.js.map +1 -1
  23. package/dist/SharedApplicationServer.d.ts.map +1 -1
  24. package/dist/SharedApplicationServer.js +1 -0
  25. package/dist/SharedApplicationServer.js.map +1 -1
  26. package/dist/cyrus-skills-plugin/skills/verify-and-ship/SKILL.md +14 -2
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/prompts/builder.md +4 -4
  32. package/dist/prompts/debugger.md +4 -4
  33. package/dist/prompts/scoper.md +5 -5
  34. package/dist/prompts/todolist-system-prompt-extension.md +6 -6
  35. package/package.json +18 -16
  36. package/prompt-template.md +5 -5
  37. package/prompts/builder.md +4 -4
  38. package/prompts/debugger.md +4 -4
  39. package/prompts/scoper.md +5 -5
  40. package/prompts/todolist-system-prompt-extension.md +6 -6
@@ -0,0 +1,158 @@
1
+ import type { NetworkPolicy, SandboxConfig } from "cyrus-core";
2
+ import { type ILogger } from "cyrus-core";
3
+ /**
4
+ * EgressProxy provides an HTTP/HTTPS forward proxy for Claude Code sandbox
5
+ * network egress control.
6
+ *
7
+ * Scope: The SDK's sandbox.network proxy only intercepts traffic from
8
+ * Bash tool subprocesses (git, gh, npm, curl, etc.). Claude's own inference
9
+ * API calls, MCP server traffic, and built-in file tools (Read/Edit/Write)
10
+ * are NOT routed through this proxy.
11
+ * @see https://docs.anthropic.com/en/docs/claude-code/security#sandbox
12
+ *
13
+ * Capabilities:
14
+ * - Domain-based allow/deny filtering for subprocess traffic
15
+ * - TLS termination (MITM) for domains with header transform rules
16
+ * - Per-domain header injection (credentials brokering)
17
+ * - Request logging
18
+ *
19
+ * Architecture follows the Vercel Sandbox Firewall pattern:
20
+ * @see https://vercel.com/docs/vercel-sandbox/concepts/firewall
21
+ *
22
+ * TLS termination is selective — only domains with transform rules get intercepted.
23
+ * A per-instance CA certificate is generated and must be trusted by the client
24
+ * via NODE_EXTRA_CA_CERTS.
25
+ */
26
+ export declare class EgressProxy {
27
+ private httpServer;
28
+ private socksServer;
29
+ private httpProxyPort;
30
+ private socksProxyPort;
31
+ private networkPolicy;
32
+ private logRequests;
33
+ private logger;
34
+ /** CA key pair and certificate for on-the-fly cert generation */
35
+ private caKey;
36
+ private caCert;
37
+ private caKeyPem;
38
+ private caCertPem;
39
+ /** Path where the CA cert PEM is written for NODE_EXTRA_CA_CERTS */
40
+ private caCertPath;
41
+ /** Directory where cert files are stored */
42
+ private certsDir;
43
+ /** Cache of generated server certificates keyed by hostname */
44
+ private certCache;
45
+ /** Set of domains that require TLS termination (have transform rules) */
46
+ private tlsTerminationDomains;
47
+ /** Merged header transforms keyed by domain pattern */
48
+ private domainTransforms;
49
+ /** Set of allowed domain patterns (if policy specifies allow rules) */
50
+ private allowedDomains;
51
+ private isRunning;
52
+ constructor(config: SandboxConfig, cyrusHome: string, logger?: ILogger);
53
+ /**
54
+ * Get the path to the CA certificate PEM file.
55
+ * This should be set as NODE_EXTRA_CA_CERTS for child processes.
56
+ */
57
+ getCACertPath(): string;
58
+ /**
59
+ * Build a CA cert bundle that includes the proxy CA and any pre-existing
60
+ * cert file (e.g., corporate proxy CA). NODE_EXTRA_CA_CERTS accepts a
61
+ * single file path, so we concatenate all PEM certs into one bundle.
62
+ *
63
+ * Checks (in order): explicit existingCertPath arg, then the host
64
+ * process's NODE_EXTRA_CA_CERTS env var. If neither is set or the file
65
+ * doesn't exist, returns the proxy CA cert path unchanged.
66
+ */
67
+ buildCACertBundle(existingCertPath?: string): string;
68
+ /**
69
+ * Get configured HTTP proxy port.
70
+ */
71
+ getHttpProxyPort(): number;
72
+ /**
73
+ * Get configured SOCKS proxy port.
74
+ */
75
+ getSocksProxyPort(): number;
76
+ /**
77
+ * Start the egress proxy servers.
78
+ */
79
+ start(): Promise<void>;
80
+ /**
81
+ * Log a human-readable summary of the active network policy.
82
+ */
83
+ private logPolicySummary;
84
+ /**
85
+ * Stop the egress proxy servers.
86
+ */
87
+ stop(): Promise<void>;
88
+ /**
89
+ * Update the network policy at runtime without restarting.
90
+ */
91
+ updateNetworkPolicy(policy: NetworkPolicy): void;
92
+ private generateCA;
93
+ private generateServerCert;
94
+ private parsePolicy;
95
+ /**
96
+ * Check if a hostname is allowed by the network policy.
97
+ *
98
+ * Three modes (matching Vercel Sandbox Firewall):
99
+ * - allow-all: no networkPolicy or no allow rules → all traffic passes
100
+ * - deny-all: networkPolicy with empty allow → all traffic blocked
101
+ * - user-defined: networkPolicy with allow rules → deny-all default,
102
+ * only listed domains pass
103
+ *
104
+ * Only Bash-spawned subprocess traffic reaches this proxy (git, gh,
105
+ * npm, curl, etc.). Claude's inference API and MCP traffic bypass it.
106
+ */
107
+ private isDomainAllowed;
108
+ /**
109
+ * Match a hostname against policy domain patterns.
110
+ * Returns the matching pattern or null.
111
+ */
112
+ private matchDomain;
113
+ /**
114
+ * Match hostname against a domain pattern.
115
+ * Supports:
116
+ * - Leading wildcard: *.example.com matches sub.example.com but NOT example.com
117
+ * - Mid-segment wildcard: www.*.com matches www.foo.com
118
+ */
119
+ private matchesPattern;
120
+ /**
121
+ * Get the resolved transforms for a domain, if any.
122
+ */
123
+ private getTransformsForDomain;
124
+ /**
125
+ * Check if a domain requires TLS termination (has transform rules).
126
+ */
127
+ private requiresTlsTermination;
128
+ private startHttpProxy;
129
+ /**
130
+ * Handle plain HTTP proxy requests (non-CONNECT).
131
+ */
132
+ private handleHttpRequest;
133
+ /**
134
+ * Handle HTTPS CONNECT tunneling.
135
+ * For domains with transform rules: TLS-terminate, modify headers, re-encrypt.
136
+ * For other allowed domains: TCP passthrough.
137
+ */
138
+ private handleConnect;
139
+ /**
140
+ * Direct TCP tunnel (no TLS termination).
141
+ */
142
+ private handleTcpTunnel;
143
+ /**
144
+ * TLS termination for domains with transform rules.
145
+ * Spins up a local HTTPS server on an ephemeral port, bridges
146
+ * the client socket to it, then forwards decrypted HTTP upstream
147
+ * with injected headers.
148
+ */
149
+ private handleTlsTermination;
150
+ private startSocksProxy;
151
+ /**
152
+ * Handle SOCKS5 connection.
153
+ * Implements the SOCKS5 handshake (RFC 1928) with no-auth only,
154
+ * then tunnels the connection like CONNECT.
155
+ */
156
+ private handleSocksConnection;
157
+ }
158
+ //# sourceMappingURL=EgressProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EgressProxy.d.ts","sourceRoot":"","sources":["../src/EgressProxy.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAgB,KAAK,OAAO,EAAmB,MAAM,YAAY,CAAC;AAWzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,UAAU,CAAoD;IACtE,OA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