@botiverse/oar 0.94.0 → 0.95.1
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.
- package/README.md +4 -0
- package/dist/contracts/account-usage.d.ts +80 -0
- package/dist/contracts/account-usage.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/login.d.ts +1 -0
- package/dist/contracts/login.d.ts.map +1 -1
- package/dist/contracts/runtime.d.ts +3 -1
- package/dist/contracts/runtime.d.ts.map +1 -1
- package/dist/contracts/runtime.js.map +1 -1
- package/dist/runtimes/claude/account-usage.d.ts.map +1 -1
- package/dist/runtimes/claude/account-usage.js +69 -66
- package/dist/runtimes/claude/account-usage.js.map +1 -1
- package/dist/runtimes/claude/auth-status.d.ts +1 -3
- package/dist/runtimes/claude/auth-status.d.ts.map +1 -1
- package/dist/runtimes/claude/auth-status.js +6 -2
- package/dist/runtimes/claude/auth-status.js.map +1 -1
- package/dist/runtimes/claude/login.d.ts.map +1 -1
- package/dist/runtimes/claude/login.js +4 -3
- package/dist/runtimes/claude/login.js.map +1 -1
- package/dist/runtimes/codebuddy/auth-status.d.ts +2 -1
- package/dist/runtimes/codebuddy/auth-status.d.ts.map +1 -1
- package/dist/runtimes/codebuddy/auth-status.js +9 -1
- package/dist/runtimes/codebuddy/auth-status.js.map +1 -1
- package/dist/runtimes/codebuddy/login.js +2 -2
- package/dist/runtimes/codebuddy/login.js.map +1 -1
- package/dist/runtimes/codex/account-request.d.ts +48 -0
- package/dist/runtimes/codex/account-request.d.ts.map +1 -0
- package/dist/runtimes/codex/account-request.js +101 -0
- package/dist/runtimes/codex/account-request.js.map +1 -0
- package/dist/runtimes/codex/account-usage.d.ts +3 -36
- package/dist/runtimes/codex/account-usage.d.ts.map +1 -1
- package/dist/runtimes/codex/account-usage.js +11 -74
- package/dist/runtimes/codex/account-usage.js.map +1 -1
- package/dist/runtimes/codex/index.d.ts +2 -0
- package/dist/runtimes/codex/index.d.ts.map +1 -1
- package/dist/runtimes/codex/index.js +3 -0
- package/dist/runtimes/codex/index.js.map +1 -1
- package/dist/runtimes/codex/limit-reset.d.ts +8 -0
- package/dist/runtimes/codex/limit-reset.d.ts.map +1 -0
- package/dist/runtimes/codex/limit-reset.js +34 -0
- package/dist/runtimes/codex/limit-reset.js.map +1 -0
- package/dist/runtimes/codex/login.d.ts +4 -1
- package/dist/runtimes/codex/login.d.ts.map +1 -1
- package/dist/runtimes/codex/login.js +10 -3
- package/dist/runtimes/codex/login.js.map +1 -1
- package/dist/runtimes/codex/logout.js +2 -2
- package/dist/runtimes/codex/logout.js.map +1 -1
- package/dist/runtimes/codex/reset-credits.d.ts +15 -0
- package/dist/runtimes/codex/reset-credits.d.ts.map +1 -0
- package/dist/runtimes/codex/reset-credits.js +64 -0
- package/dist/runtimes/codex/reset-credits.js.map +1 -0
- package/dist/runtimes/cursor/auth-status.d.ts.map +1 -1
- package/dist/runtimes/cursor/auth-status.js +15 -10
- package/dist/runtimes/cursor/auth-status.js.map +1 -1
- package/dist/runtimes/grok/account-usage.d.ts.map +1 -1
- package/dist/runtimes/grok/account-usage.js +58 -29
- package/dist/runtimes/grok/account-usage.js.map +1 -1
- package/dist/runtimes/kimi/auth-config.d.ts.map +1 -1
- package/dist/runtimes/kimi/auth-config.js +5 -3
- package/dist/runtimes/kimi/auth-config.js.map +1 -1
- package/dist/runtimes/kimi/auth-status.d.ts +3 -0
- package/dist/runtimes/kimi/auth-status.d.ts.map +1 -1
- package/dist/runtimes/kimi/auth-status.js +11 -1
- package/dist/runtimes/kimi/auth-status.js.map +1 -1
- package/dist/runtimes/kimi/logout.js +2 -2
- package/dist/runtimes/kimi/logout.js.map +1 -1
- package/dist/runtimes/qoder/auth-status.d.ts +3 -0
- package/dist/runtimes/qoder/auth-status.d.ts.map +1 -1
- package/dist/runtimes/qoder/auth-status.js +10 -2
- package/dist/runtimes/qoder/auth-status.js.map +1 -1
- package/dist/runtimes/qoder/login.js +2 -2
- package/dist/runtimes/qoder/login.js.map +1 -1
- package/dist/runtimes/qwen/auth-status.d.ts.map +1 -1
- package/dist/runtimes/qwen/auth-status.js +10 -16
- package/dist/runtimes/qwen/auth-status.js.map +1 -1
- package/dist/shared/executable/query.d.ts +11 -0
- package/dist/shared/executable/query.d.ts.map +1 -0
- package/dist/shared/executable/query.js +31 -0
- package/dist/shared/executable/query.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withQueryDeadline } from "../../shared/executable/query.js";
|
|
1
2
|
import { environmentValue, sessionEnvironment } from "../../shared/environment.js";
|
|
2
3
|
import { asRecord } from "../../shared/json.js";
|
|
3
4
|
import { loginBounds } from "../../shared/login.js";
|
|
@@ -13,7 +14,7 @@ export function projectCodebuddyAuthStatus(response) {
|
|
|
13
14
|
}
|
|
14
15
|
return { kind: "unknown", source: SOURCE, detail: "CodeBuddy initialize gave no account state" };
|
|
15
16
|
}
|
|
16
|
-
export async function
|
|
17
|
+
export async function readCodebuddyAuthStatus(installation, options = {}, signal) {
|
|
17
18
|
if (installation.via !== "executable") {
|
|
18
19
|
return { kind: "unknown", detail: "not a machine-installed executable" };
|
|
19
20
|
}
|
|
@@ -41,4 +42,11 @@ export async function codebuddyAuthStatus(installation, options = {}, signal) {
|
|
|
41
42
|
await client?.process.exited;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
export async function codebuddyAuthStatus(installation, options = {}) {
|
|
46
|
+
const status = await withQueryDeadline("CodeBuddy auth status", options.timeoutMs ?? 30_000, async (signal) => {
|
|
47
|
+
const result = await readCodebuddyAuthStatus(installation, options, signal);
|
|
48
|
+
return result;
|
|
49
|
+
}, { kind: "unknown", source: SOURCE, detail: "CodeBuddy account query timed out" });
|
|
50
|
+
return status;
|
|
51
|
+
}
|
|
44
52
|
//# sourceMappingURL=auth-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status.js","sources":["../../../src/runtimes/codebuddy/auth-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGnF,OAAO,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,GAAG,0CAA0C,CAAC;AAE1D,kGAAkG;AAClG,MAAM,UAAU,0BAA0B,CAAC,QAAoB;IAC7D,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAAC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC;IACjF,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC;IAC1F,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA4C,EAAE,CAAC;AACnG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"auth-status.js","sources":["../../../src/runtimes/codebuddy/auth-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGnF,OAAO,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,GAAG,0CAA0C,CAAC;AAE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,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,mCAAmC,EAAE,CAAC,CAAC;IACrF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { errorMessage, loginBounds, loginExecutable, stoppedResult } from "../../shared/login.js";
|
|
4
4
|
import { asRecord } from "../../shared/json.js";
|
|
5
5
|
import { codebuddyAccountControl } from "./account-control.js";
|
|
6
|
-
import {
|
|
6
|
+
import { readCodebuddyAuthStatus } from "./auth-status.js";
|
|
7
7
|
/** Native auth_failed includes token retrieval errors, not an explicit authorization denial. */
|
|
8
8
|
function authenticationFailure(value, redact) {
|
|
9
9
|
const error = asRecord(value);
|
|
@@ -92,7 +92,7 @@ export async function codebuddyLogin(installation, interaction, options = {}) {
|
|
|
92
92
|
if (remaining <= 0) {
|
|
93
93
|
return { kind: "logged_in" };
|
|
94
94
|
}
|
|
95
|
-
const status = await
|
|
95
|
+
const status = await readCodebuddyAuthStatus(installation, { env: options.env, timeoutMs: Math.min(30_000, remaining) }, interaction.signal);
|
|
96
96
|
return status.kind === "logged_out"
|
|
97
97
|
? { kind: "failed", reason: "not_logged_in", detail: "CodeBuddy reported success but its account query reads logged out" }
|
|
98
98
|
: { kind: "logged_in" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sources":["../../../src/runtimes/codebuddy/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.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Options } from "../../contracts/session-options.js";
|
|
2
|
+
import type { AccountUsageReauthReason, AccountUsageUnsupportedReason } from "../../contracts/account-usage.js";
|
|
3
|
+
import { type AppServerClient } from "./app-server-client.js";
|
|
4
|
+
export type ReadOutcome = {
|
|
5
|
+
readonly kind: "ok";
|
|
6
|
+
readonly result: unknown;
|
|
7
|
+
readonly email: string | undefined;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "reauth_required";
|
|
10
|
+
readonly reason: AccountUsageReauthReason;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "unsupported";
|
|
13
|
+
readonly reason: AccountUsageUnsupportedReason;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "error";
|
|
16
|
+
};
|
|
17
|
+
export type StartAppServerClient = (command: string, env?: SessionOptions["env"]) => AppServerClient;
|
|
18
|
+
/**
|
|
19
|
+
* One account request. `legacyParams` is sent instead when the app-server
|
|
20
|
+
* refuses `params` as one older than its fields (`invalid type: map,
|
|
21
|
+
* expected unit`, codex 0.131.0 for `account/rateLimits/read`).
|
|
22
|
+
*/
|
|
23
|
+
export interface AccountCall {
|
|
24
|
+
readonly method: string;
|
|
25
|
+
readonly params: Record<string, unknown>;
|
|
26
|
+
readonly legacyParams?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Native evidence from `account/read` on the same app-server session:
|
|
30
|
+
*
|
|
31
|
+
* ```json
|
|
32
|
+
* { "account": { "type": "chatgpt", "email": "user@example.com", "planType": "pro" },
|
|
33
|
+
* "requiresOpenaiAuth": true }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Only a ChatGPT (subscription) login carries a meaningful account email; an
|
|
37
|
+
* API-key account is dropped per the owner's `type === "chatgpt"` requirement.
|
|
38
|
+
*/
|
|
39
|
+
export declare function accountEmail(result: unknown): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Codex exposes ChatGPT rate-limit windows only for a ChatGPT account. API-key
|
|
42
|
+
* and provider-managed runtimes are valid, but have no subscription usage for
|
|
43
|
+
* this capability to report.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isNonSubscriptionAccount(result: unknown): boolean;
|
|
46
|
+
/** One ChatGPT-account request on a fresh app-server, after `account/read` rules out other account modes. */
|
|
47
|
+
export declare function callAppServer(command: string, timeoutMs: number, call: AccountCall, startClient?: StartAppServerClient, env?: SessionOptions["env"]): Promise<ReadOutcome>;
|
|
48
|
+
//# sourceMappingURL=account-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-request.d.ts","sources":["../../../src/runtimes/codex/account-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAChH,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGpF,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrF;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAA;CAAE,GAChF;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,eAAe,CAAC;AAErG;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMhE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAMjE;AAED,6GAA6G;AAC7G,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,WAAW,GAAE,oBAA2C,EACxD,GAAG,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAC1B,OAAO,CAAC,WAAW,CAAC,CAmDtB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { withQueryDeadline } from "../../shared/executable/query.js";
|
|
2
|
+
import { startAppServerClient } from "./app-server-client.js";
|
|
3
|
+
import { asRecord } from "../../shared/json.js";
|
|
4
|
+
async function request(client, call, signal) {
|
|
5
|
+
signal.throwIfAborted();
|
|
6
|
+
try {
|
|
7
|
+
return await client.request(call.method, call.params);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (call.legacyParams === undefined || !(error instanceof Error) || !/expected unit/iu.test(error.message)) {
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
signal.throwIfAborted();
|
|
14
|
+
return client.request(call.method, call.legacyParams);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Native evidence from `account/read` on the same app-server session:
|
|
19
|
+
*
|
|
20
|
+
* ```json
|
|
21
|
+
* { "account": { "type": "chatgpt", "email": "user@example.com", "planType": "pro" },
|
|
22
|
+
* "requiresOpenaiAuth": true }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Only a ChatGPT (subscription) login carries a meaningful account email; an
|
|
26
|
+
* API-key account is dropped per the owner's `type === "chatgpt"` requirement.
|
|
27
|
+
*/
|
|
28
|
+
export function accountEmail(result) {
|
|
29
|
+
const account = asRecord(asRecord(result)?.account);
|
|
30
|
+
if (account?.type !== "chatgpt" || typeof account.email !== "string") {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return account.email;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Codex exposes ChatGPT rate-limit windows only for a ChatGPT account. API-key
|
|
37
|
+
* and provider-managed runtimes are valid, but have no subscription usage for
|
|
38
|
+
* this capability to report.
|
|
39
|
+
*/
|
|
40
|
+
export function isNonSubscriptionAccount(result) {
|
|
41
|
+
const root = asRecord(result);
|
|
42
|
+
const account = asRecord(root?.account);
|
|
43
|
+
return account?.type === "apiKey"
|
|
44
|
+
|| account?.type === "amazonBedrock"
|
|
45
|
+
|| root?.requiresOpenaiAuth === false;
|
|
46
|
+
}
|
|
47
|
+
/** One ChatGPT-account request on a fresh app-server, after `account/read` rules out other account modes. */
|
|
48
|
+
export async function callAppServer(command, timeoutMs, call, startClient = startAppServerClient, env) {
|
|
49
|
+
try {
|
|
50
|
+
return await withQueryDeadline("Codex account request", timeoutMs, async (signal) => {
|
|
51
|
+
const client = startClient(command, env);
|
|
52
|
+
const stop = () => { client.kill(); };
|
|
53
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
54
|
+
try {
|
|
55
|
+
await client.request("initialize", {
|
|
56
|
+
clientInfo: { name: "oar", version: "0.0.0" },
|
|
57
|
+
capabilities: { experimentalApi: true },
|
|
58
|
+
});
|
|
59
|
+
signal.throwIfAborted();
|
|
60
|
+
client.notify("initialized", {});
|
|
61
|
+
// Read auth mode before the ChatGPT-only account endpoints. In API-key
|
|
62
|
+
// mode that endpoint rejects with "ChatGPT authentication required" even
|
|
63
|
+
// though Codex itself is correctly authenticated; treating that as expired
|
|
64
|
+
// OAuth would tell the user to perform a login that cannot fix the state.
|
|
65
|
+
let account = undefined;
|
|
66
|
+
try {
|
|
67
|
+
account = await client.request("account/read", {});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Older app-servers may not expose account/read. Preserve the existing
|
|
71
|
+
// rate-limit read in that case instead of making identity mandatory.
|
|
72
|
+
}
|
|
73
|
+
signal.throwIfAborted();
|
|
74
|
+
if (isNonSubscriptionAccount(account)) {
|
|
75
|
+
return { kind: "unsupported", reason: "unsupported_auth_mode" };
|
|
76
|
+
}
|
|
77
|
+
const result = await request(client, call, signal);
|
|
78
|
+
return { kind: "ok", result, email: accountEmail(account) };
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
signal.removeEventListener("abort", stop);
|
|
82
|
+
client.kill();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : "";
|
|
88
|
+
if (/chatgpt authentication required for rate limit reset/iu.test(message)) {
|
|
89
|
+
return { kind: "unsupported", reason: "unsupported_auth_mode" };
|
|
90
|
+
}
|
|
91
|
+
if (/authentication required/iu.test(message)) {
|
|
92
|
+
return { kind: "reauth_required", reason: "not_authenticated" };
|
|
93
|
+
}
|
|
94
|
+
// Codex answers a method it predates with `unknown variant` and the method name.
|
|
95
|
+
if (/method not found|not supported/iu.test(message) || message.includes(`unknown variant \`${call.method}\``)) {
|
|
96
|
+
return { kind: "unsupported", reason: "endpoint_unavailable" };
|
|
97
|
+
}
|
|
98
|
+
return { kind: "error" };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=account-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-request.js","sources":["../../../src/runtimes/codex/account-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,oBAAo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+1,6 @@
|
|
|
1
1
|
import type { SessionOptions } from "../../contracts/session-options.js";
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
4
|
-
type ReadOutcome = {
|
|
5
|
-
readonly kind: "ok";
|
|
6
|
-
readonly result: unknown;
|
|
7
|
-
readonly email: string | undefined;
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: "reauth_required";
|
|
10
|
-
readonly reason: AccountUsageReauthReason;
|
|
11
|
-
} | {
|
|
12
|
-
readonly kind: "unsupported";
|
|
13
|
-
readonly reason: AccountUsageUnsupportedReason;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "error";
|
|
16
|
-
};
|
|
17
|
-
type StartAppServerClient = (command: string, env?: SessionOptions["env"]) => AppServerClient;
|
|
2
|
+
import type { AccountUsageReader, AccountUsageSnapshot } from "../../contracts/account-usage.js";
|
|
3
|
+
import { type ReadOutcome, type StartAppServerClient } from "./account-request.js";
|
|
18
4
|
/**
|
|
19
5
|
* Native evidence comes from `codex app-server --listen stdio://`, followed by
|
|
20
6
|
* `initialize` and `account/rateLimits/read`. `rateLimits` is the
|
|
@@ -52,25 +38,6 @@ type StartAppServerClient = (command: string, env?: SessionOptions["env"]) => Ap
|
|
|
52
38
|
* ```
|
|
53
39
|
*/
|
|
54
40
|
export declare function projectCodexUsage(result: unknown, email?: string): AccountUsageSnapshot;
|
|
55
|
-
|
|
56
|
-
* Native evidence from `account/read` on the same app-server session:
|
|
57
|
-
*
|
|
58
|
-
* ```json
|
|
59
|
-
* { "account": { "type": "chatgpt", "email": "user@example.com", "planType": "pro" },
|
|
60
|
-
* "requiresOpenaiAuth": true }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* Only a ChatGPT (subscription) login carries a meaningful account email; an
|
|
64
|
-
* API-key account is dropped per the owner's `type === "chatgpt"` requirement.
|
|
65
|
-
*/
|
|
66
|
-
export declare function accountEmail(result: unknown): string | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* Codex exposes ChatGPT rate-limit windows only for a ChatGPT account. API-key
|
|
69
|
-
* and provider-managed runtimes are valid, but have no subscription usage for
|
|
70
|
-
* this capability to report.
|
|
71
|
-
*/
|
|
72
|
-
export declare function isNonSubscriptionAccount(result: unknown): boolean;
|
|
73
|
-
export declare function readFromAppServer(command: string, timeoutMs: number, startClient?: StartAppServerClient, env?: SessionOptions["env"]): Promise<ReadOutcome>;
|
|
41
|
+
export declare function readFromAppServer(command: string, timeoutMs: number, startClient?: StartAppServerClient, env?: SessionOptions["env"], limitResetDetails?: boolean): Promise<ReadOutcome>;
|
|
74
42
|
export declare const codexAccountUsage: AccountUsageReader;
|
|
75
|
-
export {};
|
|
76
43
|
//# sourceMappingURL=account-usage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-usage.d.ts","sources":["../../../src/runtimes/codex/account-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"account-usage.d.ts","sources":["../../../src/runtimes/codex/account-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAmDvF;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,oBAA2C,EACxD,GAAG,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,EAC3B,iBAAiB,UAAO,GACvB,OAAO,CAAC,WAAW,CAAC,CAMtB;AAGD,eAAO,MAAM,iBAAiB,EAAE,kBAgB/B,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { callAppServer } from "./account-request.js";
|
|
1
2
|
import { startAppServerClient } from "./app-server-client.js";
|
|
2
3
|
import { asEpochInstant, asNumber, asRecord } from "../../shared/json.js";
|
|
4
|
+
import { projectLimitResets } from "./reset-credits.js";
|
|
3
5
|
function text(value) {
|
|
4
6
|
if (typeof value !== "string") {
|
|
5
7
|
return undefined;
|
|
@@ -133,93 +135,28 @@ export function projectCodexUsage(result, email) {
|
|
|
133
135
|
if (windows.length === 0) {
|
|
134
136
|
throw new Error("Codex returned no usable account usage windows");
|
|
135
137
|
}
|
|
138
|
+
const limitResets = projectLimitResets(root?.rateLimitResetCredits);
|
|
136
139
|
return {
|
|
137
140
|
kind: "available",
|
|
138
141
|
...(plan === undefined ? {} : { plan }),
|
|
139
142
|
...(email === undefined ? {} : { email }),
|
|
140
143
|
rateLimited,
|
|
141
144
|
windows,
|
|
145
|
+
...(limitResets === undefined ? {} : { limitResets }),
|
|
142
146
|
};
|
|
143
147
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* ```
|
|
151
|
-
*
|
|
152
|
-
* Only a ChatGPT (subscription) login carries a meaningful account email; an
|
|
153
|
-
* API-key account is dropped per the owner's `type === "chatgpt"` requirement.
|
|
154
|
-
*/
|
|
155
|
-
export function accountEmail(result) {
|
|
156
|
-
const account = asRecord(asRecord(result)?.account);
|
|
157
|
-
if (account?.type !== "chatgpt" || typeof account.email !== "string") {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
return account.email;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Codex exposes ChatGPT rate-limit windows only for a ChatGPT account. API-key
|
|
164
|
-
* and provider-managed runtimes are valid, but have no subscription usage for
|
|
165
|
-
* this capability to report.
|
|
166
|
-
*/
|
|
167
|
-
export function isNonSubscriptionAccount(result) {
|
|
168
|
-
const root = asRecord(result);
|
|
169
|
-
const account = asRecord(root?.account);
|
|
170
|
-
return account?.type === "apiKey"
|
|
171
|
-
|| account?.type === "amazonBedrock"
|
|
172
|
-
|| root?.requiresOpenaiAuth === false;
|
|
173
|
-
}
|
|
174
|
-
export async function readFromAppServer(command, timeoutMs, startClient = startAppServerClient, env) {
|
|
175
|
-
const client = startClient(command, env);
|
|
176
|
-
const deadline = setTimeout(() => {
|
|
177
|
-
client.kill();
|
|
178
|
-
}, timeoutMs);
|
|
179
|
-
try {
|
|
180
|
-
await client.request("initialize", {
|
|
181
|
-
clientInfo: { name: "oar", version: "0.0.0" },
|
|
182
|
-
capabilities: { experimentalApi: true },
|
|
183
|
-
});
|
|
184
|
-
client.notify("initialized", {});
|
|
185
|
-
// Read auth mode before the ChatGPT-only rate-limit endpoint. In API-key
|
|
186
|
-
// mode that endpoint rejects with "ChatGPT authentication required" even
|
|
187
|
-
// though Codex itself is correctly authenticated; treating that as expired
|
|
188
|
-
// OAuth would tell the user to perform a login that cannot fix the state.
|
|
189
|
-
let account = undefined;
|
|
190
|
-
try {
|
|
191
|
-
account = await client.request("account/read", {});
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
// Older app-servers may not expose account/read. Preserve the existing
|
|
195
|
-
// rate-limit read in that case instead of making identity mandatory.
|
|
196
|
-
}
|
|
197
|
-
if (isNonSubscriptionAccount(account)) {
|
|
198
|
-
return { kind: "unsupported", reason: "unsupported_auth_mode" };
|
|
199
|
-
}
|
|
200
|
-
const result = await client.request("account/rateLimits/read", {});
|
|
201
|
-
return { kind: "ok", result, email: accountEmail(account) };
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
const message = error instanceof Error ? error.message : "";
|
|
205
|
-
if (/authentication required/iu.test(message)) {
|
|
206
|
-
return { kind: "reauth_required", reason: "not_authenticated" };
|
|
207
|
-
}
|
|
208
|
-
if (/method not found|not supported/iu.test(message)) {
|
|
209
|
-
return { kind: "unsupported", reason: "endpoint_unavailable" };
|
|
210
|
-
}
|
|
211
|
-
return { kind: "error" };
|
|
212
|
-
}
|
|
213
|
-
finally {
|
|
214
|
-
clearTimeout(deadline);
|
|
215
|
-
client.kill();
|
|
216
|
-
}
|
|
148
|
+
export async function readFromAppServer(command, timeoutMs, startClient = startAppServerClient, env, limitResetDetails = true) {
|
|
149
|
+
// Older app-servers take this read with no params and refuse any field;
|
|
150
|
+
// they report no reset credits either, so the bare read loses nothing.
|
|
151
|
+
const params = limitResetDetails ? {} : { excludeResetCreditDetails: true };
|
|
152
|
+
const outcome = await callAppServer(command, timeoutMs, { method: "account/rateLimits/read", params, legacyParams: {} }, startClient, env);
|
|
153
|
+
return outcome;
|
|
217
154
|
}
|
|
218
155
|
export const codexAccountUsage = async (installation, options = {}) => {
|
|
219
156
|
if (installation.via !== "executable") {
|
|
220
157
|
return { kind: "unsupported", reason: "unsupported_installation" };
|
|
221
158
|
}
|
|
222
|
-
const outcome = await readFromAppServer(installation.command, options.timeoutMs ?? 8000, undefined, options.env);
|
|
159
|
+
const outcome = await readFromAppServer(installation.command, options.timeoutMs ?? 8000, undefined, options.env, options.limitResetDetails ?? true);
|
|
223
160
|
switch (outcome.kind) {
|
|
224
161
|
case "ok":
|
|
225
162
|
return projectCodexUsage(outcome.result, outcome.email);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-usage.js","sources":["../../../src/runtimes/codex/account-usage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account-usage.js","sources":["../../../src/runtimes/codex/account-usage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAA+C,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,s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AAE,CAAC;QACrB,KAAK,IAAI;YACP,OAAO,iBAAiB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1D,KAAK,iBAAiB;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO;YACV,MAAM;IACV,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -34,6 +34,7 @@ export declare const codexRuntime: Omit<{
|
|
|
34
34
|
readonly installPlan: import("../../browser.js").InstallPlanner;
|
|
35
35
|
readonly install: import("../../browser.js").Installer;
|
|
36
36
|
readonly accountUsage: import("../../browser.js").AccountUsageReader;
|
|
37
|
+
readonly redeemLimitReset: import("../../browser.js").LimitResetRedeemer;
|
|
37
38
|
readonly listModels: import("../../browser.js").ModelLister;
|
|
38
39
|
readonly checkUpdate: typeof codexCheckUpdate;
|
|
39
40
|
readonly upgrade: typeof codexUpgrade;
|
|
@@ -43,6 +44,7 @@ export declare const codexRuntime: Omit<{
|
|
|
43
44
|
readonly session: import("../../browser.js").StartSession;
|
|
44
45
|
}, "execution" | "placement" | "session" | "withPlacement"> & import("../../contracts/runtime.js").Runtime;
|
|
45
46
|
export { codexAccountUsage, projectCodexUsage } from "./account-usage.js";
|
|
47
|
+
export { codexRedeemLimitReset } from "./limit-reset.js";
|
|
46
48
|
export { codexListModels, projectCodexModels } from "./list-models.js";
|
|
47
49
|
export { codexSession } from "./session.js";
|
|
48
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../../../src/runtimes/codex/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../../src/runtimes/codex/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI7D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0GAyBG,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { defineRuntime } from "../../contracts/runtime.js";
|
|
|
5
5
|
import { codexAuthStatus, codexLogin } from "./login.js";
|
|
6
6
|
import { codexLogout } from "./logout.js";
|
|
7
7
|
import { codexAccountUsage } from "./account-usage.js";
|
|
8
|
+
import { codexRedeemLimitReset } from "./limit-reset.js";
|
|
8
9
|
import { codexInstallation } from "./installation.js";
|
|
9
10
|
import { codexInstall, codexInstallPlan } from "./install.js";
|
|
10
11
|
import { codexListModels } from "./list-models.js";
|
|
@@ -28,6 +29,7 @@ export const codexRuntime = defineRuntime({
|
|
|
28
29
|
installPlan: codexInstallPlan,
|
|
29
30
|
install: codexInstall,
|
|
30
31
|
accountUsage: codexAccountUsage,
|
|
32
|
+
redeemLimitReset: codexRedeemLimitReset,
|
|
31
33
|
listModels: codexListModels,
|
|
32
34
|
checkUpdate: codexCheckUpdate,
|
|
33
35
|
upgrade: codexUpgrade,
|
|
@@ -37,6 +39,7 @@ export const codexRuntime = defineRuntime({
|
|
|
37
39
|
session: codexSession,
|
|
38
40
|
}, { execution: "process" });
|
|
39
41
|
export { codexAccountUsage, projectCodexUsage } from "./account-usage.js";
|
|
42
|
+
export { codexRedeemLimitReset } from "./limit-reset.js";
|
|
40
43
|
export { codexListModels, projectCodexModels } from "./list-models.js";
|
|
41
44
|
export { codexSession } from "./session.js";
|
|
42
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/runtimes/codex/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;IACxC,EAAE,EAAE,OAAO;IACX,gBAAgB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE;IAC7D,qBAAqB,EAAE,0BAA0B;IACjD,qBAAqB,EAAE;QACrB,YAAY,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE;QACzD,kBAAkB,EAAE,EAA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E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LimitResetRedeemer } from "../../contracts/account-usage.js";
|
|
2
|
+
/**
|
|
3
|
+
* Spends a reset credit through the call the codex TUI makes. The idempotency
|
|
4
|
+
* key goes to Codex's backend as its redeem request id; Codex bounds that
|
|
5
|
+
* backend call itself at 10 s.
|
|
6
|
+
*/
|
|
7
|
+
export declare const codexRedeemLimitReset: LimitResetRedeemer;
|
|
8
|
+
//# sourceMappingURL=limit-reset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit-reset.d.ts","sources":["../../../src/runtimes/codex/limit-reset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAI3E;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBA+BnC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { callAppServer } from "./account-request.js";
|
|
2
|
+
import { projectLimitResetOutcome } from "./reset-credits.js";
|
|
3
|
+
/**
|
|
4
|
+
* Spends a reset credit through the call the codex TUI makes. The idempotency
|
|
5
|
+
* key goes to Codex's backend as its redeem request id; Codex bounds that
|
|
6
|
+
* backend call itself at 10 s.
|
|
7
|
+
*/
|
|
8
|
+
export const codexRedeemLimitReset = async (installation, options) => {
|
|
9
|
+
if (options.idempotencyKey.length === 0) {
|
|
10
|
+
throw new Error("idempotencyKey must not be empty");
|
|
11
|
+
}
|
|
12
|
+
if (options.resetId?.length === 0) {
|
|
13
|
+
throw new Error("resetId must not be empty");
|
|
14
|
+
}
|
|
15
|
+
if (installation.via !== "executable") {
|
|
16
|
+
return { kind: "unsupported", reason: "unsupported_installation" };
|
|
17
|
+
}
|
|
18
|
+
const outcome = await callAppServer(installation.command, options.timeoutMs ?? 20_000, {
|
|
19
|
+
method: "account/rateLimitResetCredit/consume",
|
|
20
|
+
params: { idempotencyKey: options.idempotencyKey, ...(options.resetId === undefined ? {} : { creditId: options.resetId }) },
|
|
21
|
+
}, undefined, options.env);
|
|
22
|
+
switch (outcome.kind) {
|
|
23
|
+
case "ok":
|
|
24
|
+
return projectLimitResetOutcome(outcome.result);
|
|
25
|
+
case "reauth_required":
|
|
26
|
+
return outcome;
|
|
27
|
+
case "unsupported":
|
|
28
|
+
return outcome;
|
|
29
|
+
case "error":
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
throw new Error("Failed to redeem a Codex limit reset; whether it was spent is unknown, so retry with the same idempotencyKey");
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=limit-reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit-reset.js","sources":["../../../src/runtimes/codex/limit-reset.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAuB,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE;IACvF,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,YAAY,CAAC,GAAG,KAAK,YAAY,EAAE,CAAC;QACtC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrE,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,aAAa,CACjC,YAAY,CAAC,OAAO,EACpB,OAAO,CAAC,SAAS,IAAI,MAAM,EAC3B;QACE,MAAM,EAAE,sCAAsC;QAC9C,MAAM,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE;KAC5H,EACD,SAAS,EACT,OAAO,CAAC,GAAG,CACZ,CAAC;IACF,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,IAAI;YACP,OAAO,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,KAAK,iBAAiB;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO;YACV,MAAM;IACV,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,8GAA8G,CAAC,CAAC;AAClI,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvailableInstallation } from "../../contracts/installation.js";
|
|
2
|
-
import type { AuthStatus, AuthStatusReader, LoginAccount, LoginOptions, LoginResult } from "../../contracts/login.js";
|
|
2
|
+
import type { AuthStatus, AuthStatusOptions, AuthStatusReader, LoginAccount, LoginOptions, LoginResult } from "../../contracts/login.js";
|
|
3
3
|
import type { ProviderLoginInteraction } from "../../contracts/provider-auth.js";
|
|
4
4
|
/**
|
|
5
5
|
* `codex login status` prints to stderr and exits 0 when logged in
|
|
@@ -8,6 +8,9 @@ import type { ProviderLoginInteraction } from "../../contracts/provider-auth.js"
|
|
|
8
8
|
* it cannot tell (an unreadable configuration or credential store).
|
|
9
9
|
*/
|
|
10
10
|
export declare function projectCodexLoginStatus(exitCode: number | null, output: string): AuthStatus;
|
|
11
|
+
export declare function readCodexAuthStatus(installation: AvailableInstallation, options?: AuthStatusOptions & {
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}): Promise<AuthStatus>;
|
|
11
14
|
/** Native status can hydrate personal access tokens and identity credentials over the network. */
|
|
12
15
|
export declare const codexAuthStatus: AuthStatusReader;
|
|
13
16
|
/** `account/read` after the sign-in; null when codex reports no account. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sources":["../../../src/runtimes/codex/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sources":["../../../src/runtimes/codex/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AA+CjF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAc3F;AAED,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,qBAAqB,EAAE,OAAO,GAAE,iBAAiB,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAMvK;AAED,kGAAkG;AAClG,eAAO,MAAM,eAAe,EAAE,gBAM7B,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAcxE;AA4KD,oGAAoG;AACpG,wBAAsB,UAAU,CAC9B,YAAY,EAAE,qBAAqB,EACnC,WAAW,EAAE,wBAAwB,EACrC,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAUtB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withQueryDeadline } from "../../shared/executable/query.js";
|
|
1
2
|
import { sessionEnvironment } from "../../shared/environment.js";
|
|
2
3
|
import { runExecutable } from "../../shared/executable/index.js";
|
|
3
4
|
import { asRecord } from "../../shared/json.js";
|
|
@@ -57,15 +58,21 @@ export function projectCodexLoginStatus(exitCode, output) {
|
|
|
57
58
|
source: STATUS_SOURCE,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
async function readCodexAuthStatus(installation, options = {}) {
|
|
61
|
+
export async function readCodexAuthStatus(installation, options = {}) {
|
|
61
62
|
if (installation.via !== "executable") {
|
|
62
63
|
return { kind: "unknown", detail: "not a machine-installed executable" };
|
|
63
64
|
}
|
|
64
|
-
const result = await runExecutable(installation.command, ["login", "status"], { env: sessionEnvironment(options.env), timeoutMs: options.timeoutMs ?? STATUS_TIMEOUT_MS });
|
|
65
|
+
const result = await runExecutable(installation.command, ["login", "status"], { env: sessionEnvironment(options.env), timeoutMs: options.timeoutMs ?? STATUS_TIMEOUT_MS, ...(options.signal === undefined ? {} : { signal: options.signal }) });
|
|
65
66
|
return projectCodexLoginStatus(result.ok ? 0 : result.exitCode, `${result.stdout}\n${result.stderr}`);
|
|
66
67
|
}
|
|
67
68
|
/** Native status can hydrate personal access tokens and identity credentials over the network. */
|
|
68
|
-
export const codexAuthStatus =
|
|
69
|
+
export const codexAuthStatus = async (installation, options = {}) => {
|
|
70
|
+
const status = await withQueryDeadline("Codex auth status", options.timeoutMs ?? STATUS_TIMEOUT_MS, async (signal) => {
|
|
71
|
+
const result = await readCodexAuthStatus(installation, { ...options, signal });
|
|
72
|
+
return result;
|
|
73
|
+
}, { kind: "unknown", source: STATUS_SOURCE, detail: "Codex auth status timed out" });
|
|
74
|
+
return status;
|
|
75
|
+
};
|
|
69
76
|
/** `account/read` after the sign-in; null when codex reports no account. */
|
|
70
77
|
export function projectCodexAccount(result) {
|
|
71
78
|
const account = asRecord(asRecord(result)?.account);
|