@sendmux/cli 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +26 -3
  2. package/dist/base-command.d.ts +11 -4
  3. package/dist/base-command.d.ts.map +1 -1
  4. package/dist/base-command.js +24 -1
  5. package/dist/commands/auth/login.d.ts +14 -0
  6. package/dist/commands/auth/login.d.ts.map +1 -0
  7. package/dist/commands/auth/login.js +36 -0
  8. package/dist/commands/auth/logout.d.ts +9 -0
  9. package/dist/commands/auth/logout.d.ts.map +1 -0
  10. package/dist/commands/auth/logout.js +22 -0
  11. package/dist/commands/mailbox/stream-events.d.ts +6 -6
  12. package/dist/commands/profiles/list.d.ts.map +1 -1
  13. package/dist/commands/profiles/list.js +3 -1
  14. package/dist/commands/profiles/set.d.ts.map +1 -1
  15. package/dist/commands/profiles/set.js +4 -1
  16. package/dist/commands/profiles/show.d.ts.map +1 -1
  17. package/dist/commands/profiles/show.js +25 -23
  18. package/dist/generated/operations.d.ts +6 -6
  19. package/dist/generated/operations.js +7 -7
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/oauth-http.d.ts +18 -0
  23. package/dist/oauth-http.d.ts.map +1 -0
  24. package/dist/oauth-http.js +113 -0
  25. package/dist/oauth-login.d.ts +13 -0
  26. package/dist/oauth-login.d.ts.map +1 -0
  27. package/dist/oauth-login.js +236 -0
  28. package/dist/oauth-profile.d.ts +6 -0
  29. package/dist/oauth-profile.d.ts.map +1 -0
  30. package/dist/oauth-profile.js +123 -0
  31. package/dist/operation-runner.d.ts.map +1 -1
  32. package/dist/operation-runner.js +1 -1
  33. package/dist/profiles.d.ts +23 -1
  34. package/dist/profiles.d.ts.map +1 -1
  35. package/dist/profiles.js +4 -1
  36. package/oclif.manifest.json +1459 -1368
  37. package/package.json +2 -2
@@ -0,0 +1,236 @@
1
+ import { execFile } from "node:child_process";
2
+ import { createHash, randomBytes, randomUUID } from "node:crypto";
3
+ import { createServer } from "node:http";
4
+ import { promisify } from "node:util";
5
+ import { discoverOAuth, oauthForm, oauthRequest, oauthTokenFields, oauthUrl, OAUTH_RESOURCE, } from "./oauth-http.js";
6
+ import { isOAuthProfile, updateCliConfig, } from "./profiles.js";
7
+ export async function loginOAuth(input) {
8
+ const issuer = oauthUrl(input.issuer).href.replace(/\/$/, "");
9
+ const scopes = [
10
+ ...new Set(input.scopes.flatMap((scope) => scope.split(/\s+/)).filter(Boolean)),
11
+ ];
12
+ if (!scopes.length)
13
+ throw new Error("Choose at least one OAuth scope.");
14
+ const sessionId = randomUUID();
15
+ await updateCliConfig(input.configDir, (config) => {
16
+ if (config.profiles[input.name])
17
+ throw new Error("That profile already exists. Choose another name or log out first.");
18
+ config.profiles[input.name] = {
19
+ type: "oauth",
20
+ state: "authorizing",
21
+ sessionId,
22
+ issuer,
23
+ };
24
+ });
25
+ const abort = new AbortController();
26
+ const cancel = () => abort.abort();
27
+ process.once("SIGINT", cancel);
28
+ process.once("SIGTERM", cancel);
29
+ const timeout = setTimeout(cancel, 120_000);
30
+ let callback;
31
+ let activated;
32
+ try {
33
+ const endpoints = await discoverOAuth(issuer, scopes);
34
+ const state = randomBytes(32).toString("base64url");
35
+ const verifier = randomBytes(32).toString("base64url");
36
+ callback = await loopbackCallback({ state, issuer, signal: abort.signal });
37
+ const client = await oauthRequest(endpoints.registration, {
38
+ method: "POST",
39
+ headers: { "Content-Type": "application/json" },
40
+ body: JSON.stringify({
41
+ client_name: "Sendmux CLI",
42
+ application_type: "native",
43
+ redirect_uris: [callback.redirectUri],
44
+ grant_types: ["authorization_code", "refresh_token"],
45
+ response_types: ["code"],
46
+ token_endpoint_auth_method: "none",
47
+ resource: OAUTH_RESOURCE,
48
+ scope: scopes.join(" "),
49
+ }),
50
+ });
51
+ if (typeof client.client_id !== "string" ||
52
+ !client.client_id ||
53
+ client.token_endpoint_auth_method !== "none" ||
54
+ client.resource !== OAUTH_RESOURCE ||
55
+ !Array.isArray(client.redirect_uris) ||
56
+ client.redirect_uris.length !== 1 ||
57
+ client.redirect_uris[0] !== callback.redirectUri)
58
+ throw new Error("The issuer returned invalid client registration metadata.");
59
+ const url = new URL(endpoints.authorization);
60
+ url.search = new URLSearchParams({
61
+ client_id: client.client_id,
62
+ response_type: "code",
63
+ redirect_uri: callback.redirectUri,
64
+ scope: scopes.join(" "),
65
+ state,
66
+ resource: OAUTH_RESOURCE,
67
+ code_challenge_method: "S256",
68
+ code_challenge: createHash("sha256").update(verifier).digest("base64url"),
69
+ }).toString();
70
+ input.report(`Open this URL to sign in:\n${url.href}`);
71
+ if (!input.noBrowser)
72
+ await openBrowser(url.href).catch(() => input.report("Could not open the browser. Open the URL above to continue."));
73
+ const code = await callback.code;
74
+ await callback.close();
75
+ const fields = oauthTokenFields(await oauthRequest(endpoints.token, oauthForm({
76
+ grant_type: "authorization_code",
77
+ code,
78
+ code_verifier: verifier,
79
+ redirect_uri: callback.redirectUri,
80
+ client_id: client.client_id,
81
+ resource: OAUTH_RESOURCE,
82
+ })), scopes);
83
+ activated = {
84
+ type: "oauth",
85
+ state: "active",
86
+ sessionId,
87
+ issuer,
88
+ clientId: client.client_id,
89
+ tokenEndpoint: endpoints.token,
90
+ revocationEndpoint: endpoints.revocation,
91
+ ...fields,
92
+ };
93
+ const profile = activated;
94
+ await updateCliConfig(input.configDir, (config) => {
95
+ const existing = config.profiles[input.name];
96
+ if (!existing ||
97
+ !isOAuthProfile(existing) ||
98
+ existing.sessionId !== sessionId ||
99
+ existing.state !== "authorizing")
100
+ throw new Error("The login profile changed during authorization.");
101
+ config.profiles[input.name] = profile;
102
+ if (!config.defaultProfile)
103
+ config.defaultProfile = input.name;
104
+ });
105
+ return { profile: input.name, type: "oauth", scopes: profile.scopes };
106
+ }
107
+ catch (error) {
108
+ if (activated) {
109
+ await oauthRequest(activated.revocationEndpoint, oauthForm({
110
+ token: activated.refreshToken,
111
+ token_type_hint: "refresh_token",
112
+ client_id: activated.clientId,
113
+ })).catch(() => input.report("Could not revoke the interrupted login. Revoke the connection in Sendmux settings."));
114
+ }
115
+ await updateCliConfig(input.configDir, (config) => {
116
+ const existing = config.profiles[input.name];
117
+ if (existing &&
118
+ isOAuthProfile(existing) &&
119
+ existing.sessionId === sessionId &&
120
+ existing.state === "authorizing")
121
+ delete config.profiles[input.name];
122
+ });
123
+ throw error;
124
+ }
125
+ finally {
126
+ clearTimeout(timeout);
127
+ process.removeListener("SIGINT", cancel);
128
+ process.removeListener("SIGTERM", cancel);
129
+ await callback?.close();
130
+ }
131
+ }
132
+ async function openBrowser(url) {
133
+ const command = process.platform === "darwin"
134
+ ? "open"
135
+ : process.platform === "win32"
136
+ ? "rundll32.exe"
137
+ : "xdg-open";
138
+ await promisify(execFile)(command, process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url], { timeout: 5_000 });
139
+ }
140
+ async function loopbackCallback({ state, issuer, signal, }) {
141
+ let resolveCode;
142
+ let rejectCode;
143
+ const code = new Promise((resolve, reject) => {
144
+ resolveCode = resolve;
145
+ rejectCode = reject;
146
+ });
147
+ // Attach before registration/browser work so cancellation cannot become an unhandled rejection.
148
+ void code.catch(() => undefined);
149
+ let redirectUri = "";
150
+ let received = false;
151
+ const server = createServer((request, response) => {
152
+ response.setHeader("Cache-Control", "no-store");
153
+ response.setHeader("Content-Type", "text/plain; charset=utf-8");
154
+ let url;
155
+ try {
156
+ url = new URL(request.url ?? "/", redirectUri);
157
+ }
158
+ catch {
159
+ response.writeHead(400);
160
+ response.end("Invalid authorization response.");
161
+ return;
162
+ }
163
+ const one = (key) => url.searchParams.getAll(key).length === 1;
164
+ const valid = request.method === "GET" &&
165
+ url.pathname === "/callback" &&
166
+ request.headers.host === new URL(redirectUri).host &&
167
+ one("state") &&
168
+ url.searchParams.get("state") === state &&
169
+ one("iss") &&
170
+ url.searchParams.get("iss") === issuer &&
171
+ ((one("code") &&
172
+ !url.searchParams.has("error") &&
173
+ !!url.searchParams.get("code")) ||
174
+ (one("error") && !url.searchParams.has("code")));
175
+ if (!valid || received) {
176
+ response.writeHead(400);
177
+ response.end("Invalid authorization response.");
178
+ return;
179
+ }
180
+ received = true;
181
+ response.setHeader("Content-Type", "text/html; charset=utf-8");
182
+ response.end('<!doctype html><meta charset="utf-8"><link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27/%3E"><pre>Authorization received. You can return to the terminal.</pre>', () => {
183
+ if (url.searchParams.has("error"))
184
+ rejectCode(new Error("OAuth authorization was declined."));
185
+ else
186
+ resolveCode(url.searchParams.get("code"));
187
+ });
188
+ });
189
+ server.headersTimeout = 5_000;
190
+ server.requestTimeout = 10_000;
191
+ let host = "127.0.0.1";
192
+ for (const candidate of ["127.0.0.1", "::1"]) {
193
+ try {
194
+ await new Promise((resolve, reject) => {
195
+ const failed = (error) => {
196
+ server.removeListener("listening", bound);
197
+ reject(error);
198
+ };
199
+ const bound = () => {
200
+ server.removeListener("error", failed);
201
+ resolve();
202
+ };
203
+ server.once("error", failed);
204
+ server.once("listening", bound);
205
+ server.listen(0, candidate);
206
+ });
207
+ host = candidate;
208
+ break;
209
+ }
210
+ catch {
211
+ if (candidate === "::1")
212
+ throw new Error("Could not bind the OAuth callback listener.");
213
+ }
214
+ }
215
+ const address = server.address();
216
+ if (!address || typeof address === "string")
217
+ throw new Error("Could not bind the OAuth callback listener.");
218
+ redirectUri = `http://${host === "::1" ? "[::1]" : host}:${address.port}/callback`;
219
+ const cancel = () => rejectCode(new Error("OAuth login was cancelled or timed out."));
220
+ signal.addEventListener("abort", cancel, { once: true });
221
+ if (signal.aborted)
222
+ cancel();
223
+ let closing;
224
+ return {
225
+ redirectUri,
226
+ code,
227
+ close: () => {
228
+ if (closing)
229
+ return closing;
230
+ signal.removeEventListener("abort", cancel);
231
+ closing = new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())));
232
+ server.closeAllConnections();
233
+ return closing;
234
+ },
235
+ };
236
+ }
@@ -0,0 +1,6 @@
1
+ export declare function resolveOAuthToken(configDir: string, name: string): Promise<string>;
2
+ export declare function logoutOAuth(configDir: string, name: string): Promise<{
3
+ profile: string;
4
+ revoked: boolean;
5
+ }>;
6
+ //# sourceMappingURL=oauth-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-profile.d.ts","sourceRoot":"","sources":["../src/oauth-profile.ts"],"names":[],"mappings":"AAsBA,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CA4CjB;AA0DD,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;GA4ChE"}
@@ -0,0 +1,123 @@
1
+ import { oauthForm, oauthRequest, oauthTokenFields, oauthUrl, OAUTH_RESOURCE, } from "./oauth-http.js";
2
+ import { isOAuthProfile, readCliConfig, updateCliConfig, } from "./profiles.js";
3
+ function activeProfile(profile) {
4
+ if (!profile || !isOAuthProfile(profile) || profile.state === "authorizing") {
5
+ throw new Error("The OAuth profile is not ready. Complete login first.");
6
+ }
7
+ return profile;
8
+ }
9
+ export async function resolveOAuthToken(configDir, name) {
10
+ const deadline = Date.now() + 20_000;
11
+ while (true) {
12
+ const profile = activeProfile((await readCliConfig(configDir)).profiles[name]);
13
+ if (profile.state === "revoking" || profile.state === "reauthorize") {
14
+ throw new Error("This OAuth profile needs a new login. Run auth:logout, then auth:login.");
15
+ }
16
+ if (profile.state === "active" && profile.expiresAt > Date.now() + 30_000)
17
+ return profile.accessToken;
18
+ if (profile.state === "refreshing") {
19
+ if (Date.now() >= deadline ||
20
+ Date.now() - (profile.refreshStartedAt ?? 0) >= 20_000) {
21
+ throw new Error("OAuth refresh did not finish. Log out and sign in again; the old refresh token will not be replayed.");
22
+ }
23
+ await new Promise((resolve) => setTimeout(resolve, 50));
24
+ continue;
25
+ }
26
+ const reserved = await updateCliConfig(configDir, (config) => {
27
+ const current = activeProfile(config.profiles[name]);
28
+ if (current.state !== "active" ||
29
+ current.sessionId !== profile.sessionId ||
30
+ current.expiresAt > Date.now() + 30_000)
31
+ return null;
32
+ const next = {
33
+ ...current,
34
+ state: "refreshing",
35
+ refreshStartedAt: Date.now(),
36
+ };
37
+ config.profiles[name] = next;
38
+ return next;
39
+ });
40
+ if (!reserved)
41
+ continue;
42
+ return refreshReservedProfile(configDir, name, reserved);
43
+ }
44
+ }
45
+ async function refreshReservedProfile(configDir, name, profile) {
46
+ try {
47
+ const endpoint = oauthUrl(profile.tokenEndpoint, profile.issuer).href;
48
+ const fields = oauthTokenFields(await oauthRequest(endpoint, oauthForm({
49
+ grant_type: "refresh_token",
50
+ refresh_token: profile.refreshToken,
51
+ client_id: profile.clientId,
52
+ resource: OAUTH_RESOURCE,
53
+ })), profile.scopes);
54
+ await updateCliConfig(configDir, (config) => {
55
+ const current = activeProfile(config.profiles[name]);
56
+ if (current.sessionId !== profile.sessionId ||
57
+ current.state !== "refreshing" ||
58
+ current.refreshStartedAt !== profile.refreshStartedAt) {
59
+ throw new Error("The OAuth profile changed during refresh.");
60
+ }
61
+ const next = {
62
+ ...profile,
63
+ ...fields,
64
+ state: "active",
65
+ };
66
+ delete next.refreshStartedAt;
67
+ config.profiles[name] = next;
68
+ });
69
+ return fields.accessToken;
70
+ }
71
+ catch {
72
+ await updateCliConfig(configDir, (config) => {
73
+ const current = config.profiles[name];
74
+ if (current &&
75
+ isOAuthProfile(current) &&
76
+ current.state === "refreshing" &&
77
+ current.sessionId === profile.sessionId &&
78
+ current.refreshStartedAt === profile.refreshStartedAt) {
79
+ current.state = "reauthorize";
80
+ }
81
+ });
82
+ throw new Error("OAuth refresh failed. Log out and sign in again; the old refresh token will not be replayed.");
83
+ }
84
+ }
85
+ export async function logoutOAuth(configDir, name) {
86
+ const profile = await updateCliConfig(configDir, (config) => {
87
+ const stored = config.profiles[name];
88
+ if (stored && isOAuthProfile(stored) && stored.state === "authorizing") {
89
+ delete config.profiles[name];
90
+ if (config.defaultProfile === name)
91
+ delete config.defaultProfile;
92
+ return null;
93
+ }
94
+ const current = activeProfile(stored);
95
+ if (current.state === "refreshing" &&
96
+ Date.now() - (current.refreshStartedAt ?? 0) < 20_000) {
97
+ throw new Error("OAuth refresh is in progress. Retry logout when it finishes.");
98
+ }
99
+ const next = { ...current, state: "revoking" };
100
+ config.profiles[name] = next;
101
+ return next;
102
+ });
103
+ if (!profile)
104
+ return { profile: name, revoked: false };
105
+ const endpoint = oauthUrl(profile.revocationEndpoint, profile.issuer).href;
106
+ await oauthRequest(endpoint, oauthForm({
107
+ token: profile.refreshToken,
108
+ token_type_hint: "refresh_token",
109
+ client_id: profile.clientId,
110
+ }));
111
+ await updateCliConfig(configDir, (config) => {
112
+ const current = config.profiles[name];
113
+ if (current &&
114
+ isOAuthProfile(current) &&
115
+ current.sessionId === profile.sessionId &&
116
+ current.state === "revoking") {
117
+ delete config.profiles[name];
118
+ if (config.defaultProfile === name)
119
+ delete config.defaultProfile;
120
+ }
121
+ });
122
+ return { profile: name, revoked: true };
123
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"operation-runner.d.ts","sourceRoot":"","sources":["../src/operation-runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAsBhE,wBAAsB,eAAe,CACnC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,OAAO,CAAC,CAwElB"}
1
+ {"version":3,"file":"operation-runner.d.ts","sourceRoot":"","sources":["../src/operation-runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAmBhE,wBAAsB,eAAe,CACnC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,OAAO,CAAC,CAwElB"}
@@ -23,7 +23,7 @@ export async function runSdkOperation(command, operation, flags) {
23
23
  const auth = await command.resolveAuth(flags, operation.requiredKeyKind);
24
24
  baseUrl = auth.baseUrl;
25
25
  client = clientFactories[operation.surface]({
26
- apiKey: auth.apiKey,
26
+ ...(auth.apiKeyKind === "oauth" ? { accessToken: auth.accessToken } : { apiKey: auth.apiKey }),
27
27
  ...(baseUrl ? { baseUrl } : {}),
28
28
  });
29
29
  }
@@ -31,7 +31,28 @@ export interface ActiveAgentCliProfile extends AgentProfileBase {
31
31
  state: "active";
32
32
  }
33
33
  export type AgentCliProfile = ActiveAgentCliProfile | RegisteringAgentCliProfile;
34
- export type CliProfile = AgentCliProfile | ApiKeyCliProfile;
34
+ export interface AuthorizingOAuthCliProfile {
35
+ type: "oauth";
36
+ state: "authorizing";
37
+ sessionId: string;
38
+ issuer: string;
39
+ }
40
+ export interface ActiveOAuthCliProfile {
41
+ type: "oauth";
42
+ state: "active" | "refreshing" | "revoking" | "reauthorize";
43
+ sessionId: string;
44
+ issuer: string;
45
+ clientId: string;
46
+ tokenEndpoint: string;
47
+ revocationEndpoint: string;
48
+ accessToken: string;
49
+ refreshToken: string;
50
+ expiresAt: number;
51
+ scopes: string[];
52
+ refreshStartedAt?: number;
53
+ }
54
+ export type OAuthCliProfile = AuthorizingOAuthCliProfile | ActiveOAuthCliProfile;
55
+ export type CliProfile = AgentCliProfile | ApiKeyCliProfile | OAuthCliProfile;
35
56
  export interface CliConfig {
36
57
  defaultProfile?: string;
37
58
  profiles: Record<string, CliProfile>;
@@ -43,6 +64,7 @@ export declare function clearAgentRegistrationIntent(configDir: string, profileN
43
64
  export declare function configPath(configDir: string): string;
44
65
  export declare function isAgentProfile(profile: CliProfile): profile is AgentCliProfile;
45
66
  export declare function isApiKeyProfile(profile: CliProfile): profile is ApiKeyCliProfile;
67
+ export declare function isOAuthProfile(profile: CliProfile): profile is OAuthCliProfile;
46
68
  export declare function isActiveAgentProfile(profile: CliProfile): profile is ActiveAgentCliProfile;
47
69
  export {};
48
70
  //# sourceMappingURL=profiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,UAAU,gBAAgB;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IAClE,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;KACnC,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,MAAM,e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/dist/profiles.js CHANGED
@@ -168,7 +168,10 @@ export function isAgentProfile(profile) {
168
168
  return profile.type === "agent";
169
169
  }
170
170
  export function isApiKeyProfile(profile) {
171
- return !isAgentProfile(profile);
171
+ return profile.type === undefined || profile.type === "api_key";
172
+ }
173
+ export function isOAuthProfile(profile) {
174
+ return profile.type === "oauth";
172
175
  }
173
176
  export function isActiveAgentProfile(profile) {
174
177
  return isAgentProfile(profile) && profile.state === "active";