arc402-cli 0.4.0 → 0.4.2
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/arbitrator.d.ts.map +1 -1
- package/dist/commands/arbitrator.js +62 -13
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena.d.ts.map +1 -1
- package/dist/commands/arena.js +4 -3
- package/dist/commands/arena.js.map +1 -1
- package/dist/commands/cancel.d.ts.map +1 -1
- package/dist/commands/cancel.js +20 -10
- package/dist/commands/cancel.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +1 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/deliver.d.ts.map +1 -1
- package/dist/commands/deliver.js +16 -3
- package/dist/commands/deliver.js.map +1 -1
- package/dist/commands/discover.d.ts.map +1 -1
- package/dist/commands/discover.js +2 -0
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/dispute.d.ts.map +1 -1
- package/dist/commands/dispute.js +11 -10
- package/dist/commands/dispute.js.map +1 -1
- package/dist/commands/hire.d.ts.map +1 -1
- package/dist/commands/hire.js +12 -2
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +29 -29
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/negotiate.d.ts.map +1 -1
- package/dist/commands/negotiate.js +8 -7
- package/dist/commands/negotiate.js.map +1 -1
- package/dist/commands/openshell.d.ts.map +1 -1
- package/dist/commands/openshell.js +6 -5
- package/dist/commands/openshell.js.map +1 -1
- package/dist/commands/owner.d.ts.map +1 -1
- package/dist/commands/owner.js +2 -1
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +22 -10
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.js +6 -5
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.js +3 -2
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.d.ts.map +1 -1
- package/dist/commands/reputation.js +12 -5
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/trust.d.ts.map +1 -1
- package/dist/commands/trust.js +16 -1
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +6 -4
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/commands/wallet.js +202 -165
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watchtower.d.ts.map +1 -1
- package/dist/commands/watchtower.js +30 -13
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/commands/workroom.d.ts.map +1 -1
- package/dist/commands/workroom.js +123 -95
- package/dist/commands/workroom.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/arbitrator.ts +45 -10
- package/src/commands/arena.ts +4 -3
- package/src/commands/cancel.ts +19 -10
- package/src/commands/config.ts +1 -0
- package/src/commands/deliver.ts +16 -3
- package/src/commands/discover.ts +2 -0
- package/src/commands/dispute.ts +12 -10
- package/src/commands/hire.ts +9 -2
- package/src/commands/migrate.ts +28 -26
- package/src/commands/negotiate.ts +8 -7
- package/src/commands/openshell.ts +7 -5
- package/src/commands/owner.ts +2 -1
- package/src/commands/policy.ts +18 -10
- package/src/commands/relay.ts +5 -5
- package/src/commands/remediate.ts +2 -2
- package/src/commands/reputation.ts +9 -5
- package/src/commands/trust.ts +10 -1
- package/src/commands/verify.ts +5 -4
- package/src/commands/wallet.ts +203 -165
- package/src/commands/watchtower.ts +25 -13
- package/src/commands/workroom.ts +121 -95
- package/src/config.ts +2 -1
|
@@ -40,6 +40,8 @@ const http = __importStar(require("http"));
|
|
|
40
40
|
const child_process_1 = require("child_process");
|
|
41
41
|
const openshell_runtime_1 = require("../openshell-runtime");
|
|
42
42
|
const config_1 = require("../daemon/config");
|
|
43
|
+
const colors_1 = require("../ui/colors");
|
|
44
|
+
const tree_1 = require("../ui/tree");
|
|
43
45
|
// ─── Daemon lifecycle notify ──────────────────────────────────────────────────
|
|
44
46
|
function notifyDaemonWorkroomStatus(event, agentAddress, jobId, port = 4402) {
|
|
45
47
|
try {
|
|
@@ -126,75 +128,75 @@ function registerWorkroomCommands(program) {
|
|
|
126
128
|
.command("init")
|
|
127
129
|
.description("Create the ARC-402 Workroom: build Docker image, validate policy, prepare runtime bundle.")
|
|
128
130
|
.action(async () => {
|
|
129
|
-
console.log("ARC-402 Workroom Init");
|
|
130
|
-
console.log("─────────────────────");
|
|
131
|
+
console.log(colors_1.c.brightCyan("ARC-402 Workroom Init"));
|
|
132
|
+
console.log(colors_1.c.dim("─────────────────────"));
|
|
131
133
|
// Check Docker
|
|
132
134
|
if (!dockerAvailable()) {
|
|
133
|
-
console.error("Docker is not available. Install Docker Desktop and try again.");
|
|
135
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Docker is not available. Install Docker Desktop and try again."));
|
|
134
136
|
process.exit(1);
|
|
135
137
|
}
|
|
136
|
-
console.log("
|
|
138
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Docker available"));
|
|
137
139
|
// Check policy file
|
|
138
140
|
if (!fs.existsSync(POLICY_FILE)) {
|
|
139
|
-
console.log("No policy file found. Generating default...");
|
|
141
|
+
console.log(colors_1.c.dim("No policy file found. Generating default..."));
|
|
140
142
|
// Import and call the existing policy generator
|
|
141
143
|
const { registerOpenShellCommands } = require("./openshell");
|
|
142
|
-
console.log(`Policy file will be generated at: ${POLICY_FILE}`);
|
|
143
|
-
console.log("Run 'arc402 workroom policy preset core-launch' after init to apply defaults.");
|
|
144
|
+
console.log(colors_1.c.dim(`Policy file will be generated at: ${POLICY_FILE}`));
|
|
145
|
+
console.log(colors_1.c.dim("Run 'arc402 workroom policy preset core-launch' after init to apply defaults."));
|
|
144
146
|
}
|
|
145
147
|
else {
|
|
146
|
-
console.log(
|
|
148
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(" Policy file: ") + colors_1.c.white(POLICY_FILE));
|
|
147
149
|
}
|
|
148
150
|
// Check daemon.toml
|
|
149
151
|
if (!fs.existsSync(config_1.DAEMON_TOML)) {
|
|
150
|
-
console.error("daemon.toml not found. Run 'arc402 daemon init' first.");
|
|
152
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("daemon.toml not found. Run 'arc402 daemon init' first."));
|
|
151
153
|
process.exit(1);
|
|
152
154
|
}
|
|
153
|
-
console.log("
|
|
155
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" daemon.toml found"));
|
|
154
156
|
// Set up Arena directories and default policy
|
|
155
157
|
if (!fs.existsSync(ARENA_DATA_DIR)) {
|
|
156
158
|
fs.mkdirSync(ARENA_DATA_DIR, { recursive: true });
|
|
157
159
|
for (const sub of ["feed", "profile", "state", "queue"]) {
|
|
158
160
|
fs.mkdirSync(path.join(ARENA_DATA_DIR, sub), { recursive: true });
|
|
159
161
|
}
|
|
160
|
-
console.log("
|
|
162
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Arena directories created"));
|
|
161
163
|
}
|
|
162
164
|
else {
|
|
163
|
-
console.log("
|
|
165
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Arena directories exist"));
|
|
164
166
|
}
|
|
165
167
|
// Copy default arena policy if not present
|
|
166
168
|
if (!fs.existsSync(ARENA_POLICY_FILE)) {
|
|
167
169
|
const defaultArenaPolicy = path.join(WORKROOM_DIR, "arena-policy.yaml");
|
|
168
170
|
if (fs.existsSync(defaultArenaPolicy)) {
|
|
169
171
|
fs.copyFileSync(defaultArenaPolicy, ARENA_POLICY_FILE);
|
|
170
|
-
console.log("
|
|
172
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Arena policy: default installed"));
|
|
171
173
|
}
|
|
172
174
|
else {
|
|
173
|
-
console.log("
|
|
175
|
+
console.log(" " + colors_1.c.warning + " " + colors_1.c.yellow("Arena policy template not found — create manually at " + ARENA_POLICY_FILE));
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
else {
|
|
177
|
-
console.log("
|
|
179
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Arena policy exists"));
|
|
178
180
|
}
|
|
179
181
|
// Build image
|
|
180
182
|
if (!imageExists()) {
|
|
181
183
|
if (!buildImage()) {
|
|
182
|
-
console.error("Failed to build workroom image.");
|
|
184
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Failed to build workroom image."));
|
|
183
185
|
process.exit(1);
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
|
-
console.log(
|
|
188
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(" Image: ") + colors_1.c.white(WORKROOM_IMAGE));
|
|
187
189
|
// Package CLI runtime for the workroom
|
|
188
190
|
const cliDist = path.resolve(__dirname, "..", "..");
|
|
189
191
|
const cliPackage = path.resolve(__dirname, "..", "..", "..", "package.json");
|
|
190
192
|
if (fs.existsSync(cliDist) && fs.existsSync(cliPackage)) {
|
|
191
|
-
console.log("
|
|
193
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" CLI runtime available for workroom mount"));
|
|
192
194
|
}
|
|
193
195
|
else {
|
|
194
|
-
console.warn("
|
|
196
|
+
console.warn(" " + colors_1.c.warning + " " + colors_1.c.yellow("CLI dist not found — workroom will need runtime bundle"));
|
|
195
197
|
}
|
|
196
|
-
console.log("\
|
|
197
|
-
console.log(
|
|
198
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Workroom initialized. Start with: arc402 workroom start"));
|
|
199
|
+
console.log(colors_1.c.dim("Policy hash: ") + colors_1.c.white(getPolicyHash()));
|
|
198
200
|
});
|
|
199
201
|
// ── start ─────────────────────────────────────────────────────────────────
|
|
200
202
|
workroom
|
|
@@ -231,7 +233,7 @@ function registerWorkroomCommands(program) {
|
|
|
231
233
|
}
|
|
232
234
|
// CLI runtime path
|
|
233
235
|
const cliRoot = path.resolve(__dirname, "..", "..", "..");
|
|
234
|
-
console.log("Starting ARC-402 Workroom...");
|
|
236
|
+
console.log(colors_1.c.dim("Starting ARC-402 Workroom..."));
|
|
235
237
|
const args = [
|
|
236
238
|
"run", "-d",
|
|
237
239
|
"--name", WORKROOM_CONTAINER,
|
|
@@ -265,17 +267,19 @@ function registerWorkroomCommands(program) {
|
|
|
265
267
|
// Wait briefly and check health
|
|
266
268
|
(0, child_process_1.spawnSync)("sleep", ["2"]);
|
|
267
269
|
if (containerRunning()) {
|
|
268
|
-
console.log("\n
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" ARC-402 Workroom is running"));
|
|
271
|
+
(0, tree_1.renderTree)([
|
|
272
|
+
{ label: "Container", value: WORKROOM_CONTAINER },
|
|
273
|
+
{ label: "Policy hash", value: getPolicyHash() },
|
|
274
|
+
{ label: "Relay port", value: "4402" },
|
|
275
|
+
{ label: "Logs", value: "arc402 workroom logs", last: true },
|
|
276
|
+
]);
|
|
273
277
|
// Notify local daemon of workroom entry
|
|
274
278
|
notifyDaemonWorkroomStatus("entered");
|
|
275
279
|
}
|
|
276
280
|
else {
|
|
277
|
-
console.error("Workroom started but exited immediately. Check logs:");
|
|
278
|
-
console.error(" docker logs arc402-workroom");
|
|
281
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Workroom started but exited immediately. Check logs:"));
|
|
282
|
+
console.error(colors_1.c.dim(" docker logs arc402-workroom"));
|
|
279
283
|
process.exit(1);
|
|
280
284
|
}
|
|
281
285
|
});
|
|
@@ -288,30 +292,35 @@ function registerWorkroomCommands(program) {
|
|
|
288
292
|
console.log("Workroom is not running.");
|
|
289
293
|
return;
|
|
290
294
|
}
|
|
291
|
-
console.log("Stopping ARC-402 Workroom...");
|
|
295
|
+
console.log(colors_1.c.dim("Stopping ARC-402 Workroom..."));
|
|
292
296
|
// Notify daemon before stopping (daemon may be inside container)
|
|
293
297
|
notifyDaemonWorkroomStatus("exited");
|
|
294
298
|
(0, openshell_runtime_1.runCmd)("docker", ["stop", WORKROOM_CONTAINER]);
|
|
295
|
-
console.log("
|
|
299
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Workroom stopped"));
|
|
296
300
|
});
|
|
297
301
|
// ── status ────────────────────────────────────────────────────────────────
|
|
298
302
|
workroom
|
|
299
303
|
.command("status")
|
|
300
304
|
.description("Show ARC-402 Workroom health, policy, and active state.")
|
|
301
305
|
.action(async () => {
|
|
302
|
-
console.log("ARC-402 Workroom Status");
|
|
303
|
-
console.log("───────────────────────");
|
|
306
|
+
console.log(colors_1.c.brightCyan("ARC-402 Workroom Status"));
|
|
307
|
+
console.log(colors_1.c.dim("───────────────────────"));
|
|
304
308
|
// Docker
|
|
305
309
|
if (!dockerAvailable()) {
|
|
306
|
-
console.log("Docker:
|
|
310
|
+
console.log(colors_1.c.dim("Docker: ") + colors_1.c.failure + " " + colors_1.c.red("not available"));
|
|
307
311
|
return;
|
|
308
312
|
}
|
|
309
|
-
console.log("Docker:
|
|
313
|
+
console.log(colors_1.c.dim("Docker: ") + colors_1.c.success + colors_1.c.white(" available"));
|
|
310
314
|
// Image
|
|
311
|
-
|
|
315
|
+
if (imageExists()) {
|
|
316
|
+
console.log(colors_1.c.dim("Image: ") + colors_1.c.success + " " + colors_1.c.white(WORKROOM_IMAGE));
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
console.log(colors_1.c.dim("Image: ") + colors_1.c.failure + " " + colors_1.c.red("not built (run: arc402 workroom init)"));
|
|
320
|
+
}
|
|
312
321
|
// Container
|
|
313
322
|
if (containerRunning()) {
|
|
314
|
-
console.log(
|
|
323
|
+
console.log(colors_1.c.dim("Container: ") + colors_1.c.success + colors_1.c.white(` running (${WORKROOM_CONTAINER})`));
|
|
315
324
|
// Get container uptime
|
|
316
325
|
const inspect = (0, openshell_runtime_1.runCmd)("docker", ["inspect", WORKROOM_CONTAINER, "--format", "{{.State.StartedAt}}"]);
|
|
317
326
|
if (inspect.ok) {
|
|
@@ -319,39 +328,49 @@ function registerWorkroomCommands(program) {
|
|
|
319
328
|
const uptime = Math.floor((Date.now() - started.getTime()) / 1000);
|
|
320
329
|
const h = Math.floor(uptime / 3600);
|
|
321
330
|
const m = Math.floor((uptime % 3600) / 60);
|
|
322
|
-
console.log(
|
|
331
|
+
console.log(colors_1.c.dim("Uptime: ") + colors_1.c.white(`${h}h ${m}m`));
|
|
323
332
|
}
|
|
324
333
|
// Get iptables rule count from inside container
|
|
325
334
|
const rules = (0, openshell_runtime_1.runCmd)("docker", ["exec", WORKROOM_CONTAINER, "iptables", "-L", "OUTPUT", "-n", "--line-numbers"]);
|
|
326
335
|
if (rules.ok) {
|
|
327
336
|
const ruleCount = rules.stdout.split("\n").filter(l => l.match(/^\d+/)).length;
|
|
328
|
-
console.log(
|
|
337
|
+
console.log(colors_1.c.dim("Network rules: ") + colors_1.c.white(`${ruleCount} iptables rules enforced`));
|
|
329
338
|
}
|
|
330
339
|
}
|
|
331
340
|
else if (containerExists()) {
|
|
332
|
-
console.log(
|
|
341
|
+
console.log(colors_1.c.dim("Container: ") + colors_1.c.warning + " " + colors_1.c.yellow("stopped (run: arc402 workroom start)"));
|
|
333
342
|
}
|
|
334
343
|
else {
|
|
335
|
-
console.log(
|
|
344
|
+
console.log(colors_1.c.dim("Container: ") + colors_1.c.failure + " " + colors_1.c.red("not created (run: arc402 workroom init)"));
|
|
336
345
|
}
|
|
337
346
|
// Policy
|
|
338
|
-
|
|
339
|
-
|
|
347
|
+
if (fs.existsSync(POLICY_FILE)) {
|
|
348
|
+
console.log(colors_1.c.dim("Policy file: ") + colors_1.c.success + " " + colors_1.c.white(POLICY_FILE));
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
console.log(colors_1.c.dim("Policy file: ") + colors_1.c.failure + " " + colors_1.c.red("missing"));
|
|
352
|
+
}
|
|
353
|
+
console.log(colors_1.c.dim("Policy hash: ") + colors_1.c.white(getPolicyHash()));
|
|
340
354
|
// Arena
|
|
341
355
|
const arenaExists = fs.existsSync(ARENA_DATA_DIR);
|
|
342
356
|
const arenaPolicy = fs.existsSync(ARENA_POLICY_FILE);
|
|
343
|
-
|
|
344
|
-
|
|
357
|
+
if (arenaExists) {
|
|
358
|
+
console.log(colors_1.c.dim("Arena data: ") + colors_1.c.success + " " + colors_1.c.white(ARENA_DATA_DIR));
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
console.log(colors_1.c.dim("Arena data: ") + colors_1.c.failure + " " + colors_1.c.red("missing (run: arc402 workroom init)"));
|
|
362
|
+
}
|
|
363
|
+
console.log(colors_1.c.dim("Arena policy: ") + (arenaPolicy ? colors_1.c.success + colors_1.c.white(" loaded") : colors_1.c.failure + " " + colors_1.c.red("missing")));
|
|
345
364
|
// Arena queue (pending approvals)
|
|
346
365
|
if (arenaExists) {
|
|
347
366
|
const queueDir = path.join(ARENA_DATA_DIR, "queue");
|
|
348
367
|
if (fs.existsSync(queueDir)) {
|
|
349
368
|
const pending = fs.readdirSync(queueDir).filter(f => f.endsWith(".json")).length;
|
|
350
369
|
if (pending > 0) {
|
|
351
|
-
console.log(
|
|
370
|
+
console.log(colors_1.c.dim("Arena queue: ") + colors_1.c.warning + " " + colors_1.c.yellow(`${pending} action(s) awaiting approval`));
|
|
352
371
|
}
|
|
353
372
|
else {
|
|
354
|
-
console.log(
|
|
373
|
+
console.log(colors_1.c.dim("Arena queue: ") + colors_1.c.success + colors_1.c.white(" empty"));
|
|
355
374
|
}
|
|
356
375
|
}
|
|
357
376
|
}
|
|
@@ -388,8 +407,8 @@ function registerWorkroomCommands(program) {
|
|
|
388
407
|
.command("doctor")
|
|
389
408
|
.description("Diagnose workroom health: Docker, image, container, network, policy, daemon.")
|
|
390
409
|
.action(async () => {
|
|
391
|
-
console.log("ARC-402 Workroom Doctor");
|
|
392
|
-
console.log("───────────────────────");
|
|
410
|
+
console.log(colors_1.c.brightCyan("ARC-402 Workroom Doctor"));
|
|
411
|
+
console.log(colors_1.c.dim("───────────────────────"));
|
|
393
412
|
const checks = [];
|
|
394
413
|
// Docker
|
|
395
414
|
const docker = dockerAvailable();
|
|
@@ -416,17 +435,20 @@ function registerWorkroomCommands(program) {
|
|
|
416
435
|
checks.push({ label: "Base RPC from workroom", pass: rpcOk, detail: rpcOk ? `HTTP ${rpcTest.stdout.trim()}` : "FAILED — network policy may be blocking RPC" });
|
|
417
436
|
}
|
|
418
437
|
// Print results
|
|
419
|
-
for (const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
438
|
+
for (const chk of checks) {
|
|
439
|
+
if (chk.pass) {
|
|
440
|
+
console.log(" " + colors_1.c.success + " " + colors_1.c.dim(chk.label + ":") + " " + colors_1.c.white(chk.detail));
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
console.log(" " + colors_1.c.failure + " " + colors_1.c.dim(chk.label + ":") + " " + colors_1.c.red(chk.detail) + colors_1.c.yellow(" ← FIX"));
|
|
444
|
+
}
|
|
423
445
|
}
|
|
424
|
-
const failures = checks.filter(
|
|
446
|
+
const failures = checks.filter(chk => !chk.pass);
|
|
425
447
|
if (failures.length === 0) {
|
|
426
|
-
console.log("\n
|
|
448
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" All checks passed. Workroom is healthy."));
|
|
427
449
|
}
|
|
428
450
|
else {
|
|
429
|
-
console.log(
|
|
451
|
+
console.log("\n" + colors_1.c.failure + " " + colors_1.c.red(`${failures.length} issue(s) found.`));
|
|
430
452
|
}
|
|
431
453
|
});
|
|
432
454
|
// ── policy (delegate to existing openshell policy commands) ───────────────
|
|
@@ -459,19 +481,19 @@ function registerWorkroomCommands(program) {
|
|
|
459
481
|
console.error("Workroom is not running. Start it first: arc402 workroom start");
|
|
460
482
|
process.exit(1);
|
|
461
483
|
}
|
|
462
|
-
console.log(`Testing connectivity to ${host} from inside workroom...`);
|
|
484
|
+
console.log(colors_1.c.dim(`Testing connectivity to ${host} from inside workroom...`));
|
|
463
485
|
const result = (0, openshell_runtime_1.runCmd)("docker", [
|
|
464
486
|
"exec", WORKROOM_CONTAINER,
|
|
465
487
|
"curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", "--max-time", "5",
|
|
466
488
|
`https://${host}`,
|
|
467
489
|
]);
|
|
468
490
|
if (result.ok && result.stdout.trim() !== "000") {
|
|
469
|
-
console.log(
|
|
491
|
+
console.log(" " + colors_1.c.success + " " + colors_1.c.white(host) + colors_1.c.dim(` is reachable (HTTP ${result.stdout.trim()})`));
|
|
470
492
|
}
|
|
471
493
|
else {
|
|
472
|
-
console.log(
|
|
473
|
-
console.log(" This host may not be in the workroom policy.");
|
|
474
|
-
console.log(" Add it with: arc402 openshell policy add <name> <host>");
|
|
494
|
+
console.log(" " + colors_1.c.failure + " " + colors_1.c.red(`${host} is NOT reachable from the workroom`));
|
|
495
|
+
console.log(colors_1.c.dim(" This host may not be in the workroom policy."));
|
|
496
|
+
console.log(colors_1.c.dim(" Add it with: arc402 openshell policy add <name> <host>"));
|
|
475
497
|
}
|
|
476
498
|
});
|
|
477
499
|
// ── worker ─────────────────────────────────────────────────────────────────
|
|
@@ -527,10 +549,10 @@ Write these learnings concisely. They will be available on your next job.
|
|
|
527
549
|
- If the task is unclear, produce the best interpretation and document assumptions
|
|
528
550
|
- Every deliverable must be verifiable against the task spec
|
|
529
551
|
`);
|
|
530
|
-
console.log(
|
|
552
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Worker SOUL.md created: ${soulPath}`));
|
|
531
553
|
}
|
|
532
554
|
else {
|
|
533
|
-
console.log(
|
|
555
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Worker SOUL.md already exists: ${soulPath}`));
|
|
534
556
|
}
|
|
535
557
|
// Generate default MEMORY.md
|
|
536
558
|
const memoryPath = path.join(workerDir, "MEMORY.md");
|
|
@@ -546,7 +568,7 @@ Write these learnings concisely. They will be available on your next job.
|
|
|
546
568
|
|
|
547
569
|
No jobs completed yet. Learnings will accumulate here as the worker completes hired tasks.
|
|
548
570
|
`);
|
|
549
|
-
console.log(
|
|
571
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Worker MEMORY.md created: ${memoryPath}`));
|
|
550
572
|
}
|
|
551
573
|
// Generate learnings.md
|
|
552
574
|
const learningsPath = path.join(memoryDir, "learnings.md");
|
|
@@ -559,7 +581,7 @@ No jobs completed yet. Learnings will accumulate here as the worker completes hi
|
|
|
559
581
|
|
|
560
582
|
No learnings yet. Complete your first hired task to start accumulating expertise.
|
|
561
583
|
`);
|
|
562
|
-
console.log(
|
|
584
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Learnings file created: ${learningsPath}`));
|
|
563
585
|
}
|
|
564
586
|
// Worker config
|
|
565
587
|
const configPath = path.join(workerDir, "config.json");
|
|
@@ -573,12 +595,12 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
573
595
|
total_earned_eth: "0",
|
|
574
596
|
};
|
|
575
597
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
576
|
-
console.log(
|
|
598
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Worker config created: ${configPath}`));
|
|
577
599
|
}
|
|
578
|
-
console.log(
|
|
579
|
-
console.log("Next: customize the worker SOUL.md and add skills.");
|
|
580
|
-
console.log(" arc402 workroom worker set-soul <file>");
|
|
581
|
-
console.log(" arc402 workroom worker set-skills <dir>");
|
|
600
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Worker initialized at: ${workerDir}`));
|
|
601
|
+
console.log(colors_1.c.dim("Next: customize the worker SOUL.md and add skills."));
|
|
602
|
+
console.log(colors_1.c.dim(" arc402 workroom worker set-soul <file>"));
|
|
603
|
+
console.log(colors_1.c.dim(" arc402 workroom worker set-skills <dir>"));
|
|
582
604
|
});
|
|
583
605
|
worker
|
|
584
606
|
.command("status")
|
|
@@ -603,16 +625,18 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
603
625
|
const skillCount = fs.existsSync(skillsDir)
|
|
604
626
|
? fs.readdirSync(skillsDir).length
|
|
605
627
|
: 0;
|
|
606
|
-
console.log("ARC-402 Workroom Worker");
|
|
607
|
-
console.log("───────────────────────");
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
628
|
+
console.log(colors_1.c.brightCyan("ARC-402 Workroom Worker"));
|
|
629
|
+
console.log(colors_1.c.dim("───────────────────────"));
|
|
630
|
+
(0, tree_1.renderTree)([
|
|
631
|
+
{ label: "Name", value: config.name },
|
|
632
|
+
{ label: "Model", value: config.model },
|
|
633
|
+
{ label: "Created", value: config.created },
|
|
634
|
+
{ label: "Jobs done", value: String(config.job_count) },
|
|
635
|
+
{ label: "Job memories", value: String(jobFiles) },
|
|
636
|
+
{ label: "Learnings", value: learningsSize > 200 ? Math.round(learningsSize / 1024) + " KB" : "empty" },
|
|
637
|
+
{ label: "Skills", value: String(skillCount) },
|
|
638
|
+
{ label: "Total earned", value: config.total_earned_eth + " ETH", last: true },
|
|
639
|
+
]);
|
|
616
640
|
});
|
|
617
641
|
worker
|
|
618
642
|
.command("set-soul <file>")
|
|
@@ -625,7 +649,7 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
625
649
|
const dest = path.join(openshell_runtime_1.ARC402_DIR, "worker", "SOUL.md");
|
|
626
650
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
627
651
|
fs.copyFileSync(file, dest);
|
|
628
|
-
console.log(
|
|
652
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(` Worker SOUL.md updated from: ${file}`));
|
|
629
653
|
});
|
|
630
654
|
worker
|
|
631
655
|
.command("set-skills <dir>")
|
|
@@ -650,7 +674,7 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
650
674
|
fs.cpSync(src, dst, { recursive: true });
|
|
651
675
|
}
|
|
652
676
|
}
|
|
653
|
-
console.log(
|
|
677
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(` ${files.length} items copied to worker skills`));
|
|
654
678
|
});
|
|
655
679
|
worker
|
|
656
680
|
.command("set-knowledge <dir>")
|
|
@@ -676,10 +700,10 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
676
700
|
count++;
|
|
677
701
|
}
|
|
678
702
|
}
|
|
679
|
-
console.log(
|
|
680
|
-
console.log(
|
|
681
|
-
console.log(
|
|
682
|
-
console.log(
|
|
703
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(` ${count} items copied to worker knowledge`));
|
|
704
|
+
console.log(" " + colors_1.c.dim("Path:") + " " + colors_1.c.white(dest));
|
|
705
|
+
console.log(colors_1.c.dim(" The worker can reference these files during hired tasks."));
|
|
706
|
+
console.log(colors_1.c.dim(" To update: run this command again with the updated directory."));
|
|
683
707
|
});
|
|
684
708
|
worker
|
|
685
709
|
.command("knowledge")
|
|
@@ -731,7 +755,7 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
731
755
|
config.job_count = 0;
|
|
732
756
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
733
757
|
}
|
|
734
|
-
console.log("
|
|
758
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Worker memory cleared. Starting fresh."));
|
|
735
759
|
});
|
|
736
760
|
// ── token usage ──────────────────────────────────────────────────────────
|
|
737
761
|
workroom
|
|
@@ -836,14 +860,18 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
836
860
|
return;
|
|
837
861
|
}
|
|
838
862
|
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
839
|
-
console.log("ARC-402 Earnings");
|
|
840
|
-
console.log("────────────────");
|
|
841
|
-
|
|
842
|
-
|
|
863
|
+
console.log(colors_1.c.brightCyan("ARC-402 Earnings"));
|
|
864
|
+
console.log(colors_1.c.dim("────────────────"));
|
|
865
|
+
const earningsItems = [
|
|
866
|
+
{ label: "Total earned", value: config.total_earned_eth + " ETH" },
|
|
867
|
+
{ label: "Jobs completed", value: String(config.job_count) },
|
|
868
|
+
];
|
|
843
869
|
if (config.job_count > 0) {
|
|
844
870
|
const avg = (parseFloat(config.total_earned_eth) / config.job_count).toFixed(6);
|
|
845
|
-
|
|
871
|
+
earningsItems.push({ label: "Average/job", value: avg + " ETH" });
|
|
846
872
|
}
|
|
873
|
+
earningsItems[earningsItems.length - 1].last = true;
|
|
874
|
+
(0, tree_1.renderTree)(earningsItems);
|
|
847
875
|
});
|
|
848
876
|
workroom
|
|
849
877
|
.command("history")
|
|
@@ -875,17 +903,17 @@ No learnings yet. Complete your first hired task to start accumulating expertise
|
|
|
875
903
|
console.error("Workroom is not running.");
|
|
876
904
|
process.exit(1);
|
|
877
905
|
}
|
|
878
|
-
console.log("Reloading workroom policy...");
|
|
906
|
+
console.log(colors_1.c.dim("Reloading workroom policy..."));
|
|
879
907
|
// Trigger DNS refresh manually (which re-reads policy and updates iptables)
|
|
880
908
|
const result = (0, openshell_runtime_1.runCmd)("docker", [
|
|
881
909
|
"exec", WORKROOM_CONTAINER,
|
|
882
910
|
"bash", "-c", "/dns-refresh.sh /workroom/.arc402/openshell-policy.yaml &",
|
|
883
911
|
]);
|
|
884
912
|
if (result.ok) {
|
|
885
|
-
console.log("
|
|
913
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Policy reload triggered"));
|
|
886
914
|
}
|
|
887
915
|
else {
|
|
888
|
-
console.error("Failed to reload policy");
|
|
916
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Failed to reload policy"));
|
|
889
917
|
}
|
|
890
918
|
});
|
|
891
919
|
}
|