Files
openclaw/src/agents/agent-runtime-metadata.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

57 lines
2.3 KiB
TypeScript

/** Resolves agent runtime metadata from model/provider policy and ACP session overlays. */
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { applyAcpRuntimeOverlay, type AgentRuntimeMetadata } from "./acp-runtime-overlay.js";
import { isDefaultAgentRuntimeId } from "./agent-runtime-id.js";
import { resolveAgentHarnessPolicy } from "./harness/policy.js";
import { resolveDefaultModelForAgent } from "./model-selection.js";
import { resolvePersistedSessionRuntimeId } from "./session-runtime-compat.js";
/** Resolves the runtime id/source that should be reported for a model-backed agent session. */
export function resolveModelAgentRuntimeMetadata(params: {
cfg: OpenClawConfig;
agentId: string;
provider?: string;
model?: string;
sessionKey?: string;
sessionEntry?: Parameters<typeof resolvePersistedSessionRuntimeId>[0];
/**
* True when the loaded session entry has persisted ACP metadata. ACP-shaped
* keys without this marker can be bridge sessions that use the configured
* model/runtime.
*/
acpRuntime?: boolean;
/**
* The ACP backend identifier stored on the session entry (`entry.acp.backend`).
* When provided for an ACP-keyed session, the overlay reports this value as the
* runtime id instead of the generic fallback "acpx", so sessions backed by a
* non-default registered ACP backend are classified correctly.
*/
acpBackend?: string;
}): AgentRuntimeMetadata {
const persistedRuntimeId = resolvePersistedSessionRuntimeId(params.sessionEntry);
if (persistedRuntimeId && !isDefaultAgentRuntimeId(persistedRuntimeId)) {
return applyAcpRuntimeOverlay(
{ id: persistedRuntimeId, source: "session" },
params.sessionKey,
params.acpRuntime,
params.acpBackend,
);
}
const resolved =
params.provider && params.model
? { provider: params.provider, model: params.model }
: resolveDefaultModelForAgent({ cfg: params.cfg, agentId: params.agentId });
const policy = resolveAgentHarnessPolicy({
provider: resolved.provider,
modelId: resolved.model,
config: params.cfg,
agentId: params.agentId,
sessionKey: params.sessionKey,
});
const meta: AgentRuntimeMetadata = {
id: policy.runtime,
source: policy.runtimeSource ?? "implicit",
};
return applyAcpRuntimeOverlay(meta, params.sessionKey, params.acpRuntime, params.acpBackend);
}