Skip to content

Commit 0048a2c

Browse files
committed
refactor(provider): drop meta provider narration
1 parent 52305c8 commit 0048a2c

13 files changed

Lines changed: 8 additions & 82 deletions

File tree

‎src/auth/meta/constants.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ import {
66

77
export { META_BASE_URL, META_DEFAULT_MODELS, META_API_KEY_LIFETIME_MS };
88

9-
// Meta's minted Model API key is valid about 24h. The refresh path re-mints
10-
// from the stored identity token, so the skew just needs to stay comfortably
11-
// below the hard 24h lifetime to avoid last-second races.
9+
// Minted keys last ~24h; skew stays inside that to avoid an expiry race.
1210
export const META_REFRESH_SKEW_MS = 5 * 60 * 1000;

‎src/auth/meta/login.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ describe("startMetaLogin (device flow)", () => {
103103
expires_in: 1800,
104104
});
105105
}
106-
// Token poll parks until the caller aborts, then rejects like real fetch.
107106
return new Promise<Response>((_resolve, reject) => {
108107
init?.signal?.addEventListener(
109108
"abort",

‎src/auth/meta/login.ts‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { metaDeviceLogin, type MetaOAuthTokens } from "@corbits/meta-provider";
33
import type { AuthProfile } from "../store.js";
44
import { saveMetaProfile } from "../../config/oauth-stores.js";
55

6-
// Meta's device flow is a direct RFC 8628 exchange: there is no PKCE loopback
7-
// server and no authorization-code round trip. `startMetaLogin` adapts the
8-
// self-contained `metaDeviceLogin` into the TUI's `OAuthLoginHandle` shape so
9-
// the sign-in step can wait on a single promise.
106
export type MetaLoginHandle = {
117
authorizeUrl: string;
128
completed: Promise<{
@@ -20,34 +16,22 @@ export type StartMetaLoginOptions = {
2016
profile: string;
2117
signal: AbortSignal;
2218
home?: string;
23-
/** Injectable fetch for tests (device authorize / token poll / mint). */
2419
fetchImpl?: typeof fetch;
25-
/** Injectable sleep so tests skip real wall-clock waits. */
2620
sleep?: (ms: number, signal: AbortSignal) => Promise<void>;
27-
/** Injectable clock for expiry math. */
2821
now?: () => number;
29-
/** Called with the device-code event so the TUI can surface verificationUri + userCode. */
3022
notify?: (event: {
3123
type: "device_code";
3224
verificationUri: string;
3325
userCode: string;
3426
}) => void;
3527
};
3628

37-
/**
38-
* Runs Meta's device login. `metaDeviceLogin` owns the authorize → poll →
39-
* mint sequence; `notify` surfaces the verification URI + user code so the
40-
* caller can print them for the operator (Meta has no loopback callback).
41-
* The returned handle resolves with the minted tokens once the flow
42-
* completes, and `cancel` aborts the in-flight request.
43-
*/
4429
export function startMetaLogin(opts: StartMetaLoginOptions): MetaLoginHandle {
4530
const controller = new AbortController();
4631
const abort = (): void => {
4732
controller.abort();
4833
};
49-
// The TUI's cancel is a soft abandon: it lets the underlying login reject
50-
// with the cancel message (the same shape the caller matches on).
34+
// Abort only; the login promise rejects with the message the TUI matches.
5135
opts.signal.addEventListener("abort", abort, { once: true });
5236

5337
let committed: Promise<void> | undefined;
@@ -92,10 +76,7 @@ export function startMetaLogin(opts: StartMetaLoginOptions): MetaLoginHandle {
9276
})();
9377

9478
return {
95-
// The verification URI is surfaced via `notify` (device flow); the
96-
// authorizeUrl slot is unused for Meta, but the TUI reads it for the
97-
// "open this url" login box. Keep it empty — the device code box shows
98-
// the real instructions instead.
79+
// Empty: notify carries the device URI; this slot is the open-url box.
9980
authorizeUrl: "",
10081
completed,
10182
cancel: abort,

‎src/auth/meta/session.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe("isMetaTokenExpired", () => {
2020
});
2121

2222
test("expired within the refresh skew window", () => {
23-
// 4 minutes before expiry is inside the 5-minute skew, so treated as expired.
2423
expect(
2524
isMetaTokenExpired(
2625
{ access: "a", refresh: "r", expiresAt: 1_000_000 },

‎src/auth/meta/session.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import {
2020
} from "../token-session-boundary.js";
2121
import { META_REFRESH_SKEW_MS } from "./constants.js";
2222

23-
// Raised when a Meta profile cannot yield a usable access token: it is gone,
24-
// or its identity token has been revoked/expired (401/403 on re-mint). Carries
25-
// the profile name so the TUI can name the affected profile in a re-login
26-
// prompt.
2723
export class MetaAuthError extends Error {
2824
readonly profile: string;
2925
readonly reason: "missing" | "refresh-failed";

‎src/config/index.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ export type ProviderCatalogEntry = Omit<
339339
// xAI/Grok OAuth profile. Still routes through openai-compatible; the
340340
// marker only controls token refresh and persistence.
341341
xaiProfile?: string;
342-
// Set when this entry is a Meta (Muse) OAuth profile. Routes to the
343-
// "meta-responses" adapter; the marker controls token refresh/persistence.
342+
// Routes to the meta-responses adapter, not openai-compatible.
344343
metaProfile?: string;
345344
// Bifrost virtual key: sources use provider "bifrost" so the adapter
346345
// injects the x-bf-vk header; also enables /models auto-discovery scoped
@@ -428,11 +427,6 @@ export function buildXaiSource(fields: {
428427
};
429428
}
430429

431-
// Build the InferenceSource for a Meta (Muse) OAuth profile. Routes to the
432-
// "meta" Responses adapter (Meta's Model API speaks the Responses protocol
433-
// natively at META_BASE_URL). The minted key is registered in the credential
434-
// cell under the source id; refresh re-mints it from the stored identity
435-
// token (see getValidMetaToken).
436430
export function buildMetaSource(fields: {
437431
id: string;
438432
profile: string;
@@ -459,11 +453,6 @@ export function buildMetaSource(fields: {
459453
};
460454
}
461455

462-
// Build the InferenceSource for a Meta Model API key (the Meta chooser's
463-
// "API key" path, a hand-named meta/<slug>, or a bare `meta` settings row).
464-
// The endpoint speaks the Responses protocol, so the source rides the same
465-
// "meta" adapter as the OAuth profiles — only the credential provenance
466-
// differs: a plain key is api-key provenance, never an OAuth profile.
467456
export function buildMetaApiKeySource(fields: {
468457
id: string;
469458
apiKey?: string;

‎src/config/inference-sources.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,7 @@ export function buildInferenceSourceForRef(
148148
...(effort !== undefined ? { reasoningEffort: effort } : {}),
149149
});
150150
}
151-
// Meta Model API key rows (the Meta chooser's "API key" path, a hand-named
152-
// meta/<slug>, or a bare `meta` row) also speak the Responses protocol at
153-
// META_BASE_URL — never the openai-compatible /chat/completions fallback
154-
// below. They have no metaProfile marker, so route them to the same
155-
// meta-responses adapter as the OAuth profiles.
151+
// No metaProfile on API-key rows; do not fall through to chat completions.
156152
if (
157153
ref.provider === "meta" ||
158154
(entry?.metaProfile === undefined && isMetaProviderName(ref.provider))

‎src/provider/meta-responses.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { createMetaResponsesAdapter as createPackageMetaResponsesAdapter } from "@corbits/meta-provider";
22
import type { AdapterFactory } from "@intx/inference";
33

4-
// The packaged Meta Responses adapter is host-agnostic; Corbits Code only
5-
// needs the provider id wired into the adapter registry. No host quirks or
6-
// option remaps are required — Meta's Model API speaks the Responses protocol
7-
// natively and the package factory bakes the host-specifics in.
84
export const createMetaResponsesAdapter: AdapterFactory =
95
createPackageMetaResponsesAdapter;

‎src/tui/provider-setup.test.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ function stagedLoginStarter(
9898
opts: {
9999
onStart?: (input: StagedLoginInput) => void;
100100
deniedStarts?: number;
101-
/** Emit a device_code event via `notify` on the first start (Meta flow). */
102101
emitDeviceCode?: boolean;
103102
} = {},
104103
): {
@@ -358,8 +357,6 @@ describe("provider setup pure helpers", () => {
358357
{ name: "codex/default" },
359358
]);
360359
expect(rows.map((r) => r.id)).toContain(CUSTOM_CHOICE_ID);
361-
// Alt+A rows are keyed by the pick-list row id (two Meta rows stay
362-
// distinct), which mirrors the onboarding list.
363360
expect(rows.map((r) => r.id)).toEqual(choices.map((c) => c.rowId));
364361
const openai = rows.find((r) => r.id === "openai");
365362
const codex = rows.find((r) => r.id === "codex");
@@ -496,7 +493,6 @@ async function mountConfig(
496493
return { done, harness };
497494
}
498495

499-
/** Recording clipboard port for the Meta device-flow copy test. */
500496
function recordingClipboard(): {
501497
clipboard: { writeText: (t: string) => void; writes: string[] };
502498
} {
@@ -1258,7 +1254,6 @@ describe("runProviderSetup sign-in", () => {
12581254
await pickRow(harness, PROVIDER_IDS, "meta/api");
12591255
await flush(harness);
12601256
expect(harness.captureCharFrame()).toContain("step 2 of 4");
1261-
// Instance name step, then key — not the login step.
12621257
harness.pressKey("Enter");
12631258
await harness.renderOnce();
12641259
type(harness, "LLM|test-key");

‎src/tui/provider/choices.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ export function providerChoices(): readonly ProviderChoice[] {
207207
if (seeded === undefined) continue;
208208
const choice = choiceFromDef(seeded);
209209
if (choice !== null) {
210-
// A chooser whose paths resolve to the same catalog kind (Meta Sign
211-
// In vs Meta API key, both `meta`) would otherwise put two rows
212-
// under one id — the second row becomes unreachable with arrows.
213-
// Give it a distinct pick-list row id while keeping the catalog id.
210+
// A shared catalog id would hide the second row from arrow keys.
214211
const rowId = pushedRowIds.has(choice.rowId)
215212
? `${def.id}/${path.id}`
216213
: choice.rowId;
@@ -317,8 +314,6 @@ export function addProviderSelectorChoices(
317314
const connected =
318315
choice.oauth !== null && !choice.custom && accountCount > 0;
319316
return {
320-
// The pick-list row id so two chooser rows sharing a catalog kind stay
321-
// distinct in the Alt+A selector too.
322317
id: choice.rowId,
323318
label: connected
324319
? `${choice.label.split(" — ")[0]} · ${accountCount} connected`

0 commit comments

Comments
 (0)