cnagent 2.2.12 → 2.2.14
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 +118 -47
package/package.json
CHANGED
package/tools/dist/cn.js
CHANGED
|
@@ -13618,7 +13618,7 @@ var require_cn_lib = __commonJS({
|
|
|
13618
13618
|
);
|
|
13619
13619
|
}
|
|
13620
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";
|
|
13621
|
-
var version = "2.2.
|
|
13621
|
+
var version = "2.2.14";
|
|
13622
13622
|
module2.exports = {
|
|
13623
13623
|
starts_with,
|
|
13624
13624
|
strip_prefix,
|
|
@@ -15275,7 +15275,7 @@ var require_camlinternalFormat = __commonJS({
|
|
|
15275
15275
|
var CamlinternalFormatBasics = require_camlinternalFormatBasics();
|
|
15276
15276
|
var Curry2 = require_curry();
|
|
15277
15277
|
var Stdlib2 = require_stdlib();
|
|
15278
|
-
var
|
|
15278
|
+
var Stdlib__Buffer2 = require_buffer();
|
|
15279
15279
|
var Stdlib__Bytes = require_bytes();
|
|
15280
15280
|
var Stdlib__Char = require_char();
|
|
15281
15281
|
var Stdlib__Int = require_int();
|
|
@@ -21776,7 +21776,7 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21776
21776
|
0:
|
|
21777
21777
|
const s = string_of_formatting_lit(acc._1);
|
|
21778
21778
|
bufput_acc(b, acc._0);
|
|
21779
|
-
return
|
|
21779
|
+
return Stdlib__Buffer2.add_string(b, s);
|
|
21780
21780
|
case /* Acc_formatting_gen */
|
|
21781
21781
|
1:
|
|
21782
21782
|
const acc$p = acc._1;
|
|
@@ -21784,12 +21784,12 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21784
21784
|
if (acc$p.TAG === /* Acc_open_tag */
|
|
21785
21785
|
0) {
|
|
21786
21786
|
bufput_acc(b, p);
|
|
21787
|
-
|
|
21787
|
+
Stdlib__Buffer2.add_string(b, "@{");
|
|
21788
21788
|
_acc = acc$p._0;
|
|
21789
21789
|
continue;
|
|
21790
21790
|
}
|
|
21791
21791
|
bufput_acc(b, p);
|
|
21792
|
-
|
|
21792
|
+
Stdlib__Buffer2.add_string(b, "@[");
|
|
21793
21793
|
_acc = acc$p._0;
|
|
21794
21794
|
continue;
|
|
21795
21795
|
case /* Acc_string_literal */
|
|
@@ -21823,10 +21823,10 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21823
21823
|
switch (exit) {
|
|
21824
21824
|
case 1:
|
|
21825
21825
|
bufput_acc(b, acc._0);
|
|
21826
|
-
return
|
|
21826
|
+
return Stdlib__Buffer2.add_string(b, acc._1);
|
|
21827
21827
|
case 2:
|
|
21828
21828
|
bufput_acc(b, acc._0);
|
|
21829
|
-
return
|
|
21829
|
+
return Stdlib__Buffer2.add_char(b, acc._1);
|
|
21830
21830
|
}
|
|
21831
21831
|
}
|
|
21832
21832
|
;
|
|
@@ -21846,7 +21846,7 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21846
21846
|
0:
|
|
21847
21847
|
const s = string_of_formatting_lit(acc._1);
|
|
21848
21848
|
strput_acc(b, acc._0);
|
|
21849
|
-
return
|
|
21849
|
+
return Stdlib__Buffer2.add_string(b, s);
|
|
21850
21850
|
case /* Acc_formatting_gen */
|
|
21851
21851
|
1:
|
|
21852
21852
|
const acc$p = acc._1;
|
|
@@ -21854,12 +21854,12 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21854
21854
|
if (acc$p.TAG === /* Acc_open_tag */
|
|
21855
21855
|
0) {
|
|
21856
21856
|
strput_acc(b, p);
|
|
21857
|
-
|
|
21857
|
+
Stdlib__Buffer2.add_string(b, "@{");
|
|
21858
21858
|
_acc = acc$p._0;
|
|
21859
21859
|
continue;
|
|
21860
21860
|
}
|
|
21861
21861
|
strput_acc(b, p);
|
|
21862
|
-
|
|
21862
|
+
Stdlib__Buffer2.add_string(b, "@[");
|
|
21863
21863
|
_acc = acc$p._0;
|
|
21864
21864
|
continue;
|
|
21865
21865
|
case /* Acc_string_literal */
|
|
@@ -21877,7 +21877,7 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21877
21877
|
case /* Acc_delay */
|
|
21878
21878
|
6:
|
|
21879
21879
|
strput_acc(b, acc._0);
|
|
21880
|
-
return
|
|
21880
|
+
return Stdlib__Buffer2.add_string(b, Curry2._1(acc._1, void 0));
|
|
21881
21881
|
case /* Acc_flush */
|
|
21882
21882
|
7:
|
|
21883
21883
|
_acc = acc._0;
|
|
@@ -21893,19 +21893,19 @@ var require_camlinternalFormat = __commonJS({
|
|
|
21893
21893
|
switch (exit) {
|
|
21894
21894
|
case 1:
|
|
21895
21895
|
strput_acc(b, acc._0);
|
|
21896
|
-
return
|
|
21896
|
+
return Stdlib__Buffer2.add_string(b, acc._1);
|
|
21897
21897
|
case 2:
|
|
21898
21898
|
strput_acc(b, acc._0);
|
|
21899
|
-
return
|
|
21899
|
+
return Stdlib__Buffer2.add_char(b, acc._1);
|
|
21900
21900
|
}
|
|
21901
21901
|
}
|
|
21902
21902
|
;
|
|
21903
21903
|
}
|
|
21904
21904
|
function failwith_message(param) {
|
|
21905
|
-
const buf =
|
|
21905
|
+
const buf = Stdlib__Buffer2.create(256);
|
|
21906
21906
|
const k = function(acc) {
|
|
21907
21907
|
strput_acc(buf, acc);
|
|
21908
|
-
const s =
|
|
21908
|
+
const s = Stdlib__Buffer2.contents(buf);
|
|
21909
21909
|
throw new Caml_js_exceptions2.MelangeError("Failure", {
|
|
21910
21910
|
MEL_EXN_ID: "Failure",
|
|
21911
21911
|
_1: s
|
|
@@ -26169,7 +26169,7 @@ var require_printf = __commonJS({
|
|
|
26169
26169
|
var CamlinternalFormat = require_camlinternalFormat();
|
|
26170
26170
|
var Curry2 = require_curry();
|
|
26171
26171
|
var Stdlib2 = require_stdlib();
|
|
26172
|
-
var
|
|
26172
|
+
var Stdlib__Buffer2 = require_buffer();
|
|
26173
26173
|
function kfprintf(k, o, param) {
|
|
26174
26174
|
return CamlinternalFormat.make_printf(
|
|
26175
26175
|
(function(acc) {
|
|
@@ -26219,9 +26219,9 @@ var require_printf = __commonJS({
|
|
|
26219
26219
|
}
|
|
26220
26220
|
function ksprintf(k, param) {
|
|
26221
26221
|
const k$p = function(acc) {
|
|
26222
|
-
const buf =
|
|
26222
|
+
const buf = Stdlib__Buffer2.create(64);
|
|
26223
26223
|
CamlinternalFormat.strput_acc(buf, acc);
|
|
26224
|
-
return Curry2._1(k,
|
|
26224
|
+
return Curry2._1(k, Stdlib__Buffer2.contents(buf));
|
|
26225
26225
|
};
|
|
26226
26226
|
return CamlinternalFormat.make_printf(
|
|
26227
26227
|
k$p,
|
|
@@ -26265,6 +26265,7 @@ var Js__Js_dict = require_js_dict();
|
|
|
26265
26265
|
var Js__Js_exn = require_js_exn();
|
|
26266
26266
|
var Stdlib = require_stdlib();
|
|
26267
26267
|
var Stdlib__Array = require_array();
|
|
26268
|
+
var Stdlib__Buffer = require_buffer();
|
|
26268
26269
|
var Stdlib__List = require_list();
|
|
26269
26270
|
var Stdlib__Option = require_option();
|
|
26270
26271
|
var Stdlib__Printf = require_printf();
|
|
@@ -28230,8 +28231,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28230
28231
|
return p.name === to_peer;
|
|
28231
28232
|
}), peers);
|
|
28232
28233
|
if (peer !== void 0) {
|
|
28233
|
-
|
|
28234
|
-
if (clone_path !== void 0) {
|
|
28234
|
+
if (peer.clone !== void 0) {
|
|
28235
28235
|
const thread_name = Path.basename(file, ".md");
|
|
28236
28236
|
const branch_name = Curry._2(Stdlib__Printf.sprintf({
|
|
28237
28237
|
TAG: (
|
|
@@ -28273,7 +28273,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28273
28273
|
}
|
|
28274
28274
|
},
|
|
28275
28275
|
_1: "%s/%s"
|
|
28276
|
-
}),
|
|
28276
|
+
}), to_peer, thread_name);
|
|
28277
28277
|
if (dry_run_mode.contents) {
|
|
28278
28278
|
console.log(color("2", Curry._3(Stdlib__Printf.sprintf({
|
|
28279
28279
|
TAG: (
|
|
@@ -28349,10 +28349,9 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28349
28349
|
}), file, to_peer, branch_name)));
|
|
28350
28350
|
return file;
|
|
28351
28351
|
}
|
|
28352
|
-
const match2 = exec_in(
|
|
28352
|
+
const match2 = exec_in(hub_path, "git checkout main 2>/dev/null || git checkout master");
|
|
28353
28353
|
if (match2 !== void 0) {
|
|
28354
|
-
exec_in(
|
|
28355
|
-
exec_in(clone_path, Curry._2(Stdlib__Printf.sprintf({
|
|
28354
|
+
exec_in(hub_path, Curry._2(Stdlib__Printf.sprintf({
|
|
28356
28355
|
TAG: (
|
|
28357
28356
|
/* Format */
|
|
28358
28357
|
0
|
|
@@ -28397,11 +28396,11 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28397
28396
|
},
|
|
28398
28397
|
_1: "git checkout -b %s 2>/dev/null || git checkout %s"
|
|
28399
28398
|
}), branch_name, branch_name));
|
|
28400
|
-
const
|
|
28401
|
-
ensure_dir(
|
|
28402
|
-
const prim0 = Path.join(
|
|
28399
|
+
const thread_dir = Path.join(hub_path, "threads/in");
|
|
28400
|
+
ensure_dir(thread_dir);
|
|
28401
|
+
const prim0 = Path.join(thread_dir, file);
|
|
28403
28402
|
Fs.writeFileSync(prim0, content);
|
|
28404
|
-
exec_in(
|
|
28403
|
+
exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
|
|
28405
28404
|
TAG: (
|
|
28406
28405
|
/* Format */
|
|
28407
28406
|
0
|
|
@@ -28439,7 +28438,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28439
28438
|
},
|
|
28440
28439
|
_1: "git add 'threads/in/%s'"
|
|
28441
28440
|
}), file));
|
|
28442
|
-
exec_in(
|
|
28441
|
+
exec_in(hub_path, Curry._2(Stdlib__Printf.sprintf({
|
|
28443
28442
|
TAG: (
|
|
28444
28443
|
/* Format */
|
|
28445
28444
|
0
|
|
@@ -28494,7 +28493,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28494
28493
|
},
|
|
28495
28494
|
_1: "git commit -m '%s: %s'"
|
|
28496
28495
|
}), name, thread_name));
|
|
28497
|
-
exec_in(
|
|
28496
|
+
exec_in(hub_path, Curry._1(Stdlib__Printf.sprintf({
|
|
28498
28497
|
TAG: (
|
|
28499
28498
|
/* Format */
|
|
28500
28499
|
0
|
|
@@ -28529,7 +28528,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28529
28528
|
},
|
|
28530
28529
|
_1: "git push -u origin %s -f"
|
|
28531
28530
|
}), branch_name));
|
|
28532
|
-
exec_in(
|
|
28531
|
+
exec_in(hub_path, "git checkout main 2>/dev/null || git checkout master");
|
|
28533
28532
|
const prim1 = Cn_lib.update_frontmatter(content, {
|
|
28534
28533
|
hd: [
|
|
28535
28534
|
"sent",
|
|
@@ -28543,7 +28542,7 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28543
28542
|
const prim0$1 = Path.join(sent_dir, file);
|
|
28544
28543
|
Fs.writeFileSync(prim0$1, prim1);
|
|
28545
28544
|
Fs.unlinkSync(file_path);
|
|
28546
|
-
log_action(hub_path, "outbox.send", Curry.
|
|
28545
|
+
log_action(hub_path, "outbox.send", Curry._3(Stdlib__Printf.sprintf({
|
|
28547
28546
|
TAG: (
|
|
28548
28547
|
/* Format */
|
|
28549
28548
|
0
|
|
@@ -28578,16 +28577,33 @@ function send_thread(hub_path, name, peers, outbox_dir, sent_dir, file) {
|
|
|
28578
28577
|
/* No_padding */
|
|
28579
28578
|
0
|
|
28580
28579
|
),
|
|
28581
|
-
_1:
|
|
28582
|
-
|
|
28583
|
-
|
|
28584
|
-
|
|
28580
|
+
_1: {
|
|
28581
|
+
TAG: (
|
|
28582
|
+
/* String_literal */
|
|
28583
|
+
11
|
|
28584
|
+
),
|
|
28585
|
+
_0: " branch:",
|
|
28586
|
+
_1: {
|
|
28587
|
+
TAG: (
|
|
28588
|
+
/* String */
|
|
28589
|
+
2
|
|
28590
|
+
),
|
|
28591
|
+
_0: (
|
|
28592
|
+
/* No_padding */
|
|
28593
|
+
0
|
|
28594
|
+
),
|
|
28595
|
+
_1: (
|
|
28596
|
+
/* End_of_format */
|
|
28597
|
+
0
|
|
28598
|
+
)
|
|
28599
|
+
}
|
|
28600
|
+
}
|
|
28585
28601
|
}
|
|
28586
28602
|
}
|
|
28587
28603
|
}
|
|
28588
28604
|
},
|
|
28589
|
-
_1: "to:%s thread:%s"
|
|
28590
|
-
}), to_peer, file));
|
|
28605
|
+
_1: "to:%s thread:%s branch:%s"
|
|
28606
|
+
}), to_peer, file, branch_name));
|
|
28591
28607
|
console.log(ok(Curry._2(Stdlib__Printf.sprintf({
|
|
28592
28608
|
TAG: (
|
|
28593
28609
|
/* Format */
|
|
@@ -33072,14 +33088,68 @@ function feed_next_input(hub_path) {
|
|
|
33072
33088
|
console.log(ok("Queue empty - nothing to process"));
|
|
33073
33089
|
return false;
|
|
33074
33090
|
}
|
|
33075
|
-
function
|
|
33076
|
-
|
|
33077
|
-
|
|
33078
|
-
|
|
33079
|
-
|
|
33080
|
-
|
|
33081
|
-
|
|
33091
|
+
function shell_escape(s) {
|
|
33092
|
+
const buf = Stdlib__Buffer.create(s.length << 1);
|
|
33093
|
+
Stdlib__String.iter((function(c) {
|
|
33094
|
+
if (c === /* '\'' */
|
|
33095
|
+
39) {
|
|
33096
|
+
return Stdlib__Buffer.add_string(buf, "'\\''");
|
|
33097
|
+
} else {
|
|
33098
|
+
return Stdlib__Buffer.add_char(buf, c);
|
|
33099
|
+
}
|
|
33100
|
+
}), s);
|
|
33101
|
+
return Stdlib__Buffer.contents(buf);
|
|
33102
|
+
}
|
|
33103
|
+
function wake_agent(hub_path) {
|
|
33104
|
+
const inp = Path.join(hub_path, "state/input.md");
|
|
33105
|
+
if (Fs.existsSync(inp)) {
|
|
33106
|
+
const content = Fs.readFileSync(inp, "utf8");
|
|
33107
|
+
const escaped = shell_escape(content);
|
|
33108
|
+
console.log(color("36", "Triggering OpenClaw wake with input content..."));
|
|
33109
|
+
const wake_cmd = Curry._1(Stdlib__Printf.sprintf({
|
|
33110
|
+
TAG: (
|
|
33111
|
+
/* Format */
|
|
33112
|
+
0
|
|
33113
|
+
),
|
|
33114
|
+
_0: {
|
|
33115
|
+
TAG: (
|
|
33116
|
+
/* String_literal */
|
|
33117
|
+
11
|
|
33118
|
+
),
|
|
33119
|
+
_0: "openclaw system event --text '",
|
|
33120
|
+
_1: {
|
|
33121
|
+
TAG: (
|
|
33122
|
+
/* String */
|
|
33123
|
+
2
|
|
33124
|
+
),
|
|
33125
|
+
_0: (
|
|
33126
|
+
/* No_padding */
|
|
33127
|
+
0
|
|
33128
|
+
),
|
|
33129
|
+
_1: {
|
|
33130
|
+
TAG: (
|
|
33131
|
+
/* String_literal */
|
|
33132
|
+
11
|
|
33133
|
+
),
|
|
33134
|
+
_0: "' --mode now 2>/dev/null",
|
|
33135
|
+
_1: (
|
|
33136
|
+
/* End_of_format */
|
|
33137
|
+
0
|
|
33138
|
+
)
|
|
33139
|
+
}
|
|
33140
|
+
}
|
|
33141
|
+
},
|
|
33142
|
+
_1: "openclaw system event --text '%s' --mode now 2>/dev/null"
|
|
33143
|
+
}), escaped);
|
|
33144
|
+
const match2 = exec(wake_cmd);
|
|
33145
|
+
if (match2 !== void 0) {
|
|
33146
|
+
console.log(ok("Wake triggered with input content"));
|
|
33147
|
+
} else {
|
|
33148
|
+
console.log(warn("Wake trigger failed - is OpenClaw running?"));
|
|
33149
|
+
}
|
|
33150
|
+
return;
|
|
33082
33151
|
}
|
|
33152
|
+
console.log(warn("No input.md to wake with"));
|
|
33083
33153
|
}
|
|
33084
33154
|
function run_sync(hub_path, name) {
|
|
33085
33155
|
console.log(color("36", "Syncing..."));
|
|
@@ -35607,7 +35677,7 @@ function run_inbound(hub_path, name) {
|
|
|
35607
35677
|
if (archive_io_pair(hub_path, name)) {
|
|
35608
35678
|
auto_save(hub_path, name);
|
|
35609
35679
|
if (feed_next_input(hub_path)) {
|
|
35610
|
-
return wake_agent(
|
|
35680
|
+
return wake_agent(hub_path);
|
|
35611
35681
|
} else {
|
|
35612
35682
|
return;
|
|
35613
35683
|
}
|
|
@@ -35654,7 +35724,7 @@ function run_inbound(hub_path, name) {
|
|
|
35654
35724
|
}), queue_count(hub_path))));
|
|
35655
35725
|
return;
|
|
35656
35726
|
} else if (feed_next_input(hub_path)) {
|
|
35657
|
-
return wake_agent(
|
|
35727
|
+
return wake_agent(hub_path);
|
|
35658
35728
|
} else {
|
|
35659
35729
|
return;
|
|
35660
35730
|
}
|
|
@@ -37775,6 +37845,7 @@ module.exports = {
|
|
|
37775
37845
|
archive_io_pair,
|
|
37776
37846
|
queue_inbox_items,
|
|
37777
37847
|
feed_next_input,
|
|
37848
|
+
shell_escape,
|
|
37778
37849
|
wake_agent,
|
|
37779
37850
|
run_sync,
|
|
37780
37851
|
run_queue_list,
|