/** * "What is this run?" — the ONE resolver (seam X2), read from the engine's own record. * * The engine stores a synthetic `workflow_id` on every run it launches (`wf-`), so the name a * run was launched under is not on the session's `workflow_id`. Crew used to recover it by matching * the run's unit sequence against its mirrors of the built-in defs — which stops matching the moment * the engine's floor adds a step to a preset run, never matched a user plan (`:plan-`), * and cannot survive the mirrors being deleted. This module replaces that guess with what the * engine RECORDED: * * 1. `AgentSession.team_plan` (wicked-core `TeamPlanState`, DES-TEAMING-002 §8.4) — present on a * run launched from a plan or a preset. `team_plan.preset` names the preset; absent, the run * is a USER PLAN. * 2. The launch's `sessionStarted` frame in the engine's durable run event log (`workflowId`): * the preset name, the registered def id, the per-run plan def (`:plan-`) or `null` * for a free-text run. The adapter reads it once per run and memoizes it (`launched` below); * this is the only record of a NON-team run's def, because the session keeps only `wf-`. * 3. A session whose `workflow_id` is not synthetic already names its def. * * Each unit's catalog id (`WorkUnit.catalog`, stamped by the engine on a catalog-composed plan) is * carried as-is. Nothing here reads unit ids or phase sequences. * * SYSTEM classification lives here too, in ONE list keyed by preset/workflow name: the runs studio * keeps off its delivery surfaces (chat, onboarding, the interactive seams, …). The served run * carries it as `run_identity.system`, and `listWorkflows()` stamps the defs' `is_system` from the * same list, so the two can no longer disagree. */ import type { RunIdentity, SessionView, WorkflowDef } from './types.js'; /** * The machine-owned workflows and presets — keyed by NAME, so a preset and the def it replaces * classify alike (`chat` and `onboarding` are engine built-in presets since DES-TEAMING-002 * M3/M4). Studio hides these from its delivery surfaces and its work-mode selector; * `GET /workflows` serves `is_system: true` for exactly these ids, and `GET /presets` serves * `system: true` for a preset of one of these names. */ export declare const SYSTEM_WORKFLOWS: ReadonlySet; /** Whether a preset/workflow name is a system one ({@link SYSTEM_WORKFLOWS}). */ export declare function isSystemWorkflow(name: string | null | undefined): boolean; /** * A def with its `is_system` flag set from {@link isSystemWorkflow} — the ONE source of the flag. * Returns the same object when it already agrees (a registered def's own `is_system` is not a * second source: it is overwritten either way). */ export declare function withSystemFlag(def: T): T; /** * A preset with its `system` flag set from {@link SYSTEM_WORKFLOWS} — the preset's half of the one * classification (DES-TEAMING-002 §11.3: delivery classification reads the preset's system flag * where it read the def's `is_system`). */ export declare function withPresetSystemFlag(preset: T): T & { system: boolean; }; /** * The run a per-run plan def id belongs to — `:plan-`, `rev` a positive decimal * (wicked-core `plan::per_run_def_run_id`, the same reserved shape). `null` for any other id. */ export declare function perRunPlanRunId(defId: string): string | null; /** The engine's synthetic instance id — a session that carries it does not name its def. */ export declare function isSyntheticWorkflowId(workflowId: string): boolean; /** What the resolver answers: the wire identity plus each unit's catalog id, in `ord` order. */ export interface ResolvedRun extends RunIdentity { /** `WorkUnit.catalog` per unit, ordered by `ord` — `null` for a unit not planned from the catalog. */ catalog: Array; } /** * Resolve a run from its record. * * `launched` is the launch's `sessionStarted.workflowId` from the engine's event log: `undefined` * when it is not known (no log binding, a run predating the log, or a caller that has none), * `null` when the launch named nothing (a free-text run). Pure. */ export declare function resolveRunIdentity(view: SessionView, launched?: string | null): ResolvedRun; /** The wire half of a resolution (`AgentSession.run_identity`): the identity without the catalog. */ export declare function wireIdentity(resolved: ResolvedRun): RunIdentity; /** * The identity of a served run view: the one the adapter attached (`session.run_identity`, which * the event-log read informed), else resolved from the record alone. Every caller asking "what is * this run?" goes through here. */ export declare function runIdentityOf(view: SessionView): ResolvedRun; /** The run's preset or workflow NAME (`null` for a user plan, a free-text run, or an unknown one). */ export declare function runNameOf(view: SessionView): string | null; /** * The registered def carrying the run's name, for callers that read def fields (acceptance, * delivery candidacy, the deliver text). `null` when the run has no name or the registry holds no * def under it. A lookup BY NAME — never by phase sequence. */ export declare function runWorkflowDef(view: SessionView, workflows: WorkflowDef[]): WorkflowDef | null; /** * The catalog ids whose entry declares `verified_evidence`, from `Core.catalog()`'s entries — * `null` when the catalog does not carry the flag (an older engine), so no caller mistakes "not * said" for "none". */ export declare function verifiedEvidenceCatalog(entries: ReadonlyArray<{ id: string; verified_evidence?: boolean; }>): ReadonlySet | null; //# sourceMappingURL=run-identity.d.ts.map