@integrity-labs/agt-cli 0.12.6 → 0.12.8

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.
@@ -17,7 +17,7 @@ import {
17
17
  resolveChannels,
18
18
  resolveDmTarget,
19
19
  wrapScheduledTaskPrompt
20
- } from "../chunk-35KA6J3P.js";
20
+ } from "../chunk-ZFTZDO5E.js";
21
21
  import {
22
22
  findTaskByTemplate,
23
23
  getProjectDir,
@@ -40,7 +40,7 @@ import {
40
40
 
41
41
  // src/lib/manager-worker.ts
42
42
  import { createHash } from "crypto";
43
- import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync, readdirSync, statSync, unlinkSync, copyFileSync } from "fs";
43
+ import { readFileSync, writeFileSync, appendFileSync, mkdirSync, chmodSync, existsSync, rmSync, readdirSync, statSync, unlinkSync, copyFileSync } from "fs";
44
44
  import https from "https";
45
45
  import { join as join2, dirname } from "path";
46
46
  import { homedir as homedir2 } from "os";
@@ -1119,10 +1119,36 @@ function send(msg) {
1119
1119
  log(`Error: ${msg.message}`);
1120
1120
  }
1121
1121
  }
1122
+ var managerLogPath = null;
1123
+ function redactForDiskLog(value) {
1124
+ try {
1125
+ return value.replace(/\b(Bearer\s+)[A-Za-z0-9._-]+\b/gi, "$1[REDACTED]").replace(/\bxox[baprs]-[A-Za-z0-9-]+\b/g, "[REDACTED-SLACK]").replace(/\btlk_[A-Za-z0-9._-]+\b/g, "[REDACTED-HOST]").replace(/\bsk-ant-[A-Za-z0-9_-]+\b/g, "[REDACTED-ANTHROPIC]").replace(/\b\d{8,12}:[A-Za-z0-9_-]{30,}\b/g, "[REDACTED-TELEGRAM]").replace(
1126
+ /\b([A-Z0-9_]*(?:TOKEN|SECRET|API[_-]?KEY|PASSWORD)[A-Z0-9_]*)=(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s\r\n]+)/gi,
1127
+ "$1=[REDACTED]"
1128
+ );
1129
+ } catch {
1130
+ return "[REDACTED]";
1131
+ }
1132
+ }
1122
1133
  function log(msg) {
1123
1134
  const ts = (/* @__PURE__ */ new Date()).toISOString();
1124
- process.stderr.write(`[manager-worker ${ts}] ${msg}
1135
+ const safeMsg = redactForDiskLog(msg);
1136
+ process.stderr.write(`[manager-worker ${ts}] ${safeMsg}
1125
1137
  `);
1138
+ try {
1139
+ if (!managerLogPath) {
1140
+ managerLogPath = join2(homedir2(), ".augmented", "manager.log");
1141
+ mkdirSync(dirname(managerLogPath), { recursive: true });
1142
+ if (!existsSync(managerLogPath)) {
1143
+ appendFileSync(managerLogPath, "", { mode: 384 });
1144
+ } else {
1145
+ chmodSync(managerLogPath, 384);
1146
+ }
1147
+ }
1148
+ appendFileSync(managerLogPath, `[manager-worker ${ts}] ${safeMsg}
1149
+ `);
1150
+ } catch {
1151
+ }
1126
1152
  }
1127
1153
  function sha256(content) {
1128
1154
  return createHash("sha256").update(content, "utf8").digest("hex");
@@ -1966,9 +1992,20 @@ async function processAgent(agent, agentStates) {
1966
1992
  activeChannels.get(channelId).add(agent.code_name);
1967
1993
  const configHash = createHash("sha256").update(JSON.stringify(entry.config)).digest("hex");
1968
1994
  const cacheKey = `${agent.agent_id}:${channelId}`;
1969
- if (knownChannelConfigHashes.get(cacheKey) === configHash) {
1995
+ let onDiskPresent = true;
1996
+ try {
1997
+ onDiskPresent = frameworkAdapter.hasChannelCredentials?.(agent.code_name, channelId) ?? true;
1998
+ } catch (err) {
1999
+ log(`hasChannelCredentials failed for '${agent.code_name}/${channelId}': ${err.message} \u2014 forcing credential rewrite`);
2000
+ onDiskPresent = false;
2001
+ }
2002
+ if (knownChannelConfigHashes.get(cacheKey) === configHash && onDiskPresent) {
1970
2003
  continue;
1971
2004
  }
2005
+ if (!onDiskPresent && knownChannelConfigHashes.has(cacheKey)) {
2006
+ log(`Cached hash for '${agent.code_name}/${channelId}' but on-disk entry missing \u2014 re-writing credentials`);
2007
+ knownChannelConfigHashes.delete(cacheKey);
2008
+ }
1972
2009
  try {
1973
2010
  const sessionMode2 = refreshData.agent.session_mode;
1974
2011
  frameworkAdapter.writeChannelCredentials(agent.code_name, channelId, entry.config, { sessionMode: sessionMode2 });
@@ -3002,14 +3039,18 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
3002
3039
  const channels = [];
3003
3040
  const devChannels = [];
3004
3041
  if (channelConfigs) {
3005
- if ("telegram" in channelConfigs) {
3006
- channels.push("plugin:telegram@claude-plugins-official");
3042
+ const isChannelEnabled = (id) => {
3043
+ const entry = channelConfigs[id];
3044
+ return !!entry?.config && (entry.status === "active" || entry.status === "pending");
3045
+ };
3046
+ if (isChannelEnabled("slack")) {
3047
+ devChannels.push("server:slack");
3007
3048
  }
3008
- if ("discord" in channelConfigs) {
3009
- channels.push("plugin:discord@claude-plugins-official");
3049
+ if (isChannelEnabled("telegram")) {
3050
+ devChannels.push("server:telegram");
3010
3051
  }
3011
- if ("slack" in channelConfigs) {
3012
- devChannels.push("server:slack");
3052
+ if (isChannelEnabled("discord")) {
3053
+ channels.push("plugin:discord@claude-plugins-official");
3013
3054
  }
3014
3055
  }
3015
3056
  devChannels.push("server:direct-chat");
@@ -4724,7 +4765,7 @@ function deployMcpAssets() {
4724
4765
  log("[manager] MCP assets not found in CLI package \u2014 skipping deployment");
4725
4766
  return;
4726
4767
  }
4727
- for (const file of ["index.js", "slack-channel.js", "direct-chat-channel.js"]) {
4768
+ for (const file of ["index.js", "slack-channel.js", "direct-chat-channel.js", "telegram-channel.js"]) {
4728
4769
  const src = join2(mcpSourceDir, file);
4729
4770
  const dst = join2(targetDir, file);
4730
4771
  if (!existsSync(src)) continue;