hypercore-cli 1.1.1 → 1.3.0
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/LICENSE +92 -21
- package/README.md +8 -1
- package/dist/App-YMX7FSXR.js +1 -0
- package/dist/api-Q2TX5JJL.js +1 -0
- package/dist/auth-X6CUT3DW.js +1 -0
- package/dist/background-ACODXSUG.js +1 -0
- package/dist/backlog-JD2IM336.js +1 -0
- package/dist/chunk-2QI2IU2V.js +1 -0
- package/dist/chunk-3KFRDIPQ.js +1 -0
- package/dist/chunk-42C5J7PN.js +1 -0
- package/dist/chunk-4D7XVJ7Q.js +1 -0
- package/dist/chunk-545IGTXV.js +1 -0
- package/dist/chunk-5KUSGQP2.js +1 -0
- package/dist/chunk-AUQ64BK2.js +1 -0
- package/dist/chunk-AV244H5C.js +1 -0
- package/dist/chunk-BQVBEFS4.js +1 -0
- package/dist/chunk-BYWQLFP2.js +1 -0
- package/dist/chunk-COITWWZJ.js +1 -0
- package/dist/chunk-CR7UUJVX.js +1 -0
- package/dist/chunk-E3MULLBX.js +1 -0
- package/dist/chunk-EWBV7YPP.js +1 -0
- package/dist/chunk-EZHYVJGQ.js +1 -0
- package/dist/chunk-FAKXBY7Q.js +1 -0
- package/dist/chunk-FHGATV5B.js +1 -0
- package/dist/chunk-I2G27Y5P.js +1 -0
- package/dist/chunk-IKF43TX2.js +1 -0
- package/dist/chunk-INSPHCBN.js +1 -0
- package/dist/chunk-LQMDUKIE.js +1 -0
- package/dist/chunk-M3MTKGA5.js +1 -0
- package/dist/chunk-MPO54FU3.js +1 -0
- package/dist/chunk-PVKCZI6A.js +1 -0
- package/dist/chunk-Q7KEPCYL.js +1 -0
- package/dist/chunk-R5XD3NT2.js +1 -0
- package/dist/chunk-ROBZ6PAL.js +1 -0
- package/dist/chunk-RXB5BS2N.js +1 -0
- package/dist/chunk-RZ3HNYMT.js +1 -0
- package/dist/chunk-UCGLRMTG.js +1 -0
- package/dist/chunk-UEHJVRKB.js +1 -0
- package/dist/chunk-UZYX5GGF.js +1 -0
- package/dist/chunk-XQJBB725.js +1 -0
- package/dist/chunk-ZB5ZQSXH.js +1 -0
- package/dist/claude-US2QPRBA.js +1 -0
- package/dist/commands-5TFN74MD.js +1 -0
- package/dist/commands-EKPWCB3T.js +1 -0
- package/dist/commands-QHJLREPM.js +1 -0
- package/dist/config-2OUL5FLS.js +1 -0
- package/dist/config-loader-N7IBWN2P.js +1 -0
- package/dist/diagnose-NLHN4SAJ.js +1 -0
- package/dist/display-TB5YACJV.js +1 -0
- package/dist/extractor-3KTM2IUL.js +1 -0
- package/dist/feature-flag-VVIF5FJG.js +1 -0
- package/dist/history-GVNDPXXQ.js +1 -0
- package/dist/index.js +1 -402
- package/dist/instance-registry-I5AIVJE2.js +1 -0
- package/dist/keybindings-RN3A7CRW.js +1 -0
- package/dist/loader-3IKPXP4R.js +1 -0
- package/dist/network-GI2F3IDE.js +1 -0
- package/dist/notify-O6FNVHC4.js +1 -0
- package/dist/openai-compat-IPCMINVF.js +1 -0
- package/dist/permissions-5O7KVAXU.js +1 -0
- package/dist/prompt-VWFPFM4N.js +1 -0
- package/dist/quality-GPQD25UL.js +1 -0
- package/dist/repl-YNXCDVU4.js +1 -0
- package/dist/roadmap-QRZODSNJ.js +1 -0
- package/dist/server-USQP4GC4.js +1 -0
- package/dist/session-5HDDQQP6.js +1 -0
- package/dist/skills-DXWSVJSU.js +1 -0
- package/dist/store-WXXTKTTL.js +1 -0
- package/dist/team-VTPJ3WRT.js +1 -0
- package/dist/telemetry-NT4UZLBS.js +1 -0
- package/dist/test-runner-F6B6RH3S.js +1 -0
- package/dist/theme-JJJ6ABR2.js +1 -0
- package/dist/upgrade-RUG3R7R5.js +1 -0
- package/dist/verify-6OGRY2PR.js +1 -0
- package/dist/version-DLROA5JN.js +1 -0
- package/dist/web/static/app.js +1 -562
- package/dist/web/static/index.html +114 -126
- package/dist/web/static/mirror.css +1 -1001
- package/dist/web/static/mirror.html +155 -178
- package/dist/web/static/mirror.js +1 -1125
- package/dist/web/static/onboard.css +1 -302
- package/dist/web/static/onboard.html +121 -145
- package/dist/web/static/onboard.js +1 -300
- package/dist/web/static/style.css +1 -602
- package/dist/web/static/utils.js +1 -0
- package/dist/web/static/workspace.css +1 -1568
- package/dist/web/static/workspace.html +369 -402
- package/dist/web/static/workspace.js +1 -1683
- package/dist/web-P5YUKEAU.js +1 -0
- package/package.json +25 -4
- package/dist/api-D4PUN5BN.js +0 -162
- package/dist/auth-UTR4I6QY.js +0 -21
- package/dist/background-2EGCAAQH.js +0 -14
- package/dist/backlog-Q2NZCLNY.js +0 -24
- package/dist/chunk-2CMSCWQW.js +0 -162
- package/dist/chunk-4DVYJAJL.js +0 -57
- package/dist/chunk-77FRUHTU.js +0 -271
- package/dist/chunk-7ZYMJFCA.js +0 -251
- package/dist/chunk-BE46C7JW.js +0 -46
- package/dist/chunk-CM423E2U.js +0 -133
- package/dist/chunk-E4NKO2KI.js +0 -263
- package/dist/chunk-GH7E2OJE.js +0 -223
- package/dist/chunk-GMLQ7GZ5.js +0 -134
- package/dist/chunk-GU2FZQ6A.js +0 -69
- package/dist/chunk-IOPKN5GD.js +0 -190
- package/dist/chunk-LWDNLX6B.js +0 -2025
- package/dist/chunk-MGLJ53QN.js +0 -219
- package/dist/chunk-NHPDLYEW.js +0 -139
- package/dist/chunk-OGQGKMDX.js +0 -173
- package/dist/chunk-OPZYEVYR.js +0 -150
- package/dist/chunk-OWAOKDIN.js +0 -1505
- package/dist/chunk-R3GPQC7I.js +0 -393
- package/dist/chunk-RKB2JOV2.js +0 -43
- package/dist/chunk-RNG3K465.js +0 -80
- package/dist/chunk-SHJQMIJL.js +0 -288
- package/dist/chunk-SVF2VWOZ.js +0 -145
- package/dist/chunk-TGTYKBGC.js +0 -86
- package/dist/chunk-V2EBSFPU.js +0 -575
- package/dist/chunk-VJDQNNSO.js +0 -681
- package/dist/chunk-VQ35XX7B.js +0 -167
- package/dist/chunk-WHLVZCQY.js +0 -245
- package/dist/chunk-XMGHVNH2.js +0 -66
- package/dist/chunk-YWOSOTUO.js +0 -58
- package/dist/chunk-ZQRNV2US.js +0 -166
- package/dist/chunk-ZSBHUGWR.js +0 -262
- package/dist/claude-O5FSOXZC.js +0 -12
- package/dist/commands-43PLOWRU.js +0 -128
- package/dist/commands-5YVUSUMP.js +0 -232
- package/dist/commands-VZMZJFZF.js +0 -1044
- package/dist/config-WXXEEEVW.js +0 -8
- package/dist/config-loader-SXO674TF.js +0 -24
- package/dist/diagnose-BX45APUZ.js +0 -12
- package/dist/display-IIUBEYWN.js +0 -58
- package/dist/extractor-R5ABXNTJ.js +0 -129
- package/dist/history-JPXZEOT3.js +0 -180
- package/dist/index.d.ts +0 -1
- package/dist/instance-registry-6NJTCAE4.js +0 -15
- package/dist/keybindings-ADWNOX5M.js +0 -15
- package/dist/loader-AXDDCB2G.js +0 -58
- package/dist/network-V3O4UZYZ.js +0 -279
- package/dist/notify-HPTALZDC.js +0 -14
- package/dist/openai-compat-UFDV2SCK.js +0 -12
- package/dist/permissions-JUKXMNDH.js +0 -10
- package/dist/prompt-5CZ34WGA.js +0 -166
- package/dist/quality-ST7PPNFR.js +0 -16
- package/dist/repl-EOWP6AAB.js +0 -3374
- package/dist/roadmap-5OBEKROY.js +0 -17
- package/dist/server-BB5AENWU.js +0 -57
- package/dist/session-5NDKKFLN.js +0 -21
- package/dist/skills-JVLIQVJN.js +0 -175
- package/dist/store-G7KRD4PN.js +0 -25
- package/dist/team-FVNNVDBY.js +0 -385
- package/dist/telemetry-6R4EIE6O.js +0 -30
- package/dist/test-runner-REKSVPPY.js +0 -619
- package/dist/theme-3SYJ3UQA.js +0 -14
- package/dist/upgrade-YSXCO63I.js +0 -83
- package/dist/verify-JUDKTPKZ.js +0 -14
- package/dist/web-H2BJXUBZ.js +0 -39
package/dist/chunk-VQ35XX7B.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadTeam,
|
|
3
|
-
updateMemberStatus
|
|
4
|
-
} from "./chunk-OGQGKMDX.js";
|
|
5
|
-
import {
|
|
6
|
-
validateToken
|
|
7
|
-
} from "./chunk-XMGHVNH2.js";
|
|
8
|
-
|
|
9
|
-
// src/web/ws.ts
|
|
10
|
-
import { WebSocketServer, WebSocket } from "ws";
|
|
11
|
-
var clients = /* @__PURE__ */ new Map();
|
|
12
|
-
function getTeamClients(teamId) {
|
|
13
|
-
return Array.from(clients.values()).filter((c) => c.teamId === teamId);
|
|
14
|
-
}
|
|
15
|
-
function sendToMember(memberId, msg) {
|
|
16
|
-
const client = clients.get(memberId);
|
|
17
|
-
if (client && client.ws.readyState === WebSocket.OPEN) {
|
|
18
|
-
client.ws.send(JSON.stringify(msg));
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
function broadcastToTeam(teamId, msg, excludeId) {
|
|
24
|
-
for (const client of getTeamClients(teamId)) {
|
|
25
|
-
if (client.member.id !== excludeId && client.ws.readyState === WebSocket.OPEN) {
|
|
26
|
-
client.ws.send(JSON.stringify(msg));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function broadcastToAll(teamId, msg) {
|
|
31
|
-
for (const client of getTeamClients(teamId)) {
|
|
32
|
-
if (client.ws.readyState === WebSocket.OPEN) {
|
|
33
|
-
client.ws.send(JSON.stringify(msg));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function makeMsg(type, payload, senderId) {
|
|
38
|
-
return { type, payload, timestamp: (/* @__PURE__ */ new Date()).toISOString(), senderId };
|
|
39
|
-
}
|
|
40
|
-
var pendingCheckpoints = /* @__PURE__ */ new Map();
|
|
41
|
-
function resolveCheckpoint(runId, stationIndex, response) {
|
|
42
|
-
const key = `${runId}:${stationIndex}`;
|
|
43
|
-
const resolver = pendingCheckpoints.get(key);
|
|
44
|
-
if (resolver) {
|
|
45
|
-
resolver(response);
|
|
46
|
-
pendingCheckpoints.delete(key);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
async function handleMessage(ws, raw) {
|
|
52
|
-
let msg;
|
|
53
|
-
try {
|
|
54
|
-
msg = JSON.parse(raw);
|
|
55
|
-
} catch {
|
|
56
|
-
ws.send(JSON.stringify(makeMsg("auth_fail", { reason: "\u65E0\u6548 JSON" })));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const existingClient = Array.from(clients.values()).find((c) => c.ws === ws);
|
|
60
|
-
if (!existingClient) {
|
|
61
|
-
if (msg.type !== "auth") {
|
|
62
|
-
ws.send(JSON.stringify(makeMsg("auth_fail", { reason: "\u8BF7\u5148\u8BA4\u8BC1" })));
|
|
63
|
-
ws.close();
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const { teamId: teamId2, token } = msg.payload;
|
|
67
|
-
const team = await loadTeam(teamId2);
|
|
68
|
-
if (!team) {
|
|
69
|
-
ws.send(JSON.stringify(makeMsg("auth_fail", { reason: "\u56E2\u961F\u4E0D\u5B58\u5728" })));
|
|
70
|
-
ws.close();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const member2 = validateToken(team, token);
|
|
74
|
-
if (!member2) {
|
|
75
|
-
ws.send(JSON.stringify(makeMsg("auth_fail", { reason: "\u4EE4\u724C\u65E0\u6548" })));
|
|
76
|
-
ws.close();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
clients.set(member2.id, { ws, teamId: teamId2, member: member2 });
|
|
80
|
-
await updateMemberStatus(teamId2, member2.id, "online");
|
|
81
|
-
ws.send(JSON.stringify(makeMsg("auth_ok", {
|
|
82
|
-
memberId: member2.id,
|
|
83
|
-
memberName: member2.name,
|
|
84
|
-
role: member2.role,
|
|
85
|
-
teamName: team.name
|
|
86
|
-
})));
|
|
87
|
-
broadcastToTeam(teamId2, makeMsg("member_joined", {
|
|
88
|
-
memberId: member2.id,
|
|
89
|
-
memberName: member2.name
|
|
90
|
-
}), member2.id);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const { teamId, member } = existingClient;
|
|
94
|
-
switch (msg.type) {
|
|
95
|
-
// ----- 任务事件 -----
|
|
96
|
-
case "task_created":
|
|
97
|
-
case "task_updated":
|
|
98
|
-
case "task_deleted":
|
|
99
|
-
broadcastToTeam(teamId, makeMsg(msg.type, msg.payload, member.id), member.id);
|
|
100
|
-
break;
|
|
101
|
-
// ----- 检查点响应 -----
|
|
102
|
-
case "run_checkpoint_response": {
|
|
103
|
-
const { runId, stationIndex, action, feedback } = msg.payload;
|
|
104
|
-
resolveCheckpoint(runId, stationIndex, { action, feedback });
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
// ----- 聊天消息 -----
|
|
108
|
-
case "chat_message": {
|
|
109
|
-
const { content } = msg.payload;
|
|
110
|
-
broadcastToAll(teamId, makeMsg("chat_message", {
|
|
111
|
-
senderId: member.id,
|
|
112
|
-
senderName: member.name,
|
|
113
|
-
content
|
|
114
|
-
}));
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
case "chat_typing": {
|
|
118
|
-
broadcastToTeam(teamId, makeMsg("chat_typing", {
|
|
119
|
-
memberId: member.id,
|
|
120
|
-
memberName: member.name
|
|
121
|
-
}), member.id);
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
default:
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function attachWebSocket(_server, _config) {
|
|
129
|
-
const wss = new WebSocketServer({ noServer: true });
|
|
130
|
-
wss.on("connection", (ws) => {
|
|
131
|
-
ws.on("message", (data) => {
|
|
132
|
-
handleMessage(ws, data.toString()).catch((err) => {
|
|
133
|
-
console.error("[WS] \u5904\u7406\u6D88\u606F\u9519\u8BEF:", err);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
ws.on("close", async () => {
|
|
137
|
-
for (const [memberId, client] of clients.entries()) {
|
|
138
|
-
if (client.ws === ws) {
|
|
139
|
-
clients.delete(memberId);
|
|
140
|
-
await updateMemberStatus(client.teamId, memberId, "offline");
|
|
141
|
-
broadcastToTeam(client.teamId, makeMsg("member_left", {
|
|
142
|
-
memberId,
|
|
143
|
-
memberName: client.member.name
|
|
144
|
-
}));
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
ws.on("error", (err) => {
|
|
150
|
-
console.error("[WS] \u8FDE\u63A5\u9519\u8BEF:", err.message);
|
|
151
|
-
});
|
|
152
|
-
setTimeout(() => {
|
|
153
|
-
const isAuthed = Array.from(clients.values()).some((c) => c.ws === ws);
|
|
154
|
-
if (!isAuthed && ws.readyState === WebSocket.OPEN) {
|
|
155
|
-
ws.send(JSON.stringify(makeMsg("auth_fail", { reason: "\u8BA4\u8BC1\u8D85\u65F6" })));
|
|
156
|
-
ws.close();
|
|
157
|
-
}
|
|
158
|
-
}, 1e4);
|
|
159
|
-
});
|
|
160
|
-
return wss;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
sendToMember,
|
|
165
|
-
broadcastToTeam,
|
|
166
|
-
attachWebSocket
|
|
167
|
-
};
|
package/dist/chunk-WHLVZCQY.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
// src/core/config-loader.ts
|
|
2
|
-
import { readFile, readdir } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
function splitByHeadings(markdown, level) {
|
|
5
|
-
const regex = new RegExp(`^${"#".repeat(level)}\\s+(.+)$`, "gm");
|
|
6
|
-
const sections = [];
|
|
7
|
-
let lastIndex = 0;
|
|
8
|
-
let lastTitle = "";
|
|
9
|
-
let match;
|
|
10
|
-
while ((match = regex.exec(markdown)) !== null) {
|
|
11
|
-
if (lastTitle) {
|
|
12
|
-
sections.push({
|
|
13
|
-
title: lastTitle,
|
|
14
|
-
content: markdown.slice(lastIndex, match.index).trim(),
|
|
15
|
-
level
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
lastTitle = match[1].trim();
|
|
19
|
-
lastIndex = match.index + match[0].length;
|
|
20
|
-
}
|
|
21
|
-
if (lastTitle) {
|
|
22
|
-
sections.push({
|
|
23
|
-
title: lastTitle,
|
|
24
|
-
content: markdown.slice(lastIndex).trim(),
|
|
25
|
-
level
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return sections;
|
|
29
|
-
}
|
|
30
|
-
function parseKeyValue(text) {
|
|
31
|
-
const result = {};
|
|
32
|
-
const lines = text.split("\n");
|
|
33
|
-
let currentKey = "";
|
|
34
|
-
let currentValue = "";
|
|
35
|
-
let inMultiline = false;
|
|
36
|
-
for (const line of lines) {
|
|
37
|
-
if (inMultiline) {
|
|
38
|
-
if (/^\w+:/.test(line) && !line.startsWith(" ")) {
|
|
39
|
-
result[currentKey] = currentValue.trim();
|
|
40
|
-
inMultiline = false;
|
|
41
|
-
} else {
|
|
42
|
-
currentValue += "\n" + line;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const kvMatch = line.match(/^(\w[\w_]*)\s*:\s*(.*)$/);
|
|
47
|
-
if (kvMatch) {
|
|
48
|
-
const [, key, value] = kvMatch;
|
|
49
|
-
if (value === "|" || value === "") {
|
|
50
|
-
currentKey = key;
|
|
51
|
-
currentValue = "";
|
|
52
|
-
inMultiline = true;
|
|
53
|
-
} else {
|
|
54
|
-
result[key] = value.trim();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (inMultiline && currentKey) {
|
|
59
|
-
result[currentKey] = currentValue.trim();
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
function parseList(text) {
|
|
64
|
-
return text.split("\n").filter((line) => line.trim().startsWith("-")).map((line) => line.replace(/^[\s]*-\s*/, "").trim());
|
|
65
|
-
}
|
|
66
|
-
function parsePWP(content) {
|
|
67
|
-
const sections = splitByHeadings(content, 2);
|
|
68
|
-
let identity = "";
|
|
69
|
-
let qualityStandards = [];
|
|
70
|
-
for (const section of sections) {
|
|
71
|
-
const titleLower = section.title.toLowerCase();
|
|
72
|
-
if (titleLower.includes("\u8EAB\u4EFD") || titleLower.includes("identity")) {
|
|
73
|
-
identity = section.content;
|
|
74
|
-
} else if (titleLower.includes("\u54C1\u8D28") || titleLower.includes("quality") || titleLower.includes("\u6807\u51C6")) {
|
|
75
|
-
qualityStandards = parseList(section.content);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return { identity, qualityStandards, rawContent: content };
|
|
79
|
-
}
|
|
80
|
-
function parseAgent(content) {
|
|
81
|
-
const sections = splitByHeadings(content, 2);
|
|
82
|
-
const firstLine = content.split("\n").find((l) => l.startsWith("# "));
|
|
83
|
-
const name = firstLine ? firstLine.replace(/^#\s+/, "").trim() : "unknown";
|
|
84
|
-
let role = "";
|
|
85
|
-
let skillIds = [];
|
|
86
|
-
let style = "";
|
|
87
|
-
for (const section of sections) {
|
|
88
|
-
const titleLower = section.title.toLowerCase();
|
|
89
|
-
if (titleLower.includes("\u89D2\u8272") || titleLower.includes("role")) {
|
|
90
|
-
role = section.content;
|
|
91
|
-
} else if (titleLower.includes("\u6280\u80FD") || titleLower.includes("skill")) {
|
|
92
|
-
skillIds = parseList(section.content);
|
|
93
|
-
} else if (titleLower.includes("\u98CE\u683C") || titleLower.includes("style") || titleLower.includes("\u6027\u683C")) {
|
|
94
|
-
style = section.content;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return { name, role, skillIds, style, rawContent: content };
|
|
98
|
-
}
|
|
99
|
-
function parseSkill(content) {
|
|
100
|
-
const sections = splitByHeadings(content, 2);
|
|
101
|
-
const firstLine = content.split("\n").find((l) => l.startsWith("# "));
|
|
102
|
-
const name = firstLine ? firstLine.replace(/^#\s+/, "").trim() : "unknown";
|
|
103
|
-
let domain = "";
|
|
104
|
-
let knowledge = "";
|
|
105
|
-
let toolStrategy = "";
|
|
106
|
-
let qualityStandards = [];
|
|
107
|
-
for (const section of sections) {
|
|
108
|
-
const titleLower = section.title.toLowerCase();
|
|
109
|
-
if (titleLower.includes("\u9886\u57DF") || titleLower.includes("domain")) {
|
|
110
|
-
domain = section.content;
|
|
111
|
-
} else if (titleLower.includes("\u77E5\u8BC6") || titleLower.includes("knowledge") || titleLower.includes("\u65B9\u6CD5")) {
|
|
112
|
-
knowledge = section.content;
|
|
113
|
-
} else if (titleLower.includes("\u5DE5\u5177") || titleLower.includes("tool")) {
|
|
114
|
-
toolStrategy = section.content;
|
|
115
|
-
} else if (titleLower.includes("\u8D28\u91CF") || titleLower.includes("quality") || titleLower.includes("\u6807\u51C6")) {
|
|
116
|
-
qualityStandards = parseList(section.content);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return { name, domain, knowledge, toolStrategy, qualityStandards, rawContent: content };
|
|
120
|
-
}
|
|
121
|
-
function parseProductionLine(content) {
|
|
122
|
-
const sections = splitByHeadings(content, 2);
|
|
123
|
-
const firstLine = content.split("\n").find((l) => l.startsWith("# "));
|
|
124
|
-
const name = firstLine ? firstLine.replace(/^#\s+/, "").trim() : "unknown";
|
|
125
|
-
let description = "";
|
|
126
|
-
let icon;
|
|
127
|
-
let inputs = [];
|
|
128
|
-
let stations = [];
|
|
129
|
-
let output = { format: "markdown", description: "" };
|
|
130
|
-
for (const section of sections) {
|
|
131
|
-
const titleLower = section.title.toLowerCase();
|
|
132
|
-
if (titleLower.includes("\u63CF\u8FF0") || titleLower.includes("description")) {
|
|
133
|
-
description = section.content;
|
|
134
|
-
} else if (titleLower.includes("\u56FE\u6807") || titleLower.includes("icon")) {
|
|
135
|
-
icon = section.content.trim();
|
|
136
|
-
} else if (titleLower.includes("\u8F93\u5165") || titleLower.includes("input")) {
|
|
137
|
-
inputs = parseInputs(section.content);
|
|
138
|
-
} else if (titleLower.includes("\u5DE5\u4F4D") || titleLower.includes("station")) {
|
|
139
|
-
stations = parseStations(section.content);
|
|
140
|
-
} else if (titleLower.includes("\u8F93\u51FA") || titleLower.includes("output")) {
|
|
141
|
-
const kv = parseKeyValue(section.content);
|
|
142
|
-
output = {
|
|
143
|
-
format: kv["format"] || "markdown",
|
|
144
|
-
description: kv["description"] || ""
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return { name, description, icon, inputs, stations, output };
|
|
149
|
-
}
|
|
150
|
-
function parseInputs(content) {
|
|
151
|
-
return parseList(content).map((line) => {
|
|
152
|
-
const nameMatch = line.match(/^(\w+)\s*[::]\s*(.+)/);
|
|
153
|
-
if (!nameMatch) return { name: line, type: "string", required: false, description: line };
|
|
154
|
-
const [, paramName, rest] = nameMatch;
|
|
155
|
-
const required = rest.includes("\u5FC5\u586B") || rest.includes("required");
|
|
156
|
-
const defaultMatch = rest.match(/默认值?\s*[::]\s*(.+?)(?:[,,))]|$)/);
|
|
157
|
-
return {
|
|
158
|
-
name: paramName,
|
|
159
|
-
type: "string",
|
|
160
|
-
required,
|
|
161
|
-
description: rest,
|
|
162
|
-
defaultValue: defaultMatch?.[1]?.trim()
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
function parseStations(content) {
|
|
167
|
-
const stationSections = splitByHeadings(content, 3);
|
|
168
|
-
return stationSections.map((section, i) => {
|
|
169
|
-
const nameMatch = section.title.match(/^\d+\.\s*(.+)/);
|
|
170
|
-
const stationName = nameMatch ? nameMatch[1].trim() : section.title;
|
|
171
|
-
const kv = parseKeyValue(section.content);
|
|
172
|
-
let checkpoint;
|
|
173
|
-
if (kv["checkpoint"]) {
|
|
174
|
-
const cp = kv["checkpoint"].toLowerCase();
|
|
175
|
-
if (cp === "decision" || cp === "approval") {
|
|
176
|
-
checkpoint = cp;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
index: i + 1,
|
|
181
|
-
name: stationName,
|
|
182
|
-
agentName: kv["agent"] || "default",
|
|
183
|
-
task: kv["task"] || section.content,
|
|
184
|
-
skillName: kv["skill"],
|
|
185
|
-
model: kv["model"],
|
|
186
|
-
retry: kv["retry"] ? parseInt(kv["retry"], 10) : void 0,
|
|
187
|
-
condition: kv["condition"],
|
|
188
|
-
checkpoint,
|
|
189
|
-
checkpointDescription: kv["checkpoint_description"]
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
async function loadFile(path) {
|
|
194
|
-
return readFile(path, "utf-8");
|
|
195
|
-
}
|
|
196
|
-
async function loadPWP(dir) {
|
|
197
|
-
const content = await loadFile(join(dir, "PWP.md"));
|
|
198
|
-
return parsePWP(content);
|
|
199
|
-
}
|
|
200
|
-
async function loadAgent(dir, name) {
|
|
201
|
-
const content = await loadFile(join(dir, "agents", `${name}.agent.md`));
|
|
202
|
-
return parseAgent(content);
|
|
203
|
-
}
|
|
204
|
-
async function loadSkill(dir, name) {
|
|
205
|
-
const content = await loadFile(join(dir, "skills", `${name}.skill.md`));
|
|
206
|
-
return parseSkill(content);
|
|
207
|
-
}
|
|
208
|
-
async function loadLine(dir, name) {
|
|
209
|
-
const content = await loadFile(join(dir, "lines", `${name}.line.md`));
|
|
210
|
-
return parseProductionLine(content);
|
|
211
|
-
}
|
|
212
|
-
async function listLines(dir) {
|
|
213
|
-
const linesDir = join(dir, "lines");
|
|
214
|
-
try {
|
|
215
|
-
const files = await readdir(linesDir);
|
|
216
|
-
const lines = [];
|
|
217
|
-
for (const file of files) {
|
|
218
|
-
if (file.endsWith(".line.md")) {
|
|
219
|
-
const content = await loadFile(join(linesDir, file));
|
|
220
|
-
const line = parseProductionLine(content);
|
|
221
|
-
lines.push({
|
|
222
|
-
name: line.name,
|
|
223
|
-
description: line.description,
|
|
224
|
-
icon: line.icon
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return lines;
|
|
229
|
-
} catch {
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export {
|
|
235
|
-
parsePWP,
|
|
236
|
-
parseAgent,
|
|
237
|
-
parseSkill,
|
|
238
|
-
parseProductionLine,
|
|
239
|
-
loadFile,
|
|
240
|
-
loadPWP,
|
|
241
|
-
loadAgent,
|
|
242
|
-
loadSkill,
|
|
243
|
-
loadLine,
|
|
244
|
-
listLines
|
|
245
|
-
};
|
package/dist/chunk-XMGHVNH2.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HYPERCORE_DIR
|
|
3
|
-
} from "./chunk-SVF2VWOZ.js";
|
|
4
|
-
|
|
5
|
-
// src/team/auth.ts
|
|
6
|
-
import { randomBytes } from "crypto";
|
|
7
|
-
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
8
|
-
import { existsSync } from "fs";
|
|
9
|
-
import { join } from "path";
|
|
10
|
-
function generateId() {
|
|
11
|
-
return randomBytes(4).toString("hex");
|
|
12
|
-
}
|
|
13
|
-
function generateToken() {
|
|
14
|
-
return randomBytes(8).toString("hex");
|
|
15
|
-
}
|
|
16
|
-
function generateJoinCode() {
|
|
17
|
-
const chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
18
|
-
let code = "";
|
|
19
|
-
const bytes = randomBytes(6);
|
|
20
|
-
for (let i = 0; i < 6; i++) {
|
|
21
|
-
code += chars[bytes[i] % chars.length];
|
|
22
|
-
}
|
|
23
|
-
return code;
|
|
24
|
-
}
|
|
25
|
-
function validateToken(team, token) {
|
|
26
|
-
return team.members.find((m) => m.token === token) || null;
|
|
27
|
-
}
|
|
28
|
-
function isOwner(member) {
|
|
29
|
-
return member.role === "owner";
|
|
30
|
-
}
|
|
31
|
-
var TOKEN_FILE = "team-token.json";
|
|
32
|
-
function getTokenPath() {
|
|
33
|
-
return join(HYPERCORE_DIR, TOKEN_FILE);
|
|
34
|
-
}
|
|
35
|
-
async function saveLocalToken(token) {
|
|
36
|
-
await mkdir(HYPERCORE_DIR, { recursive: true });
|
|
37
|
-
await writeFile(getTokenPath(), JSON.stringify(token, null, 2), "utf-8");
|
|
38
|
-
}
|
|
39
|
-
async function loadLocalToken() {
|
|
40
|
-
const p = getTokenPath();
|
|
41
|
-
if (!existsSync(p)) return null;
|
|
42
|
-
try {
|
|
43
|
-
const data = await readFile(p, "utf-8");
|
|
44
|
-
return JSON.parse(data);
|
|
45
|
-
} catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function clearLocalToken() {
|
|
50
|
-
const p = getTokenPath();
|
|
51
|
-
if (existsSync(p)) {
|
|
52
|
-
const { unlink } = await import("fs/promises");
|
|
53
|
-
await unlink(p);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
generateId,
|
|
59
|
-
generateToken,
|
|
60
|
-
generateJoinCode,
|
|
61
|
-
validateToken,
|
|
62
|
-
isOwner,
|
|
63
|
-
saveLocalToken,
|
|
64
|
-
loadLocalToken,
|
|
65
|
-
clearLocalToken
|
|
66
|
-
};
|
package/dist/chunk-YWOSOTUO.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HYPERCORE_DIR
|
|
3
|
-
} from "./chunk-SVF2VWOZ.js";
|
|
4
|
-
|
|
5
|
-
// src/ui/keybindings.ts
|
|
6
|
-
import { existsSync } from "fs";
|
|
7
|
-
import { readFile } from "fs/promises";
|
|
8
|
-
import { join } from "path";
|
|
9
|
-
var DEFAULT_BINDINGS = {
|
|
10
|
-
"ctrl+t": "todo",
|
|
11
|
-
"ctrl+n": "new",
|
|
12
|
-
"ctrl+k": "palette"
|
|
13
|
-
};
|
|
14
|
-
var loadedBindings = null;
|
|
15
|
-
async function loadKeyBindings() {
|
|
16
|
-
const merged = { ...DEFAULT_BINDINGS };
|
|
17
|
-
const filePath = join(HYPERCORE_DIR, "keybindings.json");
|
|
18
|
-
if (existsSync(filePath)) {
|
|
19
|
-
try {
|
|
20
|
-
const content = await readFile(filePath, "utf-8");
|
|
21
|
-
const userBindings = JSON.parse(content);
|
|
22
|
-
Object.assign(merged, userBindings);
|
|
23
|
-
} catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
loadedBindings = merged;
|
|
27
|
-
return merged;
|
|
28
|
-
}
|
|
29
|
-
function getKeyBindings() {
|
|
30
|
-
return loadedBindings || DEFAULT_BINDINGS;
|
|
31
|
-
}
|
|
32
|
-
function keypressToCombo(key) {
|
|
33
|
-
if (!key.name) return null;
|
|
34
|
-
const parts = [];
|
|
35
|
-
if (key.ctrl) parts.push("ctrl");
|
|
36
|
-
if (key.meta) parts.push("alt");
|
|
37
|
-
if (key.shift) parts.push("shift");
|
|
38
|
-
parts.push(key.name);
|
|
39
|
-
return parts.join("+");
|
|
40
|
-
}
|
|
41
|
-
function matchKeyBinding(key) {
|
|
42
|
-
const combo = keypressToCombo(key);
|
|
43
|
-
if (!combo) return null;
|
|
44
|
-
const bindings = getKeyBindings();
|
|
45
|
-
return bindings[combo] || null;
|
|
46
|
-
}
|
|
47
|
-
function listKeyBindings() {
|
|
48
|
-
const bindings = getKeyBindings();
|
|
49
|
-
return Object.entries(bindings).map(([combo, command]) => ({ combo, command }));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
loadKeyBindings,
|
|
54
|
-
getKeyBindings,
|
|
55
|
-
keypressToCombo,
|
|
56
|
-
matchKeyBinding,
|
|
57
|
-
listKeyBindings
|
|
58
|
-
};
|
package/dist/chunk-ZQRNV2US.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getToolPermission
|
|
3
|
-
} from "./chunk-GU2FZQ6A.js";
|
|
4
|
-
|
|
5
|
-
// src/core/agent.ts
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
async function runSubAgent(task, client, config, tools, parentSystemPrompt) {
|
|
8
|
-
const startTime = Date.now();
|
|
9
|
-
const maxTurns = task.maxTurns || 15;
|
|
10
|
-
const timeout = task.timeout || 12e4;
|
|
11
|
-
const toolCalls = [];
|
|
12
|
-
const tokenUsage = { inputTokens: 0, outputTokens: 0 };
|
|
13
|
-
const isSafeTool = (tool) => getToolPermission(tool.definition.name) === "safe";
|
|
14
|
-
const isDangerousTool = (tool) => getToolPermission(tool.definition.name) === "dangerous";
|
|
15
|
-
let filteredTools = tools;
|
|
16
|
-
if (task.type === "explore" || task.type === "plan") {
|
|
17
|
-
filteredTools = tools.filter(isSafeTool);
|
|
18
|
-
} else if (task.type === "research") {
|
|
19
|
-
filteredTools = tools.filter((t) => !isDangerousTool(t));
|
|
20
|
-
}
|
|
21
|
-
const allowedTools = task.allowedTools ? filteredTools.filter((t) => task.allowedTools.includes(t.definition.name)) : filteredTools;
|
|
22
|
-
const typeHints = {
|
|
23
|
-
explore: "\u4F60\u662F\u4E00\u4E2A\u4EE3\u7801\u63A2\u7D22\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u641C\u7D22\u6587\u4EF6\u3001\u8BFB\u53D6\u4EE3\u7801\u3001\u7406\u89E3\u67B6\u6784\u3002\u4E0D\u8981\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\u3002",
|
|
24
|
-
code: "\u4F60\u662F\u4E00\u4E2A\u4EE3\u7801\u7F16\u5199\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u5B9E\u73B0\u529F\u80FD\u3001\u4FEE\u6539\u4EE3\u7801\u3001\u521B\u5EFA\u6587\u4EF6\u3002",
|
|
25
|
-
research: "\u4F60\u662F\u4E00\u4E2A\u7814\u7A76\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u641C\u7D22\u4FE1\u606F\u3001\u9605\u8BFB\u6587\u6863\u3001\u5206\u6790\u6570\u636E\u3002",
|
|
26
|
-
plan: "\u4F60\u662F\u4E00\u4E2A\u89C4\u5212\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u5206\u6790\u9700\u6C42\u3001\u8BBE\u8BA1\u65B9\u6848\u3001\u5236\u5B9A\u8BA1\u5212\u3002\u4E0D\u8981\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\u3002",
|
|
27
|
-
general: "\u4F60\u662F\u4E00\u4E2A\u901A\u7528\u52A9\u624B\u4EE3\u7406\u3002"
|
|
28
|
-
};
|
|
29
|
-
let systemPrompt = task.systemPrompt || "";
|
|
30
|
-
if (!systemPrompt && task.type) {
|
|
31
|
-
systemPrompt = typeHints[task.type] || typeHints.general;
|
|
32
|
-
}
|
|
33
|
-
if (!systemPrompt) {
|
|
34
|
-
systemPrompt = typeHints.general;
|
|
35
|
-
}
|
|
36
|
-
systemPrompt += `
|
|
37
|
-
|
|
38
|
-
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${process.cwd()}`;
|
|
39
|
-
systemPrompt += `
|
|
40
|
-
|
|
41
|
-
\u4EFB\u52A1:
|
|
42
|
-
${task.description}`;
|
|
43
|
-
if (task.planMode) {
|
|
44
|
-
systemPrompt += `
|
|
45
|
-
|
|
46
|
-
\u91CD\u8981\uFF1A\u4F60\u5904\u4E8E\u89C4\u5212\u6A21\u5F0F\u3002\u8BF7\u5206\u6790\u4EFB\u52A1\uFF0C\u63A2\u7D22\u4EE3\u7801\uFF0C\u8F93\u51FA\u8BE6\u7EC6\u7684\u5B9E\u65BD\u65B9\u6848\u3002`;
|
|
47
|
-
systemPrompt += `\u4E0D\u8981\u76F4\u63A5\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\uFF0C\u53EA\u8F93\u51FA\u65B9\u6848\uFF08\u5305\u542B\uFF1A\u9700\u8981\u4FEE\u6539\u7684\u6587\u4EF6\u3001\u5177\u4F53\u6539\u52A8\u3001\u5B9E\u65BD\u6B65\u9AA4\uFF09\u3002`;
|
|
48
|
-
} else {
|
|
49
|
-
systemPrompt += `
|
|
50
|
-
|
|
51
|
-
\u5B8C\u6210\u4EFB\u52A1\u540E\uFF0C\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\u3002\u4FDD\u6301\u7B80\u6D01\u3002`;
|
|
52
|
-
}
|
|
53
|
-
let output = "";
|
|
54
|
-
let timedOut = false;
|
|
55
|
-
try {
|
|
56
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
57
|
-
setTimeout(() => reject(new Error("timeout")), timeout);
|
|
58
|
-
});
|
|
59
|
-
const executionPromise = (async () => {
|
|
60
|
-
if (config.modelConfig.sdkType === "openai") {
|
|
61
|
-
const { streamOpenAIChat } = await import("./openai-compat-UFDV2SCK.js");
|
|
62
|
-
const OpenAI = (await import("openai")).default;
|
|
63
|
-
const openaiClient = client;
|
|
64
|
-
const messages = [
|
|
65
|
-
{ role: "system", content: systemPrompt },
|
|
66
|
-
{ role: "user", content: task.description }
|
|
67
|
-
];
|
|
68
|
-
const result = await streamOpenAIChat(openaiClient, messages, {
|
|
69
|
-
model: config.modelConfig.model,
|
|
70
|
-
tools: allowedTools,
|
|
71
|
-
// maxToolRounds: maxTurns, // TODO: 支持自定义工具轮数
|
|
72
|
-
onChunk: (text) => {
|
|
73
|
-
process.stdout.write(chalk.dim(text));
|
|
74
|
-
},
|
|
75
|
-
onToolCall: (name) => {
|
|
76
|
-
toolCalls.push({ name, input: "" });
|
|
77
|
-
console.log(chalk.dim(` \u{1F527} [\u5B50\u4EE3\u7406] ${name}`));
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
output = result.content;
|
|
81
|
-
tokenUsage.inputTokens += result.tokenUsage.inputTokens;
|
|
82
|
-
tokenUsage.outputTokens += result.tokenUsage.outputTokens;
|
|
83
|
-
} else {
|
|
84
|
-
const { streamCallLLM } = await import("./claude-O5FSOXZC.js");
|
|
85
|
-
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
86
|
-
const anthropicClient = client;
|
|
87
|
-
const result = await streamCallLLM(anthropicClient, {
|
|
88
|
-
systemPrompt,
|
|
89
|
-
userPrompt: task.description,
|
|
90
|
-
history: [],
|
|
91
|
-
tools: allowedTools,
|
|
92
|
-
model: config.modelConfig.model,
|
|
93
|
-
// maxToolRounds: maxTurns, // TODO: 支持自定义工具轮数
|
|
94
|
-
onText: (text) => {
|
|
95
|
-
process.stdout.write(chalk.dim(text));
|
|
96
|
-
},
|
|
97
|
-
onToolCall: (name) => {
|
|
98
|
-
toolCalls.push({ name, input: "" });
|
|
99
|
-
console.log(chalk.dim(` \u{1F527} [\u5B50\u4EE3\u7406] ${name}`));
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
output = result.output;
|
|
103
|
-
tokenUsage.inputTokens += result.tokenUsage.inputTokens;
|
|
104
|
-
tokenUsage.outputTokens += result.tokenUsage.outputTokens;
|
|
105
|
-
}
|
|
106
|
-
})();
|
|
107
|
-
await Promise.race([executionPromise, timeoutPromise]);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
if (err instanceof Error && err.message === "timeout") {
|
|
110
|
-
timedOut = true;
|
|
111
|
-
output = "[\u5B50\u4EE3\u7406\u8D85\u65F6]";
|
|
112
|
-
} else {
|
|
113
|
-
output = `[\u5B50\u4EE3\u7406\u9519\u8BEF: ${err instanceof Error ? err.message : String(err)}]`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const elapsed = Date.now() - startTime;
|
|
117
|
-
return {
|
|
118
|
-
output,
|
|
119
|
-
tokenUsage,
|
|
120
|
-
toolCalls,
|
|
121
|
-
timedOut,
|
|
122
|
-
elapsed
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function createSubAgentTool(getClient, config, tools, systemPrompt) {
|
|
126
|
-
return {
|
|
127
|
-
definition: {
|
|
128
|
-
name: "sub_agent",
|
|
129
|
-
description: "\u542F\u52A8\u5B50\u4EE3\u7406\u6267\u884C\u590D\u6742\u4EFB\u52A1\u3002\u9002\u7528\u4E8E\u9700\u8981\u591A\u6B65\u9AA4\u5DE5\u5177\u8C03\u7528\u7684\u573A\u666F\uFF08\u5982\u63A2\u7D22\u4EE3\u7801\u3001\u7814\u7A76\u95EE\u9898\u3001\u6267\u884C\u8BA1\u5212\uFF09\u3002\u5B50\u4EE3\u7406\u62E5\u6709\u72EC\u7ACB\u4E0A\u4E0B\u6587\u3002",
|
|
130
|
-
input_schema: {
|
|
131
|
-
type: "object",
|
|
132
|
-
properties: {
|
|
133
|
-
description: {
|
|
134
|
-
type: "string",
|
|
135
|
-
description: "\u4EFB\u52A1\u63CF\u8FF0\uFF1A\u6E05\u6670\u63CF\u8FF0\u5B50\u4EE3\u7406\u9700\u8981\u5B8C\u6210\u7684\u4EFB\u52A1"
|
|
136
|
-
},
|
|
137
|
-
type: {
|
|
138
|
-
type: "string",
|
|
139
|
-
enum: ["explore", "code", "research", "plan", "general"],
|
|
140
|
-
description: "\u5B50\u4EE3\u7406\u7C7B\u578B\uFF1Aexplore\uFF08\u63A2\u7D22\u4EE3\u7801\uFF09, code\uFF08\u7F16\u5199\u4EE3\u7801\uFF09, research\uFF08\u7814\u7A76\uFF09, plan\uFF08\u89C4\u5212\uFF09, general\uFF08\u901A\u7528\uFF09"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
required: ["description"]
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
handler: async (input) => {
|
|
147
|
-
const task = {
|
|
148
|
-
description: input.description,
|
|
149
|
-
type: input.type || "general"
|
|
150
|
-
};
|
|
151
|
-
console.log(chalk.dim(`
|
|
152
|
-
\u{1F916} \u542F\u52A8\u5B50\u4EE3\u7406 [${task.type}]...
|
|
153
|
-
`));
|
|
154
|
-
const result = await runSubAgent(task, getClient(), config, tools, systemPrompt);
|
|
155
|
-
console.log(chalk.dim(`
|
|
156
|
-
\u2705 \u5B50\u4EE3\u7406\u5B8C\u6210 (${(result.elapsed / 1e3).toFixed(1)}s, ${result.toolCalls.length} \u6B21\u5DE5\u5177\u8C03\u7528)
|
|
157
|
-
`));
|
|
158
|
-
return result.output;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
runSubAgent,
|
|
165
|
-
createSubAgentTool
|
|
166
|
-
};
|