import type { TrustAuthorizationPolicy } from "../trust-policy.js"; import type { RuntimeExposureStatus } from "./runtime-exposure.js"; export type ExecutionWorkspaceStrategyType = "project_primary" | "git_worktree" | "adapter_managed" | "cloud_sandbox"; export type ProjectExecutionWorkspaceDefaultMode = "shared_workspace" | "isolated_workspace" | "operator_branch" | "adapter_default"; export type ExecutionWorkspaceMode = "inherit" | "shared_workspace" | "isolated_workspace" | "operator_branch" | "reuse_existing" | "agent_default"; export type SharedWorkspaceConcurrency = "auto" | "serialize" | "allow"; export type ExecutionWorkspaceProviderType = "local_fs" | "git_worktree" | "adapter_managed" | "cloud_sandbox"; export type ExecutionWorkspaceStatus = "active" | "idle" | "in_review" | "archived" | "cleanup_failed"; export type ExecutionWorkspaceDeliveryState = "merged_via_pr" | "merged_by_ancestry" | "unmerged" | "unknown"; export type ExecutionWorkspaceCloseReadinessState = "ready" | "ready_with_warnings" | "blocked"; export type ExecutionWorkspaceCloseActionKind = "archive_record" | "stop_runtime_services" | "cleanup_command" | "teardown_command" | "git_worktree_remove" | "git_branch_delete" | "remove_local_directory"; export type WorkspaceRuntimeDesiredState = "running" | "stopped" | "manual"; export type WorkspaceRuntimeServiceStateMap = Record; export type WorkspaceCommandKind = "service" | "job"; export interface WorkspaceCommandSource { type: "paperclip"; key: "commands" | "services" | "jobs"; index: number; } export interface WorkspaceCommandDefinition { id: string; name: string; kind: WorkspaceCommandKind; command: string | null; cwd: string | null; port: number | null; lifecycle: "shared" | "ephemeral" | null; serviceIndex: number | null; disabledReason: string | null; rawConfig: Record; source: WorkspaceCommandSource; } export interface ExecutionWorkspaceStrategy { type: ExecutionWorkspaceStrategyType; baseRef?: string | null; branchTemplate?: string | null; /** * Pin the worktree to this exact pre-existing branch instead of rendering * `branchTemplate`. Realization attaches (never creates) the branch and * fails closed when the branch does not exist or is not safely attachable. */ existingBranch?: string | null; worktreeParentDir?: string | null; provisionCommand?: string | null; runtimeProvisionCommand?: string | null; teardownCommand?: string | null; } export interface ExecutionWorkspaceConfig { environmentId?: string | null; provisionCommand: string | null; runtimeProvisionCommand?: string | null; teardownCommand: string | null; cleanupCommand: string | null; workspaceRuntime: Record | null; desiredState: WorkspaceRuntimeDesiredState | null; serviceStates?: WorkspaceRuntimeServiceStateMap | null; } export interface ProjectWorkspaceRuntimeConfig { workspaceRuntime: Record | null; desiredState: WorkspaceRuntimeDesiredState | null; serviceStates?: WorkspaceRuntimeServiceStateMap | null; } export interface WorkspaceRuntimeControlTarget { workspaceCommandId?: string | null; runtimeServiceId?: string | null; serviceIndex?: number | null; } export interface ExecutionWorkspaceCloseAction { kind: ExecutionWorkspaceCloseActionKind; label: string; description: string; command: string | null; } export interface ExecutionWorkspaceCloseLinkedIssue { id: string; identifier: string | null; title: string; status: string; isTerminal: boolean; } export interface ExecutionWorkspaceCloseGitReadiness { repoRoot: string | null; workspacePath: string | null; branchName: string | null; baseRef: string | null; hasDirtyTrackedFiles: boolean; hasUntrackedFiles: boolean; dirtyEntryCount: number; untrackedEntryCount: number; aheadCount: number | null; behindCount: number | null; isMergedIntoBase: boolean | null; createdByRuntime: boolean; } export interface ExecutionWorkspaceCloseReadiness { workspaceId: string; deliveryState: ExecutionWorkspaceDeliveryState; state: ExecutionWorkspaceCloseReadinessState; blockingReasons: string[]; warnings: string[]; linkedIssues: ExecutionWorkspaceCloseLinkedIssue[]; plannedActions: ExecutionWorkspaceCloseAction[]; isDestructiveCloseAllowed: boolean; isSharedWorkspace: boolean; isProjectPrimaryWorkspace: boolean; git: ExecutionWorkspaceCloseGitReadiness | null; runtimeServices: WorkspaceRuntimeService[]; } export interface ProjectExecutionWorkspacePolicy { enabled: boolean; sharedWorkspaceConcurrency?: SharedWorkspaceConcurrency; defaultMode?: ProjectExecutionWorkspaceDefaultMode; allowIssueOverride?: boolean; defaultProjectWorkspaceId?: string | null; environmentId?: string | null; workspaceStrategy?: ExecutionWorkspaceStrategy | null; workspaceRuntime?: Record | null; branchPolicy?: Record | null; pullRequestPolicy?: Record | null; runtimePolicy?: Record | null; cleanupPolicy?: Record | null; authorizationPolicy?: TrustAuthorizationPolicy | null; } export interface IssueExecutionWorkspaceSettings { mode?: ExecutionWorkspaceMode; sharedWorkspaceConcurrency?: SharedWorkspaceConcurrency; environmentId?: string | null; workspaceStrategy?: ExecutionWorkspaceStrategy | null; workspaceRuntime?: Record | null; networkEgress?: { allowFqdns?: string[]; allowCidrs?: string[]; } | null; } export interface ExecutionWorkspaceSummary { id: string; name: string; mode: Exclude | "adapter_managed" | "cloud_sandbox"; status: ExecutionWorkspaceStatus; cwd: string | null; branchName: string | null; projectWorkspaceId: string | null; lastUsedAt: Date; } export interface WorkspaceOverviewLinkedIssue { id: string; identifier: string | null; title: string; status: string; priority: string; updatedAt: Date; } export interface WorkspaceOverviewPrimaryService { id: string; serviceName: string; status: WorkspaceRuntimeService["status"]; url: string | null; port: number | null; healthStatus: WorkspaceRuntimeService["healthStatus"]; /** HTTPS exposure state, surfaced separately from process `healthStatus`. */ exposure?: RuntimeExposureStatus | null; updatedAt: Date; } export interface WorkspaceOverviewItem { key: string; kind: "execution_workspace"; workspaceId: string; workspaceName: string; projectId: string; projectUrlKey: string; projectName: string; mode: ExecutionWorkspaceSummary["mode"]; strategyType: ExecutionWorkspaceStrategyType; cwd: string | null; branchName: string | null; lastUpdatedAt: Date; projectWorkspaceId: string | null; executionWorkspaceId: string; executionWorkspaceStatus: ExecutionWorkspaceStatus; serviceCount: number; runningServiceCount: number; primaryServiceUrl: string | null; primaryServiceUrlRunning: boolean; primaryService: WorkspaceOverviewPrimaryService | null; hasRuntimeConfig: boolean; linkedIssueCount: number; linkedIssues: WorkspaceOverviewLinkedIssue[]; } export interface WorkspaceOverviewResponse { items: WorkspaceOverviewItem[]; total: number; limit: number; offset: number; hasMore: boolean; nextOffset: number | null; } export interface ExecutionWorkspace { id: string; companyId: string; projectId: string; projectWorkspaceId: string | null; sourceIssueId: string | null; mode: Exclude | "adapter_managed" | "cloud_sandbox"; strategyType: ExecutionWorkspaceStrategyType; name: string; status: ExecutionWorkspaceStatus; deliveryState: ExecutionWorkspaceDeliveryState; cwd: string | null; repoUrl: string | null; baseRef: string | null; branchName: string | null; providerType: ExecutionWorkspaceProviderType; providerRef: string | null; derivedFromExecutionWorkspaceId: string | null; lastUsedAt: Date; openedAt: Date; closedAt: Date | null; cleanupEligibleAt: Date | null; cleanupReason: string | null; config: ExecutionWorkspaceConfig | null; metadata: Record | null; runtimeServices?: WorkspaceRuntimeService[]; createdAt: Date; updatedAt: Date; } export interface WorkspaceRuntimeService { id: string; companyId: string; projectId: string | null; projectWorkspaceId: string | null; executionWorkspaceId: string | null; issueId: string | null; scopeType: "project_workspace" | "execution_workspace" | "run" | "agent"; scopeId: string | null; serviceName: string; status: "provisioning" | "starting" | "running" | "stopped" | "failed"; lifecycle: "shared" | "ephemeral"; reuseKey: string | null; command: string | null; cwd: string | null; port: number | null; url: string | null; provider: "local_process" | "adapter_managed"; providerRef: string | null; ownerAgentId: string | null; startedByRunId: string | null; lastUsedAt: Date; startedAt: Date; stoppedAt: Date | null; stopPolicy: Record | null; healthStatus: "unknown" | "healthy" | "unhealthy"; /** * Structured HTTPS exposure state for the opt-in `tailscale_https` mode, * modelled independently of `healthStatus` (process health). Null when the * service does not opt into exposure. See PAP-17049 / PAP-17050. */ exposure?: RuntimeExposureStatus | null; configIndex?: number | null; createdAt: Date; updatedAt: Date; } export type WorkspaceRealizationMode = "copy" | "in_place"; export interface WorkspaceRealizationPathAlias { path: string; target: string; } export interface WorkspaceRealizationRequest { version: 1; adapterType: string; companyId: string; environmentId: string; executionWorkspaceId: string | null; issueId: string | null; heartbeatRunId: string; requestedMode: string | null; source: { kind: "project_primary" | "task_session" | "agent_home"; localPath: string; projectId: string | null; projectWorkspaceId: string | null; repoUrl: string | null; repoRef: string | null; strategy: "project_primary" | "git_worktree"; branchName: string | null; worktreePath: string | null; }; /** * Read-only referenced (mentioned) project sources for this run, one per authorized additional * project. Additive and backward-compatible: it defaults to an empty array for legacy payloads * and for the anchor-only path. Additional sources are plain trees; they never get git-worktree * realization (that stays the anchor-only path). */ additionalSources?: Array<{ localPath: string; projectId: string | null; projectWorkspaceId: string | null; repoUrl: string | null; repoRef: string | null; }>; runtimeOverlay: { provisionCommand: string | null; runtimeProvisionCommand: string | null; teardownCommand: string | null; cleanupCommand: string | null; workspaceRuntime: Record | null; }; } export interface WorkspaceRealizationRecord { version: 1; mode: WorkspaceRealizationMode; authoritativeRoot: string; pathAliases: WorkspaceRealizationPathAlias[]; outboundRestorePaths: string[]; provider: string | null; environmentId: string; leaseId: string; providerLeaseId: string | null; local: { path: string; source: WorkspaceRealizationRequest["source"]["kind"]; strategy: WorkspaceRealizationRequest["source"]["strategy"]; projectId: string | null; projectWorkspaceId: string | null; repoUrl: string | null; repoRef: string | null; branchName: string | null; worktreePath: string | null; }; /** * Realized read-only referenced (mentioned) project workspaces for this run, one per authorized * additional source in the request. This field carries each resolved path to the execution * target so the target can expose the referenced trees to the agent. It is additive and * backward-compatible: it defaults to an empty array for legacy records and for the anchor-only * path. */ additional?: Array<{ path: string; projectId: string | null; projectWorkspaceId: string | null; repoUrl: string | null; repoRef: string | null; }>; remote: { path: string | null; host?: string | null; port?: number | null; username?: string | null; sandboxId?: string | null; }; bootstrap: { command: string | null; }; rebuild: { executionWorkspaceId: string | null; mode: string | null; repoUrl: string | null; repoRef: string | null; localPath: string; remotePath: string | null; providerLeaseId: string | null; metadata: Record; }; summary: string; } //# sourceMappingURL=workspace-runtime.d.ts.map