@basein/runner 0.2.12 → 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/README.md +540 -369
- package/dist/auth/client.d.ts +65 -3
- package/dist/auth/client.js +305 -53
- package/dist/bin/bir-hooks.d.ts +72 -31
- package/dist/bin/bir-hooks.js +176 -284
- package/dist/bin/bir-proxy.d.ts +17 -2
- package/dist/bin/bir-proxy.js +222 -28
- package/dist/bin/bir-scenario.d.ts +61 -21
- package/dist/bin/bir-scenario.js +593 -122
- package/dist/bin/bir.d.ts +12 -6
- package/dist/bin/bir.js +2935 -489
- package/dist/bin/investigate.js +40 -15
- package/dist/bin/scenario-edit.d.ts +7 -1
- package/dist/bin/scenario-edit.js +43 -21
- package/dist/bin/scenario-liveness.d.ts +194 -0
- package/dist/bin/scenario-liveness.js +459 -0
- package/dist/bin/scenario-stderr.d.ts +43 -0
- package/dist/bin/scenario-stderr.js +76 -0
- package/dist/bin/service-read.d.ts +88 -0
- package/dist/bin/service-read.js +128 -0
- package/dist/bin/setup.d.ts +19 -0
- package/dist/bin/setup.js +146 -20
- package/dist/config/adapters/claude-code.d.ts +92 -14
- package/dist/config/adapters/claude-code.js +291 -101
- package/dist/config/adapters/generic.d.ts +4 -1
- package/dist/config/adapters/generic.js +13 -14
- package/dist/config/generate.d.ts +392 -14
- package/dist/config/generate.js +666 -19
- package/dist/config/mcp-approval.d.ts +76 -0
- package/dist/config/mcp-approval.js +210 -0
- package/dist/config/node-path.d.ts +42 -0
- package/dist/config/node-path.js +102 -0
- package/dist/config/overrides.d.ts +62 -0
- package/dist/config/overrides.js +136 -0
- package/dist/config/resolve.d.ts +70 -8
- package/dist/config/resolve.js +186 -15
- package/dist/control/client.d.ts +22 -0
- package/dist/control/client.js +26 -7
- package/dist/control/correlation.d.ts +23 -5
- package/dist/control/correlation.js +0 -0
- package/dist/control/daemon.d.ts +400 -18
- package/dist/control/daemon.js +1105 -102
- package/dist/control/discovery.d.ts +77 -5
- package/dist/control/discovery.js +186 -11
- package/dist/control/ensure-hook.d.ts +61 -0
- package/dist/control/ensure-hook.js +160 -8
- package/dist/control/paths.d.ts +26 -0
- package/dist/control/paths.js +34 -0
- package/dist/control/pin-guard.d.ts +83 -0
- package/dist/control/pin-guard.js +534 -0
- package/dist/control/recorder-keeper.d.ts +229 -0
- package/dist/control/recorder-keeper.js +721 -0
- package/dist/control/recorder-main.d.ts +73 -0
- package/dist/control/recorder-main.js +778 -0
- package/dist/control/server.d.ts +707 -31
- package/dist/control/server.js +2786 -302
- package/dist/control/transcript.d.ts +21 -1
- package/dist/control/transcript.js +378 -112
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/jsonrpc/framing.d.ts +76 -12
- package/dist/jsonrpc/framing.js +216 -59
- package/dist/proxy/intercept.d.ts +49 -5
- package/dist/proxy/intercept.js +188 -59
- package/dist/proxy/relay.d.ts +16 -0
- package/dist/proxy/relay.js +77 -5
- package/dist/proxy/revive.d.ts +122 -0
- package/dist/proxy/revive.js +251 -0
- package/dist/proxy/session.d.ts +222 -14
- package/dist/proxy/session.js +708 -99
- package/dist/record/recorder.d.ts +51 -3
- package/dist/record/recorder.js +3 -0
- package/dist/record/redact.d.ts +103 -9
- package/dist/record/redact.js +659 -30
- package/dist/record/remote-recorder.d.ts +327 -32
- package/dist/record/remote-recorder.js +1517 -187
- package/dist/record/switchable-recorder.d.ts +126 -0
- package/dist/record/switchable-recorder.js +351 -0
- package/dist/record/truncate.d.ts +40 -1
- package/dist/record/truncate.js +111 -4
- package/dist/replay/bash-channel.d.ts +35 -0
- package/dist/replay/bash-channel.js +133 -0
- package/dist/replay/bundle.d.ts +10 -0
- package/dist/replay/bundle.js +10 -0
- package/dist/replay/controller.d.ts +369 -20
- package/dist/replay/controller.js +1176 -107
- package/dist/replay/derive.d.ts +1 -0
- package/dist/replay/derive.js +81 -24
- package/dist/replay/executor.d.ts +51 -16
- package/dist/replay/executor.js +114 -41
- package/dist/replay/handover.d.ts +54 -1
- package/dist/replay/handover.js +55 -5
- package/dist/replay/logic.d.ts +62 -10
- package/dist/replay/logic.js +140 -22
- package/dist/replay/plan.d.ts +201 -27
- package/dist/replay/plan.js +581 -141
- package/dist/replay/safety.d.ts +72 -0
- package/dist/replay/safety.js +303 -0
- package/dist/replay/source-run.d.ts +10 -0
- package/dist/replay/source-run.js +80 -35
- package/dist/replay/targets.d.ts +15 -1
- package/dist/replay/targets.js +62 -4
- package/dist/replay/tool-error.d.ts +15 -1
- package/dist/replay/tool-error.js +33 -1
- package/dist/replay/types.d.ts +7 -4
- package/dist/upstream/client.d.ts +56 -3
- package/dist/upstream/client.js +61 -4
- package/dist/upstream/headers.d.ts +43 -0
- package/dist/upstream/headers.js +90 -0
- package/dist/upstream/http-client.d.ts +213 -22
- package/dist/upstream/http-client.js +1034 -168
- package/dist/upstream/http-transport.d.ts +143 -0
- package/dist/upstream/http-transport.js +391 -0
- package/dist/upstream/lazy-client.d.ts +8 -0
- package/dist/upstream/lazy-client.js +29 -1
- package/dist/upstream/sse.d.ts +78 -0
- package/dist/upstream/sse.js +189 -0
- package/dist/upstream/stdio-client.d.ts +61 -1
- package/dist/upstream/stdio-client.js +356 -33
- package/dist/util/atomic-write.d.ts +29 -0
- package/dist/util/atomic-write.js +96 -0
- package/dist/util/journal.d.ts +15 -0
- package/dist/util/journal.js +48 -3
- package/dist/util/log.d.ts +10 -0
- package/dist/util/log.js +28 -1
- package/dist/util/off-switch.d.ts +46 -0
- package/dist/util/off-switch.js +91 -0
- package/dist/util/service-health.d.ts +133 -0
- package/dist/util/service-health.js +217 -0
- package/docs/BaseInstRunner.md +694 -621
- package/docs/calculatedReplay.md +1625 -1304
- package/docs/calculatedReplayGuide.md +1212 -1087
- package/docs/installRun.md +1013 -772
- package/docs/loginWeb.md +627 -607
- package/docs/mcpmark.md +49 -16
- package/docs/my-first-sample.md +569 -545
- package/docs/quickstart.md +384 -311
- package/docs/t-bench.md +406 -394
- package/package.json +58 -57
- package/production.md +1371 -0
- package/scripts/install.ps1 +97 -6
- package/scripts/install.sh +104 -7
package/dist/control/paths.d.ts
CHANGED
|
@@ -27,6 +27,25 @@ export declare function configPath(): string;
|
|
|
27
27
|
export declare function logsDir(): string;
|
|
28
28
|
/** The log file of the background recorder for `cwd`. */
|
|
29
29
|
export declare function daemonLogPath(cwd: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* The log of a recorder that no longer serves the port `cwd`'s hooks post to
|
|
32
|
+
* (a reinstall moved them) but still serves the windows opened before that.
|
|
33
|
+
* Its own file, so the project's log has one writer and one rotation.
|
|
34
|
+
*/
|
|
35
|
+
export declare function supersededLogPath(cwd: string, port: number): string;
|
|
36
|
+
/**
|
|
37
|
+
* The record of such a superseded recorder, one per process, so `bir status`,
|
|
38
|
+
* `bir down` and `bir uninstall` can find and stop it: the project's discovery
|
|
39
|
+
* file names only the recorder its hooks post to now.
|
|
40
|
+
*/
|
|
41
|
+
export declare function supersededPath(cwd: string, pid: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* Written when a recorder of `cwd` is stopped on purpose (`bir down`),
|
|
44
|
+
* removed when one is started again (a session start, `bir up`, `bir setup`).
|
|
45
|
+
* While it is there, a bound proxy that finds the recorder gone does not bring
|
|
46
|
+
* it back (`bir-hooks revive`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function downMarkerPath(cwd: string): string;
|
|
30
49
|
/** Create a directory with restrictive permissions. Idempotent, never throws. */
|
|
31
50
|
export declare function ensureDir(dir: string, mode?: number): void;
|
|
32
51
|
/**
|
|
@@ -43,4 +62,11 @@ export declare function normalizePath(p: string): string;
|
|
|
43
62
|
export declare function controlKey(cwd: string): string;
|
|
44
63
|
/** Absolute path of the discovery file for `cwd`. */
|
|
45
64
|
export declare function discoveryPath(cwd: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Where a background recorder that could not take this project's port says
|
|
67
|
+
* why — who holds it, or that the system reserved it — so `bir doctor` and the
|
|
68
|
+
* next SessionStart can name the problem instead of a hidden log line. Removed
|
|
69
|
+
* by the first recorder that binds the port again.
|
|
70
|
+
*/
|
|
71
|
+
export declare function portProblemPath(cwd: string): string;
|
|
46
72
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/control/paths.js
CHANGED
|
@@ -43,6 +43,31 @@ export function logsDir() {
|
|
|
43
43
|
export function daemonLogPath(cwd) {
|
|
44
44
|
return join(logsDir(), `${controlKey(cwd)}.log`);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* The log of a recorder that no longer serves the port `cwd`'s hooks post to
|
|
48
|
+
* (a reinstall moved them) but still serves the windows opened before that.
|
|
49
|
+
* Its own file, so the project's log has one writer and one rotation.
|
|
50
|
+
*/
|
|
51
|
+
export function supersededLogPath(cwd, port) {
|
|
52
|
+
return join(logsDir(), `${controlKey(cwd)}.superseded-${port}.log`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The record of such a superseded recorder, one per process, so `bir status`,
|
|
56
|
+
* `bir down` and `bir uninstall` can find and stop it: the project's discovery
|
|
57
|
+
* file names only the recorder its hooks post to now.
|
|
58
|
+
*/
|
|
59
|
+
export function supersededPath(cwd, pid) {
|
|
60
|
+
return join(controlDir(), `${controlKey(cwd)}.superseded.${pid}.json`);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Written when a recorder of `cwd` is stopped on purpose (`bir down`),
|
|
64
|
+
* removed when one is started again (a session start, `bir up`, `bir setup`).
|
|
65
|
+
* While it is there, a bound proxy that finds the recorder gone does not bring
|
|
66
|
+
* it back (`bir-hooks revive`).
|
|
67
|
+
*/
|
|
68
|
+
export function downMarkerPath(cwd) {
|
|
69
|
+
return join(controlDir(), `${controlKey(cwd)}.down`);
|
|
70
|
+
}
|
|
46
71
|
/** Create a directory with restrictive permissions. Idempotent, never throws. */
|
|
47
72
|
export function ensureDir(dir, mode = 0o700) {
|
|
48
73
|
try {
|
|
@@ -73,4 +98,13 @@ export function controlKey(cwd) {
|
|
|
73
98
|
export function discoveryPath(cwd) {
|
|
74
99
|
return join(controlDir(), `${controlKey(cwd)}.json`);
|
|
75
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Where a background recorder that could not take this project's port says
|
|
103
|
+
* why — who holds it, or that the system reserved it — so `bir doctor` and the
|
|
104
|
+
* next SessionStart can name the problem instead of a hidden log line. Removed
|
|
105
|
+
* by the first recorder that binds the port again.
|
|
106
|
+
*/
|
|
107
|
+
export function portProblemPath(cwd) {
|
|
108
|
+
return join(controlDir(), `${controlKey(cwd)}.port.json`);
|
|
109
|
+
}
|
|
76
110
|
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pin-guard — whether a live call is plausibly the step a steering plan
|
|
3
|
+
* expects, before the control server rewrites it to the step's input.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS. A steer plan pins "the next call to the expected tool", and
|
|
6
|
+
* the pin replaces the model's arguments with the step's and answers `allow`.
|
|
7
|
+
* Matching on the tool name alone meant that a model checking its work with
|
|
8
|
+
* `Bash ls` while a `Bash git push --force` step was due had Claude Code show
|
|
9
|
+
* `ls` and run the push, unasked. A tool name says which *kind* of call this
|
|
10
|
+
* is; it says nothing about whether the call is the step.
|
|
11
|
+
*
|
|
12
|
+
* The rule is deliberately conservative, because the two mistakes are not the
|
|
13
|
+
* same size. Not pinning a call that was the step costs a replay: the call
|
|
14
|
+
* runs as the model wrote it, and the plan stays armed for the call that is
|
|
15
|
+
* the step (the control server retires it, running nothing, if the model moves
|
|
16
|
+
* on to another tool instead). Pinning one that was not the step runs
|
|
17
|
+
* something the user never saw.
|
|
18
|
+
*
|
|
19
|
+
* - `Bash` / `PowerShell`: the same command, or the same *commands*: as
|
|
20
|
+
* many of them, chained the same way (`&&`, `||`, `;`, `|`, `&`, a new
|
|
21
|
+
* line), each with the same head (the program, plus its subcommand when
|
|
22
|
+
* it has one: `git push`, `npm test`; plus what it runs when it only runs
|
|
23
|
+
* something else: `npm run lint`, `python deploy.py`). Comparing only the
|
|
24
|
+
* first command's head pinned a model's `git status` to a step's `git
|
|
25
|
+
* status && git push --force`. A step that runs a command substitution
|
|
26
|
+
* (`$(…)`, backticks) is pinned only to an exact copy.
|
|
27
|
+
* - Tools that write a file: the same file.
|
|
28
|
+
* - MCP tools whose input is run — a query, a statement, a shell command
|
|
29
|
+
* (replay/safety.ts `sinkOf`): every statement the step runs, supplied by
|
|
30
|
+
* the model with the same verb (`SELECT` for `SELECT`, never for
|
|
31
|
+
* `DELETE`), or no arguments at all. One shared key such as `sql` said
|
|
32
|
+
* nothing about what the call does. An empty statement argument of the
|
|
33
|
+
* step (`input: ""` beside the query) runs nothing and need not be
|
|
34
|
+
* supplied — but a call that runs something there is not the step.
|
|
35
|
+
* - Everything else: at least one argument in common, and no argument that
|
|
36
|
+
* names *where* the call acts (a path, a URL) pointing somewhere else. A
|
|
37
|
+
* call with no arguments at all is the model deferring to the directive
|
|
38
|
+
* ("the system supplies the exact arguments") and is pinned.
|
|
39
|
+
*
|
|
40
|
+
* Read-only file tools are not held to the same file: pinning a `Read` of the
|
|
41
|
+
* wrong path to the step's path is exactly what the directive asks for, and it
|
|
42
|
+
* changes nothing on disk.
|
|
43
|
+
*/
|
|
44
|
+
export interface PinVerdict {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
/** Why not, for the audit line. */
|
|
47
|
+
why?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The part of a command that says what it does: the program and, when the
|
|
51
|
+
* next word reads like a subcommand, that too — `git push`, `npm test`,
|
|
52
|
+
* `docker compose`. Leading environment assignments and a leading `cd <dir> &&`
|
|
53
|
+
* are skipped; a path, a flag or a file name is not a subcommand.
|
|
54
|
+
*
|
|
55
|
+
* A program that only runs something else is named with what it runs —
|
|
56
|
+
* `npm run lint` (never just `npm run`, which would pin a lint to a deploy),
|
|
57
|
+
* `npx eslint`, `python deploy.py`, `python -m pytest`, `uv run pytest` —
|
|
58
|
+
* and a shell's inline command is that command: `bash -c "git push"` is
|
|
59
|
+
* `git push`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function commandHead(command: string, depth?: number): string;
|
|
62
|
+
/**
|
|
63
|
+
* A command line split into the commands it chains, at the separators that
|
|
64
|
+
* are not quoted or escaped: `&&`, `||`, `;`, `|` (and `|&`), a background
|
|
65
|
+
* `&`, a new line. A redirection's `&` (`2>&1`, `&>file`, `>&2`) is not one.
|
|
66
|
+
* `escape` is the shell's own escape character: a backslash in a POSIX shell,
|
|
67
|
+
* a backtick in PowerShell (where `C:\;` ends a command), a caret in cmd.
|
|
68
|
+
* Good enough to count and name the commands; not a shell parser.
|
|
69
|
+
*/
|
|
70
|
+
export declare function commandSegments(command: string, escape?: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* What a command line does, command by command: the {@link commandHead} of
|
|
73
|
+
* each chained command, a shell's inline command expanded into its own, and a
|
|
74
|
+
* leading `cd <dir>` (which only says where) left out. Two command lines run
|
|
75
|
+
* the same things when these are equal.
|
|
76
|
+
*/
|
|
77
|
+
export declare function commandShape(command: string, depth?: number, escape?: string): string[];
|
|
78
|
+
/**
|
|
79
|
+
* Whether the model's call `modelArgs` to `toolName` may be pinned to the
|
|
80
|
+
* step's `pinnedArgs`. See the file comment for the rule.
|
|
81
|
+
*/
|
|
82
|
+
export declare function pinCompatible(toolName: string, modelArgs: unknown, pinnedArgs: unknown): PinVerdict;
|
|
83
|
+
//# sourceMappingURL=pin-guard.d.ts.map
|