@kitman-sh/cli 0.9.0 → 0.10.53

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 (37) hide show
  1. package/dist/chunk-11p4wf6n.js +3551 -0
  2. package/dist/chunk-1mc9vgcr.js +39 -0
  3. package/dist/chunk-30397r95.js +30 -0
  4. package/dist/chunk-3bj7sc3v.js +389 -0
  5. package/dist/chunk-6vns3ej0.js +23 -0
  6. package/dist/chunk-7thnf14y.js +936 -0
  7. package/dist/chunk-arvwar2c.js +141 -0
  8. package/dist/chunk-b6thzgc9.js +32 -0
  9. package/dist/{chunk-8bvf4fh4.js → chunk-ctasxxz5.js} +26 -11
  10. package/dist/{chunk-5gjpv3ax.js → chunk-dzh9e6n2.js} +824 -651
  11. package/dist/{chunk-snn0e1qb.js → chunk-eg8f5ncv.js} +7 -3
  12. package/dist/chunk-g5bs3f6z.js +173 -0
  13. package/dist/chunk-jafetf7z.js +109 -0
  14. package/dist/chunk-jagzz148.js +527 -0
  15. package/dist/{chunk-1d4316hp.js → chunk-jfvq7s24.js} +38 -25
  16. package/dist/chunk-mbctzx7e.js +11436 -0
  17. package/dist/chunk-mej2bx5n.js +100 -0
  18. package/dist/chunk-p6spvbwq.js +6305 -0
  19. package/dist/chunk-pp1p3g6e.js +133 -0
  20. package/dist/chunk-r8p3nxcp.js +231 -0
  21. package/dist/chunk-txwt6r25.js +1731 -0
  22. package/dist/chunk-v290mf51.js +5242 -0
  23. package/dist/chunk-vjmz23rs.js +13 -0
  24. package/dist/chunk-vyv0p5eq.js +3183 -0
  25. package/dist/chunk-wh1pa2aa.js +15322 -0
  26. package/dist/chunk-x0b92bjb.js +222 -0
  27. package/dist/{chunk-8z5b6fpd.js → chunk-x9dhxfts.js} +216 -152
  28. package/dist/chunk-z821b2gp.js +164 -0
  29. package/dist/index.js +13 -5738
  30. package/dist/opencode-reader.main.ts +4 -0
  31. package/package.json +6 -5
  32. package/dist/chunk-3gxahgnq.js +0 -28495
  33. package/dist/chunk-ehzbtavj.js +0 -247
  34. package/dist/chunk-f5z8tgss.js +0 -1214
  35. package/dist/chunk-kdb1cbnx.js +0 -1273
  36. package/dist/chunk-ke1w0hx7.js +0 -5771
  37. package/dist/chunk-z6hc4ew9.js +0 -13
@@ -0,0 +1,100 @@
1
+ // @bun
2
+ import"./chunk-mbctzx7e.js";
3
+ import"./chunk-arvwar2c.js";
4
+ import"./chunk-pp1p3g6e.js";
5
+ import {
6
+ decideSecretRequest,
7
+ readSecretRegistry,
8
+ appendSecretRefusals
9
+ } from "./chunk-jafetf7z.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
+ };