@botpress/runtime 1.13.10 → 1.13.11

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.10", adk: "1.13.10", sdk: "5.0.2", llmz: "0.0.35", zai: "2.5.6", cognitive: "0.3.3" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.13.11", adk: "1.13.11", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
52
52
  }
53
53
  });
54
54
 
@@ -32780,7 +32780,7 @@ var init_assets = __esm({
32780
32780
 
32781
32781
  // src/runtime/context/context.ts
32782
32782
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
32783
- var storage, context2;
32783
+ var storage, defaultContext, context2;
32784
32784
  var init_context3 = __esm({
32785
32785
  "src/runtime/context/context.ts"() {
32786
32786
  "use strict";
@@ -32788,6 +32788,7 @@ var init_context3 = __esm({
32788
32788
  init_define_PACKAGE_VERSIONS();
32789
32789
  init_singletons();
32790
32790
  storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage2());
32791
+ defaultContext = getSingleton("__ADK_GLOBAL_DEFAULT_CTX", () => ({ value: null }));
32791
32792
  context2 = {
32792
32793
  enterWith: (data) => {
32793
32794
  storage.enterWith(data);
@@ -32806,7 +32807,10 @@ var init_context3 = __esm({
32806
32807
  return store;
32807
32808
  },
32808
32809
  get: (key, opts) => {
32809
- const store = storage.getStore();
32810
+ let store = storage.getStore();
32811
+ if (!store && defaultContext.value) {
32812
+ store = defaultContext.value;
32813
+ }
32810
32814
  if (store) {
32811
32815
  store.states ??= [];
32812
32816
  store.tags ??= [];
@@ -32822,6 +32826,28 @@ var init_context3 = __esm({
32822
32826
  const store = storage.getStore();
32823
32827
  if (!store) throw new Error("Cannot set context outside of `run`");
32824
32828
  store[key] = value;
32829
+ },
32830
+ /**
32831
+ * Set a default context that will be used as a fallback when no AsyncLocalStorage context is active.
32832
+ * This is useful for testing and script execution where code runs outside of request handlers.
32833
+ *
32834
+ * @example
32835
+ * ```typescript
32836
+ * context.setDefaultContext({
32837
+ * botId: 'my-bot',
32838
+ * integrations: agentRegistry.integrations,
32839
+ * interfaces: agentRegistry.interfaces,
32840
+ * })
32841
+ * ```
32842
+ */
32843
+ setDefaultContext: (data) => {
32844
+ defaultContext.value = data;
32845
+ },
32846
+ /**
32847
+ * Clear the default context.
32848
+ */
32849
+ clearDefaultContext: () => {
32850
+ defaultContext.value = null;
32825
32851
  }
32826
32852
  };
32827
32853
  }
@@ -32945,6 +32971,9 @@ var init_agent_registry = __esm({
32945
32971
  });
32946
32972
 
32947
32973
  // src/runtime/tracked-tags.ts
32974
+ function isSystemTag(key) {
32975
+ return key.includes(":");
32976
+ }
32948
32977
  var TrackedTags;
32949
32978
  var init_tracked_tags = __esm({
32950
32979
  "src/runtime/tracked-tags.ts"() {
@@ -33124,8 +33153,8 @@ var init_tracked_tags = __esm({
33124
33153
  }
33125
33154
  }
33126
33155
  isDirty() {
33127
- const currentKeys = Object.keys(this._tags).filter((k) => !k.includes(":")).sort();
33128
- const initialKeys = Object.keys(this._initialTags).filter((k) => !k.includes(":")).sort();
33156
+ const currentKeys = Object.keys(this._tags).filter((k) => !isSystemTag(k)).sort();
33157
+ const initialKeys = Object.keys(this._initialTags).filter((k) => !isSystemTag(k)).sort();
33129
33158
  if (currentKeys.length !== initialKeys.length) {
33130
33159
  return true;
33131
33160
  }
@@ -33139,10 +33168,16 @@ var init_tracked_tags = __esm({
33139
33168
  get tags() {
33140
33169
  return new Proxy(this._tags, {
33141
33170
  set: (target, prop, value) => {
33171
+ if (isSystemTag(prop)) {
33172
+ return true;
33173
+ }
33142
33174
  target[prop] = value;
33143
33175
  return true;
33144
33176
  },
33145
33177
  deleteProperty: (target, prop) => {
33178
+ if (isSystemTag(prop)) {
33179
+ return true;
33180
+ }
33146
33181
  target[prop] = void 0;
33147
33182
  return true;
33148
33183
  }
@@ -33174,7 +33209,7 @@ var init_tracked_tags = __esm({
33174
33209
  async persistTags(tags) {
33175
33210
  const tagsForApi = {};
33176
33211
  for (const [key, value] of Object.entries(tags)) {
33177
- if (value !== void 0 && !key.includes(":")) {
33212
+ if (value !== void 0 && !isSystemTag(key)) {
33178
33213
  tagsForApi[key] = value;
33179
33214
  }
33180
33215
  }
@@ -34240,7 +34275,7 @@ var init_actions = __esm({
34240
34275
  }
34241
34276
  integrations ??= context2.get("integrations", { optional: true });
34242
34277
  client2 ??= context2.get("client", { optional: true });
34243
- const integration = integrations.find((i) => i.alias === integrationName);
34278
+ const integration = integrations?.find((i) => i.alias === integrationName);
34244
34279
  const actionDef = integration?.definition.actions?.[actionName];
34245
34280
  const handler = async (params) => {
34246
34281
  integrations ??= context2.get("integrations", { optional: true });