artifactcontent

package
v1.30.13 Latest Latest
Warning

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

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

Documentation

Overview

Package artifactcontent contains the transport-neutral seam for tool results that carry protocol-native binary content. A driver exposes the content through tools.ArtifactContentResult; this package persists each binary part and returns the driver's metadata-only projection.

Index

Constants

View Source
const (
	// DefaultMaxBytesPerPart is the defensive upper bound for one
	// protocol-native binary part. It prevents one malformed result from
	// turning the materializer into an unbounded allocation/write path.
	// Deployments may impose a stricter limit in their ArtifactStore.
	DefaultMaxBytesPerPart int64 = 64 << 20

	// DefaultMaxBytesPerResult bounds the aggregate binary payload in one
	// ToolResult. Keeping a separate aggregate bound prevents a result with
	// many individually valid parts from bypassing the per-part ceiling.
	DefaultMaxBytesPerResult int64 = 128 << 20
)

Variables

View Source
var (
	// ErrStoreUnavailable means a binary result reached a path with no
	// ArtifactStore. Returning the raw value would violate the planner
	// boundary, so callers must fail closed.
	ErrStoreUnavailable = errors.New("artifact content: ArtifactStore is required for binary tool output")
	// ErrTooLarge means a protocol-native result exceeded the materializer's
	// bounded write budget. The result is refused rather than truncated.
	ErrTooLarge = errors.New("artifact content: binary tool output exceeds the materialization limit")
	// ErrInvalidResult means a driver violated the content-result contract,
	// such as returning a different number of refs than candidates or leaving
	// a raw candidate in its projected value.
	ErrInvalidResult = errors.New("artifact content: invalid projected tool result")
	// ErrEmptyPart means a driver returned a binary content block without
	// any bytes. Empty binary blocks are refused instead of creating an
	// apparently valid artifact that cannot be rendered or downloaded.
	ErrEmptyPart = errors.New("artifact content: binary content part is empty")
)

Functions

func Materialize

func Materialize(ctx context.Context, store artifacts.ArtifactStore, scope artifacts.ArtifactScope, value any, provenance string) (projected any, err error)

Materialize stores every binary candidate in value under scope and returns the driver's metadata-only projection. Non-implementing values pass through unchanged. The function is deliberately independent of MCP or any concrete tool driver; MCP, A2A, and future protocol adapters can implement the same tools.ArtifactContentResult seam.

Ordering is deterministic: candidates are walked in the value's declared order, receive a stable content_index, and are handed back to the driver in that same order. One timestamp is used for the whole result so a session manifest never depends on sub-millisecond Put timing. Resource links and other references are not candidates and are never fetched.

Identity is checked before the first write. The ArtifactStore scope is the session's (tenant, user, session) triple; scope.TaskID is provenance only. Cancellation is checked before each write and before projection. A storage error is returned as-is with context, never replaced by a truncated or raw fallback. ArtifactStore has no transaction/rollback contract; if a later part fails, earlier content-addressed writes may remain in the session manifest. They are identity-scoped and deduplicated on retry.

Types

This section is empty.

Jump to

Keyboard shortcuts

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