opencode-swarm 7.165.0 → 7.166.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 (112) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/background/delegation-cost-identity.d.ts +41 -0
  4. package/dist/background/delegation-lifecycle.d.ts +24 -5
  5. package/dist/background/pending-delegations.d.ts +2 -0
  6. package/dist/background/pr-monitor-worker.d.ts +60 -6
  7. package/dist/background/pr-subscriptions.d.ts +13 -0
  8. package/dist/cli/{capability-probe-5wa7mcp6.js → capability-probe-faqefhah.js} +2 -1
  9. package/dist/cli/{coder-settlement-89nt4j7g.js → coder-settlement-x0h3h6vd.js} +13 -13
  10. package/dist/cli/{config-doctor-gm6f5chm.js → config-doctor-pjcjeh8f.js} +5 -5
  11. package/dist/cli/{core-91p43zwj.js → core-v11pd1yk.js} +4 -4
  12. package/dist/cli/{curation-policy-bqpmry2n.js → curation-policy-jtzwz6bc.js} +4 -4
  13. package/dist/cli/{curator-drift-hbc3w5zj.js → curator-drift-jpdfwae9.js} +5 -5
  14. package/dist/cli/curator-llm-factory-da5q3gg6.js +70 -0
  15. package/dist/cli/{curator-4bs2hmy9.js → curator-ssvd7evd.js} +40 -40
  16. package/dist/cli/{dispatch-c7xjt7js.js → dispatch-591v13pp.js} +3 -3
  17. package/dist/cli/{evidence-summary-service-g1xd8egd.js → evidence-summary-service-mw6tnsp9.js} +19 -19
  18. package/dist/cli/{gate-evidence-gdmgsz7c.js → gate-evidence-jymaxb82.js} +9 -9
  19. package/dist/cli/guardrail-explain-eva1yrtf.js +71 -0
  20. package/dist/cli/guardrail-log-kzq2sktb.js +23 -0
  21. package/dist/cli/{guardrail-reset-rp9jq0gj.js → guardrail-reset-ea1g3g7d.js} +40 -40
  22. package/dist/cli/hive-promoter-ghjbgsms.js +85 -0
  23. package/dist/cli/{index-6be5caj8.js → index-066xxa4q.js} +3 -3
  24. package/dist/cli/{index-5ythtd9t.js → index-0g5v4s0x.js} +67 -16
  25. package/dist/cli/{index-a0d4fp6r.js → index-0tc0pcmh.js} +1 -1
  26. package/dist/cli/{index-n3pjcks8.js → index-13egyjgv.js} +5 -5
  27. package/dist/cli/{index-tqw8w2n5.js → index-17yszqs5.js} +1 -1
  28. package/dist/cli/{index-8bdk7124.js → index-1zqf2pny.js} +1 -1
  29. package/dist/cli/{index-8d90gzaz.js → index-2sqgbmtq.js} +1 -1
  30. package/dist/cli/{index-xwbn7c8m.js → index-2v17wb75.js} +2 -2
  31. package/dist/cli/{index-y1zhpfk8.js → index-2y4kargd.js} +4 -4
  32. package/dist/cli/{index-hwz46jj7.js → index-399nq780.js} +2509 -1094
  33. package/dist/cli/{index-r5hj3nfe.js → index-3tyym20r.js} +2 -2
  34. package/dist/cli/{index-zycp24b9.js → index-52xdezsh.js} +12 -3
  35. package/dist/cli/{index-2k53pfnc.js → index-6rff2h8x.js} +4 -4
  36. package/dist/cli/{index-6m24v15v.js → index-79sr3fd1.js} +2 -2
  37. package/dist/cli/{index-k1ntjzmf.js → index-8fr2wn18.js} +2 -2
  38. package/dist/cli/{index-dh5th4jn.js → index-8hqkrd2j.js} +1 -1
  39. package/dist/cli/{index-6rx1rdaq.js → index-a7rw4g4s.js} +1 -1
  40. package/dist/cli/{index-w6988bbc.js → index-aftapk6j.js} +75 -1
  41. package/dist/cli/{index-j2svfhzk.js → index-axf65x87.js} +1 -1
  42. package/dist/cli/{index-anxs69ad.js → index-bfr392e7.js} +1 -1
  43. package/dist/cli/{index-c4ddtrqg.js → index-bkd3450m.js} +6 -6
  44. package/dist/cli/{index-ajknebrc.js → index-c20gf089.js} +1 -1
  45. package/dist/cli/{index-qzvry1n1.js → index-crjx4sx0.js} +42 -42
  46. package/dist/cli/{index-jre6tm3v.js → index-edm41q4j.js} +1 -1
  47. package/dist/cli/{index-z6xqpmqg.js → index-ee6ydtfe.js} +1 -1
  48. package/dist/cli/{index-p7hdp3rp.js → index-fc1dqzjp.js} +2 -2
  49. package/dist/cli/{index-4gmt79q9.js → index-gerkwyrr.js} +1 -1
  50. package/dist/cli/{index-hdakb4n9.js → index-gr8ppbq3.js} +16 -13
  51. package/dist/cli/{index-f36hy1x4.js → index-hvk3zs62.js} +1 -1
  52. package/dist/cli/{index-5ebgzb5a.js → index-hwj25q9r.js} +78 -53
  53. package/dist/cli/{index-1v6vc90w.js → index-j29nkq5d.js} +5 -5
  54. package/dist/cli/{index-e45htt92.js → index-jx9f4ke1.js} +1 -1
  55. package/dist/cli/{index-7h94rfem.js → index-k5w284js.js} +16 -14
  56. package/dist/cli/{index-58be2gtd.js → index-nph5g4em.js} +3 -3
  57. package/dist/cli/{index-4fwbbad3.js → index-q1r1cfww.js} +46 -17
  58. package/dist/cli/{index-afpkqsdb.js → index-w11whwn3.js} +14 -7
  59. package/dist/cli/{index-0e9jh9c7.js → index-wf12wckd.js} +3 -3
  60. package/dist/cli/{index-ptsqnxwd.js → index-xezfx7ge.js} +21 -11
  61. package/dist/cli/{index-3xyjvx24.js → index-xwkn5hse.js} +11 -9
  62. package/dist/cli/{index-g8wdekzz.js → index-ybcxvv17.js} +2 -2
  63. package/dist/cli/{index-e6n7cemz.js → index-yt25kpvz.js} +12 -8
  64. package/dist/cli/{index-556ja8an.js → index-yzjaj53h.js} +9 -2
  65. package/dist/cli/{index-gn6ybsc4.js → index-zha9bdj9.js} +8 -8
  66. package/dist/cli/index-zpsr8rpc.js +68 -0
  67. package/dist/cli/index.js +40 -40
  68. package/dist/cli/{knowledge-escalator-eq07pcj3.js → knowledge-escalator-3pjed4tq.js} +14 -14
  69. package/dist/cli/{knowledge-events-rv9q9mkm.js → knowledge-events-a5dwkg30.js} +12 -12
  70. package/dist/cli/{knowledge-link-dgvbqjqg.js → knowledge-link-1zykfk1p.js} +3 -3
  71. package/dist/cli/{knowledge-store-cxcr0ttk.js → knowledge-store-h85efsak.js} +4 -4
  72. package/dist/cli/{knowledge-validator-8qtd9ys0.js → knowledge-validator-76qrf1ev.js} +6 -6
  73. package/dist/cli/{model-preflight-3s1c0zpc.js → model-preflight-b3b5pgsc.js} +2 -2
  74. package/dist/cli/{pending-delegations-dp3g8e7k.js → pending-delegations-zgwfqfac.js} +14 -12
  75. package/dist/cli/{pr-subscriptions-3vx06rar.js → pr-subscriptions-fzy3ks1k.js} +16 -12
  76. package/dist/cli/{pr-workflow-gate-bbet0apk.js → pr-workflow-gate-1gtsn7f0.js} +40 -40
  77. package/dist/cli/{runner-0e3bjeev.js → runner-j3acybhs.js} +4 -4
  78. package/dist/cli/{scan-cursor-zwm0xng7.js → scan-cursor-ahwkxa8j.js} +5 -5
  79. package/dist/cli/{schema-ebfxgya0.js → schema-27sedbfk.js} +3 -3
  80. package/dist/cli/{scope-persistence-6c55akfz.js → scope-persistence-q792yfxh.js} +16 -16
  81. package/dist/cli/{skill-generator-mv5jxzsh.js → skill-generator-g8wbjw6v.js} +16 -16
  82. package/dist/cli/{snapshot-coordination-init-n556wa18.js → snapshot-coordination-init-y6spakwm.js} +40 -40
  83. package/dist/cli/{telemetry-a1yvjerj.js → telemetry-9h1z2w9d.js} +1 -1
  84. package/dist/cli/{worktree-collision-ownership-pp4z4z8p.js → worktree-collision-ownership-pmpnftkd.js} +13 -13
  85. package/dist/cli/{worktree-isolation-69hz9dgg.js → worktree-isolation-4053n0px.js} +40 -40
  86. package/dist/commands/pr-monitor-status.d.ts +2 -0
  87. package/dist/commands/registry.d.ts +8 -0
  88. package/dist/commands/report.d.ts +36 -0
  89. package/dist/db/observability-event-store.d.ts +162 -0
  90. package/dist/git/pr.d.ts +27 -27
  91. package/dist/git/safe-ref.d.ts +51 -0
  92. package/dist/hooks/context-capsule-inject.d.ts +3 -0
  93. package/dist/index.d.ts +6 -1
  94. package/dist/index.js +573 -480
  95. package/dist/observability/catalog.d.ts +8 -4
  96. package/dist/sandbox/executor.d.ts +10 -0
  97. package/dist/sandbox/win32/runner-client.d.ts +7 -0
  98. package/dist/services/context-attribution.d.ts +69 -0
  99. package/dist/services/cost-accounting.d.ts +2 -0
  100. package/dist/telemetry.d.ts +10 -2
  101. package/dist/tools/co-change-analyzer.d.ts +7 -0
  102. package/dist/tools/gh-evidence.d.ts +15 -8
  103. package/dist/tools/pkg-audit.d.ts +23 -0
  104. package/dist/utils/gh-executable.d.ts +106 -0
  105. package/dist/utils/merge.d.ts +26 -0
  106. package/opencode-swarm.schema.json +1 -1
  107. package/package.json +1 -1
  108. package/dist/cli/curator-llm-factory-fhbjwar0.js +0 -70
  109. package/dist/cli/guardrail-explain-1nfbtpgg.js +0 -71
  110. package/dist/cli/guardrail-log-nyggdv04.js +0 -23
  111. package/dist/cli/hive-promoter-39xb4tx2.js +0 -85
  112. package/dist/cli/index-zjygnfay.js +0 -33
package/dist/git/pr.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as child_process from 'node:child_process';
2
- import { resolveGhBinary } from '../tools/gh-evidence.js';
2
+ import { resolveGhExecutable } from '../utils/gh-executable.js';
3
+ import { resolveGitExecutable } from '../utils/git-executable.js';
3
4
  import { readLaneEnvFileFromDiskSync } from './branch.js';
4
5
  export declare const GIT_TIMEOUT_MS = 30000;
5
6
  /**
@@ -71,7 +72,8 @@ export declare const _internals: {
71
72
  spawnSync: typeof __spawnSyncSeam.spawnSync;
72
73
  readLaneEnvFileFromDiskSync: typeof readLaneEnvFileFromDiskSync;
73
74
  getMergeGroupRun: typeof getMergeGroupRun;
74
- resolveGhBinary: typeof resolveGhBinary;
75
+ resolveGhExecutable: typeof resolveGhExecutable;
76
+ resolveGitExecutable: typeof resolveGitExecutable;
75
77
  };
76
78
  /**
77
79
  * Check if gh CLI is available
@@ -113,13 +115,6 @@ export interface PRStatusResult {
113
115
  detailsUrl?: string;
114
116
  }>;
115
117
  }
116
- export interface PRCheckResult {
117
- name: string;
118
- bucket: string;
119
- state: string;
120
- startedAt: string | null;
121
- completedAt: string | null;
122
- }
123
118
  export interface PRCommentResult {
124
119
  id: string;
125
120
  author: string;
@@ -138,28 +133,33 @@ export interface ReviewStateResult {
138
133
  /** Number of requesting reviewers (non-zero means reviews are still pending). */
139
134
  reviewRequestCount: number;
140
135
  }
136
+ /** All per-PR data one poll cycle needs, in two gh spawns. */
137
+ export interface PRPollSnapshot {
138
+ status: PRStatusResult;
139
+ comments: PRCommentResult[];
140
+ merge: MergeStateResult;
141
+ review: ReviewStateResult;
142
+ }
141
143
  /**
142
- * Fetch PR status via gh pr view --json
143
- */
144
- export declare function getPRStatus(prNumber: number, repoFullName: string, cwd: string): Promise<PRStatusResult>;
145
- /**
146
- * Fetch CI check results via gh pr checks --json
147
- */
148
- export declare function getPRChecks(prNumber: number, repoFullName: string, cwd: string): Promise<PRCheckResult[]>;
149
- /**
150
- * Fetch PR comments since a given timestamp via gh api
151
- * Returns both issue comments and pull request review comments, merged together
152
- */
153
- export declare function getPRComments(prNumber: number, repoFullName: string, cwd: string, since?: string): Promise<PRCommentResult[]>;
154
- /**
155
- * Fetch merge state (mergeable + mergeStateStatus) via gh pr view --json
144
+ * Fetch status, merge state, review state and conversation (issue) comments
145
+ * with ONE `gh pr view --json` call. Previously this was three near-duplicate
146
+ * pr-view spawns (status/merge/review) plus two gh api spawns per PR per poll.
147
+ *
148
+ * `comments[].id` from pr-view is the GraphQL node id, NOT the numeric
149
+ * database id the REST endpoints return. The numeric id is recovered from the
150
+ * comment permalink (`#issuecomment-<id>` suffix, verified equal to the REST
151
+ * id on gh >= 2.92) so `lastCommentId` markers written by earlier versions
152
+ * keep matching; the node id remains the defensive fallback (a warn is
153
+ * logged if it ever fires fallback ids change the marker space).
156
154
  */
157
- export declare function getMergeState(prNumber: number, repoFullName: string, cwd: string): Promise<MergeStateResult>;
155
+ export declare function getPRPollSnapshot(prNumber: number, repoFullName: string, cwd: string): Promise<PRPollSnapshot>;
158
156
  /**
159
- * Fetch the current review state for a PR using `gh pr view --json reviewDecision,reviewRequests`.
160
- * Uses async ghExecAsync to avoid blocking the event loop.
157
+ * Fetch inline pull-request review comments via gh api the review half of
158
+ * the old two-endpoint getPRComments (the issue-comment half now rides the
159
+ * pr-view snapshot). Inline review comments have no `gh pr view --json`
160
+ * equivalent, so this stays the second spawn of the poll cycle.
161
161
  */
162
- export declare function getPRReviewState(prNumber: number, repoFullName: string, cwd: string): Promise<ReviewStateResult>;
162
+ export declare function getPRReviewComments(prNumber: number, repoFullName: string, cwd: string): Promise<PRCommentResult[]>;
163
163
  /**
164
164
  * Result of fetching a GitHub Actions run for a PR's merge group.
165
165
  */
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Fail-closed guard for git ref arguments (issue #2476 AC3, source issue
3
+ * #2265).
4
+ *
5
+ * Defect class: a repository- or caller-derived ref interpolated into a git
6
+ * argv position can BEGIN WITH A DASH and be parsed by git as an OPTION. A
7
+ * hostile remote can advertise `refs/heads/--evil` (`git update-ref` bypasses
8
+ * `check-ref-format`; a plain `git clone` propagates it), so `git checkout
9
+ * --evil` exits 129 with "unknown option" and a branch literally named
10
+ * `--force` makes `git checkout --force` SILENTLY DESTRUCTIVE.
11
+ *
12
+ * Guard placement is per-command, settled empirically against git 2.x (see
13
+ * `.agents/issue-traces/2476-harden-trust-boundaries/02-reproduction.md` R3):
14
+ *
15
+ * - `branch -d -- <name>` and `push <remote> -- <refspec>` accept a literal
16
+ * `--` end-of-options separator with IDENTICAL semantics for benign names
17
+ * and fail-closed behavior for hostile ones — those sinks insert `--`.
18
+ * - `checkout`, `checkout -b <new> <start>`, `rev-parse --verify`,
19
+ * `rev-parse --abbrev-ref <b>@{upstream}`, `reset --hard`, `log <range>`,
20
+ * `diff <base> HEAD`, and `branch --merged <target>` REGRESS benign
21
+ * behavior when a leading `--` is inserted (pathspec/malformed-object
22
+ * errors) — those sinks use this validation guard instead.
23
+ *
24
+ * The predicate is deliberately minimal — NOT the full check-ref-format
25
+ * grammar — so `origin/main`, `HEAD`, `feature/x`, SHAs, and each side of an
26
+ * `a..b` range all pass while any dash-leading side is rejected. This mirrors
27
+ * the in-repo validator family (`isSafeGitRef` in ci-simulate.ts,
28
+ * `isSafeGitRevisionToken` in workspace-snapshot.ts, `isSafeGitRefToken` in
29
+ * pr-workflow-gate.ts), which this module centralizes for the src/git sinks.
30
+ */
31
+ /** Typed, fail-closed rejection of an option-injectable git ref. */
32
+ export declare class UnsafeGitRefError extends Error {
33
+ readonly ref: string;
34
+ readonly context: string;
35
+ constructor(ref: string, context: string);
36
+ }
37
+ /**
38
+ * True when `value` is safe to interpolate into a git argv ref position:
39
+ * non-empty, and no `..`-separated side starts with "-". Empty/odd `..`
40
+ * sides are deliberately NOT rejected here (a name like `../../x` is not an
41
+ * option-injection risk; git itself rejects it as an invalid ref, and the
42
+ * pre-existing adversarial contract in tests/unit/git/branch.adversarial
43
+ * pins pass-through for those shapes) — only dash-leading sides are.
44
+ */
45
+ export declare function isSafeGitRefArg(value: string): boolean;
46
+ /**
47
+ * Fail-closed form of {@link isSafeGitRefArg}: returns `value` unchanged when
48
+ * safe, throws {@link UnsafeGitRefError} otherwise. `context` names the
49
+ * caller/sink so the error is actionable (e.g. "createBranch checkout").
50
+ */
51
+ export declare function assertSafeGitRefArg(value: string, context: string): string;
@@ -23,6 +23,7 @@ import type { PluginConfig } from '../config/index.js';
23
23
  import { buildCapsule } from '../context-map/capsule-builder.js';
24
24
  import { saveCapsule } from '../context-map/capsule-persistence.js';
25
25
  import { recordTelemetry } from '../context-map/telemetry.js';
26
+ import { measureCitedFileTokens, recordContextSourceAttribution } from '../services/context-attribution.js';
26
27
  import type { AgentSessionState } from '../state.js';
27
28
  import type { CapsuleDelegationReason } from '../types/context-capsule.js';
28
29
  /**
@@ -58,6 +59,8 @@ export declare const _internals: {
58
59
  buildCapsule: typeof buildCapsule;
59
60
  recordTelemetry: typeof recordTelemetry;
60
61
  saveCapsule: typeof saveCapsule;
62
+ measureCitedFileTokens: typeof measureCitedFileTokens;
63
+ recordContextSourceAttribution: typeof recordContextSourceAttribution;
61
64
  getActiveAgent: (sessionID: string) => string | undefined;
62
65
  getSession: (sessionID: string) => AgentSessionState | undefined;
63
66
  getCurrentTaskId: (sessionID: string) => string | null;
package/dist/index.d.ts CHANGED
@@ -12,7 +12,12 @@ import { ensureSwarmGitExcluded } from './utils/gitignore-warning';
12
12
  * unit testing of the cap invariant; used by the heartbeat throttle and
13
13
  * delegation-telemetry pairing paths below.
14
14
  */
15
- export declare function capSessionMap<K, V>(map: Map<K, V>, max: number): void;
15
+ export declare function capSessionMap<K, V>(map: Map<K, V>, max: number,
16
+ /** #2482 / #2244: the just-inserted key must never evict itself (a re-set
17
+ * entry keeps its ORIGINAL insertion position, so without this guard the
18
+ * fresh entry can be the oldest and evict itself at the cap — mirroring
19
+ * the stored-input-args guard). */
20
+ justInserted?: K): void;
16
21
  /** @internal — test-only: clears delegation-telemetry pairing state so one
17
22
  * test's unconsumed entries (e.g. a before with no matching after) cannot
18
23
  * leak into the next. Mirrors resetTelemetryForTesting / resetSwarmState. */