Documentation
¶
Overview ¶
Package plugin is the public surface a Tangent plugin is written against (CW-20260930-0102).
A plugin is its own program, speaking the plugin-sdk subprocess wire (github.com/hollis-labs/libs/mcp/plugin-mcp/plugin-sdk/subprocess) to the Tangent that spawned it. The SDK is host-neutral and stays that way; this package carries only the Tangent-specific half — the shapes a plugin registers, the capability a browser route is gated on, the plugin.yaml a plugin emits, and the one-method caller it drives Tangent's tool surface through. pkg/plugin/hostclient is that caller over MCP.
A leaf, deliberately ¶
Nothing here imports github.com/hollis-labs/tangent/internal/... . Go lets a package inside this module import internal/, and a plugin in another module importing this one would then silently compile Tangent's host internals and pin them through the tangent version it requires. internal/smoke's TestPublicPluginSurfaceIsALeaf holds that.
The definitions live here and the host aliases them (internal/pluginhost, internal/authz, internal/pluginpkg), so a host type and the plugin type are the same type, not two that are kept in step.
Scope ¶
Exactly what the first-party plugins use. The host's own machinery — the Host, discovery, install, lifecycle and isolation — stays internal. A generic "a plugin calls its host's tools" abstraction may move down into plugin-sdk when a second host needs one; until then it lives here.
Index ¶
- Constants
- Variables
- func EncodeManifest(w io.Writer, common sdkmanifest.Manifest, bindings TangentExtension) error
- func EncodeNativeManifest(w io.Writer, payload []byte, entry string, common sdkmanifest.Manifest, ...) error
- func TurnsEnqueueInputSchema() []byte
- type AgentTurnOption
- type AgentTurnRequest
- type AgentTurnResponse
- type AgentTurnSource
- type Capability
- type HTTPRoute
- type KindRef
- type MCPTool
- type Manifest
- type RouteDecl
- type TangentExtension
- type ToolCaller
- type ToolDecl
- type ToolResult
- type TurnAnnotation
- type TurnSourceAttribution
- type TurnSourceMessage
- type TurnStageTrace
- type TurnSummary
Constants ¶
const ( ManifestName = sdkmanifest.Filename // ContractVersion versions the public Tangent plugin declaration contract, // independently of the application release and interaction definitions. ContractVersion = "1.0.0" // BinaryContractVersion is the host's native subprocess runner contract. BinaryContractVersion = "1.0.0" TangentSchemaVersion = 1 )
const AgentTurnContractVersion = "1.2"
AgentTurnContractVersion is the payload contract version of the tangent.agent-turn kind a plugin enqueues through tangent_turns_enqueue (docs/contracts/agent-turns-inbox-v1.md). The host owns the kind and aliases this constant; it lives here so a plugin and the host agree by construction.
const MaxTurnStageMetadataBytes = 8 * 1024
const RoutePrefix = "/api/plugins/"
RoutePrefix is the reserved mount point for every plugin-served route.
const ToolNamespace = "tangent."
ToolNamespace is the prefix every tool this build serves carries. It is not decoration: the documentation gate matches tool mentions by this spelling, so a name outside it is a tool no document can be checked against.
Variables ¶
"plugin: no tool caller is attached to this host")
ErrToolCallerUnavailable reports a plugin trying to drive Tangent before the host has been given a caller — which in a real process means before the MCP server exists. It is not a state a plugin can recover from; it is a composition-root defect, and it says so.
Functions ¶
func EncodeManifest ¶ added in v0.17.0
func EncodeManifest(w io.Writer, common sdkmanifest.Manifest, bindings TangentExtension) error
EncodeManifest emits the SDK declaration after checking its Tangent bindings. Artifact inventory must already cover the built payload; this grants nothing.
func EncodeNativeManifest ¶ added in v0.17.0
func EncodeNativeManifest(w io.Writer, payload []byte, entry string, common sdkmanifest.Manifest, bindings TangentExtension) error
EncodeNativeManifest inventories one built native executable. Call it with the final executable bytes, before writing plugin.yaml into a fresh bundle. Additional payload files need an explicit SDK artifact inventory instead.
func TurnsEnqueueInputSchema ¶ added in v0.16.0
func TurnsEnqueueInputSchema() []byte
TurnsEnqueueInputSchema returns the JSON Schema tangent_turns_enqueue accepts: the tangent.agent-turn request schema, which the host owns and ships in its package tree. A plugin that enqueues turns validates what it builds against this in its own tests, so the contract with the host is a published schema rather than an import of host code.
This file is a copy, because an embed cannot reach the host's package tree. internal/mcp's TestTurnsEnqueueAdvertisesThePublishedSchema holds the copy, the packaged schema and the live tool's advertised schema equal.
Types ¶
type AgentTurnOption ¶ added in v0.18.0
type AgentTurnRequest ¶ added in v0.18.0
type AgentTurnRequest struct {
ContractVersion string `json:"contract_version"`
TurnID string `json:"turn_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
IdempotencyKey string `json:"idempotency_key"`
Kind string `json:"kind"`
Source AgentTurnSource `json:"source"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Content string `json:"content"`
Annotations []TurnAnnotation `json:"annotations,omitempty"`
StageTrace []TurnStageTrace `json:"stage_trace,omitempty"`
SourceMessage *TurnSourceMessage `json:"source_message,omitempty"`
Options []AgentTurnOption `json:"options,omitempty"`
Correlations map[string]any `json:"correlations,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
}
AgentTurnRequest is the public turns_enqueue payload. Contract 1.1 permits publication-origin checkpoints without invented runtime IDs; the host validates this data against TurnsEnqueueInputSchema and its cross-field admission rules.
type AgentTurnResponse ¶ added in v0.19.0
type AgentTurnResponse struct {
Action string `json:"action"`
ResponseText string `json:"response_text,omitempty"`
SelectedOption string `json:"selected_option,omitempty"`
Note string `json:"note,omitempty"`
Interrupt bool `json:"interrupt,omitempty"`
}
AgentTurnResponse is an immutable operator resolution payload. Interrupt is explicit user intent; absence means false. A consumer still checks the actual target capability before dispatch. This field confers no reply authority.
type AgentTurnSource ¶ added in v0.18.0
type AgentTurnSource struct {
AgentID string `json:"agent_id"`
ApplicationID string `json:"application_id,omitempty"`
AgentLabel string `json:"agent_label,omitempty"`
}
AgentTurnSource is attribution supplied by the caller, not sender authority.
type Capability ¶
type Capability string
Capability is an ADR 0004 §2 object-access capability. internal/authz aliases this type and owns the full set and the rules; a plugin names one on an HTTPRoute or a RouteDecl.
const ( // CapabilityView reads a surface or interaction projection. CapabilityView Capability = "view" // CapabilityDraft writes a draft revision: view state, never a decision. CapabilityDraft Capability = "draft" )
The capabilities a plugin-served browser route may be gated on. A route must name one a participant session can hold — the host refuses the rest at registration, because a route gated on anything else is unreachable from a browser.
type HTTPRoute ¶
type HTTPRoute struct {
// Method is GET or POST.
Method string
// Path is the literal mount path. It must be under RoutePrefix and must
// carry a plugin-owned segment: /api/plugins/<plugin>/<path>.
Path string
// Capability is the ADR 0004 §2 capability the route exercises, checked
// against the participant's session before the handler runs. It must be
// one a participant session can hold; the host refuses the rest at
// registration.
Capability Capability
// Handler services requests. It is the SDK's own dispatch interface.
Handler subprocess.HTTPHandler
}
HTTPRoute is one plugin-served browser route.
type MCPTool ¶
type MCPTool struct {
// Name is the wire name agents call. It must be `tangent.<name>`.
Name string
// Description is what an agent reads when choosing a tool.
Description string
// InputSchema is the tool's JSON Schema. It must parse and it must be of
// type "object" — MCP requires that of every tool, and the host checks it
// here so a malformed schema fails the boot rather than the first call.
InputSchema json.RawMessage
// Effect is the reviewed host effect, never an authorization grant.
Effect string
Annotations *sdkmanifest.ToolAnnotations
// Handler services invocations. It is the SDK's own dispatch interface,
// unchanged, so a plugin written against it needs no Tangent-specific
// handler type.
Handler subprocess.MCPHandler
}
MCPTool is one agent-callable tool a plugin contributes.
InputSchema is raw JSON rather than a parsed schema type on purpose: it is what a plugin puts on the wire and in its plugin.yaml (ToolDecl), so the declaration and the registration cannot drift apart.
type Manifest ¶
type Manifest struct {
sdkmanifest.Manifest
Bindings TangentExtension
}
Manifest retains the reviewed SDK declaration and its validated host bindings. It is not an interaction definition or an authorization grant.
func DecodeManifest ¶ added in v0.17.0
DecodeManifest is the only process-manifest decoder. Broader YAML, legacy entrypoints and unknown/duplicate/null/trailing fields have no fallback.
type TangentExtension ¶ added in v0.17.0
type ToolCaller ¶
type ToolCaller interface {
CallTool(ctx context.Context, name string, arguments any) (ToolResult, error)
}
ToolCaller invokes one of the host's own MCP tools in process.
type ToolDecl ¶
type ToolDecl = sdkmanifest.Tool
type ToolResult ¶
type ToolResult struct {
Content json.RawMessage
IsError bool
}
ToolResult is one tool call's answer.
Content is the tool's own JSON, verbatim. IsError distinguishes a tool that answered "no" from a transport failure, which comes back as an error — the same split the MCP contract makes, preserved rather than collapsed, because "Torque said this task does not exist" and "the call never arrived" need different handling by the plugin.
func (ToolResult) Unmarshal ¶
func (r ToolResult) Unmarshal(value any) error
Unmarshal decodes a successful result into value. An isError result is returned as an error carrying the tool's own body, so a plugin that forgets to check IsError cannot mistake a refusal for data.
type TurnAnnotation ¶ added in v0.18.0
type TurnAnnotation struct {
SchemaVersion int `json:"schema_version"`
StageID string `json:"stage_id"`
StageVersion string `json:"stage_version"`
Kind string `json:"kind"`
Summary TurnSummary `json:"summary"`
}
TurnAnnotation is a bounded, versioned stage result. Summary is plain text, never a command, response option, or authority to act.
type TurnSourceAttribution ¶ added in v0.18.0
type TurnSourceAttribution struct {
Kind string `json:"kind,omitempty"`
LogicalAgentID string `json:"logical_agent_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
WorkstreamID string `json:"workstream_id,omitempty"`
LaunchID string `json:"launch_id,omitempty"`
LaunchDisplayName string `json:"launch_display_name,omitempty"`
Runtime string `json:"runtime,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
Confidence string `json:"confidence,omitempty"`
}
type TurnSourceMessage ¶ added in v0.18.0
type TurnSourceMessage struct {
SchemaVersion int `json:"schema_version"`
Origin string `json:"origin"`
EndpointRef string `json:"endpoint_ref"`
Channel string `json:"channel"`
MessageID string `json:"message_id"`
Sequence int64 `json:"sequence"`
SenderURN string `json:"sender_urn"`
OutputID string `json:"output_id,omitempty"`
Attribution TurnSourceAttribution `json:"attribution,omitempty"`
}
TurnSourceMessage identifies a source publication without authenticating its sender. Ordinary publications have no runtime reply target.
type TurnStageTrace ¶ added in v0.18.0
type TurnStageTrace struct {
StageID string `json:"stage_id"`
StageVersion string `json:"stage_version"`
Outcome string `json:"outcome"`
DurationMS int64 `json:"duration_ms"`
FailureCode string `json:"failure_code,omitempty"`
}
TurnStageTrace carries operational metadata, not raw diagnostics or reasoning.
type TurnSummary ¶ added in v0.18.0
type TurnSummary struct {
Text string `json:"text"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package hostclient is how a subprocess plugin calls back into Tangent.
|
Package hostclient is how a subprocess plugin calls back into Tangent. |