UNPKG

@openai/agents-core

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

48 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.timeIso = timeIso; exports.generateTraceId = generateTraceId; exports.generateSpanId = generateSpanId; exports.generateGroupId = generateGroupId; exports.removePrivateFields = removePrivateFields; const _shims_1 = require("@openai/agents-core/_shims"); /** * Generate an ISO 8601 timestamp of the current time. * @returns An ISO 8601 timestamp. */ function timeIso() { return new Date().toISOString(); } /** * Generate a trace ID by creating a random UUID v4 and removing the dashes. This is the equivalent * of `uuid4().hex` in Python and prefixing it with `trace_`. * @returns A trace ID. */ function generateTraceId() { return `trace_${(0, _shims_1.randomUUID)().replace(/-/g, '')}`; } /** * Generate a span ID by creating a random UUID v4 and removing the dashes. This is the equivalent * of `uuid4().hex` in Python and prefixing it with `span_`. * @returns A span ID. */ function generateSpanId() { return `span_${(0, _shims_1.randomUUID)().replace(/-/g, '').slice(0, 24)}`; } /** * Generate a group ID by creating a random UUID v4 and removing the dashes. This is the equivalent * of `uuid4().hex` in Python and prefixing it with `group_`. * @returns A group ID. */ function generateGroupId() { return `group_${(0, _shims_1.randomUUID)().replace(/-/g, '').slice(0, 24)}`; } /** * Remove fields that start with an underscore from an object. * @param obj - The object to remove private fields from. * @returns A new object with private fields removed. */ function removePrivateFields(obj) { return Object.fromEntries(Object.entries(obj).filter(([key]) => !key.startsWith('_'))); } //# sourceMappingURL=utils.js.map