cnagent 2.1.22 → 2.2.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tools/dist/cn.js +788 -264
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnagent",
3
- "version": "2.1.22",
3
+ "version": "2.2.0",
4
4
  "description": "Coherent Network agent CLI — everything runs through cn",
5
5
  "keywords": [
6
6
  "cn-agent",
package/tools/dist/cn.js CHANGED
@@ -12128,9 +12128,9 @@ var require_cn_lib = __commonJS({
12128
12128
  case /* Push */
12129
12129
  6:
12130
12130
  return "push";
12131
- case /* Process */
12131
+ case /* Inbound */
12132
12132
  7:
12133
- return "process";
12133
+ return "inbound";
12134
12134
  case /* Update */
12135
12135
  8:
12136
12136
  return "update";
@@ -13057,12 +13057,13 @@ var require_cn_lib = __commonJS({
13057
13057
  _0: c
13058
13058
  };
13059
13059
  }), parse_peer_cmd(param.tl));
13060
+ case "inbound":
13060
13061
  case "process":
13061
13062
  if (param.tl) {
13062
13063
  return;
13063
13064
  } else {
13064
13065
  return (
13065
- /* Process */
13066
+ /* Inbound */
13066
13067
  7
13067
13068
  );
13068
13069
  }
@@ -13592,8 +13593,8 @@ var require_cn_lib = __commonJS({
13592
13593
  10
13593
13594
  );
13594
13595
  }
13595
- 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";
13596
- var version = "2.1.21";
13596
+ 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 inbound Queue inbox \xE2\x86\x92 input.md \xE2\x86\x92 wake agent (alias: 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";
13597
+ var version = "2.2.0";
13597
13598
  module2.exports = {
13598
13599
  starts_with,
13599
13600
  strip_prefix,
@@ -32487,20 +32488,22 @@ function run_mca_list(hub_path) {
32487
32488
  console.log("(no MCAs)");
32488
32489
  }
32489
32490
  function run_out(hub_path, name, gtd) {
32491
+ const start_time = (/* @__PURE__ */ new Date()).toISOString();
32490
32492
  const inp = Path.join(hub_path, "state/input.md");
32491
- const input_meta = Fs.existsSync(inp) ? Cn_lib.parse_frontmatter(Fs.readFileSync(inp, "utf8")) : void 0;
32492
- const input_id = input_meta !== void 0 ? Stdlib__List.find_map((function(param) {
32493
- if (param[0] === "id") {
32494
- return param[1];
32495
- }
32496
- }), input_meta) : void 0;
32497
- const input_from = input_meta !== void 0 ? Stdlib__List.find_map((function(param) {
32498
- if (param[0] === "from") {
32499
- return param[1];
32500
- }
32501
- }), input_meta) : void 0;
32502
32493
  const outp = Path.join(hub_path, "state/output.md");
32503
- const id = Stdlib__Option.value(input_id, "unknown");
32494
+ const input_content = Fs.existsSync(inp) ? Fs.readFileSync(inp, "utf8") : "";
32495
+ const input_meta = input_content !== "" ? Cn_lib.parse_frontmatter(input_content) : void 0;
32496
+ const get_meta = function(key) {
32497
+ if (input_meta !== void 0) {
32498
+ return Stdlib__List.find_map((function(param) {
32499
+ if (param[0] === key) {
32500
+ return param[1];
32501
+ }
32502
+ }), input_meta);
32503
+ }
32504
+ };
32505
+ const id = Stdlib__Option.value(get_meta("id"), "unknown");
32506
+ const from = Stdlib__Option.value(get_meta("from"), "unknown");
32504
32507
  let match2;
32505
32508
  switch (gtd.TAG) {
32506
32509
  case /* Do */
@@ -32509,6 +32512,7 @@ function run_out(hub_path, name, gtd) {
32509
32512
  switch (match$1.TAG) {
32510
32513
  case /* Reply */
32511
32514
  0:
32515
+ const message = match$1.message;
32512
32516
  match2 = [
32513
32517
  "do",
32514
32518
  Curry._1(Stdlib__Printf.sprintf({
@@ -32538,11 +32542,17 @@ function run_out(hub_path, name, gtd) {
32538
32542
  }
32539
32543
  },
32540
32544
  _1: "reply: %s"
32541
- }), match$1.message)
32545
+ }), message),
32546
+ {
32547
+ NAME: "Reply",
32548
+ VAL: message
32549
+ }
32542
32550
  ];
32543
32551
  break;
32544
32552
  case /* Send */
32545
32553
  1:
32554
+ const message$1 = match$1.message;
32555
+ const to_ = match$1.to_;
32546
32556
  match2 = [
32547
32557
  "do",
32548
32558
  Curry._2(Stdlib__Printf.sprintf({
@@ -32592,11 +32602,19 @@ function run_out(hub_path, name, gtd) {
32592
32602
  }
32593
32603
  },
32594
32604
  _1: "send: %s|%s"
32595
- }), match$1.to_, match$1.message)
32605
+ }), to_, message$1),
32606
+ {
32607
+ NAME: "Send",
32608
+ VAL: [
32609
+ to_,
32610
+ message$1
32611
+ ]
32612
+ }
32596
32613
  ];
32597
32614
  break;
32598
32615
  case /* Surface */
32599
32616
  2:
32617
+ const desc = match$1.desc;
32600
32618
  match2 = [
32601
32619
  "do",
32602
32620
  Curry._1(Stdlib__Printf.sprintf({
@@ -32626,7 +32644,11 @@ function run_out(hub_path, name, gtd) {
32626
32644
  }
32627
32645
  },
32628
32646
  _1: "surface: %s"
32629
- }), match$1.desc)
32647
+ }), desc),
32648
+ {
32649
+ NAME: "Surface",
32650
+ VAL: desc
32651
+ }
32630
32652
  ];
32631
32653
  break;
32632
32654
  case /* Noop */
@@ -32660,11 +32682,13 @@ function run_out(hub_path, name, gtd) {
32660
32682
  }
32661
32683
  },
32662
32684
  _1: "noop: %s"
32663
- }), match$1.reason)
32685
+ }), match$1.reason),
32686
+ "Noop"
32664
32687
  ];
32665
32688
  break;
32666
32689
  case /* Commit */
32667
32690
  4:
32691
+ const artifact = match$1.artifact;
32668
32692
  match2 = [
32669
32693
  "do",
32670
32694
  Curry._1(Stdlib__Printf.sprintf({
@@ -32694,7 +32718,11 @@ function run_out(hub_path, name, gtd) {
32694
32718
  }
32695
32719
  },
32696
32720
  _1: "commit: %s"
32697
- }), match$1.artifact)
32721
+ }), artifact),
32722
+ {
32723
+ NAME: "Commit",
32724
+ VAL: artifact
32725
+ }
32698
32726
  ];
32699
32727
  break;
32700
32728
  }
@@ -32730,11 +32758,13 @@ function run_out(hub_path, name, gtd) {
32730
32758
  }
32731
32759
  },
32732
32760
  _1: "reason: %s"
32733
- }), gtd.reason)
32761
+ }), gtd.reason),
32762
+ "Defer"
32734
32763
  ];
32735
32764
  break;
32736
32765
  case /* Delegate */
32737
32766
  2:
32767
+ const to_$1 = gtd.to_;
32738
32768
  match2 = [
32739
32769
  "delegate",
32740
32770
  Curry._1(Stdlib__Printf.sprintf({
@@ -32764,7 +32794,11 @@ function run_out(hub_path, name, gtd) {
32764
32794
  }
32765
32795
  },
32766
32796
  _1: "to: %s"
32767
- }), gtd.to_)
32797
+ }), to_$1),
32798
+ {
32799
+ NAME: "Delegate",
32800
+ VAL: to_$1
32801
+ }
32768
32802
  ];
32769
32803
  break;
32770
32804
  case /* Delete */
@@ -32798,12 +32832,25 @@ function run_out(hub_path, name, gtd) {
32798
32832
  }
32799
32833
  },
32800
32834
  _1: "reason: %s"
32801
- }), gtd.reason)
32835
+ }), gtd.reason),
32836
+ "Delete"
32802
32837
  ];
32803
32838
  break;
32804
32839
  }
32840
+ const op_kind = match2[2];
32805
32841
  const gtd_type = match2[0];
32806
- const content = Curry._4(Stdlib__Printf.sprintf({
32842
+ const run_ts = Stdlib__String.map((function(c) {
32843
+ if (c === /* ':' */
32844
+ 58) {
32845
+ return (
32846
+ /* '-' */
32847
+ 45
32848
+ );
32849
+ } else {
32850
+ return c;
32851
+ }
32852
+ }), start_time);
32853
+ const run_dir = Path.join(hub_path, Curry._2(Stdlib__Printf.sprintf({
32807
32854
  TAG: (
32808
32855
  /* Format */
32809
32856
  0
@@ -32813,7 +32860,7 @@ function run_out(hub_path, name, gtd) {
32813
32860
  /* String_literal */
32814
32861
  11
32815
32862
  ),
32816
- _0: "---\nid: ",
32863
+ _0: "logs/runs/",
32817
32864
  _1: {
32818
32865
  TAG: (
32819
32866
  /* String */
@@ -32825,10 +32872,13 @@ function run_out(hub_path, name, gtd) {
32825
32872
  ),
32826
32873
  _1: {
32827
32874
  TAG: (
32828
- /* String_literal */
32829
- 11
32875
+ /* Char_literal */
32876
+ 12
32877
+ ),
32878
+ _0: (
32879
+ /* '-' */
32880
+ 45
32830
32881
  ),
32831
- _0: "\ngtd: ",
32832
32882
  _1: {
32833
32883
  TAG: (
32834
32884
  /* String */
@@ -32838,87 +32888,73 @@ function run_out(hub_path, name, gtd) {
32838
32888
  /* No_padding */
32839
32889
  0
32840
32890
  ),
32841
- _1: {
32842
- TAG: (
32843
- /* Char_literal */
32844
- 12
32845
- ),
32846
- _0: (
32847
- /* '\n' */
32848
- 10
32849
- ),
32850
- _1: {
32851
- TAG: (
32852
- /* String */
32853
- 2
32854
- ),
32855
- _0: (
32856
- /* No_padding */
32857
- 0
32858
- ),
32859
- _1: {
32860
- TAG: (
32861
- /* String_literal */
32862
- 11
32863
- ),
32864
- _0: "\ncreated: ",
32865
- _1: {
32866
- TAG: (
32867
- /* String */
32868
- 2
32869
- ),
32870
- _0: (
32871
- /* No_padding */
32872
- 0
32873
- ),
32874
- _1: {
32875
- TAG: (
32876
- /* String_literal */
32877
- 11
32878
- ),
32879
- _0: "\n---\n",
32880
- _1: (
32881
- /* End_of_format */
32882
- 0
32883
- )
32884
- }
32885
- }
32886
- }
32887
- }
32888
- }
32891
+ _1: (
32892
+ /* End_of_format */
32893
+ 0
32894
+ )
32889
32895
  }
32890
32896
  }
32891
32897
  }
32892
32898
  },
32893
- _1: "---\nid: %s\ngtd: %s\n%s\ncreated: %s\n---\n"
32894
- }), id, gtd_type, match2[1], (/* @__PURE__ */ new Date()).toISOString());
32895
- Fs.writeFileSync(outp, content);
32896
- log_action(hub_path, "out", Curry._2(Stdlib__Printf.sprintf({
32897
- TAG: (
32898
- /* Format */
32899
- 0
32900
- ),
32901
- _0: {
32899
+ _1: "logs/runs/%s-%s"
32900
+ }), run_ts, id));
32901
+ mkdir_p(run_dir);
32902
+ if (input_content !== "") {
32903
+ const prim0 = Path.join(run_dir, "input.md");
32904
+ Fs.writeFileSync(prim0, input_content);
32905
+ console.log(color("2", Curry._1(Stdlib__Printf.sprintf({
32902
32906
  TAG: (
32903
- /* String_literal */
32904
- 11
32907
+ /* Format */
32908
+ 0
32905
32909
  ),
32906
- _0: "id:",
32907
- _1: {
32910
+ _0: {
32908
32911
  TAG: (
32909
- /* String */
32910
- 2
32912
+ /* String_literal */
32913
+ 11
32911
32914
  ),
32912
- _0: (
32913
- /* No_padding */
32915
+ _0: "Archived input \xE2\x86\x92 ",
32916
+ _1: {
32917
+ TAG: (
32918
+ /* String */
32919
+ 2
32920
+ ),
32921
+ _0: (
32922
+ /* No_padding */
32923
+ 0
32924
+ ),
32925
+ _1: (
32926
+ /* End_of_format */
32927
+ 0
32928
+ )
32929
+ }
32930
+ },
32931
+ _1: "Archived input \xE2\x86\x92 %s"
32932
+ }), run_dir)));
32933
+ }
32934
+ const outbox_dir = Path.join(hub_path, "threads/outbox");
32935
+ ensure_dir(outbox_dir);
32936
+ if (typeof op_kind === "string") {
32937
+ if (op_kind === "Delete") {
32938
+ console.log(color("2", "Deleted - removed from queue"));
32939
+ } else if (op_kind === "Noop") {
32940
+ console.log(color("2", "Noop - no action taken"));
32941
+ } else {
32942
+ console.log(color("2", "Deferred - will resurface later"));
32943
+ }
32944
+ } else {
32945
+ const variant = op_kind.NAME;
32946
+ if (variant === "Commit") {
32947
+ const msg = Curry._1(Stdlib__Printf.sprintf({
32948
+ TAG: (
32949
+ /* Format */
32914
32950
  0
32915
32951
  ),
32916
- _1: {
32952
+ _0: {
32917
32953
  TAG: (
32918
32954
  /* String_literal */
32919
32955
  11
32920
32956
  ),
32921
- _0: " gtd:",
32957
+ _0: "Commit recorded: ",
32922
32958
  _1: {
32923
32959
  TAG: (
32924
32960
  /* String */
@@ -32933,37 +32969,55 @@ function run_out(hub_path, name, gtd) {
32933
32969
  0
32934
32970
  )
32935
32971
  }
32936
- }
32937
- }
32938
- },
32939
- _1: "id:%s gtd:%s"
32940
- }), id, gtd_type));
32941
- const msg = Curry._2(Stdlib__Printf.sprintf({
32942
- TAG: (
32943
- /* Format */
32944
- 0
32945
- ),
32946
- _0: {
32947
- TAG: (
32948
- /* String_literal */
32949
- 11
32950
- ),
32951
- _0: "Output: ",
32952
- _1: {
32972
+ },
32973
+ _1: "Commit recorded: %s"
32974
+ }), op_kind.VAL);
32975
+ console.log(color("32", "\xE2\x9C\x93 ") + msg);
32976
+ } else if (variant === "Surface") {
32977
+ const desc$1 = op_kind.VAL;
32978
+ const mca_dir2 = Path.join(hub_path, "state/mca");
32979
+ mkdir_p(mca_dir2);
32980
+ const mca_file = Curry._1(Stdlib__Printf.sprintf({
32953
32981
  TAG: (
32954
- /* String */
32955
- 2
32982
+ /* Format */
32983
+ 0
32956
32984
  ),
32957
- _0: (
32958
- /* No_padding */
32985
+ _0: {
32986
+ TAG: (
32987
+ /* String */
32988
+ 2
32989
+ ),
32990
+ _0: (
32991
+ /* No_padding */
32992
+ 0
32993
+ ),
32994
+ _1: {
32995
+ TAG: (
32996
+ /* String_literal */
32997
+ 11
32998
+ ),
32999
+ _0: ".md",
33000
+ _1: (
33001
+ /* End_of_format */
33002
+ 0
33003
+ )
33004
+ }
33005
+ },
33006
+ _1: "%s.md"
33007
+ }), id);
33008
+ const prim0$1 = Path.join(mca_dir2, mca_file);
33009
+ Fs.writeFileSync(prim0$1, desc$1);
33010
+ const msg$1 = Curry._1(Stdlib__Printf.sprintf({
33011
+ TAG: (
33012
+ /* Format */
32959
33013
  0
32960
33014
  ),
32961
- _1: {
33015
+ _0: {
32962
33016
  TAG: (
32963
33017
  /* String_literal */
32964
33018
  11
32965
33019
  ),
32966
- _0: " (",
33020
+ _0: "Surfaced MCA: ",
32967
33021
  _1: {
32968
33022
  TAG: (
32969
33023
  /* String */
@@ -32973,59 +33027,27 @@ function run_out(hub_path, name, gtd) {
32973
33027
  /* No_padding */
32974
33028
  0
32975
33029
  ),
32976
- _1: {
32977
- TAG: (
32978
- /* Char_literal */
32979
- 12
32980
- ),
32981
- _0: (
32982
- /* ')' */
32983
- 41
32984
- ),
32985
- _1: (
32986
- /* End_of_format */
32987
- 0
32988
- )
32989
- }
33030
+ _1: (
33031
+ /* End_of_format */
33032
+ 0
33033
+ )
32990
33034
  }
32991
- }
32992
- }
32993
- },
32994
- _1: "Output: %s (%s)"
32995
- }), gtd_type, id);
32996
- console.log(color("32", "\xE2\x9C\x93 ") + msg);
32997
- if (input_from === void 0) {
32998
- return;
32999
- }
33000
- if (!(input_from !== name && input_from !== "system")) {
33001
- return;
33002
- }
33003
- const notify_msg = Curry._3(Stdlib__Printf.sprintf({
33004
- TAG: (
33005
- /* Format */
33006
- 0
33007
- ),
33008
- _0: {
33009
- TAG: (
33010
- /* String_literal */
33011
- 11
33012
- ),
33013
- _0: "[auto] ",
33014
- _1: {
33035
+ },
33036
+ _1: "Surfaced MCA: %s"
33037
+ }), desc$1);
33038
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$1);
33039
+ } else if (variant === "Delegate") {
33040
+ const msg$2 = Curry._1(Stdlib__Printf.sprintf({
33015
33041
  TAG: (
33016
- /* String */
33017
- 2
33018
- ),
33019
- _0: (
33020
- /* No_padding */
33042
+ /* Format */
33021
33043
  0
33022
33044
  ),
33023
- _1: {
33045
+ _0: {
33024
33046
  TAG: (
33025
33047
  /* String_literal */
33026
33048
  11
33027
33049
  ),
33028
- _0: ": ",
33050
+ _0: "Delegated to ",
33029
33051
  _1: {
33030
33052
  TAG: (
33031
33053
  /* String */
@@ -33035,81 +33057,556 @@ function run_out(hub_path, name, gtd) {
33035
33057
  /* No_padding */
33036
33058
  0
33037
33059
  ),
33038
- _1: {
33039
- TAG: (
33040
- /* String_literal */
33041
- 11
33042
- ),
33043
- _0: " on ",
33044
- _1: {
33045
- TAG: (
33046
- /* String */
33047
- 2
33048
- ),
33049
- _0: (
33050
- /* No_padding */
33051
- 0
33052
- ),
33053
- _1: (
33054
- /* End_of_format */
33055
- 0
33056
- )
33057
- }
33058
- }
33059
- }
33060
- }
33061
- }
33060
+ _1: (
33061
+ /* End_of_format */
33062
+ 0
33063
+ )
33064
+ }
33065
+ },
33066
+ _1: "Delegated to %s"
33067
+ }), op_kind.VAL);
33068
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$2);
33069
+ } else if (variant === "Send") {
33070
+ const match$2 = op_kind.VAL;
33071
+ const to_$2 = match$2[0];
33072
+ const send_file = Curry._2(Stdlib__Printf.sprintf({
33073
+ TAG: (
33074
+ /* Format */
33075
+ 0
33076
+ ),
33077
+ _0: {
33078
+ TAG: (
33079
+ /* String */
33080
+ 2
33081
+ ),
33082
+ _0: (
33083
+ /* No_padding */
33084
+ 0
33085
+ ),
33086
+ _1: {
33087
+ TAG: (
33088
+ /* Char_literal */
33089
+ 12
33090
+ ),
33091
+ _0: (
33092
+ /* '-' */
33093
+ 45
33094
+ ),
33095
+ _1: {
33096
+ TAG: (
33097
+ /* String */
33098
+ 2
33099
+ ),
33100
+ _0: (
33101
+ /* No_padding */
33102
+ 0
33103
+ ),
33104
+ _1: {
33105
+ TAG: (
33106
+ /* String_literal */
33107
+ 11
33108
+ ),
33109
+ _0: ".md",
33110
+ _1: (
33111
+ /* End_of_format */
33112
+ 0
33113
+ )
33114
+ }
33115
+ }
33116
+ }
33117
+ },
33118
+ _1: "%s-%s.md"
33119
+ }), to_$2, id);
33120
+ const send_content = Curry._3(Stdlib__Printf.sprintf({
33121
+ TAG: (
33122
+ /* Format */
33123
+ 0
33124
+ ),
33125
+ _0: {
33126
+ TAG: (
33127
+ /* String_literal */
33128
+ 11
33129
+ ),
33130
+ _0: "---\nto: ",
33131
+ _1: {
33132
+ TAG: (
33133
+ /* String */
33134
+ 2
33135
+ ),
33136
+ _0: (
33137
+ /* No_padding */
33138
+ 0
33139
+ ),
33140
+ _1: {
33141
+ TAG: (
33142
+ /* String_literal */
33143
+ 11
33144
+ ),
33145
+ _0: "\ncreated: ",
33146
+ _1: {
33147
+ TAG: (
33148
+ /* String */
33149
+ 2
33150
+ ),
33151
+ _0: (
33152
+ /* No_padding */
33153
+ 0
33154
+ ),
33155
+ _1: {
33156
+ TAG: (
33157
+ /* String_literal */
33158
+ 11
33159
+ ),
33160
+ _0: "\n---\n\n",
33161
+ _1: {
33162
+ TAG: (
33163
+ /* String */
33164
+ 2
33165
+ ),
33166
+ _0: (
33167
+ /* No_padding */
33168
+ 0
33169
+ ),
33170
+ _1: {
33171
+ TAG: (
33172
+ /* Char_literal */
33173
+ 12
33174
+ ),
33175
+ _0: (
33176
+ /* '\n' */
33177
+ 10
33178
+ ),
33179
+ _1: (
33180
+ /* End_of_format */
33181
+ 0
33182
+ )
33183
+ }
33184
+ }
33185
+ }
33186
+ }
33187
+ }
33188
+ }
33189
+ },
33190
+ _1: "---\nto: %s\ncreated: %s\n---\n\n%s\n"
33191
+ }), to_$2, (/* @__PURE__ */ new Date()).toISOString(), match$2[1]);
33192
+ const prim0$2 = Path.join(outbox_dir, send_file);
33193
+ Fs.writeFileSync(prim0$2, send_content);
33194
+ const msg$3 = Curry._1(Stdlib__Printf.sprintf({
33195
+ TAG: (
33196
+ /* Format */
33197
+ 0
33198
+ ),
33199
+ _0: {
33200
+ TAG: (
33201
+ /* String_literal */
33202
+ 11
33203
+ ),
33204
+ _0: "Send \xE2\x86\x92 outbox/",
33205
+ _1: {
33206
+ TAG: (
33207
+ /* String */
33208
+ 2
33209
+ ),
33210
+ _0: (
33211
+ /* No_padding */
33212
+ 0
33213
+ ),
33214
+ _1: (
33215
+ /* End_of_format */
33216
+ 0
33217
+ )
33218
+ }
33219
+ },
33220
+ _1: "Send \xE2\x86\x92 outbox/%s"
33221
+ }), send_file);
33222
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$3);
33223
+ } else {
33224
+ const reply_file = Curry._2(Stdlib__Printf.sprintf({
33225
+ TAG: (
33226
+ /* Format */
33227
+ 0
33228
+ ),
33229
+ _0: {
33230
+ TAG: (
33231
+ /* String */
33232
+ 2
33233
+ ),
33234
+ _0: (
33235
+ /* No_padding */
33236
+ 0
33237
+ ),
33238
+ _1: {
33239
+ TAG: (
33240
+ /* String_literal */
33241
+ 11
33242
+ ),
33243
+ _0: "-reply-",
33244
+ _1: {
33245
+ TAG: (
33246
+ /* String */
33247
+ 2
33248
+ ),
33249
+ _0: (
33250
+ /* No_padding */
33251
+ 0
33252
+ ),
33253
+ _1: {
33254
+ TAG: (
33255
+ /* String_literal */
33256
+ 11
33257
+ ),
33258
+ _0: ".md",
33259
+ _1: (
33260
+ /* End_of_format */
33261
+ 0
33262
+ )
33263
+ }
33264
+ }
33265
+ }
33266
+ },
33267
+ _1: "%s-reply-%s.md"
33268
+ }), from, id);
33269
+ const reply_content = Curry._4(Stdlib__Printf.sprintf({
33270
+ TAG: (
33271
+ /* Format */
33272
+ 0
33273
+ ),
33274
+ _0: {
33275
+ TAG: (
33276
+ /* String_literal */
33277
+ 11
33278
+ ),
33279
+ _0: "---\nto: ",
33280
+ _1: {
33281
+ TAG: (
33282
+ /* String */
33283
+ 2
33284
+ ),
33285
+ _0: (
33286
+ /* No_padding */
33287
+ 0
33288
+ ),
33289
+ _1: {
33290
+ TAG: (
33291
+ /* String_literal */
33292
+ 11
33293
+ ),
33294
+ _0: "\nin-reply-to: ",
33295
+ _1: {
33296
+ TAG: (
33297
+ /* String */
33298
+ 2
33299
+ ),
33300
+ _0: (
33301
+ /* No_padding */
33302
+ 0
33303
+ ),
33304
+ _1: {
33305
+ TAG: (
33306
+ /* String_literal */
33307
+ 11
33308
+ ),
33309
+ _0: "\ncreated: ",
33310
+ _1: {
33311
+ TAG: (
33312
+ /* String */
33313
+ 2
33314
+ ),
33315
+ _0: (
33316
+ /* No_padding */
33317
+ 0
33318
+ ),
33319
+ _1: {
33320
+ TAG: (
33321
+ /* String_literal */
33322
+ 11
33323
+ ),
33324
+ _0: "\n---\n\n",
33325
+ _1: {
33326
+ TAG: (
33327
+ /* String */
33328
+ 2
33329
+ ),
33330
+ _0: (
33331
+ /* No_padding */
33332
+ 0
33333
+ ),
33334
+ _1: {
33335
+ TAG: (
33336
+ /* Char_literal */
33337
+ 12
33338
+ ),
33339
+ _0: (
33340
+ /* '\n' */
33341
+ 10
33342
+ ),
33343
+ _1: (
33344
+ /* End_of_format */
33345
+ 0
33346
+ )
33347
+ }
33348
+ }
33349
+ }
33350
+ }
33351
+ }
33352
+ }
33353
+ }
33354
+ }
33355
+ },
33356
+ _1: "---\nto: %s\nin-reply-to: %s\ncreated: %s\n---\n\n%s\n"
33357
+ }), from, id, (/* @__PURE__ */ new Date()).toISOString(), op_kind.VAL);
33358
+ const prim0$3 = Path.join(outbox_dir, reply_file);
33359
+ Fs.writeFileSync(prim0$3, reply_content);
33360
+ const msg$4 = Curry._1(Stdlib__Printf.sprintf({
33361
+ TAG: (
33362
+ /* Format */
33363
+ 0
33364
+ ),
33365
+ _0: {
33366
+ TAG: (
33367
+ /* String_literal */
33368
+ 11
33369
+ ),
33370
+ _0: "Reply \xE2\x86\x92 outbox/",
33371
+ _1: {
33372
+ TAG: (
33373
+ /* String */
33374
+ 2
33375
+ ),
33376
+ _0: (
33377
+ /* No_padding */
33378
+ 0
33379
+ ),
33380
+ _1: (
33381
+ /* End_of_format */
33382
+ 0
33383
+ )
33384
+ }
33385
+ },
33386
+ _1: "Reply \xE2\x86\x92 outbox/%s"
33387
+ }), reply_file);
33388
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$4);
33389
+ }
33390
+ }
33391
+ const output_content = Curry._4(Stdlib__Printf.sprintf({
33392
+ TAG: (
33393
+ /* Format */
33394
+ 0
33395
+ ),
33396
+ _0: {
33397
+ TAG: (
33398
+ /* String_literal */
33399
+ 11
33400
+ ),
33401
+ _0: "---\nid: ",
33402
+ _1: {
33403
+ TAG: (
33404
+ /* String */
33405
+ 2
33406
+ ),
33407
+ _0: (
33408
+ /* No_padding */
33409
+ 0
33410
+ ),
33411
+ _1: {
33412
+ TAG: (
33413
+ /* String_literal */
33414
+ 11
33415
+ ),
33416
+ _0: "\ngtd: ",
33417
+ _1: {
33418
+ TAG: (
33419
+ /* String */
33420
+ 2
33421
+ ),
33422
+ _0: (
33423
+ /* No_padding */
33424
+ 0
33425
+ ),
33426
+ _1: {
33427
+ TAG: (
33428
+ /* Char_literal */
33429
+ 12
33430
+ ),
33431
+ _0: (
33432
+ /* '\n' */
33433
+ 10
33434
+ ),
33435
+ _1: {
33436
+ TAG: (
33437
+ /* String */
33438
+ 2
33439
+ ),
33440
+ _0: (
33441
+ /* No_padding */
33442
+ 0
33443
+ ),
33444
+ _1: {
33445
+ TAG: (
33446
+ /* String_literal */
33447
+ 11
33448
+ ),
33449
+ _0: "\ncreated: ",
33450
+ _1: {
33451
+ TAG: (
33452
+ /* String */
33453
+ 2
33454
+ ),
33455
+ _0: (
33456
+ /* No_padding */
33457
+ 0
33458
+ ),
33459
+ _1: {
33460
+ TAG: (
33461
+ /* String_literal */
33462
+ 11
33463
+ ),
33464
+ _0: "\n---\n",
33465
+ _1: (
33466
+ /* End_of_format */
33467
+ 0
33468
+ )
33469
+ }
33470
+ }
33471
+ }
33472
+ }
33473
+ }
33474
+ }
33475
+ }
33476
+ }
33062
33477
  },
33063
- _1: "[auto] %s: %s on %s"
33064
- }), name, gtd_type, id);
33065
- const outbox_dir = Path.join(hub_path, "threads/outbox");
33066
- ensure_dir(outbox_dir);
33067
- const notify_file = Curry._2(Stdlib__Printf.sprintf({
33478
+ _1: "---\nid: %s\ngtd: %s\n%s\ncreated: %s\n---\n"
33479
+ }), id, gtd_type, match2[1], (/* @__PURE__ */ new Date()).toISOString());
33480
+ Fs.writeFileSync(outp, output_content);
33481
+ const prim0$4 = Path.join(run_dir, "output.md");
33482
+ Fs.writeFileSync(prim0$4, output_content);
33483
+ const end_time = (/* @__PURE__ */ new Date()).toISOString();
33484
+ const meta_content = Curry._6(Stdlib__Printf.sprintf({
33068
33485
  TAG: (
33069
33486
  /* Format */
33070
33487
  0
33071
33488
  ),
33072
33489
  _0: {
33073
33490
  TAG: (
33074
- /* String */
33075
- 2
33076
- ),
33077
- _0: (
33078
- /* No_padding */
33079
- 0
33491
+ /* String_literal */
33492
+ 11
33080
33493
  ),
33494
+ _0: '{\n "id": "',
33081
33495
  _1: {
33082
33496
  TAG: (
33083
- /* String_literal */
33084
- 11
33497
+ /* String */
33498
+ 2
33499
+ ),
33500
+ _0: (
33501
+ /* No_padding */
33502
+ 0
33085
33503
  ),
33086
- _0: "-auto-notify-",
33087
33504
  _1: {
33088
33505
  TAG: (
33089
- /* String */
33090
- 2
33091
- ),
33092
- _0: (
33093
- /* No_padding */
33094
- 0
33506
+ /* String_literal */
33507
+ 11
33095
33508
  ),
33509
+ _0: '",\n "from": "',
33096
33510
  _1: {
33097
33511
  TAG: (
33098
- /* String_literal */
33099
- 11
33512
+ /* String */
33513
+ 2
33100
33514
  ),
33101
- _0: ".md",
33102
- _1: (
33103
- /* End_of_format */
33515
+ _0: (
33516
+ /* No_padding */
33104
33517
  0
33105
- )
33518
+ ),
33519
+ _1: {
33520
+ TAG: (
33521
+ /* String_literal */
33522
+ 11
33523
+ ),
33524
+ _0: '",\n "gtd": "',
33525
+ _1: {
33526
+ TAG: (
33527
+ /* String */
33528
+ 2
33529
+ ),
33530
+ _0: (
33531
+ /* No_padding */
33532
+ 0
33533
+ ),
33534
+ _1: {
33535
+ TAG: (
33536
+ /* String_literal */
33537
+ 11
33538
+ ),
33539
+ _0: '",\n "start": "',
33540
+ _1: {
33541
+ TAG: (
33542
+ /* String */
33543
+ 2
33544
+ ),
33545
+ _0: (
33546
+ /* No_padding */
33547
+ 0
33548
+ ),
33549
+ _1: {
33550
+ TAG: (
33551
+ /* String_literal */
33552
+ 11
33553
+ ),
33554
+ _0: '",\n "end": "',
33555
+ _1: {
33556
+ TAG: (
33557
+ /* String */
33558
+ 2
33559
+ ),
33560
+ _0: (
33561
+ /* No_padding */
33562
+ 0
33563
+ ),
33564
+ _1: {
33565
+ TAG: (
33566
+ /* String_literal */
33567
+ 11
33568
+ ),
33569
+ _0: '",\n "agent": "',
33570
+ _1: {
33571
+ TAG: (
33572
+ /* String */
33573
+ 2
33574
+ ),
33575
+ _0: (
33576
+ /* No_padding */
33577
+ 0
33578
+ ),
33579
+ _1: {
33580
+ TAG: (
33581
+ /* String_literal */
33582
+ 11
33583
+ ),
33584
+ _0: '"\n}\n',
33585
+ _1: (
33586
+ /* End_of_format */
33587
+ 0
33588
+ )
33589
+ }
33590
+ }
33591
+ }
33592
+ }
33593
+ }
33594
+ }
33595
+ }
33596
+ }
33597
+ }
33106
33598
  }
33107
33599
  }
33108
33600
  }
33109
33601
  },
33110
- _1: "%s-auto-notify-%s.md"
33111
- }), input_from, id);
33112
- const notify_content = Curry._3(Stdlib__Printf.sprintf({
33602
+ _1: '{\n "id": "%s",\n "from": "%s",\n "gtd": "%s",\n "start": "%s",\n "end": "%s",\n "agent": "%s"\n}\n'
33603
+ }), id, from, gtd_type, start_time, end_time, name);
33604
+ const prim0$5 = Path.join(run_dir, "meta.json");
33605
+ Fs.writeFileSync(prim0$5, meta_content);
33606
+ Fs.writeFileSync(inp, "");
33607
+ Fs.writeFileSync(outp, "");
33608
+ console.log(color("32", "\xE2\x9C\x93 ") + "State cleared");
33609
+ log_action(hub_path, "out", Curry._3(Stdlib__Printf.sprintf({
33113
33610
  TAG: (
33114
33611
  /* Format */
33115
33612
  0
@@ -33119,7 +33616,7 @@ function run_out(hub_path, name, gtd) {
33119
33616
  /* String_literal */
33120
33617
  11
33121
33618
  ),
33122
- _0: "---\nto: ",
33619
+ _0: "id:",
33123
33620
  _1: {
33124
33621
  TAG: (
33125
33622
  /* String */
@@ -33134,7 +33631,7 @@ function run_out(hub_path, name, gtd) {
33134
33631
  /* String_literal */
33135
33632
  11
33136
33633
  ),
33137
- _0: "\ncreated: ",
33634
+ _0: " gtd:",
33138
33635
  _1: {
33139
33636
  TAG: (
33140
33637
  /* String */
@@ -33149,7 +33646,7 @@ function run_out(hub_path, name, gtd) {
33149
33646
  /* String_literal */
33150
33647
  11
33151
33648
  ),
33152
- _0: "\nauto: true\n---\n\n",
33649
+ _0: " run:",
33153
33650
  _1: {
33154
33651
  TAG: (
33155
33652
  /* String */
@@ -33159,31 +33656,19 @@ function run_out(hub_path, name, gtd) {
33159
33656
  /* No_padding */
33160
33657
  0
33161
33658
  ),
33162
- _1: {
33163
- TAG: (
33164
- /* Char_literal */
33165
- 12
33166
- ),
33167
- _0: (
33168
- /* '\n' */
33169
- 10
33170
- ),
33171
- _1: (
33172
- /* End_of_format */
33173
- 0
33174
- )
33175
- }
33659
+ _1: (
33660
+ /* End_of_format */
33661
+ 0
33662
+ )
33176
33663
  }
33177
33664
  }
33178
33665
  }
33179
33666
  }
33180
33667
  }
33181
33668
  },
33182
- _1: "---\nto: %s\ncreated: %s\nauto: true\n---\n\n%s\n"
33183
- }), input_from, (/* @__PURE__ */ new Date()).toISOString(), notify_msg);
33184
- const prim0 = Path.join(outbox_dir, notify_file);
33185
- Fs.writeFileSync(prim0, notify_content);
33186
- log_action(hub_path, "out.notify", Curry._2(Stdlib__Printf.sprintf({
33669
+ _1: "id:%s gtd:%s run:%s"
33670
+ }), id, gtd_type, run_dir));
33671
+ const msg$5 = Curry._2(Stdlib__Printf.sprintf({
33187
33672
  TAG: (
33188
33673
  /* Format */
33189
33674
  0
@@ -33193,7 +33678,7 @@ function run_out(hub_path, name, gtd) {
33193
33678
  /* String_literal */
33194
33679
  11
33195
33680
  ),
33196
- _0: "to:",
33681
+ _0: "Run complete: ",
33197
33682
  _1: {
33198
33683
  TAG: (
33199
33684
  /* String */
@@ -33208,7 +33693,7 @@ function run_out(hub_path, name, gtd) {
33208
33693
  /* String_literal */
33209
33694
  11
33210
33695
  ),
33211
- _0: " id:",
33696
+ _0: " (",
33212
33697
  _1: {
33213
33698
  TAG: (
33214
33699
  /* String */
@@ -33218,17 +33703,28 @@ function run_out(hub_path, name, gtd) {
33218
33703
  /* No_padding */
33219
33704
  0
33220
33705
  ),
33221
- _1: (
33222
- /* End_of_format */
33223
- 0
33224
- )
33706
+ _1: {
33707
+ TAG: (
33708
+ /* Char_literal */
33709
+ 12
33710
+ ),
33711
+ _0: (
33712
+ /* ')' */
33713
+ 41
33714
+ ),
33715
+ _1: (
33716
+ /* End_of_format */
33717
+ 0
33718
+ )
33719
+ }
33225
33720
  }
33226
33721
  }
33227
33722
  }
33228
33723
  },
33229
- _1: "to:%s id:%s"
33230
- }), input_from, id));
33231
- const msg$1 = Curry._1(Stdlib__Printf.sprintf({
33724
+ _1: "Run complete: %s (%s)"
33725
+ }), gtd_type, id);
33726
+ console.log(color("32", "\xE2\x9C\x93 ") + msg$5);
33727
+ exec_in(hub_path, Curry._2(Stdlib__Printf.sprintf({
33232
33728
  TAG: (
33233
33729
  /* Format */
33234
33730
  0
@@ -33238,7 +33734,7 @@ function run_out(hub_path, name, gtd) {
33238
33734
  /* String_literal */
33239
33735
  11
33240
33736
  ),
33241
- _0: "Notified ",
33737
+ _0: "git add -A && git commit -m 'run: ",
33242
33738
  _1: {
33243
33739
  TAG: (
33244
33740
  /* String */
@@ -33248,17 +33744,45 @@ function run_out(hub_path, name, gtd) {
33248
33744
  /* No_padding */
33249
33745
  0
33250
33746
  ),
33251
- _1: (
33252
- /* End_of_format */
33253
- 0
33254
- )
33747
+ _1: {
33748
+ TAG: (
33749
+ /* Char_literal */
33750
+ 12
33751
+ ),
33752
+ _0: (
33753
+ /* ' ' */
33754
+ 32
33755
+ ),
33756
+ _1: {
33757
+ TAG: (
33758
+ /* String */
33759
+ 2
33760
+ ),
33761
+ _0: (
33762
+ /* No_padding */
33763
+ 0
33764
+ ),
33765
+ _1: {
33766
+ TAG: (
33767
+ /* Char_literal */
33768
+ 12
33769
+ ),
33770
+ _0: (
33771
+ /* '\'' */
33772
+ 39
33773
+ ),
33774
+ _1: (
33775
+ /* End_of_format */
33776
+ 0
33777
+ )
33778
+ }
33779
+ }
33780
+ }
33255
33781
  }
33256
33782
  },
33257
- _1: "Notified %s"
33258
- }), input_from);
33259
- console.log(color("32", "\xE2\x9C\x93 ") + msg$1);
33260
- exec_in(hub_path, "git add -A && git commit -m '[auto] notify' && git push");
33261
- console.log(color("32", "\xE2\x9C\x93 ") + "Pushed notification");
33783
+ _1: "git add -A && git commit -m 'run: %s %s'"
33784
+ }), gtd_type, id));
33785
+ console.log(color("32", "\xE2\x9C\x93 ") + "Committed run");
33262
33786
  }
33263
33787
  function mca_cycle_path(hub_path) {
33264
33788
  return Path.join(hub_path, "state/.mca-cycle");
@@ -33669,8 +34193,8 @@ function auto_save(hub_path, name) {
33669
34193
  log_action(hub_path, "auto-save.commit", "failed");
33670
34194
  console.log(color("33", "\xE2\x9A\xA0 ") + "Auto-commit failed");
33671
34195
  }
33672
- function run_process(hub_path, name) {
33673
- console.log(color("36", "cn process: actor loop..."));
34196
+ function run_inbound(hub_path, name) {
34197
+ console.log(color("36", "cn inbound: handling external input..."));
33674
34198
  const queued = queue_inbox_items(hub_path);
33675
34199
  if (queued > 0) {
33676
34200
  console.log(color("36", Curry._1(Stdlib__Printf.sprintf({
@@ -35502,9 +36026,9 @@ if (cmd !== void 0) {
35502
36026
  6:
35503
36027
  run_push(hub_path$1);
35504
36028
  break;
35505
- case /* Process */
36029
+ case /* Inbound */
35506
36030
  7:
35507
- run_process(hub_path$1, name);
36031
+ run_inbound(hub_path$1, name);
35508
36032
  break;
35509
36033
  }
35510
36034
  } else {
@@ -35751,7 +36275,7 @@ module.exports = {
35751
36275
  mca_count,
35752
36276
  queue_mca_review,
35753
36277
  auto_save,
35754
- run_process,
36278
+ run_inbound,
35755
36279
  update_runtime,
35756
36280
  run_init,
35757
36281
  format_peers_md,