@botpress/runtime 1.13.14 → 1.13.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/library.js CHANGED
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
48
48
  var define_PACKAGE_VERSIONS_default;
49
49
  var init_define_PACKAGE_VERSIONS = __esm({
50
50
  "<define:__PACKAGE_VERSIONS__>"() {
51
- define_PACKAGE_VERSIONS_default = { runtime: "1.13.14", adk: "1.13.14", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.13.16", adk: "1.13.16", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
52
52
  }
53
53
  });
54
54
 
@@ -34609,10 +34609,15 @@ var init_actions = __esm({
34609
34609
  if (typeof propertyName !== "string") {
34610
34610
  return void 0;
34611
34611
  }
34612
+ let client2;
34613
+ client2 ??= context.get("client", { optional: true });
34612
34614
  const botAction = adk.project.actions.find((a) => a.name === propertyName);
34613
34615
  if (botAction) {
34614
34616
  const handler = async (input) => {
34615
- return await botAction.handler(input);
34617
+ return await botAction.handler({
34618
+ input,
34619
+ client: client2
34620
+ });
34616
34621
  };
34617
34622
  handler.asTool = () => new Autonomous.Tool({
34618
34623
  name: botAction.name,
@@ -34624,9 +34629,7 @@ var init_actions = __esm({
34624
34629
  return handler;
34625
34630
  }
34626
34631
  let integrations;
34627
- let client2;
34628
34632
  integrations ??= context.get("integrations", { optional: true });
34629
- client2 ??= context.get("client", { optional: true });
34630
34633
  const integrationName = propertyName.replace("__", "/");
34631
34634
  return new Proxy(
34632
34635
  {},
@@ -36828,9 +36831,13 @@ var init_workflow_instance = __esm({
36828
36831
  const trackedState = this.TrackedState;
36829
36832
  const stateProxy = new Proxy(this.TrackedState.value, {
36830
36833
  set(target, prop, value) {
36831
- const result = Reflect.set(target, prop, value);
36832
- trackedState.markDirty();
36833
- return result;
36834
+ const oldValue = target[prop];
36835
+ if (oldValue !== value) {
36836
+ const result = Reflect.set(target, prop, value);
36837
+ trackedState.markDirty();
36838
+ return result;
36839
+ }
36840
+ return true;
36834
36841
  }
36835
36842
  });
36836
36843
  if (this.workflow.status === "pending") {
@@ -37292,7 +37299,8 @@ var init_tracked_state = __esm({
37292
37299
  } else {
37293
37300
  this.value = value;
37294
37301
  }
37295
- if (this.value == null || this.value === void 0) {
37302
+ const needsDefaults = this.value == null || this.value === void 0;
37303
+ if (needsDefaults) {
37296
37304
  if (this.state && "parse" in this.state) {
37297
37305
  try {
37298
37306
  this.value = this.state.parse({});
@@ -37495,6 +37503,7 @@ var init_tracked_tags = __esm({
37495
37503
  init_define_PACKAGE_VERSIONS();
37496
37504
  init_context();
37497
37505
  init_tracing();
37506
+ init_adk();
37498
37507
  TrackedTags = class _TrackedTags {
37499
37508
  type;
37500
37509
  id;
@@ -37719,13 +37728,49 @@ var init_tracked_tags = __esm({
37719
37728
  }
37720
37729
  return {};
37721
37730
  }
37731
+ /**
37732
+ * Get the list of valid tag keys from the agent configuration.
37733
+ * Only tags defined in agent.config.ts can be persisted.
37734
+ */
37735
+ getValidTagKeys() {
37736
+ const validKeys = /* @__PURE__ */ new Set();
37737
+ try {
37738
+ const config = adk.project.config;
37739
+ if (this.type === "bot" && config.bot?.tags) {
37740
+ Object.keys(config.bot.tags).forEach((key) => validKeys.add(key));
37741
+ } else if (this.type === "user" && config.user?.tags) {
37742
+ Object.keys(config.user.tags).forEach((key) => validKeys.add(key));
37743
+ } else if (this.type === "conversation" && config.conversation?.tags) {
37744
+ Object.keys(config.conversation.tags).forEach((key) => validKeys.add(key));
37745
+ } else if (this.type === "workflow" && config.workflow?.tags) {
37746
+ Object.keys(config.workflow.tags).forEach((key) => validKeys.add(key));
37747
+ }
37748
+ } catch (err) {
37749
+ console.warn(`[TrackedTags] Could not load tag definitions from config: ${err}`);
37750
+ }
37751
+ return validKeys;
37752
+ }
37722
37753
  async persistTags(tags) {
37754
+ const validKeys = this.getValidTagKeys();
37723
37755
  const tagsForApi = {};
37756
+ const skippedTags = [];
37724
37757
  for (const [key, value] of Object.entries(tags)) {
37725
- if (value !== void 0 && !isSystemTag(key)) {
37758
+ if (value === void 0 || isSystemTag(key)) {
37759
+ continue;
37760
+ }
37761
+ if (validKeys.size === 0 || validKeys.has(key)) {
37726
37762
  tagsForApi[key] = value;
37763
+ } else {
37764
+ skippedTags.push(key);
37765
+ delete this._tags[key];
37766
+ delete this._initialTags[key];
37727
37767
  }
37728
37768
  }
37769
+ if (skippedTags.length > 0) {
37770
+ console.warn(
37771
+ `[TrackedTags] Skipping tags not defined in agent.config.ts for ${this.type}/${this.id}: ${skippedTags.join(", ")}`
37772
+ );
37773
+ }
37729
37774
  try {
37730
37775
  if (this.type === "bot") {
37731
37776
  await this.client.updateBot({ id: this.id, tags: tagsForApi });
@@ -38824,9 +38869,13 @@ var init_conversation = __esm({
38824
38869
  }
38825
38870
  const stateProxy = new Proxy(conversationInstance.TrackedState.value, {
38826
38871
  set(target, prop, value) {
38827
- const result = Reflect.set(target, prop, value);
38828
- conversationInstance.TrackedState.markDirty();
38829
- return result;
38872
+ const oldValue = target[prop];
38873
+ if (oldValue !== value) {
38874
+ const result = Reflect.set(target, prop, value);
38875
+ conversationInstance.TrackedState.markDirty();
38876
+ return result;
38877
+ }
38878
+ return true;
38830
38879
  }
38831
38880
  });
38832
38881
  await this.#handler({
@@ -40955,13 +41004,13 @@ var init_source_website = __esm({
40955
41004
  parseLlmsTxt(content) {
40956
41005
  const urls = [];
40957
41006
  const lines = content.split("\n");
40958
- const urlRegex = /https?:\/\/[^\s)]+\.md/g;
41007
+ const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^\s)]+\.md)\)/g;
40959
41008
  for (const line of lines) {
40960
- const matches = line.matchAll(urlRegex);
41009
+ const matches = line.matchAll(linkRegex);
40961
41010
  for (const match2 of matches) {
40962
- const [url2] = match2;
41011
+ const [, title, url2] = match2;
40963
41012
  if (url2) {
40964
- urls.push(url2);
41013
+ urls.push({ loc: url2, ...title && { title } });
40965
41014
  }
40966
41015
  }
40967
41016
  }
@@ -41037,11 +41086,11 @@ var init_source_website = __esm({
41037
41086
  console.log(`Reached maxPages limit (${this.maxPages}), stopping`);
41038
41087
  break;
41039
41088
  }
41040
- const filterContext = { url: url2 };
41089
+ const filterContext = { url: url2.loc };
41041
41090
  if (!this.filterFn || this.filterFn(filterContext)) {
41042
- filteredUrls.push({ loc: url2 });
41091
+ filteredUrls.push(url2);
41043
41092
  } else {
41044
- console.log(`Skipped URL (filtered): ${url2}`);
41093
+ console.log(`Skipped URL (filtered): ${url2.loc}`);
41045
41094
  }
41046
41095
  }
41047
41096
  return filteredUrls;
@@ -41236,8 +41285,8 @@ var init_source_website = __esm({
41236
41285
  hash,
41237
41286
  ...sitemapUrl.lastmod && { lastmod: sitemapUrl.lastmod },
41238
41287
  ...contentType && { contentType },
41239
- ...fetchMetadata?.[WellKnownMetadata.knowledge.TITLE] && {
41240
- [WellKnownMetadata.knowledge.TITLE]: fetchMetadata[WellKnownMetadata.knowledge.TITLE]
41288
+ ...(fetchMetadata?.[WellKnownMetadata.knowledge.TITLE] || sitemapUrl.title) && {
41289
+ [WellKnownMetadata.knowledge.TITLE]: fetchMetadata?.[WellKnownMetadata.knowledge.TITLE] ?? sitemapUrl.title
41241
41290
  },
41242
41291
  ...fetchMetadata?.[WellKnownMetadata.knowledge.DESCRIPTION] && {
41243
41292
  [WellKnownMetadata.knowledge.DESCRIPTION]: fetchMetadata[WellKnownMetadata.knowledge.DESCRIPTION]