UNPKG

@openai/agents-core

Version:

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

35 lines • 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sandboxPathGrantHostPath = sandboxPathGrantHostPath; exports.relativeHostPathEscapesRoot = relativeHostPathEscapesRoot; exports.relativeHostPathEscapesRootOrSelf = relativeHostPathEscapesRootOrSelf; exports.isHostPathWithinRoot = isHostPathWithinRoot; exports.isHostPathStrictlyWithinRoot = isHostPathStrictlyWithinRoot; const node_path_1 = require("node:path"); function sandboxPathGrantHostPath(grant) { const hostPath = grant.hostPath ?? grant.path; if (grant.hostPath !== undefined && !(0, node_path_1.isAbsolute)(hostPath)) { throw new Error(`Sandbox path grant hostPath must be absolute on the current host: ${hostPath}`); } if (grant.hostPath !== undefined && node_path_1.sep === '\\' && !/^[A-Za-z]:\\/u.test(hostPath)) { throw new Error(`Sandbox path grant hostPath must be drive-qualified on Windows: ${hostPath}`); } return hostPath; } function relativeHostPathEscapesRoot(relativePath) { return (relativePath === '..' || relativePath.startsWith(`..${node_path_1.sep}`) || (0, node_path_1.isAbsolute)(relativePath)); } function relativeHostPathEscapesRootOrSelf(relativePath) { return relativePath === '' || relativeHostPathEscapesRoot(relativePath); } function isHostPathWithinRoot(root, path) { return !relativeHostPathEscapesRoot((0, node_path_1.relative)(root, path)); } function isHostPathStrictlyWithinRoot(root, path) { return !relativeHostPathEscapesRootOrSelf((0, node_path_1.relative)(root, path)); } //# sourceMappingURL=hostPath.js.map