@integrity-labs/agt-cli 0.28.547 → 0.28.549

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
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-SYHPBJK7.js";
43
+ } from "../chunk-MDIHMULA.js";
44
44
  import {
45
45
  AnchorSessionClient,
46
46
  CHANNEL_REGISTRY,
@@ -4834,7 +4834,7 @@ import { execFileSync, execSync } from "child_process";
4834
4834
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4835
4835
  import chalk18 from "chalk";
4836
4836
  import ora16 from "ora";
4837
- var cliVersion = true ? "0.28.547" : "dev";
4837
+ var cliVersion = true ? "0.28.549" : "dev";
4838
4838
  async function fetchLatestVersion() {
4839
4839
  const host2 = getHost();
4840
4840
  if (!host2) return null;
@@ -6006,7 +6006,7 @@ function handleError(err) {
6006
6006
  }
6007
6007
 
6008
6008
  // src/bin/agt.ts
6009
- var cliVersion2 = true ? "0.28.547" : "dev";
6009
+ var cliVersion2 = true ? "0.28.549" : "dev";
6010
6010
  var program = new Command();
6011
6011
  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");
6012
6012
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -1689,6 +1689,49 @@ function provisionStopHook(codeName) {
1689
1689
  "# turns (not an allowlist of user/notification, which could miss a real",
1690
1690
  "# notification record shape).",
1691
1691
  `CHANNEL_TAG=$(jq -r 'select((.type // "") != "assistant" and (.role // "") != "assistant") | ${jqNormalizeContent} | map(select(type == "object" and .type == "text") | .text | gsub("[\\n\\r]+"; " ")) | join(" ")' "$RECENT_FILE" 2>/dev/null | grep -oE '<channel [^>]+>' | tail -1 || true)`,
1692
+ "# ENG-6786: an internal wake is NOT a conversation, and it leaves the previous",
1693
+ "# conversation's <channel> tag as the newest one in the transcript.",
1694
+ "#",
1695
+ "# The manager wakes an agent for board work by injecting a PLAIN tmux message",
1696
+ "# (manager-worker.ts kanban-work-trigger -> injectMessage(..., 'task', ...)),",
1697
+ "# rendered as `[Task: <name>] ...`. It carries NO <channel> envelope, so the",
1698
+ "# `tail -1` above still returns whatever customer conversation came before it,",
1699
+ "# and the housekeeping text the agent then writes gets recovered INTO that",
1700
+ "# customer thread. The kanban /loop notice rail has the same effect from the",
1701
+ "# other direction: it is kind=notice, so direct-chat deliberately writes no",
1702
+ "# pending marker for it, which means it can never become the recovery target",
1703
+ "# and can only leave the older tag in place.",
1704
+ "#",
1705
+ "# So classify ONE event per transcript record, in transcript order, and keep",
1706
+ "# only the last. If the newest inbound event is an internal task inject, the",
1707
+ "# newest <channel> tag is stale and must not correlate this turn's text.",
1708
+ "#",
1709
+ "# Per RECORD, not per match (CodeRabbit, PR #4301). The jq above emits exactly",
1710
+ "# one line per transcript record, so a record is a line. An earlier revision",
1711
+ "# ran `grep -oE '<channel \u2026>|\\[Task: \u2026\\]' | tail -1` over the whole stream,",
1712
+ "# which takes the last MATCH rather than the last RECORD: a genuine customer",
1713
+ "# message whose body merely contains the literal text `[Task: kanban-work-trigger]`",
1714
+ "# emitted its channel tag AND then the task marker, `tail -1` picked the marker,",
1715
+ "# and CHANNEL_TAG was cleared for a real inbound. That is over-suppression \u2014 the",
1716
+ "# silent-lost-reply class this net exists to prevent, reintroduced by the fix for",
1717
+ "# the leak. Quoting a task marker is not far-fetched: this hook's own incident",
1718
+ "# threads do it. So reduce each line to a single verdict, preferring a channel",
1719
+ "# envelope, and treat a task marker as an internal wake only when that same",
1720
+ "# record carries no envelope. sed (already used below) rather than awk, to add",
1721
+ "# no new dependency to the hook: `t` branches past the second rule once the",
1722
+ "# first has substituted, so a channel record can never also score as a task.",
1723
+ "#",
1724
+ "# This suppresses the auto-POST only (recover_*_for). Block-turn-end is left",
1725
+ "# armed on purpose: a reply that is genuinely owed still gets rescued, by the",
1726
+ "# MODEL composing it deliberately, rather than by this hook scraping internal",
1727
+ "# narration into a customer thread. Fixing the leak must not reintroduce the",
1728
+ "# silent-lost-reply class the net exists to prevent.",
1729
+ `LAST_INBOUND_EVENT=$(jq -r 'select((.type // "") != "assistant" and (.role // "") != "assistant") | ${jqNormalizeContent} | map(select(type == "object" and .type == "text") | .text | gsub("[\\n\\r]+"; " ")) | join(" ")' "$RECENT_FILE" 2>/dev/null | sed -nE -e 's/.*<channel [^>]+>.*/channel/p' -e 't' -e 's/.*\\[Task: [A-Za-z0-9_-]+\\].*/task/p' | tail -1 || true)`,
1730
+ "SYS_WAKE_LAST=0",
1731
+ 'if [ "$LAST_INBOUND_EVENT" = "task" ]; then SYS_WAKE_LAST=1; fi',
1732
+ "# A stale tag must not correlate anything: drop it so the per-source dispatch",
1733
+ "# and the sole-pending-marker fallback both see no target.",
1734
+ 'if [ "$SYS_WAKE_LAST" = "1" ]; then CHANNEL_TAG=""; fi',
1692
1735
  'TAG_SOURCE=""',
1693
1736
  `if [ -n "$CHANNEL_TAG" ]; then TAG_SOURCE=$(echo "$CHANNEL_TAG" | grep -oE 'source="[^"]+"' | head -1 | sed 's/source="\\(.*\\)"/\\1/' || true); fi`,
1694
1737
  "# ENG-6567: one context line per Stop that reached here (non-empty assistant",
@@ -1757,6 +1800,10 @@ function provisionStopHook(codeName) {
1757
1800
  ' [ "$hit" = "yes" ]',
1758
1801
  "}",
1759
1802
  "recover_telegram_for() {",
1803
+ " # ENG-6786: never synthesize a post when the newest inbound event was an",
1804
+ " # internal wake \u2014 the tag that selected this target belongs to an older",
1805
+ " # conversation, and the text is board housekeeping, not a reply to anyone.",
1806
+ ' if [ "$SYS_WAKE_LAST" = "1" ]; then log_ghost "skip=system_wake_last_no_recovery fn=${FUNCNAME[0]}"; return; fi',
1760
1807
  ' local chat_id="$1" msg_id="$2"',
1761
1808
  ' if [ -z "$chat_id" ] || [ -z "$msg_id" ]; then return; fi',
1762
1809
  " # ENG-6727 (mode 1): scoped same-turn guard. Suppress only if the agent",
@@ -1815,6 +1862,10 @@ function provisionStopHook(codeName) {
1815
1862
  ' log_ghost "telegram RECOVERED chat=$(safe_id "$chat_id") msg=$(safe_id "$msg_id") text_len=${#TEXT}"',
1816
1863
  "}",
1817
1864
  "recover_slack_for() {",
1865
+ " # ENG-6786: never synthesize a post when the newest inbound event was an",
1866
+ " # internal wake \u2014 the tag that selected this target belongs to an older",
1867
+ " # conversation, and the text is board housekeeping, not a reply to anyone.",
1868
+ ' if [ "$SYS_WAKE_LAST" = "1" ]; then log_ghost "skip=system_wake_last_no_recovery fn=${FUNCNAME[0]}"; return; fi',
1818
1869
  ' local channel="$1" thread_ts="$2"',
1819
1870
  ' if [ -z "$channel" ]; then return; fi',
1820
1871
  " # ENG-6727 (mode 1): scoped same-turn guard. Suppress only if the agent",
@@ -1931,6 +1982,10 @@ function provisionStopHook(codeName) {
1931
1982
  ' log_ghost "slack RECOVERED channel=$(safe_id "$channel") thread=$(safe_id "$thread_ts") marker=${marker_name} text_len=${#TEXT}"',
1932
1983
  "}",
1933
1984
  "recover_teams_for() {",
1985
+ " # ENG-6786: never synthesize a post when the newest inbound event was an",
1986
+ " # internal wake \u2014 the tag that selected this target belongs to an older",
1987
+ " # conversation, and the text is board housekeeping, not a reply to anyone.",
1988
+ ' if [ "$SYS_WAKE_LAST" = "1" ]; then log_ghost "skip=system_wake_last_no_recovery fn=${FUNCNAME[0]}"; return; fi',
1934
1989
  ' local conversation_id="$1" reply_to_id="$2" service_url="$3"',
1935
1990
  ' if [ -z "$conversation_id" ] || [ -z "$service_url" ]; then return; fi',
1936
1991
  " # ENG-6727 (mode 1): scoped same-turn guard. Suppress only if the agent",
@@ -2001,6 +2056,10 @@ function provisionStopHook(codeName) {
2001
2056
  "# marker only after /host/direct-chat/reply confirms, and removes the ledger entry on",
2002
2057
  "# success OR failure (re-arm), so a failed re-send retries on a later Stop.",
2003
2058
  "recover_directchat_for() {",
2059
+ " # ENG-6786: never synthesize a post when the newest inbound event was an",
2060
+ " # internal wake \u2014 the tag that selected this target belongs to an older",
2061
+ " # conversation, and the text is board housekeeping, not a reply to anyone.",
2062
+ ' if [ "$SYS_WAKE_LAST" = "1" ]; then log_ghost "skip=system_wake_last_no_recovery fn=${FUNCNAME[0]}"; return; fi',
2004
2063
  ' local session_id="$1" hex_session="$2"',
2005
2064
  ' if [ -z "$session_id" ] || [ -z "$hex_session" ]; then return; fi',
2006
2065
  ' local marker_path=""',
@@ -5549,7 +5608,7 @@ function exchangeFailureKind(err) {
5549
5608
  }
5550
5609
 
5551
5610
  // src/lib/api-client.ts
5552
- var agtCliVersion = true ? "0.28.547" : "dev";
5611
+ var agtCliVersion = true ? "0.28.549" : "dev";
5553
5612
  var lastConfigHash = null;
5554
5613
  function setConfigHash(hash) {
5555
5614
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -8861,4 +8920,4 @@ export {
8861
8920
  managerInstallSystemUnitCommand,
8862
8921
  managerUninstallSystemUnitCommand
8863
8922
  };
8864
- //# sourceMappingURL=chunk-SYHPBJK7.js.map
8923
+ //# sourceMappingURL=chunk-MDIHMULA.js.map