mpd-llm-cli 0.1.45 → 0.1.47

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/bundle/api.js CHANGED
@@ -27724,7 +27724,7 @@ async function createContentGeneratorConfig(model, authType) {
27724
27724
  return contentGeneratorConfig;
27725
27725
  }
27726
27726
  async function createContentGenerator(config2, sessionId2) {
27727
- const version2 = "0.1.45";
27727
+ const version2 = "0.1.47";
27728
27728
  const httpOptions = {
27729
27729
  headers: {
27730
27730
  "User-Agent": `GeminiCLI/${version2} (${process.platform}; ${process.arch})`
@@ -166412,7 +166412,7 @@ async function getPackageJson() {
166412
166412
  // packages/cli/src/utils/version.ts
166413
166413
  async function getCliVersion() {
166414
166414
  const pkgJson = await getPackageJson();
166415
- return "0.1.45";
166415
+ return "0.1.47";
166416
166416
  }
166417
166417
 
166418
166418
  // packages/cli/src/config/sandboxConfig.ts
package/bundle/gemini.js CHANGED
@@ -24179,8 +24179,8 @@ var require_websocket = __commonJS({
24179
24179
  "node_modules/ws/lib/websocket.js"(exports2, module2) {
24180
24180
  "use strict";
24181
24181
  var EventEmitter7 = __require("events");
24182
- var https3 = __require("https");
24183
- var http2 = __require("http");
24182
+ var https4 = __require("https");
24183
+ var http3 = __require("http");
24184
24184
  var net2 = __require("net");
24185
24185
  var tls = __require("tls");
24186
24186
  var { randomBytes, createHash: createHash2 } = __require("crypto");
@@ -24711,7 +24711,7 @@ var require_websocket = __commonJS({
24711
24711
  }
24712
24712
  const defaultPort = isSecure ? 443 : 80;
24713
24713
  const key = randomBytes(16).toString("base64");
24714
- const request2 = isSecure ? https3.request : http2.request;
24714
+ const request2 = isSecure ? https4.request : http3.request;
24715
24715
  const protocolSet = /* @__PURE__ */ new Set();
24716
24716
  let perMessageDeflate;
24717
24717
  opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
@@ -25205,7 +25205,7 @@ var require_websocket_server = __commonJS({
25205
25205
  "node_modules/ws/lib/websocket-server.js"(exports2, module2) {
25206
25206
  "use strict";
25207
25207
  var EventEmitter7 = __require("events");
25208
- var http2 = __require("http");
25208
+ var http3 = __require("http");
25209
25209
  var { Duplex } = __require("stream");
25210
25210
  var { createHash: createHash2 } = __require("crypto");
25211
25211
  var extension = require_extension();
@@ -25276,8 +25276,8 @@ var require_websocket_server = __commonJS({
25276
25276
  );
25277
25277
  }
25278
25278
  if (options.port != null) {
25279
- this._server = http2.createServer((req, res) => {
25280
- const body = http2.STATUS_CODES[426];
25279
+ this._server = http3.createServer((req, res) => {
25280
+ const body = http3.STATUS_CODES[426];
25281
25281
  res.writeHead(426, {
25282
25282
  "Content-Length": body.length,
25283
25283
  "Content-Type": "text/plain"
@@ -25564,7 +25564,7 @@ var require_websocket_server = __commonJS({
25564
25564
  this.destroy();
25565
25565
  }
25566
25566
  function abortHandshake(socket, code, message, headers) {
25567
- message = message || http2.STATUS_CODES[code];
25567
+ message = message || http3.STATUS_CODES[code];
25568
25568
  headers = {
25569
25569
  Connection: "close",
25570
25570
  "Content-Type": "text/html",
@@ -25573,7 +25573,7 @@ var require_websocket_server = __commonJS({
25573
25573
  };
25574
25574
  socket.once("finish", socket.destroy);
25575
25575
  socket.end(
25576
- `HTTP/1.1 ${code} ${http2.STATUS_CODES[code]}\r
25576
+ `HTTP/1.1 ${code} ${http3.STATUS_CODES[code]}\r
25577
25577
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
25578
25578
  );
25579
25579
  }
@@ -41129,10 +41129,10 @@ var require_lib2 = __commonJS({
41129
41129
  return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
41130
41130
  }
41131
41131
  var Stream4 = _interopDefault(__require("stream"));
41132
- var http2 = _interopDefault(__require("http"));
41132
+ var http3 = _interopDefault(__require("http"));
41133
41133
  var Url = _interopDefault(__require("url"));
41134
41134
  var whatwgUrl = _interopDefault(require_public_api());
41135
- var https3 = _interopDefault(__require("https"));
41135
+ var https4 = _interopDefault(__require("https"));
41136
41136
  var zlib = _interopDefault(__require("zlib"));
41137
41137
  var Readable = Stream4.Readable;
41138
41138
  var BUFFER2 = Symbol("buffer");
@@ -41869,7 +41869,7 @@ var require_lib2 = __commonJS({
41869
41869
  return headers;
41870
41870
  }
41871
41871
  var INTERNALS$1 = Symbol("Response internals");
41872
- var STATUS_CODES = http2.STATUS_CODES;
41872
+ var STATUS_CODES = http3.STATUS_CODES;
41873
41873
  var Response2 = class _Response {
41874
41874
  constructor() {
41875
41875
  let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
@@ -42122,7 +42122,7 @@ var require_lib2 = __commonJS({
42122
42122
  return new fetch2.Promise(function(resolve18, reject) {
42123
42123
  const request2 = new Request2(url2, opts);
42124
42124
  const options = getNodeRequestOptions(request2);
42125
- const send = (options.protocol === "https:" ? https3 : http2).request;
42125
+ const send = (options.protocol === "https:" ? https4 : http3).request;
42126
42126
  const signal = request2.signal;
42127
42127
  let response = null;
42128
42128
  const abort = function abort2() {
@@ -43902,8 +43902,8 @@ var require_helpers = __commonJS({
43902
43902
  };
43903
43903
  Object.defineProperty(exports2, "__esModule", { value: true });
43904
43904
  exports2.req = exports2.json = exports2.toBuffer = void 0;
43905
- var http2 = __importStar(__require("http"));
43906
- var https3 = __importStar(__require("https"));
43905
+ var http3 = __importStar(__require("http"));
43906
+ var https4 = __importStar(__require("https"));
43907
43907
  async function toBuffer(stream2) {
43908
43908
  let length = 0;
43909
43909
  const chunks = [];
@@ -43928,7 +43928,7 @@ var require_helpers = __commonJS({
43928
43928
  exports2.json = json2;
43929
43929
  function req(url2, opts = {}) {
43930
43930
  const href = typeof url2 === "string" ? url2 : url2.href;
43931
- const req2 = (href.startsWith("https:") ? https3 : http2).request(url2, opts);
43931
+ const req2 = (href.startsWith("https:") ? https4 : http3).request(url2, opts);
43932
43932
  const promise = new Promise((resolve18, reject) => {
43933
43933
  req2.once("response", resolve18).once("error", reject).end();
43934
43934
  });
@@ -43976,11 +43976,11 @@ var require_dist = __commonJS({
43976
43976
  Object.defineProperty(exports2, "__esModule", { value: true });
43977
43977
  exports2.Agent = void 0;
43978
43978
  var net2 = __importStar(__require("net"));
43979
- var http2 = __importStar(__require("http"));
43979
+ var http3 = __importStar(__require("http"));
43980
43980
  var https_1 = __require("https");
43981
43981
  __exportStar(require_helpers(), exports2);
43982
43982
  var INTERNAL = Symbol("AgentBaseInternalState");
43983
- var Agent = class extends http2.Agent {
43983
+ var Agent = class extends http3.Agent {
43984
43984
  constructor(opts) {
43985
43985
  super(opts);
43986
43986
  this[INTERNAL] = {};
@@ -44052,7 +44052,7 @@ var require_dist = __commonJS({
44052
44052
  const fakeSocket = this.incrementSockets(name2);
44053
44053
  Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
44054
44054
  this.decrementSockets(name2, fakeSocket);
44055
- if (socket instanceof http2.Agent) {
44055
+ if (socket instanceof http3.Agent) {
44056
44056
  try {
44057
44057
  return socket.addRequest(req, connectOpts);
44058
44058
  } catch (err) {
@@ -62351,7 +62351,7 @@ async function createContentGeneratorConfig(model, authType) {
62351
62351
  return contentGeneratorConfig;
62352
62352
  }
62353
62353
  async function createContentGenerator(config2, sessionId2) {
62354
- const version3 = "0.1.45";
62354
+ const version3 = "0.1.47";
62355
62355
  const httpOptions = {
62356
62356
  headers: {
62357
62357
  "User-Agent": `GeminiCLI/${version3} (${process.platform}; ${process.arch})`
@@ -80673,15 +80673,15 @@ var require_schemes = __commonJS({
80673
80673
  urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
80674
80674
  return urnComponents;
80675
80675
  }
80676
- var http2 = {
80676
+ var http3 = {
80677
80677
  scheme: "http",
80678
80678
  domainHost: true,
80679
80679
  parse: httpParse,
80680
80680
  serialize: httpSerialize
80681
80681
  };
80682
- var https3 = {
80682
+ var https4 = {
80683
80683
  scheme: "https",
80684
- domainHost: http2.domainHost,
80684
+ domainHost: http3.domainHost,
80685
80685
  parse: httpParse,
80686
80686
  serialize: httpSerialize
80687
80687
  };
@@ -80710,8 +80710,8 @@ var require_schemes = __commonJS({
80710
80710
  skipNormalize: true
80711
80711
  };
80712
80712
  var SCHEMES = {
80713
- http: http2,
80714
- https: https3,
80713
+ http: http3,
80714
+ https: https4,
80715
80715
  ws: ws3,
80716
80716
  wss,
80717
80717
  urn,
@@ -115949,8 +115949,8 @@ var require_util6 = __commonJS({
115949
115949
  Object.defineProperty(exports2, "__esModule", { value: true });
115950
115950
  exports2.configureCompression = exports2.createHttpAgent = exports2.sendWithHttp = void 0;
115951
115951
  var url2 = __require("url");
115952
- var http2 = __require("http");
115953
- var https3 = __require("https");
115952
+ var http3 = __require("http");
115953
+ var https4 = __require("https");
115954
115954
  var zlib = __require("zlib");
115955
115955
  var stream_1 = __require("stream");
115956
115956
  var api_1 = (init_esm2(), __toCommonJS(esm_exports));
@@ -115983,7 +115983,7 @@ var require_util6 = __commonJS({
115983
115983
  headers: Object.assign({ "Content-Type": contentType }, collector.headers),
115984
115984
  agent: collector.agent
115985
115985
  };
115986
- const request2 = parsedUrl.protocol === "http:" ? http2.request : https3.request;
115986
+ const request2 = parsedUrl.protocol === "http:" ? http3.request : https4.request;
115987
115987
  const sendWithRetry = (retries = util_1.DEFAULT_EXPORT_MAX_ATTEMPTS, minDelay = util_1.DEFAULT_EXPORT_INITIAL_BACKOFF) => {
115988
115988
  req = request2(options, (res) => {
115989
115989
  let responseData = "";
@@ -116069,7 +116069,7 @@ var require_util6 = __commonJS({
116069
116069
  return void 0;
116070
116070
  try {
116071
116071
  const parsedUrl = new url2.URL(config2.url);
116072
- const Agent = parsedUrl.protocol === "http:" ? http2.Agent : https3.Agent;
116072
+ const Agent = parsedUrl.protocol === "http:" ? http3.Agent : https4.Agent;
116073
116073
  return new Agent(Object.assign({ keepAlive: true }, config2.httpAgentOptions));
116074
116074
  } catch (err) {
116075
116075
  api_1.diag.error(`collector exporter failed to create http agent. err: ${err.message}`);
@@ -131212,7 +131212,7 @@ var require_http_proxy = __commonJS({
131212
131212
  var logging_1 = require_logging();
131213
131213
  var constants_1 = require_constants4();
131214
131214
  var net_1 = __require("net");
131215
- var http2 = __require("http");
131215
+ var http3 = __require("http");
131216
131216
  var logging = require_logging();
131217
131217
  var subchannel_address_1 = require_subchannel_address();
131218
131218
  var uri_parser_1 = require_uri_parser();
@@ -131393,7 +131393,7 @@ var require_http_proxy = __commonJS({
131393
131393
  const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address);
131394
131394
  trace2("Using proxy " + proxyAddressString + " to connect to " + options.path);
131395
131395
  return new Promise((resolve18, reject) => {
131396
- const request2 = http2.request(options);
131396
+ const request2 = http3.request(options);
131397
131397
  request2.once("connect", (res, socket, head) => {
131398
131398
  request2.removeAllListeners();
131399
131399
  socket.removeAllListeners();
@@ -131511,7 +131511,7 @@ var require_subchannel_call = __commonJS({
131511
131511
  "use strict";
131512
131512
  Object.defineProperty(exports2, "__esModule", { value: true });
131513
131513
  exports2.Http2SubchannelCall = void 0;
131514
- var http2 = __require("http2");
131514
+ var http22 = __require("http2");
131515
131515
  var os24 = __require("os");
131516
131516
  var constants_1 = require_constants4();
131517
131517
  var metadata_1 = require_metadata2();
@@ -131586,7 +131586,7 @@ var require_subchannel_call = __commonJS({
131586
131586
  }
131587
131587
  this.trace("Received server headers:\n" + headersString);
131588
131588
  this.httpStatusCode = headers[":status"];
131589
- if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) {
131589
+ if (flags & http22.constants.NGHTTP2_FLAG_END_STREAM) {
131590
131590
  this.handleTrailers(headers);
131591
131591
  } else {
131592
131592
  let metadata;
@@ -131644,7 +131644,7 @@ var require_subchannel_call = __commonJS({
131644
131644
  let code;
131645
131645
  let details = "";
131646
131646
  switch (http2Stream.rstCode) {
131647
- case http2.constants.NGHTTP2_NO_ERROR:
131647
+ case http22.constants.NGHTTP2_NO_ERROR:
131648
131648
  if (this.finalStatus !== null) {
131649
131649
  return;
131650
131650
  }
@@ -131657,11 +131657,11 @@ var require_subchannel_call = __commonJS({
131657
131657
  details = `Received RST_STREAM with code ${http2Stream.rstCode} (Call ended without gRPC status)`;
131658
131658
  }
131659
131659
  break;
131660
- case http2.constants.NGHTTP2_REFUSED_STREAM:
131660
+ case http22.constants.NGHTTP2_REFUSED_STREAM:
131661
131661
  code = constants_1.Status.UNAVAILABLE;
131662
131662
  details = "Stream refused by server";
131663
131663
  break;
131664
- case http2.constants.NGHTTP2_CANCEL:
131664
+ case http22.constants.NGHTTP2_CANCEL:
131665
131665
  if (this.connectionDropped) {
131666
131666
  code = constants_1.Status.UNAVAILABLE;
131667
131667
  details = "Connection dropped";
@@ -131670,15 +131670,15 @@ var require_subchannel_call = __commonJS({
131670
131670
  details = "Call cancelled";
131671
131671
  }
131672
131672
  break;
131673
- case http2.constants.NGHTTP2_ENHANCE_YOUR_CALM:
131673
+ case http22.constants.NGHTTP2_ENHANCE_YOUR_CALM:
131674
131674
  code = constants_1.Status.RESOURCE_EXHAUSTED;
131675
131675
  details = "Bandwidth exhausted or memory limit exceeded";
131676
131676
  break;
131677
- case http2.constants.NGHTTP2_INADEQUATE_SECURITY:
131677
+ case http22.constants.NGHTTP2_INADEQUATE_SECURITY:
131678
131678
  code = constants_1.Status.PERMISSION_DENIED;
131679
131679
  details = "Protocol not secure enough";
131680
131680
  break;
131681
- case http2.constants.NGHTTP2_INTERNAL_ERROR:
131681
+ case http22.constants.NGHTTP2_INTERNAL_ERROR:
131682
131682
  code = constants_1.Status.INTERNAL;
131683
131683
  if (this.internalError === null) {
131684
131684
  details = `Received RST_STREAM with code ${http2Stream.rstCode} (Internal server error)`;
@@ -131836,9 +131836,9 @@ var require_subchannel_call = __commonJS({
131836
131836
  } else {
131837
131837
  let code;
131838
131838
  if (((_a6 = this.finalStatus) === null || _a6 === void 0 ? void 0 : _a6.code) === constants_1.Status.OK) {
131839
- code = http2.constants.NGHTTP2_NO_ERROR;
131839
+ code = http22.constants.NGHTTP2_NO_ERROR;
131840
131840
  } else {
131841
- code = http2.constants.NGHTTP2_CANCEL;
131841
+ code = http22.constants.NGHTTP2_CANCEL;
131842
131842
  }
131843
131843
  this.trace("close http2 stream with code " + code);
131844
131844
  this.http2Stream.close(code);
@@ -131927,7 +131927,7 @@ var require_transport = __commonJS({
131927
131927
  "use strict";
131928
131928
  Object.defineProperty(exports2, "__esModule", { value: true });
131929
131929
  exports2.Http2SubchannelConnector = void 0;
131930
- var http2 = __require("http2");
131930
+ var http22 = __require("http2");
131931
131931
  var channelz_1 = require_channelz();
131932
131932
  var constants_1 = require_constants4();
131933
131933
  var http_proxy_1 = require_http_proxy();
@@ -131941,7 +131941,7 @@ var require_transport = __commonJS({
131941
131941
  var TRACER_NAME = "transport";
131942
131942
  var FLOW_CONTROL_TRACER_NAME = "transport_flowctrl";
131943
131943
  var clientVersion = require_package3().version;
131944
- var { HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_TE, HTTP2_HEADER_USER_AGENT } = http2.constants;
131944
+ var { HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_TE, HTTP2_HEADER_USER_AGENT } = http22.constants;
131945
131945
  var KEEPALIVE_TIMEOUT_MS = 2e4;
131946
131946
  var tooManyPingsData = Buffer.from("too_many_pings", "ascii");
131947
131947
  var Http2Transport = class {
@@ -131994,7 +131994,7 @@ var require_transport = __commonJS({
131994
131994
  });
131995
131995
  session.once("goaway", (errorCode, lastStreamID, opaqueData) => {
131996
131996
  let tooManyPings = false;
131997
- if (errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && opaqueData && opaqueData.equals(tooManyPingsData)) {
131997
+ if (errorCode === http22.constants.NGHTTP2_ENHANCE_YOUR_CALM && opaqueData && opaqueData.equals(tooManyPingsData)) {
131998
131998
  tooManyPings = true;
131999
131999
  }
132000
132000
  this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === void 0 ? void 0 : opaqueData.toString()));
@@ -132344,7 +132344,7 @@ var require_transport = __commonJS({
132344
132344
  initialWindowSize: options["grpc-node.flow_control_window"]
132345
132345
  };
132346
132346
  }
132347
- const session = http2.connect(`${scheme}://${targetPath}`, sessionOptions);
132347
+ const session = http22.connect(`${scheme}://${targetPath}`, sessionOptions);
132348
132348
  this.session = session;
132349
132349
  let errorMessage = "Failed to connect";
132350
132350
  let reportedError = false;
@@ -133002,7 +133002,7 @@ var require_load_balancing_call = __commonJS({
133002
133002
  var uri_parser_1 = require_uri_parser();
133003
133003
  var logging = require_logging();
133004
133004
  var control_plane_status_1 = require_control_plane_status();
133005
- var http2 = __require("http2");
133005
+ var http22 = __require("http2");
133006
133006
  var TRACER_NAME = "load_balancing_call";
133007
133007
  var LoadBalancingCall = class {
133008
133008
  constructor(channel, callConfig, methodName, host, credentials, deadline, callNumber) {
@@ -133115,7 +133115,7 @@ var require_load_balancing_call = __commonJS({
133115
133115
  },
133116
133116
  onReceiveStatus: (status) => {
133117
133117
  this.trace("Received status");
133118
- if (status.rstCode === http2.constants.NGHTTP2_REFUSED_STREAM) {
133118
+ if (status.rstCode === http22.constants.NGHTTP2_REFUSED_STREAM) {
133119
133119
  this.outputStatus(status, "REFUSED");
133120
133120
  } else {
133121
133121
  this.outputStatus(status, "PROCESSED");
@@ -135242,7 +135242,7 @@ var require_server_interceptors = __commonJS({
135242
135242
  exports2.getServerInterceptingCall = getServerInterceptingCall;
135243
135243
  var metadata_1 = require_metadata2();
135244
135244
  var constants_1 = require_constants4();
135245
- var http2 = __require("http2");
135245
+ var http22 = __require("http2");
135246
135246
  var error_1 = require_error();
135247
135247
  var zlib = __require("zlib");
135248
135248
  var stream_decoder_1 = require_stream_decoder();
@@ -135538,8 +135538,8 @@ var require_server_interceptors = __commonJS({
135538
135538
  [GRPC_ENCODING_HEADER]: "identity"
135539
135539
  };
135540
135540
  var defaultResponseHeaders = {
135541
- [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_OK,
135542
- [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/grpc+proto"
135541
+ [http22.constants.HTTP2_HEADER_STATUS]: http22.constants.HTTP_STATUS_OK,
135542
+ [http22.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/grpc+proto"
135543
135543
  };
135544
135544
  var defaultResponseOptions = {
135545
135545
  waitForTrailers: true
@@ -135610,9 +135610,9 @@ var require_server_interceptors = __commonJS({
135610
135610
  metadata.remove(GRPC_TIMEOUT_HEADER);
135611
135611
  metadata.remove(GRPC_ENCODING_HEADER);
135612
135612
  metadata.remove(GRPC_ACCEPT_ENCODING_HEADER);
135613
- metadata.remove(http2.constants.HTTP2_HEADER_ACCEPT_ENCODING);
135614
- metadata.remove(http2.constants.HTTP2_HEADER_TE);
135615
- metadata.remove(http2.constants.HTTP2_HEADER_CONTENT_TYPE);
135613
+ metadata.remove(http22.constants.HTTP2_HEADER_ACCEPT_ENCODING);
135614
+ metadata.remove(http22.constants.HTTP2_HEADER_TE);
135615
+ metadata.remove(http22.constants.HTTP2_HEADER_CONTENT_TYPE);
135616
135616
  this.metadata = metadata;
135617
135617
  }
135618
135618
  handleTimeoutHeader(timeoutHeader) {
@@ -135984,7 +135984,7 @@ var require_server = __commonJS({
135984
135984
  };
135985
135985
  Object.defineProperty(exports2, "__esModule", { value: true });
135986
135986
  exports2.Server = void 0;
135987
- var http2 = __require("http2");
135987
+ var http22 = __require("http2");
135988
135988
  var util4 = __require("util");
135989
135989
  var constants_1 = require_constants4();
135990
135990
  var server_call_1 = require_server_call();
@@ -135999,7 +135999,7 @@ var require_server = __commonJS({
135999
135999
  var KEEPALIVE_MAX_TIME_MS = ~(1 << 31);
136000
136000
  var KEEPALIVE_TIMEOUT_MS = 2e4;
136001
136001
  var MAX_CONNECTION_IDLE_MS = ~(1 << 31);
136002
- var { HTTP2_HEADER_PATH } = http2.constants;
136002
+ var { HTTP2_HEADER_PATH } = http22.constants;
136003
136003
  var TRACER_NAME = "server";
136004
136004
  var kMaxAge = Buffer.from("max_age");
136005
136005
  function serverCallTrace(text) {
@@ -136242,7 +136242,7 @@ var require_server = __commonJS({
136242
136242
  const secureServerOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, this.commonServerOptions), constructorOptions), contextOptions), { enableTrace: this.options["grpc-node.tls_enable_trace"] === 1 });
136243
136243
  let areCredentialsValid = contextOptions !== null;
136244
136244
  this.trace("Initial credentials valid: " + areCredentialsValid);
136245
- http2Server = http2.createSecureServer(secureServerOptions);
136245
+ http2Server = http22.createSecureServer(secureServerOptions);
136246
136246
  http2Server.prependListener("connection", (socket) => {
136247
136247
  if (!areCredentialsValid) {
136248
136248
  this.trace("Dropped connection from " + JSON.stringify(socket.address()) + " due to unloaded credentials");
@@ -136272,7 +136272,7 @@ var require_server = __commonJS({
136272
136272
  credentials._removeWatcher(credsWatcher);
136273
136273
  });
136274
136274
  } else {
136275
- http2Server = http2.createServer(this.commonServerOptions);
136275
+ http2Server = http22.createServer(this.commonServerOptions);
136276
136276
  }
136277
136277
  http2Server.setTimeout(0, noop4);
136278
136278
  this._setupHandlers(http2Server, credentials._getInterceptors());
@@ -136532,7 +136532,7 @@ var require_server = __commonJS({
136532
136532
  }
136533
136533
  (_c2 = (_b2 = setTimeout(() => {
136534
136534
  for (const session of sessionsSet) {
136535
- session.destroy(http2.constants.NGHTTP2_CANCEL);
136535
+ session.destroy(http22.constants.NGHTTP2_CANCEL);
136536
136536
  }
136537
136537
  }, graceTimeMs)).unref) === null || _c2 === void 0 ? void 0 : _c2.call(_b2);
136538
136538
  },
@@ -136655,7 +136655,7 @@ var require_server = __commonJS({
136655
136655
  }
136656
136656
  (_c2 = (_b2 = setTimeout(() => {
136657
136657
  for (const session of allSessions) {
136658
- session.destroy(http2.constants.NGHTTP2_CANCEL);
136658
+ session.destroy(http22.constants.NGHTTP2_CANCEL);
136659
136659
  }
136660
136660
  }, graceTimeMs)).unref) === null || _c2 === void 0 ? void 0 : _c2.call(_b2);
136661
136661
  }
@@ -136669,7 +136669,7 @@ var require_server = __commonJS({
136669
136669
  }
136670
136670
  this.sessions.forEach((channelzInfo, session) => {
136671
136671
  this.closeSession(session);
136672
- session.destroy(http2.constants.NGHTTP2_CANCEL);
136672
+ session.destroy(http22.constants.NGHTTP2_CANCEL);
136673
136673
  });
136674
136674
  this.sessions.clear();
136675
136675
  (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
@@ -136751,10 +136751,10 @@ var require_server = __commonJS({
136751
136751
  return this.channelzRef;
136752
136752
  }
136753
136753
  _verifyContentType(stream2, headers) {
136754
- const contentType = headers[http2.constants.HTTP2_HEADER_CONTENT_TYPE];
136754
+ const contentType = headers[http22.constants.HTTP2_HEADER_CONTENT_TYPE];
136755
136755
  if (typeof contentType !== "string" || !contentType.startsWith("application/grpc")) {
136756
136756
  stream2.respond({
136757
- [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
136757
+ [http22.constants.HTTP2_HEADER_STATUS]: http22.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
136758
136758
  }, { endStream: true });
136759
136759
  return false;
136760
136760
  }
@@ -136771,7 +136771,7 @@ var require_server = __commonJS({
136771
136771
  }
136772
136772
  _respondWithError(err, stream2, channelzSessionInfo = null) {
136773
136773
  var _b2, _c2;
136774
- const trailersToSend = Object.assign({ "grpc-status": (_b2 = err.code) !== null && _b2 !== void 0 ? _b2 : constants_1.Status.INTERNAL, "grpc-message": err.details, [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_OK, [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/grpc+proto" }, (_c2 = err.metadata) === null || _c2 === void 0 ? void 0 : _c2.toHttp2Headers());
136774
+ const trailersToSend = Object.assign({ "grpc-status": (_b2 = err.code) !== null && _b2 !== void 0 ? _b2 : constants_1.Status.INTERNAL, "grpc-message": err.details, [http22.constants.HTTP2_HEADER_STATUS]: http22.constants.HTTP_STATUS_OK, [http22.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/grpc+proto" }, (_c2 = err.metadata) === null || _c2 === void 0 ? void 0 : _c2.toHttp2Headers());
136775
136775
  stream2.respond(trailersToSend, { endStream: true });
136776
136776
  this.callTracker.addCallFailed();
136777
136777
  channelzSessionInfo === null || channelzSessionInfo === void 0 ? void 0 : channelzSessionInfo.streamTracker.addCallFailed();
@@ -136902,7 +136902,7 @@ var require_server = __commonJS({
136902
136902
  sessionClosedByServer = true;
136903
136903
  this.trace("Connection dropped by max connection age: " + ((_b3 = session.socket) === null || _b3 === void 0 ? void 0 : _b3.remoteAddress));
136904
136904
  try {
136905
- session.goaway(http2.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
136905
+ session.goaway(http22.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
136906
136906
  } catch (e2) {
136907
136907
  session.destroy();
136908
136908
  return;
@@ -137033,7 +137033,7 @@ var require_server = __commonJS({
137033
137033
  sessionClosedByServer = true;
137034
137034
  this.channelzTrace.addTrace("CT_INFO", "Connection dropped by max connection age from " + clientAddress);
137035
137035
  try {
137036
- session.goaway(http2.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
137036
+ session.goaway(http22.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
137037
137037
  } catch (e2) {
137038
137038
  session.destroy();
137039
137039
  return;
@@ -162089,8 +162089,8 @@ var require_util12 = __commonJS({
162089
162089
  exports2.prepareSend = void 0;
162090
162090
  var api_1 = (init_esm2(), __toCommonJS(esm_exports));
162091
162091
  var core_1 = require_src9();
162092
- var http2 = __require("http");
162093
- var https3 = __require("https");
162092
+ var http3 = __require("http");
162093
+ var https4 = __require("https");
162094
162094
  var url2 = __require("url");
162095
162095
  function prepareSend(urlStr, headers) {
162096
162096
  const urlOpts = url2.parse(urlStr);
@@ -162103,7 +162103,7 @@ var require_util12 = __commonJS({
162103
162103
  api_1.diag.debug("Zipkin send with empty spans");
162104
162104
  return done({ code: core_1.ExportResultCode.SUCCESS });
162105
162105
  }
162106
- const { request: request2 } = reqOpts.protocol === "http:" ? http2 : https3;
162106
+ const { request: request2 } = reqOpts.protocol === "http:" ? http3 : https4;
162107
162107
  const req = request2(reqOpts, (res) => {
162108
162108
  let rawData = "";
162109
162109
  res.on("data", (chunk) => {
@@ -173915,11 +173915,11 @@ var require_client_h2 = __commonJS({
173915
173915
  var { channels } = require_diagnostics();
173916
173916
  var kOpenStreams = Symbol("open streams");
173917
173917
  var extractBody;
173918
- var http2;
173918
+ var http22;
173919
173919
  try {
173920
- http2 = __require("node:http2");
173920
+ http22 = __require("node:http2");
173921
173921
  } catch {
173922
- http2 = { constants: {} };
173922
+ http22 = { constants: {} };
173923
173923
  }
173924
173924
  var {
173925
173925
  constants: {
@@ -173931,7 +173931,7 @@ var require_client_h2 = __commonJS({
173931
173931
  HTTP2_HEADER_EXPECT,
173932
173932
  HTTP2_HEADER_STATUS
173933
173933
  }
173934
- } = http2;
173934
+ } = http22;
173935
173935
  function parseH2Headers(headers) {
173936
173936
  const result = [];
173937
173937
  for (const [name2, value] of Object.entries(headers)) {
@@ -173947,7 +173947,7 @@ var require_client_h2 = __commonJS({
173947
173947
  }
173948
173948
  async function connectH2(client, socket) {
173949
173949
  client[kSocket] = socket;
173950
- const session = http2.connect(client[kUrl], {
173950
+ const session = http22.connect(client[kUrl], {
173951
173951
  createConnection: () => socket,
173952
173952
  peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
173953
173953
  settings: {
@@ -174473,7 +174473,7 @@ var require_client2 = __commonJS({
174473
174473
  "use strict";
174474
174474
  var assert2 = __require("node:assert");
174475
174475
  var net2 = __require("node:net");
174476
- var http2 = __require("node:http");
174476
+ var http3 = __require("node:http");
174477
174477
  var util4 = require_util13();
174478
174478
  var { ClientStats } = require_stats();
174479
174479
  var { channels } = require_diagnostics();
@@ -174528,7 +174528,7 @@ var require_client2 = __commonJS({
174528
174528
  var connectH1 = require_client_h1();
174529
174529
  var connectH2 = require_client_h2();
174530
174530
  var kClosedResolve = Symbol("kClosedResolve");
174531
- var getDefaultNodeMaxHeaderSize = http2 && http2.maxHeaderSize && Number.isInteger(http2.maxHeaderSize) && http2.maxHeaderSize > 0 ? () => http2.maxHeaderSize : () => {
174531
+ var getDefaultNodeMaxHeaderSize = http3 && http3.maxHeaderSize && Number.isInteger(http3.maxHeaderSize) && http3.maxHeaderSize > 0 ? () => http3.maxHeaderSize : () => {
174532
174532
  throw new InvalidArgumentError("http module not available or http.maxHeaderSize invalid");
174533
174533
  };
174534
174534
  var noop4 = () => {
@@ -199411,7 +199411,7 @@ var init_langfuseClient = __esm({
199411
199411
  userId,
199412
199412
  metadata: {
199413
199413
  ...safeMetadata,
199414
- cli_version: this.safeString("0.1.45", "unknown"),
199414
+ cli_version: this.safeString("0.1.47", "unknown"),
199415
199415
  model: this.safeString(process.env.CUSTOM_LLM_MODEL_NAME, "gemini"),
199416
199416
  auth_type: process.env.USE_CUSTOM_LLM ? "custom_llm" : "google_oauth",
199417
199417
  environment: this.safeString(this.configManager.getConfig()?.environment, "unknown")
@@ -200578,7 +200578,7 @@ var init_langfuseIntegration = __esm({
200578
200578
  const metadata = {
200579
200579
  model: this.config.getModel(),
200580
200580
  auth_type: this.config.getContentGeneratorConfig()?.authType,
200581
- cli_version: "0.1.45",
200581
+ cli_version: "0.1.47",
200582
200582
  start_time: (/* @__PURE__ */ new Date()).toISOString(),
200583
200583
  session_id: this.sessionId
200584
200584
  };
@@ -200637,7 +200637,7 @@ var init_langfuseIntegration = __esm({
200637
200637
  totalCachedTokens: sessionStats.totalCachedTokens,
200638
200638
  totalPromptTokens: sessionStats.totalPromptTokens,
200639
200639
  metadata: {
200640
- cli_version: "0.1.45",
200640
+ cli_version: "0.1.47",
200641
200641
  auth_type: this.config.getContentGeneratorConfig()?.authType,
200642
200642
  session_end_time: (/* @__PURE__ */ new Date()).toISOString()
200643
200643
  }
@@ -200709,7 +200709,7 @@ var init_langfuseIntegration = __esm({
200709
200709
  error,
200710
200710
  metadata: {
200711
200711
  session_id: this.sessionId,
200712
- cli_version: "0.1.45",
200712
+ cli_version: "0.1.47",
200713
200713
  auth_type: this.config.getContentGeneratorConfig()?.authType
200714
200714
  }
200715
200715
  });
@@ -206130,7 +206130,7 @@ __export(version_exports, {
206130
206130
  });
206131
206131
  async function getCliVersion() {
206132
206132
  const pkgJson = await getPackageJson();
206133
- return "0.1.45";
206133
+ return "0.1.47";
206134
206134
  }
206135
206135
  var init_version5 = __esm({
206136
206136
  "packages/cli/src/utils/version.ts"() {
@@ -209855,6 +209855,227 @@ var init_update = __esm({
209855
209855
  }
209856
209856
  });
209857
209857
 
209858
+ // packages/router/dist/src/utils/diagnose.js
209859
+ import { existsSync as existsSync13 } from "fs";
209860
+ import https3 from "https";
209861
+ import http2 from "http";
209862
+ async function diagnoseRouterConfig() {
209863
+ const result = {
209864
+ configFile: "",
209865
+ configExists: false,
209866
+ configValid: false,
209867
+ providers: [],
209868
+ router: {},
209869
+ issues: []
209870
+ };
209871
+ try {
209872
+ const configFilePath2 = await getConfigFilePath();
209873
+ result.configFile = configFilePath2;
209874
+ result.configExists = existsSync13(configFilePath2);
209875
+ if (!result.configExists) {
209876
+ result.issues.push(`Configuration file does not exist: ${configFilePath2}`);
209877
+ return result;
209878
+ }
209879
+ let config2;
209880
+ try {
209881
+ config2 = await readConfigFile();
209882
+ result.configValid = true;
209883
+ } catch (error) {
209884
+ result.issues.push(`Failed to read config file: ${error.message}`);
209885
+ return result;
209886
+ }
209887
+ if (!config2.Providers || !Array.isArray(config2.Providers) || config2.Providers.length === 0) {
209888
+ result.issues.push("No Providers configured in router-config.json");
209889
+ } else {
209890
+ for (const provider of config2.Providers) {
209891
+ const providerInfo = {
209892
+ name: provider.name || "Unknown",
209893
+ api_base_url: provider.api_base_url || "",
209894
+ models: Array.isArray(provider.models) ? provider.models : [],
209895
+ hasApiKey: !!provider.api_key,
209896
+ endpointReachable: void 0,
209897
+ endpointError: void 0
209898
+ };
209899
+ if (!providerInfo.name) {
209900
+ result.issues.push("Provider missing name");
209901
+ }
209902
+ if (!providerInfo.api_base_url) {
209903
+ result.issues.push(`Provider "${providerInfo.name}" missing api_base_url`);
209904
+ } else {
209905
+ try {
209906
+ const reachable = await testEndpointReachability(providerInfo.api_base_url);
209907
+ providerInfo.endpointReachable = reachable.reachable;
209908
+ providerInfo.endpointError = reachable.error;
209909
+ if (!reachable.reachable) {
209910
+ result.issues.push(`Provider "${providerInfo.name}" endpoint unreachable: ${reachable.error}`);
209911
+ }
209912
+ } catch (error) {
209913
+ providerInfo.endpointReachable = false;
209914
+ providerInfo.endpointError = error.message;
209915
+ result.issues.push(`Provider "${providerInfo.name}" endpoint test failed: ${error.message}`);
209916
+ }
209917
+ }
209918
+ if (providerInfo.models.length === 0) {
209919
+ result.issues.push(`Provider "${providerInfo.name}" has no models configured`);
209920
+ }
209921
+ if (!providerInfo.hasApiKey) {
209922
+ result.issues.push(`Provider "${providerInfo.name}" missing api_key`);
209923
+ }
209924
+ result.providers.push(providerInfo);
209925
+ }
209926
+ }
209927
+ if (config2.Router && typeof config2.Router === "object") {
209928
+ result.router = {
209929
+ default: config2.Router.default,
209930
+ background: config2.Router.background,
209931
+ think: config2.Router.think,
209932
+ longContext: config2.Router.longContext,
209933
+ webSearch: config2.Router.webSearch,
209934
+ image: config2.Router.image
209935
+ };
209936
+ const allModelNames = /* @__PURE__ */ new Set();
209937
+ result.providers.forEach((p) => {
209938
+ p.models.forEach((m) => allModelNames.add(m.toLowerCase()));
209939
+ });
209940
+ const validateModelReference = (modelRef, type) => {
209941
+ if (!modelRef)
209942
+ return;
209943
+ if (modelRef.includes(",")) {
209944
+ const [providerName, modelName] = modelRef.split(",");
209945
+ const provider = result.providers.find((p) => p.name.toLowerCase() === providerName.trim().toLowerCase());
209946
+ if (!provider) {
209947
+ result.issues.push(`Router.${type} references unknown provider: "${providerName}"`);
209948
+ } else {
209949
+ const modelExists = provider.models.some((m) => m.toLowerCase() === modelName.trim().toLowerCase());
209950
+ if (!modelExists) {
209951
+ result.issues.push(`Router.${type} references unknown model: "${modelName}" in provider "${providerName}"`);
209952
+ }
209953
+ }
209954
+ } else {
209955
+ const modelExists = Array.from(allModelNames).some((m) => m === modelRef.toLowerCase());
209956
+ if (!modelExists) {
209957
+ result.issues.push(`Router.${type} references unknown model: "${modelRef}"`);
209958
+ }
209959
+ }
209960
+ };
209961
+ validateModelReference(result.router.default, "default");
209962
+ validateModelReference(result.router.background, "background");
209963
+ validateModelReference(result.router.think, "think");
209964
+ validateModelReference(result.router.longContext, "longContext");
209965
+ validateModelReference(result.router.webSearch, "webSearch");
209966
+ validateModelReference(result.router.image, "image");
209967
+ } else {
209968
+ result.issues.push("Router configuration is missing or invalid");
209969
+ }
209970
+ if (config2.PORT && (config2.PORT < 1 || config2.PORT > 65535)) {
209971
+ result.issues.push(`Invalid PORT: ${config2.PORT} (must be 1-65535)`);
209972
+ }
209973
+ if (!config2.APIKEY || config2.APIKEY === "123456") {
209974
+ result.issues.push("APIKEY is missing or using default value (123456)");
209975
+ }
209976
+ const hasSSLIssue = result.providers.some((p) => p.endpointReachable === false && p.endpointError && (p.endpointError.includes("SSL") || p.endpointError.includes("certificate")));
209977
+ if (hasSSLIssue && !config2.REJECT_UNAUTHORIZED && !config2.ALLOW_INSECURE_SSL) {
209978
+ result.issues.push('SSL certificate verification failed for some endpoints. Add "REJECT_UNAUTHORIZED": false or "ALLOW_INSECURE_SSL": true to router-config.json to allow self-signed certificates.');
209979
+ }
209980
+ } catch (error) {
209981
+ result.issues.push(`Diagnostic error: ${error.message}`);
209982
+ }
209983
+ return result;
209984
+ }
209985
+ async function testEndpointReachability(url2) {
209986
+ return new Promise((resolve18) => {
209987
+ try {
209988
+ const urlObj = new URL(url2);
209989
+ const isHttps = urlObj.protocol === "https:";
209990
+ const client = isHttps ? https3 : http2;
209991
+ const options = {
209992
+ hostname: urlObj.hostname,
209993
+ port: urlObj.port || (isHttps ? 443 : 80),
209994
+ path: urlObj.pathname,
209995
+ method: "OPTIONS",
209996
+ // Use OPTIONS to test connectivity without sending data
209997
+ timeout: 5e3,
209998
+ rejectUnauthorized: false
209999
+ // Allow self-signed certificates for testing
210000
+ };
210001
+ const req = client.request(options, (res) => {
210002
+ resolve18({ reachable: true });
210003
+ });
210004
+ req.on("error", (error) => {
210005
+ let errorMsg = error.message;
210006
+ if (error.code === "ENOTFOUND") {
210007
+ errorMsg = `DNS resolution failed (${error.hostname})`;
210008
+ } else if (error.code === "ECONNREFUSED") {
210009
+ errorMsg = "Connection refused (server may be down)";
210010
+ } else if (error.code === "ETIMEDOUT") {
210011
+ errorMsg = "Connection timeout (server may be unreachable)";
210012
+ } else if (error.code === "ECONNRESET") {
210013
+ errorMsg = "Connection reset";
210014
+ } else if (error.code === "SELF_SIGNED_CERT_IN_CHAIN") {
210015
+ errorMsg = "SSL certificate issue (self-signed certificate)";
210016
+ }
210017
+ resolve18({ reachable: false, error: errorMsg });
210018
+ });
210019
+ req.on("timeout", () => {
210020
+ req.destroy();
210021
+ resolve18({ reachable: false, error: "Connection timeout (5s)" });
210022
+ });
210023
+ req.setTimeout(5e3);
210024
+ req.end();
210025
+ } catch (error) {
210026
+ resolve18({ reachable: false, error: `Invalid URL: ${error.message}` });
210027
+ }
210028
+ });
210029
+ }
210030
+ function printDiagnosticResult(result) {
210031
+ console.log("\n\u{1F4CB} Router Configuration Diagnostic\n");
210032
+ console.log(`Config File: ${result.configFile}`);
210033
+ console.log(`Exists: ${result.configExists ? "\u2705" : "\u274C"}`);
210034
+ console.log(`Valid: ${result.configValid ? "\u2705" : "\u274C"}
210035
+ `);
210036
+ if (result.providers.length > 0) {
210037
+ console.log("Providers:");
210038
+ result.providers.forEach((provider, index) => {
210039
+ console.log(` ${index + 1}. ${provider.name}`);
210040
+ console.log(` API URL: ${provider.api_base_url || "\u274C Missing"}`);
210041
+ if (provider.endpointReachable !== void 0) {
210042
+ if (provider.endpointReachable) {
210043
+ console.log(` Endpoint: \u2705 Reachable`);
210044
+ } else {
210045
+ console.log(` Endpoint: \u274C Unreachable - ${provider.endpointError || "Unknown error"}`);
210046
+ }
210047
+ }
210048
+ console.log(` API Key: ${provider.hasApiKey ? "\u2705 Set" : "\u274C Missing"}`);
210049
+ console.log(` Models: ${provider.models.length > 0 ? provider.models.join(", ") : "\u274C None"}`);
210050
+ });
210051
+ console.log("");
210052
+ }
210053
+ if (Object.keys(result.router).length > 0) {
210054
+ console.log("Router Configuration:");
210055
+ Object.entries(result.router).forEach(([key, value]) => {
210056
+ if (value) {
210057
+ console.log(` ${key}: ${value}`);
210058
+ }
210059
+ });
210060
+ console.log("");
210061
+ }
210062
+ if (result.issues.length > 0) {
210063
+ console.log("\u26A0\uFE0F Issues Found:");
210064
+ result.issues.forEach((issue, index) => {
210065
+ console.log(` ${index + 1}. ${issue}`);
210066
+ });
210067
+ console.log("");
210068
+ } else {
210069
+ console.log("\u2705 No issues found!\n");
210070
+ }
210071
+ }
210072
+ var init_diagnose = __esm({
210073
+ "packages/router/dist/src/utils/diagnose.js"() {
210074
+ "use strict";
210075
+ init_utils6();
210076
+ }
210077
+ });
210078
+
209858
210079
  // packages/router/dist/src/utils/index.js
209859
210080
  import fs33 from "node:fs/promises";
209860
210081
  import path39 from "node:path";
@@ -209866,6 +210087,7 @@ var init_utils6 = __esm({
209866
210087
  init_constants2();
209867
210088
  init_logCleanup();
209868
210089
  init_update();
210090
+ init_diagnose();
209869
210091
  interpolateEnvVars = (obj) => {
209870
210092
  if (typeof obj === "string") {
209871
210093
  return obj.replace(/\$\{([^}]+)\}|\$([A-Z_][A-Z0-9_]*)/g, (match2, braced, unbraced) => {
@@ -210032,6 +210254,11 @@ var init_utils6 = __esm({
210032
210254
  initConfig = async () => {
210033
210255
  const config2 = await readConfigFile();
210034
210256
  Object.assign(process.env, config2);
210257
+ if (config2.REJECT_UNAUTHORIZED === false || config2.ALLOW_INSECURE_SSL === true) {
210258
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
210259
+ } else if (config2.REJECT_UNAUTHORIZED === true) {
210260
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "1";
210261
+ }
210035
210262
  return config2;
210036
210263
  };
210037
210264
  updateRouterConfigFromModel = async (modelData) => {
@@ -212563,8 +212790,8 @@ var require_promise2 = __commonJS({
212563
212790
  var require_server2 = __commonJS({
212564
212791
  "node_modules/fastify/lib/server.js"(exports2, module2) {
212565
212792
  "use strict";
212566
- var http2 = __require("node:http");
212567
- var https3 = __require("node:https");
212793
+ var http3 = __require("node:http");
212794
+ var https4 = __require("node:https");
212568
212795
  var http22 = __require("node:http2");
212569
212796
  var dns = __require("node:dns");
212570
212797
  var os24 = __require("node:os");
@@ -212791,7 +213018,7 @@ var require_server2 = __commonJS({
212791
213018
  server2.setTimeout(options.connectionTimeout);
212792
213019
  return server2;
212793
213020
  }
212794
- const server = httpsOptions ? https3.createServer(httpsOptions, httpHandler) : http2.createServer(options.http, httpHandler);
213021
+ const server = httpsOptions ? https4.createServer(httpsOptions, httpHandler) : http3.createServer(options.http, httpHandler);
212795
213022
  server.keepAliveTimeout = options.keepAliveTimeout;
212796
213023
  server.requestTimeout = options.requestTimeout;
212797
213024
  server.setTimeout(options.connectionTimeout);
@@ -252074,12 +252301,12 @@ var require_set_cookie = __commonJS({
252074
252301
  var require_response2 = __commonJS({
252075
252302
  "node_modules/light-my-request/lib/response.js"(exports2, module2) {
252076
252303
  "use strict";
252077
- var http2 = __require("node:http");
252304
+ var http3 = __require("node:http");
252078
252305
  var { Writable, Readable, addAbortSignal } = __require("node:stream");
252079
252306
  var util4 = __require("node:util");
252080
252307
  var setCookie = require_set_cookie();
252081
252308
  function Response2(req, onEnd, reject) {
252082
- http2.ServerResponse.call(this, req);
252309
+ http3.ServerResponse.call(this, req);
252083
252310
  if (req._lightMyRequest?.payloadAsStream) {
252084
252311
  const read = this.emit.bind(this, "drain");
252085
252312
  this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read }) };
@@ -252144,7 +252371,7 @@ var require_response2 = __commonJS({
252144
252371
  this.once("error", onEndFailure);
252145
252372
  this.once("close", onEndFailure);
252146
252373
  }
252147
- util4.inherits(Response2, http2.ServerResponse);
252374
+ util4.inherits(Response2, http3.ServerResponse);
252148
252375
  Response2.prototype.setTimeout = function(msecs, callback) {
252149
252376
  this.timeoutHandle = setTimeout(() => {
252150
252377
  this.emit("timeout");
@@ -252153,7 +252380,7 @@ var require_response2 = __commonJS({
252153
252380
  return this;
252154
252381
  };
252155
252382
  Response2.prototype.writeHead = function() {
252156
- const result = http2.ServerResponse.prototype.writeHead.apply(this, arguments);
252383
+ const result = http3.ServerResponse.prototype.writeHead.apply(this, arguments);
252157
252384
  copyHeaders(this);
252158
252385
  if (this._lightMyRequest.stream) {
252159
252386
  this._lightMyRequest.onEndSuccess(generatePayload(this));
@@ -252164,7 +252391,7 @@ var require_response2 = __commonJS({
252164
252391
  if (this.timeoutHandle) {
252165
252392
  clearTimeout(this.timeoutHandle);
252166
252393
  }
252167
- http2.ServerResponse.prototype.write.call(this, data, encoding, callback);
252394
+ http3.ServerResponse.prototype.write.call(this, data, encoding, callback);
252168
252395
  if (this._lightMyRequest.stream) {
252169
252396
  return this._lightMyRequest.stream.push(Buffer.from(data, encoding));
252170
252397
  } else {
@@ -252176,7 +252403,7 @@ var require_response2 = __commonJS({
252176
252403
  if (data) {
252177
252404
  this.write(data, encoding);
252178
252405
  }
252179
- http2.ServerResponse.prototype.end.call(this, callback);
252406
+ http3.ServerResponse.prototype.end.call(this, callback);
252180
252407
  this.emit("finish");
252181
252408
  this.destroy();
252182
252409
  };
@@ -253257,7 +253484,7 @@ var require_fastify = __commonJS({
253257
253484
  "use strict";
253258
253485
  var VERSION3 = "5.6.1";
253259
253486
  var Avvio = require_boot();
253260
- var http2 = __require("node:http");
253487
+ var http3 = __require("node:http");
253261
253488
  var diagnostics = __require("node:diagnostics_channel");
253262
253489
  var lightMyRequest;
253263
253490
  var {
@@ -253849,17 +254076,17 @@ var require_fastify = __commonJS({
253849
254076
  let body, errorCode, errorStatus, errorLabel;
253850
254077
  if (err.code === "ERR_HTTP_REQUEST_TIMEOUT") {
253851
254078
  errorCode = "408";
253852
- errorStatus = http2.STATUS_CODES[errorCode];
254079
+ errorStatus = http3.STATUS_CODES[errorCode];
253853
254080
  body = `{"error":"${errorStatus}","message":"Client Timeout","statusCode":408}`;
253854
254081
  errorLabel = "timeout";
253855
254082
  } else if (err.code === "HPE_HEADER_OVERFLOW") {
253856
254083
  errorCode = "431";
253857
- errorStatus = http2.STATUS_CODES[errorCode];
254084
+ errorStatus = http3.STATUS_CODES[errorCode];
253858
254085
  body = `{"error":"${errorStatus}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`;
253859
254086
  errorLabel = "header_overflow";
253860
254087
  } else {
253861
254088
  errorCode = "400";
253862
- errorStatus = http2.STATUS_CODES[errorCode];
254089
+ errorStatus = http3.STATUS_CODES[errorCode];
253863
254090
  body = `{"error":"${errorStatus}","message":"Client Error","statusCode":400}`;
253864
254091
  errorLabel = "error";
253865
254092
  }
@@ -254002,7 +254229,7 @@ ${body}`);
254002
254229
  return this;
254003
254230
  }
254004
254231
  function addHttpMethod(method, { hasBody = false } = {}) {
254005
- if (typeof method !== "string" || http2.METHODS.indexOf(method) === -1) {
254232
+ if (typeof method !== "string" || http3.METHODS.indexOf(method) === -1) {
254006
254233
  throw new FST_ERR_ROUTE_METHOD_INVALID();
254007
254234
  }
254008
254235
  if (hasBody === true) {
@@ -276829,7 +277056,7 @@ var require_package7 = __commonJS({
276829
277056
  "packages/router/package.json"(exports2, module2) {
276830
277057
  module2.exports = {
276831
277058
  name: "@mpdai/router",
276832
- version: "0.1.10",
277059
+ version: "0.1.12",
276833
277060
  description: "MPD AI Router - Route Claude Code to other LLM providers",
276834
277061
  type: "module",
276835
277062
  main: "dist/index.js",
@@ -276872,7 +277099,7 @@ var require_package7 = __commonJS({
276872
277099
  // packages/router/dist/src/server.js
276873
277100
  import { join as join19, dirname as dirname7 } from "path";
276874
277101
  import { fileURLToPath as fileURLToPath7 } from "url";
276875
- import { readdirSync as readdirSync2, statSync as statSync2, readFileSync as readFileSync12, writeFileSync as writeFileSync5, existsSync as existsSync13 } from "fs";
277102
+ import { readdirSync as readdirSync2, statSync as statSync2, readFileSync as readFileSync12, writeFileSync as writeFileSync5, existsSync as existsSync14 } from "fs";
276876
277103
  var import_static, __filename2, __dirname4, createServer4;
276877
277104
  var init_server3 = __esm({
276878
277105
  "packages/router/dist/src/server.js"() {
@@ -276966,7 +277193,7 @@ var init_server3 = __esm({
276966
277193
  try {
276967
277194
  const logDir = join19(HOME_DIR, "logs");
276968
277195
  const logFiles = [];
276969
- if (existsSync13(logDir)) {
277196
+ if (existsSync14(logDir)) {
276970
277197
  const files = readdirSync2(logDir);
276971
277198
  for (const file of files) {
276972
277199
  if (file.endsWith(".log")) {
@@ -276997,7 +277224,7 @@ var init_server3 = __esm({
276997
277224
  } else {
276998
277225
  logFilePath = join19(HOME_DIR, "logs", "app.log");
276999
277226
  }
277000
- if (!existsSync13(logFilePath)) {
277227
+ if (!existsSync14(logFilePath)) {
277001
277228
  return [];
277002
277229
  }
277003
277230
  const logContent = readFileSync12(logFilePath, "utf8");
@@ -277017,7 +277244,7 @@ var init_server3 = __esm({
277017
277244
  } else {
277018
277245
  logFilePath = join19(HOME_DIR, "logs", "app.log");
277019
277246
  }
277020
- if (existsSync13(logFilePath)) {
277247
+ if (existsSync14(logFilePath)) {
277021
277248
  writeFileSync5(logFilePath, "", "utf8");
277022
277249
  }
277023
277250
  return { success: true, message: "Logs cleared successfully" };
@@ -278037,7 +278264,7 @@ var require_dist10 = __commonJS({
278037
278264
  });
278038
278265
 
278039
278266
  // packages/router/dist/src/utils/processCheck.js
278040
- import { existsSync as existsSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
278267
+ import { existsSync as existsSync15, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
278041
278268
  import { execSync as execSync2 } from "child_process";
278042
278269
  async function isProcessRunning(pid) {
278043
278270
  try {
@@ -278049,7 +278276,7 @@ async function isProcessRunning(pid) {
278049
278276
  }
278050
278277
  function incrementReferenceCount() {
278051
278278
  let count = 0;
278052
- if (existsSync14(REFERENCE_COUNT_FILE)) {
278279
+ if (existsSync15(REFERENCE_COUNT_FILE)) {
278053
278280
  count = parseInt(readFileSync13(REFERENCE_COUNT_FILE, "utf-8")) || 0;
278054
278281
  }
278055
278282
  count++;
@@ -278057,20 +278284,20 @@ function incrementReferenceCount() {
278057
278284
  }
278058
278285
  function decrementReferenceCount() {
278059
278286
  let count = 0;
278060
- if (existsSync14(REFERENCE_COUNT_FILE)) {
278287
+ if (existsSync15(REFERENCE_COUNT_FILE)) {
278061
278288
  count = parseInt(readFileSync13(REFERENCE_COUNT_FILE, "utf-8")) || 0;
278062
278289
  }
278063
278290
  count = Math.max(0, count - 1);
278064
278291
  writeFileSync6(REFERENCE_COUNT_FILE, count.toString());
278065
278292
  }
278066
278293
  function getReferenceCount() {
278067
- if (!existsSync14(REFERENCE_COUNT_FILE)) {
278294
+ if (!existsSync15(REFERENCE_COUNT_FILE)) {
278068
278295
  return 0;
278069
278296
  }
278070
278297
  return parseInt(readFileSync13(REFERENCE_COUNT_FILE, "utf-8")) || 0;
278071
278298
  }
278072
278299
  function isServiceRunning() {
278073
- if (!existsSync14(PID_FILE)) {
278300
+ if (!existsSync15(PID_FILE)) {
278074
278301
  return false;
278075
278302
  }
278076
278303
  let pid;
@@ -278107,7 +278334,7 @@ function savePid(pid) {
278107
278334
  writeFileSync6(PID_FILE, pid.toString());
278108
278335
  }
278109
278336
  function cleanupPidFile() {
278110
- if (existsSync14(PID_FILE)) {
278337
+ if (existsSync15(PID_FILE)) {
278111
278338
  try {
278112
278339
  const fs54 = __require("fs");
278113
278340
  fs54.unlinkSync(PID_FILE);
@@ -278116,7 +278343,7 @@ function cleanupPidFile() {
278116
278343
  }
278117
278344
  }
278118
278345
  function getServicePid() {
278119
- if (!existsSync14(PID_FILE)) {
278346
+ if (!existsSync15(PID_FILE)) {
278120
278347
  return null;
278121
278348
  }
278122
278349
  try {
@@ -278561,7 +278788,7 @@ var init_agents = __esm({
278561
278788
  });
278562
278789
 
278563
278790
  // packages/router/dist/src/index.js
278564
- import { existsSync as existsSync15 } from "fs";
278791
+ import { existsSync as existsSync16 } from "fs";
278565
278792
  import { writeFile as writeFile3 } from "fs/promises";
278566
278793
  import { homedir as homedir13 } from "os";
278567
278794
  import { join as join20 } from "path";
@@ -278570,7 +278797,7 @@ import { EventEmitter as EventEmitter6 } from "node:events";
278570
278797
  async function initializeClaudeConfig() {
278571
278798
  const homeDir2 = homedir13();
278572
278799
  const configPath = join20(homeDir2, ".claude.json");
278573
- if (!existsSync15(configPath)) {
278800
+ if (!existsSync16(configPath)) {
278574
278801
  const userID = Array.from({ length: 64 }, () => Math.random().toString(16)[2]).join("");
278575
278802
  const configContent = {
278576
278803
  numStartups: 184,
@@ -283073,6 +283300,7 @@ __export(dist_exports2, {
283073
283300
  cleanupLogFiles: () => cleanupLogFiles,
283074
283301
  cleanupPidFile: () => cleanupPidFile,
283075
283302
  decrementReferenceCount: () => decrementReferenceCount,
283303
+ diagnoseRouterConfig: () => diagnoseRouterConfig,
283076
283304
  executeCodeCommand: () => executeCodeCommand,
283077
283305
  getConfigFilePath: () => getConfigFilePath,
283078
283306
  getReferenceCount: () => getReferenceCount,
@@ -283085,6 +283313,7 @@ __export(dist_exports2, {
283085
283313
  isServiceRunning: () => isServiceRunning,
283086
283314
  parseStatusLineData: () => parseStatusLineData,
283087
283315
  performUpdate: () => performUpdate,
283316
+ printDiagnosticResult: () => printDiagnosticResult,
283088
283317
  readConfigFile: () => readConfigFile,
283089
283318
  run: () => run,
283090
283319
  runModelSelector: () => runModelSelector,
@@ -295608,7 +295837,7 @@ var require_config_chain = __commonJS({
295608
295837
  var ini3 = require_ini2();
295609
295838
  var EE = __require("events").EventEmitter;
295610
295839
  var url2 = __require("url");
295611
- var http2 = __require("http");
295840
+ var http3 = __require("http");
295612
295841
  var exports2 = module2.exports = function() {
295613
295842
  var args = [].slice.call(arguments), conf = new ConfigChain();
295614
295843
  while (args.length) {
@@ -295791,7 +296020,7 @@ var require_config_chain = __commonJS({
295791
296020
  var marker = { __source__: name2 };
295792
296021
  this.sources[name2] = { href, type };
295793
296022
  this.push(marker);
295794
- http2.request(req, function(res) {
296023
+ http3.request(req, function(res) {
295795
296024
  var c3 = [];
295796
296025
  var ct = res.headers["content-type"];
295797
296026
  if (!type) {
@@ -310814,7 +311043,7 @@ import { promises as fs36 } from "fs";
310814
311043
  import path40 from "path";
310815
311044
 
310816
311045
  // packages/cli/src/generated/git-commit.ts
310817
- var GIT_COMMIT_INFO = "8491a55 (local modifications)";
311046
+ var GIT_COMMIT_INFO = "af48d1a (local modifications)";
310818
311047
 
310819
311048
  // packages/cli/src/ui/hooks/slashCommandProcessor.ts
310820
311049
  init_version5();
@@ -311036,7 +311265,27 @@ var modelCommand = {
311036
311265
  content: "\u274C Failed to load user credentials."
311037
311266
  };
311038
311267
  }
311039
- const authResponse = await authService.authenticate(credentials);
311268
+ let authResponse;
311269
+ if (credentials.sso) {
311270
+ const now = Math.floor(Date.now() / 1e3);
311271
+ const tokenPayload = {
311272
+ r10_transaction_type: "LOGIN",
311273
+ aud: ["jid_sample_client"],
311274
+ sub: credentials.username.split("@")[0],
311275
+ // 使用用户名部分作为 sub
311276
+ r10_factor: "password",
311277
+ r10_mobile_email: credentials.username,
311278
+ auth_time: now,
311279
+ iss: "https://stg.login.account.rakuten.com",
311280
+ exp: now + 365 * 24 * 60 * 60,
311281
+ // 1年后过期
311282
+ iat: now,
311283
+ email: credentials.username
311284
+ };
311285
+ authResponse = await authService.authenticateWithToken(tokenPayload);
311286
+ } else {
311287
+ authResponse = await authService.authenticate(credentials);
311288
+ }
311040
311289
  if (!authResponse.success || !authResponse.models) {
311041
311290
  return {
311042
311291
  type: "message",
@@ -311066,7 +311315,7 @@ init_dist4();
311066
311315
  init_dist4();
311067
311316
  init_dist4();
311068
311317
  init_dist4();
311069
- import { readFileSync as readFileSync16, existsSync as existsSync17, unlinkSync as unlinkSync2 } from "fs";
311318
+ import { readFileSync as readFileSync16, existsSync as existsSync18, unlinkSync as unlinkSync2 } from "fs";
311070
311319
  async function waitForService(timeout2 = 1e4, initialDelay = 1e3) {
311071
311320
  await new Promise((resolve18) => setTimeout(resolve18, initialDelay));
311072
311321
  const startTime = Date.now();
@@ -311100,6 +311349,10 @@ async function handleRouterCode(args) {
311100
311349
  executeCodeCommand(codeArgs);
311101
311350
  }
311102
311351
  }
311352
+ async function handleRouterDiagnose() {
311353
+ const result = await diagnoseRouterConfig();
311354
+ printDiagnosticResult(result);
311355
+ }
311103
311356
  var routerCommand = {
311104
311357
  name: "router",
311105
311358
  description: "Router commands for managing the MPD AI router service",
@@ -311117,6 +311370,13 @@ var routerCommand = {
311117
311370
  action: async (_context, args) => {
311118
311371
  await handleRouterCode(args);
311119
311372
  }
311373
+ },
311374
+ {
311375
+ name: "diagnose",
311376
+ description: "Diagnose router configuration issues",
311377
+ action: async (_context, _args) => {
311378
+ await handleRouterDiagnose();
311379
+ }
311120
311380
  }
311121
311381
  ]
311122
311382
  };
@@ -311166,7 +311426,27 @@ var claudeCodeModelCommand = {
311166
311426
  content: "\u274C Failed to load user credentials."
311167
311427
  };
311168
311428
  }
311169
- const authResponse = await authService.authenticate(credentials);
311429
+ let authResponse;
311430
+ if (credentials.sso) {
311431
+ const now = Math.floor(Date.now() / 1e3);
311432
+ const tokenPayload = {
311433
+ r10_transaction_type: "LOGIN",
311434
+ aud: ["jid_sample_client"],
311435
+ sub: credentials.username.split("@")[0],
311436
+ // 使用用户名部分作为 sub
311437
+ r10_factor: "password",
311438
+ r10_mobile_email: credentials.username,
311439
+ auth_time: now,
311440
+ iss: "https://stg.login.account.rakuten.com",
311441
+ exp: now + 365 * 24 * 60 * 60,
311442
+ // 1年后过期
311443
+ iat: now,
311444
+ email: credentials.username
311445
+ };
311446
+ authResponse = await authService.authenticateWithToken(tokenPayload);
311447
+ } else {
311448
+ authResponse = await authService.authenticate(credentials);
311449
+ }
311170
311450
  if (!authResponse.success || !authResponse.models) {
311171
311451
  return {
311172
311452
  type: "message",
@@ -332174,7 +332454,7 @@ var DataCollector = class {
332174
332454
  // 提取元数据
332175
332455
  extractMetadata(data) {
332176
332456
  return {
332177
- cli_version: "0.1.45",
332457
+ cli_version: "0.1.47",
332178
332458
  model: process.env.CUSTOM_LLM_MODEL_NAME || "gemini",
332179
332459
  auth_type: process.env.USE_CUSTOM_LLM ? "custom_llm" : "google_oauth",
332180
332460
  project_path: data.projectPath,
@@ -337985,7 +338265,25 @@ var App2 = ({ config: config2, settings, startupWarnings = [] }) => {
337985
338265
  );
337986
338266
  return;
337987
338267
  }
337988
- const authResponse = await authService.authenticate(credentials);
338268
+ let authResponse;
338269
+ if (credentials.sso) {
338270
+ const now = Math.floor(Date.now() / 1e3);
338271
+ const tokenPayload = {
338272
+ r10_transaction_type: "LOGIN",
338273
+ aud: ["jid_sample_client"],
338274
+ sub: credentials.username.split("@")[0],
338275
+ r10_factor: "password",
338276
+ r10_mobile_email: credentials.username,
338277
+ auth_time: now,
338278
+ iss: "https://stg.login.account.rakuten.com",
338279
+ exp: now + 365 * 24 * 60 * 60,
338280
+ iat: now,
338281
+ email: credentials.username
338282
+ };
338283
+ authResponse = await authService.authenticateWithToken(tokenPayload);
338284
+ } else {
338285
+ authResponse = await authService.authenticate(credentials);
338286
+ }
337989
338287
  if (authResponse.success && authResponse.models) {
337990
338288
  setAvailableModels(authResponse.models);
337991
338289
  setShowModelDialog(true);
@@ -339617,7 +339915,7 @@ init_dist4();
339617
339915
  init_dist4();
339618
339916
  init_dist4();
339619
339917
  init_dist4();
339620
- import { readFileSync as readFileSync22, existsSync as existsSync22, unlinkSync as unlinkSync3 } from "fs";
339918
+ import { readFileSync as readFileSync22, existsSync as existsSync23, unlinkSync as unlinkSync3 } from "fs";
339621
339919
  async function waitForService2(timeout2 = 1e4, initialDelay = 1e3) {
339622
339920
  await new Promise((resolve18) => setTimeout(resolve18, initialDelay));
339623
339921
  const startTime = Date.now();
@@ -339646,7 +339944,7 @@ async function handleRouterCommand(command, args) {
339646
339944
  const pid = parseInt(readFileSync22(PID_FILE, "utf-8"));
339647
339945
  process.kill(pid);
339648
339946
  cleanupPidFile();
339649
- if (existsSync22(REFERENCE_COUNT_FILE)) {
339947
+ if (existsSync23(REFERENCE_COUNT_FILE)) {
339650
339948
  try {
339651
339949
  unlinkSync3(REFERENCE_COUNT_FILE);
339652
339950
  } catch (e2) {
@@ -339663,7 +339961,7 @@ async function handleRouterCommand(command, args) {
339663
339961
  const pid = parseInt(readFileSync22(PID_FILE, "utf-8"));
339664
339962
  process.kill(pid);
339665
339963
  cleanupPidFile();
339666
- if (existsSync22(REFERENCE_COUNT_FILE)) {
339964
+ if (existsSync23(REFERENCE_COUNT_FILE)) {
339667
339965
  try {
339668
339966
  unlinkSync3(REFERENCE_COUNT_FILE);
339669
339967
  } catch (e2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mpd-llm-cli",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://git.rakuten-it.com/scm/mpd-ai/mpd-llm-cli.git"
14
14
  },
15
15
  "config": {
16
- "sandboxImageUri": "xx:0.1.45"
16
+ "sandboxImageUri": "xx:0.1.47"
17
17
  },
18
18
  "scripts": {
19
19
  "start": "node scripts/start.js",