import {
embeddedAgentLog,
type EmbeddedRunAttemptParams,
} from "openclaw/plugin-sdk/agent-harness-runtime"; import { renderCodexPromptOverlay } from "../../prompt-overlay.js"; import type { CodexAppServerClient } from "./client.js"; import { codexSandboxPolicyForTurn, type CodexAppServerRuntimeOptions } from "./config.js"; import {
assertCodexThreadResumeResponse,
assertCodexThreadStartResponse,
} from "./protocol-validators.js"; import {
isJsonObject,
type CodexDynamicToolSpec,
type CodexThreadResumeParams,
type CodexThreadStartParams,
type CodexTurnStartParams,
type CodexUserInput,
type JsonObject,
type JsonValue,
} from "./protocol.js"; import {
clearCodexAppServerBinding,
readCodexAppServerBinding,
writeCodexAppServerBinding,
type CodexAppServerThreadBinding,
} from "./session-binding.js";
function fingerprintDynamicTools(dynamicTools: CodexDynamicToolSpec[]): string { return JSON.stringify(dynamicTools.map(fingerprintDynamicToolSpec));
}
function fingerprintDynamicToolSpec(tool: JsonValue): JsonValue { if (!isJsonObject(tool)) { return stabilizeJsonValue(tool);
} const stable: JsonObject = {}; for (const [key, child] of Object.entries(tool).toSorted(([left], [right]) =>
left.localeCompare(right),
)) { if (key === "description") { continue;
}
stable[key] = stabilizeJsonValue(child);
} return stable;
}
function stabilizeJsonValue(value: JsonValue): JsonValue { if (Array.isArray(value)) { return value.map(stabilizeJsonValue);
} if (!isJsonObject(value)) { return value;
} const stable: JsonObject = {}; for (const [key, child] of Object.entries(value).toSorted(([left], [right]) =>
left.localeCompare(right),
)) {
stable[key] = stabilizeJsonValue(child);
} return stable;
}
export function buildDeveloperInstructions(params: EmbeddedRunAttemptParams): string { const promptOverlay = renderCodexRuntimePromptOverlay(params); const sections = [ "You are running inside OpenClaw. Use OpenClaw dynamic tools for messaging, cron, sessions, and host actions when available.", "Preserve the user's existing channel/session context. If sending a channel reply, use the OpenClaw messaging tool instead of describing that you would reply.",
promptOverlay,
params.extraSystemPrompt,
params.skillsSnapshot?.prompt,
]; return sections.filter((section) => typeof section === "string" && section.trim()).join("\n\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.