@alvin0/ai-agent-sdk-auth-node 0.1.1 → 0.1.2

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/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as shouldRefresh, E as fileCodexAuthStore, O as resolveCodexAuthPath, S as runDeviceCodeLogin, _ as readJwtClaims } from "./codex-CrzzZWDA.mjs";
1
+ import { C as runDeviceCodeLogin, D as fileCodexAuthStore, k as resolveCodexAuthPath, v as readJwtClaims, w as shouldRefresh } from "./codex-DKTYBDm3.mjs";
2
2
 
3
3
  //#region src/cli.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { i as withCredentialFileLock, n as readCredentialText, r as replaceCredentialText, t as credentialFileError } from "./credential-file-D6R3OOpe.mjs";
2
2
  import { defineCredentialStore } from "@alvin0/ai-agent-sdk-core/provider";
3
- import { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexRefreshError, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, codexAdapter, codexPlugin, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, runDeviceCodeLogin, shouldRefresh } from "@alvin0/ai-agent-sdk-provider-codex";
3
+ import { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexRefreshError, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, codexAdapter, codexPlugin, getCodexTokens, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, runDeviceCodeLogin, shouldRefresh } from "@alvin0/ai-agent-sdk-provider-codex";
4
4
  import { createHash } from "node:crypto";
5
5
  import { isAbsolute, resolve } from "node:path";
6
6
 
@@ -122,5 +122,5 @@ const codexAdapter$1 = codexNodeAdapter;
122
122
  const codexPlugin$1 = codexNodePlugin;
123
123
 
124
124
  //#endregion
125
- export { shouldRefresh as C, fileCodexCredentialStore as D, fileCodexAuthStore as E, resolveCodexAuthPath as O, runDeviceCodeLogin as S, DEFAULT_CODEX_AUTH_PATH as T, readJwtClaims as _, CODEX_ORIGINATOR as a, requireTokens as b, LAST_REFRESH_MAX_AGE_MS as c, codexNodePlugin as d, codexNodeProviderPlugin as f, memoryCodexCredentialStore as g, memoryCodexAuthStore as h, CODEX_CLIENT_VERSION as i, codexAdapter$1 as l, isFedrampAccount as m, CODEX_BASE_URL as n, CodexRefreshError as o, codexPlugin$1 as p, CODEX_CLIENT_ID as r, DEFAULT_CODEX_ISSUER as s, ACCESS_TOKEN_REFRESH_WINDOW_MS as t, codexNodeAdapter as u, refreshCodexTokens as v, CODEX_AUTH_PATH_ENV as w, resolveAccountId as x, requestDeviceCode as y };
126
- //# sourceMappingURL=codex-CrzzZWDA.mjs.map
125
+ export { runDeviceCodeLogin as C, fileCodexAuthStore as D, DEFAULT_CODEX_AUTH_PATH as E, fileCodexCredentialStore as O, resolveAccountId as S, CODEX_AUTH_PATH_ENV as T, memoryCodexCredentialStore as _, CODEX_ORIGINATOR as a, requestDeviceCode as b, LAST_REFRESH_MAX_AGE_MS as c, codexNodePlugin as d, codexNodeProviderPlugin as f, memoryCodexAuthStore as g, isFedrampAccount as h, CODEX_CLIENT_VERSION as i, resolveCodexAuthPath as k, codexAdapter$1 as l, getCodexTokens as m, CODEX_BASE_URL as n, CodexRefreshError as o, codexPlugin$1 as p, CODEX_CLIENT_ID as r, DEFAULT_CODEX_ISSUER as s, ACCESS_TOKEN_REFRESH_WINDOW_MS as t, codexNodeAdapter as u, readJwtClaims as v, shouldRefresh as w, requireTokens as x, refreshCodexTokens as y };
126
+ //# sourceMappingURL=codex-DKTYBDm3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-CrzzZWDA.mjs","names":["universalCodexAdapter","universalCodexPlugin","codexAdapter","codexPlugin"],"sources":["../src/codex-store.ts","../src/codex.ts"],"sourcesContent":["/** Symlink-safe, atomic Node filesystem store for Codex OAuth credentials. */\n\nimport { createHash } from 'node:crypto'\nimport { isAbsolute, resolve } from 'node:path'\nimport { defineCredentialStore } from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n CodexAuthFile,\n CodexAuthStore,\n CodexCredentialStore,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nimport {\n credentialFileError,\n readCredentialText,\n replaceCredentialText,\n withCredentialFileLock,\n} from './common/credential-file.ts'\n\nexport const DEFAULT_CODEX_AUTH_PATH = '.providers/.codex/auth.json'\nexport const CODEX_AUTH_PATH_ENV = 'AI_AGENT_SDK_CODEX_AUTH'\n\nexport interface CodexAuthPathOptions {\n /** Base for relative paths. Defaults to `process.cwd()`. */\n readonly cwd?: string\n /** Environment source. Defaults to `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>>\n}\n\nexport function resolveCodexAuthPath(\n explicitPath?: string,\n options: CodexAuthPathOptions = {},\n): string {\n const env = options.env ?? process.env\n const selected = nonEmptyPath(explicitPath)\n ?? nonEmptyPath(env[CODEX_AUTH_PATH_ENV])\n ?? DEFAULT_CODEX_AUTH_PATH\n const cwd = resolve(options.cwd ?? process.cwd())\n return isAbsolute(selected) ? resolve(selected) : resolve(cwd, selected)\n}\n\n/** @deprecated Use the revisioned {@link fileCodexCredentialStore}. */\nexport function fileCodexAuthStore(\n path?: string,\n options: CodexAuthPathOptions = {},\n): CodexAuthStore {\n const location = resolveCodexAuthPath(path, options)\n return {\n location,\n async read(): Promise<CodexAuthFile | undefined> {\n return (await readAuthFile(location))?.file\n },\n async write(file: CodexAuthFile): Promise<void> {\n const payload = authPayload(file)\n await withCredentialFileLock(location, undefined, async () => {\n await replaceCredentialText(location, payload)\n })\n },\n }\n}\n\n/** Revisioned compare-and-swap store used by normal Node provider composition. */\nexport function fileCodexCredentialStore(\n path?: string,\n options: CodexAuthPathOptions = {},\n): CodexCredentialStore {\n const location = resolveCodexAuthPath(path, options)\n return defineCredentialStore<CodexAuthFile>({\n id: 'codex-file-credentials',\n label: 'Codex file credential store',\n async read({ signal }) {\n const snapshot = await readAuthFile(location, signal)\n return snapshot === undefined ? undefined : Object.freeze({\n value: snapshot.file,\n revision: revisionOf(snapshot.raw),\n })\n },\n async commit(input, { signal }) {\n validateExpectedRevision(input.expectedRevision)\n const payload = authPayload(input.value)\n return await withCredentialFileLock(location, signal, async () => {\n const current = await readAuthFile(location, signal)\n const actual = current === undefined ? null : revisionOf(current.raw)\n if (actual !== input.expectedRevision) {\n throw credentialFileError(\n 'Codex credential revision changed before commit',\n undefined,\n 'CODEX_CREDENTIAL_REVISION_CONFLICT',\n )\n }\n await replaceCredentialText(location, payload, signal)\n return Object.freeze({ revision: revisionOf(payload) })\n })\n },\n })\n}\n\nfunction nonEmptyPath(value: string | undefined): string | undefined {\n if (value === undefined || value.trim().length === 0) return undefined\n if (value.includes('\\0')) throw new TypeError('Codex credential path must not contain NUL')\n return value\n}\n\nasync function readAuthFile(\n location: string,\n signal?: AbortSignal,\n): Promise<{ readonly file: CodexAuthFile; readonly raw: string } | undefined> {\n const raw = await readCredentialText(location, signal)\n if (raw === undefined) return undefined\n try {\n return Object.freeze({ file: JSON.parse(raw) as CodexAuthFile, raw })\n } catch (error: unknown) {\n throw credentialFileError(\n 'Codex credential file is not valid JSON; delete it and log in again',\n error,\n )\n }\n}\n\nfunction authPayload(file: CodexAuthFile): string {\n try {\n const encoded = JSON.stringify(file, null, 2)\n if (encoded === undefined) throw new TypeError('credential value is not JSON')\n return `${encoded}\\n`\n } catch (error: unknown) {\n throw credentialFileError('Codex credential value could not be serialized', error)\n }\n}\n\nfunction revisionOf(raw: string): string {\n return createHash('sha256').update(raw, 'utf8').digest('hex')\n}\n\nfunction validateExpectedRevision(value: string | null): void {\n if (value !== null && (typeof value !== 'string' || value.length === 0 || value.length > 256)) {\n throw credentialFileError('Codex expected credential revision is invalid')\n }\n}\n","/** Node wrapper over the injected-store Universal Codex provider. */\n\nimport type {\n ComposableModelProviderPlugin,\n ModelProviderPlugin,\n ModelProviderRegistrar,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n CODEX_BASE_URL,\n CODEX_CLIENT_VERSION,\n CODEX_ORIGINATOR,\n codexAdapter as universalCodexAdapter,\n codexPlugin as universalCodexPlugin,\n type CodexAdapterOptions as UniversalCodexAdapterOptions,\n type CodexAuthStore,\n type CodexCredentialStore,\n type CodexProviderOptions,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nimport { fileCodexAuthStore, fileCodexCredentialStore } from './codex-store.ts'\n\nexport { CODEX_BASE_URL, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR }\n\nexport interface CodexNodeAdapterOptions extends Omit<UniversalCodexAdapterOptions, 'authStore'> {\n /** Omit only in the Node compatibility wrapper to use the project-local file store. */\n readonly authStore?: CodexAuthStore\n}\n\nexport interface CodexNodePluginOptions extends CodexNodeAdapterOptions {\n readonly routes?: readonly string[]\n}\n\n/** @deprecated Use {@link codexNodeProviderPlugin} for normal runtime composition. */\nexport function codexNodeAdapter(\n options: CodexNodeAdapterOptions = {},\n): ReturnType<typeof universalCodexAdapter> {\n return universalCodexAdapter({\n ...options,\n authStore: options.authStore ?? fileCodexAuthStore(),\n })\n}\n\n/** @deprecated Use {@link codexNodeProviderPlugin}. */\nexport function codexNodePlugin(options: CodexNodePluginOptions = {}): ModelProviderPlugin {\n const routes = Object.freeze([...(options.routes ?? ['codex'])])\n const adapter = codexNodeAdapter(options)\n return Object.freeze({\n id: 'codex', displayName: 'Codex',\n setup: (registrar: ModelProviderRegistrar) => { registrar.registerAdapter(routes, adapter) },\n })\n}\n\nexport interface CodexNodeProviderOptions extends Omit<CodexProviderOptions, 'authStore'> {\n readonly authStore?: CodexCredentialStore\n}\n\n/** Preferred Node composition plugin backed by revision-safe file credentials by default. */\nexport function codexNodeProviderPlugin(\n options: CodexNodeProviderOptions = {},\n): ComposableModelProviderPlugin & { readonly family: 'codex' } {\n return universalCodexPlugin({\n ...options,\n authStore: options.authStore ?? fileCodexCredentialStore(),\n })\n}\n\n/** Compatibility alias for the former `ai-agent-sdk/codex` entry. */\nexport const codexAdapter = codexNodeAdapter\n/** Compatibility alias for the former `ai-agent-sdk/codex` entry. */\nexport const codexPlugin = codexNodePlugin\nexport type CodexAdapterOptions = CodexNodeAdapterOptions\nexport type CodexPluginOptions = CodexNodePluginOptions\n\nexport {\n ACCESS_TOKEN_REFRESH_WINDOW_MS,\n CODEX_CLIENT_ID,\n CodexRefreshError,\n DEFAULT_CODEX_ISSUER,\n LAST_REFRESH_MAX_AGE_MS,\n isFedrampAccount,\n memoryCodexAuthStore,\n memoryCodexCredentialStore,\n readJwtClaims,\n refreshCodexTokens,\n requestDeviceCode,\n requireTokens,\n resolveAccountId,\n runDeviceCodeLogin,\n shouldRefresh,\n type CodexAuthFile,\n type CodexAuthStore,\n type CodexCredentialStore,\n type CodexDeviceCode,\n type CodexJwtClaims,\n type CodexLoginProgress,\n type CodexLoginResult,\n type CodexOAuthOptions,\n type CodexTokens,\n type RefreshFailureKind,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nexport {\n CODEX_AUTH_PATH_ENV,\n DEFAULT_CODEX_AUTH_PATH,\n fileCodexAuthStore,\n fileCodexCredentialStore,\n resolveCodexAuthPath,\n type CodexAuthPathOptions,\n} from './codex-store.ts'\n"],"mappings":";;;;;;;;AAiBA,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AASnC,SAAgB,qBACd,cACA,UAAgC,CAAC,GACzB;CACR,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,WAAW,aAAa,YAAY,KACrC,aAAa,8BAAwB;CAE1C,MAAM,MAAM,QAAQ,QAAQ,OAAO,QAAQ,IAAI,CAAC;CAChD,OAAO,WAAW,QAAQ,IAAI,QA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qB;EAC1B,GAAG;EACH,WAAW,QAAQ,aAAa,yBAAyB;CAC3D,CAAC;AACH;;AAGA,MAAaC,iBAAe;;AAE5B,MAAaC,gBAAc"}
1
+ {"version":3,"file":"codex-DKTYBDm3.mjs","names":["universalCodexAdapter","universalCodexPlugin","codexAdapter","codexPlugin"],"sources":["../src/codex-store.ts","../src/codex.ts"],"sourcesContent":["/** Symlink-safe, atomic Node filesystem store for Codex OAuth credentials. */\n\nimport { createHash } from 'node:crypto'\nimport { isAbsolute, resolve } from 'node:path'\nimport { defineCredentialStore } from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n CodexAuthFile,\n CodexAuthStore,\n CodexCredentialStore,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nimport {\n credentialFileError,\n readCredentialText,\n replaceCredentialText,\n withCredentialFileLock,\n} from './common/credential-file.ts'\n\nexport const DEFAULT_CODEX_AUTH_PATH = '.providers/.codex/auth.json'\nexport const CODEX_AUTH_PATH_ENV = 'AI_AGENT_SDK_CODEX_AUTH'\n\nexport interface CodexAuthPathOptions {\n /** Base for relative paths. Defaults to `process.cwd()`. */\n readonly cwd?: string\n /** Environment source. Defaults to `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>>\n}\n\nexport function resolveCodexAuthPath(\n explicitPath?: string,\n options: CodexAuthPathOptions = {},\n): string {\n const env = options.env ?? process.env\n const selected = nonEmptyPath(explicitPath)\n ?? nonEmptyPath(env[CODEX_AUTH_PATH_ENV])\n ?? DEFAULT_CODEX_AUTH_PATH\n const cwd = resolve(options.cwd ?? process.cwd())\n return isAbsolute(selected) ? resolve(selected) : resolve(cwd, selected)\n}\n\n/** @deprecated Use the revisioned {@link fileCodexCredentialStore}. */\nexport function fileCodexAuthStore(\n path?: string,\n options: CodexAuthPathOptions = {},\n): CodexAuthStore {\n const location = resolveCodexAuthPath(path, options)\n return {\n location,\n async read(): Promise<CodexAuthFile | undefined> {\n return (await readAuthFile(location))?.file\n },\n async write(file: CodexAuthFile): Promise<void> {\n const payload = authPayload(file)\n await withCredentialFileLock(location, undefined, async () => {\n await replaceCredentialText(location, payload)\n })\n },\n }\n}\n\n/** Revisioned compare-and-swap store used by normal Node provider composition. */\nexport function fileCodexCredentialStore(\n path?: string,\n options: CodexAuthPathOptions = {},\n): CodexCredentialStore {\n const location = resolveCodexAuthPath(path, options)\n return defineCredentialStore<CodexAuthFile>({\n id: 'codex-file-credentials',\n label: 'Codex file credential store',\n async read({ signal }) {\n const snapshot = await readAuthFile(location, signal)\n return snapshot === undefined ? undefined : Object.freeze({\n value: snapshot.file,\n revision: revisionOf(snapshot.raw),\n })\n },\n async commit(input, { signal }) {\n validateExpectedRevision(input.expectedRevision)\n const payload = authPayload(input.value)\n return await withCredentialFileLock(location, signal, async () => {\n const current = await readAuthFile(location, signal)\n const actual = current === undefined ? null : revisionOf(current.raw)\n if (actual !== input.expectedRevision) {\n throw credentialFileError(\n 'Codex credential revision changed before commit',\n undefined,\n 'CODEX_CREDENTIAL_REVISION_CONFLICT',\n )\n }\n await replaceCredentialText(location, payload, signal)\n return Object.freeze({ revision: revisionOf(payload) })\n })\n },\n })\n}\n\nfunction nonEmptyPath(value: string | undefined): string | undefined {\n if (value === undefined || value.trim().length === 0) return undefined\n if (value.includes('\\0')) throw new TypeError('Codex credential path must not contain NUL')\n return value\n}\n\nasync function readAuthFile(\n location: string,\n signal?: AbortSignal,\n): Promise<{ readonly file: CodexAuthFile; readonly raw: string } | undefined> {\n const raw = await readCredentialText(location, signal)\n if (raw === undefined) return undefined\n try {\n return Object.freeze({ file: JSON.parse(raw) as CodexAuthFile, raw })\n } catch (error: unknown) {\n throw credentialFileError(\n 'Codex credential file is not valid JSON; delete it and log in again',\n error,\n )\n }\n}\n\nfunction authPayload(file: CodexAuthFile): string {\n try {\n const encoded = JSON.stringify(file, null, 2)\n if (encoded === undefined) throw new TypeError('credential value is not JSON')\n return `${encoded}\\n`\n } catch (error: unknown) {\n throw credentialFileError('Codex credential value could not be serialized', error)\n }\n}\n\nfunction revisionOf(raw: string): string {\n return createHash('sha256').update(raw, 'utf8').digest('hex')\n}\n\nfunction validateExpectedRevision(value: string | null): void {\n if (value !== null && (typeof value !== 'string' || value.length === 0 || value.length > 256)) {\n throw credentialFileError('Codex expected credential revision is invalid')\n }\n}\n","/** Node wrapper over the injected-store Universal Codex provider. */\n\nimport type {\n ComposableModelProviderPlugin,\n ModelProviderPlugin,\n ModelProviderRegistrar,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n CODEX_BASE_URL,\n CODEX_CLIENT_VERSION,\n CODEX_ORIGINATOR,\n codexAdapter as universalCodexAdapter,\n codexPlugin as universalCodexPlugin,\n type CodexAdapterOptions as UniversalCodexAdapterOptions,\n type CodexAuthStore,\n type CodexCredentialStore,\n type CodexProviderOptions,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nimport { fileCodexAuthStore, fileCodexCredentialStore } from './codex-store.ts'\n\nexport { CODEX_BASE_URL, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR }\n\nexport interface CodexNodeAdapterOptions extends Omit<UniversalCodexAdapterOptions, 'authStore'> {\n /** Omit only in the Node compatibility wrapper to use the project-local file store. */\n readonly authStore?: CodexAuthStore\n}\n\nexport interface CodexNodePluginOptions extends CodexNodeAdapterOptions {\n readonly routes?: readonly string[]\n}\n\n/** @deprecated Use {@link codexNodeProviderPlugin} for normal runtime composition. */\nexport function codexNodeAdapter(\n options: CodexNodeAdapterOptions = {},\n): ReturnType<typeof universalCodexAdapter> {\n return universalCodexAdapter({\n ...options,\n authStore: options.authStore ?? fileCodexAuthStore(),\n })\n}\n\n/** @deprecated Use {@link codexNodeProviderPlugin}. */\nexport function codexNodePlugin(options: CodexNodePluginOptions = {}): ModelProviderPlugin {\n const routes = Object.freeze([...(options.routes ?? ['codex'])])\n const adapter = codexNodeAdapter(options)\n return Object.freeze({\n id: 'codex', displayName: 'Codex',\n setup: (registrar: ModelProviderRegistrar) => { registrar.registerAdapter(routes, adapter) },\n })\n}\n\nexport interface CodexNodeProviderOptions extends Omit<CodexProviderOptions, 'authStore'> {\n readonly authStore?: CodexCredentialStore\n}\n\n/** Preferred Node composition plugin backed by revision-safe file credentials by default. */\nexport function codexNodeProviderPlugin(\n options: CodexNodeProviderOptions = {},\n): ComposableModelProviderPlugin & { readonly family: 'codex' } {\n return universalCodexPlugin({\n ...options,\n authStore: options.authStore ?? fileCodexCredentialStore(),\n })\n}\n\n/** Compatibility alias for the former `ai-agent-sdk/codex` entry. */\nexport const codexAdapter = codexNodeAdapter\n/** Compatibility alias for the former `ai-agent-sdk/codex` entry. */\nexport const codexPlugin = codexNodePlugin\nexport type CodexAdapterOptions = CodexNodeAdapterOptions\nexport type CodexPluginOptions = CodexNodePluginOptions\n\nexport {\n ACCESS_TOKEN_REFRESH_WINDOW_MS,\n CODEX_CLIENT_ID,\n CodexRefreshError,\n DEFAULT_CODEX_ISSUER,\n LAST_REFRESH_MAX_AGE_MS,\n isFedrampAccount,\n memoryCodexAuthStore,\n memoryCodexCredentialStore,\n readJwtClaims,\n refreshCodexTokens,\n getCodexTokens,\n type GetCodexTokensOptions,\n requestDeviceCode,\n requireTokens,\n resolveAccountId,\n runDeviceCodeLogin,\n shouldRefresh,\n type CodexAuthFile,\n type CodexAuthStore,\n type CodexCredentialStore,\n type CodexDeviceCode,\n type CodexJwtClaims,\n type CodexLoginProgress,\n type CodexLoginResult,\n type CodexOAuthOptions,\n type CodexTokens,\n type RefreshFailureKind,\n} from '@alvin0/ai-agent-sdk-provider-codex'\nexport {\n CODEX_AUTH_PATH_ENV,\n DEFAULT_CODEX_AUTH_PATH,\n fileCodexAuthStore,\n fileCodexCredentialStore,\n resolveCodexAuthPath,\n type CodexAuthPathOptions,\n} from './codex-store.ts'\n"],"mappings":";;;;;;;;AAiBA,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AASnC,SAAgB,qBACd,cACA,UAAgC,CAAC,GACzB;CACR,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,WAAW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Q,cAAsC;GAAE,UAAU,gBAAgB,QAAQ,OAAO;EAAE;CAC7F,CAAC;AACH;;AAOA,SAAgB,wBACd,UAAoC,CAAC,GACyB;CAC9D,OAAOC,YAAqB;EAC1B,GAAG;EACH,WAAW,QAAQ,aAAa,yBAAyB;CAC3D,CAAC;AACH;;AAGA,MAAaC,iBAAe;;AAE5B,MAAaC,gBAAc"}
package/dist/codex.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ComposableModelProviderPlugin, ModelProviderPlugin } from "@alvin0/ai-agent-sdk-core/provider";
2
- import { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexAdapterOptions as CodexAdapterOptions$1, CodexAuthFile, CodexAuthStore, CodexAuthStore as CodexAuthStore$1, CodexCredentialStore, CodexCredentialStore as CodexCredentialStore$1, CodexDeviceCode, CodexJwtClaims, CodexLoginProgress, CodexLoginResult, CodexOAuthOptions, CodexProviderOptions, CodexRefreshError, CodexTokens, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, RefreshFailureKind, codexAdapter as codexAdapter$1, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, runDeviceCodeLogin, shouldRefresh } from "@alvin0/ai-agent-sdk-provider-codex";
2
+ import { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexAdapterOptions as CodexAdapterOptions$1, CodexAuthFile, CodexAuthStore, CodexAuthStore as CodexAuthStore$1, CodexCredentialStore, CodexCredentialStore as CodexCredentialStore$1, CodexDeviceCode, CodexJwtClaims, CodexLoginProgress, CodexLoginResult, CodexOAuthOptions, CodexProviderOptions, CodexRefreshError, CodexTokens, DEFAULT_CODEX_ISSUER, GetCodexTokensOptions, LAST_REFRESH_MAX_AGE_MS, RefreshFailureKind, codexAdapter as codexAdapter$1, getCodexTokens, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, runDeviceCodeLogin, shouldRefresh } from "@alvin0/ai-agent-sdk-provider-codex";
3
3
  //#region src/codex-store.d.ts
4
4
  declare const DEFAULT_CODEX_AUTH_PATH = ".providers/.codex/auth.json";
5
5
  declare const CODEX_AUTH_PATH_ENV = "AI_AGENT_SDK_CODEX_AUTH";
@@ -41,5 +41,5 @@ declare const codexPlugin: typeof codexNodePlugin;
41
41
  type CodexAdapterOptions = CodexNodeAdapterOptions;
42
42
  type CodexPluginOptions = CodexNodePluginOptions;
43
43
  //#endregion
44
- export { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_AUTH_PATH_ENV, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexAdapterOptions, type CodexAuthFile, type CodexAuthPathOptions, type CodexAuthStore, type CodexCredentialStore, type CodexDeviceCode, type CodexJwtClaims, type CodexLoginProgress, type CodexLoginResult, CodexNodeAdapterOptions, CodexNodePluginOptions, CodexNodeProviderOptions, type CodexOAuthOptions, CodexPluginOptions, CodexRefreshError, type CodexTokens, DEFAULT_CODEX_AUTH_PATH, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, type RefreshFailureKind, codexAdapter, codexNodeAdapter, codexNodePlugin, codexNodeProviderPlugin, codexPlugin, fileCodexAuthStore, fileCodexCredentialStore, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, resolveCodexAuthPath, runDeviceCodeLogin, shouldRefresh };
44
+ export { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_AUTH_PATH_ENV, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexAdapterOptions, type CodexAuthFile, type CodexAuthPathOptions, type CodexAuthStore, type CodexCredentialStore, type CodexDeviceCode, type CodexJwtClaims, type CodexLoginProgress, type CodexLoginResult, CodexNodeAdapterOptions, CodexNodePluginOptions, CodexNodeProviderOptions, type CodexOAuthOptions, CodexPluginOptions, CodexRefreshError, type CodexTokens, DEFAULT_CODEX_AUTH_PATH, DEFAULT_CODEX_ISSUER, type GetCodexTokensOptions, LAST_REFRESH_MAX_AGE_MS, type RefreshFailureKind, codexAdapter, codexNodeAdapter, codexNodePlugin, codexNodeProviderPlugin, codexPlugin, fileCodexAuthStore, fileCodexCredentialStore, getCodexTokens, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, resolveCodexAuthPath, runDeviceCodeLogin, shouldRefresh };
45
45
  //# sourceMappingURL=codex.d.mts.map
package/dist/codex.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { C as shouldRefresh, D as fileCodexCredentialStore, E as fileCodexAuthStore, O as resolveCodexAuthPath, S as runDeviceCodeLogin, T as DEFAULT_CODEX_AUTH_PATH, _ as readJwtClaims, a as CODEX_ORIGINATOR, b as requireTokens, c as LAST_REFRESH_MAX_AGE_MS, d as codexNodePlugin, f as codexNodeProviderPlugin, g as memoryCodexCredentialStore, h as memoryCodexAuthStore, i as CODEX_CLIENT_VERSION, l as codexAdapter, m as isFedrampAccount, n as CODEX_BASE_URL, o as CodexRefreshError, p as codexPlugin, r as CODEX_CLIENT_ID, s as DEFAULT_CODEX_ISSUER, t as ACCESS_TOKEN_REFRESH_WINDOW_MS, u as codexNodeAdapter, v as refreshCodexTokens, w as CODEX_AUTH_PATH_ENV, x as resolveAccountId, y as requestDeviceCode } from "./codex-CrzzZWDA.mjs";
1
+ import { C as runDeviceCodeLogin, D as fileCodexAuthStore, E as DEFAULT_CODEX_AUTH_PATH, O as fileCodexCredentialStore, S as resolveAccountId, T as CODEX_AUTH_PATH_ENV, _ as memoryCodexCredentialStore, a as CODEX_ORIGINATOR, b as requestDeviceCode, c as LAST_REFRESH_MAX_AGE_MS, d as codexNodePlugin, f as codexNodeProviderPlugin, g as memoryCodexAuthStore, h as isFedrampAccount, i as CODEX_CLIENT_VERSION, k as resolveCodexAuthPath, l as codexAdapter, m as getCodexTokens, n as CODEX_BASE_URL, o as CodexRefreshError, p as codexPlugin, r as CODEX_CLIENT_ID, s as DEFAULT_CODEX_ISSUER, t as ACCESS_TOKEN_REFRESH_WINDOW_MS, u as codexNodeAdapter, v as readJwtClaims, w as shouldRefresh, x as requireTokens, y as refreshCodexTokens } from "./codex-DKTYBDm3.mjs";
2
2
 
3
- export { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_AUTH_PATH_ENV, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexRefreshError, DEFAULT_CODEX_AUTH_PATH, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, codexAdapter, codexNodeAdapter, codexNodePlugin, codexNodeProviderPlugin, codexPlugin, fileCodexAuthStore, fileCodexCredentialStore, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, resolveCodexAuthPath, runDeviceCodeLogin, shouldRefresh };
3
+ export { ACCESS_TOKEN_REFRESH_WINDOW_MS, CODEX_AUTH_PATH_ENV, CODEX_BASE_URL, CODEX_CLIENT_ID, CODEX_CLIENT_VERSION, CODEX_ORIGINATOR, CodexRefreshError, DEFAULT_CODEX_AUTH_PATH, DEFAULT_CODEX_ISSUER, LAST_REFRESH_MAX_AGE_MS, codexAdapter, codexNodeAdapter, codexNodePlugin, codexNodeProviderPlugin, codexPlugin, fileCodexAuthStore, fileCodexCredentialStore, getCodexTokens, isFedrampAccount, memoryCodexAuthStore, memoryCodexCredentialStore, readJwtClaims, refreshCodexTokens, requestDeviceCode, requireTokens, resolveAccountId, resolveCodexAuthPath, runDeviceCodeLogin, shouldRefresh };
@@ -2,7 +2,7 @@ import { i as withCredentialFileLock, n as readCredentialText, r as replaceCrede
2
2
  import { defineCredentialStore } from "@alvin0/ai-agent-sdk-core/provider";
3
3
  import { createHash } from "node:crypto";
4
4
  import { isAbsolute, resolve } from "node:path";
5
- import { COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, CopilotDeviceLoginError, CopilotTokenExchangeError, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotPlugin, copilotPlugin as copilotPlugin$1, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect } from "@alvin0/ai-agent-sdk-provider-copilot";
5
+ import { COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, CopilotDeviceLoginError, CopilotTokenExchangeError, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotPlugin, copilotPlugin as copilotPlugin$1, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, getCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect } from "@alvin0/ai-agent-sdk-provider-copilot";
6
6
 
7
7
  //#region src/copilot-store.ts
8
8
  /**
@@ -149,5 +149,5 @@ function copilotNodeProviderPlugin(options = {}) {
149
149
  }
150
150
 
151
151
  //#endregion
152
- export { fileCopilotCredentialStore as $, copilotAdapter as A, memoryCopilotAuthStore as B, COPILOT_TOKEN_EXCHANGE_MARGIN_MS as C, DEFAULT_COPILOT_OAUTH_ISSUER as D, CopilotTokenExchangeError as E, createCopilotEndpointRouter as F, resolveCopilotCatalogLimits as G, partitionCopilotCatalog as H, createCopilotTokenCache as I, toChatCompletionsDialect as J, runCopilotDeviceLogin as K, credentialFailure as L, copilotDualProtocol as M, copilotNodeProviderPlugin as N, DEFAULT_COPILOT_TIMER as O, copilotPlugin$1 as P, fileCopilotAuthStore as Q, discoverCopilotModels as R, COPILOT_SLOW_DOWN_INCREMENT_SECONDS as S, CopilotDeviceLoginError as T, requestCopilotDeviceCode as U, memoryCopilotCredentialStore as V, requireGitHubToken as W, COPILOT_AUTH_PATH_ENV as X, toResponsesDialect as Y, DEFAULT_COPILOT_AUTH_PATH as Z, COPILOT_OAUTH_CLIENT_ID as _, COPILOT_DEFAULT_MAX_CATALOG_BYTES as a, COPILOT_RESPONSES_MODEL_PREFIXES as b, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS as c, COPILOT_DISPLAY_NAME as d, resolveCopilotAuthPath as et, COPILOT_DUAL_PROTOCOL_ID as f, COPILOT_LOGIN_COMMAND as g, COPILOT_ERROR_CODES as h, COPILOT_DEFAULT_DIALECT as i, copilotCatalogCacheOptions as j, DEFAULT_GITHUB_API_BASE_URL as k, COPILOT_DEVICE_CODE_MAX_WAIT_MS as l, COPILOT_EDITOR_VERSION as m, COPILOT_CATALOG_PATH as n, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS as o, COPILOT_EDITOR_PLUGIN_VERSION as p, shouldExchange as q, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS as r, COPILOT_DEFAULT_MAX_CATALOG_MODELS as s, COPILOT_BASE_URL as t, COPILOT_DEVICE_LOGIN_WARNING as u, COPILOT_OAUTH_SCOPE as v, COPILOT_TOKEN_EXCHANGE_PATH as w, COPILOT_ROUTE_ID as x, COPILOT_PROVIDER_ID as y, exchangeCopilotToken as z };
153
- //# sourceMappingURL=copilot-LLMqtNSM.mjs.map
152
+ export { fileCopilotAuthStore as $, copilotAdapter as A, getCopilotToken as B, COPILOT_TOKEN_EXCHANGE_MARGIN_MS as C, DEFAULT_COPILOT_OAUTH_ISSUER as D, CopilotTokenExchangeError as E, createCopilotEndpointRouter as F, requireGitHubToken as G, memoryCopilotCredentialStore as H, createCopilotTokenCache as I, shouldExchange as J, resolveCopilotCatalogLimits as K, credentialFailure as L, copilotDualProtocol as M, copilotNodeProviderPlugin as N, DEFAULT_COPILOT_TIMER as O, copilotPlugin$1 as P, DEFAULT_COPILOT_AUTH_PATH as Q, discoverCopilotModels as R, COPILOT_SLOW_DOWN_INCREMENT_SECONDS as S, CopilotDeviceLoginError as T, partitionCopilotCatalog as U, memoryCopilotAuthStore as V, requestCopilotDeviceCode as W, toResponsesDialect as X, toChatCompletionsDialect as Y, COPILOT_AUTH_PATH_ENV as Z, COPILOT_OAUTH_CLIENT_ID as _, COPILOT_DEFAULT_MAX_CATALOG_BYTES as a, COPILOT_RESPONSES_MODEL_PREFIXES as b, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS as c, COPILOT_DISPLAY_NAME as d, fileCopilotCredentialStore as et, COPILOT_DUAL_PROTOCOL_ID as f, COPILOT_LOGIN_COMMAND as g, COPILOT_ERROR_CODES as h, COPILOT_DEFAULT_DIALECT as i, copilotCatalogCacheOptions as j, DEFAULT_GITHUB_API_BASE_URL as k, COPILOT_DEVICE_CODE_MAX_WAIT_MS as l, COPILOT_EDITOR_VERSION as m, COPILOT_CATALOG_PATH as n, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS as o, COPILOT_EDITOR_PLUGIN_VERSION as p, runCopilotDeviceLogin as q, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS as r, COPILOT_DEFAULT_MAX_CATALOG_MODELS as s, COPILOT_BASE_URL as t, resolveCopilotAuthPath as tt, COPILOT_DEVICE_LOGIN_WARNING as u, COPILOT_OAUTH_SCOPE as v, COPILOT_TOKEN_EXCHANGE_PATH as w, COPILOT_ROUTE_ID as x, COPILOT_PROVIDER_ID as y, exchangeCopilotToken as z };
153
+ //# sourceMappingURL=copilot-C0bQCpbl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-LLMqtNSM.mjs","names":["universalCopilotPlugin"],"sources":["../src/copilot-store.ts","../src/copilot.ts"],"sourcesContent":["/**\n * Symlink-safe, atomic Node filesystem store for Copilot credentials.\n *\n * This is a deliberate mirror of `./codex-store.ts`: same path precedence, same\n * revisioned compare-and-swap shape, and the SAME shared helpers from\n * `./common/credential-file.ts` rather than a second copy of them. The two\n * providers persist structurally different documents, but the hazards of writing\n * a secret to a filesystem are identical, so the write path is shared and only\n * the document type differs.\n *\n * The default path `.providers/.copilot/auth.json` belongs to THIS SDK and sits\n * beside `.providers/.codex/auth.json`, separate from the credential location of\n * any editor client or vendor CLI (Requirement 6.7). The reason differs from\n * Codex: Codex MUST be separate because its refresh token rotates, so sharing the\n * file would sign the user out of their real CLI. Copilot has no rotation hazard\n * at all, and is still separate for the two remaining reasons — the SDK has no\n * business writing into another program's file, and a file the SDK owns is the\n * precondition for `--status` telling the truth about the SDK's own state.\n *\n * @module ai-agent-sdk/auth-node/copilot-store\n */\n\nimport { createHash } from 'node:crypto'\nimport { isAbsolute, resolve } from 'node:path'\nimport { defineCredentialStore } from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n CopilotAuthFile,\n CopilotAuthStore,\n CopilotCredentialStore,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nimport {\n credentialFileError,\n readCredentialText,\n replaceCredentialText,\n withCredentialFileLock,\n} from './common/credential-file.ts'\n\nexport const DEFAULT_COPILOT_AUTH_PATH = '.providers/.copilot/auth.json'\nexport const COPILOT_AUTH_PATH_ENV = 'AI_AGENT_SDK_COPILOT_AUTH'\n\n/**\n * The code a losing commit carries (Requirement 6.3).\n *\n * Spelled as a literal rather than read from `COPILOT_ERROR_CODES` on purpose:\n * `@alvin0/ai-agent-sdk-provider-copilot` is an OPTIONAL peer of this package, so\n * every other reference to it here is type-only. A value import would turn the\n * optional peer into a hard runtime requirement of this module.\n */\nconst COPILOT_REVISION_CONFLICT_CODE = 'COPILOT_CREDENTIAL_REVISION_CONFLICT'\n\nexport interface CopilotAuthPathOptions {\n /** Base for relative paths. Defaults to `process.cwd()`. */\n readonly cwd?: string\n /** Environment source. Defaults to `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>>\n}\n\n/**\n * Resolve the credential file path: `explicitPath` → environment → default.\n *\n * An empty or all-whitespace string counts as absent, so an unset shell variable\n * that expanded to `''` falls through to the next source instead of resolving to\n * the current directory (Requirement 6.5).\n * @param explicitPath - a caller-supplied path; highest precedence.\n * @param options - the `cwd` relative paths resolve against, and the environment source.\n * @returns an absolute path.\n * @throws TypeError when a supplied path contains a NUL character.\n */\nexport function resolveCopilotAuthPath(\n explicitPath?: string,\n options: CopilotAuthPathOptions = {},\n): string {\n const env = options.env ?? process.env\n const selected = nonEmptyPath(explicitPath)\n ?? nonEmptyPath(env[COPILOT_AUTH_PATH_ENV])\n ?? DEFAULT_COPILOT_AUTH_PATH\n const cwd = resolve(options.cwd ?? process.cwd())\n return isAbsolute(selected) ? resolve(selected) : resolve(cwd, selected)\n}\n\n/** @deprecated Use the revisioned {@link fileCopilotCredentialStore}. */\nexport function fileCopilotAuthStore(\n path?: string,\n options: CopilotAuthPathOptions = {},\n): CopilotAuthStore {\n const location = resolveCopilotAuthPath(path, options)\n return {\n location,\n async read(): Promise<CopilotAuthFile | undefined> {\n return (await readAuthFile(location))?.file\n },\n async write(file: CopilotAuthFile): Promise<void> {\n const payload = authPayload(file)\n await withCredentialFileLock(location, undefined, async () => {\n await replaceCredentialText(location, payload)\n })\n },\n }\n}\n\n/**\n * Revisioned compare-and-swap store used by normal Node provider composition.\n *\n * The revision is a sha256 of the RAW file bytes, so any change made by any\n * writer — this SDK or a hand edit — invalidates a revision a reader is holding.\n * The compare and the replace both happen inside `withCredentialFileLock`, which\n * is what makes exactly one of two concurrent commits win (Requirement 6.3).\n * @param path - an explicit credential path; otherwise resolved by precedence.\n * @param options - the `cwd` relative paths resolve against, and the environment source.\n * @returns a compare-and-swap store over one file.\n */\nexport function fileCopilotCredentialStore(\n path?: string,\n options: CopilotAuthPathOptions = {},\n): CopilotCredentialStore {\n const location = resolveCopilotAuthPath(path, options)\n return defineCredentialStore<CopilotAuthFile>({\n id: 'copilot-file-credentials',\n label: 'Copilot file credential store',\n async read({ signal }) {\n const snapshot = await readAuthFile(location, signal)\n return snapshot === undefined ? undefined : Object.freeze({\n value: snapshot.file,\n revision: revisionOf(snapshot.raw),\n })\n },\n async commit(input, { signal }) {\n validateExpectedRevision(input.expectedRevision)\n const payload = authPayload(input.value)\n return await withCredentialFileLock(location, signal, async () => {\n const current = await readAuthFile(location, signal)\n const actual = current === undefined ? null : revisionOf(current.raw)\n if (actual !== input.expectedRevision) {\n throw credentialFileError(\n 'Copilot credential revision changed before commit',\n undefined,\n COPILOT_REVISION_CONFLICT_CODE,\n )\n }\n await replaceCredentialText(location, payload, signal)\n return Object.freeze({ revision: revisionOf(payload) })\n })\n },\n })\n}\n\nfunction nonEmptyPath(value: string | undefined): string | undefined {\n if (value === undefined || value.trim().length === 0) return undefined\n if (value.includes('\\0')) throw new TypeError('Copilot credential path must not contain NUL')\n return value\n}\n\nasync function readAuthFile(\n location: string,\n signal?: AbortSignal,\n): Promise<{ readonly file: CopilotAuthFile; readonly raw: string } | undefined> {\n const raw = await readCredentialText(location, signal)\n if (raw === undefined) return undefined\n try {\n return Object.freeze({ file: JSON.parse(raw) as CopilotAuthFile, raw })\n } catch (error: unknown) {\n throw credentialFileError(\n 'Copilot credential file is not valid JSON; delete it and log in again',\n error,\n )\n }\n}\n\nfunction authPayload(file: CopilotAuthFile): string {\n try {\n const encoded = JSON.stringify(file, null, 2)\n if (encoded === undefined) throw new TypeError('credential value is not JSON')\n return `${encoded}\\n`\n } catch (error: unknown) {\n throw credentialFileError('Copilot credential value could not be serialized', error)\n }\n}\n\nfunction revisionOf(raw: string): string {\n return createHash('sha256').update(raw, 'utf8').digest('hex')\n}\n\nfunction validateExpectedRevision(value: string | null): void {\n if (value !== null && (typeof value !== 'string' || value.length === 0 || value.length > 256)) {\n throw credentialFileError('Copilot expected credential revision is invalid')\n }\n}\n","/**\n * Node wrapper over the injected-store Universal Copilot provider.\n *\n * A deliberate mirror of `./codex.ts` and just as thin: the ONLY thing this module\n * does is default `authStore` to the project-local file store, because paths, the\n * filesystem and the environment belong to this package and never to a Universal\n * one (Requirements 6.5, 18.2). Everything else here is a re-export of the\n * Universal surface so a Node caller needs one import specifier instead of two.\n *\n * Unlike `./codex.ts` there are no `@deprecated` compatibility aliases: Copilot\n * ships with no former entry point to stay compatible with.\n *\n * @module ai-agent-sdk/auth-node/copilot\n */\n\nimport type { ComposableModelProviderPlugin } from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n copilotPlugin as universalCopilotPlugin,\n type CopilotCredentialStore,\n type CopilotProviderOptions,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nimport { fileCopilotCredentialStore } from './copilot-store.ts'\n\nexport interface CopilotNodeProviderOptions extends Omit<CopilotProviderOptions, 'authStore'> {\n /** Omit to use the project-local file credential store. */\n readonly authStore?: CopilotCredentialStore\n}\n\n/** Preferred Node composition plugin backed by revision-safe file credentials by default. */\nexport function copilotNodeProviderPlugin(\n options: CopilotNodeProviderOptions = {},\n): ComposableModelProviderPlugin & { readonly family: 'copilot' } {\n return universalCopilotPlugin({\n ...options,\n authStore: options.authStore ?? fileCopilotCredentialStore(),\n })\n}\n\nexport {\n COPILOT_BASE_URL,\n COPILOT_CATALOG_PATH,\n COPILOT_DEFAULT_CATALOG_TIMEOUT_MS,\n COPILOT_DEFAULT_DIALECT,\n COPILOT_DEFAULT_MAX_CATALOG_BYTES,\n COPILOT_DEFAULT_MAX_CATALOG_CHUNKS,\n COPILOT_DEFAULT_MAX_CATALOG_MODELS,\n COPILOT_DEFAULT_POLL_INTERVAL_SECONDS,\n COPILOT_DEVICE_CODE_MAX_WAIT_MS,\n COPILOT_DEVICE_LOGIN_WARNING,\n COPILOT_DISPLAY_NAME,\n COPILOT_DUAL_PROTOCOL_ID,\n COPILOT_EDITOR_PLUGIN_VERSION,\n COPILOT_EDITOR_VERSION,\n COPILOT_ERROR_CODES,\n COPILOT_LOGIN_COMMAND,\n COPILOT_OAUTH_CLIENT_ID,\n COPILOT_OAUTH_SCOPE,\n COPILOT_PROVIDER_ID,\n COPILOT_RESPONSES_MODEL_PREFIXES,\n COPILOT_ROUTE_ID,\n COPILOT_SLOW_DOWN_INCREMENT_SECONDS,\n COPILOT_TOKEN_EXCHANGE_MARGIN_MS,\n COPILOT_TOKEN_EXCHANGE_PATH,\n CopilotDeviceLoginError,\n CopilotTokenExchangeError,\n DEFAULT_COPILOT_OAUTH_ISSUER,\n DEFAULT_COPILOT_TIMER,\n DEFAULT_GITHUB_API_BASE_URL,\n copilotAdapter,\n copilotCatalogCacheOptions,\n copilotDualProtocol,\n copilotPlugin,\n createCopilotEndpointRouter,\n createCopilotTokenCache,\n credentialFailure,\n discoverCopilotModels,\n exchangeCopilotToken,\n memoryCopilotAuthStore,\n memoryCopilotCredentialStore,\n partitionCopilotCatalog,\n requestCopilotDeviceCode,\n requireGitHubToken,\n resolveCopilotCatalogLimits,\n runCopilotDeviceLogin,\n shouldExchange,\n toChatCompletionsDialect,\n toResponsesDialect,\n type ChatCompletionsProtocolLike,\n type CopilotAccountIdentity,\n type CopilotApiToken,\n type CopilotAuthFile,\n type CopilotAuthStore,\n type CopilotCatalogLimits,\n type CopilotCatalogOptions,\n type CopilotCatalogSnapshot,\n type CopilotCredentialFailure,\n type CopilotCredentialSnapshot,\n type CopilotCredentialStore,\n type CopilotDeviceCode,\n type CopilotDeviceLoginReason,\n type CopilotDialect,\n type CopilotDualProtocolOptions,\n type CopilotEditorHeaders,\n type CopilotEmbeddingModel,\n type CopilotEndpoint,\n type CopilotEndpointDecision,\n type CopilotEndpointRouter,\n type CopilotEndpointRouterOptions,\n type CopilotErrorCode,\n type CopilotExchangeOptions,\n type CopilotGenerationModel,\n type CopilotGitHubToken,\n type CopilotLegacyProviderOptions,\n type CopilotLoginProgress,\n type CopilotLoginResult,\n type CopilotOAuthOptions,\n type CopilotOmitReason,\n type CopilotOmittedModel,\n type CopilotPluginOptions,\n type CopilotProviderOptions,\n type CopilotSubProtocol,\n type CopilotTimer,\n type CopilotTokenCache,\n type CopilotTokenCacheEntry,\n type CopilotTokenCacheOptions,\n type CopilotTokenExchangeFailureKind,\n type CopilotTokenExpiry,\n type ResponsesProtocolLike,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nexport {\n COPILOT_AUTH_PATH_ENV,\n DEFAULT_COPILOT_AUTH_PATH,\n fileCopilotAuthStore,\n fileCopilotCredentialStore,\n resolveCopilotAuthPath,\n type CopilotAuthPathOptions,\n} from './copilot-store.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;AAUrC,MAAM,iCAAiC;;;;;;;;;;;;AAoBvC,SAAgB,uBACd,cACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,WAAW,aAAa,YAAY,KACrC,aAAa,gCAA0B;CAE5C,MAAM,MAAM,QAAQ,QAAQ,OAAO,QAAQ,IAAI,CAAC;CAChD,OAAO,WAAW,QAAQ,IAAI,QAAQ,QAAQ,IAAI,QAAQ,KAAK,QAAQ;AACzE;;AAGA,SAAgB,qBACd,MACA,UAAkC,CAAC,GACjB;CAClB,MAAM,WAAW,uBAAuB,MAAM,OAAO;CACrD,OAAO;EACL;EACA,MAAM,OAA6C;GACjD,QAAQ,MAAM,aAAa,QAAQ,EAAC,EAAG;EACzC;EACA,MAAM,MAAM,MAAsC;GAChD,MAAM,UAAU,YAAY,IAAI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M,oBACJ,yEACA,KACF;CACF;AACF;AAEA,SAAS,YAAY,MAA+B;CAClD,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,MAAM,MAAM,CAAC;EAC5C,IAAI,YAAY,QAAW,MAAM,IAAI,UAAU,8BAA8B;EAC7E,OAAO,GAAG,QAAQ;CACpB,SAAS,OAAgB;EACvB,MAAM,oBAAoB,oDAAoD,KAAK;CACrF;AACF;AAEA,SAAS,WAAW,KAAqB;CACvC,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,OAAO,KAAK;AAC9D;AAEA,SAAS,yBAAyB,OAA4B;CAC5D,IAAI,UAAU,SAAS,OAAO,UAAU,YAAY,MAAM,WAAW,KAAK,MAAM,SAAS,MACvF,MAAM,oBAAoB,iDAAiD;AAE/E;;;;;AC7JA,SAAgB,0BACd,UAAsC,CAAC,GACyB;CAChE,OAAOA,cAAuB;EAC5B,GAAG;EACH,WAAW,QAAQ,aAAa,2BAA2B;CAC7D,CAAC;AACH"}
1
+ {"version":3,"file":"copilot-C0bQCpbl.mjs","names":["universalCopilotPlugin"],"sources":["../src/copilot-store.ts","../src/copilot.ts"],"sourcesContent":["/**\n * Symlink-safe, atomic Node filesystem store for Copilot credentials.\n *\n * This is a deliberate mirror of `./codex-store.ts`: same path precedence, same\n * revisioned compare-and-swap shape, and the SAME shared helpers from\n * `./common/credential-file.ts` rather than a second copy of them. The two\n * providers persist structurally different documents, but the hazards of writing\n * a secret to a filesystem are identical, so the write path is shared and only\n * the document type differs.\n *\n * The default path `.providers/.copilot/auth.json` belongs to THIS SDK and sits\n * beside `.providers/.codex/auth.json`, separate from the credential location of\n * any editor client or vendor CLI (Requirement 6.7). The reason differs from\n * Codex: Codex MUST be separate because its refresh token rotates, so sharing the\n * file would sign the user out of their real CLI. Copilot has no rotation hazard\n * at all, and is still separate for the two remaining reasons — the SDK has no\n * business writing into another program's file, and a file the SDK owns is the\n * precondition for `--status` telling the truth about the SDK's own state.\n *\n * @module ai-agent-sdk/auth-node/copilot-store\n */\n\nimport { createHash } from 'node:crypto'\nimport { isAbsolute, resolve } from 'node:path'\nimport { defineCredentialStore } from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n CopilotAuthFile,\n CopilotAuthStore,\n CopilotCredentialStore,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nimport {\n credentialFileError,\n readCredentialText,\n replaceCredentialText,\n withCredentialFileLock,\n} from './common/credential-file.ts'\n\nexport const DEFAULT_COPILOT_AUTH_PATH = '.providers/.copilot/auth.json'\nexport const COPILOT_AUTH_PATH_ENV = 'AI_AGENT_SDK_COPILOT_AUTH'\n\n/**\n * The code a losing commit carries (Requirement 6.3).\n *\n * Spelled as a literal rather than read from `COPILOT_ERROR_CODES` on purpose:\n * `@alvin0/ai-agent-sdk-provider-copilot` is an OPTIONAL peer of this package, so\n * every other reference to it here is type-only. A value import would turn the\n * optional peer into a hard runtime requirement of this module.\n */\nconst COPILOT_REVISION_CONFLICT_CODE = 'COPILOT_CREDENTIAL_REVISION_CONFLICT'\n\nexport interface CopilotAuthPathOptions {\n /** Base for relative paths. Defaults to `process.cwd()`. */\n readonly cwd?: string\n /** Environment source. Defaults to `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>>\n}\n\n/**\n * Resolve the credential file path: `explicitPath` → environment → default.\n *\n * An empty or all-whitespace string counts as absent, so an unset shell variable\n * that expanded to `''` falls through to the next source instead of resolving to\n * the current directory (Requirement 6.5).\n * @param explicitPath - a caller-supplied path; highest precedence.\n * @param options - the `cwd` relative paths resolve against, and the environment source.\n * @returns an absolute path.\n * @throws TypeError when a supplied path contains a NUL character.\n */\nexport function resolveCopilotAuthPath(\n explicitPath?: string,\n options: CopilotAuthPathOptions = {},\n): string {\n const env = options.env ?? process.env\n const selected = nonEmptyPath(explicitPath)\n ?? nonEmptyPath(env[COPILOT_AUTH_PATH_ENV])\n ?? DEFAULT_COPILOT_AUTH_PATH\n const cwd = resolve(options.cwd ?? process.cwd())\n return isAbsolute(selected) ? resolve(selected) : resolve(cwd, selected)\n}\n\n/** @deprecated Use the revisioned {@link fileCopilotCredentialStore}. */\nexport function fileCopilotAuthStore(\n path?: string,\n options: CopilotAuthPathOptions = {},\n): CopilotAuthStore {\n const location = resolveCopilotAuthPath(path, options)\n return {\n location,\n async read(): Promise<CopilotAuthFile | undefined> {\n return (await readAuthFile(location))?.file\n },\n async write(file: CopilotAuthFile): Promise<void> {\n const payload = authPayload(file)\n await withCredentialFileLock(location, undefined, async () => {\n await replaceCredentialText(location, payload)\n })\n },\n }\n}\n\n/**\n * Revisioned compare-and-swap store used by normal Node provider composition.\n *\n * The revision is a sha256 of the RAW file bytes, so any change made by any\n * writer — this SDK or a hand edit — invalidates a revision a reader is holding.\n * The compare and the replace both happen inside `withCredentialFileLock`, which\n * is what makes exactly one of two concurrent commits win (Requirement 6.3).\n * @param path - an explicit credential path; otherwise resolved by precedence.\n * @param options - the `cwd` relative paths resolve against, and the environment source.\n * @returns a compare-and-swap store over one file.\n */\nexport function fileCopilotCredentialStore(\n path?: string,\n options: CopilotAuthPathOptions = {},\n): CopilotCredentialStore {\n const location = resolveCopilotAuthPath(path, options)\n return defineCredentialStore<CopilotAuthFile>({\n id: 'copilot-file-credentials',\n label: 'Copilot file credential store',\n async read({ signal }) {\n const snapshot = await readAuthFile(location, signal)\n return snapshot === undefined ? undefined : Object.freeze({\n value: snapshot.file,\n revision: revisionOf(snapshot.raw),\n })\n },\n async commit(input, { signal }) {\n validateExpectedRevision(input.expectedRevision)\n const payload = authPayload(input.value)\n return await withCredentialFileLock(location, signal, async () => {\n const current = await readAuthFile(location, signal)\n const actual = current === undefined ? null : revisionOf(current.raw)\n if (actual !== input.expectedRevision) {\n throw credentialFileError(\n 'Copilot credential revision changed before commit',\n undefined,\n COPILOT_REVISION_CONFLICT_CODE,\n )\n }\n await replaceCredentialText(location, payload, signal)\n return Object.freeze({ revision: revisionOf(payload) })\n })\n },\n })\n}\n\nfunction nonEmptyPath(value: string | undefined): string | undefined {\n if (value === undefined || value.trim().length === 0) return undefined\n if (value.includes('\\0')) throw new TypeError('Copilot credential path must not contain NUL')\n return value\n}\n\nasync function readAuthFile(\n location: string,\n signal?: AbortSignal,\n): Promise<{ readonly file: CopilotAuthFile; readonly raw: string } | undefined> {\n const raw = await readCredentialText(location, signal)\n if (raw === undefined) return undefined\n try {\n return Object.freeze({ file: JSON.parse(raw) as CopilotAuthFile, raw })\n } catch (error: unknown) {\n throw credentialFileError(\n 'Copilot credential file is not valid JSON; delete it and log in again',\n error,\n )\n }\n}\n\nfunction authPayload(file: CopilotAuthFile): string {\n try {\n const encoded = JSON.stringify(file, null, 2)\n if (encoded === undefined) throw new TypeError('credential value is not JSON')\n return `${encoded}\\n`\n } catch (error: unknown) {\n throw credentialFileError('Copilot credential value could not be serialized', error)\n }\n}\n\nfunction revisionOf(raw: string): string {\n return createHash('sha256').update(raw, 'utf8').digest('hex')\n}\n\nfunction validateExpectedRevision(value: string | null): void {\n if (value !== null && (typeof value !== 'string' || value.length === 0 || value.length > 256)) {\n throw credentialFileError('Copilot expected credential revision is invalid')\n }\n}\n","/**\n * Node wrapper over the injected-store Universal Copilot provider.\n *\n * A deliberate mirror of `./codex.ts` and just as thin: the ONLY thing this module\n * does is default `authStore` to the project-local file store, because paths, the\n * filesystem and the environment belong to this package and never to a Universal\n * one (Requirements 6.5, 18.2). Everything else here is a re-export of the\n * Universal surface so a Node caller needs one import specifier instead of two.\n *\n * Unlike `./codex.ts` there are no `@deprecated` compatibility aliases: Copilot\n * ships with no former entry point to stay compatible with.\n *\n * @module ai-agent-sdk/auth-node/copilot\n */\n\nimport type { ComposableModelProviderPlugin } from '@alvin0/ai-agent-sdk-core/provider'\nimport {\n copilotPlugin as universalCopilotPlugin,\n type CopilotCredentialStore,\n type CopilotProviderOptions,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nimport { fileCopilotCredentialStore } from './copilot-store.ts'\n\nexport interface CopilotNodeProviderOptions extends Omit<CopilotProviderOptions, 'authStore'> {\n /** Omit to use the project-local file credential store. */\n readonly authStore?: CopilotCredentialStore\n}\n\n/** Preferred Node composition plugin backed by revision-safe file credentials by default. */\nexport function copilotNodeProviderPlugin(\n options: CopilotNodeProviderOptions = {},\n): ComposableModelProviderPlugin & { readonly family: 'copilot' } {\n return universalCopilotPlugin({\n ...options,\n authStore: options.authStore ?? fileCopilotCredentialStore(),\n })\n}\n\nexport {\n COPILOT_BASE_URL,\n COPILOT_CATALOG_PATH,\n COPILOT_DEFAULT_CATALOG_TIMEOUT_MS,\n COPILOT_DEFAULT_DIALECT,\n COPILOT_DEFAULT_MAX_CATALOG_BYTES,\n COPILOT_DEFAULT_MAX_CATALOG_CHUNKS,\n COPILOT_DEFAULT_MAX_CATALOG_MODELS,\n COPILOT_DEFAULT_POLL_INTERVAL_SECONDS,\n COPILOT_DEVICE_CODE_MAX_WAIT_MS,\n COPILOT_DEVICE_LOGIN_WARNING,\n COPILOT_DISPLAY_NAME,\n COPILOT_DUAL_PROTOCOL_ID,\n COPILOT_EDITOR_PLUGIN_VERSION,\n COPILOT_EDITOR_VERSION,\n COPILOT_ERROR_CODES,\n COPILOT_LOGIN_COMMAND,\n COPILOT_OAUTH_CLIENT_ID,\n COPILOT_OAUTH_SCOPE,\n COPILOT_PROVIDER_ID,\n COPILOT_RESPONSES_MODEL_PREFIXES,\n COPILOT_ROUTE_ID,\n COPILOT_SLOW_DOWN_INCREMENT_SECONDS,\n COPILOT_TOKEN_EXCHANGE_MARGIN_MS,\n COPILOT_TOKEN_EXCHANGE_PATH,\n CopilotDeviceLoginError,\n CopilotTokenExchangeError,\n DEFAULT_COPILOT_OAUTH_ISSUER,\n DEFAULT_COPILOT_TIMER,\n DEFAULT_GITHUB_API_BASE_URL,\n copilotAdapter,\n copilotCatalogCacheOptions,\n copilotDualProtocol,\n copilotPlugin,\n createCopilotEndpointRouter,\n createCopilotTokenCache,\n credentialFailure,\n discoverCopilotModels,\n exchangeCopilotToken,\n getCopilotToken,\n type GetCopilotTokenOptions,\n memoryCopilotAuthStore,\n memoryCopilotCredentialStore,\n partitionCopilotCatalog,\n requestCopilotDeviceCode,\n requireGitHubToken,\n resolveCopilotCatalogLimits,\n runCopilotDeviceLogin,\n shouldExchange,\n toChatCompletionsDialect,\n toResponsesDialect,\n type ChatCompletionsProtocolLike,\n type CopilotAccountIdentity,\n type CopilotApiToken,\n type CopilotAuthFile,\n type CopilotAuthStore,\n type CopilotCatalogLimits,\n type CopilotCatalogOptions,\n type CopilotCatalogSnapshot,\n type CopilotCredentialFailure,\n type CopilotCredentialSnapshot,\n type CopilotCredentialStore,\n type CopilotDeviceCode,\n type CopilotDeviceLoginReason,\n type CopilotDialect,\n type CopilotDualProtocolOptions,\n type CopilotEditorHeaders,\n type CopilotEmbeddingModel,\n type CopilotEndpoint,\n type CopilotEndpointDecision,\n type CopilotEndpointRouter,\n type CopilotEndpointRouterOptions,\n type CopilotErrorCode,\n type CopilotExchangeOptions,\n type CopilotGenerationModel,\n type CopilotGitHubToken,\n type CopilotLegacyProviderOptions,\n type CopilotLoginProgress,\n type CopilotLoginResult,\n type CopilotOAuthOptions,\n type CopilotOmitReason,\n type CopilotOmittedModel,\n type CopilotPluginOptions,\n type CopilotProviderOptions,\n type CopilotSubProtocol,\n type CopilotTimer,\n type CopilotTokenCache,\n type CopilotTokenCacheEntry,\n type CopilotTokenCacheOptions,\n type CopilotTokenExchangeFailureKind,\n type CopilotTokenExpiry,\n type ResponsesProtocolLike,\n} from '@alvin0/ai-agent-sdk-provider-copilot'\nexport {\n COPILOT_AUTH_PATH_ENV,\n DEFAULT_COPILOT_AUTH_PATH,\n fileCopilotAuthStore,\n fileCopilotCredentialStore,\n resolveCopilotAuthPath,\n type CopilotAuthPathOptions,\n} from './copilot-store.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;;;;;;AAUrC,MAAM,iCAAiC;;;;;;;;;;;;AA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discoverCopilotModels, W as requireGitHubToken, et as resolveCopilotAuthPath, m as COPILOT_EDITOR_VERSION, p as COPILOT_EDITOR_PLUGIN_VERSION, t as COPILOT_BASE_URL, u as COPILOT_DEVICE_LOGIN_WARNING, z as exchangeCopilotToken } from "./copilot-LLMqtNSM.mjs";
1
+ import { F as createCopilotEndpointRouter, G as requireGitHubToken, K as resolveCopilotCatalogLimits, R as discoverCopilotModels, et as fileCopilotCredentialStore, m as COPILOT_EDITOR_VERSION, p as COPILOT_EDITOR_PLUGIN_VERSION, q as runCopilotDeviceLogin, t as COPILOT_BASE_URL, tt as resolveCopilotAuthPath, u as COPILOT_DEVICE_LOGIN_WARNING, z as exchangeCopilotToken } from "./copilot-C0bQCpbl.mjs";
2
2
 
3
3
  //#region src/copilot-cli.ts
4
4
  const BLUE = "\x1B[94m";
@@ -1,5 +1,5 @@
1
1
  import { ComposableModelProviderPlugin } from "@alvin0/ai-agent-sdk-core/provider";
2
- import { COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, ChatCompletionsProtocolLike, CopilotAccountIdentity, CopilotApiToken, CopilotAuthFile, CopilotAuthStore, CopilotAuthStore as CopilotAuthStore$1, CopilotCatalogLimits, CopilotCatalogOptions, CopilotCatalogSnapshot, CopilotCredentialFailure, CopilotCredentialSnapshot, CopilotCredentialStore, CopilotCredentialStore as CopilotCredentialStore$1, CopilotDeviceCode, CopilotDeviceLoginError, CopilotDeviceLoginReason, CopilotDialect, CopilotDualProtocolOptions, CopilotEditorHeaders, CopilotEmbeddingModel, CopilotEndpoint, CopilotEndpointDecision, CopilotEndpointRouter, CopilotEndpointRouterOptions, CopilotErrorCode, CopilotExchangeOptions, CopilotGenerationModel, CopilotGitHubToken, CopilotLegacyProviderOptions, CopilotLoginProgress, CopilotLoginResult, CopilotOAuthOptions, CopilotOmitReason, CopilotOmittedModel, CopilotPluginOptions, CopilotProviderOptions, CopilotProviderOptions as CopilotProviderOptions$1, CopilotSubProtocol, CopilotTimer, CopilotTokenCache, CopilotTokenCacheEntry, CopilotTokenCacheOptions, CopilotTokenExchangeError, CopilotTokenExchangeFailureKind, CopilotTokenExpiry, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, ResponsesProtocolLike, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect } from "@alvin0/ai-agent-sdk-provider-copilot";
2
+ import { COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, ChatCompletionsProtocolLike, CopilotAccountIdentity, CopilotApiToken, CopilotAuthFile, CopilotAuthStore, CopilotAuthStore as CopilotAuthStore$1, CopilotCatalogLimits, CopilotCatalogOptions, CopilotCatalogSnapshot, CopilotCredentialFailure, CopilotCredentialSnapshot, CopilotCredentialStore, CopilotCredentialStore as CopilotCredentialStore$1, CopilotDeviceCode, CopilotDeviceLoginError, CopilotDeviceLoginReason, CopilotDialect, CopilotDualProtocolOptions, CopilotEditorHeaders, CopilotEmbeddingModel, CopilotEndpoint, CopilotEndpointDecision, CopilotEndpointRouter, CopilotEndpointRouterOptions, CopilotErrorCode, CopilotExchangeOptions, CopilotGenerationModel, CopilotGitHubToken, CopilotLegacyProviderOptions, CopilotLoginProgress, CopilotLoginResult, CopilotOAuthOptions, CopilotOmitReason, CopilotOmittedModel, CopilotPluginOptions, CopilotProviderOptions, CopilotProviderOptions as CopilotProviderOptions$1, CopilotSubProtocol, CopilotTimer, CopilotTokenCache, CopilotTokenCacheEntry, CopilotTokenCacheOptions, CopilotTokenExchangeError, CopilotTokenExchangeFailureKind, CopilotTokenExpiry, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, GetCopilotTokenOptions, ResponsesProtocolLike, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, getCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect } from "@alvin0/ai-agent-sdk-provider-copilot";
3
3
  //#region src/copilot-store.d.ts
4
4
  declare const DEFAULT_COPILOT_AUTH_PATH = ".providers/.copilot/auth.json";
5
5
  declare const COPILOT_AUTH_PATH_ENV = "AI_AGENT_SDK_COPILOT_AUTH";
@@ -46,5 +46,5 @@ declare function copilotNodeProviderPlugin(options?: CopilotNodeProviderOptions)
46
46
  readonly family: 'copilot';
47
47
  };
48
48
  //#endregion
49
- export { COPILOT_AUTH_PATH_ENV, COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, type ChatCompletionsProtocolLike, type CopilotAccountIdentity, type CopilotApiToken, type CopilotAuthFile, type CopilotAuthPathOptions, type CopilotAuthStore, type CopilotCatalogLimits, type CopilotCatalogOptions, type CopilotCatalogSnapshot, type CopilotCredentialFailure, type CopilotCredentialSnapshot, type CopilotCredentialStore, type CopilotDeviceCode, CopilotDeviceLoginError, type CopilotDeviceLoginReason, type CopilotDialect, type CopilotDualProtocolOptions, type CopilotEditorHeaders, type CopilotEmbeddingModel, type CopilotEndpoint, type CopilotEndpointDecision, type CopilotEndpointRouter, type CopilotEndpointRouterOptions, type CopilotErrorCode, type CopilotExchangeOptions, type CopilotGenerationModel, type CopilotGitHubToken, type CopilotLegacyProviderOptions, type CopilotLoginProgress, type CopilotLoginResult, CopilotNodeProviderOptions, type CopilotOAuthOptions, type CopilotOmitReason, type CopilotOmittedModel, type CopilotPluginOptions, type CopilotProviderOptions, type CopilotSubProtocol, type CopilotTimer, type CopilotTokenCache, type CopilotTokenCacheEntry, type CopilotTokenCacheOptions, CopilotTokenExchangeError, type CopilotTokenExchangeFailureKind, type CopilotTokenExpiry, DEFAULT_COPILOT_AUTH_PATH, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, type ResponsesProtocolLike, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotNodeProviderPlugin, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, fileCopilotAuthStore, fileCopilotCredentialStore, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotAuthPath, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect };
49
+ export { COPILOT_AUTH_PATH_ENV, COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, type ChatCompletionsProtocolLike, type CopilotAccountIdentity, type CopilotApiToken, type CopilotAuthFile, type CopilotAuthPathOptions, type CopilotAuthStore, type CopilotCatalogLimits, type CopilotCatalogOptions, type CopilotCatalogSnapshot, type CopilotCredentialFailure, type CopilotCredentialSnapshot, type CopilotCredentialStore, type CopilotDeviceCode, CopilotDeviceLoginError, type CopilotDeviceLoginReason, type CopilotDialect, type CopilotDualProtocolOptions, type CopilotEditorHeaders, type CopilotEmbeddingModel, type CopilotEndpoint, type CopilotEndpointDecision, type CopilotEndpointRouter, type CopilotEndpointRouterOptions, type CopilotErrorCode, type CopilotExchangeOptions, type CopilotGenerationModel, type CopilotGitHubToken, type CopilotLegacyProviderOptions, type CopilotLoginProgress, type CopilotLoginResult, CopilotNodeProviderOptions, type CopilotOAuthOptions, type CopilotOmitReason, type CopilotOmittedModel, type CopilotPluginOptions, type CopilotProviderOptions, type CopilotSubProtocol, type CopilotTimer, type CopilotTokenCache, type CopilotTokenCacheEntry, type CopilotTokenCacheOptions, CopilotTokenExchangeError, type CopilotTokenExchangeFailureKind, type CopilotTokenExpiry, DEFAULT_COPILOT_AUTH_PATH, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, type GetCopilotTokenOptions, type ResponsesProtocolLike, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotNodeProviderPlugin, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, fileCopilotAuthStore, fileCopilotCredentialStore, getCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotAuthPath, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect };
50
50
  //# sourceMappingURL=copilot.d.mts.map
package/dist/copilot.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as fileCopilotCredentialStore, A as copilotAdapter, B as memoryCopilotAuthStore, C as COPILOT_TOKEN_EXCHANGE_MARGIN_MS, D as DEFAULT_COPILOT_OAUTH_ISSUER, E as CopilotTokenExchangeError, F as createCopilotEndpointRouter, G as resolveCopilotCatalogLimits, H as partitionCopilotCatalog, I as createCopilotTokenCache, J as toChatCompletionsDialect, K as runCopilotDeviceLogin, L as credentialFailure, M as copilotDualProtocol, N as copilotNodeProviderPlugin, O as DEFAULT_COPILOT_TIMER, P as copilotPlugin, Q as fileCopilotAuthStore, R as discoverCopilotModels, S as COPILOT_SLOW_DOWN_INCREMENT_SECONDS, T as CopilotDeviceLoginError, U as requestCopilotDeviceCode, V as memoryCopilotCredentialStore, W as requireGitHubToken, X as COPILOT_AUTH_PATH_ENV, Y as toResponsesDialect, Z as DEFAULT_COPILOT_AUTH_PATH, _ as COPILOT_OAUTH_CLIENT_ID, a as COPILOT_DEFAULT_MAX_CATALOG_BYTES, b as COPILOT_RESPONSES_MODEL_PREFIXES, c as COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, d as COPILOT_DISPLAY_NAME, et as resolveCopilotAuthPath, f as COPILOT_DUAL_PROTOCOL_ID, g as COPILOT_LOGIN_COMMAND, h as COPILOT_ERROR_CODES, i as COPILOT_DEFAULT_DIALECT, j as copilotCatalogCacheOptions, k as DEFAULT_GITHUB_API_BASE_URL, l as COPILOT_DEVICE_CODE_MAX_WAIT_MS, m as COPILOT_EDITOR_VERSION, n as COPILOT_CATALOG_PATH, o as COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, p as COPILOT_EDITOR_PLUGIN_VERSION, q as shouldExchange, r as COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, s as COPILOT_DEFAULT_MAX_CATALOG_MODELS, t as COPILOT_BASE_URL, u as COPILOT_DEVICE_LOGIN_WARNING, v as COPILOT_OAUTH_SCOPE, w as COPILOT_TOKEN_EXCHANGE_PATH, x as COPILOT_ROUTE_ID, y as COPILOT_PROVIDER_ID, z as exchangeCopilotToken } from "./copilot-LLMqtNSM.mjs";
1
+ import { $ as fileCopilotAuthStore, A as copilotAdapter, B as getCopilotToken, C as COPILOT_TOKEN_EXCHANGE_MARGIN_MS, D as DEFAULT_COPILOT_OAUTH_ISSUER, E as CopilotTokenExchangeError, F as createCopilotEndpointRouter, G as requireGitHubToken, H as memoryCopilotCredentialStore, I as createCopilotTokenCache, J as shouldExchange, K as resolveCopilotCatalogLimits, L as credentialFailure, M as copilotDualProtocol, N as copilotNodeProviderPlugin, O as DEFAULT_COPILOT_TIMER, P as copilotPlugin, Q as DEFAULT_COPILOT_AUTH_PATH, R as discoverCopilotModels, S as COPILOT_SLOW_DOWN_INCREMENT_SECONDS, T as CopilotDeviceLoginError, U as partitionCopilotCatalog, V as memoryCopilotAuthStore, W as requestCopilotDeviceCode, X as toResponsesDialect, Y as toChatCompletionsDialect, Z as COPILOT_AUTH_PATH_ENV, _ as COPILOT_OAUTH_CLIENT_ID, a as COPILOT_DEFAULT_MAX_CATALOG_BYTES, b as COPILOT_RESPONSES_MODEL_PREFIXES, c as COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, d as COPILOT_DISPLAY_NAME, et as fileCopilotCredentialStore, f as COPILOT_DUAL_PROTOCOL_ID, g as COPILOT_LOGIN_COMMAND, h as COPILOT_ERROR_CODES, i as COPILOT_DEFAULT_DIALECT, j as copilotCatalogCacheOptions, k as DEFAULT_GITHUB_API_BASE_URL, l as COPILOT_DEVICE_CODE_MAX_WAIT_MS, m as COPILOT_EDITOR_VERSION, n as COPILOT_CATALOG_PATH, o as COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, p as COPILOT_EDITOR_PLUGIN_VERSION, q as runCopilotDeviceLogin, r as COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, s as COPILOT_DEFAULT_MAX_CATALOG_MODELS, t as COPILOT_BASE_URL, tt as resolveCopilotAuthPath, u as COPILOT_DEVICE_LOGIN_WARNING, v as COPILOT_OAUTH_SCOPE, w as COPILOT_TOKEN_EXCHANGE_PATH, x as COPILOT_ROUTE_ID, y as COPILOT_PROVIDER_ID, z as exchangeCopilotToken } from "./copilot-C0bQCpbl.mjs";
2
2
 
3
- export { COPILOT_AUTH_PATH_ENV, COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, CopilotDeviceLoginError, CopilotTokenExchangeError, DEFAULT_COPILOT_AUTH_PATH, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotNodeProviderPlugin, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, fileCopilotAuthStore, fileCopilotCredentialStore, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotAuthPath, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect };
3
+ export { COPILOT_AUTH_PATH_ENV, COPILOT_BASE_URL, COPILOT_CATALOG_PATH, COPILOT_DEFAULT_CATALOG_TIMEOUT_MS, COPILOT_DEFAULT_DIALECT, COPILOT_DEFAULT_MAX_CATALOG_BYTES, COPILOT_DEFAULT_MAX_CATALOG_CHUNKS, COPILOT_DEFAULT_MAX_CATALOG_MODELS, COPILOT_DEFAULT_POLL_INTERVAL_SECONDS, COPILOT_DEVICE_CODE_MAX_WAIT_MS, COPILOT_DEVICE_LOGIN_WARNING, COPILOT_DISPLAY_NAME, COPILOT_DUAL_PROTOCOL_ID, COPILOT_EDITOR_PLUGIN_VERSION, COPILOT_EDITOR_VERSION, COPILOT_ERROR_CODES, COPILOT_LOGIN_COMMAND, COPILOT_OAUTH_CLIENT_ID, COPILOT_OAUTH_SCOPE, COPILOT_PROVIDER_ID, COPILOT_RESPONSES_MODEL_PREFIXES, COPILOT_ROUTE_ID, COPILOT_SLOW_DOWN_INCREMENT_SECONDS, COPILOT_TOKEN_EXCHANGE_MARGIN_MS, COPILOT_TOKEN_EXCHANGE_PATH, CopilotDeviceLoginError, CopilotTokenExchangeError, DEFAULT_COPILOT_AUTH_PATH, DEFAULT_COPILOT_OAUTH_ISSUER, DEFAULT_COPILOT_TIMER, DEFAULT_GITHUB_API_BASE_URL, copilotAdapter, copilotCatalogCacheOptions, copilotDualProtocol, copilotNodeProviderPlugin, copilotPlugin, createCopilotEndpointRouter, createCopilotTokenCache, credentialFailure, discoverCopilotModels, exchangeCopilotToken, fileCopilotAuthStore, fileCopilotCredentialStore, getCopilotToken, memoryCopilotAuthStore, memoryCopilotCredentialStore, partitionCopilotCatalog, requestCopilotDeviceCode, requireGitHubToken, resolveCopilotAuthPath, resolveCopilotCatalogLimits, runCopilotDeviceLogin, shouldExchange, toChatCompletionsDialect, toResponsesDialect };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "alvin0 - chaulamdinhai",
5
5
  "email": "chaulamdinhai@gmail.com"
6
6
  },
7
- "version": "0.1.1",
7
+ "version": "0.1.2",
8
8
  "description": "Node environment credentials and project-local Codex authentication for ai-agent-sdk",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "provenance": true
59
59
  },
60
60
  "peerDependencies": {
61
- "@alvin0/ai-agent-sdk-core": "^0.1.1",
62
- "@alvin0/ai-agent-sdk-provider-codex": "^0.1.1",
63
- "@alvin0/ai-agent-sdk-provider-copilot": "^0.1.1"
61
+ "@alvin0/ai-agent-sdk-core": "^0.1.2",
62
+ "@alvin0/ai-agent-sdk-provider-codex": "^0.1.2",
63
+ "@alvin0/ai-agent-sdk-provider-copilot": "^0.1.2"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "@alvin0/ai-agent-sdk-provider-codex": {
@@ -71,9 +71,9 @@
71
71
  }
72
72
  },
73
73
  "devDependencies": {
74
- "@alvin0/ai-agent-sdk-core": "^0.1.1",
75
- "@alvin0/ai-agent-sdk-provider-codex": "^0.1.1",
76
- "@alvin0/ai-agent-sdk-provider-copilot": "^0.1.1",
74
+ "@alvin0/ai-agent-sdk-core": "^0.1.2",
75
+ "@alvin0/ai-agent-sdk-provider-codex": "^0.1.2",
76
+ "@alvin0/ai-agent-sdk-provider-copilot": "^0.1.2",
77
77
  "@arethetypeswrong/cli": "0.18.5",
78
78
  "@types/node": "26.4.0",
79
79
  "publint": "0.3.24",