import type { WorkflowGateMode, WorkflowPhase } from '../types/index.js'; import type { ProtectedPolicyLayer } from './protected-bundle.js'; import { type RuntimePermissionSupport } from './runtime-permissions.js'; export declare function isCursorAuthError(exitCode: number, stderr: string): boolean; export type CursorFallback = { prompt: string; ruleFile: string; resumeCommand: string; }; export type SupportedRuntime = 'claude' | 'cursor' | 'codex' | 'opencode' | 'agentforce' | 'windsurf'; /** * Resolve a profile's rule file for a given runtime, in its runtime-native * location and extension: Cursor → `.cursor/rules/.mdc`, Claude → * `.claude/rules/.md`, Codex → `.codex/.md`, OpenCode → * `.opencode/agents/.md`. Returns the path * when it exists, else `null`. Centralizes the per-runtime path logic so the * preview (buildCursorFallback) and the real invocation (buildRuntimeInvocation) * can never diverge (which produced a misleading "rule file not found" preview * when a non-cursor runtime was targeted). */ export declare function resolveProfileRuleFile(cwd: string, profile: string, runtime: SupportedRuntime): string | null; /** * Maximum combined byte size of the appended system prompt (rule file content + * primary skill content) for the claude runtime. Claude's `--append-system-prompt` * takes a literal string, so we read file CONTENT and concatenate it into one arg. * Rules are <=40KB by policy and skills are 1-7KB; if the combined payload would * exceed this ceiling we drop the skill back to reference-only (demand-loaded by * path in the phase prompt) so the spawn can never trip "Prompt is too long". */ export declare const CLAUDE_APPEND_SYSTEM_PROMPT_BUDGET: number; export type ProtectedPolicyLoader = () => ProtectedPolicyLayer | null | undefined; export type ClaudeSystemPromptOptions = { protectedPolicyLoader?: ProtectedPolicyLoader; }; /** * Pick the phase's PRIMARY skill: the matched capability skill with the most * matched signals (ties broken by catalog order). Returns the skill descriptor * plus its on-disk content, or null when no skill matched, the file is absent, * or it cannot be read. This is the "how-to" we guarantee-load into the spawned * agent rather than merely referencing by path (GH #414). */ export declare function resolvePrimarySkill(cwd: string, profile: string, capabilitySignals: string[], storyId: string, phase: WorkflowPhase): { title: string; path: string; content: string; } | null; /** * Build the claude `--append-system-prompt` payload: the role rule file content * (the WHAT/guardrails) plus, budget permitting, the phase primary skill content * (the HOW-TO). Returns the combined string and which skill (if any) was inlined. * When no rule file exists the payload is the skill alone; when neither exists it * is null and the caller omits the flag entirely. */ export declare function buildClaudeSystemPrompt(cwd: string, profile: string, capabilitySignals: string[], storyId: string, phase: WorkflowPhase, options?: ClaudeSystemPromptOptions): { content: string | null; ruleFile: string | null; appendedSkill: string | null; }; export declare function buildCursorFallback(phase: WorkflowPhase, storyId: string, cwd: string, runtime?: SupportedRuntime): CursorFallback; export declare const DEFAULT_WORKFLOW_RUNTIME_PREFERENCE: readonly ["claude", "cursor", "codex", "opencode"]; export type WorkflowRuntimePreference = (typeof DEFAULT_WORKFLOW_RUNTIME_PREFERENCE)[number]; export declare function normalizeWorkflowRuntimePreference(values?: readonly string[] | string | null): WorkflowRuntimePreference[]; export declare function detectRuntime(preference?: readonly string[]): SupportedRuntime | null; export type RuntimeInvocation = { command: string; args: string[]; env?: NodeJS.ProcessEnv; ruleFile: string | null; /** Path of the primary skill inlined into the system prompt (claude), or null. */ appendedSkill?: string | null; permissionSupport?: RuntimePermissionSupport; }; /** Render an invocation without exposing prompt payloads carried in argv. */ export declare function renderRuntimeInvocation(invocation: RuntimeInvocation): string; export type RuntimeInvocationOptions = { gates?: WorkflowGateMode; maxAgents?: number; capabilitySignals?: string[]; protectedPolicyLoader?: ProtectedPolicyLoader; }; export declare function assertAutonomousRuntime(runtime: SupportedRuntime): void; export declare function collectSubagentCapabilitySignals(cwd: string, storyId: string): string[]; export declare function claudePermissionArgs(gates: WorkflowGateMode): string[]; export declare function codexPermissionArgs(_gates: WorkflowGateMode): string[]; export declare function cursorPermissionArgs(_gates: WorkflowGateMode): string[]; export declare function runtimePermissionSupport(runtime: SupportedRuntime): RuntimePermissionSupport; export declare function buildInvocation(runtime: SupportedRuntime, phase: WorkflowPhase, storyId: string, cwd: string, options?: RuntimeInvocationOptions | WorkflowGateMode): RuntimeInvocation;