core

package
v0.98.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package core registers hub.CapCore — internal multi-op capability for notify, clip, agent, HTTP, sandboxed execution, and persistent KV.

Index

Constants

View Source
const (
	OpNotifySend   = "notify_send"
	OpNotifyHealth = "notify_health"

	OpClipCreate = "clip_create"
	OpClipGet    = "clip_get"
	OpClipHealth = "clip_health"

	OpAgentRun    = "agent_run"
	OpAgentHealth = "agent_health"

	OpHTTPRequest = "http_request"

	OpRunCode     = "run_code"
	OpRunTerminal = "run_terminal"

	OpKVGet    = "kv_get"
	OpKVSet    = "kv_set"
	OpKVDelete = "kv_delete"
)
View Source
const (

	// MaxContentBytes is the maximum accepted markdown body size for create.
	MaxContentBytes = 512 * 1024
)

Variables

This section is empty.

Functions

func CatalogSpec

func CatalogSpec() capability.Spec

CatalogSpec returns capability metadata for documentation (handlers may close over a nil service and must not be invoked).

func LegacyCapability

func LegacyCapability(name string) bool

LegacyCapability reports whether name is a pre-CapCore capability type string.

func LegacyOperation

func LegacyOperation(capability, operation string) (coreOp string, ok bool)

LegacyOperation maps pre-CapCore (capability, operation) to CapCore op name. ok is false when the pair is not a known legacy mapping.

func Register

func Register() error

Register registers hub.CapCore with all core operations.

func SetExecProvider

func SetExecProvider(p ExecProvider)

SetExecProvider wires sandboxed execution used by run_code and run_terminal.

func SetKVStore

func SetKVStore(s KVStore)

SetKVStore wires the persistence backend used by kv_get/set/delete.

func SetMetaLLMForTest

func SetMetaLLMForTest(fn metaLLMFunc)

SetMetaLLMForTest overrides LLM metadata generation in unit tests.

func SetNotifier

func SetNotifier(n Notifier)

SetNotifier wires the notification gateway used by notify_send.

func SetNotifierFunc

func SetNotifierFunc(fn func(ctx context.Context, uid types.Uid, templateID string, channels []string, payload map[string]any) error)

SetNotifierFunc wires a send function (tests and server).

func SetPersister

func SetPersister(p Persister)

SetPersister wires the persistence backend used by clip_create.

func SetRunner

func SetRunner(r Runner)

SetRunner wires the product-layer agent runner used by pipeline steps.

func WordCount

func WordCount(content string) int

WordCount returns a rough word count for markdown display metadata.

Types

type ExecProvider

type ExecProvider interface {
	// ExecConfig returns workspace root and ExecutionEnv (typically Docker sandbox).
	ExecConfig(ctx context.Context) (pkgexec.Config, error)
}

ExecProvider supplies workspace-bound execution config for run_code / run_terminal.

type KVStore

type KVStore interface {
	Get(ctx context.Context, uid types.Uid, namespace, key string) (types.KV, error)
	Set(ctx context.Context, uid types.Uid, namespace, key string, value types.KV) error
	Delete(ctx context.Context, uid types.Uid, namespace, key string) error
}

KVStore persists namespaced key/value data for core.kv_* ops.

type Meta

type Meta struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

Meta holds LLM-generated (or fallback) title and description.

type Notifier

type Notifier interface {
	Send(ctx context.Context, uid types.Uid, templateID string, channels []string, payload map[string]any) error
}

Notifier dispatches template notifications (wired to pkg/notify.GatewaySend in server).

type Persister

type Persister interface {
	// CreateClip inserts a clip row keyed by slug.
	CreateClip(ctx context.Context, slug, title, description, content, createdBy string) error
	// GetClipBySlug returns a clip by slug, or nil when not found.
	GetClipBySlug(ctx context.Context, slug string) (*Record, error)
}

Persister stores and loads clips.

type Record

type Record struct {
	// Slug is the public short identifier.
	Slug string
	// Title is the clip title.
	Title string
	// Description is the short preview text.
	Description string
	// Content is the markdown body.
	Content string
	// CreatedBy is the optional creator identifier.
	CreatedBy string
	// CreatedAt is when the clip was created.
	CreatedAt time.Time
}

Record is a persisted clip returned by get operations.

type RunParams

type RunParams struct {
	Prompt      string
	UID         types.Uid
	Tools       []string
	Skills      []string
	MemoryScope string
}

RunParams carries one pipeline-rendered agent run request.

type RunResult

type RunResult struct {
	Reply     string
	SessionID string
}

RunResult holds the outcome of one agent_run invocation.

type Runner

type Runner interface {
	Run(ctx context.Context, params RunParams) (*RunResult, error)
}

Runner executes one agent prompt from a pipeline step.

Jump to

Keyboard shortcuts

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