@botpress/adk 1.0.1 → 1.2.0
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/agent-project/expand-exports.d.ts.map +1 -1
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/interface-sync.d.ts.map +1 -1
- package/dist/commands/bp-chat-command.d.ts +18 -0
- package/dist/commands/bp-chat-command.d.ts.map +1 -0
- package/dist/commands/bp-cli.d.ts.map +1 -1
- package/dist/commands/bp-dev-command.d.ts.map +1 -1
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/generators/action-types.d.ts.map +1 -1
- package/dist/generators/state-types.d.ts.map +1 -1
- package/dist/generators/table-types.d.ts.map +1 -1
- package/dist/generators/workflow-types.d.ts.map +1 -1
- package/dist/index.js +207 -105
- package/dist/index.js.map +16 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -155503,7 +155503,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155503
155503
|
Object.defineProperty(exports, "__esModule", {
|
|
155504
155504
|
value: true
|
|
155505
155505
|
});
|
|
155506
|
-
exports.access =
|
|
155506
|
+
exports.access = access4;
|
|
155507
155507
|
exports.assertArray = assertArray;
|
|
155508
155508
|
exports.assertAssumptions = assertAssumptions;
|
|
155509
155509
|
exports.assertBabelrcSearch = assertBabelrcSearch;
|
|
@@ -155547,7 +155547,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155547
155547
|
throw new Error(`Assertion failure: Unknown type ${loc.type}`);
|
|
155548
155548
|
}
|
|
155549
155549
|
}
|
|
155550
|
-
function
|
|
155550
|
+
function access4(loc, name) {
|
|
155551
155551
|
return {
|
|
155552
155552
|
type: "access",
|
|
155553
155553
|
name,
|
|
@@ -155585,7 +155585,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155585
155585
|
throw new Error(`${msg(loc)} set but does not contain "name" property string`);
|
|
155586
155586
|
}
|
|
155587
155587
|
for (const prop of Object.keys(obj)) {
|
|
155588
|
-
const propLoc =
|
|
155588
|
+
const propLoc = access4(loc, prop);
|
|
155589
155589
|
const value3 = obj[prop];
|
|
155590
155590
|
if (value3 != null && typeof value3 !== "boolean" && typeof value3 !== "string" && typeof value3 !== "number") {
|
|
155591
155591
|
throw new Error(`${msg(propLoc)} must be null, undefined, a boolean, a string, or a number.`);
|
|
@@ -155632,7 +155632,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155632
155632
|
}
|
|
155633
155633
|
function assertIgnoreList(loc, value2) {
|
|
155634
155634
|
const arr = assertArray(loc, value2);
|
|
155635
|
-
arr == null || arr.forEach((item, i3) => assertIgnoreItem(
|
|
155635
|
+
arr == null || arr.forEach((item, i3) => assertIgnoreItem(access4(loc, i3), item));
|
|
155636
155636
|
return arr;
|
|
155637
155637
|
}
|
|
155638
155638
|
function assertIgnoreItem(loc, value2) {
|
|
@@ -155648,7 +155648,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155648
155648
|
if (Array.isArray(value2)) {
|
|
155649
155649
|
value2.forEach((item, i3) => {
|
|
155650
155650
|
if (!checkValidTest(item)) {
|
|
155651
|
-
throw new Error(`${msg(
|
|
155651
|
+
throw new Error(`${msg(access4(loc, i3))} must be a string/Function/RegExp.`);
|
|
155652
155652
|
}
|
|
155653
155653
|
});
|
|
155654
155654
|
} else if (!checkValidTest(value2)) {
|
|
@@ -155672,7 +155672,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155672
155672
|
if (Array.isArray(value2)) {
|
|
155673
155673
|
value2.forEach((item, i3) => {
|
|
155674
155674
|
if (!checkValidTest(item)) {
|
|
155675
|
-
throw new Error(`${msg(
|
|
155675
|
+
throw new Error(`${msg(access4(loc, i3))} must be a string/Function/RegExp.`);
|
|
155676
155676
|
}
|
|
155677
155677
|
});
|
|
155678
155678
|
} else if (!checkValidTest(value2)) {
|
|
@@ -155683,7 +155683,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155683
155683
|
function assertPluginList(loc, value2) {
|
|
155684
155684
|
const arr = assertArray(loc, value2);
|
|
155685
155685
|
if (arr) {
|
|
155686
|
-
arr.forEach((item, i3) => assertPluginItem(
|
|
155686
|
+
arr.forEach((item, i3) => assertPluginItem(access4(loc, i3), item));
|
|
155687
155687
|
}
|
|
155688
155688
|
return arr;
|
|
155689
155689
|
}
|
|
@@ -155695,17 +155695,17 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155695
155695
|
if (value2.length > 3) {
|
|
155696
155696
|
throw new Error(`${msg(loc)} may only be a two-tuple or three-tuple`);
|
|
155697
155697
|
}
|
|
155698
|
-
assertPluginTarget(
|
|
155698
|
+
assertPluginTarget(access4(loc, 0), value2[0]);
|
|
155699
155699
|
if (value2.length > 1) {
|
|
155700
155700
|
const opts = value2[1];
|
|
155701
155701
|
if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts) || opts === null)) {
|
|
155702
|
-
throw new Error(`${msg(
|
|
155702
|
+
throw new Error(`${msg(access4(loc, 1))} must be an object, false, or undefined`);
|
|
155703
155703
|
}
|
|
155704
155704
|
}
|
|
155705
155705
|
if (value2.length === 3) {
|
|
155706
155706
|
const name = value2[2];
|
|
155707
155707
|
if (name !== undefined && typeof name !== "string") {
|
|
155708
|
-
throw new Error(`${msg(
|
|
155708
|
+
throw new Error(`${msg(access4(loc, 2))} must be a string, or undefined`);
|
|
155709
155709
|
}
|
|
155710
155710
|
}
|
|
155711
155711
|
} else {
|
|
@@ -155725,13 +155725,13 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155725
155725
|
if (typeof value2 !== "object" || !value2 || Array.isArray(value2)) {
|
|
155726
155726
|
throw new Error(`${msg(loc)} must be a string, an array of strings or an object`);
|
|
155727
155727
|
}
|
|
155728
|
-
const browsersLoc =
|
|
155729
|
-
const esmodulesLoc =
|
|
155728
|
+
const browsersLoc = access4(loc, "browsers");
|
|
155729
|
+
const esmodulesLoc = access4(loc, "esmodules");
|
|
155730
155730
|
assertBrowsersList(browsersLoc, value2.browsers);
|
|
155731
155731
|
assertBoolean(esmodulesLoc, value2.esmodules);
|
|
155732
155732
|
for (const key of Object.keys(value2)) {
|
|
155733
155733
|
const val = value2[key];
|
|
155734
|
-
const subLoc =
|
|
155734
|
+
const subLoc = access4(loc, key);
|
|
155735
155735
|
if (key === "esmodules")
|
|
155736
155736
|
assertBoolean(subLoc, val);
|
|
155737
155737
|
else if (key === "browsers")
|
|
@@ -155768,7 +155768,7 @@ var require_option_assertions = __commonJS((exports) => {
|
|
|
155768
155768
|
} while (root3.type !== "root");
|
|
155769
155769
|
const inPreset = root3.source === "preset";
|
|
155770
155770
|
for (const name of Object.keys(value2)) {
|
|
155771
|
-
const subLoc =
|
|
155771
|
+
const subLoc = access4(loc, name);
|
|
155772
155772
|
if (!_options.assumptionsNames.has(name)) {
|
|
155773
155773
|
throw new Error(`${msg(subLoc)} is not a supported assumption.`);
|
|
155774
155774
|
}
|
|
@@ -225623,7 +225623,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225623
225623
|
throw new Error("Assertion failure: Unknown type " + loc.type);
|
|
225624
225624
|
}
|
|
225625
225625
|
}
|
|
225626
|
-
function
|
|
225626
|
+
function access4(loc, name2) {
|
|
225627
225627
|
return {
|
|
225628
225628
|
type: "access",
|
|
225629
225629
|
name: name2,
|
|
@@ -225662,7 +225662,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225662
225662
|
}
|
|
225663
225663
|
for (var _i3 = 0, _Object$keys = Object.keys(obj);_i3 < _Object$keys.length; _i3++) {
|
|
225664
225664
|
var prop2 = _Object$keys[_i3];
|
|
225665
|
-
var propLoc =
|
|
225665
|
+
var propLoc = access4(loc, prop2);
|
|
225666
225666
|
var _value = obj[prop2];
|
|
225667
225667
|
if (_value != null && typeof _value !== "boolean" && typeof _value !== "string" && typeof _value !== "number") {
|
|
225668
225668
|
throw new Error(msg(propLoc) + " must be null, undefined, a boolean, a string, or a number.");
|
|
@@ -225710,7 +225710,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225710
225710
|
function assertIgnoreList(loc, value2) {
|
|
225711
225711
|
var arr = assertArray(loc, value2);
|
|
225712
225712
|
arr == null || arr.forEach(function(item, i4) {
|
|
225713
|
-
return assertIgnoreItem(
|
|
225713
|
+
return assertIgnoreItem(access4(loc, i4), item);
|
|
225714
225714
|
});
|
|
225715
225715
|
return arr;
|
|
225716
225716
|
}
|
|
@@ -225727,7 +225727,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225727
225727
|
if (Array.isArray(value2)) {
|
|
225728
225728
|
value2.forEach(function(item, i4) {
|
|
225729
225729
|
if (!checkValidTest(item)) {
|
|
225730
|
-
throw new Error(msg(
|
|
225730
|
+
throw new Error(msg(access4(loc, i4)) + " must be a string/Function/RegExp.");
|
|
225731
225731
|
}
|
|
225732
225732
|
});
|
|
225733
225733
|
} else if (!checkValidTest(value2)) {
|
|
@@ -225751,7 +225751,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225751
225751
|
if (Array.isArray(value2)) {
|
|
225752
225752
|
value2.forEach(function(item, i4) {
|
|
225753
225753
|
if (!checkValidTest(item)) {
|
|
225754
|
-
throw new Error(msg(
|
|
225754
|
+
throw new Error(msg(access4(loc, i4)) + " must be a string/Function/RegExp.");
|
|
225755
225755
|
}
|
|
225756
225756
|
});
|
|
225757
225757
|
} else if (!checkValidTest(value2)) {
|
|
@@ -225763,7 +225763,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225763
225763
|
var arr = assertArray(loc, value2);
|
|
225764
225764
|
if (arr) {
|
|
225765
225765
|
arr.forEach(function(item, i4) {
|
|
225766
|
-
return assertPluginItem(
|
|
225766
|
+
return assertPluginItem(access4(loc, i4), item);
|
|
225767
225767
|
});
|
|
225768
225768
|
}
|
|
225769
225769
|
return arr;
|
|
@@ -225776,17 +225776,17 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225776
225776
|
if (value2.length > 3) {
|
|
225777
225777
|
throw new Error(msg(loc) + " may only be a two-tuple or three-tuple");
|
|
225778
225778
|
}
|
|
225779
|
-
assertPluginTarget(
|
|
225779
|
+
assertPluginTarget(access4(loc, 0), value2[0]);
|
|
225780
225780
|
if (value2.length > 1) {
|
|
225781
225781
|
var opts = value2[1];
|
|
225782
225782
|
if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts) || opts === null)) {
|
|
225783
|
-
throw new Error(msg(
|
|
225783
|
+
throw new Error(msg(access4(loc, 1)) + " must be an object, false, or undefined");
|
|
225784
225784
|
}
|
|
225785
225785
|
}
|
|
225786
225786
|
if (value2.length === 3) {
|
|
225787
225787
|
var _name = value2[2];
|
|
225788
225788
|
if (_name !== undefined && typeof _name !== "string") {
|
|
225789
|
-
throw new Error(msg(
|
|
225789
|
+
throw new Error(msg(access4(loc, 2)) + " must be a string, or undefined");
|
|
225790
225790
|
}
|
|
225791
225791
|
}
|
|
225792
225792
|
} else {
|
|
@@ -225806,14 +225806,14 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225806
225806
|
if (typeof value2 !== "object" || !value2 || Array.isArray(value2)) {
|
|
225807
225807
|
throw new Error(msg(loc) + " must be a string, an array of strings or an object");
|
|
225808
225808
|
}
|
|
225809
|
-
var browsersLoc =
|
|
225810
|
-
var esmodulesLoc =
|
|
225809
|
+
var browsersLoc = access4(loc, "browsers");
|
|
225810
|
+
var esmodulesLoc = access4(loc, "esmodules");
|
|
225811
225811
|
assertBrowsersList(browsersLoc, value2.browsers);
|
|
225812
225812
|
assertBoolean(esmodulesLoc, value2.esmodules);
|
|
225813
225813
|
for (var _i22 = 0, _Object$keys2 = Object.keys(value2);_i22 < _Object$keys2.length; _i22++) {
|
|
225814
225814
|
var key = _Object$keys2[_i22];
|
|
225815
225815
|
var val = value2[key];
|
|
225816
|
-
var subLoc =
|
|
225816
|
+
var subLoc = access4(loc, key);
|
|
225817
225817
|
if (key === "esmodules")
|
|
225818
225818
|
assertBoolean(subLoc, val);
|
|
225819
225819
|
else if (key === "browsers")
|
|
@@ -225851,7 +225851,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
225851
225851
|
var inPreset = root3.source === "preset";
|
|
225852
225852
|
for (var _i3 = 0, _Object$keys3 = Object.keys(value2);_i3 < _Object$keys3.length; _i3++) {
|
|
225853
225853
|
var _name2 = _Object$keys3[_i3];
|
|
225854
|
-
var subLoc =
|
|
225854
|
+
var subLoc = access4(loc, _name2);
|
|
225855
225855
|
if (!assumptionsNames.has(_name2)) {
|
|
225856
225856
|
throw new Error(msg(subLoc) + " is not a supported assumption.");
|
|
225857
225857
|
}
|
|
@@ -226119,7 +226119,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
226119
226119
|
if (obj) {
|
|
226120
226120
|
for (var _i3 = 0, _Object$keys = Object.keys(obj);_i3 < _Object$keys.length; _i3++) {
|
|
226121
226121
|
var envName = _Object$keys[_i3];
|
|
226122
|
-
var env2 = assertObject(
|
|
226122
|
+
var env2 = assertObject(access4(loc, envName), obj[envName]);
|
|
226123
226123
|
if (!env2)
|
|
226124
226124
|
continue;
|
|
226125
226125
|
var envLoc = {
|
|
@@ -226144,7 +226144,7 @@ getting parsed as 6.1, which can lead to unexpected behavior.
|
|
|
226144
226144
|
if (arr) {
|
|
226145
226145
|
for (var _iterator3 = _createForOfIteratorHelperLoose(arr.entries()), _step3;!(_step3 = _iterator3()).done; ) {
|
|
226146
226146
|
var _step$value2 = _slicedToArray(_step3.value, 2), index2 = _step$value2[0], item = _step$value2[1];
|
|
226147
|
-
var objLoc =
|
|
226147
|
+
var objLoc = access4(loc, index2);
|
|
226148
226148
|
var env2 = assertObject(objLoc, item);
|
|
226149
226149
|
if (!env2)
|
|
226150
226150
|
throw new Error(msg(objLoc) + " must be an object");
|
|
@@ -311062,29 +311062,60 @@ function isLeafTag(obj, options) {
|
|
|
311062
311062
|
}
|
|
311063
311063
|
return false;
|
|
311064
311064
|
}
|
|
311065
|
+
function debugLog(...args) {
|
|
311066
|
+
if (DEBUG_ENABLED) {
|
|
311067
|
+
console.log(...args);
|
|
311068
|
+
}
|
|
311069
|
+
}
|
|
311070
|
+
function debugLog2(...args) {
|
|
311071
|
+
if (DEBUG_ENABLED2) {
|
|
311072
|
+
console.log(...args);
|
|
311073
|
+
}
|
|
311074
|
+
}
|
|
311065
311075
|
function initializeParentWorker(bot2) {
|
|
311066
|
-
|
|
311076
|
+
debugLog2("[Main] Initializing bot with worker pool...");
|
|
311067
311077
|
const pool = new WorkerPool;
|
|
311078
|
+
globalWorkerPool = pool;
|
|
311068
311079
|
bot2.handler = async (event3) => {
|
|
311069
|
-
|
|
311080
|
+
debugLog2("[Main] Received event, delegating to worker pool:", event3.type || "unknown");
|
|
311070
311081
|
const workerStats = pool.getWorkerStats();
|
|
311071
|
-
|
|
311082
|
+
debugLog2(`[Main] Pool stats - Total: ${workerStats.total}, Idle: ${workerStats.idle}, Busy: ${workerStats.busy}`);
|
|
311072
311083
|
try {
|
|
311073
311084
|
await pool.executeTask(event3);
|
|
311074
|
-
|
|
311085
|
+
debugLog2("[Main] Event processed successfully by worker");
|
|
311075
311086
|
} catch (error) {
|
|
311076
311087
|
console.error("[Main] Error processing event:", error);
|
|
311077
311088
|
throw error;
|
|
311078
311089
|
}
|
|
311079
311090
|
};
|
|
311080
311091
|
const shutdown = async () => {
|
|
311081
|
-
|
|
311092
|
+
debugLog2("[Main] Shutting down...");
|
|
311082
311093
|
await pool.shutdown();
|
|
311083
311094
|
process.exit(0);
|
|
311084
311095
|
};
|
|
311085
311096
|
process.on("SIGINT", shutdown);
|
|
311086
311097
|
process.on("SIGTERM", shutdown);
|
|
311087
|
-
|
|
311098
|
+
debugLog2("[Main] Bot initialized with worker pool");
|
|
311099
|
+
setInterval(() => {
|
|
311100
|
+
const stats = pool.getWorkerStats();
|
|
311101
|
+
const detailedStats = pool.getStats();
|
|
311102
|
+
console.log(JSON.stringify({
|
|
311103
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
311104
|
+
type: "worker_stats",
|
|
311105
|
+
stats: {
|
|
311106
|
+
total: stats.total,
|
|
311107
|
+
idle: stats.idle,
|
|
311108
|
+
busy: stats.busy,
|
|
311109
|
+
terminated: stats.terminated,
|
|
311110
|
+
queueSize: detailedStats.currentQueueSize
|
|
311111
|
+
}
|
|
311112
|
+
}));
|
|
311113
|
+
}, 2000);
|
|
311114
|
+
}
|
|
311115
|
+
function debugLog3(...args) {
|
|
311116
|
+
if (DEBUG_ENABLED3) {
|
|
311117
|
+
originalLog(...args);
|
|
311118
|
+
}
|
|
311088
311119
|
}
|
|
311089
311120
|
function setupLogRelay() {
|
|
311090
311121
|
if (!parentPort)
|
|
@@ -311096,6 +311127,7 @@ function setupLogRelay() {
|
|
|
311096
311127
|
error: console.error,
|
|
311097
311128
|
debug: console.debug
|
|
311098
311129
|
};
|
|
311130
|
+
originalLog = originalConsole.log;
|
|
311099
311131
|
const createLogRelay = (level) => {
|
|
311100
311132
|
return (...args) => {
|
|
311101
311133
|
parentPort.postMessage({
|
|
@@ -311103,7 +311135,9 @@ function setupLogRelay() {
|
|
|
311103
311135
|
level,
|
|
311104
311136
|
args
|
|
311105
311137
|
});
|
|
311106
|
-
|
|
311138
|
+
if (DEBUG_ENABLED3) {
|
|
311139
|
+
originalConsole[level](...args);
|
|
311140
|
+
}
|
|
311107
311141
|
};
|
|
311108
311142
|
};
|
|
311109
311143
|
console.log = createLogRelay("log");
|
|
@@ -311124,15 +311158,15 @@ function runWorker(bot2) {
|
|
|
311124
311158
|
console.error(`Invalid message received:`, message3);
|
|
311125
311159
|
return;
|
|
311126
311160
|
}
|
|
311127
|
-
|
|
311161
|
+
debugLog3(`[Worker] Received task ${taskId}`);
|
|
311128
311162
|
try {
|
|
311129
311163
|
parentPort.postMessage({
|
|
311130
311164
|
type: "ack",
|
|
311131
311165
|
taskId
|
|
311132
311166
|
});
|
|
311133
|
-
|
|
311167
|
+
debugLog3(`[Worker] Processing event for task ${taskId}...`);
|
|
311134
311168
|
await bot2.handler(event3);
|
|
311135
|
-
|
|
311169
|
+
debugLog3(`[Worker] Task ${taskId} completed successfully`);
|
|
311136
311170
|
parentPort.postMessage({
|
|
311137
311171
|
type: "complete",
|
|
311138
311172
|
taskId
|
|
@@ -311149,7 +311183,7 @@ function runWorker(bot2) {
|
|
|
311149
311183
|
const checkInterval = setInterval(() => {
|
|
311150
311184
|
const timeRemaining = expiryTime - Date.now();
|
|
311151
311185
|
if (timeRemaining <= 0) {
|
|
311152
|
-
|
|
311186
|
+
debugLog3(`[Worker] Lifetime expired, shutting down...`);
|
|
311153
311187
|
clearInterval(checkInterval);
|
|
311154
311188
|
clearInterval(logInterval);
|
|
311155
311189
|
process.exit(0);
|
|
@@ -311162,13 +311196,13 @@ function runWorker(bot2) {
|
|
|
311162
311196
|
}
|
|
311163
311197
|
const minutes = Math.floor(timeRemaining / 60000);
|
|
311164
311198
|
const seconds = Math.floor(timeRemaining % 60000 / 1000);
|
|
311165
|
-
|
|
311199
|
+
debugLog3(`[Worker] Time remaining: ${minutes}m ${seconds}s`);
|
|
311166
311200
|
}, 30000);
|
|
311167
311201
|
process.on("exit", () => {
|
|
311168
311202
|
clearInterval(checkInterval);
|
|
311169
311203
|
clearInterval(logInterval);
|
|
311170
311204
|
});
|
|
311171
|
-
|
|
311205
|
+
debugLog3(`[Worker] Ready to process tasks`);
|
|
311172
311206
|
}
|
|
311173
311207
|
var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3, import_sdk4, import_const, import_sdk5, import_sdk6, import_sdk7, import_sdk8, import_sdk9, import_sdk10, import_sdk11, import_sdk12, import_const2, import_sdk13, import_sdk14, import_sdk15, import_sdk16, import_sdk17, import_sdk18, import_sdk19, import_sdk20, import_sdk21, __create3, __defProp5, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3, __hasOwnProp4, __require2, __esm2 = (fn3, res) => function __init() {
|
|
311174
311208
|
return fn3 && (res = (0, fn3[__getOwnPropNames3(fn3)[0]])(fn3 = 0)), res;
|
|
@@ -313739,7 +313773,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313739
313773
|
events: this.events
|
|
313740
313774
|
};
|
|
313741
313775
|
}
|
|
313742
|
-
}, Primitives3, Action, DataSource2, WORKER_POOL_SIZE = 10, WORKER_LIFETIME_MS, WORKER_MIN_LIFETIME_MS = 30000, WORKER_ACK_TIMEOUT_MS = 5000, WORKER_TASK_TIMEOUT_MS = 120000, WORKER_EXPIRY_CHECK_INTERVAL_MS = 1e4, QUEUE_TIMEOUT_MS = 30000, WorkerPool = class {
|
|
313776
|
+
}, Primitives3, Action, DataSource2, DEBUG_ENABLED, WORKER_POOL_SIZE = 10, WORKER_LIFETIME_MS, WORKER_MIN_LIFETIME_MS = 30000, WORKER_ACK_TIMEOUT_MS = 5000, WORKER_TASK_TIMEOUT_MS = 120000, WORKER_EXPIRY_CHECK_INTERVAL_MS = 1e4, QUEUE_TIMEOUT_MS = 30000, WorkerPool = class {
|
|
313743
313777
|
workers = /* @__PURE__ */ new Map;
|
|
313744
313778
|
roundRobinIndex = 0;
|
|
313745
313779
|
nextWorkerId = 0;
|
|
@@ -313762,11 +313796,11 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313762
313796
|
};
|
|
313763
313797
|
constructor(workerScript) {
|
|
313764
313798
|
this.workerScript = workerScript || path42.join(process.cwd(), ".botpress/dist/index.cjs");
|
|
313765
|
-
|
|
313799
|
+
debugLog("[WorkerPool] Initializing...", this.workerScript, process.cwd());
|
|
313766
313800
|
this.initialize();
|
|
313767
313801
|
}
|
|
313768
313802
|
initialize() {
|
|
313769
|
-
|
|
313803
|
+
debugLog(`[WorkerPool] Initializing pool with ${WORKER_POOL_SIZE} workers`);
|
|
313770
313804
|
for (let i3 = 0;i3 < WORKER_POOL_SIZE; i3++) {
|
|
313771
313805
|
this.createWorker();
|
|
313772
313806
|
}
|
|
@@ -313776,7 +313810,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313776
313810
|
this.expiryCheckInterval = setInterval(() => {
|
|
313777
313811
|
this.checkWorkerExpiry();
|
|
313778
313812
|
}, WORKER_EXPIRY_CHECK_INTERVAL_MS);
|
|
313779
|
-
|
|
313813
|
+
debugLog(`[WorkerPool] Started expiry check (interval: ${WORKER_EXPIRY_CHECK_INTERVAL_MS}ms, threshold: ${WORKER_MIN_LIFETIME_MS}ms)`);
|
|
313780
313814
|
}
|
|
313781
313815
|
checkWorkerExpiry() {
|
|
313782
313816
|
const now2 = Date.now();
|
|
@@ -313786,7 +313820,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313786
313820
|
}
|
|
313787
313821
|
const timeRemaining = workerInfo.expiryTime - now2;
|
|
313788
313822
|
if (timeRemaining <= WORKER_MIN_LIFETIME_MS) {
|
|
313789
|
-
|
|
313823
|
+
debugLog(`[WorkerPool] Proactively replacing worker ${workerId} (${Math.floor(timeRemaining / 1000)}s remaining)`);
|
|
313790
313824
|
this.replaceWorker(workerId);
|
|
313791
313825
|
}
|
|
313792
313826
|
}
|
|
@@ -313795,7 +313829,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313795
313829
|
const workerId = this.nextWorkerId++;
|
|
313796
313830
|
const startTime = Date.now();
|
|
313797
313831
|
const expiryTime = startTime + WORKER_LIFETIME_MS;
|
|
313798
|
-
|
|
313832
|
+
debugLog(`[WorkerPool] Creating worker ${workerId} (expires at ${new Date(expiryTime).toISOString()})`);
|
|
313799
313833
|
const worker = new Worker(this.workerScript, {
|
|
313800
313834
|
env: {
|
|
313801
313835
|
...process.env,
|
|
@@ -313820,10 +313854,10 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313820
313854
|
this.handleWorkerCrash(workerId, error);
|
|
313821
313855
|
});
|
|
313822
313856
|
worker.on("exit", (code) => {
|
|
313823
|
-
|
|
313857
|
+
debugLog(`[WorkerPool] Worker ${workerId} exited with code ${code}`);
|
|
313824
313858
|
const info = this.workers.get(workerId);
|
|
313825
313859
|
if (info && info.status !== "terminated") {
|
|
313826
|
-
|
|
313860
|
+
debugLog(`[WorkerPool] Worker ${workerId} died unexpectedly, respawning...`);
|
|
313827
313861
|
this.handleWorkerCrash(workerId);
|
|
313828
313862
|
}
|
|
313829
313863
|
});
|
|
@@ -313853,11 +313887,11 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313853
313887
|
console.debug(prefix, ...args);
|
|
313854
313888
|
break;
|
|
313855
313889
|
default:
|
|
313856
|
-
|
|
313890
|
+
debugLog(prefix, ...args);
|
|
313857
313891
|
}
|
|
313858
313892
|
break;
|
|
313859
313893
|
case "ack":
|
|
313860
|
-
|
|
313894
|
+
debugLog(`[WorkerPool] Worker ${workerId} acknowledged task ${message3.taskId}`);
|
|
313861
313895
|
const pendingAck = this.pendingTasks.get(message3.taskId);
|
|
313862
313896
|
if (pendingAck?.ackTimer) {
|
|
313863
313897
|
clearTimeout(pendingAck.ackTimer);
|
|
@@ -313871,7 +313905,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313871
313905
|
}
|
|
313872
313906
|
break;
|
|
313873
313907
|
case "complete":
|
|
313874
|
-
|
|
313908
|
+
debugLog(`[WorkerPool] Worker ${workerId} completed task ${message3.taskId}`);
|
|
313875
313909
|
workerInfo.status = "idle";
|
|
313876
313910
|
workerInfo.currentTaskId = undefined;
|
|
313877
313911
|
const pendingComplete = this.pendingTasks.get(message3.taskId);
|
|
@@ -313931,7 +313965,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313931
313965
|
}
|
|
313932
313966
|
}
|
|
313933
313967
|
this.workers.delete(workerId);
|
|
313934
|
-
|
|
313968
|
+
debugLog(`[WorkerPool] Spawning replacement worker for ${workerId}`);
|
|
313935
313969
|
this.createWorker();
|
|
313936
313970
|
}
|
|
313937
313971
|
getNextAvailableWorker() {
|
|
@@ -313951,7 +313985,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313951
313985
|
if (workerInfo.status === "idle") {
|
|
313952
313986
|
const timeRemaining = workerInfo.expiryTime - Date.now();
|
|
313953
313987
|
if (timeRemaining < WORKER_MIN_LIFETIME_MS) {
|
|
313954
|
-
|
|
313988
|
+
debugLog(`[WorkerPool] Worker ${workerId} has ${timeRemaining}ms remaining, replacing...`);
|
|
313955
313989
|
this.replaceWorker(workerId);
|
|
313956
313990
|
attempts++;
|
|
313957
313991
|
continue;
|
|
@@ -313966,7 +314000,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313966
314000
|
const workerInfo = this.workers.get(workerId);
|
|
313967
314001
|
if (!workerInfo)
|
|
313968
314002
|
return;
|
|
313969
|
-
|
|
314003
|
+
debugLog(`[WorkerPool] Replacing worker ${workerId}`);
|
|
313970
314004
|
workerInfo.status = "terminated";
|
|
313971
314005
|
this.workers.delete(workerId);
|
|
313972
314006
|
workerInfo.worker.terminate().catch((err) => {
|
|
@@ -313990,11 +314024,11 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
313990
314024
|
}
|
|
313991
314025
|
const queueTime = Date.now() - queued.queuedAt;
|
|
313992
314026
|
this.stats.queueTimes.push(queueTime);
|
|
313993
|
-
|
|
314027
|
+
debugLog(`[WorkerPool] Dequeued task ${queued.taskId} (waited ${queueTime}ms, ${this.requestQueue.length} remaining in queue)`);
|
|
313994
314028
|
this.dispatchToWorker(available.workerId, available.workerInfo, queued.taskId, queued.event, queued.resolve, queued.reject);
|
|
313995
314029
|
}
|
|
313996
314030
|
dispatchToWorker(workerId, workerInfo, taskId, event3, resolve2, reject) {
|
|
313997
|
-
|
|
314031
|
+
debugLog(`[WorkerPool] Assigning task ${taskId} to worker ${workerId}`);
|
|
313998
314032
|
const timing = this.taskTimings.get(taskId);
|
|
313999
314033
|
if (timing) {
|
|
314000
314034
|
timing.dispatchedAt = Date.now();
|
|
@@ -314045,7 +314079,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
314045
314079
|
if (available) {
|
|
314046
314080
|
this.dispatchToWorker(available.workerId, available.workerInfo, taskId, event3, resolve2, reject);
|
|
314047
314081
|
} else {
|
|
314048
|
-
|
|
314082
|
+
debugLog(`[WorkerPool] All workers busy, queueing task ${taskId} (queue size: ${this.requestQueue.length})`);
|
|
314049
314083
|
timing.queuedAt = Date.now();
|
|
314050
314084
|
this.stats.requestsQueued++;
|
|
314051
314085
|
const queueTimeout = setTimeout(() => {
|
|
@@ -314070,7 +314104,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
314070
314104
|
});
|
|
314071
314105
|
}
|
|
314072
314106
|
async shutdown() {
|
|
314073
|
-
|
|
314107
|
+
debugLog(`[WorkerPool] Shutting down pool...`);
|
|
314074
314108
|
if (this.expiryCheckInterval) {
|
|
314075
314109
|
clearInterval(this.expiryCheckInterval);
|
|
314076
314110
|
this.expiryCheckInterval = undefined;
|
|
@@ -314083,7 +314117,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
314083
314117
|
}
|
|
314084
314118
|
this.requestQueue = [];
|
|
314085
314119
|
const terminationPromises = Array.from(this.workers.entries()).map(([workerId, info]) => {
|
|
314086
|
-
|
|
314120
|
+
debugLog(`[WorkerPool] Terminating worker ${workerId}`);
|
|
314087
314121
|
info.status = "terminated";
|
|
314088
314122
|
return info.worker.terminate();
|
|
314089
314123
|
});
|
|
@@ -314091,7 +314125,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
314091
314125
|
this.workers.clear();
|
|
314092
314126
|
this.pendingTasks.clear();
|
|
314093
314127
|
this.taskTimings.clear();
|
|
314094
|
-
|
|
314128
|
+
debugLog(`[WorkerPool] Pool shutdown complete`);
|
|
314095
314129
|
}
|
|
314096
314130
|
getWorkerStats() {
|
|
314097
314131
|
const stats = {
|
|
@@ -314192,7 +314226,7 @@ var import_sdk, import_sdk2, import_sdk3, sdk, import_cognitive3, import_client3
|
|
|
314192
314226
|
return lines.join(`
|
|
314193
314227
|
`);
|
|
314194
314228
|
}
|
|
314195
|
-
}, isWorkerMode = () => {
|
|
314229
|
+
}, DEBUG_ENABLED2, globalWorkerPool = null, DEBUG_ENABLED3, originalLog, isWorkerMode = () => {
|
|
314196
314230
|
const mode = process.env.WORKER_MODE?.trim().toLowerCase();
|
|
314197
314231
|
return mode === "true" || mode === "1" || mode === "yes";
|
|
314198
314232
|
};
|
|
@@ -314252,7 +314286,7 @@ var init_internal = __esm(() => {
|
|
|
314252
314286
|
});
|
|
314253
314287
|
init_define_PACKAGE_VERSIONS = __esm2({
|
|
314254
314288
|
"<define:__PACKAGE_VERSIONS__>"() {
|
|
314255
|
-
define_PACKAGE_VERSIONS_default = { runtime: "1.0
|
|
314289
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.2.0", adk: "not-installed", sdk: "4.16.0", llmz: "0.0.26", zai: "2.1.16", cognitive: "0.1.47" };
|
|
314256
314290
|
}
|
|
314257
314291
|
});
|
|
314258
314292
|
init_globalThis = __esm2({
|
|
@@ -348626,16 +348660,16 @@ ${issues.join(`
|
|
|
348626
348660
|
}
|
|
348627
348661
|
};
|
|
348628
348662
|
import_lodash2 = __toESM3(require_lodash(), 1);
|
|
348629
|
-
((
|
|
348630
|
-
|
|
348631
|
-
|
|
348632
|
-
|
|
348633
|
-
|
|
348634
|
-
|
|
348635
|
-
|
|
348636
|
-
|
|
348637
|
-
|
|
348638
|
-
|
|
348663
|
+
((Autonomous2) => {
|
|
348664
|
+
Autonomous2.Tool = Tool;
|
|
348665
|
+
Autonomous2.Exit = Exit;
|
|
348666
|
+
Autonomous2.Object = ObjectInstance;
|
|
348667
|
+
Autonomous2.ThinkSignal = ThinkSignal;
|
|
348668
|
+
Autonomous2.SnapshotSignal = SnapshotSignal;
|
|
348669
|
+
Autonomous2.CitationsManager = CitationsManager;
|
|
348670
|
+
Autonomous2.ListenExit = ListenExit;
|
|
348671
|
+
Autonomous2.ThinkExit = ThinkExit;
|
|
348672
|
+
Autonomous2.DefaultExit = DefaultExit;
|
|
348639
348673
|
function createKnowledgeSearchTool(knowledgeBases) {
|
|
348640
348674
|
const kbNames = knowledgeBases.map((kb2) => kb2.name);
|
|
348641
348675
|
const description = knowledgeBases.map((kb2) => `- "${kb2.name}": ${kb2.description || "No description"}`).join(`
|
|
@@ -348667,7 +348701,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
348667
348701
|
}
|
|
348668
348702
|
});
|
|
348669
348703
|
if (!passages.length) {
|
|
348670
|
-
throw new
|
|
348704
|
+
throw new Autonomous2.ThinkSignal("No results were found", "No results were found in the knowledge bases. You can try rephrasing your question or asking something else. Do NOT answer the question as no results were found.");
|
|
348671
348705
|
}
|
|
348672
348706
|
const message3 = [
|
|
348673
348707
|
"Here are the search results from the knowledge base that might be relevant, formatted with citations:"
|
|
@@ -348706,7 +348740,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
348706
348740
|
message3.push(p.content);
|
|
348707
348741
|
message3.push(`</${tag}>`);
|
|
348708
348742
|
}
|
|
348709
|
-
throw new
|
|
348743
|
+
throw new Autonomous2.ThinkSignal(`We got the search results. When answering the question, you MUST add inline the citations used (eg: "Yes, the price is $10${example} ...")`, message3.join(`
|
|
348710
348744
|
`).trim());
|
|
348711
348745
|
}
|
|
348712
348746
|
});
|
|
@@ -348906,7 +348940,7 @@ ${iteration.status.execution_error.stack}`;
|
|
|
348906
348940
|
});
|
|
348907
348941
|
};
|
|
348908
348942
|
}
|
|
348909
|
-
|
|
348943
|
+
Autonomous2.createExecute = createExecute;
|
|
348910
348944
|
})(Autonomous || (Autonomous = {}));
|
|
348911
348945
|
actions = new Proxy({}, {
|
|
348912
348946
|
get(_22, propertyName) {
|
|
@@ -350829,9 +350863,13 @@ ${iteration.status.execution_error.stack}`;
|
|
|
350829
350863
|
init_define_PACKAGE_VERSIONS();
|
|
350830
350864
|
init_define_BUILD();
|
|
350831
350865
|
init_define_PACKAGE_VERSIONS();
|
|
350866
|
+
DEBUG_ENABLED = process.env.BP_DEBUG === "true" || process.env.BP_DEBUG === "1";
|
|
350832
350867
|
WORKER_LIFETIME_MS = process.env.WORKER_LIFETIME_MS ? Math.max(parseInt(process.env.WORKER_LIFETIME_MS, 10), 60000) : 300000;
|
|
350868
|
+
DEBUG_ENABLED2 = process.env.BP_DEBUG === "true" || process.env.BP_DEBUG === "1";
|
|
350833
350869
|
init_define_BUILD();
|
|
350834
350870
|
init_define_PACKAGE_VERSIONS();
|
|
350871
|
+
DEBUG_ENABLED3 = process.env.BP_DEBUG === "true" || process.env.BP_DEBUG === "1";
|
|
350872
|
+
originalLog = console.log;
|
|
350835
350873
|
/*! Bundled license information:
|
|
350836
350874
|
|
|
350837
350875
|
lodash/lodash.js:
|
|
@@ -435594,7 +435632,7 @@ async function generateActionTypes(project) {
|
|
|
435594
435632
|
}
|
|
435595
435633
|
try {
|
|
435596
435634
|
const absolutePath = path39.join(project.path, action.path);
|
|
435597
|
-
const actionModule = await import(absolutePath);
|
|
435635
|
+
const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
435598
435636
|
const actionInstance = actionModule[action.export] || actionModule.default;
|
|
435599
435637
|
if (actionInstance && actionInstance.input && actionInstance.output) {
|
|
435600
435638
|
const inputType = actionInstance.input.toTypescriptType ? actionInstance.input.toTypescriptType() : "any";
|
|
@@ -442596,8 +442634,28 @@ var {
|
|
|
442596
442634
|
// src/commands/bp-cli.ts
|
|
442597
442635
|
import path8 from "path";
|
|
442598
442636
|
import { createRequire as createRequire2 } from "module";
|
|
442599
|
-
|
|
442637
|
+
import { access } from "fs/promises";
|
|
442638
|
+
async function findBundledBpPath() {
|
|
442639
|
+
try {
|
|
442640
|
+
const require2 = createRequire2(import.meta.url);
|
|
442641
|
+
try {
|
|
442642
|
+
const cliPackagePath = require2.resolve("@botpress/adk-cli/package.json");
|
|
442643
|
+
const cliDir = path8.dirname(cliPackagePath);
|
|
442644
|
+
const bundledBpPath = path8.join(cliDir, "dist", "bp-cli", "bin.js");
|
|
442645
|
+
await access(bundledBpPath);
|
|
442646
|
+
return bundledBpPath;
|
|
442647
|
+
} catch {}
|
|
442648
|
+
return null;
|
|
442649
|
+
} catch {
|
|
442650
|
+
return null;
|
|
442651
|
+
}
|
|
442652
|
+
}
|
|
442653
|
+
async function findBpPath(projectPath) {
|
|
442600
442654
|
const basePath = projectPath || process.cwd();
|
|
442655
|
+
const bundledPath = await findBundledBpPath();
|
|
442656
|
+
if (bundledPath) {
|
|
442657
|
+
return bundledPath;
|
|
442658
|
+
}
|
|
442601
442659
|
try {
|
|
442602
442660
|
const require2 = createRequire2(path8.join(basePath, "package.json"));
|
|
442603
442661
|
const cliPath = require2.resolve("@botpress/cli/package.json");
|
|
@@ -442616,21 +442674,18 @@ function findBpPath(projectPath) {
|
|
|
442616
442674
|
}
|
|
442617
442675
|
async function getVersionFromPath(bpPath) {
|
|
442618
442676
|
try {
|
|
442619
|
-
const
|
|
442620
|
-
|
|
442621
|
-
|
|
442622
|
-
|
|
442623
|
-
|
|
442624
|
-
} catch {}
|
|
442625
|
-
const { stdout } = await execa(bpPath, ["--version"]);
|
|
442626
|
-
return parseVersion(stdout);
|
|
442677
|
+
const { stdout } = await execa("node", [bpPath, "--version"]);
|
|
442678
|
+
return parseVersion(stdout);
|
|
442679
|
+
} catch {
|
|
442680
|
+
return "unknown";
|
|
442681
|
+
}
|
|
442627
442682
|
}
|
|
442628
442683
|
function parseVersion(versionOutput) {
|
|
442629
442684
|
const match = versionOutput.match(/v?(\d+\.\d+\.\d+)/);
|
|
442630
442685
|
return match?.[1] || "0.0.0";
|
|
442631
442686
|
}
|
|
442632
442687
|
async function getBpCli(projectPath) {
|
|
442633
|
-
const localBpPath = findBpPath(projectPath);
|
|
442688
|
+
const localBpPath = await findBpPath(projectPath);
|
|
442634
442689
|
if (localBpPath) {
|
|
442635
442690
|
const version = await getVersionFromPath(localBpPath);
|
|
442636
442691
|
return {
|
|
@@ -442646,7 +442701,7 @@ async function getBpCli(projectPath) {
|
|
|
442646
442701
|
version
|
|
442647
442702
|
};
|
|
442648
442703
|
} catch {
|
|
442649
|
-
throw new Error("Botpress CLI not found.
|
|
442704
|
+
throw new Error("Botpress CLI not found. This should not happen as @botpress/cli is bundled with the ADK CLI.");
|
|
442650
442705
|
}
|
|
442651
442706
|
}
|
|
442652
442707
|
|
|
@@ -442714,7 +442769,7 @@ class BpAddCommand extends BaseCommand {
|
|
|
442714
442769
|
}
|
|
442715
442770
|
// src/commands/bp-build-command.ts
|
|
442716
442771
|
import { join } from "path";
|
|
442717
|
-
import { access } from "fs/promises";
|
|
442772
|
+
import { access as access2 } from "fs/promises";
|
|
442718
442773
|
|
|
442719
442774
|
// src/utils/source-map-optimizer.ts
|
|
442720
442775
|
import { readFile, writeFile } from "fs/promises";
|
|
@@ -443007,7 +443062,7 @@ class BpBuildCommand extends BaseCommand {
|
|
|
443007
443062
|
const { botPath } = this.options;
|
|
443008
443063
|
const sourceMapPath = join(botPath, ".botpress", "dist", "index.cjs.map");
|
|
443009
443064
|
try {
|
|
443010
|
-
await
|
|
443065
|
+
await access2(sourceMapPath);
|
|
443011
443066
|
const agentSrcPath = join(botPath, "..", "..", "src");
|
|
443012
443067
|
await optimizeSourceMap({
|
|
443013
443068
|
sourceMapPath,
|
|
@@ -443085,7 +443140,7 @@ class BpDeployCommand extends BaseCommand {
|
|
|
443085
443140
|
}
|
|
443086
443141
|
// src/commands/bp-dev-command.ts
|
|
443087
443142
|
import { join as join2 } from "path";
|
|
443088
|
-
import { access as
|
|
443143
|
+
import { access as access3 } from "fs/promises";
|
|
443089
443144
|
class BpDevCommand extends BaseCommand {
|
|
443090
443145
|
options;
|
|
443091
443146
|
childProcess = null;
|
|
@@ -443273,11 +443328,12 @@ ${this.stderrLines.join(`
|
|
|
443273
443328
|
}
|
|
443274
443329
|
const listeningMatch = text.match(/listening\s+on\s+port\s+(\d+)/i);
|
|
443275
443330
|
if (listeningMatch && listeningMatch[1]) {
|
|
443331
|
+
const port = parseInt(listeningMatch[1], 10);
|
|
443276
443332
|
const event2 = {
|
|
443277
443333
|
type: "listening",
|
|
443278
443334
|
startTime: now,
|
|
443279
443335
|
data: {
|
|
443280
|
-
port
|
|
443336
|
+
port
|
|
443281
443337
|
}
|
|
443282
443338
|
};
|
|
443283
443339
|
this.progressEvents.set("listening", event2);
|
|
@@ -443289,7 +443345,7 @@ ${this.stderrLines.join(`
|
|
|
443289
443345
|
const { botPath } = this.options;
|
|
443290
443346
|
const sourceMapPath = join2(botPath, ".botpress", "dist", "index.cjs.map");
|
|
443291
443347
|
try {
|
|
443292
|
-
await
|
|
443348
|
+
await access3(sourceMapPath);
|
|
443293
443349
|
const agentSrcPath = join2(botPath, "..", "..", "src");
|
|
443294
443350
|
await optimizeSourceMap({
|
|
443295
443351
|
sourceMapPath,
|
|
@@ -443317,6 +443373,48 @@ ${this.stderrLines.join(`
|
|
|
443317
443373
|
return Array.from(this.progressEvents.values());
|
|
443318
443374
|
}
|
|
443319
443375
|
}
|
|
443376
|
+
// src/commands/bp-chat-command.ts
|
|
443377
|
+
class BpChatCommand extends BaseCommand {
|
|
443378
|
+
options;
|
|
443379
|
+
childProcess = null;
|
|
443380
|
+
constructor(options) {
|
|
443381
|
+
super();
|
|
443382
|
+
this.options = options;
|
|
443383
|
+
}
|
|
443384
|
+
async run() {
|
|
443385
|
+
const { botId, workspaceId, credentials, projectPath } = this.options;
|
|
443386
|
+
const { path: bpCommand } = await getBpCli(projectPath);
|
|
443387
|
+
const bpArgs = [
|
|
443388
|
+
"chat",
|
|
443389
|
+
"--botId",
|
|
443390
|
+
botId,
|
|
443391
|
+
"--workspaceId",
|
|
443392
|
+
workspaceId,
|
|
443393
|
+
"--token",
|
|
443394
|
+
credentials.token,
|
|
443395
|
+
"--apiUrl",
|
|
443396
|
+
credentials.apiUrl
|
|
443397
|
+
];
|
|
443398
|
+
this.childProcess = execa(bpCommand, bpArgs, {
|
|
443399
|
+
stdio: "inherit"
|
|
443400
|
+
});
|
|
443401
|
+
try {
|
|
443402
|
+
await this.childProcess;
|
|
443403
|
+
} catch (error) {
|
|
443404
|
+
this.emit("error", {
|
|
443405
|
+
exitCode: error.exitCode || 1,
|
|
443406
|
+
stderr: error.stderr || "",
|
|
443407
|
+
message: error.message || "Chat command failed"
|
|
443408
|
+
});
|
|
443409
|
+
throw error;
|
|
443410
|
+
}
|
|
443411
|
+
}
|
|
443412
|
+
kill(signal) {
|
|
443413
|
+
if (this.childProcess) {
|
|
443414
|
+
this.childProcess.kill(signal);
|
|
443415
|
+
}
|
|
443416
|
+
}
|
|
443417
|
+
}
|
|
443320
443418
|
// src/workspace/workspace-cache.ts
|
|
443321
443419
|
var import_client2 = __toESM(require_dist(), 1);
|
|
443322
443420
|
class WorkspaceCache {
|
|
@@ -450018,7 +450116,8 @@ async function expandExports(options) {
|
|
|
450018
450116
|
const { absolutePath, relPath, filename, onWarning } = options;
|
|
450019
450117
|
let result = {};
|
|
450020
450118
|
try {
|
|
450021
|
-
const
|
|
450119
|
+
const importPath = `${absolutePath}?t=${Date.now()}`;
|
|
450120
|
+
const exports = await import(importPath);
|
|
450022
450121
|
if (typeof exports === "object" && exports !== null) {
|
|
450023
450122
|
for (const key of Object.keys(exports)) {
|
|
450024
450123
|
try {
|
|
@@ -450394,7 +450493,8 @@ class AgentProject {
|
|
|
450394
450493
|
}
|
|
450395
450494
|
async loadConfig() {
|
|
450396
450495
|
try {
|
|
450397
|
-
const
|
|
450496
|
+
const configPath = path17.join(this._path, "agent.config.ts");
|
|
450497
|
+
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
450398
450498
|
if (!configModule || !configModule.default) {
|
|
450399
450499
|
this._errors.push({
|
|
450400
450500
|
$type: "ValidationError",
|
|
@@ -451127,7 +451227,7 @@ declare global {
|
|
|
451127
451227
|
await createFile(typesPath, emptyTypesCode);
|
|
451128
451228
|
const emptyRuntimeCode = `
|
|
451129
451229
|
// No assets available
|
|
451130
|
-
import { Asset, initAssets } from '@botpress/runtime
|
|
451230
|
+
import { Asset, initAssets } from '@botpress/runtime';
|
|
451131
451231
|
|
|
451132
451232
|
// Empty asset metadata
|
|
451133
451233
|
export const assetsMetadata: Record<string, Asset> = {};
|
|
@@ -451634,7 +451734,7 @@ async function generateTableTypes(project) {
|
|
|
451634
451734
|
for (const tableRef of project.tables) {
|
|
451635
451735
|
try {
|
|
451636
451736
|
const tablePath = path28.join(project.path, tableRef.path);
|
|
451637
|
-
const tableModule = await import(tablePath);
|
|
451737
|
+
const tableModule = await import(`${tablePath}?t=${Date.now()}`);
|
|
451638
451738
|
const tableInstance = tableModule.default || tableModule[tableRef.export];
|
|
451639
451739
|
if (tableInstance && tableInstance.columns) {
|
|
451640
451740
|
const columns = {};
|
|
@@ -451779,7 +451879,7 @@ async function generateStateTypes(project) {
|
|
|
451779
451879
|
let userStateType = "{}";
|
|
451780
451880
|
try {
|
|
451781
451881
|
const configPath = path30.join(project.path, "agent.config.ts");
|
|
451782
|
-
const configModule = await import(configPath);
|
|
451882
|
+
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
451783
451883
|
const config = configModule.default;
|
|
451784
451884
|
if (config?.bot?.state) {
|
|
451785
451885
|
const botSchema = config.bot.state;
|
|
@@ -451829,7 +451929,7 @@ async function generateWorkflowTypes(project) {
|
|
|
451829
451929
|
continue;
|
|
451830
451930
|
}
|
|
451831
451931
|
const workflowPath = path31.join(project.path, workflowRef.path);
|
|
451832
|
-
const workflowModule = await import(workflowPath);
|
|
451932
|
+
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
451833
451933
|
const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
|
|
451834
451934
|
if (!workflowInstance) {
|
|
451835
451935
|
console.warn(`No default export found in workflow file: ${workflowRef.path}`);
|
|
@@ -452205,8 +452305,9 @@ class InterfaceSync {
|
|
|
452205
452305
|
if (!workspaceId) {
|
|
452206
452306
|
throw new Error('No workspace ID found. Please login with "adk login"');
|
|
452207
452307
|
}
|
|
452308
|
+
const bpCli = await getBpCli(this.projectPath);
|
|
452309
|
+
const command = bpCli.path;
|
|
452208
452310
|
return new Promise((resolve4, reject) => {
|
|
452209
|
-
const command = `bp`;
|
|
452210
452311
|
const args = [
|
|
452211
452312
|
"add",
|
|
452212
452313
|
`interface:${interfaceInfo.fullVersion}`,
|
|
@@ -452456,7 +452557,7 @@ class BotGenerator {
|
|
|
452456
452557
|
let userStateType = "{}";
|
|
452457
452558
|
try {
|
|
452458
452559
|
const configPath = path41.join(project.path, "agent.config.ts");
|
|
452459
|
-
const configModule = await import(configPath);
|
|
452560
|
+
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
452460
452561
|
const config = configModule.default;
|
|
452461
452562
|
if (config?.bot?.state) {
|
|
452462
452563
|
const botSchema = config.bot.state;
|
|
@@ -452654,7 +452755,7 @@ export {};
|
|
|
452654
452755
|
continue;
|
|
452655
452756
|
}
|
|
452656
452757
|
const workflowPath = path41.join(project.path, workflow.path);
|
|
452657
|
-
const workflowModule = await import(workflowPath);
|
|
452758
|
+
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
452658
452759
|
const workflowInstance = workflowModule.default || workflowModule[workflow.export];
|
|
452659
452760
|
if (workflowInstance) {
|
|
452660
452761
|
workflowInstances.push(workflowInstance);
|
|
@@ -453087,7 +453188,7 @@ export {};
|
|
|
453087
453188
|
for (const trigger of project.triggers) {
|
|
453088
453189
|
try {
|
|
453089
453190
|
const absolutePath = path41.join(project.path, trigger.path);
|
|
453090
|
-
const triggerModule = await import(absolutePath);
|
|
453191
|
+
const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
453091
453192
|
const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
|
|
453092
453193
|
if (triggerInstance && triggerInstance.payload) {
|
|
453093
453194
|
const jsonSchema = transforms6.toJSONSchema(triggerInstance.payload);
|
|
@@ -453715,6 +453816,7 @@ export {
|
|
|
453715
453816
|
DevIdManager,
|
|
453716
453817
|
BpDevCommand,
|
|
453717
453818
|
BpDeployCommand,
|
|
453819
|
+
BpChatCommand,
|
|
453718
453820
|
BpBuildCommand,
|
|
453719
453821
|
BpAddCommand,
|
|
453720
453822
|
BotGenerator,
|
|
@@ -453724,5 +453826,5 @@ export {
|
|
|
453724
453826
|
AgentProject
|
|
453725
453827
|
};
|
|
453726
453828
|
|
|
453727
|
-
//# debugId=
|
|
453829
|
+
//# debugId=E37DAEF3719C03FE64756E2164756E21
|
|
453728
453830
|
//# sourceMappingURL=index.js.map
|