@mycadet/cli 0.13.0-dev.202610200020.9f20440 → 0.13.0-dev.202610201855.522ff0d
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/node_modules/@mycadet/assistant-api/constants/personality-sliders.test.ts +0 -8
- package/node_modules/@mycadet/assistant-api/constants/personality-sliders.ts +5 -41
- package/node_modules/@mycadet/assistant-api/events/message-complete.ts +0 -5
- package/node_modules/@mycadet/assistant-api/index.ts +0 -2
- package/node_modules/@mycadet/assistant-api/responses/conversation-message.ts +0 -10
- package/node_modules/@mycadet/environments/src/seeds.ts +6 -2
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/seeds.ts +6 -2
- package/node_modules/@mycadet/local-mode/src/config.ts +0 -2
- package/node_modules/@mycadet/local-mode/src/index.ts +1 -1
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +1 -22
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +26 -7
- package/node_modules/@mycadet/local-mode/src/util.ts +1 -20
- package/node_modules/@mycadet/shared/github-repository.ts +5 -0
- package/node_modules/@mycadet/shared/package.json +10 -0
- package/node_modules/@mycadet/shared/scripts/run-isolated-tests.ts +700 -0
- package/package.json +3 -2
- package/src/__tests__/app-command.test.ts +164 -0
- package/src/__tests__/client-web-config.test.ts +0 -1
- package/src/__tests__/cloud-releases.test.ts +1 -1
- package/src/__tests__/local-version.test.ts +16 -0
- package/src/__tests__/nginx-ingress.test.ts +248 -630
- package/src/__tests__/ps-cloud-status.test.ts +85 -11
- package/src/__tests__/root-process-lockfile.test.ts +29 -2
- package/src/__tests__/tunnel-holder-heal.test.ts +119 -0
- package/src/__tests__/tunnel-stop.test.ts +6 -13
- package/src/__tests__/tunnel.test.ts +50 -193
- package/src/__tests__/wake.test.ts +6 -38
- package/src/__tests__/web-dist.test.ts +267 -89
- package/src/commands/app.ts +113 -0
- package/src/commands/backup.ts +5 -4
- package/src/commands/clean.ts +2 -1
- package/src/commands/client.ts +5 -68
- package/src/commands/completions.ts +12 -1
- package/src/commands/connect.ts +2 -1
- package/src/commands/debug.ts +2 -1
- package/src/commands/exec.ts +7 -6
- package/src/commands/gateway/token.ts +2 -1
- package/src/commands/gateway.ts +2 -1
- package/src/commands/hatch.ts +74 -80
- package/src/commands/login.ts +7 -6
- package/src/commands/logs.ts +2 -1
- package/src/commands/ps.ts +136 -6
- package/src/commands/restart.ts +2 -1
- package/src/commands/restore.ts +10 -9
- package/src/commands/retire.ts +4 -3
- package/src/commands/setup.ts +5 -4
- package/src/commands/sleep.ts +3 -2
- package/src/commands/teleport.ts +2 -1
- package/src/commands/terminal.ts +7 -6
- package/src/commands/tunnel.ts +196 -242
- package/src/commands/uninstall.ts +2 -1
- package/src/commands/upgrade.ts +2 -1
- package/src/commands/use.ts +2 -1
- package/src/commands/wake.ts +3 -2
- package/src/index.ts +5 -4
- package/src/lib/__tests__/web-dist.test.ts +1 -27
- package/src/lib/assistant-config.ts +101 -37
- package/src/lib/cli-name.ts +14 -0
- package/src/lib/cloud-client.ts +2 -1
- package/src/lib/cloud-login-poll.ts +2 -1
- package/src/lib/cloud-releases.ts +1 -1
- package/src/lib/docker.ts +32 -21
- package/src/lib/hatch-local.ts +1 -3
- package/src/lib/hatch-next-steps.ts +1 -9
- package/src/lib/ingress-config.ts +0 -31
- package/src/lib/local-version.ts +25 -4
- package/src/lib/local.ts +34 -9
- package/src/lib/nginx-ingress.ts +143 -244
- package/src/lib/provider-secrets.ts +0 -5
- package/src/lib/statefulset.ts +0 -1
- package/src/lib/tunnel.ts +244 -43
- package/src/lib/tunnels/ngrok.ts +57 -9
- package/src/lib/tunnels/tailscale.ts +2 -1
- package/src/lib/web-dist.ts +134 -56
- package/src/__tests__/flags.test.ts +0 -318
- package/src/__tests__/shell-mode.test.ts +0 -83
- package/src/commands/flags.ts +0 -255
- package/src/lib/flag-args.test.ts +0 -84
- package/src/lib/flag-args.ts +0 -74
- package/src/lib/github-repository.ts +0 -2
|
@@ -95,8 +95,6 @@ const ensureTunnelEdgeMock = mock<typeof nginxIngress.ensureTunnelEdge>(
|
|
|
95
95
|
async () => ({
|
|
96
96
|
port: EDGE_PORT,
|
|
97
97
|
started: true,
|
|
98
|
-
includesWebApp: true,
|
|
99
|
-
shellMode: "web",
|
|
100
98
|
}),
|
|
101
99
|
);
|
|
102
100
|
const getNginxVersionMock = mock<typeof nginxIngress.getNginxVersion>(
|
|
@@ -264,6 +262,7 @@ describe("tunnel edge targeting", () => {
|
|
|
264
262
|
"bun",
|
|
265
263
|
"cadet",
|
|
266
264
|
"tunnel",
|
|
265
|
+
"start",
|
|
267
266
|
"--provider",
|
|
268
267
|
"tailscale",
|
|
269
268
|
"--foreground",
|
|
@@ -294,8 +293,6 @@ describe("tunnel edge targeting", () => {
|
|
|
294
293
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
295
294
|
port: EDGE_PORT,
|
|
296
295
|
started: true,
|
|
297
|
-
includesWebApp: true,
|
|
298
|
-
shellMode: "web",
|
|
299
296
|
});
|
|
300
297
|
});
|
|
301
298
|
|
|
@@ -338,6 +335,7 @@ describe("tunnel edge targeting", () => {
|
|
|
338
335
|
"bun",
|
|
339
336
|
"cadet",
|
|
340
337
|
"tunnel",
|
|
338
|
+
"start",
|
|
341
339
|
"--provider",
|
|
342
340
|
"ngrok",
|
|
343
341
|
"--foreground",
|
|
@@ -360,12 +358,14 @@ describe("tunnel edge targeting", () => {
|
|
|
360
358
|
expect(logs).toContain(`Started the nginx edge on 127.0.0.1:${EDGE_PORT}`);
|
|
361
359
|
});
|
|
362
360
|
|
|
363
|
-
test("the tunnel level notifies
|
|
364
|
-
|
|
361
|
+
test("the tunnel level notifies every local gateway of the public URL", async () => {
|
|
362
|
+
const second = makeLocalEntry("assistant-2");
|
|
363
|
+
writeLockfile([makeLocalEntry(), second]);
|
|
365
364
|
process.argv = [
|
|
366
365
|
"bun",
|
|
367
366
|
"cadet",
|
|
368
367
|
"tunnel",
|
|
368
|
+
"start",
|
|
369
369
|
"--provider",
|
|
370
370
|
"ngrok",
|
|
371
371
|
"--foreground",
|
|
@@ -374,11 +374,16 @@ describe("tunnel edge targeting", () => {
|
|
|
374
374
|
await runTunnelCapturingLogs();
|
|
375
375
|
|
|
376
376
|
// The provider hands its URL back; the notification is the tunnel
|
|
377
|
-
// level's job,
|
|
377
|
+
// level's job, and the domain is app-global info — every locally
|
|
378
|
+
// reachable assistant's gateway hears it, not just the edge's front.
|
|
378
379
|
expect(notifyGatewayOfPublicUrlMock).toHaveBeenCalledWith(
|
|
379
380
|
"https://test.example.ngrok.dev",
|
|
380
381
|
"assistant-1",
|
|
381
382
|
);
|
|
383
|
+
expect(notifyGatewayOfPublicUrlMock).toHaveBeenCalledWith(
|
|
384
|
+
"https://test.example.ngrok.dev",
|
|
385
|
+
"assistant-2",
|
|
386
|
+
);
|
|
382
387
|
});
|
|
383
388
|
|
|
384
389
|
test("an active cloud assistant falls back to the sole local entry with a note", async () => {
|
|
@@ -389,6 +394,7 @@ describe("tunnel edge targeting", () => {
|
|
|
389
394
|
"bun",
|
|
390
395
|
"cadet",
|
|
391
396
|
"tunnel",
|
|
397
|
+
"start",
|
|
392
398
|
"--provider",
|
|
393
399
|
"ngrok",
|
|
394
400
|
"--foreground",
|
|
@@ -413,15 +419,15 @@ describe("tunnel edge targeting", () => {
|
|
|
413
419
|
});
|
|
414
420
|
});
|
|
415
421
|
|
|
416
|
-
test("a
|
|
422
|
+
test("a docker assistant set active tunnels via its runtimeUrl gateway port", async () => {
|
|
417
423
|
const workspaceDir = useTempDefaultWorkspaceDir();
|
|
418
424
|
const local = makeLocalEntry();
|
|
419
|
-
writeLockfile([local, makeDockerEntry()],
|
|
425
|
+
writeLockfile([local, makeDockerEntry()], "docker-1");
|
|
420
426
|
process.argv = [
|
|
421
427
|
"bun",
|
|
422
428
|
"cadet",
|
|
423
429
|
"tunnel",
|
|
424
|
-
"
|
|
430
|
+
"start",
|
|
425
431
|
"--provider",
|
|
426
432
|
"ngrok",
|
|
427
433
|
"--foreground",
|
|
@@ -449,6 +455,7 @@ describe("tunnel edge targeting", () => {
|
|
|
449
455
|
"bun",
|
|
450
456
|
"cadet",
|
|
451
457
|
"tunnel",
|
|
458
|
+
"start",
|
|
452
459
|
"--provider",
|
|
453
460
|
"ngrok",
|
|
454
461
|
"--foreground",
|
|
@@ -476,6 +483,7 @@ describe("tunnel edge targeting", () => {
|
|
|
476
483
|
"bun",
|
|
477
484
|
"cadet",
|
|
478
485
|
"tunnel",
|
|
486
|
+
"start",
|
|
479
487
|
"--provider",
|
|
480
488
|
"ngrok",
|
|
481
489
|
"--foreground",
|
|
@@ -500,6 +508,7 @@ describe("tunnel edge targeting", () => {
|
|
|
500
508
|
"bun",
|
|
501
509
|
"cadet",
|
|
502
510
|
"tunnel",
|
|
511
|
+
"start",
|
|
503
512
|
"--provider",
|
|
504
513
|
"ngrok",
|
|
505
514
|
"--foreground",
|
|
@@ -526,6 +535,7 @@ describe("tunnel edge targeting", () => {
|
|
|
526
535
|
"bun",
|
|
527
536
|
"cadet",
|
|
528
537
|
"tunnel",
|
|
538
|
+
"start",
|
|
529
539
|
"--provider",
|
|
530
540
|
"ngrok",
|
|
531
541
|
"--foreground",
|
|
@@ -538,19 +548,20 @@ describe("tunnel edge targeting", () => {
|
|
|
538
548
|
"Assistant 'cloud-1' runs on Cadet Cloud and needs no tunnel.",
|
|
539
549
|
);
|
|
540
550
|
expect(errors).toContain(
|
|
541
|
-
"
|
|
551
|
+
"Multiple local assistants found; set the one to front with `cadet use <name>`.",
|
|
542
552
|
);
|
|
543
553
|
expect(ensureTunnelEdgeMock).not.toHaveBeenCalled();
|
|
544
554
|
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
545
555
|
});
|
|
546
556
|
|
|
547
|
-
test("a positional
|
|
557
|
+
test("a stray positional errors pointing at the subcommands", async () => {
|
|
548
558
|
const local = makeLocalEntry();
|
|
549
559
|
writeLockfile([makeCloudEntry(), local], local.assistantId);
|
|
550
560
|
process.argv = [
|
|
551
561
|
"bun",
|
|
552
562
|
"cadet",
|
|
553
563
|
"tunnel",
|
|
564
|
+
"start",
|
|
554
565
|
"cloud-1",
|
|
555
566
|
"--provider",
|
|
556
567
|
"ngrok",
|
|
@@ -560,74 +571,20 @@ describe("tunnel edge targeting", () => {
|
|
|
560
571
|
const { exited, errors } = await runTunnelExpectingExit1();
|
|
561
572
|
|
|
562
573
|
expect(exited).toBe(true);
|
|
563
|
-
expect(errors).toContain(
|
|
564
|
-
"Assistant 'cloud-1' runs on Cadet Cloud and needs no tunnel.",
|
|
565
|
-
);
|
|
566
|
-
expect(errors).toContain(
|
|
567
|
-
"Pass a local assistant as the name argument: assistant-1.",
|
|
568
|
-
);
|
|
574
|
+
expect(errors).toContain("takes no assistant name");
|
|
569
575
|
expect(ensureTunnelEdgeMock).not.toHaveBeenCalled();
|
|
570
576
|
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
571
577
|
});
|
|
572
578
|
|
|
573
|
-
test("
|
|
574
|
-
const local = makeLocalEntry();
|
|
575
|
-
local.name = "Ada";
|
|
576
|
-
writeLockfile([makeCloudEntry(), local], "cloud-1");
|
|
577
|
-
process.argv = [
|
|
578
|
-
"bun",
|
|
579
|
-
"cadet",
|
|
580
|
-
"tunnel",
|
|
581
|
-
"Ada",
|
|
582
|
-
"--provider",
|
|
583
|
-
"ngrok",
|
|
584
|
-
"--foreground",
|
|
585
|
-
];
|
|
586
|
-
|
|
587
|
-
await runTunnelCapturingLogs();
|
|
588
|
-
|
|
589
|
-
const workspaceDir = join(local.resources!.instanceDir, "workspace");
|
|
590
|
-
expect(runNgrokTunnelMock).toHaveBeenCalledWith({
|
|
591
|
-
port: EDGE_PORT,
|
|
592
|
-
assistantId: "assistant-1",
|
|
593
|
-
workspaceDir,
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
test("an unquoted multi-word display name resolves the local assistant", async () => {
|
|
598
|
-
const local = makeLocalEntry();
|
|
599
|
-
local.name = "Ada Lovelace";
|
|
600
|
-
writeLockfile([makeCloudEntry(), local], "cloud-1");
|
|
601
|
-
process.argv = [
|
|
602
|
-
"bun",
|
|
603
|
-
"cadet",
|
|
604
|
-
"tunnel",
|
|
605
|
-
"Ada",
|
|
606
|
-
"Lovelace",
|
|
607
|
-
"--provider",
|
|
608
|
-
"ngrok",
|
|
609
|
-
"--foreground",
|
|
610
|
-
];
|
|
611
|
-
|
|
612
|
-
await runTunnelCapturingLogs();
|
|
613
|
-
|
|
614
|
-
const workspaceDir = join(local.resources!.instanceDir, "workspace");
|
|
615
|
-
expect(runNgrokTunnelMock).toHaveBeenCalledWith({
|
|
616
|
-
port: EDGE_PORT,
|
|
617
|
-
assistantId: "assistant-1",
|
|
618
|
-
workspaceDir,
|
|
619
|
-
});
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
test("a positional apple-container assistant name tunnels via its runtimeUrl gateway port", async () => {
|
|
579
|
+
test("an apple-container assistant set active tunnels via its runtimeUrl gateway port", async () => {
|
|
623
580
|
const workspaceDir = useTempDefaultWorkspaceDir();
|
|
624
581
|
const local = makeLocalEntry();
|
|
625
|
-
writeLockfile([local, makeAppleContainerEntry()],
|
|
582
|
+
writeLockfile([local, makeAppleContainerEntry()], "apple-1");
|
|
626
583
|
process.argv = [
|
|
627
584
|
"bun",
|
|
628
585
|
"cadet",
|
|
629
586
|
"tunnel",
|
|
630
|
-
"
|
|
587
|
+
"start",
|
|
631
588
|
"--provider",
|
|
632
589
|
"ngrok",
|
|
633
590
|
"--foreground",
|
|
@@ -655,6 +612,7 @@ describe("tunnel edge targeting", () => {
|
|
|
655
612
|
"bun",
|
|
656
613
|
"cadet",
|
|
657
614
|
"tunnel",
|
|
615
|
+
"start",
|
|
658
616
|
"--provider",
|
|
659
617
|
"ngrok",
|
|
660
618
|
"--foreground",
|
|
@@ -678,101 +636,6 @@ describe("tunnel edge targeting", () => {
|
|
|
678
636
|
});
|
|
679
637
|
});
|
|
680
638
|
|
|
681
|
-
test("an exact assistant ID wins over a colliding display name", async () => {
|
|
682
|
-
const decoy = makeLocalEntry("assistant-a");
|
|
683
|
-
decoy.name = "assistant-b";
|
|
684
|
-
const target = makeLocalEntry("assistant-b");
|
|
685
|
-
writeLockfile([decoy, target], "assistant-a");
|
|
686
|
-
process.argv = [
|
|
687
|
-
"bun",
|
|
688
|
-
"cadet",
|
|
689
|
-
"tunnel",
|
|
690
|
-
"assistant-b",
|
|
691
|
-
"--provider",
|
|
692
|
-
"ngrok",
|
|
693
|
-
"--foreground",
|
|
694
|
-
];
|
|
695
|
-
|
|
696
|
-
await runTunnelCapturingLogs();
|
|
697
|
-
|
|
698
|
-
expect(runNgrokTunnelMock).toHaveBeenCalledWith(
|
|
699
|
-
expect.objectContaining({ assistantId: "assistant-b" }),
|
|
700
|
-
);
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
test("a positional display name of a cloud assistant errors without auto-fallback", async () => {
|
|
704
|
-
const cloud = makeCloudEntry();
|
|
705
|
-
cloud.name = "Cloudy";
|
|
706
|
-
const local = makeLocalEntry();
|
|
707
|
-
writeLockfile([cloud, local], local.assistantId);
|
|
708
|
-
process.argv = [
|
|
709
|
-
"bun",
|
|
710
|
-
"cadet",
|
|
711
|
-
"tunnel",
|
|
712
|
-
"Cloudy",
|
|
713
|
-
"--provider",
|
|
714
|
-
"ngrok",
|
|
715
|
-
"--foreground",
|
|
716
|
-
];
|
|
717
|
-
|
|
718
|
-
const { exited, errors } = await runTunnelExpectingExit1();
|
|
719
|
-
|
|
720
|
-
expect(exited).toBe(true);
|
|
721
|
-
expect(errors).toContain(
|
|
722
|
-
"Assistant 'Cloudy (cloud-1)' runs on Cadet Cloud and needs no tunnel.",
|
|
723
|
-
);
|
|
724
|
-
expect(errors).toContain(
|
|
725
|
-
"Pass a local assistant as the name argument: assistant-1.",
|
|
726
|
-
);
|
|
727
|
-
expect(ensureTunnelEdgeMock).not.toHaveBeenCalled();
|
|
728
|
-
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
test("an ambiguous positional display name errors listing the candidates", async () => {
|
|
732
|
-
const first = makeLocalEntry("assistant-a");
|
|
733
|
-
first.name = "Ada";
|
|
734
|
-
const second = makeLocalEntry("assistant-b");
|
|
735
|
-
second.name = "Ada";
|
|
736
|
-
writeLockfile([first, second], "assistant-a");
|
|
737
|
-
process.argv = [
|
|
738
|
-
"bun",
|
|
739
|
-
"cadet",
|
|
740
|
-
"tunnel",
|
|
741
|
-
"Ada",
|
|
742
|
-
"--provider",
|
|
743
|
-
"ngrok",
|
|
744
|
-
"--foreground",
|
|
745
|
-
];
|
|
746
|
-
|
|
747
|
-
const { exited, errors } = await runTunnelExpectingExit1();
|
|
748
|
-
|
|
749
|
-
expect(exited).toBe(true);
|
|
750
|
-
expect(errors).toContain(
|
|
751
|
-
"Multiple assistants match 'Ada': Ada (assistant-a), Ada (assistant-b).",
|
|
752
|
-
);
|
|
753
|
-
expect(ensureTunnelEdgeMock).not.toHaveBeenCalled();
|
|
754
|
-
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
test("an unknown positional name errors", async () => {
|
|
758
|
-
process.argv = [
|
|
759
|
-
"bun",
|
|
760
|
-
"cadet",
|
|
761
|
-
"tunnel",
|
|
762
|
-
"nope",
|
|
763
|
-
"--provider",
|
|
764
|
-
"ngrok",
|
|
765
|
-
"--foreground",
|
|
766
|
-
];
|
|
767
|
-
|
|
768
|
-
const { exited, errors } = await runTunnelExpectingExit1();
|
|
769
|
-
|
|
770
|
-
expect(exited).toBe(true);
|
|
771
|
-
expect(errors).toContain("No assistant found with name or ID 'nope'.");
|
|
772
|
-
expect(ensureTunnelEdgeMock).not.toHaveBeenCalled();
|
|
773
|
-
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
774
|
-
});
|
|
775
|
-
|
|
776
639
|
test("targets the edge port for cloudflare", async () => {
|
|
777
640
|
const entry = makeLocalEntry();
|
|
778
641
|
writeLockfile(entry);
|
|
@@ -780,6 +643,7 @@ describe("tunnel edge targeting", () => {
|
|
|
780
643
|
"bun",
|
|
781
644
|
"cadet",
|
|
782
645
|
"tunnel",
|
|
646
|
+
"start",
|
|
783
647
|
"--provider",
|
|
784
648
|
"cloudflare",
|
|
785
649
|
"--foreground",
|
|
@@ -795,13 +659,14 @@ describe("tunnel edge targeting", () => {
|
|
|
795
659
|
expect(runNgrokTunnelMock).not.toHaveBeenCalled();
|
|
796
660
|
});
|
|
797
661
|
|
|
798
|
-
test("targets the edge port for tailscale and notes a reused
|
|
662
|
+
test("targets the edge port for tailscale and notes a reused edge", async () => {
|
|
799
663
|
const entry = makeLocalEntry();
|
|
800
664
|
writeLockfile(entry);
|
|
801
665
|
process.argv = [
|
|
802
666
|
"bun",
|
|
803
667
|
"cadet",
|
|
804
668
|
"tunnel",
|
|
669
|
+
"start",
|
|
805
670
|
"--provider",
|
|
806
671
|
"tailscale",
|
|
807
672
|
"--foreground",
|
|
@@ -809,8 +674,6 @@ describe("tunnel edge targeting", () => {
|
|
|
809
674
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
810
675
|
port: EDGE_PORT,
|
|
811
676
|
started: false,
|
|
812
|
-
includesWebApp: false,
|
|
813
|
-
shellMode: "web",
|
|
814
677
|
});
|
|
815
678
|
|
|
816
679
|
const logs = await runTunnelCapturingLogs();
|
|
@@ -826,7 +689,7 @@ describe("tunnel edge targeting", () => {
|
|
|
826
689
|
test("a bare invocation tunnels the default provider", async () => {
|
|
827
690
|
const entry = makeLocalEntry();
|
|
828
691
|
writeLockfile(entry);
|
|
829
|
-
process.argv = ["bun", "cadet", "tunnel", "--foreground"];
|
|
692
|
+
process.argv = ["bun", "cadet", "tunnel", "start", "--foreground"];
|
|
830
693
|
|
|
831
694
|
const logs = await runTunnelCapturingLogs();
|
|
832
695
|
|
|
@@ -841,24 +704,6 @@ describe("tunnel edge targeting", () => {
|
|
|
841
704
|
expect(runCloudflareTunnelMock).not.toHaveBeenCalled();
|
|
842
705
|
});
|
|
843
706
|
|
|
844
|
-
test("a named assistant without --provider tunnels it with the default provider", async () => {
|
|
845
|
-
const entry = makeLocalEntry();
|
|
846
|
-
entry.name = "Ada";
|
|
847
|
-
writeLockfile(entry);
|
|
848
|
-
process.argv = ["bun", "cadet", "tunnel", "Ada", "--foreground"];
|
|
849
|
-
|
|
850
|
-
const logs = await runTunnelCapturingLogs();
|
|
851
|
-
|
|
852
|
-
expect(logs).toContain("Using the default provider: ngrok");
|
|
853
|
-
// The assistant that was asked for is the one tunneled.
|
|
854
|
-
expect(runNgrokTunnelMock).toHaveBeenCalledWith({
|
|
855
|
-
port: EDGE_PORT,
|
|
856
|
-
assistantId: entry.assistantId,
|
|
857
|
-
workspaceDir: join(entry.resources!.instanceDir, "workspace"),
|
|
858
|
-
});
|
|
859
|
-
expect(ensureTunnelEdgeMock).toHaveBeenCalled();
|
|
860
|
-
});
|
|
861
|
-
|
|
862
707
|
test("--provider tailscale keeps the webhook callback base and says so", async () => {
|
|
863
708
|
const entry = makeLocalEntry();
|
|
864
709
|
writeLockfile(entry);
|
|
@@ -869,6 +714,7 @@ describe("tunnel edge targeting", () => {
|
|
|
869
714
|
"bun",
|
|
870
715
|
"cadet",
|
|
871
716
|
"tunnel",
|
|
717
|
+
"start",
|
|
872
718
|
"--provider",
|
|
873
719
|
"tailscale",
|
|
874
720
|
"--foreground",
|
|
@@ -907,6 +753,7 @@ describe("tunnel edge targeting", () => {
|
|
|
907
753
|
"bun",
|
|
908
754
|
"cadet",
|
|
909
755
|
"tunnel",
|
|
756
|
+
"start",
|
|
910
757
|
"--provider",
|
|
911
758
|
"tailscale",
|
|
912
759
|
"--foreground",
|
|
@@ -931,6 +778,7 @@ describe("tunnel edge targeting", () => {
|
|
|
931
778
|
"bun",
|
|
932
779
|
"cadet",
|
|
933
780
|
"tunnel",
|
|
781
|
+
"start",
|
|
934
782
|
"--provider",
|
|
935
783
|
"ngrok",
|
|
936
784
|
"--foreground",
|
|
@@ -950,6 +798,7 @@ describe("tunnel edge targeting", () => {
|
|
|
950
798
|
"bun",
|
|
951
799
|
"cadet",
|
|
952
800
|
"tunnel",
|
|
801
|
+
"start",
|
|
953
802
|
"--provider",
|
|
954
803
|
"ngrok",
|
|
955
804
|
"--foreground",
|
|
@@ -978,6 +827,7 @@ describe("tunnel edge targeting", () => {
|
|
|
978
827
|
"bun",
|
|
979
828
|
"cadet",
|
|
980
829
|
"tunnel",
|
|
830
|
+
"start",
|
|
981
831
|
"--provider",
|
|
982
832
|
"bogus",
|
|
983
833
|
"--foreground",
|
|
@@ -1002,6 +852,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1002
852
|
"bun",
|
|
1003
853
|
"cadet",
|
|
1004
854
|
"tunnel",
|
|
855
|
+
"start",
|
|
1005
856
|
"--provider",
|
|
1006
857
|
provider,
|
|
1007
858
|
"--foreground",
|
|
@@ -1024,6 +875,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1024
875
|
"bun",
|
|
1025
876
|
"cadet",
|
|
1026
877
|
"tunnel",
|
|
878
|
+
"start",
|
|
1027
879
|
"--provider",
|
|
1028
880
|
"ngrok",
|
|
1029
881
|
"--domain",
|
|
@@ -1046,6 +898,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1046
898
|
"bun",
|
|
1047
899
|
"cadet",
|
|
1048
900
|
"tunnel",
|
|
901
|
+
"start",
|
|
1049
902
|
"--provider",
|
|
1050
903
|
"cloudflare",
|
|
1051
904
|
"--domain",
|
|
@@ -1073,6 +926,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1073
926
|
"bun",
|
|
1074
927
|
"cadet",
|
|
1075
928
|
"tunnel",
|
|
929
|
+
"start",
|
|
1076
930
|
"--provider",
|
|
1077
931
|
"ngrok",
|
|
1078
932
|
"--clear-domain",
|
|
@@ -1097,6 +951,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1097
951
|
"bun",
|
|
1098
952
|
"cadet",
|
|
1099
953
|
"tunnel",
|
|
954
|
+
"start",
|
|
1100
955
|
"--provider",
|
|
1101
956
|
"ngrok",
|
|
1102
957
|
"--domain",
|
|
@@ -1117,6 +972,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1117
972
|
"bun",
|
|
1118
973
|
"cadet",
|
|
1119
974
|
"tunnel",
|
|
975
|
+
"start",
|
|
1120
976
|
"--provider",
|
|
1121
977
|
"cloudflare",
|
|
1122
978
|
"--clear-domain",
|
|
@@ -1138,6 +994,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1138
994
|
"bun",
|
|
1139
995
|
"cadet",
|
|
1140
996
|
"tunnel",
|
|
997
|
+
"start",
|
|
1141
998
|
"--provider",
|
|
1142
999
|
"ngrok",
|
|
1143
1000
|
"--domain",
|
|
@@ -1158,6 +1015,7 @@ describe("tunnel edge targeting", () => {
|
|
|
1158
1015
|
"bun",
|
|
1159
1016
|
"cadet",
|
|
1160
1017
|
"tunnel",
|
|
1018
|
+
"start",
|
|
1161
1019
|
"--provider",
|
|
1162
1020
|
"cadet",
|
|
1163
1021
|
"--foreground",
|
|
@@ -1496,7 +1354,7 @@ describe("ngrok --domain spawn args", () => {
|
|
|
1496
1354
|
"does not match the reserved domain 'foo.ngrok.app'",
|
|
1497
1355
|
);
|
|
1498
1356
|
expect(combined).toContain(
|
|
1499
|
-
"cadet tunnel --provider ngrok --domain foo.ngrok.app",
|
|
1357
|
+
"cadet tunnel start --provider ngrok --domain foo.ngrok.app",
|
|
1500
1358
|
);
|
|
1501
1359
|
|
|
1502
1360
|
const config = IngressTestConfigSchema.parse(
|
|
@@ -1796,8 +1654,6 @@ describe("tunnel background mode", () => {
|
|
|
1796
1654
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
1797
1655
|
port: EDGE_PORT,
|
|
1798
1656
|
started: true,
|
|
1799
|
-
includesWebApp: true,
|
|
1800
|
-
shellMode: "web",
|
|
1801
1657
|
});
|
|
1802
1658
|
const configHome = mkdtempSync(join(tmpdir(), "cadet-tunnel-xdg-"));
|
|
1803
1659
|
tempDirs.push(configHome);
|
|
@@ -1817,7 +1673,7 @@ describe("tunnel background mode", () => {
|
|
|
1817
1673
|
});
|
|
1818
1674
|
|
|
1819
1675
|
test("runs detached by default: re-invokes itself as a detached child and reports readiness", async () => {
|
|
1820
|
-
process.argv = ["bun", "cadet", "tunnel", "--provider", "ngrok"];
|
|
1676
|
+
process.argv = ["bun", "cadet", "tunnel", "start", "--provider", "ngrok"];
|
|
1821
1677
|
|
|
1822
1678
|
// Simulate the detached child writing its readiness line to the log file
|
|
1823
1679
|
// the moment it is spawned.
|
|
@@ -1857,6 +1713,7 @@ describe("tunnel background mode", () => {
|
|
|
1857
1713
|
"bun",
|
|
1858
1714
|
"cadet",
|
|
1859
1715
|
"tunnel",
|
|
1716
|
+
"start",
|
|
1860
1717
|
"--provider",
|
|
1861
1718
|
"ngrok",
|
|
1862
1719
|
"--foreground",
|
|
@@ -1870,7 +1727,7 @@ describe("tunnel background mode", () => {
|
|
|
1870
1727
|
});
|
|
1871
1728
|
|
|
1872
1729
|
test("reports an early child exit instead of hanging", async () => {
|
|
1873
|
-
process.argv = ["bun", "cadet", "tunnel", "--provider", "ngrok"];
|
|
1730
|
+
process.argv = ["bun", "cadet", "tunnel", "start", "--provider", "ngrok"];
|
|
1874
1731
|
spawnMock.mockImplementationOnce(() => {
|
|
1875
1732
|
const child = makeFakeChild(4242);
|
|
1876
1733
|
// Listeners attach synchronously right after spawn() returns; defer the
|
|
@@ -1887,7 +1744,7 @@ describe("tunnel background mode", () => {
|
|
|
1887
1744
|
});
|
|
1888
1745
|
|
|
1889
1746
|
test("an adopted ngrok tunnel gets an accurate stop message, not a false kill claim", async () => {
|
|
1890
|
-
process.argv = ["bun", "cadet", "tunnel", "--provider", "ngrok"];
|
|
1747
|
+
process.argv = ["bun", "cadet", "tunnel", "start", "--provider", "ngrok"];
|
|
1891
1748
|
spawnMock.mockImplementationOnce(() => {
|
|
1892
1749
|
appendFileSync(
|
|
1893
1750
|
detachedLogPath(),
|
|
@@ -62,9 +62,9 @@ const dockerResourceNamesMock = mock<typeof docker.dockerResourceNames>(
|
|
|
62
62
|
realDocker.dockerResourceNames,
|
|
63
63
|
);
|
|
64
64
|
const wakeContainersMock = mock<typeof docker.wakeContainers>(async () => {});
|
|
65
|
-
const recreateDockerContainersMock = mock<
|
|
66
|
-
|
|
67
|
-
);
|
|
65
|
+
const recreateDockerContainersMock = mock<
|
|
66
|
+
typeof docker.recreateDockerContainers
|
|
67
|
+
>(async () => {});
|
|
68
68
|
|
|
69
69
|
mock.module("../lib/docker.js", () => ({
|
|
70
70
|
...realDocker,
|
|
@@ -173,7 +173,7 @@ mock.module("../lib/ingress-config.js", () => ({
|
|
|
173
173
|
}));
|
|
174
174
|
|
|
175
175
|
const ensureTunnelEdgeMock = mock<typeof nginxIngress.ensureTunnelEdge>(
|
|
176
|
-
async () => ({ port: 7840, started: true,
|
|
176
|
+
async () => ({ port: 7840, started: true, shellMode: "web" }),
|
|
177
177
|
);
|
|
178
178
|
const isIngressRunningMock = mock<typeof nginxIngress.isIngressRunning>(
|
|
179
179
|
() => false,
|
|
@@ -304,8 +304,6 @@ beforeEach(() => {
|
|
|
304
304
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
305
305
|
port: 7840,
|
|
306
306
|
started: true,
|
|
307
|
-
includesWebApp: true,
|
|
308
|
-
shellMode: "web",
|
|
309
307
|
});
|
|
310
308
|
isIngressRunningMock.mockReset();
|
|
311
309
|
isIngressRunningMock.mockReturnValue(false);
|
|
@@ -1031,7 +1029,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1031
1029
|
isIngressRunningMock.mockReturnValue(true);
|
|
1032
1030
|
readIngressStateMock.mockReturnValue({
|
|
1033
1031
|
listenPort: 7840,
|
|
1034
|
-
includeWebApp: true,
|
|
1035
1032
|
gatewayPort: 8030,
|
|
1036
1033
|
});
|
|
1037
1034
|
process.argv = ["bun", "cadet", "wake", "docker-1"];
|
|
@@ -1065,7 +1062,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1065
1062
|
isIngressRunningMock.mockReturnValue(true);
|
|
1066
1063
|
readIngressStateMock.mockReturnValue({
|
|
1067
1064
|
listenPort: 7840,
|
|
1068
|
-
includeWebApp: true,
|
|
1069
1065
|
gatewayPort: 7930,
|
|
1070
1066
|
});
|
|
1071
1067
|
// Ownership clears the restore, and `ensureTunnelEdge` is what decides the
|
|
@@ -1073,8 +1069,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1073
1069
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
1074
1070
|
port: 7840,
|
|
1075
1071
|
started: false,
|
|
1076
|
-
includesWebApp: true,
|
|
1077
|
-
shellMode: "web",
|
|
1078
1072
|
});
|
|
1079
1073
|
process.argv = ["bun", "cadet", "wake", "docker-1"];
|
|
1080
1074
|
|
|
@@ -1406,7 +1400,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1406
1400
|
isIngressRunningMock.mockReturnValue(true);
|
|
1407
1401
|
readIngressStateMock.mockReturnValue({
|
|
1408
1402
|
listenPort: 7845,
|
|
1409
|
-
includeWebApp: true,
|
|
1410
1403
|
gatewayPort: 7830,
|
|
1411
1404
|
remoteWebConfigHash: "fingerprint-of-an-older-edge-template",
|
|
1412
1405
|
});
|
|
@@ -1434,7 +1427,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1434
1427
|
isIngressRunningMock.mockReturnValue(true);
|
|
1435
1428
|
readIngressStateMock.mockReturnValue({
|
|
1436
1429
|
listenPort: 7845,
|
|
1437
|
-
includeWebApp: true,
|
|
1438
1430
|
gatewayPort: 7830,
|
|
1439
1431
|
remoteWebConfigHash: "fingerprint-of-an-older-edge-template",
|
|
1440
1432
|
});
|
|
@@ -1464,7 +1456,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1464
1456
|
isIngressRunningMock.mockReturnValue(true);
|
|
1465
1457
|
readIngressStateMock.mockReturnValue({
|
|
1466
1458
|
listenPort: 7845,
|
|
1467
|
-
includeWebApp: true,
|
|
1468
1459
|
gatewayPort: 7831,
|
|
1469
1460
|
});
|
|
1470
1461
|
ensureTunnelEdgeMock.mockRejectedValue(
|
|
@@ -1480,27 +1471,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1480
1471
|
);
|
|
1481
1472
|
});
|
|
1482
1473
|
|
|
1483
|
-
test("a failed rebuild falls back to the gateway port when only a webhooks-only edge survives", async () => {
|
|
1484
|
-
loadRawConfigMock.mockReturnValue(webhookConfig);
|
|
1485
|
-
isIngressRunningMock.mockReturnValue(true);
|
|
1486
|
-
readIngressStateMock.mockReturnValue({
|
|
1487
|
-
listenPort: 7845,
|
|
1488
|
-
includeWebApp: false,
|
|
1489
|
-
gatewayPort: 7830,
|
|
1490
|
-
});
|
|
1491
|
-
ensureTunnelEdgeMock.mockRejectedValue(
|
|
1492
|
-
new Error("The nginx edge is still running in webhooks-only mode."),
|
|
1493
|
-
);
|
|
1494
|
-
|
|
1495
|
-
await wake();
|
|
1496
|
-
|
|
1497
|
-
expect(maybeStartNgrokTunnelMock).toHaveBeenCalledWith(
|
|
1498
|
-
7830,
|
|
1499
|
-
workspaceDirOf(tempDir),
|
|
1500
|
-
"local-assistant",
|
|
1501
|
-
);
|
|
1502
|
-
});
|
|
1503
|
-
|
|
1504
1474
|
test("nginx-missing falls back to the gateway-port tunnel with a warning", async () => {
|
|
1505
1475
|
loadRawConfigMock.mockReturnValue(webhookConfig);
|
|
1506
1476
|
ensureTunnelEdgeMock.mockRejectedValue(
|
|
@@ -1543,7 +1513,7 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1543
1513
|
|
|
1544
1514
|
expect(warnSpy).toHaveBeenCalledWith(
|
|
1545
1515
|
expect.stringContaining(
|
|
1546
|
-
"Run `cadet tunnel
|
|
1516
|
+
"Run `cadet tunnel start --provider cloudflare` to rebuild the edge.",
|
|
1547
1517
|
),
|
|
1548
1518
|
);
|
|
1549
1519
|
});
|
|
@@ -1570,7 +1540,7 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1570
1540
|
|
|
1571
1541
|
expect(warnSpy).toHaveBeenCalledWith(
|
|
1572
1542
|
expect.stringContaining(
|
|
1573
|
-
"Run `cadet tunnel
|
|
1543
|
+
"Run `cadet tunnel start --provider tailscale` to rebuild the edge.",
|
|
1574
1544
|
),
|
|
1575
1545
|
);
|
|
1576
1546
|
});
|
|
@@ -1580,8 +1550,6 @@ describe("cadet wake — tunnel edge restore", () => {
|
|
|
1580
1550
|
ensureTunnelEdgeMock.mockResolvedValue({
|
|
1581
1551
|
port: 7841,
|
|
1582
1552
|
started: false,
|
|
1583
|
-
includesWebApp: true,
|
|
1584
|
-
shellMode: "web",
|
|
1585
1553
|
});
|
|
1586
1554
|
|
|
1587
1555
|
await wake();
|