@botpress/runtime 1.13.1 → 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.
package/dist/library.js CHANGED
@@ -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.1", adk: "1.13.1", 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
 
@@ -34981,18 +34981,51 @@ var init_state = __esm({
34981
34981
  });
34982
34982
 
34983
34983
  // src/runtime/configuration.ts
34984
- var configuration;
34984
+ function getEnvConfig() {
34985
+ const cache = getEnvConfigCache();
34986
+ if (cache.attempted) {
34987
+ return cache.parsed;
34988
+ }
34989
+ cache.attempted = true;
34990
+ const envConfig = process.env.ADK_CONFIGURATION;
34991
+ if (!envConfig) {
34992
+ return null;
34993
+ }
34994
+ try {
34995
+ cache.parsed = JSON.parse(envConfig);
34996
+ return cache.parsed;
34997
+ } catch {
34998
+ console.warn("[ADK] Failed to parse ADK_CONFIGURATION environment variable");
34999
+ return null;
35000
+ }
35001
+ }
35002
+ function getConfig() {
35003
+ const contextConfig = context.get("configuration", { optional: true });
35004
+ if (contextConfig) {
35005
+ return contextConfig;
35006
+ }
35007
+ return getEnvConfig();
35008
+ }
35009
+ var getEnvConfigCache, configuration;
34985
35010
  var init_configuration = __esm({
34986
35011
  "src/runtime/configuration.ts"() {
34987
35012
  "use strict";
34988
35013
  init_define_BUILD();
34989
35014
  init_define_PACKAGE_VERSIONS();
34990
35015
  init_context();
35016
+ init_singletons();
35017
+ getEnvConfigCache = () => getSingleton("__ADK_GLOBAL_ENV_CONFIG_CACHE", () => ({
35018
+ parsed: null,
35019
+ attempted: false
35020
+ }));
34991
35021
  configuration = new Proxy({}, {
34992
35022
  get(_target, prop) {
34993
- const config = context.get("configuration", { optional: true });
35023
+ if (typeof prop === "symbol") {
35024
+ return void 0;
35025
+ }
35026
+ const config = getConfig();
34994
35027
  if (!config) {
34995
- throw new Error("Configuration not found in context.");
35028
+ return void 0;
34996
35029
  }
34997
35030
  return config[prop];
34998
35031
  },
@@ -35000,11 +35033,11 @@ var init_configuration = __esm({
35000
35033
  throw new Error(`Cannot set configuration property "${prop}". Configuration is read-only.`);
35001
35034
  },
35002
35035
  ownKeys() {
35003
- const config = context.get("configuration", { optional: true });
35036
+ const config = getConfig();
35004
35037
  return config ? Object.keys(config) : [];
35005
35038
  },
35006
35039
  getOwnPropertyDescriptor(_target, prop) {
35007
- const config = context.get("configuration", { optional: true });
35040
+ const config = getConfig();
35008
35041
  if (!config || !(prop in config)) {
35009
35042
  return void 0;
35010
35043
  }
@@ -39573,7 +39606,7 @@ function resolveNameSpace(tagname) {
39573
39606
  }
39574
39607
  return tagname;
39575
39608
  }
39576
- function buildAttributesMap(attrStr, jPath, tagName) {
39609
+ function buildAttributesMap(attrStr, jPath) {
39577
39610
  if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
39578
39611
  const matches = getAllMatches(attrStr, attrsRegx);
39579
39612
  const len = matches.length;
@@ -39651,12 +39684,9 @@ function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
39651
39684
  }
39652
39685
  return textData;
39653
39686
  }
39654
- function isItStopNode(stopNodes, jPath, currentTagName) {
39655
- const allNodesExp = "*." + currentTagName;
39656
- for (const stopNodePath in stopNodes) {
39657
- const stopNodeExp = stopNodes[stopNodePath];
39658
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
39659
- }
39687
+ function isItStopNode(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
39688
+ if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
39689
+ if (stopNodesExact && stopNodesExact.has(jPath)) return true;
39660
39690
  return false;
39661
39691
  }
39662
39692
  function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
@@ -39830,6 +39860,19 @@ var init_OrderedObjParser = __esm({
39830
39860
  this.saveTextToParentTag = saveTextToParentTag;
39831
39861
  this.addChild = addChild;
39832
39862
  this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
39863
+ if (this.options.stopNodes && this.options.stopNodes.length > 0) {
39864
+ this.stopNodesExact = /* @__PURE__ */ new Set();
39865
+ this.stopNodesWildcard = /* @__PURE__ */ new Set();
39866
+ for (let i = 0; i < this.options.stopNodes.length; i++) {
39867
+ const stopNodeExp = this.options.stopNodes[i];
39868
+ if (typeof stopNodeExp !== "string") continue;
39869
+ if (stopNodeExp.startsWith("*.")) {
39870
+ this.stopNodesWildcard.add(stopNodeExp.substring(2));
39871
+ } else {
39872
+ this.stopNodesExact.add(stopNodeExp);
39873
+ }
39874
+ }
39875
+ }
39833
39876
  }
39834
39877
  };
39835
39878
  attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
@@ -39882,7 +39925,7 @@ var init_OrderedObjParser = __esm({
39882
39925
  const childNode = new XmlNode(tagData.tagName);
39883
39926
  childNode.add(this.options.textNodeName, "");
39884
39927
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
39885
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
39928
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
39886
39929
  }
39887
39930
  this.addChild(currentNode, childNode, jPath, i);
39888
39931
  }
@@ -39919,7 +39962,11 @@ var init_OrderedObjParser = __esm({
39919
39962
  let attrExpPresent = result.attrExpPresent;
39920
39963
  let closeIndex = result.closeIndex;
39921
39964
  if (this.options.transformTagName) {
39922
- tagName = this.options.transformTagName(tagName);
39965
+ const newTagName = this.options.transformTagName(tagName);
39966
+ if (tagExp === tagName) {
39967
+ tagExp = newTagName;
39968
+ }
39969
+ tagName = newTagName;
39923
39970
  }
39924
39971
  if (currentNode && textData) {
39925
39972
  if (currentNode.tagname !== "!xml") {
@@ -39935,7 +39982,7 @@ var init_OrderedObjParser = __esm({
39935
39982
  jPath += jPath ? "." + tagName : tagName;
39936
39983
  }
39937
39984
  const startIndex = i;
39938
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
39985
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
39939
39986
  let tagContent = "";
39940
39987
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
39941
39988
  if (tagName[tagName.length - 1] === "/") {
@@ -39956,7 +40003,10 @@ var init_OrderedObjParser = __esm({
39956
40003
  }
39957
40004
  const childNode = new XmlNode(tagName);
39958
40005
  if (tagName !== tagExp && attrExpPresent) {
39959
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40006
+ childNode[":@"] = this.buildAttributesMap(
40007
+ tagExp,
40008
+ jPath
40009
+ );
39960
40010
  }
39961
40011
  if (tagContent) {
39962
40012
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
@@ -39974,11 +40024,15 @@ var init_OrderedObjParser = __esm({
39974
40024
  tagExp = tagExp.substr(0, tagExp.length - 1);
39975
40025
  }
39976
40026
  if (this.options.transformTagName) {
39977
- tagName = this.options.transformTagName(tagName);
40027
+ const newTagName = this.options.transformTagName(tagName);
40028
+ if (tagExp === tagName) {
40029
+ tagExp = newTagName;
40030
+ }
40031
+ tagName = newTagName;
39978
40032
  }
39979
40033
  const childNode = new XmlNode(tagName);
39980
40034
  if (tagName !== tagExp && attrExpPresent) {
39981
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40035
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
39982
40036
  }
39983
40037
  this.addChild(currentNode, childNode, jPath, startIndex);
39984
40038
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
@@ -39986,7 +40040,7 @@ var init_OrderedObjParser = __esm({
39986
40040
  const childNode = new XmlNode(tagName);
39987
40041
  this.tagsNodeStack.push(currentNode);
39988
40042
  if (tagName !== tagExp && attrExpPresent) {
39989
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40043
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
39990
40044
  }
39991
40045
  this.addChild(currentNode, childNode, jPath, startIndex);
39992
40046
  currentNode = childNode;
@@ -48723,6 +48777,7 @@ var init_runtime2 = __esm({
48723
48777
  init_handlers();
48724
48778
  init_promises();
48725
48779
  init_chat2();
48780
+ init_configuration();
48726
48781
  init_handlers2();
48727
48782
  init_interfaces();
48728
48783
  init_tracked_state();