opencode-swarm 7.33.0 → 7.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -175,6 +175,15 @@ export declare function appendLedgerEventWithRetry(directory: string, eventInput
175
175
  backoffMs?: number;
176
176
  verifyValid?: () => Promise<boolean> | boolean;
177
177
  }): Promise<LedgerEvent | null>;
178
+ /**
179
+ * Take a snapshot with bounded retry and always-visible warning logging (FR-004).
180
+ * Retries up to 3 times with exponential backoff, then logs a visible warning.
181
+ * Non-fatal — never throws. Shared by save-plan tool and plan manager.
182
+ */
183
+ export declare function takeSnapshotWithRetry(directory: string, plan: Plan, options?: {
184
+ planHashAfter?: string;
185
+ source?: string;
186
+ }): Promise<void>;
178
187
  /**
179
188
  * Take a snapshot event and append it to the ledger.
180
189
  * The snapshot embeds the full Plan payload for ledger-only rebuild.
@@ -39,7 +39,7 @@ export interface AcknowledgedRemovals {
39
39
  source: string;
40
40
  }
41
41
  import { type Plan, type RuntimePlan, type TaskStatus } from '../config/plan-schema';
42
- import { type LedgerEvent, type LedgerEventInput } from './ledger';
42
+ import { type LedgerEvent, type LedgerEventInput, takeSnapshotWithRetry } from './ledger';
43
43
  /** Reset the startup ledger check flag. For testing only. */
44
44
  export declare function resetStartupLedgerCheck(): void;
45
45
  /**
@@ -55,6 +55,10 @@ export declare const _internals: {
55
55
  loadPlanJsonOnly: typeof loadPlanJsonOnly;
56
56
  regeneratePlanMarkdown: typeof regeneratePlanMarkdown;
57
57
  };
58
+ /** @internal Test seam for snapshot retry helper */
59
+ export declare const _snapshot_test_exports: {
60
+ takeSnapshotWithRetry: typeof takeSnapshotWithRetry;
61
+ };
58
62
  /**
59
63
  * Append a ledger event with exponential-backoff retry on stale-writer conflicts.
60
64
  *
@@ -130,7 +134,29 @@ export declare function savePlan(directory: string, plan: Plan, options?: {
130
134
  * @param directory - The working directory
131
135
  * @returns Reconstructed Plan from ledger, or null if ledger is empty/missing
132
136
  */
133
- export declare function rebuildPlan(directory: string, plan?: Plan): Promise<Plan | null>;
137
+ export declare function rebuildPlan(directory: string, plan?: Plan, options?: {
138
+ reason?: string;
139
+ }): Promise<Plan | null>;
140
+ /**
141
+ * Write terminal plan state through the managed write path (FR-002, FR-005, FR-006).
142
+ *
143
+ * Used by the `/swarm close` command to record the final plan state when a session
144
+ * is unconditionally terminated. Unlike `savePlan()`, this function:
145
+ * - Does NOT re-derive task statuses or enforce locked profiles
146
+ * - Does NOT use CAS protection (no concurrent writer should be active during close)
147
+ * - Appends terminal ledger events for audit trail before writing plan files
148
+ *
149
+ * @param directory - Project root directory
150
+ * @param plan - The plan with terminal state already applied by the caller
151
+ * @param options.closedPhaseIds - Phase IDs that were closed
152
+ * @param options.closedTaskIds - Task IDs that were closed
153
+ * @param options.originalStatuses - Optional map of taskId → from_status for ledger events
154
+ */
155
+ export declare function closePlanTerminalState(directory: string, plan: Plan, options: {
156
+ closedPhaseIds: number[];
157
+ closedTaskIds: string[];
158
+ originalStatuses?: Map<string, string>;
159
+ }): Promise<void>;
134
160
  /**
135
161
  * Load plan → find task by ID → update status → save → return updated plan.
136
162
  * Throw if plan not found or task not found.
@@ -70,6 +70,10 @@ declare function getTaskStatus(task: Task | undefined, bundle: EvidenceBundle |
70
70
  /**
71
71
  * Check if evidence meets completion criteria for a task
72
72
  */
73
+ declare function evidenceCompleteFromEntries(entries: Evidence[]): {
74
+ isComplete: boolean;
75
+ missingEvidence: string[];
76
+ };
73
77
  declare function isEvidenceComplete(bundle: EvidenceBundle | null): {
74
78
  isComplete: boolean;
75
79
  missingEvidence: string[];
@@ -116,6 +120,7 @@ export declare const _internals: {
116
120
  isAutoSummaryEnabled: typeof isAutoSummaryEnabled;
117
121
  normalizeBundleEntries: typeof normalizeBundleEntries;
118
122
  getTaskStatus: typeof getTaskStatus;
123
+ evidenceCompleteFromEntries: typeof evidenceCompleteFromEntries;
119
124
  isEvidenceComplete: typeof isEvidenceComplete;
120
125
  getTaskBlockers: typeof getTaskBlockers;
121
126
  buildTaskSummary: typeof buildTaskSummary;
@@ -1,4 +1,4 @@
1
- export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'phase_changed' | 'budget_updated' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'prm_pattern_detected' | 'prm_course_correction_injected' | 'prm_escalation_triggered' | 'prm_hard_stop';
1
+ export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'phase_changed' | 'budget_updated' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'prm_pattern_detected' | 'prm_course_correction_injected' | 'prm_escalation_triggered' | 'prm_hard_stop';
2
2
  export type TelemetryListener = (event: TelemetryEvent, data: Record<string, unknown>) => void;
3
3
  /** @internal - For testing only */
4
4
  export declare function resetTelemetryForTesting(): void;
@@ -3,6 +3,11 @@
3
3
  * Allows the Architect agent to save structured plans to .swarm/plan.json and .swarm/plan.md.
4
4
  */
5
5
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
6
+ import { takeSnapshotWithRetry } from '../plan/ledger';
7
+ /** Test seam for the snapshot retry helper (FR-004). */
8
+ export declare const _test_exports: {
9
+ takeSnapshotWithRetry: typeof takeSnapshotWithRetry;
10
+ };
6
11
  /**
7
12
  * Arguments for the save_plan tool
8
13
  */
@@ -52,6 +57,13 @@ export interface SavePlanArgs {
52
57
  * prevent a destructive reset from silently dropping unfinished work.
53
58
  */
54
59
  confirm_destructive_reset?: boolean;
60
+ /**
61
+ * When true, allows save_plan to overwrite an existing plan that has a
62
+ * different identity (swarm_id + title). Without this flag, save_plan
63
+ * rejects with PLAN_IDENTITY_MISMATCH if the incoming identity differs
64
+ * from the existing plan's identity.
65
+ */
66
+ confirm_identity_change?: boolean;
55
67
  /**
56
68
  * Architect-facing concurrency controls for this plan.
57
69
  * When execution_profile.locked is true the profile is immutable — subsequent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.33.0",
3
+ "version": "7.33.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",