mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:41:24 +00:00
feat(plugins): expose llm input/output hook payloads (openclaw#16724) thanks @SecondThread
Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: SecondThread <18317476+SecondThread@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -97,15 +97,18 @@ export async function resolveControlUiDistIndexPath(
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const pkgJsonPath = path.join(dir, "package.json");
|
||||
const indexPath = path.join(dir, "dist", "control-ui", "index.html");
|
||||
if (fs.existsSync(pkgJsonPath) && fs.existsSync(indexPath)) {
|
||||
if (fs.existsSync(pkgJsonPath)) {
|
||||
try {
|
||||
const raw = fs.readFileSync(pkgJsonPath, "utf-8");
|
||||
const parsed = JSON.parse(raw) as { name?: unknown };
|
||||
if (parsed.name === "openclaw") {
|
||||
return indexPath;
|
||||
return fs.existsSync(indexPath) ? indexPath : null;
|
||||
}
|
||||
// Stop at the first package boundary to avoid resolving through unrelated ancestors.
|
||||
return null;
|
||||
} catch {
|
||||
// Invalid package.json, continue searching
|
||||
// Invalid package.json at package boundary; abort fallback resolution.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const parent = path.dirname(dir);
|
||||
|
||||
@@ -22,6 +22,13 @@ export type DiagnosticUsageEvent = DiagnosticBaseEvent & {
|
||||
promptTokens?: number;
|
||||
total?: number;
|
||||
};
|
||||
lastCallUsage?: {
|
||||
input?: number;
|
||||
output?: number;
|
||||
cacheRead?: number;
|
||||
cacheWrite?: number;
|
||||
total?: number;
|
||||
};
|
||||
context?: {
|
||||
limit?: number;
|
||||
used?: number;
|
||||
|
||||
Reference in New Issue
Block a user