@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.
Files changed (46) hide show
  1. package/dist/approval/prompt.js +17 -3
  2. package/dist/cli/commands/run.js +19 -1
  3. package/dist/cli/session-factory.d.ts +2 -1
  4. package/dist/cli/session-factory.js +10 -3
  5. package/dist/components/fuzzy.js +7 -1
  6. package/dist/config/schema.d.ts +123 -0
  7. package/dist/config/schema.js +40 -0
  8. package/dist/errors/constructors.d.ts +21 -0
  9. package/dist/errors/constructors.js +58 -0
  10. package/dist/errors/types.d.ts +5 -0
  11. package/dist/errors/types.js +11 -0
  12. package/dist/onboarding/steps.js +4 -1
  13. package/dist/render/capabilities.d.ts +10 -2
  14. package/dist/render/capabilities.js +26 -6
  15. package/dist/render/index.d.ts +9 -5
  16. package/dist/render/index.js +12 -5
  17. package/dist/render/plain-renderer.d.ts +3 -3
  18. package/dist/render/plain-renderer.js +10 -2
  19. package/dist/render/screen-reader-renderer.d.ts +45 -0
  20. package/dist/render/screen-reader-renderer.js +75 -0
  21. package/dist/render/types.d.ts +15 -1
  22. package/dist/sandbox/detect.d.ts +22 -0
  23. package/dist/sandbox/detect.js +67 -0
  24. package/dist/sandbox/docker-runtime.d.ts +32 -0
  25. package/dist/sandbox/docker-runtime.js +263 -0
  26. package/dist/sandbox/index.d.ts +7 -0
  27. package/dist/sandbox/index.js +5 -0
  28. package/dist/sandbox/policy.d.ts +17 -0
  29. package/dist/sandbox/policy.js +90 -0
  30. package/dist/sandbox/service.d.ts +57 -0
  31. package/dist/sandbox/service.js +64 -0
  32. package/dist/sandbox/types.d.ts +114 -0
  33. package/dist/sandbox/types.js +17 -0
  34. package/dist/subagent/orchestrator.d.ts +7 -0
  35. package/dist/subagent/orchestrator.js +1 -0
  36. package/dist/testing/run-tests-tool.d.ts +5 -1
  37. package/dist/testing/run-tests-tool.js +8 -1
  38. package/dist/testing/sandbox-runner.d.ts +16 -0
  39. package/dist/testing/sandbox-runner.js +47 -0
  40. package/dist/theme/resolve.d.ts +18 -7
  41. package/dist/theme/resolve.js +32 -10
  42. package/dist/theme/tokens.d.ts +16 -1
  43. package/dist/theme/tokens.js +27 -0
  44. package/dist/tools/shell/run-command.js +35 -1
  45. package/dist/tools/types.d.ts +10 -0
  46. 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
- return runBounded(input.command, ctx);
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;
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cruxy/cli",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "an agentic coding CLI",
5
5
  "type": "module",
6
6
  "bin": {