TansrConfig
type TansrConfig = { $schemaVersion: 1; audit?: { dir?: string; enabled?: boolean; }; budget?: { maxTotalTokens?: number; maxUsd?: number; onExceeded: "block" | "warn"; }; effort?: "max" | "low" | "medium" | "high"; fallbacks: Record<string, string[]>; hooks?: { allowManagedHooksOnly?: boolean; disableAllHooks?: boolean; PermissionDenied?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PermissionRequest?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PostToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PreToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; SessionEnd?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; SessionStart?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; Stop?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; UserPromptSubmit?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; }; locale?: string; mcpServers?: Record<string, | { args?: string[]; command: string; cwd?: string; enabled?: boolean; env?: Record<string, string>; load?: "lazy" | "eager"; pool?: { connections?: number; maxInflightPerConnection?: number; queueTimeoutMs?: number; }; reconnect?: { enabled?: boolean; initialBackoffMs?: number; maxAttempts?: number | null; maxBackoffMs?: number; }; toolAllowlist?: string[]; transport: "stdio"; } | { enabled?: boolean; headers?: Record<string, string>; load?: "lazy" | "eager"; pool?: { connections?: number; maxInflightPerConnection?: number; queueTimeoutMs?: number; }; reconnect?: { enabled?: boolean; initialBackoffMs?: number; maxAttempts?: number | null; maxBackoffMs?: number; }; toolAllowlist?: string[]; transport: "http"; url: string; }>; modelAliases: { fast?: string; main?: string; reasoning?: string; }; outputStyle?: string; permissions?: { allow?: string[]; ask?: string[]; classifier?: { callBudget?: number | "off"; enabled?: boolean; tightenOutsideAuto?: boolean; }; defaultMode?: | "default" | "acceptEdits" | "plan" | "bypassPermissions" | "auto" | "dontAsk"; deny?: string[]; disableBaselineProtection?: boolean; projectAskBudget?: number | "off"; recommendedRules?: boolean; }; policy?: { trust?: { keys: Record<string, string>; unsignedPolicy?: "accept" | "reject"; }; }; providers: Record<string, { auth?: { env: string; }; baseUrl: string; capability?: { background?: boolean; defaultContextWithoutModifier?: number; effectiveContext?: number; hostedTools?: string[]; inputModalities: { document: "supported" | "rejected" | "silently_dropped"; image: "supported" | "rejected" | "silently_dropped"; }; maxContext: number; maxOutput?: number; modelModifiers: string[]; promptCaching: { maxBreakpoints?: number; minCacheableTokens?: number; mode: "explicit" | "implicit" | "ignored"; ttlSeconds?: number; }; quirks: { claudeModelNameMapping: boolean; countTokensEndpoint?: boolean; maxTokensExcludesReasoning?: boolean; minTimeoutMs?: number; modelsEndpoint?: boolean; stopSequences?: "ignored" | "honored" | "misreported_end_turn"; streamUsageLocation?: "message_start" | "message_delta" | "both"; systemRoleInMessages: boolean; unknownModelFallback: boolean; }; reasoning?: boolean; sampling: { temperature?: { clampEpsilon: number; max: number; maxExclusive: boolean; min: number; minExclusive: boolean; }; temperatureFixed?: number; temperatureRange?: [number, number]; }; thinking: { budgetMaxTokens?: number; budgetTokens: "ignored" | "honored"; cannotDisable: boolean; effortParam?: string; mustEchoBack: boolean; signatureShape?: "opaque" | "always_empty" | "absent"; toggleValues: string[]; }; thinkingOptional?: boolean; toolChoice: boolean; vision: boolean; }; models: Record<string, string>; pricing?: Record<string, { cachedInputPerMillion?: number; inputPerMillion: number; outputPerMillion: number; peakMultiplier?: number; tiers?: { cachedInputPerMillion?: number; inputPerMillion: number; outputPerMillion: number; upToInputTokens?: number; }[]; }>; protocol: "anthropic" | "openai" | "openai-responses" | "twp"; }>; sandbox?: { allowWrite?: string[]; mode?: "off" | "on" | "required"; network?: "allow" | "deny"; }; semanticIndex?: { branch?: string; repoId?: string; timeoutMs?: number; topK?: number; url?: string; }; telemetry: { enabled: boolean; }; ui?: { theme?: "dark" | "light" | "high-contrast" | "colorblind"; }; verify?: { command?: string; timeoutMs?: number; }; workspaceTrust?: { enforce?: boolean; };};五层合并后的完整配置(TansrConfigSchema 推导)。
$schemaVersion
Section titled “$schemaVersion”$schemaVersion: 1;audit?
Section titled “audit?”optional audit?: { dir?: string; enabled?: boolean;};optional dir?: string;enabled?
Section titled “enabled?”optional enabled?: boolean;budget?
Section titled “budget?”optional budget?: { maxTotalTokens?: number; maxUsd?: number; onExceeded: "block" | "warn";};maxTotalTokens?
Section titled “maxTotalTokens?”optional maxTotalTokens?: number;maxUsd?
Section titled “maxUsd?”optional maxUsd?: number;onExceeded
Section titled “onExceeded”onExceeded: "block" | "warn";effort?
Section titled “effort?”optional effort?: "max" | "low" | "medium" | "high";fallbacks
Section titled “fallbacks”fallbacks: Record<string, string[]>;hooks?
Section titled “hooks?”optional hooks?: { allowManagedHooksOnly?: boolean; disableAllHooks?: boolean; PermissionDenied?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PermissionRequest?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PostToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; PreToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; SessionEnd?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; SessionStart?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; Stop?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[]; UserPromptSubmit?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string; }[];};allowManagedHooksOnly?
Section titled “allowManagedHooksOnly?”optional allowManagedHooksOnly?: boolean;disableAllHooks?
Section titled “disableAllHooks?”optional disableAllHooks?: boolean;PermissionDenied?
Section titled “PermissionDenied?”optional PermissionDenied?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];PermissionRequest?
Section titled “PermissionRequest?”optional PermissionRequest?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];PostToolUse?
Section titled “PostToolUse?”optional PostToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];PreToolUse?
Section titled “PreToolUse?”optional PreToolUse?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];SessionEnd?
Section titled “SessionEnd?”optional SessionEnd?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];SessionStart?
Section titled “SessionStart?”optional SessionStart?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];optional Stop?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];UserPromptSubmit?
Section titled “UserPromptSubmit?”optional UserPromptSubmit?: { hooks: ( | { command: ...[]; timeoutMs?: ... | ...; type: "command"; } | { headers?: ... | ...; timeoutMs?: ... | ...; type: "http"; url: string; })[]; matcher?: string;}[];locale?
Section titled “locale?”optional locale?: string;mcpServers?
Section titled “mcpServers?”optional mcpServers?: Record<string, | { args?: string[]; command: string; cwd?: string; enabled?: boolean; env?: Record<string, string>; load?: "lazy" | "eager"; pool?: { connections?: number; maxInflightPerConnection?: number; queueTimeoutMs?: number; }; reconnect?: { enabled?: boolean; initialBackoffMs?: number; maxAttempts?: number | null; maxBackoffMs?: number; }; toolAllowlist?: string[]; transport: "stdio";} | { enabled?: boolean; headers?: Record<string, string>; load?: "lazy" | "eager"; pool?: { connections?: number; maxInflightPerConnection?: number; queueTimeoutMs?: number; }; reconnect?: { enabled?: boolean; initialBackoffMs?: number; maxAttempts?: number | null; maxBackoffMs?: number; }; toolAllowlist?: string[]; transport: "http"; url: string;}>;modelAliases
Section titled “modelAliases”modelAliases: { fast?: string; main?: string; reasoning?: string;};optional fast?: string;optional main?: string;reasoning?
Section titled “reasoning?”optional reasoning?: string;outputStyle?
Section titled “outputStyle?”optional outputStyle?: string;permissions?
Section titled “permissions?”optional permissions?: { allow?: string[]; ask?: string[]; classifier?: { callBudget?: number | "off"; enabled?: boolean; tightenOutsideAuto?: boolean; }; defaultMode?: | "default" | "acceptEdits" | "plan" | "bypassPermissions" | "auto" | "dontAsk"; deny?: string[]; disableBaselineProtection?: boolean; projectAskBudget?: number | "off"; recommendedRules?: boolean;};allow?
Section titled “allow?”optional allow?: string[];optional ask?: string[];classifier?
Section titled “classifier?”optional classifier?: { callBudget?: number | "off"; enabled?: boolean; tightenOutsideAuto?: boolean;};classifier.callBudget?
Section titled “classifier.callBudget?”optional callBudget?: number | "off";classifier.enabled?
Section titled “classifier.enabled?”optional enabled?: boolean;classifier.tightenOutsideAuto?
Section titled “classifier.tightenOutsideAuto?”optional tightenOutsideAuto?: boolean;defaultMode?
Section titled “defaultMode?”optional defaultMode?: | "default" | "acceptEdits" | "plan" | "bypassPermissions" | "auto" | "dontAsk";optional deny?: string[];disableBaselineProtection?
Section titled “disableBaselineProtection?”optional disableBaselineProtection?: boolean;projectAskBudget?
Section titled “projectAskBudget?”optional projectAskBudget?: number | "off";recommendedRules?
Section titled “recommendedRules?”optional recommendedRules?: boolean;policy?
Section titled “policy?”optional policy?: { trust?: { keys: Record<string, string>; unsignedPolicy?: "accept" | "reject"; };};trust?
Section titled “trust?”optional trust?: { keys: Record<string, string>; unsignedPolicy?: "accept" | "reject";};trust.keys
Section titled “trust.keys”keys: Record<string, string>;trust.unsignedPolicy?
Section titled “trust.unsignedPolicy?”optional unsignedPolicy?: "accept" | "reject";providers
Section titled “providers”providers: Record<string, { auth?: { env: string; }; baseUrl: string; capability?: { background?: boolean; defaultContextWithoutModifier?: number; effectiveContext?: number; hostedTools?: string[]; inputModalities: { document: "supported" | "rejected" | "silently_dropped"; image: "supported" | "rejected" | "silently_dropped"; }; maxContext: number; maxOutput?: number; modelModifiers: string[]; promptCaching: { maxBreakpoints?: number; minCacheableTokens?: number; mode: "explicit" | "implicit" | "ignored"; ttlSeconds?: number; }; quirks: { claudeModelNameMapping: boolean; countTokensEndpoint?: boolean; maxTokensExcludesReasoning?: boolean; minTimeoutMs?: number; modelsEndpoint?: boolean; stopSequences?: "ignored" | "honored" | "misreported_end_turn"; streamUsageLocation?: "message_start" | "message_delta" | "both"; systemRoleInMessages: boolean; unknownModelFallback: boolean; }; reasoning?: boolean; sampling: { temperature?: { clampEpsilon: number; max: number; maxExclusive: boolean; min: number; minExclusive: boolean; }; temperatureFixed?: number; temperatureRange?: [number, number]; }; thinking: { budgetMaxTokens?: number; budgetTokens: "ignored" | "honored"; cannotDisable: boolean; effortParam?: string; mustEchoBack: boolean; signatureShape?: "opaque" | "always_empty" | "absent"; toggleValues: string[]; }; thinkingOptional?: boolean; toolChoice: boolean; vision: boolean; }; models: Record<string, string>; pricing?: Record<string, { cachedInputPerMillion?: number; inputPerMillion: number; outputPerMillion: number; peakMultiplier?: number; tiers?: { cachedInputPerMillion?: number; inputPerMillion: number; outputPerMillion: number; upToInputTokens?: number; }[]; }>; protocol: "anthropic" | "openai" | "openai-responses" | "twp";}>;sandbox?
Section titled “sandbox?”optional sandbox?: { allowWrite?: string[]; mode?: "off" | "on" | "required"; network?: "allow" | "deny";};allowWrite?
Section titled “allowWrite?”optional allowWrite?: string[];optional mode?: "off" | "on" | "required";network?
Section titled “network?”optional network?: "allow" | "deny";semanticIndex?
Section titled “semanticIndex?”optional semanticIndex?: { branch?: string; repoId?: string; timeoutMs?: number; topK?: number; url?: string;};branch?
Section titled “branch?”optional branch?: string;repoId?
Section titled “repoId?”optional repoId?: string;timeoutMs?
Section titled “timeoutMs?”optional timeoutMs?: number;optional topK?: number;optional url?: string;telemetry
Section titled “telemetry”telemetry: { enabled: boolean;};enabled
Section titled “enabled”enabled: boolean;optional ui?: { theme?: "dark" | "light" | "high-contrast" | "colorblind";};theme?
Section titled “theme?”optional theme?: "dark" | "light" | "high-contrast" | "colorblind";verify?
Section titled “verify?”optional verify?: { command?: string; timeoutMs?: number;};command?
Section titled “command?”optional command?: string;timeoutMs?
Section titled “timeoutMs?”optional timeoutMs?: number;workspaceTrust?
Section titled “workspaceTrust?”optional workspaceTrust?: { enforce?: boolean;};enforce?
Section titled “enforce?”optional enforce?: boolean;本文是否有帮助?
感谢反馈,我们会持续改进这篇文章。