build: compile dist/ [auto]

This commit is contained in:
github-actions[bot]
2026-04-04 07:07:41 +00:00
parent aa1f00e5bb
commit f4848b1acb
4 changed files with 104 additions and 15 deletions

11
dist/stdin.d.ts vendored
View File

@@ -1,6 +1,14 @@
import type { StdinData, UsageData } from './types.js';
import type { ModelFormatMode } from './config.js';
export declare function readStdin(): Promise<StdinData | null>;
type StdinStream = Pick<NodeJS.ReadStream, 'setEncoding' | 'on' | 'off' | 'pause'> & {
isTTY?: boolean;
};
type ReadStdinOptions = {
firstByteTimeoutMs?: number;
idleTimeoutMs?: number;
maxBytes?: number;
};
export declare function readStdin(stream?: StdinStream, options?: ReadStdinOptions): Promise<StdinData | null>;
export declare function getTotalTokens(stdin: StdinData): number;
export declare function getContextPercent(stdin: StdinData): number;
export declare function getBufferedPercent(stdin: StdinData): number;
@@ -27,4 +35,5 @@ export declare function stripContextSuffix(name: string): string;
* short: Strip context suffix AND leading "Claude " prefix (e.g. "Opus 4.6")
*/
export declare function formatModelName(name: string, format?: ModelFormatMode, override?: string): string;
export {};
//# sourceMappingURL=stdin.d.ts.map

2
dist/stdin.d.ts.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../src/stdin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,wBAAsB,SAAS,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAoB3D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAOvD;AAcD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAe1D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAyB3D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAarD;AAED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AC,KAAK,EAAE,SAAS,GAAG,MAAM,CAyB3D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAarD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAM1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAKhE;AAkBD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAkBpE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBjG"}

104
dist/stdin.js vendored
View File

@@ -1,23 +1,103 @@
import { AUTOCOMPACT_BUFFER_PERCENT } from './constants.js';
export async function readStdin() {
if (process.stdin.isTTY) {
const DEFAULT_FIRST_BYTE_TIMEOUT_MS = 250;
const DEFAULT_IDLE_TIMEOUT_MS = 30;
const DEFAULT_MAX_STDIN_BYTES = 256 * 1024;
export async function readStdin(stream = process.stdin, options = {}) {
if (stream.isTTY) {
return null;
}
const chunks = [];
const firstByteTimeoutMs = options.firstByteTimeoutMs ?? DEFAULT_FIRST_BYTE_TIMEOUT_MS;
const idleTimeoutMs = options.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
const maxBytes = options.maxBytes ?? DEFAULT_MAX_STDIN_BYTES;
try {
process.stdin.setEncoding('utf8');
for await (const chunk of process.stdin) {
chunks.push(chunk);
}
const raw = chunks.join('');
if (!raw.trim()) {
return null;
}
return JSON.parse(raw);
stream.setEncoding('utf8');
}
catch {
return null;
}
return await new Promise((resolve) => {
let raw = '';
let settled = false;
let sawData = false;
let firstByteTimer;
let idleTimer;
const cleanup = () => {
if (firstByteTimer) {
clearTimeout(firstByteTimer);
firstByteTimer = undefined;
}
if (idleTimer) {
clearTimeout(idleTimer);
idleTimer = undefined;
}
stream.off('data', onData);
stream.off('end', onEnd);
stream.off('error', onError);
stream.pause();
};
const finish = (value) => {
if (settled) {
return;
}
settled = true;
cleanup();
resolve(value);
};
const tryParse = () => {
const trimmed = raw.trim();
if (!trimmed) {
return null;
}
try {
return JSON.parse(trimmed);
}
catch {
return undefined;
}
};
const scheduleIdleParse = () => {
if (idleTimer) {
clearTimeout(idleTimer);
}
idleTimer = setTimeout(() => {
const parsed = tryParse();
finish(parsed ?? null);
}, idleTimeoutMs);
};
const onData = (chunk) => {
sawData = true;
if (firstByteTimer) {
clearTimeout(firstByteTimer);
firstByteTimer = undefined;
}
raw += String(chunk);
if (Buffer.byteLength(raw, 'utf8') > maxBytes) {
finish(null);
return;
}
const parsed = tryParse();
if (parsed !== undefined) {
finish(parsed);
return;
}
scheduleIdleParse();
};
const onEnd = () => {
const parsed = tryParse();
finish(parsed ?? null);
};
const onError = () => {
finish(null);
};
firstByteTimer = setTimeout(() => {
if (!sawData) {
finish(null);
}
}, firstByteTimeoutMs);
stream.on('data', onData);
stream.on('end', onEnd);
stream.on('error', onError);
});
}
export function getTotalTokens(stdin) {
const usage = stdin.context_window?.current_usage;

2
dist/stdin.js.map vendored

File diff suppressed because one or more lines are too long