@kitman-sh/cli 0.10.70 → 0.10.72

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 (29) hide show
  1. package/dist/{chunk-x7g0rzqj.js → chunk-030xsst1.js} +339 -113
  2. package/dist/{chunk-pq9bkyj6.js → chunk-290se4bt.js} +3 -3
  3. package/dist/{chunk-f8qqmcgy.js → chunk-2es1djpn.js} +8 -8
  4. package/dist/{chunk-dena9bpd.js → chunk-61by5f18.js} +27 -18
  5. package/dist/{chunk-dk0ftqwg.js → chunk-7672g0fj.js} +28 -177
  6. package/dist/{chunk-e5dq8dbz.js → chunk-7g4e5fsj.js} +189 -53
  7. package/dist/{chunk-csbf77zs.js → chunk-7sm45hhc.js} +6 -6
  8. package/dist/{chunk-1j1jh211.js → chunk-7wenq6ew.js} +7 -5
  9. package/dist/{chunk-q3c7vmby.js → chunk-b63rssdn.js} +1 -1
  10. package/dist/{chunk-h0sw8tks.js → chunk-cefprsjj.js} +4 -4
  11. package/dist/{chunk-fgecj3t0.js → chunk-cj3ef3pv.js} +6 -6
  12. package/dist/{chunk-8ttdzwa3.js → chunk-d2fxfv0j.js} +9 -9
  13. package/dist/{chunk-8w7d269h.js → chunk-g8b2z9jn.js} +4 -4
  14. package/dist/chunk-gngg8j56.js +202 -0
  15. package/dist/{chunk-2wkdq54x.js → chunk-hxm3bvpn.js} +5 -5
  16. package/dist/{chunk-v01c0k6j.js → chunk-nhd7dh79.js} +1 -1
  17. package/dist/{chunk-9hr71e7c.js → chunk-pnsqttt3.js} +7 -7
  18. package/dist/{chunk-1rry0tsn.js → chunk-pyt2zrwc.js} +2 -2
  19. package/dist/{chunk-rrnee9mk.js → chunk-se79jbha.js} +1 -1
  20. package/dist/{chunk-60333x3q.js → chunk-tv94e132.js} +5 -5
  21. package/dist/{chunk-7jh6atr0.js → chunk-vd8f9brg.js} +17 -17
  22. package/dist/{chunk-d3ksv8y1.js → chunk-vrt08dk9.js} +60 -60
  23. package/dist/{chunk-rm83dbpv.js → chunk-w6qjh6q5.js} +2 -2
  24. package/dist/chunk-wssfts9s.js +16 -0
  25. package/dist/egress-proxy.ts +51 -4
  26. package/dist/index.js +4 -4
  27. package/package.json +1 -1
  28. package/dist/chunk-1w81w56v.js +0 -109
  29. package/dist/chunk-wtpwkjws.js +0 -100
@@ -1,100 +0,0 @@
1
- // @bun
2
- import"./chunk-d3ksv8y1.js";
3
- import"./chunk-rrnee9mk.js";
4
- import"./chunk-v01c0k6j.js";
5
- import {
6
- decideSecretRequest,
7
- readSecretRegistry,
8
- appendSecretRefusals
9
- } from "./chunk-1w81w56v.js";
10
-
11
- // packages/agent-runtime/src/srt-step.ts
12
- import { SandboxRuntimeConfigSchema } from "@anthropic-ai/sandbox-runtime";
13
- import { spawn } from "child_process";
14
- import { readFileSync } from "fs";
15
- var secretFilter = (registryFile) => (request, info) => {
16
- const url = new URL(request.url);
17
- const decision = decideSecretRequest({
18
- headers: [...request.headers.entries()],
19
- host: info?.target?.host ?? url.hostname,
20
- port: info?.target?.port ?? (url.port === "" ? url.protocol === "https:" ? 443 : 80 : Number(url.port)),
21
- target: info?.requestTarget ?? `${url.pathname}${url.search}`,
22
- scheme: info?.scheme ?? (url.protocol === "https:" ? "https" : "http")
23
- }, () => readSecretRegistry(registryFile));
24
- if (decision.action === "allow")
25
- return Promise.resolve(decision.setHeaders === undefined ? { action: "allow" } : { action: "allow", setHeaders: decision.setHeaders.map(([name, value]) => [name, value]) });
26
- try {
27
- appendSecretRefusals(registryFile, decision.refusals);
28
- } catch {}
29
- return Promise.resolve({ action: "deny", status: 403, mark: "secret-refused", reason: decision.reason });
30
- };
31
- var stepSandboxConfig = (settings, registryFile) => {
32
- const parsed = SandboxRuntimeConfigSchema.safeParse({
33
- ...settings,
34
- network: { ...settings.network, tlsTerminate: {}, refuseOpaqueTunnels: true }
35
- });
36
- return parsed.success ? {
37
- success: true,
38
- data: { ...parsed.data, network: { ...parsed.data.network, filterRequest: secretFilter(registryFile) } }
39
- } : parsed;
40
- };
41
- var opaqueTunnel = /^deny (?:socks-tunnel (\S+) \(refuseOpaqueTunnels\)|http-request CONNECT (\S+) \((?:tunnel carries no TLS|this proxy does not tunnel CONNECTs)[^)]*\))/;
42
- var refusedTunnelHost = (line) => {
43
- const match = opaqueTunnel.exec(line);
44
- return match === null ? undefined : match[1] ?? match[2];
45
- };
46
- var shellQuoted = (arg) => `'${arg.replaceAll("'", "'\\''")}'`;
47
- var argument = (args, flag) => {
48
- const at = args.indexOf(flag);
49
- return at === -1 ? undefined : args[at + 1];
50
- };
51
- var runSrtStep = async (args) => {
52
- const separator = args.indexOf("--");
53
- const settingsFile = argument(args, "--settings");
54
- const registryFile = argument(args, "--secrets");
55
- const command = separator === -1 ? [] : args.slice(separator + 1);
56
- if (settingsFile === undefined || registryFile === undefined || command.length === 0) {
57
- console.error("Usage: srt-step --settings <file> --secrets <registry> -- <command>");
58
- process.exit(2);
59
- }
60
- delete process.env.SRT_DEBUG;
61
- const { SandboxManager } = await import("@anthropic-ai/sandbox-runtime");
62
- const config = stepSandboxConfig(JSON.parse(readFileSync(settingsFile, "utf8")), registryFile);
63
- if (!config.success) {
64
- console.error(`srt-step: ${settingsFile} does not hold a valid srt config: ${config.error.message}`);
65
- process.exit(2);
66
- }
67
- await SandboxManager.initialize(config.data);
68
- const recorded = new WeakSet;
69
- SandboxManager.getSandboxViolationStore().subscribe((violations) => {
70
- const refusals = violations.flatMap((violation) => {
71
- if (recorded.has(violation))
72
- return [];
73
- recorded.add(violation);
74
- const host = refusedTunnelHost(violation.line);
75
- return host === undefined ? [] : [{ host, reason: "A tunnel Kitman cannot see into, such as SOCKS or a CONNECT without TLS, is refused." }];
76
- });
77
- if (refusals.length === 0)
78
- return;
79
- try {
80
- appendSecretRefusals(registryFile, refusals);
81
- } catch {}
82
- });
83
- const child = spawn(await SandboxManager.wrapWithSandbox(command.map(shellQuoted).join(" ")), {
84
- shell: true,
85
- stdio: "inherit"
86
- });
87
- child.on("exit", (code, signal) => {
88
- SandboxManager.cleanupAfterCommand();
89
- process.exit(signal === null ? code ?? 0 : signal === "SIGINT" || signal === "SIGTERM" ? 0 : 1);
90
- });
91
- child.on("error", (error) => {
92
- console.error(`Failed to execute command: ${error.message}`);
93
- process.exit(1);
94
- });
95
- for (const signal of ["SIGINT", "SIGTERM"])
96
- process.on(signal, () => child.kill(signal));
97
- };
98
- export {
99
- runSrtStep
100
- };