/** * On by default for a client we did not launch. * * THE PROBLEM THIS SOLVES. Everything else here routes a client by setting a variable in the * process we spawn, which only reaches people who type `claude` in a shell we wrapped. The * documented install is `/plugin`, and those users start Claude Code from a shortcut, an IDE or a * desktop app -- so compression was off for them, and the doctor reported that as a broken install * rather than as a feature that never applied. * * Claude Code reads `env` from settings.json at startup, which is the one lever that reaches a * session we did not start. Using it means writing to a file the user owns, so: * * RECORDED. Every value we write is recorded in our own manifest next to what was there before. * Removal restores the previous value exactly, and refuses when the current value is not the one * we wrote -- a user who edited it since owns it again. * * NEVER WRITTEN ON HOPE. The entry is written only after the supervisor has actually served the * route, because a settings file naming a dead port does not degrade politely: Claude Code cannot * reach Anthropic at all. * * SELF-HEALING. Session start calls this again. If the supervisor cannot be brought up, the entry * is removed there and then, so at most one session is affected and the next one is clean. * * THE USER'S ENDPOINT IS THE UPSTREAM. Someone already pointed at a gateway or a proxy of their * own keeps reaching it; we insert ourselves in front of that value and record it as the one to * restore. */ export interface RoutingEntry { readonly variable: string; readonly value: string; /** What the file said before we ever touched it; absent when the variable was not set. */ readonly previous?: string; /** Whether the settings file had no `env` object at all before we wrote one. */ readonly createdEnv?: boolean; readonly upstream: string; readonly writtenAt: string; } export interface RoutingManifest { readonly schema: 1; readonly entries: Record; } export interface RoutingResult { readonly status: 'written' | 'unchanged' | 'removed' | 'healed' | 'absent' | 'disabled' | 'no-client' | 'unreadable' | 'unavailable' | 'foreign-proxy' | 'user-owned'; readonly path?: string; readonly url?: string; readonly upstream?: string; } export declare function optimizerHome(env?: NodeJS.ProcessEnv): string; /** Claude Code's user settings file. */ export declare function claudeSettingsFile(env?: NodeJS.ProcessEnv): string; /** Where we record what we wrote, so it can be taken back out exactly. */ export declare function routingManifestFile(env?: NodeJS.ProcessEnv): string; export declare function readRoutingManifest(env?: NodeJS.ProcessEnv): RoutingManifest; /** * May we write to a client's own configuration at all? * * Three separate refusals, because they mean different things: the whole product being off, request * compression being off, and this one mechanism being declined by someone who is happy to keep * launching through the wrapper. */ export declare function defaultRoutingAllowed(env?: NodeJS.ProcessEnv): boolean; /** * Take our entry back out, restoring what was there before. * * Refuses when the file no longer holds the value we wrote: that means the user has changed it since * and restoring "our" previous value would overwrite their choice. */ export declare function removeDefaultRouting(env?: NodeJS.ProcessEnv): RoutingResult; /** * Point Claude Code at the proxy, or take the entry back out when we cannot serve it. * * `route` is injected: this module must not import the compiled supervisor, because the hooks that * call it are also copied into client integrations that do not ship `dist/`. */ export declare function applyDefaultRouting(route: (upstream: string) => Promise, env?: NodeJS.ProcessEnv): Promise; /** * The real endpoint behind a value that may be a route we installed. * * WHY THE LAUNCHER NEEDS THIS. Once settings.json names our loopback route, anything that reads that * file to decide where a client is pointed -- `token-optimizer-run claude`, most of all -- would * take our own proxy for the provider and start a second proxy in front of the first. That chain * works only for as long as both are up, and it compresses already-compressed traffic. * * Recognised by the manifest, not by being loopback: a user running their own local gateway is * pointed somewhere real, and we must keep forwarding to it. */ export declare function originalUpstream(value: string | undefined, env?: NodeJS.ProcessEnv): string | undefined; /** * Ensure the route and write it where a client we did not launch will read it. * * Fire-and-forget: every failure inside is a reason to leave the user's configuration as it is, and * none of them is a reason to fail whatever called this. */ export declare function maintainDefaultRouting(env?: NodeJS.ProcessEnv): Promise; //# sourceMappingURL=default-routing.d.ts.map