@integrity-labs/agt-cli 0.28.595 → 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.
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
safeWriteJsonAtomic,
|
|
54
54
|
setConfigHash,
|
|
55
55
|
tripClass
|
|
56
|
-
} from "../chunk-
|
|
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.
|
|
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
|
|
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
|
|
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) {
|