@zgeoff/imp-client 0.7.0 → 0.8.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.
package/dist/index.d.ts CHANGED
@@ -316,6 +316,7 @@ declare const impContract: {
316
316
  imp: "imp";
317
317
  secret: "secret";
318
318
  session: "session";
319
+ "ssh-key": "ssh-key";
319
320
  token: "token";
320
321
  }>;
321
322
  name: z.ZodString;
@@ -332,6 +333,7 @@ declare const impContract: {
332
333
  imp: "imp";
333
334
  secret: "secret";
334
335
  session: "session";
336
+ "ssh-key": "ssh-key";
335
337
  token: "token";
336
338
  }>;
337
339
  name: z.ZodString;
@@ -442,6 +444,7 @@ declare const impContract: {
442
444
  imp: "imp";
443
445
  secret: "secret";
444
446
  session: "session";
447
+ "ssh-key": "ssh-key";
445
448
  token: "token";
446
449
  }>;
447
450
  name: z.ZodString;
@@ -458,6 +461,7 @@ declare const impContract: {
458
461
  imp: "imp";
459
462
  secret: "secret";
460
463
  session: "session";
464
+ "ssh-key": "ssh-key";
461
465
  token: "token";
462
466
  }>;
463
467
  name: z.ZodString;
@@ -570,6 +574,7 @@ declare const impContract: {
570
574
  imp: "imp";
571
575
  secret: "secret";
572
576
  session: "session";
577
+ "ssh-key": "ssh-key";
573
578
  token: "token";
574
579
  }>;
575
580
  name: z.ZodString;
@@ -586,6 +591,7 @@ declare const impContract: {
586
591
  imp: "imp";
587
592
  secret: "secret";
588
593
  session: "session";
594
+ "ssh-key": "ssh-key";
589
595
  token: "token";
590
596
  }>;
591
597
  name: z.ZodString;
@@ -657,6 +663,7 @@ declare const impContract: {
657
663
  imp: "imp";
658
664
  secret: "secret";
659
665
  session: "session";
666
+ "ssh-key": "ssh-key";
660
667
  token: "token";
661
668
  }>;
662
669
  name: z.ZodString;
@@ -673,6 +680,7 @@ declare const impContract: {
673
680
  imp: "imp";
674
681
  secret: "secret";
675
682
  session: "session";
683
+ "ssh-key": "ssh-key";
676
684
  token: "token";
677
685
  }>;
678
686
  name: z.ZodString;
@@ -785,6 +793,7 @@ declare const impContract: {
785
793
  imp: "imp";
786
794
  secret: "secret";
787
795
  session: "session";
796
+ "ssh-key": "ssh-key";
788
797
  token: "token";
789
798
  }>;
790
799
  name: z.ZodString;
@@ -801,6 +810,7 @@ declare const impContract: {
801
810
  imp: "imp";
802
811
  secret: "secret";
803
812
  session: "session";
813
+ "ssh-key": "ssh-key";
804
814
  token: "token";
805
815
  }>;
806
816
  name: z.ZodString;
@@ -913,6 +923,7 @@ declare const impContract: {
913
923
  imp: "imp";
914
924
  secret: "secret";
915
925
  session: "session";
926
+ "ssh-key": "ssh-key";
916
927
  token: "token";
917
928
  }>;
918
929
  name: z.ZodString;
@@ -929,6 +940,7 @@ declare const impContract: {
929
940
  imp: "imp";
930
941
  secret: "secret";
931
942
  session: "session";
943
+ "ssh-key": "ssh-key";
932
944
  token: "token";
933
945
  }>;
934
946
  name: z.ZodString;
@@ -1041,6 +1053,7 @@ declare const impContract: {
1041
1053
  imp: "imp";
1042
1054
  secret: "secret";
1043
1055
  session: "session";
1056
+ "ssh-key": "ssh-key";
1044
1057
  token: "token";
1045
1058
  }>;
1046
1059
  name: z.ZodString;
@@ -1057,6 +1070,7 @@ declare const impContract: {
1057
1070
  imp: "imp";
1058
1071
  secret: "secret";
1059
1072
  session: "session";
1073
+ "ssh-key": "ssh-key";
1060
1074
  token: "token";
1061
1075
  }>;
1062
1076
  name: z.ZodString;
@@ -1170,6 +1184,7 @@ declare const impContract: {
1170
1184
  imp: "imp";
1171
1185
  secret: "secret";
1172
1186
  session: "session";
1187
+ "ssh-key": "ssh-key";
1173
1188
  token: "token";
1174
1189
  }>;
1175
1190
  name: z.ZodString;
@@ -1186,6 +1201,7 @@ declare const impContract: {
1186
1201
  imp: "imp";
1187
1202
  secret: "secret";
1188
1203
  session: "session";
1204
+ "ssh-key": "ssh-key";
1189
1205
  token: "token";
1190
1206
  }>;
1191
1207
  name: z.ZodString;
@@ -1299,6 +1315,7 @@ declare const impContract: {
1299
1315
  imp: "imp";
1300
1316
  secret: "secret";
1301
1317
  session: "session";
1318
+ "ssh-key": "ssh-key";
1302
1319
  token: "token";
1303
1320
  }>;
1304
1321
  name: z.ZodString;
@@ -1315,6 +1332,7 @@ declare const impContract: {
1315
1332
  imp: "imp";
1316
1333
  secret: "secret";
1317
1334
  session: "session";
1335
+ "ssh-key": "ssh-key";
1318
1336
  token: "token";
1319
1337
  }>;
1320
1338
  name: z.ZodString;
@@ -1428,6 +1446,7 @@ declare const impContract: {
1428
1446
  imp: "imp";
1429
1447
  secret: "secret";
1430
1448
  session: "session";
1449
+ "ssh-key": "ssh-key";
1431
1450
  token: "token";
1432
1451
  }>;
1433
1452
  name: z.ZodString;
@@ -1444,6 +1463,7 @@ declare const impContract: {
1444
1463
  imp: "imp";
1445
1464
  secret: "secret";
1446
1465
  session: "session";
1466
+ "ssh-key": "ssh-key";
1447
1467
  token: "token";
1448
1468
  }>;
1449
1469
  name: z.ZodString;
@@ -1506,6 +1526,7 @@ declare const impContract: {
1506
1526
  }, z.core.$strip>, z.ZodObject<{
1507
1527
  local: z.ZodURL;
1508
1528
  https: z.ZodNullable<z.ZodURL>;
1529
+ service: z.ZodNullable<z.ZodURL>;
1509
1530
  tailnet: z.ZodNullable<z.ZodURL>;
1510
1531
  }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
1511
1532
  NOT_FOUND: {
@@ -1519,6 +1540,7 @@ declare const impContract: {
1519
1540
  imp: "imp";
1520
1541
  secret: "secret";
1521
1542
  session: "session";
1543
+ "ssh-key": "ssh-key";
1522
1544
  token: "token";
1523
1545
  }>;
1524
1546
  name: z.ZodString;
@@ -1535,6 +1557,7 @@ declare const impContract: {
1535
1557
  imp: "imp";
1536
1558
  secret: "secret";
1537
1559
  session: "session";
1560
+ "ssh-key": "ssh-key";
1538
1561
  token: "token";
1539
1562
  }>;
1540
1563
  name: z.ZodString;
@@ -1613,6 +1636,7 @@ declare const impContract: {
1613
1636
  imp: "imp";
1614
1637
  secret: "secret";
1615
1638
  session: "session";
1639
+ "ssh-key": "ssh-key";
1616
1640
  token: "token";
1617
1641
  }>;
1618
1642
  name: z.ZodString;
@@ -1629,6 +1653,7 @@ declare const impContract: {
1629
1653
  imp: "imp";
1630
1654
  secret: "secret";
1631
1655
  session: "session";
1656
+ "ssh-key": "ssh-key";
1632
1657
  token: "token";
1633
1658
  }>;
1634
1659
  name: z.ZodString;
@@ -1715,6 +1740,7 @@ declare const impContract: {
1715
1740
  imp: "imp";
1716
1741
  secret: "secret";
1717
1742
  session: "session";
1743
+ "ssh-key": "ssh-key";
1718
1744
  token: "token";
1719
1745
  }>;
1720
1746
  name: z.ZodString;
@@ -1731,6 +1757,7 @@ declare const impContract: {
1731
1757
  imp: "imp";
1732
1758
  secret: "secret";
1733
1759
  session: "session";
1760
+ "ssh-key": "ssh-key";
1734
1761
  token: "token";
1735
1762
  }>;
1736
1763
  name: z.ZodString;
@@ -1845,6 +1872,7 @@ declare const impContract: {
1845
1872
  imp: "imp";
1846
1873
  secret: "secret";
1847
1874
  session: "session";
1875
+ "ssh-key": "ssh-key";
1848
1876
  token: "token";
1849
1877
  }>;
1850
1878
  name: z.ZodString;
@@ -1861,6 +1889,7 @@ declare const impContract: {
1861
1889
  imp: "imp";
1862
1890
  secret: "secret";
1863
1891
  session: "session";
1892
+ "ssh-key": "ssh-key";
1864
1893
  token: "token";
1865
1894
  }>;
1866
1895
  name: z.ZodString;
@@ -1941,6 +1970,7 @@ declare const impContract: {
1941
1970
  imp: "imp";
1942
1971
  secret: "secret";
1943
1972
  session: "session";
1973
+ "ssh-key": "ssh-key";
1944
1974
  token: "token";
1945
1975
  }>;
1946
1976
  name: z.ZodString;
@@ -1957,6 +1987,7 @@ declare const impContract: {
1957
1987
  imp: "imp";
1958
1988
  secret: "secret";
1959
1989
  session: "session";
1990
+ "ssh-key": "ssh-key";
1960
1991
  token: "token";
1961
1992
  }>;
1962
1993
  name: z.ZodString;
@@ -2034,6 +2065,7 @@ declare const impContract: {
2034
2065
  imp: "imp";
2035
2066
  secret: "secret";
2036
2067
  session: "session";
2068
+ "ssh-key": "ssh-key";
2037
2069
  token: "token";
2038
2070
  }>;
2039
2071
  name: z.ZodString;
@@ -2050,6 +2082,7 @@ declare const impContract: {
2050
2082
  imp: "imp";
2051
2083
  secret: "secret";
2052
2084
  session: "session";
2085
+ "ssh-key": "ssh-key";
2053
2086
  token: "token";
2054
2087
  }>;
2055
2088
  name: z.ZodString;
@@ -2163,6 +2196,7 @@ declare const impContract: {
2163
2196
  imp: "imp";
2164
2197
  secret: "secret";
2165
2198
  session: "session";
2199
+ "ssh-key": "ssh-key";
2166
2200
  token: "token";
2167
2201
  }>;
2168
2202
  name: z.ZodString;
@@ -2179,6 +2213,7 @@ declare const impContract: {
2179
2213
  imp: "imp";
2180
2214
  secret: "secret";
2181
2215
  session: "session";
2216
+ "ssh-key": "ssh-key";
2182
2217
  token: "token";
2183
2218
  }>;
2184
2219
  name: z.ZodString;
@@ -2251,6 +2286,7 @@ declare const impContract: {
2251
2286
  imp: "imp";
2252
2287
  secret: "secret";
2253
2288
  session: "session";
2289
+ "ssh-key": "ssh-key";
2254
2290
  token: "token";
2255
2291
  }>;
2256
2292
  name: z.ZodString;
@@ -2267,6 +2303,7 @@ declare const impContract: {
2267
2303
  imp: "imp";
2268
2304
  secret: "secret";
2269
2305
  session: "session";
2306
+ "ssh-key": "ssh-key";
2270
2307
  token: "token";
2271
2308
  }>;
2272
2309
  name: z.ZodString;
@@ -2347,6 +2384,7 @@ declare const impContract: {
2347
2384
  imp: "imp";
2348
2385
  secret: "secret";
2349
2386
  session: "session";
2387
+ "ssh-key": "ssh-key";
2350
2388
  token: "token";
2351
2389
  }>;
2352
2390
  name: z.ZodString;
@@ -2363,6 +2401,7 @@ declare const impContract: {
2363
2401
  imp: "imp";
2364
2402
  secret: "secret";
2365
2403
  session: "session";
2404
+ "ssh-key": "ssh-key";
2366
2405
  token: "token";
2367
2406
  }>;
2368
2407
  name: z.ZodString;
@@ -2444,6 +2483,7 @@ declare const impContract: {
2444
2483
  imp: "imp";
2445
2484
  secret: "secret";
2446
2485
  session: "session";
2486
+ "ssh-key": "ssh-key";
2447
2487
  token: "token";
2448
2488
  }>;
2449
2489
  name: z.ZodString;
@@ -2460,6 +2500,7 @@ declare const impContract: {
2460
2500
  imp: "imp";
2461
2501
  secret: "secret";
2462
2502
  session: "session";
2503
+ "ssh-key": "ssh-key";
2463
2504
  token: "token";
2464
2505
  }>;
2465
2506
  name: z.ZodString;
@@ -2583,6 +2624,7 @@ declare const impContract: {
2583
2624
  imp: "imp";
2584
2625
  secret: "secret";
2585
2626
  session: "session";
2627
+ "ssh-key": "ssh-key";
2586
2628
  token: "token";
2587
2629
  }>;
2588
2630
  name: z.ZodString;
@@ -2599,6 +2641,7 @@ declare const impContract: {
2599
2641
  imp: "imp";
2600
2642
  secret: "secret";
2601
2643
  session: "session";
2644
+ "ssh-key": "ssh-key";
2602
2645
  token: "token";
2603
2646
  }>;
2604
2647
  name: z.ZodString;
@@ -2670,6 +2713,7 @@ declare const impContract: {
2670
2713
  imp: "imp";
2671
2714
  secret: "secret";
2672
2715
  session: "session";
2716
+ "ssh-key": "ssh-key";
2673
2717
  token: "token";
2674
2718
  }>;
2675
2719
  name: z.ZodString;
@@ -2686,6 +2730,7 @@ declare const impContract: {
2686
2730
  imp: "imp";
2687
2731
  secret: "secret";
2688
2732
  session: "session";
2733
+ "ssh-key": "ssh-key";
2689
2734
  token: "token";
2690
2735
  }>;
2691
2736
  name: z.ZodString;
@@ -2764,6 +2809,7 @@ declare const impContract: {
2764
2809
  imp: "imp";
2765
2810
  secret: "secret";
2766
2811
  session: "session";
2812
+ "ssh-key": "ssh-key";
2767
2813
  token: "token";
2768
2814
  }>;
2769
2815
  name: z.ZodString;
@@ -2780,6 +2826,7 @@ declare const impContract: {
2780
2826
  imp: "imp";
2781
2827
  secret: "secret";
2782
2828
  session: "session";
2829
+ "ssh-key": "ssh-key";
2783
2830
  token: "token";
2784
2831
  }>;
2785
2832
  name: z.ZodString;
@@ -2859,6 +2906,7 @@ declare const impContract: {
2859
2906
  imp: "imp";
2860
2907
  secret: "secret";
2861
2908
  session: "session";
2909
+ "ssh-key": "ssh-key";
2862
2910
  token: "token";
2863
2911
  }>;
2864
2912
  name: z.ZodString;
@@ -2875,6 +2923,7 @@ declare const impContract: {
2875
2923
  imp: "imp";
2876
2924
  secret: "secret";
2877
2925
  session: "session";
2926
+ "ssh-key": "ssh-key";
2878
2927
  token: "token";
2879
2928
  }>;
2880
2929
  name: z.ZodString;
@@ -2955,6 +3004,7 @@ declare const impContract: {
2955
3004
  imp: "imp";
2956
3005
  secret: "secret";
2957
3006
  session: "session";
3007
+ "ssh-key": "ssh-key";
2958
3008
  token: "token";
2959
3009
  }>;
2960
3010
  name: z.ZodString;
@@ -2971,6 +3021,7 @@ declare const impContract: {
2971
3021
  imp: "imp";
2972
3022
  secret: "secret";
2973
3023
  session: "session";
3024
+ "ssh-key": "ssh-key";
2974
3025
  token: "token";
2975
3026
  }>;
2976
3027
  name: z.ZodString;
@@ -3042,6 +3093,7 @@ declare const impContract: {
3042
3093
  imp: "imp";
3043
3094
  secret: "secret";
3044
3095
  session: "session";
3096
+ "ssh-key": "ssh-key";
3045
3097
  token: "token";
3046
3098
  }>;
3047
3099
  name: z.ZodString;
@@ -3058,6 +3110,7 @@ declare const impContract: {
3058
3110
  imp: "imp";
3059
3111
  secret: "secret";
3060
3112
  session: "session";
3113
+ "ssh-key": "ssh-key";
3061
3114
  token: "token";
3062
3115
  }>;
3063
3116
  name: z.ZodString;
@@ -3134,6 +3187,7 @@ declare const impContract: {
3134
3187
  imp: "imp";
3135
3188
  secret: "secret";
3136
3189
  session: "session";
3190
+ "ssh-key": "ssh-key";
3137
3191
  token: "token";
3138
3192
  }>;
3139
3193
  name: z.ZodString;
@@ -3150,6 +3204,7 @@ declare const impContract: {
3150
3204
  imp: "imp";
3151
3205
  secret: "secret";
3152
3206
  session: "session";
3207
+ "ssh-key": "ssh-key";
3153
3208
  token: "token";
3154
3209
  }>;
3155
3210
  name: z.ZodString;
@@ -3239,6 +3294,7 @@ declare const impContract: {
3239
3294
  imp: "imp";
3240
3295
  secret: "secret";
3241
3296
  session: "session";
3297
+ "ssh-key": "ssh-key";
3242
3298
  token: "token";
3243
3299
  }>;
3244
3300
  name: z.ZodString;
@@ -3255,6 +3311,7 @@ declare const impContract: {
3255
3311
  imp: "imp";
3256
3312
  secret: "secret";
3257
3313
  session: "session";
3314
+ "ssh-key": "ssh-key";
3258
3315
  token: "token";
3259
3316
  }>;
3260
3317
  name: z.ZodString;
@@ -3327,6 +3384,7 @@ declare const impContract: {
3327
3384
  imp: "imp";
3328
3385
  secret: "secret";
3329
3386
  session: "session";
3387
+ "ssh-key": "ssh-key";
3330
3388
  token: "token";
3331
3389
  }>;
3332
3390
  name: z.ZodString;
@@ -3343,6 +3401,7 @@ declare const impContract: {
3343
3401
  imp: "imp";
3344
3402
  secret: "secret";
3345
3403
  session: "session";
3404
+ "ssh-key": "ssh-key";
3346
3405
  token: "token";
3347
3406
  }>;
3348
3407
  name: z.ZodString;
@@ -3454,6 +3513,7 @@ declare const impContract: {
3454
3513
  imp: "imp";
3455
3514
  secret: "secret";
3456
3515
  session: "session";
3516
+ "ssh-key": "ssh-key";
3457
3517
  token: "token";
3458
3518
  }>;
3459
3519
  name: z.ZodString;
@@ -3470,6 +3530,7 @@ declare const impContract: {
3470
3530
  imp: "imp";
3471
3531
  secret: "secret";
3472
3532
  session: "session";
3533
+ "ssh-key": "ssh-key";
3473
3534
  token: "token";
3474
3535
  }>;
3475
3536
  name: z.ZodString;
@@ -3559,6 +3620,7 @@ declare const impContract: {
3559
3620
  imp: "imp";
3560
3621
  secret: "secret";
3561
3622
  session: "session";
3623
+ "ssh-key": "ssh-key";
3562
3624
  token: "token";
3563
3625
  }>;
3564
3626
  name: z.ZodString;
@@ -3575,6 +3637,7 @@ declare const impContract: {
3575
3637
  imp: "imp";
3576
3638
  secret: "secret";
3577
3639
  session: "session";
3640
+ "ssh-key": "ssh-key";
3578
3641
  token: "token";
3579
3642
  }>;
3580
3643
  name: z.ZodString;
@@ -3646,6 +3709,7 @@ declare const impContract: {
3646
3709
  imp: "imp";
3647
3710
  secret: "secret";
3648
3711
  session: "session";
3712
+ "ssh-key": "ssh-key";
3649
3713
  token: "token";
3650
3714
  }>;
3651
3715
  name: z.ZodString;
@@ -3662,6 +3726,7 @@ declare const impContract: {
3662
3726
  imp: "imp";
3663
3727
  secret: "secret";
3664
3728
  session: "session";
3729
+ "ssh-key": "ssh-key";
3665
3730
  token: "token";
3666
3731
  }>;
3667
3732
  name: z.ZodString;
@@ -3736,6 +3801,7 @@ declare const impContract: {
3736
3801
  imp: "imp";
3737
3802
  secret: "secret";
3738
3803
  session: "session";
3804
+ "ssh-key": "ssh-key";
3739
3805
  token: "token";
3740
3806
  }>;
3741
3807
  name: z.ZodString;
@@ -3752,6 +3818,7 @@ declare const impContract: {
3752
3818
  imp: "imp";
3753
3819
  secret: "secret";
3754
3820
  session: "session";
3821
+ "ssh-key": "ssh-key";
3755
3822
  token: "token";
3756
3823
  }>;
3757
3824
  name: z.ZodString;
@@ -3824,6 +3891,7 @@ declare const impContract: {
3824
3891
  imp: "imp";
3825
3892
  secret: "secret";
3826
3893
  session: "session";
3894
+ "ssh-key": "ssh-key";
3827
3895
  token: "token";
3828
3896
  }>;
3829
3897
  name: z.ZodString;
@@ -3840,6 +3908,7 @@ declare const impContract: {
3840
3908
  imp: "imp";
3841
3909
  secret: "secret";
3842
3910
  session: "session";
3911
+ "ssh-key": "ssh-key";
3843
3912
  token: "token";
3844
3913
  }>;
3845
3914
  name: z.ZodString;
@@ -3911,6 +3980,7 @@ declare const impContract: {
3911
3980
  imp: "imp";
3912
3981
  secret: "secret";
3913
3982
  session: "session";
3983
+ "ssh-key": "ssh-key";
3914
3984
  token: "token";
3915
3985
  }>;
3916
3986
  name: z.ZodString;
@@ -3927,6 +3997,7 @@ declare const impContract: {
3927
3997
  imp: "imp";
3928
3998
  secret: "secret";
3929
3999
  session: "session";
4000
+ "ssh-key": "ssh-key";
3930
4001
  token: "token";
3931
4002
  }>;
3932
4003
  name: z.ZodString;
@@ -4012,6 +4083,7 @@ declare const impContract: {
4012
4083
  imp: "imp";
4013
4084
  secret: "secret";
4014
4085
  session: "session";
4086
+ "ssh-key": "ssh-key";
4015
4087
  token: "token";
4016
4088
  }>;
4017
4089
  name: z.ZodString;
@@ -4028,6 +4100,7 @@ declare const impContract: {
4028
4100
  imp: "imp";
4029
4101
  secret: "secret";
4030
4102
  session: "session";
4103
+ "ssh-key": "ssh-key";
4031
4104
  token: "token";
4032
4105
  }>;
4033
4106
  name: z.ZodString;
@@ -4113,6 +4186,7 @@ declare const impContract: {
4113
4186
  imp: "imp";
4114
4187
  secret: "secret";
4115
4188
  session: "session";
4189
+ "ssh-key": "ssh-key";
4116
4190
  token: "token";
4117
4191
  }>;
4118
4192
  name: z.ZodString;
@@ -4129,6 +4203,7 @@ declare const impContract: {
4129
4203
  imp: "imp";
4130
4204
  secret: "secret";
4131
4205
  session: "session";
4206
+ "ssh-key": "ssh-key";
4132
4207
  token: "token";
4133
4208
  }>;
4134
4209
  name: z.ZodString;
@@ -4494,6 +4569,7 @@ declare const impContract: {
4494
4569
  imp: "imp";
4495
4570
  secret: "secret";
4496
4571
  session: "session";
4572
+ "ssh-key": "ssh-key";
4497
4573
  token: "token";
4498
4574
  }>;
4499
4575
  name: z.ZodString;
@@ -4510,6 +4586,7 @@ declare const impContract: {
4510
4586
  imp: "imp";
4511
4587
  secret: "secret";
4512
4588
  session: "session";
4589
+ "ssh-key": "ssh-key";
4513
4590
  token: "token";
4514
4591
  }>;
4515
4592
  name: z.ZodString;
@@ -4611,6 +4688,13 @@ declare const impContract: {
4611
4688
  state: z.ZodNullable<z.ZodString>;
4612
4689
  hostname: z.ZodNullable<z.ZodString>;
4613
4690
  ip: z.ZodNullable<z.ZodString>;
4691
+ names: z.ZodNullable<z.ZodObject<{
4692
+ live: z.ZodInt;
4693
+ failed: z.ZodReadonly<z.ZodArray<z.ZodObject<{
4694
+ name: z.ZodString;
4695
+ error: z.ZodString;
4696
+ }, z.core.$strip>>>;
4697
+ }, z.core.$strip>>;
4614
4698
  }, z.core.$strip>;
4615
4699
  }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4616
4700
  NOT_FOUND: {
@@ -4624,6 +4708,7 @@ declare const impContract: {
4624
4708
  imp: "imp";
4625
4709
  secret: "secret";
4626
4710
  session: "session";
4711
+ "ssh-key": "ssh-key";
4627
4712
  token: "token";
4628
4713
  }>;
4629
4714
  name: z.ZodString;
@@ -4640,6 +4725,7 @@ declare const impContract: {
4640
4725
  imp: "imp";
4641
4726
  secret: "secret";
4642
4727
  session: "session";
4728
+ "ssh-key": "ssh-key";
4643
4729
  token: "token";
4644
4730
  }>;
4645
4731
  name: z.ZodString;
@@ -4723,6 +4809,7 @@ declare const impContract: {
4723
4809
  imp: "imp";
4724
4810
  secret: "secret";
4725
4811
  session: "session";
4812
+ "ssh-key": "ssh-key";
4726
4813
  token: "token";
4727
4814
  }>;
4728
4815
  name: z.ZodString;
@@ -4739,6 +4826,7 @@ declare const impContract: {
4739
4826
  imp: "imp";
4740
4827
  secret: "secret";
4741
4828
  session: "session";
4829
+ "ssh-key": "ssh-key";
4742
4830
  token: "token";
4743
4831
  }>;
4744
4832
  name: z.ZodString;
@@ -4806,6 +4894,11 @@ declare const impContract: {
4806
4894
  read: "read";
4807
4895
  }>;
4808
4896
  imps: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
4897
+ sshKeys: z.ZodReadonly<z.ZodArray<z.ZodObject<{
4898
+ fingerprint: z.ZodString;
4899
+ type: z.ZodString;
4900
+ comment: z.ZodString;
4901
+ }, z.core.$strip>>>;
4809
4902
  createdAt: z.ZodDate;
4810
4903
  }, z.core.$strip>>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4811
4904
  NOT_FOUND: {
@@ -4819,6 +4912,7 @@ declare const impContract: {
4819
4912
  imp: "imp";
4820
4913
  secret: "secret";
4821
4914
  session: "session";
4915
+ "ssh-key": "ssh-key";
4822
4916
  token: "token";
4823
4917
  }>;
4824
4918
  name: z.ZodString;
@@ -4835,6 +4929,7 @@ declare const impContract: {
4835
4929
  imp: "imp";
4836
4930
  secret: "secret";
4837
4931
  session: "session";
4932
+ "ssh-key": "ssh-key";
4838
4933
  token: "token";
4839
4934
  }>;
4840
4935
  name: z.ZodString;
@@ -4900,6 +4995,7 @@ declare const impContract: {
4900
4995
  read: "read";
4901
4996
  }>;
4902
4997
  imps: z.ZodOptional<z.ZodArray<z.ZodString>>;
4998
+ sshKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
4903
4999
  }, z.core.$strip>, z.ZodObject<{
4904
5000
  token: z.ZodObject<{
4905
5001
  name: z.ZodString;
@@ -4909,6 +5005,11 @@ declare const impContract: {
4909
5005
  read: "read";
4910
5006
  }>;
4911
5007
  imps: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
5008
+ sshKeys: z.ZodReadonly<z.ZodArray<z.ZodObject<{
5009
+ fingerprint: z.ZodString;
5010
+ type: z.ZodString;
5011
+ comment: z.ZodString;
5012
+ }, z.core.$strip>>>;
4912
5013
  createdAt: z.ZodDate;
4913
5014
  }, z.core.$strip>;
4914
5015
  secret: z.ZodString;
@@ -4924,6 +5025,7 @@ declare const impContract: {
4924
5025
  imp: "imp";
4925
5026
  secret: "secret";
4926
5027
  session: "session";
5028
+ "ssh-key": "ssh-key";
4927
5029
  token: "token";
4928
5030
  }>;
4929
5031
  name: z.ZodString;
@@ -4940,6 +5042,7 @@ declare const impContract: {
4940
5042
  imp: "imp";
4941
5043
  secret: "secret";
4942
5044
  session: "session";
5045
+ "ssh-key": "ssh-key";
4943
5046
  token: "token";
4944
5047
  }>;
4945
5048
  name: z.ZodString;
@@ -5011,6 +5114,191 @@ declare const impContract: {
5011
5114
  imp: "imp";
5012
5115
  secret: "secret";
5013
5116
  session: "session";
5117
+ "ssh-key": "ssh-key";
5118
+ token: "token";
5119
+ }>;
5120
+ name: z.ZodString;
5121
+ }, z.core.$strip>;
5122
+ };
5123
+ CONFLICT: {
5124
+ readonly message: "Already exists";
5125
+ readonly data: z.ZodObject<{
5126
+ kind: z.ZodEnum<{
5127
+ backup: "backup";
5128
+ checkpoint: "checkpoint";
5129
+ grant: "grant";
5130
+ image: "image";
5131
+ imp: "imp";
5132
+ secret: "secret";
5133
+ session: "session";
5134
+ "ssh-key": "ssh-key";
5135
+ token: "token";
5136
+ }>;
5137
+ name: z.ZodString;
5138
+ }, z.core.$strip>;
5139
+ };
5140
+ FORBIDDEN: {
5141
+ readonly message: "Not allowed";
5142
+ };
5143
+ PRECONDITION_FAILED: {
5144
+ readonly message: "Not possible on this host";
5145
+ };
5146
+ RAM_BUDGET_EXCEEDED: {
5147
+ readonly message: "Not enough RAM budget, even after sleeping idle imps";
5148
+ readonly status: 503;
5149
+ readonly data: z.ZodObject<{
5150
+ budgetMib: z.ZodInt;
5151
+ usedMib: z.ZodInt;
5152
+ requestedMib: z.ZodInt;
5153
+ }, z.core.$strip>;
5154
+ };
5155
+ SERVICE_UNAVAILABLE: {
5156
+ readonly message: "impd is stopping";
5157
+ };
5158
+ INVALID_STATE: {
5159
+ readonly message: "The imp is not in a state that allows this";
5160
+ readonly status: 409;
5161
+ readonly data: z.ZodObject<{
5162
+ state: z.ZodEnum<{
5163
+ creating: "creating";
5164
+ error: "error";
5165
+ running: "running";
5166
+ sleeping: "sleeping";
5167
+ stopped: "stopped";
5168
+ }>;
5169
+ allowed: z.ZodArray<z.ZodEnum<{
5170
+ creating: "creating";
5171
+ error: "error";
5172
+ running: "running";
5173
+ sleeping: "sleeping";
5174
+ stopped: "stopped";
5175
+ }>>;
5176
+ }, z.core.$strip>;
5177
+ };
5178
+ DISK_FULL: {
5179
+ readonly message: "Not enough free disk on the host";
5180
+ readonly status: 507;
5181
+ readonly data: z.ZodObject<{
5182
+ availableBytes: z.ZodInt;
5183
+ reserveBytes: z.ZodInt;
5184
+ requestedBytes: z.ZodInt;
5185
+ }, z.core.$strip>;
5186
+ };
5187
+ AGENT_OUTDATED: {
5188
+ readonly message: "The imp's agent is too old for this";
5189
+ readonly status: 409;
5190
+ };
5191
+ }>, Record<never, never>>;
5192
+ addKey: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
5193
+ name: z.ZodString;
5194
+ key: z.ZodString;
5195
+ }, z.core.$strip>, z.ZodObject<{
5196
+ fingerprint: z.ZodString;
5197
+ type: z.ZodString;
5198
+ comment: z.ZodString;
5199
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
5200
+ NOT_FOUND: {
5201
+ readonly message: "Not found";
5202
+ readonly data: z.ZodObject<{
5203
+ kind: z.ZodEnum<{
5204
+ backup: "backup";
5205
+ checkpoint: "checkpoint";
5206
+ grant: "grant";
5207
+ image: "image";
5208
+ imp: "imp";
5209
+ secret: "secret";
5210
+ session: "session";
5211
+ "ssh-key": "ssh-key";
5212
+ token: "token";
5213
+ }>;
5214
+ name: z.ZodString;
5215
+ }, z.core.$strip>;
5216
+ };
5217
+ CONFLICT: {
5218
+ readonly message: "Already exists";
5219
+ readonly data: z.ZodObject<{
5220
+ kind: z.ZodEnum<{
5221
+ backup: "backup";
5222
+ checkpoint: "checkpoint";
5223
+ grant: "grant";
5224
+ image: "image";
5225
+ imp: "imp";
5226
+ secret: "secret";
5227
+ session: "session";
5228
+ "ssh-key": "ssh-key";
5229
+ token: "token";
5230
+ }>;
5231
+ name: z.ZodString;
5232
+ }, z.core.$strip>;
5233
+ };
5234
+ FORBIDDEN: {
5235
+ readonly message: "Not allowed";
5236
+ };
5237
+ PRECONDITION_FAILED: {
5238
+ readonly message: "Not possible on this host";
5239
+ };
5240
+ RAM_BUDGET_EXCEEDED: {
5241
+ readonly message: "Not enough RAM budget, even after sleeping idle imps";
5242
+ readonly status: 503;
5243
+ readonly data: z.ZodObject<{
5244
+ budgetMib: z.ZodInt;
5245
+ usedMib: z.ZodInt;
5246
+ requestedMib: z.ZodInt;
5247
+ }, z.core.$strip>;
5248
+ };
5249
+ SERVICE_UNAVAILABLE: {
5250
+ readonly message: "impd is stopping";
5251
+ };
5252
+ INVALID_STATE: {
5253
+ readonly message: "The imp is not in a state that allows this";
5254
+ readonly status: 409;
5255
+ readonly data: z.ZodObject<{
5256
+ state: z.ZodEnum<{
5257
+ creating: "creating";
5258
+ error: "error";
5259
+ running: "running";
5260
+ sleeping: "sleeping";
5261
+ stopped: "stopped";
5262
+ }>;
5263
+ allowed: z.ZodArray<z.ZodEnum<{
5264
+ creating: "creating";
5265
+ error: "error";
5266
+ running: "running";
5267
+ sleeping: "sleeping";
5268
+ stopped: "stopped";
5269
+ }>>;
5270
+ }, z.core.$strip>;
5271
+ };
5272
+ DISK_FULL: {
5273
+ readonly message: "Not enough free disk on the host";
5274
+ readonly status: 507;
5275
+ readonly data: z.ZodObject<{
5276
+ availableBytes: z.ZodInt;
5277
+ reserveBytes: z.ZodInt;
5278
+ requestedBytes: z.ZodInt;
5279
+ }, z.core.$strip>;
5280
+ };
5281
+ AGENT_OUTDATED: {
5282
+ readonly message: "The imp's agent is too old for this";
5283
+ readonly status: 409;
5284
+ };
5285
+ }>, Record<never, never>>;
5286
+ removeKey: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
5287
+ name: z.ZodString;
5288
+ fingerprint: z.ZodString;
5289
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
5290
+ NOT_FOUND: {
5291
+ readonly message: "Not found";
5292
+ readonly data: z.ZodObject<{
5293
+ kind: z.ZodEnum<{
5294
+ backup: "backup";
5295
+ checkpoint: "checkpoint";
5296
+ grant: "grant";
5297
+ image: "image";
5298
+ imp: "imp";
5299
+ secret: "secret";
5300
+ session: "session";
5301
+ "ssh-key": "ssh-key";
5014
5302
  token: "token";
5015
5303
  }>;
5016
5304
  name: z.ZodString;
@@ -5027,6 +5315,7 @@ declare const impContract: {
5027
5315
  imp: "imp";
5028
5316
  secret: "secret";
5029
5317
  session: "session";
5318
+ "ssh-key": "ssh-key";
5030
5319
  token: "token";
5031
5320
  }>;
5032
5321
  name: z.ZodString;
@@ -5110,6 +5399,7 @@ declare const impContract: {
5110
5399
  imp: "imp";
5111
5400
  secret: "secret";
5112
5401
  session: "session";
5402
+ "ssh-key": "ssh-key";
5113
5403
  token: "token";
5114
5404
  }>;
5115
5405
  name: z.ZodString;
@@ -5126,6 +5416,7 @@ declare const impContract: {
5126
5416
  imp: "imp";
5127
5417
  secret: "secret";
5128
5418
  session: "session";
5419
+ "ssh-key": "ssh-key";
5129
5420
  token: "token";
5130
5421
  }>;
5131
5422
  name: z.ZodString;
@@ -5306,6 +5597,13 @@ declare const SystemInfoSchema: z.ZodObject<{
5306
5597
  state: z.ZodNullable<z.ZodString>;
5307
5598
  hostname: z.ZodNullable<z.ZodString>;
5308
5599
  ip: z.ZodNullable<z.ZodString>;
5600
+ names: z.ZodNullable<z.ZodObject<{
5601
+ live: z.ZodInt;
5602
+ failed: z.ZodReadonly<z.ZodArray<z.ZodObject<{
5603
+ name: z.ZodString;
5604
+ error: z.ZodString;
5605
+ }, z.core.$strip>>>;
5606
+ }, z.core.$strip>>;
5309
5607
  }, z.core.$strip>;
5310
5608
  }, z.core.$strip>;
5311
5609
  type SystemInfo = z.infer<typeof SystemInfoSchema>;
@@ -5317,6 +5615,12 @@ declare const ScopeSchema: z.ZodEnum<{
5317
5615
  read: "read";
5318
5616
  }>;
5319
5617
  type Scope = z.infer<typeof ScopeSchema>;
5618
+ declare const SshKeySchema: z.ZodObject<{
5619
+ fingerprint: z.ZodString;
5620
+ type: z.ZodString;
5621
+ comment: z.ZodString;
5622
+ }, z.core.$strip>;
5623
+ type SshKey = z.infer<typeof SshKeySchema>;
5320
5624
  declare const TokenSchema: z.ZodObject<{
5321
5625
  name: z.ZodString;
5322
5626
  scope: z.ZodEnum<{
@@ -5325,6 +5629,11 @@ declare const TokenSchema: z.ZodObject<{
5325
5629
  read: "read";
5326
5630
  }>;
5327
5631
  imps: z.ZodNullable<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
5632
+ sshKeys: z.ZodReadonly<z.ZodArray<z.ZodObject<{
5633
+ fingerprint: z.ZodString;
5634
+ type: z.ZodString;
5635
+ comment: z.ZodString;
5636
+ }, z.core.$strip>>>;
5328
5637
  createdAt: z.ZodDate;
5329
5638
  }, z.core.$strip>;
5330
5639
  type Token = z.infer<typeof TokenSchema>;
@@ -5363,6 +5672,7 @@ interface ExecStart {
5363
5672
  readonly cols?: number;
5364
5673
  readonly rows?: number;
5365
5674
  readonly session?: string;
5675
+ readonly killGraceMs?: number;
5366
5676
  }
5367
5677
  interface ExecAttach {
5368
5678
  readonly name: string;
@@ -5374,6 +5684,7 @@ interface ExecStarted {
5374
5684
  readonly pid: number;
5375
5685
  readonly session: string | null;
5376
5686
  readonly created: boolean;
5687
+ readonly groupKill: boolean;
5377
5688
  }
5378
5689
  type ExecOutcome = {
5379
5690
  readonly kind: 'exit';
@@ -5404,6 +5715,7 @@ type ExecOutcome = {
5404
5715
  readonly kind: 'local_error';
5405
5716
  readonly error: unknown;
5406
5717
  };
5718
+ type ExecSocket = Pick<WebSocket, 'binaryType' | 'readyState' | 'bufferedAmount' | 'send' | 'close' | 'addEventListener'>;
5407
5719
  interface ExecSessionOptions {
5408
5720
  readonly baseUrl: string;
5409
5721
  readonly token: string | null;
@@ -5411,7 +5723,7 @@ interface ExecSessionOptions {
5411
5723
  readonly start: ExecStart | ExecAttach;
5412
5724
  readonly onStarted: (started: ExecStarted) => void;
5413
5725
  readonly onOutput: (channel: 'stdout' | 'stderr', data: Uint8Array) => void;
5414
- readonly connect: (url: string, headers: Readonly<Record<string, string>>) => WebSocket;
5726
+ readonly connect: (url: string, headers: Readonly<Record<string, string>>) => ExecSocket;
5415
5727
  readonly fetch?: (request: Request) => Promise<Response>;
5416
5728
  }
5417
5729
  interface ExecSession {
@@ -5434,6 +5746,7 @@ interface ExecOptions {
5434
5746
  readonly cols?: number;
5435
5747
  readonly rows?: number;
5436
5748
  readonly session?: string;
5749
+ readonly killGraceMs?: number;
5437
5750
  readonly signal?: Readonly<AbortSignal>;
5438
5751
  readonly maxUnreadBytes?: number;
5439
5752
  }
@@ -5478,6 +5791,7 @@ interface ImpClientOptions {
5478
5791
  readonly url: string;
5479
5792
  readonly token?: string;
5480
5793
  readonly fetch?: (request: Request) => Promise<Response>;
5794
+ readonly connect?: (url: string) => ExecSocket;
5481
5795
  }
5482
5796
  interface ImpClient extends RpcClient {
5483
5797
  readonly requireAwake: (name: string, options?: RequireAwakeOptions) => Promise<Imp>;
@@ -5489,6 +5803,57 @@ interface ImpClient extends RpcClient {
5489
5803
  }
5490
5804
  export declare function createImpClient(options: Readonly<ImpClientOptions>): ImpClient;
5491
5805
  //#endregion
5806
+ //#region src/reverse/open-reverse-forward.d.ts
5807
+ type ReverseGuest = {
5808
+ readonly network: 'unix';
5809
+ readonly path: string | null;
5810
+ } | {
5811
+ readonly network: 'tcp';
5812
+ readonly port: number;
5813
+ };
5814
+ interface ReverseListening {
5815
+ readonly path: string | null;
5816
+ readonly port: number | null;
5817
+ }
5818
+ type ReverseForwardEnd = {
5819
+ readonly kind: 'stopped';
5820
+ } | {
5821
+ readonly kind: 'lost';
5822
+ } | {
5823
+ readonly kind: 'failed';
5824
+ readonly code: string | null;
5825
+ readonly message: string;
5826
+ } | {
5827
+ readonly kind: 'closed';
5828
+ readonly code: number;
5829
+ readonly reason: string;
5830
+ };
5831
+ interface ReverseRelayHandlers {
5832
+ readonly onData: (data: Uint8Array) => Promise<void> | void;
5833
+ readonly onEof: () => void;
5834
+ readonly onClose: (lost: boolean) => void;
5835
+ }
5836
+ interface ReverseRelay {
5837
+ readonly send: (data: Uint8Array) => boolean;
5838
+ readonly waitForRoom: () => Promise<void>;
5839
+ readonly sendEof: () => void;
5840
+ readonly close: () => void;
5841
+ }
5842
+ interface ReverseForwardOptions {
5843
+ readonly baseUrl: string;
5844
+ readonly token: string | null;
5845
+ readonly name: string;
5846
+ readonly guest: ReverseGuest;
5847
+ readonly connect: (url: string, headers: Readonly<Record<string, string>>) => WebSocket;
5848
+ readonly onConnection: (accept: (handlers: ReverseRelayHandlers) => ReverseRelay) => void;
5849
+ }
5850
+ interface ReverseForward {
5851
+ readonly listening: Promise<ReverseListening>;
5852
+ readonly ended: Promise<ReverseForwardEnd>;
5853
+ readonly stop: () => void;
5854
+ }
5855
+ export declare function openReverseForward(options: Readonly<ReverseForwardOptions>): ReverseForward;
5856
+ //#endregion
5492
5857
  //#region src/exec/exec-error.d.ts
5493
5858
  type ExecClientErrorCode = 'UNAUTHORIZED' | 'UNREACHABLE' | 'RESTARTING' | 'CONNECTION_CLOSED' | 'DETACHED' | 'BAD_MESSAGE' | 'CLOSED' | 'OUTPUT_OVERFLOW' | 'LOCAL_ERROR';
5494
5859
  export declare class ExecError extends Error {
@@ -5500,4 +5865,4 @@ export declare class ExecError extends Error {
5500
5865
  }>);
5501
5866
  }
5502
5867
  //#endregion
5503
- export { type ApiCall, type AttachOptions, type Checkpoint, type ConsoleOptions, type DetachReason, type ExecClientErrorCode, type ExecExit, type ExecHandle, type ExecOptions, type ExecOutcome, type ExecSession, type ExecSessionOptions, type ExecStarted, type Identity, type Image, type Imp, type ImpClient, type ImpClientOptions, type ImpEvent, type ImpState, ORPCError, type RequireAwakeOptions, type RunOptions, type RunResult, type Scope, type ServerCheck, type Session, type SystemInfo, type Token, isDefinedError, safe };
5868
+ export { type ApiCall, type AttachOptions, type Checkpoint, type ConsoleOptions, type DetachReason, type ExecClientErrorCode, type ExecExit, type ExecHandle, type ExecOptions, type ExecOutcome, type ExecSession, type ExecSessionOptions, type ExecSocket, type ExecStarted, type Identity, type Image, type Imp, type ImpClient, type ImpClientOptions, type ImpEvent, type ImpState, ORPCError, type RequireAwakeOptions, type ReverseForward, type ReverseForwardEnd, type ReverseForwardOptions, type ReverseGuest, type ReverseListening, type ReverseRelay, type ReverseRelayHandlers, type RunOptions, type RunResult, type Scope, type ServerCheck, type Session, type SshKey, type SystemInfo, type Token, isDefinedError, safe };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { RPCLink } from "@orpc/client/fetch";
3
3
  import * as z from "zod";
4
4
  //#endregion
5
5
  //#region src/check-server.ts
6
- const CLIENT_VERSION = "0.7.0";
6
+ const CLIENT_VERSION = "0.8.0";
7
7
  async function checkServer(rpc) {
8
8
  const info = await rpc.system.info();
9
9
  return {
@@ -66,10 +66,14 @@ const ExecStartMessageSchema = z.object({
66
66
  cols: DimensionSchema.optional(),
67
67
  rows: DimensionSchema.optional(),
68
68
  session: SessionNameSchema.optional(),
69
- tool: z.enum(["tar"]).optional()
69
+ tool: z.enum(["tar"]).optional(),
70
+ killGraceMs: z.int().min(1).max(6e4).optional()
70
71
  }).refine((start) => start.session === void 0 || start.tty, {
71
72
  message: "a session needs a tty",
72
73
  path: ["tty"]
74
+ }).refine((start) => start.killGraceMs === void 0 || !start.tty, {
75
+ message: "a tty exec takes no kill grace",
76
+ path: ["killGraceMs"]
73
77
  }).refine((start) => start.tool === void 0 || !start.tty && start.session === void 0 && start.env === void 0 && start.cwd === void 0, {
74
78
  message: "a tool takes no tty, session, env or cwd",
75
79
  path: ["tool"]
@@ -104,7 +108,8 @@ const ExecServerMessageSchema = z.discriminatedUnion("type", [
104
108
  type: z.literal("started"),
105
109
  pid: z.int().positive(),
106
110
  session: SessionNameSchema.optional(),
107
- created: z.boolean().optional()
111
+ created: z.boolean().optional(),
112
+ groupKill: z.boolean().optional()
108
113
  }),
109
114
  z.object({
110
115
  type: z.literal("exit"),
@@ -148,6 +153,63 @@ function isExecChannel(value) {
148
153
  return value === EXEC_CHANNELS.stdin || value === EXEC_CHANNELS.stdout || value === EXEC_CHANNELS.stderr;
149
154
  }
150
155
  //#endregion
156
+ //#region ../api/src/tunnel-protocol.ts
157
+ const TUNNEL_PATH = "/tunnel";
158
+ const TUNNEL_CLOSE_NORMAL = 1e3;
159
+ const TUNNEL_CLOSE_PROTOCOL = 1002;
160
+ const TUNNEL_WINDOW_BYTES = 1048576;
161
+ const TUNNEL_MAX_FRAME_BYTES = 65536;
162
+ const AckSchema = z.object({
163
+ type: z.literal("ack"),
164
+ bytes: z.int().positive()
165
+ });
166
+ const TunnelListenSchema = z.object({
167
+ type: z.literal("listen"),
168
+ name: NameSchema,
169
+ network: z.enum(["unix", "tcp"]),
170
+ path: z.string().startsWith("/").nullable().optional(),
171
+ port: z.int().min(0).max(65535).optional()
172
+ }).refine((listen) => listen.network === "tcp" ? listen.port !== void 0 && listen.path === void 0 : listen.port === void 0, {
173
+ message: "tcp takes a port, unix a path or null",
174
+ path: ["network"]
175
+ });
176
+ z.discriminatedUnion("type", [
177
+ z.object({
178
+ type: z.literal("open"),
179
+ name: NameSchema,
180
+ port: z.int().min(1).max(65535)
181
+ }),
182
+ z.object({ type: z.literal("eof") }),
183
+ AckSchema,
184
+ TunnelListenSchema,
185
+ z.object({
186
+ type: z.literal("accept"),
187
+ name: NameSchema,
188
+ listener: z.string().min(1),
189
+ connection: z.int().positive()
190
+ })
191
+ ]);
192
+ const TunnelServerMessageSchema = z.discriminatedUnion("type", [
193
+ z.object({ type: z.literal("opened") }),
194
+ z.object({ type: z.literal("eof") }),
195
+ AckSchema,
196
+ z.object({
197
+ type: z.literal("listening"),
198
+ listener: z.string(),
199
+ path: z.string().nullable(),
200
+ port: z.int().nullable()
201
+ }),
202
+ z.object({
203
+ type: z.literal("connection"),
204
+ id: z.int().positive()
205
+ }),
206
+ z.object({
207
+ type: z.literal("error"),
208
+ message: z.string(),
209
+ code: z.string().optional()
210
+ })
211
+ ]);
212
+ //#endregion
151
213
  //#region ../api/src/login-shell.ts
152
214
  const CONSOLE_SHELL = [
153
215
  "uid=$(id -u 2>/dev/null) || uid=0",
@@ -272,7 +334,8 @@ function openExecSession(options) {
272
334
  options.onStarted({
273
335
  pid: message.pid,
274
336
  session: message.session ?? null,
275
- created: message.created ?? false
337
+ created: message.created ?? false,
338
+ groupKill: message.groupKill ?? false
276
339
  });
277
340
  } else if (message.type === "exit") resolveOutcome({
278
341
  kind: "exit",
@@ -407,7 +470,8 @@ function openExec(deps, name, argv, options = {}) {
407
470
  ...options.cwd !== void 0 && { cwd: options.cwd },
408
471
  ...options.cols !== void 0 && { cols: options.cols },
409
472
  ...options.rows !== void 0 && { rows: options.rows },
410
- ...options.session !== void 0 && { session: options.session }
473
+ ...options.session !== void 0 && { session: options.session },
474
+ ...options.killGraceMs !== void 0 && { killGraceMs: options.killGraceMs }
411
475
  });
412
476
  }
413
477
  function openAttach(deps, name, session, options = {}) {
@@ -459,7 +523,7 @@ async function openHandle(deps, options, tty, start) {
459
523
  onOutput: (channel, data) => {
460
524
  (channel === "stderr" ? stderr : stdout).push(data);
461
525
  },
462
- connect: (url) => new WebSocket(url),
526
+ connect: deps.connect ?? ((url) => new WebSocket(url)),
463
527
  ...deps.fetch !== void 0 && { fetch: deps.fetch }
464
528
  });
465
529
  const resolveHandle = (result) => {
@@ -701,7 +765,8 @@ function createImpClient(options) {
701
765
  rpc,
702
766
  baseUrl: options.url,
703
767
  token: token ?? null,
704
- ...customFetch !== void 0 && { fetch: customFetch }
768
+ ...customFetch !== void 0 && { fetch: customFetch },
769
+ ...options.connect !== void 0 && { connect: options.connect }
705
770
  };
706
771
  return {
707
772
  ...namespaces,
@@ -714,4 +779,210 @@ function createImpClient(options) {
714
779
  };
715
780
  }
716
781
  //#endregion
717
- export { CLIENT_VERSION, CONSOLE_SHELL, ExecError, ORPCError, createImpClient, isDefinedError, openExecSession, safe };
782
+ //#region src/reverse/open-reverse-forward.ts
783
+ function parseMessage(text) {
784
+ try {
785
+ const parsed = TunnelServerMessageSchema.safeParse(JSON.parse(text));
786
+ return parsed.success ? parsed.data : null;
787
+ } catch {
788
+ return null;
789
+ }
790
+ }
791
+ function buildListenMessage(name, guest) {
792
+ return guest.network === "tcp" ? {
793
+ type: "listen",
794
+ name,
795
+ network: "tcp",
796
+ port: guest.port
797
+ } : {
798
+ type: "listen",
799
+ name,
800
+ network: "unix",
801
+ path: guest.path
802
+ };
803
+ }
804
+ function openRelay(target, accept, handlers) {
805
+ const ws = target.connect(target.url, target.headers);
806
+ const state = {
807
+ opened: false,
808
+ unacked: 0,
809
+ done: false,
810
+ peerEof: false,
811
+ guestEof: false
812
+ };
813
+ const waiters = [];
814
+ const pending = [];
815
+ ws.binaryType = "arraybuffer";
816
+ const wakeWaiters = () => {
817
+ for (const wake of waiters.splice(0)) wake();
818
+ };
819
+ const sendText = (message) => {
820
+ if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify(message));
821
+ };
822
+ const sendFrames = (data) => {
823
+ for (let offset = 0; offset < data.byteLength; offset += TUNNEL_MAX_FRAME_BYTES) ws.send(Uint8Array.from(data.subarray(offset, offset + TUNNEL_MAX_FRAME_BYTES)));
824
+ };
825
+ const stopRelay = (lost) => {
826
+ if (state.done) return;
827
+ state.done = true;
828
+ wakeWaiters();
829
+ handlers.onClose(lost);
830
+ };
831
+ const sendAck = async (data) => {
832
+ await handlers.onData(data);
833
+ sendText({
834
+ type: "ack",
835
+ bytes: data.byteLength
836
+ });
837
+ };
838
+ const handleControl = (message) => {
839
+ if (message.type === "opened") {
840
+ state.opened = true;
841
+ for (const data of pending.splice(0)) sendFrames(data);
842
+ if (state.peerEof) sendText({ type: "eof" });
843
+ } else if (message.type === "eof") {
844
+ state.guestEof = true;
845
+ handlers.onEof();
846
+ } else if (message.type === "ack") {
847
+ state.unacked -= message.bytes;
848
+ if (state.unacked <= 1048576) wakeWaiters();
849
+ } else {
850
+ ws.close(TUNNEL_CLOSE_NORMAL, "relay failed");
851
+ stopRelay(true);
852
+ }
853
+ };
854
+ ws.addEventListener("open", () => {
855
+ sendText(accept);
856
+ });
857
+ ws.addEventListener("message", (event) => {
858
+ if (event.data instanceof ArrayBuffer) {
859
+ sendAck(new Uint8Array(event.data));
860
+ return;
861
+ }
862
+ const message = parseMessage(String(event.data));
863
+ if (message === null) {
864
+ ws.close(TUNNEL_CLOSE_PROTOCOL, "bad message");
865
+ stopRelay(true);
866
+ } else handleControl(message);
867
+ });
868
+ ws.addEventListener("close", (event) => {
869
+ stopRelay(event.code !== TUNNEL_CLOSE_NORMAL);
870
+ });
871
+ ws.addEventListener("error", () => {});
872
+ return {
873
+ send: (data) => {
874
+ if (state.done) return true;
875
+ if (state.opened) sendFrames(data);
876
+ else pending.push(Uint8Array.from(data));
877
+ state.unacked += data.byteLength;
878
+ return state.unacked <= TUNNEL_WINDOW_BYTES;
879
+ },
880
+ waitForRoom: async () => {
881
+ while (!state.done && state.unacked > 1048576) await new Promise((resolve) => {
882
+ waiters.push(resolve);
883
+ });
884
+ },
885
+ sendEof: () => {
886
+ state.peerEof = true;
887
+ if (state.opened) sendText({ type: "eof" });
888
+ },
889
+ close: () => {
890
+ if (ws.readyState === WebSocket.CONNECTING || ws.readyState === WebSocket.OPEN) ws.close(TUNNEL_CLOSE_NORMAL, "local side closed");
891
+ stopRelay(false);
892
+ }
893
+ };
894
+ }
895
+ function openReverseForward(options) {
896
+ const url = resolveImpdUrl(options.baseUrl, TUNNEL_PATH);
897
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
898
+ const headers = options.token === null ? {} : { authorization: `Bearer ${options.token}` };
899
+ const target = {
900
+ url: url.href,
901
+ headers,
902
+ connect: options.connect
903
+ };
904
+ const ws = options.connect(url.href, headers);
905
+ const listening = Promise.withResolvers();
906
+ const ended = Promise.withResolvers();
907
+ const relays = /* @__PURE__ */ new Set();
908
+ const state = {
909
+ listener: "",
910
+ done: false
911
+ };
912
+ const waitForListening = async () => {
913
+ try {
914
+ await listening.promise;
915
+ } catch {}
916
+ };
917
+ waitForListening();
918
+ const stopForward = (end) => {
919
+ if (state.done) return;
920
+ state.done = true;
921
+ for (const relay of relays) relay.close();
922
+ const why = end.kind === "failed" ? end.message : `the forward ${end.kind}`;
923
+ listening.reject(new Error(why));
924
+ ended.resolve(end);
925
+ };
926
+ const openClientRelay = (id) => {
927
+ const message = {
928
+ type: "accept",
929
+ name: options.name,
930
+ listener: state.listener,
931
+ connection: id
932
+ };
933
+ options.onConnection((handlers) => {
934
+ const relay = openRelay(target, message, {
935
+ ...handlers,
936
+ onClose: (lost) => {
937
+ relays.delete(relay);
938
+ handlers.onClose(lost);
939
+ }
940
+ });
941
+ relays.add(relay);
942
+ return relay;
943
+ });
944
+ };
945
+ const handleControl = (message) => {
946
+ if (message.type === "listening") {
947
+ state.listener = message.listener;
948
+ listening.resolve({
949
+ path: message.path,
950
+ port: message.port
951
+ });
952
+ } else if (message.type === "connection") openClientRelay(message.id);
953
+ else if (message.type === "error") stopForward({
954
+ kind: "failed",
955
+ code: message.code ?? null,
956
+ message: message.message
957
+ });
958
+ else ws.close(TUNNEL_CLOSE_PROTOCOL, "bad message");
959
+ };
960
+ ws.binaryType = "arraybuffer";
961
+ ws.addEventListener("open", () => {
962
+ ws.send(JSON.stringify(buildListenMessage(options.name, options.guest)));
963
+ });
964
+ ws.addEventListener("message", (event) => {
965
+ const message = event.data instanceof ArrayBuffer ? null : parseMessage(String(event.data));
966
+ if (message === null) ws.close(TUNNEL_CLOSE_PROTOCOL, "bad message");
967
+ else handleControl(message);
968
+ });
969
+ ws.addEventListener("close", (event) => {
970
+ if (event.code === 4e3) stopForward({ kind: "lost" });
971
+ else stopForward({
972
+ kind: "closed",
973
+ code: event.code,
974
+ reason: event.reason
975
+ });
976
+ });
977
+ ws.addEventListener("error", () => {});
978
+ return {
979
+ listening: listening.promise,
980
+ ended: ended.promise,
981
+ stop: () => {
982
+ if (ws.readyState === WebSocket.CONNECTING || ws.readyState === WebSocket.OPEN) ws.close(TUNNEL_CLOSE_NORMAL, "stopped");
983
+ stopForward({ kind: "stopped" });
984
+ }
985
+ };
986
+ }
987
+ //#endregion
988
+ export { CLIENT_VERSION, CONSOLE_SHELL, ExecError, ORPCError, createImpClient, isDefinedError, openExecSession, openReverseForward, safe };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/imp-client",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Typed client for impd, the imp host daemon: imps, checkpoints, images and exec",
5
5
  "license": "MIT",
6
6
  "repository": {