@botpress/runtime 1.13.10 → 1.13.12
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/definition.js +46 -8
- package/dist/definition.js.map +2 -2
- package/dist/internal.js +46 -8
- package/dist/internal.js.map +2 -2
- package/dist/library.js +46 -8
- package/dist/library.js.map +2 -2
- package/dist/runtime/context/context.d.ts +18 -0
- package/dist/runtime/context/context.d.ts.map +1 -1
- package/dist/runtime/handlers/trigger.d.ts.map +1 -1
- package/dist/runtime/tracked-tags.d.ts +2 -0
- package/dist/runtime/tracked-tags.d.ts.map +1 -1
- package/dist/runtime.js +60 -20
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/definition.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.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.13.12", adk: "1.13.12", 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);
|
|
@@ -32801,12 +32802,18 @@ var init_context3 = __esm({
|
|
|
32801
32802
|
return storage.run(data, callback);
|
|
32802
32803
|
},
|
|
32803
32804
|
getAll: () => {
|
|
32804
|
-
|
|
32805
|
+
let store = storage.getStore();
|
|
32806
|
+
if (!store && defaultContext.value) {
|
|
32807
|
+
store = defaultContext.value;
|
|
32808
|
+
}
|
|
32805
32809
|
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
32806
32810
|
return store;
|
|
32807
32811
|
},
|
|
32808
32812
|
get: (key, opts) => {
|
|
32809
|
-
|
|
32813
|
+
let store = storage.getStore();
|
|
32814
|
+
if (!store && defaultContext.value) {
|
|
32815
|
+
store = defaultContext.value;
|
|
32816
|
+
}
|
|
32810
32817
|
if (store) {
|
|
32811
32818
|
store.states ??= [];
|
|
32812
32819
|
store.tags ??= [];
|
|
@@ -32822,6 +32829,28 @@ var init_context3 = __esm({
|
|
|
32822
32829
|
const store = storage.getStore();
|
|
32823
32830
|
if (!store) throw new Error("Cannot set context outside of `run`");
|
|
32824
32831
|
store[key] = value;
|
|
32832
|
+
},
|
|
32833
|
+
/**
|
|
32834
|
+
* Set a default context that will be used as a fallback when no AsyncLocalStorage context is active.
|
|
32835
|
+
* This is useful for testing and script execution where code runs outside of request handlers.
|
|
32836
|
+
*
|
|
32837
|
+
* @example
|
|
32838
|
+
* ```typescript
|
|
32839
|
+
* context.setDefaultContext({
|
|
32840
|
+
* botId: 'my-bot',
|
|
32841
|
+
* integrations: agentRegistry.integrations,
|
|
32842
|
+
* interfaces: agentRegistry.interfaces,
|
|
32843
|
+
* })
|
|
32844
|
+
* ```
|
|
32845
|
+
*/
|
|
32846
|
+
setDefaultContext: (data) => {
|
|
32847
|
+
defaultContext.value = data;
|
|
32848
|
+
},
|
|
32849
|
+
/**
|
|
32850
|
+
* Clear the default context.
|
|
32851
|
+
*/
|
|
32852
|
+
clearDefaultContext: () => {
|
|
32853
|
+
defaultContext.value = null;
|
|
32825
32854
|
}
|
|
32826
32855
|
};
|
|
32827
32856
|
}
|
|
@@ -32945,6 +32974,9 @@ var init_agent_registry = __esm({
|
|
|
32945
32974
|
});
|
|
32946
32975
|
|
|
32947
32976
|
// src/runtime/tracked-tags.ts
|
|
32977
|
+
function isSystemTag(key) {
|
|
32978
|
+
return key.includes(":");
|
|
32979
|
+
}
|
|
32948
32980
|
var TrackedTags;
|
|
32949
32981
|
var init_tracked_tags = __esm({
|
|
32950
32982
|
"src/runtime/tracked-tags.ts"() {
|
|
@@ -33124,8 +33156,8 @@ var init_tracked_tags = __esm({
|
|
|
33124
33156
|
}
|
|
33125
33157
|
}
|
|
33126
33158
|
isDirty() {
|
|
33127
|
-
const currentKeys = Object.keys(this._tags).filter((k) => !k
|
|
33128
|
-
const initialKeys = Object.keys(this._initialTags).filter((k) => !k
|
|
33159
|
+
const currentKeys = Object.keys(this._tags).filter((k) => !isSystemTag(k)).sort();
|
|
33160
|
+
const initialKeys = Object.keys(this._initialTags).filter((k) => !isSystemTag(k)).sort();
|
|
33129
33161
|
if (currentKeys.length !== initialKeys.length) {
|
|
33130
33162
|
return true;
|
|
33131
33163
|
}
|
|
@@ -33139,10 +33171,16 @@ var init_tracked_tags = __esm({
|
|
|
33139
33171
|
get tags() {
|
|
33140
33172
|
return new Proxy(this._tags, {
|
|
33141
33173
|
set: (target, prop, value) => {
|
|
33174
|
+
if (isSystemTag(prop)) {
|
|
33175
|
+
return true;
|
|
33176
|
+
}
|
|
33142
33177
|
target[prop] = value;
|
|
33143
33178
|
return true;
|
|
33144
33179
|
},
|
|
33145
33180
|
deleteProperty: (target, prop) => {
|
|
33181
|
+
if (isSystemTag(prop)) {
|
|
33182
|
+
return true;
|
|
33183
|
+
}
|
|
33146
33184
|
target[prop] = void 0;
|
|
33147
33185
|
return true;
|
|
33148
33186
|
}
|
|
@@ -33174,7 +33212,7 @@ var init_tracked_tags = __esm({
|
|
|
33174
33212
|
async persistTags(tags) {
|
|
33175
33213
|
const tagsForApi = {};
|
|
33176
33214
|
for (const [key, value] of Object.entries(tags)) {
|
|
33177
|
-
if (value !== void 0 && !key
|
|
33215
|
+
if (value !== void 0 && !isSystemTag(key)) {
|
|
33178
33216
|
tagsForApi[key] = value;
|
|
33179
33217
|
}
|
|
33180
33218
|
}
|
|
@@ -34240,7 +34278,7 @@ var init_actions = __esm({
|
|
|
34240
34278
|
}
|
|
34241
34279
|
integrations ??= context2.get("integrations", { optional: true });
|
|
34242
34280
|
client2 ??= context2.get("client", { optional: true });
|
|
34243
|
-
const integration = integrations
|
|
34281
|
+
const integration = integrations?.find((i) => i.alias === integrationName);
|
|
34244
34282
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
34245
34283
|
const handler = async (params) => {
|
|
34246
34284
|
integrations ??= context2.get("integrations", { optional: true });
|