Repository navigation
fix(server): renew active managed Codex turns through native auth #21787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
01ae27b
test(server): cover native Codex token helper and catalog races
juliusmarminge 281f81e
fix(server): renew active managed Codex sessions through native auth
juliusmarminge 47819da
fix(server): preserve managed Codex provider identity across sign-ins
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // @effect-diagnostics nodeBuiltinImport:off - Lean self-invoked local IPC client; no auth/store graph. | ||
| import * as NodeNet from "node:net"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Exit from "effect/Exit"; | ||
| import * as Schema from "effect/Schema"; | ||
| import * as Protocol from "../provider/CodexManagedTokenProtocol.ts"; | ||
|
|
||
| const decodeArguments = Schema.decodeUnknownEffect( | ||
| Schema.Tuple([ | ||
| Schema.NonEmptyString, | ||
| Protocol.Request.fields.instanceId, | ||
| Protocol.Request.fields.environmentId, | ||
| Protocol.Request.fields.profileKey, | ||
| ]), | ||
| ); | ||
| const encodeRequest = Schema.encodeSync(Schema.fromJsonString(Protocol.Request)); | ||
| const decodeResponse = Schema.decodeUnknownEffect(Schema.fromJsonString(Protocol.Response), { | ||
| onExcessProperty: "error", | ||
| }); | ||
|
|
||
| /** Codex's auth.command protocol is a bare token on stdout, never a CLI diagnostic. */ | ||
| export async function runManagedChatGptTokenCli(args: ReadonlyArray<string>): Promise<void> { | ||
| const program = Effect.gen(function* () { | ||
| const [endpoint, instanceId, environmentId, profileKey] = yield* decodeArguments(args); | ||
| const socket = yield* Effect.acquireRelease( | ||
| Effect.sync(() => NodeNet.createConnection(endpoint)), | ||
| (socket) => Effect.sync(() => socket.destroy()), | ||
| ); | ||
| socket.on("error", () => {}); | ||
| socket.once("connect", () => | ||
| socket.write(encodeRequest({ version: 1, instanceId, environmentId, profileKey }) + "\n"), | ||
| ); | ||
| return yield* Protocol.readFrame( | ||
| socket, | ||
| Protocol.RESPONSE_BYTES, | ||
| Protocol.COMMAND_TIMEOUT_MS, | ||
| ).pipe(Effect.flatMap(decodeResponse)); | ||
| }).pipe(Effect.scoped); | ||
| const result = await Effect.runPromiseExit(program); | ||
| if (Exit.isFailure(result)) { | ||
| process.stderr.write( | ||
| "Could not access the managed ChatGPT connection. Reconnect in T3 Code.\n", | ||
| ); | ||
| process.exitCode = 1; | ||
| return; | ||
| } | ||
| process.stdout.write(result.value.token); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Make the helper test runnable on Node v22.16.
The declared Node engine permits v22.16, but this test launches
bin.tsthroughprocess.execPathwithout a TypeScript loader or type-stripping flag. Node v22.16 requires--experimental-strip-typesfor that entrypoint. On that supported version, the child exits before it returns a token, so the helper assertions fail. Invoke a built entrypoint or supply the required execution mode and account for its diagnostic output. (nodejs.org)🤖 Prompt for AI Agents