/** * Coding agent service contracts for extension managers. * * Defines the CodingAgent type and CodingAgentRepository service interface * that extension managers depend on. The concrete implementation * (DefaultCodingAgentRepository) lives in the CLI package. * * @experimental This API is unstable and may change without notice. * @packageDocumentation */ import type * as Effect from "effect/Effect"; import type * as FileSystem from "effect/FileSystem"; import type * as Path from "effect/Path"; import * as ServiceMap from "effect/Context"; import type { AppError } from "../app-error/index.js"; import type { Handle } from "../extensions/handle.js"; import type { RenderedFilePath } from "../extensions/rendered-files.js"; import type { ArtifactChange } from "../plan/plan.js"; import type { SubagentRenderInput } from "../subagents/rendering/types.js"; import type { WorkspaceScope } from "../workspace/scope.js"; import type { WorkspaceMutations } from "../workspace/service-interface.js"; import type { AgentId } from "./types.js"; /** * Inputs for resolving an agent's effective skills directory. */ export interface ResolveSkillsDirArgs { readonly workspaceRoot: string; } /** * Tagged outcome for skills-directory resolution. */ export type ResolveSkillsDirOutcome = { readonly _tag: "supported"; readonly dir: string; } | { readonly _tag: "unsupported"; readonly reason: string; } | { readonly _tag: "disabled"; readonly reason: string; } | { readonly _tag: "misconfigured"; readonly reason: string; }; /** * Inputs for adding an MCP server to an agent's configuration. */ export interface AddMcpServerArgs { readonly workspaceRoot: string; readonly scope?: WorkspaceScope; readonly serverName: string; readonly canonicalPath: string; readonly owner: Handle; readonly resolvedVersion: string; readonly enabled?: boolean; readonly configValues?: Readonly>; } /** * Inputs for removing an MCP server from an agent's configuration. */ export interface RemoveMcpServerArgs { readonly workspaceRoot: string; readonly scope?: WorkspaceScope; readonly serverName: string; readonly disableOnly?: boolean; } /** * Inputs for resolving an agent's effective subagents directory. */ export interface ResolveSubagentsDirArgs { readonly workspaceRoot: string; readonly scope: WorkspaceScope; } /** * Tagged outcome for subagents-directory resolution. */ export type ResolveSubagentsDirOutcome = { readonly _tag: "supported"; readonly dir: string; readonly warnings: ReadonlyArray; } | { readonly _tag: "unsupported"; readonly reason: string; } | { readonly _tag: "disabled"; readonly reason: string; } | { readonly _tag: "misconfigured"; readonly reason: string; }; /** * Inputs for adding a subagent to an agent's subagents directory. */ export interface AddSubagentArgs { readonly workspaceRoot: string; readonly scope: WorkspaceScope; readonly editSourcePath: string; readonly input: SubagentRenderInput; readonly force: boolean; } /** * Inputs for removing a subagent from an agent's subagents directory. */ export interface RemoveSubagentArgs { readonly workspaceRoot: string; readonly scope: WorkspaceScope; readonly subagentName: string; /** Rendered file paths from the lockfile, used to know which files to delete. */ readonly renderedFilePaths: ReadonlyArray; } /** * Outcome of a subagent sync operation (add or remove). */ export type SubagentSyncOutcome = { readonly _tag: "success"; readonly renderedFilePaths: ReadonlyArray; readonly warnings: ReadonlyArray; } | { readonly _tag: "skipped"; readonly reason: string; } | { readonly _tag: "unsupported"; readonly reason: string; } | { readonly _tag: "conflict"; readonly reason: string; }; export type McpServerSyncFallbackSource = "unsupported" | "disabled"; export interface McpServerSyncTarget { readonly path: string; readonly change: ArtifactChange; } export type McpServerSyncOutcome = { readonly _tag: "success"; readonly targets?: ReadonlyArray; readonly warnings?: ReadonlyArray; } | { readonly _tag: "fallback"; readonly fallbackFrom: McpServerSyncFallbackSource; readonly reason: string; readonly targets?: ReadonlyArray; readonly warnings?: ReadonlyArray; } | { readonly _tag: "unsupported"; readonly reason: string; } | { readonly _tag: "disabled"; readonly reason: string; } | { readonly _tag: "nothing-runnable"; readonly reason: string; } | { readonly _tag: "needs-input"; readonly reason: string; } | { readonly _tag: "misconfigured"; readonly reason: string; } | { readonly _tag: "failed"; readonly reason: string; }; /** * Agent-specific extension installation behavior. * * Each coding agent knows how to resolve its skills directory, * manage MCP server configuration entries, and manage subagent files. */ export interface CodingAgent { readonly id: AgentId; readonly resolveEffectiveSkillsDir: (args: ResolveSkillsDirArgs) => Effect.Effect; readonly addMcpServer: (args: AddMcpServerArgs) => Effect.Effect; readonly removeMcpServer: (args: RemoveMcpServerArgs) => Effect.Effect; readonly resolveEffectiveSubagentsDir: (args: ResolveSubagentsDirArgs) => Effect.Effect; readonly addSubagent: (args: AddSubagentArgs) => Effect.Effect; readonly removeSubagent: (args: RemoveSubagentArgs) => Effect.Effect; } /** * Repository for coding-agent implementations. * * Generic over `W` — the workspace service requirement. The CLI package * instantiates this with its concrete `WorkspaceMutations` type; core keeps it * abstract to avoid a circular dependency. * * @typeParam W - WorkspaceMutations service requirement for methods that need workspace read model */ export interface CodingAgentRepositoryShape { readonly get: (id: AgentId) => Effect.Effect; readonly all: Effect.Effect, AppError>; readonly getConfiguredAgents: () => Effect.Effect, AppError, W>; readonly getMaterializationAgents: () => Effect.Effect, AppError, W>; readonly getUnknownConfiguredAgentIds: () => Effect.Effect, AppError, W>; } /** * Repository for coding-agent implementations. * * Instantiates the generic CodingAgentRepositoryShape with the core WorkspaceMutations * service for methods that need workspace read model. */ export type CodingAgentRepositoryService = CodingAgentRepositoryShape; declare const CodingAgentRepository_base: ServiceMap.ServiceClass; export declare class CodingAgentRepository extends CodingAgentRepository_base { } export {}; //# sourceMappingURL=coding-agent.d.ts.map