@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NextClaw contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ import { AgentRuntimeSessionTypeDescribeParams, AgentRuntimeSessionTypeOption } from "@nextclaw/kernel";
2
+
3
+ //#region src/cli/commands/agent/agent-runtime.utils.d.ts
4
+ type AgentRuntimeListEntry = AgentRuntimeSessionTypeOption & {
5
+ default: boolean;
6
+ source: "builtin" | "plugin";
7
+ pluginId?: string;
8
+ };
9
+ type AgentRuntimeListResult = {
10
+ defaultRuntime: string;
11
+ runtimes: AgentRuntimeListEntry[];
12
+ };
13
+ declare function listAvailableAgentRuntimes(params?: AgentRuntimeSessionTypeDescribeParams): Promise<AgentRuntimeListResult>;
14
+ //#endregion
15
+ export { AgentRuntimeListEntry, AgentRuntimeListResult, listAvailableAgentRuntimes };
@@ -0,0 +1,85 @@
1
+ import { buildReservedPluginLoadOptions } from "../../../commands/plugin/plugin-command-utils.js";
2
+ import { resolveDevFirstPartyPluginDir } from "../../../commands/plugin/development-source/first-party-plugin-load-paths.js";
3
+ import { resolveDevPluginLoadingContext } from "../../../commands/plugin/development-source/dev-plugin-overrides.utils.js";
4
+ import { toExtensionRegistry } from "../../../commands/plugin/plugin-extension-registry.js";
5
+ import { logPluginDiagnostics } from "../../../commands/plugin/index.js";
6
+ import { getWorkspacePath, loadConfig } from "@nextclaw/core";
7
+ import { loadOpenClawPlugins } from "@nextclaw/openclaw-compat";
8
+ import { AgentRuntimeRegistry, BuiltinNarpRuntimeRegistrationService, DEFAULT_AGENT_RUNTIME_ENTRY_ID, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, resolveAgentRuntimeEntries } from "@nextclaw/kernel";
9
+ //#region src/cli/commands/agent/agent-runtime.utils.ts
10
+ function createUnusedRuntime(_params) {
11
+ throw new Error("runtime creation is not available during runtime listing");
12
+ }
13
+ function loadRuntimeOnlyPluginRegistry(config, workspaceDir) {
14
+ const { configWithDevPluginOverrides, excludedRoots } = resolveDevPluginLoadingContext(config, resolveDevFirstPartyPluginDir(process.env.NEXTCLAW_DEV_FIRST_PARTY_PLUGIN_DIR));
15
+ return loadOpenClawPlugins({
16
+ config: configWithDevPluginOverrides,
17
+ workspaceDir,
18
+ includeBundled: false,
19
+ kinds: ["agent-runtime"],
20
+ excludeRoots: excludedRoots,
21
+ ...buildReservedPluginLoadOptions(),
22
+ logger: {
23
+ info: (message) => console.log(message),
24
+ warn: (message) => console.warn(message),
25
+ error: (message) => console.error(message),
26
+ debug: (message) => console.debug(message)
27
+ }
28
+ });
29
+ }
30
+ async function listAvailableAgentRuntimes(params) {
31
+ const config = loadConfig();
32
+ const pluginRegistry = loadRuntimeOnlyPluginRegistry(config, getWorkspacePath(config.agents.defaults.workspace));
33
+ logPluginDiagnostics(pluginRegistry);
34
+ const extensionRegistry = toExtensionRegistry(pluginRegistry);
35
+ const runtimeRegistry = new AgentRuntimeRegistry();
36
+ const runtimeSourceByKind = /* @__PURE__ */ new Map();
37
+ const runtimeSourceByEntryId = /* @__PURE__ */ new Map();
38
+ runtimeRegistry.register({
39
+ kind: DEFAULT_AGENT_RUNTIME_ENTRY_ID,
40
+ label: "Native",
41
+ createRuntime: createUnusedRuntime
42
+ });
43
+ runtimeSourceByKind.set(DEFAULT_AGENT_RUNTIME_ENTRY_ID, { source: "builtin" });
44
+ new BuiltinNarpRuntimeRegistrationService(() => config).registerInto(runtimeRegistry);
45
+ runtimeSourceByKind.set("narp-http", { source: "builtin" });
46
+ runtimeSourceByKind.set("narp-stdio", { source: "builtin" });
47
+ for (const registration of extensionRegistry.ncpAgentRuntimes) {
48
+ const normalizedKind = registration.kind.trim().toLowerCase();
49
+ if (normalizedKind === NARP_HTTP_RUNTIME_KIND || normalizedKind === NARP_STDIO_RUNTIME_KIND) continue;
50
+ runtimeRegistry.register({
51
+ kind: registration.kind,
52
+ label: registration.label,
53
+ createRuntime: registration.createRuntime,
54
+ describeSessionType: registration.describeSessionType
55
+ });
56
+ runtimeSourceByKind.set(registration.kind, {
57
+ source: "plugin",
58
+ pluginId: registration.pluginId
59
+ });
60
+ }
61
+ const resolvedEntries = resolveAgentRuntimeEntries({
62
+ config,
63
+ providerKinds: runtimeRegistry.listProviderKinds()
64
+ });
65
+ runtimeRegistry.applyEntries(resolvedEntries);
66
+ for (const entry of resolvedEntries.entries) {
67
+ const source = runtimeSourceByKind.get(entry.type);
68
+ runtimeSourceByEntryId.set(entry.id, source ?? { source: entry.id === DEFAULT_AGENT_RUNTIME_ENTRY_ID ? "builtin" : "plugin" });
69
+ }
70
+ const listed = await runtimeRegistry.listSessionTypes(params);
71
+ return {
72
+ defaultRuntime: listed.defaultType,
73
+ runtimes: listed.options.map((runtime) => {
74
+ const source = runtimeSourceByEntryId.get(runtime.value);
75
+ return {
76
+ ...runtime,
77
+ default: runtime.value === listed.defaultType,
78
+ source: source?.source ?? "plugin",
79
+ ...source?.pluginId ? { pluginId: source.pluginId } : {}
80
+ };
81
+ })
82
+ };
83
+ }
84
+ //#endregion
85
+ export { listAvailableAgentRuntimes };
@@ -0,0 +1,21 @@
1
+ import { AgentCommandOptions } from "../../../shared/types/cli.types.js";
2
+ import { NextclawExtensionRegistry } from "../../../commands/plugin/plugin-extension-registry.js";
3
+ import { Config } from "@nextclaw/core";
4
+ import { LlmProviderRuntime, NextclawKernel } from "@nextclaw/kernel";
5
+
6
+ //#region src/cli/commands/agent/cli-agent-runner.utils.d.ts
7
+ declare function runCliAgentCommand(params: {
8
+ logo: string;
9
+ opts: AgentCommandOptions;
10
+ config: Config;
11
+ kernel: NextclawKernel;
12
+ providerManager: LlmProviderRuntime;
13
+ extensionRegistry: NextclawExtensionRegistry;
14
+ loadResolvedConfig: () => Config;
15
+ resolveMessageToolHints: (params: {
16
+ channel: string;
17
+ accountId?: string | null;
18
+ }) => string[];
19
+ }): Promise<void>;
20
+ //#endregion
21
+ export { runCliAgentCommand };
@@ -0,0 +1,89 @@
1
+ import { printAgentResponse, prompt } from "../../../shared/utils/cli.utils.js";
2
+ import { join, resolve } from "node:path";
3
+ import { getDataDir } from "@nextclaw/core";
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { createInterface } from "node:readline";
6
+ import { dispatchPromptOverNcp } from "@nextclaw/kernel";
7
+ //#region src/cli/commands/agent/cli-agent-runner.utils.ts
8
+ const EXIT_COMMANDS = new Set([
9
+ "exit",
10
+ "quit",
11
+ "/exit",
12
+ "/quit",
13
+ ":q"
14
+ ]);
15
+ function buildCliSharedMetadata(opts) {
16
+ return typeof opts.model === "string" && opts.model.trim() ? { model: opts.model.trim() } : {};
17
+ }
18
+ function createCliHistoryInterface() {
19
+ const historyFile = join(getDataDir(), "history", "cli_history");
20
+ mkdirSync(resolve(historyFile, ".."), { recursive: true });
21
+ const history = existsSync(historyFile) ? readFileSync(historyFile, "utf-8").split("\n").filter(Boolean) : [];
22
+ const rl = createInterface({
23
+ input: process.stdin,
24
+ output: process.stdout
25
+ });
26
+ rl.on("close", () => {
27
+ writeFileSync(historyFile, history.concat(rl.history ?? []).join("\n"));
28
+ process.exit(0);
29
+ });
30
+ return rl;
31
+ }
32
+ async function runCliInteractiveLoop(params) {
33
+ const { config, logo, metadata, ncpAgent, sessionKey, sessionManager } = params;
34
+ console.log(`${logo} Interactive mode (type exit or Ctrl+C to quit)\n`);
35
+ const rl = createCliHistoryInterface();
36
+ let running = true;
37
+ while (running) {
38
+ const trimmed = (await prompt(rl, "You: ")).trim();
39
+ if (!trimmed) continue;
40
+ if (EXIT_COMMANDS.has(trimmed.toLowerCase())) {
41
+ rl.close();
42
+ running = false;
43
+ break;
44
+ }
45
+ printAgentResponse(await dispatchPromptOverNcp({
46
+ config,
47
+ sessionManager,
48
+ resolveNcpAgent: () => ncpAgent,
49
+ sessionKey,
50
+ content: trimmed,
51
+ metadata
52
+ }));
53
+ }
54
+ }
55
+ async function runCliAgentCommand(params) {
56
+ const { config, extensionRegistry, kernel, logo, opts } = params;
57
+ const sessionManager = kernel.sessions;
58
+ kernel.extensions.loadExtensionRegistry(extensionRegistry);
59
+ await kernel.start();
60
+ const ncpAgent = kernel.agentRuntimeManager.currentHandle;
61
+ if (!ncpAgent) throw new Error("Kernel start completed without an agent runtime handle.");
62
+ try {
63
+ const sessionKey = opts.session ?? "cli:default";
64
+ const sharedMetadata = buildCliSharedMetadata(opts);
65
+ if (opts.message) {
66
+ printAgentResponse(await dispatchPromptOverNcp({
67
+ config,
68
+ sessionManager,
69
+ resolveNcpAgent: () => ncpAgent,
70
+ sessionKey,
71
+ content: opts.message,
72
+ metadata: sharedMetadata
73
+ }));
74
+ return;
75
+ }
76
+ await runCliInteractiveLoop({
77
+ logo,
78
+ config,
79
+ sessionManager,
80
+ ncpAgent,
81
+ sessionKey,
82
+ metadata: sharedMetadata
83
+ });
84
+ } finally {
85
+ await ncpAgent.dispose?.();
86
+ }
87
+ }
88
+ //#endregion
89
+ export { runCliAgentCommand };
@@ -0,0 +1,3 @@
1
+ import { runCliAgentCommand } from "./cli-agent-runner.utils.js";
2
+ import { AgentCommands } from "./services/agent-commands.service.js";
3
+ export { AgentCommands, runCliAgentCommand };
@@ -0,0 +1,3 @@
1
+ import { runCliAgentCommand } from "./cli-agent-runner.utils.js";
2
+ import { AgentCommands } from "./services/agent-commands.service.js";
3
+ export { AgentCommands, runCliAgentCommand };
@@ -0,0 +1,17 @@
1
+ import { AgentsListCommandOptions, AgentsNewCommandOptions, AgentsRemoveCommandOptions, AgentsRuntimesCommandOptions, AgentsUpdateCommandOptions } from "../../../../shared/types/cli.types.js";
2
+
3
+ //#region src/cli/commands/agent/services/agent-commands.service.d.ts
4
+ declare class AgentCommands {
5
+ private readonly deps;
6
+ constructor(deps: {
7
+ initializeAgentHomeDirectory: (homeDirectory: string) => void;
8
+ });
9
+ list: (opts?: AgentsListCommandOptions) => void;
10
+ runtimes: (opts?: AgentsRuntimesCommandOptions) => Promise<void>;
11
+ create: (agentId: string, opts?: AgentsNewCommandOptions) => Promise<void>;
12
+ update: (agentId: string, opts?: AgentsUpdateCommandOptions) => Promise<void>;
13
+ remove: (agentId: string, opts?: AgentsRemoveCommandOptions) => Promise<void>;
14
+ private toAgentListEntry;
15
+ }
16
+ //#endregion
17
+ export { AgentCommands };
@@ -0,0 +1,112 @@
1
+ import { listAvailableAgentRuntimes } from "../agent-runtime.utils.js";
2
+ import { BUILTIN_MAIN_AGENT_ID, createAgentProfile, loadConfig, removeAgentProfile, resolveEffectiveAgentProfiles, updateAgentProfile } from "@nextclaw/core";
3
+ //#region src/cli/commands/agent/services/agent-commands.service.ts
4
+ var AgentCommands = class {
5
+ constructor(deps) {
6
+ this.deps = deps;
7
+ }
8
+ list = (opts = {}) => {
9
+ const agents = resolveEffectiveAgentProfiles(loadConfig()).map((agent) => this.toAgentListEntry(agent));
10
+ if (opts.json) {
11
+ console.log(JSON.stringify(agents, null, 2));
12
+ return;
13
+ }
14
+ for (const agent of agents) {
15
+ const head = agent.builtIn ? `${agent.id} (built-in)` : agent.id;
16
+ console.log(head);
17
+ console.log(` name: ${agent.displayName ?? "-"}`);
18
+ console.log(` description: ${agent.description ?? "-"}`);
19
+ console.log(` home: ${agent.workspace}`);
20
+ console.log(` avatar: ${agent.avatar ?? "-"}`);
21
+ console.log(` runtime: ${agent.runtime ?? "-"}`);
22
+ }
23
+ };
24
+ runtimes = async (opts = {}) => {
25
+ const describeMode = opts.probe ? "probe" : "observation";
26
+ const listed = await listAvailableAgentRuntimes({ describeMode });
27
+ if (opts.json) {
28
+ console.log(JSON.stringify({
29
+ defaultRuntime: listed.defaultRuntime,
30
+ describeMode,
31
+ runtimes: listed.runtimes
32
+ }, null, 2));
33
+ return;
34
+ }
35
+ for (const runtime of listed.runtimes) {
36
+ const head = runtime.default ? `${runtime.value} (default)` : runtime.value;
37
+ console.log(head);
38
+ console.log(` label: ${runtime.label}`);
39
+ console.log(` source: ${runtime.source}`);
40
+ if (runtime.pluginId) console.log(` pluginId: ${runtime.pluginId}`);
41
+ console.log(` ready: ${runtime.ready === false ? "no" : "yes"}`);
42
+ console.log(` reason: ${runtime.reason ?? "-"}`);
43
+ console.log(` reasonMessage: ${runtime.reasonMessage ?? "-"}`);
44
+ console.log(` recommendedModel: ${runtime.recommendedModel ?? "-"}`);
45
+ console.log(` supportedModels: ${runtime.supportedModels?.join(", ") ?? "-"}`);
46
+ }
47
+ };
48
+ create = async (agentId, opts = {}) => {
49
+ const created = createAgentProfile({
50
+ id: agentId,
51
+ displayName: opts.name,
52
+ description: opts.description,
53
+ avatar: opts.avatar,
54
+ home: opts.home,
55
+ runtime: opts.runtime
56
+ }, { initializeHomeDirectory: this.deps.initializeAgentHomeDirectory });
57
+ if (opts.json) {
58
+ console.log(JSON.stringify({ agent: created }, null, 2));
59
+ return;
60
+ }
61
+ console.log(`✓ Created agent ${created.id}`);
62
+ console.log(` name: ${created.displayName ?? "-"}`);
63
+ console.log(` description: ${created.description ?? "-"}`);
64
+ console.log(` home: ${created.workspace}`);
65
+ console.log(` avatar: ${created.avatar ?? "-"}`);
66
+ console.log(` runtime: ${created.runtime ?? created.engine ?? "-"}`);
67
+ };
68
+ update = async (agentId, opts = {}) => {
69
+ const updated = updateAgentProfile({
70
+ id: agentId,
71
+ displayName: opts.name,
72
+ description: opts.description,
73
+ avatar: opts.avatar,
74
+ runtime: opts.runtime
75
+ });
76
+ if (opts.json) {
77
+ console.log(JSON.stringify({ agent: updated }, null, 2));
78
+ return;
79
+ }
80
+ console.log(`✓ Updated agent ${updated.id}`);
81
+ console.log(` name: ${updated.displayName ?? "-"}`);
82
+ console.log(` description: ${updated.description ?? "-"}`);
83
+ console.log(` home: ${updated.workspace}`);
84
+ console.log(` avatar: ${updated.avatar ?? "-"}`);
85
+ console.log(` runtime: ${updated.runtime ?? updated.engine ?? "-"}`);
86
+ };
87
+ remove = async (agentId, opts = {}) => {
88
+ if (agentId.trim().toLowerCase() === BUILTIN_MAIN_AGENT_ID) throw new Error(`agent id '${BUILTIN_MAIN_AGENT_ID}' is reserved`);
89
+ if (!removeAgentProfile(agentId)) throw new Error(`agent '${agentId}' not found`);
90
+ if (opts.json) {
91
+ console.log(JSON.stringify({
92
+ removed: true,
93
+ agentId
94
+ }, null, 2));
95
+ return;
96
+ }
97
+ console.log(`✓ Removed agent ${agentId}`);
98
+ };
99
+ toAgentListEntry = (agent) => {
100
+ return {
101
+ id: agent.id,
102
+ displayName: agent.displayName ?? null,
103
+ description: agent.description ?? null,
104
+ avatar: agent.avatar ?? null,
105
+ workspace: agent.workspace,
106
+ runtime: agent.runtime ?? agent.engine ?? null,
107
+ builtIn: agent.builtIn === true
108
+ };
109
+ };
110
+ };
111
+ //#endregion
112
+ export { AgentCommands };
@@ -0,0 +1,15 @@
1
+ import { CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions } from "../../../shared/types/cli.types.js";
2
+ import { CompanionProcessService } from "./services/companion-process.service.js";
3
+
4
+ //#region src/cli/commands/companion/index.d.ts
5
+ declare class CompanionCommands {
6
+ private readonly companionProcessService;
7
+ constructor(companionProcessService?: CompanionProcessService);
8
+ readonly start: (options?: CompanionStartCommandOptions) => Promise<void>;
9
+ readonly enable: (options?: CompanionEnableCommandOptions) => Promise<void>;
10
+ readonly disable: (options?: CompanionDisableCommandOptions) => Promise<void>;
11
+ readonly status: (options?: CompanionStatusCommandOptions) => Promise<void>;
12
+ readonly stop: (options?: CompanionStopCommandOptions) => Promise<void>;
13
+ }
14
+ //#endregion
15
+ export { CompanionCommands };
@@ -0,0 +1,24 @@
1
+ import { CompanionProcessService } from "./services/companion-process.service.js";
2
+ //#region src/cli/commands/companion/index.ts
3
+ var CompanionCommands = class {
4
+ constructor(companionProcessService = new CompanionProcessService()) {
5
+ this.companionProcessService = companionProcessService;
6
+ }
7
+ start = async (options = {}) => {
8
+ await this.companionProcessService.start(options);
9
+ };
10
+ enable = async (options = {}) => {
11
+ await this.companionProcessService.enable(options);
12
+ };
13
+ disable = async (options = {}) => {
14
+ await this.companionProcessService.disable(options);
15
+ };
16
+ status = async (options = {}) => {
17
+ await this.companionProcessService.status(options);
18
+ };
19
+ stop = async (options = {}) => {
20
+ await this.companionProcessService.stop(options);
21
+ };
22
+ };
23
+ //#endregion
24
+ export { CompanionCommands };
@@ -0,0 +1,17 @@
1
+ import { CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions } from "../../../../shared/types/cli.types.js";
2
+ import { CompanionRuntimeService } from "../../../../shared/services/ui/companion-runtime.service.js";
3
+
4
+ //#region src/cli/commands/companion/services/companion-process.service.d.ts
5
+ declare class CompanionProcessService {
6
+ private readonly runtimeService;
7
+ constructor(runtimeService?: CompanionRuntimeService);
8
+ readonly start: (options?: CompanionStartCommandOptions) => Promise<void>;
9
+ readonly status: (options?: CompanionStatusCommandOptions) => Promise<void>;
10
+ readonly stop: (options?: CompanionStopCommandOptions) => Promise<void>;
11
+ readonly enable: (options?: CompanionEnableCommandOptions) => Promise<void>;
12
+ readonly disable: (_options?: CompanionDisableCommandOptions) => Promise<void>;
13
+ private readonly resolveBaseUrl;
14
+ private readonly printConfigEnabled;
15
+ }
16
+ //#endregion
17
+ export { CompanionProcessService };
@@ -0,0 +1,49 @@
1
+ import { companionRuntimeService } from "../../../../shared/services/ui/companion-runtime.service.js";
2
+ import "@nextclaw/core";
3
+ //#region src/cli/commands/companion/services/companion-process.service.ts
4
+ var CompanionProcessService = class {
5
+ constructor(runtimeService = companionRuntimeService) {
6
+ this.runtimeService = runtimeService;
7
+ }
8
+ start = async (options = {}) => {
9
+ const state = await this.runtimeService.ensureStarted({ baseUrl: this.resolveBaseUrl(options) });
10
+ this.runtimeService.printStarted(state);
11
+ };
12
+ status = async (options = {}) => {
13
+ this.runtimeService.printStatus(options);
14
+ };
15
+ stop = async (options = {}) => {
16
+ const stopped = await this.runtimeService.ensureStopped(options);
17
+ this.runtimeService.printStopped(stopped);
18
+ };
19
+ enable = async (options = {}) => {
20
+ const nextConfig = await this.runtimeService.updateEnabled(true, options);
21
+ this.printConfigEnabled(nextConfig, options.baseUrl);
22
+ };
23
+ disable = async (_options = {}) => {
24
+ const nextConfig = await this.runtimeService.updateEnabled(false);
25
+ console.log(nextConfig.companion.enabled ? "Companion remains enabled." : "Companion feature disabled. It will stay off until you enable it again.");
26
+ };
27
+ resolveBaseUrl = (options) => {
28
+ const explicitBaseUrl = options.baseUrl?.trim();
29
+ if (explicitBaseUrl) return explicitBaseUrl.replace(/\/+$/, "");
30
+ const discoveredBaseUrl = this.runtimeService.resolveDiscoveredBaseUrl();
31
+ if (discoveredBaseUrl) return discoveredBaseUrl;
32
+ const runningState = this.runtimeService.getRunningState();
33
+ if (runningState) return runningState.baseUrl;
34
+ throw new Error("Cannot resolve NextClaw UI base URL. Start NextClaw first or pass --base-url.");
35
+ };
36
+ printConfigEnabled = (config, baseUrl) => {
37
+ if (this.runtimeService.getRunningState()) {
38
+ console.log("Companion feature enabled and companion started.");
39
+ return;
40
+ }
41
+ if (baseUrl?.trim()) {
42
+ console.log("Companion feature enabled.");
43
+ return;
44
+ }
45
+ console.log(config.companion.enabled ? "Companion feature enabled. It will auto-start the next time a local NextClaw runtime is available." : "Companion feature is not enabled.");
46
+ };
47
+ };
48
+ //#endregion
49
+ export { CompanionProcessService };
@@ -0,0 +1,2 @@
1
+ import { ConfigCommands } from "./services/config-commands.service.js";
2
+ export { ConfigCommands };
@@ -0,0 +1,2 @@
1
+ import { ConfigCommands } from "./services/config-commands.service.js";
2
+ export { ConfigCommands };
@@ -0,0 +1,18 @@
1
+ import { ConfigGetOptions, ConfigSetOptions, RequestRestartParams } from "../../../../shared/types/cli.types.js";
2
+
3
+ //#region src/cli/commands/config/services/config-commands.service.d.ts
4
+ declare class ConfigCommands {
5
+ private deps;
6
+ constructor(deps: {
7
+ requestRestart: (params: RequestRestartParams) => Promise<void>;
8
+ });
9
+ get: (pathExpr: string, opts?: ConfigGetOptions) => void;
10
+ set: (pathExpr: string, value: string, opts?: ConfigSetOptions) => Promise<void>;
11
+ unset: (pathExpr: string) => Promise<void>;
12
+ private resolveReadConfigView;
13
+ private resolveProjectedChannelContext;
14
+ private loadPluginChannelBindings;
15
+ private requestRestartForConfigDiff;
16
+ }
17
+ //#endregion
18
+ export { ConfigCommands };
@@ -0,0 +1,133 @@
1
+ import { getAtConfigPath, parseConfigSetValue, parseRequiredConfigPath, setAtConfigPath, unsetAtConfigPath } from "../../../../shared/utils/config-path.js";
2
+ import { resolveChannelConfigView } from "../../../../commands/channel/channel-config-view.js";
3
+ import { loadPluginRegistry, mergePluginConfigView } from "../../../../commands/plugin/index.js";
4
+ import "../../../../commands/channel/index.js";
5
+ import { buildReloadPlan, diffConfigPaths, getWorkspacePath, loadConfig, saveConfig } from "@nextclaw/core";
6
+ import { getPluginChannelBindings } from "@nextclaw/openclaw-compat";
7
+ //#region src/cli/commands/config/services/config-commands.service.ts
8
+ var ConfigCommands = class {
9
+ constructor(deps) {
10
+ this.deps = deps;
11
+ }
12
+ get = (pathExpr, opts = {}) => {
13
+ let parsedPath;
14
+ try {
15
+ parsedPath = parseRequiredConfigPath(pathExpr);
16
+ } catch (error) {
17
+ console.error(String(error));
18
+ process.exit(1);
19
+ return;
20
+ }
21
+ const config = loadConfig();
22
+ const result = getAtConfigPath(this.resolveReadConfigView(config, parsedPath), parsedPath);
23
+ if (!result.found) {
24
+ console.error(`Config path not found: ${pathExpr}`);
25
+ process.exit(1);
26
+ return;
27
+ }
28
+ if (opts.json) {
29
+ console.log(JSON.stringify(result.value ?? null, null, 2));
30
+ return;
31
+ }
32
+ if (typeof result.value === "string" || typeof result.value === "number" || typeof result.value === "boolean") {
33
+ console.log(String(result.value));
34
+ return;
35
+ }
36
+ console.log(JSON.stringify(result.value ?? null, null, 2));
37
+ };
38
+ set = async (pathExpr, value, opts = {}) => {
39
+ let parsedPath;
40
+ try {
41
+ parsedPath = parseRequiredConfigPath(pathExpr);
42
+ } catch (error) {
43
+ console.error(String(error));
44
+ process.exit(1);
45
+ return;
46
+ }
47
+ let parsedValue;
48
+ try {
49
+ parsedValue = parseConfigSetValue(value, opts);
50
+ } catch (error) {
51
+ console.error(`Failed to parse config value: ${String(error)}`);
52
+ process.exit(1);
53
+ return;
54
+ }
55
+ const prevConfig = loadConfig();
56
+ const projectedContext = this.resolveProjectedChannelContext(prevConfig, parsedPath);
57
+ const nextConfigTarget = projectedContext ? structuredClone(projectedContext.view) : structuredClone(prevConfig);
58
+ try {
59
+ setAtConfigPath(nextConfigTarget, parsedPath, parsedValue);
60
+ } catch (error) {
61
+ console.error(String(error));
62
+ process.exit(1);
63
+ return;
64
+ }
65
+ const nextConfig = projectedContext ? mergePluginConfigView(prevConfig, nextConfigTarget, projectedContext.bindings) : nextConfigTarget;
66
+ saveConfig(nextConfig);
67
+ await this.requestRestartForConfigDiff({
68
+ prevConfig,
69
+ nextConfig,
70
+ reason: `config.set ${pathExpr}`,
71
+ manualMessage: `Updated ${pathExpr}. Restart the gateway to apply.`
72
+ });
73
+ };
74
+ unset = async (pathExpr) => {
75
+ let parsedPath;
76
+ try {
77
+ parsedPath = parseRequiredConfigPath(pathExpr);
78
+ } catch (error) {
79
+ console.error(String(error));
80
+ process.exit(1);
81
+ return;
82
+ }
83
+ const prevConfig = loadConfig();
84
+ const projectedContext = this.resolveProjectedChannelContext(prevConfig, parsedPath);
85
+ const nextConfigTarget = projectedContext ? structuredClone(projectedContext.view) : structuredClone(prevConfig);
86
+ if (!unsetAtConfigPath(nextConfigTarget, parsedPath)) {
87
+ console.error(`Config path not found: ${pathExpr}`);
88
+ process.exit(1);
89
+ return;
90
+ }
91
+ const nextConfig = projectedContext ? mergePluginConfigView(prevConfig, nextConfigTarget, projectedContext.bindings) : nextConfigTarget;
92
+ saveConfig(nextConfig);
93
+ await this.requestRestartForConfigDiff({
94
+ prevConfig,
95
+ nextConfig,
96
+ reason: `config.unset ${pathExpr}`,
97
+ manualMessage: `Removed ${pathExpr}. Restart the gateway to apply.`
98
+ });
99
+ };
100
+ resolveReadConfigView = (config, parsedPath) => {
101
+ if (parsedPath[0] !== "channels") return config;
102
+ const { bindings } = this.loadPluginChannelBindings(config);
103
+ return resolveChannelConfigView(config, bindings);
104
+ };
105
+ resolveProjectedChannelContext = (config, parsedPath) => {
106
+ if (parsedPath[0] !== "channels" || parsedPath.length < 2) return null;
107
+ const channelId = parsedPath[1];
108
+ const { bindings } = this.loadPluginChannelBindings(config);
109
+ if (!bindings.some((binding) => binding.channelId === channelId)) return null;
110
+ return {
111
+ bindings,
112
+ view: resolveChannelConfigView(config, bindings)
113
+ };
114
+ };
115
+ loadPluginChannelBindings = (config) => {
116
+ return { bindings: getPluginChannelBindings(loadPluginRegistry(config, getWorkspacePath(config.agents.defaults.workspace))) };
117
+ };
118
+ requestRestartForConfigDiff = async (params) => {
119
+ const { manualMessage, nextConfig, prevConfig, reason } = params;
120
+ const changedPaths = diffConfigPaths(prevConfig, nextConfig);
121
+ if (!changedPaths.length) return;
122
+ const plan = buildReloadPlan(changedPaths);
123
+ if (plan.restartRequired.length === 0) return;
124
+ await this.deps.requestRestart({
125
+ changedPaths: plan.restartRequired,
126
+ mode: "notify",
127
+ reason: `${reason} (${plan.restartRequired.join(", ")})`,
128
+ manualMessage
129
+ });
130
+ };
131
+ };
132
+ //#endregion
133
+ export { ConfigCommands };
@@ -0,0 +1,2 @@
1
+ import { CronCommands } from "./services/cron-commands.service.js";
2
+ export { CronCommands };
@@ -0,0 +1,2 @@
1
+ import { CronCommands } from "./services/cron-commands.service.js";
2
+ export { CronCommands };