@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,295 @@
1
+ import { RestartStrategy } from "../services/restart/restart-coordinator.service.js";
2
+ import { RemoteConnectCommandOptions, RemoteDoctorCommandOptions, RemoteEnableCommandOptions, RemoteRuntimeState, RemoteStatusCommandOptions } from "@nextclaw/remote";
3
+
4
+ //#region src/shared/types/cli.types.d.ts
5
+ type GatewayCommandOptions = {
6
+ ui?: boolean;
7
+ uiPort?: string | number;
8
+ uiOpen?: boolean;
9
+ };
10
+ type UiCommandOptions = {
11
+ port?: string | number;
12
+ open?: boolean;
13
+ };
14
+ type StartCommandOptions = {
15
+ uiPort?: string | number;
16
+ open?: boolean;
17
+ startTimeout?: string | number;
18
+ };
19
+ type CompanionStartCommandOptions = {
20
+ baseUrl?: string;
21
+ };
22
+ type CompanionEnableCommandOptions = {
23
+ baseUrl?: string;
24
+ };
25
+ type CompanionDisableCommandOptions = Record<string, never>;
26
+ type CompanionStatusCommandOptions = {
27
+ json?: boolean;
28
+ };
29
+ type CompanionStopCommandOptions = {
30
+ force?: boolean;
31
+ };
32
+ type ServiceAutostartCommandOptions = {
33
+ user?: boolean;
34
+ system?: boolean;
35
+ dryRun?: boolean;
36
+ json?: boolean;
37
+ };
38
+ type AgentCommandOptions = {
39
+ message?: string;
40
+ session?: string;
41
+ markdown?: boolean;
42
+ model?: string;
43
+ };
44
+ type SkillsInstalledCommandOptions = {
45
+ workdir?: string;
46
+ scope?: string;
47
+ query?: string;
48
+ json?: boolean;
49
+ };
50
+ type SkillsInfoCommandOptions = {
51
+ workdir?: string;
52
+ json?: boolean;
53
+ };
54
+ type MarketplaceSkillsSearchCommandOptions = {
55
+ apiBase?: string;
56
+ query?: string;
57
+ tag?: string;
58
+ sort?: string;
59
+ page?: string | number;
60
+ pageSize?: string | number;
61
+ json?: boolean;
62
+ };
63
+ type MarketplaceSkillsRecommendCommandOptions = {
64
+ apiBase?: string;
65
+ scene?: string;
66
+ limit?: string | number;
67
+ json?: boolean;
68
+ };
69
+ type UpdateCommandOptions = {
70
+ check?: boolean;
71
+ download?: boolean;
72
+ apply?: boolean;
73
+ channel?: string;
74
+ manifestUrl?: string;
75
+ json?: boolean;
76
+ };
77
+ type LoginCommandOptions = {
78
+ apiBase?: string;
79
+ email?: string;
80
+ password?: string;
81
+ open?: boolean;
82
+ };
83
+ type AccountCommandOptions = {
84
+ apiBase?: string;
85
+ json?: boolean;
86
+ };
87
+ type AccountSetUsernameCommandOptions = {
88
+ apiBase?: string;
89
+ json?: boolean;
90
+ };
91
+ type PluginsListOptions = {
92
+ json?: boolean;
93
+ enabled?: boolean;
94
+ verbose?: boolean;
95
+ };
96
+ type AgentsListCommandOptions = {
97
+ json?: boolean;
98
+ };
99
+ type AgentsRuntimesCommandOptions = {
100
+ json?: boolean;
101
+ probe?: boolean;
102
+ };
103
+ type AgentsNewCommandOptions = {
104
+ name?: string;
105
+ description?: string;
106
+ avatar?: string;
107
+ home?: string;
108
+ runtime?: string;
109
+ json?: boolean;
110
+ };
111
+ type AgentsUpdateCommandOptions = {
112
+ name?: string;
113
+ description?: string;
114
+ avatar?: string;
115
+ runtime?: string;
116
+ json?: boolean;
117
+ };
118
+ type AgentsRemoveCommandOptions = {
119
+ json?: boolean;
120
+ };
121
+ type PluginsInfoOptions = {
122
+ json?: boolean;
123
+ };
124
+ type PluginsInstallOptions = {
125
+ link?: boolean;
126
+ };
127
+ type PluginsUninstallOptions = {
128
+ keepFiles?: boolean;
129
+ keepConfig?: boolean;
130
+ force?: boolean;
131
+ dryRun?: boolean;
132
+ };
133
+ type ChannelsAddOptions = {
134
+ channel: string;
135
+ code?: string;
136
+ token?: string;
137
+ name?: string;
138
+ url?: string;
139
+ httpUrl?: string;
140
+ };
141
+ type ChannelsLoginOptions = {
142
+ channel?: string;
143
+ account?: string;
144
+ url?: string;
145
+ httpUrl?: string;
146
+ verbose?: boolean;
147
+ };
148
+ type ConfigGetOptions = {
149
+ json?: boolean;
150
+ };
151
+ type ConfigSetOptions = {
152
+ json?: boolean;
153
+ };
154
+ type McpListOptions = {
155
+ json?: boolean;
156
+ };
157
+ type McpAddCommandOptions = {
158
+ transport?: string;
159
+ url?: string;
160
+ header?: string[];
161
+ env?: string[];
162
+ cwd?: string;
163
+ timeoutMs?: string | number;
164
+ disabled?: boolean;
165
+ allAgents?: boolean;
166
+ agent?: string[];
167
+ stderr?: string;
168
+ insecure?: boolean;
169
+ };
170
+ type McpDoctorOptions = {
171
+ json?: boolean;
172
+ };
173
+ type SecretsAuditOptions = {
174
+ json?: boolean;
175
+ strict?: boolean;
176
+ };
177
+ type SecretsConfigureOptions = {
178
+ provider?: string;
179
+ source?: string;
180
+ prefix?: string;
181
+ path?: string;
182
+ command?: string;
183
+ arg?: string[];
184
+ cwd?: string;
185
+ timeoutMs?: string | number;
186
+ setDefault?: boolean;
187
+ remove?: boolean;
188
+ json?: boolean;
189
+ };
190
+ type SecretsApplyOptions = {
191
+ path?: string;
192
+ source?: string;
193
+ id?: string;
194
+ provider?: string;
195
+ file?: string;
196
+ remove?: boolean;
197
+ enable?: boolean;
198
+ disable?: boolean;
199
+ json?: boolean;
200
+ };
201
+ type SecretsReloadOptions = {
202
+ json?: boolean;
203
+ };
204
+ type CronAddOptions = {
205
+ name: string;
206
+ message: string;
207
+ agent?: string;
208
+ session?: string;
209
+ every?: string;
210
+ cron?: string;
211
+ at?: string;
212
+ deliver?: boolean;
213
+ to?: string;
214
+ channel?: string;
215
+ account?: string;
216
+ };
217
+ type StatusCommandOptions = {
218
+ json?: boolean;
219
+ verbose?: boolean;
220
+ fix?: boolean;
221
+ };
222
+ type DoctorCommandOptions = {
223
+ json?: boolean;
224
+ verbose?: boolean;
225
+ fix?: boolean;
226
+ };
227
+ type LogsTailCommandOptions = {
228
+ crash?: boolean;
229
+ lines?: string | number;
230
+ };
231
+ type UsageCommandOptions = {
232
+ json?: boolean;
233
+ history?: boolean;
234
+ stats?: boolean;
235
+ limit?: string | number;
236
+ };
237
+ type HealthProbe = {
238
+ state: "ok" | "unreachable" | "invalid-response";
239
+ detail: string;
240
+ payload?: unknown;
241
+ };
242
+ type RuntimeStatusReport = {
243
+ generatedAt: string;
244
+ configPath: string;
245
+ configExists: boolean;
246
+ workspacePath: string;
247
+ workspaceExists: boolean;
248
+ model: string;
249
+ providers: Array<{
250
+ name: string;
251
+ configured: boolean;
252
+ detail: string;
253
+ }>;
254
+ serviceStatePath: string;
255
+ serviceStateExists: boolean;
256
+ fixActions: string[];
257
+ process: {
258
+ managedByState: boolean;
259
+ pid: number | null;
260
+ running: boolean;
261
+ staleState: boolean;
262
+ orphanSuspected: boolean;
263
+ startedAt: string | null;
264
+ };
265
+ endpoints: {
266
+ uiUrl: string | null;
267
+ apiUrl: string | null;
268
+ configuredUiUrl: string;
269
+ configuredApiUrl: string;
270
+ };
271
+ health: {
272
+ managed: HealthProbe;
273
+ configured: HealthProbe;
274
+ };
275
+ issues: string[];
276
+ recommendations: string[];
277
+ logTail: string[];
278
+ remote: {
279
+ configuredEnabled: boolean;
280
+ runtime: RemoteRuntimeState | null;
281
+ };
282
+ level: "healthy" | "degraded" | "stopped";
283
+ exitCode: 0 | 1 | 2;
284
+ };
285
+ type RequestRestartParams = {
286
+ reason: string;
287
+ manualMessage: string;
288
+ strategy?: RestartStrategy;
289
+ delayMs?: number;
290
+ silentOnServiceRestart?: boolean;
291
+ changedPaths?: string[];
292
+ mode?: "execute" | "notify";
293
+ };
294
+ //#endregion
295
+ export { AccountCommandOptions, AccountSetUsernameCommandOptions, AgentCommandOptions, AgentsListCommandOptions, AgentsNewCommandOptions, AgentsRemoveCommandOptions, AgentsRuntimesCommandOptions, AgentsUpdateCommandOptions, ChannelsAddOptions, ChannelsLoginOptions, CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions, ConfigGetOptions, ConfigSetOptions, CronAddOptions, DoctorCommandOptions, GatewayCommandOptions, HealthProbe, LoginCommandOptions, LogsTailCommandOptions, MarketplaceSkillsRecommendCommandOptions, MarketplaceSkillsSearchCommandOptions, McpAddCommandOptions, McpDoctorOptions, McpListOptions, PluginsInfoOptions, PluginsInstallOptions, PluginsListOptions, PluginsUninstallOptions, type RemoteConnectCommandOptions, type RemoteDoctorCommandOptions, type RemoteEnableCommandOptions, type RemoteStatusCommandOptions, RequestRestartParams, RuntimeStatusReport, SecretsApplyOptions, SecretsAuditOptions, SecretsConfigureOptions, SecretsReloadOptions, ServiceAutostartCommandOptions, SkillsInfoCommandOptions, SkillsInstalledCommandOptions, StartCommandOptions, StatusCommandOptions, UiCommandOptions, UpdateCommandOptions, UsageCommandOptions };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { getPackageVersion } from "./package/package-manifest.utils.js";
2
+ import { Config } from "@nextclaw/core";
3
+ import { Interface } from "node:readline";
4
+
5
+ //#region src/shared/utils/cli.utils.d.ts
6
+ declare function resolveUiConfig(config: Config, overrides?: Partial<Config["ui"]>): Config["ui"];
7
+ declare function resolveUiApiBase(host: string, port: number): string;
8
+ declare function isLoopbackHost(host: string): boolean;
9
+ declare function resolvePublicIp(timeoutMs?: number): Promise<string | null>;
10
+ declare function buildServeArgs(options: {
11
+ uiPort: number;
12
+ }): string[];
13
+ declare function resolveServiceLogPath(): string;
14
+ declare function isProcessRunning(pid: number): boolean;
15
+ declare function waitForExit(pid: number, timeoutMs: number): Promise<boolean>;
16
+ type ListeningProcessInfo = {
17
+ pid: number;
18
+ command: string | null;
19
+ };
20
+ declare function findListeningProcessByPort(port: number): ListeningProcessInfo | null;
21
+ declare function resolveUiStaticDir(importMetaUrl?: string): string | null;
22
+ declare function openBrowser(url: string): boolean;
23
+ type ExecutableLookupEnv = {
24
+ [key: string]: string | undefined;
25
+ PATH?: string;
26
+ Path?: string;
27
+ path?: string;
28
+ PATHEXT?: string;
29
+ };
30
+ declare function findExecutableOnPath(binary: string, env?: ExecutableLookupEnv, platform?: NodeJS.Platform): string | null;
31
+ declare function printAgentResponse(response: string): void;
32
+ declare function prompt(rl: Interface, question: string): Promise<string>;
33
+ //#endregion
34
+ export { ExecutableLookupEnv, ListeningProcessInfo, buildServeArgs, findExecutableOnPath, findListeningProcessByPort, getPackageVersion, isLoopbackHost, isProcessRunning, openBrowser, printAgentResponse, prompt, resolvePublicIp, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, resolveUiStaticDir, waitForExit };
@@ -0,0 +1,262 @@
1
+ import { findNearestPackageManifest, getPackageVersion } from "./package/package-manifest.utils.js";
2
+ import { spawn, spawnSync } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { join, resolve } from "node:path";
5
+ import { createExternalCommandEnv, getLogsPath, resolveLocalUiBaseUrl } from "@nextclaw/core";
6
+ import { existsSync } from "node:fs";
7
+ import { isIP } from "node:net";
8
+ //#region src/shared/utils/cli.utils.ts
9
+ function resolveUiConfig(config, overrides) {
10
+ return {
11
+ ...config.ui ?? {
12
+ enabled: false,
13
+ host: "127.0.0.1",
14
+ port: 55667,
15
+ open: false
16
+ },
17
+ ...overrides ?? {}
18
+ };
19
+ }
20
+ function resolveUiApiBase(host, port) {
21
+ return resolveLocalUiBaseUrl({
22
+ host,
23
+ port
24
+ });
25
+ }
26
+ function isLoopbackHost(host) {
27
+ const normalized = host.trim().toLowerCase();
28
+ return normalized === "127.0.0.1" || normalized === "localhost" || normalized === "::1";
29
+ }
30
+ const PUBLIC_IP_CHECK_URLS = ["https://api.ipify.org", "https://ifconfig.me/ip"];
31
+ async function fetchPublicIpFrom(url, timeoutMs) {
32
+ const controller = new AbortController();
33
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
34
+ try {
35
+ const response = await fetch(url, {
36
+ signal: controller.signal,
37
+ headers: { Accept: "text/plain" }
38
+ });
39
+ if (!response.ok) return null;
40
+ const text = (await response.text()).trim();
41
+ return isIP(text) ? text : null;
42
+ } catch {
43
+ return null;
44
+ } finally {
45
+ clearTimeout(timer);
46
+ }
47
+ }
48
+ async function resolvePublicIp(timeoutMs = 1500) {
49
+ for (const endpoint of PUBLIC_IP_CHECK_URLS) {
50
+ const candidate = await fetchPublicIpFrom(endpoint, timeoutMs);
51
+ if (candidate) return candidate;
52
+ }
53
+ return null;
54
+ }
55
+ function buildServeArgs(options) {
56
+ return [
57
+ fileURLToPath(new URL("../../app/index.js", import.meta.url)),
58
+ "serve",
59
+ "--ui-port",
60
+ String(options.uiPort)
61
+ ];
62
+ }
63
+ function resolveServiceLogPath() {
64
+ return resolve(getLogsPath(), "service.log");
65
+ }
66
+ function isProcessRunning(pid) {
67
+ try {
68
+ process.kill(pid, 0);
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ }
74
+ async function waitForExit(pid, timeoutMs) {
75
+ const start = Date.now();
76
+ while (Date.now() - start < timeoutMs) {
77
+ if (!isProcessRunning(pid)) return true;
78
+ await new Promise((resolve) => setTimeout(resolve, 200));
79
+ }
80
+ return !isProcessRunning(pid);
81
+ }
82
+ function runLookupCommand(command, args) {
83
+ try {
84
+ const result = spawnSync(command, args, {
85
+ encoding: "utf8",
86
+ env: createExternalCommandEnv(process.env)
87
+ });
88
+ if (result.error || result.status !== 0) return {
89
+ ok: false,
90
+ stdout: ""
91
+ };
92
+ return {
93
+ ok: true,
94
+ stdout: result.stdout ?? ""
95
+ };
96
+ } catch {
97
+ return {
98
+ ok: false,
99
+ stdout: ""
100
+ };
101
+ }
102
+ }
103
+ function parseListeningPidFromLsof(raw) {
104
+ for (const line of raw.split("\n")) {
105
+ if (!line.startsWith("p")) continue;
106
+ const pid = Number(line.slice(1));
107
+ if (Number.isFinite(pid) && pid > 0) return pid;
108
+ }
109
+ return null;
110
+ }
111
+ function parseListeningPidFromNetstat(raw, port) {
112
+ const portSuffix = `:${port}`;
113
+ for (const line of raw.split("\n")) {
114
+ const trimmed = line.trim();
115
+ if (!trimmed || !trimmed.includes("LISTEN")) continue;
116
+ const columns = trimmed.split(/\s+/);
117
+ if (columns.length < 5) continue;
118
+ if (!(columns[1] ?? "").endsWith(portSuffix)) continue;
119
+ const pid = Number(columns[4]);
120
+ if (Number.isFinite(pid) && pid > 0) return pid;
121
+ }
122
+ return null;
123
+ }
124
+ function lookupProcessCommandByPid(pid) {
125
+ if (!Number.isFinite(pid) || pid <= 0) return null;
126
+ if (process.platform === "win32") {
127
+ const result = runLookupCommand("powershell", [
128
+ "-NoProfile",
129
+ "-Command",
130
+ `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CommandLine`
131
+ ]);
132
+ if (!result.ok) return null;
133
+ const command = result.stdout.trim();
134
+ return command.length > 0 ? command : null;
135
+ }
136
+ const result = runLookupCommand("ps", [
137
+ "-p",
138
+ String(pid),
139
+ "-o",
140
+ "command="
141
+ ]);
142
+ if (!result.ok) return null;
143
+ const command = result.stdout.trim();
144
+ return command.length > 0 ? command : null;
145
+ }
146
+ function findListeningProcessByPort(port) {
147
+ if (!Number.isFinite(port) || port <= 0) return null;
148
+ let pid = null;
149
+ if (process.platform === "win32") {
150
+ const result = runLookupCommand("netstat", [
151
+ "-ano",
152
+ "-p",
153
+ "tcp"
154
+ ]);
155
+ if (!result.ok) return null;
156
+ pid = parseListeningPidFromNetstat(result.stdout, port);
157
+ } else {
158
+ const result = runLookupCommand("lsof", [
159
+ "-nP",
160
+ `-iTCP:${port}`,
161
+ "-sTCP:LISTEN",
162
+ "-F",
163
+ "p"
164
+ ]);
165
+ if (!result.ok) return null;
166
+ pid = parseListeningPidFromLsof(result.stdout);
167
+ }
168
+ if (!pid) return null;
169
+ return {
170
+ pid,
171
+ command: lookupProcessCommandByPid(pid)
172
+ };
173
+ }
174
+ function resolveUiStaticDir(importMetaUrl = import.meta.url) {
175
+ if (process.env.NEXTCLAW_DISABLE_STATIC_UI === "1") return null;
176
+ const envDir = process.env.NEXTCLAW_UI_STATIC_DIR;
177
+ if (envDir) return existsSync(join(envDir, "index.html")) ? envDir : null;
178
+ const pkgRoot = findNearestPackageManifest(resolve(fileURLToPath(new URL(".", importMetaUrl))), "nextclaw")?.rootDir;
179
+ if (!pkgRoot) return null;
180
+ const bundledDir = join(pkgRoot, "ui-dist");
181
+ return existsSync(join(bundledDir, "index.html")) ? bundledDir : null;
182
+ }
183
+ function openBrowser(url) {
184
+ const platform = process.platform;
185
+ let command;
186
+ let args;
187
+ if (platform === "darwin") {
188
+ command = "open";
189
+ args = [url];
190
+ } else if (platform === "win32") {
191
+ command = "cmd";
192
+ args = [
193
+ "/c",
194
+ "start",
195
+ "",
196
+ url
197
+ ];
198
+ } else {
199
+ command = "xdg-open";
200
+ args = [url];
201
+ }
202
+ if (!findExecutableOnPath(command)) return false;
203
+ try {
204
+ spawn(command, args, {
205
+ stdio: "ignore",
206
+ detached: true,
207
+ env: createExternalCommandEnv(process.env)
208
+ }).unref();
209
+ return true;
210
+ } catch {
211
+ return false;
212
+ }
213
+ }
214
+ function normalizePathEntries(rawPath, platform) {
215
+ const delimiter = platform === "win32" ? ";" : ":";
216
+ return rawPath.split(delimiter).map((entry) => entry.trim().replace(/^"+|"+$/g, "")).filter(Boolean);
217
+ }
218
+ function normalizeWindowsPathExt(rawPathExt) {
219
+ const source = rawPathExt && rawPathExt.trim().length > 0 ? rawPathExt : ".COM;.EXE;.BAT;.CMD";
220
+ const unique = /* @__PURE__ */ new Set();
221
+ for (const ext of source.split(";")) {
222
+ const trimmed = ext.trim();
223
+ if (!trimmed) continue;
224
+ const normalized = trimmed.startsWith(".") ? trimmed : `.${trimmed}`;
225
+ unique.add(normalized.toUpperCase());
226
+ }
227
+ return [...unique];
228
+ }
229
+ function hasFileExtension(binary) {
230
+ return binary.lastIndexOf(".") > Math.max(binary.lastIndexOf("/"), binary.lastIndexOf("\\"));
231
+ }
232
+ function findExecutableOnPath(binary, env = process.env, platform = process.platform) {
233
+ const target = binary.trim();
234
+ if (!target) return null;
235
+ if (target.includes("/") || target.includes("\\")) return existsSync(target) ? target : null;
236
+ const rawPath = env.PATH ?? env.Path ?? env.path ?? "";
237
+ if (!rawPath.trim()) return null;
238
+ const entries = normalizePathEntries(rawPath, platform);
239
+ if (entries.length === 0) return null;
240
+ for (const dir of entries) {
241
+ const direct = join(dir, target);
242
+ if (existsSync(direct)) return direct;
243
+ if (platform !== "win32" || hasFileExtension(target)) continue;
244
+ for (const ext of normalizeWindowsPathExt(env.PATHEXT)) {
245
+ const withExt = join(dir, `${target}${ext}`);
246
+ if (existsSync(withExt)) return withExt;
247
+ }
248
+ }
249
+ return null;
250
+ }
251
+ function printAgentResponse(response) {
252
+ console.log("\n" + response + "\n");
253
+ }
254
+ async function prompt(rl, question) {
255
+ rl.setPrompt(question);
256
+ rl.prompt();
257
+ return new Promise((resolve) => {
258
+ rl.once("line", (line) => resolve(line));
259
+ });
260
+ }
261
+ //#endregion
262
+ export { buildServeArgs, findExecutableOnPath, findListeningProcessByPort, getPackageVersion, isLoopbackHost, isProcessRunning, openBrowser, printAgentResponse, prompt, resolvePublicIp, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, resolveUiStaticDir, waitForExit };
@@ -0,0 +1,15 @@
1
+ import { ConfigSetOptions } from "../types/cli.types.js";
2
+
3
+ //#region src/shared/utils/config-path.d.ts
4
+ declare function isIndexSegment(raw: string): boolean;
5
+ declare function parseConfigPath(raw: string): string[];
6
+ declare function parseRequiredConfigPath(raw: string): string[];
7
+ declare function parseConfigSetValue(raw: string, opts: ConfigSetOptions): unknown;
8
+ declare function getAtConfigPath(root: unknown, pathSegments: string[]): {
9
+ found: boolean;
10
+ value?: unknown;
11
+ };
12
+ declare function setAtConfigPath(root: Record<string, unknown>, pathSegments: string[], value: unknown): void;
13
+ declare function unsetAtConfigPath(root: Record<string, unknown>, pathSegments: string[]): boolean;
14
+ //#endregion
15
+ export { getAtConfigPath, isIndexSegment, parseConfigPath, parseConfigSetValue, parseRequiredConfigPath, setAtConfigPath, unsetAtConfigPath };