mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-12 12:06:20 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* Build an import URL for a hook handler module.
|
|
*
|
|
* Bundled hooks (shipped in dist/) are immutable between installs, so they
|
|
* can be imported without a cache-busting suffix — letting V8 reuse its
|
|
* module cache across gateway restarts.
|
|
*
|
|
* Workspace, managed, and plugin hooks may be edited by the user between
|
|
* restarts. For those we append `?t=<mtime>&s=<size>` so the module key
|
|
* reflects on-disk changes while staying stable for unchanged files.
|
|
*/
|
|
|
|
import fs from "node:fs";
|
|
import { pathToFileURL } from "node:url";
|
|
import type { HookSource } from "./types.js";
|
|
|
|
/**
|
|
* Sources whose handler files never change between `npm install` runs.
|
|
* Imports from these sources skip cache busting entirely.
|
|
*/
|
|
const IMMUTABLE_SOURCES: ReadonlySet<HookSource> = new Set(["openclaw-bundled"]);
|
|
|
|
export function buildImportUrl(handlerPath: string, source: HookSource): string {
|
|
const base = pathToFileURL(handlerPath).href;
|
|
|
|
if (IMMUTABLE_SOURCES.has(source)) {
|
|
return base;
|
|
}
|
|
|
|
// Use file metadata so the cache key only changes when the file changes
|
|
try {
|
|
const { mtimeMs, size } = fs.statSync(handlerPath);
|
|
return `${base}?t=${mtimeMs}&s=${size}`;
|
|
} catch {
|
|
// If stat fails (unlikely), fall back to Date.now() to guarantee freshness
|
|
return `${base}?t=${Date.now()}`;
|
|
}
|
|
}
|