From 64dae38e9c9bb95a574c794c6e27ca3f7136f831 Mon Sep 17 00:00:00 2001 From: "Alice (OpenClaw)" Date: Thu, 14 May 2026 10:49:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20make=20npm=20test=20and=20typecheck=20ru?= =?UTF-8?q?nnable=20/=20=E4=BF=AE=E6=AD=A3=20npm=20test=20=E8=88=87=20type?= =?UTF-8?q?check=20=E5=8F=AF=E7=9B=B4=E6=8E=A5=E5=9F=B7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/config.ts | 14 +++++++++++++- src/node-shims.d.ts | 8 ++++++++ tsconfig.json | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4564a0e..d0091c2 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "refresh:openclawtest": "bash ./scripts/refresh-openclawtest-poc.sh", "rollback:openclawtest": "bash ./scripts/rollback-openclaw-poc-patch.sh /home/openclawtest/.nvm/versions/node/v22.22.2/lib/node_modules/openclaw/dist", "verify:openclawtest": "bash ./scripts/verify-openclaw-poc.sh /home/openclawtest/.openclaw /home/openclawtest/.nvm/versions/node/v22.22.2/lib/node_modules/openclaw/dist", - "test": "tsx --test tests/**/*.test.mjs", - "typecheck": "tsc --noEmit" + "test": "npx -p tsx@4.20.6 -p typescript@5.9.3 tsx --test tests/**/*.test.mjs", + "typecheck": "npx -p typescript@5.9.3 tsc --noEmit" }, "devDependencies": { "tsx": "^4.20.6", diff --git a/src/config.ts b/src/config.ts index 6404dd5..eab7015 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,17 @@ import type { ReplyEndChoice } from "./types.js" -import config from "../config/reply-end-controls.json" +import fs from "node:fs" +import path from "node:path" +import { fileURLToPath } from "node:url" + +const currentDir = path.dirname(fileURLToPath(import.meta.url)) +const configPath = path.join(currentDir, "..", "config", "reply-end-controls.json") +const config = JSON.parse(fs.readFileSync(configPath, "utf-8")) as { + callbacks: Record + labels: Record + resolvedLabels: Record + ack: Record + stopPolicyText: string +} export const REPLY_END_CALLBACKS = config.callbacks as Record diff --git a/src/node-shims.d.ts b/src/node-shims.d.ts index f116cf5..c086a4a 100644 --- a/src/node-shims.d.ts +++ b/src/node-shims.d.ts @@ -7,3 +7,11 @@ declare module "node:path" { const path: any export default path } + +declare module "node:url" { + export function fileURLToPath(url: string | URL): string +} + +interface ImportMeta { + url: string +} diff --git a/tsconfig.json b/tsconfig.json index 0eade3b..317b5dd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,8 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, + "allowImportingTsExtensions": true, + "resolveJsonModule": true, "noEmit": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true,