diff --git a/extensions/remote-control/buffer/writer.ts b/extensions/remote-control/buffer/writer.ts index 2ed726d..ac6a25b 100644 --- a/extensions/remote-control/buffer/writer.ts +++ b/extensions/remote-control/buffer/writer.ts @@ -17,6 +17,7 @@ */ import fs from "node:fs/promises"; +import type { Dirent } from "node:fs"; import os from "node:os"; import path from "node:path"; import type { SeqNum } from "../sequence.js"; @@ -165,7 +166,7 @@ export async function cleanupIdleBuffers( const maxIdleMs = cfg.idleDays * 24 * 60 * 60 * 1000; const deleted: string[] = []; - let entries: fs.Dirent[] = []; + let entries: Dirent[] = []; try { entries = await fs.readdir(dir, { withFileTypes: true }); } catch { diff --git a/extensions/remote-control/messages.ts b/extensions/remote-control/messages.ts index 975b362..bb7e392 100644 --- a/extensions/remote-control/messages.ts +++ b/extensions/remote-control/messages.ts @@ -58,8 +58,8 @@ export function serializeMessage( const toolCalls = (msg.content as RawContent[]) .filter((c) => c.type === "toolCall") .map((c) => ({ - id: c.id, - name: c.name, + id: c.id ?? "", + name: c.name ?? "", args: JSON.stringify(c.arguments, null, 2), })); return { diff --git a/package-lock.json b/package-lock.json index 34ad1e7..be73810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,8 @@ "devDependencies": { "@biomejs/biome": "^2.4.12", "@types/qrcode": "^1.5.6", - "husky": "^9.1.7" + "husky": "^9.1.7", + "typescript": "^6.0.3" }, "peerDependencies": { "@earendil-works/pi-coding-agent": "*", @@ -3970,6 +3971,20 @@ "license": "MIT", "peer": true }, + "node_modules/typescript": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uint8array-extras": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.5.0.tgz", diff --git a/package.json b/package.json index 5ef2b51..b4fe2dd 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "pi-remote-control", + "type": "module", "version": "1.0.0", "description": "Expose a running pi session over HTTP/WebSocket — view and interact from any browser on your network.", "keywords": [ @@ -18,6 +19,7 @@ "lint": "biome check --write .", "lint:check": "biome check .", "prepare": "node .husky/install.mjs", + "typecheck": "tsc --noEmit", "smoke": "node --test scripts/smoke/smoke.mjs", "smoke:stream": "node --test scripts/smoke/stream.test.mjs", "smoke:all": "node --test scripts/smoke/smoke.mjs scripts/smoke/stream.test.mjs" @@ -25,6 +27,7 @@ "devDependencies": { "@biomejs/biome": "^2.4.12", "@types/qrcode": "^1.5.6", - "husky": "^9.1.7" + "husky": "^9.1.7", + "typescript": "^6.0.3" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4eb457b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,43 @@ +{ + "compilerOptions": { + // Simulate pi's TypeScript runtime environment + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["ES2022"], + + // Type-check only, no emit — pi handles the actual transpilation + "noEmit": true, + "strict": true, + "exactOptionalPropertyTypes": false, + + // Resolve peer deps from pi's global node_modules + "baseUrl": ".", + "paths": { + "@earendil-works/pi-coding-agent": [ + "../../../../../../usr/local/lib/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts" + ], + "@earendil-works/pi-tui": [ + "../../../../../../usr/local/lib/node_modules/@earendil-works/pi-tui/dist/index.d.ts" + ] + }, + "typeRoots": [ + "./node_modules/@types", + "/usr/local/lib/node_modules/@types" + ], + + // Project uses .js extensions in imports (NodeNext convention) + "allowImportingTsExtensions": false, + + // Relax some checks that are impractical without the real pi runtime + "skipLibCheck": true, + "ignoreDeprecations": "6.0" + }, + "include": [ + "extensions/remote-control/**/*.ts" + ], + "exclude": [ + "node_modules", + "build" + ] +}