

















@@ -28,6 +28,15 @@ function writeFakeCrabbox(binDir: string, helpText: string): string {
2828` process.stdout.write(${JSON.stringify(helpText)});`,
2929" process.exit(0);",
3030"}",
31+'if (args[0] === "config" && args[1] === "show" && args.includes("--json")) {',
32+" const status = Number.parseInt(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_STATUS || '0', 10);",
33+" if (status !== 0) {",
34+" process.stderr.write('config unavailable\\n');",
35+" process.exit(status);",
36+" }",
37+" process.stdout.write(process.env.OPENCLAW_FAKE_CRABBOX_CONFIG_JSON || '{\"coordinator\":\"configured-broker\",\"brokerAuth\":\"configured\"}');",
38+" process.exit(0);",
39+"}",
3140"const scriptIndex = args.findIndex((arg) => arg === '--script' || arg === '-script');",
3241"const scriptPath = scriptIndex >= 0 ? args[scriptIndex + 1] : '';",
3342"const scriptContent = scriptPath ? require('node:fs').readFileSync(scriptPath, 'utf8') : '';",
@@ -75,6 +84,9 @@ function runWrapper(
7584helpText: string,
7685args: string[],
7786options: {
87+configJson?: Record<string, unknown>;
88+configStatus?: number;
89+env?: Record<string, string>;
7890extraPathEntries?: string[];
7991gitResponses?: Record<string, { status?: number; stdout?: string; stderr?: string }>;
8092input?: string;
@@ -92,6 +104,13 @@ function runWrapper(
92104.filter(Boolean)
93105.join(path.delimiter),
94106OPENCLAW_CRABBOX_WRAPPER_IGNORE_REPO_BINARY: "1",
107+ ...(options.configJson
108+ ? { OPENCLAW_FAKE_CRABBOX_CONFIG_JSON: JSON.stringify(options.configJson) }
109+ : {}),
110+ ...(options.configStatus
111+ ? { OPENCLAW_FAKE_CRABBOX_CONFIG_STATUS: String(options.configStatus) }
112+ : {}),
113+ ...(options.env ?? {}),
95114 ...(options.gitResponses
96115 ? { OPENCLAW_FAKE_GIT_RESPONSES: JSON.stringify(options.gitResponses) }
97116 : {}),
@@ -189,6 +208,40 @@ describe("scripts/crabbox-wrapper", () => {
189208]);
190209});
191210211+it("fails closed for AWS proof when broker auth is missing", () => {
212+const result = runWrapper(
213+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
214+["run", "--provider", "aws", "--", "echo ok"],
215+{ configJson: { coordinator: "", brokerAuth: "missing" } },
216+);
217+218+expect(result.status).toBe(2);
219+expect(result.stdout).toBe("");
220+expect(result.stderr).toContain("provider=aws requires a configured Crabbox broker");
221+expect(result.stderr).toContain("crabbox login --provider aws");
222+expect(result.stderr).not.toContain("crabbox.openclaw.ai");
223+});
224+225+it("allows explicit direct AWS debugging without broker auth", () => {
226+const result = runWrapper(
227+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
228+["run", "--provider", "aws", "--", "echo ok"],
229+{
230+configJson: { coordinator: "", brokerAuth: "missing" },
231+env: { OPENCLAW_CRABBOX_ALLOW_DIRECT_AWS: "1" },
232+},
233+);
234+235+expect(result.status).toBe(0);
236+expect(parseFakeCrabboxOutput(result).args).toEqual([
237+"run",
238+"--provider",
239+"aws",
240+"--",
241+"echo ok",
242+]);
243+});
244+192245it("defaults AWS macOS warmups to on-demand capacity", () => {
193246const result = runWrapper(
194247"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。