@f5-sales-demo/pi-natives 19.51.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.
@@ -0,0 +1,1370 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /**
4
+ * Parsed file as a chunk tree: query nodes, render views, format grep hits,
5
+ * and apply edits.
6
+ */
7
+ export declare class ChunkState {
8
+ /**
9
+ * Build chunk state by parsing `source` with the given `language` id (e.g.
10
+ * `typescript`).
11
+ */
12
+ static parse(source: string, language: string): ChunkState
13
+ /** Normalized language identifier used for the tree-sitter parse. */
14
+ get language(): string
15
+ /** Full source text for this file. */
16
+ get source(): string
17
+ /** Stable checksum for the entire file contents. */
18
+ get checksum(): string
19
+ /** Line count of the source buffer. */
20
+ get lineCount(): number
21
+ /** Count of tree-sitter error nodes seen while building the tree. */
22
+ get parseErrors(): number
23
+ /** True when a fallback classifier produced the tree. */
24
+ get fallback(): boolean
25
+ /** Selector path string for the synthetic root (often empty). */
26
+ get rootPath(): string
27
+ /** Top-level child chunk paths under the root. */
28
+ get rootChildren(): Array<string>
29
+ /** Total number of chunk nodes. */
30
+ get chunkCount(): number
31
+ /** True when the parsed file contains unresolved merge conflicts. */
32
+ hasConflicts(): boolean
33
+ /** Count of unresolved merge conflicts represented in the chunk tree. */
34
+ conflictCount(): number
35
+ /** Summary for the root chunk, if it exists. */
36
+ root(): ChunkInfo | null
37
+ /** Look up [`ChunkInfo`] for a chunk selector path. */
38
+ chunk(chunkPath: string): ChunkInfo | null
39
+ /** Every chunk node as a [`ChunkInfo`] list. */
40
+ chunks(): Array<ChunkInfo>
41
+ /**
42
+ * Direct children of `chunkPath` (use empty or omit for root); errors if
43
+ * the path is missing.
44
+ */
45
+ children(chunkPath?: string | undefined | null): Array<ChunkInfo>
46
+ /** Chunk selector path that contains 1-based source line `line`, if any. */
47
+ lineToContainingChunkPath(line: number): string | null
48
+ /** Render a chunk subtree or listing as UTF-8 text for tools. */
49
+ render(params: RenderParams): string
50
+ /**
51
+ * Parse `readPath` (selector, line scope, etc.) and return rendered text or
52
+ * errors.
53
+ */
54
+ renderRead(params: ReadRenderParams): ReadResult
55
+ /**
56
+ * Prefix a grep line with `display_path` and the chunk path for
57
+ * `line_number`, when known.
58
+ */
59
+ formatGrepLine(displayPath: string, lineNumber: number, line: string): string
60
+ /**
61
+ * Apply batch edits, re-parse, write files, and return updated state and
62
+ * messaging.
63
+ */
64
+ applyEdits(params: EditParams): EditResult
65
+ }
66
+
67
+ /**
68
+ * Long-lived macOS appearance observer.
69
+ *
70
+ * Subscribes to `AppleInterfaceThemeChangedNotification` via
71
+ * `CFDistributedNotificationCenter` and calls the provided callback
72
+ * with `"dark"` or `"light"` on each change (and once on start).
73
+ *
74
+ * A 2-second polling timer also runs as fallback — distributed
75
+ * notifications may not reliably reach background threads on all
76
+ * macOS versions.
77
+ *
78
+ * On non-macOS platforms, `start()` returns a no-op observer.
79
+ */
80
+ export declare class MacAppearanceObserver {
81
+ static start(callback: (err: null | Error, appearance: MacOSAppearance) => void): MacAppearanceObserver
82
+ stop(): void
83
+ }
84
+
85
+ /**
86
+ * Long-lived macOS power assertion.
87
+ *
88
+ * On macOS this acquires an `IOKit` assertion that prevents idle sleep until
89
+ * the handle is stopped or dropped. On other platforms it is a no-op handle so
90
+ * the caller can keep one cross-platform code path.
91
+ */
92
+ export declare class MacOSPowerAssertion {
93
+ /** Acquire a macOS power assertion. */
94
+ static start(options?: MacOSPowerAssertionOptions | undefined | null): MacOSPowerAssertion
95
+ /** Release the power assertion early. */
96
+ stop(): void
97
+ }
98
+
99
+ /** Image container for native interop. */
100
+ export declare class PhotonImage {
101
+ /**
102
+ * Create a new `PhotonImage` from encoded image bytes (PNG, JPEG, WebP,
103
+ * GIF). Returns the decoded image handle on success.
104
+ *
105
+ * # Errors
106
+ * Returns an error if the image format cannot be detected or decoded.
107
+ */
108
+ static parse(bytes: Uint8Array): ImageTask
109
+ /** Get the image width in pixels. */
110
+ get width(): number
111
+ /** Get the image height in pixels. */
112
+ get height(): number
113
+ /**
114
+ * Encode the image to bytes in the specified format.
115
+ *
116
+ * # Errors
117
+ * Returns an error if encoding fails or format is invalid.
118
+ */
119
+ encode(format: ImageFormat, quality: number): Promise<Array<number>>
120
+ /**
121
+ * Resize the image to the specified pixel dimensions using the filter.
122
+ * Returns a new `PhotonImage` containing the resized image.
123
+ */
124
+ resize(width: number, height: number, filter: SamplingFilter): ImageTask
125
+ }
126
+
127
+ /** Stateful PTY session for interactive stdin/stdout passthrough. */
128
+ export declare class PtySession {
129
+ constructor()
130
+ /** Start a PTY command and stream output chunks via callback. */
131
+ start(options: PtyStartOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<PtyRunResult>
132
+ /** Write raw input bytes to PTY stdin. */
133
+ write(data: string): void
134
+ /** Resize the active PTY. */
135
+ resize(cols: number, rows: number): void
136
+ /** Force-kill the active PTY command. */
137
+ kill(): void
138
+ }
139
+
140
+ /** Persistent brush-core shell session. */
141
+ export declare class Shell {
142
+ /**
143
+ * Create a new shell session from optional configuration.
144
+ *
145
+ * The options set session-scoped environment variables and a snapshot path.
146
+ */
147
+ constructor(options?: ShellOptions | undefined | null)
148
+ /**
149
+ * Run a shell command using the provided options.
150
+ *
151
+ * The `on_chunk` callback receives streamed stdout/stderr output. Returns
152
+ * the exit code when the command completes, or flags when cancelled or
153
+ * timed out.
154
+ */
155
+ run(options: ShellRunOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellRunResult>
156
+ /**
157
+ * Abort all running commands for this shell session.
158
+ *
159
+ * Returns `Ok(())` even when no commands are running.
160
+ */
161
+ abort(): Promise<void>
162
+ }
163
+
164
+ /**
165
+ * Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
166
+ * a promise.
167
+ */
168
+ export declare function astEdit(options: AstReplaceOptions): Promise<AstReplaceResult>
169
+
170
+ /** One ast-grep match with source range and optional meta-variables. */
171
+ export interface AstFindMatch {
172
+ /** Display path of the matching file. */
173
+ path: string
174
+ /** Matched source text. */
175
+ text: string
176
+ /** Start byte offset in the file (UTF-8 byte index). */
177
+ byteStart: number
178
+ /** End byte offset in the file (exclusive UTF-8 byte index). */
179
+ byteEnd: number
180
+ /** 1-based start line. */
181
+ startLine: number
182
+ /** 1-based start column. */
183
+ startColumn: number
184
+ /** 1-based end line. */
185
+ endLine: number
186
+ /** 1-based end column. */
187
+ endColumn: number
188
+ /** Meta-variable name to captured text, when `includeMeta` was enabled. */
189
+ metaVariables?: Record<string, string>
190
+ }
191
+
192
+ /** Options for `astGrep`: patterns, scan scope, and match limits. */
193
+ export interface AstFindOptions {
194
+ /** ast-grep patterns to search for (OR across patterns). */
195
+ patterns?: Array<string>
196
+ /** Language override; otherwise inferred from file extension per candidate. */
197
+ lang?: string
198
+ /** Single file or directory to scan (combined with `glob` when set). */
199
+ path?: string
200
+ /** Optional glob filter relative to the search root. */
201
+ glob?: string
202
+ /** Rule selector for multi-rule ast-grep configurations. */
203
+ selector?: string
204
+ /** Pattern strictness; defaults to smart matching when omitted. */
205
+ strictness?: AstMatchStrictness
206
+ /** Maximum matches to return after `offset` (default applies when omitted). */
207
+ limit?: number
208
+ /** Number of leading matches to skip before applying `limit`. */
209
+ offset?: number
210
+ /** When true, include meta-variable bindings per match. */
211
+ includeMeta?: boolean
212
+ /**
213
+ * Reserved for contextual snippets; not used by the current native find
214
+ * path.
215
+ */
216
+ context?: number
217
+ /** Optional cancellation handle (library-specific). */
218
+ signal?: unknown
219
+ /** Wall-clock timeout for the worker task in milliseconds. */
220
+ timeoutMs?: number
221
+ }
222
+
223
+ /** Aggregated search statistics and any parse or compile diagnostics. */
224
+ export interface AstFindResult {
225
+ /** Page of matches after sort, offset, and limit. */
226
+ matches: Array<AstFindMatch>
227
+ /** Total matches found before paging (can exceed `matches.length`). */
228
+ totalMatches: number
229
+ /** Distinct files that contained at least one match. */
230
+ filesWithMatches: number
231
+ /** Files examined for the query. */
232
+ filesSearched: number
233
+ /** True when results were truncated by `limit`. */
234
+ limitReached: boolean
235
+ /** Non-fatal parse or pattern errors collected during the run. */
236
+ parseErrors?: Array<string>
237
+ }
238
+
239
+ /**
240
+ * Search source files with ast-grep patterns; returns a promise resolved on a
241
+ * worker thread.
242
+ */
243
+ export declare function astGrep(options: AstFindOptions): Promise<AstFindResult>
244
+
245
+ /** ast-grep pattern strictness (controls how patterns match syntax). */
246
+ export declare enum AstMatchStrictness {
247
+ /** Match at the concrete syntax tree level. */
248
+ Cst = 'cst',
249
+ /** Balanced default suitable for most searches. */
250
+ Smart = 'smart',
251
+ /** Match at the AST level. */
252
+ Ast = 'ast',
253
+ /** More permissive matching. */
254
+ Relaxed = 'relaxed',
255
+ /** Match structural signatures. */
256
+ Signature = 'signature',
257
+ /** Template-style pattern matching. */
258
+ Template = 'template'
259
+ }
260
+
261
+ /**
262
+ * One textual replacement applied to a file (before/after slice and
263
+ * coordinates).
264
+ */
265
+ export interface AstReplaceChange {
266
+ /** File path for this change. */
267
+ path: string
268
+ /** Original matched text. */
269
+ before: string
270
+ /** Replacement text. */
271
+ after: string
272
+ /** Start byte offset of the replaced span. */
273
+ byteStart: number
274
+ /** End byte offset of the replaced span (exclusive). */
275
+ byteEnd: number
276
+ /**
277
+ * Length of deleted text in bytes (may differ from `byteEnd - byteStart`
278
+ * for edge cases).
279
+ */
280
+ deletedLength: number
281
+ /** 1-based start line of the match. */
282
+ startLine: number
283
+ /** 1-based start column. */
284
+ startColumn: number
285
+ /** 1-based end line. */
286
+ endLine: number
287
+ /** 1-based end column. */
288
+ endColumn: number
289
+ }
290
+
291
+ /** Per-file replacement count after an `astEdit` run. */
292
+ export interface AstReplaceFileChange {
293
+ /** File that had replacements. */
294
+ path: string
295
+ /** Number of replacements in that file. */
296
+ count: number
297
+ }
298
+
299
+ /**
300
+ * Options for `astEdit`: rewrite rules, scan scope, safety limits, and
301
+ * dry-run.
302
+ */
303
+ export interface AstReplaceOptions {
304
+ /** Map of pattern string to replacement template. */
305
+ rewrites?: Record<string, string>
306
+ /** Language override; otherwise inferred from discovered files. */
307
+ lang?: string
308
+ /** Single file or directory to rewrite. */
309
+ path?: string
310
+ /** Optional glob filter within the search root. */
311
+ glob?: string
312
+ /** Rule selector for multi-rule configurations. */
313
+ selector?: string
314
+ /** Pattern strictness for rewrites. */
315
+ strictness?: AstMatchStrictness
316
+ /** When true (default), compute changes without writing files. */
317
+ dryRun?: boolean
318
+ /** Cap on replacement applications across all files. */
319
+ maxReplacements?: number
320
+ /** Cap on distinct files that may be modified. */
321
+ maxFiles?: number
322
+ /** Fail the operation when a file cannot be parsed for rewriting. */
323
+ failOnParseError?: boolean
324
+ /** Optional cancellation handle. */
325
+ signal?: unknown
326
+ /** Wall-clock timeout for the worker task in milliseconds. */
327
+ timeoutMs?: number
328
+ }
329
+
330
+ /** Summary of an ast-grep rewrite pass, including whether disk writes occurred. */
331
+ export interface AstReplaceResult {
332
+ /** Individual replacement records (may be large). */
333
+ changes: Array<AstReplaceChange>
334
+ /** Replacement counts grouped by file. */
335
+ fileChanges: Array<AstReplaceFileChange>
336
+ /** Total replacements applied or previewed. */
337
+ totalReplacements: number
338
+ /** Files that had at least one replacement. */
339
+ filesTouched: number
340
+ /** Files considered for rewriting. */
341
+ filesSearched: number
342
+ /** False when `dryRun` prevented writing. */
343
+ applied: boolean
344
+ /** True when limits stopped further replacements. */
345
+ limitReached: boolean
346
+ /** Parse or pattern errors when not failing the whole operation. */
347
+ parseErrors?: Array<string>
348
+ }
349
+
350
+ /**
351
+ * How chunk anchors are formatted in rendered output (name and checksum
352
+ * visibility).
353
+ */
354
+ export declare enum ChunkAnchorStyle {
355
+ /** `[.name#crc]` style anchor. */
356
+ Full = 'full',
357
+ /** `[.kind#crc]` style anchor (kind is the name prefix before `_`). */
358
+ Kind = 'kind',
359
+ /** `[#crc]` style anchor. */
360
+ Bare = 'bare',
361
+ /** `[.name]` without checksum. */
362
+ FullOmit = 'full-omit',
363
+ /** `[.kind]` without checksum. */
364
+ KindOmit = 'kind-omit',
365
+ /** Minimal anchor without name or checksum. */
366
+ None = 'none'
367
+ }
368
+
369
+ /** Structural edit to apply relative to a chunk anchor. */
370
+ export declare enum ChunkEditOp {
371
+ /** Put new content into the targeted region. */
372
+ Put = 'put',
373
+ /** Find and replace a literal substring within the targeted region. */
374
+ Replace = 'replace',
375
+ /** Remove the targeted region. */
376
+ Delete = 'delete',
377
+ /** Insert `content` before the targeted region span. */
378
+ Before = 'before',
379
+ /** Insert `content` after the targeted region span. */
380
+ After = 'after',
381
+ /** Insert `content` at the start inside the targeted region. */
382
+ Prepend = 'prepend',
383
+ /** Insert `content` at the end inside the targeted region. */
384
+ Append = 'append'
385
+ }
386
+
387
+ /** How a chunk participates in a focus-scoped render pass. */
388
+ export declare enum ChunkFocusMode {
389
+ /** Emit full content and recurse normally. */
390
+ Expanded = 'expanded',
391
+ /** Emit just the opening anchor; do not recurse or emit body. */
392
+ Collapsed = 'collapsed',
393
+ /**
394
+ * Emit opening + closing anchors; recurse into focused children only.
395
+ * Interior gap lines between children are suppressed.
396
+ */
397
+ Container = 'container'
398
+ }
399
+
400
+ /** Summary of a single chunk node for tool output and navigation. */
401
+ export interface ChunkInfo {
402
+ /** Chunk selector path within the tree. */
403
+ path: string
404
+ /** Bare chunk identifier (without kind prefix), if available. */
405
+ identifier?: string
406
+ /** Stable checksum anchor for this chunk. */
407
+ checksum: string
408
+ /** 1-based start line in the source file (inclusive). */
409
+ startLine: number
410
+ /** 1-based end line in the source file (inclusive). */
411
+ endLine: number
412
+ /** Whether this node is a leaf (no child chunks). */
413
+ leaf: boolean
414
+ }
415
+
416
+ /** Result of resolving a chunk read request against the tree. */
417
+ export declare enum ChunkReadStatus {
418
+ /** Selector matched a chunk and content was produced. */
419
+ Ok = 'ok',
420
+ /** No chunk matched the requested selector. */
421
+ NotFound = 'not_found',
422
+ /** Chunk matched but does not support the requested region. */
423
+ UnsupportedRegion = 'unsupported_region'
424
+ }
425
+
426
+ /** Outcome of resolving which chunk was read for a `renderRead`-style request. */
427
+ export interface ChunkReadTarget {
428
+ /** Whether the selector matched. */
429
+ status: ChunkReadStatus
430
+ /** Sanitized selector string that was applied. */
431
+ selector: string
432
+ }
433
+
434
+ export declare enum ChunkRegion {
435
+ Head = '^',
436
+ Body = '~'
437
+ }
438
+
439
+ /** Clipboard image payload encoded as PNG bytes. */
440
+ export interface ClipboardImage {
441
+ /** PNG-encoded image bytes. */
442
+ data: Uint8Array
443
+ /** MIME type for the encoded image payload. */
444
+ mimeType: string
445
+ }
446
+
447
+ /** A context line (before or after a match). */
448
+ export interface ContextLine {
449
+ /** 1-indexed line number in the source file. */
450
+ lineNumber: number
451
+ /** Raw line content (trimmed line ending). */
452
+ line: string
453
+ }
454
+
455
+ /**
456
+ * Copy plain text to the system clipboard.
457
+ *
458
+ * # Parameters
459
+ * - `text`: UTF-8 text to place on the clipboard.
460
+ *
461
+ * # Errors
462
+ * Returns an error if clipboard access fails.
463
+ */
464
+ export declare function copyToClipboard(text: string): void
465
+
466
+ /**
467
+ * Detect macOS system appearance via CoreFoundation.
468
+ * Returns `"dark"` or `"light"` on macOS, `null` on other platforms.
469
+ */
470
+ export declare function detectMacOSAppearance(): MacOSAppearance | null
471
+
472
+ /**
473
+ * One edit in a batch; targets a chunk via `sel`/`crc` (with params-level
474
+ * defaults).
475
+ */
476
+ export interface EditOperation {
477
+ /** Edit kind (replace, delete, insert relative to anchor). */
478
+ op: ChunkEditOp
479
+ /**
480
+ * Chunk selector path; falls back to `EditParams.defaultSelector` when
481
+ * omitted.
482
+ */
483
+ sel?: string
484
+ /**
485
+ * Optional checksum anchor; falls back to `EditParams.defaultCrc` when
486
+ * omitted.
487
+ */
488
+ crc?: string
489
+ /** Region to target. When omitted, targets the full chunk. */
490
+ region?: ChunkRegion
491
+ /** Replacement or inserted text (meaning depends on `op`). */
492
+ content?: string
493
+ /**
494
+ * For `replace` op: literal substring to find inside the target chunk.
495
+ * Must match exactly once.
496
+ */
497
+ find?: string
498
+ }
499
+
500
+ /** Arguments for applying a batch of chunk edits to a file. */
501
+ export interface EditParams {
502
+ /** Edits to apply in order. */
503
+ operations: Array<EditOperation>
504
+ /**
505
+ * When true, normalize indentation for response rendering and inserted
506
+ * content. When false, preserve literal tabs/spaces.
507
+ */
508
+ normalizeIndent?: boolean
509
+ /** Default chunk selector when an `EditOperation` omits `sel`. */
510
+ defaultSelector?: string
511
+ /** Default checksum when an `EditOperation` omits `crc`. */
512
+ defaultCrc?: string
513
+ /** Anchor formatting for rendered response text. */
514
+ anchorStyle?: ChunkAnchorStyle
515
+ /** Working directory used to resolve `filePath` and display paths. */
516
+ cwd: string
517
+ /** Path to the source file to edit (often relative to `cwd`). */
518
+ filePath: string
519
+ }
520
+
521
+ /**
522
+ * Result of applying edits: new parse state plus before/after source and
523
+ * messaging.
524
+ */
525
+ export interface EditResult {
526
+ /** Chunk tree state after applying edits and re-parsing. */
527
+ state: ChunkState
528
+ /** Full file text before edits. */
529
+ diffBefore: string
530
+ /** Full file text after edits. */
531
+ diffAfter: string
532
+ /** Rendered summary for tooling (hunks, anchors), driven by `anchorStyle`. */
533
+ responseText: string
534
+ /** Whether the on-disk source changed. */
535
+ changed: boolean
536
+ /** Whether the updated source re-parsed without fatal issues. */
537
+ parseValid: boolean
538
+ /** Absolute or normalized paths that were written or touched. */
539
+ touchedPaths: Array<string>
540
+ /** Non-fatal issues (e.g. selector warnings) collected during apply. */
541
+ warnings: Array<string>
542
+ }
543
+
544
+ /** Ellipsis strategy for [`truncate_to_width`]. */
545
+ export declare enum Ellipsis {
546
+ /** Use a single Unicode ellipsis character ("…"). */
547
+ Unicode = 0,
548
+ /** Use three ASCII dots ("..."). */
549
+ Ascii = 1,
550
+ /** Omit ellipsis entirely. */
551
+ Omit = 2
552
+ }
553
+
554
+ /**
555
+ * Encode image bytes into a SIXEL escape sequence for terminal rendering.
556
+ *
557
+ * The input image is decoded and resized to the requested pixel dimensions
558
+ * before encoding.
559
+ *
560
+ * # Errors
561
+ * Returns an error if decoding, resizing, or SIXEL encoding fails.
562
+ */
563
+ export declare function encodeSixel(bytes: Uint8Array, targetWidthPx: number, targetHeightPx: number): string
564
+
565
+ /**
566
+ * Execute a brush shell command.
567
+ *
568
+ * Creates a fresh session for each call. The `on_chunk` callback receives
569
+ * streamed stdout/stderr output. Returns the exit code when the command
570
+ * completes, or flags when cancelled or timed out.
571
+ */
572
+ export declare function executeShell(options: ShellExecuteOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellExecuteResult>
573
+
574
+ /**
575
+ * Extract the before/after slices around an overlay region.
576
+ *
577
+ * Preserves ANSI state so the `after` segment renders correctly after
578
+ * truncation.
579
+ */
580
+ export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean, tabWidth: number): ExtractSegmentsResult
581
+
582
+ /** Before/after UTF-16 segments around an overlay region, with measured widths. */
583
+ export interface ExtractSegmentsResult {
584
+ /** UTF-16 content before the overlay region. */
585
+ before: string
586
+ /** Visible width of the `before` segment. */
587
+ beforeWidth: number
588
+ /** UTF-16 content after the overlay region. */
589
+ after: string
590
+ /** Visible width of the `after` segment. */
591
+ afterWidth: number
592
+ }
593
+
594
+ /** Resolved filesystem entry kind for glob filters and match metadata. */
595
+ export declare enum FileType {
596
+ /** Regular file. */
597
+ File = 1,
598
+ /** Directory. */
599
+ Dir = 2,
600
+ /** Symbolic link. */
601
+ Symlink = 3
602
+ }
603
+
604
+ /** Path + focus mode pair for the N-API boundary (`HashMap` doesn't cross FFI). */
605
+ export interface FocusedPath {
606
+ path: string
607
+ mode: ChunkFocusMode
608
+ }
609
+
610
+ /**
611
+ * Format one chunk anchor string for a node at `depth` using `style` and
612
+ * optional checksum omission.
613
+ */
614
+ export declare function formatAnchor(name: string, checksum: string, style: ChunkAnchorStyle, omitChecksum?: boolean | undefined | null): string
615
+
616
+ /** Fuzzy file path search for autocomplete. */
617
+ export declare function fuzzyFind(options: FuzzyFindOptions): Promise<FuzzyFindResult>
618
+
619
+ /** A single match in fuzzy find results. */
620
+ export interface FuzzyFindMatch {
621
+ /** Relative path from the search root (uses `/` separators). */
622
+ path: string
623
+ /** Whether this entry is a directory. */
624
+ isDirectory: boolean
625
+ /** Match quality score (higher is better). */
626
+ score: number
627
+ }
628
+
629
+ /** Options for fuzzy file path search. */
630
+ export interface FuzzyFindOptions {
631
+ /** Fuzzy query to match against file paths (case-insensitive). */
632
+ query: string
633
+ /** Directory to search. */
634
+ path: string
635
+ /** Include hidden files (default: false). */
636
+ hidden?: boolean
637
+ /** Respect .gitignore (default: true). */
638
+ gitignore?: boolean
639
+ /** Enable shared filesystem scan cache (default: false). */
640
+ cache?: boolean
641
+ /** Maximum number of matches to return (default: 100). */
642
+ maxResults?: number
643
+ /** Abort signal for cancelling the operation. */
644
+ signal?: unknown
645
+ /** Timeout in milliseconds for the operation. */
646
+ timeoutMs?: number
647
+ }
648
+
649
+ /** Result of fuzzy file path search. */
650
+ export interface FuzzyFindResult {
651
+ /** Matched entries (up to `maxResults`). */
652
+ matches: Array<FuzzyFindMatch>
653
+ /** Total number of matches found (may exceed `matches.len()`). */
654
+ totalMatches: number
655
+ }
656
+
657
+ /** Get list of supported languages. */
658
+ export declare function getSupportedLanguages(): Array<string>
659
+
660
+ /**
661
+ * Get work profile data from the last N seconds.
662
+ *
663
+ * Always-on profiling - no need to start/stop. Just call this to get
664
+ * recent activity.
665
+ */
666
+ export declare function getWorkProfile(lastSeconds: number): WorkProfile
667
+
668
+ /**
669
+ * Find filesystem entries matching a glob pattern.
670
+ *
671
+ * Resolves the search root, scans entries, applies glob and optional file-type
672
+ * filters, and optionally streams each accepted match through `on_match`.
673
+ *
674
+ * If `sortByMtime` is enabled, all matching entries are collected, sorted by
675
+ * descending mtime, then truncated to `maxResults`.
676
+ *
677
+ * # Errors
678
+ * Returns an error when the search path cannot be resolved, the path is not a
679
+ * directory, the glob pattern is invalid, or cancellation/timeout is
680
+ * triggered.
681
+ */
682
+ export declare function glob(options: GlobOptions, onMatch?: ((error: Error | null, match: GlobMatch) => void) | undefined | null): Promise<GlobResult>
683
+
684
+ /** A single filesystem entry from a directory scan. */
685
+ export interface GlobMatch {
686
+ /** Relative path from the search root, using forward slashes. */
687
+ path: string
688
+ /** Resolved filesystem type for the match. */
689
+ fileType: FileType
690
+ /**
691
+ * Modification time in milliseconds since Unix epoch (from
692
+ * `symlink_metadata`).
693
+ */
694
+ mtime?: number
695
+ }
696
+
697
+ /** Input options for `glob`, including traversal, filtering, and cancellation. */
698
+ export interface GlobOptions {
699
+ /** Glob pattern to match (e.g., "*.ts"). */
700
+ pattern: string
701
+ /** Directory to search. */
702
+ path: string
703
+ /**
704
+ * Filter by file type: "file", "dir", or "symlink". Symlinks are
705
+ * matched for file/dir filters based on their target type.
706
+ */
707
+ fileType?: FileType
708
+ /** Match simple patterns recursively by default (`*.ts` -> recursive). */
709
+ recursive?: boolean
710
+ /** Include hidden files (default: false). */
711
+ hidden?: boolean
712
+ /** Maximum number of results to return. */
713
+ maxResults?: number
714
+ /** Respect .gitignore files (default: true). */
715
+ gitignore?: boolean
716
+ /** Enable shared filesystem scan cache (default: false). */
717
+ cache?: boolean
718
+ /** Sort results by mtime (most recent first) before applying limit. */
719
+ sortByMtime?: boolean
720
+ /**
721
+ * Include `node_modules` entries when the pattern does not explicitly
722
+ * mention them.
723
+ */
724
+ includeNodeModules?: boolean
725
+ /** Abort signal for cancelling the operation. */
726
+ signal?: unknown
727
+ /** Timeout in milliseconds for the operation. */
728
+ timeoutMs?: number
729
+ }
730
+
731
+ /** Result payload returned by a glob operation. */
732
+ export interface GlobResult {
733
+ /** Matched filesystem entries. */
734
+ matches: Array<GlobMatch>
735
+ /** Number of returned matches (`matches.len()`), clamped to `u32::MAX`. */
736
+ totalMatches: number
737
+ }
738
+
739
+ /**
740
+ * Search files for a regex pattern.
741
+ *
742
+ * # Arguments
743
+ * - `options`: Pattern, path, filters, and output mode.
744
+ * - `on_match`: Optional callback invoked per match/result.
745
+ *
746
+ * # Returns
747
+ * Aggregated results across matching files.
748
+ */
749
+ export declare function grep(options: GrepOptions, onMatch?: ((error: Error | null, match: GrepMatch) => void) | undefined | null): Promise<GrepResult>
750
+
751
+ /** A single match in a grep result. */
752
+ export interface GrepMatch {
753
+ /** File path for the match (relative for directory searches). */
754
+ path: string
755
+ /** 1-indexed line number (0 for count-only entries). */
756
+ lineNumber: number
757
+ /** The matched line content (empty for count-only entries). */
758
+ line: string
759
+ /** Context lines before the match. */
760
+ contextBefore?: Array<ContextLine>
761
+ /** Context lines after the match. */
762
+ contextAfter?: Array<ContextLine>
763
+ /** Whether the line was truncated. */
764
+ truncated?: boolean
765
+ /** Per-file match count (count mode only). */
766
+ matchCount?: number
767
+ }
768
+
769
+ /** Options for searching files on disk. */
770
+ export interface GrepOptions {
771
+ /** Regex pattern to search for. */
772
+ pattern: string
773
+ /** Directory or file to search. */
774
+ path: string
775
+ /** Glob filter for filenames (e.g., "*.ts"). */
776
+ glob?: string
777
+ /** Filter by file type (e.g., "js", "py", "rust"). */
778
+ type?: string
779
+ /** Case-insensitive search. */
780
+ ignoreCase?: boolean
781
+ /** Enable multiline matching. */
782
+ multiline?: boolean
783
+ /** Include hidden files (default: true). */
784
+ hidden?: boolean
785
+ /** Respect .gitignore files (default: true). */
786
+ gitignore?: boolean
787
+ /** Enable shared filesystem scan cache (default: false). */
788
+ cache?: boolean
789
+ /** Maximum number of matches to return. */
790
+ maxCount?: number
791
+ /** Skip first N matches. */
792
+ offset?: number
793
+ /** Lines of context before matches. */
794
+ contextBefore?: number
795
+ /** Lines of context after matches. */
796
+ contextAfter?: number
797
+ /** Lines of context before/after matches (legacy). */
798
+ context?: number
799
+ /** Truncate lines longer than this (characters). */
800
+ maxColumns?: number
801
+ /** Output mode (content, filesWithMatches, or count). */
802
+ mode?: GrepOutputMode
803
+ /** Abort signal for cancelling the operation. */
804
+ signal?: unknown
805
+ /** Timeout in milliseconds for the operation. */
806
+ timeoutMs?: number
807
+ }
808
+
809
+ /** Output mode for [`search`] and [`grep`] (string values match JS callers). */
810
+ export declare enum GrepOutputMode {
811
+ /** Emit matched lines (and optional context lines). */
812
+ Content = 'content',
813
+ /** Emit per-file or total counts instead of line content. */
814
+ Count = 'count',
815
+ /** Emit one row per file that matched, without line content. */
816
+ FilesWithMatches = 'filesWithMatches'
817
+ }
818
+
819
+ /** Result of searching files. */
820
+ export interface GrepResult {
821
+ /** Matches or per-file counts, depending on output mode. */
822
+ matches: Array<GrepMatch>
823
+ /** Total matches across all files. */
824
+ totalMatches: number
825
+ /** Number of files with at least one match. */
826
+ filesWithMatches: number
827
+ /** Number of files searched. */
828
+ filesSearched: number
829
+ /** Whether the limit/offset stopped the search early. */
830
+ limitReached?: boolean
831
+ }
832
+
833
+ /**
834
+ * Quick check if content matches a pattern.
835
+ *
836
+ * # Arguments
837
+ * - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
838
+ * - `pattern`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
839
+ * - `ignore_case`: Case-insensitive matching.
840
+ * - `multiline`: Enable multiline regex mode.
841
+ *
842
+ * # Returns
843
+ * True if any match exists; false on no match.
844
+ */
845
+ export declare function hasMatch(content: string | Uint8Array, pattern: string | Uint8Array, ignoreCase?: boolean | undefined | null, multiline?: boolean | undefined | null): boolean
846
+
847
+ /**
848
+ * Highlight code and return ANSI-colored lines.
849
+ *
850
+ * # Arguments
851
+ * * `code` - The source code to highlight
852
+ * * `lang` - Language identifier (e.g., "rust", "typescript", "python")
853
+ * * `colors` - Theme colors as ANSI escape sequences
854
+ *
855
+ * # Returns
856
+ * Highlighted code with ANSI color codes, or the original code if highlighting
857
+ * fails.
858
+ */
859
+ export declare function highlightCode(code: string, lang: string | undefined | null, colors: HighlightColors): string
860
+
861
+ /**
862
+ * Theme colors for syntax highlighting.
863
+ * Each color is an ANSI escape sequence (e.g., "\x1b[38;2;255;0;0m").
864
+ */
865
+ export interface HighlightColors {
866
+ /** ANSI color for comments. */
867
+ comment: string
868
+ /** ANSI color for keywords. */
869
+ keyword: string
870
+ /** ANSI color for function names. */
871
+ function: string
872
+ /** ANSI color for variables and identifiers. */
873
+ variable: string
874
+ /** ANSI color for string literals. */
875
+ string: string
876
+ /** ANSI color for numeric literals. */
877
+ number: string
878
+ /** ANSI color for type identifiers. */
879
+ type: string
880
+ /** ANSI color for operators. */
881
+ operator: string
882
+ /** ANSI color for punctuation tokens. */
883
+ punctuation: string
884
+ /**
885
+ * ANSI color for control flow keywords (if, else, for, while, return,
886
+ * import).
887
+ */
888
+ control?: string
889
+ /** ANSI color for diff inserted lines. */
890
+ inserted?: string
891
+ /** ANSI color for diff deleted lines. */
892
+ deleted?: string
893
+ }
894
+
895
+ /**
896
+ * Convert HTML source to Markdown with optional preprocessing.
897
+ *
898
+ * # Errors
899
+ * Returns an error if the conversion fails or the worker task aborts.
900
+ */
901
+ export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions | undefined | null): Promise<string>
902
+
903
+ /** Options for HTML to Markdown conversion. */
904
+ export interface HtmlToMarkdownOptions {
905
+ /** Remove navigation elements, forms, headers, footers. */
906
+ cleanContent?: boolean
907
+ /** Skip images during conversion. */
908
+ skipImages?: boolean
909
+ }
910
+
911
+ /** Output format for [`PhotonImage::encode`]. */
912
+ export declare enum ImageFormat {
913
+ /** PNG encoded bytes. */
914
+ PNG = 0,
915
+ /** JPEG encoded bytes. */
916
+ JPEG = 1,
917
+ /** WebP encoded bytes. */
918
+ WEBP = 2,
919
+ /** GIF encoded bytes. */
920
+ GIF = 3
921
+ }
922
+
923
+ /**
924
+ * Invalidate the filesystem scan cache.
925
+ *
926
+ * When called with a path, removes entries for roots containing that path.
927
+ * When called without a path, clears the entire cache.
928
+ *
929
+ * Intended to be called after agent file mutations (write, edit, rename,
930
+ * delete).
931
+ */
932
+ export declare function invalidateFsScanCache(path?: string | undefined | null): void
933
+
934
+ /** Event types from Kitty keyboard protocol (flag 2). */
935
+ export declare enum KeyEventType {
936
+ /** Key press event. */
937
+ Press = 1,
938
+ /** Key repeat event. */
939
+ Repeat = 2,
940
+ /** Key release event. */
941
+ Release = 3
942
+ }
943
+
944
+ /**
945
+ * Kill a process tree (the process and all its descendants).
946
+ *
947
+ * Arguments: `pid` is the root process and `signal` is the kill signal.
948
+ * Kills children first (bottom-up) to prevent orphan re-parenting issues.
949
+ * Returns the number of processes successfully killed.
950
+ */
951
+ export declare function killTree(pid: number, signal: number): number
952
+
953
+ /**
954
+ * List all descendant PIDs of `pid`.
955
+ *
956
+ * Returns an empty array if the process has no children or doesn't exist.
957
+ */
958
+ export declare function listDescendants(pid: number): Array<number>
959
+
960
+ /**
961
+ * System UI appearance reported by native macOS APIs (`detectMacOSAppearance`
962
+ * and observer).
963
+ */
964
+ export declare enum MacOSAppearance {
965
+ /** Dark color scheme. */
966
+ Dark = 'dark',
967
+ /** Light color scheme. */
968
+ Light = 'light'
969
+ }
970
+
971
+ /** Options for starting a macOS power assertion. */
972
+ export interface MacOSPowerAssertionOptions {
973
+ /** Human-readable reason shown in macOS power diagnostics. */
974
+ reason?: string
975
+ /** Keep the display awake in addition to preventing idle system sleep. */
976
+ display?: boolean
977
+ }
978
+
979
+ /** A single match in the content. */
980
+ export interface Match {
981
+ /** 1-indexed line number. */
982
+ lineNumber: number
983
+ /** The matched line content. */
984
+ line: string
985
+ /** Context lines before the match. */
986
+ contextBefore?: Array<ContextLine>
987
+ /** Context lines after the match. */
988
+ contextAfter?: Array<ContextLine>
989
+ /** Whether the line was truncated. */
990
+ truncated?: boolean
991
+ }
992
+
993
+ /**
994
+ * Match input data against a key identifier string.
995
+ *
996
+ * Returns true when the bytes represent the specified key with modifiers.
997
+ */
998
+ export declare function matchesKey(data: string, keyId: string, kittyProtocolActive: boolean): boolean
999
+
1000
+ /**
1001
+ * Match Kitty protocol input against a codepoint and modifier mask.
1002
+ *
1003
+ * Returns true when the parsed sequence matches the expected codepoint (or
1004
+ * base layout key) and modifier bits.
1005
+ */
1006
+ export declare function matchesKittySequence(data: string, expectedCodepoint: number, expectedModifier: number): boolean
1007
+
1008
+ /**
1009
+ * Check if input matches a legacy escape sequence for the given key name.
1010
+ *
1011
+ * Returns true only when the byte sequence maps to the exact key identifier.
1012
+ */
1013
+ export declare function matchesLegacySequence(data: string, keyName: string): boolean
1014
+
1015
+ /** Parsed Kitty keyboard protocol sequence result for a Kitty input sequence. */
1016
+ export interface ParsedKittyResult {
1017
+ /** Primary codepoint associated with the key. */
1018
+ codepoint: number
1019
+ /** Optional shifted key codepoint from the sequence. */
1020
+ shiftedKey?: number
1021
+ /** Optional base layout key codepoint from the sequence. */
1022
+ baseLayoutKey?: number
1023
+ /** Modifier bitmask (shift/alt/ctrl), excluding lock bits. */
1024
+ modifier: number
1025
+ /** Optional event type (1 = press, 2 = repeat, 3 = release). */
1026
+ eventType?: KeyEventType
1027
+ }
1028
+
1029
+ /**
1030
+ * Parse terminal input and return a normalized key identifier.
1031
+ *
1032
+ * Returns a key id like "escape" or "ctrl+c", or None if unrecognized.
1033
+ */
1034
+ export declare function parseKey(data: string, kittyProtocolActive: boolean): string | null
1035
+
1036
+ /**
1037
+ * Parse a Kitty keyboard protocol sequence.
1038
+ *
1039
+ * Returns a structured parse result when the input is a valid Kitty sequence.
1040
+ */
1041
+ export declare function parseKittySequence(data: string): ParsedKittyResult | null
1042
+
1043
+ /** Probe whether `ProjFS` overlay virtualization can be started on this system. */
1044
+ export declare function projfsOverlayProbe(): ProjfsOverlayProbeResult
1045
+
1046
+ /**
1047
+ * Result of probing Windows Projected File System (`ProjFS`) support for
1048
+ * overlay workflows.
1049
+ */
1050
+ export interface ProjfsOverlayProbeResult {
1051
+ /** True when `ProjFS` APIs are available and loaded. */
1052
+ available: boolean
1053
+ /**
1054
+ * Human-readable reason when `available` is false (e.g. wrong OS or missing
1055
+ * DLL).
1056
+ */
1057
+ reason?: string
1058
+ }
1059
+
1060
+ /**
1061
+ * Start a `ProjFS` overlay: `projection_root` shows the merged view;
1062
+ * `lower_root` is the backing tree.
1063
+ */
1064
+ export declare function projfsOverlayStart(lowerRoot: string, projectionRoot: string): void
1065
+
1066
+ /** Stop `ProjFS` virtualization for an active `projection_root` session. */
1067
+ export declare function projfsOverlayStop(projectionRoot: string): void
1068
+
1069
+ /** Result of a PTY command run. */
1070
+ export interface PtyRunResult {
1071
+ /** Exit code when the command completes. */
1072
+ exitCode?: number
1073
+ /** Whether command was cancelled by signal/user kill. */
1074
+ cancelled: boolean
1075
+ /** Whether command timed out. */
1076
+ timedOut: boolean
1077
+ }
1078
+
1079
+ /** Options for running a command in a PTY session. */
1080
+ export interface PtyStartOptions {
1081
+ /** Command string to execute. */
1082
+ command: string
1083
+ /** Working directory for command execution. */
1084
+ cwd?: string
1085
+ /** Environment variables for this command. */
1086
+ env?: Record<string, string>
1087
+ /** Timeout in milliseconds before cancelling. */
1088
+ timeoutMs?: number
1089
+ /** Abort signal for cancelling the operation. */
1090
+ signal?: unknown
1091
+ /** PTY column count. */
1092
+ cols?: number
1093
+ /** PTY row count. */
1094
+ rows?: number
1095
+ }
1096
+
1097
+ /**
1098
+ * Read an image from the system clipboard.
1099
+ *
1100
+ * Returns `Ok(None)` when no image data is available.
1101
+ *
1102
+ * # Errors
1103
+ * Returns an error if clipboard access fails or image encoding fails.
1104
+ */
1105
+ export declare function readImageFromClipboard(): Promise<ClipboardImage | undefined | null>
1106
+
1107
+ /**
1108
+ * Options for `ChunkState.renderRead`: selector path, display path, and
1109
+ * optional line scoping.
1110
+ */
1111
+ export interface ReadRenderParams {
1112
+ /** Read selector (`sel=...` path, line range, or empty for whole tree). */
1113
+ readPath: string
1114
+ /** Path shown in titles and error messages (often the file path). */
1115
+ displayPath: string
1116
+ /** Optional language label for the rendered block. */
1117
+ languageTag?: string
1118
+ /** Hide checksums in rendered anchors. */
1119
+ omitChecksum: boolean
1120
+ /** Anchor formatting style. */
1121
+ anchorStyle?: ChunkAnchorStyle
1122
+ /** Optional absolute file line range to intersect with the resolved chunk. */
1123
+ absoluteLineRange?: VisibleLineRange
1124
+ /** Replace tabs in embedded previews. */
1125
+ tabReplacement?: string
1126
+ /** When true, normalize displayed indentation to canonical tabs. */
1127
+ normalizeIndent?: boolean
1128
+ }
1129
+
1130
+ /** Rendered chunk text plus optional resolution metadata for the read request. */
1131
+ export interface ReadResult {
1132
+ /** Rendered UTF-8 text (chunk tree, notice, or error message). */
1133
+ text: string
1134
+ /** When a selector was used, whether it matched and which selector applied. */
1135
+ chunk?: ChunkReadTarget
1136
+ }
1137
+
1138
+ /**
1139
+ * Options for `ChunkState.render`: which subtree to show and how anchors
1140
+ * appear.
1141
+ */
1142
+ export interface RenderParams {
1143
+ /** Path of the chunk to render; `None` uses the tree root. */
1144
+ chunkPath?: string
1145
+ /** Title line shown above the tree (often the file path). */
1146
+ title: string
1147
+ /** Optional language label for the header block. */
1148
+ languageTag?: string
1149
+ /** Restrict output to an inclusive line range of the file. */
1150
+ visibleRange?: VisibleLineRange
1151
+ /** When true, list only direct children instead of a full subtree. */
1152
+ renderChildrenOnly: boolean
1153
+ /** Hide checksums in anchors when true. */
1154
+ omitChecksum: boolean
1155
+ /** Anchor formatting style for chunk headers. */
1156
+ anchorStyle?: ChunkAnchorStyle
1157
+ /** Include a one-line preview for leaf chunks. */
1158
+ showLeafPreview: boolean
1159
+ /** Replace tab characters in displayed previews (e.g. two spaces). */
1160
+ tabReplacement?: string
1161
+ /** When true, normalize displayed indentation to canonical tabs. */
1162
+ normalizeIndent?: boolean
1163
+ /**
1164
+ * When set, restrict rendering to these chunks with their specified focus
1165
+ * modes. Everything not in this list is skipped.
1166
+ */
1167
+ focusedPaths?: Array<FocusedPath>
1168
+ }
1169
+
1170
+ /** Sampling filter for resize operations. */
1171
+ export declare enum SamplingFilter {
1172
+ /** Nearest-neighbor sampling (fast, low quality). */
1173
+ Nearest = 1,
1174
+ /** Triangle filter (linear interpolation). */
1175
+ Triangle = 2,
1176
+ /** Catmull-Rom filter with sharper edges. */
1177
+ CatmullRom = 3,
1178
+ /** Gaussian filter for smoother results. */
1179
+ Gaussian = 4,
1180
+ /** Lanczos3 filter for high-quality downscaling. */
1181
+ Lanczos3 = 5
1182
+ }
1183
+
1184
+ /**
1185
+ * Strip ANSI escape sequences, remove control characters / lone surrogates,
1186
+ * and normalize line endings.
1187
+ */
1188
+ export declare function sanitizeText(text: string): string
1189
+
1190
+ /**
1191
+ * Search content for a pattern (one-shot, compiles pattern each time).
1192
+ * For repeated searches with the same pattern, use [`grep`] with file filters.
1193
+ *
1194
+ * # Arguments
1195
+ * - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
1196
+ * - `options`: Regex settings, context, and output mode.
1197
+ *
1198
+ * # Returns
1199
+ * Match list plus counts/limit status; errors are surfaced in `error`.
1200
+ */
1201
+ export declare function search(content: string | Uint8Array, options: SearchOptions): SearchResult
1202
+
1203
+ /** Options for searching file content. */
1204
+ export interface SearchOptions {
1205
+ /** Regex pattern to search for. */
1206
+ pattern: string
1207
+ /** Case-insensitive search. */
1208
+ ignoreCase?: boolean
1209
+ /** Enable multiline matching. */
1210
+ multiline?: boolean
1211
+ /** Maximum number of matches to return. */
1212
+ maxCount?: number
1213
+ /** Skip first N matches. */
1214
+ offset?: number
1215
+ /** Lines of context before matches. */
1216
+ contextBefore?: number
1217
+ /** Lines of context after matches. */
1218
+ contextAfter?: number
1219
+ /** Lines of context before/after matches (legacy). */
1220
+ context?: number
1221
+ /** Truncate lines longer than this (characters). */
1222
+ maxColumns?: number
1223
+ /** Output mode (content or count). */
1224
+ mode?: GrepOutputMode
1225
+ }
1226
+
1227
+ /** Result of searching content. */
1228
+ export interface SearchResult {
1229
+ /** All matches found. */
1230
+ matches: Array<Match>
1231
+ /** Total number of matches (may exceed `matches.len()` due to offset/limit). */
1232
+ matchCount: number
1233
+ /** Whether the limit was reached. */
1234
+ limitReached: boolean
1235
+ /** Error message, if any. */
1236
+ error?: string
1237
+ }
1238
+
1239
+ /** Options for executing a shell command via brush-core. */
1240
+ export interface ShellExecuteOptions {
1241
+ /** Command string to execute in the shell. */
1242
+ command: string
1243
+ /** Working directory for the command. */
1244
+ cwd?: string
1245
+ /** Environment variables to apply for this command only. */
1246
+ env?: Record<string, string>
1247
+ /** Environment variables to apply once per session. */
1248
+ sessionEnv?: Record<string, string>
1249
+ /** Timeout in milliseconds before cancelling the command. */
1250
+ timeoutMs?: number
1251
+ /** Optional snapshot file to source on session creation. */
1252
+ snapshotPath?: string
1253
+ /** Abort signal for cancelling the operation. */
1254
+ signal?: unknown
1255
+ }
1256
+
1257
+ /** Result of executing a shell command via brush-core. */
1258
+ export interface ShellExecuteResult {
1259
+ /** Exit code when the command completes normally. */
1260
+ exitCode?: number
1261
+ /** Whether the command was cancelled via abort. */
1262
+ cancelled: boolean
1263
+ /** Whether the command timed out before completion. */
1264
+ timedOut: boolean
1265
+ }
1266
+
1267
+ /** Options for configuring a persistent shell session. */
1268
+ export interface ShellOptions {
1269
+ /** Environment variables to apply once per session. */
1270
+ sessionEnv?: Record<string, string>
1271
+ /** Optional snapshot file to source on session creation. */
1272
+ snapshotPath?: string
1273
+ }
1274
+
1275
+ /** Options for running a shell command. */
1276
+ export interface ShellRunOptions {
1277
+ /** Command string to execute in the shell. */
1278
+ command: string
1279
+ /** Working directory for the command. */
1280
+ cwd?: string
1281
+ /** Environment variables to apply for this command only. */
1282
+ env?: Record<string, string>
1283
+ /** Timeout in milliseconds before cancelling the command. */
1284
+ timeoutMs?: number
1285
+ /** Abort signal for cancelling the operation. */
1286
+ signal?: unknown
1287
+ }
1288
+
1289
+ /** Result of running a shell command. */
1290
+ export interface ShellRunResult {
1291
+ /** Exit code when the command completes normally. */
1292
+ exitCode?: number
1293
+ /** Whether the command was cancelled via abort. */
1294
+ cancelled: boolean
1295
+ /** Whether the command timed out before completion. */
1296
+ timedOut: boolean
1297
+ }
1298
+
1299
+ /**
1300
+ * Visible slice of a line after ANSI-aware column selection
1301
+ * (`sliceWithWidth`).
1302
+ */
1303
+ export interface SliceResult {
1304
+ /** UTF-16 slice containing the selected text. */
1305
+ text: string
1306
+ /** Visible width of the slice in terminal cells. */
1307
+ width: number
1308
+ }
1309
+
1310
+ /**
1311
+ * Slice a range of visible columns from a line.
1312
+ *
1313
+ * Counts terminal cells, skipping ANSI escapes, and optionally enforces strict
1314
+ * width.
1315
+ */
1316
+ export declare function sliceWithWidth(line: string, startCol: number, length: number, strict: boolean | undefined | null, tabWidth: number): SliceResult
1317
+
1318
+ /**
1319
+ * Check if a language is supported for highlighting.
1320
+ * Returns true if the language has either direct support or a fallback
1321
+ * mapping.
1322
+ */
1323
+ export declare function supportsLanguage(lang: string): boolean
1324
+
1325
+ /**
1326
+ * Truncate text to a visible width, preserving ANSI codes.
1327
+ *
1328
+ * Pads with spaces when requested.
1329
+ */
1330
+ export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind: Ellipsis | undefined | null, pad: boolean | undefined | null, tabWidth: number): string
1331
+
1332
+ /**
1333
+ * Inclusive 1-based line range within a source file (used for scoped chunk
1334
+ * rendering).
1335
+ */
1336
+ export interface VisibleLineRange {
1337
+ /** First line to include. */
1338
+ startLine: number
1339
+ /** Last line to include. */
1340
+ endLine: number
1341
+ }
1342
+
1343
+ /**
1344
+ * Calculate visible width of text, excluding ANSI escape sequences.
1345
+ *
1346
+ * Tabs count as a fixed-width cell.
1347
+ */
1348
+ export declare function visibleWidth(text: string, tabWidth: number): number
1349
+
1350
+ /** Profiling results returned to JavaScript. */
1351
+ export interface WorkProfile {
1352
+ /** Folded stack format for flamegraph tools. */
1353
+ folded: string
1354
+ /** Markdown summary of profiling results. */
1355
+ summary: string
1356
+ /** SVG flamegraph (if generation succeeded). */
1357
+ svg?: string
1358
+ /** Total profiled duration in milliseconds. */
1359
+ totalMs: number
1360
+ /** Number of samples collected. */
1361
+ sampleCount: number
1362
+ }
1363
+
1364
+ /**
1365
+ * Wrap text to a visible width, preserving ANSI escape codes across line
1366
+ * breaks.
1367
+ *
1368
+ * Returns UTF-16 lines with active SGR codes carried across line boundaries.
1369
+ */
1370
+ export declare function wrapTextWithAnsi(text: string, width: number, tabWidth: number): Array<string>