@simonfestl/husky-cli 1.25.3 → 1.26.0
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/commands/auth.js +9 -47
- package/dist/commands/business.d.ts +2 -0
- package/dist/commands/business.js +865 -0
- package/dist/commands/config.js +33 -45
- package/dist/commands/interactive/business.js +3 -0
- package/dist/commands/interactive/infra.js +3 -0
- package/dist/commands/interactive/pr.js +5 -0
- package/dist/commands/interactive/tasks.js +5 -0
- package/dist/commands/interactive/vm-sessions.js +9 -0
- package/dist/commands/task.js +90 -293
- package/dist/index.js +2 -0
- package/dist/lib/worker.d.ts +3 -3
- package/dist/lib/worker.js +37 -39
- package/package.json +3 -1
package/dist/lib/worker.js
CHANGED
|
@@ -4,6 +4,7 @@ import { randomUUID } from "crypto";
|
|
|
4
4
|
import { readFileSync } from "fs";
|
|
5
5
|
import { join, dirname } from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
+
import { getApiClient } from "./api-client.js";
|
|
7
8
|
// Get or generate persistent worker identity (stored in ~/.husky/config.json)
|
|
8
9
|
export function getWorkerIdentity() {
|
|
9
10
|
const config = getConfig();
|
|
@@ -43,55 +44,54 @@ export function generateSessionId() {
|
|
|
43
44
|
return `sess-${randomUUID().slice(0, 8)}`;
|
|
44
45
|
}
|
|
45
46
|
// Register or update worker with API, return workerId
|
|
46
|
-
|
|
47
|
+
// Note: apiUrl and apiKey parameters kept for backwards compatibility but not used
|
|
48
|
+
export async function ensureWorkerRegistered(_apiUrl, _apiKey) {
|
|
47
49
|
const identity = getWorkerIdentity();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (getRes.ok) {
|
|
50
|
+
const api = getApiClient();
|
|
51
|
+
try {
|
|
52
|
+
// Try to get existing worker
|
|
53
|
+
await api.get(`/api/workers/${identity.workerId}`);
|
|
53
54
|
// Worker exists, just return the ID
|
|
54
55
|
return identity.workerId;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
|
|
61
|
-
body: JSON.stringify({
|
|
62
|
-
name: identity.workerName,
|
|
63
|
-
type: "claude-code",
|
|
64
|
-
hostname: identity.hostname,
|
|
65
|
-
username: identity.username,
|
|
66
|
-
platform: identity.platform,
|
|
67
|
-
agentVersion: identity.agentVersion,
|
|
68
|
-
}),
|
|
69
|
-
});
|
|
70
|
-
if (!registerRes.ok) {
|
|
71
|
-
console.error(`Warning: Failed to register worker: ${registerRes.status}`);
|
|
57
|
+
catch (error) {
|
|
58
|
+
const errorMsg = error instanceof Error ? error.message : "";
|
|
59
|
+
if (!errorMsg.includes("404")) {
|
|
60
|
+
// Unexpected error, return local ID
|
|
72
61
|
return identity.workerId;
|
|
73
62
|
}
|
|
74
|
-
|
|
63
|
+
}
|
|
64
|
+
// Worker not found (404), register new worker
|
|
65
|
+
try {
|
|
66
|
+
const worker = await api.post("/api/workers", {
|
|
67
|
+
name: identity.workerName,
|
|
68
|
+
type: "claude-code",
|
|
69
|
+
hostname: identity.hostname,
|
|
70
|
+
username: identity.username,
|
|
71
|
+
platform: identity.platform,
|
|
72
|
+
agentVersion: identity.agentVersion,
|
|
73
|
+
});
|
|
75
74
|
// Update local config with server-assigned ID if different
|
|
76
75
|
if (worker.id !== identity.workerId) {
|
|
77
76
|
setConfig("workerId", worker.id);
|
|
78
77
|
return worker.id;
|
|
79
78
|
}
|
|
80
79
|
}
|
|
80
|
+
catch {
|
|
81
|
+
console.error("Warning: Failed to register worker");
|
|
82
|
+
}
|
|
81
83
|
return identity.workerId;
|
|
82
84
|
}
|
|
83
85
|
// Register a new session with API
|
|
84
|
-
|
|
86
|
+
// Note: apiUrl and apiKey parameters kept for backwards compatibility but not used
|
|
87
|
+
export async function registerSession(_apiUrl, _apiKey, workerId, sessionId) {
|
|
85
88
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
pid: process.pid,
|
|
93
|
-
workingDirectory: process.cwd(),
|
|
94
|
-
}),
|
|
89
|
+
const api = getApiClient();
|
|
90
|
+
await api.post("/api/workers/sessions", {
|
|
91
|
+
id: sessionId,
|
|
92
|
+
workerId,
|
|
93
|
+
pid: process.pid,
|
|
94
|
+
workingDirectory: process.cwd(),
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
catch {
|
|
@@ -99,13 +99,11 @@ export async function registerSession(apiUrl, apiKey, workerId, sessionId) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
// Send session heartbeat
|
|
102
|
-
|
|
102
|
+
// Note: apiUrl and apiKey parameters kept for backwards compatibility but not used
|
|
103
|
+
export async function sessionHeartbeat(_apiUrl, _apiKey, sessionId, currentTaskId) {
|
|
103
104
|
try {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
|
|
107
|
-
body: JSON.stringify({ currentTaskId }),
|
|
108
|
-
});
|
|
105
|
+
const api = getApiClient();
|
|
106
|
+
await api.post(`/api/workers/sessions/${sessionId}/heartbeat`, { currentTaskId });
|
|
109
107
|
}
|
|
110
108
|
catch {
|
|
111
109
|
// Silently fail
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonfestl/husky-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "CLI for Huskyv0 Task Orchestration with Claude Agent SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"@google/generative-ai": "^0.24.1",
|
|
26
26
|
"@inquirer/prompts": "^8.1.0",
|
|
27
27
|
"@types/uuid": "^10.0.0",
|
|
28
|
+
"chalk": "^5.6.2",
|
|
29
|
+
"cli-table3": "^0.6.5",
|
|
28
30
|
"commander": "^12.1.0",
|
|
29
31
|
"firebase-admin": "^13.6.0",
|
|
30
32
|
"playwright": "^1.57.0",
|