@mycadet/cli 0.13.0-dev.202611141833.f5bfff5 → 0.13.0-dev.202611142107.f5e00a2

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 (20) hide show
  1. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
  2. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  3. package/node_modules/@mycadet/avatar-manifest/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/ipc-server-utils/package.json +1 -1
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
  8. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  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__/remotes-local-pair.test.ts +3 -1
  12. package/node_modules/@mycadet/local-mode/src/__tests__/upgrade-root-recovery.test.ts +1 -1
  13. package/node_modules/@mycadet/local-mode/src/index.ts +1 -0
  14. package/node_modules/@mycadet/local-mode/src/operations/pair.ts +10 -2
  15. package/node_modules/@mycadet/local-mode/src/remotes/local/common.ts +0 -4
  16. package/node_modules/@mycadet/service-contracts/package.json +1 -1
  17. package/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  18. package/node_modules/@mycadet/shared/package.json +1 -1
  19. package/package.json +1 -1
  20. package/src/commands/pair.ts +7 -6
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,6 +55,8 @@ export const CesRpcMethod = {
55
55
  ListCredentialRecords: "list_credential_records",
56
56
  /** Bulk-import credential records. */
57
57
  BulkSetCredentialRecords: "bulk_set_credential_records",
58
+ /** Collect CES's own log files for a diagnostic export (tar.gz, base64). */
59
+ ExportLogs: "export_logs",
58
60
  } as const;
59
61
 
60
62
  export type CesRpcMethod = (typeof CesRpcMethod)[keyof typeof CesRpcMethod];
@@ -72,9 +74,7 @@ export const UpdateCloudCredentialSchema = z.object({
72
74
  */
73
75
  assistantId: z.string().optional(),
74
76
  });
75
- export type UpdateCloudCredential = z.infer<
76
- typeof UpdateCloudCredentialSchema
77
- >;
77
+ export type UpdateCloudCredential = z.infer<typeof UpdateCloudCredentialSchema>;
78
78
 
79
79
  export const UpdateCloudCredentialResponseSchema = z.object({
80
80
  /** Whether the cloud credential was successfully updated. */
@@ -302,6 +302,28 @@ export type BulkSetCredentialRecordsResponse = z.infer<
302
302
  typeof BulkSetCredentialRecordsResponseSchema
303
303
  >;
304
304
 
305
+ // ---------------------------------------------------------------------------
306
+ // export_logs
307
+ // ---------------------------------------------------------------------------
308
+
309
+ export const ExportLogsSchema = z.object({
310
+ /** Inclusive range start (epoch ms); log files entirely before it are skipped. */
311
+ startTime: z.number().optional(),
312
+ /** Inclusive range end (epoch ms); log files entirely after it are skipped. */
313
+ endTime: z.number().optional(),
314
+ });
315
+ export type ExportLogs = z.infer<typeof ExportLogsSchema>;
316
+
317
+ export const ExportLogsResponseSchema = z.object({
318
+ /** tar.gz of the collected log files plus a manifest, base64-encoded. */
319
+ archiveBase64: z.string(),
320
+ /** Number of log files included in the archive. */
321
+ filesCollected: z.number(),
322
+ /** Cumulative size of the collected log files, before archiving. */
323
+ totalBytes: z.number(),
324
+ });
325
+ export type ExportLogsResponse = z.infer<typeof ExportLogsResponseSchema>;
326
+
305
327
  // ---------------------------------------------------------------------------
306
328
  // Full RPC contract type map
307
329
  // ---------------------------------------------------------------------------
@@ -355,6 +377,10 @@ export interface CesRpcContract {
355
377
  request: BulkSetCredentialRecords;
356
378
  response: BulkSetCredentialRecordsResponse;
357
379
  };
380
+ [CesRpcMethod.ExportLogs]: {
381
+ request: ExportLogs;
382
+ response: ExportLogsResponse;
383
+ };
358
384
  }
359
385
 
360
386
  /**
@@ -405,4 +431,8 @@ export const CesRpcSchemas = {
405
431
  request: BulkSetCredentialRecordsSchema,
406
432
  response: BulkSetCredentialRecordsResponseSchema,
407
433
  },
434
+ [CesRpcMethod.ExportLogs]: {
435
+ request: ExportLogsSchema,
436
+ response: ExportLogsResponseSchema,
437
+ },
408
438
  } as const;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,6 +55,8 @@ export const CesRpcMethod = {
55
55
  ListCredentialRecords: "list_credential_records",
56
56
  /** Bulk-import credential records. */
57
57
  BulkSetCredentialRecords: "bulk_set_credential_records",
58
+ /** Collect CES's own log files for a diagnostic export (tar.gz, base64). */
59
+ ExportLogs: "export_logs",
58
60
  } as const;
59
61
 
60
62
  export type CesRpcMethod = (typeof CesRpcMethod)[keyof typeof CesRpcMethod];
@@ -72,9 +74,7 @@ export const UpdateCloudCredentialSchema = z.object({
72
74
  */
73
75
  assistantId: z.string().optional(),
74
76
  });
75
- export type UpdateCloudCredential = z.infer<
76
- typeof UpdateCloudCredentialSchema
77
- >;
77
+ export type UpdateCloudCredential = z.infer<typeof UpdateCloudCredentialSchema>;
78
78
 
79
79
  export const UpdateCloudCredentialResponseSchema = z.object({
80
80
  /** Whether the cloud credential was successfully updated. */
@@ -302,6 +302,28 @@ export type BulkSetCredentialRecordsResponse = z.infer<
302
302
  typeof BulkSetCredentialRecordsResponseSchema
303
303
  >;
304
304
 
305
+ // ---------------------------------------------------------------------------
306
+ // export_logs
307
+ // ---------------------------------------------------------------------------
308
+
309
+ export const ExportLogsSchema = z.object({
310
+ /** Inclusive range start (epoch ms); log files entirely before it are skipped. */
311
+ startTime: z.number().optional(),
312
+ /** Inclusive range end (epoch ms); log files entirely after it are skipped. */
313
+ endTime: z.number().optional(),
314
+ });
315
+ export type ExportLogs = z.infer<typeof ExportLogsSchema>;
316
+
317
+ export const ExportLogsResponseSchema = z.object({
318
+ /** tar.gz of the collected log files plus a manifest, base64-encoded. */
319
+ archiveBase64: z.string(),
320
+ /** Number of log files included in the archive. */
321
+ filesCollected: z.number(),
322
+ /** Cumulative size of the collected log files, before archiving. */
323
+ totalBytes: z.number(),
324
+ });
325
+ export type ExportLogsResponse = z.infer<typeof ExportLogsResponseSchema>;
326
+
305
327
  // ---------------------------------------------------------------------------
306
328
  // Full RPC contract type map
307
329
  // ---------------------------------------------------------------------------
@@ -355,6 +377,10 @@ export interface CesRpcContract {
355
377
  request: BulkSetCredentialRecords;
356
378
  response: BulkSetCredentialRecordsResponse;
357
379
  };
380
+ [CesRpcMethod.ExportLogs]: {
381
+ request: ExportLogs;
382
+ response: ExportLogsResponse;
383
+ };
358
384
  }
359
385
 
360
386
  /**
@@ -405,4 +431,8 @@ export const CesRpcSchemas = {
405
431
  request: BulkSetCredentialRecordsSchema,
406
432
  response: BulkSetCredentialRecordsResponseSchema,
407
433
  },
434
+ [CesRpcMethod.ExportLogs]: {
435
+ request: ExportLogsSchema,
436
+ response: ExportLogsResponseSchema,
437
+ },
408
438
  } as const;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/local-mode",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -118,7 +118,9 @@ describe("pairLocal — running the gateway's own CLI is the local presence proo
118
118
  expect(result.ok).toBe(false);
119
119
  if (result.ok) throw new Error("expected refusal");
120
120
  expect(result.status).toBe(0);
121
- expect(result.error).toBe("could not parse the gateway's pair output");
121
+ expect(result.error).toBe(
122
+ "could not parse the gateway's pair output (stdout tail: not json at all)",
123
+ );
122
124
  });
123
125
 
124
126
  test("an exec failure (gateway down) comes back structured", async () => {
@@ -130,7 +130,7 @@ test("versioned restore installs roots into stopped target containers before fir
130
130
  await mockChildProcessSpawn((command, args) => {
131
131
  if (command === "docker" && args[0] === "inspect") {
132
132
  return {
133
- stdout: JSON.stringify(["ACTOR_TOKEN_SIGNING_KEY=" + "01".repeat(32)]),
133
+ stdout: JSON.stringify(["PATH=/usr/local/bin:/usr/bin"]),
134
134
  code: 0,
135
135
  pid: 4242,
136
136
  unref: () => {},
@@ -194,6 +194,7 @@ export {
194
194
 
195
195
  export { loopbackSafeFetch, isLoopbackUrl } from "./loopback-fetch";
196
196
  export {
197
+ pairCliStdoutToResult,
197
198
  pairDevice,
198
199
  type PairDeviceIdentity,
199
200
  type PairOperationResult,
@@ -23,17 +23,25 @@ export interface PairDeviceIdentity {
23
23
 
24
24
  /**
25
25
  * The gateway CLI prints the pair payload as single-line JSON; its last
26
- * stdout line is the answer (earlier lines may carry warnings).
26
+ * stdout line is the answer (earlier lines may carry warnings). The CLI
27
+ * itself runs with pino silenced, so the payload line is reliably last.
27
28
  */
28
29
  export function pairCliStdoutToResult(stdout: string): PairOperationResult {
29
30
  const lastLine = stdout.split("\n").filter(Boolean).pop() ?? "";
30
31
  try {
31
32
  return { ok: true, response: JSON.parse(lastLine) };
32
33
  } catch {
34
+ // The output is the only diagnostic for a failed lease — surface a
35
+ // bounded tail of it (the payload line never parsed, so it is not a
36
+ // live credential; earlier lines may still carry secrets, so keep the
37
+ // tail, not the whole stdout).
38
+ const tail = stdout.trimEnd().slice(-300);
33
39
  return {
34
40
  ok: false,
35
41
  status: 0,
36
- error: "could not parse the gateway's pair output",
42
+ error: `could not parse the gateway's pair output${
43
+ tail ? ` (stdout tail: ${tail})` : " (stdout was empty)"
44
+ }`,
37
45
  };
38
46
  }
39
47
  }
@@ -1150,10 +1150,6 @@ export async function startCes(
1150
1150
  writeFileSync(cesPidFile, String(ces.pid), "utf-8");
1151
1151
  }
1152
1152
 
1153
- // No blocking wait for the socket here: the assistant's overall health
1154
- // check owns CES readiness (it probes live and nudges the single-flight
1155
- // connect), and the daemon's own discovery retries absorb the bind window.
1156
- // Hatch proceeds as soon as the sibling is spawned.
1157
1153
  startupLog("✅ credential-executor started\n");
1158
1154
  }
1159
1155
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,6 +55,8 @@ export const CesRpcMethod = {
55
55
  ListCredentialRecords: "list_credential_records",
56
56
  /** Bulk-import credential records. */
57
57
  BulkSetCredentialRecords: "bulk_set_credential_records",
58
+ /** Collect CES's own log files for a diagnostic export (tar.gz, base64). */
59
+ ExportLogs: "export_logs",
58
60
  } as const;
59
61
 
60
62
  export type CesRpcMethod = (typeof CesRpcMethod)[keyof typeof CesRpcMethod];
@@ -72,9 +74,7 @@ export const UpdateCloudCredentialSchema = z.object({
72
74
  */
73
75
  assistantId: z.string().optional(),
74
76
  });
75
- export type UpdateCloudCredential = z.infer<
76
- typeof UpdateCloudCredentialSchema
77
- >;
77
+ export type UpdateCloudCredential = z.infer<typeof UpdateCloudCredentialSchema>;
78
78
 
79
79
  export const UpdateCloudCredentialResponseSchema = z.object({
80
80
  /** Whether the cloud credential was successfully updated. */
@@ -302,6 +302,28 @@ export type BulkSetCredentialRecordsResponse = z.infer<
302
302
  typeof BulkSetCredentialRecordsResponseSchema
303
303
  >;
304
304
 
305
+ // ---------------------------------------------------------------------------
306
+ // export_logs
307
+ // ---------------------------------------------------------------------------
308
+
309
+ export const ExportLogsSchema = z.object({
310
+ /** Inclusive range start (epoch ms); log files entirely before it are skipped. */
311
+ startTime: z.number().optional(),
312
+ /** Inclusive range end (epoch ms); log files entirely after it are skipped. */
313
+ endTime: z.number().optional(),
314
+ });
315
+ export type ExportLogs = z.infer<typeof ExportLogsSchema>;
316
+
317
+ export const ExportLogsResponseSchema = z.object({
318
+ /** tar.gz of the collected log files plus a manifest, base64-encoded. */
319
+ archiveBase64: z.string(),
320
+ /** Number of log files included in the archive. */
321
+ filesCollected: z.number(),
322
+ /** Cumulative size of the collected log files, before archiving. */
323
+ totalBytes: z.number(),
324
+ });
325
+ export type ExportLogsResponse = z.infer<typeof ExportLogsResponseSchema>;
326
+
305
327
  // ---------------------------------------------------------------------------
306
328
  // Full RPC contract type map
307
329
  // ---------------------------------------------------------------------------
@@ -355,6 +377,10 @@ export interface CesRpcContract {
355
377
  request: BulkSetCredentialRecords;
356
378
  response: BulkSetCredentialRecordsResponse;
357
379
  };
380
+ [CesRpcMethod.ExportLogs]: {
381
+ request: ExportLogs;
382
+ response: ExportLogsResponse;
383
+ };
358
384
  }
359
385
 
360
386
  /**
@@ -405,4 +431,8 @@ export const CesRpcSchemas = {
405
431
  request: BulkSetCredentialRecordsSchema,
406
432
  response: BulkSetCredentialRecordsResponseSchema,
407
433
  },
434
+ [CesRpcMethod.ExportLogs]: {
435
+ request: ExportLogsSchema,
436
+ response: ExportLogsResponseSchema,
437
+ },
408
438
  } as const;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/cli",
3
- "version": "0.13.0-dev.202611141833.f5bfff5",
3
+ "version": "0.13.0-dev.202611142107.f5e00a2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vargasjr-dev/mycadet-temp.git"
@@ -36,6 +36,7 @@ import {
36
36
  getAssistantDisplayName,
37
37
  lookupAssistantByIdentifier,
38
38
  loopbackSafeFetch,
39
+ pairCliStdoutToResult,
39
40
  pairDocker,
40
41
  pairLocal,
41
42
  } from "@mycadet/local-mode";
@@ -201,18 +202,18 @@ async function mintPairingChallengeOrExit(
201
202
  return parseMintedChallenge(stdout);
202
203
  }
203
204
 
204
- /** Parse the mint's last stdout line into the challenge response. */
205
+ /** Parse the mint's JSON stdout line into the challenge response. */
205
206
  function parseMintedChallenge(
206
207
  stdout: string,
207
208
  ): RemoteWebPairingChallengeResponse {
208
- const lastLine = stdout.split("\n").filter(Boolean).pop() ?? "";
209
- let challenge: RemoteWebPairingChallengeResponse;
210
- try {
211
- challenge = JSON.parse(lastLine) as RemoteWebPairingChallengeResponse;
212
- } catch {
209
+ // Same last-line JSON contract the guardian lease's pair door uses — the
210
+ // CLI runs with pino silenced, so the payload line is reliably last.
211
+ const parsed = pairCliStdoutToResult(stdout);
212
+ if (!parsed.ok) {
213
213
  console.error("Error: could not parse the gateway's pairing mint output.");
214
214
  process.exit(1);
215
215
  }
216
+ const challenge = parsed.response as RemoteWebPairingChallengeResponse;
216
217
  if (!challenge.deviceCode || !challenge.userCode) {
217
218
  console.error(
218
219
  "Error: the gateway's pairing mint output is missing the challenge codes.",