cnagent 2.2.17 → 2.2.18
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 +189 -2
package/package.json
CHANGED
package/tools/dist/cn.js
CHANGED
|
@@ -12160,6 +12160,9 @@ var require_cn_lib = __commonJS({
|
|
|
12160
12160
|
case /* Weekly */
|
|
12161
12161
|
10:
|
|
12162
12162
|
return "weekly";
|
|
12163
|
+
case /* Setup */
|
|
12164
|
+
11:
|
|
12165
|
+
return "setup";
|
|
12163
12166
|
}
|
|
12164
12167
|
} else {
|
|
12165
12168
|
switch (t.TAG) {
|
|
@@ -13182,6 +13185,15 @@ var require_cn_lib = __commonJS({
|
|
|
13182
13185
|
}
|
|
13183
13186
|
exit = 3;
|
|
13184
13187
|
break;
|
|
13188
|
+
case "setup":
|
|
13189
|
+
if (param.tl) {
|
|
13190
|
+
return;
|
|
13191
|
+
} else {
|
|
13192
|
+
return (
|
|
13193
|
+
/* Setup */
|
|
13194
|
+
11
|
|
13195
|
+
);
|
|
13196
|
+
}
|
|
13185
13197
|
case "status":
|
|
13186
13198
|
if (param.tl) {
|
|
13187
13199
|
return;
|
|
@@ -13654,8 +13666,8 @@ var require_cn_lib = __commonJS({
|
|
|
13654
13666
|
10
|
|
13655
13667
|
);
|
|
13656
13668
|
}
|
|
13657
|
-
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 # Thread creation\n adhoc <title> Create adhoc thread\n daily Create/show daily reflection\n weekly Create/show weekly reflection\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";
|
|
13658
|
-
var version = "2.2.
|
|
13669
|
+
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 # Thread creation\n adhoc <title> Create adhoc thread\n daily Create/show daily reflection\n weekly Create/show weekly reflection\n \n # Hub management\n init [name] Create new hub\n setup System setup (logrotate + cron) \xE2\x80\x94 run with sudo\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";
|
|
13670
|
+
var version = "2.2.18";
|
|
13659
13671
|
module2.exports = {
|
|
13660
13672
|
starts_with,
|
|
13661
13673
|
strip_prefix,
|
|
@@ -37646,6 +37658,176 @@ function inbox_flush(hub_path, _name) {
|
|
|
37646
37658
|
}
|
|
37647
37659
|
console.log(ok("Inbox empty"));
|
|
37648
37660
|
}
|
|
37661
|
+
function run_setup(hub_path) {
|
|
37662
|
+
const s = exec("id -u");
|
|
37663
|
+
const uid = s !== void 0 ? Stdlib__String.trim(s) : "unknown";
|
|
37664
|
+
if (uid !== "0") {
|
|
37665
|
+
console.log(fail("Setup requires root. Run: sudo cn setup"));
|
|
37666
|
+
process.exit(1);
|
|
37667
|
+
}
|
|
37668
|
+
console.log(color("36", "Setting up cn system components..."));
|
|
37669
|
+
const logrotate_path = "/etc/logrotate.d/cn";
|
|
37670
|
+
Fs.writeFileSync(logrotate_path, "/var/log/cn-*.log {\n daily\n rotate 7\n compress\n missingok\n notifempty\n}\n");
|
|
37671
|
+
console.log(ok(Curry._1(Stdlib__Printf.sprintf({
|
|
37672
|
+
TAG: (
|
|
37673
|
+
/* Format */
|
|
37674
|
+
0
|
|
37675
|
+
),
|
|
37676
|
+
_0: {
|
|
37677
|
+
TAG: (
|
|
37678
|
+
/* String_literal */
|
|
37679
|
+
11
|
|
37680
|
+
),
|
|
37681
|
+
_0: "Created ",
|
|
37682
|
+
_1: {
|
|
37683
|
+
TAG: (
|
|
37684
|
+
/* String */
|
|
37685
|
+
2
|
|
37686
|
+
),
|
|
37687
|
+
_0: (
|
|
37688
|
+
/* No_padding */
|
|
37689
|
+
0
|
|
37690
|
+
),
|
|
37691
|
+
_1: (
|
|
37692
|
+
/* End_of_format */
|
|
37693
|
+
0
|
|
37694
|
+
)
|
|
37695
|
+
}
|
|
37696
|
+
},
|
|
37697
|
+
_1: "Created %s"
|
|
37698
|
+
}), logrotate_path)));
|
|
37699
|
+
const cron_line = Curry._1(Stdlib__Printf.sprintf({
|
|
37700
|
+
TAG: (
|
|
37701
|
+
/* Format */
|
|
37702
|
+
0
|
|
37703
|
+
),
|
|
37704
|
+
_0: {
|
|
37705
|
+
TAG: (
|
|
37706
|
+
/* String_literal */
|
|
37707
|
+
11
|
|
37708
|
+
),
|
|
37709
|
+
_0: "*/5 * * * * cn-cron ",
|
|
37710
|
+
_1: {
|
|
37711
|
+
TAG: (
|
|
37712
|
+
/* String */
|
|
37713
|
+
2
|
|
37714
|
+
),
|
|
37715
|
+
_0: (
|
|
37716
|
+
/* No_padding */
|
|
37717
|
+
0
|
|
37718
|
+
),
|
|
37719
|
+
_1: (
|
|
37720
|
+
/* End_of_format */
|
|
37721
|
+
0
|
|
37722
|
+
)
|
|
37723
|
+
}
|
|
37724
|
+
},
|
|
37725
|
+
_1: "*/5 * * * * cn-cron %s"
|
|
37726
|
+
}), hub_path);
|
|
37727
|
+
const cmd2 = Curry._1(Stdlib__Printf.sprintf({
|
|
37728
|
+
TAG: (
|
|
37729
|
+
/* Format */
|
|
37730
|
+
0
|
|
37731
|
+
),
|
|
37732
|
+
_0: {
|
|
37733
|
+
TAG: (
|
|
37734
|
+
/* String_literal */
|
|
37735
|
+
11
|
|
37736
|
+
),
|
|
37737
|
+
_0: "echo '",
|
|
37738
|
+
_1: {
|
|
37739
|
+
TAG: (
|
|
37740
|
+
/* String */
|
|
37741
|
+
2
|
|
37742
|
+
),
|
|
37743
|
+
_0: (
|
|
37744
|
+
/* No_padding */
|
|
37745
|
+
0
|
|
37746
|
+
),
|
|
37747
|
+
_1: {
|
|
37748
|
+
TAG: (
|
|
37749
|
+
/* String_literal */
|
|
37750
|
+
11
|
|
37751
|
+
),
|
|
37752
|
+
_0: "' | crontab -",
|
|
37753
|
+
_1: (
|
|
37754
|
+
/* End_of_format */
|
|
37755
|
+
0
|
|
37756
|
+
)
|
|
37757
|
+
}
|
|
37758
|
+
}
|
|
37759
|
+
},
|
|
37760
|
+
_1: "echo '%s' | crontab -"
|
|
37761
|
+
}), cron_line);
|
|
37762
|
+
const match2 = exec(cmd2);
|
|
37763
|
+
if (match2 !== void 0) {
|
|
37764
|
+
console.log(ok("Crontab configured"));
|
|
37765
|
+
} else {
|
|
37766
|
+
console.log(warn("Crontab update failed - configure manually"));
|
|
37767
|
+
}
|
|
37768
|
+
console.log("");
|
|
37769
|
+
console.log(ok("Setup complete!"));
|
|
37770
|
+
console.log("");
|
|
37771
|
+
console.log("Configured:");
|
|
37772
|
+
console.log(Curry._1(Stdlib__Printf.sprintf({
|
|
37773
|
+
TAG: (
|
|
37774
|
+
/* Format */
|
|
37775
|
+
0
|
|
37776
|
+
),
|
|
37777
|
+
_0: {
|
|
37778
|
+
TAG: (
|
|
37779
|
+
/* String_literal */
|
|
37780
|
+
11
|
|
37781
|
+
),
|
|
37782
|
+
_0: " \xE2\x80\xA2 Logrotate: ",
|
|
37783
|
+
_1: {
|
|
37784
|
+
TAG: (
|
|
37785
|
+
/* String */
|
|
37786
|
+
2
|
|
37787
|
+
),
|
|
37788
|
+
_0: (
|
|
37789
|
+
/* No_padding */
|
|
37790
|
+
0
|
|
37791
|
+
),
|
|
37792
|
+
_1: (
|
|
37793
|
+
/* End_of_format */
|
|
37794
|
+
0
|
|
37795
|
+
)
|
|
37796
|
+
}
|
|
37797
|
+
},
|
|
37798
|
+
_1: " \xE2\x80\xA2 Logrotate: %s"
|
|
37799
|
+
}), logrotate_path));
|
|
37800
|
+
console.log(Curry._1(Stdlib__Printf.sprintf({
|
|
37801
|
+
TAG: (
|
|
37802
|
+
/* Format */
|
|
37803
|
+
0
|
|
37804
|
+
),
|
|
37805
|
+
_0: {
|
|
37806
|
+
TAG: (
|
|
37807
|
+
/* String_literal */
|
|
37808
|
+
11
|
|
37809
|
+
),
|
|
37810
|
+
_0: " \xE2\x80\xA2 Cron: */5 * * * * cn-cron ",
|
|
37811
|
+
_1: {
|
|
37812
|
+
TAG: (
|
|
37813
|
+
/* String */
|
|
37814
|
+
2
|
|
37815
|
+
),
|
|
37816
|
+
_0: (
|
|
37817
|
+
/* No_padding */
|
|
37818
|
+
0
|
|
37819
|
+
),
|
|
37820
|
+
_1: (
|
|
37821
|
+
/* End_of_format */
|
|
37822
|
+
0
|
|
37823
|
+
)
|
|
37824
|
+
}
|
|
37825
|
+
},
|
|
37826
|
+
_1: " \xE2\x80\xA2 Cron: */5 * * * * cn-cron %s"
|
|
37827
|
+
}), hub_path));
|
|
37828
|
+
console.log("");
|
|
37829
|
+
console.log("Logs will be written to: /var/log/cn-YYYYMMDD.log");
|
|
37830
|
+
}
|
|
37649
37831
|
function update_cron(hub_path) {
|
|
37650
37832
|
const cron_line = Curry._1(Stdlib__Printf.sprintf({
|
|
37651
37833
|
TAG: (
|
|
@@ -38125,6 +38307,10 @@ if (cmd !== void 0) {
|
|
|
38125
38307
|
10:
|
|
38126
38308
|
run_weekly(hub_path$1);
|
|
38127
38309
|
break;
|
|
38310
|
+
case /* Setup */
|
|
38311
|
+
11:
|
|
38312
|
+
run_setup(hub_path$1);
|
|
38313
|
+
break;
|
|
38128
38314
|
}
|
|
38129
38315
|
} else {
|
|
38130
38316
|
switch (cmd.TAG) {
|
|
@@ -38409,6 +38595,7 @@ module.exports = {
|
|
|
38409
38595
|
run_peer_remove,
|
|
38410
38596
|
run_peer_sync,
|
|
38411
38597
|
inbox_flush,
|
|
38598
|
+
run_setup,
|
|
38412
38599
|
update_cron,
|
|
38413
38600
|
run_update,
|
|
38414
38601
|
run_update_with_cron,
|