@agentforge/tools 0.16.62 → 0.16.64
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 +155 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +155 -135
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
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, logger18) {
|
|
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, logger19) {
|
|
|
824
824
|
message: zod.z.string().describe("Message content to send")
|
|
825
825
|
})
|
|
826
826
|
).implementSafe(async ({ channel, message }) => {
|
|
827
|
-
|
|
827
|
+
logger18.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, logger19) {
|
|
|
833
833
|
username: config.botName,
|
|
834
834
|
icon_emoji: config.botIcon
|
|
835
835
|
});
|
|
836
|
-
|
|
836
|
+
logger18.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, logger19) {
|
|
|
846
846
|
message_id: result.ts
|
|
847
847
|
};
|
|
848
848
|
} catch (error) {
|
|
849
|
-
|
|
849
|
+
logger18.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, logger19) {
|
|
|
855
855
|
}
|
|
856
856
|
}).build();
|
|
857
857
|
}
|
|
858
|
-
function createNotifySlackTool(getSlackClient,
|
|
858
|
+
function createNotifySlackTool(getSlackClient, logger18) {
|
|
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, logger19) {
|
|
|
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
|
+
logger18.info("notify-slack called", {
|
|
869
869
|
channel,
|
|
870
870
|
messageLength: message.length,
|
|
871
871
|
mentionCount: mentions.length
|
|
@@ -879,7 +879,7 @@ function createNotifySlackTool(getSlackClient, logger19) {
|
|
|
879
879
|
username: config.botName,
|
|
880
880
|
icon_emoji: config.botIcon
|
|
881
881
|
});
|
|
882
|
-
|
|
882
|
+
logger18.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, logger19) {
|
|
|
893
893
|
};
|
|
894
894
|
}).build();
|
|
895
895
|
}
|
|
896
|
-
function createGetSlackChannelsTool(getSlackClient,
|
|
896
|
+
function createGetSlackChannelsTool(getSlackClient, logger18) {
|
|
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, logger19) {
|
|
|
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
|
+
logger18.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, logger19) {
|
|
|
915
915
|
});
|
|
916
916
|
allChannels = [...allChannels, ...privateChannels.channels || []];
|
|
917
917
|
}
|
|
918
|
-
|
|
918
|
+
logger18.info("get-slack-channels result", {
|
|
919
919
|
channelCount: allChannels.length,
|
|
920
920
|
includePrivate: include_private
|
|
921
921
|
});
|
|
@@ -930,7 +930,7 @@ function createGetSlackChannelsTool(getSlackClient, logger19) {
|
|
|
930
930
|
};
|
|
931
931
|
}).build();
|
|
932
932
|
}
|
|
933
|
-
function createGetSlackMessagesTool(getSlackClient,
|
|
933
|
+
function createGetSlackMessagesTool(getSlackClient, logger18) {
|
|
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, logger19) {
|
|
|
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
|
+
logger18.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, logger19) {
|
|
|
950
950
|
});
|
|
951
951
|
const found = channels.channels?.find((c) => c.name === channel);
|
|
952
952
|
if (!found) {
|
|
953
|
-
|
|
953
|
+
logger18.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, logger19) {
|
|
|
962
962
|
limit: Math.min(limit, 100)
|
|
963
963
|
// Cap at 100 for performance
|
|
964
964
|
});
|
|
965
|
-
|
|
965
|
+
logger18.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, logger19) {
|
|
|
980
980
|
})) || []
|
|
981
981
|
};
|
|
982
982
|
} catch (error) {
|
|
983
|
-
|
|
983
|
+
logger18.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, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1091
1091
|
lastModified: page.version?.when || ""
|
|
1092
1092
|
}));
|
|
1093
1093
|
if (results.length === 0) {
|
|
1094
|
-
|
|
1094
|
+
logger18.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
|
+
logger18.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, logger19) {
|
|
|
1112
1112
|
results
|
|
1113
1113
|
});
|
|
1114
1114
|
} catch (error) {
|
|
1115
|
-
|
|
1115
|
+
logger18.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, logger19) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
}).build();
|
|
1126
1126
|
}
|
|
1127
|
-
function createGetConfluencePageTool(getAuth, getAuthHeader2,
|
|
1127
|
+
function createGetConfluencePageTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
});
|
|
1143
1143
|
const page = response.data;
|
|
1144
|
-
|
|
1144
|
+
logger18.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, logger19) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
});
|
|
1165
1165
|
} catch (error) {
|
|
1166
|
-
|
|
1166
|
+
logger18.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, logger19) {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
}).build();
|
|
1177
1177
|
}
|
|
1178
|
-
function createListConfluenceSpacesTool(getAuth, getAuthHeader2,
|
|
1178
|
+
function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1198
1198
|
description: space.description?.plain?.value || "",
|
|
1199
1199
|
url: `${ATLASSIAN_SITE_URL}/wiki${space._links.webui}`
|
|
1200
1200
|
}));
|
|
1201
|
-
|
|
1201
|
+
logger18.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, logger19) {
|
|
|
1209
1209
|
spaces
|
|
1210
1210
|
});
|
|
1211
1211
|
} catch (error) {
|
|
1212
|
-
|
|
1212
|
+
logger18.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, logger19) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
}).build();
|
|
1222
1222
|
}
|
|
1223
|
-
function createGetSpacePagesTool(getAuth, getAuthHeader2,
|
|
1223
|
+
function createGetSpacePagesTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1247
1247
|
lastModified: page.version?.when || ""
|
|
1248
1248
|
}));
|
|
1249
1249
|
if (pages.length === 0) {
|
|
1250
|
-
|
|
1250
|
+
logger18.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
|
+
logger18.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, logger19) {
|
|
|
1266
1266
|
pages
|
|
1267
1267
|
});
|
|
1268
1268
|
} catch (error) {
|
|
1269
|
-
|
|
1269
|
+
logger18.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, logger19) {
|
|
|
1278
1278
|
}
|
|
1279
1279
|
}).build();
|
|
1280
1280
|
}
|
|
1281
|
-
function createCreateConfluencePageTool(getAuth, getAuthHeader2,
|
|
1281
|
+
function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
1314
|
);
|
|
1315
|
-
|
|
1315
|
+
logger18.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, logger19) {
|
|
|
1328
1328
|
}
|
|
1329
1329
|
});
|
|
1330
1330
|
} catch (error) {
|
|
1331
|
-
|
|
1331
|
+
logger18.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, logger19) {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
}).build();
|
|
1343
1343
|
}
|
|
1344
|
-
function createUpdateConfluencePageTool(getAuth, getAuthHeader2,
|
|
1344
|
+
function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.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, logger19) {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
}
|
|
1382
1382
|
);
|
|
1383
|
-
|
|
1383
|
+
logger18.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, logger19) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
});
|
|
1399
1399
|
} catch (error) {
|
|
1400
|
-
|
|
1400
|
+
logger18.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, logger19) {
|
|
|
1410
1410
|
}
|
|
1411
1411
|
}).build();
|
|
1412
1412
|
}
|
|
1413
|
-
function createArchiveConfluencePageTool(getAuth, getAuthHeader2,
|
|
1413
|
+
function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger18) {
|
|
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
|
+
logger18.info("archive-confluence-page called", {
|
|
1419
1419
|
page_id,
|
|
1420
1420
|
...reason ? { reason } : {}
|
|
1421
1421
|
});
|
|
@@ -1449,7 +1449,7 @@ function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
1451
|
);
|
|
1452
|
-
|
|
1452
|
+
logger18.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, logger19) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
});
|
|
1469
1469
|
} catch (error) {
|
|
1470
|
-
|
|
1470
|
+
logger18.error("archive-confluence-page error", {
|
|
1471
1471
|
page_id,
|
|
1472
1472
|
error: error.response?.data?.message || error.message,
|
|
1473
1473
|
status: error.response?.status
|
|
@@ -4195,19 +4195,19 @@ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
|
4195
4195
|
ConnectionState2["ERROR"] = "error";
|
|
4196
4196
|
return ConnectionState2;
|
|
4197
4197
|
})(ConnectionState || {});
|
|
4198
|
-
function cancelPendingReconnection(timer,
|
|
4198
|
+
function cancelPendingReconnection(timer, logger18, vendor, message) {
|
|
4199
4199
|
if (!timer) {
|
|
4200
4200
|
return null;
|
|
4201
4201
|
}
|
|
4202
|
-
|
|
4202
|
+
logger18.debug(message, { vendor });
|
|
4203
4203
|
clearTimeout(timer);
|
|
4204
4204
|
return null;
|
|
4205
4205
|
}
|
|
4206
|
-
async function waitForInFlightConnection(promise,
|
|
4206
|
+
async function waitForInFlightConnection(promise, logger18, vendor, phase) {
|
|
4207
4207
|
if (!promise) {
|
|
4208
4208
|
return null;
|
|
4209
4209
|
}
|
|
4210
|
-
|
|
4210
|
+
logger18.debug(`Waiting for in-flight connection attempt to complete before ${phase}`, {
|
|
4211
4211
|
vendor
|
|
4212
4212
|
});
|
|
4213
4213
|
try {
|
|
@@ -4224,9 +4224,9 @@ function shutdownClient(vendor, client) {
|
|
|
4224
4224
|
client.close();
|
|
4225
4225
|
}
|
|
4226
4226
|
}
|
|
4227
|
-
function scheduleReconnection(context,
|
|
4227
|
+
function scheduleReconnection(context, logger18) {
|
|
4228
4228
|
if (context.reconnectionConfig.maxAttempts > 0 && context.reconnectionAttempts >= context.reconnectionConfig.maxAttempts) {
|
|
4229
|
-
|
|
4229
|
+
logger18.error("Max reconnection attempts reached", {
|
|
4230
4230
|
vendor: context.vendor,
|
|
4231
4231
|
attempts: context.reconnectionAttempts,
|
|
4232
4232
|
maxAttempts: context.reconnectionConfig.maxAttempts
|
|
@@ -4240,7 +4240,7 @@ function scheduleReconnection(context, logger19) {
|
|
|
4240
4240
|
const nextAttempt = context.reconnectionAttempts + 1;
|
|
4241
4241
|
context.setReconnectionAttempts(nextAttempt);
|
|
4242
4242
|
context.setState("reconnecting" /* RECONNECTING */);
|
|
4243
|
-
|
|
4243
|
+
logger18.info("Scheduling reconnection attempt", {
|
|
4244
4244
|
vendor: context.vendor,
|
|
4245
4245
|
attempt: nextAttempt,
|
|
4246
4246
|
maxAttempts: context.reconnectionConfig.maxAttempts,
|
|
@@ -4254,7 +4254,7 @@ function scheduleReconnection(context, logger19) {
|
|
|
4254
4254
|
const timer = setTimeout(async () => {
|
|
4255
4255
|
context.setReconnectionTimer(null);
|
|
4256
4256
|
try {
|
|
4257
|
-
|
|
4257
|
+
logger18.info("Attempting reconnection", {
|
|
4258
4258
|
vendor: context.vendor,
|
|
4259
4259
|
attempt: nextAttempt
|
|
4260
4260
|
});
|
|
@@ -4264,7 +4264,7 @@ function scheduleReconnection(context, logger19) {
|
|
|
4264
4264
|
context.setConnectPromise(promise);
|
|
4265
4265
|
await promise;
|
|
4266
4266
|
} catch (error) {
|
|
4267
|
-
|
|
4267
|
+
logger18.error("Reconnection attempt failed", {
|
|
4268
4268
|
vendor: context.vendor,
|
|
4269
4269
|
attempt: nextAttempt,
|
|
4270
4270
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -4275,17 +4275,17 @@ function scheduleReconnection(context, logger19) {
|
|
|
4275
4275
|
}
|
|
4276
4276
|
|
|
4277
4277
|
// src/data/relational/connection/connection-cleanup.ts
|
|
4278
|
-
async function cleanupConnectionResources(vendor, client, clearConnection,
|
|
4278
|
+
async function cleanupConnectionResources(vendor, client, clearConnection, logger18) {
|
|
4279
4279
|
if (!client) {
|
|
4280
4280
|
return;
|
|
4281
4281
|
}
|
|
4282
|
-
|
|
4282
|
+
logger18.debug("Cleaning up cancelled connection", {
|
|
4283
4283
|
vendor
|
|
4284
4284
|
});
|
|
4285
4285
|
try {
|
|
4286
4286
|
await shutdownClient(vendor, client);
|
|
4287
4287
|
} catch (error) {
|
|
4288
|
-
|
|
4288
|
+
logger18.debug("Error during cancelled connection cleanup", {
|
|
4289
4289
|
vendor,
|
|
4290
4290
|
error: error instanceof Error ? error.message : String(error)
|
|
4291
4291
|
});
|
|
@@ -4293,10 +4293,10 @@ async function cleanupConnectionResources(vendor, client, clearConnection, logge
|
|
|
4293
4293
|
clearConnection();
|
|
4294
4294
|
}
|
|
4295
4295
|
}
|
|
4296
|
-
async function closeManagedConnection(runtime,
|
|
4296
|
+
async function closeManagedConnection(runtime, logger18) {
|
|
4297
4297
|
const client = runtime.getClient();
|
|
4298
4298
|
if (client) {
|
|
4299
|
-
|
|
4299
|
+
logger18.info("Closing database connection", {
|
|
4300
4300
|
vendor: runtime.vendor,
|
|
4301
4301
|
state: runtime.getState()
|
|
4302
4302
|
});
|
|
@@ -4304,12 +4304,12 @@ async function closeManagedConnection(runtime, logger19) {
|
|
|
4304
4304
|
await shutdownClient(runtime.vendor, client);
|
|
4305
4305
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4306
4306
|
runtime.emitDisconnected();
|
|
4307
|
-
|
|
4307
|
+
logger18.debug("Database connection closed successfully", {
|
|
4308
4308
|
vendor: runtime.vendor,
|
|
4309
4309
|
state: runtime.getState()
|
|
4310
4310
|
});
|
|
4311
4311
|
} catch (error) {
|
|
4312
|
-
|
|
4312
|
+
logger18.error("Error closing database connection", {
|
|
4313
4313
|
vendor: runtime.vendor,
|
|
4314
4314
|
error: error instanceof Error ? error.message : String(error),
|
|
4315
4315
|
state: runtime.getState()
|
|
@@ -4482,11 +4482,11 @@ async function initializeSQLiteConnection(connection) {
|
|
|
4482
4482
|
}
|
|
4483
4483
|
|
|
4484
4484
|
// src/data/relational/connection/connection-initialization.ts
|
|
4485
|
-
async function initializeManagedConnection(runtime,
|
|
4485
|
+
async function initializeManagedConnection(runtime, logger18) {
|
|
4486
4486
|
const startTime = Date.now();
|
|
4487
4487
|
const currentGeneration = runtime.getConnectionGeneration();
|
|
4488
4488
|
if (runtime.getState() === "connected" /* CONNECTED */ && runtime.getClient()) {
|
|
4489
|
-
|
|
4489
|
+
logger18.warn("Re-initializing an already connected manager; emitting disconnected before cleanup", {
|
|
4490
4490
|
vendor: runtime.vendor
|
|
4491
4491
|
});
|
|
4492
4492
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
@@ -4498,11 +4498,11 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4498
4498
|
runtime.setClient(null);
|
|
4499
4499
|
runtime.setDb(null);
|
|
4500
4500
|
},
|
|
4501
|
-
|
|
4501
|
+
logger18
|
|
4502
4502
|
);
|
|
4503
4503
|
}
|
|
4504
4504
|
runtime.setState("connecting" /* CONNECTING */);
|
|
4505
|
-
|
|
4505
|
+
logger18.info("Initializing database connection", {
|
|
4506
4506
|
vendor: runtime.vendor,
|
|
4507
4507
|
connectionType: typeof runtime.config.connection,
|
|
4508
4508
|
state: runtime.getState()
|
|
@@ -4512,7 +4512,7 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4512
4512
|
runtime.setClient(initialized.client);
|
|
4513
4513
|
runtime.setDb(initialized.db);
|
|
4514
4514
|
if (currentGeneration !== runtime.getConnectionGeneration()) {
|
|
4515
|
-
|
|
4515
|
+
logger18.debug("Connection cancelled during initialization", {
|
|
4516
4516
|
vendor: runtime.vendor,
|
|
4517
4517
|
currentGeneration,
|
|
4518
4518
|
newGeneration: runtime.getConnectionGeneration()
|
|
@@ -4524,18 +4524,18 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4524
4524
|
runtime.setClient(null);
|
|
4525
4525
|
runtime.setDb(null);
|
|
4526
4526
|
},
|
|
4527
|
-
|
|
4527
|
+
logger18
|
|
4528
4528
|
);
|
|
4529
4529
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4530
4530
|
throw new Error("Connection cancelled during initialization");
|
|
4531
4531
|
}
|
|
4532
|
-
|
|
4532
|
+
logger18.debug("Validating connection health", { vendor: runtime.vendor });
|
|
4533
4533
|
const healthy = await runtime.isHealthy();
|
|
4534
4534
|
if (!healthy) {
|
|
4535
4535
|
throw new Error(`Failed to establish healthy connection to ${runtime.vendor} database`);
|
|
4536
4536
|
}
|
|
4537
4537
|
if (currentGeneration !== runtime.getConnectionGeneration()) {
|
|
4538
|
-
|
|
4538
|
+
logger18.debug("Connection cancelled during health check", {
|
|
4539
4539
|
vendor: runtime.vendor,
|
|
4540
4540
|
currentGeneration,
|
|
4541
4541
|
newGeneration: runtime.getConnectionGeneration()
|
|
@@ -4547,7 +4547,7 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4547
4547
|
runtime.setClient(null);
|
|
4548
4548
|
runtime.setDb(null);
|
|
4549
4549
|
},
|
|
4550
|
-
|
|
4550
|
+
logger18
|
|
4551
4551
|
);
|
|
4552
4552
|
runtime.setState("disconnected" /* DISCONNECTED */);
|
|
4553
4553
|
throw new Error("Connection cancelled during health check");
|
|
@@ -4555,7 +4555,7 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4555
4555
|
runtime.setState("connected" /* CONNECTED */);
|
|
4556
4556
|
runtime.emitConnected();
|
|
4557
4557
|
runtime.resetReconnectionAttempts();
|
|
4558
|
-
|
|
4558
|
+
logger18.info("Database connection initialized successfully", {
|
|
4559
4559
|
vendor: runtime.vendor,
|
|
4560
4560
|
duration: Date.now() - startTime,
|
|
4561
4561
|
state: runtime.getState()
|
|
@@ -4576,7 +4576,7 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4576
4576
|
if (runtime.errorListenerCount() > 0) {
|
|
4577
4577
|
runtime.emitError(normalizedError);
|
|
4578
4578
|
}
|
|
4579
|
-
|
|
4579
|
+
logger18.error(errorMessage, {
|
|
4580
4580
|
vendor: runtime.vendor,
|
|
4581
4581
|
error: normalizedError.message,
|
|
4582
4582
|
duration: Date.now() - startTime,
|
|
@@ -4589,13 +4589,13 @@ async function initializeManagedConnection(runtime, logger19) {
|
|
|
4589
4589
|
runtime.setClient(null);
|
|
4590
4590
|
runtime.setDb(null);
|
|
4591
4591
|
},
|
|
4592
|
-
|
|
4592
|
+
logger18
|
|
4593
4593
|
);
|
|
4594
4594
|
if (runtime.getReconnectionConfig().enabled && currentGeneration === runtime.getConnectionGeneration()) {
|
|
4595
4595
|
runtime.scheduleReconnection();
|
|
4596
4596
|
}
|
|
4597
4597
|
} else {
|
|
4598
|
-
|
|
4598
|
+
logger18.debug("Connection initialization cancelled", {
|
|
4599
4599
|
vendor: runtime.vendor,
|
|
4600
4600
|
duration: Date.now() - startTime,
|
|
4601
4601
|
state: runtime.getState()
|
|
@@ -4613,17 +4613,17 @@ function isSqliteNonQueryError(error) {
|
|
|
4613
4613
|
const hasNonQueryMessage = error.message.includes("does not return data");
|
|
4614
4614
|
return isSqliteOrTypeError && hasNonQueryMessage;
|
|
4615
4615
|
}
|
|
4616
|
-
async function checkConnectionHealth(args,
|
|
4616
|
+
async function checkConnectionHealth(args, logger18) {
|
|
4617
4617
|
if (!args.db || !args.client) {
|
|
4618
|
-
|
|
4618
|
+
logger18.debug("Health check failed: connection not initialized", { vendor: args.vendor });
|
|
4619
4619
|
return false;
|
|
4620
4620
|
}
|
|
4621
4621
|
try {
|
|
4622
4622
|
await args.execute(drizzleOrm.sql`SELECT 1`);
|
|
4623
|
-
|
|
4623
|
+
logger18.debug("Health check passed", { vendor: args.vendor });
|
|
4624
4624
|
return true;
|
|
4625
4625
|
} catch (error) {
|
|
4626
|
-
|
|
4626
|
+
logger18.debug("Health check failed", {
|
|
4627
4627
|
vendor: args.vendor,
|
|
4628
4628
|
error: error instanceof Error ? error.message : String(error)
|
|
4629
4629
|
});
|
|
@@ -4666,8 +4666,8 @@ function getConnectionPoolMetrics(vendor, client) {
|
|
|
4666
4666
|
}
|
|
4667
4667
|
|
|
4668
4668
|
// src/data/relational/connection/query-execution.ts
|
|
4669
|
-
async function executeQuery(context, query,
|
|
4670
|
-
|
|
4669
|
+
async function executeQuery(context, query, logger18) {
|
|
4670
|
+
logger18.debug("Executing SQL query", {
|
|
4671
4671
|
vendor: context.vendor
|
|
4672
4672
|
});
|
|
4673
4673
|
if (context.vendor === "sqlite") {
|
|
@@ -5652,10 +5652,13 @@ async function executeBatchedTask(task, options = {}) {
|
|
|
5652
5652
|
failures
|
|
5653
5653
|
};
|
|
5654
5654
|
}
|
|
5655
|
-
var logger9 = core.createLogger("agentforge:tools:data:relational:stream");
|
|
5656
5655
|
var DEFAULT_CHUNK_SIZE = 100;
|
|
5657
|
-
var MAX_CHUNK_SIZE = 5e3;
|
|
5658
5656
|
var DEFAULT_SAMPLE_SIZE = 50;
|
|
5657
|
+
var MAX_CHUNK_SIZE = 5e3;
|
|
5658
|
+
var MAX_SAMPLE_SIZE = 5e3;
|
|
5659
|
+
var streamExecutorLogger = core.createLogger("agentforge:tools:data:relational:stream");
|
|
5660
|
+
|
|
5661
|
+
// src/data/relational/query/stream-executor-options.ts
|
|
5659
5662
|
function normalizeBoundedInt(value, fieldName, min, max, fallback) {
|
|
5660
5663
|
if (value === void 0) {
|
|
5661
5664
|
return fallback;
|
|
@@ -5674,14 +5677,17 @@ function normalizePositiveInt2(value, fieldName, fallback) {
|
|
|
5674
5677
|
}
|
|
5675
5678
|
return value;
|
|
5676
5679
|
}
|
|
5677
|
-
function
|
|
5678
|
-
|
|
5679
|
-
return result;
|
|
5680
|
-
}
|
|
5681
|
-
return result.rows ?? [];
|
|
5680
|
+
function resolveChunkSize(options) {
|
|
5681
|
+
return normalizeBoundedInt(options.chunkSize, "chunkSize", 1, MAX_CHUNK_SIZE, DEFAULT_CHUNK_SIZE);
|
|
5682
5682
|
}
|
|
5683
|
-
function
|
|
5684
|
-
return
|
|
5683
|
+
function resolveSampleSize(options) {
|
|
5684
|
+
return normalizeBoundedInt(
|
|
5685
|
+
options.sampleSize,
|
|
5686
|
+
"sampleSize",
|
|
5687
|
+
0,
|
|
5688
|
+
MAX_SAMPLE_SIZE,
|
|
5689
|
+
DEFAULT_SAMPLE_SIZE
|
|
5690
|
+
);
|
|
5685
5691
|
}
|
|
5686
5692
|
function resolveTotalRowsLimit(input, options) {
|
|
5687
5693
|
const inputLimit = normalizePositiveInt2(input.limit, "limit");
|
|
@@ -5694,8 +5700,21 @@ function resolveTotalRowsLimit(input, options) {
|
|
|
5694
5700
|
}
|
|
5695
5701
|
return Math.min(inputLimit, maxRows);
|
|
5696
5702
|
}
|
|
5703
|
+
|
|
5704
|
+
// src/data/relational/query/stream-executor-runtime.ts
|
|
5705
|
+
function extractRows(result) {
|
|
5706
|
+
if (Array.isArray(result)) {
|
|
5707
|
+
return result;
|
|
5708
|
+
}
|
|
5709
|
+
return result.rows ?? [];
|
|
5710
|
+
}
|
|
5711
|
+
function isCancelledError(error) {
|
|
5712
|
+
return error instanceof Error && error.message.includes("Stream cancelled by caller");
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
// src/data/relational/query/stream-executor-chunks.ts
|
|
5697
5716
|
async function* streamSelectChunks(executor, input, options = {}) {
|
|
5698
|
-
const chunkSize =
|
|
5717
|
+
const chunkSize = resolveChunkSize(options);
|
|
5699
5718
|
const baseOffset = input.offset ?? 0;
|
|
5700
5719
|
const totalRowsLimit = resolveTotalRowsLimit(input, options);
|
|
5701
5720
|
let processedRows = 0;
|
|
@@ -5738,16 +5757,12 @@ function createSelectReadableStream(executor, input, options = {}) {
|
|
|
5738
5757
|
highWaterMark: 1
|
|
5739
5758
|
});
|
|
5740
5759
|
}
|
|
5760
|
+
|
|
5761
|
+
// src/data/relational/query/stream-executor-execution.ts
|
|
5741
5762
|
async function executeStreamingSelect(executor, input, options = {}) {
|
|
5742
5763
|
const startTime = Date.now();
|
|
5743
5764
|
const collectedRows = [];
|
|
5744
|
-
const sampleSize =
|
|
5745
|
-
options.sampleSize,
|
|
5746
|
-
"sampleSize",
|
|
5747
|
-
0,
|
|
5748
|
-
5e3,
|
|
5749
|
-
DEFAULT_SAMPLE_SIZE
|
|
5750
|
-
);
|
|
5765
|
+
const sampleSize = resolveSampleSize(options);
|
|
5751
5766
|
let rowCount = 0;
|
|
5752
5767
|
let chunkCount = 0;
|
|
5753
5768
|
let cancelled = false;
|
|
@@ -5785,7 +5800,7 @@ async function executeStreamingSelect(executor, input, options = {}) {
|
|
|
5785
5800
|
const endHeapUsed = process.memoryUsage().heapUsed;
|
|
5786
5801
|
peakHeapUsed = Math.max(peakHeapUsed, endHeapUsed);
|
|
5787
5802
|
const executionTime = Date.now() - startTime;
|
|
5788
|
-
|
|
5803
|
+
streamExecutorLogger.debug("Streaming SELECT execution completed", {
|
|
5789
5804
|
table: input.table,
|
|
5790
5805
|
vendor: input.vendor,
|
|
5791
5806
|
chunkCount,
|
|
@@ -5808,11 +5823,16 @@ async function executeStreamingSelect(executor, input, options = {}) {
|
|
|
5808
5823
|
}
|
|
5809
5824
|
};
|
|
5810
5825
|
}
|
|
5826
|
+
|
|
5827
|
+
// src/data/relational/query/stream-executor-benchmark.ts
|
|
5811
5828
|
async function benchmarkStreamingSelectMemory(executor, input, options = {}) {
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5829
|
+
streamExecutorLogger.warn(
|
|
5830
|
+
"Running streaming benchmark will execute the SELECT query twice (regular + streaming).",
|
|
5831
|
+
{
|
|
5832
|
+
table: input.table,
|
|
5833
|
+
vendor: input.vendor
|
|
5834
|
+
}
|
|
5835
|
+
);
|
|
5816
5836
|
const nonStreamingStartHeapUsed = process.memoryUsage().heapUsed;
|
|
5817
5837
|
const nonStreamingStartTime = Date.now();
|
|
5818
5838
|
const nonStreamingResult = await executor.execute(buildSelectQuery(input));
|
|
@@ -5829,7 +5849,7 @@ async function benchmarkStreamingSelectMemory(executor, input, options = {}) {
|
|
|
5829
5849
|
0
|
|
5830
5850
|
);
|
|
5831
5851
|
const memorySavedPercent = nonStreamingPeakHeapUsed > 0 ? memorySavedBytes / nonStreamingPeakHeapUsed * 100 : 0;
|
|
5832
|
-
|
|
5852
|
+
streamExecutorLogger.debug("Streaming benchmark completed", {
|
|
5833
5853
|
table: input.table,
|
|
5834
5854
|
vendor: input.vendor,
|
|
5835
5855
|
nonStreamingRows: nonStreamingRows.length,
|
|
@@ -5901,7 +5921,7 @@ function withTransactionTimeout(operation, timeoutMs, onTimeout) {
|
|
|
5901
5921
|
}
|
|
5902
5922
|
|
|
5903
5923
|
// src/data/relational/query/transaction-managed.ts
|
|
5904
|
-
var
|
|
5924
|
+
var logger9 = core.createLogger("agentforge:tools:data:relational:transaction");
|
|
5905
5925
|
var SAVEPOINT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5906
5926
|
var ManagedTransaction = class {
|
|
5907
5927
|
id;
|
|
@@ -6009,7 +6029,7 @@ var ManagedTransaction = class {
|
|
|
6009
6029
|
await this.executeQuery(drizzleOrm.sql.raw("PRAGMA read_uncommitted = 1"));
|
|
6010
6030
|
this.shouldRestoreSqliteReadUncommitted = true;
|
|
6011
6031
|
} else {
|
|
6012
|
-
|
|
6032
|
+
logger9.debug("Ignoring SQLite isolation level override", {
|
|
6013
6033
|
transactionId: this.id,
|
|
6014
6034
|
isolationLevel: this.options.isolationLevel
|
|
6015
6035
|
});
|
|
@@ -6034,7 +6054,7 @@ var ManagedTransaction = class {
|
|
|
6034
6054
|
const targetValue = this.sqliteReadUncommittedOriginal ?? 0;
|
|
6035
6055
|
await this.executeQuery(drizzleOrm.sql.raw(`PRAGMA read_uncommitted = ${targetValue}`));
|
|
6036
6056
|
} catch (error) {
|
|
6037
|
-
|
|
6057
|
+
logger9.warn("Failed to restore SQLite read_uncommitted pragma", {
|
|
6038
6058
|
transactionId: this.id,
|
|
6039
6059
|
error: error instanceof Error ? error.message : String(error)
|
|
6040
6060
|
});
|
|
@@ -6060,14 +6080,14 @@ var ManagedTransaction = class {
|
|
|
6060
6080
|
};
|
|
6061
6081
|
|
|
6062
6082
|
// src/data/relational/query/transaction-runner.ts
|
|
6063
|
-
var
|
|
6083
|
+
var logger10 = core.createLogger("agentforge:tools:data:relational:transaction");
|
|
6064
6084
|
var transactionSequence = 0;
|
|
6065
6085
|
async function withTransaction(manager, operation, options) {
|
|
6066
6086
|
const startTime = Date.now();
|
|
6067
6087
|
const resolvedOptions = resolveTransactionOptions(options);
|
|
6068
6088
|
const transactionId = `tx-${++transactionSequence}`;
|
|
6069
6089
|
const vendor = manager.getVendor();
|
|
6070
|
-
|
|
6090
|
+
logger10.debug("Starting transaction", {
|
|
6071
6091
|
transactionId,
|
|
6072
6092
|
vendor,
|
|
6073
6093
|
...resolvedOptions.isolationLevel ? { isolationLevel: resolvedOptions.isolationLevel } : {},
|
|
@@ -6094,7 +6114,7 @@ async function withTransaction(manager, operation, options) {
|
|
|
6094
6114
|
if (transaction.isActive()) {
|
|
6095
6115
|
await transaction.commit();
|
|
6096
6116
|
}
|
|
6097
|
-
|
|
6117
|
+
logger10.debug("Transaction committed", {
|
|
6098
6118
|
transactionId,
|
|
6099
6119
|
vendor,
|
|
6100
6120
|
duration: Date.now() - startTime
|
|
@@ -6105,14 +6125,14 @@ async function withTransaction(manager, operation, options) {
|
|
|
6105
6125
|
try {
|
|
6106
6126
|
await transaction.rollback();
|
|
6107
6127
|
} catch (rollbackError) {
|
|
6108
|
-
|
|
6128
|
+
logger10.error("Transaction rollback failed", {
|
|
6109
6129
|
transactionId,
|
|
6110
6130
|
vendor,
|
|
6111
6131
|
error: rollbackError instanceof Error ? rollbackError.message : String(rollbackError)
|
|
6112
6132
|
});
|
|
6113
6133
|
}
|
|
6114
6134
|
}
|
|
6115
|
-
|
|
6135
|
+
logger10.error("Transaction failed", {
|
|
6116
6136
|
transactionId,
|
|
6117
6137
|
vendor,
|
|
6118
6138
|
duration: Date.now() - startTime,
|
|
@@ -6603,7 +6623,7 @@ async function inspectSQLite(runQueryRows) {
|
|
|
6603
6623
|
}
|
|
6604
6624
|
|
|
6605
6625
|
// src/data/relational/schema/schema-inspector.ts
|
|
6606
|
-
var
|
|
6626
|
+
var logger11 = core.createLogger("agentforge:tools:data:relational:schema-inspector");
|
|
6607
6627
|
var DEFAULT_CACHE_TTL_MS = 6e4;
|
|
6608
6628
|
var schemaCache = /* @__PURE__ */ new Map();
|
|
6609
6629
|
var SchemaInspector = class _SchemaInspector {
|
|
@@ -6631,7 +6651,7 @@ var SchemaInspector = class _SchemaInspector {
|
|
|
6631
6651
|
if (!bypassCache && this.cacheKey) {
|
|
6632
6652
|
const cached = schemaCache.get(this.cacheKey);
|
|
6633
6653
|
if (cached && cached.expiresAt > Date.now()) {
|
|
6634
|
-
|
|
6654
|
+
logger11.debug("Schema cache hit", { vendor: this.vendor });
|
|
6635
6655
|
return filterSchemaTables(cloneSchema(cached.schema), tableFilters);
|
|
6636
6656
|
}
|
|
6637
6657
|
}
|
|
@@ -6676,7 +6696,7 @@ var SchemaInspector = class _SchemaInspector {
|
|
|
6676
6696
|
return result.rows;
|
|
6677
6697
|
}
|
|
6678
6698
|
};
|
|
6679
|
-
var
|
|
6699
|
+
var logger12 = core.createLogger("agentforge:tools:data:relational:schema-validator");
|
|
6680
6700
|
function validateTableExists(schema, tableName) {
|
|
6681
6701
|
const errors = [];
|
|
6682
6702
|
if (!tableName || typeof tableName !== "string") {
|
|
@@ -6690,7 +6710,7 @@ function validateTableExists(schema, tableName) {
|
|
|
6690
6710
|
`Table "${tableName}" does not exist. Available tables: ${available || "(none)"}`
|
|
6691
6711
|
);
|
|
6692
6712
|
}
|
|
6693
|
-
|
|
6713
|
+
logger12.debug("Table existence validation", { tableName, valid: errors.length === 0 });
|
|
6694
6714
|
return { valid: errors.length === 0, errors };
|
|
6695
6715
|
}
|
|
6696
6716
|
function validateColumnsExist(schema, tableName, columnNames) {
|
|
@@ -6713,7 +6733,7 @@ function validateColumnsExist(schema, tableName, columnNames) {
|
|
|
6713
6733
|
);
|
|
6714
6734
|
}
|
|
6715
6735
|
}
|
|
6716
|
-
|
|
6736
|
+
logger12.debug("Column existence validation", {
|
|
6717
6737
|
tableName,
|
|
6718
6738
|
columnCount: columnNames.length,
|
|
6719
6739
|
valid: errors.length === 0
|
|
@@ -6749,7 +6769,7 @@ function validateColumnTypes(schema, tableName, expectedTypes) {
|
|
|
6749
6769
|
);
|
|
6750
6770
|
}
|
|
6751
6771
|
}
|
|
6752
|
-
|
|
6772
|
+
logger12.debug("Column type validation", {
|
|
6753
6773
|
tableName,
|
|
6754
6774
|
typeChecks: Object.keys(expectedTypes).length,
|
|
6755
6775
|
valid: errors.length === 0
|
|
@@ -6769,7 +6789,7 @@ function findTable(schema, tableName) {
|
|
|
6769
6789
|
function formatTableName(table) {
|
|
6770
6790
|
return table.schema ? `${table.schema}.${table.name}` : table.name;
|
|
6771
6791
|
}
|
|
6772
|
-
var
|
|
6792
|
+
var logger13 = core.createLogger("agentforge:tools:data:relational:type-mapper");
|
|
6773
6793
|
var POSTGRES_TYPE_MAP = {
|
|
6774
6794
|
// Numeric
|
|
6775
6795
|
smallint: "number",
|
|
@@ -6935,7 +6955,7 @@ function mapColumnType(vendor, dbType, nullable = false) {
|
|
|
6935
6955
|
const result = { tsType, nullable, dbType };
|
|
6936
6956
|
if (tsType === "unknown" && normalised !== "json" && normalised !== "jsonb") {
|
|
6937
6957
|
result.notes = `No explicit mapping for "${dbType}"; defaulting to unknown`;
|
|
6938
|
-
|
|
6958
|
+
logger13.debug("Unmapped database type", { vendor, dbType, normalised });
|
|
6939
6959
|
}
|
|
6940
6960
|
if ((normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql")) {
|
|
6941
6961
|
result.notes = "Mapped to string to avoid JavaScript number precision loss for 64-bit integers";
|
|
@@ -6950,7 +6970,7 @@ function mapSchemaTypes(vendor, columns) {
|
|
|
6950
6970
|
}
|
|
6951
6971
|
result.get(col.table).set(col.name, mapColumnType(vendor, col.type, col.nullable));
|
|
6952
6972
|
}
|
|
6953
|
-
|
|
6973
|
+
logger13.debug("Schema type mapping complete", {
|
|
6954
6974
|
vendor,
|
|
6955
6975
|
tables: result.size,
|
|
6956
6976
|
columns: columns.length
|
|
@@ -6967,7 +6987,7 @@ function normaliseDbType(raw) {
|
|
|
6967
6987
|
type = type.replace(/\s+unsigned$/, "");
|
|
6968
6988
|
return type.trim();
|
|
6969
6989
|
}
|
|
6970
|
-
var
|
|
6990
|
+
var logger14 = core.createLogger("agentforge:tools:data:relational:schema-diff");
|
|
6971
6991
|
function diffSchemas(before, after) {
|
|
6972
6992
|
const tableDiffs = [];
|
|
6973
6993
|
let columnsAdded = 0;
|
|
@@ -7007,7 +7027,7 @@ function diffSchemas(before, after) {
|
|
|
7007
7027
|
const tablesRemoved = tableDiffs.filter((d) => d.type === "removed").length;
|
|
7008
7028
|
const tablesChanged = tableDiffs.filter((d) => d.type === "changed").length;
|
|
7009
7029
|
const identical = tableDiffs.length === 0;
|
|
7010
|
-
|
|
7030
|
+
logger14.debug("Schema diff computed", {
|
|
7011
7031
|
identical,
|
|
7012
7032
|
tablesAdded,
|
|
7013
7033
|
tablesRemoved,
|
|
@@ -7051,7 +7071,7 @@ function importSchemaFromJson(json) {
|
|
|
7051
7071
|
throw new Error(`Invalid schema JSON: table "${table.name}" missing "primaryKey" array`);
|
|
7052
7072
|
}
|
|
7053
7073
|
}
|
|
7054
|
-
|
|
7074
|
+
logger14.debug("Schema imported from JSON", {
|
|
7055
7075
|
vendor: obj.vendor,
|
|
7056
7076
|
tableCount: obj.tables.length
|
|
7057
7077
|
});
|
|
@@ -7348,7 +7368,7 @@ function isSafeValidationError(error) {
|
|
|
7348
7368
|
}
|
|
7349
7369
|
|
|
7350
7370
|
// src/data/relational/tools/relational-select/executor.ts
|
|
7351
|
-
var
|
|
7371
|
+
var logger15 = core.createLogger("agentforge:tools:data:relational:select");
|
|
7352
7372
|
function toSelectQueryInput(input) {
|
|
7353
7373
|
return {
|
|
7354
7374
|
table: input.table,
|
|
@@ -7362,7 +7382,7 @@ function toSelectQueryInput(input) {
|
|
|
7362
7382
|
}
|
|
7363
7383
|
async function executeSelect(manager, input, context) {
|
|
7364
7384
|
const startTime = Date.now();
|
|
7365
|
-
|
|
7385
|
+
logger15.debug("Building SELECT query", {
|
|
7366
7386
|
vendor: input.vendor,
|
|
7367
7387
|
table: input.table,
|
|
7368
7388
|
hasWhere: !!input.where,
|
|
@@ -7380,7 +7400,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7380
7400
|
};
|
|
7381
7401
|
const streamInput = toSelectQueryInput(input);
|
|
7382
7402
|
if (input.streaming.benchmark) {
|
|
7383
|
-
|
|
7403
|
+
logger15.warn("Streaming benchmark enabled; SELECT will execute up to three times (result + benchmark regular + benchmark streaming).", {
|
|
7384
7404
|
vendor: input.vendor,
|
|
7385
7405
|
table: input.table,
|
|
7386
7406
|
chunkSize: streamOptions.chunkSize ?? DEFAULT_CHUNK_SIZE,
|
|
@@ -7391,7 +7411,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7391
7411
|
const streamResult = await executeStreamingSelect(executor, streamInput, streamOptions);
|
|
7392
7412
|
const benchmark = input.streaming.benchmark ? await benchmarkStreamingSelectMemory(executor, streamInput, streamOptions) : void 0;
|
|
7393
7413
|
const executionTime2 = Date.now() - startTime;
|
|
7394
|
-
|
|
7414
|
+
logger15.debug("Streaming SELECT query executed successfully", {
|
|
7395
7415
|
vendor: input.vendor,
|
|
7396
7416
|
table: input.table,
|
|
7397
7417
|
rowCount: streamResult.rowCount,
|
|
@@ -7420,7 +7440,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7420
7440
|
const executionTime = Date.now() - startTime;
|
|
7421
7441
|
const rows = Array.isArray(result) ? result : result.rows || [];
|
|
7422
7442
|
const rowCount = rows.length;
|
|
7423
|
-
|
|
7443
|
+
logger15.debug("SELECT query executed successfully", {
|
|
7424
7444
|
vendor: input.vendor,
|
|
7425
7445
|
table: input.table,
|
|
7426
7446
|
rowCount,
|
|
@@ -7433,7 +7453,7 @@ async function executeSelect(manager, input, context) {
|
|
|
7433
7453
|
};
|
|
7434
7454
|
} catch (error) {
|
|
7435
7455
|
const executionTime = Date.now() - startTime;
|
|
7436
|
-
|
|
7456
|
+
logger15.error("SELECT query execution failed", {
|
|
7437
7457
|
vendor: input.vendor,
|
|
7438
7458
|
table: input.table,
|
|
7439
7459
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -9003,7 +9023,7 @@ function isSafeGetSchemaValidationError(error) {
|
|
|
9003
9023
|
}
|
|
9004
9024
|
|
|
9005
9025
|
// src/data/relational/tools/relational-get-schema.ts
|
|
9006
|
-
var
|
|
9026
|
+
var logger16 = core.createLogger("agentforge:tools:data:relational:get-schema");
|
|
9007
9027
|
function buildSchemaCacheKey(vendor, connectionString, database) {
|
|
9008
9028
|
const databaseScope = database ?? "default";
|
|
9009
9029
|
const connectionHash = crypto.createHash("sha256").update(connectionString).digest("hex");
|
|
@@ -9075,7 +9095,7 @@ var relationalGetSchema = core.toolBuilder().name("relational-get-schema").displ
|
|
|
9075
9095
|
summary
|
|
9076
9096
|
};
|
|
9077
9097
|
} catch (error) {
|
|
9078
|
-
|
|
9098
|
+
logger16.error("Schema introspection failed", {
|
|
9079
9099
|
vendor: input.vendor,
|
|
9080
9100
|
hasTablesFilter: Array.isArray(input.tables),
|
|
9081
9101
|
tablesFilterCount: input.tables?.length ?? 0,
|
|
@@ -10241,7 +10261,7 @@ var AskHumanInputSchema = zod.z.object({
|
|
|
10241
10261
|
suggestions: zod.z.array(zod.z.string()).optional().describe("Suggested responses for the human")
|
|
10242
10262
|
});
|
|
10243
10263
|
var logLevel3 = process.env.LOG_LEVEL?.toLowerCase() || core.LogLevel.INFO;
|
|
10244
|
-
var
|
|
10264
|
+
var logger17 = core.createLogger("agentforge:tools:agent:ask-human", { level: logLevel3 });
|
|
10245
10265
|
function isRecord2(value) {
|
|
10246
10266
|
return typeof value === "object" && value !== null;
|
|
10247
10267
|
}
|
|
@@ -10306,7 +10326,7 @@ function createAskHumanTool() {
|
|
|
10306
10326
|
suggestions: validatedInput.suggestions,
|
|
10307
10327
|
status: "pending"
|
|
10308
10328
|
};
|
|
10309
|
-
|
|
10329
|
+
logger17.debug("About to call interrupt()", {
|
|
10310
10330
|
humanRequest: {
|
|
10311
10331
|
id: humanRequest.id,
|
|
10312
10332
|
question: humanRequest.question,
|
|
@@ -10322,13 +10342,13 @@ function createAskHumanTool() {
|
|
|
10322
10342
|
let response;
|
|
10323
10343
|
try {
|
|
10324
10344
|
response = interrupt(humanRequest);
|
|
10325
|
-
|
|
10345
|
+
logger17.debug("interrupt() returned successfully", {
|
|
10326
10346
|
responseType: typeof response,
|
|
10327
10347
|
hasResponse: response != null,
|
|
10328
10348
|
...typeof response === "string" ? { responseLength: response.length } : {}
|
|
10329
10349
|
});
|
|
10330
10350
|
} catch (error) {
|
|
10331
|
-
|
|
10351
|
+
logger17.debug("interrupt() threw error (expected for GraphInterrupt)", {
|
|
10332
10352
|
...error && typeof error === "object" && "constructor" in error ? { errorType: error.constructor?.name } : {},
|
|
10333
10353
|
error: error instanceof Error ? error.message : String(error)
|
|
10334
10354
|
});
|