Forge documentation
Library referenceGo

github.com/l1fe-labs/forge-go/core

Go core package.

Go core package.

Package contract

FieldValue
Languagego
Source versionmodule source snapshot
Manifestforge-go/go.mod
Source files16
EvidenceSource reference; registry publication and runtime conformance are separate checks

Import boundary

import "github.com/l1fe-labs/forge-go/core"

Use a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.

Source reference

Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.

brew.go

Read declaration text · 18 declaration entries

type BrewNodeKindType string

const (
BrewNodeKindAgentStep         BrewNodeKindType;

type BrewNodeKind struct

func NewAgentStepNode(provider ProviderRef, systemPrompt string, maxSteps uint32) BrewNodeKind

func NewToolInvocationNode(toolID string, tier ToolTier) BrewNodeKind

func NewMcpCallNode(serverID, toolName string) BrewNodeKind

func NewWebOperationNode(operation string) BrewNodeKind

func NewConditionalBranchNode(conditionExpr, trueTarget, falseTarget string) BrewNodeKind

func NewParallelForkNode(branches []string, joinMode JoinMode) BrewNodeKind

func NewSubBrewRefNode(brewID string) BrewNodeKind

func NewHumanCheckpointNode(prompt string, timeoutMs *uint64) BrewNodeKind

type JoinMode string

const (
// JoinModeAwaitAll waits for all branches to complete. Fail if any branch fails.
JoinModeAwaitAll JoinMode;

func JoinModeFirstN(n uint32) JoinMode

type BrewEdgeKind string

const (
// BrewEdgeKindDataFlow means the output of source is fed as input to target.
BrewEdgeKindDataFlow BrewEdgeKind;

type BrewEdge struct

type BrewNode struct

type Brew struct

func (b *Brew) SortedNodeIDs() []string

func (b *Brew) SortedEdges() []BrewEdge

brew_builder.go

Read declaration text · 9 declaration entries

type BrewBuilder struct

func NewBrewBuilder(id, version string) *BrewBuilder

func (b *BrewBuilder) AddNode(nodeID string, kind BrewNodeKind) *BrewBuilder

func (b *BrewBuilder) AddEdge(from, to string, kind BrewEdgeKind) *BrewBuilder

func (b *BrewBuilder) SetEntry(nodeID string) *BrewBuilder

func (b *BrewBuilder) SetExit(nodeID string) *BrewBuilder

func (b *BrewBuilder) WithTopology(topology *ModelTopology) *BrewBuilder

func (b *BrewBuilder) WithMetadata(nodeID, key, value string) *BrewBuilder

func (b *BrewBuilder) Build() (*Brew, error)

brew_resolver.go

Read declaration text · 8 declaration entries

type BrewEnvironment struct

type BrewResolutionErrorKind string

const (
// BrewResolutionProviderUnavailable means a provider reference is not registered.
BrewResolutionProviderUnavailable BrewResolutionErrorKind;

type BrewResolutionError struct

func (e *BrewResolutionError) Error() string

type BrewResolutionErrors struct

func (e *BrewResolutionErrors) Error() string

type ResolvedBrewPlan struct

func ResolveBrew(brew *Brew, env *BrewEnvironment) (*ResolvedBrewPlan, error)

config.go

Read declaration text · 14 declaration entries

type GenerateOptions struct

func (o GenerateOptions) WithTemperature(t float64) GenerateOptions

func (o GenerateOptions) WithMaxTokens(n int) GenerateOptions

func (o GenerateOptions) WithTopP(p float64) GenerateOptions

func (o GenerateOptions) WithTopK(k int) GenerateOptions

func (o GenerateOptions) WithFrequencyPenalty(p float64) GenerateOptions

func (o GenerateOptions) WithPresencePenalty(p float64) GenerateOptions

func (o GenerateOptions) WithStopSequences(seqs ...string) GenerateOptions

func (o GenerateOptions) WithSeed(seed int64) GenerateOptions

func (o GenerateOptions) WithResponseFormat(format string) GenerateOptions

func (o GenerateOptions) WithSchema(schema *JsonSchema) GenerateOptions

type EmbedOptions struct

func (o EmbedOptions) WithModel(model string) EmbedOptions

func (o EmbedOptions) WithDimensions(d int) EmbedOptions

error.go

Read declaration text · 23 declaration entries

type ErrKind string

const (
// ErrKindProvider indicates a provider-related error (network, auth, rate limit).
ErrKindProvider ErrKind;

type ForgeError struct

func (e *ForgeError) Error() string

func (e *ForgeError) Unwrap() error

func (e *ForgeError) Is(target error) bool

func (e *ForgeError) WithContext(key, value string) *ForgeError

func NewProviderError(providerRef, message string, cause error) *ForgeError

func NewProviderUnavailableError(providerRef, reason string) *ForgeError

func NewProviderAuthenticationError(providerRef, reason string) *ForgeError

func NewCapabilityUnsupportedError(providerRef string, capability RuntimeCapability) *ForgeError

func NewProviderNegotiationError(providerRef, reason string) *ForgeError

func NewProviderSessionExpiredError(providerRef, sessionID string) *ForgeError

func NewProviderInterruptUnsupportedError(providerRef string) *ForgeError

func NewProviderResumeUnsupportedError(providerRef string) *ForgeError

func NewValidationError(message string) *ForgeError

func NewToolError(toolName, message string, cause error) *ForgeError

func NewIdentityError(operation, message string, cause error) *ForgeError

func NewAuthError(agentDID, actID, message string) *ForgeError

func NewLifecycleError(from, to, message string) *ForgeError

func NewSchemaError(path, message string) *ForgeError

func NewSerializationError(message string, cause error) *ForgeError

func NewTimeoutError(operation string, cause error) *ForgeError

func NewCancelledError(operation string) *ForgeError

message.go

Read declaration text · 21 declaration entries

type Role string

const (
// RoleSystem is the system instruction role.
RoleSystem Role;

func (r Role) String() string

func (r Role) IsValid() bool

type MessagePartType string

const (
// MessagePartText is a text content part.
MessagePartText MessagePartType;

type MessagePart struct

func NewTextPart(text string) MessagePart

func NewImagePart(url, mimeType string) MessagePart

func NewToolCallPart(tc ToolCall) MessagePart

func NewToolResultPart(tr ToolResult) MessagePart

type ModelMessage struct

func NewModelMessage(role Role, parts ...MessagePart) ModelMessage

func NewTextMessage(role Role, text string) ModelMessage

func NewSystemMessage(text string) ModelMessage

func NewUserMessage(text string) ModelMessage

func NewAssistantMessage(text string) ModelMessage

func (m ModelMessage) TextContent() string

func (m ModelMessage) ToolCalls() []ToolCall

func (m ModelMessage) ToolResults() []ToolResult

func (m ModelMessage) HasToolCalls() bool

func (m ModelMessage) MarshalJSON() ([]byte, error)

func (m *ModelMessage) UnmarshalJSON(data []byte) error

model.go

Read declaration text · 1 declaration entries

type LanguageModel interface

output.go

Read declaration text · 13 declaration entries

type FinishReason string

const (
// FinishReasonStop indicates the model generated a natural stop token.
FinishReasonStop FinishReason;

func (f FinishReason) String() string

type Usage struct

func (u Usage) Add(other Usage) Usage

type GenerateResult struct

func (r *GenerateResult) Text() string

func (r *GenerateResult) HasToolCalls() bool

type StreamChunkType string

const (
// StreamChunkTextDelta is an incremental text fragment.
StreamChunkTextDelta StreamChunkType;

type StreamChunk struct

func NewTextDelta(text string) StreamChunk

func NewToolCallDelta(callID, name, argsDelta string) StreamChunk

func NewStreamDone(reason FinishReason, usage Usage) StreamChunk

func NewStreamError(err error) StreamChunk

provider.go

Read declaration text · 22 declaration entries

type ProviderRef struct

func ParseProviderRef(ref string) (ProviderRef, error)

func (p ProviderRef) String() string

type ProviderMetadata struct

type RuntimeCapability string

const (
RuntimeCapabilityToolCalls           RuntimeCapability;

type ProviderRuntimeCapabilities struct

func BaselineProviderRuntimeCapabilities() ProviderRuntimeCapabilities

func (c ProviderRuntimeCapabilities) WithCapability(capability RuntimeCapability) ProviderRuntimeCapabilities

func (c ProviderRuntimeCapabilities) Supports(capability RuntimeCapability) bool

type ProviderNegotiationRequest struct

type ProviderNegotiationResult struct

type ProviderFactory func(ref ProviderRef) (LanguageModel, error)

// ProviderRegistry manages the set of available language model providers.
//
// Providers are registered by namespace. When an agent needs a model,
// it resolves a ProviderRef against the registry to get a LanguageModel.
//
// The registry is safe for concurrent use.
//
// ANVIL Spec Section 4.6 -- Provider registry and dispatch.
type ProviderRegistry struct

type ProviderRegistry struct

func NewProviderRegistry() *ProviderRegistry

func (r *ProviderRegistry) Register(namespace string, factory ProviderFactory, meta ProviderMetadata)

func (r *ProviderRegistry) RegisterWithRuntime(
namespace string,
factory ProviderFactory,
meta ProviderMetadata,
runtime ProviderRuntimeCapabilities,
)

func (r *ProviderRegistry) Resolve(ref ProviderRef) (LanguageModel, error)

func (r *ProviderRegistry) ResolveString(ref string) (LanguageModel, error)

func (r *ProviderRegistry) Metadata(namespace string) (ProviderMetadata, bool)

func (r *ProviderRegistry) Namespaces() []string

func (r *ProviderRegistry) Has(namespace string) bool

func (r *ProviderRegistry) Negotiate(request ProviderNegotiationRequest) (ProviderNegotiationResult, error)

provider_official.go

Read declaration text · 37 declaration entries

type ProviderFamily string

const (
ProviderFamilyCodingProduct ProviderFamily;

type AuthStrategy string

const (
AuthStrategyAPIKey              AuthStrategy;

type ProviderPreset struct

func ApprovedCodingProviderPresets() []ProviderPreset

func ApprovedDirectProviderPresets() []ProviderPreset

func ApprovedGatewayProviderPresets() []ProviderPreset

func RegisterOfficialCodingProviders(registry *ProviderRegistry) error

func RegisterDefaultCoreDirectProviders(registry *ProviderRegistry) error

func RegisterClaudeCodeProvider(registry *ProviderRegistry) (string, error)

func RegisterCodexProvider(registry *ProviderRegistry) (string, error)

func RegisterKimiCodingProvider(registry *ProviderRegistry) (string, error)

func RegisterGLMCodingProvider(registry *ProviderRegistry) (string, error)

func RegisterMiniMaxCodingProvider(registry *ProviderRegistry) (string, error)

func RegisterOpenAIModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterAnthropicModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterGoogleModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterXAIModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterDeepSeekModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterMistralModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterCohereModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterGroqModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterMoonshotModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterZAIModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterMiniMaxModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterOpenRouterModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterFoundryModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterBedrockModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterVertexAIModel(registry *ProviderRegistry, modelID string) (string, error)

func RegisterMicrosoftFoundryModel(registry *ProviderRegistry, modelID string) (string, error)

func (m *officialProviderModel) Generate(ctx context.Context, messages []ModelMessage, tools []ToolDefinition, options GenerateOptions) (*GenerateResult, error)

func (m *officialProviderModel) Stream(ctx context.Context, messages []ModelMessage, tools []ToolDefinition, options GenerateOptions) (<-chan StreamChunk, error)

func (m *officialProviderModel) ModelID() string

func (m *officialProviderModel) Provider() string

func (m *officialProviderModel) SupportsTools() bool

func (m *officialProviderModel) SupportsImages() bool

func (m *officialProviderModel) SupportsStreaming() bool

func (m *officialProviderModel) SupportsObjectGeneration() bool

routing.go

Read declaration text · 9 declaration entries

type TaskMode string

const (
// TaskModePlanning represents strategic reasoning, goal decomposition, plan generation.
TaskModePlanning TaskMode;

func (m TaskMode) AsRoleName() string

type ExecutionTopology string

const (
// ExecutionTopologySequential is a single sequential call.
ExecutionTopologySequential ExecutionTopology;

type RoutingContext struct

type ResolvedRoute struct

type ModelRouter interface

type DefaultModelRouter struct

func (r DefaultModelRouter) Name() string

func (r DefaultModelRouter) Route(ctx *RoutingContext, topology *ModelTopology) (ResolvedRoute, error)

schema.go

Read declaration text · 20 declaration entries

type SchemaType string

const (
SchemaTypeString  SchemaType;

type JsonSchema struct

func ObjectSchema(description string, properties map[string]*JsonSchema, required []string) *JsonSchema

func StringSchema(description string) *JsonSchema

func NumberSchema(description string) *JsonSchema

func IntegerSchema(description string) *JsonSchema

func BooleanSchema(description string) *JsonSchema

func ArraySchema(description string, items *JsonSchema) *JsonSchema

func NullSchema(description string) *JsonSchema

func (s *JsonSchema) WithMinLength(n int) *JsonSchema

func (s *JsonSchema) WithMaxLength(n int) *JsonSchema

func (s *JsonSchema) WithMinimum(v float64) *JsonSchema

func (s *JsonSchema) WithMaximum(v float64) *JsonSchema

func (s *JsonSchema) WithMinItems(n int) *JsonSchema

func (s *JsonSchema) WithMaxItems(n int) *JsonSchema

func (s *JsonSchema) WithEnum(values ...any) *JsonSchema

func (s *JsonSchema) WithDefault(v any) *JsonSchema

func (s *JsonSchema) WithNoAdditionalProperties() *JsonSchema

func (s *JsonSchema) Validate(value any, path string) error

func (s *JsonSchema) ValidateJSON(data []byte) error

telemetry.go

Read declaration text · 19 declaration entries

type SpanStatus string

const (
// SpanStatusOK indicates the operation completed successfully.
SpanStatusOK SpanStatus;

type SpanAttribute struct

func NewSpanAttribute(key, value string) SpanAttribute

type ForgeSpan struct

func (s ForgeSpan) Duration() time.Duration

type ForgeEvent struct

type TelemetryEmitter interface

type NoopEmitter struct

func (NoopEmitter) EmitSpan(_ ForgeSpan)

func (NoopEmitter) EmitEvent(_ ForgeEvent)

func (NoopEmitter) Flush()

type InMemoryEmitter struct

func NewInMemoryEmitter() *InMemoryEmitter

func (e *InMemoryEmitter) EmitSpan(span ForgeSpan)

func (e *InMemoryEmitter) EmitEvent(event ForgeEvent)

func (e *InMemoryEmitter) Flush()

func (e *InMemoryEmitter) Spans() []ForgeSpan

func (e *InMemoryEmitter) Events() []ForgeEvent

func (e *InMemoryEmitter) Reset()

tool.go

Read declaration text · 19 declaration entries

type ToolTier int

const (
// ToolTierPlatform (Tier 1) tools run inside the sandbox and are always
// available without authorization. Examples: clock, crypto, logging, random.
ToolTierPlatform ToolTier;

func (t ToolTier) String() string

func (t ToolTier) RequiresAuthorization() bool

func (t ToolTier) MarshalJSON() ([]byte, error)

func (t *ToolTier) UnmarshalJSON(data []byte) error

type ToolDefinition struct

func NewToolDefinition(name, description string, tier ToolTier, parameters *JsonSchema) (ToolDefinition, error)

type ToolCall struct

func (tc ToolCall) ParseArguments(target any) error

type ToolResult struct

func NewToolResult(callID, content string) ToolResult

func NewToolResultError(callID, errMsg string) ToolResult

type ToolApproval struct

type ApprovalDecision int

const (
// ApprovalApprove allows the tool call to proceed as-is.
ApprovalApprove ApprovalDecision;

func (d ApprovalDecision) String() string

func Approve() ToolApproval

func Deny(reason string) ToolApproval

func Modify(modifiedArgs string) ToolApproval

type ToolApprovalHandler func(call ToolCall, def ToolDefinition) ToolApproval

topology.go

Read declaration text · 25 declaration entries

const DefaultRole;

type CostPreference string

const (
// CostPreferenceMinimize prefers the cheapest model that satisfies requirements.
CostPreferenceMinimize CostPreference;

type LatencyPreference string

const (
// LatencyPreferenceLow prefers the lowest-latency model.
LatencyPreferenceLow LatencyPreference;

type ModelSlot struct

type ModelTopology struct

func NewSingleTopology(provider ProviderRef) *ModelTopology

func (t *ModelTopology) Name() string

func (t *ModelTopology) DefaultRoleName() string

func (t *ModelTopology) DefaultSlot() ModelSlot

func (t *ModelTopology) SlotForRole(role string) ModelSlot

func (t *ModelTopology) Slots() map[string]ModelSlot

func (t *ModelTopology) SortedRoles() []string

func (t *ModelTopology) HasRole(role string) bool

func (t *ModelTopology) SlotCount() int

func (t *ModelTopology) AllProviderRefs() []ProviderRef

type TopologyBuilder struct

func NewTopologyBuilder() *TopologyBuilder

func (b *TopologyBuilder) Name(name string) *TopologyBuilder

func (b *TopologyBuilder) Slot(role string, primary ProviderRef) *TopologyBuilder

func (b *TopologyBuilder) WithFallback(role string, fallback ProviderRef) *TopologyBuilder

func (b *TopologyBuilder) WithRequiredCapability(role string, cap RuntimeCapability) *TopologyBuilder

func (b *TopologyBuilder) WithCostPreference(role string, pref CostPreference) *TopologyBuilder

func (b *TopologyBuilder) WithLatencyPreference(role string, pref LatencyPreference) *TopologyBuilder

func (b *TopologyBuilder) WithScopeNarrowing(role string, scopes []string) *TopologyBuilder

func (b *TopologyBuilder) Build() (*ModelTopology, error)

types.go

Read declaration text · 20 declaration entries

type AgentDID struct

func NewAgentDID(did string) (AgentDID, error)

func NewCanonicalAgentDID(did string) (AgentDID, error)

func (d AgentDID) String() string

func (d AgentDID) IsZero() bool

func (d AgentDID) Namespace() string

func (d AgentDID) Kind() string

func (d AgentDID) Identifier() string

type Timestamp struct

func Now() Timestamp

func NewTimestamp(t time.Time) Timestamp

func ParseTimestamp(s string) (Timestamp, error)

func (ts Timestamp) Time() time.Time

func (ts Timestamp) String() string

func (ts Timestamp) IsZero() bool

func (ts Timestamp) Before(other Timestamp) bool

func (ts Timestamp) After(other Timestamp) bool

func (ts Timestamp) Since() time.Duration

func (ts Timestamp) MarshalJSON() ([]byte, error)

func (ts *Timestamp) UnmarshalJSON(data []byte) error

Continue

On this page