origin

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package origin defines the "dev.acp-kit.origin/v1" _meta entry: who sent a message, and from where, on a chat platform a relay bridges to an ACP agent.

Relays attach it to session/new, session/load, session/resume, session/fork and every session/prompt. It is the ONLY place identity travels: relays must not put identity text into prompt content. Agents read it to pick a per-user cwd, credentials or policy.

On session/new, session/fork and session/prompt the entry describes the triggering message. On session/resume and session/load it may describe the message that created the session instead (acp-kit re-sends that one when it recovers a session after an agent respawn), so agents should key per-message behaviour on prompts only.

The cwd a relay sends alongside it is opaque (it may be a placeholder); the agent chooses the real working directory.

Index

Constants

View Source
const Key = "dev.acp-kit.origin/v1"

Key is the _meta key the origin entry is stored under.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, o Origin) context.Context

With returns a context carrying o. acp-kit's client attaches it to the _meta of every session call made with that context.

Types

type Origin

type Origin struct {
	Platform  string `json:"platform,omitempty"` // e.g. "slack", "zulip", "poe"
	TeamID    string `json:"team_id,omitempty"`  // workspace / realm / site
	UserID    string `json:"user_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	ThreadID  string `json:"thread_id,omitempty"` // thread / topic / conversation
	MessageID string `json:"message_id,omitempty"`
	IsDM      bool   `json:"is_dm"`
	IsMention bool   `json:"is_mention"`
}

Origin identifies the chat message that triggered an ACP call. Every field is optional; IDs are the platform's own, as opaque strings. It must stay comparable (no maps or slices): IsZero relies on ==.

func Decode

func Decode(b []byte) (Origin, bool)

Decode parses one encoded origin entry (the value under Key). A null or empty entry reads as absent.

func From

func From(ctx context.Context) (Origin, bool)

From returns the origin carried by ctx, if any.

func FromMeta

func FromMeta(meta map[string]any) (o Origin, ok bool)

FromMeta reads the origin entry from a decoded _meta map. It accepts the entry either as an Origin value (in-process) or as the generic map/JSON-decoded form. ok is false when the key is absent or malformed.

func FromRawMeta

func FromRawMeta(raw json.RawMessage) (Origin, bool)

FromRawMeta reads the origin entry from an undecoded _meta object.

func (Origin) IsZero

func (o Origin) IsZero() bool

IsZero reports whether o carries no information.

func (Origin) Merge

func (o Origin) Merge(meta map[string]any) map[string]any

Merge returns meta with o stored under Key. It never modifies meta: the result is a fresh map. A zero o returns meta unchanged (possibly nil).

Jump to

Keyboard shortcuts

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