docs

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 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

Index

Constants

View Source
const (
	DropFilesPath = "/_hub/drop/files"
	DropGetPath   = "/_hub/drop/get"
)

DropFilesPath and DropGetPath are relayed paths that are not HTTP endpoints of the hub: hubAsk answers them in process, for a room's stdio server.

View Source
const PromptSlugPrefix = "prompt-"

PromptSlugPrefix marks a hub document as a prompt.

View Source
const PublishPath = "/_hub/publish"

PublishPath is the one relayed path that is not an HTTP endpoint of the hub: hubAsk answers it in process.

View Source
const RealPathHeader = "X-Atrium-Real-Path"

RealPathHeader is the room's api.RealPathHeader. Spelled here because this package does not import the room's API.

Variables

This section is empty.

Functions

func AddRoomDropTools added in v0.0.6

func AddRoomDropTools(s *mcp.Server, call func(ctx context.Context, method, path string, body, out any) error)

AddRoomDropTools is atrium_files and atrium_get on a room's stdio server, asked of the hub over the room's link.

func AddRoomPublishTool

func AddRoomPublishTool(s *mcp.Server, call func(ctx context.Context, method, path string, body, out any) error, by string)

AddRoomPublishTool is atrium_publish on a room's stdio server. The tool is the hub's: call asks the hub over the room's link (see hubAsk) and the hub names the caller from the link, never from here.

func AttachmentHeader

func AttachmentHeader(name string) string

AttachmentHeader is a Content-Disposition by RFC 6266: an ASCII `filename=` with CR, LF, `"` and `\` taken out, and `filename*=UTF-8”` carrying the real name percent-encoded.

A TITLE IS TEXT A MODEL WROTE. A raw CR or LF in it would end the header and start another, so both are removed from BOTH forms, and everything outside the unreserved set is percent-encoded in the second.

func DescribeExport

func DescribeExport(req *mcp.CallToolRequest, in ExportInput, out ExportOutput) (string, string, bool)

func DescribeGet

func DescribeGet(req *mcp.CallToolRequest, in GetInput, out GetOutput) (string, string, bool)

func DescribePublish

func DescribePublish(req *mcp.CallToolRequest, in PublishInput, out PublishOutput) (string, string, bool)

func DescribePut

func DescribePut(req *mcp.CallToolRequest, in PutInput, out PutOutput) (string, string, bool)

func ParseDocPath

func ParseDocPath(p string) (slug string, n int, ok bool)

ParseDocPath reads /d/<slug> and /d/<slug>@<n>. The split is on the LAST `@`, and a slug never holds one. n is 0 for the newest. False for anything else.

Types

type ExportInput

type ExportInput struct {
	What  string   `json:"what" jsonschema:"usage or tasks"`
	Since string   `json:"since,omitempty" jsonschema:"RFC 3339 time. default 7 days ago"`
	Rooms []string `json:"rooms,omitempty" jsonschema:"rooms to pull from. default every online room"`
}

type ExportOutput

type ExportOutput struct {
	Files   []exportedFile `json:"files"`
	Skipped []exportSkip   `json:"skipped"`
}

type FilesInput

type FilesInput struct {
	Mine bool `json:"mine,omitempty" jsonschema:"list only the files your card put"`
}

type FilesOutput

type FilesOutput struct {
	Files []dropFile `json:"files"`
	Usage dropUsage  `json:"usage"`
}

type GetInput

type GetInput struct {
	Name    string `json:"name" jsonschema:"the file's name in the drop, as atrium_files or atrium_put gave it"`
	Dest    string `` /* 130-byte string literal not displayed */
	Replace bool   `json:"replace,omitempty" jsonschema:"replace a file already at dest"`
}

type GetOutput

type GetOutput struct {
	Path string `json:"path"`
	Rel  string `json:"rel"`
	Size int64  `json:"size"`
}

type MCP

type MCP struct {
	ctl.Caller
	// Docs is the hub's document store, read at each call so it may be wired later. Nil on a hub without one.
	Docs func() *hubstore.Store
	// Rooms lists the rooms the export reads. Nil in a test that does not read it.
	Rooms func() []Room
	// Board is the loopback base of the hub's own API, and Client reaches it under Timeout.
	Board   string
	Client  *http.Client
	Timeout time.Duration
}

MCP is the document and file tools. The Caller is the hub's control server, and the rest is what it reads of the hub.

func (*MCP) ExportHandler

func (c *MCP) ExportHandler(ctx context.Context, req *mcp.CallToolRequest, in ExportInput) (
	*mcp.CallToolResult, ExportOutput, error)

func (*MCP) FilesHandler

func (c *MCP) FilesHandler(ctx context.Context, req *mcp.CallToolRequest, in FilesInput) (
	*mcp.CallToolResult, FilesOutput, error)

func (*MCP) GetHandler

func (c *MCP) GetHandler(ctx context.Context, req *mcp.CallToolRequest, in GetInput) (
	*mcp.CallToolResult, GetOutput, error)

func (*MCP) PromptHandler

func (*MCP) PublishFor

func (c *MCP) PublishFor(ctx context.Context, agent, room, by string, in PublishInput) (
	*mcp.CallToolResult, PublishOutput, error)

PublishFor is atrium_publish for a caller already named: agent on room, by `by`. The HTTP control server names the caller from its headers and a room's stdio server from the link (hubAsk), and both end here.

func (*MCP) PublishHandler

func (c *MCP) PublishHandler(ctx context.Context, req *mcp.CallToolRequest, in PublishInput) (
	*mcp.CallToolResult, PublishOutput, error)

func (*MCP) PutHandler

func (c *MCP) PutHandler(ctx context.Context, req *mcp.CallToolRequest, in PutInput) (
	*mcp.CallToolResult, PutOutput, error)

func (*MCP) RegisterDocs

func (c *MCP) RegisterDocs(s *mcp.Server, class ctl.Class)

func (*MCP) RegisterFiles

func (c *MCP) RegisterFiles(s *mcp.Server, class ctl.Class)

func (*MCP) RegisterPrompts

func (c *MCP) RegisterPrompts(s *mcp.Server, class ctl.Class)

type PromptInput

type PromptInput struct {
	Action  string `json:"action" jsonschema:"list or get"`
	Name    string `json:"name,omitempty" jsonschema:"the prompt to get, as list names it"`
	Version int    `json:"version,omitempty" jsonschema:"an older version to get. leave out for the newest"`
}

type PromptOutput

type PromptOutput struct {
	Prompts []PromptSummary `json:"prompts,omitempty"`
	Name    string          `json:"name,omitempty"`
	Version int             `json:"version,omitempty"`
	// Builtin is a prompt that ships with atrium and has no hub document yet. It has no versions.
	Builtin bool   `json:"builtin,omitempty"`
	Text    string `json:"text,omitempty"`
}

type PromptSummary

type PromptSummary struct {
	Name    string `json:"name"`
	Summary string `json:"summary"`
}

type PublishInput

type PublishInput struct {
	Title   string `json:"title,omitempty" jsonschema:"the document's title. needed for a new document. a new version keeps the title it has"`
	Content string `json:"content,omitempty" jsonschema:"the text to publish. give this or path, not both"`
	Path    string `json:"path,omitempty" jsonschema:"a file inside your own card's directory, read on your room. give this or content, not both"`
	Slug    string `json:"slug,omitempty" jsonschema:"to add a new version to the document with this slug. leave out for a new document"`
}

type PublishOutput

type PublishOutput struct {
	URL     string `json:"url"`
	Slug    string `json:"slug"`
	Version int    `json:"version"`
}

type PutInput

type PutInput struct {
	Path    string `json:"path,omitempty" jsonschema:"a file inside your own card's directory, read on your room. give this or content, not both"`
	Content string `json:"content,omitempty" jsonschema:"the text to leave. give this or path, not both. needs a name"`
	Name    string `` /* 129-byte string literal not displayed */
	Note    string `json:"note,omitempty" jsonschema:"a line saying what it is and who it is for. at most 500 characters"`
	TTLDays int    `json:"ttl_days,omitempty" jsonschema:"days to keep it, 1 to 30. default 7"`
}

type PutOutput

type PutOutput struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	Expires string `json:"expires"`
}

type Refusal

type Refusal struct {
	Status int
	Rule   string
	Msg    string
}

Refusal is a refusal with the status the HTTP API would have given it, so the same rule reads the same on both doors. It is a refusedError underneath, for the audit line.

func (*Refusal) Error

func (e *Refusal) Error() string

func (*Refusal) Unwrap

func (e *Refusal) Unwrap() error

type Room

type Room struct {
	Name   string
	Online bool
}

Room is a room as the export names it.

type Service

type Service struct {

	// RecordAudit writes one line in the hub's operational audit log.
	RecordAudit func(room, kind, detail string)
	// contains filtered or unexported fields
}

Service is the hub's document store and the HTTP half of the documents and the file drop. See mcp.go for the tools.

func New

func New(recordAudit func(room, kind, detail string)) *Service

New is a Service with nothing wired yet.

func (*Service) DocStore

func (p *Service) DocStore() *hubstore.Store

func (*Service) ServeDocs

func (p *Service) ServeDocs(w http.ResponseWriter, r *http.Request, sub string)

ServeDocs answers every /_hub/docs route.

func (*Service) ServeFiles

func (p *Service) ServeFiles(w http.ResponseWriter, r *http.Request, sub string)

ServeFiles answers every /_hub/files route.

func (*Service) SetDocs

func (p *Service) SetDocs(st *hubstore.Store)

SetDocs wires the document store. Optional: a hub without one answers /_hub/docs 404.

Jump to

Keyboard shortcuts

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