@mrciphersmith/keryx 0.2.101 → 0.2.102
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.js +50 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1089,6 +1089,8 @@ var init_providers = __esm(() => {
|
|
|
1089
1089
|
label: "GitHub Copilot",
|
|
1090
1090
|
baseUrl: "https://api.githubcopilot.com",
|
|
1091
1091
|
envKey: "GITHUB_COPILOT_TOKEN",
|
|
1092
|
+
chatPath: "/chat/completions",
|
|
1093
|
+
modelsPath: "/models",
|
|
1092
1094
|
models: ["gpt-4o", "gpt-4.1", "gpt-4o-mini"],
|
|
1093
1095
|
note: "Copilot \xB7 device login"
|
|
1094
1096
|
}
|
|
@@ -41137,6 +41139,24 @@ var init_device_code = __esm(() => {
|
|
|
41137
41139
|
});
|
|
41138
41140
|
|
|
41139
41141
|
// src/lib/oauth/copilot.ts
|
|
41142
|
+
function copilotApiBaseFromExchange(raw) {
|
|
41143
|
+
if (typeof raw !== "string" || raw.length === 0) {
|
|
41144
|
+
return;
|
|
41145
|
+
}
|
|
41146
|
+
try {
|
|
41147
|
+
const url = new URL(raw);
|
|
41148
|
+
if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0) {
|
|
41149
|
+
return;
|
|
41150
|
+
}
|
|
41151
|
+
const host = url.hostname;
|
|
41152
|
+
if (host !== "api.githubcopilot.com" && !host.endsWith(".githubcopilot.com")) {
|
|
41153
|
+
return;
|
|
41154
|
+
}
|
|
41155
|
+
return `https://${host}${url.port.length > 0 ? `:${url.port}` : ""}`;
|
|
41156
|
+
} catch {
|
|
41157
|
+
return;
|
|
41158
|
+
}
|
|
41159
|
+
}
|
|
41140
41160
|
function expiresInSecondsFrom(rec, now) {
|
|
41141
41161
|
if (typeof rec.expires_at === "string") {
|
|
41142
41162
|
const expires = Date.parse(rec.expires_at);
|
|
@@ -41197,7 +41217,12 @@ async function exchangeGithubTokenForCopilot(githubToken, http) {
|
|
|
41197
41217
|
throw new DeviceCodeError("failed", "GitHub Copilot token exchange returned no token");
|
|
41198
41218
|
}
|
|
41199
41219
|
const expiresInSeconds = expiresInSecondsFrom(rec, Date.now());
|
|
41200
|
-
|
|
41220
|
+
const apiBaseUrl = copilotApiBaseFromExchange(rec.endpoints?.api);
|
|
41221
|
+
return {
|
|
41222
|
+
accessToken: rec.token,
|
|
41223
|
+
...expiresInSeconds !== undefined ? { expiresInSeconds } : {},
|
|
41224
|
+
...apiBaseUrl !== undefined ? { apiBaseUrl } : {}
|
|
41225
|
+
};
|
|
41201
41226
|
}
|
|
41202
41227
|
var COPILOT_TOKEN_URL = "https://api.github.com/copilot_internal/v2/token";
|
|
41203
41228
|
var init_copilot = __esm(() => {
|
|
@@ -41321,6 +41346,9 @@ async function loginRfc8628(input) {
|
|
|
41321
41346
|
}, http);
|
|
41322
41347
|
if (endpoints.afterToken === "github-copilot") {
|
|
41323
41348
|
const copilot = await exchangeGithubTokenForCopilot(tokens.accessToken, http);
|
|
41349
|
+
if (copilot.apiBaseUrl !== undefined) {
|
|
41350
|
+
saveProviderBaseUrl("github-copilot", copilot.apiBaseUrl, input.dir);
|
|
41351
|
+
}
|
|
41324
41352
|
return {
|
|
41325
41353
|
accessToken: copilot.accessToken,
|
|
41326
41354
|
refreshToken: tokens.accessToken,
|
|
@@ -41370,6 +41398,9 @@ async function refreshProviderGrant(provider, http, dir) {
|
|
|
41370
41398
|
const endpoints = provider === "github-copilot" ? GITHUB_COPILOT_DEVICE : XAI_GROK_DEVICE;
|
|
41371
41399
|
if (provider === "github-copilot") {
|
|
41372
41400
|
const copilot = await exchangeGithubTokenForCopilot(grant.refresh, http);
|
|
41401
|
+
if (copilot.apiBaseUrl !== undefined) {
|
|
41402
|
+
saveProviderBaseUrl("github-copilot", copilot.apiBaseUrl, dir);
|
|
41403
|
+
}
|
|
41373
41404
|
const next = grantFromTokens("device-code", {
|
|
41374
41405
|
accessToken: copilot.accessToken,
|
|
41375
41406
|
refreshToken: grant.refresh,
|
|
@@ -41424,6 +41455,7 @@ function logoutProvider(provider, dir) {
|
|
|
41424
41455
|
}
|
|
41425
41456
|
var SESSION_REFRESHED_GRANTS;
|
|
41426
41457
|
var init_login = __esm(() => {
|
|
41458
|
+
init_shell_config();
|
|
41427
41459
|
init_catalog();
|
|
41428
41460
|
init_copilot();
|
|
41429
41461
|
init_device_code();
|
|
@@ -48228,7 +48260,7 @@ import path47 from "path";
|
|
|
48228
48260
|
// package.json
|
|
48229
48261
|
var package_default = {
|
|
48230
48262
|
name: "@mrciphersmith/keryx",
|
|
48231
|
-
version: "0.2.
|
|
48263
|
+
version: "0.2.102",
|
|
48232
48264
|
description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
48233
48265
|
private: false,
|
|
48234
48266
|
publishConfig: {
|
|
@@ -95021,7 +95053,7 @@ function pickAuthMethodStep(otui, r, providerLabel, methods) {
|
|
|
95021
95053
|
});
|
|
95022
95054
|
});
|
|
95023
95055
|
}
|
|
95024
|
-
function runDeviceLoginInTui(otui, r, provider) {
|
|
95056
|
+
function runDeviceLoginInTui(otui, r, provider, dir) {
|
|
95025
95057
|
return new Promise((resolve) => {
|
|
95026
95058
|
const box = overlayBox(otui, r, "device-login");
|
|
95027
95059
|
r.root.add(box);
|
|
@@ -95049,6 +95081,7 @@ function runDeviceLoginInTui(otui, r, provider) {
|
|
|
95049
95081
|
provider,
|
|
95050
95082
|
fetch: (input, init) => globalThis.fetch(input, init),
|
|
95051
95083
|
signal: controller.signal,
|
|
95084
|
+
...dir !== undefined ? { dir } : {},
|
|
95052
95085
|
onChallenge: (challenge) => {
|
|
95053
95086
|
status.content = otui.t`${otui.bold(challenge.userCode)}\n${otui.dim(challenge.verificationUri)}\n${otui.dim("Open that URL on any device and enter the code. Waiting for authorization\u2026")}`;
|
|
95054
95087
|
openVerificationUrl(challenge.verificationUriComplete ?? challenge.verificationUri);
|
|
@@ -95165,12 +95198,14 @@ function selectProviderModelInTui(otui, r, detected, options = {}) {
|
|
|
95165
95198
|
}
|
|
95166
95199
|
continue;
|
|
95167
95200
|
}
|
|
95168
|
-
|
|
95169
|
-
|
|
95201
|
+
const lockDiscoveredHost = prov.name === "github-copilot";
|
|
95202
|
+
let selectedBaseUrl = options.onlyConnected || prov.baseUrl === undefined || lockDiscoveredHost ? prov.baseUrl : await promptBaseUrlStep(otui, r, prov.label ?? prov.name, prov.baseUrl);
|
|
95203
|
+
if (!options.onlyConnected && !lockDiscoveredHost && prov.baseUrl !== undefined && selectedBaseUrl === undefined) {
|
|
95170
95204
|
continue;
|
|
95171
95205
|
}
|
|
95172
|
-
if (!options.onlyConnected && selectedBaseUrl !== undefined)
|
|
95206
|
+
if (!options.onlyConnected && !lockDiscoveredHost && selectedBaseUrl !== undefined) {
|
|
95173
95207
|
saveProviderBaseUrl(prov.name, selectedBaseUrl, options.configDir);
|
|
95208
|
+
}
|
|
95174
95209
|
let selectedProvider = selectedBaseUrl === undefined ? prov : { ...prov, baseUrl: selectedBaseUrl };
|
|
95175
95210
|
const envKey = prov.envKey;
|
|
95176
95211
|
const label = prov.label ?? prov.name;
|
|
@@ -95198,7 +95233,15 @@ function selectProviderModelInTui(otui, r, detected, options = {}) {
|
|
|
95198
95233
|
}
|
|
95199
95234
|
}
|
|
95200
95235
|
if (method === "device-code") {
|
|
95201
|
-
|
|
95236
|
+
if (!await runDeviceLoginInTui(otui, r, prov.name, options.configDir)) {
|
|
95237
|
+
return "back";
|
|
95238
|
+
}
|
|
95239
|
+
const saved = loadShellConfig(options.configDir).baseUrls?.[prov.name];
|
|
95240
|
+
if (typeof saved === "string" && saved.length > 0) {
|
|
95241
|
+
selectedBaseUrl = saved;
|
|
95242
|
+
selectedProvider = { ...prov, baseUrl: saved };
|
|
95243
|
+
}
|
|
95244
|
+
return "ok";
|
|
95202
95245
|
}
|
|
95203
95246
|
const kr = await promptApiKeyStep(otui, r, {
|
|
95204
95247
|
label,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/keryx",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.102",
|
|
4
4
|
"description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|