@mycadet/cli 0.13.0-dev.202611110042.6f8c11c → 0.13.0-dev.202611131045.a556a8a

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/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
  2. package/node_modules/@mycadet/assistant-api/responses/activation.ts +1 -1
  3. package/node_modules/@mycadet/assistant-api/responses/conversation-message.ts +1 -1
  4. package/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  5. package/node_modules/@mycadet/environments/package.json +1 -1
  6. package/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  8. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/package.json +1 -1
  9. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  10. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
  11. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/eslint/no-empty-imports.mjs +65 -0
  12. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/eslint/no-empty-imports.test.mjs +71 -0
  13. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/package.json +3 -2
  14. package/node_modules/@mycadet/local-mode/package.json +1 -1
  15. package/node_modules/@mycadet/local-mode/src/__tests__/local-exec-invocation.test.ts +111 -0
  16. package/node_modules/@mycadet/local-mode/src/index.ts +32 -0
  17. package/node_modules/@mycadet/local-mode/src/operations/exec.ts +139 -0
  18. package/{src/lib/remotes/apple-container.ts → node_modules/@mycadet/local-mode/src/remotes/apple-container/exec.ts} +3 -5
  19. package/node_modules/@mycadet/local-mode/src/remotes/baseten/Dockerfile +5 -3
  20. package/node_modules/@mycadet/local-mode/src/remotes/baseten/entrypoint.sh +17 -3
  21. package/node_modules/@mycadet/local-mode/src/remotes/cloud/exec.ts +520 -0
  22. package/{src/lib → node_modules/@mycadet/local-mode/src/remotes/cloud}/terminal-client.ts +2 -5
  23. package/node_modules/@mycadet/local-mode/src/remotes/docker/exec.ts +33 -0
  24. package/node_modules/@mycadet/local-mode/src/remotes/local/common.ts +37 -1
  25. package/node_modules/@mycadet/local-mode/src/remotes/local/exec.ts +104 -1
  26. package/node_modules/@mycadet/local-mode/src/remotes/local/wake.ts +11 -0
  27. package/node_modules/@mycadet/service-contracts/package.json +1 -1
  28. package/node_modules/@mycadet/shared/eslint/no-empty-imports.mjs +65 -0
  29. package/node_modules/@mycadet/shared/eslint/no-empty-imports.test.mjs +71 -0
  30. package/node_modules/@mycadet/shared/package.json +3 -2
  31. package/package.json +1 -1
  32. package/src/commands/exec.ts +17 -190
  33. package/src/commands/pair.ts +1 -1
  34. package/src/commands/terminal.ts +5 -7
  35. package/src/lib/__tests__/terminal-session.test.ts +1 -1
  36. package/src/lib/remotes/cloud.ts +1 -1
  37. package/src/lib/terminal-session.ts +5 -516
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,7 +33,7 @@ export const ACTIVATION_ID_PATTERN = /^[a-z0-9-]{1,64}$/;
33
33
  */
34
34
  export const ACTIVATION_CONVERSATION_ID_MAX_LENGTH = 128;
35
35
 
36
- export const ActivationIdSchema = z
36
+ const ActivationIdSchema = z
37
37
  .string()
38
38
  .regex(ACTIVATION_ID_PATTERN)
39
39
  .describe("Opaque lowercase-kebab identifier, 1-64 characters");
@@ -324,7 +324,7 @@ export type ConversationSubagentNotification = z.infer<
324
324
  // ---------------------------------------------------------------------------
325
325
 
326
326
  /** Daemon-injected ACP-run lifecycle notification attached to a history row. */
327
- export const ConversationAcpNotificationSchema = z.object({
327
+ const ConversationAcpNotificationSchema = z.object({
328
328
  acpSessionId: z.string(),
329
329
  agent: z.string().optional(),
330
330
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/environments",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/environments",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,65 @@
1
+ // @ts-check
2
+ /**
3
+ * `no-empty-imports` — outlaw import declarations that bind no names.
4
+ *
5
+ * `import type {} from "y"` compiles to nothing: TypeScript erases it
6
+ * entirely, so the "dependency" it describes does not exist at runtime and
7
+ * only exists in the type graph. `import {} from "y"` is the same statement
8
+ * with the braces kept — a side-effect import written in a shape that
9
+ * *looks* like it is about to name bindings. Both are husks, usually left
10
+ * behind by a codemod that removed the last binding (a knip sweep, an
11
+ * unused-type cleanup) and kept the shell of the import alive.
12
+ *
13
+ * The fix is almost always deletion: if the file uses nothing from the
14
+ * module, the import line goes away. Two legitimate survivors exist:
15
+ * - a real side-effect dependency (`import "y"`) — write it bare, so the
16
+ * intent is explicit (this is how composition roots wire seams);
17
+ * - a module that must join the type program for its declarations to apply
18
+ * (module augmentation) — then import a name from it, or use a bare
19
+ * value import so the dependency is a visible, runtime-real edge.
20
+ *
21
+ * Flagged shapes:
22
+ * - `import type {} from "y"` (empty type import — erased at compile time)
23
+ * - `import {} from "y"` (empty named import)
24
+ *
25
+ * Not flagged: `import "y"` — a bare side-effect import is an intentional
26
+ * statement that the module's evaluation matters, and carries no pretense
27
+ * of bindings. `import type * as ns from "y"` also survives: it binds
28
+ * `ns`, and an unused namespace is `no-unused-vars`' territory.
29
+ */
30
+
31
+ /** True for an empty named import list: the AST gives `import {} from "y"` and `import "y"` the same shape, so the braces only exist in the text. */
32
+ function hasEmptyNamedList(sourceCode, node) {
33
+ const text = sourceCode.getText(node);
34
+ return /^import\s*(?:type\s*)?\{/.test(text);
35
+ }
36
+
37
+ /** The rule object exported for `eslint.config` `plugins` registries. */
38
+ export const noEmptyImports = {
39
+ meta: {
40
+ type: "problem",
41
+ docs: {
42
+ description: "outlaw import declarations that bind no names",
43
+ },
44
+ schema: [],
45
+ messages: {
46
+ emptyTypeImport:
47
+ "This type import binds no names — TypeScript erases the whole declaration, so the dependency it describes does not exist. Delete it, or import the names this file actually uses.",
48
+ emptyImport:
49
+ 'This import binds no names. For side effects only, write a bare `import "source"`; otherwise import the names this file actually uses.',
50
+ },
51
+ },
52
+ create(context) {
53
+ return {
54
+ ImportDeclaration(node) {
55
+ if (node.specifiers.length > 0) return;
56
+ if (!hasEmptyNamedList(context.sourceCode, node)) return;
57
+ context.report({
58
+ node,
59
+ messageId:
60
+ node.importKind === "type" ? "emptyTypeImport" : "emptyImport",
61
+ });
62
+ },
63
+ };
64
+ },
65
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Unit tests for the no-empty-imports ESLint rule.
3
+ *
4
+ * Run with: `bun test packages/shared/eslint/no-empty-imports.test.mjs`
5
+ *
6
+ * A passing run prints "Ran 0 tests". That is a reporting artifact, not a
7
+ * skip: bun does not expose `describe` / `it` as globals to `.mjs`, so
8
+ * `RuleTester` falls back to its own inline runner and never registers with
9
+ * bun's reporter. The cases still execute, a wrong expectation still throws,
10
+ * and the process still exits non-zero. Verify by breaking a case on purpose.
11
+ */
12
+ import { RuleTester } from "eslint";
13
+ import tseslint from "typescript-eslint";
14
+
15
+ import { noEmptyImports } from "./no-empty-imports.mjs";
16
+
17
+ const ruleTester = new RuleTester({
18
+ languageOptions: {
19
+ parser: tseslint.parser,
20
+ ecmaVersion: "latest",
21
+ sourceType: "module",
22
+ },
23
+ });
24
+
25
+ ruleTester.run("no-empty-imports", noEmptyImports, {
26
+ valid: [
27
+ {
28
+ name: "a bare side-effect import is the honest shape and survives",
29
+ code: 'import "./auto-update.client";',
30
+ },
31
+ {
32
+ name: "an import that binds names survives",
33
+ code: 'import { applyEdit } from "./edit-engine.js";',
34
+ },
35
+ {
36
+ name: "a type import that binds names survives",
37
+ code: 'import type { EditEngineResult } from "./edit-engine.js";',
38
+ },
39
+ {
40
+ name: "a namespace import survives (unused ns is no-unused-vars' job)",
41
+ code: 'import type * as protocol from "./message-protocol.js";',
42
+ },
43
+ {
44
+ name: "a default import survives",
45
+ code: 'import log from "./logger.js";',
46
+ },
47
+ ],
48
+
49
+ invalid: [
50
+ {
51
+ name: "empty type import — the knip-sweep husk",
52
+ code: 'import type {} from "../tools/shared/filesystem/edit-engine.js";',
53
+ errors: [{ messageId: "emptyTypeImport" }],
54
+ },
55
+ {
56
+ name: "empty type import of a builtin",
57
+ code: 'import type {} from "bun:sqlite";',
58
+ errors: [{ messageId: "emptyTypeImport" }],
59
+ },
60
+ {
61
+ name: "empty named value import",
62
+ code: 'import {} from "./fixtures/edge-swipe";',
63
+ errors: [{ messageId: "emptyImport" }],
64
+ },
65
+ {
66
+ name: "spaced-out braces still count",
67
+ code: 'import { } from "./x.js";',
68
+ errors: [{ messageId: "emptyImport" }],
69
+ },
70
+ ],
71
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./github-repository.ts",
@@ -10,7 +10,8 @@
10
10
  "./scripts/run-isolated-tests": "./scripts/run-isolated-tests.ts",
11
11
  "./version": "./version.ts",
12
12
  "./eslint/no-re-exports": "./eslint/no-re-exports.mjs",
13
- "./eslint/imports-first": "./eslint/imports-first.mjs"
13
+ "./eslint/imports-first": "./eslint/imports-first.mjs",
14
+ "./eslint/no-empty-imports": "./eslint/no-empty-imports.mjs"
14
15
  },
15
16
  "devDependencies": {
16
17
  "eslint": "10.1.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/local-mode",
3
- "version": "0.13.0-dev.202611110042.6f8c11c",
3
+ "version": "0.13.0-dev.202611131045.a556a8a",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,111 @@
1
+ import { chmodSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
5
+ import { ensureLocalBinShims } from "../remotes/local/exec";
6
+
7
+ // The bin/ folder is the contract: exec prepends it to the child's PATH, so
8
+ // EVERY invocation shape — argv, compound commands, pipes, shell scripts —
9
+ // resolves the cadet binaries to the source build the daemons run, never a
10
+ // globally installed published build from the host PATH. These tests pin the
11
+ // shim contents: each binary's entry point must match its package's own bin.
12
+ // In a checkout with no runtime install, resolution falls through to the
13
+ // repo-root source tree — four levels up from this __tests__ dir.
14
+ const repoRoot = join(import.meta.dir, "..", "..", "..", "..");
15
+
16
+ describe("ensureLocalBinShims", () => {
17
+ let instanceDir: string;
18
+
19
+ beforeEach(() => {
20
+ instanceDir = join(
21
+ tmpdir(),
22
+ `cadet-bin-shims-${Date.now()}-${Math.random().toString(36).slice(2)}`,
23
+ );
24
+ mkdirSync(instanceDir, { recursive: true });
25
+ });
26
+
27
+ afterEach(() => {
28
+ try {
29
+ rmSync(instanceDir, { recursive: true, force: true });
30
+ } catch {
31
+ // best-effort — a leaked temp dir is harmless
32
+ }
33
+ });
34
+
35
+ function entry() {
36
+ return {
37
+ assistantId: "shim-test",
38
+ cloud: "local" as const,
39
+ port: 7821,
40
+ instanceDir,
41
+ };
42
+ }
43
+
44
+ function shimBody(name: string): string {
45
+ return readFileSync(join(instanceDir, "bin", name), "utf-8");
46
+ }
47
+
48
+ test("writes executable shims for every cadet binary", () => {
49
+ const { dir, unresolved } = ensureLocalBinShims(entry());
50
+ expect(unresolved).toEqual([]);
51
+ expect(dir).toBe(join(instanceDir, "bin"));
52
+ for (const name of ["assistant", "gateway", "ces"]) {
53
+ const mode = statSync(join(dir, name)).mode & 0o111;
54
+ expect(mode).not.toBe(0);
55
+ }
56
+ });
57
+
58
+ test("assistant shim runs its own bin entry from source", () => {
59
+ ensureLocalBinShims(entry());
60
+ expect(shimBody("assistant")).toContain(
61
+ join(repoRoot, "assistant", "src", "index.ts"),
62
+ );
63
+ });
64
+
65
+ test("gateway shim runs the CLI entry, not the server entry", () => {
66
+ // `gateway`'s bin is src/cli/index.ts; src/index.ts is the server entry
67
+ // startGateway spawns — the shim must never boot a second server.
68
+ ensureLocalBinShims(entry());
69
+ expect(shimBody("gateway")).toContain(
70
+ join(repoRoot, "gateway", "src", "cli", "index.ts"),
71
+ );
72
+ });
73
+
74
+ test("ces shim runs its CLI entry", () => {
75
+ ensureLocalBinShims(entry());
76
+ expect(shimBody("ces")).toContain(
77
+ join(repoRoot, "credential-executor", "src", "cli.ts"),
78
+ );
79
+ });
80
+
81
+ test("a runtime install outranks the source tree", () => {
82
+ // The instance's newest self-managed runtime install is what the daemon
83
+ // stack runs — the shims must bake THAT path, not the checkout's.
84
+ const runtimeDir = join(instanceDir, "runtime", "001");
85
+ const fakeIndex = join(
86
+ runtimeDir,
87
+ "node_modules",
88
+ "@mycadet",
89
+ "assistant",
90
+ "src",
91
+ "index.ts",
92
+ );
93
+ mkdirSync(join(runtimeDir, "node_modules", "@mycadet", "assistant", "src"), {
94
+ recursive: true,
95
+ });
96
+ writeFileSync(fakeIndex, "export {};\n");
97
+ chmodSync(fakeIndex, 0o644);
98
+ ensureLocalBinShims(entry());
99
+ expect(shimBody("assistant")).toContain(fakeIndex);
100
+ });
101
+
102
+ test("shims exec through bun with run", () => {
103
+ ensureLocalBinShims(entry());
104
+ for (const name of ["assistant", "gateway", "ces"]) {
105
+ const body = shimBody(name);
106
+ expect(body.startsWith("#!/bin/sh")).toBe(true);
107
+ expect(body).toContain(" run ");
108
+ expect(body.trimEnd().endsWith('"$@"')).toBe(true);
109
+ }
110
+ });
111
+ });
@@ -23,6 +23,38 @@ export {
23
23
  export { stageBasetenBuildContext } from "./remotes/baseten/context";
24
24
  export { execBasetenSandbox } from "./remotes/baseten/exec";
25
25
  export { localExecDirForService } from "./remotes/local/exec";
26
+ export { ensureLocalBinShims } from "./remotes/local/exec";
27
+ export {
28
+ DEFAULT_EXEC_TIMEOUT,
29
+ execCommand,
30
+ } from "./operations/exec";
31
+ export {
32
+ appleContainerPair,
33
+ execAppleContainer,
34
+ sshAppleContainer,
35
+ } from "./remotes/apple-container/exec";
36
+ export {
37
+ closeTerminalSession,
38
+ createTerminalSession,
39
+ execViaTerminalSession,
40
+ parseSentinelOutput,
41
+ stripAnsi,
42
+ interactiveSession,
43
+ nonInteractiveExec,
44
+ resizeTerminalSession,
45
+ sendTerminalInput,
46
+ shellEscapeArgs,
47
+ subscribeTerminalEvents,
48
+ } from "./remotes/cloud/exec";
49
+ export type {
50
+ NonInteractiveExecOptions,
51
+ ResolvedManagedAssistant,
52
+ } from "./remotes/cloud/exec";
53
+ export { RemoteExecTimeoutError } from "./remotes/cloud/exec";
54
+ export type {
55
+ ExecCommandOptions,
56
+ ExecCommandResult,
57
+ } from "./operations/exec";
26
58
  export { createBackup, formatSize } from "./backup-ops";
27
59
 
28
60
  export { type ManagedProcessEntry } from "./daemon-readiness";
@@ -0,0 +1,139 @@
1
+ import { readCloudToken, resolveCloudUrl } from "../cloud-auth";
2
+ import { cliCommand } from "../environment";
3
+ import type { LockfileAssistant } from "../lockfile-contract";
4
+ import { execBasetenSandbox } from "../remotes/baseten/exec";
5
+ import {
6
+ execAppleContainer,
7
+ sshAppleContainer,
8
+ } from "../remotes/apple-container/exec";
9
+ import { execDocker } from "../remotes/docker/exec";
10
+ import { execLocal } from "../remotes/local/exec";
11
+ import type { ServiceName } from "../remotes/docker/statefulset";
12
+ import {
13
+ interactiveSession,
14
+ nonInteractiveExec,
15
+ shellEscapeArgs,
16
+ } from "../remotes/cloud/exec";
17
+
18
+ /** The exec timeout a caller implies by passing nothing (`--timeout` omitted). */
19
+ export const DEFAULT_EXEC_TIMEOUT = 30_000;
20
+
21
+ /** Options the exec operation dispatches on. */
22
+ export interface ExecCommandOptions {
23
+ /** The full argv after `--` — the command to run inside the service. */
24
+ command: string[];
25
+ /** Which service's directory/state the command runs against. */
26
+ service: ServiceName;
27
+ /** Interactive mode with TTY (like docker exec -it). */
28
+ interactive?: boolean;
29
+ /** Cloud only: show debug output. */
30
+ verbose?: boolean;
31
+ /** Milliseconds before the sandbox kills the process; 0 = never. Feeding
32
+ * the default is the same as feeding nothing. */
33
+ timeoutMs?: number;
34
+ }
35
+
36
+ /**
37
+ * An exec's outcome: the command either ran (its own exit code — its output
38
+ * already went to the caller's stdio) or was refused before any spawn
39
+ * (status + the diagnostic the CLI prints).
40
+ */
41
+ export type ExecCommandResult =
42
+ | { ok: true; code: number }
43
+ | { ok: false; code: number }
44
+ | { ok: false; status: number; error: string };
45
+
46
+ /**
47
+ * The exec operation: run a command inside an assistant's service — the
48
+ * remote -> method router, like sleep/wake. Local runs the command on the
49
+ * host with the instance's bin/ shims on PATH; docker dials the service
50
+ * container; baseten rides the sandbox's execution API; apple-container
51
+ * dials the management socket and cloud opens a terminal session — every
52
+ * leg lives here, like wake.
53
+ */
54
+ export async function execCommand(
55
+ entry: LockfileAssistant,
56
+ opts: ExecCommandOptions,
57
+ ): Promise<ExecCommandResult> {
58
+ switch (entry.cloud) {
59
+ case "local":
60
+ return await execLocal(entry, opts);
61
+ case "docker":
62
+ return await execDocker(entry, opts);
63
+ case "apple-container": {
64
+ const fullServiceName = `cadet-${opts.service}`;
65
+ if (opts.interactive) {
66
+ await sshAppleContainer(entry, opts.command, fullServiceName);
67
+ } else {
68
+ await execAppleContainer(entry, opts.command, fullServiceName);
69
+ }
70
+ return { ok: true, code: 0 };
71
+ }
72
+ case "cloud": {
73
+ const token = readCloudToken();
74
+ if (!token) {
75
+ return {
76
+ ok: false,
77
+ status: 401,
78
+ error:
79
+ "Not logged in. Run `cadet login` first to authenticate with Cadet Cloud.",
80
+ };
81
+ }
82
+ const assistant = {
83
+ assistantId: entry.assistantId,
84
+ token,
85
+ cloudUrl: resolveCloudUrl(),
86
+ };
87
+ const serviceParam =
88
+ opts.service === "assistant" ? undefined : opts.service;
89
+ if (opts.interactive) {
90
+ await interactiveSession(
91
+ assistant,
92
+ shellEscapeArgs(opts.command),
93
+ serviceParam,
94
+ );
95
+ return { ok: true, code: 0 };
96
+ }
97
+ // Non-interactive: sentinel-based output capture; exits with the
98
+ // command's own exit code.
99
+ await nonInteractiveExec(assistant, opts.command, {
100
+ verbose: opts.verbose,
101
+ timeoutMs: opts.timeoutMs ?? DEFAULT_EXEC_TIMEOUT,
102
+ service: serviceParam,
103
+ });
104
+ return { ok: true, code: 0 };
105
+ }
106
+ case "baseten": {
107
+ if (!entry.name) {
108
+ return {
109
+ ok: false,
110
+ status: 400,
111
+ error:
112
+ `assistant '${entry.assistantId}' has no sandbox name ` +
113
+ "recorded — re-hatch with `cadet hatch --remote baseten` to fix.",
114
+ };
115
+ }
116
+ const { code } = await execBasetenSandbox({
117
+ assistantId: entry.assistantId,
118
+ sandboxUrl: entry.sandboxUrl,
119
+ name: entry.name,
120
+ command: opts.command,
121
+ service: opts.service,
122
+ interactive: opts.interactive,
123
+ ...(opts.timeoutMs !== undefined &&
124
+ opts.timeoutMs !== DEFAULT_EXEC_TIMEOUT
125
+ ? { timeoutSeconds: Math.round(opts.timeoutMs / 1000) }
126
+ : {}),
127
+ });
128
+ return code === 0 ? { ok: true, code } : { ok: false, code };
129
+ }
130
+ default:
131
+ return {
132
+ ok: false,
133
+ status: 400,
134
+ error:
135
+ `'${cliCommand()} exec' is not supported for ${entry.cloud} ` +
136
+ "assistants — supported: local, docker, apple-container, cloud, baseten.",
137
+ };
138
+ }
139
+ }
@@ -6,11 +6,9 @@
6
6
  import { createConnection } from "net";
7
7
  import { existsSync } from "fs";
8
8
 
9
- import {
10
- type AppleContainerAssistant,
11
- isAppleContainerEntry,
12
- type LockfileAssistant,
13
- } from "@mycadet/local-mode/contract";
9
+ import type { AppleContainerAssistant } from "../../lockfile-contract";
10
+ import { isAppleContainerEntry } from "../../lockfile-contract";
11
+ import type { LockfileAssistant } from "../../lockfile-contract";
14
12
 
15
13
  /**
16
14
  * Execute a command inside an Apple Container assistant via the management
@@ -39,9 +39,11 @@ ENV PATH="/root/.bun/bin:${PATH}"
39
39
  COPY --from=ghcr.io/blaxel-ai/sandbox@sha256:8ebb596be14ed4c48f6fe4352e9d3de45dc31634dbca2194293187f54aba8647 \
40
40
  /sandbox-api /usr/local/bin/sandbox-api
41
41
 
42
- # The published stack: `cadet`/`gateway`/`assistant` bins on PATH plus every
43
- # runtime package (@mycadet/cli, web, gateway, assistant, credential-executor).
44
- # Stamped from cli/package.json.
42
+ # The published stack: the `cadet` bin on PATH plus every runtime package
43
+ # (@mycadet/cli, web, gateway, assistant, credential-executor). Stamped from
44
+ # cli/package.json. The meta package stopped shipping assistant/gateway bins —
45
+ # on a HOST they shadow the local source; here the shims below replace them
46
+ # with the sandbox's own version-correct resolution.
45
47
  ARG MYCADET_VERSION
46
48
  RUN bun add -g "mycadet@${MYCADET_VERSION}"
47
49
 
@@ -2,13 +2,20 @@
2
2
  # Cadet sandbox entrypoint.
3
3
  #
4
4
  # Sandbox startup order:
5
- # 1. sandbox-api in the background — Baseten requires it and its process /
5
+ # 1. the instance's bin/ shims are materialized and their dir prepended to
6
+ # PATH. Sandbox execs inherit THIS process's environment, fixed before
7
+ # `cadet wake` ever runs, so the shim dir must be on PATH from the
8
+ # start — the shims land inside it here and every wake after refreshes
9
+ # them. They resolve the cadet binaries to the sandbox's own install,
10
+ # the same build the daemon stack runs. Best effort: a resolution
11
+ # failure leaves PATH untouched.
12
+ # 2. sandbox-api in the background — Baseten requires it and its process /
6
13
  # filesystem / port APIs are the platform's window into the sandbox.
7
- # 2. `cadet wake` in the background — brings up the hatched assistant
14
+ # 3. `cadet wake` in the background — brings up the hatched assistant
8
15
  # (daemon + gateway + CES) with its logs streaming to the sandbox
9
16
  # console. When the hatch mounted a state volume it pointed the XDG
10
17
  # homes at it at create time, so every write below lands there.
11
- # 3. `wait` — holds the container open. When either background job exits,
18
+ # 4. `wait` — holds the container open. When either background job exits,
12
19
  # the container is considered dead and Baseten restarts it.
13
20
  #
14
21
  # The model loop runs IN the sandbox: the assistant daemon is the primary
@@ -16,6 +23,13 @@
16
23
  # of it.
17
24
  set -eu
18
25
 
26
+ SHIM_DIR=$(bun -e '
27
+ const { readLockfile, ensureLocalBinShims } = require("@mycadet/local-mode");
28
+ const entry = readLockfile().assistants.find((a) => a.cloud === "local");
29
+ if (entry) process.stdout.write(ensureLocalBinShims(entry).dir);
30
+ ' 2>/dev/null || true)
31
+ export PATH="${SHIM_DIR:+$SHIM_DIR:$PATH}"
32
+
19
33
  /usr/local/bin/sandbox-api &
20
34
 
21
35
  cd /app