@mycompbox/compbox-cli 1.13.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.
Files changed (98) hide show
  1. package/.tsbuildinfo +1 -0
  2. package/commands/configure.d.ts +24 -0
  3. package/commands/configure.d.ts.map +1 -0
  4. package/commands/configure.js +170 -0
  5. package/commands/configure.js.map +1 -0
  6. package/commands/doctor.d.ts +136 -0
  7. package/commands/doctor.d.ts.map +1 -0
  8. package/commands/doctor.js +606 -0
  9. package/commands/doctor.js.map +1 -0
  10. package/commands/install.d.ts +3 -0
  11. package/commands/install.d.ts.map +1 -0
  12. package/commands/install.js +88 -0
  13. package/commands/install.js.map +1 -0
  14. package/commands/list.d.ts +3 -0
  15. package/commands/list.d.ts.map +1 -0
  16. package/commands/list.js +141 -0
  17. package/commands/list.js.map +1 -0
  18. package/commands/login.d.ts +15 -0
  19. package/commands/login.d.ts.map +1 -0
  20. package/commands/login.js +102 -0
  21. package/commands/login.js.map +1 -0
  22. package/commands/publish.d.ts +3 -0
  23. package/commands/publish.d.ts.map +1 -0
  24. package/commands/publish.js +102 -0
  25. package/commands/publish.js.map +1 -0
  26. package/commands/run.d.ts +76 -0
  27. package/commands/run.d.ts.map +1 -0
  28. package/commands/run.js +417 -0
  29. package/commands/run.js.map +1 -0
  30. package/commands/service.d.ts +29 -0
  31. package/commands/service.d.ts.map +1 -0
  32. package/commands/service.js +142 -0
  33. package/commands/service.js.map +1 -0
  34. package/commands/update.d.ts +3 -0
  35. package/commands/update.d.ts.map +1 -0
  36. package/commands/update.js +141 -0
  37. package/commands/update.js.map +1 -0
  38. package/index.d.ts +3 -0
  39. package/index.d.ts.map +1 -0
  40. package/index.js +8508 -0
  41. package/index.js.map +1 -0
  42. package/package.json +30 -0
  43. package/utils/agent-invoker.d.ts +393 -0
  44. package/utils/agent-invoker.d.ts.map +1 -0
  45. package/utils/agent-invoker.js +1632 -0
  46. package/utils/agent-invoker.js.map +1 -0
  47. package/utils/api-client.d.ts +54 -0
  48. package/utils/api-client.d.ts.map +1 -0
  49. package/utils/api-client.js +214 -0
  50. package/utils/api-client.js.map +1 -0
  51. package/utils/auth-client.d.ts +61 -0
  52. package/utils/auth-client.d.ts.map +1 -0
  53. package/utils/auth-client.js +135 -0
  54. package/utils/auth-client.js.map +1 -0
  55. package/utils/claude-runtime.d.ts +116 -0
  56. package/utils/claude-runtime.d.ts.map +1 -0
  57. package/utils/claude-runtime.js +291 -0
  58. package/utils/claude-runtime.js.map +1 -0
  59. package/utils/config-store.d.ts +128 -0
  60. package/utils/config-store.d.ts.map +1 -0
  61. package/utils/config-store.js +137 -0
  62. package/utils/config-store.js.map +1 -0
  63. package/utils/file-manager.d.ts +32 -0
  64. package/utils/file-manager.d.ts.map +1 -0
  65. package/utils/file-manager.js +208 -0
  66. package/utils/file-manager.js.map +1 -0
  67. package/utils/keychain.d.ts +46 -0
  68. package/utils/keychain.d.ts.map +1 -0
  69. package/utils/keychain.js +167 -0
  70. package/utils/keychain.js.map +1 -0
  71. package/utils/loopback.d.ts +45 -0
  72. package/utils/loopback.d.ts.map +1 -0
  73. package/utils/loopback.js +95 -0
  74. package/utils/loopback.js.map +1 -0
  75. package/utils/mailbox-client.d.ts +98 -0
  76. package/utils/mailbox-client.d.ts.map +1 -0
  77. package/utils/mailbox-client.js +178 -0
  78. package/utils/mailbox-client.js.map +1 -0
  79. package/utils/mcp-config-writer.d.ts +133 -0
  80. package/utils/mcp-config-writer.d.ts.map +1 -0
  81. package/utils/mcp-config-writer.js +184 -0
  82. package/utils/mcp-config-writer.js.map +1 -0
  83. package/utils/pack-bundler.d.ts +30 -0
  84. package/utils/pack-bundler.d.ts.map +1 -0
  85. package/utils/pack-bundler.js +141 -0
  86. package/utils/pack-bundler.js.map +1 -0
  87. package/utils/prompt.d.ts +31 -0
  88. package/utils/prompt.d.ts.map +1 -0
  89. package/utils/prompt.js +86 -0
  90. package/utils/prompt.js.map +1 -0
  91. package/utils/table-formatter.d.ts +42 -0
  92. package/utils/table-formatter.d.ts.map +1 -0
  93. package/utils/table-formatter.js +125 -0
  94. package/utils/table-formatter.js.map +1 -0
  95. package/utils/version-resolver.d.ts +31 -0
  96. package/utils/version-resolver.d.ts.map +1 -0
  97. package/utils/version-resolver.js +75 -0
  98. package/utils/version-resolver.js.map +1 -0
@@ -0,0 +1,136 @@
1
+ /**
2
+ * `compbox doctor` — verify the local setup end-to-end.
3
+ *
4
+ * Runs a series of independent checks, each printed with a clear
5
+ * PASS / FAIL / SKIP and a concrete remediation on failure:
6
+ * 1. Local config present (central URL + token).
7
+ * 2. Central API reachable over the network.
8
+ * 3. Token authenticates (GET /auth/me returns an identity).
9
+ * 4. Attribution: a user-scoped write resolves to the expected user id.
10
+ * 5. Machine paired — the stored machine token resolves against central
11
+ * (reported present/valid; the token value is NEVER printed).
12
+ * 6. MCP config written at the expected path (verifies the WRITTEN config
13
+ * file, not a locally installed MCP binary — the server auto-installs via
14
+ * `npx` on first use).
15
+ * 6.5 Central target — which central the MCP writes to (its API_BASE_URL).
16
+ * WARN-level (never fails): warns when it is a local/loopback endpoint or
17
+ * differs from the logged-in central, so work is never silently pointed at
18
+ * localhost instead of the cloud. The API token is never printed.
19
+ * 6.7 MCP launch target — the written entry must actually be launchable
20
+ * (ENG-141): `node` entries must point at a bundle that exists on disk
21
+ * and answers a short startup probe (hard 5s timeout so doctor can never
22
+ * hang — WARN on timeout); `npx` entries resolve from registry.npmjs.org
23
+ * on first use, so there is nothing local to verify.
24
+ * 7. AI mode configured (keychain key present, or subscription acknowledged).
25
+ * 8. macOS only — the Homebrew-managed service is running (best-effort; skips
26
+ * gracefully when `brew` is not on PATH).
27
+ * 9. pxpipe token proxy — reachable when enabled (SKIP when disabled). Agents
28
+ * fall back to direct calls if it is down, so this never hard-fails setup.
29
+ *
30
+ * Exits non-zero if any non-skipped check fails so it is usable in scripts.
31
+ */
32
+ import { Command } from 'commander';
33
+ import type { CompboxConfig } from '../utils/config-store.js';
34
+ import type { AgentRuntimeProbe } from '../utils/claude-runtime.js';
35
+ import type { McpConfigStatus } from '../utils/mcp-config-writer.js';
36
+ export interface CheckResult {
37
+ name: string;
38
+ passed: boolean;
39
+ detail: string;
40
+ /** Skipped checks are informational and never count as a failure. */
41
+ skipped?: boolean;
42
+ /**
43
+ * WARN-level checks surface a concern (e.g. writing to a localhost central)
44
+ * without failing the run. Like skipped checks, they never count as a failure
45
+ * or affect the exit code — they exist to keep the user informed.
46
+ */
47
+ warning?: boolean;
48
+ }
49
+ /**
50
+ * Compare two central URLs for equivalence so trivial formatting differences
51
+ * don't trip the central-target mismatch warning. Normalizes via WHATWG
52
+ * `new URL(u).href` (lowercases scheme/host, drops default ports such as
53
+ * `:443` for https and `:80` for http), falling back to plain string
54
+ * normalization for values that don't parse as URLs, then ignores trailing
55
+ * slashes.
56
+ *
57
+ * Intentionally NOT tolerant of http↔https or path differences (e.g. an
58
+ * `/api` suffix): those point at genuinely different targets, so they should
59
+ * still trigger the mismatch WARN.
60
+ */
61
+ export declare function sameCentralUrl(a: string, b: string): boolean;
62
+ /**
63
+ * Check 6.5: Central target — which central the MCP actually writes to.
64
+ * Uses the read-only API_BASE_URL from the written MCP entry (never the
65
+ * token). WARN-level only: localhost is valid in dev, so we surface — never
66
+ * block. Warns when the MCP writes to a local/loopback endpoint, OR when it
67
+ * targets a different central than the one this machine logged into.
68
+ * Extracted (and exported) so the WARN semantics are unit-testable.
69
+ */
70
+ export declare function centralTargetCheck(mcpStatus: Pick<McpConfigStatus, 'entryPresent' | 'apiBaseUrl'>, loggedInUrl: string | undefined): CheckResult;
71
+ /**
72
+ * Count hard failures: skipped checks are informational and WARN-level checks
73
+ * (e.g. a localhost central target) never fail the run or affect the exit
74
+ * code. Extracted (and exported) so this exclusion is unit-testable.
75
+ */
76
+ export declare function countFailures(results: CheckResult[]): number;
77
+ /**
78
+ * Hard upper bound for the launch-target startup probe. The probe must never
79
+ * hang `doctor`: after this many milliseconds the child is killed and the
80
+ * check reports WARN (not FAIL — a slow machine is not a broken setup).
81
+ */
82
+ export declare const LAUNCH_PROBE_TIMEOUT_MS = 5000;
83
+ /** Outcome of spawning the configured launch target (see probeLaunchTarget). */
84
+ export interface LaunchProbeResult {
85
+ status: 'answered' | 'timeout' | 'error';
86
+ /** Populated for `error`: why the target failed to start. */
87
+ detail?: string;
88
+ }
89
+ export type LaunchProbe = (command: string, args: string[]) => Promise<LaunchProbeResult>;
90
+ /**
91
+ * Spawn the configured MCP launch target and wait for its startup banner.
92
+ * The server logs `… started (stdio transport)` to stderr once the stdio
93
+ * transport is connected, so ANY output on stderr/stdout counts as an answer
94
+ * — the probe cares that the process starts, not what it says. Runs with a
95
+ * dummy API_TOKEN (env validation happens before the banner) pointing at an
96
+ * unroutable loopback port so the probe can never write to a real central.
97
+ * The child is always killed, and `timeoutMs` (default
98
+ * LAUNCH_PROBE_TIMEOUT_MS) guarantees the probe cannot hang.
99
+ */
100
+ export declare function probeLaunchTarget(command: string, args: string[], timeoutMs?: number): Promise<LaunchProbeResult>;
101
+ /**
102
+ * Check 6.7: MCP launch target — the entry `configure` wrote must actually be
103
+ * launchable (ENG-141). Semantics:
104
+ * - `node <bundle>`: FAIL when the bundle file is missing (broken install)
105
+ * or crashes on startup; WARN when it exists but does not answer within
106
+ * LAUNCH_PROBE_TIMEOUT_MS; PASS when it answers the startup probe.
107
+ * - `npx …`: nothing installed locally to verify — PASS with a note that
108
+ * the package resolves from registry.npmjs.org on first use.
109
+ * - No entry / no command / custom override command: SKIP (informational).
110
+ * Extracted (and exported) with injectable fs/spawn deps so every branch is
111
+ * unit-testable without touching the real filesystem or spawning processes.
112
+ */
113
+ export declare function launchTargetCheck(mcpStatus: Pick<McpConfigStatus, 'entryPresent' | 'command' | 'args'>, deps?: {
114
+ fileExists?: (path: string) => boolean;
115
+ probe?: LaunchProbe;
116
+ }): Promise<CheckResult>;
117
+ /** A zero-arg agent-runtime probe (matches probeAgentRuntime's default call). */
118
+ export type AgentRuntimeProbeFn = () => Promise<AgentRuntimeProbe>;
119
+ /**
120
+ * Check 7.5: Agent runtime (claude CLI) — only meaningful in
121
+ * `claude-subscription` mode, where the `compbox run` daemon must be able to
122
+ * spawn the local `claude` binary (ENG-135). Semantics:
123
+ * - api-key mode (or unset): SKIP — no `claude` needed, so this never
124
+ * affects the exit code.
125
+ * - claude-subscription + probe `ok`: PASS, echoing the version.
126
+ * - claude-subscription + probe `not-found`/`error`: FAIL with a remediation
127
+ * that lists the searched install locations (WELL_KNOWN_DIRS /
128
+ * claudeNotFoundMessage), the install link, and a note to re-run doctor.
129
+ * The probe is injectable (defaults to ENG-135 probeAgentRuntime) so every
130
+ * branch is unit-testable without spawning a real `claude`.
131
+ */
132
+ export declare function agentRuntimeCheck(config: Pick<CompboxConfig, 'aiMode'>, deps?: {
133
+ probe?: AgentRuntimeProbeFn;
134
+ }): Promise<CheckResult>;
135
+ export declare const doctorCommand: Command;
136
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAM9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAWpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAQrE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAA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