Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 848 Bytes

File metadata and controls

40 lines (29 loc) · 848 Bytes

Permissions

Set the default mode at startup:

sdk = AutohandSDK::Client.new(permission_mode: "interactive")

Change it during a session:

sdk.set_permission_mode("unrestricted")

When the CLI emits a permission_request, respond with one of the helper methods:

sdk.stream_prompt("Apply the migration").each do |event|
  next unless event["type"] == "permission_request"

  if event["tool"] == "bash"
    sdk.allow_permission(event["request_id"], scope: :once)
  else
    sdk.deny_permission(event["request_id"], scope: :session)
  end
end

Scopes:

  • :once - only this request.
  • :session - this CLI session.
  • :project - persist for the project.
  • :user - persist for the user.

For a safer alternative:

sdk.suggest_permission_alternative(event["request_id"], "bundle exec rake test")