opencode-swarm 7.46.1 → 7.46.3

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.
@@ -19,7 +19,7 @@
19
19
  * `directory` argument injected by `createSwarmTool` / hook constructors — never
20
20
  * from the process working directory.
21
21
  */
22
- import type { KnowledgeApplicationRecord } from './knowledge-types.js';
22
+ import type { KnowledgeApplicationRecord, RetrievalOutcome } from './knowledge-types.js';
23
23
  /** Current event-log record schema version. Bump when the on-disk shape changes. */
24
24
  export declare const KNOWLEDGE_EVENT_SCHEMA_VERSION = 1;
25
25
  /**
@@ -112,6 +112,8 @@ export type KnowledgeEventInput = KnowledgeEvent extends infer T ? T extends Kno
112
112
  export declare const RECEIPT_EVENT_TYPES: ReadonlySet<string>;
113
113
  /** Returns `.swarm/knowledge-events.jsonl` for the given project directory. */
114
114
  export declare function resolveKnowledgeEventsPath(directory: string): string;
115
+ /** Returns `.swarm/knowledge-application.jsonl` for legacy v2 audit records. */
116
+ export declare function resolveLegacyApplicationLogPath(directory: string): string;
115
117
  /** Generate a fresh trace id. One per retrieval; receipts reference it. */
116
118
  export declare function newTraceId(): string;
117
119
  /** Generate a fresh event id. Unique per appended event. */
@@ -135,6 +137,11 @@ export declare function recordKnowledgeEvent(directory: string, event: Knowledge
135
137
  * `readKnowledge` in knowledge-store.ts.
136
138
  */
137
139
  export declare function readKnowledgeEvents(directory: string): Promise<KnowledgeEvent[]>;
140
+ /**
141
+ * Read legacy knowledge-application audit records. Corrupt lines are skipped so
142
+ * stale telemetry cannot break search, promotion, or manual recall.
143
+ */
144
+ export declare function readLegacyApplicationRecords(directory: string): Promise<KnowledgeApplicationRecord[]>;
138
145
  /**
139
146
  * Derived per-entry counters. This is the rollup shape recomputed from the
140
147
  * event log; it maps onto the v2 `RetrievalOutcome` counter fields plus the v3
@@ -182,11 +189,22 @@ export interface CounterRollup {
182
189
  * @param legacyRecords Optional legacy application records (any order).
183
190
  */
184
191
  export declare function recomputeCounters(events: KnowledgeEvent[], legacyRecords?: KnowledgeApplicationRecord[]): Map<string, CounterRollup>;
192
+ /**
193
+ * Fail-open rollup reader for hot paths. Search and promotion use this instead
194
+ * of stale persisted counters so `knowledge_receipt` feedback affects ranking
195
+ * and safety gates immediately.
196
+ */
197
+ export declare function readKnowledgeCounterRollups(directory: string): Promise<Map<string, CounterRollup>>;
198
+ /** Merge event-derived rollups over stored outcome counters for scoring only. */
199
+ export declare function effectiveRetrievalOutcomes(stored: RetrievalOutcome | undefined, rollup: CounterRollup | undefined): RetrievalOutcome;
185
200
  export declare const _internals: {
186
201
  resolveKnowledgeEventsPath: typeof resolveKnowledgeEventsPath;
187
202
  appendKnowledgeEvent: typeof appendKnowledgeEvent;
188
203
  recordKnowledgeEvent: typeof recordKnowledgeEvent;
189
204
  readKnowledgeEvents: typeof readKnowledgeEvents;
205
+ readLegacyApplicationRecords: typeof readLegacyApplicationRecords;
206
+ readKnowledgeCounterRollups: typeof readKnowledgeCounterRollups;
207
+ effectiveRetrievalOutcomes: typeof effectiveRetrievalOutcomes;
190
208
  recomputeCounters: typeof recomputeCounters;
191
209
  newTraceId: typeof newTraceId;
192
210
  newEventId: typeof newEventId;
@@ -5,7 +5,10 @@
5
5
  * compaction. Skips for non-architect agents. Appends rejected-pattern warnings
6
6
  * to prevent re-learning loops.
7
7
  */
8
+ import { recordKnowledgeShown } from './knowledge-application.js';
9
+ import { recordKnowledgeEvent } from './knowledge-events.js';
8
10
  import type { KnowledgeConfig, MessageWithParts } from './knowledge-types.js';
11
+ import { searchKnowledge } from './search-knowledge.js';
9
12
  /**
10
13
  * Creates a knowledge injection hook that injects relevant knowledge into the
11
14
  * architect's message context at phase start. Supports caching for re-injection
@@ -19,3 +22,8 @@ import type { KnowledgeConfig, MessageWithParts } from './knowledge-types.js';
19
22
  export declare function createKnowledgeInjectorHook(directory: string, config: KnowledgeConfig): (input: Record<string, never>, output: {
20
23
  messages?: MessageWithParts[];
21
24
  }) => Promise<void>;
25
+ export declare const _internals: {
26
+ searchKnowledge: typeof searchKnowledge;
27
+ recordKnowledgeEvent: typeof recordKnowledgeEvent;
28
+ recordKnowledgeShown: typeof recordKnowledgeShown;
29
+ };
@@ -16,6 +16,7 @@
16
16
  * updates after the initial scan completes.
17
17
  */
18
18
  import { type RepoGraph } from '../tools/repo-graph';
19
+ import { safeRealpathSync } from '../tools/repo-graph/safe-realpath';
19
20
  export interface RepoGraphBuilderHook {
20
21
  init(): Promise<void>;
21
22
  toolAfter(input: {
@@ -40,5 +41,6 @@ export interface RepoGraphDeps {
40
41
  updateGraphForFiles: (workspace: string, files: string[], options?: {
41
42
  forceRebuild?: boolean;
42
43
  }) => Promise<RepoGraph>;
44
+ safeRealpathSync?: typeof safeRealpathSync;
43
45
  }
44
46
  export declare function createRepoGraphBuilderHook(workspaceRoot: string, deps?: Partial<RepoGraphDeps>): RepoGraphBuilderHook;