@agentforge/tools 0.18.5 → 0.18.6

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/index.js CHANGED
@@ -949,47 +949,33 @@ var webSearch = toolBuilder().name("web-search").description(
949
949
  };
950
950
  }
951
951
  }).build();
952
- function createGetConfiguredSlackClient(token, botName = "AgentForge Bot", botIcon = ":robot_face:") {
953
- let configuredClient = null;
954
- return function getConfiguredSlackClient() {
955
- if (!configuredClient) {
956
- const slackToken = token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN;
957
- if (!slackToken) {
958
- throw new Error(
959
- "Slack token not configured. Please provide a token in config or set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
960
- );
952
+ function createLazySlackClient(resolveToken, config, missingTokenError) {
953
+ let client = null;
954
+ return () => {
955
+ const token = resolveToken();
956
+ if (!client) {
957
+ if (!token) {
958
+ throw new Error(missingTokenError);
961
959
  }
962
- configuredClient = new WebClient(slackToken);
960
+ client = new WebClient(token);
963
961
  }
964
- return {
965
- client: configuredClient,
966
- config: {
967
- token: token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN || "",
968
- botName,
969
- botIcon
970
- }
971
- };
962
+ return { client, config: { token: token || "", ...config } };
972
963
  };
973
964
  }
974
- var defaultSlackClient = null;
965
+ function createGetConfiguredSlackClient(token, botName = "AgentForge Bot", botIcon = ":robot_face:") {
966
+ return createLazySlackClient(
967
+ () => token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN,
968
+ { botName, botIcon },
969
+ "Slack token not configured. Please provide a token in config or set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
970
+ );
971
+ }
972
+ var getLazyDefaultSlackClient = createLazySlackClient(
973
+ () => process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN,
974
+ { botName: "AgentForge Bot", botIcon: ":robot_face:" },
975
+ "Slack token not configured. Please set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
976
+ );
975
977
  function getDefaultSlackClient() {
976
- if (!defaultSlackClient) {
977
- const token = process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN;
978
- if (!token) {
979
- throw new Error(
980
- "Slack token not configured. Please set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
981
- );
982
- }
983
- defaultSlackClient = new WebClient(token);
984
- }
985
- return {
986
- client: defaultSlackClient,
987
- config: {
988
- token: process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN || "",
989
- botName: "AgentForge Bot",
990
- botIcon: ":robot_face:"
991
- }
992
- };
978
+ return getLazyDefaultSlackClient();
993
979
  }
994
980
  function createSendSlackMessageTool(getSlackClient, logger20) {
995
981
  return toolBuilder().name("send-slack-message").description("Send a message to a Slack channel for team communication and notifications").category(ToolCategory.WEB).tags(["slack", "messaging", "communication"]).usageNotes(
@@ -2966,77 +2952,51 @@ var HuggingFaceEmbeddingProvider = class {
2966
2952
  return !!this.apiKey;
2967
2953
  }
2968
2954
  async generateEmbedding(text, model) {
2969
- const modelToUse = model || this.defaultModel;
2970
- return retryWithBackoff2(async () => {
2971
- try {
2972
- const response = await axios5.post(
2973
- `${this.baseUrl}/${modelToUse}`,
2974
- {
2975
- inputs: text,
2976
- options: {
2977
- wait_for_model: true
2978
- }
2979
- },
2980
- {
2981
- headers: {
2982
- "Authorization": `Bearer ${this.apiKey}`,
2983
- "Content-Type": "application/json"
2984
- }
2985
- }
2986
- );
2987
- const embedding = Array.isArray(response.data) ? response.data : response.data[0];
2988
- return {
2989
- embedding,
2990
- model: modelToUse,
2991
- dimensions: embedding.length
2992
- };
2993
- } catch (error) {
2994
- if (axios5.isAxiosError(error)) {
2995
- const status = error.response?.status;
2996
- const message = error.response?.data?.error || error.message;
2997
- let messageText;
2998
- if (status === 401) {
2999
- messageText = `HuggingFace API authentication failed. Please check your HUGGINGFACE_API_KEY. ${message}`;
3000
- } else if (status === 429) {
3001
- messageText = `HuggingFace API rate limit exceeded. ${message}`;
3002
- } else if (status === 400) {
3003
- messageText = `HuggingFace API request invalid: ${message}`;
3004
- } else if (status === 503) {
3005
- messageText = `HuggingFace model is loading. Please retry in a moment. ${message}`;
3006
- } else {
3007
- messageText = `HuggingFace API error (${status}): ${message}`;
3008
- }
3009
- throw withProviderErrorMetadata(error, messageText);
3010
- }
3011
- throw error;
3012
- }
3013
- });
2955
+ const { data, model: modelToUse } = await this.requestEmbeddings(
2956
+ text,
2957
+ model
2958
+ );
2959
+ const embedding = Array.isArray(data) ? data : data[0];
2960
+ return {
2961
+ embedding,
2962
+ model: modelToUse,
2963
+ dimensions: embedding.length
2964
+ };
3014
2965
  }
3015
2966
  async generateBatchEmbeddings(texts, model) {
2967
+ const { data: embeddings, model: modelToUse } = await this.requestEmbeddings(
2968
+ texts,
2969
+ model
2970
+ );
2971
+ const dimensions = embeddings[0]?.length || 0;
2972
+ return {
2973
+ embeddings,
2974
+ model: modelToUse,
2975
+ dimensions
2976
+ };
2977
+ }
2978
+ async requestEmbeddings(inputs, model) {
3016
2979
  const modelToUse = model || this.defaultModel;
3017
2980
  return retryWithBackoff2(async () => {
3018
2981
  try {
3019
2982
  const response = await axios5.post(
3020
2983
  `${this.baseUrl}/${modelToUse}`,
3021
2984
  {
3022
- inputs: texts,
2985
+ inputs,
3023
2986
  options: {
3024
2987
  wait_for_model: true
3025
2988
  }
3026
2989
  },
3027
2990
  {
3028
2991
  headers: {
3029
- "Authorization": `Bearer ${this.apiKey}`,
2992
+ Authorization: `Bearer ${this.apiKey}`,
3030
2993
  "Content-Type": "application/json"
3031
2994
  }
3032
2995
  }
3033
2996
  );
3034
- const embeddings = response.data;
3035
- const dimensions = embeddings[0]?.length || 0;
3036
2997
  return {
3037
- embeddings,
3038
- model: modelToUse,
3039
- dimensions
2998
+ data: response.data,
2999
+ model: modelToUse
3040
3000
  };
3041
3001
  } catch (error) {
3042
3002
  if (axios5.isAxiosError(error)) {
@@ -7173,15 +7133,6 @@ function formatTableName(table) {
7173
7133
  return table.schema ? `${table.schema}.${table.name}` : table.name;
7174
7134
  }
7175
7135
 
7176
- // src/data/relational/schema/type-mapper-normalization.ts
7177
- function normaliseDbType(raw) {
7178
- let type = raw.toLowerCase().trim();
7179
- type = type.replace(/\[\]$/, "");
7180
- type = type.replace(/\([\d,\s]+\)/, "");
7181
- type = type.replace(/\s+unsigned$/, "");
7182
- return type.trim();
7183
- }
7184
-
7185
7136
  // src/data/relational/schema/type-mapper-vendor-maps.ts
7186
7137
  var POSTGRES_TYPE_MAP = {
7187
7138
  smallint: "number",
@@ -7357,6 +7308,13 @@ function getVendorTypeMap(vendor) {
7357
7308
  function usesStringPrecisionFallback(vendor, normalised) {
7358
7309
  return (normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql");
7359
7310
  }
7311
+ function normaliseDbType(raw) {
7312
+ let type = raw.toLowerCase().trim();
7313
+ type = type.replace(/\[\]$/, "");
7314
+ type = type.replace(/\([\d,\s]+\)/, "");
7315
+ type = type.replace(/\s+unsigned$/, "");
7316
+ return type.trim();
7317
+ }
7360
7318
  var logger14 = createLogger("agentforge:tools:data:relational:schema-diff");
7361
7319
  function diffSchemas(before, after) {
7362
7320
  const tableDiffs = [];