@getworkle/cli 0.2.9 → 0.2.11

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