@basein/runner 0.2.12 → 0.3.1

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.
Files changed (142) hide show
  1. package/README.md +540 -369
  2. package/dist/auth/client.d.ts +65 -3
  3. package/dist/auth/client.js +305 -53
  4. package/dist/bin/bir-hooks.d.ts +72 -31
  5. package/dist/bin/bir-hooks.js +176 -284
  6. package/dist/bin/bir-proxy.d.ts +17 -2
  7. package/dist/bin/bir-proxy.js +222 -28
  8. package/dist/bin/bir-scenario.d.ts +61 -21
  9. package/dist/bin/bir-scenario.js +593 -122
  10. package/dist/bin/bir.d.ts +12 -6
  11. package/dist/bin/bir.js +2935 -489
  12. package/dist/bin/investigate.js +40 -15
  13. package/dist/bin/scenario-edit.d.ts +7 -1
  14. package/dist/bin/scenario-edit.js +43 -21
  15. package/dist/bin/scenario-liveness.d.ts +194 -0
  16. package/dist/bin/scenario-liveness.js +459 -0
  17. package/dist/bin/scenario-stderr.d.ts +43 -0
  18. package/dist/bin/scenario-stderr.js +76 -0
  19. package/dist/bin/service-read.d.ts +88 -0
  20. package/dist/bin/service-read.js +128 -0
  21. package/dist/bin/setup.d.ts +19 -0
  22. package/dist/bin/setup.js +146 -20
  23. package/dist/config/adapters/claude-code.d.ts +92 -14
  24. package/dist/config/adapters/claude-code.js +291 -101
  25. package/dist/config/adapters/generic.d.ts +4 -1
  26. package/dist/config/adapters/generic.js +13 -14
  27. package/dist/config/generate.d.ts +392 -14
  28. package/dist/config/generate.js +666 -19
  29. package/dist/config/mcp-approval.d.ts +76 -0
  30. package/dist/config/mcp-approval.js +210 -0
  31. package/dist/config/node-path.d.ts +42 -0
  32. package/dist/config/node-path.js +102 -0
  33. package/dist/config/overrides.d.ts +62 -0
  34. package/dist/config/overrides.js +136 -0
  35. package/dist/config/resolve.d.ts +70 -8
  36. package/dist/config/resolve.js +186 -15
  37. package/dist/control/client.d.ts +22 -0
  38. package/dist/control/client.js +26 -7
  39. package/dist/control/correlation.d.ts +23 -5
  40. package/dist/control/correlation.js +0 -0
  41. package/dist/control/daemon.d.ts +400 -18
  42. package/dist/control/daemon.js +1105 -102
  43. package/dist/control/discovery.d.ts +77 -5
  44. package/dist/control/discovery.js +186 -11
  45. package/dist/control/ensure-hook.d.ts +61 -0
  46. package/dist/control/ensure-hook.js +160 -8
  47. package/dist/control/paths.d.ts +26 -0
  48. package/dist/control/paths.js +34 -0
  49. package/dist/control/pin-guard.d.ts +83 -0
  50. package/dist/control/pin-guard.js +534 -0
  51. package/dist/control/recorder-keeper.d.ts +229 -0
  52. package/dist/control/recorder-keeper.js +721 -0
  53. package/dist/control/recorder-main.d.ts +73 -0
  54. package/dist/control/recorder-main.js +778 -0
  55. package/dist/control/server.d.ts +707 -31
  56. package/dist/control/server.js +2787 -302
  57. package/dist/control/transcript.d.ts +21 -1
  58. package/dist/control/transcript.js +378 -112
  59. package/dist/index.d.ts +5 -1
  60. package/dist/index.js +5 -1
  61. package/dist/jsonrpc/framing.d.ts +76 -12
  62. package/dist/jsonrpc/framing.js +216 -59
  63. package/dist/proxy/intercept.d.ts +49 -5
  64. package/dist/proxy/intercept.js +188 -59
  65. package/dist/proxy/relay.d.ts +16 -0
  66. package/dist/proxy/relay.js +77 -5
  67. package/dist/proxy/revive.d.ts +122 -0
  68. package/dist/proxy/revive.js +251 -0
  69. package/dist/proxy/session.d.ts +222 -14
  70. package/dist/proxy/session.js +708 -99
  71. package/dist/record/recorder.d.ts +51 -3
  72. package/dist/record/recorder.js +3 -0
  73. package/dist/record/redact.d.ts +103 -9
  74. package/dist/record/redact.js +659 -30
  75. package/dist/record/remote-recorder.d.ts +327 -32
  76. package/dist/record/remote-recorder.js +1517 -187
  77. package/dist/record/switchable-recorder.d.ts +126 -0
  78. package/dist/record/switchable-recorder.js +351 -0
  79. package/dist/record/truncate.d.ts +40 -1
  80. package/dist/record/truncate.js +111 -4
  81. package/dist/replay/bash-channel.d.ts +35 -0
  82. package/dist/replay/bash-channel.js +133 -0
  83. package/dist/replay/bundle.d.ts +10 -0
  84. package/dist/replay/bundle.js +10 -0
  85. package/dist/replay/controller.d.ts +369 -20
  86. package/dist/replay/controller.js +1176 -107
  87. package/dist/replay/derive.d.ts +1 -0
  88. package/dist/replay/derive.js +81 -24
  89. package/dist/replay/executor.d.ts +51 -16
  90. package/dist/replay/executor.js +114 -41
  91. package/dist/replay/handover.d.ts +54 -1
  92. package/dist/replay/handover.js +55 -5
  93. package/dist/replay/logic.d.ts +62 -10
  94. package/dist/replay/logic.js +140 -22
  95. package/dist/replay/plan.d.ts +201 -27
  96. package/dist/replay/plan.js +581 -141
  97. package/dist/replay/safety.d.ts +72 -0
  98. package/dist/replay/safety.js +303 -0
  99. package/dist/replay/source-run.d.ts +10 -0
  100. package/dist/replay/source-run.js +80 -35
  101. package/dist/replay/targets.d.ts +15 -1
  102. package/dist/replay/targets.js +62 -4
  103. package/dist/replay/tool-error.d.ts +15 -1
  104. package/dist/replay/tool-error.js +33 -1
  105. package/dist/replay/types.d.ts +7 -4
  106. package/dist/upstream/client.d.ts +56 -3
  107. package/dist/upstream/client.js +61 -4
  108. package/dist/upstream/headers.d.ts +43 -0
  109. package/dist/upstream/headers.js +90 -0
  110. package/dist/upstream/http-client.d.ts +213 -22
  111. package/dist/upstream/http-client.js +1034 -168
  112. package/dist/upstream/http-transport.d.ts +143 -0
  113. package/dist/upstream/http-transport.js +391 -0
  114. package/dist/upstream/lazy-client.d.ts +8 -0
  115. package/dist/upstream/lazy-client.js +29 -1
  116. package/dist/upstream/sse.d.ts +78 -0
  117. package/dist/upstream/sse.js +189 -0
  118. package/dist/upstream/stdio-client.d.ts +61 -1
  119. package/dist/upstream/stdio-client.js +356 -33
  120. package/dist/util/atomic-write.d.ts +29 -0
  121. package/dist/util/atomic-write.js +96 -0
  122. package/dist/util/journal.d.ts +15 -0
  123. package/dist/util/journal.js +48 -3
  124. package/dist/util/log.d.ts +10 -0
  125. package/dist/util/log.js +28 -1
  126. package/dist/util/off-switch.d.ts +46 -0
  127. package/dist/util/off-switch.js +91 -0
  128. package/dist/util/service-health.d.ts +133 -0
  129. package/dist/util/service-health.js +217 -0
  130. package/docs/BaseInstRunner.md +694 -621
  131. package/docs/calculatedReplay.md +1625 -1304
  132. package/docs/calculatedReplayGuide.md +1212 -1087
  133. package/docs/installRun.md +1013 -772
  134. package/docs/loginWeb.md +627 -607
  135. package/docs/mcpmark.md +49 -16
  136. package/docs/my-first-sample.md +569 -545
  137. package/docs/quickstart.md +384 -311
  138. package/docs/t-bench.md +406 -394
  139. package/package.json +58 -57
  140. package/production.md +1371 -0
  141. package/scripts/install.ps1 +97 -6
  142. package/scripts/install.sh +104 -7
@@ -0,0 +1,73 @@
1
+ /**
2
+ * recorder-main — the long-running half of `bir-hooks`: the control server
3
+ * that receives Claude Code's hooks and the proxies' step reports.
4
+ *
5
+ * Kept out of `bin/bir-hooks.ts` so the SessionStart hook (`bir-hooks ensure`),
6
+ * which runs on every session start, `/clear` and compaction, never loads the
7
+ * control server, the replay engine or the service client it does not use.
8
+ *
9
+ * THE ORDER OF START-UP IS THE POINT. Claude Code sends every hook of a
10
+ * session to this process's port. Until it listens, each one is refused, and
11
+ * Claude Code shows each refusal as a hook error. So, in order:
12
+ *
13
+ * 1. crash handlers — nothing after this can take the process down;
14
+ * 2. the log, the project's port and token, the journal — local files only;
15
+ * 3. the recorder, decided from disk alone (recorder-keeper.ts) — no network;
16
+ * 4. listen, and write the discovery file;
17
+ * 5. only then, in the background and bounded: refresh the token, check an
18
+ * http address, notice a sign-in appearing — none of it ever delays a hook.
19
+ *
20
+ * It used to sign in (two network calls, no timeouts) between 2 and 4, and a
21
+ * slow service held the port closed for up to five minutes.
22
+ */
23
+ import { ControlServer } from "./server.js";
24
+ /**
25
+ * What a prompt waits for its scenario match by default (`BIR_MATCH_BUDGET_MS`).
26
+ * Past it the prompt goes on without one (K5): a service slower than 3 s must
27
+ * not add that to every prompt.
28
+ */
29
+ export declare const DEFAULT_MATCH_BUDGET_MS = 3000;
30
+ /**
31
+ * `BIR_CORRELATION_DECISION`, passed on only when it was set to `allow` or
32
+ * `ask`. Unset, nothing is passed and the control server decides — and by
33
+ * default (`auto`) it never answers `allow` for an ordinary wrapped call,
34
+ * which skipped the person's permission prompt.
35
+ */
36
+ export declare function correlationDecisionFromEnv(): "allow" | "ask" | undefined;
37
+ /**
38
+ * Which Anthropic key derivation may use, if any.
39
+ *
40
+ * In the background, only one the person set for this purpose. The
41
+ * hook-started recorder has Claude Code's environment, and an API-billed
42
+ * Claude Code carries its `ANTHROPIC_API_KEY` there: picking that up silently
43
+ * billed the person's own key for work the service does for a signed-in
44
+ * runner. It is dropped from this process (replay would otherwise read it
45
+ * from the environment) unless `BIR_USE_ANTHROPIC_API_KEY=1` says to use it.
46
+ *
47
+ * In a terminal (`bir-hooks` run by hand, `daemon` false) the environment is
48
+ * the operator's own, and older guides told them to set exactly this variable
49
+ * to keep derivation on the machine: it is used as it always was.
50
+ */
51
+ export declare function derivationKey(daemon?: boolean): {
52
+ apiKey?: string;
53
+ source?: string;
54
+ };
55
+ /** Where the three replay switches came from, for `/health` and `bir doctor`. */
56
+ export type ReplaySource = "env" | "sidecar" | "default";
57
+ /** What a recorder still serves (K4, `ControlServer.activity()`). */
58
+ export interface RecorderActivity {
59
+ /** Runs opened and not yet sealed. */
60
+ openRuns: number;
61
+ /** Sessions it has not forgotten (see the control server's reaper). */
62
+ knownSessions: number;
63
+ /** Registered proxies whose process is alive: an open window's MCP servers. */
64
+ liveProxyPids: number;
65
+ }
66
+ /**
67
+ * The control server's {@link RecorderActivity}. From its own accessor when it
68
+ * has one; otherwise the same, read from its `/health` body (heavier, and
69
+ * asked once a minute only while superseded).
70
+ */
71
+ export declare function activityOf(server: ControlServer): RecorderActivity;
72
+ export declare function runRecorder(): Promise<void>;
73
+ //# sourceMappingURL=recorder-main.d.ts.map