@integrity-labs/agt-cli 0.19.4 → 0.19.5

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
@@ -50,7 +50,7 @@ import {
50
50
  success,
51
51
  table,
52
52
  warn
53
- } from "../chunk-MC3SMG4A.js";
53
+ } from "../chunk-IOTGOCC4.js";
54
54
 
55
55
  // src/bin/agt.ts
56
56
  import { join as join10 } from "path";
@@ -3734,7 +3734,7 @@ import { execFileSync, execSync } from "child_process";
3734
3734
  import { existsSync as existsSync5, realpathSync } from "fs";
3735
3735
  import chalk17 from "chalk";
3736
3736
  import ora15 from "ora";
3737
- var cliVersion = true ? "0.19.4" : "dev";
3737
+ var cliVersion = true ? "0.19.5" : "dev";
3738
3738
  async function fetchLatestVersion() {
3739
3739
  const host2 = getHost();
3740
3740
  if (!host2) return null;
@@ -4192,7 +4192,7 @@ function handleError(err) {
4192
4192
  }
4193
4193
 
4194
4194
  // src/bin/agt.ts
4195
- var cliVersion2 = true ? "0.19.4" : "dev";
4195
+ var cliVersion2 = true ? "0.19.5" : "dev";
4196
4196
  var program = new Command();
4197
4197
  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");
4198
4198
  program.hook("preAction", (thisCommand) => {
@@ -8181,4 +8181,4 @@ export {
8181
8181
  managerInstallSystemUnitCommand,
8182
8182
  managerUninstallSystemUnitCommand
8183
8183
  };
8184
- //# sourceMappingURL=chunk-MC3SMG4A.js.map
8184
+ //# sourceMappingURL=chunk-IOTGOCC4.js.map
@@ -22,7 +22,7 @@ import {
22
22
  resolveChannels,
23
23
  resolveDmTarget,
24
24
  wrapScheduledTaskPrompt
25
- } from "../chunk-MC3SMG4A.js";
25
+ } from "../chunk-IOTGOCC4.js";
26
26
  import {
27
27
  findTaskByTemplate,
28
28
  getProjectDir,
@@ -1459,6 +1459,14 @@ function startRealtimeIntegrationContext(config2) {
1459
1459
  });
1460
1460
  log2(`[realtime] Subscribing to plugin_context for ${agentIds.length} agent(s)`);
1461
1461
  }
1462
+ function stopRealtimeIntegrationContext() {
1463
+ if (!integrationContextChannel) return;
1464
+ try {
1465
+ integrationContextChannel.unsubscribe();
1466
+ } catch {
1467
+ }
1468
+ integrationContextChannel = null;
1469
+ }
1462
1470
  function isRealtimeConnected() {
1463
1471
  return connected;
1464
1472
  }
@@ -1622,7 +1630,7 @@ function clearAgentCaches(agentId, codeName) {
1622
1630
  var cachedFrameworkVersion = null;
1623
1631
  var lastVersionCheckAt = 0;
1624
1632
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
1625
- var agtCliVersion = true ? "0.19.4" : "dev";
1633
+ var agtCliVersion = true ? "0.19.5" : "dev";
1626
1634
  function resolveBrewPath(execFileSync2) {
1627
1635
  try {
1628
1636
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -4484,7 +4492,7 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash("sha256").u
4484
4492
  var realtimeStarted = false;
4485
4493
  var realtimeDriftStarted = false;
4486
4494
  var realtimeKanbanStarted = false;
4487
- var realtimeIntegrationContextStarted = false;
4495
+ var subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4488
4496
  var realtimeAssignStarted = false;
4489
4497
  var realtimeConfigStarted = false;
4490
4498
  var realtimeSubscribedAgentIds = /* @__PURE__ */ new Set();
@@ -4503,7 +4511,7 @@ function ensureRealtimeStarted(agentStates) {
4503
4511
  realtimeAssignStarted = false;
4504
4512
  realtimeConfigStarted = false;
4505
4513
  realtimeKanbanStarted = false;
4506
- realtimeIntegrationContextStarted = false;
4514
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4507
4515
  }
4508
4516
  const activeAgentIds = agentStates.filter((a) => a.status === "active").map((a) => a.agentId);
4509
4517
  if (activeAgentIds.length === 0) return;
@@ -4543,7 +4551,7 @@ function ensureRealtimeStarted(agentStates) {
4543
4551
  realtimeAssignStarted = false;
4544
4552
  realtimeConfigStarted = false;
4545
4553
  realtimeKanbanStarted = false;
4546
- realtimeIntegrationContextStarted = false;
4554
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4547
4555
  }
4548
4556
  },
4549
4557
  log
@@ -4684,19 +4692,41 @@ function ensureRealtimeKanbanStarted(agentStates) {
4684
4692
  log(`[realtime] Kanban subscription failed: ${err.message}`);
4685
4693
  });
4686
4694
  }
4695
+ function activeAgentIdSetsEqual(current, previous) {
4696
+ if (current.length !== previous.size) return false;
4697
+ for (const id of current) if (!previous.has(id)) return false;
4698
+ return true;
4699
+ }
4687
4700
  function ensureRealtimeIntegrationContextStarted(agentStates) {
4688
- if (realtimeIntegrationContextStarted) return;
4689
4701
  const activeAgentIds = agentStates.filter((a) => a.status === "active").map((a) => a.agentId);
4690
- if (activeAgentIds.length === 0) return;
4702
+ if (activeAgentIds.length === 0) {
4703
+ if (subscribedIntegrationContextAgentIds.size > 0) {
4704
+ stopRealtimeIntegrationContext();
4705
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4706
+ log("[realtime] Integration context subscription torn down (no active agents)");
4707
+ }
4708
+ return;
4709
+ }
4710
+ if (activeAgentIdSetsEqual(activeAgentIds, subscribedIntegrationContextAgentIds)) return;
4691
4711
  const apiKey = process.env["AGT_API_KEY"];
4692
4712
  if (!apiKey) return;
4713
+ const isResubscribe = subscribedIntegrationContextAgentIds.size > 0;
4714
+ if (isResubscribe) {
4715
+ stopRealtimeIntegrationContext();
4716
+ }
4717
+ const targetSet = new Set(activeAgentIds);
4718
+ subscribedIntegrationContextAgentIds = targetSet;
4693
4719
  void exchangeApiKey(apiKey).then((exchange) => {
4694
- if (!exchange.supabaseUrl || !exchange.supabaseAnonKey) return;
4720
+ if (subscribedIntegrationContextAgentIds !== targetSet) return;
4721
+ if (!exchange.supabaseUrl || !exchange.supabaseAnonKey) {
4722
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4723
+ return;
4724
+ }
4695
4725
  startRealtimeIntegrationContext({
4696
4726
  supabaseUrl: exchange.supabaseUrl,
4697
4727
  supabaseAnonKey: exchange.supabaseAnonKey,
4698
4728
  token: exchange.token,
4699
- agentIds: activeAgentIds,
4729
+ agentIds: [...targetSet],
4700
4730
  onContextChange: (payload) => {
4701
4731
  const agent = agentStates.find((a) => a.agentId === payload.agent_id);
4702
4732
  if (agent) {
@@ -4710,9 +4740,13 @@ function ensureRealtimeIntegrationContextStarted(agentStates) {
4710
4740
  },
4711
4741
  log
4712
4742
  });
4713
- realtimeIntegrationContextStarted = true;
4714
- log(`[realtime] Integration context subscription started for ${activeAgentIds.length} agent(s)`);
4743
+ log(
4744
+ `[realtime] Integration context subscription ${isResubscribe ? "re-bound" : "started"} for ${targetSet.size} agent(s)`
4745
+ );
4715
4746
  }).catch((err) => {
4747
+ if (subscribedIntegrationContextAgentIds === targetSet) {
4748
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
4749
+ }
4716
4750
  log(`[realtime] Integration context subscription failed: ${err.message}`);
4717
4751
  });
4718
4752
  }