cnagent 2.2.8 → 2.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tools/dist/cn.js +168 -7
package/package.json
CHANGED
package/tools/dist/cn.js
CHANGED
|
@@ -12071,18 +12071,38 @@ var require_cn_lib = __commonJS({
|
|
|
12071
12071
|
/* '|' */
|
|
12072
12072
|
124
|
|
12073
12073
|
);
|
|
12074
|
-
if (i$4
|
|
12074
|
+
if (i$4 === void 0) {
|
|
12075
|
+
return;
|
|
12076
|
+
}
|
|
12077
|
+
const peer = Stdlib__String2.sub(value, 0, i$4);
|
|
12078
|
+
const rest = Stdlib__String2.sub(value, i$4 + 1 | 0, (value.length - i$4 | 0) - 1 | 0);
|
|
12079
|
+
const j = Stdlib__String2.index_opt(
|
|
12080
|
+
rest,
|
|
12081
|
+
/* '|' */
|
|
12082
|
+
124
|
|
12083
|
+
);
|
|
12084
|
+
if (j === void 0) {
|
|
12075
12085
|
return {
|
|
12076
12086
|
TAG: (
|
|
12077
12087
|
/* Send */
|
|
12078
12088
|
4
|
|
12079
12089
|
),
|
|
12080
|
-
_0:
|
|
12081
|
-
_1:
|
|
12090
|
+
_0: peer,
|
|
12091
|
+
_1: rest,
|
|
12092
|
+
_2: void 0
|
|
12082
12093
|
};
|
|
12083
|
-
} else {
|
|
12084
|
-
return;
|
|
12085
12094
|
}
|
|
12095
|
+
const message = Stdlib__String2.sub(rest, 0, j);
|
|
12096
|
+
const body = Stdlib__String2.sub(rest, j + 1 | 0, (rest.length - j | 0) - 1 | 0);
|
|
12097
|
+
return {
|
|
12098
|
+
TAG: (
|
|
12099
|
+
/* Send */
|
|
12100
|
+
4
|
|
12101
|
+
),
|
|
12102
|
+
_0: peer,
|
|
12103
|
+
_1: message,
|
|
12104
|
+
_2: body
|
|
12105
|
+
};
|
|
12086
12106
|
case "mca":
|
|
12087
12107
|
case "surface":
|
|
12088
12108
|
return {
|
|
@@ -13598,7 +13618,7 @@ var require_cn_lib = __commonJS({
|
|
|
13598
13618
|
);
|
|
13599
13619
|
}
|
|
13600
13620
|
var help_text = "cn - Coherent Network agent CLI\n\nUsage: cn <command> [options]\n\nCommands:\n # Agent decisions (output)\n delete <thread> GTD: discard\n defer <thread> GTD: postpone\n delegate <t> <peer> GTD: forward\n do <thread> GTD: claim/start\n done <thread> GTD: complete \xE2\x86\x92 archive\n reply <thread> <msg> Append to thread\n send <peer> <msg> Message to peer (or self)\n \n # cn operations (orchestrator)\n sync Fetch inbound + send outbound\n in Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent (alias: inbound, process)\n queue [list|clear] View or clear the task queue\n mca [list|add <desc>] Surface MCAs for community pickup\n inbox List inbox threads\n outbox List outbox threads\n next Get next inbox item (with cadence)\n read <thread> Read thread with cadence\n \n # Hub management\n init [name] Create new hub\n status Show hub state\n commit [msg] Stage + commit\n push Push to origin\n save [msg] Commit + push\n peer Manage peers\n doctor Health check\n update Update cn to latest version\n\nAliases:\n i = inbox, o = outbox, s = status, d = doctor\n\nFlags:\n --help, -h Show help\n --version, -V Show version\n --json Machine-readable output\n --quiet, -q Minimal output\n --dry-run Show what would happen\n\nActor Model:\n cn runs on cron (every 5 min). It:\n 1. Syncs peers \xE2\x86\x92 queues new inbox items to state/queue/\n 2. If input.md empty \xE2\x86\x92 pops from queue \xE2\x86\x92 writes input.md \xE2\x86\x92 wakes agent\n Agent reads input.md, processes, deletes when done.\n";
|
|
13601
|
-
var version = "2.2.
|
|
13621
|
+
var version = "2.2.10";
|
|
13602
13622
|
module2.exports = {
|
|
13603
13623
|
starts_with,
|
|
13604
13624
|
strip_prefix,
|
|
@@ -30792,6 +30812,7 @@ function execute_op(hub_path, name, input_id, op) {
|
|
|
30792
30812
|
return;
|
|
30793
30813
|
case /* Send */
|
|
30794
30814
|
4:
|
|
30815
|
+
const body_opt = op._2;
|
|
30795
30816
|
const msg$5 = op._1;
|
|
30796
30817
|
const peer = op._0;
|
|
30797
30818
|
const outbox_dir = Path.join(hub_path, "threads/outbox");
|
|
@@ -30804,6 +30825,7 @@ function execute_op(hub_path, name, input_id, op) {
|
|
|
30804
30825
|
msg$5
|
|
30805
30826
|
);
|
|
30806
30827
|
const first_line = match2 ? match2.hd : msg$5;
|
|
30828
|
+
const body = body_opt !== void 0 ? body_opt : msg$5;
|
|
30807
30829
|
const content = Curry._5(Stdlib__Printf.sprintf({
|
|
30808
30830
|
TAG: (
|
|
30809
30831
|
/* Format */
|
|
@@ -30909,7 +30931,7 @@ function execute_op(hub_path, name, input_id, op) {
|
|
|
30909
30931
|
}
|
|
30910
30932
|
},
|
|
30911
30933
|
_1: "---\nto: %s\ncreated: %s\nfrom: %s\n---\n\n# %s\n\n%s\n"
|
|
30912
|
-
}), peer, (/* @__PURE__ */ new Date()).toISOString(), name, first_line,
|
|
30934
|
+
}), peer, (/* @__PURE__ */ new Date()).toISOString(), name, first_line, body);
|
|
30913
30935
|
const prim0 = Path.join(outbox_dir, file_name);
|
|
30914
30936
|
Fs.writeFileSync(prim0, content);
|
|
30915
30937
|
log_action(hub_path, "op.send", Curry._2(Stdlib__Printf.sprintf({
|
|
@@ -36259,6 +36281,143 @@ function run_update_with_cron(hub_path) {
|
|
|
36259
36281
|
}
|
|
36260
36282
|
console.log(color("2", "No runtime changes to commit"));
|
|
36261
36283
|
}
|
|
36284
|
+
function self_update_check(param) {
|
|
36285
|
+
const args2 = Stdlib__Array.to_list(process.argv);
|
|
36286
|
+
const is_skip_cmd = Stdlib__List.exists((function(a) {
|
|
36287
|
+
if (a === "--help" || a === "-h" || a === "--version" || a === "-V") {
|
|
36288
|
+
return true;
|
|
36289
|
+
} else {
|
|
36290
|
+
return a === "help";
|
|
36291
|
+
}
|
|
36292
|
+
}), args2);
|
|
36293
|
+
if (is_skip_cmd) {
|
|
36294
|
+
return;
|
|
36295
|
+
}
|
|
36296
|
+
const latest_raw = exec("npm view cnagent version --fetch-timeout=5000 2>/dev/null");
|
|
36297
|
+
if (latest_raw === void 0) {
|
|
36298
|
+
return;
|
|
36299
|
+
}
|
|
36300
|
+
const latest = Stdlib__String.trim(latest_raw);
|
|
36301
|
+
if (!(latest !== Cn_lib.version && latest !== "")) {
|
|
36302
|
+
return;
|
|
36303
|
+
}
|
|
36304
|
+
console.log(color("36", Curry._2(Stdlib__Printf.sprintf({
|
|
36305
|
+
TAG: (
|
|
36306
|
+
/* Format */
|
|
36307
|
+
0
|
|
36308
|
+
),
|
|
36309
|
+
_0: {
|
|
36310
|
+
TAG: (
|
|
36311
|
+
/* String_literal */
|
|
36312
|
+
11
|
|
36313
|
+
),
|
|
36314
|
+
_0: "Updating cn ",
|
|
36315
|
+
_1: {
|
|
36316
|
+
TAG: (
|
|
36317
|
+
/* String */
|
|
36318
|
+
2
|
|
36319
|
+
),
|
|
36320
|
+
_0: (
|
|
36321
|
+
/* No_padding */
|
|
36322
|
+
0
|
|
36323
|
+
),
|
|
36324
|
+
_1: {
|
|
36325
|
+
TAG: (
|
|
36326
|
+
/* String_literal */
|
|
36327
|
+
11
|
|
36328
|
+
),
|
|
36329
|
+
_0: " \xE2\x86\x92 ",
|
|
36330
|
+
_1: {
|
|
36331
|
+
TAG: (
|
|
36332
|
+
/* String */
|
|
36333
|
+
2
|
|
36334
|
+
),
|
|
36335
|
+
_0: (
|
|
36336
|
+
/* No_padding */
|
|
36337
|
+
0
|
|
36338
|
+
),
|
|
36339
|
+
_1: {
|
|
36340
|
+
TAG: (
|
|
36341
|
+
/* String_literal */
|
|
36342
|
+
11
|
|
36343
|
+
),
|
|
36344
|
+
_0: "...",
|
|
36345
|
+
_1: (
|
|
36346
|
+
/* End_of_format */
|
|
36347
|
+
0
|
|
36348
|
+
)
|
|
36349
|
+
}
|
|
36350
|
+
}
|
|
36351
|
+
}
|
|
36352
|
+
}
|
|
36353
|
+
},
|
|
36354
|
+
_1: "Updating cn %s \xE2\x86\x92 %s..."
|
|
36355
|
+
}), Cn_lib.version, latest)));
|
|
36356
|
+
const match2 = exec("npm install -g cnagent@latest 2>/dev/null");
|
|
36357
|
+
if (match2 !== void 0) {
|
|
36358
|
+
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
36359
|
+
TAG: (
|
|
36360
|
+
/* Format */
|
|
36361
|
+
0
|
|
36362
|
+
),
|
|
36363
|
+
_0: {
|
|
36364
|
+
TAG: (
|
|
36365
|
+
/* String_literal */
|
|
36366
|
+
11
|
|
36367
|
+
),
|
|
36368
|
+
_0: "Updated to cn ",
|
|
36369
|
+
_1: {
|
|
36370
|
+
TAG: (
|
|
36371
|
+
/* String */
|
|
36372
|
+
2
|
|
36373
|
+
),
|
|
36374
|
+
_0: (
|
|
36375
|
+
/* No_padding */
|
|
36376
|
+
0
|
|
36377
|
+
),
|
|
36378
|
+
_1: (
|
|
36379
|
+
/* End_of_format */
|
|
36380
|
+
0
|
|
36381
|
+
)
|
|
36382
|
+
}
|
|
36383
|
+
},
|
|
36384
|
+
_1: "Updated to cn %s"
|
|
36385
|
+
}), latest);
|
|
36386
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
36387
|
+
const args_str = Stdlib__String.concat(" ", Stdlib__List.tl(args2));
|
|
36388
|
+
exec(Curry._1(Stdlib__Printf.sprintf({
|
|
36389
|
+
TAG: (
|
|
36390
|
+
/* Format */
|
|
36391
|
+
0
|
|
36392
|
+
),
|
|
36393
|
+
_0: {
|
|
36394
|
+
TAG: (
|
|
36395
|
+
/* String_literal */
|
|
36396
|
+
11
|
|
36397
|
+
),
|
|
36398
|
+
_0: "cn ",
|
|
36399
|
+
_1: {
|
|
36400
|
+
TAG: (
|
|
36401
|
+
/* String */
|
|
36402
|
+
2
|
|
36403
|
+
),
|
|
36404
|
+
_0: (
|
|
36405
|
+
/* No_padding */
|
|
36406
|
+
0
|
|
36407
|
+
),
|
|
36408
|
+
_1: (
|
|
36409
|
+
/* End_of_format */
|
|
36410
|
+
0
|
|
36411
|
+
)
|
|
36412
|
+
}
|
|
36413
|
+
},
|
|
36414
|
+
_1: "cn %s"
|
|
36415
|
+
}), args_str));
|
|
36416
|
+
process.exit(0);
|
|
36417
|
+
return;
|
|
36418
|
+
}
|
|
36419
|
+
console.log(color("33", "\xE2\x9A\xA0 ") + "Self-update failed - continuing with current version");
|
|
36420
|
+
}
|
|
36262
36421
|
function drop(n, lst) {
|
|
36263
36422
|
let _n = n;
|
|
36264
36423
|
let _lst = lst;
|
|
@@ -36280,6 +36439,7 @@ function drop(n, lst) {
|
|
|
36280
36439
|
}
|
|
36281
36440
|
;
|
|
36282
36441
|
}
|
|
36442
|
+
self_update_check(void 0);
|
|
36283
36443
|
var args = drop(2, Stdlib__Array.to_list(process.argv));
|
|
36284
36444
|
var match = Cn_lib.parse_flags(args);
|
|
36285
36445
|
var cmd_args = match[1];
|
|
@@ -36647,5 +36807,6 @@ module.exports = {
|
|
|
36647
36807
|
update_cron,
|
|
36648
36808
|
run_update,
|
|
36649
36809
|
run_update_with_cron,
|
|
36810
|
+
self_update_check,
|
|
36650
36811
|
drop
|
|
36651
36812
|
};
|