Skip to content

Commit cc54abf

Browse files
serjicjunie-agentclaude
authored
fix: display the selected wire provider as JetBrains Air Gateway (spacering-net#589)
### Summary Addresses [IJAI-2956](https://youtrack.jetbrains.com/issue/IJAI-2956). - Classify the **selected agent-owned** provider ID returned by `getAgentConfiguredModelProvider()` as a gateway when it equals `wire` after trimming, case-insensitively. - Emit `kind: gateway` and the exact label `JetBrains Air Gateway`, with no `detail` or invented account identity. Do not fetch or inspect the provider's friendly `name`, URL, backend, or route. - Preserve effective configuration/launch-override precedence and the separation between authentication identity and client-owned ACP `providers/set`; an unused wire provider does not affect auth status. - Use the same classification for the initial status and subsequent updates; retain existing behavior for other providers. - Add regression coverage for case/whitespace, active selection and overrides, friendly-name negatives, client-owned providers, exact payloads, and source switching; update `docs/air-extensions.md`. This is an agreed weak display heuristic, not proof that the endpoint is a Central deployment or that the user has any particular entitlement. A different selected provider ID does not match merely because its friendly name contains `wire`. ### Sanitized auth status ```json { "kind": "gateway", "label": "JetBrains Air Gateway" } ``` No keys, headers, private routes, technical `wire` detail, or invented account information is sent. ### Verification Based on fresh upstream `main` at `ca1d971`, rechecked immediately before publication. Changes and rebuilt `dist` are available in the main local clone; the user confirmed the local adapters work. ```bash npm run typecheck npm run build npm test ``` - Typecheck (including examples) and build passed. - Full test suite: **1218 passed, 33 existing skipped** across 76 passed test files and 6 skipped opt-in e2e files. - Auth-status coverage: 33 tests passed in the targeted run and the full suite. - No new skip flags or disabled tests were used. ### Scope No AIR UI, provisioning, personal configuration migration, effort/mode changes, or new ACP protocol. Plan files and personal configurations are not committed. Co-authored-by: Junie <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 202e66e commit cc54abf

4 files changed

Lines changed: 112 additions & 3 deletions

File tree

‎docs/air-extensions.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,18 @@ The adapter keeps them where they are.
245245
| `quota` | `PromptResponse._meta.quota` | Token usage of the whole turn, the same counts as `PromptResponse.usage`: `token_count` and one `model_usage` entry for the current model, or `null` and `[]` when Codex reported no usage for the prompt, as for a prompt that started no turn. |
246246
| `authStatus` | `initialize` response `agentCapabilities._meta.authStatus` | The agent pushes `_auth/status_update`. The object carries no payload. |
247247

248+
## Auth source display
249+
250+
The agent-owned provider ID comes from `getAgentConfiguredModelProvider()`: launch options take priority over the effective app-server `configRead`, and client-owned `providers/set` routing is ignored for identity reporting.
251+
252+
An active `model_provider` ID equal to `wire` after trimming whitespace and ignoring case is displayed as:
253+
254+
```json
255+
{ "authStatus": { "kind": "gateway", "label": "JetBrains Air Gateway" } }
256+
```
257+
258+
The configured friendly `name`, URL, host and route are not checked. An unused provider or another ID whose friendly name is `wire` does not match. This is a weak display heuristic, not proof of configuration provenance or access rights. This payload omits `detail` and `account` and contains no keys, headers or private routes. Both the initial push and subsequent status publication use the same classification and existing duplicate suppression. Other providers and gateway authentication names retain their previous presentation.
259+
248260
## Zed conventions
249261

250262
The adapter keeps these Zed conventions for every client:

‎src/AuthStatusMeta.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export function authStatusCapability(): AuthStatusCapability {
7878

7979
const NOT_LOGGED_IN_LABEL = "Not logged in";
8080
const DEFAULT_GATEWAY_LABEL = "Custom model gateway";
81+
/** Agent-owned `model_provider` ID that the JetBrains Air Gateway setup writes. */
82+
const AIR_GATEWAY_PROVIDER_ID = "wire";
83+
/** Same label the Junie agent reports for this gateway, so AIR shows one name. */
84+
const AIR_GATEWAY_LABEL = "JetBrains Air Gateway";
8185

8286
const PLAN_DISPLAY_NAMES: Record<string, string> = {
8387
free: "Free",
@@ -126,6 +130,19 @@ export function gatewayStatus(providerName?: string | null): AuthStatus {
126130
};
127131
}
128132

133+
/**
134+
* Status for the agent-owned provider ID. Matching the bare `wire` ID is
135+
* deliberate: it is a display-only heuristic, not proof of where the config
136+
* came from, and the provider name, URL and route are not checked
137+
* (see `docs/air-extensions.md`, "Auth source display").
138+
*/
139+
export function agentConfiguredProviderStatus(providerId: string | null): AuthStatus {
140+
if (providerId?.trim().toLowerCase() === AIR_GATEWAY_PROVIDER_ID) {
141+
return {kind: "gateway", label: AIR_GATEWAY_LABEL};
142+
}
143+
return gatewayStatus(providerId);
144+
}
145+
129146
export function unauthenticatedStatus(): AuthStatus {
130147
return {
131148
kind: "none",

‎src/CodexAcpServer.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ import {listCodexHooks, trustCodexHooks, type CodexHookIdentity} from "./CodexHo
146146
import type {HooksListEntry} from "./app-server/v2/HooksListEntry";
147147
import {
148148
accountFromUpdated,
149+
agentConfiguredProviderStatus,
149150
fromAccount,
150151
fromAccountUpdated,
151152
gatewayStatus,
@@ -1746,7 +1747,7 @@ export class CodexAcpServer {
17461747
}
17471748
const modelProvider = await this.runWithProcessCheck(() => this.codexAcpClient.getAgentConfiguredModelProvider());
17481749
if (!this.authProviderUsesOpenAiAccount(modelProvider)) {
1749-
return gatewayStatus(modelProvider);
1750+
return agentConfiguredProviderStatus(modelProvider);
17501751
}
17511752
const accountResponse = await this.runWithProcessCheck(() => this.codexAcpClient.getAccount());
17521753
this.lastReadAccount = accountResponse.account;
@@ -1779,7 +1780,7 @@ export class CodexAcpServer {
17791780
await this.publishAuthStatusRead();
17801781
return;
17811782
}
1782-
await this.setAuthStatus(gatewayStatus(authProvider));
1783+
await this.setAuthStatus(agentConfiguredProviderStatus(authProvider));
17831784
}
17841785

17851786
/**

‎src/__tests__/CodexACPAgent/auth-status.test.ts‎

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import {ModelId} from "../../ModelId";
1818
import {PROTOCOL_VERSION} from "@agentclientprotocol/sdk";
1919
import type {AcpClientConnection} from "../../ACPSessionConnection";
20-
import type {Account, AccountUpdatedNotification} from "../../app-server/v2";
20+
import type {Account, AccountUpdatedNotification, Config, ConfigReadResponse} from "../../app-server/v2";
2121

2222
const CHAT_GPT_PLUS: AuthStatus = {
2323
kind: "account",
@@ -95,6 +95,85 @@ function gatewayAuthRequest(providerName: string) {
9595
}
9696

9797
describe("authStatus extension", () => {
98+
describe("Central provider display", () => {
99+
const centralStatus: AuthStatus = {kind: "gateway", label: "JetBrains Air Gateway"};
100+
101+
function providerConfig(provider: string, name = "Any display name", baseUrl?: string): ConfigReadResponse {
102+
return {
103+
config: {
104+
model_provider: provider,
105+
model_providers: {
106+
[provider.trim()]: {name, ...(baseUrl ? {base_url: baseUrl} : {})},
107+
unused: {name: "wire", base_url: "https://example.invalid/unused"},
108+
},
109+
} as unknown as Config,
110+
origins: {},
111+
layers: null,
112+
};
113+
}
114+
115+
it.each([
116+
["wire", "Custom name", undefined],
117+
["WIRE", "wire", "https://example.invalid/other-backend"],
118+
[" WiRe ", "JetBrains Central CLI proxy", "http://127.0.0.1:12345/wire/redacted/codex/openai/v1"],
119+
])("uses active ID %j independently of name and URL", async (provider, name, baseUrl) => {
120+
const fixture = createCodexMockTestFixture();
121+
const configRead = vi.spyOn(fixture.getCodexAppServerClient(), "configRead")
122+
.mockResolvedValue(providerConfig(provider!, name!, baseUrl));
123+
const accountRead = mockAccount(fixture, {type: "chatgpt", email: "[email protected]", planType: "plus"});
124+
expect(await initializeAndAwaitFirstPush(fixture)).toEqual(centralStatus);
125+
expect(configRead).toHaveBeenCalledWith({includeLayers: false});
126+
expect(accountRead).not.toHaveBeenCalled();
127+
expect(JSON.stringify(authStatusUpdates(fixture))).not.toContain("redacted");
128+
});
129+
130+
it("retains ordinary provider display even when its friendly name is wire", async () => {
131+
const fixture = createCodexMockTestFixture();
132+
vi.spyOn(fixture.getCodexAppServerClient(), "configRead").mockResolvedValue(providerConfig("another", "wire"));
133+
expect(await initializeAndAwaitFirstPush(fixture)).toEqual({kind: "gateway", label: "Custom model gateway", detail: "another"});
134+
});
135+
136+
it("preserves launch ID priority over a Central entry in config", async () => {
137+
const fixture = createCodexMockTestFixture();
138+
const configRead = vi.spyOn(fixture.getCodexAppServerClient(), "configRead").mockResolvedValue(providerConfig("wire"));
139+
vi.spyOn(fixture.getCodexAcpClient(), "getModelProvider").mockReturnValue("openai");
140+
mockAccount(fixture, {type: "chatgpt", email: "[email protected]", planType: "plus"});
141+
expect(await initializeAndAwaitFirstPush(fixture)).toEqual(CHAT_GPT_PLUS);
142+
expect(configRead).not.toHaveBeenCalled();
143+
});
144+
145+
it("uses the same display for session creation and suppresses account-event duplicates", async () => {
146+
const fixture = createCodexMockTestFixture();
147+
const client = fixture.getCodexAcpClient();
148+
const modelProvider = vi.spyOn(client, "getModelProvider").mockReturnValue("wire");
149+
expect(await initializeAndAwaitFirstPush(fixture)).toEqual(centralStatus);
150+
await createPromptableSession(fixture);
151+
fixture.getCodexAcpAgent().handleAccountUpdated({authMode: "chatgpt", planType: "pro"});
152+
await drainScheduledWork();
153+
expect(authStatusUpdates(fixture)).toEqual([centralStatus]);
154+
modelProvider.mockReturnValue("another");
155+
await createPromptableSession(fixture);
156+
expect(authStatusUpdates(fixture).at(-1)).toEqual({kind: "gateway", label: "Custom model gateway", detail: "another"});
157+
});
158+
159+
it("keeps client-owned routing separate from the configured wire identity", async () => {
160+
const fixture = createCodexMockTestFixture();
161+
vi.spyOn(fixture.getCodexAppServerClient(), "configRead").mockResolvedValue(providerConfig("wire"));
162+
const agent = fixture.getCodexAcpAgent();
163+
await agent.setProvider({providerId: "openai", apiType: "openai", baseUrl: "https://example.invalid/client", headers: {Authorization: "dummy-secret"}});
164+
expect(await initializeAndAwaitFirstPush(fixture)).toEqual(centralStatus);
165+
await createPromptableSession(fixture);
166+
expect(authStatusUpdates(fixture)).toEqual([centralStatus]);
167+
expect(JSON.stringify(authStatusUpdates(fixture))).not.toContain("dummy-secret");
168+
});
169+
170+
it("does not mistake a gateway authentication friendly name for the provider ID", async () => {
171+
const fixture = createCodexMockTestFixture();
172+
await fixture.getCodexAcpAgent().authenticate(gatewayAuthRequest("wire"));
173+
expect(authStatusUpdates(fixture)).toEqual([{kind: "gateway", label: "Custom model gateway", detail: "wire"}]);
174+
});
175+
});
176+
98177
describe("capability marker", () => {
99178
it("is advertised in the initialize response, without a payload", async () => {
100179
const fixture = createCodexMockTestFixture();

0 commit comments

Comments
 (0)