Preflight

loom-builder-solsourcetypescript
Path: loom-builder-sol/src/preflight.tsRelative: src/preflight.tsSubproject: loom-builder-solCategory: dispatch-system-sol
Lines: 183Bytes: 6,119Imports: 6Exports: 4

Content Preview

  1. import { readFileSync } from "node:fs";
  2. import { globSync } from "glob";
  3. import { resolve, relative } from "node:path";
  4. import type { DispatchSpec } from "./types.js";
  5. import { lintSpec, ensureValidation } from "./spec_lint.js";
  6. import { preferredPiExecutable, validatePiExecutable } from "./pi-executable.js";
  7. const TOKENS_PER_BYTE = 1 / 4; // conservative estimate: 1 token ≈ 4 bytes
  8. const PREFLIGHT_THRESHOLD = 100_000; // refuse dispatch above 100K estimated tokens
  9. /**
  10. * Estimate input tokens