scriptdecide

package
v1.162.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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.

View Source
const (
	DecisionAllow   = "allow"
	DecisionDeny    = "deny"
	DecisionApprove = "require_approval"
)

The decisions a policy returns, as the "decision" key of the dict the three constructors build.

View Source
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

func ParseWindow(s string) (time.Duration, error)

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.

Types

type Counter

type Counter func(ctx context.Context, key string, window time.Duration, amount int) (int, error)

Counter adds amount under key and returns the total over the window, this call included (callhandler.Store.Count, scoped to one handler and call).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL