@nextclaw/service 0.1.11 → 0.1.13

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 (72) hide show
  1. package/dist/cli/commands/agent/agent-runtime.utils.d.ts +1 -2
  2. package/dist/cli/commands/agent/agent-runtime.utils.js +6 -50
  3. package/dist/cli/commands/agent/cli-agent-runner.utils.d.ts +0 -2
  4. package/dist/cli/commands/agent/cli-agent-runner.utils.js +7 -9
  5. package/dist/cli/commands/agent/services/agent-commands.service.js +0 -1
  6. package/dist/cli/commands/cron/services/cron-local.service.d.ts +1 -2
  7. package/dist/cli/commands/skills/index.js +1 -1
  8. package/dist/cli/commands/skills/marketplace-client.d.ts +11 -1
  9. package/dist/cli/commands/skills/marketplace-client.js +39 -1
  10. package/dist/cli/commands/skills/marketplace-command-options.utils.d.ts +1 -1
  11. package/dist/cli/commands/skills/marketplace.metadata.d.ts +3 -12
  12. package/dist/cli/commands/skills/marketplace.metadata.js +1 -87
  13. package/dist/cli/commands/skills/{marketplace.service.d.ts → marketplace.utils.d.ts} +1 -1
  14. package/dist/cli/commands/skills/{marketplace.service.js → marketplace.utils.js} +11 -47
  15. package/dist/cli/commands/skills/skills-query.service.d.ts +4 -37
  16. package/dist/cli/commands/skills/skills-query.service.js +16 -98
  17. package/dist/cli/commands/usage/services/llm-usage-command.service.d.ts +3 -5
  18. package/dist/cli/commands/usage/services/llm-usage-command.service.js +16 -26
  19. package/dist/commands/channel/channel-list-view.service.d.ts +0 -1
  20. package/dist/commands/channel/channel-list-view.service.js +6 -23
  21. package/dist/commands/channel/index.js +0 -1
  22. package/dist/commands/plugin/index.d.ts +2 -4
  23. package/dist/commands/plugin/index.js +8 -20
  24. package/dist/commands/plugin/{plugin-command-utils.d.ts → plugin-command.utils.d.ts} +1 -2
  25. package/dist/commands/plugin/{plugin-command-utils.js → plugin-command.utils.js} +2 -4
  26. package/dist/commands/plugin/{plugin-mutation-actions.d.ts → plugin-mutation-actions.utils.d.ts} +1 -1
  27. package/dist/commands/plugin/{plugin-mutation-actions.js → plugin-mutation-actions.utils.js} +2 -2
  28. package/dist/commands/service/services/autostart/linux-systemd-autostart.service.js +1 -1
  29. package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.js +1 -1
  30. package/dist/commands/service/services/autostart/windows-task-autostart.service.js +1 -1
  31. package/dist/launcher/npm-runtime-launcher.service.js +1 -1
  32. package/dist/service-runtime.service.d.ts +1 -1
  33. package/dist/service-runtime.service.js +7 -15
  34. package/dist/shared/controllers/gateway.controller.d.ts +3 -11
  35. package/dist/shared/controllers/gateway.controller.js +24 -180
  36. package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts +2 -9
  37. package/dist/shared/services/gateway/managers/gateway-plugin.manager.js +30 -88
  38. package/dist/shared/services/gateway/nextclaw-app.service.d.ts +2 -7
  39. package/dist/shared/services/gateway/nextclaw-app.service.js +6 -16
  40. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +4 -9
  41. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +12 -46
  42. package/dist/shared/services/gateway/{cron-job-handler.service.d.ts → utils/cron-job-handler.utils.d.ts} +3 -6
  43. package/dist/shared/services/gateway/utils/cron-job-handler.utils.js +57 -0
  44. package/dist/shared/services/marketplace/service-marketplace-installer.service.js +3 -3
  45. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js +1 -1
  46. package/dist/shared/services/runtime/runtime-command.service.js +2 -2
  47. package/dist/shared/services/runtime/service-managed-startup.service.js +1 -1
  48. package/dist/shared/services/ui/companion-runtime.service.js +1 -1
  49. package/dist/shared/services/workspace/workspace-manager.service.js +8 -10
  50. package/dist/shared/utils/cli.utils.js +1 -1
  51. package/package.json +20 -20
  52. package/dist/cli/commands/usage/services/llm-usage-query.service.d.ts +0 -43
  53. package/dist/cli/commands/usage/services/llm-usage-query.service.js +0 -85
  54. package/dist/commands/plugin/development-source/dev-plugin-overrides.utils.d.ts +0 -18
  55. package/dist/commands/plugin/development-source/dev-plugin-overrides.utils.js +0 -111
  56. package/dist/commands/plugin/development-source/first-party-plugin-load-paths.utils.d.ts +0 -9
  57. package/dist/commands/plugin/development-source/first-party-plugin-load-paths.utils.js +0 -183
  58. package/dist/commands/plugin/plugin-extension-registry.d.ts +0 -10
  59. package/dist/commands/plugin/plugin-extension-registry.js +0 -35
  60. package/dist/commands/plugin/plugin-registry-loader.utils.d.ts +0 -14
  61. package/dist/commands/plugin/plugin-registry-loader.utils.js +0 -43
  62. package/dist/commands/plugin/plugin-reload.d.ts +0 -13
  63. package/dist/commands/plugin/plugin-reload.js +0 -42
  64. package/dist/shared/services/extensions/extension-lifecycle.service.d.ts +0 -63
  65. package/dist/shared/services/extensions/extension-lifecycle.service.js +0 -174
  66. package/dist/shared/services/extensions/service-extension-runtime.service.d.ts +0 -52
  67. package/dist/shared/services/extensions/service-extension-runtime.service.js +0 -325
  68. package/dist/shared/services/gateway/cron-job-handler.service.js +0 -100
  69. package/dist/shared/services/runtime/utils/skills-loader.utils.d.ts +0 -12
  70. package/dist/shared/services/runtime/utils/skills-loader.utils.js +0 -9
  71. package/dist/shared/services/session/service-deferred-ncp-agent.service.d.ts +0 -14
  72. package/dist/shared/services/session/service-deferred-ncp-agent.service.js +0 -85
@@ -2,20 +2,17 @@ import { logStartupTrace, measureStartupAsync, measureStartupSync } from "../../
2
2
  import { openBrowser, resolveUiConfig, resolveUiStaticDir } from "../../utils/cli.utils.js";
3
3
  import { NextclawDistributionService } from "../runtime/nextclaw-distribution.service.js";
4
4
  import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
5
- import { resolveChannelConfigView } from "../../../commands/channel/channel-config-view.js";
6
- import { ServiceExtensionRuntime } from "../extensions/service-extension-runtime.service.js";
7
5
  import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
8
6
  import { GatewayControllerImpl } from "../../controllers/gateway.controller.js";
9
7
  import { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from "./service-startup-support.service.js";
10
8
  import { GatewayPluginManager } from "./managers/gateway-plugin.manager.js";
11
9
  import { GatewayRemoteManager } from "./managers/gateway-remote.manager.js";
12
10
  import { GatewayRestartWakeService } from "./gateway-restart-wake.service.js";
13
- import { createCronJobHandler } from "./cron-job-handler.service.js";
11
+ import { createCronJobHandler } from "./utils/cron-job-handler.utils.js";
14
12
  import { companionRuntimeService } from "../ui/companion-runtime.service.js";
15
13
  import { handleGatewayDeferredStartupError } from "./utils/gateway-runtime-lifecycle.utils.js";
16
14
  import { NextclawApp } from "./nextclaw-app.service.js";
17
15
  import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.js";
18
- import { createDeferredUiNcpAgent } from "../session/service-deferred-ncp-agent.service.js";
19
16
  import { installPluginRuntimeBridge } from "../plugin/utils/plugin-runtime-bridge.utils.js";
20
17
  import { wrapStartChannelsWithDevPluginHotReload } from "../plugin/utils/plugin-dev-hot-reload.utils.js";
21
18
  import { ServiceMarketplaceInstaller } from "../marketplace/service-marketplace-installer.service.js";
@@ -28,7 +25,7 @@ import { resolve } from "node:path";
28
25
  import { startUiServer } from "@nextclaw/server";
29
26
  import { setImmediate } from "node:timers/promises";
30
27
  //#region src/shared/services/gateway/nextclaw-gateway-runtime.service.ts
31
- const { getConfigPath: getConfigPath$1, getDataDir: getDataDir$1, getWorkspacePath: getWorkspacePath$1, saveConfig: saveConfig$1 } = NextclawCore;
28
+ const { getConfigPath: getConfigPath$1, getDataDir: getDataDir$1, getWorkspacePath: getWorkspacePath$1 } = NextclawCore;
32
29
  const DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS = 5e3;
33
30
  function resolveApplyRestartMode(uiPort) {
34
31
  const serviceState = managedServiceStateStore.read();
@@ -59,8 +56,6 @@ var NextclawGatewayRuntime = class {
59
56
  restartWake;
60
57
  bootstrapStatus;
61
58
  uiStartup;
62
- extensions;
63
- liveAgentRuntime = null;
64
59
  fileWatchers = new ServiceFileWatcherRegistry();
65
60
  deferredChannelStarter;
66
61
  constructor(deps, options) {
@@ -84,11 +79,10 @@ var NextclawGatewayRuntime = class {
84
79
  this.productVersion = this.distribution.version;
85
80
  this.plugins = new GatewayPluginManager(this);
86
81
  this.providerManager = this.kernel.llmProviders;
87
- this.installConfigRuntimeHooks();
82
+ this.installConfigHostHooks();
88
83
  this.restartWake = new GatewayRestartWakeService(this);
89
84
  this.bootstrapStatus = this.createBootstrapStatus();
90
85
  this.uiStartup = this.createDisabledUiStartup();
91
- this.extensions = new ServiceExtensionRuntime(this);
92
86
  this.remoteManager = new GatewayRemoteManager({
93
87
  deps: this.deps,
94
88
  configManager: this.configManager,
@@ -108,10 +102,10 @@ var NextclawGatewayRuntime = class {
108
102
  uiConfig: this.uiConfig
109
103
  });
110
104
  this.gatewayController = this.createGatewayController();
111
- this.kernel.agentRuntimeManager.connectGatewayController(this.gatewayController);
105
+ this.kernel.provideGatewayController(this.gatewayController);
112
106
  this.deferredChannelStarter = this.startChannels;
113
107
  this.automation.onJob = createCronJobHandler({
114
- resolveNcpAgent: () => this.liveAgentRuntime,
108
+ agentRunRequests: this.kernel.agentRunRequestManager,
115
109
  bus: this.messageBus
116
110
  });
117
111
  }
@@ -133,15 +127,6 @@ var NextclawGatewayRuntime = class {
133
127
  this.bootstrapStatus = this.createBootstrapStatus();
134
128
  this.uiStartup = this.createDisabledUiStartup();
135
129
  this.deferredChannelStarter = this.startChannels;
136
- this.liveAgentRuntime = null;
137
- };
138
- get ncpAgent() {
139
- return this.uiStartup.deferredNcpAgent.agent;
140
- }
141
- activateAgentRuntime = (ncpAgent) => {
142
- this.liveAgentRuntime = ncpAgent;
143
- if (this.uiConfig.enabled) this.uiStartup.deferredNcpAgent.activate(ncpAgent);
144
- this.bootstrapStatus.markNcpAgentReady();
145
130
  };
146
131
  createBootstrapStatus = () => {
147
132
  const bootstrapStatus = new ServiceBootstrapStatusStore();
@@ -149,15 +134,11 @@ var NextclawGatewayRuntime = class {
149
134
  bootstrapStatus.setRemoteState(this.configManager.config.remote.enabled ? "pending" : "disabled");
150
135
  return bootstrapStatus;
151
136
  };
152
- createDisabledUiStartup = () => ({
153
- deferredNcpAgent: createDeferredUiNcpAgent(),
154
- endpoint: ""
155
- });
137
+ createDisabledUiStartup = () => ({ endpoint: "" });
156
138
  startUiRuntime = async () => {
157
139
  const uiStartup = await measureStartupAsync("service.start_ui_runtime", async () => {
158
140
  logStartupTrace("service.start_ui_runtime.begin");
159
141
  if (!this.uiConfig.enabled) return this.createDisabledUiStartup();
160
- const deferredNcpAgent = this.uiStartup.deferredNcpAgent;
161
142
  const uiServer = await startUiServer(this.createUiRouterOptions());
162
143
  const uiUrl = NextclawCore.resolveLocalUiBaseUrl({
163
144
  host: uiServer.host,
@@ -170,10 +151,7 @@ var NextclawGatewayRuntime = class {
170
151
  host: uiServer.host,
171
152
  port: uiServer.port
172
153
  });
173
- return {
174
- deferredNcpAgent,
175
- endpoint: uiUrl
176
- };
154
+ return { endpoint: uiUrl };
177
155
  });
178
156
  markLocalUiRuntimeIfStarted({
179
157
  uiStartup: this.uiConfig.enabled ? uiStartup : null,
@@ -182,9 +160,9 @@ var NextclawGatewayRuntime = class {
182
160
  return uiStartup;
183
161
  };
184
162
  createUiRouterOptions = () => ({
163
+ kernel: this.kernel,
185
164
  configPath: this.configManager.configPath,
186
165
  appEventBus: this.appEventBus,
187
- ingress: this.ingress,
188
166
  uiConfig: this.uiConfig,
189
167
  uiStaticDir: this.uiStaticDir,
190
168
  productVersion: this.productVersion,
@@ -192,14 +170,11 @@ var NextclawGatewayRuntime = class {
192
170
  initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,
193
171
  marketplace: this.marketplace,
194
172
  cron: this.automation,
195
- ncpAgent: this.ncpAgent,
196
- sessions: this.kernel.ncpSessionApi,
197
173
  remoteAccess: this.remoteManager.remoteAccess,
198
174
  runtimeControl: this.runtimeControl,
199
175
  ...this.runtimeUpdate ? { runtimeUpdate: this.runtimeUpdate } : {},
200
176
  bootstrapStatus: this.bootstrapStatus,
201
- plugins: this.plugins,
202
- providers: this.providerManager
177
+ plugins: this.plugins
203
178
  });
204
179
  runRuntimeLoop = async () => {
205
180
  logStartupTrace("service.start_gateway.runtime_loop_begin");
@@ -252,9 +227,7 @@ var NextclawGatewayRuntime = class {
252
227
  cleanup = async () => {
253
228
  localUiRuntimeStore.clearIfOwnedByProcess();
254
229
  await this.fileWatchers.clear();
255
- this.liveAgentRuntime = null;
256
- await this.uiStartup.deferredNcpAgent.close();
257
- await this.extensions.stop();
230
+ await this.kernel.extensions.stop();
258
231
  await this.remoteManager.stop();
259
232
  await this.plugins.stopGateways();
260
233
  setPluginRuntimeBridge(null);
@@ -269,8 +242,6 @@ var NextclawGatewayRuntime = class {
269
242
  channels: this.kernel.channels,
270
243
  cron: this.automation,
271
244
  sessionManager: this.sessionManager,
272
- getConfigPath: getConfigPath$1,
273
- saveConfig: saveConfig$1,
274
245
  requestRestart: async (options) => {
275
246
  await this.deps.requestRestart({
276
247
  reason: options?.reason ?? "gateway tool restart",
@@ -299,10 +270,8 @@ var NextclawGatewayRuntime = class {
299
270
  configurePluginRuntime = () => {
300
271
  installPluginRuntimeBridge(this);
301
272
  };
302
- installConfigRuntimeHooks = () => {
273
+ installConfigHostHooks = () => {
303
274
  this.configManager.installRuntimeHooks({
304
- resolveChannelConfig: (nextConfig) => resolveChannelConfigView(nextConfig, this.kernel.extensions.getChannelBindings()),
305
- getExtensionChannels: () => this.kernel.extensions.getExtensionRegistry().channels,
306
275
  reloadCompanion: async ({ config: nextConfig }) => {
307
276
  await companionRuntimeService.applyConfig(nextConfig);
308
277
  },
@@ -314,9 +283,6 @@ var NextclawGatewayRuntime = class {
314
283
  if (result.restartChannels) console.log("Config reload: plugin channel gateways restarted.");
315
284
  return { restartChannels: result.restartChannels };
316
285
  },
317
- reloadMcp: async ({ config: nextConfig }) => {
318
- await this.liveAgentRuntime?.applyMcpConfig?.(nextConfig);
319
- },
320
286
  onRestartRequired: (paths) => {
321
287
  this.deps.requestRestart({
322
288
  changedPaths: paths,
@@ -329,7 +295,7 @@ var NextclawGatewayRuntime = class {
329
295
  });
330
296
  };
331
297
  configureIngressHandlers = () => {
332
- this.extensions.registerIngressHandlers(this.ingress);
298
+ this.kernel.extensions.registerIngressHandlers();
333
299
  };
334
300
  };
335
301
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { MessageBus } from "@nextclaw/core";
2
- import { NcpAgentRunApi } from "@nextclaw/ncp";
2
+ import { NcpRunnerAgent } from "@nextclaw/kernel";
3
3
 
4
- //#region src/shared/services/gateway/cron-job-handler.service.d.ts
4
+ //#region src/shared/services/gateway/utils/cron-job-handler.utils.d.ts
5
5
  type CronJobLike = {
6
6
  id: string;
7
7
  name: string;
@@ -15,11 +15,8 @@ type CronJobLike = {
15
15
  accountId?: string | null;
16
16
  };
17
17
  };
18
- type BackgroundNcpAgent = {
19
- runApi: NcpAgentRunApi;
20
- };
21
18
  declare function createCronJobHandler(params: {
22
- resolveNcpAgent: () => BackgroundNcpAgent | null;
19
+ agentRunRequests: NcpRunnerAgent;
23
20
  bus: MessageBus;
24
21
  }): (job: CronJobLike) => Promise<string>;
25
22
  //#endregion
@@ -0,0 +1,57 @@
1
+ import { runPromptOverNcp } from "@nextclaw/kernel";
2
+ //#region src/shared/services/gateway/utils/cron-job-handler.utils.ts
3
+ function normalizeOptionalString(value) {
4
+ if (typeof value !== "string") return;
5
+ return value.trim() || void 0;
6
+ }
7
+ function buildCronSessionMetadata(params) {
8
+ const { job, agentId, accountId } = params;
9
+ const channel = normalizeOptionalString(job.payload.channel) ?? "cli";
10
+ const chatId = normalizeOptionalString(job.payload.to) ?? "direct";
11
+ const metadata = {
12
+ agentId,
13
+ agent_id: agentId,
14
+ channel,
15
+ chatId,
16
+ chat_id: chatId,
17
+ label: job.name,
18
+ cron_job_id: job.id,
19
+ cron_job_name: job.name,
20
+ session_origin: "cron"
21
+ };
22
+ if (accountId) {
23
+ metadata.accountId = accountId;
24
+ metadata.account_id = accountId;
25
+ }
26
+ return metadata;
27
+ }
28
+ function createCronJobHandler(params) {
29
+ return async (job) => {
30
+ const accountId = normalizeOptionalString(job.payload.accountId);
31
+ const agentId = normalizeOptionalString(job.payload.agentId) ?? "main";
32
+ const sessionId = normalizeOptionalString(job.payload.sessionId) ?? `cron:${job.id}`;
33
+ const metadata = buildCronSessionMetadata({
34
+ job,
35
+ agentId,
36
+ accountId
37
+ });
38
+ const response = (await runPromptOverNcp({
39
+ agent: params.agentRunRequests,
40
+ sessionId,
41
+ content: job.payload.message,
42
+ metadata,
43
+ missingCompletedMessageError: "cron job completed without a final assistant message",
44
+ runErrorMessage: "cron job failed"
45
+ })).text;
46
+ if (job.payload.deliver && job.payload.to) await params.bus.publishOutbound({
47
+ channel: job.payload.channel ?? "cli",
48
+ chatId: job.payload.to,
49
+ content: response,
50
+ media: [],
51
+ metadata
52
+ });
53
+ return response;
54
+ };
55
+ }
56
+ //#endregion
57
+ export { createCronJobHandler };
@@ -1,7 +1,7 @@
1
- import { disablePluginMutation, enablePluginMutation, installPluginMutation, uninstallPluginMutation } from "../../../commands/plugin/plugin-mutation-actions.js";
1
+ import { disablePluginMutation, enablePluginMutation, installPluginMutation, uninstallPluginMutation } from "../../../commands/plugin/plugin-mutation-actions.utils.js";
2
2
  import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
3
3
  import { ServiceMcpMarketplaceOps } from "./service-mcp-marketplace-ops.js";
4
- import { getWorkspacePath, loadConfig } from "@nextclaw/core";
4
+ import { getSkillsPath, getWorkspacePath, loadConfig } from "@nextclaw/core";
5
5
  import { existsSync, rmSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  //#region src/shared/services/marketplace/service-marketplace-installer.service.ts
@@ -71,7 +71,7 @@ var ServiceMarketplaceInstaller = class {
71
71
  return { message: result.message };
72
72
  }
73
73
  async uninstallSkill(slug) {
74
- const targetDir = join(getWorkspacePath(loadConfig().agents.defaults.workspace), "skills", slug);
74
+ const targetDir = join(getSkillsPath(getWorkspacePath(loadConfig().agents.defaults.workspace)), slug);
75
75
  if (!existsSync(targetDir)) throw new Error(`Skill not installed in workspace: ${slug}`);
76
76
  rmSync(targetDir, {
77
77
  recursive: true,
@@ -18,7 +18,7 @@ function installPluginRuntimeBridge(gateway) {
18
18
  const response = await dispatchPromptOverNcp({
19
19
  config: gateway.configManager.loadConfig(),
20
20
  sessionManager: gateway.sessionManager,
21
- resolveNcpAgent: () => gateway.liveAgentRuntime,
21
+ agentRunRequests: gateway.kernel.agentRunRequestManager,
22
22
  ...request
23
23
  });
24
24
  const replyText = typeof response === "string" ? response : String(response ?? "");
@@ -5,8 +5,8 @@ import { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from "../../ut
5
5
  import { ManagedServiceCommandService } from "./service-managed-startup.service.js";
6
6
  import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
7
7
  import { NextclawGatewayRuntime } from "../gateway/nextclaw-gateway-runtime.service.js";
8
- import { createSkillsLoader } from "./utils/skills-loader.utils.js";
9
8
  import * as NextclawCore from "@nextclaw/core";
9
+ import { SkillManager } from "@nextclaw/kernel";
10
10
  import { spawn } from "node:child_process";
11
11
  //#region src/shared/services/runtime/runtime-command.service.ts
12
12
  const { getWorkspacePath: getWorkspacePath$1, loadConfig: loadConfig$1 } = NextclawCore;
@@ -56,7 +56,7 @@ var RuntimeCommandService = class {
56
56
  await this.managedServiceCommandService.runForeground(options);
57
57
  };
58
58
  installBuiltinMarketplaceSkill = (slug, _force) => {
59
- if (!(createSkillsLoader(getWorkspacePath$1(loadConfig$1().agents.defaults.workspace))?.listSkills(false) ?? []).find((skill) => skill.name === slug && skill.source === "builtin")) return null;
59
+ if (!new SkillManager({ workspace: getWorkspacePath$1(loadConfig$1().agents.defaults.workspace) }).findBuiltinSkill(slug)) return null;
60
60
  return { message: `${slug} is already available (built-in)` };
61
61
  };
62
62
  mergeCommandOutput = (stdout, stderr) => {
@@ -9,8 +9,8 @@ import { probeHealthEndpoint } from "../../utils/service-port-probe.utils.js";
9
9
  import * as NextclawCore from "@nextclaw/core";
10
10
  import { FileLogSink } from "@nextclaw/core";
11
11
  import { mkdirSync } from "node:fs";
12
- import { dirname } from "node:path";
13
12
  import { spawn } from "node:child_process";
13
+ import { dirname } from "node:path";
14
14
  //#region src/shared/services/runtime/service-managed-startup.service.ts
15
15
  const { APP_NAME: APP_NAME$1, loadConfig: loadConfig$1 } = NextclawCore;
16
16
  const serviceStartupLogger = NextclawCore.getAppLogger("service.startup");
@@ -4,8 +4,8 @@ import { companionRuntimeStore } from "../../stores/companion-runtime.store.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { APP_NAME, getConfigPath, loadConfig, saveConfig } from "@nextclaw/core";
6
6
  import { existsSync } from "node:fs";
7
- import { dirname, resolve } from "node:path";
8
7
  import { spawn } from "node:child_process";
8
+ import { dirname, resolve } from "node:path";
9
9
  //#region src/shared/services/ui/companion-runtime.service.ts
10
10
  const require = createRequire(import.meta.url);
11
11
  var CompanionUnavailableError = class extends Error {
@@ -1,8 +1,8 @@
1
1
  import { findExecutableOnPath } from "../../utils/cli.utils.js";
2
- import { APP_NAME, getDataDir } from "@nextclaw/core";
2
+ import { APP_NAME, DEFAULT_SKILLS_DIR, getDataDir } from "@nextclaw/core";
3
3
  import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
- import { dirname, join, resolve } from "node:path";
5
4
  import { spawnSync } from "node:child_process";
5
+ import { dirname, join, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  //#region src/shared/services/workspace/workspace-manager.service.ts
8
8
  var WorkspaceManager = class {
@@ -14,11 +14,8 @@ var WorkspaceManager = class {
14
14
  const created = [];
15
15
  const force = Boolean(options.force);
16
16
  const templateDir = this.resolveTemplateDir();
17
- if (!templateDir) {
18
- console.warn("Warning: Template directory not found. Skipping workspace templates.");
19
- return { created };
20
- }
21
- for (const entry of [
17
+ if (!templateDir) console.warn("Warning: Template directory not found. Skipping workspace templates.");
18
+ const templateFiles = [
22
19
  {
23
20
  source: "AGENTS.md",
24
21
  target: "AGENTS.md"
@@ -55,7 +52,8 @@ var WorkspaceManager = class {
55
52
  source: "memory/MEMORY.md",
56
53
  target: "memory/MEMORY.md"
57
54
  }
58
- ]) {
55
+ ];
56
+ if (templateDir) for (const entry of templateFiles) {
59
57
  const filePath = join(workspace, entry.target);
60
58
  if (!force && existsSync(filePath)) continue;
61
59
  const templatePath = join(templateDir, entry.source);
@@ -73,10 +71,10 @@ var WorkspaceManager = class {
73
71
  mkdirSync(memoryDir, { recursive: true });
74
72
  created.push(join("memory", ""));
75
73
  }
76
- const skillsDir = join(workspace, "skills");
74
+ const skillsDir = join(workspace, DEFAULT_SKILLS_DIR);
77
75
  if (!existsSync(skillsDir)) {
78
76
  mkdirSync(skillsDir, { recursive: true });
79
- created.push(join("skills", ""));
77
+ created.push(join(DEFAULT_SKILLS_DIR, ""));
80
78
  }
81
79
  return { created };
82
80
  };
@@ -1,8 +1,8 @@
1
1
  import { getPackageVersion } from "./package/package-manifest.utils.js";
2
2
  import { createExternalCommandEnv, getLogsPath, resolveLocalUiBaseUrl } from "@nextclaw/core";
3
3
  import { existsSync } from "node:fs";
4
- import { join, resolve } from "node:path";
5
4
  import { spawn, spawnSync } from "node:child_process";
5
+ import { join, resolve } from "node:path";
6
6
  import { isIP } from "node:net";
7
7
  //#region src/shared/utils/cli.utils.ts
8
8
  function resolveUiConfig(config, overrides) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/service",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "description": "NextClaw long-running service host and runtime lifecycle.",
6
6
  "type": "module",
@@ -27,6 +27,7 @@
27
27
  "nextclaw": {
28
28
  "builtinExtensions": [
29
29
  "@nextclaw/channel-extension-feishu",
30
+ "@nextclaw/channel-extension-qq",
30
31
  "@nextclaw/channel-extension-weixin"
31
32
  ]
32
33
  },
@@ -34,25 +35,24 @@
34
35
  "chokidar": "^3.6.0",
35
36
  "commander": "^12.1.0",
36
37
  "jszip": "^3.10.1",
37
- "yaml": "^2.8.1",
38
- "@nextclaw/channel-extension-feishu": "0.1.3",
39
- "@nextclaw/kernel": "0.1.8",
40
- "@nextclaw/mcp": "0.1.84",
41
- "@nextclaw/core": "0.12.19",
42
- "@nextclaw/channel-extension-weixin": "0.1.6",
43
- "@nextclaw/ncp": "0.5.12",
44
- "@nextclaw/ncp-agent-runtime": "0.3.22",
45
- "@nextclaw/nextclaw-hermes-acp-bridge": "0.1.11",
46
- "@nextclaw/ncp-http-agent-server": "0.3.24",
47
- "@nextclaw/ncp-toolkit": "0.5.17",
48
- "@nextclaw/nextclaw-ncp-runtime-http-client": "0.1.11",
49
- "@nextclaw/ncp-mcp": "0.1.86",
50
- "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.12",
51
- "@nextclaw/remote": "0.1.96",
52
- "@nextclaw/shared": "0.1.6",
53
- "@nextclaw/runtime": "0.2.51",
54
- "@nextclaw/openclaw-compat": "1.0.19",
55
- "@nextclaw/server": "0.12.19"
38
+ "@nextclaw/channel-extension-feishu": "0.1.4",
39
+ "@nextclaw/channel-extension-qq": "0.1.1",
40
+ "@nextclaw/kernel": "0.1.10",
41
+ "@nextclaw/mcp": "0.1.85",
42
+ "@nextclaw/core": "0.12.20",
43
+ "@nextclaw/ncp-agent-runtime": "0.3.24",
44
+ "@nextclaw/channel-extension-weixin": "0.1.7",
45
+ "@nextclaw/ncp": "0.5.13",
46
+ "@nextclaw/ncp-mcp": "0.1.87",
47
+ "@nextclaw/nextclaw-hermes-acp-bridge": "0.1.12",
48
+ "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.13",
49
+ "@nextclaw/openclaw-compat": "1.0.20",
50
+ "@nextclaw/ncp-toolkit": "0.5.18",
51
+ "@nextclaw/nextclaw-ncp-runtime-http-client": "0.1.12",
52
+ "@nextclaw/server": "0.12.21",
53
+ "@nextclaw/runtime": "0.2.52",
54
+ "@nextclaw/remote": "0.1.98",
55
+ "@nextclaw/shared": "0.1.7"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/node": "^20.17.6",
@@ -1,43 +0,0 @@
1
- import { LlmUsageRecord, LlmUsageStore } from "@nextclaw/kernel";
2
-
3
- //#region src/cli/commands/usage/services/llm-usage-query.service.d.ts
4
- type LlmUsageStats = {
5
- totalRecords: number;
6
- usageRecordCount: number;
7
- emptyUsageRecordCount: number;
8
- promptTokenRecordCount: number;
9
- oldestObservedAt: string | null;
10
- latestObservedAt: string | null;
11
- totalPromptTokens: number;
12
- totalCompletionTokens: number;
13
- totalTokens: number;
14
- totalCachedTokens: number;
15
- cacheHitRecords: number;
16
- cacheHitRate: number;
17
- tokenCacheRate: number;
18
- sources: Array<{
19
- value: string;
20
- count: number;
21
- }>;
22
- models: Array<{
23
- value: string;
24
- count: number;
25
- }>;
26
- };
27
- declare class LlmUsageQueryService {
28
- private readonly store;
29
- constructor(deps?: {
30
- store?: LlmUsageStore;
31
- });
32
- get snapshotPath(): string;
33
- get historyPath(): string;
34
- readonly getSnapshot: () => LlmUsageRecord | null;
35
- readonly getHistory: (limit?: string | number) => LlmUsageRecord[];
36
- readonly getStats: () => LlmUsageStats;
37
- private readonly resolveLimit;
38
- private readonly bumpCounter;
39
- private readonly toSortedCounts;
40
- }
41
- declare const llmUsageQueryService: LlmUsageQueryService;
42
- //#endregion
43
- export { LlmUsageQueryService, LlmUsageStats, llmUsageQueryService };
@@ -1,85 +0,0 @@
1
- import { LlmUsageStore } from "@nextclaw/kernel";
2
- //#region src/cli/commands/usage/services/llm-usage-query.service.ts
3
- var LlmUsageQueryService = class {
4
- store;
5
- constructor(deps = {}) {
6
- this.store = deps.store ?? new LlmUsageStore();
7
- }
8
- get snapshotPath() {
9
- return this.store.snapshotPath;
10
- }
11
- get historyPath() {
12
- return this.store.historyPath;
13
- }
14
- getSnapshot = () => {
15
- return this.store.readSnapshot();
16
- };
17
- getHistory = (limit) => {
18
- const records = this.store.listHistory();
19
- const resolvedLimit = this.resolveLimit(limit);
20
- return records.slice(-resolvedLimit).reverse();
21
- };
22
- getStats = () => {
23
- const records = this.store.listHistory();
24
- const sources = /* @__PURE__ */ new Map();
25
- const models = /* @__PURE__ */ new Map();
26
- let totalPromptTokens = 0;
27
- let totalCompletionTokens = 0;
28
- let totalTokens = 0;
29
- let totalCachedTokens = 0;
30
- let cacheHitRecords = 0;
31
- let usageRecordCount = 0;
32
- let promptTokenRecordCount = 0;
33
- for (const record of records) {
34
- if (Object.keys(record.usage).length > 0) usageRecordCount += 1;
35
- totalPromptTokens += record.summary.promptTokens;
36
- totalCompletionTokens += record.summary.completionTokens;
37
- totalTokens += record.summary.totalTokens;
38
- totalCachedTokens += record.summary.cachedTokens;
39
- if (record.summary.promptTokens > 0) promptTokenRecordCount += 1;
40
- if (record.summary.cacheHit) cacheHitRecords += 1;
41
- this.bumpCounter(sources, record.source);
42
- this.bumpCounter(models, record.model ?? "unknown");
43
- }
44
- return {
45
- totalRecords: records.length,
46
- usageRecordCount,
47
- emptyUsageRecordCount: records.length - usageRecordCount,
48
- promptTokenRecordCount,
49
- oldestObservedAt: records[0]?.observedAt ?? null,
50
- latestObservedAt: records.at(-1)?.observedAt ?? null,
51
- totalPromptTokens,
52
- totalCompletionTokens,
53
- totalTokens,
54
- totalCachedTokens,
55
- cacheHitRecords,
56
- cacheHitRate: promptTokenRecordCount > 0 ? cacheHitRecords / promptTokenRecordCount : 0,
57
- tokenCacheRate: totalPromptTokens > 0 ? totalCachedTokens / totalPromptTokens : 0,
58
- sources: this.toSortedCounts(sources),
59
- models: this.toSortedCounts(models)
60
- };
61
- };
62
- resolveLimit = (value) => {
63
- if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
64
- if (typeof value === "string" && value.trim().length > 0) {
65
- const parsed = Number(value);
66
- if (Number.isFinite(parsed) && parsed > 0) return Math.floor(parsed);
67
- }
68
- return 10;
69
- };
70
- bumpCounter = (map, value) => {
71
- map.set(value, (map.get(value) ?? 0) + 1);
72
- };
73
- toSortedCounts = (map) => {
74
- return [...map.entries()].map(([value, count]) => ({
75
- value,
76
- count
77
- })).sort((left, right) => {
78
- if (right.count !== left.count) return right.count - left.count;
79
- return left.value.localeCompare(right.value);
80
- });
81
- };
82
- };
83
- const llmUsageQueryService = new LlmUsageQueryService();
84
- //#endregion
85
- export { LlmUsageQueryService, llmUsageQueryService };
@@ -1,18 +0,0 @@
1
- import { Config } from "@nextclaw/core";
2
-
3
- //#region src/commands/plugin/development-source/dev-plugin-overrides.utils.d.ts
4
- declare const DEV_PLUGIN_OVERRIDES_ENV = "NEXTCLAW_DEV_PLUGIN_OVERRIDES";
5
- type PluginEntrySource = "production" | "development";
6
- type DevPluginOverride = {
7
- pluginId: string;
8
- pluginPath: string;
9
- source: PluginEntrySource;
10
- };
11
- declare function resolveDevPluginOverrides(rawEnv?: string | undefined): DevPluginOverride[];
12
- declare function resolveDevPluginLoadingContext(config: Config, workspaceExtensionsDir: string | undefined, rawOverridesEnv?: string | undefined): {
13
- configWithDevPluginOverrides: Config;
14
- excludedRoots: string[];
15
- overrides: DevPluginOverride[];
16
- };
17
- //#endregion
18
- export { DEV_PLUGIN_OVERRIDES_ENV, DevPluginOverride, resolveDevPluginLoadingContext, resolveDevPluginOverrides };