@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/internal.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
 
@@ -35082,18 +35082,51 @@ var init_state = __esm({
35082
35082
  });
35083
35083
 
35084
35084
  // src/runtime/configuration.ts
35085
- var configuration;
35085
+ function getEnvConfig() {
35086
+ const cache = getEnvConfigCache();
35087
+ if (cache.attempted) {
35088
+ return cache.parsed;
35089
+ }
35090
+ cache.attempted = true;
35091
+ const envConfig = process.env.ADK_CONFIGURATION;
35092
+ if (!envConfig) {
35093
+ return null;
35094
+ }
35095
+ try {
35096
+ cache.parsed = JSON.parse(envConfig);
35097
+ return cache.parsed;
35098
+ } catch {
35099
+ console.warn("[ADK] Failed to parse ADK_CONFIGURATION environment variable");
35100
+ return null;
35101
+ }
35102
+ }
35103
+ function getConfig() {
35104
+ const contextConfig = context.get("configuration", { optional: true });
35105
+ if (contextConfig) {
35106
+ return contextConfig;
35107
+ }
35108
+ return getEnvConfig();
35109
+ }
35110
+ var getEnvConfigCache, configuration;
35086
35111
  var init_configuration = __esm({
35087
35112
  "src/runtime/configuration.ts"() {
35088
35113
  "use strict";
35089
35114
  init_define_BUILD();
35090
35115
  init_define_PACKAGE_VERSIONS();
35091
35116
  init_context();
35117
+ init_singletons();
35118
+ getEnvConfigCache = () => getSingleton("__ADK_GLOBAL_ENV_CONFIG_CACHE", () => ({
35119
+ parsed: null,
35120
+ attempted: false
35121
+ }));
35092
35122
  configuration = new Proxy({}, {
35093
35123
  get(_target, prop) {
35094
- const config = context.get("configuration", { optional: true });
35124
+ if (typeof prop === "symbol") {
35125
+ return void 0;
35126
+ }
35127
+ const config = getConfig();
35095
35128
  if (!config) {
35096
- throw new Error("Configuration not found in context.");
35129
+ return void 0;
35097
35130
  }
35098
35131
  return config[prop];
35099
35132
  },
@@ -35101,11 +35134,11 @@ var init_configuration = __esm({
35101
35134
  throw new Error(`Cannot set configuration property "${prop}". Configuration is read-only.`);
35102
35135
  },
35103
35136
  ownKeys() {
35104
- const config = context.get("configuration", { optional: true });
35137
+ const config = getConfig();
35105
35138
  return config ? Object.keys(config) : [];
35106
35139
  },
35107
35140
  getOwnPropertyDescriptor(_target, prop) {
35108
- const config = context.get("configuration", { optional: true });
35141
+ const config = getConfig();
35109
35142
  if (!config || !(prop in config)) {
35110
35143
  return void 0;
35111
35144
  }
@@ -37937,6 +37970,7 @@ var init_runtime2 = __esm({
37937
37970
  init_handlers();
37938
37971
  init_promises();
37939
37972
  init_chat2();
37973
+ init_configuration();
37940
37974
  init_handlers2();
37941
37975
  init_interfaces();
37942
37976
  init_tracked_state();
@@ -39834,7 +39868,7 @@ function resolveNameSpace(tagname) {
39834
39868
  }
39835
39869
  return tagname;
39836
39870
  }
39837
- function buildAttributesMap(attrStr, jPath, tagName) {
39871
+ function buildAttributesMap(attrStr, jPath) {
39838
39872
  if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
39839
39873
  const matches = getAllMatches(attrStr, attrsRegx);
39840
39874
  const len = matches.length;
@@ -39912,12 +39946,9 @@ function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
39912
39946
  }
39913
39947
  return textData;
39914
39948
  }
39915
- function isItStopNode(stopNodes, jPath, currentTagName) {
39916
- const allNodesExp = "*." + currentTagName;
39917
- for (const stopNodePath in stopNodes) {
39918
- const stopNodeExp = stopNodes[stopNodePath];
39919
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
39920
- }
39949
+ function isItStopNode(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
39950
+ if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
39951
+ if (stopNodesExact && stopNodesExact.has(jPath)) return true;
39921
39952
  return false;
39922
39953
  }
39923
39954
  function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
@@ -40091,6 +40122,19 @@ var init_OrderedObjParser = __esm({
40091
40122
  this.saveTextToParentTag = saveTextToParentTag;
40092
40123
  this.addChild = addChild;
40093
40124
  this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
40125
+ if (this.options.stopNodes && this.options.stopNodes.length > 0) {
40126
+ this.stopNodesExact = /* @__PURE__ */ new Set();
40127
+ this.stopNodesWildcard = /* @__PURE__ */ new Set();
40128
+ for (let i = 0; i < this.options.stopNodes.length; i++) {
40129
+ const stopNodeExp = this.options.stopNodes[i];
40130
+ if (typeof stopNodeExp !== "string") continue;
40131
+ if (stopNodeExp.startsWith("*.")) {
40132
+ this.stopNodesWildcard.add(stopNodeExp.substring(2));
40133
+ } else {
40134
+ this.stopNodesExact.add(stopNodeExp);
40135
+ }
40136
+ }
40137
+ }
40094
40138
  }
40095
40139
  };
40096
40140
  attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
@@ -40143,7 +40187,7 @@ var init_OrderedObjParser = __esm({
40143
40187
  const childNode = new XmlNode(tagData.tagName);
40144
40188
  childNode.add(this.options.textNodeName, "");
40145
40189
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
40146
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
40190
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
40147
40191
  }
40148
40192
  this.addChild(currentNode, childNode, jPath, i);
40149
40193
  }
@@ -40180,7 +40224,11 @@ var init_OrderedObjParser = __esm({
40180
40224
  let attrExpPresent = result.attrExpPresent;
40181
40225
  let closeIndex = result.closeIndex;
40182
40226
  if (this.options.transformTagName) {
40183
- tagName = this.options.transformTagName(tagName);
40227
+ const newTagName = this.options.transformTagName(tagName);
40228
+ if (tagExp === tagName) {
40229
+ tagExp = newTagName;
40230
+ }
40231
+ tagName = newTagName;
40184
40232
  }
40185
40233
  if (currentNode && textData) {
40186
40234
  if (currentNode.tagname !== "!xml") {
@@ -40196,7 +40244,7 @@ var init_OrderedObjParser = __esm({
40196
40244
  jPath += jPath ? "." + tagName : tagName;
40197
40245
  }
40198
40246
  const startIndex = i;
40199
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
40247
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
40200
40248
  let tagContent = "";
40201
40249
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
40202
40250
  if (tagName[tagName.length - 1] === "/") {
@@ -40217,7 +40265,10 @@ var init_OrderedObjParser = __esm({
40217
40265
  }
40218
40266
  const childNode = new XmlNode(tagName);
40219
40267
  if (tagName !== tagExp && attrExpPresent) {
40220
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40268
+ childNode[":@"] = this.buildAttributesMap(
40269
+ tagExp,
40270
+ jPath
40271
+ );
40221
40272
  }
40222
40273
  if (tagContent) {
40223
40274
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
@@ -40235,11 +40286,15 @@ var init_OrderedObjParser = __esm({
40235
40286
  tagExp = tagExp.substr(0, tagExp.length - 1);
40236
40287
  }
40237
40288
  if (this.options.transformTagName) {
40238
- tagName = this.options.transformTagName(tagName);
40289
+ const newTagName = this.options.transformTagName(tagName);
40290
+ if (tagExp === tagName) {
40291
+ tagExp = newTagName;
40292
+ }
40293
+ tagName = newTagName;
40239
40294
  }
40240
40295
  const childNode = new XmlNode(tagName);
40241
40296
  if (tagName !== tagExp && attrExpPresent) {
40242
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40297
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
40243
40298
  }
40244
40299
  this.addChild(currentNode, childNode, jPath, startIndex);
40245
40300
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
@@ -40247,7 +40302,7 @@ var init_OrderedObjParser = __esm({
40247
40302
  const childNode = new XmlNode(tagName);
40248
40303
  this.tagsNodeStack.push(currentNode);
40249
40304
  if (tagName !== tagExp && attrExpPresent) {
40250
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
40305
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
40251
40306
  }
40252
40307
  this.addChild(currentNode, childNode, jPath, startIndex);
40253
40308
  currentNode = childNode;