agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
35 lines • 1.74 kB
TypeScript
/**
* longTimeout — arm a host timer for a limit of any length.
*
* A host timer holds at most 2^31 − 1 ms (about 24.8 days). Node turns a longer
* delay — `Infinity` included — into 1 ms, with a `TimeoutOverflowWarning`, so
* a raw `setTimeout(fn, limit)` gives up at once exactly when the caller asked
* to wait longest. The law, by the limit:
*
* - `Infinity` — no limit: NO timer is armed and `fn` never runs, so nothing
* keeps the process alive on its account.
* - a finite delay past 2^31 − 1 ms — waited in chained chunks of at most
* 2^31 − 1 ms, so it never fires early and never after 1 ms.
* - anything else that is not a number > 0 (`0`, a negative, `NaN`) — already
* due: `fn` runs on the next timer turn, as `setTimeout(fn, 0)` does.
*
* `{ unref: true }` unrefs every chunk, for a timer that only bounds a wait.
* The returned function cancels whichever chunk is armed; it is a no-op when
* nothing was armed.
*
* A COPY, ON PURPOSE: footprintjs has the same helper (`setLongTimeout`,
* footprintjs#136) but keeps it private — it is not part of footprintjs's
* public exports. agentfootprint keeps this copy, with the same signature and
* the same law, until footprintjs exports a supported long-timer helper.
*
* A leaf: imports nothing.
*/
/** How a long timer is armed. */
export interface LongTimeoutOptions {
/** Unref every host timer it arms (where the host has `unref`). */
readonly unref?: boolean;
}
/** `setTimeout` for a limit of any length, by the law above. Returns its
* cancel. */
export declare function setLongTimeout(fn: () => void, ms: number, options?: LongTimeoutOptions): () => void;
//# sourceMappingURL=longTimeout.d.ts.map