@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
@@ -19,9 +19,41 @@ import type { FunctionReference } from "convex/server";
19
19
  * ```
20
20
  */
21
21
  export type ComponentApi<Name extends string | undefined = string | undefined> = {
22
+ flyCleanup: {
23
+ runFlyCleanup: FunctionReference<"action", "internal", {
24
+ flyApiToken?: string;
25
+ machineConcurrency?: number;
26
+ providerConfig?: {
27
+ appName: string;
28
+ image: string;
29
+ kind: "fly" | "runpod" | "ecs";
30
+ organizationSlug: string;
31
+ region: string;
32
+ volumeName: string;
33
+ volumePath: string;
34
+ volumeSizeGb: number;
35
+ };
36
+ volumeConcurrency?: number;
37
+ }, {
38
+ appName: string;
39
+ errors: Array<string>;
40
+ machineIdsDeleted: Array<string>;
41
+ machineIdsRemaining: Array<string>;
42
+ machinesDeleted: number;
43
+ machinesFound: number;
44
+ machinesRemaining: number;
45
+ volumeIdsDeleted: Array<string>;
46
+ volumeIdsRemaining: Array<string>;
47
+ volumesDeleted: number;
48
+ volumesFound: number;
49
+ volumesRemaining: number;
50
+ warnings: Array<string>;
51
+ }, Name>;
52
+ };
22
53
  identity: {
23
54
  bindUserAgent: FunctionReference<"mutation", "internal", {
24
55
  agentKey: string;
56
+ botIdentity?: string;
25
57
  consumerUserId: string;
26
58
  metadata?: Record<string, string>;
27
59
  nowMs?: number;
@@ -30,6 +62,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
30
62
  telegramUserId?: string;
31
63
  }, {
32
64
  agentKey: string;
65
+ botIdentity: null | string;
33
66
  boundAt: number;
34
67
  consumerUserId: string;
35
68
  conversationId: string;
@@ -41,9 +74,11 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
41
74
  telegramUserId: null | string;
42
75
  }, Name>;
43
76
  configureTelegramWebhook: FunctionReference<"action", "internal", {
77
+ agentKey?: string;
44
78
  convexSiteUrl: string;
45
79
  secretRef?: string;
46
80
  }, {
81
+ botIdentity: null | string;
47
82
  currentUrl: null | string;
48
83
  description: string;
49
84
  isReady: boolean;
@@ -51,15 +86,18 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
51
86
  lastErrorMessage: null | string;
52
87
  ok: boolean;
53
88
  pendingUpdateCount: number;
89
+ secretTokenConfigured: boolean;
54
90
  webhookUrl: string;
55
91
  }, Name>;
56
92
  consumePairingCode: FunctionReference<"mutation", "internal", {
93
+ botIdentity?: string;
57
94
  code: string;
58
95
  nowMs?: number;
59
96
  telegramChatId: string;
60
97
  telegramUserId: string;
61
98
  }, {
62
99
  agentKey: string;
100
+ botIdentity: null | string;
63
101
  code: string;
64
102
  consumerUserId: string;
65
103
  createdAt: number;
@@ -76,6 +114,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
76
114
  ttlMs?: number;
77
115
  }, {
78
116
  agentKey: string;
117
+ botIdentity: null | string;
79
118
  code: string;
80
119
  consumerUserId: string;
81
120
  createdAt: number;
@@ -94,6 +133,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
94
133
  deepLink: null | string;
95
134
  pairing: {
96
135
  agentKey: string;
136
+ botIdentity: null | string;
97
137
  code: string;
98
138
  consumerUserId: string;
99
139
  createdAt: number;
@@ -139,6 +179,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
139
179
  nowMs?: number;
140
180
  }, null | {
141
181
  agentKey: string;
182
+ botIdentity: null | string;
142
183
  code: string;
143
184
  consumerUserId: string;
144
185
  createdAt: number;
@@ -194,6 +235,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
194
235
  consumerUserId: string;
195
236
  }, null | {
196
237
  agentKey: string;
238
+ botIdentity: null | string;
197
239
  boundAt: number;
198
240
  consumerUserId: string;
199
241
  conversationId: string;
@@ -210,6 +252,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
210
252
  nowMs?: number;
211
253
  }, {
212
254
  agentKey: string;
255
+ botIdentity: null | string;
213
256
  nextAction: "import_token" | "configure_webhook" | "create_pairing" | "complete_pairing" | "ready";
214
257
  pairingCode: null | string;
215
258
  pairingDeepLink: null | string;
@@ -225,6 +268,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
225
268
  nowMs?: number;
226
269
  }, null | {
227
270
  agentKey: string;
271
+ botIdentity: null | string;
228
272
  code: string;
229
273
  consumerUserId: string;
230
274
  createdAt: number;
@@ -267,14 +311,16 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
267
311
  secretRef: null | string;
268
312
  webhookReady: boolean;
269
313
  }, Name>;
270
- importTelegramTokenForAgent: FunctionReference<"mutation", "internal", {
314
+ importTelegramTokenForAgent: FunctionReference<"action", "internal", {
271
315
  agentKey: string;
272
316
  consumerUserId: string;
273
317
  metadata?: Record<string, string>;
274
318
  plaintextValue: string;
275
319
  }, {
320
+ botIdentity: string;
276
321
  secretId: string;
277
322
  secretRef: string;
323
+ telegramUsername: null | string;
278
324
  version: number;
279
325
  }, Name>;
280
326
  listUserAgents: FunctionReference<"query", "internal", {
@@ -296,7 +342,17 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
296
342
  telegramUsername: null | string;
297
343
  version: null | string;
298
344
  }>, Name>;
345
+ reconcileTelegramBotIdentityForAgent: FunctionReference<"action", "internal", {
346
+ agentKey: string;
347
+ secretRef?: string;
348
+ }, {
349
+ agentKey: string;
350
+ botIdentity: string;
351
+ secretRef: null | string;
352
+ telegramUsername: null | string;
353
+ }, Name>;
299
354
  resolveAgentForTelegram: FunctionReference<"query", "internal", {
355
+ botIdentity?: string;
300
356
  telegramChatId?: string;
301
357
  telegramUserId?: string;
302
358
  }, {
@@ -316,6 +372,18 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
316
372
  }, {
317
373
  revoked: number;
318
374
  }, Name>;
375
+ softResetTelegramBindingsMissingBotIdentity: FunctionReference<"mutation", "internal", {
376
+ expirePendingPairings?: boolean;
377
+ nowMs?: number;
378
+ revokeActiveBindings?: boolean;
379
+ }, {
380
+ annotatedBindings: number;
381
+ expiredPairings: number;
382
+ legacyBindingsMissingBotIdentity: number;
383
+ pendingPairingsMissingBotIdentity: number;
384
+ profilesMissingBotIdentity: number;
385
+ revokedBindings: number;
386
+ }, Name>;
319
387
  };
320
388
  lib: {
321
389
  appendConversationMessages: FunctionReference<"mutation", "internal", {
@@ -337,6 +405,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
337
405
  }, boolean, Name>;
338
406
  bindUserAgent: FunctionReference<"mutation", "internal", {
339
407
  agentKey: string;
408
+ botIdentity?: string;
340
409
  consumerUserId: string;
341
410
  metadata?: Record<string, string>;
342
411
  nowMs?: number;
@@ -345,6 +414,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
345
414
  telegramUserId?: string;
346
415
  }, {
347
416
  agentKey: string;
417
+ botIdentity: null | string;
348
418
  boundAt: number;
349
419
  consumerUserId: string;
350
420
  conversationId: string;
@@ -422,6 +492,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
422
492
  }, boolean, Name>;
423
493
  configureAgent: FunctionReference<"mutation", "internal", {
424
494
  agentKey: string;
495
+ botIdentity?: string;
425
496
  bridgeConfig?: {
426
497
  appBaseUrlMapJsonSecretRef?: string;
427
498
  appKey?: string;
@@ -435,9 +506,11 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
435
506
  version: string;
436
507
  }, string, Name>;
437
508
  configureTelegramWebhook: FunctionReference<"action", "internal", {
509
+ agentKey?: string;
438
510
  convexSiteUrl: string;
439
511
  secretRef?: string;
440
512
  }, {
513
+ botIdentity: null | string;
441
514
  currentUrl: null | string;
442
515
  description: string;
443
516
  isReady: boolean;
@@ -445,15 +518,18 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
445
518
  lastErrorMessage: null | string;
446
519
  ok: boolean;
447
520
  pendingUpdateCount: number;
521
+ secretTokenConfigured: boolean;
448
522
  webhookUrl: string;
449
523
  }, Name>;
450
524
  consumePairingCode: FunctionReference<"mutation", "internal", {
525
+ botIdentity?: string;
451
526
  code: string;
452
527
  nowMs?: number;
453
528
  telegramChatId: string;
454
529
  telegramUserId: string;
455
530
  }, {
456
531
  agentKey: string;
532
+ botIdentity: null | string;
457
533
  code: string;
458
534
  consumerUserId: string;
459
535
  createdAt: number;
@@ -478,6 +554,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
478
554
  ttlMs?: number;
479
555
  }, {
480
556
  agentKey: string;
557
+ botIdentity: null | string;
481
558
  code: string;
482
559
  consumerUserId: string;
483
560
  createdAt: number;
@@ -612,6 +689,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
612
689
  deepLink: null | string;
613
690
  pairing: {
614
691
  agentKey: string;
692
+ botIdentity: null | string;
615
693
  code: string;
616
694
  consumerUserId: string;
617
695
  createdAt: number;
@@ -811,6 +889,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
811
889
  appBaseUrlMapJson: null | string;
812
890
  appKey: null | string;
813
891
  baseUrl: null | string;
892
+ botIdentity: null | string;
814
893
  serviceId: null | string;
815
894
  serviceKey: null | string;
816
895
  serviceKeySecretRef: null | string;
@@ -868,6 +947,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
868
947
  nowMs?: number;
869
948
  }, null | {
870
949
  agentKey: string;
950
+ botIdentity: null | string;
871
951
  code: string;
872
952
  consumerUserId: string;
873
953
  createdAt: number;
@@ -926,6 +1006,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
926
1006
  consumerUserId: string;
927
1007
  }, null | {
928
1008
  agentKey: string;
1009
+ botIdentity: null | string;
929
1010
  boundAt: number;
930
1011
  consumerUserId: string;
931
1012
  conversationId: string;
@@ -950,6 +1031,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
950
1031
  nowMs?: number;
951
1032
  }, {
952
1033
  agentKey: string;
1034
+ botIdentity: null | string;
953
1035
  nextAction: "import_token" | "configure_webhook" | "create_pairing" | "complete_pairing" | "ready";
954
1036
  pairingCode: null | string;
955
1037
  pairingDeepLink: null | string;
@@ -965,6 +1047,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
965
1047
  nowMs?: number;
966
1048
  }, null | {
967
1049
  agentKey: string;
1050
+ botIdentity: null | string;
968
1051
  code: string;
969
1052
  consumerUserId: string;
970
1053
  createdAt: number;
@@ -1043,14 +1126,16 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1043
1126
  secretRef: string;
1044
1127
  version: number;
1045
1128
  }, Name>;
1046
- importTelegramTokenForAgent: FunctionReference<"mutation", "internal", {
1129
+ importTelegramTokenForAgent: FunctionReference<"action", "internal", {
1047
1130
  agentKey: string;
1048
1131
  consumerUserId: string;
1049
1132
  metadata?: Record<string, string>;
1050
1133
  plaintextValue: string;
1051
1134
  }, {
1135
+ botIdentity: string;
1052
1136
  secretId: string;
1053
1137
  secretRef: string;
1138
+ telegramUsername: null | string;
1054
1139
  version: number;
1055
1140
  }, Name>;
1056
1141
  listMessageTemplatesByCompany: FunctionReference<"query", "internal", {
@@ -1327,6 +1412,15 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1327
1412
  processing: number;
1328
1413
  queuedReady: number;
1329
1414
  }, Name>;
1415
+ reconcileTelegramBotIdentityForAgent: FunctionReference<"action", "internal", {
1416
+ agentKey: string;
1417
+ secretRef?: string;
1418
+ }, {
1419
+ agentKey: string;
1420
+ botIdentity: string;
1421
+ secretRef: null | string;
1422
+ telegramUsername: null | string;
1423
+ }, Name>;
1330
1424
  reconcileWorkers: FunctionReference<"action", "internal", {
1331
1425
  convexUrl?: string;
1332
1426
  flyApiToken?: string;
@@ -1362,6 +1456,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1362
1456
  unlocked: number;
1363
1457
  }, Name>;
1364
1458
  resolveAgentForTelegram: FunctionReference<"query", "internal", {
1459
+ botIdentity?: string;
1365
1460
  telegramChatId?: string;
1366
1461
  telegramUserId?: string;
1367
1462
  }, {
@@ -1381,6 +1476,35 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1381
1476
  }, {
1382
1477
  revoked: number;
1383
1478
  }, Name>;
1479
+ runFlyCleanup: FunctionReference<"action", "internal", {
1480
+ flyApiToken?: string;
1481
+ machineConcurrency?: number;
1482
+ providerConfig?: {
1483
+ appName: string;
1484
+ image: string;
1485
+ kind: "fly" | "runpod" | "ecs";
1486
+ organizationSlug: string;
1487
+ region: string;
1488
+ volumeName: string;
1489
+ volumePath: string;
1490
+ volumeSizeGb: number;
1491
+ };
1492
+ volumeConcurrency?: number;
1493
+ }, {
1494
+ appName: string;
1495
+ errors: Array<string>;
1496
+ machineIdsDeleted: Array<string>;
1497
+ machineIdsRemaining: Array<string>;
1498
+ machinesDeleted: number;
1499
+ machinesFound: number;
1500
+ machinesRemaining: number;
1501
+ volumeIdsDeleted: Array<string>;
1502
+ volumeIdsRemaining: Array<string>;
1503
+ volumesDeleted: number;
1504
+ volumesFound: number;
1505
+ volumesRemaining: number;
1506
+ warnings: Array<string>;
1507
+ }, Name>;
1384
1508
  secretStatus: FunctionReference<"query", "internal", {
1385
1509
  secretRefs: Array<string>;
1386
1510
  }, Array<{
@@ -1472,6 +1596,18 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
1472
1596
  jobId: string;
1473
1597
  nowMs?: number;
1474
1598
  }, boolean, Name>;
1599
+ softResetTelegramBindingsMissingBotIdentity: FunctionReference<"mutation", "internal", {
1600
+ expirePendingPairings?: boolean;
1601
+ nowMs?: number;
1602
+ revokeActiveBindings?: boolean;
1603
+ }, {
1604
+ annotatedBindings: number;
1605
+ expiredPairings: number;
1606
+ legacyBindingsMissingBotIdentity: number;
1607
+ pendingPairingsMissingBotIdentity: number;
1608
+ profilesMissingBotIdentity: number;
1609
+ revokedBindings: number;
1610
+ }, Name>;
1475
1611
  triggerPushJobNow: FunctionReference<"mutation", "internal", {
1476
1612
  jobId: string;
1477
1613
  nowMs?: number;
@@ -2307,6 +2443,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2307
2443
  appBaseUrlMapJson: null | string;
2308
2444
  appKey: null | string;
2309
2445
  baseUrl: null | string;
2446
+ botIdentity: null | string;
2310
2447
  serviceId: null | string;
2311
2448
  serviceKey: null | string;
2312
2449
  serviceKeySecretRef: null | string;
@@ -2703,6 +2840,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2703
2840
  }, null, Name>;
2704
2841
  upsertAgentProfile: FunctionReference<"mutation", "internal", {
2705
2842
  agentKey: string;
2843
+ botIdentity?: string;
2706
2844
  bridgeConfig?: {
2707
2845
  appBaseUrlMapJsonSecretRef?: string;
2708
2846
  appKey?: string;