runtime

package
v1.801.388 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package runtime is the transport to the bot runtime service — the TS bot that executes channels and skills — and it relays that service's own ops paths at /v1/bot/* (ops.go), the only routes it serves.

It knows how to MOVE BYTES to that service and nothing about what they mean. There is no run here, no coding task, no tenant policy: the domains own their own wire contracts (apps/bots' stop, apps/coding's task) and express them as a Call. So exactly ONE place resolves the base address, mints the server-originated identity, frames the stream, bounds a call, and decides whether a cleartext hop is allowed.

The edge is transport-agnostic on purpose. A caller states WHAT it wants done (Call) and gets back a domain-shaped outcome — never an *http.Response, a status code, a header map, or a framing detail. Today those bytes move over HTTP; per HIP-0106/HIP-0120 they should move over ZAP, and that swap is meant to be a change to THIS package's internals plus each domain's one stub file, not a rewrite of the domains.

Dependencies point one way: bots -> runtime, coding -> runtime. runtime imports neither, and must not: the moment it knows what a run is, it has stopped being a transport.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("runtime: no such target")
	ErrNotServed = errors.New("runtime: operation not served")
)

ErrNotFound reports that the runtime ANSWERED that it holds no such target — a structured reply from an operation that exists. It is the transport-agnostic form of "absent": a caller decides what absence MEANS for its domain, and that decision stays in the domain rather than being read off a status code.

ErrNotServed reports that the runtime does not serve the operation AT ALL — it never answered about the target, so nothing was learned about it. The two are separated because conflating them is a correctness lie: a runtime build without the operation reports absent for EVERY target, and treating that as "already gone" turns permanent failure into permanent success. Absence is only ever meaningful from a callee that could have said otherwise.

Functions

func Do

func Do(ctx context.Context, c Call) error

Do invokes c and discards any response payload — the command form. It returns ErrNotFound when the runtime answers that the target is absent, ErrNotServed when it does not serve the operation, and a bounded descriptive error otherwise. Bounded by callTimeout.

func ErrBody

func ErrBody(resp *http.Response) string

ErrBody reads a bounded prefix of a body for an error message.

func Mount

func Mount(app cloud.Router, deps cloud.Deps) error

Mount registers the /v1/bot/* surface on app per HIP-0106.

func Read

func Read(ctx context.Context, c Call, out any) error

Read invokes c and decodes its answer into out — the query form. Same error vocabulary as Do. Bounded by callTimeout.

func Stream

func Stream(ctx context.Context, c Call, fn func(msg []byte)) error

Stream invokes c and hands each response message to fn as it arrives — the streaming form. Framing is ours; what a message MEANS is the caller's contract, so fn receives one encoded message and decodes it itself. A message over lineCap ends the stream with an error rather than growing the buffer. The deadline is the caller's ctx: a stream legitimately runs for minutes.

Types

type Call

type Call struct {
	Op     string
	Org    string
	User   string
	Body   any
	Secret bool
}

Call is one operation on the runtime.

Op addresses the operation. It is the caller's own identity for what it is invoking and is opaque here — the transport carries it, it never interprets it. (Under HTTP it is a path; under ZAP it becomes a generated method id. Either way it belongs to the domain's stub, which is why runtime holds no table of operations and therefore no domain knowledge.)

Org/User are the tenant context cloud has ALREADY resolved and authorized. Body is the payload, encoded by the transport; nil sends none. Secret declares that Body carries a credential, which forbids a cleartext hop.

Jump to

Keyboard shortcuts

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