@okrlinkhub/agent-factory 3.0.2 → 3.1.0

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 (55) hide show
  1. package/README.md +235 -31
  2. package/dist/client/bridge.d.ts +1 -0
  3. package/dist/client/bridge.d.ts.map +1 -1
  4. package/dist/client/bridge.js.map +1 -1
  5. package/dist/client/index.d.ts +29 -3
  6. package/dist/client/index.d.ts.map +1 -1
  7. package/dist/client/index.js +59 -3
  8. package/dist/client/index.js.map +1 -1
  9. package/dist/component/_generated/api.d.ts +2 -0
  10. package/dist/component/_generated/api.d.ts.map +1 -1
  11. package/dist/component/_generated/api.js.map +1 -1
  12. package/dist/component/_generated/component.d.ts +140 -2
  13. package/dist/component/_generated/component.d.ts.map +1 -1
  14. package/dist/component/flyCleanup.d.ts +32 -0
  15. package/dist/component/flyCleanup.d.ts.map +1 -0
  16. package/dist/component/flyCleanup.js +272 -0
  17. package/dist/component/flyCleanup.js.map +1 -0
  18. package/dist/component/identity.d.ts +60 -2
  19. package/dist/component/identity.d.ts.map +1 -1
  20. package/dist/component/identity.js +372 -32
  21. package/dist/component/identity.js.map +1 -1
  22. package/dist/component/lib.d.ts +2 -1
  23. package/dist/component/lib.d.ts.map +1 -1
  24. package/dist/component/lib.js +2 -1
  25. package/dist/component/lib.js.map +1 -1
  26. package/dist/component/providers/fly.d.ts +23 -2
  27. package/dist/component/providers/fly.d.ts.map +1 -1
  28. package/dist/component/providers/fly.js +15 -3
  29. package/dist/component/providers/fly.js.map +1 -1
  30. package/dist/component/pushing.d.ts +4 -4
  31. package/dist/component/queue.d.ts +12 -7
  32. package/dist/component/queue.d.ts.map +1 -1
  33. package/dist/component/queue.js +9 -0
  34. package/dist/component/queue.js.map +1 -1
  35. package/dist/component/scheduler.d.ts +8 -8
  36. package/dist/component/scheduler.d.ts.map +1 -1
  37. package/dist/component/scheduler.js +22 -2
  38. package/dist/component/scheduler.js.map +1 -1
  39. package/dist/component/schema.d.ts +16 -4
  40. package/dist/component/schema.d.ts.map +1 -1
  41. package/dist/component/schema.js +16 -0
  42. package/dist/component/schema.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/client/bridge.ts +1 -0
  45. package/src/client/index.ts +68 -3
  46. package/src/component/_generated/api.ts +2 -0
  47. package/src/component/_generated/component.ts +188 -8
  48. package/src/component/flyCleanup.ts +386 -0
  49. package/src/component/identity.ts +425 -31
  50. package/src/component/lib.test.ts +197 -3
  51. package/src/component/lib.ts +3 -0
  52. package/src/component/providers/fly.ts +39 -5
  53. package/src/component/queue.ts +11 -0
  54. package/src/component/scheduler.ts +23 -2
  55. package/src/component/schema.ts +16 -0
@@ -7,6 +7,7 @@ import {
7
7
  import type { Auth, HttpRouter } from "convex/server";
8
8
  import { v } from "convex/values";
9
9
  import type { ComponentApi } from "../component/_generated/component.js";
10
+ import { parseTelegramWebhookSecretToken } from "../component/identity.js";
10
11
  import {
11
12
  providerConfigValidator,
12
13
  scalingPolicyValidator,
@@ -488,6 +489,7 @@ export function exposeApi(
488
489
  agentKey: "default",
489
490
  version: "1.0.0",
490
491
  secretsRef: ["telegram.botToken"],
492
+ botIdentity: "telegram-bot-default",
491
493
  enabled: true,
492
494
  });
493
495
  },
@@ -555,6 +557,22 @@ export function exposeApi(
555
557
  return await ctx.runAction((component.lib as any).deleteFlyVolume, args);
556
558
  },
557
559
  }),
560
+ runFlyCleanup: actionGeneric({
561
+ args: {
562
+ flyApiToken: v.optional(v.string()),
563
+ machineConcurrency: v.optional(v.number()),
564
+ volumeConcurrency: v.optional(v.number()),
565
+ },
566
+ handler: async (ctx, args) => {
567
+ await options.auth(ctx, { type: "read" });
568
+ return await ctx.runAction((component.lib as any).runFlyCleanup, {
569
+ flyApiToken: args.flyApiToken,
570
+ machineConcurrency: args.machineConcurrency,
571
+ volumeConcurrency: args.volumeConcurrency,
572
+ providerConfig: options.providerConfig,
573
+ });
574
+ },
575
+ }),
558
576
  recoverQueue: actionGeneric({
559
577
  args: {
560
578
  nowMs: v.optional(v.number()),
@@ -583,6 +601,7 @@ export function exposeApi(
583
601
  args: {
584
602
  consumerUserId: v.string(),
585
603
  agentKey: v.string(),
604
+ botIdentity: v.optional(v.string()),
586
605
  source: v.optional(
587
606
  v.union(v.literal("manual"), v.literal("telegram_pairing"), v.literal("api")),
588
607
  ),
@@ -665,6 +684,7 @@ export function exposeApi(
665
684
  }),
666
685
  resolveAgentForTelegram: queryGeneric({
667
686
  args: {
687
+ botIdentity: v.optional(v.string()),
668
688
  telegramUserId: v.optional(v.string()),
669
689
  telegramChatId: v.optional(v.string()),
670
690
  },
@@ -698,6 +718,7 @@ export function exposeApi(
698
718
  consumePairingCode: mutationGeneric({
699
719
  args: {
700
720
  code: v.string(),
721
+ botIdentity: v.optional(v.string()),
701
722
  telegramUserId: v.string(),
702
723
  telegramChatId: v.string(),
703
724
  },
@@ -725,7 +746,7 @@ export function exposeApi(
725
746
  return await ctx.runQuery((component.lib as any).getUserAgentPairingStatus, args);
726
747
  },
727
748
  }),
728
- importTelegramTokenForAgent: mutationGeneric({
749
+ importTelegramTokenForAgent: actionGeneric({
729
750
  args: {
730
751
  consumerUserId: v.string(),
731
752
  agentKey: v.string(),
@@ -734,7 +755,17 @@ export function exposeApi(
734
755
  },
735
756
  handler: async (ctx, args) => {
736
757
  await options.auth(ctx, { type: "write", agentKey: args.agentKey });
737
- return await ctx.runMutation((component.lib as any).importTelegramTokenForAgent, args);
758
+ return await ctx.runAction((component.lib as any).importTelegramTokenForAgent, args);
759
+ },
760
+ }),
761
+ reconcileTelegramBotIdentityForAgent: actionGeneric({
762
+ args: {
763
+ agentKey: v.string(),
764
+ secretRef: v.optional(v.string()),
765
+ },
766
+ handler: async (ctx, args) => {
767
+ await options.auth(ctx, { type: "write", agentKey: args.agentKey });
768
+ return await ctx.runAction((component.lib as any).reconcileTelegramBotIdentityForAgent, args);
738
769
  },
739
770
  }),
740
771
  getUserAgentOnboardingState: queryGeneric({
@@ -787,12 +818,27 @@ export function exposeApi(
787
818
  args: {
788
819
  convexSiteUrl: v.string(),
789
820
  secretRef: v.optional(v.string()),
821
+ agentKey: v.optional(v.string()),
790
822
  },
791
823
  handler: async (ctx, args) => {
792
824
  await options.auth(ctx, { type: "read" });
793
825
  return await ctx.runAction(component.lib.configureTelegramWebhook, args);
794
826
  },
795
827
  }),
828
+ softResetTelegramBindingsMissingBotIdentity: mutationGeneric({
829
+ args: {
830
+ nowMs: v.optional(v.number()),
831
+ revokeActiveBindings: v.optional(v.boolean()),
832
+ expirePendingPairings: v.optional(v.boolean()),
833
+ },
834
+ handler: async (ctx, args) => {
835
+ await options.auth(ctx, { type: "write" });
836
+ return await ctx.runMutation(
837
+ (component.lib as any).softResetTelegramBindingsMissingBotIdentity,
838
+ args,
839
+ );
840
+ },
841
+ }),
796
842
  getWebhookReadiness: actionGeneric({
797
843
  args: {
798
844
  agentKey: v.string(),
@@ -1227,6 +1273,18 @@ export function registerRoutes(
1227
1273
  path: `${pathPrefix}/telegram/webhook`,
1228
1274
  method: "POST",
1229
1275
  handler: httpActionGeneric(async (ctx, request) => {
1276
+ const botIdentity = parseTelegramWebhookSecretToken(
1277
+ request.headers.get("X-Telegram-Bot-Api-Secret-Token"),
1278
+ );
1279
+ if (!botIdentity) {
1280
+ return new Response(
1281
+ JSON.stringify({ ok: false, error: "missing or invalid telegram webhook secret token" }),
1282
+ {
1283
+ status: 403,
1284
+ headers: { "Content-Type": "application/json" },
1285
+ },
1286
+ );
1287
+ }
1230
1288
  const update = (await request.json()) as {
1231
1289
  update_id?: number;
1232
1290
  message?: {
@@ -1280,6 +1338,7 @@ export function registerRoutes(
1280
1338
  try {
1281
1339
  const pairing = await ctx.runMutation(component.lib.consumePairingCode, {
1282
1340
  code: startCommandCode,
1341
+ botIdentity,
1283
1342
  telegramUserId,
1284
1343
  telegramChatId,
1285
1344
  });
@@ -1331,6 +1390,7 @@ export function registerRoutes(
1331
1390
 
1332
1391
  const mappedRaw = resolveAgentKeyFromBinding
1333
1392
  ? await ctx.runQuery(component.lib.resolveAgentForTelegram, {
1393
+ botIdentity,
1334
1394
  telegramUserId,
1335
1395
  telegramChatId,
1336
1396
  })
@@ -1360,6 +1420,7 @@ export function registerRoutes(
1360
1420
  });
1361
1421
  }
1362
1422
  const metadata: Record<string, string> = {
1423
+ telegramBotIdentity: botIdentity,
1363
1424
  telegramChatId,
1364
1425
  telegramUserId,
1365
1426
  };
@@ -1381,7 +1442,7 @@ export function registerRoutes(
1381
1442
  })
1382
1443
  : undefined;
1383
1444
  await ctx.runMutation(component.lib.enqueue, {
1384
- conversationId: mapped.conversationId ?? `telegram:${telegramChatId}`,
1445
+ conversationId: mapped.conversationId ?? buildTelegramIngressConversationId(botIdentity, telegramChatId),
1385
1446
  agentKey,
1386
1447
  payload: {
1387
1448
  provider: "telegram",
@@ -1407,6 +1468,10 @@ function parseStartCommandCode(messageText: string): string | null {
1407
1468
  return match?.[1] ?? null;
1408
1469
  }
1409
1470
 
1471
+ function buildTelegramIngressConversationId(botIdentity: string, telegramChatId: string) {
1472
+ return `telegram:${botIdentity}:${telegramChatId}`;
1473
+ }
1474
+
1410
1475
  type TelegramWebhookMessage = {
1411
1476
  text?: string;
1412
1477
  caption?: string;
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import type * as config from "../config.js";
12
+ import type * as flyCleanup from "../flyCleanup.js";
12
13
  import type * as identity from "../identity.js";
13
14
  import type * as lib from "../lib.js";
14
15
  import type * as messageTemplates from "../messageTemplates.js";
@@ -27,6 +28,7 @@ import { anyApi, componentsGeneric } from "convex/server";
27
28
 
28
29
  const fullApi: ApiFromModules<{
29
30
  config: typeof config;
31
+ flyCleanup: typeof flyCleanup;
30
32
  identity: typeof identity;
31
33
  lib: typeof lib;
32
34
  messageTemplates: typeof messageTemplates;
@@ -23,12 +23,50 @@ import type { FunctionReference } from "convex/server";
23
23
  */
24
24
  export type ComponentApi<Name extends string | undefined = string | undefined> =
25
25
  {
26
+ flyCleanup: {
27
+ runFlyCleanup: FunctionReference<
28
+ "action",
29
+ "internal",
30
+ {
31
+ flyApiToken?: string;
32
+ machineConcurrency?: number;
33
+ providerConfig?: {
34
+ appName: string;
35
+ image: string;
36
+ kind: "fly" | "runpod" | "ecs";
37
+ organizationSlug: string;
38
+ region: string;
39
+ volumeName: string;
40
+ volumePath: string;
41
+ volumeSizeGb: number;
42
+ };
43
+ volumeConcurrency?: number;
44
+ },
45
+ {
46
+ appName: string;
47
+ errors: Array<string>;
48
+ machineIdsDeleted: Array<string>;
49
+ machineIdsRemaining: Array<string>;
50
+ machinesDeleted: number;
51
+ machinesFound: number;
52
+ machinesRemaining: number;
53
+ volumeIdsDeleted: Array<string>;
54
+ volumeIdsRemaining: Array<string>;
55
+ volumesDeleted: number;
56
+ volumesFound: number;
57
+ volumesRemaining: number;
58
+ warnings: Array<string>;
59
+ },
60
+ Name
61
+ >;
62
+ };
26
63
  identity: {
27
64
  bindUserAgent: FunctionReference<
28
65
  "mutation",
29
66
  "internal",
30
67
  {
31
68
  agentKey: string;
69
+ botIdentity?: string;
32
70
  consumerUserId: string;
33
71
  metadata?: Record<string, string>;
34
72
  nowMs?: number;
@@ -38,6 +76,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
38
76
  },
39
77
  {
40
78
  agentKey: string;
79
+ botIdentity: null | string;
41
80
  boundAt: number;
42
81
  consumerUserId: string;
43
82
  conversationId: string;
@@ -53,8 +92,9 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
53
92
  configureTelegramWebhook: FunctionReference<
54
93
  "action",
55
94
  "internal",
56
- { convexSiteUrl: string; secretRef?: string },
95
+ { agentKey?: string; convexSiteUrl: string; secretRef?: string },
57
96
  {
97
+ botIdentity: null | string;
58
98
  currentUrl: null | string;
59
99
  description: string;
60
100
  isReady: boolean;
@@ -62,6 +102,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
62
102
  lastErrorMessage: null | string;
63
103
  ok: boolean;
64
104
  pendingUpdateCount: number;
105
+ secretTokenConfigured: boolean;
65
106
  webhookUrl: string;
66
107
  },
67
108
  Name
@@ -70,6 +111,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
70
111
  "mutation",
71
112
  "internal",
72
113
  {
114
+ botIdentity?: string;
73
115
  code: string;
74
116
  nowMs?: number;
75
117
  telegramChatId: string;
@@ -77,6 +119,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
77
119
  },
78
120
  {
79
121
  agentKey: string;
122
+ botIdentity: null | string;
80
123
  code: string;
81
124
  consumerUserId: string;
82
125
  createdAt: number;
@@ -99,6 +142,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
99
142
  },
100
143
  {
101
144
  agentKey: string;
145
+ botIdentity: null | string;
102
146
  code: string;
103
147
  consumerUserId: string;
104
148
  createdAt: number;
@@ -123,6 +167,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
123
167
  deepLink: null | string;
124
168
  pairing: {
125
169
  agentKey: string;
170
+ botIdentity: null | string;
126
171
  code: string;
127
172
  consumerUserId: string;
128
173
  createdAt: number;
@@ -176,6 +221,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
176
221
  { code: string; nowMs?: number },
177
222
  null | {
178
223
  agentKey: string;
224
+ botIdentity: null | string;
179
225
  code: string;
180
226
  consumerUserId: string;
181
227
  createdAt: number;
@@ -246,6 +292,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
246
292
  { consumerUserId: string },
247
293
  null | {
248
294
  agentKey: string;
295
+ botIdentity: null | string;
249
296
  boundAt: number;
250
297
  consumerUserId: string;
251
298
  conversationId: string;
@@ -264,6 +311,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
264
311
  { agentKey: string; consumerUserId: string; nowMs?: number },
265
312
  {
266
313
  agentKey: string;
314
+ botIdentity: null | string;
267
315
  nextAction:
268
316
  | "import_token"
269
317
  | "configure_webhook"
@@ -286,6 +334,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
286
334
  { agentKey: string; consumerUserId: string; nowMs?: number },
287
335
  null | {
288
336
  agentKey: string;
337
+ botIdentity: null | string;
289
338
  code: string;
290
339
  consumerUserId: string;
291
340
  createdAt: number;
@@ -338,7 +387,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
338
387
  Name
339
388
  >;
340
389
  importTelegramTokenForAgent: FunctionReference<
341
- "mutation",
390
+ "action",
342
391
  "internal",
343
392
  {
344
393
  agentKey: string;
@@ -346,7 +395,13 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
346
395
  metadata?: Record<string, string>;
347
396
  plaintextValue: string;
348
397
  },
349
- { secretId: string; secretRef: string; version: number },
398
+ {
399
+ botIdentity: string;
400
+ secretId: string;
401
+ secretRef: string;
402
+ telegramUsername: null | string;
403
+ version: number;
404
+ },
350
405
  Name
351
406
  >;
352
407
  listUserAgents: FunctionReference<
@@ -370,10 +425,26 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
370
425
  }>,
371
426
  Name
372
427
  >;
428
+ reconcileTelegramBotIdentityForAgent: FunctionReference<
429
+ "action",
430
+ "internal",
431
+ { agentKey: string; secretRef?: string },
432
+ {
433
+ agentKey: string;
434
+ botIdentity: string;
435
+ secretRef: null | string;
436
+ telegramUsername: null | string;
437
+ },
438
+ Name
439
+ >;
373
440
  resolveAgentForTelegram: FunctionReference<
374
441
  "query",
375
442
  "internal",
376
- { telegramChatId?: string; telegramUserId?: string },
443
+ {
444
+ botIdentity?: string;
445
+ telegramChatId?: string;
446
+ telegramUserId?: string;
447
+ },
377
448
  {
378
449
  agentKey: null | string;
379
450
  consumerUserId: null | string;
@@ -395,6 +466,24 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
395
466
  { revoked: number },
396
467
  Name
397
468
  >;
469
+ softResetTelegramBindingsMissingBotIdentity: FunctionReference<
470
+ "mutation",
471
+ "internal",
472
+ {
473
+ expirePendingPairings?: boolean;
474
+ nowMs?: number;
475
+ revokeActiveBindings?: boolean;
476
+ },
477
+ {
478
+ annotatedBindings: number;
479
+ expiredPairings: number;
480
+ legacyBindingsMissingBotIdentity: number;
481
+ pendingPairingsMissingBotIdentity: number;
482
+ profilesMissingBotIdentity: number;
483
+ revokedBindings: number;
484
+ },
485
+ Name
486
+ >;
398
487
  };
399
488
  lib: {
400
489
  appendConversationMessages: FunctionReference<
@@ -425,6 +514,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
425
514
  "internal",
426
515
  {
427
516
  agentKey: string;
517
+ botIdentity?: string;
428
518
  consumerUserId: string;
429
519
  metadata?: Record<string, string>;
430
520
  nowMs?: number;
@@ -434,6 +524,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
434
524
  },
435
525
  {
436
526
  agentKey: string;
527
+ botIdentity: null | string;
437
528
  boundAt: number;
438
529
  consumerUserId: string;
439
530
  conversationId: string;
@@ -530,6 +621,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
530
621
  "internal",
531
622
  {
532
623
  agentKey: string;
624
+ botIdentity?: string;
533
625
  bridgeConfig?: {
534
626
  appBaseUrlMapJsonSecretRef?: string;
535
627
  appKey?: string;
@@ -548,8 +640,9 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
548
640
  configureTelegramWebhook: FunctionReference<
549
641
  "action",
550
642
  "internal",
551
- { convexSiteUrl: string; secretRef?: string },
643
+ { agentKey?: string; convexSiteUrl: string; secretRef?: string },
552
644
  {
645
+ botIdentity: null | string;
553
646
  currentUrl: null | string;
554
647
  description: string;
555
648
  isReady: boolean;
@@ -557,6 +650,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
557
650
  lastErrorMessage: null | string;
558
651
  ok: boolean;
559
652
  pendingUpdateCount: number;
653
+ secretTokenConfigured: boolean;
560
654
  webhookUrl: string;
561
655
  },
562
656
  Name
@@ -565,6 +659,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
565
659
  "mutation",
566
660
  "internal",
567
661
  {
662
+ botIdentity?: string;
568
663
  code: string;
569
664
  nowMs?: number;
570
665
  telegramChatId: string;
@@ -572,6 +667,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
572
667
  },
573
668
  {
574
669
  agentKey: string;
670
+ botIdentity: null | string;
575
671
  code: string;
576
672
  consumerUserId: string;
577
673
  createdAt: number;
@@ -608,6 +704,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
608
704
  },
609
705
  {
610
706
  agentKey: string;
707
+ botIdentity: null | string;
611
708
  code: string;
612
709
  consumerUserId: string;
613
710
  createdAt: number;
@@ -735,6 +832,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
735
832
  deepLink: null | string;
736
833
  pairing: {
737
834
  agentKey: string;
835
+ botIdentity: null | string;
738
836
  code: string;
739
837
  consumerUserId: string;
740
838
  createdAt: number;
@@ -971,6 +1069,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
971
1069
  appBaseUrlMapJson: null | string;
972
1070
  appKey: null | string;
973
1071
  baseUrl: null | string;
1072
+ botIdentity: null | string;
974
1073
  serviceId: null | string;
975
1074
  serviceKey: null | string;
976
1075
  serviceKeySecretRef: null | string;
@@ -1033,6 +1132,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1033
1132
  { code: string; nowMs?: number },
1034
1133
  null | {
1035
1134
  agentKey: string;
1135
+ botIdentity: null | string;
1036
1136
  code: string;
1037
1137
  consumerUserId: string;
1038
1138
  createdAt: number;
@@ -1110,6 +1210,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1110
1210
  { consumerUserId: string },
1111
1211
  null | {
1112
1212
  agentKey: string;
1213
+ botIdentity: null | string;
1113
1214
  boundAt: number;
1114
1215
  consumerUserId: string;
1115
1216
  conversationId: string;
@@ -1139,6 +1240,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1139
1240
  { agentKey: string; consumerUserId: string; nowMs?: number },
1140
1241
  {
1141
1242
  agentKey: string;
1243
+ botIdentity: null | string;
1142
1244
  nextAction:
1143
1245
  | "import_token"
1144
1246
  | "configure_webhook"
@@ -1161,6 +1263,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1161
1263
  { agentKey: string; consumerUserId: string; nowMs?: number },
1162
1264
  null | {
1163
1265
  agentKey: string;
1266
+ botIdentity: null | string;
1164
1267
  code: string;
1165
1268
  consumerUserId: string;
1166
1269
  createdAt: number;
@@ -1263,7 +1366,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1263
1366
  Name
1264
1367
  >;
1265
1368
  importTelegramTokenForAgent: FunctionReference<
1266
- "mutation",
1369
+ "action",
1267
1370
  "internal",
1268
1371
  {
1269
1372
  agentKey: string;
@@ -1271,7 +1374,13 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1271
1374
  metadata?: Record<string, string>;
1272
1375
  plaintextValue: string;
1273
1376
  },
1274
- { secretId: string; secretRef: string; version: number },
1377
+ {
1378
+ botIdentity: string;
1379
+ secretId: string;
1380
+ secretRef: string;
1381
+ telegramUsername: null | string;
1382
+ version: number;
1383
+ },
1275
1384
  Name
1276
1385
  >;
1277
1386
  listMessageTemplatesByCompany: FunctionReference<
@@ -1572,6 +1681,18 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1572
1681
  { deadLetter: number; processing: number; queuedReady: number },
1573
1682
  Name
1574
1683
  >;
1684
+ reconcileTelegramBotIdentityForAgent: FunctionReference<
1685
+ "action",
1686
+ "internal",
1687
+ { agentKey: string; secretRef?: string },
1688
+ {
1689
+ agentKey: string;
1690
+ botIdentity: string;
1691
+ secretRef: null | string;
1692
+ telegramUsername: null | string;
1693
+ },
1694
+ Name
1695
+ >;
1575
1696
  reconcileWorkers: FunctionReference<
1576
1697
  "action",
1577
1698
  "internal",
@@ -1611,7 +1732,11 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1611
1732
  resolveAgentForTelegram: FunctionReference<
1612
1733
  "query",
1613
1734
  "internal",
1614
- { telegramChatId?: string; telegramUserId?: string },
1735
+ {
1736
+ botIdentity?: string;
1737
+ telegramChatId?: string;
1738
+ telegramUserId?: string;
1739
+ },
1615
1740
  {
1616
1741
  agentKey: null | string;
1617
1742
  consumerUserId: null | string;
@@ -1633,6 +1758,41 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1633
1758
  { revoked: number },
1634
1759
  Name
1635
1760
  >;
1761
+ runFlyCleanup: FunctionReference<
1762
+ "action",
1763
+ "internal",
1764
+ {
1765
+ flyApiToken?: string;
1766
+ machineConcurrency?: number;
1767
+ providerConfig?: {
1768
+ appName: string;
1769
+ image: string;
1770
+ kind: "fly" | "runpod" | "ecs";
1771
+ organizationSlug: string;
1772
+ region: string;
1773
+ volumeName: string;
1774
+ volumePath: string;
1775
+ volumeSizeGb: number;
1776
+ };
1777
+ volumeConcurrency?: number;
1778
+ },
1779
+ {
1780
+ appName: string;
1781
+ errors: Array<string>;
1782
+ machineIdsDeleted: Array<string>;
1783
+ machineIdsRemaining: Array<string>;
1784
+ machinesDeleted: number;
1785
+ machinesFound: number;
1786
+ machinesRemaining: number;
1787
+ volumeIdsDeleted: Array<string>;
1788
+ volumeIdsRemaining: Array<string>;
1789
+ volumesDeleted: number;
1790
+ volumesFound: number;
1791
+ volumesRemaining: number;
1792
+ warnings: Array<string>;
1793
+ },
1794
+ Name
1795
+ >;
1636
1796
  secretStatus: FunctionReference<
1637
1797
  "query",
1638
1798
  "internal",
@@ -1757,6 +1917,24 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1757
1917
  boolean,
1758
1918
  Name
1759
1919
  >;
1920
+ softResetTelegramBindingsMissingBotIdentity: FunctionReference<
1921
+ "mutation",
1922
+ "internal",
1923
+ {
1924
+ expirePendingPairings?: boolean;
1925
+ nowMs?: number;
1926
+ revokeActiveBindings?: boolean;
1927
+ },
1928
+ {
1929
+ annotatedBindings: number;
1930
+ expiredPairings: number;
1931
+ legacyBindingsMissingBotIdentity: number;
1932
+ pendingPairingsMissingBotIdentity: number;
1933
+ profilesMissingBotIdentity: number;
1934
+ revokedBindings: number;
1935
+ },
1936
+ Name
1937
+ >;
1760
1938
  triggerPushJobNow: FunctionReference<
1761
1939
  "mutation",
1762
1940
  "internal",
@@ -2666,6 +2844,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2666
2844
  appBaseUrlMapJson: null | string;
2667
2845
  appKey: null | string;
2668
2846
  baseUrl: null | string;
2847
+ botIdentity: null | string;
2669
2848
  serviceId: null | string;
2670
2849
  serviceKey: null | string;
2671
2850
  serviceKeySecretRef: null | string;
@@ -3179,6 +3358,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
3179
3358
  "internal",
3180
3359
  {
3181
3360
  agentKey: string;
3361
+ botIdentity?: string;
3182
3362
  bridgeConfig?: {
3183
3363
  appBaseUrlMapJsonSecretRef?: string;
3184
3364
  appKey?: string;