Documentation
¶
Overview ¶
Package scriptdecide is the part of a managed script's host a tool-call handler decides and counts with (#2436): what decide(call) returns, the count over a rolling window a rate limit reads, and the messages a handler's read-only run queues for the platform to send after the call.
Index ¶
- Constants
- func Allow(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func Count(ctx context.Context, counter Counter, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func Deny(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func ParseWindow(s string) (time.Duration, error)
- func Queue(b *starlark.Builtin, notices *[]map[string]any, payload map[string]any) (starlark.Value, error)
- func RequireApproval(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- type Counter
Constants ¶
const ( CapabilityAllow = "platform.allow" CapabilityDeny = "platform.deny" CapabilityRequireApproval = "platform.require_approval" CapabilityCount = "platform.count" )
The bindings a policy decides with (#2436): what decide(call) returns, and the count over a rolling window a rate limit reads.
const ( DecisionAllow = "allow" DecisionDeny = "deny" DecisionApprove = "require_approval" )
The decisions a policy returns, as the "decision" key of the dict the three constructors build.
const MaxNotices = 5
MaxNotices is the most messages one tool-call handler's run may queue.
Variables ¶
This section is empty.
Functions ¶
func Allow ¶
func Allow(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
Allow is platform.allow(): the call may run.
func Count ¶
func Count(ctx context.Context, counter Counter, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
Count is platform.count(key, window, add=1): add this call under key and return the total over the window ("90s", "1h", "7d"), this call included. Counts are the handler's own and are released when its call does not run. With no counter (a draft, a test) it counts only this call.
func Deny ¶
func Deny(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
Deny is platform.deny(reason): the call is refused, the caller told why.
func ParseWindow ¶
ParseWindow reads a count's window: a Go duration ("90s", "1h30m") or a number of days ("7d"), at most 31 days.
func Queue ¶
func Queue(b *starlark.Builtin, notices *[]map[string]any, payload map[string]any) (starlark.Value, error)
Queue keeps a tool-call handler's message on notices for the platform to send once the call has been answered.
func RequireApproval ¶
func RequireApproval(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
RequireApproval is platform.require_approval(approvers, summary): the call waits for one of approvers (addresses or personas; "administrators", or none, is an administrator) to approve it.