/** * JIT layer-2 tools (T1.2 + T1.3) — configuration surface. * * `team-mode.jsonc` is the ONLY configuration source. The registry in * `config-layers.ts` carries each key's default and doc; `resolveConfig` * validates, clamps and fills defaults from it. There is no `TM_*` config * env var any more (the three internal/test switches — TM_STORE_RECLAIM, * TM_V2_PROBE, TM_CONFIG_AUTOCREATE — are read where they are used, not here). * * Invalid values never crash plugin startup: a non-numeric number falls back to * its default, an out-of-range number is CLAMPED to `min`/`max`, a wrong * type falls back to the default (same fail-soft philosophy as * blackboard.resolveTtlMs and envprotect.resolveEnvProtectMode). * * Token 口径 (estimate basis): CJK-range code points ≈ one token each, * everything else tokens ≈ chars/4, ceil. Pure chars/4 under-counted CJK * up to 4× — the LESS-governed direction for CJK-heavy payloads — so CJK * now counts as a full token (offload earlier, the safe direction). Two * design choices keep the estimate honest: the conservative boundary * (estimate == threshold still offloads) and the hard preview cap. This * 口径 is pinned by test-tm-tools.mjs. * * Naming note: `blackboardDir` (this module, run-payload store, default * AUTO = `/.git/opencode-team/blackboard`) is a DIFFERENT artifact * from the team blackboard in blackboard.ts (`.git/opencode-team/`, * plugin options). They share a root philosophy (TTL sweeper is the sole * cleanup path), not code. */ import { DEFAULT_BASH_READONLY_ALLOWED, DEFAULT_WEBFETCH_DOMAINS, type ConfigKeySpec } from "./config-layers.js"; export { DEFAULT_BASH_READONLY_ALLOWED, DEFAULT_WEBFETCH_DOMAINS }; export interface TmConfig { /** Offload boundary in estimated tokens (estimate == threshold offloads). */ offloadThreshold: number; /** Raw lines a preview builder may scan before summarizing. */ previewLines: number; /** Hard preview cap in estimated tokens — preview bloat is an R4 regression. */ previewMaxTokens: number; /** Single tm_fetch segment cap in lines. */ fetchMaxLines: number; /** Run-payload store dir. Empty = AUTO (/.git/opencode-team/blackboard, * tmpdir fallback); explicit value = absolute, or relative to project root. */ blackboardDir: string; /** Trajectory store dir. Empty = AUTO (/.git/opencode-team/trajectory, * tmpdir fallback); explicit value = absolute, or relative to project root. */ trajectoryDir: string; /** Handle TTL in days (expire_at + physical sweep of expired run dirs). */ blackboardTtlDays: number; /** P3 read-only command allowlist for tm_bash. */ bashReadonlyAllowed: string[]; /** tm_webfetch domain allowlist (subdomains included; "*" = any host). */ webfetchAllowedDomains: string[]; /** tm_memory GLOBAL scope dir. Empty = auto (~/.opencode-team/memories/global * — user-level, follows the user across projects). */ memoryGlobalDir: string; /** tm_memory session-scope entry TTL in minutes (lazy + boot sweep). */ memorySessionTtlMin: number; /** tm_memory max entries per scope (project / global); over the cap, * add fails with a compact/forget hint. */ memoryMaxEntries: number; /** tm_memory staleness marker age in days; 0 disables `[stale Nd]`. */ memoryStaleDays: number; /** tm_memory session persistence: "" (default) = ephemeral in-process * Map only; "1" = also write under /memories/sessions//. */ memorySessionPersist: string; /** tm_search default engine when no explicit `engine` arg is given. */ searchDefaultEngine: string; /** Hits kept per engine leg AND in the final fused list. */ searchMaxHits: number; /** Per-engine fusion weight overrides (`bing=0.2,hn=0.3`). */ searchWeights: Record; /** Engines removed from the roster AND from every auto route. */ searchDisabledEngines: string[]; /** Weight multiplier applied to a ZERO-overlap hit. */ searchRelevanceFloor: number; /** Offload boundary (estimated tokens) for the markdown/text/log prose * class. Inherits an explicitly-set `offloadThreshold` when this key is * not set; an explicit value always wins. */ offloadThresholdText: number; /** Offload boundary for the json/csv/code/binary data class. Inherits the * global exactly like the text tier. */ offloadThresholdData: number; /** URL-level cache TTL in seconds (0 disables). */ webCacheTtlSec: number; /** The ceiling on tm_join's bounded wait (ms). */ joinMaxWaitMs: number; /** tm_board_write: one board file's character cap and one session folder's file cap. */ boardMaxChars: number; boardMaxFiles: number; /** Keep the HOST's own background sub-agent reply inside our context budget. */ taskOffload: "on" | "off"; /** Reclaim the store layout an upgrade left behind. */ storeReclaim: "on" | "off"; /** Floor (minutes) for the (v1) approval-gate ask timeout. ORPHANED. */ askTimeoutFloorMin: number; /** Ceiling (ms) forced onto the built-in bash tool's `timeout` ARG. */ bashTimeoutMaxMs: number; /** Ceiling (ms) for a bash command the P3 read-only allowlist accepts. */ bashTimeoutProbeMs: number; /** Sub-agent concurrency ceiling (running children + in-flight dispatches). * `0` = unlimited, and then no decision is taken at all. */ subagentConcurrency: number; /** JIT governance over the HOST's own tools (read/grep/shell…). */ nativeOffload: "on" | "off"; /** (v1-only) tm_ptc_run's web bridge. */ ptcWebBridge: "on" | "off"; /** Extra hit-domain blacklist entries (merged with the built-in default). */ hitBlacklist: string[]; /** R6 extra deny rules (raw `K=V;K2=V2`-style string). */ envProtectExtraDeny: string; /** (v1-only) shell env passthrough. */ shellEnv: string; /** (v1-only) compaction survival list. */ compactionContext: "on" | "off"; /** R6 mode (strict/standard/off). */ envProtect: string; /** R6 fine-grained ask policy; "off" = every shell command asks. */ r6FineAsk: string; /** Private-space policy (allow/deny/ask). */ privateSpace: string; /** v2 tool delivery: "direct" sends options.codemode=false; "" = catalog. */ v2CodeMode: string; /** Context pruning (settled messages → pointers). */ prune: "on" | "off"; /** Percent of the window at which pruning starts. */ pruneAtPercent: number; /** Percent of the window kept verbatim at the tail. */ pruneKeepTailPercent: number; /** 修剪前先离载(stub 带 tm_fetch 句柄);off = 纯注记、原文不保留。 */ pruneOffload: "on" | "off"; /** 修剪保护正则(逗号分隔,命中任一的消息永不修剪);空串 = 关闭。 */ pruneProtectPatterns: string; /** Retry governor (recognise throttle + inject wait + cooldown). */ retry: "on" | "off"; retryBaseMs: number; retryMaxMs: number; retryJitter: number; retryBreakAfter: number; retryCooldownMs: number; retryMaxRetries: number; retryChainGapMs: number; /** Split advice when a dispatch brief is oversized. */ splitAdvice: "on" | "off"; splitBriefTokens: number; splitMaxCriteria: number; /** Code Mode adoption hint after a run of native calls. */ probeChain: "on" | "off"; probeChainAfter: number; /** Token budget a native browser snapshot keeps (addressing lines). */ nativeSnapshotMaxTokens: number; /** Token budget a native report keeps (tables). */ nativeReportMaxTokens: number; /** The native `browser_*` catalog gate. */ v2BrowserGate: "on" | "off"; /** tm_ledger per-session item cap. */ ledgerMaxItems: number; /** 任务状态卡:请求侧 JIT 状态注入(`on` / `off`)。 */ stateCard: "on" | "off"; /** 易变上下文(状态卡/窗口/重试/拆分建议)作为请求末尾的一条消息;`off` = 旧的 system 注入。 */ dynamicTail: "on" | "off"; } /** The registry's defaults, keyed by canonical key. Derived from * `CONFIG_KEYS` so a default can never drift from its spec. */ export declare const TM_CONFIG_DEFAULTS: Record; /** TM_SEARCH_WEIGHTS — `bing=0.2,hn=0.3` into a partial weight table. A * malformed pair is dropped (not the whole var), so one typo cannot silently * flatten every custom weight back to the built-in table. Kept for the * string form; a file value is native JSON and skips this. */ export declare function parseWeightsEnv(raw: unknown): Record; /** * Parse a comma/semicolon-separated allowlist string. Unset/absent -> null * (caller applies the default). An explicitly EMPTY string parses to [] * (deny-all) — an explicit user choice is respected. Kept for the string * form; a file value is native JSON and skips this. */ export declare function parseAllowlistEnv(raw: unknown): string[] | null; /** Historical alias — identical grammar to parseAllowlistEnv. */ export declare const parseWebfetchAllowlistEnv: typeof parseAllowlistEnv; /** TM_PTC_WEB_BRIDGE — off only on an explicit off-ish value; unset or * invalid keeps the bridge on (fail-soft toward the newer default). */ export declare function resolveOnOff(raw: unknown): "on" | "off"; /** * Coerce ONE raw value against its spec. `undefined`/`null` -> the default. * A `number` is truncated when the default is an integer, then clamped to * `min`/`max`; a non-numeric value falls back to the default. A `string` * with an `enum` must match (case-insensitively; on/off also accept the * 0/1/false/true/no/yes spellings); otherwise the default. A `string[]` * must be an array of strings; a `record` a plain object of numbers. */ export declare function coerceValue(spec: ConfigKeySpec, raw: unknown): unknown; /** * Resolve the full tm-tools config from an already-merged JSON value record * (the file layers, plus any programmatic `configDefaults`). Registry-driven: * every key gets its coerced value or its default. The two offload tiers * INHERIT an explicitly-set `offloadThreshold` when they are not set * themselves (Wave B M1) — a user who raised the global to save tokens must * not have prose silently capped back to 4000. */ export declare function resolveConfig(values?: Record): TmConfig; /** Token cost of ONE code point — CJK-range ≈ 1 token (kana / Hangul / * fullwidth / CJK punctuation all sit above U+2E80), everything else ≈ 0.25 * (chars/4). Shared by estimateTokens and preview.capTokens so the two * can never drift apart (a chars/4 cap would under-count CJK bodies 4×). */ export declare function tokenCostOf(cp: number): number; /** * Token estimate — CJK-aware: CJK-range code points count ≈ one token each, * everything else chars/4, ceil. The pure chars/4 basis under-counted CJK * up to 4× (one CJK char ≈ one token), which let CJK-heavy payloads ride * inline PAST the threshold — a mis-estimate in the LESS-governed * direction. Counting CJK as a full token errs the other way (offload * earlier), the safe direction for context size. The conservative * boundary (estimate == threshold still offloads) is unchanged. Empty * input = 0. */ export declare function estimateTokens(text: string): number; /** * Offload decision. estimate == threshold ALSO offloads — the conservative * boundary (HUMAN-pinned spec: "等于阈值也卸载"). */ export declare function shouldOffload(tokens: number, threshold: number): boolean; /** Collapse whitespace and hard-cap a string for messages / clue lines. */ export declare function shorten(text: unknown, max: number): string; //# sourceMappingURL=config.d.ts.map