@okrlinkhub/agent-factory 0.2.4 → 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.
- package/README.md +32 -0
- package/dist/client/index.d.ts +145 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +192 -0
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +456 -4
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/lib.d.ts +1 -0
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +1 -0
- package/dist/component/lib.js.map +1 -1
- package/dist/component/pushing.d.ts +226 -0
- package/dist/component/pushing.d.ts.map +1 -0
- package/dist/component/pushing.js +954 -0
- package/dist/component/pushing.js.map +1 -0
- package/dist/component/queue.d.ts +8 -7
- package/dist/component/queue.d.ts.map +1 -1
- package/dist/component/queue.js +20 -1
- package/dist/component/queue.js.map +1 -1
- package/dist/component/scheduler.d.ts +5 -5
- package/dist/component/schema.d.ts +258 -8
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +103 -0
- package/dist/component/schema.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.test.ts +29 -19
- package/src/client/index.ts +209 -0
- package/src/component/_generated/api.ts +2 -0
- package/src/component/_generated/component.ts +448 -4
- package/src/component/lib.test.ts +98 -0
- package/src/component/lib.ts +17 -0
- package/src/component/pushing.ts +1111 -0
- package/src/component/queue.ts +27 -1
- package/src/component/schema.ts +137 -0
|
@@ -288,15 +288,16 @@ 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;
|
|
294
|
-
appBaseUrlMapJsonSecretRef?: string;
|
|
295
295
|
serviceId?: string;
|
|
296
296
|
serviceKeySecretRef?: string;
|
|
297
297
|
};
|
|
298
298
|
clientMd?: string;
|
|
299
299
|
enabled: boolean;
|
|
300
|
+
providerUserId?: string;
|
|
300
301
|
secretsRef: Array<string>;
|
|
301
302
|
skills: Array<string>;
|
|
302
303
|
soulMd: string;
|
|
@@ -365,6 +366,67 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
365
366
|
},
|
|
366
367
|
Name
|
|
367
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
|
+
>;
|
|
368
430
|
deleteFlyVolume: FunctionReference<
|
|
369
431
|
"action",
|
|
370
432
|
"internal",
|
|
@@ -372,6 +434,27 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
372
434
|
{ message: string; ok: boolean; status: number },
|
|
373
435
|
Name
|
|
374
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
|
+
>;
|
|
375
458
|
enqueue: FunctionReference<
|
|
376
459
|
"mutation",
|
|
377
460
|
"internal",
|
|
@@ -445,9 +528,9 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
445
528
|
null | {
|
|
446
529
|
agentKey: string;
|
|
447
530
|
bridgeRuntimeConfig: null | {
|
|
531
|
+
appBaseUrlMapJson: null | string;
|
|
448
532
|
appKey: null | string;
|
|
449
533
|
baseUrl: null | string;
|
|
450
|
-
appBaseUrlMapJson: null | string;
|
|
451
534
|
serviceId: null | string;
|
|
452
535
|
serviceKey: null | string;
|
|
453
536
|
serviceKeySecretRef: null | string;
|
|
@@ -542,6 +625,72 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
542
625
|
{ secretId: string; secretRef: string; version: number },
|
|
543
626
|
Name
|
|
544
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
|
+
>;
|
|
545
694
|
queueStats: FunctionReference<
|
|
546
695
|
"query",
|
|
547
696
|
"internal",
|
|
@@ -617,6 +766,78 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
617
766
|
}>,
|
|
618
767
|
Name
|
|
619
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
|
+
>;
|
|
620
841
|
workerStats: FunctionReference<
|
|
621
842
|
"query",
|
|
622
843
|
"internal",
|
|
@@ -647,6 +868,228 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
647
868
|
>;
|
|
648
869
|
};
|
|
649
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
|
+
};
|
|
650
1093
|
queue: {
|
|
651
1094
|
appendConversationMessages: FunctionReference<
|
|
652
1095
|
"mutation",
|
|
@@ -808,9 +1251,9 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
808
1251
|
null | {
|
|
809
1252
|
agentKey: string;
|
|
810
1253
|
bridgeRuntimeConfig: null | {
|
|
1254
|
+
appBaseUrlMapJson: null | string;
|
|
811
1255
|
appKey: null | string;
|
|
812
1256
|
baseUrl: null | string;
|
|
813
|
-
appBaseUrlMapJson: null | string;
|
|
814
1257
|
serviceId: null | string;
|
|
815
1258
|
serviceKey: null | string;
|
|
816
1259
|
serviceKeySecretRef: null | string;
|
|
@@ -987,15 +1430,16 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
987
1430
|
{
|
|
988
1431
|
agentKey: string;
|
|
989
1432
|
bridgeConfig?: {
|
|
1433
|
+
appBaseUrlMapJsonSecretRef?: string;
|
|
990
1434
|
appKey?: string;
|
|
991
1435
|
baseUrl?: string;
|
|
992
1436
|
enabled: boolean;
|
|
993
|
-
appBaseUrlMapJsonSecretRef?: string;
|
|
994
1437
|
serviceId?: string;
|
|
995
1438
|
serviceKeySecretRef?: string;
|
|
996
1439
|
};
|
|
997
1440
|
clientMd?: string;
|
|
998
1441
|
enabled: boolean;
|
|
1442
|
+
providerUserId?: string;
|
|
999
1443
|
secretsRef: Array<string>;
|
|
1000
1444
|
skills: Array<string>;
|
|
1001
1445
|
soulMd: string;
|
|
@@ -456,4 +456,102 @@ describe("component lib", () => {
|
|
|
456
456
|
expect(reconcile.spawned).toBe(0);
|
|
457
457
|
expect(reconcile.terminated).toBe(0);
|
|
458
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
|
+
});
|
|
459
557
|
});
|
package/src/component/lib.ts
CHANGED
|
@@ -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";
|