#ifndef LLSH_LIMITS_H #define LLSH_LIMITS_H #include "util.h" /* Process-global tool limits + run_shell policy (mirrors limits.rs). */ typedef struct { unsigned long shell_timeout_secs; unsigned long max_output_chars; unsigned long max_file_bytes; strlist shell_allowlist; strlist shell_denylist; bool confirm_destructive; bool verbose; } tool_limits; void tool_limits_defaults(tool_limits *l); void tool_limits_set(const tool_limits *l); /* Read-only view of the current limits (no copy). The pointer is valid until * the next tool_limits_set; do not store it across set calls. */ const tool_limits *tool_limits_current(void); void tool_limits_get(tool_limits *out); void tool_limits_free(tool_limits *l); typedef enum { SHELL_ALLOWED, SHELL_DENIED, } shell_verdict; /* Returns 0 allowed, -1 denied (reason in **err, owned). */ int shell_policy(const char *command, const tool_limits *l, char **reason); bool is_destructive(const char *command); void set_confirm_hook(bool (*hook)(const char *command, void *ud), void *ud); /* Full gate: policy, then destructive confirmation. 0 = proceed. */ int shell_gate(const char *command, const tool_limits *l, char **err); #endif