@getworkle/cli 0.2.7 → 0.2.9
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 +199 -117
- package/dist/cli.js.map +1 -1
- package/package.json +4 -5
package/dist/cli.js
CHANGED
|
@@ -1209,7 +1209,7 @@ var require_command = __commonJS({
|
|
|
1209
1209
|
"use strict";
|
|
1210
1210
|
var EventEmitter = __require("events").EventEmitter;
|
|
1211
1211
|
var childProcess = __require("child_process");
|
|
1212
|
-
var
|
|
1212
|
+
var path20 = __require("path");
|
|
1213
1213
|
var fs17 = __require("fs");
|
|
1214
1214
|
var process2 = __require("process");
|
|
1215
1215
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2222,9 +2222,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2222
2222
|
let launchWithNode = false;
|
|
2223
2223
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2224
2224
|
function findFile(baseDir, baseName) {
|
|
2225
|
-
const localBin =
|
|
2225
|
+
const localBin = path20.resolve(baseDir, baseName);
|
|
2226
2226
|
if (fs17.existsSync(localBin)) return localBin;
|
|
2227
|
-
if (sourceExt.includes(
|
|
2227
|
+
if (sourceExt.includes(path20.extname(baseName))) return void 0;
|
|
2228
2228
|
const foundExt = sourceExt.find(
|
|
2229
2229
|
(ext) => fs17.existsSync(`${localBin}${ext}`)
|
|
2230
2230
|
);
|
|
@@ -2242,17 +2242,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2242
2242
|
} catch {
|
|
2243
2243
|
resolvedScriptPath = this._scriptPath;
|
|
2244
2244
|
}
|
|
2245
|
-
executableDir =
|
|
2246
|
-
|
|
2245
|
+
executableDir = path20.resolve(
|
|
2246
|
+
path20.dirname(resolvedScriptPath),
|
|
2247
2247
|
executableDir
|
|
2248
2248
|
);
|
|
2249
2249
|
}
|
|
2250
2250
|
if (executableDir) {
|
|
2251
2251
|
let localFile = findFile(executableDir, executableFile);
|
|
2252
2252
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2253
|
-
const legacyName =
|
|
2253
|
+
const legacyName = path20.basename(
|
|
2254
2254
|
this._scriptPath,
|
|
2255
|
-
|
|
2255
|
+
path20.extname(this._scriptPath)
|
|
2256
2256
|
);
|
|
2257
2257
|
if (legacyName !== this._name) {
|
|
2258
2258
|
localFile = findFile(
|
|
@@ -2263,7 +2263,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2263
2263
|
}
|
|
2264
2264
|
executableFile = localFile || executableFile;
|
|
2265
2265
|
}
|
|
2266
|
-
launchWithNode = sourceExt.includes(
|
|
2266
|
+
launchWithNode = sourceExt.includes(path20.extname(executableFile));
|
|
2267
2267
|
let proc;
|
|
2268
2268
|
if (process2.platform !== "win32") {
|
|
2269
2269
|
if (launchWithNode) {
|
|
@@ -3178,7 +3178,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3178
3178
|
* @return {Command}
|
|
3179
3179
|
*/
|
|
3180
3180
|
nameFromFilename(filename) {
|
|
3181
|
-
this._name =
|
|
3181
|
+
this._name = path20.basename(filename, path20.extname(filename));
|
|
3182
3182
|
return this;
|
|
3183
3183
|
}
|
|
3184
3184
|
/**
|
|
@@ -3192,9 +3192,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3192
3192
|
* @param {string} [path]
|
|
3193
3193
|
* @return {(string|null|Command)}
|
|
3194
3194
|
*/
|
|
3195
|
-
executableDir(
|
|
3196
|
-
if (
|
|
3197
|
-
this._executableDir =
|
|
3195
|
+
executableDir(path21) {
|
|
3196
|
+
if (path21 === void 0) return this._executableDir;
|
|
3197
|
+
this._executableDir = path21;
|
|
3198
3198
|
return this;
|
|
3199
3199
|
}
|
|
3200
3200
|
/**
|
|
@@ -4285,7 +4285,7 @@ var require_background_scheduled_task = __commonJS({
|
|
|
4285
4285
|
"../../node_modules/node-cron/src/background-scheduled-task/index.js"(exports, module) {
|
|
4286
4286
|
"use strict";
|
|
4287
4287
|
var EventEmitter = __require("events");
|
|
4288
|
-
var
|
|
4288
|
+
var path20 = __require("path");
|
|
4289
4289
|
var { fork } = __require("child_process");
|
|
4290
4290
|
var uuid3 = (init_esm_node(), __toCommonJS(esm_node_exports));
|
|
4291
4291
|
var daemonPath = `${__dirname}/daemon.js`;
|
|
@@ -4320,7 +4320,7 @@ var require_background_scheduled_task = __commonJS({
|
|
|
4320
4320
|
options.scheduled = true;
|
|
4321
4321
|
this.forkProcess.send({
|
|
4322
4322
|
type: "register",
|
|
4323
|
-
path:
|
|
4323
|
+
path: path20.resolve(this.taskPath),
|
|
4324
4324
|
cron: this.cronExpression,
|
|
4325
4325
|
options
|
|
4326
4326
|
});
|
|
@@ -8033,7 +8033,7 @@ import { readFileSync } from "fs";
|
|
|
8033
8033
|
import fs16 from "fs/promises";
|
|
8034
8034
|
import http2 from "http";
|
|
8035
8035
|
import os18 from "os";
|
|
8036
|
-
import
|
|
8036
|
+
import path19 from "path";
|
|
8037
8037
|
|
|
8038
8038
|
// src/agents/config-materializer.ts
|
|
8039
8039
|
import fs2 from "fs/promises";
|
|
@@ -8249,13 +8249,22 @@ var AgentConfigMaterializer = class {
|
|
|
8249
8249
|
};
|
|
8250
8250
|
|
|
8251
8251
|
// src/agents/runner.ts
|
|
8252
|
+
import { createRequire } from "module";
|
|
8253
|
+
import path4 from "path";
|
|
8252
8254
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
8255
|
+
function resolveClaudeCodeExecutable() {
|
|
8256
|
+
const sdkEntry = createRequire(import.meta.url).resolve(
|
|
8257
|
+
"@anthropic-ai/claude-agent-sdk"
|
|
8258
|
+
);
|
|
8259
|
+
return path4.join(path4.dirname(sdkEntry), "cli.js");
|
|
8260
|
+
}
|
|
8253
8261
|
async function runAgent(opts) {
|
|
8254
8262
|
const { agentDir, prompt, sessionId, maxTurns, mcpServers, onMessage, abortController } = opts;
|
|
8255
8263
|
try {
|
|
8256
8264
|
const stream = query({
|
|
8257
8265
|
prompt,
|
|
8258
8266
|
options: {
|
|
8267
|
+
pathToClaudeCodeExecutable: resolveClaudeCodeExecutable(),
|
|
8259
8268
|
cwd: agentDir,
|
|
8260
8269
|
settingSources: ["project"],
|
|
8261
8270
|
...sessionId ? { resume: sessionId } : {},
|
|
@@ -9058,10 +9067,10 @@ function mergeDefs(...defs) {
|
|
|
9058
9067
|
function cloneDef(schema) {
|
|
9059
9068
|
return mergeDefs(schema._zod.def);
|
|
9060
9069
|
}
|
|
9061
|
-
function getElementAtPath(obj,
|
|
9062
|
-
if (!
|
|
9070
|
+
function getElementAtPath(obj, path20) {
|
|
9071
|
+
if (!path20)
|
|
9063
9072
|
return obj;
|
|
9064
|
-
return
|
|
9073
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
9065
9074
|
}
|
|
9066
9075
|
function promiseAllObject(promisesObj) {
|
|
9067
9076
|
const keys = Object.keys(promisesObj);
|
|
@@ -9427,11 +9436,11 @@ function aborted(x, startIndex = 0) {
|
|
|
9427
9436
|
}
|
|
9428
9437
|
return false;
|
|
9429
9438
|
}
|
|
9430
|
-
function prefixIssues(
|
|
9439
|
+
function prefixIssues(path20, issues) {
|
|
9431
9440
|
return issues.map((iss) => {
|
|
9432
9441
|
var _a2;
|
|
9433
9442
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
9434
|
-
iss.path.unshift(
|
|
9443
|
+
iss.path.unshift(path20);
|
|
9435
9444
|
return iss;
|
|
9436
9445
|
});
|
|
9437
9446
|
}
|
|
@@ -9593,7 +9602,7 @@ function formatError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9593
9602
|
}
|
|
9594
9603
|
function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
9595
9604
|
const result = { errors: [] };
|
|
9596
|
-
const processError = (error47,
|
|
9605
|
+
const processError = (error47, path20 = []) => {
|
|
9597
9606
|
var _a2, _b;
|
|
9598
9607
|
for (const issue2 of error47.issues) {
|
|
9599
9608
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -9603,7 +9612,7 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9603
9612
|
} else if (issue2.code === "invalid_element") {
|
|
9604
9613
|
processError({ issues: issue2.issues }, issue2.path);
|
|
9605
9614
|
} else {
|
|
9606
|
-
const fullpath = [...
|
|
9615
|
+
const fullpath = [...path20, ...issue2.path];
|
|
9607
9616
|
if (fullpath.length === 0) {
|
|
9608
9617
|
result.errors.push(mapper(issue2));
|
|
9609
9618
|
continue;
|
|
@@ -9635,8 +9644,8 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9635
9644
|
}
|
|
9636
9645
|
function toDotPath(_path) {
|
|
9637
9646
|
const segs = [];
|
|
9638
|
-
const
|
|
9639
|
-
for (const seg of
|
|
9647
|
+
const path20 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
9648
|
+
for (const seg of path20) {
|
|
9640
9649
|
if (typeof seg === "number")
|
|
9641
9650
|
segs.push(`[${seg}]`);
|
|
9642
9651
|
else if (typeof seg === "symbol")
|
|
@@ -20972,23 +20981,23 @@ function date4(params) {
|
|
|
20972
20981
|
config(en_default());
|
|
20973
20982
|
|
|
20974
20983
|
// src/agents/mcp-server.ts
|
|
20975
|
-
async function apiGet(apiUrl,
|
|
20976
|
-
const res = await fetch(`${apiUrl}${
|
|
20984
|
+
async function apiGet(apiUrl, path20, headers) {
|
|
20985
|
+
const res = await fetch(`${apiUrl}${path20}`, {
|
|
20977
20986
|
headers: { ...headers, "Content-Type": "application/json" }
|
|
20978
20987
|
});
|
|
20979
20988
|
if (!res.ok) {
|
|
20980
|
-
throw new Error(`API GET ${
|
|
20989
|
+
throw new Error(`API GET ${path20} failed: HTTP ${res.status}`);
|
|
20981
20990
|
}
|
|
20982
20991
|
return res.json();
|
|
20983
20992
|
}
|
|
20984
|
-
async function apiPost(apiUrl,
|
|
20985
|
-
const res = await fetch(`${apiUrl}${
|
|
20993
|
+
async function apiPost(apiUrl, path20, body, headers) {
|
|
20994
|
+
const res = await fetch(`${apiUrl}${path20}`, {
|
|
20986
20995
|
method: "POST",
|
|
20987
20996
|
headers: { ...headers, "Content-Type": "application/json" },
|
|
20988
20997
|
body: JSON.stringify(body)
|
|
20989
20998
|
});
|
|
20990
20999
|
if (!res.ok) {
|
|
20991
|
-
throw new Error(`API POST ${
|
|
21000
|
+
throw new Error(`API POST ${path20} failed: HTTP ${res.status}`);
|
|
20992
21001
|
}
|
|
20993
21002
|
return res.json();
|
|
20994
21003
|
}
|
|
@@ -21304,8 +21313,8 @@ var RelayClient = class {
|
|
|
21304
21313
|
// src/agents/sessions.ts
|
|
21305
21314
|
import fs3 from "fs/promises";
|
|
21306
21315
|
import os4 from "os";
|
|
21307
|
-
import
|
|
21308
|
-
var SESSIONS_FILE =
|
|
21316
|
+
import path5 from "path";
|
|
21317
|
+
var SESSIONS_FILE = path5.join(
|
|
21309
21318
|
os4.homedir(),
|
|
21310
21319
|
".workle",
|
|
21311
21320
|
"agent-sessions.json"
|
|
@@ -21327,7 +21336,7 @@ async function saveSessionId(agentId, sessionId) {
|
|
|
21327
21336
|
} catch {
|
|
21328
21337
|
}
|
|
21329
21338
|
map2[agentId] = sessionId;
|
|
21330
|
-
await fs3.mkdir(
|
|
21339
|
+
await fs3.mkdir(path5.dirname(SESSIONS_FILE), { recursive: true });
|
|
21331
21340
|
await fs3.writeFile(SESSIONS_FILE, JSON.stringify(map2, null, 2), "utf-8");
|
|
21332
21341
|
}
|
|
21333
21342
|
|
|
@@ -21367,6 +21376,7 @@ var AgentService = class _AgentService {
|
|
|
21367
21376
|
scheduler;
|
|
21368
21377
|
relayClient = null;
|
|
21369
21378
|
unsubscribeRelay = null;
|
|
21379
|
+
relaySendFn = null;
|
|
21370
21380
|
/** Map of agentId -> agent stub (for name lookups). */
|
|
21371
21381
|
agentMap = /* @__PURE__ */ new Map();
|
|
21372
21382
|
/** Map of agentId -> pulled config (for schedule + runtime settings). */
|
|
@@ -21396,6 +21406,55 @@ var AgentService = class _AgentService {
|
|
|
21396
21406
|
return;
|
|
21397
21407
|
}
|
|
21398
21408
|
console.log("[agents] Starting AgentService...");
|
|
21409
|
+
await this.syncConfigsAndSchedules();
|
|
21410
|
+
const relayUrl = deriveRelayUrl(this.apiUrl);
|
|
21411
|
+
this.relayClient = new RelayClient(relayUrl, this.instanceId, this.token);
|
|
21412
|
+
this.unsubscribeRelay = this.relayClient.onMessage((msg) => {
|
|
21413
|
+
this.handleRelayMessage(msg);
|
|
21414
|
+
});
|
|
21415
|
+
await this.relayClient.connect();
|
|
21416
|
+
console.log("[agents] Connected to relay");
|
|
21417
|
+
this.running = true;
|
|
21418
|
+
console.log("[agents] AgentService running");
|
|
21419
|
+
}
|
|
21420
|
+
/**
|
|
21421
|
+
* Start embedded inside SyncService — no own relay connection.
|
|
21422
|
+
* Relay messages are forwarded via ingestRelayMessage().
|
|
21423
|
+
* Progress frames are sent via the provided sendFn.
|
|
21424
|
+
*/
|
|
21425
|
+
async startEmbedded(sendFn) {
|
|
21426
|
+
if (this.running) {
|
|
21427
|
+
console.log("[agents] AgentService already running");
|
|
21428
|
+
return;
|
|
21429
|
+
}
|
|
21430
|
+
console.log("[agents] Starting AgentService (embedded)...");
|
|
21431
|
+
this.relaySendFn = sendFn;
|
|
21432
|
+
await this.syncConfigsAndSchedules();
|
|
21433
|
+
this.running = true;
|
|
21434
|
+
console.log("[agents] AgentService running (embedded \u2014 relay via SyncService)");
|
|
21435
|
+
}
|
|
21436
|
+
/**
|
|
21437
|
+
* Handle a relay message forwarded from SyncService.
|
|
21438
|
+
*/
|
|
21439
|
+
ingestRelayMessage(msg) {
|
|
21440
|
+
this.handleRelayMessage(msg);
|
|
21441
|
+
}
|
|
21442
|
+
/**
|
|
21443
|
+
* Send a message to the relay — uses own RelayClient in standalone mode,
|
|
21444
|
+
* or the injected sendFn in embedded mode.
|
|
21445
|
+
*/
|
|
21446
|
+
sendRelay(msg) {
|
|
21447
|
+
if (this.relaySendFn) {
|
|
21448
|
+
this.relaySendFn(msg);
|
|
21449
|
+
} else if (this.relayClient?.connected) {
|
|
21450
|
+
this.relayClient.send(msg);
|
|
21451
|
+
}
|
|
21452
|
+
}
|
|
21453
|
+
isRelayConnected() {
|
|
21454
|
+
if (this.relaySendFn) return true;
|
|
21455
|
+
return this.relayClient?.connected ?? false;
|
|
21456
|
+
}
|
|
21457
|
+
async syncConfigsAndSchedules() {
|
|
21399
21458
|
const stubs = await this.materializer.listAgents();
|
|
21400
21459
|
console.log(`[agents] Found ${stubs.length} claude_code agent(s)`);
|
|
21401
21460
|
const configs = [];
|
|
@@ -21424,16 +21483,7 @@ var AgentService = class _AgentService {
|
|
|
21424
21483
|
`[agents] Materialized ${materialized.length} agent config(s)`
|
|
21425
21484
|
);
|
|
21426
21485
|
}
|
|
21427
|
-
const relayUrl = deriveRelayUrl(this.apiUrl);
|
|
21428
|
-
this.relayClient = new RelayClient(relayUrl, this.instanceId, this.token);
|
|
21429
|
-
this.unsubscribeRelay = this.relayClient.onMessage((msg) => {
|
|
21430
|
-
this.handleRelayMessage(msg);
|
|
21431
|
-
});
|
|
21432
|
-
await this.relayClient.connect();
|
|
21433
|
-
console.log("[agents] Connected to relay");
|
|
21434
21486
|
this.refreshSchedules();
|
|
21435
|
-
this.running = true;
|
|
21436
|
-
console.log("[agents] AgentService running");
|
|
21437
21487
|
}
|
|
21438
21488
|
/**
|
|
21439
21489
|
* Trigger an agent run. Prevents concurrent runs of the same agent.
|
|
@@ -21446,8 +21496,8 @@ var AgentService = class _AgentService {
|
|
|
21446
21496
|
console.log(
|
|
21447
21497
|
`[agents] Agent ${agentId} is already running \u2014 skipping trigger`
|
|
21448
21498
|
);
|
|
21449
|
-
if (executionId && this.
|
|
21450
|
-
this.
|
|
21499
|
+
if (executionId && this.isRelayConnected()) {
|
|
21500
|
+
this.sendRelay({
|
|
21451
21501
|
type: "agent.result",
|
|
21452
21502
|
payload: {
|
|
21453
21503
|
agentId,
|
|
@@ -21466,8 +21516,8 @@ var AgentService = class _AgentService {
|
|
|
21466
21516
|
}
|
|
21467
21517
|
const runExecutionId = executionId ?? randomUUID();
|
|
21468
21518
|
const sendProgressPart = (part, sessionId) => {
|
|
21469
|
-
if (this.
|
|
21470
|
-
this.
|
|
21519
|
+
if (this.isRelayConnected()) {
|
|
21520
|
+
this.sendRelay({
|
|
21471
21521
|
type: "agent.progress",
|
|
21472
21522
|
payload: {
|
|
21473
21523
|
agentId,
|
|
@@ -21673,8 +21723,8 @@ var AgentService = class _AgentService {
|
|
|
21673
21723
|
this.activeRuns.set(agentId, runPromise);
|
|
21674
21724
|
try {
|
|
21675
21725
|
const result = await runPromise;
|
|
21676
|
-
if (this.
|
|
21677
|
-
this.
|
|
21726
|
+
if (this.isRelayConnected()) {
|
|
21727
|
+
this.sendRelay({
|
|
21678
21728
|
type: "agent.result",
|
|
21679
21729
|
payload: {
|
|
21680
21730
|
agentId,
|
|
@@ -21691,8 +21741,8 @@ var AgentService = class _AgentService {
|
|
|
21691
21741
|
} catch (err) {
|
|
21692
21742
|
const error46 = err instanceof Error ? err.message : String(err);
|
|
21693
21743
|
sendProgressPart({ type: "error", message: error46 });
|
|
21694
|
-
if (this.
|
|
21695
|
-
this.
|
|
21744
|
+
if (this.isRelayConnected()) {
|
|
21745
|
+
this.sendRelay({
|
|
21696
21746
|
type: "agent.result",
|
|
21697
21747
|
payload: {
|
|
21698
21748
|
agentId,
|
|
@@ -21825,10 +21875,10 @@ import { spawn } from "child_process";
|
|
|
21825
21875
|
import fs5 from "fs/promises";
|
|
21826
21876
|
import http from "http";
|
|
21827
21877
|
import os5 from "os";
|
|
21828
|
-
import
|
|
21829
|
-
var CLAW_HOME =
|
|
21830
|
-
var LOG_FILE =
|
|
21831
|
-
var PID_FILE =
|
|
21878
|
+
import path6 from "path";
|
|
21879
|
+
var CLAW_HOME = path6.join(os5.homedir(), ".workle");
|
|
21880
|
+
var LOG_FILE = path6.join(CLAW_HOME, "openclaw.log");
|
|
21881
|
+
var PID_FILE = path6.join(CLAW_HOME, "openclaw.pid");
|
|
21832
21882
|
var OPENCLAW_PORT = 18789;
|
|
21833
21883
|
var HEALTH_CHECK_TIMEOUT = 5e3;
|
|
21834
21884
|
var ProcessManager = class {
|
|
@@ -21841,7 +21891,7 @@ var ProcessManager = class {
|
|
|
21841
21891
|
* @param openclawBinary - Path to the openclaw binary (defaults to "openclaw" in PATH)
|
|
21842
21892
|
* @param configPath - Path to openclaw.json config (defaults to ~/.workle/openclaw.json)
|
|
21843
21893
|
*/
|
|
21844
|
-
async spawn(openclawBinary = "openclaw", configPath =
|
|
21894
|
+
async spawn(openclawBinary = "openclaw", configPath = path6.join(CLAW_HOME, "openclaw.json")) {
|
|
21845
21895
|
if (this.process) {
|
|
21846
21896
|
console.log("[claw] OpenClaw process already running");
|
|
21847
21897
|
return;
|
|
@@ -21973,8 +22023,8 @@ var ProcessManager = class {
|
|
|
21973
22023
|
import { execSync } from "child_process";
|
|
21974
22024
|
import fs6 from "fs/promises";
|
|
21975
22025
|
import os6 from "os";
|
|
21976
|
-
import
|
|
21977
|
-
var WORKLE_HOME2 =
|
|
22026
|
+
import path7 from "path";
|
|
22027
|
+
var WORKLE_HOME2 = path7.join(os6.homedir(), ".workle");
|
|
21978
22028
|
var MIN_NODE_MAJOR = 22;
|
|
21979
22029
|
async function runDoctor() {
|
|
21980
22030
|
const checks = [];
|
|
@@ -22057,7 +22107,7 @@ async function checkClawHome() {
|
|
|
22057
22107
|
}
|
|
22058
22108
|
}
|
|
22059
22109
|
async function checkAuthFile() {
|
|
22060
|
-
const authPath =
|
|
22110
|
+
const authPath = path7.join(WORKLE_HOME2, "auth.json");
|
|
22061
22111
|
try {
|
|
22062
22112
|
const raw = await fs6.readFile(authPath, "utf-8");
|
|
22063
22113
|
const parsed = JSON.parse(raw);
|
|
@@ -22082,7 +22132,7 @@ async function checkAuthFile() {
|
|
|
22082
22132
|
}
|
|
22083
22133
|
}
|
|
22084
22134
|
async function checkConfigFile() {
|
|
22085
|
-
const configPath =
|
|
22135
|
+
const configPath = path7.join(WORKLE_HOME2, "openclaw.json");
|
|
22086
22136
|
try {
|
|
22087
22137
|
const raw = await fs6.readFile(configPath, "utf-8");
|
|
22088
22138
|
const parsed = JSON.parse(raw);
|
|
@@ -22131,25 +22181,25 @@ async function checkGatewayReachable() {
|
|
|
22131
22181
|
// src/lifecycle/install.ts
|
|
22132
22182
|
import fs7 from "fs/promises";
|
|
22133
22183
|
import os7 from "os";
|
|
22134
|
-
import
|
|
22135
|
-
var WORKLE_HOME3 =
|
|
22136
|
-
var LAUNCH_AGENTS_DIR =
|
|
22137
|
-
var STAGED_CLI_PATH =
|
|
22184
|
+
import path8 from "path";
|
|
22185
|
+
var WORKLE_HOME3 = path8.join(os7.homedir(), ".workle");
|
|
22186
|
+
var LAUNCH_AGENTS_DIR = path8.join(os7.homedir(), "Library", "LaunchAgents");
|
|
22187
|
+
var STAGED_CLI_PATH = path8.join(WORKLE_HOME3, "bin", "cli.js");
|
|
22138
22188
|
function escapeXml(value) {
|
|
22139
22189
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
22140
22190
|
}
|
|
22141
22191
|
async function setupClawDirectory() {
|
|
22142
22192
|
const dirs = [
|
|
22143
22193
|
WORKLE_HOME3,
|
|
22144
|
-
|
|
22145
|
-
|
|
22194
|
+
path8.join(WORKLE_HOME3, "logs"),
|
|
22195
|
+
path8.join(WORKLE_HOME3, "bin")
|
|
22146
22196
|
];
|
|
22147
22197
|
for (const dir of dirs) {
|
|
22148
22198
|
await fs7.mkdir(dir, { recursive: true, mode: 448 });
|
|
22149
22199
|
await fs7.chmod(dir, 448).catch(() => {
|
|
22150
22200
|
});
|
|
22151
22201
|
}
|
|
22152
|
-
const gitignorePath =
|
|
22202
|
+
const gitignorePath = path8.join(WORKLE_HOME3, ".gitignore");
|
|
22153
22203
|
try {
|
|
22154
22204
|
await fs7.access(gitignorePath);
|
|
22155
22205
|
} catch {
|
|
@@ -22173,7 +22223,7 @@ async function stageCliForDaemon(currentCliPath) {
|
|
|
22173
22223
|
}
|
|
22174
22224
|
async function writeLaunchdPlist(serviceName = "com.workle.claw", executable = process.execPath, args = [STAGED_CLI_PATH, "start"]) {
|
|
22175
22225
|
await fs7.mkdir(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
22176
|
-
const plistPath =
|
|
22226
|
+
const plistPath = path8.join(LAUNCH_AGENTS_DIR, `${serviceName}.plist`);
|
|
22177
22227
|
const programArguments = [executable, ...args].map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n");
|
|
22178
22228
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
22179
22229
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -22197,10 +22247,10 @@ ${programArguments}
|
|
|
22197
22247
|
</dict>
|
|
22198
22248
|
|
|
22199
22249
|
<key>StandardOutPath</key>
|
|
22200
|
-
<string>${
|
|
22250
|
+
<string>${path8.join(WORKLE_HOME3, "logs", "stdout.log")}</string>
|
|
22201
22251
|
|
|
22202
22252
|
<key>StandardErrorPath</key>
|
|
22203
|
-
<string>${
|
|
22253
|
+
<string>${path8.join(WORKLE_HOME3, "logs", "stderr.log")}</string>
|
|
22204
22254
|
|
|
22205
22255
|
<key>WorkingDirectory</key>
|
|
22206
22256
|
<string>${WORKLE_HOME3}</string>
|
|
@@ -22221,18 +22271,18 @@ ${programArguments}
|
|
|
22221
22271
|
// src/sync/service.ts
|
|
22222
22272
|
import fs15 from "fs/promises";
|
|
22223
22273
|
import os17 from "os";
|
|
22224
|
-
import
|
|
22274
|
+
import path18 from "path";
|
|
22225
22275
|
|
|
22226
22276
|
// src/legacy/openclaw/gateway.ts
|
|
22227
22277
|
import os8 from "os";
|
|
22228
|
-
import
|
|
22229
|
-
var CLAW_HOME2 =
|
|
22278
|
+
import path9 from "path";
|
|
22279
|
+
var CLAW_HOME2 = path9.join(os8.homedir(), ".workle");
|
|
22230
22280
|
function generateGatewayConfig(_instance, agents) {
|
|
22231
22281
|
const sorted = [...agents].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
22232
22282
|
const list = sorted.map((agent) => ({
|
|
22233
22283
|
id: agent.id,
|
|
22234
22284
|
default: !agent.isSubAgent,
|
|
22235
|
-
workspace:
|
|
22285
|
+
workspace: path9.join(CLAW_HOME2, `workspace-${agent.agentKey}`),
|
|
22236
22286
|
model: agent.model,
|
|
22237
22287
|
toolProfile: agent.toolProfile,
|
|
22238
22288
|
promptMode: agent.promptMode
|
|
@@ -22245,8 +22295,8 @@ function generateGatewayConfig(_instance, agents) {
|
|
|
22245
22295
|
// src/legacy/openclaw/soul.ts
|
|
22246
22296
|
import fs8 from "fs/promises";
|
|
22247
22297
|
import os9 from "os";
|
|
22248
|
-
import
|
|
22249
|
-
var CLAW_HOME3 =
|
|
22298
|
+
import path10 from "path";
|
|
22299
|
+
var CLAW_HOME3 = path10.join(os9.homedir(), ".workle");
|
|
22250
22300
|
var DEFAULT_SOUL_MD = `# Soul
|
|
22251
22301
|
|
|
22252
22302
|
You are a Workle agent. Follow your assigned skills and operational instructions.
|
|
@@ -22258,17 +22308,17 @@ async function writeSoulMd(agentKey, content, rpcCall) {
|
|
|
22258
22308
|
await rpcCall(agentKey, "SOUL.md", body);
|
|
22259
22309
|
return;
|
|
22260
22310
|
}
|
|
22261
|
-
const workspaceDir =
|
|
22311
|
+
const workspaceDir = path10.join(CLAW_HOME3, `workspace-${agentKey}`);
|
|
22262
22312
|
await fs8.mkdir(workspaceDir, { recursive: true });
|
|
22263
|
-
const filePath =
|
|
22313
|
+
const filePath = path10.join(workspaceDir, "SOUL.md");
|
|
22264
22314
|
await fs8.writeFile(filePath, body, "utf-8");
|
|
22265
22315
|
}
|
|
22266
22316
|
|
|
22267
22317
|
// src/legacy/openclaw/agents.ts
|
|
22268
22318
|
import fs9 from "fs/promises";
|
|
22269
22319
|
import os10 from "os";
|
|
22270
|
-
import
|
|
22271
|
-
var CLAW_HOME4 =
|
|
22320
|
+
import path11 from "path";
|
|
22321
|
+
var CLAW_HOME4 = path11.join(os10.homedir(), ".workle");
|
|
22272
22322
|
var DEFAULT_AGENTS_MD = `# Agents
|
|
22273
22323
|
|
|
22274
22324
|
No additional agent configuration provided.
|
|
@@ -22279,17 +22329,17 @@ async function writeAgentsMd(agentKey, content, rpcCall) {
|
|
|
22279
22329
|
await rpcCall(agentKey, "AGENTS.md", body);
|
|
22280
22330
|
return;
|
|
22281
22331
|
}
|
|
22282
|
-
const workspaceDir =
|
|
22332
|
+
const workspaceDir = path11.join(CLAW_HOME4, `workspace-${agentKey}`);
|
|
22283
22333
|
await fs9.mkdir(workspaceDir, { recursive: true });
|
|
22284
|
-
const filePath =
|
|
22334
|
+
const filePath = path11.join(workspaceDir, "AGENTS.md");
|
|
22285
22335
|
await fs9.writeFile(filePath, body, "utf-8");
|
|
22286
22336
|
}
|
|
22287
22337
|
|
|
22288
22338
|
// src/config/identity.ts
|
|
22289
22339
|
import fs10 from "fs/promises";
|
|
22290
22340
|
import os11 from "os";
|
|
22291
|
-
import
|
|
22292
|
-
var WORKLE_HOME4 =
|
|
22341
|
+
import path12 from "path";
|
|
22342
|
+
var WORKLE_HOME4 = path12.join(os11.homedir(), ".workle");
|
|
22293
22343
|
var DEFAULT_IDENTITY_MD = `# Identity
|
|
22294
22344
|
|
|
22295
22345
|
No identity configuration provided.
|
|
@@ -22300,17 +22350,17 @@ async function writeIdentityMd(agentKey, content, rpcCall) {
|
|
|
22300
22350
|
await rpcCall(agentKey, "IDENTITY.md", body);
|
|
22301
22351
|
return;
|
|
22302
22352
|
}
|
|
22303
|
-
const workspaceDir =
|
|
22353
|
+
const workspaceDir = path12.join(WORKLE_HOME4, `workspace-${agentKey}`);
|
|
22304
22354
|
await fs10.mkdir(workspaceDir, { recursive: true });
|
|
22305
|
-
const filePath =
|
|
22355
|
+
const filePath = path12.join(workspaceDir, "IDENTITY.md");
|
|
22306
22356
|
await fs10.writeFile(filePath, body, "utf-8");
|
|
22307
22357
|
}
|
|
22308
22358
|
|
|
22309
22359
|
// src/config/heartbeat.ts
|
|
22310
22360
|
import fs11 from "fs/promises";
|
|
22311
22361
|
import os12 from "os";
|
|
22312
|
-
import
|
|
22313
|
-
var WORKLE_HOME5 =
|
|
22362
|
+
import path13 from "path";
|
|
22363
|
+
var WORKLE_HOME5 = path13.join(os12.homedir(), ".workle");
|
|
22314
22364
|
var DEFAULT_HEARTBEAT_MD = `# Heartbeat
|
|
22315
22365
|
|
|
22316
22366
|
No heartbeat configuration provided.
|
|
@@ -22321,34 +22371,34 @@ async function writeHeartbeatMd(agentKey, content, rpcCall) {
|
|
|
22321
22371
|
await rpcCall(agentKey, "HEARTBEAT.md", body);
|
|
22322
22372
|
return;
|
|
22323
22373
|
}
|
|
22324
|
-
const workspaceDir =
|
|
22374
|
+
const workspaceDir = path13.join(WORKLE_HOME5, `workspace-${agentKey}`);
|
|
22325
22375
|
await fs11.mkdir(workspaceDir, { recursive: true });
|
|
22326
|
-
const filePath =
|
|
22376
|
+
const filePath = path13.join(workspaceDir, "HEARTBEAT.md");
|
|
22327
22377
|
await fs11.writeFile(filePath, body, "utf-8");
|
|
22328
22378
|
}
|
|
22329
22379
|
|
|
22330
22380
|
// src/config/skills.ts
|
|
22331
22381
|
import fs12 from "fs/promises";
|
|
22332
22382
|
import os13 from "os";
|
|
22333
|
-
import
|
|
22334
|
-
var WORKLE_HOME6 =
|
|
22383
|
+
import path14 from "path";
|
|
22384
|
+
var WORKLE_HOME6 = path14.join(os13.homedir(), ".workle");
|
|
22335
22385
|
|
|
22336
22386
|
// src/legacy/openclaw/rpc.ts
|
|
22337
22387
|
import crypto4 from "crypto";
|
|
22338
22388
|
import fs13 from "fs";
|
|
22339
22389
|
import os14 from "os";
|
|
22340
|
-
import
|
|
22390
|
+
import path15 from "path";
|
|
22341
22391
|
var OPENCLAW_PORT2 = 18789;
|
|
22342
22392
|
var OPENCLAW_URL = `ws://127.0.0.1:${OPENCLAW_PORT2}`;
|
|
22343
22393
|
var RPC_TIMEOUT = 3e4;
|
|
22344
22394
|
var MAX_RECONNECT_BACKOFF = 1e4;
|
|
22345
22395
|
var CLAW_VERSION = "0.1.16";
|
|
22346
22396
|
var OPENCLAW_CONFIG_PATHS = [
|
|
22347
|
-
() =>
|
|
22348
|
-
() =>
|
|
22397
|
+
() => path15.join(os14.homedir(), ".openclaw", "openclaw.json"),
|
|
22398
|
+
() => path15.join(os14.homedir(), ".config", "openclaw", "openclaw.json")
|
|
22349
22399
|
];
|
|
22350
|
-
var CLAW_IDENTITY_DIR =
|
|
22351
|
-
var CLAW_IDENTITY_FILE =
|
|
22400
|
+
var CLAW_IDENTITY_DIR = path15.join(os14.homedir(), ".workle");
|
|
22401
|
+
var CLAW_IDENTITY_FILE = path15.join(CLAW_IDENTITY_DIR, "device-identity.json");
|
|
22352
22402
|
var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
22353
22403
|
function base64UrlEncode(buf) {
|
|
22354
22404
|
return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
|
|
@@ -22857,17 +22907,17 @@ async function agentDiscovery(rpc, apiUrl, instanceId, token) {
|
|
|
22857
22907
|
|
|
22858
22908
|
// src/sync/events.ts
|
|
22859
22909
|
import os16 from "os";
|
|
22860
|
-
import
|
|
22910
|
+
import path17 from "path";
|
|
22861
22911
|
|
|
22862
22912
|
// src/sync/queue.ts
|
|
22863
22913
|
import fs14 from "fs/promises";
|
|
22864
22914
|
import os15 from "os";
|
|
22865
|
-
import
|
|
22915
|
+
import path16 from "path";
|
|
22866
22916
|
var MAX_FILE_SIZE = 5e8;
|
|
22867
22917
|
var PersistentEventQueue = class {
|
|
22868
22918
|
filePath;
|
|
22869
22919
|
constructor(customPath) {
|
|
22870
|
-
this.filePath = customPath ??
|
|
22920
|
+
this.filePath = customPath ?? path16.join(os15.homedir(), ".workle", "pending-events.jsonl");
|
|
22871
22921
|
}
|
|
22872
22922
|
/**
|
|
22873
22923
|
* Append a single entry to the queue file.
|
|
@@ -22934,7 +22984,7 @@ var PersistentEventQueue = class {
|
|
|
22934
22984
|
}
|
|
22935
22985
|
// --- Internal ---
|
|
22936
22986
|
async ensureDir() {
|
|
22937
|
-
const dir =
|
|
22987
|
+
const dir = path16.dirname(this.filePath);
|
|
22938
22988
|
await fs14.mkdir(dir, { recursive: true });
|
|
22939
22989
|
}
|
|
22940
22990
|
/**
|
|
@@ -22962,7 +23012,7 @@ var PersistentEventQueue = class {
|
|
|
22962
23012
|
};
|
|
22963
23013
|
|
|
22964
23014
|
// src/sync/events.ts
|
|
22965
|
-
var WORKLE_HOME7 =
|
|
23015
|
+
var WORKLE_HOME7 = path17.join(os16.homedir(), ".workle");
|
|
22966
23016
|
var EVENT_TYPE_MAP = {
|
|
22967
23017
|
"agent.run": "agent.started",
|
|
22968
23018
|
"agent.run.complete": "agent.completed",
|
|
@@ -23003,7 +23053,7 @@ function getQueue(instanceId) {
|
|
|
23003
23053
|
const existing = sharedQueues.get(queueKey);
|
|
23004
23054
|
if (existing) return existing;
|
|
23005
23055
|
const queue = new PersistentEventQueue(
|
|
23006
|
-
|
|
23056
|
+
path17.join(WORKLE_HOME7, `pending-events-${queueKey}.jsonl`)
|
|
23007
23057
|
);
|
|
23008
23058
|
sharedQueues.set(queueKey, queue);
|
|
23009
23059
|
return queue;
|
|
@@ -23066,7 +23116,7 @@ async function replayPendingEvents(apiUrl, token, instanceId) {
|
|
|
23066
23116
|
}
|
|
23067
23117
|
|
|
23068
23118
|
// src/sync/service.ts
|
|
23069
|
-
var WORKLE_HOME8 =
|
|
23119
|
+
var WORKLE_HOME8 = path18.join(os17.homedir(), ".workle");
|
|
23070
23120
|
function deriveRelayUrl2(apiUrl) {
|
|
23071
23121
|
const url2 = new URL(apiUrl);
|
|
23072
23122
|
url2.protocol = url2.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -23086,6 +23136,22 @@ var SyncService = class {
|
|
|
23086
23136
|
unsubscribeEvents = null;
|
|
23087
23137
|
unsubscribeRelayMessages = null;
|
|
23088
23138
|
running = false;
|
|
23139
|
+
externalMessageHandler = null;
|
|
23140
|
+
/**
|
|
23141
|
+
* Register a handler for relay messages that SyncService doesn't handle
|
|
23142
|
+
* (e.g. agent.trigger, agent.cancel, agent.config.updated).
|
|
23143
|
+
* Must be called before start().
|
|
23144
|
+
*/
|
|
23145
|
+
onRelayMessage(handler) {
|
|
23146
|
+
this.externalMessageHandler = handler;
|
|
23147
|
+
}
|
|
23148
|
+
/**
|
|
23149
|
+
* Send a message through the relay WebSocket connection.
|
|
23150
|
+
* Used by AgentService in embedded mode to send progress/result frames.
|
|
23151
|
+
*/
|
|
23152
|
+
sendRelayMessage(msg) {
|
|
23153
|
+
this.relayClient?.send(msg);
|
|
23154
|
+
}
|
|
23089
23155
|
get isRunning() {
|
|
23090
23156
|
return this.running;
|
|
23091
23157
|
}
|
|
@@ -23181,7 +23247,12 @@ var SyncService = class {
|
|
|
23181
23247
|
);
|
|
23182
23248
|
}
|
|
23183
23249
|
this.unsubscribeRelayMessages = this.relayClient.onMessage((msg) => {
|
|
23184
|
-
if (msg.type !== "rpc.request")
|
|
23250
|
+
if (msg.type !== "rpc.request") {
|
|
23251
|
+
if (this.externalMessageHandler) {
|
|
23252
|
+
this.externalMessageHandler(msg);
|
|
23253
|
+
}
|
|
23254
|
+
return;
|
|
23255
|
+
}
|
|
23185
23256
|
const rpcId = typeof msg.id === "string" ? msg.id : null;
|
|
23186
23257
|
const method = typeof msg.method === "string" ? msg.method : null;
|
|
23187
23258
|
const params = msg.params && typeof msg.params === "object" ? msg.params : {};
|
|
@@ -23398,7 +23469,7 @@ var SyncService = class {
|
|
|
23398
23469
|
}
|
|
23399
23470
|
async writeConfigFiles(instance, agents) {
|
|
23400
23471
|
const gatewayConfig = generateGatewayConfig(instance, agents);
|
|
23401
|
-
const configPath =
|
|
23472
|
+
const configPath = path18.join(WORKLE_HOME8, "openclaw.json");
|
|
23402
23473
|
await fs15.mkdir(WORKLE_HOME8, { recursive: true });
|
|
23403
23474
|
await fs15.writeFile(configPath, JSON.stringify(gatewayConfig, null, 2), "utf-8");
|
|
23404
23475
|
await Promise.all(
|
|
@@ -23413,9 +23484,9 @@ var SyncService = class {
|
|
|
23413
23484
|
};
|
|
23414
23485
|
|
|
23415
23486
|
// src/cli.ts
|
|
23416
|
-
var WORKLE_HOME9 =
|
|
23417
|
-
var AUTH_FILE2 =
|
|
23418
|
-
var LAUNCH_AGENTS_DIR2 =
|
|
23487
|
+
var WORKLE_HOME9 = path19.join(os18.homedir(), ".workle");
|
|
23488
|
+
var AUTH_FILE2 = path19.join(WORKLE_HOME9, "auth.json");
|
|
23489
|
+
var LAUNCH_AGENTS_DIR2 = path19.join(os18.homedir(), "Library", "LaunchAgents");
|
|
23419
23490
|
var PLIST_LABEL = "com.workle.claw";
|
|
23420
23491
|
var color = {
|
|
23421
23492
|
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
@@ -23665,7 +23736,7 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23665
23736
|
console.log("");
|
|
23666
23737
|
console.log(` Service: ${color.dim(PLIST_LABEL)}`);
|
|
23667
23738
|
console.log(` Plist: ${color.dim(plistPath)}`);
|
|
23668
|
-
console.log(` Logs: ${color.dim(
|
|
23739
|
+
console.log(` Logs: ${color.dim(path19.join(WORKLE_HOME9, "logs/"))}`);
|
|
23669
23740
|
console.log("");
|
|
23670
23741
|
console.log(
|
|
23671
23742
|
`To stop: ${color.cyan("npx @getworkle/cli stop")}`
|
|
@@ -23681,9 +23752,11 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23681
23752
|
console.log(color.dim("Starting sync service... (Ctrl+C to stop)\n"));
|
|
23682
23753
|
const processManager = new ProcessManager();
|
|
23683
23754
|
const syncService = new SyncService();
|
|
23755
|
+
let agentService = null;
|
|
23684
23756
|
let weSpawnedGateway = false;
|
|
23685
23757
|
const shutdown = () => {
|
|
23686
23758
|
console.log("\n" + color.dim("Shutting down..."));
|
|
23759
|
+
agentService?.stop();
|
|
23687
23760
|
syncService.stop();
|
|
23688
23761
|
if (weSpawnedGateway) {
|
|
23689
23762
|
void processManager.stop().then(() => {
|
|
@@ -23706,6 +23779,15 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23706
23779
|
weSpawnedGateway = true;
|
|
23707
23780
|
}
|
|
23708
23781
|
await syncService.start();
|
|
23782
|
+
try {
|
|
23783
|
+
agentService = await createAgentService();
|
|
23784
|
+
syncService.onRelayMessage((msg) => agentService.ingestRelayMessage(msg));
|
|
23785
|
+
await agentService.startEmbedded((msg) => syncService.sendRelayMessage(msg));
|
|
23786
|
+
} catch (err) {
|
|
23787
|
+
console.error(
|
|
23788
|
+
color.dim(`[agents] AgentService failed to start: ${err instanceof Error ? err.message : String(err)}`)
|
|
23789
|
+
);
|
|
23790
|
+
}
|
|
23709
23791
|
console.log(color.green("\u2713 Running"));
|
|
23710
23792
|
console.log(color.dim(" Press Ctrl+C to stop\n"));
|
|
23711
23793
|
} catch (err) {
|
|
@@ -23722,14 +23804,14 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23722
23804
|
}
|
|
23723
23805
|
});
|
|
23724
23806
|
program2.command("stop").description("Stop the Workle Claw daemon").action(async () => {
|
|
23725
|
-
const plistPath =
|
|
23807
|
+
const plistPath = path19.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23726
23808
|
try {
|
|
23727
23809
|
execSync2(`launchctl unload "${plistPath}"`, { stdio: "inherit" });
|
|
23728
23810
|
console.log(color.green("\u2713 Daemon stopped"));
|
|
23729
23811
|
} catch {
|
|
23730
23812
|
console.log(color.dim("No launchd service loaded."));
|
|
23731
23813
|
}
|
|
23732
|
-
const pidFile =
|
|
23814
|
+
const pidFile = path19.join(WORKLE_HOME9, "openclaw.pid");
|
|
23733
23815
|
try {
|
|
23734
23816
|
const pidStr = await fs16.readFile(pidFile, "utf-8");
|
|
23735
23817
|
const pid = parseInt(pidStr.trim(), 10);
|
|
@@ -23774,7 +23856,7 @@ program2.command("status").description("Show connection state and instance info"
|
|
|
23774
23856
|
} catch {
|
|
23775
23857
|
console.log(` Gateway: ${color.yellow("unreachable")}`);
|
|
23776
23858
|
}
|
|
23777
|
-
const plistPath =
|
|
23859
|
+
const plistPath = path19.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23778
23860
|
try {
|
|
23779
23861
|
await fs16.access(plistPath);
|
|
23780
23862
|
try {
|
|
@@ -23801,8 +23883,8 @@ program2.command("logs").description("Tail the Workle Claw log files").option("-
|
|
|
23801
23883
|
process.exit(1);
|
|
23802
23884
|
}
|
|
23803
23885
|
const logFiles = [
|
|
23804
|
-
|
|
23805
|
-
|
|
23886
|
+
path19.join(WORKLE_HOME9, "openclaw.log"),
|
|
23887
|
+
path19.join(WORKLE_HOME9, "logs", "stderr.log")
|
|
23806
23888
|
];
|
|
23807
23889
|
const args = ["-n", String(lineCount)];
|
|
23808
23890
|
if (opts.follow) args.push("-f");
|
|
@@ -23966,12 +24048,12 @@ agentCmd.command("logs [agentId]").description("Tail agent run logs").option("-n
|
|
|
23966
24048
|
console.error(color.red("Error: --lines must be a positive integer."));
|
|
23967
24049
|
process.exit(1);
|
|
23968
24050
|
}
|
|
23969
|
-
const logsDir =
|
|
24051
|
+
const logsDir = path19.join(WORKLE_HOME9, "agents");
|
|
23970
24052
|
let logFile;
|
|
23971
24053
|
if (agentId) {
|
|
23972
|
-
logFile =
|
|
24054
|
+
logFile = path19.join(logsDir, agentId, "run.log");
|
|
23973
24055
|
} else {
|
|
23974
|
-
logFile =
|
|
24056
|
+
logFile = path19.join(logsDir, "*", "run.log");
|
|
23975
24057
|
}
|
|
23976
24058
|
const args = ["-n", String(lineCount)];
|
|
23977
24059
|
if (opts.follow) args.push("-f");
|