refactor(stream-parsing): restructured stream utilities to use Web standard APIs and generic SSE parsing

- Refactored SSE stream parsing to use generic `readSseJson` utility instead of domain-specific handlers across multiple packages.
- Migrated from Node.js Buffer API to Web standard APIs (Uint8Array, TextDecoder, DataView) for cross-platform compatibility.
- Simplified stream transformation pipeline by consolidating multiple stream operations into unified `createTextLineSplitter` utility.
- Refactored `ptree.ts` to remove complex stream pumping infrastructure and simplify stderr handling with direct async iteration.
- Rewrote stream utilities to operate at binary level with byte-level parsing for improved efficiency and reduced string allocations.
- Updated TypeScript configuration to include DOM.AsyncIterable type definitions for async iterable DOM API support.
This commit is contained in:
can1357
2026-02-05 10:59:47 +01:00
parent 251d5a91ef
commit 1f7c4f6f90
39 changed files with 679 additions and 714 deletions
@@ -79,6 +79,7 @@ export async function executeSSH(
using child = ptree.spawn(["ssh", ...(await buildRemoteCommand(host, resolvedCommand))], {
signal: options?.signal,
timeout: options?.timeout,
exposeStderr: true,
});
const sink = new OutputSink({
@@ -87,9 +88,11 @@ export async function executeSSH(
artifactId: options?.artifactId,
});
await Promise.allSettled([child.stdout.pipeTo(sink.createInput()), child.stderr.pipeTo(sink.createInput())]).catch(
() => {},
);
const streams = [child.stdout.pipeTo(sink.createInput())];
if (child.stderr) {
streams.push(child.stderr.pipeTo(sink.createInput()));
}
await Promise.allSettled(streams).catch(() => {});
try {
return {