function isInputProvenanceKind(value: unknown): value is InputProvenanceKind { return ( typeof value === "string" && (INPUT_PROVENANCE_KIND_VALUES as readonly string[]).includes(value)
);
}
export function normalizeInputProvenance(value: unknown): InputProvenance | undefined { if (!value || typeof value !== "object") { return undefined;
} const record = value as Record<string, unknown>; if (!isInputProvenanceKind(record.kind)) { return undefined;
} return {
kind: record.kind,
originSessionId: normalizeOptionalString(record.originSessionId),
sourceSessionKey: normalizeOptionalString(record.sourceSessionKey),
sourceChannel: normalizeOptionalString(record.sourceChannel),
sourceTool: normalizeOptionalString(record.sourceTool),
};
}
export function applyInputProvenanceToUserMessage(
message: AgentMessage,
inputProvenance: InputProvenance | undefined,
): AgentMessage { if (!inputProvenance) { return message;
} if ((message as { role?: unknown }).role !== "user") { return message;
} const existing = normalizeInputProvenance((message as { provenance?: unknown }).provenance); if (existing) { return message;
} return {
...(message as unknown as Record<string, unknown>),
provenance: inputProvenance,
} as unknown as AgentMessage;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.