@clawos-dev/clawd 0.2.225 → 0.2.227
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.cjs +45 -23
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -41919,7 +41919,7 @@ var CONTACT_SSH_SYSTEM_PROMPT_HINT = `## \u8DE8\u8BBE\u5907\u6587\u4EF6\u8BBF\u9
|
|
|
41919
41919
|
|
|
41920
41920
|
**\u6CE8\u610F**\uFF1A
|
|
41921
41921
|
- \u6388\u6743\u76EE\u5F55\u6570\u636E\u6E90\u5B9E\u65F6\uFF08jail \u6BCF\u6B21\u8BFB A \u4FA7\u6700\u65B0\u914D\u7F6E\uFF09\uFF0CA \u6539\u4E86\u6388\u6743\u540E\u4F60\u4E0B\u4E00\u6B21\u62E8\u53F7\u7ACB\u5373\u611F\u77E5
|
|
41922
|
-
- \u6392\u969C\uFF1A\u672C\u673A debug \u65E5\u5FD7\u5728 \`~/.clawd/contact-ssh.log\`\uFF08\u7528\u6237\u53EF \`tail -f\` \u770B\u6BCF\u4E00\u6B65\uFF09\uFF0C\u4F60\u51FA\u9519\u65F6\u544A\u8BC9\u7528\u6237\u67E5\u8FD9\u4E2A\u6587\u4EF6
|
|
41922
|
+
- \u6392\u969C\uFF1A\u672C\u673A debug \u65E5\u5FD7\u5728 \`~/.clawd/log/contact-ssh.log\`\uFF08\u7528\u6237\u53EF \`tail -f\` \u770B\u6BCF\u4E00\u6B65\uFF09\uFF0C\u4F60\u51FA\u9519\u65F6\u544A\u8BC9\u7528\u6237\u67E5\u8FD9\u4E2A\u6587\u4EF6
|
|
41923
41923
|
- \u5982\u679C \`ls ~/.clawd/contact-ssh-keys/\` \u4E3A\u7A7A\uFF0C\u8BF4\u660E\u8FD8\u6CA1\u6709\u5BF9\u7AEF\u6388\u6743\u4F60\u6216 key \u8FD8\u6CA1\u62C9\u5230\uFF08B \u4FA7 daemon \u6BCF 60s \u4E00\u6B21\u81EA\u52A8\u62C9\uFF09\uFF0C\u5982\u5B9E\u544A\u8BC9\u7528\u6237
|
|
41924
41924
|
`;
|
|
41925
41925
|
|
|
@@ -48364,6 +48364,12 @@ function computeNextRunAtMs(schedule, fromMs) {
|
|
|
48364
48364
|
}
|
|
48365
48365
|
|
|
48366
48366
|
// src/shift/store.ts
|
|
48367
|
+
function normalizeSchedule(schedule, nowMs) {
|
|
48368
|
+
if (schedule.kind === "every" && schedule.anchorMs === void 0) {
|
|
48369
|
+
return { ...schedule, anchorMs: nowMs };
|
|
48370
|
+
}
|
|
48371
|
+
return schedule;
|
|
48372
|
+
}
|
|
48367
48373
|
function createShiftStore(deps) {
|
|
48368
48374
|
let shifts = [];
|
|
48369
48375
|
let flushTimer = null;
|
|
@@ -48382,7 +48388,15 @@ function createShiftStore(deps) {
|
|
|
48382
48388
|
if (parsed.version !== 1) {
|
|
48383
48389
|
throw new Error(`shift.json: unsupported version ${parsed.version}`);
|
|
48384
48390
|
}
|
|
48385
|
-
|
|
48391
|
+
const now = deps.now();
|
|
48392
|
+
shifts = (parsed.shifts ?? []).map((s) => {
|
|
48393
|
+
const schedule = normalizeSchedule(s.schedule, s.createdAtMs);
|
|
48394
|
+
if (schedule === s.schedule) return s;
|
|
48395
|
+
const gridNext = computeNextRunAtMs(schedule, now) ?? void 0;
|
|
48396
|
+
const oldNext = s.state.nextRunAtMs;
|
|
48397
|
+
const nextRunAtMs = gridNext !== void 0 && (oldNext === void 0 || gridNext < oldNext) ? gridNext : oldNext;
|
|
48398
|
+
return { ...s, schedule, state: { ...s.state, nextRunAtMs } };
|
|
48399
|
+
});
|
|
48386
48400
|
}
|
|
48387
48401
|
async function flushNow() {
|
|
48388
48402
|
if (flushTimer) {
|
|
@@ -48415,9 +48429,11 @@ function createShiftStore(deps) {
|
|
|
48415
48429
|
}
|
|
48416
48430
|
function add(input) {
|
|
48417
48431
|
const now = deps.now();
|
|
48418
|
-
const
|
|
48432
|
+
const schedule = normalizeSchedule(input.schedule, now);
|
|
48433
|
+
const nextRunAtMs = computeNextRunAtMs(schedule, now) ?? void 0;
|
|
48419
48434
|
const shift = {
|
|
48420
48435
|
...input,
|
|
48436
|
+
schedule,
|
|
48421
48437
|
id: (0, import_node_crypto6.randomUUID)(),
|
|
48422
48438
|
createdAtMs: now,
|
|
48423
48439
|
updatedAtMs: now,
|
|
@@ -48432,8 +48448,8 @@ function createShiftStore(deps) {
|
|
|
48432
48448
|
const idx = shifts.findIndex((s) => s.id === id);
|
|
48433
48449
|
if (idx < 0) throw new Error(`shift not found: ${id}`);
|
|
48434
48450
|
const now = deps.now();
|
|
48435
|
-
const newSchedule = patch.schedule
|
|
48436
|
-
const nextRunAtMs = patch.schedule ? computeNextRunAtMs(
|
|
48451
|
+
const newSchedule = patch.schedule ? normalizeSchedule(patch.schedule, now) : shifts[idx].schedule;
|
|
48452
|
+
const nextRunAtMs = patch.schedule ? computeNextRunAtMs(newSchedule, now) ?? void 0 : shifts[idx].state.nextRunAtMs;
|
|
48437
48453
|
const merged = {
|
|
48438
48454
|
...shifts[idx],
|
|
48439
48455
|
...patch,
|
|
@@ -48529,13 +48545,10 @@ function createShiftScheduler(deps) {
|
|
|
48529
48545
|
async function tickNow() {
|
|
48530
48546
|
const now = deps.now();
|
|
48531
48547
|
if (now < lastTickAtMs || now - lastTickAtMs > CLOCK_JUMP_THRESHOLD_MS) {
|
|
48532
|
-
for (const shift of deps.store.list()) {
|
|
48533
|
-
const next = computeNextRunAtMs(shift.schedule, now) ?? void 0;
|
|
48534
|
-
deps.store.patchState(shift.id, { nextRunAtMs: next });
|
|
48535
|
-
}
|
|
48536
48548
|
deps.logger?.warn("shift.scheduler.clock_jump", {
|
|
48537
48549
|
lastTickAtMs,
|
|
48538
|
-
now
|
|
48550
|
+
now,
|
|
48551
|
+
gapMs: now - lastTickAtMs
|
|
48539
48552
|
});
|
|
48540
48553
|
}
|
|
48541
48554
|
lastTickAtMs = now;
|
|
@@ -53190,7 +53203,9 @@ var TunnelManager = class {
|
|
|
53190
53203
|
const proc = (this.deps.spawnImpl ?? import_node_child_process9.spawn)(frpcBin, ["-c", tomlPath], {
|
|
53191
53204
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53192
53205
|
});
|
|
53193
|
-
const
|
|
53206
|
+
const logDir = import_node_path35.default.join(this.deps.dataDir, "log");
|
|
53207
|
+
import_node_fs34.default.mkdirSync(logDir, { recursive: true });
|
|
53208
|
+
const logFilePath = import_node_path35.default.join(logDir, "frpc.log");
|
|
53194
53209
|
const logStream = import_node_fs34.default.createWriteStream(logFilePath, { flags: "a", mode: 384 });
|
|
53195
53210
|
logStream.on("error", () => {
|
|
53196
53211
|
});
|
|
@@ -53431,8 +53446,11 @@ var CLAWD_SSH_JAIL_SCRIPT = String.raw`#!/usr/bin/env bash
|
|
|
53431
53446
|
|
|
53432
53447
|
set -euo pipefail
|
|
53433
53448
|
|
|
53434
|
-
# 用户可读审计日志:追加到 ~/.clawd/contact-ssh.log(跟 daemon TS 侧 contact-ssh-log.ts 共写)
|
|
53435
|
-
|
|
53449
|
+
# 用户可读审计日志:追加到 ~/.clawd/log/contact-ssh.log(跟 daemon TS 侧 contact-ssh-log.ts 共写)
|
|
53450
|
+
# bash 侧写死 ~/.clawd/log/,因为 jail 脚本在 authorized_keys command= 里被 sshd 起,
|
|
53451
|
+
# 拿不到 daemon --data-dir 覆盖。dev daemon 用 --data-dir=/tmp/x 时 jail 仍写 ~/.clawd/log/,
|
|
53452
|
+
# 跟改动前 (~/.clawd/contact-ssh.log) 一样的分歧行为,不做统一。
|
|
53453
|
+
CONTACT_SSH_LOG="${"${HOME}"}/.clawd/log/contact-ssh.log"
|
|
53436
53454
|
log_line() {
|
|
53437
53455
|
# 参数: level tag msg
|
|
53438
53456
|
local ts
|
|
@@ -53629,7 +53647,9 @@ var SshdManager = class {
|
|
|
53629
53647
|
const proc = (this.deps.spawnImpl ?? import_node_child_process11.spawn)(sshdBin, ["-D", "-e", "-f", configPath], {
|
|
53630
53648
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53631
53649
|
});
|
|
53632
|
-
const
|
|
53650
|
+
const sshdLogDir = import_node_path39.default.join(this.deps.dataDir, "log");
|
|
53651
|
+
import_node_fs38.default.mkdirSync(sshdLogDir, { recursive: true });
|
|
53652
|
+
const logStream = import_node_fs38.default.createWriteStream(import_node_path39.default.join(sshdLogDir, "sshd.log"), {
|
|
53633
53653
|
flags: "a",
|
|
53634
53654
|
mode: 384
|
|
53635
53655
|
});
|
|
@@ -53810,7 +53830,7 @@ var import_node_path42 = __toESM(require("path"), 1);
|
|
|
53810
53830
|
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
53811
53831
|
var import_node_path41 = __toESM(require("path"), 1);
|
|
53812
53832
|
function createContactSshLog(dataDir) {
|
|
53813
|
-
const file = import_node_path41.default.join(dataDir, "contact-ssh.log");
|
|
53833
|
+
const file = import_node_path41.default.join(dataDir, "log", "contact-ssh.log");
|
|
53814
53834
|
function append(level, tag, message, meta) {
|
|
53815
53835
|
const time = (/* @__PURE__ */ new Date()).toISOString();
|
|
53816
53836
|
let line = `[${time}] [${level}] [${tag}] ${message}`;
|
|
@@ -59421,18 +59441,20 @@ async function startDaemon(config) {
|
|
|
59421
59441
|
sampling: logShippingCfg.sampling,
|
|
59422
59442
|
homeDir: import_node_os21.default.homedir()
|
|
59423
59443
|
});
|
|
59444
|
+
const logDir = import_node_path64.default.join(config.dataDir, "log");
|
|
59445
|
+
import_node_fs51.default.mkdirSync(logDir, { recursive: true });
|
|
59424
59446
|
const logger = createLogger({
|
|
59425
59447
|
level: config.logLevel,
|
|
59426
|
-
file: import_node_path64.default.join(
|
|
59448
|
+
file: import_node_path64.default.join(logDir, "clawd.log"),
|
|
59427
59449
|
logClient
|
|
59428
59450
|
});
|
|
59429
59451
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
59430
59452
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
59431
|
-
file: import_node_path64.default.join(
|
|
59453
|
+
file: import_node_path64.default.join(logDir, "screen-idle-probe.log"),
|
|
59432
59454
|
level: "debug"
|
|
59433
59455
|
});
|
|
59434
59456
|
logger.info("screen-idle probe logger enabled", {
|
|
59435
|
-
file: import_node_path64.default.join(
|
|
59457
|
+
file: import_node_path64.default.join(logDir, "screen-idle-probe.log")
|
|
59436
59458
|
});
|
|
59437
59459
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
59438
59460
|
const pre = stateMgr.preflight();
|
|
@@ -59603,7 +59625,7 @@ async function startDaemon(config) {
|
|
|
59603
59625
|
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) => import_node_fs51.default.existsSync(p2));
|
|
59604
59626
|
let dispatchMcpConfigPath2;
|
|
59605
59627
|
if (dispatchServerScriptPath) {
|
|
59606
|
-
const dispatchLogPath = import_node_path64.default.join(
|
|
59628
|
+
const dispatchLogPath = import_node_path64.default.join(logDir, "dispatch-mcp-server.log");
|
|
59607
59629
|
dispatchMcpConfigPath2 = writeDispatchMcpConfig({
|
|
59608
59630
|
dataDir: config.dataDir,
|
|
59609
59631
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -59626,7 +59648,7 @@ async function startDaemon(config) {
|
|
|
59626
59648
|
const ticketServerScriptPath = ticketServerCandidates.find((p2) => import_node_fs51.default.existsSync(p2));
|
|
59627
59649
|
let ticketMcpConfigPath2;
|
|
59628
59650
|
if (ticketServerScriptPath) {
|
|
59629
|
-
const ticketLogPath = import_node_path64.default.join(
|
|
59651
|
+
const ticketLogPath = import_node_path64.default.join(logDir, "ticket-mcp-server.log");
|
|
59630
59652
|
ticketMcpConfigPath2 = writeTicketMcpConfig({
|
|
59631
59653
|
dataDir: config.dataDir,
|
|
59632
59654
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -59651,7 +59673,7 @@ async function startDaemon(config) {
|
|
|
59651
59673
|
const shiftServerScriptPath = shiftServerCandidates.find((p2) => import_node_fs51.default.existsSync(p2));
|
|
59652
59674
|
let shiftMcpConfigPath2;
|
|
59653
59675
|
if (shiftServerScriptPath) {
|
|
59654
|
-
const shiftLogPath = import_node_path64.default.join(
|
|
59676
|
+
const shiftLogPath = import_node_path64.default.join(logDir, "shift-mcp-server.log");
|
|
59655
59677
|
shiftMcpConfigPath2 = await writeShiftMcpConfig({
|
|
59656
59678
|
dataDir: config.dataDir,
|
|
59657
59679
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -59675,7 +59697,7 @@ async function startDaemon(config) {
|
|
|
59675
59697
|
const inboxServerScriptPath = inboxServerCandidates.find((p2) => import_node_fs51.default.existsSync(p2));
|
|
59676
59698
|
let inboxMcpConfigPath2;
|
|
59677
59699
|
if (inboxServerScriptPath) {
|
|
59678
|
-
const inboxLogPath = import_node_path64.default.join(
|
|
59700
|
+
const inboxLogPath = import_node_path64.default.join(logDir, "inbox-mcp-server.log");
|
|
59679
59701
|
inboxMcpConfigPath2 = await writeInboxMcpConfig({
|
|
59680
59702
|
dataDir: config.dataDir,
|
|
59681
59703
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -60487,7 +60509,7 @@ async function startDaemon(config) {
|
|
|
60487
60509
|
`Tunnel: ${r.url}`,
|
|
60488
60510
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
60489
60511
|
`Frpc config: ${import_node_path64.default.join(config.dataDir, "frpc.toml")}`,
|
|
60490
|
-
`Frpc log: ${import_node_path64.default.join(
|
|
60512
|
+
`Frpc log: ${import_node_path64.default.join(logDir, "frpc.log")}`
|
|
60491
60513
|
];
|
|
60492
60514
|
const width = Math.max(...lines.map((l) => l.length));
|
|
60493
60515
|
const bar = "\u2550".repeat(width + 4);
|