@botpress/runtime 1.6.9 → 1.7.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/definition.js +117 -14
- package/dist/definition.js.map +4 -4
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +331 -217
- package/dist/internal.js.map +4 -4
- package/dist/library.js +296 -191
- package/dist/library.js.map +4 -4
- package/dist/primitives/action.d.ts +7 -3
- package/dist/primitives/action.d.ts.map +1 -1
- package/dist/primitives/conversation-instance.d.ts.map +1 -1
- package/dist/primitives/conversation.d.ts +30 -9
- package/dist/primitives/conversation.d.ts.map +1 -1
- package/dist/primitives/table.d.ts +11 -7
- package/dist/primitives/table.d.ts.map +1 -1
- package/dist/primitives/workflow.d.ts +18 -0
- package/dist/primitives/workflow.d.ts.map +1 -1
- package/dist/runtime/actions/computed-columns.d.ts +42 -0
- package/dist/runtime/actions/computed-columns.d.ts.map +1 -0
- package/dist/runtime/actions/index.d.ts +47 -0
- package/dist/runtime/actions/index.d.ts.map +1 -0
- package/dist/runtime/adk.d.ts.map +1 -1
- package/dist/runtime/context/http.d.ts +1 -1
- package/dist/runtime/context/http.d.ts.map +1 -1
- package/dist/runtime/handlers/actions.d.ts +3 -0
- package/dist/runtime/handlers/actions.d.ts.map +1 -0
- package/dist/runtime/handlers/event.d.ts.map +1 -1
- package/dist/runtime/handlers/index.d.ts +2 -0
- package/dist/runtime/handlers/index.d.ts.map +1 -1
- package/dist/runtime.js +207 -70
- package/dist/runtime.js.map +4 -4
- package/dist/telemetry/spans/index.d.ts +0 -52
- package/dist/telemetry/spans/index.d.ts.map +1 -1
- package/dist/ui.js +1 -2
- package/dist/ui.js.map +2 -2
- package/dist/workers/dev_worker.d.ts.map +1 -1
- package/dist/workers/parent_worker.d.ts.map +1 -1
- package/dist/workers/worker_pool.d.ts.map +1 -1
- 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.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.7.0", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.5.0", cognitive: "0.2.0" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -27678,11 +27678,11 @@ function expand_(str, isTop) {
|
|
|
27678
27678
|
if (pad) {
|
|
27679
27679
|
const need = width - c.length;
|
|
27680
27680
|
if (need > 0) {
|
|
27681
|
-
const
|
|
27681
|
+
const z26 = new Array(need + 1).join("0");
|
|
27682
27682
|
if (i < 0) {
|
|
27683
|
-
c = "-" +
|
|
27683
|
+
c = "-" + z26 + c.slice(1);
|
|
27684
27684
|
} else {
|
|
27685
|
-
c =
|
|
27685
|
+
c = z26 + c;
|
|
27686
27686
|
}
|
|
27687
27687
|
}
|
|
27688
27688
|
}
|
|
@@ -34305,7 +34305,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
34305
34305
|
// src/primitives/workflow-instance.ts
|
|
34306
34306
|
init_define_BUILD();
|
|
34307
34307
|
init_define_PACKAGE_VERSIONS();
|
|
34308
|
-
import { z as
|
|
34308
|
+
import { z as z19 } from "@botpress/sdk";
|
|
34309
34309
|
import assert2 from "assert";
|
|
34310
34310
|
|
|
34311
34311
|
// src/errors.ts
|
|
@@ -34480,7 +34480,7 @@ ${issues.join("\n")}`;
|
|
|
34480
34480
|
// src/library.ts
|
|
34481
34481
|
init_define_BUILD();
|
|
34482
34482
|
init_define_PACKAGE_VERSIONS();
|
|
34483
|
-
import { z as
|
|
34483
|
+
import { z as z17 } from "@botpress/sdk";
|
|
34484
34484
|
|
|
34485
34485
|
// src/runtime/index.ts
|
|
34486
34486
|
init_define_BUILD();
|
|
@@ -35838,8 +35838,7 @@ var ActionHandlerSpan = {
|
|
|
35838
35838
|
name: "handler.action",
|
|
35839
35839
|
importance: "high",
|
|
35840
35840
|
attributes: {
|
|
35841
|
-
...required("botId"
|
|
35842
|
-
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
35841
|
+
...required("botId"),
|
|
35843
35842
|
"action.name": { type: "string", required: true },
|
|
35844
35843
|
"action.input": { type: "json", required: true }
|
|
35845
35844
|
}
|
|
@@ -36407,7 +36406,7 @@ var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentR
|
|
|
36407
36406
|
// src/runtime/tracked-state.ts
|
|
36408
36407
|
init_define_BUILD();
|
|
36409
36408
|
init_define_PACKAGE_VERSIONS();
|
|
36410
|
-
import { z as
|
|
36409
|
+
import { z as z11 } from "@botpress/sdk";
|
|
36411
36410
|
|
|
36412
36411
|
// ../../node_modules/.bun/axios@1.12.2/node_modules/axios/index.js
|
|
36413
36412
|
init_define_BUILD();
|
|
@@ -40693,7 +40692,7 @@ var actions = new Proxy({}, {
|
|
|
40693
40692
|
const botAction = adk.project.actions.find((a) => a.name === propertyName);
|
|
40694
40693
|
if (botAction) {
|
|
40695
40694
|
const handler = async (input) => {
|
|
40696
|
-
return botAction.handler(input);
|
|
40695
|
+
return await botAction.handler(input);
|
|
40697
40696
|
};
|
|
40698
40697
|
handler.asTool = () => new Autonomous.Tool({
|
|
40699
40698
|
name: botAction.name,
|
|
@@ -41157,6 +41156,40 @@ var BaseWorkflow = class {
|
|
|
41157
41156
|
workflow: res.workflow
|
|
41158
41157
|
});
|
|
41159
41158
|
}
|
|
41159
|
+
/**
|
|
41160
|
+
* Convert this workflow into an Autonomous.Tool that can be used with execute().
|
|
41161
|
+
* Starts the workflow and returns basic information about the workflow instance.
|
|
41162
|
+
*
|
|
41163
|
+
* @param options.description - Optional description override for the tool
|
|
41164
|
+
* @returns An Autonomous.Tool instance
|
|
41165
|
+
*
|
|
41166
|
+
* @example
|
|
41167
|
+
* const tool = MyWorkflow.asTool()
|
|
41168
|
+
*
|
|
41169
|
+
* await execute({
|
|
41170
|
+
* tools: [tool],
|
|
41171
|
+
* instructions: 'Use the workflow when needed'
|
|
41172
|
+
* })
|
|
41173
|
+
*/
|
|
41174
|
+
asTool(options) {
|
|
41175
|
+
const description = options?.description || this.description || `Starts the ${this.name} workflow`;
|
|
41176
|
+
return new Autonomous.Tool({
|
|
41177
|
+
name: this.name,
|
|
41178
|
+
description,
|
|
41179
|
+
input: this._inputSchema,
|
|
41180
|
+
output: z5.object({
|
|
41181
|
+
workflowId: z5.string().describe("The ID of the started workflow"),
|
|
41182
|
+
status: z5.string().describe("The initial status of the workflow")
|
|
41183
|
+
}),
|
|
41184
|
+
handler: async (input) => {
|
|
41185
|
+
const instance = await this.start(input);
|
|
41186
|
+
return {
|
|
41187
|
+
workflowId: instance.id,
|
|
41188
|
+
status: instance.status
|
|
41189
|
+
};
|
|
41190
|
+
}
|
|
41191
|
+
});
|
|
41192
|
+
}
|
|
41160
41193
|
};
|
|
41161
41194
|
|
|
41162
41195
|
// src/runtime/workflows/knowledge-indexing.ts
|
|
@@ -41268,6 +41301,140 @@ var BuiltInWorkflows = {
|
|
|
41268
41301
|
|
|
41269
41302
|
// src/runtime/adk.ts
|
|
41270
41303
|
import { Zai } from "@botpress/zai";
|
|
41304
|
+
|
|
41305
|
+
// src/runtime/actions/index.ts
|
|
41306
|
+
init_define_BUILD();
|
|
41307
|
+
init_define_PACKAGE_VERSIONS();
|
|
41308
|
+
|
|
41309
|
+
// src/runtime/actions/computed-columns.ts
|
|
41310
|
+
init_define_BUILD();
|
|
41311
|
+
init_define_PACKAGE_VERSIONS();
|
|
41312
|
+
import { z as z9 } from "@botpress/sdk";
|
|
41313
|
+
|
|
41314
|
+
// src/primitives/action.ts
|
|
41315
|
+
init_define_BUILD();
|
|
41316
|
+
init_define_PACKAGE_VERSIONS();
|
|
41317
|
+
import { transforms } from "@botpress/sdk";
|
|
41318
|
+
var Typings3;
|
|
41319
|
+
((Typings8) => {
|
|
41320
|
+
Typings8.Primitive = "action";
|
|
41321
|
+
})(Typings3 || (Typings3 = {}));
|
|
41322
|
+
var BaseAction = class {
|
|
41323
|
+
name;
|
|
41324
|
+
title;
|
|
41325
|
+
description;
|
|
41326
|
+
attributes;
|
|
41327
|
+
input;
|
|
41328
|
+
output;
|
|
41329
|
+
cached;
|
|
41330
|
+
handler;
|
|
41331
|
+
constructor(props) {
|
|
41332
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
41333
|
+
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
41334
|
+
}
|
|
41335
|
+
this.name = props.name;
|
|
41336
|
+
if (props.title !== void 0) {
|
|
41337
|
+
this.title = props.title;
|
|
41338
|
+
}
|
|
41339
|
+
if (props.description !== void 0) {
|
|
41340
|
+
this.description = props.description;
|
|
41341
|
+
}
|
|
41342
|
+
if (props.attributes !== void 0) {
|
|
41343
|
+
this.attributes = props.attributes;
|
|
41344
|
+
}
|
|
41345
|
+
this.input = props.input;
|
|
41346
|
+
this.output = props.output;
|
|
41347
|
+
this.cached = props.cached ?? false;
|
|
41348
|
+
this.handler = props.handler;
|
|
41349
|
+
}
|
|
41350
|
+
/** @internal */
|
|
41351
|
+
getDefinition() {
|
|
41352
|
+
const def = {
|
|
41353
|
+
type: "action",
|
|
41354
|
+
name: this.name
|
|
41355
|
+
};
|
|
41356
|
+
if (this.title !== void 0) {
|
|
41357
|
+
def.title = this.title;
|
|
41358
|
+
}
|
|
41359
|
+
if (this.description !== void 0) {
|
|
41360
|
+
def.description = this.description;
|
|
41361
|
+
}
|
|
41362
|
+
if (this.input) {
|
|
41363
|
+
def.input = transforms.toJSONSchema(this.input);
|
|
41364
|
+
}
|
|
41365
|
+
if (this.output) {
|
|
41366
|
+
def.output = transforms.toJSONSchema(this.output);
|
|
41367
|
+
}
|
|
41368
|
+
if (this.cached !== void 0) {
|
|
41369
|
+
def.cached = this.cached;
|
|
41370
|
+
}
|
|
41371
|
+
if (this.attributes !== void 0) {
|
|
41372
|
+
def.attributes = this.attributes;
|
|
41373
|
+
}
|
|
41374
|
+
return def;
|
|
41375
|
+
}
|
|
41376
|
+
/**
|
|
41377
|
+
* Execute the action with input validation and output validation
|
|
41378
|
+
*/
|
|
41379
|
+
async execute({ input, client }) {
|
|
41380
|
+
return await this.handler({ input, client });
|
|
41381
|
+
}
|
|
41382
|
+
};
|
|
41383
|
+
|
|
41384
|
+
// src/runtime/actions/computed-columns.ts
|
|
41385
|
+
var tablesRecomputeRows = new BaseAction({
|
|
41386
|
+
name: "tablesRecomputeRows",
|
|
41387
|
+
// skynet/packages/tables-api/src/services/computed/compute-stale-rows.ts
|
|
41388
|
+
input: z9.object({
|
|
41389
|
+
tableId: z9.string(),
|
|
41390
|
+
botId: z9.string(),
|
|
41391
|
+
schema: z9.any(),
|
|
41392
|
+
requests: z9.array(
|
|
41393
|
+
z9.object({
|
|
41394
|
+
row: z9.record(z9.any()),
|
|
41395
|
+
columnsToRecompute: z9.array(z9.string())
|
|
41396
|
+
})
|
|
41397
|
+
)
|
|
41398
|
+
}),
|
|
41399
|
+
output: z9.object({
|
|
41400
|
+
isFinished: z9.boolean(),
|
|
41401
|
+
rows: z9.array(z9.any())
|
|
41402
|
+
}),
|
|
41403
|
+
handler: async ({ input, client }) => {
|
|
41404
|
+
const { tableId, requests } = input;
|
|
41405
|
+
const { table: remoteTable } = await client._inner.getTable({ table: tableId });
|
|
41406
|
+
const table = adk.project.tables.find((x) => x.name === remoteTable.name);
|
|
41407
|
+
async function computeRow(row, columnsToRecompute) {
|
|
41408
|
+
const newRow = { id: row.id };
|
|
41409
|
+
for (const colName of columnsToRecompute) {
|
|
41410
|
+
const col = table?.columns[colName];
|
|
41411
|
+
if (!col || !col.computed) {
|
|
41412
|
+
newRow[colName] = { status: "error", error: "Column not found or not computed" };
|
|
41413
|
+
continue;
|
|
41414
|
+
}
|
|
41415
|
+
newRow[colName] = {
|
|
41416
|
+
status: "computed",
|
|
41417
|
+
value: await col.value(row)
|
|
41418
|
+
};
|
|
41419
|
+
}
|
|
41420
|
+
return newRow;
|
|
41421
|
+
}
|
|
41422
|
+
const computedRows = await Promise.all(
|
|
41423
|
+
requests.map(async (r) => {
|
|
41424
|
+
const computedRow = await computeRow(r.row, r.columnsToRecompute);
|
|
41425
|
+
return computedRow;
|
|
41426
|
+
})
|
|
41427
|
+
);
|
|
41428
|
+
return { isFinished: true, rows: computedRows };
|
|
41429
|
+
}
|
|
41430
|
+
});
|
|
41431
|
+
|
|
41432
|
+
// src/runtime/actions/index.ts
|
|
41433
|
+
var BuiltInActions = {
|
|
41434
|
+
tablesRecomputeRows
|
|
41435
|
+
};
|
|
41436
|
+
|
|
41437
|
+
// src/runtime/adk.ts
|
|
41271
41438
|
var getState = () => getSingleton("__ADK_GLOBAL_PROJECT", () => {
|
|
41272
41439
|
const state = {
|
|
41273
41440
|
initialized: false,
|
|
@@ -41346,12 +41513,12 @@ var importScheduledHeavyImports = async () => {
|
|
|
41346
41513
|
// src/runtime/tracked-state-schema.ts
|
|
41347
41514
|
init_define_BUILD();
|
|
41348
41515
|
init_define_PACKAGE_VERSIONS();
|
|
41349
|
-
import { z as
|
|
41350
|
-
var TrackedStateSchema =
|
|
41351
|
-
value:
|
|
41352
|
-
location:
|
|
41353
|
-
|
|
41354
|
-
|
|
41516
|
+
import { z as z10 } from "@botpress/sdk";
|
|
41517
|
+
var TrackedStateSchema = z10.object({
|
|
41518
|
+
value: z10.any(),
|
|
41519
|
+
location: z10.discriminatedUnion("type", [
|
|
41520
|
+
z10.object({ type: z10.literal("state") }),
|
|
41521
|
+
z10.object({ type: z10.literal("file"), key: z10.string() })
|
|
41355
41522
|
])
|
|
41356
41523
|
});
|
|
41357
41524
|
|
|
@@ -41448,7 +41615,7 @@ var TrackedState = class _TrackedState {
|
|
|
41448
41615
|
name: BUILT_IN_STATES.bot,
|
|
41449
41616
|
type: "bot",
|
|
41450
41617
|
id: botId,
|
|
41451
|
-
schema: adk.project.config.bot?.state ||
|
|
41618
|
+
schema: adk.project.config.bot?.state || z11.object({})
|
|
41452
41619
|
});
|
|
41453
41620
|
}
|
|
41454
41621
|
if (user2) {
|
|
@@ -41457,7 +41624,7 @@ var TrackedState = class _TrackedState {
|
|
|
41457
41624
|
name: BUILT_IN_STATES.user,
|
|
41458
41625
|
type: "user",
|
|
41459
41626
|
id: user2.id,
|
|
41460
|
-
schema: adk.project.config.user?.state ||
|
|
41627
|
+
schema: adk.project.config.user?.state || z11.object({})
|
|
41461
41628
|
});
|
|
41462
41629
|
}
|
|
41463
41630
|
if (conversation) {
|
|
@@ -41474,7 +41641,7 @@ var TrackedState = class _TrackedState {
|
|
|
41474
41641
|
name: BUILT_IN_STATES.conversation,
|
|
41475
41642
|
type: "conversation",
|
|
41476
41643
|
id: conversation.id,
|
|
41477
|
-
schema: definition?.schema ||
|
|
41644
|
+
schema: definition?.schema || z11.object({})
|
|
41478
41645
|
});
|
|
41479
41646
|
}
|
|
41480
41647
|
const states = context.get("states", { optional: true });
|
|
@@ -41706,48 +41873,48 @@ init_define_PACKAGE_VERSIONS();
|
|
|
41706
41873
|
// src/runtime/events.ts
|
|
41707
41874
|
init_define_BUILD();
|
|
41708
41875
|
init_define_PACKAGE_VERSIONS();
|
|
41709
|
-
import { z as
|
|
41876
|
+
import { z as z12 } from "@botpress/sdk";
|
|
41710
41877
|
var WorkflowCallbackEvent = {
|
|
41711
41878
|
name: "workflowCallback",
|
|
41712
|
-
schema:
|
|
41713
|
-
workflow:
|
|
41714
|
-
workflowId:
|
|
41715
|
-
target:
|
|
41716
|
-
|
|
41717
|
-
conversationId:
|
|
41879
|
+
schema: z12.object({
|
|
41880
|
+
workflow: z12.string(),
|
|
41881
|
+
workflowId: z12.string(),
|
|
41882
|
+
target: z12.union([
|
|
41883
|
+
z12.object({
|
|
41884
|
+
conversationId: z12.string()
|
|
41718
41885
|
}),
|
|
41719
|
-
|
|
41720
|
-
workflowId:
|
|
41886
|
+
z12.object({
|
|
41887
|
+
workflowId: z12.string()
|
|
41721
41888
|
})
|
|
41722
41889
|
]),
|
|
41723
|
-
status:
|
|
41724
|
-
output:
|
|
41725
|
-
error:
|
|
41890
|
+
status: z12.enum(["completed", "failed", "canceled", "timed_out"]),
|
|
41891
|
+
output: z12.any().optional(),
|
|
41892
|
+
error: z12.string().optional()
|
|
41726
41893
|
})
|
|
41727
41894
|
};
|
|
41728
41895
|
var WorkflowScheduleEvent = {
|
|
41729
41896
|
name: "workflowSchedule",
|
|
41730
|
-
schema:
|
|
41731
|
-
workflow:
|
|
41897
|
+
schema: z12.object({
|
|
41898
|
+
workflow: z12.string()
|
|
41732
41899
|
})
|
|
41733
41900
|
};
|
|
41734
41901
|
var WorkflowContinueEvent = {
|
|
41735
41902
|
name: "workflowContinue",
|
|
41736
|
-
schema:
|
|
41903
|
+
schema: z12.object({})
|
|
41737
41904
|
};
|
|
41738
41905
|
var SubworkflowFinished = {
|
|
41739
41906
|
name: "subworkflowFinished",
|
|
41740
|
-
schema:
|
|
41907
|
+
schema: z12.object({})
|
|
41741
41908
|
};
|
|
41742
41909
|
var WorkflowDataRequestEvent2 = {
|
|
41743
41910
|
name: "workflowDataRequest",
|
|
41744
|
-
schema:
|
|
41745
|
-
workflowId:
|
|
41746
|
-
workflowName:
|
|
41747
|
-
stepName:
|
|
41748
|
-
request:
|
|
41749
|
-
message:
|
|
41750
|
-
schema:
|
|
41911
|
+
schema: z12.object({
|
|
41912
|
+
workflowId: z12.string(),
|
|
41913
|
+
workflowName: z12.string(),
|
|
41914
|
+
stepName: z12.string(),
|
|
41915
|
+
request: z12.string(),
|
|
41916
|
+
message: z12.string(),
|
|
41917
|
+
schema: z12.any()
|
|
41751
41918
|
// JSON Schema
|
|
41752
41919
|
})
|
|
41753
41920
|
};
|
|
@@ -41772,7 +41939,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
41772
41939
|
// src/runtime/chat/messages.ts
|
|
41773
41940
|
init_define_BUILD();
|
|
41774
41941
|
init_define_PACKAGE_VERSIONS();
|
|
41775
|
-
import { z as
|
|
41942
|
+
import { z as z13 } from "@bpinternal/zui";
|
|
41776
41943
|
import { isAnyComponent } from "llmz";
|
|
41777
41944
|
|
|
41778
41945
|
// src/runtime/chat/html.ts
|
|
@@ -41910,13 +42077,13 @@ function joinMarkdownChildren(children, stringify3 = (el) => JSON.stringify(el,
|
|
|
41910
42077
|
return [...acc, prev, str];
|
|
41911
42078
|
}, []).join("").trim();
|
|
41912
42079
|
}
|
|
41913
|
-
var Message =
|
|
41914
|
-
__jsx:
|
|
41915
|
-
type:
|
|
41916
|
-
props:
|
|
41917
|
-
type:
|
|
42080
|
+
var Message = z13.object({
|
|
42081
|
+
__jsx: z13.literal(true),
|
|
42082
|
+
type: z13.literal("MESSAGE"),
|
|
42083
|
+
props: z13.object({
|
|
42084
|
+
type: z13.enum(["error", "info", "success", "prompt"]).default("info").catch(() => "info")
|
|
41918
42085
|
}).passthrough(),
|
|
41919
|
-
children:
|
|
42086
|
+
children: z13.array(z13.any()).default([]).transform((children) => {
|
|
41920
42087
|
children = children.map((child) => Array.isArray(child) ? child : [child]).flat();
|
|
41921
42088
|
const text = joinMarkdownChildren(
|
|
41922
42089
|
children.filter((x) => !isAnyComponent(x)).map((x) => rebuildTSXCode(x, false))
|
|
@@ -42098,21 +42265,21 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42098
42265
|
// src/runtime/chat/transcript.ts
|
|
42099
42266
|
init_define_BUILD();
|
|
42100
42267
|
init_define_PACKAGE_VERSIONS();
|
|
42101
|
-
import { z as
|
|
42102
|
-
var AttachmentSchema =
|
|
42103
|
-
type:
|
|
42104
|
-
url:
|
|
42105
|
-
});
|
|
42106
|
-
var TranscriptItemSchema =
|
|
42107
|
-
id:
|
|
42108
|
-
role:
|
|
42109
|
-
name:
|
|
42110
|
-
createdAt:
|
|
42111
|
-
content:
|
|
42112
|
-
attachments:
|
|
42113
|
-
payload:
|
|
42114
|
-
});
|
|
42115
|
-
var TranscriptSchema =
|
|
42268
|
+
import { z as z14 } from "@botpress/sdk";
|
|
42269
|
+
var AttachmentSchema = z14.object({
|
|
42270
|
+
type: z14.literal("image"),
|
|
42271
|
+
url: z14.string()
|
|
42272
|
+
});
|
|
42273
|
+
var TranscriptItemSchema = z14.object({
|
|
42274
|
+
id: z14.string(),
|
|
42275
|
+
role: z14.union([z14.literal("assistant"), z14.literal("user"), z14.literal("event"), z14.literal("summary")]),
|
|
42276
|
+
name: z14.string().optional(),
|
|
42277
|
+
createdAt: z14.string().optional(),
|
|
42278
|
+
content: z14.string().optional(),
|
|
42279
|
+
attachments: z14.array(AttachmentSchema).optional(),
|
|
42280
|
+
payload: z14.unknown().optional()
|
|
42281
|
+
});
|
|
42282
|
+
var TranscriptSchema = z14.array(TranscriptItemSchema);
|
|
42116
42283
|
|
|
42117
42284
|
// src/runtime/handlers/index.ts
|
|
42118
42285
|
init_define_BUILD();
|
|
@@ -42125,7 +42292,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42125
42292
|
// src/primitives/conversation.ts
|
|
42126
42293
|
init_define_BUILD();
|
|
42127
42294
|
init_define_PACKAGE_VERSIONS();
|
|
42128
|
-
import { z as
|
|
42295
|
+
import { z as z15 } from "@botpress/sdk";
|
|
42129
42296
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
42130
42297
|
|
|
42131
42298
|
// src/primitives/conversation-instance.ts
|
|
@@ -42143,7 +42310,7 @@ var BaseConversationInstance = class {
|
|
|
42143
42310
|
TrackedState;
|
|
42144
42311
|
constructor(conversation, client) {
|
|
42145
42312
|
this.id = conversation.id;
|
|
42146
|
-
this.channel = conversation.channel
|
|
42313
|
+
this.channel = `${conversation.integration}.${conversation.channel}`;
|
|
42147
42314
|
this.integration = conversation.integration;
|
|
42148
42315
|
this.tags = conversation.tags;
|
|
42149
42316
|
this.conversation = conversation;
|
|
@@ -42245,10 +42412,10 @@ var BaseConversationInstance = class {
|
|
|
42245
42412
|
|
|
42246
42413
|
// src/primitives/conversation.ts
|
|
42247
42414
|
var ConversationHandler = Symbol.for("conversation.handler");
|
|
42248
|
-
var
|
|
42415
|
+
var Typings4;
|
|
42249
42416
|
((Typings8) => {
|
|
42250
42417
|
Typings8.Primitive = "conversation";
|
|
42251
|
-
})(
|
|
42418
|
+
})(Typings4 || (Typings4 = {}));
|
|
42252
42419
|
var BaseConversation = class {
|
|
42253
42420
|
channel;
|
|
42254
42421
|
/** @internal */
|
|
@@ -42257,7 +42424,7 @@ var BaseConversation = class {
|
|
|
42257
42424
|
#startFromTrigger;
|
|
42258
42425
|
constructor(props) {
|
|
42259
42426
|
this.channel = props.channel;
|
|
42260
|
-
this.schema = props.state ??
|
|
42427
|
+
this.schema = props.state ?? z15.object({}).passthrough();
|
|
42261
42428
|
this.#handler = props.handler;
|
|
42262
42429
|
if (props.startFromTrigger) {
|
|
42263
42430
|
this.#startFromTrigger = props.startFromTrigger;
|
|
@@ -42396,6 +42563,7 @@ var BaseConversation = class {
|
|
|
42396
42563
|
await this.#handler({
|
|
42397
42564
|
type,
|
|
42398
42565
|
message,
|
|
42566
|
+
channel: conversationInstance.channel,
|
|
42399
42567
|
event,
|
|
42400
42568
|
request: requestObject,
|
|
42401
42569
|
conversation: conversationInstance,
|
|
@@ -42456,13 +42624,17 @@ var import_ms2 = __toESM(require_ms(), 1);
|
|
|
42456
42624
|
init_define_BUILD();
|
|
42457
42625
|
init_define_PACKAGE_VERSIONS();
|
|
42458
42626
|
|
|
42627
|
+
// src/runtime/handlers/actions.ts
|
|
42628
|
+
init_define_BUILD();
|
|
42629
|
+
init_define_PACKAGE_VERSIONS();
|
|
42630
|
+
|
|
42459
42631
|
// src/primitives/workflow-step.ts
|
|
42460
42632
|
init_define_BUILD();
|
|
42461
42633
|
init_define_PACKAGE_VERSIONS();
|
|
42462
42634
|
import { ulid } from "ulid";
|
|
42463
42635
|
import assert from "assert";
|
|
42464
42636
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
42465
|
-
import { transforms } from "@botpress/sdk";
|
|
42637
|
+
import { transforms as transforms2 } from "@botpress/sdk";
|
|
42466
42638
|
var DEFAULT_MAX_ATTEMPTS = 5;
|
|
42467
42639
|
var MIN_STEP_REMAINING_TIME_MS = 1e4;
|
|
42468
42640
|
var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
|
|
@@ -42829,7 +43001,7 @@ step.request = async (request, message, stepName) => {
|
|
|
42829
43001
|
stepName: actualStepName,
|
|
42830
43002
|
request,
|
|
42831
43003
|
message,
|
|
42832
|
-
schema:
|
|
43004
|
+
schema: transforms2.toJSONSchema(requestSchema)
|
|
42833
43005
|
}
|
|
42834
43006
|
});
|
|
42835
43007
|
await updateWorkflow({
|
|
@@ -42847,25 +43019,25 @@ step.request = async (request, message, stepName) => {
|
|
|
42847
43019
|
};
|
|
42848
43020
|
|
|
42849
43021
|
// src/primitives/workflow-instance.ts
|
|
42850
|
-
var workflowStepContextSchema =
|
|
42851
|
-
() =>
|
|
42852
|
-
output:
|
|
42853
|
-
attempts:
|
|
42854
|
-
i:
|
|
42855
|
-
startedAt:
|
|
42856
|
-
finishedAt:
|
|
42857
|
-
steps:
|
|
42858
|
-
error:
|
|
42859
|
-
message:
|
|
42860
|
-
failedAt:
|
|
42861
|
-
maxAttemptsReached:
|
|
43022
|
+
var workflowStepContextSchema = z19.lazy(
|
|
43023
|
+
() => z19.object({
|
|
43024
|
+
output: z19.unknown().optional(),
|
|
43025
|
+
attempts: z19.number(),
|
|
43026
|
+
i: z19.number().optional(),
|
|
43027
|
+
startedAt: z19.string(),
|
|
43028
|
+
finishedAt: z19.string().optional(),
|
|
43029
|
+
steps: z19.record(z19.string(), workflowStepContextSchema).optional(),
|
|
43030
|
+
error: z19.object({
|
|
43031
|
+
message: z19.string(),
|
|
43032
|
+
failedAt: z19.string(),
|
|
43033
|
+
maxAttemptsReached: z19.boolean()
|
|
42862
43034
|
}).optional()
|
|
42863
43035
|
})
|
|
42864
43036
|
);
|
|
42865
|
-
var workflowExecutionContextSchema =
|
|
42866
|
-
executionCount:
|
|
42867
|
-
revision:
|
|
42868
|
-
steps:
|
|
43037
|
+
var workflowExecutionContextSchema = z19.object({
|
|
43038
|
+
executionCount: z19.number().default(0),
|
|
43039
|
+
revision: z19.number().default(0),
|
|
43040
|
+
steps: z19.record(z19.string(), workflowStepContextSchema)
|
|
42869
43041
|
}).default({
|
|
42870
43042
|
executionCount: 0,
|
|
42871
43043
|
steps: {}
|
|
@@ -43104,45 +43276,45 @@ function createWorkflowExecutionState(client, workflowId) {
|
|
|
43104
43276
|
// src/primitives/definition.ts
|
|
43105
43277
|
init_define_BUILD();
|
|
43106
43278
|
init_define_PACKAGE_VERSIONS();
|
|
43107
|
-
import { z as
|
|
43279
|
+
import { z as z20 } from "@botpress/sdk";
|
|
43108
43280
|
var Definitions;
|
|
43109
43281
|
((Definitions2) => {
|
|
43110
|
-
const conversationDefinitionSchema =
|
|
43111
|
-
type:
|
|
43112
|
-
channel:
|
|
43113
|
-
|
|
43114
|
-
|
|
43115
|
-
|
|
43282
|
+
const conversationDefinitionSchema = z20.object({
|
|
43283
|
+
type: z20.literal("conversation"),
|
|
43284
|
+
channel: z20.union([
|
|
43285
|
+
z20.string().min(1, "Channel must be a non-empty string").max(255, "Channel must be less than 255 characters").regex(/^(\*|[a-zA-Z0-9._-]+)$/, "Channel must be a valid identifier or glob '*'"),
|
|
43286
|
+
z20.array(
|
|
43287
|
+
z20.string().min(1, "Channel must be a non-empty string").max(255, "Channel must be less than 255 characters").regex(/^[a-zA-Z0-9._-]+$/, "Channel must be a valid identifier")
|
|
43116
43288
|
)
|
|
43117
43289
|
])
|
|
43118
43290
|
});
|
|
43119
|
-
const workflowDefinitionSchema =
|
|
43120
|
-
type:
|
|
43121
|
-
name:
|
|
43291
|
+
const workflowDefinitionSchema = z20.object({
|
|
43292
|
+
type: z20.literal("workflow"),
|
|
43293
|
+
name: z20.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z0-9_-]+$/, "Name must be a valid identifier")
|
|
43122
43294
|
});
|
|
43123
|
-
const knowledgeDefinitionSchema =
|
|
43124
|
-
type:
|
|
43125
|
-
name:
|
|
43295
|
+
const knowledgeDefinitionSchema = z20.object({
|
|
43296
|
+
type: z20.literal("knowledge"),
|
|
43297
|
+
name: z20.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z0-9_-]+$/, "Name must be a valid identifier")
|
|
43126
43298
|
});
|
|
43127
|
-
const triggerDefinitionSchema =
|
|
43128
|
-
type:
|
|
43129
|
-
name:
|
|
43299
|
+
const triggerDefinitionSchema = z20.object({
|
|
43300
|
+
type: z20.literal("trigger"),
|
|
43301
|
+
name: z20.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z0-9_-]+$/, "Name must be a valid identifier")
|
|
43130
43302
|
});
|
|
43131
|
-
const actionDefinitionSchema =
|
|
43132
|
-
type:
|
|
43133
|
-
name:
|
|
43134
|
-
title:
|
|
43135
|
-
description:
|
|
43136
|
-
attributes:
|
|
43137
|
-
input:
|
|
43303
|
+
const actionDefinitionSchema = z20.object({
|
|
43304
|
+
type: z20.literal("action"),
|
|
43305
|
+
name: z20.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z][a-zA-Z0-9]*$/, "Name must be alphanumeric with no special characters"),
|
|
43306
|
+
title: z20.string().optional(),
|
|
43307
|
+
description: z20.string().optional(),
|
|
43308
|
+
attributes: z20.record(z20.string()).optional(),
|
|
43309
|
+
input: z20.any().optional(),
|
|
43138
43310
|
// JSONSchema7
|
|
43139
|
-
output:
|
|
43311
|
+
output: z20.any().optional(),
|
|
43140
43312
|
// JSONSchema7
|
|
43141
|
-
cached:
|
|
43313
|
+
cached: z20.boolean().optional()
|
|
43142
43314
|
});
|
|
43143
|
-
const tableDefinitionSchema =
|
|
43144
|
-
type:
|
|
43145
|
-
name:
|
|
43315
|
+
const tableDefinitionSchema = z20.object({
|
|
43316
|
+
type: z20.literal("table"),
|
|
43317
|
+
name: z20.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(/^[a-zA-Z0-9_-]+$/, "Name must be a valid identifier")
|
|
43146
43318
|
});
|
|
43147
43319
|
function isConversationDefinition(value) {
|
|
43148
43320
|
return conversationDefinitionSchema.safeParse(value).success;
|
|
@@ -43198,7 +43370,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
43198
43370
|
// src/primitives/data-sources/source-table.ts
|
|
43199
43371
|
init_define_BUILD();
|
|
43200
43372
|
init_define_PACKAGE_VERSIONS();
|
|
43201
|
-
import { z as
|
|
43373
|
+
import { z as z21 } from "@botpress/sdk";
|
|
43202
43374
|
var TableSource = class _TableSource extends DataSource {
|
|
43203
43375
|
table;
|
|
43204
43376
|
transformFn;
|
|
@@ -43210,7 +43382,7 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43210
43382
|
get syncWorkflow() {
|
|
43211
43383
|
return createSyncWorkflow({
|
|
43212
43384
|
type: "table",
|
|
43213
|
-
state:
|
|
43385
|
+
state: z21.object({ offset: z21.number().default(0) }),
|
|
43214
43386
|
handler: async () => {
|
|
43215
43387
|
throw new Error("TableSource synchronization not implemented");
|
|
43216
43388
|
}
|
|
@@ -43225,7 +43397,7 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43225
43397
|
// src/primitives/data-sources/source-website.ts
|
|
43226
43398
|
init_define_BUILD();
|
|
43227
43399
|
init_define_PACKAGE_VERSIONS();
|
|
43228
|
-
import { z as
|
|
43400
|
+
import { z as z22 } from "@botpress/sdk";
|
|
43229
43401
|
|
|
43230
43402
|
// ../../node_modules/.bun/fast-xml-parser@5.3.0/node_modules/fast-xml-parser/src/fxp.js
|
|
43231
43403
|
init_define_BUILD();
|
|
@@ -44778,16 +44950,16 @@ async function fetchHtml(url2, options) {
|
|
|
44778
44950
|
}
|
|
44779
44951
|
|
|
44780
44952
|
// src/primitives/data-sources/source-website.ts
|
|
44781
|
-
var State =
|
|
44782
|
-
urls:
|
|
44783
|
-
|
|
44784
|
-
loc:
|
|
44785
|
-
lastmod:
|
|
44786
|
-
changefreq:
|
|
44787
|
-
priority:
|
|
44953
|
+
var State = z22.object({
|
|
44954
|
+
urls: z22.array(
|
|
44955
|
+
z22.object({
|
|
44956
|
+
loc: z22.string(),
|
|
44957
|
+
lastmod: z22.string().optional(),
|
|
44958
|
+
changefreq: z22.string().optional(),
|
|
44959
|
+
priority: z22.string().optional()
|
|
44788
44960
|
})
|
|
44789
44961
|
).default([]),
|
|
44790
|
-
queue:
|
|
44962
|
+
queue: z22.array(z22.object({ url: z22.string(), depth: z22.number() })).default([])
|
|
44791
44963
|
});
|
|
44792
44964
|
var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
44793
44965
|
mode;
|
|
@@ -45282,7 +45454,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45282
45454
|
// src/primitives/data-sources/source-directory.ts
|
|
45283
45455
|
init_define_BUILD();
|
|
45284
45456
|
init_define_PACKAGE_VERSIONS();
|
|
45285
|
-
import { z as
|
|
45457
|
+
import { z as z23 } from "@botpress/sdk";
|
|
45286
45458
|
var DirectorySource = class _DirectorySource extends DataSource {
|
|
45287
45459
|
directoryPath;
|
|
45288
45460
|
filterFn;
|
|
@@ -45294,7 +45466,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45294
45466
|
get syncWorkflow() {
|
|
45295
45467
|
return createSyncWorkflow({
|
|
45296
45468
|
type: "directory",
|
|
45297
|
-
state:
|
|
45469
|
+
state: z23.object({}),
|
|
45298
45470
|
handler: async ({ input, step: step2, client }) => {
|
|
45299
45471
|
if (!adk.environment.isDevelopment()) {
|
|
45300
45472
|
console.log("Directory ingestion is only supported in development environment");
|
|
@@ -45439,10 +45611,10 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45439
45611
|
// src/primitives/knowledge.ts
|
|
45440
45612
|
init_define_BUILD();
|
|
45441
45613
|
init_define_PACKAGE_VERSIONS();
|
|
45442
|
-
var
|
|
45614
|
+
var Typings5;
|
|
45443
45615
|
((Typings8) => {
|
|
45444
45616
|
Typings8.Primitive = "knowledge";
|
|
45445
|
-
})(
|
|
45617
|
+
})(Typings5 || (Typings5 = {}));
|
|
45446
45618
|
var BaseKnowledge = class {
|
|
45447
45619
|
name;
|
|
45448
45620
|
sources;
|
|
@@ -45499,80 +45671,10 @@ var BaseKnowledge = class {
|
|
|
45499
45671
|
}
|
|
45500
45672
|
};
|
|
45501
45673
|
|
|
45502
|
-
// src/primitives/action.ts
|
|
45503
|
-
init_define_BUILD();
|
|
45504
|
-
init_define_PACKAGE_VERSIONS();
|
|
45505
|
-
import { transforms as transforms2 } from "@botpress/sdk";
|
|
45506
|
-
var Typings5;
|
|
45507
|
-
((Typings8) => {
|
|
45508
|
-
Typings8.Primitive = "action";
|
|
45509
|
-
})(Typings5 || (Typings5 = {}));
|
|
45510
|
-
var BaseAction = class {
|
|
45511
|
-
name;
|
|
45512
|
-
title;
|
|
45513
|
-
description;
|
|
45514
|
-
attributes;
|
|
45515
|
-
input;
|
|
45516
|
-
output;
|
|
45517
|
-
cached;
|
|
45518
|
-
handler;
|
|
45519
|
-
constructor(props) {
|
|
45520
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
45521
|
-
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
45522
|
-
}
|
|
45523
|
-
this.name = props.name;
|
|
45524
|
-
if (props.title !== void 0) {
|
|
45525
|
-
this.title = props.title;
|
|
45526
|
-
}
|
|
45527
|
-
if (props.description !== void 0) {
|
|
45528
|
-
this.description = props.description;
|
|
45529
|
-
}
|
|
45530
|
-
if (props.attributes !== void 0) {
|
|
45531
|
-
this.attributes = props.attributes;
|
|
45532
|
-
}
|
|
45533
|
-
this.input = props.input;
|
|
45534
|
-
this.output = props.output;
|
|
45535
|
-
this.cached = props.cached ?? false;
|
|
45536
|
-
this.handler = props.handler;
|
|
45537
|
-
}
|
|
45538
|
-
/** @internal */
|
|
45539
|
-
getDefinition() {
|
|
45540
|
-
const def = {
|
|
45541
|
-
type: "action",
|
|
45542
|
-
name: this.name
|
|
45543
|
-
};
|
|
45544
|
-
if (this.title !== void 0) {
|
|
45545
|
-
def.title = this.title;
|
|
45546
|
-
}
|
|
45547
|
-
if (this.description !== void 0) {
|
|
45548
|
-
def.description = this.description;
|
|
45549
|
-
}
|
|
45550
|
-
if (this.input) {
|
|
45551
|
-
def.input = transforms2.toJSONSchema(this.input);
|
|
45552
|
-
}
|
|
45553
|
-
if (this.output) {
|
|
45554
|
-
def.output = transforms2.toJSONSchema(this.output);
|
|
45555
|
-
}
|
|
45556
|
-
if (this.cached !== void 0) {
|
|
45557
|
-
def.cached = this.cached;
|
|
45558
|
-
}
|
|
45559
|
-
if (this.attributes !== void 0) {
|
|
45560
|
-
def.attributes = this.attributes;
|
|
45561
|
-
}
|
|
45562
|
-
return def;
|
|
45563
|
-
}
|
|
45564
|
-
/**
|
|
45565
|
-
* Execute the action with input validation and output validation
|
|
45566
|
-
*/
|
|
45567
|
-
async execute({ input }) {
|
|
45568
|
-
return this.handler(input);
|
|
45569
|
-
}
|
|
45570
|
-
};
|
|
45571
|
-
|
|
45572
45674
|
// src/primitives/table.ts
|
|
45573
45675
|
init_define_BUILD();
|
|
45574
45676
|
init_define_PACKAGE_VERSIONS();
|
|
45575
|
-
import { transforms as transforms3, z as
|
|
45677
|
+
import { transforms as transforms3, z as z24 } from "@bpinternal/zui";
|
|
45576
45678
|
var Typings6;
|
|
45577
45679
|
((Typings8) => {
|
|
45578
45680
|
Typings8.Primitive = "table";
|
|
@@ -45590,13 +45692,21 @@ var BaseTable = class {
|
|
|
45590
45692
|
return context.get("client");
|
|
45591
45693
|
}
|
|
45592
45694
|
constructor(props) {
|
|
45695
|
+
const tableNameSchema = z24.string().min(1).refine((name) => !z24.string().uuid().safeParse(name).success, "Table name cannot be a UUID").refine(
|
|
45696
|
+
(name) => /^[a-zA-Z_$][a-zA-Z0-9_]{0,29}Table$/.test(name),
|
|
45697
|
+
"Table name must start with a letter/underscore, be 35 chars or less, contain only letters/numbers/underscores, and end with 'Table'"
|
|
45698
|
+
);
|
|
45699
|
+
const validation = tableNameSchema.safeParse(props.name);
|
|
45700
|
+
if (!validation.success) {
|
|
45701
|
+
throw new Errors.InvalidPrimitiveError(`Invalid table name '${props.name}'`, validation.error);
|
|
45702
|
+
}
|
|
45593
45703
|
this.name = props.name;
|
|
45594
45704
|
if (props.description !== void 0) {
|
|
45595
45705
|
this.description = props.description;
|
|
45596
45706
|
}
|
|
45597
45707
|
this.factor = props.factor ?? 1;
|
|
45598
45708
|
this.columns = {};
|
|
45599
|
-
let schema =
|
|
45709
|
+
let schema = z24.object({});
|
|
45600
45710
|
for (const [key, value] of Object.entries(props.columns)) {
|
|
45601
45711
|
const val = value;
|
|
45602
45712
|
if (val && typeof val === "object" && "schema" in val) {
|
|
@@ -45772,16 +45882,16 @@ var BaseTable = class {
|
|
|
45772
45882
|
// src/primitives/trigger.ts
|
|
45773
45883
|
init_define_BUILD();
|
|
45774
45884
|
init_define_PACKAGE_VERSIONS();
|
|
45775
|
-
import { z as
|
|
45885
|
+
import { z as z25 } from "@botpress/sdk";
|
|
45776
45886
|
var Typings7;
|
|
45777
45887
|
((Typings8) => {
|
|
45778
45888
|
Typings8.Primitive = "trigger";
|
|
45779
45889
|
})(Typings7 || (Typings7 = {}));
|
|
45780
|
-
var TriggerSchema =
|
|
45781
|
-
name:
|
|
45782
|
-
description:
|
|
45783
|
-
events:
|
|
45784
|
-
handler:
|
|
45890
|
+
var TriggerSchema = z25.object({
|
|
45891
|
+
name: z25.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(/^[a-zA-Z0-9_]+$/, "Trigger name must contain only alphanumeric characters and underscores"),
|
|
45892
|
+
description: z25.string().max(1024, "Description must be less than 1024 characters").optional(),
|
|
45893
|
+
events: z25.array(z25.string()),
|
|
45894
|
+
handler: z25.function().describe("Handler function for the trigger")
|
|
45785
45895
|
});
|
|
45786
45896
|
var Trigger = class {
|
|
45787
45897
|
name;
|
|
@@ -45814,13 +45924,13 @@ var Primitives;
|
|
|
45814
45924
|
Primitives2.Definitions = Definitions;
|
|
45815
45925
|
Primitives2.BaseConversation = BaseConversation;
|
|
45816
45926
|
Primitives2.BaseConversationInstance = BaseConversationInstance;
|
|
45817
|
-
Primitives2.Conversation =
|
|
45927
|
+
Primitives2.Conversation = Typings4;
|
|
45818
45928
|
Primitives2.BaseKnowledge = BaseKnowledge;
|
|
45819
|
-
Primitives2.Knowledge =
|
|
45929
|
+
Primitives2.Knowledge = Typings5;
|
|
45820
45930
|
Primitives2.BaseWorkflow = BaseWorkflow;
|
|
45821
45931
|
Primitives2.Workflow = Typings;
|
|
45822
45932
|
Primitives2.BaseAction = BaseAction;
|
|
45823
|
-
Primitives2.Action =
|
|
45933
|
+
Primitives2.Action = Typings3;
|
|
45824
45934
|
Primitives2.BaseTable = BaseTable;
|
|
45825
45935
|
Primitives2.Table = Typings6;
|
|
45826
45936
|
Primitives2.BaseTrigger = Trigger;
|
|
@@ -46024,7 +46134,7 @@ var WorkerPool = class {
|
|
|
46024
46134
|
if (pendingComplete) {
|
|
46025
46135
|
if (pendingComplete.taskTimer) clearTimeout(pendingComplete.taskTimer);
|
|
46026
46136
|
if (pendingComplete.ackTimer) clearTimeout(pendingComplete.ackTimer);
|
|
46027
|
-
pendingComplete.resolve(message);
|
|
46137
|
+
pendingComplete.resolve(message.result);
|
|
46028
46138
|
this.pendingTasks.delete(message.taskId);
|
|
46029
46139
|
}
|
|
46030
46140
|
const completeTiming = this.taskTimings.get(message.taskId);
|
|
@@ -46047,7 +46157,8 @@ var WorkerPool = class {
|
|
|
46047
46157
|
if (pendingError) {
|
|
46048
46158
|
if (pendingError.taskTimer) clearTimeout(pendingError.taskTimer);
|
|
46049
46159
|
if (pendingError.ackTimer) clearTimeout(pendingError.ackTimer);
|
|
46050
|
-
|
|
46160
|
+
const rejectionError = new Error(message.error || "Worker task failed");
|
|
46161
|
+
pendingError.reject(rejectionError);
|
|
46051
46162
|
this.pendingTasks.delete(message.taskId);
|
|
46052
46163
|
}
|
|
46053
46164
|
this.taskTimings.delete(message.taskId);
|
|
@@ -46383,8 +46494,9 @@ function initializeParentWorker(bot2) {
|
|
|
46383
46494
|
const workerStats = pool.getWorkerStats();
|
|
46384
46495
|
debugLog2(`[Main] Pool stats - Total: ${workerStats.total}, Idle: ${workerStats.idle}, Busy: ${workerStats.busy}`);
|
|
46385
46496
|
try {
|
|
46386
|
-
await pool.executeTask(event);
|
|
46387
|
-
debugLog2("[Main] Event processed successfully by worker");
|
|
46497
|
+
const result = await pool.executeTask(event);
|
|
46498
|
+
debugLog2("[Main] Event processed successfully by worker, result:", result);
|
|
46499
|
+
return result;
|
|
46388
46500
|
} catch (error) {
|
|
46389
46501
|
console.error("[Main] Error processing event:", error);
|
|
46390
46502
|
throw error;
|
|
@@ -46445,11 +46557,12 @@ function runWorker(bot2) {
|
|
|
46445
46557
|
taskId
|
|
46446
46558
|
});
|
|
46447
46559
|
debugLog3(`[Worker] Processing event for task ${taskId}...`);
|
|
46448
|
-
await bot2.handler(event);
|
|
46560
|
+
const result = await bot2.handler(event);
|
|
46449
46561
|
debugLog3(`[Worker] Task ${taskId} completed successfully`);
|
|
46450
46562
|
parentPort.postMessage({
|
|
46451
46563
|
type: "complete",
|
|
46452
|
-
taskId
|
|
46564
|
+
taskId,
|
|
46565
|
+
result
|
|
46453
46566
|
});
|
|
46454
46567
|
} catch (error) {
|
|
46455
46568
|
console.error(`Error processing task ${taskId}:`, error);
|
|
@@ -46497,6 +46610,7 @@ export {
|
|
|
46497
46610
|
BUILT_IN_STATES,
|
|
46498
46611
|
BaseConversationInstance,
|
|
46499
46612
|
BaseWorkflowInstance,
|
|
46613
|
+
BuiltInActions,
|
|
46500
46614
|
BuiltInWorkflows,
|
|
46501
46615
|
CONFIGURATION_PAYLOAD_HEADER,
|
|
46502
46616
|
CONFIGURATION_TYPE_HEADER,
|