hyperclaw 4.0.0 → 4.0.2
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/README.md +53 -18
- package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
- package/dist/agents-routing-683Q2JGp.js +129 -0
- package/dist/agents-routing-BpZBswBH.js +4 -0
- package/dist/api-keys-guide-Bzig1R5W.js +149 -0
- package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
- package/dist/audit-BYxPlnTQ.js +248 -0
- package/dist/bounty-tools-C6LyzxM-.js +211 -0
- package/dist/browser-tools-CQBSbIuO.js +5 -0
- package/dist/browser-tools-YQmwRLLM.js +179 -0
- package/dist/claw-tasks-BRLUvFRD.js +80 -0
- package/dist/connector-3HnyH8fn.js +167 -0
- package/dist/connector-6PMZo5Ky.js +189 -0
- package/dist/connector-B6eoF3DD.js +181 -0
- package/dist/connector-B9tLG8UZ.js +196 -0
- package/dist/connector-BOlqjXWP.js +182 -0
- package/dist/connector-BP8zsbP8.js +189 -0
- package/dist/connector-BPoSevxp.js +286 -0
- package/dist/connector-BRHj773i.js +163 -0
- package/dist/connector-BToxU-jV.js +267 -0
- package/dist/connector-BliDVsJQ.js +239 -0
- package/dist/connector-Bv6s9oP7.js +88 -0
- package/dist/connector-By5wWGTR.js +343 -0
- package/dist/connector-C1BaFFgN.js +213 -0
- package/dist/connector-CRRWY5Wv.js +167 -0
- package/dist/connector-CXPQVGyI.js +85 -0
- package/dist/connector-Cdk1CXKi.js +194 -0
- package/dist/connector-CwlgFgjx.js +181 -0
- package/dist/connector-DFchk6l7.js +178 -0
- package/dist/connector-DKw7tRAy.js +192 -0
- package/dist/connector-DRv1ahC_.js +343 -0
- package/dist/connector-DU63KW94.js +165 -0
- package/dist/connector-Dbvb1Cj9.js +280 -0
- package/dist/connector-DcZdQcgR.js +173 -0
- package/dist/connector-DxKL8VvZ.js +182 -0
- package/dist/connector-T_YdZtzv.js +162 -0
- package/dist/connector-i4gOS9xL.js +154 -0
- package/dist/connector-rHXE1ZD2.js +167 -0
- package/dist/connector-wdUXChwa.js +172 -0
- package/dist/cost-tracker-pVE15Yq4.js +103 -0
- package/dist/credentials-store-BvnMPJwi.js +4 -0
- package/dist/credentials-store-sb-TRLwR.js +77 -0
- package/dist/cron-tasks-BvDFNyiE.js +82 -0
- package/dist/delivery-B-SJqXLn.js +95 -0
- package/dist/delivery-D5Z98EVq.js +95 -0
- package/dist/delivery-DCOXhXEO.js +5 -0
- package/dist/delivery-VgFeuu2J.js +5 -0
- package/dist/destructive-gate-m-dWqUFg.js +101 -0
- package/dist/developer-keys-JaJK3T27.js +127 -0
- package/dist/developer-keys-kyqmtWK3.js +8 -0
- package/dist/doctor-3oi89QIc.js +175 -0
- package/dist/doctor-Cf1XSfp9.js +4 -0
- package/dist/engine-B4eMiTgl.js +7 -0
- package/dist/engine-B8M7dYul.js +7 -0
- package/dist/engine-BhT-1M9W.js +256 -0
- package/dist/engine-D49jnSd_.js +256 -0
- package/dist/env-resolve-DWOQ45jG.js +9 -0
- package/dist/env-resolve-szSWl0UF.js +94 -0
- package/dist/extraction-tools-D3qDFBJ1.js +91 -0
- package/dist/extraction-tools-DLr_AEwq.js +5 -0
- package/dist/form_data-B_hIUrxU.js +8657 -0
- package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
- package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
- package/dist/hub-DTsqe5Bt.js +6 -0
- package/dist/hub-FrPTA33j.js +515 -0
- package/dist/hyperclawbot-D9KCtc4P.js +480 -0
- package/dist/hyperclawbot-DfMGowZC.js +480 -0
- package/dist/hyperclawbot-Dw27pJo4.js +480 -0
- package/dist/inference-CTWJeX9Q.js +922 -0
- package/dist/inference-ix607p7k.js +6 -0
- package/dist/knowledge-graph-DqA-Fztl.js +131 -0
- package/dist/loader-CISCqBto.js +400 -0
- package/dist/loader-CYMQ8VOS.js +4 -0
- package/dist/logger-8tEtAd3y.js +83 -0
- package/dist/manager-CPjeRe-6.js +4 -0
- package/dist/manager-Cwzj7w5R.js +105 -0
- package/dist/manager-DLmZI-9R.js +6 -0
- package/dist/manager-DSGhn5i3.js +117 -0
- package/dist/manager-DgyF52mg.js +218 -0
- package/dist/manager-Dm8nrMFx.js +40 -0
- package/dist/mcp-B_9Ber63.js +139 -0
- package/dist/mcp-loader-DSM5UiFG.js +94 -0
- package/dist/mcp-loader-j5ZLLw5O.js +94 -0
- package/dist/memory-BI1kPkAN.js +4 -0
- package/dist/memory-BVFGkxxK.js +270 -0
- package/dist/memory-auto-Bc7euou4.js +306 -0
- package/dist/memory-auto-DPfbkMVt.js +5 -0
- package/dist/memory-integration-DZExqWr4.js +91 -0
- package/dist/moltbook-B6ZeGN5_.js +81 -0
- package/dist/node-pwL6O_KX.js +222 -0
- package/dist/nodes-registry-CsPm_-CJ.js +52 -0
- package/dist/oauth-flow-CpWlgvNB.js +150 -0
- package/dist/oauth-provider-BZb6qOw5.js +110 -0
- package/dist/observability-B43YvNQV.js +89 -0
- package/dist/onboard-3q20ZyHj.js +9 -0
- package/dist/onboard-Bd_wsYdi.js +4086 -0
- package/dist/onboard-CAN7x3me.js +3026 -0
- package/dist/onboard-DnegOHMh.js +3026 -0
- package/dist/onboard-RYtDlYBw.js +9 -0
- package/dist/onboard-aTwlQs-4.js +9 -0
- package/dist/orchestrator-BSp2M5EU.js +189 -0
- package/dist/orchestrator-C7ko5tWa.js +6 -0
- package/dist/orchestrator-DfPkIx2Z.js +6 -0
- package/dist/orchestrator-NJQsmiBE.js +189 -0
- package/dist/pairing-DU0_J28n.js +87 -0
- package/dist/pairing-DWllbSbO.js +4 -0
- package/dist/pc-access-Ly-uA8mn.js +8 -0
- package/dist/pc-access-NxBvTrRj.js +819 -0
- package/dist/pending-approval-DIHvwwWS.js +22 -0
- package/dist/puppeteer-2o3QOwAy.js +2 -2
- package/dist/puppeteer-BYTMp3BI.js +2 -2
- package/dist/puppeteer-DQ45qwWk.js +2 -2
- package/dist/reminders-store-D79qdfN0.js +58 -0
- package/dist/renderer-pqlDRKbH.js +225 -0
- package/dist/rules-BooT_qFP.js +103 -0
- package/dist/run-main.js +366 -1109
- package/dist/runner-Bu--_RXw.js +810 -0
- package/dist/runner-D1rjuMTJ.js +810 -0
- package/dist/sdk/index.js +2 -2
- package/dist/sdk/index.mjs +2 -2
- package/dist/security-C-5URby1.js +73 -0
- package/dist/security-_xve79aq.js +4 -0
- package/dist/server-0kgyELx4.js +1047 -0
- package/dist/server-BIuTobTC.js +4 -0
- package/dist/server-BRlCEjyT.js +1047 -0
- package/dist/server-CCI1hv45.js +1047 -0
- package/dist/server-DU9POoWc.js +4 -0
- package/dist/server-RBqwE_GN.js +4 -0
- package/dist/session-store-CujxByI6.js +113 -0
- package/dist/session-store-qpJUg2M1.js +5 -0
- package/dist/sessions-tools-CB2qbwIk.js +5 -0
- package/dist/sessions-tools-DHMaTZIs.js +95 -0
- package/dist/skill-loader-BkceKkIg.js +7 -0
- package/dist/skill-loader-DhgIwK4J.js +159 -0
- package/dist/skill-runtime--LqxWrp5.js +102 -0
- package/dist/skill-runtime-C5l0Tgt-.js +5 -0
- package/dist/skill-runtime-DsXK_HYG.js +102 -0
- package/dist/skill-runtime-IVTiqrMR.js +5 -0
- package/dist/src-BEVLgaF1.js +63 -0
- package/dist/src-Bgu_OxTQ.js +458 -0
- package/dist/src-Bq-oKt7Z.js +458 -0
- package/dist/src-DWCUhnD4.js +20 -0
- package/dist/src-cfRTjFef.js +63 -0
- package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
- package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
- package/dist/tool-policy-DNvNRnve.js +189 -0
- package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
- package/dist/update-check-BD4qH7Am.js +81 -0
- package/dist/vision-DRq-f-Dj.js +121 -0
- package/dist/vision-tools-CFZEpQKm.js +5 -0
- package/dist/vision-tools-CQnBI9aa.js +51 -0
- package/dist/voice-transcription-CbQBToY0.js +138 -0
- package/dist/voice-transcription-CgWq54hn.js +138 -0
- package/dist/website-watch-tools-Bk_TnwuE.js +5 -0
- package/dist/website-watch-tools-DraMPxdl.js +139 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./paths-DPovhojT.js');
|
|
4
|
+
require('./env-resolve-BzDlV2CS.js');
|
|
5
|
+
const require_onboard = require('./onboard-CAN7x3me.js');
|
|
6
|
+
require('./server-0kgyELx4.js');
|
|
7
|
+
require('./theme-LUTKWUWd.js');
|
|
8
|
+
|
|
9
|
+
exports.HyperClawWizard = require_onboard.HyperClawWizard;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./paths-DPovhojT.js');
|
|
4
|
+
require('./env-resolve-szSWl0UF.js');
|
|
5
|
+
const require_onboard = require('./onboard-Bd_wsYdi.js');
|
|
6
|
+
require('./server-BRlCEjyT.js');
|
|
7
|
+
require('./theme-LUTKWUWd.js');
|
|
8
|
+
|
|
9
|
+
exports.HyperClawWizard = require_onboard.HyperClawWizard;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
|
|
3
|
+
//#region packages/core/src/agent/orchestrator.ts
|
|
4
|
+
/** Parse parallel plan into waves: [['A'], ['B','C'], ['D']] = A then B||C then D. */
|
|
5
|
+
function parseParallelWaves(text) {
|
|
6
|
+
const waves = [];
|
|
7
|
+
const lines = (text || "").trim().split(/\n/);
|
|
8
|
+
for (const line of lines) {
|
|
9
|
+
const m = line.match(/^\s*\d+\.\s*(.+)$/);
|
|
10
|
+
if (!m) continue;
|
|
11
|
+
const parts = m[1].split(/\|/).map((s) => s.trim()).filter(Boolean);
|
|
12
|
+
if (parts.length > 0) waves.push(parts);
|
|
13
|
+
}
|
|
14
|
+
return waves;
|
|
15
|
+
}
|
|
16
|
+
/** Parse "1. X\n2. Y" into step strings. */
|
|
17
|
+
function parseSteps(text) {
|
|
18
|
+
const steps = [];
|
|
19
|
+
const lines = (text || "").trim().split(/\n/);
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
const m = line.match(/^\s*\d+\.\s*(.+)$/);
|
|
22
|
+
if (m) steps.push(m[1].trim());
|
|
23
|
+
}
|
|
24
|
+
return steps.length > 0 ? steps : [];
|
|
25
|
+
}
|
|
26
|
+
/** Multi-step with retry, session context, checkpointing, error recovery. */
|
|
27
|
+
async function runMultiStep(goal, opts) {
|
|
28
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B4eMiTgl.js"));
|
|
29
|
+
const maxRetries = opts.maxStepRetries ?? 2;
|
|
30
|
+
const checkpointable = opts.checkpointable ?? false;
|
|
31
|
+
let steps;
|
|
32
|
+
let results = [];
|
|
33
|
+
let startIndex = 0;
|
|
34
|
+
if (opts.checkpoint && opts.checkpoint.goal === goal && opts.checkpoint.steps.length > 0) {
|
|
35
|
+
steps = opts.checkpoint.steps;
|
|
36
|
+
results = [...opts.checkpoint.results ?? []];
|
|
37
|
+
startIndex = results.length;
|
|
38
|
+
} else {
|
|
39
|
+
const planOpts = opts.sessionId && opts.appendTranscript ? opts : {
|
|
40
|
+
...opts,
|
|
41
|
+
sessionId: opts.sessionId,
|
|
42
|
+
appendTranscript: opts.appendTranscript
|
|
43
|
+
};
|
|
44
|
+
const planResult = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
|
|
45
|
+
steps = parseSteps(planResult.text);
|
|
46
|
+
if (steps.length === 0) return runAgentEngine(goal, opts);
|
|
47
|
+
}
|
|
48
|
+
let lastUsage;
|
|
49
|
+
for (let i = startIndex; i < steps.length; i++) {
|
|
50
|
+
const step = steps[i];
|
|
51
|
+
const ctx = results.length > 0 ? `Previous results:\n${results.map((r, j) => `Step ${j + 1}: ${r.slice(0, 400)}${r.length > 400 ? "..." : ""}`).join("\n")}\n\n` : "";
|
|
52
|
+
const message = `${ctx}Step ${i + 1}: ${step}`;
|
|
53
|
+
let lastErr;
|
|
54
|
+
let stepResult;
|
|
55
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
56
|
+
stepResult = await runAgentEngine(message, opts);
|
|
57
|
+
if (stepResult.usage) lastUsage = stepResult.usage;
|
|
58
|
+
if (!stepResult.error) {
|
|
59
|
+
results.push(stepResult.text);
|
|
60
|
+
if (checkpointable && opts.onCheckpoint) await Promise.resolve(opts.onCheckpoint({
|
|
61
|
+
goal,
|
|
62
|
+
steps,
|
|
63
|
+
completedIndices: [...Array(results.length)].map((_, k) => k),
|
|
64
|
+
results: [...results]
|
|
65
|
+
}));
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
lastErr = stepResult.error;
|
|
69
|
+
if (attempt < maxRetries && opts.onToken) opts.onToken(`[Retry ${attempt + 1}/${maxRetries} for step ${i + 1}…]\n`);
|
|
70
|
+
}
|
|
71
|
+
if (lastErr) {
|
|
72
|
+
const summary$1 = results.length > 0 ? results.map((r, j) => `**Step ${j + 1}**\n${r}`).join("\n\n---\n\n") + `\n\n**Step ${i + 1}** (failed): ${lastErr}` : `Step ${i + 1} failed: ${lastErr}`;
|
|
73
|
+
opts.onDone?.(summary$1);
|
|
74
|
+
return {
|
|
75
|
+
text: summary$1,
|
|
76
|
+
error: lastErr,
|
|
77
|
+
usage: lastUsage
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const summary = results.map((r, i) => `**Step ${i + 1}**\n${r}`).join("\n\n---\n\n");
|
|
82
|
+
opts.onDone?.(summary);
|
|
83
|
+
return {
|
|
84
|
+
text: summary,
|
|
85
|
+
usage: lastUsage
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Parallel sub-agents: plan waves → run each wave in parallel (Promise.all) → aggregate. */
|
|
89
|
+
async function runMultiStepParallel(goal, opts) {
|
|
90
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B4eMiTgl.js"));
|
|
91
|
+
const planOpts = {
|
|
92
|
+
...opts,
|
|
93
|
+
sessionId: void 0,
|
|
94
|
+
appendTranscript: void 0
|
|
95
|
+
};
|
|
96
|
+
const planResult = await runAgentEngine(`${PARALLEL_PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
|
|
97
|
+
const waves = parseParallelWaves(planResult.text);
|
|
98
|
+
if (waves.length === 0) return runAgentEngine(goal, opts);
|
|
99
|
+
const allResults = [];
|
|
100
|
+
let lastUsage = planResult.usage;
|
|
101
|
+
for (let w = 0; w < waves.length; w++) {
|
|
102
|
+
const wave = waves[w];
|
|
103
|
+
const ctx = allResults.length > 0 ? `Previous results:\n${allResults.map((r, j) => `Result ${j + 1}: ${r.slice(0, 300)}${r.length > 300 ? "..." : ""}`).join("\n")}\n\n` : "";
|
|
104
|
+
const messages = wave.map((step, i) => `${ctx}Sub-task ${w + 1}.${i + 1}: ${step}`);
|
|
105
|
+
const runOpts = {
|
|
106
|
+
...opts,
|
|
107
|
+
onToken: void 0,
|
|
108
|
+
onDone: void 0
|
|
109
|
+
};
|
|
110
|
+
const results = await Promise.all(messages.map((msg) => runAgentEngine(msg, runOpts)));
|
|
111
|
+
for (const r of results) {
|
|
112
|
+
if (r.usage) lastUsage = r.usage;
|
|
113
|
+
if (r.error) {
|
|
114
|
+
const summary$1 = allResults.map((r0, j) => `**Sub-agent ${j + 1}**\n${r0}`).join("\n\n---\n\n") + `\n\n**Failed**\n${r.text}`;
|
|
115
|
+
opts.onDone?.(summary$1);
|
|
116
|
+
return {
|
|
117
|
+
text: summary$1,
|
|
118
|
+
error: r.error,
|
|
119
|
+
usage: lastUsage
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
allResults.push(r.text);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const summary = allResults.map((r, i) => `**Sub-agent ${i + 1}**\n${r}`).join("\n\n---\n\n");
|
|
126
|
+
opts.onDone?.(summary);
|
|
127
|
+
return {
|
|
128
|
+
text: summary,
|
|
129
|
+
usage: lastUsage
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** Single-run passthrough (unchanged). */
|
|
133
|
+
async function runWithPlan(message, opts) {
|
|
134
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B4eMiTgl.js"));
|
|
135
|
+
return runAgentEngine(message, opts);
|
|
136
|
+
}
|
|
137
|
+
async function planSteps(goal) {
|
|
138
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B4eMiTgl.js"));
|
|
139
|
+
const r = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, {});
|
|
140
|
+
return parseSteps(r.text).map((g) => ({ goal: g }));
|
|
141
|
+
}
|
|
142
|
+
var PLAN_PROMPT, PARALLEL_PLAN_PROMPT;
|
|
143
|
+
var init_orchestrator = require_chunk.__esm({ "packages/core/src/agent/orchestrator.ts"() {
|
|
144
|
+
PLAN_PROMPT = `Break this goal into 1-4 concrete, executable steps. Output ONLY numbered lines.
|
|
145
|
+
Format: 1. step one
|
|
146
|
+
2. step two
|
|
147
|
+
...
|
|
148
|
+
No other text.`;
|
|
149
|
+
PARALLEL_PLAN_PROMPT = `Break this goal into 2-6 steps. Steps that can run IN PARALLEL (independent) put on the SAME line with | between them.
|
|
150
|
+
Format:
|
|
151
|
+
1. step one
|
|
152
|
+
2. step A | step B
|
|
153
|
+
3. step three
|
|
154
|
+
Example: "Compare Python vs Node for APIs" → 1. research Python for APIs | research Node for APIs
|
|
155
|
+
2. summarize comparison
|
|
156
|
+
Output ONLY numbered lines. No other text.`;
|
|
157
|
+
} });
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
Object.defineProperty(exports, 'init_orchestrator', {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () {
|
|
163
|
+
return init_orchestrator;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, 'planSteps', {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function () {
|
|
169
|
+
return planSteps;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, 'runMultiStep', {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function () {
|
|
175
|
+
return runMultiStep;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, 'runMultiStepParallel', {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function () {
|
|
181
|
+
return runMultiStepParallel;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, 'runWithPlan', {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () {
|
|
187
|
+
return runWithPlan;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_orchestrator = require('./orchestrator-NJQsmiBE.js');
|
|
3
|
+
|
|
4
|
+
require_orchestrator.init_orchestrator();
|
|
5
|
+
exports.runMultiStep = require_orchestrator.runMultiStep;
|
|
6
|
+
exports.runMultiStepParallel = require_orchestrator.runMultiStepParallel;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_orchestrator = require('./orchestrator-BSp2M5EU.js');
|
|
3
|
+
|
|
4
|
+
require_orchestrator.init_orchestrator();
|
|
5
|
+
exports.runMultiStep = require_orchestrator.runMultiStep;
|
|
6
|
+
exports.runMultiStepParallel = require_orchestrator.runMultiStepParallel;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
|
|
3
|
+
//#region packages/core/src/agent/orchestrator.ts
|
|
4
|
+
/** Parse parallel plan into waves: [['A'], ['B','C'], ['D']] = A then B||C then D. */
|
|
5
|
+
function parseParallelWaves(text) {
|
|
6
|
+
const waves = [];
|
|
7
|
+
const lines = (text || "").trim().split(/\n/);
|
|
8
|
+
for (const line of lines) {
|
|
9
|
+
const m = line.match(/^\s*\d+\.\s*(.+)$/);
|
|
10
|
+
if (!m) continue;
|
|
11
|
+
const parts = m[1].split(/\|/).map((s) => s.trim()).filter(Boolean);
|
|
12
|
+
if (parts.length > 0) waves.push(parts);
|
|
13
|
+
}
|
|
14
|
+
return waves;
|
|
15
|
+
}
|
|
16
|
+
/** Parse "1. X\n2. Y" into step strings. */
|
|
17
|
+
function parseSteps(text) {
|
|
18
|
+
const steps = [];
|
|
19
|
+
const lines = (text || "").trim().split(/\n/);
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
const m = line.match(/^\s*\d+\.\s*(.+)$/);
|
|
22
|
+
if (m) steps.push(m[1].trim());
|
|
23
|
+
}
|
|
24
|
+
return steps.length > 0 ? steps : [];
|
|
25
|
+
}
|
|
26
|
+
/** Multi-step with retry, session context, checkpointing, error recovery. */
|
|
27
|
+
async function runMultiStep(goal, opts) {
|
|
28
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B8M7dYul.js"));
|
|
29
|
+
const maxRetries = opts.maxStepRetries ?? 2;
|
|
30
|
+
const checkpointable = opts.checkpointable ?? false;
|
|
31
|
+
let steps;
|
|
32
|
+
let results = [];
|
|
33
|
+
let startIndex = 0;
|
|
34
|
+
if (opts.checkpoint && opts.checkpoint.goal === goal && opts.checkpoint.steps.length > 0) {
|
|
35
|
+
steps = opts.checkpoint.steps;
|
|
36
|
+
results = [...opts.checkpoint.results ?? []];
|
|
37
|
+
startIndex = results.length;
|
|
38
|
+
} else {
|
|
39
|
+
const planOpts = opts.sessionId && opts.appendTranscript ? opts : {
|
|
40
|
+
...opts,
|
|
41
|
+
sessionId: opts.sessionId,
|
|
42
|
+
appendTranscript: opts.appendTranscript
|
|
43
|
+
};
|
|
44
|
+
const planResult = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
|
|
45
|
+
steps = parseSteps(planResult.text);
|
|
46
|
+
if (steps.length === 0) return runAgentEngine(goal, opts);
|
|
47
|
+
}
|
|
48
|
+
let lastUsage;
|
|
49
|
+
for (let i = startIndex; i < steps.length; i++) {
|
|
50
|
+
const step = steps[i];
|
|
51
|
+
const ctx = results.length > 0 ? `Previous results:\n${results.map((r, j) => `Step ${j + 1}: ${r.slice(0, 400)}${r.length > 400 ? "..." : ""}`).join("\n")}\n\n` : "";
|
|
52
|
+
const message = `${ctx}Step ${i + 1}: ${step}`;
|
|
53
|
+
let lastErr;
|
|
54
|
+
let stepResult;
|
|
55
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
56
|
+
stepResult = await runAgentEngine(message, opts);
|
|
57
|
+
if (stepResult.usage) lastUsage = stepResult.usage;
|
|
58
|
+
if (!stepResult.error) {
|
|
59
|
+
results.push(stepResult.text);
|
|
60
|
+
if (checkpointable && opts.onCheckpoint) await Promise.resolve(opts.onCheckpoint({
|
|
61
|
+
goal,
|
|
62
|
+
steps,
|
|
63
|
+
completedIndices: [...Array(results.length)].map((_, k) => k),
|
|
64
|
+
results: [...results]
|
|
65
|
+
}));
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
lastErr = stepResult.error;
|
|
69
|
+
if (attempt < maxRetries && opts.onToken) opts.onToken(`[Retry ${attempt + 1}/${maxRetries} for step ${i + 1}…]\n`);
|
|
70
|
+
}
|
|
71
|
+
if (lastErr) {
|
|
72
|
+
const summary$1 = results.length > 0 ? results.map((r, j) => `**Step ${j + 1}**\n${r}`).join("\n\n---\n\n") + `\n\n**Step ${i + 1}** (failed): ${lastErr}` : `Step ${i + 1} failed: ${lastErr}`;
|
|
73
|
+
opts.onDone?.(summary$1);
|
|
74
|
+
return {
|
|
75
|
+
text: summary$1,
|
|
76
|
+
error: lastErr,
|
|
77
|
+
usage: lastUsage
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const summary = results.map((r, i) => `**Step ${i + 1}**\n${r}`).join("\n\n---\n\n");
|
|
82
|
+
opts.onDone?.(summary);
|
|
83
|
+
return {
|
|
84
|
+
text: summary,
|
|
85
|
+
usage: lastUsage
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Parallel sub-agents: plan waves → run each wave in parallel (Promise.all) → aggregate. */
|
|
89
|
+
async function runMultiStepParallel(goal, opts) {
|
|
90
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B8M7dYul.js"));
|
|
91
|
+
const planOpts = {
|
|
92
|
+
...opts,
|
|
93
|
+
sessionId: void 0,
|
|
94
|
+
appendTranscript: void 0
|
|
95
|
+
};
|
|
96
|
+
const planResult = await runAgentEngine(`${PARALLEL_PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
|
|
97
|
+
const waves = parseParallelWaves(planResult.text);
|
|
98
|
+
if (waves.length === 0) return runAgentEngine(goal, opts);
|
|
99
|
+
const allResults = [];
|
|
100
|
+
let lastUsage = planResult.usage;
|
|
101
|
+
for (let w = 0; w < waves.length; w++) {
|
|
102
|
+
const wave = waves[w];
|
|
103
|
+
const ctx = allResults.length > 0 ? `Previous results:\n${allResults.map((r, j) => `Result ${j + 1}: ${r.slice(0, 300)}${r.length > 300 ? "..." : ""}`).join("\n")}\n\n` : "";
|
|
104
|
+
const messages = wave.map((step, i) => `${ctx}Sub-task ${w + 1}.${i + 1}: ${step}`);
|
|
105
|
+
const runOpts = {
|
|
106
|
+
...opts,
|
|
107
|
+
onToken: void 0,
|
|
108
|
+
onDone: void 0
|
|
109
|
+
};
|
|
110
|
+
const results = await Promise.all(messages.map((msg) => runAgentEngine(msg, runOpts)));
|
|
111
|
+
for (const r of results) {
|
|
112
|
+
if (r.usage) lastUsage = r.usage;
|
|
113
|
+
if (r.error) {
|
|
114
|
+
const summary$1 = allResults.map((r0, j) => `**Sub-agent ${j + 1}**\n${r0}`).join("\n\n---\n\n") + `\n\n**Failed**\n${r.text}`;
|
|
115
|
+
opts.onDone?.(summary$1);
|
|
116
|
+
return {
|
|
117
|
+
text: summary$1,
|
|
118
|
+
error: r.error,
|
|
119
|
+
usage: lastUsage
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
allResults.push(r.text);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const summary = allResults.map((r, i) => `**Sub-agent ${i + 1}**\n${r}`).join("\n\n---\n\n");
|
|
126
|
+
opts.onDone?.(summary);
|
|
127
|
+
return {
|
|
128
|
+
text: summary,
|
|
129
|
+
usage: lastUsage
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** Single-run passthrough (unchanged). */
|
|
133
|
+
async function runWithPlan(message, opts) {
|
|
134
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B8M7dYul.js"));
|
|
135
|
+
return runAgentEngine(message, opts);
|
|
136
|
+
}
|
|
137
|
+
async function planSteps(goal) {
|
|
138
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-B8M7dYul.js"));
|
|
139
|
+
const r = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, {});
|
|
140
|
+
return parseSteps(r.text).map((g) => ({ goal: g }));
|
|
141
|
+
}
|
|
142
|
+
var PLAN_PROMPT, PARALLEL_PLAN_PROMPT;
|
|
143
|
+
var init_orchestrator = require_chunk.__esm({ "packages/core/src/agent/orchestrator.ts"() {
|
|
144
|
+
PLAN_PROMPT = `Break this goal into 1-4 concrete, executable steps. Output ONLY numbered lines.
|
|
145
|
+
Format: 1. step one
|
|
146
|
+
2. step two
|
|
147
|
+
...
|
|
148
|
+
No other text.`;
|
|
149
|
+
PARALLEL_PLAN_PROMPT = `Break this goal into 2-6 steps. Steps that can run IN PARALLEL (independent) put on the SAME line with | between them.
|
|
150
|
+
Format:
|
|
151
|
+
1. step one
|
|
152
|
+
2. step A | step B
|
|
153
|
+
3. step three
|
|
154
|
+
Example: "Compare Python vs Node for APIs" → 1. research Python for APIs | research Node for APIs
|
|
155
|
+
2. summarize comparison
|
|
156
|
+
Output ONLY numbered lines. No other text.`;
|
|
157
|
+
} });
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
Object.defineProperty(exports, 'init_orchestrator', {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () {
|
|
163
|
+
return init_orchestrator;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, 'planSteps', {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function () {
|
|
169
|
+
return planSteps;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, 'runMultiStep', {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function () {
|
|
175
|
+
return runMultiStep;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, 'runMultiStepParallel', {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function () {
|
|
181
|
+
return runMultiStepParallel;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, 'runWithPlan', {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () {
|
|
187
|
+
return runWithPlan;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const chalk = require_chunk.__toESM(require("chalk"));
|
|
3
|
+
const fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
4
|
+
const path = require_chunk.__toESM(require("path"));
|
|
5
|
+
const os = require_chunk.__toESM(require("os"));
|
|
6
|
+
const crypto = require_chunk.__toESM(require("crypto"));
|
|
7
|
+
|
|
8
|
+
//#region src/channels/pairing.ts
|
|
9
|
+
var PairingStore = class {
|
|
10
|
+
storePath;
|
|
11
|
+
entries = [];
|
|
12
|
+
constructor() {
|
|
13
|
+
this.storePath = path.default.join(os.default.homedir(), ".hyperclaw", "pairing-store.json");
|
|
14
|
+
this.load();
|
|
15
|
+
}
|
|
16
|
+
load() {
|
|
17
|
+
try {
|
|
18
|
+
this.entries = fs_extra.default.readJsonSync(this.storePath);
|
|
19
|
+
} catch {
|
|
20
|
+
this.entries = [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
save() {
|
|
24
|
+
fs_extra.default.ensureDirSync(path.default.dirname(this.storePath));
|
|
25
|
+
fs_extra.default.writeJsonSync(this.storePath, this.entries, { spaces: 2 });
|
|
26
|
+
}
|
|
27
|
+
generateCode(channelId) {
|
|
28
|
+
const code = crypto.default.randomBytes(3).toString("hex").toUpperCase();
|
|
29
|
+
this.entries.push({
|
|
30
|
+
code,
|
|
31
|
+
channelId,
|
|
32
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33
|
+
status: "pending"
|
|
34
|
+
});
|
|
35
|
+
this.save();
|
|
36
|
+
return code;
|
|
37
|
+
}
|
|
38
|
+
approve(channelId, code, userId) {
|
|
39
|
+
const entry = this.entries.find((e) => e.channelId === channelId && e.code === code && e.status === "pending");
|
|
40
|
+
if (!entry) return false;
|
|
41
|
+
entry.status = "approved";
|
|
42
|
+
entry.approvedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43
|
+
if (userId) entry.userId = userId;
|
|
44
|
+
this.save();
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
listPending(channelId) {
|
|
48
|
+
return this.entries.filter((e) => e.status === "pending" && (!channelId || e.channelId === channelId));
|
|
49
|
+
}
|
|
50
|
+
listApproved(channelId) {
|
|
51
|
+
return this.entries.filter((e) => e.status === "approved" && (!channelId || e.channelId === channelId));
|
|
52
|
+
}
|
|
53
|
+
showList() {
|
|
54
|
+
console.log(chalk.default.bold.cyan("\n 🔑 PAIRING CODES\n"));
|
|
55
|
+
const pending = this.listPending();
|
|
56
|
+
const approved = this.listApproved();
|
|
57
|
+
if (pending.length > 0) {
|
|
58
|
+
console.log(chalk.default.yellow(" Pending:\n"));
|
|
59
|
+
for (const e of pending) console.log(` ${chalk.default.yellow("○")} ${chalk.default.bold(e.code)} channel: ${e.channelId} generated: ${new Date(e.generatedAt).toLocaleTimeString()}`);
|
|
60
|
+
console.log();
|
|
61
|
+
}
|
|
62
|
+
if (approved.length > 0) {
|
|
63
|
+
console.log(chalk.default.green(" Approved:\n"));
|
|
64
|
+
for (const e of approved) {
|
|
65
|
+
const user = e.userId ? ` user: ${e.userId}` : "";
|
|
66
|
+
console.log(` ${chalk.default.green("●")} ${chalk.default.bold(e.code)} channel: ${e.channelId}${user} approved: ${e.approvedAt ? new Date(e.approvedAt).toLocaleDateString() : "unknown"}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
}
|
|
70
|
+
if (pending.length === 0 && approved.length === 0) console.log(chalk.default.gray(" No pairing entries yet.\n"));
|
|
71
|
+
}
|
|
72
|
+
cliApprove(channelId, code) {
|
|
73
|
+
const ok = this.approve(channelId, code);
|
|
74
|
+
if (ok) {
|
|
75
|
+
console.log(chalk.default.green(`\n ✔ Pairing approved — ${channelId} code ${code}`));
|
|
76
|
+
console.log(chalk.default.gray(" User added to channel allowlist\n"));
|
|
77
|
+
} else console.log(chalk.default.red(`\n ✖ Pairing not found or already processed: ${channelId} ${code}\n`));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
Object.defineProperty(exports, 'PairingStore', {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return PairingStore;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./src-DWCUhnD4.js');
|
|
4
|
+
const require_pc_access = require('./pc-access-NxBvTrRj.js');
|
|
5
|
+
|
|
6
|
+
require_pc_access.init_pc_access();
|
|
7
|
+
exports.getPCAccessTools = require_pc_access.getPCAccessTools;
|
|
8
|
+
exports.loadPCAccessConfig = require_pc_access.loadPCAccessConfig;
|