@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/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.
|
|
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
|
|
|
@@ -79,7 +79,7 @@ var init_singletons = __esm({
|
|
|
79
79
|
|
|
80
80
|
// src/runtime/context/context.ts
|
|
81
81
|
import { AsyncLocalStorage } from "async_hooks";
|
|
82
|
-
var storage, context;
|
|
82
|
+
var storage, defaultContext, context;
|
|
83
83
|
var init_context = __esm({
|
|
84
84
|
"src/runtime/context/context.ts"() {
|
|
85
85
|
"use strict";
|
|
@@ -87,6 +87,7 @@ var init_context = __esm({
|
|
|
87
87
|
init_define_PACKAGE_VERSIONS();
|
|
88
88
|
init_singletons();
|
|
89
89
|
storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage());
|
|
90
|
+
defaultContext = getSingleton("__ADK_GLOBAL_DEFAULT_CTX", () => ({ value: null }));
|
|
90
91
|
context = {
|
|
91
92
|
enterWith: (data) => {
|
|
92
93
|
storage.enterWith(data);
|
|
@@ -100,12 +101,18 @@ var init_context = __esm({
|
|
|
100
101
|
return storage.run(data, callback);
|
|
101
102
|
},
|
|
102
103
|
getAll: () => {
|
|
103
|
-
|
|
104
|
+
let store = storage.getStore();
|
|
105
|
+
if (!store && defaultContext.value) {
|
|
106
|
+
store = defaultContext.value;
|
|
107
|
+
}
|
|
104
108
|
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
105
109
|
return store;
|
|
106
110
|
},
|
|
107
111
|
get: (key, opts) => {
|
|
108
|
-
|
|
112
|
+
let store = storage.getStore();
|
|
113
|
+
if (!store && defaultContext.value) {
|
|
114
|
+
store = defaultContext.value;
|
|
115
|
+
}
|
|
109
116
|
if (store) {
|
|
110
117
|
store.states ??= [];
|
|
111
118
|
store.tags ??= [];
|
|
@@ -121,6 +128,28 @@ var init_context = __esm({
|
|
|
121
128
|
const store = storage.getStore();
|
|
122
129
|
if (!store) throw new Error("Cannot set context outside of `run`");
|
|
123
130
|
store[key] = value;
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* Set a default context that will be used as a fallback when no AsyncLocalStorage context is active.
|
|
134
|
+
* This is useful for testing and script execution where code runs outside of request handlers.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* context.setDefaultContext({
|
|
139
|
+
* botId: 'my-bot',
|
|
140
|
+
* integrations: agentRegistry.integrations,
|
|
141
|
+
* interfaces: agentRegistry.interfaces,
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
setDefaultContext: (data) => {
|
|
146
|
+
defaultContext.value = data;
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* Clear the default context.
|
|
150
|
+
*/
|
|
151
|
+
clearDefaultContext: () => {
|
|
152
|
+
defaultContext.value = null;
|
|
124
153
|
}
|
|
125
154
|
};
|
|
126
155
|
}
|
|
@@ -34608,7 +34637,7 @@ var init_actions = __esm({
|
|
|
34608
34637
|
}
|
|
34609
34638
|
integrations ??= context.get("integrations", { optional: true });
|
|
34610
34639
|
client2 ??= context.get("client", { optional: true });
|
|
34611
|
-
const integration = integrations
|
|
34640
|
+
const integration = integrations?.find((i) => i.alias === integrationName);
|
|
34612
34641
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
34613
34642
|
const handler = async (params) => {
|
|
34614
34643
|
integrations ??= context.get("integrations", { optional: true });
|
|
@@ -37455,6 +37484,9 @@ var init_tracked_state = __esm({
|
|
|
37455
37484
|
});
|
|
37456
37485
|
|
|
37457
37486
|
// src/runtime/tracked-tags.ts
|
|
37487
|
+
function isSystemTag(key) {
|
|
37488
|
+
return key.includes(":");
|
|
37489
|
+
}
|
|
37458
37490
|
var TrackedTags;
|
|
37459
37491
|
var init_tracked_tags = __esm({
|
|
37460
37492
|
"src/runtime/tracked-tags.ts"() {
|
|
@@ -37634,8 +37666,8 @@ var init_tracked_tags = __esm({
|
|
|
37634
37666
|
}
|
|
37635
37667
|
}
|
|
37636
37668
|
isDirty() {
|
|
37637
|
-
const currentKeys = Object.keys(this._tags).filter((k) => !k
|
|
37638
|
-
const initialKeys = Object.keys(this._initialTags).filter((k) => !k
|
|
37669
|
+
const currentKeys = Object.keys(this._tags).filter((k) => !isSystemTag(k)).sort();
|
|
37670
|
+
const initialKeys = Object.keys(this._initialTags).filter((k) => !isSystemTag(k)).sort();
|
|
37639
37671
|
if (currentKeys.length !== initialKeys.length) {
|
|
37640
37672
|
return true;
|
|
37641
37673
|
}
|
|
@@ -37649,10 +37681,16 @@ var init_tracked_tags = __esm({
|
|
|
37649
37681
|
get tags() {
|
|
37650
37682
|
return new Proxy(this._tags, {
|
|
37651
37683
|
set: (target, prop, value) => {
|
|
37684
|
+
if (isSystemTag(prop)) {
|
|
37685
|
+
return true;
|
|
37686
|
+
}
|
|
37652
37687
|
target[prop] = value;
|
|
37653
37688
|
return true;
|
|
37654
37689
|
},
|
|
37655
37690
|
deleteProperty: (target, prop) => {
|
|
37691
|
+
if (isSystemTag(prop)) {
|
|
37692
|
+
return true;
|
|
37693
|
+
}
|
|
37656
37694
|
target[prop] = void 0;
|
|
37657
37695
|
return true;
|
|
37658
37696
|
}
|
|
@@ -37684,7 +37722,7 @@ var init_tracked_tags = __esm({
|
|
|
37684
37722
|
async persistTags(tags) {
|
|
37685
37723
|
const tagsForApi = {};
|
|
37686
37724
|
for (const [key, value] of Object.entries(tags)) {
|
|
37687
|
-
if (value !== void 0 && !key
|
|
37725
|
+
if (value !== void 0 && !isSystemTag(key)) {
|
|
37688
37726
|
tagsForApi[key] = value;
|
|
37689
37727
|
}
|
|
37690
37728
|
}
|