@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
31 lines • 1.17 kB
JavaScript
import { dirname } from "node:path";
export const APPROVED_MONITOR_PARENT = Symbol("approved-monitor-parent");
export function setApprovedMonitorParent(input, parent) {
Object.defineProperty(input, APPROVED_MONITOR_PARENT, {
configurable: true,
value: parent,
writable: false,
});
}
export function getApprovedMonitorParent(input) {
return input[APPROVED_MONITOR_PARENT];
}
/**
* Carry the parent the permission parser approved onto the frozen copy of a monitor call (senpi#5795): the JSON freeze
* drops symbol keys, which would skip the parent-swap check at registration. Only for the same watched path; never
* throws.
*/
export function transferApprovedMonitorParent(from, to) {
if (typeof from !== "object" || from === null || typeof to !== "object" || to === null)
return;
const source = from;
const target = to;
const parent = getApprovedMonitorParent(source);
if (parent === undefined || source.path !== target.path)
return;
setApprovedMonitorParent(target, parent);
}
export function monitorParent(path) {
return dirname(path);
}
//# sourceMappingURL=monitor-permission.js.map