@autorag/librarian 2.13.0 → 2.13.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 (56) hide show
  1. package/NOTICE +9 -9
  2. package/README.md +25 -9
  3. package/dist/agent/agent.d.ts +12 -6
  4. package/dist/agent/answer-guidelines.d.ts +3 -3
  5. package/dist/agent/refresh-progress.d.ts +4 -0
  6. package/dist/agent/search-documents.d.ts +3 -1
  7. package/dist/agent/search-progress.d.ts +5 -0
  8. package/dist/cli/commands/attachments.d.ts +13 -0
  9. package/dist/cli/index.d.ts +1 -1
  10. package/dist/cli/index.js +8688 -6851
  11. package/dist/convert/installer.d.ts +1 -1
  12. package/dist/core.js +5969 -4248
  13. package/dist/datasource/connector-skill.d.ts +1 -2
  14. package/dist/datasource/connector.d.ts +2 -3
  15. package/dist/datasource/index.d.ts +1 -2
  16. package/dist/datasource/sidecar/descriptors.d.ts +14 -1
  17. package/dist/datasource/sidecar/index.d.ts +4 -0
  18. package/dist/datasource/sidecar/methods.d.ts +5 -2
  19. package/dist/datasource/skills/discrawl/attachments.d.ts +139 -0
  20. package/dist/datasource/skills/discrawl/client.d.ts +11 -1
  21. package/dist/datasource/skills/discrawl/index.d.ts +2 -1
  22. package/dist/datasource/skills/discrawl/ranked-method.d.ts +19 -0
  23. package/dist/datasource/skills/discrawl/sidecar.d.ts +21 -0
  24. package/dist/datasource/skills/discrawl/skill.d.ts +18 -2
  25. package/dist/datasource/skills/discrawl/types.d.ts +41 -0
  26. package/dist/datasource/skills/factory.d.ts +12 -1
  27. package/dist/datasource/skills/hister/client.d.ts +5 -5
  28. package/dist/datasource/skills/hister/setup.d.ts +5 -0
  29. package/dist/datasource/skills/mailcrawl/types.d.ts +18 -0
  30. package/dist/datasource/skills/spotlight/connector.d.ts +16 -24
  31. package/dist/datasource/skills/spotlight/index.d.ts +2 -2
  32. package/dist/datasource/skills/spotlight/skill.d.ts +26 -13
  33. package/dist/index.js +6027 -4305
  34. package/dist/mcp/index.js +6021 -4293
  35. package/dist/minsync/client.d.ts +2 -2
  36. package/dist/minsync/index.d.ts +1 -1
  37. package/dist/minsync/installer.d.ts +1 -1
  38. package/dist/minsync/method.d.ts +3 -3
  39. package/dist/minsync/process.d.ts +1 -0
  40. package/dist/minsync/stage.d.ts +361 -0
  41. package/dist/minsync/types.d.ts +4 -0
  42. package/dist/minsync/workspace.d.ts +2 -1
  43. package/dist/mirror/index-store.d.ts +16 -15
  44. package/dist/mirror/index.d.ts +2 -2
  45. package/dist/mirror/paths.d.ts +0 -2
  46. package/dist/mirror/sync.d.ts +6 -15
  47. package/dist/parser/types.d.ts +2 -2
  48. package/dist/process/lifecycle.d.ts +10 -0
  49. package/dist/profiles.js +6525 -4804
  50. package/dist/retrieval/scope.d.ts +1 -1
  51. package/package.json +14 -15
  52. package/skills/autorag-lite-setup/SKILL.md +27 -3
  53. package/skills/autorag-setup/SKILL.md +32 -8
  54. package/dist/datasource/skills/mail-export/connector.d.ts +0 -21
  55. package/dist/datasource/skills/mail-export/index.d.ts +0 -2
  56. package/dist/datasource/skills/mail-export/skill.d.ts +0 -20
@@ -1,4 +1,4 @@
1
- import type { MinSyncEmbedderConfig, MinSyncQueryHit, MinSyncSyncResult } from "./types.js";
1
+ import type { MinSyncEmbedderConfig, MinSyncQueryHit, MinSyncSyncProgress, MinSyncSyncResult } from "./types.js";
2
2
  export interface MinSyncClientOptions {
3
3
  readonly binaryPath: string;
4
4
  readonly workspacePath: string;
@@ -32,7 +32,7 @@ export declare class MinSyncClient {
32
32
  private readIdentity;
33
33
  private writeIdentity;
34
34
  private identityMismatch;
35
- sync(force?: boolean, signal?: AbortSignal): Promise<MinSyncSyncResult>;
35
+ sync(force?: boolean, signal?: AbortSignal, onProgress?: (progress: MinSyncSyncProgress) => void): Promise<MinSyncSyncResult>;
36
36
  /**
37
37
  * The tokenizer to run this sync with: always {@link MINSYNC_LEXICAL_LANGUAGE}, which fails every sync when the
38
38
  * Kiwi native library is missing. A workspace that is new, or tokenized differently, then gets whitespace
@@ -5,5 +5,5 @@ export { type EnsureMinSyncBinaryOptions, ensureMinSyncBinary, executableName, f
5
5
  export { ensureLocalEmbedder, LocalEmbedderError, type LocalEmbedderPreflightOptions, } from "./local-embedder.js";
6
6
  export { MinSyncHybridMethod, type MinSyncHybridMethodOptions, MinSyncVectorMethod, type MinSyncVectorMethodOptions, } from "./method.js";
7
7
  export { MINSYNC_FILES_SUBDIR, MINSYNC_SUBDIR, minSyncDocumentPath, minSyncWorkspaceRoot } from "./paths.js";
8
- export type { MinSyncChunkerConfig, MinSyncDiagnostic, MinSyncEmbedderConfig, MinSyncFileFailure, MinSyncOptions, MinSyncQueryHit, MinSyncSyncResult, } from "./types.js";
8
+ export type { MinSyncChunkerConfig, MinSyncDiagnostic, MinSyncEmbedderConfig, MinSyncFileFailure, MinSyncOptions, MinSyncQueryHit, MinSyncSyncProgress, MinSyncSyncResult, } from "./types.js";
9
9
  export { buildMinSyncPathMap, type MinSyncWorkspaceEntry, type MinSyncWorkspaceSyncResult, syncMinSyncWorkspace, } from "./workspace.js";
@@ -1,4 +1,4 @@
1
- export declare const MINSYNC_VERSION = "0.4.12";
1
+ export declare const MINSYNC_VERSION = "0.5.1";
2
2
  export declare const MINSYNC_CARGO_INSTALL_TIMEOUT_MS: number;
3
3
  export interface MinSyncReleaseAsset {
4
4
  readonly name: string;
@@ -1,7 +1,7 @@
1
1
  import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
2
2
  import type { MinSyncQueryMode } from "./client.js";
3
3
  import type { EnsureMinSyncBinaryOptions } from "./installer.js";
4
- import type { MinSyncEmbedderConfig, MinSyncSyncResult } from "./types.js";
4
+ import type { MinSyncEmbedderConfig, MinSyncSyncProgress, MinSyncSyncResult } from "./types.js";
5
5
  export interface MinSyncVectorMethodOptions {
6
6
  readonly root: string;
7
7
  /** Test/embedded override; CLI config intentionally does not persist this. */
@@ -31,7 +31,7 @@ export declare class MinSyncVectorMethod implements RetrievalMethod {
31
31
  private readonly scopedTopK;
32
32
  constructor(options: MinSyncVectorMethodOptions);
33
33
  describe(): RetrievalMethodDescriptor;
34
- sync(force?: boolean, signal?: AbortSignal): Promise<MinSyncSyncResult>;
34
+ sync(force?: boolean, signal?: AbortSignal, onProgress?: (progress: MinSyncSyncProgress) => void): Promise<MinSyncSyncResult>;
35
35
  private syncUnlocked;
36
36
  /** Report unavailable binaries without treating auto-install as already failed. */
37
37
  isBinaryMissing(): boolean;
@@ -45,7 +45,7 @@ export declare class MinSyncVectorMethod implements RetrievalMethod {
45
45
  * Queries pass `install: false` so a user's turn never waits on `cargo install`; only `sync` (refresh)
46
46
  * may install. See {@link resolveMinSyncBinary}.
47
47
  */
48
- protected resolveBinary(options?: {
48
+ resolveBinary(options?: {
49
49
  readonly install?: boolean;
50
50
  }): Promise<string>;
51
51
  }
@@ -9,4 +9,5 @@ export declare function spawnProcess(command: string, args: readonly string[], c
9
9
  readonly timeoutMs?: number;
10
10
  readonly signal?: AbortSignal;
11
11
  readonly env?: NodeJS.ProcessEnv;
12
+ readonly onStdoutLine?: (line: string) => void;
12
13
  }): Promise<ProcessResult>;
@@ -0,0 +1,361 @@
1
+ /**
2
+ * The host side of MinSync's materialization-stage protocol: one JSON request
3
+ * per line on the child's stdin, one JSON response per line on its stdout
4
+ * (`minsync stage --state-dir DIR`).
5
+ *
6
+ * One session is one run. MinSync holds the stage's state lock from `open`
7
+ * until `finish` or exit, and the OS releases it on any exit, so a session that
8
+ * ends without `finish` (EOF, a signal, a crash) leaves the journal behind and
9
+ * the next `open` resumes from it. Requests are strictly sequential: one
10
+ * request is in flight at a time, whatever the caller does.
11
+ *
12
+ * Keys and output paths stay exactly as given: both are relative to the
13
+ * session's source listing and to `output_root`, and MinSync validates them at
14
+ * its own boundary. MinSync is the only authority on what a request means — a
15
+ * refusal rejects with its protocol code and the session stays usable, while a
16
+ * request that MinSync never answers (EOF, a dead host-side pipe) rejects too,
17
+ * so nothing waits on a process that is gone. Each request returns its own
18
+ * promise; a caller that does not await one owns its rejection.
19
+ *
20
+ * `plan` and `inspect` are the read-only doors onto the same state: neither
21
+ * opens a run, takes the lock, or writes anything, so either may be used
22
+ * before `open` or while this session's own run is open.
23
+ *
24
+ * `open` is the only mutation, so it performs one `capabilities` handshake
25
+ * first: a build that does not speak this transport's protocol is refused with
26
+ * `unsupported_protocol` before any state is touched.
27
+ */
28
+ /** What MinSync decided for one item. Only `process`, `retry` and `delete` are work to do. */
29
+ export type MinSyncStageAction = "process" | "retry" | "skip" | "delete" | "preserve";
30
+ export type MinSyncStageVerify = "fast" | "digest";
31
+ /**
32
+ * What a MinSync build says it can do, from the `capabilities` op: the stage
33
+ * protocol revision and the named capabilities it implements.
34
+ */
35
+ export interface MinSyncStageCapabilities {
36
+ /** Stage protocol revision; the durable-outcome protocol this host needs is 2. */
37
+ readonly protocol: number;
38
+ readonly features: readonly string[];
39
+ }
40
+ /** One current source item, relative to the stage's source listing. */
41
+ export interface MinSyncStageItem {
42
+ readonly key: string;
43
+ /**
44
+ * Any host-chosen string that changes whenever the item's content or its
45
+ * processing does — the mirror sends a stable JSON identity of the source
46
+ * path, parser and sizes. Opaque here: the transport passes it through.
47
+ */
48
+ readonly version: string;
49
+ }
50
+ export interface MinSyncStageOpenInput {
51
+ /** Stage name: 1-64 characters of `[A-Za-z0-9._-]`, not starting with `.` or `-`. */
52
+ readonly stage: string;
53
+ /** Corpus identity; one state directory belongs to exactly one. */
54
+ readonly source_id: string;
55
+ /** Everything that changes what the stage produces (parser name and version, output format, ...). */
56
+ readonly fingerprint: string;
57
+ /** Directory holding every output; MinSync creates it if missing. */
58
+ readonly output_root: string;
59
+ /** The whole current source. An item absent from `items` and from `unknown` is confirmed gone. */
60
+ readonly items: readonly MinSyncStageItem[];
61
+ /** Keys the source could not be observed for: their previous output is kept, never deleted. */
62
+ readonly unknown?: readonly string[];
63
+ /** Reuse only what this run committed itself, via its own ledger. */
64
+ readonly full?: boolean;
65
+ readonly verify?: MinSyncStageVerify;
66
+ /**
67
+ * Identity of the host's retry policy. A deferred failure is only retried
68
+ * once this differs from the one it was deferred under, so a stage that
69
+ * changes how it retries does not inherit the previous policy's deferrals.
70
+ */
71
+ readonly retry_fingerprint?: string;
72
+ /** Release every deferred failure now, whatever it was deferred against. */
73
+ readonly retry_failed?: boolean;
74
+ /** Wait for another run's lock instead of failing. */
75
+ readonly wait?: boolean;
76
+ }
77
+ export interface MinSyncStageCounts {
78
+ readonly process: number;
79
+ readonly retry: number;
80
+ readonly skip: number;
81
+ /** Skips that rest on the interrupted run's ledger (a subset of `skip`). */
82
+ readonly resumed: number;
83
+ readonly delete: number;
84
+ readonly preserve: number;
85
+ }
86
+ export interface MinSyncStageDecision {
87
+ readonly key: string;
88
+ readonly action: MinSyncStageAction;
89
+ /** The source version to process; absent for `skip`, `delete` and `preserve`. */
90
+ readonly version?: string;
91
+ /**
92
+ * Set on the `skip` that stands in for a deferred failure: MinSync is
93
+ * deliberately not retrying until the source, the settings or the retry
94
+ * fingerprint change, or the host releases it. `open` reports these so the
95
+ * host can diagnose them; an unchanged successful skip stays a count.
96
+ */
97
+ readonly deferred?: boolean;
98
+ /** The recorded failure message behind a deferred `skip`. */
99
+ readonly error?: string;
100
+ }
101
+ export interface MinSyncStageOpenReport {
102
+ readonly run_token: string;
103
+ /** An interrupted run's ledger was resumed. */
104
+ readonly resumed: boolean;
105
+ readonly counts: MinSyncStageCounts;
106
+ /**
107
+ * Work still to do, in key order, plus a `skip` for every deferred failure
108
+ * MinSync is holding back. Unchanged successful skips stay in `counts`.
109
+ */
110
+ readonly decisions: readonly MinSyncStageDecision[];
111
+ }
112
+ /** What the host wrote, relative to `output_root`. `size` and `digest` are optional cross-checks. */
113
+ export interface MinSyncStageOutput {
114
+ readonly path: string;
115
+ readonly size?: number;
116
+ readonly digest?: string;
117
+ }
118
+ /** What MinSync recorded: measured itself, not what the host claimed. */
119
+ export interface MinSyncStageRecordedOutput {
120
+ readonly path: string;
121
+ readonly size: number;
122
+ readonly digest: string;
123
+ }
124
+ export interface MinSyncStageFinishReport {
125
+ /** Items committed in this run, including ones resumed from its ledger. */
126
+ readonly committed: number;
127
+ readonly deleted: number;
128
+ readonly failed: number;
129
+ /** Items the next run still has to do. */
130
+ readonly pending: number;
131
+ }
132
+ /** How `fail` records an item beyond the failure itself. */
133
+ export interface MinSyncStageFailOptions {
134
+ /**
135
+ * Keep MinSync from retrying this exact failure until the source, the
136
+ * settings or the retry fingerprint change, or the host releases it with
137
+ * `retry_failed`. The item's previous output stays either way.
138
+ */
139
+ readonly defer?: boolean;
140
+ /**
141
+ * Remove the item's known output through MinSync, so a later run can no
142
+ * longer reuse it. Without this the last good output is preserved.
143
+ */
144
+ readonly discard_output?: boolean;
145
+ }
146
+ /** A stage to reconstruct the durable state of; no open session is needed. */
147
+ export interface MinSyncStageInspectInput {
148
+ readonly stage: string;
149
+ readonly source_id: string;
150
+ readonly output_root: string;
151
+ readonly verify?: MinSyncStageVerify;
152
+ }
153
+ /** One durable output, as the recorded commit measured it. */
154
+ export interface MinSyncStageInspectOutput {
155
+ readonly path: string;
156
+ readonly size: number;
157
+ readonly digest: string;
158
+ /** Modification time at commit, in nanoseconds, as a decimal string. */
159
+ readonly mtime_ns: string;
160
+ }
161
+ /** One source item MinSync holds a verified output for. */
162
+ export interface MinSyncStageInspectItem {
163
+ readonly key: string;
164
+ /** The host's own source version for the item; MinSync only stores it. */
165
+ readonly version: string;
166
+ readonly fingerprint: string;
167
+ readonly output: MinSyncStageInspectOutput;
168
+ /** Stable timestamp of this output, derived from the recorded mtime. */
169
+ readonly updated_at: string;
170
+ }
171
+ /** The latest failure MinSync holds for an item. */
172
+ export interface MinSyncStageInspectFailure {
173
+ readonly key: string;
174
+ /** The source version that failed, absent when the host did not name one. */
175
+ readonly version: string | null;
176
+ readonly error: string;
177
+ /** MinSync is holding the failure back instead of retrying it. */
178
+ readonly deferred: boolean;
179
+ }
180
+ /** A deliberate omission MinSync recorded for an item. */
181
+ export interface MinSyncStageInspectSkip {
182
+ readonly key: string;
183
+ readonly version: string;
184
+ readonly reason: string;
185
+ readonly fingerprint: string;
186
+ }
187
+ /** A key MinSync still holds durable state for, and the version it holds it at. */
188
+ export interface MinSyncStageInspectKnown {
189
+ readonly key: string;
190
+ /**
191
+ * The failure's version when MinSync holds one, else the omission's, else
192
+ * the completion's. `null` only for a legacy failure the host never named.
193
+ */
194
+ readonly version: string | null;
195
+ }
196
+ /**
197
+ * The durable state of a stage: every output that still verifies, every
198
+ * failure and every deliberate omission. An item can appear in `items` with
199
+ * its last good output and in `failed` for a newer version at the same time.
200
+ */
201
+ export interface MinSyncStageInspectReport {
202
+ readonly items: readonly MinSyncStageInspectItem[];
203
+ readonly failed: readonly MinSyncStageInspectFailure[];
204
+ readonly skipped: readonly MinSyncStageInspectSkip[];
205
+ /**
206
+ * Every key the durable state holds, whatever the three lists above report:
207
+ * a key stays here when its output no longer verifies or when its failure is
208
+ * deferred. Always present, empty when the state holds nothing.
209
+ */
210
+ readonly known: readonly MinSyncStageInspectKnown[];
211
+ }
212
+ export interface MinSyncStagePlanReport {
213
+ readonly counts: MinSyncStageCounts;
214
+ /**
215
+ * Every item's decision, in key order — `skip` and `preserve` included, so
216
+ * the host can report staleness without opening a run.
217
+ */
218
+ readonly decisions: readonly MinSyncStageDecision[];
219
+ }
220
+ /**
221
+ * A stage session failure. `code` is MinSync's protocol code when it refused the
222
+ * request (`invalid_output_path`, `output_missing`, `version_mismatch`,
223
+ * `unknown_item`, `still_present`, `lock_failed`, ...) and a transport code when
224
+ * it never answered: `spawn_failed`, `eof`, `invalid_response`, `process_failed`.
225
+ */
226
+ export declare class MinSyncStageError extends Error {
227
+ readonly code: string;
228
+ readonly op: string | undefined;
229
+ /** Tail of the session's stderr, for a failure MinSync could not report itself. */
230
+ readonly stderr: string;
231
+ constructor(code: string, message: string, details?: {
232
+ readonly op?: string;
233
+ readonly stderr?: string;
234
+ });
235
+ }
236
+ export declare class MinSyncStageSession {
237
+ private readonly child;
238
+ private readonly lines;
239
+ private readonly signal;
240
+ private readonly exitPromise;
241
+ private readonly settleExit;
242
+ /** The caller gave up: stop the tree, then reject with the caller's own reason. */
243
+ private readonly abortHandler;
244
+ private stderrTail;
245
+ private stderrTruncated;
246
+ private pending;
247
+ private closedReason;
248
+ private exit;
249
+ private tail;
250
+ private closing;
251
+ /** The one capability handshake this session performs, before it mutates. */
252
+ private handshake;
253
+ private escalation;
254
+ /**
255
+ * Start `minsync stage --state-dir stateDir` in `cwd`. `stateDir` holds the
256
+ * run's lock, marker, journal and snapshot, and belongs to one stage and one
257
+ * source. An aborted `signal` rejects the in-flight request with the signal's
258
+ * reason and takes the process tree down, which releases the stage lock.
259
+ */
260
+ constructor(binaryPath: string, stateDir: string, cwd: string, signal?: AbortSignal);
261
+ /**
262
+ * Open a run, or resume the interrupted one, and return what it still has to
263
+ * do. A refusal (bad key, duplicate item, held lock, ...) rejects with its
264
+ * protocol code.
265
+ *
266
+ * A run is the first thing this transport mutates, so it first asks the
267
+ * build what it implements — once per session — and refuses to start
268
+ * against one that cannot own durable parsing outcomes.
269
+ */
270
+ open(input: MinSyncStageOpenInput): Promise<MinSyncStageOpenReport>;
271
+ /** Check this binary's contract without opening or creating a stage. */
272
+ verifyProtocol(): Promise<void>;
273
+ /**
274
+ * The one capability handshake this session performs, started on first use
275
+ * and always inside the request queue: a build from before the extended
276
+ * protocol answers the capabilities op with a refusal, or claims less than
277
+ * a run requires, and both become `unsupported_protocol`.
278
+ */
279
+ private capabilities;
280
+ private checkCapabilities;
281
+ /**
282
+ * Preview what a run with the same request would do, without opening one:
283
+ * no lock, no journal, no snapshot write. Unlike `open` it lists every
284
+ * decision — `skip` and `preserve` included — so the host can report
285
+ * staleness without a session.
286
+ */
287
+ plan(input: MinSyncStageOpenInput): Promise<MinSyncStagePlanReport>;
288
+ /**
289
+ * Reconstruct a stage's durable state from its snapshot and journal and
290
+ * verify every recorded output. Non-mutating: it takes no lock, so it is
291
+ * safe while another run of the same stage is open (that run's own journal
292
+ * records are merged in), and it needs no `open` of its own.
293
+ */
294
+ inspect(input: MinSyncStageInspectInput): Promise<MinSyncStageInspectReport>;
295
+ /**
296
+ * Commit an item's output: `output.path` is relative to `output_root` and must
297
+ * already be written. MinSync checks the file and returns what it recorded.
298
+ */
299
+ commit(key: string, version: string, output: MinSyncStageOutput): Promise<MinSyncStageRecordedOutput>;
300
+ /**
301
+ * Record that an item could not be produced. Its previous output stays
302
+ * intact unless `discard_output` asks MinSync to remove it, and `defer`
303
+ * keeps MinSync from retrying this same failure until the source, the
304
+ * settings or the retry fingerprint change.
305
+ */
306
+ fail(key: string, version: string, error: string, options?: MinSyncStageFailOptions): Promise<void>;
307
+ /**
308
+ * Record a deliberate omission: the item was considered and intentionally
309
+ * produced nothing, which is not a failure. MinSync removes any previous
310
+ * output of the item and stops asking for it while the source version and
311
+ * the settings stay the same.
312
+ */
313
+ skip(key: string, version: string, reason: string): Promise<void>;
314
+ /**
315
+ * Delete an item's recorded output, which must be absent from `items` and from
316
+ * `unknown`. Idempotent; returns whether a file was removed.
317
+ */
318
+ delete(key: string): Promise<boolean>;
319
+ /**
320
+ * Fold this run into the snapshot and end the session with exit code 0, which
321
+ * is what makes the run complete rather than resumable. Fails if the session
322
+ * dies without finishing, or finishes with any other exit code.
323
+ */
324
+ finish(): Promise<MinSyncStageFinishReport>;
325
+ /**
326
+ * End the session without `finish`: the run stays in the journal and the next
327
+ * `open` resumes it. Idempotent, and always reaps the child — stdin closes,
328
+ * then SIGTERM, then SIGKILL — so no stage lock holder is left behind.
329
+ */
330
+ close(): Promise<void>;
331
+ private reap;
332
+ /** One outstanding line-in/line-out exchange at a time, whatever the caller awaits. */
333
+ private send;
334
+ /**
335
+ * Run `work` after every request already issued and before any later one,
336
+ * so a job of several exchanges — the handshake and the open — is atomic
337
+ * with respect to a caller that does not await its requests.
338
+ */
339
+ private enqueue;
340
+ private exchange;
341
+ private write;
342
+ private onLine;
343
+ private onExit;
344
+ /** SIGTERM the process tree, escalating to SIGKILL when it does not go. */
345
+ private terminate;
346
+ /** The session is unusable from here on: reject whatever is in flight. */
347
+ private failSession;
348
+ private appendStderr;
349
+ private stderrText;
350
+ }
351
+ /**
352
+ * Read a stage's durable state in one synchronous round trip, for callers that
353
+ * reconstruct state while they are already synchronous. Exactly one `inspect`
354
+ * line is written and stdin is closed, so a helper that answers and then exits
355
+ * non-zero on EOF is still fine — code 0 or 1 with a valid answer is success.
356
+ *
357
+ * Anything else throws `MinSyncStageError`: MinSync's own refusal code, a
358
+ * transport code (`spawn_failed`, `process_failed`) or `unsupported_protocol`
359
+ * when the build simply never answered.
360
+ */
361
+ export declare function readMinSyncStage(binaryPath: string, stateDir: string, cwd: string, input: MinSyncStageInspectInput): MinSyncStageInspectReport;
@@ -26,6 +26,10 @@ export interface MinSyncOptions {
26
26
  readonly embedder?: MinSyncEmbedderConfig;
27
27
  readonly maxChunkSize?: number;
28
28
  }
29
+ export interface MinSyncSyncProgress {
30
+ readonly processed: number;
31
+ readonly total: number;
32
+ }
29
33
  export interface MinSyncSyncResult {
30
34
  readonly ok: boolean;
31
35
  readonly synced: number;
@@ -16,5 +16,6 @@ export interface MinSyncWorkspaceSyncResult {
16
16
  }
17
17
  export declare function syncMinSyncWorkspace(root: string, options?: {
18
18
  readonly workspacePath?: string;
19
+ readonly minSyncBinaryPath?: string;
19
20
  }): MinSyncWorkspaceSyncResult;
20
- export declare function buildMinSyncPathMap(root: string, workspacePath: string): ReadonlyMap<string, MinSyncWorkspaceEntry>;
21
+ export declare function buildMinSyncPathMap(root: string, workspacePath: string, minSyncBinaryPath?: string): ReadonlyMap<string, MinSyncWorkspaceEntry>;
@@ -1,3 +1,5 @@
1
+ import { type MinSyncStageInspectReport } from "../minsync/stage.js";
2
+ /** A read-only application view of MinSync-owned committed source metadata. */
1
3
  export interface ParsedMirrorEntry {
2
4
  readonly virtualPath: string;
3
5
  readonly sourcePath: string;
@@ -6,35 +8,34 @@ export interface ParsedMirrorEntry {
6
8
  readonly sourceMtimeNs: number;
7
9
  readonly sourceSizeBytes: number;
8
10
  readonly updatedAt: string;
11
+ readonly parserVersion?: string;
12
+ readonly sourceVersion?: string;
13
+ readonly parserFingerprint?: string;
9
14
  }
10
- /** Why refresh deliberately left a source out of the parsed mirror. */
11
15
  export type ParsedMirrorSkipReason = "duplicate-excluded" | "user-excluded" | "parser-skipped" | "parser-failed" | "source-unreadable";
12
- /**
13
- * A source the last refresh decided not to mirror, pinned to the exact version it
14
- * decided on. Staleness checks compare against this record instead of re-deriving
15
- * the decision, so a deliberately skipped file is not reported as a new source.
16
- *
17
- * Retryable skips (`parser-failed`, `source-unreadable`) also carry the parser stamp, so refresh
18
- * can honor the record without reading or parsing the file again.
19
- */
16
+ /** Projected from engine outcomes; never stored or used to schedule work by the host. */
20
17
  export interface ParsedMirrorSkipEntry {
21
18
  readonly virtualPath: string;
22
19
  readonly sourcePath: string;
23
20
  readonly reason: ParsedMirrorSkipReason;
24
21
  readonly sourceMtimeNs: number;
25
22
  readonly sourceSizeBytes: number;
26
- readonly updatedAt: string;
27
- /** `Parser.name` the skip was decided with. */
28
23
  readonly parserName?: string;
29
- /** `Parser.version` the skip was decided with. Absent on records written before version stamps. */
30
24
  readonly parserVersion?: string;
25
+ readonly parserFingerprint?: string;
31
26
  }
32
27
  export interface ParsedMirrorIndex {
33
28
  readonly version: 1;
34
29
  readonly entries: Readonly<Record<string, ParsedMirrorEntry>>;
35
- /** Deliberate skips recorded by the last refresh. Absent in indexes written before this field existed. */
36
30
  readonly skipped?: Readonly<Record<string, ParsedMirrorSkipEntry>>;
31
+ /** All engine-held identities, including missing outputs and ordinary failures; never reusable outputs. */
32
+ readonly known?: readonly string[];
37
33
  }
38
34
  export declare function emptyMirrorIndex(): ParsedMirrorIndex;
39
- export declare function loadMirrorIndex(root: string): ParsedMirrorIndex;
40
- export declare function saveMirrorIndex(root: string, index: ParsedMirrorIndex): void;
35
+ export declare function mirrorStageKey(virtualPath: string): string;
36
+ export declare function loadMirrorIndex(root: string, options?: {
37
+ readonly minSyncBinaryPath?: string;
38
+ }): ParsedMirrorIndex;
39
+ /** Decode only the host's own opaque source payload, never the engine's disk format. */
40
+ export declare function mirrorSourceMetadata(version: string | null): Omit<ParsedMirrorEntry, "outputPath" | "updatedAt"> | undefined;
41
+ export declare function mirrorIndexFromStage(root: string, report: MinSyncStageInspectReport): ParsedMirrorIndex;
@@ -1,5 +1,5 @@
1
1
  export type { ParsedMirrorEntry, ParsedMirrorIndex } from "./index-store.js";
2
- export { emptyMirrorIndex, loadMirrorIndex, saveMirrorIndex } from "./index-store.js";
3
- export { isParsedRefreshComplete, parsedMirrorIndexPath, parsedMirrorRoot, parsedOutputPath, refreshReadinessPath, } from "./paths.js";
2
+ export { emptyMirrorIndex, loadMirrorIndex } from "./index-store.js";
3
+ export { isParsedRefreshComplete, parsedMirrorRoot, parsedOutputPath, refreshReadinessPath, } from "./paths.js";
4
4
  export type { ParsedMirrorDiagnostic, ParsedMirrorDiagnosticCode, ParsedMirrorProgress, ParsedMirrorSyncOptions, ParsedMirrorSyncResult, } from "./sync.js";
5
5
  export { DEFAULT_MAX_SOURCE_BYTES, DEFAULT_TRANSIENT_RETRIES, detectMirrorStaleness, isPathExcluded, MirrorWorkspaceError, syncParsedMirrors, } from "./sync.js";
@@ -1,10 +1,8 @@
1
1
  export declare const PARSED_MIRROR_SUBDIR: string;
2
2
  export declare const PARSED_FILES_SUBDIR = "files";
3
- export declare const PARSED_INDEX_FILE = "index.json";
4
3
  export declare const REFRESH_READINESS_FILE = "refresh-complete.json";
5
4
  export declare const REFRESH_PROGRESS_FILE = "refresh-progress.json";
6
5
  export declare function parsedMirrorRoot(root: string): string;
7
- export declare function parsedMirrorIndexPath(root: string): string;
8
6
  export declare function parsedOutputPath(root: string, virtualPath: string): string;
9
7
  export declare function refreshReadinessPath(root: string): string;
10
8
  export declare function refreshProgressPath(root: string): string;
@@ -2,8 +2,6 @@ import { type DefaultParserRegistryOptions } from "../parser/defaults.js";
2
2
  import type { ParserRegistry } from "../parser/registry.js";
3
3
  /** Refuse to fully load/parse sources larger than this. Keeps Node heap stable on home folders. */
4
4
  export declare const DEFAULT_MAX_SOURCE_BYTES: number;
5
- /** Persist partial mirror progress this often so an OOM mid-run still restarts incrementally. */
6
- export declare const MIRROR_CHECKPOINT_EVERY = 25;
7
5
  /** A refresh may delete at most this share of the indexed documents (above {@link MASS_DELETE_FLOOR}). */
8
6
  export declare const DEFAULT_MAX_DELETE_RATIO = 0.3;
9
7
  /** Directory entries examined per search root before the walk stops. */
@@ -16,6 +14,8 @@ export interface ParsedMirrorSyncOptions {
16
14
  readonly registry?: ParserRegistry;
17
15
  readonly parserOptions?: DefaultParserRegistryOptions;
18
16
  readonly force?: boolean;
17
+ /** Embedded/test binary override; the normal path resolves the installed MinSync. */
18
+ readonly minSyncBinaryPath?: string;
19
19
  /** Override max source size for parse attempts (bytes). */
20
20
  readonly maxSourceBytes?: number;
21
21
  /** Absolute source paths omitted from parsed mirrors (for example exact duplicate copies). */
@@ -28,8 +28,8 @@ export interface ParsedMirrorSyncOptions {
28
28
  */
29
29
  readonly retrySkipped?: boolean;
30
30
  /**
31
- * Stops the sync between files and kills an in-flight parse worker. The sync rejects with the signal's
32
- * reason after checkpointing the mirror, so finished files are not re-parsed next time.
31
+ * Stops between files and kills an in-flight parse worker. Rejects with the signal's
32
+ * reason; MinSync's durable journal retains completed items for the next run.
33
33
  */
34
34
  readonly signal?: AbortSignal;
35
35
  /** Called before each file and once more with `processed === total` when the parse phase ends. */
@@ -63,7 +63,7 @@ export interface ParsedMirrorProgress {
63
63
  /** The file about to be processed; absent on the final event. */
64
64
  readonly currentVirtualPath?: string;
65
65
  }
66
- export type ParsedMirrorDiagnosticCode = "unsupported-file" | "parser-skipped" | "parser-failed" | "parser-crashed" | "source-vanished" | "source-unreadable" | "source-read-failed" | "mirror-write-failed" | "duplicate-excluded" | "deleted-mirror" | "stale-index" | "pdf-extract-thin" | "parser-warning" | "search-root-unavailable" | "mass-delete-suppressed" | "walk-truncated" | "directory-unreadable";
66
+ export type ParsedMirrorDiagnosticCode = "unsupported-file" | "parser-skipped" | "parser-failed" | "parser-crashed" | "source-changed" | "source-vanished" | "source-unreadable" | "source-read-failed" | "mirror-write-failed" | "duplicate-excluded" | "deleted-mirror" | "stale-index" | "pdf-extract-thin" | "parser-warning" | "search-root-unavailable" | "mass-delete-suppressed" | "walk-truncated" | "directory-unreadable";
67
67
  /**
68
68
  * Refresh diagnostic. `source` is an opaque virtual path, never a real filesystem path.
69
69
  * `message` keeps the underlying error text, which may include a filesystem path.
@@ -94,15 +94,6 @@ export declare class MirrorWorkspaceError extends Error {
94
94
  constructor(workspace: string, cause: unknown);
95
95
  }
96
96
  export declare function syncParsedMirrors(options: ParsedMirrorSyncOptions): Promise<ParsedMirrorSyncResult>;
97
- /**
98
- * Cheap, parse-free staleness check: compares current source files (by mtime and
99
- * size only — no parsing) against the mirror index's own records. A source is
100
- * current when the last refresh either indexed it or deliberately skipped it at
101
- * this exact version, so a skipped duplicate, oversize, or unparseable file is not
102
- * reported as a new source. Returns a `stale-index` diagnostic (opaque virtual
103
- * path) for every supported source that is new or changed since the last
104
- * successful refresh. Safe to call outside the query hot path (e.g. from
105
- * getRefreshStatus).
106
- */
97
+ /** Ask MinSync's read-only plan which current source revisions still need work. */
107
98
  export declare function detectMirrorStaleness(options: ParsedMirrorSyncOptions): Promise<ParsedMirrorDiagnostic[]>;
108
99
  export declare function isPathExcluded(sourcePath: string, excluded: ReadonlySet<string> | undefined): boolean;
@@ -18,8 +18,8 @@ export declare abstract class Parser {
18
18
  abstract readonly name: string;
19
19
  abstract readonly extensions: readonly string[];
20
20
  /**
21
- * Stamp recorded next to a per-file skip. Refresh retries a source a parser failed on exactly
22
- * once when this changes, so bump it whenever parse behavior changes (including the engine behind it).
21
+ * Processing revision used by the durable parse stage and per-file failure skips.
22
+ * Bump whenever parse behavior changes, including an engine dependency upgrade.
23
23
  */
24
24
  readonly version: string;
25
25
  abstract parse(input: ParseInput): Promise<ParseOutput>;
@@ -0,0 +1,10 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ /**
3
+ * Track a spawned child so it cannot outlive the host: a host exit, and
4
+ * SIGINT/SIGTERM/SIGHUP, kill its process tree. Windows has no process group to
5
+ * signal, so it keeps the parent/child chain `taskkill /t` walks and tracks
6
+ * nothing.
7
+ */
8
+ export declare function trackLiveChild(child: ChildProcess): void;
9
+ /** Stop tracking a child that has exited; the host handlers go with the last one. */
10
+ export declare function untrackLiveChild(child: ChildProcess): void;