@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.
- package/dist/definition.js +42 -7
- package/dist/definition.js.map +2 -2
- package/dist/internal.js +42 -7
- package/dist/internal.js.map +2 -2
- package/dist/library.js +42 -7
- 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 +56 -19
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
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.
|
|
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
|
|
|
@@ -380,7 +380,7 @@ var init_singletons = __esm({
|
|
|
380
380
|
|
|
381
381
|
// src/runtime/context/context.ts
|
|
382
382
|
import { AsyncLocalStorage } from "async_hooks";
|
|
383
|
-
var storage, context;
|
|
383
|
+
var storage, defaultContext, context;
|
|
384
384
|
var init_context = __esm({
|
|
385
385
|
"src/runtime/context/context.ts"() {
|
|
386
386
|
"use strict";
|
|
@@ -388,6 +388,7 @@ var init_context = __esm({
|
|
|
388
388
|
init_define_PACKAGE_VERSIONS();
|
|
389
389
|
init_singletons();
|
|
390
390
|
storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage());
|
|
391
|
+
defaultContext = getSingleton("__ADK_GLOBAL_DEFAULT_CTX", () => ({ value: null }));
|
|
391
392
|
context = {
|
|
392
393
|
enterWith: (data) => {
|
|
393
394
|
storage.enterWith(data);
|
|
@@ -406,7 +407,10 @@ var init_context = __esm({
|
|
|
406
407
|
return store;
|
|
407
408
|
},
|
|
408
409
|
get: (key, opts) => {
|
|
409
|
-
|
|
410
|
+
let store = storage.getStore();
|
|
411
|
+
if (!store && defaultContext.value) {
|
|
412
|
+
store = defaultContext.value;
|
|
413
|
+
}
|
|
410
414
|
if (store) {
|
|
411
415
|
store.states ??= [];
|
|
412
416
|
store.tags ??= [];
|
|
@@ -422,6 +426,28 @@ var init_context = __esm({
|
|
|
422
426
|
const store = storage.getStore();
|
|
423
427
|
if (!store) throw new Error("Cannot set context outside of `run`");
|
|
424
428
|
store[key] = value;
|
|
429
|
+
},
|
|
430
|
+
/**
|
|
431
|
+
* Set a default context that will be used as a fallback when no AsyncLocalStorage context is active.
|
|
432
|
+
* This is useful for testing and script execution where code runs outside of request handlers.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* context.setDefaultContext({
|
|
437
|
+
* botId: 'my-bot',
|
|
438
|
+
* integrations: agentRegistry.integrations,
|
|
439
|
+
* interfaces: agentRegistry.interfaces,
|
|
440
|
+
* })
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
setDefaultContext: (data) => {
|
|
444
|
+
defaultContext.value = data;
|
|
445
|
+
},
|
|
446
|
+
/**
|
|
447
|
+
* Clear the default context.
|
|
448
|
+
*/
|
|
449
|
+
clearDefaultContext: () => {
|
|
450
|
+
defaultContext.value = null;
|
|
425
451
|
}
|
|
426
452
|
};
|
|
427
453
|
}
|
|
@@ -34808,7 +34834,7 @@ var init_actions = __esm({
|
|
|
34808
34834
|
}
|
|
34809
34835
|
integrations ??= context.get("integrations", { optional: true });
|
|
34810
34836
|
client2 ??= context.get("client", { optional: true });
|
|
34811
|
-
const integration = integrations
|
|
34837
|
+
const integration = integrations?.find((i) => i.alias === integrationName);
|
|
34812
34838
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
34813
34839
|
const handler = async (params) => {
|
|
34814
34840
|
integrations ??= context.get("integrations", { optional: true });
|
|
@@ -36357,6 +36383,9 @@ var init_tracked_state = __esm({
|
|
|
36357
36383
|
});
|
|
36358
36384
|
|
|
36359
36385
|
// src/runtime/tracked-tags.ts
|
|
36386
|
+
function isSystemTag(key) {
|
|
36387
|
+
return key.includes(":");
|
|
36388
|
+
}
|
|
36360
36389
|
var TrackedTags;
|
|
36361
36390
|
var init_tracked_tags = __esm({
|
|
36362
36391
|
"src/runtime/tracked-tags.ts"() {
|
|
@@ -36536,8 +36565,8 @@ var init_tracked_tags = __esm({
|
|
|
36536
36565
|
}
|
|
36537
36566
|
}
|
|
36538
36567
|
isDirty() {
|
|
36539
|
-
const currentKeys = Object.keys(this._tags).filter((k) => !k
|
|
36540
|
-
const initialKeys = Object.keys(this._initialTags).filter((k) => !k
|
|
36568
|
+
const currentKeys = Object.keys(this._tags).filter((k) => !isSystemTag(k)).sort();
|
|
36569
|
+
const initialKeys = Object.keys(this._initialTags).filter((k) => !isSystemTag(k)).sort();
|
|
36541
36570
|
if (currentKeys.length !== initialKeys.length) {
|
|
36542
36571
|
return true;
|
|
36543
36572
|
}
|
|
@@ -36551,10 +36580,16 @@ var init_tracked_tags = __esm({
|
|
|
36551
36580
|
get tags() {
|
|
36552
36581
|
return new Proxy(this._tags, {
|
|
36553
36582
|
set: (target, prop, value) => {
|
|
36583
|
+
if (isSystemTag(prop)) {
|
|
36584
|
+
return true;
|
|
36585
|
+
}
|
|
36554
36586
|
target[prop] = value;
|
|
36555
36587
|
return true;
|
|
36556
36588
|
},
|
|
36557
36589
|
deleteProperty: (target, prop) => {
|
|
36590
|
+
if (isSystemTag(prop)) {
|
|
36591
|
+
return true;
|
|
36592
|
+
}
|
|
36558
36593
|
target[prop] = void 0;
|
|
36559
36594
|
return true;
|
|
36560
36595
|
}
|
|
@@ -36586,7 +36621,7 @@ var init_tracked_tags = __esm({
|
|
|
36586
36621
|
async persistTags(tags) {
|
|
36587
36622
|
const tagsForApi = {};
|
|
36588
36623
|
for (const [key, value] of Object.entries(tags)) {
|
|
36589
|
-
if (value !== void 0 && !key
|
|
36624
|
+
if (value !== void 0 && !isSystemTag(key)) {
|
|
36590
36625
|
tagsForApi[key] = value;
|
|
36591
36626
|
}
|
|
36592
36627
|
}
|