/** * `@ai-matrx/agents/runtime` — the RUN TIER's row types (agent core B2). * * The run tier is everything a client needs to RUN an agent and nothing it needs to BUILD one: * name, description, variables, context rules, the kill switches, the default model, UI gates, * tool ids, access level and the run-control counts. JSON columns are typed `unknown` here — the * core never interprets variable, context-policy or gate shapes; a host narrows them at its seam * (chat's `AgentRunTier` does). */ /** One `agx_get_run_tier(p_agent_id)` row. */ interface AgentRunTierRow { id: string; is_version: boolean; version_id: string | null; name: string; description: string | null; variable_definitions: unknown[] | null; context_policies: unknown[] | null; auto_context_disabled: boolean; model_id: string | null; ui_gates: Record | null; tool_ids: string[] | null; access_level: string; custom_tool_count: number; skill_count: number; connection_count: number; /** The agent's model settings (a small object): the override-diff base and what "Model and overrides" shows. */ settings?: Record | null; } /** One `agx_get_run_controls(p_agent_id)` row — what the run-control pickers show (P25). */ interface AgentRunControlsRow { id: string; tool_ids: string[] | null; custom_tool_names: string[] | null; auto_tools_disabled: boolean | null; skill_config: unknown; /** Catalog server IDS (uuid) — never names. Read `mcp_server_slugs` to name or resolve a connector. */ mcp_servers: string[] | null; /** The same servers as catalog slugs, in the same order (a server the caller cannot see has none). */ mcp_server_slugs?: string[] | null; /** The agent's forbidden tool names (`tool_config.excluded_tools`); the composer shows them off. */ excluded_tools?: string[] | null; } /** One `agx_get_access_level(p_agent_id)` row. */ interface AgentAccessLevelRow { agent_id: string; agent_name: string; owner_id: string; owner_email: string; access_level: "owner" | "admin" | "editor" | "viewer" | "public" | "none"; is_owner: boolean; } /** One `agx_get_shared_with_me()` row. */ interface SharedAgentItem { id: string; name: string; description: string | null; agent_type: "user" | "builtin"; category: string | null; tags: string[]; owner_id: string | null; owner_email: string | null; permission_level: string; created_at: string; updated_at: string; } /** One `agx_get_shared_for_chat()` row. */ interface SharedAgentForChat { id: string; name: string; permission_level: string; owner_email: string | null; } type RunTierStatus = "idle" | "loading" | "ready" | "failed"; /** One cached read. `data` is the last good answer; a failed refresh keeps it and sets `error`. */ interface RunTierEntry { status: RunTierStatus; data: T | null; error: string | null; } /** * `@ai-matrx/agents/runtime` — `createRunTierStore`: the headless RUN TIER store (agent core B2). * * The ONE place a client reads what it needs to RUN an agent: the run tier (`agx_get_run_tier`), * the run controls (`agx_get_run_controls`), the caller's access level (`agx_get_access_level`) and * the shared lists (`agx_get_shared_with_me`, `agx_get_shared_for_chat`). Built like * `createAgentCatalog` / `createSkillCatalog`: framework-free, `getState` / `subscribe`, no Redux. * A host binds it (chat's run thunks read it; extend/local/vscode call it directly). * * It READS only (guard G1). Every read is deduped in flight and cached per agent; `force` re-reads. * A read failure rejects with `RunTierReadError` AND lands in the entry's `error` + the * `errorSink` — never silent. An empty answer is a refusal (`RunTierNotReadableError`), never a * quiet success: the RPCs answer `[]` when the caller cannot read the agent. */ interface RunTierState { runTier: Record>; runControls: Record>; accessLevel: Record>; sharedWithMe: RunTierEntry; sharedForChat: RunTierEntry; } interface RunTierStore { getState(): RunTierState; subscribe(listener: () => void): () => void; /** The run tier for one agent. Cached; `force` re-reads. Rejects on refusal or failure. */ loadRunTier(agentId: string, options?: { force?: boolean; }): Promise; /** The run controls for one agent (fetched when a run-control picker opens). */ loadRunControls(agentId: string, options?: { force?: boolean; }): Promise; /** The caller's access level on one agent. */ loadAccessLevel(agentId: string, options?: { force?: boolean; }): Promise; loadSharedWithMe(options?: { force?: boolean; }): Promise; loadSharedForChat(options?: { force?: boolean; }): Promise; /** * Hold a GENERATED run tier answer (`@ai-matrx/agents/mandates` `MANDATE_DISPLAY_SEEDS`) as if * it had been read — only when nothing for that agent is held or reading. Returns whether it * seeded. Once per agent: after `invalidate` the next ask is a real read. */ seedRunTier(row: AgentRunTierRow): boolean; getRunTier(agentId: string): AgentRunTierRow | undefined; getRunControls(agentId: string): AgentRunControlsRow | undefined; getAccessLevel(agentId: string): AgentAccessLevelRow | undefined; /** Drop every cached read for one agent (a save landed; the next read is fresh). */ invalidate(agentId: string): void; } /** Subscribe to a slice of a run tier store. `select` must return a stable value for unchanged state. */ declare function useRunTierSelector(store: RunTierStore, select: (state: RunTierState) => T): T; /** One agent's run tier; reads it on mount when missing. A failure lands in `error`. */ declare function useAgentRunTier(store: RunTierStore, agentId: string | null | undefined): RunTierEntry; export { useAgentRunTier, useRunTierSelector };