Wardrik. Scope
(wardrik_protocol v0.1.0-rc.6)
Copy Markdown
Who an operation runs for. Every operation takes one.
# user_42
scope = MyApp.AgentRuntime.as("user_42")
# user_42's agent, through its own tools
scope = MyApp.AgentRuntime.as("user_42", actor: {:agent, "agt_1"})Your app's Wardrik.Authorizer decides what each scope may do.
Fields
:server- theWardrik.Serverthat runs its operations.:wardrik- which Wardrik, by name.:principal- theWardrikCore.Principalit runs for.:actor-{:agent, id}or{:channel, name}when one acts for the principal, ornil.:context- facts for the authorizer, like a channel's:asked_by.%{}unless set.:policy- in an agent's scope, the policy every agent it defines is held to.:labels- in an agent's scope, the labels of what its run has read.:operation- the operation running, while one runs.
Summary
Functions
Returns a scope run by server.
Runs operation id with input through the scope's server.
Streams operation id with input through the scope's server.
Types
Who acts for the principal, as {kind, id}, or nil.
@type t() :: %Wardrik.Scope{ actor: actor(), context: map(), labels: [String.t()], operation: WardrikProtocol.operation() | nil, policy: String.t() | map() | nil, principal: WardrikCore.Principal.t(), server: module(), wardrik: atom() | struct() }
Functions
@spec new(module(), wardrik: atom() | struct(), principal: WardrikCore.Principal.t() | String.t(), actor: actor(), context: map() ) :: t()
Returns a scope run by server.
Wardrik.Scope.new(Wardrik,
wardrik: MyApp.AgentRuntime,
principal: "user_42",
actor: {:channel, "slack"},
context: %{asked_by: "user_7"}
):principal is a WardrikCore.Principal or its ID.
@spec run(t(), String.t(), map()) :: {:ok, term()} | {:error, Wardrik.Error.t()}
Runs operation id with input through the scope's server.
@spec stream(t(), String.t(), map()) :: {:ok, Enumerable.t()} | {:error, Wardrik.Error.t()}
Streams operation id with input through the scope's server.