config.ts
query/config.ts
No strong subsystem tag
47
Lines
1808
Bytes
2
Exports
4
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 47 lines, 4 detected imports, and 2 detected exports.
Important relationships
Detected exports
QueryConfigbuildQueryConfig
Keywords
gatessessionidconfigisenvtruthyprocessgetsessionidcheckstatsigfeaturegate_cached_may_be_staleoncequeryfeature
Detected imports
../bootstrap/state.js../services/analytics/growthbook.js../types/ids.js../utils/envUtils.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { getSessionId } from '../bootstrap/state.js'
import { checkStatsigFeatureGate_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
import type { SessionId } from '../types/ids.js'
import { isEnvTruthy } from '../utils/envUtils.js'
// -- config
// Immutable values snapshotted once at query() entry. Separating these from
// the per-iteration State struct and the mutable ToolUseContext makes future
// step() extraction tractable — a pure reducer can take (state, event, config)
// where config is plain data.
//
// Intentionally excludes feature() gates — those are tree-shaking boundaries
// and must stay inline at the guarded blocks for dead-code elimination.
export type QueryConfig = {
sessionId: SessionId
// Runtime gates (env/statsig). NOT feature() gates — see above.
gates: {
// Statsig — CACHED_MAY_BE_STALE already admits staleness, so snapshotting
// once per query() call stays within the existing contract.
streamingToolExecution: boolean
emitToolUseSummaries: boolean
isAnt: boolean
fastModeEnabled: boolean
}
}
export function buildQueryConfig(): QueryConfig {
return {
sessionId: getSessionId(),
gates: {
streamingToolExecution: checkStatsigFeatureGate_CACHED_MAY_BE_STALE(
'tengu_streaming_tool_execution2',
),
emitToolUseSummaries: isEnvTruthy(
process.env.CLAUDE_CODE_EMIT_TOOL_USE_SUMMARIES,
),
isAnt: process.env.USER_TYPE === 'ant',
// Inlined from fastMode.ts to avoid pulling its heavy module graph
// (axios, settings, auth, model, oauth, config) into test shards that
// didn't previously load it — changes init order and breaks unrelated tests.
fastModeEnabled: !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_FAST_MODE),
},
}
}