@ngosangns/ns-bridge 0.1.4 → 0.1.6
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 +8 -0
- package/dist/agents.d.ts +28 -0
- package/dist/agents.js +168 -0
- package/dist/agents.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +63 -0
- package/dist/cli.js.map +1 -1
- package/dist/providers.d.ts +32 -0
- package/dist/providers.js +207 -0
- package/dist/providers.js.map +1 -0
- package/dist/refresh-entry.js +445 -375
- package/dist/selection.d.ts +32 -0
- package/dist/selection.js +87 -0
- package/dist/selection.js.map +1 -0
- package/package.json +1 -1
package/dist/refresh-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.6 — catalog refresh bundle.
|
|
2
2
|
import { createRequire as __nsBridgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __nsBridgeCreateRequire(import.meta.url);
|
|
4
4
|
var __create = Object.create;
|
|
@@ -815,14 +815,14 @@ function createProvider(input) {
|
|
|
815
815
|
return merged;
|
|
816
816
|
};
|
|
817
817
|
const apiFor = (model) => single ?? byApi?.[model.api];
|
|
818
|
-
const dispatch = (model,
|
|
818
|
+
const dispatch = (model, run2) => {
|
|
819
819
|
const streams2 = apiFor(model);
|
|
820
820
|
if (!streams2) {
|
|
821
821
|
return lazyStream(model, async () => {
|
|
822
822
|
throw new ModelsError("stream", `Provider ${input.id} has no API implementation for "${model.api}"`);
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
|
-
return
|
|
825
|
+
return run2(streams2);
|
|
826
826
|
};
|
|
827
827
|
const provider = {
|
|
828
828
|
id: input.id,
|
|
@@ -13110,7 +13110,7 @@ var init_BetaToolRunner = __esm({
|
|
|
13110
13110
|
}
|
|
13111
13111
|
let definition = change.tool;
|
|
13112
13112
|
if ("run" in change.tool) {
|
|
13113
|
-
const { run, parse, close, ...rest } = change.tool;
|
|
13113
|
+
const { run: run2, parse, close, ...rest } = change.tool;
|
|
13114
13114
|
definition = rest;
|
|
13115
13115
|
}
|
|
13116
13116
|
content.push({ type: "tool_addition", tool: { type: "tool_definition", definition } });
|
|
@@ -34520,10 +34520,10 @@ var init_AssistantStream = __esm({
|
|
|
34520
34520
|
}));
|
|
34521
34521
|
return runner;
|
|
34522
34522
|
}
|
|
34523
|
-
async _createToolAssistantStream(
|
|
34523
|
+
async _createToolAssistantStream(run2, runId, params, options) {
|
|
34524
34524
|
this._listenForAbort(options?.signal);
|
|
34525
34525
|
const body = { ...params, stream: true };
|
|
34526
|
-
const stream11 = await
|
|
34526
|
+
const stream11 = await run2.submitToolOutputs(runId, body, {
|
|
34527
34527
|
...options,
|
|
34528
34528
|
signal: this.controller.signal
|
|
34529
34529
|
});
|
|
@@ -34608,10 +34608,10 @@ var init_AssistantStream = __esm({
|
|
|
34608
34608
|
}
|
|
34609
34609
|
return this._addRun(__classPrivateFieldGet2(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
34610
34610
|
}
|
|
34611
|
-
async _createAssistantStream(
|
|
34611
|
+
async _createAssistantStream(run2, threadId, params, options) {
|
|
34612
34612
|
this._listenForAbort(options?.signal);
|
|
34613
34613
|
const body = { ...params, stream: true };
|
|
34614
|
-
const stream11 = await
|
|
34614
|
+
const stream11 = await run2.create(threadId, body, { ...options, signal: this.controller.signal });
|
|
34615
34615
|
this._connected();
|
|
34616
34616
|
for await (const event of stream11) {
|
|
34617
34617
|
__classPrivateFieldGet2(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
@@ -34628,9 +34628,9 @@ var init_AssistantStream = __esm({
|
|
|
34628
34628
|
static accumulateDelta(acc, delta) {
|
|
34629
34629
|
return accumulateAssistantStreamDelta(acc, delta);
|
|
34630
34630
|
}
|
|
34631
|
-
_addRun(
|
|
34632
|
-
__classPrivateFieldGet2(this, _AssistantStream_instances, "m", _AssistantStream_emitExposed).call(this, "run",
|
|
34633
|
-
return
|
|
34631
|
+
_addRun(run2) {
|
|
34632
|
+
__classPrivateFieldGet2(this, _AssistantStream_instances, "m", _AssistantStream_emitExposed).call(this, "run", run2);
|
|
34633
|
+
return run2;
|
|
34634
34634
|
}
|
|
34635
34635
|
async _threadAssistantStream(params, thread, options) {
|
|
34636
34636
|
return await this._createThreadAssistantStream(thread, params, options);
|
|
@@ -35310,8 +35310,8 @@ var init_runs = __esm({
|
|
|
35310
35310
|
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
|
|
35311
35311
|
*/
|
|
35312
35312
|
async createAndPoll(threadId, body, options) {
|
|
35313
|
-
const
|
|
35314
|
-
return await this.poll(
|
|
35313
|
+
const run2 = await this.create(threadId, body, options);
|
|
35314
|
+
return await this.poll(run2.id, { thread_id: threadId }, options);
|
|
35315
35315
|
}
|
|
35316
35316
|
/**
|
|
35317
35317
|
* Create a Run stream
|
|
@@ -35352,8 +35352,8 @@ var init_runs = __esm({
|
|
|
35352
35352
|
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
|
|
35353
35353
|
*/
|
|
35354
35354
|
async submitToolOutputsAndPoll(runId, params, options) {
|
|
35355
|
-
const
|
|
35356
|
-
return await this.poll(
|
|
35355
|
+
const run2 = await this.submitToolOutputs(runId, params, options);
|
|
35356
|
+
return await this.poll(run2.id, params, options);
|
|
35357
35357
|
}
|
|
35358
35358
|
/**
|
|
35359
35359
|
* Submit the tool outputs from a previous run and stream the run to a terminal
|
|
@@ -35452,8 +35452,8 @@ var init_threads3 = __esm({
|
|
|
35452
35452
|
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
|
|
35453
35453
|
*/
|
|
35454
35454
|
async createAndRunPoll(body, options) {
|
|
35455
|
-
const
|
|
35456
|
-
return await this.runs.poll(
|
|
35455
|
+
const run2 = await this.createAndRun(body, options);
|
|
35456
|
+
return await this.runs.poll(run2.id, { thread_id: run2.thread_id }, options);
|
|
35457
35457
|
}
|
|
35458
35458
|
/**
|
|
35459
35459
|
* Create a thread and stream the run back
|
|
@@ -50781,7 +50781,7 @@ var require_gaxios = __commonJS({
|
|
|
50781
50781
|
var retry_js_1 = require_retry3();
|
|
50782
50782
|
var stream_1 = __require("stream");
|
|
50783
50783
|
var interceptor_js_1 = require_interceptor();
|
|
50784
|
-
var
|
|
50784
|
+
var randomUUID4 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
50785
50785
|
var HTTP_STATUS_NO_CONTENT = 204;
|
|
50786
50786
|
var Gaxios = class {
|
|
50787
50787
|
agentCache = /* @__PURE__ */ new Map();
|
|
@@ -51054,7 +51054,7 @@ var require_gaxios = __commonJS({
|
|
|
51054
51054
|
*/
|
|
51055
51055
|
["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
51056
51056
|
if (opts.multipart?.length) {
|
|
51057
|
-
const boundary = await
|
|
51057
|
+
const boundary = await randomUUID4();
|
|
51058
51058
|
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
51059
51059
|
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
51060
51060
|
} else if (shouldDirectlyPassData) {
|
|
@@ -92417,64 +92417,6 @@ var init_endpoints = __esm({
|
|
|
92417
92417
|
}
|
|
92418
92418
|
});
|
|
92419
92419
|
|
|
92420
|
-
// ../kiro-core/dist/kiro-ide.js
|
|
92421
|
-
import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
|
|
92422
|
-
import { homedir as homedir6 } from "node:os";
|
|
92423
|
-
import { join as join7 } from "node:path";
|
|
92424
|
-
function readKiroIdeToken(allowExpired) {
|
|
92425
|
-
try {
|
|
92426
|
-
if (!existsSync3(KIRO_IDE_TOKEN_PATH))
|
|
92427
|
-
return void 0;
|
|
92428
|
-
const tokenData = JSON.parse(readFileSync5(KIRO_IDE_TOKEN_PATH, "utf-8"));
|
|
92429
|
-
if (!tokenData.accessToken || !tokenData.refreshToken)
|
|
92430
|
-
return void 0;
|
|
92431
|
-
const expiresAt = new Date(tokenData.expiresAt).getTime();
|
|
92432
|
-
if (!allowExpired && Date.now() >= expiresAt - 2 * 60 * 1e3)
|
|
92433
|
-
return void 0;
|
|
92434
|
-
const region = tokenData.region ?? "us-east-1";
|
|
92435
|
-
let clientId = "";
|
|
92436
|
-
let clientSecret = "";
|
|
92437
|
-
if (tokenData.clientIdHash) {
|
|
92438
|
-
const regPath = join7(SSO_CACHE_DIR, `${tokenData.clientIdHash}.json`);
|
|
92439
|
-
if (existsSync3(regPath)) {
|
|
92440
|
-
try {
|
|
92441
|
-
const reg = JSON.parse(readFileSync5(regPath, "utf-8"));
|
|
92442
|
-
clientId = reg.clientId ?? "";
|
|
92443
|
-
clientSecret = reg.clientSecret ?? "";
|
|
92444
|
-
} catch {
|
|
92445
|
-
}
|
|
92446
|
-
}
|
|
92447
|
-
}
|
|
92448
|
-
return {
|
|
92449
|
-
// Pack into the same pipe-delimited format used by the rest of the refresh chain
|
|
92450
|
-
refresh: `${tokenData.refreshToken}|${clientId}|${clientSecret}|idc`,
|
|
92451
|
-
access: tokenData.accessToken,
|
|
92452
|
-
// Subtract 2-min buffer so we refresh before the actual AWS expiry
|
|
92453
|
-
expires: expiresAt - 2 * 60 * 1e3,
|
|
92454
|
-
clientId,
|
|
92455
|
-
clientSecret,
|
|
92456
|
-
region,
|
|
92457
|
-
authMethod: "idc"
|
|
92458
|
-
};
|
|
92459
|
-
} catch {
|
|
92460
|
-
return void 0;
|
|
92461
|
-
}
|
|
92462
|
-
}
|
|
92463
|
-
function getKiroIdeCredentials() {
|
|
92464
|
-
return readKiroIdeToken(false);
|
|
92465
|
-
}
|
|
92466
|
-
function getKiroIdeCredentialsAllowExpired() {
|
|
92467
|
-
return readKiroIdeToken(true);
|
|
92468
|
-
}
|
|
92469
|
-
var SSO_CACHE_DIR, KIRO_IDE_TOKEN_PATH;
|
|
92470
|
-
var init_kiro_ide = __esm({
|
|
92471
|
-
"../kiro-core/dist/kiro-ide.js"() {
|
|
92472
|
-
"use strict";
|
|
92473
|
-
SSO_CACHE_DIR = join7(homedir6(), ".aws", "sso", "cache");
|
|
92474
|
-
KIRO_IDE_TOKEN_PATH = join7(SSO_CACHE_DIR, "kiro-auth-token.json");
|
|
92475
|
-
}
|
|
92476
|
-
});
|
|
92477
|
-
|
|
92478
92420
|
// ../kiro-core/dist/kiro-cli.js
|
|
92479
92421
|
var kiro_cli_exports = {};
|
|
92480
92422
|
__export(kiro_cli_exports, {
|
|
@@ -92489,17 +92431,17 @@ __export(kiro_cli_exports, {
|
|
|
92489
92431
|
saveKiroCliCredentials: () => saveKiroCliCredentials,
|
|
92490
92432
|
tryKiroCliToken: () => tryKiroCliToken
|
|
92491
92433
|
});
|
|
92492
|
-
import { execFileSync
|
|
92493
|
-
import { existsSync as
|
|
92434
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
92435
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
92494
92436
|
import { createRequire } from "node:module";
|
|
92495
|
-
import { homedir as
|
|
92496
|
-
import { join as
|
|
92437
|
+
import { homedir as homedir6, platform } from "node:os";
|
|
92438
|
+
import { join as join7 } from "node:path";
|
|
92497
92439
|
function getKiroCliDbPath() {
|
|
92498
92440
|
const p = platform();
|
|
92499
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
92500
|
-
const roamingAppData = process.env.APPDATA ||
|
|
92501
|
-
const candidates = p === "win32" ? [
|
|
92502
|
-
return candidates.find((candidate) =>
|
|
92441
|
+
const localAppData = process.env.LOCALAPPDATA || join7(homedir6(), "AppData", "Local");
|
|
92442
|
+
const roamingAppData = process.env.APPDATA || join7(homedir6(), "AppData", "Roaming");
|
|
92443
|
+
const candidates = p === "win32" ? [join7(localAppData, "Kiro-Cli", "data.sqlite3"), join7(roamingAppData, "kiro-cli", "data.sqlite3")] : p === "darwin" ? [join7(homedir6(), "Library", "Application Support", "kiro-cli", "data.sqlite3")] : [join7(homedir6(), ".local", "share", "kiro-cli", "data.sqlite3")];
|
|
92444
|
+
return candidates.find((candidate) => existsSync3(candidate));
|
|
92503
92445
|
}
|
|
92504
92446
|
function getKiroCliExternalIdpCredentials() {
|
|
92505
92447
|
const dbPath = getKiroCliDbPath();
|
|
@@ -92730,7 +92672,7 @@ function saveKiroCliCredentials(creds) {
|
|
|
92730
92672
|
function getKiroCliModelRates() {
|
|
92731
92673
|
let raw;
|
|
92732
92674
|
try {
|
|
92733
|
-
raw =
|
|
92675
|
+
raw = execFileSync("kiro-cli", ["chat", "--list-models", "--format", "json"], {
|
|
92734
92676
|
encoding: "utf-8",
|
|
92735
92677
|
timeout: 1e4,
|
|
92736
92678
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -92764,7 +92706,7 @@ function getKiroCliModelRates() {
|
|
|
92764
92706
|
}
|
|
92765
92707
|
function refreshViaKiroCli() {
|
|
92766
92708
|
try {
|
|
92767
|
-
|
|
92709
|
+
execFileSync("kiro-cli", ["debug", "refresh-auth-token"], {
|
|
92768
92710
|
timeout: 15e3,
|
|
92769
92711
|
stdio: ["pipe", "pipe", "pipe"]
|
|
92770
92712
|
});
|
|
@@ -92790,6 +92732,152 @@ var init_kiro_cli = __esm({
|
|
|
92790
92732
|
}
|
|
92791
92733
|
});
|
|
92792
92734
|
|
|
92735
|
+
// ../kiro-core/dist/token-type.js
|
|
92736
|
+
function isExternalIdpAccessToken(accessToken) {
|
|
92737
|
+
if (typeof accessToken !== "string" || !accessToken)
|
|
92738
|
+
return false;
|
|
92739
|
+
const segments = accessToken.split(".");
|
|
92740
|
+
const payloadSegment = segments[1];
|
|
92741
|
+
if (segments.length === 3 && payloadSegment) {
|
|
92742
|
+
try {
|
|
92743
|
+
const payload = JSON.parse(Buffer.from(payloadSegment.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf-8"));
|
|
92744
|
+
if (payload.aud === EXTERNAL_IDP_AUDIENCE || Array.isArray(payload.aud) && payload.aud.includes(EXTERNAL_IDP_AUDIENCE)) {
|
|
92745
|
+
return true;
|
|
92746
|
+
}
|
|
92747
|
+
} catch {
|
|
92748
|
+
}
|
|
92749
|
+
}
|
|
92750
|
+
try {
|
|
92751
|
+
return getKiroCliExternalIdpCredentials()?.access === accessToken;
|
|
92752
|
+
} catch {
|
|
92753
|
+
return false;
|
|
92754
|
+
}
|
|
92755
|
+
}
|
|
92756
|
+
function kiroTokenTypeHeaders(accessToken) {
|
|
92757
|
+
return isExternalIdpAccessToken(accessToken) ? { tokentype: "EXTERNAL_IDP" } : {};
|
|
92758
|
+
}
|
|
92759
|
+
function isApiKey(token) {
|
|
92760
|
+
return token.startsWith("ksk_");
|
|
92761
|
+
}
|
|
92762
|
+
function kiroAuthHeaders(token) {
|
|
92763
|
+
const headers = { Authorization: `Bearer ${token}` };
|
|
92764
|
+
if (isApiKey(token))
|
|
92765
|
+
headers.tokentype = "API_KEY";
|
|
92766
|
+
return headers;
|
|
92767
|
+
}
|
|
92768
|
+
var EXTERNAL_IDP_AUDIENCE;
|
|
92769
|
+
var init_token_type = __esm({
|
|
92770
|
+
"../kiro-core/dist/token-type.js"() {
|
|
92771
|
+
"use strict";
|
|
92772
|
+
init_kiro_cli();
|
|
92773
|
+
EXTERNAL_IDP_AUDIENCE = "api://kiro";
|
|
92774
|
+
}
|
|
92775
|
+
});
|
|
92776
|
+
|
|
92777
|
+
// ../kiro-core/dist/http.js
|
|
92778
|
+
function kiroSdkUserAgent(service, sdkVersion) {
|
|
92779
|
+
return {
|
|
92780
|
+
"User-Agent": `aws-sdk-js/3.714.0 os/macos/24.3.0 lang/js md/nodejs/22.14.0 api/${service}/3.714.0 exec-env/kiro-cli/2.7.0 m/E`,
|
|
92781
|
+
"amz-sdk-invocation-id": "00000000-0000-0000-0000-000000000000",
|
|
92782
|
+
"amz-sdk-request": `attempt=1; max=${sdkVersion}`
|
|
92783
|
+
};
|
|
92784
|
+
}
|
|
92785
|
+
function kiroFetch(url, init) {
|
|
92786
|
+
return fetch(url, init);
|
|
92787
|
+
}
|
|
92788
|
+
async function kiroManagementFetch(url, auth, method, body) {
|
|
92789
|
+
const headers = {
|
|
92790
|
+
Accept: "application/json",
|
|
92791
|
+
...kiroAuthHeaders(auth.accessToken),
|
|
92792
|
+
...kiroTokenTypeHeaders(auth.accessToken),
|
|
92793
|
+
"User-Agent": KIRO_USER_AGENTS.management
|
|
92794
|
+
};
|
|
92795
|
+
const init = { method, headers };
|
|
92796
|
+
if (method === "GET") {
|
|
92797
|
+
for (const [name, value] of Object.entries(body)) {
|
|
92798
|
+
if (value !== void 0)
|
|
92799
|
+
url.searchParams.set(name, String(value));
|
|
92800
|
+
}
|
|
92801
|
+
} else {
|
|
92802
|
+
headers["Content-Type"] = "application/json";
|
|
92803
|
+
init.body = JSON.stringify(body);
|
|
92804
|
+
}
|
|
92805
|
+
return kiroFetch(url.toString(), init);
|
|
92806
|
+
}
|
|
92807
|
+
var KIRO_USER_AGENTS;
|
|
92808
|
+
var init_http = __esm({
|
|
92809
|
+
"../kiro-core/dist/http.js"() {
|
|
92810
|
+
"use strict";
|
|
92811
|
+
init_token_type();
|
|
92812
|
+
KIRO_USER_AGENTS = {
|
|
92813
|
+
/** REST-style management calls (ListAvailableProfiles, ListAvailableModels, GetUsageLimits). */
|
|
92814
|
+
management: "ns-kiro-provider",
|
|
92815
|
+
/** `prod.{region}.auth.desktop.kiro.dev/refreshToken` — the desktop app's own refresh. */
|
|
92816
|
+
desktop: "Kiro-Desktop/0.2.13 (darwin; arm64)",
|
|
92817
|
+
/** A customer's own OIDC token endpoint. No vendor to impersonate, so this names the package. */
|
|
92818
|
+
externalIdp: "kiro-core"
|
|
92819
|
+
};
|
|
92820
|
+
}
|
|
92821
|
+
});
|
|
92822
|
+
|
|
92823
|
+
// ../kiro-core/dist/kiro-ide.js
|
|
92824
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
92825
|
+
import { homedir as homedir7 } from "node:os";
|
|
92826
|
+
import { join as join8 } from "node:path";
|
|
92827
|
+
function readKiroIdeToken(allowExpired) {
|
|
92828
|
+
try {
|
|
92829
|
+
if (!existsSync4(KIRO_IDE_TOKEN_PATH))
|
|
92830
|
+
return void 0;
|
|
92831
|
+
const tokenData = JSON.parse(readFileSync5(KIRO_IDE_TOKEN_PATH, "utf-8"));
|
|
92832
|
+
if (!tokenData.accessToken || !tokenData.refreshToken)
|
|
92833
|
+
return void 0;
|
|
92834
|
+
const expiresAt = new Date(tokenData.expiresAt).getTime();
|
|
92835
|
+
if (!allowExpired && Date.now() >= expiresAt - 2 * 60 * 1e3)
|
|
92836
|
+
return void 0;
|
|
92837
|
+
const region = tokenData.region ?? "us-east-1";
|
|
92838
|
+
let clientId = "";
|
|
92839
|
+
let clientSecret = "";
|
|
92840
|
+
if (tokenData.clientIdHash) {
|
|
92841
|
+
const regPath = join8(SSO_CACHE_DIR, `${tokenData.clientIdHash}.json`);
|
|
92842
|
+
if (existsSync4(regPath)) {
|
|
92843
|
+
try {
|
|
92844
|
+
const reg = JSON.parse(readFileSync5(regPath, "utf-8"));
|
|
92845
|
+
clientId = reg.clientId ?? "";
|
|
92846
|
+
clientSecret = reg.clientSecret ?? "";
|
|
92847
|
+
} catch {
|
|
92848
|
+
}
|
|
92849
|
+
}
|
|
92850
|
+
}
|
|
92851
|
+
return {
|
|
92852
|
+
// Pack into the same pipe-delimited format used by the rest of the refresh chain
|
|
92853
|
+
refresh: `${tokenData.refreshToken}|${clientId}|${clientSecret}|idc`,
|
|
92854
|
+
access: tokenData.accessToken,
|
|
92855
|
+
// Subtract 2-min buffer so we refresh before the actual AWS expiry
|
|
92856
|
+
expires: expiresAt - 2 * 60 * 1e3,
|
|
92857
|
+
clientId,
|
|
92858
|
+
clientSecret,
|
|
92859
|
+
region,
|
|
92860
|
+
authMethod: "idc"
|
|
92861
|
+
};
|
|
92862
|
+
} catch {
|
|
92863
|
+
return void 0;
|
|
92864
|
+
}
|
|
92865
|
+
}
|
|
92866
|
+
function getKiroIdeCredentials() {
|
|
92867
|
+
return readKiroIdeToken(false);
|
|
92868
|
+
}
|
|
92869
|
+
function getKiroIdeCredentialsAllowExpired() {
|
|
92870
|
+
return readKiroIdeToken(true);
|
|
92871
|
+
}
|
|
92872
|
+
var SSO_CACHE_DIR, KIRO_IDE_TOKEN_PATH;
|
|
92873
|
+
var init_kiro_ide = __esm({
|
|
92874
|
+
"../kiro-core/dist/kiro-ide.js"() {
|
|
92875
|
+
"use strict";
|
|
92876
|
+
SSO_CACHE_DIR = join8(homedir7(), ".aws", "sso", "cache");
|
|
92877
|
+
KIRO_IDE_TOKEN_PATH = join8(SSO_CACHE_DIR, "kiro-auth-token.json");
|
|
92878
|
+
}
|
|
92879
|
+
});
|
|
92880
|
+
|
|
92793
92881
|
// ../kiro-core/dist/oauth.js
|
|
92794
92882
|
function resolveKiroAuthSource() {
|
|
92795
92883
|
const configured = process.env[AUTH_SOURCE_ENV]?.trim().toLowerCase();
|
|
@@ -92800,31 +92888,15 @@ function resolveKiroAuthSource() {
|
|
|
92800
92888
|
console.warn(`[kiro-core] Ignoring ${AUTH_SOURCE_ENV}=${configured}: expected "cli" or "ide".`);
|
|
92801
92889
|
return "cli";
|
|
92802
92890
|
}
|
|
92803
|
-
function kiroUserAgent(service, sdkVersion) {
|
|
92804
|
-
return {
|
|
92805
|
-
"User-Agent": `aws-sdk-js/3.714.0 os/macos/24.3.0 lang/js md/nodejs/22.14.0 api/${service}/3.714.0 exec-env/kiro-cli/2.7.0 m/E`,
|
|
92806
|
-
"amz-sdk-invocation-id": "00000000-0000-0000-0000-000000000000",
|
|
92807
|
-
"amz-sdk-request": `attempt=1; max=${sdkVersion}`
|
|
92808
|
-
};
|
|
92809
|
-
}
|
|
92810
|
-
function kiroAuthHeaders(token) {
|
|
92811
|
-
const headers = { Authorization: `Bearer ${token}` };
|
|
92812
|
-
if (isApiKey(token))
|
|
92813
|
-
headers.tokentype = "API_KEY";
|
|
92814
|
-
return headers;
|
|
92815
|
-
}
|
|
92816
|
-
function isApiKey(token) {
|
|
92817
|
-
return token.startsWith("ksk_");
|
|
92818
|
-
}
|
|
92819
92891
|
async function fetchApiKeyGetProfile(accessToken) {
|
|
92820
92892
|
try {
|
|
92821
|
-
return await
|
|
92893
|
+
return await kiroFetch(getKiroEndpoints(API_KEY_REGION).management, {
|
|
92822
92894
|
method: "POST",
|
|
92823
92895
|
headers: {
|
|
92824
92896
|
"Content-Type": "application/x-amz-json-1.0",
|
|
92825
92897
|
"X-Amz-Target": "AmazonCodeWhispererService.GetProfile",
|
|
92826
92898
|
...kiroAuthHeaders(accessToken),
|
|
92827
|
-
...
|
|
92899
|
+
...kiroSdkUserAgent("codewhispererruntime", "F,C")
|
|
92828
92900
|
},
|
|
92829
92901
|
body: "{}"
|
|
92830
92902
|
});
|
|
@@ -92900,9 +92972,9 @@ async function refreshKiroTokenDirectInProcess(credentials) {
|
|
|
92900
92972
|
return credentials;
|
|
92901
92973
|
if (authMethod === "desktop") {
|
|
92902
92974
|
const url = endpointFromEnv(KIRO_DESKTOP_REFRESH_ENDPOINT_ENV, KIRO_DESKTOP_REFRESH_URL, region);
|
|
92903
|
-
const response2 = await
|
|
92975
|
+
const response2 = await kiroFetch(url, {
|
|
92904
92976
|
method: "POST",
|
|
92905
|
-
headers: { "Content-Type": "application/json", "User-Agent":
|
|
92977
|
+
headers: { "Content-Type": "application/json", "User-Agent": KIRO_USER_AGENTS.desktop },
|
|
92906
92978
|
body: JSON.stringify({ refreshToken })
|
|
92907
92979
|
});
|
|
92908
92980
|
if (!response2.ok)
|
|
@@ -92927,12 +92999,12 @@ async function refreshKiroTokenDirectInProcess(credentials) {
|
|
|
92927
92999
|
const tokenEndpoint = parts[2] ?? "";
|
|
92928
93000
|
if (!tokenEndpoint)
|
|
92929
93001
|
throw new Error("External IdP token refresh: missing token endpoint");
|
|
92930
|
-
const response2 = await
|
|
93002
|
+
const response2 = await kiroFetch(tokenEndpoint, {
|
|
92931
93003
|
method: "POST",
|
|
92932
93004
|
headers: {
|
|
92933
93005
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
92934
93006
|
Accept: "application/json",
|
|
92935
|
-
"User-Agent":
|
|
93007
|
+
"User-Agent": KIRO_USER_AGENTS.externalIdp
|
|
92936
93008
|
},
|
|
92937
93009
|
body: new URLSearchParams({
|
|
92938
93010
|
grant_type: "refresh_token",
|
|
@@ -92960,9 +93032,9 @@ async function refreshKiroTokenDirectInProcess(credentials) {
|
|
|
92960
93032
|
const clientId = parts[1] ?? "";
|
|
92961
93033
|
const clientSecret = parts[2] ?? "";
|
|
92962
93034
|
const ssoEndpoint = endpointFromEnv(KIRO_OIDC_ENDPOINT_ENV, "https://oidc.{region}.amazonaws.com", region);
|
|
92963
|
-
const response = await
|
|
93035
|
+
const response = await kiroFetch(`${ssoEndpoint}/token`, {
|
|
92964
93036
|
method: "POST",
|
|
92965
|
-
headers: { "Content-Type": "application/json", ...
|
|
93037
|
+
headers: { "Content-Type": "application/json", ...kiroSdkUserAgent("ssooidc", "E") },
|
|
92966
93038
|
body: JSON.stringify({ clientId, clientSecret, refreshToken, grantType: "refresh_token" })
|
|
92967
93039
|
});
|
|
92968
93040
|
if (!response.ok)
|
|
@@ -93013,10 +93085,13 @@ var init_oauth = __esm({
|
|
|
93013
93085
|
"use strict";
|
|
93014
93086
|
init_debug();
|
|
93015
93087
|
init_endpoints();
|
|
93088
|
+
init_http();
|
|
93089
|
+
init_kiro_cli();
|
|
93016
93090
|
init_kiro_ide();
|
|
93091
|
+
init_token_type();
|
|
93017
93092
|
KIRO_DESKTOP_REFRESH_URL = "https://prod.{region}.auth.desktop.kiro.dev/refreshToken";
|
|
93018
93093
|
EXPIRES_BUFFER_MS = 5 * 60 * 1e3;
|
|
93019
|
-
KIRO_DESKTOP_USER_AGENT =
|
|
93094
|
+
KIRO_DESKTOP_USER_AGENT = KIRO_USER_AGENTS.desktop;
|
|
93020
93095
|
AUTH_SOURCE_ENV = "KIRO_AUTH_SOURCE";
|
|
93021
93096
|
API_KEY_REGION = "us-east-1";
|
|
93022
93097
|
KIRO_DESKTOP_REFRESH_ENDPOINT_ENV = "KIRO_DESKTOP_REFRESH_ENDPOINT";
|
|
@@ -93024,39 +93099,6 @@ var init_oauth = __esm({
|
|
|
93024
93099
|
}
|
|
93025
93100
|
});
|
|
93026
93101
|
|
|
93027
|
-
// ../kiro-core/dist/token-type.js
|
|
93028
|
-
function isExternalIdpAccessToken(accessToken) {
|
|
93029
|
-
if (typeof accessToken !== "string" || !accessToken)
|
|
93030
|
-
return false;
|
|
93031
|
-
const segments = accessToken.split(".");
|
|
93032
|
-
const payloadSegment = segments[1];
|
|
93033
|
-
if (segments.length === 3 && payloadSegment) {
|
|
93034
|
-
try {
|
|
93035
|
-
const payload = JSON.parse(Buffer.from(payloadSegment.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf-8"));
|
|
93036
|
-
if (payload.aud === EXTERNAL_IDP_AUDIENCE || Array.isArray(payload.aud) && payload.aud.includes(EXTERNAL_IDP_AUDIENCE)) {
|
|
93037
|
-
return true;
|
|
93038
|
-
}
|
|
93039
|
-
} catch {
|
|
93040
|
-
}
|
|
93041
|
-
}
|
|
93042
|
-
try {
|
|
93043
|
-
return getKiroCliExternalIdpCredentials()?.access === accessToken;
|
|
93044
|
-
} catch {
|
|
93045
|
-
return false;
|
|
93046
|
-
}
|
|
93047
|
-
}
|
|
93048
|
-
function kiroTokenTypeHeaders(accessToken) {
|
|
93049
|
-
return isExternalIdpAccessToken(accessToken) ? { tokentype: "EXTERNAL_IDP" } : {};
|
|
93050
|
-
}
|
|
93051
|
-
var EXTERNAL_IDP_AUDIENCE;
|
|
93052
|
-
var init_token_type = __esm({
|
|
93053
|
-
"../kiro-core/dist/token-type.js"() {
|
|
93054
|
-
"use strict";
|
|
93055
|
-
init_kiro_cli();
|
|
93056
|
-
EXTERNAL_IDP_AUDIENCE = "api://kiro";
|
|
93057
|
-
}
|
|
93058
|
-
});
|
|
93059
|
-
|
|
93060
93102
|
// ../kiro-core/dist/management.js
|
|
93061
93103
|
var management_exports = {};
|
|
93062
93104
|
__export(management_exports, {
|
|
@@ -93086,26 +93128,9 @@ function candidateManagementRegions(primary) {
|
|
|
93086
93128
|
}
|
|
93087
93129
|
async function requestManagement(auth, operation, path6, method, body) {
|
|
93088
93130
|
const url = new URL(path6, getKiroEndpoints(auth.region).management);
|
|
93089
|
-
const request = {
|
|
93090
|
-
method,
|
|
93091
|
-
headers: {
|
|
93092
|
-
Accept: "application/json",
|
|
93093
|
-
...kiroAuthHeaders(auth.accessToken),
|
|
93094
|
-
...kiroTokenTypeHeaders(auth.accessToken)
|
|
93095
|
-
}
|
|
93096
|
-
};
|
|
93097
|
-
if (method === "GET") {
|
|
93098
|
-
for (const [name, value] of Object.entries(body)) {
|
|
93099
|
-
if (value !== void 0)
|
|
93100
|
-
url.searchParams.set(name, String(value));
|
|
93101
|
-
}
|
|
93102
|
-
} else {
|
|
93103
|
-
request.headers = { ...request.headers, "Content-Type": "application/json" };
|
|
93104
|
-
request.body = JSON.stringify(body);
|
|
93105
|
-
}
|
|
93106
93131
|
let response;
|
|
93107
93132
|
try {
|
|
93108
|
-
response = await
|
|
93133
|
+
response = await kiroManagementFetch(url, auth, method, body);
|
|
93109
93134
|
} catch (error) {
|
|
93110
93135
|
throw new Error(`Kiro management ${operation} request failed in ${auth.region}`, { cause: error });
|
|
93111
93136
|
}
|
|
@@ -93257,21 +93282,9 @@ async function fetchKiroModelCatalog(auth, providedProfileArn) {
|
|
|
93257
93282
|
async function getUsageLimits(auth, request) {
|
|
93258
93283
|
const operation = "GetUsageLimits";
|
|
93259
93284
|
const url = new URL("Get-Usage-Limits", getKiroEndpoints(auth.region).management);
|
|
93260
|
-
for (const [name, value] of Object.entries(request)) {
|
|
93261
|
-
if (value !== void 0)
|
|
93262
|
-
url.searchParams.set(name, String(value));
|
|
93263
|
-
}
|
|
93264
93285
|
let response;
|
|
93265
93286
|
try {
|
|
93266
|
-
response = await
|
|
93267
|
-
method: "GET",
|
|
93268
|
-
headers: {
|
|
93269
|
-
Accept: "application/json",
|
|
93270
|
-
...kiroAuthHeaders(auth.accessToken),
|
|
93271
|
-
...kiroTokenTypeHeaders(auth.accessToken),
|
|
93272
|
-
"User-Agent": "ns-kiro-provider"
|
|
93273
|
-
}
|
|
93274
|
-
});
|
|
93287
|
+
response = await kiroManagementFetch(url, auth, "GET", request);
|
|
93275
93288
|
} catch (error) {
|
|
93276
93289
|
throw new Error(`Kiro management ${operation} request failed in ${auth.region}`, { cause: error });
|
|
93277
93290
|
}
|
|
@@ -93283,8 +93296,8 @@ var init_management = __esm({
|
|
|
93283
93296
|
"use strict";
|
|
93284
93297
|
init_debug();
|
|
93285
93298
|
init_endpoints();
|
|
93299
|
+
init_http();
|
|
93286
93300
|
init_oauth();
|
|
93287
|
-
init_token_type();
|
|
93288
93301
|
LIST_PROFILES_PATH = "List-Available-Profiles";
|
|
93289
93302
|
LIST_MODELS_PATH = "List-Available-Models";
|
|
93290
93303
|
API_KEY_REGION2 = "us-east-1";
|
|
@@ -93351,6 +93364,11 @@ function lazyOAuth(input) {
|
|
|
93351
93364
|
// ../bridge-core/dist/types.js
|
|
93352
93365
|
var BRIDGE_EFFORT_ORDER = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
93353
93366
|
|
|
93367
|
+
// ../bridge-core/dist/effort.js
|
|
93368
|
+
var EFFORTS = {};
|
|
93369
|
+
for (const level of BRIDGE_EFFORT_ORDER)
|
|
93370
|
+
EFFORTS[level] = true;
|
|
93371
|
+
|
|
93354
93372
|
// ../bridge-core/dist/pi/models.js
|
|
93355
93373
|
function toPiThinkingLevelMap(efforts) {
|
|
93356
93374
|
if (!efforts?.length)
|
|
@@ -93361,7 +93379,28 @@ function toPiThinkingLevelMap(efforts) {
|
|
|
93361
93379
|
map[level] = supported.has(level) ? level : null;
|
|
93362
93380
|
return map;
|
|
93363
93381
|
}
|
|
93364
|
-
|
|
93382
|
+
|
|
93383
|
+
// ../core-utils/dist/cache.js
|
|
93384
|
+
import { randomUUID } from "node:crypto";
|
|
93385
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
93386
|
+
import { dirname } from "node:path";
|
|
93387
|
+
function readJsonFile(path6) {
|
|
93388
|
+
try {
|
|
93389
|
+
return JSON.parse(readFileSync(path6, "utf8"));
|
|
93390
|
+
} catch {
|
|
93391
|
+
return void 0;
|
|
93392
|
+
}
|
|
93393
|
+
}
|
|
93394
|
+
function writeJsonFileAtomic(path6, value, options = {}) {
|
|
93395
|
+
const temporaryPath = `${path6}.${process.pid}.${randomUUID()}.tmp`;
|
|
93396
|
+
try {
|
|
93397
|
+
mkdirSync(dirname(path6), { recursive: true });
|
|
93398
|
+
writeFileSync(temporaryPath, JSON.stringify(value, null, options.pretty ? 2 : void 0), "utf8");
|
|
93399
|
+
renameSync(temporaryPath, path6);
|
|
93400
|
+
} finally {
|
|
93401
|
+
rmSync(temporaryPath, { force: true });
|
|
93402
|
+
}
|
|
93403
|
+
}
|
|
93365
93404
|
|
|
93366
93405
|
// ../devin-core/dist/util.js
|
|
93367
93406
|
function isRecord(value) {
|
|
@@ -95847,9 +95886,9 @@ var MAX_CONNECT_FRAME_PAYLOAD = 16 * 1024 * 1024;
|
|
|
95847
95886
|
var LARGE_HISTORY_RECOVERY_BYTES = 512 * 1024;
|
|
95848
95887
|
|
|
95849
95888
|
// ../devin-core/dist/credentials.js
|
|
95850
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
95889
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
95851
95890
|
import { homedir } from "node:os";
|
|
95852
|
-
import { dirname, join } from "node:path";
|
|
95891
|
+
import { dirname as dirname2, join } from "node:path";
|
|
95853
95892
|
|
|
95854
95893
|
// ../devin-core/dist/oauth.js
|
|
95855
95894
|
var FALLBACK_EXPIRES_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
@@ -95862,28 +95901,40 @@ function devinCredentialsPath() {
|
|
|
95862
95901
|
const dataHome = process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
95863
95902
|
return join(dataHome, "devin", "credentials.toml");
|
|
95864
95903
|
}
|
|
95904
|
+
var TOKEN_FIELDS = ["windsurf_api_key", "session_token", "access_token", "api_key", "token"];
|
|
95865
95905
|
function parseCredentialsToml(text) {
|
|
95866
95906
|
const out = {};
|
|
95867
95907
|
for (const line of text.split("\n")) {
|
|
95868
95908
|
const trimmed = line.trim();
|
|
95869
95909
|
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("["))
|
|
95870
95910
|
continue;
|
|
95871
|
-
const match2 = /^([\w.-]+)\s*=\s*"(.*)"\s*$/.exec(trimmed);
|
|
95872
|
-
|
|
95911
|
+
const match2 = /^([\w.-]+)\s*=\s*(?:"(.*)"|'(.*)')\s*$/.exec(trimmed);
|
|
95912
|
+
const key = match2?.[1];
|
|
95913
|
+
const value = match2?.[2] ?? match2?.[3];
|
|
95914
|
+
if (!key || value === void 0)
|
|
95873
95915
|
continue;
|
|
95874
|
-
out[
|
|
95916
|
+
out[key] = value.replace(/\\(["\\])/g, "$1");
|
|
95875
95917
|
}
|
|
95876
95918
|
return out;
|
|
95877
95919
|
}
|
|
95920
|
+
function devinTokenFromToml(text) {
|
|
95921
|
+
const fields = parseCredentialsToml(text);
|
|
95922
|
+
for (const name of TOKEN_FIELDS) {
|
|
95923
|
+
const value = fields[name]?.trim();
|
|
95924
|
+
if (value)
|
|
95925
|
+
return value;
|
|
95926
|
+
}
|
|
95927
|
+
return void 0;
|
|
95928
|
+
}
|
|
95878
95929
|
function resolveDevinCredentials() {
|
|
95879
95930
|
let text;
|
|
95880
95931
|
try {
|
|
95881
|
-
text =
|
|
95932
|
+
text = readFileSync2(devinCredentialsPath(), "utf8");
|
|
95882
95933
|
} catch {
|
|
95883
95934
|
return void 0;
|
|
95884
95935
|
}
|
|
95885
95936
|
const fields = parseCredentialsToml(text);
|
|
95886
|
-
const apiKey =
|
|
95937
|
+
const apiKey = TOKEN_FIELDS.map((name) => fields[name]?.trim()).find((value) => value);
|
|
95887
95938
|
if (!apiKey)
|
|
95888
95939
|
return void 0;
|
|
95889
95940
|
const trimUrl = (value) => {
|
|
@@ -96240,9 +96291,9 @@ function normalizeDevinModels(configs, baseUrlOverride) {
|
|
|
96240
96291
|
}
|
|
96241
96292
|
|
|
96242
96293
|
// ../devin-core/dist/models.js
|
|
96243
|
-
import {
|
|
96294
|
+
import { statSync } from "node:fs";
|
|
96244
96295
|
import { homedir as homedir2 } from "node:os";
|
|
96245
|
-
import {
|
|
96296
|
+
import { join as join2 } from "node:path";
|
|
96246
96297
|
var devinModels = [
|
|
96247
96298
|
{
|
|
96248
96299
|
id: "swe-1-6",
|
|
@@ -96285,7 +96336,7 @@ function loadCacheFile() {
|
|
|
96285
96336
|
const mtimeMs = statSync(devinModelCachePath()).mtimeMs;
|
|
96286
96337
|
if (mtimeMs !== cacheMtimeMs) {
|
|
96287
96338
|
cacheMtimeMs = mtimeMs;
|
|
96288
|
-
const parsed =
|
|
96339
|
+
const parsed = readJsonFile(devinModelCachePath());
|
|
96289
96340
|
cacheFile = typeof parsed === "object" && parsed !== null && Array.isArray(parsed.models) && typeof parsed.fetchedAt === "number" ? parsed : void 0;
|
|
96290
96341
|
}
|
|
96291
96342
|
} catch {
|
|
@@ -96304,8 +96355,7 @@ function isCacheStale(now = Date.now()) {
|
|
|
96304
96355
|
function updateDevinModelsCache(models, now = Date.now()) {
|
|
96305
96356
|
cacheFile = { fetchedAt: now, models };
|
|
96306
96357
|
try {
|
|
96307
|
-
|
|
96308
|
-
writeFileSync2(devinModelCachePath(), JSON.stringify(cacheFile), "utf8");
|
|
96358
|
+
writeJsonFileAtomic(devinModelCachePath(), cacheFile);
|
|
96309
96359
|
cacheMtimeMs = statSync(devinModelCachePath()).mtimeMs;
|
|
96310
96360
|
} catch {
|
|
96311
96361
|
}
|
|
@@ -96331,11 +96381,6 @@ function toPiDevinModel(spec) {
|
|
|
96331
96381
|
...thinkingLevelMap ? { thinkingLevelMap } : {}
|
|
96332
96382
|
};
|
|
96333
96383
|
}
|
|
96334
|
-
var DEVIN_TOML_TOKEN_RE = /(?:windsurf_api_key|session_token|access_token|api_key|token)\s*=\s*(?:"([^"]+)"|'([^']+)')/i;
|
|
96335
|
-
function parseDevinCredentialsToml(text) {
|
|
96336
|
-
const match2 = text.match(DEVIN_TOML_TOKEN_RE);
|
|
96337
|
-
return match2?.[1] || match2?.[2] || void 0;
|
|
96338
|
-
}
|
|
96339
96384
|
function resolveDevinToken(env3 = process.env, options = {}) {
|
|
96340
96385
|
const fromEnv = env3.DEVIN_API_KEY?.trim() || env3.DEVIN_SESSION_TOKEN?.trim() || env3.WINDSURF_API_KEY?.trim();
|
|
96341
96386
|
if (fromEnv) return fromEnv;
|
|
@@ -96344,7 +96389,7 @@ function resolveDevinToken(env3 = process.env, options = {}) {
|
|
|
96344
96389
|
for (const path6 of options.paths) {
|
|
96345
96390
|
if (!existsSync(path6)) continue;
|
|
96346
96391
|
try {
|
|
96347
|
-
const token =
|
|
96392
|
+
const token = devinTokenFromToml(readFileSync3(path6, "utf8"));
|
|
96348
96393
|
if (token) return token;
|
|
96349
96394
|
} catch {
|
|
96350
96395
|
}
|
|
@@ -96371,6 +96416,24 @@ async function refreshDevinModels(options = {}) {
|
|
|
96371
96416
|
return { models: getCachedModels().map(toPiDevinModel), fromCache };
|
|
96372
96417
|
}
|
|
96373
96418
|
|
|
96419
|
+
// ../grok-core/dist/catalog.js
|
|
96420
|
+
var GROK_BOOTSTRAP_MODEL_IDS = ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"];
|
|
96421
|
+
var GROK_DEFAULT_CONTEXT_WINDOW = 5e5;
|
|
96422
|
+
var GROK_DEFAULT_MAX_TOKENS = 128e3;
|
|
96423
|
+
var GROK_CATALOG_PROVIDER_ID = "grok";
|
|
96424
|
+
var GROK_DEFAULT_MODEL_ID = "grok-4.5";
|
|
96425
|
+
var GROK_CATALOG_FILE = `${GROK_CATALOG_PROVIDER_ID}.models.json`;
|
|
96426
|
+
function grokBootstrapModels() {
|
|
96427
|
+
return GROK_BOOTSTRAP_MODEL_IDS.map((id) => ({
|
|
96428
|
+
id,
|
|
96429
|
+
name: id,
|
|
96430
|
+
contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96431
|
+
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96432
|
+
reasoning: true,
|
|
96433
|
+
input: ["text"]
|
|
96434
|
+
}));
|
|
96435
|
+
}
|
|
96436
|
+
|
|
96374
96437
|
// ../pi-provider/src/shared/types.ts
|
|
96375
96438
|
function ensureCacheCost(cost) {
|
|
96376
96439
|
return {
|
|
@@ -96382,7 +96445,7 @@ function ensureCacheCost(cost) {
|
|
|
96382
96445
|
}
|
|
96383
96446
|
|
|
96384
96447
|
// ../pi-provider/src/shared/catalog-cache.ts
|
|
96385
|
-
import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync3, existsSync as existsSync2 } from "node:fs";
|
|
96448
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3, existsSync as existsSync2 } from "node:fs";
|
|
96386
96449
|
import { join as join3 } from "node:path";
|
|
96387
96450
|
import { homedir as homedir3 } from "node:os";
|
|
96388
96451
|
var DEFAULT_TTL_MS = 15 * 60 * 1e3;
|
|
@@ -96406,7 +96469,7 @@ var CatalogCache = class {
|
|
|
96406
96469
|
mkdirSync: options.fs?.mkdirSync ?? ((path6, opts) => {
|
|
96407
96470
|
mkdirSync3(path6, opts);
|
|
96408
96471
|
}),
|
|
96409
|
-
renameSync: options.fs?.renameSync ??
|
|
96472
|
+
renameSync: options.fs?.renameSync ?? renameSync2,
|
|
96410
96473
|
existsSync: options.fs?.existsSync ?? existsSync2
|
|
96411
96474
|
};
|
|
96412
96475
|
}
|
|
@@ -96522,12 +96585,13 @@ function getDefaultCatalogCache(options) {
|
|
|
96522
96585
|
return defaultCache;
|
|
96523
96586
|
}
|
|
96524
96587
|
|
|
96525
|
-
// ../
|
|
96588
|
+
// ../grok-core/dist/agent/binary.js
|
|
96589
|
+
import { execFile } from "node:child_process";
|
|
96526
96590
|
import { accessSync, constants } from "node:fs";
|
|
96527
|
-
import { execFileSync } from "node:child_process";
|
|
96528
96591
|
import { homedir as homedir4 } from "node:os";
|
|
96529
96592
|
import { join as join4 } from "node:path";
|
|
96530
96593
|
var CANDIDATE_NAMES = ["agent", "grok"];
|
|
96594
|
+
var BINARY_ENV_NAMES = ["GROK_AGENT_BIN", "GROK_BIN", "PI_GROK_SDK_BIN", "PI_GROK_AGENT_BIN"];
|
|
96531
96595
|
function isExecutable(path6) {
|
|
96532
96596
|
try {
|
|
96533
96597
|
accessSync(path6, constants.X_OK);
|
|
@@ -96536,59 +96600,44 @@ function isExecutable(path6) {
|
|
|
96536
96600
|
return false;
|
|
96537
96601
|
}
|
|
96538
96602
|
}
|
|
96539
|
-
function
|
|
96540
|
-
|
|
96541
|
-
|
|
96542
|
-
|
|
96543
|
-
|
|
96544
|
-
|
|
96545
|
-
|
|
96546
|
-
|
|
96547
|
-
|
|
96548
|
-
|
|
96603
|
+
function run(command, args, timeout) {
|
|
96604
|
+
return new Promise((resolve2) => {
|
|
96605
|
+
execFile(command, args, { encoding: "utf8", timeout }, (error, stdout) => {
|
|
96606
|
+
resolve2(error ? void 0 : stdout);
|
|
96607
|
+
});
|
|
96608
|
+
});
|
|
96609
|
+
}
|
|
96610
|
+
async function which(name) {
|
|
96611
|
+
const out = await run(process.platform === "win32" ? "where" : "which", [name], 5e3);
|
|
96612
|
+
if (out === void 0)
|
|
96549
96613
|
return void 0;
|
|
96550
|
-
|
|
96614
|
+
const first = out.trim().split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
96615
|
+
return first && isExecutable(first) ? first : void 0;
|
|
96551
96616
|
}
|
|
96552
|
-
function resolveGrokBinary(env3 = process.env) {
|
|
96553
|
-
const explicit =
|
|
96617
|
+
async function resolveGrokBinary(env3 = process.env) {
|
|
96618
|
+
const explicit = BINARY_ENV_NAMES.map((name) => env3[name]?.trim()).find(Boolean);
|
|
96554
96619
|
if (explicit) {
|
|
96555
96620
|
if (!isExecutable(explicit)) {
|
|
96556
|
-
throw new Error(
|
|
96557
|
-
`Configured Grok agent binary is not executable: ${explicit}. Check PI_GROK_SDK_BIN / PI_GROK_AGENT_BIN / GROK_AGENT_BIN.`
|
|
96558
|
-
);
|
|
96621
|
+
throw new Error(`Configured Grok agent binary is not executable: ${explicit}. Check ${BINARY_ENV_NAMES.join(" / ")}.`);
|
|
96559
96622
|
}
|
|
96560
96623
|
return explicit;
|
|
96561
96624
|
}
|
|
96562
96625
|
for (const name of CANDIDATE_NAMES) {
|
|
96563
|
-
const found = which(name);
|
|
96564
|
-
if (found)
|
|
96626
|
+
const found = await which(name);
|
|
96627
|
+
if (found)
|
|
96628
|
+
return found;
|
|
96565
96629
|
}
|
|
96566
96630
|
const homeBin = join4(homedir4(), ".grok", "bin");
|
|
96567
96631
|
for (const name of CANDIDATE_NAMES) {
|
|
96568
96632
|
const candidate = join4(homeBin, name);
|
|
96569
|
-
if (isExecutable(candidate))
|
|
96633
|
+
if (isExecutable(candidate))
|
|
96634
|
+
return candidate;
|
|
96570
96635
|
}
|
|
96571
|
-
throw new Error(
|
|
96572
|
-
"Grok agent CLI not found. Install/authenticate the xAI Grok agent (`agent` or `grok` on PATH, or ~/.grok/bin). Then run: agent --version"
|
|
96573
|
-
);
|
|
96636
|
+
throw new Error("Grok agent CLI not found. Install/authenticate the xAI Grok agent (`agent` or `grok` on PATH, or ~/.grok/bin). Then run: agent --version");
|
|
96574
96637
|
}
|
|
96575
96638
|
|
|
96576
|
-
// ../
|
|
96577
|
-
|
|
96578
|
-
var THINKING_LEVEL_MAP = {
|
|
96579
|
-
off: "none",
|
|
96580
|
-
minimal: "minimal",
|
|
96581
|
-
low: "low",
|
|
96582
|
-
medium: "medium",
|
|
96583
|
-
high: "high",
|
|
96584
|
-
xhigh: "xhigh",
|
|
96585
|
-
max: "max"
|
|
96586
|
-
};
|
|
96587
|
-
var DEFAULT_CONTEXT_WINDOW2 = 5e5;
|
|
96588
|
-
var DEFAULT_MAX_TOKENS2 = 128e3;
|
|
96589
|
-
|
|
96590
|
-
// ../pi-provider/src/grok/models.ts
|
|
96591
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
96639
|
+
// ../grok-core/dist/agent/models.js
|
|
96640
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
96592
96641
|
function parseGrokModelsOutput(stdout) {
|
|
96593
96642
|
const models = [];
|
|
96594
96643
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -96603,8 +96652,8 @@ function parseGrokModelsOutput(stdout) {
|
|
|
96603
96652
|
models.push({
|
|
96604
96653
|
id,
|
|
96605
96654
|
name: id,
|
|
96606
|
-
contextWindow:
|
|
96607
|
-
maxTokens:
|
|
96655
|
+
contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96656
|
+
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96608
96657
|
supportsReasoningEffort: true
|
|
96609
96658
|
});
|
|
96610
96659
|
}
|
|
@@ -96616,45 +96665,68 @@ function parseGrokModelsOutput(stdout) {
|
|
|
96616
96665
|
models.unshift({
|
|
96617
96666
|
id: d[1],
|
|
96618
96667
|
name: d[1],
|
|
96619
|
-
contextWindow:
|
|
96620
|
-
maxTokens:
|
|
96668
|
+
contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96669
|
+
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96621
96670
|
supportsReasoningEffort: true
|
|
96622
96671
|
});
|
|
96623
96672
|
}
|
|
96624
96673
|
}
|
|
96625
96674
|
return models;
|
|
96626
96675
|
}
|
|
96627
|
-
|
|
96628
|
-
function fallbackModels() {
|
|
96629
|
-
return BOOTSTRAP_MODEL_IDS.map((id) => ({
|
|
96630
|
-
id,
|
|
96631
|
-
name: id,
|
|
96632
|
-
contextWindow: DEFAULT_CONTEXT_WINDOW2,
|
|
96633
|
-
maxTokens: DEFAULT_MAX_TOKENS2,
|
|
96634
|
-
supportsReasoningEffort: true
|
|
96635
|
-
}));
|
|
96636
|
-
}
|
|
96637
|
-
function discoverModels(binary) {
|
|
96676
|
+
async function discoverGrokModels(binary) {
|
|
96638
96677
|
try {
|
|
96639
|
-
const bin = binary ?? resolveGrokBinary();
|
|
96640
|
-
const stdout =
|
|
96641
|
-
encoding: "utf8",
|
|
96642
|
-
|
|
96643
|
-
|
|
96678
|
+
const bin = binary ?? await resolveGrokBinary();
|
|
96679
|
+
const stdout = await new Promise((resolve2, reject) => {
|
|
96680
|
+
execFile2(bin, ["models"], { encoding: "utf8", timeout: 2e4 }, (error, out) => {
|
|
96681
|
+
if (error)
|
|
96682
|
+
reject(error);
|
|
96683
|
+
else
|
|
96684
|
+
resolve2(out);
|
|
96685
|
+
});
|
|
96644
96686
|
});
|
|
96645
96687
|
const parsed = parseGrokModelsOutput(stdout);
|
|
96646
96688
|
if (parsed.length === 0) {
|
|
96647
|
-
return { models:
|
|
96689
|
+
return { models: [], source: "fallback", error: "empty model list from CLI" };
|
|
96648
96690
|
}
|
|
96649
96691
|
return { models: parsed, source: "live" };
|
|
96650
96692
|
} catch (err) {
|
|
96651
96693
|
return {
|
|
96652
|
-
models:
|
|
96694
|
+
models: [],
|
|
96653
96695
|
source: "fallback",
|
|
96654
96696
|
error: err instanceof Error ? err.message : String(err)
|
|
96655
96697
|
};
|
|
96656
96698
|
}
|
|
96657
96699
|
}
|
|
96700
|
+
|
|
96701
|
+
// ../pi-provider/src/grok/config.ts
|
|
96702
|
+
var DEFAULT_MODEL_ID = GROK_DEFAULT_MODEL_ID;
|
|
96703
|
+
var THINKING_LEVEL_MAP = {
|
|
96704
|
+
off: "none",
|
|
96705
|
+
minimal: "minimal",
|
|
96706
|
+
low: "low",
|
|
96707
|
+
medium: "medium",
|
|
96708
|
+
high: "high",
|
|
96709
|
+
xhigh: "xhigh",
|
|
96710
|
+
max: "max"
|
|
96711
|
+
};
|
|
96712
|
+
var DEFAULT_CONTEXT_WINDOW2 = GROK_DEFAULT_CONTEXT_WINDOW;
|
|
96713
|
+
var DEFAULT_MAX_TOKENS2 = GROK_DEFAULT_MAX_TOKENS;
|
|
96714
|
+
|
|
96715
|
+
// ../pi-provider/src/grok/models.ts
|
|
96716
|
+
function fallbackModels() {
|
|
96717
|
+
return grokBootstrapModels().map((model) => ({
|
|
96718
|
+
id: model.id,
|
|
96719
|
+
name: model.name,
|
|
96720
|
+
contextWindow: model.contextWindow,
|
|
96721
|
+
maxTokens: model.maxTokens,
|
|
96722
|
+
supportsReasoningEffort: model.reasoning
|
|
96723
|
+
}));
|
|
96724
|
+
}
|
|
96725
|
+
async function discoverModels(binary) {
|
|
96726
|
+
const discovered = await discoverGrokModels(binary);
|
|
96727
|
+
if (discovered.source === "live") return discovered;
|
|
96728
|
+
return { ...discovered, models: fallbackModels() };
|
|
96729
|
+
}
|
|
96658
96730
|
function toProviderModel(d) {
|
|
96659
96731
|
return {
|
|
96660
96732
|
id: d.id,
|
|
@@ -98519,7 +98591,7 @@ function catalogToProviderModels(models) {
|
|
|
98519
98591
|
cost: ensureCacheCost(models[i2]?.cost ?? m2.cost)
|
|
98520
98592
|
}));
|
|
98521
98593
|
}
|
|
98522
|
-
function refreshGrokModels(options = {}) {
|
|
98594
|
+
async function refreshGrokModels(options = {}) {
|
|
98523
98595
|
const cache = options.cache ?? getDefaultCatalogCache();
|
|
98524
98596
|
if (!options.force) {
|
|
98525
98597
|
const lookup = cache.lookup(GROK_PROVIDER_ID);
|
|
@@ -98554,11 +98626,11 @@ function refreshGrokModels(options = {}) {
|
|
|
98554
98626
|
}
|
|
98555
98627
|
let binary = options.binary;
|
|
98556
98628
|
try {
|
|
98557
|
-
binary ??= resolveGrokBinary();
|
|
98629
|
+
binary ??= await resolveGrokBinary();
|
|
98558
98630
|
} catch {
|
|
98559
98631
|
binary = void 0;
|
|
98560
98632
|
}
|
|
98561
|
-
const discovered = discoverModels(binary);
|
|
98633
|
+
const discovered = await discoverModels(binary);
|
|
98562
98634
|
const catalog = descriptorsToCatalog(discovered.models);
|
|
98563
98635
|
cache.store(GROK_PROVIDER_ID, catalog, { version: "grok-cli-v1" });
|
|
98564
98636
|
return {
|
|
@@ -98570,6 +98642,100 @@ function refreshGrokModels(options = {}) {
|
|
|
98570
98642
|
|
|
98571
98643
|
// ../kiro-core/dist/index.js
|
|
98572
98644
|
init_debug();
|
|
98645
|
+
init_endpoints();
|
|
98646
|
+
|
|
98647
|
+
// ../kiro-core/dist/retry.js
|
|
98648
|
+
var KIRO_REASON_CODES = Object.freeze({
|
|
98649
|
+
/** Request body exceeded the service's size threshold. */
|
|
98650
|
+
CONTENT_LENGTH_EXCEEDS_THRESHOLD: "CONTENT_LENGTH_EXCEEDS_THRESHOLD",
|
|
98651
|
+
/** Prose-only size rejection; the service sends no reason code for this one. */
|
|
98652
|
+
INPUT_TOO_LONG: "Input is too long",
|
|
98653
|
+
/** Monthly request quota exhausted — hard limit, not transient. */
|
|
98654
|
+
MONTHLY_REQUEST_COUNT: "MONTHLY_REQUEST_COUNT",
|
|
98655
|
+
/** Model capacity temporarily unavailable — transient, worth retrying. */
|
|
98656
|
+
INSUFFICIENT_MODEL_CAPACITY: "INSUFFICIENT_MODEL_CAPACITY",
|
|
98657
|
+
/** Short-window request throttle — retry only within the provider budget. */
|
|
98658
|
+
USER_REQUEST_RATE_EXCEEDED: "USER_REQUEST_RATE_EXCEEDED",
|
|
98659
|
+
/**
|
|
98660
|
+
* Generic request-validation rejection, returned for a malformed body of any
|
|
98661
|
+
* size (empty `content`, history referencing tools absent from the catalog).
|
|
98662
|
+
* Not a size signal: classifying it as "too big" makes the caller compact a
|
|
98663
|
+
* history that was never the problem, a loop it can never satisfy.
|
|
98664
|
+
*/
|
|
98665
|
+
REQUEST_BODY_INVALID: "REQUEST_BODY_INVALID"
|
|
98666
|
+
});
|
|
98667
|
+
var TOO_BIG_PATTERNS = Object.freeze([
|
|
98668
|
+
KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
|
|
98669
|
+
KIRO_REASON_CODES.INPUT_TOO_LONG
|
|
98670
|
+
]);
|
|
98671
|
+
var NON_RETRYABLE_BODY_PATTERNS = Object.freeze([KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT]);
|
|
98672
|
+
var CAPACITY_PATTERN = KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY;
|
|
98673
|
+
|
|
98674
|
+
// ../kiro-core/dist/errors.js
|
|
98675
|
+
var REASON_CODE_MARKERS = [
|
|
98676
|
+
KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
|
|
98677
|
+
KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT,
|
|
98678
|
+
KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY,
|
|
98679
|
+
KIRO_REASON_CODES.REQUEST_BODY_INVALID
|
|
98680
|
+
];
|
|
98681
|
+
|
|
98682
|
+
// ../kiro-core/dist/event-parser.js
|
|
98683
|
+
var KIRO_EVENT_KEYS = [
|
|
98684
|
+
"assistantResponseEvent",
|
|
98685
|
+
"codeReferenceEvent",
|
|
98686
|
+
"contextUsageEvent",
|
|
98687
|
+
"documentCitationEvent",
|
|
98688
|
+
"error",
|
|
98689
|
+
"metadataEvent",
|
|
98690
|
+
"meteringEvent",
|
|
98691
|
+
"reasoningContentEvent",
|
|
98692
|
+
"serviceUnavailableError",
|
|
98693
|
+
"throttlingError",
|
|
98694
|
+
"toolResultEvent",
|
|
98695
|
+
"toolUseEvent",
|
|
98696
|
+
"validationError"
|
|
98697
|
+
];
|
|
98698
|
+
var KIRO_EVENT_KEY_SET = new Set(KIRO_EVENT_KEYS);
|
|
98699
|
+
var KIRO_ERROR_MEMBERS = {
|
|
98700
|
+
error: { kind: "internalServer", exception: "InternalServerException" },
|
|
98701
|
+
throttlingError: { kind: "throttling", exception: "ThrottlingException" },
|
|
98702
|
+
validationError: { kind: "validation", exception: "ValidationException" },
|
|
98703
|
+
serviceUnavailableError: { kind: "serviceUnavailable", exception: "ServiceUnavailableException" }
|
|
98704
|
+
};
|
|
98705
|
+
var KIRO_ERROR_TOKENS = {
|
|
98706
|
+
...KIRO_ERROR_MEMBERS,
|
|
98707
|
+
InternalServerException: KIRO_ERROR_MEMBERS.error,
|
|
98708
|
+
ThrottlingException: KIRO_ERROR_MEMBERS.throttlingError,
|
|
98709
|
+
ValidationException: KIRO_ERROR_MEMBERS.validationError,
|
|
98710
|
+
ServiceUnavailableException: KIRO_ERROR_MEMBERS.serviceUnavailableError
|
|
98711
|
+
};
|
|
98712
|
+
|
|
98713
|
+
// ../kiro-core/dist/host-auth.js
|
|
98714
|
+
init_endpoints();
|
|
98715
|
+
init_oauth();
|
|
98716
|
+
async function resolveKiroRequestCredentials(hostKey) {
|
|
98717
|
+
const stored = await resolveKiroCredentials();
|
|
98718
|
+
const region = resolveApiRegion(stored?.region);
|
|
98719
|
+
if (hostKey && (isApiKey(hostKey) || hostKey === stored?.access)) {
|
|
98720
|
+
return { accessToken: hostKey, region, ...stored?.profileArn ? { profileArn: stored.profileArn } : {} };
|
|
98721
|
+
}
|
|
98722
|
+
if (stored) {
|
|
98723
|
+
return {
|
|
98724
|
+
accessToken: stored.access,
|
|
98725
|
+
region,
|
|
98726
|
+
...stored.profileArn ? { profileArn: stored.profileArn } : {}
|
|
98727
|
+
};
|
|
98728
|
+
}
|
|
98729
|
+
if (hostKey)
|
|
98730
|
+
return { accessToken: hostKey, region };
|
|
98731
|
+
throw new Error("Kiro credentials not set. Run `kiro-cli login`, or set KIRO_API_KEY to a `ksk_` API key.");
|
|
98732
|
+
}
|
|
98733
|
+
|
|
98734
|
+
// ../kiro-core/dist/models.js
|
|
98735
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
98736
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
98737
|
+
import { homedir as homedir8 } from "node:os";
|
|
98738
|
+
import { join as join9 } from "node:path";
|
|
98573
98739
|
|
|
98574
98740
|
// ../kiro-core/dist/types.js
|
|
98575
98741
|
var KIRO_EFFORT_ORDER = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -98633,14 +98799,7 @@ function getKiroEffortConfig(schema, kiroModelId) {
|
|
|
98633
98799
|
return fallbackKiroEffort(kiroModelId);
|
|
98634
98800
|
}
|
|
98635
98801
|
|
|
98636
|
-
// ../kiro-core/dist/index.js
|
|
98637
|
-
init_endpoints();
|
|
98638
|
-
|
|
98639
98802
|
// ../kiro-core/dist/models.js
|
|
98640
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
98641
|
-
import { existsSync as existsSync5, readFileSync as readFileSync6, renameSync as renameSync2, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
98642
|
-
import { homedir as homedir8 } from "node:os";
|
|
98643
|
-
import { join as join9 } from "node:path";
|
|
98644
98803
|
init_endpoints();
|
|
98645
98804
|
var KIRO_MANAGEMENT_CACHE_VERSION = 1;
|
|
98646
98805
|
var KIRO_MANAGEMENT_CACHE_SOURCE = "ns-kiro-provider-management";
|
|
@@ -98923,12 +99082,12 @@ function readManagementCache() {
|
|
|
98923
99082
|
}
|
|
98924
99083
|
}
|
|
98925
99084
|
function writeManagementCache(cache) {
|
|
98926
|
-
const temporaryPath = `${KIRO_MANAGEMENT_CACHE_PATH}.${process.pid}.${
|
|
99085
|
+
const temporaryPath = `${KIRO_MANAGEMENT_CACHE_PATH}.${process.pid}.${randomUUID3()}.tmp`;
|
|
98927
99086
|
try {
|
|
98928
99087
|
writeFileSync4(temporaryPath, JSON.stringify(cache, null, 2), "utf-8");
|
|
98929
|
-
|
|
99088
|
+
renameSync3(temporaryPath, KIRO_MANAGEMENT_CACHE_PATH);
|
|
98930
99089
|
} finally {
|
|
98931
|
-
|
|
99090
|
+
rmSync2(temporaryPath, { force: true });
|
|
98932
99091
|
}
|
|
98933
99092
|
}
|
|
98934
99093
|
function toLocalModelId(kiroModelId) {
|
|
@@ -99046,10 +99205,6 @@ function isCacheStale2(region) {
|
|
|
99046
99205
|
return !entry || Date.now() - entry.fetchedAt > CACHE_MAX_AGE_MS;
|
|
99047
99206
|
}
|
|
99048
99207
|
async function updateKiroModelsCache(accessToken, region, profileArn) {
|
|
99049
|
-
await updateKiroModelsCacheInProcess(accessToken, region, profileArn);
|
|
99050
|
-
refreshKnownModelIds(readManagementCache());
|
|
99051
|
-
}
|
|
99052
|
-
async function updateKiroModelsCacheInProcess(accessToken, region, profileArn) {
|
|
99053
99208
|
const { fetchKiroModelCatalog: fetchKiroModelCatalog2 } = await Promise.resolve().then(() => (init_management(), management_exports));
|
|
99054
99209
|
const { getKiroCliModelRates: getKiroCliModelRates2 } = await Promise.resolve().then(() => (init_kiro_cli(), kiro_cli_exports));
|
|
99055
99210
|
const response = await fetchKiroModelCatalog2({ accessToken, region }, profileArn);
|
|
@@ -99064,71 +99219,15 @@ async function updateKiroModelsCacheInProcess(accessToken, region, profileArn) {
|
|
|
99064
99219
|
refreshKnownModelIds(cache);
|
|
99065
99220
|
}
|
|
99066
99221
|
|
|
99067
|
-
// ../kiro-core/dist/
|
|
99068
|
-
|
|
99069
|
-
|
|
99070
|
-
CONTENT_LENGTH_EXCEEDS_THRESHOLD: "CONTENT_LENGTH_EXCEEDS_THRESHOLD",
|
|
99071
|
-
/** Prose-only size rejection; the service sends no reason code for this one. */
|
|
99072
|
-
INPUT_TOO_LONG: "Input is too long",
|
|
99073
|
-
/** Monthly request quota exhausted — hard limit, not transient. */
|
|
99074
|
-
MONTHLY_REQUEST_COUNT: "MONTHLY_REQUEST_COUNT",
|
|
99075
|
-
/** Model capacity temporarily unavailable — transient, worth retrying. */
|
|
99076
|
-
INSUFFICIENT_MODEL_CAPACITY: "INSUFFICIENT_MODEL_CAPACITY",
|
|
99077
|
-
/** Short-window request throttle — retry only within the provider budget. */
|
|
99078
|
-
USER_REQUEST_RATE_EXCEEDED: "USER_REQUEST_RATE_EXCEEDED",
|
|
99079
|
-
/**
|
|
99080
|
-
* Generic request-validation rejection, returned for a malformed body of any
|
|
99081
|
-
* size (empty `content`, history referencing tools absent from the catalog).
|
|
99082
|
-
* Not a size signal: classifying it as "too big" makes the caller compact a
|
|
99083
|
-
* history that was never the problem, a loop it can never satisfy.
|
|
99084
|
-
*/
|
|
99085
|
-
REQUEST_BODY_INVALID: "REQUEST_BODY_INVALID"
|
|
99086
|
-
});
|
|
99087
|
-
var TOO_BIG_PATTERNS = Object.freeze([
|
|
99088
|
-
KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
|
|
99089
|
-
KIRO_REASON_CODES.INPUT_TOO_LONG
|
|
99090
|
-
]);
|
|
99091
|
-
var NON_RETRYABLE_BODY_PATTERNS = Object.freeze([KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT]);
|
|
99092
|
-
var CAPACITY_PATTERN = KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY;
|
|
99222
|
+
// ../kiro-core/dist/index.js
|
|
99223
|
+
init_kiro_cli();
|
|
99224
|
+
init_oauth();
|
|
99093
99225
|
|
|
99094
|
-
// ../kiro-core/dist/
|
|
99095
|
-
|
|
99096
|
-
KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
|
|
99097
|
-
KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT,
|
|
99098
|
-
KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY,
|
|
99099
|
-
KIRO_REASON_CODES.REQUEST_BODY_INVALID
|
|
99100
|
-
];
|
|
99226
|
+
// ../kiro-core/dist/request-builder.js
|
|
99227
|
+
init_debug();
|
|
99101
99228
|
|
|
99102
|
-
// ../kiro-core/dist/
|
|
99103
|
-
var
|
|
99104
|
-
"assistantResponseEvent",
|
|
99105
|
-
"codeReferenceEvent",
|
|
99106
|
-
"contextUsageEvent",
|
|
99107
|
-
"documentCitationEvent",
|
|
99108
|
-
"error",
|
|
99109
|
-
"metadataEvent",
|
|
99110
|
-
"meteringEvent",
|
|
99111
|
-
"reasoningContentEvent",
|
|
99112
|
-
"serviceUnavailableError",
|
|
99113
|
-
"throttlingError",
|
|
99114
|
-
"toolResultEvent",
|
|
99115
|
-
"toolUseEvent",
|
|
99116
|
-
"validationError"
|
|
99117
|
-
];
|
|
99118
|
-
var KIRO_EVENT_KEY_SET = new Set(KIRO_EVENT_KEYS);
|
|
99119
|
-
var KIRO_ERROR_MEMBERS = {
|
|
99120
|
-
error: { kind: "internalServer", exception: "InternalServerException" },
|
|
99121
|
-
throttlingError: { kind: "throttling", exception: "ThrottlingException" },
|
|
99122
|
-
validationError: { kind: "validation", exception: "ValidationException" },
|
|
99123
|
-
serviceUnavailableError: { kind: "serviceUnavailable", exception: "ServiceUnavailableException" }
|
|
99124
|
-
};
|
|
99125
|
-
var KIRO_ERROR_TOKENS = {
|
|
99126
|
-
...KIRO_ERROR_MEMBERS,
|
|
99127
|
-
InternalServerException: KIRO_ERROR_MEMBERS.error,
|
|
99128
|
-
ThrottlingException: KIRO_ERROR_MEMBERS.throttlingError,
|
|
99129
|
-
ValidationException: KIRO_ERROR_MEMBERS.validationError,
|
|
99130
|
-
ServiceUnavailableException: KIRO_ERROR_MEMBERS.serviceUnavailableError
|
|
99131
|
-
};
|
|
99229
|
+
// ../kiro-core/dist/history.js
|
|
99230
|
+
var HISTORY_IMAGE_BASE64_LIMIT = 512 * 1024;
|
|
99132
99231
|
|
|
99133
99232
|
// ../kiro-core/dist/history-validator.js
|
|
99134
99233
|
var KiroValidationRule;
|
|
@@ -99156,39 +99255,6 @@ var KIRO_TOOL_STRUCTURE_RULES = [
|
|
|
99156
99255
|
KiroValidationRule.TOOL_RESULTS_ORPHAN_IDS
|
|
99157
99256
|
];
|
|
99158
99257
|
|
|
99159
|
-
// ../kiro-core/dist/host-auth.js
|
|
99160
|
-
init_endpoints();
|
|
99161
|
-
init_oauth();
|
|
99162
|
-
async function resolveKiroRequestCredentials(hostKey) {
|
|
99163
|
-
const stored = await resolveKiroCredentials();
|
|
99164
|
-
const region = resolveApiRegion(stored?.region);
|
|
99165
|
-
if (hostKey && (isApiKey(hostKey) || hostKey === stored?.access)) {
|
|
99166
|
-
return { accessToken: hostKey, region, ...stored?.profileArn ? { profileArn: stored.profileArn } : {} };
|
|
99167
|
-
}
|
|
99168
|
-
if (stored) {
|
|
99169
|
-
return {
|
|
99170
|
-
accessToken: stored.access,
|
|
99171
|
-
region,
|
|
99172
|
-
...stored.profileArn ? { profileArn: stored.profileArn } : {}
|
|
99173
|
-
};
|
|
99174
|
-
}
|
|
99175
|
-
if (hostKey)
|
|
99176
|
-
return { accessToken: hostKey, region };
|
|
99177
|
-
throw new Error("Kiro credentials not set. Run `kiro-cli login`, or set KIRO_API_KEY to a `ksk_` API key.");
|
|
99178
|
-
}
|
|
99179
|
-
|
|
99180
|
-
// ../kiro-core/dist/index.js
|
|
99181
|
-
init_kiro_cli();
|
|
99182
|
-
init_kiro_ide();
|
|
99183
|
-
init_management();
|
|
99184
|
-
init_oauth();
|
|
99185
|
-
|
|
99186
|
-
// ../kiro-core/dist/request-builder.js
|
|
99187
|
-
init_debug();
|
|
99188
|
-
|
|
99189
|
-
// ../kiro-core/dist/history.js
|
|
99190
|
-
var HISTORY_IMAGE_BASE64_LIMIT = 512 * 1024;
|
|
99191
|
-
|
|
99192
99258
|
// ../kiro-core/dist/response-assembler.js
|
|
99193
99259
|
init_debug();
|
|
99194
99260
|
|
|
@@ -99201,10 +99267,14 @@ init_debug();
|
|
|
99201
99267
|
import { createRequire as createRequire3 } from "node:module";
|
|
99202
99268
|
var require4 = createRequire3(import.meta.url);
|
|
99203
99269
|
|
|
99270
|
+
// ../kiro-core/dist/credential-rotation.js
|
|
99271
|
+
init_kiro_cli();
|
|
99272
|
+
init_management();
|
|
99273
|
+
|
|
99204
99274
|
// ../kiro-core/dist/stream.js
|
|
99205
99275
|
init_debug();
|
|
99206
99276
|
init_endpoints();
|
|
99207
|
-
|
|
99277
|
+
init_http();
|
|
99208
99278
|
init_management();
|
|
99209
99279
|
init_oauth();
|
|
99210
99280
|
init_token_type();
|
|
@@ -99290,7 +99360,7 @@ function createBundledRefresh() {
|
|
|
99290
99360
|
return { count: refreshed.models.length };
|
|
99291
99361
|
},
|
|
99292
99362
|
grok: async () => {
|
|
99293
|
-
const refreshed = refreshGrokModels({ force: true });
|
|
99363
|
+
const refreshed = await refreshGrokModels({ force: true });
|
|
99294
99364
|
return { count: refreshed.models.length, detail: `source=${refreshed.source}` };
|
|
99295
99365
|
}
|
|
99296
99366
|
};
|