opencode-swarm 7.167.1 → 7.167.2

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 (105) 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/agents/project-context.d.ts +12 -8
  4. package/dist/cli/{coder-settlement-2ye4s5xr.js → coder-settlement-jy9rad28.js} +16 -16
  5. package/dist/cli/{config-doctor-b0k8eyd6.js → config-doctor-p66vnpy3.js} +3 -3
  6. package/dist/cli/{core-xgzgjk8s.js → core-tw0wtntz.js} +4 -4
  7. package/dist/cli/{curation-policy-bvxf5pxv.js → curation-policy-ndp27v0c.js} +7 -7
  8. package/dist/cli/{curator-jpvzrxcv.js → curator-5nzde80g.js} +45 -45
  9. package/dist/cli/{curator-drift-20m2ab5w.js → curator-drift-gb651hcw.js} +8 -8
  10. package/dist/cli/curator-llm-factory-xy96x5x8.js +71 -0
  11. package/dist/cli/{dispatch-tmb929w8.js → dispatch-8ks9dyk5.js} +244 -70
  12. package/dist/cli/{evidence-summary-service-74az43cb.js → evidence-summary-service-bzpfaypy.js} +22 -22
  13. package/dist/cli/{explorer-zvk5kbcb.js → explorer-2cv64zfj.js} +1 -1
  14. package/dist/cli/{gate-evidence-f26h2gn3.js → gate-evidence-wa8cj8h6.js} +11 -11
  15. package/dist/cli/guardrail-explain-1ef5he6j.js +72 -0
  16. package/dist/cli/{guardrail-log-pnye3xw8.js → guardrail-log-7dv73e0q.js} +9 -9
  17. package/dist/cli/{guardrail-reset-0da7q8ap.js → guardrail-reset-1kng6y8x.js} +44 -44
  18. package/dist/cli/hive-promoter-87kk2pg5.js +86 -0
  19. package/dist/cli/{index-fmzz6aw7.js → index-09gv90d7.js} +4 -4
  20. package/dist/cli/{index-9e6fdz2h.js → index-0mhftbpp.js} +1 -1
  21. package/dist/cli/{index-t8tw1bhs.js → index-0q839sg6.js} +2 -2
  22. package/dist/cli/{index-9bhzbwa4.js → index-18rfc7qv.js} +9 -9
  23. package/dist/cli/{index-7qefgq4j.js → index-1xnse449.js} +11 -1
  24. package/dist/cli/index-25xeyjfx.js +116 -0
  25. package/dist/cli/{index-87agfprq.js → index-2b1hd1fx.js} +2 -2
  26. package/dist/cli/{index-bv8ha57q.js → index-3r6k6qa7.js} +6 -6
  27. package/dist/cli/{index-69y9p6dh.js → index-3ws11dq0.js} +2 -2
  28. package/dist/cli/{index-eretcr6t.js → index-5sjq3shs.js} +11 -11
  29. package/dist/cli/{index-8x4zwk0t.js → index-65s0vgb1.js} +47 -47
  30. package/dist/cli/{index-es13aqdb.js → index-79234evf.js} +1 -1
  31. package/dist/cli/{index-5bd84nxc.js → index-83r0v5tn.js} +1 -1
  32. package/dist/cli/{index-sahf5yz3.js → index-8vbahc4c.js} +1 -1
  33. package/dist/cli/{index-6d4dc99f.js → index-962qme08.js} +1 -1
  34. package/dist/cli/{index-9ss2m4rs.js → index-9br68j86.js} +1 -1
  35. package/dist/cli/{index-4rhhvd1a.js → index-a1w58b47.js} +1 -1
  36. package/dist/cli/{index-qyr17fbz.js → index-arqv4psy.js} +16 -16
  37. package/dist/cli/{index-qtd3hrk8.js → index-ce8p9t28.js} +5 -5
  38. package/dist/cli/{index-q265ytw6.js → index-dme7wvwg.js} +4 -4
  39. package/dist/cli/{index-54vzqy47.js → index-ehq2vtkq.js} +6 -6
  40. package/dist/cli/{index-1aex5zd9.js → index-f8cc92g7.js} +2 -2
  41. package/dist/cli/{index-bzdc4b7t.js → index-f91fhch0.js} +6 -6
  42. package/dist/cli/{index-70ha9e09.js → index-fyfbpz4f.js} +1 -1
  43. package/dist/cli/{index-75f9jj3h.js → index-g409c7ke.js} +2 -2
  44. package/dist/cli/{index-0tc0pcmh.js → index-g5m43paw.js} +37 -2
  45. package/dist/cli/{index-9wv6a3jx.js → index-gmjg65tm.js} +2 -2
  46. package/dist/cli/{index-qd726agw.js → index-gs12223x.js} +3 -3
  47. package/dist/cli/{index-rk10x4zr.js → index-hhkm64wh.js} +5 -5
  48. package/dist/cli/{index-mgc3c483.js → index-jhd3pmd1.js} +10 -10
  49. package/dist/cli/{index-m3tx1q9v.js → index-k73ehxa1.js} +1 -1
  50. package/dist/cli/{index-z5gdgdkp.js → index-m3z83nhs.js} +12 -12
  51. package/dist/cli/{index-251vrmge.js → index-m7cwnt9r.js} +4 -4
  52. package/dist/cli/{index-3nm1b3t2.js → index-mtepgqan.js} +8 -8
  53. package/dist/cli/{index-79wnzc8q.js → index-pdcperq5.js} +3 -3
  54. package/dist/cli/{index-bf6zx8cq.js → index-rrne6g2m.js} +2 -2
  55. package/dist/cli/{index-hdsg7yf6.js → index-s7a9dqtb.js} +3 -3
  56. package/dist/cli/{index-f8xk5q5j.js → index-shrf0wt3.js} +4 -4
  57. package/dist/cli/{index-zwsbegc1.js → index-sjkg2hc4.js} +7 -7
  58. package/dist/cli/{index-qww0h314.js → index-syedr4e3.js} +1 -1
  59. package/dist/cli/{index-f6zgz02s.js → index-tcj8v6my.js} +3 -3
  60. package/dist/cli/{index-2w0beg3s.js → index-vgpedapd.js} +5 -5
  61. package/dist/cli/{index-emwezg3y.js → index-wjet7x0a.js} +3 -3
  62. package/dist/cli/{index-m21x1bkx.js → index-x7pm61wk.js} +2 -0
  63. package/dist/cli/{index-32bxwzw0.js → index-y1sj2e1n.js} +92719 -90312
  64. package/dist/cli/{index-qd619x3r.js → index-z6we1abx.js} +2 -2
  65. package/dist/cli/{index-fenasyvr.js → index-z7z3g5wt.js} +62 -12
  66. package/dist/cli/index.js +44 -44
  67. package/dist/cli/{knowledge-escalator-p2a8xh8x.js → knowledge-escalator-5e4zxan5.js} +17 -17
  68. package/dist/cli/{knowledge-events-jmh28m8d.js → knowledge-events-abzm5vfh.js} +15 -15
  69. package/dist/cli/{knowledge-link-w1fwqts4.js → knowledge-link-9ga6hyd5.js} +6 -6
  70. package/dist/cli/{knowledge-store-8gmabtsn.js → knowledge-store-q4a92eq7.js} +7 -7
  71. package/dist/cli/{knowledge-validator-yk579vs4.js → knowledge-validator-pn3m5r41.js} +9 -9
  72. package/dist/cli/{model-preflight-b3b5pgsc.js → model-preflight-mw895vgt.js} +1 -1
  73. package/dist/cli/{pending-delegations-nw7ph53z.js → pending-delegations-3z0xjppd.js} +14 -14
  74. package/dist/cli/{pr-subscriptions-9815fxbc.js → pr-subscriptions-h7mwnp62.js} +14 -14
  75. package/dist/cli/{pr-workflow-gate-98a7b6py.js → pr-workflow-gate-fec04fa0.js} +44 -44
  76. package/dist/cli/{runner-nmrjv7te.js → runner-d9833azt.js} +7 -7
  77. package/dist/cli/{scan-cursor-6zcs0frg.js → scan-cursor-ymfvzdkz.js} +10 -10
  78. package/dist/cli/{schema-warvhy9h.js → schema-chc4aez6.js} +2 -2
  79. package/dist/cli/{scope-persistence-c2ck77cv.js → scope-persistence-3xnr59y8.js} +20 -20
  80. package/dist/cli/{skill-generator-jamm1cna.js → skill-generator-3mvaghxk.js} +19 -19
  81. package/dist/cli/{snapshot-coordination-init-st0xsn3f.js → snapshot-coordination-init-arnc77r9.js} +44 -44
  82. package/dist/cli/{telemetry-ce0tx41h.js → telemetry-g9pppt9e.js} +2 -2
  83. package/dist/cli/{workspace-snapshot-0kxj2grt.js → workspace-snapshot-hvsjtepd.js} +6 -6
  84. package/dist/cli/{worktree-collision-ownership-qra7r8pw.js → worktree-collision-ownership-vj8anvb7.js} +17 -17
  85. package/dist/cli/{worktree-isolation-yr9gnf64.js → worktree-isolation-mt7z75hz.js} +45 -45
  86. package/dist/commands/close/align-stage.d.ts +10 -0
  87. package/dist/commands/close/archive-stage.d.ts +34 -0
  88. package/dist/commands/close/clean-stage.d.ts +2 -0
  89. package/dist/commands/close/constants.d.ts +122 -0
  90. package/dist/commands/close/context.d.ts +129 -0
  91. package/dist/commands/close/db-helpers.d.ts +10 -0
  92. package/dist/commands/close/dry-run.d.ts +12 -0
  93. package/dist/commands/close/finalize-stage.d.ts +44 -0
  94. package/dist/commands/close/fs-helpers.d.ts +17 -0
  95. package/dist/commands/close/internals.d.ts +55 -0
  96. package/dist/commands/close/orchestrator.d.ts +32 -0
  97. package/dist/commands/close/wiring.d.ts +2 -0
  98. package/dist/commands/close.d.ts +10 -402
  99. package/dist/index.js +485 -485
  100. package/dist/lang/dispatch.d.ts +6 -6
  101. package/dist/utils/canonical-root.d.ts +19 -0
  102. package/package.json +1 -1
  103. package/dist/cli/curator-llm-factory-zeb0pe2j.js +0 -71
  104. package/dist/cli/guardrail-explain-5vhveypz.js +0 -72
  105. package/dist/cli/hive-promoter-2vj54xc4.js +0 -86
@@ -1,402 +1,10 @@
1
- import * as fsSync from 'node:fs';
2
- import { loadPluginConfigWithMeta } from '../config';
3
- import type { Plan } from '../config/plan-schema';
4
- import { type KnowledgeConfig, type PluginConfig } from '../config/schema';
5
- import { archiveEvidence } from '../evidence/manager';
6
- import { getGitRepositoryStatus, resetToMainAfterMerge, resetToRemoteBranch } from '../git/branch';
7
- import { createCuratorLLMDelegate } from '../hooks/curator-llm-factory';
8
- import { runCuratorPostMortem } from '../hooks/curator-postmortem';
9
- import { checkHivePromotions } from '../hooks/hive-promoter';
10
- import { curateAndStoreSwarm } from '../hooks/knowledge-curator';
11
- import { reconcilePhaseClose } from '../hooks/knowledge-receipt-ledger.js';
12
- import { closeSnapshotCoordinationInitialization } from '../session/snapshot-coordination-init.js';
13
- import { closeRepoMemory } from '../tools/repo-graph/indexed-storage';
14
- /** Narrow seam for receipt/plan ordering tests. */
15
- export declare const closeReceiptLifecycleInternals: {
16
- recordPhaseCloseIntent: (directory: string, phase: string, sessionId?: string, taskId?: string) => Promise<import("../hooks/knowledge-receipt-ledger.js").ReceiptLedgerResult<{
17
- event_id: string;
18
- }>>;
19
- reconcilePhaseClose: typeof reconcilePhaseClose;
20
- };
21
- import { runFinalizeRewardSweep } from '../memory/finalize-reward-sweep';
22
- import { type SessionReflectionResult } from '../services/session-reflection';
23
- import { endAgentSession, resetSwarmStatePreservingSingletons } from '../state';
24
- import { collectGarbageBestEffort, sleep } from '../utils/bun-compat.js';
25
- import { type CloseTerminalResult } from '../workflow/close-terminal.js';
26
- import { type SqliteRowCounts } from './archive-sqlite';
27
- interface PlanPhase {
28
- id: number;
29
- name: string;
30
- status: string;
31
- tasks: Array<{
32
- id: string;
33
- status: string;
34
- close_reason?: string;
35
- }>;
36
- }
37
- interface PlanData {
38
- title: string;
39
- phases: PlanPhase[];
40
- }
41
- /**
42
- * Close-command wrapper around the exact-task terminal reconciliation service.
43
- *
44
- * Deliberately NOT named `closePlanTerminalState`: `src/plan/manager.ts` exports a
45
- * distinct function by that name (ledger-first phase/projection persistence), which
46
- * `reconcileCloseTerminalState` itself calls downstream. Keeping the two identifiers
47
- * distinct avoids a same-name collision across close.ts / close-terminal.ts /
48
- * plan/manager.ts. The `_internals` key below stays `closePlanTerminalState` so the
49
- * existing test seam is unchanged.
50
- */
51
- declare function reconcileCloseTerminalStateForPlan(directory: string, targetPlan: Plan, options: {
52
- actor: string;
53
- requestedClosedTaskIds: string[];
54
- closedPhaseIds: number[];
55
- originalStatuses?: Map<string, string>;
56
- }): Promise<CloseTerminalResult | undefined>;
57
- interface CloseCommandOptions {
58
- sessionID?: string;
59
- skillReviewTimeoutMs?: number;
60
- }
61
- interface CurationCounts {
62
- stored: number;
63
- /** Issue #2077: surfaced for the reflection knowledge-delta report. */
64
- reinforced: number;
65
- skipped: number;
66
- rejected: number;
67
- quarantined: number;
68
- }
69
- interface CloseKnowledgeEntry {
70
- created_at?: string;
71
- }
72
- export type ArchiveRequiredness = 'required' | 'optional';
73
- export type ArchiveAttempt = 'not_attempted' | 'succeeded' | 'failed';
74
- export type ArchiveValidation = 'not_applicable' | 'passed' | 'failed';
75
- export type ArchiveSourceDisposition = 'absent' | 'retained' | 'removed';
76
- export interface ArtifactArchiveResult {
77
- artifact: string;
78
- requiredness: ArchiveRequiredness;
79
- attempt: ArchiveAttempt;
80
- validation: ArchiveValidation;
81
- source_disposition: ArchiveSourceDisposition;
82
- method: string;
83
- reason_code: string;
84
- /** Counts only (no row content), present for validated sqlite snapshots. */
85
- row_counts?: SqliteRowCounts;
86
- /** Non-sensitive diagnostic. */
87
- detail?: string;
88
- }
89
- export interface ArchiveStageContext {
90
- directory: string;
91
- swarmDir: string;
92
- config: PluginConfig;
93
- warnings: string[];
94
- }
95
- export interface CloseStageContext {
96
- directory: string;
97
- swarmDir: string;
98
- planData: PlanData;
99
- planExists: boolean;
100
- planAlreadyDone: boolean;
101
- config: KnowledgeConfig;
102
- projectName: string;
103
- warnings: string[];
104
- closedPhases: number[];
105
- closedTasks: string[];
106
- sessionStart: string | undefined;
107
- isForced: boolean;
108
- runSkillReview: boolean;
109
- options: CloseCommandOptions;
110
- phases: PlanPhase[];
111
- inProgressPhases: PlanPhase[];
112
- curationSucceeded: boolean;
113
- curationResult: CurationCounts | undefined;
114
- allLessons: string[];
115
- explicitLessons: string[];
116
- retroLessons: string[];
117
- knowledgeSkillHint: string;
118
- skillReviewSummary: string;
119
- postMortemSummary: string;
120
- sessionReflection: SessionReflectionResult | undefined;
121
- hivePromoted: number;
122
- sessionKnowledgeCreated: number;
123
- fallbackKnowledgeCreated: number;
124
- /** Issue #2077: FR-015 dedup drop count (retro lessons dropped as already-known). */
125
- dedupDropped: number;
126
- /** Issue #2077: false when the dedup knowledge read failed (fail-open). */
127
- dedupAvailable: boolean;
128
- /** Issue #2077: total retro lessons before dedup. */
129
- retroLessonTotal: number;
130
- /** Issue #2077: full-auto state computed once, reused at reflection + menu render. */
131
- fullAuto: boolean;
132
- originalStatuses: Map<string, string>;
133
- guaranteeResult: {
134
- closedPhaseIds: number[];
135
- closedTaskIds: string[];
136
- };
137
- terminalizationError?: string;
138
- archiveResult: string;
139
- archivedFileCount: number;
140
- archivedActiveStateFiles: Set<string>;
141
- archivedActiveStateDirs: Set<string>;
142
- archiveFailureReasons: Map<string, string>;
143
- /** Structured per-artifact results — single source of truth (issue #2030). */
144
- archiveResults: ArtifactArchiveResult[];
145
- /** True when the archive STAGE threw wholesale (e.g. mkdir EACCES/ENOSPC). */
146
- archiveStageFailed: boolean;
147
- timestamp: string;
148
- archiveDir: string;
149
- archiveSuffix: string;
150
- args: string[];
151
- }
152
- declare function archiveCloseSummary(ctx: Pick<CloseStageContext, 'archiveStageFailed' | 'archiveDir' | 'warnings'>, closeSummaryPath: string, summaryWritten: boolean): Promise<void>;
153
- declare function countSessionKnowledgeEntries(entries: CloseKnowledgeEntry[], sessionStart: string | undefined, fallbackCount: number): number;
154
- /**
155
- * Backward-compatible wrapper that returns only the copied count.
156
- * Direct callers (including tests) that expect a number continue to work.
157
- * Use copyDirRecursiveWithFailures when per-file failure tracking is needed.
158
- */
159
- declare function copyDirRecursive(src: string, dest: string): Promise<number>;
160
- /**
161
- * Flat-file artifacts to include in the archive bundle.
162
- * Each entry is a relative path under .swarm/.
163
- *
164
- * plan-ledger.jsonl is included so the archive bundle is a self-contained
165
- * forensic snapshot of the session: the ledger holds the full audit trail of
166
- * task state transitions and snapshot events that plan.json/plan.md don't
167
- * preserve.
168
- */
169
- export declare const ARCHIVE_ARTIFACTS: string[];
170
- /**
171
- * Active-state flat files to clean after archiving so future swarms start clean.
172
- *
173
- * plan.json, plan.md, and plan-ledger.jsonl are all removed so the next /swarm
174
- * session starts with a clean slate. The user's original ask for /swarm close
175
- * was to "archive plan files so future swarms aren't confused" — leaving a
176
- * terminal-state plan.json in place violates that invariant because the next
177
- * session's loadPlan() would pick it up as if it were still active.
178
- *
179
- * CRITICAL: the ledger must also be removed. Without this, loadPlan()'s Step 4
180
- * would see no plan.json but a surviving ledger, call replayFromLedger(), and
181
- * materialize the CLOSED plan back into plan.json on the next session. The
182
- * ledger is a second backing store for the same "terminal-state plan" and
183
- * leaving it behind re-enables the exact bug this cleanup is meant to fix.
184
- * The archive-first guard below ensures we only delete files we successfully
185
- * copied to the archive bundle, so the audit trail is preserved in the bundle.
186
- *
187
- * knowledge-rejected.jsonl, repo-graph.json, doc-manifest.json,
188
- * dark-matter.md, telemetry.jsonl, and swarm.db are
189
- * session-generated artifacts that do not persist meaningfully across sessions —
190
- * they are recreated on next session init and must be removed to avoid stale-state
191
- * interference.
192
- *
193
- * The SQLite WAL sidecars swarm.db-shm and swarm.db-wal are deliberately NOT in
194
- * either list (the archive-first guard would preserve them anyway): since #2483
195
- * they are removed immediately AFTER the swarm.db unlink by
196
- * removeSqliteSidecarsAfterClose, deliberately reversing #1692. Post-unlink the
197
- * sidecar paths are meaningless for future opens (no new opener can attach),
198
- * live processes keep their already-open fds so deleting the PATH cannot
199
- * corrupt them, and a Windows open-handle collision yields EBUSY which the
200
- * helper skips fail-open.
201
- *
202
- * Note: knowledge.jsonl is intentionally NOT cleaned because it contains cumulative
203
- * project knowledge (lessons learned) that should persist across sessions and finalize
204
- * cycles. The archive step still creates a backup for safety.
205
- * close-summary.md is NOT cleaned because it is written as the final close output
206
- * AFTER the clean stage runs. spec.md IS cleaned: it is single-session state coupled
207
- * to the plan lifecycle (the plan it produced is removed above), so leaving it behind
208
- * makes the next session pick up a stale spec via readEffectiveSpecSync and mis-route
209
- * the architect into CLARIFY-SPEC/overwrite prompts. It is archived first (archive-first
210
- * guard), so the forensic copy is preserved in the bundle. The earlier "spec.md may not
211
- * exist" rationale was wrong — handoff.md is equally optional and is cleaned the same way.
212
- * session-reflection.md is a single-session snapshot (not cumulative like
213
- * knowledge.jsonl) so it IS cleaned to maintain the clean-slate invariant.
214
- * spec-staleness.json and spec-snapshot.md are the same class of single-session
215
- * spec-drift state as spec.md. spec-staleness.json is an existence-only gate
216
- * checked unconditionally by enforceSpecDriftGate, which hard-blocks the core
217
- * write tools (save_plan, update_task_status, phase_complete,
218
- * lean_turbo_run_phase, lean_turbo_acquire_locks) with SPEC_DRIFT_BLOCK — a
219
- * survivor would block the NEXT session against drift that no longer applies.
220
- * spec-snapshot.md is its companion diff source, feeding the mismatch shown in
221
- * the SPEC_DRIFT_BLOCK message. Both are archived first (archive-first guard),
222
- * then cleaned so the next session starts drift-free.
223
- */
224
- export declare const ACTIVE_STATE_TO_CLEAN: string[];
225
- /**
226
- * Active-state directories to archive and clean after archiving.
227
- * These contain session-generated data that must be removed so future
228
- * swarms start clean. Each entry is a relative path under .swarm/.
229
- */
230
- export declare const ACTIVE_STATE_DIRS_TO_CLEAN: string[];
231
- /**
232
- * Guarantee all phases and tasks in a plan are marked complete/closed.
233
- * Mutates planData in place. Returns actual IDs of newly closed phases and
234
- * tasks so the caller can track only genuinely new closures (idempotent).
235
- */
236
- declare function guaranteeAllPlansComplete(planData: PlanData): {
237
- closedPhaseIds: number[];
238
- closedTaskIds: string[];
239
- };
240
- export interface GitAlignResult {
241
- gitAlignResult: string;
242
- prunedBranches: string[];
243
- }
244
- export interface CleanStageResult {
245
- cleanedFiles: string[];
246
- configBackupsRemoved: number;
247
- swarmPlanFilesRemoved: number;
248
- /**
249
- * Stale atomic-write temp files MOVED into `.swarm/quarantine/<batch>/`
250
- * (issue #2035). Quarantine is a recoverable move with a manifest — the
251
- * pre-#2035 blind `.tmp.*` unlink sweep is gone; preserved candidates
252
- * (recent/active/tracked/ambiguous) are counted in `residuePreserved`.
253
- */
254
- residueQuarantined: number;
255
- residuePreserved: number;
256
- }
257
- /**
258
- * Emit the single `close_archive_result` telemetry event whose payload is the
259
- * SAME `ctx.archiveResults` array the user-facing prose derives from, so the
260
- * two cannot disagree (issue #2030 item 6). Called AFTER `runCleanStage` so
261
- * `source_disposition` can be finalized truthfully: artifacts that were
262
- * successfully archived AND then unlinked by the clean stage report `'removed'`;
263
- * artifacts preserved (absent, or failed/retained) keep their archive-time
264
- * disposition. Counts only — no row content (issue items 4/9).
265
- */
266
- export declare function emitCloseArchiveResult(ctx: CloseStageContext, cleanResult: CleanStageResult): void;
267
- /**
268
- * STAGE 1: FINALIZE
269
- *
270
- * Writes retrospectives for in-progress phases (or a session-level retro for
271
- * plan-free closes), curates lessons, promotes to hive, runs skill review,
272
- * persists terminal plan state, and runs post-mortem. All state mutations are
273
- * written back to ctx so the caller can build the close summary.
274
- */
275
- export declare function runFinalizeStage(ctx: CloseStageContext): Promise<void>;
276
- /**
277
- * STAGE 2: ARCHIVE
278
- *
279
- * Creates a timestamped archive bundle under .swarm/archive/, copies flat-file
280
- * artifacts and active-state directories, then runs the evidence retention
281
- * policy. All state mutations (archive path, counts, success sets) are written
282
- * back to ctx so the caller can build the close summary.
283
- */
284
- export declare function runArchiveStage(ctx: CloseStageContext): Promise<void>;
285
- /**
286
- * Runs the evidence-retention sub-logic of STAGE 2 (ARCHIVE).
287
- * Reads max_age_days / max_bundles / cache_max_bytes / cache_max_records from
288
- * config.evidence (FR-016, issue #1184) and calls archiveEvidence. The report
289
- * overload is used so the documents-cache prune runs when cache caps are set.
290
- * Fail-open: pushes a warning on error but never throws.
291
- */
292
- export declare function runArchiveEvidenceRetention(ctx: ArchiveStageContext): Promise<void>;
293
- /**
294
- * Delete one archived active-state artifact, tolerating the short-lived file
295
- * locks Windows antivirus and SQLite sidecars can retain after handle close.
296
- * Non-transient errors fail immediately; the retry budget is bounded to
297
- * 375 ms so `/swarm close` remains responsive.
298
- */
299
- declare function unlinkActiveStateFileWithRetry(filePath: string): Promise<void>;
300
- /**
301
- * Remove the SQLite WAL sidecars (swarm.db-wal / swarm.db-shm) immediately
302
- * after the clean stage unlinks swarm.db (#2483, deliberately reversing the
303
- * #1692 preserve decision): once the main db is unlinked the sidecar paths
304
- * are meaningless for future opens — no new opener can attach — and live
305
- * processes keep their already-open fds, so deleting the PATH cannot corrupt
306
- * them. Best-effort and per-file fail-open: ENOENT (already gone) and EBUSY
307
- * (Windows open-handle collision) are skipped silently.
308
- */
309
- export declare function removeSqliteSidecarsAfterClose(swarmDir: string): void;
310
- export declare function runCleanStage(ctx: CloseStageContext): Promise<CleanStageResult>;
311
- /**
312
- * STAGE 4: ALIGN
313
- *
314
- * Performs safe git alignment to main (resetToMainAfterMerge / resetToRemoteBranch
315
- * via _internals), handling post-merge scenarios and non-git directories.
316
- * Returns { gitAlignResult, prunedBranches } so the orchestrator can build
317
- * the close summary. All warnings are pushed into ctx.warnings.
318
- */
319
- export declare function runAlignStage(ctx: CloseStageContext): Promise<GitAlignResult>;
320
- /**
321
- * Builds the `/swarm finalize --dry-run` report. Purely READ-ONLY: inspects the
322
- * plan and the filesystem and describes what a real finalize WOULD do, without
323
- * acquiring the finalize lock, creating an archive bundle, deleting any file,
324
- * running git, or tearing down session state. (#1692)
325
- *
326
- * The archive-first guard means the clean stage only removes files it first
327
- * archived successfully; this report approximates that by listing existing
328
- * clean-set members as "would remove" and notes the approximation.
329
- */
330
- export declare function runFinalizeDryRun(directory: string, swarmDir: string, planData: PlanData, planExists: boolean): Promise<string>;
331
- /**
332
- * Handles /swarm close command - performs full terminal session finalization:
333
- * 0. Guarantee: mark all incomplete phases/tasks as closed
334
- * 1. Finalize: write retrospectives, produce terminal summary
335
- * 2. Archive: create timestamped bundle of swarm artifacts
336
- * 3. Clean: clear active-state files that confuse future swarms
337
- * 4. Align: safe git alignment to main
338
- *
339
- * Must be idempotent - safe to run multiple times.
340
- */
341
- export declare function handleCloseCommand(directory: string, args: string[], options?: CloseCommandOptions): Promise<string>;
342
- /**
343
- * Acquire the finalize lock for the close command (FR-012).
344
- * Wraps tryAcquireLock with a directory-only API.
345
- */
346
- declare function acquireFinalizeLock(directory: string): Promise<{
347
- acquired: boolean;
348
- release?: () => Promise<void>;
349
- }>;
350
- /**
351
- * Issue #2077: detect full-auto state for the action-menu prompt suppression.
352
- * Combines the in-memory session flag (hasActiveFullAuto) with the durable
353
- * run state (isFullAutoRunActive reads .swarm/full-auto-state.json) so a
354
- * process restart mid-run does not silently re-enable the interactive menu
355
- * prompt. The durable check is sync and takes a state lock; if it throws,
356
- * fall back to the in-memory flag alone. Caller MUST guard with a defined
357
- * sessionID to avoid the cross-session leak (hasActiveFullAuto(undefined)
358
- * scans all sessions).
359
- */
360
- declare function detectFullAuto(directory: string, sessionID: string): boolean;
361
- export declare const _internals: {
362
- closeSnapshotCoordinationInitialization: typeof closeSnapshotCoordinationInitialization;
363
- closeRepoMemory: typeof closeRepoMemory;
364
- unlinkActiveStateFileWithRetry: typeof unlinkActiveStateFileWithRetry;
365
- unlink: typeof fsSync.promises.unlink;
366
- unlinkSidecarSync: typeof fsSync.unlinkSync;
367
- sleep: typeof sleep;
368
- collectGarbageBestEffort: typeof collectGarbageBestEffort;
369
- ACTIVE_STATE_DIRS_TO_CLEAN: string[];
370
- countSessionKnowledgeEntries: typeof countSessionKnowledgeEntries;
371
- CLOSE_SKILL_REVIEW_TIMEOUT_MS: number;
372
- CLOSE_REFLECTION_TIMEOUT_MS: number;
373
- detectFullAuto: typeof detectFullAuto;
374
- guaranteeAllPlansComplete: typeof guaranteeAllPlansComplete;
375
- getGitRepositoryStatus: typeof getGitRepositoryStatus;
376
- resetToMainAfterMerge: typeof resetToMainAfterMerge;
377
- resetToRemoteBranch: typeof resetToRemoteBranch;
378
- copyDirRecursive: typeof copyDirRecursive;
379
- loadPluginConfigWithMeta: typeof loadPluginConfigWithMeta;
380
- curateAndStoreSwarm: typeof curateAndStoreSwarm;
381
- checkHivePromotions: typeof checkHivePromotions;
382
- runCuratorPostMortem: typeof runCuratorPostMortem;
383
- createCuratorLLMDelegate: typeof createCuratorLLMDelegate;
384
- resetSwarmStatePreservingSingletons: typeof resetSwarmStatePreservingSingletons;
385
- runFinalizeStage: typeof runFinalizeStage;
386
- runFinalizeRewardSweep: typeof runFinalizeRewardSweep;
387
- acquireFinalizeLock: typeof acquireFinalizeLock;
388
- runArchiveStage: typeof runArchiveStage;
389
- archiveCloseSummary: typeof archiveCloseSummary;
390
- runArchiveEvidenceRetention: typeof runArchiveEvidenceRetention;
391
- runCleanStage: typeof runCleanStage;
392
- runAlignStage: typeof runAlignStage;
393
- runFinalizeDryRun: typeof runFinalizeDryRun;
394
- archiveEvidence: typeof archiveEvidence;
395
- closePlanTerminalState: typeof reconcileCloseTerminalStateForPlan;
396
- endAgentSession: typeof endAgentSession;
397
- flushAndDrainTelemetry: () => Promise<void>;
398
- finalizeContextTelemetry: (directory: string) => void;
399
- finalizeCoreEvents: (directory: string) => void;
400
- finalizeShellAudit: (directory: string) => void;
401
- };
402
- export {};
1
+ export { runAlignStage } from './close/align-stage.js';
2
+ export { emitCloseArchiveResult, runArchiveEvidenceRetention, runArchiveStage, } from './close/archive-stage.js';
3
+ export { runCleanStage } from './close/clean-stage.js';
4
+ export { ACTIVE_STATE_DIRS_TO_CLEAN, ACTIVE_STATE_TO_CLEAN, ARCHIVE_ARTIFACTS, } from './close/constants.js';
5
+ export type { ArchiveAttempt, ArchiveRequiredness, ArchiveSourceDisposition, ArchiveStageContext, ArchiveValidation, ArtifactArchiveResult, CleanStageResult, CloseStageContext, GitAlignResult, } from './close/context.js';
6
+ export { removeSqliteSidecarsAfterClose } from './close/db-helpers.js';
7
+ export { runFinalizeDryRun } from './close/dry-run.js';
8
+ export { runFinalizeStage } from './close/finalize-stage.js';
9
+ export { _internals, closeReceiptLifecycleInternals, } from './close/internals.js';
10
+ export { handleCloseCommand } from './close/orchestrator.js';