@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.
Files changed (37) hide show
  1. package/README.md +32 -0
  2. package/dist/client/index.d.ts +145 -3
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +192 -0
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/component/_generated/api.d.ts +2 -0
  7. package/dist/component/_generated/api.d.ts.map +1 -1
  8. package/dist/component/_generated/api.js.map +1 -1
  9. package/dist/component/_generated/component.d.ts +456 -4
  10. package/dist/component/_generated/component.d.ts.map +1 -1
  11. package/dist/component/lib.d.ts +1 -0
  12. package/dist/component/lib.d.ts.map +1 -1
  13. package/dist/component/lib.js +1 -0
  14. package/dist/component/lib.js.map +1 -1
  15. package/dist/component/pushing.d.ts +226 -0
  16. package/dist/component/pushing.d.ts.map +1 -0
  17. package/dist/component/pushing.js +954 -0
  18. package/dist/component/pushing.js.map +1 -0
  19. package/dist/component/queue.d.ts +8 -7
  20. package/dist/component/queue.d.ts.map +1 -1
  21. package/dist/component/queue.js +20 -1
  22. package/dist/component/queue.js.map +1 -1
  23. package/dist/component/scheduler.d.ts +5 -5
  24. package/dist/component/schema.d.ts +258 -8
  25. package/dist/component/schema.d.ts.map +1 -1
  26. package/dist/component/schema.js +103 -0
  27. package/dist/component/schema.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/client/index.test.ts +29 -19
  30. package/src/client/index.ts +209 -0
  31. package/src/component/_generated/api.ts +2 -0
  32. package/src/component/_generated/component.ts +448 -4
  33. package/src/component/lib.test.ts +98 -0
  34. package/src/component/lib.ts +17 -0
  35. package/src/component/pushing.ts +1111 -0
  36. package/src/component/queue.ts +27 -1
  37. package/src/component/schema.ts +137 -0
@@ -12,6 +12,50 @@ import {
12
12
  scalingPolicyValidator,
13
13
  type ProviderConfig,
14
14
  } from "../component/config.js";
15
+
16
+ const pushPeriodicityValidator = v.union(
17
+ v.literal("manual"),
18
+ v.literal("daily"),
19
+ v.literal("weekly"),
20
+ v.literal("monthly"),
21
+ );
22
+
23
+ const pushSuggestedTimeValidator = v.union(
24
+ v.object({
25
+ kind: v.literal("daily"),
26
+ time: v.string(),
27
+ }),
28
+ v.object({
29
+ kind: v.literal("weekly"),
30
+ weekday: v.number(),
31
+ time: v.string(),
32
+ }),
33
+ v.object({
34
+ kind: v.literal("monthly"),
35
+ dayOfMonth: v.union(v.number(), v.literal("last")),
36
+ time: v.string(),
37
+ }),
38
+ );
39
+
40
+ const pushScheduleValidator = v.union(
41
+ v.object({
42
+ kind: v.literal("manual"),
43
+ }),
44
+ v.object({
45
+ kind: v.literal("daily"),
46
+ time: v.string(),
47
+ }),
48
+ v.object({
49
+ kind: v.literal("weekly"),
50
+ weekday: v.number(),
51
+ time: v.string(),
52
+ }),
53
+ v.object({
54
+ kind: v.literal("monthly"),
55
+ dayOfMonth: v.union(v.number(), v.literal("last")),
56
+ time: v.string(),
57
+ }),
58
+ );
15
59
  export {
16
60
  bridgeFunctionKeyFromToolName,
17
61
  executeBridgeFunction,
@@ -463,6 +507,171 @@ export function exposeApi(
463
507
  return await ctx.runAction(component.lib.configureTelegramWebhook, args);
464
508
  },
465
509
  }),
510
+ createPushTemplate: mutationGeneric({
511
+ args: {
512
+ companyId: v.string(),
513
+ templateKey: v.string(),
514
+ title: v.string(),
515
+ text: v.string(),
516
+ periodicity: pushPeriodicityValidator,
517
+ suggestedTimes: v.array(pushSuggestedTimeValidator),
518
+ enabled: v.optional(v.boolean()),
519
+ actorUserId: v.string(),
520
+ },
521
+ handler: async (ctx, args) => {
522
+ await options.auth(ctx, { type: "write" });
523
+ return await ctx.runMutation((component.lib as any).createPushTemplate, args);
524
+ },
525
+ }),
526
+ updatePushTemplate: mutationGeneric({
527
+ args: {
528
+ templateId: v.string(),
529
+ title: v.optional(v.string()),
530
+ text: v.optional(v.string()),
531
+ periodicity: v.optional(pushPeriodicityValidator),
532
+ suggestedTimes: v.optional(v.array(pushSuggestedTimeValidator)),
533
+ enabled: v.optional(v.boolean()),
534
+ actorUserId: v.string(),
535
+ },
536
+ handler: async (ctx, args) => {
537
+ await options.auth(ctx, { type: "write" });
538
+ return await ctx.runMutation((component.lib as any).updatePushTemplate, args);
539
+ },
540
+ }),
541
+ deletePushTemplate: mutationGeneric({
542
+ args: {
543
+ templateId: v.string(),
544
+ },
545
+ handler: async (ctx, args) => {
546
+ await options.auth(ctx, { type: "write" });
547
+ return await ctx.runMutation((component.lib as any).deletePushTemplate, args);
548
+ },
549
+ }),
550
+ listPushTemplatesByCompany: queryGeneric({
551
+ args: {
552
+ companyId: v.string(),
553
+ includeDisabled: v.optional(v.boolean()),
554
+ },
555
+ handler: async (ctx, args) => {
556
+ await options.auth(ctx, { type: "read" });
557
+ return await ctx.runQuery((component.lib as any).listPushTemplatesByCompany, args);
558
+ },
559
+ }),
560
+ createPushJobFromTemplate: mutationGeneric({
561
+ args: {
562
+ companyId: v.string(),
563
+ consumerUserId: v.string(),
564
+ templateId: v.string(),
565
+ timezone: v.string(),
566
+ schedule: v.optional(pushScheduleValidator),
567
+ enabled: v.optional(v.boolean()),
568
+ },
569
+ handler: async (ctx, args) => {
570
+ await options.auth(ctx, { type: "write" });
571
+ return await ctx.runMutation((component.lib as any).createPushJobFromTemplate, args);
572
+ },
573
+ }),
574
+ createPushJobCustom: mutationGeneric({
575
+ args: {
576
+ companyId: v.string(),
577
+ consumerUserId: v.string(),
578
+ title: v.string(),
579
+ text: v.string(),
580
+ periodicity: pushPeriodicityValidator,
581
+ timezone: v.string(),
582
+ schedule: pushScheduleValidator,
583
+ enabled: v.optional(v.boolean()),
584
+ },
585
+ handler: async (ctx, args) => {
586
+ await options.auth(ctx, { type: "write" });
587
+ return await ctx.runMutation((component.lib as any).createPushJobCustom, args);
588
+ },
589
+ }),
590
+ updatePushJob: mutationGeneric({
591
+ args: {
592
+ jobId: v.string(),
593
+ title: v.optional(v.string()),
594
+ text: v.optional(v.string()),
595
+ periodicity: v.optional(pushPeriodicityValidator),
596
+ timezone: v.optional(v.string()),
597
+ schedule: v.optional(pushScheduleValidator),
598
+ enabled: v.optional(v.boolean()),
599
+ },
600
+ handler: async (ctx, args) => {
601
+ await options.auth(ctx, { type: "write" });
602
+ return await ctx.runMutation((component.lib as any).updatePushJob, args);
603
+ },
604
+ }),
605
+ deletePushJob: mutationGeneric({
606
+ args: {
607
+ jobId: v.string(),
608
+ },
609
+ handler: async (ctx, args) => {
610
+ await options.auth(ctx, { type: "write" });
611
+ return await ctx.runMutation((component.lib as any).deletePushJob, args);
612
+ },
613
+ }),
614
+ setPushJobEnabled: mutationGeneric({
615
+ args: {
616
+ jobId: v.string(),
617
+ enabled: v.boolean(),
618
+ },
619
+ handler: async (ctx, args) => {
620
+ await options.auth(ctx, { type: "write" });
621
+ return await ctx.runMutation((component.lib as any).setPushJobEnabled, args);
622
+ },
623
+ }),
624
+ listPushJobsForUser: queryGeneric({
625
+ args: {
626
+ consumerUserId: v.string(),
627
+ includeDisabled: v.optional(v.boolean()),
628
+ },
629
+ handler: async (ctx, args) => {
630
+ await options.auth(ctx, { type: "read" });
631
+ return await ctx.runQuery((component.lib as any).listPushJobsForUser, args);
632
+ },
633
+ }),
634
+ triggerPushJobNow: mutationGeneric({
635
+ args: {
636
+ jobId: v.string(),
637
+ },
638
+ handler: async (ctx, args) => {
639
+ await options.auth(ctx, { type: "write" });
640
+ return await ctx.runMutation((component.lib as any).triggerPushJobNow, args);
641
+ },
642
+ }),
643
+ dispatchDuePushJobs: mutationGeneric({
644
+ args: {
645
+ nowMs: v.optional(v.number()),
646
+ limit: v.optional(v.number()),
647
+ },
648
+ handler: async (ctx, args) => {
649
+ await options.auth(ctx, { type: "write" });
650
+ return await ctx.runMutation((component.lib as any).dispatchDuePushJobs, args);
651
+ },
652
+ }),
653
+ sendBroadcastToAllActiveAgents: mutationGeneric({
654
+ args: {
655
+ companyId: v.string(),
656
+ title: v.string(),
657
+ text: v.string(),
658
+ requestedBy: v.string(),
659
+ },
660
+ handler: async (ctx, args) => {
661
+ await options.auth(ctx, { type: "write" });
662
+ return await ctx.runMutation((component.lib as any).sendBroadcastToAllActiveAgents, args);
663
+ },
664
+ }),
665
+ listPushDispatchesByJob: queryGeneric({
666
+ args: {
667
+ jobId: v.string(),
668
+ limit: v.optional(v.number()),
669
+ },
670
+ handler: async (ctx, args) => {
671
+ await options.auth(ctx, { type: "read" });
672
+ return await ctx.runQuery((component.lib as any).listPushDispatchesByJob, args);
673
+ },
674
+ }),
466
675
  };
467
676
  }
468
677
 
@@ -12,6 +12,7 @@ import type * as config from "../config.js";
12
12
  import type * as identity from "../identity.js";
13
13
  import type * as lib from "../lib.js";
14
14
  import type * as providers_fly from "../providers/fly.js";
15
+ import type * as pushing from "../pushing.js";
15
16
  import type * as queue from "../queue.js";
16
17
  import type * as scheduler from "../scheduler.js";
17
18
 
@@ -27,6 +28,7 @@ const fullApi: ApiFromModules<{
27
28
  identity: typeof identity;
28
29
  lib: typeof lib;
29
30
  "providers/fly": typeof providers_fly;
31
+ pushing: typeof pushing;
30
32
  queue: typeof queue;
31
33
  scheduler: typeof scheduler;
32
34
  }> = anyApi as any;