mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
refactor(trajectory): use findLast in export scans (#120612)
This commit is contained in:
committed by
GitHub
parent
6318e30077
commit
a67784ef43
@@ -919,10 +919,7 @@ function redactEventForExport(
|
||||
}
|
||||
|
||||
function resolveRuntimeContext(runtimeEvents: TrajectoryEvent[]): RuntimeTrajectoryContext {
|
||||
const latestContext = runtimeEvents
|
||||
.slice()
|
||||
.toReversed()
|
||||
.find((event) => event.type === "context.compiled");
|
||||
const latestContext = runtimeEvents.findLast((event) => event.type === "context.compiled");
|
||||
const runtimeData = latestContext?.data;
|
||||
const toolsValue = Array.isArray(runtimeData?.tools)
|
||||
? (runtimeData.tools as TrajectoryToolDefinition[])
|
||||
@@ -938,10 +935,7 @@ function resolveLatestRuntimeEventData(
|
||||
runtimeEvents: TrajectoryEvent[],
|
||||
type: string,
|
||||
): JsonRecord | undefined {
|
||||
const event = runtimeEvents
|
||||
.slice()
|
||||
.toReversed()
|
||||
.find((candidate) => candidate.type === type);
|
||||
const event = runtimeEvents.findLast((candidate) => candidate.type === type);
|
||||
return event?.data;
|
||||
}
|
||||
|
||||
@@ -1041,10 +1035,9 @@ function buildMetadataCapture(params: {
|
||||
return undefined;
|
||||
}
|
||||
const modelFallback = (() => {
|
||||
const latest = params.runtimeEvents
|
||||
.slice()
|
||||
.toReversed()
|
||||
.find((event) => event.provider || event.modelId || event.modelApi);
|
||||
const latest = params.runtimeEvents.findLast(
|
||||
(event) => event.provider || event.modelId || event.modelApi,
|
||||
);
|
||||
if (!latest?.provider && !latest?.modelId && !latest?.modelApi) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user