platformtools

package
v0.0.0-...-38ed774 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 24 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 (
	SourceLogs                     = "logs"
	SourceMemory                   = "memory"
	SourcePlatform                 = "platform"
	SourceSlack                    = "slack"
	SourceTriggers                 = "triggers"
	ToolNameSearchLogs             = "platform_search_logs"
	ToolNameListTriggers           = "platform_list_triggers"
	ToolNameConfigureTrigger       = "platform_configure_trigger"
	ToolNameMemoryForget           = "platform_memory_forget"
	ToolNameMemoryRecall           = "platform_memory_recall"
	ToolNameMemoryRemember         = "platform_memory_remember"
	ToolNameReadChannelMessages    = "platform_slack_read_channel_messages"
	ToolNameReadThreadMessages     = "platform_slack_read_thread_messages"
	ToolNameReadUserProfile        = "platform_slack_read_user_profile"
	ToolNameSearchChannels         = "platform_slack_search_channels"
	ToolNameSearchMessagesAndFiles = "platform_slack_search_messages_and_files"
	ToolNameSearchUsers            = "platform_slack_search_users"
	ToolNameScheduleMessage        = "platform_slack_schedule_message"
	ToolNameSendMessage            = "platform_slack_send_message"
	ToolNameAddReaction            = "platform_slack_add_reaction"
	ToolNameRemoveReaction         = "platform_slack_remove_reaction"
	ToolNameGetReactions           = "platform_slack_get_reactions"
	ToolNameListReactions          = "platform_slack_list_reactions"
	ToolNameListEmoji              = "platform_slack_list_emoji"
	ToolNameListUserSessions       = "platform_list_user_sessions"
	ToolNameGetUserSession         = "platform_get_user_session"
	ToolNameGetPlatformContext     = "platform_get_platform_context"
	ToolNameListProjects           = "platform_list_projects"
	ToolNameFindMCP                = "platform_find_mcp"
	ToolNameGetMCP                 = "platform_get_mcp"
)
View Source
const AssistantsPlatformToolsetSlug = "assistants"

AssistantsPlatformToolsetSlug is the reserved slug for the platform toolset granted to every assistant runtime.

View Source
const ManagedAssistantPlatformToolsetSlug = "managed-assistant"

ManagedAssistantPlatformToolsetSlug is the reserved slug for the platform toolset granted only to a project's managed assistant (the one powering the dashboard sidebar). It carries tools that must not be reachable by any other assistant.

View Source
const PlatformMCPReadToolsetSlug = "platform"

PlatformMCPReadToolsetSlug is the reserved slug for the platform toolset re-serving the Platform MCP read tools to a project's managed assistant. Granted only when the assistant-platform-mcp rollout flag is on for the organization.

View Source
const ResearchToolsetSlug = "research"

ResearchToolsetSlug is the reserved slug for the MCP research agent's web tools (search and page fetch). No assistant is granted it by default; the research-agent runner attaches it explicitly, and its tools are gated on the mcp_approval feature.

View Source
const SpeakeasySlackPlatformToolsetSlug = "speakeasy-slack"

SpeakeasySlackPlatformToolsetSlug is the reserved slug for the toolset a project's managed assistant replies through when the Speakeasy Slack app routes a workspace to its project. The tools post with that workspace's bot token, resolved on the server per call.

View Source
const (
	ToolNameSkillsLoad = "skills_load"
)

Skill tool names are externally specified by the skills RFC.

Variables

This section is empty.

Functions

func BuildExecutors

func BuildExecutors(deps Dependencies, extras ...ExternalTool) (map[string]PlatformToolExecutor, map[string]string)

BuildExecutors materializes executors for built-in plus caller-supplied platform tools. The second return value maps URN to the required feature gate; absent entries are ungated.

func BuildToolsets

func BuildToolsets(deps ToolsetDependencies) map[string]Toolset

BuildToolsets materializes every registered platform toolset against the supplied dependencies and returns them indexed by slug. Panics on misconfiguration (empty slug or duplicate slug) so registry mistakes surface at startup instead of as runtime 404s.

func CountTools

func CountTools(toolURNs []string, extras ...ExternalTool) int

func FindToolEntries

func FindToolEntries(toolURNs []string, extras ...ExternalTool) []*types.ToolEntry

func FindTypedTools

func FindTypedTools(projectID uuid.UUID, toolURNs []string, extras ...ExternalTool) []*types.Tool

func ListTypedTools

func ListTypedTools(
	ctx context.Context,
	organizationID string,
	projectID uuid.UUID,
	urnPrefix string,
	checker FeatureChecker,
	extras ...ExternalTool,
) []*types.Tool

ListTypedTools enumerates platform tools available to organizationID, excluding any whose required feature flag is disabled. A nil checker grants access to every gated tool.

func PlatformToolsetID

func PlatformToolsetID(slug string) uuid.UUID

PlatformToolsetID returns the stable policy and finding identity for a code-owned Platform MCP toolset.

func PlatformToolsetName

func PlatformToolsetName(slug string) string

PlatformToolsetName returns the dashboard label for a Platform MCP toolset.

func PlatformToolsetURL

func PlatformToolsetURL(base *url.URL, slug string) string

PlatformToolsetURL builds the URL where a runtime reaches the named platform toolset. Keep the path segments in lockstep with the chi route registered by the mcp package.

func PrepareThreadContext

func PrepareThreadContext(ctx context.Context, descriptor ToolDescriptor, env toolconfig.ToolCallEnv, payload io.Reader, resolve ThreadContextResolver) (context.Context, toolconfig.ToolCallEnv, io.Reader, error)

PrepareThreadContext resolves explicit tool targeting without changing caller authentication. Callers can use the returned context for both execution and target attribution. The returned reader preserves the original payload, including thread_id, for gateway schema validation. Only the executor wrapper strips it. Repeated preparation preserves an already selected target.

Types

type Dependencies

type Dependencies struct {
	Logger           *slog.Logger
	DB               *pgxpool.Pool
	TelemetryService TelemetryService
	TriggerApp       *bgtriggers.App
	SlackHTTPClient  *guardian.HTTPClient
	Audit            *audit.Logger

	// Encryption seals the payload behind minted asset download URLs.
	Encryption *encryption.Client

	// ServerURL is the public base URL minted download URLs point at.
	ServerURL *url.URL
}

type ExternalTool

type ExternalTool struct {
	Executor        PlatformToolExecutor
	RequiredFeature string // empty string = always available

	// RequiredScope hides the tool from callers that do not hold this
	// authorization scope (an authz.Scope value) on the active project, so an
	// assistant is not offered a tool every call to which would be refused.
	// Empty means no scope beyond toolset access. It is a string because this
	// package cannot import authz without a cycle through mv.
	RequiredScope string
}

type FeatureChecker

type FeatureChecker func(ctx context.Context, organizationID string, feature string) bool

FeatureChecker reports whether a product feature is enabled for an organization. Features are referenced by string name to avoid a productfeatures import cycle through openrouter -> productfeatures -> auth -> mv -> platformtools.

type PlatformToolExecutor

type PlatformToolExecutor = core.PlatformToolExecutor

func WithThreadFallback

func WithThreadFallback(tool PlatformToolExecutor, resolve ThreadContextResolver) PlatformToolExecutor

WithThreadFallback adds explicit thread selection without changing the tool's automatic assistant behavior or its authorization checks. Use DescriptorForContext when listing the wrapped tool to callers.

type TelemetryService

type TelemetryService = logs.TelemetryService

type ThreadContextResolver

type ThreadContextResolver func(ctx context.Context, threadID uuid.UUID, write bool) (contextvalues.AssistantPrincipal, string, error)

ThreadContextResolver resolves an explicitly selected thread under the caller's existing authorization. It must not replace the caller's auth context or actor. The returned chat ID supplies the same conversation metadata as automatic calls. ThreadContextResolver selects a thread; write is true when the tool can change state.

type ToolDescriptor

type ToolDescriptor = core.ToolDescriptor

func DescriptorForContext

func DescriptorForContext(ctx context.Context, descriptor ToolDescriptor) ToolDescriptor

DescriptorForContext returns an independent schema for this request. Shared descriptors and schemas are never mutated, including across concurrent callers.

func FindToolDescriptor

func FindToolDescriptor(toolURN urn.Tool, extras ...ExternalTool) (ToolDescriptor, bool)

func ListPlatformTools

func ListPlatformTools(extras ...ExternalTool) []ToolDescriptor

ListPlatformTools returns descriptors without applying feature gates; callers that need per-org gating should use ListTypedTools instead.

type Toolset

type Toolset struct {
	Slug  string
	Tools []ExternalTool

	// ActingContext, when set, returns the context a request to this toolset
	// both lists and calls its tools in. Nil means the authenticated request
	// context is used as is.
	ActingContext func(ctx context.Context) (context.Context, error)
}

Toolset is a virtual collection of platform tools exposed at runtime via a dedicated MCP endpoint. Platform toolsets are not persisted; the slug is hardcoded per consumer and wired in code at process startup.

func NewAssistantsToolset

func NewAssistantsToolset(tools ...ExternalTool) Toolset

NewAssistantsToolset returns the assistants platform toolset bound to the supplied tools. Exposed for tests and direct callers; production wiring goes through BuildToolsets.

func NewManagedAssistantToolset

func NewManagedAssistantToolset(tools ...ExternalTool) Toolset

NewManagedAssistantToolset returns the platform toolset granted only to a project's managed assistant. Exposed for tests and direct callers; production wiring goes through BuildToolsets.

func NewPlatformMCPReadToolset

func NewPlatformMCPReadToolset(tools ...ExternalTool) Toolset

NewPlatformMCPReadToolset returns the platform toolset re-serving the Platform MCP read tools to a project's managed assistant. Exposed for tests and direct callers; production wiring goes through BuildToolsets.

type ToolsetDependencies

type ToolsetDependencies struct {
	AssistantMemoryTools          []ExternalTool
	AssistantSkillTools           []ExternalTool
	AssistantTriggerTools         []ExternalTool
	ManagedAssistantInsightsTools []ExternalTool
	PlatformMCPReadTools          []ExternalTool

	// PlatformMCPReadActingContext is the Platform MCP read toolset's
	// ActingContext.
	PlatformMCPReadActingContext func(ctx context.Context) (context.Context, error)
	SpeakeasySlackTools          []ExternalTool
}

ToolsetDependencies bundles the inputs required to materialize the static platform toolset registry. Add a field here when a new toolset needs an external service or pre-built tool slice.

Directories

Path Synopsis
Package changelog exposes the public Speakeasy platform changelog as a read-only platform tool for the project's managed assistant.
Package changelog exposes the public Speakeasy platform changelog as a read-only platform tool for the project's managed assistant.
Package docs exposes the public Speakeasy AI control plane documentation (speakeasy.com/docs/ai-control-plane) as read-only platform tools for the project's managed assistant.
Package docs exposes the public Speakeasy AI control plane documentation (speakeasy.com/docs/ai-control-plane) as read-only platform tools for the project's managed assistant.
Package memory implements the gram://memory/* platform tools that wrap the MemoryService for use by assistant agents at runtime.
Package memory implements the gram://memory/* platform tools that wrap the MemoryService for use by assistant agents at runtime.
Package platform re-serves the Platform MCP read tools (server/internal/platformmcp) as platform tools on the assistant runtime channel.
Package platform re-serves the Platform MCP read tools (server/internal/platformmcp) as platform tools on the assistant runtime channel.
Package research provides the MCP research agent's web tools: search and page fetch.
Package research provides the MCP research agent's web tools: search and page fetch.

Jump to

Keyboard shortcuts

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