feat: shadow produce code agent kafka events

This commit is contained in:
lyon1998
2026-06-28 19:51:36 +08:00
parent 2338e8520f
commit fc7fc23f4e
4 changed files with 204 additions and 0 deletions
+8
View File
@@ -21,6 +21,7 @@ import { scheduleWorkbenchProjectionFinalizer } from "./workbench-projection-fin
import { writeWorkbenchProjectionSession, writeWorkbenchSessionAdmissionFact } from "./workbench-projection-writer.ts";
import { buildAgentRunProjectionEventsFetchPlan } from "./workbench-projection-cursor.ts";
import { createWorkbenchReadModel } from "./workbench-read-model.ts";
import { publishHwlabAgentRunCommandShadow } from "./kafka-shadow-producer.ts";
import { codeAgentOtelTraceFields, emitCodeAgentOtelSpan } from "./otel-trace.ts";
import {
firstHeaderValue,
@@ -946,6 +947,13 @@ async function submitCodeAgentChatTurn({ params, options, traceId }) {
});
if (isCodeAgentResultCanceled(results.get(traceId))) return;
const owned = annotateOwner(withCodeAgentBillingReservation(payload, dispatchParams), dispatchParams);
publishHwlabAgentRunCommandShadow({
params: dispatchParams,
payload: owned,
traceId,
lifecycle: codeAgentTurnLifecycleFields(traceId, dispatchParams),
env: executionOptions.env ?? process.env
});
await recordCodeAgentSessionOwner({ payload: owned, params: dispatchParams, options: executionOptions, status: "running" });
results.set(traceId, owned);
scheduleAgentRunProjectionSync({ traceId, params: dispatchParams, options: executionOptions, traceStore, currentResult: owned });