@kubun/plugin-p2p 0.15.1 → 0.16.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.
@@ -508,9 +508,404 @@ export declare const peerProtocol: {
508
508
  };
509
509
  };
510
510
  };
511
+ /**
512
+ * Workflow plane: remote observation of a device's durable workflow instances.
513
+ * Mounted only when this device runs the workflow plugin (see the manager's
514
+ * conditional composition) — absent it, no `workflow` topic exists and a gather
515
+ * on this lane routes to nothing.
516
+ *
517
+ * ATTRIBUTION IS THE LANE'S, NOT THE BODY'S, as on the peer plane: the reply is a
518
+ * bare `InstanceStatus[]` and the gather envelope supplies the responder's
519
+ * authenticated `senderDID`, so the body names no device.
520
+ */
521
+ export declare const workflowProtocol: {
522
+ readonly 'workflow/discover': {
523
+ readonly type: "request";
524
+ readonly retain: "ephemeral";
525
+ readonly description: "Ask co-members which of their workflow instances are remotely observable. Gathered: each device replies with only its own remote.observe instances.";
526
+ readonly param: {
527
+ readonly type: "object";
528
+ readonly properties: {};
529
+ readonly additionalProperties: false;
530
+ };
531
+ readonly result: {
532
+ readonly type: "array";
533
+ readonly items: {
534
+ readonly type: "object";
535
+ readonly properties: {
536
+ readonly instanceID: {
537
+ readonly type: "string";
538
+ };
539
+ readonly name: {
540
+ readonly type: "string";
541
+ };
542
+ readonly queue: {
543
+ readonly type: "string";
544
+ };
545
+ readonly status: {
546
+ readonly type: "string";
547
+ };
548
+ readonly attempts: {
549
+ readonly type: "number";
550
+ };
551
+ readonly lastError: {
552
+ readonly type: readonly ["string", "null"];
553
+ };
554
+ readonly createdAt: {
555
+ readonly type: "number";
556
+ };
557
+ readonly updatedAt: {
558
+ readonly type: "number";
559
+ };
560
+ };
561
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
562
+ readonly additionalProperties: false;
563
+ };
564
+ };
565
+ };
566
+ readonly 'workflow/list': {
567
+ readonly type: "request";
568
+ readonly retain: "ephemeral";
569
+ readonly description: "Ask one peer (directed) for its remotely-observable workflow instances. The peer replies with only its own remote.observe instances.";
570
+ readonly param: {
571
+ readonly type: "object";
572
+ readonly properties: {};
573
+ readonly additionalProperties: false;
574
+ };
575
+ readonly result: {
576
+ readonly type: "array";
577
+ readonly items: {
578
+ readonly type: "object";
579
+ readonly properties: {
580
+ readonly instanceID: {
581
+ readonly type: "string";
582
+ };
583
+ readonly name: {
584
+ readonly type: "string";
585
+ };
586
+ readonly queue: {
587
+ readonly type: "string";
588
+ };
589
+ readonly status: {
590
+ readonly type: "string";
591
+ };
592
+ readonly attempts: {
593
+ readonly type: "number";
594
+ };
595
+ readonly lastError: {
596
+ readonly type: readonly ["string", "null"];
597
+ };
598
+ readonly createdAt: {
599
+ readonly type: "number";
600
+ };
601
+ readonly updatedAt: {
602
+ readonly type: "number";
603
+ };
604
+ };
605
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
606
+ readonly additionalProperties: false;
607
+ };
608
+ };
609
+ };
610
+ readonly 'workflow/status': {
611
+ readonly type: "request";
612
+ readonly retain: "ephemeral";
613
+ readonly description: "Ask one peer (directed) for one instance status by id. A non-observable instance is refused identically to an unknown one, so the reply never reveals that a hidden instance exists.";
614
+ readonly param: {
615
+ readonly type: "object";
616
+ readonly properties: {
617
+ readonly instanceID: {
618
+ readonly type: "string";
619
+ };
620
+ };
621
+ readonly required: readonly ["instanceID"];
622
+ readonly additionalProperties: false;
623
+ };
624
+ readonly result: {
625
+ readonly type: "object";
626
+ readonly properties: {
627
+ readonly instanceID: {
628
+ readonly type: "string";
629
+ };
630
+ readonly name: {
631
+ readonly type: "string";
632
+ };
633
+ readonly queue: {
634
+ readonly type: "string";
635
+ };
636
+ readonly status: {
637
+ readonly type: "string";
638
+ };
639
+ readonly attempts: {
640
+ readonly type: "number";
641
+ };
642
+ readonly lastError: {
643
+ readonly type: readonly ["string", "null"];
644
+ };
645
+ readonly createdAt: {
646
+ readonly type: "number";
647
+ };
648
+ readonly updatedAt: {
649
+ readonly type: "number";
650
+ };
651
+ };
652
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
653
+ readonly additionalProperties: false;
654
+ };
655
+ };
656
+ readonly 'workflow/enqueue': {
657
+ readonly type: "request";
658
+ readonly retain: "ephemeral";
659
+ readonly description: "Ask one peer (directed) to enqueue a named workflow. Directed addressing means exactly one device runs it — no double-execution. A workflow that did not opt into remote command is refused with `not_commandable`; success returns the new instance status.";
660
+ readonly param: {
661
+ readonly type: "object";
662
+ readonly properties: {
663
+ readonly name: {
664
+ readonly type: "string";
665
+ };
666
+ readonly params: {};
667
+ readonly opts: {
668
+ readonly type: "object";
669
+ readonly properties: {
670
+ readonly queue: {
671
+ readonly type: "string";
672
+ };
673
+ readonly priority: {
674
+ readonly type: "number";
675
+ };
676
+ readonly idempotencyKey: {
677
+ readonly type: "string";
678
+ };
679
+ readonly singletonKey: {
680
+ readonly type: "string";
681
+ };
682
+ };
683
+ readonly additionalProperties: false;
684
+ };
685
+ };
686
+ readonly required: readonly ["name"];
687
+ readonly additionalProperties: false;
688
+ };
689
+ readonly result: {
690
+ readonly anyOf: [{
691
+ readonly type: "object";
692
+ readonly properties: {
693
+ readonly ok: {
694
+ readonly type: "boolean";
695
+ readonly const: true;
696
+ };
697
+ readonly status: {
698
+ readonly type: "object";
699
+ readonly properties: {
700
+ readonly instanceID: {
701
+ readonly type: "string";
702
+ };
703
+ readonly name: {
704
+ readonly type: "string";
705
+ };
706
+ readonly queue: {
707
+ readonly type: "string";
708
+ };
709
+ readonly status: {
710
+ readonly type: "string";
711
+ };
712
+ readonly attempts: {
713
+ readonly type: "number";
714
+ };
715
+ readonly lastError: {
716
+ readonly type: readonly ["string", "null"];
717
+ };
718
+ readonly createdAt: {
719
+ readonly type: "number";
720
+ };
721
+ readonly updatedAt: {
722
+ readonly type: "number";
723
+ };
724
+ };
725
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
726
+ readonly additionalProperties: false;
727
+ };
728
+ };
729
+ readonly required: readonly ["ok", "status"];
730
+ readonly additionalProperties: false;
731
+ }, {
732
+ readonly type: "object";
733
+ readonly properties: {
734
+ readonly ok: {
735
+ readonly type: "boolean";
736
+ readonly const: false;
737
+ };
738
+ readonly reason: {
739
+ readonly type: "string";
740
+ readonly enum: readonly ["not_commandable", "not_found", "not_failed", "no_next_action", "singleton"];
741
+ };
742
+ };
743
+ readonly required: readonly ["ok", "reason"];
744
+ readonly additionalProperties: false;
745
+ }];
746
+ };
747
+ };
748
+ readonly 'workflow/cancel': {
749
+ readonly type: "request";
750
+ readonly retain: "ephemeral";
751
+ readonly description: "Ask one peer (directed) to cancel one instance by id. A non-commandable instance is refused identically to an unknown one (`not_found`), so the reply never reveals that a hidden instance exists.";
752
+ readonly param: {
753
+ readonly type: "object";
754
+ readonly properties: {
755
+ readonly instanceID: {
756
+ readonly type: "string";
757
+ };
758
+ };
759
+ readonly required: readonly ["instanceID"];
760
+ readonly additionalProperties: false;
761
+ };
762
+ readonly result: {
763
+ readonly anyOf: [{
764
+ readonly type: "object";
765
+ readonly properties: {
766
+ readonly ok: {
767
+ readonly type: "boolean";
768
+ readonly const: true;
769
+ };
770
+ readonly status: {
771
+ readonly type: "object";
772
+ readonly properties: {
773
+ readonly instanceID: {
774
+ readonly type: "string";
775
+ };
776
+ readonly name: {
777
+ readonly type: "string";
778
+ };
779
+ readonly queue: {
780
+ readonly type: "string";
781
+ };
782
+ readonly status: {
783
+ readonly type: "string";
784
+ };
785
+ readonly attempts: {
786
+ readonly type: "number";
787
+ };
788
+ readonly lastError: {
789
+ readonly type: readonly ["string", "null"];
790
+ };
791
+ readonly createdAt: {
792
+ readonly type: "number";
793
+ };
794
+ readonly updatedAt: {
795
+ readonly type: "number";
796
+ };
797
+ };
798
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
799
+ readonly additionalProperties: false;
800
+ };
801
+ };
802
+ readonly required: readonly ["ok", "status"];
803
+ readonly additionalProperties: false;
804
+ }, {
805
+ readonly type: "object";
806
+ readonly properties: {
807
+ readonly ok: {
808
+ readonly type: "boolean";
809
+ readonly const: false;
810
+ };
811
+ readonly reason: {
812
+ readonly type: "string";
813
+ readonly enum: readonly ["not_commandable", "not_found", "not_failed", "no_next_action", "singleton"];
814
+ };
815
+ };
816
+ readonly required: readonly ["ok", "reason"];
817
+ readonly additionalProperties: false;
818
+ }];
819
+ };
820
+ };
821
+ readonly 'workflow/retry': {
822
+ readonly type: "request";
823
+ readonly retain: "ephemeral";
824
+ readonly description: "Ask one peer (directed) to re-arm one failed instance by id. A non-commandable instance is refused identically to an unknown one (`not_found`); the engine's own retry refusals (`not_failed`/`no_next_action`/`singleton`) map through verbatim.";
825
+ readonly param: {
826
+ readonly type: "object";
827
+ readonly properties: {
828
+ readonly instanceID: {
829
+ readonly type: "string";
830
+ };
831
+ };
832
+ readonly required: readonly ["instanceID"];
833
+ readonly additionalProperties: false;
834
+ };
835
+ readonly result: {
836
+ readonly anyOf: [{
837
+ readonly type: "object";
838
+ readonly properties: {
839
+ readonly ok: {
840
+ readonly type: "boolean";
841
+ readonly const: true;
842
+ };
843
+ readonly status: {
844
+ readonly type: "object";
845
+ readonly properties: {
846
+ readonly instanceID: {
847
+ readonly type: "string";
848
+ };
849
+ readonly name: {
850
+ readonly type: "string";
851
+ };
852
+ readonly queue: {
853
+ readonly type: "string";
854
+ };
855
+ readonly status: {
856
+ readonly type: "string";
857
+ };
858
+ readonly attempts: {
859
+ readonly type: "number";
860
+ };
861
+ readonly lastError: {
862
+ readonly type: readonly ["string", "null"];
863
+ };
864
+ readonly createdAt: {
865
+ readonly type: "number";
866
+ };
867
+ readonly updatedAt: {
868
+ readonly type: "number";
869
+ };
870
+ };
871
+ readonly required: readonly ["instanceID", "name", "queue", "status", "attempts", "lastError", "createdAt", "updatedAt"];
872
+ readonly additionalProperties: false;
873
+ };
874
+ };
875
+ readonly required: readonly ["ok", "status"];
876
+ readonly additionalProperties: false;
877
+ }, {
878
+ readonly type: "object";
879
+ readonly properties: {
880
+ readonly ok: {
881
+ readonly type: "boolean";
882
+ readonly const: false;
883
+ };
884
+ readonly reason: {
885
+ readonly type: "string";
886
+ readonly enum: readonly ["not_commandable", "not_found", "not_failed", "no_next_action", "singleton"];
887
+ };
888
+ };
889
+ readonly required: readonly ["ok", "reason"];
890
+ readonly additionalProperties: false;
891
+ }];
892
+ };
893
+ };
894
+ };
511
895
  export type ControlProtocol = typeof controlProtocol;
512
896
  export type SyncProtocol = typeof syncProtocol;
513
897
  export type PeerProtocol = typeof peerProtocol;
898
+ export type WorkflowProtocol = typeof workflowProtocol;
899
+ /**
900
+ * A directed command's wire result: `{ ok:true, status }` on success or
901
+ * `{ ok:false, reason }` on a business refusal. Derived from the enqueue result
902
+ * schema — the three commands share one shape.
903
+ */
904
+ export type WorkflowCommandResult = FromSchema<(typeof workflowProtocol)['workflow/enqueue']['result']>;
905
+ /** The machine reason a refused command carries. */
906
+ export type WorkflowCommandRefusalReason = Extract<WorkflowCommandResult, {
907
+ ok: false;
908
+ }>['reason'];
514
909
  export type LedgerCatchupResult = FromSchema<(typeof controlProtocol)['control/ledgerCatchup']['result']>;
515
910
  export type DelegationShareData = FromSchema<(typeof controlProtocol)['control/delegationShare']['data']>;
516
911
  export type DelegationRevokeData = FromSchema<(typeof controlProtocol)['control/delegationRevoke']['data']>;
@@ -1026,3 +1421,15 @@ export declare const groupProtocols: {
1026
1421
  };
1027
1422
  };
1028
1423
  export type GroupProtocols = typeof groupProtocols;
1424
+ /**
1425
+ * The group protocols with the `workflow` lane conditionally mounted. A FRESH
1426
+ * object each call — the shared static {@link groupProtocols} is never mutated.
1427
+ * When `hasWorkflow` is false the base map is returned unchanged, so no
1428
+ * `workflow` key exists and a gather on that lane routes to nothing.
1429
+ *
1430
+ * The workflow lane is an extra runtime key served by `createGroupPeer`
1431
+ * (`Object.entries(protocols)`), but callers stay typed at the base shape: the
1432
+ * manager never statically routes `workflow`, and the peer it holds keeps its
1433
+ * base type. The paired handler is composed by `composeGroupHandlers`.
1434
+ */
1435
+ export declare function composeGroupProtocols(hasWorkflow: boolean): GroupProtocols;