opencode-swarm 7.144.3 → 7.144.5

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 (127) hide show
  1. package/.opencode/skills/swarm-pr-review/SKILL.md +3 -1
  2. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +28 -0
  3. package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -0
  4. package/README.md +3 -1
  5. package/dist/background/pending-delegations.d.ts +14 -0
  6. package/dist/background/workspace-snapshot.d.ts +7 -0
  7. package/dist/cli/{capability-probe-f1paszww.js → capability-probe-976tt4ba.js} +6 -2
  8. package/dist/cli/{config-doctor-pkr9w2nv.js → config-doctor-m005xfdt.js} +3 -3
  9. package/dist/cli/{core-7pymdx0b.js → core-6vdtfb8s.js} +4 -3
  10. package/dist/cli/{curation-policy-y1pqpztb.js → curation-policy-a511r0qz.js} +6 -6
  11. package/dist/cli/{curator-wbzcjd0q.js → curator-0t87anp5.js} +35 -34
  12. package/dist/cli/{curator-drift-2jbjv03a.js → curator-drift-ckjm272w.js} +2 -2
  13. package/dist/cli/curator-llm-factory-j8tk9rxm.js +63 -0
  14. package/dist/cli/{dispatch-1y1rnv1h.js → dispatch-ndxbsk98.js} +2 -2
  15. package/dist/cli/{evidence-summary-service-rcgrdm52.js → evidence-summary-service-c22gahjc.js} +15 -14
  16. package/dist/cli/{gate-evidence-jmzctnhg.js → gate-evidence-hh8kc9wt.js} +9 -8
  17. package/dist/cli/guardrail-explain-9gjw2dsd.js +64 -0
  18. package/dist/cli/{guardrail-log-k1s9xf3h.js → guardrail-log-ejf5zjac.js} +5 -5
  19. package/dist/cli/{hive-promoter-vcj5h0e3.js → hive-promoter-gkbfpdtv.js} +35 -34
  20. package/dist/cli/{index-s2rcz51a.js → index-1jsmmx7y.js} +66 -34
  21. package/dist/cli/{index-qj22wyw2.js → index-1pxqkvvq.js} +3 -3
  22. package/dist/cli/{index-p863y7xx.js → index-3qdzpv91.js} +1 -1
  23. package/dist/cli/{index-8hkjk37c.js → index-58cvm3dw.js} +36 -1
  24. package/dist/cli/{index-ghzvxj3g.js → index-5wenr2vs.js} +40 -37
  25. package/dist/cli/{index-wck434f8.js → index-63tgh0cn.js} +15 -4
  26. package/dist/cli/{index-xwpmxpb7.js → index-641yjpk8.js} +6 -6
  27. package/dist/cli/{index-zwrqe065.js → index-6z5jtf7d.js} +2 -2
  28. package/dist/cli/{index-j6mfyy0a.js → index-7e4q41nb.js} +3 -3
  29. package/dist/cli/{index-6s2q144w.js → index-855hseq4.js} +43 -22
  30. package/dist/cli/index-9e6fdz2h.js +282 -0
  31. package/dist/cli/{index-zswmbm15.js → index-9s8drsf9.js} +2 -2
  32. package/dist/cli/{index-x68tw7v3.js → index-a1hxejxc.js} +168 -36
  33. package/dist/cli/{index-b6e016tv.js → index-abtrcs16.js} +1 -1
  34. package/dist/cli/{index-8fwhhayc.js → index-b44qqqt2.js} +27 -18
  35. package/dist/cli/{index-k3cxyk66.js → index-cwtpqm5f.js} +1 -1
  36. package/dist/cli/{index-2en8s72h.js → index-dc04v786.js} +30 -2
  37. package/dist/cli/{index-7554tecy.js → index-dtbzyr3s.js} +2 -2
  38. package/dist/cli/{index-eya357bk.js → index-ea09xax6.js} +5 -5
  39. package/dist/cli/{index-74hpm6sh.js → index-f36ybbsv.js} +12 -6
  40. package/dist/cli/{index-wd24zn2e.js → index-f9vvg5xb.js} +1 -1
  41. package/dist/cli/{index-rn0eq85g.js → index-fv0s19g9.js} +1 -1
  42. package/dist/cli/{index-ep14xc5z.js → index-fv2pzwnp.js} +6 -5
  43. package/dist/cli/{index-dpfphnmy.js → index-h1p08s3n.js} +1 -1
  44. package/dist/cli/{index-584grrwn.js → index-hkdgkkhb.js} +2 -2
  45. package/dist/cli/{index-1brb14xc.js → index-kdak6s63.js} +12 -6
  46. package/dist/cli/{index-satc0vs6.js → index-kh0jt9pg.js} +300 -1181
  47. package/dist/cli/{index-p7hbphaq.js → index-mkmcz6x8.js} +4 -4
  48. package/dist/cli/{index-krxcxkdq.js → index-n4hwcsbd.js} +20 -5
  49. package/dist/cli/{index-06cn7haa.js → index-rdgtfj74.js} +2 -2
  50. package/dist/cli/{index-b227mpnk.js → index-rnyt30tm.js} +4 -4
  51. package/dist/cli/{index-whezv7vc.js → index-v3y3qg48.js} +1 -1
  52. package/dist/cli/{index-0fgwdtvp.js → index-vdha477y.js} +1 -1
  53. package/dist/cli/{index-pr8vhj6j.js → index-wbrqvm2g.js} +8 -8
  54. package/dist/cli/{index-8214dd7j.js → index-wknz5c8q.js} +2 -2
  55. package/dist/cli/{index-pag8nsb1.js → index-wm6f7t7w.js} +3 -3
  56. package/dist/cli/{index-247wf23m.js → index-wmsehjq6.js} +2847 -1791
  57. package/dist/cli/{index-4nt52yr9.js → index-zj6t9zgx.js} +173 -25
  58. package/dist/cli/index-zy7f84cs.js +1210 -0
  59. package/dist/cli/index.d.ts +11 -1
  60. package/dist/cli/index.js +64 -42
  61. package/dist/cli/{knowledge-escalator-x6jrcrwj.js → knowledge-escalator-1d79m1tr.js} +14 -13
  62. package/dist/cli/{knowledge-events-aw22r72m.js → knowledge-events-ces29ncg.js} +12 -11
  63. package/dist/cli/{knowledge-link-bntppte4.js → knowledge-link-4cg4776a.js} +5 -5
  64. package/dist/cli/{knowledge-store-19xg1rw1.js → knowledge-store-pe8webc2.js} +6 -6
  65. package/dist/cli/{knowledge-validator-8wh82z0a.js → knowledge-validator-4yjf1f7k.js} +8 -8
  66. package/dist/cli/{pending-delegations-1y303j3k.js → pending-delegations-9h1jmtw1.js} +5 -5
  67. package/dist/cli/{pr-subscriptions-wvd041rp.js → pr-subscriptions-8pg34pev.js} +5 -5
  68. package/dist/cli/{runner-jn55k8xb.js → runner-cqecp1na.js} +6 -6
  69. package/dist/cli/{scan-cursor-429r5db9.js → scan-cursor-d6exjmqj.js} +9 -7
  70. package/dist/cli/{schema-jdwjcby0.js → schema-2esybebd.js} +4 -2
  71. package/dist/cli/{scope-persistence-s0s1bz15.js → scope-persistence-ej59x0yc.js} +9 -8
  72. package/dist/cli/{skill-generator-ffbj0ye5.js → skill-generator-yqta3yrg.js} +16 -15
  73. package/dist/cli/{telemetry-xyfb5vm8.js → telemetry-cybx6cfz.js} +1 -1
  74. package/dist/cli/{workspace-snapshot-w3tg4ne5.js → workspace-snapshot-d89zm6wm.js} +5 -2
  75. package/dist/cli/{worktree-collision-ownership-z5ftwjz3.js → worktree-collision-ownership-vy0kxa98.js} +28 -21
  76. package/dist/cli/{worktree-isolation-y2p93438.js → worktree-isolation-rwq0kke7.js} +35 -34
  77. package/dist/cli/{worktree-provisioning-owner-g24xd417.js → worktree-provisioning-owner-zzkjycp1.js} +3 -3
  78. package/dist/commands/ci-simulate.d.ts +2 -0
  79. package/dist/commands/index.d.ts +1 -0
  80. package/dist/commands/recover.d.ts +17 -0
  81. package/dist/commands/registry.d.ts +9 -1
  82. package/dist/commands/reset-session.d.ts +2 -0
  83. package/dist/config/cache-paths.d.ts +57 -0
  84. package/dist/config/evidence-schema.d.ts +3 -3
  85. package/dist/config/schema.d.ts +9 -0
  86. package/dist/git/branch.d.ts +2 -0
  87. package/dist/git/pr.d.ts +2 -0
  88. package/dist/hooks/context-budget.d.ts +4 -0
  89. package/dist/hooks/context-usage.d.ts +48 -0
  90. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +7 -0
  91. package/dist/hooks/diff-scope.d.ts +7 -0
  92. package/dist/hooks/pr-workflow-gate.d.ts +29 -2
  93. package/dist/hooks/review-receipt-scope.d.ts +7 -0
  94. package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -0
  95. package/dist/hooks/semantic-diff-injection.d.ts +8 -0
  96. package/dist/index.js +607 -591
  97. package/dist/mutation/engine.d.ts +11 -0
  98. package/dist/observability/catalog.d.ts +8 -6
  99. package/dist/review/diff-source.d.ts +2 -0
  100. package/dist/sandbox/capability-probe.d.ts +22 -0
  101. package/dist/sandbox/executor.d.ts +15 -0
  102. package/dist/sandbox/linux/bubblewrap-executor.d.ts +6 -0
  103. package/dist/sandbox/macos/sandbox-exec-executor.d.ts +41 -0
  104. package/dist/sast/semgrep.d.ts +3 -2
  105. package/dist/telemetry.d.ts +17 -1
  106. package/dist/tools/checkpoint.d.ts +11 -0
  107. package/dist/tools/complexity-hotspots.d.ts +15 -0
  108. package/dist/tools/context-status.d.ts +9 -3
  109. package/dist/tools/diff-summary.d.ts +12 -0
  110. package/dist/tools/dispatch-lanes.d.ts +35 -2
  111. package/dist/tools/gh-evidence.d.ts +17 -1
  112. package/dist/tools/knowledge-receipt.d.ts +1 -1
  113. package/dist/tools/pkg-audit.d.ts +13 -0
  114. package/dist/tools/pre-check-batch.d.ts +9 -0
  115. package/dist/tools/prepare-pr-workflow-checkout.d.ts +1 -0
  116. package/dist/tools/sast-scan.d.ts +3 -0
  117. package/dist/utils/bun-compat.d.ts +80 -3
  118. package/dist/utils/git-binary-missing-error.d.ts +80 -2
  119. package/dist/utils/git-executable.d.ts +179 -0
  120. package/dist/utils/gitignore-warning.d.ts +10 -0
  121. package/dist/workflow/coder-settlement.d.ts +92 -0
  122. package/dist/worktree/core.d.ts +8 -0
  123. package/dist/worktree/merge.d.ts +33 -0
  124. package/package.json +3 -2
  125. package/dist/cli/curator-llm-factory-7are9wjh.js +0 -62
  126. package/dist/cli/guardrail-explain-brgw4sve.js +0 -63
  127. package/dist/cli/index-q1exe2b3.js +0 -256
@@ -1,5 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { resolveExecutableFromPath, runExternalTool } from '../utils/external-tool-runner.js';
3
+ import { resolveGitExecutable } from '../utils/git-executable.js';
3
4
  export type MutationOutcome = 'killed' | 'survived' | 'timeout' | 'cancelled' | 'error' | 'equivalent' | 'skipped';
4
5
  /**
5
6
  * Known test runner executables permitted as the first element of testCommand.
@@ -84,6 +85,16 @@ export declare const _internals: {
84
85
  runCommand: MutationCommandRunner;
85
86
  runExternalTool: typeof runExternalTool;
86
87
  resolveExecutableFromPath: typeof resolveExecutableFromPath;
88
+ /**
89
+ * Test seam for git binary resolution (issue #2236 hardening, lane C1b) —
90
+ * used ONLY by the two `executable: 'git'` sites in `executeMutation`
91
+ * (apply / revert). Deliberately NOT used by `runMutationCommand`'s
92
+ * caller-supplied `args.executable` path (see the doc comment above
93
+ * `runMutationCommand`) — that path stays on `resolveExecutableFromPath`
94
+ * so the friendly "git is not installed" message (keyed on
95
+ * `args.executable === 'git'`) keeps working for `git`-flavored callers.
96
+ */
97
+ resolveGitExecutable: typeof resolveGitExecutable;
87
98
  };
88
99
  export declare function executeMutation(patch: MutationPatch, testCommand: string[], testFiles: string[], workingDir: string, options?: MutationExecutionOptions): Promise<MutationResult>;
89
100
  export declare function computeReport(results: MutationResult[], durationMs: number, budgetMs?: number): MutationReport;
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * The event catalog (issue #2029).
3
3
  *
4
- * Exactly 42 entries, matching the `TelemetryEvent` union at
5
- * `src/telemetry.ts:15-91`. Thirty-eight predate the #2029 contract; the 39th is
4
+ * Exactly 43 entries, matching the `TelemetryEvent` union at
5
+ * `src/telemetry.ts:15-92`. Thirty-eight predate the #2029 contract; the 39th is
6
6
  * `agent_conflict_detected` (previously emitted through a force-cast past the
7
- * type system), and the 40th is `close_archive_result` (issue #2030 — the
8
- * structured close/archive result event). The 41st is the bounded diagnostic
7
+ * type system), the 40th is `close_archive_result` (issue #2030 — the
8
+ * structured close/archive result event), the 41st is the bounded diagnostic
9
9
  * projection of authoritative knowledge-receipt transitions (issue #2031).
10
- * These late additions are instances of
10
+ * The 42nd is the human-only `knowledge_maintenance` quarantine audit
11
+ * (issue #2033), and the 43rd is the aggregate `context_pruned` transcript
12
+ * mutation audit. These late additions are instances of
11
13
  * the defect class this contract exists to close: an event kind entering the
12
14
  * stream with no registration.
13
15
  *
@@ -62,7 +64,7 @@ export interface CatalogEntry {
62
64
  /**
63
65
  * Whether an event of this kind must carry `trace.parentSpanId`.
64
66
  *
65
- * `false` for all 42 entries today, and that is a truthful statement about
67
+ * `false` for all 43 entries today, and that is a truthful statement about
66
68
  * the current system rather than a placeholder: no producer supplies a
67
69
  * parent span, so `createObservation` never sets one. Setting this to `true`
68
70
  * for a kind whose producer cannot supply a parent would make every
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import * as fs from 'node:fs';
10
10
  import { bunSpawn } from '../utils/bun-compat.js';
11
+ import { resolveGitExecutableAsync } from '../utils/git-executable.js';
11
12
  export interface InclusiveLineRange {
12
13
  start: number;
13
14
  end: number;
@@ -130,5 +131,6 @@ export declare const _internals: {
130
131
  fstatBigIntSync: (fd: number) => fs.BigIntStats;
131
132
  readSync: typeof fs.readSync;
132
133
  closeSync: typeof fs.closeSync;
134
+ resolveGitExecutable: typeof resolveGitExecutableAsync;
133
135
  };
134
136
  export {};
@@ -36,6 +36,27 @@ export interface SandboxCapability {
36
36
  /** Error message from the probe, if any. */
37
37
  error?: string;
38
38
  }
39
+ /** Reset the session-lifetime capability cache. Test-only. */
40
+ export declare function _resetCapabilityCache(): void;
41
+ /**
42
+ * Wraps a probe command in an AbortController timeout.
43
+ *
44
+ * @param cmd Command binary to run.
45
+ * @param args Arguments to pass.
46
+ * @param ms Timeout in milliseconds.
47
+ * @returns A promise that resolves to the captured stdout string, or rejects on timeout / error.
48
+ */
49
+ declare function withProbeTimeout(cmd: string, args: string[], ms: number): Promise<string>;
50
+ /**
51
+ * DI seam for testability. Exposes withProbeTimeout so tests can simulate
52
+ * exit-0/exit-nonzero/ENOENT probe outcomes for every platform's probe
53
+ * (including darwin) without requiring the real binary on the host running
54
+ * the tests. See src/sandbox/macos/sandbox-exec-executor.ts's _internals for
55
+ * the sibling sync-probe seam.
56
+ */
57
+ export declare const _internals: {
58
+ withProbeTimeout: typeof withProbeTimeout;
59
+ };
39
60
  /**
40
61
  * Detects the availability of OS-native sandbox mechanisms.
41
62
  *
@@ -67,3 +88,4 @@ export declare class SandboxCapabilityProbe {
67
88
  */
68
89
  detect(): Promise<SandboxCapability>;
69
90
  }
91
+ export {};
@@ -54,6 +54,21 @@ export interface SandboxExecutor {
54
54
  * failures on platforms where they don't exist.
55
55
  */
56
56
  export declare function getExecutor(): Promise<SandboxExecutor | null>;
57
+ /**
58
+ * Set whether the macOS sandbox-exec mechanism may be activated. Called
59
+ * once from `createToolBeforeHandler` (src/hooks/guardrails/tool-before.ts)
60
+ * using the already-resolved `GuardrailsConfig`, at guardrails hook
61
+ * registration — which runs at plugin init, before the first bash tool call
62
+ * can trigger `getExecutor()`. When false (the default), `getExecutor()`
63
+ * behaves exactly as it did before F6: it resolves to `null` and every
64
+ * consumer (tool-before's `applySandboxExecution`, `diagnose-service`,
65
+ * guardrails/index) observes the identical fail-open "executor not
66
+ * available" state, so activation stays byte-identical to today until this
67
+ * is explicitly turned on.
68
+ */
69
+ export declare function setMacOSSandboxPolicy(enabled: boolean): void;
70
+ /** @internal test seam — read the current policy without going through config. */
71
+ export declare function _getMacOSSandboxPolicyForTest(): boolean;
57
72
  /**
58
73
  * Reset the cached executor — useful for testing.
59
74
  * @internal
@@ -7,6 +7,11 @@
7
7
  * for defense-in-depth within the user namespace.
8
8
  */
9
9
  import { type SandboxExecutor } from '../executor';
10
+ /**
11
+ * Resolve the bwrap binary: absolute base-OS path when present, bare-name
12
+ * (PATH resolution) fallback otherwise. Never throws.
13
+ */
14
+ declare function resolveBwrapBinary(): string;
10
15
  /**
11
16
  * Check whether the bwrap binary is present on PATH.
12
17
  * Uses spawnSync to probe synchronously without throwing.
@@ -20,6 +25,7 @@ declare function probeBwrap(): boolean;
20
25
  */
21
26
  export declare const _internals: {
22
27
  probeBwrap: typeof probeBwrap;
28
+ resolveBwrapBinary: typeof resolveBwrapBinary;
23
29
  };
24
30
  /**
25
31
  * Linux Bubblewrap sandbox executor.
@@ -11,19 +11,60 @@
11
11
  * - Read-write access to each scope path and the temp directory
12
12
  * - All other file writes are denied
13
13
  */
14
+ import { spawnSync } from 'node:child_process';
15
+ import { existsSync } from 'node:fs';
14
16
  import { type SandboxExecutor } from '../executor';
17
+ /** Resolve the sandbox-exec binary: absolute base-OS path, bare-name fallback. */
18
+ declare function resolveSandboxExecBinary(): string;
19
+ /** Resolve the probe's target command: absolute base-OS path, bare-name fallback. */
20
+ declare function resolveProbeTargetBinary(): string;
21
+ /**
22
+ * Build the SBPL profile used ONLY for availability probing.
23
+ *
24
+ * F6a item 2 (issue #2236): this deliberately shares the same primitives and
25
+ * ordering as buildSandboxProfile's production profile — a blanket
26
+ * `(deny file-write*)` followed by a scoped `(allow file-write* (subpath …))`,
27
+ * plus a `(setenv …)`/`(unsetenv …)` pair (F6b) — so that probe success
28
+ * implies the production profile's primitives actually parse under this
29
+ * host's sandbox-exec. A trivial `(allow default)`-only probe would pass
30
+ * even when the production profile is unparseable, which is the exact
31
+ * probe-passes/production-fails failure mode this guards against.
32
+ */
33
+ declare function buildProbeProfile(tempDir: string): string;
15
34
  /**
16
35
  * Check whether the sandbox-exec binary is present and functional.
17
36
  * Uses spawnSync to probe synchronously without throwing.
37
+ *
38
+ * F6 (issue #2236 RC2): sandbox-exec(8) has NO `--version` flag — its
39
+ * synopsis is `sandbox-exec [-f file | -n name | -p string] [-D k=v]
40
+ * command [args...]` (BSD getopt, short options only). The previous probe
41
+ * invoked `sandbox-exec --version`, which is consumed as an invalid option
42
+ * and fails on EVERY macOS host regardless of whether Seatbelt actually
43
+ * works. The corrected probe runs a real invocation
44
+ * (`sandbox-exec -p <profile> <target>`) and gates on **exit code 0 ONLY**.
45
+ * stderr is deliberately never consulted — modern macOS prints a
46
+ * deprecation notice to stderr on every sandbox-exec call, and that is not
47
+ * a failure. Empty stdout with exit 0 IS success (sandbox-exec prints
48
+ * nothing on a clean run of `true`).
18
49
  */
19
50
  declare function probeSandboxExec(): boolean;
51
+ declare function probeSandboxExecMemoized(): boolean;
52
+ /** Clear the probe memo. Test-only — production never needs to reset it mid-process. */
53
+ declare function resetProbeMemo(): void;
20
54
  /**
21
55
  * DI seam for testability. Exposes probeSandboxExec so tests can simulate
22
56
  * ENOENT / EACCES / ENOSPC error conditions without requiring a real sandbox-exec binary.
23
57
  */
24
58
  export declare const _internals: {
25
59
  probeSandboxExec: typeof probeSandboxExec;
60
+ probeSandboxExecMemoized: typeof probeSandboxExecMemoized;
61
+ resetProbeMemo: typeof resetProbeMemo;
26
62
  buildSandboxProfile: typeof buildSandboxProfile;
63
+ buildProbeProfile: typeof buildProbeProfile;
64
+ resolveSandboxExecBinary: typeof resolveSandboxExecBinary;
65
+ resolveProbeTargetBinary: typeof resolveProbeTargetBinary;
66
+ exists: typeof existsSync;
67
+ spawnSync: typeof spawnSync;
27
68
  };
28
69
  /**
29
70
  * Build a sandbox-exec profile string for the given scope paths, temp dir, and optional env overrides.
@@ -16,13 +16,12 @@ export interface SemgrepOptions {
16
16
  timeoutMs?: number;
17
17
  /** Working directory for Semgrep execution */
18
18
  cwd?: string;
19
- /** Language identifier for --lang flag (used with useAutoConfig) */
20
- lang?: string;
21
19
  /** When true, use --config auto instead of local rulesDir (for profile-driven languages) */
22
20
  useAutoConfig?: boolean;
23
21
  /** Host/tool cancellation propagated to the shared subprocess runner. */
24
22
  abortSignal?: AbortSignal;
25
23
  }
24
+ export type SemgrepFailureKind = 'process_exit' | 'timeout' | 'cancelled' | 'output_limit' | 'spawn_error' | 'invalid_output' | 'scan_error' | 'unexpected';
26
25
  /**
27
26
  * Result from Semgrep execution
28
27
  */
@@ -33,6 +32,8 @@ export interface SemgrepResult {
33
32
  findings: SastFinding[];
34
33
  /** Error message if Semgrep failed */
35
34
  error?: string;
35
+ /** Machine-readable category for an available scanner failure. */
36
+ failure_kind?: SemgrepFailureKind;
36
37
  /** Engine label for the findings */
37
38
  engine: 'tier_a' | 'tier_a+tier_b';
38
39
  }
@@ -1,6 +1,6 @@
1
1
  import { createObservation, toLegacyTelemetryLine } from './observability/index.js';
2
2
  import type { DelegationCostFields } from './services/cost-accounting.js';
3
- export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'reviewer_gate_decision' | 'phase_changed' | 'budget_updated' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'no_op_strong_warning' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'gate_denial_loop'
3
+ export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'reviewer_gate_decision' | 'phase_changed' | 'budget_updated' | 'context_pruned' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'no_op_strong_warning' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'gate_denial_loop'
4
4
  /**
5
5
  * Issue #2063 B5 — an ARMED execution episode reached the advisory rung:
6
6
  * `execution_stall_warn_calls` tool calls with no delegation completion, no
@@ -116,6 +116,22 @@ export declare const telemetry: {
116
116
  reviewerGateDecision(sessionId: string, taskId: string, blocked: boolean, reasonCode: ReviewerGateReasonCode, evidenceKind: ReviewerGateEvidenceKind): void;
117
117
  phaseChanged(sessionId: string, oldPhase: number, newPhase: number): void;
118
118
  budgetUpdated(sessionId: string, budgetPct: number, agentName: string): void;
119
+ contextPruned(data: {
120
+ sessionId: string;
121
+ agentName: string;
122
+ trigger: "agent_switch" | "critical_threshold";
123
+ usageSource: "provider" | "estimated";
124
+ beforeTokens: number;
125
+ afterTokens: number;
126
+ modelLimit: number;
127
+ maskedMessages: number;
128
+ maskedToolParts: number;
129
+ maskedTokensFreed: number;
130
+ prunedMessages: number;
131
+ prunedTextParts: number;
132
+ prunedToolParts: number;
133
+ prunedTokensFreed: number;
134
+ }): void;
119
135
  modelFallback(sessionId: string, agentName: string, fromModel: string, toModel: string, reason: string): void;
120
136
  hardLimitHit(sessionId: string, agentName: string, limitType: string, value: number): void;
121
137
  revisionLimitHit(sessionId: string, agentName: string): void;
@@ -1,6 +1,7 @@
1
1
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
2
2
  import { tryAcquireLock } from '../parallel/file-locks.js';
3
3
  import { loadPlan } from '../plan/manager.js';
4
+ import { resolveGitExecutable } from '../utils/git-executable.js';
4
5
  export declare const _internals: {
5
6
  tryAcquireLock: typeof tryAcquireLock;
6
7
  loadPlan: typeof loadPlan;
@@ -9,6 +10,16 @@ export declare const _internals: {
9
10
  findCommitByExactSubject: typeof findCommitByExactSubject;
10
11
  stageAllExcludingSwarm: typeof stageAllExcludingSwarm;
11
12
  afterTaskEligibilityRead?: (directory: string, taskId: string) => Promise<void>;
13
+ /**
14
+ * Issue #2236 hardening (F1/F4/F5) — resolves the absolute git executable
15
+ * path instead of spawning the bare `'git'` name. Exposed for test
16
+ * injection (mirrors `src/git/branch.ts`'s `_internals.resolveGitExecutable`
17
+ * convention) so a test that mocks `node:child_process` wholesale to drive
18
+ * `gitExec`'s retry/classification logic can stub a fixed value instead of
19
+ * having the real candidate-probing loop consume the same mocked
20
+ * `spawnSync` call slots the test is asserting on.
21
+ */
22
+ resolveGitExecutable: typeof resolveGitExecutable;
12
23
  };
13
24
  declare function stageAllExcludingSwarm(directory: string): void;
14
25
  declare function gitExec(args: string[], cwd: string): string;
@@ -1,2 +1,17 @@
1
1
  import type { tool } from '@opencode-ai/plugin';
2
+ import { bunSpawn } from '../utils/bun-compat';
3
+ import { resolveGitExecutable } from '../utils/git-executable.js';
4
+ /**
5
+ * Test-only seam for the `bunSpawn` call this file makes. Lets tests inject a
6
+ * synthetic subprocess (e.g. one with `spawnError` set) without monkey-patching
7
+ * the `Bun.spawn` global — see #2236 Sweep A, FIX 1.
8
+ *
9
+ * `resolveGitExecutable` (issue #2236 hardening, F1/F4/F5) resolves the
10
+ * absolute git executable path instead of spawning the bare `'git'` name;
11
+ * exposed here so tests can inject a deterministic value.
12
+ */
13
+ export declare const _internals: {
14
+ bunSpawn: typeof bunSpawn;
15
+ resolveGitExecutable: typeof resolveGitExecutable;
16
+ };
2
17
  export declare const complexity_hotspots: ReturnType<typeof tool>;
@@ -2,7 +2,9 @@
2
2
  * Context Status Tool
3
3
  *
4
4
  * Read-only tool that reports current context-window headroom for the active
5
- * session. Derives messages from the runtime session context (via
5
+ * session. Returns both the measured usage and the `usageSource`
6
+ * (`provider` prompt accounting when available, otherwise `estimated`).
7
+ * Derives messages from the runtime session context (via
6
8
  * `swarmState.opencodeClient.session.messages`) and resolves thresholds from
7
9
  * the plugin config, mirroring the active `createContextBudgetHandler` hook's
8
10
  * behavior exactly — including strict `>` boundary semantics (exact threshold
@@ -12,6 +14,7 @@
12
14
  * Works whether `context_budget.enabled` is true or false.
13
15
  */
14
16
  import { loadPluginConfig } from '../config';
17
+ import { type ContextUsageSource } from '../hooks/context-usage';
15
18
  import { createSwarmTool } from './create-tool';
16
19
  /**
17
20
  * Shape of a message's info block.
@@ -47,8 +50,10 @@ export interface ContextMessage {
47
50
  * Result returned by the context_status tool.
48
51
  */
49
52
  export interface ContextStatusResult {
50
- /** Estimated tokens used across all text parts in the session */
53
+ /** Provider-accounted or estimated tokens used across the session */
51
54
  tokensUsed: number;
55
+ /** Whether usage came from provider prompt accounting or a bounded estimate */
56
+ usageSource: ContextUsageSource;
52
57
  /** Resolved model context limit in tokens */
53
58
  modelLimit: number;
54
59
  /** Ratio of tokens-used to model-limit (0.0 – 1.0+) */
@@ -101,7 +106,8 @@ declare function computeContextHeadroom(messages: ContextMessage[], warnThreshol
101
106
  *
102
107
  * No arguments required — the tool queries current state automatically.
103
108
  *
104
- * Returns JSON string with tokensUsed, modelLimit, usagePercent, thresholdCrossed, modelId, provider.
109
+ * Returns JSON with tokensUsed, usageSource, modelLimit, usagePercent,
110
+ * thresholdCrossed, modelId, and provider.
105
111
  */
106
112
  export { computeContextHeadroom };
107
113
  export declare const context_status: ReturnType<typeof createSwarmTool>;
@@ -1,5 +1,16 @@
1
+ import * as child_process from 'node:child_process';
1
2
  import { type ChangeCategory, type RiskLevel } from '../diff/semantic-classifier.js';
3
+ import { resolveGitExecutableAsync } from '../utils/git-executable.js';
2
4
  import { createSwarmTool } from './create-tool';
5
+ export declare const _internals: {
6
+ execFile: typeof child_process.execFile;
7
+ resolveGitExecutableAsync: typeof resolveGitExecutableAsync;
8
+ execGit: typeof execGit;
9
+ };
10
+ declare function execGit(workingDir: string, args: string[], options?: {
11
+ timeout?: number;
12
+ maxBuffer?: number;
13
+ }): Promise<string>;
3
14
  export interface DiffSummaryArgs {
4
15
  files: string[];
5
16
  classification?: ChangeCategory;
@@ -10,3 +21,4 @@ export interface DiffSummaryArgs {
10
21
  * to produce a filtered SemanticDiffSummary.
11
22
  */
12
23
  export declare const diff_summary: ReturnType<typeof createSwarmTool>;
24
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { type BackgroundDelegationRecord } from '../background/pending-delegations.js';
2
+ import { type BackgroundDelegationRecord, type BackgroundDelegationWorkflowLaneRecovery } from '../background/pending-delegations.js';
3
3
  import { resolveExactMergeBaseAsync, resolvePrWorkflowRevisionDigestAsync } from '../background/workspace-snapshot.js';
4
- import { type PrReviewDepthTier } from '../hooks/pr-workflow-gate.js';
4
+ import { type PrReviewDepthTier, validatePrWorkflowTransportRecovery } from '../hooks/pr-workflow-gate.js';
5
5
  import { buildLaneOrientationBlock } from '../hooks/repo-graph-injection.js';
6
6
  import { createParallelDispatcher } from '../parallel/dispatcher/parallel-dispatcher.js';
7
7
  import { createSwarmTool } from './create-tool.js';
@@ -126,6 +126,12 @@ export interface DispatchLaneResult {
126
126
  output_artifact_error?: string;
127
127
  transcript_incomplete?: boolean;
128
128
  message_count?: number;
129
+ salvaged_workflow_lanes?: string[];
130
+ salvaged_workflow_lane_recoveries?: Array<{
131
+ workflow_lane: string;
132
+ kind: BackgroundDelegationWorkflowLaneRecovery['kind'];
133
+ reason: string;
134
+ }>;
129
135
  /**
130
136
  * Set to true when this lane's `output` preview was withheld because an
131
137
  * identical preview (same batch, lane, and result digest) was already
@@ -251,6 +257,11 @@ export interface SessionOps {
251
257
  data?: Array<{
252
258
  info?: {
253
259
  role?: string;
260
+ time?: {
261
+ completed?: number;
262
+ };
263
+ finish?: string;
264
+ error?: unknown;
254
265
  };
255
266
  parts?: Array<{
256
267
  type: string;
@@ -286,6 +297,7 @@ export declare const _internals: {
286
297
  createParallelDispatcher: typeof createParallelDispatcher;
287
298
  resolvePrWorkflowRevisionDigestAsync: typeof resolvePrWorkflowRevisionDigestAsync;
288
299
  resolveExactMergeBaseAsync: typeof resolveExactMergeBaseAsync;
300
+ validatePrWorkflowTransportRecovery: typeof validatePrWorkflowTransportRecovery;
289
301
  now: () => number;
290
302
  sleep: (ms: number) => Promise<void>;
291
303
  };
@@ -302,6 +314,7 @@ export declare const _test_exports: {
302
314
  formatError: typeof formatError;
303
315
  nextCollectPollInterval: typeof nextCollectPollInterval;
304
316
  promptHash: typeof promptHash;
317
+ reserveCollectionLaneCallBudgets: typeof reserveCollectionLaneCallBudgets;
305
318
  isRetryableSessionCreateFailure: typeof isRetryableSessionCreateFailure;
306
319
  DispatchLanesArgsSchema: z.ZodObject<{
307
320
  lanes: z.ZodArray<z.ZodObject<{
@@ -386,6 +399,7 @@ export declare const _test_exports: {
386
399
  */
387
400
  resetDeliveredLaneOutputs: () => void;
388
401
  recordToLaneResult: typeof recordToLaneResult;
402
+ prReviewLaneResponseBudgetChars: typeof prReviewLaneResponseBudgetChars;
389
403
  };
390
404
  type ReadOnlyToolPermissions = Record<string, false> & {
391
405
  write: false;
@@ -403,6 +417,11 @@ declare function isRetryableSessionCreateFailure(error: unknown): boolean;
403
417
  declare function extractAssistantTranscript(messages: Array<{
404
418
  info?: {
405
419
  role?: string;
420
+ time?: {
421
+ completed?: number;
422
+ };
423
+ finish?: string;
424
+ error?: unknown;
406
425
  };
407
426
  parts?: Array<{
408
427
  type: string;
@@ -412,6 +431,13 @@ declare function extractAssistantTranscript(messages: Array<{
412
431
  text: string;
413
432
  messageCount: number;
414
433
  transcriptIncomplete: boolean;
434
+ terminalAssistantProof: boolean;
435
+ };
436
+ declare function reserveCollectionLaneCallBudgets(deadline: number, remainingLaneCount: number, hasStatusCall: boolean, hasRevisionDigestCall?: boolean): {
437
+ laneBudgetMs: number;
438
+ statusBudgetMs: number;
439
+ messagesBudgetMs: number;
440
+ revisionDigestBudgetMs: number;
415
441
  };
416
442
  declare function nextCollectPollInterval(currentMs: number): number;
417
443
  declare function buildCollectResult(batchId: string, records: BackgroundDelegationRecord[], includePending: boolean, deliveryContext?: {
@@ -472,6 +498,13 @@ declare function applyExplorerFormatSuffix(lanes: DispatchLaneSpec[], options?:
472
498
  failClosed?: boolean;
473
499
  mode?: string;
474
500
  }): ApplyCommonPromptResult;
501
+ /**
502
+ * #2276: derive the final-response character budget for a PR-review lane from
503
+ * the lane's owned workload. Returns `undefined` for modes without a derived
504
+ * budget (the swarm-pr-feedback modes keep their flat
505
+ * {@link PR_WORKFLOW_PROTOCOL_OUTPUT_MAX_CHARS} guidance).
506
+ */
507
+ declare function prReviewLaneResponseBudgetChars(mode: string, lane: DispatchLaneSpec): number | undefined;
475
508
  declare function applyPrWorkflowPromptContract(lanes: DispatchLaneSpec[], options: {
476
509
  mode?: string;
477
510
  prHeadSha?: string;
@@ -5,7 +5,23 @@ interface GhBinaryCandidateOptions {
5
5
  platform?: NodeJS.Platform;
6
6
  }
7
7
  export declare function resolveGhBinaryCandidates(options?: GhBinaryCandidateOptions): string[];
8
- declare function resolveGhBinary(): string | null;
8
+ /**
9
+ * Resolve the `gh` binary to invoke. Exported (issue #2236 hardening, lane
10
+ * C1b) so other call sites that need a `gh` executable — e.g. `src/git/pr.ts`,
11
+ * `src/commands/pr-monitor-status.ts` — reuse this resolver instead of
12
+ * spawning a bare `'gh'` literal or inventing a second gh resolver. Returns
13
+ * `null` when no candidate is found; callers should fall back to the bare
14
+ * `'gh'` literal (mirrors `resolveGitExecutable()`'s "never regress a working
15
+ * host" fallback in `src/utils/git-executable.ts`).
16
+ */
17
+ export declare function resolveGhBinary(): string | null;
18
+ /**
19
+ * TEST-ONLY seam (issue #2236 FR-006 ratchet fix) — NOT a production API, do
20
+ * not call from `src/`. Sets the pin `resolveGhBinary()` checks first; pass
21
+ * `null` to simulate "no `gh` candidate found". Mirrors
22
+ * `__seedGitExecutableForTests` in `src/utils/git-executable.ts`.
23
+ */
24
+ export declare function __seedGhBinaryForTests(value: string | null): void;
9
25
  export declare const gh_evidence: ToolDefinition;
10
26
  export declare const _internals: {
11
27
  resolveGhBinaryCandidates: typeof resolveGhBinaryCandidates;
@@ -17,8 +17,8 @@ import { createSwarmTool } from './create-tool.js';
17
17
  declare const ignoredItem: z.ZodObject<{
18
18
  id: z.ZodString;
19
19
  reason: z.ZodEnum<{
20
- stale: "stale";
21
20
  other: "other";
21
+ stale: "stale";
22
22
  superseded: "superseded";
23
23
  unsafe: "unsafe";
24
24
  too_generic: "too_generic";
@@ -1,2 +1,15 @@
1
1
  import type { tool } from '@opencode-ai/plugin';
2
+ import { bunSpawn } from '../utils/bun-compat';
3
+ /**
4
+ * Test-only seam for the `bunSpawn` calls `runNpmAudit` and `runCargoAudit`
5
+ * make. Lets tests inject a synthetic subprocess (e.g. one with `spawnError`
6
+ * set) without monkey-patching the `Bun.spawn` global — see #2236 Sweep A,
7
+ * FIX 2. These two route through the seam because both had a path where a
8
+ * failed spawn could be reported as a completed scan; the remaining audit
9
+ * functions gate strictly on a non-zero exit and were dispositioned
10
+ * SAFE-EXIT-CHECK by that sweep.
11
+ */
12
+ export declare const _internals: {
13
+ bunSpawn: typeof bunSpawn;
14
+ };
2
15
  export declare const pkg_audit: ReturnType<typeof tool>;
@@ -9,6 +9,7 @@ import { saveEvidence } from '../evidence/manager.js';
9
9
  import { runExternalTool } from '../utils/external-tool-runner';
10
10
  import type { LintResult, ResolvedLinterCommand } from './lint';
11
11
  import { detectResolvedLinter } from './lint';
12
+ import { resolveGatePreamble } from './phase-complete/gates/gate-helpers';
12
13
  import type { QualityBudgetResult } from './quality-budget';
13
14
  import { qualityBudget } from './quality-budget';
14
15
  import type { SastScanFinding, SastScanResult } from './sast-scan';
@@ -27,6 +28,8 @@ export declare const _internals: {
27
28
  runLintOnFiles: typeof runLintOnFiles;
28
29
  platform: () => NodeJS.Platform;
29
30
  serializePreCheckResult: typeof serializePreCheckResult;
31
+ resolveGatePreamble: typeof resolveGatePreamble;
32
+ runPreCheckBatch: typeof runPreCheckBatch;
30
33
  MAX_COMBINED_BYTES: number;
31
34
  };
32
35
  export interface PreCheckBatchInput {
@@ -46,6 +49,8 @@ export interface PreCheckBatchInput {
46
49
  * with capture_baseline:true.
47
50
  */
48
51
  phase?: number;
52
+ /** Effective QA-profile value derived internally by the public tool boundary. */
53
+ sast_enabled?: boolean;
49
54
  }
50
55
  export interface ToolResult<T> {
51
56
  /** Whether the tool was executed */
@@ -76,6 +81,10 @@ export interface PreCheckBatchResult {
76
81
  total_duration_ms: number;
77
82
  /** Pre-existing SAST findings on unchanged lines, requiring reviewer triage */
78
83
  sast_preexisting_findings?: SastScanFinding[];
84
+ /** Optional Semgrep exited nonzero with no findings; SAST coverage is incomplete. */
85
+ sast_degraded?: boolean;
86
+ /** SAST was intentionally disabled by the effective QA profile. */
87
+ sast_skipped?: boolean;
79
88
  }
80
89
  /**
81
90
  * Serialize the public result below the decoder's stricter byte ceiling. When
@@ -22,6 +22,7 @@ declare function runGit(directory: string, args: string[], options?: {
22
22
  }): Promise<{
23
23
  exitCode: number;
24
24
  stdout: string;
25
+ spawnError?: Error | null;
25
26
  }>;
26
27
  declare function readBoundedGitStdout(stream: {
27
28
  getReader(): ReadableStreamDefaultReader<Uint8Array>;
@@ -40,6 +40,8 @@ export interface SastScanResult {
40
40
  verdict: EvidenceVerdict;
41
41
  /** Validation error when the requested scan cannot safely run */
42
42
  error?: string;
43
+ /** Machine-readable failure category for gate consumers. */
44
+ failure_kind?: SastFailureKind;
43
45
  /** Array of security findings */
44
46
  findings: SastScanFinding[];
45
47
  /** Summary information */
@@ -71,6 +73,7 @@ export interface SastScanResult {
71
73
  /** True when pre_existing_findings were truncated to fit result limits */
72
74
  truncated_pre_existing?: boolean;
73
75
  }
76
+ export type SastFailureKind = 'semgrep_process_exit' | 'semgrep_timeout' | 'semgrep_cancelled' | 'semgrep_output_limit' | 'semgrep_spawn_error' | 'semgrep_invalid_output' | 'semgrep_scan_error' | 'semgrep_unexpected' | 'semgrep_unclassified' | 'coverage' | 'cancelled' | 'invalid_input';
74
77
  export interface SastScanFinding {
75
78
  rule_id: string;
76
79
  severity: 'critical' | 'high' | 'medium' | 'low';