@okrlinkhub/agent-factory 3.0.3 → 3.1.1

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.
@@ -487,18 +487,21 @@ describe("component lib", () => {
487
487
  agentKey: "agent-a",
488
488
  version: "1.0.0",
489
489
  secretsRef: [],
490
+ botIdentity: "bot-agent-a",
490
491
  enabled: true,
491
492
  });
492
493
  await t.mutation(api.queue.upsertAgentProfile, {
493
494
  agentKey: "agent-b",
494
495
  version: "1.0.0",
495
496
  secretsRef: [],
497
+ botIdentity: "bot-agent-b",
496
498
  enabled: true,
497
499
  });
498
500
 
499
501
  const first = await t.mutation(api.lib.bindUserAgent, {
500
502
  consumerUserId: "u-1",
501
503
  agentKey: "agent-a",
504
+ botIdentity: "bot-agent-a",
502
505
  source: "telegram_pairing",
503
506
  telegramUserId: "tg-user-1",
504
507
  telegramChatId: "tg-chat-1",
@@ -711,6 +714,7 @@ describe("component lib", () => {
711
714
  appKey: "crm",
712
715
  serviceKey: "abs_live_bridge_key",
713
716
  serviceKeySecretRef: "agent-bridge.serviceKey.bridge-agent",
717
+ botIdentity: null,
714
718
  });
715
719
  });
716
720
 
@@ -2850,11 +2854,13 @@ describe("component lib", () => {
2850
2854
  agentKey: "push-telegram-manual-agent",
2851
2855
  version: "1.0.0",
2852
2856
  secretsRef: [],
2857
+ botIdentity: "push-telegram-manual-bot",
2853
2858
  enabled: true,
2854
2859
  });
2855
2860
  await t.mutation(api.lib.bindUserAgent, {
2856
2861
  consumerUserId: "user-push-telegram-manual",
2857
2862
  agentKey: "push-telegram-manual-agent",
2863
+ botIdentity: "push-telegram-manual-bot",
2858
2864
  source: "telegram_pairing",
2859
2865
  telegramUserId: "tg-user-manual-1",
2860
2866
  telegramChatId: "8246761447",
@@ -2895,11 +2901,13 @@ describe("component lib", () => {
2895
2901
  agentKey: "push-telegram-scheduled-agent",
2896
2902
  version: "1.0.0",
2897
2903
  secretsRef: [],
2904
+ botIdentity: "push-telegram-scheduled-bot",
2898
2905
  enabled: true,
2899
2906
  });
2900
2907
  await t.mutation(api.lib.bindUserAgent, {
2901
2908
  consumerUserId: "user-push-telegram-scheduled",
2902
2909
  agentKey: "push-telegram-scheduled-agent",
2910
+ botIdentity: "push-telegram-scheduled-bot",
2903
2911
  source: "telegram_pairing",
2904
2912
  telegramUserId: "tg-user-scheduled-1",
2905
2913
  telegramChatId: "9988776655",
@@ -53,12 +53,14 @@ export {
53
53
  createUserAgentPairing,
54
54
  getUserAgentPairingStatus,
55
55
  importTelegramTokenForAgent,
56
+ reconcileTelegramBotIdentityForAgent,
56
57
  getUserAgentOnboardingState,
57
58
  getRequiredSecretRefs,
58
59
  getProviderOperationalReadiness,
59
60
  getTelegramAgentReadiness,
60
61
  getAgentOperationalReadiness,
61
62
  getWebhookReadiness,
63
+ softResetTelegramBindingsMissingBotIdentity,
62
64
  } from "./identity.js";
63
65
 
64
66
  export {
@@ -181,6 +181,7 @@ const bridgeRuntimeConfigValidator = v.object({
181
181
  appKey: v.union(v.null(), v.string()),
182
182
  serviceKey: v.union(v.null(), v.string()),
183
183
  serviceKeySecretRef: v.union(v.null(), v.string()),
184
+ botIdentity: v.union(v.null(), v.string()),
184
185
  });
185
186
  const workerSpawnOpenClawEnvValidator = v.object({
186
187
  OPENCLAW_SERVICE_ID: v.optional(v.string()),
@@ -343,6 +344,7 @@ export const upsertAgentProfile = mutation({
343
344
  agentKey: v.string(),
344
345
  version: v.string(),
345
346
  secretsRef: v.array(v.string()),
347
+ botIdentity: v.optional(v.string()),
346
348
  bridgeConfig: v.optional(bridgeProfileConfigValidator),
347
349
  enabled: v.boolean(),
348
350
  },
@@ -2731,6 +2733,7 @@ async function resolveBridgeRuntimeConfig(
2731
2733
  ctx: any,
2732
2734
  profile: {
2733
2735
  agentKey: string;
2736
+ botIdentity?: string;
2734
2737
  bridgeConfig?: {
2735
2738
  enabled: boolean;
2736
2739
  baseUrl?: string;
@@ -2747,6 +2750,7 @@ async function resolveBridgeRuntimeConfig(
2747
2750
  appKey: string | null;
2748
2751
  serviceKey: string | null;
2749
2752
  serviceKeySecretRef: string | null;
2753
+ botIdentity: string | null;
2750
2754
  } | null> {
2751
2755
  if (!profile.bridgeConfig?.enabled) {
2752
2756
  return null;
@@ -2791,6 +2795,7 @@ async function resolveBridgeRuntimeConfig(
2791
2795
  appKey: profile.bridgeConfig.appKey ?? appKeyFromSecret,
2792
2796
  serviceKey,
2793
2797
  serviceKeySecretRef,
2798
+ botIdentity: profile.botIdentity ?? null,
2794
2799
  };
2795
2800
  }
2796
2801
 
@@ -7,6 +7,7 @@ export default defineSchema({
7
7
  agentKey: v.string(),
8
8
  version: v.string(),
9
9
  secretsRef: v.array(v.string()),
10
+ botIdentity: v.optional(v.string()),
10
11
  bridgeConfig: v.optional(
11
12
  v.object({
12
13
  enabled: v.boolean(),
@@ -20,6 +21,7 @@ export default defineSchema({
20
21
  enabled: v.boolean(),
21
22
  })
22
23
  .index("by_agentKey", ["agentKey"])
24
+ .index("by_botIdentity", ["botIdentity"])
23
25
  .index("by_enabled", ["enabled"]),
24
26
 
25
27
  conversations: defineTable({
@@ -256,6 +258,7 @@ export default defineSchema({
256
258
  consumerUserId: v.string(),
257
259
  agentKey: v.string(),
258
260
  conversationId: v.string(),
261
+ botIdentity: v.optional(v.string()),
259
262
  status: v.union(v.literal("active"), v.literal("revoked")),
260
263
  source: v.union(
261
264
  v.literal("manual"),
@@ -274,6 +277,16 @@ export default defineSchema({
274
277
  "agentKey",
275
278
  "boundAt",
276
279
  ])
280
+ .index("by_botIdentity_and_telegramUserId_and_status", [
281
+ "botIdentity",
282
+ "telegramUserId",
283
+ "status",
284
+ ])
285
+ .index("by_botIdentity_and_telegramChatId_and_status", [
286
+ "botIdentity",
287
+ "telegramChatId",
288
+ "status",
289
+ ])
277
290
  .index("by_telegramUserId_and_status", ["telegramUserId", "status"])
278
291
  .index("by_telegramChatId_and_status", ["telegramChatId", "status"])
279
292
  .index("by_agentKey_and_status", ["agentKey", "status"]),
@@ -282,6 +295,7 @@ export default defineSchema({
282
295
  code: v.string(),
283
296
  consumerUserId: v.string(),
284
297
  agentKey: v.string(),
298
+ botIdentity: v.optional(v.string()),
285
299
  status: v.union(v.literal("pending"), v.literal("used"), v.literal("expired")),
286
300
  createdAt: v.number(),
287
301
  expiresAt: v.number(),
@@ -296,6 +310,7 @@ export default defineSchema({
296
310
  "agentKey",
297
311
  "createdAt",
298
312
  ])
313
+ .index("by_botIdentity_and_status", ["botIdentity", "status"])
299
314
  .index("by_expiresAt", ["expiresAt"]),
300
315
 
301
316
  globalSkills: defineTable({