@integrity-labs/agt-cli 0.28.1250 → 0.28.1251

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.
Files changed (36) hide show
  1. package/dist/api-client-ECOBF6BM.js +39 -0
  2. package/dist/bin/agt.js +17 -15
  3. package/dist/bin/agt.js.map +1 -1
  4. package/dist/chunk-2VGFSHFP.js +471 -0
  5. package/dist/chunk-2VGFSHFP.js.map +1 -0
  6. package/dist/{chunk-5ALBA7KT.js → chunk-4AUE34MF.js} +94 -552
  7. package/dist/chunk-4AUE34MF.js.map +1 -0
  8. package/dist/{chunk-DFJ5E5EW.js → chunk-6KY5FKXC.js} +192 -1
  9. package/dist/chunk-6KY5FKXC.js.map +1 -0
  10. package/dist/{chunk-IUMFAYZO.js → chunk-O6WRX5FE.js} +3 -3
  11. package/dist/{chunk-JOBL3ZF4.js → chunk-OAAKFU3J.js} +2 -2
  12. package/dist/{chunk-SMD577FW.js → chunk-VOMOPWFI.js} +2 -2
  13. package/dist/{claude-code-updater-5MPOBIWN.js → claude-code-updater-2TZ4TSOB.js} +3 -3
  14. package/dist/{claude-pair-runtime-SNU3CU3K.js → claude-pair-runtime-CTJCJNK4.js} +3 -3
  15. package/dist/lib/manager-worker.js +172 -61
  16. package/dist/lib/manager-worker.js.map +1 -1
  17. package/dist/mcp/direct-chat-channel.js +5 -0
  18. package/dist/mcp/index.js +5 -0
  19. package/dist/mcp/origami.js +5 -0
  20. package/dist/mcp/slack-channel.js +5 -0
  21. package/dist/mcp/telegram-channel.js +367 -186
  22. package/dist/{persistent-session-SYCA6MW2.js → persistent-session-TBE4KP4K.js} +4 -4
  23. package/dist/persistent-session-TBE4KP4K.js.map +1 -0
  24. package/dist/{responsiveness-probe-BUXWVOSA.js → responsiveness-probe-J7DA3AB4.js} +4 -4
  25. package/dist/{session-auth-dead-G5NHWSRP.js → session-auth-dead-OL5ODQRN.js} +3 -3
  26. package/package.json +1 -1
  27. package/dist/chunk-5ALBA7KT.js.map +0 -1
  28. package/dist/chunk-DFJ5E5EW.js.map +0 -1
  29. /package/dist/{claude-code-updater-5MPOBIWN.js.map → api-client-ECOBF6BM.js.map} +0 -0
  30. /package/dist/{chunk-IUMFAYZO.js.map → chunk-O6WRX5FE.js.map} +0 -0
  31. /package/dist/{chunk-JOBL3ZF4.js.map → chunk-OAAKFU3J.js.map} +0 -0
  32. /package/dist/{chunk-SMD577FW.js.map → chunk-VOMOPWFI.js.map} +0 -0
  33. /package/dist/{persistent-session-SYCA6MW2.js.map → claude-code-updater-2TZ4TSOB.js.map} +0 -0
  34. /package/dist/{claude-pair-runtime-SNU3CU3K.js.map → claude-pair-runtime-CTJCJNK4.js.map} +0 -0
  35. /package/dist/{responsiveness-probe-BUXWVOSA.js.map → responsiveness-probe-J7DA3AB4.js.map} +0 -0
  36. /package/dist/{session-auth-dead-G5NHWSRP.js.map → session-auth-dead-OL5ODQRN.js.map} +0 -0
@@ -5167,6 +5167,191 @@ function decideInboundAccess(input) {
5167
5167
  return { kind: "admit" };
5168
5168
  }
5169
5169
 
5170
+ // ../../packages/core/dist/channels/telegram-group-link.js
5171
+ var GROUP_START_WITH_CODE_RE = /^\/start(?:@[A-Za-z0-9_]{1,64})?\s+(gk_[A-Za-z0-9_-]{22})$/;
5172
+ function isTelegramGroupChatType(chatType) {
5173
+ return chatType === "group" || chatType === "supergroup";
5174
+ }
5175
+ function parseTelegramGroupLinkStart(input) {
5176
+ if (!isTelegramGroupChatType(input.chatType))
5177
+ return null;
5178
+ if (input.isBot === true)
5179
+ return null;
5180
+ if (typeof input.text !== "string")
5181
+ return null;
5182
+ const match = GROUP_START_WITH_CODE_RE.exec(input.text.trim());
5183
+ return match ? match[1] : null;
5184
+ }
5185
+ function isTelegramGroupChatId(id) {
5186
+ return typeof id === "string" && /^-[1-9][0-9]{0,19}$/.test(id);
5187
+ }
5188
+
5189
+ // ../../packages/core/dist/channels/telegram-group-link-host.js
5190
+ var GROUP_LINK_TIMEOUT_MS = 5e3;
5191
+ async function postWithTimeout(post, path, body, timeoutMs) {
5192
+ let timer;
5193
+ const timeout = new Promise((resolve) => {
5194
+ timer = setTimeout(() => resolve(null), timeoutMs);
5195
+ });
5196
+ try {
5197
+ return await Promise.race([post(path, body), timeout]);
5198
+ } catch {
5199
+ return null;
5200
+ } finally {
5201
+ if (timer)
5202
+ clearTimeout(timer);
5203
+ }
5204
+ }
5205
+ async function claimTelegramGroupLinkCode(post, input, timeoutMs = GROUP_LINK_TIMEOUT_MS) {
5206
+ const res = await postWithTimeout(post, "/host/telegram-link/group-claim", {
5207
+ agent_id: input.agentId,
5208
+ code: input.code,
5209
+ chat_id: input.chatId,
5210
+ chat_type: input.chatType,
5211
+ ...input.chatTitle ? { chat_title: input.chatTitle } : {},
5212
+ ...input.fromId ? { from_id: input.fromId } : {},
5213
+ ...input.firstName ? { first_name: input.firstName } : {},
5214
+ ...input.lastName ? { last_name: input.lastName } : {}
5215
+ }, timeoutMs);
5216
+ if (!res || res.status < 200 || res.status >= 300)
5217
+ return false;
5218
+ return res.json?.ok === true;
5219
+ }
5220
+ async function reportTelegramGroupMigrationOutcome(post, input, timeoutMs = GROUP_LINK_TIMEOUT_MS) {
5221
+ const res = await postWithTimeout(post, "/host/telegram-link/group-migrate", { agent_id: input.agentId, from_chat_id: input.fromChatId, to_chat_id: input.toChatId }, timeoutMs);
5222
+ if (!res)
5223
+ return "retry";
5224
+ if (res.status === 400)
5225
+ return "drop";
5226
+ if (res.status < 200 || res.status >= 300)
5227
+ return "retry";
5228
+ return res.json?.ok === true ? "done" : "retry";
5229
+ }
5230
+ var GROUP_CLAIMED_REPLY = "Thanks for adding me. Go back to the setup screen to finish: I will answer here once it is confirmed.";
5231
+ function applyMigrationToAllowlist(allowed, fromChatId, toChatId) {
5232
+ if (!allowed.has(fromChatId) || allowed.has(toChatId))
5233
+ return false;
5234
+ allowed.add(toChatId);
5235
+ return true;
5236
+ }
5237
+ var MIGRATION_REPORT_BASE_DELAY_MS = 3e4;
5238
+ var MIGRATION_REPORT_MAX_DELAY_MS = 60 * 6e4;
5239
+ var MIGRATION_REPORT_MAX_AGE_MS = 7 * 24 * 60 * 6e4;
5240
+ var MIGRATION_REPORT_MAX_PENDING = 32;
5241
+ var MIGRATION_REPORT_MAX_PER_FLUSH = 4;
5242
+ function migrationReportRetryDelayMs(attempts) {
5243
+ const exp = Math.max(0, attempts - 1);
5244
+ return Math.min(MIGRATION_REPORT_MAX_DELAY_MS, MIGRATION_REPORT_BASE_DELAY_MS * 2 ** Math.min(exp, 20));
5245
+ }
5246
+ var MIGRATION_REPORT_CLOCK_SKEW_MS = 5 * 6e4;
5247
+ function isPendingMigrationReport(v) {
5248
+ if (typeof v !== "object" || v === null)
5249
+ return false;
5250
+ const r = v;
5251
+ return isTelegramGroupChatId(r["from_chat_id"]) && isTelegramGroupChatId(r["to_chat_id"]) && r["from_chat_id"] !== r["to_chat_id"] && typeof r["first_seen_at"] === "number" && Number.isFinite(r["first_seen_at"]) && typeof r["attempts"] === "number" && Number.isInteger(r["attempts"]) && r["attempts"] >= 0 && typeof r["next_attempt_at"] === "number" && Number.isFinite(r["next_attempt_at"]);
5252
+ }
5253
+ function parsePendingMigrationReports(raw, now = Date.now()) {
5254
+ if (!raw)
5255
+ return [];
5256
+ let parsed;
5257
+ try {
5258
+ parsed = JSON.parse(raw);
5259
+ } catch {
5260
+ return [];
5261
+ }
5262
+ const list = parsed?.pending;
5263
+ if (!Array.isArray(list))
5264
+ return [];
5265
+ return list.filter(isPendingMigrationReport).filter((r) => r.first_seen_at <= now + MIGRATION_REPORT_CLOCK_SKEW_MS && now - r.first_seen_at < MIGRATION_REPORT_MAX_AGE_MS).map((r) => r.next_attempt_at > now + MIGRATION_REPORT_MAX_DELAY_MS ? { ...r, next_attempt_at: now + MIGRATION_REPORT_MAX_DELAY_MS } : r).slice(-MIGRATION_REPORT_MAX_PENDING);
5266
+ }
5267
+ function serializePendingMigrationReports(list) {
5268
+ return JSON.stringify({ pending: list });
5269
+ }
5270
+ function enqueueMigrationReport(list, fromChatId, toChatId, now) {
5271
+ if (!isTelegramGroupChatId(fromChatId) || !isTelegramGroupChatId(toChatId) || fromChatId === toChatId) {
5272
+ return [...list];
5273
+ }
5274
+ if (list.some((r) => r.from_chat_id === fromChatId && r.to_chat_id === toChatId))
5275
+ return [...list];
5276
+ const next = [
5277
+ ...list,
5278
+ { from_chat_id: fromChatId, to_chat_id: toChatId, first_seen_at: now, attempts: 0, next_attempt_at: now }
5279
+ ];
5280
+ return next.slice(-MIGRATION_REPORT_MAX_PENDING);
5281
+ }
5282
+ function settleMigrationReport(list, entry, outcome, now) {
5283
+ const same = (r) => r.from_chat_id === entry.from_chat_id && r.to_chat_id === entry.to_chat_id;
5284
+ if (outcome !== "retry" || now - entry.first_seen_at >= MIGRATION_REPORT_MAX_AGE_MS) {
5285
+ return list.filter((r) => !same(r));
5286
+ }
5287
+ return list.map((r) => {
5288
+ if (!same(r))
5289
+ return r;
5290
+ const attempts = r.attempts + 1;
5291
+ return { ...r, attempts, next_attempt_at: now + migrationReportRetryDelayMs(attempts) };
5292
+ });
5293
+ }
5294
+ function createMigrationReportQueue(deps) {
5295
+ const now = deps.now ?? Date.now;
5296
+ let list = parsePendingMigrationReports(safeLoad(deps.io), now());
5297
+ let inFlight = null;
5298
+ const persist = () => {
5299
+ try {
5300
+ deps.io.save(serializePendingMigrationReports(list));
5301
+ } catch (err) {
5302
+ deps.log(`migration-report persist failed: ${err instanceof Error ? err.message : String(err)}`);
5303
+ }
5304
+ };
5305
+ const flush = async () => {
5306
+ const outcomes = /* @__PURE__ */ new Map();
5307
+ const t = now();
5308
+ const due = list.filter((r) => r.next_attempt_at <= t).sort((a, b) => a.attempts - b.attempts).slice(0, MIGRATION_REPORT_MAX_PER_FLUSH);
5309
+ for (const entry of due) {
5310
+ let outcome;
5311
+ try {
5312
+ outcome = await deps.report(entry.from_chat_id, entry.to_chat_id);
5313
+ } catch {
5314
+ outcome = "retry";
5315
+ }
5316
+ const before = list.length;
5317
+ list = settleMigrationReport(list, entry, outcome, now());
5318
+ outcomes.set(`${entry.from_chat_id}->${entry.to_chat_id}`, outcome);
5319
+ if (outcome === "retry" && list.length < before) {
5320
+ deps.log(`migration-report gave up after ${entry.attempts + 1} attempt(s) (aged out)`);
5321
+ }
5322
+ persist();
5323
+ }
5324
+ return outcomes;
5325
+ };
5326
+ return {
5327
+ pending: () => [...list],
5328
+ enqueue(fromChatId, toChatId) {
5329
+ const next = enqueueMigrationReport(list, fromChatId, toChatId, now());
5330
+ if (next.length === list.length && next.every((r, i) => r === list[i]))
5331
+ return;
5332
+ list = next;
5333
+ persist();
5334
+ },
5335
+ flushDue() {
5336
+ if (!list.some((r) => r.next_attempt_at <= now()))
5337
+ return Promise.resolve(/* @__PURE__ */ new Map());
5338
+ if (!inFlight) {
5339
+ inFlight = flush().finally(() => {
5340
+ inFlight = null;
5341
+ });
5342
+ }
5343
+ return inFlight;
5344
+ }
5345
+ };
5346
+ }
5347
+ function safeLoad(io) {
5348
+ try {
5349
+ return io.load();
5350
+ } catch {
5351
+ return null;
5352
+ }
5353
+ }
5354
+
5170
5355
  // ../../packages/core/dist/parser/frontmatter.js
5171
5356
  import { parse as parseYaml, parseDocument } from "yaml";
5172
5357
  function extractFrontmatter(content) {
@@ -18347,6 +18532,12 @@ export {
18347
18532
  classifySlackPolicyBlock,
18348
18533
  classifyTelegramPolicyBlock,
18349
18534
  decideInboundAccess,
18535
+ parseTelegramGroupLinkStart,
18536
+ claimTelegramGroupLinkCode,
18537
+ reportTelegramGroupMigrationOutcome,
18538
+ GROUP_CLAIMED_REPLY,
18539
+ applyMigrationToAllowlist,
18540
+ createMigrationReportQueue,
18350
18541
  extractFrontmatter,
18351
18542
  generateCharterMd,
18352
18543
  generateToolsMd,
@@ -18465,4 +18656,4 @@ export {
18465
18656
  HOST_ROTATE_KEY_CONFLICT,
18466
18657
  shouldMintReplacementKey
18467
18658
  };
18468
- //# sourceMappingURL=chunk-DFJ5E5EW.js.map
18659
+ //# sourceMappingURL=chunk-6KY5FKXC.js.map