opencode-swarm 7.163.0 → 7.164.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.
- package/README.md +1 -1
- package/dist/cli/{coder-settlement-g2g5kkv5.js → coder-settlement-84je6bza.js} +8 -8
- package/dist/cli/{config-doctor-p16xr78z.js → config-doctor-vfze38e1.js} +2 -2
- package/dist/cli/{core-g088v0zt.js → core-q5hv8e2w.js} +1 -1
- package/dist/cli/{curation-policy-j12j2gvc.js → curation-policy-a2zty4br.js} +5 -5
- package/dist/cli/{curator-3m8a8qsn.js → curator-4pckmmyf.js} +32 -32
- package/dist/cli/{curator-drift-g6w4ga1q.js → curator-drift-wy7ejcvw.js} +105 -37
- package/dist/cli/{curator-llm-factory-p00hks4v.js → curator-llm-factory-msbj3hpn.js} +32 -32
- package/dist/cli/{evidence-summary-service-4ghqakhx.js → evidence-summary-service-b15yes21.js} +14 -14
- package/dist/cli/{gate-evidence-4v8apasx.js → gate-evidence-70h0w4tb.js} +5 -5
- package/dist/cli/{guardrail-explain-smqenqtm.js → guardrail-explain-kksdy032.js} +33 -33
- package/dist/cli/{guardrail-log-mmh4b4k4.js → guardrail-log-7rxbd20p.js} +6 -6
- package/dist/cli/{guardrail-reset-zge5hg4p.js → guardrail-reset-3b4gs357.js} +32 -32
- package/dist/cli/{hive-promoter-vxez5s7m.js → hive-promoter-s80g1gwb.js} +32 -32
- package/dist/cli/index-0515j0cz.js +403 -0
- package/dist/cli/{index-t4hs3qk6.js → index-12f1tsn2.js} +3 -3
- package/dist/cli/{index-2zgjcmmc.js → index-1b1h770t.js} +3 -3
- package/dist/cli/{index-9ss2m4rs.js → index-1hpjwz3s.js} +410 -1
- package/dist/cli/{index-4t68xs0p.js → index-1z4jzwja.js} +3 -3
- package/dist/cli/{index-0103w5pf.js → index-2s4s9n82.js} +2 -2
- package/dist/cli/{index-9crtmnqg.js → index-36nt17m8.js} +1 -1
- package/dist/cli/{index-qy2rm1f6.js → index-4afh2cz7.js} +5 -5
- package/dist/cli/{index-pykfqsk0.js → index-4jersar8.js} +4 -4
- package/dist/cli/{index-n67vx5zw.js → index-70bfj3v1.js} +1 -1
- package/dist/cli/{index-eqkdjfqa.js → index-7r9vpkwa.js} +4 -4
- package/dist/cli/{index-8ada7ag7.js → index-93sepnc9.js} +2 -2
- package/dist/cli/{index-s8c6f9rr.js → index-9sy65e94.js} +3 -3
- package/dist/cli/{index-ptsmms01.js → index-bm73pych.js} +6 -6
- package/dist/cli/{index-xyhmt813.js → index-c4pynht5.js} +1 -1
- package/dist/cli/{index-w1mc7gcm.js → index-c69jbpex.js} +2 -2
- package/dist/cli/{index-axx3t3k7.js → index-e3hwzcjv.js} +2 -2
- package/dist/cli/{index-453tzvkg.js → index-g64154pd.js} +1 -1
- package/dist/cli/{index-f7t5fn4z.js → index-gxd8fwyt.js} +4 -4
- package/dist/cli/{index-5hgn302x.js → index-hyq20s2v.js} +118 -296
- package/dist/cli/{index-7n9jznv0.js → index-ma8w6pfp.js} +3 -3
- package/dist/cli/{index-rqh25ns3.js → index-nhxaa9j5.js} +1 -1
- package/dist/cli/{index-zgz81a8x.js → index-nzrhw31r.js} +1 -1
- package/dist/cli/{index-4xggfhge.js → index-pvgcex0d.js} +3 -3
- package/dist/cli/{index-nwa7ctyf.js → index-qkk2skff.js} +34 -34
- package/dist/cli/{index-g4bvsapf.js → index-t5t82jy8.js} +5 -5
- package/dist/cli/{index-m4nhy4fp.js → index-t90gjc0k.js} +1 -1
- package/dist/cli/{index-3rjxbe1p.js → index-t9rhtvy9.js} +2 -2
- package/dist/cli/{index-hm239n1p.js → index-tb1k8jya.js} +1 -1
- package/dist/cli/{index-m7yt3xmk.js → index-td6n935w.js} +3 -2
- package/dist/cli/{index-w0yn4rmh.js → index-v3a9rmyh.js} +3 -3
- package/dist/cli/{index-cqgpvx2d.js → index-wdtckfnf.js} +1 -1
- package/dist/cli/{index-7wb2v7jg.js → index-xk0kc1py.js} +522 -358
- package/dist/cli/{index-n2mhyect.js → index-ynqp3jb6.js} +1 -1
- package/dist/cli/{index-n249fbw7.js → index-zaab1wz9.js} +5 -0
- package/dist/cli/{index-3ab9tczn.js → index-zbpcpsk0.js} +8 -8
- package/dist/cli/index.js +32 -32
- package/dist/cli/{knowledge-escalator-91d1n291.js → knowledge-escalator-sttdnwf8.js} +11 -11
- package/dist/cli/{knowledge-events-xrd9es3p.js → knowledge-events-4h88stj7.js} +9 -9
- package/dist/cli/{knowledge-link-vmdj5e5d.js → knowledge-link-yykmxdyw.js} +4 -4
- package/dist/cli/{knowledge-store-2brg88cx.js → knowledge-store-j832fxpx.js} +5 -5
- package/dist/cli/{knowledge-validator-s1v7kry2.js → knowledge-validator-edbg761g.js} +7 -7
- package/dist/cli/{pending-delegations-b341397j.js → pending-delegations-sphntrs0.js} +4 -4
- package/dist/cli/{pr-subscriptions-2mkdt0ak.js → pr-subscriptions-1a4gcnzv.js} +4 -4
- package/dist/cli/{runner-3gw2njnx.js → runner-d294h1by.js} +5 -5
- package/dist/cli/{scan-cursor-jm7j3w1c.js → scan-cursor-5frvp7nb.js} +6 -6
- package/dist/cli/{schema-6cpgnq4s.js → schema-9xkt5hvd.js} +1 -1
- package/dist/cli/{scope-persistence-q713ck5n.js → scope-persistence-gk55h3sp.js} +8 -8
- package/dist/cli/{skill-generator-z9bs6vdt.js → skill-generator-sxxf7jbb.js} +13 -13
- package/dist/cli/{sqlite-loader-c92413n7.js → sqlite-loader-8zefc142.js} +1 -1
- package/dist/cli/{telemetry-x4zggfd7.js → telemetry-q51s6tyt.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-drtv7jjp.js → worktree-collision-ownership-7kj2ryt1.js} +4 -4
- package/dist/cli/{worktree-isolation-534h3c2f.js → worktree-isolation-67fs6rz9.js} +32 -32
- package/dist/db/canonical-project.d.ts +31 -0
- package/dist/db/db-errors.d.ts +24 -0
- package/dist/db/driver-parity.d.ts +31 -0
- package/dist/db/durability.d.ts +40 -0
- package/dist/db/group-commit-writer.d.ts +117 -0
- package/dist/db/health.d.ts +35 -0
- package/dist/db/insight-candidate-store.d.ts +61 -0
- package/dist/db/legacy-import.d.ts +77 -0
- package/dist/db/phase-report-store.d.ts +45 -0
- package/dist/db/project-db.d.ts +35 -8
- package/dist/db/qa-gate-profile.d.ts +2 -0
- package/dist/hooks/curator-drift.d.ts +9 -5
- package/dist/hooks/curator-types.d.ts +1 -0
- package/dist/hooks/knowledge-curator.d.ts +5 -3
- package/dist/hooks/micro-reflector.d.ts +12 -7
- package/dist/index.js +619 -567
- package/dist/memory/schema.d.ts +4 -4
- package/dist/prm/index.d.ts +3 -1
- package/package.json +3 -2
- package/dist/cli/index-c8s9a3zh.js +0 -73
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
handleGuardrailLog
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
4
|
+
} from "./index-t90gjc0k.js";
|
|
5
|
+
import"./index-9sy65e94.js";
|
|
6
|
+
import"./index-93sepnc9.js";
|
|
7
7
|
import"./index-556ja8an.js";
|
|
8
8
|
import"./index-z6xqpmqg.js";
|
|
9
9
|
import"./index-r3mvsbtq.js";
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
import"./index-td6n935w.js";
|
|
11
|
+
import"./index-wdtckfnf.js";
|
|
12
12
|
import"./index-9xd073d4.js";
|
|
13
13
|
import"./index-zjygnfay.js";
|
|
14
14
|
import"./index-bk5tah7q.js";
|
|
15
15
|
import"./index-3b762978.js";
|
|
16
|
-
import"./index-
|
|
16
|
+
import"./index-1b1h770t.js";
|
|
17
17
|
import"./index-ed5ykebp.js";
|
|
18
18
|
import"./index-bpmtbmy9.js";
|
|
19
19
|
import"./index-zgwm4ryv.js";
|
|
@@ -3,64 +3,64 @@ import {
|
|
|
3
3
|
getAgentSession,
|
|
4
4
|
getBlockingActionCircuit,
|
|
5
5
|
resetActionCircuitExternally
|
|
6
|
-
} from "./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
6
|
+
} from "./index-xk0kc1py.js";
|
|
7
|
+
import"./index-c4pynht5.js";
|
|
8
|
+
import"./index-9sy65e94.js";
|
|
9
|
+
import"./index-g64154pd.js";
|
|
10
|
+
import"./index-hyq20s2v.js";
|
|
11
|
+
import"./index-2s4s9n82.js";
|
|
12
12
|
import"./index-txdagbh7.js";
|
|
13
|
-
import"./index-n249fbw7.js";
|
|
14
13
|
import"./index-3146wmgv.js";
|
|
15
|
-
import"./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
14
|
+
import"./index-pvgcex0d.js";
|
|
15
|
+
import"./index-t5t82jy8.js";
|
|
16
|
+
import"./index-e3hwzcjv.js";
|
|
18
17
|
import"./index-70ha9e09.js";
|
|
19
|
-
import"./index-
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
18
|
+
import"./index-0515j0cz.js";
|
|
19
|
+
import"./index-1hpjwz3s.js";
|
|
20
|
+
import"./index-zaab1wz9.js";
|
|
21
|
+
import"./index-ma8w6pfp.js";
|
|
22
22
|
import"./index-zsrtt42s.js";
|
|
23
|
-
import"./index-
|
|
23
|
+
import"./index-4afh2cz7.js";
|
|
24
24
|
import"./index-3f7hqtgg.js";
|
|
25
25
|
import"./index-fckfgptr.js";
|
|
26
|
-
import"./index-
|
|
27
|
-
import"./index-
|
|
26
|
+
import"./index-gxd8fwyt.js";
|
|
27
|
+
import"./index-tb1k8jya.js";
|
|
28
28
|
import"./index-rtry5xyf.js";
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
31
|
-
import"./index-
|
|
29
|
+
import"./index-7r9vpkwa.js";
|
|
30
|
+
import"./index-nzrhw31r.js";
|
|
31
|
+
import"./index-12f1tsn2.js";
|
|
32
32
|
import"./index-ddszzne4.js";
|
|
33
33
|
import"./index-mmngnxev.js";
|
|
34
34
|
import"./index-w7ekntej.js";
|
|
35
|
-
import"./index-
|
|
36
|
-
import"./index-
|
|
37
|
-
import"./index-
|
|
35
|
+
import"./index-4jersar8.js";
|
|
36
|
+
import"./index-1z4jzwja.js";
|
|
37
|
+
import"./index-93sepnc9.js";
|
|
38
38
|
import"./index-556ja8an.js";
|
|
39
39
|
import"./index-4fwbbad3.js";
|
|
40
40
|
import"./index-b43rt5ph.js";
|
|
41
41
|
import"./index-q7sjgr1y.js";
|
|
42
|
-
import"./index-
|
|
43
|
-
import"./index-
|
|
44
|
-
import"./index-
|
|
42
|
+
import"./index-bm73pych.js";
|
|
43
|
+
import"./index-zbpcpsk0.js";
|
|
44
|
+
import"./index-t9rhtvy9.js";
|
|
45
45
|
import"./index-zg9d392c.js";
|
|
46
46
|
import"./index-n832052r.js";
|
|
47
47
|
import"./index-dtn0pne5.js";
|
|
48
48
|
import"./index-z6xqpmqg.js";
|
|
49
49
|
import"./index-r3mvsbtq.js";
|
|
50
|
-
import"./index-
|
|
51
|
-
import"./index-
|
|
50
|
+
import"./index-nhxaa9j5.js";
|
|
51
|
+
import"./index-td6n935w.js";
|
|
52
52
|
import"./index-9e6fdz2h.js";
|
|
53
53
|
import"./index-4rhhvd1a.js";
|
|
54
|
-
import"./index-
|
|
54
|
+
import"./index-wdtckfnf.js";
|
|
55
55
|
import"./index-9xd073d4.js";
|
|
56
56
|
import"./index-zjygnfay.js";
|
|
57
57
|
import"./index-ae75rja9.js";
|
|
58
|
-
import"./index-
|
|
59
|
-
import"./index-
|
|
58
|
+
import"./index-ynqp3jb6.js";
|
|
59
|
+
import"./index-70bfj3v1.js";
|
|
60
60
|
import"./index-bk5tah7q.js";
|
|
61
|
-
import"./index-
|
|
61
|
+
import"./index-36nt17m8.js";
|
|
62
62
|
import"./index-3b762978.js";
|
|
63
|
-
import"./index-
|
|
63
|
+
import"./index-1b1h770t.js";
|
|
64
64
|
import"./index-ed5ykebp.js";
|
|
65
65
|
import"./index-7g4c7s5r.js";
|
|
66
66
|
import"./index-bpmtbmy9.js";
|
|
@@ -7,66 +7,66 @@ import {
|
|
|
7
7
|
isHiveEligible,
|
|
8
8
|
promoteFromSwarm,
|
|
9
9
|
promoteToHive
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
15
|
-
import"./index-
|
|
10
|
+
} from "./index-xk0kc1py.js";
|
|
11
|
+
import"./index-c4pynht5.js";
|
|
12
|
+
import"./index-9sy65e94.js";
|
|
13
|
+
import"./index-g64154pd.js";
|
|
14
|
+
import"./index-hyq20s2v.js";
|
|
15
|
+
import"./index-2s4s9n82.js";
|
|
16
16
|
import"./index-txdagbh7.js";
|
|
17
|
-
import"./index-n249fbw7.js";
|
|
18
17
|
import"./index-3146wmgv.js";
|
|
19
|
-
import"./index-
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
18
|
+
import"./index-pvgcex0d.js";
|
|
19
|
+
import"./index-t5t82jy8.js";
|
|
20
|
+
import"./index-e3hwzcjv.js";
|
|
22
21
|
import"./index-70ha9e09.js";
|
|
23
|
-
import"./index-
|
|
24
|
-
import"./index-
|
|
25
|
-
import"./index-
|
|
22
|
+
import"./index-0515j0cz.js";
|
|
23
|
+
import"./index-1hpjwz3s.js";
|
|
24
|
+
import"./index-zaab1wz9.js";
|
|
25
|
+
import"./index-ma8w6pfp.js";
|
|
26
26
|
import"./index-zsrtt42s.js";
|
|
27
|
-
import"./index-
|
|
27
|
+
import"./index-4afh2cz7.js";
|
|
28
28
|
import"./index-3f7hqtgg.js";
|
|
29
29
|
import"./index-fckfgptr.js";
|
|
30
|
-
import"./index-
|
|
31
|
-
import"./index-
|
|
30
|
+
import"./index-gxd8fwyt.js";
|
|
31
|
+
import"./index-tb1k8jya.js";
|
|
32
32
|
import"./index-rtry5xyf.js";
|
|
33
|
-
import"./index-
|
|
34
|
-
import"./index-
|
|
35
|
-
import"./index-
|
|
33
|
+
import"./index-7r9vpkwa.js";
|
|
34
|
+
import"./index-nzrhw31r.js";
|
|
35
|
+
import"./index-12f1tsn2.js";
|
|
36
36
|
import"./index-ddszzne4.js";
|
|
37
37
|
import"./index-mmngnxev.js";
|
|
38
38
|
import"./index-w7ekntej.js";
|
|
39
|
-
import"./index-
|
|
40
|
-
import"./index-
|
|
41
|
-
import"./index-
|
|
39
|
+
import"./index-4jersar8.js";
|
|
40
|
+
import"./index-1z4jzwja.js";
|
|
41
|
+
import"./index-93sepnc9.js";
|
|
42
42
|
import"./index-556ja8an.js";
|
|
43
43
|
import"./index-4fwbbad3.js";
|
|
44
44
|
import"./index-b43rt5ph.js";
|
|
45
45
|
import"./index-q7sjgr1y.js";
|
|
46
46
|
import {
|
|
47
47
|
resolveHiveKnowledgePath
|
|
48
|
-
} from "./index-
|
|
49
|
-
import"./index-
|
|
50
|
-
import"./index-
|
|
48
|
+
} from "./index-bm73pych.js";
|
|
49
|
+
import"./index-zbpcpsk0.js";
|
|
50
|
+
import"./index-t9rhtvy9.js";
|
|
51
51
|
import"./index-zg9d392c.js";
|
|
52
52
|
import"./index-n832052r.js";
|
|
53
53
|
import"./index-dtn0pne5.js";
|
|
54
54
|
import"./index-z6xqpmqg.js";
|
|
55
55
|
import"./index-r3mvsbtq.js";
|
|
56
|
-
import"./index-
|
|
57
|
-
import"./index-
|
|
56
|
+
import"./index-nhxaa9j5.js";
|
|
57
|
+
import"./index-td6n935w.js";
|
|
58
58
|
import"./index-9e6fdz2h.js";
|
|
59
59
|
import"./index-4rhhvd1a.js";
|
|
60
|
-
import"./index-
|
|
60
|
+
import"./index-wdtckfnf.js";
|
|
61
61
|
import"./index-9xd073d4.js";
|
|
62
62
|
import"./index-zjygnfay.js";
|
|
63
63
|
import"./index-ae75rja9.js";
|
|
64
|
-
import"./index-
|
|
65
|
-
import"./index-
|
|
64
|
+
import"./index-ynqp3jb6.js";
|
|
65
|
+
import"./index-70bfj3v1.js";
|
|
66
66
|
import"./index-bk5tah7q.js";
|
|
67
|
-
import"./index-
|
|
67
|
+
import"./index-36nt17m8.js";
|
|
68
68
|
import"./index-3b762978.js";
|
|
69
|
-
import"./index-
|
|
69
|
+
import"./index-1b1h770t.js";
|
|
70
70
|
import"./index-ed5ykebp.js";
|
|
71
71
|
import"./index-7g4c7s5r.js";
|
|
72
72
|
import"./index-bpmtbmy9.js";
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
DbWriteError,
|
|
4
|
+
applySynchronousForClass,
|
|
5
|
+
batchDurabilityClass,
|
|
6
|
+
canonicalProjectKey,
|
|
7
|
+
classifyDbWriteError,
|
|
8
|
+
getProjectDb
|
|
9
|
+
} from "./index-1hpjwz3s.js";
|
|
10
|
+
import {
|
|
11
|
+
init_logger,
|
|
12
|
+
log,
|
|
13
|
+
warn
|
|
14
|
+
} from "./index-zgwm4ryv.js";
|
|
15
|
+
|
|
16
|
+
// src/background/event-bus.ts
|
|
17
|
+
class AutomationEventBus {
|
|
18
|
+
listeners = new Map;
|
|
19
|
+
eventHistory = [];
|
|
20
|
+
maxHistorySize;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.maxHistorySize = options?.maxHistorySize ?? 100;
|
|
23
|
+
}
|
|
24
|
+
subscribe(type, listener) {
|
|
25
|
+
if (!this.listeners.has(type)) {
|
|
26
|
+
this.listeners.set(type, new Set);
|
|
27
|
+
}
|
|
28
|
+
this.listeners.get(type).add(listener);
|
|
29
|
+
return () => {
|
|
30
|
+
this.listeners.get(type)?.delete(listener);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async publish(type, payload, source) {
|
|
34
|
+
const event = {
|
|
35
|
+
type,
|
|
36
|
+
timestamp: Date.now(),
|
|
37
|
+
payload,
|
|
38
|
+
source
|
|
39
|
+
};
|
|
40
|
+
this.eventHistory.push(event);
|
|
41
|
+
if (this.eventHistory.length > this.maxHistorySize) {
|
|
42
|
+
this.eventHistory.shift();
|
|
43
|
+
}
|
|
44
|
+
log(`[EventBus] ${type}`, {
|
|
45
|
+
source,
|
|
46
|
+
payload: typeof payload === "object" ? "..." : payload
|
|
47
|
+
});
|
|
48
|
+
const listeners = this.listeners.get(type);
|
|
49
|
+
if (listeners) {
|
|
50
|
+
await Promise.all(Array.from(listeners).map(async (listener) => {
|
|
51
|
+
try {
|
|
52
|
+
await listener(event);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
log(`[EventBus] Listener error for ${type}`, { error });
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getHistory(types) {
|
|
60
|
+
if (!types || types.length === 0) {
|
|
61
|
+
return [...this.eventHistory];
|
|
62
|
+
}
|
|
63
|
+
return this.eventHistory.filter((e) => types.includes(e.type));
|
|
64
|
+
}
|
|
65
|
+
clearHistory() {
|
|
66
|
+
this.eventHistory = [];
|
|
67
|
+
}
|
|
68
|
+
getListenerCount(type) {
|
|
69
|
+
return this.listeners.get(type)?.size ?? 0;
|
|
70
|
+
}
|
|
71
|
+
hasListeners(type) {
|
|
72
|
+
return this.getListenerCount(type) > 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var globalEventBus = null;
|
|
76
|
+
function getGlobalEventBus() {
|
|
77
|
+
if (!globalEventBus) {
|
|
78
|
+
globalEventBus = new AutomationEventBus;
|
|
79
|
+
}
|
|
80
|
+
return globalEventBus;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/db/group-commit-writer.ts
|
|
84
|
+
init_logger();
|
|
85
|
+
function isClosedHandleError(err) {
|
|
86
|
+
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
|
87
|
+
return msg.includes("database has closed") || msg.includes("database is closed") || msg.includes("cannot use a closed database") || msg.includes("database is not open");
|
|
88
|
+
}
|
|
89
|
+
var MAX_QUEUED_OPS = 1024;
|
|
90
|
+
var FLUSH_THRESHOLD_OPS = 64;
|
|
91
|
+
var DEGRADED_COOLDOWN_MS = 60000;
|
|
92
|
+
var _writers = new Map;
|
|
93
|
+
var _internals = {
|
|
94
|
+
getProjectDb,
|
|
95
|
+
isClosedHandleError
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
class GroupCommitWriter {
|
|
99
|
+
db;
|
|
100
|
+
queue = [];
|
|
101
|
+
flushing = false;
|
|
102
|
+
degraded = null;
|
|
103
|
+
lastAdvisoryAt = 0;
|
|
104
|
+
closed = false;
|
|
105
|
+
registryKey = null;
|
|
106
|
+
constructor(db) {
|
|
107
|
+
this.db = db;
|
|
108
|
+
}
|
|
109
|
+
get queuedOpCount() {
|
|
110
|
+
return this.queue.length;
|
|
111
|
+
}
|
|
112
|
+
bindRegistryKey(key) {
|
|
113
|
+
this.registryKey = key;
|
|
114
|
+
}
|
|
115
|
+
enqueue(op) {
|
|
116
|
+
if (this.closed) {
|
|
117
|
+
throw new DbWriteError("unknown", "group-commit writer is closed");
|
|
118
|
+
}
|
|
119
|
+
if (this.queue.length >= MAX_QUEUED_OPS) {
|
|
120
|
+
this.flushSync();
|
|
121
|
+
}
|
|
122
|
+
this.queue.push(op);
|
|
123
|
+
if (this.queue.length >= FLUSH_THRESHOLD_OPS) {
|
|
124
|
+
this.flushSync();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
flushSync() {
|
|
128
|
+
if (this.closed || this.flushing || this.queue.length === 0)
|
|
129
|
+
return;
|
|
130
|
+
this.flushing = true;
|
|
131
|
+
const batch = this.queue;
|
|
132
|
+
this.queue = [];
|
|
133
|
+
try {
|
|
134
|
+
try {
|
|
135
|
+
this.applyBatch(batch);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (!isClosedHandleError(err) || this.registryKey === null)
|
|
138
|
+
throw err;
|
|
139
|
+
this.db = _internals.getProjectDb(this.registryKey);
|
|
140
|
+
this.applyBatch(batch);
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
const category = classifyDbWriteError(err);
|
|
144
|
+
if (isClosedHandleError(err)) {
|
|
145
|
+
this.close();
|
|
146
|
+
if (this.registryKey !== null)
|
|
147
|
+
_writers.delete(this.registryKey);
|
|
148
|
+
}
|
|
149
|
+
if (category === "busy" || category === "disk_full" || category === "read_only") {
|
|
150
|
+
this.queue = [...batch, ...this.queue];
|
|
151
|
+
this.noteDegraded(category);
|
|
152
|
+
} else {
|
|
153
|
+
this.noteDegraded(category);
|
|
154
|
+
}
|
|
155
|
+
throw new DbWriteError(category, `swarm.db group-commit flush failed (${category}): ${err instanceof Error ? err.message : String(err)}`);
|
|
156
|
+
} finally {
|
|
157
|
+
this.flushing = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async flush() {
|
|
161
|
+
this.flushSync();
|
|
162
|
+
}
|
|
163
|
+
close() {
|
|
164
|
+
this.closed = true;
|
|
165
|
+
this.queue = [];
|
|
166
|
+
}
|
|
167
|
+
applyBatch(batch) {
|
|
168
|
+
const cls = batchDurabilityClass(batch.map((op) => op.durability));
|
|
169
|
+
applySynchronousForClass(this.db, cls);
|
|
170
|
+
try {
|
|
171
|
+
this.db.run("BEGIN IMMEDIATE");
|
|
172
|
+
} catch (err) {
|
|
173
|
+
applySynchronousForClass(this.db, "normal");
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
for (const op of batch) {
|
|
178
|
+
op.run(this.db);
|
|
179
|
+
}
|
|
180
|
+
this.db.run("COMMIT");
|
|
181
|
+
} catch (err) {
|
|
182
|
+
try {
|
|
183
|
+
this.db.run("ROLLBACK");
|
|
184
|
+
} catch {}
|
|
185
|
+
throw err;
|
|
186
|
+
} finally {
|
|
187
|
+
applySynchronousForClass(this.db, "normal");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
noteDegraded(category) {
|
|
191
|
+
const now = Date.now();
|
|
192
|
+
this.degraded = { category, until: now + DEGRADED_COOLDOWN_MS };
|
|
193
|
+
if (now - this.lastAdvisoryAt < DEGRADED_COOLDOWN_MS)
|
|
194
|
+
return;
|
|
195
|
+
this.lastAdvisoryAt = now;
|
|
196
|
+
warn(`[swarm.db] durable-state writer degraded (category=${category}); queued writes retry on the next flush`);
|
|
197
|
+
}
|
|
198
|
+
get degradation() {
|
|
199
|
+
if (!this.degraded)
|
|
200
|
+
return null;
|
|
201
|
+
if (Date.now() > this.degraded.until)
|
|
202
|
+
return null;
|
|
203
|
+
return this.degraded;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function getGroupCommitWriter(directory) {
|
|
207
|
+
const key = canonicalProjectKey(directory);
|
|
208
|
+
let writer = _writers.get(key);
|
|
209
|
+
if (!writer) {
|
|
210
|
+
writer = new GroupCommitWriter(getProjectDb(directory));
|
|
211
|
+
writer.bindRegistryKey(key);
|
|
212
|
+
_writers.set(key, writer);
|
|
213
|
+
}
|
|
214
|
+
return writer;
|
|
215
|
+
}
|
|
216
|
+
function closeGroupCommitWriter(directory) {
|
|
217
|
+
const key = canonicalProjectKey(directory);
|
|
218
|
+
const writer = _writers.get(key);
|
|
219
|
+
if (writer) {
|
|
220
|
+
try {
|
|
221
|
+
writer.flushSync();
|
|
222
|
+
} catch {}
|
|
223
|
+
writer.close();
|
|
224
|
+
_writers.delete(key);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/db/legacy-import.ts
|
|
229
|
+
init_logger();
|
|
230
|
+
import {
|
|
231
|
+
existsSync,
|
|
232
|
+
readdirSync,
|
|
233
|
+
readFileSync,
|
|
234
|
+
renameSync,
|
|
235
|
+
statSync
|
|
236
|
+
} from "fs";
|
|
237
|
+
import { join } from "path";
|
|
238
|
+
var RENAME_RETRIES = 20;
|
|
239
|
+
var RENAME_RETRY_DELAY_MS = 5;
|
|
240
|
+
var warnedStaleLegacy = new Set;
|
|
241
|
+
var MAX_LEGACY_IMPORT_BYTES = 32 * 1024 * 1024;
|
|
242
|
+
function sleepSync(ms) {
|
|
243
|
+
const shared = new SharedArrayBuffer(4);
|
|
244
|
+
Atomics.wait(new Int32Array(shared), 0, 0, ms);
|
|
245
|
+
}
|
|
246
|
+
function renameWithRetry(from, to) {
|
|
247
|
+
let lastErr;
|
|
248
|
+
for (let attempt = 0;attempt < RENAME_RETRIES; attempt++) {
|
|
249
|
+
try {
|
|
250
|
+
_internals2.renameSync(from, to);
|
|
251
|
+
return;
|
|
252
|
+
} catch (err) {
|
|
253
|
+
lastErr = err;
|
|
254
|
+
const code = err?.code;
|
|
255
|
+
if (code !== "EPERM" && code !== "EACCES" && code !== "EBUSY")
|
|
256
|
+
throw err;
|
|
257
|
+
sleepSync(RENAME_RETRY_DELAY_MS);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
throw lastErr;
|
|
261
|
+
}
|
|
262
|
+
function warnStaleLegacyOnce(key, fileName) {
|
|
263
|
+
const guard = `${key}::${fileName}`;
|
|
264
|
+
if (warnedStaleLegacy.has(guard))
|
|
265
|
+
return;
|
|
266
|
+
warnedStaleLegacy.add(guard);
|
|
267
|
+
warn(`[swarm.db] legacy artifact ${fileName} is present but the target table is non-empty; leaving the file untouched (it is inert \u2014 readers use swarm.db)`);
|
|
268
|
+
}
|
|
269
|
+
var _internals2 = {
|
|
270
|
+
renameSync,
|
|
271
|
+
warnStaleLegacyOnce,
|
|
272
|
+
maxLegacyImportBytes: () => MAX_LEGACY_IMPORT_BYTES
|
|
273
|
+
};
|
|
274
|
+
function importLegacyJsonl(directory, opts) {
|
|
275
|
+
const root = canonicalProjectKey(directory);
|
|
276
|
+
const filePath = join(root, ".swarm", opts.fileName);
|
|
277
|
+
if (!existsSync(filePath)) {
|
|
278
|
+
return { imported: 0, skipped: 0, archived: false };
|
|
279
|
+
}
|
|
280
|
+
const db = getProjectDb(directory);
|
|
281
|
+
let content;
|
|
282
|
+
try {
|
|
283
|
+
if (statSync(filePath).size > _internals2.maxLegacyImportBytes()) {
|
|
284
|
+
warn(`[swarm.db] legacy artifact ${opts.fileName} exceeds the import size cap; leaving it inert (not imported, not renamed)`);
|
|
285
|
+
return { imported: 0, skipped: 0, archived: false };
|
|
286
|
+
}
|
|
287
|
+
content = readFileSync(filePath, "utf-8");
|
|
288
|
+
} catch {
|
|
289
|
+
return { imported: 0, skipped: 0, archived: false };
|
|
290
|
+
}
|
|
291
|
+
const payloads = [];
|
|
292
|
+
let skipped = 0;
|
|
293
|
+
for (const line of content.split(`
|
|
294
|
+
`)) {
|
|
295
|
+
const trimmed = line.trim();
|
|
296
|
+
if (!trimmed)
|
|
297
|
+
continue;
|
|
298
|
+
const payload = opts.parseLine(trimmed);
|
|
299
|
+
if (payload === null) {
|
|
300
|
+
skipped++;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
payloads.push(payload);
|
|
304
|
+
}
|
|
305
|
+
let imported = 0;
|
|
306
|
+
db.run("BEGIN IMMEDIATE");
|
|
307
|
+
try {
|
|
308
|
+
if (opts.streamCount(db) === 0) {
|
|
309
|
+
for (const payload of payloads) {
|
|
310
|
+
imported += 1;
|
|
311
|
+
opts.insertRow(db, imported, payload);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
db.run("COMMIT");
|
|
315
|
+
} catch (err) {
|
|
316
|
+
try {
|
|
317
|
+
db.run("ROLLBACK");
|
|
318
|
+
} catch {}
|
|
319
|
+
throw err;
|
|
320
|
+
}
|
|
321
|
+
if (imported > 0) {
|
|
322
|
+
try {
|
|
323
|
+
renameWithRetry(filePath, `${filePath}.imported`);
|
|
324
|
+
return { imported, skipped, archived: true };
|
|
325
|
+
} catch {
|
|
326
|
+
return { imported, skipped, archived: false };
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (payloads.length > 0) {
|
|
330
|
+
_internals2.warnStaleLegacyOnce(root, opts.fileName);
|
|
331
|
+
}
|
|
332
|
+
return { imported: 0, skipped, archived: false };
|
|
333
|
+
}
|
|
334
|
+
function importLegacyJsonFiles(directory, opts) {
|
|
335
|
+
const root = canonicalProjectKey(directory);
|
|
336
|
+
const swarmDir = join(root, ".swarm");
|
|
337
|
+
let entries;
|
|
338
|
+
try {
|
|
339
|
+
entries = readdirSync(swarmDir);
|
|
340
|
+
} catch {
|
|
341
|
+
return { imported: 0, skipped: 0, archived: false };
|
|
342
|
+
}
|
|
343
|
+
const suffix = ".json";
|
|
344
|
+
const phaseRe = new RegExp(`^${opts.filePrefix}(\\d+)\\${suffix}$`);
|
|
345
|
+
const files = entries.filter((name) => name.startsWith(opts.filePrefix) && name.endsWith(suffix) && !name.includes(".imported"));
|
|
346
|
+
if (files.length === 0) {
|
|
347
|
+
return { imported: 0, skipped: 0, archived: false };
|
|
348
|
+
}
|
|
349
|
+
const parsed = [];
|
|
350
|
+
let skipped = 0;
|
|
351
|
+
for (const fileName of files) {
|
|
352
|
+
const match = phaseRe.exec(fileName);
|
|
353
|
+
if (!match) {
|
|
354
|
+
skipped++;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const abs = join(swarmDir, fileName);
|
|
359
|
+
if (statSync(abs).size > _internals2.maxLegacyImportBytes()) {
|
|
360
|
+
skipped++;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const raw = readFileSync(abs, "utf-8");
|
|
364
|
+
JSON.parse(raw);
|
|
365
|
+
parsed.push({ phase: Number(match[1]), payload: raw, fileName });
|
|
366
|
+
} catch {
|
|
367
|
+
skipped++;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const db = getProjectDb(directory);
|
|
371
|
+
let imported = 0;
|
|
372
|
+
const archivedNames = [];
|
|
373
|
+
db.run("BEGIN IMMEDIATE");
|
|
374
|
+
try {
|
|
375
|
+
if (opts.kindCount(db) === 0 && parsed.length > 0) {
|
|
376
|
+
for (const item of parsed) {
|
|
377
|
+
imported += 1;
|
|
378
|
+
opts.upsertRow(db, item.phase, item.payload);
|
|
379
|
+
archivedNames.push(item.fileName);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
db.run("COMMIT");
|
|
383
|
+
} catch (err) {
|
|
384
|
+
try {
|
|
385
|
+
db.run("ROLLBACK");
|
|
386
|
+
} catch {}
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
389
|
+
if (imported > 0) {
|
|
390
|
+
for (const fileName of archivedNames) {
|
|
391
|
+
try {
|
|
392
|
+
renameWithRetry(join(swarmDir, fileName), join(swarmDir, `${fileName}.imported`));
|
|
393
|
+
} catch {}
|
|
394
|
+
}
|
|
395
|
+
return { imported, skipped, archived: archivedNames.length > 0 };
|
|
396
|
+
}
|
|
397
|
+
if (parsed.length > 0) {
|
|
398
|
+
_internals2.warnStaleLegacyOnce(root, `${opts.filePrefix}*`);
|
|
399
|
+
}
|
|
400
|
+
return { imported: 0, skipped, archived: false };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export { getGroupCommitWriter, closeGroupCommitWriter, importLegacyJsonl, importLegacyJsonFiles, getGlobalEventBus };
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
} from "./index-r3mvsbtq.js";
|
|
14
14
|
import {
|
|
15
15
|
observeDelegationLedgerPressure
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-wdtckfnf.js";
|
|
17
17
|
import {
|
|
18
18
|
EvidenceLockTimeoutError,
|
|
19
19
|
withEvidenceLock
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-36nt17m8.js";
|
|
21
21
|
import {
|
|
22
22
|
exports_external,
|
|
23
23
|
init_zod
|
|
@@ -3308,7 +3308,7 @@ async function reconcileLegacyCoderSettlements(directory, maxRecords, onReconcil
|
|
|
3308
3308
|
const candidates = readDelegations(directory).filter((record) => record.normalizedAgent === "coder" && Boolean(record.legacyCoderSettlementTransfer) && Boolean(record.terminalResult)).slice(0, maxRecords);
|
|
3309
3309
|
if (candidates.length === 0)
|
|
3310
3310
|
return 0;
|
|
3311
|
-
const { transferCoderSettlementToBackground } = await import("./coder-settlement-
|
|
3311
|
+
const { transferCoderSettlementToBackground } = await import("./coder-settlement-84je6bza.js");
|
|
3312
3312
|
let transferred = 0;
|
|
3313
3313
|
for (const record of candidates) {
|
|
3314
3314
|
try {
|
|
@@ -217,7 +217,7 @@ var CATALOG_SOURCE = [
|
|
|
217
217
|
category: "delegation",
|
|
218
218
|
severity: "info",
|
|
219
219
|
privacyClass: "pseudonymous",
|
|
220
|
-
producer: "src/index.ts:
|
|
220
|
+
producer: "src/index.ts:638",
|
|
221
221
|
consumers: CONSUMER_COST_CORRECTION,
|
|
222
222
|
retentionOwnerIssue: ISSUE_COST_RETENTION,
|
|
223
223
|
requiredWorkflowIds: REQUIRE_SESSION_AND_TASK,
|
|
@@ -230,7 +230,7 @@ var CATALOG_SOURCE = [
|
|
|
230
230
|
category: "delegation",
|
|
231
231
|
severity: "info",
|
|
232
232
|
privacyClass: "pseudonymous",
|
|
233
|
-
producer: "src/index.ts:
|
|
233
|
+
producer: "src/index.ts:1563",
|
|
234
234
|
consumers: NO_CONSUMERS,
|
|
235
235
|
futureOwnerIssue: ISSUE_SINK,
|
|
236
236
|
retentionOwnerIssue: ISSUE_COST_RETENTION,
|
|
@@ -244,7 +244,7 @@ var CATALOG_SOURCE = [
|
|
|
244
244
|
category: "delegation",
|
|
245
245
|
severity: "notice",
|
|
246
246
|
privacyClass: "pseudonymous",
|
|
247
|
-
producer: "src/index.ts:
|
|
247
|
+
producer: "src/index.ts:1583",
|
|
248
248
|
consumers: CONSUMER_COST_JOIN,
|
|
249
249
|
retentionOwnerIssue: ISSUE_COST_RETENTION,
|
|
250
250
|
requiredWorkflowIds: REQUIRE_SESSION,
|