@codeworksh/aikit 0.8.0 → 0.9.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.
- package/README.md +10 -1
- package/cli.mjs +75 -83
- package/cli.mjs.map +1 -1
- package/{codex-MtP1574D.mjs → codex-CLDBTrFm.mjs} +132 -134
- package/codex-CLDBTrFm.mjs.map +1 -0
- package/copilot-CcD3g6H8.mjs +425 -0
- package/copilot-CcD3g6H8.mjs.map +1 -0
- package/copilot-headers-DceqXlpj.mjs +104 -0
- package/copilot-headers-DceqXlpj.mjs.map +1 -0
- package/github-copilot-BJIrxOzT.mjs +3 -0
- package/github-copilot-SIUCJz1G.mjs +126 -0
- package/github-copilot-SIUCJz1G.mjs.map +1 -0
- package/index.d.mts +980 -932
- package/index.mjs +63 -11
- package/index.mjs.map +1 -1
- package/interactive-eoNnscGB.mjs +57 -0
- package/interactive-eoNnscGB.mjs.map +1 -0
- package/{model-CpX11Oob.d.mts → model-CrVLp622.d.mts} +159 -130
- package/{model-CBnredXj.mjs → model-gCDbmGqT.mjs} +31 -2
- package/model-gCDbmGqT.mjs.map +1 -0
- package/{modelgen-BjSsusLQ.mjs → modelgen-DvorXOjJ.mjs} +148 -29
- package/modelgen-DvorXOjJ.mjs.map +1 -0
- package/modelgen.d.mts +2 -3
- package/modelgen.mjs +1 -1
- package/oauth/github/copilot.d.mts +169 -0
- package/oauth/github/copilot.mjs +2 -0
- package/oauth/interactive.d.mts +21 -0
- package/oauth/interactive.mjs +2 -0
- package/oauth/openai/codex.d.mts +46 -28
- package/oauth/openai/codex.mjs +2 -2
- package/oauth/summary.d.mts +67 -0
- package/oauth/summary.mjs +2 -0
- package/{openai-codex-t4B7g-gv.mjs → openai-codex-Bqzti6Mc.mjs} +3 -3
- package/{openai-codex-t4B7g-gv.mjs.map → openai-codex-Bqzti6Mc.mjs.map} +1 -1
- package/openai-codex-DA1Q7mLN.mjs +2 -0
- package/package.json +34 -22
- package/{registry-DYdYTwFt.mjs → registry-ZxwIW0gX.mjs} +5 -3
- package/registry-ZxwIW0gX.mjs.map +1 -0
- package/storage-v6qjTQ0v.mjs +178 -0
- package/storage-v6qjTQ0v.mjs.map +1 -0
- package/summary-C_QyCVWa.mjs +68 -0
- package/summary-C_QyCVWa.mjs.map +1 -0
- package/codex-MtP1574D.mjs.map +0 -1
- package/model-CBnredXj.mjs.map +0 -1
- package/modelgen-BjSsusLQ.mjs.map +0 -1
- package/openai-codex-BRH4Qa7l.mjs +0 -2
- package/registry-DYdYTwFt.mjs.map +0 -1
package/oauth/openai/codex.d.mts
CHANGED
|
@@ -16,82 +16,101 @@
|
|
|
16
16
|
* Everything else in this module is an implementation detail and intentionally
|
|
17
17
|
* not exported.
|
|
18
18
|
*/
|
|
19
|
-
type OpenAICodexOAuthCredentials = {
|
|
19
|
+
export type OpenAICodexOAuthCredentials = {
|
|
20
20
|
access: string;
|
|
21
21
|
refresh: string;
|
|
22
22
|
expires: number;
|
|
23
23
|
accountId: string;
|
|
24
24
|
};
|
|
25
|
-
type OpenAICodexTokenSuccess = {
|
|
25
|
+
export type OpenAICodexTokenSuccess = {
|
|
26
26
|
type: "success";
|
|
27
27
|
access: string;
|
|
28
28
|
refresh: string;
|
|
29
29
|
expires: number;
|
|
30
30
|
};
|
|
31
|
-
type OpenAICodexTokenFailure = {
|
|
31
|
+
export type OpenAICodexTokenFailure = {
|
|
32
32
|
type: "failed";
|
|
33
33
|
message: string;
|
|
34
34
|
status?: number;
|
|
35
35
|
};
|
|
36
|
-
type OpenAICodexTokenResult = OpenAICodexTokenSuccess | OpenAICodexTokenFailure;
|
|
37
|
-
type OpenAICodexAuthorizationFlow = {
|
|
36
|
+
export type OpenAICodexTokenResult = OpenAICodexTokenSuccess | OpenAICodexTokenFailure;
|
|
37
|
+
export type OpenAICodexAuthorizationFlow = {
|
|
38
38
|
url: string;
|
|
39
39
|
verifier: string;
|
|
40
40
|
state: string;
|
|
41
41
|
redirectUri: string;
|
|
42
42
|
};
|
|
43
|
-
type OpenAICodexAuthorizationOptions = {
|
|
43
|
+
export type OpenAICodexAuthorizationOptions = {
|
|
44
44
|
originator?: string;
|
|
45
45
|
redirectUri?: string;
|
|
46
46
|
scope?: string;
|
|
47
47
|
};
|
|
48
|
-
type OpenAICodexLoginPrompt = {
|
|
48
|
+
export type OpenAICodexLoginPrompt = {
|
|
49
49
|
message: string;
|
|
50
50
|
placeholder?: string;
|
|
51
51
|
allowEmpty?: boolean;
|
|
52
52
|
};
|
|
53
|
-
type
|
|
53
|
+
export type OpenAICodexDeviceAuth = {
|
|
54
|
+
deviceAuthId: string;
|
|
55
|
+
userCode: string;
|
|
56
|
+
verificationUri: string;
|
|
57
|
+
intervalSeconds: number;
|
|
58
|
+
};
|
|
59
|
+
export type OpenAICodexLoginOptions = OpenAICodexAuthorizationOptions & {
|
|
60
|
+
/** Use the device-code flow instead of the localhost browser callback. */
|
|
61
|
+
device?: boolean | undefined;
|
|
62
|
+
signal?: AbortSignal | undefined;
|
|
54
63
|
onAuth: (info: {
|
|
55
64
|
url: string;
|
|
56
|
-
|
|
65
|
+
userCode?: string | undefined;
|
|
66
|
+
instructions?: string | undefined;
|
|
57
67
|
}) => void;
|
|
58
68
|
onPrompt: (prompt: OpenAICodexLoginPrompt) => Promise<string>;
|
|
59
69
|
onProgress?: (message: string) => void;
|
|
60
|
-
onManualCodeInput?: () => Promise<string>;
|
|
61
70
|
};
|
|
62
|
-
interface OpenAICodexAuthStorage {
|
|
71
|
+
export interface OpenAICodexAuthStorage {
|
|
63
72
|
get(): Promise<OpenAICodexOAuthCredentials | undefined>;
|
|
64
73
|
set(credentials: OpenAICodexOAuthCredentials): Promise<void>;
|
|
65
74
|
clear(): Promise<void>;
|
|
66
75
|
}
|
|
67
|
-
type JsonOpenAICodexAuthStorageOptions = {
|
|
76
|
+
export type JsonOpenAICodexAuthStorageOptions = {
|
|
68
77
|
path?: string;
|
|
69
78
|
providerId?: string;
|
|
70
79
|
};
|
|
71
|
-
declare function parseOpenAICodexAuthorizationInput(input: string): {
|
|
80
|
+
export declare function parseOpenAICodexAuthorizationInput(input: string): {
|
|
72
81
|
code?: string;
|
|
73
82
|
state?: string;
|
|
74
83
|
};
|
|
75
|
-
declare function getOpenAICodexAccountId(accessToken: string): string | null;
|
|
76
|
-
declare function createOpenAICodexAuthorizationFlow(options?: OpenAICodexAuthorizationOptions): Promise<OpenAICodexAuthorizationFlow>;
|
|
77
|
-
declare function exchangeOpenAICodexAuthorizationCode(code: string, verifier: string, redirectUri?: string): Promise<OpenAICodexTokenResult>;
|
|
78
|
-
|
|
79
|
-
declare function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
export declare function getOpenAICodexAccountId(accessToken: string): string | null;
|
|
85
|
+
export declare function createOpenAICodexAuthorizationFlow(options?: OpenAICodexAuthorizationOptions): Promise<OpenAICodexAuthorizationFlow>;
|
|
86
|
+
export declare function exchangeOpenAICodexAuthorizationCode(code: string, verifier: string, redirectUri?: string): Promise<OpenAICodexTokenResult>;
|
|
87
|
+
/** Ask for a user code to type at {@link DEVICE_VERIFICATION_URI}. */
|
|
88
|
+
export declare function createOpenAICodexDeviceAuth(options?: {
|
|
89
|
+
signal?: AbortSignal | undefined;
|
|
90
|
+
}): Promise<OpenAICodexDeviceAuth>;
|
|
91
|
+
/** Wait for the code to be approved; the server returns the code and its verifier. */
|
|
92
|
+
export declare function pollOpenAICodexDeviceAuth(device: OpenAICodexDeviceAuth, options?: {
|
|
93
|
+
signal?: AbortSignal | undefined;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
authorizationCode: string;
|
|
96
|
+
codeVerifier: string;
|
|
97
|
+
}>;
|
|
98
|
+
export declare function refreshOpenAICodexToken(refreshToken: string): Promise<OpenAICodexOAuthCredentials>;
|
|
99
|
+
export declare function openAICodexHeaders(credentials: OpenAICodexOAuthCredentials): Record<string, string>;
|
|
100
|
+
export declare class JsonOpenAICodexAuthStorage implements OpenAICodexAuthStorage {
|
|
101
|
+
private readonly storage;
|
|
83
102
|
constructor(options?: JsonOpenAICodexAuthStorageOptions);
|
|
103
|
+
get path(): string;
|
|
104
|
+
get providerId(): string;
|
|
84
105
|
get(): Promise<OpenAICodexOAuthCredentials | undefined>;
|
|
85
106
|
set(credentials: OpenAICodexOAuthCredentials): Promise<void>;
|
|
86
107
|
clear(): Promise<void>;
|
|
87
|
-
private readFile;
|
|
88
|
-
private writeFile;
|
|
89
108
|
}
|
|
90
|
-
type OpenAICodexOAuthClientOptions = {
|
|
109
|
+
export type OpenAICodexOAuthClientOptions = {
|
|
91
110
|
storage?: OpenAICodexAuthStorage;
|
|
92
111
|
refreshSkewMs?: number;
|
|
93
112
|
};
|
|
94
|
-
declare class OpenAICodexOAuthClient {
|
|
113
|
+
export declare class OpenAICodexOAuthClient {
|
|
95
114
|
readonly storage: OpenAICodexAuthStorage;
|
|
96
115
|
readonly refreshSkewMs: number;
|
|
97
116
|
constructor(options?: OpenAICodexOAuthClientOptions);
|
|
@@ -101,7 +120,7 @@ declare class OpenAICodexOAuthClient {
|
|
|
101
120
|
getHeaders(): Promise<Record<string, string> | undefined>;
|
|
102
121
|
logout(): Promise<void>;
|
|
103
122
|
}
|
|
104
|
-
declare const OPENAI_CODEX_API_KEY_ENV = "OPENAI_CODEX_API_KEY";
|
|
123
|
+
export declare const OPENAI_CODEX_API_KEY_ENV = "OPENAI_CODEX_API_KEY";
|
|
105
124
|
/**
|
|
106
125
|
* Resolve the OpenAI Codex API key the same way other provider API keys are
|
|
107
126
|
* resolved: prefer the OPENAI_CODEX_API_KEY environment variable, then fall
|
|
@@ -110,7 +129,6 @@ declare const OPENAI_CODEX_API_KEY_ENV = "OPENAI_CODEX_API_KEY";
|
|
|
110
129
|
* The result can be passed directly as `apiKey` to the runtime options or to
|
|
111
130
|
* `createOpenAICodex`. Returns undefined when no key is available.
|
|
112
131
|
*/
|
|
113
|
-
declare function getOpenAICodexApiKey(options?: OpenAICodexOAuthClientOptions): Promise<string | undefined>;
|
|
132
|
+
export declare function getOpenAICodexApiKey(options?: OpenAICodexOAuthClientOptions): Promise<string | undefined>;
|
|
114
133
|
//#endregion
|
|
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 };
|
|
116
134
|
//# sourceMappingURL=codex.d.mts.map
|
package/oauth/openai/codex.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { JsonOpenAICodexAuthStorage, OPENAI_CODEX_API_KEY_ENV, OpenAICodexOAuthClient, createOpenAICodexAuthorizationFlow, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, getOpenAICodexApiKey, openAICodexHeaders, parseOpenAICodexAuthorizationInput, refreshOpenAICodexToken };
|
|
1
|
+
import { a as createOpenAICodexDeviceAuth, c as getOpenAICodexApiKey, d as pollOpenAICodexDeviceAuth, f as refreshOpenAICodexToken, i as createOpenAICodexAuthorizationFlow, l as openAICodexHeaders, n as OPENAI_CODEX_API_KEY_ENV, o as exchangeOpenAICodexAuthorizationCode, r as OpenAICodexOAuthClient, s as getOpenAICodexAccountId, t as JsonOpenAICodexAuthStorage, u as parseOpenAICodexAuthorizationInput } from "../../codex-CLDBTrFm.mjs";
|
|
2
|
+
export { JsonOpenAICodexAuthStorage, OPENAI_CODEX_API_KEY_ENV, OpenAICodexOAuthClient, createOpenAICodexAuthorizationFlow, createOpenAICodexDeviceAuth, exchangeOpenAICodexAuthorizationCode, getOpenAICodexAccountId, getOpenAICodexApiKey, openAICodexHeaders, parseOpenAICodexAuthorizationInput, pollOpenAICodexDeviceAuth, refreshOpenAICodexToken };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region src/oauth/summary.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* One presentation and one rule set for every OAuth login, so a command behaves
|
|
4
|
+
* the same whichever CLI runs it.
|
|
5
|
+
*
|
|
6
|
+
* Credentials differ per provider; what a user is shown does not. Each provider
|
|
7
|
+
* narrows to an {@link OAuthSummary} — metadata only, never a token — and
|
|
8
|
+
* everything downstream works from that.
|
|
9
|
+
*
|
|
10
|
+
* Output convention: the summary is the command's result and belongs on stdout,
|
|
11
|
+
* alone, so `--json` stays parseable. Every notice here is progress, not result,
|
|
12
|
+
* and belongs on stderr.
|
|
13
|
+
*/
|
|
14
|
+
export type OAuthProviderId = "openai-codex" | "github-copilot";
|
|
15
|
+
export declare const OAUTH_PROVIDER_LABELS: Record<OAuthProviderId, string>;
|
|
16
|
+
export declare const oauthProviderLabel: (provider: OAuthProviderId) => string;
|
|
17
|
+
/** A stored login as the outside world sees it. */
|
|
18
|
+
export type OAuthSummary = {
|
|
19
|
+
readonly provider: OAuthProviderId;
|
|
20
|
+
/** Epoch millis, or 0 for a credential that does not expire. */
|
|
21
|
+
readonly expires: number;
|
|
22
|
+
readonly accountId?: string | undefined;
|
|
23
|
+
readonly apiEndpoint?: string | undefined;
|
|
24
|
+
readonly enterpriseUrl?: string | undefined;
|
|
25
|
+
readonly availableModels?: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
export declare const summarizeOpenAICodex: (credentials: {
|
|
28
|
+
readonly accountId: string;
|
|
29
|
+
readonly expires: number;
|
|
30
|
+
}) => OAuthSummary;
|
|
31
|
+
export declare const summarizeGitHubCopilot: (credentials: {
|
|
32
|
+
readonly expires: number;
|
|
33
|
+
readonly apiEndpoint?: string | undefined;
|
|
34
|
+
readonly enterpriseUrl?: string | undefined;
|
|
35
|
+
readonly availableModelIds?: ReadonlyArray<string> | undefined;
|
|
36
|
+
}) => OAuthSummary;
|
|
37
|
+
/** Render a summary. Tokens never appear in it. */
|
|
38
|
+
export declare function formatOAuthSummary(summary: OAuthSummary, options?: {
|
|
39
|
+
readonly json?: boolean | undefined;
|
|
40
|
+
}): string;
|
|
41
|
+
export type OAuthNoticeKind = "saved" | "cleared" | "refreshed" | "missing";
|
|
42
|
+
/** `location` is a bare place — a file path, or "the server". */
|
|
43
|
+
export declare function oauthNotice(kind: OAuthNoticeKind, provider: OAuthProviderId, location: string): string;
|
|
44
|
+
export type OAuthProviderFlags = {
|
|
45
|
+
readonly openaiCodex?: boolean | undefined;
|
|
46
|
+
readonly githubCopilot?: boolean | undefined;
|
|
47
|
+
};
|
|
48
|
+
export type OAuthFlagCheck = {
|
|
49
|
+
ok: true;
|
|
50
|
+
provider: OAuthProviderId;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
/** Resolve the provider from the two mutually exclusive flags. */
|
|
56
|
+
export declare function checkOAuthProvider(flags: OAuthProviderFlags): OAuthFlagCheck;
|
|
57
|
+
export type OAuthLoginFlags = {
|
|
58
|
+
readonly device?: boolean | undefined;
|
|
59
|
+
readonly enterprise?: string | undefined;
|
|
60
|
+
readonly enableModels?: boolean | undefined;
|
|
61
|
+
};
|
|
62
|
+
/** A login option the chosen provider has no use for, when one was given. */
|
|
63
|
+
export declare function oauthLoginIssue(provider: OAuthProviderId, flags: OAuthLoginFlags): string | undefined;
|
|
64
|
+
/** Why a provider cannot be refreshed, when it cannot. */
|
|
65
|
+
export declare function oauthRefreshIssue(provider: OAuthProviderId): string | undefined;
|
|
66
|
+
//#endregion
|
|
67
|
+
//# sourceMappingURL=summary.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as oauthNotice, c as summarizeGitHubCopilot, i as oauthLoginIssue, l as summarizeOpenAICodex, n as checkOAuthProvider, o as oauthProviderLabel, r as formatOAuthSummary, s as oauthRefreshIssue, t as OAUTH_PROVIDER_LABELS } from "../summary-C_QyCVWa.mjs";
|
|
2
|
+
export { OAUTH_PROVIDER_LABELS, checkOAuthProvider, formatOAuthSummary, oauthLoginIssue, oauthNotice, oauthProviderLabel, oauthRefreshIssue, summarizeGitHubCopilot, summarizeOpenAICodex };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { a as FailureSchema } from "./schema-rXSoWhic.mjs";
|
|
3
|
-
import { a as KnownProviderEnumSchema, o as ProviderInfo } from "./model-
|
|
4
|
-
import {
|
|
3
|
+
import { a as KnownProviderEnumSchema, o as ProviderInfo } from "./model-gCDbmGqT.mjs";
|
|
4
|
+
import { s as getOpenAICodexAccountId } from "./codex-CLDBTrFm.mjs";
|
|
5
5
|
import Type$1 from "typebox";
|
|
6
6
|
import { uuidv7 } from "uuidv7";
|
|
7
7
|
import { APICallError, LoadAPIKeyError, NoSuchModelError } from "@ai-sdk/provider";
|
|
@@ -1592,4 +1592,4 @@ const openaiCodex = createOpenAICodex();
|
|
|
1592
1592
|
//#endregion
|
|
1593
1593
|
export { ToolCallSchema as C, transformMessages as D, resolveJsonSchemaConstraint as E, AssistantMessageSchema as S, message_exports as T, appendOpenAICodexGrammarInputJsonDelta as _, OpenAICodexLanguageModel as a, resolveOpenAICodexDeferredToolsMode as b, convertOpenAICodexUsage as c, convertToOpenAICodexPrompt as d, joinToolCallId as f, shortHash as g, openAICodexErrorMessage as h, OPENAI_CODEX_DEFAULT_BASE_URL as i, mapOpenAICodexFinishReason as l, createOpenAICodexAPICallError as m, createOpenAICodex as n, clampOpenAICodexPromptCacheKey as o, splitToolCallId as p, openaiCodex as r, resolveOpenAICodexUrl as s, OPENAI_CODEX_API_KEY_ENV as t, collectOpenAICodexDeferredToolNames as u, openAICodexTools as v, createAssistantMessage as w, resolveOpenAICodexToolConstraint as x, prepareOpenAICodexTools as y };
|
|
1594
1594
|
|
|
1595
|
-
//# sourceMappingURL=openai-codex-
|
|
1595
|
+
//# sourceMappingURL=openai-codex-Bqzti6Mc.mjs.map
|