opencode-swarm 7.79.1 → 7.79.5

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.
@@ -43,9 +43,9 @@ export declare class EscalationTracker {
43
43
  hardStop: boolean;
44
44
  };
45
45
  /**
46
- * Returns the current escalation state.
46
+ * Returns a defensive copy of the current escalation state.
47
47
  *
48
- * @returns The current EscalationState (reference, not a copy)
48
+ * @returns The current EscalationState copy
49
49
  */
50
50
  getState(): EscalationState;
51
51
  /**
@@ -54,7 +54,7 @@ export declare class EscalationTracker {
54
54
  */
55
55
  reset(): void;
56
56
  /**
57
- * Returns all pending course corrections.
57
+ * Returns defensive copies of all pending course corrections.
58
58
  *
59
59
  * @returns Array of pending CourseCorrection objects
60
60
  */
@@ -19,9 +19,10 @@ export type { CourseCorrection, EscalationState, PatternDetectionResult, Pattern
19
19
  import { getAgentSession } from '../state';
20
20
  import { telemetry } from '../telemetry';
21
21
  import { formatCourseCorrectionForInjection, generateCourseCorrection } from './course-correction';
22
+ import { EscalationTracker } from './escalation';
22
23
  import { detectPatterns } from './pattern-detector';
23
24
  import { recordReplayEntry, startReplayRecording } from './replay';
24
- import { cleanupOldTrajectoryFiles, getInMemoryTrajectory, readTrajectory } from './trajectory-store';
25
+ import { cleanupOldTrajectoryFiles, clearTrajectoryCache, getInMemoryTrajectory, readTrajectory } from './trajectory-store';
25
26
  import type { PrmConfig } from './types';
26
27
  /**
27
28
  * Test-only dependency-injection seam — see `gitignore-warning.ts:_internals`.
@@ -39,6 +40,7 @@ export declare const _internals: {
39
40
  generateCourseCorrection: typeof generateCourseCorrection;
40
41
  formatCourseCorrectionForInjection: typeof formatCourseCorrectionForInjection;
41
42
  cleanupOldTrajectoryFiles: typeof cleanupOldTrajectoryFiles;
43
+ clearTrajectoryCache: typeof clearTrajectoryCache;
42
44
  recordReplayEntry: typeof recordReplayEntry;
43
45
  startReplayRecording: typeof startReplayRecording;
44
46
  telemetry: typeof telemetry;
@@ -58,6 +60,17 @@ interface ToolAfterContext {
58
60
  interface PrmHook {
59
61
  toolAfter: (context: ToolAfterContext) => Promise<void>;
60
62
  }
63
+ interface ResettablePrmSessionState {
64
+ prmEscalationTracker?: EscalationTracker;
65
+ prmInitialized?: boolean;
66
+ prmPatternCounts?: Map<string, number>;
67
+ prmEscalationLevel?: number;
68
+ prmLastPatternDetected?: unknown;
69
+ prmHardStopPending?: boolean;
70
+ prmTrajectoryStep?: number;
71
+ replayArtifactPath?: string | null;
72
+ }
73
+ export declare function resetPrmSessionState(session: ResettablePrmSessionState, sessionId?: string): void;
61
74
  /**
62
75
  * Creates a PRM hook for the given configuration.
63
76
  *
@@ -6,6 +6,23 @@
6
6
  *
7
7
  * Replay artifacts are stored in `.swarm/replays/{sessionId}-{timestamp}.jsonl`
8
8
  */
9
+ /**
10
+ * Validates that a path is within a base directory using canonical path resolution.
11
+ * Rejects paths with traversal attempts (..) or absolute paths pointing outside.
12
+ *
13
+ * @param targetPath - The path to validate
14
+ * @param basePath - The base directory
15
+ * @returns true if path is safe, false otherwise
16
+ */
17
+ declare function isPathSafe(targetPath: string, basePath: string): boolean;
18
+ /**
19
+ * Validates that a path is within the swarm replays directory.
20
+ * Checks that '.swarm' and 'replays' appear as consecutive path segments.
21
+ *
22
+ * @param targetPath - The path to validate
23
+ * @returns true if path is within .swarm/replays/, false otherwise
24
+ */
25
+ declare function isWithinReplaysDir(targetPath: string): boolean;
9
26
  /**
10
27
  * Entry types for replay recording
11
28
  */
@@ -23,6 +40,15 @@ export interface ReplayEntry {
23
40
  /** Entry data payload */
24
41
  data: Record<string, unknown>;
25
42
  }
43
+ /**
44
+ * Sanitizes a string for safe use in filenames.
45
+ * Allows only alphanumeric characters, underscores, and hyphens.
46
+ * All other characters are replaced with underscores.
47
+ *
48
+ * @param input - String to sanitize
49
+ * @returns Sanitized string safe for filenames
50
+ */
51
+ declare function sanitizeFilename(input: string): string;
26
52
  /**
27
53
  * Initializes replay recording for a session.
28
54
  * Creates the replay directory if it doesn't exist.
@@ -42,3 +68,9 @@ export declare function startReplayRecording(sessionID: string, directory: strin
42
68
  * @param entry - Entry to record (without timestamp/sessionID)
43
69
  */
44
70
  export declare function recordReplayEntry(artifactPath: string, sessionID: string, entry: Omit<ReplayEntry, 'timestamp' | 'sessionID'>): Promise<void>;
71
+ export declare const _test_exports: {
72
+ readonly isPathSafe: typeof isPathSafe;
73
+ readonly isWithinReplaysDir: typeof isWithinReplaysDir;
74
+ readonly sanitizeFilename: typeof sanitizeFilename;
75
+ };
76
+ export {};
@@ -33,6 +33,9 @@ export declare function appendTrajectoryEntry(sessionId: string, entry: Trajecto
33
33
  * @returns Array of trajectory entries (empty array if file doesn't exist)
34
34
  */
35
35
  export declare function readTrajectory(sessionId: string, directory: string): Promise<TrajectoryEntry[]>;
36
+ export declare const _test_exports: {
37
+ readonly MAX_TRACKED_TRAJECTORY_SESSIONS: 500;
38
+ };
36
39
  /**
37
40
  * Alias for readTrajectory - retrieves trajectory entries for a session.
38
41
  *
@@ -48,10 +48,12 @@ export interface NeverAppliedEntry {
48
48
  lesson: string;
49
49
  phasesAlive: number;
50
50
  }
51
- export declare function computeLearningMetrics(directory: string, options?: {
51
+ export interface LearningMetricsOptions {
52
52
  now?: Date;
53
53
  currentPhase?: number;
54
- }): Promise<LearningMetrics>;
54
+ signal?: AbortSignal;
55
+ }
56
+ export declare function computeLearningMetrics(directory: string, options?: LearningMetricsOptions): Promise<LearningMetrics>;
55
57
  export declare function formatLearningMarkdown(metrics: LearningMetrics): string;
56
58
  export declare function formatLearningJSON(metrics: LearningMetrics): object;
57
59
  export declare function formatLearningSummary(metrics: LearningMetrics): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.79.1",
3
+ "version": "7.79.5",
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",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/zaxbysauce/opencode-swarm.git"
24
+ "url": "https://github.com/ZaxbyHub/opencode-swarm.git"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public",
@@ -60,6 +60,7 @@
60
60
  ".opencode/skills/critic-gate",
61
61
  ".opencode/skills/execute",
62
62
  ".opencode/skills/phase-wrap",
63
+ ".opencode/skills/loop",
63
64
  "tests/fixtures/memory-recall",
64
65
  "README.md",
65
66
  "LICENSE"