@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.cjs CHANGED
@@ -977,47 +977,33 @@ var webSearch = core.toolBuilder().name("web-search").description(
977
977
  };
978
978
  }
979
979
  }).build();
980
- function createGetConfiguredSlackClient(token, botName = "AgentForge Bot", botIcon = ":robot_face:") {
981
- let configuredClient = null;
982
- return function getConfiguredSlackClient() {
983
- if (!configuredClient) {
984
- const slackToken = token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN;
985
- if (!slackToken) {
986
- throw new Error(
987
- "Slack token not configured. Please provide a token in config or set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
988
- );
980
+ function createLazySlackClient(resolveToken, config, missingTokenError) {
981
+ let client = null;
982
+ return () => {
983
+ const token = resolveToken();
984
+ if (!client) {
985
+ if (!token) {
986
+ throw new Error(missingTokenError);
989
987
  }
990
- configuredClient = new webApi.WebClient(slackToken);
988
+ client = new webApi.WebClient(token);
991
989
  }
992
- return {
993
- client: configuredClient,
994
- config: {
995
- token: token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN || "",
996
- botName,
997
- botIcon
998
- }
999
- };
990
+ return { client, config: { token: token || "", ...config } };
1000
991
  };
1001
992
  }
1002
- var defaultSlackClient = null;
993
+ function createGetConfiguredSlackClient(token, botName = "AgentForge Bot", botIcon = ":robot_face:") {
994
+ return createLazySlackClient(
995
+ () => token || process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN,
996
+ { botName, botIcon },
997
+ "Slack token not configured. Please provide a token in config or set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
998
+ );
999
+ }
1000
+ var getLazyDefaultSlackClient = createLazySlackClient(
1001
+ () => process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN,
1002
+ { botName: "AgentForge Bot", botIcon: ":robot_face:" },
1003
+ "Slack token not configured. Please set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
1004
+ );
1003
1005
  function getDefaultSlackClient() {
1004
- if (!defaultSlackClient) {
1005
- const token = process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN;
1006
- if (!token) {
1007
- throw new Error(
1008
- "Slack token not configured. Please set SLACK_USER_TOKEN or SLACK_BOT_TOKEN environment variable."
1009
- );
1010
- }
1011
- defaultSlackClient = new webApi.WebClient(token);
1012
- }
1013
- return {
1014
- client: defaultSlackClient,
1015
- config: {
1016
- token: process.env.SLACK_USER_TOKEN || process.env.SLACK_BOT_TOKEN || "",
1017
- botName: "AgentForge Bot",
1018
- botIcon: ":robot_face:"
1019
- }
1020
- };
1006
+ return getLazyDefaultSlackClient();
1021
1007
  }
1022
1008
  function createSendSlackMessageTool(getSlackClient, logger20) {
1023
1009
  return core.toolBuilder().name("send-slack-message").description("Send a message to a Slack channel for team communication and notifications").category(core.ToolCategory.WEB).tags(["slack", "messaging", "communication"]).usageNotes(
@@ -2994,77 +2980,51 @@ var HuggingFaceEmbeddingProvider = class {
2994
2980
  return !!this.apiKey;
2995
2981
  }
2996
2982
  async generateEmbedding(text, model) {
2997
- const modelToUse = model || this.defaultModel;
2998
- return retryWithBackoff2(async () => {
2999
- try {
3000
- const response = await axios5__default.default.post(
3001
- `${this.baseUrl}/${modelToUse}`,
3002
- {
3003
- inputs: text,
3004
- options: {
3005
- wait_for_model: true
3006
- }
3007
- },
3008
- {
3009
- headers: {
3010
- "Authorization": `Bearer ${this.apiKey}`,
3011
- "Content-Type": "application/json"
3012
- }
3013
- }
3014
- );
3015
- const embedding = Array.isArray(response.data) ? response.data : response.data[0];
3016
- return {
3017
- embedding,
3018
- model: modelToUse,
3019
- dimensions: embedding.length
3020
- };
3021
- } catch (error) {
3022
- if (axios5__default.default.isAxiosError(error)) {
3023
- const status = error.response?.status;
3024
- const message = error.response?.data?.error || error.message;
3025
- let messageText;
3026
- if (status === 401) {
3027
- messageText = `HuggingFace API authentication failed. Please check your HUGGINGFACE_API_KEY. ${message}`;
3028
- } else if (status === 429) {
3029
- messageText = `HuggingFace API rate limit exceeded. ${message}`;
3030
- } else if (status === 400) {
3031
- messageText = `HuggingFace API request invalid: ${message}`;
3032
- } else if (status === 503) {
3033
- messageText = `HuggingFace model is loading. Please retry in a moment. ${message}`;
3034
- } else {
3035
- messageText = `HuggingFace API error (${status}): ${message}`;
3036
- }
3037
- throw withProviderErrorMetadata(error, messageText);
3038
- }
3039
- throw error;
3040
- }
3041
- });
2983
+ const { data, model: modelToUse } = await this.requestEmbeddings(
2984
+ text,
2985
+ model
2986
+ );
2987
+ const embedding = Array.isArray(data) ? data : data[0];
2988
+ return {
2989
+ embedding,
2990
+ model: modelToUse,
2991
+ dimensions: embedding.length
2992
+ };
3042
2993
  }
3043
2994
  async generateBatchEmbeddings(texts, model) {
2995
+ const { data: embeddings, model: modelToUse } = await this.requestEmbeddings(
2996
+ texts,
2997
+ model
2998
+ );
2999
+ const dimensions = embeddings[0]?.length || 0;
3000
+ return {
3001
+ embeddings,
3002
+ model: modelToUse,
3003
+ dimensions
3004
+ };
3005
+ }
3006
+ async requestEmbeddings(inputs, model) {
3044
3007
  const modelToUse = model || this.defaultModel;
3045
3008
  return retryWithBackoff2(async () => {
3046
3009
  try {
3047
3010
  const response = await axios5__default.default.post(
3048
3011
  `${this.baseUrl}/${modelToUse}`,
3049
3012
  {
3050
- inputs: texts,
3013
+ inputs,
3051
3014
  options: {
3052
3015
  wait_for_model: true
3053
3016
  }
3054
3017
  },
3055
3018
  {
3056
3019
  headers: {
3057
- "Authorization": `Bearer ${this.apiKey}`,
3020
+ Authorization: `Bearer ${this.apiKey}`,
3058
3021
  "Content-Type": "application/json"
3059
3022
  }
3060
3023
  }
3061
3024
  );
3062
- const embeddings = response.data;
3063
- const dimensions = embeddings[0]?.length || 0;
3064
3025
  return {
3065
- embeddings,
3066
- model: modelToUse,
3067
- dimensions
3026
+ data: response.data,
3027
+ model: modelToUse
3068
3028
  };
3069
3029
  } catch (error) {
3070
3030
  if (axios5__default.default.isAxiosError(error)) {
@@ -7201,15 +7161,6 @@ function formatTableName(table) {
7201
7161
  return table.schema ? `${table.schema}.${table.name}` : table.name;
7202
7162
  }
7203
7163
 
7204
- // src/data/relational/schema/type-mapper-normalization.ts
7205
- function normaliseDbType(raw) {
7206
- let type = raw.toLowerCase().trim();
7207
- type = type.replace(/\[\]$/, "");
7208
- type = type.replace(/\([\d,\s]+\)/, "");
7209
- type = type.replace(/\s+unsigned$/, "");
7210
- return type.trim();
7211
- }
7212
-
7213
7164
  // src/data/relational/schema/type-mapper-vendor-maps.ts
7214
7165
  var POSTGRES_TYPE_MAP = {
7215
7166
  smallint: "number",
@@ -7385,6 +7336,13 @@ function getVendorTypeMap(vendor) {
7385
7336
  function usesStringPrecisionFallback(vendor, normalised) {
7386
7337
  return (normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql");
7387
7338
  }
7339
+ function normaliseDbType(raw) {
7340
+ let type = raw.toLowerCase().trim();
7341
+ type = type.replace(/\[\]$/, "");
7342
+ type = type.replace(/\([\d,\s]+\)/, "");
7343
+ type = type.replace(/\s+unsigned$/, "");
7344
+ return type.trim();
7345
+ }
7388
7346
  var logger14 = core.createLogger("agentforge:tools:data:relational:schema-diff");
7389
7347
  function diffSchemas(before, after) {
7390
7348
  const tableDiffs = [];