/** * useActiveAgentProfile — Phase 5B (multi-profile-per-daemon). * * Lists `AgentProfile` rows for an agent and tracks the currently-active * profile name in the VibeControls Zustand store (`activeProfilePerAgent`). * * Active-selection rules: * 1. If the user has explicitly selected a profile for this agent, use it. * 2. Otherwise, fall back to the profile flagged `isDefault`. * 3. Otherwise, fall back to the first profile in the list. * 4. Otherwise, fall back to the literal string "default" so callers can * build canonical paths even before any AgentProfile rows exist * (server-side compatibility shim). * * NOTE: The Apollo `gql` document is inlined here (not generated) so this * hook compiles cleanly even before the Phase 5A svc work has published * the AgentProfile schema to Hive. Once published, the inline document * can be replaced with the generated `useVibecontrolsAgentProfilesQuery` * hook without touching callsites. */ export interface AgentProfile { id: string; agentId: string; name: string; isDefault: boolean; port: number | null; status: string | null; tunnelUrl: string | null; createdAt: string; updatedAt: string; } export interface UseActiveAgentProfileResult { /** All profiles for the agent (empty until svc Phase 5A is live). */ profiles: AgentProfile[]; /** The currently-selected profile name for this agent. */ active: string; /** Persist a new active profile for this agent into the store. */ setActive: (profile: string) => void; loading: boolean; error: Error | null; /** * Re-fetch the profile list. Resolves when the round-trip settles and * never rejects (failures are swallowed), so it is safe to call * fire-and-forget. */ refetch: () => Promise; } /** * A profile is a valid *active* target only when it's usable — i.e. the * daemon can actually serve profile-scoped requests for it. A never-started * `awaiting-config` profile is NOT usable; sitting on it confuses the user * and breaks profile-scoped features (Open Editor, Logs, …) with 404s. * * `default`/`isDefault` are NOT exempt from the readiness check: the boot * profile is not always running (its persisted status can be * `awaiting-config`), so treating it as usable regardless of status let the * stored-selection path preserve an unready `default` and target a * non-running profile. We only trust `default`/`isDefault` unconditionally * when the svc reports *no* status at all (Phase 5A compat shim: status * null/empty), so the UI still works before statuses are populated. */ export declare function isUsableProfile(p: AgentProfile): boolean; export declare function useActiveAgentProfile(agentId: string | null | undefined): UseActiveAgentProfileResult;