dsh-lark-bot 0.19.11 → 0.19.12
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/cli.js +114 -54
- package/dist/cli.js.map +1 -1
- package/dist/plugin.js +147 -25
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -296,6 +296,16 @@ var init_profile_package = __esm({
|
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
+
// src/adapters/model-choice.ts
|
|
300
|
+
function resolveModelChoice(preferenceModel, envModel) {
|
|
301
|
+
return preferenceModel?.trim() || envModel;
|
|
302
|
+
}
|
|
303
|
+
var init_model_choice = __esm({
|
|
304
|
+
"src/adapters/model-choice.ts"() {
|
|
305
|
+
"use strict";
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
299
309
|
// src/adapters/dsh/acp-runtime.ts
|
|
300
310
|
import { spawn as spawn4 } from "cross-spawn";
|
|
301
311
|
import { existsSync as existsSync4, realpathSync as realpathSync3 } from "fs";
|
|
@@ -666,7 +676,7 @@ async function buildAcpAgentAdapter(env, preferences) {
|
|
|
666
676
|
home: homedir2(),
|
|
667
677
|
env: process.env,
|
|
668
678
|
provider: env.provider,
|
|
669
|
-
model: preferences.model
|
|
679
|
+
model: resolveModelChoice(preferences.model, env.model),
|
|
670
680
|
...env.dshExplicit ? { command: env.dshCommand, args: env.dshArgs } : {}
|
|
671
681
|
};
|
|
672
682
|
const ensure = await ensureAcpProfile(runtimeOptions);
|
|
@@ -679,7 +689,7 @@ async function buildAcpAgentAdapter(env, preferences) {
|
|
|
679
689
|
return new AcpDshAdapter({
|
|
680
690
|
launch,
|
|
681
691
|
provider: env.provider,
|
|
682
|
-
model: preferences.model
|
|
692
|
+
model: resolveModelChoice(preferences.model, env.model)
|
|
683
693
|
});
|
|
684
694
|
}
|
|
685
695
|
var AcpDshAdapter;
|
|
@@ -688,6 +698,7 @@ var init_acp_adapter = __esm({
|
|
|
688
698
|
"use strict";
|
|
689
699
|
init_acp_runtime();
|
|
690
700
|
init_event_channel();
|
|
701
|
+
init_model_choice();
|
|
691
702
|
AcpDshAdapter = class {
|
|
692
703
|
id = "dsh-acp";
|
|
693
704
|
displayName = "DeepSeek Harness (ACP)";
|
|
@@ -972,12 +983,18 @@ async function listProcesses(platform = process.platform, run = captureOutput) {
|
|
|
972
983
|
return listProcessesPosix(run);
|
|
973
984
|
}
|
|
974
985
|
async function listProcessesPosix(run) {
|
|
975
|
-
const { stdout } = await run("ps", ["-axo", "pid=,args="], 1e4);
|
|
986
|
+
const { stdout } = await run("ps", ["-axo", "pid=,ppid=,args="], 1e4);
|
|
976
987
|
const result = [];
|
|
977
988
|
for (const line of stdout.split("\n")) {
|
|
978
|
-
const match = /^\s*(\d+)\s+(.+)$/.exec(line);
|
|
979
|
-
if (match)
|
|
980
|
-
|
|
989
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(line);
|
|
990
|
+
if (!match) continue;
|
|
991
|
+
const pid = Number(match[1]);
|
|
992
|
+
const ppid = Number(match[2]);
|
|
993
|
+
if (!Number.isInteger(pid) || pid <= 0) continue;
|
|
994
|
+
if (Number.isInteger(ppid) && ppid > 0) {
|
|
995
|
+
result.push({ pid, ppid, cmdline: match[3] ?? "" });
|
|
996
|
+
} else {
|
|
997
|
+
result.push({ pid, cmdline: match[3] ?? "" });
|
|
981
998
|
}
|
|
982
999
|
}
|
|
983
1000
|
return result;
|
|
@@ -989,7 +1006,7 @@ async function listProcessesWindows(run) {
|
|
|
989
1006
|
"-NoProfile",
|
|
990
1007
|
"-NonInteractive",
|
|
991
1008
|
"-Command",
|
|
992
|
-
"Get-CimInstance Win32_Process | Select-Object ProcessId, CommandLine | ConvertTo-Json -Compress"
|
|
1009
|
+
"Get-CimInstance Win32_Process | Select-Object ProcessId, ParentProcessId, CommandLine | ConvertTo-Json -Compress"
|
|
993
1010
|
],
|
|
994
1011
|
1e4
|
|
995
1012
|
);
|
|
@@ -1000,8 +1017,11 @@ async function listProcessesWindows(run) {
|
|
|
1000
1017
|
if (typeof row !== "object" || row === null) return [];
|
|
1001
1018
|
const record = row;
|
|
1002
1019
|
const pid = Number(record.ProcessId);
|
|
1020
|
+
const ppid = Number(record.ParentProcessId);
|
|
1003
1021
|
const cmdline = record.CommandLine;
|
|
1004
|
-
|
|
1022
|
+
if (!Number.isInteger(pid) || pid <= 0 || typeof cmdline !== "string") return [];
|
|
1023
|
+
if (Number.isInteger(ppid) && ppid > 0) return [{ pid, ppid, cmdline }];
|
|
1024
|
+
return [{ pid, cmdline }];
|
|
1005
1025
|
});
|
|
1006
1026
|
} catch {
|
|
1007
1027
|
return [];
|
|
@@ -1703,7 +1723,7 @@ var DshProviderManager = class {
|
|
|
1703
1723
|
try {
|
|
1704
1724
|
catalogProviders = await this.catalog.listProviders();
|
|
1705
1725
|
} catch (error) {
|
|
1706
|
-
log.
|
|
1726
|
+
log.info("model-catalog", "refresh-failed", {
|
|
1707
1727
|
error: error instanceof Error ? error.message : String(error)
|
|
1708
1728
|
});
|
|
1709
1729
|
}
|
|
@@ -3442,6 +3462,7 @@ var WebDshAdapter = class {
|
|
|
3442
3462
|
};
|
|
3443
3463
|
|
|
3444
3464
|
// src/adapters/index.ts
|
|
3465
|
+
init_model_choice();
|
|
3445
3466
|
async function resolveAdapterRoute(input, source) {
|
|
3446
3467
|
const provider = input.provider?.trim() || void 0;
|
|
3447
3468
|
const model = input.model?.trim() || void 0;
|
|
@@ -3461,7 +3482,7 @@ async function resolveAdapterRoute(input, source) {
|
|
|
3461
3482
|
return void 0;
|
|
3462
3483
|
}
|
|
3463
3484
|
async function buildAgentAdapter(env, preferences = { stopGraceMs: void 0, model: void 0 }) {
|
|
3464
|
-
const configuredModel = preferences.model
|
|
3485
|
+
const configuredModel = resolveModelChoice(preferences.model, env.model);
|
|
3465
3486
|
const managedRoute = env.adapterMode === "sdk" || env.adapterMode === "acp" ? await resolveAdapterRoute(
|
|
3466
3487
|
{ provider: env.provider, model: configuredModel },
|
|
3467
3488
|
new DshProviderManager({ env: process.env })
|
|
@@ -3493,7 +3514,7 @@ async function buildAgentAdapter(env, preferences = { stopGraceMs: void 0, model
|
|
|
3493
3514
|
return new WebDshAdapter({
|
|
3494
3515
|
baseUrl: env.webBaseUrl,
|
|
3495
3516
|
provider: env.provider,
|
|
3496
|
-
model: preferences.model
|
|
3517
|
+
model: resolveModelChoice(preferences.model, env.model)
|
|
3497
3518
|
});
|
|
3498
3519
|
}
|
|
3499
3520
|
case "sdk":
|
|
@@ -4189,17 +4210,36 @@ var ConfigStore = class {
|
|
|
4189
4210
|
};
|
|
4190
4211
|
|
|
4191
4212
|
// src/guardian/install.ts
|
|
4192
|
-
init_own_package();
|
|
4193
|
-
init_dsh_runtime();
|
|
4194
|
-
init_process();
|
|
4195
4213
|
import { mkdir as mkdir8, readFile as readFile8, rm as rm3, writeFile as writeFile5 } from "fs/promises";
|
|
4196
4214
|
import { existsSync as existsSync5 } from "fs";
|
|
4197
4215
|
import { homedir as homedir6 } from "os";
|
|
4198
|
-
import {
|
|
4216
|
+
import { dirname as dirname10, join as join11 } from "path";
|
|
4217
|
+
|
|
4218
|
+
// src/platform/path.ts
|
|
4219
|
+
import { delimiter, dirname as dirname8 } from "path";
|
|
4220
|
+
function sanitizeServicePath(nodeBin, inheritedPath = process.env.PATH) {
|
|
4221
|
+
const entries = [dirname8(nodeBin), ...inheritedPath?.split(delimiter) ?? []];
|
|
4222
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4223
|
+
return entries.filter((entry) => {
|
|
4224
|
+
if (!entry) return false;
|
|
4225
|
+
const normalized = entry.replaceAll("\\", "/");
|
|
4226
|
+
if (normalized.includes("/node_modules/.bin") || /\/_npx(?:\/|$)/.test(normalized) || /\/guardian\/update-worker\/npm-cache(?:\/|$)/.test(normalized)) {
|
|
4227
|
+
return false;
|
|
4228
|
+
}
|
|
4229
|
+
if (seen.has(entry)) return false;
|
|
4230
|
+
seen.add(entry);
|
|
4231
|
+
return true;
|
|
4232
|
+
}).join(delimiter);
|
|
4233
|
+
}
|
|
4234
|
+
|
|
4235
|
+
// src/guardian/install.ts
|
|
4236
|
+
init_own_package();
|
|
4237
|
+
init_dsh_runtime();
|
|
4238
|
+
init_process();
|
|
4199
4239
|
|
|
4200
4240
|
// src/guardian/state.ts
|
|
4201
4241
|
import { readFile as readFile7 } from "fs/promises";
|
|
4202
|
-
import { dirname as
|
|
4242
|
+
import { dirname as dirname9 } from "path";
|
|
4203
4243
|
import { mkdir as mkdir7 } from "fs/promises";
|
|
4204
4244
|
var DEFAULT_DSH_PROFILE = "dsh-lark";
|
|
4205
4245
|
var DEFAULT_BRIDGE_PROFILE = "default";
|
|
@@ -4241,7 +4281,7 @@ async function loadGuardianState(file, fallback) {
|
|
|
4241
4281
|
}
|
|
4242
4282
|
async function saveGuardianState(file, state) {
|
|
4243
4283
|
const next = { ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4244
|
-
await mkdir7(
|
|
4284
|
+
await mkdir7(dirname9(file), { recursive: true });
|
|
4245
4285
|
await writeFileAtomic(file, `${JSON.stringify(next, null, 2)}
|
|
4246
4286
|
`, { mode: 384 });
|
|
4247
4287
|
}
|
|
@@ -4295,7 +4335,7 @@ function guardianServiceFilePath(platform, root) {
|
|
|
4295
4335
|
}
|
|
4296
4336
|
function systemdUnit(nodeBin, cliEntry, env = {}) {
|
|
4297
4337
|
const renderedEnv = {
|
|
4298
|
-
PATH: env.PATH ??
|
|
4338
|
+
PATH: env.PATH ?? dirname10(nodeBin),
|
|
4299
4339
|
...env
|
|
4300
4340
|
};
|
|
4301
4341
|
const envLines = Object.entries(renderedEnv).map(([key, value]) => `Environment=${key}=${value}`).join("\n");
|
|
@@ -4318,18 +4358,7 @@ function systemdUnit(nodeBin, cliEntry, env = {}) {
|
|
|
4318
4358
|
].join("\n");
|
|
4319
4359
|
}
|
|
4320
4360
|
function stableGuardianServicePath(nodeBin, inheritedPath = process.env.PATH) {
|
|
4321
|
-
|
|
4322
|
-
const seen = /* @__PURE__ */ new Set();
|
|
4323
|
-
return entries.filter((entry) => {
|
|
4324
|
-
if (!entry) return false;
|
|
4325
|
-
const normalized = entry.replaceAll("\\", "/");
|
|
4326
|
-
if (normalized.includes("/node_modules/.bin") || /\/_npx(?:\/|$)/.test(normalized) || /\/guardian\/update-worker\/npm-cache(?:\/|$)/.test(normalized)) {
|
|
4327
|
-
return false;
|
|
4328
|
-
}
|
|
4329
|
-
if (seen.has(entry)) return false;
|
|
4330
|
-
seen.add(entry);
|
|
4331
|
-
return true;
|
|
4332
|
-
}).join(delimiter);
|
|
4361
|
+
return sanitizeServicePath(nodeBin, inheritedPath);
|
|
4333
4362
|
}
|
|
4334
4363
|
function launchdPlist(nodeBin, cliEntry, label2 = `io.dsh-lark.${GUARDIAN_LABEL}`, logPath = "/tmp/dsh-lark-guardian.log") {
|
|
4335
4364
|
return [
|
|
@@ -4666,7 +4695,7 @@ async function detectUpgradeState(options = {}) {
|
|
|
4666
4695
|
|
|
4667
4696
|
// src/upgrade/state.ts
|
|
4668
4697
|
import { mkdir as mkdir9, readFile as readFile11 } from "fs/promises";
|
|
4669
|
-
import { dirname as
|
|
4698
|
+
import { dirname as dirname11, join as join13 } from "path";
|
|
4670
4699
|
function upgradeStatePath(root) {
|
|
4671
4700
|
return join13(root, "upgrade-state.json");
|
|
4672
4701
|
}
|
|
@@ -4682,7 +4711,7 @@ async function loadUpgradeState(file) {
|
|
|
4682
4711
|
}
|
|
4683
4712
|
}
|
|
4684
4713
|
async function saveUpgradeState(file, state) {
|
|
4685
|
-
await mkdir9(
|
|
4714
|
+
await mkdir9(dirname11(file), { recursive: true });
|
|
4686
4715
|
await writeFileAtomic(file, JSON.stringify(state, null, 2));
|
|
4687
4716
|
}
|
|
4688
4717
|
|
|
@@ -4765,13 +4794,13 @@ function packageSpecFor(name, version) {
|
|
|
4765
4794
|
|
|
4766
4795
|
// src/service/manager.ts
|
|
4767
4796
|
import { mkdir as mkdir14, readFile as readFile14, rename as rename2, rm as rm7, stat as stat5 } from "fs/promises";
|
|
4768
|
-
import { dirname as
|
|
4797
|
+
import { dirname as dirname14, join as join19 } from "path";
|
|
4769
4798
|
import { homedir as homedir11 } from "os";
|
|
4770
4799
|
init_dsh_runtime();
|
|
4771
4800
|
|
|
4772
4801
|
// src/service/command.ts
|
|
4773
4802
|
import { execFile } from "child_process";
|
|
4774
|
-
import { basename as basename3, dirname as
|
|
4803
|
+
import { basename as basename3, dirname as dirname12, join as join14 } from "path";
|
|
4775
4804
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4776
4805
|
var runCommand = (command, args, options) => new Promise((resolve6) => {
|
|
4777
4806
|
execFile(
|
|
@@ -4797,7 +4826,7 @@ function resolveCliJsPath(metaUrl = import.meta.url) {
|
|
|
4797
4826
|
const current = fileURLToPath2(metaUrl);
|
|
4798
4827
|
const name = basename3(current);
|
|
4799
4828
|
if (name === "cli.js" || name === "cli.mjs" || name === "cli.cjs") return current;
|
|
4800
|
-
return join14(
|
|
4829
|
+
return join14(dirname12(current), "..", "dist", "cli.js");
|
|
4801
4830
|
}
|
|
4802
4831
|
function slugify(value) {
|
|
4803
4832
|
const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -4840,6 +4869,9 @@ function snapshotServiceEnv(source = process.env, extraKeys = [], inherited = {}
|
|
|
4840
4869
|
}
|
|
4841
4870
|
}
|
|
4842
4871
|
}
|
|
4872
|
+
if (typeof env.PATH === "string" && env.PATH.length > 0) {
|
|
4873
|
+
env.PATH = sanitizeServicePath(process.execPath, env.PATH);
|
|
4874
|
+
}
|
|
4843
4875
|
return env;
|
|
4844
4876
|
}
|
|
4845
4877
|
function formatEnvFile(env) {
|
|
@@ -5425,7 +5457,7 @@ var PortableServiceController = class {
|
|
|
5425
5457
|
|
|
5426
5458
|
// src/service/windows-task.ts
|
|
5427
5459
|
import { mkdir as mkdir13, writeFile as writeFile7 } from "fs/promises";
|
|
5428
|
-
import { dirname as
|
|
5460
|
+
import { dirname as dirname13, join as join18 } from "path";
|
|
5429
5461
|
function psQuote(value) {
|
|
5430
5462
|
return `'${value.replace(/'/g, "''")}'`;
|
|
5431
5463
|
}
|
|
@@ -5436,7 +5468,7 @@ function buildScheduledTaskScript(action, spec) {
|
|
|
5436
5468
|
`$arguments = ${psQuote(spec.commandArgs.map((arg) => `"${arg.replace(/"/g, '\\"')}"`).join(" "))}`,
|
|
5437
5469
|
`$log = ${psQuote(spec.logFile)}`,
|
|
5438
5470
|
`$profile = ${psQuote(spec.profile)}`,
|
|
5439
|
-
`$workDir = ${psQuote(
|
|
5471
|
+
`$workDir = ${psQuote(dirname13(spec.commandPath))}`
|
|
5440
5472
|
].join("\n");
|
|
5441
5473
|
const install = [
|
|
5442
5474
|
`$inner = '"' + $command + '" ' + $arguments + ' >> "' + $log + '" 2>&1'`,
|
|
@@ -5655,7 +5687,7 @@ var ServiceManager = class {
|
|
|
5655
5687
|
}
|
|
5656
5688
|
async withLifecycleLock(operation) {
|
|
5657
5689
|
const lockDir = this.paths.serviceLockDir(this.profile);
|
|
5658
|
-
await mkdir14(
|
|
5690
|
+
await mkdir14(dirname14(lockDir), { recursive: true });
|
|
5659
5691
|
try {
|
|
5660
5692
|
await mkdir14(lockDir);
|
|
5661
5693
|
} catch (error) {
|
|
@@ -5695,11 +5727,39 @@ var ServiceManager = class {
|
|
|
5695
5727
|
if (serviceStatus.state === "running") return;
|
|
5696
5728
|
const process2 = await this.findProcess(this.profile);
|
|
5697
5729
|
if (process2) {
|
|
5730
|
+
if (await this.isGuardianSpawned(process2)) {
|
|
5731
|
+
await this.stopGuardianSpawnedProcess(process2.pid);
|
|
5732
|
+
return;
|
|
5733
|
+
}
|
|
5698
5734
|
throw new Error(
|
|
5699
5735
|
`\u68C0\u6D4B\u5230\u672A\u53D7\u7BA1\u7684 dsh --profile ${this.profile}\uFF08pid ${process2.pid}\uFF09\u3002\u8BF7\u5148\u5728\u539F\u7EC8\u7AEF\u505C\u6B62\u5B83\uFF0C\u518D\u91CD\u8BD5\u3002`
|
|
5700
5736
|
);
|
|
5701
5737
|
}
|
|
5702
5738
|
}
|
|
5739
|
+
/** True when the profile process was spawned by the resident guardian. */
|
|
5740
|
+
async isGuardianSpawned(process2) {
|
|
5741
|
+
const ppid = process2.ppid;
|
|
5742
|
+
if (!ppid) return false;
|
|
5743
|
+
const parent = (await listProcesses()).find((entry) => entry.pid === ppid);
|
|
5744
|
+
return parent !== void 0 && matchGuardianProcess(parent.cmdline);
|
|
5745
|
+
}
|
|
5746
|
+
/** Best-effort stop of a guardian-spawned profile process (grace, then kill). */
|
|
5747
|
+
async stopGuardianSpawnedProcess(pid) {
|
|
5748
|
+
try {
|
|
5749
|
+
process.kill(pid, "SIGTERM");
|
|
5750
|
+
} catch {
|
|
5751
|
+
return;
|
|
5752
|
+
}
|
|
5753
|
+
const deadline = Date.now() + 5e3;
|
|
5754
|
+
while (Date.now() < deadline && isPidAlive2(pid)) {
|
|
5755
|
+
await new Promise((resolve6) => setTimeout(resolve6, 100));
|
|
5756
|
+
}
|
|
5757
|
+
if (!isPidAlive2(pid)) return;
|
|
5758
|
+
try {
|
|
5759
|
+
process.kill(pid, "SIGKILL");
|
|
5760
|
+
} catch {
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5703
5763
|
async buildSpec(requireProfile = false) {
|
|
5704
5764
|
const previous = await this.readMetadata();
|
|
5705
5765
|
const dshBin = this.dshBinOverride ?? discoverDshBin(this.home, this.sourceEnv) ?? previous?.dshBin;
|
|
@@ -5796,8 +5856,8 @@ var ServiceManager = class {
|
|
|
5796
5856
|
}
|
|
5797
5857
|
}
|
|
5798
5858
|
async prepareFiles(spec, platform) {
|
|
5799
|
-
await mkdir14(
|
|
5800
|
-
await mkdir14(
|
|
5859
|
+
await mkdir14(dirname14(spec.logFile), { recursive: true });
|
|
5860
|
+
await mkdir14(dirname14(spec.envFile), { recursive: true });
|
|
5801
5861
|
await writeServiceEnv(spec.envFile, spec.env);
|
|
5802
5862
|
if (platform === "win32-task") {
|
|
5803
5863
|
try {
|
|
@@ -10461,7 +10521,7 @@ async function handleConfigHubAction(action, ctx, value = {}) {
|
|
|
10461
10521
|
}
|
|
10462
10522
|
|
|
10463
10523
|
// src/commands/archive.ts
|
|
10464
|
-
import { dirname as
|
|
10524
|
+
import { dirname as dirname15 } from "path";
|
|
10465
10525
|
|
|
10466
10526
|
// src/media/outbound-files.ts
|
|
10467
10527
|
import { constants } from "fs";
|
|
@@ -10657,7 +10717,7 @@ async function sendArchiveFiles(ctx, record, destination = {
|
|
|
10657
10717
|
[record.jsonlPath, `${record.archiveId}.jsonl`]
|
|
10658
10718
|
]) {
|
|
10659
10719
|
try {
|
|
10660
|
-
const prepared = await prepareOutboundFile({ path, baseDir:
|
|
10720
|
+
const prepared = await prepareOutboundFile({ path, baseDir: dirname15(path), allowedRoots: [dirname15(path)], fileName });
|
|
10661
10721
|
await ctx.channel.sendFile(destination.chatId, prepared.fileName, prepared.content, {
|
|
10662
10722
|
...destination.messageId ? { replyTo: destination.messageId } : {},
|
|
10663
10723
|
...destination.threadId ? { threadId: destination.threadId } : {}
|
|
@@ -16665,7 +16725,7 @@ async function safeRemove(path) {
|
|
|
16665
16725
|
import { execFile as execFile3 } from "child_process";
|
|
16666
16726
|
import { createHash as createHash2, randomBytes as randomBytes4 } from "crypto";
|
|
16667
16727
|
import { access as access2, copyFile, mkdir as mkdir18, realpath as realpath2 } from "fs/promises";
|
|
16668
|
-
import { dirname as
|
|
16728
|
+
import { dirname as dirname16, join as join25 } from "path";
|
|
16669
16729
|
import { promisify as promisify2 } from "util";
|
|
16670
16730
|
var execFileAsync2 = promisify2(execFile3);
|
|
16671
16731
|
async function defaultRunGit2(args, cwd) {
|
|
@@ -16684,7 +16744,7 @@ async function exists2(path) {
|
|
|
16684
16744
|
}
|
|
16685
16745
|
}
|
|
16686
16746
|
async function defaultCopyRulesFile(source, target) {
|
|
16687
|
-
await mkdir18(
|
|
16747
|
+
await mkdir18(dirname16(target), { recursive: true });
|
|
16688
16748
|
await copyFile(source, target);
|
|
16689
16749
|
}
|
|
16690
16750
|
function slugify2(scope) {
|
|
@@ -16902,7 +16962,7 @@ var UpdateNotifier = class {
|
|
|
16902
16962
|
|
|
16903
16963
|
// src/bot/fleet-store.ts
|
|
16904
16964
|
import { mkdir as mkdir19, readFile as readFile28 } from "fs/promises";
|
|
16905
|
-
import { dirname as
|
|
16965
|
+
import { dirname as dirname17 } from "path";
|
|
16906
16966
|
function validBotInstanceName(name) {
|
|
16907
16967
|
return /^[a-z][a-z0-9-]{0,31}$/u.test(name);
|
|
16908
16968
|
}
|
|
@@ -17023,7 +17083,7 @@ var BotFleetStore = class {
|
|
|
17023
17083
|
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
17024
17084
|
}
|
|
17025
17085
|
async persist() {
|
|
17026
|
-
await mkdir19(
|
|
17086
|
+
await mkdir19(dirname17(this.path), { recursive: true });
|
|
17027
17087
|
await writeFileAtomic(this.path, `${JSON.stringify(this.data, null, 2)}
|
|
17028
17088
|
`, { mode: 384 });
|
|
17029
17089
|
}
|
|
@@ -17043,7 +17103,7 @@ function isFleetEntry(value) {
|
|
|
17043
17103
|
|
|
17044
17104
|
// src/bot/handoff-guard.ts
|
|
17045
17105
|
import { mkdir as mkdir20, readFile as readFile29 } from "fs/promises";
|
|
17046
|
-
import { dirname as
|
|
17106
|
+
import { dirname as dirname18 } from "path";
|
|
17047
17107
|
var BotHandoffGuard = class {
|
|
17048
17108
|
constructor(path) {
|
|
17049
17109
|
this.path = path;
|
|
@@ -17091,7 +17151,7 @@ var BotHandoffGuard = class {
|
|
|
17091
17151
|
}
|
|
17092
17152
|
}
|
|
17093
17153
|
async write(data) {
|
|
17094
|
-
await mkdir20(
|
|
17154
|
+
await mkdir20(dirname18(this.path), { recursive: true });
|
|
17095
17155
|
await writeFileAtomic(this.path, `${JSON.stringify(data, null, 2)}
|
|
17096
17156
|
`, { mode: 384 });
|
|
17097
17157
|
}
|
|
@@ -17874,7 +17934,7 @@ init_own_package();
|
|
|
17874
17934
|
import { createHash as createHash3, randomUUID as randomUUID13 } from "crypto";
|
|
17875
17935
|
import { spawn as spawn7 } from "child_process";
|
|
17876
17936
|
import { chmod, mkdir as mkdir21, readFile as readFile31, rm as rm10 } from "fs/promises";
|
|
17877
|
-
import { dirname as
|
|
17937
|
+
import { dirname as dirname19, join as join26 } from "path";
|
|
17878
17938
|
init_own_package();
|
|
17879
17939
|
init_process();
|
|
17880
17940
|
function guardianUpdateFailureHint(code) {
|
|
@@ -17911,7 +17971,7 @@ async function loadState(file) {
|
|
|
17911
17971
|
}
|
|
17912
17972
|
}
|
|
17913
17973
|
async function saveState(file, state) {
|
|
17914
|
-
await mkdir21(
|
|
17974
|
+
await mkdir21(dirname19(file), { recursive: true });
|
|
17915
17975
|
await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
|
|
17916
17976
|
`, { mode: 384 });
|
|
17917
17977
|
}
|
|
@@ -17986,7 +18046,7 @@ async function runGuardianUpdateWorker(request, options = {}) {
|
|
|
17986
18046
|
if (delayMs > 0) await new Promise((resolve6) => setTimeout(resolve6, delayMs));
|
|
17987
18047
|
const spec = `${state.packageName}@${state.targetVersion}`;
|
|
17988
18048
|
const run = options.run ?? captureOutput;
|
|
17989
|
-
const workerRoot = join26(
|
|
18049
|
+
const workerRoot = join26(dirname19(request.stateFile), "update-worker");
|
|
17990
18050
|
const cacheRoot = join26(workerRoot, "npm-cache");
|
|
17991
18051
|
const cacheDir = join26(
|
|
17992
18052
|
cacheRoot,
|
|
@@ -21166,7 +21226,7 @@ function followLogFile(path, lines) {
|
|
|
21166
21226
|
// src/cli/commands/supervise.ts
|
|
21167
21227
|
import { spawn as spawn10 } from "child_process";
|
|
21168
21228
|
import { closeSync, mkdirSync, openSync } from "fs";
|
|
21169
|
-
import { dirname as
|
|
21229
|
+
import { dirname as dirname20 } from "path";
|
|
21170
21230
|
import { homedir as homedir22 } from "os";
|
|
21171
21231
|
init_dsh_runtime();
|
|
21172
21232
|
var BASE_BACKOFF_MS = 5e3;
|
|
@@ -21200,8 +21260,8 @@ async function runSupervise(options, deps = {}) {
|
|
|
21200
21260
|
const logFile = paths.serviceLogFile(profile);
|
|
21201
21261
|
const dshBin = deps.dshBin ?? discoverDshBin(homedir22(), childEnv);
|
|
21202
21262
|
if (!dshBin) throw new Error("\u672A\u627E\u5230 dsh CLI\uFF0Cportable supervisor \u65E0\u6CD5\u542F\u52A8 profile\u3002");
|
|
21203
|
-
mkdirSync(
|
|
21204
|
-
mkdirSync(
|
|
21263
|
+
mkdirSync(dirname20(statusFile), { recursive: true });
|
|
21264
|
+
mkdirSync(dirname20(logFile), { recursive: true });
|
|
21205
21265
|
const logFd = openSync(logFile, "a");
|
|
21206
21266
|
const writeStatus = async (state, childPid, restarts2) => {
|
|
21207
21267
|
const processIdentity = await (deps.readProcessIdentity ?? readLinuxProcessIdentity)(process.pid);
|