pybao-cli 1.3.80 → 1.3.81
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/REPL-N4B3JZBZ.js +42 -0
- package/dist/{acp-ZGZTJXRX.js → acp-4HKKXFYQ.js} +29 -27
- package/dist/{acp-ZGZTJXRX.js.map → acp-4HKKXFYQ.js.map} +1 -1
- package/dist/{agentsValidate-UU3CTQQG.js → agentsValidate-Y7ESIGWC.js} +7 -7
- package/dist/{ask-ZY5BJZSV.js → ask-BFLAH7SK.js} +25 -25
- package/dist/{autoUpdater-QKSPMROL.js → autoUpdater-ZP62GDO2.js} +3 -3
- package/dist/{chunk-OW2MWOEW.js → chunk-26R2U6DS.js} +209 -19
- package/dist/chunk-26R2U6DS.js.map +7 -0
- package/dist/{chunk-K5SSMVKH.js → chunk-2BT4P5FY.js} +2 -2
- package/dist/{chunk-RVWBNMCL.js → chunk-2JAKX7IR.js} +3 -3
- package/dist/{llm-RHWOZZGJ.js → chunk-2RR4H3L6.js} +28 -55
- package/dist/chunk-2RR4H3L6.js.map +7 -0
- package/dist/{chunk-GBVT3BHF.js → chunk-4YJ6DHQK.js} +37 -38
- package/dist/{chunk-42XRBA3T.js → chunk-5RVP5P5Y.js} +2 -2
- package/dist/{chunk-IROS56AN.js → chunk-5YU3ZWG6.js} +4 -4
- package/dist/{chunk-FF4MK6K3.js → chunk-65MNQP3U.js} +3 -3
- package/dist/{chunk-ISZYPQJ4.js → chunk-72RJTELO.js} +1 -1
- package/dist/{chunk-AAIDMQFM.js → chunk-AED6OYMI.js} +3 -3
- package/dist/{chunk-C6KEBADH.js → chunk-BAGUGUP3.js} +2 -2
- package/dist/{chunk-C64GQQIX.js → chunk-BXF5H7EN.js} +1 -1
- package/dist/{chunk-XRUOSW3Q.js → chunk-D364WNKJ.js} +12 -6
- package/dist/chunk-D364WNKJ.js.map +7 -0
- package/dist/{chunk-SRWXBDPV.js → chunk-IV73XFVG.js} +3 -3
- package/dist/{chunk-ROSGQFTS.js → chunk-JEHHIOUO.js} +1 -1
- package/dist/{chunk-Z6FKI2XB.js → chunk-KZGNQII5.js} +4 -4
- package/dist/{chunk-IQIZZT3A.js → chunk-LLNNHSE3.js} +1 -1
- package/dist/{chunk-J6LHG4P2.js → chunk-LVTQN4RG.js} +1 -1
- package/dist/{chunk-A5OH2UIT.js → chunk-MTSI5244.js} +2 -2
- package/dist/{chunk-SCFTG75V.js → chunk-P2VXE3TJ.js} +3 -3
- package/dist/{chunk-TWXMVB4T.js → chunk-PYRG5FKD.js} +1 -1
- package/dist/{chunk-6FIBU73C.js → chunk-Q653YYZS.js} +1 -1
- package/dist/{chunk-JY2ZIUT6.js → chunk-R56S2D3A.js} +5 -3
- package/dist/{chunk-JY2ZIUT6.js.map → chunk-R56S2D3A.js.map} +2 -2
- package/dist/{chunk-LPRHLVIT.js → chunk-RPQ3FFN6.js} +3 -3
- package/dist/{chunk-TP3G2PLU.js → chunk-TE7EYQKI.js} +2 -2
- package/dist/{chunk-4NCEUAAH.js → chunk-TMIQYE2C.js} +3 -3
- package/dist/{chunk-6Y7R2HQJ.js → chunk-UGJJDTVJ.js} +1 -1
- package/dist/{chunk-SH2UZRTG.js → chunk-UUGAVZ5R.js} +2 -2
- package/dist/{chunk-N5WZ6CIB.js → chunk-VQYBUOUL.js} +1 -1
- package/dist/{cli-HYV3MO3Z.js → cli-KITOXFPL.js} +80 -79
- package/dist/{cli-HYV3MO3Z.js.map → cli-KITOXFPL.js.map} +1 -1
- package/dist/commands-GPZL7LEO.js +46 -0
- package/dist/{config-NHL3XV6A.js → config-EVFJADC4.js} +4 -4
- package/dist/{context-KCM2CKCI.js → context-DZU6TVXM.js} +5 -5
- package/dist/{customCommands-H4OTDEES.js → customCommands-3ZEKZS64.js} +4 -4
- package/dist/{env-45HRLZXA.js → env-KJ3YKVKD.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/llm-LVHJBUBU.js +80 -0
- package/dist/{llmLazy-C4WAHBE6.js → llmLazy-E37BRRJL.js} +1 -1
- package/dist/{loader-ECT2XQ5R.js → loader-CJQYGIOX.js} +4 -4
- package/dist/{lspAnchor-IEMAQJKB.js → lspAnchor-VYW6TBK6.js} +4 -4
- package/dist/{manager-QVC7V5FF.js → manager-2E6RCOPM.js} +4 -4
- package/dist/{mcp-HCRADJBF.js → mcp-32PUNKEE.js} +7 -7
- package/dist/{mentionProcessor-6QPEGYTQ.js → mentionProcessor-YQUVBGUO.js} +5 -5
- package/dist/{messages-E6SPHRIN.js → messages-S6XJLYHT.js} +1 -1
- package/dist/{model-SMB3E5LC.js → model-KERYS7VW.js} +5 -5
- package/dist/{openai-FMO244D7.js → openai-LIOQRL5O.js} +5 -5
- package/dist/{outputStyles-YB2ODUS7.js → outputStyles-M7AT5V2E.js} +4 -4
- package/dist/{pluginRuntime-7IMWBORD.js → pluginRuntime-RPOZH24G.js} +6 -6
- package/dist/{pluginValidation-QVVBJD66.js → pluginValidation-3PNCKYDB.js} +6 -6
- package/dist/prompts-HL3TSDJY.js +48 -0
- package/dist/{pybAgentSessionLoad-3S6RFTJU.js → pybAgentSessionLoad-U343Y3XU.js} +4 -4
- package/dist/{pybAgentSessionResume-EUKW3FMB.js → pybAgentSessionResume-747QQNMS.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-RTPFM6OV.js → pybAgentStreamJsonSession-B25HH4BN.js} +1 -1
- package/dist/{pybHooks-3IQJYVB4.js → pybHooks-7EEKA766.js} +4 -4
- package/dist/query-LXPSR7ZB.js +50 -0
- package/dist/{ripgrep-I7SPG656.js → ripgrep-US75RUV3.js} +3 -3
- package/dist/{skillMarketplace-Y46OXJ6X.js → skillMarketplace-P4P7ZUPT.js} +3 -3
- package/dist/{state-IWD2KGEM.js → state-36K5VF3G.js} +2 -2
- package/dist/{theme-RFDPFU5Y.js → theme-7R3CIM3B.js} +5 -5
- package/dist/{toolPermissionSettings-J7PFZFUY.js → toolPermissionSettings-4YLPKZWJ.js} +6 -6
- package/dist/tools-3JTWQRFN.js +51 -0
- package/dist/tools-3JTWQRFN.js.map +7 -0
- package/dist/{userInput-ADSR2X52.js → userInput-TBU35CMG.js} +27 -27
- package/package.json +5 -3
- package/dist/REPL-FCFUNTRV.js +0 -42
- package/dist/chunk-OW2MWOEW.js.map +0 -7
- package/dist/chunk-XI4LTVYT.js +0 -17
- package/dist/chunk-XI4LTVYT.js.map +0 -7
- package/dist/chunk-XRUOSW3Q.js.map +0 -7
- package/dist/commands-UF72PYOD.js +0 -46
- package/dist/llm-RHWOZZGJ.js.map +0 -7
- package/dist/prompts-4MPNSSTI.js +0 -48
- package/dist/query-QZ2RBRLD.js +0 -50
- package/dist/tools-V6LVGZ4F.js +0 -49
- /package/dist/{REPL-FCFUNTRV.js.map → REPL-N4B3JZBZ.js.map} +0 -0
- /package/dist/{agentsValidate-UU3CTQQG.js.map → agentsValidate-Y7ESIGWC.js.map} +0 -0
- /package/dist/{ask-ZY5BJZSV.js.map → ask-BFLAH7SK.js.map} +0 -0
- /package/dist/{autoUpdater-QKSPMROL.js.map → autoUpdater-ZP62GDO2.js.map} +0 -0
- /package/dist/{chunk-K5SSMVKH.js.map → chunk-2BT4P5FY.js.map} +0 -0
- /package/dist/{chunk-RVWBNMCL.js.map → chunk-2JAKX7IR.js.map} +0 -0
- /package/dist/{chunk-GBVT3BHF.js.map → chunk-4YJ6DHQK.js.map} +0 -0
- /package/dist/{chunk-42XRBA3T.js.map → chunk-5RVP5P5Y.js.map} +0 -0
- /package/dist/{chunk-IROS56AN.js.map → chunk-5YU3ZWG6.js.map} +0 -0
- /package/dist/{chunk-FF4MK6K3.js.map → chunk-65MNQP3U.js.map} +0 -0
- /package/dist/{chunk-ISZYPQJ4.js.map → chunk-72RJTELO.js.map} +0 -0
- /package/dist/{chunk-AAIDMQFM.js.map → chunk-AED6OYMI.js.map} +0 -0
- /package/dist/{chunk-C6KEBADH.js.map → chunk-BAGUGUP3.js.map} +0 -0
- /package/dist/{chunk-C64GQQIX.js.map → chunk-BXF5H7EN.js.map} +0 -0
- /package/dist/{chunk-SRWXBDPV.js.map → chunk-IV73XFVG.js.map} +0 -0
- /package/dist/{chunk-ROSGQFTS.js.map → chunk-JEHHIOUO.js.map} +0 -0
- /package/dist/{chunk-Z6FKI2XB.js.map → chunk-KZGNQII5.js.map} +0 -0
- /package/dist/{chunk-IQIZZT3A.js.map → chunk-LLNNHSE3.js.map} +0 -0
- /package/dist/{chunk-J6LHG4P2.js.map → chunk-LVTQN4RG.js.map} +0 -0
- /package/dist/{chunk-A5OH2UIT.js.map → chunk-MTSI5244.js.map} +0 -0
- /package/dist/{chunk-SCFTG75V.js.map → chunk-P2VXE3TJ.js.map} +0 -0
- /package/dist/{chunk-TWXMVB4T.js.map → chunk-PYRG5FKD.js.map} +0 -0
- /package/dist/{chunk-6FIBU73C.js.map → chunk-Q653YYZS.js.map} +0 -0
- /package/dist/{chunk-LPRHLVIT.js.map → chunk-RPQ3FFN6.js.map} +0 -0
- /package/dist/{chunk-TP3G2PLU.js.map → chunk-TE7EYQKI.js.map} +0 -0
- /package/dist/{chunk-4NCEUAAH.js.map → chunk-TMIQYE2C.js.map} +0 -0
- /package/dist/{chunk-6Y7R2HQJ.js.map → chunk-UGJJDTVJ.js.map} +0 -0
- /package/dist/{chunk-SH2UZRTG.js.map → chunk-UUGAVZ5R.js.map} +0 -0
- /package/dist/{chunk-N5WZ6CIB.js.map → chunk-VQYBUOUL.js.map} +0 -0
- /package/dist/{commands-UF72PYOD.js.map → commands-GPZL7LEO.js.map} +0 -0
- /package/dist/{config-NHL3XV6A.js.map → config-EVFJADC4.js.map} +0 -0
- /package/dist/{context-KCM2CKCI.js.map → context-DZU6TVXM.js.map} +0 -0
- /package/dist/{customCommands-H4OTDEES.js.map → customCommands-3ZEKZS64.js.map} +0 -0
- /package/dist/{env-45HRLZXA.js.map → env-KJ3YKVKD.js.map} +0 -0
- /package/dist/{llmLazy-C4WAHBE6.js.map → llm-LVHJBUBU.js.map} +0 -0
- /package/dist/{loader-ECT2XQ5R.js.map → llmLazy-E37BRRJL.js.map} +0 -0
- /package/dist/{manager-QVC7V5FF.js.map → loader-CJQYGIOX.js.map} +0 -0
- /package/dist/{lspAnchor-IEMAQJKB.js.map → lspAnchor-VYW6TBK6.js.map} +0 -0
- /package/dist/{mcp-HCRADJBF.js.map → manager-2E6RCOPM.js.map} +0 -0
- /package/dist/{messages-E6SPHRIN.js.map → mcp-32PUNKEE.js.map} +0 -0
- /package/dist/{mentionProcessor-6QPEGYTQ.js.map → mentionProcessor-YQUVBGUO.js.map} +0 -0
- /package/dist/{model-SMB3E5LC.js.map → messages-S6XJLYHT.js.map} +0 -0
- /package/dist/{openai-FMO244D7.js.map → model-KERYS7VW.js.map} +0 -0
- /package/dist/{outputStyles-YB2ODUS7.js.map → openai-LIOQRL5O.js.map} +0 -0
- /package/dist/{pluginValidation-QVVBJD66.js.map → outputStyles-M7AT5V2E.js.map} +0 -0
- /package/dist/{pluginRuntime-7IMWBORD.js.map → pluginRuntime-RPOZH24G.js.map} +0 -0
- /package/dist/{prompts-4MPNSSTI.js.map → pluginValidation-3PNCKYDB.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-3S6RFTJU.js.map → prompts-HL3TSDJY.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-EUKW3FMB.js.map → pybAgentSessionLoad-U343Y3XU.js.map} +0 -0
- /package/dist/{pybHooks-3IQJYVB4.js.map → pybAgentSessionResume-747QQNMS.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-RTPFM6OV.js.map → pybAgentStreamJsonSession-B25HH4BN.js.map} +0 -0
- /package/dist/{query-QZ2RBRLD.js.map → pybHooks-7EEKA766.js.map} +0 -0
- /package/dist/{ripgrep-I7SPG656.js.map → query-LXPSR7ZB.js.map} +0 -0
- /package/dist/{skillMarketplace-Y46OXJ6X.js.map → ripgrep-US75RUV3.js.map} +0 -0
- /package/dist/{state-IWD2KGEM.js.map → skillMarketplace-P4P7ZUPT.js.map} +0 -0
- /package/dist/{theme-RFDPFU5Y.js.map → state-36K5VF3G.js.map} +0 -0
- /package/dist/{toolPermissionSettings-J7PFZFUY.js.map → theme-7R3CIM3B.js.map} +0 -0
- /package/dist/{tools-V6LVGZ4F.js.map → toolPermissionSettings-4YLPKZWJ.js.map} +0 -0
- /package/dist/{userInput-ADSR2X52.js.map → userInput-TBU35CMG.js.map} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createRequire as __pybCreateRequire } from "node:module";
|
|
2
2
|
const require = __pybCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
queryQuick
|
|
5
|
+
} from "./chunk-2RR4H3L6.js";
|
|
3
6
|
import {
|
|
4
7
|
AskUserQuestionTool,
|
|
5
8
|
BashTool,
|
|
@@ -17,7 +20,6 @@ import {
|
|
|
17
20
|
SkillTool,
|
|
18
21
|
SlashCommandTool,
|
|
19
22
|
TodoWriteTool,
|
|
20
|
-
WebFetchTool,
|
|
21
23
|
applyMarkdown,
|
|
22
24
|
countTokens,
|
|
23
25
|
getAbsolutePath,
|
|
@@ -28,49 +30,49 @@ import {
|
|
|
28
30
|
hasWritePermission,
|
|
29
31
|
loadLanguage,
|
|
30
32
|
query
|
|
31
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-4YJ6DHQK.js";
|
|
32
34
|
import {
|
|
33
35
|
queryLLM
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-5YU3ZWG6.js";
|
|
35
37
|
import {
|
|
36
38
|
FallbackToolUseRejectedMessage,
|
|
37
39
|
MCPTool,
|
|
38
40
|
getClients,
|
|
39
41
|
getMCPTools
|
|
40
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-KZGNQII5.js";
|
|
41
43
|
import {
|
|
42
44
|
generateAgentId
|
|
43
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-TE7EYQKI.js";
|
|
44
46
|
import {
|
|
45
47
|
getActiveAgents,
|
|
46
48
|
getAgentByType,
|
|
47
49
|
getAvailableAgentTypes
|
|
48
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-UUGAVZ5R.js";
|
|
49
51
|
import {
|
|
50
52
|
INTERRUPT_MESSAGE,
|
|
51
53
|
createAssistantMessage,
|
|
52
54
|
createUserMessage,
|
|
53
55
|
getLastAssistantMessageId
|
|
54
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-JEHHIOUO.js";
|
|
55
57
|
import {
|
|
56
58
|
filesToTree,
|
|
57
59
|
ripGrep
|
|
58
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-VQYBUOUL.js";
|
|
59
61
|
import {
|
|
60
62
|
LspClientManager
|
|
61
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-D364WNKJ.js";
|
|
62
64
|
import {
|
|
63
65
|
getModelManager
|
|
64
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-RPQ3FFN6.js";
|
|
65
67
|
import {
|
|
66
68
|
getContext
|
|
67
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-2JAKX7IR.js";
|
|
68
70
|
import {
|
|
69
71
|
getTheme
|
|
70
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-LLNNHSE3.js";
|
|
71
73
|
import {
|
|
72
74
|
debug
|
|
73
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-PYRG5FKD.js";
|
|
74
76
|
import {
|
|
75
77
|
BunShell,
|
|
76
78
|
getCwd,
|
|
@@ -79,7 +81,7 @@ import {
|
|
|
79
81
|
logError,
|
|
80
82
|
overwriteLog,
|
|
81
83
|
readTaskOutput
|
|
82
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-Q653YYZS.js";
|
|
83
85
|
import {
|
|
84
86
|
formatDuration,
|
|
85
87
|
formatNumber
|
|
@@ -745,9 +747,9 @@ async function analyzeOutputWithLsp(output, exitCode) {
|
|
|
745
747
|
if (warningCount > 0) parts.push(`${warningCount} Warning${warningCount === 1 ? "" : "s"}`);
|
|
746
748
|
if (exitCode !== 0) {
|
|
747
749
|
try {
|
|
748
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
750
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
749
751
|
const { isAbsolute: isAbsolute3, resolve: resolve3 } = await import("path");
|
|
750
|
-
const { getCwd: getCwd2 } = await import("./state-
|
|
752
|
+
const { getCwd: getCwd2 } = await import("./state-36K5VF3G.js");
|
|
751
753
|
const lines = output.split("\n");
|
|
752
754
|
const uniqueFiles = /* @__PURE__ */ new Set();
|
|
753
755
|
const lspSuggestions = [];
|
|
@@ -1107,7 +1109,7 @@ var DeleteTool = {
|
|
|
1107
1109
|
}
|
|
1108
1110
|
if (!force) {
|
|
1109
1111
|
try {
|
|
1110
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
1112
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
1111
1113
|
const manager = LspClientManager2.getInstance();
|
|
1112
1114
|
const client = await manager.getClientForFile(fullPath);
|
|
1113
1115
|
if (!client) {
|
|
@@ -1391,7 +1393,7 @@ var LSTool = {
|
|
|
1391
1393
|
const stats = {};
|
|
1392
1394
|
if (semantic) {
|
|
1393
1395
|
try {
|
|
1394
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
1396
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
1395
1397
|
const BATCH_SIZE = 10;
|
|
1396
1398
|
const processedFilesList = [];
|
|
1397
1399
|
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
@@ -3546,6 +3548,194 @@ var TaskTool = {
|
|
|
3546
3548
|
}
|
|
3547
3549
|
};
|
|
3548
3550
|
|
|
3551
|
+
// src/tools/WebFetcher/WebFetcherTool.tsx
|
|
3552
|
+
import { z as z9 } from "zod";
|
|
3553
|
+
|
|
3554
|
+
// src/tools/WebFetcher/WebFetcher.ts
|
|
3555
|
+
import fetch from "node-fetch";
|
|
3556
|
+
import { AbortController as AbortController2 } from "abort-controller";
|
|
3557
|
+
import { parse } from "node-html-parser";
|
|
3558
|
+
import TurndownService from "turndown";
|
|
3559
|
+
import { gfm } from "turndown-plugin-gfm";
|
|
3560
|
+
var WebFetcher = class {
|
|
3561
|
+
DEFAULT_TIMEOUT = 30;
|
|
3562
|
+
// seconds
|
|
3563
|
+
MAX_RESPONSE_SIZE = 5 * 1024 * 1024;
|
|
3564
|
+
// 5MB
|
|
3565
|
+
CACHE_TTL = 15 * 60 * 1e3;
|
|
3566
|
+
// 15 minutes
|
|
3567
|
+
MAX_ANALYSIS_CONTENT_LENGTH = 5e4;
|
|
3568
|
+
// ~15k tokens
|
|
3569
|
+
turndownService;
|
|
3570
|
+
cache = /* @__PURE__ */ new Map();
|
|
3571
|
+
constructor() {
|
|
3572
|
+
this.turndownService = new TurndownService({
|
|
3573
|
+
headingStyle: "atx",
|
|
3574
|
+
codeBlockStyle: "fenced",
|
|
3575
|
+
bulletListMarker: "-",
|
|
3576
|
+
// Explicitly set bullet marker
|
|
3577
|
+
emDelimiter: "*"
|
|
3578
|
+
});
|
|
3579
|
+
this.turndownService.use(gfm);
|
|
3580
|
+
}
|
|
3581
|
+
async execute(input) {
|
|
3582
|
+
let content;
|
|
3583
|
+
let isCached = false;
|
|
3584
|
+
const format = input.format || "markdown";
|
|
3585
|
+
const cached = this.cache.get(input.url);
|
|
3586
|
+
if (cached) {
|
|
3587
|
+
if (Date.now() - cached.timestamp < this.CACHE_TTL) {
|
|
3588
|
+
content = cached.content;
|
|
3589
|
+
isCached = true;
|
|
3590
|
+
} else {
|
|
3591
|
+
this.cache.delete(input.url);
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
if (!isCached) {
|
|
3595
|
+
const timeout = (input.timeout || this.DEFAULT_TIMEOUT) * 1e3;
|
|
3596
|
+
const controller = new AbortController2();
|
|
3597
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
3598
|
+
try {
|
|
3599
|
+
const response = await fetch(input.url, {
|
|
3600
|
+
method: "GET",
|
|
3601
|
+
headers: {
|
|
3602
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
3603
|
+
},
|
|
3604
|
+
signal: controller.signal
|
|
3605
|
+
});
|
|
3606
|
+
if (!response.ok) {
|
|
3607
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
3608
|
+
}
|
|
3609
|
+
const contentLength = response.headers.get("content-length");
|
|
3610
|
+
if (contentLength && parseInt(contentLength) > this.MAX_RESPONSE_SIZE) {
|
|
3611
|
+
throw new Error("Response too large (exceeds 5MB limit)");
|
|
3612
|
+
}
|
|
3613
|
+
const contentType = response.headers.get("content-type") || "";
|
|
3614
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3615
|
+
if (arrayBuffer.byteLength > this.MAX_RESPONSE_SIZE) {
|
|
3616
|
+
throw new Error("Response too large (exceeds 5MB limit)");
|
|
3617
|
+
}
|
|
3618
|
+
const text = new TextDecoder().decode(arrayBuffer);
|
|
3619
|
+
let rawContent = text;
|
|
3620
|
+
if (contentType.includes("text/html")) {
|
|
3621
|
+
if (format === "markdown") {
|
|
3622
|
+
const cleanedHtml = this.cleanHtml(text);
|
|
3623
|
+
rawContent = this.turndownService.turndown(cleanedHtml);
|
|
3624
|
+
} else if (format === "text") {
|
|
3625
|
+
const cleanedHtml = this.cleanHtml(text);
|
|
3626
|
+
const root = parse(cleanedHtml);
|
|
3627
|
+
rawContent = root.textContent.trim();
|
|
3628
|
+
} else if (format === "html") {
|
|
3629
|
+
rawContent = this.cleanHtml(text);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
content = rawContent;
|
|
3633
|
+
this.cache.set(input.url, { content, timestamp: Date.now() });
|
|
3634
|
+
} finally {
|
|
3635
|
+
clearTimeout(timeoutId);
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
if (input.prompt) {
|
|
3639
|
+
const truncatedContent = content.length > this.MAX_ANALYSIS_CONTENT_LENGTH ? content.substring(0, this.MAX_ANALYSIS_CONTENT_LENGTH) + "\n\n[Content truncated due to length]" : content;
|
|
3640
|
+
const systemPrompt = [
|
|
3641
|
+
"You are analyzing web content based on a user's specific request.",
|
|
3642
|
+
"The content has been extracted from a webpage and converted to markdown.",
|
|
3643
|
+
"Provide a focused response that directly addresses the user's prompt."
|
|
3644
|
+
];
|
|
3645
|
+
const userPrompt = `Here is the content from ${input.url}:
|
|
3646
|
+
|
|
3647
|
+
${truncatedContent}
|
|
3648
|
+
|
|
3649
|
+
User request: ${input.prompt}`;
|
|
3650
|
+
const aiResponse = await queryQuick({
|
|
3651
|
+
systemPrompt,
|
|
3652
|
+
userPrompt,
|
|
3653
|
+
enablePromptCaching: false
|
|
3654
|
+
});
|
|
3655
|
+
const aiText = aiResponse.message.content.filter((c) => c.type === "text").map((c) => c.text).join("");
|
|
3656
|
+
return {
|
|
3657
|
+
url: input.url,
|
|
3658
|
+
title: input.url,
|
|
3659
|
+
content: aiText,
|
|
3660
|
+
metadata: {
|
|
3661
|
+
mode: "analysis",
|
|
3662
|
+
format,
|
|
3663
|
+
cached: isCached
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3667
|
+
return {
|
|
3668
|
+
url: input.url,
|
|
3669
|
+
title: input.url,
|
|
3670
|
+
// Temporary title
|
|
3671
|
+
content,
|
|
3672
|
+
metadata: {
|
|
3673
|
+
mode: "fetch",
|
|
3674
|
+
format,
|
|
3675
|
+
cached: isCached
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
cleanHtml(html) {
|
|
3680
|
+
const root = parse(html);
|
|
3681
|
+
const elementsToRemove = root.querySelectorAll("script, style, nav, footer, iframe, noscript, object, embed");
|
|
3682
|
+
elementsToRemove.forEach((el) => el.remove());
|
|
3683
|
+
return root.toString();
|
|
3684
|
+
}
|
|
3685
|
+
};
|
|
3686
|
+
|
|
3687
|
+
// src/tools/WebFetcher/WebFetcherTool.tsx
|
|
3688
|
+
import React9 from "react";
|
|
3689
|
+
import { Box as Box9, Text as Text9 } from "ink";
|
|
3690
|
+
var inputSchema9 = z9.strictObject({
|
|
3691
|
+
url: z9.string().url().describe("The URL to fetch content from"),
|
|
3692
|
+
prompt: z9.string().optional().describe("Optional prompt to perform AI analysis on the content"),
|
|
3693
|
+
format: z9.enum(["markdown", "html", "text"]).optional().describe("Output format (default: markdown)"),
|
|
3694
|
+
timeout: z9.number().optional().describe("Timeout in seconds (default: 30)")
|
|
3695
|
+
});
|
|
3696
|
+
var WebFetcherTool = {
|
|
3697
|
+
name: "web_fetcher",
|
|
3698
|
+
async description() {
|
|
3699
|
+
return "Fetch and analyze web content. Supports HTML cleaning, Markdown conversion, and AI-powered analysis.";
|
|
3700
|
+
},
|
|
3701
|
+
userFacingName: () => "Web Fetcher",
|
|
3702
|
+
inputSchema: inputSchema9,
|
|
3703
|
+
isReadOnly: () => true,
|
|
3704
|
+
isConcurrencySafe: () => true,
|
|
3705
|
+
async isEnabled() {
|
|
3706
|
+
return true;
|
|
3707
|
+
},
|
|
3708
|
+
needsPermissions() {
|
|
3709
|
+
return true;
|
|
3710
|
+
},
|
|
3711
|
+
async prompt() {
|
|
3712
|
+
return "Fetch and analyze web content. Supports HTML cleaning, Markdown conversion, and AI-powered analysis.";
|
|
3713
|
+
},
|
|
3714
|
+
renderResultForAssistant(output) {
|
|
3715
|
+
if (output.metadata.mode === "analysis") {
|
|
3716
|
+
return output.content;
|
|
3717
|
+
}
|
|
3718
|
+
return `Content from ${output.url} (Format: ${output.metadata.format}):
|
|
3719
|
+
|
|
3720
|
+
${output.content}`;
|
|
3721
|
+
},
|
|
3722
|
+
renderToolUseMessage(input) {
|
|
3723
|
+
return `Fetching ${input.url}${input.prompt ? ` with prompt: "${input.prompt}"` : ""}`;
|
|
3724
|
+
},
|
|
3725
|
+
renderToolResultMessage(output) {
|
|
3726
|
+
return /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, null, "Fetched ", output.url, " (", output.metadata.mode, ")"));
|
|
3727
|
+
},
|
|
3728
|
+
async *call(input, context) {
|
|
3729
|
+
const fetcher = new WebFetcher();
|
|
3730
|
+
const result = await fetcher.execute(input);
|
|
3731
|
+
yield {
|
|
3732
|
+
type: "result",
|
|
3733
|
+
data: result,
|
|
3734
|
+
resultForAssistant: this.renderResultForAssistant(result)
|
|
3735
|
+
};
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
|
|
3549
3739
|
// src/tools/index.ts
|
|
3550
3740
|
var getAllTools = () => [
|
|
3551
3741
|
TaskTool,
|
|
@@ -3563,7 +3753,7 @@ var getAllTools = () => [
|
|
|
3563
3753
|
DeleteTool,
|
|
3564
3754
|
NotebookEditTool,
|
|
3565
3755
|
TodoWriteTool,
|
|
3566
|
-
|
|
3756
|
+
WebFetcherTool,
|
|
3567
3757
|
AskUserQuestionTool,
|
|
3568
3758
|
EnterPlanModeTool,
|
|
3569
3759
|
ExitPlanModeTool,
|