| ... | ... | @@ -57,7 +57,24 @@ it.layer(NodeServices.layer)("telemetry identity", (it) => { |
| 57 | 57 | ), |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | | it.effect("falls back quietly when Codex authenticates with an API key", () => { |
| 60 | it.effect.each([ |
| 61 | { |
| 62 | login: "an API key", |
| 63 | secret: "sk-private-openai-api-key", |
| 64 | authJson: (secret: string) => `{"auth_mode":"apikey","OPENAI_API_KEY":"${secret}"}`, |
| 65 | }, |
| 66 | { |
| 67 | login: "an agent identity", |
| 68 | secret: "private-agent-identity-jwt", |
| 69 | authJson: (secret: string) => |
| 70 | `{"auth_mode":"agentIdentity","OPENAI_API_KEY":null,"agent_identity":"${secret}"}`, |
| 71 | }, |
| 72 | { |
| 73 | login: "a personal access token", |
| 74 | secret: "private-personal-access-token", |
| 75 | authJson: (secret: string) => `{"OPENAI_API_KEY":null,"personal_access_token":"${secret}"}`, |
| 76 | }, |
| 77 | ])("falls back quietly when Codex authenticates with $login", ({ secret, authJson }) => { |
| 61 | 78 | const logs: CapturedLog[] = []; |
| 62 | 79 | const logger = makeCaptureLogger(logs); |
| 63 | 80 | |
| ... | ... | @@ -67,14 +84,10 @@ it.layer(NodeServices.layer)("telemetry identity", (it) => { |
| 67 | 84 | const path = yield* Path.Path; |
| 68 | 85 | const homeDirectory = path.join(config.baseDir, "home"); |
| 69 | 86 | const codexAuthPath = path.join(homeDirectory, ".codex", "auth.json"); |
| 70 | | const anonymousId = "api-key-fallback-anonymous-id"; |
| 71 | | const privateApiKey = "sk-private-openai-api-key"; |
| 87 | const anonymousId = "tokenless-codex-anonymous-id"; |
| 72 | 88 | |
| 73 | 89 | yield* fileSystem.makeDirectory(path.dirname(codexAuthPath), { recursive: true }); |
| 74 | | yield* fileSystem.writeFileString( |
| 75 | | codexAuthPath, |
| 76 | | `{"auth_mode":"apikey","OPENAI_API_KEY":"${privateApiKey}"}`, |
| 77 | | ); |
| 90 | yield* fileSystem.writeFileString(codexAuthPath, authJson(secret)); |
| 78 | 91 | yield* fileSystem.writeFileString(config.anonymousIdPath, anonymousId); |
| 79 | 92 | |
| 80 | 93 | const identifier = yield* Identify.getTelemetryIdentifierForHome(homeDirectory); |
| ... | ... | @@ -87,12 +100,12 @@ it.layer(NodeServices.layer)("telemetry identity", (it) => { |
| 87 | 100 | [String(log.message), ...Object.values(log.annotations).map(String)].join("\n"), |
| 88 | 101 | ) |
| 89 | 102 | .join("\n"); |
| 90 | | assert.notInclude(allLogs, privateApiKey); |
| 103 | assert.notInclude(allLogs, secret); |
| 91 | 104 | }).pipe( |
| 92 | 105 | Effect.provide( |
| 93 | 106 | Layer.merge( |
| 94 | 107 | ServerConfig.layerTest(process.cwd(), { |
| 95 | | prefix: "t3-telemetry-identify-apikey-", |
| 108 | prefix: "t3-telemetry-identify-tokenless-", |
| 96 | 109 | }), |
| 97 | 110 | Logger.layer([logger], { mergeWithExisting: false }), |
| 98 | 111 | ), |