@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/library.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
|
}
|
|
@@ -34293,7 +34293,7 @@ var init_esm9 = __esm({
|
|
|
34293
34293
|
// src/library.ts
|
|
34294
34294
|
init_define_BUILD();
|
|
34295
34295
|
init_define_PACKAGE_VERSIONS();
|
|
34296
|
-
import { z as
|
|
34296
|
+
import { z as z25 } from "@botpress/sdk";
|
|
34297
34297
|
|
|
34298
34298
|
// src/runtime/index.ts
|
|
34299
34299
|
init_define_BUILD();
|
|
@@ -35648,8 +35648,7 @@ var ActionHandlerSpan = {
|
|
|
35648
35648
|
name: "handler.action",
|
|
35649
35649
|
importance: "high",
|
|
35650
35650
|
attributes: {
|
|
35651
|
-
...required("botId"
|
|
35652
|
-
...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
|
|
35651
|
+
...required("botId"),
|
|
35653
35652
|
"action.name": { type: "string", required: true },
|
|
35654
35653
|
"action.input": { type: "json", required: true }
|
|
35655
35654
|
}
|
|
@@ -36210,7 +36209,7 @@ var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentR
|
|
|
36210
36209
|
// src/runtime/tracked-state.ts
|
|
36211
36210
|
init_define_BUILD();
|
|
36212
36211
|
init_define_PACKAGE_VERSIONS();
|
|
36213
|
-
import { z as
|
|
36212
|
+
import { z as z14 } from "@botpress/sdk";
|
|
36214
36213
|
|
|
36215
36214
|
// ../../node_modules/.bun/axios@1.12.2/node_modules/axios/index.js
|
|
36216
36215
|
init_define_BUILD();
|
|
@@ -40496,7 +40495,7 @@ var actions = new Proxy({}, {
|
|
|
40496
40495
|
const botAction = adk.project.actions.find((a) => a.name === propertyName);
|
|
40497
40496
|
if (botAction) {
|
|
40498
40497
|
const handler = async (input) => {
|
|
40499
|
-
return botAction.handler(input);
|
|
40498
|
+
return await botAction.handler(input);
|
|
40500
40499
|
};
|
|
40501
40500
|
handler.asTool = () => new Autonomous.Tool({
|
|
40502
40501
|
name: botAction.name,
|
|
@@ -41882,6 +41881,40 @@ var BaseWorkflow = class {
|
|
|
41882
41881
|
workflow: res.workflow
|
|
41883
41882
|
});
|
|
41884
41883
|
}
|
|
41884
|
+
/**
|
|
41885
|
+
* Convert this workflow into an Autonomous.Tool that can be used with execute().
|
|
41886
|
+
* Starts the workflow and returns basic information about the workflow instance.
|
|
41887
|
+
*
|
|
41888
|
+
* @param options.description - Optional description override for the tool
|
|
41889
|
+
* @returns An Autonomous.Tool instance
|
|
41890
|
+
*
|
|
41891
|
+
* @example
|
|
41892
|
+
* const tool = MyWorkflow.asTool()
|
|
41893
|
+
*
|
|
41894
|
+
* await execute({
|
|
41895
|
+
* tools: [tool],
|
|
41896
|
+
* instructions: 'Use the workflow when needed'
|
|
41897
|
+
* })
|
|
41898
|
+
*/
|
|
41899
|
+
asTool(options) {
|
|
41900
|
+
const description = options?.description || this.description || `Starts the ${this.name} workflow`;
|
|
41901
|
+
return new Autonomous.Tool({
|
|
41902
|
+
name: this.name,
|
|
41903
|
+
description,
|
|
41904
|
+
input: this._inputSchema,
|
|
41905
|
+
output: z8.object({
|
|
41906
|
+
workflowId: z8.string().describe("The ID of the started workflow"),
|
|
41907
|
+
status: z8.string().describe("The initial status of the workflow")
|
|
41908
|
+
}),
|
|
41909
|
+
handler: async (input) => {
|
|
41910
|
+
const instance = await this.start(input);
|
|
41911
|
+
return {
|
|
41912
|
+
workflowId: instance.id,
|
|
41913
|
+
status: instance.status
|
|
41914
|
+
};
|
|
41915
|
+
}
|
|
41916
|
+
});
|
|
41917
|
+
}
|
|
41885
41918
|
};
|
|
41886
41919
|
|
|
41887
41920
|
// src/runtime/workflows/knowledge-indexing.ts
|
|
@@ -41988,6 +42021,135 @@ var KnowledgeIndexingWorkflow = new BaseWorkflow({
|
|
|
41988
42021
|
|
|
41989
42022
|
// src/runtime/adk.ts
|
|
41990
42023
|
import { Zai } from "@botpress/zai";
|
|
42024
|
+
|
|
42025
|
+
// src/runtime/actions/index.ts
|
|
42026
|
+
init_define_BUILD();
|
|
42027
|
+
init_define_PACKAGE_VERSIONS();
|
|
42028
|
+
|
|
42029
|
+
// src/runtime/actions/computed-columns.ts
|
|
42030
|
+
init_define_BUILD();
|
|
42031
|
+
init_define_PACKAGE_VERSIONS();
|
|
42032
|
+
import { z as z12 } from "@botpress/sdk";
|
|
42033
|
+
|
|
42034
|
+
// src/primitives/action.ts
|
|
42035
|
+
init_define_BUILD();
|
|
42036
|
+
init_define_PACKAGE_VERSIONS();
|
|
42037
|
+
import { transforms as transforms2 } from "@botpress/sdk";
|
|
42038
|
+
var Typings3;
|
|
42039
|
+
((Typings8) => {
|
|
42040
|
+
Typings8.Primitive = "action";
|
|
42041
|
+
})(Typings3 || (Typings3 = {}));
|
|
42042
|
+
var BaseAction = class {
|
|
42043
|
+
name;
|
|
42044
|
+
title;
|
|
42045
|
+
description;
|
|
42046
|
+
attributes;
|
|
42047
|
+
input;
|
|
42048
|
+
output;
|
|
42049
|
+
cached;
|
|
42050
|
+
handler;
|
|
42051
|
+
constructor(props) {
|
|
42052
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
42053
|
+
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
42054
|
+
}
|
|
42055
|
+
this.name = props.name;
|
|
42056
|
+
if (props.title !== void 0) {
|
|
42057
|
+
this.title = props.title;
|
|
42058
|
+
}
|
|
42059
|
+
if (props.description !== void 0) {
|
|
42060
|
+
this.description = props.description;
|
|
42061
|
+
}
|
|
42062
|
+
if (props.attributes !== void 0) {
|
|
42063
|
+
this.attributes = props.attributes;
|
|
42064
|
+
}
|
|
42065
|
+
this.input = props.input;
|
|
42066
|
+
this.output = props.output;
|
|
42067
|
+
this.cached = props.cached ?? false;
|
|
42068
|
+
this.handler = props.handler;
|
|
42069
|
+
}
|
|
42070
|
+
/** @internal */
|
|
42071
|
+
getDefinition() {
|
|
42072
|
+
const def = {
|
|
42073
|
+
type: "action",
|
|
42074
|
+
name: this.name
|
|
42075
|
+
};
|
|
42076
|
+
if (this.title !== void 0) {
|
|
42077
|
+
def.title = this.title;
|
|
42078
|
+
}
|
|
42079
|
+
if (this.description !== void 0) {
|
|
42080
|
+
def.description = this.description;
|
|
42081
|
+
}
|
|
42082
|
+
if (this.input) {
|
|
42083
|
+
def.input = transforms2.toJSONSchema(this.input);
|
|
42084
|
+
}
|
|
42085
|
+
if (this.output) {
|
|
42086
|
+
def.output = transforms2.toJSONSchema(this.output);
|
|
42087
|
+
}
|
|
42088
|
+
if (this.cached !== void 0) {
|
|
42089
|
+
def.cached = this.cached;
|
|
42090
|
+
}
|
|
42091
|
+
if (this.attributes !== void 0) {
|
|
42092
|
+
def.attributes = this.attributes;
|
|
42093
|
+
}
|
|
42094
|
+
return def;
|
|
42095
|
+
}
|
|
42096
|
+
/**
|
|
42097
|
+
* Execute the action with input validation and output validation
|
|
42098
|
+
*/
|
|
42099
|
+
async execute({ input, client }) {
|
|
42100
|
+
return await this.handler({ input, client });
|
|
42101
|
+
}
|
|
42102
|
+
};
|
|
42103
|
+
|
|
42104
|
+
// src/runtime/actions/computed-columns.ts
|
|
42105
|
+
var tablesRecomputeRows = new BaseAction({
|
|
42106
|
+
name: "tablesRecomputeRows",
|
|
42107
|
+
// skynet/packages/tables-api/src/services/computed/compute-stale-rows.ts
|
|
42108
|
+
input: z12.object({
|
|
42109
|
+
tableId: z12.string(),
|
|
42110
|
+
botId: z12.string(),
|
|
42111
|
+
schema: z12.any(),
|
|
42112
|
+
requests: z12.array(
|
|
42113
|
+
z12.object({
|
|
42114
|
+
row: z12.record(z12.any()),
|
|
42115
|
+
columnsToRecompute: z12.array(z12.string())
|
|
42116
|
+
})
|
|
42117
|
+
)
|
|
42118
|
+
}),
|
|
42119
|
+
output: z12.object({
|
|
42120
|
+
isFinished: z12.boolean(),
|
|
42121
|
+
rows: z12.array(z12.any())
|
|
42122
|
+
}),
|
|
42123
|
+
handler: async ({ input, client }) => {
|
|
42124
|
+
const { tableId, requests } = input;
|
|
42125
|
+
const { table: remoteTable } = await client._inner.getTable({ table: tableId });
|
|
42126
|
+
const table = adk.project.tables.find((x) => x.name === remoteTable.name);
|
|
42127
|
+
async function computeRow(row, columnsToRecompute) {
|
|
42128
|
+
const newRow = { id: row.id };
|
|
42129
|
+
for (const colName of columnsToRecompute) {
|
|
42130
|
+
const col = table?.columns[colName];
|
|
42131
|
+
if (!col || !col.computed) {
|
|
42132
|
+
newRow[colName] = { status: "error", error: "Column not found or not computed" };
|
|
42133
|
+
continue;
|
|
42134
|
+
}
|
|
42135
|
+
newRow[colName] = {
|
|
42136
|
+
status: "computed",
|
|
42137
|
+
value: await col.value(row)
|
|
42138
|
+
};
|
|
42139
|
+
}
|
|
42140
|
+
return newRow;
|
|
42141
|
+
}
|
|
42142
|
+
const computedRows = await Promise.all(
|
|
42143
|
+
requests.map(async (r) => {
|
|
42144
|
+
const computedRow = await computeRow(r.row, r.columnsToRecompute);
|
|
42145
|
+
return computedRow;
|
|
42146
|
+
})
|
|
42147
|
+
);
|
|
42148
|
+
return { isFinished: true, rows: computedRows };
|
|
42149
|
+
}
|
|
42150
|
+
});
|
|
42151
|
+
|
|
42152
|
+
// src/runtime/adk.ts
|
|
41991
42153
|
var getState = () => getSingleton("__ADK_GLOBAL_PROJECT", () => {
|
|
41992
42154
|
const state = {
|
|
41993
42155
|
initialized: false,
|
|
@@ -42066,12 +42228,12 @@ var importScheduledHeavyImports = async () => {
|
|
|
42066
42228
|
// src/runtime/tracked-state-schema.ts
|
|
42067
42229
|
init_define_BUILD();
|
|
42068
42230
|
init_define_PACKAGE_VERSIONS();
|
|
42069
|
-
import { z as
|
|
42070
|
-
var TrackedStateSchema =
|
|
42071
|
-
value:
|
|
42072
|
-
location:
|
|
42073
|
-
|
|
42074
|
-
|
|
42231
|
+
import { z as z13 } from "@botpress/sdk";
|
|
42232
|
+
var TrackedStateSchema = z13.object({
|
|
42233
|
+
value: z13.any(),
|
|
42234
|
+
location: z13.discriminatedUnion("type", [
|
|
42235
|
+
z13.object({ type: z13.literal("state") }),
|
|
42236
|
+
z13.object({ type: z13.literal("file"), key: z13.string() })
|
|
42075
42237
|
])
|
|
42076
42238
|
});
|
|
42077
42239
|
|
|
@@ -42168,7 +42330,7 @@ var TrackedState = class _TrackedState {
|
|
|
42168
42330
|
name: BUILT_IN_STATES.bot,
|
|
42169
42331
|
type: "bot",
|
|
42170
42332
|
id: botId,
|
|
42171
|
-
schema: adk.project.config.bot?.state ||
|
|
42333
|
+
schema: adk.project.config.bot?.state || z14.object({})
|
|
42172
42334
|
});
|
|
42173
42335
|
}
|
|
42174
42336
|
if (user2) {
|
|
@@ -42177,7 +42339,7 @@ var TrackedState = class _TrackedState {
|
|
|
42177
42339
|
name: BUILT_IN_STATES.user,
|
|
42178
42340
|
type: "user",
|
|
42179
42341
|
id: user2.id,
|
|
42180
|
-
schema: adk.project.config.user?.state ||
|
|
42342
|
+
schema: adk.project.config.user?.state || z14.object({})
|
|
42181
42343
|
});
|
|
42182
42344
|
}
|
|
42183
42345
|
if (conversation) {
|
|
@@ -42194,7 +42356,7 @@ var TrackedState = class _TrackedState {
|
|
|
42194
42356
|
name: BUILT_IN_STATES.conversation,
|
|
42195
42357
|
type: "conversation",
|
|
42196
42358
|
id: conversation.id,
|
|
42197
|
-
schema: definition?.schema ||
|
|
42359
|
+
schema: definition?.schema || z14.object({})
|
|
42198
42360
|
});
|
|
42199
42361
|
}
|
|
42200
42362
|
const states = context.get("states", { optional: true });
|
|
@@ -42426,48 +42588,48 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42426
42588
|
// src/runtime/events.ts
|
|
42427
42589
|
init_define_BUILD();
|
|
42428
42590
|
init_define_PACKAGE_VERSIONS();
|
|
42429
|
-
import { z as
|
|
42591
|
+
import { z as z15 } from "@botpress/sdk";
|
|
42430
42592
|
var WorkflowCallbackEvent = {
|
|
42431
42593
|
name: "workflowCallback",
|
|
42432
|
-
schema:
|
|
42433
|
-
workflow:
|
|
42434
|
-
workflowId:
|
|
42435
|
-
target:
|
|
42436
|
-
|
|
42437
|
-
conversationId:
|
|
42594
|
+
schema: z15.object({
|
|
42595
|
+
workflow: z15.string(),
|
|
42596
|
+
workflowId: z15.string(),
|
|
42597
|
+
target: z15.union([
|
|
42598
|
+
z15.object({
|
|
42599
|
+
conversationId: z15.string()
|
|
42438
42600
|
}),
|
|
42439
|
-
|
|
42440
|
-
workflowId:
|
|
42601
|
+
z15.object({
|
|
42602
|
+
workflowId: z15.string()
|
|
42441
42603
|
})
|
|
42442
42604
|
]),
|
|
42443
|
-
status:
|
|
42444
|
-
output:
|
|
42445
|
-
error:
|
|
42605
|
+
status: z15.enum(["completed", "failed", "canceled", "timed_out"]),
|
|
42606
|
+
output: z15.any().optional(),
|
|
42607
|
+
error: z15.string().optional()
|
|
42446
42608
|
})
|
|
42447
42609
|
};
|
|
42448
42610
|
var WorkflowScheduleEvent = {
|
|
42449
42611
|
name: "workflowSchedule",
|
|
42450
|
-
schema:
|
|
42451
|
-
workflow:
|
|
42612
|
+
schema: z15.object({
|
|
42613
|
+
workflow: z15.string()
|
|
42452
42614
|
})
|
|
42453
42615
|
};
|
|
42454
42616
|
var WorkflowContinueEvent = {
|
|
42455
42617
|
name: "workflowContinue",
|
|
42456
|
-
schema:
|
|
42618
|
+
schema: z15.object({})
|
|
42457
42619
|
};
|
|
42458
42620
|
var SubworkflowFinished = {
|
|
42459
42621
|
name: "subworkflowFinished",
|
|
42460
|
-
schema:
|
|
42622
|
+
schema: z15.object({})
|
|
42461
42623
|
};
|
|
42462
42624
|
var WorkflowDataRequestEvent = {
|
|
42463
42625
|
name: "workflowDataRequest",
|
|
42464
|
-
schema:
|
|
42465
|
-
workflowId:
|
|
42466
|
-
workflowName:
|
|
42467
|
-
stepName:
|
|
42468
|
-
request:
|
|
42469
|
-
message:
|
|
42470
|
-
schema:
|
|
42626
|
+
schema: z15.object({
|
|
42627
|
+
workflowId: z15.string(),
|
|
42628
|
+
workflowName: z15.string(),
|
|
42629
|
+
stepName: z15.string(),
|
|
42630
|
+
request: z15.string(),
|
|
42631
|
+
message: z15.string(),
|
|
42632
|
+
schema: z15.any()
|
|
42471
42633
|
// JSON Schema
|
|
42472
42634
|
})
|
|
42473
42635
|
};
|
|
@@ -42492,7 +42654,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42492
42654
|
// src/runtime/chat/messages.ts
|
|
42493
42655
|
init_define_BUILD();
|
|
42494
42656
|
init_define_PACKAGE_VERSIONS();
|
|
42495
|
-
import { z as
|
|
42657
|
+
import { z as z16 } from "@bpinternal/zui";
|
|
42496
42658
|
import { isAnyComponent } from "llmz";
|
|
42497
42659
|
|
|
42498
42660
|
// src/runtime/chat/html.ts
|
|
@@ -42630,13 +42792,13 @@ function joinMarkdownChildren(children, stringify3 = (el) => JSON.stringify(el,
|
|
|
42630
42792
|
return [...acc, prev, str];
|
|
42631
42793
|
}, []).join("").trim();
|
|
42632
42794
|
}
|
|
42633
|
-
var Message =
|
|
42634
|
-
__jsx:
|
|
42635
|
-
type:
|
|
42636
|
-
props:
|
|
42637
|
-
type:
|
|
42795
|
+
var Message = z16.object({
|
|
42796
|
+
__jsx: z16.literal(true),
|
|
42797
|
+
type: z16.literal("MESSAGE"),
|
|
42798
|
+
props: z16.object({
|
|
42799
|
+
type: z16.enum(["error", "info", "success", "prompt"]).default("info").catch(() => "info")
|
|
42638
42800
|
}).passthrough(),
|
|
42639
|
-
children:
|
|
42801
|
+
children: z16.array(z16.any()).default([]).transform((children) => {
|
|
42640
42802
|
children = children.map((child) => Array.isArray(child) ? child : [child]).flat();
|
|
42641
42803
|
const text = joinMarkdownChildren(
|
|
42642
42804
|
children.filter((x) => !isAnyComponent(x)).map((x) => rebuildTSXCode(x, false))
|
|
@@ -42804,21 +42966,21 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42804
42966
|
// src/runtime/chat/transcript.ts
|
|
42805
42967
|
init_define_BUILD();
|
|
42806
42968
|
init_define_PACKAGE_VERSIONS();
|
|
42807
|
-
import { z as
|
|
42808
|
-
var AttachmentSchema =
|
|
42809
|
-
type:
|
|
42810
|
-
url:
|
|
42969
|
+
import { z as z17 } from "@botpress/sdk";
|
|
42970
|
+
var AttachmentSchema = z17.object({
|
|
42971
|
+
type: z17.literal("image"),
|
|
42972
|
+
url: z17.string()
|
|
42811
42973
|
});
|
|
42812
|
-
var TranscriptItemSchema =
|
|
42813
|
-
id:
|
|
42814
|
-
role:
|
|
42815
|
-
name:
|
|
42816
|
-
createdAt:
|
|
42817
|
-
content:
|
|
42818
|
-
attachments:
|
|
42819
|
-
payload:
|
|
42974
|
+
var TranscriptItemSchema = z17.object({
|
|
42975
|
+
id: z17.string(),
|
|
42976
|
+
role: z17.union([z17.literal("assistant"), z17.literal("user"), z17.literal("event"), z17.literal("summary")]),
|
|
42977
|
+
name: z17.string().optional(),
|
|
42978
|
+
createdAt: z17.string().optional(),
|
|
42979
|
+
content: z17.string().optional(),
|
|
42980
|
+
attachments: z17.array(AttachmentSchema).optional(),
|
|
42981
|
+
payload: z17.unknown().optional()
|
|
42820
42982
|
});
|
|
42821
|
-
var TranscriptSchema =
|
|
42983
|
+
var TranscriptSchema = z17.array(TranscriptItemSchema);
|
|
42822
42984
|
|
|
42823
42985
|
// src/runtime/handlers/index.ts
|
|
42824
42986
|
init_define_BUILD();
|
|
@@ -42831,7 +42993,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
42831
42993
|
// src/primitives/conversation.ts
|
|
42832
42994
|
init_define_BUILD();
|
|
42833
42995
|
init_define_PACKAGE_VERSIONS();
|
|
42834
|
-
import { z as
|
|
42996
|
+
import { z as z18 } from "@botpress/sdk";
|
|
42835
42997
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
42836
42998
|
|
|
42837
42999
|
// src/primitives/conversation-instance.ts
|
|
@@ -42849,7 +43011,7 @@ var BaseConversationInstance = class {
|
|
|
42849
43011
|
TrackedState;
|
|
42850
43012
|
constructor(conversation, client) {
|
|
42851
43013
|
this.id = conversation.id;
|
|
42852
|
-
this.channel = conversation.channel
|
|
43014
|
+
this.channel = `${conversation.integration}.${conversation.channel}`;
|
|
42853
43015
|
this.integration = conversation.integration;
|
|
42854
43016
|
this.tags = conversation.tags;
|
|
42855
43017
|
this.conversation = conversation;
|
|
@@ -42951,10 +43113,10 @@ var BaseConversationInstance = class {
|
|
|
42951
43113
|
|
|
42952
43114
|
// src/primitives/conversation.ts
|
|
42953
43115
|
var ConversationHandler = Symbol.for("conversation.handler");
|
|
42954
|
-
var
|
|
43116
|
+
var Typings4;
|
|
42955
43117
|
((Typings8) => {
|
|
42956
43118
|
Typings8.Primitive = "conversation";
|
|
42957
|
-
})(
|
|
43119
|
+
})(Typings4 || (Typings4 = {}));
|
|
42958
43120
|
var BaseConversation = class {
|
|
42959
43121
|
channel;
|
|
42960
43122
|
/** @internal */
|
|
@@ -42963,7 +43125,7 @@ var BaseConversation = class {
|
|
|
42963
43125
|
#startFromTrigger;
|
|
42964
43126
|
constructor(props) {
|
|
42965
43127
|
this.channel = props.channel;
|
|
42966
|
-
this.schema = props.state ??
|
|
43128
|
+
this.schema = props.state ?? z18.object({}).passthrough();
|
|
42967
43129
|
this.#handler = props.handler;
|
|
42968
43130
|
if (props.startFromTrigger) {
|
|
42969
43131
|
this.#startFromTrigger = props.startFromTrigger;
|
|
@@ -43102,6 +43264,7 @@ var BaseConversation = class {
|
|
|
43102
43264
|
await this.#handler({
|
|
43103
43265
|
type,
|
|
43104
43266
|
message,
|
|
43267
|
+
channel: conversationInstance.channel,
|
|
43105
43268
|
event,
|
|
43106
43269
|
request: requestObject,
|
|
43107
43270
|
conversation: conversationInstance,
|
|
@@ -43136,45 +43299,45 @@ init_define_PACKAGE_VERSIONS();
|
|
|
43136
43299
|
// src/primitives/definition.ts
|
|
43137
43300
|
init_define_BUILD();
|
|
43138
43301
|
init_define_PACKAGE_VERSIONS();
|
|
43139
|
-
import { z as
|
|
43302
|
+
import { z as z19 } from "@botpress/sdk";
|
|
43140
43303
|
var Definitions;
|
|
43141
43304
|
((Definitions2) => {
|
|
43142
|
-
const conversationDefinitionSchema =
|
|
43143
|
-
type:
|
|
43144
|
-
channel:
|
|
43145
|
-
|
|
43146
|
-
|
|
43147
|
-
|
|
43305
|
+
const conversationDefinitionSchema = z19.object({
|
|
43306
|
+
type: z19.literal("conversation"),
|
|
43307
|
+
channel: z19.union([
|
|
43308
|
+
z19.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 '*'"),
|
|
43309
|
+
z19.array(
|
|
43310
|
+
z19.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")
|
|
43148
43311
|
)
|
|
43149
43312
|
])
|
|
43150
43313
|
});
|
|
43151
|
-
const workflowDefinitionSchema =
|
|
43152
|
-
type:
|
|
43153
|
-
name:
|
|
43314
|
+
const workflowDefinitionSchema = z19.object({
|
|
43315
|
+
type: z19.literal("workflow"),
|
|
43316
|
+
name: z19.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")
|
|
43154
43317
|
});
|
|
43155
|
-
const knowledgeDefinitionSchema =
|
|
43156
|
-
type:
|
|
43157
|
-
name:
|
|
43318
|
+
const knowledgeDefinitionSchema = z19.object({
|
|
43319
|
+
type: z19.literal("knowledge"),
|
|
43320
|
+
name: z19.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")
|
|
43158
43321
|
});
|
|
43159
|
-
const triggerDefinitionSchema =
|
|
43160
|
-
type:
|
|
43161
|
-
name:
|
|
43322
|
+
const triggerDefinitionSchema = z19.object({
|
|
43323
|
+
type: z19.literal("trigger"),
|
|
43324
|
+
name: z19.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")
|
|
43162
43325
|
});
|
|
43163
|
-
const actionDefinitionSchema =
|
|
43164
|
-
type:
|
|
43165
|
-
name:
|
|
43166
|
-
title:
|
|
43167
|
-
description:
|
|
43168
|
-
attributes:
|
|
43169
|
-
input:
|
|
43326
|
+
const actionDefinitionSchema = z19.object({
|
|
43327
|
+
type: z19.literal("action"),
|
|
43328
|
+
name: z19.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"),
|
|
43329
|
+
title: z19.string().optional(),
|
|
43330
|
+
description: z19.string().optional(),
|
|
43331
|
+
attributes: z19.record(z19.string()).optional(),
|
|
43332
|
+
input: z19.any().optional(),
|
|
43170
43333
|
// JSONSchema7
|
|
43171
|
-
output:
|
|
43334
|
+
output: z19.any().optional(),
|
|
43172
43335
|
// JSONSchema7
|
|
43173
|
-
cached:
|
|
43336
|
+
cached: z19.boolean().optional()
|
|
43174
43337
|
});
|
|
43175
|
-
const tableDefinitionSchema =
|
|
43176
|
-
type:
|
|
43177
|
-
name:
|
|
43338
|
+
const tableDefinitionSchema = z19.object({
|
|
43339
|
+
type: z19.literal("table"),
|
|
43340
|
+
name: z19.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")
|
|
43178
43341
|
});
|
|
43179
43342
|
function isConversationDefinition(value) {
|
|
43180
43343
|
return conversationDefinitionSchema.safeParse(value).success;
|
|
@@ -43230,7 +43393,7 @@ init_define_PACKAGE_VERSIONS();
|
|
|
43230
43393
|
// src/primitives/data-sources/source-table.ts
|
|
43231
43394
|
init_define_BUILD();
|
|
43232
43395
|
init_define_PACKAGE_VERSIONS();
|
|
43233
|
-
import { z as
|
|
43396
|
+
import { z as z20 } from "@botpress/sdk";
|
|
43234
43397
|
var TableSource = class _TableSource extends DataSource {
|
|
43235
43398
|
table;
|
|
43236
43399
|
transformFn;
|
|
@@ -43242,7 +43405,7 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43242
43405
|
get syncWorkflow() {
|
|
43243
43406
|
return createSyncWorkflow({
|
|
43244
43407
|
type: "table",
|
|
43245
|
-
state:
|
|
43408
|
+
state: z20.object({ offset: z20.number().default(0) }),
|
|
43246
43409
|
handler: async () => {
|
|
43247
43410
|
throw new Error("TableSource synchronization not implemented");
|
|
43248
43411
|
}
|
|
@@ -43257,7 +43420,7 @@ var TableSource = class _TableSource extends DataSource {
|
|
|
43257
43420
|
// src/primitives/data-sources/source-website.ts
|
|
43258
43421
|
init_define_BUILD();
|
|
43259
43422
|
init_define_PACKAGE_VERSIONS();
|
|
43260
|
-
import { z as
|
|
43423
|
+
import { z as z21 } from "@botpress/sdk";
|
|
43261
43424
|
|
|
43262
43425
|
// ../../node_modules/.bun/fast-xml-parser@5.3.0/node_modules/fast-xml-parser/src/fxp.js
|
|
43263
43426
|
init_define_BUILD();
|
|
@@ -44810,16 +44973,16 @@ async function fetchHtml(url2, options) {
|
|
|
44810
44973
|
}
|
|
44811
44974
|
|
|
44812
44975
|
// src/primitives/data-sources/source-website.ts
|
|
44813
|
-
var State =
|
|
44814
|
-
urls:
|
|
44815
|
-
|
|
44816
|
-
loc:
|
|
44817
|
-
lastmod:
|
|
44818
|
-
changefreq:
|
|
44819
|
-
priority:
|
|
44976
|
+
var State = z21.object({
|
|
44977
|
+
urls: z21.array(
|
|
44978
|
+
z21.object({
|
|
44979
|
+
loc: z21.string(),
|
|
44980
|
+
lastmod: z21.string().optional(),
|
|
44981
|
+
changefreq: z21.string().optional(),
|
|
44982
|
+
priority: z21.string().optional()
|
|
44820
44983
|
})
|
|
44821
44984
|
).default([]),
|
|
44822
|
-
queue:
|
|
44985
|
+
queue: z21.array(z21.object({ url: z21.string(), depth: z21.number() })).default([])
|
|
44823
44986
|
});
|
|
44824
44987
|
var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
44825
44988
|
mode;
|
|
@@ -45314,7 +45477,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
|
|
|
45314
45477
|
// src/primitives/data-sources/source-directory.ts
|
|
45315
45478
|
init_define_BUILD();
|
|
45316
45479
|
init_define_PACKAGE_VERSIONS();
|
|
45317
|
-
import { z as
|
|
45480
|
+
import { z as z22 } from "@botpress/sdk";
|
|
45318
45481
|
var DirectorySource = class _DirectorySource extends DataSource {
|
|
45319
45482
|
directoryPath;
|
|
45320
45483
|
filterFn;
|
|
@@ -45326,7 +45489,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45326
45489
|
get syncWorkflow() {
|
|
45327
45490
|
return createSyncWorkflow({
|
|
45328
45491
|
type: "directory",
|
|
45329
|
-
state:
|
|
45492
|
+
state: z22.object({}),
|
|
45330
45493
|
handler: async ({ input, step: step2, client }) => {
|
|
45331
45494
|
if (!adk.environment.isDevelopment()) {
|
|
45332
45495
|
console.log("Directory ingestion is only supported in development environment");
|
|
@@ -45471,10 +45634,10 @@ var DirectorySource = class _DirectorySource extends DataSource {
|
|
|
45471
45634
|
// src/primitives/knowledge.ts
|
|
45472
45635
|
init_define_BUILD();
|
|
45473
45636
|
init_define_PACKAGE_VERSIONS();
|
|
45474
|
-
var
|
|
45637
|
+
var Typings5;
|
|
45475
45638
|
((Typings8) => {
|
|
45476
45639
|
Typings8.Primitive = "knowledge";
|
|
45477
|
-
})(
|
|
45640
|
+
})(Typings5 || (Typings5 = {}));
|
|
45478
45641
|
var BaseKnowledge = class {
|
|
45479
45642
|
name;
|
|
45480
45643
|
sources;
|
|
@@ -45531,80 +45694,10 @@ var BaseKnowledge = class {
|
|
|
45531
45694
|
}
|
|
45532
45695
|
};
|
|
45533
45696
|
|
|
45534
|
-
// src/primitives/action.ts
|
|
45535
|
-
init_define_BUILD();
|
|
45536
|
-
init_define_PACKAGE_VERSIONS();
|
|
45537
|
-
import { transforms as transforms2 } from "@botpress/sdk";
|
|
45538
|
-
var Typings5;
|
|
45539
|
-
((Typings8) => {
|
|
45540
|
-
Typings8.Primitive = "action";
|
|
45541
|
-
})(Typings5 || (Typings5 = {}));
|
|
45542
|
-
var BaseAction = class {
|
|
45543
|
-
name;
|
|
45544
|
-
title;
|
|
45545
|
-
description;
|
|
45546
|
-
attributes;
|
|
45547
|
-
input;
|
|
45548
|
-
output;
|
|
45549
|
-
cached;
|
|
45550
|
-
handler;
|
|
45551
|
-
constructor(props) {
|
|
45552
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
|
|
45553
|
-
throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
|
|
45554
|
-
}
|
|
45555
|
-
this.name = props.name;
|
|
45556
|
-
if (props.title !== void 0) {
|
|
45557
|
-
this.title = props.title;
|
|
45558
|
-
}
|
|
45559
|
-
if (props.description !== void 0) {
|
|
45560
|
-
this.description = props.description;
|
|
45561
|
-
}
|
|
45562
|
-
if (props.attributes !== void 0) {
|
|
45563
|
-
this.attributes = props.attributes;
|
|
45564
|
-
}
|
|
45565
|
-
this.input = props.input;
|
|
45566
|
-
this.output = props.output;
|
|
45567
|
-
this.cached = props.cached ?? false;
|
|
45568
|
-
this.handler = props.handler;
|
|
45569
|
-
}
|
|
45570
|
-
/** @internal */
|
|
45571
|
-
getDefinition() {
|
|
45572
|
-
const def = {
|
|
45573
|
-
type: "action",
|
|
45574
|
-
name: this.name
|
|
45575
|
-
};
|
|
45576
|
-
if (this.title !== void 0) {
|
|
45577
|
-
def.title = this.title;
|
|
45578
|
-
}
|
|
45579
|
-
if (this.description !== void 0) {
|
|
45580
|
-
def.description = this.description;
|
|
45581
|
-
}
|
|
45582
|
-
if (this.input) {
|
|
45583
|
-
def.input = transforms2.toJSONSchema(this.input);
|
|
45584
|
-
}
|
|
45585
|
-
if (this.output) {
|
|
45586
|
-
def.output = transforms2.toJSONSchema(this.output);
|
|
45587
|
-
}
|
|
45588
|
-
if (this.cached !== void 0) {
|
|
45589
|
-
def.cached = this.cached;
|
|
45590
|
-
}
|
|
45591
|
-
if (this.attributes !== void 0) {
|
|
45592
|
-
def.attributes = this.attributes;
|
|
45593
|
-
}
|
|
45594
|
-
return def;
|
|
45595
|
-
}
|
|
45596
|
-
/**
|
|
45597
|
-
* Execute the action with input validation and output validation
|
|
45598
|
-
*/
|
|
45599
|
-
async execute({ input }) {
|
|
45600
|
-
return this.handler(input);
|
|
45601
|
-
}
|
|
45602
|
-
};
|
|
45603
|
-
|
|
45604
45697
|
// src/primitives/table.ts
|
|
45605
45698
|
init_define_BUILD();
|
|
45606
45699
|
init_define_PACKAGE_VERSIONS();
|
|
45607
|
-
import { transforms as transforms3, z as
|
|
45700
|
+
import { transforms as transforms3, z as z23 } from "@bpinternal/zui";
|
|
45608
45701
|
var Typings6;
|
|
45609
45702
|
((Typings8) => {
|
|
45610
45703
|
Typings8.Primitive = "table";
|
|
@@ -45622,13 +45715,21 @@ var BaseTable = class {
|
|
|
45622
45715
|
return context.get("client");
|
|
45623
45716
|
}
|
|
45624
45717
|
constructor(props) {
|
|
45718
|
+
const tableNameSchema = z23.string().min(1).refine((name) => !z23.string().uuid().safeParse(name).success, "Table name cannot be a UUID").refine(
|
|
45719
|
+
(name) => /^[a-zA-Z_$][a-zA-Z0-9_]{0,29}Table$/.test(name),
|
|
45720
|
+
"Table name must start with a letter/underscore, be 35 chars or less, contain only letters/numbers/underscores, and end with 'Table'"
|
|
45721
|
+
);
|
|
45722
|
+
const validation = tableNameSchema.safeParse(props.name);
|
|
45723
|
+
if (!validation.success) {
|
|
45724
|
+
throw new Errors.InvalidPrimitiveError(`Invalid table name '${props.name}'`, validation.error);
|
|
45725
|
+
}
|
|
45625
45726
|
this.name = props.name;
|
|
45626
45727
|
if (props.description !== void 0) {
|
|
45627
45728
|
this.description = props.description;
|
|
45628
45729
|
}
|
|
45629
45730
|
this.factor = props.factor ?? 1;
|
|
45630
45731
|
this.columns = {};
|
|
45631
|
-
let schema =
|
|
45732
|
+
let schema = z23.object({});
|
|
45632
45733
|
for (const [key, value] of Object.entries(props.columns)) {
|
|
45633
45734
|
const val = value;
|
|
45634
45735
|
if (val && typeof val === "object" && "schema" in val) {
|
|
@@ -45804,16 +45905,16 @@ var BaseTable = class {
|
|
|
45804
45905
|
// src/primitives/trigger.ts
|
|
45805
45906
|
init_define_BUILD();
|
|
45806
45907
|
init_define_PACKAGE_VERSIONS();
|
|
45807
|
-
import { z as
|
|
45908
|
+
import { z as z24 } from "@botpress/sdk";
|
|
45808
45909
|
var Typings7;
|
|
45809
45910
|
((Typings8) => {
|
|
45810
45911
|
Typings8.Primitive = "trigger";
|
|
45811
45912
|
})(Typings7 || (Typings7 = {}));
|
|
45812
|
-
var TriggerSchema =
|
|
45813
|
-
name:
|
|
45814
|
-
description:
|
|
45815
|
-
events:
|
|
45816
|
-
handler:
|
|
45913
|
+
var TriggerSchema = z24.object({
|
|
45914
|
+
name: z24.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"),
|
|
45915
|
+
description: z24.string().max(1024, "Description must be less than 1024 characters").optional(),
|
|
45916
|
+
events: z24.array(z24.string()),
|
|
45917
|
+
handler: z24.function().describe("Handler function for the trigger")
|
|
45817
45918
|
});
|
|
45818
45919
|
var Trigger = class {
|
|
45819
45920
|
name;
|
|
@@ -45846,13 +45947,13 @@ var Primitives;
|
|
|
45846
45947
|
Primitives2.Definitions = Definitions;
|
|
45847
45948
|
Primitives2.BaseConversation = BaseConversation;
|
|
45848
45949
|
Primitives2.BaseConversationInstance = BaseConversationInstance;
|
|
45849
|
-
Primitives2.Conversation =
|
|
45950
|
+
Primitives2.Conversation = Typings4;
|
|
45850
45951
|
Primitives2.BaseKnowledge = BaseKnowledge;
|
|
45851
|
-
Primitives2.Knowledge =
|
|
45952
|
+
Primitives2.Knowledge = Typings5;
|
|
45852
45953
|
Primitives2.BaseWorkflow = BaseWorkflow;
|
|
45853
45954
|
Primitives2.Workflow = Typings;
|
|
45854
45955
|
Primitives2.BaseAction = BaseAction;
|
|
45855
|
-
Primitives2.Action =
|
|
45956
|
+
Primitives2.Action = Typings3;
|
|
45856
45957
|
Primitives2.BaseTable = BaseTable;
|
|
45857
45958
|
Primitives2.Table = Typings6;
|
|
45858
45959
|
Primitives2.BaseTrigger = Trigger;
|
|
@@ -45874,6 +45975,10 @@ var import_ms2 = __toESM(require_ms(), 1);
|
|
|
45874
45975
|
// src/runtime/handlers/event.ts
|
|
45875
45976
|
init_define_BUILD();
|
|
45876
45977
|
init_define_PACKAGE_VERSIONS();
|
|
45978
|
+
|
|
45979
|
+
// src/runtime/handlers/actions.ts
|
|
45980
|
+
init_define_BUILD();
|
|
45981
|
+
init_define_PACKAGE_VERSIONS();
|
|
45877
45982
|
export {
|
|
45878
45983
|
Action,
|
|
45879
45984
|
Autonomous,
|
|
@@ -45893,7 +45998,7 @@ export {
|
|
|
45893
45998
|
defineConfig,
|
|
45894
45999
|
isWorkflowDataRequest,
|
|
45895
46000
|
user,
|
|
45896
|
-
|
|
46001
|
+
z25 as z
|
|
45897
46002
|
};
|
|
45898
46003
|
/*! Bundled license information:
|
|
45899
46004
|
|