import type { Api, AssistantMessageEventStream, Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai"; import type { AccountSlot } from "../../core/accounts.js"; import { type MigrationNotice } from "../../core/failover.js"; import { readPool, writePool } from "../../core/store.js"; import { type UsageCache } from "../../core/usage-cache.js"; import type { ProviderBuildContext, ProviderConfig } from "../../core/types.js"; import { type KiroTokens } from "./oauth.js"; import { DebugLogger } from "./vendor/debug-logger.js"; import { createKiroStream } from "./vendor/kiro.js"; export declare function slotToTokens(slot: AccountSlot): KiroTokens; export declare function tokensToSlot(name: string, tokens: KiroTokens, source?: AccountSlot["source"]): AccountSlot; /** First user message text, used as the cache-affinity anchor. */ export declare function firstUserText(context: Context): string | undefined; export interface KiroProviderDeps { readPoolState?: typeof readPool; writePoolState?: typeof writePool; refresh?: (tokens: KiroTokens) => Promise; createStream?: typeof createKiroStream; onFailover?: (message: string) => void; reportMigration?: (providerId: string, notice: MigrationNotice) => void; logger?: DebugLogger; /** Per-account headroom source for `balanced` placement. */ usage?: UsageCache; } /** * Read one account's usage, refreshing an expired access token first. * * An expired token makes the usage endpoint answer 403, which previously read as * "headroom unknown" and quietly excluded that account from usage-aware * placement. The refresh is best-effort and its result is not persisted here: * this is a read-only probe, and the request path refreshes and stores tokens on * its own. */ export declare function readKiroHeadroom(slot: AccountSlot, deps?: { refresh?: (tokens: KiroTokens) => Promise; }): Promise; export declare function createKiroStreamSimple(agentDir: string, deps?: KiroProviderDeps): (model: Model, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream; export declare function buildKiroProviderConfig(context: ProviderBuildContext, oauth: ProviderConfig["oauth"], deps?: KiroProviderDeps): ProviderConfig;