@codeworksh/aikit 0.5.0 → 0.5.1-dev.20260613074656

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.
@@ -1,10 +1,20 @@
1
1
  //#region src/oauth/openai/codex.d.ts
2
2
  /**
3
- * OpenAI Codex OAuth helpers.
3
+ * OpenAI Codex OAuth.
4
4
  *
5
- * This flow is intended for Node.js CLI/server environments. The low-level
6
- * authorization helpers are storage-free so they can also be used from an
7
- * existing HTTP server callback route.
5
+ * Public interface, by use case:
6
+ *
7
+ * 1. Server OAuth integration (storage-free, bring your own routes):
8
+ * `createOpenAICodexAuthorizationFlow`, `exchangeOpenAICodexAuthorizationCode`,
9
+ * `parseOpenAICodexAuthorizationInput`, `refreshOpenAICodexToken`, `getOpenAICodexAccountId`.
10
+ * 2. CLI / interactive login (localhost callback server, persisted credentials):
11
+ * `OpenAICodexOAuthClient`, `JsonOpenAICodexAuthStorage`, `OpenAICodexAuthStorage`.
12
+ * 3. Application credential access (get key, auto-refresh, request headers):
13
+ * `getOpenAICodexApiKey`, `OpenAICodexOAuthClient.getCredentials/getApiKey/getHeaders`,
14
+ * `openAICodexHeaders`, `OPENAI_CODEX_API_KEY_ENV`.
15
+ *
16
+ * Everything else in this module is an implementation detail and intentionally
17
+ * not exported.
8
18
  */
9
19
  type OpenAICodexOAuthCredentials = {
10
20
  access: string;
@@ -35,7 +45,7 @@ type OpenAICodexAuthorizationOptions = {
35
45
  redirectUri?: string;
36
46
  scope?: string;
37
47
  };
38
- type OpenAICodexPrompt = {
48
+ type OpenAICodexLoginPrompt = {
39
49
  message: string;
40
50
  placeholder?: string;
41
51
  allowEmpty?: boolean;
@@ -45,7 +55,7 @@ type OpenAICodexLoginOptions = OpenAICodexAuthorizationOptions & {
45
55
  url: string;
46
56
  instructions?: string;
47
57
  }) => void;
48
- onPrompt: (prompt: OpenAICodexPrompt) => Promise<string>;
58
+ onPrompt: (prompt: OpenAICodexLoginPrompt) => Promise<string>;
49
59
  onProgress?: (message: string) => void;
50
60
  onManualCodeInput?: () => Promise<string>;
51
61
  };
@@ -58,7 +68,6 @@ type JsonOpenAICodexAuthStorageOptions = {
58
68
  path?: string;
59
69
  providerId?: string;
60
70
  };
61
- declare function defaultOpenAICodexAuthFilePath(): string;
62
71
  declare function parseOpenAICodexAuthorizationInput(input: string): {
63
72
  code?: string;
64
73
  state?: string;
@@ -66,7 +75,6 @@ declare function parseOpenAICodexAuthorizationInput(input: string): {
66
75
  declare function getOpenAICodexAccountId(accessToken: string): string | null;
67
76
  declare function createOpenAICodexAuthorizationFlow(options?: OpenAICodexAuthorizationOptions): Promise<OpenAICodexAuthorizationFlow>;
68
77
  declare function exchangeOpenAICodexAuthorizationCode(code: string, verifier: string, redirectUri?: string): Promise<OpenAICodexTokenResult>;
69
- declare function loginOpenAICodex(options: OpenAICodexLoginOptions): Promise<OpenAICodexOAuthCredentials>;
70
78
  declare function refreshOpenAICodexToken(refreshToken: string): Promise<OpenAICodexOAuthCredentials>;
71
79
  declare function openAICodexHeaders(credentials: OpenAICodexOAuthCredentials): Record<string, string>;
72
80
  declare class JsonOpenAICodexAuthStorage implements OpenAICodexAuthStorage {
@@ -93,15 +101,16 @@ declare class OpenAICodexOAuthClient {
93
101
  getHeaders(): Promise<Record<string, string> | undefined>;
94
102
  logout(): Promise<void>;
95
103
  }
96
- declare const openAICodexOAuthProvider: {
97
- readonly id: "openai-codex";
98
- readonly name: "ChatGPT Plus/Pro (OpenAI Codex)";
99
- readonly usesCallbackServer: true;
100
- readonly login: (options: OpenAICodexLoginOptions) => Promise<OpenAICodexOAuthCredentials>;
101
- readonly refreshToken: (credentials: OpenAICodexOAuthCredentials) => Promise<OpenAICodexOAuthCredentials>;
102
- readonly getApiKey: (credentials: OpenAICodexOAuthCredentials) => string;
103
- readonly getHeaders: (credentials: OpenAICodexOAuthCredentials) => Record<string, string>;
104
- };
104
+ declare const OPENAI_CODEX_API_KEY_ENV = "OPENAI_CODEX_API_KEY";
105
+ /**
106
+ * Resolve the OpenAI Codex API key the same way other provider API keys are
107
+ * resolved: prefer the OPENAI_CODEX_API_KEY environment variable, then fall
108
+ * back to stored OAuth credentials (refreshing them when close to expiry).
109
+ *
110
+ * The result can be passed directly as `apiKey` to the runtime options or to
111
+ * `createOpenAICodex`. Returns undefined when no key is available.
112
+ */
113
+ declare function getOpenAICodexApiKey(options?: OpenAICodexOAuthClientOptions): Promise<string | undefined>;
105
114
  //#endregion
106
- export { JsonOpenAICodexAuthStorage, JsonOpenAICodexAuthStorageOptions, OpenAICodexAuthStorage, OpenAICodexAuthorizationFlow, OpenAICodexAuthorizationOptions, OpenAICodexLoginOptions, OpenAICodexOAuthClient, OpenAICodexOAuthClientOptions, OpenAICodexOAuthCredentials, OpenAICodexPrompt, OpenAICodexTokenFailure, OpenAICodexTokenResult, OpenAICodexTokenSuccess, createOpenAICodexAuthorizationFlow, defaultOpenAICodexAuthFilePath, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, loginOpenAICodex, openAICodexHeaders, openAICodexOAuthProvider, parseOpenAICodexAuthorizationInput, refreshOpenAICodexToken };
115
+ export { JsonOpenAICodexAuthStorage, JsonOpenAICodexAuthStorageOptions, OPENAI_CODEX_API_KEY_ENV, OpenAICodexAuthStorage, OpenAICodexAuthorizationFlow, OpenAICodexAuthorizationOptions, OpenAICodexLoginOptions, OpenAICodexLoginPrompt, OpenAICodexOAuthClient, OpenAICodexOAuthClientOptions, OpenAICodexOAuthCredentials, OpenAICodexTokenFailure, OpenAICodexTokenResult, OpenAICodexTokenSuccess, createOpenAICodexAuthorizationFlow, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, getOpenAICodexApiKey, openAICodexHeaders, parseOpenAICodexAuthorizationInput, refreshOpenAICodexToken };
107
116
  //# sourceMappingURL=codex.d.mts.map
@@ -1,2 +1,2 @@
1
- import { a as exchangeOpenAICodexAuthorizationCode, c as openAICodexHeaders, d as refreshOpenAICodexToken, i as defaultOpenAICodexAuthFilePath, l as openAICodexOAuthProvider, n as OpenAICodexOAuthClient, o as getOpenAICodexAccountId, r as createOpenAICodexAuthorizationFlow, s as loginOpenAICodex, t as JsonOpenAICodexAuthStorage, u as parseOpenAICodexAuthorizationInput } from "../../codex-DfYk740t.mjs";
2
- export { JsonOpenAICodexAuthStorage, OpenAICodexOAuthClient, createOpenAICodexAuthorizationFlow, defaultOpenAICodexAuthFilePath, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, loginOpenAICodex, openAICodexHeaders, openAICodexOAuthProvider, parseOpenAICodexAuthorizationInput, refreshOpenAICodexToken };
1
+ import { a as exchangeOpenAICodexAuthorizationCode, c as openAICodexHeaders, i as createOpenAICodexAuthorizationFlow, l as parseOpenAICodexAuthorizationInput, n as OPENAI_CODEX_API_KEY_ENV, o as getOpenAICodexAccountId, r as OpenAICodexOAuthClient, s as getOpenAICodexApiKey, t as JsonOpenAICodexAuthStorage, u as refreshOpenAICodexToken } from "../../codex-C36oU6yH.mjs";
2
+ export { JsonOpenAICodexAuthStorage, OPENAI_CODEX_API_KEY_ENV, OpenAICodexOAuthClient, createOpenAICodexAuthorizationFlow, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, getOpenAICodexApiKey, openAICodexHeaders, parseOpenAICodexAuthorizationInput, refreshOpenAICodexToken };