@getworkle/cli 0.2.9 → 0.2.10
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 +103 -105
- 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 path19 = __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 = path19.resolve(baseDir, baseName);
|
|
2226
2226
|
if (fs17.existsSync(localBin)) return localBin;
|
|
2227
|
-
if (sourceExt.includes(
|
|
2227
|
+
if (sourceExt.includes(path19.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 = path19.resolve(
|
|
2246
|
+
path19.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 = path19.basename(
|
|
2254
2254
|
this._scriptPath,
|
|
2255
|
-
|
|
2255
|
+
path19.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(path19.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 = path19.basename(filename, path19.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(path20) {
|
|
3196
|
+
if (path20 === void 0) return this._executableDir;
|
|
3197
|
+
this._executableDir = path20;
|
|
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 path19 = __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: path19.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 path18 from "path";
|
|
8037
8037
|
|
|
8038
8038
|
// src/agents/config-materializer.ts
|
|
8039
8039
|
import fs2 from "fs/promises";
|
|
@@ -8249,14 +8249,12 @@ var AgentConfigMaterializer = class {
|
|
|
8249
8249
|
};
|
|
8250
8250
|
|
|
8251
8251
|
// src/agents/runner.ts
|
|
8252
|
-
import { createRequire } from "module";
|
|
8253
|
-
import path4 from "path";
|
|
8254
8252
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
8255
8253
|
function resolveClaudeCodeExecutable() {
|
|
8256
|
-
const
|
|
8257
|
-
|
|
8258
|
-
);
|
|
8259
|
-
return
|
|
8254
|
+
const sdkUrl = import.meta.resolve("@anthropic-ai/claude-agent-sdk");
|
|
8255
|
+
const sdkPath = new URL(sdkUrl).pathname;
|
|
8256
|
+
const sdkDir = sdkPath.substring(0, sdkPath.lastIndexOf("/"));
|
|
8257
|
+
return `${sdkDir}/cli.js`;
|
|
8260
8258
|
}
|
|
8261
8259
|
async function runAgent(opts) {
|
|
8262
8260
|
const { agentDir, prompt, sessionId, maxTurns, mcpServers, onMessage, abortController } = opts;
|
|
@@ -9067,10 +9065,10 @@ function mergeDefs(...defs) {
|
|
|
9067
9065
|
function cloneDef(schema) {
|
|
9068
9066
|
return mergeDefs(schema._zod.def);
|
|
9069
9067
|
}
|
|
9070
|
-
function getElementAtPath(obj,
|
|
9071
|
-
if (!
|
|
9068
|
+
function getElementAtPath(obj, path19) {
|
|
9069
|
+
if (!path19)
|
|
9072
9070
|
return obj;
|
|
9073
|
-
return
|
|
9071
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
9074
9072
|
}
|
|
9075
9073
|
function promiseAllObject(promisesObj) {
|
|
9076
9074
|
const keys = Object.keys(promisesObj);
|
|
@@ -9436,11 +9434,11 @@ function aborted(x, startIndex = 0) {
|
|
|
9436
9434
|
}
|
|
9437
9435
|
return false;
|
|
9438
9436
|
}
|
|
9439
|
-
function prefixIssues(
|
|
9437
|
+
function prefixIssues(path19, issues) {
|
|
9440
9438
|
return issues.map((iss) => {
|
|
9441
9439
|
var _a2;
|
|
9442
9440
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
9443
|
-
iss.path.unshift(
|
|
9441
|
+
iss.path.unshift(path19);
|
|
9444
9442
|
return iss;
|
|
9445
9443
|
});
|
|
9446
9444
|
}
|
|
@@ -9602,7 +9600,7 @@ function formatError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9602
9600
|
}
|
|
9603
9601
|
function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
9604
9602
|
const result = { errors: [] };
|
|
9605
|
-
const processError = (error47,
|
|
9603
|
+
const processError = (error47, path19 = []) => {
|
|
9606
9604
|
var _a2, _b;
|
|
9607
9605
|
for (const issue2 of error47.issues) {
|
|
9608
9606
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -9612,7 +9610,7 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9612
9610
|
} else if (issue2.code === "invalid_element") {
|
|
9613
9611
|
processError({ issues: issue2.issues }, issue2.path);
|
|
9614
9612
|
} else {
|
|
9615
|
-
const fullpath = [...
|
|
9613
|
+
const fullpath = [...path19, ...issue2.path];
|
|
9616
9614
|
if (fullpath.length === 0) {
|
|
9617
9615
|
result.errors.push(mapper(issue2));
|
|
9618
9616
|
continue;
|
|
@@ -9644,8 +9642,8 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
9644
9642
|
}
|
|
9645
9643
|
function toDotPath(_path) {
|
|
9646
9644
|
const segs = [];
|
|
9647
|
-
const
|
|
9648
|
-
for (const seg of
|
|
9645
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
9646
|
+
for (const seg of path19) {
|
|
9649
9647
|
if (typeof seg === "number")
|
|
9650
9648
|
segs.push(`[${seg}]`);
|
|
9651
9649
|
else if (typeof seg === "symbol")
|
|
@@ -20981,23 +20979,23 @@ function date4(params) {
|
|
|
20981
20979
|
config(en_default());
|
|
20982
20980
|
|
|
20983
20981
|
// src/agents/mcp-server.ts
|
|
20984
|
-
async function apiGet(apiUrl,
|
|
20985
|
-
const res = await fetch(`${apiUrl}${
|
|
20982
|
+
async function apiGet(apiUrl, path19, headers) {
|
|
20983
|
+
const res = await fetch(`${apiUrl}${path19}`, {
|
|
20986
20984
|
headers: { ...headers, "Content-Type": "application/json" }
|
|
20987
20985
|
});
|
|
20988
20986
|
if (!res.ok) {
|
|
20989
|
-
throw new Error(`API GET ${
|
|
20987
|
+
throw new Error(`API GET ${path19} failed: HTTP ${res.status}`);
|
|
20990
20988
|
}
|
|
20991
20989
|
return res.json();
|
|
20992
20990
|
}
|
|
20993
|
-
async function apiPost(apiUrl,
|
|
20994
|
-
const res = await fetch(`${apiUrl}${
|
|
20991
|
+
async function apiPost(apiUrl, path19, body, headers) {
|
|
20992
|
+
const res = await fetch(`${apiUrl}${path19}`, {
|
|
20995
20993
|
method: "POST",
|
|
20996
20994
|
headers: { ...headers, "Content-Type": "application/json" },
|
|
20997
20995
|
body: JSON.stringify(body)
|
|
20998
20996
|
});
|
|
20999
20997
|
if (!res.ok) {
|
|
21000
|
-
throw new Error(`API POST ${
|
|
20998
|
+
throw new Error(`API POST ${path19} failed: HTTP ${res.status}`);
|
|
21001
20999
|
}
|
|
21002
21000
|
return res.json();
|
|
21003
21001
|
}
|
|
@@ -21313,8 +21311,8 @@ var RelayClient = class {
|
|
|
21313
21311
|
// src/agents/sessions.ts
|
|
21314
21312
|
import fs3 from "fs/promises";
|
|
21315
21313
|
import os4 from "os";
|
|
21316
|
-
import
|
|
21317
|
-
var SESSIONS_FILE =
|
|
21314
|
+
import path4 from "path";
|
|
21315
|
+
var SESSIONS_FILE = path4.join(
|
|
21318
21316
|
os4.homedir(),
|
|
21319
21317
|
".workle",
|
|
21320
21318
|
"agent-sessions.json"
|
|
@@ -21336,7 +21334,7 @@ async function saveSessionId(agentId, sessionId) {
|
|
|
21336
21334
|
} catch {
|
|
21337
21335
|
}
|
|
21338
21336
|
map2[agentId] = sessionId;
|
|
21339
|
-
await fs3.mkdir(
|
|
21337
|
+
await fs3.mkdir(path4.dirname(SESSIONS_FILE), { recursive: true });
|
|
21340
21338
|
await fs3.writeFile(SESSIONS_FILE, JSON.stringify(map2, null, 2), "utf-8");
|
|
21341
21339
|
}
|
|
21342
21340
|
|
|
@@ -21875,10 +21873,10 @@ import { spawn } from "child_process";
|
|
|
21875
21873
|
import fs5 from "fs/promises";
|
|
21876
21874
|
import http from "http";
|
|
21877
21875
|
import os5 from "os";
|
|
21878
|
-
import
|
|
21879
|
-
var CLAW_HOME =
|
|
21880
|
-
var LOG_FILE =
|
|
21881
|
-
var PID_FILE =
|
|
21876
|
+
import path5 from "path";
|
|
21877
|
+
var CLAW_HOME = path5.join(os5.homedir(), ".workle");
|
|
21878
|
+
var LOG_FILE = path5.join(CLAW_HOME, "openclaw.log");
|
|
21879
|
+
var PID_FILE = path5.join(CLAW_HOME, "openclaw.pid");
|
|
21882
21880
|
var OPENCLAW_PORT = 18789;
|
|
21883
21881
|
var HEALTH_CHECK_TIMEOUT = 5e3;
|
|
21884
21882
|
var ProcessManager = class {
|
|
@@ -21891,7 +21889,7 @@ var ProcessManager = class {
|
|
|
21891
21889
|
* @param openclawBinary - Path to the openclaw binary (defaults to "openclaw" in PATH)
|
|
21892
21890
|
* @param configPath - Path to openclaw.json config (defaults to ~/.workle/openclaw.json)
|
|
21893
21891
|
*/
|
|
21894
|
-
async spawn(openclawBinary = "openclaw", configPath =
|
|
21892
|
+
async spawn(openclawBinary = "openclaw", configPath = path5.join(CLAW_HOME, "openclaw.json")) {
|
|
21895
21893
|
if (this.process) {
|
|
21896
21894
|
console.log("[claw] OpenClaw process already running");
|
|
21897
21895
|
return;
|
|
@@ -22023,8 +22021,8 @@ var ProcessManager = class {
|
|
|
22023
22021
|
import { execSync } from "child_process";
|
|
22024
22022
|
import fs6 from "fs/promises";
|
|
22025
22023
|
import os6 from "os";
|
|
22026
|
-
import
|
|
22027
|
-
var WORKLE_HOME2 =
|
|
22024
|
+
import path6 from "path";
|
|
22025
|
+
var WORKLE_HOME2 = path6.join(os6.homedir(), ".workle");
|
|
22028
22026
|
var MIN_NODE_MAJOR = 22;
|
|
22029
22027
|
async function runDoctor() {
|
|
22030
22028
|
const checks = [];
|
|
@@ -22107,7 +22105,7 @@ async function checkClawHome() {
|
|
|
22107
22105
|
}
|
|
22108
22106
|
}
|
|
22109
22107
|
async function checkAuthFile() {
|
|
22110
|
-
const authPath =
|
|
22108
|
+
const authPath = path6.join(WORKLE_HOME2, "auth.json");
|
|
22111
22109
|
try {
|
|
22112
22110
|
const raw = await fs6.readFile(authPath, "utf-8");
|
|
22113
22111
|
const parsed = JSON.parse(raw);
|
|
@@ -22132,7 +22130,7 @@ async function checkAuthFile() {
|
|
|
22132
22130
|
}
|
|
22133
22131
|
}
|
|
22134
22132
|
async function checkConfigFile() {
|
|
22135
|
-
const configPath =
|
|
22133
|
+
const configPath = path6.join(WORKLE_HOME2, "openclaw.json");
|
|
22136
22134
|
try {
|
|
22137
22135
|
const raw = await fs6.readFile(configPath, "utf-8");
|
|
22138
22136
|
const parsed = JSON.parse(raw);
|
|
@@ -22181,25 +22179,25 @@ async function checkGatewayReachable() {
|
|
|
22181
22179
|
// src/lifecycle/install.ts
|
|
22182
22180
|
import fs7 from "fs/promises";
|
|
22183
22181
|
import os7 from "os";
|
|
22184
|
-
import
|
|
22185
|
-
var WORKLE_HOME3 =
|
|
22186
|
-
var LAUNCH_AGENTS_DIR =
|
|
22187
|
-
var STAGED_CLI_PATH =
|
|
22182
|
+
import path7 from "path";
|
|
22183
|
+
var WORKLE_HOME3 = path7.join(os7.homedir(), ".workle");
|
|
22184
|
+
var LAUNCH_AGENTS_DIR = path7.join(os7.homedir(), "Library", "LaunchAgents");
|
|
22185
|
+
var STAGED_CLI_PATH = path7.join(WORKLE_HOME3, "bin", "cli.js");
|
|
22188
22186
|
function escapeXml(value) {
|
|
22189
22187
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
22190
22188
|
}
|
|
22191
22189
|
async function setupClawDirectory() {
|
|
22192
22190
|
const dirs = [
|
|
22193
22191
|
WORKLE_HOME3,
|
|
22194
|
-
|
|
22195
|
-
|
|
22192
|
+
path7.join(WORKLE_HOME3, "logs"),
|
|
22193
|
+
path7.join(WORKLE_HOME3, "bin")
|
|
22196
22194
|
];
|
|
22197
22195
|
for (const dir of dirs) {
|
|
22198
22196
|
await fs7.mkdir(dir, { recursive: true, mode: 448 });
|
|
22199
22197
|
await fs7.chmod(dir, 448).catch(() => {
|
|
22200
22198
|
});
|
|
22201
22199
|
}
|
|
22202
|
-
const gitignorePath =
|
|
22200
|
+
const gitignorePath = path7.join(WORKLE_HOME3, ".gitignore");
|
|
22203
22201
|
try {
|
|
22204
22202
|
await fs7.access(gitignorePath);
|
|
22205
22203
|
} catch {
|
|
@@ -22223,7 +22221,7 @@ async function stageCliForDaemon(currentCliPath) {
|
|
|
22223
22221
|
}
|
|
22224
22222
|
async function writeLaunchdPlist(serviceName = "com.workle.claw", executable = process.execPath, args = [STAGED_CLI_PATH, "start"]) {
|
|
22225
22223
|
await fs7.mkdir(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
22226
|
-
const plistPath =
|
|
22224
|
+
const plistPath = path7.join(LAUNCH_AGENTS_DIR, `${serviceName}.plist`);
|
|
22227
22225
|
const programArguments = [executable, ...args].map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n");
|
|
22228
22226
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
22229
22227
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -22247,10 +22245,10 @@ ${programArguments}
|
|
|
22247
22245
|
</dict>
|
|
22248
22246
|
|
|
22249
22247
|
<key>StandardOutPath</key>
|
|
22250
|
-
<string>${
|
|
22248
|
+
<string>${path7.join(WORKLE_HOME3, "logs", "stdout.log")}</string>
|
|
22251
22249
|
|
|
22252
22250
|
<key>StandardErrorPath</key>
|
|
22253
|
-
<string>${
|
|
22251
|
+
<string>${path7.join(WORKLE_HOME3, "logs", "stderr.log")}</string>
|
|
22254
22252
|
|
|
22255
22253
|
<key>WorkingDirectory</key>
|
|
22256
22254
|
<string>${WORKLE_HOME3}</string>
|
|
@@ -22271,18 +22269,18 @@ ${programArguments}
|
|
|
22271
22269
|
// src/sync/service.ts
|
|
22272
22270
|
import fs15 from "fs/promises";
|
|
22273
22271
|
import os17 from "os";
|
|
22274
|
-
import
|
|
22272
|
+
import path17 from "path";
|
|
22275
22273
|
|
|
22276
22274
|
// src/legacy/openclaw/gateway.ts
|
|
22277
22275
|
import os8 from "os";
|
|
22278
|
-
import
|
|
22279
|
-
var CLAW_HOME2 =
|
|
22276
|
+
import path8 from "path";
|
|
22277
|
+
var CLAW_HOME2 = path8.join(os8.homedir(), ".workle");
|
|
22280
22278
|
function generateGatewayConfig(_instance, agents) {
|
|
22281
22279
|
const sorted = [...agents].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
22282
22280
|
const list = sorted.map((agent) => ({
|
|
22283
22281
|
id: agent.id,
|
|
22284
22282
|
default: !agent.isSubAgent,
|
|
22285
|
-
workspace:
|
|
22283
|
+
workspace: path8.join(CLAW_HOME2, `workspace-${agent.agentKey}`),
|
|
22286
22284
|
model: agent.model,
|
|
22287
22285
|
toolProfile: agent.toolProfile,
|
|
22288
22286
|
promptMode: agent.promptMode
|
|
@@ -22295,8 +22293,8 @@ function generateGatewayConfig(_instance, agents) {
|
|
|
22295
22293
|
// src/legacy/openclaw/soul.ts
|
|
22296
22294
|
import fs8 from "fs/promises";
|
|
22297
22295
|
import os9 from "os";
|
|
22298
|
-
import
|
|
22299
|
-
var CLAW_HOME3 =
|
|
22296
|
+
import path9 from "path";
|
|
22297
|
+
var CLAW_HOME3 = path9.join(os9.homedir(), ".workle");
|
|
22300
22298
|
var DEFAULT_SOUL_MD = `# Soul
|
|
22301
22299
|
|
|
22302
22300
|
You are a Workle agent. Follow your assigned skills and operational instructions.
|
|
@@ -22308,17 +22306,17 @@ async function writeSoulMd(agentKey, content, rpcCall) {
|
|
|
22308
22306
|
await rpcCall(agentKey, "SOUL.md", body);
|
|
22309
22307
|
return;
|
|
22310
22308
|
}
|
|
22311
|
-
const workspaceDir =
|
|
22309
|
+
const workspaceDir = path9.join(CLAW_HOME3, `workspace-${agentKey}`);
|
|
22312
22310
|
await fs8.mkdir(workspaceDir, { recursive: true });
|
|
22313
|
-
const filePath =
|
|
22311
|
+
const filePath = path9.join(workspaceDir, "SOUL.md");
|
|
22314
22312
|
await fs8.writeFile(filePath, body, "utf-8");
|
|
22315
22313
|
}
|
|
22316
22314
|
|
|
22317
22315
|
// src/legacy/openclaw/agents.ts
|
|
22318
22316
|
import fs9 from "fs/promises";
|
|
22319
22317
|
import os10 from "os";
|
|
22320
|
-
import
|
|
22321
|
-
var CLAW_HOME4 =
|
|
22318
|
+
import path10 from "path";
|
|
22319
|
+
var CLAW_HOME4 = path10.join(os10.homedir(), ".workle");
|
|
22322
22320
|
var DEFAULT_AGENTS_MD = `# Agents
|
|
22323
22321
|
|
|
22324
22322
|
No additional agent configuration provided.
|
|
@@ -22329,17 +22327,17 @@ async function writeAgentsMd(agentKey, content, rpcCall) {
|
|
|
22329
22327
|
await rpcCall(agentKey, "AGENTS.md", body);
|
|
22330
22328
|
return;
|
|
22331
22329
|
}
|
|
22332
|
-
const workspaceDir =
|
|
22330
|
+
const workspaceDir = path10.join(CLAW_HOME4, `workspace-${agentKey}`);
|
|
22333
22331
|
await fs9.mkdir(workspaceDir, { recursive: true });
|
|
22334
|
-
const filePath =
|
|
22332
|
+
const filePath = path10.join(workspaceDir, "AGENTS.md");
|
|
22335
22333
|
await fs9.writeFile(filePath, body, "utf-8");
|
|
22336
22334
|
}
|
|
22337
22335
|
|
|
22338
22336
|
// src/config/identity.ts
|
|
22339
22337
|
import fs10 from "fs/promises";
|
|
22340
22338
|
import os11 from "os";
|
|
22341
|
-
import
|
|
22342
|
-
var WORKLE_HOME4 =
|
|
22339
|
+
import path11 from "path";
|
|
22340
|
+
var WORKLE_HOME4 = path11.join(os11.homedir(), ".workle");
|
|
22343
22341
|
var DEFAULT_IDENTITY_MD = `# Identity
|
|
22344
22342
|
|
|
22345
22343
|
No identity configuration provided.
|
|
@@ -22350,17 +22348,17 @@ async function writeIdentityMd(agentKey, content, rpcCall) {
|
|
|
22350
22348
|
await rpcCall(agentKey, "IDENTITY.md", body);
|
|
22351
22349
|
return;
|
|
22352
22350
|
}
|
|
22353
|
-
const workspaceDir =
|
|
22351
|
+
const workspaceDir = path11.join(WORKLE_HOME4, `workspace-${agentKey}`);
|
|
22354
22352
|
await fs10.mkdir(workspaceDir, { recursive: true });
|
|
22355
|
-
const filePath =
|
|
22353
|
+
const filePath = path11.join(workspaceDir, "IDENTITY.md");
|
|
22356
22354
|
await fs10.writeFile(filePath, body, "utf-8");
|
|
22357
22355
|
}
|
|
22358
22356
|
|
|
22359
22357
|
// src/config/heartbeat.ts
|
|
22360
22358
|
import fs11 from "fs/promises";
|
|
22361
22359
|
import os12 from "os";
|
|
22362
|
-
import
|
|
22363
|
-
var WORKLE_HOME5 =
|
|
22360
|
+
import path12 from "path";
|
|
22361
|
+
var WORKLE_HOME5 = path12.join(os12.homedir(), ".workle");
|
|
22364
22362
|
var DEFAULT_HEARTBEAT_MD = `# Heartbeat
|
|
22365
22363
|
|
|
22366
22364
|
No heartbeat configuration provided.
|
|
@@ -22371,34 +22369,34 @@ async function writeHeartbeatMd(agentKey, content, rpcCall) {
|
|
|
22371
22369
|
await rpcCall(agentKey, "HEARTBEAT.md", body);
|
|
22372
22370
|
return;
|
|
22373
22371
|
}
|
|
22374
|
-
const workspaceDir =
|
|
22372
|
+
const workspaceDir = path12.join(WORKLE_HOME5, `workspace-${agentKey}`);
|
|
22375
22373
|
await fs11.mkdir(workspaceDir, { recursive: true });
|
|
22376
|
-
const filePath =
|
|
22374
|
+
const filePath = path12.join(workspaceDir, "HEARTBEAT.md");
|
|
22377
22375
|
await fs11.writeFile(filePath, body, "utf-8");
|
|
22378
22376
|
}
|
|
22379
22377
|
|
|
22380
22378
|
// src/config/skills.ts
|
|
22381
22379
|
import fs12 from "fs/promises";
|
|
22382
22380
|
import os13 from "os";
|
|
22383
|
-
import
|
|
22384
|
-
var WORKLE_HOME6 =
|
|
22381
|
+
import path13 from "path";
|
|
22382
|
+
var WORKLE_HOME6 = path13.join(os13.homedir(), ".workle");
|
|
22385
22383
|
|
|
22386
22384
|
// src/legacy/openclaw/rpc.ts
|
|
22387
22385
|
import crypto4 from "crypto";
|
|
22388
22386
|
import fs13 from "fs";
|
|
22389
22387
|
import os14 from "os";
|
|
22390
|
-
import
|
|
22388
|
+
import path14 from "path";
|
|
22391
22389
|
var OPENCLAW_PORT2 = 18789;
|
|
22392
22390
|
var OPENCLAW_URL = `ws://127.0.0.1:${OPENCLAW_PORT2}`;
|
|
22393
22391
|
var RPC_TIMEOUT = 3e4;
|
|
22394
22392
|
var MAX_RECONNECT_BACKOFF = 1e4;
|
|
22395
22393
|
var CLAW_VERSION = "0.1.16";
|
|
22396
22394
|
var OPENCLAW_CONFIG_PATHS = [
|
|
22397
|
-
() =>
|
|
22398
|
-
() =>
|
|
22395
|
+
() => path14.join(os14.homedir(), ".openclaw", "openclaw.json"),
|
|
22396
|
+
() => path14.join(os14.homedir(), ".config", "openclaw", "openclaw.json")
|
|
22399
22397
|
];
|
|
22400
|
-
var CLAW_IDENTITY_DIR =
|
|
22401
|
-
var CLAW_IDENTITY_FILE =
|
|
22398
|
+
var CLAW_IDENTITY_DIR = path14.join(os14.homedir(), ".workle");
|
|
22399
|
+
var CLAW_IDENTITY_FILE = path14.join(CLAW_IDENTITY_DIR, "device-identity.json");
|
|
22402
22400
|
var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
22403
22401
|
function base64UrlEncode(buf) {
|
|
22404
22402
|
return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
|
|
@@ -22907,17 +22905,17 @@ async function agentDiscovery(rpc, apiUrl, instanceId, token) {
|
|
|
22907
22905
|
|
|
22908
22906
|
// src/sync/events.ts
|
|
22909
22907
|
import os16 from "os";
|
|
22910
|
-
import
|
|
22908
|
+
import path16 from "path";
|
|
22911
22909
|
|
|
22912
22910
|
// src/sync/queue.ts
|
|
22913
22911
|
import fs14 from "fs/promises";
|
|
22914
22912
|
import os15 from "os";
|
|
22915
|
-
import
|
|
22913
|
+
import path15 from "path";
|
|
22916
22914
|
var MAX_FILE_SIZE = 5e8;
|
|
22917
22915
|
var PersistentEventQueue = class {
|
|
22918
22916
|
filePath;
|
|
22919
22917
|
constructor(customPath) {
|
|
22920
|
-
this.filePath = customPath ??
|
|
22918
|
+
this.filePath = customPath ?? path15.join(os15.homedir(), ".workle", "pending-events.jsonl");
|
|
22921
22919
|
}
|
|
22922
22920
|
/**
|
|
22923
22921
|
* Append a single entry to the queue file.
|
|
@@ -22984,7 +22982,7 @@ var PersistentEventQueue = class {
|
|
|
22984
22982
|
}
|
|
22985
22983
|
// --- Internal ---
|
|
22986
22984
|
async ensureDir() {
|
|
22987
|
-
const dir =
|
|
22985
|
+
const dir = path15.dirname(this.filePath);
|
|
22988
22986
|
await fs14.mkdir(dir, { recursive: true });
|
|
22989
22987
|
}
|
|
22990
22988
|
/**
|
|
@@ -23012,7 +23010,7 @@ var PersistentEventQueue = class {
|
|
|
23012
23010
|
};
|
|
23013
23011
|
|
|
23014
23012
|
// src/sync/events.ts
|
|
23015
|
-
var WORKLE_HOME7 =
|
|
23013
|
+
var WORKLE_HOME7 = path16.join(os16.homedir(), ".workle");
|
|
23016
23014
|
var EVENT_TYPE_MAP = {
|
|
23017
23015
|
"agent.run": "agent.started",
|
|
23018
23016
|
"agent.run.complete": "agent.completed",
|
|
@@ -23053,7 +23051,7 @@ function getQueue(instanceId) {
|
|
|
23053
23051
|
const existing = sharedQueues.get(queueKey);
|
|
23054
23052
|
if (existing) return existing;
|
|
23055
23053
|
const queue = new PersistentEventQueue(
|
|
23056
|
-
|
|
23054
|
+
path16.join(WORKLE_HOME7, `pending-events-${queueKey}.jsonl`)
|
|
23057
23055
|
);
|
|
23058
23056
|
sharedQueues.set(queueKey, queue);
|
|
23059
23057
|
return queue;
|
|
@@ -23116,7 +23114,7 @@ async function replayPendingEvents(apiUrl, token, instanceId) {
|
|
|
23116
23114
|
}
|
|
23117
23115
|
|
|
23118
23116
|
// src/sync/service.ts
|
|
23119
|
-
var WORKLE_HOME8 =
|
|
23117
|
+
var WORKLE_HOME8 = path17.join(os17.homedir(), ".workle");
|
|
23120
23118
|
function deriveRelayUrl2(apiUrl) {
|
|
23121
23119
|
const url2 = new URL(apiUrl);
|
|
23122
23120
|
url2.protocol = url2.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -23469,7 +23467,7 @@ var SyncService = class {
|
|
|
23469
23467
|
}
|
|
23470
23468
|
async writeConfigFiles(instance, agents) {
|
|
23471
23469
|
const gatewayConfig = generateGatewayConfig(instance, agents);
|
|
23472
|
-
const configPath =
|
|
23470
|
+
const configPath = path17.join(WORKLE_HOME8, "openclaw.json");
|
|
23473
23471
|
await fs15.mkdir(WORKLE_HOME8, { recursive: true });
|
|
23474
23472
|
await fs15.writeFile(configPath, JSON.stringify(gatewayConfig, null, 2), "utf-8");
|
|
23475
23473
|
await Promise.all(
|
|
@@ -23484,9 +23482,9 @@ var SyncService = class {
|
|
|
23484
23482
|
};
|
|
23485
23483
|
|
|
23486
23484
|
// src/cli.ts
|
|
23487
|
-
var WORKLE_HOME9 =
|
|
23488
|
-
var AUTH_FILE2 =
|
|
23489
|
-
var LAUNCH_AGENTS_DIR2 =
|
|
23485
|
+
var WORKLE_HOME9 = path18.join(os18.homedir(), ".workle");
|
|
23486
|
+
var AUTH_FILE2 = path18.join(WORKLE_HOME9, "auth.json");
|
|
23487
|
+
var LAUNCH_AGENTS_DIR2 = path18.join(os18.homedir(), "Library", "LaunchAgents");
|
|
23490
23488
|
var PLIST_LABEL = "com.workle.claw";
|
|
23491
23489
|
var color = {
|
|
23492
23490
|
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
@@ -23736,7 +23734,7 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23736
23734
|
console.log("");
|
|
23737
23735
|
console.log(` Service: ${color.dim(PLIST_LABEL)}`);
|
|
23738
23736
|
console.log(` Plist: ${color.dim(plistPath)}`);
|
|
23739
|
-
console.log(` Logs: ${color.dim(
|
|
23737
|
+
console.log(` Logs: ${color.dim(path18.join(WORKLE_HOME9, "logs/"))}`);
|
|
23740
23738
|
console.log("");
|
|
23741
23739
|
console.log(
|
|
23742
23740
|
`To stop: ${color.cyan("npx @getworkle/cli stop")}`
|
|
@@ -23804,14 +23802,14 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23804
23802
|
}
|
|
23805
23803
|
});
|
|
23806
23804
|
program2.command("stop").description("Stop the Workle Claw daemon").action(async () => {
|
|
23807
|
-
const plistPath =
|
|
23805
|
+
const plistPath = path18.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23808
23806
|
try {
|
|
23809
23807
|
execSync2(`launchctl unload "${plistPath}"`, { stdio: "inherit" });
|
|
23810
23808
|
console.log(color.green("\u2713 Daemon stopped"));
|
|
23811
23809
|
} catch {
|
|
23812
23810
|
console.log(color.dim("No launchd service loaded."));
|
|
23813
23811
|
}
|
|
23814
|
-
const pidFile =
|
|
23812
|
+
const pidFile = path18.join(WORKLE_HOME9, "openclaw.pid");
|
|
23815
23813
|
try {
|
|
23816
23814
|
const pidStr = await fs16.readFile(pidFile, "utf-8");
|
|
23817
23815
|
const pid = parseInt(pidStr.trim(), 10);
|
|
@@ -23856,7 +23854,7 @@ program2.command("status").description("Show connection state and instance info"
|
|
|
23856
23854
|
} catch {
|
|
23857
23855
|
console.log(` Gateway: ${color.yellow("unreachable")}`);
|
|
23858
23856
|
}
|
|
23859
|
-
const plistPath =
|
|
23857
|
+
const plistPath = path18.join(LAUNCH_AGENTS_DIR2, `${PLIST_LABEL}.plist`);
|
|
23860
23858
|
try {
|
|
23861
23859
|
await fs16.access(plistPath);
|
|
23862
23860
|
try {
|
|
@@ -23883,8 +23881,8 @@ program2.command("logs").description("Tail the Workle Claw log files").option("-
|
|
|
23883
23881
|
process.exit(1);
|
|
23884
23882
|
}
|
|
23885
23883
|
const logFiles = [
|
|
23886
|
-
|
|
23887
|
-
|
|
23884
|
+
path18.join(WORKLE_HOME9, "openclaw.log"),
|
|
23885
|
+
path18.join(WORKLE_HOME9, "logs", "stderr.log")
|
|
23888
23886
|
];
|
|
23889
23887
|
const args = ["-n", String(lineCount)];
|
|
23890
23888
|
if (opts.follow) args.push("-f");
|
|
@@ -24048,12 +24046,12 @@ agentCmd.command("logs [agentId]").description("Tail agent run logs").option("-n
|
|
|
24048
24046
|
console.error(color.red("Error: --lines must be a positive integer."));
|
|
24049
24047
|
process.exit(1);
|
|
24050
24048
|
}
|
|
24051
|
-
const logsDir =
|
|
24049
|
+
const logsDir = path18.join(WORKLE_HOME9, "agents");
|
|
24052
24050
|
let logFile;
|
|
24053
24051
|
if (agentId) {
|
|
24054
|
-
logFile =
|
|
24052
|
+
logFile = path18.join(logsDir, agentId, "run.log");
|
|
24055
24053
|
} else {
|
|
24056
|
-
logFile =
|
|
24054
|
+
logFile = path18.join(logsDir, "*", "run.log");
|
|
24057
24055
|
}
|
|
24058
24056
|
const args = ["-n", String(lineCount)];
|
|
24059
24057
|
if (opts.follow) args.push("-f");
|