// Package extension composes trusted, code-registered Builtin provider
// Extensions for the server registry.
//
// An Extension is the bootstrap-time assembly of three independently-owned
// facets: the Agent-visible Definition catalog (what the Extension is), the
// trusted Implementation (how Actions execute), and the server-only
// Distribution (which product App ships it). Only the Definition and the
// implementation revision participate in the registry digest; Distribution is
// product routing and never enters execution identity.
package extension

import (
	"github.com/tidbcloud/AgentTeam/internal/extension/registry"
	"github.com/tidbcloud/AgentTeam/internal/extension/runner"
)

// Extension is one trusted Builtin registration unit.
type Extension struct {
	// Definition is the Agent-visible catalog registered in the registry.
	Definition registry.Definition

	// Implementation is the trusted execution facet: executor, revision,
	// connection policy, credential contract, and credential validation.
	Implementation runner.Implementation

	// Distribution maps the Extension to the product App that ships it.
	Distribution Distribution
}

// Distribution is the server-only product mapping of a provider Extension: the
// Marketplace App identity it is installed through and the default
// workspace-visible selection. It must stay in sync with the App seed
// migration and the product App registry; the providers contract test asserts
// that consistency.
type Distribution struct {
	// AppID is the fixed Marketplace App identifier (for example
	// "app_todoist").
	AppID string

	// AppSlug is the fixed App slug (for example "todoist").
	AppSlug string

	// DefaultName is the default workspace-visible Extension selection name
	// for the App's capability entry.
	DefaultName string

	// DefaultEnabled reports whether the App's capability entry enables the
	// Extension selection by default on install.
	DefaultEnabled bool

	// IconURL is the App avatar path under web/public.
	IconURL string

	// GenericProviderConnection opts this App into the browser's generic,
	// field-driven provider connection form. The zero value is deliberately
	// closed; the projected domain always comes from Definition.Domain.
	GenericProviderConnection bool
}
