@integrity-labs/agt-cli 0.27.150-test.15 → 0.27.150-test.17

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.
@@ -10,7 +10,7 @@ import {
10
10
  registerFramework,
11
11
  resolveAvatarEnvUrl,
12
12
  wrapScheduledTaskPrompt
13
- } from "./chunk-WOOYOAPG.js";
13
+ } from "./chunk-FZTGR2AQ.js";
14
14
 
15
15
  // ../../packages/core/dist/integrations/registry.js
16
16
  var INTEGRATION_REGISTRY = [
@@ -4478,7 +4478,13 @@ function provisionStopHook(codeName) {
4478
4478
  "# tag (slack-channel.ts:1247 / telegram-channel.ts:776 emit content +",
4479
4479
  "# meta which Claude Code wraps in a <channel ...> preamble). Searching",
4480
4480
  "# the raw text gives us the exact pending conversation key.",
4481
- `CHANNEL_TAG=$(tail -400 "$TRANSCRIPT_PATH" | jq -r '(.message.content // .content // []) | map(select(.type == "text") | .text) | join(" ")' 2>/dev/null | grep -oE '<channel [^>]+>' | tail -1 || true)`,
4481
+ "# User-event content is frequently a PLAIN STRING (channel notifications",
4482
+ "# land that way), not a content-block array \u2014 map() over a string is a",
4483
+ "# jq error, which the 2>/dev/null swallowed, so the tag came back empty",
4484
+ "# and recovery silently no-oped on every Slack ghost reply (confirmed",
4485
+ "# live on sherlock/agt-aws-1 2026-06-10). Normalize string \u2192 one text",
4486
+ "# block before mapping.",
4487
+ `CHANNEL_TAG=$(tail -400 "$TRANSCRIPT_PATH" | jq -r '(.message.content // .content // []) | if type == "string" then [{type: "text", text: .}] else . end | map(select(.type == "text") | .text) | join(" ")' 2>/dev/null | grep -oE '<channel [^>]+>' | tail -1 || true)`,
4482
4488
  'TAG_SOURCE=""',
4483
4489
  `if [ -n "$CHANNEL_TAG" ]; then TAG_SOURCE=$(echo "$CHANNEL_TAG" | grep -oE 'source="[^"]+"' | head -1 | sed 's/source="\\(.*\\)"/\\1/' || true); fi`,
4484
4490
  'extract_attr() { echo "$1" | grep -oE "$2=\\"[^\\"]+\\"" | head -1 | sed -E "s/$2=\\"(.*)\\"/\\\\1/"; }',
@@ -4896,6 +4902,111 @@ function provisionOrientHook(codeName) {
4896
4902
  settings["hooks"] = hooks;
4897
4903
  writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
4898
4904
  }
4905
+ function provisionSessionStateHook(codeName) {
4906
+ const projectDir = getProjectDir(codeName);
4907
+ const claudeDir = join4(projectDir, ".claude");
4908
+ mkdirSync4(claudeDir, { recursive: true });
4909
+ const homeDir = getHomeDir3();
4910
+ const agentDir = join4(homeDir, ".augmented", codeName);
4911
+ const hookScriptPath = join4(claudeDir, "agt-session-state-hook.sh");
4912
+ const hookScript = `#!/usr/bin/env bash
4913
+ # Auto-generated by Augmented (ENG-6233 / ENG-6268) \u2014 SessionStart session-state
4914
+ # recorder. Writes the model + session origin (which only the agent's own
4915
+ # Claude Code session knows) to session-state.json, which the channel servers
4916
+ # read back for the /status command. Best-effort, silent; every path exits 0 so
4917
+ # it can NEVER block or fail session start.
4918
+ # Canonical source: packages/claudecode-plugin-augmented/hooks/session-state.sh
4919
+
4920
+ # Best-effort: any unexpected error just exits clean.
4921
+ trap 'exit 0' ERR
4922
+
4923
+ # Hook input (stdin canonical; CLAUDE_HOOK_INPUT kept as a fallback).
4924
+ INPUT="$(cat 2>/dev/null || true)"
4925
+ [ -n "$INPUT" ] || INPUT="\${CLAUDE_HOOK_INPUT:-}"
4926
+ [ -n "$INPUT" ] || exit 0
4927
+ command -v jq >/dev/null 2>&1 || exit 0
4928
+
4929
+ # Identity / state dir are baked at provision time.
4930
+ CODE_NAME="${codeName}"
4931
+ STATE_DIR="${agentDir}"
4932
+ mkdir -p "$STATE_DIR" 2>/dev/null || exit 0
4933
+
4934
+ # Pull the fields we surface from the SessionStart payload.
4935
+ SESSION_ID="$(printf '%s' "$INPUT" | jq -r '.session_id // empty' 2>/dev/null || true)"
4936
+ SOURCE="$(printf '%s' "$INPUT" | jq -r '.source // empty' 2>/dev/null || true)"
4937
+ MODEL="$(printf '%s' "$INPUT" | jq -r '.model // empty' 2>/dev/null || true)"
4938
+ CWD="$(printf '%s' "$INPUT" | jq -r '.cwd // empty' 2>/dev/null || true)"
4939
+ [ -n "$CWD" ] || CWD="\${CLAUDE_PROJECT_DIR:-$PWD}"
4940
+
4941
+ # Channels: the channel MCP servers wired in the project .mcp.json. The adapter
4942
+ # writes each channel as a bare server id \u2014 slack / telegram / msteams (the
4943
+ # DEV_CHANNEL_SERVER_IDS set) plus direct-chat \u2014 NOT a "<name>-channel" key, so
4944
+ # match that allowlist and exclude the non-channel servers (augmented,
4945
+ # cloud-broker, composio_*). The "-channel" suffix only names the bundled .js
4946
+ # asset, never the .mcp.json key (verified against a live host, ENG-6268).
4947
+ CHANNELS_JSON='[]'
4948
+ if [ -f "$CWD/.mcp.json" ]; then
4949
+ CHANNELS_JSON="$(jq -c '
4950
+ ["slack","telegram","msteams","direct-chat"] as $ch
4951
+ | [ (.mcpServers // {} | keys[]) | select(. as $k | $ch | index($k)) ]
4952
+ ' "$CWD/.mcp.json" 2>/dev/null || echo '[]')"
4953
+ [ -n "$CHANNELS_JSON" ] || CHANNELS_JSON='[]'
4954
+ fi
4955
+
4956
+ # Environment: best-effort from the agent's CLAUDE.md frontmatter (CHARTER.md
4957
+ # maps to CLAUDE.md for the Claude Code adapter; the frontmatter carries
4958
+ # environment: dev|stage|prod). Missing / unreadable -> omitted.
4959
+ ENVIRONMENT=""
4960
+ if [ -f "$CWD/CLAUDE.md" ]; then
4961
+ ENVIRONMENT="$(grep -m1 -E '^environment:[[:space:]]*' "$CWD/CLAUDE.md" 2>/dev/null | sed -E 's/^environment:[[:space:]]*//; s/[[:space:]]*$//' || true)"
4962
+ fi
4963
+
4964
+ # Seconds->millis keeps this portable across GNU (Linux hosts) and BSD (macOS
4965
+ # dev) date; second granularity is plenty for "started 12m ago".
4966
+ RECORDED_AT="$(date +%s)000"
4967
+
4968
+ # Write atomically (temp + rename) so a concurrent reader never sees a
4969
+ # half-written file.
4970
+ OUT="$STATE_DIR/session-state.json"
4971
+ TMP="$OUT.$$.tmp"
4972
+ if jq -nc --arg session_id "$SESSION_ID" --arg source "$SOURCE" --arg model "$MODEL" --arg cwd "$CWD" --arg environment "$ENVIRONMENT" --argjson channels "$CHANNELS_JSON" --argjson recorded_at "$RECORDED_AT" '{
4973
+ session_id: $session_id,
4974
+ source: $source,
4975
+ model: $model,
4976
+ cwd: $cwd,
4977
+ channels: $channels,
4978
+ recorded_at: $recorded_at
4979
+ }
4980
+ | if $environment == "" then . else . + { environment: $environment } end' > "$TMP" 2>/dev/null; then
4981
+ mv -f "$TMP" "$OUT" 2>/dev/null || rm -f "$TMP" 2>/dev/null || true
4982
+ else
4983
+ rm -f "$TMP" 2>/dev/null || true
4984
+ fi
4985
+
4986
+ exit 0
4987
+ `;
4988
+ writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
4989
+ const settingsPath = join4(claudeDir, "settings.local.json");
4990
+ let settings = {};
4991
+ try {
4992
+ settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
4993
+ } catch {
4994
+ }
4995
+ const hooks = settings["hooks"] ?? {};
4996
+ const existingSessionStart = Array.isArray(hooks["SessionStart"]) ? [...hooks["SessionStart"]] : [];
4997
+ const alreadyRegistered = existingSessionStart.some((entry) => {
4998
+ const entryHooks = entry.hooks;
4999
+ return Array.isArray(entryHooks) && entryHooks.some((h) => typeof h === "object" && h !== null && h.type === "command" && h.command === hookScriptPath);
5000
+ });
5001
+ if (!alreadyRegistered) {
5002
+ existingSessionStart.push({
5003
+ hooks: [{ type: "command", command: hookScriptPath }]
5004
+ });
5005
+ }
5006
+ hooks["SessionStart"] = existingSessionStart;
5007
+ settings["hooks"] = hooks;
5008
+ writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
5009
+ }
4899
5010
  function modifyJsonConfig(filePath, fn) {
4900
5011
  let originalContent;
4901
5012
  let config;
@@ -7851,6 +7962,7 @@ export {
7851
7962
  provisionIsolationHook,
7852
7963
  provisionAutoKanbanProgressHook,
7853
7964
  provisionOrientHook,
7965
+ provisionSessionStateHook,
7854
7966
  setJsonMode,
7855
7967
  isJsonMode,
7856
7968
  jsonOutput,
@@ -7881,4 +7993,4 @@ export {
7881
7993
  managerInstallSystemUnitCommand,
7882
7994
  managerUninstallSystemUnitCommand
7883
7995
  };
7884
- //# sourceMappingURL=chunk-24FTY53Z.js.map
7996
+ //# sourceMappingURL=chunk-L2JA4OHU.js.map