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,72 @@
|
|
|
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 "./chunk-BUUVFUPO.js";
|
|
7
|
+
import "./chunk-X76UX47U.js";
|
|
8
|
+
import "./chunk-NWDBD4PA.js";
|
|
9
|
+
|
|
10
|
+
// src/components/transport/sse-parser-anthropic.ts
|
|
11
|
+
init_log_and_swallow();
|
|
12
|
+
var TAG = "sse_parser_anthropic";
|
|
13
|
+
async function* parseAnthropicSSE(response, signal) {
|
|
14
|
+
const reader = response.body?.getReader();
|
|
15
|
+
if (!reader) throw new Error("Response body is not readable");
|
|
16
|
+
const decoder = new TextDecoder();
|
|
17
|
+
let buffer = "";
|
|
18
|
+
let usage = null;
|
|
19
|
+
try {
|
|
20
|
+
while (true) {
|
|
21
|
+
if (signal.aborted) break;
|
|
22
|
+
const { done, value } = await reader.read();
|
|
23
|
+
if (done) break;
|
|
24
|
+
buffer += decoder.decode(value, { stream: true });
|
|
25
|
+
const lines = buffer.split("\n");
|
|
26
|
+
buffer = lines.pop() ?? "";
|
|
27
|
+
let eventType = "";
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
if (line.startsWith("event: ")) {
|
|
30
|
+
eventType = line.slice(7).trim();
|
|
31
|
+
} else if (line.startsWith("data: ") && eventType) {
|
|
32
|
+
const data = line.slice(6).trim();
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = JSON.parse(data);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
logAndSwallow(TAG, "JSON.parse SSE chunk", err);
|
|
38
|
+
eventType = "";
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (eventType === "content_block_delta") {
|
|
42
|
+
const delta = parsed["delta"];
|
|
43
|
+
if (delta?.["type"] === "text_delta" && typeof delta["text"] === "string") {
|
|
44
|
+
yield { type: "chunk", content: delta["text"] };
|
|
45
|
+
} else if (delta?.["type"] === "input_json_delta" && typeof delta["partial_json"] === "string") {
|
|
46
|
+
yield { type: "tool_call_delta", index: parsed["index"] ?? 0, id: void 0, name: void 0, arguments: delta["partial_json"] };
|
|
47
|
+
}
|
|
48
|
+
} else if (eventType === "content_block_start") {
|
|
49
|
+
const block = parsed["content_block"];
|
|
50
|
+
if (block?.["type"] === "tool_use") {
|
|
51
|
+
yield { type: "tool_call_delta", index: parsed["index"] ?? 0, id: block["id"], name: block["name"], arguments: void 0 };
|
|
52
|
+
}
|
|
53
|
+
} else if (eventType === "message_delta") {
|
|
54
|
+
const u = parsed["usage"];
|
|
55
|
+
if (u) usage = { prompt_tokens: u["input_tokens"] ?? 0, completion_tokens: u["output_tokens"] ?? 0 };
|
|
56
|
+
} else if (eventType === "message_stop") {
|
|
57
|
+
yield { type: "done", usage };
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
eventType = "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
yield { type: "done", usage };
|
|
65
|
+
} finally {
|
|
66
|
+
reader.releaseLock();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
parseAnthropicSSE
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=sse-parser-anthropic-P7CE2MH2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/transport/sse-parser-anthropic.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * sse-parser-anthropic.ts \u2014 Anthropic Messages API streaming parser (#472).\n * Yields same SSEEvent types as sse-parser.ts for consumer compatibility.\n * v1: text streaming only. Tool calls (tool_use blocks) not yet mapped.\n */\n\nimport type { SSEEvent } from \"./sse-parser.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\n\nconst TAG = \"sse_parser_anthropic\";\n\nexport async function* parseAnthropicSSE(\n response: Response,\n signal: AbortSignal,\n): AsyncGenerator<SSEEvent> {\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"Response body is not readable\");\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n let usage: { prompt_tokens: number; completion_tokens: number } | null = null;\n\n try {\n while (true) {\n if (signal.aborted) break;\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n let eventType = \"\";\n for (const line of lines) {\n if (line.startsWith(\"event: \")) {\n eventType = line.slice(7).trim();\n } else if (line.startsWith(\"data: \") && eventType) {\n const data = line.slice(6).trim();\n let parsed: Record<string, unknown>;\n try { parsed = JSON.parse(data); } catch (err) { logAndSwallow(TAG, \"JSON.parse SSE chunk\", err); eventType = \"\"; continue; }\n\n if (eventType === \"content_block_delta\") {\n const delta = parsed[\"delta\"] as Record<string, unknown> | undefined;\n if (delta?.[\"type\"] === \"text_delta\" && typeof delta[\"text\"] === \"string\") {\n yield { type: \"chunk\", content: delta[\"text\"] as string };\n } else if (delta?.[\"type\"] === \"input_json_delta\" && typeof delta[\"partial_json\"] === \"string\") {\n yield { type: \"tool_call_delta\", index: (parsed[\"index\"] as number) ?? 0, id: undefined, name: undefined, arguments: delta[\"partial_json\"] as string };\n }\n } else if (eventType === \"content_block_start\") {\n const block = parsed[\"content_block\"] as Record<string, unknown> | undefined;\n if (block?.[\"type\"] === \"tool_use\") {\n yield { type: \"tool_call_delta\", index: (parsed[\"index\"] as number) ?? 0, id: block[\"id\"] as string, name: block[\"name\"] as string, arguments: undefined };\n }\n } else if (eventType === \"message_delta\") {\n const u = parsed[\"usage\"] as Record<string, number> | undefined;\n if (u) usage = { prompt_tokens: u[\"input_tokens\"] ?? 0, completion_tokens: u[\"output_tokens\"] ?? 0 };\n } else if (eventType === \"message_stop\") {\n yield { type: \"done\", usage };\n return;\n }\n eventType = \"\";\n }\n }\n }\n yield { type: \"done\", usage };\n } finally {\n reader.releaseLock();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAOA;AAEA,IAAM,MAAM;AAEZ,gBAAuB,kBACrB,UACA,QAC0B;AAC1B,QAAM,SAAS,SAAS,MAAM,UAAU;AACxC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+BAA+B;AAE5D,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,SAAS;AACb,MAAI,QAAqE;AAEzE,MAAI;AACF,WAAO,MAAM;AACX,UAAI,OAAO,QAAS;AACpB,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,UAAI,KAAM;AAEV,gBAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAChD,YAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,eAAS,MAAM,IAAI,KAAK;AAExB,UAAI,YAAY;AAChB,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,WAAW,SAAS,GAAG;AAC9B,sBAAY,KAAK,MAAM,CAAC,EAAE,KAAK;AAAA,QACjC,WAAW,KAAK,WAAW,QAAQ,KAAK,WAAW;AACjD,gBAAM,OAAO,KAAK,MAAM,CAAC,EAAE,KAAK;AAChC,cAAI;AACJ,cAAI;AAAE,qBAAS,KAAK,MAAM,IAAI;AAAA,UAAG,SAAS,KAAK;AAAE,0BAAc,KAAK,wBAAwB,GAAG;AAAG,wBAAY;AAAI;AAAA,UAAU;AAE5H,cAAI,cAAc,uBAAuB;AACvC,kBAAM,QAAQ,OAAO,OAAO;AAC5B,gBAAI,QAAQ,MAAM,MAAM,gBAAgB,OAAO,MAAM,MAAM,MAAM,UAAU;AACzE,oBAAM,EAAE,MAAM,SAAS,SAAS,MAAM,MAAM,EAAY;AAAA,YAC1D,WAAW,QAAQ,MAAM,MAAM,sBAAsB,OAAO,MAAM,cAAc,MAAM,UAAU;AAC9F,oBAAM,EAAE,MAAM,mBAAmB,OAAQ,OAAO,OAAO,KAAgB,GAAG,IAAI,QAAW,MAAM,QAAW,WAAW,MAAM,cAAc,EAAY;AAAA,YACvJ;AAAA,UACF,WAAW,cAAc,uBAAuB;AAC9C,kBAAM,QAAQ,OAAO,eAAe;AACpC,gBAAI,QAAQ,MAAM,MAAM,YAAY;AAClC,oBAAM,EAAE,MAAM,mBAAmB,OAAQ,OAAO,OAAO,KAAgB,GAAG,IAAI,MAAM,IAAI,GAAa,MAAM,MAAM,MAAM,GAAa,WAAW,OAAU;AAAA,YAC3J;AAAA,UACF,WAAW,cAAc,iBAAiB;AACxC,kBAAM,IAAI,OAAO,OAAO;AACxB,gBAAI,EAAG,SAAQ,EAAE,eAAe,EAAE,cAAc,KAAK,GAAG,mBAAmB,EAAE,eAAe,KAAK,EAAE;AAAA,UACrG,WAAW,cAAc,gBAAgB;AACvC,kBAAM,EAAE,MAAM,QAAQ,MAAM;AAC5B;AAAA,UACF;AACA,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AACA,UAAM,EAAE,MAAM,QAAQ,MAAM;AAAA,EAC9B,UAAE;AACA,WAAO,YAAY;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 "./chunk-BUUVFUPO.js";
|
|
7
|
+
import "./chunk-X76UX47U.js";
|
|
8
|
+
import "./chunk-NWDBD4PA.js";
|
|
9
|
+
|
|
10
|
+
// src/components/transport/sse-parser-responses.ts
|
|
11
|
+
init_log_and_swallow();
|
|
12
|
+
var TAG = "sse_parser_responses";
|
|
13
|
+
async function* parseResponsesSSE(response, signal) {
|
|
14
|
+
const reader = response.body?.getReader();
|
|
15
|
+
if (!reader) throw new Error("Response body is not readable");
|
|
16
|
+
const decoder = new TextDecoder();
|
|
17
|
+
let buffer = "";
|
|
18
|
+
try {
|
|
19
|
+
while (true) {
|
|
20
|
+
if (signal.aborted) break;
|
|
21
|
+
const { done, value } = await reader.read();
|
|
22
|
+
if (done) break;
|
|
23
|
+
buffer += decoder.decode(value, { stream: true });
|
|
24
|
+
const lines = buffer.split("\n");
|
|
25
|
+
buffer = lines.pop() ?? "";
|
|
26
|
+
let eventType = "";
|
|
27
|
+
for (const line of lines) {
|
|
28
|
+
if (line.startsWith("event: ")) {
|
|
29
|
+
eventType = line.slice(7).trim();
|
|
30
|
+
} else if (line.startsWith("data: ") && eventType) {
|
|
31
|
+
const data = line.slice(6).trim();
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(data);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
logAndSwallow(TAG, "JSON.parse SSE chunk", err);
|
|
37
|
+
eventType = "";
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (eventType === "response.output_text.delta") {
|
|
41
|
+
const delta = parsed["delta"];
|
|
42
|
+
if (delta) yield { type: "chunk", content: delta };
|
|
43
|
+
} else if (eventType === "response.function_call_arguments.delta") {
|
|
44
|
+
yield { type: "tool_call_delta", index: 0, id: parsed["call_id"] ?? void 0, name: void 0, arguments: parsed["delta"] ?? "" };
|
|
45
|
+
} else if (eventType === "response.function_call_arguments.done") {
|
|
46
|
+
yield { type: "tool_call_delta", index: 0, id: parsed["call_id"] ?? void 0, name: parsed["name"] ?? void 0, arguments: void 0 };
|
|
47
|
+
} else if (eventType === "response.completed" || eventType === "response.done") {
|
|
48
|
+
yield { type: "done", usage: null };
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
eventType = "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
yield { type: "done", usage: null };
|
|
56
|
+
} finally {
|
|
57
|
+
reader.releaseLock();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
parseResponsesSSE
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=sse-parser-responses-EQQA5FWN.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/transport/sse-parser-responses.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * sse-parser-responses.ts \u2014 OpenAI Responses API streaming parser (#472).\n * Yields same SSEEvent types as sse-parser.ts for consumer compatibility.\n * v1: text streaming only.\n */\n\nimport type { SSEEvent } from \"./sse-parser.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\n\nconst TAG = \"sse_parser_responses\";\n\nexport async function* parseResponsesSSE(\n response: Response,\n signal: AbortSignal,\n): AsyncGenerator<SSEEvent> {\n const reader = response.body?.getReader();\n if (!reader) throw new Error(\"Response body is not readable\");\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n try {\n while (true) {\n if (signal.aborted) break;\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n let eventType = \"\";\n for (const line of lines) {\n if (line.startsWith(\"event: \")) {\n eventType = line.slice(7).trim();\n } else if (line.startsWith(\"data: \") && eventType) {\n const data = line.slice(6).trim();\n let parsed: Record<string, unknown>;\n try { parsed = JSON.parse(data); } catch (err) { logAndSwallow(TAG, \"JSON.parse SSE chunk\", err); eventType = \"\"; continue; }\n\n if (eventType === \"response.output_text.delta\") {\n const delta = parsed[\"delta\"] as string | undefined;\n if (delta) yield { type: \"chunk\", content: delta };\n } else if (eventType === \"response.function_call_arguments.delta\") {\n yield { type: \"tool_call_delta\", index: 0, id: (parsed[\"call_id\"] as string) ?? undefined, name: undefined, arguments: (parsed[\"delta\"] as string) ?? \"\" };\n } else if (eventType === \"response.function_call_arguments.done\") {\n yield { type: \"tool_call_delta\", index: 0, id: (parsed[\"call_id\"] as string) ?? undefined, name: (parsed[\"name\"] as string) ?? undefined, arguments: undefined };\n } else if (eventType === \"response.completed\" || eventType === \"response.done\") {\n yield { type: \"done\", usage: null };\n return;\n }\n eventType = \"\";\n }\n }\n }\n yield { type: \"done\", usage: null };\n } finally {\n reader.releaseLock();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAOA;AAEA,IAAM,MAAM;AAEZ,gBAAuB,kBACrB,UACA,QAC0B;AAC1B,QAAM,SAAS,SAAS,MAAM,UAAU;AACxC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+BAA+B;AAE5D,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,SAAS;AAEb,MAAI;AACF,WAAO,MAAM;AACX,UAAI,OAAO,QAAS;AACpB,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,UAAI,KAAM;AAEV,gBAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAChD,YAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,eAAS,MAAM,IAAI,KAAK;AAExB,UAAI,YAAY;AAChB,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,WAAW,SAAS,GAAG;AAC9B,sBAAY,KAAK,MAAM,CAAC,EAAE,KAAK;AAAA,QACjC,WAAW,KAAK,WAAW,QAAQ,KAAK,WAAW;AACjD,gBAAM,OAAO,KAAK,MAAM,CAAC,EAAE,KAAK;AAChC,cAAI;AACJ,cAAI;AAAE,qBAAS,KAAK,MAAM,IAAI;AAAA,UAAG,SAAS,KAAK;AAAE,0BAAc,KAAK,wBAAwB,GAAG;AAAG,wBAAY;AAAI;AAAA,UAAU;AAE5H,cAAI,cAAc,8BAA8B;AAC9C,kBAAM,QAAQ,OAAO,OAAO;AAC5B,gBAAI,MAAO,OAAM,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,UACnD,WAAW,cAAc,0CAA0C;AACjE,kBAAM,EAAE,MAAM,mBAAmB,OAAO,GAAG,IAAK,OAAO,SAAS,KAAgB,QAAW,MAAM,QAAW,WAAY,OAAO,OAAO,KAAgB,GAAG;AAAA,UAC3J,WAAW,cAAc,yCAAyC;AAChE,kBAAM,EAAE,MAAM,mBAAmB,OAAO,GAAG,IAAK,OAAO,SAAS,KAAgB,QAAW,MAAO,OAAO,MAAM,KAAgB,QAAW,WAAW,OAAU;AAAA,UACjK,WAAW,cAAc,wBAAwB,cAAc,iBAAiB;AAC9E,kBAAM,EAAE,MAAM,QAAQ,OAAO,KAAK;AAClC;AAAA,UACF;AACA,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AACA,UAAM,EAAE,MAAM,QAAQ,OAAO,KAAK;AAAA,EACpC,UAAE;AACA,WAAO,YAAY;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 "./chunk-BUUVFUPO.js";
|
|
7
|
+
import "./chunk-X76UX47U.js";
|
|
8
|
+
import "./chunk-NWDBD4PA.js";
|
|
9
|
+
|
|
10
|
+
// src/capabilities/browser/ssrf-guard.ts
|
|
11
|
+
init_log_and_swallow();
|
|
12
|
+
import { resolve4, resolve6 } from "node:dns/promises";
|
|
13
|
+
var PRIVATE_RANGES_V4 = [
|
|
14
|
+
// [network, mask, bits] — network & mask === candidate & mask → private
|
|
15
|
+
[2130706432, 4278190080, 8],
|
|
16
|
+
// 127.0.0.0/8
|
|
17
|
+
[167772160, 4278190080, 8],
|
|
18
|
+
// 10.0.0.0/8
|
|
19
|
+
[2886729728, 4293918720, 12],
|
|
20
|
+
// 172.16.0.0/12
|
|
21
|
+
[3232235520, 4294901760, 16],
|
|
22
|
+
// 192.168.0.0/16
|
|
23
|
+
[2851995648, 4294901760, 16],
|
|
24
|
+
// 169.254.0.0/16 (link-local)
|
|
25
|
+
[1681915904, 4290772992, 10],
|
|
26
|
+
// 100.64.0.0/10 (CGNAT)
|
|
27
|
+
[0, 4294967295, 32]
|
|
28
|
+
// 0.0.0.0
|
|
29
|
+
];
|
|
30
|
+
function ipv4ToInt(ip) {
|
|
31
|
+
const parts = ip.split(".").map(Number);
|
|
32
|
+
return (parts[0] << 24 | parts[1] << 16 | parts[2] << 8 | parts[3]) >>> 0;
|
|
33
|
+
}
|
|
34
|
+
function isPrivateV4(ip) {
|
|
35
|
+
const n = ipv4ToInt(ip);
|
|
36
|
+
return PRIVATE_RANGES_V4.some(([net, mask]) => (n & mask) >>> 0 === (net & mask) >>> 0);
|
|
37
|
+
}
|
|
38
|
+
function isPrivateV6(ip) {
|
|
39
|
+
const lower = ip.toLowerCase();
|
|
40
|
+
return lower === "::1" || lower.startsWith("fd") || lower.startsWith("fe80") || lower.startsWith("::ffff:127.");
|
|
41
|
+
}
|
|
42
|
+
async function isPrivateHost(hostname) {
|
|
43
|
+
if (/^\d+\.\d+\.\d+\.\d+$/.test(hostname)) return isPrivateV4(hostname);
|
|
44
|
+
if (hostname.includes(":")) return isPrivateV6(hostname);
|
|
45
|
+
if (hostname === "localhost") return true;
|
|
46
|
+
const timeout = (p) => Promise.race([p, new Promise((_, reject) => setTimeout(() => reject(new Error("dns timeout")), 2e3))]);
|
|
47
|
+
try {
|
|
48
|
+
const v4 = await timeout(resolve4(hostname));
|
|
49
|
+
if (v4.some(isPrivateV4)) return true;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
logAndSwallow("ssrf_guard", "op", err);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const v6 = await timeout(resolve6(hostname));
|
|
55
|
+
if (v6.some(isPrivateV6)) return true;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
logAndSwallow("ssrf_guard", "op", err);
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
isPrivateHost
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=ssrf-guard-FZCBYIVW.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/capabilities/browser/ssrf-guard.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * SSRF guard \u2014 reject private/internal IP addresses.\n * Adapted from NemoClaw's ssrf.ts.\n */\n\nimport { logAndSwallow } from \"../../components/log-and-swallow.js\";\nimport { resolve4, resolve6 } from \"node:dns/promises\";\n\nconst PRIVATE_RANGES_V4: ReadonlyArray<[number, number, number]> = [\n // [network, mask, bits] \u2014 network & mask === candidate & mask \u2192 private\n [0x7F000000, 0xFF000000, 8], // 127.0.0.0/8\n [0x0A000000, 0xFF000000, 8], // 10.0.0.0/8\n [0xAC100000, 0xFFF00000, 12], // 172.16.0.0/12\n [0xC0A80000, 0xFFFF0000, 16], // 192.168.0.0/16\n [0xA9FE0000, 0xFFFF0000, 16], // 169.254.0.0/16 (link-local)\n [0x64400000, 0xFFC00000, 10], // 100.64.0.0/10 (CGNAT)\n [0x00000000, 0xFFFFFFFF, 32], // 0.0.0.0\n];\n\nfunction ipv4ToInt(ip: string): number {\n const parts = ip.split(\".\").map(Number);\n return ((parts[0]! << 24) | (parts[1]! << 16) | (parts[2]! << 8) | parts[3]!) >>> 0;\n}\n\nfunction isPrivateV4(ip: string): boolean {\n const n = ipv4ToInt(ip);\n return PRIVATE_RANGES_V4.some(([net, mask]) => (n & mask) >>> 0 === (net & mask) >>> 0);\n}\n\nfunction isPrivateV6(ip: string): boolean {\n const lower = ip.toLowerCase();\n return lower === \"::1\" || lower.startsWith(\"fd\") || lower.startsWith(\"fe80\") || lower.startsWith(\"::ffff:127.\");\n}\n\n/** Check if a hostname resolves to a private IP. Resolves DNS to catch rebinding. */\nexport async function isPrivateHost(hostname: string): Promise<boolean> {\n // Direct IP check\n if (/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(hostname)) return isPrivateV4(hostname);\n if (hostname.includes(\":\")) return isPrivateV6(hostname);\n if (hostname === \"localhost\") return true;\n\n // DNS resolution check (catches DNS rebinding)\n const timeout = (p: Promise<string[]>): Promise<string[]> =>\n Promise.race([p, new Promise<string[]>((_, reject) => setTimeout(() => reject(new Error(\"dns timeout\")), 2000))]);\n\n try {\n const v4 = await timeout(resolve4(hostname));\n if (v4.some(isPrivateV4)) return true;\n } catch (err) { logAndSwallow(\"ssrf_guard\", \"op\", err); }\n\n try {\n const v6 = await timeout(resolve6(hostname));\n if (v6.some(isPrivateV6)) return true;\n } catch (err) { logAndSwallow(\"ssrf_guard\", \"op\", err); }\n\n return false;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAKA;AACA,SAAS,UAAU,gBAAgB;AAEnC,IAAM,oBAA6D;AAAA;AAAA,EAEjE,CAAC,YAAY,YAAY,CAAC;AAAA;AAAA,EAC1B,CAAC,WAAY,YAAY,CAAC;AAAA;AAAA,EAC1B,CAAC,YAAY,YAAY,EAAE;AAAA;AAAA,EAC3B,CAAC,YAAY,YAAY,EAAE;AAAA;AAAA,EAC3B,CAAC,YAAY,YAAY,EAAE;AAAA;AAAA,EAC3B,CAAC,YAAY,YAAY,EAAE;AAAA;AAAA,EAC3B,CAAC,GAAY,YAAY,EAAE;AAAA;AAC7B;AAEA,SAAS,UAAU,IAAoB;AACrC,QAAM,QAAQ,GAAG,MAAM,GAAG,EAAE,IAAI,MAAM;AACtC,UAAS,MAAM,CAAC,KAAM,KAAO,MAAM,CAAC,KAAM,KAAO,MAAM,CAAC,KAAM,IAAK,MAAM,CAAC,OAAQ;AACpF;AAEA,SAAS,YAAY,IAAqB;AACxC,QAAM,IAAI,UAAU,EAAE;AACtB,SAAO,kBAAkB,KAAK,CAAC,CAAC,KAAK,IAAI,OAAO,IAAI,UAAU,OAAO,MAAM,UAAU,CAAC;AACxF;AAEA,SAAS,YAAY,IAAqB;AACxC,QAAM,QAAQ,GAAG,YAAY;AAC7B,SAAO,UAAU,SAAS,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW,MAAM,KAAK,MAAM,WAAW,aAAa;AAChH;AAGA,eAAsB,cAAc,UAAoC;AAEtE,MAAI,uBAAuB,KAAK,QAAQ,EAAG,QAAO,YAAY,QAAQ;AACtE,MAAI,SAAS,SAAS,GAAG,EAAG,QAAO,YAAY,QAAQ;AACvD,MAAI,aAAa,YAAa,QAAO;AAGrC,QAAM,UAAU,CAAC,MACf,QAAQ,KAAK,CAAC,GAAG,IAAI,QAAkB,CAAC,GAAG,WAAW,WAAW,MAAM,OAAO,IAAI,MAAM,aAAa,CAAC,GAAG,GAAI,CAAC,CAAC,CAAC;AAElH,MAAI;AACF,UAAM,KAAK,MAAM,QAAQ,SAAS,QAAQ,CAAC;AAC3C,QAAI,GAAG,KAAK,WAAW,EAAG,QAAO;AAAA,EACnC,SAAS,KAAK;AAAE,kBAAc,cAAc,MAAM,GAAG;AAAA,EAAG;AAExD,MAAI;AACF,UAAM,KAAK,MAAM,QAAQ,SAAS,QAAQ,CAAC;AAC3C,QAAI,GAAG,KAAK,WAAW,EAAG,QAAO;AAAA,EACnC,SAAS,KAAK;AAAE,kBAAc,cAAc,MAAM,GAAG;AAAA,EAAG;AAExD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 "./chunk-NWDBD4PA.js";
|
|
3
|
+
|
|
4
|
+
// src/cli/commands/start.ts
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
function abtarsHome() {
|
|
8
|
+
return process.env["ABTARS_HOME"] ?? join(process.env["HOME"] ?? "", ".abtars");
|
|
9
|
+
}
|
|
10
|
+
function pidAlive(pid) {
|
|
11
|
+
try {
|
|
12
|
+
process.kill(pid, 0);
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function start() {
|
|
19
|
+
const home = abtarsHome();
|
|
20
|
+
const pidFile = join(home, "bridge.pid");
|
|
21
|
+
if (existsSync(pidFile)) {
|
|
22
|
+
const pid = parseInt(readFileSync(pidFile, "utf-8").trim(), 10);
|
|
23
|
+
if (!isNaN(pid) && pidAlive(pid)) {
|
|
24
|
+
process.stdout.write(`Bridge already running (pid ${pid}).
|
|
25
|
+
`);
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const { restart } = await import("./abtars-restart.js");
|
|
30
|
+
return restart({ cold: true });
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
start
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=start-FH3GRMJ4.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli/commands/start.ts"],
|
|
4
|
+
"sourcesContent": ["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nfunction abtarsHome(): string {\n return process.env[\"ABTARS_HOME\"] ?? join(process.env[\"HOME\"] ?? \"\", \".abtars\");\n}\n\nfunction pidAlive(pid: number): boolean {\n try { process.kill(pid, 0); return true; } catch { return false; }\n}\n\nexport async function start(): Promise<number> {\n const home = abtarsHome();\n const pidFile = join(home, \"bridge.pid\");\n\n if (existsSync(pidFile)) {\n const pid = parseInt(readFileSync(pidFile, \"utf-8\").trim(), 10);\n if (!isNaN(pid) && pidAlive(pid)) {\n process.stdout.write(`Bridge already running (pid ${pid}).\\n`);\n return 0;\n }\n }\n\n const { restart } = await import(\"./restart.js\");\n return restart({ cold: true });\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAErB,SAAS,aAAqB;AAC5B,SAAO,QAAQ,IAAI,aAAa,KAAK,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,SAAS;AAChF;AAEA,SAAS,SAAS,KAAsB;AACtC,MAAI;AAAE,YAAQ,KAAK,KAAK,CAAC;AAAG,WAAO;AAAA,EAAM,QAAQ;AAAE,WAAO;AAAA,EAAO;AACnE;AAEA,eAAsB,QAAyB;AAC7C,QAAM,OAAO,WAAW;AACxB,QAAM,UAAU,KAAK,MAAM,YAAY;AAEvC,MAAI,WAAW,OAAO,GAAG;AACvB,UAAM,MAAM,SAAS,aAAa,SAAS,OAAO,EAAE,KAAK,GAAG,EAAE;AAC9D,QAAI,CAAC,MAAM,GAAG,KAAK,SAAS,GAAG,GAAG;AAChC,cAAQ,OAAO,MAAM,+BAA+B,GAAG;AAAA,CAAM;AAC7D,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,qBAAc;AAC/C,SAAO,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 "./chunk-NWDBD4PA.js";
|
|
3
|
+
|
|
4
|
+
// src/components/transport/stream-single.ts
|
|
5
|
+
async function streamSingleCompletion(params) {
|
|
6
|
+
const { endpoint, apiKey, model, systemPrompt, userPrompt, maxTokens } = params;
|
|
7
|
+
const body = {
|
|
8
|
+
model,
|
|
9
|
+
messages: [
|
|
10
|
+
{ role: "system", content: systemPrompt },
|
|
11
|
+
{ role: "user", content: userPrompt }
|
|
12
|
+
],
|
|
13
|
+
max_tokens: maxTokens,
|
|
14
|
+
stream: false
|
|
15
|
+
};
|
|
16
|
+
const headers = { "Content-Type": "application/json" };
|
|
17
|
+
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
18
|
+
const response = await fetch(`${endpoint}/chat/completions`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers,
|
|
21
|
+
body: JSON.stringify(body),
|
|
22
|
+
signal: AbortSignal.timeout(6e4)
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new Error(`Summarization LLM call failed: ${response.status} ${response.statusText}`);
|
|
26
|
+
}
|
|
27
|
+
const json = await response.json();
|
|
28
|
+
return json.choices?.[0]?.message?.content?.trim() ?? "";
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
streamSingleCompletion
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=stream-single-WSG4D53C.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/transport/stream-single.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * stream-single.ts \u2014 Single-shot LLM completion for internal use (summarization, etc.).\n * Non-streaming, returns full text response.\n */\n\nexport interface SingleCompletionParams {\n endpoint: string;\n apiKey?: string;\n model: string;\n systemPrompt: string;\n userPrompt: string;\n maxTokens: number;\n}\n\nexport async function streamSingleCompletion(params: SingleCompletionParams): Promise<string> {\n const { endpoint, apiKey, model, systemPrompt, userPrompt, maxTokens } = params;\n\n const body = {\n model,\n messages: [\n { role: \"system\", content: systemPrompt },\n { role: \"user\", content: userPrompt },\n ],\n max_tokens: maxTokens,\n stream: false,\n };\n\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"Authorization\"] = `Bearer ${apiKey}`;\n\n const response = await fetch(`${endpoint}/chat/completions`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(60_000),\n });\n\n if (!response.ok) {\n throw new Error(`Summarization LLM call failed: ${response.status} ${response.statusText}`);\n }\n\n const json = await response.json() as { choices?: Array<{ message?: { content?: string } }> };\n return json.choices?.[0]?.message?.content?.trim() ?? \"\";\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAcA,eAAsB,uBAAuB,QAAiD;AAC5F,QAAM,EAAE,UAAU,QAAQ,OAAO,cAAc,YAAY,UAAU,IAAI;AAEzE,QAAM,OAAO;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACR,EAAE,MAAM,UAAU,SAAS,aAAa;AAAA,MACxC,EAAE,MAAM,QAAQ,SAAS,WAAW;AAAA,IACtC;AAAA,IACA,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAEA,QAAM,UAAkC,EAAE,gBAAgB,mBAAmB;AAC7E,MAAI,OAAQ,SAAQ,eAAe,IAAI,UAAU,MAAM;AAEvD,QAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,qBAAqB;AAAA,IAC3D,QAAQ;AAAA,IACR;AAAA,IACA,MAAM,KAAK,UAAU,IAAI;AAAA,IACzB,QAAQ,YAAY,QAAQ,GAAM;AAAA,EACpC,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,kCAAkC,SAAS,MAAM,IAAI,SAAS,UAAU,EAAE;AAAA,EAC5F;AAEA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,SAAO,KAAK,UAAU,CAAC,GAAG,SAAS,SAAS,KAAK,KAAK;AACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
LANGUAGE_HINT_PROMPT,
|
|
4
|
+
transcribeAudio
|
|
5
|
+
} from "./chunk-V76TVMCM.js";
|
|
6
|
+
import "./chunk-FMWKEPM7.js";
|
|
7
|
+
import "./chunk-BUUVFUPO.js";
|
|
8
|
+
import "./chunk-X76UX47U.js";
|
|
9
|
+
import "./chunk-NWDBD4PA.js";
|
|
10
|
+
export {
|
|
11
|
+
LANGUAGE_HINT_PROMPT,
|
|
12
|
+
transcribeAudio
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=stt-2UH3RITX.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
SubagentRuntime
|
|
4
|
+
} from "./chunk-JW6RU47G.js";
|
|
5
|
+
import "./chunk-FMWKEPM7.js";
|
|
6
|
+
import "./chunk-BUUVFUPO.js";
|
|
7
|
+
import "./chunk-X76UX47U.js";
|
|
8
|
+
import "./chunk-NWDBD4PA.js";
|
|
9
|
+
export {
|
|
10
|
+
SubagentRuntime
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=subagent-runtime-LE2ZXH3G.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
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 "./chunk-X76UX47U.js";
|
|
8
|
+
import "./chunk-NWDBD4PA.js";
|
|
9
|
+
|
|
10
|
+
// src/components/system-message.ts
|
|
11
|
+
init_logger();
|
|
12
|
+
var TAG = "system-msg";
|
|
13
|
+
var _sender = null;
|
|
14
|
+
function initSystemMessage(sender) {
|
|
15
|
+
_sender = sender;
|
|
16
|
+
logInfo(TAG, "System message sender initialized");
|
|
17
|
+
}
|
|
18
|
+
async function sendSystemMessage(prompt) {
|
|
19
|
+
if (!_sender) {
|
|
20
|
+
logWarn(TAG, "System message sender not initialized \u2014 message dropped");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
logInfo(TAG, `Sending system message (${prompt.length} chars)`);
|
|
24
|
+
await _sender(prompt);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
initSystemMessage,
|
|
28
|
+
sendSystemMessage
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=system-message-T5R3EYYN.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/system-message.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * system-message.ts \u2014 Generic system message sender.\n *\n * Any component can send a system prompt to the agent and have the response\n * delivered to the user. Initialized once during bridge startup.\n *\n * Usage:\n * import { sendSystemMessage } from \"./system-message.js\";\n * await sendSystemMessage(\"[SYSTEM] You are getting sleepy...\");\n */\n\nimport { logInfo, logWarn } from \"./logger.js\";\n\nconst TAG = \"system-msg\";\n\ntype MessageSender = (prompt: string) => Promise<void>;\n\nlet _sender: MessageSender | null = null;\n\n/** Initialize the system message sender. Called once during bridge startup. */\nexport function initSystemMessage(sender: MessageSender): void {\n _sender = sender;\n logInfo(TAG, \"System message sender initialized\");\n}\n\n/**\n * Send a system prompt to the agent. The agent's response is delivered to the user.\n * No-op if sender not initialized (e.g. during tests or standalone memory use).\n */\nexport async function sendSystemMessage(prompt: string): Promise<void> {\n if (!_sender) {\n logWarn(TAG, \"System message sender not initialized \u2014 message dropped\");\n return;\n }\n logInfo(TAG, `Sending system message (${prompt.length} chars)`);\n await _sender(prompt);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAWA;AAEA,IAAM,MAAM;AAIZ,IAAI,UAAgC;AAG7B,SAAS,kBAAkB,QAA6B;AAC7D,YAAU;AACV,UAAQ,KAAK,mCAAmC;AAClD;AAMA,eAAsB,kBAAkB,QAA+B;AACrE,MAAI,CAAC,SAAS;AACZ,YAAQ,KAAK,8DAAyD;AACtE;AAAA,EACF;AACA,UAAQ,KAAK,2BAA2B,OAAO,MAAM,SAAS;AAC9D,QAAM,QAAQ,MAAM;AACtB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
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_update_check,
|
|
4
|
+
update_check_exports
|
|
5
|
+
} from "./chunk-QBGBT5QS.js";
|
|
6
|
+
import {
|
|
7
|
+
init_log_and_swallow,
|
|
8
|
+
logAndSwallow
|
|
9
|
+
} from "./chunk-FMWKEPM7.js";
|
|
10
|
+
import "./chunk-BUUVFUPO.js";
|
|
11
|
+
import "./chunk-X76UX47U.js";
|
|
12
|
+
import {
|
|
13
|
+
__toCommonJS
|
|
14
|
+
} from "./chunk-NWDBD4PA.js";
|
|
15
|
+
|
|
16
|
+
// src/components/system-status.ts
|
|
17
|
+
init_log_and_swallow();
|
|
18
|
+
import { readFileSync, readlinkSync, existsSync } from "node:fs";
|
|
19
|
+
import { join, basename } from "node:path";
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
var TAG = "system_status";
|
|
22
|
+
async function getSystemStatus(ctx) {
|
|
23
|
+
let version = "?";
|
|
24
|
+
let commit = "?";
|
|
25
|
+
try {
|
|
26
|
+
const target = basename(readlinkSync(join(homedir(), ".abtars", "current")));
|
|
27
|
+
const dash = target.lastIndexOf("-");
|
|
28
|
+
if (dash > 0) {
|
|
29
|
+
version = target.slice(0, dash);
|
|
30
|
+
commit = target.slice(dash + 1);
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
logAndSwallow("system_status", "op", err);
|
|
34
|
+
}
|
|
35
|
+
let model = "unknown";
|
|
36
|
+
let transportType = "unknown";
|
|
37
|
+
let transportProvider = "unknown";
|
|
38
|
+
try {
|
|
39
|
+
const { loadTransport, resolveAgent } = await import("./transport-config-YLXU33RO.js");
|
|
40
|
+
const tc = loadTransport();
|
|
41
|
+
const prof = tc ? resolveAgent("professor", tc) : null;
|
|
42
|
+
if (prof) {
|
|
43
|
+
model = prof.model;
|
|
44
|
+
transportType = (prof.provider.transport ?? "acp").toUpperCase();
|
|
45
|
+
transportProvider = prof.providerName ?? "unknown";
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
logAndSwallow("system_status", "op", err);
|
|
49
|
+
}
|
|
50
|
+
const serviceStates = ctx.registry.getStates();
|
|
51
|
+
const subsystems = [];
|
|
52
|
+
for (const [name, health] of ctx.phaseHealth) {
|
|
53
|
+
const entry = { name, status: health.status };
|
|
54
|
+
const svcName = phaseToService(name);
|
|
55
|
+
if (svcName && serviceStates[svcName]) {
|
|
56
|
+
const svc = serviceStates[svcName];
|
|
57
|
+
if (health.status === "ok" && !svc.running) {
|
|
58
|
+
entry.status = svc.retrying ? "retrying" : "stopped";
|
|
59
|
+
}
|
|
60
|
+
if (svc.retrying) {
|
|
61
|
+
entry.detail = `retry #${svc.retrying.attempt}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (name === "phaseTransport" && health.status === "ok" && ctx.transport) {
|
|
65
|
+
entry.detail = `${transportType} (${transportProvider}), ${ctx.transport.isReady ? "ready" : "not ready"}`;
|
|
66
|
+
}
|
|
67
|
+
if (name === "phaseHeartbeat" && health.status === "ok" && ctx.heartbeat) {
|
|
68
|
+
try {
|
|
69
|
+
const lock = JSON.parse(readFileSync(ctx.bridgeLockPath, "utf-8"));
|
|
70
|
+
const ago = Math.round((Date.now() - (lock.lastHeartbeat || 0)) / 6e4);
|
|
71
|
+
entry.detail = `${Math.round(ctx.heartbeat.intervalMs / 1e3)}s, last tick ${ago}m ago`;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
logAndSwallow("system_status", "op", err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (name === "phaseDashboard" && health.status === "ok") {
|
|
77
|
+
entry.detail = `:${process.env["WEB_PORT"] || "3000"}`;
|
|
78
|
+
}
|
|
79
|
+
subsystems.push(entry);
|
|
80
|
+
}
|
|
81
|
+
let tasks = { recurring: 0, pending: 0, paused: 0 };
|
|
82
|
+
try {
|
|
83
|
+
const { readEntries } = await import("./task-store-K7CQDEPI.js");
|
|
84
|
+
const entries = readEntries();
|
|
85
|
+
tasks = {
|
|
86
|
+
recurring: entries.filter((e) => e.schedule && !e.paused).length,
|
|
87
|
+
pending: entries.filter((e) => !e.fired && !e.schedule).length,
|
|
88
|
+
paused: entries.filter((e) => e.paused).length
|
|
89
|
+
};
|
|
90
|
+
} catch (err) {
|
|
91
|
+
logAndSwallow("system_status", "op", err);
|
|
92
|
+
}
|
|
93
|
+
let lastBackup = null;
|
|
94
|
+
try {
|
|
95
|
+
const { readdirSync } = await import("node:fs");
|
|
96
|
+
const bd = join(homedir(), ".backup-abtars");
|
|
97
|
+
const bk = readdirSync(bd).filter((f) => f.startsWith("abtars-")).sort();
|
|
98
|
+
if (bk.length > 0) lastBackup = bk[bk.length - 1] ?? null;
|
|
99
|
+
} catch (err) {
|
|
100
|
+
logAndSwallow("system_status", "op", err);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
version,
|
|
104
|
+
commit,
|
|
105
|
+
model,
|
|
106
|
+
transportType,
|
|
107
|
+
transportProvider,
|
|
108
|
+
transportReady: ctx.transport?.isReady ?? false,
|
|
109
|
+
uptimeMs: Date.now() - ctx.startedAt,
|
|
110
|
+
subsystems,
|
|
111
|
+
tasks,
|
|
112
|
+
lastBackup
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function phaseToService(phaseName) {
|
|
116
|
+
switch (phaseName) {
|
|
117
|
+
case "phasePlatforms":
|
|
118
|
+
return null;
|
|
119
|
+
// platforms registers telegram + discord separately
|
|
120
|
+
case "phaseDashboard":
|
|
121
|
+
return null;
|
|
122
|
+
case "phaseAgentApi":
|
|
123
|
+
return "agent-api";
|
|
124
|
+
default:
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function renderStatusText(status) {
|
|
129
|
+
const uptime = formatUptime(status.uptimeMs);
|
|
130
|
+
const lines = [
|
|
131
|
+
`abTARS v${status.version} (${status.commit})`
|
|
132
|
+
];
|
|
133
|
+
try {
|
|
134
|
+
const abmindManifest = join(homedir(), ".abmind", "manifest.json");
|
|
135
|
+
if (existsSync(abmindManifest)) {
|
|
136
|
+
const m = JSON.parse(readFileSync(abmindManifest, "utf-8"));
|
|
137
|
+
const ver = m.version?.replace(/-[a-f0-9]{7,}$/, "") || null;
|
|
138
|
+
const commit = m.commit?.slice(0, 7) ?? "";
|
|
139
|
+
if (ver) {
|
|
140
|
+
lines.push(`abmind v${ver}${commit ? ` (${commit})` : ""}`);
|
|
141
|
+
} else {
|
|
142
|
+
lines.push("abmind: installed (version unknown)");
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
lines.push("abmind: not installed");
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
logAndSwallow(TAG, "read abmind manifest", err);
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const { checkForUpdate } = (init_update_check(), __toCommonJS(update_check_exports));
|
|
152
|
+
const result = checkForUpdate("abtars", status.version);
|
|
153
|
+
if (result?.updateAvailable) {
|
|
154
|
+
lines.push(`\u{1F4E6} Update available: ${result.current} \u2192 ${result.latest}`);
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
logAndSwallow(TAG, "update check", err);
|
|
158
|
+
}
|
|
159
|
+
lines.push(
|
|
160
|
+
`\u{1F916} Model: ${status.model}`,
|
|
161
|
+
`\u23F1\uFE0F Uptime: ${uptime}`,
|
|
162
|
+
"",
|
|
163
|
+
"\u{1F3E5} Subsystems:"
|
|
164
|
+
);
|
|
165
|
+
for (const s of status.subsystems) {
|
|
166
|
+
const icon = s.status === "ok" ? "\u2713" : s.status === "skipped" ? "\u25CB" : "\u2717";
|
|
167
|
+
const label = s.name.replace("phase", "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
168
|
+
const detail = s.detail ? ` \u2014 ${s.detail}` : "";
|
|
169
|
+
lines.push(` ${icon} ${label}${detail}`);
|
|
170
|
+
}
|
|
171
|
+
lines.push("");
|
|
172
|
+
lines.push(`\u23F0 Tasks: ${status.tasks.recurring} recurring, ${status.tasks.pending} pending${status.tasks.paused ? `, ${status.tasks.paused} paused` : ""}`);
|
|
173
|
+
if (status.lastBackup) lines.push(`\u{1F4BE} Last backup: ${status.lastBackup}`);
|
|
174
|
+
return lines.join("\n");
|
|
175
|
+
}
|
|
176
|
+
function formatUptime(ms) {
|
|
177
|
+
const s = Math.floor(ms / 1e3);
|
|
178
|
+
const m = Math.floor(s / 60) % 60;
|
|
179
|
+
const h = Math.floor(s / 3600) % 24;
|
|
180
|
+
const d = Math.floor(s / 86400);
|
|
181
|
+
if (d > 0) return `${d}d ${h}h ${m}m`;
|
|
182
|
+
if (h > 0) return `${h}h ${m}m`;
|
|
183
|
+
return `${m}m`;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
getSystemStatus,
|
|
187
|
+
renderStatusText
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=system-status-KQ6KHFJ6.js.map
|