import { z } from 'zod'; import { type CredentialStore, type CredentialStores } from './credentials.js'; import { SynomemError } from './errors.js'; import { createLocalResolver, createRemoteResolver, type ContextResolver, type RemoteCredentialSource } from './resolvers.js'; import type { ActorIdentity, ContextSummary } from './types.js'; export declare const PROFILES_FILE = "profiles.json"; declare const credentialEntrySchema: z.ZodObject<{ kind: z.ZodEnum<{ oauth: "oauth"; "access-key": "access-key"; }>; apiUrl: z.ZodString; store: z.ZodEnum<{ file: "file"; keychain: "keychain"; environment: "environment"; }>; secretRef: z.ZodOptional; issuer: z.ZodOptional; resource: z.ZodOptional; clientId: z.ZodOptional; connectionId: z.ZodOptional; label: z.ZodOptional; createdAt: z.ZodString; }, z.core.$strict>; declare const localProfileSchema: z.ZodObject<{ backend: z.ZodLiteral<"local">; actorKind: z.ZodOptional>; home: z.ZodOptional; actorId: z.ZodString; actorName: z.ZodOptional; contextId: z.ZodString; }, z.core.$strict>; declare const remoteProfileSchema: z.ZodObject<{ backend: z.ZodOptional>; credentialRef: z.ZodString; contextId: z.ZodString; workspaceId: z.ZodOptional; workspaceName: z.ZodOptional; actor: z.ZodOptional; id: z.ZodString; displayName: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>; export declare const profileSchema: z.ZodUnion; actorKind: z.ZodOptional>; home: z.ZodOptional; actorId: z.ZodString; actorName: z.ZodOptional; contextId: z.ZodString; }, z.core.$strict>, z.ZodObject<{ backend: z.ZodOptional>; credentialRef: z.ZodString; contextId: z.ZodString; workspaceId: z.ZodOptional; workspaceName: z.ZodOptional; actor: z.ZodOptional; id: z.ZodString; displayName: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>]>; export declare const profilesConfigSchema: z.ZodObject<{ version: z.ZodLiteral<1>; credentials: z.ZodDefault; apiUrl: z.ZodString; store: z.ZodEnum<{ file: "file"; keychain: "keychain"; environment: "environment"; }>; secretRef: z.ZodOptional; issuer: z.ZodOptional; resource: z.ZodOptional; clientId: z.ZodOptional; connectionId: z.ZodOptional; label: z.ZodOptional; createdAt: z.ZodString; }, z.core.$strict>>>; profiles: z.ZodDefault; actorKind: z.ZodOptional>; home: z.ZodOptional; actorId: z.ZodString; actorName: z.ZodOptional; contextId: z.ZodString; }, z.core.$strict>, z.ZodObject<{ backend: z.ZodOptional>; credentialRef: z.ZodString; contextId: z.ZodString; workspaceId: z.ZodOptional; workspaceName: z.ZodOptional; actor: z.ZodOptional; id: z.ZodString; displayName: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>]>>>; harnessPresets: z.ZodDefault>>; defaultProfile: z.ZodOptional; }, z.core.$strict>; export type CredentialEntry = z.infer; export type LocalProfile = z.infer; export type RemoteProfile = z.infer; export type Profile = z.infer; export type ProfilesConfig = z.infer; export declare function isLocalProfile(profile: Profile): profile is LocalProfile; export declare function emptyProfilesConfig(): ProfilesConfig; export declare function assertName(name: string, what: string): string; /** Reads and writes `/profiles.json`. Injected in tests. */ export declare class ProfileStore { readonly home: string; constructor(explicitHome?: string); get path(): string; read(): ProfilesConfig; write(config: ProfilesConfig): void; } export type Selection = { kind: 'profile'; name: string; source: string; } | { kind: 'preset'; name: string; source: string; }; export interface SelectionInput { profile?: string; preset?: string; env?: NodeJS.ProcessEnv; cwd?: string; /** The Synomem home, so it is never mistaken for a project directory. */ home?: string; } /** * Which profile or preset a process acts through. One implementation, used by * the CLI and both stdio entrypoints: * * 1. `--profile` / `--preset` on this invocation * 2. `SYNOMEM_PROFILE` / `SYNOMEM_PRESET` for this process * 3. the nearest project `.synomem/project.json` (names a profile/preset only) * 4. `defaultProfile` in profiles.json * * Returns undefined when nothing selects anything. Naming something that does * not exist is an error, never a fall-through to the next source. */ export declare function resolveSelection(config: ProfilesConfig, input: SelectionInput): Selection | undefined; export declare function noSelectionError(): SynomemError; export interface CredentialSourceOptions { home: string; name: string; entry: CredentialEntry; stores: CredentialStores; env?: NodeJS.ProcessEnv; fetch?: typeof fetch; } export declare function storeFor(stores: CredentialStores, entry: CredentialEntry): CredentialStore; /** * A connection's current bearer: an access key as stored, or an OAuth access * token, refreshed under the cross-process lock when it has expired. * * After taking the lock the stored credential is re-read: if another process * already refreshed it (a newer generation), that token is used and the * refresh token is not spent again. A refused refresh is never retried — the * connection must be logged in again. */ export declare class ConnectionCredentialSource implements RemoteCredentialSource { private readonly options; private cached?; private cachedExpiry; private pending?; constructor(options: CredentialSourceOptions); bearer(): Promise; private reauthorize; private load; private remember; } export interface ResolverDependencies { stores: CredentialStores; env?: NodeJS.ProcessEnv; fetch?: typeof fetch; createRemoteResolver?: typeof createRemoteResolver; createLocalResolver?: typeof createLocalResolver; } export declare function credentialSourceFor(home: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): ConnectionCredentialSource; /** The canonical local actor for a local profile, after checking its store. */ export declare function localProfileTarget(rootHome: string, profile: LocalProfile): { home: string; actor: ActorIdentity; }; /** A fixed-mode resolver for one profile. */ export declare function profileResolver(rootHome: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): ContextResolver; interface Route { profile: string; contextId: string; resolver: ContextResolver; } /** * An explicit-context resolver over a preset's profiles. * * Remote profiles sharing a connection share one remote resolver, restricted * to exactly the contexts the preset names (the server still authorizes each). * Every operation must name its context; there is no default and no switch. */ export declare class PresetResolver implements ContextResolver { private readonly name; private readonly routes; constructor(name: string, routes: Route[]); mode(): 'explicit'; backend(): 'local' | 'remote' | 'mixed'; resolve(contextId?: string): Promise; list(): Promise<{ mode: "explicit"; fixedContextId: null; contexts: ContextSummary[]; }>; close(): Promise; } export declare function presetResolver(rootHome: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): PresetResolver; /** * The single entry point for the CLI and both stdio servers: selection flags * and environment in, one resolver out. */ export declare function resolverForSelection(rootHome: string, config: ProfilesConfig, selection: Selection, deps: ResolverDependencies): ContextResolver; export declare function describeContext(context: ContextSummary): string; /** One line describing a profile, for list/show. Never a secret. */ export declare function describeProfile(name: string, profile: Profile): string; export {}; //# sourceMappingURL=profiles.d.ts.map