SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
38.6 KB · 1,304 lines typescript
Raw Blame History
1/**2 * Types mirroring docs/API.md (contract v1). Postgres aggregates may arrive as strings → `Num`; always go through `num()`/`fmt*`.3 * Unknown/extra keys are tolerated: the web layer only reads what it renders.4 */56export type Num = number | string | null;7export type Org = { id: string; slug: string; name: string } | null;89export type Quality = { score?: number; completeness?: number; primary_source_ratio?: number; freshness?: number; source_count?: number; conflicts?: number };10export type Counts = { relations?: number; events?: number; claims?: number };1112export interface EntitySummary {13  id: string;14  entity_type: string;15  slug: string;16  name: string;17  description: string | null;18  status: string;19  organization: Org;20  attributes: Record<string, unknown>;21  quality: Quality;22  counts: Counts;23  first_seen_at: string;24  last_seen_at: string;25  updated_at: string;26}2728export interface Page<T> {29  items: T[];30  total: number;31  limit: number;32  offset: number;33}3435export type ProvenanceEntry = {36  source_id: string | null;37  source_name?: string;38  url: string | null;39  observed_at: string;40  tier: number;41  confidence: string;42  extractor: string;43  unit?: string;44};45export type Provenance = Record<string, ProvenanceEntry>;4647export type Importance = 0 | 1 | 2 | 3;4849export interface ChangeEvent {50  id: string;51  event_type: string;52  category: string;53  property: string | null;54  old_value: unknown;55  new_value: unknown;56  summary: string;57  importance: Importance;58  observed_at: string;59  effective_at: string | null;60  source_url: string | null;61  connector_name: string | null;62  entity: EntitySummary | null;63  meta: Record<string, unknown>;64}6566export interface Price {67  id: string;68  model: EntitySummary;69  provider: EntitySummary;70  provider_model_id: string | null;71  input_per_mtok: Num;72  output_per_mtok: Num;73  cached_input_per_mtok: Num;74  cache_write_per_mtok: Num;75  batch_input_per_mtok: Num;76  batch_output_per_mtok: Num;77  per_image: Num;78  currency: string;79  context_length: Num;80  max_output_tokens: Num;81  features: Record<string, unknown>;82  observed_at: string;83  valid_from: string;84  valid_to: string | null;85  source_url: string | null;86  tier: number;87}8889export interface BenchmarkResult {90  id: string;91  model: EntitySummary;92  benchmark: EntitySummary;93  score: number;94  metric: string | null;95  unit: string | null;96  higher_is_better: boolean;97  config: Record<string, unknown>;98  evaluated_at: string | null;99  observed_at: string;100  source_url: string | null;101  tier: number;102  confidence: string;103}104105export interface Claim {106  id: string;107  property: string;108  value: unknown;109  unit: string | null;110  tier: number;111  confidence: string;112  status: string;113  extractor: string;114  observed_at: string;115  effective_at: string | null;116  valid_from: string;117  valid_to: string | null;118  source_url: string | null;119  source_name: string | null;120}121122export interface SourceRef {123  source_id: string | null;124  source_name: string | null;125  domain: string | null;126  tier: number | null;127  url: string;128  doc_type: string;129  last_observed_at: string | null;130  snapshots: number;131}132133export interface RelationGroup {134  predicate: string;135  direction: 'out' | 'in';136  items: EntitySummary[];137  total: number;138}139140export interface Lineage {141  ancestors: EntitySummary[];142  descendants: EntitySummary[];143  quantizations: EntitySummary[];144}145146export interface HardwareFitRow {147  hardware: EntitySummary;148  quantization: string;149  estimated_memory_gb: number;150  fits: boolean;151}152153export interface EntityDetail extends EntitySummary {154  provenance: Provenance;155  aliases: string[];156  identifiers: { scheme: string; value: string }[];157  relations: RelationGroup[];158  sources: SourceRef[];159  timeline: ChangeEvent[];160  prices?: Price[];161  price_history?: Price[];162  results?: BenchmarkResult[];163  lineage?: Lineage;164  providers?: EntitySummary[];165  hardware_fit?: HardwareFitRow[];166  models?: Page<EntitySummary>;167  papers?: EntitySummary[];168  repositories?: EntitySummary[];169  // companies listing enrichments may also be present on detail170  model_count?: number;171  paper_count?: number;172}173174export interface Health {175  status: 'ok' | 'degraded' | string;176  version: string;177  db: boolean;178  redis: boolean;179  llm: { available: boolean; reachable?: boolean };180  time: string;181}182183export interface Stats {184  entities: Record<string, Num>;185  entities_total: Num;186  sources: Num;187  connectors: Num;188  connectors_enabled: Num;189  documents: Num;190  snapshots: Num;191  claims: Num;192  claims_current: Num;193  relations: Num;194  change_events: Num;195  change_events_24h: Num;196  change_events_7d: Num;197  benchmark_results: Num;198  prices_current: Num;199  prices_total: Num;200  review_pending: Num;201  llm_jobs: Num;202  llm_tokens: Num;203  last_snapshot_at: string | null;204  last_event_at: string | null;205  first_entity_at: string | null;206  archive: { raw_bytes: Num; raw_files: Num; text_bytes: Num; text_files: Num };207  computed_at: string;208  // ---- 1.1 additions (optional until the API stream lands)209  /** Change events observed in the last 24 h excluding historical backfill. */210  change_events_live_24h?: Num;211  /** How each counter is computed ("Models = canonical model releases; artifacts and folded variants excluded"). */212  definitions?: Record<string, string>;213  [k: string]: unknown;214}215216export interface StatsHistory {217  items: { day: string; counts: Record<string, Num> }[];218}219220/** Output of services.search.compile_query — shape is loose; we render what we recognise. */221export interface CompiledQuery {222  text?: string | null;223  q?: string | null;224  entity_type?: string | null;225  type?: string | null;226  filters?: Record<string, unknown>;227  [k: string]: unknown;228}229230export interface SearchPayload {231  query: CompiledQuery;232  items: (EntitySummary & { rank: number })[];233  total: number;234}235236export interface Suggestion {237  id: string;238  entity_type: string;239  slug: string;240  name: string;241  organization_name: string | null;242}243244export interface FacetValue {245  value: string;246  count: Num;247}248export interface OrgFacet {249  slug: string;250  name: string;251  count: Num;252}253export interface ModelFacets {254  organizations?: OrgFacet[];255  openness?: FacetValue[];256  modalities?: FacetValue[];257  families?: FacetValue[];258  years?: FacetValue[];259  licenses?: FacetValue[];260  status?: FacetValue[];261}262export type ModelsPage = Page<EntitySummary> & { facets?: ModelFacets };263264export type CompanyRow = EntitySummary & { model_count: Num; paper_count: Num };265export interface CompanyFacets {266  countries?: FacetValue[];267  kinds?: FacetValue[];268}269export type CompaniesPage = Page<CompanyRow> & { facets?: CompanyFacets };270271export type ProviderRow = EntitySummary & { model_count: Num; price_count: Num; min_input_per_mtok: Num; min_output_per_mtok: Num };272export type BenchmarkRow = EntitySummary & { result_count: Num; model_count: Num; top: { model: EntitySummary; score: number } | null };273274export interface PriceIndexPoint {275  day: string;276  median_input: Num;277  median_output: Num;278  min_input: Num;279  max_input?: Num;280  models: number;281  offers?: number;282}283export interface PriceIndex {284  days?: number;285  note?: string;286  series: PriceIndexPoint[];287  movers: ChangeEvent[];288}289290export interface HardwareFitItem {291  model: EntitySummary;292  parameter_count: number;293  estimated_memory_gb: number;294  fits: boolean;295  headroom_gb: number;296  quantization: string;297  note: string;298}299export interface HardwareFit {300  inputs: Record<string, unknown>;301  estimated?: boolean;302  counts?: { fits?: Num; evaluated?: Num };303  assumptions: string[];304  items: HardwareFitItem[];305}306307export interface ExploreType {308  entity_type: string;309  count: Num;310  label: string;311}312313export interface DailyDigest {314  date: string;315  counts: Record<string, Num>;316  sections: { category: string; label: string; items: ChangeEvent[]; key?: string; total?: Num }[];317  new_models: EntitySummary[];318  total?: Num;319  labels?: Record<string, string>;320  previous_day?: string | null;321  next_day?: string | null;322  /** 2.0: number of historical backfill events left out of the digest (honesty line). */323  backfill_excluded?: Num;324}325326/** 1.1 — `GET /frontier`: current leaders per benchmark family + recent frontier movements. Loose shape; render what is present. */327export interface FrontierPayload {328  leaders?: { benchmark: EntitySummary; model: EntitySummary; score: Num; metric?: string | null; since?: string | null; trust_level?: string | null }[];329  recent_frontier_movements?: ChangeEvent[];330  computed_at?: string;331  [k: string]: unknown;332}333334/** 1.1 — `GET /open?days=`: open-weight releases in the window. */335export interface OpenModelsPayload {336  items: EntitySummary[];337  total?: Num;338  days?: number;339  [k: string]: unknown;340}341342/** 1.1 — `GET /entities/{slug}/provenance/{property}`: the full evidence behind one displayed value. */343export interface ProvenanceDetail {344  slug?: string;345  property: string;346  value: unknown;347  unit?: string | null;348  claim_id?: string | null;349  source_id?: string | null;350  source_name?: string | null;351  domain?: string | null;352  url?: string | null;353  tier: number | null;354  confidence?: string | null;355  extractor?: string | null;356  observed_at?: string | null;357  valid_from?: string | null;358  valid_to?: string | null;359  status?: string | null;360  /** Other current/conflicting claims for the same property. */361  conflicts?: Claim[];362  history_count?: Num;363  snapshot_id?: string | null;364  [k: string]: unknown;365}366367/** 1.1 — `GET /pulse`: live activity summary (events/hour, connectors running…). Loose. */368export interface PulsePayload {369  events_24h?: Num;370  events_live_24h?: Num;371  per_hour?: { hour: string; count: Num }[];372  [k: string]: unknown;373}374375export interface ChangeCategories {376  items: { category: string; event_type: string; count: Num }[];377}378379export interface TimelinePayload {380  items: { month: string; count?: number; events: ChangeEvent[] }[];381  total?: number;382}383384/** Local watchlist item (`lib/watchlist.ts`, localStorage `aia-watchlist`). */385export interface WatchItem {386  slug: string;387  name: string;388  entity_type: string;389  org?: string | null;390  added_at?: string;391}392393export interface CompareDimension {394  key: string;395  label: string;396  unit?: string;397  kind: 'number' | 'text' | 'list' | 'bool' | 'date';398  /** Where the value comes from: `attr` (claims) · `prices` · `results` (benchmark) — informational. */399  source?: string;400}401export interface ComparePayload {402  entity_type: string;403  dimensions: CompareDimension[];404  items: { entity: EntitySummary; values: Record<string, unknown>; provenance: Provenance; prices?: Price[]; results?: BenchmarkResult[] }[];405}406407export interface DiffPayload {408  a: string;409  b: string;410  scope?: Record<string, unknown> | string;411  new_entities: EntitySummary[];412  gone_entities: EntitySummary[];413  property_changes: ChangeEvent[];414  price_changes: ChangeEvent[];415  benchmark_changes: ChangeEvent[];416  counts: Record<string, Num>;417}418419export interface ConnectorHealth {420  name: string;421  label: string;422  health: string;423  last_success_at: string | null;424  interval_seconds: Num;425}426export interface SourceRow {427  key: string;428  name: string;429  domain: string;430  tier: number;431  kind: string;432  category: string;433  organization: Org;434  enabled: boolean;435  documents: Num;436  last_crawled_at: string | null;437  connectors: ConnectorHealth[];438}439440export interface MetricDefinition {441  key?: string;442  name?: string;443  label?: string;444  description?: string;445  formula?: string;446  version?: string | number;447  unit?: string;448  [k: string]: unknown;449}450export interface Methodology {451  metrics: MetricDefinition[];452  confidence_levels: Record<string, string> | { key: string; label?: string; description?: string }[] | string[];453  tiers: Record<string, string> | { tier: number; label?: string; description?: string }[];454  event_types: Record<string, string> | { event_type: string; category?: string; label?: string; description?: string; importance?: number }[] | string[];455  extractors: Record<string, string> | { key?: string; name?: string; description?: string }[] | string[];456}457458export type TrendingRow = EntitySummary & { views: Num };459460export interface SitemapPayload {461  items: { slug: string; entity_type: string; updated_at: string }[];462  total: number;463}464465export interface GraphNode {466  id: string;467  slug: string;468  name: string;469  entity_type: string;470  organization_name?: string | null;471}472export interface GraphEdge {473  source: string;474  target: string;475  predicate: string;476}477export interface GraphPayload {478  root?: string;479  nodes: GraphNode[];480  edges: GraphEdge[];481}482483export interface AsOfPayload {484  id?: string;485  slug?: string;486  name?: string;487  entity_type?: string;488  existed: boolean;489  first_seen_at: string | null;490  date: string;491  attributes: Record<string, unknown>;492  claims: Claim[];493}494495// ---- D1 (models/benchmarks/compare) ----496/** 1.1 shapes consumed by the models · artifacts · families · benchmarks · compare · licences pages. Mirrors docs/API.md §1.1. */497export type IdentityConfidence = 'high' | 'medium' | 'low';498export interface FamilyRef {499  id: string | null;500  slug: string;501  name: string;502}503/** `/models` row (1.1): canonical model, or an artifact when `include=artifacts`. */504export type ModelRow = EntitySummary & { identity_confidence?: IdentityConfidence; family?: FamilyRef | null; canonical?: EntitySummary | null; artifact_kind?: string | null };505export interface FacetValue11 {506  value: string;507  label?: string;508  count: Num;509  canonical?: boolean;510  category?: string;511  raw_labels?: string[];512  raw?: boolean;513}514export interface ModelFacets11 {515  organizations?: OrgFacet[];516  openness?: FacetValue11[];517  modalities?: FacetValue11[];518  families?: FacetValue11[];519  years?: FacetValue11[];520  licenses?: FacetValue11[];521  status?: FacetValue11[];522  trust?: FacetValue11[];523  definitions?: Record<string, string>;524}525export type ModelsPage11 = Page<ModelRow> & { facets?: ModelFacets11; universe?: string };526527export interface DeploymentPrices {528  input: Num;529  cached_input: Num;530  cache_write: Num;531  output: Num;532  batch_input: Num;533  batch_output: Num;534  per_image: Num;535  per_request: Num;536  currency: string;537  unit: string;538  native_units: Record<string, unknown>;539}540export interface Deployment {541  id: string;542  model: EntitySummary;543  provider: EntitySummary;544  provider_model_id: string | null;545  context_length: Num;546  max_output_tokens: Num;547  prices: DeploymentPrices;548  features: Record<string, unknown>;549  status: 'active' | 'delisted' | string;550  observed_at: string;551  valid_from: string;552  valid_to: string | null;553  source_url: string | null;554  tier: number;555}556export interface Group {557  metric: string;558  config_key: string;559  label: string;560  n: number;561  model_count: number;562  config: Record<string, unknown>;563  higher_is_better: boolean;564  trust_mix: Record<string, number>;565}566export interface ModelRef {567  id: string;568  slug: string;569  name: string;570  entity_type: string;571  organization: Org;572  attributes: Record<string, unknown>;573}574export type Comparability = 'comparable' | 'partially-comparable' | 'not-comparable';575export interface LeaderboardRow {576  rank: number;577  model: ModelRef;578  score: number;579  metric: string;580  unit: string | null;581  higher_is_better: boolean;582  delta_rank: number | null;583  previous_rank: number | null;584  trust_level: string;585  trust_label: string;586  config: Record<string, unknown>;587  config_key: string;588  comparability: Comparability;589  comparability_reasons: string[];590  evaluated_at: string | null;591  observed_at: string;592  source_url: string | null;593  tier: number;594  result_id: string;595  n_rows: number;596}597export interface LicenseInfo {598  key: string;599  label: string;600  category: string;601  spdx: string | null;602  url: string | null;603  commercial_use: boolean | null;604  redistribution: boolean | null;605  derivatives: boolean | null;606  hosting_restrictions: boolean | null;607  attribution: boolean | null;608  acceptable_use: boolean | null;609  osi_approved: boolean;610  weights_downloadable: boolean;611}612export interface BenchmarkListItem {613  id: string;614  entity_type: string;615  slug: string;616  name: string;617  description?: string | null;618  category: string | null;619  family: string | null;620  variant: string | null;621  metric: string | null;622  unit: string | null;623  direction: 'higher' | 'lower' | string | null;624  attributes: Record<string, unknown>;625  result_count: Num;626  model_count: Num;627  leader: LeaderboardRow | null;628  second: LeaderboardRow | null;629  top: { model: EntitySummary; score: number } | null;630  primary_group: Group | null;631  groups: Group[];632  trust_mix: Record<string, number>;633  trust_labels: Record<string, string>;634  updated_at?: string;635}636export interface BenchmarksPayload {637  items: BenchmarkListItem[];638  total: Num;639  note?: string;640}641export interface BenchmarkDetail extends Omit<EntityDetail, 'model_count'> {642  family?: string | null;643  variant?: string | null;644  metric?: string | null;645  direction?: string | null;646  category?: string | null;647  groups?: Group[];648  primary_group?: Group | null;649  result_count?: Num;650  model_count?: Num;651  leaderboard?: LeaderboardRow[];652  trust_mix?: Record<string, number>;653}654export interface LeaderboardPayload {655  benchmark: EntitySummary;656  group: Group | null;657  groups: Group[];658  items: LeaderboardRow[];659  total: number;660  limit: number;661  offset: number;662  comparable_only: boolean;663  filters: Record<string, unknown>;664  history_available: boolean;665  methodology: string;666}667export interface FrontierPoint {668  date: string;669  model: ModelRef;670  score: number;671  trust_level: string;672  config: Record<string, unknown>;673  result_id: string;674}675export interface BenchmarkFrontierPayload {676  benchmark: EntitySummary;677  series: { group: Group; primary: boolean; points: FrontierPoint[]; current_leader: FrontierPoint | null }[];678  generated_at: string;679  methodology: string;680}681export interface MatrixColumn {682  id: string;683  slug: string;684  name: string;685  category: string | null;686  metric: string;687  config_key: string;688  group_label: string;689  higher_is_better: boolean;690  n_models: number;691}692export interface MatrixCell {693  score: number;694  rank: number;695  trust_level: string;696  config_key: string;697  comparability: Comparability;698  result_id: string;699}700export interface MatrixRow {701  model: { id: string; slug: string; name: string; organization: string | null; organization_slug: string | null; openness: string | null; release_date: string | null };702  cells: Record<string, MatrixCell | null>;703  n_cells: number;704  mean_rank: number | null;705}706export interface MatrixPayload {707  columns: MatrixColumn[];708  rows: MatrixRow[];709  total_rows: number;710  comparable_only: boolean;711  min_cells: number;712  methodology: string;713}714export interface ParetoPoint {715  id: string;716  model: { id: string; slug: string; name: string; organization: string | null; openness: string | null };717  x: number;718  y: number;719  rank: number;720  trust_level: string;721  config: Record<string, unknown>;722  provider?: EntitySummary | null;723  estimated?: boolean;724  pareto: boolean;725}726export interface ParetoPayload {727  benchmark: EntitySummary;728  group: Group | null;729  groups: Group[];730  x: { key: string; label: string };731  y: { key: string; label: string };732  points: ParetoPoint[];733  frontier: string[];734  methodology: string;735}736export interface FamilyRow {737  id: string | null;738  slug: string;739  name: string;740  canonical: boolean;741  entity_type: 'model_family' | string;742  organization: Org;743  model_count: Num;744  first_release: string | null;745  last_release: string | null;746  param_range: { min: Num; max: Num } | null;747  modalities: string[];748  licenses: { key: string; label: string; models: Num }[];749  benchmark_best: Record<string, { rank: number; model: string }>;750}751export interface FamilyMember {752  model: EntitySummary;753  key_facts: Record<string, unknown>;754  benchmark_ranks: Record<string, number>;755}756export interface FamilyDetail extends FamilyRow {757  summary: EntitySummary | null;758  members: FamilyMember[];759  artifacts_count: Num;760  providers: EntitySummary[];761  lineage: { source: string; target: string; predicate: string }[];762  timeline: { date: string | null; kind: string; model: { id: string; slug: string; name: string } }[];763  note: string | null;764}765export type FamiliesPage = Page<FamilyRow> & { note?: string };766export type LicenseRow = LicenseInfo & { aliases: string[]; models: Num };767export interface LicensesPayload {768  items: LicenseRow[];769  total: Num;770  categories: string[];771  unclassified: { raw: string; models: Num }[];772  note?: string;773}774export type LicenseDetail = LicenseInfo & { aliases: string[]; models: Page<EntitySummary> };775776export interface ModelIdentity {777  canonical_model: boolean;778  official_checkpoints: string[];779  official_artifacts: number;780  third_party_artifacts: number;781  provider_deployments: number;782  folded_variants: number;783  api_aliases: string[];784  note?: string;785}786export interface ModelOpenness {787  category: string;788  raw: string | null;789  label: string;790  definition: string;791  dimensions: Record<string, boolean | null>;792  note?: string;793}794export type ModelLicence = (LicenseInfo & { raw: string | null; url_observed: string | null }) | { key: null; raw: string | null; note?: string };795export interface VersionTransition {796  from: unknown;797  to: unknown;798  valid_from: string;799  valid_to: string | null;800  effective_at: string | null;801  source_url: string | null;802  tier: number;803  claim_id: string;804  status: string;805}806export interface VersionHistoryItem {807  property: string;808  transitions: VersionTransition[];809  current: unknown;810}811export interface ModelBenchmarkBest {812  score: number;813  unit: string | null;814  trust_level: string;815  trust_label: string;816  config: Record<string, unknown>;817  evaluated_at: string | null;818  observed_at: string;819  source_url: string | null;820  tier: number;821  result_id: string;822}823export interface ModelBenchmarkGroup {824  config_key: string;825  comparability_group: string;826  n_rows: number;827  higher_is_better: boolean;828  best: ModelBenchmarkBest;829  trust_levels: string[];830}831export interface ModelBenchmarks {832  items: { id: string; slug: string; name: string; category: string | null; metrics: { metric: string; groups: ModelBenchmarkGroup[] }[] }[];833  total_rows: number;834  note?: string;835}836export type ArtifactKind = 'checkpoint' | 'quantization' | 'conversion' | 'packaging';837export type ArtifactSummary = EntitySummary & { artifact_kind?: ArtifactKind | string | null };838export type FamilyBlock = EntitySummary | { id: null; name: string; canonical: false; note?: string } | null;839/** Model (or artifact) detail with the 1.1 blocks. */840export interface ModelDetail extends EntityDetail {841  redirected_from?: { slug: string; id: string; entity_type: string } | null;842  family?: FamilyBlock;843  artifacts?: { items: { kind: string; items: ArtifactSummary[]; count: number }[]; total: number };844  deployments?: Deployment[];845  identity?: ModelIdentity;846  licence?: ModelLicence | null;847  openness?: ModelOpenness | null;848  version_history?: VersionHistoryItem[];849  benchmarks?: ModelBenchmarks;850  family_id?: string | null;851  identity_confidence?: IdentityConfidence;852  hardware_fit_assumptions?: string[];853  canonical?: EntitySummary | null;854  artifact_kind?: ArtifactKind | string | null;855}856export interface CompareDimension11 extends CompareDimension {857  higher_is_better?: boolean;858  benchmark?: string;859  metric?: string;860  config_key?: string;861  comparability?: Comparability;862  trust_levels?: string[];863}864export interface ComparabilityInfo {865  level: Comparability;866  reasons: string[];867  trust: Record<string, { level: string; label: string }>;868}869export interface ComparePayload11 {870  entity_type: string;871  dimensions: CompareDimension11[];872  items: { entity: EntitySummary; values: Record<string, unknown>; provenance: Provenance; prices?: Price[]; results?: BenchmarkResult[]; deployments?: Deployment[] }[];873  comparability: Record<string, ComparabilityInfo>;874  diff_only: boolean;875  note?: string;876}877export type DiffDelta = { absolute: number; percent: number | null } | { added: unknown[]; removed: unknown[] } | null;878export interface ModelDiffPayload {879  a: EntitySummary;880  b: EntitySummary;881  dimensions: (CompareDimension11 & { a: unknown; b: unknown; delta: DiffDelta })[];882  comparability: Record<string, ComparabilityInfo>;883  note?: string;884}885export interface Methodology11 extends Methodology {886  openness?: { categories: string[]; labels: Record<string, string>; definitions: Record<string, string>; dimensions: string[]; note?: string };887  trust_levels?: { key: string; label: string }[];888  comparability?: Record<string, unknown> & { comparable?: string; 'partially-comparable'?: string; 'not-comparable'?: string };889  licence_categories?: string[];890  counters?: Record<string, string>;891  hardware_fit?: unknown;892}893// ---- /D1 ----894895// ---- D2 (intelligence) ----896// Reuses the D1 shapes above: Deployment · DeploymentPrices · Group · ModelRef · LeaderboardRow · LicenseInfo · ModelLicence · ParetoPoint · ParetoPayload.897export type DeploymentsPage = Page<Deployment> & { next_before?: string | null; current?: boolean };898/** 1.1 feed fields on events (`occurred_at = coalesce(effective_at, observed_at)`, backfill flag, semantic group). */899export type ChangeEventIntel = ChangeEvent & { occurred_at?: string; is_backfill?: boolean; group_key?: string | null; percent_change?: Num };900/** Event date to display: 1.1 `occurred_at`, else effective, else observed. */901export function eventDate(e: ChangeEventIntel): string {902  return e.occurred_at ?? e.effective_at ?? e.observed_at;903}904905/** 1.1 `Fit` — every hardware-fit figure is an estimate (`estimated: true`). */906export interface FitBreakdown {907  weights_gb: number;908  weights_source: 'observed' | 'estimated' | string;909  overhead_gb: number;910  kv_cache_gb: number;911  kv_cache_method: 'architecture' | 'heuristic' | string;912  reserved_gb: number;913  context: number;914  batch: number;915}916export interface Fit {917  quantization: string;918  estimated: true | boolean;919  fits: boolean | null;920  estimated_memory_gb: Num;921  headroom_gb: Num;922  parameter_count?: Num;923  breakdown?: FitBreakdown;924  device?: { memory_gb: number; gpu_count: number; total_memory_gb: number };925  note?: string | null;926  multi_gpu_note?: string | null;927}928929930export type BenchmarkRef = { id: string; slug: string; name: string; category?: string | null; entity_type?: string };931932/** `GET /frontier` (1.1) — every section is optional so partial payloads still render. */933export interface FrontierIntel {934  latest_major_models?: ChangeEventIntel[];935  benchmark_frontier?: { benchmark: BenchmarkRef; group: Group | null; leader: LeaderboardRow | null; second: LeaderboardRow | null; gap: Num }[];936  price_frontier?: {937    cheapest_output: Deployment | null;938    cheapest_output_1m_context: Deployment | null;939    frontier_models: Num;940    composition?: { recent_by_active_orgs?: Num; top10_on_a_benchmark?: Num; total?: Num; since?: string } | null;941  };942  context_frontier?: { model: EntitySummary; context_length: Num }[];943  open_weight_frontier?: { items: { model: EntitySummary; best_rank: Num; best_rank_on: string | null; parameter_count: Num; context_length: Num; ranks: Record<string, number> }[]; dimensions: string[]; note?: string };944  efficiency_frontier?: { quality: { benchmark: string; group: Group | null }; x: string; points: ParetoPoint[]; frontier: string[] };945  agentic_frontier?: { benchmark: BenchmarkRef; group: Group | null; leaders: LeaderboardRow[] }[];946  multimodal_frontier?: { model: ModelRef | EntitySummary; modalities: string[]; top10_on: string[] }[];947  recent_frontier_movements?: ChangeEventIntel[];948  generated_at?: string;949  methodology?: string;950}951952/** AI Price Index (1.1) — v1 keys kept, new medians and sample sizes per day. */953export interface PriceIndexPointIntel extends PriceIndexPoint {954  median_frontier_output?: Num;955  median_frontier_input?: Num;956  median_open_output?: Num;957  median_embedding_input?: Num;958  min_frontier_output?: Num;959  sample?: { models?: Num; offers?: Num; frontier_models?: Num; frontier_offers?: Num; open_models?: Num; embedding_models?: Num };960}961export interface PriceDistribution {962  metric: string;963  unit: string;964  buckets: { from: Num; to: Num; label: string; offers: Num }[];965  offers: Num;966}967export interface CheapestFrontier {968  model: EntitySummary;969  provider: EntitySummary;970  output: Num;971  input: Num;972  context_length: Num;973  price_id?: string;974}975export interface PriceIndexIntel {976  days?: number;977  series: PriceIndexPointIntel[];978  movers: ChangeEventIntel[];979  cheapest_frontier?: CheapestFrontier | null;980  cheapest_frontier_1m_context?: CheapestFrontier | null;981  distribution?: PriceDistribution | null;982  new_listings_30d?: Num | ChangeEvent[];983  delistings_30d?: Num | ChangeEvent[];984  price_changes_30d?: Num | ChangeEvent[];985  frontier?: { composition?: Record<string, unknown>; methodology?: string };986  methodology?: string;987  note?: string;988}989990/** `/providers` 1.1 aggregates. */991export interface PriceDistributionStats {992  min: Num;993  p25: Num;994  median: Num;995  p75: Num;996  max: Num;997  n: Num;998}999export type ProviderIntelRow = ProviderRow & {1000  input_price_distribution?: PriceDistributionStats | null;1001  output_price_distribution?: PriceDistributionStats | null;1002  models_added_30d?: Num;1003  models_removed_30d?: Num;1004  price_changes_30d?: Num;1005  organizations_covered?: Num;1006  features_supported?: string[];1007  feature_keys?: string[];1008};10091010/** `GET /cost` and `GET /cost/context`. */1011export interface CostItem {1012  deployment: Deployment;1013  cost: {1014    per_request: Num;1015    daily: Num;1016    monthly: Num;1017    annual: Num;1018    effective_input_per_mtok: Num;1019    effective_output_per_mtok: Num;1020    per_request_fee: Num;1021    inputs?: Record<string, unknown>;1022    notes: string[];1023  };1024}1025export interface CostPayload {1026  model: EntitySummary | null;1027  inputs: { input_tokens: Num; output_tokens: Num; requests_per_day: Num; cached_share: Num; batch: boolean };1028  items: CostItem[];1029  total: number;1030  currency: string;1031  methodology?: string;1032  note?: string | null;1033}1034export interface CostContextPayload {1035  tokens: number;1036  items: { deployment: Deployment; context_length: Num; context_source: 'offer' | 'model attribute' | string; cost_usd: Num }[];1037  total: number;1038  currency: string;1039  methodology?: string;1040  note?: string | null;1041}10421043/** `GET /run-locally`. */1044export interface RunLocallyArtifact {1045  artifact: EntitySummary;1046  quant_format: string | null;1047  file_size_gb: Num;1048  weights_source: 'observed' | 'estimated' | string;1049  fit: Fit;1050}1051export interface RunLocallyItem {1052  model: EntitySummary;1053  fit: Fit;1054  artifacts: RunLocallyArtifact[];1055  artifact_count: Num;1056}1057export interface RunLocallyPayload {1058  inputs: Record<string, unknown>;1059  estimated: boolean;1060  assumptions: string[];1061  counts: { fits?: Num; evaluated?: Num };1062  items: RunLocallyItem[];1063  note?: string;1064}1065/** `GET /hardware/{slug}/fit`. */1066export interface HardwareSlugFit {1067  hardware: EntitySummary;1068  memory_options_gb: number[];1069  inputs: Record<string, unknown>;1070  estimated: boolean;1071  assumptions: string[];1072  runtimes: string[];1073  counts: { fits?: Num; evaluated?: Num };1074  items: ({ model: EntitySummary } & Fit)[];1075  note?: string;1076}10771078/** `GET /find-a-model`. */1079export interface FinderMatch {1080  model: EntitySummary;1081  why: string[];1082  observed: Record<string, unknown> & { benchmark_ranks?: Record<string, number>; best_rank?: Num; providers?: Num; cheapest_input_per_mtok?: Num; cheapest_output_per_mtok?: Num };1083  estimated_fit?: Partial<Fit> | null;1084  deployments?: Deployment[] | null;1085}1086export interface FinderPayload {1087  matches: FinderMatch[];1088  total: number;1089  filters_applied: Record<string, unknown>;1090  rules: Record<string, string>;1091  note?: string;1092}10931094/** `GET /open` (1.1). */1095export interface OpenItem {1096  model: EntitySummary;1097  licence: ModelLicence;1098  dimensions: Record<string, unknown>;1099  best_results: { benchmark: string; rank: number }[];1100  best_rank: Num;1101  hardware_fit: { '4bit_64gb'?: Partial<Fit> | null; '8bit_128gb'?: Partial<Fit> | null; estimated?: boolean } | null;1102  providers: Num;1103  cheapest_output_per_mtok: Num;1104}1105export interface OpenPayload extends Page<OpenItem> {1106  summary?: { by_category?: Record<string, Num>; by_license_top?: { key: string; label: string; models: Num }[]; new_30d?: Num };1107  note?: string;1108}11091110/** `GET /pulse` (1.1). */1111export interface PulseCounter {1112  value: Num;1113  definition: string;1114  median_percent?: Num | null;1115  items?: unknown[] | null;1116}1117export interface PulseIntel {1118  days: number;1119  since: string;1120  until: string;1121  counters: Record<string, PulseCounter>;1122  note?: string;1123}1124export interface PulseLeaderItem {1125  benchmark: BenchmarkRef;1126  previous: { model: ModelRef; score: Num } | null;1127  current: { model: ModelRef; score: Num; metric?: string; group_label?: string; trust_level?: string; n_models?: Num; as_of?: string } | null;1128}11291130/** `/methodology` 1.1 additions read by the intelligence pages. */1131export interface MethodologyIntel {1132  openness?: { categories: string[]; labels: Record<string, string>; definitions: Record<string, string>; dimensions: string[]; note?: string };1133  hardware_fit?: { assumptions: string[]; bytes_per_param?: Record<string, number>; reserved_gb?: number };1134  frontier?: string;1135  find_a_model?: Record<string, string> | string;1136  licence_categories?: string[];1137  trust_levels?: { key: string; label: string }[];1138  counters?: Record<string, string> | string[];1139  [k: string]: unknown;1140}11411142/** `/hardware` facets (1.1). */1143export type HardwarePage = Page<EntitySummary> & { facets?: { kinds?: FacetValue[]; manufacturers?: FacetValue[] } };1144// ---- /D2 ----11451146// ---- D3 (temporal/graph/admin) ----1147/** 1.1 feed fields merged into the base event (declaration merging: additive, optional). */1148export interface ChangeEvent {1149  occurred_at?: string;1150  is_backfill?: boolean;1151  group_key?: string | null;1152}1153/** `GET /graph/explore` (1.1): typed neighbourhood explorer, one of seven modes. */1154export type GraphExploreMode = 'lineage' | 'research' | 'company' | 'benchmark' | 'dataset' | 'provider' | 'hardware';1155export interface ExploreNode {1156  id: string;1157  slug: string;1158  name: string;1159  entity_type: string;1160  org: string | null;1161  org_slug: string | null;1162  level: number;1163  artifact_kind: string | null;1164  attributes: Record<string, unknown>;1165}1166export interface ExploreEdge {1167  source: string;1168  target: string;1169  predicate: string;1170  attributes?: Record<string, unknown>;1171  tier?: number | null;1172}1173export interface GraphExplorePayload {1174  root: string;1175  mode: GraphExploreMode;1176  depth: number;1177  predicates: string[];1178  nodes: ExploreNode[];1179  edges: ExploreEdge[];1180  truncated: boolean;1181  counts: { nodes: Num; edges: Num; by_type: Record<string, Num> };1182}11831184/** `GET /time-machine` (1.1). */1185export interface TimeMachineModelRow {1186  model: EntitySummary;1187  attributes_as_of: Record<string, unknown>;1188  observed_then: boolean;1189  reconstructed: boolean;1190}1191export interface TimeMachineLeader {1192  benchmark: { id: string; slug: string; name: string; category?: string | null };1193  leader: { model: EntitySummary; score: number; metric: string | null; config_key?: string | null; group_label?: string | null; trust_level?: string | null; n_models?: Num; as_of?: string | null } | null;1194}1195export interface TimeMachinePayload {1196  date: string;1197  scope: string;1198  first_entity_at: string | null;1199  reconstructed: boolean;1200  note: string | null;1201  models?: { items: TimeMachineModelRow[]; total: Num; limit?: Num; note?: string };1202  prices?: { items: Price[]; total: Num; note?: string };1203  benchmarks?: { leaders: TimeMachineLeader[]; note?: string };1204  hardware?: { items: { hardware: EntitySummary; reconstructed?: boolean }[]; total?: Num; note?: string };1205}12061207/** `GET /diff` (1.1): v1 keys + the new sections. */1208export interface DiffPayload11 extends DiffPayload {1209  new_benchmark_leaders?: { benchmark: { id: string; slug: string; name: string; category?: string | null }; at_a: TimeMachineLeader['leader']; at_b: TimeMachineLeader['leader'] }[];1210  provider_changes?: ChangeEvent[];1211  hardware_changes?: ChangeEvent[];1212  context_changes?: ChangeEvent[];1213  retired_models?: (EntitySummary | ChangeEvent)[];1214  include_artifacts?: boolean;1215  include_backfill?: boolean;1216  note?: string;1217}12181219/** Today in AI 2.0 (`/changes/daily.today`). */1220export type TodayItem = ChangeEvent & { sources?: Num; documents?: string[]; grouped_events?: Num; event_ids?: string[] };1221export interface TodaySection {1222  key: string;1223  label: string;1224  items: TodayItem[];1225  total: Num;1226}1227export interface DailyDigest2 extends DailyDigest {1228  today?: TodaySection[];1229  date_field?: string;1230  note?: string;1231}1232export type ChangesPage = Page<ChangeEvent> & { next_before?: string | null; date_field?: string; include_backfill?: boolean };1233export interface TimelinePayload11 extends TimelinePayload {1234  date_field?: string;1235  include_backfill?: boolean;1236}12371238/** Search compiler v2. */1239export interface CompiledFilter {1240  filter: string;1241  label: string;1242  value: unknown;1243  source_span?: string | null;1244}1245export interface CompiledQuery2 extends CompiledQuery {1246  compiled?: CompiledFilter[];1247  sort?: string | null;1248  residual?: string | null;1249  unrecognised?: string[];1250  semantic?: boolean;1251  version?: number;1252  note?: string | null;1253}1254export type SearchPayload2 = Omit<SearchPayload, 'query'> & { query: CompiledQuery2 };12551256/** `GET /claims/{id}` and `GET /entities/{slug}/claims`. */1257export type ClaimRow = Claim & { snapshot_id?: string | null; run_id?: string | null; value_raw?: unknown; extractor_version?: string | null };1258export interface ClaimDetail {1259  claim: ClaimRow;1260  entity: EntitySummary | null;1261  property: string;1262  chain: { previous: ClaimRow[]; superseding: ClaimRow[]; conflicting: ClaimRow[]; history_count: Num };1263  source: { id: string | null; name: string | null; domain: string | null; tier: number | null; url: string | null; snapshot_id: string | null; observed_at: string | null } | null;1264  extractor: { name: string | null; version: string | null; confidence: string | null } | null;1265  run_id: string | null;1266  evidence: { snapshot_id: string | null; document_url: string | null; archived: boolean; snapshot_observed_at: string | null; document_title: string | null; doc_type: string | null } | null;1267  note?: string | null;1268}1269export interface EntityClaimsPayload {1270  entity: EntitySummary;1271  items: ClaimRow[];1272  total: number;1273  limit: number;1274  offset: number;1275  status: string;1276}12771278/** `GET /methodology` fields D3 renders beyond D1's `Methodology11` (loose: rendered as-is). */1279export interface MethodologyD3 extends Methodology11 {1280  quality_version?: string;1281  expected_fields?: Record<string, string[]>;1282  status_vocabulary?: string[];1283  anomaly_checks?: { check: string; severity: string; description: string }[];1284  event_semantics?: Record<string, string>;1285  frontier?: string | Record<string, unknown>;1286  find_a_model?: Record<string, string>;1287  principles?: string[];1288}12891290export interface SourcesPayload {1291  items: SourceRow[];1292  total?: Num;1293  tiers?: Record<string, string>;1294}1295export type SourceRow11 = SourceRow & { snapshots?: Num; claims?: Num; base_url?: string | null; robots_policy?: string | null; priority?: Num; notes?: string | null };12961297export interface TrendingPayload {1298  days: number;1299  kind: string;1300  items: (EntitySummary & { views?: Num; events?: Num; last_event_at?: string | null })[];1301  definition?: string;1302}1303// ---- /D3 ----1304