@integrity-labs/agt-cli 0.28.596 → 0.28.597

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
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-EAZQXZ4Q.js";
43
+ } from "../chunk-WAQM45OE.js";
44
44
  import {
45
45
  readDirectChatSessionState
46
46
  } from "../chunk-6NVRWZ5W.js";
@@ -4910,7 +4910,7 @@ import { execFileSync, execSync } from "child_process";
4910
4910
  import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
4911
4911
  import chalk18 from "chalk";
4912
4912
  import ora16 from "ora";
4913
- var cliVersion = true ? "0.28.596" : "dev";
4913
+ var cliVersion = true ? "0.28.597" : "dev";
4914
4914
  async function fetchLatestVersion() {
4915
4915
  const host2 = getHost();
4916
4916
  if (!host2) return null;
@@ -6090,7 +6090,7 @@ function handleError(err) {
6090
6090
  }
6091
6091
 
6092
6092
  // src/bin/agt.ts
6093
- var cliVersion2 = true ? "0.28.596" : "dev";
6093
+ var cliVersion2 = true ? "0.28.597" : "dev";
6094
6094
  var program = new Command();
6095
6095
  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");
6096
6096
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -5987,7 +5987,7 @@ function exchangeFailureKind(err) {
5987
5987
  }
5988
5988
 
5989
5989
  // src/lib/api-client.ts
5990
- var agtCliVersion = true ? "0.28.596" : "dev";
5990
+ var agtCliVersion = true ? "0.28.597" : "dev";
5991
5991
  var lastConfigHash = null;
5992
5992
  function setConfigHash(hash) {
5993
5993
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -9442,4 +9442,4 @@ export {
9442
9442
  managerInstallSystemUnitCommand,
9443
9443
  managerUninstallSystemUnitCommand
9444
9444
  };
9445
- //# sourceMappingURL=chunk-EAZQXZ4Q.js.map
9445
+ //# sourceMappingURL=chunk-WAQM45OE.js.map
@@ -53,7 +53,7 @@ import {
53
53
  safeWriteJsonAtomic,
54
54
  setConfigHash,
55
55
  tripClass
56
- } from "../chunk-EAZQXZ4Q.js";
56
+ } from "../chunk-WAQM45OE.js";
57
57
  import {
58
58
  getProjectDir as getProjectDir2,
59
59
  getReadyTasks,
@@ -10041,6 +10041,8 @@ var assignChannel = null;
10041
10041
  var configChannel = null;
10042
10042
  var kanbanChannel = null;
10043
10043
  var integrationContextChannel = null;
10044
+ var tokenRotationChannels = [];
10045
+ var tokenRotationEpoch = 0;
10044
10046
  var connected = false;
10045
10047
  var tearingDown = false;
10046
10048
  function ensureClient(config2) {
@@ -10086,6 +10088,7 @@ function startRealtimeChat(config2) {
10086
10088
  configChannel = null;
10087
10089
  kanbanChannel = null;
10088
10090
  integrationContextChannel = null;
10091
+ tokenRotationChannels = [];
10089
10092
  if (client) {
10090
10093
  try {
10091
10094
  client.removeAllChannels();
@@ -10334,6 +10337,49 @@ function stopRealtimeIntegrationContext() {
10334
10337
  }
10335
10338
  integrationContextChannel = null;
10336
10339
  }
10340
+ function startRealtimeTokenRotation(config2) {
10341
+ const { agentIds, onTokenRotated, onSubscriptionLost, log: log2 } = config2;
10342
+ if (agentIds.length === 0) return;
10343
+ stopRealtimeTokenRotation();
10344
+ const epoch = ++tokenRotationEpoch;
10345
+ const sb = ensureClient(config2);
10346
+ for (const agentId of agentIds) {
10347
+ const topic = `token-rotated-agent:${agentId}`;
10348
+ const channel = sb.channel(topic, { config: { private: true } }).on("broadcast", { event: "token.rotated" }, (message) => {
10349
+ const payload = message.payload;
10350
+ if (!payload || typeof payload.integration_id !== "string" || payload.integration_id.length === 0) {
10351
+ log2(`[realtime] token.rotated for agent ${agentId} ignored \u2014 no integration_id in payload`);
10352
+ return;
10353
+ }
10354
+ log2(
10355
+ `[realtime] token.rotated for agent ${agentId} (integration ${payload.integration_id}, ${payload.definition_id ?? "unknown provider"})`
10356
+ );
10357
+ onTokenRotated(agentId, {
10358
+ integration_id: payload.integration_id,
10359
+ definition_id: typeof payload.definition_id === "string" ? payload.definition_id : "unknown",
10360
+ rotated_at: typeof payload.rotated_at === "string" ? payload.rotated_at : (/* @__PURE__ */ new Date()).toISOString()
10361
+ });
10362
+ }).subscribe((status) => {
10363
+ if (epoch !== tokenRotationEpoch) return;
10364
+ if (status === "CLOSED" || status === "CHANNEL_ERROR" || status === "TIMED_OUT") {
10365
+ log2(`[realtime] Token rotation channel for agent ${agentId}: ${status}`);
10366
+ onSubscriptionLost?.(agentId, status);
10367
+ }
10368
+ });
10369
+ tokenRotationChannels.push(channel);
10370
+ }
10371
+ log2(`[realtime] Subscribing to token.rotated for ${agentIds.length} agent(s)`);
10372
+ }
10373
+ function stopRealtimeTokenRotation() {
10374
+ tokenRotationEpoch += 1;
10375
+ for (const channel of tokenRotationChannels) {
10376
+ try {
10377
+ channel.unsubscribe();
10378
+ } catch {
10379
+ }
10380
+ }
10381
+ tokenRotationChannels = [];
10382
+ }
10337
10383
  function isRealtimeConnected() {
10338
10384
  return connected;
10339
10385
  }
@@ -10393,6 +10439,13 @@ function stopRealtimeChat() {
10393
10439
  }
10394
10440
  integrationContextChannel = null;
10395
10441
  }
10442
+ for (const ch of tokenRotationChannels) {
10443
+ try {
10444
+ ch.unsubscribe();
10445
+ } catch {
10446
+ }
10447
+ }
10448
+ tokenRotationChannels = [];
10396
10449
  if (client) {
10397
10450
  try {
10398
10451
  client.removeAllChannels();
@@ -11827,7 +11880,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
11827
11880
  var lastVersionCheckAt = 0;
11828
11881
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
11829
11882
  var lastResponsivenessProbeAt = 0;
11830
- var agtCliVersion = true ? "0.28.596" : "dev";
11883
+ var agtCliVersion = true ? "0.28.597" : "dev";
11831
11884
  function resolveBrewPath(execFileSync3) {
11832
11885
  try {
11833
11886
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -17239,8 +17292,9 @@ function ensureRealtimeIntegrationContextStarted(agentStates) {
17239
17292
  if (activeAgentIds.length === 0) {
17240
17293
  if (subscribedIntegrationContextAgentIds.size > 0) {
17241
17294
  stopRealtimeIntegrationContext();
17295
+ stopRealtimeTokenRotation();
17242
17296
  subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
17243
- log("[realtime] Integration context subscription torn down (no active agents)");
17297
+ log("[realtime] Integration context + token rotation subscriptions torn down (no active agents)");
17244
17298
  }
17245
17299
  return;
17246
17300
  }
@@ -17250,6 +17304,7 @@ function ensureRealtimeIntegrationContextStarted(agentStates) {
17250
17304
  const isResubscribe = subscribedIntegrationContextAgentIds.size > 0;
17251
17305
  if (isResubscribe) {
17252
17306
  stopRealtimeIntegrationContext();
17307
+ stopRealtimeTokenRotation();
17253
17308
  }
17254
17309
  const targetSet = new Set(activeAgentIds);
17255
17310
  subscribedIntegrationContextAgentIds = targetSet;
@@ -17277,8 +17332,24 @@ function ensureRealtimeIntegrationContextStarted(agentStates) {
17277
17332
  },
17278
17333
  log
17279
17334
  });
17335
+ startRealtimeTokenRotation({
17336
+ supabaseUrl: exchange.supabaseUrl,
17337
+ supabaseAnonKey: exchange.supabaseAnonKey,
17338
+ token: exchange.token,
17339
+ agentIds: [...targetSet],
17340
+ onTokenRotated: (agentId, event) => {
17341
+ triggerEarlyPoll(
17342
+ `integration token rotated for agent ${agentId} (integration ${event.integration_id}, ${event.definition_id})`
17343
+ );
17344
+ },
17345
+ onSubscriptionLost: (agentId, status) => {
17346
+ log(`[realtime] Token rotation subscription lost for agent ${agentId} (${status}) \u2014 will rebind next tick`);
17347
+ subscribedIntegrationContextAgentIds = /* @__PURE__ */ new Set();
17348
+ },
17349
+ log
17350
+ });
17280
17351
  log(
17281
- `[realtime] Integration context subscription ${isResubscribe ? "re-bound" : "started"} for ${targetSet.size} agent(s)`
17352
+ `[realtime] Integration context + token rotation subscriptions ${isResubscribe ? "re-bound" : "started"} for ${targetSet.size} agent(s)`
17282
17353
  );
17283
17354
  }).catch((err) => {
17284
17355
  if (subscribedIntegrationContextAgentIds === targetSet) {