UNPKG

@openai/agents-core

Version:

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

28 lines • 1.18 kB
import { isAbsolute, relative, sep } from 'node:path'; export function sandboxPathGrantHostPath(grant) { const hostPath = grant.hostPath ?? grant.path; if (grant.hostPath !== undefined && !isAbsolute(hostPath)) { throw new Error(`Sandbox path grant hostPath must be absolute on the current host: ${hostPath}`); } if (grant.hostPath !== undefined && sep === '\\' && !/^[A-Za-z]:\\/u.test(hostPath)) { throw new Error(`Sandbox path grant hostPath must be drive-qualified on Windows: ${hostPath}`); } return hostPath; } export function relativeHostPathEscapesRoot(relativePath) { return (relativePath === '..' || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath)); } export function relativeHostPathEscapesRootOrSelf(relativePath) { return relativePath === '' || relativeHostPathEscapesRoot(relativePath); } export function isHostPathWithinRoot(root, path) { return !relativeHostPathEscapesRoot(relative(root, path)); } export function isHostPathStrictlyWithinRoot(root, path) { return !relativeHostPathEscapesRootOrSelf(relative(root, path)); } //# sourceMappingURL=hostPath.mjs.map