import type { BtcCacheArtifact, MarketRegimeArtifact, OiHistoryArtifact, PrescreenedArtifact, SharedArtifactContract, SharedArtifactValue } from "../artifacts.js"; import type { ScannerDependencyPolicyMode } from "../scanner-definition.js"; import type { ScannerDefinition } from "../scanner-definition.js"; import type { ScannerRuntimeState } from "../store/runtime-store.js"; import type { CandleResult, Instrument, OiSnapshot, ScannerId, SharedArtifactKey, SmMarket } from "../types.js"; import type { ClearingHouseState } from "../implementations/liquidation-watchdog.js"; import type { DslState } from "../../types/dsl/index.js"; type ReadonlyPrimitive = bigint | boolean | null | number | string | symbol | undefined; type ReadonlyDeepArray = ReadonlyArray>; type ReadonlyDeepObject = { readonly [Key in keyof T]: ReadonlyDeep; }; /** * Recursively marks nested scan-input payloads as readonly. * This is used for artifact-backed inputs so scanners cannot mutate shared * market intelligence snapshots in place. */ type ReadonlyDeep = T extends ReadonlyPrimitive ? T : T extends (...args: never[]) => unknown ? T : T extends readonly (infer Item)[] ? ReadonlyDeepArray : T extends object ? ReadonlyDeepObject : T; /** Candle data indexed first by asset, then by timeframe within each candle result. */ export type CandlesByAsset = Readonly>>; /** Open-interest history indexed by asset name. */ export type OiHistoryByAsset = Readonly[]>>; /** * Known built-in retained-context hints kept for built-in scanner ergonomics. * Runtime wiring remains open-keyed beyond these built-ins. */ interface BuiltInArtifactInputHints { readonly prescreened?: ReadonlyDeep; readonly "oi-history"?: ReadonlyDeep; readonly "btc-cache"?: ReadonlyDeep; readonly "market-regime"?: ReadonlyDeep; } /** * Shared market intelligence resolved for one scan run. * These values come from shared artifact bindings rather than direct provider needs. */ export type ScanArtifactInputs = Readonly | undefined>> & BuiltInArtifactInputHints; /** * Data payload assembled by engine for one scan run. * Top-level fields are provider-backed inputs; `artifacts` contains shared * market intelligence. Scanners should treat this snapshot as read-only input. */ export interface ScanInputs { readonly instruments?: readonly Readonly[]; readonly candles?: CandlesByAsset; readonly smData?: readonly Readonly[]; readonly activePositions?: readonly Readonly>[]; readonly clearingHouseState?: Readonly; readonly dslStates?: readonly Readonly[]; readonly artifacts: ScanArtifactInputs; } export interface ResolvedScannerDependency { readonly scanner: ScannerId; readonly contextKey: string; readonly updatedAt: number; readonly maxAgeMs?: number; readonly stale: boolean; readonly onMissing?: ScannerDependencyPolicyMode; readonly onStale?: ScannerDependencyPolicyMode; readonly value: ReadonlyDeep; } /** Optional logger surface exposed to scanners and hooks. */ export interface ScannerLogger { debug?: (message: string, meta?: Record) => void; info?: (message: string, meta?: Record) => void; warn?: (message: string, meta?: Record) => void; error?: (message: string, meta?: Record) => void; } /** Shared-artifact accessors available to scanners for reading and writing shared market intelligence. */ export interface SharedArtifactAccessor { loadSharedArtifact: (artifact: Key | SharedArtifactContract, opts?: { maxAgeMs?: number; }) => Promise | null>; saveSharedArtifact: (artifact: Key | SharedArtifactContract, value: SharedArtifactValue) => Promise; } /** Context passed once during scanner bootstrap. */ export interface ScannerInitContext extends SharedArtifactAccessor { address: string; scannerId: ScannerId; definition: ScannerDefinition; runtime: ScannerRuntimeState; config: Cfg; state: St; now: () => number; logger?: ScannerLogger; setState: (nextState: St) => Promise; } /** Context passed on each scan run after runtime and inputs are loaded. */ export interface ScanContext extends ScannerInitContext { runStartedAt: number; inputs: ScanInputs; dependencies: readonly ResolvedScannerDependency[]; } export {}; //# sourceMappingURL=context.d.ts.map