mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 09:14:54 +00:00
86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildCodexPluginThreadConfigEligibilityLogData } from "./attempt-diagnostics.js";
|
|
import { resolveCodexPluginsPolicy } from "./config.js";
|
|
import { buildCodexPluginAppCacheKey } from "./plugin-app-cache-key.js";
|
|
|
|
describe("Codex app-server attempt diagnostics", () => {
|
|
it("redacts plugin thread config eligibility log data", () => {
|
|
const appServer = {
|
|
start: {
|
|
transport: "websocket" as const,
|
|
command: "codex",
|
|
commandSource: "config" as const,
|
|
args: [],
|
|
url: "ws://127.0.0.1:39175",
|
|
authToken: "token-secret",
|
|
headers: {
|
|
Authorization: "Bearer secret",
|
|
"X-Test-Token": "header-secret",
|
|
},
|
|
env: {
|
|
CODEX_HOME: "/tmp/codex-home",
|
|
OPENAI_API_KEY: "env-secret",
|
|
},
|
|
},
|
|
codeModeOnly: false,
|
|
requestTimeoutMs: 60_000,
|
|
turnCompletionIdleTimeoutMs: 60_000,
|
|
approvalPolicy: "never" as const,
|
|
approvalsReviewer: "user" as const,
|
|
sandbox: "danger-full-access" as const,
|
|
serviceTier: "priority" as const,
|
|
};
|
|
const resolvedPluginPolicy = resolveCodexPluginsPolicy({
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: "openai-curated",
|
|
pluginName: "google-calendar",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const logData = buildCodexPluginThreadConfigEligibilityLogData({
|
|
sessionId: "session-1",
|
|
sessionKey: "agent:main:session-1",
|
|
pluginThreadConfigRequired: true,
|
|
resolvedPluginPolicy,
|
|
enabledPluginConfigKeys: ["google-calendar"],
|
|
pluginAppCacheKey: buildCodexPluginAppCacheKey({
|
|
appServer,
|
|
agentDir: "/tmp/agent",
|
|
authProfileId: "openai-codex:work",
|
|
accountId: "account-work",
|
|
envApiKeyFingerprint: "env-key",
|
|
}),
|
|
startupAuthProfileId: "openai-codex:work",
|
|
appServer,
|
|
});
|
|
|
|
expect(logData).toEqual(
|
|
expect.objectContaining({
|
|
sessionId: "session-1",
|
|
sessionKey: "agent:main:session-1",
|
|
enabled: true,
|
|
policyConfigured: true,
|
|
policyEnabled: true,
|
|
pluginConfigKeys: ["google-calendar"],
|
|
enabledPluginConfigKeys: ["google-calendar"],
|
|
appCacheKeyFingerprint: expect.stringMatching(/^sha256:/),
|
|
authProfileId: "openai-codex:work",
|
|
appServerTransport: "websocket",
|
|
appServerCommandSource: "config",
|
|
}),
|
|
);
|
|
expect(logData).not.toHaveProperty("appCacheKeyInput");
|
|
const serialized = JSON.stringify(logData);
|
|
expect(serialized).not.toContain("token-secret");
|
|
expect(serialized).not.toContain("Bearer secret");
|
|
expect(serialized).not.toContain("header-secret");
|
|
expect(serialized).not.toContain("env-secret");
|
|
expect(serialized).not.toContain("/tmp/codex-home");
|
|
});
|
|
});
|