@cotal-ai/cmux 0.8.1 → 0.8.3
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/runtime.d.ts +10 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +11 -7
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { type AgentHandle, type LaunchSpec, type Runtime, type RuntimeProvider, type TerminalLayout } from "@cotal-ai/core";
|
|
1
|
+
import { type AgentHandle, type LaunchSpec, type Pane, type Runtime, type RuntimeProvider, type TerminalLayout } from "@cotal-ai/core";
|
|
2
|
+
/** cmux can't run a command in a fresh surface directly, and panes start under a login shell
|
|
3
|
+
* (maybe nushell) before bash — so we write each pane's launch as a temp bash script and point
|
|
4
|
+
* the tab at it, sidestepping all shell quoting (callers pass argv, never shell strings). `login`
|
|
5
|
+
* runs it as a login shell (`bash -l`) so the user's PATH is present — setup's panes run further
|
|
6
|
+
* `cotal` subcommands that resolve `claude`. `exec env …` (not `exec …`): exec can't take KEY=val
|
|
7
|
+
* assignments, so `env` applies them and then execs the command. `isolate` (agent-spawn panes)
|
|
8
|
+
* adds `-i` so the pane inherits ONLY the connector-declared env, not the cmux server's (P3 — the
|
|
9
|
+
* operator's unrelated secrets don't reach a spawned agent); setup panes keep the inherited env. */
|
|
10
|
+
export declare function paneCommand(pane: Pane, login: boolean, isolate?: boolean): string;
|
|
2
11
|
/**
|
|
3
12
|
* Spawns each agent into its own new cmux tab (workspace), so spawned teammates get
|
|
4
13
|
* room instead of crowding the spawner. The launch goes through {@link paneCommand}
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAgBxB;;;;;;;qGAOqG;AACrG,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,UAAQ,GAAG,MAAM,CAa/E;AAkBD;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,OAAO;IACzC,QAAQ,CAAC,IAAI,UAAU;IAEvB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW;CAyDhE;AAED;+EAC+E;AAC/E,eAAO,MAAM,mBAAmB,EAAE,eAKjC,CAAC;AAIF;;;;qBAIqB;AACrB,eAAO,MAAM,oBAAoB,EAAE,cAOlC,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
1
|
+
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { registry, } from "@cotal-ai/core";
|
|
@@ -20,15 +20,19 @@ function shellQuote(s) {
|
|
|
20
20
|
* assignments, so `env` applies them and then execs the command. `isolate` (agent-spawn panes)
|
|
21
21
|
* adds `-i` so the pane inherits ONLY the connector-declared env, not the cmux server's (P3 — the
|
|
22
22
|
* operator's unrelated secrets don't reach a spawned agent); setup panes keep the inherited env. */
|
|
23
|
-
function paneCommand(pane,
|
|
23
|
+
export function paneCommand(pane, login, isolate = false) {
|
|
24
24
|
const env = Object.entries(pane.env ?? {}).map(([k, v]) => `${k}=${shellQuote(v)}`);
|
|
25
25
|
const cmd = [...env, shellQuote(pane.command), ...(pane.args ?? []).map(shellQuote)].join(" ");
|
|
26
26
|
const cd = pane.cwd ? `cd ${shellQuote(pane.cwd)}\n` : "";
|
|
27
27
|
const confirm = pane.confirm ? `${ENTER_LOOP}\n` : "";
|
|
28
28
|
const script = `#!/usr/bin/env bash\n${cd}${confirm}exec env ${isolate ? "-i " : ""}${cmd}\n`;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// The script holds the pane's env inline (the agent's creds + control token, and any provider key).
|
|
30
|
+
// Write it into a fresh 0o700 temp dir as a 0o600 file: never a world-readable script, and never a
|
|
31
|
+
// predictable, symlink-attackable /tmp path. cmux runs it as the same user via `bash <path>`.
|
|
32
|
+
const dir = mkdtempSync(join(tmpdir(), "cotal-pane-"));
|
|
33
|
+
const scriptPath = join(dir, "launch.sh");
|
|
34
|
+
writeFileSync(scriptPath, script, { mode: 0o600 });
|
|
35
|
+
return `bash ${login ? "-l " : ""}${shellQuote(scriptPath)}`;
|
|
32
36
|
}
|
|
33
37
|
/** A single-terminal pane node in cmux's layout JSON. */
|
|
34
38
|
function surface(command) {
|
|
@@ -38,7 +42,7 @@ function surface(command) {
|
|
|
38
42
|
* knows cmux's layout shape. One pane → a bare terminal; several → a split (`direction` + `split`
|
|
39
43
|
* ratio). These panes run under a login shell. */
|
|
40
44
|
function cmuxLayout(label, tab) {
|
|
41
|
-
const nodes = tab.panes.map((p
|
|
45
|
+
const nodes = tab.panes.map((p) => surface(paneCommand(p, true)));
|
|
42
46
|
if (nodes.length === 1 && !tab.split)
|
|
43
47
|
return JSON.stringify(nodes[0]);
|
|
44
48
|
if (!tab.split)
|
|
@@ -65,7 +69,7 @@ export class CmuxRuntime {
|
|
|
65
69
|
"is cmux running, and is this process inside a cmux surface (CMUX_SOCKET_PATH set)?");
|
|
66
70
|
// `confirm` auto-clears a one-time prompt (Claude's dev-channels) by sending Enter to this
|
|
67
71
|
// tab's own surface — so a spawned teammate joins the mesh without anyone switching to its tab.
|
|
68
|
-
const command = paneCommand({ command: spec.command, args: spec.args, env: spec.env, cwd, confirm: Boolean(spec.confirm) },
|
|
72
|
+
const command = paneCommand({ command: spec.command, args: spec.args, env: spec.env, cwd, confirm: Boolean(spec.confirm) }, false, true);
|
|
69
73
|
// Keep the new tab's workspace ref so we can drive (send keys to its terminal)
|
|
70
74
|
// and close it later. cmux targets the tab's single terminal surface by workspace.
|
|
71
75
|
const workspace = cmux.openWorkspace(`cotal-${name}`, JSON.stringify(surface(command)), { focus: false });
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EACL,QAAQ,GAQT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,iFAAiF;AACjF,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB;gGACgG;AAChG,MAAM,UAAU,GACd,kEAAkE;IAClE,kIAAkI,CAAC;AAErI,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AACzC,CAAC;AAED;;;;;;;qGAOqG;AACrG,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,KAAc,EAAE,OAAO,GAAG,KAAK;IACrE,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAA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
|
2
2
|
"name": "@cotal-ai/cmux",
|
|
3
3
|
"description": "Cotal cmux integration: a cmux Runtime and TerminalLayout provider for spawning agents into cmux tabs.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cotal-ai/core": "0.8.
|
|
21
|
+
"@cotal-ai/core": "0.8.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsx": "^4.22.4"
|