Files
openclaw/src/agents/acp-runtime-overlay.ts
Peter Steinberger f94a7dc183 feat(codex): supervise native Codex sessions (#104045)
* feat(codex): add native session supervision

* fix(codex): harden supervision integration

* fix(codex): preserve locked harness ownership

* fix(codex): fence native session archive

* fix(codex): revalidate archive binding ownership

* feat(codex): integrate supervision runtime

* feat(sessions): preserve harness-owned execution

* feat(sessions): persist harness ownership invariants

* feat(gateway): enforce harness-owned sessions

* feat(setup): enable detected Codex supervision

* feat(mac): expose supervised Codex sessions

* feat(ui): make Codex sessions actionable

* docs(codex): document session supervision

* test(codex): cover integration ownership

* chore(i18n): refresh supervision inventories

* fix(setup): finalize Codex activation atomically

* test(codex): narrow binding store update

* fix(sessions): preserve legacy model locks

* test(macos): serialize Codex catalog fixtures

* fix(sessions): preserve legacy lock admission

* chore(i18n): reconcile supervision metadata

* test(sessions): mark legacy lock fixture

* fix(macos): drain final Codex catalog frame

* docs: leave supervision note to release

* style(macos): satisfy Codex catalog type length

* chore: record session accessor seam owners

* fix(macos): honor configured Codex supervision

* fix(codex): preserve harness-owned model locks

* fix(codex): satisfy supervision lint gates

* chore(i18n): refresh native supervision inventory

* fix(codex): align supervision validation contracts

* fix(codex): close supervision boundary gaps

* fix(codex): preserve supervision activation contracts

* fix(codex): dispose standalone supervision runtime

* fix(codex): pin supervised source connection

* fix(plugins): bind delegated runs to exact session target

* fix(codex): scope supervised sessions to configured agents

* fix(codex): fingerprint effective supervision home

* fix(codex): normalize supervision plugin policy

* fix(codex): keep supervised bindings stable across upgrades

* fix(codex): guard all supervised binding connections

* fix(codex): preserve catalog filters and pending CAS identity

* fix(codex): preserve supervision identity for diagnostics

* fix(codex): bind uncertain commits to supervision connection

* fix(codex): satisfy supervision type boundaries

* fix(macos): reconcile current main validation

* fix(codex): handle absent runtime config in supervision

* fix(doctor): own local audio acceleration check

* fix(codex): satisfy integration lint gates

* fix(codex): satisfy lifecycle safety guards
2026-07-11 00:12:08 -07:00

45 lines
1.8 KiB
TypeScript

/** Applies ACP session-key metadata overrides to agent runtime classification. */
import { isAcpSessionKey } from "../routing/session-key.js";
/**
* Leaf type for agent runtime classification. Defined here so that
* agent-runtime-metadata.ts can import applyAcpRuntimeOverlay without
* creating a circular dependency (agent-runtime-metadata → acp-runtime-overlay
* → agent-runtime-metadata).
*/
export type AgentRuntimeMetadata = {
id: string;
source: "implicit" | "model" | "provider" | "session" | "session-key";
};
/**
* When a session key and persisted session metadata identify an ACP
* control-plane session, override the resolved runtime metadata to report the
* ACP runtime id with a "session-key" source — regardless of what the
* agent-config policy resolved to.
*
* Callers that already have model/provider context (resolveModelAgentRuntimeMetadata)
* still benefit here because the model-runtime policy chain does not inspect session
* keys for the ACP indicator.
*
* Key shape alone is not sufficient: ACP bridge sessions may use ACP-shaped
* keys without persisted SessionAcpMeta and still run the configured model.
*
* When `acpBackend` is provided and non-empty, it is used as the runtime id so that
* sessions backed by a configured non-default ACP backend (e.g. a custom registered
* backend) are reported faithfully instead of always being labelled "acpx".
* Falls back to "acpx" when no backend is known.
*/
export function applyAcpRuntimeOverlay(
meta: AgentRuntimeMetadata,
sessionKey: string | undefined | null,
acpRuntime: boolean | undefined,
acpBackend?: string,
): AgentRuntimeMetadata {
if (acpRuntime === true && isAcpSessionKey(sessionKey)) {
const id = acpBackend && acpBackend.length > 0 ? acpBackend : "acpx";
return { id, source: "session-key" };
}
return meta;
}