@getworkle/cli 0.2.4 → 0.2.5
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 +319 -89
- package/dist/cli.js.map +1 -1
- package/package.json +13 -7
package/dist/cli.js
CHANGED
|
@@ -8044,8 +8044,8 @@ import path3 from "path";
|
|
|
8044
8044
|
import fs from "fs/promises";
|
|
8045
8045
|
import os from "os";
|
|
8046
8046
|
import path from "path";
|
|
8047
|
-
var
|
|
8048
|
-
var AUTH_FILE = path.join(
|
|
8047
|
+
var WORKLE_HOME = path.join(os.homedir(), ".workle");
|
|
8048
|
+
var AUTH_FILE = path.join(WORKLE_HOME, "auth.json");
|
|
8049
8049
|
async function loadAuth() {
|
|
8050
8050
|
let raw;
|
|
8051
8051
|
try {
|
|
@@ -8111,7 +8111,7 @@ function sanitizeAgentAssetFilename(filename, fallback) {
|
|
|
8111
8111
|
}
|
|
8112
8112
|
|
|
8113
8113
|
// src/agents/config-materializer.ts
|
|
8114
|
-
var CACHE_FILE = path3.join(os3.homedir(), ".workle
|
|
8114
|
+
var CACHE_FILE = path3.join(os3.homedir(), ".workle", "agent-cache.json");
|
|
8115
8115
|
var AgentConfigMaterializer = class {
|
|
8116
8116
|
apiUrl;
|
|
8117
8117
|
instanceId;
|
|
@@ -8251,26 +8251,17 @@ var AgentConfigMaterializer = class {
|
|
|
8251
8251
|
// src/agents/runner.ts
|
|
8252
8252
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
8253
8253
|
async function runAgent(opts) {
|
|
8254
|
-
const { agentDir, prompt, sessionId, mcpServers, onMessage } = opts;
|
|
8254
|
+
const { agentDir, prompt, sessionId, maxTurns, mcpServers, onMessage, abortController } = opts;
|
|
8255
8255
|
try {
|
|
8256
8256
|
const stream = query({
|
|
8257
8257
|
prompt,
|
|
8258
8258
|
options: {
|
|
8259
8259
|
cwd: agentDir,
|
|
8260
8260
|
settingSources: ["project"],
|
|
8261
|
-
permissionMode: "bypassPermissions",
|
|
8262
|
-
allowDangerouslySkipPermissions: true,
|
|
8263
|
-
allowedTools: [
|
|
8264
|
-
"Read",
|
|
8265
|
-
"Write",
|
|
8266
|
-
"Edit",
|
|
8267
|
-
"Bash",
|
|
8268
|
-
"Glob",
|
|
8269
|
-
"Grep",
|
|
8270
|
-
"mcp__workle__*"
|
|
8271
|
-
],
|
|
8272
8261
|
...sessionId ? { resume: sessionId } : {},
|
|
8273
|
-
...
|
|
8262
|
+
...typeof maxTurns === "number" ? { maxTurns } : {},
|
|
8263
|
+
...mcpServers ? { mcpServers } : {},
|
|
8264
|
+
...abortController ? { abortController } : {}
|
|
8274
8265
|
}
|
|
8275
8266
|
});
|
|
8276
8267
|
let resultSessionId = sessionId ?? "";
|
|
@@ -21316,7 +21307,7 @@ import os4 from "os";
|
|
|
21316
21307
|
import path4 from "path";
|
|
21317
21308
|
var SESSIONS_FILE = path4.join(
|
|
21318
21309
|
os4.homedir(),
|
|
21319
|
-
".workle
|
|
21310
|
+
".workle",
|
|
21320
21311
|
"agent-sessions.json"
|
|
21321
21312
|
);
|
|
21322
21313
|
async function loadSessionId(agentId) {
|
|
@@ -21341,6 +21332,23 @@ async function saveSessionId(agentId, sessionId) {
|
|
|
21341
21332
|
}
|
|
21342
21333
|
|
|
21343
21334
|
// src/agents/service.ts
|
|
21335
|
+
function asRecord(value) {
|
|
21336
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
21337
|
+
}
|
|
21338
|
+
function getMessageSessionId(message) {
|
|
21339
|
+
const record2 = asRecord(message);
|
|
21340
|
+
return typeof record2?.session_id === "string" ? record2.session_id : void 0;
|
|
21341
|
+
}
|
|
21342
|
+
function stringifyProgressValue(value) {
|
|
21343
|
+
if (typeof value === "string") {
|
|
21344
|
+
return value;
|
|
21345
|
+
}
|
|
21346
|
+
try {
|
|
21347
|
+
return JSON.stringify(value);
|
|
21348
|
+
} catch {
|
|
21349
|
+
return String(value);
|
|
21350
|
+
}
|
|
21351
|
+
}
|
|
21344
21352
|
function deriveRelayUrl(apiUrl) {
|
|
21345
21353
|
const url2 = new URL(apiUrl);
|
|
21346
21354
|
url2.protocol = url2.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -21350,7 +21358,8 @@ function deriveRelayUrl(apiUrl) {
|
|
|
21350
21358
|
}
|
|
21351
21359
|
return url2.toString().replace(/\/$/, "");
|
|
21352
21360
|
}
|
|
21353
|
-
var AgentService = class {
|
|
21361
|
+
var AgentService = class _AgentService {
|
|
21362
|
+
static SCHEDULED_RUN_PROMPT = "Run your scheduled workflow for this agent.";
|
|
21354
21363
|
apiUrl;
|
|
21355
21364
|
token;
|
|
21356
21365
|
instanceId;
|
|
@@ -21360,8 +21369,12 @@ var AgentService = class {
|
|
|
21360
21369
|
unsubscribeRelay = null;
|
|
21361
21370
|
/** Map of agentId -> agent stub (for name lookups). */
|
|
21362
21371
|
agentMap = /* @__PURE__ */ new Map();
|
|
21372
|
+
/** Map of agentId -> pulled config (for schedule + runtime settings). */
|
|
21373
|
+
agentConfigMap = /* @__PURE__ */ new Map();
|
|
21363
21374
|
/** Map of agentId -> currently running promise (prevents concurrent runs). */
|
|
21364
21375
|
activeRuns = /* @__PURE__ */ new Map();
|
|
21376
|
+
/** Map of executionId -> AbortController (for cancel support). */
|
|
21377
|
+
activeAborts = /* @__PURE__ */ new Map();
|
|
21365
21378
|
running = false;
|
|
21366
21379
|
constructor(opts) {
|
|
21367
21380
|
this.apiUrl = opts.apiUrl;
|
|
@@ -21396,6 +21409,7 @@ var AgentService = class {
|
|
|
21396
21409
|
runtime: config2.runtime,
|
|
21397
21410
|
updatedAt: config2.updatedAt
|
|
21398
21411
|
});
|
|
21412
|
+
this.agentConfigMap.set(config2.id, config2);
|
|
21399
21413
|
configs.push(config2);
|
|
21400
21414
|
} catch (err) {
|
|
21401
21415
|
console.error(
|
|
@@ -21417,43 +21431,83 @@ var AgentService = class {
|
|
|
21417
21431
|
});
|
|
21418
21432
|
await this.relayClient.connect();
|
|
21419
21433
|
console.log("[agents] Connected to relay");
|
|
21434
|
+
this.refreshSchedules();
|
|
21420
21435
|
this.running = true;
|
|
21421
21436
|
console.log("[agents] AgentService running");
|
|
21422
21437
|
}
|
|
21423
21438
|
/**
|
|
21424
21439
|
* Trigger an agent run. Prevents concurrent runs of the same agent.
|
|
21425
21440
|
*/
|
|
21426
|
-
async triggerAgent(agentId, prompt) {
|
|
21441
|
+
async triggerAgent(agentId, prompt, options) {
|
|
21442
|
+
const executionId = options?.executionId;
|
|
21443
|
+
const resumeSession = options?.resumeSession !== false;
|
|
21427
21444
|
const existing = this.activeRuns.get(agentId);
|
|
21428
21445
|
if (existing) {
|
|
21429
21446
|
console.log(
|
|
21430
21447
|
`[agents] Agent ${agentId} is already running \u2014 skipping trigger`
|
|
21431
21448
|
);
|
|
21449
|
+
if (executionId && this.relayClient?.connected) {
|
|
21450
|
+
this.relayClient.send({
|
|
21451
|
+
type: "agent.result",
|
|
21452
|
+
payload: {
|
|
21453
|
+
agentId,
|
|
21454
|
+
executionId,
|
|
21455
|
+
success: false,
|
|
21456
|
+
error: "Agent is already running",
|
|
21457
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
21458
|
+
}
|
|
21459
|
+
});
|
|
21460
|
+
}
|
|
21432
21461
|
return {
|
|
21433
21462
|
sessionId: "",
|
|
21434
21463
|
success: false,
|
|
21435
21464
|
error: "Agent is already running"
|
|
21436
21465
|
};
|
|
21437
21466
|
}
|
|
21438
|
-
const
|
|
21439
|
-
const
|
|
21467
|
+
const runExecutionId = executionId ?? randomUUID();
|
|
21468
|
+
const sendProgressPart = (part, sessionId) => {
|
|
21440
21469
|
if (this.relayClient?.connected) {
|
|
21441
21470
|
this.relayClient.send({
|
|
21442
21471
|
type: "agent.progress",
|
|
21443
21472
|
payload: {
|
|
21444
21473
|
agentId,
|
|
21445
|
-
executionId,
|
|
21446
|
-
|
|
21474
|
+
executionId: runExecutionId,
|
|
21475
|
+
part,
|
|
21476
|
+
...sessionId ? { sessionId } : {},
|
|
21447
21477
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
21448
21478
|
}
|
|
21449
21479
|
});
|
|
21450
21480
|
}
|
|
21451
21481
|
};
|
|
21452
|
-
|
|
21482
|
+
const abortController = new AbortController();
|
|
21483
|
+
this.activeAborts.set(runExecutionId, abortController);
|
|
21453
21484
|
const runPromise = (async () => {
|
|
21454
|
-
await this.ensureAgentReady(agentId);
|
|
21455
|
-
|
|
21485
|
+
const config2 = await this.ensureAgentReady(agentId);
|
|
21486
|
+
if (!this.isAgentActive(config2)) {
|
|
21487
|
+
return {
|
|
21488
|
+
sessionId: "",
|
|
21489
|
+
success: false,
|
|
21490
|
+
error: "Agent is inactive"
|
|
21491
|
+
};
|
|
21492
|
+
}
|
|
21493
|
+
const previousSessionId = resumeSession ? await loadSessionId(agentId) : void 0;
|
|
21456
21494
|
const agentDir = getAgentDirPath(agentId);
|
|
21495
|
+
const startedToolCalls = /* @__PURE__ */ new Set();
|
|
21496
|
+
const toolCallIdsByContentBlock = /* @__PURE__ */ new Map();
|
|
21497
|
+
let emittedVisibleProgress = false;
|
|
21498
|
+
const emitProgressPart = (part, sessionId) => {
|
|
21499
|
+
if (part.type !== "error") {
|
|
21500
|
+
emittedVisibleProgress = true;
|
|
21501
|
+
}
|
|
21502
|
+
sendProgressPart(part, sessionId);
|
|
21503
|
+
};
|
|
21504
|
+
const emitToolCallStart = (toolCallId, toolName, sessionId) => {
|
|
21505
|
+
if (!toolCallId || startedToolCalls.has(toolCallId)) {
|
|
21506
|
+
return;
|
|
21507
|
+
}
|
|
21508
|
+
startedToolCalls.add(toolCallId);
|
|
21509
|
+
emitProgressPart({ type: "tool-call-start", toolCallId, toolName }, sessionId);
|
|
21510
|
+
};
|
|
21457
21511
|
const mcpServer = createWorkleMcpServer({
|
|
21458
21512
|
apiUrl: this.apiUrl,
|
|
21459
21513
|
instanceId: this.instanceId,
|
|
@@ -21463,20 +21517,168 @@ var AgentService = class {
|
|
|
21463
21517
|
agentDir,
|
|
21464
21518
|
prompt,
|
|
21465
21519
|
sessionId: previousSessionId,
|
|
21520
|
+
maxTurns: typeof config2?.maxTurns === "number" ? config2.maxTurns : void 0,
|
|
21466
21521
|
mcpServers: { workle: mcpServer },
|
|
21522
|
+
abortController,
|
|
21467
21523
|
onMessage: (message) => {
|
|
21468
|
-
|
|
21524
|
+
const msg = asRecord(message);
|
|
21525
|
+
const sessionId = getMessageSessionId(message);
|
|
21526
|
+
if (msg?.type === "stream_event") {
|
|
21527
|
+
const event = asRecord(msg.event);
|
|
21528
|
+
const eventType = typeof event?.type === "string" ? event.type : "";
|
|
21529
|
+
const eventIndex = typeof event?.index === "number" ? event.index : null;
|
|
21530
|
+
if (eventType === "content_block_start") {
|
|
21531
|
+
const contentBlock = asRecord(event?.content_block);
|
|
21532
|
+
const contentType = typeof contentBlock?.type === "string" ? contentBlock.type : "";
|
|
21533
|
+
if (contentType === "text" && typeof contentBlock?.text === "string") {
|
|
21534
|
+
emitProgressPart({ type: "text-delta", text: contentBlock.text }, sessionId);
|
|
21535
|
+
return;
|
|
21536
|
+
}
|
|
21537
|
+
if (contentType === "thinking" && typeof contentBlock?.thinking === "string") {
|
|
21538
|
+
emitProgressPart(
|
|
21539
|
+
{ type: "reasoning", text: contentBlock.thinking },
|
|
21540
|
+
sessionId
|
|
21541
|
+
);
|
|
21542
|
+
return;
|
|
21543
|
+
}
|
|
21544
|
+
if (contentType === "tool_use") {
|
|
21545
|
+
const toolCallId = typeof contentBlock?.id === "string" ? contentBlock.id : typeof contentBlock?.tool_use_id === "string" ? contentBlock.tool_use_id : "";
|
|
21546
|
+
const toolName = typeof contentBlock?.name === "string" ? contentBlock.name : "";
|
|
21547
|
+
emitToolCallStart(toolCallId, toolName, sessionId);
|
|
21548
|
+
if (contentBlock?.input !== void 0) {
|
|
21549
|
+
emitProgressPart(
|
|
21550
|
+
{
|
|
21551
|
+
type: "tool-call-delta",
|
|
21552
|
+
toolCallId,
|
|
21553
|
+
argsText: stringifyProgressValue(contentBlock.input)
|
|
21554
|
+
},
|
|
21555
|
+
sessionId
|
|
21556
|
+
);
|
|
21557
|
+
}
|
|
21558
|
+
if (eventIndex !== null && toolCallId) {
|
|
21559
|
+
toolCallIdsByContentBlock.set(eventIndex, toolCallId);
|
|
21560
|
+
}
|
|
21561
|
+
return;
|
|
21562
|
+
}
|
|
21563
|
+
}
|
|
21564
|
+
if (eventType === "content_block_delta") {
|
|
21565
|
+
const delta = asRecord(event?.delta);
|
|
21566
|
+
const deltaType = typeof delta?.type === "string" ? delta.type : "";
|
|
21567
|
+
if (deltaType === "text_delta" && typeof delta?.text === "string") {
|
|
21568
|
+
emitProgressPart({ type: "text-delta", text: delta.text }, sessionId);
|
|
21569
|
+
return;
|
|
21570
|
+
}
|
|
21571
|
+
if (deltaType === "thinking_delta" && typeof delta?.thinking === "string") {
|
|
21572
|
+
emitProgressPart(
|
|
21573
|
+
{ type: "reasoning", text: delta.thinking },
|
|
21574
|
+
sessionId
|
|
21575
|
+
);
|
|
21576
|
+
return;
|
|
21577
|
+
}
|
|
21578
|
+
if (deltaType === "input_json_delta" && typeof delta?.partial_json === "string") {
|
|
21579
|
+
const toolCallId = eventIndex === null ? "" : toolCallIdsByContentBlock.get(eventIndex) ?? "";
|
|
21580
|
+
if (toolCallId) {
|
|
21581
|
+
emitProgressPart(
|
|
21582
|
+
{
|
|
21583
|
+
type: "tool-call-delta",
|
|
21584
|
+
toolCallId,
|
|
21585
|
+
argsText: delta.partial_json
|
|
21586
|
+
},
|
|
21587
|
+
sessionId
|
|
21588
|
+
);
|
|
21589
|
+
return;
|
|
21590
|
+
}
|
|
21591
|
+
}
|
|
21592
|
+
}
|
|
21593
|
+
}
|
|
21594
|
+
if (msg?.type === "assistant") {
|
|
21595
|
+
const assistantMessage = asRecord(msg.message);
|
|
21596
|
+
const content = assistantMessage?.content;
|
|
21597
|
+
if (typeof content === "string") {
|
|
21598
|
+
emitProgressPart({ type: "text-delta", text: content }, sessionId);
|
|
21599
|
+
return;
|
|
21600
|
+
}
|
|
21601
|
+
if (Array.isArray(content)) {
|
|
21602
|
+
for (const item of content) {
|
|
21603
|
+
const block = asRecord(item);
|
|
21604
|
+
const blockType = typeof block?.type === "string" ? block.type : "";
|
|
21605
|
+
if (blockType === "text" && typeof block?.text === "string") {
|
|
21606
|
+
emitProgressPart({ type: "text-delta", text: block.text }, sessionId);
|
|
21607
|
+
continue;
|
|
21608
|
+
}
|
|
21609
|
+
if (blockType === "thinking" && typeof block?.thinking === "string") {
|
|
21610
|
+
emitProgressPart(
|
|
21611
|
+
{ type: "reasoning", text: block.thinking },
|
|
21612
|
+
sessionId
|
|
21613
|
+
);
|
|
21614
|
+
continue;
|
|
21615
|
+
}
|
|
21616
|
+
if (blockType === "tool_use") {
|
|
21617
|
+
const toolCallId = typeof block?.id === "string" ? block.id : typeof block?.tool_use_id === "string" ? block.tool_use_id : "";
|
|
21618
|
+
const toolName = typeof block?.name === "string" ? block.name : "";
|
|
21619
|
+
emitToolCallStart(toolCallId, toolName, sessionId);
|
|
21620
|
+
if (block?.input !== void 0) {
|
|
21621
|
+
emitProgressPart(
|
|
21622
|
+
{
|
|
21623
|
+
type: "tool-call-delta",
|
|
21624
|
+
toolCallId,
|
|
21625
|
+
argsText: stringifyProgressValue(block.input)
|
|
21626
|
+
},
|
|
21627
|
+
sessionId
|
|
21628
|
+
);
|
|
21629
|
+
}
|
|
21630
|
+
continue;
|
|
21631
|
+
}
|
|
21632
|
+
}
|
|
21633
|
+
return;
|
|
21634
|
+
}
|
|
21635
|
+
}
|
|
21636
|
+
if (msg?.type === "tool_progress") {
|
|
21637
|
+
const toolCallId = typeof msg.tool_use_id === "string" ? msg.tool_use_id : "";
|
|
21638
|
+
const toolName = typeof msg.tool_name === "string" ? msg.tool_name : "";
|
|
21639
|
+
emitToolCallStart(toolCallId, toolName, sessionId);
|
|
21640
|
+
return;
|
|
21641
|
+
}
|
|
21642
|
+
if (msg?.type === "user" && typeof msg.parent_tool_use_id === "string" && msg.tool_use_result !== void 0) {
|
|
21643
|
+
emitProgressPart(
|
|
21644
|
+
{
|
|
21645
|
+
type: "tool-result",
|
|
21646
|
+
toolCallId: msg.parent_tool_use_id,
|
|
21647
|
+
result: msg.tool_use_result
|
|
21648
|
+
},
|
|
21649
|
+
sessionId
|
|
21650
|
+
);
|
|
21651
|
+
return;
|
|
21652
|
+
}
|
|
21653
|
+
if (msg?.type === "system" && msg.subtype === "local_command_output" && typeof msg.content === "string") {
|
|
21654
|
+
emitProgressPart({ type: "text-delta", text: msg.content }, sessionId);
|
|
21655
|
+
return;
|
|
21656
|
+
}
|
|
21657
|
+
if (msg?.type === "result") {
|
|
21658
|
+
if (msg.subtype === "success" && typeof msg.result === "string" && !emittedVisibleProgress) {
|
|
21659
|
+
emitProgressPart({ type: "text-delta", text: msg.result }, sessionId);
|
|
21660
|
+
}
|
|
21661
|
+
return;
|
|
21662
|
+
}
|
|
21663
|
+
if (typeof message === "string" && message.trim().length > 0) {
|
|
21664
|
+
emitProgressPart({ type: "text-delta", text: message }, sessionId);
|
|
21665
|
+
}
|
|
21469
21666
|
}
|
|
21470
21667
|
});
|
|
21471
|
-
if (result.sessionId) {
|
|
21668
|
+
if (resumeSession && result.sessionId) {
|
|
21472
21669
|
await saveSessionId(agentId, result.sessionId);
|
|
21473
21670
|
}
|
|
21671
|
+
return result;
|
|
21672
|
+
})();
|
|
21673
|
+
this.activeRuns.set(agentId, runPromise);
|
|
21674
|
+
try {
|
|
21675
|
+
const result = await runPromise;
|
|
21474
21676
|
if (this.relayClient?.connected) {
|
|
21475
21677
|
this.relayClient.send({
|
|
21476
21678
|
type: "agent.result",
|
|
21477
21679
|
payload: {
|
|
21478
21680
|
agentId,
|
|
21479
|
-
executionId,
|
|
21681
|
+
executionId: runExecutionId,
|
|
21480
21682
|
success: result.success,
|
|
21481
21683
|
sessionId: result.sessionId || void 0,
|
|
21482
21684
|
result: result.result,
|
|
@@ -21486,19 +21688,15 @@ var AgentService = class {
|
|
|
21486
21688
|
});
|
|
21487
21689
|
}
|
|
21488
21690
|
return result;
|
|
21489
|
-
})();
|
|
21490
|
-
this.activeRuns.set(agentId, runPromise);
|
|
21491
|
-
try {
|
|
21492
|
-
return await runPromise;
|
|
21493
21691
|
} catch (err) {
|
|
21494
21692
|
const error46 = err instanceof Error ? err.message : String(err);
|
|
21495
|
-
|
|
21693
|
+
sendProgressPart({ type: "error", message: error46 });
|
|
21496
21694
|
if (this.relayClient?.connected) {
|
|
21497
21695
|
this.relayClient.send({
|
|
21498
21696
|
type: "agent.result",
|
|
21499
21697
|
payload: {
|
|
21500
21698
|
agentId,
|
|
21501
|
-
executionId,
|
|
21699
|
+
executionId: runExecutionId,
|
|
21502
21700
|
success: false,
|
|
21503
21701
|
error: error46,
|
|
21504
21702
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -21508,6 +21706,7 @@ var AgentService = class {
|
|
|
21508
21706
|
return { sessionId: "", success: false, error: error46 };
|
|
21509
21707
|
} finally {
|
|
21510
21708
|
this.activeRuns.delete(agentId);
|
|
21709
|
+
this.activeAborts.delete(runExecutionId);
|
|
21511
21710
|
}
|
|
21512
21711
|
}
|
|
21513
21712
|
/**
|
|
@@ -21524,6 +21723,7 @@ var AgentService = class {
|
|
|
21524
21723
|
this.relayClient.disconnect();
|
|
21525
21724
|
this.relayClient = null;
|
|
21526
21725
|
}
|
|
21726
|
+
this.agentConfigMap.clear();
|
|
21527
21727
|
this.running = false;
|
|
21528
21728
|
console.log("[agents] AgentService stopped");
|
|
21529
21729
|
}
|
|
@@ -21540,9 +21740,9 @@ var AgentService = class {
|
|
|
21540
21740
|
handleRelayMessage(msg) {
|
|
21541
21741
|
if (msg.type === "agent.trigger") {
|
|
21542
21742
|
const frame = msg;
|
|
21543
|
-
const { agentId, prompt } = frame.payload;
|
|
21743
|
+
const { agentId, prompt, executionId, resumeSession } = frame.payload;
|
|
21544
21744
|
console.log(`[agents] Received trigger for agent ${agentId}`);
|
|
21545
|
-
void this.triggerAgent(agentId, prompt);
|
|
21745
|
+
void this.triggerAgent(agentId, prompt, { executionId, resumeSession });
|
|
21546
21746
|
}
|
|
21547
21747
|
if (msg.type === "agent.config.updated") {
|
|
21548
21748
|
const frame = msg;
|
|
@@ -21550,6 +21750,15 @@ var AgentService = class {
|
|
|
21550
21750
|
console.log(`[agents] Config updated for agent ${agentId} \u2014 re-syncing`);
|
|
21551
21751
|
void this.resyncAgent(agentId);
|
|
21552
21752
|
}
|
|
21753
|
+
if (msg.type === "agent.cancel") {
|
|
21754
|
+
const frame = msg;
|
|
21755
|
+
const { executionId } = frame.payload;
|
|
21756
|
+
const controller = this.activeAborts.get(executionId);
|
|
21757
|
+
if (controller) {
|
|
21758
|
+
console.log(`[agents] Cancelling execution ${executionId}`);
|
|
21759
|
+
controller.abort();
|
|
21760
|
+
}
|
|
21761
|
+
}
|
|
21553
21762
|
}
|
|
21554
21763
|
async resyncAgent(agentId) {
|
|
21555
21764
|
try {
|
|
@@ -21563,10 +21772,15 @@ var AgentService = class {
|
|
|
21563
21772
|
}
|
|
21564
21773
|
}
|
|
21565
21774
|
async ensureAgentReady(agentId) {
|
|
21775
|
+
const cachedConfig = this.agentConfigMap.get(agentId);
|
|
21776
|
+
if (!cachedConfig) {
|
|
21777
|
+
return this.syncAgentConfig(agentId);
|
|
21778
|
+
}
|
|
21566
21779
|
try {
|
|
21567
21780
|
await fs4.access(getAgentDirPath(agentId));
|
|
21781
|
+
return cachedConfig;
|
|
21568
21782
|
} catch {
|
|
21569
|
-
|
|
21783
|
+
return this.syncAgentConfig(agentId);
|
|
21570
21784
|
}
|
|
21571
21785
|
}
|
|
21572
21786
|
async syncAgentConfig(agentId) {
|
|
@@ -21577,9 +21791,25 @@ var AgentService = class {
|
|
|
21577
21791
|
runtime: config2.runtime,
|
|
21578
21792
|
updatedAt: config2.updatedAt
|
|
21579
21793
|
});
|
|
21794
|
+
this.agentConfigMap.set(config2.id, config2);
|
|
21580
21795
|
await this.materializer.materializeOne(config2);
|
|
21796
|
+
this.refreshSchedules();
|
|
21581
21797
|
return config2;
|
|
21582
21798
|
}
|
|
21799
|
+
isAgentActive(config2) {
|
|
21800
|
+
const isActive = config2?.settings && typeof config2.settings === "object" && "isActive" in config2.settings ? config2.settings.isActive : void 0;
|
|
21801
|
+
return isActive !== false;
|
|
21802
|
+
}
|
|
21803
|
+
refreshSchedules() {
|
|
21804
|
+
const schedules = Array.from(this.agentConfigMap.values()).filter(
|
|
21805
|
+
(config2) => this.isAgentActive(config2) && typeof config2.schedule === "string" && config2.schedule.trim().length > 0
|
|
21806
|
+
).map((config2) => ({
|
|
21807
|
+
agentId: config2.id,
|
|
21808
|
+
schedule: config2.schedule.trim(),
|
|
21809
|
+
prompt: _AgentService.SCHEDULED_RUN_PROMPT
|
|
21810
|
+
}));
|
|
21811
|
+
this.updateSchedules(schedules);
|
|
21812
|
+
}
|
|
21583
21813
|
};
|
|
21584
21814
|
async function createAgentService() {
|
|
21585
21815
|
const auth = await loadAuth();
|
|
@@ -21596,9 +21826,9 @@ import fs5 from "fs/promises";
|
|
|
21596
21826
|
import http from "http";
|
|
21597
21827
|
import os5 from "os";
|
|
21598
21828
|
import path5 from "path";
|
|
21599
|
-
var
|
|
21600
|
-
var LOG_FILE = path5.join(
|
|
21601
|
-
var PID_FILE = path5.join(
|
|
21829
|
+
var CLAW_HOME = path5.join(os5.homedir(), ".workle");
|
|
21830
|
+
var LOG_FILE = path5.join(CLAW_HOME, "openclaw.log");
|
|
21831
|
+
var PID_FILE = path5.join(CLAW_HOME, "openclaw.pid");
|
|
21602
21832
|
var OPENCLAW_PORT = 18789;
|
|
21603
21833
|
var HEALTH_CHECK_TIMEOUT = 5e3;
|
|
21604
21834
|
var ProcessManager = class {
|
|
@@ -21609,14 +21839,14 @@ var ProcessManager = class {
|
|
|
21609
21839
|
* Pipes stdout/stderr to a log file and writes PID to disk.
|
|
21610
21840
|
*
|
|
21611
21841
|
* @param openclawBinary - Path to the openclaw binary (defaults to "openclaw" in PATH)
|
|
21612
|
-
* @param configPath - Path to openclaw.json config (defaults to ~/.workle
|
|
21842
|
+
* @param configPath - Path to openclaw.json config (defaults to ~/.workle/openclaw.json)
|
|
21613
21843
|
*/
|
|
21614
|
-
async spawn(openclawBinary = "openclaw", configPath = path5.join(
|
|
21844
|
+
async spawn(openclawBinary = "openclaw", configPath = path5.join(CLAW_HOME, "openclaw.json")) {
|
|
21615
21845
|
if (this.process) {
|
|
21616
21846
|
console.log("[claw] OpenClaw process already running");
|
|
21617
21847
|
return;
|
|
21618
21848
|
}
|
|
21619
|
-
await fs5.mkdir(
|
|
21849
|
+
await fs5.mkdir(CLAW_HOME, { recursive: true });
|
|
21620
21850
|
this.logHandle = await fs5.open(LOG_FILE, "a");
|
|
21621
21851
|
const logFd = this.logHandle.fd;
|
|
21622
21852
|
this.process = spawn(openclawBinary, ["--config", configPath], {
|
|
@@ -21744,7 +21974,7 @@ import { execSync } from "child_process";
|
|
|
21744
21974
|
import fs6 from "fs/promises";
|
|
21745
21975
|
import os6 from "os";
|
|
21746
21976
|
import path6 from "path";
|
|
21747
|
-
var
|
|
21977
|
+
var WORKLE_HOME2 = path6.join(os6.homedir(), ".workle");
|
|
21748
21978
|
var MIN_NODE_MAJOR = 22;
|
|
21749
21979
|
async function runDoctor() {
|
|
21750
21980
|
const checks = [];
|
|
@@ -21805,29 +22035,29 @@ function checkOpenClawInstalled() {
|
|
|
21805
22035
|
}
|
|
21806
22036
|
async function checkClawHome() {
|
|
21807
22037
|
try {
|
|
21808
|
-
const stat = await fs6.stat(
|
|
22038
|
+
const stat = await fs6.stat(WORKLE_HOME2);
|
|
21809
22039
|
if (stat.isDirectory()) {
|
|
21810
22040
|
return {
|
|
21811
22041
|
name: "Claw home directory",
|
|
21812
22042
|
status: "pass",
|
|
21813
|
-
message:
|
|
22043
|
+
message: WORKLE_HOME2
|
|
21814
22044
|
};
|
|
21815
22045
|
}
|
|
21816
22046
|
return {
|
|
21817
22047
|
name: "Claw home directory",
|
|
21818
22048
|
status: "fail",
|
|
21819
|
-
message: `${
|
|
22049
|
+
message: `${WORKLE_HOME2} exists but is not a directory`
|
|
21820
22050
|
};
|
|
21821
22051
|
} catch {
|
|
21822
22052
|
return {
|
|
21823
22053
|
name: "Claw home directory",
|
|
21824
22054
|
status: "fail",
|
|
21825
|
-
message: `${
|
|
22055
|
+
message: `${WORKLE_HOME2} does not exist. Run 'workle setup'`
|
|
21826
22056
|
};
|
|
21827
22057
|
}
|
|
21828
22058
|
}
|
|
21829
22059
|
async function checkAuthFile() {
|
|
21830
|
-
const authPath = path6.join(
|
|
22060
|
+
const authPath = path6.join(WORKLE_HOME2, "auth.json");
|
|
21831
22061
|
try {
|
|
21832
22062
|
const raw = await fs6.readFile(authPath, "utf-8");
|
|
21833
22063
|
const parsed = JSON.parse(raw);
|
|
@@ -21852,7 +22082,7 @@ async function checkAuthFile() {
|
|
|
21852
22082
|
}
|
|
21853
22083
|
}
|
|
21854
22084
|
async function checkConfigFile() {
|
|
21855
|
-
const configPath = path6.join(
|
|
22085
|
+
const configPath = path6.join(WORKLE_HOME2, "openclaw.json");
|
|
21856
22086
|
try {
|
|
21857
22087
|
const raw = await fs6.readFile(configPath, "utf-8");
|
|
21858
22088
|
const parsed = JSON.parse(raw);
|
|
@@ -21893,7 +22123,7 @@ async function checkGatewayReachable() {
|
|
|
21893
22123
|
return {
|
|
21894
22124
|
name: "OpenClaw gateway",
|
|
21895
22125
|
status: "warn",
|
|
21896
|
-
message: "Not reachable on :18789. Start with 'workle
|
|
22126
|
+
message: "Not reachable on :18789. Start with 'workle start'"
|
|
21897
22127
|
};
|
|
21898
22128
|
}
|
|
21899
22129
|
}
|
|
@@ -21902,30 +22132,30 @@ async function checkGatewayReachable() {
|
|
|
21902
22132
|
import fs7 from "fs/promises";
|
|
21903
22133
|
import os7 from "os";
|
|
21904
22134
|
import path7 from "path";
|
|
21905
|
-
var
|
|
22135
|
+
var WORKLE_HOME3 = path7.join(os7.homedir(), ".workle");
|
|
21906
22136
|
var LAUNCH_AGENTS_DIR = path7.join(os7.homedir(), "Library", "LaunchAgents");
|
|
21907
|
-
var STAGED_CLI_PATH = path7.join(
|
|
22137
|
+
var STAGED_CLI_PATH = path7.join(WORKLE_HOME3, "bin", "cli.js");
|
|
21908
22138
|
function escapeXml(value) {
|
|
21909
22139
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
21910
22140
|
}
|
|
21911
22141
|
async function setupClawDirectory() {
|
|
21912
22142
|
const dirs = [
|
|
21913
|
-
|
|
21914
|
-
path7.join(
|
|
21915
|
-
path7.join(
|
|
22143
|
+
WORKLE_HOME3,
|
|
22144
|
+
path7.join(WORKLE_HOME3, "logs"),
|
|
22145
|
+
path7.join(WORKLE_HOME3, "bin")
|
|
21916
22146
|
];
|
|
21917
22147
|
for (const dir of dirs) {
|
|
21918
22148
|
await fs7.mkdir(dir, { recursive: true, mode: 448 });
|
|
21919
22149
|
await fs7.chmod(dir, 448).catch(() => {
|
|
21920
22150
|
});
|
|
21921
22151
|
}
|
|
21922
|
-
const gitignorePath = path7.join(
|
|
22152
|
+
const gitignorePath = path7.join(WORKLE_HOME3, ".gitignore");
|
|
21923
22153
|
try {
|
|
21924
22154
|
await fs7.access(gitignorePath);
|
|
21925
22155
|
} catch {
|
|
21926
22156
|
await fs7.writeFile(gitignorePath, "*\n", "utf-8");
|
|
21927
22157
|
}
|
|
21928
|
-
console.log(`[claw] Directory structure created at ${
|
|
22158
|
+
console.log(`[claw] Directory structure created at ${WORKLE_HOME3}`);
|
|
21929
22159
|
}
|
|
21930
22160
|
async function stageCliForDaemon(currentCliPath) {
|
|
21931
22161
|
if (!currentCliPath) {
|
|
@@ -21963,13 +22193,13 @@ ${programArguments}
|
|
|
21963
22193
|
</dict>
|
|
21964
22194
|
|
|
21965
22195
|
<key>StandardOutPath</key>
|
|
21966
|
-
<string>${path7.join(
|
|
22196
|
+
<string>${path7.join(WORKLE_HOME3, "logs", "stdout.log")}</string>
|
|
21967
22197
|
|
|
21968
22198
|
<key>StandardErrorPath</key>
|
|
21969
|
-
<string>${path7.join(
|
|
22199
|
+
<string>${path7.join(WORKLE_HOME3, "logs", "stderr.log")}</string>
|
|
21970
22200
|
|
|
21971
22201
|
<key>WorkingDirectory</key>
|
|
21972
|
-
<string>${
|
|
22202
|
+
<string>${WORKLE_HOME3}</string>
|
|
21973
22203
|
|
|
21974
22204
|
<key>ThrottleInterval</key>
|
|
21975
22205
|
<integer>10</integer>
|
|
@@ -21992,13 +22222,13 @@ import path17 from "path";
|
|
|
21992
22222
|
// src/legacy/openclaw/gateway.ts
|
|
21993
22223
|
import os8 from "os";
|
|
21994
22224
|
import path8 from "path";
|
|
21995
|
-
var
|
|
22225
|
+
var CLAW_HOME2 = path8.join(os8.homedir(), ".workle");
|
|
21996
22226
|
function generateGatewayConfig(_instance, agents) {
|
|
21997
22227
|
const sorted = [...agents].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
21998
22228
|
const list = sorted.map((agent) => ({
|
|
21999
22229
|
id: agent.id,
|
|
22000
22230
|
default: !agent.isSubAgent,
|
|
22001
|
-
workspace: path8.join(
|
|
22231
|
+
workspace: path8.join(CLAW_HOME2, `workspace-${agent.agentKey}`),
|
|
22002
22232
|
model: agent.model,
|
|
22003
22233
|
toolProfile: agent.toolProfile,
|
|
22004
22234
|
promptMode: agent.promptMode
|
|
@@ -22012,7 +22242,7 @@ function generateGatewayConfig(_instance, agents) {
|
|
|
22012
22242
|
import fs8 from "fs/promises";
|
|
22013
22243
|
import os9 from "os";
|
|
22014
22244
|
import path9 from "path";
|
|
22015
|
-
var
|
|
22245
|
+
var CLAW_HOME3 = path9.join(os9.homedir(), ".workle");
|
|
22016
22246
|
var DEFAULT_SOUL_MD = `# Soul
|
|
22017
22247
|
|
|
22018
22248
|
You are a Workle agent. Follow your assigned skills and operational instructions.
|
|
@@ -22024,7 +22254,7 @@ async function writeSoulMd(agentKey, content, rpcCall) {
|
|
|
22024
22254
|
await rpcCall(agentKey, "SOUL.md", body);
|
|
22025
22255
|
return;
|
|
22026
22256
|
}
|
|
22027
|
-
const workspaceDir = path9.join(
|
|
22257
|
+
const workspaceDir = path9.join(CLAW_HOME3, `workspace-${agentKey}`);
|
|
22028
22258
|
await fs8.mkdir(workspaceDir, { recursive: true });
|
|
22029
22259
|
const filePath = path9.join(workspaceDir, "SOUL.md");
|
|
22030
22260
|
await fs8.writeFile(filePath, body, "utf-8");
|
|
@@ -22034,7 +22264,7 @@ async function writeSoulMd(agentKey, content, rpcCall) {
|
|
|
22034
22264
|
import fs9 from "fs/promises";
|
|
22035
22265
|
import os10 from "os";
|
|
22036
22266
|
import path10 from "path";
|
|
22037
|
-
var
|
|
22267
|
+
var CLAW_HOME4 = path10.join(os10.homedir(), ".workle");
|
|
22038
22268
|
var DEFAULT_AGENTS_MD = `# Agents
|
|
22039
22269
|
|
|
22040
22270
|
No additional agent configuration provided.
|
|
@@ -22045,7 +22275,7 @@ async function writeAgentsMd(agentKey, content, rpcCall) {
|
|
|
22045
22275
|
await rpcCall(agentKey, "AGENTS.md", body);
|
|
22046
22276
|
return;
|
|
22047
22277
|
}
|
|
22048
|
-
const workspaceDir = path10.join(
|
|
22278
|
+
const workspaceDir = path10.join(CLAW_HOME4, `workspace-${agentKey}`);
|
|
22049
22279
|
await fs9.mkdir(workspaceDir, { recursive: true });
|
|
22050
22280
|
const filePath = path10.join(workspaceDir, "AGENTS.md");
|
|
22051
22281
|
await fs9.writeFile(filePath, body, "utf-8");
|
|
@@ -22055,7 +22285,7 @@ async function writeAgentsMd(agentKey, content, rpcCall) {
|
|
|
22055
22285
|
import fs10 from "fs/promises";
|
|
22056
22286
|
import os11 from "os";
|
|
22057
22287
|
import path11 from "path";
|
|
22058
|
-
var
|
|
22288
|
+
var WORKLE_HOME4 = path11.join(os11.homedir(), ".workle");
|
|
22059
22289
|
var DEFAULT_IDENTITY_MD = `# Identity
|
|
22060
22290
|
|
|
22061
22291
|
No identity configuration provided.
|
|
@@ -22066,7 +22296,7 @@ async function writeIdentityMd(agentKey, content, rpcCall) {
|
|
|
22066
22296
|
await rpcCall(agentKey, "IDENTITY.md", body);
|
|
22067
22297
|
return;
|
|
22068
22298
|
}
|
|
22069
|
-
const workspaceDir = path11.join(
|
|
22299
|
+
const workspaceDir = path11.join(WORKLE_HOME4, `workspace-${agentKey}`);
|
|
22070
22300
|
await fs10.mkdir(workspaceDir, { recursive: true });
|
|
22071
22301
|
const filePath = path11.join(workspaceDir, "IDENTITY.md");
|
|
22072
22302
|
await fs10.writeFile(filePath, body, "utf-8");
|
|
@@ -22076,7 +22306,7 @@ async function writeIdentityMd(agentKey, content, rpcCall) {
|
|
|
22076
22306
|
import fs11 from "fs/promises";
|
|
22077
22307
|
import os12 from "os";
|
|
22078
22308
|
import path12 from "path";
|
|
22079
|
-
var
|
|
22309
|
+
var WORKLE_HOME5 = path12.join(os12.homedir(), ".workle");
|
|
22080
22310
|
var DEFAULT_HEARTBEAT_MD = `# Heartbeat
|
|
22081
22311
|
|
|
22082
22312
|
No heartbeat configuration provided.
|
|
@@ -22087,7 +22317,7 @@ async function writeHeartbeatMd(agentKey, content, rpcCall) {
|
|
|
22087
22317
|
await rpcCall(agentKey, "HEARTBEAT.md", body);
|
|
22088
22318
|
return;
|
|
22089
22319
|
}
|
|
22090
|
-
const workspaceDir = path12.join(
|
|
22320
|
+
const workspaceDir = path12.join(WORKLE_HOME5, `workspace-${agentKey}`);
|
|
22091
22321
|
await fs11.mkdir(workspaceDir, { recursive: true });
|
|
22092
22322
|
const filePath = path12.join(workspaceDir, "HEARTBEAT.md");
|
|
22093
22323
|
await fs11.writeFile(filePath, body, "utf-8");
|
|
@@ -22097,7 +22327,7 @@ async function writeHeartbeatMd(agentKey, content, rpcCall) {
|
|
|
22097
22327
|
import fs12 from "fs/promises";
|
|
22098
22328
|
import os13 from "os";
|
|
22099
22329
|
import path13 from "path";
|
|
22100
|
-
var
|
|
22330
|
+
var WORKLE_HOME6 = path13.join(os13.homedir(), ".workle");
|
|
22101
22331
|
|
|
22102
22332
|
// src/legacy/openclaw/rpc.ts
|
|
22103
22333
|
import crypto4 from "crypto";
|
|
@@ -22113,7 +22343,7 @@ var OPENCLAW_CONFIG_PATHS = [
|
|
|
22113
22343
|
() => path14.join(os14.homedir(), ".openclaw", "openclaw.json"),
|
|
22114
22344
|
() => path14.join(os14.homedir(), ".config", "openclaw", "openclaw.json")
|
|
22115
22345
|
];
|
|
22116
|
-
var CLAW_IDENTITY_DIR = path14.join(os14.homedir(), ".workle
|
|
22346
|
+
var CLAW_IDENTITY_DIR = path14.join(os14.homedir(), ".workle");
|
|
22117
22347
|
var CLAW_IDENTITY_FILE = path14.join(CLAW_IDENTITY_DIR, "device-identity.json");
|
|
22118
22348
|
var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
22119
22349
|
function base64UrlEncode(buf) {
|
|
@@ -22633,7 +22863,7 @@ var MAX_FILE_SIZE = 5e8;
|
|
|
22633
22863
|
var PersistentEventQueue = class {
|
|
22634
22864
|
filePath;
|
|
22635
22865
|
constructor(customPath) {
|
|
22636
|
-
this.filePath = customPath ?? path15.join(os15.homedir(), ".workle
|
|
22866
|
+
this.filePath = customPath ?? path15.join(os15.homedir(), ".workle", "pending-events.jsonl");
|
|
22637
22867
|
}
|
|
22638
22868
|
/**
|
|
22639
22869
|
* Append a single entry to the queue file.
|
|
@@ -22728,7 +22958,7 @@ var PersistentEventQueue = class {
|
|
|
22728
22958
|
};
|
|
22729
22959
|
|
|
22730
22960
|
// src/sync/events.ts
|
|
22731
|
-
var
|
|
22961
|
+
var WORKLE_HOME7 = path16.join(os16.homedir(), ".workle");
|
|
22732
22962
|
var EVENT_TYPE_MAP = {
|
|
22733
22963
|
"agent.run": "agent.started",
|
|
22734
22964
|
"agent.run.complete": "agent.completed",
|
|
@@ -22769,7 +22999,7 @@ function getQueue(instanceId) {
|
|
|
22769
22999
|
const existing = sharedQueues.get(queueKey);
|
|
22770
23000
|
if (existing) return existing;
|
|
22771
23001
|
const queue = new PersistentEventQueue(
|
|
22772
|
-
path16.join(
|
|
23002
|
+
path16.join(WORKLE_HOME7, `pending-events-${queueKey}.jsonl`)
|
|
22773
23003
|
);
|
|
22774
23004
|
sharedQueues.set(queueKey, queue);
|
|
22775
23005
|
return queue;
|
|
@@ -22832,7 +23062,7 @@ async function replayPendingEvents(apiUrl, token, instanceId) {
|
|
|
22832
23062
|
}
|
|
22833
23063
|
|
|
22834
23064
|
// src/sync/service.ts
|
|
22835
|
-
var
|
|
23065
|
+
var WORKLE_HOME8 = path17.join(os17.homedir(), ".workle");
|
|
22836
23066
|
function deriveRelayUrl2(apiUrl) {
|
|
22837
23067
|
const url2 = new URL(apiUrl);
|
|
22838
23068
|
url2.protocol = url2.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -23164,8 +23394,8 @@ var SyncService = class {
|
|
|
23164
23394
|
}
|
|
23165
23395
|
async writeConfigFiles(instance, agents) {
|
|
23166
23396
|
const gatewayConfig = generateGatewayConfig(instance, agents);
|
|
23167
|
-
const configPath = path17.join(
|
|
23168
|
-
await fs15.mkdir(
|
|
23397
|
+
const configPath = path17.join(WORKLE_HOME8, "openclaw.json");
|
|
23398
|
+
await fs15.mkdir(WORKLE_HOME8, { recursive: true });
|
|
23169
23399
|
await fs15.writeFile(configPath, JSON.stringify(gatewayConfig, null, 2), "utf-8");
|
|
23170
23400
|
await Promise.all(
|
|
23171
23401
|
agents.map(async (agent) => {
|
|
@@ -23179,8 +23409,8 @@ var SyncService = class {
|
|
|
23179
23409
|
};
|
|
23180
23410
|
|
|
23181
23411
|
// src/cli.ts
|
|
23182
|
-
var
|
|
23183
|
-
var AUTH_FILE2 = path18.join(
|
|
23412
|
+
var WORKLE_HOME9 = path18.join(os18.homedir(), ".workle");
|
|
23413
|
+
var AUTH_FILE2 = path18.join(WORKLE_HOME9, "auth.json");
|
|
23184
23414
|
var LAUNCH_AGENTS_DIR2 = path18.join(os18.homedir(), "Library", "LaunchAgents");
|
|
23185
23415
|
var PLIST_LABEL = "com.workle.claw";
|
|
23186
23416
|
var color = {
|
|
@@ -23399,7 +23629,7 @@ async function tokenAuth(setupToken, apiUrl) {
|
|
|
23399
23629
|
}
|
|
23400
23630
|
return await res.json();
|
|
23401
23631
|
}
|
|
23402
|
-
var program2 = new Command().name("workle
|
|
23632
|
+
var program2 = new Command().name("workle").description("Workle \u2014 connect your Mac to your Workle org").version(readPkgVersion(), "-v, --version", "Show version");
|
|
23403
23633
|
program2.command("setup").alias("pair").description("Pair this Mac with a Workle instance").option("-t, --token <token>", "Setup token (skip browser, use headless pairing)").option("--api-url <url>", "Override API URL (defaults to https://getworkle.com)").action(async (opts) => {
|
|
23404
23634
|
const apiUrl = opts.apiUrl ?? "https://getworkle.com";
|
|
23405
23635
|
try {
|
|
@@ -23431,7 +23661,7 @@ program2.command("start").description("Start the Workle Claw sync service").opti
|
|
|
23431
23661
|
console.log("");
|
|
23432
23662
|
console.log(` Service: ${color.dim(PLIST_LABEL)}`);
|
|
23433
23663
|
console.log(` Plist: ${color.dim(plistPath)}`);
|
|
23434
|
-
console.log(` Logs: ${color.dim(path18.join(
|
|
23664
|
+
console.log(` Logs: ${color.dim(path18.join(WORKLE_HOME9, "logs/"))}`);
|
|
23435
23665
|
console.log("");
|
|
23436
23666
|
console.log(
|
|
23437
23667
|
`To stop: ${color.cyan("npx @getworkle/cli stop")}`
|
|
@@ -23495,7 +23725,7 @@ program2.command("stop").description("Stop the Workle Claw daemon").action(async
|
|
|
23495
23725
|
} catch {
|
|
23496
23726
|
console.log(color.dim("No launchd service loaded."));
|
|
23497
23727
|
}
|
|
23498
|
-
const pidFile = path18.join(
|
|
23728
|
+
const pidFile = path18.join(WORKLE_HOME9, "openclaw.pid");
|
|
23499
23729
|
try {
|
|
23500
23730
|
const pidStr = await fs16.readFile(pidFile, "utf-8");
|
|
23501
23731
|
const pid = parseInt(pidStr.trim(), 10);
|
|
@@ -23567,8 +23797,8 @@ program2.command("logs").description("Tail the Workle Claw log files").option("-
|
|
|
23567
23797
|
process.exit(1);
|
|
23568
23798
|
}
|
|
23569
23799
|
const logFiles = [
|
|
23570
|
-
path18.join(
|
|
23571
|
-
path18.join(
|
|
23800
|
+
path18.join(WORKLE_HOME9, "openclaw.log"),
|
|
23801
|
+
path18.join(WORKLE_HOME9, "logs", "stderr.log")
|
|
23572
23802
|
];
|
|
23573
23803
|
const args = ["-n", String(lineCount)];
|
|
23574
23804
|
if (opts.follow) args.push("-f");
|
|
@@ -23576,7 +23806,7 @@ program2.command("logs").description("Tail the Workle Claw log files").option("-
|
|
|
23576
23806
|
const result = spawnSync("tail", args, { stdio: "inherit" });
|
|
23577
23807
|
if (result.error && !opts.follow) {
|
|
23578
23808
|
console.error(color.red(`Failed to read logs: ${result.error.message}`));
|
|
23579
|
-
console.error(`Expected log files at: ${
|
|
23809
|
+
console.error(`Expected log files at: ${WORKLE_HOME9}/logs/`);
|
|
23580
23810
|
}
|
|
23581
23811
|
});
|
|
23582
23812
|
var agentCmd = program2.command("agent").description("Manage and run Workle AI agents locally");
|
|
@@ -23732,7 +23962,7 @@ agentCmd.command("logs [agentId]").description("Tail agent run logs").option("-n
|
|
|
23732
23962
|
console.error(color.red("Error: --lines must be a positive integer."));
|
|
23733
23963
|
process.exit(1);
|
|
23734
23964
|
}
|
|
23735
|
-
const logsDir = path18.join(
|
|
23965
|
+
const logsDir = path18.join(WORKLE_HOME9, "agents");
|
|
23736
23966
|
let logFile;
|
|
23737
23967
|
if (agentId) {
|
|
23738
23968
|
logFile = path18.join(logsDir, agentId, "run.log");
|