tools.privilege_capsh module
Stargazer capability shell — capsh for the privilege bitmask system.
Star calls this to get a full decoded view of a user’s privilege state across all scopes: global, guild, channel, effective (resolved), and per-bit resolution mode annotations.
Equivalent to capsh --print on Linux capabilities.
- async tools.privilege_capsh.run(target_user_id='', guild_id='', channel_id='', ctx=None)[source]
Produce a full decoded capability dump of a user’s privilege bitmask.
Entry point for the
privilege_capshtool — thecapsh --printanalogue for Stargazer’s 64-bit privilege system. It resolves the target user’s global, guild, and channel masks, computes the effective (resolved) mask under each bit’s resolution mode, annotates every set bit (NORMAL/INVERTED/DANGEROUS and whether a scope granted or revoked it), diffs global versus effective, and estimates a self-escalation ceiling (the maximum mask the user could reach if they went adversarial, given any admin bits they hold).All privilege logic is imported lazily from
tools.alter_privileges(PRIVILEGES,DANGEROUS_BITS,ALL_BITS,_bit_mode,_is_admin,_mask_to_names,_get_scoped_mask,get_user_privileges,resolve_privilege_bit); the mask reads ultimately consult Redis throughctx.redis. Guild/channel scopes default toctx.guild_id/ctx.channel_idwhen not passed explicitly. Reading another user’s capabilities is gated: it requires the caller to holdALTER_PRIVILEGESor be an admin, otherwise an error JSON is returned. This handler is read-only and mutates no state.Registered via the single-tool module contract (
TOOL_NAME/run) and dispatched bytool_loader.load_tools; the same decode is also surfaced to the!capshchat command throughmessage_processor.proxy_status_commands.capsh_text.- Parameters:
target_user_id (
str) – User ID to inspect; empty means the calling user (ctx.user_id).guild_id (
str) – Guild scope to evaluate; empty falls back toctx.guild_id.channel_id (
str) – Channel scope to evaluate; empty falls back toctx.channel_id. Channel masks are only fetched when a guild is known.ctx (
ToolContext|None) – The tool context supplyingredis,config,user_id, and the guild/channel context.
- Returns:
A pretty-printed JSON dump with per-scope masks, the effective mask, per-bit details, scope diffs, resolution-mode legend, and the escalation ceiling; or a JSON
{"error": ...}string when there is no context, Redis is unavailable, no target user can be determined, or the caller lacksALTER_PRIVILEGESto read another user.- Return type: