@probelabs/probe 0.6.0-rc263 → 0.6.0-rc264

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/cjs/index.cjs CHANGED
@@ -19363,7 +19363,7 @@ var require_package2 = __commonJS({
19363
19363
  module2.exports = {
19364
19364
  name: "@aws-sdk/client-bedrock-runtime",
19365
19365
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
19366
- version: "3.999.0",
19366
+ version: "3.1000.0",
19367
19367
  scripts: {
19368
19368
  build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
19369
19369
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -19374,7 +19374,11 @@ var require_package2 = __commonJS({
19374
19374
  clean: "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
19375
19375
  "extract:docs": "api-extractor run --local",
19376
19376
  "generate:client": "node ../../scripts/generate-clients/single-service --solo bedrock-runtime",
19377
- "test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs"
19377
+ test: "yarn g:vitest run --passWithNoTests",
19378
+ "test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs",
19379
+ "test:integration": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
19380
+ "test:integration:watch": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
19381
+ "test:watch": "yarn g:vitest watch --passWithNoTests"
19378
19382
  },
19379
19383
  main: "./dist-cjs/index.js",
19380
19384
  types: "./dist-types/index.d.ts",
@@ -19393,7 +19397,7 @@ var require_package2 = __commonJS({
19393
19397
  "@aws-sdk/middleware-user-agent": "^3.972.15",
19394
19398
  "@aws-sdk/middleware-websocket": "^3.972.10",
19395
19399
  "@aws-sdk/region-config-resolver": "^3.972.6",
19396
- "@aws-sdk/token-providers": "3.999.0",
19400
+ "@aws-sdk/token-providers": "3.1000.0",
19397
19401
  "@aws-sdk/types": "^3.973.4",
19398
19402
  "@aws-sdk/util-endpoints": "^3.996.3",
19399
19403
  "@aws-sdk/util-user-agent-browser": "^3.972.6",
@@ -19430,12 +19434,14 @@ var require_package2 = __commonJS({
19430
19434
  tslib: "^2.6.2"
19431
19435
  },
19432
19436
  devDependencies: {
19437
+ "@smithy/snapshot-testing": "^1.0.7",
19433
19438
  "@tsconfig/node20": "20.1.8",
19434
19439
  "@types/node": "^20.14.8",
19435
19440
  concurrently: "7.0.0",
19436
19441
  "downlevel-dts": "0.10.1",
19437
19442
  premove: "4.0.0",
19438
- typescript: "~5.8.3"
19443
+ typescript: "~5.8.3",
19444
+ vitest: "^4.0.17"
19439
19445
  },
19440
19446
  engines: {
19441
19447
  node: ">=20.0.0"
@@ -21437,9 +21443,9 @@ var init_sso_oidc = __esm({
21437
21443
  }
21438
21444
  });
21439
21445
 
21440
- // node_modules/@aws-sdk/token-providers/dist-cjs/index.js
21446
+ // node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js
21441
21447
  var require_dist_cjs56 = __commonJS({
21442
- "node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
21448
+ "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
21443
21449
  "use strict";
21444
21450
  var client = (init_client(), __toCommonJS(client_exports));
21445
21451
  var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
@@ -25272,8 +25278,155 @@ var require_dist_cjs63 = __commonJS({
25272
25278
  }
25273
25279
  });
25274
25280
 
25275
- // node_modules/@smithy/eventstream-serde-node/dist-cjs/index.js
25281
+ // node_modules/@aws-sdk/token-providers/dist-cjs/index.js
25276
25282
  var require_dist_cjs64 = __commonJS({
25283
+ "node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
25284
+ "use strict";
25285
+ var client = (init_client(), __toCommonJS(client_exports));
25286
+ var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
25287
+ var propertyProvider = require_dist_cjs24();
25288
+ var sharedIniFileLoader = require_dist_cjs42();
25289
+ var node_fs = require("node:fs");
25290
+ var fromEnvSigningName = ({ logger: logger2, signingName } = {}) => async () => {
25291
+ logger2?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
25292
+ if (!signingName) {
25293
+ throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger2 });
25294
+ }
25295
+ const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
25296
+ if (!(bearerTokenKey in process.env)) {
25297
+ throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger2 });
25298
+ }
25299
+ const token = { token: process.env[bearerTokenKey] };
25300
+ client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
25301
+ return token;
25302
+ };
25303
+ var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
25304
+ var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
25305
+ var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
25306
+ const { SSOOIDCClient: SSOOIDCClient2 } = await Promise.resolve().then(() => (init_sso_oidc(), sso_oidc_exports));
25307
+ const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
25308
+ const ssoOidcClient = new SSOOIDCClient2(Object.assign({}, init.clientConfig ?? {}, {
25309
+ region: ssoRegion ?? init.clientConfig?.region,
25310
+ logger: coalesce("logger"),
25311
+ userAgentAppId: coalesce("userAgentAppId")
25312
+ }));
25313
+ return ssoOidcClient;
25314
+ };
25315
+ var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
25316
+ const { CreateTokenCommand: CreateTokenCommand2 } = await Promise.resolve().then(() => (init_sso_oidc(), sso_oidc_exports));
25317
+ const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
25318
+ return ssoOidcClient.send(new CreateTokenCommand2({
25319
+ clientId: ssoToken.clientId,
25320
+ clientSecret: ssoToken.clientSecret,
25321
+ refreshToken: ssoToken.refreshToken,
25322
+ grantType: "refresh_token"
25323
+ }));
25324
+ };
25325
+ var validateTokenExpiry = (token) => {
25326
+ if (token.expiration && token.expiration.getTime() < Date.now()) {
25327
+ throw new propertyProvider.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
25328
+ }
25329
+ };
25330
+ var validateTokenKey = (key, value, forRefresh = false) => {
25331
+ if (typeof value === "undefined") {
25332
+ throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
25333
+ }
25334
+ };
25335
+ var { writeFile: writeFile2 } = node_fs.promises;
25336
+ var writeSSOTokenToFile = (id, ssoToken) => {
25337
+ const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
25338
+ const tokenString = JSON.stringify(ssoToken, null, 2);
25339
+ return writeFile2(tokenFilepath, tokenString);
25340
+ };
25341
+ var lastRefreshAttemptTime = /* @__PURE__ */ new Date(0);
25342
+ var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
25343
+ init.logger?.debug("@aws-sdk/token-providers - fromSso");
25344
+ const profiles = await sharedIniFileLoader.parseKnownFiles(init);
25345
+ const profileName = sharedIniFileLoader.getProfileName({
25346
+ profile: init.profile ?? callerClientConfig?.profile
25347
+ });
25348
+ const profile = profiles[profileName];
25349
+ if (!profile) {
25350
+ throw new propertyProvider.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
25351
+ } else if (!profile["sso_session"]) {
25352
+ throw new propertyProvider.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
25353
+ }
25354
+ const ssoSessionName = profile["sso_session"];
25355
+ const ssoSessions = await sharedIniFileLoader.loadSsoSessionData(init);
25356
+ const ssoSession = ssoSessions[ssoSessionName];
25357
+ if (!ssoSession) {
25358
+ throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
25359
+ }
25360
+ for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
25361
+ if (!ssoSession[ssoSessionRequiredKey]) {
25362
+ throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
25363
+ }
25364
+ }
25365
+ ssoSession["sso_start_url"];
25366
+ const ssoRegion = ssoSession["sso_region"];
25367
+ let ssoToken;
25368
+ try {
25369
+ ssoToken = await sharedIniFileLoader.getSSOTokenFromFile(ssoSessionName);
25370
+ } catch (e5) {
25371
+ throw new propertyProvider.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
25372
+ }
25373
+ validateTokenKey("accessToken", ssoToken.accessToken);
25374
+ validateTokenKey("expiresAt", ssoToken.expiresAt);
25375
+ const { accessToken, expiresAt } = ssoToken;
25376
+ const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
25377
+ if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
25378
+ return existingToken;
25379
+ }
25380
+ if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1e3) {
25381
+ validateTokenExpiry(existingToken);
25382
+ return existingToken;
25383
+ }
25384
+ validateTokenKey("clientId", ssoToken.clientId, true);
25385
+ validateTokenKey("clientSecret", ssoToken.clientSecret, true);
25386
+ validateTokenKey("refreshToken", ssoToken.refreshToken, true);
25387
+ try {
25388
+ lastRefreshAttemptTime.setTime(Date.now());
25389
+ const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
25390
+ validateTokenKey("accessToken", newSsoOidcToken.accessToken);
25391
+ validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
25392
+ const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1e3);
25393
+ try {
25394
+ await writeSSOTokenToFile(ssoSessionName, {
25395
+ ...ssoToken,
25396
+ accessToken: newSsoOidcToken.accessToken,
25397
+ expiresAt: newTokenExpiration.toISOString(),
25398
+ refreshToken: newSsoOidcToken.refreshToken
25399
+ });
25400
+ } catch (error2) {
25401
+ }
25402
+ return {
25403
+ token: newSsoOidcToken.accessToken,
25404
+ expiration: newTokenExpiration
25405
+ };
25406
+ } catch (error2) {
25407
+ validateTokenExpiry(existingToken);
25408
+ return existingToken;
25409
+ }
25410
+ };
25411
+ var fromStatic = ({ token, logger: logger2 }) => async () => {
25412
+ logger2?.debug("@aws-sdk/token-providers - fromStatic");
25413
+ if (!token || !token.token) {
25414
+ throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
25415
+ }
25416
+ return token;
25417
+ };
25418
+ var nodeProvider = (init = {}) => propertyProvider.memoize(propertyProvider.chain(fromSso(init), async () => {
25419
+ throw new propertyProvider.TokenProviderError("Could not load token from any providers", false);
25420
+ }), (token) => token.expiration !== void 0 && token.expiration.getTime() - Date.now() < 3e5, (token) => token.expiration !== void 0);
25421
+ exports2.fromEnvSigningName = fromEnvSigningName;
25422
+ exports2.fromSso = fromSso;
25423
+ exports2.fromStatic = fromStatic;
25424
+ exports2.nodeProvider = nodeProvider;
25425
+ }
25426
+ });
25427
+
25428
+ // node_modules/@smithy/eventstream-serde-node/dist-cjs/index.js
25429
+ var require_dist_cjs65 = __commonJS({
25277
25430
  "node_modules/@smithy/eventstream-serde-node/dist-cjs/index.js"(exports2) {
25278
25431
  "use strict";
25279
25432
  var eventstreamSerdeUniversal = require_dist_cjs35();
@@ -27955,11 +28108,11 @@ var require_runtimeConfig = __commonJS({
27955
28108
  var core_1 = (init_dist_es2(), __toCommonJS(dist_es_exports2));
27956
28109
  var credential_provider_node_1 = require_dist_cjs62();
27957
28110
  var eventstream_handler_node_1 = require_dist_cjs63();
27958
- var token_providers_1 = require_dist_cjs56();
28111
+ var token_providers_1 = require_dist_cjs64();
27959
28112
  var util_user_agent_node_1 = require_dist_cjs51();
27960
28113
  var config_resolver_1 = require_dist_cjs39();
27961
28114
  var core_2 = (init_dist_es(), __toCommonJS(dist_es_exports));
27962
- var eventstream_serde_node_1 = require_dist_cjs64();
28115
+ var eventstream_serde_node_1 = require_dist_cjs65();
27963
28116
  var hash_node_1 = require_dist_cjs52();
27964
28117
  var middleware_retry_1 = require_dist_cjs47();
27965
28118
  var node_config_provider_1 = require_dist_cjs43();
@@ -28031,7 +28184,7 @@ var require_runtimeConfig = __commonJS({
28031
28184
  });
28032
28185
 
28033
28186
  // node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js
28034
- var require_dist_cjs65 = __commonJS({
28187
+ var require_dist_cjs66 = __commonJS({
28035
28188
  "node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js"(exports2) {
28036
28189
  "use strict";
28037
28190
  var middlewareEventstream = require_dist_cjs3();
@@ -28876,13 +29029,13 @@ var import_client_bedrock_runtime, import_client_bedrock_runtime2, import_client
28876
29029
  var init_dist3 = __esm({
28877
29030
  "node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs"() {
28878
29031
  init_dist2();
28879
- import_client_bedrock_runtime = __toESM(require_dist_cjs65(), 1);
29032
+ import_client_bedrock_runtime = __toESM(require_dist_cjs66(), 1);
28880
29033
  init_dist();
28881
- import_client_bedrock_runtime2 = __toESM(require_dist_cjs65(), 1);
29034
+ import_client_bedrock_runtime2 = __toESM(require_dist_cjs66(), 1);
28882
29035
  init_dist();
28883
29036
  init_dist();
28884
29037
  init_dist2();
28885
- import_client_bedrock_runtime3 = __toESM(require_dist_cjs65(), 1);
29038
+ import_client_bedrock_runtime3 = __toESM(require_dist_cjs66(), 1);
28886
29039
  generateFileId = createIdGenerator({ prefix: "file", size: 16 });
28887
29040
  BedrockChatLanguageModel = class {
28888
29041
  constructor(modelId, settings, config) {
@@ -52050,7 +52203,6 @@ var init_reg_exp = __esm({
52050
52203
  // node_modules/chevrotain/lib/src/scan/lexer.js
52051
52204
  function analyzeTokenTypes(tokenTypes, options) {
52052
52205
  options = defaults_default(options, {
52053
- useSticky: SUPPORT_STICKY,
52054
52206
  debug: false,
52055
52207
  safeMode: false,
52056
52208
  positionTracking: "full",
@@ -52099,7 +52251,7 @@ function analyzeTokenTypes(tokenTypes, options) {
52099
52251
  ], regExpSource[1])) {
52100
52252
  return regExpSource[1];
52101
52253
  } else {
52102
- return options.useSticky ? addStickyFlag(currPattern) : addStartOfInput(currPattern);
52254
+ return addStickyFlag(currPattern);
52103
52255
  }
52104
52256
  } else if (isFunction_default(currPattern)) {
52105
52257
  hasCustom = true;
@@ -52113,7 +52265,7 @@ function analyzeTokenTypes(tokenTypes, options) {
52113
52265
  } else {
52114
52266
  const escapedRegExpString = currPattern.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
52115
52267
  const wrappedRegExp = new RegExp(escapedRegExpString);
52116
- return options.useSticky ? addStickyFlag(wrappedRegExp) : addStartOfInput(wrappedRegExp);
52268
+ return addStickyFlag(wrappedRegExp);
52117
52269
  }
52118
52270
  } else {
52119
52271
  throw Error("non exhaustive match");
@@ -52517,10 +52669,6 @@ function noMetaChar(regExp) {
52517
52669
  function usesLookAheadOrBehind(regExp) {
52518
52670
  return /(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(regExp.source);
52519
52671
  }
52520
- function addStartOfInput(pattern) {
52521
- const flags = pattern.ignoreCase ? "i" : "";
52522
- return new RegExp(`^(?:${pattern.source})`, flags);
52523
- }
52524
52672
  function addStickyFlag(pattern) {
52525
52673
  const flags = pattern.ignoreCase ? "iy" : "y";
52526
52674
  return new RegExp(`${pattern.source}`, flags);
@@ -52709,7 +52857,7 @@ function initCharCodeToOptimizedIndexMap() {
52709
52857
  }
52710
52858
  }
52711
52859
  }
52712
- var PATTERN, DEFAULT_MODE, MODES, SUPPORT_STICKY, end_of_input, start_of_input, LineTerminatorOptimizedTester, minOptimizationVal, charCodeToOptimizedIdxMap;
52860
+ var PATTERN, DEFAULT_MODE, MODES, end_of_input, start_of_input, LineTerminatorOptimizedTester, minOptimizationVal, charCodeToOptimizedIdxMap;
52713
52861
  var init_lexer = __esm({
52714
52862
  "node_modules/chevrotain/lib/src/scan/lexer.js"() {
52715
52863
  init_api3();
@@ -52721,7 +52869,6 @@ var init_lexer = __esm({
52721
52869
  PATTERN = "PATTERN";
52722
52870
  DEFAULT_MODE = "defaultMode";
52723
52871
  MODES = "modes";
52724
- SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean";
52725
52872
  end_of_input = /[^\\][$]/;
52726
52873
  start_of_input = /[^\\[][\^]|^\^/;
52727
52874
  LineTerminatorOptimizedTester = {
@@ -53037,13 +53184,6 @@ var init_lexer_public = __esm({
53037
53184
  PRINT_WARNING(warningDescriptor.message);
53038
53185
  });
53039
53186
  this.TRACE_INIT("Choosing sub-methods implementations", () => {
53040
- if (SUPPORT_STICKY) {
53041
- this.chopInput = identity_default;
53042
- this.match = this.matchWithTest;
53043
- } else {
53044
- this.updateLastIndex = noop_default;
53045
- this.match = this.matchWithExec;
53046
- }
53047
53187
  if (hasOnlySingleMode) {
53048
53188
  this.handleModes = noop_default;
53049
53189
  }
@@ -53106,7 +53246,7 @@ var init_lexer_public = __esm({
53106
53246
  // this method also used quite a bit of `!` none null assertions because it is too optimized
53107
53247
  // for `tsc` to always understand it is "safe"
53108
53248
  tokenizeInternal(text, initialMode) {
53109
- let i5, j5, k5, matchAltImage, longerAlt, matchedImage, payload2, altPayload, imageLength, group, tokType, newToken, errLength, droppedChar, msg, match2;
53249
+ let i5, j5, k5, matchAltImage, longerAlt, matchedImage, payload2, altPayload, imageLength, group, tokType, newToken, errLength, msg, match2;
53110
53250
  const orgText = text;
53111
53251
  const orgLength = orgText.length;
53112
53252
  let offset2 = 0;
@@ -53125,19 +53265,7 @@ var init_lexer_public = __esm({
53125
53265
  const modeStack = [];
53126
53266
  const emptyArray = [];
53127
53267
  Object.freeze(emptyArray);
53128
- let getPossiblePatterns;
53129
- function getPossiblePatternsSlow() {
53130
- return patternIdxToConfig;
53131
- }
53132
- function getPossiblePatternsOptimized(charCode) {
53133
- const optimizedCharIdx = charCodeToOptimizedIndex(charCode);
53134
- const possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx];
53135
- if (possiblePatterns === void 0) {
53136
- return emptyArray;
53137
- } else {
53138
- return possiblePatterns;
53139
- }
53140
- }
53268
+ let isOptimizedMode = false;
53141
53269
  const pop_mode = (popToken) => {
53142
53270
  if (modeStack.length === 1 && // if we have both a POP_MODE and a PUSH_MODE this is in-fact a "transition"
53143
53271
  // So no error should occur.
@@ -53158,9 +53286,9 @@ var init_lexer_public = __esm({
53158
53286
  currModePatternsLength = patternIdxToConfig.length;
53159
53287
  const modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false;
53160
53288
  if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {
53161
- getPossiblePatterns = getPossiblePatternsOptimized;
53289
+ isOptimizedMode = true;
53162
53290
  } else {
53163
- getPossiblePatterns = getPossiblePatternsSlow;
53291
+ isOptimizedMode = false;
53164
53292
  }
53165
53293
  }
53166
53294
  };
@@ -53172,9 +53300,9 @@ var init_lexer_public = __esm({
53172
53300
  currModePatternsLength = patternIdxToConfig.length;
53173
53301
  const modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false;
53174
53302
  if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {
53175
- getPossiblePatterns = getPossiblePatternsOptimized;
53303
+ isOptimizedMode = true;
53176
53304
  } else {
53177
- getPossiblePatterns = getPossiblePatternsSlow;
53305
+ isOptimizedMode = false;
53178
53306
  }
53179
53307
  }
53180
53308
  push_mode.call(this, initialMode);
@@ -53182,8 +53310,16 @@ var init_lexer_public = __esm({
53182
53310
  const recoveryEnabled = this.config.recoveryEnabled;
53183
53311
  while (offset2 < orgLength) {
53184
53312
  matchedImage = null;
53313
+ imageLength = -1;
53185
53314
  const nextCharCode = orgText.charCodeAt(offset2);
53186
- const chosenPatternIdxToConfig = getPossiblePatterns(nextCharCode);
53315
+ let chosenPatternIdxToConfig;
53316
+ if (isOptimizedMode) {
53317
+ const optimizedCharIdx = charCodeToOptimizedIndex(nextCharCode);
53318
+ const possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx];
53319
+ chosenPatternIdxToConfig = possiblePatterns !== void 0 ? possiblePatterns : emptyArray;
53320
+ } else {
53321
+ chosenPatternIdxToConfig = patternIdxToConfig;
53322
+ }
53187
53323
  const chosenPatternsLength = chosenPatternIdxToConfig.length;
53188
53324
  for (i5 = 0; i5 < chosenPatternsLength; i5++) {
53189
53325
  currConfig = chosenPatternIdxToConfig[i5];
@@ -53192,12 +53328,14 @@ var init_lexer_public = __esm({
53192
53328
  const singleCharCode = currConfig.short;
53193
53329
  if (singleCharCode !== false) {
53194
53330
  if (nextCharCode === singleCharCode) {
53331
+ imageLength = 1;
53195
53332
  matchedImage = currPattern;
53196
53333
  }
53197
53334
  } else if (currConfig.isCustom === true) {
53198
53335
  match2 = currPattern.exec(orgText, offset2, matchedTokens, groups);
53199
53336
  if (match2 !== null) {
53200
53337
  matchedImage = match2[0];
53338
+ imageLength = matchedImage.length;
53201
53339
  if (match2.payload !== void 0) {
53202
53340
  payload2 = match2.payload;
53203
53341
  }
@@ -53205,12 +53343,13 @@ var init_lexer_public = __esm({
53205
53343
  matchedImage = null;
53206
53344
  }
53207
53345
  } else {
53208
- this.updateLastIndex(currPattern, offset2);
53209
- matchedImage = this.match(currPattern, text, offset2);
53346
+ currPattern.lastIndex = offset2;
53347
+ imageLength = this.matchLength(currPattern, text, offset2);
53210
53348
  }
53211
- if (matchedImage !== null) {
53349
+ if (imageLength !== -1) {
53212
53350
  longerAlt = currConfig.longerAlt;
53213
53351
  if (longerAlt !== void 0) {
53352
+ matchedImage = text.substring(offset2, offset2 + imageLength);
53214
53353
  const longerAltLength = longerAlt.length;
53215
53354
  for (k5 = 0; k5 < longerAltLength; k5++) {
53216
53355
  const longerAltConfig = patternIdxToConfig[longerAlt[k5]];
@@ -53227,11 +53366,12 @@ var init_lexer_public = __esm({
53227
53366
  matchAltImage = null;
53228
53367
  }
53229
53368
  } else {
53230
- this.updateLastIndex(longerAltPattern, offset2);
53369
+ longerAltPattern.lastIndex = offset2;
53231
53370
  matchAltImage = this.match(longerAltPattern, text, offset2);
53232
53371
  }
53233
53372
  if (matchAltImage && matchAltImage.length > matchedImage.length) {
53234
53373
  matchedImage = matchAltImage;
53374
+ imageLength = matchAltImage.length;
53235
53375
  payload2 = altPayload;
53236
53376
  currConfig = longerAltConfig;
53237
53377
  break;
@@ -53241,10 +53381,10 @@ var init_lexer_public = __esm({
53241
53381
  break;
53242
53382
  }
53243
53383
  }
53244
- if (matchedImage !== null) {
53245
- imageLength = matchedImage.length;
53384
+ if (imageLength !== -1) {
53246
53385
  group = currConfig.group;
53247
53386
  if (group !== void 0) {
53387
+ matchedImage = matchedImage !== null ? matchedImage : text.substring(offset2, offset2 + imageLength);
53248
53388
  tokType = currConfig.tokenTypeIdx;
53249
53389
  newToken = this.createTokenInstance(matchedImage, offset2, tokType, currConfig.tokenType, line, column, imageLength);
53250
53390
  this.handlePayload(newToken, payload2);
@@ -53254,15 +53394,13 @@ var init_lexer_public = __esm({
53254
53394
  groups[group].push(newToken);
53255
53395
  }
53256
53396
  }
53257
- text = this.chopInput(text, imageLength);
53258
- offset2 = offset2 + imageLength;
53259
- column = this.computeNewColumn(column, imageLength);
53260
53397
  if (trackLines === true && currConfig.canLineTerminator === true) {
53261
53398
  let numOfLTsInMatch = 0;
53262
53399
  let foundTerminator;
53263
53400
  let lastLTEndOffset;
53264
53401
  lineTerminatorPattern.lastIndex = 0;
53265
53402
  do {
53403
+ matchedImage = matchedImage !== null ? matchedImage : text.substring(offset2, offset2 + imageLength);
53266
53404
  foundTerminator = lineTerminatorPattern.test(matchedImage);
53267
53405
  if (foundTerminator === true) {
53268
53406
  lastLTEndOffset = lineTerminatorPattern.lastIndex - 1;
@@ -53273,8 +53411,13 @@ var init_lexer_public = __esm({
53273
53411
  line = line + numOfLTsInMatch;
53274
53412
  column = imageLength - lastLTEndOffset;
53275
53413
  this.updateTokenEndLineColumnLocation(newToken, group, lastLTEndOffset, numOfLTsInMatch, line, column, imageLength);
53414
+ } else {
53415
+ column = this.computeNewColumn(column, imageLength);
53276
53416
  }
53417
+ } else {
53418
+ column = this.computeNewColumn(column, imageLength);
53277
53419
  }
53420
+ offset2 = offset2 + imageLength;
53278
53421
  this.handleModes(currConfig, pop_mode, push_mode, newToken);
53279
53422
  } else {
53280
53423
  const errorStartOffset = offset2;
@@ -53282,7 +53425,6 @@ var init_lexer_public = __esm({
53282
53425
  const errorColumn = column;
53283
53426
  let foundResyncPoint = recoveryEnabled === false;
53284
53427
  while (foundResyncPoint === false && offset2 < orgLength) {
53285
- text = this.chopInput(text, 1);
53286
53428
  offset2++;
53287
53429
  for (j5 = 0; j5 < currModePatternsLength; j5++) {
53288
53430
  const currConfig2 = patternIdxToConfig[j5];
@@ -53295,7 +53437,7 @@ var init_lexer_public = __esm({
53295
53437
  } else if (currConfig2.isCustom === true) {
53296
53438
  foundResyncPoint = currPattern.exec(orgText, offset2, matchedTokens, groups) !== null;
53297
53439
  } else {
53298
- this.updateLastIndex(currPattern, offset2);
53440
+ currPattern.lastIndex = offset2;
53299
53441
  foundResyncPoint = currPattern.exec(text) !== null;
53300
53442
  }
53301
53443
  if (foundResyncPoint === true) {
@@ -53338,12 +53480,6 @@ var init_lexer_public = __esm({
53338
53480
  push_mode.call(this, config.push);
53339
53481
  }
53340
53482
  }
53341
- chopInput(text, length) {
53342
- return text.substring(length);
53343
- }
53344
- updateLastIndex(regExp, newLastIndex) {
53345
- regExp.lastIndex = newLastIndex;
53346
- }
53347
53483
  // TODO: decrease this under 600 characters? inspect stripping comments option in TSC compiler
53348
53484
  updateTokenEndLineColumnLocation(newToken, group, lastLTIdx, numOfLTsInMatch, line, column, imageLength) {
53349
53485
  let lastCharIsLT, fixForEndingInLT;
@@ -53406,16 +53542,19 @@ var init_lexer_public = __esm({
53406
53542
  token.payload = payload2;
53407
53543
  }
53408
53544
  }
53409
- matchWithTest(pattern, text, offset2) {
53545
+ match(pattern, text, offset2) {
53410
53546
  const found = pattern.test(text);
53411
53547
  if (found === true) {
53412
53548
  return text.substring(offset2, pattern.lastIndex);
53413
53549
  }
53414
53550
  return null;
53415
53551
  }
53416
- matchWithExec(pattern, text) {
53417
- const regExpArray = pattern.exec(text);
53418
- return regExpArray !== null ? regExpArray[0] : null;
53552
+ matchLength(pattern, text, offset2) {
53553
+ const found = pattern.test(text);
53554
+ if (found === true) {
53555
+ return pattern.lastIndex - offset2;
53556
+ }
53557
+ return -1;
53419
53558
  }
53420
53559
  };
53421
53560
  Lexer.SKIPPED = "This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";
@@ -53607,12 +53746,20 @@ For Further details.`;
53607
53746
  return errMsg;
53608
53747
  },
53609
53748
  buildAlternationAmbiguityError(options) {
53610
- const pathMsg = map_default(options.prefixPath, (currtok) => tokenLabel2(currtok)).join(", ");
53611
53749
  const occurrence = options.alternation.idx === 0 ? "" : options.alternation.idx;
53750
+ const isEmptyPath = options.prefixPath.length === 0;
53612
53751
  let currMessage = `Ambiguous Alternatives Detected: <${options.ambiguityIndices.join(" ,")}> in <OR${occurrence}> inside <${options.topLevelRule.name}> Rule,
53613
- <${pathMsg}> may appears as a prefix path in all these alternatives.
53614
53752
  `;
53615
- currMessage = currMessage + `See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
53753
+ if (isEmptyPath) {
53754
+ currMessage += `These alternatives are all empty (match no tokens), making them indistinguishable.
53755
+ Only the last alternative may be empty.
53756
+ `;
53757
+ } else {
53758
+ const pathMsg = map_default(options.prefixPath, (currtok) => tokenLabel2(currtok)).join(", ");
53759
+ currMessage += `<${pathMsg}> may appears as a prefix path in all these alternatives.
53760
+ `;
53761
+ }
53762
+ currMessage += `See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
53616
53763
  For Further details.`;
53617
53764
  return currMessage;
53618
53765
  },
@@ -105256,6 +105403,122 @@ var init_bashPermissions = __esm({
105256
105403
  });
105257
105404
 
105258
105405
  // src/agent/bashExecutor.js
105406
+ function splitCommandComponents(command) {
105407
+ const parts = [];
105408
+ let current2 = "";
105409
+ let inQuote = false;
105410
+ let quoteChar = "";
105411
+ for (let i5 = 0; i5 < command.length; i5++) {
105412
+ const c5 = command[i5];
105413
+ const next = command[i5 + 1] || "";
105414
+ if (c5 === "\\" && !inQuote) {
105415
+ current2 += c5 + next;
105416
+ i5++;
105417
+ continue;
105418
+ }
105419
+ if (inQuote && quoteChar === '"' && c5 === "\\" && next) {
105420
+ current2 += c5 + next;
105421
+ i5++;
105422
+ continue;
105423
+ }
105424
+ if (!inQuote && (c5 === '"' || c5 === "'")) {
105425
+ inQuote = true;
105426
+ quoteChar = c5;
105427
+ current2 += c5;
105428
+ continue;
105429
+ }
105430
+ if (inQuote && c5 === quoteChar) {
105431
+ inQuote = false;
105432
+ current2 += c5;
105433
+ continue;
105434
+ }
105435
+ if (!inQuote) {
105436
+ if (c5 === "&" && next === "&" || c5 === "|" && next === "|") {
105437
+ if (current2.trim()) parts.push(current2.trim());
105438
+ current2 = "";
105439
+ i5++;
105440
+ continue;
105441
+ }
105442
+ if (c5 === "|" || c5 === ";") {
105443
+ if (current2.trim()) parts.push(current2.trim());
105444
+ current2 = "";
105445
+ continue;
105446
+ }
105447
+ }
105448
+ current2 += c5;
105449
+ }
105450
+ if (current2.trim()) parts.push(current2.trim());
105451
+ return parts;
105452
+ }
105453
+ function checkSingleCommandInteractive(command) {
105454
+ let effective = command.trim();
105455
+ while (/^\w+=\S*\s/.test(effective)) {
105456
+ effective = effective.replace(/^\w+=\S*\s+/, "");
105457
+ }
105458
+ const parts = effective.split(/\s+/);
105459
+ const base2 = parts[0];
105460
+ const args = parts.slice(1);
105461
+ if (["vi", "vim", "nvim", "nano", "emacs", "pico", "joe", "mcedit"].includes(base2)) {
105462
+ return `'${base2}' is an interactive editor and cannot run without a terminal. Use non-interactive file manipulation commands instead.`;
105463
+ }
105464
+ if (["less", "more"].includes(base2)) {
105465
+ return `'${base2}' is an interactive pager. Use 'cat', 'head', or 'tail' instead.`;
105466
+ }
105467
+ if (base2 === "git") {
105468
+ const sub = args[0];
105469
+ if (sub === "commit") {
105470
+ const hasNonInteractiveFlag = args.some(
105471
+ (a5) => a5 === "-m" || a5.startsWith("--message") || a5 === "-C" || a5 === "-c" || a5.startsWith("--fixup") || a5.startsWith("--squash") || a5 === "--allow-empty-message" || a5 === "--no-edit"
105472
+ );
105473
+ if (!hasNonInteractiveFlag) {
105474
+ return `Interactive command: 'git commit' opens an editor for the commit message. Use 'git commit -m "your message"' instead.`;
105475
+ }
105476
+ }
105477
+ if (sub === "rebase" && (args.includes("--continue") || args.includes("--skip"))) {
105478
+ return "Interactive command: 'git rebase --continue' opens an editor. Set environment variable GIT_EDITOR=true to accept default messages, e.g. pass env: {GIT_EDITOR: 'true'} or prepend GIT_EDITOR=true to the command.";
105479
+ }
105480
+ if (sub === "rebase" && (args.includes("-i") || args.includes("--interactive"))) {
105481
+ return "Interactive command: 'git rebase -i' requires an interactive editor. Interactive rebase cannot run without a terminal.";
105482
+ }
105483
+ if (sub === "merge" && !args.includes("--no-edit") && !args.includes("--no-commit") && !args.includes("--ff-only")) {
105484
+ return "Interactive command: 'git merge' may open an editor for the merge commit message. Add '--no-edit' to accept the default message.";
105485
+ }
105486
+ if (sub === "cherry-pick" && !args.includes("--no-edit")) {
105487
+ return "Interactive command: 'git cherry-pick' may open an editor. Add '--no-edit' to accept the default message.";
105488
+ }
105489
+ if (sub === "revert" && !args.includes("--no-edit")) {
105490
+ return "Interactive command: 'git revert' opens an editor. Add '--no-edit' to accept the default message.";
105491
+ }
105492
+ if (sub === "tag" && args.includes("-a") && !args.some((a5) => a5 === "-m" || a5.startsWith("--message"))) {
105493
+ return `Interactive command: 'git tag -a' opens an editor for the tag message. Use 'git tag -a <name> -m "message"' instead.`;
105494
+ }
105495
+ if (sub === "add" && (args.includes("-i") || args.includes("--interactive") || args.includes("-p") || args.includes("--patch"))) {
105496
+ return "Interactive command: 'git add -i/-p' requires interactive input. Use 'git add <files>' to stage specific files instead.";
105497
+ }
105498
+ }
105499
+ if (["python", "python3", "node", "irb", "ghci", "lua", "R", "ruby"].includes(base2) && args.length === 0) {
105500
+ return `Interactive command: '${base2}' without arguments starts an interactive REPL. Provide a script file or use '-c'/'--eval' for inline code.`;
105501
+ }
105502
+ if (base2 === "mysql" && !args.some((a5) => a5 === "-e" || a5.startsWith("--execute"))) {
105503
+ return `Interactive command: 'mysql' without -e flag starts an interactive session. Use 'mysql -e "SQL QUERY"' instead.`;
105504
+ }
105505
+ if (base2 === "psql" && !args.some((a5) => a5 === "-c" || a5.startsWith("--command") || a5 === "-f" || a5.startsWith("--file"))) {
105506
+ return `Interactive command: 'psql' without -c flag starts an interactive session. Use 'psql -c "SQL QUERY"' instead.`;
105507
+ }
105508
+ if (["top", "htop", "btop", "nmon"].includes(base2)) {
105509
+ return `Interactive command: '${base2}' is an interactive TUI tool. Use 'ps aux' or 'top -b -n 1' for non-interactive process listing.`;
105510
+ }
105511
+ return null;
105512
+ }
105513
+ function checkInteractiveCommand(command) {
105514
+ if (!command || typeof command !== "string") return null;
105515
+ const components = splitCommandComponents(command.trim());
105516
+ for (const component of components) {
105517
+ const result = checkSingleCommandInteractive(component);
105518
+ if (result) return result;
105519
+ }
105520
+ return null;
105521
+ }
105259
105522
  async function executeBashCommand(command, options = {}) {
105260
105523
  const {
105261
105524
  workingDirectory = process.cwd(),
@@ -105285,6 +105548,24 @@ async function executeBashCommand(command, options = {}) {
105285
105548
  };
105286
105549
  }
105287
105550
  const startTime = Date.now();
105551
+ const interactiveError = checkInteractiveCommand(command);
105552
+ if (interactiveError) {
105553
+ if (debug) {
105554
+ console.log(`[BashExecutor] Blocked interactive command: "${command}"`);
105555
+ console.log(`[BashExecutor] Reason: ${interactiveError}`);
105556
+ }
105557
+ return {
105558
+ success: false,
105559
+ error: interactiveError,
105560
+ stdout: "",
105561
+ stderr: interactiveError,
105562
+ exitCode: 1,
105563
+ command,
105564
+ workingDirectory: cwd,
105565
+ duration: 0,
105566
+ interactive: true
105567
+ };
105568
+ }
105288
105569
  if (debug) {
105289
105570
  console.log(`[BashExecutor] Executing command: "${command}"`);
105290
105571
  console.log(`[BashExecutor] Working directory: "${cwd}"`);
@@ -105295,6 +105576,8 @@ async function executeBashCommand(command, options = {}) {
105295
105576
  ...process.env,
105296
105577
  ...env
105297
105578
  };
105579
+ if (!processEnv.GIT_EDITOR) processEnv.GIT_EDITOR = "true";
105580
+ if (!processEnv.GIT_TERMINAL_PROMPT) processEnv.GIT_TERMINAL_PROMPT = "0";
105298
105581
  const isComplex = isComplexCommand(command);
105299
105582
  let cmd, cmdArgs, useShell;
105300
105583
  if (isComplex) {
@@ -105329,20 +105612,32 @@ async function executeBashCommand(command, options = {}) {
105329
105612
  // stdin ignored, capture stdout/stderr
105330
105613
  shell: useShell,
105331
105614
  // false for security
105615
+ detached: true,
105616
+ // new session — no controlling terminal
105332
105617
  windowsHide: true
105333
105618
  });
105334
105619
  let stdout = "";
105335
105620
  let stderr = "";
105336
105621
  let killed = false;
105337
105622
  let timeoutHandle;
105623
+ const killProcessGroup = (signal) => {
105624
+ try {
105625
+ if (child.pid) process.kill(-child.pid, signal);
105626
+ } catch {
105627
+ try {
105628
+ child.kill(signal);
105629
+ } catch {
105630
+ }
105631
+ }
105632
+ };
105338
105633
  if (timeout > 0) {
105339
105634
  timeoutHandle = setTimeout(() => {
105340
105635
  if (!killed) {
105341
105636
  killed = true;
105342
- child.kill("SIGTERM");
105637
+ killProcessGroup("SIGTERM");
105343
105638
  setTimeout(() => {
105344
105639
  if (child.exitCode === null) {
105345
- child.kill("SIGKILL");
105640
+ killProcessGroup("SIGKILL");
105346
105641
  }
105347
105642
  }, 5e3);
105348
105643
  }
@@ -105355,7 +105650,7 @@ async function executeBashCommand(command, options = {}) {
105355
105650
  } else {
105356
105651
  if (!killed) {
105357
105652
  killed = true;
105358
- child.kill("SIGTERM");
105653
+ killProcessGroup("SIGTERM");
105359
105654
  }
105360
105655
  }
105361
105656
  });
@@ -105366,7 +105661,7 @@ async function executeBashCommand(command, options = {}) {
105366
105661
  } else {
105367
105662
  if (!killed) {
105368
105663
  killed = true;
105369
- child.kill("SIGTERM");
105664
+ killProcessGroup("SIGTERM");
105370
105665
  }
105371
105666
  }
105372
105667
  });