@prometheus-ai/natives 0.5.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.
- package/README.md +80 -0
- package/native/embedded-addon.js +31 -0
- package/native/index.d.ts +1405 -0
- package/native/index.js +124 -0
- package/native/loader-state.d.ts +65 -0
- package/native/loader-state.js +598 -0
- package/package.json +75 -0
|
@@ -0,0 +1,1405 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Long-lived macOS appearance observer.
|
|
5
|
+
*
|
|
6
|
+
* Subscribes to `AppleInterfaceThemeChangedNotification` via
|
|
7
|
+
* `CFDistributedNotificationCenter` and calls the provided callback
|
|
8
|
+
* with `"dark"` or `"light"` on each change (and once on start).
|
|
9
|
+
*
|
|
10
|
+
* A 2-second polling timer also runs as fallback — distributed
|
|
11
|
+
* notifications may not reliably reach background threads on all
|
|
12
|
+
* macOS versions.
|
|
13
|
+
*
|
|
14
|
+
* On non-macOS platforms, `start()` returns a no-op observer.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MacAppearanceObserver {
|
|
17
|
+
static start(callback: (err: null | Error, appearance: MacOSAppearance) => void): MacAppearanceObserver
|
|
18
|
+
stop(): void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Long-lived macOS power assertion.
|
|
23
|
+
*
|
|
24
|
+
* On macOS this acquires one or more `IOKit` assertions that prevent the
|
|
25
|
+
* requested sleep modes until the handle is stopped or dropped. On other
|
|
26
|
+
* platforms it is a no-op handle so the caller can keep one cross-platform
|
|
27
|
+
* code path.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MacOSPowerAssertion {
|
|
30
|
+
/**
|
|
31
|
+
* Acquire a macOS power assertion. On non-macOS platforms returns a
|
|
32
|
+
* no-op handle so callers can stay cross-platform.
|
|
33
|
+
*/
|
|
34
|
+
static start(options?: MacOSPowerAssertionOptions | undefined | null): MacOSPowerAssertion
|
|
35
|
+
/**
|
|
36
|
+
* Release every assertion held by this handle. Safe to call multiple
|
|
37
|
+
* times; subsequent calls are a no-op.
|
|
38
|
+
*/
|
|
39
|
+
stop(): void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Stable process reference. */
|
|
43
|
+
export declare class Process {
|
|
44
|
+
/** Open a stable process reference from a PID. */
|
|
45
|
+
static fromPid(pid: number): Process | null
|
|
46
|
+
/** Open stable process references whose executable path matches exactly. */
|
|
47
|
+
static fromPath(path: string): Array<Process>
|
|
48
|
+
/** Operating-system process identifier for this process reference. */
|
|
49
|
+
get pid(): number
|
|
50
|
+
/** Parent process id for this process, when available. */
|
|
51
|
+
get ppid(): number | null
|
|
52
|
+
/** Launch arguments for this process. */
|
|
53
|
+
args(): Array<string>
|
|
54
|
+
/**
|
|
55
|
+
* Send `signal` to this process and its descendants, children first.
|
|
56
|
+
*
|
|
57
|
+
* On Linux and macOS the signal is forwarded as-is. On Windows there is no
|
|
58
|
+
* signal abstraction, so the `signal` argument is ignored and the entire
|
|
59
|
+
* tree is hard-killed via `TerminateProcess`. Defaults to the POSIX
|
|
60
|
+
* hard-kill signal.
|
|
61
|
+
*/
|
|
62
|
+
killTree(signal?: number | undefined | null): number
|
|
63
|
+
/**
|
|
64
|
+
* Gracefully terminate this process and its descendants.
|
|
65
|
+
*
|
|
66
|
+
* By default this waits 1000ms after polite termination before
|
|
67
|
+
* hard-killing. Pass `graceful_ms < 0` to skip the graceful phase.
|
|
68
|
+
*/
|
|
69
|
+
terminate(options?: ProcessTerminateOptions | undefined | null): Promise<boolean>
|
|
70
|
+
/**
|
|
71
|
+
* Wait until this process exits.
|
|
72
|
+
*
|
|
73
|
+
* When `options.timeout_ms` is omitted, waits until the process exits.
|
|
74
|
+
*/
|
|
75
|
+
waitForExit(options?: ProcessWaitOptions | undefined | null): Promise<boolean>
|
|
76
|
+
/** Process group id for this process, when supported by the platform. */
|
|
77
|
+
groupId(): number | null
|
|
78
|
+
/** Direct children of this process as stable process references. */
|
|
79
|
+
children(): Array<Process>
|
|
80
|
+
/** Current status of this process reference. */
|
|
81
|
+
status(): ProcessStatus
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Stateful PTY session for interactive stdin/stdout passthrough. */
|
|
85
|
+
export declare class PtySession {
|
|
86
|
+
constructor()
|
|
87
|
+
/** Start a PTY command and stream output chunks via callback. */
|
|
88
|
+
start(options: PtyStartOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<PtyRunResult>
|
|
89
|
+
/** Write raw input bytes to PTY stdin. */
|
|
90
|
+
write(data: string): void
|
|
91
|
+
/** Resize the active PTY. */
|
|
92
|
+
resize(cols: number, rows: number): void
|
|
93
|
+
/** Force-kill the active PTY command. */
|
|
94
|
+
kill(): void
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Persistent brush-core shell session. */
|
|
98
|
+
export declare class Shell {
|
|
99
|
+
/**
|
|
100
|
+
* Create a new shell session from optional configuration.
|
|
101
|
+
*
|
|
102
|
+
* The options set session-scoped environment variables and a snapshot path.
|
|
103
|
+
*/
|
|
104
|
+
constructor(options?: ShellOptions | undefined | null)
|
|
105
|
+
/**
|
|
106
|
+
* Run a shell command using the provided options.
|
|
107
|
+
*
|
|
108
|
+
* The `on_chunk` callback receives streamed stdout/stderr output. Returns
|
|
109
|
+
* the exit code when the command completes, or flags when cancelled or
|
|
110
|
+
* timed out.
|
|
111
|
+
*/
|
|
112
|
+
run(options: ShellRunOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellRunResult>
|
|
113
|
+
/**
|
|
114
|
+
* Abort all running commands for this shell session.
|
|
115
|
+
*
|
|
116
|
+
* Returns `Ok(())` even when no commands are running.
|
|
117
|
+
*/
|
|
118
|
+
abort(): Promise<void>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Version sentinel — exists solely so the JS loader can prove at load time
|
|
123
|
+
* that the `.node` file on disk is from the same package release as the
|
|
124
|
+
* `index.js` ESM wrapper invoking it.
|
|
125
|
+
*
|
|
126
|
+
* The `js_name` is bumped by `scripts/release.ts` to match the new
|
|
127
|
+
* `Cargo.toml` / `package.json` version on every release. The JS loader
|
|
128
|
+
* computes the expected name from `package.json#version` and refuses to use
|
|
129
|
+
* a `.node` that doesn't expose it, turning the silent
|
|
130
|
+
* `<sym> is not a function` crash from a locked-file update (the canonical
|
|
131
|
+
* Windows `bun install -g` failure mode) into a clear load-time error.
|
|
132
|
+
*
|
|
133
|
+
* Bump policy: `__prometheusNativesV{major}_{minor}_{patch}` —
|
|
134
|
+
* non-alphanumerics in the version string are mapped to `_` to keep it a valid
|
|
135
|
+
* JS identifier. MUST stay in sync with `VERSION_SENTINEL_EXPORT` in
|
|
136
|
+
* `packages/natives/native/index.js` (which derives the name from
|
|
137
|
+
* `package.json#version`).
|
|
138
|
+
*/
|
|
139
|
+
export declare function __prometheusNativesV0_5_0(): void
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Apply conservative pre-execution rewrites to a bash command.
|
|
143
|
+
*
|
|
144
|
+
* Strips trailing `| head|tail [safe-args]` and redundant trailing `2>&1`
|
|
145
|
+
* from each top-level pipeline. The full rules and bail conditions live in
|
|
146
|
+
* `prometheus_shell::fixup`. Synchronous and cheap (one parse pass over the
|
|
147
|
+
* input).
|
|
148
|
+
*/
|
|
149
|
+
export declare function applyBashFixups(command: string): BashFixupResult
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
|
|
153
|
+
* a promise.
|
|
154
|
+
*/
|
|
155
|
+
export declare function astEdit(options: AstReplaceOptions): Promise<AstReplaceResult>
|
|
156
|
+
|
|
157
|
+
/** One ast-grep match with source range and optional meta-variables. */
|
|
158
|
+
export interface AstFindMatch {
|
|
159
|
+
/** Display path of the matching file. */
|
|
160
|
+
path: string
|
|
161
|
+
/** Matched source text. */
|
|
162
|
+
text: string
|
|
163
|
+
/** Start byte offset in the file (UTF-8 byte index). */
|
|
164
|
+
byteStart: number
|
|
165
|
+
/** End byte offset in the file (exclusive UTF-8 byte index). */
|
|
166
|
+
byteEnd: number
|
|
167
|
+
/** 1-based start line. */
|
|
168
|
+
startLine: number
|
|
169
|
+
/** 1-based start column. */
|
|
170
|
+
startColumn: number
|
|
171
|
+
/** 1-based end line. */
|
|
172
|
+
endLine: number
|
|
173
|
+
/** 1-based end column. */
|
|
174
|
+
endColumn: number
|
|
175
|
+
/** Meta-variable name to captured text, when `includeMeta` was enabled. */
|
|
176
|
+
metaVariables?: Record<string, string>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Options for `astGrep`: patterns, scan scope, and match limits. */
|
|
180
|
+
export interface AstFindOptions {
|
|
181
|
+
/** ast-grep patterns to search for (OR across patterns). */
|
|
182
|
+
patterns?: Array<string>
|
|
183
|
+
/** Language override; otherwise inferred from file extension per candidate. */
|
|
184
|
+
lang?: string
|
|
185
|
+
/** Single file or directory to scan (combined with `glob` when set). */
|
|
186
|
+
path?: string
|
|
187
|
+
/** Optional glob filter relative to the search root. */
|
|
188
|
+
glob?: string
|
|
189
|
+
/** Rule selector for multi-rule ast-grep configurations. */
|
|
190
|
+
selector?: string
|
|
191
|
+
/** Pattern strictness; defaults to smart matching when omitted. */
|
|
192
|
+
strictness?: AstMatchStrictness
|
|
193
|
+
/** Maximum matches to return after `offset` (default applies when omitted). */
|
|
194
|
+
limit?: number
|
|
195
|
+
/** Number of leading matches to skip before applying `limit`. */
|
|
196
|
+
offset?: number
|
|
197
|
+
/** When true, include meta-variable bindings per match. */
|
|
198
|
+
includeMeta?: boolean
|
|
199
|
+
/**
|
|
200
|
+
* Reserved for contextual snippets; not used by the current native find
|
|
201
|
+
* path.
|
|
202
|
+
*/
|
|
203
|
+
context?: number
|
|
204
|
+
/** Optional cancellation handle (library-specific). */
|
|
205
|
+
signal?: unknown
|
|
206
|
+
/** Wall-clock timeout for the worker task in milliseconds. */
|
|
207
|
+
timeoutMs?: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Aggregated search statistics and any parse or compile diagnostics. */
|
|
211
|
+
export interface AstFindResult {
|
|
212
|
+
/** Page of matches after sort, offset, and limit. */
|
|
213
|
+
matches: Array<AstFindMatch>
|
|
214
|
+
/** Total matches found before paging (can exceed `matches.length`). */
|
|
215
|
+
totalMatches: number
|
|
216
|
+
/** Distinct files that contained at least one match. */
|
|
217
|
+
filesWithMatches: number
|
|
218
|
+
/** Files examined for the query. */
|
|
219
|
+
filesSearched: number
|
|
220
|
+
/** True when results were truncated by `limit`. */
|
|
221
|
+
limitReached: boolean
|
|
222
|
+
/** Non-fatal parse or pattern errors collected during the run. */
|
|
223
|
+
parseErrors?: Array<string>
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Search source files with ast-grep patterns; returns a promise resolved on a
|
|
228
|
+
* worker thread.
|
|
229
|
+
*/
|
|
230
|
+
export declare function astGrep(options: AstFindOptions): Promise<AstFindResult>
|
|
231
|
+
|
|
232
|
+
/** ast-grep pattern strictness (controls how patterns match syntax). */
|
|
233
|
+
export declare enum AstMatchStrictness {
|
|
234
|
+
/** Match at the concrete syntax tree level. */
|
|
235
|
+
Cst = 'cst',
|
|
236
|
+
/** Balanced default suitable for most searches. */
|
|
237
|
+
Smart = 'smart',
|
|
238
|
+
/** Match at the AST level. */
|
|
239
|
+
Ast = 'ast',
|
|
240
|
+
/** More permissive matching. */
|
|
241
|
+
Relaxed = 'relaxed',
|
|
242
|
+
/** Match structural signatures. */
|
|
243
|
+
Signature = 'signature',
|
|
244
|
+
/** Template-style pattern matching. */
|
|
245
|
+
Template = 'template'
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* One textual replacement applied to a file (before/after slice and
|
|
250
|
+
* coordinates).
|
|
251
|
+
*/
|
|
252
|
+
export interface AstReplaceChange {
|
|
253
|
+
/** File path for this change. */
|
|
254
|
+
path: string
|
|
255
|
+
/** Original matched text. */
|
|
256
|
+
before: string
|
|
257
|
+
/** Replacement text. */
|
|
258
|
+
after: string
|
|
259
|
+
/** Start byte offset of the replaced span. */
|
|
260
|
+
byteStart: number
|
|
261
|
+
/** End byte offset of the replaced span (exclusive). */
|
|
262
|
+
byteEnd: number
|
|
263
|
+
/**
|
|
264
|
+
* Length of deleted text in bytes (may differ from `byteEnd - byteStart`
|
|
265
|
+
* for edge cases).
|
|
266
|
+
*/
|
|
267
|
+
deletedLength: number
|
|
268
|
+
/** 1-based start line of the match. */
|
|
269
|
+
startLine: number
|
|
270
|
+
/** 1-based start column. */
|
|
271
|
+
startColumn: number
|
|
272
|
+
/** 1-based end line. */
|
|
273
|
+
endLine: number
|
|
274
|
+
/** 1-based end column. */
|
|
275
|
+
endColumn: number
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Per-file replacement count after an `astEdit` run. */
|
|
279
|
+
export interface AstReplaceFileChange {
|
|
280
|
+
/** File that had replacements. */
|
|
281
|
+
path: string
|
|
282
|
+
/** Number of replacements in that file. */
|
|
283
|
+
count: number
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Options for `astEdit`: rewrite rules, scan scope, safety limits, and
|
|
288
|
+
* dry-run.
|
|
289
|
+
*/
|
|
290
|
+
export interface AstReplaceOptions {
|
|
291
|
+
/** Map of pattern string to replacement template. */
|
|
292
|
+
rewrites?: Record<string, string>
|
|
293
|
+
/** Language override; otherwise inferred from discovered files. */
|
|
294
|
+
lang?: string
|
|
295
|
+
/** Single file or directory to rewrite. */
|
|
296
|
+
path?: string
|
|
297
|
+
/** Optional glob filter within the search root. */
|
|
298
|
+
glob?: string
|
|
299
|
+
/** Rule selector for multi-rule configurations. */
|
|
300
|
+
selector?: string
|
|
301
|
+
/** Pattern strictness for rewrites. */
|
|
302
|
+
strictness?: AstMatchStrictness
|
|
303
|
+
/** When true (default), compute changes without writing files. */
|
|
304
|
+
dryRun?: boolean
|
|
305
|
+
/** Cap on replacement applications across all files. */
|
|
306
|
+
maxReplacements?: number
|
|
307
|
+
/** Cap on distinct files that may be modified. */
|
|
308
|
+
maxFiles?: number
|
|
309
|
+
/** Fail the operation when a file cannot be parsed for rewriting. */
|
|
310
|
+
failOnParseError?: boolean
|
|
311
|
+
/** Optional cancellation handle. */
|
|
312
|
+
signal?: unknown
|
|
313
|
+
/** Wall-clock timeout for the worker task in milliseconds. */
|
|
314
|
+
timeoutMs?: number
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Summary of an ast-grep rewrite pass, including whether disk writes occurred. */
|
|
318
|
+
export interface AstReplaceResult {
|
|
319
|
+
/** Individual replacement records (may be large). */
|
|
320
|
+
changes: Array<AstReplaceChange>
|
|
321
|
+
/** Replacement counts grouped by file. */
|
|
322
|
+
fileChanges: Array<AstReplaceFileChange>
|
|
323
|
+
/** Total replacements applied or previewed. */
|
|
324
|
+
totalReplacements: number
|
|
325
|
+
/** Files that had at least one replacement. */
|
|
326
|
+
filesTouched: number
|
|
327
|
+
/** Files considered for rewriting. */
|
|
328
|
+
filesSearched: number
|
|
329
|
+
/** False when `dryRun` prevented writing. */
|
|
330
|
+
applied: boolean
|
|
331
|
+
/** True when limits stopped further replacements. */
|
|
332
|
+
limitReached: boolean
|
|
333
|
+
/** Parse or pattern errors when not failing the whole operation. */
|
|
334
|
+
parseErrors?: Array<string>
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Result of [`apply_bash_fixups`]: a possibly-rewritten command plus the
|
|
339
|
+
* substrings that were removed (in source order).
|
|
340
|
+
*/
|
|
341
|
+
export interface BashFixupResult {
|
|
342
|
+
/** Possibly-rewritten command. Equal to the input when no fixup fired. */
|
|
343
|
+
command: string
|
|
344
|
+
/** Substrings removed, in source order — suitable for a user-facing notice. */
|
|
345
|
+
stripped: Array<string>
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface BlockRange {
|
|
349
|
+
/** 1-indexed inclusive first line of the resolved block. */
|
|
350
|
+
startLine: number
|
|
351
|
+
/** 1-indexed inclusive last line of the resolved block. */
|
|
352
|
+
endLine: number
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Find the outermost named tree-sitter node that begins on `options.line`.
|
|
357
|
+
*
|
|
358
|
+
* Returns its 1-indexed inclusive line span, or `null` when the language is
|
|
359
|
+
* unrecognized, the line is out of range / blank, no node begins on that line,
|
|
360
|
+
* or the resolved subtree contains a syntax error.
|
|
361
|
+
*/
|
|
362
|
+
export declare function blockRangeAt(options: BlockRangeOptions): BlockRange | null
|
|
363
|
+
|
|
364
|
+
export interface BlockRangeOptions {
|
|
365
|
+
/** Source code to inspect. */
|
|
366
|
+
code: string
|
|
367
|
+
/** Language alias (e.g. "rust", "typescript") used before path inference. */
|
|
368
|
+
lang?: string
|
|
369
|
+
/** File path used to infer language by extension when `lang` is omitted. */
|
|
370
|
+
path?: string
|
|
371
|
+
/** 1-indexed source line the block must begin on. */
|
|
372
|
+
line: number
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Clipboard image payload encoded as PNG bytes. */
|
|
376
|
+
export interface ClipboardImage {
|
|
377
|
+
/** PNG-encoded image bytes. */
|
|
378
|
+
data: Uint8Array
|
|
379
|
+
/** MIME type for the encoded image payload. */
|
|
380
|
+
mimeType: string
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** A context line (before or after a match). */
|
|
384
|
+
export interface ContextLine {
|
|
385
|
+
/** 1-indexed line number in the source file. */
|
|
386
|
+
lineNumber: number
|
|
387
|
+
/** Raw line content (trimmed line ending). */
|
|
388
|
+
line: string
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Copy plain text to the system clipboard.
|
|
393
|
+
*
|
|
394
|
+
* # Parameters
|
|
395
|
+
* - `text`: UTF-8 text to place on the clipboard.
|
|
396
|
+
*
|
|
397
|
+
* # Errors
|
|
398
|
+
* Returns an error if clipboard access fails.
|
|
399
|
+
*/
|
|
400
|
+
export declare function copyToClipboard(text: string): void
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Count tokens in `input`.
|
|
404
|
+
*
|
|
405
|
+
* `input` may be a single string or an array of strings; an array returns
|
|
406
|
+
* the sum across all elements (encoded in parallel via rayon). Always
|
|
407
|
+
* returns a single token total — use this for any aggregate budget question
|
|
408
|
+
* without paying a per-element napi crossing.
|
|
409
|
+
*
|
|
410
|
+
* Uses ordinary encoding (no special-token handling), which is the right
|
|
411
|
+
* choice for measuring user/model content rather than wire-protocol tokens.
|
|
412
|
+
* Defaults to `o200k_base`; pass `Cl100kBase` for older `OpenAI` models.
|
|
413
|
+
*/
|
|
414
|
+
export declare function countTokens(input: string | Array<string>, encoding?: Encoding | undefined | null): number
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Detect macOS system appearance via CoreFoundation.
|
|
418
|
+
* Returns `"dark"` or `"light"` on macOS, `null` on other platforms.
|
|
419
|
+
*/
|
|
420
|
+
export declare function detectMacOSAppearance(): MacOSAppearance | null
|
|
421
|
+
|
|
422
|
+
/** Ellipsis strategy for [`truncate_to_width`]. */
|
|
423
|
+
export declare enum Ellipsis {
|
|
424
|
+
/** Use a single Unicode ellipsis character ("…"). */
|
|
425
|
+
Unicode = 0,
|
|
426
|
+
/** Use three ASCII dots ("..."). */
|
|
427
|
+
Ascii = 1,
|
|
428
|
+
/** Omit ellipsis entirely. */
|
|
429
|
+
Omit = 2
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Encode image bytes into a SIXEL escape sequence for terminal rendering.
|
|
434
|
+
*
|
|
435
|
+
* The input image is decoded and resized to the requested pixel dimensions
|
|
436
|
+
* before encoding.
|
|
437
|
+
*
|
|
438
|
+
* # Errors
|
|
439
|
+
* Returns an error if decoding, resizing, or SIXEL encoding fails.
|
|
440
|
+
*/
|
|
441
|
+
export declare function encodeSixel(bytes: Uint8Array, targetWidthPx: number, targetHeightPx: number): string
|
|
442
|
+
|
|
443
|
+
/** Tokenizer encoding to use. */
|
|
444
|
+
export declare enum Encoding {
|
|
445
|
+
/** GPT-4o / o1 / GPT-5 (default). */
|
|
446
|
+
O200kBase = 'O200kBase',
|
|
447
|
+
/** GPT-3.5 / GPT-4 / older. */
|
|
448
|
+
Cl100kBase = 'Cl100kBase'
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Execute a brush shell command.
|
|
453
|
+
*
|
|
454
|
+
* Creates a fresh session for each call. The `on_chunk` callback receives
|
|
455
|
+
* streamed stdout/stderr output. Returns the exit code when the command
|
|
456
|
+
* completes, or flags when cancelled or timed out.
|
|
457
|
+
*/
|
|
458
|
+
export declare function executeShell(options: ShellExecuteOptions, onChunk?: ((error: Error | null, chunk: string) => void) | undefined | null): Promise<ShellRunResult>
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Extract the before/after slices around an overlay region.
|
|
462
|
+
*
|
|
463
|
+
* Preserves ANSI state so the `after` segment renders correctly after
|
|
464
|
+
* truncation.
|
|
465
|
+
*/
|
|
466
|
+
export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean, tabWidth: number): ExtractSegmentsResult
|
|
467
|
+
|
|
468
|
+
/** Before/after UTF-16 segments around an overlay region, with measured widths. */
|
|
469
|
+
export interface ExtractSegmentsResult {
|
|
470
|
+
/** UTF-16 content before the overlay region. */
|
|
471
|
+
before: string
|
|
472
|
+
/** Visible width of the `before` segment. */
|
|
473
|
+
beforeWidth: number
|
|
474
|
+
/** UTF-16 content after the overlay region. */
|
|
475
|
+
after: string
|
|
476
|
+
/** Visible width of the `after` segment. */
|
|
477
|
+
afterWidth: number
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** Resolved filesystem entry kind for glob filters and match metadata. */
|
|
481
|
+
export declare enum FileType {
|
|
482
|
+
/** Regular file. */
|
|
483
|
+
File = 1,
|
|
484
|
+
/** Directory. */
|
|
485
|
+
Dir = 2,
|
|
486
|
+
/** Symbolic link. */
|
|
487
|
+
Symlink = 3
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** Fuzzy file path search for autocomplete. */
|
|
491
|
+
export declare function fuzzyFind(options: FuzzyFindOptions): Promise<FuzzyFindResult>
|
|
492
|
+
|
|
493
|
+
/** A single match in fuzzy find results. */
|
|
494
|
+
export interface FuzzyFindMatch {
|
|
495
|
+
/** Relative path from the search root (uses `/` separators). */
|
|
496
|
+
path: string
|
|
497
|
+
/** Whether this entry is a directory. */
|
|
498
|
+
isDirectory: boolean
|
|
499
|
+
/** Match quality score (higher is better). */
|
|
500
|
+
score: number
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Options for fuzzy file path search. */
|
|
504
|
+
export interface FuzzyFindOptions {
|
|
505
|
+
/** Fuzzy query to match against file paths (case-insensitive). */
|
|
506
|
+
query: string
|
|
507
|
+
/** Directory to search. */
|
|
508
|
+
path: string
|
|
509
|
+
/** Include hidden files (default: false). */
|
|
510
|
+
hidden?: boolean
|
|
511
|
+
/** Respect .gitignore (default: true). */
|
|
512
|
+
gitignore?: boolean
|
|
513
|
+
/** Enable shared filesystem scan cache (default: false). */
|
|
514
|
+
cache?: boolean
|
|
515
|
+
/** Maximum number of matches to return (default: 100). */
|
|
516
|
+
maxResults?: number
|
|
517
|
+
/** Abort signal for cancelling the operation. */
|
|
518
|
+
signal?: unknown
|
|
519
|
+
/** Timeout in milliseconds for the operation. */
|
|
520
|
+
timeoutMs?: number
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** Result of fuzzy file path search. */
|
|
524
|
+
export interface FuzzyFindResult {
|
|
525
|
+
/** Matched entries (up to `maxResults`). */
|
|
526
|
+
matches: Array<FuzzyFindMatch>
|
|
527
|
+
/** Total number of matches found (may exceed `matches.len()`). */
|
|
528
|
+
totalMatches: number
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Get list of supported languages. */
|
|
532
|
+
export declare function getSupportedLanguages(): Array<string>
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Get work profile data from the last N seconds.
|
|
536
|
+
*
|
|
537
|
+
* Always-on profiling - no need to start/stop. Just call this to get
|
|
538
|
+
* recent activity.
|
|
539
|
+
*/
|
|
540
|
+
export declare function getWorkProfile(lastSeconds: number): WorkProfile
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Find filesystem entries matching a glob pattern.
|
|
544
|
+
*
|
|
545
|
+
* Resolves the search root, scans entries, applies glob and optional file-type
|
|
546
|
+
* filters, and optionally streams each accepted match through `on_match`.
|
|
547
|
+
*
|
|
548
|
+
* If `sortByMtime` is enabled with a finite `maxResults`, uncached scans keep
|
|
549
|
+
* only the current top results while traversing instead of collecting the full
|
|
550
|
+
* tree.
|
|
551
|
+
*
|
|
552
|
+
* # Errors
|
|
553
|
+
* Returns an error when the search path cannot be resolved, the path is not a
|
|
554
|
+
* directory, the glob pattern is invalid, or cancellation/timeout is
|
|
555
|
+
* triggered.
|
|
556
|
+
*/
|
|
557
|
+
export declare function glob(options: GlobOptions, onMatch?: ((error: Error | null, match: GlobMatch) => void) | undefined | null): Promise<GlobResult>
|
|
558
|
+
|
|
559
|
+
/** A single filesystem entry from a directory scan. */
|
|
560
|
+
export interface GlobMatch {
|
|
561
|
+
/** Relative path from the search root, using forward slashes. */
|
|
562
|
+
path: string
|
|
563
|
+
/** Resolved filesystem type for the match. */
|
|
564
|
+
fileType: FileType
|
|
565
|
+
/**
|
|
566
|
+
* Modification time in milliseconds since Unix epoch (from
|
|
567
|
+
* `symlink_metadata`).
|
|
568
|
+
*/
|
|
569
|
+
mtime?: number
|
|
570
|
+
/** File size in bytes for regular files. */
|
|
571
|
+
size?: number
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/** Input options for `glob`, including traversal, filtering, and cancellation. */
|
|
575
|
+
export interface GlobOptions {
|
|
576
|
+
/** Glob pattern to match (e.g., "*.ts"). */
|
|
577
|
+
pattern: string
|
|
578
|
+
/** Directory to search. */
|
|
579
|
+
path: string
|
|
580
|
+
/**
|
|
581
|
+
* Filter by file type: "file", "dir", or "symlink". Symlinks are
|
|
582
|
+
* matched for file/dir filters based on their target type.
|
|
583
|
+
*/
|
|
584
|
+
fileType?: FileType
|
|
585
|
+
/** Match simple patterns recursively by default (`*.ts` -> recursive). */
|
|
586
|
+
recursive?: boolean
|
|
587
|
+
/** Include hidden files (default: false). */
|
|
588
|
+
hidden?: boolean
|
|
589
|
+
/** Maximum number of results to return. */
|
|
590
|
+
maxResults?: number
|
|
591
|
+
/** Respect .gitignore files (default: true). */
|
|
592
|
+
gitignore?: boolean
|
|
593
|
+
/** Enable shared filesystem scan cache (default: false). */
|
|
594
|
+
cache?: boolean
|
|
595
|
+
/** Sort results by mtime (most recent first) before applying limit. */
|
|
596
|
+
sortByMtime?: boolean
|
|
597
|
+
/**
|
|
598
|
+
* Include `node_modules` entries when the pattern does not explicitly
|
|
599
|
+
* mention them.
|
|
600
|
+
*/
|
|
601
|
+
includeNodeModules?: boolean
|
|
602
|
+
/** Abort signal for cancelling the operation. */
|
|
603
|
+
signal?: unknown
|
|
604
|
+
/** Timeout in milliseconds for the operation. */
|
|
605
|
+
timeoutMs?: number
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** Result payload returned by a glob operation. */
|
|
609
|
+
export interface GlobResult {
|
|
610
|
+
/** Matched filesystem entries. */
|
|
611
|
+
matches: Array<GlobMatch>
|
|
612
|
+
/** Number of returned matches (`matches.len()`), clamped to `u32::MAX`. */
|
|
613
|
+
totalMatches: number
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Search files for a regex pattern.
|
|
618
|
+
*
|
|
619
|
+
* # Arguments
|
|
620
|
+
* - `options`: Pattern, path, filters, and output mode.
|
|
621
|
+
* - `on_match`: Optional callback invoked per match/result.
|
|
622
|
+
*
|
|
623
|
+
* # Returns
|
|
624
|
+
* Aggregated results across matching files.
|
|
625
|
+
*/
|
|
626
|
+
export declare function grep(options: GrepOptions, onMatch?: ((error: Error | null, match: GrepMatch) => void) | undefined | null): Promise<GrepResult>
|
|
627
|
+
|
|
628
|
+
/** A single match in a grep result. */
|
|
629
|
+
export interface GrepMatch {
|
|
630
|
+
/** File path for the match (relative for directory searches). */
|
|
631
|
+
path: string
|
|
632
|
+
/** 1-indexed line number (0 for count-only entries). */
|
|
633
|
+
lineNumber: number
|
|
634
|
+
/** The matched line content (empty for count-only entries). */
|
|
635
|
+
line: string
|
|
636
|
+
/** Context lines before the match. */
|
|
637
|
+
contextBefore?: Array<ContextLine>
|
|
638
|
+
/** Context lines after the match. */
|
|
639
|
+
contextAfter?: Array<ContextLine>
|
|
640
|
+
/** Whether the line was truncated. */
|
|
641
|
+
truncated?: boolean
|
|
642
|
+
/** Per-file match count (count mode only). */
|
|
643
|
+
matchCount?: number
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/** Options for searching files on disk. */
|
|
647
|
+
export interface GrepOptions {
|
|
648
|
+
/** Regex pattern to search for. */
|
|
649
|
+
pattern: string
|
|
650
|
+
/** Directory or file to search. */
|
|
651
|
+
path: string
|
|
652
|
+
/** Glob filter for filenames (e.g., "*.ts"). */
|
|
653
|
+
glob?: string
|
|
654
|
+
/** Filter by file type (e.g., "js", "py", "rust"). */
|
|
655
|
+
type?: string
|
|
656
|
+
/** Case-insensitive search. */
|
|
657
|
+
ignoreCase?: boolean
|
|
658
|
+
/** Enable multiline matching. */
|
|
659
|
+
multiline?: boolean
|
|
660
|
+
/** Include hidden files (default: true). */
|
|
661
|
+
hidden?: boolean
|
|
662
|
+
/** Respect .gitignore files (default: true). */
|
|
663
|
+
gitignore?: boolean
|
|
664
|
+
/** Enable shared filesystem scan cache (default: false). */
|
|
665
|
+
cache?: boolean
|
|
666
|
+
/** Maximum number of matches to return. */
|
|
667
|
+
maxCount?: number
|
|
668
|
+
/** Skip first N matches. */
|
|
669
|
+
offset?: number
|
|
670
|
+
/** Lines of context before matches. */
|
|
671
|
+
contextBefore?: number
|
|
672
|
+
/** Lines of context after matches. */
|
|
673
|
+
contextAfter?: number
|
|
674
|
+
/** Lines of context before/after matches (legacy). */
|
|
675
|
+
context?: number
|
|
676
|
+
/** Truncate lines longer than this (characters). */
|
|
677
|
+
maxColumns?: number
|
|
678
|
+
/** Output mode (content, filesWithMatches, or count). */
|
|
679
|
+
mode?: GrepOutputMode
|
|
680
|
+
/** Abort signal for cancelling the operation. */
|
|
681
|
+
signal?: unknown
|
|
682
|
+
/** Timeout in milliseconds for the operation. */
|
|
683
|
+
timeoutMs?: number
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/** Output mode for [`search`] and [`grep`] (string values match JS callers). */
|
|
687
|
+
export declare enum GrepOutputMode {
|
|
688
|
+
/** Emit matched lines (and optional context lines). */
|
|
689
|
+
Content = 'content',
|
|
690
|
+
/** Emit per-file or total counts instead of line content. */
|
|
691
|
+
Count = 'count',
|
|
692
|
+
/** Emit one row per file that matched, without line content. */
|
|
693
|
+
FilesWithMatches = 'filesWithMatches'
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** Result of searching files. */
|
|
697
|
+
export interface GrepResult {
|
|
698
|
+
/** Matches or per-file counts, depending on output mode. */
|
|
699
|
+
matches: Array<GrepMatch>
|
|
700
|
+
/**
|
|
701
|
+
* Total matches across all files, or matched file count in filesWithMatches
|
|
702
|
+
* mode.
|
|
703
|
+
*/
|
|
704
|
+
totalMatches: number
|
|
705
|
+
/** Number of files with at least one match. */
|
|
706
|
+
filesWithMatches: number
|
|
707
|
+
/** Number of files searched. */
|
|
708
|
+
filesSearched: number
|
|
709
|
+
/** Whether the limit/offset stopped the search early. */
|
|
710
|
+
limitReached?: boolean
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Quick check if content matches a pattern.
|
|
715
|
+
*
|
|
716
|
+
* # Arguments
|
|
717
|
+
* - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
|
|
718
|
+
* - `pattern`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
|
|
719
|
+
* - `ignore_case`: Case-insensitive matching.
|
|
720
|
+
* - `multiline`: Enable multiline regex mode.
|
|
721
|
+
*
|
|
722
|
+
* # Returns
|
|
723
|
+
* True if any match exists; false on no match.
|
|
724
|
+
*/
|
|
725
|
+
export declare function hasMatch(content: string | Uint8Array, pattern: string | Uint8Array, ignoreCase?: boolean | undefined | null, multiline?: boolean | undefined | null): boolean
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Highlight code and return ANSI-colored lines.
|
|
729
|
+
*
|
|
730
|
+
* # Arguments
|
|
731
|
+
* * `code` - The source code to highlight
|
|
732
|
+
* * `lang` - Language identifier (e.g., "rust", "typescript", "python")
|
|
733
|
+
* * `colors` - Theme colors as ANSI escape sequences
|
|
734
|
+
*
|
|
735
|
+
* # Returns
|
|
736
|
+
* Highlighted code with ANSI color codes, or the original code if highlighting
|
|
737
|
+
* fails.
|
|
738
|
+
*/
|
|
739
|
+
export declare function highlightCode(code: string, lang: string | undefined | null, colors: HighlightColors): string
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Theme colors for syntax highlighting.
|
|
743
|
+
* Each color is an ANSI escape sequence (e.g., "\x1b[38;2;255;0;0m").
|
|
744
|
+
*/
|
|
745
|
+
export interface HighlightColors {
|
|
746
|
+
/** ANSI color for comments. */
|
|
747
|
+
comment: string
|
|
748
|
+
/** ANSI color for keywords. */
|
|
749
|
+
keyword: string
|
|
750
|
+
/** ANSI color for function names. */
|
|
751
|
+
function: string
|
|
752
|
+
/** ANSI color for variables and identifiers. */
|
|
753
|
+
variable: string
|
|
754
|
+
/** ANSI color for string literals. */
|
|
755
|
+
string: string
|
|
756
|
+
/** ANSI color for numeric literals. */
|
|
757
|
+
number: string
|
|
758
|
+
/** ANSI color for type identifiers. */
|
|
759
|
+
type: string
|
|
760
|
+
/** ANSI color for operators. */
|
|
761
|
+
operator: string
|
|
762
|
+
/** ANSI color for punctuation tokens. */
|
|
763
|
+
punctuation: string
|
|
764
|
+
/** ANSI color for diff inserted lines. */
|
|
765
|
+
inserted?: string
|
|
766
|
+
/** ANSI color for diff deleted lines. */
|
|
767
|
+
deleted?: string
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Convert HTML source to Markdown with optional preprocessing.
|
|
772
|
+
*
|
|
773
|
+
* # Errors
|
|
774
|
+
* Returns an error if the conversion fails or the worker task aborts.
|
|
775
|
+
*/
|
|
776
|
+
export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions | undefined | null): Promise<string>
|
|
777
|
+
|
|
778
|
+
/** Options for HTML to Markdown conversion. */
|
|
779
|
+
export interface HtmlToMarkdownOptions {
|
|
780
|
+
/** Remove navigation elements, forms, headers, footers. */
|
|
781
|
+
cleanContent?: boolean
|
|
782
|
+
/** Skip images during conversion. */
|
|
783
|
+
skipImages?: boolean
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Invalidate the filesystem scan cache.
|
|
788
|
+
*
|
|
789
|
+
* When called with a path, removes entries for roots containing that path.
|
|
790
|
+
* When called without a path, clears the entire cache.
|
|
791
|
+
*
|
|
792
|
+
* Intended to be called after agent file mutations (write, edit, rename,
|
|
793
|
+
* delete).
|
|
794
|
+
*/
|
|
795
|
+
export declare function invalidateFsScanCache(path?: string | undefined | null): void
|
|
796
|
+
|
|
797
|
+
/** Kind enum of the backend selected by default for this build target. */
|
|
798
|
+
export declare function isoBackend(): IsoBackendKind
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Isolation backend identifier. Numeric so the JS side can `switch` on
|
|
802
|
+
* the enum without string comparisons.
|
|
803
|
+
*/
|
|
804
|
+
export declare enum IsoBackendKind {
|
|
805
|
+
Apfs = 0,
|
|
806
|
+
Btrfs = 1,
|
|
807
|
+
Zfs = 2,
|
|
808
|
+
LinuxReflink = 3,
|
|
809
|
+
Overlayfs = 4,
|
|
810
|
+
WindowsBlockClone = 5,
|
|
811
|
+
Projfs = 6,
|
|
812
|
+
Rcopy = 7
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/** How a single file changed between `lower` and `merged`. */
|
|
816
|
+
export declare enum IsoChangeKind {
|
|
817
|
+
Added = 0,
|
|
818
|
+
Modified = 1,
|
|
819
|
+
Removed = 2
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Capture the changes between `lower` and `merged`.
|
|
824
|
+
*
|
|
825
|
+
* Uses [`prometheus_iso::IsolationBackend::diff`]'s default implementation —
|
|
826
|
+
* `git diff` when `merged/.git` exists, otherwise a mtime-skipped tree
|
|
827
|
+
* walk. The backend selection only affects the lifecycle methods; diff
|
|
828
|
+
* behaviour is uniform.
|
|
829
|
+
*/
|
|
830
|
+
export declare function isoDiff(lower: string, merged: string): Promise<IsoDiff>
|
|
831
|
+
|
|
832
|
+
export interface IsoDiff {
|
|
833
|
+
files: Array<IsoFileChange>
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** One entry in an [`IsoDiff`]. */
|
|
837
|
+
export interface IsoFileChange {
|
|
838
|
+
/** Path relative to `merged`. */
|
|
839
|
+
path: string
|
|
840
|
+
op: IsoChangeKind
|
|
841
|
+
/**
|
|
842
|
+
* Unified-diff text. `None` (`null` in JS) means the file is binary;
|
|
843
|
+
* read it directly from `merged` if you need the bytes.
|
|
844
|
+
*/
|
|
845
|
+
diff?: string
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* True if `message` is an error message produced by [`IsoError::Unavailable`].
|
|
850
|
+
* Use this to distinguish "this backend isn't installed" from a hard
|
|
851
|
+
* failure when handling caught errors on the JS side.
|
|
852
|
+
*/
|
|
853
|
+
export declare function isoIsUnavailableError(message: string): boolean
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Probe whether the requested backend can start on this host. Pass
|
|
857
|
+
* `null`/omit `kind` to probe the platform-native backend.
|
|
858
|
+
*/
|
|
859
|
+
export declare function isoProbe(kind?: IsoBackendKind | undefined | null): IsoProbeResult
|
|
860
|
+
|
|
861
|
+
/** Probe result for a specific isolation backend. */
|
|
862
|
+
export interface IsoProbeResult {
|
|
863
|
+
/** True when the backend's prerequisites are satisfied. */
|
|
864
|
+
available: boolean
|
|
865
|
+
/** Human-readable explanation when `available` is false. */
|
|
866
|
+
reason?: string
|
|
867
|
+
/** Resolved backend kind. */
|
|
868
|
+
kind: IsoBackendKind
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Pick the best backend available right now. `preferred` is treated as
|
|
873
|
+
* a hint — see [`prometheus_iso::resolve`] for the exact priority rules.
|
|
874
|
+
*/
|
|
875
|
+
export declare function isoResolve(preferred?: IsoBackendKind | undefined | null): IsoResolveResult
|
|
876
|
+
|
|
877
|
+
/** Outcome of [`iso_resolve`]. */
|
|
878
|
+
export interface IsoResolveResult {
|
|
879
|
+
/** Backend that will actually be tried first. */
|
|
880
|
+
kind: IsoBackendKind
|
|
881
|
+
/** Host-available backends in retry order, starting with `kind`. */
|
|
882
|
+
candidates: Array<IsoBackendKind>
|
|
883
|
+
/**
|
|
884
|
+
* True when the resolver fell back from `preferred` (or from the
|
|
885
|
+
* first automatic candidate) to a different backend.
|
|
886
|
+
*/
|
|
887
|
+
fellBack: boolean
|
|
888
|
+
/** Human-readable reason for the fallback, if any. */
|
|
889
|
+
reason?: string
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Materialise `merged` as a writable view of `lower` using the requested
|
|
894
|
+
* backend. `kind` defaults to the native backend.
|
|
895
|
+
*/
|
|
896
|
+
export declare function isoStart(kind: IsoBackendKind | undefined | null, lower: string, merged: string): Promise<void>
|
|
897
|
+
|
|
898
|
+
/** Tear down a previously started backend at `merged`. */
|
|
899
|
+
export declare function isoStop(kind: IsoBackendKind | undefined | null, merged: string): Promise<void>
|
|
900
|
+
|
|
901
|
+
/** Event types from Kitty keyboard protocol (flag 2). */
|
|
902
|
+
export declare enum KeyEventType {
|
|
903
|
+
/** Key press event. */
|
|
904
|
+
Press = 1,
|
|
905
|
+
/** Key repeat event. */
|
|
906
|
+
Repeat = 2,
|
|
907
|
+
/** Key release event. */
|
|
908
|
+
Release = 3
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Walk the workspace once and return tree entries plus AGENTS.md candidates.
|
|
913
|
+
*
|
|
914
|
+
* File-level ignore rules for AGENTS.md are bypassed by checking each
|
|
915
|
+
* traversed directory directly when `collectAgentsMd` is enabled, but ignored
|
|
916
|
+
* directories are still pruned by the walker and are not searched.
|
|
917
|
+
*/
|
|
918
|
+
export declare function listWorkspace(options: ListWorkspaceOptions): Promise<ListWorkspaceResult>
|
|
919
|
+
|
|
920
|
+
/** Input options for `listWorkspace`, the single-pass workspace startup scan. */
|
|
921
|
+
export interface ListWorkspaceOptions {
|
|
922
|
+
/** Directory to scan. */
|
|
923
|
+
path: string
|
|
924
|
+
/** Maximum depth for returned tree entries. Root children are depth 1. */
|
|
925
|
+
maxDepth: number
|
|
926
|
+
/** Include hidden files and directories. Default: false. */
|
|
927
|
+
hidden?: boolean
|
|
928
|
+
/** Respect .gitignore files. Default: true. */
|
|
929
|
+
gitignore?: boolean
|
|
930
|
+
/**
|
|
931
|
+
* Also surface AGENTS.md files in directories at depth 1..=4, even when
|
|
932
|
+
* gitignore would otherwise hide the file. Walks deeper than `maxDepth`
|
|
933
|
+
* to find them. Default: false.
|
|
934
|
+
*/
|
|
935
|
+
collectAgentsMd?: boolean
|
|
936
|
+
/** Timeout in milliseconds for the operation. */
|
|
937
|
+
timeoutMs?: number
|
|
938
|
+
/** Abort signal for cancelling the operation. */
|
|
939
|
+
signal?: unknown
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** Result payload returned by a workspace scan. */
|
|
943
|
+
export interface ListWorkspaceResult {
|
|
944
|
+
/** Entries within `maxDepth`, with mtime and regular-file size metadata. */
|
|
945
|
+
entries: Array<GlobMatch>
|
|
946
|
+
/**
|
|
947
|
+
* Directory-scoped AGENTS.md files within depth 1..=4 (capped at 200).
|
|
948
|
+
* Always empty when `collectAgentsMd` is false.
|
|
949
|
+
*/
|
|
950
|
+
agentsMdFiles: Array<string>
|
|
951
|
+
/** True when any output cap was hit. */
|
|
952
|
+
truncated: boolean
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* System UI appearance reported by native macOS APIs (`detectMacOSAppearance`
|
|
957
|
+
* and observer).
|
|
958
|
+
*/
|
|
959
|
+
export declare enum MacOSAppearance {
|
|
960
|
+
/** Dark color scheme. */
|
|
961
|
+
Dark = 'dark',
|
|
962
|
+
/** Light color scheme. */
|
|
963
|
+
Light = 'light'
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Options for starting a macOS power assertion.
|
|
968
|
+
*
|
|
969
|
+
* Each boolean maps to a `caffeinate(8)` flag and a corresponding `IOKit`
|
|
970
|
+
* `IOPMAssertion` type. Multiple flags can be combined; when set, one
|
|
971
|
+
* assertion is taken per flag and all are released together when the
|
|
972
|
+
* handle is stopped or dropped.
|
|
973
|
+
*
|
|
974
|
+
* If every flag is unset (or omitted), the handle behaves as if `idle`
|
|
975
|
+
* were `true` — preserving the historical default of `caffeinate -i`.
|
|
976
|
+
*/
|
|
977
|
+
export interface MacOSPowerAssertionOptions {
|
|
978
|
+
/** Human-readable reason shown in macOS power diagnostics. */
|
|
979
|
+
reason?: string
|
|
980
|
+
/** `caffeinate -i`: prevent the system from idle-sleeping. */
|
|
981
|
+
idle?: boolean
|
|
982
|
+
/** `caffeinate -s`: prevent the system from sleeping (AC power only). */
|
|
983
|
+
system?: boolean
|
|
984
|
+
/** `caffeinate -u`: declare the user is active (wakes the display). */
|
|
985
|
+
user?: boolean
|
|
986
|
+
/** `caffeinate -d`: prevent the display from idle-sleeping. */
|
|
987
|
+
display?: boolean
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/** A single match in the content. */
|
|
991
|
+
export interface Match {
|
|
992
|
+
/** 1-indexed line number. */
|
|
993
|
+
lineNumber: number
|
|
994
|
+
/** The matched line content. */
|
|
995
|
+
line: string
|
|
996
|
+
/** Context lines before the match. */
|
|
997
|
+
contextBefore?: Array<ContextLine>
|
|
998
|
+
/** Context lines after the match. */
|
|
999
|
+
contextAfter?: Array<ContextLine>
|
|
1000
|
+
/** Whether the line was truncated. */
|
|
1001
|
+
truncated?: boolean
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Match input data against a key identifier string.
|
|
1006
|
+
*
|
|
1007
|
+
* Returns true when the bytes represent the specified key with modifiers.
|
|
1008
|
+
*/
|
|
1009
|
+
export declare function matchesKey(data: string, keyId: string, kittyProtocolActive: boolean): boolean
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Match Kitty protocol input against a codepoint and modifier mask.
|
|
1013
|
+
*
|
|
1014
|
+
* Returns true when the parsed sequence matches the expected codepoint (or
|
|
1015
|
+
* base layout key) and modifier bits.
|
|
1016
|
+
*/
|
|
1017
|
+
export declare function matchesKittySequence(data: string, expectedCodepoint: number, expectedModifier: number): boolean
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Check if input matches a legacy escape sequence for the given key name.
|
|
1021
|
+
*
|
|
1022
|
+
* Returns true only when the byte sequence maps to the exact key identifier.
|
|
1023
|
+
*/
|
|
1024
|
+
export declare function matchesLegacySequence(data: string, keyName: string): boolean
|
|
1025
|
+
|
|
1026
|
+
/** N-API opt-in handle for the minimizer. */
|
|
1027
|
+
export interface MinimizerOptions {
|
|
1028
|
+
/** Master switch. Absent / false = disabled. */
|
|
1029
|
+
enabled?: boolean
|
|
1030
|
+
/**
|
|
1031
|
+
* Optional path to a TOML settings file whose values override
|
|
1032
|
+
* field-level defaults. `~` is expanded.
|
|
1033
|
+
*/
|
|
1034
|
+
settingsPath?: string
|
|
1035
|
+
/**
|
|
1036
|
+
* Optional xxHash64 digest (hex) of the settings file contents. When
|
|
1037
|
+
* supplied, the engine refuses to honor a settings file whose hash does
|
|
1038
|
+
* not match — a lightweight trust gate for agent-controllable paths.
|
|
1039
|
+
*/
|
|
1040
|
+
settingsHash?: string
|
|
1041
|
+
/**
|
|
1042
|
+
* Opt-in allowlist of program names (e.g. `"git"`). When empty or
|
|
1043
|
+
* absent, all built-in filters are active.
|
|
1044
|
+
*/
|
|
1045
|
+
only?: Array<string>
|
|
1046
|
+
/** Program names explicitly excluded from minimization. */
|
|
1047
|
+
except?: Array<string>
|
|
1048
|
+
/**
|
|
1049
|
+
* Maximum captured bytes per command before the engine falls back to
|
|
1050
|
+
* the raw, un-minimized output. Default 4 MiB.
|
|
1051
|
+
*/
|
|
1052
|
+
maxCaptureBytes?: number
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Telemetry for a single minimization.
|
|
1057
|
+
*
|
|
1058
|
+
* Surfaced when the minimizer actually rewrote the command's output. The
|
|
1059
|
+
* session layer is expected to persist `original_text` via its
|
|
1060
|
+
* `ArtifactManager`, splice the resulting `artifact://<id>` reference
|
|
1061
|
+
* into `text`, and replace any previously streamed raw output with the
|
|
1062
|
+
* minimized text.
|
|
1063
|
+
*/
|
|
1064
|
+
export interface MinimizerResult {
|
|
1065
|
+
/**
|
|
1066
|
+
* Dispatch label produced by the minimizer (e.g. `"git"`,
|
|
1067
|
+
* `"pipeline:gradle"`, `"pipeline+builtin"`).
|
|
1068
|
+
*/
|
|
1069
|
+
filter: string
|
|
1070
|
+
/**
|
|
1071
|
+
* The minimized replacement text. Callers that streamed raw chunks
|
|
1072
|
+
* during execution should clear and replace their accumulated output
|
|
1073
|
+
* with this text.
|
|
1074
|
+
*/
|
|
1075
|
+
text: string
|
|
1076
|
+
/** The full original capture, before minimization. */
|
|
1077
|
+
originalText: string
|
|
1078
|
+
/** Captured byte length before minimization. */
|
|
1079
|
+
inputBytes: number
|
|
1080
|
+
/** Byte length of the minimized text the consumer received. */
|
|
1081
|
+
outputBytes: number
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** Parsed Kitty keyboard protocol sequence result for a Kitty input sequence. */
|
|
1085
|
+
export interface ParsedKittyResult {
|
|
1086
|
+
/** Primary codepoint associated with the key. */
|
|
1087
|
+
codepoint: number
|
|
1088
|
+
/** Optional shifted key codepoint from the sequence. */
|
|
1089
|
+
shiftedKey?: number
|
|
1090
|
+
/** Optional base layout key codepoint from the sequence. */
|
|
1091
|
+
baseLayoutKey?: number
|
|
1092
|
+
/** Modifier bitmask (shift/alt/ctrl), excluding lock bits. */
|
|
1093
|
+
modifier: number
|
|
1094
|
+
/** Optional event type (1 = press, 2 = repeat, 3 = release). */
|
|
1095
|
+
eventType?: KeyEventType
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Parse terminal input and return a normalized key identifier.
|
|
1100
|
+
*
|
|
1101
|
+
* Returns a key id like "escape" or "ctrl+c", or None if unrecognized.
|
|
1102
|
+
*/
|
|
1103
|
+
export declare function parseKey(data: string, kittyProtocolActive: boolean): string | null
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Parse a Kitty keyboard protocol sequence.
|
|
1107
|
+
*
|
|
1108
|
+
* Returns a structured parse result when the input is a valid Kitty sequence.
|
|
1109
|
+
*/
|
|
1110
|
+
export declare function parseKittySequence(data: string): ParsedKittyResult | null
|
|
1111
|
+
|
|
1112
|
+
/** Current state of a process reference. */
|
|
1113
|
+
export declare enum ProcessStatus {
|
|
1114
|
+
/** The referenced process is still running. */
|
|
1115
|
+
Running = 'running',
|
|
1116
|
+
/** The referenced process has exited or is no longer observable. */
|
|
1117
|
+
Exited = 'exited'
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
export interface ProcessTerminateOptions {
|
|
1121
|
+
/** Also signal the process group when supported by the platform. */
|
|
1122
|
+
group?: boolean
|
|
1123
|
+
/**
|
|
1124
|
+
* Milliseconds to wait after polite termination before hard-killing.
|
|
1125
|
+
* Omit to use the default grace period. Pass a negative value to skip the
|
|
1126
|
+
* graceful phase and hard-kill immediately.
|
|
1127
|
+
*/
|
|
1128
|
+
gracefulMs?: number
|
|
1129
|
+
/** Milliseconds to wait after hard-kill for the process tree to exit. */
|
|
1130
|
+
timeoutMs?: number
|
|
1131
|
+
/** Abort signal for cancelling termination while waiting. */
|
|
1132
|
+
signal?: unknown
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/** Options for waiting on a process exit. */
|
|
1136
|
+
export interface ProcessWaitOptions {
|
|
1137
|
+
/** Milliseconds to wait before returning false. Omit to wait indefinitely. */
|
|
1138
|
+
timeoutMs?: number
|
|
1139
|
+
/** Abort signal for cancelling the wait. */
|
|
1140
|
+
signal?: unknown
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/** Result of a PTY command run. */
|
|
1144
|
+
export interface PtyRunResult {
|
|
1145
|
+
/** Exit code when the command completes. */
|
|
1146
|
+
exitCode?: number
|
|
1147
|
+
/** Whether command was cancelled by signal/user kill. */
|
|
1148
|
+
cancelled: boolean
|
|
1149
|
+
/** Whether command timed out. */
|
|
1150
|
+
timedOut: boolean
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/** Options for running a command in a PTY session. */
|
|
1154
|
+
export interface PtyStartOptions {
|
|
1155
|
+
/** Command string to execute. */
|
|
1156
|
+
command: string
|
|
1157
|
+
/** Working directory for command execution. */
|
|
1158
|
+
cwd?: string
|
|
1159
|
+
/** Environment variables for this command. */
|
|
1160
|
+
env?: Record<string, string>
|
|
1161
|
+
/** Timeout in milliseconds before cancelling. */
|
|
1162
|
+
timeoutMs?: number
|
|
1163
|
+
/** Abort signal for cancelling the operation. */
|
|
1164
|
+
signal?: unknown
|
|
1165
|
+
/** PTY column count. */
|
|
1166
|
+
cols?: number
|
|
1167
|
+
/** PTY row count. */
|
|
1168
|
+
rows?: number
|
|
1169
|
+
/**
|
|
1170
|
+
* Shell binary to use (e.g. "sh", "bash", or an absolute path).
|
|
1171
|
+
* Defaults to "sh" if not provided.
|
|
1172
|
+
*/
|
|
1173
|
+
shell?: string
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* Read an image from the system clipboard.
|
|
1178
|
+
*
|
|
1179
|
+
* Returns `Ok(None)` when no image data is available.
|
|
1180
|
+
*
|
|
1181
|
+
* # Errors
|
|
1182
|
+
* Returns an error if clipboard access fails or image encoding fails.
|
|
1183
|
+
*/
|
|
1184
|
+
export declare function readImageFromClipboard(): Promise<ClipboardImage | undefined | null>
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Search content for a pattern (one-shot, compiles pattern each time).
|
|
1188
|
+
* For repeated searches with the same pattern, use [`grep`] with file filters.
|
|
1189
|
+
*
|
|
1190
|
+
* # Arguments
|
|
1191
|
+
* - `content`: `Uint8Array`/`Buffer` (zero-copy) or `string` (UTF-8).
|
|
1192
|
+
* - `options`: Regex settings, context, and output mode.
|
|
1193
|
+
*
|
|
1194
|
+
* # Returns
|
|
1195
|
+
* Match list plus counts/limit status; errors are surfaced in `error`.
|
|
1196
|
+
*/
|
|
1197
|
+
export declare function search(content: string | Uint8Array, options: SearchOptions): SearchResult
|
|
1198
|
+
|
|
1199
|
+
/** Options for searching file content. */
|
|
1200
|
+
export interface SearchOptions {
|
|
1201
|
+
/** Regex pattern to search for. */
|
|
1202
|
+
pattern: string
|
|
1203
|
+
/** Case-insensitive search. */
|
|
1204
|
+
ignoreCase?: boolean
|
|
1205
|
+
/** Enable multiline matching. */
|
|
1206
|
+
multiline?: boolean
|
|
1207
|
+
/** Maximum number of matches to return. */
|
|
1208
|
+
maxCount?: number
|
|
1209
|
+
/** Skip first N matches. */
|
|
1210
|
+
offset?: number
|
|
1211
|
+
/** Lines of context before matches. */
|
|
1212
|
+
contextBefore?: number
|
|
1213
|
+
/** Lines of context after matches. */
|
|
1214
|
+
contextAfter?: number
|
|
1215
|
+
/** Lines of context before/after matches (legacy). */
|
|
1216
|
+
context?: number
|
|
1217
|
+
/** Truncate lines longer than this (characters). */
|
|
1218
|
+
maxColumns?: number
|
|
1219
|
+
/** Output mode (content or count). */
|
|
1220
|
+
mode?: GrepOutputMode
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/** Result of searching content. */
|
|
1224
|
+
export interface SearchResult {
|
|
1225
|
+
/** All matches found. */
|
|
1226
|
+
matches: Array<Match>
|
|
1227
|
+
/** Total number of matches (may exceed `matches.len()` due to offset/limit). */
|
|
1228
|
+
matchCount: number
|
|
1229
|
+
/** Whether the limit was reached. */
|
|
1230
|
+
limitReached: boolean
|
|
1231
|
+
/** Error message, if any. */
|
|
1232
|
+
error?: string
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/** Options for executing a shell command via brush-core. */
|
|
1236
|
+
export interface ShellExecuteOptions {
|
|
1237
|
+
/** Command string to execute in the shell. */
|
|
1238
|
+
command: string
|
|
1239
|
+
/** Working directory for the command. */
|
|
1240
|
+
cwd?: string
|
|
1241
|
+
/** Environment variables to apply for this command only. */
|
|
1242
|
+
env?: Record<string, string>
|
|
1243
|
+
/** Environment variables to apply once per session. */
|
|
1244
|
+
sessionEnv?: Record<string, string>
|
|
1245
|
+
/** Timeout in milliseconds before cancelling the command. */
|
|
1246
|
+
timeoutMs?: number
|
|
1247
|
+
/** Optional snapshot file to source on session creation. */
|
|
1248
|
+
snapshotPath?: string
|
|
1249
|
+
/** Optional per-command output minimizer configuration. */
|
|
1250
|
+
minimizer?: MinimizerOptions
|
|
1251
|
+
/** Abort signal for cancelling the operation. */
|
|
1252
|
+
signal?: unknown
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/** Options for configuring a persistent shell session. */
|
|
1256
|
+
export interface ShellOptions {
|
|
1257
|
+
/** Environment variables to apply once per session. */
|
|
1258
|
+
sessionEnv?: Record<string, string>
|
|
1259
|
+
/** Optional snapshot file to source on session creation. */
|
|
1260
|
+
snapshotPath?: string
|
|
1261
|
+
/** Optional per-command output minimizer configuration. */
|
|
1262
|
+
minimizer?: MinimizerOptions
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/** Options for running a shell command. */
|
|
1266
|
+
export interface ShellRunOptions {
|
|
1267
|
+
/** Command string to execute in the shell. */
|
|
1268
|
+
command: string
|
|
1269
|
+
/** Working directory for the command. */
|
|
1270
|
+
cwd?: string
|
|
1271
|
+
/** Environment variables to apply for this command only. */
|
|
1272
|
+
env?: Record<string, string>
|
|
1273
|
+
/** Timeout in milliseconds before cancelling the command. */
|
|
1274
|
+
timeoutMs?: number
|
|
1275
|
+
/** Abort signal for cancelling the operation. */
|
|
1276
|
+
signal?: unknown
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/** Result of running a shell command. */
|
|
1280
|
+
export interface ShellRunResult {
|
|
1281
|
+
/** Exit code when the command completes normally. */
|
|
1282
|
+
exitCode?: number
|
|
1283
|
+
/** Whether the command was cancelled via abort. */
|
|
1284
|
+
cancelled: boolean
|
|
1285
|
+
/** Whether the command timed out before completion. */
|
|
1286
|
+
timedOut: boolean
|
|
1287
|
+
/**
|
|
1288
|
+
* When the minimizer rewrote the captured output, this carries the
|
|
1289
|
+
* original buffer + telemetry so the session layer can persist it as
|
|
1290
|
+
* an artifact and splice an `artifact://<id>` reference into the
|
|
1291
|
+
* minimized text shown to the agent. `None` when nothing was rewritten.
|
|
1292
|
+
*/
|
|
1293
|
+
minimized?: MinimizerResult
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Visible slice of a line after ANSI-aware column selection
|
|
1298
|
+
* (`sliceWithWidth`).
|
|
1299
|
+
*/
|
|
1300
|
+
export interface SliceResult {
|
|
1301
|
+
/** UTF-16 slice containing the selected text. */
|
|
1302
|
+
text: string
|
|
1303
|
+
/** Visible width of the slice in terminal cells. */
|
|
1304
|
+
width: number
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Slice a range of visible columns from a line.
|
|
1309
|
+
*
|
|
1310
|
+
* Counts terminal cells, skipping ANSI escapes, and optionally enforces strict
|
|
1311
|
+
* width.
|
|
1312
|
+
*/
|
|
1313
|
+
export declare function sliceWithWidth(line: string, startCol: number, length: number, strict: boolean | undefined | null, tabWidth: number): SliceResult
|
|
1314
|
+
|
|
1315
|
+
export declare function summarizeCode(options: SummaryOptions): SummaryResult
|
|
1316
|
+
|
|
1317
|
+
export interface SummaryOptions {
|
|
1318
|
+
/** Source code to summarize. */
|
|
1319
|
+
code: string
|
|
1320
|
+
/** Language alias (e.g. "rust", "typescript") used before path inference. */
|
|
1321
|
+
lang?: string
|
|
1322
|
+
/** File path used to infer language by extension when `lang` is omitted. */
|
|
1323
|
+
path?: string
|
|
1324
|
+
/** Minimum total node lines before eliding a body/literal node. */
|
|
1325
|
+
minBodyLines?: number
|
|
1326
|
+
/** Minimum total comment lines before eliding a multiline block comment. */
|
|
1327
|
+
minCommentLines?: number
|
|
1328
|
+
/**
|
|
1329
|
+
* Target visible-line count for BFS unfold. `None` or `0` keeps only
|
|
1330
|
+
* the outermost elisions (no progressive unfolding).
|
|
1331
|
+
*/
|
|
1332
|
+
unfoldUntilLines?: number
|
|
1333
|
+
/**
|
|
1334
|
+
* Hard ceiling for BFS unfold. Defaults to `unfold_until_lines * 2`
|
|
1335
|
+
* when omitted.
|
|
1336
|
+
*/
|
|
1337
|
+
unfoldLimitLines?: number
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
export interface SummaryResult {
|
|
1341
|
+
/** Canonical language name when parsing succeeded. */
|
|
1342
|
+
language?: string
|
|
1343
|
+
/** True when tree-sitter parsed the source without syntax errors. */
|
|
1344
|
+
parsed: boolean
|
|
1345
|
+
/** True when at least one elision span was emitted. */
|
|
1346
|
+
elided: boolean
|
|
1347
|
+
/** Total source lines. */
|
|
1348
|
+
totalLines: number
|
|
1349
|
+
/** Kept/elided segments in source order. */
|
|
1350
|
+
segments: Array<SummarySegment>
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
export interface SummarySegment {
|
|
1354
|
+
/** "kept" or "elided". */
|
|
1355
|
+
kind: string
|
|
1356
|
+
/** 1-based inclusive start line. */
|
|
1357
|
+
startLine: number
|
|
1358
|
+
/** 1-based inclusive end line. */
|
|
1359
|
+
endLine: number
|
|
1360
|
+
/** Verbatim text for kept segments; absent for elided segments. */
|
|
1361
|
+
text?: string
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Check if a language is supported for highlighting.
|
|
1366
|
+
* Returns true if the language has either direct support or a fallback
|
|
1367
|
+
* mapping.
|
|
1368
|
+
*/
|
|
1369
|
+
export declare function supportsLanguage(lang: string): boolean
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Truncate text to a visible width, preserving ANSI codes.
|
|
1373
|
+
*
|
|
1374
|
+
* Pads with spaces when requested.
|
|
1375
|
+
*/
|
|
1376
|
+
export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind: Ellipsis | undefined | null, pad: boolean | undefined | null, tabWidth: number): string
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Calculate visible width of text, excluding ANSI escape sequences.
|
|
1380
|
+
*
|
|
1381
|
+
* Tabs count as a fixed-width cell.
|
|
1382
|
+
*/
|
|
1383
|
+
export declare function visibleWidth(text: string, tabWidth: number): number
|
|
1384
|
+
|
|
1385
|
+
/** Profiling results returned to JavaScript. */
|
|
1386
|
+
export interface WorkProfile {
|
|
1387
|
+
/** Folded stack format for flamegraph tools. */
|
|
1388
|
+
folded: string
|
|
1389
|
+
/** Markdown summary of profiling results. */
|
|
1390
|
+
summary: string
|
|
1391
|
+
/** SVG flamegraph (if generation succeeded). */
|
|
1392
|
+
svg?: string
|
|
1393
|
+
/** Total profiled duration in milliseconds. */
|
|
1394
|
+
totalMs: number
|
|
1395
|
+
/** Number of samples collected. */
|
|
1396
|
+
sampleCount: number
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Wrap text to a visible width, preserving ANSI escape codes across line
|
|
1401
|
+
* breaks.
|
|
1402
|
+
*
|
|
1403
|
+
* Returns UTF-16 lines with active SGR codes carried across line boundaries.
|
|
1404
|
+
*/
|
|
1405
|
+
export declare function wrapTextWithAnsi(text: string, width: number, tabWidth: number): Array<string>
|