feat: add permissions status script (#681)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// src/hooks/index.ts
|
||||
// Main hooks module - provides high-level API for running hooks
|
||||
|
||||
import { sessionPermissions } from "../permissions/session";
|
||||
import { executeHooks, executeHooksParallel } from "./executor";
|
||||
import { getHooksForEvent, hasHooksForEvent, loadHooks } from "./loader";
|
||||
import type {
|
||||
@@ -120,6 +121,7 @@ export async function runPermissionRequestHooks(
|
||||
type: permissionType,
|
||||
scope,
|
||||
},
|
||||
session_permissions: sessionPermissions.getRules(),
|
||||
};
|
||||
|
||||
// Run sequentially - first hook that returns 0 or 2 determines outcome
|
||||
|
||||
@@ -194,6 +194,12 @@ export interface PermissionRequestHookInput extends HookInputBase {
|
||||
type: "allow" | "deny" | "ask";
|
||||
scope?: "session" | "project" | "user";
|
||||
};
|
||||
/** Current session permissions (in-memory only, cleared on exit) */
|
||||
session_permissions?: {
|
||||
allow?: string[];
|
||||
deny?: string[];
|
||||
ask?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -403,11 +403,16 @@ export async function checkToolPermission(
|
||||
matchedRule?: string;
|
||||
reason?: string;
|
||||
}> {
|
||||
const { checkPermission } = await import("../permissions/checker");
|
||||
const { checkPermissionWithHooks } = await import("../permissions/checker");
|
||||
const { loadPermissions } = await import("../permissions/loader");
|
||||
|
||||
const permissions = await loadPermissions(workingDirectory);
|
||||
return checkPermission(toolName, toolArgs, permissions, workingDirectory);
|
||||
return checkPermissionWithHooks(
|
||||
toolName,
|
||||
toolArgs,
|
||||
permissions,
|
||||
workingDirectory,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user