@mycadet/cli 0.13.0-dev.202611012320.cea2f8a → 0.13.0-dev.202611022129.ce2988d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
  2. package/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  3. package/node_modules/@mycadet/environments/package.json +1 -1
  4. package/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  5. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  6. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/package.json +1 -1
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  8. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
  9. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/package.json +1 -1
  10. package/node_modules/@mycadet/local-mode/package.json +1 -1
  11. package/node_modules/@mycadet/local-mode/src/__tests__/guardian-token-refresh.test.ts +0 -1
  12. package/node_modules/@mycadet/local-mode/src/__tests__/guardian-token.test.ts +0 -1
  13. package/{src/__tests__/config-utils.test.ts → node_modules/@mycadet/local-mode/src/__tests__/hatch-config.test.ts} +1 -1
  14. package/{src/__tests__/local-hatch-lock.test.ts → node_modules/@mycadet/local-mode/src/__tests__/hatch-lock.test.ts} +1 -1
  15. package/{src/__tests__/random-name.test.ts → node_modules/@mycadet/local-mode/src/__tests__/naming.test.ts} +1 -4
  16. package/node_modules/@mycadet/local-mode/src/__tests__/operations-hatch.test.ts +60 -0
  17. package/node_modules/@mycadet/local-mode/src/__tests__/operations-resolution.test.ts +340 -0
  18. package/node_modules/@mycadet/local-mode/src/__tests__/operations-retire.test.ts +7 -7
  19. package/node_modules/@mycadet/local-mode/src/__tests__/operations-routes.test.ts +634 -0
  20. package/node_modules/@mycadet/local-mode/src/__tests__/operations-sleep.test.ts +12 -4
  21. package/node_modules/@mycadet/local-mode/src/__tests__/operations-wake.test.ts +9 -3
  22. package/node_modules/@mycadet/local-mode/src/__tests__/pair.test.ts +0 -2
  23. package/node_modules/@mycadet/local-mode/src/__tests__/remotes-docker-pair.test.ts +3 -3
  24. package/node_modules/@mycadet/local-mode/src/__tests__/remotes-local-pair.test.ts +2 -2
  25. package/node_modules/@mycadet/local-mode/src/__tests__/remotes-local-retire.test.ts +0 -11
  26. package/node_modules/@mycadet/local-mode/src/__tests__/status.test.ts +1 -129
  27. package/node_modules/@mycadet/local-mode/src/cloud-registration.ts +614 -0
  28. package/node_modules/@mycadet/local-mode/src/daemon-readiness.ts +87 -11
  29. package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +0 -1
  30. package/node_modules/@mycadet/local-mode/src/guardian-token.ts +276 -6
  31. package/node_modules/@mycadet/local-mode/src/hatch.ts +0 -1
  32. package/node_modules/@mycadet/local-mode/src/index.ts +72 -18
  33. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +5 -5
  34. package/node_modules/@mycadet/local-mode/src/lockfile.ts +1 -2
  35. package/node_modules/@mycadet/local-mode/src/operations/hatch.ts +50 -0
  36. package/node_modules/@mycadet/local-mode/src/operations/list.ts +33 -0
  37. package/node_modules/@mycadet/local-mode/src/operations/machine.ts +1 -1
  38. package/node_modules/@mycadet/local-mode/src/operations/resolve.ts +56 -0
  39. package/node_modules/@mycadet/local-mode/src/operations/routes.ts +487 -32
  40. package/node_modules/@mycadet/local-mode/src/pair.ts +0 -5
  41. package/node_modules/@mycadet/local-mode/src/process.ts +1 -1
  42. package/node_modules/@mycadet/local-mode/src/provider-credentials.ts +495 -0
  43. package/node_modules/@mycadet/local-mode/src/provider-env-vars.ts +22 -0
  44. package/node_modules/@mycadet/local-mode/src/remotes/apple-container/retire.ts +0 -5
  45. package/node_modules/@mycadet/local-mode/src/remotes/docker/common.ts +1 -3
  46. package/node_modules/@mycadet/local-mode/src/remotes/docker/retire.ts +2 -10
  47. package/node_modules/@mycadet/local-mode/src/remotes/docker/wake.ts +0 -1
  48. package/node_modules/@mycadet/local-mode/src/remotes/local/common.ts +0 -4
  49. package/{src/lib/config-utils.ts → node_modules/@mycadet/local-mode/src/remotes/local/hatch-config.ts} +3 -3
  50. package/{src/lib/local-hatch-lock.ts → node_modules/@mycadet/local-mode/src/remotes/local/hatch-lock.ts} +6 -6
  51. package/node_modules/@mycadet/local-mode/src/remotes/local/hatch.ts +124 -0
  52. package/node_modules/@mycadet/local-mode/src/remotes/local/retire.ts +1 -6
  53. package/node_modules/@mycadet/local-mode/src/status.ts +1 -366
  54. package/node_modules/@mycadet/local-mode/src/upgrade.ts +0 -1
  55. package/node_modules/@mycadet/service-contracts/package.json +1 -1
  56. package/node_modules/@mycadet/shared/package.json +1 -1
  57. package/package.json +1 -2
  58. package/src/__tests__/app-command.test.ts +30 -45
  59. package/src/__tests__/app-server-state.test.ts +195 -0
  60. package/src/__tests__/app-tunnel-status.test.ts +1 -1
  61. package/src/__tests__/assistant-client-refresh.test.ts +0 -2
  62. package/src/__tests__/backup.test.ts +1 -1
  63. package/src/__tests__/bun.test.ts +1649 -0
  64. package/src/__tests__/client-tui-refresh.test.ts +0 -1
  65. package/src/__tests__/debug.test.ts +1 -1
  66. package/src/__tests__/devices.test.ts +1 -1
  67. package/src/__tests__/guardian-token.test.ts +5 -7
  68. package/src/__tests__/hatch-provider-secrets.test.ts +4 -2
  69. package/src/__tests__/helpers/guardian-token.ts +1 -2
  70. package/src/__tests__/host-teleport.test.ts +46 -26
  71. package/src/__tests__/llm-provider-env-var-parity.test.ts +1 -1
  72. package/src/__tests__/multi-local.test.ts +1 -1
  73. package/src/__tests__/provider-secrets.test.ts +2 -3
  74. package/src/__tests__/ps-cloud-status.test.ts +7 -7
  75. package/src/__tests__/root-restore-command.test.ts +1 -1
  76. package/src/__tests__/setup.test.ts +0 -3
  77. package/src/__tests__/tui-midsession-refresh.test.ts +0 -1
  78. package/src/__tests__/tunnel.test.ts +15 -296
  79. package/src/__tests__/upgrade-local.test.ts +4 -5
  80. package/src/__tests__/wake.test.ts +6 -544
  81. package/src/__tests__/web-dist.test.ts +39 -5
  82. package/src/commands/app.ts +25 -28
  83. package/src/commands/debug.ts +2 -1
  84. package/src/commands/devices.ts +2 -1
  85. package/src/commands/hatch.ts +70 -2
  86. package/src/commands/login.ts +3 -6
  87. package/src/commands/ps.ts +14 -12
  88. package/src/commands/setup.ts +3 -3
  89. package/src/commands/tunnel.ts +6 -9
  90. package/src/commands/upgrade.ts +1 -4
  91. package/src/commands/wake.ts +0 -11
  92. package/src/lib/api-key-check.ts +1 -1
  93. package/src/lib/assistant-config.ts +1 -43
  94. package/src/lib/cloud-client.ts +0 -404
  95. package/src/lib/cloud-login.ts +7 -110
  96. package/src/lib/guardian-token.ts +4 -297
  97. package/src/lib/host-teleport.ts +82 -51
  98. package/src/lib/provider-secrets.ts +7 -494
  99. package/src/lib/remotes/docker.ts +8 -8
  100. package/src/lib/remotes/local.ts +36 -150
  101. package/src/lib/root-backup.ts +1 -5
  102. package/src/lib/servers/bun.ts +1471 -0
  103. package/src/lib/sync-cloud-assistants.ts +2 -1
  104. package/src/lib/tunnel.ts +4 -239
  105. package/src/lib/tunnels/cloudflare.ts +6 -6
  106. package/src/lib/tunnels/ngrok.ts +3 -5
  107. package/src/lib/tunnels/tailscale.ts +1 -1
  108. package/src/lib/upgrade-lifecycle.ts +0 -35
  109. package/src/lib/web-dist.ts +47 -20
  110. package/src/shared/provider-env-vars.ts +3 -20
  111. package/node_modules/@mycadet/local-mode/src/ingress.ts +0 -229
  112. package/src/__tests__/assistant-api-key-resolution.test.ts +0 -102
  113. package/src/__tests__/nginx.test.ts +0 -2447
  114. package/src/lib/assistant-api-key-resolution.ts +0 -89
  115. package/src/lib/servers/nginx.ts +0 -1241
  116. /package/{src/lib/random-name.ts → node_modules/@mycadet/local-mode/src/naming.ts} +0 -0
@@ -264,7 +264,9 @@ describe("the operator route table — the scoped surface's wake arm", () => {
264
264
  "POST",
265
265
  );
266
266
  expect(match).not.toBeNull();
267
- const response = await match!.route.run(match!.assistantId);
267
+ const response = await match!.route.run({
268
+ assistantId: match!.assistantId,
269
+ });
268
270
  expect(response).not.toBeNull();
269
271
  expect(response!.status).toBe(204);
270
272
  });
@@ -273,7 +275,9 @@ describe("the operator route table — the scoped surface's wake arm", () => {
273
275
  seedEntry({ assistantId: "asst-local", cloud: "local", port: 7830 });
274
276
  const match = matchOperatorRequest("/v1/assistants/nobody/wake/", "POST");
275
277
  expect(match).not.toBeNull();
276
- const response = await match!.route.run(match!.assistantId);
278
+ const response = await match!.route.run({
279
+ assistantId: match!.assistantId,
280
+ });
277
281
  expect(response).toBeNull();
278
282
  });
279
283
 
@@ -288,7 +292,9 @@ describe("the operator route table — the scoped surface's wake arm", () => {
288
292
  "/v1/assistants/asst-local/wake/",
289
293
  "POST",
290
294
  );
291
- const response = (await match!.route.run(match!.assistantId))!;
295
+ const response = (await match!.route.run({
296
+ assistantId: match!.assistantId,
297
+ }))!;
292
298
  expect(response.status).toBe(500);
293
299
  expect(await response.json()).toEqual({ detail: "wake blew up" });
294
300
  });
@@ -272,7 +272,6 @@ describe("pairAssistant", () => {
272
272
  refreshToken: "",
273
273
  refreshTokenExpiresAt: 0,
274
274
  refreshAfter: "",
275
- isNew: false,
276
275
  deviceId: "dev-aaa",
277
276
  pairedGatewayUrl: "http://10.0.0.5:7830",
278
277
  });
@@ -284,7 +283,6 @@ describe("pairAssistant", () => {
284
283
  "refreshToken",
285
284
  "refreshTokenExpiresAt",
286
285
  "refreshAfter",
287
- "isNew",
288
286
  "deviceId",
289
287
  "leasedAt",
290
288
  "pairedGatewayUrl",
@@ -1,5 +1,5 @@
1
1
  import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
2
- import type { LockfileAssistant } from "../lockfile-contract";
2
+ import type { DockerAssistant } from "../lockfile-contract";
3
3
 
4
4
  // Snapshot the real modules before mocking so the module-scoped `afterAll`
5
5
  // below can restore them — bun runs every test file in one process with a
@@ -15,11 +15,11 @@ mock.module("../exec", () => ({
15
15
 
16
16
  const { pairDocker } = await import("../remotes/docker/pair");
17
17
 
18
- const entry = {
18
+ const entry: DockerAssistant = {
19
19
  assistantId: "assistant-123",
20
20
  cloud: "docker",
21
21
  port: 7831,
22
- } as unknown as LockfileAssistant;
22
+ };
23
23
 
24
24
  afterAll(() => {
25
25
  mock.module("../exec", () => realExec);
@@ -28,11 +28,11 @@ mock.module("../remotes/local/common", () => ({
28
28
 
29
29
  const { pairLocal } = await import("../remotes/local/pair");
30
30
 
31
- const entry = {
31
+ const entry: LocalAssistant = {
32
32
  assistantId: "asst-local",
33
33
  cloud: "local",
34
34
  port: 7830,
35
- } as unknown as LocalAssistant;
35
+ };
36
36
 
37
37
  afterAll(() => {
38
38
  mock.module("../exec", () => realExec);
@@ -24,7 +24,6 @@ const originalConfigHome = process.env.XDG_CONFIG_HOME;
24
24
  // `test-assistant.*` paths into sibling files, which then fail to find their
25
25
  // own archives.
26
26
  const realProcess = { ...(await import("../process")) };
27
- const realIngress = { ...(await import("../ingress")) };
28
27
  const realArchive = { ...(await import("../remotes/local/archive")) };
29
28
  const realLoopbackFetch = { ...(await import("../loopback-fetch")) };
30
29
  const realCloudAuth = { ...(await import("../cloud-auth")) };
@@ -39,18 +38,11 @@ const stopProcessByPidFileMock = mock(
39
38
  );
40
39
 
41
40
  const { DAEMON_STOP_TIMEOUT_MS } = await import("../lifecycle-budgets");
42
- const stopIngressNginxMock = mock(async (): Promise<boolean> => false);
43
-
44
41
  mock.module("../process", () => ({
45
42
  ...realProcess,
46
43
  stopProcessByPidFile: stopProcessByPidFileMock,
47
44
  }));
48
45
 
49
- mock.module("../ingress", () => ({
50
- ...realIngress,
51
- stopIngressNginx: stopIngressNginxMock,
52
- }));
53
-
54
46
  // Keep archive paths on the same filesystem as the test dir so rename doesn't
55
47
  // hit EXDEV (cross-device link).
56
48
  const retiredStagingDir = join(testDir, "retired");
@@ -95,7 +87,6 @@ mock.module("../cloud-auth", () => ({
95
87
  // leak into other test files in the same `bun test` run.
96
88
  afterAll(() => {
97
89
  mock.module("../process", () => realProcess);
98
- mock.module("../ingress", () => realIngress);
99
90
  mock.module("../remotes/local/archive", () => realArchive);
100
91
  mock.module("../loopback-fetch", () => realLoopbackFetch);
101
92
  mock.module("../cloud-auth", () => realCloudAuth);
@@ -113,8 +104,6 @@ describe("retireLocal — CES sibling stop", () => {
113
104
  beforeEach(() => {
114
105
  stopProcessByPidFileMock.mockReset();
115
106
  stopProcessByPidFileMock.mockResolvedValue(true);
116
- stopIngressNginxMock.mockReset();
117
- stopIngressNginxMock.mockResolvedValue(false);
118
107
 
119
108
  rmSync(instanceDir, { recursive: true, force: true });
120
109
  rmSync(join(testDir, "retired"), { recursive: true, force: true });
@@ -4,7 +4,7 @@ import { createServer, type Server } from "node:http";
4
4
  import { tmpdir } from "node:os";
5
5
  import path from "node:path";
6
6
 
7
- import { getLocalAssistantStatus, resolveLockfileInstanceDir } from "../status";
7
+ import { resolveLockfileInstanceDir } from "../status";
8
8
 
9
9
  let tempDir: string;
10
10
  let lockfilePath: string;
@@ -87,134 +87,6 @@ afterEach(() => {
87
87
  rmSync(tempDir, { recursive: true, force: true });
88
88
  });
89
89
 
90
- describe("getLocalAssistantStatus", () => {
91
- test("returns a structured error for unsafe assistant IDs", async () => {
92
- const result = await getLocalAssistantStatus("../other");
93
- expect(result.ok).toBe(false);
94
- expect(result.ok ? 200 : result.status).toBe(400);
95
- });
96
- test("returns sleeping when the assistant PID file is absent", async () => {
97
- writeLocalLockfile();
98
-
99
- expect(await getLocalAssistantStatus("local-1")).toEqual({
100
- ok: true,
101
- state: "sleeping",
102
- });
103
- });
104
-
105
- test("returns sleeping for local entries without recorded ports", async () => {
106
- writeLockfile({
107
- assistantId: "legacy-local",
108
- runtimeUrl: "http://127.0.0.1:30102",
109
- });
110
-
111
- expect(await getLocalAssistantStatus("legacy-local")).toEqual({
112
- ok: true,
113
- state: "sleeping",
114
- });
115
- });
116
-
117
- test("returns sleeping when the assistant PID file points at a dead process", async () => {
118
- writeLocalLockfile();
119
- writeAssistantPid("999999999");
120
-
121
- const result = await getLocalAssistantStatus("local-1");
122
-
123
- expect(result.ok).toBe(true);
124
- if (result.ok) {
125
- expect(result.state).toBe("sleeping");
126
- }
127
- });
128
-
129
- test("returns crashed when the assistant PID file is invalid", async () => {
130
- writeLocalLockfile();
131
- writeAssistantPid("not-a-pid");
132
-
133
- const result = await getLocalAssistantStatus("local-1");
134
-
135
- expect(result.ok).toBe(true);
136
- if (result.ok) {
137
- expect(result.state).toBe("crashed");
138
- expect(result.detail).toContain("PID file");
139
- }
140
- });
141
-
142
- test("returns starting when a fresh assistant PID is alive but health is not ready yet", async () => {
143
- writeLocalLockfile({
144
- instanceDir,
145
- daemonPort: await unusedPort(),
146
- port: 30102,
147
- });
148
- writeAssistantPid(String(process.pid));
149
-
150
- const result = await getLocalAssistantStatus("local-1");
151
-
152
- expect(result.ok).toBe(true);
153
- if (result.ok) {
154
- expect(result.state).toBe("starting");
155
- expect(result.pid).toBe(process.pid);
156
- }
157
- });
158
-
159
- test("returns crashed when an old live assistant PID is still not responding", async () => {
160
- writeLocalLockfile({
161
- instanceDir,
162
- daemonPort: await unusedPort(),
163
- port: 30102,
164
- });
165
- const pidPath = writeAssistantPid(String(process.pid));
166
- markStale(pidPath);
167
-
168
- const result = await getLocalAssistantStatus("local-1");
169
-
170
- expect(result.ok).toBe(true);
171
- if (result.ok) {
172
- expect(result.state).toBe("crashed");
173
- expect(result.detail).toContain("not responding");
174
- }
175
- });
176
-
177
- test("returns starting while the gateway is coming up for a freshly started assistant", async () => {
178
- const server = createServer((_req, res) => {
179
- res.writeHead(200, { "Content-Type": "application/json" });
180
- res.end(JSON.stringify({ status: "healthy" }));
181
- });
182
- const daemonPort = await listen(server);
183
- try {
184
- writeLocalLockfile({
185
- instanceDir,
186
- daemonPort,
187
- port: await unusedPort(),
188
- });
189
- writeAssistantPid(String(process.pid));
190
-
191
- const result = await getLocalAssistantStatus("local-1");
192
-
193
- expect(result.ok).toBe(true);
194
- if (result.ok) {
195
- expect(result.state).toBe("starting");
196
- expect(result.pid).toBe(process.pid);
197
- }
198
- } finally {
199
- await close(server);
200
- }
201
- });
202
-
203
- test("rejects non-local assistants", async () => {
204
- writeLockfile({
205
- assistantId: "platform-1",
206
- cloud: "cloud",
207
- runtimeUrl: "https://example.com",
208
- });
209
-
210
- expect(await getLocalAssistantStatus("platform-1")).toEqual({
211
- ok: false,
212
- status: 404,
213
- error: "Local assistant not found",
214
- });
215
- });
216
- });
217
-
218
90
  describe("resolveLockfileInstanceDir", () => {
219
91
  test("reads the instance dir from the parsed entry", () => {
220
92
  writeLocalLockfile();