cyber-mux 0.1.0 → 0.4.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/bin/cyber-mux.mjs +0 -0
- package/dist/agent.d.mts +66 -0
- package/dist/agent.d.mts.map +1 -0
- package/dist/agent.mjs +58 -0
- package/dist/agent.mjs.map +1 -0
- package/dist/backend-Cif257ji.mjs +2345 -0
- package/dist/backend-Cif257ji.mjs.map +1 -0
- package/dist/cli.d.mts +64 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +1013 -2125
- package/dist/cli.mjs.map +1 -0
- package/dist/exec-B81m4yjz.d.mts +39 -0
- package/dist/exec-B81m4yjz.d.mts.map +1 -0
- package/dist/index.d.mts +438 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/mux-CoYDrk3v.d.mts +733 -0
- package/dist/mux-CoYDrk3v.d.mts.map +1 -0
- package/dist/template-store-LQfmvcGT.d.mts +118 -0
- package/dist/template-store-LQfmvcGT.d.mts.map +1 -0
- package/dist/template.d.mts +131 -0
- package/dist/template.d.mts.map +1 -0
- package/dist/template.mjs +374 -0
- package/dist/template.mjs.map +1 -0
- package/dist/worktree-9QDz-iKC.d.mts +289 -0
- package/dist/worktree-9QDz-iKC.d.mts.map +1 -0
- package/dist/worktree-hHuFZkpW.mjs +411 -0
- package/dist/worktree-hHuFZkpW.mjs.map +1 -0
- package/dist/worktree.d.mts +2 -0
- package/dist/worktree.mjs +2 -0
- package/package.json +75 -57
- package/src/agent.ts +95 -0
- package/src/backend.ts +232 -0
- package/src/cli-error.ts +131 -0
- package/src/cli-options.ts +44 -0
- package/src/cli.ts +2045 -0
- package/src/env-fallback.ts +51 -0
- package/src/exec.ts +53 -0
- package/src/index.ts +22 -0
- package/src/mux-probe.ts +181 -0
- package/src/mux.herdr.ts +847 -0
- package/src/mux.tmux.ts +486 -0
- package/src/mux.ts +749 -0
- package/src/mux.wezterm.ts +370 -0
- package/src/mux.zellij.ts +372 -0
- package/src/new-id.ts +15 -0
- package/src/nudge.ts +94 -0
- package/src/output.ts +96 -0
- package/src/prompt.ts +68 -0
- package/src/ratio.ts +25 -0
- package/src/template-capture.ts +385 -0
- package/src/template-edit.ts +350 -0
- package/src/template-session.ts +690 -0
- package/src/template-store.ts +216 -0
- package/src/template.ts +429 -0
- package/src/wait-output.ts +116 -0
- package/src/worktree-session.ts +208 -0
- package/src/worktree.ts +556 -0
package/bin/cyber-mux.mjs
CHANGED
|
File without changes
|
package/dist/agent.d.mts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as Exec } from "./exec-B81m4yjz.mjs";
|
|
2
|
+
import { d as MuxTarget, n as AgentStatus, o as MuxAdapter, r as AgentWaitOptions, t as AgentLifecycle } from "./mux-CoYDrk3v.mjs";
|
|
3
|
+
//#region src/agent.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* An agent-lifecycle wait asked of a backend that has no native agent-state primitive (`agent wait`
|
|
6
|
+
* on tmux, wezterm or zellij). An absent `agentLifecycle` seam member is a REFUSAL, never a guess: a
|
|
7
|
+
* wait built from `read()` polling would silently disagree with herdr's own state derivation on the
|
|
8
|
+
* same question, and a wait has no truthful degrade the way a snapshot does — so a backend that cannot
|
|
9
|
+
* answer is refused rather than emulated.
|
|
10
|
+
*
|
|
11
|
+
* PORTABLE and exit-code-free by design, the exact mirror of `CaptureUnsupportedError`. The DECISION
|
|
12
|
+
* to refuse is the library's and lives in `deriveAgentWait`, the one place that sees the adapter — how
|
|
13
|
+
* the refusal SURFACES (the exit code, the fix hint, the exact sentence) is the CLI's, which catches
|
|
14
|
+
* this and re-raises its own `backend-unsupported` error. `backend` names the backend so the caller
|
|
15
|
+
* composes the message without re-deriving it; the terse `message` is a factual log line.
|
|
16
|
+
*/
|
|
17
|
+
declare class AgentLifecycleUnsupportedError extends Error {
|
|
18
|
+
readonly backend: string;
|
|
19
|
+
constructor(backend: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wait for the target pane's agent to reach one of `opts.until` (or the backend's default set) through
|
|
23
|
+
* the adapter — the surface-independent orchestrator `agent wait` drives, and the single home of the
|
|
24
|
+
* agent-wait refusal. The optional `agentLifecycle` seam is where a backend says whether it has a
|
|
25
|
+
* native wait at all; a backend without it is refused HERE (`AgentLifecycleUnsupportedError`), BEFORE
|
|
26
|
+
* any exec, because `waitForState` never sees the adapter and so cannot make that call. A backend that
|
|
27
|
+
* HAS the capability delegates to it unchanged.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors `deriveRegionCapture` (`template-capture.ts`) exactly: the orchestrator is the one place that
|
|
30
|
+
* sees the adapter, so it is the one place the emulate-or-refuse decision can be made.
|
|
31
|
+
*/
|
|
32
|
+
declare function deriveAgentWait(adapter: MuxAdapter, exec: Exec, target: MuxTarget, opts: AgentWaitOptions): AgentStatus;
|
|
33
|
+
/**
|
|
34
|
+
* The `agent` subpath facade with its `Exec` and backend BOUND — the exec-bound parallel of
|
|
35
|
+
* `worktreeApi`/`templateApi`. `agentApi(env, deps?)` resolves the backend adapter from `env` ONCE
|
|
36
|
+
* (`resolveMuxAdapter`, defaulting `exec` to `nodeExec`) and exposes `supported`/`status`/`wait` with
|
|
37
|
+
* the seams already threaded, so a caller never re-plumbs an adapter or a runner into them.
|
|
38
|
+
*
|
|
39
|
+
* It ADDS no logic of its own: `supported` reads the very capability presence `deriveAgentWait` gates
|
|
40
|
+
* on, `status` reads the same `LivePane.agentStatus` the listing already carries (for one pane rather
|
|
41
|
+
* than redefining it), and `wait` routes THROUGH `deriveAgentWait` — so the emulate-or-refuse decision
|
|
42
|
+
* stays specified once and enforced once, with no second refusal path here that could drift from it.
|
|
43
|
+
*/
|
|
44
|
+
interface AgentApi {
|
|
45
|
+
/** Whether this backend reports agent-lifecycle state at all (herdr yes; tmux/wezterm/zellij no). */
|
|
46
|
+
supported(): boolean;
|
|
47
|
+
/** A pane's current agent state, or `undefined` when the backend has no feed (absent-not-false). */
|
|
48
|
+
status(target: MuxTarget): AgentStatus | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Block until the pane's agent reaches one of `opts.until` (or the backend's default set); throws
|
|
51
|
+
* `AgentLifecycleUnsupportedError` naming the backend on one without the capability, via
|
|
52
|
+
* `deriveAgentWait`. A bare `wait(target)` takes herdr's own defaults (`opts ?? {}`).
|
|
53
|
+
*/
|
|
54
|
+
wait(target: MuxTarget, opts?: AgentWaitOptions | undefined): AgentStatus;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Bind the agent-lifecycle capability to an environment and runner once, returning an `AgentApi` whose
|
|
58
|
+
* methods no longer take an `Exec`. `deps.exec` defaults to `nodeExec`; `env` is bound like
|
|
59
|
+
* `resolveMux(env)` because it is what the probe resolves the backend from.
|
|
60
|
+
*/
|
|
61
|
+
declare function agentApi(env: NodeJS.ProcessEnv, deps?: {
|
|
62
|
+
exec?: Exec | undefined;
|
|
63
|
+
} | undefined): AgentApi;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { AgentApi, type AgentLifecycle, AgentLifecycleUnsupportedError, type AgentStatus, type AgentWaitOptions, agentApi, deriveAgentWait };
|
|
66
|
+
//# sourceMappingURL=agent.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.mts","names":[],"sources":["../src/agent.ts"],"mappings":";;;;;;;;;;;;;;;;cA4Ba,uCAAuC;WACvC;EAAZ,YAAY;;;;;;;;;;;;;iBAiBG,gBACf,SAAS,YACT,MAAM,MACN,QAAQ,WACR,MAAM,mBACJ;;;;;;;;;;;;UAiBc;;EAEhB;;EAEA,OAAO,QAAQ,YAAY;;;;;;EAM3B,KAAK,QAAQ,WAAW,OAAO,+BAA+B;;;;;;;iBAQ/C,SAAS,KAAK,OAAO,YAAY;EAAS,OAAO;gBAAiC"}
|
package/dist/agent.mjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { m as nodeExec } from "./worktree-hHuFZkpW.mjs";
|
|
2
|
+
import { r as resolveMuxAdapter } from "./backend-Cif257ji.mjs";
|
|
3
|
+
//#region src/agent.ts
|
|
4
|
+
/**
|
|
5
|
+
* An agent-lifecycle wait asked of a backend that has no native agent-state primitive (`agent wait`
|
|
6
|
+
* on tmux, wezterm or zellij). An absent `agentLifecycle` seam member is a REFUSAL, never a guess: a
|
|
7
|
+
* wait built from `read()` polling would silently disagree with herdr's own state derivation on the
|
|
8
|
+
* same question, and a wait has no truthful degrade the way a snapshot does — so a backend that cannot
|
|
9
|
+
* answer is refused rather than emulated.
|
|
10
|
+
*
|
|
11
|
+
* PORTABLE and exit-code-free by design, the exact mirror of `CaptureUnsupportedError`. The DECISION
|
|
12
|
+
* to refuse is the library's and lives in `deriveAgentWait`, the one place that sees the adapter — how
|
|
13
|
+
* the refusal SURFACES (the exit code, the fix hint, the exact sentence) is the CLI's, which catches
|
|
14
|
+
* this and re-raises its own `backend-unsupported` error. `backend` names the backend so the caller
|
|
15
|
+
* composes the message without re-deriving it; the terse `message` is a factual log line.
|
|
16
|
+
*/
|
|
17
|
+
var AgentLifecycleUnsupportedError = class extends Error {
|
|
18
|
+
backend;
|
|
19
|
+
constructor(backend) {
|
|
20
|
+
super(`${backend} cannot report agent-lifecycle state`);
|
|
21
|
+
this.backend = backend;
|
|
22
|
+
this.name = "AgentLifecycleUnsupportedError";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Wait for the target pane's agent to reach one of `opts.until` (or the backend's default set) through
|
|
27
|
+
* the adapter — the surface-independent orchestrator `agent wait` drives, and the single home of the
|
|
28
|
+
* agent-wait refusal. The optional `agentLifecycle` seam is where a backend says whether it has a
|
|
29
|
+
* native wait at all; a backend without it is refused HERE (`AgentLifecycleUnsupportedError`), BEFORE
|
|
30
|
+
* any exec, because `waitForState` never sees the adapter and so cannot make that call. A backend that
|
|
31
|
+
* HAS the capability delegates to it unchanged.
|
|
32
|
+
*
|
|
33
|
+
* Mirrors `deriveRegionCapture` (`template-capture.ts`) exactly: the orchestrator is the one place that
|
|
34
|
+
* sees the adapter, so it is the one place the emulate-or-refuse decision can be made.
|
|
35
|
+
*/
|
|
36
|
+
function deriveAgentWait(adapter, exec, target, opts) {
|
|
37
|
+
const agentLifecycle = adapter.agentLifecycle;
|
|
38
|
+
if (!agentLifecycle) throw new AgentLifecycleUnsupportedError(adapter.name);
|
|
39
|
+
return agentLifecycle.waitForState(exec, target, opts);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Bind the agent-lifecycle capability to an environment and runner once, returning an `AgentApi` whose
|
|
43
|
+
* methods no longer take an `Exec`. `deps.exec` defaults to `nodeExec`; `env` is bound like
|
|
44
|
+
* `resolveMux(env)` because it is what the probe resolves the backend from.
|
|
45
|
+
*/
|
|
46
|
+
function agentApi(env, deps) {
|
|
47
|
+
const exec = deps?.exec ?? nodeExec;
|
|
48
|
+
const adapter = resolveMuxAdapter(env, exec);
|
|
49
|
+
return {
|
|
50
|
+
supported: () => adapter.agentLifecycle !== void 0,
|
|
51
|
+
status: (target) => adapter.listPanes(exec).find((p) => p.id === target.id)?.agentStatus,
|
|
52
|
+
wait: (target, opts) => deriveAgentWait(adapter, exec, target, opts ?? {})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { AgentLifecycleUnsupportedError, agentApi, deriveAgentWait };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=agent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.mjs","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import { resolveMuxAdapter } from './backend.ts'\nimport { type Exec, nodeExec } from './exec.ts'\nimport type { AgentStatus, AgentWaitOptions, MuxAdapter, MuxTarget } from './mux.ts'\n\n/**\n * The `cyber-mux/agent` subpath — the agent-lifecycle capability's orchestrator and its refusal.\n *\n * The `AgentStatus` type rides out on the `.` barrel (it is part of `LivePane`, and `mux.ts` is\n * re-exported there); the WAIT capability — the `AgentLifecycle` seam plus the emulate-or-refuse\n * decision below — is this subpath alone, kept off the core barrel exactly as `template`'s apply\n * engine is: a capability nobody has to import to drive a pane is not on the surface everybody gets.\n */\n\nexport type { AgentLifecycle, AgentStatus, AgentWaitOptions } from './mux.ts'\n\n/**\n * An agent-lifecycle wait asked of a backend that has no native agent-state primitive (`agent wait`\n * on tmux, wezterm or zellij). An absent `agentLifecycle` seam member is a REFUSAL, never a guess: a\n * wait built from `read()` polling would silently disagree with herdr's own state derivation on the\n * same question, and a wait has no truthful degrade the way a snapshot does — so a backend that cannot\n * answer is refused rather than emulated.\n *\n * PORTABLE and exit-code-free by design, the exact mirror of `CaptureUnsupportedError`. The DECISION\n * to refuse is the library's and lives in `deriveAgentWait`, the one place that sees the adapter — how\n * the refusal SURFACES (the exit code, the fix hint, the exact sentence) is the CLI's, which catches\n * this and re-raises its own `backend-unsupported` error. `backend` names the backend so the caller\n * composes the message without re-deriving it; the terse `message` is a factual log line.\n */\nexport class AgentLifecycleUnsupportedError extends Error {\n\tconstructor(readonly backend: string) {\n\t\tsuper(`${backend} cannot report agent-lifecycle state`)\n\t\tthis.name = 'AgentLifecycleUnsupportedError'\n\t}\n}\n\n/**\n * Wait for the target pane's agent to reach one of `opts.until` (or the backend's default set) through\n * the adapter — the surface-independent orchestrator `agent wait` drives, and the single home of the\n * agent-wait refusal. The optional `agentLifecycle` seam is where a backend says whether it has a\n * native wait at all; a backend without it is refused HERE (`AgentLifecycleUnsupportedError`), BEFORE\n * any exec, because `waitForState` never sees the adapter and so cannot make that call. A backend that\n * HAS the capability delegates to it unchanged.\n *\n * Mirrors `deriveRegionCapture` (`template-capture.ts`) exactly: the orchestrator is the one place that\n * sees the adapter, so it is the one place the emulate-or-refuse decision can be made.\n */\nexport function deriveAgentWait(\n\tadapter: MuxAdapter,\n\texec: Exec,\n\ttarget: MuxTarget,\n\topts: AgentWaitOptions,\n): AgentStatus {\n\tconst agentLifecycle = adapter.agentLifecycle\n\tif (!agentLifecycle) throw new AgentLifecycleUnsupportedError(adapter.name)\n\treturn agentLifecycle.waitForState(exec, target, opts)\n}\n\n/**\n * The `agent` subpath facade with its `Exec` and backend BOUND — the exec-bound parallel of\n * `worktreeApi`/`templateApi`. `agentApi(env, deps?)` resolves the backend adapter from `env` ONCE\n * (`resolveMuxAdapter`, defaulting `exec` to `nodeExec`) and exposes `supported`/`status`/`wait` with\n * the seams already threaded, so a caller never re-plumbs an adapter or a runner into them.\n *\n * It ADDS no logic of its own: `supported` reads the very capability presence `deriveAgentWait` gates\n * on, `status` reads the same `LivePane.agentStatus` the listing already carries (for one pane rather\n * than redefining it), and `wait` routes THROUGH `deriveAgentWait` — so the emulate-or-refuse decision\n * stays specified once and enforced once, with no second refusal path here that could drift from it.\n */\nexport interface AgentApi {\n\t/** Whether this backend reports agent-lifecycle state at all (herdr yes; tmux/wezterm/zellij no). */\n\tsupported(): boolean\n\t/** A pane's current agent state, or `undefined` when the backend has no feed (absent-not-false). */\n\tstatus(target: MuxTarget): AgentStatus | undefined\n\t/**\n\t * Block until the pane's agent reaches one of `opts.until` (or the backend's default set); throws\n\t * `AgentLifecycleUnsupportedError` naming the backend on one without the capability, via\n\t * `deriveAgentWait`. A bare `wait(target)` takes herdr's own defaults (`opts ?? {}`).\n\t */\n\twait(target: MuxTarget, opts?: AgentWaitOptions | undefined): AgentStatus\n}\n\n/**\n * Bind the agent-lifecycle capability to an environment and runner once, returning an `AgentApi` whose\n * methods no longer take an `Exec`. `deps.exec` defaults to `nodeExec`; `env` is bound like\n * `resolveMux(env)` because it is what the probe resolves the backend from.\n */\nexport function agentApi(env: NodeJS.ProcessEnv, deps?: { exec?: Exec | undefined } | undefined): AgentApi {\n\tconst exec = deps?.exec ?? nodeExec\n\tconst adapter = resolveMuxAdapter(env, exec)\n\treturn {\n\t\tsupported: () => adapter.agentLifecycle !== undefined,\n\t\tstatus: (target) => adapter.listPanes(exec).find((p) => p.id === target.id)?.agentStatus,\n\t\twait: (target, opts) => deriveAgentWait(adapter, exec, target, opts ?? {}),\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAa,iCAAb,cAAoD,MAAM;CACpC;CAArB,YAAY,SAA0B;EACrC,MAAM,GAAG,QAAQ,qCAAqC;EADlC,KAAA,UAAA;EAEpB,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;AAaA,SAAgB,gBACf,SACA,MACA,QACA,MACc;CACd,MAAM,iBAAiB,QAAQ;CAC/B,IAAI,CAAC,gBAAgB,MAAM,IAAI,+BAA+B,QAAQ,IAAI;CAC1E,OAAO,eAAe,aAAa,MAAM,QAAQ,IAAI;AACtD;;;;;;AA+BA,SAAgB,SAAS,KAAwB,MAA0D;CAC1G,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,UAAU,kBAAkB,KAAK,IAAI;CAC3C,OAAO;EACN,iBAAiB,QAAQ,mBAAmB,KAAA;EAC5C,SAAS,WAAW,QAAQ,UAAU,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,OAAO,OAAO,EAAE,CAAC,EAAE;EAC7E,OAAO,QAAQ,SAAS,gBAAgB,SAAS,MAAM,QAAQ,QAAQ,CAAC,CAAC;CAC1E;AACD"}
|