dsh-session-recall 0.7.3 → 0.7.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.
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ToolDefinition, ToolRunContext } from "@deepseek-ai/dsh-tools";
2
2
  import { SessionEventResultFilter, SessionEventSearchDocument, SessionEventSearchPage, SessionEventSearchRequest, SessionLineageTrace, SessionRecord, SessionSearchExecContext, SessionSearchHit, SessionSearchPage, SessionSearchRequest, SessionTitleObservationResult } from "@deepseek-ai/dsh-session-query";
3
- import { JsonValue, SessionId } from "@deepseek-ai/dsh-session";
3
+ import { SessionId } from "@deepseek-ai/dsh-session";
4
4
  import { Context } from "@deepseek-ai/cordis";
5
5
  import { ContentBlock } from "@deepseek-ai/dsh-llm";
6
6
  //#region src/redact.d.ts
@@ -56,6 +56,19 @@ interface RecallConfig {
56
56
  * same project are invisible unless this is set to `false`.
57
57
  */
58
58
  callerTreeOnly?: boolean;
59
+ /**
60
+ * When the session index itself fails (`SESSION_QUERY_PERSISTENCE_FAILED`,
61
+ * e.g. one un-migratable artifact failing every indexed search —
62
+ * deepseek-harness discussion #7995), retry with a direct scan of the
63
+ * persisted session logs instead of failing the call. Default `true`.
64
+ */
65
+ rawScanFallback?: boolean;
66
+ /** Max persisted sessions visited by one degraded raw scan. Default `200`. */
67
+ rawScanMaxSessions?: number;
68
+ /** Wall-clock ceiling (ms) for one degraded raw scan. Default `20000`. */
69
+ rawScanMaxDurationMs?: number;
70
+ /** Compressed-size ceiling (bytes) per session log in a degraded scan. Default 8 MiB. */
71
+ rawScanMaxSessionBytes?: number;
59
72
  }
60
73
  /** Validated, fully defaulted configuration. */
61
74
  interface NormalizedRecallConfig {
@@ -72,6 +85,10 @@ interface NormalizedRecallConfig {
72
85
  readonly recencyHalfLifeDays: number | undefined;
73
86
  readonly pinnedCwds: readonly string[];
74
87
  readonly callerTreeOnly: boolean;
88
+ readonly rawScanFallback: boolean;
89
+ readonly rawScanMaxSessions: number;
90
+ readonly rawScanMaxDurationMs: number;
91
+ readonly rawScanMaxSessionBytes: number;
75
92
  }
76
93
  /** Default, clamp, and cross-check every optional field. */
77
94
  declare function normalizeRecallConfig(config?: RecallConfig): NormalizedRecallConfig;
@@ -107,7 +124,7 @@ interface RecallScope {
107
124
  /** How the matches in a result were produced (v0.5 diagnostics). */
108
125
  interface RecallDiagnostics {
109
126
  /** Which engine produced the matches. */
110
- readonly source: 'fts' | 'cjk-fallback' | 'session-scan';
127
+ readonly source: 'fts' | 'cjk-fallback' | 'session-scan' | 'raw-scan';
111
128
  /** Sessions visited by the fallback scan, when it ran. */
112
129
  readonly scanned?: number;
113
130
  /** The fallback scan budget (`cjkFallbackScanMax`), when a scan ran. */
@@ -209,7 +226,8 @@ type RecallApprovalVerdict = 'allowed-once' | 'rejected' | 'cancelled' | 'unavai
209
226
  * Optional user-approval seam for the `all_projects` gate (`allProjectsPolicy:
210
227
  * 'confirm'`). Receives the tool run context (for the agent) and a
211
228
  * human-readable reason; `'allowed-once'` is the only grant. Wired from
212
- * `ctx.approval` in the plugin entry; fail-closed when absent.
229
+ * `ctx.get('approval')` in the plugin entry (optional service, not in
230
+ * `inject`); fail-closed when absent.
213
231
  */
214
232
  type RecallApprover = (exec: ToolRunContext, reason: string) => Promise<RecallApprovalVerdict>;
215
233
  /**
@@ -218,6 +236,13 @@ type RecallApprover = (exec: ToolRunContext, reason: string) => Promise<RecallAp
218
236
  */
219
237
  declare function createRecallTool(config?: RecallConfig, engine?: RecallQueryEngine, approver?: RecallApprover): ToolDefinition;
220
238
  //#endregion
239
+ //#region node_modules/@deepseek-ai/dsh-util-values/lib/types/index.d.ts
240
+ /** Duplicate-install-safe JSON and immutable-value helpers. @module @deepseek-ai/dsh-util-values */
241
+ /** A value that round-trips through JSON without loss. */
242
+ type JsonValue = null | boolean | number | string | JsonValue[] | {
243
+ [key: string]: JsonValue;
244
+ };
245
+ //#endregion
221
246
  //#region src/render.d.ts
222
247
  /**
223
248
  * Render the compact Markdown the model reads: one header line, one line per
@@ -236,6 +261,70 @@ declare function cjkFallbackHint(matched: number, enabled: boolean): string | nu
236
261
  /** The zero-hit hint, shown only when both the full-text and substring paths miss. */
237
262
  declare function cjkZeroHitHint(query: string, zeroHits: boolean, enabled: boolean): string | null;
238
263
  //#endregion
264
+ //#region src/resilient.d.ts
265
+ /** Default scan budget (sessions visited per degraded call). */
266
+ declare const RAW_SCAN_DEFAULT_MAX_SESSIONS = 300;
267
+ /** Hard ceiling for the scan budget. */
268
+ declare const RAW_SCAN_MAX_SESSIONS_MAX = 2000;
269
+ /** Where the harness persists sessions: `$DSH_HOME/sessions` (default `~/.dsh/sessions`). */
270
+ declare function discoverSessionsRoot(): string;
271
+ /** True when an error means "the index is unavailable", not "the query was bad". */
272
+ declare function isIndexOutage(error: unknown): boolean;
273
+ interface RawScanOptions {
274
+ /** Sessions root (workspace directories below this). */
275
+ root: string;
276
+ /** Normalized search query; whitespace-separated terms, all must match. */
277
+ query: string;
278
+ /** Restrict to sessions started in this cwd (unless `allProjects`). */
279
+ cwd: string | null;
280
+ /** Ignore the cwd scope. */
281
+ allProjects: boolean;
282
+ /** Restrict to one session id (the `session_id` argument), or null. */
283
+ sessionId: string | null;
284
+ /** Only sessions newer than this many days (0 = no time filter). */
285
+ sinceDays: number;
286
+ /** Only tool events whose tool name contains one of these substrings. */
287
+ tools: readonly string[] | null;
288
+ /** Only failed tool calls (tool results carrying an error flag). */
289
+ errorsOnly: boolean;
290
+ /** Max sessions to return. */
291
+ limit: number;
292
+ /** Scan budget: max sessions visited. */
293
+ maxSessions: number;
294
+ /** Wall-clock ceiling in ms for the whole pass (0 = no ceiling). */
295
+ maxDurationMs: number;
296
+ /** Compressed-size ceiling per session log; larger logs are skipped (pure-JS zstd is slow). */
297
+ maxSessionBytes: number;
298
+ }
299
+ interface RawScanResult {
300
+ items: RecallItem[];
301
+ /** Sessions whose events were actually scanned. */
302
+ scanned: number;
303
+ /** The scan budget that applied. */
304
+ budget: number;
305
+ /** Sessions skipped because their log could not be decompressed or parsed. */
306
+ unreadable: number;
307
+ /** False when the scan stopped early (budget/ceiling): results cover the newest sessions only. */
308
+ coveredAll: boolean;
309
+ /** In-scope sessions skipped because their log exceeded `maxSessionBytes`. */
310
+ skippedOversized: number;
311
+ /** Session directories that existed under the root when the scan started. */
312
+ totalCandidates: number;
313
+ }
314
+ /**
315
+ * Scan persisted session logs directly, honoring the same scope filters as
316
+ * the indexed path. Never throws for per-session problems; returns what it
317
+ * found plus scan counters.
318
+ *
319
+ * Cost model (newest-first): the header line of every session is read
320
+ * through the streaming decompressor (milliseconds each); only sessions
321
+ * passing the scope filters are decompressed fully, and only sessions whose
322
+ * bytes mention every term are parsed line by line. `maxDurationMs` puts a
323
+ * wall-clock ceiling on the pass — when it trips, `coveredAll` is false and
324
+ * the caller should say so (results cover the newest sessions only).
325
+ */
326
+ declare function rawScanSessions(options: RawScanOptions): Promise<RawScanResult>;
327
+ //#endregion
239
328
  //#region src/util.d.ts
240
329
  /** Small pure helpers shared by the recall tool and its renderers. */
241
330
  /** Clamp `n` into the inclusive `[lo, hi]` range. */
@@ -266,4 +355,4 @@ declare const inject: string[];
266
355
  /** Plugin entry: mount the `recall` tool on the global tool registry. */
267
356
  declare function apply(ctx: Context, config?: RecallConfig): void;
268
357
  //#endregion
269
- export { ALL_PROJECTS_POLICIES, type AllProjectsPolicy, type NormalizedRecallConfig, RECALL_TOOL_DESCRIPTION, REDACTION_MODES, type RankableItem, type RankingOptions, type RecallApprovalVerdict, type RecallApprover, type RecallArgs, type RecallBestMatch, type RecallConfig, type RecallDiagnostics, type RecallItem, type RecallQueryEngine, type RecallResult, type RecallScope, type RedactionMode, apply, cjkFallbackHint, cjkZeroHitHint, clamp, createRecallTool, cwdAllowed, firstLineClipped, formatDate, hasCJK, id8, inject, name, normalizeQuery, normalizeRecallConfig, normalizeRedactionMode, rankItems, rankingActive, recallContentBlocks, recallPresentationMeta, redactText, renderRecallText, snippetAround };
358
+ export { ALL_PROJECTS_POLICIES, type AllProjectsPolicy, type NormalizedRecallConfig, RAW_SCAN_DEFAULT_MAX_SESSIONS, RAW_SCAN_MAX_SESSIONS_MAX, RECALL_TOOL_DESCRIPTION, REDACTION_MODES, type RankableItem, type RankingOptions, type RawScanOptions, type RawScanResult, type RecallApprovalVerdict, type RecallApprover, type RecallArgs, type RecallBestMatch, type RecallConfig, type RecallDiagnostics, type RecallItem, type RecallQueryEngine, type RecallResult, type RecallScope, type RedactionMode, apply, cjkFallbackHint, cjkZeroHitHint, clamp, createRecallTool, cwdAllowed, discoverSessionsRoot, firstLineClipped, formatDate, hasCJK, id8, inject, isIndexOutage, name, normalizeQuery, normalizeRecallConfig, normalizeRedactionMode, rankItems, rankingActive, rawScanSessions, recallContentBlocks, recallPresentationMeta, redactText, renderRecallText, snippetAround };