@cruxy/cli 0.12.0 → 0.14.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/approval/prompt.js +17 -3
- package/dist/cli/commands/run.js +19 -1
- package/dist/cli/session-factory.d.ts +2 -1
- package/dist/cli/session-factory.js +10 -3
- package/dist/components/fuzzy.js +7 -1
- package/dist/config/schema.d.ts +123 -0
- package/dist/config/schema.js +40 -0
- package/dist/errors/constructors.d.ts +21 -0
- package/dist/errors/constructors.js +58 -0
- package/dist/errors/types.d.ts +5 -0
- package/dist/errors/types.js +11 -0
- package/dist/onboarding/steps.js +4 -1
- package/dist/render/capabilities.d.ts +10 -2
- package/dist/render/capabilities.js +26 -6
- package/dist/render/index.d.ts +9 -5
- package/dist/render/index.js +12 -5
- package/dist/render/plain-renderer.d.ts +3 -3
- package/dist/render/plain-renderer.js +10 -2
- package/dist/render/screen-reader-renderer.d.ts +45 -0
- package/dist/render/screen-reader-renderer.js +75 -0
- package/dist/render/types.d.ts +15 -1
- package/dist/sandbox/detect.d.ts +22 -0
- package/dist/sandbox/detect.js +67 -0
- package/dist/sandbox/docker-runtime.d.ts +32 -0
- package/dist/sandbox/docker-runtime.js +263 -0
- package/dist/sandbox/index.d.ts +7 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/policy.d.ts +17 -0
- package/dist/sandbox/policy.js +90 -0
- package/dist/sandbox/service.d.ts +57 -0
- package/dist/sandbox/service.js +64 -0
- package/dist/sandbox/types.d.ts +114 -0
- package/dist/sandbox/types.js +17 -0
- package/dist/subagent/orchestrator.d.ts +7 -0
- package/dist/subagent/orchestrator.js +1 -0
- package/dist/testing/run-tests-tool.d.ts +5 -1
- package/dist/testing/run-tests-tool.js +8 -1
- package/dist/testing/sandbox-runner.d.ts +16 -0
- package/dist/testing/sandbox-runner.js +47 -0
- package/dist/theme/resolve.d.ts +18 -7
- package/dist/theme/resolve.js +32 -10
- package/dist/theme/tokens.d.ts +16 -1
- package/dist/theme/tokens.js +27 -0
- package/dist/tools/shell/run-command.js +35 -1
- package/dist/tools/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -26,9 +26,43 @@ export const runCommandTool = {
|
|
|
26
26
|
error: decision.feedback ?? "command denied by the user",
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
// Substrate is chosen SOLELY by ctx.sandbox: present → run in the box (C.16),
|
|
30
|
+
// never on the host; absent → host, unchanged. There is no fallback path — a
|
|
31
|
+
// sandbox that can't run throws a coded error (see runSandboxed) rather than
|
|
32
|
+
// silently reaching runBounded.
|
|
33
|
+
return ctx.sandbox
|
|
34
|
+
? runSandboxed(input.command, ctx)
|
|
35
|
+
: runBounded(input.command, ctx);
|
|
30
36
|
},
|
|
31
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Run inside the sandbox and map the neutral ExecResult onto the IDENTICAL
|
|
40
|
+
* ToolResult the host path produces — same "exit code N" framing, same
|
|
41
|
+
* truncation note, same timeout message — so the tool is substrate-agnostic.
|
|
42
|
+
* A container-start / image failure throws a coded CruxyError from
|
|
43
|
+
* `sandbox.exec` and propagates; we deliberately do not catch it (fail loud).
|
|
44
|
+
*/
|
|
45
|
+
function runSandboxed(command, ctx) {
|
|
46
|
+
const { timeoutMs, maxOutputBytes } = ctx.config.shell;
|
|
47
|
+
return ctx
|
|
48
|
+
.sandbox.exec(command, {
|
|
49
|
+
cwd: ctx.cwd,
|
|
50
|
+
timeoutMs,
|
|
51
|
+
maxOutputBytes,
|
|
52
|
+
capture: "head",
|
|
53
|
+
})
|
|
54
|
+
.then((result) => {
|
|
55
|
+
if (result.timedOut) {
|
|
56
|
+
return { ok: false, error: `timed out after ${timeoutMs}ms` };
|
|
57
|
+
}
|
|
58
|
+
const exit = result.exitCode ?? "unknown";
|
|
59
|
+
let output = `exit code ${exit}\n${result.output}`;
|
|
60
|
+
if (result.outputTruncated) {
|
|
61
|
+
output += `\n… [output truncated at ${maxOutputBytes} bytes]`;
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, output };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
32
66
|
/** Spawn the command, capture bounded output, and enforce the timeout. */
|
|
33
67
|
function runBounded(command, ctx) {
|
|
34
68
|
const { timeoutMs, maxOutputBytes } = ctx.config.shell;
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { z, ZodTypeAny } from "zod";
|
|
2
2
|
import type { CruxyConfig } from "../config/index.js";
|
|
3
3
|
import type { ApprovalDecision } from "../approval/types.js";
|
|
4
|
+
import type { SandboxService } from "../sandbox/index.js";
|
|
4
5
|
import type { logger } from "../utils/logger.js";
|
|
5
6
|
/** The leveled logger instance shared across the CLI. */
|
|
6
7
|
type Logger = typeof logger;
|
|
@@ -131,6 +132,15 @@ export interface ToolContext {
|
|
|
131
132
|
* tools never call this.
|
|
132
133
|
*/
|
|
133
134
|
requestApproval(action: ApproveAction): Promise<ApprovalDecision>;
|
|
135
|
+
/**
|
|
136
|
+
* Isolation substrate for the shell + test tools (C.16). Present ONLY when
|
|
137
|
+
* the sandbox is enabled; when set, `run_command`/`run_tests` execute the
|
|
138
|
+
* approved command inside the container and NEVER on the host. Its mere
|
|
139
|
+
* presence is the switch — there is no host fallback once it is set (an
|
|
140
|
+
* unavailable runtime fails loud at construction, before this is ever
|
|
141
|
+
* populated). Absent → host execution, unchanged.
|
|
142
|
+
*/
|
|
143
|
+
sandbox?: SandboxService;
|
|
134
144
|
}
|
|
135
145
|
/**
|
|
136
146
|
* The one interface every tool implements. `parameters` is a zod schema; it both
|