opencode-swarm 7.168.0 → 7.169.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 (133) hide show
  1. package/.opencode/skills/swarm-pr-feedback/SKILL.md +11 -11
  2. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  3. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  4. package/dist/cli/{coder-settlement-a35acvj1.js → coder-settlement-fd6ba876.js} +12 -12
  5. package/dist/cli/{config-doctor-9csx775x.js → config-doctor-zeppqwwx.js} +2 -2
  6. package/dist/cli/{core-agk5s7dm.js → core-fj1afc31.js} +5 -2
  7. package/dist/cli/{curation-policy-mgwv8h2k.js → curation-policy-k74qz9ms.js} +5 -5
  8. package/dist/cli/{curator-drift-k0zrnm09.js → curator-drift-3ssjr0nx.js} +5 -5
  9. package/dist/cli/{curator-2fcagjyk.js → curator-emftndv0.js} +39 -38
  10. package/dist/cli/curator-llm-factory-4t773tmz.js +72 -0
  11. package/dist/cli/{dispatch-8ks9dyk5.js → dispatch-hwwj3qrb.js} +2 -2
  12. package/dist/cli/{evidence-summary-service-4s6cje60.js → evidence-summary-service-51b69jc3.js} +16 -16
  13. package/dist/cli/{gate-evidence-saja4dan.js → gate-evidence-53s161wb.js} +7 -7
  14. package/dist/cli/guardrail-explain-mhx8gt8q.js +73 -0
  15. package/dist/cli/{guardrail-log-0h24spq0.js → guardrail-log-xg6hrdsq.js} +8 -8
  16. package/dist/cli/{guardrail-reset-cwbe47k5.js → guardrail-reset-fgv5kt5x.js} +39 -38
  17. package/dist/cli/{hive-promoter-esxtcvr1.js → hive-promoter-41zygtgx.js} +39 -38
  18. package/dist/cli/index-0hgmsyfp.js +92 -0
  19. package/dist/cli/{index-nsyxj57e.js → index-0vgs5r39.js} +8 -8
  20. package/dist/cli/{index-54w1564x.js → index-1cbjemgh.js} +2 -2
  21. package/dist/cli/{index-p612v1mv.js → index-2s7dvzff.js} +200 -51
  22. package/dist/cli/{index-3dywbkyr.js → index-2znfa537.js} +4 -4
  23. package/dist/cli/{index-seetnhpx.js → index-3bfzpzsb.js} +1 -1
  24. package/dist/cli/{index-yevn4jpe.js → index-3zcds757.js} +3101 -1918
  25. package/dist/cli/{index-d5qf7hvh.js → index-5400m33a.js} +1 -1
  26. package/dist/cli/{index-mr0wn36f.js → index-55fkkjec.js} +5 -5
  27. package/dist/cli/{index-qwsh0h2g.js → index-5qt9yf5w.js} +4 -4
  28. package/dist/cli/{index-30h1pk05.js → index-5reh1bjz.js} +3 -3
  29. package/dist/cli/{index-j950hqmq.js → index-76ng6vmq.js} +7 -7
  30. package/dist/cli/{index-qhey6vc3.js → index-7h01bkm6.js} +2 -2
  31. package/dist/cli/{index-yv76j77m.js → index-83m0y4cj.js} +6 -6
  32. package/dist/cli/{index-ddr97ram.js → index-8x9keek6.js} +41 -40
  33. package/dist/cli/{index-8ybjqg51.js → index-9ttqbhvw.js} +1 -1
  34. package/dist/cli/{index-kear8gb7.js → index-b3pmzbh1.js} +2 -2
  35. package/dist/cli/{index-h439y187.js → index-bernkwgf.js} +1 -1
  36. package/dist/cli/{index-m35hybf0.js → index-bm5xrfnx.js} +1 -1
  37. package/dist/cli/{index-pyf517sz.js → index-br3mvbsa.js} +2 -2
  38. package/dist/cli/{index-4r5pmtvk.js → index-bx1wgn3a.js} +4 -4
  39. package/dist/cli/{index-64phnth4.js → index-c7kr7tnk.js} +4 -4
  40. package/dist/cli/{index-nwwk3dej.js → index-cgpwjctj.js} +1 -1
  41. package/dist/cli/{index-s0d5xter.js → index-dd48vt27.js} +3 -3
  42. package/dist/cli/{index-wst6n478.js → index-dvbf6fpn.js} +1 -1
  43. package/dist/cli/{index-rxcgrgkc.js → index-e4dxf5cr.js} +39 -38
  44. package/dist/cli/{index-cyenn3pf.js → index-egkc2bpv.js} +36 -1
  45. package/dist/cli/{index-h0e2e3h1.js → index-exf0j569.js} +1 -1
  46. package/dist/cli/{index-a8xbvsse.js → index-fgp96k3r.js} +2 -2
  47. package/dist/cli/{index-5zqakgp4.js → index-fhh02gwx.js} +3 -3
  48. package/dist/cli/{index-dfyv3xkd.js → index-gfbggp8k.js} +9 -9
  49. package/dist/cli/{index-nprngf8p.js → index-ksybszed.js} +7 -7
  50. package/dist/cli/{index-v3xc4sde.js → index-nbdmdyke.js} +2 -1
  51. package/dist/cli/{index-z6qreakh.js → index-nprdr0sm.js} +6 -4
  52. package/dist/cli/{index-wnzxcr0z.js → index-nwv3e3kc.js} +2 -2
  53. package/dist/cli/{index-bvqqwx84.js → index-nyn01yrz.js} +2 -2
  54. package/dist/cli/{index-an8b5gda.js → index-p6xsgk4r.js} +7 -7
  55. package/dist/cli/{index-x7k3dps5.js → index-s96dpjsk.js} +2 -2
  56. package/dist/cli/{index-ze520xw1.js → index-sb1s03y9.js} +8 -8
  57. package/dist/cli/{index-00zx94vn.js → index-sxcfszbe.js} +5 -5
  58. package/dist/cli/{index-8f0kscpg.js → index-wwr67xc0.js} +197 -35
  59. package/dist/cli/{index-gp9yzr1v.js → index-xnpjwc4h.js} +1 -1
  60. package/dist/cli/{index-exatbqwj.js → index-yj24ny5k.js} +26 -4
  61. package/dist/cli/{index-21ree67h.js → index-zapc8vj4.js} +14 -14
  62. package/dist/cli/index.js +39 -38
  63. package/dist/cli/{knowledge-escalator-b2tf3sd1.js → knowledge-escalator-07s44av0.js} +13 -13
  64. package/dist/cli/{knowledge-events-bgs2kxe0.js → knowledge-events-j2n1569p.js} +11 -11
  65. package/dist/cli/{knowledge-link-dr3xnwyd.js → knowledge-link-rkxfrmhm.js} +4 -4
  66. package/dist/cli/{knowledge-store-stbmb1b9.js → knowledge-store-85metj89.js} +5 -5
  67. package/dist/cli/{knowledge-validator-zykgnsag.js → knowledge-validator-63k1xzcc.js} +7 -7
  68. package/dist/cli/{pending-delegations-n5qavj20.js → pending-delegations-dckmjymn.js} +12 -12
  69. package/dist/cli/{pr-subscriptions-gnvmyrng.js → pr-subscriptions-pyh73me6.js} +12 -12
  70. package/dist/cli/{pr-workflow-gate-cf3ybrws.js → pr-workflow-gate-k1r4rjw4.js} +39 -38
  71. package/dist/cli/{runner-k0ycgv8x.js → runner-1dwrgyyr.js} +6 -6
  72. package/dist/cli/{scan-cursor-b3mcrx23.js → scan-cursor-k6egg4n0.js} +6 -6
  73. package/dist/cli/{schema-08049cjb.js → schema-vdrtpggt.js} +5 -1
  74. package/dist/cli/{scope-persistence-a493gv51.js → scope-persistence-h1mmww19.js} +14 -14
  75. package/dist/cli/{skill-generator-2qqzkdpv.js → skill-generator-pmn6gmvk.js} +15 -15
  76. package/dist/cli/{snapshot-coordination-init-8yt8p7q0.js → snapshot-coordination-init-rspykgd0.js} +39 -38
  77. package/dist/cli/{telemetry-2wzapf11.js → telemetry-fdtaemnv.js} +1 -1
  78. package/dist/cli/{workspace-snapshot-rkgxhj9b.js → workspace-snapshot-hkz2wt1c.js} +4 -4
  79. package/dist/cli/{worktree-collision-ownership-xttafc4h.js → worktree-collision-ownership-x84dzzzc.js} +18 -104
  80. package/dist/cli/{worktree-isolation-e5q5rewk.js → worktree-isolation-nw9pakkx.js} +39 -38
  81. package/dist/commands/destructive-purge.d.ts +85 -0
  82. package/dist/commands/registry.d.ts +2 -2
  83. package/dist/commands/reset-session.d.ts +5 -1
  84. package/dist/config/constants.d.ts +4 -1
  85. package/dist/config/lane-context.d.ts +19 -0
  86. package/dist/config/schema.d.ts +77 -0
  87. package/dist/evaluation/index.d.ts +1 -0
  88. package/dist/evaluation/retrieval-quality.d.ts +116 -0
  89. package/dist/failures/invocation-failure.d.ts +23 -4
  90. package/dist/hooks/init-orphan-recovery.d.ts +7 -0
  91. package/dist/hooks/pr-workflow-gate.d.ts +8 -2
  92. package/dist/index.js +596 -590
  93. package/dist/memory/embeddings/reranker.d.ts +13 -2
  94. package/dist/memory/evaluation.d.ts +99 -0
  95. package/dist/memory/heldout-evaluation-corpus.d.ts +51 -0
  96. package/dist/memory/index.d.ts +5 -2
  97. package/dist/memory/sqlite-provider.d.ts +35 -1
  98. package/dist/memory/types.d.ts +14 -0
  99. package/dist/observability/otel-mapping.d.ts +5 -5
  100. package/dist/observability/otlp-exporter.d.ts +80 -0
  101. package/dist/parallel/lane-owners.d.ts +76 -0
  102. package/dist/tools/repo-graph/query.d.ts +6 -1
  103. package/dist/tools/repo-graph/types.d.ts +13 -4
  104. package/dist/utils/bun-compat.d.ts +20 -0
  105. package/dist/utils/gitignore-warning.d.ts +5 -2
  106. package/dist/worktree/base-migration.d.ts +55 -0
  107. package/dist/worktree/core.d.ts +15 -6
  108. package/dist/worktree/ownership.d.ts +66 -0
  109. package/opencode-swarm.schema.json +97 -0
  110. package/package.json +4 -2
  111. package/tests/fixtures/memory-recall-heldout/manifest.json +311 -0
  112. package/tests/fixtures/memory-recall-heldout/sources/bash.sh +1 -0
  113. package/tests/fixtures/memory-recall-heldout/sources/c.c +1 -0
  114. package/tests/fixtures/memory-recall-heldout/sources/cpp.cpp +1 -0
  115. package/tests/fixtures/memory-recall-heldout/sources/csharp.cs +1 -0
  116. package/tests/fixtures/memory-recall-heldout/sources/css.css +3 -0
  117. package/tests/fixtures/memory-recall-heldout/sources/dart.dart +1 -0
  118. package/tests/fixtures/memory-recall-heldout/sources/go.go +3 -0
  119. package/tests/fixtures/memory-recall-heldout/sources/ini.ini +2 -0
  120. package/tests/fixtures/memory-recall-heldout/sources/java.java +1 -0
  121. package/tests/fixtures/memory-recall-heldout/sources/javascript.js +3 -0
  122. package/tests/fixtures/memory-recall-heldout/sources/kotlin.kt +1 -0
  123. package/tests/fixtures/memory-recall-heldout/sources/php.php +1 -0
  124. package/tests/fixtures/memory-recall-heldout/sources/powershell.ps1 +1 -0
  125. package/tests/fixtures/memory-recall-heldout/sources/python.py +2 -0
  126. package/tests/fixtures/memory-recall-heldout/sources/regex.regex +1 -0
  127. package/tests/fixtures/memory-recall-heldout/sources/ruby.rb +3 -0
  128. package/tests/fixtures/memory-recall-heldout/sources/rust.rs +1 -0
  129. package/tests/fixtures/memory-recall-heldout/sources/swift.swift +1 -0
  130. package/tests/fixtures/memory-recall-heldout/sources/tsx.tsx +3 -0
  131. package/tests/fixtures/memory-recall-heldout/sources/typescript.ts +3 -0
  132. package/dist/cli/curator-llm-factory-qaxmyy46.js +0 -71
  133. package/dist/cli/guardrail-explain-z41q6sf0.js +0 -72
@@ -7,65 +7,66 @@ import {
7
7
  isHiveEligible,
8
8
  promoteFromSwarm,
9
9
  promoteToHive
10
- } from "./index-yevn4jpe.js";
11
- import"./index-d5qf7hvh.js";
12
- import"./index-qhey6vc3.js";
13
- import"./index-30h1pk05.js";
14
- import"./index-nwwk3dej.js";
15
- import"./index-cyenn3pf.js";
16
- import"./index-21ree67h.js";
17
- import"./index-gp9yzr1v.js";
10
+ } from "./index-3zcds757.js";
11
+ import"./index-5400m33a.js";
12
+ import"./index-7h01bkm6.js";
13
+ import"./index-5reh1bjz.js";
14
+ import"./index-cgpwjctj.js";
15
+ import"./index-egkc2bpv.js";
16
+ import"./index-zapc8vj4.js";
17
+ import"./index-xnpjwc4h.js";
18
18
  import"./index-txdagbh7.js";
19
19
  import"./index-9br68j86.js";
20
20
  import"./index-cw912re7.js";
21
- import"./index-64phnth4.js";
22
- import"./index-mr0wn36f.js";
23
- import"./index-wnzxcr0z.js";
21
+ import"./index-c7kr7tnk.js";
22
+ import"./index-55fkkjec.js";
23
+ import"./index-nwv3e3kc.js";
24
24
  import"./index-fyfbpz4f.js";
25
- import"./index-dfyv3xkd.js";
25
+ import"./index-gfbggp8k.js";
26
+ import"./index-0hgmsyfp.js";
26
27
  import"./index-zsrtt42s.js";
27
- import"./index-ze520xw1.js";
28
- import"./index-5zqakgp4.js";
29
- import"./index-bvqqwx84.js";
28
+ import"./index-sb1s03y9.js";
29
+ import"./index-fhh02gwx.js";
30
+ import"./index-nyn01yrz.js";
30
31
  import"./index-b43rt5ph.js";
31
32
  import"./index-q7sjgr1y.js";
32
- import"./index-00zx94vn.js";
33
- import"./index-8f0kscpg.js";
34
- import"./index-nprngf8p.js";
35
- import"./index-nsyxj57e.js";
36
- import"./index-kear8gb7.js";
37
- import"./index-p612v1mv.js";
38
- import"./index-3dywbkyr.js";
39
- import"./index-m35hybf0.js";
33
+ import"./index-sxcfszbe.js";
34
+ import"./index-wwr67xc0.js";
35
+ import"./index-ksybszed.js";
36
+ import"./index-0vgs5r39.js";
37
+ import"./index-b3pmzbh1.js";
38
+ import"./index-2s7dvzff.js";
39
+ import"./index-2znfa537.js";
40
+ import"./index-bm5xrfnx.js";
40
41
  import"./index-rtry5xyf.js";
41
- import"./index-x7k3dps5.js";
42
+ import"./index-s96dpjsk.js";
42
43
  import"./index-3qf1vxtb.js";
43
44
  import"./index-n832052r.js";
44
- import"./index-an8b5gda.js";
45
- import"./index-yv76j77m.js";
46
- import"./index-a8xbvsse.js";
47
- import"./index-pyf517sz.js";
48
- import"./index-h439y187.js";
49
- import"./index-wst6n478.js";
45
+ import"./index-p6xsgk4r.js";
46
+ import"./index-83m0y4cj.js";
47
+ import"./index-fgp96k3r.js";
48
+ import"./index-br3mvbsa.js";
49
+ import"./index-bernkwgf.js";
50
+ import"./index-dvbf6fpn.js";
50
51
  import"./index-rdm3px0g.js";
51
52
  import"./index-ry16d01s.js";
52
- import"./index-qwsh0h2g.js";
53
+ import"./index-5qt9yf5w.js";
53
54
  import {
54
55
  resolveHiveKnowledgePath
55
- } from "./index-j950hqmq.js";
56
+ } from "./index-76ng6vmq.js";
56
57
  import"./index-vzm6zre7.js";
57
58
  import"./index-ae75rja9.js";
58
- import"./index-8ybjqg51.js";
59
- import"./index-4r5pmtvk.js";
59
+ import"./index-9ttqbhvw.js";
60
+ import"./index-bx1wgn3a.js";
60
61
  import"./index-7g4c7s5r.js";
61
- import"./index-v3xc4sde.js";
62
- import"./index-z6qreakh.js";
62
+ import"./index-nprdr0sm.js";
63
+ import"./index-nbdmdyke.js";
63
64
  import"./index-1xnse449.js";
64
65
  import"./index-ee6ydtfe.js";
65
- import"./index-seetnhpx.js";
66
+ import"./index-3bfzpzsb.js";
66
67
  import"./index-0mhftbpp.js";
67
68
  import"./index-a1w58b47.js";
68
- import"./index-exatbqwj.js";
69
+ import"./index-yj24ny5k.js";
69
70
  import"./index-sxt7fgcw.js";
70
71
  import"./index-bk5tah7q.js";
71
72
  import"./index-bpmtbmy9.js";
@@ -0,0 +1,92 @@
1
+ // @bun
2
+ import {
3
+ bunSpawn
4
+ } from "./index-2s7dvzff.js";
5
+ import {
6
+ init_git_executable,
7
+ resolveGitExecutable
8
+ } from "./index-0mhftbpp.js";
9
+
10
+ // src/hooks/delegation-gate/worktree-ownership-tag.ts
11
+ import * as fs from "fs";
12
+ import * as path from "path";
13
+ init_git_executable();
14
+ var OWNERSHIP_TAG_SCAN_TIMEOUT_MS = 2000;
15
+ var MAX_OWNERSHIP_TAGS = 512;
16
+ function decodeTagPart(value) {
17
+ if (!value || !/^[A-Za-z0-9_-]+$/.test(value))
18
+ return null;
19
+ const decoded = Buffer.from(value, "base64url").toString("utf8");
20
+ return decoded && Buffer.from(decoded, "utf8").toString("base64url") === value ? decoded : null;
21
+ }
22
+ async function scanBackgroundWorktreeOwnershipTagsForRecovery(directory) {
23
+ try {
24
+ fs.statSync(path.join(directory, ".git"));
25
+ } catch (error) {
26
+ if (error.code === "ENOENT") {
27
+ return { status: "ok", owners: [] };
28
+ }
29
+ return {
30
+ status: "uncertain",
31
+ reason: `Git metadata could not be inspected: ${error instanceof Error ? error.message : String(error)}`
32
+ };
33
+ }
34
+ let proc;
35
+ try {
36
+ proc = bunSpawn([
37
+ resolveGitExecutable(),
38
+ "-C",
39
+ directory,
40
+ "for-each-ref",
41
+ `--count=${MAX_OWNERSHIP_TAGS + 1}`,
42
+ "--format=%(refname:strip=2)%00%(objectname)",
43
+ "refs/tags/swarm-preserved-owner/"
44
+ ], {
45
+ stdin: "ignore",
46
+ stdout: "pipe",
47
+ stderr: "ignore",
48
+ timeout: OWNERSHIP_TAG_SCAN_TIMEOUT_MS
49
+ });
50
+ const exitCode = await proc.exited;
51
+ if (exitCode !== 0) {
52
+ return {
53
+ status: "uncertain",
54
+ reason: `ownership tag scan exited ${exitCode}`
55
+ };
56
+ }
57
+ const lines = (await proc.stdout.text()).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
58
+ if (lines.length > MAX_OWNERSHIP_TAGS) {
59
+ return {
60
+ status: "uncertain",
61
+ reason: `ownership tag scan exceeded the ${MAX_OWNERSHIP_TAGS}-tag safety bound`
62
+ };
63
+ }
64
+ const owners = [];
65
+ for (const line of lines) {
66
+ const [tag, ref, ...extra] = line.split("\x00");
67
+ const segments = tag?.split("/") ?? [];
68
+ const sessionId = decodeTagPart(segments[1] ?? "");
69
+ const laneId = decodeTagPart(segments[2] ?? "");
70
+ const callDigest = segments[3];
71
+ if (extra.length > 0 || segments.length !== 4 || segments[0] !== "swarm-preserved-owner" || !sessionId || !laneId || !callDigest || !/^[0-9a-f]{12}$/.test(callDigest) || !ref || !/^[0-9a-f]{40,64}$/i.test(ref)) {
72
+ return {
73
+ status: "uncertain",
74
+ reason: `malformed background ownership tag entry "${tag ?? ""}"`
75
+ };
76
+ }
77
+ owners.push({ sessionId, laneId, callDigest, ref });
78
+ }
79
+ return { status: "ok", owners };
80
+ } catch (error) {
81
+ return {
82
+ status: "uncertain",
83
+ reason: `ownership tag scan failed: ${error instanceof Error ? error.message : String(error)}`
84
+ };
85
+ } finally {
86
+ try {
87
+ proc?.kill();
88
+ } catch {}
89
+ }
90
+ }
91
+
92
+ export { scanBackgroundWorktreeOwnershipTagsForRecovery };
@@ -1,36 +1,36 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-kear8gb7.js";
4
+ } from "./index-b3pmzbh1.js";
5
5
  import {
6
6
  observeReceiptTransition
7
- } from "./index-qwsh0h2g.js";
7
+ } from "./index-5qt9yf5w.js";
8
8
  import {
9
9
  resolveHiveEventsPath
10
10
  } from "./index-ae75rja9.js";
11
11
  import {
12
12
  resolveKnowledgeStoreDir
13
- } from "./index-8ybjqg51.js";
13
+ } from "./index-9ttqbhvw.js";
14
14
  import {
15
15
  assertProjectRoot,
16
16
  atomicWriteFile
17
- } from "./index-4r5pmtvk.js";
17
+ } from "./index-bx1wgn3a.js";
18
18
  import {
19
19
  require_proper_lockfile
20
20
  } from "./index-7g4c7s5r.js";
21
21
  import {
22
22
  emit
23
- } from "./index-z6qreakh.js";
23
+ } from "./index-nprdr0sm.js";
24
24
  import {
25
25
  canonicalRootKey
26
26
  } from "./index-1xnse449.js";
27
27
  import {
28
28
  loadPluginConfigWithMeta
29
- } from "./index-seetnhpx.js";
29
+ } from "./index-3bfzpzsb.js";
30
30
  import {
31
31
  KnowledgeConfigSchema,
32
32
  init_schema
33
- } from "./index-exatbqwj.js";
33
+ } from "./index-yj24ny5k.js";
34
34
  import {
35
35
  init_logger,
36
36
  warn
@@ -2813,7 +2813,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2813
2813
  }
2814
2814
  let bumps = 0;
2815
2815
  if (deltas.length > 0) {
2816
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-stbmb1b9.js");
2816
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-85metj89.js");
2817
2817
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2818
2818
  }
2819
2819
  return {
@@ -14,14 +14,14 @@ import {
14
14
  detectWindowsWrites,
15
15
  getSharedClassifierGuardrailBlock,
16
16
  resolveWriteTargets
17
- } from "./index-yevn4jpe.js";
17
+ } from "./index-3zcds757.js";
18
18
  import {
19
19
  checkFileAuthority,
20
20
  classifyFile,
21
21
  isInDeclaredScope,
22
22
  redactPath,
23
23
  redactShellCommand
24
- } from "./index-30h1pk05.js";
24
+ } from "./index-5reh1bjz.js";
25
25
 
26
26
  // src/services/guardrail-explain-service.ts
27
27
  import path from "path";
@@ -137,6 +137,20 @@ function bunHash(input) {
137
137
  }
138
138
  return hash;
139
139
  }
140
+ var DEFAULT_BUN_SPAWN_MAX_BUFFER_BYTES = 5 * 1024 * 1024;
141
+
142
+ class BunCompatOutputLimitError extends Error {
143
+ limit;
144
+ captured;
145
+ total;
146
+ constructor(limit, captured, total) {
147
+ super(`Subprocess output exceeded the ${limit}-byte buffer limit after capturing ${captured} bytes (${total} bytes observed)`);
148
+ this.name = "BunCompatOutputLimitError";
149
+ this.limit = limit;
150
+ this.captured = captured;
151
+ this.total = total;
152
+ }
153
+ }
140
154
  async function killProcessTreeImpl(pid, signal, directKill, wasDetached) {
141
155
  if (typeof pid !== "number" || pid <= 0) {
142
156
  directKill(signal);
@@ -267,32 +281,95 @@ function wrapSpawnFailure(error, cwd, executable) {
267
281
  return err;
268
282
  return describeSpawnCwdFailure(cwd, executable, err) ?? err;
269
283
  }
270
- function streamFromNode(pipe) {
284
+ function normalizedMaxBuffer(value) {
285
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : DEFAULT_BUN_SPAWN_MAX_BUFFER_BYTES;
286
+ }
287
+ function createOutputOverflowController(limit, requestKill) {
288
+ let error;
289
+ let killRequested = false;
290
+ let resolveCompleted;
291
+ const completed = new Promise((resolve) => {
292
+ resolveCompleted = resolve;
293
+ });
294
+ return {
295
+ get error() {
296
+ return error;
297
+ },
298
+ completed,
299
+ overflow(captured, total) {
300
+ if (error)
301
+ return;
302
+ error = new BunCompatOutputLimitError(limit, captured, total);
303
+ if (killRequested)
304
+ return;
305
+ killRequested = true;
306
+ try {
307
+ requestKill();
308
+ } catch {}
309
+ },
310
+ complete() {
311
+ resolveCompleted();
312
+ }
313
+ };
314
+ }
315
+ function streamFromNode(pipe, limit, controller) {
316
+ if (!pipe)
317
+ return staticStream("");
318
+ let mode;
271
319
  let collected;
272
- let readerClaimed = false;
273
320
  const collect = () => {
274
- if (readerClaimed) {
321
+ if (mode === "reader") {
275
322
  return Promise.reject(new TypeError("Subprocess output is already consumed by a reader"));
276
323
  }
277
- collected ??= new Promise((resolve) => {
324
+ mode = "buffered";
325
+ if (collected)
326
+ return collected;
327
+ collected = new Promise((resolve) => {
278
328
  if (!pipe) {
279
329
  resolve(Buffer.alloc(0));
280
330
  return;
281
331
  }
282
332
  const chunks = [];
333
+ let captured = 0;
334
+ let total = 0;
335
+ let finished = false;
336
+ const finish = () => {
337
+ if (finished)
338
+ return;
339
+ finished = true;
340
+ resolve(Buffer.concat(chunks));
341
+ };
283
342
  pipe.on("data", (chunk) => {
284
- chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
343
+ const bytes = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
344
+ total += bytes.byteLength;
345
+ if (controller?.error || limit === undefined)
346
+ return;
347
+ const remaining = limit - captured;
348
+ if (remaining > 0) {
349
+ const retained = Buffer.from(bytes.subarray(0, remaining));
350
+ chunks.push(retained);
351
+ captured += retained.byteLength;
352
+ }
353
+ if (bytes.byteLength > remaining) {
354
+ controller?.overflow(captured, total);
355
+ }
285
356
  });
286
- pipe.on("end", () => resolve(Buffer.concat(chunks)));
287
- pipe.on("error", () => resolve(Buffer.concat(chunks)));
357
+ pipe.on("end", finish);
358
+ pipe.on("close", finish);
359
+ pipe.on("error", finish);
360
+ }).then(async (bytes) => {
361
+ await controller?.completed;
362
+ if (controller?.error)
363
+ throw controller.error;
364
+ return bytes;
288
365
  });
289
366
  return collected;
290
367
  };
291
368
  const toWebReadable = () => {
292
369
  if (!pipe) {
293
370
  return new ReadableStream({
294
- start(controller) {
295
- controller.close();
371
+ start(controller2) {
372
+ controller2.close();
296
373
  }
297
374
  });
298
375
  }
@@ -301,12 +378,12 @@ function streamFromNode(pipe) {
301
378
  return r.toWeb();
302
379
  }
303
380
  return new ReadableStream({
304
- start(controller) {
381
+ start(controller2) {
305
382
  pipe.on("data", (chunk) => {
306
- controller.enqueue(typeof chunk === "string" ? new TextEncoder().encode(chunk) : new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
383
+ controller2.enqueue(typeof chunk === "string" ? new TextEncoder().encode(chunk) : new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
307
384
  });
308
- pipe.on("end", () => controller.close());
309
- pipe.on("error", (err) => controller.error(err));
385
+ pipe.on("end", () => controller2.close());
386
+ pipe.on("error", (err) => controller2.error(err));
310
387
  },
311
388
  cancel() {
312
389
  const destroyable = pipe;
@@ -318,7 +395,7 @@ function streamFromNode(pipe) {
318
395
  }
319
396
  });
320
397
  };
321
- return {
398
+ const result = {
322
399
  async text() {
323
400
  return (await collect()).toString("utf-8");
324
401
  },
@@ -327,18 +404,27 @@ function streamFromNode(pipe) {
327
404
  return new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
328
405
  },
329
406
  getReader() {
330
- if (readerClaimed || collected) {
407
+ if (mode !== undefined) {
331
408
  throw new TypeError("Subprocess output is already consumed");
332
409
  }
333
- readerClaimed = true;
410
+ mode = "reader";
334
411
  return toWebReadable().getReader();
335
412
  }
336
413
  };
414
+ if (pipe && controller && limit !== undefined) {
415
+ queueMicrotask(() => {
416
+ if (mode === undefined)
417
+ collect().catch(() => {
418
+ return;
419
+ });
420
+ });
421
+ }
422
+ return result;
337
423
  }
338
424
  function mapStdio(v) {
339
425
  return v ?? "pipe";
340
426
  }
341
- function streamFromBun(stream) {
427
+ function streamFromBun(stream, limit, controller) {
342
428
  if (!stream || typeof stream !== "object") {
343
429
  const empty = {
344
430
  async text() {
@@ -349,8 +435,8 @@ function streamFromBun(stream) {
349
435
  },
350
436
  getReader() {
351
437
  return new ReadableStream({
352
- start(controller) {
353
- controller.close();
438
+ start(controller2) {
439
+ controller2.close();
354
440
  }
355
441
  }).getReader();
356
442
  }
@@ -358,36 +444,82 @@ function streamFromBun(stream) {
358
444
  return empty;
359
445
  }
360
446
  const candidate = stream;
361
- const collect = async () => {
362
- if (typeof candidate.getReader !== "function") {
363
- return new Uint8Array(0);
364
- }
365
- const reader = candidate.getReader();
366
- const chunks = [];
367
- for (;; ) {
368
- const { done, value } = await reader.read();
369
- if (done)
370
- break;
371
- if (value)
372
- chunks.push(value);
373
- }
374
- const total = chunks.reduce((acc, c) => acc + c.byteLength, 0);
375
- const out = new Uint8Array(total);
376
- let off = 0;
377
- for (const c of chunks) {
378
- out.set(c, off);
379
- off += c.byteLength;
447
+ let mode;
448
+ let collected;
449
+ const collect = () => {
450
+ if (mode === "reader") {
451
+ return Promise.reject(new TypeError("Subprocess output is already consumed by a reader"));
380
452
  }
381
- return out;
453
+ mode = "buffered";
454
+ collected ??= (async () => {
455
+ if (typeof candidate.getReader !== "function")
456
+ return new Uint8Array(0);
457
+ const reader = candidate.getReader();
458
+ const chunks = [];
459
+ let captured = 0;
460
+ let total = 0;
461
+ try {
462
+ for (;; ) {
463
+ const { done, value } = await reader.read();
464
+ if (done)
465
+ break;
466
+ if (!value)
467
+ continue;
468
+ total += value.byteLength;
469
+ if (controller?.error || limit === undefined)
470
+ continue;
471
+ const remaining = limit - captured;
472
+ if (remaining > 0) {
473
+ const retained = value.slice(0, remaining);
474
+ chunks.push(retained);
475
+ captured += retained.byteLength;
476
+ }
477
+ if (value.byteLength > remaining) {
478
+ controller?.overflow(captured, total);
479
+ }
480
+ }
481
+ } finally {
482
+ reader.releaseLock();
483
+ }
484
+ await controller?.completed;
485
+ if (controller?.error)
486
+ throw controller.error;
487
+ const out = new Uint8Array(captured);
488
+ let offset = 0;
489
+ for (const chunk of chunks) {
490
+ out.set(chunk, offset);
491
+ offset += chunk.byteLength;
492
+ }
493
+ return out;
494
+ })();
495
+ return collected;
382
496
  };
383
- const text = typeof candidate.text === "function" ? () => candidate.text() : async () => new TextDecoder().decode(await collect());
384
- const bytes = typeof candidate.bytes === "function" ? () => candidate.bytes() : collect;
385
- const getReader = typeof candidate.getReader === "function" ? () => candidate.getReader() : () => new ReadableStream({
386
- start(controller) {
387
- controller.close();
497
+ const result = {
498
+ async text() {
499
+ return new TextDecoder().decode(await collect());
500
+ },
501
+ bytes: collect,
502
+ getReader() {
503
+ if (mode !== undefined) {
504
+ throw new TypeError("Subprocess output is already consumed");
505
+ }
506
+ mode = "reader";
507
+ return typeof candidate.getReader === "function" ? candidate.getReader() : new ReadableStream({
508
+ start(streamController) {
509
+ streamController.close();
510
+ }
511
+ }).getReader();
388
512
  }
389
- }).getReader();
390
- return { text, bytes, getReader };
513
+ };
514
+ if (typeof candidate.getReader === "function" && controller && limit !== undefined) {
515
+ queueMicrotask(() => {
516
+ if (mode === undefined)
517
+ collect().catch(() => {
518
+ return;
519
+ });
520
+ });
521
+ }
522
+ return result;
391
523
  }
392
524
  function mergeEnvForChild(baseEnv, envOverrides) {
393
525
  const hasExplicitBaseEnv = baseEnv !== undefined;
@@ -448,11 +580,13 @@ function spawnCreationFailure(error) {
448
580
  };
449
581
  }
450
582
  function bunSpawn(cmd, options) {
583
+ const maxBuffer = normalizedMaxBuffer(options?.maxBuffer);
451
584
  const bun = getBun();
452
585
  if (bun?.spawn) {
453
586
  const mergedEnv2 = mergeEnvForChild(options?.env, options?.envOverrides);
454
587
  const spawnOpts = { ...options };
455
588
  delete spawnOpts.killProcessTree;
589
+ delete spawnOpts.maxBuffer;
456
590
  if (mergedEnv2 !== undefined)
457
591
  spawnOpts.env = mergedEnv2;
458
592
  if (options?.timeout && options.timeout > 0 && options.killProcessTree !== true) {
@@ -472,6 +606,11 @@ function bunSpawn(cmd, options) {
472
606
  const proc2 = spawned;
473
607
  const killBunTree = createProcessTreeKiller(proc2.pid, (sig) => proc2.kill(sig), true);
474
608
  const killBunProcess = (sig) => options?.killProcessTree ? killBunTree(sig) : Promise.resolve(proc2.kill(sig));
609
+ const outputController2 = createOutputOverflowController(maxBuffer, () => {
610
+ killBunProcess("SIGKILL").catch(() => {
611
+ return;
612
+ });
613
+ });
475
614
  let timeoutHandle2;
476
615
  if (options?.killProcessTree === true && options.timeout && options.timeout > 0) {
477
616
  timeoutHandle2 = setTimeout(() => {
@@ -487,10 +626,11 @@ function bunSpawn(cmd, options) {
487
626
  const exited2 = proc2.exited.finally(() => {
488
627
  if (timeoutHandle2 !== undefined)
489
628
  clearTimeout(timeoutHandle2);
629
+ outputController2.complete();
490
630
  });
491
631
  return {
492
- stdout: streamFromBun(proc2.stdout),
493
- stderr: streamFromBun(proc2.stderr),
632
+ stdout: streamFromBun(proc2.stdout, maxBuffer, outputController2),
633
+ stderr: streamFromBun(proc2.stderr, maxBuffer, outputController2),
494
634
  exited: exited2,
495
635
  get exitCode() {
496
636
  return proc2.exitCode;
@@ -533,6 +673,11 @@ function bunSpawn(cmd, options) {
533
673
  proc.kill(signal);
534
674
  return Promise.resolve();
535
675
  };
676
+ const outputController = createOutputOverflowController(maxBuffer, () => {
677
+ killChild("SIGKILL").catch(() => {
678
+ return;
679
+ });
680
+ });
536
681
  let timeoutHandle;
537
682
  let observedSignal = null;
538
683
  let observedSpawnError = null;
@@ -560,10 +705,11 @@ function bunSpawn(cmd, options) {
560
705
  }).finally(() => {
561
706
  if (timeoutHandle !== undefined)
562
707
  clearTimeout(timeoutHandle);
708
+ outputController.complete();
563
709
  });
564
710
  return {
565
- stdout: streamFromNode(proc.stdout),
566
- stderr: streamFromNode(proc.stderr),
711
+ stdout: streamFromNode(proc.stdout, maxBuffer, outputController),
712
+ stderr: streamFromNode(proc.stderr, maxBuffer, outputController),
567
713
  exited,
568
714
  get exitCode() {
569
715
  return observedSpawnError ? null : proc.exitCode;
@@ -596,7 +742,10 @@ function bunSpawnSync(cmd, options) {
596
742
  const bun = getBun();
597
743
  if (bun?.spawnSync) {
598
744
  const mergedEnv2 = mergeEnvForChild(options?.env, options?.envOverrides);
599
- const spawnOpts = mergedEnv2 !== undefined ? { ...options, env: mergedEnv2 } : options;
745
+ const spawnOpts = { ...options };
746
+ delete spawnOpts.maxBuffer;
747
+ if (mergedEnv2 !== undefined)
748
+ spawnOpts.env = mergedEnv2;
600
749
  try {
601
750
  return bun.spawnSync(cmd, spawnOpts);
602
751
  } catch (error) {
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  authorizeCuration
4
- } from "./index-m35hybf0.js";
4
+ } from "./index-bm5xrfnx.js";
5
5
  import {
6
6
  findNearDuplicate,
7
7
  inferTags,
@@ -9,13 +9,13 @@ import {
9
9
  resolveSwarmKnowledgePath,
10
10
  resolveSwarmRejectedPath,
11
11
  transactKnowledge
12
- } from "./index-j950hqmq.js";
12
+ } from "./index-76ng6vmq.js";
13
13
  import {
14
14
  resolveKnowledgeStoreDir
15
- } from "./index-8ybjqg51.js";
15
+ } from "./index-9ttqbhvw.js";
16
16
  import {
17
17
  atomicWriteFile
18
- } from "./index-4r5pmtvk.js";
18
+ } from "./index-bx1wgn3a.js";
19
19
  import {
20
20
  require_proper_lockfile
21
21
  } from "./index-7g4c7s5r.js";
@@ -14,7 +14,7 @@ import {
14
14
  PluginConfigSchema,
15
15
  init_schema,
16
16
  resolveExternalSkillsConfig
17
- } from "./index-exatbqwj.js";
17
+ } from "./index-yj24ny5k.js";
18
18
  import {
19
19
  exports_external,
20
20
  init_zod