@integrity-labs/agt-cli 0.28.329 → 0.28.331

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/dist/bin/agt.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  success,
39
39
  table,
40
40
  warn
41
- } from "../chunk-AOSBSVNB.js";
41
+ } from "../chunk-4Y3UPOR2.js";
42
42
  import {
43
43
  AnchorSessionClient,
44
44
  CHANNEL_REGISTRY,
@@ -4827,7 +4827,7 @@ import { execFileSync, execSync } from "child_process";
4827
4827
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4828
4828
  import chalk18 from "chalk";
4829
4829
  import ora16 from "ora";
4830
- var cliVersion = true ? "0.28.329" : "dev";
4830
+ var cliVersion = true ? "0.28.331" : "dev";
4831
4831
  async function fetchLatestVersion() {
4832
4832
  const host2 = getHost();
4833
4833
  if (!host2) return null;
@@ -5931,7 +5931,7 @@ function handleError(err) {
5931
5931
  }
5932
5932
 
5933
5933
  // src/bin/agt.ts
5934
- var cliVersion2 = true ? "0.28.329" : "dev";
5934
+ var cliVersion2 = true ? "0.28.331" : "dev";
5935
5935
  var program = new Command();
5936
5936
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
5937
5937
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -2712,9 +2712,13 @@ function provisionStopHook(codeName) {
2712
2712
  "# observed mid-write.",
2713
2713
  "atomic_write_payload() {",
2714
2714
  ' local out_dir="$1" final="$2" jq_expr="$3"; shift 3',
2715
- ' mkdir -p "$out_dir"',
2715
+ ' if ! mkdir -p "$out_dir" 2>/dev/null; then return 1; fi',
2716
2716
  ' local tmp="$out_dir/.${final##*/}.tmp"',
2717
- ' jq -n "$jq_expr" "$@" > "$tmp"',
2717
+ " # ENG-7805 (CodeRabbit): fail (non-zero) on a jq/write fault instead of",
2718
+ " # mv-ing a half-written tmp - the script has no set -e, so an unguarded jq",
2719
+ " # error would otherwise ship an empty payload AND let callers believe the",
2720
+ " # write succeeded (leaving a recovery-ledger entry orphaned until GC).",
2721
+ ' if ! jq -n "$jq_expr" "$@" > "$tmp" 2>/dev/null; then rm -f "$tmp" 2>/dev/null || true; return 1; fi',
2718
2722
  ' chmod 600 "$tmp" 2>/dev/null || true',
2719
2723
  ' mv -f "$tmp" "$out_dir/$final"',
2720
2724
  "}",
@@ -2775,12 +2779,30 @@ function provisionStopHook(codeName) {
2775
2779
  ' marker_name="$(safe_id "$chat_id")__$(safe_id "$msg_id").json"',
2776
2780
  ' local marker_path="${TG_MARKER_DIR}/${marker_name}"',
2777
2781
  ' if [ ! -f "$marker_path" ]; then log_ghost "telegram skip=no_pending_marker chat=$(safe_id "$chat_id")"; return; fi',
2782
+ " # ENG-7805 (fm2): confirm-before-clear. Cap re-fire with a per-marker ledger and",
2783
+ " # LEAVE the marker for the consumer to clear on confirmed send. Ledger-first",
2784
+ " # fail-safe (same as recover_directchat_for / block-turn-end): if the ledger",
2785
+ " # write fails, log a skip and write no payload rather than re-fire every Stop.",
2786
+ ' if ! mkdir -p "$TG_RECOVERY_LEDGER_DIR" 2>/dev/null; then log_ghost "telegram skip=recovery_ledger_unwritable chat=$(safe_id "$chat_id")"; return; fi',
2787
+ " # ENG-7805 (CodeRabbit): atomic acquire - noclobber create fails if the entry",
2788
+ " # already exists (recovery in flight) OR the write faults; the follow-up [ -f ]",
2789
+ ' # disambiguates. Closes the "[ -f ] then : >" TOCTOU where two concurrent Stops',
2790
+ " # both observe no entry and both enqueue a duplicate payload.",
2791
+ ' if ! ( set -o noclobber; : > "${TG_RECOVERY_LEDGER_DIR}/${marker_name}" ) 2>/dev/null; then',
2792
+ ' if [ -f "${TG_RECOVERY_LEDGER_DIR}/${marker_name}" ]; then log_ghost "telegram skip=recovery_in_flight chat=$(safe_id "$chat_id")"; else log_ghost "telegram skip=recovery_ledger_unwritable chat=$(safe_id "$chat_id")"; fi',
2793
+ " return",
2794
+ " fi",
2778
2795
  " local TS",
2779
2796
  " TS=$(date -u +%Y%m%dT%H%M%S%N)",
2780
- ' atomic_write_payload "${AGENT_DIR}/telegram-recovery-outbox" "${TS}.json" \\',
2781
- ` '{chat_id:$c, message_id:$m, text:$t, source:"ghost-reply-recovery"}' \\`,
2782
- ' --arg c "$chat_id" --arg m "$msg_id" --arg t "$TEXT"',
2783
- ' rm -f "$marker_path" 2>/dev/null || true',
2797
+ ' if ! atomic_write_payload "${AGENT_DIR}/telegram-recovery-outbox" "${TS}.json" \\',
2798
+ ` '{chat_id:$c, message_id:$m, text:$t, marker_name:$mn, source:"ghost-reply-recovery"}' \\`,
2799
+ ' --arg c "$chat_id" --arg m "$msg_id" --arg t "$TEXT" --arg mn "$marker_name"; then',
2800
+ " # ENG-7805 (CodeRabbit): the write faulted after the ledger was acquired -",
2801
+ " # drop the ledger entry so replay + the next Stop are not suppressed until GC.",
2802
+ ' rm -f "${TG_RECOVERY_LEDGER_DIR}/${marker_name}" 2>/dev/null || true',
2803
+ ' log_ghost "telegram skip=recovery_payload_write_failed chat=$(safe_id "$chat_id")"',
2804
+ " return",
2805
+ " fi",
2784
2806
  ' log_ghost "telegram RECOVERED chat=$(safe_id "$chat_id") msg=$(safe_id "$msg_id") text_len=${#TEXT}"',
2785
2807
  "}",
2786
2808
  "recover_slack_for() {",
@@ -2861,13 +2883,29 @@ function provisionStopHook(codeName) {
2861
2883
  " return",
2862
2884
  " fi",
2863
2885
  " fi",
2886
+ ' local marker_name; marker_name="$(basename "$marker_path")"',
2887
+ " # ENG-7805 (fm2): confirm-before-clear. Cap re-fire with a per-marker ledger and",
2888
+ " # LEAVE the marker for the consumer to clear on confirmed send (ledger-first fail-safe).",
2889
+ ' if ! mkdir -p "$SL_RECOVERY_LEDGER_DIR" 2>/dev/null; then log_ghost "slack skip=recovery_ledger_unwritable channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts")"; return; fi',
2890
+ " # ENG-7805 (CodeRabbit): atomic acquire - noclobber create fails if the entry",
2891
+ " # already exists (recovery in flight) OR the write faults; the follow-up [ -f ]",
2892
+ ' # disambiguates. Closes the "[ -f ] then : >" TOCTOU between concurrent Stops.',
2893
+ ' if ! ( set -o noclobber; : > "${SL_RECOVERY_LEDGER_DIR}/${marker_name}" ) 2>/dev/null; then',
2894
+ ' if [ -f "${SL_RECOVERY_LEDGER_DIR}/${marker_name}" ]; then log_ghost "slack skip=recovery_in_flight channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts")"; else log_ghost "slack skip=recovery_ledger_unwritable channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts")"; fi',
2895
+ " return",
2896
+ " fi",
2864
2897
  " local TS",
2865
2898
  " TS=$(date -u +%Y%m%dT%H%M%S%N)",
2866
- ' atomic_write_payload "${AGENT_DIR}/slack-recovery-outbox" "${TS}.json" \\',
2867
- ` '{channel:$c, thread_ts:$th, text:$t, source:"ghost-reply-recovery"}' \\`,
2868
- ' --arg c "$channel" --arg th "$thread_ts" --arg t "$TEXT"',
2869
- ' rm -f "$marker_path" 2>/dev/null || true',
2870
- ' log_ghost "slack RECOVERED channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts") marker=$(basename "$marker_path") text_len=${#TEXT}"',
2899
+ ' if ! atomic_write_payload "${AGENT_DIR}/slack-recovery-outbox" "${TS}.json" \\',
2900
+ ` '{channel:$c, thread_ts:$th, text:$t, marker_name:$mn, source:"ghost-reply-recovery"}' \\`,
2901
+ ' --arg c "$channel" --arg th "$thread_ts" --arg t "$TEXT" --arg mn "$marker_name"; then',
2902
+ " # ENG-7805 (CodeRabbit): write faulted after the ledger was acquired - drop",
2903
+ " # the ledger entry so replay + the next Stop are not suppressed until GC.",
2904
+ ' rm -f "${SL_RECOVERY_LEDGER_DIR}/${marker_name}" 2>/dev/null || true',
2905
+ ' log_ghost "slack skip=recovery_payload_write_failed channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts")"',
2906
+ " return",
2907
+ " fi",
2908
+ ' log_ghost "slack RECOVERED channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts") marker=${marker_name} text_len=${#TEXT}"',
2871
2909
  "}",
2872
2910
  "recover_teams_for() {",
2873
2911
  ' local conversation_id="$1" reply_to_id="$2" service_url="$3"',
@@ -2898,12 +2936,28 @@ function provisionStopHook(codeName) {
2898
2936
  ' if [ -z "$marker_path" ]; then marker_path="$f"; fi',
2899
2937
  " done",
2900
2938
  ' if [ -z "$marker_path" ]; then log_ghost "teams skip=no_pending_marker conv=$(safe_id "$conversation_id")"; return; fi',
2939
+ ' local marker_name; marker_name="$(basename "$marker_path")"',
2940
+ " # ENG-7805 (fm2): confirm-before-clear. Cap re-fire with a per-marker ledger and",
2941
+ " # LEAVE the marker for the consumer to clear on confirmed send (ledger-first fail-safe).",
2942
+ ' if ! mkdir -p "$MS_RECOVERY_LEDGER_DIR" 2>/dev/null; then log_ghost "teams skip=recovery_ledger_unwritable conv=$(safe_id "$conversation_id")"; return; fi',
2943
+ " # ENG-7805 (CodeRabbit): atomic acquire - noclobber create fails if the entry",
2944
+ " # already exists (recovery in flight) OR the write faults; the follow-up [ -f ]",
2945
+ ' # disambiguates. Closes the "[ -f ] then : >" TOCTOU between concurrent Stops.',
2946
+ ' if ! ( set -o noclobber; : > "${MS_RECOVERY_LEDGER_DIR}/${marker_name}" ) 2>/dev/null; then',
2947
+ ' if [ -f "${MS_RECOVERY_LEDGER_DIR}/${marker_name}" ]; then log_ghost "teams skip=recovery_in_flight conv=$(safe_id "$conversation_id")"; else log_ghost "teams skip=recovery_ledger_unwritable conv=$(safe_id "$conversation_id")"; fi',
2948
+ " return",
2949
+ " fi",
2901
2950
  " local TS",
2902
2951
  " TS=$(date -u +%Y%m%dT%H%M%S%N)",
2903
- ' atomic_write_payload "${AGENT_DIR}/msteams-recovery-outbox" "${TS}.json" \\',
2904
- ` '{conversation_id:$c, reply_to_id:$r, service_url:$s, text:$t, source:"ghost-reply-recovery"}' \\`,
2905
- ' --arg c "$conversation_id" --arg r "$reply_to_id" --arg s "$service_url" --arg t "$TEXT"',
2906
- ' rm -f "$marker_path" 2>/dev/null || true',
2952
+ ' if ! atomic_write_payload "${AGENT_DIR}/msteams-recovery-outbox" "${TS}.json" \\',
2953
+ ` '{conversation_id:$c, reply_to_id:$r, service_url:$s, text:$t, marker_name:$mn, source:"ghost-reply-recovery"}' \\`,
2954
+ ' --arg c "$conversation_id" --arg r "$reply_to_id" --arg s "$service_url" --arg t "$TEXT" --arg mn "$marker_name"; then',
2955
+ " # ENG-7805 (CodeRabbit): write faulted after the ledger was acquired - drop",
2956
+ " # the ledger entry so replay + the next Stop are not suppressed until GC.",
2957
+ ' rm -f "${MS_RECOVERY_LEDGER_DIR}/${marker_name}" 2>/dev/null || true',
2958
+ ' log_ghost "teams skip=recovery_payload_write_failed conv=$(safe_id "$conversation_id")"',
2959
+ " return",
2960
+ " fi",
2907
2961
  ' log_ghost "teams RECOVERED conv=$(safe_id "$conversation_id") text_len=${#TEXT}"',
2908
2962
  "}",
2909
2963
  "# ENG-7814 (ENG-6722 slice E): always-on direct-chat recovery. Re-send the last",
@@ -2981,6 +3035,18 @@ function provisionStopHook(codeName) {
2981
3035
  "# entries here as a backstop, same as the block ledger.",
2982
3036
  'DC_RECOVERY_LEDGER_DIR="${AGENT_DIR}/.agt-direct-chat-recovery-ledger"',
2983
3037
  'if [ -d "$DC_RECOVERY_LEDGER_DIR" ]; then find "$DC_RECOVERY_LEDGER_DIR" -type f -mtime +1 -delete 2>/dev/null || true; fi',
3038
+ "# ENG-7805 (ENG-6722 slice B): per-marker recovery ledgers for slack/telegram/teams.",
3039
+ "# recover_*_for now LEAVES the pending marker in place (confirm-before-clear, fm2)",
3040
+ "# and writes a ledger entry here to cap ONE in-flight recovery per inbound; the",
3041
+ "# channel MCP consumer clears the marker on confirmed send and removes the ledger",
3042
+ "# entry when the recovery resolves (delivered / suppressed / poisoned = re-arm).",
3043
+ "# GC stale entries (>1 day) as a backstop, same as the block + direct-chat ledgers.",
3044
+ 'SL_RECOVERY_LEDGER_DIR="${AGENT_DIR}/.agt-slack-recovery-ledger"',
3045
+ 'TG_RECOVERY_LEDGER_DIR="${AGENT_DIR}/.agt-telegram-recovery-ledger"',
3046
+ 'MS_RECOVERY_LEDGER_DIR="${AGENT_DIR}/.agt-msteams-recovery-ledger"',
3047
+ 'for _rl in "$SL_RECOVERY_LEDGER_DIR" "$TG_RECOVERY_LEDGER_DIR" "$MS_RECOVERY_LEDGER_DIR"; do',
3048
+ ' if [ -d "$_rl" ]; then find "$_rl" -type f -mtime +1 -delete 2>/dev/null || true; fi',
3049
+ "done",
2984
3050
  "# Returns 0 (after printing the block JSON to stdout) when it blocked; 1 otherwise.",
2985
3051
  '# $1 = "yes"/"no" \u2014 did the agent reply to THIS conversation in the final turn?',
2986
3052
  "# (ENG-6727: per-conversation, computed by the caller via replied_this_conv_*)",
@@ -6797,7 +6863,7 @@ function requireHost() {
6797
6863
  }
6798
6864
 
6799
6865
  // src/lib/api-client.ts
6800
- var agtCliVersion = true ? "0.28.329" : "dev";
6866
+ var agtCliVersion = true ? "0.28.331" : "dev";
6801
6867
  var lastConfigHash = null;
6802
6868
  function setConfigHash(hash) {
6803
6869
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -9194,4 +9260,4 @@ export {
9194
9260
  managerInstallSystemUnitCommand,
9195
9261
  managerUninstallSystemUnitCommand
9196
9262
  };
9197
- //# sourceMappingURL=chunk-AOSBSVNB.js.map
9263
+ //# sourceMappingURL=chunk-4Y3UPOR2.js.map