// Types for the orchestrator IR — docs/ORCHESTRATOR-IR.md §2 is normative. // // ONT-6: every record shape is the committed ontology contract's // (`sdk/interchange/ontology-schemas.json`), reached // through `./ontology.d.ts` — written by // `node sdk/orchestrator/scripts/generate-types.mjs` from `supercode ontology schema`. // Declare no record here; update the contract and regenerate. import type { Access, AccessPolicy, ArtifactFidelity, Attachment, Binding, ChannelConfig, EndReason, EnvValue, Fidelity, Fire, FireStatus, Handoff, HarnessId, Job, JobOrigin, Obligation, ObligationSource, ObligationState, OutboundContent, PermissionDefault, PermissionPolicy, PermissionUnattended, PersonaRef, Posted, Profile, ProfileResidue, Recurrence, Repeat, Residue, Route, RouteMatch, Schedule, SecretRef, SurfaceKey, Target, Trigger, WebhookSubscription, Worker, WorkerSpec, Orchestration, } from './ontology.js'; export type { Access, AccessPolicy, ArtifactFidelity, Attachment, Binding, ChannelConfig, EndReason, EnvValue, Fidelity, Fire, FireStatus, Handoff, HarnessId, Job, JobOrigin, Obligation, ObligationSource, ObligationState, OutboundContent, PermissionDefault, PermissionPolicy, PermissionUnattended, PersonaRef, Posted, Profile, ProfileResidue, Recurrence, Repeat, Residue, Route, RouteMatch, Schedule, SecretRef, SurfaceKey, Target, Trigger, WebhookSubscription, Worker, WorkerSpec, Orchestration, }; export type Path = string; export type RelPath = string; export type Instant = string; // RFC 3339 export type ProfileName = string; export type Platform = string; export type UserId = string; export type JobId = string; export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; // C7 host APIs refer to the neutral Teams identity contract. Profile records remain the ontology's. export type AgentIdentity = import('@volter/teams/http-client').AgentRecord; export function resolveAgentProfile(profiles: Record, name: string, overlays?: Array>): {profile: string; layers: string[]; resolved: Record}; export function profileDifferences(intended: unknown, actual: unknown): Array<{field: string; intended: unknown; actual: unknown}>; export function sessionAgent(options: {starter?: {kind?: string; id?: string; agent?: string | null}; declared?: string | null; asAgent?: string | null; profileAgent?: string | null}): string | null; export function agentStateHome(root: Path, org: string, id: string): Path; export function recordNativeAgentSession(root: Path, runtimeRef: string, session: string): Record | null; export function materializeAgentHome(root: Path, org: string, id: string, profile: Profile): Path; export function declareAgentIntent(options: {root: Path; org: string; server: string; profiles: Record; profile: string; key: string; machine?: string | null}): Record; export function agentRunForKey(root: Path, org: string, agent: string, key: string): Record | null; export function agentIntent(root: Path, org: string, id: string): Record | null; export function assignAgent(root: Path, org: string, id: string, assignment: {kind: string; target: string; role: string}): string; export function reassignAgent(root: Path, org: string, assignment: string, to: string, options?: {context?: string}): Promise>; export function activeAgentAssignments(root: Path): Array>; /** Retained card assignments, including ended rows awaiting a board mirror. */ export function cardAgentAssignments(root: Path, target?: string | null): Array>; /** Permanent offline adoption scope and its current destination-native assignments, read together. */ export function cardAgentScopeTransition(root: Path, target: string): {from_org: string; org: string; changed_at: number; assignments: Array>} | null; export function pendingCardAgentChanges(root: Path, target: string): Array<{receipt: number; [key: string]: unknown}>; export function acknowledgeCardAgentChanges(root: Path, receipts: number[]): void; export function finishAgentAssignment(root: Path, org: string, assignment: string, reason: string): Record | null; export function recordAgentRun(root: Path, org: string, id: string, run: {session: string; machine?: string | null; run: string | number; profile?: unknown; main?: boolean; starterSession?: string | null}): void; export function agentRunForSession(root: Path, references: Array): Record | null; export function agentPreamble(agent: LocalAgent, options?: {main?: boolean; previous?: Array<{session: string; machine?: string | null; ended_at?: number | null; end_reason?: string | null}>}): string; export function agentEnvironment(agent: LocalAgent, options: {root: Path; context?: string; session?: string | null; main?: boolean}): Record; /** The Org for agent identity, read from this home's selected context without a request; `offline` when none is selected. Throws when a named context cannot be read. */ export function agentScope(context?: string): {server: string; org: string; principal: string | null; offline?: true; reason?: string}; /** The identity a run starts as without asking Teams; `identity.synced` is false until Teams has its declaration, made later under the same id. */ /** A local agent: its daemon-minted id, retained intent and assignments. */ export type LocalAgent = {identity: AgentIdentity; intended: ReturnType; assignment: string; assignments: Array>; org: string}; export function localCardAgent(options: {root: Path; org: string; server: string; profiles: Record; profile: string; card: string; role: string; handle?: string | null; readableId?: string | null; machine?: string | null; starterSession?: string | null}): LocalAgent & {synced: false}; export function localProfileAgent(options: {root: Path; org: string; server: string; profiles: Record; profile: string; machine?: string | null; agent?: string | null; declarations?: Record}): LocalAgent & {synced: false}; export function localForkAgent(options: {root: Path; org: string; server: string; profiles: Record; parent: string; session: string; name: string; key: string}): LocalAgent; /** Hand this home's agent declarations and ends to this machine's daemon, which declares and ends them in Teams. Answers what could not be handed on. */ export function handOffAgents(root: Path, options?: {context?: string}): Array<{agent: string; error: string}>; export function localAgentRecord(root: Path, org: string, id: string): LocalAgent | null; export function homeAgentId(root: Path, scope: {org: string; server: string; name: string; profile?: string}): string | null; export function localAgentSessions(root: Path, org: string, id: string): Array<{session: string; machine: string | null; ended_at: number | null; end_reason: string | null}>; export function agentProfileMismatch(intent: unknown, resolved: unknown): import('@volter/teams/agent-profile').ProfileComparison; export type ChatType = 'dm' | 'group' | 'channel' | 'thread'; export interface RuntimeState { leases: Record; queues: Record; turns: Record; starting: Record; /** The last worker event per lease (§4.3's inactivity limit). */ activity: Record; adapters: Record; pending_requests: Record; /** The worker's settlements of requests not yet queued (`settled` before its `request`), as `runtime_id\nrequest id`: the most recent 256. */ settled_requests?: string[]; clock: Instant | null; hostedJobs?: boolean; hostedFires?: Record; } export interface RequestOption { optionId?: string; name: string; kind?: string; response?: JsonValue } // ---------------------------------------------------------------- events (§3) export type WorkerEvent = | { kind: 'started'; runtime_id: string; session_id?: string; connection?: string | null; harness?: HarnessId; reattach_of?: string } | { kind: 'text'; delta: string } /** Any other runtime event (a tool call, reasoning, a turn start): the worker is alive. */ | { kind: 'activity' } | { kind: 'steer_refused'; text: string; webhook_input_id?: string | null } | { kind: 'final'; text: string | null; outcome?: 'completed' | 'error'; message?: string | null } | { kind: 'request'; id: string; subject: string; options: RequestOption[] } /** The worker settled request `id` itself (Claude Code's `control_cancel_request`, Codex's `serverRequest/resolved`). */ | { kind: 'settled'; id: string } | { kind: 'ended'; reason: string } | { kind: 'error'; message: string }; export type OrchestratorEvent = | { type: 'inbound'; profile: ProfileName; key: SurfaceKey; sender: UserId; sender_name: string | null; text: string; attachments: Attachment[]; at: Instant; adapter: Platform; guild_id: string | null; /** The platform's id for this message: the threading, reaction and edit target (ORC-1 F4). */ message_id: string | null; /** Enriched from the public identity record by the loop; never trusted from an adapter. */ identity?: Awaited>['data']; /** Our own echo (§4.1 step 0 drops it), a bot sender (`null` = the SDK's "unknown"), and whether we were @-mentioned. */ is_me: boolean; is_bot: boolean | null; mention: boolean; } | { type: 'tick'; at: Instant; inactivity_s?: number | null; max_parallel?: number | null } | { type: 'hosted_result'; profile: ProfileName; fire_id: string; at: Instant; receipt?: HostedReceipt; error?: string } | { type: 'worker'; profile: ProfileName; keyString: string; runtime_id: string | null; ev: WorkerEvent; at: Instant } | { type: 'adapter'; platform: Platform; state: 'up' | 'down'; error: string | null; at: Instant } | { type: 'operator'; verb: string; profile: ProfileName; args: Record; at: Instant } | { type: 'webhook'; name: string; payload: JsonValue; verified: boolean; at: Instant; event: string | null; delivery_id: string | null; admission_id?: string } | { type: 'webhook_refused'; name: string; delivery_id: string | null; admission_id: string; profile?: ProfileName; keyString?: string; handed: boolean; stopping: boolean; at: Instant } | { type: 'restart'; at: Instant } | { type: 'stopping'; at: Instant }; // ---------------------------------------------------------------- effects (§5) export type Effect = | { type: 'execute_job'; profile: ProfileName; job_id: string; fire_id: string } | { type: 'runtime_start'; profile: ProfileName; keyString: string; worker: WorkerSpec; prompt: string | null } | { type: 'runtime_close'; profile: ProfileName; keyString: string; lease: RuntimeState['leases'][string] } | { type: 'send_input'; profile: ProfileName; keyString: string; text: string; context_from?: string[] | null; skills?: string[]; job_id?: string; webhook_input_id?: string } | { type: 'webhook_input'; admission_id: string; profile: ProfileName; keyString: string; refusal?: string } | { type: 'respond'; profile: ProfileName; keyString: string; request_id: string; response: JsonValue } | { type: 'deliver'; profile: ProfileName; obligation_id: string } | { type: 'write_local'; profile: ProfileName; path: RelPath; text: string } | { type: 'save' } | { type: 'log'; level: 'info' | 'warn' | 'error'; message: string }; /** The reducer: mutates `state`, returns effects, performs no I/O. */ export function step(state: OrchestratorState, event: OrchestratorEvent): Effect[]; /** Hermes's session reset, as `sessionReset` reads it from the home's `session_reset:`. */ export interface SessionReset { mode: 'none' | 'daily' | 'idle' | 'both'; at_hour: number; idle_minutes: number } export function sessionReset(profile: Profile): SessionReset; /** A platform's home channel (`platforms.

.home_channel`) as a chat key; with no platform, the first one; or null. */ export function homeChannel(profile: Profile, platform?: string | null): SurfaceKey | null; export function expired(binding: Binding, reset: SessionReset, now: Instant): EndReason | null; export function leaseId(profile: ProfileName, keyString: string): string; export namespace events { function inbound(fields: Omit, 'type' | 'identity' | 'attachments' | 'adapter' | 'guild_id' | 'sender_name' | 'message_id' | 'is_me' | 'is_bot' | 'mention'> & { attachments?: Attachment[]; adapter?: Platform; guild_id?: string | null; sender_name?: string | null; message_id?: string | null; is_me?: boolean; is_bot?: boolean | null; mention?: boolean }): Extract; function tick(at: Instant, inactivity_s?: number | null, max_parallel?: number | null): Extract; function worker(fields: Omit, 'type'>): Extract; function adapterStatus(fields: Omit, 'type' | 'error'> & { error?: string | null }): Extract; function operator(fields: { verb: string; profile?: ProfileName; args?: Record; at: Instant }): Extract; function restart(at: Instant): Extract; function stopping(at: Instant): Extract; function webhook(fields: { name: string; payload?: JsonValue; verified?: boolean; at: Instant; event?: string | null; delivery_id?: string | null }): Extract; } export function parseCommand(text: string): { name: string; args: string } | null; export function frame(profile: ProfileName, key: SurfaceKey, sender: UserId, senderName: string | null, at: Instant, text: string, identity?: Extract['identity'] | null): string; export const COMMANDS: Set; export const REPLY: Record string)>; export function activationEnv(o: { root: Path; profile: Profile; surfaceKey?: string | null; vault?: Vault }): Record; export function activationCwd(profile: Profile, workdir?: RelPath | null): Path; /** Links the profile's `AGENTS.md` into the worker's config home where the harness reads a persona from any cwd (Codex; Claude Code with its `@AGENTS.md` bridge); answers that home, or null. */ export function materializePersona(profile: Profile): Path | null; export const HOME_ENV: Readonly>; /** Links each skill the profile has into the worker's config home `skills/` (Codex, Claude Code); answers that folder, or null. */ export function materializeSkills(profile: Profile): Path | null; /** Harnesses whose worker can run in the user's own home (`worker.home: user`). */ export const USER_HOME_HARNESSES: ReadonlySet; /** `--plugin-dir /` for a worker in the user's own home; nothing otherwise. */ export function userHomeArguments(profile: { dir: string; worker?: { harness: string; home?: 'profile' | 'user' } }): string[]; /** The profile's persona text for a worker in the user's own home; empty otherwise. */ export function userHomePersona(profile: { dir: string; worker?: { harness: string; home?: 'profile' | 'user' } }): string; export const HOME_SKILLS: Readonly>; export const HOME_PERSONA: Readonly>>>; export const ORCH_ENV: Readonly<{ root: string; profile: string; surface: string }>; // ---------------------------------------------------------------- the loop and adapters (§7) export interface ChannelAdapter { platform: Platform; connect(emit: (msg: Omit, 'type' | 'at' | 'attachments' | 'adapter' | 'guild_id' | 'message_id' | 'is_me' | 'is_bot' | 'mention'> & { at?: Instant; attachments?: Attachment[]; guild_id?: string | null; message_id?: string | null; is_me?: boolean; is_bot?: boolean | null; mention?: boolean }) => unknown): Promise<{ state: 'up' | 'down'; error?: string } | void>; /** A returned `message_id` is recorded on the obligation as `posted` (§2.6). */ send(target: SurfaceKey, content: { text: string; at?: Instant } & Partial): Promise<{ ok?: boolean; message_id?: string } | unknown>; close?(): Promise; } export class LoopbackAdapter implements ChannelAdapter { constructor(o?: { platform?: Platform; profile?: ProfileName; failSends?: number }); platform: Platform; profile: ProfileName; outbox: { target: SurfaceKey; text: string; at: Instant | null }[]; failSends: number; connect(emit: Parameters[0]): Promise<{ state: 'up' }>; inject(m: { kind?: ChatType; chat_id?: string; thread_id?: string; sender?: UserId; sender_name?: string | null; text: string; at?: Instant; guild_id?: string | null }): unknown; send(target: SurfaceKey, content: { text: string; at?: Instant }): Promise<{ ok: true }>; close(): Promise; } /** * ORC-9: a sidecar over `chat@4.39.0` (`vercel/chat`), one instance per * (platform, account). The platform packages (`@chat-adapter/*`) are imported * lazily at `connect`; a missing one is `{ state: 'down' }`, not a throw. */ export class ChatSdkAdapter implements ChannelAdapter { constructor(o: { platform: Platform; profile?: ProfileName; channel?: ChannelConfig | null; vault?: Vault; sdkAdapter?: unknown; chat?: unknown; state?: unknown; log?: (level: string, message: string) => void; }); platform: Platform; profile: ProfileName; /** thread_id -> the live SDK `Thread` this sidecar last answered on. */ readonly threads: Map; readonly chat: unknown; connect(emit: Parameters[0]): Promise<{ state: 'up' | 'down'; error?: string }>; /** The one door from the SDK into the loop: `(thread, message)` -> an `inbound`. */ handle(thread: unknown, message: unknown): unknown; send(target: SurfaceKey, content: { text: string; at?: Instant; reply_to?: string }): Promise<{ ok: true; message_id?: string }>; /** Joins SDK platform/state disconnect and gateway work once; rejects with retained cleanup causes. A failed owner retains its token claim. */ close(): Promise; } export const CHAT_SDK_VERSION: string; export const CHAT_SDK_PACKAGE: string; export const CHAT_SDK_STATE_PACKAGE: string; /** §2.3's four-value `kind` from the Chat SDK's `isDM` / `channelVisibility` split. */ export function chatType(thread: { isDM?: boolean; channelVisibility?: string }): ChatType; export function toAttachment(a: Record): Attachment; export function toInbound(o: { profile: ProfileName; thread: unknown; message: unknown }): Parameters[0]>[0]; /** * ORC-9: Hermes's `api_server` client API, served by this loop on its own * listener at `platforms.api_server.extra.host|port`. Every route it makes the * loop act on enters as an `inbound` (§3). */ export class ApiServerAdapter implements ChannelAdapter { constructor(o: { platform?: Platform; profile?: ProfileName; channel?: ChannelConfig | null; vault?: Vault; state: OrchestratorState; clock?: () => Instant; log?: (level: string, message: string) => void; }); platform: Platform; profile: ProfileName; /** The bound port; `extra.port: 0` lets the OS choose and tests read it here. */ readonly port: number | null; readonly sessions: Map; readonly runs: Map; connect(emit: Parameters[0]): Promise<{ state: 'up' }>; send(target: SurfaceKey, content: { text: string; at?: Instant }): Promise<{ ok: true; message_id: string }>; close(): Promise; } export const API_SERVER_HOST: string; export const API_SERVER_PORT: number; /** * A channel carried to an agent's one mailbox (supercode docs/adr/0008-agent-mailbox.md): * each person's line is filed as channel mail to the agent (a root to its main session, * a reply into its parent's thread), and the agent's answers, filed in this bridge's * mailbox, are posted back anchored at their thread's root. */ export class AgentMailboxBridge { constructor(o: { adapter: ChannelAdapter; /** A harness client (`SupercodeHarnessClient`): `messageSession` and `sessionInbox`. */ client: unknown; /** The agent's name (`sc::agent:`). */ agent: string; platform?: Platform; /** This bridge's mailbox, a participant of every thread it opens. */ fromName?: string; /** Where each thread's root was posted, and each posted answer's root, kept across restarts. */ statePath?: string | null; log?: (level: string, message: string) => void; pollMs?: number; }); start(): Promise; stop(): Promise; } export class Orchestrator { /** Private local preparation only: no hosted runtime or provider process. */ prepareMainPane(options: {directory: string; name: string; resume?: import('@volter/supercode-harness-sdk').SessionLocator | null}): Promise<{ ran: string; program: 'codex'; profile: string; cwd: string; arguments: string[]; env: Record; }>; constructor(o: { state: OrchestratorState; vault?: Vault; client: unknown; // SupercodeHarnessClient from @volter/supercode-harness-sdk adapters?: Record; clock?: () => Instant; executeJob?: ((task: HostedTask) => Promise) | null; launchFor?: (profile: Profile, worker: WorkerSpec, env: Record) => { program: string; arguments: string[]; env: Record } | undefined; log?: (level: string, message: string) => void; }); readonly state: OrchestratorState; readonly vault: Vault; readonly queue: Promise; readonly effectLog: Effect[]; readonly webhookPort: number | null; start(): Promise; /** Seals webhook ingress before waits; joins admitted processing and retains cleanup failures. */ stop(): Promise; tick(at?: Instant): Promise; drainHosted(): Promise; /** A fork starts in a registered, unoccupied conversation on this execution host. */ forkRuntime(options: {profile: ProfileName; keyString: string; parent: string; locator: import('@volter/supercode-harness-sdk').SessionLocator; name: string; key: string; machine?: string | null}): Promise<{agent: AgentIdentity; locator: import('@volter/supercode-harness-sdk').SessionLocator; runtime: unknown}>; dispatch(event: OrchestratorEvent): Promise; enqueue(event: OrchestratorEvent): void; /** §7: effects produced by an MCP tool call, run on the loop's own queue. */ /** §7: the model-facing MCP door's loop side, open between start and stop. */ readonly bridge: { path: Path; close(): Promise } | null; } export function normalizeWorkerEvent(ev: unknown): WorkerEvent | null; // ---------------------------------------------------------------- cron and webhooks (ORC-5, §4.3/§4.4) export interface CronFields { minute: Set; hour: Set; dom: Set; month: Set; dow: Set; domRestricted: boolean; dowRestricted: boolean } /** The next run strictly after `after`, or null when the schedule is spent. */ export function nextRunAt(schedule: Schedule, after: Instant): Instant | null; export function parseCron(expr: string): CronFields; /** Why a schedule cannot be evaluated (bad instant, interval, expression or zone), or null. */ export function scheduleError(schedule: Schedule): string | null; export function dueJobs(profile: Profile, now: Instant): Job[]; export function claimFire(profile: Profile, job: Job, now: Instant): Fire | null; export function finishFire(profile: Profile, fire: Fire, job: Job | null, status: FireStatus, now: Instant, error?: string | null, effects?: Effect[] | null): Fire; /** Re-arm after a run; a schedule that cannot be evaluated disables the job and returns why. */ export function advanceSchedule(job: Job, now: Instant): string | null; export function resolveTarget(job: Job | null, profile: Profile, target?: Target | null): SurfaceKey | { kind: 'local' }; export function cronTick(state: OrchestratorState, ev: Extract, effects: Effect[]): void; export function fireFinal(state: OrchestratorState, profile: Profile, binding: Binding, text: string, now: Instant, effects: Effect[]): boolean; export function fireFailed(state: OrchestratorState, profile: Profile, binding: Binding, message: string, now: Instant, effects: Effect[]): boolean; export function fireSessionName(jobId: JobId, at: Instant): string; export function fireSessionId(fire: Fire): string | null; export function compactStamp(at: Instant): string; export const BACKOFF_MINUTES: readonly number[]; export const BREAKER_FAILURES: number; export const BREAKER_MINUTES: number; export const MAX_ATTEMPTS: number; export const TICK_MS: number; export function handleWebhook(state: OrchestratorState, ev: Extract, effects: Effect[]): void; export function renderTemplate(template: string, payload: unknown): string; export function signBody(secret: string, body: string): Promise; export function verifySignature(secret: string | null, body: string, header: string | null): Promise; export function subscriptionSecret(sub: WebhookSubscription | null, vault?: Vault): string | null; export function findSubscription(state: OrchestratorState, name: string): { profile: Profile; sub: WebhookSubscription } | null; export function webhookKey(name: string): SurfaceKey; export function startWebhookListener(o: { state: OrchestratorState; vault?: Vault; port?: number; host?: string; dispatch: (event: OrchestratorEvent) => unknown; clock: () => Instant; log?: (level: string, message: string) => void }): Promise<{ server: unknown; port: number; close(): Promise }>; /** `gateway.webhook_port` from config residue; 0 when unset. */ export function webhookPort(state: OrchestratorState): number; // ---------------------------------------------------------------- §7: the model-facing MCP door /** One published tool: `name`, `description`, and its JSON Schema. */ export interface OrchestratorTool { name: string; description: string; inputSchema: Record } export const TOOLS: readonly OrchestratorTool[]; export const TOOL_NAMES: readonly string[]; export const SERVER_NAME: string; export const PROTOCOL_VERSION: string; export const SOCKET_ENV: string; export const SERVER_PATH: Path; /** The door a harness publishes for an MCP server. */ export type McpDoor = 'flag' | 'toml' | 'json' | 'none' | 'acp'; export const MCP_DOORS: Readonly>; export function doorFor(harness: string): McpDoor; /** One stdio MCP server, in the uniform shape `harness.v1.runtimes.start` carries. */ export interface McpServerLaunch { name: string; command: string; arguments: string[]; env: Record } export function mountOrchestratorMcp(o: { root: Path; profile: Profile; harness: string; surfaceKey?: string | null; launch?: { program: string; arguments?: string[]; env?: Record }; socketPath?: Path; program?: string; /** The Teams id of the agent the session is; the rh2-agent record installed for that id (`--agent`) is mounted beside * the orchestrator server as `rh2-agent`. */ agentId?: string | null; }): { door: McpDoor; ran: string; launch: unknown; mcp_servers: McpServerLaunch[] | null; path: Path | null }; export function socketPathFor(root: Path): Path; export function startBridge(o: { orch: Orchestrator; socketPath: Path; log?: (level: string, message: string) => void }): Promise<{ path: Path; close(): Promise }>; export function runVerb(orch: Orchestrator, call: { verb: string; args?: Record; profile: ProfileName; surface?: string | null }): Promise<{ result?: Record; effects?: Effect[]; error?: string }>; export function parseSchedule(spec: unknown, now: Instant): Schedule; export function routedProfile(state: OrchestratorState, key: SurfaceKey): ProfileName | null; export function keyFromString(text: string | null): SurfaceKey | null; /** The binding a spawned MCP server reads out of its environment. */ export function bindingFromEnv(env?: Record): { root: Path; profile: ProfileName; surface: string | null; socket: Path }; export function handleRequest(binding: { root: Path; profile: ProfileName; surface: string | null; socket: Path }, request: unknown): Promise; export function serveStdio(binding: { root: Path; profile: ProfileName; surface: string | null; socket: Path }, input?: unknown, output?: unknown): unknown; export interface OrchestratorState { root: Path; profiles: Record; runtime: RuntimeState; } export type Vault = Map; export class LoadError extends Error { file: string; key: string | null } /** What `orchestration.decompile` / `orchestration.export` did (the SDK's `OrchestrationDecompiled`). */ export interface OrchestrationDecompiled { written: ArtifactFidelity[]; refused: { file: RelPath; reason: string }[]; notes?: string[]; rows_byte?: number; rows_emitted?: number; } /** What `orchestration.import` did: the orchestration as written, the vault's key names, and what was carried by path. */ export interface OrchestrationImported { orchestration: Omit; vault_keys: string[]; root: Path; carried: RelPath[]; } /** Our folder, strict, through `harness.v1.orchestration.load`; the vault is read out of the home's own `.env`. */ export function load(root: Path): Promise<{ state: OrchestratorState; vault: Vault }>; /** Runtime persistence through `harness.v1.orchestration.save`. Leaves workflow.yaml untouched; sends no secret. */ export function save(state: OrchestratorState, root?: Path): Promise; /** Another harness's home as a state value; `vault_keys` names the `.env` keys it would need. */ export function compile(from: 'hermes' | 'openclaw', home: Path): Promise<{ state: OrchestratorState; vault_keys: string[] }>; /** Another harness's home becomes our folder, credentials along (`harness.v1.orchestration.import`). */ export function importFrom(from: 'hermes' | 'openclaw', home: Path, into: Path): Promise; /** Our folder becomes another harness's home, credentials along (`harness.v1.orchestration.export`). */ export function exportTo(to: 'hermes' | 'openclaw', root: Path, dest: Path): Promise; /** An orchestration value as the loop's state: the persisted half plus an empty runtime half. */ export function stateOf(orchestration: Omit): OrchestratorState; /** Hold the door open (a running loop does); balanced by `releaseWorld`, after which it closes itself when idle. */ export function retainWorld(): void; export function releaseWorld(): void; /** Close the shared door to `supercode harness serve` now; the next verb opens it again. */ export function closeWorld(): Promise; /** The binary the doors are opened with: `SUPERCODE_BIN`, else this checkout's build, else PATH. */ export function supercodeCommand(): string; export function renderSurfaceKey(profile: ProfileName, key: SurfaceKey): string; export function parseSurfaceKey(text: string): { profile: ProfileName; key: SurfaceKey } | null; export function surfaceKeyString(key: SurfaceKey): string; /** `context_from` as Hermes stores it: a list of job ids (or `self`), or null. */ export function decodeContextFrom(file: string, key: string, value: unknown): string[] | null; export function parseTarget(file: string, key: string, word: string | null, extra?: { chat_id?: string; thread_id?: string }): Target | null; export function renderTarget(t: Target | null): string | null; export function resolveRoute(routes: Route[], key: SurfaceKey, guildId?: string): ProfileName | null; export function routeSpecificity(r: Route): number; export function emptyState(root: Path): OrchestratorState; export function emptyProfile(name: ProfileName, dir: Path): Profile; export function emptyRuntime(): RuntimeState; export function canonicalJson(value: unknown): string; export function persistedView(state: OrchestratorState): Omit; export function parseDotenv(text: string): Map; /** Read every profile's `.env` into `vault` again, in place; true when a value changed. */ export function refreshVault(state: { profiles: Record }, vault: Map): boolean; export const CHAT_TYPES: Set; export const END_REASONS: Set; export const FIRE_STATUSES: Set; export const OBLIGATION_STATES: Set; /** Host receipts confirm dispatch, not the eventual model answer. */ export interface HostedTask { profile: string; job: Job; fire: Fire } export interface HostedReceipt { accepted: true; output: string; profile?: string; fire_id?: string; delivery?: { platform: string; chat_id: string; id: string } } export function callOperator(options: { root: string; profile?: string; op: string; args?: Record; timeoutMs?: number }): Promise; export function httpJobExecutor(options: { url: string; tokenFile: string; root: string; timeoutMs?: number }): (task: HostedTask) => Promise; /** Stop only a hosted daemon owned by this root; wait for native shutdown. */ export function stopHostedDaemon(options: { root: string; executorUrl?: string; timeoutMs?: number }): Promise<{ stopped: boolean; wasRunning: boolean }>; // ---------------------------------------------------------------- the agent-setup applier (apply/, plan §7) /** One agent-setup package: declared records for one home (docs/plans/content-spec-status.md §6). */ export interface SetupPackage { schema_version: 1; parameters?: Record; inference?: { models?: Record; default?: string; unattended?: string; delegation?: string; fallbacks?: string[]; }; jobs?: Record>; extensions?: { hermes?: { config?: Record } }; moved?: Array<{ from: string; to: string }>; removed?: Array<{ key: string; then: 'forget' | 'pause' | 'delete' }>; } export interface SetupRow { key: string; action: string; id?: string; detail?: string } export interface SetupPlan { homeId: string; planOnly: boolean; rows: SetupRow[]; hash: string } export interface SetupDoor { target: 'hermes' | 'orchestrator' } export function planSetup(o: { door: SetupDoor; homeId: string; spec: SetupPackage; root?: string; params?: Record }): Promise; export function applySetup(o: { door: SetupDoor; homeId: string; spec: SetupPackage; root?: string; params?: Record; planHash?: string | null; reviewedPlan?: boolean }): Promise; export function adoptSetup(o: { door: SetupDoor; homeId: string; keys: string[]; root?: string }): Promise; export function resolveSetup(o: { door: SetupDoor; homeId: string; keys: string[]; root?: string }): Promise; export function provisionHome(o: { homeId: string; root?: string }): unknown; export function validateSetup(spec: SetupPackage): SetupPackage; export function resolveParameters(spec: SetupPackage, values?: Record): SetupPackage; export function hermesConfig(spec: SetupPackage): Record; export const SETUP_SCHEMA_VERSION: 1; export function hermesDoor(o: { home: string; python?: string | null; source?: string | null; runner?: unknown; prefix?: string[] }): SetupDoor; export function orchestratorDoor(o: { root: string; profile?: string; load: unknown; socket?: string | null }): Promise; export function locateHermes(o?: { python?: string | null; source?: string | null }): { python: string; source: string }; export function localRunner(o: { python: string; source: string; prefix?: string[] }): unknown; export function containerRunner(o: { container: string; user?: string; python?: string; source?: string; docker?: string }): unknown; /** The daemon's lease, `/orchestrator.lock`. */ export interface OrchestratorLease { pid: number; started_at: string; root: string; /** The machine that wrote it, and that machine's boot (Linux's boot id). */ host?: string | null; boot?: string | null; executor_url?: string | null; } export const LOCK_FILE: 'orchestrator.lock'; /** This machine's name and, on Linux, its boot id. */ export function thisHost(): { host: string | null; boot: string | null }; export function pidIsLive(pid: number): boolean; /** Whether a lease is this machine's, since this boot: only then may its pid be signalled. */ export function leaseIsHere(lease: Pick | null | undefined): boolean; /** Whether the daemon a lease names is alive now: here, and its pid live. */ export function leaseIsLive(lease: OrchestratorLease | null | undefined): boolean; export function readLease(root: string): OrchestratorLease | null; export type { PrDispositionRecorded, PrReleaseReadback } from './ontology.js';