cnagent 2.1.11 → 2.1.13
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 +1197 -475
package/tools/dist/cn.js
CHANGED
|
@@ -11878,6 +11878,7 @@ var require_string = __commonJS({
|
|
|
11878
11878
|
var require_cn_lib = __commonJS({
|
|
11879
11879
|
"_build/default/tools/src/cn/output/tools/src/cn/cn_lib.js"(exports2, module2) {
|
|
11880
11880
|
"use strict";
|
|
11881
|
+
var Caml_obj = require_caml_obj();
|
|
11881
11882
|
var Stdlib__List2 = require_list();
|
|
11882
11883
|
var Stdlib__Option2 = require_option();
|
|
11883
11884
|
var Stdlib__String2 = require_string();
|
|
@@ -11999,17 +12000,28 @@ var require_cn_lib = __commonJS({
|
|
|
11999
12000
|
} else {
|
|
12000
12001
|
return "queue clear";
|
|
12001
12002
|
}
|
|
12002
|
-
case /*
|
|
12003
|
+
case /* Mca */
|
|
12003
12004
|
5:
|
|
12005
|
+
const d = t._0;
|
|
12006
|
+
if (
|
|
12007
|
+
/* tag */
|
|
12008
|
+
typeof d === "number" || typeof d === "string"
|
|
12009
|
+
) {
|
|
12010
|
+
return "mca list";
|
|
12011
|
+
} else {
|
|
12012
|
+
return "mca add " + d._0;
|
|
12013
|
+
}
|
|
12014
|
+
case /* Read */
|
|
12015
|
+
6:
|
|
12004
12016
|
return "read " + t._0;
|
|
12005
12017
|
case /* Reply */
|
|
12006
|
-
|
|
12018
|
+
7:
|
|
12007
12019
|
return "reply " + t._0;
|
|
12008
12020
|
case /* Send */
|
|
12009
|
-
|
|
12021
|
+
8:
|
|
12010
12022
|
return "send " + t._0;
|
|
12011
12023
|
case /* Gtd */
|
|
12012
|
-
|
|
12024
|
+
9:
|
|
12013
12025
|
const t$1 = t._0;
|
|
12014
12026
|
switch (t$1.TAG) {
|
|
12015
12027
|
case /* GtdDelete */
|
|
@@ -12029,7 +12041,7 @@ var require_cn_lib = __commonJS({
|
|
|
12029
12041
|
return "done " + t$1._0;
|
|
12030
12042
|
}
|
|
12031
12043
|
case /* Commit */
|
|
12032
|
-
|
|
12044
|
+
10:
|
|
12033
12045
|
const m = t._0;
|
|
12034
12046
|
if (m !== void 0) {
|
|
12035
12047
|
return "commit " + m;
|
|
@@ -12037,7 +12049,7 @@ var require_cn_lib = __commonJS({
|
|
|
12037
12049
|
return "commit";
|
|
12038
12050
|
}
|
|
12039
12051
|
case /* Save */
|
|
12040
|
-
|
|
12052
|
+
11:
|
|
12041
12053
|
const m$1 = t._0;
|
|
12042
12054
|
if (m$1 !== void 0) {
|
|
12043
12055
|
return "save " + m$1;
|
|
@@ -12223,6 +12235,44 @@ var require_cn_lib = __commonJS({
|
|
|
12223
12235
|
return;
|
|
12224
12236
|
}
|
|
12225
12237
|
}
|
|
12238
|
+
function parse_mca_cmd(param) {
|
|
12239
|
+
if (!param) {
|
|
12240
|
+
return (
|
|
12241
|
+
/* Mca_list */
|
|
12242
|
+
0
|
|
12243
|
+
);
|
|
12244
|
+
}
|
|
12245
|
+
switch (param.hd) {
|
|
12246
|
+
case "add":
|
|
12247
|
+
const rest = param.tl;
|
|
12248
|
+
if (Caml_obj.caml_notequal(
|
|
12249
|
+
rest,
|
|
12250
|
+
/* [] */
|
|
12251
|
+
0
|
|
12252
|
+
)) {
|
|
12253
|
+
return {
|
|
12254
|
+
TAG: (
|
|
12255
|
+
/* Mca_add */
|
|
12256
|
+
0
|
|
12257
|
+
),
|
|
12258
|
+
_0: Stdlib__String2.concat(" ", rest)
|
|
12259
|
+
};
|
|
12260
|
+
} else {
|
|
12261
|
+
return;
|
|
12262
|
+
}
|
|
12263
|
+
case "list":
|
|
12264
|
+
if (param.tl) {
|
|
12265
|
+
return;
|
|
12266
|
+
} else {
|
|
12267
|
+
return (
|
|
12268
|
+
/* Mca_list */
|
|
12269
|
+
0
|
|
12270
|
+
);
|
|
12271
|
+
}
|
|
12272
|
+
default:
|
|
12273
|
+
return;
|
|
12274
|
+
}
|
|
12275
|
+
}
|
|
12226
12276
|
function parse_gtd_cmd(param) {
|
|
12227
12277
|
if (!param) {
|
|
12228
12278
|
return;
|
|
@@ -12334,7 +12384,7 @@ var require_cn_lib = __commonJS({
|
|
|
12334
12384
|
return {
|
|
12335
12385
|
TAG: (
|
|
12336
12386
|
/* Commit */
|
|
12337
|
-
|
|
12387
|
+
10
|
|
12338
12388
|
),
|
|
12339
12389
|
_0: join_rest(param.tl)
|
|
12340
12390
|
};
|
|
@@ -12343,7 +12393,7 @@ var require_cn_lib = __commonJS({
|
|
|
12343
12393
|
return {
|
|
12344
12394
|
TAG: (
|
|
12345
12395
|
/* Gtd */
|
|
12346
|
-
|
|
12396
|
+
9
|
|
12347
12397
|
),
|
|
12348
12398
|
_0: c
|
|
12349
12399
|
};
|
|
@@ -12356,7 +12406,7 @@ var require_cn_lib = __commonJS({
|
|
|
12356
12406
|
return {
|
|
12357
12407
|
TAG: (
|
|
12358
12408
|
/* Gtd */
|
|
12359
|
-
|
|
12409
|
+
9
|
|
12360
12410
|
),
|
|
12361
12411
|
_0: c
|
|
12362
12412
|
};
|
|
@@ -12369,7 +12419,7 @@ var require_cn_lib = __commonJS({
|
|
|
12369
12419
|
return {
|
|
12370
12420
|
TAG: (
|
|
12371
12421
|
/* Gtd */
|
|
12372
|
-
|
|
12422
|
+
9
|
|
12373
12423
|
),
|
|
12374
12424
|
_0: c
|
|
12375
12425
|
};
|
|
@@ -12382,7 +12432,7 @@ var require_cn_lib = __commonJS({
|
|
|
12382
12432
|
return {
|
|
12383
12433
|
TAG: (
|
|
12384
12434
|
/* Gtd */
|
|
12385
|
-
|
|
12435
|
+
9
|
|
12386
12436
|
),
|
|
12387
12437
|
_0: c
|
|
12388
12438
|
};
|
|
@@ -12404,7 +12454,7 @@ var require_cn_lib = __commonJS({
|
|
|
12404
12454
|
return {
|
|
12405
12455
|
TAG: (
|
|
12406
12456
|
/* Gtd */
|
|
12407
|
-
|
|
12457
|
+
9
|
|
12408
12458
|
),
|
|
12409
12459
|
_0: c
|
|
12410
12460
|
};
|
|
@@ -12450,6 +12500,16 @@ var require_cn_lib = __commonJS({
|
|
|
12450
12500
|
_0: void 0
|
|
12451
12501
|
};
|
|
12452
12502
|
}
|
|
12503
|
+
case "mca":
|
|
12504
|
+
return Stdlib__Option2.map((function(c) {
|
|
12505
|
+
return {
|
|
12506
|
+
TAG: (
|
|
12507
|
+
/* Mca */
|
|
12508
|
+
5
|
|
12509
|
+
),
|
|
12510
|
+
_0: c
|
|
12511
|
+
};
|
|
12512
|
+
}), parse_mca_cmd(param.tl));
|
|
12453
12513
|
case "next":
|
|
12454
12514
|
if (param.tl) {
|
|
12455
12515
|
return;
|
|
@@ -12516,7 +12576,7 @@ var require_cn_lib = __commonJS({
|
|
|
12516
12576
|
return {
|
|
12517
12577
|
TAG: (
|
|
12518
12578
|
/* Read */
|
|
12519
|
-
|
|
12579
|
+
6
|
|
12520
12580
|
),
|
|
12521
12581
|
_0: match$1.hd
|
|
12522
12582
|
};
|
|
@@ -12530,7 +12590,7 @@ var require_cn_lib = __commonJS({
|
|
|
12530
12590
|
return {
|
|
12531
12591
|
TAG: (
|
|
12532
12592
|
/* Reply */
|
|
12533
|
-
|
|
12593
|
+
7
|
|
12534
12594
|
),
|
|
12535
12595
|
_0: match$2.hd,
|
|
12536
12596
|
_1: Stdlib__String2.concat(" ", match$2.tl)
|
|
@@ -12542,7 +12602,7 @@ var require_cn_lib = __commonJS({
|
|
|
12542
12602
|
return {
|
|
12543
12603
|
TAG: (
|
|
12544
12604
|
/* Save */
|
|
12545
|
-
|
|
12605
|
+
11
|
|
12546
12606
|
),
|
|
12547
12607
|
_0: join_rest(param.tl)
|
|
12548
12608
|
};
|
|
@@ -12552,7 +12612,7 @@ var require_cn_lib = __commonJS({
|
|
|
12552
12612
|
return {
|
|
12553
12613
|
TAG: (
|
|
12554
12614
|
/* Send */
|
|
12555
|
-
|
|
12615
|
+
8
|
|
12556
12616
|
),
|
|
12557
12617
|
_0: match$3.hd,
|
|
12558
12618
|
_1: Stdlib__String2.concat(" ", match$3.tl)
|
|
@@ -13014,8 +13074,8 @@ var require_cn_lib = __commonJS({
|
|
|
13014
13074
|
10
|
|
13015
13075
|
);
|
|
13016
13076
|
}
|
|
13017
|
-
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 process Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent\n queue [list|clear] View or clear the task queue\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";
|
|
13018
|
-
var version = "2.1.
|
|
13077
|
+
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 process Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent\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";
|
|
13078
|
+
var version = "2.1.13";
|
|
13019
13079
|
module2.exports = {
|
|
13020
13080
|
starts_with,
|
|
13021
13081
|
strip_prefix,
|
|
@@ -13027,6 +13087,7 @@ var require_cn_lib = __commonJS({
|
|
|
13027
13087
|
parse_outbox_cmd,
|
|
13028
13088
|
parse_peer_cmd,
|
|
13029
13089
|
parse_queue_cmd,
|
|
13090
|
+
parse_mca_cmd,
|
|
13030
13091
|
parse_gtd_cmd,
|
|
13031
13092
|
join_rest,
|
|
13032
13093
|
parse_command,
|
|
@@ -29715,109 +29776,48 @@ function archive_io_pair(hub_path) {
|
|
|
29715
29776
|
const logs_out = Path.join(hub_path, "logs/output");
|
|
29716
29777
|
ensure_dir(logs_in);
|
|
29717
29778
|
ensure_dir(logs_out);
|
|
29779
|
+
const output_content = Fs.readFileSync(outp, "utf8");
|
|
29718
29780
|
const archive_name = match2 + ".md";
|
|
29719
29781
|
const prim1 = Fs.readFileSync(inp, "utf8");
|
|
29720
29782
|
const prim0 = Path.join(logs_in, archive_name);
|
|
29721
29783
|
Fs.writeFileSync(prim0, prim1);
|
|
29722
|
-
const prim1$1 = Fs.readFileSync(outp, "utf8");
|
|
29723
29784
|
const prim0$1 = Path.join(logs_out, archive_name);
|
|
29724
|
-
Fs.writeFileSync(prim0$1,
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
29728
|
-
|
|
29729
|
-
|
|
29730
|
-
|
|
29731
|
-
|
|
29732
|
-
_0: {
|
|
29733
|
-
TAG: (
|
|
29734
|
-
/* String_literal */
|
|
29735
|
-
11
|
|
29736
|
-
),
|
|
29737
|
-
_0: "id:",
|
|
29738
|
-
_1: {
|
|
29739
|
-
TAG: (
|
|
29740
|
-
/* String */
|
|
29741
|
-
2
|
|
29742
|
-
),
|
|
29743
|
-
_0: (
|
|
29744
|
-
/* No_padding */
|
|
29745
|
-
0
|
|
29746
|
-
),
|
|
29747
|
-
_1: (
|
|
29748
|
-
/* End_of_format */
|
|
29749
|
-
0
|
|
29750
|
-
)
|
|
29751
|
-
}
|
|
29752
|
-
},
|
|
29753
|
-
_1: "id:%s"
|
|
29754
|
-
}), match2));
|
|
29755
|
-
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
29756
|
-
TAG: (
|
|
29757
|
-
/* Format */
|
|
29758
|
-
0
|
|
29759
|
-
),
|
|
29760
|
-
_0: {
|
|
29785
|
+
Fs.writeFileSync(prim0$1, output_content);
|
|
29786
|
+
const output_meta = Cn_lib.parse_frontmatter(output_content);
|
|
29787
|
+
const match$2 = Stdlib__List.find_opt((function(param) {
|
|
29788
|
+
return param[0] === "mca";
|
|
29789
|
+
}), output_meta);
|
|
29790
|
+
if (match$2 !== void 0) {
|
|
29791
|
+
const mca_text = match$2[1];
|
|
29792
|
+
const mca_id = Curry._1(Stdlib__Printf.sprintf({
|
|
29761
29793
|
TAG: (
|
|
29762
|
-
/*
|
|
29763
|
-
|
|
29794
|
+
/* Format */
|
|
29795
|
+
0
|
|
29764
29796
|
),
|
|
29765
|
-
_0:
|
|
29766
|
-
_1: {
|
|
29797
|
+
_0: {
|
|
29767
29798
|
TAG: (
|
|
29768
|
-
/*
|
|
29769
|
-
|
|
29770
|
-
),
|
|
29771
|
-
_0: (
|
|
29772
|
-
/* No_padding */
|
|
29773
|
-
0
|
|
29799
|
+
/* String_literal */
|
|
29800
|
+
11
|
|
29774
29801
|
),
|
|
29775
|
-
|
|
29776
|
-
|
|
29777
|
-
|
|
29778
|
-
|
|
29779
|
-
|
|
29780
|
-
|
|
29781
|
-
|
|
29782
|
-
|
|
29783
|
-
|
|
29784
|
-
|
|
29785
|
-
|
|
29786
|
-
|
|
29787
|
-
|
|
29788
|
-
|
|
29789
|
-
|
|
29790
|
-
|
|
29791
|
-
|
|
29792
|
-
|
|
29793
|
-
const
|
|
29794
|
-
const content = Fs.readFileSync(file_path, "utf8");
|
|
29795
|
-
const meta = Cn_lib.parse_frontmatter(content);
|
|
29796
|
-
const is_queued = Stdlib__List.exists((function(param) {
|
|
29797
|
-
return param[0] === "queued-for-processing";
|
|
29798
|
-
}), meta);
|
|
29799
|
-
if (is_queued) {
|
|
29800
|
-
return;
|
|
29801
|
-
}
|
|
29802
|
-
const id = Path.basename(file, ".md");
|
|
29803
|
-
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
29804
|
-
if (param[0] === "from") {
|
|
29805
|
-
return param[1];
|
|
29806
|
-
}
|
|
29807
|
-
}), meta), "unknown");
|
|
29808
|
-
queue_add(hub_path, id, from, content);
|
|
29809
|
-
const prim1 = Cn_lib.update_frontmatter(content, {
|
|
29810
|
-
hd: [
|
|
29811
|
-
"queued-for-processing",
|
|
29812
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
29813
|
-
],
|
|
29814
|
-
tl: (
|
|
29815
|
-
/* [] */
|
|
29816
|
-
0
|
|
29817
|
-
)
|
|
29818
|
-
});
|
|
29819
|
-
Fs.writeFileSync(file_path, prim1);
|
|
29820
|
-
const msg = Curry._2(Stdlib__Printf.sprintf({
|
|
29802
|
+
_0: "mca-",
|
|
29803
|
+
_1: {
|
|
29804
|
+
TAG: (
|
|
29805
|
+
/* String */
|
|
29806
|
+
2
|
|
29807
|
+
),
|
|
29808
|
+
_0: (
|
|
29809
|
+
/* No_padding */
|
|
29810
|
+
0
|
|
29811
|
+
),
|
|
29812
|
+
_1: (
|
|
29813
|
+
/* End_of_format */
|
|
29814
|
+
0
|
|
29815
|
+
)
|
|
29816
|
+
}
|
|
29817
|
+
},
|
|
29818
|
+
_1: "mca-%s"
|
|
29819
|
+
}), match2);
|
|
29820
|
+
const mca_content = Curry._4(Stdlib__Printf.sprintf({
|
|
29821
29821
|
TAG: (
|
|
29822
29822
|
/* Format */
|
|
29823
29823
|
0
|
|
@@ -29827,7 +29827,7 @@ function queue_inbox_items(hub_path) {
|
|
|
29827
29827
|
/* String_literal */
|
|
29828
29828
|
11
|
|
29829
29829
|
),
|
|
29830
|
-
_0: "
|
|
29830
|
+
_0: "---\nid: ",
|
|
29831
29831
|
_1: {
|
|
29832
29832
|
TAG: (
|
|
29833
29833
|
/* String */
|
|
@@ -29842,7 +29842,7 @@ function queue_inbox_items(hub_path) {
|
|
|
29842
29842
|
/* String_literal */
|
|
29843
29843
|
11
|
|
29844
29844
|
),
|
|
29845
|
-
_0: "
|
|
29845
|
+
_0: "\ntype: mca-feedback\noriginal: ",
|
|
29846
29846
|
_1: {
|
|
29847
29847
|
TAG: (
|
|
29848
29848
|
/* String */
|
|
@@ -29854,60 +29854,63 @@ function queue_inbox_items(hub_path) {
|
|
|
29854
29854
|
),
|
|
29855
29855
|
_1: {
|
|
29856
29856
|
TAG: (
|
|
29857
|
-
/*
|
|
29858
|
-
|
|
29859
|
-
),
|
|
29860
|
-
_0: (
|
|
29861
|
-
/* ')' */
|
|
29862
|
-
41
|
|
29857
|
+
/* String_literal */
|
|
29858
|
+
11
|
|
29863
29859
|
),
|
|
29864
|
-
|
|
29865
|
-
|
|
29866
|
-
|
|
29867
|
-
|
|
29860
|
+
_0: "\n---\n\n# MCA Reinforcement\n\nYou identified this MCA during processing of ",
|
|
29861
|
+
_1: {
|
|
29862
|
+
TAG: (
|
|
29863
|
+
/* String */
|
|
29864
|
+
2
|
|
29865
|
+
),
|
|
29866
|
+
_0: (
|
|
29867
|
+
/* No_padding */
|
|
29868
|
+
0
|
|
29869
|
+
),
|
|
29870
|
+
_1: {
|
|
29871
|
+
TAG: (
|
|
29872
|
+
/* String_literal */
|
|
29873
|
+
11
|
|
29874
|
+
),
|
|
29875
|
+
_0: ":\n\n> ",
|
|
29876
|
+
_1: {
|
|
29877
|
+
TAG: (
|
|
29878
|
+
/* String */
|
|
29879
|
+
2
|
|
29880
|
+
),
|
|
29881
|
+
_0: (
|
|
29882
|
+
/* No_padding */
|
|
29883
|
+
0
|
|
29884
|
+
),
|
|
29885
|
+
_1: {
|
|
29886
|
+
TAG: (
|
|
29887
|
+
/* String_literal */
|
|
29888
|
+
11
|
|
29889
|
+
),
|
|
29890
|
+
_0: "\n\nApply this pattern next time.\n",
|
|
29891
|
+
_1: (
|
|
29892
|
+
/* End_of_format */
|
|
29893
|
+
0
|
|
29894
|
+
)
|
|
29895
|
+
}
|
|
29896
|
+
}
|
|
29897
|
+
}
|
|
29898
|
+
}
|
|
29868
29899
|
}
|
|
29869
29900
|
}
|
|
29870
29901
|
}
|
|
29871
29902
|
}
|
|
29872
29903
|
},
|
|
29873
|
-
_1: "
|
|
29874
|
-
}),
|
|
29875
|
-
|
|
29876
|
-
|
|
29877
|
-
|
|
29878
|
-
} else {
|
|
29879
|
-
return 0;
|
|
29880
|
-
}
|
|
29881
|
-
}
|
|
29882
|
-
function feed_next_input(hub_path) {
|
|
29883
|
-
const inp = Path.join(hub_path, "state/input.md");
|
|
29884
|
-
const content = queue_pop(hub_path);
|
|
29885
|
-
if (content !== void 0) {
|
|
29886
|
-
ensure_dir(Path.join(hub_path, "state"));
|
|
29887
|
-
Fs.writeFileSync(inp, content);
|
|
29888
|
-
const meta = Cn_lib.parse_frontmatter(content);
|
|
29889
|
-
const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
29890
|
-
if (param[0] === "id") {
|
|
29891
|
-
return param[1];
|
|
29892
|
-
}
|
|
29893
|
-
}), meta), "unknown");
|
|
29894
|
-
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
29895
|
-
if (param[0] === "from") {
|
|
29896
|
-
return param[1];
|
|
29897
|
-
}
|
|
29898
|
-
}), meta), "unknown");
|
|
29899
|
-
log_action(hub_path, "process.feed", Curry._2(Stdlib__Printf.sprintf({
|
|
29900
|
-
TAG: (
|
|
29901
|
-
/* Format */
|
|
29902
|
-
0
|
|
29903
|
-
),
|
|
29904
|
-
_0: {
|
|
29904
|
+
_1: "---\nid: %s\ntype: mca-feedback\noriginal: %s\n---\n\n# MCA Reinforcement\n\nYou identified this MCA during processing of %s:\n\n> %s\n\nApply this pattern next time.\n"
|
|
29905
|
+
}), mca_id, match2, match2, mca_text);
|
|
29906
|
+
const qdir = Path.join(hub_path, "state/queue");
|
|
29907
|
+
ensure_dir(qdir);
|
|
29908
|
+
const qfile = Path.join(qdir, Curry._2(Stdlib__Printf.sprintf({
|
|
29905
29909
|
TAG: (
|
|
29906
|
-
/*
|
|
29907
|
-
|
|
29910
|
+
/* Format */
|
|
29911
|
+
0
|
|
29908
29912
|
),
|
|
29909
|
-
_0:
|
|
29910
|
-
_1: {
|
|
29913
|
+
_0: {
|
|
29911
29914
|
TAG: (
|
|
29912
29915
|
/* String */
|
|
29913
29916
|
2
|
|
@@ -29918,10 +29921,13 @@ function feed_next_input(hub_path) {
|
|
|
29918
29921
|
),
|
|
29919
29922
|
_1: {
|
|
29920
29923
|
TAG: (
|
|
29921
|
-
/*
|
|
29922
|
-
|
|
29924
|
+
/* Char_literal */
|
|
29925
|
+
12
|
|
29926
|
+
),
|
|
29927
|
+
_0: (
|
|
29928
|
+
/* '-' */
|
|
29929
|
+
45
|
|
29923
29930
|
),
|
|
29924
|
-
_0: " from:",
|
|
29925
29931
|
_1: {
|
|
29926
29932
|
TAG: (
|
|
29927
29933
|
/* String */
|
|
@@ -29931,59 +29937,57 @@ function feed_next_input(hub_path) {
|
|
|
29931
29937
|
/* No_padding */
|
|
29932
29938
|
0
|
|
29933
29939
|
),
|
|
29934
|
-
_1:
|
|
29935
|
-
|
|
29936
|
-
|
|
29937
|
-
|
|
29940
|
+
_1: {
|
|
29941
|
+
TAG: (
|
|
29942
|
+
/* String_literal */
|
|
29943
|
+
11
|
|
29944
|
+
),
|
|
29945
|
+
_0: ".md",
|
|
29946
|
+
_1: (
|
|
29947
|
+
/* End_of_format */
|
|
29948
|
+
0
|
|
29949
|
+
)
|
|
29950
|
+
}
|
|
29938
29951
|
}
|
|
29939
29952
|
}
|
|
29940
|
-
}
|
|
29941
|
-
|
|
29942
|
-
|
|
29943
|
-
|
|
29944
|
-
|
|
29945
|
-
TAG: (
|
|
29946
|
-
/* Format */
|
|
29947
|
-
0
|
|
29948
|
-
),
|
|
29949
|
-
_0: {
|
|
29953
|
+
},
|
|
29954
|
+
_1: "%s-%s.md"
|
|
29955
|
+
}), (/* @__PURE__ */ new Date()).toISOString(), mca_id));
|
|
29956
|
+
Fs.writeFileSync(qfile, mca_content);
|
|
29957
|
+
log_action(hub_path, "mca.queued", Curry._2(Stdlib__Printf.sprintf({
|
|
29950
29958
|
TAG: (
|
|
29951
|
-
/*
|
|
29952
|
-
|
|
29959
|
+
/* Format */
|
|
29960
|
+
0
|
|
29953
29961
|
),
|
|
29954
|
-
_0:
|
|
29955
|
-
_1: {
|
|
29962
|
+
_0: {
|
|
29956
29963
|
TAG: (
|
|
29957
|
-
/*
|
|
29958
|
-
|
|
29959
|
-
),
|
|
29960
|
-
_0: (
|
|
29961
|
-
/* No_padding */
|
|
29962
|
-
0
|
|
29964
|
+
/* String_literal */
|
|
29965
|
+
11
|
|
29963
29966
|
),
|
|
29967
|
+
_0: "id:",
|
|
29964
29968
|
_1: {
|
|
29965
29969
|
TAG: (
|
|
29966
|
-
/*
|
|
29967
|
-
|
|
29970
|
+
/* String */
|
|
29971
|
+
2
|
|
29972
|
+
),
|
|
29973
|
+
_0: (
|
|
29974
|
+
/* No_padding */
|
|
29975
|
+
0
|
|
29968
29976
|
),
|
|
29969
|
-
_0: " (from ",
|
|
29970
29977
|
_1: {
|
|
29971
29978
|
TAG: (
|
|
29972
|
-
/*
|
|
29973
|
-
|
|
29974
|
-
),
|
|
29975
|
-
_0: (
|
|
29976
|
-
/* No_padding */
|
|
29977
|
-
0
|
|
29979
|
+
/* String_literal */
|
|
29980
|
+
11
|
|
29978
29981
|
),
|
|
29982
|
+
_0: " mca:",
|
|
29979
29983
|
_1: {
|
|
29980
29984
|
TAG: (
|
|
29981
|
-
/*
|
|
29982
|
-
|
|
29985
|
+
/* String */
|
|
29986
|
+
2
|
|
29983
29987
|
),
|
|
29984
29988
|
_0: (
|
|
29985
|
-
/*
|
|
29986
|
-
|
|
29989
|
+
/* No_padding */
|
|
29990
|
+
0
|
|
29987
29991
|
),
|
|
29988
29992
|
_1: (
|
|
29989
29993
|
/* End_of_format */
|
|
@@ -29992,13 +29996,9 @@ function feed_next_input(hub_path) {
|
|
|
29992
29996
|
}
|
|
29993
29997
|
}
|
|
29994
29998
|
}
|
|
29995
|
-
}
|
|
29996
|
-
|
|
29997
|
-
|
|
29998
|
-
}), id, from);
|
|
29999
|
-
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30000
|
-
const remaining = queue_count(hub_path);
|
|
30001
|
-
if (remaining > 0) {
|
|
29999
|
+
},
|
|
30000
|
+
_1: "id:%s mca:%s"
|
|
30001
|
+
}), match2, mca_text));
|
|
30002
30002
|
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30003
30003
|
TAG: (
|
|
30004
30004
|
/* Format */
|
|
@@ -30009,59 +30009,28 @@ function feed_next_input(hub_path) {
|
|
|
30009
30009
|
/* String_literal */
|
|
30010
30010
|
11
|
|
30011
30011
|
),
|
|
30012
|
-
_0: "
|
|
30012
|
+
_0: "MCA queued for feedback: ",
|
|
30013
30013
|
_1: {
|
|
30014
30014
|
TAG: (
|
|
30015
|
-
/*
|
|
30016
|
-
|
|
30015
|
+
/* String */
|
|
30016
|
+
2
|
|
30017
30017
|
),
|
|
30018
30018
|
_0: (
|
|
30019
|
-
/* Int_d */
|
|
30020
|
-
0
|
|
30021
|
-
),
|
|
30022
|
-
_1: (
|
|
30023
30019
|
/* No_padding */
|
|
30024
30020
|
0
|
|
30025
30021
|
),
|
|
30026
|
-
|
|
30027
|
-
/*
|
|
30022
|
+
_1: (
|
|
30023
|
+
/* End_of_format */
|
|
30028
30024
|
0
|
|
30029
|
-
)
|
|
30030
|
-
_3: {
|
|
30031
|
-
TAG: (
|
|
30032
|
-
/* String_literal */
|
|
30033
|
-
11
|
|
30034
|
-
),
|
|
30035
|
-
_0: " remaining",
|
|
30036
|
-
_1: (
|
|
30037
|
-
/* End_of_format */
|
|
30038
|
-
0
|
|
30039
|
-
)
|
|
30040
|
-
}
|
|
30025
|
+
)
|
|
30041
30026
|
}
|
|
30042
30027
|
},
|
|
30043
|
-
_1: "
|
|
30044
|
-
}),
|
|
30028
|
+
_1: "MCA queued for feedback: %s"
|
|
30029
|
+
}), mca_text)));
|
|
30045
30030
|
}
|
|
30046
|
-
|
|
30047
|
-
|
|
30048
|
-
|
|
30049
|
-
return false;
|
|
30050
|
-
}
|
|
30051
|
-
function wake_agent(param) {
|
|
30052
|
-
console.log(color("36", "Triggering OpenClaw wake..."));
|
|
30053
|
-
const match2 = exec("openclaw system event --text 'input.md ready' --mode now 2>/dev/null");
|
|
30054
|
-
if (match2 !== void 0) {
|
|
30055
|
-
console.log(color("32", "\xE2\x9C\x93 ") + "Wake triggered");
|
|
30056
|
-
} else {
|
|
30057
|
-
console.log(color("33", "\xE2\x9A\xA0 ") + "Wake trigger failed - is OpenClaw running?");
|
|
30058
|
-
}
|
|
30059
|
-
}
|
|
30060
|
-
function run_process(hub_path) {
|
|
30061
|
-
console.log(color("36", "cn process: actor loop..."));
|
|
30062
|
-
const queued = queue_inbox_items(hub_path);
|
|
30063
|
-
if (queued > 0) {
|
|
30064
|
-
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30031
|
+
Fs.unlinkSync(inp);
|
|
30032
|
+
Fs.unlinkSync(outp);
|
|
30033
|
+
log_action(hub_path, "io.archive", Curry._1(Stdlib__Printf.sprintf({
|
|
30065
30034
|
TAG: (
|
|
30066
30035
|
/* Format */
|
|
30067
30036
|
0
|
|
@@ -30071,51 +30040,25 @@ function run_process(hub_path) {
|
|
|
30071
30040
|
/* String_literal */
|
|
30072
30041
|
11
|
|
30073
30042
|
),
|
|
30074
|
-
_0: "
|
|
30043
|
+
_0: "id:",
|
|
30075
30044
|
_1: {
|
|
30076
30045
|
TAG: (
|
|
30077
|
-
/*
|
|
30078
|
-
|
|
30046
|
+
/* String */
|
|
30047
|
+
2
|
|
30079
30048
|
),
|
|
30080
30049
|
_0: (
|
|
30081
|
-
/* Int_d */
|
|
30082
|
-
0
|
|
30083
|
-
),
|
|
30084
|
-
_1: (
|
|
30085
30050
|
/* No_padding */
|
|
30086
30051
|
0
|
|
30087
30052
|
),
|
|
30088
|
-
|
|
30089
|
-
/*
|
|
30053
|
+
_1: (
|
|
30054
|
+
/* End_of_format */
|
|
30090
30055
|
0
|
|
30091
|
-
)
|
|
30092
|
-
_3: {
|
|
30093
|
-
TAG: (
|
|
30094
|
-
/* String_literal */
|
|
30095
|
-
11
|
|
30096
|
-
),
|
|
30097
|
-
_0: " item(s) to queue",
|
|
30098
|
-
_1: (
|
|
30099
|
-
/* End_of_format */
|
|
30100
|
-
0
|
|
30101
|
-
)
|
|
30102
|
-
}
|
|
30056
|
+
)
|
|
30103
30057
|
}
|
|
30104
30058
|
},
|
|
30105
|
-
_1: "
|
|
30106
|
-
}),
|
|
30107
|
-
|
|
30108
|
-
const inp = Path.join(hub_path, "state/input.md");
|
|
30109
|
-
const outp = Path.join(hub_path, "state/output.md");
|
|
30110
|
-
if (Fs.existsSync(inp) && Fs.existsSync(outp)) {
|
|
30111
|
-
if (archive_io_pair(hub_path) && feed_next_input(hub_path)) {
|
|
30112
|
-
return wake_agent(void 0);
|
|
30113
|
-
} else {
|
|
30114
|
-
return;
|
|
30115
|
-
}
|
|
30116
|
-
} else if (Fs.existsSync(inp)) {
|
|
30117
|
-
console.log(color("36", "Agent working (input.md exists, awaiting output.md)"));
|
|
30118
|
-
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30059
|
+
_1: "id:%s"
|
|
30060
|
+
}), match2));
|
|
30061
|
+
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
30119
30062
|
TAG: (
|
|
30120
30063
|
/* Format */
|
|
30121
30064
|
0
|
|
@@ -30125,70 +30068,552 @@ function run_process(hub_path) {
|
|
|
30125
30068
|
/* String_literal */
|
|
30126
30069
|
11
|
|
30127
30070
|
),
|
|
30128
|
-
_0: "
|
|
30071
|
+
_0: "Archived IO pair: ",
|
|
30129
30072
|
_1: {
|
|
30130
30073
|
TAG: (
|
|
30131
|
-
/*
|
|
30132
|
-
|
|
30074
|
+
/* String */
|
|
30075
|
+
2
|
|
30133
30076
|
),
|
|
30134
30077
|
_0: (
|
|
30135
|
-
/* Int_d */
|
|
30136
|
-
0
|
|
30137
|
-
),
|
|
30138
|
-
_1: (
|
|
30139
30078
|
/* No_padding */
|
|
30140
30079
|
0
|
|
30141
30080
|
),
|
|
30142
|
-
|
|
30143
|
-
/* No_precision */
|
|
30144
|
-
0
|
|
30145
|
-
),
|
|
30146
|
-
_3: (
|
|
30081
|
+
_1: (
|
|
30147
30082
|
/* End_of_format */
|
|
30148
30083
|
0
|
|
30149
30084
|
)
|
|
30150
30085
|
}
|
|
30151
30086
|
},
|
|
30152
|
-
_1: "
|
|
30153
|
-
}),
|
|
30154
|
-
|
|
30155
|
-
|
|
30156
|
-
return wake_agent(void 0);
|
|
30157
|
-
} else {
|
|
30158
|
-
return;
|
|
30087
|
+
_1: "Archived IO pair: %s"
|
|
30088
|
+
}), match2);
|
|
30089
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30090
|
+
return true;
|
|
30159
30091
|
}
|
|
30092
|
+
console.log(color("31", "\xE2\x9C\x97 ") + "ID mismatch between input.md and output.md");
|
|
30093
|
+
return false;
|
|
30160
30094
|
}
|
|
30161
|
-
function
|
|
30162
|
-
|
|
30163
|
-
|
|
30164
|
-
|
|
30165
|
-
|
|
30166
|
-
|
|
30167
|
-
|
|
30168
|
-
|
|
30169
|
-
|
|
30170
|
-
|
|
30171
|
-
|
|
30172
|
-
|
|
30173
|
-
|
|
30174
|
-
|
|
30175
|
-
)
|
|
30176
|
-
|
|
30177
|
-
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30095
|
+
function queue_inbox_items(hub_path) {
|
|
30096
|
+
const inbox_dir = Path.join(hub_path, "threads/inbox");
|
|
30097
|
+
if (Fs.existsSync(inbox_dir)) {
|
|
30098
|
+
return Stdlib__List.length(Stdlib__List.filter_map((function(file) {
|
|
30099
|
+
const file_path = Path.join(inbox_dir, file);
|
|
30100
|
+
const content = Fs.readFileSync(file_path, "utf8");
|
|
30101
|
+
const meta = Cn_lib.parse_frontmatter(content);
|
|
30102
|
+
const is_queued = Stdlib__List.exists((function(param) {
|
|
30103
|
+
return param[0] === "queued-for-processing";
|
|
30104
|
+
}), meta);
|
|
30105
|
+
if (is_queued) {
|
|
30106
|
+
return;
|
|
30107
|
+
}
|
|
30108
|
+
const id = Path.basename(file, ".md");
|
|
30109
|
+
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30110
|
+
if (param[0] === "from") {
|
|
30111
|
+
return param[1];
|
|
30112
|
+
}
|
|
30113
|
+
}), meta), "unknown");
|
|
30114
|
+
queue_add(hub_path, id, from, content);
|
|
30115
|
+
const prim1 = Cn_lib.update_frontmatter(content, {
|
|
30116
|
+
hd: [
|
|
30117
|
+
"queued-for-processing",
|
|
30118
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
30119
|
+
],
|
|
30120
|
+
tl: (
|
|
30121
|
+
/* [] */
|
|
30122
|
+
0
|
|
30123
|
+
)
|
|
30124
|
+
});
|
|
30125
|
+
Fs.writeFileSync(file_path, prim1);
|
|
30126
|
+
const msg = Curry._2(Stdlib__Printf.sprintf({
|
|
30127
|
+
TAG: (
|
|
30128
|
+
/* Format */
|
|
30129
|
+
0
|
|
30130
|
+
),
|
|
30131
|
+
_0: {
|
|
30132
|
+
TAG: (
|
|
30133
|
+
/* String_literal */
|
|
30134
|
+
11
|
|
30135
|
+
),
|
|
30136
|
+
_0: "Queued: ",
|
|
30137
|
+
_1: {
|
|
30138
|
+
TAG: (
|
|
30139
|
+
/* String */
|
|
30140
|
+
2
|
|
30141
|
+
),
|
|
30142
|
+
_0: (
|
|
30143
|
+
/* No_padding */
|
|
30144
|
+
0
|
|
30145
|
+
),
|
|
30146
|
+
_1: {
|
|
30147
|
+
TAG: (
|
|
30148
|
+
/* String_literal */
|
|
30149
|
+
11
|
|
30150
|
+
),
|
|
30151
|
+
_0: " (from ",
|
|
30152
|
+
_1: {
|
|
30153
|
+
TAG: (
|
|
30154
|
+
/* String */
|
|
30155
|
+
2
|
|
30156
|
+
),
|
|
30157
|
+
_0: (
|
|
30158
|
+
/* No_padding */
|
|
30159
|
+
0
|
|
30160
|
+
),
|
|
30161
|
+
_1: {
|
|
30162
|
+
TAG: (
|
|
30163
|
+
/* Char_literal */
|
|
30164
|
+
12
|
|
30165
|
+
),
|
|
30166
|
+
_0: (
|
|
30167
|
+
/* ')' */
|
|
30168
|
+
41
|
|
30169
|
+
),
|
|
30170
|
+
_1: (
|
|
30171
|
+
/* End_of_format */
|
|
30172
|
+
0
|
|
30173
|
+
)
|
|
30174
|
+
}
|
|
30175
|
+
}
|
|
30176
|
+
}
|
|
30177
|
+
}
|
|
30178
|
+
},
|
|
30179
|
+
_1: "Queued: %s (from %s)"
|
|
30180
|
+
}), id, from);
|
|
30181
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30182
|
+
return file;
|
|
30183
|
+
}), Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(inbox_dir)))));
|
|
30184
|
+
} else {
|
|
30185
|
+
return 0;
|
|
30186
|
+
}
|
|
30187
|
+
}
|
|
30188
|
+
function feed_next_input(hub_path) {
|
|
30189
|
+
const inp = Path.join(hub_path, "state/input.md");
|
|
30190
|
+
const content = queue_pop(hub_path);
|
|
30191
|
+
if (content !== void 0) {
|
|
30192
|
+
ensure_dir(Path.join(hub_path, "state"));
|
|
30193
|
+
Fs.writeFileSync(inp, content);
|
|
30194
|
+
const meta = Cn_lib.parse_frontmatter(content);
|
|
30195
|
+
const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30196
|
+
if (param[0] === "id") {
|
|
30197
|
+
return param[1];
|
|
30198
|
+
}
|
|
30199
|
+
}), meta), "unknown");
|
|
30200
|
+
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30201
|
+
if (param[0] === "from") {
|
|
30202
|
+
return param[1];
|
|
30203
|
+
}
|
|
30204
|
+
}), meta), "unknown");
|
|
30205
|
+
log_action(hub_path, "process.feed", Curry._2(Stdlib__Printf.sprintf({
|
|
30206
|
+
TAG: (
|
|
30207
|
+
/* Format */
|
|
30208
|
+
0
|
|
30209
|
+
),
|
|
30210
|
+
_0: {
|
|
30211
|
+
TAG: (
|
|
30212
|
+
/* String_literal */
|
|
30213
|
+
11
|
|
30214
|
+
),
|
|
30215
|
+
_0: "id:",
|
|
30216
|
+
_1: {
|
|
30217
|
+
TAG: (
|
|
30218
|
+
/* String */
|
|
30219
|
+
2
|
|
30220
|
+
),
|
|
30221
|
+
_0: (
|
|
30222
|
+
/* No_padding */
|
|
30223
|
+
0
|
|
30224
|
+
),
|
|
30225
|
+
_1: {
|
|
30226
|
+
TAG: (
|
|
30227
|
+
/* String_literal */
|
|
30228
|
+
11
|
|
30229
|
+
),
|
|
30230
|
+
_0: " from:",
|
|
30231
|
+
_1: {
|
|
30232
|
+
TAG: (
|
|
30233
|
+
/* String */
|
|
30234
|
+
2
|
|
30235
|
+
),
|
|
30236
|
+
_0: (
|
|
30237
|
+
/* No_padding */
|
|
30238
|
+
0
|
|
30239
|
+
),
|
|
30240
|
+
_1: (
|
|
30241
|
+
/* End_of_format */
|
|
30242
|
+
0
|
|
30243
|
+
)
|
|
30244
|
+
}
|
|
30245
|
+
}
|
|
30246
|
+
}
|
|
30247
|
+
},
|
|
30248
|
+
_1: "id:%s from:%s"
|
|
30249
|
+
}), id, from));
|
|
30250
|
+
const msg = Curry._2(Stdlib__Printf.sprintf({
|
|
30251
|
+
TAG: (
|
|
30252
|
+
/* Format */
|
|
30253
|
+
0
|
|
30254
|
+
),
|
|
30255
|
+
_0: {
|
|
30256
|
+
TAG: (
|
|
30257
|
+
/* String_literal */
|
|
30258
|
+
11
|
|
30259
|
+
),
|
|
30260
|
+
_0: "Wrote state/input.md: ",
|
|
30261
|
+
_1: {
|
|
30262
|
+
TAG: (
|
|
30263
|
+
/* String */
|
|
30264
|
+
2
|
|
30265
|
+
),
|
|
30266
|
+
_0: (
|
|
30267
|
+
/* No_padding */
|
|
30268
|
+
0
|
|
30269
|
+
),
|
|
30270
|
+
_1: {
|
|
30271
|
+
TAG: (
|
|
30272
|
+
/* String_literal */
|
|
30273
|
+
11
|
|
30274
|
+
),
|
|
30275
|
+
_0: " (from ",
|
|
30276
|
+
_1: {
|
|
30277
|
+
TAG: (
|
|
30278
|
+
/* String */
|
|
30279
|
+
2
|
|
30280
|
+
),
|
|
30281
|
+
_0: (
|
|
30282
|
+
/* No_padding */
|
|
30283
|
+
0
|
|
30284
|
+
),
|
|
30285
|
+
_1: {
|
|
30286
|
+
TAG: (
|
|
30287
|
+
/* Char_literal */
|
|
30288
|
+
12
|
|
30289
|
+
),
|
|
30290
|
+
_0: (
|
|
30291
|
+
/* ')' */
|
|
30292
|
+
41
|
|
30293
|
+
),
|
|
30294
|
+
_1: (
|
|
30295
|
+
/* End_of_format */
|
|
30296
|
+
0
|
|
30297
|
+
)
|
|
30298
|
+
}
|
|
30299
|
+
}
|
|
30300
|
+
}
|
|
30301
|
+
}
|
|
30302
|
+
},
|
|
30303
|
+
_1: "Wrote state/input.md: %s (from %s)"
|
|
30304
|
+
}), id, from);
|
|
30305
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30306
|
+
const remaining = queue_count(hub_path);
|
|
30307
|
+
if (remaining > 0) {
|
|
30308
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30309
|
+
TAG: (
|
|
30310
|
+
/* Format */
|
|
30311
|
+
0
|
|
30312
|
+
),
|
|
30313
|
+
_0: {
|
|
30314
|
+
TAG: (
|
|
30315
|
+
/* String_literal */
|
|
30316
|
+
11
|
|
30317
|
+
),
|
|
30318
|
+
_0: "Queue depth: ",
|
|
30319
|
+
_1: {
|
|
30320
|
+
TAG: (
|
|
30321
|
+
/* Int */
|
|
30322
|
+
4
|
|
30323
|
+
),
|
|
30324
|
+
_0: (
|
|
30325
|
+
/* Int_d */
|
|
30326
|
+
0
|
|
30327
|
+
),
|
|
30328
|
+
_1: (
|
|
30329
|
+
/* No_padding */
|
|
30330
|
+
0
|
|
30331
|
+
),
|
|
30332
|
+
_2: (
|
|
30333
|
+
/* No_precision */
|
|
30334
|
+
0
|
|
30335
|
+
),
|
|
30336
|
+
_3: {
|
|
30337
|
+
TAG: (
|
|
30338
|
+
/* String_literal */
|
|
30339
|
+
11
|
|
30340
|
+
),
|
|
30341
|
+
_0: " remaining",
|
|
30342
|
+
_1: (
|
|
30343
|
+
/* End_of_format */
|
|
30344
|
+
0
|
|
30345
|
+
)
|
|
30346
|
+
}
|
|
30347
|
+
}
|
|
30348
|
+
},
|
|
30349
|
+
_1: "Queue depth: %d remaining"
|
|
30350
|
+
}), remaining)));
|
|
30351
|
+
}
|
|
30352
|
+
return true;
|
|
30353
|
+
}
|
|
30354
|
+
console.log(color("32", "\xE2\x9C\x93 ") + "Queue empty - nothing to process");
|
|
30355
|
+
return false;
|
|
30356
|
+
}
|
|
30357
|
+
function wake_agent(param) {
|
|
30358
|
+
console.log(color("36", "Triggering OpenClaw wake..."));
|
|
30359
|
+
const match2 = exec("openclaw system event --text 'input.md ready' --mode now 2>/dev/null");
|
|
30360
|
+
if (match2 !== void 0) {
|
|
30361
|
+
console.log(color("32", "\xE2\x9C\x93 ") + "Wake triggered");
|
|
30362
|
+
} else {
|
|
30363
|
+
console.log(color("33", "\xE2\x9A\xA0 ") + "Wake trigger failed - is OpenClaw running?");
|
|
30364
|
+
}
|
|
30365
|
+
}
|
|
30366
|
+
function run_process(hub_path) {
|
|
30367
|
+
console.log(color("36", "cn process: actor loop..."));
|
|
30368
|
+
const queued = queue_inbox_items(hub_path);
|
|
30369
|
+
if (queued > 0) {
|
|
30370
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30371
|
+
TAG: (
|
|
30372
|
+
/* Format */
|
|
30373
|
+
0
|
|
30374
|
+
),
|
|
30375
|
+
_0: {
|
|
30376
|
+
TAG: (
|
|
30377
|
+
/* String_literal */
|
|
30378
|
+
11
|
|
30379
|
+
),
|
|
30380
|
+
_0: "Added ",
|
|
30381
|
+
_1: {
|
|
30382
|
+
TAG: (
|
|
30383
|
+
/* Int */
|
|
30384
|
+
4
|
|
30385
|
+
),
|
|
30386
|
+
_0: (
|
|
30387
|
+
/* Int_d */
|
|
30388
|
+
0
|
|
30389
|
+
),
|
|
30390
|
+
_1: (
|
|
30391
|
+
/* No_padding */
|
|
30392
|
+
0
|
|
30393
|
+
),
|
|
30394
|
+
_2: (
|
|
30395
|
+
/* No_precision */
|
|
30396
|
+
0
|
|
30397
|
+
),
|
|
30398
|
+
_3: {
|
|
30399
|
+
TAG: (
|
|
30400
|
+
/* String_literal */
|
|
30401
|
+
11
|
|
30402
|
+
),
|
|
30403
|
+
_0: " item(s) to queue",
|
|
30404
|
+
_1: (
|
|
30405
|
+
/* End_of_format */
|
|
30406
|
+
0
|
|
30407
|
+
)
|
|
30408
|
+
}
|
|
30409
|
+
}
|
|
30410
|
+
},
|
|
30411
|
+
_1: "Added %d item(s) to queue"
|
|
30412
|
+
}), queued)));
|
|
30413
|
+
}
|
|
30414
|
+
const inp = Path.join(hub_path, "state/input.md");
|
|
30415
|
+
const outp = Path.join(hub_path, "state/output.md");
|
|
30416
|
+
if (Fs.existsSync(inp) && Fs.existsSync(outp)) {
|
|
30417
|
+
if (archive_io_pair(hub_path) && feed_next_input(hub_path)) {
|
|
30418
|
+
return wake_agent(void 0);
|
|
30419
|
+
} else {
|
|
30420
|
+
return;
|
|
30421
|
+
}
|
|
30422
|
+
} else if (Fs.existsSync(inp)) {
|
|
30423
|
+
console.log(color("36", "Agent working (input.md exists, awaiting output.md)"));
|
|
30424
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30425
|
+
TAG: (
|
|
30426
|
+
/* Format */
|
|
30427
|
+
0
|
|
30428
|
+
),
|
|
30429
|
+
_0: {
|
|
30430
|
+
TAG: (
|
|
30431
|
+
/* String_literal */
|
|
30432
|
+
11
|
|
30433
|
+
),
|
|
30434
|
+
_0: "Queue depth: ",
|
|
30435
|
+
_1: {
|
|
30436
|
+
TAG: (
|
|
30437
|
+
/* Int */
|
|
30438
|
+
4
|
|
30439
|
+
),
|
|
30440
|
+
_0: (
|
|
30441
|
+
/* Int_d */
|
|
30442
|
+
0
|
|
30443
|
+
),
|
|
30444
|
+
_1: (
|
|
30445
|
+
/* No_padding */
|
|
30446
|
+
0
|
|
30447
|
+
),
|
|
30448
|
+
_2: (
|
|
30449
|
+
/* No_precision */
|
|
30450
|
+
0
|
|
30451
|
+
),
|
|
30452
|
+
_3: (
|
|
30453
|
+
/* End_of_format */
|
|
30454
|
+
0
|
|
30455
|
+
)
|
|
30456
|
+
}
|
|
30457
|
+
},
|
|
30458
|
+
_1: "Queue depth: %d"
|
|
30459
|
+
}), queue_count(hub_path))));
|
|
30460
|
+
return;
|
|
30461
|
+
} else if (feed_next_input(hub_path)) {
|
|
30462
|
+
return wake_agent(void 0);
|
|
30463
|
+
} else {
|
|
30464
|
+
return;
|
|
30465
|
+
}
|
|
30466
|
+
}
|
|
30467
|
+
function run_sync(hub_path, name) {
|
|
30468
|
+
console.log(color("36", "Syncing..."));
|
|
30469
|
+
inbox_check(hub_path, name);
|
|
30470
|
+
inbox_process(hub_path);
|
|
30471
|
+
outbox_flush(hub_path, name);
|
|
30472
|
+
console.log(color("32", "\xE2\x9C\x93 ") + "Sync complete");
|
|
30473
|
+
}
|
|
30474
|
+
function run_queue_list(hub_path) {
|
|
30475
|
+
const items = queue_list(hub_path);
|
|
30476
|
+
if (items) {
|
|
30477
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30478
|
+
TAG: (
|
|
30479
|
+
/* Format */
|
|
30480
|
+
0
|
|
30481
|
+
),
|
|
30482
|
+
_0: {
|
|
30483
|
+
TAG: (
|
|
30484
|
+
/* String_literal */
|
|
30485
|
+
11
|
|
30486
|
+
),
|
|
30487
|
+
_0: "Queue depth: ",
|
|
30488
|
+
_1: {
|
|
30489
|
+
TAG: (
|
|
30490
|
+
/* Int */
|
|
30491
|
+
4
|
|
30492
|
+
),
|
|
30493
|
+
_0: (
|
|
30494
|
+
/* Int_d */
|
|
30495
|
+
0
|
|
30496
|
+
),
|
|
30497
|
+
_1: (
|
|
30498
|
+
/* No_padding */
|
|
30499
|
+
0
|
|
30500
|
+
),
|
|
30501
|
+
_2: (
|
|
30502
|
+
/* No_precision */
|
|
30503
|
+
0
|
|
30504
|
+
),
|
|
30505
|
+
_3: (
|
|
30506
|
+
/* End_of_format */
|
|
30507
|
+
0
|
|
30508
|
+
)
|
|
30509
|
+
}
|
|
30510
|
+
},
|
|
30511
|
+
_1: "Queue depth: %d"
|
|
30512
|
+
}), Stdlib__List.length(items))));
|
|
30513
|
+
return Stdlib__List.iter((function(file) {
|
|
30514
|
+
const file_path = Path.join(Path.join(hub_path, "state/queue"), file);
|
|
30515
|
+
const content = Fs.readFileSync(file_path, "utf8");
|
|
30516
|
+
const meta = Cn_lib.parse_frontmatter(content);
|
|
30517
|
+
const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30518
|
+
if (param[0] === "id") {
|
|
30519
|
+
return param[1];
|
|
30520
|
+
}
|
|
30521
|
+
}), meta), "?");
|
|
30522
|
+
const from = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30523
|
+
if (param[0] === "from") {
|
|
30524
|
+
return param[1];
|
|
30525
|
+
}
|
|
30526
|
+
}), meta), "?");
|
|
30527
|
+
console.log(Curry._2(Stdlib__Printf.sprintf({
|
|
30528
|
+
TAG: (
|
|
30529
|
+
/* Format */
|
|
30530
|
+
0
|
|
30531
|
+
),
|
|
30532
|
+
_0: {
|
|
30533
|
+
TAG: (
|
|
30534
|
+
/* String_literal */
|
|
30535
|
+
11
|
|
30536
|
+
),
|
|
30537
|
+
_0: " ",
|
|
30538
|
+
_1: {
|
|
30539
|
+
TAG: (
|
|
30540
|
+
/* String */
|
|
30541
|
+
2
|
|
30542
|
+
),
|
|
30543
|
+
_0: (
|
|
30544
|
+
/* No_padding */
|
|
30545
|
+
0
|
|
30546
|
+
),
|
|
30547
|
+
_1: {
|
|
30548
|
+
TAG: (
|
|
30549
|
+
/* String_literal */
|
|
30550
|
+
11
|
|
30551
|
+
),
|
|
30552
|
+
_0: " (from ",
|
|
30553
|
+
_1: {
|
|
30554
|
+
TAG: (
|
|
30555
|
+
/* String */
|
|
30556
|
+
2
|
|
30557
|
+
),
|
|
30558
|
+
_0: (
|
|
30559
|
+
/* No_padding */
|
|
30560
|
+
0
|
|
30561
|
+
),
|
|
30562
|
+
_1: {
|
|
30563
|
+
TAG: (
|
|
30564
|
+
/* Char_literal */
|
|
30565
|
+
12
|
|
30566
|
+
),
|
|
30567
|
+
_0: (
|
|
30568
|
+
/* ')' */
|
|
30569
|
+
41
|
|
30570
|
+
),
|
|
30571
|
+
_1: (
|
|
30572
|
+
/* End_of_format */
|
|
30573
|
+
0
|
|
30574
|
+
)
|
|
30575
|
+
}
|
|
30576
|
+
}
|
|
30577
|
+
}
|
|
30578
|
+
}
|
|
30579
|
+
},
|
|
30580
|
+
_1: " %s (from %s)"
|
|
30581
|
+
}), id, from));
|
|
30582
|
+
}), items);
|
|
30583
|
+
} else {
|
|
30584
|
+
console.log("(queue empty)");
|
|
30585
|
+
return;
|
|
30586
|
+
}
|
|
30587
|
+
}
|
|
30588
|
+
function run_queue_clear(hub_path) {
|
|
30589
|
+
const dir = Path.join(hub_path, "state/queue");
|
|
30590
|
+
if (Fs.existsSync(dir)) {
|
|
30591
|
+
const items = Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir)));
|
|
30592
|
+
Stdlib__List.iter((function(file) {
|
|
30593
|
+
const prim = Path.join(dir, file);
|
|
30594
|
+
Fs.unlinkSync(prim);
|
|
30595
|
+
}), items);
|
|
30596
|
+
log_action(hub_path, "queue.clear", Curry._1(Stdlib__Printf.sprintf({
|
|
30597
|
+
TAG: (
|
|
30598
|
+
/* Format */
|
|
30599
|
+
0
|
|
30600
|
+
),
|
|
30601
|
+
_0: {
|
|
30602
|
+
TAG: (
|
|
30603
|
+
/* String_literal */
|
|
30604
|
+
11
|
|
30605
|
+
),
|
|
30606
|
+
_0: "count:",
|
|
30607
|
+
_1: {
|
|
30608
|
+
TAG: (
|
|
30609
|
+
/* Int */
|
|
30610
|
+
4
|
|
30611
|
+
),
|
|
30612
|
+
_0: (
|
|
30613
|
+
/* Int_d */
|
|
30614
|
+
0
|
|
30615
|
+
),
|
|
30616
|
+
_1: (
|
|
30192
30617
|
/* No_padding */
|
|
30193
30618
|
0
|
|
30194
30619
|
),
|
|
@@ -30202,23 +30627,284 @@ function run_queue_list(hub_path) {
|
|
|
30202
30627
|
)
|
|
30203
30628
|
}
|
|
30204
30629
|
},
|
|
30205
|
-
_1: "
|
|
30206
|
-
}), Stdlib__List.length(items)))
|
|
30207
|
-
|
|
30208
|
-
|
|
30209
|
-
|
|
30210
|
-
|
|
30211
|
-
|
|
30212
|
-
|
|
30213
|
-
|
|
30630
|
+
_1: "count:%d"
|
|
30631
|
+
}), Stdlib__List.length(items)));
|
|
30632
|
+
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
30633
|
+
TAG: (
|
|
30634
|
+
/* Format */
|
|
30635
|
+
0
|
|
30636
|
+
),
|
|
30637
|
+
_0: {
|
|
30638
|
+
TAG: (
|
|
30639
|
+
/* String_literal */
|
|
30640
|
+
11
|
|
30641
|
+
),
|
|
30642
|
+
_0: "Cleared ",
|
|
30643
|
+
_1: {
|
|
30644
|
+
TAG: (
|
|
30645
|
+
/* Int */
|
|
30646
|
+
4
|
|
30647
|
+
),
|
|
30648
|
+
_0: (
|
|
30649
|
+
/* Int_d */
|
|
30650
|
+
0
|
|
30651
|
+
),
|
|
30652
|
+
_1: (
|
|
30653
|
+
/* No_padding */
|
|
30654
|
+
0
|
|
30655
|
+
),
|
|
30656
|
+
_2: (
|
|
30657
|
+
/* No_precision */
|
|
30658
|
+
0
|
|
30659
|
+
),
|
|
30660
|
+
_3: {
|
|
30661
|
+
TAG: (
|
|
30662
|
+
/* String_literal */
|
|
30663
|
+
11
|
|
30664
|
+
),
|
|
30665
|
+
_0: " item(s) from queue",
|
|
30666
|
+
_1: (
|
|
30667
|
+
/* End_of_format */
|
|
30668
|
+
0
|
|
30669
|
+
)
|
|
30670
|
+
}
|
|
30214
30671
|
}
|
|
30215
|
-
}
|
|
30216
|
-
|
|
30217
|
-
|
|
30218
|
-
|
|
30672
|
+
},
|
|
30673
|
+
_1: "Cleared %d item(s) from queue"
|
|
30674
|
+
}), Stdlib__List.length(items));
|
|
30675
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30676
|
+
return;
|
|
30677
|
+
}
|
|
30678
|
+
console.log(color("32", "\xE2\x9C\x93 ") + "Queue already empty");
|
|
30679
|
+
}
|
|
30680
|
+
function mca_dir(hub_path) {
|
|
30681
|
+
return Path.join(hub_path, "state/mca");
|
|
30682
|
+
}
|
|
30683
|
+
function run_mca_add(hub_path, name, description) {
|
|
30684
|
+
const dir = Path.join(hub_path, "state/mca");
|
|
30685
|
+
ensure_dir(dir);
|
|
30686
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
30687
|
+
const slug = description.slice(0, 40).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
30688
|
+
const file_name = Curry._2(Stdlib__Printf.sprintf({
|
|
30689
|
+
TAG: (
|
|
30690
|
+
/* Format */
|
|
30691
|
+
0
|
|
30692
|
+
),
|
|
30693
|
+
_0: {
|
|
30694
|
+
TAG: (
|
|
30695
|
+
/* String */
|
|
30696
|
+
2
|
|
30697
|
+
),
|
|
30698
|
+
_0: (
|
|
30699
|
+
/* No_padding */
|
|
30700
|
+
0
|
|
30701
|
+
),
|
|
30702
|
+
_1: {
|
|
30703
|
+
TAG: (
|
|
30704
|
+
/* Char_literal */
|
|
30705
|
+
12
|
|
30706
|
+
),
|
|
30707
|
+
_0: (
|
|
30708
|
+
/* '-' */
|
|
30709
|
+
45
|
|
30710
|
+
),
|
|
30711
|
+
_1: {
|
|
30712
|
+
TAG: (
|
|
30713
|
+
/* String */
|
|
30714
|
+
2
|
|
30715
|
+
),
|
|
30716
|
+
_0: (
|
|
30717
|
+
/* No_padding */
|
|
30718
|
+
0
|
|
30719
|
+
),
|
|
30720
|
+
_1: {
|
|
30721
|
+
TAG: (
|
|
30722
|
+
/* String_literal */
|
|
30723
|
+
11
|
|
30724
|
+
),
|
|
30725
|
+
_0: ".md",
|
|
30726
|
+
_1: (
|
|
30727
|
+
/* End_of_format */
|
|
30728
|
+
0
|
|
30729
|
+
)
|
|
30730
|
+
}
|
|
30219
30731
|
}
|
|
30220
|
-
}
|
|
30221
|
-
|
|
30732
|
+
}
|
|
30733
|
+
},
|
|
30734
|
+
_1: "%s-%s.md"
|
|
30735
|
+
}), ts, slug);
|
|
30736
|
+
const file_path = Path.join(dir, file_name);
|
|
30737
|
+
const content = Curry._4(Stdlib__Printf.sprintf({
|
|
30738
|
+
TAG: (
|
|
30739
|
+
/* Format */
|
|
30740
|
+
0
|
|
30741
|
+
),
|
|
30742
|
+
_0: {
|
|
30743
|
+
TAG: (
|
|
30744
|
+
/* String_literal */
|
|
30745
|
+
11
|
|
30746
|
+
),
|
|
30747
|
+
_0: "---\nid: ",
|
|
30748
|
+
_1: {
|
|
30749
|
+
TAG: (
|
|
30750
|
+
/* String */
|
|
30751
|
+
2
|
|
30752
|
+
),
|
|
30753
|
+
_0: (
|
|
30754
|
+
/* No_padding */
|
|
30755
|
+
0
|
|
30756
|
+
),
|
|
30757
|
+
_1: {
|
|
30758
|
+
TAG: (
|
|
30759
|
+
/* String_literal */
|
|
30760
|
+
11
|
|
30761
|
+
),
|
|
30762
|
+
_0: "\nsurfaced-by: ",
|
|
30763
|
+
_1: {
|
|
30764
|
+
TAG: (
|
|
30765
|
+
/* String */
|
|
30766
|
+
2
|
|
30767
|
+
),
|
|
30768
|
+
_0: (
|
|
30769
|
+
/* No_padding */
|
|
30770
|
+
0
|
|
30771
|
+
),
|
|
30772
|
+
_1: {
|
|
30773
|
+
TAG: (
|
|
30774
|
+
/* String_literal */
|
|
30775
|
+
11
|
|
30776
|
+
),
|
|
30777
|
+
_0: "\ncreated: ",
|
|
30778
|
+
_1: {
|
|
30779
|
+
TAG: (
|
|
30780
|
+
/* String */
|
|
30781
|
+
2
|
|
30782
|
+
),
|
|
30783
|
+
_0: (
|
|
30784
|
+
/* No_padding */
|
|
30785
|
+
0
|
|
30786
|
+
),
|
|
30787
|
+
_1: {
|
|
30788
|
+
TAG: (
|
|
30789
|
+
/* String_literal */
|
|
30790
|
+
11
|
|
30791
|
+
),
|
|
30792
|
+
_0: "\nstatus: open\n---\n\n# MCA\n\n",
|
|
30793
|
+
_1: {
|
|
30794
|
+
TAG: (
|
|
30795
|
+
/* String */
|
|
30796
|
+
2
|
|
30797
|
+
),
|
|
30798
|
+
_0: (
|
|
30799
|
+
/* No_padding */
|
|
30800
|
+
0
|
|
30801
|
+
),
|
|
30802
|
+
_1: {
|
|
30803
|
+
TAG: (
|
|
30804
|
+
/* Char_literal */
|
|
30805
|
+
12
|
|
30806
|
+
),
|
|
30807
|
+
_0: (
|
|
30808
|
+
/* '\n' */
|
|
30809
|
+
10
|
|
30810
|
+
),
|
|
30811
|
+
_1: (
|
|
30812
|
+
/* End_of_format */
|
|
30813
|
+
0
|
|
30814
|
+
)
|
|
30815
|
+
}
|
|
30816
|
+
}
|
|
30817
|
+
}
|
|
30818
|
+
}
|
|
30819
|
+
}
|
|
30820
|
+
}
|
|
30821
|
+
}
|
|
30822
|
+
}
|
|
30823
|
+
},
|
|
30824
|
+
_1: "---\nid: %s\nsurfaced-by: %s\ncreated: %s\nstatus: open\n---\n\n# MCA\n\n%s\n"
|
|
30825
|
+
}), slug, name, (/* @__PURE__ */ new Date()).toISOString(), description);
|
|
30826
|
+
Fs.writeFileSync(file_path, content);
|
|
30827
|
+
log_action(hub_path, "mca.add", Curry._2(Stdlib__Printf.sprintf({
|
|
30828
|
+
TAG: (
|
|
30829
|
+
/* Format */
|
|
30830
|
+
0
|
|
30831
|
+
),
|
|
30832
|
+
_0: {
|
|
30833
|
+
TAG: (
|
|
30834
|
+
/* String_literal */
|
|
30835
|
+
11
|
|
30836
|
+
),
|
|
30837
|
+
_0: "id:",
|
|
30838
|
+
_1: {
|
|
30839
|
+
TAG: (
|
|
30840
|
+
/* String */
|
|
30841
|
+
2
|
|
30842
|
+
),
|
|
30843
|
+
_0: (
|
|
30844
|
+
/* No_padding */
|
|
30845
|
+
0
|
|
30846
|
+
),
|
|
30847
|
+
_1: {
|
|
30848
|
+
TAG: (
|
|
30849
|
+
/* String_literal */
|
|
30850
|
+
11
|
|
30851
|
+
),
|
|
30852
|
+
_0: " desc:",
|
|
30853
|
+
_1: {
|
|
30854
|
+
TAG: (
|
|
30855
|
+
/* String */
|
|
30856
|
+
2
|
|
30857
|
+
),
|
|
30858
|
+
_0: (
|
|
30859
|
+
/* No_padding */
|
|
30860
|
+
0
|
|
30861
|
+
),
|
|
30862
|
+
_1: (
|
|
30863
|
+
/* End_of_format */
|
|
30864
|
+
0
|
|
30865
|
+
)
|
|
30866
|
+
}
|
|
30867
|
+
}
|
|
30868
|
+
}
|
|
30869
|
+
},
|
|
30870
|
+
_1: "id:%s desc:%s"
|
|
30871
|
+
}), slug, description));
|
|
30872
|
+
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
30873
|
+
TAG: (
|
|
30874
|
+
/* Format */
|
|
30875
|
+
0
|
|
30876
|
+
),
|
|
30877
|
+
_0: {
|
|
30878
|
+
TAG: (
|
|
30879
|
+
/* String_literal */
|
|
30880
|
+
11
|
|
30881
|
+
),
|
|
30882
|
+
_0: "MCA surfaced: ",
|
|
30883
|
+
_1: {
|
|
30884
|
+
TAG: (
|
|
30885
|
+
/* String */
|
|
30886
|
+
2
|
|
30887
|
+
),
|
|
30888
|
+
_0: (
|
|
30889
|
+
/* No_padding */
|
|
30890
|
+
0
|
|
30891
|
+
),
|
|
30892
|
+
_1: (
|
|
30893
|
+
/* End_of_format */
|
|
30894
|
+
0
|
|
30895
|
+
)
|
|
30896
|
+
}
|
|
30897
|
+
},
|
|
30898
|
+
_1: "MCA surfaced: %s"
|
|
30899
|
+
}), description);
|
|
30900
|
+
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30901
|
+
}
|
|
30902
|
+
function run_mca_list(hub_path) {
|
|
30903
|
+
const dir = Path.join(hub_path, "state/mca");
|
|
30904
|
+
if (Fs.existsSync(dir)) {
|
|
30905
|
+
const items = Stdlib__List.sort(Stdlib__String.compare, Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir))));
|
|
30906
|
+
if (items) {
|
|
30907
|
+
console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
|
|
30222
30908
|
TAG: (
|
|
30223
30909
|
/* Format */
|
|
30224
30910
|
0
|
|
@@ -30228,148 +30914,169 @@ function run_queue_list(hub_path) {
|
|
|
30228
30914
|
/* String_literal */
|
|
30229
30915
|
11
|
|
30230
30916
|
),
|
|
30231
|
-
_0: "
|
|
30917
|
+
_0: "Open MCAs: ",
|
|
30232
30918
|
_1: {
|
|
30233
30919
|
TAG: (
|
|
30234
|
-
/*
|
|
30235
|
-
|
|
30920
|
+
/* Int */
|
|
30921
|
+
4
|
|
30236
30922
|
),
|
|
30237
30923
|
_0: (
|
|
30924
|
+
/* Int_d */
|
|
30925
|
+
0
|
|
30926
|
+
),
|
|
30927
|
+
_1: (
|
|
30238
30928
|
/* No_padding */
|
|
30239
30929
|
0
|
|
30240
30930
|
),
|
|
30931
|
+
_2: (
|
|
30932
|
+
/* No_precision */
|
|
30933
|
+
0
|
|
30934
|
+
),
|
|
30935
|
+
_3: (
|
|
30936
|
+
/* End_of_format */
|
|
30937
|
+
0
|
|
30938
|
+
)
|
|
30939
|
+
}
|
|
30940
|
+
},
|
|
30941
|
+
_1: "Open MCAs: %d"
|
|
30942
|
+
}), Stdlib__List.length(items))));
|
|
30943
|
+
return Stdlib__List.iter((function(file) {
|
|
30944
|
+
const file_path = Path.join(dir, file);
|
|
30945
|
+
const content = Fs.readFileSync(file_path, "utf8");
|
|
30946
|
+
const meta = Cn_lib.parse_frontmatter(content);
|
|
30947
|
+
const id = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30948
|
+
if (param[0] === "id") {
|
|
30949
|
+
return param[1];
|
|
30950
|
+
}
|
|
30951
|
+
}), meta), "?");
|
|
30952
|
+
const by = Stdlib__Option.value(Stdlib__List.find_map((function(param) {
|
|
30953
|
+
if (param[0] === "surfaced-by") {
|
|
30954
|
+
return param[1];
|
|
30955
|
+
}
|
|
30956
|
+
}), meta), "?");
|
|
30957
|
+
const lines = Stdlib__String.split_on_char(
|
|
30958
|
+
/* '\n' */
|
|
30959
|
+
10,
|
|
30960
|
+
content
|
|
30961
|
+
);
|
|
30962
|
+
const skip_frontmatter = function(_in_fm, _rest) {
|
|
30963
|
+
while (true) {
|
|
30964
|
+
const rest = _rest;
|
|
30965
|
+
const in_fm = _in_fm;
|
|
30966
|
+
if (!rest) {
|
|
30967
|
+
return (
|
|
30968
|
+
/* [] */
|
|
30969
|
+
0
|
|
30970
|
+
);
|
|
30971
|
+
}
|
|
30972
|
+
if (rest.hd === "---") {
|
|
30973
|
+
const rest$1 = rest.tl;
|
|
30974
|
+
if (in_fm) {
|
|
30975
|
+
if (in_fm) {
|
|
30976
|
+
return rest$1;
|
|
30977
|
+
}
|
|
30978
|
+
} else {
|
|
30979
|
+
_rest = rest$1;
|
|
30980
|
+
_in_fm = true;
|
|
30981
|
+
continue;
|
|
30982
|
+
}
|
|
30983
|
+
}
|
|
30984
|
+
if (!in_fm) {
|
|
30985
|
+
return rest;
|
|
30986
|
+
}
|
|
30987
|
+
_rest = rest.tl;
|
|
30988
|
+
continue;
|
|
30989
|
+
}
|
|
30990
|
+
;
|
|
30991
|
+
};
|
|
30992
|
+
const body_lines = skip_frontmatter(false, lines);
|
|
30993
|
+
const desc = Stdlib__Option.value(Stdlib__List.find_opt((function(l) {
|
|
30994
|
+
const t = Stdlib__String.trim(l);
|
|
30995
|
+
if (t !== "") {
|
|
30996
|
+
return !Cn_lib.starts_with("#", t);
|
|
30997
|
+
} else {
|
|
30998
|
+
return false;
|
|
30999
|
+
}
|
|
31000
|
+
}), body_lines), "(no description)");
|
|
31001
|
+
console.log(Curry._3(Stdlib__Printf.sprintf({
|
|
31002
|
+
TAG: (
|
|
31003
|
+
/* Format */
|
|
31004
|
+
0
|
|
31005
|
+
),
|
|
31006
|
+
_0: {
|
|
31007
|
+
TAG: (
|
|
31008
|
+
/* String_literal */
|
|
31009
|
+
11
|
|
31010
|
+
),
|
|
31011
|
+
_0: " [",
|
|
30241
31012
|
_1: {
|
|
30242
31013
|
TAG: (
|
|
30243
|
-
/*
|
|
30244
|
-
|
|
31014
|
+
/* String */
|
|
31015
|
+
2
|
|
31016
|
+
),
|
|
31017
|
+
_0: (
|
|
31018
|
+
/* No_padding */
|
|
31019
|
+
0
|
|
30245
31020
|
),
|
|
30246
|
-
_0: " (from ",
|
|
30247
31021
|
_1: {
|
|
30248
31022
|
TAG: (
|
|
30249
|
-
/*
|
|
30250
|
-
|
|
30251
|
-
),
|
|
30252
|
-
_0: (
|
|
30253
|
-
/* No_padding */
|
|
30254
|
-
0
|
|
31023
|
+
/* String_literal */
|
|
31024
|
+
11
|
|
30255
31025
|
),
|
|
31026
|
+
_0: "] ",
|
|
30256
31027
|
_1: {
|
|
30257
31028
|
TAG: (
|
|
30258
|
-
/*
|
|
30259
|
-
|
|
31029
|
+
/* String */
|
|
31030
|
+
2
|
|
30260
31031
|
),
|
|
30261
31032
|
_0: (
|
|
30262
|
-
/*
|
|
30263
|
-
41
|
|
30264
|
-
),
|
|
30265
|
-
_1: (
|
|
30266
|
-
/* End_of_format */
|
|
31033
|
+
/* No_padding */
|
|
30267
31034
|
0
|
|
30268
|
-
)
|
|
31035
|
+
),
|
|
31036
|
+
_1: {
|
|
31037
|
+
TAG: (
|
|
31038
|
+
/* String_literal */
|
|
31039
|
+
11
|
|
31040
|
+
),
|
|
31041
|
+
_0: " (by ",
|
|
31042
|
+
_1: {
|
|
31043
|
+
TAG: (
|
|
31044
|
+
/* String */
|
|
31045
|
+
2
|
|
31046
|
+
),
|
|
31047
|
+
_0: (
|
|
31048
|
+
/* No_padding */
|
|
31049
|
+
0
|
|
31050
|
+
),
|
|
31051
|
+
_1: {
|
|
31052
|
+
TAG: (
|
|
31053
|
+
/* Char_literal */
|
|
31054
|
+
12
|
|
31055
|
+
),
|
|
31056
|
+
_0: (
|
|
31057
|
+
/* ')' */
|
|
31058
|
+
41
|
|
31059
|
+
),
|
|
31060
|
+
_1: (
|
|
31061
|
+
/* End_of_format */
|
|
31062
|
+
0
|
|
31063
|
+
)
|
|
31064
|
+
}
|
|
31065
|
+
}
|
|
31066
|
+
}
|
|
30269
31067
|
}
|
|
30270
31068
|
}
|
|
30271
31069
|
}
|
|
30272
|
-
}
|
|
30273
|
-
|
|
30274
|
-
|
|
30275
|
-
}),
|
|
30276
|
-
}
|
|
30277
|
-
|
|
30278
|
-
|
|
30279
|
-
|
|
30280
|
-
}
|
|
30281
|
-
}
|
|
30282
|
-
function run_queue_clear(hub_path) {
|
|
30283
|
-
const dir = Path.join(hub_path, "state/queue");
|
|
30284
|
-
if (Fs.existsSync(dir)) {
|
|
30285
|
-
const items = Stdlib__List.filter(is_md_file, Stdlib__Array.to_list(Fs.readdirSync(dir)));
|
|
30286
|
-
Stdlib__List.iter((function(file) {
|
|
30287
|
-
const prim = Path.join(dir, file);
|
|
30288
|
-
Fs.unlinkSync(prim);
|
|
30289
|
-
}), items);
|
|
30290
|
-
log_action(hub_path, "queue.clear", Curry._1(Stdlib__Printf.sprintf({
|
|
30291
|
-
TAG: (
|
|
30292
|
-
/* Format */
|
|
30293
|
-
0
|
|
30294
|
-
),
|
|
30295
|
-
_0: {
|
|
30296
|
-
TAG: (
|
|
30297
|
-
/* String_literal */
|
|
30298
|
-
11
|
|
30299
|
-
),
|
|
30300
|
-
_0: "count:",
|
|
30301
|
-
_1: {
|
|
30302
|
-
TAG: (
|
|
30303
|
-
/* Int */
|
|
30304
|
-
4
|
|
30305
|
-
),
|
|
30306
|
-
_0: (
|
|
30307
|
-
/* Int_d */
|
|
30308
|
-
0
|
|
30309
|
-
),
|
|
30310
|
-
_1: (
|
|
30311
|
-
/* No_padding */
|
|
30312
|
-
0
|
|
30313
|
-
),
|
|
30314
|
-
_2: (
|
|
30315
|
-
/* No_precision */
|
|
30316
|
-
0
|
|
30317
|
-
),
|
|
30318
|
-
_3: (
|
|
30319
|
-
/* End_of_format */
|
|
30320
|
-
0
|
|
30321
|
-
)
|
|
30322
|
-
}
|
|
30323
|
-
},
|
|
30324
|
-
_1: "count:%d"
|
|
30325
|
-
}), Stdlib__List.length(items)));
|
|
30326
|
-
const msg = Curry._1(Stdlib__Printf.sprintf({
|
|
30327
|
-
TAG: (
|
|
30328
|
-
/* Format */
|
|
30329
|
-
0
|
|
30330
|
-
),
|
|
30331
|
-
_0: {
|
|
30332
|
-
TAG: (
|
|
30333
|
-
/* String_literal */
|
|
30334
|
-
11
|
|
30335
|
-
),
|
|
30336
|
-
_0: "Cleared ",
|
|
30337
|
-
_1: {
|
|
30338
|
-
TAG: (
|
|
30339
|
-
/* Int */
|
|
30340
|
-
4
|
|
30341
|
-
),
|
|
30342
|
-
_0: (
|
|
30343
|
-
/* Int_d */
|
|
30344
|
-
0
|
|
30345
|
-
),
|
|
30346
|
-
_1: (
|
|
30347
|
-
/* No_padding */
|
|
30348
|
-
0
|
|
30349
|
-
),
|
|
30350
|
-
_2: (
|
|
30351
|
-
/* No_precision */
|
|
30352
|
-
0
|
|
30353
|
-
),
|
|
30354
|
-
_3: {
|
|
30355
|
-
TAG: (
|
|
30356
|
-
/* String_literal */
|
|
30357
|
-
11
|
|
30358
|
-
),
|
|
30359
|
-
_0: " item(s) from queue",
|
|
30360
|
-
_1: (
|
|
30361
|
-
/* End_of_format */
|
|
30362
|
-
0
|
|
30363
|
-
)
|
|
30364
|
-
}
|
|
30365
|
-
}
|
|
30366
|
-
},
|
|
30367
|
-
_1: "Cleared %d item(s) from queue"
|
|
30368
|
-
}), Stdlib__List.length(items));
|
|
30369
|
-
console.log(color("32", "\xE2\x9C\x93 ") + msg);
|
|
30370
|
-
return;
|
|
31070
|
+
},
|
|
31071
|
+
_1: " [%s] %s (by %s)"
|
|
31072
|
+
}), id, Stdlib__String.trim(desc), by));
|
|
31073
|
+
}), items);
|
|
31074
|
+
} else {
|
|
31075
|
+
console.log("(no MCAs)");
|
|
31076
|
+
return;
|
|
31077
|
+
}
|
|
30371
31078
|
}
|
|
30372
|
-
console.log(
|
|
31079
|
+
console.log("(no MCAs)");
|
|
30373
31080
|
}
|
|
30374
31081
|
function update_runtime(hub_path) {
|
|
30375
31082
|
const runtime_path = Path.join(hub_path, "state/runtime.md");
|
|
@@ -32136,20 +32843,32 @@ if (cmd !== void 0) {
|
|
|
32136
32843
|
run_queue_clear(hub_path$1);
|
|
32137
32844
|
}
|
|
32138
32845
|
break;
|
|
32139
|
-
case /*
|
|
32846
|
+
case /* Mca */
|
|
32140
32847
|
5:
|
|
32848
|
+
const desc = cmd._0;
|
|
32849
|
+
if (
|
|
32850
|
+
/* tag */
|
|
32851
|
+
typeof desc === "number" || typeof desc === "string"
|
|
32852
|
+
) {
|
|
32853
|
+
run_mca_list(hub_path$1);
|
|
32854
|
+
} else {
|
|
32855
|
+
run_mca_add(hub_path$1, name, desc._0);
|
|
32856
|
+
}
|
|
32857
|
+
break;
|
|
32858
|
+
case /* Read */
|
|
32859
|
+
6:
|
|
32141
32860
|
run_read(hub_path$1, cmd._0);
|
|
32142
32861
|
break;
|
|
32143
32862
|
case /* Reply */
|
|
32144
|
-
|
|
32863
|
+
7:
|
|
32145
32864
|
run_reply(hub_path$1, cmd._0, cmd._1);
|
|
32146
32865
|
break;
|
|
32147
32866
|
case /* Send */
|
|
32148
|
-
|
|
32867
|
+
8:
|
|
32149
32868
|
run_send(hub_path$1, cmd._0, cmd._1);
|
|
32150
32869
|
break;
|
|
32151
32870
|
case /* Gtd */
|
|
32152
|
-
|
|
32871
|
+
9:
|
|
32153
32872
|
const t = cmd._0;
|
|
32154
32873
|
switch (t.TAG) {
|
|
32155
32874
|
case /* GtdDelete */
|
|
@@ -32175,11 +32894,11 @@ if (cmd !== void 0) {
|
|
|
32175
32894
|
}
|
|
32176
32895
|
break;
|
|
32177
32896
|
case /* Commit */
|
|
32178
|
-
|
|
32897
|
+
10:
|
|
32179
32898
|
run_commit(hub_path$1, name, cmd._0);
|
|
32180
32899
|
break;
|
|
32181
32900
|
case /* Save */
|
|
32182
|
-
|
|
32901
|
+
11:
|
|
32183
32902
|
run_commit(hub_path$1, name, cmd._0);
|
|
32184
32903
|
run_push(hub_path$1);
|
|
32185
32904
|
break;
|
|
@@ -32295,6 +33014,9 @@ module.exports = {
|
|
|
32295
33014
|
run_sync,
|
|
32296
33015
|
run_queue_list,
|
|
32297
33016
|
run_queue_clear,
|
|
33017
|
+
mca_dir,
|
|
33018
|
+
run_mca_add,
|
|
33019
|
+
run_mca_list,
|
|
32298
33020
|
update_runtime,
|
|
32299
33021
|
run_init,
|
|
32300
33022
|
format_peers_md,
|