@basein/runner 0.2.8 → 0.2.11
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 +86 -22
- package/dist/auth/client.d.ts +40 -1
- package/dist/auth/client.js +77 -9
- package/dist/bin/bir-hooks.d.ts +18 -3
- package/dist/bin/bir-hooks.js +124 -38
- package/dist/bin/bir-scenario.d.ts +18 -2
- package/dist/bin/bir-scenario.js +374 -4
- package/dist/bin/bir.d.ts +12 -0
- package/dist/bin/bir.js +501 -81
- package/dist/bin/investigate.js +1 -1
- package/dist/bin/scenario-edit.d.ts +173 -0
- package/dist/bin/scenario-edit.js +771 -0
- package/dist/bin/setup.d.ts +72 -0
- package/dist/bin/setup.js +286 -0
- package/dist/config/adapters/claude-code.d.ts +90 -4
- package/dist/config/adapters/claude-code.js +164 -16
- package/dist/config/generate.d.ts +114 -1
- package/dist/config/generate.js +106 -3
- package/dist/control/client.d.ts +5 -0
- package/dist/control/client.js +8 -0
- package/dist/control/daemon.d.ts +116 -0
- package/dist/control/daemon.js +339 -0
- package/dist/control/discovery.d.ts +26 -0
- package/dist/control/discovery.js +41 -9
- package/dist/control/ensure-hook.d.ts +39 -0
- package/dist/control/ensure-hook.js +98 -0
- package/dist/control/paths.d.ts +14 -0
- package/dist/control/paths.js +20 -0
- package/dist/control/server.d.ts +28 -0
- package/dist/control/server.js +15 -2
- package/dist/proxy/session.d.ts +8 -1
- package/dist/proxy/session.js +28 -6
- package/docs/calculatedReplay.md +51 -0
- package/docs/calculatedReplayGuide.md +471 -74
- package/docs/installRun.md +457 -111
- package/docs/loginWeb.md +1 -1
- package/docs/quickstart.md +195 -158
- package/package.json +2 -1
- package/scripts/install.ps1 +669 -0
- package/scripts/install.sh +586 -0
package/dist/bin/investigate.js
CHANGED
|
@@ -183,7 +183,7 @@ export const DECLINES = {
|
|
|
183
183
|
},
|
|
184
184
|
nondeterministic_first_step: {
|
|
185
185
|
cause: "the chain's first step needs a judgement the calculation could not write code for, so the plan cannot start.",
|
|
186
|
-
fix: "the
|
|
186
|
+
fix: "if its code only has a slip, fix the step yourself: read it with `bir scenario show <scnId> --step 0`, write the input logic to a file, and run `bir scenario edit <scnId> --step 0 --input-logic <file>`; the service checks it against the recording before it saves it. A real judgement — a choice with no fixed rule — stays with the agent until a model step exists (plan-services.md W3.1).",
|
|
187
187
|
},
|
|
188
188
|
unusable_first_step: {
|
|
189
189
|
cause: "the first step calls a sub-task that is gone, switched off or stale.",
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scenario-edit — read, check, change and undo one step of a calculated
|
|
3
|
+
* scenario (editSteps.md in the BaseIn repository; docs/calculatedReplayGuide.md §9.2).
|
|
4
|
+
*
|
|
5
|
+
* bir scenario show <runId|scnId> [--step <n>]
|
|
6
|
+
* bir scenario check <runId|scnId> --step <n> [--input-logic <file|->] [--output-logic <file|->] [--unfreeze]
|
|
7
|
+
* bir scenario edit <runId|scnId> --step <n> [--input-logic <file|->] [--output-logic <file|->]
|
|
8
|
+
* [--freeze | --unfreeze] [--note "why"] [--force --note "why"] [--revision <n>]
|
|
9
|
+
* bir scenario edits <runId|scnId>
|
|
10
|
+
* bir scenario undo <runId|scnId> [--edit <sedit_id>]
|
|
11
|
+
* bir scenario calc <runId> [--force [--discard-edits]]
|
|
12
|
+
* bir scenario editing on|off|status
|
|
13
|
+
*
|
|
14
|
+
* WHY THIS IS A CLIENT AND NOTHING MORE. Whether a change may be saved is
|
|
15
|
+
* decided on the service, against the recording, by the calculation's own
|
|
16
|
+
* check (D3) — and `check` and `edit` are the same function there (D11). A
|
|
17
|
+
* runner-side pre-check would be a second opinion that can disagree with the
|
|
18
|
+
* one that counts, so this module reads logic from files, sends it, and says
|
|
19
|
+
* in words what the service answered. `--json` prints the answer unchanged,
|
|
20
|
+
* which is what the `bir` MCP server hands the model.
|
|
21
|
+
*
|
|
22
|
+
* Logic never comes from the command line itself. A JavaScript body is full
|
|
23
|
+
* of quotes, braces and `$`, and every shell mangles a different subset of
|
|
24
|
+
* them; a file, or stdin with `-`, arrives byte for byte.
|
|
25
|
+
*
|
|
26
|
+
* Everything the commands touch is injected ({@link ScenarioEditDeps}), as in
|
|
27
|
+
* `investigate.ts`, so all of it is tested in-process against a fake service.
|
|
28
|
+
* The exception is `editing`, which writes the install sidecar — tests point
|
|
29
|
+
* `BIR_HOME` at a temporary directory for that.
|
|
30
|
+
*/
|
|
31
|
+
export type InputStatus = "reproduces" | "differs" | "throws" | "copy" | "not_checked";
|
|
32
|
+
export interface EditReport {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
stepIndex: number;
|
|
35
|
+
toolName: string | null;
|
|
36
|
+
/** The recording the change was checked against. */
|
|
37
|
+
sourceRunId: string;
|
|
38
|
+
verifiable: boolean;
|
|
39
|
+
input: {
|
|
40
|
+
changed: boolean;
|
|
41
|
+
before: InputStatus;
|
|
42
|
+
after: InputStatus;
|
|
43
|
+
computed?: unknown;
|
|
44
|
+
recorded?: unknown;
|
|
45
|
+
firstDifference?: {
|
|
46
|
+
at: number;
|
|
47
|
+
computed: string;
|
|
48
|
+
recorded: string;
|
|
49
|
+
};
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
output: {
|
|
53
|
+
changed: boolean;
|
|
54
|
+
status: "runs" | "throws" | "not_object" | "unchanged";
|
|
55
|
+
emittedKeys?: string[];
|
|
56
|
+
error?: string;
|
|
57
|
+
};
|
|
58
|
+
later: Array<{
|
|
59
|
+
stepIndex: number;
|
|
60
|
+
toolName: string | null;
|
|
61
|
+
before: InputStatus;
|
|
62
|
+
after: InputStatus;
|
|
63
|
+
regressed: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
answer: {
|
|
66
|
+
informativeBefore: boolean;
|
|
67
|
+
informativeAfter: boolean;
|
|
68
|
+
} | null;
|
|
69
|
+
mark: {
|
|
70
|
+
before: MarkState;
|
|
71
|
+
after: MarkState;
|
|
72
|
+
};
|
|
73
|
+
problems: string[];
|
|
74
|
+
}
|
|
75
|
+
interface MarkState {
|
|
76
|
+
marked: boolean;
|
|
77
|
+
why: string | null;
|
|
78
|
+
}
|
|
79
|
+
export interface StepState {
|
|
80
|
+
toolInputLogic: string | null;
|
|
81
|
+
toolOutputLogic: string | null;
|
|
82
|
+
nondeterministic: boolean;
|
|
83
|
+
nondeterministicWhy: string | null;
|
|
84
|
+
editedAt: string | null;
|
|
85
|
+
editForced: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface EditEntry {
|
|
88
|
+
id: string;
|
|
89
|
+
scenarioId: string;
|
|
90
|
+
stepIndex: number;
|
|
91
|
+
kind: "edit" | "freeze" | "revert";
|
|
92
|
+
revertsEditId: string | null;
|
|
93
|
+
note: string | null;
|
|
94
|
+
forced: boolean;
|
|
95
|
+
chainRevisionBefore: number;
|
|
96
|
+
chainRevisionAfter: number;
|
|
97
|
+
before: StepState;
|
|
98
|
+
after: StepState;
|
|
99
|
+
report: EditReport | null;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
/** A later undo put this one back. */
|
|
102
|
+
revertedAt: string | null;
|
|
103
|
+
/** A recalculation replaced the chain; the entry is history now. */
|
|
104
|
+
replacedAt: string | null;
|
|
105
|
+
}
|
|
106
|
+
export type ServiceReply = {
|
|
107
|
+
status: number;
|
|
108
|
+
body: unknown;
|
|
109
|
+
} | {
|
|
110
|
+
error: string;
|
|
111
|
+
};
|
|
112
|
+
export interface ScenarioEditDeps {
|
|
113
|
+
cwd: string;
|
|
114
|
+
out: (line?: string) => void;
|
|
115
|
+
/** An authenticated call to the service; a failure to reach it is `{ error }`, never a throw. */
|
|
116
|
+
service: (method: string, path: string, body?: unknown) => Promise<ServiceReply>;
|
|
117
|
+
/** A logic file's bytes. Relative paths are the caller's to resolve. */
|
|
118
|
+
readFile: (path: string) => Buffer;
|
|
119
|
+
/** All of stdin, for `--input-logic -` / `--output-logic -`. */
|
|
120
|
+
readStdin: () => Promise<Buffer>;
|
|
121
|
+
}
|
|
122
|
+
export interface ScenarioEditArgs {
|
|
123
|
+
/** The words after `bir scenario`: `[sub, target | on|off|status, …]`. */
|
|
124
|
+
positionals: string[];
|
|
125
|
+
json: boolean;
|
|
126
|
+
force: boolean;
|
|
127
|
+
step?: number;
|
|
128
|
+
/** A path, or `-` for stdin. */
|
|
129
|
+
inputLogic?: string;
|
|
130
|
+
outputLogic?: string;
|
|
131
|
+
freeze: boolean;
|
|
132
|
+
unfreeze: boolean;
|
|
133
|
+
note?: string;
|
|
134
|
+
/** `undo --edit`: the `sedit_` id to put back. */
|
|
135
|
+
edit?: string;
|
|
136
|
+
/** `--revision`: save only if the plan is still at this `chainRevision`. */
|
|
137
|
+
revision?: number;
|
|
138
|
+
discardEdits: boolean;
|
|
139
|
+
}
|
|
140
|
+
/** The `bir scenario` words this module answers; `list` and `replay` stay in bir.ts. */
|
|
141
|
+
export declare const SCENARIO_EDIT_SUBCOMMANDS: ReadonlySet<string>;
|
|
142
|
+
/** The `bir` MCP server's tools that only read: always offered (D2). */
|
|
143
|
+
export declare const READ_TOOLS: readonly ["scenario_show", "scenario_edits", "investigate"];
|
|
144
|
+
/** The ones that change a scenario: offered only after `bir scenario editing on` (D2). */
|
|
145
|
+
export declare const EDIT_TOOLS: readonly ["scenario_check", "scenario_edit", "scenario_undo"];
|
|
146
|
+
export declare function scenarioEditCommand(args: ScenarioEditArgs, deps: ScenarioEditDeps): Promise<number>;
|
|
147
|
+
/**
|
|
148
|
+
* A logic file's text. UTF-8, with a byte-order mark dropped — and UTF-16 with
|
|
149
|
+
* its mark decoded, because that is what `"…" > step.js` writes in Windows
|
|
150
|
+
* PowerShell 5.1, and a service answering "SyntaxError" to a file that looks
|
|
151
|
+
* fine in every editor is a riddle nobody should have to solve.
|
|
152
|
+
*/
|
|
153
|
+
export declare function decodeLogic(bytes: Buffer): string;
|
|
154
|
+
/**
|
|
155
|
+
* The report in the lines editSteps.md "What a person sees" shows:
|
|
156
|
+
* `input`, `output` (when the output logic changed), `later`, `answer` (when
|
|
157
|
+
* the final answer read anything before) and `mark`.
|
|
158
|
+
*/
|
|
159
|
+
export declare function renderReport(out: (line?: string) => void, r: EditReport): void;
|
|
160
|
+
/**
|
|
161
|
+
* About {@link CONTEXT} characters either side of `at`. A text already that
|
|
162
|
+
* short — a window the service cut itself, or a small call — is printed whole.
|
|
163
|
+
*/
|
|
164
|
+
export declare function around(text: string, at: number): string;
|
|
165
|
+
/**
|
|
166
|
+
* Undo puts one step back as it was before its newest edit (D9). Without
|
|
167
|
+
* `--edit`, that is the newest entry nothing has put back and no
|
|
168
|
+
* recalculation replaced — which is by construction the newest of its step.
|
|
169
|
+
* An undo is itself such an entry, so a second `undo` redoes.
|
|
170
|
+
*/
|
|
171
|
+
export declare function newestUndoable(edits: EditEntry[]): EditEntry | undefined;
|
|
172
|
+
export {};
|
|
173
|
+
//# sourceMappingURL=scenario-edit.d.ts.map
|