ShellApprovalStorage#

Build extensions, choose hooks, and manage request-scoped state. See the guide.

class zett_agent.extensions.shell_approval.ShellApprovalStorage(*args, **kwargs)[源代码]#

Persistence boundary for session policy and remembered commands.

async get_session_mode(session_id)[源代码]#

Return the persisted approval policy for one session.

参数:

session_id (str)

返回类型:

ShellApprovalMode

async set_session_mode(session_id, mode)[源代码]#

Persist the approval policy for one session.

参数:
返回类型:

None

async clear_session_mode(session_id)[源代码]#

Remove the persisted approval policy for one session.

参数:

session_id (str)

返回类型:

None

async is_allowed(session_id, command, work_dir=None)[源代码]#

Return whether one session permits execution of one exact command in one directory.

work_dir is the directory the call named, or None when it runs in the working directory. It is part of the question: the same command string can act on a different tree through it.

It is the text the call named, not the path it resolves to, so sub, ./sub and a symbolic link are three keys for one place. An entry stored before work_dir existed was approved for the working directory, so it does not cover a call that names one.

参数:
  • session_id (str)

  • command (str)

  • work_dir (str | None)

返回类型:

bool

async allow_command(command, work_dir=None)[源代码]#

Persist one command, and the directory it may run in, in the allowlist.

参数:
  • command (str)

  • work_dir (str | None)

返回类型:

None