framework
Version:
The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.
116 lines • 5.69 kB
TypeScript
/**
* The quota boundary (#879): how much of the account's week The Framework may
* have spent by now.
*
* The whole policy is one line — the boundary is the pro-rated share of the week's allowance that
* has elapsed, rising continuously with the clock rather than once a day (#960 Edit) — and it
* replaces the configurable limits of #519. There is nothing to configure: the boundary is derived
* from the account's own week, which the agent reports.
*
* Two properties fall out of it, and they are the point:
* - Nothing is left on the floor. The boundary rises on its own and reaches the full allowance
* exactly as the week resets, so a quiet week still gets spent rather than expiring.
* - Low-priority work cannot starve high-priority work. Work the user asks for
* borrows against the days still to come; unattended work stands down once it
* passes the boundary, by default a half-day cushion beyond it (#960 Edit) —
* see {@link QuotaLimit}.
*/
import type { DriverQuotaWindow } from './driver/index.js';
/** The quota week, in ms. */
export declare const QUOTA_WEEK_MS: number;
/** Where the boundary sits, and the week it is derived from. */
export interface QuotaBoundary {
/** When the current quota week began, epoch ms. */
startsAt: number;
/** When it resets, epoch ms. */
resetsAt: number;
/** Which day of the week we are on, 1-7. */
day: number;
/** The share of the week's allowance that may be spent by now, 0-100. */
percent: number;
}
/**
* Parse the agent's reset prose into an epoch.
*
* The agent prints no year (`Jul 25 at 7am (Asia/Jerusalem)`), which is why the
* driver keeps this as text. It is recoverable here because we know something
* the driver does not: a *weekly* window resets within seven days, so of the
* candidate years exactly one lands anywhere near now.
*
* `undefined` for anything that does not parse, which the callers treat as "we
* do not know where the week is" rather than as a boundary of zero.
*/
export declare function parseResetsAt(text: string, now: number): number | undefined;
/**
* Where the boundary sits, given when the week resets.
*
* `percent` is continuous — the plain elapsed share of the week (#960 Edit) — rather than a value
* that jumps once a day, so it always names the actual instant `now` falls on, on any axis that
* measures the week the same way. A stepped version once unlocked a whole day's allowance the
* moment a new day began (including the entire week's worth on the last day), which read as
* generous on paper but let a burst of spending land the instant the clock ticked over rather than
* pacing with it; continuous keeps the line honest about what has actually elapsed at the cost of
* that burst.
*
* `day` is 1-based and still names which day of the week `now` falls on — for callers that want to
* say "day 4 of 7" rather than a percentage — and steps at the exact second the week's own day
* rolls over, independently of `percent`.
*/
export declare function boundaryFromResetsAt(resetsAt: number, now: number): QuotaBoundary;
/** One quota window measured against the boundary. */
export interface BoundaryWindow {
/** The window's own label, as the agent phrased it. */
label: string;
/** How much of it is gone, 0-100. */
percentUsed: number;
/** Whether it has reached the limit in force. */
reached: boolean;
}
/**
* The line unattended work actually stops at (#960).
*
* The boundary is the policy; this is the policy plus whatever the user asked for with the
* slider. They are separate values because the panel draws both: moving your own limit should
* not silently redraw the boundary it is measured against.
*/
export interface QuotaLimit {
/** Where the limit sits, 0-100. */
percent: number;
/** How far it is from the boundary, in percentage points. `0` is the default policy. */
offset: number;
}
/** Where the account stands against its boundary. */
export interface QuotaBoundaryStatus {
boundary: QuotaBoundary;
/** The line in force, which is the boundary unless the user moved it (#960). */
limit: QuotaLimit;
/** The windows in force: the account's week, plus the selected model's own week when we can tell which it is. */
windows: BoundaryWindow[];
/** The window that has reached the limit, or `null` while there is room. */
reached: BoundaryWindow | null;
}
/**
* Measure the account's windows against the boundary (#879).
*
* Both weekly windows bind at once — the account's week and, per Rom's edit, the
* selected model's own week — so each is measured against the same boundary and
* whichever reaches it first is the one that stops the work. The model's window
* is only included when we can tell which model it belongs to; an unrecognized
* one is left out rather than allowed to stop work for a model nobody selected.
*
* `undefined` when there is no reading, or when the week's reset cannot be
* placed. That is "we do not know", and each caller decides what to do with it:
* the per-agent guard carries on, unattended work stands down.
*/
export declare function quotaBoundaryStatus(input: {
windows: DriverQuotaWindow[];
now: number;
/** The model the work will run on, e.g. `claude-fable-5`. Its own week joins the gate when given. */
model?: string;
/**
* How far the automatic-consumption limit sits from the boundary, in percentage points (#960).
* Omitted or `0` is the spend-boundary policy (#879): the limit *is* the boundary.
*/
limitOffset?: number;
}): QuotaBoundaryStatus | undefined;
//# sourceMappingURL=quota-boundary.d.ts.map