import type { Context } from '@deepseek-ai/cordis'; import type { HarnessResolver } from './_shared.ts'; import type { SessionHint } from './workflow-selection.ts'; /** Logger label for the planMode bridge (dsh logger naming: `/`). */ export declare const PLAN_MODE_BRIDGE_LOGGER = "mstar/plan-mode-bridge"; /** Consumer log levels the module sink understands. */ export type PlanModeBridgeLogLevel = 'debug' | 'warn'; /** Module-level consumer log sink — bound by `apply` to `ctx.logger(PLAN_MODE_BRIDGE_LOGGER)` (goal-bridge precedent). */ export type PlanModeBridgeLogSink = (level: PlanModeBridgeLogLevel, message: string) => void; /** * Bind the planMode-bridge log sink (the entry `apply` binds it to * `ctx.logger(PLAN_MODE_BRIDGE_LOGGER)`). Returns the PRIOR sink so a caller * can restore it (test pattern: goal-bridge `setGoalBridgeLogger`). */ export declare function setPlanModeBridgeLogger(sink: PlanModeBridgeLogSink): PlanModeBridgeLogSink; /** * Minimal structural view of the planMode service the bridge consumes * (`@deepseek-ai/dsh-plan-mode` `PlanModeController` — every method is * agent-scoped; the runtime read is `ctx.get('planMode')` without the * inject requirement, same pattern as the goal bridge). `set` is idempotent: * `'noop'` when the target already matches (`plan-mode/src/index.ts:425-445`). */ export interface PlanModeServiceView { get(agent: unknown): { active?: unknown; pending?: unknown; } | undefined; set(agent: unknown, active: boolean): unknown; } /** * The planMode target for one harness + carrying session: `true` iff the * SELECTED lifecycle's own compass still steers (compass `status: * active|locked`, `iteration_id` matching the snapshot) AND the selected * snapshot carries a Prepare window (≥1 plan row `Todo`). Otherwise the * target is OFF. * @param harnessDir - the resolved `{HARNESS_DIR}`. * @param hint - the root session's carrying hint (lease / cwd / durable pick). * @returns `true`/`false` for a resolved selection, or `undefined` when this * session has NO selected lifecycle (unbound multi-active / unreadable * binding record) — the caller must leave plan mode alone rather than * fabricate `false`, which would assert a state for a workflow the session * never selected. */ export declare function planModeTarget(harnessDir: string, hint?: SessionHint): Promise; /** Inputs of the sync: the structural planMode view and the per-workspace resolver. */ export interface PlanModeSyncInput { resolver: HarnessResolver; /** The structural planMode view (`ctx.get('planMode')`); absent → the sync is inert. */ planMode?: PlanModeServiceView; } /** * Mirror the harness Prepare state into the planMode selection of ONE agent: * root-like agent (`header.parentSession === undefined`) → resolve the * workspace → compute {@link planModeTarget} from THAT root session's selected * lifecycle → `planMode.set(agent, target)`. The service's `'noop'` return * makes repeated evaluation at multiple decision points churn-free (no new * `plan/mode` event when already in target). Non-root agent / unresolvable * harness / missing planMode service / an UNBOUND session (no selected * lifecycle) → no set. * * @returns `true` when the sync ran for this agent (set called); `false` * when not applicable or a contained failure occurred. Never throws — the * caller's listener stays contained. */ export declare function syncPlanMode(agent: unknown, input: PlanModeSyncInput): Promise; /** * Register the planMode bridge: an `agent/created` listener (root * filter inside — root and children alike fire, `runtime-types.ts:217`) plus * the EXISTING `subagent/start` decision point, * resolving the delegating ROOT via the shared `parentSession` walk — the * two edges are idempotent (`'noop'` when already in target — no churn). The * planMode service is an OPTIONAL seam (`ctx.get('planMode')` structural * read): absent → ONE debug log + the bridge stays inert, never a boot * failure. Every listener body is try/catch-contained. * * @param ctx - the plugin's registrant context (the app composition root). * @param resolver - the shared per-workspace `{HARNESS_DIR}` resolver. */ export declare function registerPlanModeBridge(ctx: Context, resolver: HarnessResolver): void;