@bridge4dev/runner 0.13.1 → 0.26.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.
Files changed (49) hide show
  1. package/dist/adapters/claude.d.ts +15 -7
  2. package/dist/adapters/claude.js +1024 -70
  3. package/dist/adapters/codex.d.ts +18 -3
  4. package/dist/adapters/codex.js +224 -65
  5. package/dist/adapters/questions.d.ts +42 -0
  6. package/dist/adapters/questions.js +86 -0
  7. package/dist/adapters/types.d.ts +200 -4
  8. package/dist/attachments.d.ts +8 -1
  9. package/dist/attachments.js +22 -4
  10. package/dist/auth-relay.d.ts +33 -3
  11. package/dist/auth-relay.js +199 -16
  12. package/dist/auto-resume.d.ts +18 -0
  13. package/dist/auto-resume.js +104 -0
  14. package/dist/commit-message.d.ts +51 -0
  15. package/dist/commit-message.js +224 -0
  16. package/dist/config.d.ts +29 -6
  17. package/dist/config.js +15 -0
  18. package/dist/crash-note.d.ts +54 -0
  19. package/dist/crash-note.js +105 -0
  20. package/dist/environment.d.ts +171 -0
  21. package/dist/environment.js +409 -0
  22. package/dist/git.d.ts +81 -0
  23. package/dist/git.js +301 -15
  24. package/dist/gitops.d.ts +489 -12
  25. package/dist/gitops.js +1717 -96
  26. package/dist/index.js +715 -8
  27. package/dist/paths.d.ts +35 -0
  28. package/dist/paths.js +45 -0
  29. package/dist/policy.d.ts +63 -0
  30. package/dist/policy.js +412 -10
  31. package/dist/protocol.d.ts +382 -60
  32. package/dist/protocol.js +104 -1
  33. package/dist/recipe-schema.d.ts +310 -0
  34. package/dist/recipe-schema.js +103 -0
  35. package/dist/recipe.d.ts +94 -0
  36. package/dist/recipe.js +238 -0
  37. package/dist/self-update.d.ts +21 -0
  38. package/dist/self-update.js +73 -1
  39. package/dist/service-unit.d.ts +61 -2
  40. package/dist/service-unit.js +150 -14
  41. package/dist/supervisor.d.ts +108 -1
  42. package/dist/supervisor.js +1045 -57
  43. package/dist/verify-queue.d.ts +17 -0
  44. package/dist/verify-queue.js +100 -0
  45. package/dist/verify.d.ts +203 -0
  46. package/dist/verify.js +788 -0
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +1 -1
package/dist/paths.d.ts CHANGED
@@ -1,7 +1,42 @@
1
1
  export declare function configDir(): string;
2
2
  export declare function stateDir(): string;
3
+ /**
4
+ * Home for systemd USER units. Honours `DEVBRIDGE_RUNNER_HOME` like everything
5
+ * else here: `service-unit.ts` used to reach for `os.homedir()` directly, and the
6
+ * moment it started WRITING (the 0.21.0 limits drop-in) a test run began
7
+ * reconfiguring the developer's own service.
8
+ */
9
+ export declare function systemdUserHome(): string;
3
10
  export declare function configFilePath(): string;
4
11
  export declare function statusFilePath(): string;
5
12
  export declare function journalDir(): string;
6
13
  export declare function worktreesDir(): string;
14
+ /**
15
+ * Project directories this runner has been pointed at.
16
+ *
17
+ * Kept so `devbridge-runner doctor` can check the permissions that actually
18
+ * matter on this machine without being told the paths — the runner learns them
19
+ * from the API (binding a project, starting a session) and the person running
20
+ * doctor may have no idea which directories are bound.
21
+ */
22
+ export declare function knownWorkspacesPath(): string;
23
+ /** Session 14: the single preview checkout per repository. */
24
+ export declare function previewsDir(): string;
25
+ /**
26
+ * Per-session MCP config files (ticket #119).
27
+ *
28
+ * The Agent SDK serialises its `mcpServers` option straight into the CLI's
29
+ * argv (`sdk.mjs`: `H.push("--mcp-config", Re({mcpServers:ke}))`), which put the
30
+ * project's `dbk_…` key in `/proc/<pid>/cmdline` — world-readable, and how the
31
+ * key was found in the first place. The CLI also accepts a PATH there
32
+ * (`--mcp-config <configs...>`: "Load MCP servers from JSON files or strings"),
33
+ * so we write the same JSON to a 0600 file and pass the path instead.
34
+ *
35
+ * The basename is deliberately distinctive rather than just `<sessionId>.json`:
36
+ * `policy.ts` matches it by name in BOTH secret lists, so the guard holds
37
+ * wherever the file ends up — including under a `DEVBRIDGE_RUNNER_HOME`
38
+ * override, where the path carries no `devbridge-runner` segment.
39
+ */
40
+ export declare function mcpConfigDir(): string;
41
+ export declare function mcpConfigPath(sessionId: string): string;
7
42
  //# sourceMappingURL=paths.d.ts.map
package/dist/paths.js CHANGED
@@ -18,6 +18,15 @@ export function stateDir() {
18
18
  const xdg = process.env['XDG_STATE_HOME'] ?? path.join(os.homedir(), '.local', 'state');
19
19
  return path.join(xdg, 'devbridge-runner');
20
20
  }
21
+ /**
22
+ * Home for systemd USER units. Honours `DEVBRIDGE_RUNNER_HOME` like everything
23
+ * else here: `service-unit.ts` used to reach for `os.homedir()` directly, and the
24
+ * moment it started WRITING (the 0.21.0 limits drop-in) a test run began
25
+ * reconfiguring the developer's own service.
26
+ */
27
+ export function systemdUserHome() {
28
+ return baseDir() ?? os.homedir();
29
+ }
21
30
  export function configFilePath() {
22
31
  return path.join(configDir(), 'config.toml');
23
32
  }
@@ -30,4 +39,40 @@ export function journalDir() {
30
39
  export function worktreesDir() {
31
40
  return path.join(stateDir(), 'worktrees');
32
41
  }
42
+ /**
43
+ * Project directories this runner has been pointed at.
44
+ *
45
+ * Kept so `devbridge-runner doctor` can check the permissions that actually
46
+ * matter on this machine without being told the paths — the runner learns them
47
+ * from the API (binding a project, starting a session) and the person running
48
+ * doctor may have no idea which directories are bound.
49
+ */
50
+ export function knownWorkspacesPath() {
51
+ return path.join(stateDir(), 'workspaces.json');
52
+ }
53
+ /** Session 14: the single preview checkout per repository. */
54
+ export function previewsDir() {
55
+ return path.join(stateDir(), 'previews');
56
+ }
57
+ /**
58
+ * Per-session MCP config files (ticket #119).
59
+ *
60
+ * The Agent SDK serialises its `mcpServers` option straight into the CLI's
61
+ * argv (`sdk.mjs`: `H.push("--mcp-config", Re({mcpServers:ke}))`), which put the
62
+ * project's `dbk_…` key in `/proc/<pid>/cmdline` — world-readable, and how the
63
+ * key was found in the first place. The CLI also accepts a PATH there
64
+ * (`--mcp-config <configs...>`: "Load MCP servers from JSON files or strings"),
65
+ * so we write the same JSON to a 0600 file and pass the path instead.
66
+ *
67
+ * The basename is deliberately distinctive rather than just `<sessionId>.json`:
68
+ * `policy.ts` matches it by name in BOTH secret lists, so the guard holds
69
+ * wherever the file ends up — including under a `DEVBRIDGE_RUNNER_HOME`
70
+ * override, where the path carries no `devbridge-runner` segment.
71
+ */
72
+ export function mcpConfigDir() {
73
+ return path.join(stateDir(), 'mcp');
74
+ }
75
+ export function mcpConfigPath(sessionId) {
76
+ return path.join(mcpConfigDir(), `devbridge-mcp.${sessionId}.json`);
77
+ }
33
78
  //# sourceMappingURL=paths.js.map
package/dist/policy.d.ts CHANGED
@@ -3,6 +3,19 @@ export interface PolicyContext {
3
3
  trustMode: TrustMode;
4
4
  /** The session worktree — the only place the agent may write. */
5
5
  worktreePath: string;
6
+ /**
7
+ * May the agent commit on its own? (session 15)
8
+ *
9
+ * `false` is the project setting «I review and commit myself». It was a
10
+ * column, an API field and a switch in the workspace form since session 14 —
11
+ * and nothing ever sent it anywhere, so the switch moved a value that no code
12
+ * read. A control that does nothing is worse than a missing one: somebody
13
+ * turns it off and believes the agent stopped committing.
14
+ *
15
+ * `undefined` means the API did not say, which is every runner-API pair older
16
+ * than this release — and there the answer stays what it has always been.
17
+ */
18
+ agentAutoCommit?: boolean;
6
19
  }
7
20
  export interface PolicyDecision {
8
21
  decision: 'allow' | 'deny' | 'ask';
@@ -13,5 +26,55 @@ export declare function maskString(value: string): string;
13
26
  export declare function maskSecrets<T>(value: T): T;
14
27
  export declare function isSecretPath(p: string): boolean;
15
28
  export declare function isInsideWorktree(p: string, worktreePath: string): boolean;
29
+ /**
30
+ * Anything inside a `.git` directory (session 16, QA-110 B2).
31
+ *
32
+ * This became load-bearing the day DIRECT mode made the repository ROOT the
33
+ * agent's confinement. In a linked worktree the real `.git` lives elsewhere, so
34
+ * «outside the worktree» happened to cover it; in the project folder it sits
35
+ * right there, one level down, and «inside the worktree» happened to allow it.
36
+ *
37
+ * A file in `.git/hooks/` is not data — it is code git runs on the next commit,
38
+ * outside every rule on the Bash denylist, including the `git clean` and
39
+ * `git reset --hard` this same session added to it. `.git/config` is worse: it
40
+ * can set `core.fsmonitor` or a credential helper and run a command on the very
41
+ * next git invocation. Neither is ever ordinary agent work.
42
+ */
43
+ export declare function isGitInternalPath(p: string): boolean;
44
+ export interface RecipeCommandContext {
45
+ /**
46
+ * The docker compose project this preview owns, from `preview.project` in the
47
+ * recipe. Present only for the preview `stop` command.
48
+ */
49
+ dockerProject?: string;
50
+ /** True only for the recipe's own `preview.stop` command. */
51
+ isPreviewStop?: boolean;
52
+ }
53
+ export interface RecipeCommandDecision {
54
+ allowed: boolean;
55
+ reason?: string;
56
+ }
57
+ /**
58
+ * Layer 1 for a command that came out of an APPROVED project recipe.
59
+ *
60
+ * The semantics, fixed here rather than left to be discovered: **an approved
61
+ * recipe does not ask, but it cannot get past the denylist.** Both halves
62
+ * matter and neither is what `evaluateToolUse` would do on its own.
63
+ *
64
+ * - It does not ask, because there is nobody to ask: a build runs for minutes
65
+ * with no agent turn around it, and the human already read every command on
66
+ * the approval screen. Running it through the strict-mode branch would turn
67
+ * `docker compose up --build` — which is not on any safe list — into a
68
+ * permission card nobody can answer.
69
+ * - It cannot get past the denylist, because approval is a statement about a
70
+ * build, not a grant of `sudo`, of the firewall, or of the machine's power
71
+ * switch.
72
+ *
73
+ * One denial is liftable, and only one: `docker … down`. A preview that cannot
74
+ * tear its own stack down leaks containers forever, so a recipe that NAMES its
75
+ * compose project may run `down` on that project in its `stop` command — and
76
+ * nowhere else. Without the name, the refusal stands and says why.
77
+ */
78
+ export declare function evaluateRecipeCommand(command: string, ctx?: RecipeCommandContext): RecipeCommandDecision;
16
79
  export declare function evaluateToolUse(toolName: string, input: Record<string, unknown>, ctx: PolicyContext): PolicyDecision;
17
80
  //# sourceMappingURL=policy.d.ts.map