mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-20 06:51:38 +00:00
* 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
143 lines
5.3 KiB
TypeScript
143 lines
5.3 KiB
TypeScript
/**
|
|
* Codex app-server agent harness registration and lazy runtime boundaries.
|
|
*/
|
|
import type {
|
|
AgentHarness,
|
|
AgentHarnessCompactParams,
|
|
AgentHarnessCompactResult,
|
|
ContextEngineHostCapability,
|
|
} from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import type {
|
|
CodexAppServerListModelsOptions,
|
|
CodexAppServerModel,
|
|
CodexAppServerModelListResult,
|
|
} from "./src/app-server/models.js";
|
|
import type { CodexAppServerBindingStore } from "./src/app-server/session-binding.js";
|
|
|
|
const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = new Set(["codex", "openai"]);
|
|
const CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES = [
|
|
"bootstrap",
|
|
"assemble-before-prompt",
|
|
"after-turn",
|
|
"maintain",
|
|
"compact",
|
|
"runtime-llm-complete",
|
|
"thread-bootstrap-projection",
|
|
] as const satisfies readonly ContextEngineHostCapability[];
|
|
|
|
/** Public model-listing types exposed for Codex app-server catalog callers. */
|
|
export type { CodexAppServerListModelsOptions, CodexAppServerModel, CodexAppServerModelListResult };
|
|
|
|
type CodexAppServerAgentHarness = AgentHarness & {
|
|
compactAfterContextEngine?(
|
|
params: AgentHarnessCompactParams,
|
|
): Promise<AgentHarnessCompactResult | undefined>;
|
|
};
|
|
|
|
/**
|
|
* Creates the Codex app-server harness used for attempts, side questions,
|
|
* compaction, reset, and disposal.
|
|
*/
|
|
export function createCodexAppServerAgentHarness(options: {
|
|
id?: string;
|
|
label?: string;
|
|
providerIds?: Iterable<string>;
|
|
pluginConfig?: unknown;
|
|
resolvePluginConfig?: () => unknown;
|
|
resolveConfig?: () => OpenClawConfig | undefined;
|
|
bindingStore: CodexAppServerBindingStore;
|
|
}): AgentHarness {
|
|
const providerIds = new Set(
|
|
[...(options?.providerIds ?? DEFAULT_CODEX_HARNESS_PROVIDER_IDS)].map((id) =>
|
|
id.trim().toLowerCase(),
|
|
),
|
|
);
|
|
const harness: CodexAppServerAgentHarness = {
|
|
id: options?.id ?? "codex",
|
|
label: options?.label ?? "Codex agent harness",
|
|
delegatedExecutionPluginIds: ["voice-call"],
|
|
contextEngineHostCapabilities: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES,
|
|
deliveryDefaults: {
|
|
sourceVisibleReplies: "message_tool",
|
|
},
|
|
authBootstrap: "harness",
|
|
supports: (ctx) => {
|
|
const provider = ctx.provider.trim().toLowerCase();
|
|
if (providerIds.has(provider)) {
|
|
return { supported: true, priority: 100 };
|
|
}
|
|
return {
|
|
supported: false,
|
|
reason: `provider is not one of: ${[...providerIds].toSorted().join(", ")}`,
|
|
};
|
|
},
|
|
runAttempt: async (params) => {
|
|
// Keep app-server runtime code behind lazy imports so plugin discovery and
|
|
// cold provider catalog reads do not pull in the whole Codex runtime.
|
|
const { runCodexAppServerAttempt } = await import("./src/app-server/run-attempt.js");
|
|
return runCodexAppServerAttempt(params, {
|
|
bindingStore: options.bindingStore,
|
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
nativeHookRelay: { enabled: true },
|
|
});
|
|
},
|
|
runSideQuestion: async (params) => {
|
|
const { runCodexAppServerSideQuestion } = await import("./src/app-server/side-question.js");
|
|
return runCodexAppServerSideQuestion(params, {
|
|
bindingStore: options.bindingStore,
|
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
nativeHookRelay: { enabled: true },
|
|
});
|
|
},
|
|
compact: async (params) => {
|
|
const { maybeCompactCodexAppServerSession } = await import("./src/app-server/compact.js");
|
|
return maybeCompactCodexAppServerSession(params, {
|
|
bindingStore: options.bindingStore,
|
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
});
|
|
},
|
|
compactAfterContextEngine: async (params) => {
|
|
const { maybeCompactCodexAppServerSession } = await import("./src/app-server/compact.js");
|
|
return maybeCompactCodexAppServerSession(params, {
|
|
bindingStore: options.bindingStore,
|
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
allowNonManualNativeRequest: true,
|
|
});
|
|
},
|
|
reset: async (params) => {
|
|
if (params.sessionId) {
|
|
const { reclaimCurrentCodexSessionGeneration, sessionBindingIdentity } =
|
|
await import("./src/app-server/session-binding.js");
|
|
const identity = sessionBindingIdentity({
|
|
agentId: params.agentId,
|
|
sessionId: params.sessionId,
|
|
sessionKey: params.sessionKey,
|
|
});
|
|
let retired = await options.bindingStore.retireSessionGeneration(identity);
|
|
if (retired === "conflict") {
|
|
const reclaimed = await reclaimCurrentCodexSessionGeneration({
|
|
bindingStore: options.bindingStore,
|
|
identity,
|
|
config: options.resolveConfig?.(),
|
|
});
|
|
if (reclaimed) {
|
|
retired = await options.bindingStore.retireSessionGeneration(identity);
|
|
}
|
|
}
|
|
if (retired === "conflict") {
|
|
throw new Error(
|
|
`Codex binding generation changed before session ${params.sessionId} could reset`,
|
|
);
|
|
}
|
|
}
|
|
},
|
|
dispose: async () => {
|
|
const { clearSharedCodexAppServerClientAndWait } =
|
|
await import("./src/app-server/shared-client.js");
|
|
await clearSharedCodexAppServerClientAndWait();
|
|
},
|
|
};
|
|
return harness;
|
|
}
|