@linxiraos/pi-natives 1.0.0

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.
@@ -0,0 +1,2013 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /**
4
+ * Default-microphone capture converted to mono `f32` at the requested sample
5
+ * rate.
6
+ */
7
+ export declare class AudioCapture {
8
+ /** Open the default microphone and deliver low-latency mono PCM chunks. */
9
+ constructor(sampleRate: number, onAudio: (error: Error | null, samples: Float32Array) => void)
10
+ /** Stop capture immediately and release the microphone. */
11
+ stop(): void
12
+ }
13
+
14
+ /** Gapless mono `f32` playback through the default speaker. */
15
+ export declare class AudioPlayback {
16
+ /** Open the default speaker at the requested logical sample rate. */
17
+ constructor(sampleRate: number)
18
+ /** Queue mono floating-point PCM in playback order. */
19
+ write(samples: Float32Array): void
20
+ /** Scale audio at render time so gain changes affect already queued samples. */
21
+ setGain(gain: number): void
22
+ /**
23
+ * Close input, wait until queued samples reach the speaker, then release
24
+ * it.
25
+ */
26
+ end(): Promise<void>
27
+ /** Stop immediately and discard all queued samples. */
28
+ stop(): void
29
+ }
30
+
31
+ /** Persistent, serialized native desktop capture/input/accessibility session. */
32
+ export declare class DesktopSession {
33
+ constructor(options?: DesktopSessionOptions | undefined | null)
34
+ get capabilities(): DesktopCapabilities
35
+ listDisplays(): Promise<Array<DesktopDisplay>>
36
+ listWindows(): Promise<Array<DesktopWindow>>
37
+ capture(target: string, caps?: CaptureCaps | undefined | null): Promise<DesktopCapture>
38
+ click(target: string, x: number, y: number, opts?: PointerOptions | undefined | null): Promise<undefined>
39
+ moveMouse(target: string, x: number, y: number, opts?: PointerOptions | undefined | null): Promise<undefined>
40
+ drag(target: string, path: Array<DesktopPoint>, opts?: PointerOptions | undefined | null): Promise<undefined>
41
+ scroll(target: string, x: number, y: number, dx: number, dy: number, opts?: PointerOptions | undefined | null): Promise<undefined>
42
+ typeText(target: string, text: string, opts?: PointerOptions | undefined | null): Promise<undefined>
43
+ keyChord(target: string, keys: Array<string>, opts?: PointerOptions | undefined | null): Promise<undefined>
44
+ raiseWindow(windowId: string): Promise<undefined>
45
+ axSnapshot(target: string, opts?: AxSnapshotOptions | undefined | null): Promise<AxSnapshot>
46
+ axQuery(target: string, query: AxQuery): Promise<Array<AxNode>>
47
+ /**
48
+ * Accessibility hit-test at global logical desktop coordinates; needs no
49
+ * prior capture.
50
+ */
51
+ axElementAt(target: string, x: number, y: number): Promise<AxNode | undefined | null>
52
+ axFocused(): Promise<AxNode | undefined | null>
53
+ axNode(reference: string): Promise<AxNode>
54
+ axAttributes(reference: string): Promise<Array<[string, string]>>
55
+ axChildren(reference: string): Promise<Array<AxNode>>
56
+ axParent(reference: string): Promise<AxNode | undefined | null>
57
+ axPerform(reference: string, action: string): Promise<undefined>
58
+ axSetValue(reference: string, value: string): Promise<undefined>
59
+ axFocus(reference: string): Promise<undefined>
60
+ axClick(reference: string, opts?: PointerOptions | undefined | null): Promise<undefined>
61
+ close(): Promise<undefined>
62
+ }
63
+
64
+ /**
65
+ * Process-owned cross-platform advisory lock.
66
+ *
67
+ * `tryAcquire()` is non-blocking; its returned handle reports whether it won
68
+ * through `acquired`. Ownership ends on `release()`, garbage collection, or
69
+ * process exit; `release()` is idempotent.
70
+ */
71
+ export declare class FileLock {
72
+ /** Try to acquire `path` without blocking. */
73
+ static tryAcquire(path: string): FileLock
74
+ /** Whether this handle owns the requested lock. */
75
+ get acquired(): boolean
76
+ /** Release this handle's ownership without affecting a successor. */
77
+ release(): void
78
+ }
79
+
80
+ /** WebRTC peer that accepts 16 kHz mono PCM and renders remote Opus audio. */
81
+ export declare class LiveWebRtcPeer {
82
+ /**
83
+ * Create an idle peer and register its event, output-level, and failure
84
+ * callbacks.
85
+ */
86
+ constructor(onEvent: (error: Error | null, payload: string) => void, onLevel: (error: Error | null, level: number) => void, onFailure: (error: Error | null, message: string) => void)
87
+ /** Start the native media peer and return its SDP offer. */
88
+ createOffer(): Promise<string>
89
+ /** Apply the remote SDP answer returned by Codex signaling. */
90
+ acceptAnswer(sdp: string): Promise<void>
91
+ /** Wait until the `oai-events` data channel is open. */
92
+ waitForOpen(timeoutMs?: number | undefined | null): Promise<void>
93
+ /** Queue 16 kHz mono floating-point PCM for Opus transmission. */
94
+ pushAudio(samples: Float32Array): void
95
+ /**
96
+ * Enable or disable microphone transmission, discarding partial muted
97
+ * frames.
98
+ */
99
+ setMuted(muted: boolean): void
100
+ /** Close media, the data channel, the peer connection, and speaker playback. */
101
+ close(): Promise<void>
102
+ }
103
+
104
+ /**
105
+ * Long-lived macOS appearance observer.
106
+ *
107
+ * Subscribes to `AppleInterfaceThemeChangedNotification` via
108
+ * `CFDistributedNotificationCenter` and calls the provided callback
109
+ * with `"dark"` or `"light"` on each change (and once on start).
110
+ *
111
+ * A 2-second polling timer also runs as fallback — distributed
112
+ * notifications may not reliably reach background threads on all
113
+ * macOS versions.
114
+ *
115
+ * On non-macOS platforms, `start()` returns a no-op observer.
116
+ */
117
+ export declare class MacAppearanceObserver {
118
+ static start(callback: (err: null | Error, appearance: MacOSAppearance) => void): MacAppearanceObserver
119
+ stop(): void
120
+ }
121
+
122
+ /**
123
+ * Long-lived macOS power assertion.
124
+ *
125
+ * On macOS this acquires one or more `IOKit` assertions that prevent the
126
+ * requested sleep modes until the handle is stopped or dropped. On other
127
+ * platforms it is a no-op handle so the caller can keep one cross-platform
128
+ * code path.
129
+ */
130
+ export declare class MacOSPowerAssertion {
131
+ /**
132
+ * Acquire a macOS power assertion. On non-macOS platforms returns a
133
+ * no-op handle so callers can stay cross-platform.
134
+ */
135
+ static start(options?: MacOSPowerAssertionOptions | undefined | null): MacOSPowerAssertion
136
+ /**
137
+ * Release every assertion held by this handle. Safe to call multiple
138
+ * times; subsequent calls are a no-op.
139
+ */
140
+ stop(): void
141
+ }
142
+
143
+ /** Stable process reference. */
144
+ export declare class Process {
145
+ /** Open a stable process reference from a PID. */
146
+ static fromPid(pid: number): Process | null
147
+ /** Open stable process references whose executable path matches exactly. */
148
+ static fromPath(path: string): Array<Process>
149
+ /** Operating-system process identifier for this process reference. */
150
+ get pid(): number
151
+ /** Parent process id for this process, when available. */
152
+ get ppid(): number | null
153
+ /** Launch arguments for this process. */
154
+ args(): Array<string>
155
+ /**
156
+ * Send `signal` to this process and its descendants, children first.
157
+ *
158
+ * On Linux and macOS the signal is forwarded as-is. On Windows there is no
159
+ * signal abstraction, so the `signal` argument is ignored and the entire
160
+ * tree is hard-killed via `TerminateProcess`. Defaults to the POSIX
161
+ * hard-kill signal.
162
+ */
163
+ killTree(signal?: number | undefined | null): number
164
+ /**
165
+ * Gracefully terminate this process and its descendants.
166
+ *
167
+ * By default this waits 1000ms after polite termination before
168
+ * hard-killing. Pass `graceful_ms < 0` to skip the graceful phase.
169
+ */
170
+ terminate(options?: ProcessTerminateOptions | undefined | null): Promise<boolean>
171
+ /**
172
+ * Wait until this process exits.
173
+ *
174
+ * When `options.timeout_ms` is omitted, waits until the process exits.
175
+ */
176
+ waitForExit(options?: ProcessWaitOptions | undefined | null): Promise<boolean>
177
+ /** Process group id for this process, when supported by the platform. */
178
+ groupId(): number | null
179
+ /** Direct children of this process as stable process references. */
180
+ children(): Array<Process>
181
+ /** Current status of this process reference. */
182
+ status(): ProcessStatus
183
+ }
184
+
185
+ /** Stateful PTY session for interactive stdin/stdout passthrough. */
186
+ export declare class PtySession {
187
+ constructor()
188
+ /**
189
+ * Start a shell command, stream output chunks, and report the spawned child
190
+ * PID.
191
+ */
192
+ start(options: PtyStartOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null, onStart?: ((error: Error | null, pid: number) => void) | undefined | null): Promise<PtyRunResult>
193
+ /**
194
+ * Start an executable with separate arguments, stream output chunks, and
195
+ * report the spawned child PID.
196
+ */
197
+ startArgv(options: PtyArgvStartOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null, onStart?: ((error: Error | null, pid: number) => void) | undefined | null): Promise<PtyRunResult>
198
+ /** Write raw input bytes to PTY stdin. */
199
+ write(data: string): void
200
+ /** Resize the active PTY. */
201
+ resize(cols: number, rows: number): void
202
+ /** Force-kill the active PTY command. */
203
+ kill(): void
204
+ }
205
+
206
+ /** Persistent brush-core shell session. */
207
+ export declare class Shell {
208
+ /**
209
+ * Create a new shell session from optional configuration.
210
+ *
211
+ * The options set session-scoped environment variables and a snapshot path.
212
+ */
213
+ constructor(options?: ShellOptions | undefined | null)
214
+ /**
215
+ * Run a shell command using the provided options.
216
+ *
217
+ * The `on_chunk` callback receives streamed stdout/stderr output. Returns
218
+ * the exit code when the command completes, or flags when cancelled or
219
+ * timed out.
220
+ */
221
+ run(options: ShellRunOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellRunResult>
222
+ /**
223
+ * Abort all running commands for this shell session.
224
+ *
225
+ * Returns `Ok(())` even when no commands are running.
226
+ */
227
+ abort(): Promise<void>
228
+ /**
229
+ * Count live background jobs (`&`/`nohup` children still running) on this
230
+ * session. Completed jobs are reaped first. The host uses this to retain a
231
+ * per-call shell whose background processes are still running instead of
232
+ * dropping it (which would SIGKILL them via kill-on-drop).
233
+ */
234
+ liveBackgroundJobCount(): Promise<number>
235
+ }
236
+
237
+ /**
238
+ * Install the bounded Tokio runtime napi-rs adopts for async exports and the
239
+ * bounded Rayon global pool used by native parallel iterators.
240
+ *
241
+ * The JS loader calls this exactly once, synchronously, right *after* `dlopen`
242
+ * returns and *before* any async native or parallel iterator runs — never from
243
+ * `#[module_init]`. Building a multi-thread runtime eagerly spawns worker
244
+ * threads, and doing that during module init (while the dynamic-loader lock is
245
+ * held) deadlocks on some hosts: a fresh worker blocks acquiring the loader
246
+ * lock that the init thread still owns. napi-rs only materializes its runtime
247
+ * on the first async call (`RT` is a `LazyLock`) and
248
+ * `create_custom_tokio_runtime` merely records the runtime in a `OnceLock`, so
249
+ * installing it post-load is still honored.
250
+ *
251
+ * Without the Tokio override napi builds its own default (one worker per CPU,
252
+ * spawned eagerly), which aborts the process (`os error 1455`) on a
253
+ * memory-constrained Windows host before any JS error can surface;
254
+ * [`create_windows_napi_tokio_runtime`] pre-flights the spawn instead. Rayon
255
+ * has the same one-thread-per-core lazy default, so [`configure_rayon_pool`]
256
+ * installs a probed global pool before `count_tokens` or vendored `sort` can
257
+ * trigger it across a N-API nounwind boundary. If no worker thread is
258
+ * spawnable, patched Rayon callsites stay sequential rather than registering a
259
+ * current-thread-only global pool that cannot steal work from later native
260
+ * calls. Idempotent.
261
+ */
262
+ export declare function __ompInstallTokioRuntime(): void
263
+
264
+ /**
265
+ * Version sentinel — exists solely so the JS loader can prove at load time
266
+ * that the `.node` file on disk is from the same package release as the
267
+ * `index.js` ESM wrapper invoking it.
268
+ *
269
+ * The `js_name` is bumped by `scripts/release.ts` to match the new
270
+ * `Cargo.toml` / `package.json` version on every release. The JS loader
271
+ * computes the expected name from `package.json#version` and refuses to use
272
+ * a `.node` that doesn't expose it, turning the silent
273
+ * `<sym> is not a function` crash from a locked-file update (the canonical
274
+ * Windows `bun install -g` failure mode) into a clear load-time error.
275
+ *
276
+ * Bump policy: `__piNativesV{major}_{minor}_{patch}` — non-alphanumerics in
277
+ * the version string are mapped to `_` to keep it a valid JS identifier.
278
+ * MUST stay in sync with `VERSION_SENTINEL_EXPORT` in
279
+ * `packages/natives/native/index.js` (which derives the name from
280
+ * `package.json#version`).
281
+ */
282
+ export declare function __piNativesV1_0_0(): void
283
+
284
+ /**
285
+ * Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
286
+ * a promise.
287
+ */
288
+ export declare function astEdit(options: AstReplaceOptions): Promise<AstReplaceResult>
289
+
290
+ /** One ast-grep match with source range and optional meta-variables. */
291
+ export interface AstFindMatch {
292
+ /** Display path of the matching file. */
293
+ path: string
294
+ /** Matched source text. */
295
+ text: string
296
+ /** Start byte offset in the file (UTF-8 byte index). */
297
+ byteStart: number
298
+ /** End byte offset in the file (exclusive UTF-8 byte index). */
299
+ byteEnd: number
300
+ /** 1-based start line. */
301
+ startLine: number
302
+ /** 1-based start column. */
303
+ startColumn: number
304
+ /** 1-based end line. */
305
+ endLine: number
306
+ /** 1-based end column. */
307
+ endColumn: number
308
+ /** Meta-variable name to captured text, when `includeMeta` was enabled. */
309
+ metaVariables?: Record<string, string>
310
+ }
311
+
312
+ /** Options for `astGrep`: patterns, scan scope, and match limits. */
313
+ export interface AstFindOptions {
314
+ /** ast-grep patterns to search for (OR across patterns). */
315
+ patterns?: Array<string>
316
+ /** Language override; otherwise inferred from file extension per candidate. */
317
+ lang?: string
318
+ /** Single file or directory to scan (combined with `glob` when set). */
319
+ path?: string
320
+ /** Optional glob filter relative to the search root. */
321
+ glob?: string
322
+ /** Rule selector for multi-rule ast-grep configurations. */
323
+ selector?: string
324
+ /** Pattern strictness; defaults to smart matching when omitted. */
325
+ strictness?: AstMatchStrictness
326
+ /** Maximum matches to return after `offset` (default applies when omitted). */
327
+ limit?: number
328
+ /** Number of leading matches to skip before applying `limit`. */
329
+ offset?: number
330
+ /** When true, include meta-variable bindings per match. */
331
+ includeMeta?: boolean
332
+ /**
333
+ * Reserved for contextual snippets; not used by the current native find
334
+ * path.
335
+ */
336
+ context?: number
337
+ /** Optional cancellation handle (library-specific). */
338
+ signal?: unknown
339
+ /** Wall-clock timeout for the worker task in milliseconds. */
340
+ timeoutMs?: number
341
+ }
342
+
343
+ /** Aggregated search statistics and any parse or compile diagnostics. */
344
+ export interface AstFindResult {
345
+ /** Page of matches after sort, offset, and limit. */
346
+ matches: Array<AstFindMatch>
347
+ /** Total matches found before paging (can exceed `matches.length`). */
348
+ totalMatches: number
349
+ /** Distinct files that contained at least one match. */
350
+ filesWithMatches: number
351
+ /** Files examined for the query. */
352
+ filesSearched: number
353
+ /** True when results were truncated by `limit`. */
354
+ limitReached: boolean
355
+ /** Non-fatal parse or pattern errors collected during the run. */
356
+ parseErrors?: Array<string>
357
+ }
358
+
359
+ /**
360
+ * Search source files with ast-grep patterns; returns a promise resolved on a
361
+ * worker thread.
362
+ */
363
+ export declare function astGrep(options: AstFindOptions): Promise<AstFindResult>
364
+
365
+ /**
366
+ * Match ast-grep patterns against an in-memory source string; returns a
367
+ * promise resolved on a worker thread.
368
+ *
369
+ * This is the file-free counterpart to [`ast_grep`]: callers that already hold
370
+ * the source (streaming buffers, generated code, editor contents) avoid a
371
+ * temp-file round trip. `lang` is required since there is no path to infer it
372
+ * from.
373
+ */
374
+ export declare function astMatch(options: AstMatchOptions): Promise<AstMatchResult>
375
+
376
+ /**
377
+ * Options for `astMatch`: run ast-grep patterns against an in-memory source
378
+ * string instead of files on disk.
379
+ */
380
+ export interface AstMatchOptions {
381
+ /** Source code to match against (parsed in memory, never read from disk). */
382
+ source: string
383
+ /** Language of `source` (required; e.g. "ts", "tsx", "rust", "python"). */
384
+ lang: string
385
+ /** ast-grep patterns to search for (OR across patterns). */
386
+ patterns: Array<string>
387
+ /** Rule selector for multi-rule ast-grep configurations. */
388
+ selector?: string
389
+ /** Pattern strictness; defaults to smart matching when omitted. */
390
+ strictness?: AstMatchStrictness
391
+ /** Maximum matches to return after `offset` (default applies when omitted). */
392
+ limit?: number
393
+ /** Number of leading matches to skip before applying `limit`. */
394
+ offset?: number
395
+ /** When true, include meta-variable bindings per match. */
396
+ includeMeta?: boolean
397
+ /** Optional cancellation handle (library-specific). */
398
+ signal?: unknown
399
+ /** Wall-clock timeout for the worker task in milliseconds. */
400
+ timeoutMs?: number
401
+ }
402
+
403
+ /** Result of an in-memory `astMatch` run. */
404
+ export interface AstMatchResult {
405
+ /** Page of matches after sort, offset, and limit. */
406
+ matches: Array<AstFindMatch>
407
+ /** Total matches found before paging (can exceed `matches.length`). */
408
+ totalMatches: number
409
+ /** True when results were truncated by `limit`. */
410
+ limitReached: boolean
411
+ /** Non-fatal parse or pattern-compile errors collected during the run. */
412
+ parseErrors?: Array<string>
413
+ }
414
+
415
+ /** ast-grep pattern strictness (controls how patterns match syntax). */
416
+ export declare enum AstMatchStrictness {
417
+ /** Match at the concrete syntax tree level. */
418
+ Cst = 'cst',
419
+ /** Balanced default suitable for most searches. */
420
+ Smart = 'smart',
421
+ /** Match at the AST level. */
422
+ Ast = 'ast',
423
+ /** More permissive matching. */
424
+ Relaxed = 'relaxed',
425
+ /** Match structural signatures. */
426
+ Signature = 'signature',
427
+ /** Template-style pattern matching. */
428
+ Template = 'template'
429
+ }
430
+
431
+ /**
432
+ * One textual replacement applied to a file (before/after slice and
433
+ * coordinates).
434
+ */
435
+ export interface AstReplaceChange {
436
+ /** File path for this change. */
437
+ path: string
438
+ /** Original matched text. */
439
+ before: string
440
+ /** Replacement text. */
441
+ after: string
442
+ /** Start byte offset of the replaced span. */
443
+ byteStart: number
444
+ /** End byte offset of the replaced span (exclusive). */
445
+ byteEnd: number
446
+ /**
447
+ * Length of deleted text in bytes (may differ from `byteEnd - byteStart`
448
+ * for edge cases).
449
+ */
450
+ deletedLength: number
451
+ /** 1-based start line of the match. */
452
+ startLine: number
453
+ /** 1-based start column. */
454
+ startColumn: number
455
+ /** 1-based end line. */
456
+ endLine: number
457
+ /** 1-based end column. */
458
+ endColumn: number
459
+ }
460
+
461
+ /** Per-file replacement count after an `astEdit` run. */
462
+ export interface AstReplaceFileChange {
463
+ /** File that had replacements. */
464
+ path: string
465
+ /** Number of replacements in that file. */
466
+ count: number
467
+ }
468
+
469
+ /**
470
+ * Options for `astEdit`: rewrite rules, scan scope, safety limits, and
471
+ * dry-run.
472
+ */
473
+ export interface AstReplaceOptions {
474
+ /** Map of pattern string to replacement template. */
475
+ rewrites?: Record<string, string>
476
+ /**
477
+ * Language override applied to every file; otherwise inferred per file, so
478
+ * mixed-language paths rewrite each file in its own language.
479
+ */
480
+ lang?: string
481
+ /** Single file or directory to rewrite. */
482
+ path?: string
483
+ /** Optional glob filter within the search root. */
484
+ glob?: string
485
+ /** Rule selector for multi-rule configurations. */
486
+ selector?: string
487
+ /** Pattern strictness for rewrites. */
488
+ strictness?: AstMatchStrictness
489
+ /** When true (default), compute changes without writing files. */
490
+ dryRun?: boolean
491
+ /** Cap on replacement applications across all files. */
492
+ maxReplacements?: number
493
+ /** Cap on distinct files that may be modified. */
494
+ maxFiles?: number
495
+ /** Fail the operation when a file cannot be parsed for rewriting. */
496
+ failOnParseError?: boolean
497
+ /** Optional cancellation handle. */
498
+ signal?: unknown
499
+ /** Wall-clock timeout for the worker task in milliseconds. */
500
+ timeoutMs?: number
501
+ }
502
+
503
+ /** Summary of an ast-grep rewrite pass, including whether disk writes occurred. */
504
+ export interface AstReplaceResult {
505
+ /** Individual replacement records (may be large). */
506
+ changes: Array<AstReplaceChange>
507
+ /** Replacement counts grouped by file. */
508
+ fileChanges: Array<AstReplaceFileChange>
509
+ /** Total replacements applied or previewed. */
510
+ totalReplacements: number
511
+ /** Files that had at least one replacement. */
512
+ filesTouched: number
513
+ /** Files considered for rewriting. */
514
+ filesSearched: number
515
+ /** False when `dryRun` prevented writing. */
516
+ applied: boolean
517
+ /** True when limits stopped further replacements. */
518
+ limitReached: boolean
519
+ /** Parse or pattern errors when not failing the whole operation. */
520
+ parseErrors?: Array<string>
521
+ }
522
+
523
+ export interface AxNode {
524
+ ref: string
525
+ role: string
526
+ nativeRole: string
527
+ title?: string
528
+ value?: string
529
+ description?: string
530
+ enabled: boolean
531
+ focused: boolean
532
+ x?: number
533
+ y?: number
534
+ width?: number
535
+ height?: number
536
+ actions?: Array<string>
537
+ childCount: number
538
+ }
539
+
540
+ export interface AxQuery {
541
+ role?: string
542
+ title?: string
543
+ value?: string
544
+ limit?: number
545
+ }
546
+
547
+ export interface AxSnapshot {
548
+ text: string
549
+ nodeCount: number
550
+ truncated: boolean
551
+ }
552
+
553
+ export interface AxSnapshotOptions {
554
+ maxDepth?: number
555
+ maxNodes?: number
556
+ all?: boolean
557
+ }
558
+
559
+ export interface BlockRange {
560
+ /** 1-indexed inclusive first line of the resolved block. */
561
+ startLine: number
562
+ /** 1-indexed inclusive last line of the resolved block. */
563
+ endLine: number
564
+ }
565
+
566
+ /**
567
+ * Find the outermost named tree-sitter node that begins on `options.line`.
568
+ *
569
+ * Returns its 1-indexed inclusive line span, or `null` when the language is
570
+ * unrecognized, the line is out of range / blank, no node begins on that line,
571
+ * or the resolved subtree contains a syntax error.
572
+ */
573
+ export declare function blockRangeAt(options: BlockRangeOptions): BlockRange | null
574
+
575
+ export interface BlockRangeOptions {
576
+ /** Source code to inspect. */
577
+ code: string
578
+ /** Language alias (e.g. "rust", "typescript") used before path inference. */
579
+ lang?: string
580
+ /** File path used to infer language by extension when `lang` is omitted. */
581
+ path?: string
582
+ /** 1-indexed source line the block must begin on. */
583
+ line: number
584
+ }
585
+
586
+ export interface CaptureCaps {
587
+ maxWidth?: number
588
+ maxHeight?: number
589
+ }
590
+
591
+ /** Clipboard image payload encoded as PNG bytes. */
592
+ export interface ClipboardImage {
593
+ /** PNG-encoded image bytes. */
594
+ data: Uint8Array
595
+ /** MIME type for the encoded image payload. */
596
+ mimeType: string
597
+ }
598
+
599
+ /** A context line (before or after a match). */
600
+ export interface ContextLine {
601
+ /** 1-indexed line number in the source file. */
602
+ lineNumber: number
603
+ /** Raw line content (trimmed line ending). */
604
+ line: string
605
+ }
606
+
607
+ /**
608
+ * Copy plain text to the system clipboard.
609
+ *
610
+ * # Parameters
611
+ * - `text`: UTF-8 text to place on the clipboard.
612
+ *
613
+ * # Errors
614
+ * Returns an error if clipboard access fails.
615
+ */
616
+ export declare function copyToClipboard(text: string): void
617
+
618
+ /**
619
+ * All pairs `(i, j)` with `i < j` whose cosine similarity meets `threshold`.
620
+ *
621
+ * `vectors` is `count` vectors flattened row-major at `dim` `f64` elements
622
+ * per row (zero-padded, which matches the TS `?? 0` missing-element
623
+ * semantics), so the similarity is bit-identical to the TS pairwise loop in
624
+ * `clusterBySimilarity`. Returns pairs flattened as `[i0, j0, i1, j1, ...]`
625
+ * in the same `(i, j)` visit order as the TS nested loop.
626
+ */
627
+ export declare function cosineSimilarityPairs(vectors: Float64Array, count: number, dim: number, threshold: number): Uint32Array
628
+
629
+ /**
630
+ * Count tokens in `input`.
631
+ *
632
+ * `input` may be a single string or an array of strings; an array returns
633
+ * the sum across all elements (encoded in parallel via rayon when the global
634
+ * pool is available). Always returns a single token total — use this for any
635
+ * aggregate budget question without paying a per-element napi crossing.
636
+ *
637
+ * Uses ordinary encoding (no special-token handling), which is the right
638
+ * choice for measuring user/model content rather than wire-protocol tokens.
639
+ * Defaults to `o200k_base`; pass `Cl100kBase` for older `OpenAI` models.
640
+ */
641
+ export declare function countTokens(input: string | Array<string>, encoding?: Encoding | undefined | null): number
642
+
643
+ export interface DesktopCapabilities {
644
+ backend: string
645
+ displayServer?: string
646
+ capture: boolean
647
+ input: boolean
648
+ ax: boolean
649
+ backgroundWindowInput: boolean
650
+ deliveryModes: Array<string>
651
+ capturePermission: string
652
+ inputPermission: string
653
+ axPermission: string
654
+ displayCount: number
655
+ }
656
+
657
+ export interface DesktopCapture {
658
+ data: Uint8Array
659
+ width: number
660
+ height: number
661
+ /** Pre-scaling capture width in native pixels; equals `width` when unscaled. */
662
+ sourceWidth: number
663
+ /**
664
+ * Pre-scaling capture height in native pixels; equals `height` when
665
+ * unscaled.
666
+ */
667
+ sourceHeight: number
668
+ target: string
669
+ displays: Array<DesktopDisplay>
670
+ backend: string
671
+ displayServer?: string
672
+ }
673
+
674
+ /**
675
+ * Monitor geometry in both global logical desktop coordinates and composite
676
+ * screenshot pixels.
677
+ */
678
+ export interface DesktopDisplay {
679
+ id: string
680
+ name: string
681
+ x: number
682
+ y: number
683
+ width: number
684
+ height: number
685
+ scale: number
686
+ pixelX: number
687
+ pixelY: number
688
+ pixelWidth: number
689
+ pixelHeight: number
690
+ isPrimary: boolean
691
+ }
692
+
693
+ export interface DesktopPoint {
694
+ x: number
695
+ y: number
696
+ }
697
+
698
+ export interface DesktopSessionOptions {
699
+ display?: string
700
+ }
701
+
702
+ /** One capturable top-level window in global logical desktop coordinates. */
703
+ export interface DesktopWindow {
704
+ /**
705
+ * Backend-defined opaque window id, valid as a capture target while the
706
+ * window lives. Numeric on X11/Win32/macOS; a composite AT-SPI string on
707
+ * Wayland (e.g. `atspi::1.31:/org/a11y/atspi/accessible/1`). Never parse
708
+ * it.
709
+ */
710
+ id: string
711
+ /** Window title; may be empty for untitled windows. */
712
+ title: string
713
+ /** Owning application name. */
714
+ app: string
715
+ /** Owning process id when the platform exposes it. */
716
+ pid?: number
717
+ x: number
718
+ y: number
719
+ width: number
720
+ height: number
721
+ /** Whether the window currently holds input focus. */
722
+ focused: boolean
723
+ }
724
+
725
+ /**
726
+ * Detect macOS system appearance via CoreFoundation.
727
+ * Returns `"dark"` or `"light"` on macOS, `null` on other platforms.
728
+ */
729
+ export declare function detectMacOSAppearance(): MacOSAppearance | null
730
+
731
+ /**
732
+ * Generate an Apple `DeviceCheck` attestation token.
733
+ *
734
+ * Resolves with the token (or the error reason) after at most a 1-second
735
+ * wait, matching the upstream `devicecheck.node` addon contract.
736
+ */
737
+ export declare function deviceCheckGenerateToken(): Promise<DeviceCheckTokenResult>
738
+
739
+ /** Outcome of a single `DCDevice.generateToken` request. */
740
+ export interface DeviceCheckTokenResult {
741
+ /** Whether `DCDevice.isSupported` reported attestation support. */
742
+ supported: boolean
743
+ /**
744
+ * Base64-encoded `DeviceCheck` token; present only when generation
745
+ * succeeded.
746
+ */
747
+ tokenBase64?: string
748
+ /** Human-readable failure reason when no token was produced. */
749
+ error?: string
750
+ /** Wall-clock time spent in the native call, in milliseconds. */
751
+ latencyMs: number
752
+ }
753
+
754
+ /** One jsdiff change object: a run of added, removed, or common tokens. */
755
+ export interface DiffChange {
756
+ /** Joined token text for this run (lines keep their `
757
+ ` terminators). */
758
+ value: string
759
+ /** Number of tokens in this run. */
760
+ count: number
761
+ /** True when this run exists only in the new text. */
762
+ added: boolean
763
+ /** True when this run exists only in the old text. */
764
+ removed: boolean
765
+ }
766
+
767
+ /**
768
+ * Diff `oldText.split("
769
+ ")` against `newText.split("
770
+ ")` with jsdiff
771
+ * `diffArrays` semantics (exact code-unit equality, empty lines preserved),
772
+ * returning only run lengths.
773
+ *
774
+ * Callers that map line numbers — like hashline recovery — need the counts,
775
+ * not another copy of the text.
776
+ */
777
+ export declare function diffLineRuns(oldText: string, newText: string): Array<DiffRun>
778
+
779
+ /**
780
+ * Line diff with jsdiff `diffLines(oldText, newText)` semantics (default
781
+ * options). Change values keep line terminators, and common runs are joined
782
+ * from the new text.
783
+ */
784
+ export declare function diffLines(oldText: string, newText: string): Array<DiffChange>
785
+
786
+ /** A change run without its token text, for callers that only need counts. */
787
+ export interface DiffRun {
788
+ /** Number of tokens in this run. */
789
+ count: number
790
+ /** True when this run exists only in the new text. */
791
+ added: boolean
792
+ /** True when this run exists only in the old text. */
793
+ removed: boolean
794
+ }
795
+
796
+ /**
797
+ * Word diff with jsdiff `diffWords(oldText, newText)` semantics (default
798
+ * options).
799
+ *
800
+ * Tokens carry surrounding whitespace, equality ignores it, and the
801
+ * post-pass dedupes whitespace across change boundaries.
802
+ */
803
+ export declare function diffWords(oldText: string, newText: string): Array<DiffChange>
804
+
805
+ /** Ellipsis strategy for [`truncate_to_width`]. */
806
+ export declare enum Ellipsis {
807
+ /** Use a single Unicode ellipsis character ("…"). */
808
+ Unicode = 0,
809
+ /** Use three ASCII dots ("..."). */
810
+ Ascii = 1,
811
+ /** Omit ellipsis entirely. */
812
+ Omit = 2
813
+ }
814
+
815
+ /**
816
+ * Matching-bracket context for an arbitrary tree-sitter language.
817
+ *
818
+ * For each multi-line named node whose span crosses the visible window, return
819
+ * the boundary line sitting *outside* that window (the closer when the opener
820
+ * is shown, the opener when the closer is shown). Covers brace and indentation
821
+ * languages alike using real syntactic spans.
822
+ *
823
+ * Returns `null` when the language is unrecognized or the source fails to
824
+ * parse / carries a syntax error (caller should fall back to a lexical scan);
825
+ * a sorted, unique list of 1-indexed boundary lines otherwise.
826
+ */
827
+ export declare function enclosingBlockBoundaries(options: EnclosingBoundaryOptions): Array<number> | null
828
+
829
+ export interface EnclosingBoundaryOptions {
830
+ /** Source code to inspect. */
831
+ code: string
832
+ /** Language alias (e.g. "rust", "typescript") used before path inference. */
833
+ lang?: string
834
+ /** File path used to infer language by extension when `lang` is omitted. */
835
+ path?: string
836
+ /** 1-indexed inclusive visible line ranges (the lines actually shown). */
837
+ ranges: Array<LineRange>
838
+ }
839
+
840
+ /**
841
+ * Encode image bytes into a SIXEL escape sequence for terminal rendering.
842
+ *
843
+ * The input image is decoded and resized to the requested pixel dimensions
844
+ * before encoding.
845
+ *
846
+ * # Errors
847
+ * Returns an error if decoding, resizing, or SIXEL encoding fails.
848
+ */
849
+ export declare function encodeSixel(bytes: Uint8Array, targetWidthPx: number, targetHeightPx: number): string
850
+
851
+ /** Tokenizer encoding to use. */
852
+ export declare enum Encoding {
853
+ /** GPT-4o / o1 / GPT-5 (default). */
854
+ O200kBase = 'O200kBase',
855
+ /** GPT-3.5 / GPT-4 / older. */
856
+ Cl100kBase = 'Cl100kBase'
857
+ }
858
+
859
+ /**
860
+ * Execute a brush shell command.
861
+ *
862
+ * Creates a fresh session for each call. The `on_chunk` callback receives
863
+ * streamed stdout/stderr output. Returns the exit code when the command
864
+ * completes, or flags when cancelled or timed out.
865
+ */
866
+ export declare function executeShell(options: ShellExecuteOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellRunResult>
867
+
868
+ /**
869
+ * Extract the before/after slices around an overlay region.
870
+ *
871
+ * Preserves ANSI state so the `after` segment renders correctly after
872
+ * truncation.
873
+ */
874
+ export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean, tabWidth: number): ExtractSegmentsResult
875
+
876
+ /** Before/after UTF-16 segments around an overlay region, with measured widths. */
877
+ export interface ExtractSegmentsResult {
878
+ /** UTF-16 content before the overlay region. */
879
+ before: string
880
+ /** Visible width of the `before` segment. */
881
+ beforeWidth: number
882
+ /** UTF-16 content after the overlay region. */
883
+ after: string
884
+ /** Visible width of the `after` segment. */
885
+ afterWidth: number
886
+ }
887
+
888
+ /** Resolved filesystem entry kind for glob filters and match metadata. */
889
+ export declare enum FileType {
890
+ /** Regular file. */
891
+ File = 1,
892
+ /** Directory. */
893
+ Dir = 2,
894
+ /** Symbolic link. */
895
+ Symlink = 3
896
+ }
897
+
898
+ /** Fuzzy file path search for autocomplete. */
899
+ export declare function fuzzyFind(options: FuzzyFindOptions): Promise<FuzzyFindResult>
900
+
901
+ /** A single match in fuzzy find results. */
902
+ export interface FuzzyFindMatch {
903
+ /** Relative path from the search root (uses `/` separators). */
904
+ path: string
905
+ /** Whether this entry is a directory. */
906
+ isDirectory: boolean
907
+ /** Match quality score (higher is better). */
908
+ score: number
909
+ }
910
+
911
+ /** Options for fuzzy file path search. */
912
+ export interface FuzzyFindOptions {
913
+ /** Fuzzy query to match against file paths (case-insensitive). */
914
+ query: string
915
+ /** Directory to search. */
916
+ path: string
917
+ /** Include hidden files (default: false). */
918
+ hidden?: boolean
919
+ /** Respect .gitignore (default: true). */
920
+ gitignore?: boolean
921
+ /** Enable walker scan caching (default: false). */
922
+ cache?: boolean
923
+ /** Maximum number of matches to return (default: 100). */
924
+ maxResults?: number
925
+ /** Abort signal for cancelling the operation. */
926
+ signal?: unknown
927
+ /** Timeout in milliseconds for the operation. */
928
+ timeoutMs?: number
929
+ }
930
+
931
+ /** Result of fuzzy file path search. */
932
+ export interface FuzzyFindResult {
933
+ /** Matched entries (up to `maxResults`). */
934
+ matches: Array<FuzzyFindMatch>
935
+ /** Total number of matches found (may exceed `matches.len()`). */
936
+ totalMatches: number
937
+ }
938
+
939
+ /** Get list of supported languages. */
940
+ export declare function getSupportedLanguages(): Array<string>
941
+
942
+ /**
943
+ * Get work profile data from the last N seconds.
944
+ *
945
+ * Always-on profiling - no need to start/stop. Just call this to get
946
+ * recent activity.
947
+ */
948
+ export declare function getWorkProfile(lastSeconds: number): WorkProfile
949
+
950
+ /**
951
+ * Find filesystem entries matching a glob pattern.
952
+ *
953
+ * Resolves the search root, scans entries, applies glob and optional file-type
954
+ * filters, and optionally streams each accepted match through `on_match`.
955
+ *
956
+ * When `sortByMtime` is enabled, the walker ranks matches by mtime before the
957
+ * native layer applies final symlink-aware file-type filtering and callback
958
+ * emission.
959
+ *
960
+ * # Errors
961
+ * Returns an error when the search path cannot be resolved, the path is not a
962
+ * directory, the glob pattern is invalid, or cancellation/timeout is
963
+ * triggered.
964
+ */
965
+ export declare function glob(options: GlobOptions, onMatch?: ((error: Error | null, match: GlobMatch) => void) | undefined | null): Promise<GlobResult>
966
+
967
+ /** A single filesystem entry from a directory scan. */
968
+ export interface GlobMatch {
969
+ /** Relative path from the search root, using forward slashes. */
970
+ path: string
971
+ /** Resolved filesystem type for the match. */
972
+ fileType: FileType
973
+ /** Modification time in milliseconds since Unix epoch. */
974
+ mtime?: number
975
+ /** File size in bytes for regular files. */
976
+ size?: number
977
+ }
978
+
979
+ /** Input options for `glob`, including traversal, filtering, and cancellation. */
980
+ export interface GlobOptions {
981
+ /** Glob pattern to match (e.g., "*.ts"). */
982
+ pattern: string
983
+ /** Directory to search. */
984
+ path: string
985
+ /**
986
+ * Filter by file type: "file", "dir", or "symlink". Symlinks are
987
+ * matched for file/dir filters based on their target type.
988
+ */
989
+ fileType?: FileType
990
+ /** Match simple patterns recursively by default (`*.ts` -> recursive). */
991
+ recursive?: boolean
992
+ /** Include hidden files (default: false). */
993
+ hidden?: boolean
994
+ /** Maximum number of results to return. */
995
+ maxResults?: number
996
+ /** Respect .gitignore files (default: true). */
997
+ gitignore?: boolean
998
+ /** Enable walker scan caching (default: false). */
999
+ cache?: boolean
1000
+ /** Sort results by mtime (most recent first) before applying limit. */
1001
+ sortByMtime?: boolean
1002
+ /**
1003
+ * Include `node_modules` entries when the pattern does not explicitly
1004
+ * mention them.
1005
+ */
1006
+ includeNodeModules?: boolean
1007
+ /** Abort signal for cancelling the operation. */
1008
+ signal?: unknown
1009
+ /** Timeout in milliseconds for the operation. */
1010
+ timeoutMs?: number
1011
+ }
1012
+
1013
+ /** Result payload returned by a glob operation. */
1014
+ export interface GlobResult {
1015
+ /** Matched filesystem entries. */
1016
+ matches: Array<GlobMatch>
1017
+ /** Number of returned matches (`matches.len()`), clamped to `u32::MAX`. */
1018
+ totalMatches: number
1019
+ }
1020
+
1021
+ /**
1022
+ * Search files for a regex pattern.
1023
+ *
1024
+ * # Arguments
1025
+ * - `options`: Pattern, path, filters, and output mode.
1026
+ * - `on_match`: Optional callback invoked per match/result.
1027
+ *
1028
+ * # Returns
1029
+ * Aggregated results across matching files.
1030
+ */
1031
+ export declare function grep(options: GrepOptions, onMatch?: ((error: Error | null, match: GrepMatch) => void) | undefined | null): Promise<GrepResult>
1032
+
1033
+ /** A single match in a grep result. */
1034
+ export interface GrepMatch {
1035
+ /** File path for the match (relative for directory searches). */
1036
+ path: string
1037
+ /** 1-indexed line number (0 for count-only entries). */
1038
+ lineNumber: number
1039
+ /** The matched line content (empty for count-only entries). */
1040
+ line: string
1041
+ /** Context lines before the match. */
1042
+ contextBefore?: Array<ContextLine>
1043
+ /** Context lines after the match. */
1044
+ contextAfter?: Array<ContextLine>
1045
+ /** Whether the line was truncated. */
1046
+ truncated?: boolean
1047
+ /** Per-file match count (count mode only). */
1048
+ matchCount?: number
1049
+ }
1050
+
1051
+ /** Options for searching files on disk. */
1052
+ export interface GrepOptions {
1053
+ /** Regex pattern to search for. */
1054
+ pattern: string
1055
+ /** Directory or file to search. */
1056
+ path: string
1057
+ /** Glob filter for filenames (e.g., "*.ts"). */
1058
+ glob?: string
1059
+ /** Filter by file type (e.g., "js", "py", "rust"). */
1060
+ type?: string
1061
+ /** Case-insensitive search. */
1062
+ ignoreCase?: boolean
1063
+ /** Enable multiline matching. */
1064
+ multiline?: boolean
1065
+ /** Include hidden files (default: true). */
1066
+ hidden?: boolean
1067
+ /** Respect .gitignore files (default: true). */
1068
+ gitignore?: boolean
1069
+ /** Maximum number of matches to return. */
1070
+ maxCount?: number
1071
+ /** Skip first N matches. */
1072
+ offset?: number
1073
+ /** Lines of context before matches. */
1074
+ contextBefore?: number
1075
+ /** Lines of context after matches. */
1076
+ contextAfter?: number
1077
+ /** Lines of context before/after matches (legacy). */
1078
+ context?: number
1079
+ /** Truncate lines longer than this (characters). */
1080
+ maxColumns?: number
1081
+ /** Output mode (content, filesWithMatches, or count). */
1082
+ mode?: GrepOutputMode
1083
+ /**
1084
+ * Maximum matches collected per file (content mode). Keeps one hot file
1085
+ * from exhausting the global `max_count` budget before other files are
1086
+ * reached.
1087
+ */
1088
+ maxCountPerFile?: number
1089
+ /** Abort signal for cancelling the operation. */
1090
+ signal?: unknown
1091
+ /** Timeout in milliseconds for the operation. */
1092
+ timeoutMs?: number
1093
+ }
1094
+
1095
+ /** Output mode for [`search`] and [`grep`] (string values match JS callers). */
1096
+ export declare enum GrepOutputMode {
1097
+ /** Emit matched lines (and optional context lines). */
1098
+ Content = 'content',
1099
+ /** Emit per-file or total counts instead of line content. */
1100
+ Count = 'count',
1101
+ /** Emit one row per file that matched, without line content. */
1102
+ FilesWithMatches = 'filesWithMatches'
1103
+ }
1104
+
1105
+ /** Result of searching files. */
1106
+ export interface GrepResult {
1107
+ /** Matches or per-file counts, depending on output mode. */
1108
+ matches: Array<GrepMatch>
1109
+ /**
1110
+ * Total matches across all files, or matched file count in filesWithMatches
1111
+ * mode.
1112
+ */
1113
+ totalMatches: number
1114
+ /** Number of files with at least one match. */
1115
+ filesWithMatches: number
1116
+ /** Number of files searched. */
1117
+ filesSearched: number
1118
+ /** Whether the limit/offset stopped the search early. */
1119
+ limitReached?: boolean
1120
+ /** Number of files skipped because they exceed the size limit. */
1121
+ skippedOversized?: number
1122
+ }
1123
+
1124
+ /**
1125
+ * Quick check if content matches a pattern.
1126
+ *
1127
+ * # Arguments
1128
+ * - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
1129
+ * - `pattern`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
1130
+ * - `ignore_case`: Case-insensitive matching.
1131
+ * - `multiline`: Enable multiline regex mode.
1132
+ *
1133
+ * # Returns
1134
+ * True if any match exists; false on no match.
1135
+ */
1136
+ export declare function hasMatch(content: string | Uint8Array, pattern: string | Uint8Array, ignoreCase?: boolean | undefined | null, multiline?: boolean | undefined | null): boolean
1137
+
1138
+ /**
1139
+ * Highlight code and return ANSI-colored lines.
1140
+ *
1141
+ * # Arguments
1142
+ * * `code` - The source code to highlight
1143
+ * * `lang` - Language identifier (e.g., "rust", "typescript", "python")
1144
+ * * `colors` - Theme colors as ANSI escape sequences
1145
+ *
1146
+ * # Returns
1147
+ * Highlighted code with ANSI color codes, or the original code if highlighting
1148
+ * fails.
1149
+ */
1150
+ export declare function highlightCode(code: string, lang: string | undefined | null, colors: HighlightColors): string
1151
+
1152
+ /**
1153
+ * Theme colors for syntax highlighting.
1154
+ * Each color is an ANSI escape sequence (e.g., "\x1b[38;2;255;0;0m").
1155
+ */
1156
+ export interface HighlightColors {
1157
+ /** ANSI color for comments. */
1158
+ comment: string
1159
+ /** ANSI color for keywords. */
1160
+ keyword: string
1161
+ /** ANSI color for function names. */
1162
+ function: string
1163
+ /** ANSI color for variables and identifiers. */
1164
+ variable: string
1165
+ /** ANSI color for string literals. */
1166
+ string: string
1167
+ /** ANSI color for numeric literals. */
1168
+ number: string
1169
+ /** ANSI color for type identifiers. */
1170
+ type: string
1171
+ /** ANSI color for operators. */
1172
+ operator: string
1173
+ /** ANSI color for punctuation tokens. */
1174
+ punctuation: string
1175
+ /** ANSI color for diff inserted lines. */
1176
+ inserted?: string
1177
+ /** ANSI color for diff deleted lines. */
1178
+ deleted?: string
1179
+ }
1180
+
1181
+ /**
1182
+ * Convert HTML source to Markdown with optional preprocessing.
1183
+ *
1184
+ * # Errors
1185
+ * Returns an error if the conversion fails or the worker task aborts.
1186
+ */
1187
+ export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions | undefined | null): Promise<string>
1188
+
1189
+ /** Options for HTML to Markdown conversion. */
1190
+ export interface HtmlToMarkdownOptions {
1191
+ /** Remove navigation elements, forms, headers, footers. */
1192
+ cleanContent?: boolean
1193
+ /** Skip images during conversion. */
1194
+ skipImages?: boolean
1195
+ }
1196
+
1197
+ /**
1198
+ * Invalidate the walker scan cache.
1199
+ *
1200
+ * When called with a path, removes entries for roots containing that path.
1201
+ * When called without a path, clears the entire cache.
1202
+ *
1203
+ * Intended to be called after agent file mutations: write, edit, rename, or
1204
+ * delete.
1205
+ */
1206
+ export declare function invalidateFsScanCache(path?: string | undefined | null): void
1207
+
1208
+ /** Kind enum of the backend selected by default for this build target. */
1209
+ export declare function isoBackend(): IsoBackendKind
1210
+
1211
+ /**
1212
+ * Isolation backend identifier. Numeric so the JS side can `switch` on
1213
+ * the enum without string comparisons.
1214
+ */
1215
+ export declare enum IsoBackendKind {
1216
+ Apfs = 0,
1217
+ Btrfs = 1,
1218
+ Zfs = 2,
1219
+ LinuxReflink = 3,
1220
+ Overlayfs = 4,
1221
+ WindowsBlockClone = 5,
1222
+ Projfs = 6,
1223
+ Rcopy = 7
1224
+ }
1225
+
1226
+ /** How a single file changed between `lower` and `merged`. */
1227
+ export declare enum IsoChangeKind {
1228
+ Added = 0,
1229
+ Modified = 1,
1230
+ Removed = 2
1231
+ }
1232
+
1233
+ /**
1234
+ * Capture the changes between `lower` and `merged`.
1235
+ *
1236
+ * Uses [`pi_iso::IsolationBackend::diff`]'s default implementation —
1237
+ * `git diff` when `merged/.git` exists, otherwise a mtime-skipped tree
1238
+ * walk. The backend selection only affects the lifecycle methods; diff
1239
+ * behaviour is uniform.
1240
+ */
1241
+ export declare function isoDiff(lower: string, merged: string): Promise<IsoDiff>
1242
+
1243
+ export interface IsoDiff {
1244
+ files: Array<IsoFileChange>
1245
+ }
1246
+
1247
+ /** One entry in an [`IsoDiff`]. */
1248
+ export interface IsoFileChange {
1249
+ /** Path relative to `merged`. */
1250
+ path: string
1251
+ op: IsoChangeKind
1252
+ /**
1253
+ * Unified-diff text. `None` (`null` in JS) means the file is binary;
1254
+ * read it directly from `merged` if you need the bytes.
1255
+ */
1256
+ diff?: string
1257
+ }
1258
+
1259
+ /**
1260
+ * True if `message` is an error message produced by [`IsoError::Unavailable`].
1261
+ * Use this to distinguish "this backend isn't installed" from a hard
1262
+ * failure when handling caught errors on the JS side.
1263
+ */
1264
+ export declare function isoIsUnavailableError(message: string): boolean
1265
+
1266
+ /**
1267
+ * Probe whether the requested backend can start on this host. Pass
1268
+ * `null`/omit `kind` to probe the platform-native backend.
1269
+ */
1270
+ export declare function isoProbe(kind?: IsoBackendKind | undefined | null): IsoProbeResult
1271
+
1272
+ /** Probe result for a specific isolation backend. */
1273
+ export interface IsoProbeResult {
1274
+ /** True when the backend's prerequisites are satisfied. */
1275
+ available: boolean
1276
+ /** Human-readable explanation when `available` is false. */
1277
+ reason?: string
1278
+ /** Resolved backend kind. */
1279
+ kind: IsoBackendKind
1280
+ }
1281
+
1282
+ /**
1283
+ * Pick the best backend available right now. `preferred` is treated as
1284
+ * a hint — see [`pi_iso::resolve`] for the exact priority rules.
1285
+ */
1286
+ export declare function isoResolve(preferred?: IsoBackendKind | undefined | null): IsoResolveResult
1287
+
1288
+ /** Outcome of [`iso_resolve`]. */
1289
+ export interface IsoResolveResult {
1290
+ /** Backend that will actually be tried first. */
1291
+ kind: IsoBackendKind
1292
+ /** Host-available backends in retry order, starting with `kind`. */
1293
+ candidates: Array<IsoBackendKind>
1294
+ /**
1295
+ * True when the resolver fell back from `preferred` (or from the
1296
+ * first automatic candidate) to a different backend.
1297
+ */
1298
+ fellBack: boolean
1299
+ /** Human-readable reason for the fallback, if any. */
1300
+ reason?: string
1301
+ }
1302
+
1303
+ /**
1304
+ * Materialise `merged` as a writable view of `lower` using the requested
1305
+ * backend. `kind` defaults to the native backend.
1306
+ */
1307
+ export declare function isoStart(kind: IsoBackendKind | undefined | null, lower: string, merged: string): Promise<void>
1308
+
1309
+ /** Tear down a previously started backend at `merged`. */
1310
+ export declare function isoStop(kind: IsoBackendKind | undefined | null, merged: string): Promise<void>
1311
+
1312
+ /** Event types from Kitty keyboard protocol (flag 2). */
1313
+ export declare enum KeyEventType {
1314
+ /** Key press event. */
1315
+ Press = 1,
1316
+ /** Key repeat event. */
1317
+ Repeat = 2,
1318
+ /** Key release event. */
1319
+ Release = 3
1320
+ }
1321
+
1322
+ export interface LineRange {
1323
+ /** 1-indexed inclusive first visible line. */
1324
+ startLine: number
1325
+ /** 1-indexed inclusive last visible line. */
1326
+ endLine: number
1327
+ }
1328
+
1329
+ /**
1330
+ * Walk the workspace once and return tree entries plus AGENTS.md candidates.
1331
+ *
1332
+ * File-level ignore rules for AGENTS.md are bypassed by checking each
1333
+ * traversed directory directly when `collectAgentsMd` is enabled, but ignored
1334
+ * directories are still pruned by the walker and are not searched.
1335
+ */
1336
+ export declare function listWorkspace(options: ListWorkspaceOptions): Promise<ListWorkspaceResult>
1337
+
1338
+ /** Input options for `listWorkspace`, the single-pass workspace startup scan. */
1339
+ export interface ListWorkspaceOptions {
1340
+ /** Directory to scan. */
1341
+ path: string
1342
+ /** Maximum depth for returned tree entries. Root children are depth 1. */
1343
+ maxDepth: number
1344
+ /** Include hidden files and directories. Default: false. */
1345
+ hidden?: boolean
1346
+ /** Respect .gitignore files. Default: true. */
1347
+ gitignore?: boolean
1348
+ /**
1349
+ * Also surface AGENTS.md files in directories at depth 1..=4, even when
1350
+ * gitignore would otherwise hide the file. Walks deeper than `maxDepth`
1351
+ * to find them. Default: false.
1352
+ */
1353
+ collectAgentsMd?: boolean
1354
+ /** Timeout in milliseconds for the operation. */
1355
+ timeoutMs?: number
1356
+ /** Abort signal for cancelling the operation. */
1357
+ signal?: unknown
1358
+ }
1359
+
1360
+ /** Result payload returned by a workspace scan. */
1361
+ export interface ListWorkspaceResult {
1362
+ /** Entries within `maxDepth`, with mtime and regular-file size metadata. */
1363
+ entries: Array<GlobMatch>
1364
+ /**
1365
+ * Directory-scoped AGENTS.md files within depth 1..=4 (capped at 200).
1366
+ * Always empty when `collectAgentsMd` is false.
1367
+ */
1368
+ agentsMdFiles: Array<string>
1369
+ /** True when any output cap was hit. */
1370
+ truncated: boolean
1371
+ }
1372
+
1373
+ /**
1374
+ * System UI appearance reported by native macOS APIs (`detectMacOSAppearance`
1375
+ * and observer).
1376
+ */
1377
+ export declare enum MacOSAppearance {
1378
+ /** Dark color scheme. */
1379
+ Dark = 'dark',
1380
+ /** Light color scheme. */
1381
+ Light = 'light'
1382
+ }
1383
+
1384
+ /**
1385
+ * Options for starting a macOS power assertion.
1386
+ *
1387
+ * Each boolean maps to a `caffeinate(8)` flag and a corresponding `IOKit`
1388
+ * `IOPMAssertion` type. Multiple flags can be combined; when set, one
1389
+ * assertion is taken per flag and all are released together when the
1390
+ * handle is stopped or dropped.
1391
+ *
1392
+ * If every flag is unset (or omitted), the handle behaves as if `idle`
1393
+ * were `true` — preserving the historical default of `caffeinate -i`.
1394
+ */
1395
+ export interface MacOSPowerAssertionOptions {
1396
+ /** Human-readable reason shown in macOS power diagnostics. */
1397
+ reason?: string
1398
+ /** `caffeinate -i`: prevent the system from idle-sleeping. */
1399
+ idle?: boolean
1400
+ /** `caffeinate -s`: prevent the system from sleeping (AC power only). */
1401
+ system?: boolean
1402
+ /** `caffeinate -u`: declare the user is active (wakes the display). */
1403
+ user?: boolean
1404
+ /** `caffeinate -d`: prevent the display from idle-sleeping. */
1405
+ display?: boolean
1406
+ }
1407
+
1408
+ /** A single match in the content. */
1409
+ export interface Match {
1410
+ /** 1-indexed line number. */
1411
+ lineNumber: number
1412
+ /** The matched line content. */
1413
+ line: string
1414
+ /** Context lines before the match. */
1415
+ contextBefore?: Array<ContextLine>
1416
+ /** Context lines after the match. */
1417
+ contextAfter?: Array<ContextLine>
1418
+ /** Whether the line was truncated. */
1419
+ truncated?: boolean
1420
+ }
1421
+
1422
+ /**
1423
+ * Match input data against a key identifier string.
1424
+ *
1425
+ * Returns true when the bytes represent the specified key with modifiers.
1426
+ */
1427
+ export declare function matchesKey(data: string, keyId: string, kittyProtocolActive: boolean): boolean
1428
+
1429
+ /**
1430
+ * Match Kitty protocol input against a codepoint and modifier mask.
1431
+ *
1432
+ * Returns true when the parsed sequence matches the expected codepoint (or
1433
+ * base layout key) and modifier bits.
1434
+ */
1435
+ export declare function matchesKittySequence(data: string, expectedCodepoint: number, expectedModifier: number): boolean
1436
+
1437
+ /**
1438
+ * Check if input matches a legacy escape sequence for the given key name.
1439
+ *
1440
+ * Returns true only when the byte sequence maps to the exact key identifier.
1441
+ */
1442
+ export declare function matchesLegacySequence(data: string, keyName: string): boolean
1443
+
1444
+ /** N-API opt-in handle for the minimizer. */
1445
+ export interface MinimizerOptions {
1446
+ /** Master switch. Absent / false = disabled. */
1447
+ enabled?: boolean
1448
+ /**
1449
+ * Optional path to a TOML settings file whose values override
1450
+ * field-level defaults. `~` is expanded.
1451
+ */
1452
+ settingsPath?: string
1453
+ /**
1454
+ * Optional xxHash64 digest (hex) of the settings file contents. When
1455
+ * supplied, the engine refuses to honor a settings file whose hash does
1456
+ * not match — a lightweight trust gate for agent-controllable paths.
1457
+ */
1458
+ settingsHash?: string
1459
+ /**
1460
+ * Opt-in allowlist of program names (e.g. `"git"`). When empty or
1461
+ * absent, all built-in filters are active.
1462
+ */
1463
+ only?: Array<string>
1464
+ /** Program names explicitly excluded from minimization. */
1465
+ except?: Array<string>
1466
+ /**
1467
+ * Maximum captured bytes per command before the engine falls back to
1468
+ * the raw, un-minimized output. Default 4 MiB.
1469
+ */
1470
+ maxCaptureBytes?: number
1471
+ /**
1472
+ * Source-outline level for `cat <source-file>` minimization. Accepts
1473
+ * `"default"` (current behavior) or `"aggressive"` (strip function bodies).
1474
+ */
1475
+ sourceOutlineLevel?: string
1476
+ /**
1477
+ * Kill-switch to fall back to the pre-PR (legacy) filter behavior for
1478
+ * grep / find / pytest. When `Some(true)`, filters that opted into the
1479
+ * always-shrink Tier 1 / Tier 2 behavior skip the new code path. When
1480
+ * `None`, defers to the `OMP_MINIMIZER_LEGACY_FILTERS` env var.
1481
+ */
1482
+ legacyFilters?: boolean
1483
+ }
1484
+
1485
+ /**
1486
+ * Telemetry for a single minimization.
1487
+ *
1488
+ * Surfaced when the minimizer actually rewrote the command's output. The
1489
+ * session layer is expected to persist `original_text` via its
1490
+ * `ArtifactManager`, splice the resulting `artifact://<id>` reference
1491
+ * into `text`, and replace any previously streamed raw output with the
1492
+ * minimized text.
1493
+ */
1494
+ export interface MinimizerResult {
1495
+ /**
1496
+ * Dispatch label produced by the minimizer (e.g. `"git"`,
1497
+ * `"pipeline:gradle"`, `"pipeline+builtin"`).
1498
+ */
1499
+ filter: string
1500
+ /**
1501
+ * The minimized replacement text. Callers that streamed raw chunks
1502
+ * during execution should clear and replace their accumulated output
1503
+ * with this text.
1504
+ */
1505
+ text: string
1506
+ /** The full original capture, before minimization. */
1507
+ originalText: string
1508
+ /** Captured byte length before minimization. */
1509
+ inputBytes: number
1510
+ /** Byte length of the minimized text the consumer received. */
1511
+ outputBytes: number
1512
+ }
1513
+
1514
+ /**
1515
+ * MMR selection over pre-sorted candidates using Jaccard word similarity.
1516
+ *
1517
+ * `contents[i]` and `scores[i]` describe candidate `i`, already sorted by
1518
+ * relevance exactly as the TS `mmrRerank` sorts them (the JS stable sort
1519
+ * stays on the TS side so its tie and NaN semantics are preserved).
1520
+ * Replicates the TS selection loop exactly: candidate `0` is always taken
1521
+ * first; each round picks the remaining candidate maximizing
1522
+ * `lambda * score - (1 - lambda) * maxSimilarity(selected)` with strict
1523
+ * `>` comparisons, so ties keep the earliest remaining candidate — and a
1524
+ * round where every score is `NaN` picks the first remaining candidate,
1525
+ * matching the TS `bestIdx = 0` initialisation. Returns the selected
1526
+ * indices into the input order.
1527
+ *
1528
+ * Word tokenization matches `text.toLowerCase().split(/\s+/)` (ECMA `\s`,
1529
+ * Unicode default full case conversion). Known divergence: unpaired
1530
+ * surrogates arrive here as U+FFFD, while JS keeps the lone surrogate; both
1531
+ * tokenize to a single non-whitespace word so Jaccard counts still agree
1532
+ * unless a text mixes U+FFFD words with lone-surrogate words.
1533
+ */
1534
+ export declare function mmrRerankIndices(contents: Array<string>, scores: Float64Array, lambdaParam: number, topK: number): Uint32Array
1535
+
1536
+ /** Parsed Kitty keyboard protocol sequence result for a Kitty input sequence. */
1537
+ export interface ParsedKittyResult {
1538
+ /** Primary codepoint associated with the key. */
1539
+ codepoint: number
1540
+ /** Optional shifted key codepoint from the sequence. */
1541
+ shiftedKey?: number
1542
+ /** Optional base layout key codepoint from the sequence. */
1543
+ baseLayoutKey?: number
1544
+ /** Modifier bitmask (shift/alt/ctrl), excluding lock bits. */
1545
+ modifier: number
1546
+ /** Optional event type (1 = press, 2 = repeat, 3 = release). */
1547
+ eventType?: KeyEventType
1548
+ }
1549
+
1550
+ /**
1551
+ * Parse terminal input and return a normalized key identifier.
1552
+ *
1553
+ * Returns a key id like "escape" or "ctrl+c", or None if unrecognized.
1554
+ */
1555
+ export declare function parseKey(data: string, kittyProtocolActive: boolean): string | null
1556
+
1557
+ /**
1558
+ * Parse a Kitty keyboard protocol sequence.
1559
+ *
1560
+ * Returns a structured parse result when the input is a valid Kitty sequence.
1561
+ */
1562
+ export declare function parseKittySequence(data: string): ParsedKittyResult | null
1563
+
1564
+ /** One hunk of a unified diff, matching jsdiff `structuredPatch` hunks. */
1565
+ export interface PatchHunk {
1566
+ /** 1-based first line of the hunk in the old text. */
1567
+ oldStart: number
1568
+ /** Number of old-text lines covered by the hunk. */
1569
+ oldLines: number
1570
+ /** 1-based first line of the hunk in the new text. */
1571
+ newStart: number
1572
+ /** Number of new-text lines covered by the hunk. */
1573
+ newLines: number
1574
+ /**
1575
+ * Hunk body: `+`/`-`/` `-prefixed lines without trailing newlines, plus
1576
+ * `` markers where applicable.
1577
+ */
1578
+ lines: Array<string>
1579
+ }
1580
+
1581
+ export interface PointerOptions {
1582
+ button?: string
1583
+ count?: number
1584
+ modifiers?: Array<string>
1585
+ deliveryMode?: string
1586
+ }
1587
+
1588
+ /** Current state of a process reference. */
1589
+ export declare enum ProcessStatus {
1590
+ /** The referenced process is still running. */
1591
+ Running = 'running',
1592
+ /** The referenced process has exited or is no longer observable. */
1593
+ Exited = 'exited'
1594
+ }
1595
+
1596
+ export interface ProcessTerminateOptions {
1597
+ /** Also signal the process group when supported by the platform. */
1598
+ group?: boolean
1599
+ /**
1600
+ * Milliseconds to wait after polite termination before hard-killing.
1601
+ * Omit to use the default grace period. Pass a negative value to skip the
1602
+ * graceful phase and hard-kill immediately.
1603
+ */
1604
+ gracefulMs?: number
1605
+ /** Milliseconds to wait after hard-kill for the process tree to exit. */
1606
+ timeoutMs?: number
1607
+ /** Abort signal for cancelling termination while waiting. */
1608
+ signal?: unknown
1609
+ }
1610
+
1611
+ /** Options for waiting on a process exit. */
1612
+ export interface ProcessWaitOptions {
1613
+ /** Milliseconds to wait before returning false. Omit to wait indefinitely. */
1614
+ timeoutMs?: number
1615
+ /** Abort signal for cancelling the wait. */
1616
+ signal?: unknown
1617
+ }
1618
+
1619
+ /** Options for running an executable and argument vector in a PTY session. */
1620
+ export interface PtyArgvStartOptions {
1621
+ /** Executable name or path. */
1622
+ application: string
1623
+ /** Arguments passed directly to the executable. */
1624
+ args: Array<string>
1625
+ /** Working directory for command execution. */
1626
+ cwd?: string
1627
+ /** Environment variables for this command. */
1628
+ env?: Record<string, string>
1629
+ /** Timeout in milliseconds before cancelling. */
1630
+ timeoutMs?: number
1631
+ /** Abort signal for cancelling the operation. */
1632
+ signal?: unknown
1633
+ /** PTY column count. */
1634
+ cols?: number
1635
+ /** PTY row count. */
1636
+ rows?: number
1637
+ }
1638
+
1639
+ /** Result of a PTY command run. */
1640
+ export interface PtyRunResult {
1641
+ /** Exit code when the command completes. */
1642
+ exitCode?: number
1643
+ /** Whether command was cancelled by signal/user kill. */
1644
+ cancelled: boolean
1645
+ /** Whether command timed out. */
1646
+ timedOut: boolean
1647
+ }
1648
+
1649
+ /** Options for running a command in a PTY session. */
1650
+ export interface PtyStartOptions {
1651
+ /** Command string to execute. */
1652
+ command: string
1653
+ /** Working directory for command execution. */
1654
+ cwd?: string
1655
+ /** Environment variables for this command. */
1656
+ env?: Record<string, string>
1657
+ /** Timeout in milliseconds before cancelling. */
1658
+ timeoutMs?: number
1659
+ /** Abort signal for cancelling the operation. */
1660
+ signal?: unknown
1661
+ /** PTY column count. */
1662
+ cols?: number
1663
+ /** PTY row count. */
1664
+ rows?: number
1665
+ /**
1666
+ * Shell binary to use (e.g. "sh", "bash", or an absolute path).
1667
+ * Defaults to "sh" if not provided.
1668
+ */
1669
+ shell?: string
1670
+ }
1671
+
1672
+ /**
1673
+ * Read an image from the system clipboard.
1674
+ *
1675
+ * Returns `Ok(None)` when no image data is available.
1676
+ *
1677
+ * # Errors
1678
+ * Returns an error if clipboard access fails or image encoding fails.
1679
+ */
1680
+ export declare function readImageFromClipboard(): Promise<ClipboardImage | undefined | null>
1681
+
1682
+ /**
1683
+ * Render one snapcompact frame on a libuv worker: print pre-normalized text
1684
+ * onto a `size`-wide bitmap and encode it as PNG.
1685
+ *
1686
+ * The bitmap height hugs the rows the text actually occupies
1687
+ * (`usedRows * lineRepeat * cellHeight`), so a partially filled frame never
1688
+ * pays for blank padding rows. The glyph grid holds `floor(size/cellWidth) *
1689
+ * floor(size/cellHeight/lineRepeat)` characters; input beyond that is ignored.
1690
+ * Native-cell bitmap-font shapes encode as indexed PNG; stretched bitmap-font
1691
+ * shapes (target cell != font cell) encode as RGB. TrueType shapes encode RGB
1692
+ * directly from grayscale coverage.
1693
+ * `stretch: false` pins bitmap fonts to the indexed path, printing
1694
+ * natural-size glyphs on the requested cell box; `columns: 2` flows
1695
+ * pre-wrapped newline-separated lines down two newspaper columns.
1696
+ * `U+000E`/`U+000F` in `text` toggle dim-gray ink spans without occupying a
1697
+ * cell.
1698
+ * Returns a promise for the PNG encoded as base64, created as a one-byte
1699
+ * (Latin-1) JS string straight from native code — no `Uint8Array` hop or
1700
+ * JS-side re-encode.
1701
+ */
1702
+ export declare function renderSnapcompactPng(text: string, options: SnapcompactRenderOptions): Promise<string>
1703
+
1704
+ /**
1705
+ * Search content for a pattern (one-shot, compiles pattern each time).
1706
+ * For repeated searches with the same pattern, use [`grep`] with file filters.
1707
+ *
1708
+ * # Arguments
1709
+ * - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
1710
+ * - `options`: Regex settings, context, and output mode.
1711
+ *
1712
+ * # Returns
1713
+ * Match list plus counts/limit status; errors are surfaced in `error`.
1714
+ */
1715
+ export declare function search(content: string | Uint8Array, options: SearchOptions): SearchResult
1716
+
1717
+ /** Options for searching file content. */
1718
+ export interface SearchOptions {
1719
+ /** Regex pattern to search for. */
1720
+ pattern: string
1721
+ /** Case-insensitive search. */
1722
+ ignoreCase?: boolean
1723
+ /** Enable multiline matching. */
1724
+ multiline?: boolean
1725
+ /** Maximum number of matches to return. */
1726
+ maxCount?: number
1727
+ /** Skip first N matches. */
1728
+ offset?: number
1729
+ /** Lines of context before matches. */
1730
+ contextBefore?: number
1731
+ /** Lines of context after matches. */
1732
+ contextAfter?: number
1733
+ /** Lines of context before/after matches (legacy). */
1734
+ context?: number
1735
+ /** Truncate lines longer than this (characters). */
1736
+ maxColumns?: number
1737
+ /** Output mode (content or count). */
1738
+ mode?: GrepOutputMode
1739
+ }
1740
+
1741
+ /** Result of searching content. */
1742
+ export interface SearchResult {
1743
+ /** All matches found. */
1744
+ matches: Array<Match>
1745
+ /** Total number of matches (may exceed `matches.len()` due to offset/limit). */
1746
+ matchCount: number
1747
+ /** Whether the limit was reached. */
1748
+ limitReached: boolean
1749
+ /** Error message, if any. */
1750
+ error?: string
1751
+ }
1752
+
1753
+ export declare function setHangulCompatJamoWidthOverride(value: number): void
1754
+
1755
+ /** Options for executing a shell command via brush-core. */
1756
+ export interface ShellExecuteOptions {
1757
+ /** Command string to execute in the shell. */
1758
+ command: string
1759
+ /** Working directory for the command. */
1760
+ cwd?: string
1761
+ /** Environment variables to apply for this command only. */
1762
+ env?: Record<string, string>
1763
+ /** Environment variables to apply once per session. */
1764
+ sessionEnv?: Record<string, string>
1765
+ /** Timeout in milliseconds before cancelling the command. */
1766
+ timeoutMs?: number
1767
+ /** Optional snapshot file to source on session creation. */
1768
+ snapshotPath?: string
1769
+ /** Optional per-command output minimizer configuration. */
1770
+ minimizer?: MinimizerOptions
1771
+ /** Abort signal for cancelling the operation. */
1772
+ signal?: unknown
1773
+ }
1774
+
1775
+ /** Options for configuring a persistent shell session. */
1776
+ export interface ShellOptions {
1777
+ /** Environment variables to apply once per session. */
1778
+ sessionEnv?: Record<string, string>
1779
+ /** Optional snapshot file to source on session creation. */
1780
+ snapshotPath?: string
1781
+ /** Optional per-command output minimizer configuration. */
1782
+ minimizer?: MinimizerOptions
1783
+ }
1784
+
1785
+ /** Options for running a shell command. */
1786
+ export interface ShellRunOptions {
1787
+ /** Command string to execute in the shell. */
1788
+ command: string
1789
+ /** Working directory for the command. */
1790
+ cwd?: string
1791
+ /** Environment variables to apply for this command only. */
1792
+ env?: Record<string, string>
1793
+ /** Timeout in milliseconds before cancelling the command. */
1794
+ timeoutMs?: number
1795
+ /** Abort signal for cancelling the operation. */
1796
+ signal?: unknown
1797
+ }
1798
+
1799
+ /** Result of running a shell command. */
1800
+ export interface ShellRunResult {
1801
+ /** Exit code when the command completes normally. */
1802
+ exitCode?: number
1803
+ /** Whether the command was cancelled via abort. */
1804
+ cancelled: boolean
1805
+ /** Whether the command timed out before completion. */
1806
+ timedOut: boolean
1807
+ /**
1808
+ * When the minimizer rewrote the captured output, this carries the
1809
+ * original buffer + telemetry so the session layer can persist it as
1810
+ * an artifact and splice an `artifact://<id>` reference into the
1811
+ * minimized text shown to the agent. `None` when nothing was rewritten.
1812
+ */
1813
+ minimized?: MinimizerResult
1814
+ /** Shell working directory after command completion. */
1815
+ workingDir?: string
1816
+ }
1817
+
1818
+ /**
1819
+ * Visible slice of a line after ANSI-aware column selection
1820
+ * (`sliceWithWidth`).
1821
+ */
1822
+ export interface SliceResult {
1823
+ /** UTF-16 slice containing the selected text. */
1824
+ text: string
1825
+ /** Visible width of the slice in terminal cells. */
1826
+ width: number
1827
+ }
1828
+
1829
+ /**
1830
+ * Slice a range of visible columns from a line.
1831
+ *
1832
+ * Counts terminal cells, skipping ANSI escapes, and optionally enforces strict
1833
+ * width.
1834
+ */
1835
+ export declare function sliceWithWidth(line: string, startCol: number, length: number, strict: boolean | undefined | null, tabWidth: number): SliceResult
1836
+
1837
+ /** Shape options for one snapcompact frame. */
1838
+ export interface SnapcompactRenderOptions {
1839
+ /**
1840
+ * Frame width in pixels; also bounds the grid rows
1841
+ * (`floor(size/cellHeight/lineRepeat)`). Output height hugs the rows the
1842
+ * text actually uses instead of padding to a square.
1843
+ */
1844
+ size: number
1845
+ /**
1846
+ * Bundled font: `"5x8"`, `"6x12"`, `"8x13"` (X.org BDF), `"8x8"`
1847
+ * (unscii-8), or `"silver"` (embedded TrueType). Default `"5x8"`.
1848
+ */
1849
+ font?: string
1850
+ /**
1851
+ * Target cell advance in pixels. Differing from the font's natural cell
1852
+ * triggers the Lanczos stretch path. Default: font natural width.
1853
+ */
1854
+ cellWidth?: number
1855
+ /** Target cell pitch in pixels. Default: font natural height. */
1856
+ cellHeight?: number
1857
+ /**
1858
+ * Ink variant: `"sent"` (six-hue sentence cycling) or `"bw"` (black).
1859
+ * Default `"sent"`.
1860
+ */
1861
+ variant?: string
1862
+ /**
1863
+ * Print each text line this many times; copies after the first sit on a
1864
+ * pale highlight band. Default 1.
1865
+ */
1866
+ lineRepeat?: number
1867
+ /**
1868
+ * Stretch behavior. Unset: auto — Lanczos-stretch whenever the target
1869
+ * cell differs from the font's natural cell. `false`: never stretch —
1870
+ * render indexed with glyphs at natural size on the requested cell box
1871
+ * (e.g. 8x13 glyphs on an 8x16 pitch, the "8on16" shapes). `true`: force
1872
+ * the stretch path (identical to auto; natural cells render indexed).
1873
+ */
1874
+ stretch?: boolean
1875
+ /**
1876
+ * Layout columns: `1` (default) row-major grid; `2` two newspaper "doc"
1877
+ * columns of pre-wrapped newline-separated lines.
1878
+ */
1879
+ columns?: number
1880
+ }
1881
+
1882
+ /**
1883
+ * Return the subset of `chars` that the named snapcompact font can render.
1884
+ *
1885
+ * The TypeScript normalizer uses this to keep Unicode text intact only when
1886
+ * the selected native font has a glyph for it; renderer control codes are
1887
+ * considered renderable because they are interpreted outside font lookup.
1888
+ */
1889
+ export declare function snapcompactSupportedChars(font: string, chars: string): string
1890
+
1891
+ /**
1892
+ * Unified-diff hunks with jsdiff
1893
+ * `structuredPatch(_, _, oldText, newText, _, _, { context }).hunks`
1894
+ * semantics. `context` defaults to 4 like jsdiff.
1895
+ */
1896
+ export declare function structuredPatchHunks(oldText: string, newText: string, context?: number | undefined | null): Array<PatchHunk>
1897
+
1898
+ export declare function summarizeCode(options: SummaryOptions): SummaryResult
1899
+
1900
+ export interface SummaryOptions {
1901
+ /** Source code to summarize. */
1902
+ code: string
1903
+ /** Language alias (e.g. "rust", "typescript") used before path inference. */
1904
+ lang?: string
1905
+ /** File path used to infer language by extension when `lang` is omitted. */
1906
+ path?: string
1907
+ /** Minimum total node lines before eliding a body/literal node. */
1908
+ minBodyLines?: number
1909
+ /** Minimum total comment lines before eliding a multiline block comment. */
1910
+ minCommentLines?: number
1911
+ /**
1912
+ * Target visible-line count for BFS unfold. `None` or `0` keeps only
1913
+ * the outermost elisions (no progressive unfolding).
1914
+ */
1915
+ unfoldUntilLines?: number
1916
+ /**
1917
+ * Hard ceiling for BFS unfold. Defaults to `unfold_until_lines * 2`
1918
+ * when omitted.
1919
+ */
1920
+ unfoldLimitLines?: number
1921
+ }
1922
+
1923
+ export interface SummaryResult {
1924
+ /** Canonical language name when parsing succeeded. */
1925
+ language?: string
1926
+ /** True when tree-sitter parsed the source without syntax errors. */
1927
+ parsed: boolean
1928
+ /** True when at least one elision span was emitted. */
1929
+ elided: boolean
1930
+ /** Total source lines. */
1931
+ totalLines: number
1932
+ /** Kept/elided segments in source order. */
1933
+ segments: Array<SummarySegment>
1934
+ }
1935
+
1936
+ export interface SummarySegment {
1937
+ /** "kept" or "elided". */
1938
+ kind: string
1939
+ /** 1-based inclusive start line. */
1940
+ startLine: number
1941
+ /** 1-based inclusive end line. */
1942
+ endLine: number
1943
+ /** Verbatim text for kept segments; absent for elided segments. */
1944
+ text?: string
1945
+ }
1946
+
1947
+ /**
1948
+ * Check if a language is supported for highlighting.
1949
+ * Returns true if the language has either direct support or a fallback
1950
+ * mapping.
1951
+ */
1952
+ export declare function supportsLanguage(lang: string): boolean
1953
+
1954
+ /**
1955
+ * Truncate text to a visible width, preserving ANSI codes.
1956
+ *
1957
+ * Pads with spaces when requested.
1958
+ */
1959
+ export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind: Ellipsis | undefined | null, pad: boolean | undefined | null, tabWidth: number): string
1960
+
1961
+ /**
1962
+ * Score every row of a normalized `f32` matrix against `query` and return
1963
+ * the top `limit` rows.
1964
+ *
1965
+ * Mirrors the TS `searchExactVectorIndex` loop bit-exactly: the query is
1966
+ * normalized by the L2 norm of its *full* length, each row score sums
1967
+ * `matrix[row][col] * (query[col] / norm)` over
1968
+ * `min(query.len, dimensions)` columns in column order. Ranking matches the
1969
+ * TS stable sort: score descending, lower row index first on exact ties
1970
+ * (`-0.0` and `+0.0` compare equal). Callers are expected to enforce the TS
1971
+ * guards first (finite query with a positive norm, non-empty matrix).
1972
+ */
1973
+ export declare function vectorIndexTopK(matrix: Float32Array, dimensions: number, query: Float64Array, limit: number): VectorTopK
1974
+
1975
+ /**
1976
+ * Top-k rows of a normalized vector matrix ranked by dot product with a
1977
+ * normalized query.
1978
+ */
1979
+ export interface VectorTopK {
1980
+ /** Row indices of the selected hits, best score first. */
1981
+ indices: Uint32Array
1982
+ /** Scores aligned with `indices`. */
1983
+ scores: Float64Array
1984
+ }
1985
+
1986
+ /**
1987
+ * Calculate visible width of text, excluding ANSI escape sequences.
1988
+ *
1989
+ * Tabs count as a fixed-width cell.
1990
+ */
1991
+ export declare function visibleWidth(text: string, tabWidth: number): number
1992
+
1993
+ /** Profiling results returned to JavaScript. */
1994
+ export interface WorkProfile {
1995
+ /** Folded stack format for flamegraph tools. */
1996
+ folded: string
1997
+ /** Markdown summary of profiling results. */
1998
+ summary: string
1999
+ /** SVG flamegraph (if generation succeeded). */
2000
+ svg?: string
2001
+ /** Total profiled duration in milliseconds. */
2002
+ totalMs: number
2003
+ /** Number of samples collected. */
2004
+ sampleCount: number
2005
+ }
2006
+
2007
+ /**
2008
+ * Wrap text to a visible width, preserving ANSI escape codes across line
2009
+ * breaks.
2010
+ *
2011
+ * Returns UTF-16 lines with active SGR codes carried across line boundaries.
2012
+ */
2013
+ export declare function wrapTextWithAnsi(text: string, width: number, tabWidth: number): Array<string>