@botpress/runtime 1.2.3 → 1.2.4
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/consts.d.ts +1 -0
- package/dist/consts.d.ts.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +41 -43
- package/dist/internal.js.map +2 -2
- package/dist/library.js +19 -3
- package/dist/library.js.map +2 -2
- package/dist/primitives/knowledge.d.ts.map +1 -1
- package/dist/runtime/autonomous.d.ts.map +1 -1
- package/dist/runtime.js +19 -3
- package/dist/runtime.js.map +2 -2
- package/dist/telemetry/structured-logging.d.ts.map +1 -1
- package/dist/workers/dev_worker.d.ts.map +1 -1
- package/dist/workers/worker_pool.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/consts.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export declare const CONFIGURATION_TYPE_HEADER = "x-bp-configuration-type";
|
|
|
5
5
|
export declare const CONFIGURATION_PAYLOAD_HEADER = "x-bp-configuration";
|
|
6
6
|
export declare const OPERATION_TYPE_HEADER = "x-bp-operation";
|
|
7
7
|
export declare const OPERATION_SUBTYPE_HEADER = "x-bp-type";
|
|
8
|
+
export declare const LOG_DELIMITER = "<|MESSAGE_END|>\n";
|
|
8
9
|
//# sourceMappingURL=consts.d.ts.map
|
package/dist/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAChD,eAAO,MAAM,yBAAyB,4BAA4B,CAAC;AACnE,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AACjE,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,wBAAwB,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAChD,eAAO,MAAM,yBAAyB,4BAA4B,CAAC;AACnE,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AACjE,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,wBAAwB,cAAc,CAAC;AACpD,eAAO,MAAM,aAAa,sBAAsB,CAAC"}
|
package/dist/internal.d.ts
CHANGED
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
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.2.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.2.4", adk: "not-installed", sdk: "4.16.0", llmz: "0.0.26", zai: "2.1.16", cognitive: "0.1.47" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -36437,6 +36437,14 @@ init_define_PACKAGE_VERSIONS();
|
|
|
36437
36437
|
// src/consts.ts
|
|
36438
36438
|
init_define_BUILD();
|
|
36439
36439
|
init_define_PACKAGE_VERSIONS();
|
|
36440
|
+
var BOT_ID_HEADER = "x-bot-id";
|
|
36441
|
+
var BOT_USER_ID_HEADER = "x-bot-user-id";
|
|
36442
|
+
var WEBHOOK_ID_HEADER = "x-webhook-id";
|
|
36443
|
+
var CONFIGURATION_TYPE_HEADER = "x-bp-configuration-type";
|
|
36444
|
+
var CONFIGURATION_PAYLOAD_HEADER = "x-bp-configuration";
|
|
36445
|
+
var OPERATION_TYPE_HEADER = "x-bp-operation";
|
|
36446
|
+
var OPERATION_SUBTYPE_HEADER = "x-bp-type";
|
|
36447
|
+
var LOG_DELIMITER = "<|MESSAGE_END|>\n";
|
|
36440
36448
|
|
|
36441
36449
|
// src/runtime/context/handlers.ts
|
|
36442
36450
|
import { Client } from "@botpress/client";
|
|
@@ -40407,6 +40415,9 @@ var Autonomous;
|
|
|
40407
40415
|
Autonomous2.DefaultExit = _DefaultExit;
|
|
40408
40416
|
function createKnowledgeSearchTool(knowledgeBases) {
|
|
40409
40417
|
const kbNames = knowledgeBases.map((kb) => kb.name);
|
|
40418
|
+
for (const kb of knowledgeBases) {
|
|
40419
|
+
console.log(kb.name, kb.description);
|
|
40420
|
+
}
|
|
40410
40421
|
const description = knowledgeBases.map((kb) => `- "${kb.name}": ${kb.description || "No description"}`).join("\n");
|
|
40411
40422
|
return new LlmzTool({
|
|
40412
40423
|
name: "search_knowledge",
|
|
@@ -40479,6 +40490,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40479
40490
|
message.push(p.content);
|
|
40480
40491
|
message.push(`</${tag}>`);
|
|
40481
40492
|
}
|
|
40493
|
+
console.log(message.join("\n").trim());
|
|
40482
40494
|
throw new Autonomous2.ThinkSignal(
|
|
40483
40495
|
`We got the search results. When answering the question, you MUST add inline the citations used (eg: "Yes, the price is $10${example} ...")`,
|
|
40484
40496
|
message.join("\n").trim()
|
|
@@ -40601,6 +40613,7 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40601
40613
|
message: "ThinkSignal"
|
|
40602
40614
|
});
|
|
40603
40615
|
err[HandledErrorProp] = true;
|
|
40616
|
+
throw err;
|
|
40604
40617
|
} else {
|
|
40605
40618
|
s.setAttributes({
|
|
40606
40619
|
"autonomous.tool.status": "error",
|
|
@@ -40945,7 +40958,17 @@ function serializeArgs(...args) {
|
|
|
40945
40958
|
});
|
|
40946
40959
|
}
|
|
40947
40960
|
function writeStructuredLog(type, ...args) {
|
|
40961
|
+
const output2 = process.stdout;
|
|
40948
40962
|
const { spanId, traceId } = getTraceContext();
|
|
40963
|
+
let maybeArgObj = null;
|
|
40964
|
+
try {
|
|
40965
|
+
maybeArgObj = typeof args[0] === "string" ? JSON.parse(args[0]) : args[0];
|
|
40966
|
+
} catch {
|
|
40967
|
+
}
|
|
40968
|
+
if (maybeArgObj && typeof maybeArgObj === "object" && maybeArgObj.type === "worker_stats") {
|
|
40969
|
+
output2.write((0, import_fast_safe_stringify3.default)(maybeArgObj) + LOG_DELIMITER);
|
|
40970
|
+
return;
|
|
40971
|
+
}
|
|
40949
40972
|
const logEntry = {
|
|
40950
40973
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40951
40974
|
type,
|
|
@@ -40957,8 +40980,7 @@ function writeStructuredLog(type, ...args) {
|
|
|
40957
40980
|
if (traceId) {
|
|
40958
40981
|
logEntry.traceId = traceId;
|
|
40959
40982
|
}
|
|
40960
|
-
|
|
40961
|
-
output2.write(JSON.stringify(logEntry) + "\n");
|
|
40983
|
+
output2.write((0, import_fast_safe_stringify3.default)(logEntry) + LOG_DELIMITER);
|
|
40962
40984
|
}
|
|
40963
40985
|
function installStructuredLogging() {
|
|
40964
40986
|
console.log = (...args) => {
|
|
@@ -45425,6 +45447,7 @@ var BaseKnowledge = class {
|
|
|
45425
45447
|
constructor(props) {
|
|
45426
45448
|
this.name = props.name;
|
|
45427
45449
|
this.sources = props.sources;
|
|
45450
|
+
this.description = props.description;
|
|
45428
45451
|
}
|
|
45429
45452
|
/** @internal */
|
|
45430
45453
|
getDefinition() {
|
|
@@ -45871,20 +45894,14 @@ var WorkerPool = class {
|
|
|
45871
45894
|
};
|
|
45872
45895
|
constructor(workerScript) {
|
|
45873
45896
|
this.workerScript = workerScript || path4.join(process.cwd(), ".botpress/dist/index.cjs");
|
|
45874
|
-
debugLog(
|
|
45875
|
-
"[WorkerPool] Initializing...",
|
|
45876
|
-
this.workerScript,
|
|
45877
|
-
process.cwd()
|
|
45878
|
-
);
|
|
45897
|
+
debugLog("[WorkerPool] Initializing...", this.workerScript, process.cwd());
|
|
45879
45898
|
this.initialize();
|
|
45880
45899
|
}
|
|
45881
45900
|
/**
|
|
45882
45901
|
* Initialize the worker pool with the configured number of workers
|
|
45883
45902
|
*/
|
|
45884
45903
|
initialize() {
|
|
45885
|
-
debugLog(
|
|
45886
|
-
`[WorkerPool] Initializing pool with ${WORKER_POOL_SIZE} workers`
|
|
45887
|
-
);
|
|
45904
|
+
debugLog(`[WorkerPool] Initializing pool with ${WORKER_POOL_SIZE} workers`);
|
|
45888
45905
|
for (let i = 0; i < WORKER_POOL_SIZE; i++) {
|
|
45889
45906
|
this.createWorker();
|
|
45890
45907
|
}
|
|
@@ -45989,6 +46006,9 @@ var WorkerPool = class {
|
|
|
45989
46006
|
case "debug":
|
|
45990
46007
|
console.debug(prefix, ...args);
|
|
45991
46008
|
break;
|
|
46009
|
+
case "log":
|
|
46010
|
+
console.log(prefix, ...args);
|
|
46011
|
+
break;
|
|
45992
46012
|
default:
|
|
45993
46013
|
debugLog(prefix, ...args);
|
|
45994
46014
|
}
|
|
@@ -46437,7 +46457,7 @@ function initializeParentWorker(bot2) {
|
|
|
46437
46457
|
}
|
|
46438
46458
|
})
|
|
46439
46459
|
);
|
|
46440
|
-
},
|
|
46460
|
+
}, 500);
|
|
46441
46461
|
}
|
|
46442
46462
|
|
|
46443
46463
|
// src/workers/dev_worker.ts
|
|
@@ -46445,46 +46465,16 @@ init_define_BUILD();
|
|
|
46445
46465
|
init_define_PACKAGE_VERSIONS();
|
|
46446
46466
|
import { parentPort } from "worker_threads";
|
|
46447
46467
|
var DEBUG_ENABLED3 = process.env.BP_DEBUG === "true" || process.env.BP_DEBUG === "1";
|
|
46448
|
-
var originalLog = console.log;
|
|
46449
46468
|
function debugLog3(...args) {
|
|
46450
46469
|
if (DEBUG_ENABLED3) {
|
|
46451
|
-
|
|
46470
|
+
console.log(...args);
|
|
46452
46471
|
}
|
|
46453
46472
|
}
|
|
46454
|
-
function setupLogRelay() {
|
|
46455
|
-
if (!parentPort) return;
|
|
46456
|
-
const originalConsole = {
|
|
46457
|
-
log: console.log,
|
|
46458
|
-
info: console.info,
|
|
46459
|
-
warn: console.warn,
|
|
46460
|
-
error: console.error,
|
|
46461
|
-
debug: console.debug
|
|
46462
|
-
};
|
|
46463
|
-
originalLog = originalConsole.log;
|
|
46464
|
-
const createLogRelay = (level) => {
|
|
46465
|
-
return (...args) => {
|
|
46466
|
-
parentPort.postMessage({
|
|
46467
|
-
type: "log",
|
|
46468
|
-
level,
|
|
46469
|
-
args
|
|
46470
|
-
});
|
|
46471
|
-
if (DEBUG_ENABLED3) {
|
|
46472
|
-
originalConsole[level](...args);
|
|
46473
|
-
}
|
|
46474
|
-
};
|
|
46475
|
-
};
|
|
46476
|
-
console.log = createLogRelay("log");
|
|
46477
|
-
console.info = createLogRelay("info");
|
|
46478
|
-
console.warn = createLogRelay("warn");
|
|
46479
|
-
console.error = createLogRelay("error");
|
|
46480
|
-
console.debug = createLogRelay("debug");
|
|
46481
|
-
}
|
|
46482
46473
|
function runWorker(bot2) {
|
|
46483
46474
|
const expiryTime = process.env.WORKER_EXPIRY_TIME ? parseInt(process.env.WORKER_EXPIRY_TIME, 10) : Date.now() + 5 * 60 * 1e3;
|
|
46484
46475
|
if (!parentPort) {
|
|
46485
46476
|
throw new Error("This script must be run as a worker thread");
|
|
46486
46477
|
}
|
|
46487
|
-
setupLogRelay();
|
|
46488
46478
|
parentPort.on("message", async (message) => {
|
|
46489
46479
|
const { type, taskId, event } = message;
|
|
46490
46480
|
if (type !== "event" || !taskId) {
|
|
@@ -46545,15 +46535,23 @@ var isWorkerMode = () => {
|
|
|
46545
46535
|
};
|
|
46546
46536
|
export {
|
|
46547
46537
|
Action,
|
|
46538
|
+
BOT_ID_HEADER,
|
|
46539
|
+
BOT_USER_ID_HEADER,
|
|
46548
46540
|
BaseWorkflowInstance,
|
|
46549
46541
|
BuiltInWorkflows,
|
|
46542
|
+
CONFIGURATION_PAYLOAD_HEADER,
|
|
46543
|
+
CONFIGURATION_TYPE_HEADER,
|
|
46550
46544
|
BaseConversation as Conversation,
|
|
46551
46545
|
DataSource2 as DataSource,
|
|
46552
46546
|
Errors,
|
|
46553
46547
|
BaseKnowledge as Knowledge,
|
|
46548
|
+
LOG_DELIMITER,
|
|
46549
|
+
OPERATION_SUBTYPE_HEADER,
|
|
46550
|
+
OPERATION_TYPE_HEADER,
|
|
46554
46551
|
Primitives,
|
|
46555
46552
|
BaseTable as Table,
|
|
46556
46553
|
Trigger,
|
|
46554
|
+
WEBHOOK_ID_HEADER,
|
|
46557
46555
|
BaseWorkflow as Workflow,
|
|
46558
46556
|
contextManager,
|
|
46559
46557
|
createSpan,
|