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,