@botpress/runtime 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/_types/actions.d.ts +1 -1
  2. package/dist/_types/actions.d.ts.map +1 -1
  3. package/dist/_types/channels.d.ts +1 -1
  4. package/dist/_types/channels.d.ts.map +1 -1
  5. package/dist/_types/conversations.d.ts +3 -3
  6. package/dist/_types/conversations.d.ts.map +1 -1
  7. package/dist/_types/events.d.ts +1 -1
  8. package/dist/_types/events.d.ts.map +1 -1
  9. package/dist/_types/integration-actions.d.ts +1 -1
  10. package/dist/_types/integration-actions.d.ts.map +1 -1
  11. package/dist/_types/integrations.d.ts +1 -1
  12. package/dist/_types/integrations.d.ts.map +1 -1
  13. package/dist/_types/state.d.ts +1 -1
  14. package/dist/_types/state.d.ts.map +1 -1
  15. package/dist/_types/tables.d.ts +1 -1
  16. package/dist/_types/tables.d.ts.map +1 -1
  17. package/dist/_types/triggers.d.ts +1 -1
  18. package/dist/_types/triggers.d.ts.map +1 -1
  19. package/dist/_types/workflows.d.ts +4 -4
  20. package/dist/_types/workflows.d.ts.map +1 -1
  21. package/dist/constants.d.ts.map +1 -1
  22. package/dist/consts.d.ts.map +1 -1
  23. package/dist/debugging/node-inspector.d.ts +1 -1
  24. package/dist/debugging/node-inspector.d.ts.map +1 -1
  25. package/dist/define-config.d.ts +3 -3
  26. package/dist/define-config.d.ts.map +1 -1
  27. package/dist/definition.d.ts +4 -4
  28. package/dist/definition.d.ts.map +1 -1
  29. package/dist/definition.js +137 -494
  30. package/dist/definition.js.map +2 -2
  31. package/dist/environment.d.ts +17 -17
  32. package/dist/environment.d.ts.map +1 -1
  33. package/dist/errors.d.ts +1 -1
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/globals.d.ts.map +1 -1
  36. package/dist/internal.d.ts +9 -9
  37. package/dist/internal.d.ts.map +1 -1
  38. package/dist/internal.js +156 -549
  39. package/dist/internal.js.map +2 -2
  40. package/dist/library.d.ts +18 -18
  41. package/dist/library.d.ts.map +1 -1
  42. package/dist/library.js +141 -506
  43. package/dist/library.js.map +2 -2
  44. package/dist/primitives/action.d.ts +7 -7
  45. package/dist/primitives/action.d.ts.map +1 -1
  46. package/dist/primitives/asset.d.ts.map +1 -1
  47. package/dist/primitives/conversation-instance.d.ts +6 -6
  48. package/dist/primitives/conversation-instance.d.ts.map +1 -1
  49. package/dist/primitives/conversation.d.ts +15 -15
  50. package/dist/primitives/conversation.d.ts.map +1 -1
  51. package/dist/primitives/data-sources/index.d.ts +5 -5
  52. package/dist/primitives/data-sources/index.d.ts.map +1 -1
  53. package/dist/primitives/data-sources/source-base.d.ts +3 -3
  54. package/dist/primitives/data-sources/source-base.d.ts.map +1 -1
  55. package/dist/primitives/data-sources/source-directory.d.ts +1 -1
  56. package/dist/primitives/data-sources/source-directory.d.ts.map +1 -1
  57. package/dist/primitives/data-sources/source-table.d.ts +2 -2
  58. package/dist/primitives/data-sources/source-table.d.ts.map +1 -1
  59. package/dist/primitives/data-sources/source-website.d.ts +2 -2
  60. package/dist/primitives/data-sources/source-website.d.ts.map +1 -1
  61. package/dist/primitives/definition.d.ts +8 -8
  62. package/dist/primitives/definition.d.ts.map +1 -1
  63. package/dist/primitives/index.d.ts +18 -18
  64. package/dist/primitives/index.d.ts.map +1 -1
  65. package/dist/primitives/knowledge.d.ts +2 -2
  66. package/dist/primitives/knowledge.d.ts.map +1 -1
  67. package/dist/primitives/table.d.ts +31 -31
  68. package/dist/primitives/table.d.ts.map +1 -1
  69. package/dist/primitives/trigger.d.ts +5 -5
  70. package/dist/primitives/trigger.d.ts.map +1 -1
  71. package/dist/primitives/workflow-instance.d.ts +8 -8
  72. package/dist/primitives/workflow-instance.d.ts.map +1 -1
  73. package/dist/primitives/workflow-step.d.ts +4 -4
  74. package/dist/primitives/workflow-step.d.ts.map +1 -1
  75. package/dist/primitives/workflow-utils.d.ts +5 -5
  76. package/dist/primitives/workflow-utils.d.ts.map +1 -1
  77. package/dist/primitives/workflow.d.ts +13 -13
  78. package/dist/primitives/workflow.d.ts.map +1 -1
  79. package/dist/runtime/actions.d.ts +2 -2
  80. package/dist/runtime/actions.d.ts.map +1 -1
  81. package/dist/runtime/adk.d.ts +7 -7
  82. package/dist/runtime/adk.d.ts.map +1 -1
  83. package/dist/runtime/agent-registry.d.ts +1 -1
  84. package/dist/runtime/agent-registry.d.ts.map +1 -1
  85. package/dist/runtime/assets.d.ts.map +1 -1
  86. package/dist/runtime/autonomous.d.ts +16 -16
  87. package/dist/runtime/autonomous.d.ts.map +1 -1
  88. package/dist/runtime/chat/chat.d.ts +4 -4
  89. package/dist/runtime/chat/chat.d.ts.map +1 -1
  90. package/dist/runtime/chat/citations.d.ts +1 -1
  91. package/dist/runtime/chat/citations.d.ts.map +1 -1
  92. package/dist/runtime/chat/components.d.ts +21 -21
  93. package/dist/runtime/chat/components.d.ts.map +1 -1
  94. package/dist/runtime/chat/html.d.ts.map +1 -1
  95. package/dist/runtime/chat/index.d.ts +4 -4
  96. package/dist/runtime/chat/index.d.ts.map +1 -1
  97. package/dist/runtime/chat/messages.d.ts +2 -2
  98. package/dist/runtime/chat/messages.d.ts.map +1 -1
  99. package/dist/runtime/chat/transcript.d.ts +5 -5
  100. package/dist/runtime/chat/transcript.d.ts.map +1 -1
  101. package/dist/runtime/chat/truncate-object.d.ts.map +1 -1
  102. package/dist/runtime/chat/truncate-transcript.d.ts +1 -1
  103. package/dist/runtime/chat/truncate-transcript.d.ts.map +1 -1
  104. package/dist/runtime/config.d.ts.map +1 -1
  105. package/dist/runtime/context/cognitive.d.ts +1 -1
  106. package/dist/runtime/context/cognitive.d.ts.map +1 -1
  107. package/dist/runtime/context/context.d.ts +10 -10
  108. package/dist/runtime/context/context.d.ts.map +1 -1
  109. package/dist/runtime/context/handlers.d.ts +5 -5
  110. package/dist/runtime/context/handlers.d.ts.map +1 -1
  111. package/dist/runtime/context/http.d.ts +4 -4
  112. package/dist/runtime/context/http.d.ts.map +1 -1
  113. package/dist/runtime/context/inspector-handler.d.ts.map +1 -1
  114. package/dist/runtime/context/promises.d.ts.map +1 -1
  115. package/dist/runtime/events.d.ts.map +1 -1
  116. package/dist/runtime/handlers/conversation-matching.d.ts.map +1 -1
  117. package/dist/runtime/handlers/conversation.d.ts +1 -1
  118. package/dist/runtime/handlers/conversation.d.ts.map +1 -1
  119. package/dist/runtime/handlers/event.d.ts +1 -1
  120. package/dist/runtime/handlers/event.d.ts.map +1 -1
  121. package/dist/runtime/handlers/index.d.ts +4 -4
  122. package/dist/runtime/handlers/index.d.ts.map +1 -1
  123. package/dist/runtime/handlers/trigger.d.ts +1 -1
  124. package/dist/runtime/handlers/trigger.d.ts.map +1 -1
  125. package/dist/runtime/handlers/workflow.d.ts +1 -1
  126. package/dist/runtime/handlers/workflow.d.ts.map +1 -1
  127. package/dist/runtime/heavy-imports.d.ts.map +1 -1
  128. package/dist/runtime/index.d.ts +11 -11
  129. package/dist/runtime/index.d.ts.map +1 -1
  130. package/dist/runtime/interfaces.d.ts.map +1 -1
  131. package/dist/runtime/singletons.d.ts.map +1 -1
  132. package/dist/runtime/state.d.ts +1 -1
  133. package/dist/runtime/state.d.ts.map +1 -1
  134. package/dist/runtime/tracked-state-schema.d.ts.map +1 -1
  135. package/dist/runtime/tracked-state.d.ts +5 -5
  136. package/dist/runtime/tracked-state.d.ts.map +1 -1
  137. package/dist/runtime/workflows/index.d.ts +1 -1
  138. package/dist/runtime/workflows/index.d.ts.map +1 -1
  139. package/dist/runtime/workflows/knowledge-indexing.d.ts +1 -1
  140. package/dist/runtime/workflows/knowledge-indexing.d.ts.map +1 -1
  141. package/dist/runtime.d.ts +13 -13
  142. package/dist/runtime.d.ts.map +1 -1
  143. package/dist/runtime.js +223 -666
  144. package/dist/runtime.js.map +2 -2
  145. package/dist/telemetry/context-manager.d.ts +2 -2
  146. package/dist/telemetry/context-manager.d.ts.map +1 -1
  147. package/dist/telemetry/file-exporter.d.ts +1 -1
  148. package/dist/telemetry/file-exporter.d.ts.map +1 -1
  149. package/dist/telemetry/instrument-http.d.ts +1 -1
  150. package/dist/telemetry/instrument-http.d.ts.map +1 -1
  151. package/dist/telemetry/live-file-processor.d.ts +2 -2
  152. package/dist/telemetry/live-file-processor.d.ts.map +1 -1
  153. package/dist/telemetry/span-helpers.d.ts +8 -8
  154. package/dist/telemetry/span-helpers.d.ts.map +1 -1
  155. package/dist/telemetry/spans/factory.d.ts +11 -11
  156. package/dist/telemetry/spans/factory.d.ts.map +1 -1
  157. package/dist/telemetry/spans/index.d.ts +98 -98
  158. package/dist/telemetry/spans/index.d.ts.map +1 -1
  159. package/dist/telemetry/spans/well-known-attributes.d.ts +5 -5
  160. package/dist/telemetry/spans/well-known-attributes.d.ts.map +1 -1
  161. package/dist/telemetry/structured-logging.d.ts.map +1 -1
  162. package/dist/telemetry/tracing.d.ts +3 -3
  163. package/dist/telemetry/tracing.d.ts.map +1 -1
  164. package/dist/telemetry/utils.d.ts +1 -1
  165. package/dist/telemetry/utils.d.ts.map +1 -1
  166. package/dist/types.d.ts +4 -4
  167. package/dist/types.d.ts.map +1 -1
  168. package/dist/ui.d.ts +4 -4
  169. package/dist/ui.d.ts.map +1 -1
  170. package/dist/ui.js +9 -76
  171. package/dist/ui.js.map +2 -2
  172. package/dist/utilities/abort-signal.d.ts.map +1 -1
  173. package/dist/utilities/events.d.ts +2 -2
  174. package/dist/utilities/events.d.ts.map +1 -1
  175. package/dist/utilities/promises.d.ts.map +1 -1
  176. package/dist/utilities/size.d.ts.map +1 -1
  177. package/dist/utilities/strings.d.ts.map +1 -1
  178. package/dist/utilities/trigger-tags.d.ts.map +1 -1
  179. package/dist/utilities/types.d.ts.map +1 -1
  180. package/dist/workers/dev_worker.d.ts +1 -1
  181. package/dist/workers/dev_worker.d.ts.map +1 -1
  182. package/dist/workers/index.d.ts +3 -3
  183. package/dist/workers/index.d.ts.map +1 -1
  184. package/dist/workers/parent_worker.d.ts +1 -1
  185. package/dist/workers/parent_worker.d.ts.map +1 -1
  186. package/dist/workers/worker_pool.d.ts.map +1 -1
  187. package/package.json +3 -3
package/dist/runtime.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.3", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.3.0", cognitive: "0.1.50" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.6.4", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.4.0", cognitive: "0.2.0" };
52
52
  }
53
53
  });
54
54
 
@@ -34297,15 +34297,14 @@ init_define_PACKAGE_VERSIONS();
34297
34297
  // src/globals.ts
34298
34298
  init_define_BUILD();
34299
34299
  init_define_PACKAGE_VERSIONS();
34300
- var DefinedGlobalObjects = [
34301
- "__PACKAGE_VERSIONS__",
34302
- "__BUILD__"
34303
- ];
34300
+ var DefinedGlobalObjects = ["__PACKAGE_VERSIONS__", "__BUILD__"];
34304
34301
  for (const key of Object.keys(DefinedGlobalObjects)) {
34305
34302
  if (typeof globalThis[key] === "string") {
34306
34303
  try {
34304
+ ;
34307
34305
  globalThis[key] = JSON.parse(globalThis[key]);
34308
34306
  } catch {
34307
+ ;
34309
34308
  globalThis[key] = DefinedGlobalObjects[key];
34310
34309
  }
34311
34310
  }
@@ -34320,6 +34319,7 @@ init_define_BUILD();
34320
34319
  init_define_PACKAGE_VERSIONS();
34321
34320
  function getSingleton(key, factory2) {
34322
34321
  if (!globalThis[key]) {
34322
+ ;
34323
34323
  globalThis[key] = factory2();
34324
34324
  }
34325
34325
  return globalThis[key];
@@ -34583,10 +34583,7 @@ var INDEX_DIR2 = path2.join(DIR2, "index");
34583
34583
  var append = (o) => fs2.appendFile(LIVE, JSON.stringify(o) + "\n", () => {
34584
34584
  });
34585
34585
  var appendToDay = (o) => {
34586
- const dayFile2 = path2.join(
34587
- DIR2,
34588
- `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
34589
- );
34586
+ const dayFile2 = path2.join(DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
34590
34587
  fs2.appendFile(dayFile2, JSON.stringify(o) + "\n", () => {
34591
34588
  });
34592
34589
  };
@@ -34596,10 +34593,7 @@ var appendToTrace = (traceId, o) => {
34596
34593
  });
34597
34594
  };
34598
34595
  var appendToIndex = (o) => {
34599
- const indexFile2 = path2.join(
34600
- INDEX_DIR2,
34601
- `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
34602
- );
34596
+ const indexFile2 = path2.join(INDEX_DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
34603
34597
  fs2.appendFile(indexFile2, JSON.stringify(o) + "\n", () => {
34604
34598
  });
34605
34599
  };
@@ -34613,8 +34607,7 @@ var LiveFileSpanProcessor = class {
34613
34607
  this.timer = setInterval(() => {
34614
34608
  if (!this.active.size) return;
34615
34609
  const ts = nowNs();
34616
- for (const [spanId, traceId] of this.active)
34617
- append({ t: "beat", traceId, spanId, ts });
34610
+ for (const [spanId, traceId] of this.active) append({ t: "beat", traceId, spanId, ts });
34618
34611
  }, beatMs);
34619
34612
  this.timer.unref?.();
34620
34613
  }
@@ -34624,9 +34617,7 @@ var LiveFileSpanProcessor = class {
34624
34617
  onStart(span2, _ctx) {
34625
34618
  const ctx = span2.spanContext();
34626
34619
  this.active.set(ctx.spanId, ctx.traceId);
34627
- const startNs = Number(
34628
- span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs()
34629
- );
34620
+ const startNs = Number(span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs());
34630
34621
  const startEvent = {
34631
34622
  t: "start",
34632
34623
  traceId: ctx.traceId,
@@ -34651,13 +34642,7 @@ var LiveFileSpanProcessor = class {
34651
34642
  handler: span2.name
34652
34643
  // Use span name as handler
34653
34644
  };
34654
- const trackedIds = [
34655
- "conversationId",
34656
- "messageId",
34657
- "eventId",
34658
- "userId",
34659
- "workflowId"
34660
- ];
34645
+ const trackedIds = ["conversationId", "messageId", "eventId", "userId", "workflowId"];
34661
34646
  for (const idKey of trackedIds) {
34662
34647
  if (span2.attributes[idKey]) {
34663
34648
  indexEntry[idKey] = span2.attributes[idKey];
@@ -34759,8 +34744,7 @@ function extractIds(fullUrl, body) {
34759
34744
  if (userMatch?.[1]) ids.userId = userMatch[1];
34760
34745
  if (eventMatch?.[1]) ids.eventId = eventMatch[1];
34761
34746
  if (body && typeof body === "object") {
34762
- if (body.conversationId && !ids.conversationId)
34763
- ids.conversationId = body.conversationId;
34747
+ if (body.conversationId && !ids.conversationId) ids.conversationId = body.conversationId;
34764
34748
  if (body.messageId && !ids.messageId) ids.messageId = body.messageId;
34765
34749
  if (body.workflowId && !ids.workflowId) ids.workflowId = body.workflowId;
34766
34750
  if (body.userId && !ids.userId) ids.userId = body.userId;
@@ -34768,9 +34752,7 @@ function extractIds(fullUrl, body) {
34768
34752
  }
34769
34753
  return ids;
34770
34754
  }
34771
- function installHttpClientInstrumentation({
34772
- injectTraceHeader = true
34773
- } = {}) {
34755
+ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
34774
34756
  const restores = [];
34775
34757
  const genId = (n) => randomBytes(n).toString("hex");
34776
34758
  const makeTraceparent = () => `00-${genId(16)}-${genId(8)}-01`;
@@ -34840,8 +34822,7 @@ function installHttpClientInstrumentation({
34840
34822
  },
34841
34823
  context.active()
34842
34824
  );
34843
- if (injectTraceHeader && !("traceparent" in options.headers))
34844
- options.headers.traceparent = traceparent;
34825
+ if (injectTraceHeader && !("traceparent" in options.headers)) options.headers.traceparent = traceparent;
34845
34826
  let req;
34846
34827
  if (typeof args[0] === "string" || args[0] instanceof URL) {
34847
34828
  req = requestFn.call(this, args[0], options, cb);
@@ -34863,18 +34844,12 @@ function installHttpClientInstrumentation({
34863
34844
  }
34864
34845
  if (requestBodyChunks.length > 0) {
34865
34846
  const bodyString = Buffer.concat(requestBodyChunks).toString("utf-8");
34866
- span2.setAttribute(
34867
- isBotpress ? "botpress.request.body" : "http.request.body",
34868
- bodyString
34869
- );
34847
+ span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", bodyString);
34870
34848
  }
34871
34849
  return origEnd(chunk, ...args2);
34872
34850
  };
34873
34851
  req.on("response", (res) => {
34874
- span2.setAttribute(
34875
- isBotpress ? "botpress.status_code" : "http.status_code",
34876
- res.statusCode || 0
34877
- );
34852
+ span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
34878
34853
  const responseBodyChunks = [];
34879
34854
  res.on("data", (chunk) => {
34880
34855
  responseBodyChunks.push(chunk);
@@ -34882,10 +34857,7 @@ function installHttpClientInstrumentation({
34882
34857
  res.on("end", () => {
34883
34858
  if (responseBodyChunks.length > 0) {
34884
34859
  const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
34885
- span2.setAttribute(
34886
- isBotpress ? "botpress.response.body" : "http.response.body",
34887
- bodyString
34888
- );
34860
+ span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
34889
34861
  }
34890
34862
  if ((res.statusCode || 0) >= 400) {
34891
34863
  span2.setStatus({
@@ -34897,10 +34869,7 @@ function installHttpClientInstrumentation({
34897
34869
  });
34898
34870
  });
34899
34871
  req.on("error", (err) => {
34900
- span2.setAttribute(
34901
- isBotpress ? "botpress.error" : "http.error",
34902
- err.message
34903
- );
34872
+ span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
34904
34873
  span2.recordException(err);
34905
34874
  span2.setStatus({
34906
34875
  code: SpanStatusCode.ERROR,
@@ -34918,6 +34887,7 @@ function installHttpClientInstrumentation({
34918
34887
  httpsRequest: https.request,
34919
34888
  httpsGet: https.get
34920
34889
  };
34890
+ ;
34921
34891
  http.request = wrapRequest2(orig.httpRequest);
34922
34892
  https.request = wrapRequest2(orig.httpsRequest);
34923
34893
  http.get = function wrappedGet(...a) {
@@ -35011,10 +34981,7 @@ function installHttpClientInstrumentation({
35011
34981
  }
35012
34982
  }
35013
34983
  if (requestBody) {
35014
- span2.setAttribute(
35015
- isBotpress ? "botpress.request.body" : "http.request.body",
35016
- requestBody
35017
- );
34984
+ span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", requestBody);
35018
34985
  }
35019
34986
  }
35020
34987
  const traceparent = makeTraceparent();
@@ -35022,10 +34989,7 @@ function installHttpClientInstrumentation({
35022
34989
  if (Array.isArray(opts.headers)) {
35023
34990
  headers.push(...opts.headers);
35024
34991
  } else if (opts.headers && typeof opts.headers === "object") {
35025
- for (const [k, v] of Object.entries(
35026
- opts.headers
35027
- ))
35028
- headers.push(k, String(v));
34992
+ for (const [k, v] of Object.entries(opts.headers)) headers.push(k, String(v));
35029
34993
  }
35030
34994
  headers.push(INSTRUMENTED_HEADER, "true");
35031
34995
  if (injectTraceHeader) {
@@ -35043,10 +35007,7 @@ function installHttpClientInstrumentation({
35043
35007
  onConnect: handler.onConnect?.bind(handler),
35044
35008
  onUpgrade: handler.onUpgrade?.bind(handler),
35045
35009
  onHeaders: (statusCode, rawHeaders, resume) => {
35046
- span2.setAttribute(
35047
- isBotpress ? "botpress.status_code" : "http.status_code",
35048
- statusCode
35049
- );
35010
+ span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
35050
35011
  if (statusCode >= 500) {
35051
35012
  span2.setStatus({
35052
35013
  code: SpanStatusCode.ERROR,
@@ -35061,10 +35022,7 @@ function installHttpClientInstrumentation({
35061
35022
  handler.onHeaders?.(statusCode, rawHeaders, resume);
35062
35023
  },
35063
35024
  onError: (err) => {
35064
- span2.setAttribute(
35065
- isBotpress ? "botpress.error" : "http.error",
35066
- err.message
35067
- );
35025
+ span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
35068
35026
  span2.recordException(err);
35069
35027
  span2.setStatus({
35070
35028
  code: SpanStatusCode.ERROR,
@@ -35081,10 +35039,7 @@ function installHttpClientInstrumentation({
35081
35039
  onComplete: (trailers) => {
35082
35040
  if (responseBodyChunks.length > 0) {
35083
35041
  const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
35084
- span2.setAttribute(
35085
- isBotpress ? "botpress.response.body" : "http.response.body",
35086
- bodyString
35087
- );
35042
+ span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
35088
35043
  }
35089
35044
  span2.end();
35090
35045
  handler.onComplete?.(trailers);
@@ -35164,10 +35119,8 @@ function inspectToJsonSize(input, opts) {
35164
35119
  if (value === null) return null;
35165
35120
  const t = typeof value;
35166
35121
  if (t === "boolean" || t === "number") return value;
35167
- if (t === "string")
35168
- return elideString(value, limits2.head, limits2.tail);
35169
- if (t === "bigint")
35170
- return elideString(String(value), limits2.head, limits2.tail);
35122
+ if (t === "string") return elideString(value, limits2.head, limits2.tail);
35123
+ if (t === "bigint") return elideString(String(value), limits2.head, limits2.tail);
35171
35124
  if (t === "symbol" || t === "function" || t === "undefined") {
35172
35125
  return null;
35173
35126
  }
@@ -35222,8 +35175,7 @@ function inspectToJsonSize(input, opts) {
35222
35175
  const k = keys[i];
35223
35176
  props[k] = summarize(value[k], seen, nextLimits);
35224
35177
  }
35225
- if (keys.length > keep)
35226
- props["__truncated__"] = `+${keys.length - keep} keys`;
35178
+ if (keys.length > keep) props["__truncated__"] = `+${keys.length - keep} keys`;
35227
35179
  seen.delete(value);
35228
35180
  return { [`<${tag}>`]: props };
35229
35181
  }
@@ -35433,10 +35385,7 @@ function getAssetsMetadata() {
35433
35385
  init_define_BUILD();
35434
35386
  init_define_PACKAGE_VERSIONS();
35435
35387
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
35436
- var storage = getSingleton(
35437
- "__ADK_GLOBAL_CTX_STORAGE",
35438
- () => new AsyncLocalStorage2()
35439
- );
35388
+ var storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage2());
35440
35389
  var context2 = {
35441
35390
  enterWith: (data) => {
35442
35391
  storage.enterWith(data);
@@ -35451,10 +35400,7 @@ var context2 = {
35451
35400
  },
35452
35401
  getAll: () => {
35453
35402
  const store = storage.getStore();
35454
- if (!store)
35455
- throw new Error(
35456
- "No context found. Did you forget to call `context.run()`?"
35457
- );
35403
+ if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
35458
35404
  return store;
35459
35405
  },
35460
35406
  get: (key, opts) => {
@@ -35524,10 +35470,7 @@ var InstrumentedCognitive = class _InstrumentedCognitive extends Cognitive {
35524
35470
  "ai.top_p": input.topP,
35525
35471
  "ai.system_length": input.systemPrompt?.length || 0,
35526
35472
  "ai.messages_count": input.messages?.length || 0,
35527
- "ai.input_length": input.messages?.reduce(
35528
- (acc, m) => acc + (m.content?.length || 0),
35529
- 0
35530
- ) || 0,
35473
+ "ai.input_length": input.messages?.reduce((acc, m) => acc + (m.content?.length || 0), 0) || 0,
35531
35474
  "ai.prompt_category": input.meta?.promptCategory,
35532
35475
  "ai.prompt_source": input.meta?.promptSource,
35533
35476
  "ai.instructions": input.systemPrompt,
@@ -35540,10 +35483,7 @@ var InstrumentedCognitive = class _InstrumentedCognitive extends Cognitive {
35540
35483
  s.setAttribute("ai.output_tokens", result.meta.tokens.output || 0);
35541
35484
  s.setAttribute("ai.cost_input", result.meta.cost.input || 0);
35542
35485
  s.setAttribute("ai.cost_output", result.meta.cost.output || 0);
35543
- s.setAttribute(
35544
- "ai.cost",
35545
- (result.meta.cost.input || 0) + (result.meta.cost.output || 0)
35546
- );
35486
+ s.setAttribute("ai.cost", (result.meta.cost.input || 0) + (result.meta.cost.output || 0));
35547
35487
  s.setAttribute("ai.model", result.meta.model.model);
35548
35488
  s.setAttribute("ai.provider", result.meta.model.integration);
35549
35489
  return result;
@@ -35613,9 +35553,7 @@ var getPromiseTracker = () => {
35613
35553
  if (tracker) {
35614
35554
  return tracker;
35615
35555
  }
35616
- throw new Error(
35617
- "PromiseTracker not found in context. Make sure to initialize it in your runtime setup."
35618
- );
35556
+ throw new Error("PromiseTracker not found in context. Make sure to initialize it in your runtime setup.");
35619
35557
  };
35620
35558
  function trackPromise(promise) {
35621
35559
  return getPromiseTracker().register(promise);
@@ -35705,14 +35643,10 @@ function parseHttpRequest(req) {
35705
35643
  if (!req.headers) {
35706
35644
  return void 0;
35707
35645
  }
35708
- const headerKey = Object.keys(req.headers).find(
35709
- (key) => key.toLowerCase().trim() === name.toLowerCase().trim()
35710
- );
35646
+ const headerKey = Object.keys(req.headers).find((key) => key.toLowerCase().trim() === name.toLowerCase().trim());
35711
35647
  return headerKey ? req.headers[headerKey] : void 0;
35712
35648
  };
35713
- const operation = getHeader(
35714
- OPERATION_TYPE_HEADER
35715
- );
35649
+ const operation = getHeader(OPERATION_TYPE_HEADER);
35716
35650
  const botId = getHeader(BOT_ID_HEADER) || "unknown";
35717
35651
  const botUserId = getHeader(BOT_USER_ID_HEADER) || "";
35718
35652
  const webhookId = getHeader(WEBHOOK_ID_HEADER) || "";
@@ -35735,9 +35669,7 @@ function parseHttpRequest(req) {
35735
35669
  if (contentType.includes("application/json")) {
35736
35670
  body = parseJson(body);
35737
35671
  }
35738
- let configuration = decodeBase64Obj(
35739
- config || ""
35740
- );
35672
+ let configuration = decodeBase64Obj(config || "");
35741
35673
  if (configuration && typeof configuration === "object" && "payload" in configuration) {
35742
35674
  configuration.payload = parseJson(configuration.payload);
35743
35675
  }
@@ -35800,16 +35732,11 @@ var AgentRegistry = class {
35800
35732
  }
35801
35733
  ensureInitialized() {
35802
35734
  if (!this._data) {
35803
- throw new Error(
35804
- "Agent registry not initialized. Call agentRegistry.initialize() during bot startup."
35805
- );
35735
+ throw new Error("Agent registry not initialized. Call agentRegistry.initialize() during bot startup.");
35806
35736
  }
35807
35737
  }
35808
35738
  };
35809
- var agentRegistry = getSingleton(
35810
- "__ADK_GLOBAL_AGENT_REGISTRY",
35811
- () => new AgentRegistry()
35812
- );
35739
+ var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentRegistry());
35813
35740
 
35814
35741
  // src/runtime/tracked-state.ts
35815
35742
  init_define_BUILD();
@@ -39607,9 +39534,7 @@ init_define_PACKAGE_VERSIONS();
39607
39534
  init_define_BUILD();
39608
39535
  init_define_PACKAGE_VERSIONS();
39609
39536
  init_esm();
39610
- import {
39611
- getValue
39612
- } from "llmz";
39537
+ import { getValue } from "llmz";
39613
39538
  import {
39614
39539
  Tool as LlmzTool,
39615
39540
  ThinkSignal as _ThinkSignal,
@@ -39627,9 +39552,7 @@ init_define_BUILD();
39627
39552
  init_define_PACKAGE_VERSIONS();
39628
39553
  function createJoinedAbortController(signals) {
39629
39554
  const controller = new AbortController();
39630
- const validSignals = signals.filter(
39631
- (signal) => signal != null
39632
- );
39555
+ const validSignals = signals.filter((signal) => signal != null);
39633
39556
  if (validSignals.length === 0) {
39634
39557
  return controller;
39635
39558
  }
@@ -39754,9 +39677,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
39754
39677
  const client = context2.get("client");
39755
39678
  const citations = context2.get("citations");
39756
39679
  if (!client) {
39757
- throw new Error(
39758
- "Client is not available in this context. Make sure to run in a context with a client."
39759
- );
39680
+ throw new Error("Client is not available in this context. Make sure to run in a context with a client.");
39760
39681
  }
39761
39682
  const { passages } = await client.searchFiles({
39762
39683
  query,
@@ -39806,9 +39727,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
39806
39727
  citationMetadata.sourceId = tags[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID];
39807
39728
  }
39808
39729
  const { tag } = citations.registerSource(citationMetadata);
39809
- message.push(
39810
- `<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`
39811
- );
39730
+ message.push(`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`);
39812
39731
  message.push(p.content);
39813
39732
  message.push(`</${tag}>`);
39814
39733
  }
@@ -39824,9 +39743,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
39824
39743
  return async (props) => {
39825
39744
  const cognitive = context2.get("cognitive");
39826
39745
  if (!cognitive) {
39827
- throw new Error(
39828
- "Cognitive client is not available in this context. Make sure to run in a cognitive context."
39829
- );
39746
+ throw new Error("Cognitive client is not available in this context. Make sure to run in a cognitive context.");
39830
39747
  }
39831
39748
  const defaultTemperature = 0.7;
39832
39749
  const maxLoops = import_lodash2.default.clamp(props.iterations ?? 10, 1, 100);
@@ -39838,10 +39755,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
39838
39755
  "autonomous.mode": options.mode
39839
39756
  },
39840
39757
  async (execSpan) => {
39841
- const joinedSignal = createJoinedAbortSignal([
39842
- props.signal,
39843
- options.interruption
39844
- ]);
39758
+ const joinedSignal = createJoinedAbortSignal([props.signal, options.interruption]);
39845
39759
  const llmz_execute = (await import("llmz")).execute;
39846
39760
  const asyncResource = new AsyncResource("autonomous.execution");
39847
39761
  const getNewIteration = (index) => createSpan(
@@ -39859,17 +39773,11 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
39859
39773
  );
39860
39774
  const _chat = options.mode === "chat" ? context2.get("chat") : void 0;
39861
39775
  if (options.mode === "chat" && !_chat) {
39862
- throw new Error(
39863
- "Chat is not available in this context. Make sure to run in chat mode with a chat context."
39864
- );
39776
+ throw new Error("Chat is not available in this context. Make sure to run in chat mode with a chat context.");
39865
39777
  }
39866
39778
  const chat = _chat ? {
39867
- components: bindContext(
39868
- (ctx) => getValue(_chat.components, ctx)
39869
- ),
39870
- transcript: bindContext(
39871
- (ctx) => getValue(_chat.transcript, ctx)
39872
- ),
39779
+ components: bindContext((ctx) => getValue(_chat.components, ctx)),
39780
+ transcript: bindContext((ctx) => getValue(_chat.transcript, ctx)),
39873
39781
  handler: bindContext(_chat.handler),
39874
39782
  onExecutionDone: bindContext(_chat.onExecutionDone)
39875
39783
  } : void 0;
@@ -39904,10 +39812,7 @@ Always prefer information from the knowledge bases over general knowledge when a
39904
39812
  ...props.objects && {
39905
39813
  objects: async (ctx) => {
39906
39814
  const objs = await getValue(props.objects, ctx) ?? [];
39907
- iterationSpan?.setAttribute(
39908
- "autonomous.objects",
39909
- objs.map((o) => o.name).join(", ")
39910
- );
39815
+ iterationSpan?.setAttribute("autonomous.objects", objs.map((o) => o.name).join(", "));
39911
39816
  for (const obj of objs) {
39912
39817
  obj.tools = obj.tools?.map(
39913
39818
  (tool) => tool.clone({
@@ -39971,10 +39876,7 @@ Always prefer information from the knowledge bases over general knowledge when a
39971
39876
  if (search_knowledge) {
39972
39877
  allTools.push(search_knowledge);
39973
39878
  }
39974
- iterationSpan?.setAttribute(
39975
- "autonomous.tools",
39976
- allTools?.map((t) => t.name).join(", ")
39977
- );
39879
+ iterationSpan?.setAttribute("autonomous.tools", allTools?.map((t) => t.name).join(", "));
39978
39880
  return allTools.map(
39979
39881
  (tool) => tool.clone({
39980
39882
  handler: asyncResource.bind((args, ctx2) => {
@@ -40036,9 +39938,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40036
39938
  onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
40037
39939
  },
40038
39940
  ...props.hooks?.onBeforeExecution && {
40039
- onBeforeExecution: asyncResource.bind(
40040
- props.hooks.onBeforeExecution
40041
- )
39941
+ onBeforeExecution: asyncResource.bind(props.hooks.onBeforeExecution)
40042
39942
  },
40043
39943
  ...props.hooks?.onExit && {
40044
39944
  onExit: asyncResource.bind(props.hooks.onExit)
@@ -40057,9 +39957,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40057
39957
  });
40058
39958
  }
40059
39959
  if (props.hooks?.onTrace) {
40060
- return asyncResource.runInAsyncScope(
40061
- () => props.hooks.onTrace({ trace: trace2, iteration })
40062
- );
39960
+ return asyncResource.runInAsyncScope(() => props.hooks.onTrace({ trace: trace2, iteration }));
40063
39961
  }
40064
39962
  },
40065
39963
  onIterationEnd: async (iteration, controller) => {
@@ -40085,9 +39983,7 @@ ${iteration.status.execution_error.stack}`;
40085
39983
  } else if (iteration.status.type === "invalid_code_error") {
40086
39984
  message = `Iteration failed due to invalid code: ${iteration.status.invalid_code_error.message}`;
40087
39985
  }
40088
- iterationSpan?.recordException(
40089
- iteration.error ?? new Error(message)
40090
- );
39986
+ iterationSpan?.recordException(iteration.error ?? new Error(message));
40091
39987
  iterationSpan?.setStatus({
40092
39988
  code: SpanStatusCode.ERROR,
40093
39989
  message
@@ -40109,16 +40005,11 @@ ${iteration.status.execution_error.stack}`;
40109
40005
  }
40110
40006
  iterationSpan?.end();
40111
40007
  if (props.hooks?.onIterationEnd) {
40112
- return await asyncResource.runInAsyncScope(
40113
- () => props.hooks.onIterationEnd(iteration, controller)
40114
- );
40008
+ return await asyncResource.runInAsyncScope(() => props.hooks.onIterationEnd(iteration, controller));
40115
40009
  }
40116
40010
  }
40117
40011
  });
40118
- execSpan.setAttribute(
40119
- "autonomous.execution_id",
40120
- execution.context.id
40121
- );
40012
+ execSpan.setAttribute("autonomous.execution_id", execution.context.id);
40122
40013
  return execution;
40123
40014
  }
40124
40015
  );
@@ -40161,22 +40052,16 @@ var actions = new Proxy({}, {
40161
40052
  }
40162
40053
  integrations ??= context2.get("integrations", { optional: true });
40163
40054
  client ??= context2.get("client", { optional: true });
40164
- const integration = integrations.find(
40165
- (i) => i.alias === integrationName
40166
- );
40055
+ const integration = integrations.find((i) => i.alias === integrationName);
40167
40056
  const actionDef = integration?.definition.actions?.[actionName];
40168
40057
  const handler = async (params) => {
40169
40058
  integrations ??= context2.get("integrations", { optional: true });
40170
40059
  client ??= context2.get("client", { optional: true });
40171
40060
  if (!integration || !actionDef) {
40172
- throw new Error(
40173
- `Could not find integration "${integrationName}" and action "${actionName}"`
40174
- );
40061
+ throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
40175
40062
  }
40176
40063
  if (!integration.definition.actions?.[actionName]) {
40177
- throw new Error(
40178
- `Action "${actionName}" not found in integration "${integrationName}"`
40179
- );
40064
+ throw new Error(`Action "${actionName}" not found in integration "${integrationName}"`);
40180
40065
  }
40181
40066
  return client.callAction({
40182
40067
  type: `${integration.alias}:${actionName}`,
@@ -40185,9 +40070,7 @@ var actions = new Proxy({}, {
40185
40070
  };
40186
40071
  handler.asTool = () => {
40187
40072
  if (!integration || !actionDef) {
40188
- throw new Error(
40189
- `Could not find integration "${integrationName}" and action "${actionName}"`
40190
- );
40073
+ throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
40191
40074
  }
40192
40075
  return new Autonomous.Tool({
40193
40076
  name: actionName,
@@ -40205,9 +40088,7 @@ var actions = new Proxy({}, {
40205
40088
  optional: true
40206
40089
  });
40207
40090
  if (!integrations2) return [];
40208
- const integration = integrations2.find(
40209
- (i) => i.alias === integrationName
40210
- );
40091
+ const integration = integrations2.find((i) => i.alias === integrationName);
40211
40092
  if (!integration?.definition?.actions) return [];
40212
40093
  return Object.keys(integration.definition.actions);
40213
40094
  } catch {
@@ -40220,9 +40101,7 @@ var actions = new Proxy({}, {
40220
40101
  optional: true
40221
40102
  });
40222
40103
  if (!integrations2) return false;
40223
- const integration = integrations2.find(
40224
- (i) => i.alias === integrationName
40225
- );
40104
+ const integration = integrations2.find((i) => i.alias === integrationName);
40226
40105
  return !!integration?.definition?.actions?.[actionName];
40227
40106
  } catch {
40228
40107
  return false;
@@ -40530,11 +40409,7 @@ var BaseConversationInstance = class {
40530
40409
  * Start typing indicator
40531
40410
  */
40532
40411
  async startTyping() {
40533
- const mapping = InterfaceMappings.getIntegrationAction(
40534
- "typingIndicator",
40535
- "startTypingIndicator",
40536
- this.integration
40537
- );
40412
+ const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
40538
40413
  if (mapping) {
40539
40414
  const message = context2.get("message", { optional: true });
40540
40415
  await this.client.callAction({
@@ -40551,11 +40426,7 @@ var BaseConversationInstance = class {
40551
40426
  * Stop typing indicator
40552
40427
  */
40553
40428
  async stopTyping() {
40554
- const mapping = InterfaceMappings.getIntegrationAction(
40555
- "typingIndicator",
40556
- "stopTypingIndicator",
40557
- this.integration
40558
- );
40429
+ const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
40559
40430
  if (mapping) {
40560
40431
  const message = context2.get("message", { optional: true });
40561
40432
  await this.client.callAction({
@@ -40631,10 +40502,7 @@ var Definitions;
40631
40502
  });
40632
40503
  const actionDefinitionSchema = z3.object({
40633
40504
  type: z3.literal("action"),
40634
- name: z3.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(
40635
- /^[a-zA-Z][a-zA-Z0-9]*$/,
40636
- "Name must be alphanumeric with no special characters"
40637
- ),
40505
+ name: z3.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"),
40638
40506
  title: z3.string().optional(),
40639
40507
  description: z3.string().optional(),
40640
40508
  attributes: z3.record(z3.string()).optional(),
@@ -40735,9 +40603,7 @@ var createSyncWorkflow = (props) => new BaseWorkflow({
40735
40603
  }
40736
40604
  const source = kb.sources.find((s) => s.id === sourceId);
40737
40605
  if (!source) {
40738
- throw new Error(
40739
- `Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`
40740
- );
40606
+ throw new Error(`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`);
40741
40607
  }
40742
40608
  console.log(
40743
40609
  `\u{1F504} Starting sync for data source '${sourceId}' of type '${source.type}' in knowledge base '${kbName}'`
@@ -42277,17 +42143,8 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42277
42143
  this.urls = options.urls ?? void 0;
42278
42144
  this.filterFn = "filter" in options ? options.filter : void 0;
42279
42145
  this.customFetch = options.fetch ?? void 0;
42280
- this.maxPages = Math.max(
42281
- 1,
42282
- Math.min(
42283
- ("maxPages" in options ? options.maxPages : void 0) ?? 5e4,
42284
- 5e4
42285
- )
42286
- );
42287
- this.maxDepth = Math.max(
42288
- 1,
42289
- Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20)
42290
- );
42146
+ this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
42147
+ this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
42291
42148
  }
42292
42149
  isBrowserIntegrationAvailable() {
42293
42150
  return !!adk.project.integrations.get("browser");
@@ -42451,9 +42308,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42451
42308
  }
42452
42309
  return passed;
42453
42310
  });
42454
- console.log(
42455
- `Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`
42456
- );
42311
+ console.log(`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`);
42457
42312
  }
42458
42313
  return filteredUrls.map((url2) => ({ loc: url2 }));
42459
42314
  }
@@ -42485,20 +42340,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42485
42340
  await step2(`processing sitemap ${item.url}`, async () => {
42486
42341
  try {
42487
42342
  const { content, contentType } = await this.fetchSitemap(item.url);
42488
- console.log(
42489
- `Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`
42490
- );
42343
+ console.log(`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`);
42491
42344
  console.log(content, contentType);
42492
42345
  try {
42493
42346
  const { urls, sitemaps } = this.parseSitemapXml(content);
42494
- console.log(
42495
- `Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`
42496
- );
42347
+ console.log(`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`);
42497
42348
  for (const url2 of urls) {
42498
42349
  if (state.urls.length >= this.maxPages) {
42499
- console.log(
42500
- `Reached maxPages limit (${this.maxPages}), stopping URL discovery`
42501
- );
42350
+ console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
42502
42351
  break;
42503
42352
  }
42504
42353
  const filterContext = {
@@ -42519,20 +42368,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42519
42368
  state.queue.push({ url: sitemapUrl, depth: item.depth + 1 });
42520
42369
  }
42521
42370
  } else if (sitemaps.length > 0) {
42522
- console.log(
42523
- `Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`
42524
- );
42371
+ console.log(`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`);
42525
42372
  }
42526
42373
  } catch (xmlErr) {
42527
- console.log(
42528
- `XML parsing failed for ${item.url}, trying TXT format...`
42529
- );
42374
+ console.log(`XML parsing failed for ${item.url}, trying TXT format...`);
42530
42375
  const { urls } = this.parseSitemapTxt(content);
42531
42376
  for (const url2 of urls) {
42532
42377
  if (state.urls.length >= this.maxPages) {
42533
- console.log(
42534
- `Reached maxPages limit (${this.maxPages}), stopping URL discovery`
42535
- );
42378
+ console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
42536
42379
  break;
42537
42380
  }
42538
42381
  const filterContext = { url: url2.loc };
@@ -42550,13 +42393,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42550
42393
  }
42551
42394
  });
42552
42395
  }
42553
- console.log(
42554
- `URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`
42555
- );
42396
+ console.log(`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`);
42556
42397
  if (state.urls.length >= this.maxPages) {
42557
- console.log(
42558
- `Note: Discovery stopped at maxPages limit (${this.maxPages})`
42559
- );
42398
+ console.log(`Note: Discovery stopped at maxPages limit (${this.maxPages})`);
42560
42399
  }
42561
42400
  return state.urls.slice(0, this.maxPages);
42562
42401
  }
@@ -42569,13 +42408,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42569
42408
  console.log(
42570
42409
  `Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
42571
42410
  );
42572
- console.log(
42573
- `Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`
42574
- );
42411
+ console.log(`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`);
42575
42412
  if (input.force) {
42576
- console.log(
42577
- "\u{1F504} FORCE MODE: Re-indexing all files regardless of changes"
42578
- );
42413
+ console.log("\u{1F504} FORCE MODE: Re-indexing all files regardless of changes");
42579
42414
  }
42580
42415
  const tags = {
42581
42416
  [WellKnownTags.knowledge.KNOWLEDGE]: "true",
@@ -42583,10 +42418,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42583
42418
  [WellKnownTags.knowledge.KNOWLEDGE_SOURCE_TYPE]: this.type,
42584
42419
  [WellKnownTags.knowledge.KNOWLEDGE_BASE_NAME]: input.kbName
42585
42420
  };
42586
- const discoveredUrls = await step2(
42587
- "discover urls from sitemap",
42588
- () => this.discoverUrls(step2, state)
42589
- );
42421
+ const discoveredUrls = await step2("discover urls from sitemap", () => this.discoverUrls(step2, state));
42590
42422
  console.log(`Discovered ${discoveredUrls.length} URLs from sitemap`);
42591
42423
  console.log(`Will process up to ${this.maxPages} pages`);
42592
42424
  const existingFiles = await step2(
@@ -42596,15 +42428,10 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
42596
42428
  }).collect()
42597
42429
  );
42598
42430
  const existingFileMap = new Map(
42599
- existingFiles.map((f) => [
42600
- f.metadata?.[WellKnownMetadata.knowledge.URL],
42601
- f
42602
- ])
42431
+ existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
42603
42432
  );
42604
42433
  const toRemove = existingFiles.filter(
42605
- (f) => !discoveredUrls.find(
42606
- (u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL]
42607
- )
42434
+ (f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
42608
42435
  );
42609
42436
  const toFetch = [];
42610
42437
  let skippedUnchanged = 0;
@@ -42751,9 +42578,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
42751
42578
  state: z7.object({}),
42752
42579
  handler: async ({ input, step: step2, client }) => {
42753
42580
  if (!adk.environment.isDevelopment()) {
42754
- console.log(
42755
- "Directory ingestion is only supported in development environment"
42756
- );
42581
+ console.log("Directory ingestion is only supported in development environment");
42757
42582
  return {
42758
42583
  added: [],
42759
42584
  updated: [],
@@ -42769,10 +42594,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
42769
42594
  const path4 = await import("path");
42770
42595
  const fs3 = await import("fs/promises");
42771
42596
  const crypto3 = await import("crypto");
42772
- const directory = path4.resolve(
42773
- adk.environment.agent.directory,
42774
- this.directoryPath
42775
- );
42597
+ const directory = path4.resolve(adk.environment.agent.directory, this.directoryPath);
42776
42598
  const tags = {
42777
42599
  [WellKnownTags.knowledge.KNOWLEDGE]: "true",
42778
42600
  [WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID]: this.id,
@@ -42812,11 +42634,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
42812
42634
  const toRemove = existingFiles.filter(
42813
42635
  (f) => !allFiles.find((af) => af.rel === f.metadata?.relPath)
42814
42636
  );
42815
- const toAdd = allFiles.filter(
42816
- (af) => !existingFiles.find(
42817
- (f) => f.metadata?.relPath === af.rel
42818
- )
42819
- );
42637
+ const toAdd = allFiles.filter((af) => !existingFiles.find((f) => f.metadata?.relPath === af.rel));
42820
42638
  const toUpdate = allFiles.filter(
42821
42639
  (af) => existingFiles.find((f) => f.metadata?.relPath === af.rel)
42822
42640
  );
@@ -42878,18 +42696,11 @@ var DirectorySource = class _DirectorySource extends DataSource {
42878
42696
  size: uploaded.file.size ?? -1
42879
42697
  };
42880
42698
  };
42881
- const added = await step2.map(
42882
- "to add files",
42883
- toAdd,
42884
- (f) => upsertFile(f),
42885
- { concurrency: 5, maxAttempts: 2 }
42886
- );
42887
- const updated = await step2.map(
42888
- "to update files",
42889
- toUpdate,
42890
- (f) => upsertFile(f),
42891
- { concurrency: 5, maxAttempts: 2 }
42892
- );
42699
+ const added = await step2.map("to add files", toAdd, (f) => upsertFile(f), { concurrency: 5, maxAttempts: 2 });
42700
+ const updated = await step2.map("to update files", toUpdate, (f) => upsertFile(f), {
42701
+ concurrency: 5,
42702
+ maxAttempts: 2
42703
+ });
42893
42704
  return {
42894
42705
  processed: allFiles.length,
42895
42706
  deleted,
@@ -42979,10 +42790,7 @@ var BaseConversation = class {
42979
42790
  const chat = context2.get("chat");
42980
42791
  const client = context2.get("client");
42981
42792
  const botpressConversation = context2.get("conversation");
42982
- const conversationInstance = new BaseConversationInstance(
42983
- botpressConversation,
42984
- client
42985
- );
42793
+ const conversationInstance = new BaseConversationInstance(botpressConversation, client);
42986
42794
  let type;
42987
42795
  let requestObject = void 0;
42988
42796
  if (message) {
@@ -43021,9 +42829,7 @@ var BaseConversation = class {
43021
42829
  conversationId: conversationInstance.id,
43022
42830
  status: "pending"
43023
42831
  });
43024
- const newEvents = events.filter(
43025
- (e) => e.createdAt > event?.createdAt && e.id !== event?.id
43026
- );
42832
+ const newEvents = events.filter((e) => e.createdAt > event?.createdAt && e.id !== event?.id);
43027
42833
  if (newEvents.length) {
43028
42834
  s.setAttributes({
43029
42835
  "interruption.detected": true,
@@ -43051,9 +42857,7 @@ var BaseConversation = class {
43051
42857
  }
43052
42858
  }
43053
42859
  if (newEvents.length) {
43054
- controller.abort(
43055
- `More messages were received during processing, aborting current processing.`
43056
- );
42860
+ controller.abort(`More messages were received during processing, aborting current processing.`);
43057
42861
  } else {
43058
42862
  s.setAttribute("interruption.detected", false);
43059
42863
  }
@@ -43150,9 +42954,7 @@ var BaseKnowledge = class {
43150
42954
  async refreshSource(sourceId, options) {
43151
42955
  const source = this.sources.find((s) => s.id === sourceId);
43152
42956
  if (!source) {
43153
- throw new Error(
43154
- `Data source with id "${sourceId}" not found in knowledge base "${this.name}"`
43155
- );
42957
+ throw new Error(`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`);
43156
42958
  }
43157
42959
  await source.syncWorkflow.getOrCreate({
43158
42960
  key: `${this.name}:${sourceId}`,
@@ -43184,9 +42986,7 @@ var BaseAction = class {
43184
42986
  handler;
43185
42987
  constructor(props) {
43186
42988
  if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
43187
- throw new Error(
43188
- `Action name "${props.name}" must be alphanumeric with no special characters or spaces`
43189
- );
42989
+ throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
43190
42990
  }
43191
42991
  this.name = props.name;
43192
42992
  if (props.title !== void 0) {
@@ -43232,9 +43032,7 @@ var BaseAction = class {
43232
43032
  /**
43233
43033
  * Execute the action with input validation and output validation
43234
43034
  */
43235
- async execute({
43236
- input
43237
- }) {
43035
+ async execute({ input }) {
43238
43036
  return this.handler(input);
43239
43037
  }
43240
43038
  };
@@ -43322,6 +43120,7 @@ var BaseTable = class {
43322
43120
  for (const col of Object.keys(this.columns)) {
43323
43121
  if (this.computedColumns.has(col) || this.nullableColumns.has(col)) {
43324
43122
  if ("properties" in schema && schema.properties && col in schema.properties && typeof schema.properties[col] === "object" && schema.properties[col] !== null) {
43123
+ ;
43325
43124
  schema.properties[col].nullable = true;
43326
43125
  }
43327
43126
  if ("required" in schema && Array.isArray(schema.required)) {
@@ -43447,10 +43246,7 @@ var Typings6;
43447
43246
  Typings8.Primitive = "trigger";
43448
43247
  })(Typings6 || (Typings6 = {}));
43449
43248
  var TriggerSchema = z11.object({
43450
- name: z11.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(
43451
- /^[a-zA-Z0-9_]+$/,
43452
- "Trigger name must contain only alphanumeric characters and underscores"
43453
- ),
43249
+ name: z11.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"),
43454
43250
  description: z11.string().max(1024, "Description must be less than 1024 characters").optional(),
43455
43251
  events: z11.array(z11.string()),
43456
43252
  handler: z11.function().describe("Handler function for the trigger")
@@ -43463,10 +43259,7 @@ var Trigger = class {
43463
43259
  constructor(props) {
43464
43260
  const result = TriggerSchema.safeParse(props);
43465
43261
  if (!result.success) {
43466
- throw new Errors.InvalidPrimitiveError(
43467
- "Trigger validation failed",
43468
- result.error
43469
- );
43262
+ throw new Errors.InvalidPrimitiveError("Trigger validation failed", result.error);
43470
43263
  }
43471
43264
  this.name = result.data.name;
43472
43265
  this.description = result.data.description;
@@ -43552,9 +43345,7 @@ var bot = {
43552
43345
  get state() {
43553
43346
  const botId = context2.get("botId");
43554
43347
  const states = context2.get("states", { optional: true }) ?? [];
43555
- const state = states.find(
43556
- (x) => x.type === "bot" && x.name === "botState" && x.id === botId
43557
- );
43348
+ const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
43558
43349
  if (!state) {
43559
43350
  throw new Error("Bot state not initialized.");
43560
43351
  }
@@ -43563,9 +43354,7 @@ var bot = {
43563
43354
  set state(value) {
43564
43355
  const botId = context2.get("botId");
43565
43356
  const states = context2.get("states", { optional: true }) ?? [];
43566
- const state = states.find(
43567
- (x) => x.type === "bot" && x.name === "botState" && x.id === botId
43568
- );
43357
+ const state = states.find((x) => x.type === "bot" && x.name === "botState" && x.id === botId);
43569
43358
  if (!state) {
43570
43359
  throw new Error("Bot state not initialized.");
43571
43360
  }
@@ -43579,9 +43368,7 @@ var user = {
43579
43368
  throw new Error("User not found in context.");
43580
43369
  }
43581
43370
  const states = context2.get("states", { optional: true }) ?? [];
43582
- const state = states.find(
43583
- (x) => x.type === "user" && x.name === "userState" && x.id === user2.id
43584
- );
43371
+ const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
43585
43372
  if (!state) {
43586
43373
  throw new Error("User state not initialized.");
43587
43374
  }
@@ -43593,9 +43380,7 @@ var user = {
43593
43380
  throw new Error("User not found in context.");
43594
43381
  }
43595
43382
  const states = context2.get("states", { optional: true }) ?? [];
43596
- const state = states.find(
43597
- (x) => x.type === "user" && x.name === "userState" && x.id === user2.id
43598
- );
43383
+ const state = states.find((x) => x.type === "user" && x.name === "userState" && x.id === user2.id);
43599
43384
  if (!state) {
43600
43385
  throw new Error("User state not initialized.");
43601
43386
  }
@@ -43660,10 +43445,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
43660
43445
  import { transforms as transforms3 } from "@botpress/sdk";
43661
43446
  var DEFAULT_MAX_ATTEMPTS = 5;
43662
43447
  var MIN_STEP_REMAINING_TIME_MS = 1e4;
43663
- var storage2 = getSingleton(
43664
- "__ADK_GLOBAL_CTX_WORKFLOW_STEP",
43665
- () => new AsyncLocalStorage3()
43666
- );
43448
+ var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
43667
43449
  async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
43668
43450
  spanFunc,
43669
43451
  stepType
@@ -43681,9 +43463,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
43681
43463
  }
43682
43464
  const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
43683
43465
  if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
43684
- await new Promise(
43685
- (resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
43686
- );
43466
+ await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
43687
43467
  throw createStepSignal();
43688
43468
  }
43689
43469
  const stepContext = storage2.getStore();
@@ -43763,13 +43543,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
43763
43543
  }
43764
43544
  if (shouldRetry) {
43765
43545
  await new Promise(
43766
- (resolve) => setTimeout(
43767
- resolve,
43768
- Math.min(
43769
- 100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1),
43770
- 5e3
43771
- )
43772
- )
43546
+ (resolve) => setTimeout(resolve, Math.min(100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1), 5e3))
43773
43547
  );
43774
43548
  continue;
43775
43549
  }
@@ -43874,10 +43648,7 @@ step.sleep = async (name, ms3) => {
43874
43648
  );
43875
43649
  };
43876
43650
  step.sleepUntil = async (name, date) => {
43877
- const ms3 = Math.max(
43878
- 0,
43879
- new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS
43880
- );
43651
+ const ms3 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
43881
43652
  await step.sleep(name, ms3);
43882
43653
  };
43883
43654
  step.waitForWorkflow = async (name, workflowId) => {
@@ -43923,10 +43694,9 @@ step.executeWorkflow = async (name, workflow, input) => _step(
43923
43694
  // Ensures idempotency
43924
43695
  })).id
43925
43696
  );
43926
- return _step(
43927
- `${name}-wait`,
43928
- async () => step.waitForWorkflow(`${name}-wait`, wfId)
43929
- ).then((finishedWorkflow) => finishedWorkflow.output);
43697
+ return _step(`${name}-wait`, async () => step.waitForWorkflow(`${name}-wait`, wfId)).then(
43698
+ (finishedWorkflow) => finishedWorkflow.output
43699
+ );
43930
43700
  },
43931
43701
  {}
43932
43702
  );
@@ -43943,9 +43713,7 @@ async function processWithConcurrency(items, processor, maxConcurrency = 5) {
43943
43713
  }
43944
43714
  const remainingTime = context2.get("runtime").getRemainingExecutionTimeInMs();
43945
43715
  if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
43946
- await new Promise(
43947
- (resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
43948
- );
43716
+ await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
43949
43717
  throw createStepSignal();
43950
43718
  }
43951
43719
  const promise = processor(items[i], i).then((result) => {
@@ -44013,17 +43781,11 @@ step.request = async (request, message, stepName) => {
44013
43781
  const workflowControlContext = context2.get("workflowControlContext");
44014
43782
  const client = context2.get("client");
44015
43783
  if (!workflowControlContext.workflow.conversationId) {
44016
- throw new Error(
44017
- `Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`
44018
- );
43784
+ throw new Error(`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`);
44019
43785
  }
44020
- const workflowDef = adk.project.workflows.find(
44021
- (w) => w.name === workflowControlContext.workflow.name
44022
- );
43786
+ const workflowDef = adk.project.workflows.find((w) => w.name === workflowControlContext.workflow.name);
44023
43787
  if (!workflowDef) {
44024
- throw new Error(
44025
- `Workflow definition not found for "${workflowControlContext.workflow.name}"`
44026
- );
43788
+ throw new Error(`Workflow definition not found for "${workflowControlContext.workflow.name}"`);
44027
43789
  }
44028
43790
  const requestSchema = workflowDef._requestsSchemas?.[request];
44029
43791
  if (!requestSchema) {
@@ -44031,10 +43793,7 @@ step.request = async (request, message, stepName) => {
44031
43793
  `Request "${request}" not found in workflow "${workflowDef.name}". Available requests: ${Object.keys(workflowDef._requestsSchemas || {}).join(", ") || "none"}`
44032
43794
  );
44033
43795
  }
44034
- const state = createWorkflowExecutionState(
44035
- client._inner,
44036
- workflowControlContext.workflow.id
44037
- );
43796
+ const state = createWorkflowExecutionState(client._inner, workflowControlContext.workflow.id);
44038
43797
  if (!state.value) {
44039
43798
  throw new Error("Workflow execution state not loaded");
44040
43799
  }
@@ -44114,9 +43873,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44114
43873
  // @internal
44115
43874
  TrackedState;
44116
43875
  constructor(workflow, client) {
44117
- const definition = adk.project.workflows.find(
44118
- (w) => w.name === workflow.name
44119
- );
43876
+ const definition = adk.project.workflows.find((w) => w.name === workflow.name);
44120
43877
  this.TrackedState = TrackedState2.create({
44121
43878
  type: "workflow",
44122
43879
  client: client._inner,
@@ -44139,9 +43896,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44139
43896
  const client = context2.get("client");
44140
43897
  const workflow = props.workflow ? props.workflow : await client.getWorkflow({ id: props.id }).then((x) => x.workflow);
44141
43898
  if (!adk.project.workflows.find((w) => w.name === workflow.name)) {
44142
- throw new Error(
44143
- `No ADK Workflow definition found for "${workflow.name}"`
44144
- );
43899
+ throw new Error(`No ADK Workflow definition found for "${workflow.name}"`);
44145
43900
  }
44146
43901
  return new _BaseWorkflowInstance(workflow, client);
44147
43902
  }
@@ -44168,10 +43923,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44168
43923
  */
44169
43924
  async provide(request, data) {
44170
43925
  const client = context2.get("client");
44171
- const state = createWorkflowExecutionState(
44172
- client._inner,
44173
- this.id
44174
- );
43926
+ const state = createWorkflowExecutionState(client._inner, this.id);
44175
43927
  await state.load();
44176
43928
  if (!state.value) {
44177
43929
  throw new Error(`Workflow execution state not found for workflow ${this.id}`);
@@ -44198,13 +43950,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44198
43950
  }
44199
43951
  // @internal
44200
43952
  async handle() {
44201
- const handler = adk.project.workflows.find(
44202
- (w) => w.name === this.name
44203
- )._handler;
43953
+ const handler = adk.project.workflows.find((w) => w.name === this.name)._handler;
44204
43954
  if (!handler) {
44205
- throw new Error(
44206
- `No ADK Workflow handler found for "${this.name}"`
44207
- );
43955
+ throw new Error(`No ADK Workflow handler found for "${this.name}"`);
44208
43956
  }
44209
43957
  await TrackedState2.loadAll();
44210
43958
  const workflowControlContext = {
@@ -44229,9 +43977,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44229
43977
  }
44230
43978
  const eventId = context2.get("event")?.id;
44231
43979
  if (!eventId) {
44232
- throw new Error(
44233
- `Event ID not found in context. Cannot ack workflow ${this.id}`
44234
- );
43980
+ throw new Error(`Event ID not found in context. Cannot ack workflow ${this.id}`);
44235
43981
  }
44236
43982
  workflowControlContext.acked = true;
44237
43983
  await updateWorkflow({
@@ -44243,15 +43989,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
44243
43989
  };
44244
43990
  try {
44245
43991
  const ctx = context2.getAll();
44246
- const workflowExecutionState = createWorkflowExecutionState(
44247
- ctx.client._inner,
44248
- this.id
44249
- );
43992
+ const workflowExecutionState = createWorkflowExecutionState(ctx.client._inner, this.id);
44250
43993
  await workflowExecutionState.load();
44251
- assert2(
44252
- workflowExecutionState.value,
44253
- "Workflow execution state is not loaded"
44254
- );
43994
+ assert2(workflowExecutionState.value, "Workflow execution state is not loaded");
44255
43995
  workflowExecutionState.value.executionCount++;
44256
43996
  if (!this.TrackedState.value) {
44257
43997
  this.TrackedState.value = {};
@@ -44418,12 +44158,7 @@ var BaseWorkflow = class {
44418
44158
  */
44419
44159
  async getOrCreate(props) {
44420
44160
  const client = context2.get("client");
44421
- const statuses = props.statuses || [
44422
- "pending",
44423
- "in_progress",
44424
- "listening",
44425
- "paused"
44426
- ];
44161
+ const statuses = props.statuses || ["pending", "in_progress", "listening", "paused"];
44427
44162
  const validatedInput = this._inputSchema.parse(props.input);
44428
44163
  const tags = {};
44429
44164
  if (props.key) {
@@ -44437,9 +44172,7 @@ var BaseWorkflow = class {
44437
44172
  tags,
44438
44173
  conversationId: context2.get("conversation", { optional: true })?.id,
44439
44174
  parentWorkflowId: context2.get("workflow", { optional: true })?.id,
44440
- timeoutAt: new Date(
44441
- Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
44442
- ).toISOString(),
44175
+ timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString(),
44443
44176
  ...discriminator && { discriminateBy: { tags: discriminator } }
44444
44177
  };
44445
44178
  let { workflow } = await client._inner.getOrCreateWorkflow(createArgs);
@@ -44465,21 +44198,12 @@ var BaseWorkflow = class {
44465
44198
  async provide(event, data) {
44466
44199
  const client = context2.get("client");
44467
44200
  const { workflowId, stepName } = event.payload;
44468
- const state = createWorkflowExecutionState(
44469
- client._inner,
44470
- workflowId
44471
- );
44201
+ const state = createWorkflowExecutionState(client._inner, workflowId);
44472
44202
  await state.load();
44473
44203
  if (!state.value) {
44474
- throw new Error(
44475
- `Workflow execution state not found for workflow ${workflowId}`
44476
- );
44204
+ throw new Error(`Workflow execution state not found for workflow ${workflowId}`);
44477
44205
  }
44478
- console.log(
44479
- `Providing data to workflow ${workflowId} step ${stepName}`,
44480
- data,
44481
- stepName
44482
- );
44206
+ console.log(`Providing data to workflow ${workflowId} step ${stepName}`, data, stepName);
44483
44207
  if (!state.value.steps[stepName]) {
44484
44208
  state.value.steps[stepName] = {
44485
44209
  output: data,
@@ -44511,9 +44235,7 @@ var BaseWorkflow = class {
44511
44235
  input: validatedInput,
44512
44236
  parentWorkflowId: workflow?.id,
44513
44237
  conversationId: context2.get("conversation", { optional: true })?.id,
44514
- timeoutAt: new Date(
44515
- Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
44516
- ).toISOString()
44238
+ timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString()
44517
44239
  });
44518
44240
  return await BaseWorkflowInstance.load({
44519
44241
  id: res.workflow.id,
@@ -44664,12 +44386,8 @@ var adk = {
44664
44386
  config: state.projectConfig,
44665
44387
  integrations: Object.assign(state.primitives.integrations, {
44666
44388
  get(name) {
44667
- const byAlias = state.primitives.integrations.find(
44668
- (int) => int.alias === name
44669
- );
44670
- const byName = state.primitives.integrations.find(
44671
- (int) => int.definition.name === name
44672
- );
44389
+ const byAlias = state.primitives.integrations.find((int) => int.alias === name);
44390
+ const byName = state.primitives.integrations.find((int) => int.definition.name === name);
44673
44391
  return byAlias || byName;
44674
44392
  }
44675
44393
  }),
@@ -44767,9 +44485,7 @@ var TrackedState2 = class _TrackedState {
44767
44485
  }
44768
44486
  static create(props) {
44769
44487
  const states = context2.get("states", { optional: true });
44770
- const match2 = states?.find(
44771
- (x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state")
44772
- );
44488
+ const match2 = states?.find((x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state"));
44773
44489
  if (match2) {
44774
44490
  return match2;
44775
44491
  }
@@ -44849,9 +44565,7 @@ var TrackedState2 = class _TrackedState {
44849
44565
  });
44850
44566
  }
44851
44567
  const states = context2.get("states", { optional: true });
44852
- const promises = Promise.allSettled(
44853
- states?.map((state) => state.load()) ?? []
44854
- );
44568
+ const promises = Promise.allSettled(states?.map((state) => state.load()) ?? []);
44855
44569
  void importScheduledHeavyImports();
44856
44570
  await promises;
44857
44571
  });
@@ -44886,9 +44600,7 @@ var TrackedState2 = class _TrackedState {
44886
44600
  const { data } = await axios_default.get(file.url);
44887
44601
  this.value = typeof data === "string" ? JSON.parse(data) : data;
44888
44602
  } catch (err) {
44889
- console.error(
44890
- `Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`
44891
- );
44603
+ console.error(`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`);
44892
44604
  this.value = void 0;
44893
44605
  }
44894
44606
  } else {
@@ -44974,9 +44686,7 @@ var TrackedState2 = class _TrackedState {
44974
44686
  contentType: "application/json",
44975
44687
  content: JSON.stringify(this.value),
44976
44688
  accessPolicies: [],
44977
- expiresAt: new Date(
44978
- Date.now() + 30 * 24 * 60 * 60 * 1e3
44979
- ).toISOString(),
44689
+ expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString(),
44980
44690
  tags: {
44981
44691
  system: "true",
44982
44692
  purpose: "swap"
@@ -44996,9 +44706,7 @@ var TrackedState2 = class _TrackedState {
44996
44706
  error: err instanceof Error ? err.message : String(err),
44997
44707
  size_bytes: stateSize
44998
44708
  });
44999
- console.error(
45000
- `Failed to swap state: ${err instanceof Error ? err.message : String(err)}`
45001
- );
44709
+ console.error(`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`);
45002
44710
  payload = {
45003
44711
  value: this.value,
45004
44712
  location: { type: "state" }
@@ -45118,9 +44826,7 @@ async function handleInspectorChrome() {
45118
44826
  let devtoolsFrontendUrl = null;
45119
44827
  if (inspectorPort && inspectorUrl) {
45120
44828
  try {
45121
- const response = await fetch(
45122
- `http://127.0.0.1:${inspectorPort}/json/list`
45123
- );
44829
+ const response = await fetch(`http://127.0.0.1:${inspectorPort}/json/list`);
45124
44830
  const data = await response.json();
45125
44831
  if (data && data.length > 0 && data[0]) {
45126
44832
  webSocketDebuggerUrl = data[0].webSocketDebuggerUrl || null;
@@ -45294,10 +45000,7 @@ var patchHandlers = (bot2) => {
45294
45000
  }
45295
45001
  }
45296
45002
  const RUNTIME_SAFETY_MARGIN = 5e3;
45297
- const remainingTime = Math.max(
45298
- lambdaCtx.getRemainingTimeInMillis() - RUNTIME_SAFETY_MARGIN,
45299
- 100
45300
- );
45003
+ const remainingTime = Math.max(lambdaCtx.getRemainingTimeInMillis() - RUNTIME_SAFETY_MARGIN, 100);
45301
45004
  return await new Promise(async (resolve, reject) => {
45302
45005
  const started = Date.now();
45303
45006
  const timeout = setTimeout(
@@ -45343,6 +45046,7 @@ var patchHandlers = (bot2) => {
45343
45046
  props.client.getConversation({
45344
45047
  id: props.event.conversationId
45345
45048
  }).then(({ conversation }) => {
45049
+ ;
45346
45050
  props.conversation = conversation;
45347
45051
  }).catch(() => {
45348
45052
  })
@@ -45354,6 +45058,7 @@ var patchHandlers = (bot2) => {
45354
45058
  // @ts-ignore
45355
45059
  id: props.event.workflowId
45356
45060
  }).then(({ workflow }) => {
45061
+ ;
45357
45062
  props.workflow = workflow;
45358
45063
  }).catch(() => {
45359
45064
  })
@@ -45364,6 +45069,7 @@ var patchHandlers = (bot2) => {
45364
45069
  props.client.getUser({
45365
45070
  id: props.event.userId
45366
45071
  }).then(({ user: user2 }) => {
45072
+ ;
45367
45073
  props.user = user2;
45368
45074
  }).catch(() => {
45369
45075
  })
@@ -45421,11 +45127,7 @@ init_define_PACKAGE_VERSIONS();
45421
45127
  // src/runtime/chat/chat.ts
45422
45128
  init_define_BUILD();
45423
45129
  init_define_PACKAGE_VERSIONS();
45424
- import {
45425
- Chat,
45426
- DefaultComponents,
45427
- isAnyComponent as isAnyComponent2
45428
- } from "llmz";
45130
+ import { Chat, DefaultComponents, isAnyComponent as isAnyComponent2 } from "llmz";
45429
45131
 
45430
45132
  // src/runtime/chat/truncate-transcript.ts
45431
45133
  init_define_BUILD();
@@ -45961,17 +45663,12 @@ var BotpressChat = class extends Chat {
45961
45663
  const items = this._transcript?.splice(
45962
45664
  0,
45963
45665
  // We want to keep the last N items as higher-precision context
45964
- Math.max(
45965
- this._transcript.length - Config.Transcript.SUMMARY_END_PADDING,
45966
- 0
45967
- )
45666
+ Math.max(this._transcript.length - Config.Transcript.SUMMARY_END_PADDING, 0)
45968
45667
  );
45969
45668
  try {
45970
- const summary = await adk.zai.summarize(
45971
- JSON.stringify(items, null, 2),
45972
- {
45973
- length: 250,
45974
- prompt: dedent_default`
45669
+ const summary = await adk.zai.summarize(JSON.stringify(items, null, 2), {
45670
+ length: 250,
45671
+ prompt: dedent_default`
45975
45672
  You are a transcript summarizer tasked with compressing a long conversation between a user and an AI agent.
45976
45673
  Your goal is to drastically reduce the transcript length while retaining all key information, decisions, facts, user goals, and outputs.
45977
45674
 
@@ -45985,8 +45682,7 @@ var BotpressChat = class extends Chat {
45985
45682
 
45986
45683
  The final output should feel like a high-value executive summary of a working session, not a chat log.
45987
45684
  `.trim()
45988
- }
45989
- );
45685
+ });
45990
45686
  this._transcript?.unshift({
45991
45687
  id: `summary-${Date.now()}`,
45992
45688
  role: "summary",
@@ -46037,9 +45733,7 @@ var BotpressChat = class extends Chat {
46037
45733
  "message.type": message.type
46038
45734
  },
46039
45735
  async (s) => {
46040
- const [payload, citations] = this.citations.removeCitationsFromObject(
46041
- message.payload
46042
- );
45736
+ const [payload, citations] = this.citations.removeCitationsFromObject(message.payload);
46043
45737
  const { message: created } = await this.client.createMessage({
46044
45738
  conversationId: this.conversation.id,
46045
45739
  tags: message.tags || {},
@@ -46095,9 +45789,7 @@ var BotpressChat = class extends Chat {
46095
45789
  (c) => c.definition.name.toLowerCase() === message.type.toLowerCase() || c.definition.aliases?.map((x) => x.toLowerCase()).includes(message.type.toLowerCase())
46096
45790
  );
46097
45791
  if (!component) {
46098
- throw new Error(
46099
- `Could not find component for message type "${message.type}"`
46100
- );
45792
+ throw new Error(`Could not find component for message type "${message.type}"`);
46101
45793
  }
46102
45794
  await this.sendMessage({
46103
45795
  type: component.definition.name,
@@ -46199,9 +45891,7 @@ ${footer}`.trim();
46199
45891
  return cleaned.trim();
46200
45892
  }
46201
45893
  if (Array.isArray(obj)) {
46202
- return obj.map(
46203
- (item) => expandCitationsInObject(item, citationsManager)
46204
- );
45894
+ return obj.map((item) => expandCitationsInObject(item, citationsManager));
46205
45895
  }
46206
45896
  if (obj && typeof obj === "object") {
46207
45897
  const result = {};
@@ -46223,12 +45913,7 @@ var AttachmentSchema = z23.object({
46223
45913
  });
46224
45914
  var TranscriptItemSchema = z23.object({
46225
45915
  id: z23.string(),
46226
- role: z23.union([
46227
- z23.literal("assistant"),
46228
- z23.literal("user"),
46229
- z23.literal("event"),
46230
- z23.literal("summary")
46231
- ]),
45916
+ role: z23.union([z23.literal("assistant"), z23.literal("user"), z23.literal("event"), z23.literal("summary")]),
46232
45917
  name: z23.string().optional(),
46233
45918
  createdAt: z23.string().optional(),
46234
45919
  content: z23.string().optional(),
@@ -46262,9 +45947,7 @@ function matchesChannel(handlerChannel, incomingChannel) {
46262
45947
  }
46263
45948
  }
46264
45949
  function findMatchingHandler(handlers2, incomingChannel) {
46265
- const matchingHandlers = handlers2.filter(
46266
- (h) => matchesChannel(h.channel, incomingChannel)
46267
- );
45950
+ const matchingHandlers = handlers2.filter((h) => matchesChannel(h.channel, incomingChannel));
46268
45951
  return matchingHandlers.sort((a, b) => {
46269
45952
  const aScore = a.channel === "*" ? 0 : Array.isArray(a.channel) ? 1 : 2;
46270
45953
  const bScore = b.channel === "*" ? 0 : Array.isArray(b.channel) ? 1 : 2;
@@ -46274,53 +45957,42 @@ function findMatchingHandler(handlers2, incomingChannel) {
46274
45957
 
46275
45958
  // src/runtime/handlers/conversation.ts
46276
45959
  var setup = (bot2) => {
46277
- bot2.on.message(
46278
- "*",
46279
- async ({ conversation, message, logger, ctx, event, user: user2 }) => {
46280
- await span(
46281
- "handler.conversation",
46282
- {
46283
- botId: ctx.botId,
46284
- conversationId: conversation.id,
46285
- eventId: event.id,
46286
- integration: conversation.integration,
46287
- channel: conversation.channel,
46288
- "event.type": event.type,
46289
- messageId: message.id,
46290
- userId: user2.id,
46291
- "message.type": message.type,
46292
- "message.payload": message.payload,
46293
- "event.payload": event.payload
46294
- },
46295
- async () => {
46296
- const handlerName = conversation.integration + "." + conversation.channel;
46297
- const handler = findMatchingHandler(
46298
- adk.project.conversations,
46299
- handlerName
46300
- );
46301
- if (!handler) {
46302
- logger.debug(
46303
- `Skipping message, no ADK Conversation defined for "${handlerName}"`
46304
- );
46305
- return;
46306
- }
46307
- const chat = new BotpressChat(context2.getAll());
46308
- context2.set("chat", chat);
46309
- const [transcript, _statesLoaded] = await Promise.all([
46310
- chat.fetchTranscript(),
46311
- TrackedState2.loadAll()
46312
- ]);
46313
- if (transcript.find((x) => x.id === message.id)) {
46314
- return;
46315
- }
46316
- await chat.addMessage(message);
46317
- await handler[ConversationHandler]();
46318
- await TrackedState2.saveAllDirty();
46319
- await chat.saveTranscript();
45960
+ bot2.on.message("*", async ({ conversation, message, logger, ctx, event, user: user2 }) => {
45961
+ await span(
45962
+ "handler.conversation",
45963
+ {
45964
+ botId: ctx.botId,
45965
+ conversationId: conversation.id,
45966
+ eventId: event.id,
45967
+ integration: conversation.integration,
45968
+ channel: conversation.channel,
45969
+ "event.type": event.type,
45970
+ messageId: message.id,
45971
+ userId: user2.id,
45972
+ "message.type": message.type,
45973
+ "message.payload": message.payload,
45974
+ "event.payload": event.payload
45975
+ },
45976
+ async () => {
45977
+ const handlerName = conversation.integration + "." + conversation.channel;
45978
+ const handler = findMatchingHandler(adk.project.conversations, handlerName);
45979
+ if (!handler) {
45980
+ logger.debug(`Skipping message, no ADK Conversation defined for "${handlerName}"`);
45981
+ return;
46320
45982
  }
46321
- );
46322
- }
46323
- );
45983
+ const chat = new BotpressChat(context2.getAll());
45984
+ context2.set("chat", chat);
45985
+ const [transcript, _statesLoaded] = await Promise.all([chat.fetchTranscript(), TrackedState2.loadAll()]);
45986
+ if (transcript.find((x) => x.id === message.id)) {
45987
+ return;
45988
+ }
45989
+ await chat.addMessage(message);
45990
+ await handler[ConversationHandler]();
45991
+ await TrackedState2.saveAllDirty();
45992
+ await chat.saveTranscript();
45993
+ }
45994
+ );
45995
+ });
46324
45996
  };
46325
45997
 
46326
45998
  // src/runtime/handlers/trigger.ts
@@ -46342,13 +46014,9 @@ var setup2 = (bot2) => {
46342
46014
  }
46343
46015
  const [integration, event] = name.split(":");
46344
46016
  const names = /* @__PURE__ */ new Set([name]);
46345
- const int = adk.project.integrations.find(
46346
- (x) => x.alias === integration || x.definition.name === integration
46347
- );
46017
+ const int = adk.project.integrations.find((x) => x.alias === integration || x.definition.name === integration);
46348
46018
  if (!int) {
46349
- console.warn(
46350
- `Integration "${integration}" not found for event "${name}". Skipping trigger registration.`
46351
- );
46019
+ console.warn(`Integration "${integration}" not found for event "${name}". Skipping trigger registration.`);
46352
46020
  continue;
46353
46021
  }
46354
46022
  names.add(`${int.definition.name}:${event}`);
@@ -46368,9 +46036,7 @@ var setup2 = (bot2) => {
46368
46036
  userId: event2.userId
46369
46037
  },
46370
46038
  async () => {
46371
- console.log(
46372
- `Evaluating trigger "${trigger.name}" for event "${originalName}" (mapped to "${name2}")`
46373
- );
46039
+ console.log(`Evaluating trigger "${trigger.name}" for event "${originalName}" (mapped to "${name2}")`);
46374
46040
  await trigger.handler({
46375
46041
  event: {
46376
46042
  ...event2,
@@ -46395,13 +46061,7 @@ init_define_PACKAGE_VERSIONS();
46395
46061
  init_esm();
46396
46062
  var import_ms2 = __toESM(require_ms(), 1);
46397
46063
  var setup3 = (bot2) => {
46398
- const handler = async function({
46399
- workflow,
46400
- event,
46401
- client,
46402
- ctx,
46403
- conversation
46404
- }) {
46064
+ const handler = async function({ workflow, event, client, ctx, conversation }) {
46405
46065
  await span(
46406
46066
  "handler.workflow",
46407
46067
  {
@@ -46417,9 +46077,7 @@ var setup3 = (bot2) => {
46417
46077
  "workflow.status.initial": workflow.status
46418
46078
  },
46419
46079
  async (s) => {
46420
- const workflowDefinition = adk.project.workflows.find(
46421
- (w) => w.name === workflow.name
46422
- );
46080
+ const workflowDefinition = adk.project.workflows.find((w) => w.name === workflow.name);
46423
46081
  if (!workflowDefinition?._handler) {
46424
46082
  console.warn(`No ADK Workflow handler found for "${workflow.name}"`);
46425
46083
  s.setAttribute("handler", false);
@@ -46437,9 +46095,7 @@ var setup3 = (bot2) => {
46437
46095
  const currentTimeoutDuration = currentTimeoutAt - workflowStartedAt;
46438
46096
  const isDefaultTimeout = Math.abs(currentTimeoutDuration - DEFAULT_TIMEOUT_MS) < 1e4;
46439
46097
  if (isDefaultTimeout) {
46440
- const newTimeoutAt = new Date(
46441
- workflowStartedAt + configuredTimeout
46442
- ).toISOString();
46098
+ const newTimeoutAt = new Date(workflowStartedAt + configuredTimeout).toISOString();
46443
46099
  await updateWorkflow({
46444
46100
  id: workflow.id,
46445
46101
  timeoutAt: newTimeoutAt
@@ -46577,26 +46233,19 @@ __export(event_exports, {
46577
46233
  init_define_BUILD();
46578
46234
  init_define_PACKAGE_VERSIONS();
46579
46235
  var setup4 = (bot2) => {
46580
- const conversationEventTypes = [
46581
- WorkflowCallbackEvent.name,
46582
- WorkflowDataRequestEvent.name
46583
- ];
46236
+ const conversationEventTypes = [WorkflowCallbackEvent.name, WorkflowDataRequestEvent.name];
46584
46237
  for (const eventType of conversationEventTypes) {
46585
46238
  bot2.on.event(eventType, async ({ event, client, logger, ctx }) => {
46586
46239
  const payload = event.payload;
46587
46240
  const conversation = context2.get("conversation");
46588
46241
  if (!conversation) {
46589
- logger.warn(
46590
- `Skipping ${WorkflowCallbackEvent.name} event, conversation not found in context`
46591
- );
46242
+ logger.warn(`Skipping ${WorkflowCallbackEvent.name} event, conversation not found in context`);
46592
46243
  return;
46593
46244
  }
46594
46245
  const handlerName = conversation.integration + "." + conversation.channel;
46595
46246
  const handler = findMatchingHandler(adk.project.conversations, handlerName);
46596
46247
  if (!handler) {
46597
- logger.debug(
46598
- `Skipping message, no ADK Conversation defined for "${handlerName}"`
46599
- );
46248
+ logger.debug(`Skipping message, no ADK Conversation defined for "${handlerName}"`);
46600
46249
  return;
46601
46250
  }
46602
46251
  await span(
@@ -46628,43 +46277,27 @@ var setup4 = (bot2) => {
46628
46277
  );
46629
46278
  });
46630
46279
  }
46631
- bot2.on.event(
46632
- WorkflowScheduleEvent.name,
46633
- async ({ event, client, logger }) => {
46634
- const payload = event.payload;
46635
- const workflowName = payload.workflow;
46636
- logger.info(
46637
- `Executing scheduled workflow: ${workflowName} at ${(/* @__PURE__ */ new Date()).toISOString()}`
46638
- );
46639
- try {
46640
- const workflowDefinition = adk.project.workflows.find(
46641
- (w) => w.name === workflowName
46642
- );
46643
- if (!workflowDefinition) {
46644
- logger.error(
46645
- `Workflow definition not found for: ${workflowName}`
46646
- );
46647
- return;
46648
- }
46649
- await client._inner.createWorkflow({
46650
- name: workflowName,
46651
- status: "pending",
46652
- input: {},
46653
- timeoutAt: new Date(
46654
- Date.now() + workflowDefinition.timeout
46655
- ).toISOString()
46656
- });
46657
- logger.info(
46658
- `Successfully created workflow instance for: ${workflowName}`
46659
- );
46660
- } catch (error) {
46661
- logger.error(
46662
- `Failed to create workflow instance for ${workflowName}:`,
46663
- error
46664
- );
46280
+ bot2.on.event(WorkflowScheduleEvent.name, async ({ event, client, logger }) => {
46281
+ const payload = event.payload;
46282
+ const workflowName = payload.workflow;
46283
+ logger.info(`Executing scheduled workflow: ${workflowName} at ${(/* @__PURE__ */ new Date()).toISOString()}`);
46284
+ try {
46285
+ const workflowDefinition = adk.project.workflows.find((w) => w.name === workflowName);
46286
+ if (!workflowDefinition) {
46287
+ logger.error(`Workflow definition not found for: ${workflowName}`);
46288
+ return;
46665
46289
  }
46290
+ await client._inner.createWorkflow({
46291
+ name: workflowName,
46292
+ status: "pending",
46293
+ input: {},
46294
+ timeoutAt: new Date(Date.now() + workflowDefinition.timeout).toISOString()
46295
+ });
46296
+ logger.info(`Successfully created workflow instance for: ${workflowName}`);
46297
+ } catch (error) {
46298
+ logger.error(`Failed to create workflow instance for ${workflowName}:`, error);
46666
46299
  }
46667
- );
46300
+ });
46668
46301
  };
46669
46302
 
46670
46303
  // src/runtime/handlers/index.ts
@@ -46795,15 +46428,7 @@ var IncomingRequestSpan = {
46795
46428
  },
46796
46429
  "request.method": {
46797
46430
  type: "enum",
46798
- enum: [
46799
- "GET",
46800
- "POST",
46801
- "PUT",
46802
- "DELETE",
46803
- "PATCH",
46804
- "HEAD",
46805
- "OPTIONS"
46806
- ],
46431
+ enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
46807
46432
  description: "The HTTP method",
46808
46433
  title: "HTTP Method",
46809
46434
  required: true
@@ -46962,14 +46587,7 @@ var BotpressClientSpan = {
46962
46587
  "botpress.request.body": { type: "string" },
46963
46588
  "botpress.response.body": { type: "string" },
46964
46589
  "trace.traceparent": { type: "string" },
46965
- ...optional(
46966
- "conversationId",
46967
- "messageId",
46968
- "workflowId",
46969
- "userId",
46970
- "eventId",
46971
- "action.name"
46972
- )
46590
+ ...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
46973
46591
  }
46974
46592
  };
46975
46593
  var HttpSpan = {
@@ -47001,21 +46619,8 @@ var ConversationHandlerSpan = {
47001
46619
  name: "handler.conversation",
47002
46620
  importance: "high",
47003
46621
  attributes: {
47004
- ...required(
47005
- "botId",
47006
- "conversationId",
47007
- "eventId",
47008
- "integration",
47009
- "channel",
47010
- "event.type"
47011
- ),
47012
- ...optional(
47013
- "messageId",
47014
- "userId",
47015
- "event.payload",
47016
- "message.payload",
47017
- "message.type"
47018
- )
46622
+ ...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
46623
+ ...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
47019
46624
  }
47020
46625
  };
47021
46626
  var TriggerHandlerSpan = {
@@ -47023,15 +46628,7 @@ var TriggerHandlerSpan = {
47023
46628
  importance: "high",
47024
46629
  attributes: {
47025
46630
  ...required("botId", "eventId", "event.type"),
47026
- ...optional(
47027
- "conversationId",
47028
- "messageId",
47029
- "userId",
47030
- "integration",
47031
- "channel",
47032
- "workflowId",
47033
- "parentWorkflowId"
47034
- )
46631
+ ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
47035
46632
  }
47036
46633
  };
47037
46634
  var EventHandlerSpan = {
@@ -47039,15 +46636,7 @@ var EventHandlerSpan = {
47039
46636
  importance: "high",
47040
46637
  attributes: {
47041
46638
  ...required("botId", "eventId", "event.type"),
47042
- ...optional(
47043
- "conversationId",
47044
- "messageId",
47045
- "userId",
47046
- "integration",
47047
- "channel",
47048
- "workflowId",
47049
- "parentWorkflowId"
47050
- )
46639
+ ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
47051
46640
  }
47052
46641
  };
47053
46642
  var WorkflowHandlerSpan = {
@@ -47055,27 +46644,11 @@ var WorkflowHandlerSpan = {
47055
46644
  importance: "high",
47056
46645
  attributes: {
47057
46646
  ...required("botId", "workflowId", "eventId", "event.type"),
47058
- ...optional(
47059
- "messageId",
47060
- "userId",
47061
- "integration",
47062
- "channel",
47063
- "conversationId",
47064
- "parentWorkflowId"
47065
- ),
46647
+ ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
47066
46648
  "workflow.name": { type: "string" },
47067
46649
  "workflow.status.initial": {
47068
46650
  type: "enum",
47069
- enum: [
47070
- "pending",
47071
- "in_progress",
47072
- "listening",
47073
- "paused",
47074
- "completed",
47075
- "failed",
47076
- "timedout",
47077
- "cancelled"
47078
- ]
46651
+ enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
47079
46652
  },
47080
46653
  "workflow.status.final": {
47081
46654
  type: "enum",
@@ -47101,14 +46674,7 @@ var ActionHandlerSpan = {
47101
46674
  importance: "high",
47102
46675
  attributes: {
47103
46676
  ...required("botId", "workflowId", "eventId", "event.type"),
47104
- ...optional(
47105
- "messageId",
47106
- "userId",
47107
- "integration",
47108
- "channel",
47109
- "conversationId",
47110
- "parentWorkflowId"
47111
- ),
46677
+ ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
47112
46678
  "action.name": { type: "string", required: true },
47113
46679
  "action.input": { type: "json", required: true }
47114
46680
  }
@@ -47493,9 +47059,7 @@ function span(name, attributes, optionsOrF, f) {
47493
47059
  options = optionsOrF;
47494
47060
  handler = f;
47495
47061
  }
47496
- const spanDef = Object.values(Spans).find(
47497
- (def) => def.name === name
47498
- );
47062
+ const spanDef = Object.values(Spans).find((def) => def.name === name);
47499
47063
  const attrsWithImportance = {
47500
47064
  ...attributes
47501
47065
  };
@@ -47524,20 +47088,13 @@ function span(name, attributes, optionsOrF, f) {
47524
47088
  }
47525
47089
  };
47526
47090
  if (parentContext) {
47527
- return tracer.startActiveSpan(
47528
- name,
47529
- spanOptions,
47530
- parentContext,
47531
- executeInSpan
47532
- );
47091
+ return tracer.startActiveSpan(name, spanOptions, parentContext, executeInSpan);
47533
47092
  } else {
47534
47093
  return tracer.startActiveSpan(name, spanOptions, executeInSpan);
47535
47094
  }
47536
47095
  }
47537
47096
  var createSpan = (name, attributes, { parentContext } = {}) => {
47538
- const spanDef = Object.values(Spans).find(
47539
- (def) => def.name === name
47540
- );
47097
+ const spanDef = Object.values(Spans).find((def) => def.name === name);
47541
47098
  const attrsWithImportance = {
47542
47099
  ...attributes
47543
47100
  };