abtars 0.2.0 → 0.2.1-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -18
- package/bundle/{_registry.generated-6GO2PAMD.js → _registry.generated-4P6KTBTH.js} +8 -8
- package/bundle/_registry.generated-G2FSGHNY.js +36 -0
- package/bundle/_registry.generated-G2FSGHNY.js.map +7 -0
- package/bundle/_registry.generated-N74SMTUJ.js +36 -0
- package/bundle/_registry.generated-N74SMTUJ.js.map +7 -0
- package/bundle/_registry.generated-Y4VT5MBX.js +36 -0
- package/bundle/_registry.generated-Y4VT5MBX.js.map +7 -0
- package/bundle/abtars-browser.js +0 -1
- package/bundle/abtars-browser.js.map +2 -2
- package/bundle/abtars-cli.js +589 -547
- package/bundle/abtars-cli.js.map +4 -4
- package/bundle/abtars-restart.js +1 -1
- package/bundle/abtars-rss.js +0 -1
- package/bundle/abtars-rss.js.map +2 -2
- package/bundle/abtars-task.js +1 -2
- package/bundle/abtars-task.js.map +2 -2
- package/bundle/abtars.js +58 -33
- package/bundle/abtars.js.map +2 -2
- package/bundle/{agent-registry-SYUFNSVB.js → agent-registry-TM7EISOV.js} +2 -2
- package/bundle/{browse-delivery-64GQIUHG.js → browse-delivery-VTLEAVYA.js} +4 -4
- package/bundle/{browser-5H2Q7GEC.js → browser-JQGYFZAG.js} +5 -5
- package/bundle/browser-M4KDLN75.js +19 -0
- package/bundle/browser-REIXOJ6S.js +19 -0
- package/bundle/browser-VG2GTEND.js +19 -0
- package/bundle/{chunk-KFENC7BM.js → chunk-4YOTNYAE.js} +2 -2
- package/bundle/{chunk-KWBGYWDO.js → chunk-7I5C2U3C.js} +1 -1
- package/bundle/chunk-7I5C2U3C.js.map +7 -0
- package/bundle/{chunk-7STAQF5O.js → chunk-CNWXVXGH.js} +4 -4
- package/bundle/{chunk-7STAQF5O.js.map → chunk-CNWXVXGH.js.map} +2 -2
- package/bundle/{chunk-JX3ZZU3O.js → chunk-CU3O53U3.js} +28 -14
- package/bundle/chunk-CU3O53U3.js.map +7 -0
- package/bundle/chunk-EZZBO2QK.js +85 -0
- package/bundle/chunk-EZZBO2QK.js.map +7 -0
- package/bundle/{chunk-XLLSPBBT.js → chunk-GPL57SRN.js} +2 -2
- package/bundle/chunk-GPL57SRN.js.map +7 -0
- package/bundle/{chunk-PQ62LZNA.js → chunk-HEHD3GG5.js} +2 -2
- package/bundle/{chunk-A5OJYQNU.js → chunk-HTGVYNPE.js} +4 -4
- package/bundle/{chunk-WUTCGJDZ.js → chunk-HZRUBJ4Q.js} +148 -9
- package/bundle/chunk-HZRUBJ4Q.js.map +7 -0
- package/bundle/{chunk-ZVDVNSXK.js → chunk-J7CFCY4U.js} +2 -2
- package/bundle/{chunk-HXJRZWKA.js → chunk-JRK3UFBS.js} +106 -58
- package/bundle/chunk-JRK3UFBS.js.map +7 -0
- package/bundle/{chunk-GZUQQWBZ.js → chunk-KJOCXWJ5.js} +3 -3
- package/bundle/chunk-KJOCXWJ5.js.map +7 -0
- package/bundle/{chunk-K7P74UNQ.js → chunk-LDKSCXGL.js} +3 -3
- package/bundle/{chunk-K7P74UNQ.js.map → chunk-LDKSCXGL.js.map} +2 -2
- package/bundle/chunk-MNKLPRGY.js +138 -0
- package/bundle/chunk-MNKLPRGY.js.map +7 -0
- package/bundle/chunk-O73EZGKR.js +135 -0
- package/bundle/chunk-O73EZGKR.js.map +7 -0
- package/bundle/{chunk-OZ4IZFV4.js → chunk-Q7F5R2LL.js} +1 -1
- package/bundle/{chunk-OZ4IZFV4.js.map → chunk-Q7F5R2LL.js.map} +2 -2
- package/bundle/{chunk-XOCP5BMO.js → chunk-URAQLQ2U.js} +2 -2
- package/bundle/chunk-URAQLQ2U.js.map +7 -0
- package/bundle/{chunk-PPSB2ZIN.js → chunk-VREI2GUO.js} +18 -7
- package/bundle/chunk-VREI2GUO.js.map +7 -0
- package/bundle/chunk-VYR25H37.js +135 -0
- package/bundle/chunk-VYR25H37.js.map +7 -0
- package/bundle/{commands-E3Y4QUNF.js → commands-J6JAZ7D2.js} +5 -5
- package/bundle/{deploy-lib-import-ODLDL2DB.js → deploy-lib-import-PJXUADPS.js} +18 -16
- package/bundle/{direct-api-transport-TRV45NO6.js → direct-api-transport-ZSJHKYBX.js} +1 -1
- package/bundle/direct-api-transport-ZSJHKYBX.js.map +7 -0
- package/bundle/{discord-adapter-5DS7UTBE.js → discord-adapter-OCWSJTJU.js} +8 -8
- package/bundle/{doctor-R54GZPKL.js → doctor-XOGVHA4W.js} +13 -2
- package/bundle/{doctor-R54GZPKL.js.map → doctor-XOGVHA4W.js.map} +2 -2
- package/bundle/{install-RSLOS3Q5.js → install-6H3APAIJ.js} +3 -3
- package/bundle/{irc-adapter-RKRUSZXB.js → irc-adapter-AIEP6OX6.js} +6 -2
- package/bundle/irc-adapter-AIEP6OX6.js.map +7 -0
- package/bundle/{message-pipeline-CFVO73CK.js → message-pipeline-TCPHRBAK.js} +5 -5
- package/bundle/meta.json +4005 -3868
- package/bundle/{phase-transport-FEZ4SIJJ.js → phase-transport-ME2XDRR2.js} +3 -3
- package/bundle/restore-UH2UE2K5.js +151 -0
- package/bundle/restore-UH2UE2K5.js.map +7 -0
- package/bundle/rollback-D7AYTC7Z.js +11 -0
- package/bundle/{sleep-BPWX3FCN.js → sleep-IOWYTSMK.js} +2 -2
- package/bundle/{soul-bundle-BRIUDEQ2.js → soul-bundle-AH5S3MVI.js} +2 -2
- package/bundle/{soul-loader-GBXJ7EBH.js → soul-loader-N5FA4I6C.js} +3 -3
- package/bundle/soul-loader-N5FA4I6C.js.map +7 -0
- package/bundle/{start-4IWBKLWO.js → start-CBVKNEAT.js} +1 -1
- package/bundle/{subagent-runtime-MDBO6LHS.js → subagent-runtime-OOJXCKJF.js} +2 -2
- package/bundle/subagent-runtime-OOJXCKJF.js.map +7 -0
- package/bundle/{system-status-WAY63BYC.js → system-status-4JP36OKC.js} +12 -5
- package/bundle/{system-status-WAY63BYC.js.map → system-status-4JP36OKC.js.map} +2 -2
- package/bundle/{task-store-KIBFZL5A.js → task-store-LC7ZMS72.js} +2 -2
- package/bundle/task-store-LC7ZMS72.js.map +7 -0
- package/bundle/{telegram-adapter-MVA33IO2.js → telegram-adapter-QXHJQLLX.js} +5 -5
- package/bundle/{update-check-O5MS6B3L.js → update-check-XVY2IK2L.js} +2 -2
- package/bundle/update-check-XVY2IK2L.js.map +7 -0
- package/core/skills/tools/rss/SKILL.md +51 -0
- package/install-manifest.json +4 -3
- package/package.json +3 -4
- package/scripts/abtars-daemon.service +1 -1
- package/scripts/abtars-watchdog.service +1 -1
- package/scripts/abtars.sh +3 -5
- package/scripts/abtars@.service +1 -1
- package/scripts/build-and-deploy.sh +6 -0
- package/scripts/com.abtars.daemon.plist +1 -1
- package/scripts/com.abtars.watchdog.plist +1 -1
- package/scripts/daily-backup.sh +1 -61
- package/scripts/doctor.sh +48 -33
- package/scripts/watchdog.sh +53 -8
- package/bundle/chunk-GZUQQWBZ.js.map +0 -7
- package/bundle/chunk-HXJRZWKA.js.map +0 -7
- package/bundle/chunk-JX3ZZU3O.js.map +0 -7
- package/bundle/chunk-KWBGYWDO.js.map +0 -7
- package/bundle/chunk-PPSB2ZIN.js.map +0 -7
- package/bundle/chunk-WUTCGJDZ.js.map +0 -7
- package/bundle/chunk-XLLSPBBT.js.map +0 -7
- package/bundle/chunk-XOCP5BMO.js.map +0 -7
- package/bundle/direct-api-transport-TRV45NO6.js.map +0 -7
- package/bundle/irc-adapter-RKRUSZXB.js.map +0 -7
- package/bundle/passwd-QSHZJ2CG.js +0 -134
- package/bundle/passwd-QSHZJ2CG.js.map +0 -7
- package/bundle/restore-ROJF22R2.js +0 -47
- package/bundle/restore-ROJF22R2.js.map +0 -7
- package/core/core_templates/SOUL.md +0 -24
- package/core/core_templates/agent_notes.md +0 -7
- package/core/core_templates/core_facts.md +0 -10
- package/core/core_templates/user_profile.md +0 -7
- package/core/skills/tools/fxtwitter/SKILL.md +0 -52
- package/core/skills/tools/twitterX/SKILL.md +0 -52
- package/core/skills/tools/twitterX/scripts/abtars-tweet.js +0 -532
- package/core/skills/tools/twitterX/scripts/package.json +0 -1
- /package/bundle/{_registry.generated-6GO2PAMD.js.map → _registry.generated-4P6KTBTH.js.map} +0 -0
- /package/bundle/{agent-registry-SYUFNSVB.js.map → agent-registry-TM7EISOV.js.map} +0 -0
- /package/bundle/{browse-delivery-64GQIUHG.js.map → browse-delivery-VTLEAVYA.js.map} +0 -0
- /package/bundle/{browser-5H2Q7GEC.js.map → browser-JQGYFZAG.js.map} +0 -0
- /package/bundle/{commands-E3Y4QUNF.js.map → browser-M4KDLN75.js.map} +0 -0
- /package/bundle/{deploy-lib-import-ODLDL2DB.js.map → browser-REIXOJ6S.js.map} +0 -0
- /package/bundle/{install-RSLOS3Q5.js.map → browser-VG2GTEND.js.map} +0 -0
- /package/bundle/{chunk-KFENC7BM.js.map → chunk-4YOTNYAE.js.map} +0 -0
- /package/bundle/{chunk-PQ62LZNA.js.map → chunk-HEHD3GG5.js.map} +0 -0
- /package/bundle/{chunk-A5OJYQNU.js.map → chunk-HTGVYNPE.js.map} +0 -0
- /package/bundle/{chunk-ZVDVNSXK.js.map → chunk-J7CFCY4U.js.map} +0 -0
- /package/bundle/{message-pipeline-CFVO73CK.js.map → commands-J6JAZ7D2.js.map} +0 -0
- /package/bundle/{phase-transport-FEZ4SIJJ.js.map → deploy-lib-import-PJXUADPS.js.map} +0 -0
- /package/bundle/{discord-adapter-5DS7UTBE.js.map → discord-adapter-OCWSJTJU.js.map} +0 -0
- /package/bundle/{sleep-BPWX3FCN.js.map → install-6H3APAIJ.js.map} +0 -0
- /package/bundle/{soul-bundle-BRIUDEQ2.js.map → message-pipeline-TCPHRBAK.js.map} +0 -0
- /package/bundle/{soul-loader-GBXJ7EBH.js.map → phase-transport-ME2XDRR2.js.map} +0 -0
- /package/bundle/{subagent-runtime-MDBO6LHS.js.map → rollback-D7AYTC7Z.js.map} +0 -0
- /package/bundle/{task-store-KIBFZL5A.js.map → sleep-IOWYTSMK.js.map} +0 -0
- /package/bundle/{update-check-O5MS6B3L.js.map → soul-bundle-AH5S3MVI.js.map} +0 -0
- /package/bundle/{start-4IWBKLWO.js.map → start-CBVKNEAT.js.map} +0 -0
- /package/bundle/{telegram-adapter-MVA33IO2.js.map → telegram-adapter-QXHJQLLX.js.map} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
createAgentTransport,
|
|
5
5
|
createSubagentTransport
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J7CFCY4U.js";
|
|
7
7
|
import "./chunk-RV54J75Q.js";
|
|
8
8
|
import "./chunk-UDZIZB5F.js";
|
|
9
9
|
import "./chunk-MZWMYN4O.js";
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
createAgentTransport,
|
|
17
17
|
createSubagentTransport
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=agent-registry-
|
|
19
|
+
//# sourceMappingURL=agent-registry-TM7EISOV.js.map
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import {
|
|
4
4
|
checkBrowseTasks,
|
|
5
5
|
deliverBrowseResult
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-LDKSCXGL.js";
|
|
7
|
+
import "./chunk-HEHD3GG5.js";
|
|
8
8
|
import "./chunk-TBLYGCPQ.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-GPL57SRN.js";
|
|
10
10
|
import "./chunk-EX2SRTUE.js";
|
|
11
11
|
import "./chunk-2BY6I4P5.js";
|
|
12
12
|
import "./chunk-MJ6PHMOK.js";
|
|
@@ -15,4 +15,4 @@ export {
|
|
|
15
15
|
checkBrowseTasks,
|
|
16
16
|
deliverBrowseResult
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=browse-delivery-
|
|
18
|
+
//# sourceMappingURL=browse-delivery-VTLEAVYA.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
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);
|
|
3
3
|
import {
|
|
4
4
|
register
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-MNKLPRGY.js";
|
|
6
|
+
import "./chunk-LDKSCXGL.js";
|
|
7
|
+
import "./chunk-HEHD3GG5.js";
|
|
8
8
|
import "./chunk-TBLYGCPQ.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-GPL57SRN.js";
|
|
10
10
|
import "./chunk-KSEIWT4T.js";
|
|
11
11
|
import "./chunk-EX2SRTUE.js";
|
|
12
12
|
import "./chunk-PZE3J7ER.js";
|
|
@@ -16,4 +16,4 @@ import "./chunk-7K2YZTLD.js";
|
|
|
16
16
|
export {
|
|
17
17
|
register
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=browser-
|
|
19
|
+
//# sourceMappingURL=browser-JQGYFZAG.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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);
|
|
3
|
+
import {
|
|
4
|
+
register
|
|
5
|
+
} from "./chunk-O73EZGKR.js";
|
|
6
|
+
import "./chunk-LDKSCXGL.js";
|
|
7
|
+
import "./chunk-HEHD3GG5.js";
|
|
8
|
+
import "./chunk-TBLYGCPQ.js";
|
|
9
|
+
import "./chunk-GPL57SRN.js";
|
|
10
|
+
import "./chunk-KSEIWT4T.js";
|
|
11
|
+
import "./chunk-EX2SRTUE.js";
|
|
12
|
+
import "./chunk-PZE3J7ER.js";
|
|
13
|
+
import "./chunk-2BY6I4P5.js";
|
|
14
|
+
import "./chunk-MJ6PHMOK.js";
|
|
15
|
+
import "./chunk-7K2YZTLD.js";
|
|
16
|
+
export {
|
|
17
|
+
register
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=browser-M4KDLN75.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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);
|
|
3
|
+
import {
|
|
4
|
+
register
|
|
5
|
+
} from "./chunk-KJOCXWJ5.js";
|
|
6
|
+
import "./chunk-LDKSCXGL.js";
|
|
7
|
+
import "./chunk-HEHD3GG5.js";
|
|
8
|
+
import "./chunk-TBLYGCPQ.js";
|
|
9
|
+
import "./chunk-GPL57SRN.js";
|
|
10
|
+
import "./chunk-KSEIWT4T.js";
|
|
11
|
+
import "./chunk-EX2SRTUE.js";
|
|
12
|
+
import "./chunk-PZE3J7ER.js";
|
|
13
|
+
import "./chunk-2BY6I4P5.js";
|
|
14
|
+
import "./chunk-MJ6PHMOK.js";
|
|
15
|
+
import "./chunk-7K2YZTLD.js";
|
|
16
|
+
export {
|
|
17
|
+
register
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=browser-REIXOJ6S.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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);
|
|
3
|
+
import {
|
|
4
|
+
register
|
|
5
|
+
} from "./chunk-VYR25H37.js";
|
|
6
|
+
import "./chunk-LDKSCXGL.js";
|
|
7
|
+
import "./chunk-HEHD3GG5.js";
|
|
8
|
+
import "./chunk-TBLYGCPQ.js";
|
|
9
|
+
import "./chunk-GPL57SRN.js";
|
|
10
|
+
import "./chunk-KSEIWT4T.js";
|
|
11
|
+
import "./chunk-EX2SRTUE.js";
|
|
12
|
+
import "./chunk-PZE3J7ER.js";
|
|
13
|
+
import "./chunk-2BY6I4P5.js";
|
|
14
|
+
import "./chunk-MJ6PHMOK.js";
|
|
15
|
+
import "./chunk-7K2YZTLD.js";
|
|
16
|
+
export {
|
|
17
|
+
register
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=browser-VG2GTEND.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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);
|
|
3
3
|
import {
|
|
4
4
|
buildSoulBundle
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q7F5R2LL.js";
|
|
6
6
|
|
|
7
7
|
// src/components/soul-loader.ts
|
|
8
8
|
function loadSoulBundle(memory) {
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
loadSoulBundle,
|
|
17
17
|
loadMinimalSoul
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-4YOTNYAE.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/capabilities/sleep/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { logAndSwallow } from \"../../components/log-and-swallow.js\";\nimport { getEnv } from \"../../components/env-schema.js\";\nimport type { CapabilityApi } from \"../capability.js\";\n/**\n * Sleep capability \u2014 spawn nightly sleep cycle via tick system.\n * One path: BED_TIME + quiet ticks \u2192 Dreamy \u2192 quiet ticks \u2192 hardware sleep.\n * Parses PROGRESS:<pct>:<label> from stdout for visibility.\n */\n\nimport { execSync } from \"node:child_process\";\nimport { writeSleepStatus, readAndClearForceSleep } from \"../../components/transport/bridge-lock-transport.js\";\nimport { join } from \"node:path\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { Level } from \"abmind\";\nimport { abmind } from \"../../utils/abmind-lazy.js\";\nimport type { SleepRuntime } from \"abmind\";\nimport { logInfo, logWarn, logDebug } from \"../../components/logger.js\";\nimport { readEnv, readEnvWithDefault } from \"../../components/env.js\";\n\nconst TAG = \"sleep\";\n\nexport interface SleepOpts {\n sleepHour: number;\n sleepAuditDir: string;\n memoryEnabled: boolean;\n memoryDir?: string;\n /** LLM runtime adapter \u2014 bridge wraps its SubagentRuntime.complete(\"dreamy\", ...). */\n runtime: SleepRuntime;\n onComplete: () => void;\n getLastMsgTs?: () => number;\n sendSystemMessage?: (prompt: string) => Promise<void>;\n killWakeInhibit?: () => void;\n}\n\nexport interface SleepProgress {\n percent: number;\n step: string;\n}\n\nexport interface SleepHandle {\n /** True while a sleep cycle is running in-process. */\n readonly isActive: boolean;\n readonly progress: SleepProgress | null;\n readonly awaitingHwSleep: boolean;\n spawn(): void;\n /** Called by tick system to check if hardware sleep should fire. */\n checkHwSleep(): void;\n}\n\nconst MAX_RETRIES = 3;\nconst RETRY_MS = 5 * 60 * 1000;\n\nexport function createSleepHandle(opts: SleepOpts): SleepHandle {\n let running = false;\n let attempts = 0;\n let progress: SleepProgress | null = null;\n let _awaitingHwSleep = false;\n // Post-Dreamy hw-sleep quiet-tick tracking (internal to this closure \u2014 decoupled from\n // daily-cycle.quietTickCount which freezes once hasSleepAuditToday returns true).\n // Both reset when _awaitingHwSleep flips to true (see the onComplete handler below).\n let postSleepQuietTicks = 0;\n let lastMsgTsSeenByHwCheck = 0;\n\n function buildDreamReport(): string {\n let dreamReport = \"Dreamy finished nightly maintenance.\";\n try {\n const sleepDir = join(opts.memoryDir ?? \"\", \"sleep\");\n const dateStr = new Date().toISOString().slice(0, 10).replace(/-/g, \"\");\n const lockPath = join(sleepDir, `sleep_${dateStr}.lock`);\n if (existsSync(lockPath)) {\n const lockData = JSON.parse(readFileSync(lockPath, \"utf-8\")) as { steps: Record<string, { status: string }>; llmCalls?: number };\n const ok = Object.entries(lockData.steps).filter(([, s]) => s.status === \"ok\").map(([k]) => k);\n const skipped = Object.entries(lockData.steps).filter(([, s]) => s.status === \"skipped\").map(([k]) => k);\n const failed = Object.entries(lockData.steps).filter(([, s]) => s.status === \"failed\" || s.status === \"timeout\").map(([k]) => k);\n dreamReport = `Dreamy finished nightly maintenance (${lockData.llmCalls ?? \"?\"} LLM calls). Completed: ${ok.join(\", \") || \"none\"}.`;\n if (skipped.length > 0) dreamReport += ` Skipped: ${skipped.join(\", \")}.`;\n if (failed.length > 0) dreamReport += ` \u26A0\uFE0F FAILED: ${failed.join(\", \")}. Please review.`;\n }\n } catch (err) { logAndSwallow(\"index\", \"op\", err); }\n return dreamReport;\n }\n\n function spawnSleep(): void {\n const forceSleep = readAndClearForceSleep();\n const forced = forceSleep !== null;\n if (forced) {\n logInfo(\"sleep\", `\u26A1 forceSleep=${forceSleep} \u2014 bypassing time-window + audit-today guards`);\n }\n\n if (!forced) {\n const hour = new Date().getHours();\n const WAKE_HOUR = parseInt(readEnvWithDefault(\"WAKE_TIME\", \"7\", \"wake hour\").split(\":\")[0] ?? \"7\", 10);\n if (opts.sleepHour <= WAKE_HOUR) {\n if (hour < opts.sleepHour || hour >= WAKE_HOUR) {\n logDebug(\"sleep\", `\uD83D\uDE34 Outside sleep window (${opts.sleepHour}:00-${WAKE_HOUR}:00) \u2014 skip`);\n return;\n }\n } else {\n if (hour < opts.sleepHour && hour >= WAKE_HOUR) {\n logDebug(\"sleep\", `\uD83D\uDE34 Outside sleep window (${opts.sleepHour}:00-${WAKE_HOUR}:00) \u2014 skip`);\n return;\n }\n }\n if (abmind()?.hasSleepAuditToday(opts.sleepAuditDir)) {\n logDebug(\"sleep\", \"\uD83D\uDE34 Sleep already done today \u2014 skip\");\n return;\n }\n }\n if (running) return;\n attempts++;\n progress = null;\n running = true;\n writeSleepStatus(\"sleeping\");\n logInfo(\"sleep\", `\uD83D\uDE34 Sleep started in-process (attempt ${attempts}, model=dreamy)`);\n\n const level = (() => {\n if (forced && forceSleep?.includes(\"fresh\")) return \"ultimate\" as Level;\n const raw = getEnv().sleepQuality;\n if (!raw) return abmind()!.DEFAULT_LEVEL;\n try { return abmind()!.parseLevel(raw); }\n catch (err) { logWarn(\"sleep\", `Invalid SLEEP_QUALITY='${raw}', using ${abmind()!.DEFAULT_LEVEL}: ${err instanceof Error ? err.message : String(err)}`); return abmind()!.DEFAULT_LEVEL; }\n })();\n\n abmind()!.runSleepCycle({ runtime: opts.runtime, level })\n .then((result: { ok: boolean; failCount: number }) => {\n running = false;\n progress = null;\n logInfo(\"sleep\", `\uD83D\uDE34 Sleep finished (ok=${result.ok}, failCount=${result.failCount}, attempt ${attempts})`);\n writeSleepStatus(\"awake\");\n if (!result.ok) {\n if (attempts < MAX_RETRIES) {\n logWarn(\"sleep\", `\uD83D\uDE34 Sleep had ${result.failCount} failures (attempt ${attempts}/${MAX_RETRIES}) \u2014 retry in 5min`);\n setTimeout(spawnSleep, RETRY_MS);\n } else {\n logWarn(\"sleep\", `\uD83D\uDE34 Sleep failures persist \u2014 exhausted ${MAX_RETRIES} attempts`);\n }\n return;\n }\n\n if (opts.memoryEnabled) opts.onComplete();\n\n // Force-sleep runs are explicit test/verify triggers \u2014 skip hw-sleep even if env enabled.\n const hwEnabled = !forced && readEnv(\"HARDWARE_SLEEP_AFTER_DREAMY\", \"hardware sleep after Dreamy disabled\") === \"true\";\n const quietTicks = Math.ceil(getEnv().bedQuietMin * 60 / parseInt(readEnvWithDefault(\"HEARTBEAT_INTERVAL_SEC\", \"60\", \"hb\"), 10));\n const hbInterval = parseInt(readEnvWithDefault(\"HEARTBEAT_INTERVAL_SEC\", \"60\", \"heartbeat tick interval\"), 10);\n const hwSleepMin = Math.round(quietTicks * hbInterval / 60);\n\n const dreamReport = buildDreamReport();\n const sleepNote = hwEnabled ? ` Hardware sleep in ~${hwSleepMin} minutes if no activity.` : \"\";\n\n if (opts.sendSystemMessage) {\n opts.sendSystemMessage(`${dreamReport}${sleepNote}`).catch(err => logAndSwallow(TAG, \"sendSystemMessage dream report\", err));\n }\n\n if (hwEnabled) {\n _awaitingHwSleep = true;\n // Reset hw-check counters \u2014 prevents stale state from a prior cycle (crash, force-sleep\n // re-run) from poisoning this one, and avoids burning the first tick on a spurious\n // reset when the very first checkHwSleep() sees currentMsgTs > 0.\n postSleepQuietTicks = 0;\n lastMsgTsSeenByHwCheck = opts.getLastMsgTs?.() ?? 0;\n logInfo(\"sleep\", `\uD83D\uDCA4 Awaiting hardware sleep \u2014 ${quietTicks} quiet ticks (${hwSleepMin} min) required`);\n }\n })\n .catch((err: unknown) => {\n running = false;\n progress = null;\n writeSleepStatus(\"awake\");\n const msg = err instanceof Error ? err.message : String(err);\n if (attempts < MAX_RETRIES) {\n logWarn(\"sleep\", `\uD83D\uDE34 Sleep threw (attempt ${attempts}/${MAX_RETRIES}): ${msg} \u2014 retry in 5min`);\n setTimeout(spawnSleep, RETRY_MS);\n } else {\n logWarn(\"sleep\", `\uD83D\uDE34 Sleep threw \u2014 exhausted ${MAX_RETRIES} attempts: ${msg}`);\n }\n });\n }\n\n function checkHwSleep(): void {\n if (!_awaitingHwSleep) return;\n\n // Sleep-window cutoff \u2014 give up if we've crossed out of the window. Next night retries.\n // Mirrors spawnSleep()'s window logic for consistency.\n const WAKE_HOUR = parseInt(readEnvWithDefault(\"WAKE_TIME\", \"7\", \"wake hour\").split(\":\")[0] ?? \"7\", 10);\n const BED_HOUR = opts.sleepHour;\n const hour = new Date().getHours();\n const inSleepWindow = (BED_HOUR < WAKE_HOUR)\n ? (hour >= BED_HOUR && hour < WAKE_HOUR) // normal: BED=00:30, WAKE=07:00 \u2192 sleep 00-06\n : (hour >= BED_HOUR || hour < WAKE_HOUR); // overnight: BED=23:00, WAKE=07:00 \u2192 sleep 23-06\n if (!inSleepWindow) {\n logInfo(\"sleep\", `\u23F0 Past sleep window (now ${hour}:00, window ${BED_HOUR}:00-${WAKE_HOUR}:00) \u2014 abandoning hw-sleep attempt`);\n _awaitingHwSleep = false;\n postSleepQuietTicks = 0;\n return;\n }\n\n // User messaged since last check \u2014 postpone and reset\n const currentMsgTs = opts.getLastMsgTs?.() ?? 0;\n if (currentMsgTs > lastMsgTsSeenByHwCheck) {\n lastMsgTsSeenByHwCheck = currentMsgTs;\n postSleepQuietTicks = 0;\n logInfo(\"sleep\", \"\uD83D\uDCA4 Hardware sleep postponed \u2014 user messaged (will retry after quiet period)\");\n return;\n }\n\n // Quiet tick \u2014 increment\n const requiredTicks = Math.ceil(getEnv().bedQuietMin * 60 / parseInt(process.env[\"HEARTBEAT_INTERVAL_SEC\"] ?? \"60\", 10));\n postSleepQuietTicks++;\n if (postSleepQuietTicks < requiredTicks) return;\n\n // Threshold reached \u2014 sleep\n _awaitingHwSleep = false;\n postSleepQuietTicks = 0;\n // Kill any wake inhibitor from /wakeup before sleeping\n opts.killWakeInhibit?.();\n const sleepCmd = process.platform === \"darwin\" ? \"pmset sleepnow\" : \"systemctl suspend\";\n logInfo(\"sleep\", `\uD83D\uDCA4 Putting hardware to sleep (${sleepCmd})...`);\n writeSleepStatus(\"hw_sleep\");\n try { execSync(sleepCmd, { timeout: 5000 }); }\n catch (err) {\n writeSleepStatus(\"awake\"); // recover \u2014 don't leave \"hw_sleep\" if pmset failed\n logWarn(\"sleep\", `\uD83D\uDCA4 Hardware sleep failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n return {\n get isActive() { return running; },\n get progress() { return progress; },\n get awaitingHwSleep() { return _awaitingHwSleep; },\n spawn: spawnSleep,\n checkHwSleep,\n };\n}\n\n/** Capability registration \u2014 called by discoverCapabilities(). */\nexport function register(_api: CapabilityApi): void {\n // Sleep registration is a no-op here \u2014 the actual SleepHandle is created\n // in phase-sleep.ts because it needs ctx.sendSystemMessage + memory deps\n // that aren't available at capability discovery time.\n // This manifest exists so sleep appears in discoverCapabilities() and\n // can be disabled via DISABLED_CAPABILITIES=sleep.\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAQA,SAAS,gBAAgB;AAEzB,SAAS,YAAY;AACrB,SAAS,YAAY,oBAAoB;AAIzC;AAGA,IAAM,MAAM;AA8BZ,IAAM,cAAc;AACpB,IAAM,WAAW,IAAI,KAAK;AAEnB,SAAS,kBAAkB,MAA8B;AAC9D,MAAI,UAAU;AACd,MAAI,WAAW;AACf,MAAI,WAAiC;AACrC,MAAI,mBAAmB;AAIvB,MAAI,sBAAsB;AAC1B,MAAI,yBAAyB;AAE7B,WAAS,mBAA2B;AAClC,QAAI,cAAc;AAClB,QAAI;AACF,YAAM,WAAW,KAAK,KAAK,aAAa,IAAI,OAAO;AACnD,YAAM,WAAU,oBAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,MAAM,EAAE;AACtE,YAAM,WAAW,KAAK,UAAU,SAAS,OAAO,OAAO;AACvD,UAAI,WAAW,QAAQ,GAAG;AACxB,cAAM,WAAW,KAAK,MAAM,aAAa,UAAU,OAAO,CAAC;AAC3D,cAAM,KAAK,OAAO,QAAQ,SAAS,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7F,cAAM,UA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AAQ,OAAO,SAAS,yCAAoC;AAC5H,yBAAmB;AACnB,4BAAsB;AACtB;AAAA,IACF;AAGA,UAAM,eAAe,KAAK,eAAe,KAAK;AAC9C,QAAI,eAAe,wBAAwB;AACzC,+BAAyB;AACzB,4BAAsB;AACtB,cAAQ,SAAS,yFAA6E;AAC9F;AAAA,IACF;AAGA,UAAM,gBAAgB,KAAK,KAAK,OAAO,EAAE,cAAc,KAAK,SAAS,QAAQ,IAAI,wBAAwB,KAAK,MAAM,EAAE,CAAC;AACvH;AACA,QAAI,sBAAsB,cAAe;AAGzC,uBAAmB;AACnB,0BAAsB;AAEtB,SAAK,kBAAkB;AACvB,UAAM,WAAW,QAAQ,aAAa,WAAW,mBAAmB;AACpE,YAAQ,SAAS,wCAAiC,QAAQ,MAAM;AAChE,qBAAiB,UAAU;AAC3B,QAAI;AAAE,eAAS,UAAU,EAAE,SAAS,IAAK,CAAC;AAAA,IAAG,SACtC,KAAK;AACV,uBAAiB,OAAO;AACxB,cAAQ,SAAS,oCAA6B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAAA,IAClG;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI,WAAW;AAAE,aAAO;AAAA,IAAS;AAAA,IACjC,IAAI,WAAW;AAAE,aAAO;AAAA,IAAU;AAAA,IAClC,IAAI,kBAAkB;AAAE,aAAO;AAAA,IAAkB;AAAA,IACjD,OAAO;AAAA,IACP;AAAA,EACF;AACF;AAGO,SAAS,SAAS,MAA2B;AAMpD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -151,15 +151,15 @@ var SubagentRuntime = class {
|
|
|
151
151
|
return true;
|
|
152
152
|
}
|
|
153
153
|
async createAgent(agent, sessionType) {
|
|
154
|
-
const { createSubagentTransport } = await import("./agent-registry-
|
|
154
|
+
const { createSubagentTransport } = await import("./agent-registry-TM7EISOV.js");
|
|
155
155
|
const role = AGENT_TO_ROLE[agent];
|
|
156
156
|
const mainModel = this._mainTransport && "currentModel" in this._mainTransport ? this._mainTransport.currentModel : void 0;
|
|
157
157
|
const { transport, model } = await createSubagentTransport(role, this._registry ?? void 0, mainModel);
|
|
158
158
|
const typeMap = { browsie: "B", coding: "C", task: "T" };
|
|
159
159
|
const resolvedType = sessionType || typeMap[agent];
|
|
160
160
|
if (resolvedType && "setSystemPrompt" in transport && typeof transport.setSystemPrompt === "function") {
|
|
161
|
-
const { buildSoulBundle } = await import("./soul-bundle-
|
|
162
|
-
const bundle = buildSoulBundle(
|
|
161
|
+
const { buildSoulBundle } = await import("./soul-bundle-AH5S3MVI.js");
|
|
162
|
+
const bundle = buildSoulBundle(resolvedType);
|
|
163
163
|
if (bundle) transport.setSystemPrompt(bundle);
|
|
164
164
|
}
|
|
165
165
|
const sessionKey = `system:${agent}`;
|
|
@@ -180,4 +180,4 @@ var AGENT_TO_ROLE = {
|
|
|
180
180
|
export {
|
|
181
181
|
SubagentRuntime
|
|
182
182
|
};
|
|
183
|
-
//# sourceMappingURL=chunk-
|
|
183
|
+
//# sourceMappingURL=chunk-CNWXVXGH.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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, opts?.sessionType);\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, sessionType?: import(\"./session-manager.js\").SessionType): 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 // Inject session-type-appropriate SOUL bundle (#744)\n const typeMap: Partial<Record<AgentName, import(\"./session-manager.js\").SessionType>> = { browsie: \"B\", coding: \"C\", task: \"T\" };\n const resolvedType = sessionType || typeMap[agent];\n if (resolvedType && \"setSystemPrompt\" in transport && typeof (transport as any).setSystemPrompt === \"function\") {\n const { buildSoulBundle } = await import(\"./soul-bundle.js\");\n const bundle = buildSoulBundle(
|
|
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,oBAAI,IAA4B;AAAA,EACxC,eAAe,oBAAI,IAA2D;AAAA,EACvF,YAAwC;AAAA,EACxC,iBAAwC;AAAA,EACxC,kBAAwE;AAAA;AAAA,EAGhF,YAAY,UAAqC;AAAE,SAAK,YAAY;AAAA,EAAU;AAAA;AAAA,EAG9E,iBAAiB,WAAiC;AAAE,SAAK,iBAAiB;AAAA,EAAW;AAAA;AAAA,EAGrF,kBAAkB,KAA0D;AAAE,SAAK,kBAAkB;AAAA,EAAK;AAAA;AAAA,EAG1G,MAAM,SAAS,OAAkB,QAAgB,MAAmC;AAClF,UAAM,kBAAkB,MAAM,WAAW,gBAAgB,KAAK,KAAK;AACnE,UAAM,QAAQ,KAAK,IAAI;AAEvB,UAAM,SAAS,KAAK,MAAM,IAAI,KAAK;AACnC,QAAI,UAAU,oBAAoB,SAAS;AACzC,YAAM,OAAO,UAAU,eAAe,OAAO,UAAU;AACvD,OAAC,MAAM,OAAO,6BAA8B,GAAG,kBAAkB;AAAA,IACnE;AAEA,UAAM,EAAE,WAAW,OAAO,WAAW,IAAI,UAAU,MAAM,KAAK,YAAY,OAAO,M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mBAAmB;AAAA,IACzC;AACA,SAAK,MAAM,MAAM;AAAA,EACnB;AAAA;AAAA,EAGA,aAA2D;AACzD,WAAO,CAAC,GAAG,KAAK,aAAa,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO;AAAA,MAChE;AAAA,MACA,WAAY,MAAc,aAAa;AAAA,IACzC,EAAE;AAAA,EACJ;AAAA;AAAA,EAGA,eAAe,QAAyB;AACtC,UAAM,QAAQ,KAAK,aAAa,IAAI,MAAM;AAC1C,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,MAAM,MAAM;AAClB,SAAK,aAAa,OAAO,MAAM;AAC/B,YAAQ,KAAK,SAAS,MAAM,cAAc;AAC1C,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,YAAY,OAAkB,aAAgF;AAC1H,UAAM,EAAE,wBAAwB,IAAI,MAAM,OAAO,8BAAqB;AACtE,UAAM,OAAO,cAAc,KAAK;AAChC,UAAM,YAAY,KAAK,kBAAkB,kBAAkB,KAAK,iBAC3D,KAAK,eAAuD,eAC7D;AACJ,UAAM,EAAE,WAAW,MAAM,IAAI,MAAM,wBAAwB,MAAM,KAAK,aAAa,QAAW,SAAS;AAGvG,UAAM,UAAkF,EAAE,SAAS,KAAK,QAAQ,KAAK,MAAM,IAAI;AAC/H,UAAM,eAAe,eAAe,QAAQ,KAAK;AACjD,QAAI,gBAAgB,qBAAqB,aAAa,OAAQ,UAAkB,oBAAoB,YAAY;AAC9G,YAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,2BAAkB;AAC3D,YAAM,SAAS,gBAAgB,
|
|
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, opts?.sessionType);\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, sessionType?: import(\"./session-manager.js\").SessionType): 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 // Inject session-type-appropriate SOUL bundle (#744)\n const typeMap: Partial<Record<AgentName, import(\"./session-manager.js\").SessionType>> = { browsie: \"B\", coding: \"C\", task: \"T\" };\n const resolvedType = sessionType || typeMap[agent];\n if (resolvedType && \"setSystemPrompt\" in transport && typeof (transport as any).setSystemPrompt === \"function\") {\n const { buildSoulBundle } = await import(\"./soul-bundle.js\");\n const bundle = buildSoulBundle(resolvedType);\n if (bundle) (transport as any).setSystemPrompt(bundle);\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 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,oBAAI,IAA4B;AAAA,EACxC,eAAe,oBAAI,IAA2D;AAAA,EACvF,YAAwC;AAAA,EACxC,iBAAwC;AAAA,EACxC,kBAAwE;AAAA;AAAA,EAGhF,YAAY,UAAqC;AAAE,SAAK,YAAY;AAAA,EAAU;A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AwB,MAAM,KAAK,aAAa,QAAW,SAAS;AAGvG,UAAM,UAAkF,EAAE,SAAS,KAAK,QAAQ,KAAK,MAAM,IAAI;AAC/H,UAAM,eAAe,eAAe,QAAQ,KAAK;AACjD,QAAI,gBAAgB,qBAAqB,aAAa,OAAQ,UAAkB,oBAAoB,YAAY;AAC9G,YAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,2BAAkB;AAC3D,YAAM,SAAS,gBAAgB,YAAY;AAC3C,UAAI,OAAQ,CAAC,UAAkB,gBAAgB,MAAM;AAAA,IACvD;AAEA,UAAM,aAAa,UAAU,KAAK;AAClC,UAAM,QAAqB,EAAE,WAAW,OAAO,WAAW;AAC1D,SAAK,MAAM,IAAI,OAAO,KAAK;AAC3B,KAAC,MAAM,OAAO,6BAA8B,GAAG,kBAAkB;AACjE,WAAO;AAAA,EACT;AACF;AAEA,IAAM,gBAA+E;AAAA,EACnF,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,41 +36,55 @@ function writeCache(data) {
|
|
|
36
36
|
} catch {
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function fetchLatest(pkg) {
|
|
39
|
+
function fetchLatest(pkg, currentVersion) {
|
|
40
40
|
try {
|
|
41
|
+
if (currentVersion.includes("-alpha") || currentVersion.includes("-beta")) {
|
|
42
|
+
const raw = execFileSync("npm", ["view", pkg, "dist-tags", "--json"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
43
|
+
const tags = JSON.parse(raw);
|
|
44
|
+
return tags.alpha ?? tags.latest ?? null;
|
|
45
|
+
}
|
|
41
46
|
return execFileSync("npm", ["view", pkg, "version"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
42
47
|
} catch {
|
|
43
48
|
return null;
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
function isNewer(a, b) {
|
|
47
|
-
const
|
|
48
|
-
|
|
52
|
+
const parseVer = (v) => {
|
|
53
|
+
const [base, preStr] = v.split("-alpha.");
|
|
54
|
+
return { parts: (base ?? "").split(".").map(Number), pre: preStr != null ? Number(preStr) : null };
|
|
55
|
+
};
|
|
56
|
+
const va = parseVer(a);
|
|
57
|
+
const vb = parseVer(b);
|
|
49
58
|
for (let i = 0; i < 3; i++) {
|
|
50
|
-
if ((
|
|
51
|
-
if ((
|
|
59
|
+
if ((va.parts[i] ?? 0) > (vb.parts[i] ?? 0)) return true;
|
|
60
|
+
if ((va.parts[i] ?? 0) < (vb.parts[i] ?? 0)) return false;
|
|
52
61
|
}
|
|
62
|
+
if (va.pre === null && vb.pre !== null) return true;
|
|
63
|
+
if (va.pre !== null && vb.pre === null) return false;
|
|
64
|
+
if (va.pre !== null && vb.pre !== null) return va.pre > vb.pre;
|
|
53
65
|
return false;
|
|
54
66
|
}
|
|
55
67
|
function checkForUpdate(pkg, currentVersion, opts) {
|
|
68
|
+
if (process.env.UPDATE_NOTIFICATION === "OFF") return null;
|
|
56
69
|
const ttlMs = opts?.ttlMs ?? DEFAULT_TTL_MS;
|
|
57
70
|
const cache = readCache(ttlMs);
|
|
58
|
-
const latest = cache?.latest ?? fetchLatest(pkg);
|
|
71
|
+
const latest = cache?.latest ?? fetchLatest(pkg, currentVersion);
|
|
59
72
|
if (!latest) return null;
|
|
60
|
-
const now = Date.now();
|
|
61
73
|
const updateAvailable = isNewer(latest, currentVersion);
|
|
62
|
-
const shouldNotify = updateAvailable &&
|
|
63
|
-
const newCache = {
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
const shouldNotify = updateAvailable && cache?.lastNotifiedVersion !== latest;
|
|
75
|
+
const newCache = {
|
|
76
|
+
ts: Date.now(),
|
|
77
|
+
latest,
|
|
78
|
+
lastNotifiedVersion: shouldNotify ? latest : cache?.lastNotifiedVersion
|
|
79
|
+
};
|
|
80
|
+
if (!cache || shouldNotify) writeCache(newCache);
|
|
66
81
|
return { current: currentVersion, latest, updateAvailable, shouldNotify };
|
|
67
82
|
}
|
|
68
|
-
var DEFAULT_TTL_MS
|
|
83
|
+
var DEFAULT_TTL_MS;
|
|
69
84
|
var init_update_check = __esm({
|
|
70
85
|
"src/components/update-check.ts"() {
|
|
71
86
|
init_paths();
|
|
72
87
|
DEFAULT_TTL_MS = 6 * 60 * 6e4;
|
|
73
|
-
NOTIFY_COOLDOWN_MS = 24 * 60 * 6e4;
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
|
|
@@ -79,4 +93,4 @@ export {
|
|
|
79
93
|
update_check_exports,
|
|
80
94
|
init_update_check
|
|
81
95
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-CU3O53U3.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/update-check.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * update-check.ts \u2014 Check npm registry for newer abtars versions (#440, #588, #806).\n * Once-per-release notification. No daily nagging. Env: UPDATE_NOTIFICATION=OFF to disable.\n */\n\nimport { execFileSync } from \"node:child_process\";\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { abtarsHome } from \"../paths.js\";\n\nconst DEFAULT_TTL_MS = 6 * 60 * 60_000; // 6h\n\ninterface CacheData {\n ts: number;\n latest: string;\n lastNotifiedVersion?: string;\n}\n\nfunction cachePath(): string {\n const dir = join(abtarsHome(), \"state\");\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n return join(dir, \"update-check.json\");\n}\n\nfunction readCache(ttlMs: number): CacheData | null {\n try {\n const data = JSON.parse(readFileSync(cachePath(), \"utf-8\")) as CacheData;\n if (Date.now() - data.ts < ttlMs) return data;\n } catch { /* missing or corrupt */ }\n return null;\n}\n\nfunction writeCache(data: CacheData): void {\n try { writeFileSync(cachePath(), JSON.stringify(data), \"utf-8\"); } catch { /* non-critical */ }\n}\n\n/** Fetch the appropriate version from npm based on whether we're running a prerelease. */\nfunction fetchLatest(pkg: string, currentVersion: string): string | null {\n try {\n // If running a prerelease, compare against alpha tag\n if (currentVersion.includes(\"-alpha\") || currentVersion.includes(\"-beta\")) {\n const raw = execFileSync(\"npm\", [\"view\", pkg, \"dist-tags\", \"--json\"], { encoding: \"utf-8\", timeout: 10_000 }).trim();\n const tags = JSON.parse(raw) as Record<string, string>;\n return tags.alpha ?? tags.latest ?? null;\n }\n return execFileSync(\"npm\", [\"view\", pkg, \"version\"], { encoding: \"utf-8\", timeout: 10_000 }).trim();\n } catch {\n return null;\n }\n}\n\n/** True if a is newer than b. Handles prerelease: strips -alpha.N, compares base, then prerelease number. */\nfunction isNewer(a: string, b: string): boolean {\n const parseVer = (v: string): { parts: number[]; pre: number | null } => {\n const [base, preStr] = v.split(\"-alpha.\");\n return { parts: (base ?? \"\").split(\".\").map(Number), pre: preStr != null ? Number(preStr) : null };\n };\n const va = parseVer(a);\n const vb = parseVer(b);\n // Compare base version\n for (let i = 0; i < 3; i++) {\n if ((va.parts[i] ?? 0) > (vb.parts[i] ?? 0)) return true;\n if ((va.parts[i] ?? 0) < (vb.parts[i] ?? 0)) return false;\n }\n // Same base \u2014 compare prerelease (null = stable > any alpha)\n if (va.pre === null && vb.pre !== null) return true; // stable > alpha\n if (va.pre !== null && vb.pre === null) return false; // alpha < stable\n if (va.pre !== null && vb.pre !== null) return va.pre > vb.pre;\n return false;\n}\n\nexport interface UpdateCheckResult {\n current: string;\n latest: string;\n updateAvailable: boolean;\n shouldNotify: boolean;\n}\n\n/**\n * Check if a newer version is available on npm.\n * Returns null if check is skipped (cached fresh / offline / npm not found / notifications off).\n */\nexport function checkForUpdate(pkg: string, currentVersion: string, opts?: { ttlMs?: number }): UpdateCheckResult | null {\n // Env kill-switch\n if (process.env.UPDATE_NOTIFICATION === \"OFF\") return null;\n\n const ttlMs = opts?.ttlMs ?? DEFAULT_TTL_MS;\n const cache = readCache(ttlMs);\n const latest = cache?.latest ?? fetchLatest(pkg, currentVersion);\n if (!latest) return null;\n\n const updateAvailable = isNewer(latest, currentVersion);\n // Notify once per release: only if latest !== lastNotifiedVersion\n const shouldNotify = updateAvailable && cache?.lastNotifiedVersion !== latest;\n\n const newCache: CacheData = {\n ts: Date.now(),\n latest,\n lastNotifiedVersion: shouldNotify ? latest : cache?.lastNotifiedVersion,\n };\n if (!cache || shouldNotify) writeCache(newCache);\n\n return { current: currentVersion, latest, updateAvailable, shouldNotify };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAKA,SAAS,oBAAoB;AAC7B,SAAS,cAAc,eAAe,WAAW,kBAAkB;AACnE,SAAS,YAAY;AAWrB,SAAS,YAAoB;AAC3B,QAAM,MAAM,KAAK,WAAW,GAAG,OAAO;AACtC,MAAI,CAAC,WAAW,GAAG,EAAG,WAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AACxD,SAAO,KAAK,KAAK,mBAAmB;AACtC;AAEA,SAAS,UAAU,OAAiC;AAClD,MAAI;AACF,UAAM,OAAO,KAAK,MAAM,aAAa,UAAU,GAAG,OAAO,CAAC;AAC1D,QAAI,KAAK,IAAI,IAAI,KAAK,KAAK,MAAO,QAAO;AAAA,EAC3C,QAAQ;AAAA,EAA2B;AACnC,SAAO;AACT;AAEA,SAAS,WAAW,MAAuB;AACzC,MAAI;AAAE,kBAAc,UAAU,GAAG,KAAK,UAAU,IAAI,GAAG,OAAO;AAAA,EAAG,QAAQ;AAAA,EAAqB;AAChG;AAGA,SAAS,YAAY,KAAa,gBAAuC;AACvE,MAAI;AAEF,QAAI,eAAe,SAAS,QAAQ,KAAK,eAAe,SAAS,OAAO,GAAG;AACzE,YAAM,MAAM,aAAa,OAAO,CAAC,QAAQ,KAAK,aAAa,QAAQ,GAAG,EAAE,UAAU,SAAS,SAAS,IAAO,CAAC,EAAE,KAAK;AACnH,YAAM,OAAO,K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,eAAe,mBAAmB,OAAO,wBAAwB;AAEvE,QAAM,WAAsB;AAAA,IAC1B,IAAI,KAAK,IAAI;AAAA,IACb;AAAA,IACA,qBAAqB,eAAe,SAAS,OAAO;AAAA,EACtD;AACA,MAAI,CAAC,SAAS,aAAc,YAAW,QAAQ;AAE/C,SAAO,EAAE,SAAS,gBAAgB,QAAQ,iBAAiB,aAAa;AAC1E;AAvGA,IAUM;AAVN;AAAA;AAQA;AAEA,IAAM,iBAAiB,IAAI,KAAK;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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);
|
|
3
|
+
import {
|
|
4
|
+
acquireLock,
|
|
5
|
+
healthProbe,
|
|
6
|
+
packagePaths,
|
|
7
|
+
readManifest,
|
|
8
|
+
writeManifest
|
|
9
|
+
} from "./chunk-JRK3UFBS.js";
|
|
10
|
+
|
|
11
|
+
// src/cli/commands/rollback.ts
|
|
12
|
+
import { existsSync, renameSync, rmSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
async function rollback(opts) {
|
|
15
|
+
const paths = packagePaths("abtars");
|
|
16
|
+
const manifest = await readManifest(paths.manifest);
|
|
17
|
+
const slot = opts?.to ?? 1;
|
|
18
|
+
if (slot < 1 || slot > 3) {
|
|
19
|
+
process.stderr.write(`Invalid --to value: ${slot}. Must be 1-3.
|
|
20
|
+
`);
|
|
21
|
+
return 2;
|
|
22
|
+
}
|
|
23
|
+
const prevDir = join(paths.home, `app.prev.${slot}`);
|
|
24
|
+
const legacyPrev = paths.appPrev;
|
|
25
|
+
if (slot === 1 && !existsSync(prevDir) && existsSync(legacyPrev)) {
|
|
26
|
+
renameSync(legacyPrev, prevDir);
|
|
27
|
+
}
|
|
28
|
+
if (!existsSync(prevDir)) {
|
|
29
|
+
process.stderr.write(`Nothing to roll back to (no app.prev.${slot}/ found).
|
|
30
|
+
`);
|
|
31
|
+
return 2;
|
|
32
|
+
}
|
|
33
|
+
if (!manifest?.version) {
|
|
34
|
+
process.stderr.write(`No active release in manifest; nothing to roll back.
|
|
35
|
+
`);
|
|
36
|
+
return 2;
|
|
37
|
+
}
|
|
38
|
+
const release = await acquireLock(paths.lock, "rollback");
|
|
39
|
+
try {
|
|
40
|
+
const brokenDir = join(paths.home, "app.broken");
|
|
41
|
+
rmSync(brokenDir, { recursive: true, force: true });
|
|
42
|
+
renameSync(paths.app, brokenDir);
|
|
43
|
+
renameSync(prevDir, paths.app);
|
|
44
|
+
rmSync(brokenDir, { recursive: true, force: true });
|
|
45
|
+
process.stdout.write(`\u2713 rolled back: app.prev.${slot}/ \u2192 app/
|
|
46
|
+
`);
|
|
47
|
+
if (manifest.previousVersion) {
|
|
48
|
+
await writeManifest(paths.manifest, {
|
|
49
|
+
...manifest,
|
|
50
|
+
version: manifest.previousVersion,
|
|
51
|
+
commit: manifest.previousCommit,
|
|
52
|
+
activatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
53
|
+
previousVersion: manifest.version,
|
|
54
|
+
previousCommit: manifest.commit
|
|
55
|
+
});
|
|
56
|
+
process.stdout.write(`\u2713 manifest: ${manifest.version} \u2192 ${manifest.previousVersion}
|
|
57
|
+
`);
|
|
58
|
+
}
|
|
59
|
+
const restartTs = Date.now();
|
|
60
|
+
const { restart } = await import("./abtars-restart.js");
|
|
61
|
+
process.stdout.write(`\u267B\uFE0F Restarting bridge...
|
|
62
|
+
`);
|
|
63
|
+
await restart({ cold: true }).catch(() => {
|
|
64
|
+
});
|
|
65
|
+
const health = await healthProbe(paths.home, restartTs, 6e4);
|
|
66
|
+
if (health.healthy) {
|
|
67
|
+
process.stdout.write(`\u2713 Bridge healthy (PID ${health.pid})
|
|
68
|
+
`);
|
|
69
|
+
} else {
|
|
70
|
+
process.stderr.write(`\u26A0\uFE0F Bridge may not have started. Check logs.
|
|
71
|
+
`);
|
|
72
|
+
}
|
|
73
|
+
process.stdout.write(`
|
|
74
|
+
Rollback complete.
|
|
75
|
+
`);
|
|
76
|
+
return 0;
|
|
77
|
+
} finally {
|
|
78
|
+
await release();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
rollback
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=chunk-EZZBO2QK.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli/commands/rollback.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * `abtars rollback` \u2014 swap app/ with a prior version, restart, health-verify.\n * --to N (1-3, default 1) selects which prior to restore.\n */\n\nimport { existsSync, renameSync, rmSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n acquireLock,\n healthProbe,\n packagePaths,\n readManifest,\n writeManifest,\n} from '../deploy-lib-import.js';\n\nexport async function rollback(opts?: { to?: number }): Promise<number> {\n const paths = packagePaths('abtars');\n const manifest = await readManifest(paths.manifest);\n const slot = opts?.to ?? 1;\n\n if (slot < 1 || slot > 3) {\n process.stderr.write(`Invalid --to value: ${slot}. Must be 1-3.\\n`);\n return 2;\n }\n\n const prevDir = join(paths.home, `app.prev.${slot}`);\n\n // Backward compat: check old app.prev/ if slot 1 and new format doesn't exist\n const legacyPrev = paths.appPrev;\n if (slot === 1 && !existsSync(prevDir) && existsSync(legacyPrev)) {\n renameSync(legacyPrev, prevDir);\n }\n\n if (!existsSync(prevDir)) {\n process.stderr.write(`Nothing to roll back to (no app.prev.${slot}/ found).\\n`);\n return 2;\n }\n\n if (!manifest?.version) {\n process.stderr.write(`No active release in manifest; nothing to roll back.\\n`);\n return 2;\n }\n\n const release = await acquireLock(paths.lock, 'rollback');\n try {\n // Swap: app/ \u2192 app.broken/, app.prev.N/ \u2192 app/\n const brokenDir = join(paths.home, 'app.broken');\n rmSync(brokenDir, { recursive: true, force: true });\n renameSync(paths.app, brokenDir);\n renameSync(prevDir, paths.app);\n rmSync(brokenDir, { recursive: true, force: true });\n process.stdout.write(`\u2713 rolled back: app.prev.${slot}/ \u2192 app/\\n`);\n\n // Update manifest (swap version \u2194 previousVersion)\n if (manifest.previousVersion) {\n await writeManifest(paths.manifest, {\n ...manifest,\n version: manifest.previousVersion,\n commit: manifest.previousCommit,\n activatedAt: new Date().toISOString(),\n previousVersion: manifest.version,\n previousCommit: manifest.commit,\n });\n process.stdout.write(`\u2713 manifest: ${manifest.version} \u2192 ${manifest.previousVersion}\\n`);\n }\n\n // Restart bridge\n const restartTs = Date.now();\n const { restart } = await import('./restart.js');\n process.stdout.write(`\u267B\uFE0F Restarting bridge...\\n`);\n await restart({ cold: true }).catch(() => {});\n\n // Health probe\n const health = await healthProbe(paths.home, restartTs, 60_000);\n if (health.healthy) {\n process.stdout.write(`\u2713 Bridge healthy (PID ${health.pid})\\n`);\n } else {\n process.stderr.write(`\u26A0\uFE0F Bridge may not have started. Check logs.\\n`);\n }\n\n process.stdout.write(`\\nRollback complete.\\n`);\n return 0;\n } finally {\n await release();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAKA,SAAS,YAAY,YAAY,cAAc;AAC/C,SAAS,YAAY;AASrB,eAAsB,SAAS,MAAyC;AACtE,QAAM,QAAQ,aAAa,QAAQ;AACnC,QAAM,WAAW,MAAM,aAAa,MAAM,QAAQ;AAClD,QAAM,OAAO,MAAM,MAAM;AAEzB,MAAI,OAAO,KAAK,OAAO,GAAG;AACxB,YAAQ,OAAO,MAAM,uBAAuB,IAAI;AAAA,CAAkB;AAClE,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,KAAK,MAAM,MAAM,YAAY,IAAI,EAAE;AAGnD,QAAM,aAA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QAAI,OAAO,SAAS;AAClB,cAAQ,OAAO,MAAM,8BAAyB,OAAO,GAAG;AAAA,CAAK;AAAA,IAC/D,OAAO;AACL,cAAQ,OAAO,MAAM;AAAA,CAA+C;AAAA,IACtE;AAEA,YAAQ,OAAO,MAAM;AAAA;AAAA,CAAwB;AAC7C,WAAO;AAAA,EACT,UAAE;AACA,UAAM,QAAQ;AAAA,EAChB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -15,7 +15,7 @@ init_log_and_swallow();
|
|
|
15
15
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from "node:fs";
|
|
16
16
|
import { join, dirname } from "node:path";
|
|
17
17
|
var TAG = "task_store";
|
|
18
|
-
var storePath = () => join(abtarsHome(), "
|
|
18
|
+
var storePath = () => join(abtarsHome(), "tasks", "tasks.json");
|
|
19
19
|
function readAll() {
|
|
20
20
|
const p = storePath();
|
|
21
21
|
if (!existsSync(p)) return [];
|
|
@@ -75,4 +75,4 @@ export {
|
|
|
75
75
|
recordRun,
|
|
76
76
|
closeDb
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-GPL57SRN.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/tasks/task-store.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * task-store.ts \u2014 JSON-backed task entry storage.\n * File: ~/.abtars/config/tasks.json\n * Same API surface for callers.\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type { CronEntry } from \"../../cli/abtars-task.js\";\nimport { abtarsHome } from \"../../paths.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\n\nconst TAG = \"task_store\";\n\nconst storePath = (): string => join(abtarsHome(), \"tasks\", \"tasks.json\");\n\nfunction readAll(): CronEntry[] {\n const p = storePath();\n if (!existsSync(p)) return [];\n try { return JSON.parse(readFileSync(p, \"utf-8\")); }\n catch (err) { logAndSwallow(TAG, \"readAll tasks.json\", err); return []; }\n}\n\nfunction writeAll(entries: CronEntry[]): void {\n const p = storePath();\n mkdirSync(dirname(p), { recursive: true });\n const tmp = p + \".tmp\";\n writeFileSync(tmp, JSON.stringify(entries, null, 2), \"utf-8\");\n renameSync(tmp, p);\n}\n\nexport function readEntries(): CronEntry[] {\n return readAll();\n}\n\nexport function readEntry(id: string): CronEntry | null {\n return readAll().find(e => e.id === id) ?? null;\n}\n\nexport function writeEntry(e: CronEntry): void {\n const entries = readAll();\n const idx = entries.findIndex(x => x.id === e.id);\n if (idx >= 0) entries[idx] = e; else entries.push(e);\n writeAll(entries);\n}\n\nexport function removeEntry(id: string): boolean {\n const entries = readAll();\n const before = entries.length;\n const filtered = entries.filter(e => e.id !== id);\n if (filtered.length === before) return false;\n writeAll(filtered);\n return true;\n}\n\nexport function recordRun(entryId: string, exitCode?: number): void {\n const entries = readAll();\n const entry = entries.find(e => e.id === entryId);\n if (!entry) return;\n const history: { ts: number; exitCode?: number }[] = entry.history ?? [];\n history.push({ ts: Date.now(), ...(exitCode !== undefined ? { exitCode } : {}) });\n if (history.length > 10) history.splice(0, history.length - 10);\n entry.history = history;\n writeAll(entries);\n}\n\n/** No-op \u2014 kept for API compat with tests that called closeDb() on the old SQLite store. */\nexport function closeDb(): void { /* JSON store has no connection to close */ }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AASA;AACA;AAJA,SAAS,YAAY,cAAc,eAAe,WAAW,kBAAkB;AAC/E,SAAS,MAAM,eAAe;AAK9B,IAAM,MAAM;AAEZ,IAAM,YAAY,MAAc,KAAK,WAAW,GAAG,SAAS,YAAY;AAExE,SAAS,UAAuB;AAC9B,QAAM,IAAI,UAAU;AACpB,MAAI,CAAC,WAAW,CAAC,EAAG,QAAO,CAAC;AAC5B,MAAI;AAAE,WAAO,KAAK,MAAM,aAAa,GAA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,EAAE;AAC9D,QAAM,UAAU;AAChB,WAAS,OAAO;AAClB;AAGO,SAAS,UAAgB;AAA8C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
readEntries,
|
|
8
8
|
removeEntry,
|
|
9
9
|
writeEntry
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GPL57SRN.js";
|
|
11
11
|
import {
|
|
12
12
|
init_log_and_swallow,
|
|
13
13
|
logAndSwallow
|
|
@@ -505,4 +505,4 @@ export {
|
|
|
505
505
|
checkCron,
|
|
506
506
|
localDate
|
|
507
507
|
};
|
|
508
|
-
//# sourceMappingURL=chunk-
|
|
508
|
+
//# sourceMappingURL=chunk-HEHD3GG5.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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);
|
|
3
3
|
import {
|
|
4
4
|
createAgentTransport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-J7CFCY4U.js";
|
|
6
6
|
import {
|
|
7
7
|
loadUsers
|
|
8
8
|
} from "./chunk-GBBTK6H2.js";
|
|
@@ -496,7 +496,7 @@ async function buildTransport(ctx) {
|
|
|
496
496
|
defaults?.maxWaitSec ?? config.transport.tmuxMaxWaitSec
|
|
497
497
|
);
|
|
498
498
|
} else if (resolved.provider.transport === "api") {
|
|
499
|
-
const { DirectApiTransport } = await import("./direct-api-transport-
|
|
499
|
+
const { DirectApiTransport } = await import("./direct-api-transport-ZSJHKYBX.js");
|
|
500
500
|
const { ModelHealthRegistry } = await import("./model-health-registry-7ECZFCW4.js");
|
|
501
501
|
const { FallbackPolicy } = await import("./fallback-policy-SR6ED5I3.js");
|
|
502
502
|
const apiKey = getEnv().getApiKey(resolved.provider.apiKeyEnv ?? "API_KEY");
|
|
@@ -549,7 +549,7 @@ async function buildTransport(ctx) {
|
|
|
549
549
|
}
|
|
550
550
|
await transport.initialize();
|
|
551
551
|
if ("setSystemPrompt" in transport && typeof transport.setSystemPrompt === "function") {
|
|
552
|
-
const { loadSoulBundle } = await import("./soul-loader-
|
|
552
|
+
const { loadSoulBundle } = await import("./soul-loader-N5FA4I6C.js");
|
|
553
553
|
const soul = loadSoulBundle();
|
|
554
554
|
if (soul) transport.setSystemPrompt(soul);
|
|
555
555
|
}
|
|
@@ -642,4 +642,4 @@ export {
|
|
|
642
642
|
buildTransport,
|
|
643
643
|
rebuildTransport
|
|
644
644
|
};
|
|
645
|
-
//# sourceMappingURL=chunk-
|
|
645
|
+
//# sourceMappingURL=chunk-HTGVYNPE.js.map
|