@cotal-ai/cmux 0.2.0 → 0.3.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/driver.d.ts +6 -0
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +27 -0
- package/dist/driver.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +12 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +55 -22
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
package/dist/driver.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function openWorkspace(name: string, layout: string, opts?: {
|
|
|
12
12
|
}): string;
|
|
13
13
|
/** Close a workspace (tab) by id/ref. */
|
|
14
14
|
export declare function closeWorkspace(workspace: string): void;
|
|
15
|
+
/** All open workspace lines (name + ref), or `[]` if cmux can't be reached. */
|
|
16
|
+
export declare function listWorkspaces(): string[];
|
|
17
|
+
/** Workspace refs (e.g. "workspace:55") whose label is exactly `name`. cmux lists tabs as
|
|
18
|
+
* "[*] <ref> [glyph] <label> [\[selected\]]"; matching the whole label keeps "cotal-main" from
|
|
19
|
+
* matching "cotal-manager". Used to close stale tabs that linger after their process exits. */
|
|
20
|
+
export declare function workspaceRefs(name: string): string[];
|
|
15
21
|
/** Split the focused pane; the new pane becomes focused. */
|
|
16
22
|
export declare function newSplit(direction: "left" | "right" | "up" | "down"): void;
|
|
17
23
|
/** Type text into a terminal surface (the focused one, or a targeted background tab). */
|
package/dist/driver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAkBA,8EAA8E;AAC9E,MAAM,WAAW,MAAM;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;C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AAM,GAAG,MAAM,EAAE,CAYpD;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED,yFAAyF;AACzF,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAE1D"}
|
package/dist/driver.js
CHANGED
|
@@ -56,6 +56,33 @@ export function openWorkspace(name, layout, opts = {}) {
|
|
|
56
56
|
export function closeWorkspace(workspace) {
|
|
57
57
|
cmux(["close-workspace", "--workspace", workspace]);
|
|
58
58
|
}
|
|
59
|
+
/** All open workspace lines (name + ref), or `[]` if cmux can't be reached. */
|
|
60
|
+
export function listWorkspaces() {
|
|
61
|
+
try {
|
|
62
|
+
return cmux(["list-workspaces"]).split("\n").map((l) => l.trim()).filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Workspace refs (e.g. "workspace:55") whose label is exactly `name`. cmux lists tabs as
|
|
69
|
+
* "[*] <ref> [glyph] <label> [\[selected\]]"; matching the whole label keeps "cotal-main" from
|
|
70
|
+
* matching "cotal-manager". Used to close stale tabs that linger after their process exits. */
|
|
71
|
+
export function workspaceRefs(name) {
|
|
72
|
+
const refs = [];
|
|
73
|
+
for (const line of listWorkspaces()) {
|
|
74
|
+
const ref = (line.match(/workspace:\d+/) ?? line.match(UUID))?.[0];
|
|
75
|
+
if (!ref)
|
|
76
|
+
continue;
|
|
77
|
+
const label = line
|
|
78
|
+
.slice(line.indexOf(ref) + ref.length)
|
|
79
|
+
.replace(/\s*\[selected\]\s*$/, "")
|
|
80
|
+
.trim();
|
|
81
|
+
if (label === name || label.endsWith(` ${name}`))
|
|
82
|
+
refs.push(ref);
|
|
83
|
+
}
|
|
84
|
+
return refs;
|
|
85
|
+
}
|
|
59
86
|
/** Split the focused pane; the new pane becomes focused. */
|
|
60
87
|
export function newSplit(direction) {
|
|
61
88
|
cmux(["new-split", direction]);
|
package/dist/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qFAAqF;AACrF,+EAA+E;AAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,MAAM,CAAC;AAE7D;;;;;GAKG;AACH,SAAS,IAAI,CAAC,IAAc;IAC1B,OAAO,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,IAAI,GAAG,+DAA+D,CAAC;AAQ7E,SAAS,UAAU,CAAC,CAAU;IAC5B,MAAM,CAAC,GAAa,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,SAAS;QAAE,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,EAAE,OAAO;QAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC;QACH,YAAY,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;2EAC2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CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;aACrC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;aAClC,IAAI,EAAE,CAAC;QACV,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,QAAQ,CAAC,SAA2C;IAClE,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,MAAe;IAChD,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,MAAe;IAClD,IAAI,CAAC,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** @cotal-ai/cmux — the cmux integration: a thin driver over the cmux CLI plus
|
|
2
|
-
* self-registering `cmux` Runtime. Importing the package
|
|
3
|
-
* with the core Registry (like a connector), so the manager can spawn
|
|
4
|
-
* tabs
|
|
5
|
-
* launch scripts import `./driver.js`
|
|
1
|
+
/** @cotal-ai/cmux — the cmux integration: a thin driver over the cmux CLI plus
|
|
2
|
+
* self-registering `cmux` Runtime and TerminalLayout providers. Importing the package
|
|
3
|
+
* registers both with the core Registry (like a connector), so the manager can spawn
|
|
4
|
+
* into cmux tabs and `cotal setup` can open/close them — neither depending on this
|
|
5
|
+
* package. The driver itself stays mesh-free; launch scripts import `./driver.js`
|
|
6
|
+
* directly to avoid the registration side effect. */
|
|
6
7
|
export * as cmux from "./driver.js";
|
|
7
|
-
export { CmuxRuntime, cmuxRuntimeProvider } from "./runtime.js";
|
|
8
|
+
export { CmuxRuntime, cmuxRuntimeProvider, cmuxTerminalProvider } from "./runtime.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;sDAKsD;AACtD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/** @cotal-ai/cmux — the cmux integration: a thin driver over the cmux CLI plus
|
|
2
|
-
* self-registering `cmux` Runtime. Importing the package
|
|
3
|
-
* with the core Registry (like a connector), so the manager can spawn
|
|
4
|
-
* tabs
|
|
5
|
-
* launch scripts import `./driver.js`
|
|
1
|
+
/** @cotal-ai/cmux — the cmux integration: a thin driver over the cmux CLI plus
|
|
2
|
+
* self-registering `cmux` Runtime and TerminalLayout providers. Importing the package
|
|
3
|
+
* registers both with the core Registry (like a connector), so the manager can spawn
|
|
4
|
+
* into cmux tabs and `cotal setup` can open/close them — neither depending on this
|
|
5
|
+
* package. The driver itself stays mesh-free; launch scripts import `./driver.js`
|
|
6
|
+
* directly to avoid the registration side effect. */
|
|
6
7
|
export * as cmux from "./driver.js";
|
|
7
|
-
|
|
8
|
+
// importing registers the cmux runtime + terminal-layout providers
|
|
9
|
+
export { CmuxRuntime, cmuxRuntimeProvider, cmuxTerminalProvider } from "./runtime.js";
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;sDAKsD;AACtD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,mEAAmE;AACnE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type AgentHandle, type LaunchSpec, type Runtime, type RuntimeProvider } from "@cotal-ai/core";
|
|
1
|
+
import { type AgentHandle, type LaunchSpec, type Runtime, type RuntimeProvider, type TerminalLayout } from "@cotal-ai/core";
|
|
2
2
|
/**
|
|
3
3
|
* Spawns each agent into its own new cmux tab (workspace), so spawned teammates get
|
|
4
|
-
* room instead of crowding the spawner.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* to drive and close it.
|
|
4
|
+
* room instead of crowding the spawner. The launch goes through {@link paneCommand}
|
|
5
|
+
* (a temp bash script) — non-login, since the agent's command is an absolute path.
|
|
6
|
+
* Opened unfocused so the human stays put; switch to the new tab to watch the worker.
|
|
7
|
+
* Like tmux, you watch it natively, so `attach()` throws — but teardown is real: we
|
|
8
|
+
* keep the tab's workspace + surface ids to drive and close it.
|
|
10
9
|
*/
|
|
11
10
|
export declare class CmuxRuntime implements Runtime {
|
|
12
11
|
readonly kind = "cmux";
|
|
@@ -15,4 +14,10 @@ export declare class CmuxRuntime implements Runtime {
|
|
|
15
14
|
/** Self-registering runtime provider — `import "@cotal-ai/cmux"` makes the manager's
|
|
16
15
|
* `cmux` runtime available, without the manager depending on this package. */
|
|
17
16
|
export declare const cmuxRuntimeProvider: RuntimeProvider;
|
|
17
|
+
/** Self-registering terminal-layout provider — lets a caller (e.g. `cotal setup`) open/close
|
|
18
|
+
* cmux tabs by resolving `registry.resolve("terminal","cmux")`, so an implementation drives cmux
|
|
19
|
+
* without importing this package. The caller passes a backend-agnostic {@link Tab};
|
|
20
|
+
* {@link cmuxLayout} turns it into cmux's native layout JSON here, so no cmux-specific shape lives
|
|
21
|
+
* in the caller. */
|
|
22
|
+
export declare const cmuxTerminalProvider: TerminalLayout;
|
|
18
23
|
//# sourceMappingURL=runtime.d.ts.map
|
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,EAEf,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAiDxB;;;;;;;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;CAgDhE;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
|
@@ -12,42 +12,61 @@ const ENTER_LOOP = '[ -n "$CMUX_SURFACE_ID" ] && [ -n "$CMUX_BUNDLED_CLI_PATH" ]
|
|
|
12
12
|
function shellQuote(s) {
|
|
13
13
|
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
14
14
|
}
|
|
15
|
+
/** cmux can't run a command in a fresh surface directly, and panes start under a login shell
|
|
16
|
+
* (maybe nushell) before bash — so we write each pane's launch as a temp bash script and point
|
|
17
|
+
* the tab at it, sidestepping all shell quoting (callers pass argv, never shell strings). `login`
|
|
18
|
+
* runs it as a login shell (`bash -l`) so the user's PATH is present — setup's panes run further
|
|
19
|
+
* `cotal` subcommands that resolve `claude`. `exec env …` (not `exec …`): exec can't take KEY=val
|
|
20
|
+
* assignments, so `env` applies them and then execs the command. */
|
|
21
|
+
function paneCommand(pane, key, login) {
|
|
22
|
+
const env = Object.entries(pane.env ?? {}).map(([k, v]) => `${k}=${shellQuote(v)}`);
|
|
23
|
+
const cmd = [...env, shellQuote(pane.command), ...(pane.args ?? []).map(shellQuote)].join(" ");
|
|
24
|
+
const cd = pane.cwd ? `cd ${shellQuote(pane.cwd)}\n` : "";
|
|
25
|
+
const confirm = pane.confirm ? `${ENTER_LOOP}\n` : "";
|
|
26
|
+
const script = `#!/usr/bin/env bash\n${cd}${confirm}exec env ${cmd}\n`;
|
|
27
|
+
const scriptPath = join(tmpdir(), `cotal-pane-${key.replace(/[^A-Za-z0-9_.-]/g, "_")}.sh`);
|
|
28
|
+
writeFileSync(scriptPath, script, { mode: 0o755 });
|
|
29
|
+
return `bash ${login ? "-l " : ""}${scriptPath}`;
|
|
30
|
+
}
|
|
31
|
+
/** A single-terminal pane node in cmux's layout JSON. */
|
|
32
|
+
function surface(command) {
|
|
33
|
+
return { pane: { surfaces: [{ type: "terminal", command }] } };
|
|
34
|
+
}
|
|
35
|
+
/** Translate a backend-agnostic {@link Tab} into a cmux layout JSON string — the one place that
|
|
36
|
+
* knows cmux's layout shape. One pane → a bare terminal; several → a split (`direction` + `split`
|
|
37
|
+
* ratio). These panes run under a login shell. */
|
|
38
|
+
function cmuxLayout(label, tab) {
|
|
39
|
+
const nodes = tab.panes.map((p, i) => surface(paneCommand(p, `${label}-${i}`, true)));
|
|
40
|
+
if (nodes.length === 1 && !tab.split)
|
|
41
|
+
return JSON.stringify(nodes[0]);
|
|
42
|
+
if (!tab.split)
|
|
43
|
+
throw new Error(`cmux layout "${label}": ${nodes.length} panes need a split (direction + ratio)`);
|
|
44
|
+
return JSON.stringify({ direction: tab.split.direction, split: tab.split.ratio, children: nodes });
|
|
45
|
+
}
|
|
15
46
|
/**
|
|
16
47
|
* Spawns each agent into its own new cmux tab (workspace), so spawned teammates get
|
|
17
|
-
* room instead of crowding the spawner.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* to drive and close it.
|
|
48
|
+
* room instead of crowding the spawner. The launch goes through {@link paneCommand}
|
|
49
|
+
* (a temp bash script) — non-login, since the agent's command is an absolute path.
|
|
50
|
+
* Opened unfocused so the human stays put; switch to the new tab to watch the worker.
|
|
51
|
+
* Like tmux, you watch it natively, so `attach()` throws — but teardown is real: we
|
|
52
|
+
* keep the tab's workspace + surface ids to drive and close it.
|
|
23
53
|
*/
|
|
24
54
|
export class CmuxRuntime {
|
|
25
55
|
kind = "cmux";
|
|
26
56
|
spawn(name, spec, cwd) {
|
|
27
|
-
// `name` becomes a temp-script
|
|
57
|
+
// `name` becomes a temp-script key and a `cotal-<name>` tab id — keep it a bare token
|
|
28
58
|
// so it can't traverse paths or break the workspace label.
|
|
29
59
|
if (!/^[A-Za-z0-9_.-]+$/.test(name))
|
|
30
60
|
throw new Error(`cmux runtime: unsafe agent name ${JSON.stringify(name)} (allowed: letters, digits, _ . -)`);
|
|
31
61
|
if (!cmux.available())
|
|
32
62
|
throw new Error(`the cmux CLI (${process.env.CMUX_BUNDLED_CLI_PATH ?? "cmux"}) couldn't reach the app — ` +
|
|
33
63
|
"is cmux running, and is this process inside a cmux surface (CMUX_SOCKET_PATH set)?");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// sending Enter to this tab's own surface a few times — so a spawned teammate joins the mesh
|
|
38
|
-
// without anyone switching to its tab to press Enter. (Same trick as run-agent.sh.)
|
|
39
|
-
const autoConfirm = spec.confirm ? `${ENTER_LOOP}\n` : "";
|
|
40
|
-
// `exec env …` (not `exec …`): exec can't take KEY=val assignments — `env` applies them
|
|
41
|
-
// then execs the agent. Without it the script dies with "exec: COTAL_SPACE=…: not found".
|
|
42
|
-
const script = `#!/usr/bin/env bash\ncd ${shellQuote(cwd)}\n${autoConfirm}exec env ${cmd}\n`;
|
|
43
|
-
const scriptPath = join(tmpdir(), `cotal-spawn-${name}.sh`);
|
|
44
|
-
writeFileSync(scriptPath, script, { mode: 0o755 });
|
|
45
|
-
const layout = JSON.stringify({
|
|
46
|
-
pane: { surfaces: [{ type: "terminal", command: `bash ${scriptPath}` }] },
|
|
47
|
-
});
|
|
64
|
+
// `confirm` auto-clears a one-time prompt (Claude's dev-channels) by sending Enter to this
|
|
65
|
+
// tab's own surface — so a spawned teammate joins the mesh without anyone switching to its tab.
|
|
66
|
+
const command = paneCommand({ command: spec.command, args: spec.args, env: spec.env, cwd, confirm: Boolean(spec.confirm) }, `spawn-${name}`, false);
|
|
48
67
|
// Keep the new tab's workspace ref so we can drive (send keys to its terminal)
|
|
49
68
|
// and close it later. cmux targets the tab's single terminal surface by workspace.
|
|
50
|
-
const workspace = cmux.openWorkspace(`cotal-${name}`,
|
|
69
|
+
const workspace = cmux.openWorkspace(`cotal-${name}`, JSON.stringify(surface(command)), { focus: false });
|
|
51
70
|
return {
|
|
52
71
|
name,
|
|
53
72
|
kind: "cmux",
|
|
@@ -86,4 +105,18 @@ export const cmuxRuntimeProvider = {
|
|
|
86
105
|
create: () => new CmuxRuntime(),
|
|
87
106
|
};
|
|
88
107
|
registry.register(cmuxRuntimeProvider);
|
|
108
|
+
/** Self-registering terminal-layout provider — lets a caller (e.g. `cotal setup`) open/close
|
|
109
|
+
* cmux tabs by resolving `registry.resolve("terminal","cmux")`, so an implementation drives cmux
|
|
110
|
+
* without importing this package. The caller passes a backend-agnostic {@link Tab};
|
|
111
|
+
* {@link cmuxLayout} turns it into cmux's native layout JSON here, so no cmux-specific shape lives
|
|
112
|
+
* in the caller. */
|
|
113
|
+
export const cmuxTerminalProvider = {
|
|
114
|
+
kind: "terminal",
|
|
115
|
+
name: "cmux",
|
|
116
|
+
available: () => cmux.available(),
|
|
117
|
+
open: (label, tab, opts) => cmux.openWorkspace(label, cmuxLayout(label, tab), opts),
|
|
118
|
+
close: (ref) => cmux.closeWorkspace(ref),
|
|
119
|
+
refs: (label) => cmux.workspaceRefs(label),
|
|
120
|
+
};
|
|
121
|
+
registry.register(cmuxTerminalProvider);
|
|
89
122
|
//# sourceMappingURL=runtime.js.map
|
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;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,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,C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|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cotal-ai/core": "0.
|
|
20
|
+
"@cotal-ai/core": "0.3.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"tsx": "^4.22.4"
|