@integrity-labs/agt-cli 0.28.133 → 0.28.135

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
@@ -37,7 +37,7 @@ import {
37
37
  success,
38
38
  table,
39
39
  warn
40
- } from "../chunk-L3WP7Y5L.js";
40
+ } from "../chunk-Z5ROLNAG.js";
41
41
  import {
42
42
  CHANNEL_REGISTRY,
43
43
  DEPLOYMENT_TEMPLATES,
@@ -4777,7 +4777,7 @@ import { execFileSync, execSync } from "child_process";
4777
4777
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4778
4778
  import chalk18 from "chalk";
4779
4779
  import ora16 from "ora";
4780
- var cliVersion = true ? "0.28.133" : "dev";
4780
+ var cliVersion = true ? "0.28.135" : "dev";
4781
4781
  async function fetchLatestVersion() {
4782
4782
  const host2 = getHost();
4783
4783
  if (!host2) return null;
@@ -5791,7 +5791,7 @@ function handleError(err) {
5791
5791
  }
5792
5792
 
5793
5793
  // src/bin/agt.ts
5794
- var cliVersion2 = true ? "0.28.133" : "dev";
5794
+ var cliVersion2 = true ? "0.28.135" : "dev";
5795
5795
  var program = new Command();
5796
5796
  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");
5797
5797
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -7746,7 +7746,7 @@ function requireHost() {
7746
7746
  }
7747
7747
 
7748
7748
  // src/lib/api-client.ts
7749
- var agtCliVersion = true ? "0.28.133" : "dev";
7749
+ var agtCliVersion = true ? "0.28.135" : "dev";
7750
7750
  var lastConfigHash = null;
7751
7751
  function setConfigHash(hash) {
7752
7752
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -9043,4 +9043,4 @@ export {
9043
9043
  managerInstallSystemUnitCommand,
9044
9044
  managerUninstallSystemUnitCommand
9045
9045
  };
9046
- //# sourceMappingURL=chunk-L3WP7Y5L.js.map
9046
+ //# sourceMappingURL=chunk-Z5ROLNAG.js.map
@@ -28,7 +28,7 @@ import {
28
28
  requireHost,
29
29
  safeWriteJsonAtomic,
30
30
  setConfigHash
31
- } from "../chunk-L3WP7Y5L.js";
31
+ } from "../chunk-Z5ROLNAG.js";
32
32
  import {
33
33
  getProjectDir as getProjectDir2,
34
34
  getReadyTasks,
@@ -7067,7 +7067,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
7067
7067
  var lastVersionCheckAt = 0;
7068
7068
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
7069
7069
  var lastResponsivenessProbeAt = 0;
7070
- var agtCliVersion = true ? "0.28.133" : "dev";
7070
+ var agtCliVersion = true ? "0.28.135" : "dev";
7071
7071
  function resolveBrewPath(execFileSync4) {
7072
7072
  try {
7073
7073
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
package/dist/mcp/index.js CHANGED
@@ -21078,6 +21078,95 @@ function writeAgentRestartFlag(codeName, reason, nowMs) {
21078
21078
  return path;
21079
21079
  }
21080
21080
 
21081
+ // src/self-restart-confirm.ts
21082
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2 } from "fs";
21083
+ import { homedir as homedir2 } from "os";
21084
+ import { join as join2 } from "path";
21085
+
21086
+ // src/restart-confirm.ts
21087
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
21088
+ import { dirname } from "path";
21089
+ import { randomUUID as randomUUID2 } from "crypto";
21090
+ var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
21091
+ function writeRestartConfirmMarker(filePath, marker) {
21092
+ const dir = dirname(filePath);
21093
+ if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true, mode: 448 });
21094
+ const tmpPath = `${filePath}.${process.pid}.${randomUUID2()}.tmp`;
21095
+ writeFileSync2(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
21096
+ renameSync2(tmpPath, filePath);
21097
+ }
21098
+
21099
+ // src/self-restart-confirm.ts
21100
+ var SELF_RESTART_PENDING_FRESHNESS_MS = 5 * 60 * 1e3;
21101
+ function selfRestartAgentDir(codeName) {
21102
+ return join2(homedir2(), ".augmented", codeName);
21103
+ }
21104
+ function selectFreshestPending(candidates, nowMs, maxAgeMs) {
21105
+ let best = null;
21106
+ for (const c of candidates) {
21107
+ if (!Number.isFinite(c.receivedAtMs)) continue;
21108
+ if (c.receivedAtMs > nowMs) continue;
21109
+ if (nowMs - c.receivedAtMs > maxAgeMs) continue;
21110
+ if (!best || c.receivedAtMs > best.receivedAtMs) best = c;
21111
+ }
21112
+ return best;
21113
+ }
21114
+ function readMarkerDir(dir, toCandidate) {
21115
+ if (!existsSync3(dir)) return [];
21116
+ const out = [];
21117
+ let entries;
21118
+ try {
21119
+ entries = readdirSync(dir);
21120
+ } catch {
21121
+ return [];
21122
+ }
21123
+ for (const entry of entries) {
21124
+ if (!entry.endsWith(".json") || entry.endsWith(".tmp")) continue;
21125
+ try {
21126
+ const parsed = JSON.parse(readFileSync2(join2(dir, entry), "utf8"));
21127
+ if (!parsed || typeof parsed !== "object") continue;
21128
+ const candidate = toCandidate(parsed);
21129
+ if (candidate) out.push(candidate);
21130
+ } catch {
21131
+ }
21132
+ }
21133
+ return out;
21134
+ }
21135
+ function readPendingCandidates(agentDir) {
21136
+ const slack = readMarkerDir(join2(agentDir, "slack-pending-inbound"), (p) => {
21137
+ const channel = p["channel"];
21138
+ if (typeof channel !== "string" || channel.length === 0) return null;
21139
+ const threadTs = p["thread_ts"];
21140
+ const reply = { channel };
21141
+ if (typeof threadTs === "string" && threadTs.length > 0) reply["thread_ts"] = threadTs;
21142
+ return { source: "slack", receivedAtMs: Date.parse(String(p["received_at"])), reply };
21143
+ });
21144
+ const telegram = readMarkerDir(join2(agentDir, "telegram-pending-inbound"), (p) => {
21145
+ const chatId = p["chat_id"];
21146
+ if (chatId == null || typeof chatId !== "string" && typeof chatId !== "number") return null;
21147
+ const reply = { chat_id: chatId };
21148
+ const messageId = p["message_id"];
21149
+ if (typeof messageId === "string" || typeof messageId === "number") reply["message_id"] = messageId;
21150
+ return { source: "telegram", receivedAtMs: Date.parse(String(p["received_at"])), reply };
21151
+ });
21152
+ return [...slack, ...telegram];
21153
+ }
21154
+ function captureSelfRestartConfirm(opts) {
21155
+ const maxAgeMs = opts.maxAgeMs ?? SELF_RESTART_PENDING_FRESHNESS_MS;
21156
+ const best = selectFreshestPending(readPendingCandidates(opts.agentDir), opts.nowMs, maxAgeMs);
21157
+ if (!best) return null;
21158
+ const marker = {
21159
+ source: best.source,
21160
+ requested_at: opts.nowMs,
21161
+ // No requester_name: a self-restart is agent-initiated, not asked by a named
21162
+ // human, so buildBackOnlineText degrades to the generic copy.
21163
+ reply: best.reply
21164
+ };
21165
+ const file = best.source === "slack" ? join2(opts.agentDir, "slack-restart-confirm.json") : join2(opts.agentDir, "telegram-restart-confirm.json");
21166
+ writeRestartConfirmMarker(file, marker);
21167
+ return best.source;
21168
+ }
21169
+
21081
21170
  // src/feature-request.ts
21082
21171
  var FEATURE_REQUEST_TYPES = [
21083
21172
  "integration",
@@ -23174,6 +23263,10 @@ if (isSelfRestartEnabled(process.env) && AGT_AGENT_CODE_NAME) {
23174
23263
  };
23175
23264
  }
23176
23265
  if (resp.mode === "local") {
23266
+ try {
23267
+ captureSelfRestartConfirm({ agentDir: selfRestartAgentDir(codeName), nowMs: Date.now() });
23268
+ } catch {
23269
+ }
23177
23270
  try {
23178
23271
  writeAgentRestartFlag(codeName, params.reason, Date.now());
23179
23272
  } catch (err) {
@@ -23197,6 +23290,10 @@ if (isSelfRestartEnabled(process.env) && AGT_AGENT_CODE_NAME) {
23197
23290
  };
23198
23291
  }
23199
23292
  if (resp.status === "auto_approved") {
23293
+ try {
23294
+ captureSelfRestartConfirm({ agentDir: selfRestartAgentDir(codeName), nowMs: Date.now() });
23295
+ } catch {
23296
+ }
23200
23297
  return {
23201
23298
  content: [
23202
23299
  {
@@ -19329,7 +19329,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
19329
19329
  }
19330
19330
  if (name === "slack.react") {
19331
19331
  const { channel, timestamp, emoji: emoji2 } = args;
19332
- noteThreadActivityByMessageTs(channel, timestamp);
19333
19332
  try {
19334
19333
  const res = await fetch("https://slack.com/api/reactions.add", {
19335
19334
  method: "POST",
@@ -19346,6 +19345,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
19346
19345
  isError: true
19347
19346
  };
19348
19347
  }
19348
+ noteThreadActivityByMessageTs(channel, timestamp);
19349
19349
  if (skipReactionShouldRetractAck(emoji2, SLACK_SKIP_REACTION, SLACK_ACK_REACTION)) {
19350
19350
  fetch("https://slack.com/api/reactions.remove", {
19351
19351
  method: "POST",
@@ -19368,7 +19368,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
19368
19368
  if (name === "slack.read_thread") {
19369
19369
  const { channel, thread_ts, limit: rawLimit } = args;
19370
19370
  const limit = Math.min(Math.max(rawLimit ?? 50, 1), 200);
19371
- noteThreadActivity(channel, thread_ts);
19372
19371
  try {
19373
19372
  const result = await fetchThreadTranscript(channel, thread_ts, limit, {
19374
19373
  botToken: BOT_TOKEN,
@@ -19380,6 +19379,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
19380
19379
  isError: true
19381
19380
  };
19382
19381
  }
19382
+ noteThreadActivity(channel, thread_ts);
19383
19383
  return {
19384
19384
  content: [{
19385
19385
  type: "text",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.133",
3
+ "version": "0.28.135",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {