@orkestrel/process 0.0.8 → 0.0.9

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.
@@ -5,10 +5,8 @@ import { ExecutableOptions } from '@orkestrel/process';
5
5
  import { ExecuteInput } from '@orkestrel/process';
6
6
  import { ExecuteOptions } from '@orkestrel/process';
7
7
  import { ExecuteResult } from '@orkestrel/process';
8
- import { ExecuteResult as ExecuteResult_2 } from '@orkestrel/process';
9
8
  import { ExecuteSyncOptions } from '@orkestrel/process';
10
9
  import { ProcessCommand } from '@orkestrel/process';
11
- import { ProcessCommand as ProcessCommand_2 } from '@orkestrel/process';
12
10
  import { ProcessEventMap } from '@orkestrel/process';
13
11
  import { ProcessExit } from '@orkestrel/process';
14
12
  import { ProcessInterface } from '@orkestrel/process';
@@ -120,6 +118,30 @@ export declare function buildPlatformSpawn(command: ProcessCommand, file: string
120
118
  */
121
119
  export declare function buildSpawn(command: ProcessCommand, options?: ExecutableOptions): SpawnInput;
122
120
 
121
+ /**
122
+ * Bounds one delivered stream chunk to the bytes a capture still has room for.
123
+ *
124
+ * @remarks
125
+ * A chunk that is not a buffer contributes nothing and reports `undefined` rather than throwing,
126
+ * because a stream `data` listener receives an `unknown` payload. The cut is byte-exact and might
127
+ * land inside a multibyte sequence, because {@link buildExecuteResult} performs the single
128
+ * code-point-boundary trim over the whole capture rather than over each chunk. Give the capture one
129
+ * byte more room than its limit, so that final trim can read the first excluded byte and retreat off
130
+ * a split sequence. A chunk that fits its room is returned as the delivered buffer itself rather
131
+ * than a copy, because a capture appending it copies again and never writes through it; a chunk that
132
+ * overruns its room returns a copy of the bytes that fit. Treat the return as read-only either way.
133
+ *
134
+ * @param chunk - The delivered chunk, ignored when it is not a buffer
135
+ * @param room - The bytes the capture still accepts
136
+ * @returns The bytes to retain, or `undefined` when the chunk contributes none
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * captureChunk(Buffer.from('hello'), 3) // <Buffer 68 65 6c>
141
+ * ```
142
+ */
143
+ export declare function captureChunk(chunk: unknown, room: number): Buffer_2 | undefined;
144
+
123
145
  /**
124
146
  * Creates one supervised child process.
125
147
  *
@@ -192,7 +214,7 @@ export declare function createSession(options: SessionOptions): SessionInterface
192
214
  * detach({ file: 'node', arguments: ['daemon.js'] }, { workspace: process.cwd() })
193
215
  * ```
194
216
  */
195
- export declare function detach(command: ProcessCommand_2, options?: DetachOptions): void;
217
+ export declare function detach(command: ProcessCommand, options?: DetachOptions): void;
196
218
 
197
219
  /**
198
220
  * Runs one command to completion, buffering its output, and settles with the outcome.
@@ -201,7 +223,9 @@ export declare function detach(command: ProcessCommand_2, options?: DetachOption
201
223
  * The executable is resolved through {@link buildSpawn}, so no run uses a shell. On a POSIX host the
202
224
  * child is detached, which is what lets its whole process group be terminated. Standard output and
203
225
  * error are each byte-bounded by `limit` (default {@link PROCESS_OUTPUT}) and `truncated` reports
204
- * whether either stream exceeded it. A positive `timeout` and an aborting `signal` both terminate the
226
+ * whether either stream exceeded it. Each capture keeps one byte beyond `limit`, so the single
227
+ * code-point-boundary trim in {@link buildExecuteResult} reads the first excluded byte and never
228
+ * delivers a split multibyte sequence. A positive `timeout` and an aborting `signal` both terminate the
205
229
  * child through the same bounded stop, and only the earliest is recorded: a timeout reports
206
230
  * `expired` and an abort reports `aborted`, never both. After termination the outcome is awaited for
207
231
  * a bounded window, so a descendant holding the child's stdio cannot keep the run pending. That bound
@@ -227,7 +251,7 @@ export declare function detach(command: ProcessCommand_2, options?: DetachOption
227
251
  * const result = await execute({ file: 'git', arguments: ['status'] }, { workspace: process.cwd() })
228
252
  * ```
229
253
  */
230
- export declare function execute(command: ProcessCommand_2, options?: ExecuteOptions): Promise<ExecuteResult_2>;
254
+ export declare function execute(command: ProcessCommand, options?: ExecuteOptions): Promise<ExecuteResult>;
231
255
 
232
256
  /**
233
257
  * Runs one command to completion synchronously, buffering its output, and returns the outcome.
@@ -253,7 +277,7 @@ export declare function execute(command: ProcessCommand_2, options?: ExecuteOpti
253
277
  * const result = executeSync({ file: 'git', arguments: ['--version'] }, { strict: false })
254
278
  * ```
255
279
  */
256
- export declare function executeSync(command: ProcessCommand_2, options?: ExecuteSyncOptions): ExecuteResult_2;
280
+ export declare function executeSync(command: ProcessCommand, options?: ExecuteSyncOptions): ExecuteResult;
257
281
 
258
282
  /**
259
283
  * Renders one command into its diagnostic command line.
@@ -715,48 +739,6 @@ export declare function readVariable(environment: Readonly<Record<string, string
715
739
  */
716
740
  export declare function resolveExecutable(file: string, options?: ExecutableOptions): string | undefined;
717
741
 
718
- /**
719
- * Accumulates byte totals while retaining a bounded stream head.
720
- *
721
- * @example
722
- * ```ts
723
- * const retention = new Retention()
724
- * retention.retain(Buffer.from('hello'), 3)?.toString('utf8') // 'hel'
725
- * retention.retained // 3
726
- * ```
727
- */
728
- export declare class Retention implements RetentionInterface {
729
- #private;
730
- /** The bytes delivered by the stream. */
731
- get delivered(): number;
732
- /** The bytes retained from the stream head. */
733
- get retained(): number;
734
- /**
735
- * Retains a delivered chunk within a byte limit.
736
- *
737
- * @param chunk - The delivered chunk, ignored when it is not a buffer
738
- * @param limit - The maximum retained byte count
739
- * @returns The retained slice, or `undefined` when the chunk contributes no retained bytes
740
- */
741
- retain(chunk: unknown, limit: number): Buffer_2 | undefined;
742
- }
743
-
744
- /** Exposes byte totals and bounded stream-head retention. */
745
- export declare interface RetentionInterface {
746
- /** The bytes delivered by the stream. */
747
- readonly delivered: number;
748
- /** The bytes retained from the stream head. */
749
- readonly retained: number;
750
- /**
751
- * Retains a delivered chunk within a byte limit.
752
- *
753
- * @param chunk - The delivered chunk, ignored when it is not a buffer
754
- * @param limit - The maximum retained byte count
755
- * @returns The retained slice, or `undefined` when the chunk contributes no retained bytes
756
- */
757
- retain(chunk: unknown, limit: number): Buffer_2 | undefined;
758
- }
759
-
760
742
  /**
761
743
  * Supervises one child and publishes its standard output as raw bytes.
762
744
  *
@@ -911,9 +893,12 @@ export declare function stopChild(child: ProcessChild, grace: number, confirm: n
911
893
  * Trims a buffer to at most `limit` leading bytes without splitting a UTF-8 sequence.
912
894
  *
913
895
  * @remarks
914
- * Keeps the head — the captured start of a one-shot run's output. When the cut point lands inside
915
- * a multibyte sequence, the end retreats to the sequence's start so the retained bytes always end
916
- * on a code-point boundary and decode without a replacement character.
896
+ * Keeps the head — the captured start of a one-shot run's output. The end retreats only when a
897
+ * sequence genuinely spans the cut: the byte at `limit` carries the continuation bit pattern, and a
898
+ * lead byte within the preceding three bytes declares a length that reaches it. The retained bytes
899
+ * then end on a code-point boundary and decode without a replacement character. A byte at `limit`
900
+ * that carries the continuation pattern without such a lead byte is invalid UTF-8 rather than a
901
+ * split sequence, so the full `limit` survives instead of a valid byte being dropped for it.
917
902
  *
918
903
  * @param bytes - The accumulated bytes
919
904
  * @param limit - The maximum retained byte count
@@ -5,10 +5,8 @@ import { ExecutableOptions } from '@orkestrel/process';
5
5
  import { ExecuteInput } from '@orkestrel/process';
6
6
  import { ExecuteOptions } from '@orkestrel/process';
7
7
  import { ExecuteResult } from '@orkestrel/process';
8
- import { ExecuteResult as ExecuteResult_2 } from '@orkestrel/process';
9
8
  import { ExecuteSyncOptions } from '@orkestrel/process';
10
9
  import { ProcessCommand } from '@orkestrel/process';
11
- import { ProcessCommand as ProcessCommand_2 } from '@orkestrel/process';
12
10
  import { ProcessEventMap } from '@orkestrel/process';
13
11
  import { ProcessExit } from '@orkestrel/process';
14
12
  import { ProcessInterface } from '@orkestrel/process';
@@ -120,6 +118,30 @@ export declare function buildPlatformSpawn(command: ProcessCommand, file: string
120
118
  */
121
119
  export declare function buildSpawn(command: ProcessCommand, options?: ExecutableOptions): SpawnInput;
122
120
 
121
+ /**
122
+ * Bounds one delivered stream chunk to the bytes a capture still has room for.
123
+ *
124
+ * @remarks
125
+ * A chunk that is not a buffer contributes nothing and reports `undefined` rather than throwing,
126
+ * because a stream `data` listener receives an `unknown` payload. The cut is byte-exact and might
127
+ * land inside a multibyte sequence, because {@link buildExecuteResult} performs the single
128
+ * code-point-boundary trim over the whole capture rather than over each chunk. Give the capture one
129
+ * byte more room than its limit, so that final trim can read the first excluded byte and retreat off
130
+ * a split sequence. A chunk that fits its room is returned as the delivered buffer itself rather
131
+ * than a copy, because a capture appending it copies again and never writes through it; a chunk that
132
+ * overruns its room returns a copy of the bytes that fit. Treat the return as read-only either way.
133
+ *
134
+ * @param chunk - The delivered chunk, ignored when it is not a buffer
135
+ * @param room - The bytes the capture still accepts
136
+ * @returns The bytes to retain, or `undefined` when the chunk contributes none
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * captureChunk(Buffer.from('hello'), 3) // <Buffer 68 65 6c>
141
+ * ```
142
+ */
143
+ export declare function captureChunk(chunk: unknown, room: number): Buffer_2 | undefined;
144
+
123
145
  /**
124
146
  * Creates one supervised child process.
125
147
  *
@@ -192,7 +214,7 @@ export declare function createSession(options: SessionOptions): SessionInterface
192
214
  * detach({ file: 'node', arguments: ['daemon.js'] }, { workspace: process.cwd() })
193
215
  * ```
194
216
  */
195
- export declare function detach(command: ProcessCommand_2, options?: DetachOptions): void;
217
+ export declare function detach(command: ProcessCommand, options?: DetachOptions): void;
196
218
 
197
219
  /**
198
220
  * Runs one command to completion, buffering its output, and settles with the outcome.
@@ -201,7 +223,9 @@ export declare function detach(command: ProcessCommand_2, options?: DetachOption
201
223
  * The executable is resolved through {@link buildSpawn}, so no run uses a shell. On a POSIX host the
202
224
  * child is detached, which is what lets its whole process group be terminated. Standard output and
203
225
  * error are each byte-bounded by `limit` (default {@link PROCESS_OUTPUT}) and `truncated` reports
204
- * whether either stream exceeded it. A positive `timeout` and an aborting `signal` both terminate the
226
+ * whether either stream exceeded it. Each capture keeps one byte beyond `limit`, so the single
227
+ * code-point-boundary trim in {@link buildExecuteResult} reads the first excluded byte and never
228
+ * delivers a split multibyte sequence. A positive `timeout` and an aborting `signal` both terminate the
205
229
  * child through the same bounded stop, and only the earliest is recorded: a timeout reports
206
230
  * `expired` and an abort reports `aborted`, never both. After termination the outcome is awaited for
207
231
  * a bounded window, so a descendant holding the child's stdio cannot keep the run pending. That bound
@@ -227,7 +251,7 @@ export declare function detach(command: ProcessCommand_2, options?: DetachOption
227
251
  * const result = await execute({ file: 'git', arguments: ['status'] }, { workspace: process.cwd() })
228
252
  * ```
229
253
  */
230
- export declare function execute(command: ProcessCommand_2, options?: ExecuteOptions): Promise<ExecuteResult_2>;
254
+ export declare function execute(command: ProcessCommand, options?: ExecuteOptions): Promise<ExecuteResult>;
231
255
 
232
256
  /**
233
257
  * Runs one command to completion synchronously, buffering its output, and returns the outcome.
@@ -253,7 +277,7 @@ export declare function execute(command: ProcessCommand_2, options?: ExecuteOpti
253
277
  * const result = executeSync({ file: 'git', arguments: ['--version'] }, { strict: false })
254
278
  * ```
255
279
  */
256
- export declare function executeSync(command: ProcessCommand_2, options?: ExecuteSyncOptions): ExecuteResult_2;
280
+ export declare function executeSync(command: ProcessCommand, options?: ExecuteSyncOptions): ExecuteResult;
257
281
 
258
282
  /**
259
283
  * Renders one command into its diagnostic command line.
@@ -715,48 +739,6 @@ export declare function readVariable(environment: Readonly<Record<string, string
715
739
  */
716
740
  export declare function resolveExecutable(file: string, options?: ExecutableOptions): string | undefined;
717
741
 
718
- /**
719
- * Accumulates byte totals while retaining a bounded stream head.
720
- *
721
- * @example
722
- * ```ts
723
- * const retention = new Retention()
724
- * retention.retain(Buffer.from('hello'), 3)?.toString('utf8') // 'hel'
725
- * retention.retained // 3
726
- * ```
727
- */
728
- export declare class Retention implements RetentionInterface {
729
- #private;
730
- /** The bytes delivered by the stream. */
731
- get delivered(): number;
732
- /** The bytes retained from the stream head. */
733
- get retained(): number;
734
- /**
735
- * Retains a delivered chunk within a byte limit.
736
- *
737
- * @param chunk - The delivered chunk, ignored when it is not a buffer
738
- * @param limit - The maximum retained byte count
739
- * @returns The retained slice, or `undefined` when the chunk contributes no retained bytes
740
- */
741
- retain(chunk: unknown, limit: number): Buffer_2 | undefined;
742
- }
743
-
744
- /** Exposes byte totals and bounded stream-head retention. */
745
- export declare interface RetentionInterface {
746
- /** The bytes delivered by the stream. */
747
- readonly delivered: number;
748
- /** The bytes retained from the stream head. */
749
- readonly retained: number;
750
- /**
751
- * Retains a delivered chunk within a byte limit.
752
- *
753
- * @param chunk - The delivered chunk, ignored when it is not a buffer
754
- * @param limit - The maximum retained byte count
755
- * @returns The retained slice, or `undefined` when the chunk contributes no retained bytes
756
- */
757
- retain(chunk: unknown, limit: number): Buffer_2 | undefined;
758
- }
759
-
760
742
  /**
761
743
  * Supervises one child and publishes its standard output as raw bytes.
762
744
  *
@@ -911,9 +893,12 @@ export declare function stopChild(child: ProcessChild, grace: number, confirm: n
911
893
  * Trims a buffer to at most `limit` leading bytes without splitting a UTF-8 sequence.
912
894
  *
913
895
  * @remarks
914
- * Keeps the head — the captured start of a one-shot run's output. When the cut point lands inside
915
- * a multibyte sequence, the end retreats to the sequence's start so the retained bytes always end
916
- * on a code-point boundary and decode without a replacement character.
896
+ * Keeps the head — the captured start of a one-shot run's output. The end retreats only when a
897
+ * sequence genuinely spans the cut: the byte at `limit` carries the continuation bit pattern, and a
898
+ * lead byte within the preceding three bytes declares a length that reaches it. The retained bytes
899
+ * then end on a code-point boundary and decode without a replacement character. A byte at `limit`
900
+ * that carries the continuation pattern without such a lead byte is invalid UTF-8 rather than a
901
+ * split sequence, so the full `limit` survives instead of a valid byte being dropped for it.
917
902
  *
918
903
  * @param bytes - The accumulated bytes
919
904
  * @param limit - The maximum retained byte count