@ngosangns/ns-bridge 0.1.5 → 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.
Files changed (2) hide show
  1. package/dist/refresh-entry.js +357 -299
  2. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- // @ngosangns/ns-bridge 0.1.5 — catalog refresh bundle.
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, run) => {
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 run(streams2);
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(run, runId, params, options) {
34523
+ async _createToolAssistantStream(run2, runId, params, options) {
34524
34524
  this._listenForAbort(options?.signal);
34525
34525
  const body = { ...params, stream: true };
34526
- const stream11 = await run.submitToolOutputs(runId, body, {
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(run, threadId, params, options) {
34611
+ async _createAssistantStream(run2, threadId, params, options) {
34612
34612
  this._listenForAbort(options?.signal);
34613
34613
  const body = { ...params, stream: true };
34614
- const stream11 = await run.create(threadId, body, { ...options, signal: this.controller.signal });
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(run) {
34632
- __classPrivateFieldGet2(this, _AssistantStream_instances, "m", _AssistantStream_emitExposed).call(this, "run", run);
34633
- return run;
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 run = await this.create(threadId, body, options);
35314
- return await this.poll(run.id, { thread_id: threadId }, options);
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 run = await this.submitToolOutputs(runId, params, options);
35356
- return await this.poll(run.id, params, options);
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 run = await this.createAndRun(body, options);
35456
- return await this.runs.poll(run.id, { thread_id: run.thread_id }, options);
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 randomUUID3 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
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 randomUUID3();
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) {
@@ -92431,7 +92431,7 @@ __export(kiro_cli_exports, {
92431
92431
  saveKiroCliCredentials: () => saveKiroCliCredentials,
92432
92432
  tryKiroCliToken: () => tryKiroCliToken
92433
92433
  });
92434
- import { execFileSync as execFileSync3, execSync } from "node:child_process";
92434
+ import { execFileSync, execSync } from "node:child_process";
92435
92435
  import { existsSync as existsSync3 } from "node:fs";
92436
92436
  import { createRequire } from "node:module";
92437
92437
  import { homedir as homedir6, platform } from "node:os";
@@ -92672,7 +92672,7 @@ function saveKiroCliCredentials(creds) {
92672
92672
  function getKiroCliModelRates() {
92673
92673
  let raw;
92674
92674
  try {
92675
- raw = execFileSync3("kiro-cli", ["chat", "--list-models", "--format", "json"], {
92675
+ raw = execFileSync("kiro-cli", ["chat", "--list-models", "--format", "json"], {
92676
92676
  encoding: "utf-8",
92677
92677
  timeout: 1e4,
92678
92678
  stdio: ["pipe", "pipe", "pipe"]
@@ -92706,7 +92706,7 @@ function getKiroCliModelRates() {
92706
92706
  }
92707
92707
  function refreshViaKiroCli() {
92708
92708
  try {
92709
- execFileSync3("kiro-cli", ["debug", "refresh-auth-token"], {
92709
+ execFileSync("kiro-cli", ["debug", "refresh-auth-token"], {
92710
92710
  timeout: 15e3,
92711
92711
  stdio: ["pipe", "pipe", "pipe"]
92712
92712
  });
@@ -92732,6 +92732,94 @@ var init_kiro_cli = __esm({
92732
92732
  }
92733
92733
  });
92734
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
+
92735
92823
  // ../kiro-core/dist/kiro-ide.js
92736
92824
  import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
92737
92825
  import { homedir as homedir7 } from "node:os";
@@ -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 fetch(getKiroEndpoints(API_KEY_REGION).management, {
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
- ...kiroUserAgent("codewhispererruntime", "F,C")
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 fetch(url, {
92975
+ const response2 = await kiroFetch(url, {
92904
92976
  method: "POST",
92905
- headers: { "Content-Type": "application/json", "User-Agent": KIRO_DESKTOP_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 fetch(tokenEndpoint, {
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": "kiro-core"
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 fetch(`${ssoEndpoint}/token`, {
93035
+ const response = await kiroFetch(`${ssoEndpoint}/token`, {
92964
93036
  method: "POST",
92965
- headers: { "Content-Type": "application/json", ...kiroUserAgent("ssooidc", "E") },
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,11 +93085,13 @@ var init_oauth = __esm({
93013
93085
  "use strict";
93014
93086
  init_debug();
93015
93087
  init_endpoints();
93088
+ init_http();
93016
93089
  init_kiro_cli();
93017
93090
  init_kiro_ide();
93091
+ init_token_type();
93018
93092
  KIRO_DESKTOP_REFRESH_URL = "https://prod.{region}.auth.desktop.kiro.dev/refreshToken";
93019
93093
  EXPIRES_BUFFER_MS = 5 * 60 * 1e3;
93020
- KIRO_DESKTOP_USER_AGENT = "Kiro-Desktop/0.2.13 (darwin; arm64)";
93094
+ KIRO_DESKTOP_USER_AGENT = KIRO_USER_AGENTS.desktop;
93021
93095
  AUTH_SOURCE_ENV = "KIRO_AUTH_SOURCE";
93022
93096
  API_KEY_REGION = "us-east-1";
93023
93097
  KIRO_DESKTOP_REFRESH_ENDPOINT_ENV = "KIRO_DESKTOP_REFRESH_ENDPOINT";
@@ -93025,39 +93099,6 @@ var init_oauth = __esm({
93025
93099
  }
93026
93100
  });
93027
93101
 
93028
- // ../kiro-core/dist/token-type.js
93029
- function isExternalIdpAccessToken(accessToken) {
93030
- if (typeof accessToken !== "string" || !accessToken)
93031
- return false;
93032
- const segments = accessToken.split(".");
93033
- const payloadSegment = segments[1];
93034
- if (segments.length === 3 && payloadSegment) {
93035
- try {
93036
- const payload = JSON.parse(Buffer.from(payloadSegment.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf-8"));
93037
- if (payload.aud === EXTERNAL_IDP_AUDIENCE || Array.isArray(payload.aud) && payload.aud.includes(EXTERNAL_IDP_AUDIENCE)) {
93038
- return true;
93039
- }
93040
- } catch {
93041
- }
93042
- }
93043
- try {
93044
- return getKiroCliExternalIdpCredentials()?.access === accessToken;
93045
- } catch {
93046
- return false;
93047
- }
93048
- }
93049
- function kiroTokenTypeHeaders(accessToken) {
93050
- return isExternalIdpAccessToken(accessToken) ? { tokentype: "EXTERNAL_IDP" } : {};
93051
- }
93052
- var EXTERNAL_IDP_AUDIENCE;
93053
- var init_token_type = __esm({
93054
- "../kiro-core/dist/token-type.js"() {
93055
- "use strict";
93056
- init_kiro_cli();
93057
- EXTERNAL_IDP_AUDIENCE = "api://kiro";
93058
- }
93059
- });
93060
-
93061
93102
  // ../kiro-core/dist/management.js
93062
93103
  var management_exports = {};
93063
93104
  __export(management_exports, {
@@ -93087,26 +93128,9 @@ function candidateManagementRegions(primary) {
93087
93128
  }
93088
93129
  async function requestManagement(auth, operation, path6, method, body) {
93089
93130
  const url = new URL(path6, getKiroEndpoints(auth.region).management);
93090
- const request = {
93091
- method,
93092
- headers: {
93093
- Accept: "application/json",
93094
- ...kiroAuthHeaders(auth.accessToken),
93095
- ...kiroTokenTypeHeaders(auth.accessToken)
93096
- }
93097
- };
93098
- if (method === "GET") {
93099
- for (const [name, value] of Object.entries(body)) {
93100
- if (value !== void 0)
93101
- url.searchParams.set(name, String(value));
93102
- }
93103
- } else {
93104
- request.headers = { ...request.headers, "Content-Type": "application/json" };
93105
- request.body = JSON.stringify(body);
93106
- }
93107
93131
  let response;
93108
93132
  try {
93109
- response = await fetch(url.toString(), request);
93133
+ response = await kiroManagementFetch(url, auth, method, body);
93110
93134
  } catch (error) {
93111
93135
  throw new Error(`Kiro management ${operation} request failed in ${auth.region}`, { cause: error });
93112
93136
  }
@@ -93258,21 +93282,9 @@ async function fetchKiroModelCatalog(auth, providedProfileArn) {
93258
93282
  async function getUsageLimits(auth, request) {
93259
93283
  const operation = "GetUsageLimits";
93260
93284
  const url = new URL("Get-Usage-Limits", getKiroEndpoints(auth.region).management);
93261
- for (const [name, value] of Object.entries(request)) {
93262
- if (value !== void 0)
93263
- url.searchParams.set(name, String(value));
93264
- }
93265
93285
  let response;
93266
93286
  try {
93267
- response = await fetch(url.toString(), {
93268
- method: "GET",
93269
- headers: {
93270
- Accept: "application/json",
93271
- ...kiroAuthHeaders(auth.accessToken),
93272
- ...kiroTokenTypeHeaders(auth.accessToken),
93273
- "User-Agent": "ns-kiro-provider"
93274
- }
93275
- });
93287
+ response = await kiroManagementFetch(url, auth, "GET", request);
93276
93288
  } catch (error) {
93277
93289
  throw new Error(`Kiro management ${operation} request failed in ${auth.region}`, { cause: error });
93278
93290
  }
@@ -93284,8 +93296,8 @@ var init_management = __esm({
93284
93296
  "use strict";
93285
93297
  init_debug();
93286
93298
  init_endpoints();
93299
+ init_http();
93287
93300
  init_oauth();
93288
- init_token_type();
93289
93301
  LIST_PROFILES_PATH = "List-Available-Profiles";
93290
93302
  LIST_MODELS_PATH = "List-Available-Models";
93291
93303
  API_KEY_REGION2 = "us-east-1";
@@ -93368,6 +93380,28 @@ function toPiThinkingLevelMap(efforts) {
93368
93380
  return map;
93369
93381
  }
93370
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
+ }
93404
+
93371
93405
  // ../devin-core/dist/util.js
93372
93406
  function isRecord(value) {
93373
93407
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -95852,9 +95886,9 @@ var MAX_CONNECT_FRAME_PAYLOAD = 16 * 1024 * 1024;
95852
95886
  var LARGE_HISTORY_RECOVERY_BYTES = 512 * 1024;
95853
95887
 
95854
95888
  // ../devin-core/dist/credentials.js
95855
- import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
95889
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
95856
95890
  import { homedir } from "node:os";
95857
- import { dirname, join } from "node:path";
95891
+ import { dirname as dirname2, join } from "node:path";
95858
95892
 
95859
95893
  // ../devin-core/dist/oauth.js
95860
95894
  var FALLBACK_EXPIRES_MS = 365 * 24 * 60 * 60 * 1e3;
@@ -95895,7 +95929,7 @@ function devinTokenFromToml(text) {
95895
95929
  function resolveDevinCredentials() {
95896
95930
  let text;
95897
95931
  try {
95898
- text = readFileSync(devinCredentialsPath(), "utf8");
95932
+ text = readFileSync2(devinCredentialsPath(), "utf8");
95899
95933
  } catch {
95900
95934
  return void 0;
95901
95935
  }
@@ -96257,9 +96291,9 @@ function normalizeDevinModels(configs, baseUrlOverride) {
96257
96291
  }
96258
96292
 
96259
96293
  // ../devin-core/dist/models.js
96260
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync2 } from "node:fs";
96294
+ import { statSync } from "node:fs";
96261
96295
  import { homedir as homedir2 } from "node:os";
96262
- import { dirname as dirname2, join as join2 } from "node:path";
96296
+ import { join as join2 } from "node:path";
96263
96297
  var devinModels = [
96264
96298
  {
96265
96299
  id: "swe-1-6",
@@ -96302,7 +96336,7 @@ function loadCacheFile() {
96302
96336
  const mtimeMs = statSync(devinModelCachePath()).mtimeMs;
96303
96337
  if (mtimeMs !== cacheMtimeMs) {
96304
96338
  cacheMtimeMs = mtimeMs;
96305
- const parsed = JSON.parse(readFileSync2(devinModelCachePath(), "utf8"));
96339
+ const parsed = readJsonFile(devinModelCachePath());
96306
96340
  cacheFile = typeof parsed === "object" && parsed !== null && Array.isArray(parsed.models) && typeof parsed.fetchedAt === "number" ? parsed : void 0;
96307
96341
  }
96308
96342
  } catch {
@@ -96321,8 +96355,7 @@ function isCacheStale(now = Date.now()) {
96321
96355
  function updateDevinModelsCache(models, now = Date.now()) {
96322
96356
  cacheFile = { fetchedAt: now, models };
96323
96357
  try {
96324
- mkdirSync2(dirname2(devinModelCachePath()), { recursive: true });
96325
- writeFileSync2(devinModelCachePath(), JSON.stringify(cacheFile), "utf8");
96358
+ writeJsonFileAtomic(devinModelCachePath(), cacheFile);
96326
96359
  cacheMtimeMs = statSync(devinModelCachePath()).mtimeMs;
96327
96360
  } catch {
96328
96361
  }
@@ -96383,6 +96416,24 @@ async function refreshDevinModels(options = {}) {
96383
96416
  return { models: getCachedModels().map(toPiDevinModel), fromCache };
96384
96417
  }
96385
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
+
96386
96437
  // ../pi-provider/src/shared/types.ts
96387
96438
  function ensureCacheCost(cost) {
96388
96439
  return {
@@ -96394,7 +96445,7 @@ function ensureCacheCost(cost) {
96394
96445
  }
96395
96446
 
96396
96447
  // ../pi-provider/src/shared/catalog-cache.ts
96397
- 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";
96398
96449
  import { join as join3 } from "node:path";
96399
96450
  import { homedir as homedir3 } from "node:os";
96400
96451
  var DEFAULT_TTL_MS = 15 * 60 * 1e3;
@@ -96418,7 +96469,7 @@ var CatalogCache = class {
96418
96469
  mkdirSync: options.fs?.mkdirSync ?? ((path6, opts) => {
96419
96470
  mkdirSync3(path6, opts);
96420
96471
  }),
96421
- renameSync: options.fs?.renameSync ?? renameSync,
96472
+ renameSync: options.fs?.renameSync ?? renameSync2,
96422
96473
  existsSync: options.fs?.existsSync ?? existsSync2
96423
96474
  };
96424
96475
  }
@@ -96534,12 +96585,13 @@ function getDefaultCatalogCache(options) {
96534
96585
  return defaultCache;
96535
96586
  }
96536
96587
 
96537
- // ../pi-provider/src/grok/binary.ts
96588
+ // ../grok-core/dist/agent/binary.js
96589
+ import { execFile } from "node:child_process";
96538
96590
  import { accessSync, constants } from "node:fs";
96539
- import { execFileSync } from "node:child_process";
96540
96591
  import { homedir as homedir4 } from "node:os";
96541
96592
  import { join as join4 } from "node:path";
96542
96593
  var CANDIDATE_NAMES = ["agent", "grok"];
96594
+ var BINARY_ENV_NAMES = ["GROK_AGENT_BIN", "GROK_BIN", "PI_GROK_SDK_BIN", "PI_GROK_AGENT_BIN"];
96543
96595
  function isExecutable(path6) {
96544
96596
  try {
96545
96597
  accessSync(path6, constants.X_OK);
@@ -96548,59 +96600,44 @@ function isExecutable(path6) {
96548
96600
  return false;
96549
96601
  }
96550
96602
  }
96551
- function which(name) {
96552
- try {
96553
- const out = execFileSync(process.platform === "win32" ? "where" : "which", [name], {
96554
- encoding: "utf8",
96555
- stdio: ["ignore", "pipe", "pipe"],
96556
- timeout: 5e3
96557
- }).trim();
96558
- const first = out.split(/\r?\n/).map((l) => l.trim()).find(Boolean);
96559
- return first && isExecutable(first) ? first : void 0;
96560
- } catch {
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)
96561
96613
  return void 0;
96562
- }
96614
+ const first = out.trim().split(/\r?\n/).map((line) => line.trim()).find(Boolean);
96615
+ return first && isExecutable(first) ? first : void 0;
96563
96616
  }
96564
- function resolveGrokBinary(env3 = process.env) {
96565
- const explicit = env3.PI_GROK_SDK_BIN?.trim() || env3.PI_GROK_AGENT_BIN?.trim() || env3.GROK_AGENT_BIN?.trim() || env3.GROK_BIN?.trim();
96617
+ async function resolveGrokBinary(env3 = process.env) {
96618
+ const explicit = BINARY_ENV_NAMES.map((name) => env3[name]?.trim()).find(Boolean);
96566
96619
  if (explicit) {
96567
96620
  if (!isExecutable(explicit)) {
96568
- throw new Error(
96569
- `Configured Grok agent binary is not executable: ${explicit}. Check PI_GROK_SDK_BIN / PI_GROK_AGENT_BIN / GROK_AGENT_BIN.`
96570
- );
96621
+ throw new Error(`Configured Grok agent binary is not executable: ${explicit}. Check ${BINARY_ENV_NAMES.join(" / ")}.`);
96571
96622
  }
96572
96623
  return explicit;
96573
96624
  }
96574
96625
  for (const name of CANDIDATE_NAMES) {
96575
- const found = which(name);
96576
- if (found) return found;
96626
+ const found = await which(name);
96627
+ if (found)
96628
+ return found;
96577
96629
  }
96578
96630
  const homeBin = join4(homedir4(), ".grok", "bin");
96579
96631
  for (const name of CANDIDATE_NAMES) {
96580
96632
  const candidate = join4(homeBin, name);
96581
- if (isExecutable(candidate)) return candidate;
96633
+ if (isExecutable(candidate))
96634
+ return candidate;
96582
96635
  }
96583
- throw new Error(
96584
- "Grok agent CLI not found. Install/authenticate the xAI Grok agent (`agent` or `grok` on PATH, or ~/.grok/bin). Then run: agent --version"
96585
- );
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");
96586
96637
  }
96587
96638
 
96588
- // ../pi-provider/src/grok/config.ts
96589
- var DEFAULT_MODEL_ID = "grok-4.5";
96590
- var THINKING_LEVEL_MAP = {
96591
- off: "none",
96592
- minimal: "minimal",
96593
- low: "low",
96594
- medium: "medium",
96595
- high: "high",
96596
- xhigh: "xhigh",
96597
- max: "max"
96598
- };
96599
- var DEFAULT_CONTEXT_WINDOW2 = 5e5;
96600
- var DEFAULT_MAX_TOKENS2 = 128e3;
96601
-
96602
- // ../pi-provider/src/grok/models.ts
96603
- import { execFileSync as execFileSync2 } from "node:child_process";
96639
+ // ../grok-core/dist/agent/models.js
96640
+ import { execFile as execFile2 } from "node:child_process";
96604
96641
  function parseGrokModelsOutput(stdout) {
96605
96642
  const models = [];
96606
96643
  const seen = /* @__PURE__ */ new Set();
@@ -96615,8 +96652,8 @@ function parseGrokModelsOutput(stdout) {
96615
96652
  models.push({
96616
96653
  id,
96617
96654
  name: id,
96618
- contextWindow: DEFAULT_CONTEXT_WINDOW2,
96619
- maxTokens: DEFAULT_MAX_TOKENS2,
96655
+ contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
96656
+ maxTokens: GROK_DEFAULT_MAX_TOKENS,
96620
96657
  supportsReasoningEffort: true
96621
96658
  });
96622
96659
  }
@@ -96628,45 +96665,68 @@ function parseGrokModelsOutput(stdout) {
96628
96665
  models.unshift({
96629
96666
  id: d[1],
96630
96667
  name: d[1],
96631
- contextWindow: DEFAULT_CONTEXT_WINDOW2,
96632
- maxTokens: DEFAULT_MAX_TOKENS2,
96668
+ contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
96669
+ maxTokens: GROK_DEFAULT_MAX_TOKENS,
96633
96670
  supportsReasoningEffort: true
96634
96671
  });
96635
96672
  }
96636
96673
  }
96637
96674
  return models;
96638
96675
  }
96639
- var BOOTSTRAP_MODEL_IDS = ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"];
96640
- function fallbackModels() {
96641
- return BOOTSTRAP_MODEL_IDS.map((id) => ({
96642
- id,
96643
- name: id,
96644
- contextWindow: DEFAULT_CONTEXT_WINDOW2,
96645
- maxTokens: DEFAULT_MAX_TOKENS2,
96646
- supportsReasoningEffort: true
96647
- }));
96648
- }
96649
- function discoverModels(binary) {
96676
+ async function discoverGrokModels(binary) {
96650
96677
  try {
96651
- const bin = binary ?? resolveGrokBinary();
96652
- const stdout = execFileSync2(bin, ["models"], {
96653
- encoding: "utf8",
96654
- stdio: ["ignore", "pipe", "pipe"],
96655
- timeout: 2e4
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
+ });
96656
96686
  });
96657
96687
  const parsed = parseGrokModelsOutput(stdout);
96658
96688
  if (parsed.length === 0) {
96659
- return { models: fallbackModels(), source: "fallback", error: "empty model list from CLI" };
96689
+ return { models: [], source: "fallback", error: "empty model list from CLI" };
96660
96690
  }
96661
96691
  return { models: parsed, source: "live" };
96662
96692
  } catch (err) {
96663
96693
  return {
96664
- models: fallbackModels(),
96694
+ models: [],
96665
96695
  source: "fallback",
96666
96696
  error: err instanceof Error ? err.message : String(err)
96667
96697
  };
96668
96698
  }
96669
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
+ }
96670
96730
  function toProviderModel(d) {
96671
96731
  return {
96672
96732
  id: d.id,
@@ -98531,7 +98591,7 @@ function catalogToProviderModels(models) {
98531
98591
  cost: ensureCacheCost(models[i2]?.cost ?? m2.cost)
98532
98592
  }));
98533
98593
  }
98534
- function refreshGrokModels(options = {}) {
98594
+ async function refreshGrokModels(options = {}) {
98535
98595
  const cache = options.cache ?? getDefaultCatalogCache();
98536
98596
  if (!options.force) {
98537
98597
  const lookup = cache.lookup(GROK_PROVIDER_ID);
@@ -98566,11 +98626,11 @@ function refreshGrokModels(options = {}) {
98566
98626
  }
98567
98627
  let binary = options.binary;
98568
98628
  try {
98569
- binary ??= resolveGrokBinary();
98629
+ binary ??= await resolveGrokBinary();
98570
98630
  } catch {
98571
98631
  binary = void 0;
98572
98632
  }
98573
- const discovered = discoverModels(binary);
98633
+ const discovered = await discoverModels(binary);
98574
98634
  const catalog = descriptorsToCatalog(discovered.models);
98575
98635
  cache.store(GROK_PROVIDER_ID, catalog, { version: "grok-cli-v1" });
98576
98636
  return {
@@ -98582,6 +98642,100 @@ function refreshGrokModels(options = {}) {
98582
98642
 
98583
98643
  // ../kiro-core/dist/index.js
98584
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";
98585
98739
 
98586
98740
  // ../kiro-core/dist/types.js
98587
98741
  var KIRO_EFFORT_ORDER = ["minimal", "low", "medium", "high", "xhigh", "max"];
@@ -98645,14 +98799,7 @@ function getKiroEffortConfig(schema, kiroModelId) {
98645
98799
  return fallbackKiroEffort(kiroModelId);
98646
98800
  }
98647
98801
 
98648
- // ../kiro-core/dist/index.js
98649
- init_endpoints();
98650
-
98651
98802
  // ../kiro-core/dist/models.js
98652
- import { randomUUID as randomUUID2 } from "node:crypto";
98653
- import { existsSync as existsSync5, readFileSync as readFileSync6, renameSync as renameSync2, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
98654
- import { homedir as homedir8 } from "node:os";
98655
- import { join as join9 } from "node:path";
98656
98803
  init_endpoints();
98657
98804
  var KIRO_MANAGEMENT_CACHE_VERSION = 1;
98658
98805
  var KIRO_MANAGEMENT_CACHE_SOURCE = "ns-kiro-provider-management";
@@ -98935,12 +99082,12 @@ function readManagementCache() {
98935
99082
  }
98936
99083
  }
98937
99084
  function writeManagementCache(cache) {
98938
- const temporaryPath = `${KIRO_MANAGEMENT_CACHE_PATH}.${process.pid}.${randomUUID2()}.tmp`;
99085
+ const temporaryPath = `${KIRO_MANAGEMENT_CACHE_PATH}.${process.pid}.${randomUUID3()}.tmp`;
98939
99086
  try {
98940
99087
  writeFileSync4(temporaryPath, JSON.stringify(cache, null, 2), "utf-8");
98941
- renameSync2(temporaryPath, KIRO_MANAGEMENT_CACHE_PATH);
99088
+ renameSync3(temporaryPath, KIRO_MANAGEMENT_CACHE_PATH);
98942
99089
  } finally {
98943
- rmSync(temporaryPath, { force: true });
99090
+ rmSync2(temporaryPath, { force: true });
98944
99091
  }
98945
99092
  }
98946
99093
  function toLocalModelId(kiroModelId) {
@@ -99058,10 +99205,6 @@ function isCacheStale2(region) {
99058
99205
  return !entry || Date.now() - entry.fetchedAt > CACHE_MAX_AGE_MS;
99059
99206
  }
99060
99207
  async function updateKiroModelsCache(accessToken, region, profileArn) {
99061
- await updateKiroModelsCacheInProcess(accessToken, region, profileArn);
99062
- refreshKnownModelIds(readManagementCache());
99063
- }
99064
- async function updateKiroModelsCacheInProcess(accessToken, region, profileArn) {
99065
99208
  const { fetchKiroModelCatalog: fetchKiroModelCatalog2 } = await Promise.resolve().then(() => (init_management(), management_exports));
99066
99209
  const { getKiroCliModelRates: getKiroCliModelRates2 } = await Promise.resolve().then(() => (init_kiro_cli(), kiro_cli_exports));
99067
99210
  const response = await fetchKiroModelCatalog2({ accessToken, region }, profileArn);
@@ -99076,71 +99219,15 @@ async function updateKiroModelsCacheInProcess(accessToken, region, profileArn) {
99076
99219
  refreshKnownModelIds(cache);
99077
99220
  }
99078
99221
 
99079
- // ../kiro-core/dist/retry.js
99080
- var KIRO_REASON_CODES = Object.freeze({
99081
- /** Request body exceeded the service's size threshold. */
99082
- CONTENT_LENGTH_EXCEEDS_THRESHOLD: "CONTENT_LENGTH_EXCEEDS_THRESHOLD",
99083
- /** Prose-only size rejection; the service sends no reason code for this one. */
99084
- INPUT_TOO_LONG: "Input is too long",
99085
- /** Monthly request quota exhausted — hard limit, not transient. */
99086
- MONTHLY_REQUEST_COUNT: "MONTHLY_REQUEST_COUNT",
99087
- /** Model capacity temporarily unavailable — transient, worth retrying. */
99088
- INSUFFICIENT_MODEL_CAPACITY: "INSUFFICIENT_MODEL_CAPACITY",
99089
- /** Short-window request throttle — retry only within the provider budget. */
99090
- USER_REQUEST_RATE_EXCEEDED: "USER_REQUEST_RATE_EXCEEDED",
99091
- /**
99092
- * Generic request-validation rejection, returned for a malformed body of any
99093
- * size (empty `content`, history referencing tools absent from the catalog).
99094
- * Not a size signal: classifying it as "too big" makes the caller compact a
99095
- * history that was never the problem, a loop it can never satisfy.
99096
- */
99097
- REQUEST_BODY_INVALID: "REQUEST_BODY_INVALID"
99098
- });
99099
- var TOO_BIG_PATTERNS = Object.freeze([
99100
- KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
99101
- KIRO_REASON_CODES.INPUT_TOO_LONG
99102
- ]);
99103
- var NON_RETRYABLE_BODY_PATTERNS = Object.freeze([KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT]);
99104
- var CAPACITY_PATTERN = KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY;
99222
+ // ../kiro-core/dist/index.js
99223
+ init_kiro_cli();
99224
+ init_oauth();
99105
99225
 
99106
- // ../kiro-core/dist/errors.js
99107
- var REASON_CODE_MARKERS = [
99108
- KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
99109
- KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT,
99110
- KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY,
99111
- KIRO_REASON_CODES.REQUEST_BODY_INVALID
99112
- ];
99226
+ // ../kiro-core/dist/request-builder.js
99227
+ init_debug();
99113
99228
 
99114
- // ../kiro-core/dist/event-parser.js
99115
- var KIRO_EVENT_KEYS = [
99116
- "assistantResponseEvent",
99117
- "codeReferenceEvent",
99118
- "contextUsageEvent",
99119
- "documentCitationEvent",
99120
- "error",
99121
- "metadataEvent",
99122
- "meteringEvent",
99123
- "reasoningContentEvent",
99124
- "serviceUnavailableError",
99125
- "throttlingError",
99126
- "toolResultEvent",
99127
- "toolUseEvent",
99128
- "validationError"
99129
- ];
99130
- var KIRO_EVENT_KEY_SET = new Set(KIRO_EVENT_KEYS);
99131
- var KIRO_ERROR_MEMBERS = {
99132
- error: { kind: "internalServer", exception: "InternalServerException" },
99133
- throttlingError: { kind: "throttling", exception: "ThrottlingException" },
99134
- validationError: { kind: "validation", exception: "ValidationException" },
99135
- serviceUnavailableError: { kind: "serviceUnavailable", exception: "ServiceUnavailableException" }
99136
- };
99137
- var KIRO_ERROR_TOKENS = {
99138
- ...KIRO_ERROR_MEMBERS,
99139
- InternalServerException: KIRO_ERROR_MEMBERS.error,
99140
- ThrottlingException: KIRO_ERROR_MEMBERS.throttlingError,
99141
- ValidationException: KIRO_ERROR_MEMBERS.validationError,
99142
- ServiceUnavailableException: KIRO_ERROR_MEMBERS.serviceUnavailableError
99143
- };
99229
+ // ../kiro-core/dist/history.js
99230
+ var HISTORY_IMAGE_BASE64_LIMIT = 512 * 1024;
99144
99231
 
99145
99232
  // ../kiro-core/dist/history-validator.js
99146
99233
  var KiroValidationRule;
@@ -99168,39 +99255,6 @@ var KIRO_TOOL_STRUCTURE_RULES = [
99168
99255
  KiroValidationRule.TOOL_RESULTS_ORPHAN_IDS
99169
99256
  ];
99170
99257
 
99171
- // ../kiro-core/dist/host-auth.js
99172
- init_endpoints();
99173
- init_oauth();
99174
- async function resolveKiroRequestCredentials(hostKey) {
99175
- const stored = await resolveKiroCredentials();
99176
- const region = resolveApiRegion(stored?.region);
99177
- if (hostKey && (isApiKey(hostKey) || hostKey === stored?.access)) {
99178
- return { accessToken: hostKey, region, ...stored?.profileArn ? { profileArn: stored.profileArn } : {} };
99179
- }
99180
- if (stored) {
99181
- return {
99182
- accessToken: stored.access,
99183
- region,
99184
- ...stored.profileArn ? { profileArn: stored.profileArn } : {}
99185
- };
99186
- }
99187
- if (hostKey)
99188
- return { accessToken: hostKey, region };
99189
- throw new Error("Kiro credentials not set. Run `kiro-cli login`, or set KIRO_API_KEY to a `ksk_` API key.");
99190
- }
99191
-
99192
- // ../kiro-core/dist/index.js
99193
- init_kiro_cli();
99194
- init_kiro_ide();
99195
- init_management();
99196
- init_oauth();
99197
-
99198
- // ../kiro-core/dist/request-builder.js
99199
- init_debug();
99200
-
99201
- // ../kiro-core/dist/history.js
99202
- var HISTORY_IMAGE_BASE64_LIMIT = 512 * 1024;
99203
-
99204
99258
  // ../kiro-core/dist/response-assembler.js
99205
99259
  init_debug();
99206
99260
 
@@ -99213,10 +99267,14 @@ init_debug();
99213
99267
  import { createRequire as createRequire3 } from "node:module";
99214
99268
  var require4 = createRequire3(import.meta.url);
99215
99269
 
99270
+ // ../kiro-core/dist/credential-rotation.js
99271
+ init_kiro_cli();
99272
+ init_management();
99273
+
99216
99274
  // ../kiro-core/dist/stream.js
99217
99275
  init_debug();
99218
99276
  init_endpoints();
99219
- init_kiro_cli();
99277
+ init_http();
99220
99278
  init_management();
99221
99279
  init_oauth();
99222
99280
  init_token_type();
@@ -99302,7 +99360,7 @@ function createBundledRefresh() {
99302
99360
  return { count: refreshed.models.length };
99303
99361
  },
99304
99362
  grok: async () => {
99305
- const refreshed = refreshGrokModels({ force: true });
99363
+ const refreshed = await refreshGrokModels({ force: true });
99306
99364
  return { count: refreshed.models.length, detail: `source=${refreshed.source}` };
99307
99365
  }
99308
99366
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngosangns/ns-bridge",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Install, update, and refresh ns-bridge providers outside Pi, OMP, and DSH.",
5
5
  "type": "module",
6
6
  "license": "MIT",