@getworkle/cli 0.2.8 → 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 +108 -99
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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
|
|
|
@@ -21866,10 +21875,10 @@ import { spawn } from "child_process";
|
|
|
21866
21875
|
import fs5 from "fs/promises";
|
|
21867
21876
|
import http from "http";
|
|
21868
21877
|
import os5 from "os";
|
|
21869
|
-
import
|
|
21870
|
-
var CLAW_HOME =
|
|
21871
|
-
var LOG_FILE =
|
|
21872
|
-
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");
|
|
21873
21882
|
var OPENCLAW_PORT = 18789;
|
|
21874
21883
|
var HEALTH_CHECK_TIMEOUT = 5e3;
|
|
21875
21884
|
var ProcessManager = class {
|
|
@@ -21882,7 +21891,7 @@ var ProcessManager = class {
|
|
|
21882
21891
|
* @param openclawBinary - Path to the openclaw binary (defaults to "openclaw" in PATH)
|
|
21883
21892
|
* @param configPath - Path to openclaw.json config (defaults to ~/.workle/openclaw.json)
|
|
21884
21893
|
*/
|
|
21885
|
-
async spawn(openclawBinary = "openclaw", configPath =
|
|
21894
|
+
async spawn(openclawBinary = "openclaw", configPath = path6.join(CLAW_HOME, "openclaw.json")) {
|
|
21886
21895
|
if (this.process) {
|
|
21887
21896
|
console.log("[claw] OpenClaw process already running");
|
|
21888
21897
|
return;
|
|
@@ -22014,8 +22023,8 @@ var ProcessManager = class {
|
|
|
22014
22023
|
import { execSync } from "child_process";
|
|
22015
22024
|
import fs6 from "fs/promises";
|
|
22016
22025
|
import os6 from "os";
|
|
22017
|
-
import
|
|
22018
|
-
var WORKLE_HOME2 =
|
|
22026
|
+
import path7 from "path";
|
|
22027
|
+
var WORKLE_HOME2 = path7.join(os6.homedir(), ".workle");
|
|
22019
22028
|
var MIN_NODE_MAJOR = 22;
|
|
22020
22029
|
async function runDoctor() {
|
|
22021
22030
|
const checks = [];
|
|
@@ -22098,7 +22107,7 @@ async function checkClawHome() {
|
|
|
22098
22107
|
}
|
|
22099
22108
|
}
|
|
22100
22109
|
async function checkAuthFile() {
|
|
22101
|
-
const authPath =
|
|
22110
|
+
const authPath = path7.join(WORKLE_HOME2, "auth.json");
|
|
22102
22111
|
try {
|
|
22103
22112
|
const raw = await fs6.readFile(authPath, "utf-8");
|
|
22104
22113
|
const parsed = JSON.parse(raw);
|
|
@@ -22123,7 +22132,7 @@ async function checkAuthFile() {
|
|
|
22123
22132
|
}
|
|
22124
22133
|
}
|
|
22125
22134
|
async function checkConfigFile() {
|
|
22126
|
-
const configPath =
|
|
22135
|
+
const configPath = path7.join(WORKLE_HOME2, "openclaw.json");
|
|
22127
22136
|
try {
|
|
22128
22137
|
const raw = await fs6.readFile(configPath, "utf-8");
|
|
22129
22138
|
const parsed = JSON.parse(raw);
|
|
@@ -22172,25 +22181,25 @@ async function checkGatewayReachable() {
|
|
|
22172
22181
|
// src/lifecycle/install.ts
|
|
22173
22182
|
import fs7 from "fs/promises";
|
|
22174
22183
|
import os7 from "os";
|
|
22175
|
-
import
|
|
22176
|
-
var WORKLE_HOME3 =
|
|
22177
|
-
var LAUNCH_AGENTS_DIR =
|
|
22178
|
-
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");
|
|
22179
22188
|
function escapeXml(value) {
|
|
22180
22189
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
22181
22190
|
}
|
|
22182
22191
|
async function setupClawDirectory() {
|
|
22183
22192
|
const dirs = [
|
|
22184
22193
|
WORKLE_HOME3,
|
|
22185
|
-
|
|
22186
|
-
|
|
22194
|
+
path8.join(WORKLE_HOME3, "logs"),
|
|
22195
|
+
path8.join(WORKLE_HOME3, "bin")
|
|
22187
22196
|
];
|
|
22188
22197
|
for (const dir of dirs) {
|
|
22189
22198
|
await fs7.mkdir(dir, { recursive: true, mode: 448 });
|
|
22190
22199
|
await fs7.chmod(dir, 448).catch(() => {
|
|
22191
22200
|
});
|
|
22192
22201
|
}
|
|
22193
|
-
const gitignorePath =
|
|
22202
|
+
const gitignorePath = path8.join(WORKLE_HOME3, ".gitignore");
|
|
22194
22203
|
try {
|
|
22195
22204
|
await fs7.access(gitignorePath);
|
|
22196
22205
|
} catch {
|
|
@@ -22214,7 +22223,7 @@ async function stageCliForDaemon(currentCliPath) {
|
|
|
22214
22223
|
}
|
|
22215
22224
|
async function writeLaunchdPlist(serviceName = "com.workle.claw", executable = process.execPath, args = [STAGED_CLI_PATH, "start"]) {
|
|
22216
22225
|
await fs7.mkdir(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
22217
|
-
const plistPath =
|
|
22226
|
+
const plistPath = path8.join(LAUNCH_AGENTS_DIR, `${serviceName}.plist`);
|
|
22218
22227
|
const programArguments = [executable, ...args].map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n");
|
|
22219
22228
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
22220
22229
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -22238,10 +22247,10 @@ ${programArguments}
|
|
|
22238
22247
|
</dict>
|
|
22239
22248
|
|
|
22240
22249
|
<key>StandardOutPath</key>
|
|
22241
|
-
<string>${
|
|
22250
|
+
<string>${path8.join(WORKLE_HOME3, "logs", "stdout.log")}</string>
|
|
22242
22251
|
|
|
22243
22252
|
<key>StandardErrorPath</key>
|
|
22244
|
-
<string>${
|
|
22253
|
+
<string>${path8.join(WORKLE_HOME3, "logs", "stderr.log")}</string>
|
|
22245
22254
|
|
|
22246
22255
|
<key>WorkingDirectory</key>
|
|
22247
22256
|
<string>${WORKLE_HOME3}</string>
|
|
@@ -22262,18 +22271,18 @@ ${programArguments}
|
|
|
22262
22271
|
// src/sync/service.ts
|
|
22263
22272
|
import fs15 from "fs/promises";
|
|
22264
22273
|
import os17 from "os";
|
|
22265
|
-
import
|
|
22274
|
+
import path18 from "path";
|
|
22266
22275
|
|
|
22267
22276
|
// src/legacy/openclaw/gateway.ts
|
|
22268
22277
|
import os8 from "os";
|
|
22269
|
-
import
|
|
22270
|
-
var CLAW_HOME2 =
|
|
22278
|
+
import path9 from "path";
|
|
22279
|
+
var CLAW_HOME2 = path9.join(os8.homedir(), ".workle");
|
|
22271
22280
|
function generateGatewayConfig(_instance, agents) {
|
|
22272
22281
|
const sorted = [...agents].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
22273
22282
|
const list = sorted.map((agent) => ({
|
|
22274
22283
|
id: agent.id,
|
|
22275
22284
|
default: !agent.isSubAgent,
|
|
22276
|
-
workspace:
|
|
22285
|
+
workspace: path9.join(CLAW_HOME2, `workspace-${agent.agentKey}`),
|
|
22277
22286
|
model: agent.model,
|
|
22278
22287
|
toolProfile: agent.toolProfile,
|
|
22279
22288
|
promptMode: agent.promptMode
|
|
@@ -22286,8 +22295,8 @@ function generateGatewayConfig(_instance, agents) {
|
|
|
22286
22295
|
// src/legacy/openclaw/soul.ts
|
|
22287
22296
|
import fs8 from "fs/promises";
|
|
22288
22297
|
import os9 from "os";
|
|
22289
|
-
import
|
|
22290
|
-
var CLAW_HOME3 =
|
|
22298
|
+
import path10 from "path";
|
|
22299
|
+
var CLAW_HOME3 = path10.join(os9.homedir(), ".workle");
|
|
22291
22300
|
var DEFAULT_SOUL_MD = `# Soul
|
|
22292
22301
|
|
|
22293
22302
|
You are a Workle agent. Follow your assigned skills and operational instructions.
|
|
@@ -22299,17 +22308,17 @@ async function writeSoulMd(agentKey, content, rpcCall) {
|
|
|
22299
22308
|
await rpcCall(agentKey, "SOUL.md", body);
|
|
22300
22309
|
return;
|
|
22301
22310
|
}
|
|
22302
|
-
const workspaceDir =
|
|
22311
|
+
const workspaceDir = path10.join(CLAW_HOME3, `workspace-${agentKey}`);
|
|
22303
22312
|
await fs8.mkdir(workspaceDir, { recursive: true });
|
|
22304
|
-
const filePath =
|
|
22313
|
+
const filePath = path10.join(workspaceDir, "SOUL.md");
|
|
22305
22314
|
await fs8.writeFile(filePath, body, "utf-8");
|
|
22306
22315
|
}
|
|
22307
22316
|
|
|
22308
22317
|
// src/legacy/openclaw/agents.ts
|
|
22309
22318
|
import fs9 from "fs/promises";
|
|
22310
22319
|
import os10 from "os";
|
|
22311
|
-
import
|
|
22312
|
-
var CLAW_HOME4 =
|
|
22320
|
+
import path11 from "path";
|
|
22321
|
+
var CLAW_HOME4 = path11.join(os10.homedir(), ".workle");
|
|
22313
22322
|
var DEFAULT_AGENTS_MD = `# Agents
|
|
22314
22323
|
|
|
22315
22324
|
No additional agent configuration provided.
|
|
@@ -22320,17 +22329,17 @@ async function writeAgentsMd(agentKey, content, rpcCall) {
|
|
|
22320
22329
|
await rpcCall(agentKey, "AGENTS.md", body);
|
|
22321
22330
|
return;
|
|
22322
22331
|
}
|
|
22323
|
-
const workspaceDir =
|
|
22332
|
+
const workspaceDir = path11.join(CLAW_HOME4, `workspace-${agentKey}`);
|
|
22324
22333
|
await fs9.mkdir(workspaceDir, { recursive: true });
|
|
22325
|
-
const filePath =
|
|
22334
|
+
const filePath = path11.join(workspaceDir, "AGENTS.md");
|
|
22326
22335
|
await fs9.writeFile(filePath, body, "utf-8");
|
|
22327
22336
|
}
|
|
22328
22337
|
|
|
22329
22338
|
// src/config/identity.ts
|
|
22330
22339
|
import fs10 from "fs/promises";
|
|
22331
22340
|
import os11 from "os";
|
|
22332
|
-
import
|
|
22333
|
-
var WORKLE_HOME4 =
|
|
22341
|
+
import path12 from "path";
|
|
22342
|
+
var WORKLE_HOME4 = path12.join(os11.homedir(), ".workle");
|
|
22334
22343
|
var DEFAULT_IDENTITY_MD = `# Identity
|
|
22335
22344
|
|
|
22336
22345
|
No identity configuration provided.
|
|
@@ -22341,17 +22350,17 @@ async function writeIdentityMd(agentKey, content, rpcCall) {
|
|
|
22341
22350
|
await rpcCall(agentKey, "IDENTITY.md", body);
|
|
22342
22351
|
return;
|
|
22343
22352
|
}
|
|
22344
|
-
const workspaceDir =
|
|
22353
|
+
const workspaceDir = path12.join(WORKLE_HOME4, `workspace-${agentKey}`);
|
|
22345
22354
|
await fs10.mkdir(workspaceDir, { recursive: true });
|
|
22346
|
-
const filePath =
|
|
22355
|
+
const filePath = path12.join(workspaceDir, "IDENTITY.md");
|
|
22347
22356
|
await fs10.writeFile(filePath, body, "utf-8");
|
|
22348
22357
|
}
|
|
22349
22358
|
|
|
22350
22359
|
// src/config/heartbeat.ts
|
|
22351
22360
|
import fs11 from "fs/promises";
|
|
22352
22361
|
import os12 from "os";
|
|
22353
|
-
import
|
|
22354
|
-
var WORKLE_HOME5 =
|
|
22362
|
+
import path13 from "path";
|
|
22363
|
+
var WORKLE_HOME5 = path13.join(os12.homedir(), ".workle");
|
|
22355
22364
|
var DEFAULT_HEARTBEAT_MD = `# Heartbeat
|
|
22356
22365
|
|
|
22357
22366
|
No heartbeat configuration provided.
|
|
@@ -22362,34 +22371,34 @@ async function writeHeartbeatMd(agentKey, content, rpcCall) {
|
|
|
22362
22371
|
await rpcCall(agentKey, "HEARTBEAT.md", body);
|
|
22363
22372
|
return;
|
|
22364
22373
|
}
|
|
22365
|
-
const workspaceDir =
|
|
22374
|
+
const workspaceDir = path13.join(WORKLE_HOME5, `workspace-${agentKey}`);
|
|
22366
22375
|
await fs11.mkdir(workspaceDir, { recursive: true });
|
|
22367
|
-
const filePath =
|
|
22376
|
+
const filePath = path13.join(workspaceDir, "HEARTBEAT.md");
|
|
22368
22377
|
await fs11.writeFile(filePath, body, "utf-8");
|
|
22369
22378
|
}
|
|
22370
22379
|
|
|
22371
22380
|
// src/config/skills.ts
|
|
22372
22381
|
import fs12 from "fs/promises";
|
|
22373
22382
|
import os13 from "os";
|
|
22374
|
-
import
|
|
22375
|
-
var WORKLE_HOME6 =
|
|
22383
|
+
import path14 from "path";
|
|
22384
|
+
var WORKLE_HOME6 = path14.join(os13.homedir(), ".workle");
|
|
22376
22385
|
|
|
22377
22386
|
// src/legacy/openclaw/rpc.ts
|
|
22378
22387
|
import crypto4 from "crypto";
|
|
22379
22388
|
import fs13 from "fs";
|
|
22380
22389
|
import os14 from "os";
|
|
22381
|
-
import
|
|
22390
|
+
import path15 from "path";
|
|
22382
22391
|
var OPENCLAW_PORT2 = 18789;
|
|
22383
22392
|
var OPENCLAW_URL = `ws://127.0.0.1:${OPENCLAW_PORT2}`;
|
|
22384
22393
|
var RPC_TIMEOUT = 3e4;
|
|
22385
22394
|
var MAX_RECONNECT_BACKOFF = 1e4;
|
|
22386
22395
|
var CLAW_VERSION = "0.1.16";
|
|
22387
22396
|
var OPENCLAW_CONFIG_PATHS = [
|
|
22388
|
-
() =>
|
|
22389
|
-
() =>
|
|
22397
|
+
() => path15.join(os14.homedir(), ".openclaw", "openclaw.json"),
|
|
22398
|
+
() => path15.join(os14.homedir(), ".config", "openclaw", "openclaw.json")
|
|
22390
22399
|
];
|
|
22391
|
-
var CLAW_IDENTITY_DIR =
|
|
22392
|
-
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");
|
|
22393
22402
|
var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
22394
22403
|
function base64UrlEncode(buf) {
|
|
22395
22404
|
return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
|
|
@@ -22898,17 +22907,17 @@ async function agentDiscovery(rpc, apiUrl, instanceId, token) {
|
|
|
22898
22907
|
|
|
22899
22908
|
// src/sync/events.ts
|
|
22900
22909
|
import os16 from "os";
|
|
22901
|
-
import
|
|
22910
|
+
import path17 from "path";
|
|
22902
22911
|
|
|
22903
22912
|
// src/sync/queue.ts
|
|
22904
22913
|
import fs14 from "fs/promises";
|
|
22905
22914
|
import os15 from "os";
|
|
22906
|
-
import
|
|
22915
|
+
import path16 from "path";
|
|
22907
22916
|
var MAX_FILE_SIZE = 5e8;
|
|
22908
22917
|
var PersistentEventQueue = class {
|
|
22909
22918
|
filePath;
|
|
22910
22919
|
constructor(customPath) {
|
|
22911
|
-
this.filePath = customPath ??
|
|
22920
|
+
this.filePath = customPath ?? path16.join(os15.homedir(), ".workle", "pending-events.jsonl");
|
|
22912
22921
|
}
|
|
22913
22922
|
/**
|
|
22914
22923
|
* Append a single entry to the queue file.
|
|
@@ -22975,7 +22984,7 @@ var PersistentEventQueue = class {
|
|
|
22975
22984
|
}
|
|
22976
22985
|
// --- Internal ---
|
|
22977
22986
|
async ensureDir() {
|
|
22978
|
-
const dir =
|
|
22987
|
+
const dir = path16.dirname(this.filePath);
|
|
22979
22988
|
await fs14.mkdir(dir, { recursive: true });
|
|
22980
22989
|
}
|
|
22981
22990
|
/**
|
|
@@ -23003,7 +23012,7 @@ var PersistentEventQueue = class {
|
|
|
23003
23012
|
};
|
|
23004
23013
|
|
|
23005
23014
|
// src/sync/events.ts
|
|
23006
|
-
var WORKLE_HOME7 =
|
|
23015
|
+
var WORKLE_HOME7 = path17.join(os16.homedir(), ".workle");
|
|
23007
23016
|
var EVENT_TYPE_MAP = {
|
|
23008
23017
|
"agent.run": "agent.started",
|
|
23009
23018
|
"agent.run.complete": "agent.completed",
|
|
@@ -23044,7 +23053,7 @@ function getQueue(instanceId) {
|
|
|
23044
23053
|
const existing = sharedQueues.get(queueKey);
|
|
23045
23054
|
if (existing) return existing;
|
|
23046
23055
|
const queue = new PersistentEventQueue(
|
|
23047
|
-
|
|
23056
|
+
path17.join(WORKLE_HOME7, `pending-events-${queueKey}.jsonl`)
|
|
23048
23057
|
);
|
|
23049
23058
|
sharedQueues.set(queueKey, queue);
|
|
23050
23059
|
return queue;
|
|
@@ -23107,7 +23116,7 @@ async function replayPendingEvents(apiUrl, token, instanceId) {
|
|
|
23107
23116
|
}
|
|
23108
23117
|
|
|
23109
23118
|
// src/sync/service.ts
|
|
23110
|
-
var WORKLE_HOME8 =
|
|
23119
|
+
var WORKLE_HOME8 = path18.join(os17.homedir(), ".workle");
|
|
23111
23120
|
function deriveRelayUrl2(apiUrl) {
|
|
23112
23121
|
const url2 = new URL(apiUrl);
|
|
23113
23122
|
url2.protocol = url2.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -23460,7 +23469,7 @@ var SyncService = class {
|
|
|
23460
23469
|
}
|
|
23461
23470
|
async writeConfigFiles(instance, agents) {
|
|
23462
23471
|
const gatewayConfig = generateGatewayConfig(instance, agents);
|
|
23463
|
-
const configPath =
|
|
23472
|
+
const configPath = path18.join(WORKLE_HOME8, "openclaw.json");
|
|
23464
23473
|
await fs15.mkdir(WORKLE_HOME8, { recursive: true });
|
|
23465
23474
|
await fs15.writeFile(configPath, JSON.stringify(gatewayConfig, null, 2), "utf-8");
|
|
23466
23475
|
await Promise.all(
|
|
@@ -23475,9 +23484,9 @@ var SyncService = class {
|
|
|
23475
23484
|
};
|
|
23476
23485
|
|
|
23477
23486
|
// src/cli.ts
|
|
23478
|
-
var WORKLE_HOME9 =
|
|
23479
|
-
var AUTH_FILE2 =
|
|
23480
|
-
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");
|
|
23481
23490
|
var PLIST_LABEL = "com.workle.claw";
|
|
23482
23491
|
var color = {
|
|
23483
23492
|
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
@@ -23727,7 +23736,7 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23727
23736
|
console.log("");
|
|
23728
23737
|
console.log(` Service: ${color.dim(PLIST_LABEL)}`);
|
|
23729
23738
|
console.log(` Plist: ${color.dim(plistPath)}`);
|
|
23730
|
-
console.log(` Logs: ${color.dim(
|
|
23739
|
+
console.log(` Logs: ${color.dim(path19.join(WORKLE_HOME9, "logs/"))}`);
|
|
23731
23740
|
console.log("");
|
|
23732
23741
|
console.log(
|
|
23733
23742
|
`To stop: ${color.cyan("npx @getworkle/cli stop")}`
|
|
@@ -23795,14 +23804,14 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23795
23804
|
}
|
|
23796
23805
|
});
|
|
23797
23806
|
program2.command("stop").description("Stop the Workle Claw daemon").action(async () => {
|
|
23798
|
-
const plistPath =
|
|
23807
|
+
const plistPath = path19.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23799
23808
|
try {
|
|
23800
23809
|
execSync2(`launchctl unload "${plistPath}"`, { stdio: "inherit" });
|
|
23801
23810
|
console.log(color.green("\u2713 Daemon stopped"));
|
|
23802
23811
|
} catch {
|
|
23803
23812
|
console.log(color.dim("No launchd service loaded."));
|
|
23804
23813
|
}
|
|
23805
|
-
const pidFile =
|
|
23814
|
+
const pidFile = path19.join(WORKLE_HOME9, "openclaw.pid");
|
|
23806
23815
|
try {
|
|
23807
23816
|
const pidStr = await fs16.readFile(pidFile, "utf-8");
|
|
23808
23817
|
const pid = parseInt(pidStr.trim(), 10);
|
|
@@ -23847,7 +23856,7 @@ program2.command("status").description("Show connection state and instance info"
|
|
|
23847
23856
|
} catch {
|
|
23848
23857
|
console.log(` Gateway: ${color.yellow("unreachable")}`);
|
|
23849
23858
|
}
|
|
23850
|
-
const plistPath =
|
|
23859
|
+
const plistPath = path19.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23851
23860
|
try {
|
|
23852
23861
|
await fs16.access(plistPath);
|
|
23853
23862
|
try {
|
|
@@ -23874,8 +23883,8 @@ program2.command("logs").description("Tail the Workle Claw log files").option("-
|
|
|
23874
23883
|
process.exit(1);
|
|
23875
23884
|
}
|
|
23876
23885
|
const logFiles = [
|
|
23877
|
-
|
|
23878
|
-
|
|
23886
|
+
path19.join(WORKLE_HOME9, "openclaw.log"),
|
|
23887
|
+
path19.join(WORKLE_HOME9, "logs", "stderr.log")
|
|
23879
23888
|
];
|
|
23880
23889
|
const args = ["-n", String(lineCount)];
|
|
23881
23890
|
if (opts.follow) args.push("-f");
|
|
@@ -24039,12 +24048,12 @@ agentCmd.command("logs [agentId]").description("Tail agent run logs").option("-n
|
|
|
24039
24048
|
console.error(color.red("Error: --lines must be a positive integer."));
|
|
24040
24049
|
process.exit(1);
|
|
24041
24050
|
}
|
|
24042
|
-
const logsDir =
|
|
24051
|
+
const logsDir = path19.join(WORKLE_HOME9, "agents");
|
|
24043
24052
|
let logFile;
|
|
24044
24053
|
if (agentId) {
|
|
24045
|
-
logFile =
|
|
24054
|
+
logFile = path19.join(logsDir, agentId, "run.log");
|
|
24046
24055
|
} else {
|
|
24047
|
-
logFile =
|
|
24056
|
+
logFile = path19.join(logsDir, "*", "run.log");
|
|
24048
24057
|
}
|
|
24049
24058
|
const args = ["-n", String(lineCount)];
|
|
24050
24059
|
if (opts.follow) args.push("-f");
|