@wastedcode/claudemux 0.2.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/CHANGELOG.md +257 -0
- package/LICENSE +21 -0
- package/README.md +493 -0
- package/bin/claudemux +6 -0
- package/dist/agents/claude.d.ts +3 -0
- package/dist/agents/claude.d.ts.map +1 -0
- package/dist/agents/claude.js +585 -0
- package/dist/agents/claude.js.map +1 -0
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/types.d.ts +252 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/backends/tmux/capture.d.ts +25 -0
- package/dist/backends/tmux/capture.d.ts.map +1 -0
- package/dist/backends/tmux/capture.js +35 -0
- package/dist/backends/tmux/capture.js.map +1 -0
- package/dist/backends/tmux/exec.d.ts +105 -0
- package/dist/backends/tmux/exec.d.ts.map +1 -0
- package/dist/backends/tmux/exec.js +226 -0
- package/dist/backends/tmux/exec.js.map +1 -0
- package/dist/backends/tmux/index.d.ts +22 -0
- package/dist/backends/tmux/index.d.ts.map +1 -0
- package/dist/backends/tmux/index.js +108 -0
- package/dist/backends/tmux/index.js.map +1 -0
- package/dist/backends/tmux/keys.d.ts +38 -0
- package/dist/backends/tmux/keys.d.ts.map +1 -0
- package/dist/backends/tmux/keys.js +63 -0
- package/dist/backends/tmux/keys.js.map +1 -0
- package/dist/backends/tmux/options.d.ts +24 -0
- package/dist/backends/tmux/options.d.ts.map +1 -0
- package/dist/backends/tmux/options.js +84 -0
- package/dist/backends/tmux/options.js.map +1 -0
- package/dist/backends/tmux/sessions.d.ts +70 -0
- package/dist/backends/tmux/sessions.d.ts.map +1 -0
- package/dist/backends/tmux/sessions.js +156 -0
- package/dist/backends/tmux/sessions.js.map +1 -0
- package/dist/backends/tmux/socket.d.ts +26 -0
- package/dist/backends/tmux/socket.d.ts.map +1 -0
- package/dist/backends/tmux/socket.js +31 -0
- package/dist/backends/tmux/socket.js.map +1 -0
- package/dist/backends/types.d.ts +110 -0
- package/dist/backends/types.d.ts.map +1 -0
- package/dist/backends/types.js +24 -0
- package/dist/backends/types.js.map +1 -0
- package/dist/cli/ask.d.ts +11 -0
- package/dist/cli/ask.d.ts.map +1 -0
- package/dist/cli/ask.js +17 -0
- package/dist/cli/ask.js.map +1 -0
- package/dist/cli/capture.d.ts +8 -0
- package/dist/cli/capture.d.ts.map +1 -0
- package/dist/cli/capture.js +15 -0
- package/dist/cli/capture.js.map +1 -0
- package/dist/cli/context.d.ts +71 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +82 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/exists.d.ts +7 -0
- package/dist/cli/exists.d.ts.map +1 -0
- package/dist/cli/exists.js +16 -0
- package/dist/cli/exists.js.map +1 -0
- package/dist/cli/interrupt.d.ts +10 -0
- package/dist/cli/interrupt.d.ts.map +1 -0
- package/dist/cli/interrupt.js +13 -0
- package/dist/cli/interrupt.js.map +1 -0
- package/dist/cli/kill.d.ts +7 -0
- package/dist/cli/kill.d.ts.map +1 -0
- package/dist/cli/kill.js +14 -0
- package/dist/cli/kill.js.map +1 -0
- package/dist/cli/list.d.ts +10 -0
- package/dist/cli/list.d.ts.map +1 -0
- package/dist/cli/list.js +19 -0
- package/dist/cli/list.js.map +1 -0
- package/dist/cli/main.d.ts +13 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +143 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/messages.d.ts +9 -0
- package/dist/cli/messages.d.ts.map +1 -0
- package/dist/cli/messages.js +13 -0
- package/dist/cli/messages.js.map +1 -0
- package/dist/cli/respond.d.ts +10 -0
- package/dist/cli/respond.d.ts.map +1 -0
- package/dist/cli/respond.js +23 -0
- package/dist/cli/respond.js.map +1 -0
- package/dist/cli/resume.d.ts +12 -0
- package/dist/cli/resume.d.ts.map +1 -0
- package/dist/cli/resume.js +21 -0
- package/dist/cli/resume.js.map +1 -0
- package/dist/cli/send.d.ts +9 -0
- package/dist/cli/send.d.ts.map +1 -0
- package/dist/cli/send.js +16 -0
- package/dist/cli/send.js.map +1 -0
- package/dist/cli/spawn.d.ts +14 -0
- package/dist/cli/spawn.d.ts.map +1 -0
- package/dist/cli/spawn.js +21 -0
- package/dist/cli/spawn.js.map +1 -0
- package/dist/cli/state.d.ts +7 -0
- package/dist/cli/state.d.ts.map +1 -0
- package/dist/cli/state.js +11 -0
- package/dist/cli/state.js.map +1 -0
- package/dist/cli/turn-complete.d.ts +8 -0
- package/dist/cli/turn-complete.d.ts.map +1 -0
- package/dist/cli/turn-complete.js +14 -0
- package/dist/cli/turn-complete.js.map +1 -0
- package/dist/cli/wait.d.ts +13 -0
- package/dist/cli/wait.d.ts.map +1 -0
- package/dist/cli/wait.js +17 -0
- package/dist/cli/wait.js.map +1 -0
- package/dist/compose.d.ts +81 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +64 -0
- package/dist/compose.js.map +1 -0
- package/dist/errors.d.ts +250 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +300 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/io/baseline.d.ts +53 -0
- package/dist/io/baseline.d.ts.map +1 -0
- package/dist/io/baseline.js +97 -0
- package/dist/io/baseline.js.map +1 -0
- package/dist/io/capture.d.ts +15 -0
- package/dist/io/capture.d.ts.map +1 -0
- package/dist/io/capture.js +13 -0
- package/dist/io/capture.js.map +1 -0
- package/dist/io/interrupt.d.ts +46 -0
- package/dist/io/interrupt.d.ts.map +1 -0
- package/dist/io/interrupt.js +60 -0
- package/dist/io/interrupt.js.map +1 -0
- package/dist/io/respond.d.ts +28 -0
- package/dist/io/respond.d.ts.map +1 -0
- package/dist/io/respond.js +33 -0
- package/dist/io/respond.js.map +1 -0
- package/dist/io/send.d.ts +44 -0
- package/dist/io/send.d.ts.map +1 -0
- package/dist/io/send.js +66 -0
- package/dist/io/send.js.map +1 -0
- package/dist/io/stabilize.d.ts +28 -0
- package/dist/io/stabilize.d.ts.map +1 -0
- package/dist/io/stabilize.js +20 -0
- package/dist/io/stabilize.js.map +1 -0
- package/dist/io/wait.d.ts +47 -0
- package/dist/io/wait.d.ts.map +1 -0
- package/dist/io/wait.js +117 -0
- package/dist/io/wait.js.map +1 -0
- package/dist/observe/incremental.d.ts +28 -0
- package/dist/observe/incremental.d.ts.map +1 -0
- package/dist/observe/incremental.js +57 -0
- package/dist/observe/incremental.js.map +1 -0
- package/dist/observe/observer.d.ts +86 -0
- package/dist/observe/observer.d.ts.map +1 -0
- package/dist/observe/observer.js +167 -0
- package/dist/observe/observer.js.map +1 -0
- package/dist/observe/session-observer.d.ts +49 -0
- package/dist/observe/session-observer.d.ts.map +1 -0
- package/dist/observe/session-observer.js +123 -0
- package/dist/observe/session-observer.js.map +1 -0
- package/dist/session/adopt.d.ts +52 -0
- package/dist/session/adopt.d.ts.map +1 -0
- package/dist/session/adopt.js +57 -0
- package/dist/session/adopt.js.map +1 -0
- package/dist/session/boot.d.ts +66 -0
- package/dist/session/boot.d.ts.map +1 -0
- package/dist/session/boot.js +216 -0
- package/dist/session/boot.js.map +1 -0
- package/dist/session/constants.d.ts +57 -0
- package/dist/session/constants.d.ts.map +1 -0
- package/dist/session/constants.js +54 -0
- package/dist/session/constants.js.map +1 -0
- package/dist/session/create.d.ts +88 -0
- package/dist/session/create.d.ts.map +1 -0
- package/dist/session/create.js +66 -0
- package/dist/session/create.js.map +1 -0
- package/dist/session/default-backend.d.ts +27 -0
- package/dist/session/default-backend.d.ts.map +1 -0
- package/dist/session/default-backend.js +58 -0
- package/dist/session/default-backend.js.map +1 -0
- package/dist/session/handle.d.ts +63 -0
- package/dist/session/handle.d.ts.map +1 -0
- package/dist/session/handle.js +284 -0
- package/dist/session/handle.js.map +1 -0
- package/dist/session/hooks.d.ts +37 -0
- package/dist/session/hooks.d.ts.map +1 -0
- package/dist/session/hooks.js +42 -0
- package/dist/session/hooks.js.map +1 -0
- package/dist/session/mutex.d.ts +15 -0
- package/dist/session/mutex.d.ts.map +1 -0
- package/dist/session/mutex.js +29 -0
- package/dist/session/mutex.js.map +1 -0
- package/dist/session/recover.d.ts +43 -0
- package/dist/session/recover.d.ts.map +1 -0
- package/dist/session/recover.js +45 -0
- package/dist/session/recover.js.map +1 -0
- package/dist/session/ref.d.ts +2 -0
- package/dist/session/ref.d.ts.map +1 -0
- package/dist/session/ref.js +5 -0
- package/dist/session/ref.js.map +1 -0
- package/dist/session/registry.d.ts +31 -0
- package/dist/session/registry.d.ts.map +1 -0
- package/dist/session/registry.js +32 -0
- package/dist/session/registry.js.map +1 -0
- package/dist/session/resolve.d.ts +30 -0
- package/dist/session/resolve.d.ts.map +1 -0
- package/dist/session/resolve.js +24 -0
- package/dist/session/resolve.js.map +1 -0
- package/dist/session/resume.d.ts +68 -0
- package/dist/session/resume.d.ts.map +1 -0
- package/dist/session/resume.js +54 -0
- package/dist/session/resume.js.map +1 -0
- package/dist/session/spawn-boot.d.ts +44 -0
- package/dist/session/spawn-boot.d.ts.map +1 -0
- package/dist/session/spawn-boot.js +87 -0
- package/dist/session/spawn-boot.js.map +1 -0
- package/dist/session/validate.d.ts +10 -0
- package/dist/session/validate.d.ts.map +1 -0
- package/dist/session/validate.js +0 -0
- package/dist/session/validate.js.map +1 -0
- package/dist/state/classifier.d.ts +29 -0
- package/dist/state/classifier.d.ts.map +1 -0
- package/dist/state/classifier.js +37 -0
- package/dist/state/classifier.js.map +1 -0
- package/dist/state/types.d.ts +32 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +2 -0
- package/dist/state/types.js.map +1 -0
- package/dist/types.d.ts +401 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/util/ansi.d.ts +14 -0
- package/dist/util/ansi.d.ts.map +1 -0
- package/dist/util/ansi.js +18 -0
- package/dist/util/ansi.js.map +1 -0
- package/dist/util/emitter.d.ts +17 -0
- package/dist/util/emitter.d.ts.map +1 -0
- package/dist/util/emitter.js +33 -0
- package/dist/util/emitter.js.map +1 -0
- package/dist/util/sleep.d.ts +8 -0
- package/dist/util/sleep.d.ts.map +1 -0
- package/dist/util/sleep.js +10 -0
- package/dist/util/sleep.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { handleFor } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* `claudemux state <name>` — print the current pane state
|
|
4
|
+
* (`working` / `idle` / `permission-prompt` / `dialog` / `unknown`).
|
|
5
|
+
*/
|
|
6
|
+
export async function stateCli(name, opts = {}) {
|
|
7
|
+
const handle = await handleFor({ ...opts, name });
|
|
8
|
+
const state = await handle.state();
|
|
9
|
+
process.stdout.write(`${state}\n`);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/cli/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,OAAmB,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CommonOpts } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* `claudemux turn-complete <name> <cursor>` — print `true`/`false` and exit 0/1
|
|
4
|
+
* for "did the turn at <cursor> produce a reply?". The crash-recovery face: after
|
|
5
|
+
* a `resume`, exit 1 (false) on your last-sent cursor means re-send that prompt.
|
|
6
|
+
*/
|
|
7
|
+
export declare function turnCompleteCli(name: string, cursor: string, opts?: CommonOpts): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=turn-complete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-complete.d.ts","sourceRoot":"","sources":["../../src/cli/turn-complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,cAAc,CAAC;AAE1D;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { handleFor } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* `claudemux turn-complete <name> <cursor>` — print `true`/`false` and exit 0/1
|
|
4
|
+
* for "did the turn at <cursor> produce a reply?". The crash-recovery face: after
|
|
5
|
+
* a `resume`, exit 1 (false) on your last-sent cursor means re-send that prompt.
|
|
6
|
+
*/
|
|
7
|
+
export async function turnCompleteCli(name, cursor, opts = {}) {
|
|
8
|
+
const handle = await handleFor({ ...opts, name });
|
|
9
|
+
const done = await handle.turnComplete(cursor);
|
|
10
|
+
process.stdout.write(`${done}\n`);
|
|
11
|
+
if (!done)
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=turn-complete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-complete.js","sourceRoot":"","sources":["../../src/cli/turn-complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,MAAc,EACd,OAAmB,EAAE;IAErB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CommonOpts, type PatienceCliOpts } from "./context.js";
|
|
2
|
+
export interface WaitCliOpts extends CommonOpts, PatienceCliOpts {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* `claudemux wait <name>` — block until the turn reaches a terminal
|
|
6
|
+
* {@link TurnOutcome}. Prints the outcome as JSON (the `kind` plus any nested
|
|
7
|
+
* `on`/`reason`) so a scripting consumer can branch on it. Exit code is 0 for
|
|
8
|
+
* `completed`, non-zero otherwise, so shell callers can gate without parsing.
|
|
9
|
+
* Patience is the consumer's: `--timeout-ms`/`--idle-ms`, else the CLI's own
|
|
10
|
+
* wall-clock default (the library imposes none).
|
|
11
|
+
*/
|
|
12
|
+
export declare function waitCli(name: string, opts?: WaitCliOpts): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/cli/wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAA2B,MAAM,cAAc,CAAC;AAE9F,MAAM,WAAW,WAAY,SAAQ,UAAU,EAAE,eAAe;CAAG;AAEnE;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKjF"}
|
package/dist/cli/wait.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { handleFor, patienceOpts } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* `claudemux wait <name>` — block until the turn reaches a terminal
|
|
4
|
+
* {@link TurnOutcome}. Prints the outcome as JSON (the `kind` plus any nested
|
|
5
|
+
* `on`/`reason`) so a scripting consumer can branch on it. Exit code is 0 for
|
|
6
|
+
* `completed`, non-zero otherwise, so shell callers can gate without parsing.
|
|
7
|
+
* Patience is the consumer's: `--timeout-ms`/`--idle-ms`, else the CLI's own
|
|
8
|
+
* wall-clock default (the library imposes none).
|
|
9
|
+
*/
|
|
10
|
+
export async function waitCli(name, opts = {}) {
|
|
11
|
+
const handle = await handleFor({ ...opts, name });
|
|
12
|
+
const outcome = await handle.wait(patienceOpts(opts));
|
|
13
|
+
process.stdout.write(`${JSON.stringify(outcome)}\n`);
|
|
14
|
+
if (outcome.kind !== "completed")
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/cli/wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI9F;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,OAAoB,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type ResumeOptions } from "./session/resume.js";
|
|
2
|
+
import type { Cursor, Message, ReadyOpts, SessionHandle, TurnOutcome } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The composition seam — the **single owner** of multi-primitive workflows over
|
|
5
|
+
* a {@link SessionHandle}. It holds no belief and no content of its own: it only
|
|
6
|
+
* sequences the primitives, each of which stays the sole owner of its decision.
|
|
7
|
+
* Both the CLI (`claudemux ask`) and programmatic consumers (e.g. Posse) call
|
|
8
|
+
* THIS, so the round-trip has one owner rather than one per interface face.
|
|
9
|
+
*/
|
|
10
|
+
/** What {@link ask} returns: the full outcome, the messages, and the cursor. */
|
|
11
|
+
export interface AskResult {
|
|
12
|
+
/**
|
|
13
|
+
* The terminal {@link TurnOutcome}, surfaced in full — never swallowed.
|
|
14
|
+
* `completed` is the happy path; `awaiting`/`aborted`/`budget-exceeded` are
|
|
15
|
+
* first-class and the caller must branch on them.
|
|
16
|
+
*/
|
|
17
|
+
readonly outcome: TurnOutcome;
|
|
18
|
+
/**
|
|
19
|
+
* The messages produced since this turn's `send`, read via the one content
|
|
20
|
+
* owner ({@link SessionHandle.messagesSince}). On `completed` they are the
|
|
21
|
+
* full, flushed reply (race-free); on a non-`completed` outcome they are
|
|
22
|
+
* whatever has landed so far (possibly partial) — interpret with `outcome`.
|
|
23
|
+
*/
|
|
24
|
+
readonly messages: readonly Message[];
|
|
25
|
+
/** The cursor this turn's `send` produced — re-read content later with it. */
|
|
26
|
+
readonly cursor: Cursor;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Do one Q&A round-trip: **send** the prompt, **wait** for the turn to reach a
|
|
30
|
+
* terminal {@link TurnOutcome}, then read the **messages** since it. Pure
|
|
31
|
+
* composition of the three primitives — `ask` is sugar, not a third source of
|
|
32
|
+
* truth: content still flows only through `messagesSince`, the outcome only
|
|
33
|
+
* through `wait`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { create, ask } from "claudemux";
|
|
38
|
+
* const session = await create({ name: "job", cwd: process.cwd() });
|
|
39
|
+
* const { outcome, messages } = await ask(session, "What's 2+2?");
|
|
40
|
+
* if (outcome.kind === "completed") console.log(messages.at(-1));
|
|
41
|
+
* else handleAbnormal(outcome); // awaiting / aborted / budget-exceeded
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function ask(session: SessionHandle, text: string, opts?: ReadyOpts): Promise<AskResult>;
|
|
45
|
+
/**
|
|
46
|
+
* How a session was reconnected on daemon boot — see {@link recover}.
|
|
47
|
+
* - `"attached"` — the pane was **still alive** (your process restarted, the
|
|
48
|
+
* session didn't); reconnected, nothing lost.
|
|
49
|
+
* - `"resumed"` — the pane was **gone** (it crashed, or the box lost its tmux
|
|
50
|
+
* server); the conversation was continued in a **fresh** pane. A turn may
|
|
51
|
+
* have been in flight when it died — check `turnComplete(yourLastCursor)`.
|
|
52
|
+
*/
|
|
53
|
+
export type RecoverStatus = "attached" | "resumed";
|
|
54
|
+
/** What {@link recover} returns: the live handle + how it was recovered. */
|
|
55
|
+
export interface RecoverResult {
|
|
56
|
+
readonly session: SessionHandle;
|
|
57
|
+
readonly status: RecoverStatus;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Reconnect to a session on boot — the **reconnect compound**, one decision
|
|
61
|
+
* (attach the live pane vs resume the dead one) composed from two atomic
|
|
62
|
+
* sub-owners ({@link adopt} and {@link resume}). It owns no policy beyond that:
|
|
63
|
+
* the re-send decision stays the consumer's (via `turnComplete`). A daemon calls
|
|
64
|
+
* THIS for each `{ name, agentSessionId }` it persisted, instead of hand-rolling
|
|
65
|
+
* a `try`/catch-`SessionGone`/resume dance — and the returned {@link RecoverStatus}
|
|
66
|
+
* makes "did it crash?" a field, not control flow you write yourself. Only
|
|
67
|
+
* `SessionGone` from `adopt` (uniform across both crash modes) triggers the
|
|
68
|
+
* resume fallback; any other adopt error propagates — those are caller mistakes,
|
|
69
|
+
* not crashes.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* // daemon boot, per persisted { name, agentSessionId, cwd, lastCursor, lastPrompt }:
|
|
74
|
+
* const { session, status } = await recover({ name, agentSessionId, cwd });
|
|
75
|
+
* if (status === "resumed" && !(await session.turnComplete(lastCursor)))
|
|
76
|
+
* await session.send(lastPrompt); // it crashed mid-turn — re-send the one lost turn
|
|
77
|
+
* // status === "attached" ⇒ the session never went down; just keep going.
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function recover(opts: ResumeOptions): Promise<RecoverResult>;
|
|
81
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzF;;;;;;GAMG;AAEH,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,GAAG,CACvB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,SAAS,CAAC,CAKpB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnD,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAczE"}
|
package/dist/compose.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SessionGone } from "./errors.js";
|
|
2
|
+
import { adopt } from "./session/adopt.js";
|
|
3
|
+
import { resume } from "./session/resume.js";
|
|
4
|
+
/**
|
|
5
|
+
* Do one Q&A round-trip: **send** the prompt, **wait** for the turn to reach a
|
|
6
|
+
* terminal {@link TurnOutcome}, then read the **messages** since it. Pure
|
|
7
|
+
* composition of the three primitives — `ask` is sugar, not a third source of
|
|
8
|
+
* truth: content still flows only through `messagesSince`, the outcome only
|
|
9
|
+
* through `wait`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { create, ask } from "claudemux";
|
|
14
|
+
* const session = await create({ name: "job", cwd: process.cwd() });
|
|
15
|
+
* const { outcome, messages } = await ask(session, "What's 2+2?");
|
|
16
|
+
* if (outcome.kind === "completed") console.log(messages.at(-1));
|
|
17
|
+
* else handleAbnormal(outcome); // awaiting / aborted / budget-exceeded
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export async function ask(session, text, opts) {
|
|
21
|
+
const cursor = await session.send(text);
|
|
22
|
+
const outcome = await session.wait(opts);
|
|
23
|
+
const messages = await session.messagesSince(cursor);
|
|
24
|
+
return { outcome, messages, cursor };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reconnect to a session on boot — the **reconnect compound**, one decision
|
|
28
|
+
* (attach the live pane vs resume the dead one) composed from two atomic
|
|
29
|
+
* sub-owners ({@link adopt} and {@link resume}). It owns no policy beyond that:
|
|
30
|
+
* the re-send decision stays the consumer's (via `turnComplete`). A daemon calls
|
|
31
|
+
* THIS for each `{ name, agentSessionId }` it persisted, instead of hand-rolling
|
|
32
|
+
* a `try`/catch-`SessionGone`/resume dance — and the returned {@link RecoverStatus}
|
|
33
|
+
* makes "did it crash?" a field, not control flow you write yourself. Only
|
|
34
|
+
* `SessionGone` from `adopt` (uniform across both crash modes) triggers the
|
|
35
|
+
* resume fallback; any other adopt error propagates — those are caller mistakes,
|
|
36
|
+
* not crashes.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // daemon boot, per persisted { name, agentSessionId, cwd, lastCursor, lastPrompt }:
|
|
41
|
+
* const { session, status } = await recover({ name, agentSessionId, cwd });
|
|
42
|
+
* if (status === "resumed" && !(await session.turnComplete(lastCursor)))
|
|
43
|
+
* await session.send(lastPrompt); // it crashed mid-turn — re-send the one lost turn
|
|
44
|
+
* // status === "attached" ⇒ the session never went down; just keep going.
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export async function recover(opts) {
|
|
48
|
+
try {
|
|
49
|
+
const session = await adopt({
|
|
50
|
+
name: opts.name,
|
|
51
|
+
...(opts.namespace === undefined ? {} : { namespace: opts.namespace }),
|
|
52
|
+
...(opts.agent === undefined ? {} : { agent: opts.agent }),
|
|
53
|
+
...(opts.backend === undefined ? {} : { backend: opts.backend }),
|
|
54
|
+
});
|
|
55
|
+
return { session, status: "attached" };
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
if (!(e instanceof SessionGone))
|
|
59
|
+
throw e; // a real adopt error, not a crash
|
|
60
|
+
const session = await resume(opts);
|
|
61
|
+
return { session, status: "resumed" };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+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AE,IAAI,CAAC,OAAO,EAAE,CAAC;SACjE,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,CAAC,YAAY,WAAW,CAAC;YAAE,MAAM,CAAC,CAAC,CAAC,kCAAkC;QAC5E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed errors thrown by the claudemux substrate. Every error carries the
|
|
3
|
+
* session name in its message so a consumer logging an unknown failure
|
|
4
|
+
* still has the context they need.
|
|
5
|
+
*
|
|
6
|
+
* No bare `Error` is ever thrown from the library. The classes here are
|
|
7
|
+
* exhaustive for the current public surface.
|
|
8
|
+
*/
|
|
9
|
+
/** Base class — consumers can `catch (e: ClaudemuxError)` for the union. */
|
|
10
|
+
export declare class ClaudemuxError extends Error {
|
|
11
|
+
/** The session this error pertains to. */
|
|
12
|
+
readonly sessionName: string;
|
|
13
|
+
constructor(message: string, sessionName: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Thrown by {@link create} when a session with the requested name already
|
|
17
|
+
* exists. The substrate never silently adopts an existing session — reconnect
|
|
18
|
+
* to the live session with {@link adopt} instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SessionExists extends ClaudemuxError {
|
|
21
|
+
constructor(sessionName: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown by {@link create} when a caller-supplied `agentSessionId` is not a
|
|
25
|
+
* well-formed v4 UUID. Thrown *before spawn*, at the substrate boundary.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* This is a **security boundary**, not just input hygiene. The id flows into
|
|
29
|
+
* the agent's argv next to its identity flag, and into the backend's per-session
|
|
30
|
+
* store and command grammar — where, in some backends, a bare `;` element can be
|
|
31
|
+
* a command separator. A v4 UUID is hex + hyphens only, so it can never be `;`,
|
|
32
|
+
* a path, or any token a backend would re-interpret; rejecting non-UUIDs here is
|
|
33
|
+
* what keeps the always-two-argv-elements injection safe. Do not "simplify" this
|
|
34
|
+
* to a loose check.
|
|
35
|
+
*/
|
|
36
|
+
export declare class InvalidAgentSessionId extends ClaudemuxError {
|
|
37
|
+
/** The malformed value the caller passed. */
|
|
38
|
+
readonly value: string;
|
|
39
|
+
constructor(value: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown by {@link create} when the caller passes an explicit
|
|
43
|
+
* `agentSessionId` **and** an identity flag in `extraArgs` that also selects a
|
|
44
|
+
* conversation id (claude: `--session-id`, `-r`/`--resume`, `--fork-session`).
|
|
45
|
+
* The two would fight over which id the agent runs under, so the substrate
|
|
46
|
+
* fails fast *before spawn* rather than silently dropping one. Pass the id one
|
|
47
|
+
* way or the other, not both.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Which `extraArgs` flags count as identity flags is agent-specific knowledge,
|
|
51
|
+
* so the conflict is detected inside the agent's `buildArgv` (claude owns the
|
|
52
|
+
* flag vocabulary per the layering grep) and surfaced as this neutral error.
|
|
53
|
+
*/
|
|
54
|
+
export declare class AgentSessionIdConflict extends ClaudemuxError {
|
|
55
|
+
constructor(sessionName: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Thrown by the boot orchestrator when a recognized dialog matches but its
|
|
59
|
+
* response did not advance the pane within the dialog timeout.
|
|
60
|
+
*/
|
|
61
|
+
export declare class DialogStuck extends ClaudemuxError {
|
|
62
|
+
/** The matched dialog's id (e.g. `"theme-picker"`). */
|
|
63
|
+
readonly dialogId: string;
|
|
64
|
+
constructor(sessionName: string, dialogId: string);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Thrown by **boot** ({@link create}/{@link resume}/{@link adopt}) when the REPL
|
|
68
|
+
* did not reach a stable ready state within `bootTimeoutMs`. NOT thrown by
|
|
69
|
+
* `wait()` — turn patience is the consumer's, so a turn that outlasts your budget
|
|
70
|
+
* is a returned `budget-exceeded` {@link TurnOutcome}, never an exception.
|
|
71
|
+
*/
|
|
72
|
+
export declare class ReplTimeout extends ClaudemuxError {
|
|
73
|
+
/** The timeout budget that elapsed, in milliseconds. */
|
|
74
|
+
readonly timeoutMs: number;
|
|
75
|
+
constructor(sessionName: string, timeoutMs: number);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown by boot when the login-method dialog fires — claudemux assumes the
|
|
79
|
+
* founder is already authenticated, so this dialog firing under claudemux is
|
|
80
|
+
* a setup error, not an auto-answerable dialog.
|
|
81
|
+
*/
|
|
82
|
+
export declare class LoginRequired extends ClaudemuxError {
|
|
83
|
+
constructor(sessionName: string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Thrown by boot when the agent presents a workspace-trust dialog for a
|
|
87
|
+
* `cwd` the substrate has not been told to trust. Trusting a folder is an
|
|
88
|
+
* **authority grant** (the agent gains read/edit/execute on those files),
|
|
89
|
+
* so the substrate fails closed: it does **not** auto-answer the dialog —
|
|
90
|
+
* it throws this *before sending any keystroke* and leaves the decision to
|
|
91
|
+
* the consumer. Pass `trustWorkspace: true` to `create` (or `--trust-workspace`
|
|
92
|
+
* on the CLI) to opt in.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* Opting in writes a **persistent, global, per-cwd** trust flag to the
|
|
96
|
+
* agent's config (`~/.claude.json` → `projects[<abs-cwd>]`), NOT a
|
|
97
|
+
* session-scoped one: it outlives the claudemux process and applies to
|
|
98
|
+
* every future `claude` run in that path, including the user's own
|
|
99
|
+
* interactive sessions. Trust is sticky per `(HOME × cwd-path)` — fail-closed
|
|
100
|
+
* only protects the *first* run in an untrusted path; a reused checkout path
|
|
101
|
+
* a prior run (or the user) already trusted inherits trust silently. For
|
|
102
|
+
* untrusted-fork workloads (PR bots / CI), use an ephemeral unique checkout
|
|
103
|
+
* path or an ephemeral HOME per run.
|
|
104
|
+
*/
|
|
105
|
+
export declare class WorkspaceUntrusted extends ClaudemuxError {
|
|
106
|
+
/** The cwd the agent asked to trust. */
|
|
107
|
+
readonly cwd: string;
|
|
108
|
+
constructor(sessionName: string, cwd: string);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Thrown by {@link SessionHandle.respond} when the agent declares no
|
|
112
|
+
* permission-prompt handling — there is no menu mapping to translate a
|
|
113
|
+
* {@link PromptChoice} into a keystroke, so the substrate refuses to guess a
|
|
114
|
+
* digit (a wrong guess could pick the broadest "allow all" option). An agent
|
|
115
|
+
* grows prompt handling by adding the mapping to its `AgentDef`; until then a
|
|
116
|
+
* consumer that hits an `awaiting{permission-prompt}` must answer the agent
|
|
117
|
+
* out-of-band (or run it in a non-interactive permission mode).
|
|
118
|
+
*/
|
|
119
|
+
export declare class PromptResponseUnsupported extends ClaudemuxError {
|
|
120
|
+
/** The agent that has no permission-prompt mapping (e.g. a future codex def). */
|
|
121
|
+
readonly agentName: string;
|
|
122
|
+
constructor(sessionName: string, agentName: string);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Thrown by {@link SessionHandle.messagesSince} / {@link SessionHandle.turnComplete}
|
|
126
|
+
* when the session's transcript **cannot be located at all** — there is no
|
|
127
|
+
* recoverable `agentSessionId` to locate it by AND no hook edge has reported its
|
|
128
|
+
* path (an {@link adopt} whose recovery cache missed, a non-claudemux session, or
|
|
129
|
+
* a fork before its first hook edge). Reads are *blind*, not "nothing new."
|
|
130
|
+
*
|
|
131
|
+
* This is a **loud** failure on purpose: an empty read silently conflated with
|
|
132
|
+
* "no reply yet" sits exactly in the crash-recovery re-send path, where the wrong
|
|
133
|
+
* answer double-runs work. Throwing forces the consumer to handle "I can't see
|
|
134
|
+
* this conversation" distinctly. A genuinely empty (but *locatable*) transcript,
|
|
135
|
+
* or an unresolvable cursor (a sentinel/garbage value), still returns empty —
|
|
136
|
+
* only true unlocatability throws.
|
|
137
|
+
*/
|
|
138
|
+
export declare class TranscriptUnlocatable extends ClaudemuxError {
|
|
139
|
+
constructor(sessionName: string);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Thrown when the backend cannot find the named session — it has been reaped
|
|
143
|
+
* (a crash, a `kill`, or the box lost its backend server). The canonical "this
|
|
144
|
+
* session is gone" for **every** per-session op (read or write); `kill()` never
|
|
145
|
+
* throws it (killing a gone session is success).
|
|
146
|
+
*/
|
|
147
|
+
export declare class SessionGone extends ClaudemuxError {
|
|
148
|
+
constructor(sessionName: string);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Thrown by {@link create} when the agent process **exits before the session
|
|
152
|
+
* becomes ready** — claudemux spawned it, but it was gone (its backend session
|
|
153
|
+
* reaped) before boot could reach an interactive prompt.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* **The most common cause is an `agentSessionId` collision:** claude refuses to
|
|
157
|
+
* silently resume or clobber an in-use conversation id — it prints
|
|
158
|
+
* "Session ID … is already in use" and exits. But a malformed `extraArgs` flag,
|
|
159
|
+
* an auth edge, or any startup crash produce the *identical* shape, and
|
|
160
|
+
* claudemux **cannot read which** — the substrate runs panes with
|
|
161
|
+
* `remain-on-exit off`, so claude's stderr is reaped before boot can capture
|
|
162
|
+
* it. That is the same deliberate property that lets {@link adopt} hand back a
|
|
163
|
+
* clean {@link SessionGone} for a crashed agent instead of a corpse handle, so
|
|
164
|
+
* we do not flip it to recover a diagnostic string.
|
|
165
|
+
*
|
|
166
|
+
* This is a distinct class on purpose (errors.ts reuses before adding):
|
|
167
|
+
* {@link SessionGone} reads as *external* reaping of a session that should
|
|
168
|
+
* exist, which does not carry the meaning the create path needs — *"the agent I
|
|
169
|
+
* just spawned rejected its own launch"* (self-inflicted exit vs external
|
|
170
|
+
* interference) — which is exactly what the consumer must act on.
|
|
171
|
+
*
|
|
172
|
+
* When the spawn used a caller-chosen id, it is carried on
|
|
173
|
+
* {@link agentSessionId} so the collision case stays actionable as structured
|
|
174
|
+
* data (pick another id, or resume that conversation) without scraping text.
|
|
175
|
+
*
|
|
176
|
+
* **Deferred precision:** once a `transcriptPath` helper lands (owning claude's
|
|
177
|
+
* cwd-slug rule in `claude.ts` per the layering grep), a pre-spawn transcript
|
|
178
|
+
* probe can upgrade the collision case to a precise `AgentSessionInUse` and
|
|
179
|
+
* fall back to this error for the other death causes — a non-breaking addition.
|
|
180
|
+
*/
|
|
181
|
+
export declare class AgentExitedDuringBoot extends ClaudemuxError {
|
|
182
|
+
/** The caller-chosen id the spawn used, if any — the likely collision culprit. */
|
|
183
|
+
readonly agentSessionId?: string;
|
|
184
|
+
constructor(sessionName: string, agentSessionId?: string);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Discriminates *why* the backend is unreachable. Recovery code branches on
|
|
188
|
+
* this: `no-server` is a legitimate "nothing is running yet" (query verbs
|
|
189
|
+
* treat it as absence), whereas `spawn-failed` (binary missing) and
|
|
190
|
+
* `timeout` (wedged backend) are real faults that must surface loudly — a
|
|
191
|
+
* missing dependency or a hung process must never masquerade as "no
|
|
192
|
+
* sessions exist."
|
|
193
|
+
*/
|
|
194
|
+
export type BackendUnreachableKind = "no-server" | "spawn-failed" | "timeout";
|
|
195
|
+
/**
|
|
196
|
+
* Thrown when the underlying backend (the agent's I/O substrate) is
|
|
197
|
+
* unreachable — the backend process failed to spawn (`spawn-failed`), its
|
|
198
|
+
* server was not running on the requested connection (`no-server`), or a
|
|
199
|
+
* backend invocation hung past its budget (`timeout`).
|
|
200
|
+
*/
|
|
201
|
+
export declare class BackendUnreachable extends ClaudemuxError {
|
|
202
|
+
/** Why the backend was unreachable — see {@link BackendUnreachableKind}. */
|
|
203
|
+
readonly kind: BackendUnreachableKind;
|
|
204
|
+
/** The underlying spawn / connection error, if available. */
|
|
205
|
+
readonly underlying?: Error;
|
|
206
|
+
constructor(sessionName: string, kind: BackendUnreachableKind, underlying?: Error);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Thrown by `create` / `spawn` when the session name or namespace contains
|
|
210
|
+
* characters that the substrate cannot encode safely for the backend's
|
|
211
|
+
* target grammar. The substrate fails fast at the boundary instead of
|
|
212
|
+
* silently renaming and producing an un-addressable handle.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* Reserved set: `.`, `:`, `*`, `?`, leading `-`, any whitespace, `/`,
|
|
216
|
+
* `\n`, `\r`, `\\`, and the empty string.
|
|
217
|
+
*/
|
|
218
|
+
export declare class InvalidSessionName extends ClaudemuxError {
|
|
219
|
+
/** Which field was invalid (`"name"` or `"namespace"`). */
|
|
220
|
+
readonly field: "name" | "namespace";
|
|
221
|
+
/** The actual value the caller passed. */
|
|
222
|
+
readonly value: string;
|
|
223
|
+
/** The reason the value is rejected. */
|
|
224
|
+
readonly reason: string;
|
|
225
|
+
constructor(field: "name" | "namespace", value: string, reason: string);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Wrapper for an unexpected backend failure that isn't one of the typed
|
|
229
|
+
* cases above (non-zero exit + unrecognized stderr).
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* The `.message` deliberately **excludes the backend argv** — the argv is
|
|
233
|
+
* pure backend vocabulary (the backend's own subcommand names) and leaking
|
|
234
|
+
* it into the user-facing message violates the substrate's "zero references
|
|
235
|
+
* to the backend in error messages" promise. The argv lives on `.argv` (and
|
|
236
|
+
* flows through `onBackendCommand`) for programmatic diagnosis; the
|
|
237
|
+
* human-readable message carries the exit code and the backend's own stderr
|
|
238
|
+
* text, which is the diagnostic value without the command vocabulary.
|
|
239
|
+
*
|
|
240
|
+
* This is the structural backstop behind the backend classifier's
|
|
241
|
+
* routine-case promotion: even a backend failure shape we haven't classified
|
|
242
|
+
* yet cannot leak the backend's command names into user-facing text.
|
|
243
|
+
*/
|
|
244
|
+
export declare class BackendError extends ClaudemuxError {
|
|
245
|
+
readonly argv: readonly string[];
|
|
246
|
+
readonly exitCode: number;
|
|
247
|
+
readonly stderr: string;
|
|
248
|
+
constructor(sessionName: string, argv: readonly string[], exitCode: number, stderr: string);
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4EAA4E;AAC5E,qBAAa,cAAe,SAAQ,KAAK;IACvC,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAKjD;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,cAAc;gBACnC,WAAW,EAAE,MAAM;CAMhC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM;CAQ1B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAuB,SAAQ,cAAc;gBAC5C,WAAW,EAAE,MAAM;CAOhC;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAIlD;AAED;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAInD;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,c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