@botpress/runtime 1.6.2 → 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 -6
package/dist/internal.js CHANGED
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
48
48
  var define_PACKAGE_VERSIONS_default;
49
49
  var init_define_PACKAGE_VERSIONS = __esm({
50
50
  "<define:__PACKAGE_VERSIONS__>"() {
51
- define_PACKAGE_VERSIONS_default = { runtime: "1.6.2", 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
 
@@ -34500,16 +34500,14 @@ init_define_BUILD();
34500
34500
  init_define_PACKAGE_VERSIONS();
34501
34501
  function getSingleton(key, factory2) {
34502
34502
  if (!globalThis[key]) {
34503
+ ;
34503
34504
  globalThis[key] = factory2();
34504
34505
  }
34505
34506
  return globalThis[key];
34506
34507
  }
34507
34508
 
34508
34509
  // src/runtime/context/context.ts
34509
- var storage = getSingleton(
34510
- "__ADK_GLOBAL_CTX_STORAGE",
34511
- () => new AsyncLocalStorage()
34512
- );
34510
+ var storage = getSingleton("__ADK_GLOBAL_CTX_STORAGE", () => new AsyncLocalStorage());
34513
34511
  var context = {
34514
34512
  enterWith: (data) => {
34515
34513
  storage.enterWith(data);
@@ -34524,10 +34522,7 @@ var context = {
34524
34522
  },
34525
34523
  getAll: () => {
34526
34524
  const store = storage.getStore();
34527
- if (!store)
34528
- throw new Error(
34529
- "No context found. Did you forget to call `context.run()`?"
34530
- );
34525
+ if (!store) throw new Error("No context found. Did you forget to call `context.run()`?");
34531
34526
  return store;
34532
34527
  },
34533
34528
  get: (key, opts) => {
@@ -34701,10 +34696,7 @@ var INDEX_DIR2 = path2.join(DIR2, "index");
34701
34696
  var append = (o) => fs2.appendFile(LIVE, JSON.stringify(o) + "\n", () => {
34702
34697
  });
34703
34698
  var appendToDay = (o) => {
34704
- const dayFile2 = path2.join(
34705
- DIR2,
34706
- `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
34707
- );
34699
+ const dayFile2 = path2.join(DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
34708
34700
  fs2.appendFile(dayFile2, JSON.stringify(o) + "\n", () => {
34709
34701
  });
34710
34702
  };
@@ -34714,10 +34706,7 @@ var appendToTrace = (traceId, o) => {
34714
34706
  });
34715
34707
  };
34716
34708
  var appendToIndex = (o) => {
34717
- const indexFile2 = path2.join(
34718
- INDEX_DIR2,
34719
- `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`
34720
- );
34709
+ const indexFile2 = path2.join(INDEX_DIR2, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.ndjson`);
34721
34710
  fs2.appendFile(indexFile2, JSON.stringify(o) + "\n", () => {
34722
34711
  });
34723
34712
  };
@@ -34731,8 +34720,7 @@ var LiveFileSpanProcessor = class {
34731
34720
  this.timer = setInterval(() => {
34732
34721
  if (!this.active.size) return;
34733
34722
  const ts = nowNs();
34734
- for (const [spanId, traceId] of this.active)
34735
- append({ t: "beat", traceId, spanId, ts });
34723
+ for (const [spanId, traceId] of this.active) append({ t: "beat", traceId, spanId, ts });
34736
34724
  }, beatMs);
34737
34725
  this.timer.unref?.();
34738
34726
  }
@@ -34742,9 +34730,7 @@ var LiveFileSpanProcessor = class {
34742
34730
  onStart(span2, _ctx) {
34743
34731
  const ctx = span2.spanContext();
34744
34732
  this.active.set(ctx.spanId, ctx.traceId);
34745
- const startNs = Number(
34746
- span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs()
34747
- );
34733
+ const startNs = Number(span2.startTime?.[0] != null ? span2.startTime[0] * 1e9 + span2.startTime[1] : nowNs());
34748
34734
  const startEvent = {
34749
34735
  t: "start",
34750
34736
  traceId: ctx.traceId,
@@ -34769,13 +34755,7 @@ var LiveFileSpanProcessor = class {
34769
34755
  handler: span2.name
34770
34756
  // Use span name as handler
34771
34757
  };
34772
- const trackedIds = [
34773
- "conversationId",
34774
- "messageId",
34775
- "eventId",
34776
- "userId",
34777
- "workflowId"
34778
- ];
34758
+ const trackedIds = ["conversationId", "messageId", "eventId", "userId", "workflowId"];
34779
34759
  for (const idKey of trackedIds) {
34780
34760
  if (span2.attributes[idKey]) {
34781
34761
  indexEntry[idKey] = span2.attributes[idKey];
@@ -34877,8 +34857,7 @@ function extractIds(fullUrl, body) {
34877
34857
  if (userMatch?.[1]) ids.userId = userMatch[1];
34878
34858
  if (eventMatch?.[1]) ids.eventId = eventMatch[1];
34879
34859
  if (body && typeof body === "object") {
34880
- if (body.conversationId && !ids.conversationId)
34881
- ids.conversationId = body.conversationId;
34860
+ if (body.conversationId && !ids.conversationId) ids.conversationId = body.conversationId;
34882
34861
  if (body.messageId && !ids.messageId) ids.messageId = body.messageId;
34883
34862
  if (body.workflowId && !ids.workflowId) ids.workflowId = body.workflowId;
34884
34863
  if (body.userId && !ids.userId) ids.userId = body.userId;
@@ -34886,9 +34865,7 @@ function extractIds(fullUrl, body) {
34886
34865
  }
34887
34866
  return ids;
34888
34867
  }
34889
- function installHttpClientInstrumentation({
34890
- injectTraceHeader = true
34891
- } = {}) {
34868
+ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
34892
34869
  const restores = [];
34893
34870
  const genId = (n) => randomBytes(n).toString("hex");
34894
34871
  const makeTraceparent = () => `00-${genId(16)}-${genId(8)}-01`;
@@ -34958,8 +34935,7 @@ function installHttpClientInstrumentation({
34958
34935
  },
34959
34936
  context2.active()
34960
34937
  );
34961
- if (injectTraceHeader && !("traceparent" in options.headers))
34962
- options.headers.traceparent = traceparent;
34938
+ if (injectTraceHeader && !("traceparent" in options.headers)) options.headers.traceparent = traceparent;
34963
34939
  let req;
34964
34940
  if (typeof args[0] === "string" || args[0] instanceof URL) {
34965
34941
  req = requestFn.call(this, args[0], options, cb);
@@ -34981,18 +34957,12 @@ function installHttpClientInstrumentation({
34981
34957
  }
34982
34958
  if (requestBodyChunks.length > 0) {
34983
34959
  const bodyString = Buffer.concat(requestBodyChunks).toString("utf-8");
34984
- span2.setAttribute(
34985
- isBotpress ? "botpress.request.body" : "http.request.body",
34986
- bodyString
34987
- );
34960
+ span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", bodyString);
34988
34961
  }
34989
34962
  return origEnd(chunk, ...args2);
34990
34963
  };
34991
34964
  req.on("response", (res) => {
34992
- span2.setAttribute(
34993
- isBotpress ? "botpress.status_code" : "http.status_code",
34994
- res.statusCode || 0
34995
- );
34965
+ span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
34996
34966
  const responseBodyChunks = [];
34997
34967
  res.on("data", (chunk) => {
34998
34968
  responseBodyChunks.push(chunk);
@@ -35000,10 +34970,7 @@ function installHttpClientInstrumentation({
35000
34970
  res.on("end", () => {
35001
34971
  if (responseBodyChunks.length > 0) {
35002
34972
  const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
35003
- span2.setAttribute(
35004
- isBotpress ? "botpress.response.body" : "http.response.body",
35005
- bodyString
35006
- );
34973
+ span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
35007
34974
  }
35008
34975
  if ((res.statusCode || 0) >= 400) {
35009
34976
  span2.setStatus({
@@ -35015,10 +34982,7 @@ function installHttpClientInstrumentation({
35015
34982
  });
35016
34983
  });
35017
34984
  req.on("error", (err) => {
35018
- span2.setAttribute(
35019
- isBotpress ? "botpress.error" : "http.error",
35020
- err.message
35021
- );
34985
+ span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
35022
34986
  span2.recordException(err);
35023
34987
  span2.setStatus({
35024
34988
  code: SpanStatusCode.ERROR,
@@ -35036,6 +35000,7 @@ function installHttpClientInstrumentation({
35036
35000
  httpsRequest: https.request,
35037
35001
  httpsGet: https.get
35038
35002
  };
35003
+ ;
35039
35004
  http.request = wrapRequest2(orig.httpRequest);
35040
35005
  https.request = wrapRequest2(orig.httpsRequest);
35041
35006
  http.get = function wrappedGet(...a) {
@@ -35129,10 +35094,7 @@ function installHttpClientInstrumentation({
35129
35094
  }
35130
35095
  }
35131
35096
  if (requestBody) {
35132
- span2.setAttribute(
35133
- isBotpress ? "botpress.request.body" : "http.request.body",
35134
- requestBody
35135
- );
35097
+ span2.setAttribute(isBotpress ? "botpress.request.body" : "http.request.body", requestBody);
35136
35098
  }
35137
35099
  }
35138
35100
  const traceparent = makeTraceparent();
@@ -35140,10 +35102,7 @@ function installHttpClientInstrumentation({
35140
35102
  if (Array.isArray(opts.headers)) {
35141
35103
  headers.push(...opts.headers);
35142
35104
  } else if (opts.headers && typeof opts.headers === "object") {
35143
- for (const [k, v] of Object.entries(
35144
- opts.headers
35145
- ))
35146
- headers.push(k, String(v));
35105
+ for (const [k, v] of Object.entries(opts.headers)) headers.push(k, String(v));
35147
35106
  }
35148
35107
  headers.push(INSTRUMENTED_HEADER, "true");
35149
35108
  if (injectTraceHeader) {
@@ -35161,10 +35120,7 @@ function installHttpClientInstrumentation({
35161
35120
  onConnect: handler.onConnect?.bind(handler),
35162
35121
  onUpgrade: handler.onUpgrade?.bind(handler),
35163
35122
  onHeaders: (statusCode, rawHeaders, resume) => {
35164
- span2.setAttribute(
35165
- isBotpress ? "botpress.status_code" : "http.status_code",
35166
- statusCode
35167
- );
35123
+ span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
35168
35124
  if (statusCode >= 500) {
35169
35125
  span2.setStatus({
35170
35126
  code: SpanStatusCode.ERROR,
@@ -35179,10 +35135,7 @@ function installHttpClientInstrumentation({
35179
35135
  handler.onHeaders?.(statusCode, rawHeaders, resume);
35180
35136
  },
35181
35137
  onError: (err) => {
35182
- span2.setAttribute(
35183
- isBotpress ? "botpress.error" : "http.error",
35184
- err.message
35185
- );
35138
+ span2.setAttribute(isBotpress ? "botpress.error" : "http.error", err.message);
35186
35139
  span2.recordException(err);
35187
35140
  span2.setStatus({
35188
35141
  code: SpanStatusCode.ERROR,
@@ -35199,10 +35152,7 @@ function installHttpClientInstrumentation({
35199
35152
  onComplete: (trailers) => {
35200
35153
  if (responseBodyChunks.length > 0) {
35201
35154
  const bodyString = Buffer.concat(responseBodyChunks).toString("utf-8");
35202
- span2.setAttribute(
35203
- isBotpress ? "botpress.response.body" : "http.response.body",
35204
- bodyString
35205
- );
35155
+ span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
35206
35156
  }
35207
35157
  span2.end();
35208
35158
  handler.onComplete?.(trailers);
@@ -35377,10 +35327,8 @@ function inspectToJsonSize(input, opts) {
35377
35327
  if (value === null) return null;
35378
35328
  const t = typeof value;
35379
35329
  if (t === "boolean" || t === "number") return value;
35380
- if (t === "string")
35381
- return elideString(value, limits2.head, limits2.tail);
35382
- if (t === "bigint")
35383
- return elideString(String(value), limits2.head, limits2.tail);
35330
+ if (t === "string") return elideString(value, limits2.head, limits2.tail);
35331
+ if (t === "bigint") return elideString(String(value), limits2.head, limits2.tail);
35384
35332
  if (t === "symbol" || t === "function" || t === "undefined") {
35385
35333
  return null;
35386
35334
  }
@@ -35435,8 +35383,7 @@ function inspectToJsonSize(input, opts) {
35435
35383
  const k = keys[i];
35436
35384
  props[k] = summarize(value[k], seen, nextLimits);
35437
35385
  }
35438
- if (keys.length > keep)
35439
- props["__truncated__"] = `+${keys.length - keep} keys`;
35386
+ if (keys.length > keep) props["__truncated__"] = `+${keys.length - keep} keys`;
35440
35387
  seen.delete(value);
35441
35388
  return { [`<${tag}>`]: props };
35442
35389
  }
@@ -35646,15 +35593,7 @@ var IncomingRequestSpan = {
35646
35593
  },
35647
35594
  "request.method": {
35648
35595
  type: "enum",
35649
- enum: [
35650
- "GET",
35651
- "POST",
35652
- "PUT",
35653
- "DELETE",
35654
- "PATCH",
35655
- "HEAD",
35656
- "OPTIONS"
35657
- ],
35596
+ enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
35658
35597
  description: "The HTTP method",
35659
35598
  title: "HTTP Method",
35660
35599
  required: true
@@ -35813,14 +35752,7 @@ var BotpressClientSpan = {
35813
35752
  "botpress.request.body": { type: "string" },
35814
35753
  "botpress.response.body": { type: "string" },
35815
35754
  "trace.traceparent": { type: "string" },
35816
- ...optional(
35817
- "conversationId",
35818
- "messageId",
35819
- "workflowId",
35820
- "userId",
35821
- "eventId",
35822
- "action.name"
35823
- )
35755
+ ...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
35824
35756
  }
35825
35757
  };
35826
35758
  var HttpSpan = {
@@ -35852,21 +35784,8 @@ var ConversationHandlerSpan = {
35852
35784
  name: "handler.conversation",
35853
35785
  importance: "high",
35854
35786
  attributes: {
35855
- ...required(
35856
- "botId",
35857
- "conversationId",
35858
- "eventId",
35859
- "integration",
35860
- "channel",
35861
- "event.type"
35862
- ),
35863
- ...optional(
35864
- "messageId",
35865
- "userId",
35866
- "event.payload",
35867
- "message.payload",
35868
- "message.type"
35869
- )
35787
+ ...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
35788
+ ...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
35870
35789
  }
35871
35790
  };
35872
35791
  var TriggerHandlerSpan = {
@@ -35874,15 +35793,7 @@ var TriggerHandlerSpan = {
35874
35793
  importance: "high",
35875
35794
  attributes: {
35876
35795
  ...required("botId", "eventId", "event.type"),
35877
- ...optional(
35878
- "conversationId",
35879
- "messageId",
35880
- "userId",
35881
- "integration",
35882
- "channel",
35883
- "workflowId",
35884
- "parentWorkflowId"
35885
- )
35796
+ ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
35886
35797
  }
35887
35798
  };
35888
35799
  var EventHandlerSpan = {
@@ -35890,15 +35801,7 @@ var EventHandlerSpan = {
35890
35801
  importance: "high",
35891
35802
  attributes: {
35892
35803
  ...required("botId", "eventId", "event.type"),
35893
- ...optional(
35894
- "conversationId",
35895
- "messageId",
35896
- "userId",
35897
- "integration",
35898
- "channel",
35899
- "workflowId",
35900
- "parentWorkflowId"
35901
- )
35804
+ ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
35902
35805
  }
35903
35806
  };
35904
35807
  var WorkflowHandlerSpan = {
@@ -35906,27 +35809,11 @@ var WorkflowHandlerSpan = {
35906
35809
  importance: "high",
35907
35810
  attributes: {
35908
35811
  ...required("botId", "workflowId", "eventId", "event.type"),
35909
- ...optional(
35910
- "messageId",
35911
- "userId",
35912
- "integration",
35913
- "channel",
35914
- "conversationId",
35915
- "parentWorkflowId"
35916
- ),
35812
+ ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
35917
35813
  "workflow.name": { type: "string" },
35918
35814
  "workflow.status.initial": {
35919
35815
  type: "enum",
35920
- enum: [
35921
- "pending",
35922
- "in_progress",
35923
- "listening",
35924
- "paused",
35925
- "completed",
35926
- "failed",
35927
- "timedout",
35928
- "cancelled"
35929
- ]
35816
+ enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
35930
35817
  },
35931
35818
  "workflow.status.final": {
35932
35819
  type: "enum",
@@ -35952,14 +35839,7 @@ var ActionHandlerSpan = {
35952
35839
  importance: "high",
35953
35840
  attributes: {
35954
35841
  ...required("botId", "workflowId", "eventId", "event.type"),
35955
- ...optional(
35956
- "messageId",
35957
- "userId",
35958
- "integration",
35959
- "channel",
35960
- "conversationId",
35961
- "parentWorkflowId"
35962
- ),
35842
+ ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
35963
35843
  "action.name": { type: "string", required: true },
35964
35844
  "action.input": { type: "json", required: true }
35965
35845
  }
@@ -36344,9 +36224,7 @@ function span(name, attributes, optionsOrF, f) {
36344
36224
  options = optionsOrF;
36345
36225
  handler = f;
36346
36226
  }
36347
- const spanDef = Object.values(Spans).find(
36348
- (def) => def.name === name
36349
- );
36227
+ const spanDef = Object.values(Spans).find((def) => def.name === name);
36350
36228
  const attrsWithImportance = {
36351
36229
  ...attributes
36352
36230
  };
@@ -36375,20 +36253,13 @@ function span(name, attributes, optionsOrF, f) {
36375
36253
  }
36376
36254
  };
36377
36255
  if (parentContext) {
36378
- return tracer.startActiveSpan(
36379
- name,
36380
- spanOptions,
36381
- parentContext,
36382
- executeInSpan
36383
- );
36256
+ return tracer.startActiveSpan(name, spanOptions, parentContext, executeInSpan);
36384
36257
  } else {
36385
36258
  return tracer.startActiveSpan(name, spanOptions, executeInSpan);
36386
36259
  }
36387
36260
  }
36388
36261
  var createSpan = (name, attributes, { parentContext } = {}) => {
36389
- const spanDef = Object.values(Spans).find(
36390
- (def) => def.name === name
36391
- );
36262
+ const spanDef = Object.values(Spans).find((def) => def.name === name);
36392
36263
  const attrsWithImportance = {
36393
36264
  ...attributes
36394
36265
  };
@@ -36456,9 +36327,7 @@ var getPromiseTracker = () => {
36456
36327
  if (tracker) {
36457
36328
  return tracker;
36458
36329
  }
36459
- throw new Error(
36460
- "PromiseTracker not found in context. Make sure to initialize it in your runtime setup."
36461
- );
36330
+ throw new Error("PromiseTracker not found in context. Make sure to initialize it in your runtime setup.");
36462
36331
  };
36463
36332
  function trackPromise(promise) {
36464
36333
  return getPromiseTracker().register(promise);
@@ -36529,16 +36398,11 @@ var AgentRegistry = class {
36529
36398
  }
36530
36399
  ensureInitialized() {
36531
36400
  if (!this._data) {
36532
- throw new Error(
36533
- "Agent registry not initialized. Call agentRegistry.initialize() during bot startup."
36534
- );
36401
+ throw new Error("Agent registry not initialized. Call agentRegistry.initialize() during bot startup.");
36535
36402
  }
36536
36403
  }
36537
36404
  };
36538
- var agentRegistry = getSingleton(
36539
- "__ADK_GLOBAL_AGENT_REGISTRY",
36540
- () => new AgentRegistry()
36541
- );
36405
+ var agentRegistry = getSingleton("__ADK_GLOBAL_AGENT_REGISTRY", () => new AgentRegistry());
36542
36406
 
36543
36407
  // src/runtime/tracked-state.ts
36544
36408
  init_define_BUILD();
@@ -40336,9 +40200,7 @@ init_define_PACKAGE_VERSIONS();
40336
40200
  init_define_BUILD();
40337
40201
  init_define_PACKAGE_VERSIONS();
40338
40202
  init_esm();
40339
- import {
40340
- getValue
40341
- } from "llmz";
40203
+ import { getValue } from "llmz";
40342
40204
  import {
40343
40205
  Tool as LlmzTool,
40344
40206
  ThinkSignal as _ThinkSignal,
@@ -40356,9 +40218,7 @@ init_define_BUILD();
40356
40218
  init_define_PACKAGE_VERSIONS();
40357
40219
  function createJoinedAbortController(signals) {
40358
40220
  const controller = new AbortController();
40359
- const validSignals = signals.filter(
40360
- (signal) => signal != null
40361
- );
40221
+ const validSignals = signals.filter((signal) => signal != null);
40362
40222
  if (validSignals.length === 0) {
40363
40223
  return controller;
40364
40224
  }
@@ -40483,9 +40343,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
40483
40343
  const client = context.get("client");
40484
40344
  const citations = context.get("citations");
40485
40345
  if (!client) {
40486
- throw new Error(
40487
- "Client is not available in this context. Make sure to run in a context with a client."
40488
- );
40346
+ throw new Error("Client is not available in this context. Make sure to run in a context with a client.");
40489
40347
  }
40490
40348
  const { passages } = await client.searchFiles({
40491
40349
  query,
@@ -40535,9 +40393,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
40535
40393
  citationMetadata.sourceId = tags[WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID];
40536
40394
  }
40537
40395
  const { tag } = citations.registerSource(citationMetadata);
40538
- message.push(
40539
- `<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`
40540
- );
40396
+ message.push(`<${tag} file="${p.file.key}" title="${citationMetadata.title || p.file.key}">`);
40541
40397
  message.push(p.content);
40542
40398
  message.push(`</${tag}>`);
40543
40399
  }
@@ -40553,9 +40409,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
40553
40409
  return async (props) => {
40554
40410
  const cognitive = context.get("cognitive");
40555
40411
  if (!cognitive) {
40556
- throw new Error(
40557
- "Cognitive client is not available in this context. Make sure to run in a cognitive context."
40558
- );
40412
+ throw new Error("Cognitive client is not available in this context. Make sure to run in a cognitive context.");
40559
40413
  }
40560
40414
  const defaultTemperature = 0.7;
40561
40415
  const maxLoops = import_lodash2.default.clamp(props.iterations ?? 10, 1, 100);
@@ -40567,10 +40421,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
40567
40421
  "autonomous.mode": options.mode
40568
40422
  },
40569
40423
  async (execSpan) => {
40570
- const joinedSignal = createJoinedAbortSignal([
40571
- props.signal,
40572
- options.interruption
40573
- ]);
40424
+ const joinedSignal = createJoinedAbortSignal([props.signal, options.interruption]);
40574
40425
  const llmz_execute = (await import("llmz")).execute;
40575
40426
  const asyncResource = new AsyncResource("autonomous.execution");
40576
40427
  const getNewIteration = (index) => createSpan(
@@ -40588,17 +40439,11 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
40588
40439
  );
40589
40440
  const _chat = options.mode === "chat" ? context.get("chat") : void 0;
40590
40441
  if (options.mode === "chat" && !_chat) {
40591
- throw new Error(
40592
- "Chat is not available in this context. Make sure to run in chat mode with a chat context."
40593
- );
40442
+ throw new Error("Chat is not available in this context. Make sure to run in chat mode with a chat context.");
40594
40443
  }
40595
40444
  const chat = _chat ? {
40596
- components: bindContext(
40597
- (ctx) => getValue(_chat.components, ctx)
40598
- ),
40599
- transcript: bindContext(
40600
- (ctx) => getValue(_chat.transcript, ctx)
40601
- ),
40445
+ components: bindContext((ctx) => getValue(_chat.components, ctx)),
40446
+ transcript: bindContext((ctx) => getValue(_chat.transcript, ctx)),
40602
40447
  handler: bindContext(_chat.handler),
40603
40448
  onExecutionDone: bindContext(_chat.onExecutionDone)
40604
40449
  } : void 0;
@@ -40633,10 +40478,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40633
40478
  ...props.objects && {
40634
40479
  objects: async (ctx) => {
40635
40480
  const objs = await getValue(props.objects, ctx) ?? [];
40636
- iterationSpan?.setAttribute(
40637
- "autonomous.objects",
40638
- objs.map((o) => o.name).join(", ")
40639
- );
40481
+ iterationSpan?.setAttribute("autonomous.objects", objs.map((o) => o.name).join(", "));
40640
40482
  for (const obj of objs) {
40641
40483
  obj.tools = obj.tools?.map(
40642
40484
  (tool) => tool.clone({
@@ -40700,10 +40542,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40700
40542
  if (search_knowledge) {
40701
40543
  allTools.push(search_knowledge);
40702
40544
  }
40703
- iterationSpan?.setAttribute(
40704
- "autonomous.tools",
40705
- allTools?.map((t) => t.name).join(", ")
40706
- );
40545
+ iterationSpan?.setAttribute("autonomous.tools", allTools?.map((t) => t.name).join(", "));
40707
40546
  return allTools.map(
40708
40547
  (tool) => tool.clone({
40709
40548
  handler: asyncResource.bind((args, ctx2) => {
@@ -40765,9 +40604,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40765
40604
  onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
40766
40605
  },
40767
40606
  ...props.hooks?.onBeforeExecution && {
40768
- onBeforeExecution: asyncResource.bind(
40769
- props.hooks.onBeforeExecution
40770
- )
40607
+ onBeforeExecution: asyncResource.bind(props.hooks.onBeforeExecution)
40771
40608
  },
40772
40609
  ...props.hooks?.onExit && {
40773
40610
  onExit: asyncResource.bind(props.hooks.onExit)
@@ -40786,9 +40623,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40786
40623
  });
40787
40624
  }
40788
40625
  if (props.hooks?.onTrace) {
40789
- return asyncResource.runInAsyncScope(
40790
- () => props.hooks.onTrace({ trace: trace2, iteration })
40791
- );
40626
+ return asyncResource.runInAsyncScope(() => props.hooks.onTrace({ trace: trace2, iteration }));
40792
40627
  }
40793
40628
  },
40794
40629
  onIterationEnd: async (iteration, controller) => {
@@ -40814,9 +40649,7 @@ ${iteration.status.execution_error.stack}`;
40814
40649
  } else if (iteration.status.type === "invalid_code_error") {
40815
40650
  message = `Iteration failed due to invalid code: ${iteration.status.invalid_code_error.message}`;
40816
40651
  }
40817
- iterationSpan?.recordException(
40818
- iteration.error ?? new Error(message)
40819
- );
40652
+ iterationSpan?.recordException(iteration.error ?? new Error(message));
40820
40653
  iterationSpan?.setStatus({
40821
40654
  code: SpanStatusCode.ERROR,
40822
40655
  message
@@ -40838,16 +40671,11 @@ ${iteration.status.execution_error.stack}`;
40838
40671
  }
40839
40672
  iterationSpan?.end();
40840
40673
  if (props.hooks?.onIterationEnd) {
40841
- return await asyncResource.runInAsyncScope(
40842
- () => props.hooks.onIterationEnd(iteration, controller)
40843
- );
40674
+ return await asyncResource.runInAsyncScope(() => props.hooks.onIterationEnd(iteration, controller));
40844
40675
  }
40845
40676
  }
40846
40677
  });
40847
- execSpan.setAttribute(
40848
- "autonomous.execution_id",
40849
- execution.context.id
40850
- );
40678
+ execSpan.setAttribute("autonomous.execution_id", execution.context.id);
40851
40679
  return execution;
40852
40680
  }
40853
40681
  );
@@ -40890,22 +40718,16 @@ var actions = new Proxy({}, {
40890
40718
  }
40891
40719
  integrations ??= context.get("integrations", { optional: true });
40892
40720
  client ??= context.get("client", { optional: true });
40893
- const integration = integrations.find(
40894
- (i) => i.alias === integrationName
40895
- );
40721
+ const integration = integrations.find((i) => i.alias === integrationName);
40896
40722
  const actionDef = integration?.definition.actions?.[actionName];
40897
40723
  const handler = async (params) => {
40898
40724
  integrations ??= context.get("integrations", { optional: true });
40899
40725
  client ??= context.get("client", { optional: true });
40900
40726
  if (!integration || !actionDef) {
40901
- throw new Error(
40902
- `Could not find integration "${integrationName}" and action "${actionName}"`
40903
- );
40727
+ throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
40904
40728
  }
40905
40729
  if (!integration.definition.actions?.[actionName]) {
40906
- throw new Error(
40907
- `Action "${actionName}" not found in integration "${integrationName}"`
40908
- );
40730
+ throw new Error(`Action "${actionName}" not found in integration "${integrationName}"`);
40909
40731
  }
40910
40732
  return client.callAction({
40911
40733
  type: `${integration.alias}:${actionName}`,
@@ -40914,9 +40736,7 @@ var actions = new Proxy({}, {
40914
40736
  };
40915
40737
  handler.asTool = () => {
40916
40738
  if (!integration || !actionDef) {
40917
- throw new Error(
40918
- `Could not find integration "${integrationName}" and action "${actionName}"`
40919
- );
40739
+ throw new Error(`Could not find integration "${integrationName}" and action "${actionName}"`);
40920
40740
  }
40921
40741
  return new Autonomous.Tool({
40922
40742
  name: actionName,
@@ -40934,9 +40754,7 @@ var actions = new Proxy({}, {
40934
40754
  optional: true
40935
40755
  });
40936
40756
  if (!integrations2) return [];
40937
- const integration = integrations2.find(
40938
- (i) => i.alias === integrationName
40939
- );
40757
+ const integration = integrations2.find((i) => i.alias === integrationName);
40940
40758
  if (!integration?.definition?.actions) return [];
40941
40759
  return Object.keys(integration.definition.actions);
40942
40760
  } catch {
@@ -40949,9 +40767,7 @@ var actions = new Proxy({}, {
40949
40767
  optional: true
40950
40768
  });
40951
40769
  if (!integrations2) return false;
40952
- const integration = integrations2.find(
40953
- (i) => i.alias === integrationName
40954
- );
40770
+ const integration = integrations2.find((i) => i.alias === integrationName);
40955
40771
  return !!integration?.definition?.actions?.[actionName];
40956
40772
  } catch {
40957
40773
  return false;
@@ -41028,15 +40844,14 @@ init_define_PACKAGE_VERSIONS();
41028
40844
  // src/globals.ts
41029
40845
  init_define_BUILD();
41030
40846
  init_define_PACKAGE_VERSIONS();
41031
- var DefinedGlobalObjects = [
41032
- "__PACKAGE_VERSIONS__",
41033
- "__BUILD__"
41034
- ];
40847
+ var DefinedGlobalObjects = ["__PACKAGE_VERSIONS__", "__BUILD__"];
41035
40848
  for (const key of Object.keys(DefinedGlobalObjects)) {
41036
40849
  if (typeof globalThis[key] === "string") {
41037
40850
  try {
40851
+ ;
41038
40852
  globalThis[key] = JSON.parse(globalThis[key]);
41039
40853
  } catch {
40854
+ ;
41040
40855
  globalThis[key] = DefinedGlobalObjects[key];
41041
40856
  }
41042
40857
  }
@@ -41258,12 +41073,7 @@ var BaseWorkflow = class {
41258
41073
  */
41259
41074
  async getOrCreate(props) {
41260
41075
  const client = context.get("client");
41261
- const statuses = props.statuses || [
41262
- "pending",
41263
- "in_progress",
41264
- "listening",
41265
- "paused"
41266
- ];
41076
+ const statuses = props.statuses || ["pending", "in_progress", "listening", "paused"];
41267
41077
  const validatedInput = this._inputSchema.parse(props.input);
41268
41078
  const tags = {};
41269
41079
  if (props.key) {
@@ -41277,9 +41087,7 @@ var BaseWorkflow = class {
41277
41087
  tags,
41278
41088
  conversationId: context.get("conversation", { optional: true })?.id,
41279
41089
  parentWorkflowId: context.get("workflow", { optional: true })?.id,
41280
- timeoutAt: new Date(
41281
- Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
41282
- ).toISOString(),
41090
+ timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString(),
41283
41091
  ...discriminator && { discriminateBy: { tags: discriminator } }
41284
41092
  };
41285
41093
  let { workflow } = await client._inner.getOrCreateWorkflow(createArgs);
@@ -41305,21 +41113,12 @@ var BaseWorkflow = class {
41305
41113
  async provide(event, data) {
41306
41114
  const client = context.get("client");
41307
41115
  const { workflowId, stepName } = event.payload;
41308
- const state = createWorkflowExecutionState(
41309
- client._inner,
41310
- workflowId
41311
- );
41116
+ const state = createWorkflowExecutionState(client._inner, workflowId);
41312
41117
  await state.load();
41313
41118
  if (!state.value) {
41314
- throw new Error(
41315
- `Workflow execution state not found for workflow ${workflowId}`
41316
- );
41119
+ throw new Error(`Workflow execution state not found for workflow ${workflowId}`);
41317
41120
  }
41318
- console.log(
41319
- `Providing data to workflow ${workflowId} step ${stepName}`,
41320
- data,
41321
- stepName
41322
- );
41121
+ console.log(`Providing data to workflow ${workflowId} step ${stepName}`, data, stepName);
41323
41122
  if (!state.value.steps[stepName]) {
41324
41123
  state.value.steps[stepName] = {
41325
41124
  output: data,
@@ -41351,9 +41150,7 @@ var BaseWorkflow = class {
41351
41150
  input: validatedInput,
41352
41151
  parentWorkflowId: workflow?.id,
41353
41152
  conversationId: context.get("conversation", { optional: true })?.id,
41354
- timeoutAt: new Date(
41355
- Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))
41356
- ).toISOString()
41153
+ timeoutAt: new Date(Date.now() + (this.timeout ?? (0, import_ms.default)("5m"))).toISOString()
41357
41154
  });
41358
41155
  return await BaseWorkflowInstance.load({
41359
41156
  id: res.workflow.id,
@@ -41401,9 +41198,7 @@ var createSyncWorkflow = (props) => new BaseWorkflow({
41401
41198
  }
41402
41199
  const source = kb.sources.find((s) => s.id === sourceId);
41403
41200
  if (!source) {
41404
- throw new Error(
41405
- `Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`
41406
- );
41201
+ throw new Error(`Data source with ID '${sourceId}' not found in knowledge base '${kbName}'`);
41407
41202
  }
41408
41203
  console.log(
41409
41204
  `\u{1F504} Starting sync for data source '${sourceId}' of type '${source.type}' in knowledge base '${kbName}'`
@@ -41507,12 +41302,8 @@ var adk = {
41507
41302
  config: state.projectConfig,
41508
41303
  integrations: Object.assign(state.primitives.integrations, {
41509
41304
  get(name) {
41510
- const byAlias = state.primitives.integrations.find(
41511
- (int) => int.alias === name
41512
- );
41513
- const byName = state.primitives.integrations.find(
41514
- (int) => int.definition.name === name
41515
- );
41305
+ const byAlias = state.primitives.integrations.find((int) => int.alias === name);
41306
+ const byName = state.primitives.integrations.find((int) => int.definition.name === name);
41516
41307
  return byAlias || byName;
41517
41308
  }
41518
41309
  }),
@@ -41607,9 +41398,7 @@ var TrackedState = class _TrackedState {
41607
41398
  }
41608
41399
  static create(props) {
41609
41400
  const states = context.get("states", { optional: true });
41610
- const match2 = states?.find(
41611
- (x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state")
41612
- );
41401
+ const match2 = states?.find((x) => x.id === props.id && x.type === props.type && x.name === (props.name || "state"));
41613
41402
  if (match2) {
41614
41403
  return match2;
41615
41404
  }
@@ -41689,9 +41478,7 @@ var TrackedState = class _TrackedState {
41689
41478
  });
41690
41479
  }
41691
41480
  const states = context.get("states", { optional: true });
41692
- const promises = Promise.allSettled(
41693
- states?.map((state) => state.load()) ?? []
41694
- );
41481
+ const promises = Promise.allSettled(states?.map((state) => state.load()) ?? []);
41695
41482
  void importScheduledHeavyImports();
41696
41483
  await promises;
41697
41484
  });
@@ -41726,9 +41513,7 @@ var TrackedState = class _TrackedState {
41726
41513
  const { data } = await axios_default.get(file.url);
41727
41514
  this.value = typeof data === "string" ? JSON.parse(data) : data;
41728
41515
  } catch (err) {
41729
- console.error(
41730
- `Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`
41731
- );
41516
+ console.error(`Failed to load swapped state from file: ${err instanceof Error ? err.message : String(err)}`);
41732
41517
  this.value = void 0;
41733
41518
  }
41734
41519
  } else {
@@ -41814,9 +41599,7 @@ var TrackedState = class _TrackedState {
41814
41599
  contentType: "application/json",
41815
41600
  content: JSON.stringify(this.value),
41816
41601
  accessPolicies: [],
41817
- expiresAt: new Date(
41818
- Date.now() + 30 * 24 * 60 * 60 * 1e3
41819
- ).toISOString(),
41602
+ expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString(),
41820
41603
  tags: {
41821
41604
  system: "true",
41822
41605
  purpose: "swap"
@@ -41836,9 +41619,7 @@ var TrackedState = class _TrackedState {
41836
41619
  error: err instanceof Error ? err.message : String(err),
41837
41620
  size_bytes: stateSize
41838
41621
  });
41839
- console.error(
41840
- `Failed to swap state: ${err instanceof Error ? err.message : String(err)}`
41841
- );
41622
+ console.error(`Failed to swap state: ${err instanceof Error ? err.message : String(err)}`);
41842
41623
  payload = {
41843
41624
  value: this.value,
41844
41625
  location: { type: "state" }
@@ -41978,11 +41759,7 @@ init_define_PACKAGE_VERSIONS();
41978
41759
  // src/runtime/chat/chat.ts
41979
41760
  init_define_BUILD();
41980
41761
  init_define_PACKAGE_VERSIONS();
41981
- import {
41982
- Chat,
41983
- DefaultComponents,
41984
- isAnyComponent as isAnyComponent2
41985
- } from "llmz";
41762
+ import { Chat, DefaultComponents, isAnyComponent as isAnyComponent2 } from "llmz";
41986
41763
 
41987
41764
  // src/runtime/chat/truncate-transcript.ts
41988
41765
  init_define_BUILD();
@@ -42328,12 +42105,7 @@ var AttachmentSchema = z12.object({
42328
42105
  });
42329
42106
  var TranscriptItemSchema = z12.object({
42330
42107
  id: z12.string(),
42331
- role: z12.union([
42332
- z12.literal("assistant"),
42333
- z12.literal("user"),
42334
- z12.literal("event"),
42335
- z12.literal("summary")
42336
- ]),
42108
+ role: z12.union([z12.literal("assistant"), z12.literal("user"), z12.literal("event"), z12.literal("summary")]),
42337
42109
  name: z12.string().optional(),
42338
42110
  createdAt: z12.string().optional(),
42339
42111
  content: z12.string().optional(),
@@ -42407,11 +42179,7 @@ var BaseConversationInstance = class {
42407
42179
  * Start typing indicator
42408
42180
  */
42409
42181
  async startTyping() {
42410
- const mapping = InterfaceMappings.getIntegrationAction(
42411
- "typingIndicator",
42412
- "startTypingIndicator",
42413
- this.integration
42414
- );
42182
+ const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "startTypingIndicator", this.integration);
42415
42183
  if (mapping) {
42416
42184
  const message = context.get("message", { optional: true });
42417
42185
  await this.client.callAction({
@@ -42428,11 +42196,7 @@ var BaseConversationInstance = class {
42428
42196
  * Stop typing indicator
42429
42197
  */
42430
42198
  async stopTyping() {
42431
- const mapping = InterfaceMappings.getIntegrationAction(
42432
- "typingIndicator",
42433
- "stopTypingIndicator",
42434
- this.integration
42435
- );
42199
+ const mapping = InterfaceMappings.getIntegrationAction("typingIndicator", "stopTypingIndicator", this.integration);
42436
42200
  if (mapping) {
42437
42201
  const message = context.get("message", { optional: true });
42438
42202
  await this.client.callAction({
@@ -42529,10 +42293,7 @@ var BaseConversation = class {
42529
42293
  const chat = context.get("chat");
42530
42294
  const client = context.get("client");
42531
42295
  const botpressConversation = context.get("conversation");
42532
- const conversationInstance = new BaseConversationInstance(
42533
- botpressConversation,
42534
- client
42535
- );
42296
+ const conversationInstance = new BaseConversationInstance(botpressConversation, client);
42536
42297
  let type;
42537
42298
  let requestObject = void 0;
42538
42299
  if (message) {
@@ -42571,9 +42332,7 @@ var BaseConversation = class {
42571
42332
  conversationId: conversationInstance.id,
42572
42333
  status: "pending"
42573
42334
  });
42574
- const newEvents = events.filter(
42575
- (e) => e.createdAt > event?.createdAt && e.id !== event?.id
42576
- );
42335
+ const newEvents = events.filter((e) => e.createdAt > event?.createdAt && e.id !== event?.id);
42577
42336
  if (newEvents.length) {
42578
42337
  s.setAttributes({
42579
42338
  "interruption.detected": true,
@@ -42601,9 +42360,7 @@ var BaseConversation = class {
42601
42360
  }
42602
42361
  }
42603
42362
  if (newEvents.length) {
42604
- controller.abort(
42605
- `More messages were received during processing, aborting current processing.`
42606
- );
42363
+ controller.abort(`More messages were received during processing, aborting current processing.`);
42607
42364
  } else {
42608
42365
  s.setAttribute("interruption.detected", false);
42609
42366
  }
@@ -42708,10 +42465,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
42708
42465
  import { transforms } from "@botpress/sdk";
42709
42466
  var DEFAULT_MAX_ATTEMPTS = 5;
42710
42467
  var MIN_STEP_REMAINING_TIME_MS = 1e4;
42711
- var storage2 = getSingleton(
42712
- "__ADK_GLOBAL_CTX_WORKFLOW_STEP",
42713
- () => new AsyncLocalStorage3()
42714
- );
42468
+ var storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
42715
42469
  async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
42716
42470
  spanFunc,
42717
42471
  stepType
@@ -42729,9 +42483,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
42729
42483
  }
42730
42484
  const remainingTime = context.get("runtime").getRemainingExecutionTimeInMs();
42731
42485
  if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
42732
- await new Promise(
42733
- (resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
42734
- );
42486
+ await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
42735
42487
  throw createStepSignal();
42736
42488
  }
42737
42489
  const stepContext = storage2.getStore();
@@ -42811,13 +42563,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
42811
42563
  }
42812
42564
  if (shouldRetry) {
42813
42565
  await new Promise(
42814
- (resolve) => setTimeout(
42815
- resolve,
42816
- Math.min(
42817
- 100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1),
42818
- 5e3
42819
- )
42820
- )
42566
+ (resolve) => setTimeout(resolve, Math.min(100 * Math.exp(state.value?.steps?.[name]?.attempts ?? 1), 5e3))
42821
42567
  );
42822
42568
  continue;
42823
42569
  }
@@ -42922,10 +42668,7 @@ step.sleep = async (name, ms3) => {
42922
42668
  );
42923
42669
  };
42924
42670
  step.sleepUntil = async (name, date) => {
42925
- const ms3 = Math.max(
42926
- 0,
42927
- new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS
42928
- );
42671
+ const ms3 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
42929
42672
  await step.sleep(name, ms3);
42930
42673
  };
42931
42674
  step.waitForWorkflow = async (name, workflowId) => {
@@ -42971,10 +42714,9 @@ step.executeWorkflow = async (name, workflow, input) => _step(
42971
42714
  // Ensures idempotency
42972
42715
  })).id
42973
42716
  );
42974
- return _step(
42975
- `${name}-wait`,
42976
- async () => step.waitForWorkflow(`${name}-wait`, wfId)
42977
- ).then((finishedWorkflow) => finishedWorkflow.output);
42717
+ return _step(`${name}-wait`, async () => step.waitForWorkflow(`${name}-wait`, wfId)).then(
42718
+ (finishedWorkflow) => finishedWorkflow.output
42719
+ );
42978
42720
  },
42979
42721
  {}
42980
42722
  );
@@ -42991,9 +42733,7 @@ async function processWithConcurrency(items, processor, maxConcurrency = 5) {
42991
42733
  }
42992
42734
  const remainingTime = context.get("runtime").getRemainingExecutionTimeInMs();
42993
42735
  if (remainingTime <= MIN_STEP_REMAINING_TIME_MS) {
42994
- await new Promise(
42995
- (resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS)
42996
- );
42736
+ await new Promise((resolve) => setTimeout(resolve, MIN_STEP_REMAINING_TIME_MS));
42997
42737
  throw createStepSignal();
42998
42738
  }
42999
42739
  const promise = processor(items[i], i).then((result) => {
@@ -43061,17 +42801,11 @@ step.request = async (request, message, stepName) => {
43061
42801
  const workflowControlContext = context.get("workflowControlContext");
43062
42802
  const client = context.get("client");
43063
42803
  if (!workflowControlContext.workflow.conversationId) {
43064
- throw new Error(
43065
- `Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`
43066
- );
42804
+ throw new Error(`Cannot request data: workflow ${workflowControlContext.workflow.id} has no conversationId`);
43067
42805
  }
43068
- const workflowDef = adk.project.workflows.find(
43069
- (w) => w.name === workflowControlContext.workflow.name
43070
- );
42806
+ const workflowDef = adk.project.workflows.find((w) => w.name === workflowControlContext.workflow.name);
43071
42807
  if (!workflowDef) {
43072
- throw new Error(
43073
- `Workflow definition not found for "${workflowControlContext.workflow.name}"`
43074
- );
42808
+ throw new Error(`Workflow definition not found for "${workflowControlContext.workflow.name}"`);
43075
42809
  }
43076
42810
  const requestSchema = workflowDef._requestsSchemas?.[request];
43077
42811
  if (!requestSchema) {
@@ -43079,10 +42813,7 @@ step.request = async (request, message, stepName) => {
43079
42813
  `Request "${request}" not found in workflow "${workflowDef.name}". Available requests: ${Object.keys(workflowDef._requestsSchemas || {}).join(", ") || "none"}`
43080
42814
  );
43081
42815
  }
43082
- const state = createWorkflowExecutionState(
43083
- client._inner,
43084
- workflowControlContext.workflow.id
43085
- );
42816
+ const state = createWorkflowExecutionState(client._inner, workflowControlContext.workflow.id);
43086
42817
  if (!state.value) {
43087
42818
  throw new Error("Workflow execution state not loaded");
43088
42819
  }
@@ -43162,9 +42893,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43162
42893
  // @internal
43163
42894
  TrackedState;
43164
42895
  constructor(workflow, client) {
43165
- const definition = adk.project.workflows.find(
43166
- (w) => w.name === workflow.name
43167
- );
42896
+ const definition = adk.project.workflows.find((w) => w.name === workflow.name);
43168
42897
  this.TrackedState = TrackedState.create({
43169
42898
  type: "workflow",
43170
42899
  client: client._inner,
@@ -43187,9 +42916,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43187
42916
  const client = context.get("client");
43188
42917
  const workflow = props.workflow ? props.workflow : await client.getWorkflow({ id: props.id }).then((x) => x.workflow);
43189
42918
  if (!adk.project.workflows.find((w) => w.name === workflow.name)) {
43190
- throw new Error(
43191
- `No ADK Workflow definition found for "${workflow.name}"`
43192
- );
42919
+ throw new Error(`No ADK Workflow definition found for "${workflow.name}"`);
43193
42920
  }
43194
42921
  return new _BaseWorkflowInstance(workflow, client);
43195
42922
  }
@@ -43216,10 +42943,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43216
42943
  */
43217
42944
  async provide(request, data) {
43218
42945
  const client = context.get("client");
43219
- const state = createWorkflowExecutionState(
43220
- client._inner,
43221
- this.id
43222
- );
42946
+ const state = createWorkflowExecutionState(client._inner, this.id);
43223
42947
  await state.load();
43224
42948
  if (!state.value) {
43225
42949
  throw new Error(`Workflow execution state not found for workflow ${this.id}`);
@@ -43246,13 +42970,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43246
42970
  }
43247
42971
  // @internal
43248
42972
  async handle() {
43249
- const handler = adk.project.workflows.find(
43250
- (w) => w.name === this.name
43251
- )._handler;
42973
+ const handler = adk.project.workflows.find((w) => w.name === this.name)._handler;
43252
42974
  if (!handler) {
43253
- throw new Error(
43254
- `No ADK Workflow handler found for "${this.name}"`
43255
- );
42975
+ throw new Error(`No ADK Workflow handler found for "${this.name}"`);
43256
42976
  }
43257
42977
  await TrackedState.loadAll();
43258
42978
  const workflowControlContext = {
@@ -43277,9 +42997,7 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43277
42997
  }
43278
42998
  const eventId = context.get("event")?.id;
43279
42999
  if (!eventId) {
43280
- throw new Error(
43281
- `Event ID not found in context. Cannot ack workflow ${this.id}`
43282
- );
43000
+ throw new Error(`Event ID not found in context. Cannot ack workflow ${this.id}`);
43283
43001
  }
43284
43002
  workflowControlContext.acked = true;
43285
43003
  await updateWorkflow({
@@ -43291,15 +43009,9 @@ var BaseWorkflowInstance = class _BaseWorkflowInstance {
43291
43009
  };
43292
43010
  try {
43293
43011
  const ctx = context.getAll();
43294
- const workflowExecutionState = createWorkflowExecutionState(
43295
- ctx.client._inner,
43296
- this.id
43297
- );
43012
+ const workflowExecutionState = createWorkflowExecutionState(ctx.client._inner, this.id);
43298
43013
  await workflowExecutionState.load();
43299
- assert2(
43300
- workflowExecutionState.value,
43301
- "Workflow execution state is not loaded"
43302
- );
43014
+ assert2(workflowExecutionState.value, "Workflow execution state is not loaded");
43303
43015
  workflowExecutionState.value.executionCount++;
43304
43016
  if (!this.TrackedState.value) {
43305
43017
  this.TrackedState.value = {};
@@ -43418,10 +43130,7 @@ var Definitions;
43418
43130
  });
43419
43131
  const actionDefinitionSchema = z18.object({
43420
43132
  type: z18.literal("action"),
43421
- name: z18.string().min(1, "Name must be a non-empty string").max(255, "Name must be less than 255 characters").regex(
43422
- /^[a-zA-Z][a-zA-Z0-9]*$/,
43423
- "Name must be alphanumeric with no special characters"
43424
- ),
43133
+ name: z18.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"),
43425
43134
  title: z18.string().optional(),
43426
43135
  description: z18.string().optional(),
43427
43136
  attributes: z18.record(z18.string()).optional(),
@@ -45009,17 +44718,8 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45009
44718
  this.urls = options.urls ?? void 0;
45010
44719
  this.filterFn = "filter" in options ? options.filter : void 0;
45011
44720
  this.customFetch = options.fetch ?? void 0;
45012
- this.maxPages = Math.max(
45013
- 1,
45014
- Math.min(
45015
- ("maxPages" in options ? options.maxPages : void 0) ?? 5e4,
45016
- 5e4
45017
- )
45018
- );
45019
- this.maxDepth = Math.max(
45020
- 1,
45021
- Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20)
45022
- );
44721
+ this.maxPages = Math.max(1, Math.min(("maxPages" in options ? options.maxPages : void 0) ?? 5e4, 5e4));
44722
+ this.maxDepth = Math.max(1, Math.min(("maxDepth" in options ? options.maxDepth : void 0) ?? 20, 20));
45023
44723
  }
45024
44724
  isBrowserIntegrationAvailable() {
45025
44725
  return !!adk.project.integrations.get("browser");
@@ -45183,9 +44883,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45183
44883
  }
45184
44884
  return passed;
45185
44885
  });
45186
- console.log(
45187
- `Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`
45188
- );
44886
+ console.log(`Applied filter: ${filteredUrls.length} URLs passed, ${skippedCount} URLs filtered out`);
45189
44887
  }
45190
44888
  return filteredUrls.map((url2) => ({ loc: url2 }));
45191
44889
  }
@@ -45217,20 +44915,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45217
44915
  await step2(`processing sitemap ${item.url}`, async () => {
45218
44916
  try {
45219
44917
  const { content, contentType } = await this.fetchSitemap(item.url);
45220
- console.log(
45221
- `Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`
45222
- );
44918
+ console.log(`Fetched sitemap ${item.url} (${content.length} bytes), processing... ${contentType}`);
45223
44919
  console.log(content, contentType);
45224
44920
  try {
45225
44921
  const { urls, sitemaps } = this.parseSitemapXml(content);
45226
- console.log(
45227
- `Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`
45228
- );
44922
+ console.log(`Parsed ${urls.length} URLs and ${sitemaps.length} sub-sitemaps from ${item.url}`);
45229
44923
  for (const url2 of urls) {
45230
44924
  if (state.urls.length >= this.maxPages) {
45231
- console.log(
45232
- `Reached maxPages limit (${this.maxPages}), stopping URL discovery`
45233
- );
44925
+ console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
45234
44926
  break;
45235
44927
  }
45236
44928
  const filterContext = {
@@ -45251,20 +44943,14 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45251
44943
  state.queue.push({ url: sitemapUrl, depth: item.depth + 1 });
45252
44944
  }
45253
44945
  } else if (sitemaps.length > 0) {
45254
- console.log(
45255
- `Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`
45256
- );
44946
+ console.log(`Reached maxDepth limit (${this.maxDepth}), skipping ${sitemaps.length} sub-sitemaps`);
45257
44947
  }
45258
44948
  } catch (xmlErr) {
45259
- console.log(
45260
- `XML parsing failed for ${item.url}, trying TXT format...`
45261
- );
44949
+ console.log(`XML parsing failed for ${item.url}, trying TXT format...`);
45262
44950
  const { urls } = this.parseSitemapTxt(content);
45263
44951
  for (const url2 of urls) {
45264
44952
  if (state.urls.length >= this.maxPages) {
45265
- console.log(
45266
- `Reached maxPages limit (${this.maxPages}), stopping URL discovery`
45267
- );
44953
+ console.log(`Reached maxPages limit (${this.maxPages}), stopping URL discovery`);
45268
44954
  break;
45269
44955
  }
45270
44956
  const filterContext = { url: url2.loc };
@@ -45282,13 +44968,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45282
44968
  }
45283
44969
  });
45284
44970
  }
45285
- console.log(
45286
- `URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`
45287
- );
44971
+ console.log(`URL discovery complete: ${state.urls.length} URLs discovered, ${skippedCount} URLs skipped by filter`);
45288
44972
  if (state.urls.length >= this.maxPages) {
45289
- console.log(
45290
- `Note: Discovery stopped at maxPages limit (${this.maxPages})`
45291
- );
44973
+ console.log(`Note: Discovery stopped at maxPages limit (${this.maxPages})`);
45292
44974
  }
45293
44975
  return state.urls.slice(0, this.maxPages);
45294
44976
  }
@@ -45301,13 +44983,9 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45301
44983
  console.log(
45302
44984
  `Starting sync for WebsiteSource [${this.id}] in mode [${this.mode}, maxPages=${this.maxPages}, maxDepth=${this.maxDepth}, baseUrl=${this.baseUrl}, sitemapUrl=${this.sitemapUrl}]`
45303
44985
  );
45304
- console.log(
45305
- `Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`
45306
- );
44986
+ console.log(`Using knowledge base: ${input.kbName}, force reindex: ${!!input.force}, ${input.sourceId}`);
45307
44987
  if (input.force) {
45308
- console.log(
45309
- "\u{1F504} FORCE MODE: Re-indexing all files regardless of changes"
45310
- );
44988
+ console.log("\u{1F504} FORCE MODE: Re-indexing all files regardless of changes");
45311
44989
  }
45312
44990
  const tags = {
45313
44991
  [WellKnownTags.knowledge.KNOWLEDGE]: "true",
@@ -45315,10 +44993,7 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45315
44993
  [WellKnownTags.knowledge.KNOWLEDGE_SOURCE_TYPE]: this.type,
45316
44994
  [WellKnownTags.knowledge.KNOWLEDGE_BASE_NAME]: input.kbName
45317
44995
  };
45318
- const discoveredUrls = await step2(
45319
- "discover urls from sitemap",
45320
- () => this.discoverUrls(step2, state)
45321
- );
44996
+ const discoveredUrls = await step2("discover urls from sitemap", () => this.discoverUrls(step2, state));
45322
44997
  console.log(`Discovered ${discoveredUrls.length} URLs from sitemap`);
45323
44998
  console.log(`Will process up to ${this.maxPages} pages`);
45324
44999
  const existingFiles = await step2(
@@ -45328,15 +45003,10 @@ var WebsiteSource = class _WebsiteSource extends DataSource {
45328
45003
  }).collect()
45329
45004
  );
45330
45005
  const existingFileMap = new Map(
45331
- existingFiles.map((f) => [
45332
- f.metadata?.[WellKnownMetadata.knowledge.URL],
45333
- f
45334
- ])
45006
+ existingFiles.map((f) => [f.metadata?.[WellKnownMetadata.knowledge.URL], f])
45335
45007
  );
45336
45008
  const toRemove = existingFiles.filter(
45337
- (f) => !discoveredUrls.find(
45338
- (u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL]
45339
- )
45009
+ (f) => !discoveredUrls.find((u) => u.loc === f.metadata?.[WellKnownMetadata.knowledge.URL])
45340
45010
  );
45341
45011
  const toFetch = [];
45342
45012
  let skippedUnchanged = 0;
@@ -45483,9 +45153,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
45483
45153
  state: z21.object({}),
45484
45154
  handler: async ({ input, step: step2, client }) => {
45485
45155
  if (!adk.environment.isDevelopment()) {
45486
- console.log(
45487
- "Directory ingestion is only supported in development environment"
45488
- );
45156
+ console.log("Directory ingestion is only supported in development environment");
45489
45157
  return {
45490
45158
  added: [],
45491
45159
  updated: [],
@@ -45501,10 +45169,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
45501
45169
  const path5 = await import("path");
45502
45170
  const fs3 = await import("fs/promises");
45503
45171
  const crypto3 = await import("crypto");
45504
- const directory = path5.resolve(
45505
- adk.environment.agent.directory,
45506
- this.directoryPath
45507
- );
45172
+ const directory = path5.resolve(adk.environment.agent.directory, this.directoryPath);
45508
45173
  const tags = {
45509
45174
  [WellKnownTags.knowledge.KNOWLEDGE]: "true",
45510
45175
  [WellKnownTags.knowledge.KNOWLEDGE_SOURCE_ID]: this.id,
@@ -45544,11 +45209,7 @@ var DirectorySource = class _DirectorySource extends DataSource {
45544
45209
  const toRemove = existingFiles.filter(
45545
45210
  (f) => !allFiles.find((af) => af.rel === f.metadata?.relPath)
45546
45211
  );
45547
- const toAdd = allFiles.filter(
45548
- (af) => !existingFiles.find(
45549
- (f) => f.metadata?.relPath === af.rel
45550
- )
45551
- );
45212
+ const toAdd = allFiles.filter((af) => !existingFiles.find((f) => f.metadata?.relPath === af.rel));
45552
45213
  const toUpdate = allFiles.filter(
45553
45214
  (af) => existingFiles.find((f) => f.metadata?.relPath === af.rel)
45554
45215
  );
@@ -45610,18 +45271,11 @@ var DirectorySource = class _DirectorySource extends DataSource {
45610
45271
  size: uploaded.file.size ?? -1
45611
45272
  };
45612
45273
  };
45613
- const added = await step2.map(
45614
- "to add files",
45615
- toAdd,
45616
- (f) => upsertFile(f),
45617
- { concurrency: 5, maxAttempts: 2 }
45618
- );
45619
- const updated = await step2.map(
45620
- "to update files",
45621
- toUpdate,
45622
- (f) => upsertFile(f),
45623
- { concurrency: 5, maxAttempts: 2 }
45624
- );
45274
+ const added = await step2.map("to add files", toAdd, (f) => upsertFile(f), { concurrency: 5, maxAttempts: 2 });
45275
+ const updated = await step2.map("to update files", toUpdate, (f) => upsertFile(f), {
45276
+ concurrency: 5,
45277
+ maxAttempts: 2
45278
+ });
45625
45279
  return {
45626
45280
  processed: allFiles.length,
45627
45281
  deleted,
@@ -45688,9 +45342,7 @@ var BaseKnowledge = class {
45688
45342
  async refreshSource(sourceId, options) {
45689
45343
  const source = this.sources.find((s) => s.id === sourceId);
45690
45344
  if (!source) {
45691
- throw new Error(
45692
- `Data source with id "${sourceId}" not found in knowledge base "${this.name}"`
45693
- );
45345
+ throw new Error(`Data source with id "${sourceId}" not found in knowledge base "${this.name}"`);
45694
45346
  }
45695
45347
  await source.syncWorkflow.getOrCreate({
45696
45348
  key: `${this.name}:${sourceId}`,
@@ -45722,9 +45374,7 @@ var BaseAction = class {
45722
45374
  handler;
45723
45375
  constructor(props) {
45724
45376
  if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(props.name)) {
45725
- throw new Error(
45726
- `Action name "${props.name}" must be alphanumeric with no special characters or spaces`
45727
- );
45377
+ throw new Error(`Action name "${props.name}" must be alphanumeric with no special characters or spaces`);
45728
45378
  }
45729
45379
  this.name = props.name;
45730
45380
  if (props.title !== void 0) {
@@ -45770,9 +45420,7 @@ var BaseAction = class {
45770
45420
  /**
45771
45421
  * Execute the action with input validation and output validation
45772
45422
  */
45773
- async execute({
45774
- input
45775
- }) {
45423
+ async execute({ input }) {
45776
45424
  return this.handler(input);
45777
45425
  }
45778
45426
  };
@@ -45860,6 +45508,7 @@ var BaseTable = class {
45860
45508
  for (const col of Object.keys(this.columns)) {
45861
45509
  if (this.computedColumns.has(col) || this.nullableColumns.has(col)) {
45862
45510
  if ("properties" in schema && schema.properties && col in schema.properties && typeof schema.properties[col] === "object" && schema.properties[col] !== null) {
45511
+ ;
45863
45512
  schema.properties[col].nullable = true;
45864
45513
  }
45865
45514
  if ("required" in schema && Array.isArray(schema.required)) {
@@ -45985,10 +45634,7 @@ var Typings7;
45985
45634
  Typings8.Primitive = "trigger";
45986
45635
  })(Typings7 || (Typings7 = {}));
45987
45636
  var TriggerSchema = z24.object({
45988
- name: z24.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(
45989
- /^[a-zA-Z0-9_]+$/,
45990
- "Trigger name must contain only alphanumeric characters and underscores"
45991
- ),
45637
+ name: z24.string().min(3, "Trigger name must be at least 3 characters").max(255, "Trigger name must be less than 255 characters").regex(/^[a-zA-Z0-9_]+$/, "Trigger name must contain only alphanumeric characters and underscores"),
45992
45638
  description: z24.string().max(1024, "Description must be less than 1024 characters").optional(),
45993
45639
  events: z24.array(z24.string()),
45994
45640
  handler: z24.function().describe("Handler function for the trigger")
@@ -46001,10 +45647,7 @@ var Trigger = class {
46001
45647
  constructor(props) {
46002
45648
  const result = TriggerSchema.safeParse(props);
46003
45649
  if (!result.success) {
46004
- throw new Errors.InvalidPrimitiveError(
46005
- "Trigger validation failed",
46006
- result.error
46007
- );
45650
+ throw new Errors.InvalidPrimitiveError("Trigger validation failed", result.error);
46008
45651
  }
46009
45652
  this.name = result.data.name;
46010
45653
  this.description = result.data.description;
@@ -46149,9 +45792,7 @@ var WorkerPool = class {
46149
45792
  const workerId = this.nextWorkerId++;
46150
45793
  const startTime = Date.now();
46151
45794
  const expiryTime = startTime + WORKER_LIFETIME_MS;
46152
- debugLog(
46153
- `[WorkerPool] Creating worker ${workerId} (expires at ${new Date(expiryTime).toISOString()})`
46154
- );
45795
+ debugLog(`[WorkerPool] Creating worker ${workerId} (expires at ${new Date(expiryTime).toISOString()})`);
46155
45796
  const worker = new Worker(this.workerScript, {
46156
45797
  env: {
46157
45798
  ...process.env,
@@ -46179,9 +45820,7 @@ var WorkerPool = class {
46179
45820
  debugLog(`[WorkerPool] Worker ${workerId} exited with code ${code}`);
46180
45821
  const info = this.workers.get(workerId);
46181
45822
  if (info && info.status !== "terminated") {
46182
- debugLog(
46183
- `[WorkerPool] Worker ${workerId} died unexpectedly, respawning...`
46184
- );
45823
+ debugLog(`[WorkerPool] Worker ${workerId} died unexpectedly, respawning...`);
46185
45824
  this.handleWorkerCrash(workerId);
46186
45825
  }
46187
45826
  });
@@ -46220,9 +45859,7 @@ var WorkerPool = class {
46220
45859
  }
46221
45860
  break;
46222
45861
  case "ack":
46223
- debugLog(
46224
- `[WorkerPool] Worker ${workerId} acknowledged task ${message.taskId}`
46225
- );
45862
+ debugLog(`[WorkerPool] Worker ${workerId} acknowledged task ${message.taskId}`);
46226
45863
  const pendingAck = this.pendingTasks.get(message.taskId);
46227
45864
  if (pendingAck?.ackTimer) {
46228
45865
  clearTimeout(pendingAck.ackTimer);
@@ -46236,15 +45873,12 @@ var WorkerPool = class {
46236
45873
  }
46237
45874
  break;
46238
45875
  case "complete":
46239
- debugLog(
46240
- `[WorkerPool] Worker ${workerId} completed task ${message.taskId}`
46241
- );
45876
+ debugLog(`[WorkerPool] Worker ${workerId} completed task ${message.taskId}`);
46242
45877
  workerInfo.status = "idle";
46243
45878
  workerInfo.currentTaskId = void 0;
46244
45879
  const pendingComplete = this.pendingTasks.get(message.taskId);
46245
45880
  if (pendingComplete) {
46246
- if (pendingComplete.taskTimer)
46247
- clearTimeout(pendingComplete.taskTimer);
45881
+ if (pendingComplete.taskTimer) clearTimeout(pendingComplete.taskTimer);
46248
45882
  if (pendingComplete.ackTimer) clearTimeout(pendingComplete.ackTimer);
46249
45883
  pendingComplete.resolve(message);
46250
45884
  this.pendingTasks.delete(message.taskId);
@@ -46262,10 +45896,7 @@ var WorkerPool = class {
46262
45896
  this.processQueue();
46263
45897
  break;
46264
45898
  case "error":
46265
- console.error(
46266
- `[WorkerPool] Worker ${workerId} error on task ${message.taskId}:`,
46267
- message.error
46268
- );
45899
+ console.error(`[WorkerPool] Worker ${workerId} error on task ${message.taskId}:`, message.error);
46269
45900
  workerInfo.status = "idle";
46270
45901
  workerInfo.currentTaskId = void 0;
46271
45902
  const pendingError = this.pendingTasks.get(message.taskId);
@@ -46320,9 +45951,7 @@ var WorkerPool = class {
46320
45951
  if (workerInfo.status === "idle") {
46321
45952
  const timeRemaining = workerInfo.expiryTime - Date.now();
46322
45953
  if (timeRemaining < WORKER_MIN_LIFETIME_MS) {
46323
- debugLog(
46324
- `[WorkerPool] Worker ${workerId} has ${timeRemaining}ms remaining, replacing...`
46325
- );
45954
+ debugLog(`[WorkerPool] Worker ${workerId} has ${timeRemaining}ms remaining, replacing...`);
46326
45955
  this.replaceWorker(workerId);
46327
45956
  attempts++;
46328
45957
  continue;
@@ -46390,9 +46019,7 @@ var WorkerPool = class {
46390
46019
  workerInfo.currentTaskId = taskId;
46391
46020
  this.stats.requestsDispatched++;
46392
46021
  const ackTimer = setTimeout(() => {
46393
- console.error(
46394
- `[WorkerPool] Worker ${workerId} failed to acknowledge task ${taskId}`
46395
- );
46022
+ console.error(`[WorkerPool] Worker ${workerId} failed to acknowledge task ${taskId}`);
46396
46023
  workerInfo.status = "idle";
46397
46024
  workerInfo.currentTaskId = void 0;
46398
46025
  this.pendingTasks.delete(taskId);
@@ -46435,18 +46062,9 @@ var WorkerPool = class {
46435
46062
  this.stats.requestsReceived++;
46436
46063
  const available = this.getNextAvailableWorker();
46437
46064
  if (available) {
46438
- this.dispatchToWorker(
46439
- available.workerId,
46440
- available.workerInfo,
46441
- taskId,
46442
- event,
46443
- resolve,
46444
- reject
46445
- );
46065
+ this.dispatchToWorker(available.workerId, available.workerInfo, taskId, event, resolve, reject);
46446
46066
  } else {
46447
- debugLog(
46448
- `[WorkerPool] All workers busy, queueing task ${taskId} (queue size: ${this.requestQueue.length})`
46449
- );
46067
+ debugLog(`[WorkerPool] All workers busy, queueing task ${taskId} (queue size: ${this.requestQueue.length})`);
46450
46068
  timing.queuedAt = Date.now();
46451
46069
  this.stats.requestsQueued++;
46452
46070
  const queueTimeout = setTimeout(() => {
@@ -46456,12 +46074,8 @@ var WorkerPool = class {
46456
46074
  }
46457
46075
  this.taskTimings.delete(taskId);
46458
46076
  this.stats.requestsAbandoned++;
46459
- console.error(
46460
- `[WorkerPool] Task ${taskId} abandoned after ${QUEUE_TIMEOUT_MS}ms in queue`
46461
- );
46462
- reject(
46463
- new Error(`Request timed out in queue after ${QUEUE_TIMEOUT_MS}ms`)
46464
- );
46077
+ console.error(`[WorkerPool] Task ${taskId} abandoned after ${QUEUE_TIMEOUT_MS}ms in queue`);
46078
+ reject(new Error(`Request timed out in queue after ${QUEUE_TIMEOUT_MS}ms`));
46465
46079
  }, QUEUE_TIMEOUT_MS);
46466
46080
  this.requestQueue.push({
46467
46081
  taskId,
@@ -46490,13 +46104,11 @@ var WorkerPool = class {
46490
46104
  queued.reject(new Error("Worker pool shutting down"));
46491
46105
  }
46492
46106
  this.requestQueue = [];
46493
- const terminationPromises = Array.from(this.workers.entries()).map(
46494
- ([workerId, info]) => {
46495
- debugLog(`[WorkerPool] Terminating worker ${workerId}`);
46496
- info.status = "terminated";
46497
- return info.worker.terminate();
46498
- }
46499
- );
46107
+ const terminationPromises = Array.from(this.workers.entries()).map(([workerId, info]) => {
46108
+ debugLog(`[WorkerPool] Terminating worker ${workerId}`);
46109
+ info.status = "terminated";
46110
+ return info.worker.terminate();
46111
+ });
46500
46112
  await Promise.all(terminationPromises);
46501
46113
  this.workers.clear();
46502
46114
  this.pendingTasks.clear();
@@ -46623,14 +46235,9 @@ function initializeParentWorker(bot2) {
46623
46235
  const pool = new WorkerPool();
46624
46236
  globalWorkerPool = pool;
46625
46237
  bot2.handler = async (event) => {
46626
- debugLog2(
46627
- "[Main] Received event, delegating to worker pool:",
46628
- event.type || "unknown"
46629
- );
46238
+ debugLog2("[Main] Received event, delegating to worker pool:", event.type || "unknown");
46630
46239
  const workerStats = pool.getWorkerStats();
46631
- debugLog2(
46632
- `[Main] Pool stats - Total: ${workerStats.total}, Idle: ${workerStats.idle}, Busy: ${workerStats.busy}`
46633
- );
46240
+ debugLog2(`[Main] Pool stats - Total: ${workerStats.total}, Idle: ${workerStats.idle}, Busy: ${workerStats.busy}`);
46634
46241
  try {
46635
46242
  await pool.executeTask(event);
46636
46243
  debugLog2("[Main] Event processed successfully by worker");