@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/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.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
|
|
|
@@ -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);
|
|
@@ -401,12 +402,18 @@ var init_context = __esm({
|
|
|
401
402
|
return storage.run(data, callback);
|
|
402
403
|
},
|
|
403
404
|
getAll: () => {
|
|
404
|
-
|
|
405
|
+
let store = storage.getStore();
|
|
406
|
+
if (!store && defaultContext.value) {
|
|
407
|
+
store = defaultContext.value;
|
|
408
|
+
}
|
|
405
409
|
if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
|
|
406
410
|
return store;
|
|
407
411
|
},
|
|
408
412
|
get: (key, opts) => {
|
|
409
|
-
|
|
413
|
+
let store = storage.getStore();
|
|
414
|
+
if (!store && defaultContext.value) {
|
|
415
|
+
store = defaultContext.value;
|
|
416
|
+
}
|
|
410
417
|
if (store) {
|
|
411
418
|
store.states ??= [];
|
|
412
419
|
store.tags ??= [];
|
|
@@ -422,6 +429,28 @@ var init_context = __esm({
|
|
|
422
429
|
const store = storage.getStore();
|
|
423
430
|
if (!store) throw new Error("Cannot set context outside of `run`");
|
|
424
431
|
store[key] = value;
|
|
432
|
+
},
|
|
433
|
+
/**
|
|
434
|
+
* Set a default context that will be used as a fallback when no AsyncLocalStorage context is active.
|
|
435
|
+
* This is useful for testing and script execution where code runs outside of request handlers.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* context.setDefaultContext({
|
|
440
|
+
* botId: 'my-bot',
|
|
441
|
+
* integrations: agentRegistry.integrations,
|
|
442
|
+
* interfaces: agentRegistry.interfaces,
|
|
443
|
+
* })
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
setDefaultContext: (data) => {
|
|
447
|
+
defaultContext.value = data;
|
|
448
|
+
},
|
|
449
|
+
/**
|
|
450
|
+
* Clear the default context.
|
|
451
|
+
*/
|
|
452
|
+
clearDefaultContext: () => {
|
|
453
|
+
defaultContext.value = null;
|
|
425
454
|
}
|
|
426
455
|
};
|
|
427
456
|
}
|
|
@@ -34808,7 +34837,7 @@ var init_actions = __esm({
|
|
|
34808
34837
|
}
|
|
34809
34838
|
integrations ??= context.get("integrations", { optional: true });
|
|
34810
34839
|
client2 ??= context.get("client", { optional: true });
|
|
34811
|
-
const integration = integrations
|
|
34840
|
+
const integration = integrations?.find((i) => i.alias === integrationName);
|
|
34812
34841
|
const actionDef = integration?.definition.actions?.[actionName];
|
|
34813
34842
|
const handler = async (params) => {
|
|
34814
34843
|
integrations ??= context.get("integrations", { optional: true });
|
|
@@ -36357,6 +36386,9 @@ var init_tracked_state = __esm({
|
|
|
36357
36386
|
});
|
|
36358
36387
|
|
|
36359
36388
|
// src/runtime/tracked-tags.ts
|
|
36389
|
+
function isSystemTag(key) {
|
|
36390
|
+
return key.includes(":");
|
|
36391
|
+
}
|
|
36360
36392
|
var TrackedTags;
|
|
36361
36393
|
var init_tracked_tags = __esm({
|
|
36362
36394
|
"src/runtime/tracked-tags.ts"() {
|
|
@@ -36536,8 +36568,8 @@ var init_tracked_tags = __esm({
|
|
|
36536
36568
|
}
|
|
36537
36569
|
}
|
|
36538
36570
|
isDirty() {
|
|
36539
|
-
const currentKeys = Object.keys(this._tags).filter((k) => !k
|
|
36540
|
-
const initialKeys = Object.keys(this._initialTags).filter((k) => !k
|
|
36571
|
+
const currentKeys = Object.keys(this._tags).filter((k) => !isSystemTag(k)).sort();
|
|
36572
|
+
const initialKeys = Object.keys(this._initialTags).filter((k) => !isSystemTag(k)).sort();
|
|
36541
36573
|
if (currentKeys.length !== initialKeys.length) {
|
|
36542
36574
|
return true;
|
|
36543
36575
|
}
|
|
@@ -36551,10 +36583,16 @@ var init_tracked_tags = __esm({
|
|
|
36551
36583
|
get tags() {
|
|
36552
36584
|
return new Proxy(this._tags, {
|
|
36553
36585
|
set: (target, prop, value) => {
|
|
36586
|
+
if (isSystemTag(prop)) {
|
|
36587
|
+
return true;
|
|
36588
|
+
}
|
|
36554
36589
|
target[prop] = value;
|
|
36555
36590
|
return true;
|
|
36556
36591
|
},
|
|
36557
36592
|
deleteProperty: (target, prop) => {
|
|
36593
|
+
if (isSystemTag(prop)) {
|
|
36594
|
+
return true;
|
|
36595
|
+
}
|
|
36558
36596
|
target[prop] = void 0;
|
|
36559
36597
|
return true;
|
|
36560
36598
|
}
|
|
@@ -36586,7 +36624,7 @@ var init_tracked_tags = __esm({
|
|
|
36586
36624
|
async persistTags(tags) {
|
|
36587
36625
|
const tagsForApi = {};
|
|
36588
36626
|
for (const [key, value] of Object.entries(tags)) {
|
|
36589
|
-
if (value !== void 0 && !key
|
|
36627
|
+
if (value !== void 0 && !isSystemTag(key)) {
|
|
36590
36628
|
tagsForApi[key] = value;
|
|
36591
36629
|
}
|
|
36592
36630
|
}
|