abtars 0.1.0-alpha.1
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 +190 -0
- package/README.md +84 -0
- package/bundle/_registry.generated-M4WY2MMI.js +35 -0
- package/bundle/_registry.generated-M4WY2MMI.js.map +7 -0
- package/bundle/abtars-browser.js +162 -0
- package/bundle/abtars-browser.js.map +7 -0
- package/bundle/abtars-cli.js +1438 -0
- package/bundle/abtars-cli.js.map +7 -0
- package/bundle/abtars-restart.js +12 -0
- package/bundle/abtars-restart.js.map +7 -0
- package/bundle/abtars-rss.js +165 -0
- package/bundle/abtars-rss.js.map +7 -0
- package/bundle/abtars-task.js +258 -0
- package/bundle/abtars-task.js.map +7 -0
- package/bundle/abtars.js +4072 -0
- package/bundle/abtars.js.map +7 -0
- package/bundle/agent-api-rate-limit-OQNFMXTZ.js +38 -0
- package/bundle/agent-api-rate-limit-OQNFMXTZ.js.map +7 -0
- package/bundle/agent-registry-LT4JNQH6.js +18 -0
- package/bundle/agent-registry-LT4JNQH6.js.map +7 -0
- package/bundle/agents/default.md +29 -0
- package/bundle/anthropic-adapter-2APTH3LA.js +40 -0
- package/bundle/anthropic-adapter-2APTH3LA.js.map +7 -0
- package/bundle/bridge-lock-transport-4AC2G5G6.js +39 -0
- package/bundle/bridge-lock-transport-4AC2G5G6.js.map +7 -0
- package/bundle/browse-delivery-JXBY36GK.js +17 -0
- package/bundle/browse-delivery-JXBY36GK.js.map +7 -0
- package/bundle/browser-ELNDVPLC.js +18 -0
- package/bundle/browser-ELNDVPLC.js.map +7 -0
- package/bundle/capability-CIL3G4FI.js +17 -0
- package/bundle/capability-CIL3G4FI.js.map +7 -0
- package/bundle/chunk-265TPOPC.js +289 -0
- package/bundle/chunk-265TPOPC.js.map +7 -0
- package/bundle/chunk-2UENBO6M.js +223 -0
- package/bundle/chunk-2UENBO6M.js.map +7 -0
- package/bundle/chunk-2UPU3OW6.js +67 -0
- package/bundle/chunk-2UPU3OW6.js.map +7 -0
- package/bundle/chunk-2XU2X4OI.js +125 -0
- package/bundle/chunk-2XU2X4OI.js.map +7 -0
- package/bundle/chunk-3B7BBE4F.js +758 -0
- package/bundle/chunk-3B7BBE4F.js.map +7 -0
- package/bundle/chunk-3E545J66.js +69 -0
- package/bundle/chunk-3E545J66.js.map +7 -0
- package/bundle/chunk-5R2ANXQ7.js +510 -0
- package/bundle/chunk-5R2ANXQ7.js.map +7 -0
- package/bundle/chunk-6CPN4IGS.js +507 -0
- package/bundle/chunk-6CPN4IGS.js.map +7 -0
- package/bundle/chunk-6NR3OHEW.js +88 -0
- package/bundle/chunk-6NR3OHEW.js.map +7 -0
- package/bundle/chunk-6SETMHNN.js +206 -0
- package/bundle/chunk-6SETMHNN.js.map +7 -0
- package/bundle/chunk-6UCRKRWR.js +644 -0
- package/bundle/chunk-6UCRKRWR.js.map +7 -0
- package/bundle/chunk-AR6GO6YC.js +83 -0
- package/bundle/chunk-AR6GO6YC.js.map +7 -0
- package/bundle/chunk-AZJIODTQ.js +54 -0
- package/bundle/chunk-AZJIODTQ.js.map +7 -0
- package/bundle/chunk-BHMZ4RCC.js +3706 -0
- package/bundle/chunk-BHMZ4RCC.js.map +7 -0
- package/bundle/chunk-BQ2L4GMG.js +9175 -0
- package/bundle/chunk-BQ2L4GMG.js.map +7 -0
- package/bundle/chunk-BSSBCSCL.js +159 -0
- package/bundle/chunk-BSSBCSCL.js.map +7 -0
- package/bundle/chunk-BUUVFUPO.js +157 -0
- package/bundle/chunk-BUUVFUPO.js.map +7 -0
- package/bundle/chunk-CEVRHKJY.js +131 -0
- package/bundle/chunk-CEVRHKJY.js.map +7 -0
- package/bundle/chunk-CWOHNFUV.js +39 -0
- package/bundle/chunk-CWOHNFUV.js.map +7 -0
- package/bundle/chunk-D2DCBO6M.js +228 -0
- package/bundle/chunk-D2DCBO6M.js.map +7 -0
- package/bundle/chunk-FMWKEPM7.js +31 -0
- package/bundle/chunk-FMWKEPM7.js.map +7 -0
- package/bundle/chunk-GRNENTPA.js +145 -0
- package/bundle/chunk-GRNENTPA.js.map +7 -0
- package/bundle/chunk-GST5T3WZ.js +93 -0
- package/bundle/chunk-GST5T3WZ.js.map +7 -0
- package/bundle/chunk-GUQVJC3U.js +299 -0
- package/bundle/chunk-GUQVJC3U.js.map +7 -0
- package/bundle/chunk-HX7Y7EYP.js +3659 -0
- package/bundle/chunk-HX7Y7EYP.js.map +7 -0
- package/bundle/chunk-JCJS4ZIB.js +296 -0
- package/bundle/chunk-JCJS4ZIB.js.map +7 -0
- package/bundle/chunk-JW6RU47G.js +184 -0
- package/bundle/chunk-JW6RU47G.js.map +7 -0
- package/bundle/chunk-LSPKJQCI.js +24 -0
- package/bundle/chunk-LSPKJQCI.js.map +7 -0
- package/bundle/chunk-M6VBAPNT.js +16 -0
- package/bundle/chunk-M6VBAPNT.js.map +7 -0
- package/bundle/chunk-MPX525QO.js +129 -0
- package/bundle/chunk-MPX525QO.js.map +7 -0
- package/bundle/chunk-MW6WDLU7.js +130 -0
- package/bundle/chunk-MW6WDLU7.js.map +7 -0
- package/bundle/chunk-NT3OBORC.js +215 -0
- package/bundle/chunk-NT3OBORC.js.map +7 -0
- package/bundle/chunk-NWDBD4PA.js +50 -0
- package/bundle/chunk-NWDBD4PA.js.map +7 -0
- package/bundle/chunk-OP7BTAWY.js +29 -0
- package/bundle/chunk-OP7BTAWY.js.map +7 -0
- package/bundle/chunk-PLCY3GFH.js +77 -0
- package/bundle/chunk-PLCY3GFH.js.map +7 -0
- package/bundle/chunk-PNEDC45Y.js +97 -0
- package/bundle/chunk-PNEDC45Y.js.map +7 -0
- package/bundle/chunk-QBGBT5QS.js +81 -0
- package/bundle/chunk-QBGBT5QS.js.map +7 -0
- package/bundle/chunk-RVE2N7FA.js +70 -0
- package/bundle/chunk-RVE2N7FA.js.map +7 -0
- package/bundle/chunk-TZHIDLDS.js +71910 -0
- package/bundle/chunk-TZHIDLDS.js.map +7 -0
- package/bundle/chunk-UCQ2WC3B.js +126 -0
- package/bundle/chunk-UCQ2WC3B.js.map +7 -0
- package/bundle/chunk-UHRP745J.js +214 -0
- package/bundle/chunk-UHRP745J.js.map +7 -0
- package/bundle/chunk-V76TVMCM.js +58 -0
- package/bundle/chunk-V76TVMCM.js.map +7 -0
- package/bundle/chunk-VVEDVGCR.js +981 -0
- package/bundle/chunk-VVEDVGCR.js.map +7 -0
- package/bundle/chunk-W6FAL35D.js +102 -0
- package/bundle/chunk-W6FAL35D.js.map +7 -0
- package/bundle/chunk-X6TERNVJ.js +15902 -0
- package/bundle/chunk-X6TERNVJ.js.map +7 -0
- package/bundle/chunk-X76UX47U.js +47 -0
- package/bundle/chunk-X76UX47U.js.map +7 -0
- package/bundle/chunk-XREWVCUO.js +518 -0
- package/bundle/chunk-XREWVCUO.js.map +7 -0
- package/bundle/chunk-Y6XAEX2Q.js +408 -0
- package/bundle/chunk-Y6XAEX2Q.js.map +7 -0
- package/bundle/chunk-YOCTDKKL.js +28 -0
- package/bundle/chunk-YOCTDKKL.js.map +7 -0
- package/bundle/chunk-ZXPXCDA6.js +160 -0
- package/bundle/chunk-ZXPXCDA6.js.map +7 -0
- package/bundle/commands-BHVUOU3V.js +31 -0
- package/bundle/commands-BHVUOU3V.js.map +7 -0
- package/bundle/completion-buffer-P253ONKF.js +13 -0
- package/bundle/completion-buffer-P253ONKF.js.map +7 -0
- package/bundle/config-RGSDAPZN.js +19 -0
- package/bundle/config-RGSDAPZN.js.map +7 -0
- package/bundle/config-show-ERTATR6E.js +40 -0
- package/bundle/config-show-ERTATR6E.js.map +7 -0
- package/bundle/context-HCEGZNDC.js +72 -0
- package/bundle/context-HCEGZNDC.js.map +7 -0
- package/bundle/delegation-tools-GYTS2D6A.js +27 -0
- package/bundle/delegation-tools-GYTS2D6A.js.map +7 -0
- package/bundle/deploy-lib-import-32ZFKHWP.js +49 -0
- package/bundle/deploy-lib-import-32ZFKHWP.js.map +7 -0
- package/bundle/digital-signature-OFCGSHWO.js +13 -0
- package/bundle/digital-signature-OFCGSHWO.js.map +7 -0
- package/bundle/direct-api-transport-YR7SXXNN.js +860 -0
- package/bundle/direct-api-transport-YR7SXXNN.js.map +7 -0
- package/bundle/discord-adapter-YYWVMPPU.js +584 -0
- package/bundle/discord-adapter-YYWVMPPU.js.map +7 -0
- package/bundle/dist-MTMKARCP.js +1969 -0
- package/bundle/dist-MTMKARCP.js.map +7 -0
- package/bundle/dns-wakeup-27M7D2MR.js +107 -0
- package/bundle/dns-wakeup-27M7D2MR.js.map +7 -0
- package/bundle/doctor-QNUSDY73.js +248 -0
- package/bundle/doctor-QNUSDY73.js.map +7 -0
- package/bundle/ensure-invariants-NMXNS476.js +49 -0
- package/bundle/ensure-invariants-NMXNS476.js.map +7 -0
- package/bundle/env-schema-2KBHBDGN.js +19 -0
- package/bundle/env-schema-2KBHBDGN.js.map +7 -0
- package/bundle/esm-DDP6NCZG.js +100663 -0
- package/bundle/esm-DDP6NCZG.js.map +7 -0
- package/bundle/fallback-policy-L4QV2PEJ.js +46 -0
- package/bundle/fallback-policy-L4QV2PEJ.js.map +7 -0
- package/bundle/health-check-SPA7NT6N.js +56 -0
- package/bundle/health-check-SPA7NT6N.js.map +7 -0
- package/bundle/hook-system-6Q5YTR53.js +17 -0
- package/bundle/hook-system-6Q5YTR53.js.map +7 -0
- package/bundle/hotskills-K7BM4YLB.js +12 -0
- package/bundle/hotskills-K7BM4YLB.js.map +7 -0
- package/bundle/install-6HRZVKUM.js +15 -0
- package/bundle/install-6HRZVKUM.js.map +7 -0
- package/bundle/install-log-IAPHYKD4.js +28 -0
- package/bundle/install-log-IAPHYKD4.js.map +7 -0
- package/bundle/install-manifest-SPQRUNXL.js +102 -0
- package/bundle/install-manifest-SPQRUNXL.js.map +7 -0
- package/bundle/install-validate-PVLZXYLQ.js +53 -0
- package/bundle/install-validate-PVLZXYLQ.js.map +7 -0
- package/bundle/irc-adapter-OI5UZSQF.js +293 -0
- package/bundle/irc-adapter-OI5UZSQF.js.map +7 -0
- package/bundle/irc-config-55YO6EGB.js +88 -0
- package/bundle/irc-config-55YO6EGB.js.map +7 -0
- package/bundle/logs-ZNYXX5PA.js +19 -0
- package/bundle/logs-ZNYXX5PA.js.map +7 -0
- package/bundle/media-utils-XNNDTYFI.js +4662 -0
- package/bundle/media-utils-XNNDTYFI.js.map +7 -0
- package/bundle/message-pipeline-LLH5SYMO.js +33 -0
- package/bundle/message-pipeline-LLH5SYMO.js.map +7 -0
- package/bundle/meta.json +41304 -0
- package/bundle/model-health-registry-35LQNVQR.js +11 -0
- package/bundle/model-health-registry-35LQNVQR.js.map +7 -0
- package/bundle/notification-Y5S5MMLV.js +13 -0
- package/bundle/notification-Y5S5MMLV.js.map +7 -0
- package/bundle/openrouter-credits-EDY7ETAU.js +32 -0
- package/bundle/openrouter-credits-EDY7ETAU.js.map +7 -0
- package/bundle/passwd-RRFV4CC5.js +133 -0
- package/bundle/passwd-RRFV4CC5.js.map +7 -0
- package/bundle/paths-G33RZWZ7.js +17 -0
- package/bundle/paths-G33RZWZ7.js.map +7 -0
- package/bundle/peer-client-52XYMNI7.js +156 -0
- package/bundle/peer-client-52XYMNI7.js.map +7 -0
- package/bundle/peer-config-VK6EDLN5.js +16 -0
- package/bundle/peer-config-VK6EDLN5.js.map +7 -0
- package/bundle/peer-sessions-EAXTNQ36.js +49 -0
- package/bundle/peer-sessions-EAXTNQ36.js.map +7 -0
- package/bundle/pending-callback-RIMQZ7FJ.js +40 -0
- package/bundle/pending-callback-RIMQZ7FJ.js.map +7 -0
- package/bundle/phase-transport-KYERDL2O.js +22 -0
- package/bundle/phase-transport-KYERDL2O.js.map +7 -0
- package/bundle/public/css/dashboard.css +542 -0
- package/bundle/public/index.html +180 -0
- package/bundle/public/js/app.js +437 -0
- package/bundle/public/memory-universe.js +384 -0
- package/bundle/responses-adapter-AAQTY3K4.js +30 -0
- package/bundle/responses-adapter-AAQTY3K4.js.map +7 -0
- package/bundle/restore-ZE3SEPSS.js +46 -0
- package/bundle/restore-ZE3SEPSS.js.map +7 -0
- package/bundle/self-healer-utils-DMUUXC47.js +43 -0
- package/bundle/self-healer-utils-DMUUXC47.js.map +7 -0
- package/bundle/skill-stats-LLEXEXLR.js +22 -0
- package/bundle/skill-stats-LLEXEXLR.js.map +7 -0
- package/bundle/sleep-OYIUOVQD.js +19 -0
- package/bundle/sleep-OYIUOVQD.js.map +7 -0
- package/bundle/soul-loader-54WCVNLJ.js +16 -0
- package/bundle/soul-loader-54WCVNLJ.js.map +7 -0
- package/bundle/src-JL4PVO23.js +8 -0
- package/bundle/src-JL4PVO23.js.map +7 -0
- package/bundle/sse-parser-anthropic-P7CE2MH2.js +72 -0
- package/bundle/sse-parser-anthropic-P7CE2MH2.js.map +7 -0
- package/bundle/sse-parser-responses-EQQA5FWN.js +63 -0
- package/bundle/sse-parser-responses-EQQA5FWN.js.map +7 -0
- package/bundle/ssrf-guard-FZCBYIVW.js +64 -0
- package/bundle/ssrf-guard-FZCBYIVW.js.map +7 -0
- package/bundle/start-FH3GRMJ4.js +35 -0
- package/bundle/start-FH3GRMJ4.js.map +7 -0
- package/bundle/stream-single-WSG4D53C.js +33 -0
- package/bundle/stream-single-WSG4D53C.js.map +7 -0
- package/bundle/stt-2UH3RITX.js +14 -0
- package/bundle/stt-2UH3RITX.js.map +7 -0
- package/bundle/subagent-runtime-LE2ZXH3G.js +12 -0
- package/bundle/subagent-runtime-LE2ZXH3G.js.map +7 -0
- package/bundle/system-message-T5R3EYYN.js +30 -0
- package/bundle/system-message-T5R3EYYN.js.map +7 -0
- package/bundle/system-status-KQ6KHFJ6.js +189 -0
- package/bundle/system-status-KQ6KHFJ6.js.map +7 -0
- package/bundle/task-store-K7CQDEPI.js +22 -0
- package/bundle/task-store-K7CQDEPI.js.map +7 -0
- package/bundle/telegram-adapter-2V3XUMT5.js +1060 -0
- package/bundle/telegram-adapter-2V3XUMT5.js.map +7 -0
- package/bundle/tool-registry-MU3OX4UI.js +38 -0
- package/bundle/tool-registry-MU3OX4UI.js.map +7 -0
- package/bundle/tool-sandbox-VYOK4ZOA.js +20 -0
- package/bundle/tool-sandbox-VYOK4ZOA.js.map +7 -0
- package/bundle/transport-config-YLXU33RO.js +57 -0
- package/bundle/transport-config-YLXU33RO.js.map +7 -0
- package/bundle/update-QCW5LXRN.js +13 -0
- package/bundle/update-QCW5LXRN.js.map +7 -0
- package/bundle/update-check-27KZSAP6.js +12 -0
- package/bundle/update-check-27KZSAP6.js.map +7 -0
- package/bundle/usage-tracker-OVVEVMOY.js +17 -0
- package/bundle/usage-tracker-OVVEVMOY.js.map +7 -0
- package/bundle/user-registry-D4SD73UV.js +16 -0
- package/bundle/user-registry-D4SD73UV.js.map +7 -0
- package/core/professor.json +14 -0
- package/core/prompts/browsing_prompt.md +39 -0
- package/core/prompts/compaction.md +32 -0
- package/core/skills/memory/classification/SKILL.md +37 -0
- package/core/skills/memory/memory-anomalies/SKILL.md +39 -0
- package/core/skills/memory/memory-search/SKILL.md +48 -0
- package/core/skills/memory/topic-save/SKILL.md +44 -0
- package/core/skills/ops/cron/SKILL.md +51 -0
- package/core/skills/ops/gdrive-backup/SKILL.md +15 -0
- package/core/skills/ops/session-start/SKILL.md +11 -0
- package/core/skills/ops/skill-authoring/SKILL.md +54 -0
- package/core/skills/ops/system-health/SKILL.md +104 -0
- package/core/skills/ops/troubleshooting/SKILL.md +48 -0
- package/core/skills/ops/trust-gating/SKILL.md +30 -0
- package/core/skills/tools/a2a-communication/SKILL.md +68 -0
- package/core/skills/tools/browse-delegate/SKILL.md +27 -0
- package/core/skills/tools/browser/SKILL.md +36 -0
- package/core/skills/tools/clawhub/SKILL.md +44 -0
- package/core/skills/tools/delegation/SKILL.md +48 -0
- package/core/skills/tools/fxtwitter/SKILL.md +52 -0
- package/core/skills/tools/gmail/SKILL.md +44 -0
- package/core/skills/tools/irc-chat/SKILL.md +84 -0
- package/core/skills/tools/linear/SKILL.md +90 -0
- package/core/skills/tools/mcporter/SKILL.md +46 -0
- package/core/skills/tools/model-scout/SKILL.md +132 -0
- package/core/skills/tools/model-scout/scout-add-model.py +67 -0
- package/core/skills/tools/model-scout/scout-ollama.py +116 -0
- package/core/skills/tools/model-scout/scout-openrouter.py +85 -0
- package/core/skills/tools/nlm/SKILL.md +40 -0
- package/core/skills/tools/todo/SKILL.md +30 -0
- package/core/skills/tools/twitterX/SKILL.md +52 -0
- package/core/skills/tools/twitterX/scripts/abtars-tweet.js +532 -0
- package/core/skills/tools/twitterX/scripts/package.json +1 -0
- package/core/skills/tools/web-fetch/SKILL.md +29 -0
- package/package.json +59 -0
- package/scripts/abtars-daemon.service +23 -0
- package/scripts/abtars-fetch.sh +42 -0
- package/scripts/abtars-watchdog.service +13 -0
- package/scripts/abtars.sh +14 -0
- package/scripts/abtars@.service +21 -0
- package/scripts/browser-patchright.sh +79 -0
- package/scripts/com.abtars.daemon.plist +24 -0
- package/scripts/com.abtars.watchdog.plist +27 -0
- package/scripts/daily-backup.sh +62 -0
- package/scripts/doctor.sh +553 -0
- package/scripts/hooks/audit-logger.sh +22 -0
- package/scripts/upgrade-deps.sh +64 -0
- package/scripts/watchdog.sh +309 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { createRequire as __bundleCreateRequire } from 'node:module'; import { fileURLToPath as __bundleFileURLToPath } from 'node:url'; import { dirname as __bundleDirname } from 'node:path'; const require = __bundleCreateRequire(import.meta.url); const __chunk_filename = __bundleFileURLToPath(import.meta.url); const __chunk_dirname = __bundleDirname(__chunk_filename);
|
|
2
|
+
import {
|
|
3
|
+
init_logger,
|
|
4
|
+
logInfo,
|
|
5
|
+
logWarn
|
|
6
|
+
} from "./chunk-BUUVFUPO.js";
|
|
7
|
+
import {
|
|
8
|
+
__esm
|
|
9
|
+
} from "./chunk-NWDBD4PA.js";
|
|
10
|
+
|
|
11
|
+
// src/components/env-schema.ts
|
|
12
|
+
function parseTime(raw, varName) {
|
|
13
|
+
const parts = raw.split(":");
|
|
14
|
+
const hour = parseInt(parts[0] ?? "", 10);
|
|
15
|
+
const minute = parseInt(parts[1] ?? "0", 10);
|
|
16
|
+
if (isNaN(hour) || isNaN(minute) || hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
|
17
|
+
throw new Error(`Invalid ${varName}: "${raw}" \u2014 expected H:MM or HH:MM (e.g. "0:30", "14:00")`);
|
|
18
|
+
}
|
|
19
|
+
return { hour, minute, raw };
|
|
20
|
+
}
|
|
21
|
+
function parseIntSafe(raw, varName) {
|
|
22
|
+
const n = parseInt(raw, 10);
|
|
23
|
+
if (isNaN(n)) throw new Error(`Invalid ${varName}: "${raw}" \u2014 expected integer`);
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
function parseBool(raw) {
|
|
27
|
+
return raw.toLowerCase() === "true" || raw === "1";
|
|
28
|
+
}
|
|
29
|
+
function getEnv() {
|
|
30
|
+
if (!_env) initEnv();
|
|
31
|
+
return _env;
|
|
32
|
+
}
|
|
33
|
+
function envDump() {
|
|
34
|
+
const env = getEnv();
|
|
35
|
+
const result = {};
|
|
36
|
+
for (const [key, value] of Object.entries(env)) {
|
|
37
|
+
if (typeof value === "function") continue;
|
|
38
|
+
const strVal = value == null ? "(not set)" : String(value);
|
|
39
|
+
if (/token|key|secret|password/i.test(key) && strVal.length > 4) {
|
|
40
|
+
result[key] = strVal.slice(0, 4) + "\u2026" + strVal.slice(-2);
|
|
41
|
+
} else {
|
|
42
|
+
result[key] = strVal;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function initEnv() {
|
|
48
|
+
const knownVars = new Set(SCHEMA.map((s) => s.env));
|
|
49
|
+
const warnings = [];
|
|
50
|
+
const envKeys = Object.keys(process.env).filter((k) => /^[A-Z_]+$/.test(k));
|
|
51
|
+
for (const k of envKeys) {
|
|
52
|
+
if (knownVars.has(k)) continue;
|
|
53
|
+
if (k.endsWith("_API_KEY") || k.endsWith("_API_ID")) continue;
|
|
54
|
+
if (k.startsWith("HA_")) continue;
|
|
55
|
+
const suggestion = findClosest(k, knownVars);
|
|
56
|
+
if (suggestion) {
|
|
57
|
+
warnings.push(`Unknown env var ${k} \u2014 did you mean ${suggestion}?`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function read(envName) {
|
|
61
|
+
return process.env[envName]?.trim() || void 0;
|
|
62
|
+
}
|
|
63
|
+
function readOr(envName, fallback) {
|
|
64
|
+
return read(envName) ?? fallback;
|
|
65
|
+
}
|
|
66
|
+
const env = {
|
|
67
|
+
abtarsHome: readOr("ABTARS_HOME", ""),
|
|
68
|
+
workingDir: readOr("WORKING_DIR", "."),
|
|
69
|
+
mainChatId: read("MAIN_CHAT_ID"),
|
|
70
|
+
mainChatProvider: (read("MAIN_CHAT_PROVIDER") ?? "telegram") === "discord" ? "discord" : "telegram",
|
|
71
|
+
logLevel: readOr("LOG_LEVEL", "low").toLowerCase(),
|
|
72
|
+
logFormat: readOr("LOG_FORMAT", "text") === "json" ? "json" : "text",
|
|
73
|
+
agentCliPath: read("AGENT_CLI_PATH"),
|
|
74
|
+
apiKey: read("API_KEY"),
|
|
75
|
+
tmuxSession: readOr("TMUX_SESSION", "kiro"),
|
|
76
|
+
defaultTransport: readOr("DEFAULT_TRANSPORT", "api"),
|
|
77
|
+
transportConfig: readOr("TRANSPORT_CONFIG", "transport.json").replace("config/", ""),
|
|
78
|
+
modelsConfig: readOr("MODELS_CONFIG", "models.json").replace("config/", ""),
|
|
79
|
+
promptTimeoutSec: parseIntSafe(readOr("PROMPT_TIMEOUT_SEC", "180"), "PROMPT_TIMEOUT_SEC"),
|
|
80
|
+
modelApiTimeoutMs: parseIntSafe(readOr("MODEL_API_TIMEOUT_SEC", "120"), "MODEL_API_TIMEOUT_SEC") * 1e3,
|
|
81
|
+
watchdogToolTimeoutSec: parseIntSafe(readOr("WATCHDOG_TOOL_TIMEOUT_SEC", "180"), "WATCHDOG_TOOL_TIMEOUT_SEC"),
|
|
82
|
+
watchdogSilentSec: parseIntSafe(readOr("WATCHDOG_SILENT_SEC", "300"), "WATCHDOG_SILENT_SEC"),
|
|
83
|
+
watchdogEndlessSec: parseIntSafe(readOr("WATCHDOG_ENDLESS_SEC", "600"), "WATCHDOG_ENDLESS_SEC"),
|
|
84
|
+
telegramBotToken: read("TELEGRAM_BOT_TOKEN"),
|
|
85
|
+
telegramTimeoutMs: parseIntSafe(readOr("TELEGRAM_TIMEOUT_SEC", "10"), "TELEGRAM_TIMEOUT_SEC") * 1e3,
|
|
86
|
+
telegramFileTimeoutMs: parseIntSafe(readOr("TELEGRAM_FILE_TIMEOUT_SEC", "60"), "TELEGRAM_FILE_TIMEOUT_SEC") * 1e3,
|
|
87
|
+
pollTimeoutS: parseIntSafe(readOr("POLL_TIMEOUT_S", "30"), "POLL_TIMEOUT_S"),
|
|
88
|
+
discordBotToken: read("DISCORD_BOT_TOKEN"),
|
|
89
|
+
discordAppId: read("DISCORD_APP_ID"),
|
|
90
|
+
discordGroupMentions: readOr("DISCORD_GROUP_MENTIONS", "required"),
|
|
91
|
+
ctxWarnPct: parseIntSafe(readOr("CTX_WARN_PCT", "70"), "CTX_WARN_PCT"),
|
|
92
|
+
ctxCompactPct: parseIntSafe(readOr("CTX_COMPACT_PCT", "80"), "CTX_COMPACT_PCT"),
|
|
93
|
+
ctxAggressivePct: parseIntSafe(readOr("CTX_AGGRESSIVE_PCT", "90"), "CTX_AGGRESSIVE_PCT"),
|
|
94
|
+
ctxIdleCompactPct: parseIntSafe(readOr("CTX_IDLE_COMPACT_PCT", "65"), "CTX_IDLE_COMPACT_PCT"),
|
|
95
|
+
ctxIdleCompactMin: parseIntSafe(readOr("CTX_IDLE_COMPACT_MIN", "10"), "CTX_IDLE_COMPACT_MIN"),
|
|
96
|
+
typingTtlMs: parseIntSafe(readOr("TYPING_TTL_SEC", "300"), "TYPING_TTL_SEC") * 1e3,
|
|
97
|
+
typingSilentThresholdMs: parseIntSafe(readOr("TYPING_SILENT_THRESHOLD_SEC", "90"), "TYPING_SILENT_THRESHOLD_SEC") * 1e3,
|
|
98
|
+
streamFlushSec: parseIntSafe(readOr("STREAM_FLUSH_SEC", "3"), "STREAM_FLUSH_SEC"),
|
|
99
|
+
activeMemory: parseBool(readOr("ACTIVE_MEMORY", "true")),
|
|
100
|
+
primingModelTopics: read("PRIMING_MODEL_TOPICS") !== "false",
|
|
101
|
+
bedTime: parseTime(readOr("BED_TIME", "0:30"), "BED_TIME"),
|
|
102
|
+
wakeTime: parseTime(readOr("WAKE_TIME", "7:00"), "WAKE_TIME"),
|
|
103
|
+
bedQuietMin: parseIntSafe(readOr("BED_QUIET_MIN", "7"), "BED_QUIET_MIN"),
|
|
104
|
+
hardwareSleepAfterDreamy: parseBool(readOr("HARDWARE_SLEEP_AFTER_DREAMY", "false")),
|
|
105
|
+
sleepModel: read("SLEEP_MODEL"),
|
|
106
|
+
sleepQuality: read("SLEEP_QUALITY"),
|
|
107
|
+
sttEnabled: parseBool(readOr("STT_ENABLED", "false")),
|
|
108
|
+
sttModel: readOr("STT_MODEL", "whisper-large-v3-turbo"),
|
|
109
|
+
ttsEnabled: parseBool(readOr("TTS_ENABLED", "false")),
|
|
110
|
+
ttsVoice: readOr("TTS_VOICE", "alloy"),
|
|
111
|
+
selfhealEnabled: parseBool(readOr("SELFHEAL_ENABLED", "false")),
|
|
112
|
+
browserEngine: readOr("BROWSER_ENGINE", "patchright"),
|
|
113
|
+
browserHeaded: parseBool(readOr("BROWSER_HEADED", "false")),
|
|
114
|
+
browserNoSandbox: parseBool(readOr("BROWSER_NO_SANDBOX", "false")),
|
|
115
|
+
browserChannel: read("BROWSER_CHANNEL"),
|
|
116
|
+
browserDocker: parseBool(readOr("BROWSER_DOCKER", "false")),
|
|
117
|
+
browserIdleStopMin: parseIntSafe(readOr("BROWSER_IDLE_STOP_MIN", "10"), "BROWSER_IDLE_STOP_MIN"),
|
|
118
|
+
browserAllowedDomains: readOr("BROWSER_ALLOWED_DOMAINS", ""),
|
|
119
|
+
browserSocketPath: readOr("BROWSER_SOCKET_PATH", "/run/browser/browser.sock"),
|
|
120
|
+
browserMaxSessions: parseIntSafe(readOr("BROWSER_MAX_SESSIONS", "3"), "BROWSER_MAX_SESSIONS"),
|
|
121
|
+
browserSessionTimeoutMs: parseIntSafe(readOr("BROWSER_SESSION_TIMEOUT_SEC", "300"), "BROWSER_SESSION_TIMEOUT_SEC") * 1e3,
|
|
122
|
+
webScrapeUserAgent: read("WEB_SCRAPE_USER_AGENT"),
|
|
123
|
+
webScrapePlaywrightTimeoutMs: parseIntSafe(readOr("WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC", "30"), "WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC") * 1e3,
|
|
124
|
+
ssrfCheck: read("SSRF_CHECK") !== "0",
|
|
125
|
+
browsingAgent: read("BROWSING_AGENT"),
|
|
126
|
+
disabledCapabilities: readOr("DISABLED_CAPABILITIES", ""),
|
|
127
|
+
codingModel: read("CODING_MODEL"),
|
|
128
|
+
dashboardModule: read("DASHBOARD_MODULE"),
|
|
129
|
+
notebooklmEnabled: parseBool(readOr("NOTEBOOKLM_ENABLED", "false")),
|
|
130
|
+
notebooklmDefaultNotebook: readOr("NOTEBOOKLM_DEFAULT_NOTEBOOK", ""),
|
|
131
|
+
permissionTimeoutMs: parseIntSafe(readOr("PERMISSION_TIMEOUT_SEC", "60"), "PERMISSION_TIMEOUT_SEC") * 1e3,
|
|
132
|
+
trustMode: parseBool(readOr("TRUST_MODE", "false")),
|
|
133
|
+
securityMode: readOr("SECURITY_MODE", "off"),
|
|
134
|
+
enableDashboard: parseBool(readOr("ENABLE_DASHBOARD", "false")),
|
|
135
|
+
enableAgentApi: parseBool(readOr("ENABLE_AGENT_API", "false")),
|
|
136
|
+
enableAsyncDelegation: parseBool(readOr("ENABLE_ASYNC_DELEGATION", "false")),
|
|
137
|
+
maxSessions: parseIntSafe(readOr("MAX_SESSIONS", "10"), "MAX_SESSIONS"),
|
|
138
|
+
maxAgentCallPerHour: parseIntSafe(readOr("MAX_AGENT_CALL_PER_HOUR", "30"), "MAX_AGENT_CALL_PER_HOUR"),
|
|
139
|
+
maxAgentCallPerDay: parseIntSafe(readOr("MAX_AGENT_CALL_PER_DAY", "100"), "MAX_AGENT_CALL_PER_DAY"),
|
|
140
|
+
getApiKey(envName) {
|
|
141
|
+
return process.env[envName]?.trim() || void 0;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
let overrideCount = 0;
|
|
145
|
+
for (const def of SCHEMA) {
|
|
146
|
+
if (def.default !== void 0 && read(def.env) !== void 0) overrideCount++;
|
|
147
|
+
}
|
|
148
|
+
for (const w of warnings) logWarn("env", w);
|
|
149
|
+
logInfo("env", `${SCHEMA.length} vars loaded, ${overrideCount} overridden, ${warnings.length} warnings`);
|
|
150
|
+
_env = Object.freeze(env);
|
|
151
|
+
return _env;
|
|
152
|
+
}
|
|
153
|
+
function _resetEnv() {
|
|
154
|
+
_env = null;
|
|
155
|
+
}
|
|
156
|
+
function findClosest(input, known) {
|
|
157
|
+
let best;
|
|
158
|
+
let bestDist = 4;
|
|
159
|
+
for (const k of known) {
|
|
160
|
+
const d = levenshtein(input, k);
|
|
161
|
+
if (d < bestDist) {
|
|
162
|
+
bestDist = d;
|
|
163
|
+
best = k;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return best;
|
|
167
|
+
}
|
|
168
|
+
function levenshtein(a, b) {
|
|
169
|
+
if (a.length === 0) return b.length;
|
|
170
|
+
if (b.length === 0) return a.length;
|
|
171
|
+
const matrix = [];
|
|
172
|
+
for (let i = 0; i <= b.length; i++) matrix[i] = [i];
|
|
173
|
+
for (let j = 0; j <= a.length; j++) matrix[0][j] = j;
|
|
174
|
+
for (let i = 1; i <= b.length; i++) {
|
|
175
|
+
for (let j = 1; j <= a.length; j++) {
|
|
176
|
+
const cost = b[i - 1] === a[j - 1] ? 0 : 1;
|
|
177
|
+
matrix[i][j] = Math.min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j - 1] + cost);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return matrix[b.length][a.length];
|
|
181
|
+
}
|
|
182
|
+
var SCHEMA, _env;
|
|
183
|
+
var init_env_schema = __esm({
|
|
184
|
+
"src/components/env-schema.ts"() {
|
|
185
|
+
init_logger();
|
|
186
|
+
SCHEMA = [
|
|
187
|
+
// ── Core ──
|
|
188
|
+
{ env: "ABTARS_HOME", type: "string", description: "Base directory for runtime data" },
|
|
189
|
+
{ env: "WORKING_DIR", type: "string", default: "~/.abtars/workspace", description: "Agent working directory (sandbox)" },
|
|
190
|
+
{ env: "MAIN_CHAT_ID", type: "string", description: "Primary chat ID for operator notifications" },
|
|
191
|
+
{ env: "MAIN_CHAT_PROVIDER", type: "string", default: "telegram", description: "Platform for MAIN_CHAT_ID: telegram | discord" },
|
|
192
|
+
{ env: "LOG_LEVEL", type: "string", default: "low", description: "Log level: off, low, debug" },
|
|
193
|
+
{ env: "LOG_FORMAT", type: "string", default: "text", description: "Log format: text or json" },
|
|
194
|
+
// ── Transport ──
|
|
195
|
+
{ env: "AGENT_CLI_PATH", type: "string", description: "Override path to agent CLI binary" },
|
|
196
|
+
{ env: "API_KEY", type: "string", description: "Default API key fallback (prefer per-provider keys)" },
|
|
197
|
+
{ env: "TMUX_SESSION", type: "string", default: "kiro", description: "Tmux session name" },
|
|
198
|
+
{ env: "DEFAULT_TRANSPORT", type: "string", default: "api", description: "Default transport type" },
|
|
199
|
+
{ env: "TRANSPORT_CONFIG", type: "string", default: "transport.json", description: "Transport config filename" },
|
|
200
|
+
{ env: "MODELS_CONFIG", type: "string", default: "models.json", description: "Models config filename" },
|
|
201
|
+
// ── Transport timeouts ──
|
|
202
|
+
{ env: "PROMPT_TIMEOUT_SEC", type: "int", default: "180", description: "ACP prompt timeout (seconds)" },
|
|
203
|
+
{ env: "MODEL_API_TIMEOUT_SEC", type: "int", default: "120", description: "Direct API model timeout (seconds)" },
|
|
204
|
+
{ env: "WATCHDOG_TOOL_TIMEOUT_SEC", type: "int", default: "180", description: "Watchdog tool call timeout (seconds)" },
|
|
205
|
+
{ env: "WATCHDOG_SILENT_SEC", type: "int", default: "300", description: "Watchdog silent timeout (seconds)" },
|
|
206
|
+
{ env: "WATCHDOG_ENDLESS_SEC", type: "int", default: "600", description: "Watchdog endless loop timeout (seconds)" },
|
|
207
|
+
// ── Telegram ──
|
|
208
|
+
{ env: "TELEGRAM_BOT_TOKEN", type: "string", description: "Telegram bot token" },
|
|
209
|
+
{ env: "TELEGRAM_TIMEOUT_SEC", type: "int", default: "10", description: "Telegram API timeout (seconds)" },
|
|
210
|
+
{ env: "TELEGRAM_FILE_TIMEOUT_SEC", type: "int", default: "60", description: "Telegram file up/download timeout (seconds)" },
|
|
211
|
+
{ env: "POLL_TIMEOUT_S", type: "int", default: "30", description: "Telegram long-poll timeout (seconds)" },
|
|
212
|
+
// ── Discord ──
|
|
213
|
+
{ env: "DISCORD_BOT_TOKEN", type: "string", description: "Discord bot token" },
|
|
214
|
+
{ env: "DISCORD_APP_ID", type: "string", description: "Discord application ID" },
|
|
215
|
+
{ env: "DISCORD_GROUP_MENTIONS", type: "string", default: "required", description: "Group mention mode: required (need @mention) | optional (bot listens to all, decides itself)" },
|
|
216
|
+
// ── Context window ──
|
|
217
|
+
{ env: "CTX_WARN_PCT", type: "int", default: "70", description: "Context % to warn user" },
|
|
218
|
+
{ env: "CTX_COMPACT_PCT", type: "int", default: "80", description: "Context % to auto-compact" },
|
|
219
|
+
{ env: "CTX_AGGRESSIVE_PCT", type: "int", default: "90", description: "Context % for aggressive compaction" },
|
|
220
|
+
{ env: "CTX_IDLE_COMPACT_PCT", type: "int", default: "65", description: "Context % for idle compaction" },
|
|
221
|
+
{ env: "CTX_IDLE_COMPACT_MIN", type: "int", default: "10", description: "Minutes idle before floating compaction" },
|
|
222
|
+
// ── Typing / streaming ──
|
|
223
|
+
{ env: "TYPING_TTL_SEC", type: "int", default: "300", description: "Typing indicator TTL (seconds)" },
|
|
224
|
+
{ env: "TYPING_SILENT_THRESHOLD_SEC", type: "int", default: "90", description: "Silent threshold before still-working msg (seconds)" },
|
|
225
|
+
{ env: "STREAM_FLUSH_SEC", type: "int", default: "3", description: "Stream edit flush interval (seconds, 0=disabled)" },
|
|
226
|
+
// ── Memory ──
|
|
227
|
+
{ env: "ACTIVE_MEMORY", type: "bool", default: "true", description: "Enable ambient recall on every turn" },
|
|
228
|
+
{ env: "PRIMING_MODEL_TOPICS", type: "bool", default: "true", description: "Use model-generated topics for priming" },
|
|
229
|
+
// ── ABM-L rendering (abmind, read by abmind directly) ──
|
|
230
|
+
{ env: "ABML_VERSION", type: "string", default: "plain", description: "ABM-L codec: plain | v0 | v1" },
|
|
231
|
+
{ env: "ABML_MIN_CHARS", type: "int", default: "100", description: "Min chars before ABM-L compression kicks in (v0)" },
|
|
232
|
+
// ── Three-tier context assembly (#348, abmind) ──
|
|
233
|
+
{ env: "CONTEXT_TIER_ENABLED", type: "bool", default: "true", description: "Enable three-tier context assembly (#348)" },
|
|
234
|
+
{ env: "CONTEXT_TIER_TAIL", type: "int", default: "20", description: "Last N turns kept verbatim (#348 tail)" },
|
|
235
|
+
{ env: "CONTEXT_TIER_MIDDLE", type: "int", default: "50", description: "Next M turns rendered as ABM-L (#348 middle)" },
|
|
236
|
+
{ env: "COMPACTION_LLM_ENABLED", type: "bool", default: "false", description: "LLM refinement for middle-tier rendering (#348 Phase 2)" },
|
|
237
|
+
// ── Sleep ──
|
|
238
|
+
{ env: "BED_TIME", type: "time", default: "0:30", description: "Daily sleep trigger time (H:MM or HH:MM)" },
|
|
239
|
+
{ env: "WAKE_TIME", type: "time", default: "7:00", description: "Wake time for platform detection" },
|
|
240
|
+
{ env: "BED_QUIET_MIN", type: "int", default: "7", description: "Quiet minutes before sleep (rounds up to nearest heartbeat cycle)" },
|
|
241
|
+
{ env: "HARDWARE_SLEEP_AFTER_DREAMY", type: "bool", default: "false", description: "Enable hardware sleep after Dreamy completes" },
|
|
242
|
+
{ env: "SLEEP_MODEL", type: "string", description: "Model override for Dreamy sleep agent" },
|
|
243
|
+
{ env: "SLEEP_QUALITY", type: "string", description: "Sleep quality override" },
|
|
244
|
+
// ── Voice ──
|
|
245
|
+
{ env: "STT_ENABLED", type: "bool", default: "false", description: "Enable speech-to-text" },
|
|
246
|
+
{ env: "STT_MODEL", type: "string", default: "whisper-large-v3-turbo", description: "STT model name" },
|
|
247
|
+
{ env: "TTS_ENABLED", type: "bool", default: "true", description: "Enable text-to-speech voice replies" },
|
|
248
|
+
{ env: "TTS_VOICE", type: "string", default: "alloy", description: "TTS voice name" },
|
|
249
|
+
// ── Self-healer ──
|
|
250
|
+
{ env: "SELFHEAL_ENABLED", type: "bool", default: "false", description: "Enable self-healer task" },
|
|
251
|
+
// ── Browser ──
|
|
252
|
+
{ env: "BROWSER_ENGINE", type: "string", default: "patchright", description: "Browser engine: patchright, chromium" },
|
|
253
|
+
{ env: "BROWSER_HEADED", type: "bool", default: "false", description: "Run browser in headed mode" },
|
|
254
|
+
{ env: "BROWSER_NO_SANDBOX", type: "bool", default: "false", description: "Disable browser sandbox" },
|
|
255
|
+
{ env: "BROWSER_CHANNEL", type: "string", description: "Browser channel (e.g. chrome)" },
|
|
256
|
+
{ env: "BROWSER_DOCKER", type: "bool", default: "false", description: "Use Docker for browser" },
|
|
257
|
+
{ env: "BROWSER_IDLE_STOP_MIN", type: "int", default: "10", description: "Minutes idle before stopping browser container" },
|
|
258
|
+
{ env: "BROWSER_ALLOWED_DOMAINS", type: "string", default: "", description: "Comma-separated allowed domains" },
|
|
259
|
+
{ env: "BROWSER_SOCKET_PATH", type: "string", default: "/run/browser/browser.sock", description: "Browser IPC socket path" },
|
|
260
|
+
{ env: "BROWSER_MAX_SESSIONS", type: "int", default: "3", description: "Max concurrent browser sessions" },
|
|
261
|
+
{ env: "BROWSER_SESSION_TIMEOUT_SEC", type: "int", default: "300", description: "Browser session timeout (seconds)" },
|
|
262
|
+
{ env: "WEB_SCRAPE_USER_AGENT", type: "string", description: "User agent for web scraping" },
|
|
263
|
+
{ env: "WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC", type: "int", default: "30", description: "Playwright page timeout (seconds)" },
|
|
264
|
+
{ env: "SSRF_CHECK", type: "bool", default: "true", description: "Enable SSRF protection for browser" },
|
|
265
|
+
{ env: "BROWSING_AGENT", type: "string", description: "Model override for browsing agent" },
|
|
266
|
+
// ── Misc ──
|
|
267
|
+
{ env: "DISABLED_CAPABILITIES", type: "string", default: "", description: "Comma-separated capabilities to disable" },
|
|
268
|
+
{ env: "CODING_MODEL", type: "string", description: "Model override for coding mode" },
|
|
269
|
+
{ env: "DASHBOARD_MODULE", type: "string", description: "Custom dashboard module path" },
|
|
270
|
+
{ env: "NOTEBOOKLM_ENABLED", type: "bool", default: "false", description: "Enable NotebookLM integration" },
|
|
271
|
+
{ env: "NOTEBOOKLM_DEFAULT_NOTEBOOK", type: "string", default: "", description: "Default NotebookLM notebook" },
|
|
272
|
+
{ env: "PERMISSION_TIMEOUT_SEC", type: "int", default: "60", description: "Permission prompt timeout (seconds)" },
|
|
273
|
+
{ env: "TRUST_MODE", type: "bool", default: "false", description: "Skip permission prompts" },
|
|
274
|
+
{ env: "SECURITY_MODE", type: "string", default: "off", description: "Security mode: off | guardrails | sandbox" },
|
|
275
|
+
{ env: "MAX_AGENT_CALL_PER_HOUR", type: "int", required: true, description: "Agent API rate limit: max requests per caller per hour" },
|
|
276
|
+
{ env: "MAX_AGENT_CALL_PER_DAY", type: "int", required: true, description: "Agent API rate limit: max requests per caller per day" },
|
|
277
|
+
{ env: "TELEGRAM_ENABLED", type: "bool", default: "", description: "Enable Telegram platform (fallback: token presence)" },
|
|
278
|
+
{ env: "DISCORD_ENABLED", type: "bool", default: "", description: "Enable Discord platform (fallback: token presence)" },
|
|
279
|
+
{ env: "IRC_ENABLED", type: "bool", default: "", description: "Enable IRC platform (fallback: irc.json presence)" },
|
|
280
|
+
{ env: "ENABLE_DASHBOARD", type: "bool", default: "false", description: "Enable web dashboard (exposes port)" },
|
|
281
|
+
{ env: "ENABLE_AGENT_API", type: "bool", default: "false", description: "Enable A2A agent API (exposes port)" },
|
|
282
|
+
{ env: "ENABLE_ASYNC_DELEGATION", type: "bool", default: "false", description: "Enable async session delegation tools (spawn/check/terminate)" },
|
|
283
|
+
{ env: "MAX_SESSIONS", type: "int", default: "10", description: "Max concurrent managed sessions per user" }
|
|
284
|
+
];
|
|
285
|
+
_env = null;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
export {
|
|
290
|
+
getEnv,
|
|
291
|
+
envDump,
|
|
292
|
+
initEnv,
|
|
293
|
+
_resetEnv,
|
|
294
|
+
init_env_schema
|
|
295
|
+
};
|
|
296
|
+
//# sourceMappingURL=chunk-JCJS4ZIB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/env-schema.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * env-schema.ts \u2014 Central env var schema. Single source of truth.\n * All env access goes through getEnv(). No process.env reads elsewhere.\n *\n * Usage:\n * import { getEnv } from \"./env-schema.js\";\n * const env = getEnv();\n * env.bedTime // \"0:30\"\n *\n * Boot:\n * import { initEnv } from \"./env-schema.js\";\n * initEnv(); // call once at boot, before anything reads config\n */\n\nimport { logInfo, logWarn } from \"./logger.js\";\n\n// \u2500\u2500 Schema definition \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ntype EnvType = \"string\" | \"int\" | \"bool\" | \"time\";\n\ninterface EnvVarDef {\n env: string;\n type: EnvType;\n default?: string;\n required?: boolean;\n description: string;\n}\n\n// All env vars in one place. Add new vars here, nowhere else.\nconst SCHEMA: readonly EnvVarDef[] = [\n // \u2500\u2500 Core \u2500\u2500\n { env: \"ABTARS_HOME\", type: \"string\", description: \"Base directory for runtime data\" },\n { env: \"WORKING_DIR\", type: \"string\", default: \"~/.abtars/workspace\", description: \"Agent working directory (sandbox)\" },\n { env: \"MAIN_CHAT_ID\", type: \"string\", description: \"Primary chat ID for operator notifications\" },\n { env: \"MAIN_CHAT_PROVIDER\", type: \"string\", default: \"telegram\", description: \"Platform for MAIN_CHAT_ID: telegram | discord\" },\n { env: \"LOG_LEVEL\", type: \"string\", default: \"low\", description: \"Log level: off, low, debug\" },\n { env: \"LOG_FORMAT\", type: \"string\", default: \"text\", description: \"Log format: text or json\" },\n\n // \u2500\u2500 Transport \u2500\u2500\n { env: \"AGENT_CLI_PATH\", type: \"string\", description: \"Override path to agent CLI binary\" },\n { env: \"API_KEY\", type: \"string\", description: \"Default API key fallback (prefer per-provider keys)\" },\n { env: \"TMUX_SESSION\", type: \"string\", default: \"kiro\", description: \"Tmux session name\" },\n { env: \"DEFAULT_TRANSPORT\", type: \"string\", default: \"api\", description: \"Default transport type\" },\n { env: \"TRANSPORT_CONFIG\", type: \"string\", default: \"transport.json\", description: \"Transport config filename\" },\n { env: \"MODELS_CONFIG\", type: \"string\", default: \"models.json\", description: \"Models config filename\" },\n\n // \u2500\u2500 Transport timeouts \u2500\u2500\n { env: \"PROMPT_TIMEOUT_SEC\", type: \"int\", default: \"180\", description: \"ACP prompt timeout (seconds)\" },\n { env: \"MODEL_API_TIMEOUT_SEC\", type: \"int\", default: \"120\", description: \"Direct API model timeout (seconds)\" },\n { env: \"WATCHDOG_TOOL_TIMEOUT_SEC\", type: \"int\", default: \"180\", description: \"Watchdog tool call timeout (seconds)\" },\n { env: \"WATCHDOG_SILENT_SEC\", type: \"int\", default: \"300\", description: \"Watchdog silent timeout (seconds)\" },\n { env: \"WATCHDOG_ENDLESS_SEC\", type: \"int\", default: \"600\", description: \"Watchdog endless loop timeout (seconds)\" },\n\n // \u2500\u2500 Telegram \u2500\u2500\n { env: \"TELEGRAM_BOT_TOKEN\", type: \"string\", description: \"Telegram bot token\" },\n { env: \"TELEGRAM_TIMEOUT_SEC\", type: \"int\", default: \"10\", description: \"Telegram API timeout (seconds)\" },\n { env: \"TELEGRAM_FILE_TIMEOUT_SEC\", type: \"int\", default: \"60\", description: \"Telegram file up/download timeout (seconds)\" },\n { env: \"POLL_TIMEOUT_S\", type: \"int\", default: \"30\", description: \"Telegram long-poll timeout (seconds)\" },\n\n // \u2500\u2500 Discord \u2500\u2500\n { env: \"DISCORD_BOT_TOKEN\", type: \"string\", description: \"Discord bot token\" },\n { env: \"DISCORD_APP_ID\", type: \"string\", description: \"Discord application ID\" },\n { env: \"DISCORD_GROUP_MENTIONS\", type: \"string\", default: \"required\", description: \"Group mention mode: required (need @mention) | optional (bot listens to all, decides itself)\" },\n\n // \u2500\u2500 Context window \u2500\u2500\n { env: \"CTX_WARN_PCT\", type: \"int\", default: \"70\", description: \"Context % to warn user\" },\n { env: \"CTX_COMPACT_PCT\", type: \"int\", default: \"80\", description: \"Context % to auto-compact\" },\n { env: \"CTX_AGGRESSIVE_PCT\", type: \"int\", default: \"90\", description: \"Context % for aggressive compaction\" },\n { env: \"CTX_IDLE_COMPACT_PCT\", type: \"int\", default: \"65\", description: \"Context % for idle compaction\" },\n { env: \"CTX_IDLE_COMPACT_MIN\", type: \"int\", default: \"10\", description: \"Minutes idle before floating compaction\" },\n\n // \u2500\u2500 Typing / streaming \u2500\u2500\n { env: \"TYPING_TTL_SEC\", type: \"int\", default: \"300\", description: \"Typing indicator TTL (seconds)\" },\n { env: \"TYPING_SILENT_THRESHOLD_SEC\", type: \"int\", default: \"90\", description: \"Silent threshold before still-working msg (seconds)\" },\n { env: \"STREAM_FLUSH_SEC\", type: \"int\", default: \"3\", description: \"Stream edit flush interval (seconds, 0=disabled)\" },\n\n // \u2500\u2500 Memory \u2500\u2500\n { env: \"ACTIVE_MEMORY\", type: \"bool\", default: \"true\", description: \"Enable ambient recall on every turn\" },\n { env: \"PRIMING_MODEL_TOPICS\", type: \"bool\", default: \"true\", description: \"Use model-generated topics for priming\" },\n\n // \u2500\u2500 ABM-L rendering (abmind, read by abmind directly) \u2500\u2500\n { env: \"ABML_VERSION\", type: \"string\", default: \"plain\", description: \"ABM-L codec: plain | v0 | v1\" },\n { env: \"ABML_MIN_CHARS\", type: \"int\", default: \"100\", description: \"Min chars before ABM-L compression kicks in (v0)\" },\n\n // \u2500\u2500 Three-tier context assembly (#348, abmind) \u2500\u2500\n { env: \"CONTEXT_TIER_ENABLED\", type: \"bool\", default: \"true\", description: \"Enable three-tier context assembly (#348)\" },\n { env: \"CONTEXT_TIER_TAIL\", type: \"int\", default: \"20\", description: \"Last N turns kept verbatim (#348 tail)\" },\n { env: \"CONTEXT_TIER_MIDDLE\", type: \"int\", default: \"50\", description: \"Next M turns rendered as ABM-L (#348 middle)\" },\n { env: \"COMPACTION_LLM_ENABLED\", type: \"bool\", default: \"false\", description: \"LLM refinement for middle-tier rendering (#348 Phase 2)\" },\n\n // \u2500\u2500 Sleep \u2500\u2500\n { env: \"BED_TIME\", type: \"time\", default: \"0:30\", description: \"Daily sleep trigger time (H:MM or HH:MM)\" },\n { env: \"WAKE_TIME\", type: \"time\", default: \"7:00\", description: \"Wake time for platform detection\" },\n { env: \"BED_QUIET_MIN\", type: \"int\", default: \"7\", description: \"Quiet minutes before sleep (rounds up to nearest heartbeat cycle)\" },\n { env: \"HARDWARE_SLEEP_AFTER_DREAMY\", type: \"bool\", default: \"false\", description: \"Enable hardware sleep after Dreamy completes\" },\n { env: \"SLEEP_MODEL\", type: \"string\", description: \"Model override for Dreamy sleep agent\" },\n { env: \"SLEEP_QUALITY\", type: \"string\", description: \"Sleep quality override\" },\n\n // \u2500\u2500 Voice \u2500\u2500\n { env: \"STT_ENABLED\", type: \"bool\", default: \"false\", description: \"Enable speech-to-text\" },\n { env: \"STT_MODEL\", type: \"string\", default: \"whisper-large-v3-turbo\", description: \"STT model name\" },\n { env: \"TTS_ENABLED\", type: \"bool\", default: \"true\", description: \"Enable text-to-speech voice replies\" },\n { env: \"TTS_VOICE\", type: \"string\", default: \"alloy\", description: \"TTS voice name\" },\n\n // \u2500\u2500 Self-healer \u2500\u2500\n { env: \"SELFHEAL_ENABLED\", type: \"bool\", default: \"false\", description: \"Enable self-healer task\" },\n\n // \u2500\u2500 Browser \u2500\u2500\n { env: \"BROWSER_ENGINE\", type: \"string\", default: \"patchright\", description: \"Browser engine: patchright, chromium\" },\n { env: \"BROWSER_HEADED\", type: \"bool\", default: \"false\", description: \"Run browser in headed mode\" },\n { env: \"BROWSER_NO_SANDBOX\", type: \"bool\", default: \"false\", description: \"Disable browser sandbox\" },\n { env: \"BROWSER_CHANNEL\", type: \"string\", description: \"Browser channel (e.g. chrome)\" },\n { env: \"BROWSER_DOCKER\", type: \"bool\", default: \"false\", description: \"Use Docker for browser\" },\n { env: \"BROWSER_IDLE_STOP_MIN\", type: \"int\", default: \"10\", description: \"Minutes idle before stopping browser container\" },\n { env: \"BROWSER_ALLOWED_DOMAINS\", type: \"string\", default: \"\", description: \"Comma-separated allowed domains\" },\n { env: \"BROWSER_SOCKET_PATH\", type: \"string\", default: \"/run/browser/browser.sock\", description: \"Browser IPC socket path\" },\n { env: \"BROWSER_MAX_SESSIONS\", type: \"int\", default: \"3\", description: \"Max concurrent browser sessions\" },\n { env: \"BROWSER_SESSION_TIMEOUT_SEC\", type: \"int\", default: \"300\", description: \"Browser session timeout (seconds)\" },\n { env: \"WEB_SCRAPE_USER_AGENT\", type: \"string\", description: \"User agent for web scraping\" },\n { env: \"WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC\", type: \"int\", default: \"30\", description: \"Playwright page timeout (seconds)\" },\n { env: \"SSRF_CHECK\", type: \"bool\", default: \"true\", description: \"Enable SSRF protection for browser\" },\n { env: \"BROWSING_AGENT\", type: \"string\", description: \"Model override for browsing agent\" },\n\n // \u2500\u2500 Misc \u2500\u2500\n { env: \"DISABLED_CAPABILITIES\", type: \"string\", default: \"\", description: \"Comma-separated capabilities to disable\" },\n { env: \"CODING_MODEL\", type: \"string\", description: \"Model override for coding mode\" },\n { env: \"DASHBOARD_MODULE\", type: \"string\", description: \"Custom dashboard module path\" },\n { env: \"NOTEBOOKLM_ENABLED\", type: \"bool\", default: \"false\", description: \"Enable NotebookLM integration\" },\n { env: \"NOTEBOOKLM_DEFAULT_NOTEBOOK\", type: \"string\", default: \"\", description: \"Default NotebookLM notebook\" },\n { env: \"PERMISSION_TIMEOUT_SEC\", type: \"int\", default: \"60\", description: \"Permission prompt timeout (seconds)\" },\n { env: \"TRUST_MODE\", type: \"bool\", default: \"false\", description: \"Skip permission prompts\" },\n { env: \"SECURITY_MODE\", type: \"string\", default: \"off\", description: \"Security mode: off | guardrails | sandbox\" },\n { env: \"MAX_AGENT_CALL_PER_HOUR\", type: \"int\", required: true, description: \"Agent API rate limit: max requests per caller per hour\" },\n { env: \"MAX_AGENT_CALL_PER_DAY\", type: \"int\", required: true, description: \"Agent API rate limit: max requests per caller per day\" },\n { env: \"TELEGRAM_ENABLED\", type: \"bool\", default: \"\", description: \"Enable Telegram platform (fallback: token presence)\" },\n { env: \"DISCORD_ENABLED\", type: \"bool\", default: \"\", description: \"Enable Discord platform (fallback: token presence)\" },\n { env: \"IRC_ENABLED\", type: \"bool\", default: \"\", description: \"Enable IRC platform (fallback: irc.json presence)\" },\n { env: \"ENABLE_DASHBOARD\", type: \"bool\", default: \"false\", description: \"Enable web dashboard (exposes port)\" },\n { env: \"ENABLE_AGENT_API\", type: \"bool\", default: \"false\", description: \"Enable A2A agent API (exposes port)\" },\n { env: \"ENABLE_ASYNC_DELEGATION\", type: \"bool\", default: \"false\", description: \"Enable async session delegation tools (spawn/check/terminate)\" },\n { env: \"MAX_SESSIONS\", type: \"int\", default: \"10\", description: \"Max concurrent managed sessions per user\" },\n] as const;\n\n// \u2500\u2500 Parsed config type \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Parsed time value from \"H:MM\" or \"HH:MM\" format. */\nexport interface TimeValue { hour: number; minute: number; raw: string; }\n\nexport interface EnvConfig {\n // Core\n abtarsHome: string;\n workingDir: string;\n mainChatId: string | undefined;\n mainChatProvider: \"telegram\" | \"discord\";\n logLevel: string;\n logFormat: \"text\" | \"json\";\n\n // Transport\n agentCliPath: string | undefined;\n apiKey: string | undefined;\n tmuxSession: string;\n defaultTransport: string;\n transportConfig: string;\n modelsConfig: string;\n\n // Transport timeouts\n promptTimeoutSec: number;\n modelApiTimeoutMs: number;\n watchdogToolTimeoutSec: number;\n watchdogSilentSec: number;\n watchdogEndlessSec: number;\n\n // Telegram\n telegramBotToken: string | undefined;\n telegramTimeoutMs: number;\n telegramFileTimeoutMs: number;\n pollTimeoutS: number;\n\n // Discord\n discordBotToken: string | undefined;\n discordAppId: string | undefined;\n discordGroupMentions: string;\n\n // Context window\n ctxWarnPct: number;\n ctxCompactPct: number;\n ctxAggressivePct: number;\n ctxIdleCompactPct: number;\n ctxIdleCompactMin: number;\n\n // Typing / streaming\n typingTtlMs: number;\n typingSilentThresholdMs: number;\n streamFlushSec: number;\n\n // Memory\n activeMemory: boolean;\n primingModelTopics: boolean;\n\n // Sleep\n bedTime: TimeValue;\n wakeTime: TimeValue;\n bedQuietMin: number;\n hardwareSleepAfterDreamy: boolean;\n sleepModel: string | undefined;\n sleepQuality: string | undefined;\n\n // Voice\n sttEnabled: boolean;\n sttModel: string;\n ttsEnabled: boolean;\n ttsVoice: string;\n\n // Self-healer\n selfhealEnabled: boolean;\n\n // Browser\n browserEngine: string;\n browserHeaded: boolean;\n browserNoSandbox: boolean;\n browserChannel: string | undefined;\n browserDocker: boolean;\n browserIdleStopMin: number;\n browserAllowedDomains: string;\n browserSocketPath: string;\n browserMaxSessions: number;\n browserSessionTimeoutMs: number;\n webScrapeUserAgent: string | undefined;\n webScrapePlaywrightTimeoutMs: number;\n ssrfCheck: boolean;\n browsingAgent: string | undefined;\n\n // Misc\n disabledCapabilities: string;\n codingModel: string | undefined;\n dashboardModule: string | undefined;\n notebooklmEnabled: boolean;\n notebooklmDefaultNotebook: string;\n permissionTimeoutMs: number;\n trustMode: boolean;\n securityMode: string;\n enableDashboard: boolean;\n enableAgentApi: boolean;\n enableAsyncDelegation: boolean;\n maxSessions: number;\n maxAgentCallPerHour: number;\n maxAgentCallPerDay: number;\n\n /** Dynamic API key lookup \u2014 for provider.apiKeyEnv pattern. */\n getApiKey(envName: string): string | undefined;\n}\n\n// \u2500\u2500 Parsing helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction parseTime(raw: string, varName: string): TimeValue {\n const parts = raw.split(\":\");\n const hour = parseInt(parts[0] ?? \"\", 10);\n const minute = parseInt(parts[1] ?? \"0\", 10);\n if (isNaN(hour) || isNaN(minute) || hour < 0 || hour > 23 || minute < 0 || minute > 59) {\n throw new Error(`Invalid ${varName}: \"${raw}\" \u2014 expected H:MM or HH:MM (e.g. \"0:30\", \"14:00\")`);\n }\n return { hour, minute, raw };\n}\n\nfunction parseIntSafe(raw: string, varName: string): number {\n const n = parseInt(raw, 10);\n if (isNaN(n)) throw new Error(`Invalid ${varName}: \"${raw}\" \u2014 expected integer`);\n return n;\n}\n\nfunction parseBool(raw: string): boolean {\n return raw.toLowerCase() === \"true\" || raw === \"1\";\n}\n\n// \u2500\u2500 Singleton \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nlet _env: Readonly<EnvConfig> | null = null;\n\n/** Get the parsed env config. Auto-initializes on first call if needed. */\nexport function getEnv(): Readonly<EnvConfig> {\n if (!_env) initEnv();\n return _env!;\n}\n\n/** Sanitized config dump \u2014 masks API keys/tokens, shows everything else. For /status. */\nexport function envDump(): Record<string, string> {\n const env = getEnv();\n const result: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === \"function\") continue;\n const strVal = value == null ? \"(not set)\" : String(value);\n // Mask anything that looks like a secret\n if (/token|key|secret|password/i.test(key) && strVal.length > 4) {\n result[key] = strVal.slice(0, 4) + \"\u2026\" + strVal.slice(-2);\n } else {\n result[key] = strVal;\n }\n }\n return result;\n}\n\n/** Initialize env config from process.env. Call once at boot. */\nexport function initEnv(): Readonly<EnvConfig> {\n const knownVars = new Set(SCHEMA.map(s => s.env));\n const warnings: string[] = [];\n\n // Detect typos: only warn if an unknown var is close (Levenshtein \u2264 3) to a known abtars var.\n // System vars (QT_*, POWERSHELL_*, etc.) are far from any known var \u2192 silently ignored.\n const envKeys = Object.keys(process.env).filter(k => /^[A-Z_]+$/.test(k));\n for (const k of envKeys) {\n if (knownVars.has(k)) continue;\n // Allow *_API_KEY pattern (provider keys referenced dynamically by transport.json)\n if (k.endsWith(\"_API_KEY\") || k.endsWith(\"_API_ID\")) continue;\n // Allow HA_* (Home Assistant, loaded from .env.skills)\n if (k.startsWith(\"HA_\")) continue;\n const suggestion = findClosest(k, knownVars);\n if (suggestion) {\n warnings.push(`Unknown env var ${k} \u2014 did you mean ${suggestion}?`);\n }\n }\n\n function read(envName: string): string | undefined {\n return process.env[envName]?.trim() || undefined;\n }\n\n function readOr(envName: string, fallback: string): string {\n return read(envName) ?? fallback;\n }\n\n const env: EnvConfig = {\n abtarsHome: readOr(\"ABTARS_HOME\", \"\"),\n workingDir: readOr(\"WORKING_DIR\", \".\"),\n mainChatId: read(\"MAIN_CHAT_ID\"),\n mainChatProvider: (read(\"MAIN_CHAT_PROVIDER\") ?? \"telegram\") === \"discord\" ? \"discord\" : \"telegram\",\n logLevel: readOr(\"LOG_LEVEL\", \"low\").toLowerCase(),\n logFormat: readOr(\"LOG_FORMAT\", \"text\") === \"json\" ? \"json\" : \"text\",\n\n agentCliPath: read(\"AGENT_CLI_PATH\"),\n apiKey: read(\"API_KEY\"),\n tmuxSession: readOr(\"TMUX_SESSION\", \"kiro\"),\n defaultTransport: readOr(\"DEFAULT_TRANSPORT\", \"api\"),\n transportConfig: readOr(\"TRANSPORT_CONFIG\", \"transport.json\").replace(\"config/\", \"\"),\n modelsConfig: readOr(\"MODELS_CONFIG\", \"models.json\").replace(\"config/\", \"\"),\n\n promptTimeoutSec: parseIntSafe(readOr(\"PROMPT_TIMEOUT_SEC\", \"180\"), \"PROMPT_TIMEOUT_SEC\"),\n modelApiTimeoutMs: parseIntSafe(readOr(\"MODEL_API_TIMEOUT_SEC\", \"120\"), \"MODEL_API_TIMEOUT_SEC\") * 1000,\n watchdogToolTimeoutSec: parseIntSafe(readOr(\"WATCHDOG_TOOL_TIMEOUT_SEC\", \"180\"), \"WATCHDOG_TOOL_TIMEOUT_SEC\"),\n watchdogSilentSec: parseIntSafe(readOr(\"WATCHDOG_SILENT_SEC\", \"300\"), \"WATCHDOG_SILENT_SEC\"),\n watchdogEndlessSec: parseIntSafe(readOr(\"WATCHDOG_ENDLESS_SEC\", \"600\"), \"WATCHDOG_ENDLESS_SEC\"),\n\n telegramBotToken: read(\"TELEGRAM_BOT_TOKEN\"),\n telegramTimeoutMs: parseIntSafe(readOr(\"TELEGRAM_TIMEOUT_SEC\", \"10\"), \"TELEGRAM_TIMEOUT_SEC\") * 1000,\n telegramFileTimeoutMs: parseIntSafe(readOr(\"TELEGRAM_FILE_TIMEOUT_SEC\", \"60\"), \"TELEGRAM_FILE_TIMEOUT_SEC\") * 1000,\n pollTimeoutS: parseIntSafe(readOr(\"POLL_TIMEOUT_S\", \"30\"), \"POLL_TIMEOUT_S\"),\n\n discordBotToken: read(\"DISCORD_BOT_TOKEN\"),\n discordAppId: read(\"DISCORD_APP_ID\"),\n discordGroupMentions: readOr(\"DISCORD_GROUP_MENTIONS\", \"required\"),\n\n ctxWarnPct: parseIntSafe(readOr(\"CTX_WARN_PCT\", \"70\"), \"CTX_WARN_PCT\"),\n ctxCompactPct: parseIntSafe(readOr(\"CTX_COMPACT_PCT\", \"80\"), \"CTX_COMPACT_PCT\"),\n ctxAggressivePct: parseIntSafe(readOr(\"CTX_AGGRESSIVE_PCT\", \"90\"), \"CTX_AGGRESSIVE_PCT\"),\n ctxIdleCompactPct: parseIntSafe(readOr(\"CTX_IDLE_COMPACT_PCT\", \"65\"), \"CTX_IDLE_COMPACT_PCT\"),\n ctxIdleCompactMin: parseIntSafe(readOr(\"CTX_IDLE_COMPACT_MIN\", \"10\"), \"CTX_IDLE_COMPACT_MIN\"),\n\n typingTtlMs: parseIntSafe(readOr(\"TYPING_TTL_SEC\", \"300\"), \"TYPING_TTL_SEC\") * 1000,\n typingSilentThresholdMs: parseIntSafe(readOr(\"TYPING_SILENT_THRESHOLD_SEC\", \"90\"), \"TYPING_SILENT_THRESHOLD_SEC\") * 1000,\n streamFlushSec: parseIntSafe(readOr(\"STREAM_FLUSH_SEC\", \"3\"), \"STREAM_FLUSH_SEC\"),\n\n activeMemory: parseBool(readOr(\"ACTIVE_MEMORY\", \"true\")),\n primingModelTopics: read(\"PRIMING_MODEL_TOPICS\") !== \"false\",\n\n bedTime: parseTime(readOr(\"BED_TIME\", \"0:30\"), \"BED_TIME\"),\n wakeTime: parseTime(readOr(\"WAKE_TIME\", \"7:00\"), \"WAKE_TIME\"),\n bedQuietMin: parseIntSafe(readOr(\"BED_QUIET_MIN\", \"7\"), \"BED_QUIET_MIN\"),\n hardwareSleepAfterDreamy: parseBool(readOr(\"HARDWARE_SLEEP_AFTER_DREAMY\", \"false\")),\n sleepModel: read(\"SLEEP_MODEL\"),\n sleepQuality: read(\"SLEEP_QUALITY\"),\n\n sttEnabled: parseBool(readOr(\"STT_ENABLED\", \"false\")),\n sttModel: readOr(\"STT_MODEL\", \"whisper-large-v3-turbo\"),\n ttsEnabled: parseBool(readOr(\"TTS_ENABLED\", \"false\")),\n ttsVoice: readOr(\"TTS_VOICE\", \"alloy\"),\n\n selfhealEnabled: parseBool(readOr(\"SELFHEAL_ENABLED\", \"false\")),\n\n browserEngine: readOr(\"BROWSER_ENGINE\", \"patchright\"),\n browserHeaded: parseBool(readOr(\"BROWSER_HEADED\", \"false\")),\n browserNoSandbox: parseBool(readOr(\"BROWSER_NO_SANDBOX\", \"false\")),\n browserChannel: read(\"BROWSER_CHANNEL\"),\n browserDocker: parseBool(readOr(\"BROWSER_DOCKER\", \"false\")),\n browserIdleStopMin: parseIntSafe(readOr(\"BROWSER_IDLE_STOP_MIN\", \"10\"), \"BROWSER_IDLE_STOP_MIN\"),\n browserAllowedDomains: readOr(\"BROWSER_ALLOWED_DOMAINS\", \"\"),\n browserSocketPath: readOr(\"BROWSER_SOCKET_PATH\", \"/run/browser/browser.sock\"),\n browserMaxSessions: parseIntSafe(readOr(\"BROWSER_MAX_SESSIONS\", \"3\"), \"BROWSER_MAX_SESSIONS\"),\n browserSessionTimeoutMs: parseIntSafe(readOr(\"BROWSER_SESSION_TIMEOUT_SEC\", \"300\"), \"BROWSER_SESSION_TIMEOUT_SEC\") * 1000,\n webScrapeUserAgent: read(\"WEB_SCRAPE_USER_AGENT\"),\n webScrapePlaywrightTimeoutMs: parseIntSafe(readOr(\"WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC\", \"30\"), \"WEB_SCRAPE_PLAYWRIGHT_TIMEOUT_SEC\") * 1000,\n ssrfCheck: read(\"SSRF_CHECK\") !== \"0\",\n browsingAgent: read(\"BROWSING_AGENT\"),\n\n disabledCapabilities: readOr(\"DISABLED_CAPABILITIES\", \"\"),\n codingModel: read(\"CODING_MODEL\"),\n dashboardModule: read(\"DASHBOARD_MODULE\"),\n notebooklmEnabled: parseBool(readOr(\"NOTEBOOKLM_ENABLED\", \"false\")),\n notebooklmDefaultNotebook: readOr(\"NOTEBOOKLM_DEFAULT_NOTEBOOK\", \"\"),\n permissionTimeoutMs: parseIntSafe(readOr(\"PERMISSION_TIMEOUT_SEC\", \"60\"), \"PERMISSION_TIMEOUT_SEC\") * 1000,\n trustMode: parseBool(readOr(\"TRUST_MODE\", \"false\")),\n securityMode: readOr(\"SECURITY_MODE\", \"off\"),\n enableDashboard: parseBool(readOr(\"ENABLE_DASHBOARD\", \"false\")),\n enableAgentApi: parseBool(readOr(\"ENABLE_AGENT_API\", \"false\")),\n enableAsyncDelegation: parseBool(readOr(\"ENABLE_ASYNC_DELEGATION\", \"false\")),\n maxSessions: parseIntSafe(readOr(\"MAX_SESSIONS\", \"10\"), \"MAX_SESSIONS\"),\n maxAgentCallPerHour: parseIntSafe(readOr(\"MAX_AGENT_CALL_PER_HOUR\", \"30\"), \"MAX_AGENT_CALL_PER_HOUR\"),\n maxAgentCallPerDay: parseIntSafe(readOr(\"MAX_AGENT_CALL_PER_DAY\", \"100\"), \"MAX_AGENT_CALL_PER_DAY\"),\n\n getApiKey(envName: string): string | undefined {\n return process.env[envName]?.trim() || undefined;\n },\n };\n\n // Count overrides\n let overrideCount = 0;\n for (const def of SCHEMA) {\n if (def.default !== undefined && read(def.env) !== undefined) overrideCount++;\n }\n\n for (const w of warnings) logWarn(\"env\", w);\n logInfo(\"env\", `${SCHEMA.length} vars loaded, ${overrideCount} overridden, ${warnings.length} warnings`);\n\n _env = Object.freeze(env);\n return _env;\n}\n\n/** Reset singleton (for tests only). */\nexport function _resetEnv(): void { _env = null; }\n\n// \u2500\u2500 Typo detection helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Find closest known var name (Levenshtein distance \u2264 3). */\nfunction findClosest(input: string, known: Set<string>): string | undefined {\n let best: string | undefined;\n let bestDist = 4; // threshold\n for (const k of known) {\n const d = levenshtein(input, k);\n if (d < bestDist) { bestDist = d; best = k; }\n }\n return best;\n}\n\nfunction levenshtein(a: string, b: string): number {\n if (a.length === 0) return b.length;\n if (b.length === 0) return a.length;\n const matrix: number[][] = [];\n for (let i = 0; i <= b.length; i++) matrix[i] = [i];\n for (let j = 0; j <= a.length; j++) matrix[0]![j] = j;\n for (let i = 1; i <= b.length; i++) {\n for (let j = 1; j <= a.length; j++) {\n const cost = b[i - 1] === a[j - 1] ? 0 : 1;\n matrix[i]![j] = Math.min(matrix[i - 1]![j]! + 1, matrix[i]![j - 1]! + 1, matrix[i - 1]![j - 1]! + cost);\n }\n }\n return matrix[b.length]![a.length]!;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AA8PA,SAAS,UAAU,KAAa,SAA4B;AAC1D,QAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,QAAM,OAAO,SAAS,MAAM,CAAC,KAAK,IAAI,EAAE;AACxC,QAAM,SAAS,SAAS,MAAM,CAAC,KAAK,KAAK,EAAE;AAC3C,MAAI,MAAM,IAAI,KAAK,MAAM,M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AS,SAAS,aAAa,sCAAsC;AAAA,MAC9G,EAAE,KAAK,2BAA2B,MAAM,QAAQ,SAAS,SAAS,aAAa,gEAAgE;AAAA,MAC/I,EAAE,KAAK,gBAAgB,MAAM,OAAO,SAAS,MAAM,aAAa,2CAA2C;AAAA,IAC7G;AAuIA,IAAI,OAAmC;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createRequire as __bundleCreateRequire } from 'node:module'; import { fileURLToPath as __bundleFileURLToPath } from 'node:url'; import { dirname as __bundleDirname } from 'node:path'; const require = __bundleCreateRequire(import.meta.url); const __chunk_filename = __bundleFileURLToPath(import.meta.url); const __chunk_dirname = __bundleDirname(__chunk_filename);
|
|
2
|
+
import {
|
|
3
|
+
init_log_and_swallow,
|
|
4
|
+
logAndSwallow
|
|
5
|
+
} from "./chunk-FMWKEPM7.js";
|
|
6
|
+
import {
|
|
7
|
+
init_logger,
|
|
8
|
+
logInfo,
|
|
9
|
+
logWarn
|
|
10
|
+
} from "./chunk-BUUVFUPO.js";
|
|
11
|
+
|
|
12
|
+
// src/components/subagent-runtime.ts
|
|
13
|
+
init_log_and_swallow();
|
|
14
|
+
init_logger();
|
|
15
|
+
import { randomBytes } from "node:crypto";
|
|
16
|
+
var TAG = "runtime";
|
|
17
|
+
var DEFAULT_SESSION = {
|
|
18
|
+
professor: "reuse",
|
|
19
|
+
dreamy: "fresh",
|
|
20
|
+
browsie: "fresh",
|
|
21
|
+
coding: "reuse",
|
|
22
|
+
task: "fresh"
|
|
23
|
+
};
|
|
24
|
+
var DEFAULT_SPAWN_TIMEOUT_MS = 6e5;
|
|
25
|
+
var SubagentRuntime = class {
|
|
26
|
+
cache = /* @__PURE__ */ new Map();
|
|
27
|
+
activeSpawns = /* @__PURE__ */ new Map();
|
|
28
|
+
_registry = null;
|
|
29
|
+
_mainTransport = null;
|
|
30
|
+
_sessionManager = null;
|
|
31
|
+
/** Set shared model health registry (from boot ctx). */
|
|
32
|
+
setRegistry(registry) {
|
|
33
|
+
this._registry = registry;
|
|
34
|
+
}
|
|
35
|
+
/** Set main transport reference for currentModel reads. */
|
|
36
|
+
setMainTransport(transport) {
|
|
37
|
+
this._mainTransport = transport;
|
|
38
|
+
}
|
|
39
|
+
/** Set session manager for auto-spawn sub-session creation (#510). */
|
|
40
|
+
setSessionManager(mgr) {
|
|
41
|
+
this._sessionManager = mgr;
|
|
42
|
+
}
|
|
43
|
+
/** Send a prompt to a named agent and get the response. */
|
|
44
|
+
async complete(agent, prompt, opts) {
|
|
45
|
+
const sessionStrategy = opts?.session ?? DEFAULT_SESSION[agent] ?? "fresh";
|
|
46
|
+
const start = Date.now();
|
|
47
|
+
const cached = this.cache.get(agent);
|
|
48
|
+
if (cached && sessionStrategy === "fresh") {
|
|
49
|
+
await cached.transport.resetSession?.(cached.sessionKey);
|
|
50
|
+
(await import("./tool-registry-MU3OX4UI.js")).resetStoreCounter();
|
|
51
|
+
}
|
|
52
|
+
const { transport, model, sessionKey } = cached ?? await this.createAgent(agent);
|
|
53
|
+
if (opts?.timeoutMs && transport.setTimeoutOverride) {
|
|
54
|
+
transport.setTimeoutOverride(opts.timeoutMs);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const response = await transport.sendPrompt(sessionKey, prompt);
|
|
58
|
+
const elapsed = Date.now() - start;
|
|
59
|
+
logInfo(TAG, `${agent} complete: ${prompt.length}ch \u2192 ${response?.length ?? 0}ch (${elapsed}ms, ${model})`);
|
|
60
|
+
return response ?? "";
|
|
61
|
+
} catch (err) {
|
|
62
|
+
logWarn(TAG, `${agent} complete failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
63
|
+
this.cache.delete(agent);
|
|
64
|
+
throw err;
|
|
65
|
+
} finally {
|
|
66
|
+
if (opts?.timeoutMs && transport.setTimeoutOverride) {
|
|
67
|
+
transport.setTimeoutOverride(null);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Get a persistent session handle for multi-turn callers. */
|
|
72
|
+
async session(agent) {
|
|
73
|
+
const cached = this.cache.get(agent) ?? await this.createAgent(agent);
|
|
74
|
+
return {
|
|
75
|
+
sendPrompt: (sessionKey, prompt) => cached.transport.sendPrompt(sessionKey, prompt),
|
|
76
|
+
destroy: async () => {
|
|
77
|
+
try {
|
|
78
|
+
cached.transport.destroy();
|
|
79
|
+
} catch (err) {
|
|
80
|
+
logAndSwallow("subagent_runtime", "op", err);
|
|
81
|
+
}
|
|
82
|
+
this.cache.delete(agent);
|
|
83
|
+
logInfo(TAG, `${agent} session destroyed`);
|
|
84
|
+
},
|
|
85
|
+
get isReady() {
|
|
86
|
+
return cached.transport.isReady;
|
|
87
|
+
},
|
|
88
|
+
get transport() {
|
|
89
|
+
return cached.transport;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Fire-and-forget: run complete() in background, deliver result via callback. */
|
|
94
|
+
async spawn(agent, prompt, opts) {
|
|
95
|
+
const taskId = randomBytes(4).toString("hex");
|
|
96
|
+
const abort = new AbortController();
|
|
97
|
+
this.activeSpawns.set(taskId, { abort, startedAt: Date.now() });
|
|
98
|
+
if (this._sessionManager) {
|
|
99
|
+
const typeMap = { browsie: "B", coding: "C", task: "T" };
|
|
100
|
+
const sessionType = typeMap[agent];
|
|
101
|
+
if (sessionType) this._sessionManager.createSubSession("master", "telegram", sessionType);
|
|
102
|
+
}
|
|
103
|
+
const timeoutMs = opts?.timeoutMs ?? DEFAULT_SPAWN_TIMEOUT_MS;
|
|
104
|
+
const timer = setTimeout(() => abort.abort(), timeoutMs);
|
|
105
|
+
void (async () => {
|
|
106
|
+
try {
|
|
107
|
+
const result = await this.complete(agent, prompt);
|
|
108
|
+
if (!abort.signal.aborted) opts?.onComplete?.(taskId, result);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
if (!abort.signal.aborted) opts?.onError?.(taskId, err instanceof Error ? err : new Error(String(err)));
|
|
111
|
+
} finally {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
this.activeSpawns.delete(taskId);
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
116
|
+
logInfo(TAG, `${agent} spawned: taskId=${taskId}, timeout=${timeoutMs}ms`);
|
|
117
|
+
return { taskId };
|
|
118
|
+
}
|
|
119
|
+
/** Shut down all cached transports and abort active spawns. */
|
|
120
|
+
async shutdown() {
|
|
121
|
+
for (const [id, { abort }] of this.activeSpawns) {
|
|
122
|
+
abort.abort();
|
|
123
|
+
logInfo(TAG, `spawn ${id} aborted`);
|
|
124
|
+
}
|
|
125
|
+
this.activeSpawns.clear();
|
|
126
|
+
for (const [name, cached] of this.cache) {
|
|
127
|
+
try {
|
|
128
|
+
cached.transport.destroy();
|
|
129
|
+
} catch (err) {
|
|
130
|
+
logAndSwallow("subagent_runtime", "op", err);
|
|
131
|
+
}
|
|
132
|
+
logInfo(TAG, `${name} transport closed`);
|
|
133
|
+
}
|
|
134
|
+
this.cache.clear();
|
|
135
|
+
}
|
|
136
|
+
/** Active registry: list running background spawns. */
|
|
137
|
+
listActive() {
|
|
138
|
+
return [...this.activeSpawns.entries()].map(([taskId, entry]) => ({
|
|
139
|
+
taskId,
|
|
140
|
+
startedAt: entry.startedAt ?? 0
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
/** Interrupt a specific spawn by taskId. Returns true if found. */
|
|
144
|
+
interruptSpawn(taskId) {
|
|
145
|
+
const entry = this.activeSpawns.get(taskId);
|
|
146
|
+
if (!entry) return false;
|
|
147
|
+
entry.abort.abort();
|
|
148
|
+
this.activeSpawns.delete(taskId);
|
|
149
|
+
logInfo(TAG, `spawn ${taskId} interrupted`);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
async createAgent(agent) {
|
|
153
|
+
const { createSubagentTransport } = await import("./agent-registry-LT4JNQH6.js");
|
|
154
|
+
const role = AGENT_TO_ROLE[agent];
|
|
155
|
+
const mainModel = this._mainTransport && "currentModel" in this._mainTransport ? this._mainTransport.currentModel : void 0;
|
|
156
|
+
const { transport, model } = await createSubagentTransport(role, this._registry ?? void 0, mainModel);
|
|
157
|
+
if (agent === "browsie" && "setSystemPrompt" in transport && typeof transport.setSystemPrompt === "function") {
|
|
158
|
+
transport.setSystemPrompt(BROWSE_SYSTEM_PROMPT);
|
|
159
|
+
}
|
|
160
|
+
const sessionKey = `system:${agent}`;
|
|
161
|
+
const entry = { transport, model, sessionKey };
|
|
162
|
+
this.cache.set(agent, entry);
|
|
163
|
+
(await import("./tool-registry-MU3OX4UI.js")).resetStoreCounter();
|
|
164
|
+
return entry;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var BROWSE_SYSTEM_PROMPT = `You are a web browsing assistant. You have two tools for web access:
|
|
168
|
+
|
|
169
|
+
1. **browser tool** (navigate, click, fill, extract_text, screenshot) \u2014 use for JS-heavy pages, rendered content, page interaction, login flows, or anything that needs a real browser.
|
|
170
|
+
2. **curl / execute_bash** \u2014 use for simple API calls, raw downloads, fetching headers, or static pages.
|
|
171
|
+
|
|
172
|
+
Prefer the browser tool when the page likely uses JavaScript rendering or requires interaction. Use curl when a simple HTTP request suffices.`;
|
|
173
|
+
var AGENT_TO_ROLE = {
|
|
174
|
+
professor: "task",
|
|
175
|
+
dreamy: "sleep",
|
|
176
|
+
browsie: "browse",
|
|
177
|
+
coding: "coding",
|
|
178
|
+
task: "task"
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export {
|
|
182
|
+
SubagentRuntime
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=chunk-JW6RU47G.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/subagent-runtime.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * SubagentRuntime \u2014 unified LLM access for all subagents.\n * Replaces manual createSubagentTransport() calls.\n * Caches transports per agent, handles session lifecycle + fallback.\n */\n\nimport { logAndSwallow } from \"./log-and-swallow.js\";\nimport type { IKiroTransport } from \"./transport/kiro-transport.js\";\nimport { logInfo, logWarn } from \"./logger.js\";\nimport { randomBytes } from \"node:crypto\";\n\nimport type { ModelHealthRegistry } from \"./transport/model-health-registry.js\";\n\nconst TAG = \"runtime\";\n\nexport type AgentName = \"professor\" | \"dreamy\" | \"browsie\" | \"coding\" | \"task\";\n\nexport interface AgentOpts {\n /** Override default session strategy for this call. */\n session?: \"fresh\" | \"reuse\";\n /** Context passed to tool executor (userId, metadata). */\n context?: Record<string, unknown>;\n /** Override model API timeout for this call (ms). */\n timeoutMs?: number;\n /** Override session type (default: derived from agent name). */\n sessionType?: import(\"./session-manager.js\").SessionType;\n}\n\n/** Persistent transport handle for multi-turn callers. */\nexport interface AgentSession {\n sendPrompt(sessionKey: string, prompt: string, image?: { mime: string; base64: string }): Promise<string>;\n destroy(): Promise<void>;\n readonly isReady: boolean;\n /** Underlying transport \u2014 used to set sandboxPolicy for peer sessions (#678). */\n readonly transport?: IKiroTransport;\n}\n\nexport interface SpawnResult {\n taskId: string;\n}\n\nexport interface SpawnOpts {\n onComplete?: (taskId: string, result: string) => void;\n onError?: (taskId: string, error: Error) => void;\n timeoutMs?: number;\n}\n\ninterface CachedAgent {\n transport: IKiroTransport;\n model: string;\n sessionKey: string;\n}\n\nconst DEFAULT_SESSION: Record<AgentName, \"fresh\" | \"reuse\"> = {\n professor: \"reuse\",\n dreamy: \"fresh\",\n browsie: \"fresh\",\n coding: \"reuse\",\n task: \"fresh\",\n};\n\nconst DEFAULT_SPAWN_TIMEOUT_MS = 600_000; // 10 min\n\nexport class SubagentRuntime {\n private readonly cache = new Map<AgentName, CachedAgent>();\n private readonly activeSpawns = new Map<string, { abort: AbortController; startedAt: number }>();\n private _registry: ModelHealthRegistry | null = null;\n private _mainTransport: IKiroTransport | null = null;\n private _sessionManager: import(\"./session-manager.js\").SessionManager | null = null;\n\n /** Set shared model health registry (from boot ctx). */\n setRegistry(registry: ModelHealthRegistry): void { this._registry = registry; }\n\n /** Set main transport reference for currentModel reads. */\n setMainTransport(transport: IKiroTransport): void { this._mainTransport = transport; }\n\n /** Set session manager for auto-spawn sub-session creation (#510). */\n setSessionManager(mgr: import(\"./session-manager.js\").SessionManager): void { this._sessionManager = mgr; }\n\n /** Send a prompt to a named agent and get the response. */\n async complete(agent: AgentName, prompt: string, opts?: AgentOpts): Promise<string> {\n const sessionStrategy = opts?.session ?? DEFAULT_SESSION[agent] ?? \"fresh\";\n const start = Date.now();\n\n const cached = this.cache.get(agent);\n if (cached && sessionStrategy === \"fresh\") {\n await cached.transport.resetSession?.(cached.sessionKey);\n (await import(\"./transport/tool-registry.js\")).resetStoreCounter();\n }\n\n const { transport, model, sessionKey } = cached ?? await this.createAgent(agent);\n\n // Per-call timeout override (e.g. dreamy sleep steps need longer than default)\n if (opts?.timeoutMs && transport.setTimeoutOverride) {\n transport.setTimeoutOverride(opts.timeoutMs);\n }\n\n try {\n const response = await transport.sendPrompt(sessionKey, prompt);\n const elapsed = Date.now() - start;\n logInfo(TAG, `${agent} complete: ${prompt.length}ch \u2192 ${response?.length ?? 0}ch (${elapsed}ms, ${model})`);\n return response ?? \"\";\n } catch (err) {\n logWarn(TAG, `${agent} complete failed: ${err instanceof Error ? err.message : String(err)}`);\n this.cache.delete(agent);\n throw err;\n } finally {\n if (opts?.timeoutMs && transport.setTimeoutOverride) {\n transport.setTimeoutOverride(null);\n }\n }\n }\n\n /** Get a persistent session handle for multi-turn callers. */\n async session(agent: AgentName): Promise<AgentSession> {\n const cached = this.cache.get(agent) ?? await this.createAgent(agent);\n return {\n sendPrompt: (sessionKey: string, prompt: string) => cached.transport.sendPrompt(sessionKey, prompt),\n destroy: async () => {\n try { cached.transport.destroy(); } catch (err) { logAndSwallow(\"subagent_runtime\", \"op\", err); }\n this.cache.delete(agent);\n logInfo(TAG, `${agent} session destroyed`);\n },\n get isReady() { return cached.transport.isReady; },\n get transport() { return cached.transport; },\n };\n }\n\n /** Fire-and-forget: run complete() in background, deliver result via callback. */\n async spawn(agent: AgentName, prompt: string, opts?: SpawnOpts): Promise<SpawnResult> {\n const taskId = randomBytes(4).toString(\"hex\");\n const abort = new AbortController();\n this.activeSpawns.set(taskId, { abort, startedAt: Date.now() });\n\n // Create sub-session for visibility in /session list (#510)\n if (this._sessionManager) {\n const typeMap: Partial<Record<AgentName, import(\"./session-manager.js\").SessionType>> = { browsie: \"B\", coding: \"C\", task: \"T\" };\n const sessionType = typeMap[agent];\n if (sessionType) this._sessionManager.createSubSession(\"master\", \"telegram\", sessionType);\n }\n\n const timeoutMs = opts?.timeoutMs ?? DEFAULT_SPAWN_TIMEOUT_MS;\n const timer = setTimeout(() => abort.abort(), timeoutMs);\n\n // Fire and forget \u2014 don't await\n void (async () => {\n try {\n const result = await this.complete(agent, prompt);\n if (!abort.signal.aborted) opts?.onComplete?.(taskId, result);\n } catch (err) {\n if (!abort.signal.aborted) opts?.onError?.(taskId, err instanceof Error ? err : new Error(String(err)));\n } finally {\n clearTimeout(timer);\n this.activeSpawns.delete(taskId);\n }\n })();\n\n logInfo(TAG, `${agent} spawned: taskId=${taskId}, timeout=${timeoutMs}ms`);\n return { taskId };\n }\n\n /** Shut down all cached transports and abort active spawns. */\n async shutdown(): Promise<void> {\n for (const [id, { abort }] of this.activeSpawns) {\n abort.abort();\n logInfo(TAG, `spawn ${id} aborted`);\n }\n this.activeSpawns.clear();\n\n for (const [name, cached] of this.cache) {\n try { cached.transport.destroy(); } catch (err) { logAndSwallow(\"subagent_runtime\", \"op\", err); }\n logInfo(TAG, `${name} transport closed`);\n }\n this.cache.clear();\n }\n\n /** Active registry: list running background spawns. */\n listActive(): Array<{ taskId: string; startedAt: number }> {\n return [...this.activeSpawns.entries()].map(([taskId, entry]) => ({\n taskId,\n startedAt: (entry as any).startedAt ?? 0,\n }));\n }\n\n /** Interrupt a specific spawn by taskId. Returns true if found. */\n interruptSpawn(taskId: string): boolean {\n const entry = this.activeSpawns.get(taskId);\n if (!entry) return false;\n entry.abort.abort();\n this.activeSpawns.delete(taskId);\n logInfo(TAG, `spawn ${taskId} interrupted`);\n return true;\n }\n\n private async createAgent(agent: AgentName): Promise<CachedAgent> {\n const { createSubagentTransport } = await import(\"./agent-registry.js\");\n const role = AGENT_TO_ROLE[agent];\n const mainModel = this._mainTransport && \"currentModel\" in this._mainTransport\n ? (this._mainTransport as unknown as { currentModel: string }).currentModel\n : undefined;\n const { transport, model } = await createSubagentTransport(role, this._registry ?? undefined, mainModel);\n\n // #524: inject system prompt for browse sessions\n if (agent === \"browsie\" && \"setSystemPrompt\" in transport && typeof (transport as any).setSystemPrompt === \"function\") {\n (transport as any).setSystemPrompt(BROWSE_SYSTEM_PROMPT);\n }\n\n const sessionKey = `system:${agent}`;\n const entry: CachedAgent = { transport, model, sessionKey };\n this.cache.set(agent, entry);\n (await import(\"./transport/tool-registry.js\")).resetStoreCounter();\n return entry;\n }\n}\n\nconst BROWSE_SYSTEM_PROMPT = `You are a web browsing assistant. You have two tools for web access:\n\n1. **browser tool** (navigate, click, fill, extract_text, screenshot) \u2014 use for JS-heavy pages, rendered content, page interaction, login flows, or anything that needs a real browser.\n2. **curl / execute_bash** \u2014 use for simple API calls, raw downloads, fetching headers, or static pages.\n\nPrefer the browser tool when the page likely uses JavaScript rendering or requires interaction. Use curl when a simple HTTP request suffices.`;\n\nconst AGENT_TO_ROLE: Record<AgentName, import(\"./agent-registry.js\").SubagentRole> = {\n professor: \"task\",\n dreamy: \"sleep\",\n browsie: \"browse\",\n coding: \"coding\",\n task: \"task\",\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAMA;AAEA;AACA,SAAS,mBAAmB;AAI5B,IAAM,MAAM;AAwCZ,IAAM,kBAAwD;AAAA,EAC5D,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;AAEA,IAAM,2BAA2B;AAE1B,IAAM,kBAAN,MAAsB;AAAA,EACV,QAAQ,oBA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