@botiverse/raft-daemon 0.58.2 → 0.59.0-play.20260613155737
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/dist/{chunk-XA4ZPIWE.js → chunk-ETNYFP47.js} +331 -88
- package/dist/cli/index.js +440 -17
- package/dist/cli/package.json +1 -1
- package/dist/core.js +5 -1
- package/dist/{dist-ADWW7UHH.js → dist-QQ3DYJPK.js} +432 -17
- package/dist/index.js +5 -3
- package/package.json +1 -1
|
@@ -1471,11 +1471,17 @@ function runtimeConfigToLaunchFields(config) {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
var PLAN_CONFIG = {
|
|
1473
1473
|
free: {
|
|
1474
|
-
displayName: "
|
|
1474
|
+
displayName: "Free",
|
|
1475
1475
|
limits: { maxMachines: 2, maxAgents: 5, maxChannels: 5, messageHistoryDays: 30, includedAgents: 5 },
|
|
1476
1476
|
comingSoon: false,
|
|
1477
1477
|
price: 0,
|
|
1478
|
-
extraAgentPrice: 0
|
|
1478
|
+
extraAgentPrice: 0,
|
|
1479
|
+
displayFeatures: [
|
|
1480
|
+
"Unlimited human seats",
|
|
1481
|
+
"Up to 5 agent seats",
|
|
1482
|
+
"30 days of message history",
|
|
1483
|
+
"100 MB file uploads/month"
|
|
1484
|
+
]
|
|
1479
1485
|
},
|
|
1480
1486
|
founder: {
|
|
1481
1487
|
displayName: "Founder",
|
|
@@ -1488,23 +1494,40 @@ var PLAN_CONFIG = {
|
|
|
1488
1494
|
var DISPLAY_PLAN_CONFIG = {
|
|
1489
1495
|
free: PLAN_CONFIG.free,
|
|
1490
1496
|
pro: {
|
|
1491
|
-
displayName: "
|
|
1492
|
-
limits: { maxMachines:
|
|
1493
|
-
comingSoon:
|
|
1497
|
+
displayName: "Pro",
|
|
1498
|
+
limits: { maxMachines: -1, maxAgents: 10, maxChannels: -1, messageHistoryDays: -1, includedAgents: 10 },
|
|
1499
|
+
comingSoon: false,
|
|
1494
1500
|
price: 20,
|
|
1495
|
-
|
|
1501
|
+
priceCadence: "/ seat pack / month",
|
|
1502
|
+
extraAgentPrice: 0,
|
|
1503
|
+
displayFeatures: [
|
|
1504
|
+
"1 human seat + 10 agent seats per Pro Seat Pack",
|
|
1505
|
+
"Unlimited message history",
|
|
1506
|
+
"Higher file upload limits",
|
|
1507
|
+
"Joint Channels",
|
|
1508
|
+
"More professional features coming soon"
|
|
1509
|
+
],
|
|
1510
|
+
displayNote: "$17.60 / seat pack / month when billed yearly"
|
|
1496
1511
|
},
|
|
1497
|
-
|
|
1498
|
-
displayName: "
|
|
1499
|
-
limits: { maxMachines:
|
|
1500
|
-
comingSoon:
|
|
1501
|
-
price:
|
|
1502
|
-
|
|
1512
|
+
enterprise: {
|
|
1513
|
+
displayName: "Enterprise",
|
|
1514
|
+
limits: { maxMachines: -1, maxAgents: -1, maxChannels: -1, messageHistoryDays: -1, includedAgents: -1 },
|
|
1515
|
+
comingSoon: false,
|
|
1516
|
+
price: 0,
|
|
1517
|
+
priceLabel: "Coming soon",
|
|
1518
|
+
priceCadence: null,
|
|
1519
|
+
extraAgentPrice: 0,
|
|
1520
|
+
displayFeatures: [
|
|
1521
|
+
"Custom commercial terms",
|
|
1522
|
+
"Security and compliance review",
|
|
1523
|
+
"Dedicated support and onboarding",
|
|
1524
|
+
"Custom deployment planning"
|
|
1525
|
+
]
|
|
1503
1526
|
}
|
|
1504
1527
|
};
|
|
1505
1528
|
|
|
1506
1529
|
// src/agentProcessManager.ts
|
|
1507
|
-
import { mkdirSync as mkdirSync4, readdirSync as
|
|
1530
|
+
import { mkdirSync as mkdirSync4, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
|
|
1508
1531
|
import { mkdir, writeFile, access, readdir as readdir2, stat as stat2, readFile, rm as rm2 } from "fs/promises";
|
|
1509
1532
|
import { createHash as createHash3 } from "crypto";
|
|
1510
1533
|
import path12 from "path";
|
|
@@ -1514,7 +1537,7 @@ import os6 from "os";
|
|
|
1514
1537
|
import { spawn } from "child_process";
|
|
1515
1538
|
|
|
1516
1539
|
// src/drivers/cliTransport.ts
|
|
1517
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
1540
|
+
import { existsSync as existsSync2, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
1518
1541
|
import { createRequire } from "module";
|
|
1519
1542
|
import path2 from "path";
|
|
1520
1543
|
|
|
@@ -2096,6 +2119,19 @@ function listLegacySlockStatePaths(slockHome = resolveSlockHome(), homeDir = os.
|
|
|
2096
2119
|
return candidates.filter((candidate) => existsSync(candidate.path));
|
|
2097
2120
|
}
|
|
2098
2121
|
|
|
2122
|
+
// src/authEnv.ts
|
|
2123
|
+
var DAEMON_API_KEY_ENV = "SLOCK_MACHINE_API_KEY";
|
|
2124
|
+
var SLOCK_AGENT_TOKEN_ENV = "SLOCK_AGENT_TOKEN";
|
|
2125
|
+
function scrubDaemonAuthEnv(env) {
|
|
2126
|
+
delete env[DAEMON_API_KEY_ENV];
|
|
2127
|
+
return env;
|
|
2128
|
+
}
|
|
2129
|
+
function scrubDaemonChildEnv(env) {
|
|
2130
|
+
delete env[DAEMON_API_KEY_ENV];
|
|
2131
|
+
delete env[SLOCK_AGENT_TOKEN_ENV];
|
|
2132
|
+
return env;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2099
2135
|
// src/agentCredentialProxy.ts
|
|
2100
2136
|
import { randomBytes } from "crypto";
|
|
2101
2137
|
import http from "http";
|
|
@@ -3583,8 +3619,36 @@ var LOOPBACK_NO_PROXY = "127.0.0.1,localhost";
|
|
|
3583
3619
|
var CLI_TRANSPORT_TRACE_DIR_ENV = "SLOCK_CLI_TRANSPORT_TRACE_DIR";
|
|
3584
3620
|
var safePathPart = (value) => value.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
3585
3621
|
var RAW_CREDENTIAL_ENV_DENYLIST = [
|
|
3586
|
-
"
|
|
3622
|
+
"SLOCK_AGENT_TOKEN",
|
|
3623
|
+
"SLOCK_AGENT_CREDENTIAL_KEY",
|
|
3624
|
+
"SLOCK_AGENT_CREDENTIAL_KEY_FILE"
|
|
3587
3625
|
];
|
|
3626
|
+
function deriveCliFallbackCandidates(cliPath) {
|
|
3627
|
+
if (!cliPath || cliPath === "__cli") return [];
|
|
3628
|
+
const normalized = cliPath.split(path2.sep).join("/");
|
|
3629
|
+
const marker = "/node_modules/";
|
|
3630
|
+
const idx = normalized.indexOf(marker);
|
|
3631
|
+
if (idx === -1) return [];
|
|
3632
|
+
const globalRoot = cliPath.slice(0, idx + marker.length - 1);
|
|
3633
|
+
const tail = path2.join("dist", "cli", "index.js");
|
|
3634
|
+
return [
|
|
3635
|
+
path2.join(globalRoot, "@botiverse", "raft-daemon", tail),
|
|
3636
|
+
path2.join(globalRoot, "@slock-ai", "daemon", tail)
|
|
3637
|
+
].filter((candidate) => candidate !== cliPath);
|
|
3638
|
+
}
|
|
3639
|
+
function deriveOpencliFallbackCandidates(binPath) {
|
|
3640
|
+
if (!binPath) return [];
|
|
3641
|
+
const normalized = binPath.split(path2.sep).join("/");
|
|
3642
|
+
const marker = "/node_modules/";
|
|
3643
|
+
const first = normalized.indexOf(marker);
|
|
3644
|
+
if (first === -1) return [];
|
|
3645
|
+
const pkgMarker = "/node_modules/@jackwener/opencli/";
|
|
3646
|
+
const last = normalized.lastIndexOf(pkgMarker);
|
|
3647
|
+
if (last === -1) return [];
|
|
3648
|
+
const suffix = normalized.slice(last + pkgMarker.length);
|
|
3649
|
+
const candidate = path2.join(binPath.slice(0, first + marker.length - 1), "@jackwener", "opencli", ...suffix.split("/"));
|
|
3650
|
+
return candidate === binPath ? [] : [candidate];
|
|
3651
|
+
}
|
|
3588
3652
|
var cachedOpencliBinPath;
|
|
3589
3653
|
function resolveOpencliBinPath() {
|
|
3590
3654
|
if (cachedOpencliBinPath !== void 0) return cachedOpencliBinPath;
|
|
@@ -3619,6 +3683,64 @@ function resolveOpencliBinPath() {
|
|
|
3619
3683
|
return null;
|
|
3620
3684
|
}
|
|
3621
3685
|
}
|
|
3686
|
+
function writeOpencliWrapper(slockDir, opencliBinPath, platform = process.platform) {
|
|
3687
|
+
const fallbacks = deriveOpencliFallbackCandidates(opencliBinPath);
|
|
3688
|
+
let binPath = opencliBinPath;
|
|
3689
|
+
if (!existsSync2(binPath)) {
|
|
3690
|
+
const fallback = fallbacks.find((candidate) => existsSync2(candidate));
|
|
3691
|
+
if (fallback) binPath = fallback;
|
|
3692
|
+
}
|
|
3693
|
+
const posixFallbackBlock = fallbacks.length === 0 ? "" : `if [ ! -e "$OPENCLI_BIN" ]; then
|
|
3694
|
+
${fallbacks.map((candidate, i) => ` ${i === 0 ? "if" : "elif"} [ -e ${shellSingleQuote(candidate)} ]; then OPENCLI_BIN=${shellSingleQuote(candidate)};`).join("\n")}
|
|
3695
|
+
fi
|
|
3696
|
+
fi
|
|
3697
|
+
`;
|
|
3698
|
+
writeFileSync(
|
|
3699
|
+
path2.join(slockDir, "opencli"),
|
|
3700
|
+
`#!/usr/bin/env bash
|
|
3701
|
+
OPENCLI_BIN=${shellSingleQuote(binPath)}
|
|
3702
|
+
${posixFallbackBlock}exec ${shellSingleQuote(process.execPath)} "$OPENCLI_BIN" "$@"
|
|
3703
|
+
`,
|
|
3704
|
+
{ mode: 493 }
|
|
3705
|
+
);
|
|
3706
|
+
if (platform === "win32") {
|
|
3707
|
+
const opencliCmdBody = [
|
|
3708
|
+
"@echo off",
|
|
3709
|
+
"set PYTHONIOENCODING=utf-8",
|
|
3710
|
+
"set PYTHONUTF8=1",
|
|
3711
|
+
"set LANG=C.UTF-8",
|
|
3712
|
+
"set LC_ALL=C.UTF-8",
|
|
3713
|
+
"chcp 65001 >NUL 2>NUL",
|
|
3714
|
+
`set "OPENCLI_BIN=${binPath}"`,
|
|
3715
|
+
...fallbacks.map((candidate) => `if not exist "%OPENCLI_BIN%" set "OPENCLI_BIN=${candidate}"`),
|
|
3716
|
+
`"${process.execPath}" "%OPENCLI_BIN%" %*`,
|
|
3717
|
+
""
|
|
3718
|
+
].join("\r\n") + "\r\n";
|
|
3719
|
+
writeFileSync(path2.join(slockDir, "opencli.cmd"), opencliCmdBody);
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
function regenerateExistingOpencliWrappers(agentsRoot, platform = process.platform, opencliBinPath = resolveOpencliBinPath()) {
|
|
3723
|
+
if (!opencliBinPath) return { scanned: 0, rewritten: 0 };
|
|
3724
|
+
let entries;
|
|
3725
|
+
try {
|
|
3726
|
+
entries = readdirSync(agentsRoot);
|
|
3727
|
+
} catch {
|
|
3728
|
+
return { scanned: 0, rewritten: 0 };
|
|
3729
|
+
}
|
|
3730
|
+
let scanned = 0;
|
|
3731
|
+
let rewritten = 0;
|
|
3732
|
+
for (const entry of entries) {
|
|
3733
|
+
const slockDir = path2.join(agentsRoot, entry, ".slock");
|
|
3734
|
+
if (!existsSync2(path2.join(slockDir, "opencli"))) continue;
|
|
3735
|
+
scanned++;
|
|
3736
|
+
try {
|
|
3737
|
+
writeOpencliWrapper(slockDir, opencliBinPath, platform);
|
|
3738
|
+
rewritten++;
|
|
3739
|
+
} catch {
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
return { scanned, rewritten };
|
|
3743
|
+
}
|
|
3622
3744
|
function windowsUtf8Env() {
|
|
3623
3745
|
return {
|
|
3624
3746
|
PYTHONIOENCODING: "utf-8",
|
|
@@ -3676,6 +3798,21 @@ async function prepareCliTransport(ctx, extraEnv = {}, platform = process.platfo
|
|
|
3676
3798
|
if (!ctx.slockCliPath) {
|
|
3677
3799
|
throw new Error(`${ctx.config.runtime} driver: slockCliPath is required (daemon must inject it)`);
|
|
3678
3800
|
}
|
|
3801
|
+
let cliPath = ctx.slockCliPath;
|
|
3802
|
+
const cliFallbackCandidates = deriveCliFallbackCandidates(cliPath);
|
|
3803
|
+
if (cliPath !== "__cli" && !existsSync2(cliPath)) {
|
|
3804
|
+
const fallback = cliFallbackCandidates.find((candidate) => existsSync2(candidate));
|
|
3805
|
+
if (fallback) {
|
|
3806
|
+
console.error(
|
|
3807
|
+
`[cliTransport] bundled CLI missing at ${cliPath} (package tree mutated under a running daemon?); using ${fallback}. Restart the daemon from its current install to clear this.`
|
|
3808
|
+
);
|
|
3809
|
+
cliPath = fallback;
|
|
3810
|
+
} else {
|
|
3811
|
+
console.error(
|
|
3812
|
+
`[cliTransport] bundled CLI missing at ${cliPath} and no global fallback found; wrappers will be broken until the daemon is restarted from a valid install.`
|
|
3813
|
+
);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3679
3816
|
const slockDir = path2.join(ctx.workingDirectory, ".slock");
|
|
3680
3817
|
mkdirSync(slockDir, { recursive: true });
|
|
3681
3818
|
const slockHome = resolveSlockHome();
|
|
@@ -3704,9 +3841,15 @@ async function prepareCliTransport(ctx, extraEnv = {}, platform = process.platfo
|
|
|
3704
3841
|
const posixWrapper = path2.join(slockDir, "slock");
|
|
3705
3842
|
const posixRaftWrapper = path2.join(slockDir, "raft");
|
|
3706
3843
|
const posixCredentialPrefix = agentCredentialProxy ? `SLOCK_AGENT_PROXY_URL=${shellSingleQuote(agentCredentialProxy.proxyUrl)} SLOCK_AGENT_PROXY_TOKEN_FILE=${shellSingleQuote(agentCredentialProxyTokenFile)} SLOCK_AGENT_ACTIVE_CAPABILITIES=${shellSingleQuote(DEFAULT_ACTIVE_CAPABILITIES)} ` : "";
|
|
3844
|
+
const posixCliFallbackBlock = cliPath === "__cli" || cliFallbackCandidates.length === 0 ? "" : `if [ ! -e "$SLOCK_CLI" ]; then
|
|
3845
|
+
${cliFallbackCandidates.map((candidate, i) => ` ${i === 0 ? "if" : "elif"} [ -e ${shellSingleQuote(candidate)} ]; then SLOCK_CLI=${shellSingleQuote(candidate)};`).join("\n")}
|
|
3846
|
+
fi
|
|
3847
|
+
fi
|
|
3848
|
+
`;
|
|
3707
3849
|
const posixBody = `#!/usr/bin/env bash
|
|
3708
3850
|
${posixLoopbackNoProxyPrelude()}
|
|
3709
|
-
|
|
3851
|
+
SLOCK_CLI=${shellSingleQuote(cliPath)}
|
|
3852
|
+
${posixCliFallbackBlock}${posixCredentialPrefix}exec ${shellSingleQuote(process.execPath)} "$SLOCK_CLI" "$@"
|
|
3710
3853
|
`;
|
|
3711
3854
|
writeFileSync(posixWrapper, posixBody, { mode: 493 });
|
|
3712
3855
|
writeFileSync(posixRaftWrapper, posixBody, { mode: 493 });
|
|
@@ -3717,6 +3860,7 @@ ${posixCredentialPrefix}exec ${shellSingleQuote(process.execPath)} ${shellSingle
|
|
|
3717
3860
|
set "SLOCK_AGENT_PROXY_TOKEN_FILE=${agentCredentialProxyTokenFile}"\r
|
|
3718
3861
|
set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
|
|
3719
3862
|
` : "";
|
|
3863
|
+
const cmdCliFallbackLines = cliPath === "__cli" ? [] : cliFallbackCandidates.map((candidate) => `if not exist "%SLOCK_CLI%" set "SLOCK_CLI=${candidate}"`);
|
|
3720
3864
|
const cmdBody = [
|
|
3721
3865
|
"@echo off",
|
|
3722
3866
|
"set PYTHONIOENCODING=utf-8",
|
|
@@ -3726,7 +3870,9 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
|
|
|
3726
3870
|
"chcp 65001 >NUL 2>NUL",
|
|
3727
3871
|
...cmdLoopbackNoProxyLines(),
|
|
3728
3872
|
cmdCredentialLine.trimEnd(),
|
|
3729
|
-
`
|
|
3873
|
+
`set "SLOCK_CLI=${cliPath}"`,
|
|
3874
|
+
...cmdCliFallbackLines,
|
|
3875
|
+
`"${process.execPath}" "%SLOCK_CLI%" %*`,
|
|
3730
3876
|
""
|
|
3731
3877
|
].filter((line) => line.length > 0).join("\r\n") + "\r\n";
|
|
3732
3878
|
writeFileSync(cmdWrapper, cmdBody);
|
|
@@ -3750,7 +3896,14 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
|
|
|
3750
3896
|
...powershellLoopbackNoProxyLines(),
|
|
3751
3897
|
...psCredentialLines,
|
|
3752
3898
|
`$node = ${powershellSingleQuote(process.execPath)}`,
|
|
3753
|
-
`$cli = ${powershellSingleQuote(
|
|
3899
|
+
`$cli = ${powershellSingleQuote(cliPath)}`,
|
|
3900
|
+
...cliPath === "__cli" || cliFallbackCandidates.length === 0 ? [] : [
|
|
3901
|
+
"if (-not (Test-Path $cli)) {",
|
|
3902
|
+
` foreach ($candidate in @(${cliFallbackCandidates.map(powershellSingleQuote).join(", ")})) {`,
|
|
3903
|
+
" if (Test-Path $candidate) { $cli = $candidate; break }",
|
|
3904
|
+
" }",
|
|
3905
|
+
"}"
|
|
3906
|
+
],
|
|
3754
3907
|
"if ($MyInvocation.ExpectingInput) {",
|
|
3755
3908
|
" $input | & $node $cli @args",
|
|
3756
3909
|
"} else {",
|
|
@@ -3764,28 +3917,7 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
|
|
|
3764
3917
|
}
|
|
3765
3918
|
const opencliBinPath = resolveOpencliBinPath();
|
|
3766
3919
|
if (opencliBinPath) {
|
|
3767
|
-
|
|
3768
|
-
writeFileSync(
|
|
3769
|
-
opencliPosixWrapper,
|
|
3770
|
-
`#!/usr/bin/env bash
|
|
3771
|
-
exec ${shellSingleQuote(process.execPath)} ${shellSingleQuote(opencliBinPath)} "$@"
|
|
3772
|
-
`,
|
|
3773
|
-
{ mode: 493 }
|
|
3774
|
-
);
|
|
3775
|
-
if (platform === "win32") {
|
|
3776
|
-
const opencliCmdWrapper = path2.join(slockDir, "opencli.cmd");
|
|
3777
|
-
const opencliCmdBody = [
|
|
3778
|
-
"@echo off",
|
|
3779
|
-
"set PYTHONIOENCODING=utf-8",
|
|
3780
|
-
"set PYTHONUTF8=1",
|
|
3781
|
-
"set LANG=C.UTF-8",
|
|
3782
|
-
"set LC_ALL=C.UTF-8",
|
|
3783
|
-
"chcp 65001 >NUL 2>NUL",
|
|
3784
|
-
`"${process.execPath}" "${opencliBinPath}" %*`,
|
|
3785
|
-
""
|
|
3786
|
-
].join("\r\n") + "\r\n";
|
|
3787
|
-
writeFileSync(opencliCmdWrapper, opencliCmdBody);
|
|
3788
|
-
}
|
|
3920
|
+
writeOpencliWrapper(slockDir, opencliBinPath, platform);
|
|
3789
3921
|
}
|
|
3790
3922
|
const wrapperPath = platform === "win32" ? path2.join(slockDir, "slock.cmd") : posixWrapper;
|
|
3791
3923
|
const launchRuntimeFields = runtimeConfigToLaunchFields(ctx.config);
|
|
@@ -3804,7 +3936,7 @@ exec ${shellSingleQuote(process.execPath)} ${shellSingleQuote(opencliBinPath)} "
|
|
|
3804
3936
|
...agentCredentialProxy ? {} : { SLOCK_AGENT_TOKEN_FILE: tokenFile },
|
|
3805
3937
|
PATH: `${slockDir}${path2.delimiter}${process.env.PATH ?? ""}`
|
|
3806
3938
|
};
|
|
3807
|
-
|
|
3939
|
+
scrubDaemonChildEnv(spawnEnv);
|
|
3808
3940
|
for (const key of RAW_CREDENTIAL_ENV_DENYLIST) {
|
|
3809
3941
|
delete spawnEnv[key];
|
|
3810
3942
|
}
|
|
@@ -4079,7 +4211,7 @@ import path4 from "path";
|
|
|
4079
4211
|
|
|
4080
4212
|
// src/drivers/probe.ts
|
|
4081
4213
|
import { execFileSync } from "child_process";
|
|
4082
|
-
import { existsSync as
|
|
4214
|
+
import { existsSync as existsSync3 } from "fs";
|
|
4083
4215
|
import path3 from "path";
|
|
4084
4216
|
function normalizeExecOutput(raw) {
|
|
4085
4217
|
return Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw ?? "");
|
|
@@ -4231,11 +4363,17 @@ function resolveCommandOnWindows(command, env, execFileSyncFn, existsSyncFn) {
|
|
|
4231
4363
|
return null;
|
|
4232
4364
|
}
|
|
4233
4365
|
}
|
|
4366
|
+
function requiresWindowsShell(command, platform = process.platform) {
|
|
4367
|
+
if (platform !== "win32") return false;
|
|
4368
|
+
if (!command) return false;
|
|
4369
|
+
const lower = command.toLowerCase();
|
|
4370
|
+
return lower.endsWith(".cmd") || lower.endsWith(".bat");
|
|
4371
|
+
}
|
|
4234
4372
|
function resolveCommandOnPath(command, deps = {}) {
|
|
4235
4373
|
const platform = deps.platform ?? process.platform;
|
|
4236
|
-
const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
|
|
4374
|
+
const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
|
|
4237
4375
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
|
|
4238
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
4376
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync3;
|
|
4239
4377
|
if (platform === "win32") {
|
|
4240
4378
|
return resolveCommandOnWindows(command, env, execFileSyncFn, existsSyncFn);
|
|
4241
4379
|
}
|
|
@@ -4252,14 +4390,14 @@ function resolveCommandOnPath(command, deps = {}) {
|
|
|
4252
4390
|
}
|
|
4253
4391
|
}
|
|
4254
4392
|
function firstExistingPath(candidates, deps = {}) {
|
|
4255
|
-
const exists = deps.existsSyncFn ??
|
|
4393
|
+
const exists = deps.existsSyncFn ?? existsSync3;
|
|
4256
4394
|
for (const candidate of candidates) {
|
|
4257
4395
|
if (exists(candidate)) return candidate;
|
|
4258
4396
|
}
|
|
4259
4397
|
return null;
|
|
4260
4398
|
}
|
|
4261
4399
|
function readCommandVersion(command, args = [], deps = {}) {
|
|
4262
|
-
const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
|
|
4400
|
+
const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
|
|
4263
4401
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
|
|
4264
4402
|
try {
|
|
4265
4403
|
const output = normalizeExecOutput(execFileSyncFn(command, [...args, "--version"], {
|
|
@@ -4354,7 +4492,7 @@ function buildClaudeSpawnSpec(claudeCommand, platform = process.platform) {
|
|
|
4354
4492
|
}
|
|
4355
4493
|
|
|
4356
4494
|
// src/drivers/claudeProviderIsolation.ts
|
|
4357
|
-
import { existsSync as
|
|
4495
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, symlinkSync } from "fs";
|
|
4358
4496
|
import os2 from "os";
|
|
4359
4497
|
import path5 from "path";
|
|
4360
4498
|
function isClaudeCustomProviderConfig(config) {
|
|
@@ -4372,7 +4510,7 @@ function getClaudeProviderStatePaths(workingDirectory) {
|
|
|
4372
4510
|
}
|
|
4373
4511
|
function linkIfPresent(source, target) {
|
|
4374
4512
|
try {
|
|
4375
|
-
if (!
|
|
4513
|
+
if (!existsSync4(source) || existsSync4(target)) return;
|
|
4376
4514
|
mkdirSync2(path5.dirname(target), { recursive: true, mode: 448 });
|
|
4377
4515
|
symlinkSync(source, target, "dir");
|
|
4378
4516
|
} catch {
|
|
@@ -4493,7 +4631,7 @@ var ClaudeDriver = class {
|
|
|
4493
4631
|
|
|
4494
4632
|
// src/drivers/codex.ts
|
|
4495
4633
|
import { spawn as spawn2, execFileSync as execFileSync2, execSync } from "child_process";
|
|
4496
|
-
import { existsSync as
|
|
4634
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
|
|
4497
4635
|
import os3 from "os";
|
|
4498
4636
|
import path6 from "path";
|
|
4499
4637
|
|
|
@@ -4882,7 +5020,7 @@ var CodexEventNormalizer = class {
|
|
|
4882
5020
|
|
|
4883
5021
|
// src/drivers/codex.ts
|
|
4884
5022
|
function ensureGitRepoForCodex(workingDirectory, deps = {}) {
|
|
4885
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
5023
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync5;
|
|
4886
5024
|
const execSyncFn = deps.execSyncFn ?? execSync;
|
|
4887
5025
|
const gitDir = path6.join(workingDirectory, ".git");
|
|
4888
5026
|
if (existsSyncFn(gitDir)) return;
|
|
@@ -4900,7 +5038,7 @@ function isWindowsSandboxRunner(commandPath) {
|
|
|
4900
5038
|
return path6.basename(commandPath).toLowerCase().startsWith("codex-command-runner");
|
|
4901
5039
|
}
|
|
4902
5040
|
function resolveWindowsNpmCodexEntry(deps = {}) {
|
|
4903
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
5041
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync5;
|
|
4904
5042
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync2;
|
|
4905
5043
|
const env = deps.env ?? process.env;
|
|
4906
5044
|
const winPath = path6.win32;
|
|
@@ -4922,7 +5060,7 @@ function resolveWindowsNpmCodexEntry(deps = {}) {
|
|
|
4922
5060
|
return null;
|
|
4923
5061
|
}
|
|
4924
5062
|
function resolveWindowsCodexDesktopEntry(deps = {}) {
|
|
4925
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
5063
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync5;
|
|
4926
5064
|
const env = deps.env ?? process.env;
|
|
4927
5065
|
const homeDir = deps.homeDir;
|
|
4928
5066
|
const winPath = path6.win32;
|
|
@@ -5037,7 +5175,7 @@ var CodexDriver = class {
|
|
|
5037
5175
|
threadParams.config = { model_reasoning_effort: launchRuntimeFields.reasoningEffort };
|
|
5038
5176
|
}
|
|
5039
5177
|
if (launchRuntimeFields.mode.kind === "fast") {
|
|
5040
|
-
threadParams.serviceTier = "
|
|
5178
|
+
threadParams.serviceTier = "fast";
|
|
5041
5179
|
}
|
|
5042
5180
|
if (ctx.config.sessionId) {
|
|
5043
5181
|
return {
|
|
@@ -5237,10 +5375,11 @@ var ANTIGRAVITY_ENV_OVERRIDES = {
|
|
|
5237
5375
|
SSH_TTY: void 0
|
|
5238
5376
|
};
|
|
5239
5377
|
function resolveAntigravitySpawn(commandArgs, deps = {}) {
|
|
5378
|
+
const command = resolveCommandOnPath("agy", deps) ?? "agy";
|
|
5240
5379
|
return {
|
|
5241
|
-
command
|
|
5380
|
+
command,
|
|
5242
5381
|
args: commandArgs,
|
|
5243
|
-
shell:
|
|
5382
|
+
shell: requiresWindowsShell(command, deps.platform)
|
|
5244
5383
|
};
|
|
5245
5384
|
}
|
|
5246
5385
|
function buildAntigravityArgs(ctx) {
|
|
@@ -5648,11 +5787,11 @@ function detectCursorModels(runCommand = runCursorModelsCommand) {
|
|
|
5648
5787
|
return parseCursorModelsOutput(String(result.stdout || ""));
|
|
5649
5788
|
}
|
|
5650
5789
|
function buildCursorModelProbeEnv(deps = {}) {
|
|
5651
|
-
return withWindowsUserEnvironment({
|
|
5790
|
+
return scrubDaemonChildEnv(withWindowsUserEnvironment({
|
|
5652
5791
|
...deps.env ?? process.env,
|
|
5653
5792
|
FORCE_COLOR: "0",
|
|
5654
5793
|
NO_COLOR: "1"
|
|
5655
|
-
}, deps);
|
|
5794
|
+
}, deps));
|
|
5656
5795
|
}
|
|
5657
5796
|
function runCursorModelsCommand() {
|
|
5658
5797
|
return spawnSync("cursor-agent", ["models"], {
|
|
@@ -5664,7 +5803,7 @@ function runCursorModelsCommand() {
|
|
|
5664
5803
|
|
|
5665
5804
|
// src/drivers/gemini.ts
|
|
5666
5805
|
import { execFileSync as execFileSync3, spawn as spawn6 } from "child_process";
|
|
5667
|
-
import { existsSync as
|
|
5806
|
+
import { existsSync as existsSync6 } from "fs";
|
|
5668
5807
|
import path7 from "path";
|
|
5669
5808
|
async function buildGeminiSpawnEnv(ctx, platform = process.platform) {
|
|
5670
5809
|
const { spawnEnv } = await prepareCliTransport(ctx, { NO_COLOR: "1" }, platform);
|
|
@@ -5707,8 +5846,8 @@ function resolveGeminiSpawn(commandArgs, deps = {}) {
|
|
|
5707
5846
|
return { command: resolveCommandOnPath("gemini", deps) ?? "gemini", args: commandArgs };
|
|
5708
5847
|
}
|
|
5709
5848
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync3;
|
|
5710
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
5711
|
-
const env = deps.env ?? process.env;
|
|
5849
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync6;
|
|
5850
|
+
const env = scrubDaemonChildEnv({ ...deps.env ?? process.env });
|
|
5712
5851
|
const winPath = path7.win32;
|
|
5713
5852
|
let geminiEntry = null;
|
|
5714
5853
|
try {
|
|
@@ -5845,12 +5984,15 @@ var GeminiDriver = class {
|
|
|
5845
5984
|
// src/drivers/kimi.ts
|
|
5846
5985
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5847
5986
|
import { spawn as spawn7 } from "child_process";
|
|
5848
|
-
import { existsSync as
|
|
5987
|
+
import { chmodSync, existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
5849
5988
|
import os4 from "os";
|
|
5850
5989
|
import path8 from "path";
|
|
5851
5990
|
var KIMI_WIRE_PROTOCOL_VERSION = "1.3";
|
|
5852
5991
|
var KIMI_SYSTEM_PROMPT_FILE = ".slock-kimi-system.md";
|
|
5853
5992
|
var KIMI_AGENT_FILE = ".slock-kimi-agent.yaml";
|
|
5993
|
+
var KIMI_GENERATED_CONFIG_FILE = ".slock-kimi-config.toml";
|
|
5994
|
+
var SLOCK_KIMI_CONFIG_CONTENT_ENV = "SLOCK_KIMI_CONFIG_CONTENT";
|
|
5995
|
+
var SLOCK_KIMI_CONFIG_FILE_ENV = "SLOCK_KIMI_CONFIG_FILE";
|
|
5854
5996
|
function parseToolArguments(raw) {
|
|
5855
5997
|
if (typeof raw !== "string") return raw;
|
|
5856
5998
|
try {
|
|
@@ -5859,6 +6001,73 @@ function parseToolArguments(raw) {
|
|
|
5859
6001
|
return raw;
|
|
5860
6002
|
}
|
|
5861
6003
|
}
|
|
6004
|
+
function readKimiConfigSource(home = os4.homedir(), env = process.env) {
|
|
6005
|
+
const inlineConfig = env[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
6006
|
+
if (inlineConfig && inlineConfig.trim()) {
|
|
6007
|
+
return {
|
|
6008
|
+
raw: inlineConfig,
|
|
6009
|
+
explicitPath: null,
|
|
6010
|
+
sourcePath: SLOCK_KIMI_CONFIG_CONTENT_ENV
|
|
6011
|
+
};
|
|
6012
|
+
}
|
|
6013
|
+
const explicitPath = env[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
6014
|
+
const configPath = explicitPath && explicitPath.trim() ? explicitPath : path8.join(home, ".kimi", "config.toml");
|
|
6015
|
+
try {
|
|
6016
|
+
return {
|
|
6017
|
+
raw: readFileSync3(configPath, "utf8"),
|
|
6018
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
6019
|
+
sourcePath: configPath
|
|
6020
|
+
};
|
|
6021
|
+
} catch {
|
|
6022
|
+
return {
|
|
6023
|
+
raw: null,
|
|
6024
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
6025
|
+
sourcePath: configPath
|
|
6026
|
+
};
|
|
6027
|
+
}
|
|
6028
|
+
}
|
|
6029
|
+
function buildKimiSpawnEnv(env = process.env) {
|
|
6030
|
+
const spawnEnv = { ...env, FORCE_COLOR: "0", NO_COLOR: "1" };
|
|
6031
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
6032
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
6033
|
+
return scrubDaemonChildEnv(spawnEnv);
|
|
6034
|
+
}
|
|
6035
|
+
function buildKimiEffectiveEnv(ctx, overrideEnv) {
|
|
6036
|
+
return {
|
|
6037
|
+
...process.env,
|
|
6038
|
+
...ctx.config.envVars || {},
|
|
6039
|
+
...overrideEnv || {}
|
|
6040
|
+
};
|
|
6041
|
+
}
|
|
6042
|
+
function buildKimiLaunchOptions(ctx, opts = {}) {
|
|
6043
|
+
const env = buildKimiEffectiveEnv(ctx, opts.env);
|
|
6044
|
+
const source = readKimiConfigSource(opts.home ?? os4.homedir(), env);
|
|
6045
|
+
const args = [];
|
|
6046
|
+
let configFilePath = null;
|
|
6047
|
+
let configContent = null;
|
|
6048
|
+
if (source.explicitPath) {
|
|
6049
|
+
configFilePath = source.explicitPath;
|
|
6050
|
+
} else if (source.raw !== null && source.sourcePath === SLOCK_KIMI_CONFIG_CONTENT_ENV) {
|
|
6051
|
+
configFilePath = path8.join(ctx.workingDirectory, KIMI_GENERATED_CONFIG_FILE);
|
|
6052
|
+
configContent = source.raw;
|
|
6053
|
+
if (opts.writeGeneratedConfig !== false) {
|
|
6054
|
+
writeFileSync3(configFilePath, source.raw, { encoding: "utf8", mode: 384 });
|
|
6055
|
+
chmodSync(configFilePath, 384);
|
|
6056
|
+
}
|
|
6057
|
+
}
|
|
6058
|
+
if (configFilePath) {
|
|
6059
|
+
args.push("--config-file", configFilePath);
|
|
6060
|
+
}
|
|
6061
|
+
if (ctx.config.model && ctx.config.model !== "default") {
|
|
6062
|
+
args.push("--model", ctx.config.model);
|
|
6063
|
+
}
|
|
6064
|
+
return {
|
|
6065
|
+
args,
|
|
6066
|
+
env: buildKimiSpawnEnv(env),
|
|
6067
|
+
configFilePath,
|
|
6068
|
+
configContent
|
|
6069
|
+
};
|
|
6070
|
+
}
|
|
5862
6071
|
function resolveKimiSpawn(commandArgs, deps = {}) {
|
|
5863
6072
|
return {
|
|
5864
6073
|
command: resolveCommandOnPath("kimi", deps) ?? "kimi",
|
|
@@ -5882,7 +6091,25 @@ var KimiDriver = class {
|
|
|
5882
6091
|
};
|
|
5883
6092
|
model = {
|
|
5884
6093
|
detectedModelsVerifiedAs: "launchable",
|
|
5885
|
-
toLaunchSpec: (modelId) =>
|
|
6094
|
+
toLaunchSpec: (modelId, ctx, opts) => {
|
|
6095
|
+
if (!ctx) return { args: ["--model", modelId] };
|
|
6096
|
+
const launchCtx = {
|
|
6097
|
+
...ctx,
|
|
6098
|
+
config: {
|
|
6099
|
+
...ctx.config,
|
|
6100
|
+
model: modelId
|
|
6101
|
+
}
|
|
6102
|
+
};
|
|
6103
|
+
const launch = buildKimiLaunchOptions(launchCtx, {
|
|
6104
|
+
home: opts?.home,
|
|
6105
|
+
writeGeneratedConfig: false
|
|
6106
|
+
});
|
|
6107
|
+
return {
|
|
6108
|
+
args: launch.args,
|
|
6109
|
+
env: launch.env,
|
|
6110
|
+
configFiles: launch.configFilePath ? [launch.configFilePath] : void 0
|
|
6111
|
+
};
|
|
6112
|
+
}
|
|
5886
6113
|
};
|
|
5887
6114
|
supportsStdinNotification = true;
|
|
5888
6115
|
busyDeliveryMode = "direct";
|
|
@@ -5896,7 +6123,7 @@ var KimiDriver = class {
|
|
|
5896
6123
|
this.promptRequestId = randomUUID2();
|
|
5897
6124
|
const systemPromptPath = path8.join(ctx.workingDirectory, KIMI_SYSTEM_PROMPT_FILE);
|
|
5898
6125
|
const agentFilePath = path8.join(ctx.workingDirectory, KIMI_AGENT_FILE);
|
|
5899
|
-
if (!isResume || !
|
|
6126
|
+
if (!isResume || !existsSync7(systemPromptPath)) {
|
|
5900
6127
|
writeFileSync3(systemPromptPath, ctx.prompt, "utf8");
|
|
5901
6128
|
}
|
|
5902
6129
|
writeFileSync3(agentFilePath, [
|
|
@@ -5906,21 +6133,23 @@ var KimiDriver = class {
|
|
|
5906
6133
|
` system_prompt_path: ./${KIMI_SYSTEM_PROMPT_FILE}`,
|
|
5907
6134
|
""
|
|
5908
6135
|
].join("\n"), "utf8");
|
|
6136
|
+
const launch = buildKimiLaunchOptions(ctx);
|
|
5909
6137
|
const args = [
|
|
5910
6138
|
"--wire",
|
|
5911
6139
|
"--yolo",
|
|
5912
6140
|
"--agent-file",
|
|
5913
6141
|
agentFilePath,
|
|
5914
6142
|
"--session",
|
|
5915
|
-
this.sessionId
|
|
6143
|
+
this.sessionId,
|
|
6144
|
+
...launch.args
|
|
5916
6145
|
];
|
|
5917
6146
|
const launchRuntimeFields = runtimeConfigToLaunchFields(ctx.config);
|
|
5918
6147
|
if (launchRuntimeFields.model && launchRuntimeFields.model !== "default") {
|
|
5919
6148
|
args.push("--model", launchRuntimeFields.model);
|
|
5920
6149
|
}
|
|
5921
6150
|
const spawnEnv = (await prepareCliTransport(ctx, { NO_COLOR: "1" })).spawnEnv;
|
|
5922
|
-
const
|
|
5923
|
-
const proc = spawn7(
|
|
6151
|
+
const spawnTarget = resolveKimiSpawn(args);
|
|
6152
|
+
const proc = spawn7(spawnTarget.command, spawnTarget.args, {
|
|
5924
6153
|
cwd: ctx.workingDirectory,
|
|
5925
6154
|
stdio: ["pipe", "pipe", "pipe"],
|
|
5926
6155
|
env: spawnEnv,
|
|
@@ -5928,7 +6157,7 @@ var KimiDriver = class {
|
|
|
5928
6157
|
// and has an 8191-character command-line limit. Kimi's official
|
|
5929
6158
|
// installer/uv entrypoint is an executable, so launch it directly and
|
|
5930
6159
|
// keep prompts on stdin / files instead of routing through cmd.exe.
|
|
5931
|
-
shell:
|
|
6160
|
+
shell: spawnTarget.shell
|
|
5932
6161
|
});
|
|
5933
6162
|
proc.stdin?.write(JSON.stringify({
|
|
5934
6163
|
jsonrpc: "2.0",
|
|
@@ -6041,14 +6270,9 @@ var KimiDriver = class {
|
|
|
6041
6270
|
return detectKimiModels();
|
|
6042
6271
|
}
|
|
6043
6272
|
};
|
|
6044
|
-
function detectKimiModels(home = os4.homedir()) {
|
|
6045
|
-
const
|
|
6046
|
-
|
|
6047
|
-
try {
|
|
6048
|
-
raw = readFileSync3(configPath, "utf8");
|
|
6049
|
-
} catch {
|
|
6050
|
-
return null;
|
|
6051
|
-
}
|
|
6273
|
+
function detectKimiModels(home = os4.homedir(), opts = {}) {
|
|
6274
|
+
const raw = readKimiConfigSource(home, opts.env).raw;
|
|
6275
|
+
if (raw === null) return null;
|
|
6052
6276
|
const models = [];
|
|
6053
6277
|
const sectionRe = /^\s*\[models(?:\.([^\]]+)|"\.[^"]+"|\."[^"]+")\s*\]\s*$/gm;
|
|
6054
6278
|
const lineRe = /^\s*\[models\.(.+?)\s*\]\s*$/gm;
|
|
@@ -6069,7 +6293,7 @@ function detectKimiModels(home = os4.homedir()) {
|
|
|
6069
6293
|
|
|
6070
6294
|
// src/drivers/opencode.ts
|
|
6071
6295
|
import { spawn as spawn8, spawnSync as spawnSync2 } from "child_process";
|
|
6072
|
-
import { existsSync as
|
|
6296
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "fs";
|
|
6073
6297
|
import os5 from "os";
|
|
6074
6298
|
import path9 from "path";
|
|
6075
6299
|
var SLOCK_AGENT_NAME = "slock";
|
|
@@ -6286,7 +6510,7 @@ function runOpenCodeModelsCommand(home, deps = {}) {
|
|
|
6286
6510
|
const platform = deps.platform ?? process.platform;
|
|
6287
6511
|
const spawnSyncFn = deps.spawnSyncFn ?? spawnSync2;
|
|
6288
6512
|
const result = spawnSyncFn("opencode", ["models"], {
|
|
6289
|
-
env: { ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" },
|
|
6513
|
+
env: scrubDaemonChildEnv({ ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" }),
|
|
6290
6514
|
encoding: "utf8",
|
|
6291
6515
|
timeout: 5e3,
|
|
6292
6516
|
shell: platform === "win32"
|
|
@@ -6317,7 +6541,7 @@ function openCodeSpecForEntry(entry, commandArgs) {
|
|
|
6317
6541
|
return { command: process.execPath, args: [entry, ...commandArgs], shell: false };
|
|
6318
6542
|
}
|
|
6319
6543
|
function resolveWindowsOpenCodePackageEntry(commandPath, deps = {}) {
|
|
6320
|
-
const existsSyncFn = deps.existsSyncFn ??
|
|
6544
|
+
const existsSyncFn = deps.existsSyncFn ?? existsSync8;
|
|
6321
6545
|
const execFileSyncFn = deps.execFileSyncFn;
|
|
6322
6546
|
const env = deps.env ?? process.env;
|
|
6323
6547
|
const winPath = path9.win32;
|
|
@@ -6545,7 +6769,7 @@ var OpenCodeDriver = class {
|
|
|
6545
6769
|
// src/drivers/pi.ts
|
|
6546
6770
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
6547
6771
|
import { EventEmitter } from "events";
|
|
6548
|
-
import { mkdirSync as mkdirSync3, readdirSync } from "fs";
|
|
6772
|
+
import { mkdirSync as mkdirSync3, readdirSync as readdirSync2 } from "fs";
|
|
6549
6773
|
import path10 from "path";
|
|
6550
6774
|
import {
|
|
6551
6775
|
AuthStorage,
|
|
@@ -6589,7 +6813,7 @@ function resolvePiModelFromRegistry(modelId, modelRegistry) {
|
|
|
6589
6813
|
function findPiSessionFile(sessionDir, sessionId) {
|
|
6590
6814
|
let entries;
|
|
6591
6815
|
try {
|
|
6592
|
-
entries =
|
|
6816
|
+
entries = readdirSync2(sessionDir);
|
|
6593
6817
|
} catch {
|
|
6594
6818
|
return null;
|
|
6595
6819
|
}
|
|
@@ -7819,7 +8043,7 @@ function findSessionJsonl(root, predicate) {
|
|
|
7819
8043
|
if (depth < 0 || visited >= maxEntries) return null;
|
|
7820
8044
|
let entries;
|
|
7821
8045
|
try {
|
|
7822
|
-
entries =
|
|
8046
|
+
entries = readdirSync3(dir, { withFileTypes: true }).sort((a, b) => b.name.localeCompare(a.name));
|
|
7823
8047
|
} catch {
|
|
7824
8048
|
return null;
|
|
7825
8049
|
}
|
|
@@ -13428,7 +13652,7 @@ function acquireDaemonMachineLock(options) {
|
|
|
13428
13652
|
}
|
|
13429
13653
|
|
|
13430
13654
|
// src/localTraceSink.ts
|
|
13431
|
-
import { appendFileSync, mkdirSync as mkdirSync6, readdirSync as
|
|
13655
|
+
import { appendFileSync, mkdirSync as mkdirSync6, readdirSync as readdirSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
13432
13656
|
import path14 from "path";
|
|
13433
13657
|
var DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
13434
13658
|
var DEFAULT_MAX_FILE_AGE_MS = 5 * 60 * 1e3;
|
|
@@ -13507,7 +13731,7 @@ var LocalRotatingTraceSink = class {
|
|
|
13507
13731
|
}
|
|
13508
13732
|
}
|
|
13509
13733
|
pruneOldFiles() {
|
|
13510
|
-
const files =
|
|
13734
|
+
const files = readdirSync4(this.traceDir).filter((name) => name.startsWith("daemon-trace-") && name.endsWith(".jsonl")).sort();
|
|
13511
13735
|
const excess = files.length - this.maxFiles;
|
|
13512
13736
|
if (excess <= 0) return;
|
|
13513
13737
|
for (const file of files.slice(0, excess)) {
|
|
@@ -14091,7 +14315,7 @@ var DAEMON_CORE_TRACE_ATTR_CONTRACTS = {
|
|
|
14091
14315
|
spanAttrs: ["running_agents_count", "idle_agents_count"]
|
|
14092
14316
|
}
|
|
14093
14317
|
};
|
|
14094
|
-
var DAEMON_CLI_USAGE =
|
|
14318
|
+
var DAEMON_CLI_USAGE = `Usage: slock-daemon --server-url <url> (--api-key <key> or ${DAEMON_API_KEY_ENV}=<key>)`;
|
|
14095
14319
|
var RunnerCredentialMintError2 = class extends Error {
|
|
14096
14320
|
code;
|
|
14097
14321
|
retryable;
|
|
@@ -14127,9 +14351,9 @@ function runnerCredentialErrorDetail2(error) {
|
|
|
14127
14351
|
async function waitForRunnerCredentialRetry2() {
|
|
14128
14352
|
await new Promise((resolve) => setTimeout(resolve, RUNNER_CREDENTIAL_MINT_RETRY_DELAY_MS2));
|
|
14129
14353
|
}
|
|
14130
|
-
function parseDaemonCliArgs(args) {
|
|
14354
|
+
function parseDaemonCliArgs(args, env = {}) {
|
|
14131
14355
|
let serverUrl = "";
|
|
14132
|
-
let apiKey = "";
|
|
14356
|
+
let apiKey = env[DAEMON_API_KEY_ENV] ?? "";
|
|
14133
14357
|
for (let i = 0; i < args.length; i++) {
|
|
14134
14358
|
if (args[i] === "--server-url" && args[i + 1]) serverUrl = args[++i];
|
|
14135
14359
|
if (args[i] === "--api-key" && args[i + 1]) apiKey = args[++i];
|
|
@@ -14166,7 +14390,7 @@ function resolveSlockCliPathOrEmpty(moduleUrl = import.meta.url) {
|
|
|
14166
14390
|
}
|
|
14167
14391
|
async function runBundledSlockCli(argv) {
|
|
14168
14392
|
process.argv = [process.execPath, "slock", ...argv];
|
|
14169
|
-
await import("./dist-
|
|
14393
|
+
await import("./dist-QQ3DYJPK.js");
|
|
14170
14394
|
}
|
|
14171
14395
|
function detectRuntimes(tracer = noopTracer) {
|
|
14172
14396
|
const ids = [];
|
|
@@ -14302,6 +14526,11 @@ var DaemonCore = class {
|
|
|
14302
14526
|
computerVersion;
|
|
14303
14527
|
slockCliPath;
|
|
14304
14528
|
slockHome;
|
|
14529
|
+
agentsDataDir;
|
|
14530
|
+
// One-shot guard: rewrite stale per-agent opencli wrappers to the current
|
|
14531
|
+
// self-healing form on the first connect of this daemon process (a SEA
|
|
14532
|
+
// computer switch / daemon upgrade restarts the daemon → triggers this).
|
|
14533
|
+
opencliWrappersRegenerated = false;
|
|
14305
14534
|
runtimeDetector;
|
|
14306
14535
|
agentManager;
|
|
14307
14536
|
connection;
|
|
@@ -14328,8 +14557,9 @@ var DaemonCore = class {
|
|
|
14328
14557
|
onFire: (job) => this.onReminderFire(job)
|
|
14329
14558
|
});
|
|
14330
14559
|
let connection;
|
|
14560
|
+
this.agentsDataDir = options.dataDir ?? resolveSlockHomePath("agents", this.slockHome);
|
|
14331
14561
|
const agentManagerOptions = {
|
|
14332
|
-
dataDir:
|
|
14562
|
+
dataDir: this.agentsDataDir,
|
|
14333
14563
|
serverUrl: options.serverUrl,
|
|
14334
14564
|
defaultAgentEnvVarsProvider: options.defaultAgentEnvVarsProvider,
|
|
14335
14565
|
slockCliPath: this.slockCliPath,
|
|
@@ -14859,6 +15089,17 @@ var DaemonCore = class {
|
|
|
14859
15089
|
const { ids: runtimes, versions: runtimeVersions } = this.runtimeDetector();
|
|
14860
15090
|
const runtimeInfo = runtimes.map((id) => runtimeVersions[id] ? `${id} (${runtimeVersions[id]})` : id);
|
|
14861
15091
|
logger.info(`[Daemon] Detected runtimes: ${runtimeInfo.join(", ") || "none"}`);
|
|
15092
|
+
if (!this.opencliWrappersRegenerated) {
|
|
15093
|
+
this.opencliWrappersRegenerated = true;
|
|
15094
|
+
try {
|
|
15095
|
+
const { scanned, rewritten } = regenerateExistingOpencliWrappers(this.agentsDataDir);
|
|
15096
|
+
if (scanned > 0) {
|
|
15097
|
+
logger.info(`[Daemon] Refreshed ${rewritten}/${scanned} opencli wrapper(s) to current self-healing form`);
|
|
15098
|
+
}
|
|
15099
|
+
} catch (err) {
|
|
15100
|
+
logger.warn(`[Daemon] opencli wrapper refresh skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
15101
|
+
}
|
|
15102
|
+
}
|
|
14862
15103
|
const runningAgentIds = this.agentManager.getRunningAgentIds();
|
|
14863
15104
|
const idleAgentSessions = this.agentManager.getIdleAgentSessionIds();
|
|
14864
15105
|
const runtimeProfileReports = this.agentManager.getAgentRuntimeProfileReports();
|
|
@@ -14948,6 +15189,8 @@ var DaemonCore = class {
|
|
|
14948
15189
|
};
|
|
14949
15190
|
|
|
14950
15191
|
export {
|
|
15192
|
+
DAEMON_API_KEY_ENV,
|
|
15193
|
+
scrubDaemonAuthEnv,
|
|
14951
15194
|
subscribeDaemonLogs,
|
|
14952
15195
|
resolveWorkspaceDirectoryPath,
|
|
14953
15196
|
scanWorkspaceDirectories,
|