@nextclaw/service 0.1.17 → 0.1.18-beta.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 (85) hide show
  1. package/dist/cli/commands/agent/cli-agent-runner.utils.d.ts.map +1 -1
  2. package/dist/cli/commands/agent/cli-agent-runner.utils.js +9 -5
  3. package/dist/cli/commands/agent/cli-agent-runner.utils.js.map +1 -1
  4. package/dist/cli/commands/config/services/config-commands.service.d.ts +0 -2
  5. package/dist/cli/commands/config/services/config-commands.service.d.ts.map +1 -1
  6. package/dist/cli/commands/config/services/config-commands.service.js +7 -25
  7. package/dist/cli/commands/config/services/config-commands.service.js.map +1 -1
  8. package/dist/commands/channel/channel-config-view.utils.d.ts +7 -0
  9. package/dist/commands/channel/channel-config-view.utils.d.ts.map +1 -0
  10. package/dist/commands/channel/channel-config-view.utils.js +9 -0
  11. package/dist/commands/channel/channel-config-view.utils.js.map +1 -0
  12. package/dist/commands/channel/channel-list-view.service.d.ts +0 -4
  13. package/dist/commands/channel/channel-list-view.service.d.ts.map +1 -1
  14. package/dist/commands/channel/channel-list-view.service.js +6 -19
  15. package/dist/commands/channel/channel-list-view.service.js.map +1 -1
  16. package/dist/commands/channel/index.d.ts +1 -12
  17. package/dist/commands/channel/index.d.ts.map +1 -1
  18. package/dist/commands/channel/index.js +26 -160
  19. package/dist/commands/channel/index.js.map +1 -1
  20. package/dist/service-runtime.service.d.ts +0 -2
  21. package/dist/service-runtime.service.d.ts.map +1 -1
  22. package/dist/service-runtime.service.js +10 -28
  23. package/dist/service-runtime.service.js.map +1 -1
  24. package/dist/shared/services/gateway/managers/gateway-extension.manager.d.ts +23 -0
  25. package/dist/shared/services/gateway/managers/gateway-extension.manager.d.ts.map +1 -0
  26. package/dist/shared/services/gateway/managers/gateway-extension.manager.js +77 -0
  27. package/dist/shared/services/gateway/managers/gateway-extension.manager.js.map +1 -0
  28. package/dist/shared/services/gateway/nextclaw-app.service.d.ts.map +1 -1
  29. package/dist/shared/services/gateway/nextclaw-app.service.js +2 -3
  30. package/dist/shared/services/gateway/nextclaw-app.service.js.map +1 -1
  31. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +4 -5
  32. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts.map +1 -1
  33. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +13 -38
  34. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js.map +1 -1
  35. package/dist/shared/services/gateway/service-bootstrap-status.service.d.ts +9 -9
  36. package/dist/shared/services/gateway/service-bootstrap-status.service.d.ts.map +1 -1
  37. package/dist/shared/services/gateway/service-bootstrap-status.service.js +24 -24
  38. package/dist/shared/services/gateway/service-bootstrap-status.service.js.map +1 -1
  39. package/dist/shared/services/gateway/service-startup-support.service.d.ts +1 -9
  40. package/dist/shared/services/gateway/service-startup-support.service.d.ts.map +1 -1
  41. package/dist/shared/services/gateway/service-startup-support.service.js +1 -14
  42. package/dist/shared/services/gateway/service-startup-support.service.js.map +1 -1
  43. package/dist/shared/services/gateway/utils/cron-job-handler.utils.d.ts +2 -2
  44. package/dist/shared/services/gateway/utils/cron-job-handler.utils.d.ts.map +1 -1
  45. package/dist/shared/services/gateway/utils/cron-job-handler.utils.js +7 -14
  46. package/dist/shared/services/gateway/utils/cron-job-handler.utils.js.map +1 -1
  47. package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js +1 -1
  48. package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js.map +1 -1
  49. package/dist/shared/services/marketplace/service-marketplace-installer.service.d.ts +0 -4
  50. package/dist/shared/services/marketplace/service-marketplace-installer.service.d.ts.map +1 -1
  51. package/dist/shared/services/marketplace/service-marketplace-installer.service.js +0 -27
  52. package/dist/shared/services/marketplace/service-marketplace-installer.service.js.map +1 -1
  53. package/dist/shared/services/workspace/workspace-manager.service.d.ts +0 -7
  54. package/dist/shared/services/workspace/workspace-manager.service.d.ts.map +1 -1
  55. package/dist/shared/services/workspace/workspace-manager.service.js +2 -50
  56. package/dist/shared/services/workspace/workspace-manager.service.js.map +1 -1
  57. package/package.json +33 -20
  58. package/dist/commands/channel/channel-config-view.d.ts +0 -8
  59. package/dist/commands/channel/channel-config-view.d.ts.map +0 -1
  60. package/dist/commands/channel/channel-config-view.js +0 -9
  61. package/dist/commands/channel/channel-config-view.js.map +0 -1
  62. package/dist/commands/plugin/index.d.ts +0 -29
  63. package/dist/commands/plugin/index.d.ts.map +0 -1
  64. package/dist/commands/plugin/index.js +0 -256
  65. package/dist/commands/plugin/index.js.map +0 -1
  66. package/dist/commands/plugin/plugin-command.utils.d.ts +0 -13
  67. package/dist/commands/plugin/plugin-command.utils.d.ts.map +0 -1
  68. package/dist/commands/plugin/plugin-command.utils.js +0 -37
  69. package/dist/commands/plugin/plugin-command.utils.js.map +0 -1
  70. package/dist/commands/plugin/plugin-mutation-actions.utils.d.ts +0 -16
  71. package/dist/commands/plugin/plugin-mutation-actions.utils.d.ts.map +0 -1
  72. package/dist/commands/plugin/plugin-mutation-actions.utils.js +0 -164
  73. package/dist/commands/plugin/plugin-mutation-actions.utils.js.map +0 -1
  74. package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts +0 -32
  75. package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts.map +0 -1
  76. package/dist/shared/services/gateway/managers/gateway-plugin.manager.js +0 -176
  77. package/dist/shared/services/gateway/managers/gateway-plugin.manager.js.map +0 -1
  78. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.d.ts +0 -25
  79. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.d.ts.map +0 -1
  80. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js +0 -119
  81. package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js.map +0 -1
  82. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.d.ts +0 -7
  83. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.d.ts.map +0 -1
  84. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js +0 -97
  85. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js.map +0 -1
@@ -4,8 +4,7 @@ import { NextclawDistributionService } from "../runtime/nextclaw-distribution.se
4
4
  import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
5
5
  import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
6
6
  import { GatewayControllerImpl } from "../../controllers/gateway.controller.js";
7
- import { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from "./service-startup-support.service.js";
8
- import { GatewayPluginManager } from "./managers/gateway-plugin.manager.js";
7
+ import { GatewayExtensionManager } from "./managers/gateway-extension.manager.js";
9
8
  import { GatewayRemoteManager } from "./managers/gateway-remote.manager.js";
10
9
  import { GatewayRestartWakeService } from "./gateway-restart-wake.service.js";
11
10
  import { createCronJobHandler } from "./utils/cron-job-handler.utils.js";
@@ -13,20 +12,17 @@ import { companionRuntimeService } from "../ui/companion-runtime.service.js";
13
12
  import { handleGatewayDeferredStartupError } from "./utils/gateway-runtime-lifecycle.utils.js";
14
13
  import { NextclawApp } from "./nextclaw-app.service.js";
15
14
  import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.js";
16
- import { installPluginRuntimeBridge } from "../plugin/utils/plugin-runtime-bridge.utils.js";
17
- import { wrapStartChannelsWithDevPluginHotReload } from "../plugin/utils/plugin-dev-hot-reload.utils.js";
15
+ import { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from "./service-startup-support.service.js";
18
16
  import { ServiceMarketplaceInstaller } from "../marketplace/service-marketplace-installer.service.js";
19
17
  import { NpmRuntimeUpdateHost } from "../ui/npm-runtime-update-host.service.js";
20
18
  import { createRuntimeControlHost } from "../ui/runtime-control-host.service.js";
21
19
  import * as NextclawCore from "@nextclaw/core";
22
- import { NextclawKernel, runGatewayInboundLoop } from "@nextclaw/kernel";
23
- import { setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
20
+ import { AgentRunClient, NextclawKernel, runGatewayInboundLoop } from "@nextclaw/kernel";
24
21
  import { resolve } from "node:path";
25
22
  import { startUiServer } from "@nextclaw/server";
26
23
  import { setImmediate } from "node:timers/promises";
27
24
  //#region src/shared/services/gateway/nextclaw-gateway-runtime.service.ts
28
25
  const { getConfigPath: getConfigPath$1, getDataDir: getDataDir$1, getWorkspacePath: getWorkspacePath$1 } = NextclawCore;
29
- const DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS = 5e3;
30
26
  function resolveApplyRestartMode(uiPort) {
31
27
  const serviceState = managedServiceStateStore.read();
32
28
  if (serviceState?.pid === process.pid) return "managed-service-restart";
@@ -39,6 +35,7 @@ var NextclawGatewayRuntime = class {
39
35
  messageBus;
40
36
  sessionManager;
41
37
  automation;
38
+ agentRunClient;
42
39
  runtimeControl;
43
40
  runtimeUpdate;
44
41
  ingress;
@@ -52,7 +49,7 @@ var NextclawGatewayRuntime = class {
52
49
  workspace;
53
50
  remoteManager;
54
51
  marketplace;
55
- plugins;
52
+ extensions;
56
53
  restartWake;
57
54
  bootstrapStatus;
58
55
  uiStartup;
@@ -73,11 +70,15 @@ var NextclawGatewayRuntime = class {
73
70
  this.workspace = getWorkspacePath$1(config.agents.defaults.workspace);
74
71
  this.appEventBus = this.kernel.eventBus;
75
72
  this.ingress = this.kernel.ingress;
73
+ this.agentRunClient = new AgentRunClient({
74
+ eventBus: this.kernel.eventBus,
75
+ ingress: this.kernel.ingress
76
+ });
76
77
  this.messageBus = this.kernel.messageBus;
77
78
  this.sessionManager = this.kernel.sessions;
78
79
  this.automation = this.kernel.automation;
79
80
  this.productVersion = this.distribution.version;
80
- this.plugins = new GatewayPluginManager(this);
81
+ this.extensions = new GatewayExtensionManager(this);
81
82
  this.providerManager = this.kernel.llmProviders;
82
83
  this.installConfigHostHooks();
83
84
  this.restartWake = new GatewayRestartWakeService(this);
@@ -105,7 +106,7 @@ var NextclawGatewayRuntime = class {
105
106
  this.kernel.provideGatewayController(this.gatewayController);
106
107
  this.deferredChannelStarter = this.startChannels;
107
108
  this.automation.onJob = createCronJobHandler({
108
- agentRunRequests: this.kernel.agentRunRequestManager,
109
+ agentRunClient: this.agentRunClient,
109
110
  bus: this.messageBus
110
111
  });
111
112
  }
@@ -117,7 +118,6 @@ var NextclawGatewayRuntime = class {
117
118
  await companionRuntimeService.applyConfig(this.configManager.config);
118
119
  await this.markUiRuntimeReady();
119
120
  await this.startSupportServices();
120
- this.installChannelDevHotReload();
121
121
  await this.runRuntimeLoop();
122
122
  await companionRuntimeService.ensureStopped();
123
123
  logStartupTrace("service.start_gateway.end");
@@ -174,7 +174,7 @@ var NextclawGatewayRuntime = class {
174
174
  runtimeControl: this.runtimeControl,
175
175
  ...this.runtimeUpdate ? { runtimeUpdate: this.runtimeUpdate } : {},
176
176
  bootstrapStatus: this.bootstrapStatus,
177
- plugins: this.plugins
177
+ extensions: this.extensions
178
178
  });
179
179
  runRuntimeLoop = async () => {
180
180
  logStartupTrace("service.start_gateway.runtime_loop_begin");
@@ -198,17 +198,6 @@ var NextclawGatewayRuntime = class {
198
198
  startDeferredChannels = async () => {
199
199
  await this.deferredChannelStarter();
200
200
  };
201
- installChannelDevHotReload = () => {
202
- this.deferredChannelStarter = wrapStartChannelsWithDevPluginHotReload({
203
- startChannels: this.startChannels,
204
- watcherRegistry: this.fileWatchers,
205
- isRuntimeActive: () => true,
206
- reloadPlugins: async (pluginIds) => {
207
- await this.plugins.reloadForDevHotReload(pluginIds.map((pluginId) => `plugins.entries.${pluginId}.source`));
208
- },
209
- startupSettleMs: DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS
210
- });
211
- };
212
201
  startChannels = async () => {
213
202
  await this.kernel.channels.start();
214
203
  const enabledChannels = this.kernel.channels.enabledChannels;
@@ -229,8 +218,6 @@ var NextclawGatewayRuntime = class {
229
218
  await this.fileWatchers.clear();
230
219
  await this.kernel.extensions.stop();
231
220
  await this.remoteManager.stop();
232
- await this.plugins.stopGateways();
233
- setPluginRuntimeBridge(null);
234
221
  };
235
222
  markUiRuntimeReady = async () => {
236
223
  this.bootstrapStatus.markShellReady();
@@ -254,8 +241,7 @@ var NextclawGatewayRuntime = class {
254
241
  }));
255
242
  };
256
243
  startSupportServices = async () => {
257
- this.plugins.publishConfigChanges();
258
- this.configurePluginRuntime();
244
+ this.extensions.publishConfigChanges();
259
245
  await measureStartupAsync("service.start_gateway_support_services", async () => await startGatewayRuntimeSupport({
260
246
  automation: this.automation,
261
247
  remoteModule: this.remoteManager.remoteModule,
@@ -267,22 +253,11 @@ var NextclawGatewayRuntime = class {
267
253
  watcherRegistry: this.fileWatchers
268
254
  }));
269
255
  };
270
- configurePluginRuntime = () => {
271
- installPluginRuntimeBridge(this);
272
- };
273
256
  installConfigHostHooks = () => {
274
257
  this.configManager.installRuntimeHooks({
275
258
  reloadCompanion: async ({ config: nextConfig }) => {
276
259
  await companionRuntimeService.applyConfig(nextConfig);
277
260
  },
278
- reloadPlugins: async ({ config: nextConfig, changedPaths }) => {
279
- const result = await this.plugins.reloadForConfigChange({
280
- config: nextConfig,
281
- changedPaths
282
- });
283
- if (result.restartChannels) console.log("Config reload: plugin channel gateways restarted.");
284
- return { restartChannels: result.restartChannels };
285
- },
286
261
  onRestartRequired: (paths) => {
287
262
  this.deps.requestRestart({
288
263
  changedPaths: paths,
@@ -1 +1 @@
1
- {"version":3,"file":"nextclaw-gateway-runtime.service.js","names":["getConfigPath","getDataDir","getWorkspacePath","waitForNextTick"],"sources":["../../../../src/shared/services/gateway/nextclaw-gateway-runtime.service.ts"],"sourcesContent":["import * as NextclawCore from \"@nextclaw/core\";\nimport {\n NextclawKernel,\n runGatewayInboundLoop,\n type AutomationManager,\n type ConfigManager,\n type LlmProviderManager,\n} from \"@nextclaw/kernel\";\nimport type { EventBus, Ingress } from \"@nextclaw/shared\";\nimport {\n setPluginRuntimeBridge,\n} from \"@nextclaw/openclaw-compat\";\nimport {\n startUiServer,\n type MarketplaceApiConfig,\n type UiRouterOptions,\n type UiRuntimeControlHost,\n type UiRuntimeUpdateHost,\n} from \"@nextclaw/server\";\nimport { resolve } from \"node:path\";\nimport { setImmediate as waitForNextTick } from \"node:timers/promises\";\nimport { GatewayControllerImpl } from \"@nextclaw-service/shared/controllers/gateway.controller.js\";\nimport { GatewayPluginManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-plugin.manager.js\";\nimport { GatewayRemoteManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-remote.manager.js\";\nimport { GatewayRestartWakeService } from \"@nextclaw-service/shared/services/gateway/gateway-restart-wake.service.js\";\nimport { createCronJobHandler } from \"@nextclaw-service/shared/services/gateway/utils/cron-job-handler.utils.js\";\nimport { companionRuntimeService } from \"@nextclaw-service/shared/services/ui/companion-runtime.service.js\";\nimport { handleGatewayDeferredStartupError } from \"@nextclaw-service/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js\";\nimport { NextclawApp, type UiStartupHandle } from \"@nextclaw-service/shared/services/gateway/nextclaw-app.service.js\";\nimport { NextclawDistributionService } from \"@nextclaw-service/shared/services/runtime/nextclaw-distribution.service.js\";\nimport { ServiceBootstrapStatusStore } from \"@nextclaw-service/shared/services/gateway/service-bootstrap-status.service.js\";\nimport { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from \"@nextclaw-service/shared/services/gateway/service-startup-support.service.js\";\nimport { installPluginRuntimeBridge } from \"@nextclaw-service/shared/services/plugin/utils/plugin-runtime-bridge.utils.js\";\nimport { wrapStartChannelsWithDevPluginHotReload } from \"@nextclaw-service/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js\";\nimport { ServiceMarketplaceInstaller } from \"@nextclaw-service/shared/services/marketplace/service-marketplace-installer.service.js\";\nimport { NpmRuntimeUpdateHost } from \"@nextclaw-service/shared/services/ui/npm-runtime-update-host.service.js\";\nimport { createRuntimeControlHost } from \"@nextclaw-service/shared/services/ui/runtime-control-host.service.js\";\nimport { localUiRuntimeStore } from \"@nextclaw-service/shared/stores/local-ui-runtime.store.js\";\nimport { managedServiceStateStore } from \"@nextclaw-service/shared/stores/managed-service-state.store.js\";\nimport type { RequestRestartParams } from \"@nextclaw-service/shared/types/cli.types.js\";\nimport { openBrowser, resolveUiConfig, resolveUiStaticDir } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nimport { logStartupTrace, measureStartupAsync, measureStartupSync } from \"@nextclaw-service/shared/utils/startup-trace.js\";\n\nconst {\n getConfigPath,\n getDataDir,\n getWorkspacePath,\n} = NextclawCore;\n\nconst DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS = 5_000;\n\nfunction resolveApplyRestartMode(uiPort: number): \"managed-service-restart\" | \"manual-process-restart\" {\n const serviceState = managedServiceStateStore.read();\n if (serviceState?.pid === process.pid) {\n return \"managed-service-restart\";\n }\n if (\n process.env.NEXTCLAW_RUNTIME_BUNDLE_CHILD === \"1\" &&\n typeof serviceState?.uiPort === \"number\" &&\n serviceState.uiPort === uiPort\n ) {\n return \"managed-service-restart\";\n }\n return \"manual-process-restart\";\n}\n\ntype Config = NextclawCore.Config;\ntype MessageBus = NextclawCore.MessageBus;\ntype SessionManager = NextclawCore.SessionManager;\n\ntype GatewayRuntimeOptions = {\n uiOverrides?: Partial<Config[\"ui\"]>;\n uiStaticDir?: string | null;\n};\n\nexport type GatewayRuntimeDeps = {\n requestRestart: (params: RequestRestartParams) => Promise<void>;\n initializeAgentHomeDirectory: (homeDirectory: string) => void;\n startService: (options: { uiOverrides: Record<string, unknown>; open: boolean }) => Promise<void>;\n stopService: () => Promise<void>;\n runCliSubcommand: (args: string[]) => Promise<string>;\n installBuiltinMarketplaceSkill: (slug: string, force: boolean | undefined) => { message: string; output?: string } | null;\n};\n\nexport class NextclawGatewayRuntime {\n readonly kernel: NextclawKernel;\n readonly appEventBus: EventBus;\n readonly messageBus: MessageBus;\n readonly sessionManager: SessionManager;\n readonly automation: AutomationManager;\n readonly runtimeControl: UiRuntimeControlHost;\n readonly runtimeUpdate: UiRuntimeUpdateHost | null;\n readonly ingress: Ingress;\n readonly distribution = NextclawDistributionService.get();\n readonly productVersion: string;\n readonly providerManager: LlmProviderManager;\n readonly gatewayController: GatewayControllerImpl;\n\n readonly configManager: ConfigManager;\n readonly uiConfig: Config[\"ui\"];\n readonly uiStaticDir: string | null;\n readonly workspace: string;\n readonly remoteManager: GatewayRemoteManager;\n readonly marketplace: MarketplaceApiConfig;\n readonly plugins: GatewayPluginManager;\n readonly restartWake: GatewayRestartWakeService;\n bootstrapStatus: ServiceBootstrapStatusStore;\n uiStartup: UiStartupHandle;\n readonly fileWatchers = new ServiceFileWatcherRegistry();\n private deferredChannelStarter: () => Promise<void>;\n\n constructor(\n private readonly deps: GatewayRuntimeDeps,\n private readonly options: GatewayRuntimeOptions,\n ) {\n const configPath = getConfigPath();\n this.kernel = measureStartupSync(\n \"service.gateway.kernel\",\n () => new NextclawKernel({\n homeDir: getDataDir(),\n configPath,\n }),\n );\n this.configManager = this.kernel.configManager;\n const config = this.configManager.config;\n this.uiConfig = resolveUiConfig(config, options.uiOverrides);\n this.uiStaticDir = options.uiStaticDir === undefined ? resolveUiStaticDir(this.distribution.uiDistDir) : options.uiStaticDir;\n this.workspace = getWorkspacePath(config.agents.defaults.workspace);\n this.appEventBus = this.kernel.eventBus;\n this.ingress = this.kernel.ingress;\n this.messageBus = this.kernel.messageBus;\n this.sessionManager = this.kernel.sessions;\n this.automation = this.kernel.automation;\n this.productVersion = this.distribution.version;\n this.plugins = new GatewayPluginManager(this);\n this.providerManager = this.kernel.llmProviders;\n this.installConfigHostHooks();\n this.restartWake = new GatewayRestartWakeService(this);\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.remoteManager = new GatewayRemoteManager({\n deps: this.deps,\n configManager: this.configManager,\n uiConfig: this.uiConfig,\n onRemoteStateChange: (state) => this.bootstrapStatus.syncRemoteRuntimeState(state),\n });\n this.marketplace = this.createMarketplace();\n this.runtimeControl = createRuntimeControlHost({\n serviceCommands: this.deps,\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.runtimeUpdate =\n process.env.NEXTCLAW_DISABLE_RUNTIME_UPDATE_HOST === \"1\"\n ? null\n : new NpmRuntimeUpdateHost({\n eventBus: this.appEventBus,\n applyRestartMode: resolveApplyRestartMode(this.uiConfig.port),\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.gatewayController = this.createGatewayController();\n this.kernel.provideGatewayController(this.gatewayController);\n this.deferredChannelStarter = this.startChannels;\n this.automation.onJob = createCronJobHandler({\n agentRunRequests: this.kernel.agentRunRequestManager,\n bus: this.messageBus,\n });\n }\n\n start = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.begin\");\n await this.reset();\n this.configureIngressHandlers();\n this.uiStartup = await this.startUiRuntime();\n await companionRuntimeService.applyConfig(this.configManager.config);\n await this.markUiRuntimeReady();\n await this.startSupportServices();\n this.installChannelDevHotReload();\n await this.runRuntimeLoop();\n await companionRuntimeService.ensureStopped();\n logStartupTrace(\"service.start_gateway.end\");\n };\n\n private reset = async (): Promise<void> => {\n await this.fileWatchers.clear();\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.deferredChannelStarter = this.startChannels;\n };\n\n private createBootstrapStatus = (): ServiceBootstrapStatusStore => {\n const bootstrapStatus = new ServiceBootstrapStatusStore();\n bootstrapStatus.markChannelsPending();\n bootstrapStatus.setRemoteState(this.configManager.config.remote.enabled ? \"pending\" : \"disabled\");\n return bootstrapStatus;\n };\n\n private createDisabledUiStartup = (): UiStartupHandle => ({\n endpoint: \"\",\n });\n\n private startUiRuntime = async (): Promise<UiStartupHandle> => {\n const uiStartup = await measureStartupAsync(\"service.start_ui_runtime\", async () => {\n logStartupTrace(\"service.start_ui_runtime.begin\");\n if (!this.uiConfig.enabled) {\n return this.createDisabledUiStartup();\n }\n const uiServer = await startUiServer(this.createUiRouterOptions());\n const uiUrl = NextclawCore.resolveLocalUiBaseUrl({\n host: uiServer.host,\n port: uiServer.port,\n });\n console.log(`✓ UI API: ${uiUrl}/api`);\n if (this.uiStaticDir) {\n console.log(`✓ UI frontend: ${uiUrl}`);\n }\n if (this.uiConfig.open) {\n openBrowser(uiUrl);\n }\n logStartupTrace(\"service.start_ui_runtime.ready\", {\n host: uiServer.host,\n port: uiServer.port,\n });\n return {\n endpoint: uiUrl,\n };\n });\n markLocalUiRuntimeIfStarted({\n uiStartup: this.uiConfig.enabled ? uiStartup : null,\n uiConfig: this.uiConfig,\n });\n return uiStartup;\n };\n\n private createUiRouterOptions = (): UiRouterOptions => ({\n kernel: this.kernel,\n configPath: this.configManager.configPath,\n appEventBus: this.appEventBus,\n uiConfig: this.uiConfig,\n uiStaticDir: this.uiStaticDir,\n productVersion: this.productVersion,\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,\n marketplace: this.marketplace,\n cron: this.automation,\n remoteAccess: this.remoteManager.remoteAccess,\n runtimeControl: this.runtimeControl,\n ...(this.runtimeUpdate ? { runtimeUpdate: this.runtimeUpdate } : {}),\n bootstrapStatus: this.bootstrapStatus,\n plugins: this.plugins,\n });\n\n private runRuntimeLoop = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.runtime_loop_begin\");\n let startupTask: Promise<void> | null = null;\n try {\n const runtimeLoopTask = runGatewayInboundLoop(this);\n startupTask = this.startDeferredRuntime();\n void startupTask.catch((error) => handleGatewayDeferredStartupError({\n bootstrapStatus: this.bootstrapStatus,\n error,\n }));\n await runtimeLoopTask;\n } finally {\n if (startupTask) {\n await startupTask.catch(() => undefined);\n }\n await this.cleanup();\n }\n };\n\n private startDeferredRuntime = async (): Promise<void> => {\n const app = new NextclawApp(this);\n await app.start();\n };\n\n readonly startDeferredChannels = async (): Promise<void> => {\n await this.deferredChannelStarter();\n };\n\n private installChannelDevHotReload = (): void => {\n this.deferredChannelStarter = wrapStartChannelsWithDevPluginHotReload({\n startChannels: this.startChannels,\n watcherRegistry: this.fileWatchers,\n isRuntimeActive: () => true,\n reloadPlugins: async (pluginIds: string[]) => {\n await this.plugins.reloadForDevHotReload(\n pluginIds.map((pluginId) => `plugins.entries.${pluginId}.source`),\n );\n },\n startupSettleMs: DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS,\n });\n };\n\n private readonly startChannels = async (): Promise<void> => {\n await this.kernel.channels.start();\n const enabledChannels = this.kernel.channels.enabledChannels;\n if (enabledChannels.length > 0) {\n console.log(`✓ Channels enabled: ${enabledChannels.join(\", \")}`);\n } else {\n console.log(\"Warning: No channels enabled\");\n }\n this.bootstrapStatus.markChannelsReady(enabledChannels);\n };\n\n private createMarketplace = (): MarketplaceApiConfig => ({\n apiBaseUrl: process.env.NEXTCLAW_MARKETPLACE_API_BASE,\n installer: new ServiceMarketplaceInstaller({\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n runCliSubcommand: this.deps.runCliSubcommand,\n installBuiltinSkill: this.deps.installBuiltinMarketplaceSkill,\n }).createInstaller(),\n });\n\n private cleanup = async (): Promise<void> => {\n localUiRuntimeStore.clearIfOwnedByProcess();\n await this.fileWatchers.clear();\n await this.kernel.extensions.stop();\n await this.remoteManager.stop();\n await this.plugins.stopGateways();\n setPluginRuntimeBridge(null);\n };\n\n private markUiRuntimeReady = async (): Promise<void> => {\n this.bootstrapStatus.markShellReady();\n await waitForNextTick();\n };\n\n private createGatewayController = (): GatewayControllerImpl => {\n return measureStartupSync(\n \"service.gateway.gateway_controller\",\n () => new GatewayControllerImpl({\n configManager: this.configManager,\n channels: this.kernel.channels,\n cron: this.automation,\n sessionManager: this.sessionManager,\n requestRestart: async (options) => {\n await this.deps.requestRestart({\n reason: options?.reason ?? \"gateway tool restart\",\n manualMessage: \"Restart the gateway to apply changes.\",\n strategy: \"background-service-or-exit\",\n delayMs: options?.delayMs,\n silentOnServiceRestart: true,\n });\n },\n })\n );\n };\n\n private startSupportServices = async (): Promise<void> => {\n this.plugins.publishConfigChanges();\n this.configurePluginRuntime();\n await measureStartupAsync(\"service.start_gateway_support_services\", async () =>\n await startGatewayRuntimeSupport({\n automation: this.automation,\n remoteModule: this.remoteManager.remoteModule,\n watchConfigFile: () => watchServiceConfigFile({\n configPath: resolve(getConfigPath()),\n watcherRegistry: this.fileWatchers,\n scheduleReload: (reason) => this.configManager.scheduleReload(reason)\n }),\n watcherRegistry: this.fileWatchers\n })\n );\n };\n\n private configurePluginRuntime = (): void => {\n installPluginRuntimeBridge(this);\n };\n\n private installConfigHostHooks = (): void => {\n this.configManager.installRuntimeHooks({\n reloadCompanion: async ({ config: nextConfig }) => {\n await companionRuntimeService.applyConfig(nextConfig);\n },\n reloadPlugins: async ({ config: nextConfig, changedPaths }) => {\n const result = await this.plugins.reloadForConfigChange({\n config: nextConfig,\n changedPaths,\n });\n if (result.restartChannels) {\n console.log(\"Config reload: plugin channel gateways restarted.\");\n }\n return { restartChannels: result.restartChannels };\n },\n onRestartRequired: (paths) => {\n void this.deps.requestRestart({\n changedPaths: paths,\n manualMessage: `已保存以下改动,等待你手动重启后生效:${paths.join(\", \")}`,\n mode: \"notify\",\n reason: `config reload requires restart: ${paths.join(\", \")}`,\n strategy: \"background-service-or-manual\",\n });\n },\n });\n };\n\n private configureIngressHandlers = (): void => {\n this.kernel.extensions.registerIngressHandlers();\n };\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,EACJ,eAAA,iBACA,YAAA,cACA,kBAAA,uBACE;AAEJ,MAAM,0CAA0C;AAEhD,SAAS,wBAAwB,QAAsE;CACrG,MAAM,eAAe,yBAAyB,MAAM;AACpD,KAAI,cAAc,QAAQ,QAAQ,IAChC,QAAO;AAET,KACE,QAAQ,IAAI,kCAAkC,OAC9C,OAAO,cAAc,WAAW,YAChC,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;KACV,SAAS,SAAS;KAClB,wBAAwB;KACzB,CAAC;;GAEL,CAAC,CACH;;CAGH,uBAA+B,YAA2B;AACxD,OAAK,QAAQ,sBAAsB;AACnC,OAAK,wBAAwB;AAC7B,QAAM,oBAAoB,0CAA0C,YAClE,MAAM,2BAA2B;GAC/B,YAAY,KAAK;GACjB,cAAc,KAAK,cAAc;GACjC,uBAAuB,uBAAuB;IAC5C,YAAY,QAAQH,iBAAe,CAAC;IACpC,iBAAiB,KAAK;IACtB,iBAAiB,WAAW,KAAK,cAAc,eAAe,OAAO;IACtE,CAAC;GACF,iBAAiB,KAAK;GACvB,CAAC,CACH;;CAGH,+BAA6C;AAC3C,6BAA2B,KAAK;;CAGlC,+BAA6C;AAC3C,OAAK,cAAc,oBAAoB;GACrC,iBAAiB,OAAO,EAAE,QAAQ,iBAAiB;AACjD,UAAM,wBAAwB,YAAY,WAAW;;GAEvD,eAAe,OAAO,EAAE,QAAQ,YAAY,mBAAmB;IAC7D,MAAM,SAAS,MAAM,KAAK,QAAQ,sBAAsB;KACtD,QAAQ;KACR;KACD,CAAC;AACF,QAAI,OAAO,gBACT,SAAQ,IAAI,oDAAoD;AAElE,WAAO,EAAE,iBAAiB,OAAO,iBAAiB;;GAEpD,oBAAoB,UAAU;AACvB,SAAK,KAAK,eAAe;KAC5B,cAAc;KACd,eAAe,sBAAsB,MAAM,KAAK,KAAK;KACrD,MAAM;KACN,QAAQ,mCAAmC,MAAM,KAAK,KAAK;KAC3D,UAAU;KACX,CAAC;;GAEL,CAAC;;CAGJ,iCAA+C;AAC7C,OAAK,OAAO,WAAW,yBAAyB"}
1
+ {"version":3,"file":"nextclaw-gateway-runtime.service.js","names":["getConfigPath","getDataDir","getWorkspacePath","waitForNextTick"],"sources":["../../../../src/shared/services/gateway/nextclaw-gateway-runtime.service.ts"],"sourcesContent":["import * as NextclawCore from \"@nextclaw/core\";\nimport {\n AgentRunClient,\n NextclawKernel,\n runGatewayInboundLoop,\n type AutomationManager,\n type ConfigManager,\n type LlmProviderManager,\n} from \"@nextclaw/kernel\";\nimport type { EventBus, Ingress } from \"@nextclaw/shared\";\nimport {\n startUiServer,\n type MarketplaceApiConfig,\n type UiRouterOptions,\n type UiRuntimeControlHost,\n type UiRuntimeUpdateHost,\n} from \"@nextclaw/server\";\nimport { resolve } from \"node:path\";\nimport { setImmediate as waitForNextTick } from \"node:timers/promises\";\nimport { GatewayControllerImpl } from \"@nextclaw-service/shared/controllers/gateway.controller.js\";\nimport { GatewayExtensionManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-extension.manager.js\";\nimport { GatewayRemoteManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-remote.manager.js\";\nimport { GatewayRestartWakeService } from \"@nextclaw-service/shared/services/gateway/gateway-restart-wake.service.js\";\nimport { createCronJobHandler } from \"@nextclaw-service/shared/services/gateway/utils/cron-job-handler.utils.js\";\nimport { companionRuntimeService } from \"@nextclaw-service/shared/services/ui/companion-runtime.service.js\";\nimport { handleGatewayDeferredStartupError } from \"@nextclaw-service/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js\";\nimport { NextclawApp, type UiStartupHandle } from \"@nextclaw-service/shared/services/gateway/nextclaw-app.service.js\";\nimport { NextclawDistributionService } from \"@nextclaw-service/shared/services/runtime/nextclaw-distribution.service.js\";\nimport { ServiceBootstrapStatusStore } from \"@nextclaw-service/shared/services/gateway/service-bootstrap-status.service.js\";\nimport { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from \"@nextclaw-service/shared/services/gateway/service-startup-support.service.js\";\nimport { ServiceMarketplaceInstaller } from \"@nextclaw-service/shared/services/marketplace/service-marketplace-installer.service.js\";\nimport { NpmRuntimeUpdateHost } from \"@nextclaw-service/shared/services/ui/npm-runtime-update-host.service.js\";\nimport { createRuntimeControlHost } from \"@nextclaw-service/shared/services/ui/runtime-control-host.service.js\";\nimport { localUiRuntimeStore } from \"@nextclaw-service/shared/stores/local-ui-runtime.store.js\";\nimport { managedServiceStateStore } from \"@nextclaw-service/shared/stores/managed-service-state.store.js\";\nimport type { RequestRestartParams } from \"@nextclaw-service/shared/types/cli.types.js\";\nimport { openBrowser, resolveUiConfig, resolveUiStaticDir } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nimport { logStartupTrace, measureStartupAsync, measureStartupSync } from \"@nextclaw-service/shared/utils/startup-trace.js\";\n\nconst {\n getConfigPath,\n getDataDir,\n getWorkspacePath,\n} = NextclawCore;\n\nfunction resolveApplyRestartMode(uiPort: number): \"managed-service-restart\" | \"manual-process-restart\" {\n const serviceState = managedServiceStateStore.read();\n if (serviceState?.pid === process.pid) {\n return \"managed-service-restart\";\n }\n if (\n process.env.NEXTCLAW_RUNTIME_BUNDLE_CHILD === \"1\" &&\n typeof serviceState?.uiPort === \"number\" &&\n serviceState.uiPort === uiPort\n ) {\n return \"managed-service-restart\";\n }\n return \"manual-process-restart\";\n}\n\ntype Config = NextclawCore.Config;\ntype MessageBus = NextclawCore.MessageBus;\ntype SessionManager = NextclawCore.SessionManager;\n\ntype GatewayRuntimeOptions = {\n uiOverrides?: Partial<Config[\"ui\"]>;\n uiStaticDir?: string | null;\n};\n\nexport type GatewayRuntimeDeps = {\n requestRestart: (params: RequestRestartParams) => Promise<void>;\n initializeAgentHomeDirectory: (homeDirectory: string) => void;\n startService: (options: { uiOverrides: Record<string, unknown>; open: boolean }) => Promise<void>;\n stopService: () => Promise<void>;\n runCliSubcommand: (args: string[]) => Promise<string>;\n installBuiltinMarketplaceSkill: (slug: string, force: boolean | undefined) => { message: string; output?: string } | null;\n};\n\nexport class NextclawGatewayRuntime {\n readonly kernel: NextclawKernel;\n readonly appEventBus: EventBus;\n readonly messageBus: MessageBus;\n readonly sessionManager: SessionManager;\n readonly automation: AutomationManager;\n readonly agentRunClient: AgentRunClient;\n readonly runtimeControl: UiRuntimeControlHost;\n readonly runtimeUpdate: UiRuntimeUpdateHost | null;\n readonly ingress: Ingress;\n readonly distribution = NextclawDistributionService.get();\n readonly productVersion: string;\n readonly providerManager: LlmProviderManager;\n readonly gatewayController: GatewayControllerImpl;\n\n readonly configManager: ConfigManager;\n readonly uiConfig: Config[\"ui\"];\n readonly uiStaticDir: string | null;\n readonly workspace: string;\n readonly remoteManager: GatewayRemoteManager;\n readonly marketplace: MarketplaceApiConfig;\n readonly extensions: GatewayExtensionManager;\n readonly restartWake: GatewayRestartWakeService;\n bootstrapStatus: ServiceBootstrapStatusStore;\n uiStartup: UiStartupHandle;\n readonly fileWatchers = new ServiceFileWatcherRegistry();\n private deferredChannelStarter: () => Promise<void>;\n\n constructor(\n private readonly deps: GatewayRuntimeDeps,\n private readonly options: GatewayRuntimeOptions,\n ) {\n const configPath = getConfigPath();\n this.kernel = measureStartupSync(\n \"service.gateway.kernel\",\n () => new NextclawKernel({\n homeDir: getDataDir(),\n configPath,\n }),\n );\n this.configManager = this.kernel.configManager;\n const config = this.configManager.config;\n this.uiConfig = resolveUiConfig(config, options.uiOverrides);\n this.uiStaticDir = options.uiStaticDir === undefined ? resolveUiStaticDir(this.distribution.uiDistDir) : options.uiStaticDir;\n this.workspace = getWorkspacePath(config.agents.defaults.workspace);\n this.appEventBus = this.kernel.eventBus;\n this.ingress = this.kernel.ingress;\n this.agentRunClient = new AgentRunClient({\n eventBus: this.kernel.eventBus,\n ingress: this.kernel.ingress,\n });\n this.messageBus = this.kernel.messageBus;\n this.sessionManager = this.kernel.sessions;\n this.automation = this.kernel.automation;\n this.productVersion = this.distribution.version;\n this.extensions = new GatewayExtensionManager(this);\n this.providerManager = this.kernel.llmProviders;\n this.installConfigHostHooks();\n this.restartWake = new GatewayRestartWakeService(this);\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.remoteManager = new GatewayRemoteManager({\n deps: this.deps,\n configManager: this.configManager,\n uiConfig: this.uiConfig,\n onRemoteStateChange: (state) => this.bootstrapStatus.syncRemoteRuntimeState(state),\n });\n this.marketplace = this.createMarketplace();\n this.runtimeControl = createRuntimeControlHost({\n serviceCommands: this.deps,\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.runtimeUpdate =\n process.env.NEXTCLAW_DISABLE_RUNTIME_UPDATE_HOST === \"1\"\n ? null\n : new NpmRuntimeUpdateHost({\n eventBus: this.appEventBus,\n applyRestartMode: resolveApplyRestartMode(this.uiConfig.port),\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.gatewayController = this.createGatewayController();\n this.kernel.provideGatewayController(this.gatewayController);\n this.deferredChannelStarter = this.startChannels;\n this.automation.onJob = createCronJobHandler({\n agentRunClient: this.agentRunClient,\n bus: this.messageBus,\n });\n }\n\n start = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.begin\");\n await this.reset();\n this.configureIngressHandlers();\n this.uiStartup = await this.startUiRuntime();\n await companionRuntimeService.applyConfig(this.configManager.config);\n await this.markUiRuntimeReady();\n await this.startSupportServices();\n await this.runRuntimeLoop();\n await companionRuntimeService.ensureStopped();\n logStartupTrace(\"service.start_gateway.end\");\n };\n\n private reset = async (): Promise<void> => {\n await this.fileWatchers.clear();\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.deferredChannelStarter = this.startChannels;\n };\n\n private createBootstrapStatus = (): ServiceBootstrapStatusStore => {\n const bootstrapStatus = new ServiceBootstrapStatusStore();\n bootstrapStatus.markChannelsPending();\n bootstrapStatus.setRemoteState(this.configManager.config.remote.enabled ? \"pending\" : \"disabled\");\n return bootstrapStatus;\n };\n\n private createDisabledUiStartup = (): UiStartupHandle => ({\n endpoint: \"\",\n });\n\n private startUiRuntime = async (): Promise<UiStartupHandle> => {\n const uiStartup = await measureStartupAsync(\"service.start_ui_runtime\", async () => {\n logStartupTrace(\"service.start_ui_runtime.begin\");\n if (!this.uiConfig.enabled) {\n return this.createDisabledUiStartup();\n }\n const uiServer = await startUiServer(this.createUiRouterOptions());\n const uiUrl = NextclawCore.resolveLocalUiBaseUrl({\n host: uiServer.host,\n port: uiServer.port,\n });\n console.log(`✓ UI API: ${uiUrl}/api`);\n if (this.uiStaticDir) {\n console.log(`✓ UI frontend: ${uiUrl}`);\n }\n if (this.uiConfig.open) {\n openBrowser(uiUrl);\n }\n logStartupTrace(\"service.start_ui_runtime.ready\", {\n host: uiServer.host,\n port: uiServer.port,\n });\n return {\n endpoint: uiUrl,\n };\n });\n markLocalUiRuntimeIfStarted({\n uiStartup: this.uiConfig.enabled ? uiStartup : null,\n uiConfig: this.uiConfig,\n });\n return uiStartup;\n };\n\n private createUiRouterOptions = (): UiRouterOptions => ({\n kernel: this.kernel,\n configPath: this.configManager.configPath,\n appEventBus: this.appEventBus,\n uiConfig: this.uiConfig,\n uiStaticDir: this.uiStaticDir,\n productVersion: this.productVersion,\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,\n marketplace: this.marketplace,\n cron: this.automation,\n remoteAccess: this.remoteManager.remoteAccess,\n runtimeControl: this.runtimeControl,\n ...(this.runtimeUpdate ? { runtimeUpdate: this.runtimeUpdate } : {}),\n bootstrapStatus: this.bootstrapStatus,\n extensions: this.extensions,\n });\n\n private runRuntimeLoop = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.runtime_loop_begin\");\n let startupTask: Promise<void> | null = null;\n try {\n const runtimeLoopTask = runGatewayInboundLoop(this);\n startupTask = this.startDeferredRuntime();\n void startupTask.catch((error) => handleGatewayDeferredStartupError({\n bootstrapStatus: this.bootstrapStatus,\n error,\n }));\n await runtimeLoopTask;\n } finally {\n if (startupTask) {\n await startupTask.catch(() => undefined);\n }\n await this.cleanup();\n }\n };\n\n private startDeferredRuntime = async (): Promise<void> => {\n const app = new NextclawApp(this);\n await app.start();\n };\n\n readonly startDeferredChannels = async (): Promise<void> => {\n await this.deferredChannelStarter();\n };\n\n private readonly startChannels = async (): Promise<void> => {\n await this.kernel.channels.start();\n const enabledChannels = this.kernel.channels.enabledChannels;\n if (enabledChannels.length > 0) {\n console.log(`✓ Channels enabled: ${enabledChannels.join(\", \")}`);\n } else {\n console.log(\"Warning: No channels enabled\");\n }\n this.bootstrapStatus.markChannelsReady(enabledChannels);\n };\n\n private createMarketplace = (): MarketplaceApiConfig => ({\n apiBaseUrl: process.env.NEXTCLAW_MARKETPLACE_API_BASE,\n installer: new ServiceMarketplaceInstaller({\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n runCliSubcommand: this.deps.runCliSubcommand,\n installBuiltinSkill: this.deps.installBuiltinMarketplaceSkill,\n }).createInstaller(),\n });\n\n private cleanup = async (): Promise<void> => {\n localUiRuntimeStore.clearIfOwnedByProcess();\n await this.fileWatchers.clear();\n await this.kernel.extensions.stop();\n await this.remoteManager.stop();\n };\n\n private markUiRuntimeReady = async (): Promise<void> => {\n this.bootstrapStatus.markShellReady();\n await waitForNextTick();\n };\n\n private createGatewayController = (): GatewayControllerImpl => {\n return measureStartupSync(\n \"service.gateway.gateway_controller\",\n () => new GatewayControllerImpl({\n configManager: this.configManager,\n channels: this.kernel.channels,\n cron: this.automation,\n sessionManager: this.sessionManager,\n requestRestart: async (options) => {\n await this.deps.requestRestart({\n reason: options?.reason ?? \"gateway tool restart\",\n manualMessage: \"Restart the gateway to apply changes.\",\n strategy: \"background-service-or-exit\",\n delayMs: options?.delayMs,\n silentOnServiceRestart: true,\n });\n },\n })\n );\n };\n\n private startSupportServices = async (): Promise<void> => {\n this.extensions.publishConfigChanges();\n await measureStartupAsync(\"service.start_gateway_support_services\", async () =>\n await startGatewayRuntimeSupport({\n automation: this.automation,\n remoteModule: this.remoteManager.remoteModule,\n watchConfigFile: () => watchServiceConfigFile({\n configPath: resolve(getConfigPath()),\n watcherRegistry: this.fileWatchers,\n scheduleReload: (reason) => this.configManager.scheduleReload(reason)\n }),\n watcherRegistry: this.fileWatchers\n })\n );\n };\n\n private installConfigHostHooks = (): void => {\n this.configManager.installRuntimeHooks({\n reloadCompanion: async ({ config: nextConfig }) => {\n await companionRuntimeService.applyConfig(nextConfig);\n },\n onRestartRequired: (paths) => {\n void this.deps.requestRestart({\n changedPaths: paths,\n manualMessage: `已保存以下改动,等待你手动重启后生效:${paths.join(\", \")}`,\n mode: \"notify\",\n reason: `config reload requires restart: ${paths.join(\", \")}`,\n strategy: \"background-service-or-manual\",\n });\n },\n });\n };\n\n private configureIngressHandlers = (): void => {\n this.kernel.extensions.registerIngressHandlers();\n };\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,EACJ,eAAA,iBACA,YAAA,cACA,kBAAA,uBACE;AAEJ,SAAS,wBAAwB,QAAsE;CACrG,MAAM,eAAe,yBAAyB,MAAM;AACpD,KAAI,cAAc,QAAQ,QAAQ,IAChC,QAAO;AAET,KACE,QAAQ,IAAI,kCAAkC,OAC9C,OAAO,cAAc,WAAW,YAChC,aAAa,WAAW,OAExB,QAAO;AAET,QAAO;;AAqBT,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,eAAwB,4BAA4B,KAAK;CACzD;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,eAAwB,IAAI,4BAA4B;CACxD;CAEA,YACE,MACA,SACA;AAFiB,OAAA,OAAA;AACA,OAAA,UAAA;EAEjB,MAAM,aAAaA,iBAAe;AAClC,OAAK,SAAS,mBACZ,gCACM,IAAI,eAAe;GACvB,SAASC,cAAY;GACrB;GACD,CAAC,CACH;AACD,OAAK,gBAAgB,KAAK,OAAO;EACjC,MAAM,SAAS,KAAK,cAAc;AAClC,OAAK,WAAW,gBAAgB,QAAQ,QAAQ,YAAY;AAC5D,OAAK,cAAc,QAAQ,gBAAgB,KAAA,IAAY,mBAAmB,KAAK,aAAa,UAAU,GAAG,QAAQ;AACjH,OAAK,YAAYC,mBAAiB,OAAO,OAAO,SAAS,UAAU;AACnE,OAAK,cAAc,KAAK,OAAO;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QAAM,KAAK,cAAc,MAAM;;CAGjC,qBAA6B,YAA2B;AACtD,OAAK,gBAAgB,gBAAgB;AACrC,QAAMC,cAAiB;;CAGzB,gCAA+D;AAC7D,SAAO,mBACL,4CACM,IAAI,sBAAsB;GAC9B,eAAe,KAAK;GACpB,UAAU,KAAK,OAAO;GACtB,MAAM,KAAK;GACX,gBAAgB,KAAK;GACrB,gBAAgB,OAAO,YAAY;AACjC,UAAM,KAAK,KAAK,eAAe;KAC7B,QAAQ,SAAS,UAAU;KAC3B,eAAe;KACf,UAAU;KACV,SAAS,SAAS;KAClB,wBAAwB;KACzB,CAAC;;GAEL,CAAC,CACH;;CAGH,uBAA+B,YAA2B;AACxD,OAAK,WAAW,sBAAsB;AACtC,QAAM,oBAAoB,0CAA0C,YAClE,MAAM,2BAA2B;GAC/B,YAAY,KAAK;GACjB,cAAc,KAAK,cAAc;GACjC,uBAAuB,uBAAuB;IAC5C,YAAY,QAAQH,iBAAe,CAAC;IACpC,iBAAiB,KAAK;IACtB,iBAAiB,WAAW,KAAK,cAAc,eAAe,OAAO;IACtE,CAAC;GACF,iBAAiB,KAAK;GACvB,CAAC,CACH;;CAGH,+BAA6C;AAC3C,OAAK,cAAc,oBAAoB;GACrC,iBAAiB,OAAO,EAAE,QAAQ,iBAAiB;AACjD,UAAM,wBAAwB,YAAY,WAAW;;GAEvD,oBAAoB,UAAU;AACvB,SAAK,KAAK,eAAe;KAC5B,cAAc;KACd,eAAe,sBAAsB,MAAM,KAAK,KAAK;KACrD,MAAM;KACN,QAAQ,mCAAmC,MAAM,KAAK,KAAK;KAC3D,UAAU;KACX,CAAC;;GAEL,CAAC;;CAGJ,iCAA+C;AAC7C,OAAK,OAAO,WAAW,yBAAyB"}
@@ -9,18 +9,18 @@ declare class ServiceBootstrapStatusStore {
9
9
  markNcpAgentRunning(): void;
10
10
  markNcpAgentReady(): void;
11
11
  markNcpAgentError(error: string): void;
12
- markPluginHydrationRunning(params: {
13
- totalPluginCount: number;
12
+ markExtensionLoadingRunning(params: {
13
+ totalExtensionCount: number;
14
14
  }): void;
15
- markPluginHydrationProgress(params: {
16
- loadedPluginCount: number;
17
- totalPluginCount?: number;
15
+ markExtensionLoadingProgress(params: {
16
+ loadedExtensionCount: number;
17
+ totalExtensionCount?: number;
18
18
  }): void;
19
- markPluginHydrationReady(params: {
20
- loadedPluginCount: number;
21
- totalPluginCount: number;
19
+ markExtensionLoadingReady(params: {
20
+ loadedExtensionCount: number;
21
+ totalExtensionCount: number;
22
22
  }): void;
23
- markPluginHydrationError(error: string): void;
23
+ markExtensionLoadingError(error: string): void;
24
24
  markChannelsPending(): void;
25
25
  markChannelsReady(enabled: string[]): void;
26
26
  markChannelsError(error: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"service-bootstrap-status.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"mappings":";;;;cAOa,2BAAA;EAAA,QACH,KAAA;EAmBR,SAAA,CAAA,GAAa,mBAAA;EAab,cAAA,CAAA;EAKA,mBAAA,CAAA;EASA,iBAAA,CAAA;EASA,iBAAA,CAAkB,KAAA;EASlB,0BAAA,CAA2B,MAAA;IACzB,gBAAA;EAAA;EAcF,2BAAA,CAA4B,MAAA;IAC1B,iBAAA;IACA,gBAAA;EAAA;EAUF,wBAAA,CAAyB,MAAA;IACvB,iBAAA;IACA,gBAAA;EAAA;EAYF,wBAAA,CAAyB,KAAA;EAWzB,mBAAA,CAAA;EAOA,iBAAA,CAAkB,OAAA;EAWlB,iBAAA,CAAkB,KAAA;EAUlB,cAAA,CAAe,KAAA,EAAO,oBAAA,EAAsB,OAAA;EAO5C,sBAAA,CAAuB,OAAA,EAAS,kBAAA;EAWhC,SAAA,CAAU,KAAA;AAAA"}
1
+ {"version":3,"file":"service-bootstrap-status.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"mappings":";;;;cAOa,2BAAA;EAAA,QACH,KAAA;EAmBR,SAAA,CAAA,GAAa,mBAAA;EAab,cAAA,CAAA;EAKA,mBAAA,CAAA;EASA,iBAAA,CAAA;EASA,iBAAA,CAAkB,KAAA;EASlB,2BAAA,CAA4B,MAAA;IAC1B,mBAAA;EAAA;EAcF,4BAAA,CAA6B,MAAA;IAC3B,oBAAA;IACA,mBAAA;EAAA;EAUF,yBAAA,CAA0B,MAAA;IACxB,oBAAA;IACA,mBAAA;EAAA;EAYF,yBAAA,CAA0B,KAAA;EAW1B,mBAAA,CAAA;EAOA,iBAAA,CAAkB,OAAA;EAWlB,iBAAA,CAAkB,KAAA;EAUlB,cAAA,CAAe,KAAA,EAAO,oBAAA,EAAsB,OAAA;EAO5C,sBAAA,CAAuB,OAAA,EAAS,kBAAA;EAWhC,SAAA,CAAU,KAAA;AAAA"}
@@ -6,10 +6,10 @@ var ServiceBootstrapStatusStore = class {
6
6
  state = {
7
7
  phase: "kernel-starting",
8
8
  ncpAgent: { state: "pending" },
9
- pluginHydration: {
9
+ extensionLoading: {
10
10
  state: "pending",
11
- loadedPluginCount: 0,
12
- totalPluginCount: 0
11
+ loadedExtensionCount: 0,
12
+ totalExtensionCount: 0
13
13
  },
14
14
  channels: {
15
15
  state: "pending",
@@ -21,7 +21,7 @@ var ServiceBootstrapStatusStore = class {
21
21
  return {
22
22
  ...this.state,
23
23
  ncpAgent: { ...this.state.ncpAgent },
24
- pluginHydration: { ...this.state.pluginHydration },
24
+ extensionLoading: { ...this.state.extensionLoading },
25
25
  channels: {
26
26
  ...this.state.channels,
27
27
  enabled: [...this.state.channels.enabled]
@@ -57,41 +57,41 @@ var ServiceBootstrapStatusStore = class {
57
57
  error
58
58
  };
59
59
  }
60
- markPluginHydrationRunning(params) {
60
+ markExtensionLoadingRunning(params) {
61
61
  this.state.phase = "hydrating-capabilities";
62
- this.state.pluginHydration = {
63
- ...this.state.pluginHydration,
62
+ this.state.extensionLoading = {
63
+ ...this.state.extensionLoading,
64
64
  state: "running",
65
- loadedPluginCount: 0,
66
- totalPluginCount: params.totalPluginCount,
67
- startedAt: this.state.pluginHydration.startedAt ?? now(),
65
+ loadedExtensionCount: 0,
66
+ totalExtensionCount: params.totalExtensionCount,
67
+ startedAt: this.state.extensionLoading.startedAt ?? now(),
68
68
  completedAt: void 0,
69
69
  error: void 0
70
70
  };
71
71
  }
72
- markPluginHydrationProgress(params) {
73
- this.state.pluginHydration = {
74
- ...this.state.pluginHydration,
72
+ markExtensionLoadingProgress(params) {
73
+ this.state.extensionLoading = {
74
+ ...this.state.extensionLoading,
75
75
  state: "running",
76
- loadedPluginCount: params.loadedPluginCount,
77
- totalPluginCount: params.totalPluginCount ?? this.state.pluginHydration.totalPluginCount
76
+ loadedExtensionCount: params.loadedExtensionCount,
77
+ totalExtensionCount: params.totalExtensionCount ?? this.state.extensionLoading.totalExtensionCount
78
78
  };
79
79
  }
80
- markPluginHydrationReady(params) {
81
- this.state.pluginHydration = {
82
- ...this.state.pluginHydration,
80
+ markExtensionLoadingReady(params) {
81
+ this.state.extensionLoading = {
82
+ ...this.state.extensionLoading,
83
83
  state: "ready",
84
- loadedPluginCount: params.loadedPluginCount,
85
- totalPluginCount: params.totalPluginCount,
84
+ loadedExtensionCount: params.loadedExtensionCount,
85
+ totalExtensionCount: params.totalExtensionCount,
86
86
  completedAt: now(),
87
87
  error: void 0
88
88
  };
89
89
  }
90
- markPluginHydrationError(error) {
90
+ markExtensionLoadingError(error) {
91
91
  this.state.phase = "error";
92
92
  this.state.lastError = error;
93
- this.state.pluginHydration = {
94
- ...this.state.pluginHydration,
93
+ this.state.extensionLoading = {
94
+ ...this.state.extensionLoading,
95
95
  state: "error",
96
96
  completedAt: now(),
97
97
  error
@@ -108,7 +108,7 @@ var ServiceBootstrapStatusStore = class {
108
108
  state: "ready",
109
109
  enabled: [...enabled]
110
110
  };
111
- if (this.state.pluginHydration.state === "ready") {
111
+ if (this.state.extensionLoading.state === "ready") {
112
112
  this.state.phase = "ready";
113
113
  this.state.lastError = void 0;
114
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service-bootstrap-status.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"sourcesContent":["import type { BootstrapRemoteState, BootstrapStatusView } from \"@nextclaw/server\";\nimport type { RemoteRuntimeState } from \"@nextclaw/remote\";\n\nfunction now(): string {\n return new Date().toISOString();\n}\n\nexport class ServiceBootstrapStatusStore {\n private state: BootstrapStatusView = {\n phase: \"kernel-starting\",\n ncpAgent: {\n state: \"pending\",\n },\n pluginHydration: {\n state: \"pending\",\n loadedPluginCount: 0,\n totalPluginCount: 0\n },\n channels: {\n state: \"pending\",\n enabled: []\n },\n remote: {\n state: \"pending\"\n }\n };\n\n getStatus(): BootstrapStatusView {\n return {\n ...this.state,\n ncpAgent: { ...this.state.ncpAgent },\n pluginHydration: { ...this.state.pluginHydration },\n channels: {\n ...this.state.channels,\n enabled: [...this.state.channels.enabled]\n },\n remote: { ...this.state.remote }\n };\n }\n\n markShellReady(): void {\n this.state.phase = \"shell-ready\";\n this.state.shellReadyAt = this.state.shellReadyAt ?? now();\n }\n\n markNcpAgentRunning(): void {\n this.state.ncpAgent = {\n state: \"running\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markNcpAgentReady(): void {\n this.state.ncpAgent = {\n state: \"ready\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error: undefined\n };\n }\n\n markNcpAgentError(error: string): void {\n this.state.ncpAgent = {\n state: \"error\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error\n };\n }\n\n markPluginHydrationRunning(params: {\n totalPluginCount: number;\n }): void {\n this.state.phase = \"hydrating-capabilities\";\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"running\",\n loadedPluginCount: 0,\n totalPluginCount: params.totalPluginCount,\n startedAt: this.state.pluginHydration.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markPluginHydrationProgress(params: {\n loadedPluginCount: number;\n totalPluginCount?: number;\n }): void {\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"running\",\n loadedPluginCount: params.loadedPluginCount,\n totalPluginCount: params.totalPluginCount ?? this.state.pluginHydration.totalPluginCount\n };\n }\n\n markPluginHydrationReady(params: {\n loadedPluginCount: number;\n totalPluginCount: number;\n }): void {\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"ready\",\n loadedPluginCount: params.loadedPluginCount,\n totalPluginCount: params.totalPluginCount,\n completedAt: now(),\n error: undefined\n };\n }\n\n markPluginHydrationError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"error\",\n completedAt: now(),\n error\n };\n }\n\n markChannelsPending(): void {\n this.state.channels = {\n state: \"pending\",\n enabled: []\n };\n }\n\n markChannelsReady(enabled: string[]): void {\n this.state.channels = {\n state: \"ready\",\n enabled: [...enabled]\n };\n if (this.state.pluginHydration.state === \"ready\") {\n this.state.phase = \"ready\";\n this.state.lastError = undefined;\n }\n }\n\n markChannelsError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.channels = {\n state: \"error\",\n enabled: [...this.state.channels.enabled],\n error\n };\n }\n\n setRemoteState(state: BootstrapRemoteState, message?: string): void {\n this.state.remote = {\n state,\n ...(message ? { message } : {})\n };\n }\n\n syncRemoteRuntimeState(runtime: RemoteRuntimeState): void {\n const message = runtime.lastError?.trim() || undefined;\n const state =\n runtime.state === \"connected\" ? \"ready\"\n : runtime.state === \"disabled\" ? \"disabled\"\n : runtime.state === \"error\" && message?.includes(\"already owned\") ? \"conflict\"\n : runtime.state === \"error\" ? \"error\"\n : \"pending\";\n this.setRemoteState(state, message);\n }\n\n markError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n }\n}\n"],"mappings":";AAGA,SAAS,MAAc;AACrB,yBAAO,IAAI,MAAM,EAAC,aAAa;;AAGjC,IAAa,8BAAb,MAAyC;CAC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,UAAU,OAAqB;AAC7B,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,YAAY"}
1
+ {"version":3,"file":"service-bootstrap-status.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"sourcesContent":["import type { BootstrapRemoteState, BootstrapStatusView } from \"@nextclaw/server\";\nimport type { RemoteRuntimeState } from \"@nextclaw/remote\";\n\nfunction now(): string {\n return new Date().toISOString();\n}\n\nexport class ServiceBootstrapStatusStore {\n private state: BootstrapStatusView = {\n phase: \"kernel-starting\",\n ncpAgent: {\n state: \"pending\",\n },\n extensionLoading: {\n state: \"pending\",\n loadedExtensionCount: 0,\n totalExtensionCount: 0\n },\n channels: {\n state: \"pending\",\n enabled: []\n },\n remote: {\n state: \"pending\"\n }\n };\n\n getStatus(): BootstrapStatusView {\n return {\n ...this.state,\n ncpAgent: { ...this.state.ncpAgent },\n extensionLoading: { ...this.state.extensionLoading },\n channels: {\n ...this.state.channels,\n enabled: [...this.state.channels.enabled]\n },\n remote: { ...this.state.remote }\n };\n }\n\n markShellReady(): void {\n this.state.phase = \"shell-ready\";\n this.state.shellReadyAt = this.state.shellReadyAt ?? now();\n }\n\n markNcpAgentRunning(): void {\n this.state.ncpAgent = {\n state: \"running\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markNcpAgentReady(): void {\n this.state.ncpAgent = {\n state: \"ready\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error: undefined\n };\n }\n\n markNcpAgentError(error: string): void {\n this.state.ncpAgent = {\n state: \"error\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error\n };\n }\n\n markExtensionLoadingRunning(params: {\n totalExtensionCount: number;\n }): void {\n this.state.phase = \"hydrating-capabilities\";\n this.state.extensionLoading = {\n ...this.state.extensionLoading,\n state: \"running\",\n loadedExtensionCount: 0,\n totalExtensionCount: params.totalExtensionCount,\n startedAt: this.state.extensionLoading.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markExtensionLoadingProgress(params: {\n loadedExtensionCount: number;\n totalExtensionCount?: number;\n }): void {\n this.state.extensionLoading = {\n ...this.state.extensionLoading,\n state: \"running\",\n loadedExtensionCount: params.loadedExtensionCount,\n totalExtensionCount: params.totalExtensionCount ?? this.state.extensionLoading.totalExtensionCount\n };\n }\n\n markExtensionLoadingReady(params: {\n loadedExtensionCount: number;\n totalExtensionCount: number;\n }): void {\n this.state.extensionLoading = {\n ...this.state.extensionLoading,\n state: \"ready\",\n loadedExtensionCount: params.loadedExtensionCount,\n totalExtensionCount: params.totalExtensionCount,\n completedAt: now(),\n error: undefined\n };\n }\n\n markExtensionLoadingError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.extensionLoading = {\n ...this.state.extensionLoading,\n state: \"error\",\n completedAt: now(),\n error\n };\n }\n\n markChannelsPending(): void {\n this.state.channels = {\n state: \"pending\",\n enabled: []\n };\n }\n\n markChannelsReady(enabled: string[]): void {\n this.state.channels = {\n state: \"ready\",\n enabled: [...enabled]\n };\n if (this.state.extensionLoading.state === \"ready\") {\n this.state.phase = \"ready\";\n this.state.lastError = undefined;\n }\n }\n\n markChannelsError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.channels = {\n state: \"error\",\n enabled: [...this.state.channels.enabled],\n error\n };\n }\n\n setRemoteState(state: BootstrapRemoteState, message?: string): void {\n this.state.remote = {\n state,\n ...(message ? { message } : {})\n };\n }\n\n syncRemoteRuntimeState(runtime: RemoteRuntimeState): void {\n const message = runtime.lastError?.trim() || undefined;\n const state =\n runtime.state === \"connected\" ? \"ready\"\n : runtime.state === \"disabled\" ? \"disabled\"\n : runtime.state === \"error\" && message?.includes(\"already owned\") ? \"conflict\"\n : runtime.state === \"error\" ? \"error\"\n : \"pending\";\n this.setRemoteState(state, message);\n }\n\n markError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\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UAAU,WAAW,SAAS,SAAS,gBAAgB,GAAG,aAChE,QAAQ,UAAU,UAAU,UAC1B;AACZ,OAAK,eAAe,OAAO,QAAQ;;CAGrC,UAAU,OAAqB;AAC7B,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,YAAY"}
@@ -1,17 +1,9 @@
1
1
  import { Config } from "@nextclaw/core";
2
2
  import { AutomationManager } from "@nextclaw/kernel";
3
3
  import { RemoteServiceModule } from "@nextclaw/remote";
4
- import { PluginDiagnostic } from "@nextclaw/openclaw-compat";
5
4
  import { FSWatcher } from "chokidar";
6
5
 
7
6
  //#region src/shared/services/gateway/service-startup-support.service.d.ts
8
- declare const pluginGatewayLogger: {
9
- info: (message: string) => void;
10
- warn: (message: string) => void;
11
- error: (message: string) => void;
12
- debug: (message: string) => void;
13
- };
14
- declare function logPluginGatewayDiagnostics(diagnostics: PluginDiagnostic[]): void;
15
7
  declare function startGatewaySupportServices(params: {
16
8
  automation: AutomationManager;
17
9
  remoteModule: RemoteServiceModule | null;
@@ -39,5 +31,5 @@ declare function startGatewayRuntimeSupport(params: {
39
31
  watcherRegistry: ServiceFileWatcherRegistry;
40
32
  }): Promise<void>;
41
33
  //#endregion
42
- export { ServiceFileWatcherRegistry, logPluginGatewayDiagnostics, markLocalUiRuntimeIfStarted, pluginGatewayLogger, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
34
+ export { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
43
35
  //# sourceMappingURL=service-startup-support.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-startup-support.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"mappings":";;;;;;;cAQa,mBAAA;;;;;;iBAOG,2BAAA,CACd,WAAA,EAAa,gBAAA;AAAA,iBAaO,2BAAA,CAA4B,MAAA;EAChD,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;AAAA,IACE,OAAA;AAAA,iBAWY,kBAAA,CAAmB,UAAA,EAAY,iBAAA,GAAoB,SAAA;AAAA,iBAqBnD,sBAAA,CAAuB,MAAA;EACrC,UAAA;EACA,eAAA,EAAiB,0BAAA;EACjB,cAAA,GAAiB,MAAA;AAAA;AAAA,cA0BN,0BAAA;EAAA,iBACM,QAAA;EAAA,SAER,QAAA,GAAY,OAAA,EAAS,SAAA;EAAA,SAIrB,KAAA,QAAkB,OAAA;AAAA;AAAA,iBAYb,2BAAA,CAA4B,MAAA;EAC1C,SAAA;EACA,QAAA,EAAU,IAAA,CAAK,MAAA;AAAA;AAAA,iBAQK,0BAAA,CAA2B,MAAA;EAC/C,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;EACA,eAAA,EAAiB,0BAAA;AAAA,IACf,OAAA"}
1
+ {"version":3,"file":"service-startup-support.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"mappings":";;;;;;iBAOsB,2BAAA,CAA4B,MAAA;EAChD,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;AAAA,IACE,OAAA;AAAA,iBAWY,kBAAA,CAAmB,UAAA,EAAY,iBAAA,GAAoB,SAAA;AAAA,iBAqBnD,sBAAA,CAAuB,MAAA;EACrC,UAAA;EACA,eAAA,EAAiB,0BAAA;EACjB,cAAA,GAAiB,MAAA;AAAA;AAAA,cA0BN,0BAAA;EAAA,iBACM,QAAA;EAAA,SAER,QAAA,GAAY,OAAA,EAAS,SAAA;EAAA,SAIrB,KAAA,QAAkB,OAAA;AAAA;AAAA,iBAYb,2BAAA,CAA4B,MAAA;EAC1C,SAAA;EACA,QAAA,EAAU,IAAA,CAAK,MAAA;AAAA;AAAA,iBAQK,0BAAA,CAA2B,MAAA;EAC/C,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;EACA,eAAA,EAAiB,0BAAA;AAAA,IACf,OAAA"}
@@ -2,19 +2,6 @@ import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
2
2
  import { resolve } from "node:path";
3
3
  import chokidar from "chokidar";
4
4
  //#region src/shared/services/gateway/service-startup-support.service.ts
5
- const pluginGatewayLogger = {
6
- info: (message) => console.log(`[plugins] ${message}`),
7
- warn: (message) => console.warn(`[plugins] ${message}`),
8
- error: (message) => console.error(`[plugins] ${message}`),
9
- debug: (message) => console.debug(`[plugins] ${message}`)
10
- };
11
- function logPluginGatewayDiagnostics(diagnostics) {
12
- for (const diag of diagnostics) {
13
- const text = `${diag.pluginId ? `${diag.pluginId}: ` : ""}${diag.message}`;
14
- if (diag.level === "error") console.error(`[plugins] ${text}`);
15
- else console.warn(`[plugins] ${text}`);
16
- }
17
- }
18
5
  async function startGatewaySupportServices(params) {
19
6
  const { automation, remoteModule, watchConfigFile } = params;
20
7
  const cronJobs = automation.status().jobs;
@@ -93,6 +80,6 @@ async function startGatewayRuntimeSupport(params) {
93
80
  watcherRegistry.remember(watchCronStoreFile(automation));
94
81
  }
95
82
  //#endregion
96
- export { ServiceFileWatcherRegistry, logPluginGatewayDiagnostics, markLocalUiRuntimeIfStarted, pluginGatewayLogger, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
83
+ export { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
97
84
 
98
85
  //# sourceMappingURL=service-startup-support.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-startup-support.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport type { AutomationManager } from \"@nextclaw/kernel\";\nimport type { PluginDiagnostic } from \"@nextclaw/openclaw-compat\";\nimport type { RemoteServiceModule } from \"@nextclaw/remote\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport { resolve } from \"node:path\";\nimport { localUiRuntimeStore } from \"../../../shared/stores/local-ui-runtime.store.js\";\n\nexport const pluginGatewayLogger = {\n info: (message: string) => console.log(`[plugins] ${message}`),\n warn: (message: string) => console.warn(`[plugins] ${message}`),\n error: (message: string) => console.error(`[plugins] ${message}`),\n debug: (message: string) => console.debug(`[plugins] ${message}`)\n};\n\nexport function logPluginGatewayDiagnostics(\n diagnostics: PluginDiagnostic[],\n): void {\n for (const diag of diagnostics) {\n const prefix = diag.pluginId ? `${diag.pluginId}: ` : \"\";\n const text = `${prefix}${diag.message}`;\n if (diag.level === \"error\") {\n console.error(`[plugins] ${text}`);\n } else {\n console.warn(`[plugins] ${text}`);\n }\n }\n}\n\nexport async function startGatewaySupportServices(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n}): Promise<void> {\n const { automation, remoteModule, watchConfigFile } = params;\n const cronJobs = automation.status().jobs;\n if (cronJobs > 0) {\n console.log(`✓ Cron: ${cronJobs} scheduled jobs`);\n }\n remoteModule?.start();\n watchConfigFile();\n await automation.start();\n}\n\nexport function watchCronStoreFile(automation: AutomationManager): FSWatcher {\n const cronStorePath = resolve(automation.storePath);\n const watcher = chokidar.watch(cronStorePath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== cronStorePath) {\n return;\n }\n if (event === \"add\" || event === \"change\" || event === \"unlink\") {\n try {\n automation.reloadFromStore();\n } catch (error) {\n console.error(`Cron store reload failed (${event}): ${String(error)}`);\n }\n }\n });\n return watcher;\n}\n\nexport function watchServiceConfigFile(params: {\n configPath: string;\n watcherRegistry: ServiceFileWatcherRegistry;\n scheduleReload: (reason: string) => void;\n}): void {\n const configPath = resolve(params.configPath);\n const watcher = chokidar.watch(configPath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n params.watcherRegistry.remember(watcher);\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== configPath) {\n return;\n }\n if (event === \"add\") {\n params.scheduleReload(\"config add\");\n return;\n }\n if (event === \"change\") {\n params.scheduleReload(\"config change\");\n return;\n }\n if (event === \"unlink\") {\n params.scheduleReload(\"config unlink\");\n }\n });\n}\n\nexport class ServiceFileWatcherRegistry {\n private readonly watchers: FSWatcher[] = [];\n\n readonly remember = (watcher: FSWatcher): void => {\n this.watchers.push(watcher);\n };\n\n readonly clear = async (): Promise<void> => {\n const watchers = this.watchers.splice(0);\n await Promise.allSettled(watchers.map(async (watcher) => {\n try {\n await watcher.close();\n } catch {\n void 0;\n }\n }));\n };\n}\n\nexport function markLocalUiRuntimeIfStarted(params: {\n uiStartup: unknown | null | undefined;\n uiConfig: Pick<Config[\"ui\"], \"host\" | \"port\">;\n}): void {\n const { uiConfig, uiStartup } = params;\n if (uiStartup) {\n localUiRuntimeStore.writeCurrentProcess(uiConfig);\n }\n}\n\nexport async function startGatewayRuntimeSupport(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n watcherRegistry: ServiceFileWatcherRegistry;\n}): Promise<void> {\n const {\n automation,\n remoteModule,\n watchConfigFile,\n watcherRegistry\n } = params;\n await startGatewaySupportServices({\n automation,\n remoteModule,\n watchConfigFile\n });\n watcherRegistry.remember(watchCronStoreFile(automation));\n}\n"],"mappings":";;;;AAQA,MAAa,sBAAsB;CACjC,OAAO,YAAoB,QAAQ,IAAI,aAAa,UAAU;CAC9D,OAAO,YAAoB,QAAQ,KAAK,aAAa,UAAU;CAC/D,QAAQ,YAAoB,QAAQ,MAAM,aAAa,UAAU;CACjE,QAAQ,YAAoB,QAAQ,MAAM,aAAa,UAAU;CAClE;AAED,SAAgB,4BACd,aACM;AACN,MAAK,MAAM,QAAQ,aAAa;EAE9B,MAAM,OAAO,GADE,KAAK,WAAW,GAAG,KAAK,S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ACtC,WAAyC,EAAE;CAE3C,YAAqB,YAA6B;AAChD,OAAK,SAAS,KAAK,QAAQ;;CAG7B,QAAiB,YAA2B;EAC1C,MAAM,WAAW,KAAK,SAAS,OAAO,EAAE;AACxC,QAAM,QAAQ,WAAW,SAAS,IAAI,OAAO,YAAY;AACvD,OAAI;AACF,UAAM,QAAQ,OAAO;WACf;IAGR,CAAC;;;AAIP,SAAgB,4BAA4B,QAGnC;CACP,MAAM,EAAE,UAAU,cAAc;AAChC,KAAI,UACF,qBAAoB,oBAAoB,SAAS;;AAIrD,eAAsB,2BAA2B,QAK/B;CAChB,MAAM,EACJ,YACA,cACA,iBACA,oBACE;AACJ,OAAM,4BAA4B;EAChC;EACA;EACA;EACD,CAAC;AACF,iBAAgB,SAAS,mBAAmB,WAAW,CAAC"}
1
+ {"version":3,"file":"service-startup-support.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport type { AutomationManager } from \"@nextclaw/kernel\";\nimport type { RemoteServiceModule } from \"@nextclaw/remote\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport { resolve } from \"node:path\";\nimport { localUiRuntimeStore } from \"../../../shared/stores/local-ui-runtime.store.js\";\n\nexport async function startGatewaySupportServices(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n}): Promise<void> {\n const { automation, remoteModule, watchConfigFile } = params;\n const cronJobs = automation.status().jobs;\n if (cronJobs > 0) {\n console.log(`✓ Cron: ${cronJobs} scheduled jobs`);\n }\n remoteModule?.start();\n watchConfigFile();\n await automation.start();\n}\n\nexport function watchCronStoreFile(automation: AutomationManager): FSWatcher {\n const cronStorePath = resolve(automation.storePath);\n const watcher = chokidar.watch(cronStorePath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== cronStorePath) {\n return;\n }\n if (event === \"add\" || event === \"change\" || event === \"unlink\") {\n try {\n automation.reloadFromStore();\n } catch (error) {\n console.error(`Cron store reload failed (${event}): ${String(error)}`);\n }\n }\n });\n return watcher;\n}\n\nexport function watchServiceConfigFile(params: {\n configPath: string;\n watcherRegistry: ServiceFileWatcherRegistry;\n scheduleReload: (reason: string) => void;\n}): void {\n const configPath = resolve(params.configPath);\n const watcher = chokidar.watch(configPath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n params.watcherRegistry.remember(watcher);\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== configPath) {\n return;\n }\n if (event === \"add\") {\n params.scheduleReload(\"config add\");\n return;\n }\n if (event === \"change\") {\n params.scheduleReload(\"config change\");\n return;\n }\n if (event === \"unlink\") {\n params.scheduleReload(\"config unlink\");\n }\n });\n}\n\nexport class ServiceFileWatcherRegistry {\n private readonly watchers: FSWatcher[] = [];\n\n readonly remember = (watcher: FSWatcher): void => {\n this.watchers.push(watcher);\n };\n\n readonly clear = async (): Promise<void> => {\n const watchers = this.watchers.splice(0);\n await Promise.allSettled(watchers.map(async (watcher) => {\n try {\n await watcher.close();\n } catch {\n void 0;\n }\n }));\n };\n}\n\nexport function markLocalUiRuntimeIfStarted(params: {\n uiStartup: unknown | null | undefined;\n uiConfig: Pick<Config[\"ui\"], \"host\" | \"port\">;\n}): void {\n const { uiConfig, uiStartup } = params;\n if (uiStartup) {\n localUiRuntimeStore.writeCurrentProcess(uiConfig);\n }\n}\n\nexport async function startGatewayRuntimeSupport(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n watcherRegistry: ServiceFileWatcherRegistry;\n}): Promise<void> {\n const {\n automation,\n remoteModule,\n watchConfigFile,\n watcherRegistry\n } = params;\n await startGatewaySupportServices({\n automation,\n remoteModule,\n watchConfigFile\n });\n watcherRegistry.remember(watchCronStoreFile(automation));\n}\n"],"mappings":";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,KAAK,SAAS,OAAO,EAAE;AACxC,QAAM,QAAQ,WAAW,SAAS,IAAI,OAAO,YAAY;AACvD,OAAI;AACF,UAAM,QAAQ,OAAO;WACf;IAGR,CAAC;;;AAIP,SAAgB,4BAA4B,QAGnC;CACP,MAAM,EAAE,UAAU,cAAc;AAChC,KAAI,UACF,qBAAoB,oBAAoB,SAAS;;AAIrD,eAAsB,2BAA2B,QAK/B;CAChB,MAAM,EACJ,YACA,cACA,iBACA,oBACE;AACJ,OAAM,4BAA4B;EAChC;EACA;EACA;EACD,CAAC;AACF,iBAAgB,SAAS,mBAAmB,WAAW,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { MessageBus } from "@nextclaw/core";
2
- import { NcpRunnerAgent } from "@nextclaw/kernel";
2
+ import { AgentRunClient } from "@nextclaw/kernel";
3
3
 
4
4
  //#region src/shared/services/gateway/utils/cron-job-handler.utils.d.ts
5
5
  type CronJobLike = {
@@ -16,7 +16,7 @@ type CronJobLike = {
16
16
  };
17
17
  };
18
18
  declare function createCronJobHandler(params: {
19
- agentRunRequests: NcpRunnerAgent;
19
+ agentRunClient: AgentRunClient;
20
20
  bus: MessageBus;
21
21
  }): (job: CronJobLike) => Promise<string>;
22
22
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"cron-job-handler.utils.d.ts","names":[],"sources":["../../../../../src/shared/services/gateway/utils/cron-job-handler.utils.ts"],"mappings":";;;;KAGK,WAAA;EACH,EAAA;EACA,IAAA;EACA,OAAA;IACE,OAAA;IACA,OAAA;IACA,SAAA;IACA,OAAA;IACA,OAAA;IACA,EAAA;IACA,SAAA;EAAA;AAAA;AAAA,iBAsCY,oBAAA,CAAqB,MAAA;EACnC,gBAAA,EAAkB,cAAA;EAClB,GAAA,EAAK,UAAA;AAAA,KACF,GAAA,EAAK,WAAA,KAAgB,OAAA"}
1
+ {"version":3,"file":"cron-job-handler.utils.d.ts","names":[],"sources":["../../../../../src/shared/services/gateway/utils/cron-job-handler.utils.ts"],"mappings":";;;;KAMK,WAAA;EACH,EAAA;EACA,IAAA;EACA,OAAA;IACE,OAAA;IACA,OAAA;IACA,SAAA;IACA,OAAA;IACA,OAAA;IACA,EAAA;IACA,SAAA;EAAA;AAAA;AAAA,iBAmCY,oBAAA,CAAqB,MAAA;EACnC,cAAA,EAAgB,cAAA;EAChB,GAAA,EAAK,UAAA;AAAA,KACF,GAAA,EAAK,WAAA,KAAgB,OAAA"}
@@ -1,4 +1,4 @@
1
- import { runPromptOverNcp } from "@nextclaw/kernel";
1
+ import { buildAgentRunSendPayload } from "@nextclaw/kernel";
2
2
  //#region src/shared/services/gateway/utils/cron-job-handler.utils.ts
3
3
  function normalizeOptionalString(value) {
4
4
  if (typeof value !== "string") return;
@@ -6,23 +6,16 @@ function normalizeOptionalString(value) {
6
6
  }
7
7
  function buildCronSessionMetadata(params) {
8
8
  const { job, agentId, accountId } = params;
9
- const channel = normalizeOptionalString(job.payload.channel) ?? "cli";
10
- const chatId = normalizeOptionalString(job.payload.to) ?? "direct";
11
9
  const metadata = {
12
10
  agentId,
13
- agent_id: agentId,
14
- channel,
15
- chatId,
16
- chat_id: chatId,
11
+ channel: normalizeOptionalString(job.payload.channel) ?? "cli",
12
+ chatId: normalizeOptionalString(job.payload.to) ?? "direct",
17
13
  label: job.name,
18
14
  cron_job_id: job.id,
19
15
  cron_job_name: job.name,
20
16
  session_origin: "cron"
21
17
  };
22
- if (accountId) {
23
- metadata.accountId = accountId;
24
- metadata.account_id = accountId;
25
- }
18
+ if (accountId) metadata.accountId = accountId;
26
19
  return metadata;
27
20
  }
28
21
  function createCronJobHandler(params) {
@@ -35,11 +28,11 @@ function createCronJobHandler(params) {
35
28
  agentId,
36
29
  accountId
37
30
  });
38
- const response = (await runPromptOverNcp({
39
- agent: params.agentRunRequests,
31
+ const response = (await params.agentRunClient.sendAndWaitForReply(await buildAgentRunSendPayload({
40
32
  sessionId,
41
33
  content: job.payload.message,
42
- metadata,
34
+ metadata
35
+ }), {
43
36
  missingCompletedMessageError: "cron job completed without a final assistant message",
44
37
  runErrorMessage: "cron job failed"
45
38
  })).text;
@@ -1 +1 @@
1
- {"version":3,"file":"cron-job-handler.utils.js","names":[],"sources":["../../../../../src/shared/services/gateway/utils/cron-job-handler.utils.ts"],"sourcesContent":["import type { MessageBus } from \"@nextclaw/core\";\nimport { runPromptOverNcp, type NcpRunnerAgent } from \"@nextclaw/kernel\";\n\ntype CronJobLike = {\n id: string;\n name: string;\n payload: {\n message: string;\n agentId?: string | null;\n sessionId?: string | null;\n deliver?: boolean;\n channel?: string | null;\n to?: string | null;\n accountId?: string | null;\n };\n};\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed || undefined;\n}\n\nfunction buildCronSessionMetadata(params: {\n job: CronJobLike;\n agentId: string;\n accountId?: string;\n}): Record<string, unknown> {\n const { job, agentId, accountId } = params;\n const channel = normalizeOptionalString(job.payload.channel) ?? \"cli\";\n const chatId = normalizeOptionalString(job.payload.to) ?? \"direct\";\n const metadata: Record<string, unknown> = {\n agentId,\n agent_id: agentId,\n channel,\n chatId,\n chat_id: chatId,\n label: job.name,\n cron_job_id: job.id,\n cron_job_name: job.name,\n session_origin: \"cron\",\n };\n if (accountId) {\n metadata.accountId = accountId;\n metadata.account_id = accountId;\n }\n return metadata;\n}\n\nexport function createCronJobHandler(params: {\n agentRunRequests: NcpRunnerAgent;\n bus: MessageBus;\n}): (job: CronJobLike) => Promise<string> {\n return async (job: CronJobLike): Promise<string> => {\n const accountId = normalizeOptionalString(job.payload.accountId);\n const agentId = normalizeOptionalString(job.payload.agentId) ?? \"main\";\n const sessionId = normalizeOptionalString(job.payload.sessionId) ?? `cron:${job.id}`;\n const metadata = buildCronSessionMetadata({\n job,\n agentId,\n accountId,\n });\n const result = await runPromptOverNcp({\n agent: params.agentRunRequests,\n sessionId,\n content: job.payload.message,\n metadata,\n missingCompletedMessageError: \"cron job completed without a final assistant message\",\n runErrorMessage: \"cron job failed\",\n });\n const response = result.text;\n\n if (job.payload.deliver && job.payload.to) {\n await params.bus.publishOutbound({\n channel: job.payload.channel ?? \"cli\",\n chatId: job.payload.to,\n content: response,\n media: [],\n metadata,\n });\n }\n\n return response;\n };\n}\n"],"mappings":";;AAiBA,SAAS,wBAAwB,OAAoC;AACnE,KAAI,OAAO,UAAU,SACnB;AAGF,QADgB,MAAM,MAAM,IACV,KAAA;;AAGpB,SAAS,yBAAyB,QAIN;CAC1B,MAAM,EAAE,KAAK,SAAS,cAAc;CACpC,MAAM,UAAU,wBAAwB,IAAI,QAAQ,QAAQ,IAAI;CAChE,MAAM,SAAS,wBAAwB,IAAI,QAAQ,GAAG,IAAI;CAC1D,MAAM,WAAoC;EACxC;EACA,UAAU;EACV;EACA;EACA,SAAS;EACT,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,eAAe,IAAI;EACnB,gBAAgB;EACjB;AACD,KAAI,WAAW;AACb,WAAS,YAAY;AACrB,WAAS,aAAa;;AAExB,QAAO;;AAGT,SAAgB,qBAAqB,QAGK;AACxC,QAAO,OAAO,QAAsC;EAClD,MAAM,YAAY,wBAAwB,IAAI,QAAQ,UAAU;EAChE,MAAM,UAAU,wBAAwB,IAAI,QAAQ,QAAQ,IAAI;EAChE,MAAM,YAAY,wBAAwB,IAAI,QAAQ,UAAU,IAAI,QAAQ,IAAI;EAChF,MAAM,WAAW,yBAAyB;GACxC;GACA;GACA;GACD,CAAC;EASF,MAAM,YARS,MAAM,iBAAiB;GACpC,OAAO,OAAO;GACd;GACA,SAAS,IAAI,QAAQ;GACrB;GACA,8BAA8B;GAC9B,iBAAiB;GAClB,CAAC,EACsB;AAExB,MAAI,IAAI,QAAQ,WAAW,IAAI,QAAQ,GACrC,OAAM,OAAO,IAAI,gBAAgB;GAC/B,SAAS,IAAI,QAAQ,WAAW;GAChC,QAAQ,IAAI,QAAQ;GACpB,SAAS;GACT,OAAO,EAAE;GACT;GACD,CAAC;AAGJ,SAAO"}
1
+ {"version":3,"file":"cron-job-handler.utils.js","names":[],"sources":["../../../../../src/shared/services/gateway/utils/cron-job-handler.utils.ts"],"sourcesContent":["import type { MessageBus } from \"@nextclaw/core\";\nimport {\n buildAgentRunSendPayload,\n type AgentRunClient,\n} from \"@nextclaw/kernel\";\n\ntype CronJobLike = {\n id: string;\n name: string;\n payload: {\n message: string;\n agentId?: string | null;\n sessionId?: string | null;\n deliver?: boolean;\n channel?: string | null;\n to?: string | null;\n accountId?: string | null;\n };\n};\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed || undefined;\n}\n\nfunction buildCronSessionMetadata(params: {\n job: CronJobLike;\n agentId: string;\n accountId?: string;\n}): Record<string, unknown> {\n const { job, agentId, accountId } = params;\n const channel = normalizeOptionalString(job.payload.channel) ?? \"cli\";\n const chatId = normalizeOptionalString(job.payload.to) ?? \"direct\";\n const metadata: Record<string, unknown> = {\n agentId,\n channel,\n chatId,\n label: job.name,\n cron_job_id: job.id,\n cron_job_name: job.name,\n session_origin: \"cron\",\n };\n if (accountId) {\n metadata.accountId = accountId;\n }\n return metadata;\n}\n\nexport function createCronJobHandler(params: {\n agentRunClient: AgentRunClient;\n bus: MessageBus;\n}): (job: CronJobLike) => Promise<string> {\n return async (job: CronJobLike): Promise<string> => {\n const accountId = normalizeOptionalString(job.payload.accountId);\n const agentId = normalizeOptionalString(job.payload.agentId) ?? \"main\";\n const sessionId = normalizeOptionalString(job.payload.sessionId) ?? `cron:${job.id}`;\n const metadata = buildCronSessionMetadata({\n job,\n agentId,\n accountId,\n });\n const result = await params.agentRunClient.sendAndWaitForReply(await buildAgentRunSendPayload({\n sessionId,\n content: job.payload.message,\n metadata,\n }), {\n missingCompletedMessageError: \"cron job completed without a final assistant message\",\n runErrorMessage: \"cron job failed\",\n });\n const response = result.text;\n\n if (job.payload.deliver && job.payload.to) {\n await params.bus.publishOutbound({\n channel: job.payload.channel ?? \"cli\",\n chatId: job.payload.to,\n content: response,\n media: [],\n metadata,\n });\n }\n\n return response;\n };\n}\n"],"mappings":";;AAoBA,SAAS,wBAAwB,OAAoC;AACnE,KAAI,OAAO,UAAU,SACnB;AAGF,QADgB,MAAM,MAAM,IACV,KAAA;;AAGpB,SAAS,yBAAyB,QAIN;CAC1B,MAAM,EAAE,KAAK,SAAS,cAAc;CAGpC,MAAM,WAAoC;EACxC;EACA,SAJc,wBAAwB,IAAI,QAAQ,QAAQ,IAAI;EAK9D,QAJa,wBAAwB,IAAI,QAAQ,GAAG,IAAI;EAKxD,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,eAAe,IAAI;EACnB,gBAAgB;EACjB;AACD,KAAI,UACF,UAAS,YAAY;AAEvB,QAAO;;AAGT,SAAgB,qBAAqB,QAGK;AACxC,QAAO,OAAO,QAAsC;EAClD,MAAM,YAAY,wBAAwB,IAAI,QAAQ,UAAU;EAChE,MAAM,UAAU,wBAAwB,IAAI,QAAQ,QAAQ,IAAI;EAChE,MAAM,YAAY,wBAAwB,IAAI,QAAQ,UAAU,IAAI,QAAQ,IAAI;EAChF,MAAM,WAAW,yBAAyB;GACxC;GACA;GACA;GACD,CAAC;EASF,MAAM,YARS,MAAM,OAAO,eAAe,oBAAoB,MAAM,yBAAyB;GAC5F;GACA,SAAS,IAAI,QAAQ;GACrB;GACD,CAAC,EAAE;GACF,8BAA8B;GAC9B,iBAAiB;GAClB,CAAC,EACsB;AAExB,MAAI,IAAI,QAAQ,WAAW,IAAI,QAAQ,GACrC,OAAM,OAAO,IAAI,gBAAgB;GAC/B,SAAS,IAAI,QAAQ,WAAW;GAChC,QAAQ,IAAI,QAAQ;GACpB,SAAS;GACT,OAAO,EAAE;GACT;GACD,CAAC;AAGJ,SAAO"}
@@ -3,7 +3,7 @@ function handleGatewayDeferredStartupError(params) {
3
3
  const { bootstrapStatus, error } = params;
4
4
  const message = error instanceof Error ? error.message : String(error);
5
5
  bootstrapStatus.markError(message);
6
- if (bootstrapStatus.getStatus().pluginHydration.state === "running") bootstrapStatus.markPluginHydrationError(message);
6
+ if (bootstrapStatus.getStatus().extensionLoading.state === "running") bootstrapStatus.markExtensionLoadingError(message);
7
7
  console.error(`Deferred startup failed: ${message}`);
8
8
  }
9
9
  //#endregion