mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
chore(plugins): remove opik investigation checkpoints
This commit is contained in:
@@ -2835,11 +2835,6 @@ export async function runEmbeddedAttempt(
|
||||
);
|
||||
}
|
||||
|
||||
if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") {
|
||||
log.warn(
|
||||
`[hooks][checkpoints] attempt llm_input runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("llm_input") === true}`,
|
||||
);
|
||||
}
|
||||
if (hookRunner?.hasHooks("llm_input")) {
|
||||
hookRunner
|
||||
.runLlmInput(
|
||||
@@ -3112,11 +3107,6 @@ export async function runEmbeddedAttempt(
|
||||
// Run agent_end hooks to allow plugins to analyze the conversation
|
||||
// This is fire-and-forget, so we don't await
|
||||
// Run even on compaction timeout so plugins can log/cleanup
|
||||
if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") {
|
||||
log.warn(
|
||||
`[hooks][checkpoints] attempt agent_end runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("agent_end") === true}`,
|
||||
);
|
||||
}
|
||||
if (hookRunner?.hasHooks("agent_end")) {
|
||||
hookRunner
|
||||
.runAgentEnd(
|
||||
@@ -3176,11 +3166,6 @@ export async function runEmbeddedAttempt(
|
||||
)
|
||||
.map((entry) => ({ toolName: entry.toolName, meta: entry.meta }));
|
||||
|
||||
if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") {
|
||||
log.warn(
|
||||
`[hooks][checkpoints] attempt llm_output runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("llm_output") === true}`,
|
||||
);
|
||||
}
|
||||
if (hookRunner?.hasHooks("llm_output")) {
|
||||
hookRunner
|
||||
.runLlmOutput(
|
||||
|
||||
@@ -13,16 +13,16 @@ vi.mock("../plugins/runtime.js", () => ({
|
||||
getActivePluginRegistryKey: hoisted.getActivePluginRegistryKey,
|
||||
}));
|
||||
|
||||
const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js");
|
||||
|
||||
describe("ensureRuntimePluginsLoaded", () => {
|
||||
beforeEach(() => {
|
||||
hoisted.loadOpenClawPlugins.mockReset();
|
||||
hoisted.getActivePluginRegistryKey.mockReset();
|
||||
hoisted.getActivePluginRegistryKey.mockReturnValue(null);
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("does not reactivate plugins when a process already has an active registry", () => {
|
||||
it("does not reactivate plugins when a process already has an active registry", async () => {
|
||||
const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js");
|
||||
hoisted.getActivePluginRegistryKey.mockReturnValue("gateway-registry");
|
||||
|
||||
ensureRuntimePluginsLoaded({
|
||||
@@ -34,7 +34,9 @@ describe("ensureRuntimePluginsLoaded", () => {
|
||||
expect(hoisted.loadOpenClawPlugins).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("loads runtime plugins when no active registry exists", () => {
|
||||
it("loads runtime plugins when no active registry exists", async () => {
|
||||
const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js");
|
||||
|
||||
ensureRuntimePluginsLoaded({
|
||||
config: {} as never,
|
||||
workspaceDir: "/tmp/workspace",
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
|
||||
const diagnosticCheckpointLogsEnabled = process.env.OPENCLAW_DIAGNOSTIC_CHECKPOINTS === "1";
|
||||
|
||||
export type DiagnosticSessionState = "idle" | "processing" | "waiting";
|
||||
|
||||
type DiagnosticBaseEvent = {
|
||||
@@ -208,11 +206,6 @@ export function emitDiagnosticEvent(event: DiagnosticEventInput) {
|
||||
seq: (state.seq += 1),
|
||||
ts: Date.now(),
|
||||
} satisfies DiagnosticEventPayload;
|
||||
if (diagnosticCheckpointLogsEnabled) {
|
||||
console.warn(
|
||||
`[diagnostic-events][checkpoints] emit type=${enriched.type} seq=${enriched.seq} listeners=${state.listeners.size}${"sessionKey" in enriched && typeof enriched.sessionKey === "string" ? ` sessionKey=${enriched.sessionKey}` : ""}`,
|
||||
);
|
||||
}
|
||||
state.dispatchDepth += 1;
|
||||
for (const listener of state.listeners) {
|
||||
try {
|
||||
@@ -236,16 +229,8 @@ export function emitDiagnosticEvent(event: DiagnosticEventInput) {
|
||||
export function onDiagnosticEvent(listener: (evt: DiagnosticEventPayload) => void): () => void {
|
||||
const state = getDiagnosticEventsState();
|
||||
state.listeners.add(listener);
|
||||
if (diagnosticCheckpointLogsEnabled) {
|
||||
console.warn(`[diagnostic-events][checkpoints] subscribe listeners=${state.listeners.size}`);
|
||||
}
|
||||
return () => {
|
||||
state.listeners.delete(listener);
|
||||
if (diagnosticCheckpointLogsEnabled) {
|
||||
console.warn(
|
||||
`[diagnostic-events][checkpoints] unsubscribe listeners=${state.listeners.size}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,6 @@ function getHooksForNameAndPlugin<K extends PluginHookName>(
|
||||
export function createHookRunner(registry: PluginRegistry, options: HookRunnerOptions = {}) {
|
||||
const logger = options.logger;
|
||||
const catchErrors = options.catchErrors ?? true;
|
||||
const hookCheckpointLogsEnabled = process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1";
|
||||
|
||||
const mergeBeforeModelResolve = (
|
||||
acc: PluginHookBeforeModelResolveResult | undefined,
|
||||
@@ -251,17 +250,9 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
|
||||
}
|
||||
|
||||
logger?.debug?.(`[hooks] running ${hookName} (${hooks.length} handlers)`);
|
||||
if (hookCheckpointLogsEnabled) {
|
||||
logger?.warn(
|
||||
`[hooks][checkpoints] dispatch ${hookName} handlers=${hooks.map((hook) => hook.pluginId).join(",")}`,
|
||||
);
|
||||
}
|
||||
|
||||
const promises = hooks.map(async (hook) => {
|
||||
try {
|
||||
if (hookCheckpointLogsEnabled) {
|
||||
logger?.warn(`[hooks][checkpoints] invoke ${hookName} plugin=${hook.pluginId}`);
|
||||
}
|
||||
await (hook.handler as (event: unknown, ctx: unknown) => Promise<void>)(event, ctx);
|
||||
} catch (err) {
|
||||
handleHookError({ hookName, pluginId: hook.pluginId, error: err });
|
||||
|
||||
@@ -28,16 +28,6 @@ const state: RegistryState = (() => {
|
||||
})();
|
||||
|
||||
export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) {
|
||||
if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") {
|
||||
const stack = new Error().stack
|
||||
?.split("\n")
|
||||
.slice(2, 5)
|
||||
.map((line) => line.trim())
|
||||
.join(" | ");
|
||||
console.warn(
|
||||
`[plugins][checkpoints] activate registry key=${cacheKey ?? "none"} plugins=${registry.plugins.length} typedHooks=${registry.typedHooks.length}${stack ? ` caller=${stack}` : ""}`,
|
||||
);
|
||||
}
|
||||
state.registry = registry;
|
||||
if (!state.httpRouteRegistryPinned) {
|
||||
state.httpRouteRegistry = registry;
|
||||
|
||||
@@ -5,8 +5,6 @@ import type { PluginRegistry } from "./registry.js";
|
||||
import type { OpenClawPluginServiceContext, PluginLogger } from "./types.js";
|
||||
|
||||
const log = createSubsystemLogger("plugins");
|
||||
const pluginCheckpointLogsEnabled = process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1";
|
||||
|
||||
function createPluginLogger(): PluginLogger {
|
||||
return {
|
||||
info: (msg) => log.info(msg),
|
||||
@@ -48,18 +46,8 @@ export async function startPluginServices(params: {
|
||||
|
||||
for (const entry of params.registry.services) {
|
||||
const service = entry.service;
|
||||
const typedHookCountBefore = params.registry.typedHooks.length;
|
||||
try {
|
||||
await service.start(serviceContext);
|
||||
if (pluginCheckpointLogsEnabled) {
|
||||
const newTypedHooks = params.registry.typedHooks
|
||||
.slice(typedHookCountBefore)
|
||||
.filter((hook) => hook.pluginId === entry.pluginId)
|
||||
.map((hook) => hook.hookName);
|
||||
log.warn(
|
||||
`[plugins][checkpoints] service started (${service.id}, plugin=${entry.pluginId}) typedHooksAdded=${newTypedHooks.length}${newTypedHooks.length > 0 ? ` hooks=${newTypedHooks.join(",")}` : ""}`,
|
||||
);
|
||||
}
|
||||
running.push({
|
||||
id: service.id,
|
||||
stop: service.stop ? () => service.stop?.(serviceContext) : undefined,
|
||||
|
||||
Reference in New Issue
Block a user