/**
 * Coding Workspace Service - Manages git workspaces for coding tasks
 *
 * Delegates to:
 * - workspace-github.ts  (issue management, OAuth, PAT auth)
 * - workspace-git-ops.ts (status, commit, push, PR creation)
 * - workspace-lifecycle.ts (GC, scratch dir cleanup)
 * - workspace-types.ts   (shared interface definitions)
 *
 * @module services/workspace-service
 */
import type { IAgentRuntime } from "@elizaos/core";
import { type CreateIssueOptions, type IssueComment, type IssueInfo, type IssueState, type PullRequestInfo, type WorkspaceEvent } from "git-workspace-service";
import type { AuthPromptCallback } from "./workspace-github.ts";
export type { AuthPromptCallback } from "./workspace-github.ts";
export type { CodingWorkspaceConfig, CommitOptions, PROptions, ProvisionWorkspaceOptions, PushOptions, WorkspaceResult, WorkspaceStatusResult, } from "./workspace-types.ts";
import type { CodingWorkspaceConfig, CommitOptions, PROptions, ProvisionWorkspaceOptions, PushOptions, WorkspaceResult, WorkspaceStatusResult } from "./workspace-types.ts";
type WorkspaceEventCallback = (event: WorkspaceEvent) => void;
type ScratchTerminalEvent = "stopped" | "task_complete" | "error";
export interface ScratchWorkspaceRecord {
    sessionId: string;
    label: string;
    path: string;
    status: "pending_decision" | "kept" | "promoted";
    createdAt: number;
    terminalAt: number;
    terminalEvent: ScratchTerminalEvent;
    expiresAt?: number;
}
export declare class CodingWorkspaceService {
    static serviceType: string;
    capabilityDescription: string;
    private runtime;
    private workspaceService;
    private credentialService;
    private githubClient;
    private githubAuthInProgress;
    private serviceConfig;
    private workspaces;
    private labels;
    private scratchBySession;
    private scratchCleanupTimers;
    private eventCallbacks;
    private authPromptCallback;
    /** Callback fired when a scratch workspace enters pending_decision state. */
    private scratchDecisionCallback;
    constructor(runtime: IAgentRuntime, config?: CodingWorkspaceConfig);
    static start(runtime: IAgentRuntime): Promise<CodingWorkspaceService>;
    static stopRuntime(runtime: IAgentRuntime): Promise<void>;
    private initialize;
    stop(): Promise<void>;
    /** Provision a new workspace */
    provisionWorkspace(options: ProvisionWorkspaceOptions): Promise<WorkspaceResult>;
    getWorkspace(id: string): WorkspaceResult | undefined;
    listWorkspaces(): WorkspaceResult[];
    /**
     * Assign a semantic label to a workspace (e.g. "auth-bugfix").
     * If the label already exists, it is reassigned to the new workspace.
     */
    setLabel(workspaceId: string, label: string): void;
    getWorkspaceByLabel(label: string): WorkspaceResult | undefined;
    /** Resolve a workspace by label or ID. */
    resolveWorkspace(labelOrId: string): WorkspaceResult | undefined;
    getStatus(workspaceId: string): Promise<WorkspaceStatusResult>;
    commit(workspaceId: string, options: CommitOptions): Promise<string>;
    push(workspaceId: string, options?: PushOptions): Promise<void>;
    createPR(workspaceId: string, options: PROptions): Promise<PullRequestInfo>;
    private getGitHubContext;
    /** Set a callback to surface OAuth auth prompts to the user. */
    setAuthPromptCallback(callback: AuthPromptCallback): void;
    /**
     * Register a callback fired when a scratch workspace enters pending_decision.
     * Used to prompt the user via chat: "Want to keep this code?"
     */
    setScratchDecisionCallback(callback: (record: ScratchWorkspaceRecord) => Promise<void>): void;
    createIssue(repo: string, options: CreateIssueOptions): Promise<IssueInfo>;
    getIssue(repo: string, issueNumber: number): Promise<IssueInfo>;
    listIssues(repo: string, options?: {
        state?: IssueState | "all";
        labels?: string[];
        assignee?: string;
    }): Promise<IssueInfo[]>;
    updateIssue(repo: string, issueNumber: number, options: {
        title?: string;
        body?: string;
        state?: IssueState;
        labels?: string[];
        assignees?: string[];
    }): Promise<IssueInfo>;
    addComment(repo: string, issueNumber: number, body: string): Promise<IssueComment>;
    listComments(repo: string, issueNumber: number): Promise<IssueComment[]>;
    closeIssue(repo: string, issueNumber: number): Promise<IssueInfo>;
    reopenIssue(repo: string, issueNumber: number): Promise<IssueInfo>;
    addLabels(repo: string, issueNumber: number, labels: string[]): Promise<void>;
    removeWorkspace(workspaceId: string): Promise<void>;
    onEvent(callback: WorkspaceEventCallback): () => void;
    private emitEvent;
    /** Remove a scratch directory — allowed under base dir or user coding directory. */
    removeScratchDir(dirPath: string): Promise<void>;
    listScratchWorkspaces(): ScratchWorkspaceRecord[];
    registerScratchWorkspace(sessionId: string, dirPath: string, label: string, terminalEvent: ScratchTerminalEvent): Promise<ScratchWorkspaceRecord | null>;
    keepScratchWorkspace(sessionId: string): Promise<ScratchWorkspaceRecord>;
    deleteScratchWorkspace(sessionId: string): Promise<void>;
    promoteScratchWorkspace(sessionId: string, name?: string): Promise<ScratchWorkspaceRecord>;
    /** GC orphaned workspace directories older than workspaceTtlMs. */
    private gcOrphanedWorkspaces;
    private log;
    /** Read a key from the config file's env section (live, no restart needed). */
    private readConfigEnvKey;
    private getScratchRetentionPolicy;
    private getScratchDecisionTtlMs;
    private requireScratchWorkspace;
    private clearScratchCleanupTimer;
    private scheduleScratchCleanup;
    private sanitizeWorkspaceName;
    private allocatePromotedPath;
}
//# sourceMappingURL=workspace-service.d.ts.map