import type { ArtifactsNamespace } from '../public.ts'; import type { PackMap } from './packmap.ts'; export type FilterName = 'tree:0' | 'blob:none'; export type ServerInfo = { agent: string; protocol: number; objectFormat: string; caps: string[]; fetchFeatures: string[]; filterAdvertised: boolean; }; export type CommitInfo = { oid: string; tree: string; parents: string[]; authorName: string; authorEmail: string; authorTime: string; authorTz: string; message: string; signed: boolean; }; export type TreeEntry = { name: string; mode: string; oid: string; type: string }; export type BranchInfo = { name: string; oid: string; head: boolean }; export type TagInfo = { name: string; oid: string }; export type TraceBar = { name: string; startMs: number; durMs: number; status: 'ok' | 'error'; httpStatus: number | null; bytes: number | null; cache: string; lines: string[]; packWant: string | null; packFilter: FilterName | null; }; /** ?trace=1: render the Diagnostics section open. A missing flag stays closed. */ type TraceOpen = Partial<{ expanded: boolean }>; export type TraceModel = { bars: TraceBar[]; totalMs: number; cfRay: string; requestId: string; } & TraceOpen; export type RepoHeader = { host: string; repoPath: string; ref: string; commit: string; treeHref: string; server: ServerInfo; }; export type Loaded = | { kind: 'tree'; header: RepoHeader; path: string; commit: CommitInfo; log: CommitInfo[]; logStopped: boolean; branches: BranchInfo[]; branchesTruncated: number; tags: TagInfo[]; tagsTruncated: number; entries: TreeEntry[]; entriesTruncated: number; readme: { name: string; text: string } | { name: string; tooBig: true } | null; } | { kind: 'file'; header: RepoHeader; path: string; branches: BranchInfo[]; branchesTruncated: number; tags: TagInfo[]; tagsTruncated: number; mode: string; blob: string; size: number; note: 'text' | 'binary' | 'too-big' | 'submodule'; text: string | null; } | { kind: 'raw'; filename: string; bytes: Uint8Array; size: number } | { kind: 'pack'; header: RepoHeader; want: string; filterRequested: FilterName; filterHonoured: FilterName; map: PackMap; offset: number | null; askedOfsDelta: true; askedThinPack: false; }; export type RateDecision = { ok: boolean; remaining: number; retryAfterMs: number }; export type RateNamespace = { idFromName(name: string): unknown; get(id: unknown): { admit(bucket: string, now: number, limit: number, windowMs: number): Promise | RateDecision }; }; export type ViewerEnv = Partial<{ VIEWER_RATE: RateNamespace; /** Artifacts binding for the public namespace (cloudflare.config.ts). Mints read tokens; nothing else is called. */ PUBLIC_REPOS: ArtifactsNamespace; /** Comma-separated exact hostnames appended to the built-in allowlist. Wildcards are ignored. */ VIEWER_EXTRA_HOSTS: string; VIEWER_RATE_PER_MIN: string; /** `memo` (default), `batched` or `legacy` (docs/rate-limit.md). Anything else is legacy. */ RATE_MODE: string; /** The batched limiter's one counter (src/rate/counter.ts). */ RATE_COUNTER: import('../rate/stub.ts').CounterNamespace; /** The /v1 bearer. The viewer never reads it: load-test headers are unlocked by PLY_LOAD_TOKEN alone. */ PLY_TOKEN: string; /** Read only to authenticate load-test headers (src/rate/admit.ts). Never forwarded or echoed by the viewer. */ PLY_LOAD_TOKEN: string; VIEWER_PACK_RATE_PER_MIN: string; PACK_CACHE: string; /** `watched`: public-namespace refs are cached long and purged on change (src/refs-watch.ts). Anything else: 5 s + 10 s. */ REFS_POLICY: string; /** Workers version metadata (cloudflare.config.ts). Its id is the `ply.script_version` on the viewer's ply spans. */ VERSION: { readonly id: string }; }>;