/** * Secret provider abstraction. * * Decouples credential resolution from process.env so secrets can be * provisioned over the transport bridge instead of living in the * container's environment. */ /** * Read-only secret resolution. Adapters receive this interface. * @docLink packages/connectors/api-reference#secret-provider */ export interface SecretProvider { /** * Resolve a credential reference. * * @param ref - Credential reference such as "env:GIT_TOKEN", * "oauth:google:user@example.com", or an inline literal. * @returns The resolved secret value or undefined if not found. */ resolve(ref: string): string | undefined; /** * Check whether a reference can be resolved. * * @param ref - Reference to check. * @returns True if resolve(ref) would return a non-undefined value. */ has(ref: string): boolean; /** * Return all ref strings this provider can currently resolve. * * @returns All resolvable refs (used by forge UI and ConnectorFieldMissingError). */ capabilities(): string[]; } /** * Extends `SecretProvider` with the ability to load secrets at runtime via `provision()`. * @docLink packages/connectors/api-reference#provisionable-secret-provider */ export interface ProvisionableSecretProvider extends SecretProvider { /** Store a batch of key-value secrets. Keys are bare names (no prefix). */ provision(secrets: Record): void; } /** * In-memory secret store. Secrets are provisioned over the transport bridge * and stored in a private Map — never touching the filesystem or process.env. * * Supports ref prefixes: * `"env:KEY"` — looks up KEY in the store * `"vault:KEY"` — looks up KEY in the store (future vault compat) * (no prefix) — returned as an inline value (backwards compat for non-chain usages) * @docLink packages/connectors/api-reference#in-memory-secret-provider */ export declare class InMemorySecretProvider implements ProvisionableSecretProvider { private readonly store; /** * Store a batch of key-value secrets. * * @param secrets - Key-value map of secret names to values. Keys are bare names (no prefix). */ provision(secrets: Record): void; resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; } /** * Delegates to `process.env`. Used in CLI/standalone mode. * Does NOT pass through inline literals — returns `undefined` for any ref * that does not start with `"env:"`. Use `InMemorySecretProvider` for inline * literals in non-chain contexts. * @docLink packages/connectors/api-reference#env-secret-provider */ export declare class EnvSecretProvider implements SecretProvider { resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; } /** * Pre-minted credential entry. Mirrors the discriminated `CredentialMint` * shape from `@skaile/workspaces/types` but redeclared here to keep this package * free of cross-package type dependencies. * * The failure branch carries the platform-side `code` + `message` so the * `ConnectorManager`'s wrapped mediator can surface the real reason instead of * a generic "no pre-mint" placeholder when a mint comes back as `ok: false`. */ export type PreMintedCredential = { ok: true; token: string; expiresAt: string | null; mintedAt?: string; } | { ok: false; code?: "not-configured" | "revoked" | "provider-error" | "backend-error"; message?: string; }; /** * Pre-minted credential store. Holds short-lived tokens delivered upfront in * the v3 `session_init` envelope so the runner never has to call back to the * platform during mount setup. * * Resolves refs of the form `mount:`, `connector:`, and `mcp:`. * Returns `undefined` for any other ref so the chain falls through to the * next provider (`EnvSecretProvider` for `pat:env:NAME`, etc.). * * Tokens can be added/removed at runtime via {@link set} / {@link unset} so * `runner.add_mount` / `runner.add_connector` / `runner.add_mcp` capabilities * stay strictly in-process — no round trip to the platform to mint while * the resource is hot-attached. * * For callers that need the full mint metadata (expiry timestamp, mintedAt * audit fields), use {@link mintFor} instead of the bare `resolve`. The * `ConnectorManager` consults this for the `auth: backend` initial-mint path so * the driver retains the original expiry semantics. * * Spec: `_devlog/specs/2026-05-10-deterministic-session-bootstrap.md`. * * @docLink packages/connectors/api-reference#pre-minted-secret-provider */ export declare class PreMintedSecretProvider implements SecretProvider { private readonly mints; /** * Seed pre-minted credentials from the v3 `session_init.credentials` map. * * Failed mints (`ok: false`) are stored too so callers can distinguish * "not pre-minted" from "pre-minted but failed"; {@link resolve} treats * both as `undefined`. * * @param credentials Optional initial `{ mounts, connectors, mcp }` map. */ constructor(credentials?: { mounts?: Record; connectors?: Record; mcp?: Record; }); /** * Insert (or replace) a pre-minted credential. Used by * `runner.add_mount` / `runner.add_connector` / `runner.add_mcp` capability * handlers when the platform delivers new credentials mid-session. */ set(kind: "mount" | "connector" | "mcp", id: string, mint: PreMintedCredential): void; /** * Remove a stored pre-minted credential. Used by the * `runner.remove_resource` capability handler. */ unset(kind: "mount" | "connector" | "mcp", id: string): boolean; /** * Look up the full {@link PreMintedCredential} for a `mount:` / * `connector:` / `mcp:` keyed entry. Callers that only need the token use * {@link resolve} via the chain; callers that need expiry / audit * metadata (e.g. ConnectorManager) use this entry point. */ mintFor(kind: "mount" | "connector" | "mcp", id: string): PreMintedCredential | undefined; resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; } /** * Forge session secret provider. Secrets are provisioned from the Forge settings * panel over the transport bridge. Only handles `"forge:"` prefixed refs — returns * `undefined` for all others. * @docLink packages/connectors/api-reference#forge-secret-provider */ export declare class ForgeSecretProvider implements ProvisionableSecretProvider { private readonly store; provision(secrets: Record): void; resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; } /** * Thrown when an OAuth-secured connector field requires user authorization before * it can be resolved. Contains the redirect URL to open in the user's browser. * @docLink packages/connectors/api-reference#o-auth-required-error */ export declare class OAuthRequiredError extends Error { readonly oauthRef: string; readonly authUrl: string; readonly state: string; /** * @param oauthRef - The 'oauth::' ref that triggered the error * @param authUrl - Browser URL to open for OAuth authorization * @param state - OAuth state token for CSRF protection and callback correlation */ constructor(oauthRef: string, authUrl: string, state: string); } /** * Shape of an OAuth token bundle stored by `OAuthSecretProvider`. * @docLink packages/connectors/api-reference#o-auth-token-bundle */ export interface OAuthTokenBundle { accessToken: string; refreshToken?: string; /** Unix timestamp in ms */ expiry?: number; } /** * Return value of `OAuthSecretProvider.initiateFlow()`. Contains the URL and CSRF state token. * @docLink packages/connectors/api-reference#o-auth-flow-request */ export interface OAuthFlowRequest { authUrl: string; state: string; } /** * OAuth token provider. Handles `"oauth::"` refs. * Callers must call `chain.prepareRef()` before `chain.resolve()` for `oauth:` refs. * @docLink packages/connectors/api-reference#o-auth-secret-provider */ export interface OAuthSecretProvider extends SecretProvider { /** * Ensure the token for this ref is fresh. * Refreshes if expired. * Throws OAuthRequiredError if no token exists and user authorization is needed. */ ensureFresh(ref: string): Promise; /** Initiate the OAuth authorization flow. Returns URL to open in the user's browser. */ initiateFlow(oauthService: string, account: string): Promise; /** Exchange authorization code for tokens and store the bundle. */ completeFlow(state: string, code: string): Promise; } /** * Abstract base for vault-backed secret providers (1Password, KeePass). Subclasses * implement `prefix` and `loadKeys()`. Locked until `unlock(credential)` is called. * @docLink packages/connectors/api-reference#locked-secret-provider */ export declare abstract class LockedSecretProvider implements SecretProvider { locked: boolean; protected readonly store: Map; abstract readonly prefix: string; unlock(credential: string): Promise; protected abstract loadKeys(credential: string): Promise; resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; } /** * True when `value` starts with a known secret-ref prefix (`env:`, `oauth:`, * `mcp:`, ...). Lets callers distinguish an intended-but-unresolved ref from a * plain literal — e.g. the runner refuses to forward an unresolved ref into * MCP transport headers/env, where the literal would otherwise leak onto the * wire and produce a misleading upstream error. */ export declare function isKnownSecretRef(value: string): boolean; /** * Chains multiple `SecretProvider` instances into a single resolver. * - Prefixed refs (`env:`, `forge:`, `op:`, `kp:`, `oauth:`) are routed to the first provider that can resolve them. * - Bare refs waterfall through all providers in order. * - Plain literals in `skaile.yaml` options are NOT passed to the chain; `ConnectorManager` handles them before calling `resolve()`. * @docLink packages/connectors/api-reference#secret-provider-chain */ export declare class SecretProviderChain implements SecretProvider { private readonly providers; /** * @param providers - Ordered list of providers. For prefixed refs, the first * provider that can resolve wins. For bare refs, waterfall through all in order. */ constructor(providers: SecretProvider[]); resolve(ref: string): string | undefined; has(ref: string): boolean; capabilities(): string[]; /** Returns the first provider that can resolve this ref. */ providerFor(ref: string): SecretProvider | undefined; /** * Calls ensureFresh(ref) on the owning provider if it implements OAuthSecretProvider. * No-op for providers that don't have ensureFresh(). * * @param ref - Must be an "oauth:" prefixed ref for this to have any effect. * Calls ensureFresh() on the owning OAuthSecretProvider. */ prepareRef(ref: string): Promise; } //# sourceMappingURL=secrets.d.ts.map