πŸ“„ File detail

query/deps.ts

🧩 .tsπŸ“ 41 linesπŸ’Ύ 1,445 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œquery/”, which covers the query pipeline (budgets, hooks, engine config, stop conditions). On the API surface it exposes QueryDeps and productionDeps β€” mainly functions, hooks, or classes. Dependencies touch crypto. It composes internal code from services (relative imports).

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import { randomUUID } from 'crypto' import { queryModelWithStreaming } from '../services/api/claude.js' import { autoCompactIfNeeded } from '../services/compact/autoCompact.js' import { microcompactMessages } from '../services/compact/microCompact.js'

πŸ“€ Exports (heuristic)

  • QueryDeps
  • productionDeps

πŸ“š External import roots

Package roots from from "…" (relative paths omitted).

  • crypto

πŸ–₯️ Source preview

import { randomUUID } from 'crypto'
import { queryModelWithStreaming } from '../services/api/claude.js'
import { autoCompactIfNeeded } from '../services/compact/autoCompact.js'
import { microcompactMessages } from '../services/compact/microCompact.js'

// -- deps

// I/O dependencies for query(). Passing a `deps` override into QueryParams
// lets tests inject fakes directly instead of spyOn-per-module β€” the most
// common mocks (callModel, autocompact) are each spied in 6-8 test files
// today with module-import-and-spy boilerplate.
//
// Using `typeof fn` keeps signatures in sync with the real implementations
// automatically. This file imports the real functions for both typing and
// the production factory β€” tests that import this file for typing are
// already importing query.ts (which imports everything), so there's no
// new module-graph cost.
//
// Scope is intentionally narrow (4 deps) to prove the pattern. Followup
// PRs can add runTools, handleStopHooks, logEvent, queue ops, etc.
export type QueryDeps = {
  // -- model
  callModel: typeof queryModelWithStreaming

  // -- compaction
  microcompact: typeof microcompactMessages
  autocompact: typeof autoCompactIfNeeded

  // -- platform
  uuid: () => string
}

export function productionDeps(): QueryDeps {
  return {
    callModel: queryModelWithStreaming,
    microcompact: microcompactMessages,
    autocompact: autoCompactIfNeeded,
    uuid: randomUUID,
  }
}