@nextclaw/service 0.1.1

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 (242) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cli/commands/agent/agent-runtime.utils.d.ts +15 -0
  3. package/dist/cli/commands/agent/agent-runtime.utils.js +85 -0
  4. package/dist/cli/commands/agent/cli-agent-runner.utils.d.ts +21 -0
  5. package/dist/cli/commands/agent/cli-agent-runner.utils.js +89 -0
  6. package/dist/cli/commands/agent/index.d.ts +3 -0
  7. package/dist/cli/commands/agent/index.js +3 -0
  8. package/dist/cli/commands/agent/services/agent-commands.service.d.ts +17 -0
  9. package/dist/cli/commands/agent/services/agent-commands.service.js +112 -0
  10. package/dist/cli/commands/companion/index.d.ts +15 -0
  11. package/dist/cli/commands/companion/index.js +24 -0
  12. package/dist/cli/commands/companion/services/companion-process.service.d.ts +17 -0
  13. package/dist/cli/commands/companion/services/companion-process.service.js +49 -0
  14. package/dist/cli/commands/config/index.d.ts +2 -0
  15. package/dist/cli/commands/config/index.js +2 -0
  16. package/dist/cli/commands/config/services/config-commands.service.d.ts +18 -0
  17. package/dist/cli/commands/config/services/config-commands.service.js +133 -0
  18. package/dist/cli/commands/cron/index.d.ts +2 -0
  19. package/dist/cli/commands/cron/index.js +2 -0
  20. package/dist/cli/commands/cron/services/cron-commands.service.d.ts +22 -0
  21. package/dist/cli/commands/cron/services/cron-commands.service.js +107 -0
  22. package/dist/cli/commands/cron/services/cron-local.service.d.ts +25 -0
  23. package/dist/cli/commands/cron/services/cron-local.service.js +95 -0
  24. package/dist/cli/commands/cron/utils/cron-job.utils.d.ts +31 -0
  25. package/dist/cli/commands/cron/utils/cron-job.utils.js +15 -0
  26. package/dist/cli/commands/diagnostics/index.d.ts +2 -0
  27. package/dist/cli/commands/diagnostics/index.js +2 -0
  28. package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.d.ts +22 -0
  29. package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.js +319 -0
  30. package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.d.ts +23 -0
  31. package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.js +66 -0
  32. package/dist/cli/commands/gateway/index.d.ts +14 -0
  33. package/dist/cli/commands/gateway/index.js +15 -0
  34. package/dist/cli/commands/logs/index.d.ts +12 -0
  35. package/dist/cli/commands/logs/index.js +29 -0
  36. package/dist/cli/commands/mcp/index.d.ts +14 -0
  37. package/dist/cli/commands/mcp/index.js +193 -0
  38. package/dist/cli/commands/restart/index.d.ts +20 -0
  39. package/dist/cli/commands/restart/index.js +88 -0
  40. package/dist/cli/commands/secrets/index.d.ts +22 -0
  41. package/dist/cli/commands/secrets/index.js +280 -0
  42. package/dist/cli/commands/serve/index.d.ts +14 -0
  43. package/dist/cli/commands/serve/index.js +19 -0
  44. package/dist/cli/commands/skills/index.d.ts +26 -0
  45. package/dist/cli/commands/skills/index.js +147 -0
  46. package/dist/cli/commands/skills/marketplace-client.d.ts +31 -0
  47. package/dist/cli/commands/skills/marketplace-client.js +84 -0
  48. package/dist/cli/commands/skills/marketplace-command-options.utils.d.ts +25 -0
  49. package/dist/cli/commands/skills/marketplace-command-options.utils.js +31 -0
  50. package/dist/cli/commands/skills/marketplace-identity.utils.d.ts +14 -0
  51. package/dist/cli/commands/skills/marketplace-identity.utils.js +77 -0
  52. package/dist/cli/commands/skills/marketplace-network-retry.d.ts +4 -0
  53. package/dist/cli/commands/skills/marketplace-network-retry.js +32 -0
  54. package/dist/cli/commands/skills/marketplace.metadata.d.ts +29 -0
  55. package/dist/cli/commands/skills/marketplace.metadata.js +158 -0
  56. package/dist/cli/commands/skills/marketplace.service.d.ts +46 -0
  57. package/dist/cli/commands/skills/marketplace.service.js +238 -0
  58. package/dist/cli/commands/skills/skills-query.service.d.ts +141 -0
  59. package/dist/cli/commands/skills/skills-query.service.js +212 -0
  60. package/dist/cli/commands/start/index.d.ts +18 -0
  61. package/dist/cli/commands/start/index.js +25 -0
  62. package/dist/cli/commands/stop/index.d.ts +12 -0
  63. package/dist/cli/commands/stop/index.js +11 -0
  64. package/dist/cli/commands/ui/index.d.ts +14 -0
  65. package/dist/cli/commands/ui/index.js +17 -0
  66. package/dist/cli/commands/usage/index.d.ts +2 -0
  67. package/dist/cli/commands/usage/index.js +2 -0
  68. package/dist/cli/commands/usage/services/llm-usage-command.service.d.ts +22 -0
  69. package/dist/cli/commands/usage/services/llm-usage-command.service.js +160 -0
  70. package/dist/cli/commands/usage/services/llm-usage-query.service.d.ts +43 -0
  71. package/dist/cli/commands/usage/services/llm-usage-query.service.js +85 -0
  72. package/dist/commands/channel/channel-config-view.d.ts +7 -0
  73. package/dist/commands/channel/channel-config-view.js +7 -0
  74. package/dist/commands/channel/index.d.ts +28 -0
  75. package/dist/commands/channel/index.js +224 -0
  76. package/dist/commands/platform-auth/index.d.ts +2 -0
  77. package/dist/commands/platform-auth/index.js +2 -0
  78. package/dist/commands/platform-auth/services/account-status.service.d.ts +18 -0
  79. package/dist/commands/platform-auth/services/account-status.service.js +34 -0
  80. package/dist/commands/platform-auth/services/platform-auth-commands.service.d.ts +77 -0
  81. package/dist/commands/platform-auth/services/platform-auth-commands.service.js +295 -0
  82. package/dist/commands/platform-auth/utils/payload.utils.d.ts +28 -0
  83. package/dist/commands/platform-auth/utils/payload.utils.js +87 -0
  84. package/dist/commands/plugin/development-source/dev-plugin-overrides.utils.d.ts +18 -0
  85. package/dist/commands/plugin/development-source/dev-plugin-overrides.utils.js +111 -0
  86. package/dist/commands/plugin/development-source/first-party-plugin-load-paths.d.ts +9 -0
  87. package/dist/commands/plugin/development-source/first-party-plugin-load-paths.js +183 -0
  88. package/dist/commands/plugin/index.d.ts +30 -0
  89. package/dist/commands/plugin/index.js +266 -0
  90. package/dist/commands/plugin/plugin-command-utils.d.ts +13 -0
  91. package/dist/commands/plugin/plugin-command-utils.js +37 -0
  92. package/dist/commands/plugin/plugin-extension-registry.d.ts +10 -0
  93. package/dist/commands/plugin/plugin-extension-registry.js +35 -0
  94. package/dist/commands/plugin/plugin-mutation-actions.d.ts +15 -0
  95. package/dist/commands/plugin/plugin-mutation-actions.js +162 -0
  96. package/dist/commands/plugin/plugin-registry-loader.d.ts +15 -0
  97. package/dist/commands/plugin/plugin-registry-loader.js +43 -0
  98. package/dist/commands/plugin/plugin-reload.d.ts +13 -0
  99. package/dist/commands/plugin/plugin-reload.js +42 -0
  100. package/dist/commands/remote/index.d.ts +47 -0
  101. package/dist/commands/remote/index.js +174 -0
  102. package/dist/commands/remote/services/remote-access-host.service.d.ts +41 -0
  103. package/dist/commands/remote/services/remote-access-host.service.js +126 -0
  104. package/dist/commands/remote/services/remote-runtime-support.service.d.ts +15 -0
  105. package/dist/commands/remote/services/remote-runtime-support.service.js +79 -0
  106. package/dist/commands/remote/services/remote-service-control.service.d.ts +33 -0
  107. package/dist/commands/remote/services/remote-service-control.service.js +188 -0
  108. package/dist/commands/remote/utils/platform-api-base.utils.d.ts +14 -0
  109. package/dist/commands/remote/utils/platform-api-base.utils.js +39 -0
  110. package/dist/commands/service/index.d.ts +16 -0
  111. package/dist/commands/service/index.js +31 -0
  112. package/dist/commands/service/services/autostart/host-autostart-command.service.d.ts +29 -0
  113. package/dist/commands/service/services/autostart/host-autostart-command.service.js +158 -0
  114. package/dist/commands/service/services/autostart/host-autostart-runtime.service.d.ts +23 -0
  115. package/dist/commands/service/services/autostart/host-autostart-runtime.service.js +53 -0
  116. package/dist/commands/service/services/autostart/host-autostart.service.d.ts +41 -0
  117. package/dist/commands/service/services/autostart/host-autostart.service.js +48 -0
  118. package/dist/commands/service/services/autostart/linux-systemd-autostart.service.d.ts +48 -0
  119. package/dist/commands/service/services/autostart/linux-systemd-autostart.service.js +433 -0
  120. package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.d.ts +54 -0
  121. package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.js +405 -0
  122. package/dist/commands/service/services/autostart/windows-task-autostart.service.d.ts +54 -0
  123. package/dist/commands/service/services/autostart/windows-task-autostart.service.js +403 -0
  124. package/dist/commands/service/types/autostart/host-autostart.types.d.ts +64 -0
  125. package/dist/commands/service/types/autostart/host-autostart.types.js +1 -0
  126. package/dist/index.d.ts +4 -0
  127. package/dist/index.js +3 -0
  128. package/dist/launcher/npm-runtime-bundle-layout.store.d.ts +23 -0
  129. package/dist/launcher/npm-runtime-bundle-layout.store.js +37 -0
  130. package/dist/launcher/npm-runtime-bundle-manifest.service.d.ts +9 -0
  131. package/dist/launcher/npm-runtime-bundle-manifest.service.js +39 -0
  132. package/dist/launcher/npm-runtime-bundle.service.d.ts +47 -0
  133. package/dist/launcher/npm-runtime-bundle.service.js +150 -0
  134. package/dist/launcher/npm-runtime-bundle.types.d.ts +49 -0
  135. package/dist/launcher/npm-runtime-bundle.types.js +1 -0
  136. package/dist/launcher/npm-runtime-launcher.service.d.ts +19 -0
  137. package/dist/launcher/npm-runtime-launcher.service.js +57 -0
  138. package/dist/launcher/npm-runtime-update-command.service.d.ts +12 -0
  139. package/dist/launcher/npm-runtime-update-command.service.js +87 -0
  140. package/dist/launcher/npm-runtime-update-source.service.d.ts +19 -0
  141. package/dist/launcher/npm-runtime-update-source.service.js +57 -0
  142. package/dist/launcher/npm-runtime-update-state.store.d.ts +17 -0
  143. package/dist/launcher/npm-runtime-update-state.store.js +92 -0
  144. package/dist/launcher/npm-runtime-update.manager.d.ts +42 -0
  145. package/dist/launcher/npm-runtime-update.manager.js +179 -0
  146. package/dist/launcher/npm-runtime-update.service.d.ts +54 -0
  147. package/dist/launcher/npm-runtime-update.service.js +183 -0
  148. package/dist/service-runtime.service.d.ts +91 -0
  149. package/dist/service-runtime.service.js +392 -0
  150. package/dist/shared/controllers/gateway.controller.d.ts +61 -0
  151. package/dist/shared/controllers/gateway.controller.js +318 -0
  152. package/dist/shared/services/extensions/extension-lifecycle.service.d.ts +56 -0
  153. package/dist/shared/services/extensions/extension-lifecycle.service.js +143 -0
  154. package/dist/shared/services/extensions/service-extension-runtime.service.d.ts +51 -0
  155. package/dist/shared/services/extensions/service-extension-runtime.service.js +338 -0
  156. package/dist/shared/services/gateway/cron-job-handler.service.d.ts +26 -0
  157. package/dist/shared/services/gateway/cron-job-handler.service.js +100 -0
  158. package/dist/shared/services/gateway/gateway-restart-wake.service.d.ts +12 -0
  159. package/dist/shared/services/gateway/gateway-restart-wake.service.js +91 -0
  160. package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts +37 -0
  161. package/dist/shared/services/gateway/managers/gateway-plugin.manager.js +218 -0
  162. package/dist/shared/services/gateway/managers/gateway-remote.manager.d.ts +20 -0
  163. package/dist/shared/services/gateway/managers/gateway-remote.manager.js +25 -0
  164. package/dist/shared/services/gateway/nextclaw-app.service.d.ts +22 -0
  165. package/dist/shared/services/gateway/nextclaw-app.service.js +53 -0
  166. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +89 -0
  167. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +337 -0
  168. package/dist/shared/services/gateway/service-bootstrap-status.d.ts +33 -0
  169. package/dist/shared/services/gateway/service-bootstrap-status.js +152 -0
  170. package/dist/shared/services/gateway/service-startup-support.service.d.ts +42 -0
  171. package/dist/shared/services/gateway/service-startup-support.service.js +96 -0
  172. package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.d.ts +9 -0
  173. package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js +10 -0
  174. package/dist/shared/services/marketplace/service-marketplace-installer.service.d.ts +31 -0
  175. package/dist/shared/services/marketplace/service-marketplace-installer.service.js +99 -0
  176. package/dist/shared/services/marketplace/service-mcp-marketplace-ops.d.ts +39 -0
  177. package/dist/shared/services/marketplace/service-mcp-marketplace-ops.js +67 -0
  178. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.d.ts +24 -0
  179. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js +117 -0
  180. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.d.ts +6 -0
  181. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js +96 -0
  182. package/dist/shared/services/restart/restart-coordinator.service.d.ts +30 -0
  183. package/dist/shared/services/restart/restart-coordinator.service.js +51 -0
  184. package/dist/shared/services/restart/restart-sentinel.service.d.ts +39 -0
  185. package/dist/shared/services/restart/restart-sentinel.service.js +88 -0
  186. package/dist/shared/services/restart/runtime-restart-request.service.d.ts +24 -0
  187. package/dist/shared/services/restart/runtime-restart-request.service.js +42 -0
  188. package/dist/shared/services/runtime/runtime-command.service.d.ts +37 -0
  189. package/dist/shared/services/runtime/runtime-command.service.js +163 -0
  190. package/dist/shared/services/runtime/runtime-config-init.service.d.ts +4 -0
  191. package/dist/shared/services/runtime/runtime-config-init.service.js +10 -0
  192. package/dist/shared/services/runtime/service-managed-startup.service.d.ts +146 -0
  193. package/dist/shared/services/runtime/service-managed-startup.service.js +426 -0
  194. package/dist/shared/services/runtime/service-remote-runtime.service.d.ts +53 -0
  195. package/dist/shared/services/runtime/service-remote-runtime.service.js +173 -0
  196. package/dist/shared/services/runtime/utils/skills-loader.utils.d.ts +12 -0
  197. package/dist/shared/services/runtime/utils/skills-loader.utils.js +9 -0
  198. package/dist/shared/services/session/service-deferred-ncp-agent.service.d.ts +14 -0
  199. package/dist/shared/services/session/service-deferred-ncp-agent.service.js +85 -0
  200. package/dist/shared/services/ui/companion-runtime.service.d.ts +33 -0
  201. package/dist/shared/services/ui/companion-runtime.service.js +145 -0
  202. package/dist/shared/services/ui/local-ui-discovery.service.d.ts +19 -0
  203. package/dist/shared/services/ui/local-ui-discovery.service.js +41 -0
  204. package/dist/shared/services/ui/npm-runtime-update-host.service.d.ts +40 -0
  205. package/dist/shared/services/ui/npm-runtime-update-host.service.js +181 -0
  206. package/dist/shared/services/ui/runtime-control-host.service.d.ts +28 -0
  207. package/dist/shared/services/ui/runtime-control-host.service.js +89 -0
  208. package/dist/shared/services/ui/service-remote-access.service.d.ts +25 -0
  209. package/dist/shared/services/ui/service-remote-access.service.js +38 -0
  210. package/dist/shared/services/ui/ui-bridge-api.service.d.ts +16 -0
  211. package/dist/shared/services/ui/ui-bridge-api.service.js +43 -0
  212. package/dist/shared/services/workspace/workspace-manager.service.d.ts +19 -0
  213. package/dist/shared/services/workspace/workspace-manager.service.js +135 -0
  214. package/dist/shared/stores/companion-runtime.store.d.ts +15 -0
  215. package/dist/shared/stores/companion-runtime.store.js +27 -0
  216. package/dist/shared/stores/local-ui-runtime.store.d.ts +25 -0
  217. package/dist/shared/stores/local-ui-runtime.store.js +54 -0
  218. package/dist/shared/stores/managed-service-state.store.d.ts +28 -0
  219. package/dist/shared/stores/managed-service-state.store.js +38 -0
  220. package/dist/shared/stores/pending-restart.store.d.ts +21 -0
  221. package/dist/shared/stores/pending-restart.store.js +35 -0
  222. package/dist/shared/types/cli.types.d.ts +295 -0
  223. package/dist/shared/types/cli.types.js +1 -0
  224. package/dist/shared/utils/cli.utils.d.ts +34 -0
  225. package/dist/shared/utils/cli.utils.js +262 -0
  226. package/dist/shared/utils/config-path.d.ts +15 -0
  227. package/dist/shared/utils/config-path.js +167 -0
  228. package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.d.ts +16 -0
  229. package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.js +46 -0
  230. package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.d.ts +9 -0
  231. package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.js +33 -0
  232. package/dist/shared/utils/package/package-manifest.utils.d.ts +8 -0
  233. package/dist/shared/utils/package/package-manifest.utils.js +48 -0
  234. package/dist/shared/utils/runtime-helpers.d.ts +14 -0
  235. package/dist/shared/utils/runtime-helpers.js +26 -0
  236. package/dist/shared/utils/service-port-probe.utils.d.ts +41 -0
  237. package/dist/shared/utils/service-port-probe.utils.js +164 -0
  238. package/dist/shared/utils/startup-trace.d.ts +7 -0
  239. package/dist/shared/utils/startup-trace.js +37 -0
  240. package/dist/shared/utils/top-level-nextclaw-command-env.utils.d.ts +4 -0
  241. package/dist/shared/utils/top-level-nextclaw-command-env.utils.js +10 -0
  242. package/package.json +68 -0
@@ -0,0 +1,66 @@
1
+ import { APP_NAME } from "@nextclaw/core";
2
+ //#region src/cli/commands/diagnostics/utils/diagnostics-render.utils.ts
3
+ function printStatusReport(params) {
4
+ const { logo, report, verbose } = params;
5
+ console.log(`${logo} ${APP_NAME} Status`);
6
+ console.log(`Level: ${report.level}`);
7
+ console.log(`Generated: ${report.generatedAt}`);
8
+ console.log("");
9
+ printProcessSection(report);
10
+ printEndpointSection(report);
11
+ printProviderSection(report);
12
+ printTextList("Fix actions", report.fixActions);
13
+ printTextList("Issues", report.issues);
14
+ printTextList("Recommendations", report.recommendations);
15
+ if (verbose && report.logTail.length > 0) {
16
+ console.log("");
17
+ console.log("Recent logs:");
18
+ for (const line of report.logTail) console.log(line);
19
+ }
20
+ }
21
+ function printProcessSection(report) {
22
+ const processLabel = report.process.running ? `running (PID ${report.process.pid})` : report.process.staleState ? "stale-state" : "stopped";
23
+ console.log(`Process: ${processLabel}`);
24
+ console.log(`State file: ${report.serviceStatePath} ${report.serviceStateExists ? "✓" : "✗"}`);
25
+ if (report.process.startedAt) console.log(`Started: ${report.process.startedAt}`);
26
+ console.log(`Managed health: ${report.health.managed.state} (${report.health.managed.detail})`);
27
+ if (!report.process.running) console.log(`Configured health: ${report.health.configured.state} (${report.health.configured.detail})`);
28
+ }
29
+ function printEndpointSection(report) {
30
+ console.log(`UI: ${report.endpoints.uiUrl ?? report.endpoints.configuredUiUrl}`);
31
+ console.log(`API: ${report.endpoints.apiUrl ?? report.endpoints.configuredApiUrl}`);
32
+ console.log(`Remote: ${report.remote.configuredEnabled ? "enabled" : "disabled"}${report.remote.runtime ? ` (${report.remote.runtime.state})` : ""}`);
33
+ if (report.remote.runtime?.deviceName) console.log(`Remote device: ${report.remote.runtime.deviceName}`);
34
+ if (report.remote.runtime?.platformBase) console.log(`Remote platform: ${report.remote.runtime.platformBase}`);
35
+ if (report.remote.runtime?.lastError) console.log(`Remote error: ${report.remote.runtime.lastError}`);
36
+ console.log(`Config: ${report.configPath} ${report.configExists ? "✓" : "✗"}`);
37
+ console.log(`Workspace: ${report.workspacePath} ${report.workspaceExists ? "✓" : "✗"}`);
38
+ console.log(`Model: ${report.model}`);
39
+ }
40
+ function printProviderSection(report) {
41
+ for (const provider of report.providers) console.log(`${provider.name}: ${provider.configured ? "✓" : "not set"}${provider.detail ? ` (${provider.detail})` : ""}`);
42
+ }
43
+ function printDoctorReport(params) {
44
+ const { checks, generatedAt, logTail, logo, recommendations, verbose } = params;
45
+ console.log(`${logo} ${APP_NAME} Doctor`);
46
+ console.log(`Generated: ${generatedAt}`);
47
+ console.log("");
48
+ for (const check of checks) {
49
+ const icon = check.status === "pass" ? "✓" : check.status === "warn" ? "!" : "✗";
50
+ console.log(`${icon} ${check.name}: ${check.detail}`);
51
+ }
52
+ printTextList("Recommendations", recommendations);
53
+ if (verbose && logTail.length > 0) {
54
+ console.log("");
55
+ console.log("Recent logs:");
56
+ for (const line of logTail) console.log(line);
57
+ }
58
+ }
59
+ function printTextList(title, items) {
60
+ if (items.length === 0) return;
61
+ console.log("");
62
+ console.log(`${title}:`);
63
+ for (const item of items) console.log(`- ${item}`);
64
+ }
65
+ //#endregion
66
+ export { printDoctorReport, printStatusReport };
@@ -0,0 +1,14 @@
1
+ import { GatewayCommandOptions } from "../../../shared/types/cli.types.js";
2
+ import { RuntimeCommandService } from "../../../shared/services/runtime/runtime-command.service.js";
3
+
4
+ //#region src/cli/commands/gateway/index.d.ts
5
+ declare class GatewayCommands {
6
+ private readonly deps;
7
+ constructor(deps: {
8
+ runtimeCommandService: RuntimeCommandService;
9
+ forcedPublicHost: string;
10
+ });
11
+ run: (opts: GatewayCommandOptions) => Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { GatewayCommands };
@@ -0,0 +1,15 @@
1
+ //#region src/cli/commands/gateway/index.ts
2
+ var GatewayCommands = class {
3
+ constructor(deps) {
4
+ this.deps = deps;
5
+ }
6
+ run = async (opts) => {
7
+ const uiOverrides = { host: this.deps.forcedPublicHost };
8
+ if (opts.ui) uiOverrides.enabled = true;
9
+ if (opts.uiPort) uiOverrides.port = Number(opts.uiPort);
10
+ if (opts.uiOpen) uiOverrides.open = true;
11
+ await this.deps.runtimeCommandService.startGateway({ uiOverrides });
12
+ };
13
+ };
14
+ //#endregion
15
+ export { GatewayCommands };
@@ -0,0 +1,12 @@
1
+ import { LogsTailCommandOptions } from "../../../shared/types/cli.types.js";
2
+ import { LoggingRuntime } from "@nextclaw/core";
3
+
4
+ //#region src/cli/commands/logs/index.d.ts
5
+ declare class LogsCommands {
6
+ private readonly runtime;
7
+ constructor(runtime?: LoggingRuntime);
8
+ path: () => void;
9
+ tail: (opts?: LogsTailCommandOptions) => void;
10
+ }
11
+ //#endregion
12
+ export { LogsCommands };
@@ -0,0 +1,29 @@
1
+ import { getLoggingRuntime } from "@nextclaw/core";
2
+ //#region src/cli/commands/logs/index.ts
3
+ var LogsCommands = class {
4
+ constructor(runtime = getLoggingRuntime()) {
5
+ this.runtime = runtime;
6
+ }
7
+ path = () => {
8
+ const paths = this.runtime.getPaths();
9
+ console.log([
10
+ `Logs directory: ${paths.logsDir}`,
11
+ `Service log: ${paths.serviceLogPath}`,
12
+ `Crash log: ${paths.crashLogPath}`,
13
+ `Archive: ${paths.archiveDir}`
14
+ ].join("\n"));
15
+ };
16
+ tail = (opts = {}) => {
17
+ const kind = opts.crash ? "crash" : "service";
18
+ const rawLines = Number(opts.lines);
19
+ const lines = Number.isFinite(rawLines) && rawLines > 0 ? Math.floor(rawLines) : 40;
20
+ const output = this.runtime.tail(kind, lines);
21
+ if (output.length === 0) {
22
+ console.log(`No log entries found in ${this.runtime.resolveLogPath(kind)}.`);
23
+ return;
24
+ }
25
+ console.log(output.join("\n"));
26
+ };
27
+ };
28
+ //#endregion
29
+ export { LogsCommands };
@@ -0,0 +1,14 @@
1
+ import { McpAddCommandOptions, McpDoctorOptions, McpListOptions } from "../../../shared/types/cli.types.js";
2
+
3
+ //#region src/cli/commands/mcp/index.d.ts
4
+ declare class McpCommands {
5
+ list: (opts?: McpListOptions) => void;
6
+ add: (name: string, command: string[], opts: McpAddCommandOptions) => Promise<void>;
7
+ remove: (name: string) => Promise<void>;
8
+ enable: (name: string) => Promise<void>;
9
+ disable: (name: string) => Promise<void>;
10
+ doctor: (name?: string, opts?: McpDoctorOptions) => Promise<void>;
11
+ private toggleEnabled;
12
+ }
13
+ //#endregion
14
+ export { McpCommands };
@@ -0,0 +1,193 @@
1
+ import { loadConfig, saveConfig } from "@nextclaw/core";
2
+ import { McpDoctorFacade, McpMutationService, McpRegistryService } from "@nextclaw/mcp";
3
+ //#region src/cli/commands/mcp/index.ts
4
+ function normalizeOptionalString(value) {
5
+ if (typeof value !== "string") return;
6
+ return value.trim() || void 0;
7
+ }
8
+ function parsePairs(values, label) {
9
+ const output = {};
10
+ for (const raw of values ?? []) {
11
+ const index = raw.indexOf("=");
12
+ if (index <= 0) throw new Error(`Invalid ${label} entry: ${raw}. Expected key=value.`);
13
+ const key = raw.slice(0, index).trim();
14
+ const value = raw.slice(index + 1);
15
+ if (!key) throw new Error(`Invalid ${label} entry: ${raw}. Expected key=value.`);
16
+ output[key] = value;
17
+ }
18
+ return output;
19
+ }
20
+ function parseTimeoutMs(value) {
21
+ if (value === void 0 || value === null || value === "") return;
22
+ const parsed = Number(value);
23
+ if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(`Invalid timeout: ${String(value)}`);
24
+ return Math.trunc(parsed);
25
+ }
26
+ function buildMcpServerDefinition(command, opts) {
27
+ const transport = (normalizeOptionalString(opts.transport) ?? "stdio").toLowerCase();
28
+ const disabled = Boolean(opts.disabled);
29
+ const explicitAgents = Array.from(new Set((opts.agent ?? []).map((agentId) => normalizeOptionalString(agentId)).filter((agentId) => Boolean(agentId))));
30
+ const allAgents = explicitAgents.length === 0 ? true : Boolean(opts.allAgents);
31
+ if (transport === "stdio") {
32
+ if (command.length === 0) throw new Error("stdio transport requires a command after --");
33
+ return {
34
+ enabled: !disabled,
35
+ transport: {
36
+ type: "stdio",
37
+ command: command[0],
38
+ args: command.slice(1),
39
+ cwd: normalizeOptionalString(opts.cwd),
40
+ env: parsePairs(opts.env, "env"),
41
+ stderr: normalizeOptionalString(opts.stderr) ?? "pipe"
42
+ },
43
+ scope: {
44
+ allAgents,
45
+ agents: allAgents ? [] : explicitAgents
46
+ },
47
+ policy: {
48
+ trust: "explicit",
49
+ start: "eager"
50
+ },
51
+ metadata: {
52
+ source: "manual",
53
+ installedAt: (/* @__PURE__ */ new Date()).toISOString()
54
+ }
55
+ };
56
+ }
57
+ const url = normalizeOptionalString(opts.url);
58
+ if (!url) throw new Error(`${transport} transport requires --url`);
59
+ const timeoutMs = parseTimeoutMs(opts.timeoutMs);
60
+ const shared = {
61
+ enabled: !disabled,
62
+ scope: {
63
+ allAgents,
64
+ agents: allAgents ? [] : explicitAgents
65
+ },
66
+ policy: {
67
+ trust: "explicit",
68
+ start: "eager"
69
+ },
70
+ metadata: {
71
+ source: "manual",
72
+ installedAt: (/* @__PURE__ */ new Date()).toISOString()
73
+ }
74
+ };
75
+ if (transport === "http") return {
76
+ ...shared,
77
+ transport: {
78
+ type: "http",
79
+ url,
80
+ headers: parsePairs(opts.header, "header"),
81
+ timeoutMs: timeoutMs ?? 15e3,
82
+ verifyTls: !opts.insecure
83
+ }
84
+ };
85
+ if (transport === "sse") return {
86
+ ...shared,
87
+ transport: {
88
+ type: "sse",
89
+ url,
90
+ headers: parsePairs(opts.header, "header"),
91
+ timeoutMs: timeoutMs ?? 15e3,
92
+ verifyTls: !opts.insecure,
93
+ reconnect: {
94
+ enabled: true,
95
+ initialDelayMs: 1e3,
96
+ maxDelayMs: 3e4
97
+ }
98
+ }
99
+ };
100
+ throw new Error(`Unsupported MCP transport: ${transport}`);
101
+ }
102
+ var McpCommands = class {
103
+ list = (opts = {}) => {
104
+ const servers = new McpRegistryService({ getConfig: () => loadConfig() }).listServers().map((server) => ({
105
+ name: server.name,
106
+ enabled: server.definition.enabled,
107
+ transport: server.definition.transport.type,
108
+ scope: server.definition.scope
109
+ }));
110
+ if (opts.json) {
111
+ console.log(JSON.stringify({ servers }, null, 2));
112
+ return;
113
+ }
114
+ if (servers.length === 0) {
115
+ console.log("No MCP servers configured.");
116
+ return;
117
+ }
118
+ for (const server of servers) {
119
+ const scope = server.scope.allAgents ? "all-agents" : server.scope.agents.length > 0 ? `agents=${server.scope.agents.join(",")}` : "default-agent";
120
+ console.log(`${server.enabled ? "ENABLED " : "DISABLED"} ${server.name} (${server.transport}, ${scope})`);
121
+ }
122
+ };
123
+ add = async (name, command, opts) => {
124
+ const result = new McpMutationService({
125
+ getConfig: () => loadConfig(),
126
+ saveConfig: (config) => saveConfig(config)
127
+ }).addServer(name, buildMcpServerDefinition(command, opts));
128
+ if (!result.changed) {
129
+ reportUserInputIssue(result.message);
130
+ return;
131
+ }
132
+ console.log(result.message);
133
+ };
134
+ remove = async (name) => {
135
+ const result = new McpMutationService({
136
+ getConfig: () => loadConfig(),
137
+ saveConfig: (config) => saveConfig(config)
138
+ }).removeServer(name);
139
+ if (!result.changed) {
140
+ reportUserInputIssue(result.message);
141
+ return;
142
+ }
143
+ console.log(result.message);
144
+ };
145
+ enable = async (name) => {
146
+ await this.toggleEnabled(name, true);
147
+ };
148
+ disable = async (name) => {
149
+ await this.toggleEnabled(name, false);
150
+ };
151
+ doctor = async (name, opts = {}) => {
152
+ const registry = new McpRegistryService({ getConfig: () => loadConfig() });
153
+ const doctor = new McpDoctorFacade({
154
+ getConfig: () => loadConfig(),
155
+ registryService: registry
156
+ });
157
+ try {
158
+ const reports = await doctor.inspect(name);
159
+ if (opts.json) {
160
+ console.log(JSON.stringify({ reports }, null, 2));
161
+ return;
162
+ }
163
+ if (reports.length === 0) {
164
+ console.log("No MCP servers matched.");
165
+ return;
166
+ }
167
+ for (const report of reports) {
168
+ const status = report.error ? "ERROR" : "OK";
169
+ const detail = report.error ? ` (${report.error})` : "";
170
+ console.log(`[${status}] ${report.name} enabled=${report.enabled} transport=${report.transport} tools=${report.toolCount}${detail}`);
171
+ }
172
+ } finally {
173
+ await registry.close();
174
+ }
175
+ };
176
+ toggleEnabled = async (name, enabled) => {
177
+ const result = new McpMutationService({
178
+ getConfig: () => loadConfig(),
179
+ saveConfig: (config) => saveConfig(config)
180
+ }).toggleEnabled(name, enabled);
181
+ if (!result.changed) {
182
+ reportUserInputIssue(result.message);
183
+ return;
184
+ }
185
+ console.log(result.message);
186
+ };
187
+ };
188
+ function reportUserInputIssue(message) {
189
+ console.error(message);
190
+ process.exitCode = 1;
191
+ }
192
+ //#endregion
193
+ export { McpCommands };
@@ -0,0 +1,20 @@
1
+ import { StartCommandOptions } from "../../../shared/types/cli.types.js";
2
+ import { RuntimeCommandService } from "../../../shared/services/runtime/runtime-command.service.js";
3
+ import { StartCommands } from "../start/index.js";
4
+
5
+ //#region src/cli/commands/restart/index.d.ts
6
+ declare class RestartCommands {
7
+ private readonly deps;
8
+ constructor(deps: {
9
+ runtimeCommandService: RuntimeCommandService;
10
+ startCommands: StartCommands;
11
+ forcedPublicHost: string;
12
+ writeRestartSentinelFromExecContext: (reason: string) => Promise<void>;
13
+ });
14
+ run: (opts: StartCommandOptions) => Promise<void>;
15
+ private restartForegroundRuntime;
16
+ private resolveAdoptableForegroundRuntimePid;
17
+ private isAdoptableNextclawRuntimeCommand;
18
+ }
19
+ //#endregion
20
+ export { RestartCommands };
@@ -0,0 +1,88 @@
1
+ import { findListeningProcessByPort, isProcessRunning, resolveUiConfig, waitForExit } from "../../../shared/utils/cli.utils.js";
2
+ import { localUiRuntimeStore } from "../../../shared/stores/local-ui-runtime.store.js";
3
+ import { managedServiceStateStore } from "../../../shared/stores/managed-service-state.store.js";
4
+ import { describeUnmanagedHealthyTargetMessage } from "../../../shared/utils/service-port-probe.utils.js";
5
+ import { resolveManagedServiceUiOverrides } from "../../../shared/utils/runtime-helpers.js";
6
+ import "../../../shared/services/runtime/runtime-command.service.js";
7
+ import { APP_NAME, loadConfig } from "@nextclaw/core";
8
+ //#region src/cli/commands/restart/index.ts
9
+ var RestartCommands = class {
10
+ constructor(deps) {
11
+ this.deps = deps;
12
+ }
13
+ run = async (opts) => {
14
+ await this.deps.writeRestartSentinelFromExecContext("cli.restart");
15
+ const uiOverrides = resolveManagedServiceUiOverrides({
16
+ uiPort: opts.uiPort,
17
+ forcedPublicHost: this.deps.forcedPublicHost
18
+ });
19
+ const targetUi = resolveUiConfig(loadConfig(), uiOverrides);
20
+ const state = managedServiceStateStore.read();
21
+ if (state && isProcessRunning(state.pid)) {
22
+ console.log(`Restarting ${APP_NAME}...`);
23
+ await this.deps.runtimeCommandService.stopService();
24
+ } else {
25
+ const foregroundRuntime = localUiRuntimeStore.read();
26
+ const foregroundMatchesTarget = Boolean(foregroundRuntime && isProcessRunning(foregroundRuntime.pid) && foregroundRuntime.uiPort === targetUi.port);
27
+ if (foregroundRuntime && foregroundMatchesTarget) {
28
+ if (!await this.restartForegroundRuntime(foregroundRuntime.pid)) return;
29
+ await this.deps.startCommands.run(opts);
30
+ return;
31
+ }
32
+ if (state) {
33
+ managedServiceStateStore.clear();
34
+ console.log("Service state was stale and has been cleaned up.");
35
+ }
36
+ const unmanagedHealthyServiceMessage = await describeUnmanagedHealthyTargetMessage({ uiOverrides });
37
+ if (unmanagedHealthyServiceMessage) {
38
+ const adoptedRuntimePid = this.resolveAdoptableForegroundRuntimePid(targetUi.port);
39
+ if (adoptedRuntimePid) {
40
+ if (!await this.restartForegroundRuntime(adoptedRuntimePid)) return;
41
+ await this.deps.startCommands.run(opts);
42
+ return;
43
+ }
44
+ console.error(`Error: Cannot restart ${APP_NAME} because the target UI/API port is already served by a healthy unmanaged instance.`);
45
+ console.error(unmanagedHealthyServiceMessage);
46
+ return;
47
+ }
48
+ if (!state) console.log("No running service found. Starting a new service.");
49
+ }
50
+ await this.deps.startCommands.run(opts);
51
+ };
52
+ restartForegroundRuntime = async (pid) => {
53
+ console.log(`Restarting ${APP_NAME} foreground runtime (PID ${pid})...`);
54
+ try {
55
+ process.kill(pid, "SIGTERM");
56
+ } catch (error) {
57
+ console.error(`Failed to stop foreground runtime: ${String(error)}`);
58
+ return false;
59
+ }
60
+ if (!await waitForExit(pid, 3e3)) {
61
+ try {
62
+ process.kill(pid, "SIGKILL");
63
+ } catch (error) {
64
+ console.error(`Failed to force stop foreground runtime: ${String(error)}`);
65
+ return false;
66
+ }
67
+ if (!await waitForExit(pid, 2e3)) {
68
+ console.error(`Failed to stop foreground runtime PID ${pid}.`);
69
+ return false;
70
+ }
71
+ }
72
+ localUiRuntimeStore.clearIfOwnedByProcess(pid);
73
+ console.log(`✓ ${APP_NAME} foreground runtime stopped`);
74
+ return true;
75
+ };
76
+ resolveAdoptableForegroundRuntimePid = (port) => {
77
+ const listeningProcess = findListeningProcessByPort(port);
78
+ if (!listeningProcess || !isProcessRunning(listeningProcess.pid)) return null;
79
+ return this.isAdoptableNextclawRuntimeCommand(listeningProcess.command) ? listeningProcess.pid : null;
80
+ };
81
+ isAdoptableNextclawRuntimeCommand = (command) => {
82
+ const normalized = command?.trim() ?? "";
83
+ if (!normalized) return false;
84
+ return /\bserve\b/.test(normalized) && (normalized.includes("/dist/cli/app/index.js") || normalized.includes("/src/cli/app/index.js") || normalized.includes("/runtime/dist/cli/app/index.js"));
85
+ };
86
+ };
87
+ //#endregion
88
+ export { RestartCommands };
@@ -0,0 +1,22 @@
1
+ import { RequestRestartParams, SecretsApplyOptions, SecretsAuditOptions, SecretsConfigureOptions, SecretsReloadOptions } from "../../../shared/types/cli.types.js";
2
+
3
+ //#region src/cli/commands/secrets/index.d.ts
4
+ declare class SecretsCommands {
5
+ private deps;
6
+ constructor(deps: {
7
+ requestRestart: (params: RequestRestartParams) => Promise<void>;
8
+ });
9
+ audit: (opts?: SecretsAuditOptions) => void;
10
+ configure: (opts: SecretsConfigureOptions) => Promise<void>;
11
+ apply: (opts: SecretsApplyOptions) => Promise<void>;
12
+ reload: (opts?: SecretsReloadOptions) => Promise<void>;
13
+ private removeProvider;
14
+ private configureProvider;
15
+ private buildProviderConfig;
16
+ private applyEnabledPatch;
17
+ private applyFilePatch;
18
+ private applySingleRefPatch;
19
+ private requestRestartForConfigDiff;
20
+ }
21
+ //#endregion
22
+ export { SecretsCommands };