webhook

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webhook is the namespace of the webhooks' tools, of a webhook server, whose URLs external services call, and which is watched for their calls

Index

Constants

View Source
const (
	// Agent is the name of the built-in agent which handles calls
	Agent = "webhook"
)
View Source
const Name = "webhook"

Name is the name of the namespace of the webhooks' tools

Variables

This section is empty.

Functions

This section is empty.

Types

type Calls added in v1.7.7

type Calls struct {
	Session  uuid.UUID
	Webhooks []schema.Webhook
	Calls    []schema.Call
}

Calls are the calls of a session's webhooks, which were accepted, and weren't seen, oldest first, and the webhooks they're of

func (*Calls) Detail added in v1.7.7

func (c *Calls) Detail() string

Detail returns what the system says of the calls, to the session's model, which is their serial numbers, such as It's of webhook calls 12 and 13. It has nothing which was sent.

func (*Calls) Input added in v1.7.7

func (c *Calls) Input(ctx context.Context, lines []string) (json.RawMessage, error)

Input returns the input of the agent which handles the calls, as JSON: the webhooks, and the calls, with what was sent, which is shortened, when it's long, without the tokens of webhooks' URLs, and what the system says, one line each, such as the time

type HandleFunc added in v1.7.7

type HandleFunc func(context.Context, *Calls) error

HandleFunc handles the calls of a session's webhooks, such as by running an agent with them, and returns nil once they're handled

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace is the namespace of the webhooks' tools, of a webhook server

func New

func New(endpoint string, opts ...client.ClientOpt) (*Namespace, error)

New returns the namespace of the webhook server's API, at the endpoint, such as http://localhost:8087/api, with the client options. The server isn't called until the namespace is run, or a tool is called.

func (*Namespace) Description

func (*Namespace) Description() string

Description returns what the namespace's tools are for

func (*Namespace) Handle added in v1.7.7

func (ns *Namespace) Handle(fn HandleFunc)

Handle sets the function which handles the calls of a session's webhooks, such as by running an agent with them. It's set before the namespace runs.

func (*Namespace) Name

func (*Namespace) Name() string

func (*Namespace) Run

func (ns *Namespace) Run(parent context.Context, logger *slog.Logger) error

Run watches the webhook server for the calls of its webhooks, and, with Handle, handles those which were accepted, and weren't seen, which include those received while it wasn't running, until the context is cancelled, when it returns nil. Those received within half a minute of the first are handled together, those of each session at once. They're marked as seen once they're handled, so they're not handled again, unless it stops before they're marked.

When the server can't be reached, or stops, it tries again, waiting longer each time. Calls which can't be handled are tried again, up to a few times, waiting longer each time, and then marked as seen, so they don't stop those after them. What was sent isn't logged. Returns ErrConflict when it's running already.

func (*Namespace) SystemPrompt

func (*Namespace) SystemPrompt() string

SystemPrompt returns no system prompt, as the tools' descriptions say how to use them

func (*Namespace) Tools

func (ns *Namespace) Tools() []llm.Tool

Tools returns the namespace's tools

func (*Namespace) Type

func (*Namespace) Type() string

Type returns that the namespace's tools are built in

func (*Namespace) Watch

func (ns *Namespace) Watch(ctx context.Context, ch chan<- eventschema.Change) error

Watch sends the namespace's tools, which don't change

Jump to

Keyboard shortcuts

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