mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
|
|
import type { DiagnosticTraceContext } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
import { wrapStreamFnWithDiagnosticModelCallEvents } from "../../../../src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.js";
|
|
|
|
export function runModelCallAndCaptureTraceparent(params: {
|
|
trace: DiagnosticTraceContext;
|
|
runId: string;
|
|
callId: string;
|
|
provider: string;
|
|
model: string;
|
|
}): string | undefined {
|
|
let outboundTraceparent: string | undefined;
|
|
const wrapped = wrapStreamFnWithDiagnosticModelCallEvents(
|
|
((
|
|
_model: Parameters<StreamFn>[0],
|
|
_context: Parameters<StreamFn>[1],
|
|
options: Parameters<StreamFn>[2],
|
|
) => {
|
|
outboundTraceparent = options?.headers?.traceparent;
|
|
return undefined as never;
|
|
}) as StreamFn,
|
|
{
|
|
runId: params.runId,
|
|
provider: params.provider,
|
|
model: params.model,
|
|
trace: params.trace,
|
|
nextCallId: () => params.callId,
|
|
suppressPluginHooks: true,
|
|
},
|
|
);
|
|
void wrapped({} as never, {} as never);
|
|
return outboundTraceparent;
|
|
}
|