@integrity-labs/agt-cli 0.28.86 → 0.28.88

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.
@@ -18088,7 +18088,7 @@ async function postEphemeralViaResponseUrl(responseUrl, text, logTag) {
18088
18088
  }
18089
18089
  }
18090
18090
  async function forwardOnboardingSlashCommand(opts) {
18091
- const { verb, path, userId, responseUrl, codeName } = opts;
18091
+ const { verb, path, userId, channelId, responseUrl, codeName } = opts;
18092
18092
  if (!AGT_HOST || !AGT_API_KEY || !AGT_AGENT_ID) {
18093
18093
  await postEphemeralViaResponseUrl(
18094
18094
  responseUrl,
@@ -18106,7 +18106,7 @@ async function forwardOnboardingSlashCommand(opts) {
18106
18106
  };
18107
18107
  const res = await apiCall2(cfg, "POST", `/host${path}`, {
18108
18108
  agent_id: AGT_AGENT_ID,
18109
- initiator: { channel: "slack", user_id: userId }
18109
+ initiator: { channel: "slack", user_id: userId, channel_id: channelId }
18110
18110
  });
18111
18111
  const data = await res.json();
18112
18112
  const text = data.ok ? `\u{1F504} ${data.message ?? "Onboarding updated."}` : data.message ?? `:x: \`${verb}\` failed${data.error ? `: ${data.error}` : "."}`;
@@ -18399,6 +18399,7 @@ async function handleSlashCommandEnvelope(payload) {
18399
18399
  verb: "/onboard",
18400
18400
  path: "/onboarding/reset",
18401
18401
  userId: payload.user_id,
18402
+ channelId: payload.channel_id,
18402
18403
  responseUrl,
18403
18404
  codeName
18404
18405
  });
@@ -18409,6 +18410,7 @@ async function handleSlashCommandEnvelope(payload) {
18409
18410
  verb: "/resume-onboarding",
18410
18411
  path: "/onboarding/resume",
18411
18412
  userId: payload.user_id,
18413
+ channelId: payload.channel_id,
18412
18414
  responseUrl,
18413
18415
  codeName
18414
18416
  });
@@ -14471,15 +14471,15 @@ import {
14471
14471
  createWriteStream,
14472
14472
  existsSync as existsSync6,
14473
14473
  ftruncateSync,
14474
- mkdirSync as mkdirSync6,
14474
+ mkdirSync as mkdirSync7,
14475
14475
  openSync,
14476
14476
  readFileSync as readFileSync9,
14477
14477
  readdirSync as readdirSync3,
14478
- renameSync as renameSync5,
14478
+ renameSync as renameSync6,
14479
14479
  statSync as statSync2,
14480
14480
  unlinkSync as unlinkSync6,
14481
14481
  watch,
14482
- writeFileSync as writeFileSync7,
14482
+ writeFileSync as writeFileSync8,
14483
14483
  writeSync
14484
14484
  } from "fs";
14485
14485
  import { homedir as homedir3 } from "os";
@@ -15083,6 +15083,22 @@ function isMaintenanceModeActive(opts) {
15083
15083
  });
15084
15084
  }
15085
15085
 
15086
+ // src/turn-initiator-marker.ts
15087
+ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, renameSync as renameSync3 } from "fs";
15088
+ import { dirname as dirname3 } from "path";
15089
+ function writeTurnInitiatorMarker(input) {
15090
+ const file = process.env["AGT_TURN_INITIATOR_FILE"];
15091
+ if (!file || !input.sender_id) return;
15092
+ try {
15093
+ mkdirSync4(dirname3(file), { recursive: true });
15094
+ const marker = { ...input, ts: Date.now() };
15095
+ const tmp = `${file}.tmp`;
15096
+ writeFileSync4(tmp, JSON.stringify(marker), "utf8");
15097
+ renameSync3(tmp, file);
15098
+ } catch {
15099
+ }
15100
+ }
15101
+
15086
15102
  // src/watch-command.ts
15087
15103
  var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
15088
15104
  var WATCH_MAX_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
@@ -15696,11 +15712,11 @@ function buildCommandRegistrations() {
15696
15712
  // src/telegram-offset-store.ts
15697
15713
  import {
15698
15714
  existsSync as existsSync3,
15699
- mkdirSync as mkdirSync4,
15715
+ mkdirSync as mkdirSync5,
15700
15716
  readFileSync as readFileSync4,
15701
- renameSync as renameSync3,
15717
+ renameSync as renameSync4,
15702
15718
  unlinkSync as unlinkSync4,
15703
- writeFileSync as writeFileSync4
15719
+ writeFileSync as writeFileSync5
15704
15720
  } from "fs";
15705
15721
  import { randomUUID as randomUUID2 } from "crypto";
15706
15722
  function loadPersistedOffset(filePath) {
@@ -15729,9 +15745,9 @@ function persistOffset(opts) {
15729
15745
  };
15730
15746
  const tmpPath = `${filePath}.${process.pid}.${randomUUID2()}.tmp`;
15731
15747
  try {
15732
- mkdirSync4(dir, { recursive: true, mode: 448 });
15733
- writeFileSync4(tmpPath, JSON.stringify(marker), { mode: 384 });
15734
- renameSync3(tmpPath, filePath);
15748
+ mkdirSync5(dir, { recursive: true, mode: 448 });
15749
+ writeFileSync5(tmpPath, JSON.stringify(marker), { mode: 384 });
15750
+ renameSync4(tmpPath, filePath);
15735
15751
  } catch (err) {
15736
15752
  onError?.(`getUpdates offset persist failed: ${err.message}`);
15737
15753
  try {
@@ -16362,11 +16378,11 @@ function parseProgressHeartbeat(raw) {
16362
16378
  // src/mcp-spawn-lock.ts
16363
16379
  import {
16364
16380
  existsSync as existsSync5,
16365
- mkdirSync as mkdirSync5,
16381
+ mkdirSync as mkdirSync6,
16366
16382
  readFileSync as readFileSync7,
16367
- renameSync as renameSync4,
16383
+ renameSync as renameSync5,
16368
16384
  unlinkSync as unlinkSync5,
16369
- writeFileSync as writeFileSync5
16385
+ writeFileSync as writeFileSync6
16370
16386
  } from "fs";
16371
16387
  import { join as join5 } from "path";
16372
16388
  function defaultIsPidAlive(pid) {
@@ -16396,11 +16412,11 @@ function acquireMcpSpawnLock(args) {
16396
16412
  return { kind: "blocked", path, holder: existing };
16397
16413
  }
16398
16414
  }
16399
- mkdirSync5(agentDir, { recursive: true, mode: 448 });
16415
+ mkdirSync6(agentDir, { recursive: true, mode: 448 });
16400
16416
  const tmpPath = `${path}.${selfPid}.tmp`;
16401
16417
  const payload = { pid: selfPid, started_at: now() };
16402
- writeFileSync5(tmpPath, JSON.stringify(payload), { mode: 384 });
16403
- renameSync4(tmpPath, path);
16418
+ writeFileSync6(tmpPath, JSON.stringify(payload), { mode: 384 });
16419
+ renameSync5(tmpPath, path);
16404
16420
  return { kind: "acquired", path };
16405
16421
  }
16406
16422
  function releaseMcpSpawnLock(lockPath, opts = {}) {
@@ -16429,7 +16445,7 @@ function readLockHolder(path) {
16429
16445
  }
16430
16446
 
16431
16447
  // src/ack-reaction.ts
16432
- import { readdirSync as readdirSync2, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
16448
+ import { readdirSync as readdirSync2, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
16433
16449
  import { join as join6 } from "path";
16434
16450
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
16435
16451
  var ACK_STARTUP_GRACE_MS = 6e4;
@@ -16603,7 +16619,7 @@ function recordChannelDeflection(agentDir, channel, cause) {
16603
16619
  }
16604
16620
  counts[cause] = (counts[cause] ?? 0) + 1;
16605
16621
  try {
16606
- writeFileSync6(path, JSON.stringify(counts), { mode: 384 });
16622
+ writeFileSync7(path, JSON.stringify(counts), { mode: 384 });
16607
16623
  } catch {
16608
16624
  }
16609
16625
  }
@@ -16740,7 +16756,7 @@ var stderrLogStream = null;
16740
16756
  if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
16741
16757
  try {
16742
16758
  const logDir = join7(homedir3(), ".augmented", AGENT_CODE_NAME);
16743
- mkdirSync6(logDir, { recursive: true });
16759
+ mkdirSync7(logDir, { recursive: true });
16744
16760
  stderrLogStream = createWriteStream(join7(logDir, "telegram-channel-stderr.log"), {
16745
16761
  flags: "a",
16746
16762
  mode: 384
@@ -17239,7 +17255,9 @@ async function handleOnboardingCommand(opts) {
17239
17255
  };
17240
17256
  const res = await apiCall2(cfg, "POST", `/host/onboarding/${opts.mode}`, {
17241
17257
  agent_id: AGT_AGENT_ID,
17242
- initiator: { channel: "telegram", user_id: opts.senderId }
17258
+ // ENG-6583: channel_id = the chat the command came from, so onboarding
17259
+ // anchors here and the agent asks its manager back in this chat.
17260
+ initiator: { channel: "telegram", user_id: opts.senderId, channel_id: opts.chatId }
17243
17261
  });
17244
17262
  const data = await res.json();
17245
17263
  process.stderr.write(
@@ -17260,7 +17278,7 @@ async function handleOnboardingCommand(opts) {
17260
17278
  async function handleRestartCommand(opts) {
17261
17279
  try {
17262
17280
  if (!existsSync6(RESTART_FLAGS_DIR)) {
17263
- mkdirSync6(RESTART_FLAGS_DIR, { recursive: true });
17281
+ mkdirSync7(RESTART_FLAGS_DIR, { recursive: true });
17264
17282
  }
17265
17283
  const flagPath = join7(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
17266
17284
  writeTelegramRestartConfirm(
@@ -17274,8 +17292,8 @@ async function handleRestartCommand(opts) {
17274
17292
  reply: { chat_id: opts.chatId, message_id: opts.messageId }
17275
17293
  };
17276
17294
  const tmpPath = `${flagPath}.${process.pid}.${randomUUID3()}.tmp`;
17277
- writeFileSync7(tmpPath, JSON.stringify(flag) + "\n", "utf8");
17278
- renameSync5(tmpPath, flagPath);
17295
+ writeFileSync8(tmpPath, JSON.stringify(flag) + "\n", "utf8");
17296
+ renameSync6(tmpPath, flagPath);
17279
17297
  process.stderr.write(
17280
17298
  `telegram-channel(${AGENT_CODE_NAME}): /restart queued from chat ${redactId(opts.chatId)}
17281
17299
  `
@@ -17732,8 +17750,8 @@ function writePendingInboundMarker(chatId, messageId, chatType, undeliverable =
17732
17750
  ...payload ? { payload } : {}
17733
17751
  };
17734
17752
  try {
17735
- mkdirSync6(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
17736
- writeFileSync7(path, JSON.stringify(marker), { mode: 384 });
17753
+ mkdirSync7(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
17754
+ writeFileSync8(path, JSON.stringify(marker), { mode: 384 });
17737
17755
  } catch (err) {
17738
17756
  process.stderr.write(
17739
17757
  `telegram-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
@@ -17837,7 +17855,7 @@ async function processRecoveryOutboxFile(filename) {
17837
17855
  `
17838
17856
  );
17839
17857
  try {
17840
- renameSync5(fullPath, `${fullPath}.parse-error.poison`);
17858
+ renameSync6(fullPath, `${fullPath}.parse-error.poison`);
17841
17859
  } catch {
17842
17860
  }
17843
17861
  return;
@@ -17848,7 +17866,7 @@ async function processRecoveryOutboxFile(filename) {
17848
17866
  `
17849
17867
  );
17850
17868
  try {
17851
- renameSync5(fullPath, `${fullPath}.malformed.poison`);
17869
+ renameSync6(fullPath, `${fullPath}.malformed.poison`);
17852
17870
  } catch {
17853
17871
  }
17854
17872
  return;
@@ -17895,7 +17913,7 @@ ${payload.text}`;
17895
17913
  const next = nextRetryName(filename);
17896
17914
  if (next) {
17897
17915
  try {
17898
- renameSync5(fullPath, join7(RECOVERY_OUTBOX_DIR, next.next));
17916
+ renameSync6(fullPath, join7(RECOVERY_OUTBOX_DIR, next.next));
17899
17917
  if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
17900
17918
  process.stderr.write(
17901
17919
  `telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -17947,7 +17965,7 @@ function scanRecoveryRetries() {
17947
17965
  function startRecoveryOutboxWatcher() {
17948
17966
  if (!RECOVERY_OUTBOX_DIR) return;
17949
17967
  try {
17950
- mkdirSync6(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
17968
+ mkdirSync7(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
17951
17969
  } catch (err) {
17952
17970
  process.stderr.write(
17953
17971
  `telegram-channel(${AGENT_CODE_NAME}): recovery outbox mkdir failed: ${err.message}
@@ -19519,6 +19537,14 @@ async function pollLoop() {
19519
19537
  is_bot: isFromBot,
19520
19538
  is_peer_agent: !!peerAgentMeta
19521
19539
  });
19540
+ if (!isFromBot && !peerAgentMeta && userId && userId !== "unknown" && chatId) {
19541
+ writeTurnInitiatorMarker({
19542
+ channel: "telegram",
19543
+ sender_id: String(userId),
19544
+ sender_name: userName,
19545
+ channel_ref: String(chatId)
19546
+ });
19547
+ }
19522
19548
  if (!isFromBot && !peerAgentMeta) {
19523
19549
  inboundContextClient?.recordInbound({
19524
19550
  sourceIntegration: "telegram",
@@ -25,8 +25,8 @@ import {
25
25
  takeZombieDetection,
26
26
  writeDirectChatSessionState,
27
27
  writePersistentClaudeWrapper
28
- } from "./chunk-OZWBVM7M.js";
29
- import "./chunk-E5TGFEDQ.js";
28
+ } from "./chunk-5Z43ORR6.js";
29
+ import "./chunk-3G2D4VXI.js";
30
30
  import "./chunk-XWVM4KPK.js";
31
31
  export {
32
32
  SEND_KEYS_ENTER_DELAY_MS,
@@ -56,4 +56,4 @@ export {
56
56
  writeDirectChatSessionState,
57
57
  writePersistentClaudeWrapper
58
58
  };
59
- //# sourceMappingURL=persistent-session-ZAKXWRX7.js.map
59
+ //# sourceMappingURL=persistent-session-OMLGMEGO.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  paneLogPath
3
- } from "./chunk-OZWBVM7M.js";
4
- import "./chunk-E5TGFEDQ.js";
3
+ } from "./chunk-5Z43ORR6.js";
4
+ import "./chunk-3G2D4VXI.js";
5
5
  import "./chunk-XWVM4KPK.js";
6
6
 
7
7
  // src/lib/responsiveness-probe.ts
@@ -250,4 +250,4 @@ export {
250
250
  parkPendingInbound,
251
251
  readAndResetChannelDeflections
252
252
  };
253
- //# sourceMappingURL=responsiveness-probe-NKH4VYGR.js.map
253
+ //# sourceMappingURL=responsiveness-probe-ANX4EOCH.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.86",
3
+ "version": "0.28.88",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {