@agentforge/tools 0.16.42 → 0.16.44
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 +140 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -41
- package/dist/index.d.ts +1 -41
- package/dist/index.js +140 -133
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -815,7 +815,7 @@ function getDefaultSlackClient() {
|
|
|
815
815
|
}
|
|
816
816
|
};
|
|
817
817
|
}
|
|
818
|
-
function createSendSlackMessageTool(getSlackClient,
|
|
818
|
+
function createSendSlackMessageTool(getSlackClient, logger24) {
|
|
819
819
|
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(
|
|
820
820
|
"Use this for general team communication. For notifications with @mentions, consider using notify-slack instead. Use get-slack-channels first if you need to find the right channel."
|
|
821
821
|
).suggests(["get-slack-channels"]).schema(
|
|
@@ -824,7 +824,7 @@ function createSendSlackMessageTool(getSlackClient, logger23) {
|
|
|
824
824
|
message: zod.z.string().describe("Message content to send")
|
|
825
825
|
})
|
|
826
826
|
).implementSafe(async ({ channel, message }) => {
|
|
827
|
-
|
|
827
|
+
logger24.info("send-slack-message called", { channel, messageLength: message.length });
|
|
828
828
|
try {
|
|
829
829
|
const { client: slack, config } = getSlackClient();
|
|
830
830
|
const result = await slack.chat.postMessage({
|
|
@@ -833,7 +833,7 @@ function createSendSlackMessageTool(getSlackClient, logger23) {
|
|
|
833
833
|
username: config.botName,
|
|
834
834
|
icon_emoji: config.botIcon
|
|
835
835
|
});
|
|
836
|
-
|
|
836
|
+
logger24.info("send-slack-message result", {
|
|
837
837
|
...result.channel ? { channel: result.channel } : {},
|
|
838
838
|
...result.ts ? { timestamp: result.ts } : {},
|
|
839
839
|
messageLength: message.length,
|
|
@@ -846,7 +846,7 @@ function createSendSlackMessageTool(getSlackClient, logger23) {
|
|
|
846
846
|
message_id: result.ts
|
|
847
847
|
};
|
|
848
848
|
} catch (error) {
|
|
849
|
-
|
|
849
|
+
logger24.error("send-slack-message failed", {
|
|
850
850
|
channel,
|
|
851
851
|
error: error.message,
|
|
852
852
|
data: error.data
|
|
@@ -855,7 +855,7 @@ function createSendSlackMessageTool(getSlackClient, logger23) {
|
|
|
855
855
|
}
|
|
856
856
|
}).build();
|
|
857
857
|
}
|
|
858
|
-
function createNotifySlackTool(getSlackClient,
|
|
858
|
+
function createNotifySlackTool(getSlackClient, logger24) {
|
|
859
859
|
return core.toolBuilder().name("notify-slack").description("Send a notification to a Slack channel with optional @mentions for urgent alerts").category(core.ToolCategory.WEB).tags(["slack", "notification", "alert"]).usageNotes(
|
|
860
860
|
"Use this for urgent notifications that require @mentions. For general messages without mentions, use send-slack-message instead."
|
|
861
861
|
).suggests(["get-slack-channels"]).schema(
|
|
@@ -865,7 +865,7 @@ function createNotifySlackTool(getSlackClient, logger23) {
|
|
|
865
865
|
mentions: zod.z.array(zod.z.string()).optional().describe("List of usernames to mention (without @)")
|
|
866
866
|
})
|
|
867
867
|
).implementSafe(async ({ channel, message, mentions = [] }) => {
|
|
868
|
-
|
|
868
|
+
logger24.info("notify-slack called", {
|
|
869
869
|
channel,
|
|
870
870
|
messageLength: message.length,
|
|
871
871
|
mentionCount: mentions.length
|
|
@@ -879,7 +879,7 @@ function createNotifySlackTool(getSlackClient, logger23) {
|
|
|
879
879
|
username: config.botName,
|
|
880
880
|
icon_emoji: config.botIcon
|
|
881
881
|
});
|
|
882
|
-
|
|
882
|
+
logger24.info("notify-slack result", {
|
|
883
883
|
...result.channel ? { channel: result.channel } : {},
|
|
884
884
|
...result.ts ? { timestamp: result.ts } : {},
|
|
885
885
|
mentions: mentions.length
|
|
@@ -893,7 +893,7 @@ function createNotifySlackTool(getSlackClient, logger23) {
|
|
|
893
893
|
};
|
|
894
894
|
}).build();
|
|
895
895
|
}
|
|
896
|
-
function createGetSlackChannelsTool(getSlackClient,
|
|
896
|
+
function createGetSlackChannelsTool(getSlackClient, logger24) {
|
|
897
897
|
return core.toolBuilder().name("get-slack-channels").description("Get a list of available Slack channels to find the right channel for messaging").category(core.ToolCategory.WEB).tags(["slack", "channels", "list"]).usageNotes(
|
|
898
898
|
"Use this first to discover available channels before sending messages. Helps ensure you are sending to the correct channel."
|
|
899
899
|
).follows(["send-slack-message", "notify-slack"]).schema(
|
|
@@ -901,7 +901,7 @@ function createGetSlackChannelsTool(getSlackClient, logger23) {
|
|
|
901
901
|
include_private: zod.z.boolean().optional().describe("Include private channels (default: false)")
|
|
902
902
|
})
|
|
903
903
|
).implementSafe(async ({ include_private = false }) => {
|
|
904
|
-
|
|
904
|
+
logger24.info("get-slack-channels called", { include_private });
|
|
905
905
|
const { client: slack } = getSlackClient();
|
|
906
906
|
const publicChannels = await slack.conversations.list({
|
|
907
907
|
types: "public_channel",
|
|
@@ -915,7 +915,7 @@ function createGetSlackChannelsTool(getSlackClient, logger23) {
|
|
|
915
915
|
});
|
|
916
916
|
allChannels = [...allChannels, ...privateChannels.channels || []];
|
|
917
917
|
}
|
|
918
|
-
|
|
918
|
+
logger24.info("get-slack-channels result", {
|
|
919
919
|
channelCount: allChannels.length,
|
|
920
920
|
includePrivate: include_private
|
|
921
921
|
});
|
|
@@ -930,7 +930,7 @@ function createGetSlackChannelsTool(getSlackClient, logger23) {
|
|
|
930
930
|
};
|
|
931
931
|
}).build();
|
|
932
932
|
}
|
|
933
|
-
function createGetSlackMessagesTool(getSlackClient,
|
|
933
|
+
function createGetSlackMessagesTool(getSlackClient, logger24) {
|
|
934
934
|
return core.toolBuilder().name("get-slack-messages").description("Retrieve message history from a Slack channel to read recent conversations").category(core.ToolCategory.WEB).tags(["slack", "messages", "history", "read"]).usageNotes(
|
|
935
935
|
"Use this to read recent messages from a channel. Use get-slack-channels first if you need to find the channel ID. Returns messages in reverse chronological order (newest first)."
|
|
936
936
|
).suggests(["get-slack-channels"]).schema(
|
|
@@ -939,7 +939,7 @@ function createGetSlackMessagesTool(getSlackClient, logger23) {
|
|
|
939
939
|
limit: zod.z.number().int().min(1).max(100).optional().describe("Number of messages to retrieve (default: 20, max: 100)")
|
|
940
940
|
})
|
|
941
941
|
).implementSafe(async ({ channel, limit = 20 }) => {
|
|
942
|
-
|
|
942
|
+
logger24.info("get-slack-messages called", { channel, limit });
|
|
943
943
|
try {
|
|
944
944
|
const { client: slack } = getSlackClient();
|
|
945
945
|
let channelId = channel;
|
|
@@ -950,7 +950,7 @@ function createGetSlackMessagesTool(getSlackClient, logger23) {
|
|
|
950
950
|
});
|
|
951
951
|
const found = channels.channels?.find((c) => c.name === channel);
|
|
952
952
|
if (!found) {
|
|
953
|
-
|
|
953
|
+
logger24.error("get-slack-messages: channel not found", { channel });
|
|
954
954
|
throw new Error(
|
|
955
955
|
`Channel '${channel}' not found. Use get-slack-channels to see available channels.`
|
|
956
956
|
);
|
|
@@ -962,7 +962,7 @@ function createGetSlackMessagesTool(getSlackClient, logger23) {
|
|
|
962
962
|
limit: Math.min(limit, 100)
|
|
963
963
|
// Cap at 100 for performance
|
|
964
964
|
});
|
|
965
|
-
|
|
965
|
+
logger24.info("get-slack-messages result", {
|
|
966
966
|
channel: channelId,
|
|
967
967
|
messageCount: result.messages?.length || 0,
|
|
968
968
|
limit
|
|
@@ -980,7 +980,7 @@ function createGetSlackMessagesTool(getSlackClient, logger23) {
|
|
|
980
980
|
})) || []
|
|
981
981
|
};
|
|
982
982
|
} catch (error) {
|
|
983
|
-
|
|
983
|
+
logger24.error("get-slack-messages failed", {
|
|
984
984
|
channel,
|
|
985
985
|
error: error.message,
|
|
986
986
|
data: error.data
|
|
@@ -1061,12 +1061,12 @@ function getAuthHeader() {
|
|
|
1061
1061
|
const auth2 = Buffer.from(`${ATLASSIAN_EMAIL}:${ATLASSIAN_API_KEY}`).toString("base64");
|
|
1062
1062
|
return `Basic ${auth2}`;
|
|
1063
1063
|
}
|
|
1064
|
-
function createSearchConfluenceTool(getAuth, getAuthHeader2,
|
|
1064
|
+
function createSearchConfluenceTool(getAuth, getAuthHeader2, logger24) {
|
|
1065
1065
|
return core.toolBuilder().name("search-confluence").description("Search for pages in Confluence using keywords or CQL (Confluence Query Language). Returns matching pages with titles, IDs, and excerpts.").category(core.ToolCategory.WEB).tag("confluence").tag("search").tag("knowledge-base").usageNotes("Use this to find relevant documentation, policies, or information in Confluence. You can search by keywords or use CQL for advanced queries (e.g., 'space=AI AND type=page'). Use get-confluence-page to retrieve full content of specific pages.").suggests(["get-confluence-page"]).schema(zod.z.object({
|
|
1066
1066
|
query: zod.z.string().describe("Search query or CQL expression (e.g., 'payment processing' or 'space=BL3 AND title~payment')"),
|
|
1067
1067
|
limit: zod.z.number().optional().describe("Maximum number of results to return (default: 10, max: 25)")
|
|
1068
1068
|
})).implement(async ({ query, limit = 10 }) => {
|
|
1069
|
-
|
|
1069
|
+
logger24.info("search-confluence called", { query, limit });
|
|
1070
1070
|
try {
|
|
1071
1071
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1072
1072
|
const response = await axios16__default.default.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/search`, {
|
|
@@ -1091,13 +1091,13 @@ function createSearchConfluenceTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1091
1091
|
lastModified: page.version?.when || ""
|
|
1092
1092
|
}));
|
|
1093
1093
|
if (results.length === 0) {
|
|
1094
|
-
|
|
1094
|
+
logger24.warn("search-confluence returned NO RESULTS - this is a valid outcome, agent should not retry", {
|
|
1095
1095
|
query,
|
|
1096
1096
|
limit,
|
|
1097
1097
|
totalSize: response.data.totalSize
|
|
1098
1098
|
});
|
|
1099
1099
|
} else {
|
|
1100
|
-
|
|
1100
|
+
logger24.info("search-confluence result", {
|
|
1101
1101
|
query,
|
|
1102
1102
|
resultCount: results.length,
|
|
1103
1103
|
totalSize: response.data.totalSize,
|
|
@@ -1112,7 +1112,7 @@ function createSearchConfluenceTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1112
1112
|
results
|
|
1113
1113
|
});
|
|
1114
1114
|
} catch (error) {
|
|
1115
|
-
|
|
1115
|
+
logger24.error("search-confluence error", {
|
|
1116
1116
|
query,
|
|
1117
1117
|
error: error.response?.data?.message || error.message,
|
|
1118
1118
|
status: error.response?.status
|
|
@@ -1124,11 +1124,11 @@ function createSearchConfluenceTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
}).build();
|
|
1126
1126
|
}
|
|
1127
|
-
function createGetConfluencePageTool(getAuth, getAuthHeader2,
|
|
1127
|
+
function createGetConfluencePageTool(getAuth, getAuthHeader2, logger24) {
|
|
1128
1128
|
return core.toolBuilder().name("get-confluence-page").description("Get the full content of a specific Confluence page by its ID. Returns the page title, content (in storage format), space, and metadata.").category(core.ToolCategory.WEB).tag("confluence").tag("page").tag("content").usageNotes("Use this after search-confluence to retrieve the full content of a specific page. The page ID can be found in search results.").requires(["search-confluence"]).schema(zod.z.object({
|
|
1129
1129
|
page_id: zod.z.string().describe("The Confluence page ID (from search results)")
|
|
1130
1130
|
})).implement(async ({ page_id }) => {
|
|
1131
|
-
|
|
1131
|
+
logger24.info("get-confluence-page called", { page_id });
|
|
1132
1132
|
try {
|
|
1133
1133
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1134
1134
|
const response = await axios16__default.default.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`, {
|
|
@@ -1141,7 +1141,7 @@ function createGetConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
});
|
|
1143
1143
|
const page = response.data;
|
|
1144
|
-
|
|
1144
|
+
logger24.info("get-confluence-page result", {
|
|
1145
1145
|
page_id,
|
|
1146
1146
|
title: page.title,
|
|
1147
1147
|
space: page.space?.name,
|
|
@@ -1163,7 +1163,7 @@ function createGetConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
});
|
|
1165
1165
|
} catch (error) {
|
|
1166
|
-
|
|
1166
|
+
logger24.error("get-confluence-page error", {
|
|
1167
1167
|
page_id,
|
|
1168
1168
|
error: error.response?.data?.message || error.message,
|
|
1169
1169
|
status: error.response?.status
|
|
@@ -1175,11 +1175,11 @@ function createGetConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
}).build();
|
|
1177
1177
|
}
|
|
1178
|
-
function createListConfluenceSpacesTool(getAuth, getAuthHeader2,
|
|
1178
|
+
function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger24) {
|
|
1179
1179
|
return core.toolBuilder().name("list-confluence-spaces").description("List all available Confluence spaces. Returns space names, keys, types, and descriptions to help identify where to search for information.").category(core.ToolCategory.WEB).tag("confluence").tag("spaces").tag("list").usageNotes("Use this first to discover available spaces before searching. Helps narrow down searches to specific areas (e.g., 'AI', 'BL3', 'Finance').").follows(["search-confluence"]).schema(zod.z.object({
|
|
1180
1180
|
limit: zod.z.number().optional().describe("Maximum number of spaces to return (default: 25)")
|
|
1181
1181
|
})).implement(async ({ limit = 25 }) => {
|
|
1182
|
-
|
|
1182
|
+
logger24.info("list-confluence-spaces called", { limit });
|
|
1183
1183
|
try {
|
|
1184
1184
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1185
1185
|
const response = await axios16__default.default.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/space`, {
|
|
@@ -1198,7 +1198,7 @@ function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1198
1198
|
description: space.description?.plain?.value || "",
|
|
1199
1199
|
url: `${ATLASSIAN_SITE_URL}/wiki${space._links.webui}`
|
|
1200
1200
|
}));
|
|
1201
|
-
|
|
1201
|
+
logger24.info("list-confluence-spaces result", {
|
|
1202
1202
|
spaceCount: spaces.length,
|
|
1203
1203
|
spaceKeys: spaces.map((s) => s.key).slice(0, 5)
|
|
1204
1204
|
// Log first 5 space keys
|
|
@@ -1209,7 +1209,7 @@ function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1209
1209
|
spaces
|
|
1210
1210
|
});
|
|
1211
1211
|
} catch (error) {
|
|
1212
|
-
|
|
1212
|
+
logger24.error("list-confluence-spaces error", {
|
|
1213
1213
|
error: error.response?.data?.message || error.message,
|
|
1214
1214
|
status: error.response?.status
|
|
1215
1215
|
});
|
|
@@ -1220,12 +1220,12 @@ function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
}).build();
|
|
1222
1222
|
}
|
|
1223
|
-
function createGetSpacePagesTool(getAuth, getAuthHeader2,
|
|
1223
|
+
function createGetSpacePagesTool(getAuth, getAuthHeader2, logger24) {
|
|
1224
1224
|
return core.toolBuilder().name("get-space-pages").description("Get all pages from a specific Confluence space by space key. Useful for browsing content in a particular area.").category(core.ToolCategory.WEB).tag("confluence").tag("space").tag("pages").usageNotes("Use this to explore all pages in a specific space. Get the space key from list-confluence-spaces first.").requires(["list-confluence-spaces"]).schema(zod.z.object({
|
|
1225
1225
|
space_key: zod.z.string().describe("The space key (e.g., 'AI', 'BL3', 'FIN')"),
|
|
1226
1226
|
limit: zod.z.number().optional().describe("Maximum number of pages to return (default: 25)")
|
|
1227
1227
|
})).implement(async ({ space_key, limit = 25 }) => {
|
|
1228
|
-
|
|
1228
|
+
logger24.info("get-space-pages called", { space_key, limit });
|
|
1229
1229
|
try {
|
|
1230
1230
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1231
1231
|
const response = await axios16__default.default.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content`, {
|
|
@@ -1247,12 +1247,12 @@ function createGetSpacePagesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1247
1247
|
lastModified: page.version?.when || ""
|
|
1248
1248
|
}));
|
|
1249
1249
|
if (pages.length === 0) {
|
|
1250
|
-
|
|
1250
|
+
logger24.warn("get-space-pages returned NO PAGES - this is a valid outcome, agent should not retry", {
|
|
1251
1251
|
space_key,
|
|
1252
1252
|
limit
|
|
1253
1253
|
});
|
|
1254
1254
|
} else {
|
|
1255
|
-
|
|
1255
|
+
logger24.info("get-space-pages result", {
|
|
1256
1256
|
space_key,
|
|
1257
1257
|
pageCount: pages.length,
|
|
1258
1258
|
titles: pages.map((p) => p.title).slice(0, 3)
|
|
@@ -1266,7 +1266,7 @@ function createGetSpacePagesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1266
1266
|
pages
|
|
1267
1267
|
});
|
|
1268
1268
|
} catch (error) {
|
|
1269
|
-
|
|
1269
|
+
logger24.error("get-space-pages error", {
|
|
1270
1270
|
space_key,
|
|
1271
1271
|
error: error.response?.data?.message || error.message,
|
|
1272
1272
|
status: error.response?.status
|
|
@@ -1278,14 +1278,14 @@ function createGetSpacePagesTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1278
1278
|
}
|
|
1279
1279
|
}).build();
|
|
1280
1280
|
}
|
|
1281
|
-
function createCreateConfluencePageTool(getAuth, getAuthHeader2,
|
|
1281
|
+
function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger24) {
|
|
1282
1282
|
return core.toolBuilder().name("create-confluence-page").description("Create a new page in a Confluence space. Requires space key, page title, and content (in HTML storage format).").category(core.ToolCategory.WEB).tag("confluence").tag("create").tag("write").usageNotes("Use this to create new documentation pages. Content should be in Confluence storage format (HTML). Get the space key from list-confluence-spaces first. Be mindful of creating duplicate pages.").requires(["list-confluence-spaces"]).schema(zod.z.object({
|
|
1283
1283
|
space_key: zod.z.string().describe("The space key where the page will be created (e.g., 'AI', 'BL3')"),
|
|
1284
1284
|
title: zod.z.string().describe("The title of the new page"),
|
|
1285
1285
|
content: zod.z.string().describe("The page content in HTML format (Confluence storage format)"),
|
|
1286
1286
|
parent_page_id: zod.z.string().optional().describe("Optional parent page ID to create this as a child page")
|
|
1287
1287
|
})).implement(async ({ space_key, title, content, parent_page_id }) => {
|
|
1288
|
-
|
|
1288
|
+
logger24.info("create-confluence-page called", { space_key, title, hasParent: !!parent_page_id });
|
|
1289
1289
|
try {
|
|
1290
1290
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1291
1291
|
const pageData = {
|
|
@@ -1312,7 +1312,7 @@ function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
1314
|
);
|
|
1315
|
-
|
|
1315
|
+
logger24.info("create-confluence-page result", {
|
|
1316
1316
|
page_id: response.data.id,
|
|
1317
1317
|
title: response.data.title,
|
|
1318
1318
|
space: space_key
|
|
@@ -1328,7 +1328,7 @@ function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1328
1328
|
}
|
|
1329
1329
|
});
|
|
1330
1330
|
} catch (error) {
|
|
1331
|
-
|
|
1331
|
+
logger24.error("create-confluence-page error", {
|
|
1332
1332
|
space_key,
|
|
1333
1333
|
title,
|
|
1334
1334
|
error: error.response?.data?.message || error.message,
|
|
@@ -1341,13 +1341,13 @@ function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
}).build();
|
|
1343
1343
|
}
|
|
1344
|
-
function createUpdateConfluencePageTool(getAuth, getAuthHeader2,
|
|
1344
|
+
function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger24) {
|
|
1345
1345
|
return core.toolBuilder().name("update-confluence-page").description("Update an existing Confluence page's content. Requires page ID, new title, and new content.").category(core.ToolCategory.WEB).tag("confluence").tag("update").tag("write").usageNotes("Use this to update existing documentation. You must provide the page ID (from search results). The tool will automatically handle version incrementing. Always get the current page content first to avoid overwriting important information.").requires(["get-confluence-page"]).schema(zod.z.object({
|
|
1346
1346
|
page_id: zod.z.string().describe("The ID of the page to update"),
|
|
1347
1347
|
title: zod.z.string().describe("The new title for the page"),
|
|
1348
1348
|
content: zod.z.string().describe("The new content in HTML format (Confluence storage format)")
|
|
1349
1349
|
})).implement(async ({ page_id, title, content }) => {
|
|
1350
|
-
|
|
1350
|
+
logger24.info("update-confluence-page called", { page_id, title });
|
|
1351
1351
|
try {
|
|
1352
1352
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1353
1353
|
const getResponse = await axios16__default.default.get(
|
|
@@ -1380,7 +1380,7 @@ function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
}
|
|
1382
1382
|
);
|
|
1383
|
-
|
|
1383
|
+
logger24.info("update-confluence-page result", {
|
|
1384
1384
|
page_id,
|
|
1385
1385
|
title: updateResponse.data.title,
|
|
1386
1386
|
previousVersion: currentVersion,
|
|
@@ -1397,7 +1397,7 @@ function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
});
|
|
1399
1399
|
} catch (error) {
|
|
1400
|
-
|
|
1400
|
+
logger24.error("update-confluence-page error", {
|
|
1401
1401
|
page_id,
|
|
1402
1402
|
title,
|
|
1403
1403
|
error: error.response?.data?.message || error.message,
|
|
@@ -1410,12 +1410,12 @@ function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1410
1410
|
}
|
|
1411
1411
|
}).build();
|
|
1412
1412
|
}
|
|
1413
|
-
function createArchiveConfluencePageTool(getAuth, getAuthHeader2,
|
|
1413
|
+
function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger24) {
|
|
1414
1414
|
return core.toolBuilder().name("archive-confluence-page").description("Archive a Confluence page by moving it to trash. The page can be restored by space admins. Note: UI may require a note explaining why the page was archived.").category(core.ToolCategory.WEB).tag("confluence").tag("archive").tag("delete").usageNotes("Use this to archive outdated or obsolete documentation. The page is moved to trash, not permanently deleted. Space admins can restore it if needed. Be very careful - only archive pages that are truly obsolete.").conflicts(["create-confluence-page"]).schema(zod.z.object({
|
|
1415
1415
|
page_id: zod.z.string().describe("The ID of the page to archive"),
|
|
1416
1416
|
reason: zod.z.string().optional().describe("Optional reason for archiving (for audit trail)")
|
|
1417
1417
|
})).implement(async ({ page_id, reason }) => {
|
|
1418
|
-
|
|
1418
|
+
logger24.info("archive-confluence-page called", {
|
|
1419
1419
|
page_id,
|
|
1420
1420
|
...reason ? { reason } : {}
|
|
1421
1421
|
});
|
|
@@ -1449,7 +1449,7 @@ function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
1451
|
);
|
|
1452
|
-
|
|
1452
|
+
logger24.info("archive-confluence-page result", {
|
|
1453
1453
|
page_id,
|
|
1454
1454
|
title: pageData.title,
|
|
1455
1455
|
previousVersion: currentVersion,
|
|
@@ -1467,7 +1467,7 @@ function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger23) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
});
|
|
1469
1469
|
} catch (error) {
|
|
1470
|
-
|
|
1470
|
+
logger24.error("archive-confluence-page error", {
|
|
1471
1471
|
page_id,
|
|
1472
1472
|
error: error.response?.data?.message || error.message,
|
|
1473
1473
|
status: error.response?.status
|
|
@@ -4148,19 +4148,19 @@ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
|
4148
4148
|
ConnectionState2["ERROR"] = "error";
|
|
4149
4149
|
return ConnectionState2;
|
|
4150
4150
|
})(ConnectionState || {});
|
|
4151
|
-
function cancelPendingReconnection(timer,
|
|
4151
|
+
function cancelPendingReconnection(timer, logger24, vendor, message) {
|
|
4152
4152
|
if (!timer) {
|
|
4153
4153
|
return null;
|
|
4154
4154
|
}
|
|
4155
|
-
|
|
4155
|
+
logger24.debug(message, { vendor });
|
|
4156
4156
|
clearTimeout(timer);
|
|
4157
4157
|
return null;
|
|
4158
4158
|
}
|
|
4159
|
-
async function waitForInFlightConnection(promise,
|
|
4159
|
+
async function waitForInFlightConnection(promise, logger24, vendor, phase) {
|
|
4160
4160
|
if (!promise) {
|
|
4161
4161
|
return null;
|
|
4162
4162
|
}
|
|
4163
|
-
|
|
4163
|
+
logger24.debug(`Waiting for in-flight connection attempt to complete before ${phase}`, {
|
|
4164
4164
|
vendor
|
|
4165
4165
|
});
|
|
4166
4166
|
try {
|
|
@@ -4177,9 +4177,9 @@ function shutdownClient(vendor, client) {
|
|
|
4177
4177
|
client.close();
|
|
4178
4178
|
}
|
|
4179
4179
|
}
|
|
4180
|
-
function scheduleReconnection(context,
|
|
4180
|
+
function scheduleReconnection(context, logger24) {
|
|
4181
4181
|
if (context.reconnectionConfig.maxAttempts > 0 && context.reconnectionAttempts >= context.reconnectionConfig.maxAttempts) {
|
|
4182
|
-
|
|
4182
|
+
logger24.error("Max reconnection attempts reached", {
|
|
4183
4183
|
vendor: context.vendor,
|
|
4184
4184
|
attempts: context.reconnectionAttempts,
|
|
4185
4185
|
maxAttempts: context.reconnectionConfig.maxAttempts
|
|
@@ -4193,7 +4193,7 @@ function scheduleReconnection(context, logger23) {
|
|
|
4193
4193
|
const nextAttempt = context.reconnectionAttempts + 1;
|
|
4194
4194
|
context.setReconnectionAttempts(nextAttempt);
|
|
4195
4195
|
context.setState("reconnecting" /* RECONNECTING */);
|
|
4196
|
-
|
|
4196
|
+
logger24.info("Scheduling reconnection attempt", {
|
|
4197
4197
|
vendor: context.vendor,
|
|
4198
4198
|
attempt: nextAttempt,
|
|
4199
4199
|
maxAttempts: context.reconnectionConfig.maxAttempts,
|
|
@@ -4207,7 +4207,7 @@ function scheduleReconnection(context, logger23) {
|
|
|
4207
4207
|
const timer = setTimeout(async () => {
|
|
4208
4208
|
context.setReconnectionTimer(null);
|
|
4209
4209
|
try {
|
|
4210
|
-
|
|
4210
|
+
logger24.info("Attempting reconnection", {
|
|
4211
4211
|
vendor: context.vendor,
|
|
4212
4212
|
attempt: nextAttempt
|
|
4213
4213
|
});
|
|
@@ -4217,7 +4217,7 @@ function scheduleReconnection(context, logger23) {
|
|
|
4217
4217
|
context.setConnectPromise(promise);
|
|
4218
4218
|
await promise;
|
|
4219
4219
|
} catch (error) {
|
|
4220
|
-
|
|
4220
|
+
logger24.error("Reconnection attempt failed", {
|
|
4221
4221
|
vendor: context.vendor,
|
|
4222
4222
|
attempt: nextAttempt,
|
|
4223
4223
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -4228,17 +4228,17 @@ function scheduleReconnection(context, logger23) {
|
|
|
4228
4228
|
}
|
|
4229
4229
|
|
|
4230
4230
|
// src/data/relational/connection/connection-cleanup.ts
|
|
4231
|
-
async function cleanupConnectionResources(vendor, client, clearConnection,
|
|
4231
|
+
async function cleanupConnectionResources(vendor, client, clearConnection, logger24) {
|
|
4232
4232
|
if (!client) {
|
|
4233
4233
|
return;
|
|
4234
4234
|
}
|
|
4235
|
-
|
|
4235
|
+
logger24.debug("Cleaning up cancelled connection", {
|
|
4236
4236
|
vendor
|
|
4237
4237
|
});
|
|
4238
4238
|
try {
|
|
4239
4239
|
await shutdownClient(vendor, client);
|
|
4240
4240
|
} catch (error) {
|
|
4241
|
-
|
|
4241
|
+
logger24.debug("Error during cancelled connection cleanup", {
|
|
4242
4242
|
vendor,
|
|
4243
4243
|
error: error instanceof Error ? error.message : String(error)
|
|
4244
4244
|
});
|
|
@@ -4246,10 +4246,10 @@ async function cleanupConnectionResources(vendor, client, clearConnection, logge
|
|
|
4246
4246
|
clearConnection();
|
|
4247
4247
|
}
|
|
4248
4248
|
}
|
|
4249
|
-
async function closeManagedConnection(runtime,
|
|
4249
|
+
async function closeManagedConnection(runtime, logger24) {
|
|
4250
4250
|
const client = runtime.getClient();
|
|
4251
4251
|
if (client) {
|
|
4252
|
-
|
|
4252
|
+
logger24.info("Closing database connection", {
|
|
4253
4253
|
vendor: runtime.vendor,
|
|
4254
4254
|
state: runtime.getState()
|
|
4255
4255
|
});
|
|
@@ -4257,12 +4257,12 @@ async function closeManagedConnection(runtime, logger23) {
|
|
|
4257
4257
|
await shutdownClient(runtime.vendor, client);
|
|
4258
4258
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4259
4259
|
runtime.emitDisconnected();
|
|
4260
|
-
|
|
4260
|
+
logger24.debug("Database connection closed successfully", {
|
|
4261
4261
|
vendor: runtime.vendor,
|
|
4262
4262
|
state: runtime.getState()
|
|
4263
4263
|
});
|
|
4264
4264
|
} catch (error) {
|
|
4265
|
-
|
|
4265
|
+
logger24.error("Error closing database connection", {
|
|
4266
4266
|
vendor: runtime.vendor,
|
|
4267
4267
|
error: error instanceof Error ? error.message : String(error),
|
|
4268
4268
|
state: runtime.getState()
|
|
@@ -4435,11 +4435,11 @@ async function initializeSQLiteConnection(connection) {
|
|
|
4435
4435
|
}
|
|
4436
4436
|
|
|
4437
4437
|
// src/data/relational/connection/connection-initialization.ts
|
|
4438
|
-
async function initializeManagedConnection(runtime,
|
|
4438
|
+
async function initializeManagedConnection(runtime, logger24) {
|
|
4439
4439
|
const startTime = Date.now();
|
|
4440
4440
|
const currentGeneration = runtime.getConnectionGeneration();
|
|
4441
4441
|
if (runtime.getState() === "connected" /* CONNECTED */ && runtime.getClient()) {
|
|
4442
|
-
|
|
4442
|
+
logger24.warn("Re-initializing an already connected manager; emitting disconnected before cleanup", {
|
|
4443
4443
|
vendor: runtime.vendor
|
|
4444
4444
|
});
|
|
4445
4445
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
@@ -4451,11 +4451,11 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4451
4451
|
runtime.setClient(null);
|
|
4452
4452
|
runtime.setDb(null);
|
|
4453
4453
|
},
|
|
4454
|
-
|
|
4454
|
+
logger24
|
|
4455
4455
|
);
|
|
4456
4456
|
}
|
|
4457
4457
|
runtime.setState("connecting" /* CONNECTING */);
|
|
4458
|
-
|
|
4458
|
+
logger24.info("Initializing database connection", {
|
|
4459
4459
|
vendor: runtime.vendor,
|
|
4460
4460
|
connectionType: typeof runtime.config.connection,
|
|
4461
4461
|
state: runtime.getState()
|
|
@@ -4465,7 +4465,7 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4465
4465
|
runtime.setClient(initialized.client);
|
|
4466
4466
|
runtime.setDb(initialized.db);
|
|
4467
4467
|
if (currentGeneration !== runtime.getConnectionGeneration()) {
|
|
4468
|
-
|
|
4468
|
+
logger24.debug("Connection cancelled during initialization", {
|
|
4469
4469
|
vendor: runtime.vendor,
|
|
4470
4470
|
currentGeneration,
|
|
4471
4471
|
newGeneration: runtime.getConnectionGeneration()
|
|
@@ -4477,18 +4477,18 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4477
4477
|
runtime.setClient(null);
|
|
4478
4478
|
runtime.setDb(null);
|
|
4479
4479
|
},
|
|
4480
|
-
|
|
4480
|
+
logger24
|
|
4481
4481
|
);
|
|
4482
4482
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4483
4483
|
throw new Error("Connection cancelled during initialization");
|
|
4484
4484
|
}
|
|
4485
|
-
|
|
4485
|
+
logger24.debug("Validating connection health", { vendor: runtime.vendor });
|
|
4486
4486
|
const healthy = await runtime.isHealthy();
|
|
4487
4487
|
if (!healthy) {
|
|
4488
4488
|
throw new Error(`Failed to establish healthy connection to ${runtime.vendor} database`);
|
|
4489
4489
|
}
|
|
4490
4490
|
if (currentGeneration !== runtime.getConnectionGeneration()) {
|
|
4491
|
-
|
|
4491
|
+
logger24.debug("Connection cancelled during health check", {
|
|
4492
4492
|
vendor: runtime.vendor,
|
|
4493
4493
|
currentGeneration,
|
|
4494
4494
|
newGeneration: runtime.getConnectionGeneration()
|
|
@@ -4500,7 +4500,7 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4500
4500
|
runtime.setClient(null);
|
|
4501
4501
|
runtime.setDb(null);
|
|
4502
4502
|
},
|
|
4503
|
-
|
|
4503
|
+
logger24
|
|
4504
4504
|
);
|
|
4505
4505
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4506
4506
|
throw new Error("Connection cancelled during health check");
|
|
@@ -4508,7 +4508,7 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4508
4508
|
runtime.setState("connected" /* CONNECTED */);
|
|
4509
4509
|
runtime.emitConnected();
|
|
4510
4510
|
runtime.resetReconnectionAttempts();
|
|
4511
|
-
|
|
4511
|
+
logger24.info("Database connection initialized successfully", {
|
|
4512
4512
|
vendor: runtime.vendor,
|
|
4513
4513
|
duration: Date.now() - startTime,
|
|
4514
4514
|
state: runtime.getState()
|
|
@@ -4529,7 +4529,7 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4529
4529
|
if (runtime.errorListenerCount() > 0) {
|
|
4530
4530
|
runtime.emitError(normalizedError);
|
|
4531
4531
|
}
|
|
4532
|
-
|
|
4532
|
+
logger24.error(errorMessage, {
|
|
4533
4533
|
vendor: runtime.vendor,
|
|
4534
4534
|
error: normalizedError.message,
|
|
4535
4535
|
duration: Date.now() - startTime,
|
|
@@ -4542,13 +4542,13 @@ async function initializeManagedConnection(runtime, logger23) {
|
|
|
4542
4542
|
runtime.setClient(null);
|
|
4543
4543
|
runtime.setDb(null);
|
|
4544
4544
|
},
|
|
4545
|
-
|
|
4545
|
+
logger24
|
|
4546
4546
|
);
|
|
4547
4547
|
if (runtime.getReconnectionConfig().enabled && currentGeneration === runtime.getConnectionGeneration()) {
|
|
4548
4548
|
runtime.scheduleReconnection();
|
|
4549
4549
|
}
|
|
4550
4550
|
} else {
|
|
4551
|
-
|
|
4551
|
+
logger24.debug("Connection initialization cancelled", {
|
|
4552
4552
|
vendor: runtime.vendor,
|
|
4553
4553
|
duration: Date.now() - startTime,
|
|
4554
4554
|
state: runtime.getState()
|
|
@@ -4566,17 +4566,17 @@ function isSqliteNonQueryError(error) {
|
|
|
4566
4566
|
const hasNonQueryMessage = error.message.includes("does not return data");
|
|
4567
4567
|
return isSqliteOrTypeError && hasNonQueryMessage;
|
|
4568
4568
|
}
|
|
4569
|
-
async function checkConnectionHealth(args,
|
|
4569
|
+
async function checkConnectionHealth(args, logger24) {
|
|
4570
4570
|
if (!args.db || !args.client) {
|
|
4571
|
-
|
|
4571
|
+
logger24.debug("Health check failed: connection not initialized", { vendor: args.vendor });
|
|
4572
4572
|
return false;
|
|
4573
4573
|
}
|
|
4574
4574
|
try {
|
|
4575
4575
|
await args.execute(drizzleOrm.sql`SELECT 1`);
|
|
4576
|
-
|
|
4576
|
+
logger24.debug("Health check passed", { vendor: args.vendor });
|
|
4577
4577
|
return true;
|
|
4578
4578
|
} catch (error) {
|
|
4579
|
-
|
|
4579
|
+
logger24.debug("Health check failed", {
|
|
4580
4580
|
vendor: args.vendor,
|
|
4581
4581
|
error: error instanceof Error ? error.message : String(error)
|
|
4582
4582
|
});
|
|
@@ -4619,8 +4619,8 @@ function getConnectionPoolMetrics(vendor, client) {
|
|
|
4619
4619
|
}
|
|
4620
4620
|
|
|
4621
4621
|
// src/data/relational/connection/query-execution.ts
|
|
4622
|
-
async function executeQuery(context, query,
|
|
4623
|
-
|
|
4622
|
+
async function executeQuery(context, query, logger24) {
|
|
4623
|
+
logger24.debug("Executing SQL query", {
|
|
4624
4624
|
vendor: context.vendor
|
|
4625
4625
|
});
|
|
4626
4626
|
if (context.vendor === "sqlite") {
|
|
@@ -5789,9 +5789,8 @@ async function benchmarkStreamingSelectMemory(executor, input, options = {}) {
|
|
|
5789
5789
|
memorySavedPercent
|
|
5790
5790
|
};
|
|
5791
5791
|
}
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
var SAVEPOINT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5792
|
+
|
|
5793
|
+
// src/data/relational/query/transaction-options.ts
|
|
5795
5794
|
function toSqlIsolationLevel(level) {
|
|
5796
5795
|
switch (level) {
|
|
5797
5796
|
case "read uncommitted":
|
|
@@ -5804,7 +5803,7 @@ function toSqlIsolationLevel(level) {
|
|
|
5804
5803
|
return "SERIALIZABLE";
|
|
5805
5804
|
}
|
|
5806
5805
|
}
|
|
5807
|
-
function
|
|
5806
|
+
function resolveTransactionOptions(options) {
|
|
5808
5807
|
if (!options) {
|
|
5809
5808
|
return {};
|
|
5810
5809
|
}
|
|
@@ -5816,7 +5815,7 @@ function resolveOptions2(options) {
|
|
|
5816
5815
|
timeoutMs: options.timeoutMs
|
|
5817
5816
|
};
|
|
5818
5817
|
}
|
|
5819
|
-
function
|
|
5818
|
+
function withTransactionTimeout(operation, timeoutMs, onTimeout) {
|
|
5820
5819
|
if (!timeoutMs) {
|
|
5821
5820
|
return operation;
|
|
5822
5821
|
}
|
|
@@ -5842,6 +5841,10 @@ function withTimeout(operation, timeoutMs, onTimeout) {
|
|
|
5842
5841
|
});
|
|
5843
5842
|
});
|
|
5844
5843
|
}
|
|
5844
|
+
|
|
5845
|
+
// src/data/relational/query/transaction-managed.ts
|
|
5846
|
+
var logger12 = core.createLogger("agentforge:tools:data:relational:transaction");
|
|
5847
|
+
var SAVEPOINT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5845
5848
|
var ManagedTransaction = class {
|
|
5846
5849
|
id;
|
|
5847
5850
|
vendor;
|
|
@@ -5997,12 +6000,16 @@ var ManagedTransaction = class {
|
|
|
5997
6000
|
return null;
|
|
5998
6001
|
}
|
|
5999
6002
|
};
|
|
6003
|
+
|
|
6004
|
+
// src/data/relational/query/transaction-runner.ts
|
|
6005
|
+
var logger13 = core.createLogger("agentforge:tools:data:relational:transaction");
|
|
6006
|
+
var transactionSequence = 0;
|
|
6000
6007
|
async function withTransaction(manager, operation, options) {
|
|
6001
6008
|
const startTime = Date.now();
|
|
6002
|
-
const resolvedOptions =
|
|
6009
|
+
const resolvedOptions = resolveTransactionOptions(options);
|
|
6003
6010
|
const transactionId = `tx-${++transactionSequence}`;
|
|
6004
6011
|
const vendor = manager.getVendor();
|
|
6005
|
-
|
|
6012
|
+
logger13.debug("Starting transaction", {
|
|
6006
6013
|
transactionId,
|
|
6007
6014
|
vendor,
|
|
6008
6015
|
...resolvedOptions.isolationLevel ? { isolationLevel: resolvedOptions.isolationLevel } : {},
|
|
@@ -6017,7 +6024,7 @@ async function withTransaction(manager, operation, options) {
|
|
|
6017
6024
|
});
|
|
6018
6025
|
await transaction.begin();
|
|
6019
6026
|
try {
|
|
6020
|
-
const result = await
|
|
6027
|
+
const result = await withTransactionTimeout(
|
|
6021
6028
|
operation(transaction),
|
|
6022
6029
|
resolvedOptions.timeoutMs,
|
|
6023
6030
|
() => {
|
|
@@ -6029,7 +6036,7 @@ async function withTransaction(manager, operation, options) {
|
|
|
6029
6036
|
if (transaction.isActive()) {
|
|
6030
6037
|
await transaction.commit();
|
|
6031
6038
|
}
|
|
6032
|
-
|
|
6039
|
+
logger13.debug("Transaction committed", {
|
|
6033
6040
|
transactionId,
|
|
6034
6041
|
vendor,
|
|
6035
6042
|
duration: Date.now() - startTime
|
|
@@ -6040,14 +6047,14 @@ async function withTransaction(manager, operation, options) {
|
|
|
6040
6047
|
try {
|
|
6041
6048
|
await transaction.rollback();
|
|
6042
6049
|
} catch (rollbackError) {
|
|
6043
|
-
|
|
6050
|
+
logger13.error("Transaction rollback failed", {
|
|
6044
6051
|
transactionId,
|
|
6045
6052
|
vendor,
|
|
6046
6053
|
error: rollbackError instanceof Error ? rollbackError.message : String(rollbackError)
|
|
6047
6054
|
});
|
|
6048
6055
|
}
|
|
6049
6056
|
}
|
|
6050
|
-
|
|
6057
|
+
logger13.error("Transaction failed", {
|
|
6051
6058
|
transactionId,
|
|
6052
6059
|
vendor,
|
|
6053
6060
|
duration: Date.now() - startTime,
|
|
@@ -6538,7 +6545,7 @@ async function inspectSQLite(runQueryRows) {
|
|
|
6538
6545
|
}
|
|
6539
6546
|
|
|
6540
6547
|
// src/data/relational/schema/schema-inspector.ts
|
|
6541
|
-
var
|
|
6548
|
+
var logger14 = core.createLogger("agentforge:tools:data:relational:schema-inspector");
|
|
6542
6549
|
var DEFAULT_CACHE_TTL_MS = 6e4;
|
|
6543
6550
|
var schemaCache = /* @__PURE__ */ new Map();
|
|
6544
6551
|
var SchemaInspector = class _SchemaInspector {
|
|
@@ -6566,7 +6573,7 @@ var SchemaInspector = class _SchemaInspector {
|
|
|
6566
6573
|
if (!bypassCache && this.cacheKey) {
|
|
6567
6574
|
const cached = schemaCache.get(this.cacheKey);
|
|
6568
6575
|
if (cached && cached.expiresAt > Date.now()) {
|
|
6569
|
-
|
|
6576
|
+
logger14.debug("Schema cache hit", { vendor: this.vendor });
|
|
6570
6577
|
return filterSchemaTables(cloneSchema(cached.schema), tableFilters);
|
|
6571
6578
|
}
|
|
6572
6579
|
}
|
|
@@ -6611,7 +6618,7 @@ var SchemaInspector = class _SchemaInspector {
|
|
|
6611
6618
|
return result.rows;
|
|
6612
6619
|
}
|
|
6613
6620
|
};
|
|
6614
|
-
var
|
|
6621
|
+
var logger15 = core.createLogger("agentforge:tools:data:relational:schema-validator");
|
|
6615
6622
|
function validateTableExists(schema, tableName) {
|
|
6616
6623
|
const errors = [];
|
|
6617
6624
|
if (!tableName || typeof tableName !== "string") {
|
|
@@ -6625,7 +6632,7 @@ function validateTableExists(schema, tableName) {
|
|
|
6625
6632
|
`Table "${tableName}" does not exist. Available tables: ${available || "(none)"}`
|
|
6626
6633
|
);
|
|
6627
6634
|
}
|
|
6628
|
-
|
|
6635
|
+
logger15.debug("Table existence validation", { tableName, valid: errors.length === 0 });
|
|
6629
6636
|
return { valid: errors.length === 0, errors };
|
|
6630
6637
|
}
|
|
6631
6638
|
function validateColumnsExist(schema, tableName, columnNames) {
|
|
@@ -6648,7 +6655,7 @@ function validateColumnsExist(schema, tableName, columnNames) {
|
|
|
6648
6655
|
);
|
|
6649
6656
|
}
|
|
6650
6657
|
}
|
|
6651
|
-
|
|
6658
|
+
logger15.debug("Column existence validation", {
|
|
6652
6659
|
tableName,
|
|
6653
6660
|
columnCount: columnNames.length,
|
|
6654
6661
|
valid: errors.length === 0
|
|
@@ -6684,7 +6691,7 @@ function validateColumnTypes(schema, tableName, expectedTypes) {
|
|
|
6684
6691
|
);
|
|
6685
6692
|
}
|
|
6686
6693
|
}
|
|
6687
|
-
|
|
6694
|
+
logger15.debug("Column type validation", {
|
|
6688
6695
|
tableName,
|
|
6689
6696
|
typeChecks: Object.keys(expectedTypes).length,
|
|
6690
6697
|
valid: errors.length === 0
|
|
@@ -6704,7 +6711,7 @@ function findTable(schema, tableName) {
|
|
|
6704
6711
|
function formatTableName(table) {
|
|
6705
6712
|
return table.schema ? `${table.schema}.${table.name}` : table.name;
|
|
6706
6713
|
}
|
|
6707
|
-
var
|
|
6714
|
+
var logger16 = core.createLogger("agentforge:tools:data:relational:type-mapper");
|
|
6708
6715
|
var POSTGRES_TYPE_MAP = {
|
|
6709
6716
|
// Numeric
|
|
6710
6717
|
smallint: "number",
|
|
@@ -6870,7 +6877,7 @@ function mapColumnType(vendor, dbType, nullable = false) {
|
|
|
6870
6877
|
const result = { tsType, nullable, dbType };
|
|
6871
6878
|
if (tsType === "unknown" && normalised !== "json" && normalised !== "jsonb") {
|
|
6872
6879
|
result.notes = `No explicit mapping for "${dbType}"; defaulting to unknown`;
|
|
6873
|
-
|
|
6880
|
+
logger16.debug("Unmapped database type", { vendor, dbType, normalised });
|
|
6874
6881
|
}
|
|
6875
6882
|
if ((normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql")) {
|
|
6876
6883
|
result.notes = "Mapped to string to avoid JavaScript number precision loss for 64-bit integers";
|
|
@@ -6885,7 +6892,7 @@ function mapSchemaTypes(vendor, columns) {
|
|
|
6885
6892
|
}
|
|
6886
6893
|
result.get(col.table).set(col.name, mapColumnType(vendor, col.type, col.nullable));
|
|
6887
6894
|
}
|
|
6888
|
-
|
|
6895
|
+
logger16.debug("Schema type mapping complete", {
|
|
6889
6896
|
vendor,
|
|
6890
6897
|
tables: result.size,
|
|
6891
6898
|
columns: columns.length
|
|
@@ -6902,7 +6909,7 @@ function normaliseDbType(raw) {
|
|
|
6902
6909
|
type = type.replace(/\s+unsigned$/, "");
|
|
6903
6910
|
return type.trim();
|
|
6904
6911
|
}
|
|
6905
|
-
var
|
|
6912
|
+
var logger17 = core.createLogger("agentforge:tools:data:relational:schema-diff");
|
|
6906
6913
|
function diffSchemas(before, after) {
|
|
6907
6914
|
const tableDiffs = [];
|
|
6908
6915
|
let columnsAdded = 0;
|
|
@@ -6942,7 +6949,7 @@ function diffSchemas(before, after) {
|
|
|
6942
6949
|
const tablesRemoved = tableDiffs.filter((d) => d.type === "removed").length;
|
|
6943
6950
|
const tablesChanged = tableDiffs.filter((d) => d.type === "changed").length;
|
|
6944
6951
|
const identical = tableDiffs.length === 0;
|
|
6945
|
-
|
|
6952
|
+
logger17.debug("Schema diff computed", {
|
|
6946
6953
|
identical,
|
|
6947
6954
|
tablesAdded,
|
|
6948
6955
|
tablesRemoved,
|
|
@@ -6986,7 +6993,7 @@ function importSchemaFromJson(json) {
|
|
|
6986
6993
|
throw new Error(`Invalid schema JSON: table "${table.name}" missing "primaryKey" array`);
|
|
6987
6994
|
}
|
|
6988
6995
|
}
|
|
6989
|
-
|
|
6996
|
+
logger17.debug("Schema imported from JSON", {
|
|
6990
6997
|
vendor: obj.vendor,
|
|
6991
6998
|
tableCount: obj.tables.length
|
|
6992
6999
|
});
|
|
@@ -7283,7 +7290,7 @@ function isSafeValidationError(error) {
|
|
|
7283
7290
|
}
|
|
7284
7291
|
|
|
7285
7292
|
// src/data/relational/tools/relational-select/executor.ts
|
|
7286
|
-
var
|
|
7293
|
+
var logger18 = core.createLogger("agentforge:tools:data:relational:select");
|
|
7287
7294
|
function toSelectQueryInput(input) {
|
|
7288
7295
|
return {
|
|
7289
7296
|
table: input.table,
|
|
@@ -7297,7 +7304,7 @@ function toSelectQueryInput(input) {
|
|
|
7297
7304
|
}
|
|
7298
7305
|
async function executeSelect(manager, input, context) {
|
|
7299
7306
|
const startTime = Date.now();
|
|
7300
|
-
|
|
7307
|
+
logger18.debug("Building SELECT query", {
|
|
7301
7308
|
vendor: input.vendor,
|
|
7302
7309
|
table: input.table,
|
|
7303
7310
|
hasWhere: !!input.where,
|
|
@@ -7315,7 +7322,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7315
7322
|
};
|
|
7316
7323
|
const streamInput = toSelectQueryInput(input);
|
|
7317
7324
|
if (input.streaming.benchmark) {
|
|
7318
|
-
|
|
7325
|
+
logger18.warn("Streaming benchmark enabled; SELECT will execute up to three times (result + benchmark regular + benchmark streaming).", {
|
|
7319
7326
|
vendor: input.vendor,
|
|
7320
7327
|
table: input.table,
|
|
7321
7328
|
chunkSize: streamOptions.chunkSize ?? DEFAULT_CHUNK_SIZE,
|
|
@@ -7326,7 +7333,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7326
7333
|
const streamResult = await executeStreamingSelect(executor, streamInput, streamOptions);
|
|
7327
7334
|
const benchmark = input.streaming.benchmark ? await benchmarkStreamingSelectMemory(executor, streamInput, streamOptions) : void 0;
|
|
7328
7335
|
const executionTime2 = Date.now() - startTime;
|
|
7329
|
-
|
|
7336
|
+
logger18.debug("Streaming SELECT query executed successfully", {
|
|
7330
7337
|
vendor: input.vendor,
|
|
7331
7338
|
table: input.table,
|
|
7332
7339
|
rowCount: streamResult.rowCount,
|
|
@@ -7355,7 +7362,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7355
7362
|
const executionTime = Date.now() - startTime;
|
|
7356
7363
|
const rows = Array.isArray(result) ? result : result.rows || [];
|
|
7357
7364
|
const rowCount = rows.length;
|
|
7358
|
-
|
|
7365
|
+
logger18.debug("SELECT query executed successfully", {
|
|
7359
7366
|
vendor: input.vendor,
|
|
7360
7367
|
table: input.table,
|
|
7361
7368
|
rowCount,
|
|
@@ -7368,7 +7375,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7368
7375
|
};
|
|
7369
7376
|
} catch (error) {
|
|
7370
7377
|
const executionTime = Date.now() - startTime;
|
|
7371
|
-
|
|
7378
|
+
logger18.error("SELECT query execution failed", {
|
|
7372
7379
|
vendor: input.vendor,
|
|
7373
7380
|
table: input.table,
|
|
7374
7381
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -7544,7 +7551,7 @@ function isSafeInsertError(error) {
|
|
|
7544
7551
|
}
|
|
7545
7552
|
|
|
7546
7553
|
// src/data/relational/tools/relational-insert/executor.ts
|
|
7547
|
-
var
|
|
7554
|
+
var logger19 = core.createLogger("agentforge:tools:data:relational:insert");
|
|
7548
7555
|
function toNumber(value) {
|
|
7549
7556
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
7550
7557
|
}
|
|
@@ -7693,7 +7700,7 @@ async function executeInsertInBatchMode(manager, input, context, options) {
|
|
|
7693
7700
|
maxRetries: options.maxRetries,
|
|
7694
7701
|
retryDelayMs: options.retryDelayMs,
|
|
7695
7702
|
onProgress: (progress) => {
|
|
7696
|
-
|
|
7703
|
+
logger19.debug("INSERT batch progress", {
|
|
7697
7704
|
vendor: input.vendor,
|
|
7698
7705
|
table: input.table,
|
|
7699
7706
|
...progress
|
|
@@ -7706,7 +7713,7 @@ async function executeInsertInBatchMode(manager, input, context, options) {
|
|
|
7706
7713
|
const insertedIds = batchResult.results.flatMap((result) => result.insertedIds);
|
|
7707
7714
|
let benchmark;
|
|
7708
7715
|
if (options.benchmark) {
|
|
7709
|
-
|
|
7716
|
+
logger19.warn("INSERT batch benchmark enabled. Synthetic benchmark callbacks are side-effect free and do not execute SQL.", {
|
|
7710
7717
|
vendor: input.vendor,
|
|
7711
7718
|
table: input.table,
|
|
7712
7719
|
totalRows: input.data.length,
|
|
@@ -7743,7 +7750,7 @@ async function executeInsertInBatchMode(manager, input, context, options) {
|
|
|
7743
7750
|
}
|
|
7744
7751
|
async function executeInsert(manager, input, context) {
|
|
7745
7752
|
const startTime = Date.now();
|
|
7746
|
-
|
|
7753
|
+
logger19.debug("Building INSERT query", {
|
|
7747
7754
|
vendor: input.vendor,
|
|
7748
7755
|
table: input.table,
|
|
7749
7756
|
isBatch: Array.isArray(input.data),
|
|
@@ -7759,7 +7766,7 @@ async function executeInsert(manager, input, context) {
|
|
|
7759
7766
|
batchOptions
|
|
7760
7767
|
) : await executeInsertOnce(manager, input, context);
|
|
7761
7768
|
const executionTime = Date.now() - startTime;
|
|
7762
|
-
|
|
7769
|
+
logger19.debug("INSERT query executed successfully", {
|
|
7763
7770
|
vendor: input.vendor,
|
|
7764
7771
|
table: input.table,
|
|
7765
7772
|
rowCount: result.rowCount,
|
|
@@ -7775,7 +7782,7 @@ async function executeInsert(manager, input, context) {
|
|
|
7775
7782
|
};
|
|
7776
7783
|
} catch (error) {
|
|
7777
7784
|
const executionTime = Date.now() - startTime;
|
|
7778
|
-
|
|
7785
|
+
logger19.error("INSERT query execution failed", {
|
|
7779
7786
|
vendor: input.vendor,
|
|
7780
7787
|
table: input.table,
|
|
7781
7788
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -8105,7 +8112,7 @@ function isSafeUpdateError(error) {
|
|
|
8105
8112
|
}
|
|
8106
8113
|
|
|
8107
8114
|
// src/data/relational/tools/relational-update/executor.ts
|
|
8108
|
-
var
|
|
8115
|
+
var logger20 = core.createLogger("agentforge:tools:data:relational:update");
|
|
8109
8116
|
function toNumber2(value) {
|
|
8110
8117
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
8111
8118
|
}
|
|
@@ -8227,7 +8234,7 @@ async function executeUpdateInBatchMode(manager, input, context, options) {
|
|
|
8227
8234
|
maxRetries: options.maxRetries,
|
|
8228
8235
|
retryDelayMs: options.retryDelayMs,
|
|
8229
8236
|
onProgress: (progress) => {
|
|
8230
|
-
|
|
8237
|
+
logger20.debug("UPDATE batch progress", {
|
|
8231
8238
|
vendor: input.vendor,
|
|
8232
8239
|
table: input.table,
|
|
8233
8240
|
...progress
|
|
@@ -8239,7 +8246,7 @@ async function executeUpdateInBatchMode(manager, input, context, options) {
|
|
|
8239
8246
|
const operationFailures = batchResult.results.flatMap((result) => result.failures);
|
|
8240
8247
|
let benchmark;
|
|
8241
8248
|
if (options.benchmark) {
|
|
8242
|
-
|
|
8249
|
+
logger20.warn("UPDATE batch benchmark enabled. Synthetic benchmark callbacks are side-effect free and do not execute SQL.", {
|
|
8243
8250
|
vendor: input.vendor,
|
|
8244
8251
|
table: input.table,
|
|
8245
8252
|
operationCount: input.operations.length,
|
|
@@ -8274,7 +8281,7 @@ async function executeUpdateInBatchMode(manager, input, context, options) {
|
|
|
8274
8281
|
}
|
|
8275
8282
|
async function executeUpdate(manager, input, context) {
|
|
8276
8283
|
const startTime = Date.now();
|
|
8277
|
-
|
|
8284
|
+
logger20.debug("Building UPDATE query", {
|
|
8278
8285
|
vendor: input.vendor,
|
|
8279
8286
|
table: input.table,
|
|
8280
8287
|
hasWhere: !!input.where?.length,
|
|
@@ -8292,7 +8299,7 @@ async function executeUpdate(manager, input, context) {
|
|
|
8292
8299
|
batchOptions
|
|
8293
8300
|
) : await executeSingleUpdate(manager, input, toSingleUpdateOperation(input), context);
|
|
8294
8301
|
const executionTime = Date.now() - startTime;
|
|
8295
|
-
|
|
8302
|
+
logger20.debug("UPDATE query executed successfully", {
|
|
8296
8303
|
vendor: input.vendor,
|
|
8297
8304
|
table: input.table,
|
|
8298
8305
|
rowCount: result.rowCount,
|
|
@@ -8306,7 +8313,7 @@ async function executeUpdate(manager, input, context) {
|
|
|
8306
8313
|
};
|
|
8307
8314
|
} catch (error) {
|
|
8308
8315
|
const executionTime = Date.now() - startTime;
|
|
8309
|
-
|
|
8316
|
+
logger20.error("UPDATE query execution failed", {
|
|
8310
8317
|
vendor: input.vendor,
|
|
8311
8318
|
table: input.table,
|
|
8312
8319
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -8610,7 +8617,7 @@ function isSafeDeleteError(error) {
|
|
|
8610
8617
|
}
|
|
8611
8618
|
|
|
8612
8619
|
// src/data/relational/tools/relational-delete/executor.ts
|
|
8613
|
-
var
|
|
8620
|
+
var logger21 = core.createLogger("agentforge:tools:data:relational:delete");
|
|
8614
8621
|
function toNumber3(value) {
|
|
8615
8622
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
8616
8623
|
}
|
|
@@ -8731,7 +8738,7 @@ async function executeDeleteInBatchMode(manager, input, context, options) {
|
|
|
8731
8738
|
maxRetries: options.maxRetries,
|
|
8732
8739
|
retryDelayMs: options.retryDelayMs,
|
|
8733
8740
|
onProgress: (progress) => {
|
|
8734
|
-
|
|
8741
|
+
logger21.debug("DELETE batch progress", {
|
|
8735
8742
|
vendor: input.vendor,
|
|
8736
8743
|
table: input.table,
|
|
8737
8744
|
...progress
|
|
@@ -8744,7 +8751,7 @@ async function executeDeleteInBatchMode(manager, input, context, options) {
|
|
|
8744
8751
|
const operationFailures = batchResult.results.flatMap((result) => result.failures);
|
|
8745
8752
|
let benchmark;
|
|
8746
8753
|
if (options.benchmark) {
|
|
8747
|
-
|
|
8754
|
+
logger21.warn("DELETE batch benchmark enabled. Synthetic benchmark callbacks are side-effect free and do not execute SQL.", {
|
|
8748
8755
|
vendor: input.vendor,
|
|
8749
8756
|
table: input.table,
|
|
8750
8757
|
operationCount: input.operations.length,
|
|
@@ -8780,7 +8787,7 @@ async function executeDeleteInBatchMode(manager, input, context, options) {
|
|
|
8780
8787
|
}
|
|
8781
8788
|
async function executeDelete(manager, input, context) {
|
|
8782
8789
|
const startTime = Date.now();
|
|
8783
|
-
|
|
8790
|
+
logger21.debug("Building DELETE query", {
|
|
8784
8791
|
vendor: input.vendor,
|
|
8785
8792
|
table: input.table,
|
|
8786
8793
|
hasWhere: !!input.where?.length,
|
|
@@ -8799,7 +8806,7 @@ async function executeDelete(manager, input, context) {
|
|
|
8799
8806
|
batchOptions
|
|
8800
8807
|
) : await executeSingleDelete(manager, input, toSingleDeleteOperation(input), context);
|
|
8801
8808
|
const executionTime = Date.now() - startTime;
|
|
8802
|
-
|
|
8809
|
+
logger21.debug("DELETE query executed successfully", {
|
|
8803
8810
|
vendor: input.vendor,
|
|
8804
8811
|
table: input.table,
|
|
8805
8812
|
rowCount: result.rowCount,
|
|
@@ -8815,7 +8822,7 @@ async function executeDelete(manager, input, context) {
|
|
|
8815
8822
|
};
|
|
8816
8823
|
} catch (error) {
|
|
8817
8824
|
const executionTime = Date.now() - startTime;
|
|
8818
|
-
|
|
8825
|
+
logger21.error("DELETE query execution failed", {
|
|
8819
8826
|
vendor: input.vendor,
|
|
8820
8827
|
table: input.table,
|
|
8821
8828
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -8920,7 +8927,7 @@ function isSafeGetSchemaValidationError(error) {
|
|
|
8920
8927
|
}
|
|
8921
8928
|
|
|
8922
8929
|
// src/data/relational/tools/relational-get-schema.ts
|
|
8923
|
-
var
|
|
8930
|
+
var logger22 = core.createLogger("agentforge:tools:data:relational:get-schema");
|
|
8924
8931
|
function buildSchemaCacheKey(vendor, connectionString, database) {
|
|
8925
8932
|
const databaseScope = database ?? "default";
|
|
8926
8933
|
const connectionHash = crypto.createHash("sha256").update(connectionString).digest("hex");
|
|
@@ -8992,7 +8999,7 @@ var relationalGetSchema = core.toolBuilder().name("relational-get-schema").displ
|
|
|
8992
8999
|
summary
|
|
8993
9000
|
};
|
|
8994
9001
|
} catch (error) {
|
|
8995
|
-
|
|
9002
|
+
logger22.error("Schema introspection failed", {
|
|
8996
9003
|
vendor: input.vendor,
|
|
8997
9004
|
hasTablesFilter: Array.isArray(input.tables),
|
|
8998
9005
|
tablesFilterCount: input.tables?.length ?? 0,
|
|
@@ -10158,7 +10165,7 @@ var AskHumanInputSchema = zod.z.object({
|
|
|
10158
10165
|
suggestions: zod.z.array(zod.z.string()).optional().describe("Suggested responses for the human")
|
|
10159
10166
|
});
|
|
10160
10167
|
var logLevel3 = process.env.LOG_LEVEL?.toLowerCase() || core.LogLevel.INFO;
|
|
10161
|
-
var
|
|
10168
|
+
var logger23 = core.createLogger("agentforge:tools:agent:ask-human", { level: logLevel3 });
|
|
10162
10169
|
function isRecord2(value) {
|
|
10163
10170
|
return typeof value === "object" && value !== null;
|
|
10164
10171
|
}
|
|
@@ -10223,7 +10230,7 @@ function createAskHumanTool() {
|
|
|
10223
10230
|
suggestions: validatedInput.suggestions,
|
|
10224
10231
|
status: "pending"
|
|
10225
10232
|
};
|
|
10226
|
-
|
|
10233
|
+
logger23.debug("About to call interrupt()", {
|
|
10227
10234
|
humanRequest: {
|
|
10228
10235
|
id: humanRequest.id,
|
|
10229
10236
|
question: humanRequest.question,
|
|
@@ -10239,13 +10246,13 @@ function createAskHumanTool() {
|
|
|
10239
10246
|
let response;
|
|
10240
10247
|
try {
|
|
10241
10248
|
response = interrupt(humanRequest);
|
|
10242
|
-
|
|
10249
|
+
logger23.debug("interrupt() returned successfully", {
|
|
10243
10250
|
responseType: typeof response,
|
|
10244
10251
|
hasResponse: response != null,
|
|
10245
10252
|
...typeof response === "string" ? { responseLength: response.length } : {}
|
|
10246
10253
|
});
|
|
10247
10254
|
} catch (error) {
|
|
10248
|
-
|
|
10255
|
+
logger23.debug("interrupt() threw error (expected for GraphInterrupt)", {
|
|
10249
10256
|
...error && typeof error === "object" && "constructor" in error ? { errorType: error.constructor?.name } : {},
|
|
10250
10257
|
error: error instanceof Error ? error.message : String(error)
|
|
10251
10258
|
});
|