@botpress/runtime 1.13.2 → 1.13.3

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.
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
48
48
  var define_PACKAGE_VERSIONS_default;
49
49
  var init_define_PACKAGE_VERSIONS = __esm({
50
50
  "<define:__PACKAGE_VERSIONS__>"() {
51
- define_PACKAGE_VERSIONS_default = { runtime: "1.13.2", adk: "1.13.2", sdk: "5.0.2", llmz: "0.0.35", zai: "2.5.5", cognitive: "0.3.3" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.13.3", adk: "1.13.3", sdk: "5.0.2", llmz: "0.0.35", zai: "2.5.6", cognitive: "0.3.3" };
52
52
  }
53
53
  });
54
54
 
@@ -35666,7 +35666,7 @@ function resolveNameSpace(tagname) {
35666
35666
  }
35667
35667
  return tagname;
35668
35668
  }
35669
- function buildAttributesMap(attrStr, jPath, tagName) {
35669
+ function buildAttributesMap(attrStr, jPath) {
35670
35670
  if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
35671
35671
  const matches = getAllMatches(attrStr, attrsRegx);
35672
35672
  const len = matches.length;
@@ -35744,12 +35744,9 @@ function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
35744
35744
  }
35745
35745
  return textData;
35746
35746
  }
35747
- function isItStopNode(stopNodes, jPath, currentTagName) {
35748
- const allNodesExp = "*." + currentTagName;
35749
- for (const stopNodePath in stopNodes) {
35750
- const stopNodeExp = stopNodes[stopNodePath];
35751
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
35752
- }
35747
+ function isItStopNode(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
35748
+ if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
35749
+ if (stopNodesExact && stopNodesExact.has(jPath)) return true;
35753
35750
  return false;
35754
35751
  }
35755
35752
  function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
@@ -35923,6 +35920,19 @@ var init_OrderedObjParser = __esm({
35923
35920
  this.saveTextToParentTag = saveTextToParentTag;
35924
35921
  this.addChild = addChild;
35925
35922
  this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
35923
+ if (this.options.stopNodes && this.options.stopNodes.length > 0) {
35924
+ this.stopNodesExact = /* @__PURE__ */ new Set();
35925
+ this.stopNodesWildcard = /* @__PURE__ */ new Set();
35926
+ for (let i = 0; i < this.options.stopNodes.length; i++) {
35927
+ const stopNodeExp = this.options.stopNodes[i];
35928
+ if (typeof stopNodeExp !== "string") continue;
35929
+ if (stopNodeExp.startsWith("*.")) {
35930
+ this.stopNodesWildcard.add(stopNodeExp.substring(2));
35931
+ } else {
35932
+ this.stopNodesExact.add(stopNodeExp);
35933
+ }
35934
+ }
35935
+ }
35926
35936
  }
35927
35937
  };
35928
35938
  attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
@@ -35975,7 +35985,7 @@ var init_OrderedObjParser = __esm({
35975
35985
  const childNode = new XmlNode(tagData.tagName);
35976
35986
  childNode.add(this.options.textNodeName, "");
35977
35987
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
35978
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
35988
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
35979
35989
  }
35980
35990
  this.addChild(currentNode, childNode, jPath, i);
35981
35991
  }
@@ -36012,7 +36022,11 @@ var init_OrderedObjParser = __esm({
36012
36022
  let attrExpPresent = result.attrExpPresent;
36013
36023
  let closeIndex = result.closeIndex;
36014
36024
  if (this.options.transformTagName) {
36015
- tagName = this.options.transformTagName(tagName);
36025
+ const newTagName = this.options.transformTagName(tagName);
36026
+ if (tagExp === tagName) {
36027
+ tagExp = newTagName;
36028
+ }
36029
+ tagName = newTagName;
36016
36030
  }
36017
36031
  if (currentNode && textData) {
36018
36032
  if (currentNode.tagname !== "!xml") {
@@ -36028,7 +36042,7 @@ var init_OrderedObjParser = __esm({
36028
36042
  jPath += jPath ? "." + tagName : tagName;
36029
36043
  }
36030
36044
  const startIndex = i;
36031
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
36045
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
36032
36046
  let tagContent = "";
36033
36047
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
36034
36048
  if (tagName[tagName.length - 1] === "/") {
@@ -36049,7 +36063,10 @@ var init_OrderedObjParser = __esm({
36049
36063
  }
36050
36064
  const childNode = new XmlNode(tagName);
36051
36065
  if (tagName !== tagExp && attrExpPresent) {
36052
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
36066
+ childNode[":@"] = this.buildAttributesMap(
36067
+ tagExp,
36068
+ jPath
36069
+ );
36053
36070
  }
36054
36071
  if (tagContent) {
36055
36072
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
@@ -36067,11 +36084,15 @@ var init_OrderedObjParser = __esm({
36067
36084
  tagExp = tagExp.substr(0, tagExp.length - 1);
36068
36085
  }
36069
36086
  if (this.options.transformTagName) {
36070
- tagName = this.options.transformTagName(tagName);
36087
+ const newTagName = this.options.transformTagName(tagName);
36088
+ if (tagExp === tagName) {
36089
+ tagExp = newTagName;
36090
+ }
36091
+ tagName = newTagName;
36071
36092
  }
36072
36093
  const childNode = new XmlNode(tagName);
36073
36094
  if (tagName !== tagExp && attrExpPresent) {
36074
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
36095
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
36075
36096
  }
36076
36097
  this.addChild(currentNode, childNode, jPath, startIndex);
36077
36098
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
@@ -36079,7 +36100,7 @@ var init_OrderedObjParser = __esm({
36079
36100
  const childNode = new XmlNode(tagName);
36080
36101
  this.tagsNodeStack.push(currentNode);
36081
36102
  if (tagName !== tagExp && attrExpPresent) {
36082
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
36103
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
36083
36104
  }
36084
36105
  this.addChild(currentNode, childNode, jPath, startIndex);
36085
36106
  currentNode = childNode;
@@ -44347,18 +44368,51 @@ var init_state = __esm({
44347
44368
  });
44348
44369
 
44349
44370
  // src/runtime/configuration.ts
44350
- var configuration;
44371
+ function getEnvConfig() {
44372
+ const cache = getEnvConfigCache();
44373
+ if (cache.attempted) {
44374
+ return cache.parsed;
44375
+ }
44376
+ cache.attempted = true;
44377
+ const envConfig = process.env.ADK_CONFIGURATION;
44378
+ if (!envConfig) {
44379
+ return null;
44380
+ }
44381
+ try {
44382
+ cache.parsed = JSON.parse(envConfig);
44383
+ return cache.parsed;
44384
+ } catch {
44385
+ console.warn("[ADK] Failed to parse ADK_CONFIGURATION environment variable");
44386
+ return null;
44387
+ }
44388
+ }
44389
+ function getConfig() {
44390
+ const contextConfig = context2.get("configuration", { optional: true });
44391
+ if (contextConfig) {
44392
+ return contextConfig;
44393
+ }
44394
+ return getEnvConfig();
44395
+ }
44396
+ var getEnvConfigCache, configuration;
44351
44397
  var init_configuration = __esm({
44352
44398
  "src/runtime/configuration.ts"() {
44353
44399
  "use strict";
44354
44400
  init_define_BUILD();
44355
44401
  init_define_PACKAGE_VERSIONS();
44356
44402
  init_context3();
44403
+ init_singletons();
44404
+ getEnvConfigCache = () => getSingleton("__ADK_GLOBAL_ENV_CONFIG_CACHE", () => ({
44405
+ parsed: null,
44406
+ attempted: false
44407
+ }));
44357
44408
  configuration = new Proxy({}, {
44358
44409
  get(_target, prop) {
44359
- const config = context2.get("configuration", { optional: true });
44410
+ if (typeof prop === "symbol") {
44411
+ return void 0;
44412
+ }
44413
+ const config = getConfig();
44360
44414
  if (!config) {
44361
- throw new Error("Configuration not found in context.");
44415
+ return void 0;
44362
44416
  }
44363
44417
  return config[prop];
44364
44418
  },
@@ -44366,11 +44420,11 @@ var init_configuration = __esm({
44366
44420
  throw new Error(`Cannot set configuration property "${prop}". Configuration is read-only.`);
44367
44421
  },
44368
44422
  ownKeys() {
44369
- const config = context2.get("configuration", { optional: true });
44423
+ const config = getConfig();
44370
44424
  return config ? Object.keys(config) : [];
44371
44425
  },
44372
44426
  getOwnPropertyDescriptor(_target, prop) {
44373
- const config = context2.get("configuration", { optional: true });
44427
+ const config = getConfig();
44374
44428
  if (!config || !(prop in config)) {
44375
44429
  return void 0;
44376
44430
  }
@@ -46800,6 +46854,7 @@ var init_runtime2 = __esm({
46800
46854
  init_handlers();
46801
46855
  init_promises();
46802
46856
  init_chat2();
46857
+ init_configuration();
46803
46858
  init_handlers2();
46804
46859
  init_interfaces();
46805
46860
  init_tracked_state();