@integrity-labs/agt-cli 0.28.81 → 0.28.83

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.
@@ -28,7 +28,7 @@ import {
28
28
  requireHost,
29
29
  safeWriteJsonAtomic,
30
30
  setConfigHash
31
- } from "../chunk-DA3DAU5V.js";
31
+ } from "../chunk-WFIKSR3G.js";
32
32
  import {
33
33
  getProjectDir as getProjectDir2,
34
34
  getReadyTasks,
@@ -6803,7 +6803,7 @@ var cachedMaintenanceWindow = null;
6803
6803
  var lastVersionCheckAt = 0;
6804
6804
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6805
6805
  var lastResponsivenessProbeAt = 0;
6806
- var agtCliVersion = true ? "0.28.81" : "dev";
6806
+ var agtCliVersion = true ? "0.28.83" : "dev";
6807
6807
  function resolveBrewPath(execFileSync4) {
6808
6808
  try {
6809
6809
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -15518,15 +15518,15 @@ import {
15518
15518
  createWriteStream,
15519
15519
  existsSync as existsSync7,
15520
15520
  ftruncateSync,
15521
- mkdirSync as mkdirSync6,
15521
+ mkdirSync as mkdirSync7,
15522
15522
  openSync,
15523
15523
  readFileSync as readFileSync9,
15524
15524
  readdirSync as readdirSync3,
15525
- renameSync as renameSync3,
15525
+ renameSync as renameSync4,
15526
15526
  statSync as statSync2,
15527
15527
  unlinkSync as unlinkSync5,
15528
15528
  watch,
15529
- writeFileSync as writeFileSync7,
15529
+ writeFileSync as writeFileSync8,
15530
15530
  writeSync
15531
15531
  } from "fs";
15532
15532
  import { basename, join as join7, resolve as resolve2 } from "path";
@@ -15812,9 +15812,25 @@ async function runOrRetry(fn, opts) {
15812
15812
  }
15813
15813
  }
15814
15814
 
15815
- // src/slack-bot-photo.ts
15816
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
15815
+ // src/turn-initiator-marker.ts
15816
+ import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, renameSync as renameSync2 } from "fs";
15817
15817
  import { dirname as dirname4 } from "path";
15818
+ function writeTurnInitiatorMarker(input) {
15819
+ const file = process.env["AGT_TURN_INITIATOR_FILE"];
15820
+ if (!file || !input.sender_id) return;
15821
+ try {
15822
+ mkdirSync4(dirname4(file), { recursive: true });
15823
+ const marker = { ...input, ts: Date.now() };
15824
+ const tmp = `${file}.tmp`;
15825
+ writeFileSync5(tmp, JSON.stringify(marker), "utf8");
15826
+ renameSync2(tmp, file);
15827
+ } catch {
15828
+ }
15829
+ }
15830
+
15831
+ // src/slack-bot-photo.ts
15832
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
15833
+ import { dirname as dirname5 } from "path";
15818
15834
  async function applyBotPhoto(opts) {
15819
15835
  const fetchImpl = opts.fetchImpl ?? fetch;
15820
15836
  const log = opts.log ?? ((m) => {
@@ -15864,8 +15880,8 @@ async function applyBotPhoto(opts) {
15864
15880
  }
15865
15881
  if (markerPath) {
15866
15882
  try {
15867
- mkdirSync4(dirname4(markerPath), { recursive: true, mode: 448 });
15868
- writeFileSync5(markerPath, avatarUrl, { mode: 384 });
15883
+ mkdirSync5(dirname5(markerPath), { recursive: true, mode: 448 });
15884
+ writeFileSync6(markerPath, avatarUrl, { mode: 384 });
15869
15885
  } catch {
15870
15886
  }
15871
15887
  }
@@ -16648,11 +16664,11 @@ function createSlackBotUserIdClient(args) {
16648
16664
  // src/mcp-spawn-lock.ts
16649
16665
  import {
16650
16666
  existsSync as existsSync6,
16651
- mkdirSync as mkdirSync5,
16667
+ mkdirSync as mkdirSync6,
16652
16668
  readFileSync as readFileSync8,
16653
- renameSync as renameSync2,
16669
+ renameSync as renameSync3,
16654
16670
  unlinkSync as unlinkSync4,
16655
- writeFileSync as writeFileSync6
16671
+ writeFileSync as writeFileSync7
16656
16672
  } from "fs";
16657
16673
  import { join as join6 } from "path";
16658
16674
  function defaultIsPidAlive(pid) {
@@ -16682,11 +16698,11 @@ function acquireMcpSpawnLock(args) {
16682
16698
  return { kind: "blocked", path, holder: existing };
16683
16699
  }
16684
16700
  }
16685
- mkdirSync5(agentDir, { recursive: true, mode: 448 });
16701
+ mkdirSync6(agentDir, { recursive: true, mode: 448 });
16686
16702
  const tmpPath = `${path}.${selfPid}.tmp`;
16687
16703
  const payload = { pid: selfPid, started_at: now() };
16688
- writeFileSync6(tmpPath, JSON.stringify(payload), { mode: 384 });
16689
- renameSync2(tmpPath, path);
16704
+ writeFileSync7(tmpPath, JSON.stringify(payload), { mode: 384 });
16705
+ renameSync3(tmpPath, path);
16690
16706
  return { kind: "acquired", path };
16691
16707
  }
16692
16708
  function releaseMcpSpawnLock(lockPath, opts = {}) {
@@ -16983,8 +16999,8 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
16983
16999
  ...payload ? { payload } : {}
16984
17000
  };
16985
17001
  try {
16986
- mkdirSync6(SLACK_PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
16987
- writeFileSync7(path, JSON.stringify(marker), { mode: 384 });
17002
+ mkdirSync7(SLACK_PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
17003
+ writeFileSync8(path, JSON.stringify(marker), { mode: 384 });
16988
17004
  } catch (err) {
16989
17005
  process.stderr.write(
16990
17006
  `slack-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
@@ -17257,7 +17273,7 @@ async function processSlackRecoveryOutboxFile(filename) {
17257
17273
  `
17258
17274
  );
17259
17275
  try {
17260
- renameSync3(fullPath, `${fullPath}.parse-error.poison`);
17276
+ renameSync4(fullPath, `${fullPath}.parse-error.poison`);
17261
17277
  } catch {
17262
17278
  }
17263
17279
  return;
@@ -17268,7 +17284,7 @@ async function processSlackRecoveryOutboxFile(filename) {
17268
17284
  `
17269
17285
  );
17270
17286
  try {
17271
- renameSync3(fullPath, `${fullPath}.malformed.poison`);
17287
+ renameSync4(fullPath, `${fullPath}.malformed.poison`);
17272
17288
  } catch {
17273
17289
  }
17274
17290
  return;
@@ -17326,7 +17342,7 @@ ${payload.text}`;
17326
17342
  const next = slackNextRetryName(filename);
17327
17343
  if (next) {
17328
17344
  try {
17329
- renameSync3(fullPath, join7(SLACK_RECOVERY_OUTBOX_DIR, next.next));
17345
+ renameSync4(fullPath, join7(SLACK_RECOVERY_OUTBOX_DIR, next.next));
17330
17346
  if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
17331
17347
  process.stderr.write(
17332
17348
  `slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -17377,7 +17393,7 @@ function scanSlackRecoveryRetries() {
17377
17393
  function startSlackRecoveryOutboxWatcher() {
17378
17394
  if (!SLACK_RECOVERY_OUTBOX_DIR) return;
17379
17395
  try {
17380
- mkdirSync6(SLACK_RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
17396
+ mkdirSync7(SLACK_RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
17381
17397
  } catch (err) {
17382
17398
  process.stderr.write(
17383
17399
  `slack-channel(${AGENT_CODE_NAME}): recovery outbox mkdir failed: ${err.message}
@@ -18073,15 +18089,6 @@ async function postEphemeralViaResponseUrl(responseUrl, text, logTag) {
18073
18089
  }
18074
18090
  async function forwardOnboardingSlashCommand(opts) {
18075
18091
  const { verb, path, userId, responseUrl, codeName } = opts;
18076
- const allowed = getEffectiveAllowedUsers();
18077
- if (allowed.size > 0 && (!userId || !allowed.has(userId))) {
18078
- await postEphemeralViaResponseUrl(
18079
- responseUrl,
18080
- `\u{1F6AB} \`${verb}\` denied \u2014 your Slack user is not in the allowlist for \`${codeName}\`.`,
18081
- codeName
18082
- );
18083
- return;
18084
- }
18085
18092
  if (!AGT_HOST || !AGT_API_KEY || !AGT_AGENT_ID) {
18086
18093
  await postEphemeralViaResponseUrl(
18087
18094
  responseUrl,
@@ -18097,9 +18104,12 @@ async function forwardOnboardingSlashCommand(opts) {
18097
18104
  apiKey: AGT_API_KEY,
18098
18105
  agentId: AGT_AGENT_ID
18099
18106
  };
18100
- const res = await apiCall2(cfg, "POST", `/host${path}`, { agent_id: AGT_AGENT_ID });
18107
+ const res = await apiCall2(cfg, "POST", `/host${path}`, {
18108
+ agent_id: AGT_AGENT_ID,
18109
+ initiator: { channel: "slack", user_id: userId }
18110
+ });
18101
18111
  const data = await res.json();
18102
- const text = data.ok ? `\u{1F504} ${data.message ?? "Onboarding updated."}` : `:x: \`${verb}\` failed${data.error ? `: ${data.error}` : "."}`;
18112
+ const text = data.ok ? `\u{1F504} ${data.message ?? "Onboarding updated."}` : data.message ?? `:x: \`${verb}\` failed${data.error ? `: ${data.error}` : "."}`;
18103
18113
  await postEphemeralViaResponseUrl(responseUrl, text, codeName);
18104
18114
  } catch (err) {
18105
18115
  process.stderr.write(
@@ -18340,7 +18350,7 @@ async function handleSlashCommandEnvelope(payload) {
18340
18350
  }
18341
18351
  try {
18342
18352
  if (!existsSync7(RESTART_FLAGS_DIR)) {
18343
- mkdirSync6(RESTART_FLAGS_DIR, { recursive: true });
18353
+ mkdirSync7(RESTART_FLAGS_DIR, { recursive: true });
18344
18354
  }
18345
18355
  const flagPath = join7(RESTART_FLAGS_DIR, `${codeName}.flag`);
18346
18356
  writeSlackRestartConfirm(
@@ -18360,8 +18370,8 @@ async function handleSlashCommandEnvelope(payload) {
18360
18370
  }
18361
18371
  };
18362
18372
  const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
18363
- writeFileSync7(tmpPath, JSON.stringify(flag) + "\n", "utf8");
18364
- renameSync3(tmpPath, flagPath);
18373
+ writeFileSync8(tmpPath, JSON.stringify(flag) + "\n", "utf8");
18374
+ renameSync4(tmpPath, flagPath);
18365
18375
  process.stderr.write(
18366
18376
  `slack-channel(${codeName}): /restart slash-command queued from channel ${hashChannelId(payload.channel_id)}
18367
18377
  `
@@ -18478,7 +18488,7 @@ async function handleRestartCommand(opts) {
18478
18488
  const codeName = AGENT_CODE_NAME ?? "unknown";
18479
18489
  try {
18480
18490
  if (!existsSync7(RESTART_FLAGS_DIR)) {
18481
- mkdirSync6(RESTART_FLAGS_DIR, { recursive: true });
18491
+ mkdirSync7(RESTART_FLAGS_DIR, { recursive: true });
18482
18492
  }
18483
18493
  const flagPath = join7(RESTART_FLAGS_DIR, `${codeName}.flag`);
18484
18494
  writeSlackRestartConfirm(
@@ -18499,8 +18509,8 @@ async function handleRestartCommand(opts) {
18499
18509
  }
18500
18510
  };
18501
18511
  const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
18502
- writeFileSync7(tmpPath, JSON.stringify(flag) + "\n", "utf8");
18503
- renameSync3(tmpPath, flagPath);
18512
+ writeFileSync8(tmpPath, JSON.stringify(flag) + "\n", "utf8");
18513
+ renameSync4(tmpPath, flagPath);
18504
18514
  process.stderr.write(
18505
18515
  `slack-channel(${codeName}): /restart queued from channel ${hashChannelId(opts.channel)}
18506
18516
  `
@@ -18643,7 +18653,7 @@ var slackStderrLogStream = null;
18643
18653
  if (AGENT_CODE_NAME) {
18644
18654
  try {
18645
18655
  const logDir = join7(homedir3(), ".augmented", AGENT_CODE_NAME);
18646
- mkdirSync6(logDir, { recursive: true });
18656
+ mkdirSync7(logDir, { recursive: true });
18647
18657
  slackStderrLogStream = createWriteStream(join7(logDir, "slack-channel-stderr.log"), {
18648
18658
  flags: "a",
18649
18659
  mode: 384
@@ -19876,8 +19886,8 @@ async function downloadSlackFile(fileId, codeName) {
19876
19886
  if (!isPathInside(savedPath, dir)) {
19877
19887
  throw new Error(`refusing to write ${savedPath} outside ${dir}`);
19878
19888
  }
19879
- mkdirSync6(dir, { recursive: true });
19880
- writeFileSync7(savedPath, bytes, { mode: 384 });
19889
+ mkdirSync7(dir, { recursive: true });
19890
+ writeFileSync8(savedPath, bytes, { mode: 384 });
19881
19891
  try {
19882
19892
  chmodSync(savedPath, 384);
19883
19893
  } catch {
@@ -20493,6 +20503,14 @@ async function connectSocketMode() {
20493
20503
  if (channel && ts && armMarker) {
20494
20504
  attachSlackReplayPayload(channel, threadTs, ts, replayPayload);
20495
20505
  }
20506
+ if (!isFromBot && evt.user && channel) {
20507
+ writeTurnInitiatorMarker({
20508
+ channel: "slack",
20509
+ sender_id: evt.user,
20510
+ sender_name: userName,
20511
+ channel_ref: threadTs
20512
+ });
20513
+ }
20496
20514
  await mcp.notification({
20497
20515
  method: "notifications/claude/channel",
20498
20516
  params: replayPayload
@@ -17190,7 +17190,8 @@ async function handleOnboardingCommand(opts) {
17190
17190
  agentId: AGT_AGENT_ID
17191
17191
  };
17192
17192
  const res = await apiCall2(cfg, "POST", `/host/onboarding/${opts.mode}`, {
17193
- agent_id: AGT_AGENT_ID
17193
+ agent_id: AGT_AGENT_ID,
17194
+ initiator: { channel: "telegram", user_id: opts.senderId }
17194
17195
  });
17195
17196
  const data = await res.json();
17196
17197
  process.stderr.write(
@@ -17198,7 +17199,7 @@ async function handleOnboardingCommand(opts) {
17198
17199
  `
17199
17200
  );
17200
17201
  await reply(
17201
- data.ok ? `\u{1F504} ${data.message ?? "Onboarding updated."}` : `\u274C ${verb} failed${data.error ? `: ${data.error}` : "."}`
17202
+ data.ok ? `\u{1F504} ${data.message ?? "Onboarding updated."}` : data.message ?? `\u274C ${verb} failed${data.error ? `: ${data.error}` : "."}`
17202
17203
  );
17203
17204
  } catch (err) {
17204
17205
  process.stderr.write(
@@ -19210,7 +19211,10 @@ async function pollLoop() {
19210
19211
  await handleOnboardingCommand({
19211
19212
  chatId,
19212
19213
  messageId: String(msg.message_id),
19213
- mode: access.command === "onboard" ? "reset" : "resume"
19214
+ mode: access.command === "onboard" ? "reset" : "resume",
19215
+ // ENG-6578: the manager gate compares the SENDER's user-id (not the
19216
+ // chat id — they differ in groups) to the resolved manager principal.
19217
+ senderId: msg.from?.id != null ? String(msg.from.id) : void 0
19214
19218
  });
19215
19219
  }
19216
19220
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.81",
3
+ "version": "0.28.83",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {