feat(logging): add usage logging hooks for AI stack monitoring

- Add usage-logging hook that sends events to log-ingest service
- Track session start/end, tool calls, and token usage
- Integrate with LOG_INGEST_URL environment variable
- Update hooks index to include usage-logging
This commit is contained in:
2026-01-10 14:20:32 +01:00
parent 7c7f974e2e
commit 2ffc72f6f8
4 changed files with 240 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import {
createStartWorkHook,
createSisyphusOrchestratorHook,
createPrometheusMdOnlyHook,
createUsageLoggingHook,
} from "./hooks";
import {
contextCollector,
@@ -212,6 +213,13 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
? createPrometheusMdOnlyHook(ctx)
: null;
const usageLogging = isHookEnabled("usage-logging")
? createUsageLoggingHook({
stackName: process.env.STACK_NAME,
ingestUrl: process.env.LOG_INGEST_URL,
})
: null;
const taskResumeInfo = createTaskResumeInfoHook();
const backgroundManager = new BackgroundManager(ctx);
@@ -411,6 +419,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
await interactiveBashSession?.event(input);
await ralphLoop?.event(input);
await sisyphusOrchestrator?.handler(input);
await usageLogging?.event(input);
const { event } = input;
const props = event.properties as Record<string, unknown> | undefined;