mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:50:43 +00:00
fix(openai): show codex device code in ssh (#74258)
Fixes #74212. Thanks @da22le123.
This commit is contained in:
@@ -234,7 +234,7 @@ describe("openai codex provider", () => {
|
||||
expect(result?.profiles[0]?.credential).not.toHaveProperty("idToken");
|
||||
});
|
||||
|
||||
it("does not log the device pairing code in remote mode", async () => {
|
||||
async function runRemoteDeviceCodeAuthFlow() {
|
||||
const provider = buildOpenAICodexProviderPlugin();
|
||||
const deviceCodeMethod = provider.auth?.find((method) => method.id === "device-code");
|
||||
const note = vi.fn(async () => {});
|
||||
@@ -273,17 +273,28 @@ describe("openai codex provider", () => {
|
||||
}),
|
||||
).resolves.toBeDefined();
|
||||
|
||||
const logOutput = runtime.log.mock.calls.flat().join("\n");
|
||||
expect(logOutput).toContain("https://auth.openai.com/codex/device");
|
||||
expect(logOutput).not.toContain("CODE-12345");
|
||||
return { note, runtime };
|
||||
}
|
||||
|
||||
it("surfaces the device pairing code via the prompter note in remote (SSH) mode (#74212)", async () => {
|
||||
const { note } = await runRemoteDeviceCodeAuthFlow();
|
||||
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Code: [shown on the local device only]"),
|
||||
"OpenAI Codex device code",
|
||||
);
|
||||
expect(note).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining("Code: CODE-12345"),
|
||||
"OpenAI Codex device code",
|
||||
);
|
||||
expect(note).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining("Code: [shown on the local device only]"),
|
||||
"OpenAI Codex device code",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not write the device pairing code to the runtime log in remote mode", async () => {
|
||||
const { runtime } = await runRemoteDeviceCodeAuthFlow();
|
||||
|
||||
const logOutput = runtime.log.mock.calls.flat().join("\n");
|
||||
expect(logOutput).toContain("https://auth.openai.com/codex/device");
|
||||
expect(logOutput).not.toContain("CODE-12345");
|
||||
});
|
||||
|
||||
it("owns native reasoning output mode for Codex responses", () => {
|
||||
|
||||
@@ -378,16 +378,15 @@ async function runOpenAICodexDeviceCode(ctx: ProviderAuthContext) {
|
||||
onProgress: (message) => spin.update(message),
|
||||
onVerification: async ({ verificationUrl, userCode, expiresInMs }) => {
|
||||
const expiresInMinutes = Math.max(1, Math.round(expiresInMs / 60_000));
|
||||
const codeLine = ctx.isRemote
|
||||
? "Code: [shown on the local device only]"
|
||||
: `Code: ${userCode}`;
|
||||
// The prompter note is the user-facing TTY surface, so remote/headless
|
||||
// users need the code there; keep the persistent runtime log URL-only.
|
||||
await ctx.prompter.note(
|
||||
[
|
||||
ctx.isRemote
|
||||
? "Open this URL in your LOCAL browser and enter the code below."
|
||||
: "Open this URL in your browser and enter the code below.",
|
||||
`URL: ${verificationUrl}`,
|
||||
codeLine,
|
||||
`Code: ${userCode}`,
|
||||
`Code expires in ${expiresInMinutes} minutes. Never share it.`,
|
||||
].join("\n"),
|
||||
"OpenAI Codex device code",
|
||||
|
||||
Reference in New Issue
Block a user