@botpress/runtime 1.6.10 → 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.
Files changed (36) hide show
  1. package/dist/definition.js +115 -13
  2. package/dist/definition.js.map +4 -4
  3. package/dist/internal.d.ts +1 -0
  4. package/dist/internal.d.ts.map +1 -1
  5. package/dist/internal.js +329 -216
  6. package/dist/internal.js.map +4 -4
  7. package/dist/library.js +294 -190
  8. package/dist/library.js.map +4 -4
  9. package/dist/primitives/action.d.ts +7 -3
  10. package/dist/primitives/action.d.ts.map +1 -1
  11. package/dist/primitives/table.d.ts +11 -7
  12. package/dist/primitives/table.d.ts.map +1 -1
  13. package/dist/primitives/workflow.d.ts +18 -0
  14. package/dist/primitives/workflow.d.ts.map +1 -1
  15. package/dist/runtime/actions/computed-columns.d.ts +42 -0
  16. package/dist/runtime/actions/computed-columns.d.ts.map +1 -0
  17. package/dist/runtime/actions/index.d.ts +47 -0
  18. package/dist/runtime/actions/index.d.ts.map +1 -0
  19. package/dist/runtime/adk.d.ts.map +1 -1
  20. package/dist/runtime/context/http.d.ts +1 -1
  21. package/dist/runtime/context/http.d.ts.map +1 -1
  22. package/dist/runtime/handlers/actions.d.ts +3 -0
  23. package/dist/runtime/handlers/actions.d.ts.map +1 -0
  24. package/dist/runtime/handlers/event.d.ts.map +1 -1
  25. package/dist/runtime/handlers/index.d.ts +2 -0
  26. package/dist/runtime/handlers/index.d.ts.map +1 -1
  27. package/dist/runtime.js +205 -69
  28. package/dist/runtime.js.map +4 -4
  29. package/dist/telemetry/spans/index.d.ts +0 -52
  30. package/dist/telemetry/spans/index.d.ts.map +1 -1
  31. package/dist/ui.js +1 -2
  32. package/dist/ui.js.map +2 -2
  33. package/dist/workers/dev_worker.d.ts.map +1 -1
  34. package/dist/workers/parent_worker.d.ts.map +1 -1
  35. package/dist/workers/worker_pool.d.ts.map +1 -1
  36. 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.6.10", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.5.0", cognitive: "0.2.0" };
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 z25 = new Array(need + 1).join("0");
27681
+ const z26 = new Array(need + 1).join("0");
27682
27682
  if (i < 0) {
27683
- c = "-" + z25 + c.slice(1);
27683
+ c = "-" + z26 + c.slice(1);
27684
27684
  } else {
27685
- c = z25 + 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 z24 } from "@botpress/sdk";
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", "workflowId", "eventId", "event.type"),
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 z12 } from "@botpress/sdk";
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 z11 } from "@botpress/sdk";
42070
- var TrackedStateSchema = z11.object({
42071
- value: z11.any(),
42072
- location: z11.discriminatedUnion("type", [
42073
- z11.object({ type: z11.literal("state") }),
42074
- z11.object({ type: z11.literal("file"), key: z11.string() })
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 || z12.object({})
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 || z12.object({})
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 || z12.object({})
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 z13 } from "@botpress/sdk";
42591
+ import { z as z15 } from "@botpress/sdk";
42430
42592
  var WorkflowCallbackEvent = {
42431
42593
  name: "workflowCallback",
42432
- schema: z13.object({
42433
- workflow: z13.string(),
42434
- workflowId: z13.string(),
42435
- target: z13.union([
42436
- z13.object({
42437
- conversationId: z13.string()
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
- z13.object({
42440
- workflowId: z13.string()
42601
+ z15.object({
42602
+ workflowId: z15.string()
42441
42603
  })
42442
42604
  ]),
42443
- status: z13.enum(["completed", "failed", "canceled", "timed_out"]),
42444
- output: z13.any().optional(),
42445
- error: z13.string().optional()
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: z13.object({
42451
- workflow: z13.string()
42612
+ schema: z15.object({
42613
+ workflow: z15.string()
42452
42614
  })
42453
42615
  };
42454
42616
  var WorkflowContinueEvent = {
42455
42617
  name: "workflowContinue",
42456
- schema: z13.object({})
42618
+ schema: z15.object({})
42457
42619
  };
42458
42620
  var SubworkflowFinished = {
42459
42621
  name: "subworkflowFinished",
42460
- schema: z13.object({})
42622
+ schema: z15.object({})
42461
42623
  };
42462
42624
  var WorkflowDataRequestEvent = {
42463
42625
  name: "workflowDataRequest",
42464
- schema: z13.object({
42465
- workflowId: z13.string(),
42466
- workflowName: z13.string(),
42467
- stepName: z13.string(),
42468
- request: z13.string(),
42469
- message: z13.string(),
42470
- schema: z13.any()
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 z14 } from "@bpinternal/zui";
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 = z14.object({
42634
- __jsx: z14.literal(true),
42635
- type: z14.literal("MESSAGE"),
42636
- props: z14.object({
42637
- type: z14.enum(["error", "info", "success", "prompt"]).default("info").catch(() => "info")
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: z14.array(z14.any()).default([]).transform((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 z15 } from "@botpress/sdk";
42808
- var AttachmentSchema = z15.object({
42809
- type: z15.literal("image"),
42810
- url: z15.string()
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 = z15.object({
42813
- id: z15.string(),
42814
- role: z15.union([z15.literal("assistant"), z15.literal("user"), z15.literal("event"), z15.literal("summary")]),
42815
- name: z15.string().optional(),
42816
- createdAt: z15.string().optional(),
42817
- content: z15.string().optional(),
42818
- attachments: z15.array(AttachmentSchema).optional(),
42819
- payload: z15.unknown().optional()
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 = z15.array(TranscriptItemSchema);
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 z16 } from "@botpress/sdk";
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
@@ -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 Typings3;
43116
+ var Typings4;
42955
43117
  ((Typings8) => {
42956
43118
  Typings8.Primitive = "conversation";
42957
- })(Typings3 || (Typings3 = {}));
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 ?? z16.object({}).passthrough();
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;
@@ -43137,45 +43299,45 @@ init_define_PACKAGE_VERSIONS();
43137
43299
  // src/primitives/definition.ts
43138
43300
  init_define_BUILD();
43139
43301
  init_define_PACKAGE_VERSIONS();
43140
- import { z as z17 } from "@botpress/sdk";
43302
+ import { z as z19 } from "@botpress/sdk";
43141
43303
  var Definitions;
43142
43304
  ((Definitions2) => {
43143
- const conversationDefinitionSchema = z17.object({
43144
- type: z17.literal("conversation"),
43145
- channel: z17.union([
43146
- z17.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 '*'"),
43147
- z17.array(
43148
- z17.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")
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")
43149
43311
  )
43150
43312
  ])
43151
43313
  });
43152
- const workflowDefinitionSchema = z17.object({
43153
- type: z17.literal("workflow"),
43154
- name: z17.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")
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")
43155
43317
  });
43156
- const knowledgeDefinitionSchema = z17.object({
43157
- type: z17.literal("knowledge"),
43158
- name: z17.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")
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")
43159
43321
  });
43160
- const triggerDefinitionSchema = z17.object({
43161
- type: z17.literal("trigger"),
43162
- name: z17.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")
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")
43163
43325
  });
43164
- const actionDefinitionSchema = z17.object({
43165
- type: z17.literal("action"),
43166
- name: z17.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"),
43167
- title: z17.string().optional(),
43168
- description: z17.string().optional(),
43169
- attributes: z17.record(z17.string()).optional(),
43170
- input: z17.any().optional(),
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(),
43171
43333
  // JSONSchema7
43172
- output: z17.any().optional(),
43334
+ output: z19.any().optional(),
43173
43335
  // JSONSchema7
43174
- cached: z17.boolean().optional()
43336
+ cached: z19.boolean().optional()
43175
43337
  });
43176
- const tableDefinitionSchema = z17.object({
43177
- type: z17.literal("table"),
43178
- name: z17.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")
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")
43179
43341
  });
43180
43342
  function isConversationDefinition(value) {
43181
43343
  return conversationDefinitionSchema.safeParse(value).success;
@@ -43231,7 +43393,7 @@ init_define_PACKAGE_VERSIONS();
43231
43393
  // src/primitives/data-sources/source-table.ts
43232
43394
  init_define_BUILD();
43233
43395
  init_define_PACKAGE_VERSIONS();
43234
- import { z as z18 } from "@botpress/sdk";
43396
+ import { z as z20 } from "@botpress/sdk";
43235
43397
  var TableSource = class _TableSource extends DataSource {
43236
43398
  table;
43237
43399
  transformFn;
@@ -43243,7 +43405,7 @@ var TableSource = class _TableSource extends DataSource {
43243
43405
  get syncWorkflow() {
43244
43406
  return createSyncWorkflow({
43245
43407
  type: "table",
43246
- state: z18.object({ offset: z18.number().default(0) }),
43408
+ state: z20.object({ offset: z20.number().default(0) }),
43247
43409
  handler: async () => {
43248
43410
  throw new Error("TableSource synchronization not implemented");
43249
43411
  }
@@ -43258,7 +43420,7 @@ var TableSource = class _TableSource extends DataSource {
43258
43420
  // src/primitives/data-sources/source-website.ts
43259
43421
  init_define_BUILD();
43260
43422
  init_define_PACKAGE_VERSIONS();
43261
- import { z as z19 } from "@botpress/sdk";
43423
+ import { z as z21 } from "@botpress/sdk";
43262
43424
 
43263
43425
  // ../../node_modules/.bun/fast-xml-parser@5.3.0/node_modules/fast-xml-parser/src/fxp.js
43264
43426
  init_define_BUILD();
@@ -44811,16 +44973,16 @@ async function fetchHtml(url2, options) {
44811
44973
  }
44812
44974
 
44813
44975
  // src/primitives/data-sources/source-website.ts
44814
- var State = z19.object({
44815
- urls: z19.array(
44816
- z19.object({
44817
- loc: z19.string(),
44818
- lastmod: z19.string().optional(),
44819
- changefreq: z19.string().optional(),
44820
- priority: z19.string().optional()
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()
44821
44983
  })
44822
44984
  ).default([]),
44823
- queue: z19.array(z19.object({ url: z19.string(), depth: z19.number() })).default([])
44985
+ queue: z21.array(z21.object({ url: z21.string(), depth: z21.number() })).default([])
44824
44986
  });
44825
44987
  var WebsiteSource = class _WebsiteSource extends DataSource {
44826
44988
  mode;
@@ -45315,7 +45477,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45315
45477
  // src/primitives/data-sources/source-directory.ts
45316
45478
  init_define_BUILD();
45317
45479
  init_define_PACKAGE_VERSIONS();
45318
- import { z as z20 } from "@botpress/sdk";
45480
+ import { z as z22 } from "@botpress/sdk";
45319
45481
  var DirectorySource = class _DirectorySource extends DataSource {
45320
45482
  directoryPath;
45321
45483
  filterFn;
@@ -45327,7 +45489,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
45327
45489
  get syncWorkflow() {
45328
45490
  return createSyncWorkflow({
45329
45491
  type: "directory",
45330
- state: z20.object({}),
45492
+ state: z22.object({}),
45331
45493
  handler: async ({ input, step: step2, client }) => {
45332
45494
  if (!adk.environment.isDevelopment()) {
45333
45495
  console.log("Directory ingestion is only supported in development environment");
@@ -45472,10 +45634,10 @@ var DirectorySource = class _DirectorySource extends DataSource {
45472
45634
  // src/primitives/knowledge.ts
45473
45635
  init_define_BUILD();
45474
45636
  init_define_PACKAGE_VERSIONS();
45475
- var Typings4;
45637
+ var Typings5;
45476
45638
  ((Typings8) => {
45477
45639
  Typings8.Primitive = "knowledge";
45478
- })(Typings4 || (Typings4 = {}));
45640
+ })(Typings5 || (Typings5 = {}));
45479
45641
  var BaseKnowledge = class {
45480
45642
  name;
45481
45643
  sources;
@@ -45532,80 +45694,10 @@ var BaseKnowledge = class {
45532
45694
  }
45533
45695
  };
45534
45696
 
45535
- // src/primitives/action.ts
45536
- init_define_BUILD();
45537
- init_define_PACKAGE_VERSIONS();
45538
- import { transforms as transforms2 } from "@botpress/sdk";
45539
- var Typings5;
45540
- ((Typings8) => {
45541
- Typings8.Primitive = "action";
45542
- })(Typings5 || (Typings5 = {}));
45543
- var BaseAction = class {
45544
- name;
45545
- title;
45546
- description;
45547
- attributes;
45548
- input;
45549
- output;
45550
- cached;
45551
- handler;
45552
- constructor(props) {
45553
- if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
45554
- throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
45555
- }
45556
- this.name = props.name;
45557
- if (props.title !== void 0) {
45558
- this.title = props.title;
45559
- }
45560
- if (props.description !== void 0) {
45561
- this.description = props.description;
45562
- }
45563
- if (props.attributes !== void 0) {
45564
- this.attributes = props.attributes;
45565
- }
45566
- this.input = props.input;
45567
- this.output = props.output;
45568
- this.cached = props.cached ?? false;
45569
- this.handler = props.handler;
45570
- }
45571
- /** @internal */
45572
- getDefinition() {
45573
- const def = {
45574
- type: "action",
45575
- name: this.name
45576
- };
45577
- if (this.title !== void 0) {
45578
- def.title = this.title;
45579
- }
45580
- if (this.description !== void 0) {
45581
- def.description = this.description;
45582
- }
45583
- if (this.input) {
45584
- def.input = transforms2.toJSONSchema(this.input);
45585
- }
45586
- if (this.output) {
45587
- def.output = transforms2.toJSONSchema(this.output);
45588
- }
45589
- if (this.cached !== void 0) {
45590
- def.cached = this.cached;
45591
- }
45592
- if (this.attributes !== void 0) {
45593
- def.attributes = this.attributes;
45594
- }
45595
- return def;
45596
- }
45597
- /**
45598
- * Execute the action with input validation and output validation
45599
- */
45600
- async execute({ input }) {
45601
- return this.handler(input);
45602
- }
45603
- };
45604
-
45605
45697
  // src/primitives/table.ts
45606
45698
  init_define_BUILD();
45607
45699
  init_define_PACKAGE_VERSIONS();
45608
- import { transforms as transforms3, z as z22 } from "@bpinternal/zui";
45700
+ import { transforms as transforms3, z as z23 } from "@bpinternal/zui";
45609
45701
  var Typings6;
45610
45702
  ((Typings8) => {
45611
45703
  Typings8.Primitive = "table";
@@ -45623,13 +45715,21 @@ var BaseTable = class {
45623
45715
  return context.get("client");
45624
45716
  }
45625
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
+ }
45626
45726
  this.name = props.name;
45627
45727
  if (props.description !== void 0) {
45628
45728
  this.description = props.description;
45629
45729
  }
45630
45730
  this.factor = props.factor ?? 1;
45631
45731
  this.columns = {};
45632
- let schema = z22.object({});
45732
+ let schema = z23.object({});
45633
45733
  for (const [key, value] of Object.entries(props.columns)) {
45634
45734
  const val = value;
45635
45735
  if (val && typeof val === "object" && "schema" in val) {
@@ -45805,16 +45905,16 @@ var BaseTable = class {
45805
45905
  // src/primitives/trigger.ts
45806
45906
  init_define_BUILD();
45807
45907
  init_define_PACKAGE_VERSIONS();
45808
- import { z as z23 } from "@botpress/sdk";
45908
+ import { z as z24 } from "@botpress/sdk";
45809
45909
  var Typings7;
45810
45910
  ((Typings8) => {
45811
45911
  Typings8.Primitive = "trigger";
45812
45912
  })(Typings7 || (Typings7 = {}));
45813
- var TriggerSchema = z23.object({
45814
- name: z23.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"),
45815
- description: z23.string().max(1024, "Description must be less than 1024 characters").optional(),
45816
- events: z23.array(z23.string()),
45817
- handler: z23.function().describe("Handler function for the trigger")
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")
45818
45918
  });
45819
45919
  var Trigger = class {
45820
45920
  name;
@@ -45847,13 +45947,13 @@ var Primitives;
45847
45947
  Primitives2.Definitions = Definitions;
45848
45948
  Primitives2.BaseConversation = BaseConversation;
45849
45949
  Primitives2.BaseConversationInstance = BaseConversationInstance;
45850
- Primitives2.Conversation = Typings3;
45950
+ Primitives2.Conversation = Typings4;
45851
45951
  Primitives2.BaseKnowledge = BaseKnowledge;
45852
- Primitives2.Knowledge = Typings4;
45952
+ Primitives2.Knowledge = Typings5;
45853
45953
  Primitives2.BaseWorkflow = BaseWorkflow;
45854
45954
  Primitives2.Workflow = Typings;
45855
45955
  Primitives2.BaseAction = BaseAction;
45856
- Primitives2.Action = Typings5;
45956
+ Primitives2.Action = Typings3;
45857
45957
  Primitives2.BaseTable = BaseTable;
45858
45958
  Primitives2.Table = Typings6;
45859
45959
  Primitives2.BaseTrigger = Trigger;
@@ -45875,6 +45975,10 @@ var import_ms2 = __toESM(require_ms(), 1);
45875
45975
  // src/runtime/handlers/event.ts
45876
45976
  init_define_BUILD();
45877
45977
  init_define_PACKAGE_VERSIONS();
45978
+
45979
+ // src/runtime/handlers/actions.ts
45980
+ init_define_BUILD();
45981
+ init_define_PACKAGE_VERSIONS();
45878
45982
  export {
45879
45983
  Action,
45880
45984
  Autonomous,
@@ -45894,7 +45998,7 @@ export {
45894
45998
  defineConfig,
45895
45999
  isWorkflowDataRequest,
45896
46000
  user,
45897
- z24 as z
46001
+ z25 as z
45898
46002
  };
45899
46003
  /*! Bundled license information:
45900
46004