hyperclaw 4.0.1 → 5.0.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/README.md +58 -4
- package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
- package/dist/a2ui-protocol-CfBI44-Q.js +75 -0
- package/dist/agents-routing-683Q2JGp.js +129 -0
- package/dist/agents-routing-BpZBswBH.js +4 -0
- package/dist/agents-routing-ChHiZp36.js +327 -0
- package/dist/agents-routing-ChqZ6l2S.js +4 -0
- package/dist/api-keys-guide-BCcOl0Q7.js +149 -0
- package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
- package/dist/audit-BYxPlnTQ.js +248 -0
- package/dist/audit-BaIiyWFu.js +441 -0
- package/dist/bounty-tools-C6LyzxM-.js +211 -0
- package/dist/bounty-tools-DWudyZie.js +211 -0
- package/dist/browser-tools-BsTeGMnX.js +5 -0
- package/dist/browser-tools-CQBSbIuO.js +5 -0
- package/dist/browser-tools-D8_rLe2p.js +179 -0
- package/dist/browser-tools-YQmwRLLM.js +179 -0
- package/dist/claw-tasks-BRLUvFRD.js +80 -0
- package/dist/claw-tasks-CgTsiNE8.js +80 -0
- package/dist/connector-3HnyH8fn.js +167 -0
- package/dist/connector-5N0-X_xs.js +194 -0
- package/dist/connector-6PMZo5Ky.js +189 -0
- package/dist/connector-B3v0qcXg.js +425 -0
- package/dist/connector-B6eoF3DD.js +181 -0
- package/dist/connector-B8R3iBY1.js +280 -0
- package/dist/connector-B9tLG8UZ.js +196 -0
- package/dist/connector-BAM-08NN.js +189 -0
- package/dist/connector-BC8FIVu4.js +181 -0
- package/dist/connector-BDmwwaVc.js +213 -0
- package/dist/connector-BGjbBy69.js +225 -0
- package/dist/connector-BO2SRzfG.js +218 -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-BfXky0L3.js +167 -0
- package/dist/connector-BiiSJpx3.js +192 -0
- package/dist/connector-BliDVsJQ.js +239 -0
- package/dist/connector-BnDmIhIu.js +85 -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-C1HSoUyk.js +189 -0
- package/dist/connector-CKQHZOXg.js +568 -0
- package/dist/connector-CRRWY5Wv.js +167 -0
- package/dist/connector-CRl-iidy.js +239 -0
- package/dist/connector-CXPQVGyI.js +85 -0
- package/dist/connector-Cdk1CXKi.js +194 -0
- package/dist/connector-Ci9glMD-.js +340 -0
- package/dist/connector-CjtZIEDj.js +181 -0
- package/dist/connector-Ck6JtOsX.js +531 -0
- package/dist/connector-CwlgFgjx.js +181 -0
- package/dist/connector-D8Kelee0.js +286 -0
- package/dist/connector-DAnRJ0oP.js +162 -0
- package/dist/connector-DFchk6l7.js +178 -0
- package/dist/connector-DKw7tRAy.js +192 -0
- package/dist/connector-DRv1ahC_.js +2 -2
- package/dist/connector-DU63KW94.js +165 -0
- package/dist/connector-DXTp5PE8.js +508 -0
- package/dist/connector-Dbvb1Cj9.js +280 -0
- package/dist/connector-DcZdQcgR.js +173 -0
- package/dist/connector-Dih6dUPP.js +173 -0
- package/dist/connector-DqTH_tPX.js +182 -0
- package/dist/connector-DrnEiiyP.js +419 -0
- package/dist/connector-DtR5GGTX.js +167 -0
- package/dist/connector-DxKL8VvZ.js +182 -0
- package/dist/connector-T_YdZtzv.js +162 -0
- package/dist/connector-Tky_qS_K.js +350 -0
- package/dist/connector-ZSc3oTTy.js +305 -0
- package/dist/connector-i4gOS9xL.js +154 -0
- package/dist/connector-rHXE1ZD2.js +167 -0
- package/dist/connector-sW5yhU1m.js +498 -0
- package/dist/connector-u3ICd3Ic.js +552 -0
- package/dist/connector-wdUXChwa.js +172 -0
- package/dist/cost-tracker-DD9wtWsr.js +103 -0
- package/dist/cost-tracker-pVE15Yq4.js +103 -0
- package/dist/credentials-store-BvnMPJwi.js +4 -0
- package/dist/credentials-store-C6ir0Dae.js +4 -0
- package/dist/credentials-store-H13LqOwJ.js +77 -0
- package/dist/credentials-store-sb-TRLwR.js +77 -0
- package/dist/cron-tasks-Bli7Kzd2.js +82 -0
- package/dist/cron-tasks-BvDFNyiE.js +82 -0
- package/dist/daemon-Bg4GtCmc.js +318 -0
- package/dist/daemon-DhmwY8k4.js +5 -0
- package/dist/delivery-BmIYy9VQ.js +4 -0
- package/dist/delivery-D5Z98EVq.js +95 -0
- package/dist/delivery-DCOXhXEO.js +5 -0
- package/dist/delivery-pWUPBp1F.js +95 -0
- package/dist/destructive-gate-D6vWOdEl.js +101 -0
- package/dist/destructive-gate-m-dWqUFg.js +101 -0
- package/dist/developer-keys-CPWT7Q6S.js +8 -0
- package/dist/developer-keys-DrrcUqFa.js +127 -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-BvCe8BBk.js +230 -0
- package/dist/doctor-Cf1XSfp9.js +4 -0
- package/dist/doctor-CxyPLYsJ.js +6 -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-CEDSqXfw.js +256 -0
- package/dist/engine-D49jnSd_.js +256 -0
- package/dist/engine-Da4JMNpI.js +7 -0
- package/dist/env-resolve-CiXbWYwe.js +10 -0
- package/dist/env-resolve-CmGWhWXJ.js +115 -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/extraction-tools-HOZstZ0y.js +91 -0
- package/dist/extraction-tools-m4lmAv7l.js +5 -0
- package/dist/form_data-B_hIUrxU.js +8657 -0
- package/dist/form_data-Cz040rio.js +8657 -0
- package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
- package/dist/gmail-watch-setup-Du7DVV7S.js +40 -0
- package/dist/health-B-asI__D.js +6 -0
- package/dist/health-Ds2YlpTB.js +152 -0
- package/dist/heartbeat-engine-BYT5ayQH.js +83 -0
- package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
- package/dist/hub-D0XwdjM-.js +515 -0
- package/dist/hub-DTsqe5Bt.js +6 -0
- package/dist/hub-FrPTA33j.js +515 -0
- package/dist/hub-LiD5Iztb.js +6 -0
- package/dist/hyperclawbot-D9KCtc4P.js +480 -0
- package/dist/hyperclawbot-Dw27pJo4.js +480 -0
- package/dist/hyperclawbot-zvczQgKx.js +505 -0
- package/dist/inference-BKVkBREb.js +6 -0
- package/dist/inference-CTWJeX9Q.js +922 -0
- package/dist/inference-DCXH4Q3x.js +922 -0
- package/dist/inference-ix607p7k.js +6 -0
- package/dist/knowledge-graph-DqA-Fztl.js +131 -0
- package/dist/knowledge-graph-iBG76fvm.js +131 -0
- package/dist/loader-CC45xGpC.js +4 -0
- package/dist/loader-CISCqBto.js +400 -0
- package/dist/loader-CYMQ8VOS.js +4 -0
- package/dist/loader-CnEdOyjT.js +400 -0
- package/dist/logger-8tEtAd3y.js +83 -0
- package/dist/logger-ybOp7VOC.js +83 -0
- package/dist/manager-03ipO9R0.js +105 -0
- package/dist/manager-BpDfbDjg.js +117 -0
- package/dist/manager-Bxl0sqlh.js +4 -0
- package/dist/manager-CPjeRe-6.js +4 -0
- package/dist/manager-CrVDn6eN.js +6 -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/manager-FCgF1plu.js +218 -0
- package/dist/manager-rgCsaWT1.js +40 -0
- package/dist/mcp-B_9Ber63.js +139 -0
- package/dist/mcp-CfoSU4Uz.js +139 -0
- package/dist/mcp-loader-DSM5UiFG.js +94 -0
- package/dist/mcp-loader-DkRBsLpk.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-BlHL7JCO.js +4 -0
- package/dist/memory-DsS_eFvJ.js +270 -0
- package/dist/memory-auto-Bc7euou4.js +306 -0
- package/dist/memory-auto-BkvtSFUw.js +5 -0
- package/dist/memory-auto-Bnz_-1wP.js +306 -0
- package/dist/memory-auto-DPfbkMVt.js +5 -0
- package/dist/memory-integration-DZExqWr4.js +91 -0
- package/dist/memory-integration-cSYkZyEo.js +91 -0
- package/dist/moltbook-B6ZeGN5_.js +81 -0
- package/dist/moltbook-BtLDZTfM.js +81 -0
- package/dist/node-Dw2Gi-cP.js +222 -0
- package/dist/node-pwL6O_KX.js +222 -0
- package/dist/nodes-registry-B8dmrlLv.js +52 -0
- package/dist/nodes-registry-CsPm_-CJ.js +52 -0
- package/dist/oauth-flow-CpWlgvNB.js +150 -0
- package/dist/oauth-flow-DQPvMHRH.js +150 -0
- package/dist/oauth-provider-BZb6qOw5.js +110 -0
- package/dist/oauth-provider-Uo4Nib_c.js +110 -0
- package/dist/observability-B43YvNQV.js +89 -0
- package/dist/observability-BV-Yx0V9.js +89 -0
- package/dist/onboard-0WoDxbv_.js +10 -0
- package/dist/onboard-BXNXCQp4.js +4070 -0
- package/dist/onboard-Bd_wsYdi.js +4086 -0
- package/dist/onboard-CAN7x3me.js +3026 -0
- package/dist/onboard-DnegOHMh.js +4 -4
- 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-DmnEvMaL.js +189 -0
- package/dist/orchestrator-NJQsmiBE.js +189 -0
- package/dist/orchestrator-RI3bpqqc.js +6 -0
- package/dist/pairing-6iM27aD8.js +196 -0
- package/dist/pairing-DU0_J28n.js +87 -0
- package/dist/pairing-DWllbSbO.js +4 -0
- package/dist/pairing-dGoiGepK.js +4 -0
- package/dist/pc-access-CgCsYrpt.js +8 -0
- package/dist/pc-access-Ly-uA8mn.js +8 -0
- package/dist/pc-access-NxBvTrRj.js +819 -0
- package/dist/pc-access-_iH2aorG.js +819 -0
- package/dist/pending-approval-CUXjysAo.js +22 -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/reminders-store-Drjed_-h.js +58 -0
- package/dist/renderer-BVQrd0_g.js +225 -0
- package/dist/renderer-pqlDRKbH.js +225 -0
- package/dist/rules-BE4GV6cV.js +103 -0
- package/dist/rules-BooT_qFP.js +103 -0
- package/dist/run-main.js +1649 -1227
- package/dist/runner-D1rjuMTJ.js +810 -0
- package/dist/runner-DatMMYYE.js +1271 -0
- package/dist/sdk/index.js +2 -2
- package/dist/sdk/index.mjs +2 -2
- package/dist/security-BqNyT4ID.js +4 -0
- package/dist/security-C-5URby1.js +73 -0
- package/dist/security-_xve79aq.js +4 -0
- package/dist/security-tpgqPWWH.js +73 -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 +2 -2
- package/dist/server-D4wVHiX9.js +4 -0
- package/dist/server-DU9POoWc.js +4 -0
- package/dist/server-Dh3JlBFB.js +1255 -0
- package/dist/session-store-BUiPz0Vv.js +5 -0
- package/dist/session-store-CujxByI6.js +113 -0
- package/dist/session-store-is4B6qmD.js +113 -0
- package/dist/session-store-qpJUg2M1.js +5 -0
- package/dist/sessions-tools-CB2qbwIk.js +5 -0
- package/dist/sessions-tools-CbUTFe4i.js +5 -0
- package/dist/sessions-tools-CeqD7iil.js +95 -0
- package/dist/sessions-tools-DHMaTZIs.js +95 -0
- package/dist/skill-loader-BaNLVmJy.js +7 -0
- package/dist/skill-loader-BkceKkIg.js +7 -0
- package/dist/skill-loader-DhgIwK4J.js +159 -0
- package/dist/skill-loader-HgpF6Vqs.js +159 -0
- package/dist/skill-runtime--LqxWrp5.js +102 -0
- package/dist/skill-runtime-C5l0Tgt-.js +5 -0
- package/dist/skill-runtime-CJN24QPW.js +102 -0
- package/dist/skill-runtime-DsXK_HYG.js +102 -0
- package/dist/skill-runtime-IVTiqrMR.js +5 -0
- package/dist/skill-runtime-w1ig_lcw.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-BxPHKO5x.js +63 -0
- package/dist/src-DIc-L2IG.js +20 -0
- package/dist/src-DWCUhnD4.js +20 -0
- package/dist/src-cfRTjFef.js +63 -0
- package/dist/src-g_rNx5rh.js +458 -0
- package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
- package/dist/sub-agent-tools-CHQoHz9c.js +39 -0
- package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
- package/dist/theme-DcxwcUgZ.js +180 -0
- package/dist/theme-cx0fkgWC.js +8 -0
- package/dist/tool-policy-CNT-mF2Z.js +189 -0
- package/dist/tool-policy-DNvNRnve.js +189 -0
- package/dist/tts-elevenlabs-BRosZv-f.js +61 -0
- package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
- package/dist/update-check-BD4qH7Am.js +81 -0
- package/dist/update-check-C2Dz85wJ.js +81 -0
- package/dist/vision-BMmiIKy7.js +121 -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/vision-tools-DVuYc17I.js +51 -0
- package/dist/vision-tools-U3YC4L-g.js +5 -0
- package/dist/voice-transcription-B555DbWR.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-DFMrJU-R.js +139 -0
- package/dist/website-watch-tools-DraMPxdl.js +139 -0
- package/dist/website-watch-tools-Du3W5sN7.js +5 -0
- package/package.json +1 -1
package/dist/onboard-DnegOHMh.js
CHANGED
|
@@ -1904,7 +1904,7 @@ var Banner = class {
|
|
|
1904
1904
|
} catch {
|
|
1905
1905
|
console.log(chalk.default.bold.red(`\n ${icon$1} HYPERCLAW\n`));
|
|
1906
1906
|
}
|
|
1907
|
-
const subtitle = daemonMode ? chalk.default.hex(t.daemonPrimary)(" 🩸 DAEMON MODE — ALWAYS WATCHING ⚡\n") : t.muted(" 🦅 HyperClaw Bot — AI Gateway v4.0.
|
|
1907
|
+
const subtitle = daemonMode ? chalk.default.hex(t.daemonPrimary)(" 🩸 DAEMON MODE — ALWAYS WATCHING ⚡\n") : t.muted(" 🦅 HyperClaw Bot — AI Gateway v4.0.2 ⚡\n");
|
|
1908
1908
|
console.log(subtitle);
|
|
1909
1909
|
const boxOpts = {
|
|
1910
1910
|
padding: 1,
|
|
@@ -1938,7 +1938,7 @@ var Banner = class {
|
|
|
1938
1938
|
} catch {
|
|
1939
1939
|
console.log(t.bold("\n 🦅 HYPERCLAW\n"));
|
|
1940
1940
|
}
|
|
1941
|
-
console.log(t.muted(" 🦅 HyperClaw Bot — AI Gateway • SETUP WIZARD v4.0.
|
|
1941
|
+
console.log(t.muted(" 🦅 HyperClaw Bot — AI Gateway • SETUP WIZARD v4.0.2 ⚡\n"));
|
|
1942
1942
|
const boxOpts = {
|
|
1943
1943
|
padding: 1,
|
|
1944
1944
|
margin: { bottom: 1 },
|
|
@@ -2892,7 +2892,7 @@ var HyperClawWizard = class {
|
|
|
2892
2892
|
const finalSkills = skillsPatch.apiKeys || skillsPatch.vtApiKey ? skillsPatch : current?.skills || { installed: [] };
|
|
2893
2893
|
await this.config.save({
|
|
2894
2894
|
...current,
|
|
2895
|
-
version: "4.0.
|
|
2895
|
+
version: "4.0.2",
|
|
2896
2896
|
workspaceName: data.workspaceName,
|
|
2897
2897
|
provider: data.providerConfig,
|
|
2898
2898
|
providers: data.providers || (data.providerConfig ? [data.providerConfig] : []),
|
|
@@ -2983,7 +2983,7 @@ var HyperClawWizard = class {
|
|
|
2983
2983
|
chalk.default.hex("#06b6d4")("Commands:"),
|
|
2984
2984
|
...cmdLines
|
|
2985
2985
|
].join("\n");
|
|
2986
|
-
console.log("\n" + (0, boxen.default)(chalk.default.hex("#06b6d4")("🎉 HyperClaw v4.0.
|
|
2986
|
+
console.log("\n" + (0, boxen.default)(chalk.default.hex("#06b6d4")("🎉 HyperClaw v4.0.2 ready!\n\n") + lines, {
|
|
2987
2987
|
padding: 1,
|
|
2988
2988
|
borderStyle: "round",
|
|
2989
2989
|
borderColor: "cyan",
|
|
@@ -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-Da4JMNpI.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-Da4JMNpI.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-Da4JMNpI.js"));
|
|
135
|
+
return runAgentEngine(message, opts);
|
|
136
|
+
}
|
|
137
|
+
async function planSteps(goal) {
|
|
138
|
+
const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-Da4JMNpI.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,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,6 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_orchestrator = require('./orchestrator-DmnEvMaL.js');
|
|
3
|
+
|
|
4
|
+
require_orchestrator.init_orchestrator();
|
|
5
|
+
exports.runMultiStep = require_orchestrator.runMultiStep;
|
|
6
|
+
exports.runMultiStepParallel = require_orchestrator.runMultiStepParallel;
|