@okrlinkhub/agent-factory 0.2.3 → 0.2.5

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 (42) hide show
  1. package/README.md +44 -0
  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 +24 -6
  5. package/dist/client/bridge.js.map +1 -1
  6. package/dist/client/index.d.ts +145 -2
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/index.js +192 -0
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/component/_generated/api.d.ts +2 -0
  11. package/dist/component/_generated/api.d.ts.map +1 -1
  12. package/dist/component/_generated/api.js.map +1 -1
  13. package/dist/component/_generated/component.d.ts +456 -0
  14. package/dist/component/_generated/component.d.ts.map +1 -1
  15. package/dist/component/lib.d.ts +1 -0
  16. package/dist/component/lib.d.ts.map +1 -1
  17. package/dist/component/lib.js +1 -0
  18. package/dist/component/lib.js.map +1 -1
  19. package/dist/component/pushing.d.ts +226 -0
  20. package/dist/component/pushing.d.ts.map +1 -0
  21. package/dist/component/pushing.js +954 -0
  22. package/dist/component/pushing.js.map +1 -0
  23. package/dist/component/queue.d.ts +8 -5
  24. package/dist/component/queue.d.ts.map +1 -1
  25. package/dist/component/queue.js +28 -1
  26. package/dist/component/queue.js.map +1 -1
  27. package/dist/component/schema.d.ts +261 -8
  28. package/dist/component/schema.d.ts.map +1 -1
  29. package/dist/component/schema.js +104 -0
  30. package/dist/component/schema.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/client/bridge.test.ts +2 -0
  33. package/src/client/bridge.ts +32 -6
  34. package/src/client/index.test.ts +29 -19
  35. package/src/client/index.ts +209 -0
  36. package/src/component/_generated/api.ts +2 -0
  37. package/src/component/_generated/component.ts +448 -0
  38. package/src/component/lib.test.ts +103 -0
  39. package/src/component/lib.ts +17 -0
  40. package/src/component/pushing.ts +1111 -0
  41. package/src/component/queue.ts +45 -1
  42. package/src/component/schema.ts +138 -0
@@ -288,6 +288,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
288
288
  {
289
289
  agentKey: string;
290
290
  bridgeConfig?: {
291
+ appBaseUrlMapJsonSecretRef?: string;
291
292
  appKey?: string;
292
293
  baseUrl?: string;
293
294
  enabled: boolean;
@@ -296,6 +297,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
296
297
  };
297
298
  clientMd?: string;
298
299
  enabled: boolean;
300
+ providerUserId?: string;
299
301
  secretsRef: Array<string>;
300
302
  skills: Array<string>;
301
303
  soulMd: string;
@@ -364,6 +366,67 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
364
366
  },
365
367
  Name
366
368
  >;
369
+ createPushJobCustom: FunctionReference<
370
+ "mutation",
371
+ "internal",
372
+ {
373
+ companyId: string;
374
+ consumerUserId: string;
375
+ enabled?: boolean;
376
+ nowMs?: number;
377
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
378
+ schedule:
379
+ | { kind: "manual" }
380
+ | { kind: "daily"; time: string }
381
+ | { kind: "weekly"; time: string; weekday: number }
382
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
383
+ text: string;
384
+ timezone: string;
385
+ title: string;
386
+ },
387
+ string,
388
+ Name
389
+ >;
390
+ createPushJobFromTemplate: FunctionReference<
391
+ "mutation",
392
+ "internal",
393
+ {
394
+ companyId: string;
395
+ consumerUserId: string;
396
+ enabled?: boolean;
397
+ nowMs?: number;
398
+ schedule?:
399
+ | { kind: "manual" }
400
+ | { kind: "daily"; time: string }
401
+ | { kind: "weekly"; time: string; weekday: number }
402
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
403
+ templateId: string;
404
+ timezone: string;
405
+ },
406
+ string,
407
+ Name
408
+ >;
409
+ createPushTemplate: FunctionReference<
410
+ "mutation",
411
+ "internal",
412
+ {
413
+ actorUserId: string;
414
+ companyId: string;
415
+ enabled?: boolean;
416
+ nowMs?: number;
417
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
418
+ suggestedTimes: Array<
419
+ | { kind: "daily"; time: string }
420
+ | { kind: "weekly"; time: string; weekday: number }
421
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
422
+ >;
423
+ templateKey: string;
424
+ text: string;
425
+ title: string;
426
+ },
427
+ string,
428
+ Name
429
+ >;
367
430
  deleteFlyVolume: FunctionReference<
368
431
  "action",
369
432
  "internal",
@@ -371,6 +434,27 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
371
434
  { message: string; ok: boolean; status: number },
372
435
  Name
373
436
  >;
437
+ deletePushJob: FunctionReference<
438
+ "mutation",
439
+ "internal",
440
+ { jobId: string },
441
+ boolean,
442
+ Name
443
+ >;
444
+ deletePushTemplate: FunctionReference<
445
+ "mutation",
446
+ "internal",
447
+ { templateId: string },
448
+ boolean,
449
+ Name
450
+ >;
451
+ dispatchDuePushJobs: FunctionReference<
452
+ "mutation",
453
+ "internal",
454
+ { limit?: number; nowMs?: number },
455
+ { enqueued: number; failed: number; scanned: number; skipped: number },
456
+ Name
457
+ >;
374
458
  enqueue: FunctionReference<
375
459
  "mutation",
376
460
  "internal",
@@ -444,6 +528,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
444
528
  null | {
445
529
  agentKey: string;
446
530
  bridgeRuntimeConfig: null | {
531
+ appBaseUrlMapJson: null | string;
447
532
  appKey: null | string;
448
533
  baseUrl: null | string;
449
534
  serviceId: null | string;
@@ -540,6 +625,72 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
540
625
  { secretId: string; secretRef: string; version: number },
541
626
  Name
542
627
  >;
628
+ listPushDispatchesByJob: FunctionReference<
629
+ "query",
630
+ "internal",
631
+ { jobId: string; limit?: number },
632
+ Array<{
633
+ _id: string;
634
+ createdAt: number;
635
+ error: null | string;
636
+ runKey: string;
637
+ scheduledFor: number;
638
+ status: "enqueued" | "skipped" | "failed";
639
+ }>,
640
+ Name
641
+ >;
642
+ listPushJobsForUser: FunctionReference<
643
+ "query",
644
+ "internal",
645
+ { consumerUserId: string; includeDisabled?: boolean },
646
+ Array<{
647
+ _id: string;
648
+ agentKey: null | string;
649
+ companyId: string;
650
+ consumerUserId: string;
651
+ createdAt: number;
652
+ enabled: boolean;
653
+ lastRunAt: null | number;
654
+ lastRunKey: null | string;
655
+ nextRunAt: null | number;
656
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
657
+ schedule:
658
+ | { kind: "manual" }
659
+ | { kind: "daily"; time: string }
660
+ | { kind: "weekly"; time: string; weekday: number }
661
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
662
+ sourceTemplateId: null | string;
663
+ text: string;
664
+ timezone: string;
665
+ title: string;
666
+ updatedAt: number;
667
+ }>,
668
+ Name
669
+ >;
670
+ listPushTemplatesByCompany: FunctionReference<
671
+ "query",
672
+ "internal",
673
+ { companyId: string; includeDisabled?: boolean },
674
+ Array<{
675
+ _id: string;
676
+ companyId: string;
677
+ createdAt: number;
678
+ createdBy: string;
679
+ enabled: boolean;
680
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
681
+ suggestedTimes: Array<
682
+ | { kind: "daily"; time: string }
683
+ | { kind: "weekly"; time: string; weekday: number }
684
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
685
+ >;
686
+ templateKey: string;
687
+ text: string;
688
+ title: string;
689
+ updatedAt: number;
690
+ updatedBy: string;
691
+ }>,
692
+ Name
693
+ >;
543
694
  queueStats: FunctionReference<
544
695
  "query",
545
696
  "internal",
@@ -615,6 +766,78 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
615
766
  }>,
616
767
  Name
617
768
  >;
769
+ sendBroadcastToAllActiveAgents: FunctionReference<
770
+ "mutation",
771
+ "internal",
772
+ {
773
+ companyId: string;
774
+ nowMs?: number;
775
+ requestedBy: string;
776
+ text: string;
777
+ title: string;
778
+ },
779
+ {
780
+ broadcastId: string;
781
+ enqueued: number;
782
+ failed: number;
783
+ totalTargets: number;
784
+ },
785
+ Name
786
+ >;
787
+ setPushJobEnabled: FunctionReference<
788
+ "mutation",
789
+ "internal",
790
+ { enabled: boolean; jobId: string; nowMs?: number },
791
+ boolean,
792
+ Name
793
+ >;
794
+ triggerPushJobNow: FunctionReference<
795
+ "mutation",
796
+ "internal",
797
+ { jobId: string; nowMs?: number },
798
+ { enqueuedMessageId: string; runKey: string },
799
+ Name
800
+ >;
801
+ updatePushJob: FunctionReference<
802
+ "mutation",
803
+ "internal",
804
+ {
805
+ enabled?: boolean;
806
+ jobId: string;
807
+ nowMs?: number;
808
+ periodicity?: "manual" | "daily" | "weekly" | "monthly";
809
+ schedule?:
810
+ | { kind: "manual" }
811
+ | { kind: "daily"; time: string }
812
+ | { kind: "weekly"; time: string; weekday: number }
813
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
814
+ text?: string;
815
+ timezone?: string;
816
+ title?: string;
817
+ },
818
+ boolean,
819
+ Name
820
+ >;
821
+ updatePushTemplate: FunctionReference<
822
+ "mutation",
823
+ "internal",
824
+ {
825
+ actorUserId: string;
826
+ enabled?: boolean;
827
+ nowMs?: number;
828
+ periodicity?: "manual" | "daily" | "weekly" | "monthly";
829
+ suggestedTimes?: Array<
830
+ | { kind: "daily"; time: string }
831
+ | { kind: "weekly"; time: string; weekday: number }
832
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
833
+ >;
834
+ templateId: string;
835
+ text?: string;
836
+ title?: string;
837
+ },
838
+ boolean,
839
+ Name
840
+ >;
618
841
  workerStats: FunctionReference<
619
842
  "query",
620
843
  "internal",
@@ -645,6 +868,228 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
645
868
  >;
646
869
  };
647
870
  };
871
+ pushing: {
872
+ createPushJobCustom: FunctionReference<
873
+ "mutation",
874
+ "internal",
875
+ {
876
+ companyId: string;
877
+ consumerUserId: string;
878
+ enabled?: boolean;
879
+ nowMs?: number;
880
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
881
+ schedule:
882
+ | { kind: "manual" }
883
+ | { kind: "daily"; time: string }
884
+ | { kind: "weekly"; time: string; weekday: number }
885
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
886
+ text: string;
887
+ timezone: string;
888
+ title: string;
889
+ },
890
+ string,
891
+ Name
892
+ >;
893
+ createPushJobFromTemplate: FunctionReference<
894
+ "mutation",
895
+ "internal",
896
+ {
897
+ companyId: string;
898
+ consumerUserId: string;
899
+ enabled?: boolean;
900
+ nowMs?: number;
901
+ schedule?:
902
+ | { kind: "manual" }
903
+ | { kind: "daily"; time: string }
904
+ | { kind: "weekly"; time: string; weekday: number }
905
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
906
+ templateId: string;
907
+ timezone: string;
908
+ },
909
+ string,
910
+ Name
911
+ >;
912
+ createPushTemplate: FunctionReference<
913
+ "mutation",
914
+ "internal",
915
+ {
916
+ actorUserId: string;
917
+ companyId: string;
918
+ enabled?: boolean;
919
+ nowMs?: number;
920
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
921
+ suggestedTimes: Array<
922
+ | { kind: "daily"; time: string }
923
+ | { kind: "weekly"; time: string; weekday: number }
924
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
925
+ >;
926
+ templateKey: string;
927
+ text: string;
928
+ title: string;
929
+ },
930
+ string,
931
+ Name
932
+ >;
933
+ deletePushJob: FunctionReference<
934
+ "mutation",
935
+ "internal",
936
+ { jobId: string },
937
+ boolean,
938
+ Name
939
+ >;
940
+ deletePushTemplate: FunctionReference<
941
+ "mutation",
942
+ "internal",
943
+ { templateId: string },
944
+ boolean,
945
+ Name
946
+ >;
947
+ dispatchDuePushJobs: FunctionReference<
948
+ "mutation",
949
+ "internal",
950
+ { limit?: number; nowMs?: number },
951
+ { enqueued: number; failed: number; scanned: number; skipped: number },
952
+ Name
953
+ >;
954
+ listPushDispatchesByJob: FunctionReference<
955
+ "query",
956
+ "internal",
957
+ { jobId: string; limit?: number },
958
+ Array<{
959
+ _id: string;
960
+ createdAt: number;
961
+ error: null | string;
962
+ runKey: string;
963
+ scheduledFor: number;
964
+ status: "enqueued" | "skipped" | "failed";
965
+ }>,
966
+ Name
967
+ >;
968
+ listPushJobsForUser: FunctionReference<
969
+ "query",
970
+ "internal",
971
+ { consumerUserId: string; includeDisabled?: boolean },
972
+ Array<{
973
+ _id: string;
974
+ agentKey: null | string;
975
+ companyId: string;
976
+ consumerUserId: string;
977
+ createdAt: number;
978
+ enabled: boolean;
979
+ lastRunAt: null | number;
980
+ lastRunKey: null | string;
981
+ nextRunAt: null | number;
982
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
983
+ schedule:
984
+ | { kind: "manual" }
985
+ | { kind: "daily"; time: string }
986
+ | { kind: "weekly"; time: string; weekday: number }
987
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
988
+ sourceTemplateId: null | string;
989
+ text: string;
990
+ timezone: string;
991
+ title: string;
992
+ updatedAt: number;
993
+ }>,
994
+ Name
995
+ >;
996
+ listPushTemplatesByCompany: FunctionReference<
997
+ "query",
998
+ "internal",
999
+ { companyId: string; includeDisabled?: boolean },
1000
+ Array<{
1001
+ _id: string;
1002
+ companyId: string;
1003
+ createdAt: number;
1004
+ createdBy: string;
1005
+ enabled: boolean;
1006
+ periodicity: "manual" | "daily" | "weekly" | "monthly";
1007
+ suggestedTimes: Array<
1008
+ | { kind: "daily"; time: string }
1009
+ | { kind: "weekly"; time: string; weekday: number }
1010
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
1011
+ >;
1012
+ templateKey: string;
1013
+ text: string;
1014
+ title: string;
1015
+ updatedAt: number;
1016
+ updatedBy: string;
1017
+ }>,
1018
+ Name
1019
+ >;
1020
+ sendBroadcastToAllActiveAgents: FunctionReference<
1021
+ "mutation",
1022
+ "internal",
1023
+ {
1024
+ companyId: string;
1025
+ nowMs?: number;
1026
+ requestedBy: string;
1027
+ text: string;
1028
+ title: string;
1029
+ },
1030
+ {
1031
+ broadcastId: string;
1032
+ enqueued: number;
1033
+ failed: number;
1034
+ totalTargets: number;
1035
+ },
1036
+ Name
1037
+ >;
1038
+ setPushJobEnabled: FunctionReference<
1039
+ "mutation",
1040
+ "internal",
1041
+ { enabled: boolean; jobId: string; nowMs?: number },
1042
+ boolean,
1043
+ Name
1044
+ >;
1045
+ triggerPushJobNow: FunctionReference<
1046
+ "mutation",
1047
+ "internal",
1048
+ { jobId: string; nowMs?: number },
1049
+ { enqueuedMessageId: string; runKey: string },
1050
+ Name
1051
+ >;
1052
+ updatePushJob: FunctionReference<
1053
+ "mutation",
1054
+ "internal",
1055
+ {
1056
+ enabled?: boolean;
1057
+ jobId: string;
1058
+ nowMs?: number;
1059
+ periodicity?: "manual" | "daily" | "weekly" | "monthly";
1060
+ schedule?:
1061
+ | { kind: "manual" }
1062
+ | { kind: "daily"; time: string }
1063
+ | { kind: "weekly"; time: string; weekday: number }
1064
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string };
1065
+ text?: string;
1066
+ timezone?: string;
1067
+ title?: string;
1068
+ },
1069
+ boolean,
1070
+ Name
1071
+ >;
1072
+ updatePushTemplate: FunctionReference<
1073
+ "mutation",
1074
+ "internal",
1075
+ {
1076
+ actorUserId: string;
1077
+ enabled?: boolean;
1078
+ nowMs?: number;
1079
+ periodicity?: "manual" | "daily" | "weekly" | "monthly";
1080
+ suggestedTimes?: Array<
1081
+ | { kind: "daily"; time: string }
1082
+ | { kind: "weekly"; time: string; weekday: number }
1083
+ | { dayOfMonth: number | "last"; kind: "monthly"; time: string }
1084
+ >;
1085
+ templateId: string;
1086
+ text?: string;
1087
+ title?: string;
1088
+ },
1089
+ boolean,
1090
+ Name
1091
+ >;
1092
+ };
648
1093
  queue: {
649
1094
  appendConversationMessages: FunctionReference<
650
1095
  "mutation",
@@ -806,6 +1251,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
806
1251
  null | {
807
1252
  agentKey: string;
808
1253
  bridgeRuntimeConfig: null | {
1254
+ appBaseUrlMapJson: null | string;
809
1255
  appKey: null | string;
810
1256
  baseUrl: null | string;
811
1257
  serviceId: null | string;
@@ -984,6 +1430,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
984
1430
  {
985
1431
  agentKey: string;
986
1432
  bridgeConfig?: {
1433
+ appBaseUrlMapJsonSecretRef?: string;
987
1434
  appKey?: string;
988
1435
  baseUrl?: string;
989
1436
  enabled: boolean;
@@ -992,6 +1439,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
992
1439
  };
993
1440
  clientMd?: string;
994
1441
  enabled: boolean;
1442
+ providerUserId?: string;
995
1443
  secretsRef: Array<string>;
996
1444
  skills: Array<string>;
997
1445
  soulMd: string;
@@ -178,6 +178,10 @@ describe("component lib", () => {
178
178
  secretRef: "agent-bridge.serviceKey.bridge-agent",
179
179
  plaintextValue: "abs_live_bridge_key",
180
180
  });
181
+ await t.mutation(api.queue.importPlaintextSecret, {
182
+ secretRef: "agent-bridge.baseUrlMapJson.bridge-agent",
183
+ plaintextValue: '{"crm":"https://consumer.example.com","billing":"https://billing.example.com"}',
184
+ });
181
185
 
182
186
  const messageId = await t.mutation(api.lib.enqueue, {
183
187
  conversationId: "bridge:chat:1",
@@ -200,6 +204,7 @@ describe("component lib", () => {
200
204
  expect(bundle).not.toBeNull();
201
205
  expect(bundle?.bridgeRuntimeConfig).toEqual({
202
206
  baseUrl: "https://consumer.example.com",
207
+ appBaseUrlMapJson: '{"crm":"https://consumer.example.com","billing":"https://billing.example.com"}',
203
208
  serviceId: "openclaw-prod",
204
209
  appKey: "crm",
205
210
  serviceKey: "abs_live_bridge_key",
@@ -451,4 +456,102 @@ describe("component lib", () => {
451
456
  expect(reconcile.spawned).toBe(0);
452
457
  expect(reconcile.terminated).toBe(0);
453
458
  });
459
+
460
+ test("push jobs should dispatch scheduled messages and log runs", async () => {
461
+ const t = initConvexTest();
462
+ await t.mutation(api.queue.upsertAgentProfile, {
463
+ agentKey: "push-agent",
464
+ version: "1.0.0",
465
+ soulMd: "# Soul",
466
+ clientMd: "# Client",
467
+ skills: [],
468
+ secretsRef: [],
469
+ enabled: true,
470
+ });
471
+ await t.mutation(api.lib.bindUserAgent, {
472
+ consumerUserId: "user-push-1",
473
+ agentKey: "push-agent",
474
+ source: "manual",
475
+ metadata: { companyId: "co-1" },
476
+ });
477
+
478
+ const baseMs = Date.UTC(2026, 0, 1, 7, 59, 0);
479
+ const jobId = await t.mutation((api.lib as any).createPushJobCustom, {
480
+ companyId: "co-1",
481
+ consumerUserId: "user-push-1",
482
+ title: "Daily check",
483
+ text: "Ping automatico",
484
+ periodicity: "daily",
485
+ timezone: "UTC",
486
+ schedule: {
487
+ kind: "daily",
488
+ time: "08:00",
489
+ },
490
+ nowMs: baseMs,
491
+ });
492
+
493
+ const dispatch = await t.mutation((api.lib as any).dispatchDuePushJobs, {
494
+ nowMs: baseMs + 6 * 60_000,
495
+ limit: 50,
496
+ });
497
+ expect(dispatch.enqueued).toBe(1);
498
+ expect(dispatch.failed).toBe(0);
499
+
500
+ const queueStats = await t.query(api.lib.queueStats, {});
501
+ expect(queueStats.queuedReady).toBe(1);
502
+
503
+ const jobDispatches = await t.query((api.lib as any).listPushDispatchesByJob, {
504
+ jobId,
505
+ limit: 10,
506
+ });
507
+ expect(jobDispatches.length).toBe(1);
508
+ expect(jobDispatches[0].status).toBe("enqueued");
509
+ });
510
+
511
+ test("admin broadcast should enqueue to all active company agents", async () => {
512
+ const t = initConvexTest();
513
+ await t.mutation(api.queue.upsertAgentProfile, {
514
+ agentKey: "broadcast-agent-a",
515
+ version: "1.0.0",
516
+ soulMd: "# Soul",
517
+ clientMd: "# Client",
518
+ skills: [],
519
+ secretsRef: [],
520
+ enabled: true,
521
+ });
522
+ await t.mutation(api.queue.upsertAgentProfile, {
523
+ agentKey: "broadcast-agent-b",
524
+ version: "1.0.0",
525
+ soulMd: "# Soul",
526
+ clientMd: "# Client",
527
+ skills: [],
528
+ secretsRef: [],
529
+ enabled: true,
530
+ });
531
+ await t.mutation(api.lib.bindUserAgent, {
532
+ consumerUserId: "company-user-a",
533
+ agentKey: "broadcast-agent-a",
534
+ source: "manual",
535
+ metadata: { companyId: "company-broadcast" },
536
+ });
537
+ await t.mutation(api.lib.bindUserAgent, {
538
+ consumerUserId: "company-user-b",
539
+ agentKey: "broadcast-agent-b",
540
+ source: "manual",
541
+ metadata: { companyId: "company-broadcast" },
542
+ });
543
+
544
+ const result = await t.mutation((api.lib as any).sendBroadcastToAllActiveAgents, {
545
+ companyId: "company-broadcast",
546
+ title: "Aggiornamento policy",
547
+ text: "Sincronizza le nuove istruzioni",
548
+ requestedBy: "admin-1",
549
+ });
550
+ expect(result.totalTargets).toBe(2);
551
+ expect(result.enqueued).toBe(2);
552
+ expect(result.failed).toBe(0);
553
+
554
+ const queueStats = await t.query(api.lib.queueStats, {});
555
+ expect(queueStats.queuedReady).toBe(2);
556
+ });
454
557
  });
@@ -34,3 +34,20 @@ export {
34
34
  consumePairingCode,
35
35
  getPairingCodeStatus,
36
36
  } from "./identity.js";
37
+
38
+ export {
39
+ createPushTemplate,
40
+ updatePushTemplate,
41
+ deletePushTemplate,
42
+ listPushTemplatesByCompany,
43
+ createPushJobFromTemplate,
44
+ createPushJobCustom,
45
+ updatePushJob,
46
+ deletePushJob,
47
+ setPushJobEnabled,
48
+ listPushJobsForUser,
49
+ triggerPushJobNow,
50
+ dispatchDuePushJobs,
51
+ sendBroadcastToAllActiveAgents,
52
+ listPushDispatchesByJob,
53
+ } from "./pushing.js";