rol-websocket-channel 1.2.6 → 1.3.6

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 (39) hide show
  1. package/dist/src/admin/cli.js +3 -3
  2. package/dist/src/admin/lib/paths.js +1 -1
  3. package/dist/src/admin/methods/admin.js +1 -1
  4. package/dist/src/admin/methods/agents-extended.js +2 -2
  5. package/dist/src/admin/methods/artifacts.js +3 -3
  6. package/dist/src/admin/methods/index.js +15 -15
  7. package/dist/src/admin/methods/mem9.js +2 -2
  8. package/dist/src/admin/methods/memory.js +6 -3
  9. package/dist/src/admin/methods/models-extended.js +2 -2
  10. package/dist/src/admin/methods/models.js +1 -1
  11. package/dist/src/admin/methods/pairing.js +2 -2
  12. package/dist/src/admin/methods/sessions-extended.js +3 -3
  13. package/dist/src/admin/methods/sessions.js +2 -2
  14. package/dist/src/admin/methods/skills-extended.js +3 -3
  15. package/dist/src/admin/methods/skills-toggle.js +12 -11
  16. package/dist/src/admin/methods/skills.js +2 -2
  17. package/dist/src/admin/methods/system.js +1 -1
  18. package/dist/src/admin/methods/usage.js +1 -1
  19. package/package.json +1 -1
  20. package/src/admin/cli.ts +4 -4
  21. package/src/admin/jsonrpc.ts +1 -1
  22. package/src/admin/lib/paths.ts +1 -1
  23. package/src/admin/methods/admin.ts +2 -2
  24. package/src/admin/methods/agents-extended.ts +3 -3
  25. package/src/admin/methods/artifacts.ts +4 -4
  26. package/src/admin/methods/index.ts +17 -17
  27. package/src/admin/methods/mem9.ts +3 -3
  28. package/src/admin/methods/memory.ts +10 -6
  29. package/src/admin/methods/models-extended.ts +3 -3
  30. package/src/admin/methods/models.ts +2 -2
  31. package/src/admin/methods/pairing.ts +3 -3
  32. package/src/admin/methods/sessions-extended.ts +4 -4
  33. package/src/admin/methods/sessions.ts +3 -3
  34. package/src/admin/methods/skills-extended.ts +4 -4
  35. package/src/admin/methods/skills-toggle.ts +13 -12
  36. package/src/admin/methods/skills.ts +11 -11
  37. package/src/admin/methods/system.ts +2 -2
  38. package/src/admin/methods/usage.ts +4 -3
  39. package/tsconfig.json +1 -0
@@ -1,6 +1,6 @@
1
- import { getOpenClawRoot, getProjectRoot } from './lib/paths.ts';
2
- import { getMethod } from './methods/index.ts';
3
- import { failure, JsonRpcException, JSON_RPC_ERRORS, parseRequest, serialize, success } from './jsonrpc.ts';
1
+ import { getOpenClawRoot, getProjectRoot } from './lib/paths.js';
2
+ import { getMethod } from './methods/index.js';
3
+ import { failure, JsonRpcException, JSON_RPC_ERRORS, parseRequest, serialize, success } from './jsonrpc.js';
4
4
  async function main() {
5
5
  const raw = await readStdin();
6
6
  const request = parseRequest(raw);
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
3
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
4
4
  const __filename = fileURLToPath(import.meta.url);
5
5
  const __dirname = path.dirname(__filename);
6
6
  export function getProjectRoot() {
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { readJsonFile } from '../lib/fs.ts';
2
+ import { readJsonFile } from '../lib/fs.js';
3
3
  export const getAgents = async (_params, context) => {
4
4
  const configPath = path.join(context.openclawRoot, 'openclaw.json');
5
5
  const config = await readJsonFile(configPath);
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
4
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
3
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
4
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
5
5
  const ALLOWED_AGENT_UPDATES = {
6
6
  'name': true,
7
7
  'workspace': true,
@@ -1,9 +1,9 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { ensureDir, pathExists, readJsonFile } from '../lib/fs.ts';
5
- import { ensureInside } from '../lib/paths.ts';
6
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
4
+ import { ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
5
+ import { ensureInside } from '../lib/paths.js';
6
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
7
7
  const INLINE_CONTENT_LIMIT_BYTES = 10 * 1024 * 1024;
8
8
  const MIN_ARTIFACT_SIZE_BYTES = 1;
9
9
  const ARTIFACT_MANIFEST_FILE = 'artifacts.json';
@@ -1,18 +1,18 @@
1
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
2
- import { getAgents, getConfig } from './admin.ts';
3
- import { createAgent, deleteAgent, listAgents, updateAgent } from './agents-extended.ts';
4
- import { createArtifactRecord, ensureArtifactUploaded, getArtifactContent, getArtifactPresignedPost, listArtifacts, markArtifactUploaded, refreshArtifacts } from './artifacts.ts';
5
- import { addCron, disableCron, enableCron, getCronStatus, listCron, listCronRuns, renameCron, removeCron, rescheduleCron, runCron, setCronContent, updateCronMessage, updateCronSystemEvent } from './cron.ts';
6
- import { backupMemory, createMemoryBackupRecord, exportMemoryZip, getMemoryPresignedPost, getMemoryFile, importMemoryZip, listMemoryFiles } from './memory.ts';
7
- import { getMem9Config, installMem9, reconnectMem9 } from './mem9.ts';
8
- import { getModels } from './models.ts';
9
- import { setModel, updateModels } from './models-extended.ts';
10
- import { listSessions } from './sessions.ts';
11
- import { getSession, prepareMessage, attachSkill } from './sessions-extended.ts';
12
- import { installSkillFromClawHub, installSkillFromNpm, listInstalledSkills, searchClawHubSkills, updateSkillFromClawHub } from './skills.ts';
13
- import { getInstalledSkill, uninstallSkill } from './skills-extended.ts';
14
- import { ping, restart, stop, doctorFix, logs } from './system.ts';
15
- import { getUsageBreakdown, getUsagePageSummary, getUsageSummary, getUsageTimeseries } from './usage.ts';
1
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
2
+ import { getAgents, getConfig } from './admin.js';
3
+ import { createAgent, deleteAgent, listAgents, updateAgent } from './agents-extended.js';
4
+ import { createArtifactRecord, ensureArtifactUploaded, getArtifactContent, getArtifactPresignedPost, listArtifacts, markArtifactUploaded, refreshArtifacts } from './artifacts.js';
5
+ import { addCron, disableCron, enableCron, getCronStatus, listCron, listCronRuns, renameCron, removeCron, rescheduleCron, runCron, setCronContent, updateCronMessage, updateCronSystemEvent } from './cron.js';
6
+ import { backupMemory, createMemoryBackupRecord, exportMemoryZip, getMemoryPresignedPost, getMemoryFile, importMemoryZip, listMemoryFiles } from './memory.js';
7
+ import { getMem9Config, installMem9, reconnectMem9 } from './mem9.js';
8
+ import { getModels } from './models.js';
9
+ import { setModel, updateModels } from './models-extended.js';
10
+ import { listSessions } from './sessions.js';
11
+ import { getSession, prepareMessage, attachSkill } from './sessions-extended.js';
12
+ import { installSkillFromClawHub, installSkillFromNpm, listInstalledSkills, searchClawHubSkills, updateSkillFromClawHub } from './skills.js';
13
+ import { getInstalledSkill, uninstallSkill } from './skills-extended.js';
14
+ import { ping, restart, stop, doctorFix, logs } from './system.js';
15
+ import { getUsageBreakdown, getUsagePageSummary, getUsageSummary, getUsageTimeseries } from './usage.js';
16
16
  const methods = new Map([
17
17
  // System
18
18
  ['system.ping', ping],
@@ -1,8 +1,8 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import { promisify } from 'node:util';
4
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
5
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
4
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
5
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
6
6
  const execFileAsync = promisify(execFile);
7
7
  const MEM9_PLUGIN_SPEC = '@mem9/mem9';
8
8
  const MEM9_PLUGIN_ID = 'mem9';
@@ -3,9 +3,9 @@ import path from 'node:path';
3
3
  import os from 'node:os';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
- import { copyIfExists, ensureDir, pathExists } from '../lib/fs.ts';
7
- import { ensureInside } from '../lib/paths.ts';
8
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
6
+ import { copyIfExists, ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
7
+ import { ensureInside } from '../lib/paths.js';
8
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
9
9
  const execFileAsync = promisify(execFile);
10
10
  const WORKSPACE_ROOT_FILES = [
11
11
  'AGENTS.md',
@@ -249,6 +249,9 @@ async function postJson(url, body, authToken) {
249
249
  }
250
250
  return payload;
251
251
  }
252
+ function isObject(value) {
253
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
254
+ }
252
255
  async function zipDirectory(sourceDir, zipPath) {
253
256
  await fs.rm(zipPath, { force: true });
254
257
  if (process.platform === 'win32') {
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
- import { readJsonFile, writeJsonFile } from '../lib/fs.ts';
3
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
2
+ import { readJsonFile, writeJsonFile } from '../lib/fs.js';
3
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
4
4
  // 允许修改的 provider 配置字段白名单
5
5
  const ALLOWED_PROVIDER_FIELDS = {
6
6
  'apiKey': true,
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { readJsonFile } from '../lib/fs.ts';
2
+ import { readJsonFile } from '../lib/fs.js';
3
3
  export const getModels = async (_params, context) => {
4
4
  const configPath = path.join(context.openclawRoot, 'openclaw.json');
5
5
  const config = await readJsonFile(configPath);
@@ -1,8 +1,8 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import { promisify } from 'node:util';
4
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
5
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
4
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
5
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
6
6
  const execFileAsync = promisify(execFile);
7
7
  const DEFAULT_PLUGIN_ID = 'rol-websocket-channel';
8
8
  const DEFAULT_PRODUCTION_BASE_URL = 'https://api.deotaland.ai';
@@ -1,9 +1,9 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import readline from 'node:readline';
4
- import { pathExists, readJsonFile } from '../lib/fs.ts';
5
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
6
- import { findSessionRecord } from './sessions.ts';
4
+ import { pathExists, readJsonFile } from '../lib/fs.js';
5
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
6
+ import { findSessionRecord } from './sessions.js';
7
7
  const MAX_SESSION_MESSAGES = 100;
8
8
  export const getSession = async (params, context) => {
9
9
  const objectParams = isObject(params) ? params : {};
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { pathExists, readJsonFile } from '../lib/fs.ts';
3
+ import { pathExists, readJsonFile } from '../lib/fs.js';
4
4
  export const listSessions = async (params, context) => {
5
5
  const objectParams = isObject(params) ? params : {};
6
6
  const agentId = typeof objectParams.agentId === 'string' && objectParams.agentId.trim()
@@ -9,7 +9,7 @@ export const listSessions = async (params, context) => {
9
9
  const items = await listAllAgentSessions(context, agentId);
10
10
  return {
11
11
  count: items.length,
12
- items
12
+ items: items
13
13
  };
14
14
  };
15
15
  export async function listAllAgentSessions(context, agentId) {
@@ -1,8 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
4
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
5
- import { getInstalledSkillsFromCli } from './skills.ts';
3
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
4
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
5
+ import { getInstalledSkillsFromCli } from './skills.js';
6
6
  export const getInstalledSkill = async (params, context) => {
7
7
  const objectParams = isObject(params) ? params : {};
8
8
  const slug = typeof objectParams.slug === 'string' ? objectParams.slug : null;
@@ -1,6 +1,6 @@
1
- import { readJsonFile, writeJsonFile } from '../lib/fs.ts';
2
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
3
- import { getInstalledSkillsFromCli } from './skills.ts';
1
+ import { readJsonFile, writeJsonFile } from '../lib/fs.js';
2
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
3
+ import { getInstalledSkillsFromCli } from './skills.js';
4
4
  import path from 'node:path';
5
5
  /**
6
6
  * 启用或停用 skill
@@ -26,10 +26,11 @@ export const toggleSkill = async (params, context) => {
26
26
  config.skills = {};
27
27
  if (!config.skills.entries)
28
28
  config.skills.entries = {};
29
- if (!config.skills.entries[slug] || typeof config.skills.entries[slug] !== 'object') {
30
- config.skills.entries[slug] = {};
29
+ const skillEntries = config.skills.entries;
30
+ if (!skillEntries[slug] || typeof skillEntries[slug] !== 'object') {
31
+ skillEntries[slug] = {};
31
32
  }
32
- config.skills.entries[slug].enabled = enabled;
33
+ skillEntries[slug].enabled = enabled;
33
34
  if (bundled) {
34
35
  if (!config.skills)
35
36
  config.skills = {};
@@ -47,7 +48,7 @@ export const toggleSkill = async (params, context) => {
47
48
  action: 'enabled',
48
49
  slug,
49
50
  bundled: true,
50
- skillEntry: config.skills.entries[slug],
51
+ skillEntry: skillEntries[slug],
51
52
  allowBundled: config.skills.allowBundled
52
53
  };
53
54
  }
@@ -57,7 +58,7 @@ export const toggleSkill = async (params, context) => {
57
58
  action: 'already_enabled',
58
59
  slug,
59
60
  bundled: true,
60
- skillEntry: config.skills.entries[slug],
61
+ skillEntry: skillEntries[slug],
61
62
  allowBundled: currentAllowBundled
62
63
  };
63
64
  }
@@ -70,7 +71,7 @@ export const toggleSkill = async (params, context) => {
70
71
  action: 'disabled',
71
72
  slug,
72
73
  bundled: true,
73
- skillEntry: config.skills.entries[slug],
74
+ skillEntry: skillEntries[slug],
74
75
  allowBundled: config.skills.allowBundled
75
76
  };
76
77
  }
@@ -80,7 +81,7 @@ export const toggleSkill = async (params, context) => {
80
81
  action: 'already_disabled',
81
82
  slug,
82
83
  bundled: true,
83
- skillEntry: config.skills.entries[slug],
84
+ skillEntry: skillEntries[slug],
84
85
  allowBundled: currentAllowBundled
85
86
  };
86
87
  }
@@ -93,7 +94,7 @@ export const toggleSkill = async (params, context) => {
93
94
  if (!installPath) {
94
95
  const globalSkillPath = path.join(context.openclawRoot, 'skills', slug);
95
96
  const workspaceSkillPath = path.join(context.openclawRoot, 'workspace', '.openclaw', 'skills', slug);
96
- const { pathExists } = await import('../lib/fs.ts');
97
+ const { pathExists } = await import('../lib/fs.js');
97
98
  if (!(await pathExists(globalSkillPath)) && !(await pathExists(workspaceSkillPath))) {
98
99
  throw new JsonRpcException(JSON_RPC_ERRORS.invalidParams, `Skill not installed: ${slug}`);
99
100
  }
@@ -3,8 +3,8 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
- import { ensureDir, pathExists, readJsonFile } from '../lib/fs.ts';
7
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
6
+ import { ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
7
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
8
8
  const execFileAsync = promisify(execFile);
9
9
  export const listInstalledSkills = async (_params, context) => {
10
10
  const items = await getInstalledSkillsFromCli(context);
@@ -121,7 +121,7 @@ export const logs = async (params, context) => {
121
121
  }
122
122
  const limit = 10;
123
123
  const maxBytes = params?.maxBytes ?? 250000;
124
- const offset = undefined;
124
+ let offset = undefined;
125
125
  // 获取所有候选日志的详细信息并排序(对应 ls -t)
126
126
  const fileStats = await Promise.all(logFiles.map(async (file) => {
127
127
  const filePath = path.join(logDir, file);
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import readline from 'node:readline';
4
4
  import { getPluginRuntime } from '../../../index.js';
5
- import { pathExists, readJsonFile } from '../lib/fs.ts';
5
+ import { pathExists, readJsonFile } from '../lib/fs.js';
6
6
  const GATEWAY_USAGE_METHODS = {
7
7
  summary: 'sessions.usage',
8
8
  timeseries: 'sessions.usage.timeseries',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rol-websocket-channel",
3
- "version": "1.2.6",
3
+ "version": "1.3.6",
4
4
  "description": "Unified OpenClaw plugin: MQTT Channel + Admin Bridge for remote management",
5
5
  "license": "MIT",
6
6
  "author": "nixgnehc",
package/src/admin/cli.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { getOpenClawRoot, getProjectRoot } from './lib/paths.ts';
2
- import { getMethod } from './methods/index.ts';
1
+ import { getOpenClawRoot, getProjectRoot } from './lib/paths.js';
2
+ import { getMethod } from './methods/index.js';
3
3
  import {
4
4
  failure,
5
5
  JsonRpcException,
@@ -7,8 +7,8 @@ import {
7
7
  parseRequest,
8
8
  serialize,
9
9
  success
10
- } from './jsonrpc.ts';
11
- import type { JsonRpcId } from './types.ts';
10
+ } from './jsonrpc.js';
11
+ import type { JsonRpcId } from './types.js';
12
12
 
13
13
  async function main(): Promise<void> {
14
14
  const raw = await readStdin();
@@ -4,7 +4,7 @@ import type {
4
4
  JsonRpcRequest,
5
5
  JsonRpcResponse,
6
6
  JsonRpcSuccess
7
- } from './types.ts';
7
+ } from './types.js';
8
8
 
9
9
  export const JSON_RPC_VERSION = '2.0';
10
10
 
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
4
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
 
3
- import { readJsonFile } from '../lib/fs.ts';
4
- import type { JsonValue, MethodHandler } from '../types.ts';
3
+ import { readJsonFile } from '../lib/fs.js';
4
+ import type { JsonValue, MethodHandler } from '../types.js';
5
5
 
6
6
  interface OpenClawConfig {
7
7
  agents?: {
@@ -1,9 +1,9 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
5
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
6
- import type { JsonValue, MethodHandler } from '../types.ts';
4
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
5
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
6
+ import type { JsonValue, MethodHandler } from '../types.js';
7
7
 
8
8
  interface OpenClawConfig {
9
9
  agents?: {
@@ -2,10 +2,10 @@ import { createHash } from 'node:crypto';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
 
5
- import { ensureDir, pathExists, readJsonFile } from '../lib/fs.ts';
6
- import { ensureInside } from '../lib/paths.ts';
7
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
8
- import type { JsonValue, MethodContext, MethodHandler } from '../types.ts';
5
+ import { ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
6
+ import { ensureInside } from '../lib/paths.js';
7
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
8
+ import type { JsonValue, MethodContext, MethodHandler } from '../types.js';
9
9
 
10
10
  type ArtifactCategory =
11
11
  | 'image'
@@ -1,7 +1,7 @@
1
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
2
- import type { MethodHandler } from '../types.ts';
3
- import { getAgents, getConfig } from './admin.ts';
4
- import { createAgent, deleteAgent, listAgents, updateAgent } from './agents-extended.ts';
1
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
2
+ import type { MethodHandler } from '../types.js';
3
+ import { getAgents, getConfig } from './admin.js';
4
+ import { createAgent, deleteAgent, listAgents, updateAgent } from './agents-extended.js';
5
5
  import {
6
6
  createArtifactRecord,
7
7
  ensureArtifactUploaded,
@@ -10,7 +10,7 @@ import {
10
10
  listArtifacts,
11
11
  markArtifactUploaded,
12
12
  refreshArtifacts
13
- } from './artifacts.ts';
13
+ } from './artifacts.js';
14
14
  import {
15
15
  addCron,
16
16
  disableCron,
@@ -25,7 +25,7 @@ import {
25
25
  setCronContent,
26
26
  updateCronMessage,
27
27
  updateCronSystemEvent
28
- } from './cron.ts';
28
+ } from './cron.js';
29
29
  import {
30
30
  backupMemory,
31
31
  createMemoryBackupRecord,
@@ -34,27 +34,27 @@ import {
34
34
  getMemoryFile,
35
35
  importMemoryZip,
36
36
  listMemoryFiles
37
- } from './memory.ts';
38
- import { getMem9Config, installMem9, reconnectMem9 } from './mem9.ts';
39
- import { getModels } from './models.ts';
40
- import { setModel, updateModels } from './models-extended.ts';
41
- import { listSessions } from './sessions.ts';
42
- import { getSession, prepareMessage, attachSkill } from './sessions-extended.ts';
37
+ } from './memory.js';
38
+ import { getMem9Config, installMem9, reconnectMem9 } from './mem9.js';
39
+ import { getModels } from './models.js';
40
+ import { setModel, updateModels } from './models-extended.js';
41
+ import { listSessions } from './sessions.js';
42
+ import { getSession, prepareMessage, attachSkill } from './sessions-extended.js';
43
43
  import {
44
44
  installSkillFromClawHub,
45
45
  installSkillFromNpm,
46
46
  listInstalledSkills,
47
47
  searchClawHubSkills,
48
48
  updateSkillFromClawHub
49
- } from './skills.ts';
50
- import { getInstalledSkill, uninstallSkill } from './skills-extended.ts';
51
- import { ping, restart, stop, doctorFix, logs } from './system.ts';
49
+ } from './skills.js';
50
+ import { getInstalledSkill, uninstallSkill } from './skills-extended.js';
51
+ import { ping, restart, stop, doctorFix, logs } from './system.js';
52
52
  import {
53
53
  getUsageBreakdown,
54
54
  getUsagePageSummary,
55
55
  getUsageSummary,
56
56
  getUsageTimeseries
57
- } from './usage.ts';
57
+ } from './usage.js';
58
58
 
59
59
  const methods = new Map<string, MethodHandler>([
60
60
  // System
@@ -140,7 +140,7 @@ const methods = new Map<string, MethodHandler>([
140
140
  ['mem9.install', installMem9],
141
141
  ['mem9.getConfig', getMem9Config],
142
142
  ['mem9.reconnect', reconnectMem9]
143
- ]);
143
+ ] as [string, MethodHandler][]);
144
144
 
145
145
  export function getMethod(methodName: string): MethodHandler {
146
146
  const handler = methods.get(methodName);
@@ -2,9 +2,9 @@ import { execFile } from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import { promisify } from 'node:util';
4
4
 
5
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
6
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
7
- import type { JsonValue, MethodContext } from '../types.ts';
5
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
6
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
7
+ import type { JsonValue, MethodContext } from '../types.js';
8
8
 
9
9
  const execFileAsync = promisify(execFile);
10
10
 
@@ -4,10 +4,10 @@ import os from 'node:os';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
6
 
7
- import { copyIfExists, ensureDir, pathExists } from '../lib/fs.ts';
8
- import { ensureInside } from '../lib/paths.ts';
9
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
10
- import type { JsonValue, MethodHandler } from '../types.ts';
7
+ import { copyIfExists, ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
8
+ import { ensureInside } from '../lib/paths.js';
9
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
10
+ import type { JsonValue, MethodHandler } from '../types.js';
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
 
@@ -359,7 +359,7 @@ async function postJson(
359
359
  url: string,
360
360
  body: Record<string, JsonValue>,
361
361
  authToken?: string
362
- ): Promise<unknown> {
362
+ ): Promise<JsonValue> {
363
363
  const headers: Record<string, string> = {
364
364
  'Content-Type': 'application/json'
365
365
  };
@@ -374,7 +374,7 @@ async function postJson(
374
374
  body: JSON.stringify(body)
375
375
  });
376
376
 
377
- const payload = await response.json().catch(async () => await response.text());
377
+ const payload = await response.json().catch(async () => await response.text()) as JsonValue;
378
378
  if (!response.ok) {
379
379
  throw new JsonRpcException(
380
380
  JSON_RPC_ERRORS.internalError,
@@ -390,6 +390,10 @@ async function postJson(
390
390
  return payload;
391
391
  }
392
392
 
393
+ function isObject(value: unknown): value is Record<string, JsonValue> {
394
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
395
+ }
396
+
393
397
  async function zipDirectory(sourceDir: string, zipPath: string): Promise<void> {
394
398
  await fs.rm(zipPath, { force: true });
395
399
 
@@ -1,8 +1,8 @@
1
1
  import path from 'node:path';
2
2
 
3
- import { readJsonFile, writeJsonFile } from '../lib/fs.ts';
4
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
5
- import type { JsonValue, MethodHandler } from '../types.ts';
3
+ import { readJsonFile, writeJsonFile } from '../lib/fs.js';
4
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
5
+ import type { JsonValue, MethodHandler } from '../types.js';
6
6
 
7
7
  interface OpenClawConfig {
8
8
  models?: {
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
 
3
- import { readJsonFile } from '../lib/fs.ts';
4
- import type { JsonValue, MethodHandler } from '../types.ts';
3
+ import { readJsonFile } from '../lib/fs.js';
4
+ import type { JsonValue, MethodHandler } from '../types.js';
5
5
 
6
6
  interface OpenClawConfig {
7
7
  models?: {
@@ -2,9 +2,9 @@ import { execFile } from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import { promisify } from 'node:util';
4
4
 
5
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
6
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
7
- import type { JsonValue, MethodContext } from '../types.ts';
5
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
6
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
7
+ import type { JsonValue, MethodContext } from '../types.js';
8
8
 
9
9
  const execFileAsync = promisify(execFile);
10
10
 
@@ -2,10 +2,10 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import readline from 'node:readline';
4
4
 
5
- import { pathExists, readJsonFile } from '../lib/fs.ts';
6
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
7
- import type { JsonValue, MethodContext, MethodHandler } from '../types.ts';
8
- import { findSessionRecord } from './sessions.ts';
5
+ import { pathExists, readJsonFile } from '../lib/fs.js';
6
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
7
+ import type { JsonValue, MethodContext, MethodHandler } from '../types.js';
8
+ import { findSessionRecord } from './sessions.js';
9
9
 
10
10
  interface SessionMessage {
11
11
  role: string;
@@ -1,8 +1,8 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- import { pathExists, readJsonFile } from '../lib/fs.ts';
5
- import type { JsonValue, MethodContext, MethodHandler } from '../types.ts';
4
+ import { pathExists, readJsonFile } from '../lib/fs.js';
5
+ import type { JsonValue, MethodContext, MethodHandler } from '../types.js';
6
6
 
7
7
  interface SessionsIndexEntry {
8
8
  sessionId?: string;
@@ -52,7 +52,7 @@ export const listSessions: MethodHandler = async (
52
52
  const items = await listAllAgentSessions(context, agentId);
53
53
  return {
54
54
  count: items.length,
55
- items
55
+ items: items as unknown as JsonValue
56
56
  };
57
57
  };
58
58
 
@@ -1,10 +1,10 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
 
4
- import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
5
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
6
- import type { JsonValue, MethodContext, MethodHandler } from '../types.ts';
7
- import { getInstalledSkillsFromCli } from './skills.ts';
4
+ import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.js';
5
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
6
+ import type { JsonValue, MethodContext, MethodHandler } from '../types.js';
7
+ import { getInstalledSkillsFromCli } from './skills.js';
8
8
 
9
9
  interface OpenClawConfig {
10
10
  agents?: {
@@ -1,7 +1,7 @@
1
- import { readJsonFile, writeJsonFile } from '../lib/fs.ts';
2
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
3
- import type { JsonValue, MethodHandler } from '../types.ts';
4
- import { getInstalledSkillsFromCli } from './skills.ts';
1
+ import { readJsonFile, writeJsonFile } from '../lib/fs.js';
2
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
3
+ import type { JsonValue, MethodHandler } from '../types.js';
4
+ import { getInstalledSkillsFromCli } from './skills.js';
5
5
  import path from 'node:path';
6
6
 
7
7
  interface OpenClawConfig {
@@ -64,10 +64,11 @@ export const toggleSkill: MethodHandler = async (
64
64
 
65
65
  if (!config.skills) config.skills = {};
66
66
  if (!config.skills.entries) config.skills.entries = {};
67
- if (!config.skills.entries[slug] || typeof config.skills.entries[slug] !== 'object') {
68
- config.skills.entries[slug] = {};
67
+ const skillEntries = config.skills.entries;
68
+ if (!skillEntries[slug] || typeof skillEntries[slug] !== 'object') {
69
+ skillEntries[slug] = {};
69
70
  }
70
- config.skills.entries[slug].enabled = enabled;
71
+ skillEntries[slug].enabled = enabled;
71
72
 
72
73
  if (bundled) {
73
74
  if (!config.skills) config.skills = {};
@@ -86,7 +87,7 @@ export const toggleSkill: MethodHandler = async (
86
87
  action: 'enabled',
87
88
  slug,
88
89
  bundled: true,
89
- skillEntry: config.skills.entries[slug],
90
+ skillEntry: skillEntries[slug],
90
91
  allowBundled: config.skills.allowBundled
91
92
  };
92
93
  }
@@ -97,7 +98,7 @@ export const toggleSkill: MethodHandler = async (
97
98
  action: 'already_enabled',
98
99
  slug,
99
100
  bundled: true,
100
- skillEntry: config.skills.entries[slug],
101
+ skillEntry: skillEntries[slug],
101
102
  allowBundled: currentAllowBundled
102
103
  };
103
104
  }
@@ -111,7 +112,7 @@ export const toggleSkill: MethodHandler = async (
111
112
  action: 'disabled',
112
113
  slug,
113
114
  bundled: true,
114
- skillEntry: config.skills.entries[slug],
115
+ skillEntry: skillEntries[slug],
115
116
  allowBundled: config.skills.allowBundled
116
117
  };
117
118
  }
@@ -122,7 +123,7 @@ export const toggleSkill: MethodHandler = async (
122
123
  action: 'already_disabled',
123
124
  slug,
124
125
  bundled: true,
125
- skillEntry: config.skills.entries[slug],
126
+ skillEntry: skillEntries[slug],
126
127
  allowBundled: currentAllowBundled
127
128
  };
128
129
  }
@@ -136,7 +137,7 @@ export const toggleSkill: MethodHandler = async (
136
137
  if (!installPath) {
137
138
  const globalSkillPath = path.join(context.openclawRoot, 'skills', slug);
138
139
  const workspaceSkillPath = path.join(context.openclawRoot, 'workspace', '.openclaw', 'skills', slug);
139
- const { pathExists } = await import('../lib/fs.ts');
140
+ const { pathExists } = await import('../lib/fs.js');
140
141
  if (!(await pathExists(globalSkillPath)) && !(await pathExists(workspaceSkillPath))) {
141
142
  throw new JsonRpcException(
142
143
  JSON_RPC_ERRORS.invalidParams,
@@ -4,9 +4,9 @@ import path from 'node:path';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
6
 
7
- import { ensureDir, pathExists, readJsonFile } from '../lib/fs.ts';
8
- import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
9
- import type { JsonValue, MethodContext, MethodHandler } from '../types.ts';
7
+ import { ensureDir, pathExists, readJsonFile } from '../lib/fs.js';
8
+ import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.js';
9
+ import type { JsonValue, MethodContext, MethodHandler } from '../types.js';
10
10
 
11
11
  const execFileAsync = promisify(execFile);
12
12
 
@@ -17,7 +17,7 @@ interface SkillManifest {
17
17
  description?: string;
18
18
  author?: string;
19
19
  tags?: string[];
20
- [key: string]: JsonValue | undefined;
20
+ [key: string]: any;
21
21
  }
22
22
 
23
23
  interface InstallSkillParams {
@@ -50,16 +50,16 @@ interface OpenClawConfig {
50
50
  agents?: {
51
51
  defaults?: {
52
52
  skills?: string[];
53
- [key: string]: JsonValue | undefined;
53
+ [key: string]: any;
54
54
  };
55
- [key: string]: JsonValue | undefined;
55
+ [key: string]: any;
56
56
  };
57
57
  skills?: {
58
58
  allowBundled?: string[];
59
- entries?: Record<string, { enabled?: boolean; [key: string]: JsonValue | undefined }>;
60
- [key: string]: JsonValue | undefined;
59
+ entries?: Record<string, { enabled?: boolean; [key: string]: any }>;
60
+ [key: string]: any;
61
61
  };
62
- [key: string]: JsonValue | undefined;
62
+ [key: string]: any;
63
63
  }
64
64
 
65
65
  interface CustomInstalledSkill {
@@ -432,7 +432,7 @@ function normalizeCliSkill(
432
432
  ): Record<string, JsonValue> {
433
433
  if (!isRecord(skill)) {
434
434
  return {
435
- raw: skill
435
+ raw: skill as JsonValue
436
436
  };
437
437
  }
438
438
 
@@ -588,7 +588,7 @@ function mergeSkillSources(
588
588
  merged.set(custom.slug, custom as unknown as JsonValue);
589
589
  }
590
590
 
591
- return Array.from(merged.values()).sort((a, b) => {
591
+ return Array.from(merged.values()).sort((a: unknown, b: unknown) => {
592
592
  const aSlug = isRecord(a) && typeof a.slug === 'string' ? a.slug : '';
593
593
  const bSlug = isRecord(b) && typeof b.slug === 'string' ? b.slug : '';
594
594
  return aSlug.localeCompare(bSlug);
@@ -2,7 +2,7 @@ import { exec } from 'node:child_process';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { promisify } from 'node:util';
5
- import type { JsonValue, MethodHandler, MethodContext } from '../types.ts';
5
+ import type { JsonValue, MethodHandler, MethodContext } from '../types.js';
6
6
 
7
7
  const execAsync = promisify(exec);
8
8
 
@@ -138,7 +138,7 @@ export const logs: MethodHandler = async (params: any, context: MethodContext):
138
138
 
139
139
  const limit = 10;
140
140
  const maxBytes = params?.maxBytes ?? 250000;
141
- const offset = undefined;
141
+ let offset: number | undefined = undefined;
142
142
 
143
143
  // 获取所有候选日志的详细信息并排序(对应 ls -t)
144
144
  const fileStats = await Promise.all(
@@ -3,12 +3,13 @@ import path from 'node:path';
3
3
  import readline from 'node:readline';
4
4
 
5
5
  import { getPluginRuntime } from '../../../index.js';
6
- import { pathExists, readJsonFile } from '../lib/fs.ts';
7
- import { resolveSessionFile } from './sessions.ts';
8
- import type { JsonValue, MethodHandler, MethodContext } from '../types.ts';
6
+ import { pathExists, readJsonFile } from '../lib/fs.js';
7
+ import { resolveSessionFile } from './sessions.js';
8
+ import type { JsonValue, MethodHandler, MethodContext } from '../types.js';
9
9
 
10
10
  interface SessionsIndexEntry {
11
11
  sessionId?: string;
12
+ updatedAt?: number;
12
13
  inputTokens?: number;
13
14
  outputTokens?: number;
14
15
  totalTokens?: number;
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
+ "lib": ["ES2021"],
4
5
  "module": "ESNext",
5
6
  "moduleResolution": "node",
6
7
  "strict": true,