@jphutchins/code-review 0.1.0-alpha.35 → 0.1.0-alpha.36-rc.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.
package/dist/index.js CHANGED
@@ -2736,6 +2736,32 @@ var composeReviewSettings = (opts) => {
2736
2736
  };
2737
2737
  };
2738
2738
 
2739
+ // src/sandbox.ts
2740
+ var GITHUB_HOSTS = ["api.github.com", "github.com"];
2741
+ var deriveModelHost = (apiBaseUrl) => {
2742
+ const host = URL.canParse(apiBaseUrl) ? new URL(apiBaseUrl).hostname : "";
2743
+ if (host === "") {
2744
+ throw new Error(
2745
+ `could not derive the model host from api_base_url ${JSON.stringify(apiBaseUrl)} \u2014 expected a URL like https://api.deepseek.com/anthropic`
2746
+ );
2747
+ }
2748
+ return host;
2749
+ };
2750
+ var parseExtraEndpoints = (extra) => extra.split(/\s+/).map((token) => token.replace(/:\d+$/, "")).filter((token) => token.length > 0);
2751
+ var buildSandboxConfig = (opts) => ({
2752
+ network: {
2753
+ allowedDomains: [
2754
+ .../* @__PURE__ */ new Set([
2755
+ deriveModelHost(opts.apiBaseUrl),
2756
+ ...GITHUB_HOSTS,
2757
+ ...parseExtraEndpoints(opts.extra ?? "")
2758
+ ])
2759
+ ],
2760
+ deniedDomains: []
2761
+ },
2762
+ filesystem: { allowRead: [], denyRead: [], allowWrite: ["/"], denyWrite: [] }
2763
+ });
2764
+
2739
2765
  // src/index.ts
2740
2766
  var readJSON = (path) => {
2741
2767
  try {
@@ -4189,6 +4215,37 @@ var awaitCiCmd = defineCommand({
4189
4215
  process.stdout.write(renderCiOutputs(outcome));
4190
4216
  }
4191
4217
  });
4218
+ var sandboxConfigCmd = defineCommand({
4219
+ meta: {
4220
+ name: "sandbox-config",
4221
+ description: "Emit the sandbox-runtime (srt) settings that jail the untrusted review agent's egress: allow the model host (derived from api_base_url), the GitHub API/host, and the consumer's extra_endpoints; deny all else; filesystem isolation off"
4222
+ },
4223
+ args: {
4224
+ "api-base-url": {
4225
+ type: "string",
4226
+ description: "The model endpoint the CLI dials (ANTHROPIC_BASE_URL) \u2014 its host is allowlisted",
4227
+ required: true
4228
+ },
4229
+ extra: {
4230
+ type: "string",
4231
+ description: "Whitespace-separated host[:port] list of extra domains to allow (the extra_endpoints input)"
4232
+ },
4233
+ out: {
4234
+ type: "string",
4235
+ description: "Write the settings JSON here instead of stdout"
4236
+ }
4237
+ },
4238
+ run: ({ args }) => {
4239
+ const config = buildSandboxConfig({ apiBaseUrl: args["api-base-url"], extra: args.extra });
4240
+ const json = `${JSON.stringify(config, null, 2)}
4241
+ `;
4242
+ if (args.out) {
4243
+ writeFileSync(resolve$1(args.out), json);
4244
+ } else {
4245
+ process.stdout.write(json);
4246
+ }
4247
+ }
4248
+ });
4192
4249
  var main = defineCommand({
4193
4250
  meta: {
4194
4251
  name: "code-review",
@@ -4218,7 +4275,8 @@ var main = defineCommand({
4218
4275
  "stop-gate": stopGateCmd,
4219
4276
  "budget-hook": budgetHookCmd,
4220
4277
  "print-settings": printSettingsCmd,
4221
- deadline: deadlineCmd
4278
+ deadline: deadlineCmd,
4279
+ "sandbox-config": sandboxConfigCmd
4222
4280
  }
4223
4281
  });
4224
4282
  if (!process.env["VITEST"]) {