moduleapi

package
v0.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 27 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

Overview

Package moduleapi defines the compile-time contract between the Node runtime and optional native feature modules under modules/*/node.

Core packages never import concrete feature modules; an explicit assembly package (such as internal/assembly/host) constructs an Assembly and passes it to node.StartWithOptions.

Index

Constants

View Source
const (
	// ConnectorHTTPDefaultTimeout is applied when HTTPRequest.Timeout is zero.
	ConnectorHTTPDefaultTimeout = 15 * time.Second
	// ConnectorHTTPMaxTimeout caps HTTPRequest.Timeout regardless of caller input.
	ConnectorHTTPMaxTimeout = 30 * time.Second
	// ConnectorHTTPMaxRequestBytes caps outbound connector HTTP request bodies.
	ConnectorHTTPMaxRequestBytes = 1 << 20 // 1 MiB
	// ConnectorHTTPMaxResponseBytes caps inbound connector HTTP response bodies.
	ConnectorHTTPMaxResponseBytes = 2 << 20 // 2 MiB
)
View Source
const (
	EventTurnCompleted      = "turn.completed"
	EventChannelWSStatus    = "channel.ws.status"
	EventWorkDeliveryQueued = "work.delivery.queued"
)

Standard domain event names shared between Harness, native modules, and plugins.

View Source
const (
	WakeMissedSkip     = store.WakeMissedSkip
	WakeMissedCoalesce = store.WakeMissedCoalesce
)
View Source
const MaxProjectSessions = 32

MaxProjectSessions bounds one Host.ListProjectSessions call.

Variables

This section is empty.

Functions

func BuildCustomTool

func BuildCustomTool(spec ToolSpec, instruction string, execute func(context.Context, canonical.ToolRequest) engine.ToolResult) (engine.Tool, error)

BuildCustomTool constructs an engine.Tool directly from a ToolSpec and custom execution hooks (used by modules such as code-index workflows, OCR listing, and memory).

func ConnectionServices

func ConnectionServices(a Assembly) (DatabaseExecutor, SSHFactory)

ConnectionServices retains the connection-only view of assembly resolution.

func WithCallEnvironment

func WithCallEnvironment(ctx context.Context, host Host, projectPath string) context.Context

Types

type ApprovalPendingEvent

type ApprovalPendingEvent struct {
	Session   protocol.SessionID
	Turn      protocol.TurnID
	Approval  protocol.ConversationApproval
	Tool      string
	Arguments json.RawMessage
}

ApprovalPendingEvent carries a newly pending tool approval waiting on user confirmation in a session.

type ApprovalPendingObserver

type ApprovalPendingObserver interface {
	OnApprovalPending(ctx context.Context, host Host, event ApprovalPendingEvent)
}

ApprovalPendingObserver is an optional module interface notified when a tool call pauses waiting for interactive user approval.

type ArtifactViewProvider

type ArtifactViewProvider interface {
	ArtifactViews() []BuiltInArtifactView
}

ArtifactViewProvider is optionally implemented by native modules that ship document renderers. A module can keep old versions registered for replay.

type Assembly

type Assembly struct {
	// SystemPrompt replaces the default product instructions for main and
	// delegated turns. An empty value selects the Harness default.
	SystemPrompt string
	// Nil and empty lists select no packages.
	BundledDefaults []plugins.DefaultPackage
	// BundledPackages is immutable and rooted at plugins/<name>, with plugins/catalog.json.
	BundledPackages fs.FS
	CodeIndex       codeindexapi.Factory
	// Databases overrides the selected database executor when non-nil.
	Databases DatabaseExecutor
	// SSH overrides the selected SSH provider's factory when non-nil.
	SSH SSHFactory
	// Terminal overrides the selected terminal provider's factory when non-nil.
	Terminal TerminalFactory
	// Deprecated: retained for source compatibility. Workspace modules must
	// register their own handlers through WorkspaceServiceProvider.
	LegacyWorkspaceModules bool
	// DisableManagementRoutes excludes the shared hooks and remote host/runtime
	// administration commands from this product. Existing assemblies retain them.
	DisableManagementRoutes bool
	Modules                 []Module
}

Assembly selects the compile-time Node modules and optional services.

func (Assembly) ArtifactViewFor

func (a Assembly) ArtifactViewFor(reference protocol.PluginReference) (BuiltInArtifactView, bool)

ArtifactViewFor only matches the recorded native reference; a package with the same name still uses the assets from its own captured revision.

func (Assembly) CommandHandlerFor

func (a Assembly) CommandHandlerFor(kind string) CommandHandler

CommandHandlerFor returns the assembled module owning the given protocol command kind, if any.

func (Assembly) CommandModuleFor

func (a Assembly) CommandModuleFor(kind string) (Module, CommandHandler)

CommandModuleFor returns both the assembled Module and CommandHandler owning the given protocol command kind, if any.

func (Assembly) DirectoryDiscussions

func (a Assembly) DirectoryDiscussions() (store.DirectoryDiscussions, error)

DirectoryDiscussions resolves the immutable product contributions at startup. Only one module may authorize a private association.

func (Assembly) HasModule

func (a Assembly) HasModule(id string) bool

HasModule reports presence by identity, independently of service availability.

func (Assembly) LookupTool

func (a Assembly) LookupTool(name string) (ToolMeta, bool)

LookupTool resolves presentation metadata for a canonical module tool name or its legacy plugin/MCP alias.

func (Assembly) NativeSkillPackages

func (a Assembly) NativeSkillPackages() []operations.NativeSkillPackage

NativeSkillPackages returns the skill trees contributed by assembled modules.

func (Assembly) NativeSkills

func (a Assembly) NativeSkills() []protocol.NativeSkill

NativeSkills returns the protocol-facing metadata of all built-in module skills.

func (Assembly) ReadOnlyConversation

func (a Assembly) ReadOnlyConversation(association protocol.ConversationAssociation) bool

ReadOnlyConversation lets a module retain the history of a retired feature.

func (Assembly) ReplacesPlugin

func (a Assembly) ReplacesPlugin(name string) bool

ReplacesPlugin reports whether any assembled module supersedes the tool declarations of the named legacy plugin package.

func (Assembly) ResolveServices

func (a Assembly) ResolveServices() ResolvedServices

ResolveServices selects the first provider of each factory in assembly order. A legacy factory override can accompany a typed provider or an old named module; alone it does not enable a service (except the standalone code index).

type BrowserToolConfig

type BrowserToolConfig struct {
	Spec         ToolSpec
	Instruction  string
	PluginGate   string
	PrepareArgs  func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult func(ctx context.Context, result engine.ToolResult) engine.ToolResult
}

BrowserToolConfig configures one built-in controller browser tool.

type BuiltInArtifactView

type BuiltInArtifactView struct {
	Reference protocol.PluginReference
	View      protocol.ArtifactView
	Tree      fs.FS
}

BuiltInArtifactView pairs an immutable native artifact owner with its view declaration and embedded resources. It does not grant artifact access.

type BuiltInSkill

type BuiltInSkill struct {
	Package string
	Skill   protocol.PluginSkill
	Tree    fs.FS
}

BuiltInSkill describes a compile-time skill bundled inside a native module.

type CatalogSpec

type CatalogSpec struct {
	Instructions string     `json:"instructions,omitempty"`
	Tools        []ToolSpec `json:"tools"`
}

CatalogSpec pairs optional module-level instructions with its tool specs.

func LoadCatalog

func LoadCatalog(raw []byte) (CatalogSpec, error)

LoadCatalog decodes an embedded module tool catalog and fills default policy, presentation and grouping values.

type ChannelAdapter

type ChannelAdapter interface {
	TaskEventSink
	Provider() string
}

ChannelAdapter reserves the clean Node-side integration boundary for future third-party chat/issue bots (Feishu, GitHub Issues, Linear, Jira) without coupling core task state machines to any external transport.

type CodeIndexServiceProvider

type CodeIndexServiceProvider interface {
	NewCodeIndexService(string, codeindexapi.Watch) codeindexapi.Service
}

type CommandHandler

type CommandHandler interface {
	CommandPolicies
	ExecuteCommand(ctx context.Context, host Host, caller protocol.NodeID, request protocol.Request) (protocol.Output, []protocol.Event, error)
}

CommandHandler is optionally implemented by native modules that own direct Node protocol commands (such as native memory catalog CRUD).

type CommandPolicies

type CommandPolicies interface {
	RegisteredCommands() map[string]CommandPolicy
}

CommandPolicies is implemented by direct command handlers and optionally by services that declare the policy of their module-scoped actions.

type CommandPolicy

type CommandPolicy struct {
	ConfigurationWrite bool
}

CommandPolicy describes a command or native service action at registration.

type ConfigurationReader

type ConfigurationReader interface {
	RoleKeys() (map[string]string, error)
	Values(prefix string) (map[string]ConfigurationValue, error)
}

Keys are personal to the current user and constrained to the registered module.

type ConfigurationSyncParticipant

type ConfigurationSyncParticipant interface {
	ExportConfiguration(context.Context, ConfigurationReader) (json.RawMessage, error)
	ApplyConfiguration(context.Context, ConfigurationWriter, json.RawMessage) error
}

ConfigurationSyncParticipant contributes one versioned JSON section to a user's configuration. Missing source sections are delivered as nil so a module can remove settings it previously mirrored.

type ConfigurationValue

type ConfigurationValue = store.ModuleConfigurationValue

type ConfigurationWriter

type ConfigurationWriter interface {
	ConfigurationReader
	Replace(prefix string, values map[string]ConfigurationValue) error
}

type ConnectionToolConfig

type ConnectionToolConfig struct {
	Spec            ToolSpec
	Instruction     string
	TurnInstruction prompt.Part
	Captured        []protocol.ConnectionResource
	PrepareArgs     func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult    func(ctx context.Context, preparedArgs json.RawMessage, result engine.ToolResult) engine.ToolResult
}

ConnectionToolConfig configures one native tool backed by a database or SSH connection operation.

type ConnectorAccountSummary

type ConnectorAccountSummary = protocol.ConnectorAccountSummary

ConnectorAccountSummary is a secret-free description of a user-configured connector account owned by the Node.

type ConversationHistoryProvider

type ConversationHistoryProvider interface {
	ReadOnlyConversation(protocol.ConversationAssociation) bool
}

ConversationHistoryProvider identifies a module's retired conversation kinds. Their transcripts remain available, but new turns cannot be admitted.

type ConversationModeHost

type ConversationModeHost interface {
	ListConversationModes(ctx context.Context) ([]ConversationModeInfo, error)
}

ConversationModeHost is an optional Host capability exposing enabled plugin conversation modes so coordinators can choose among built-in and plugin modes.

type ConversationModeInfo

type ConversationModeInfo struct {
	Key         string
	Label       string
	Description string
	ReadOnly    bool
}

ConversationModeInfo describes an enabled host-scope plugin conversation mode.

type DatabaseServiceProvider

type DatabaseServiceProvider interface {
	ExecuteDatabase(context.Context, store.DatabaseOperation) (protocol.DatabaseOutcome, error)
}

DatabaseServiceProvider supplies the executor for the Node's database commands.

type DirectoryDiscussionProvider

type DirectoryDiscussionProvider interface {
	DirectoryDiscussions() []store.DirectoryDiscussion
}

DirectoryDiscussionProvider declares the native association kinds whose private conversations use a role or team from the owner's directory.

type DiscussionDocumentProvider

type DiscussionDocumentProvider interface {
	DiscussionDocumentTools(context.Context, Host, *store.AgentInvocation) ([]engine.Tool, error)
}

DiscussionDocumentProvider supplies only the current Bot conversation's document tools, without capturing the general module or package catalogs.

type DiscussionToolProvider

type DiscussionToolProvider interface {
	ProvidesDiscussionTools() bool
}

DiscussionToolProvider identifies a native Node module whose tools should be mounted for workspace discussions.

type DispatchProvider

type DispatchProvider interface {
	NativeDispatchNamespace() string
}

DispatchProvider is optionally implemented by native modules that own a persistent Node dispatch namespace (for example scheduled-tasks or reminders) so existing schedules and jobs continue running after legacy plugins retire.

type EventBus

type EventBus struct {
	// contains filtered or unexported fields
}

EventBus is a lightweight in-process domain event registry supporting both typed Go listeners and raw JSON listeners with priority ordering and isolation.

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) Emit

func (b *EventBus) Emit(ctx context.Context, eventName string, payload any) error

func (*EventBus) EmitRaw

func (b *EventBus) EmitRaw(ctx context.Context, eventName string, payload *json.RawMessage) error

func (*EventBus) Off

func (b *EventBus) Off(eventName, listenerName string)

func (*EventBus) On

func (b *EventBus) On(eventName string, fn func(context.Context, any) error, opts ...EventOption)

func (*EventBus) OnRaw

func (b *EventBus) OnRaw(eventName string, fn func(context.Context, *RawEvent) error, opts ...EventOption)

type EventModuleService

type EventModuleService interface {
	ModuleService
	CallWithEvents(ctx context.Context, caller protocol.NodeID, requestID protocol.RequestID, call protocol.NativeModuleCall) (json.RawMessage, []protocol.Event, error)
}

EventModuleService is an optional capability for ModuleServices that emit protocol events (such as board invalidation or notices) committed atomically with the durable module command admission.

type EventOption

type EventOption func(*eventListenerConfig)

EventOption configures an EventBus listener.

func Isolate

func Isolate() EventOption

Isolate logs listener errors and continues dispatching remaining listeners.

func ListenerName

func ListenerName(name string) EventOption

ListenerName assigns a stable name so the listener can be removed with Off.

func Priority

func Priority(p int) EventOption

Priority sets listener execution priority (higher runs first).

type ExternalBrowserToolConfig

type ExternalBrowserToolConfig struct {
	Spec         ToolSpec
	Instruction  string
	Close        func() error
	PrepareArgs  func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult func(ctx context.Context, result engine.ToolResult) engine.ToolResult
}

ExternalBrowserToolConfig configures one managed Chromium browser tool.

type GitCommandResult

type GitCommandResult struct {
	Stdout, Stderr []byte
	ExitCode       int
	Truncated      bool
	InvalidUTF8    bool
}

type GitOptions

type GitOptions struct {
	Run         GitRunner
	Now         func() time.Time
	Environment []string
	Profile     string
	// Lock covers local Git effects, not waits on a remote transfer.
	Lock func(string) func()
}

GitOptions is the existing injected Git execution boundary. Only a workspace provider that implements Git consumes it.

type GitRunner

type GitRunner func(context.Context, string, []string, []byte) (GitCommandResult, error)

type HTTPRequest

type HTTPRequest struct {
	// Method must be one of GET, POST, PUT, PATCH, DELETE, or HEAD.
	Method string
	// URL must be an absolute HTTPS URL whose origin is in the connector
	// account's allowlist.
	URL string
	// Headers holds optional non-credential request headers. Authentication and
	// hop-by-hop headers (Authorization, Cookie, Proxy-Authorization, Host,
	// Connection, Transfer-Encoding, Content-Length, Upgrade, etc.) are rejected.
	Headers map[string]string
	// Body is the optional request body, capped at ConnectorHTTPMaxRequestBytes.
	Body []byte
	// Timeout optionally bounds the request duration (default 15s, max 30s,
	// always bounded by ctx).
	Timeout time.Duration
}

HTTPRequest describes an outbound HTTPS request executed by the Node using credentials owned by a user-configured connector account.

type HTTPResponse

type HTTPResponse struct {
	StatusCode int
	Headers    http.Header
	Body       []byte
}

HTTPResponse is the sanitized HTTP response returned by Host.ConnectorHTTP. Sensitive headers (Authorization, Cookie, Set-Cookie, Proxy-Authorization, WWW-Authenticate, Proxy-Authenticate, etc.) are always removed, and any response echoing protected credential material is rejected.

type Host

type Host interface {
	WorkspaceTool(inv *store.AgentInvocation, cfg WorkspaceToolConfig) (engine.Tool, error)
	ScopedTool(inv *store.AgentInvocation, cfg ScopedToolConfig) (engine.Tool, error)
	ConnectionTool(inv *store.AgentInvocation, cfg ConnectionToolConfig) (engine.Tool, error)
	BrowserTool(inv *store.AgentInvocation, cfg BrowserToolConfig) (engine.Tool, error)
	ExternalBrowserTool(inv *store.AgentInvocation, cfg ExternalBrowserToolConfig) (engine.Tool, error)

	HasCodeIndex() bool
	RunWorkspaceOperation(ctx context.Context, inv *store.AgentInvocation, op protocol.ToolOperation, args json.RawMessage) (protocol.Output, error)
	ListLocalModels(ctx context.Context, kind protocol.ModelsKind) ([]protocol.ModelsLocalModel, error)

	ConnectionCatalog(ctx context.Context, inv *store.AgentInvocation) (store.ConnectionCatalog, error)
	CaptureConnectionTargets(inv *store.AgentInvocation, targets []protocol.ConnectionResource)

	BrowserAvailable(inv *store.AgentInvocation) bool
	ExternalBrowserAvailable() bool
	ExternalBrowserEnabled(ctx context.Context) (bool, error)
	ExternalBrowserCloseOnCancel(ctx context.Context, session protocol.SessionID) func() error

	ComputerEnabled(ctx context.Context) (bool, error)
	ConnectComputerMCP(ctx context.Context, inv *store.AgentInvocation, catalog CatalogSpec) ([]engine.Tool, error)

	PluginCaptured(inv *store.AgentInvocation, name string) (protocol.PluginReference, bool)
	PluginInstalled(ctx context.Context, name string) (installed bool, enabled bool, err error)
	// EnabledPackageNamesForAction lists compatible installed packages for this user.
	EnabledPackageNamesForAction(ctx context.Context, action string) ([]string, error)

	PluginStorageGet(ctx context.Context, inv *store.AgentInvocation, namespace, key string) (protocol.PluginStorageEntry, error)
	PluginStorageSearch(ctx context.Context, inv *store.AgentInvocation, namespace string, query protocol.PluginStorageSearch) (protocol.PluginStorageSearchPage, error)
	PluginStorageTransaction(ctx context.Context, inv *store.AgentInvocation, namespace string, ops []protocol.PluginTransactionOperation) ([]protocol.Output, error)
	ConfigureStorageApproval(ctx context.Context, db *sql.Conn, turn protocol.TurnID, value protocol.ConversationApproval) (protocol.ConversationApproval, error)

	// Controller-scoped storage helpers for native module commands (outside an agent turn).
	StorageGet(ctx context.Context, namespace, key string) (protocol.PluginStorageEntry, error)
	StorageListKeys(ctx context.Context, namespace, prefix string, after *string, limit uint16) (protocol.PluginStoragePage, error)
	StorageSearch(ctx context.Context, namespace string, query protocol.PluginStorageSearch) (protocol.PluginStorageSearchPage, error)
	StorageTransaction(ctx context.Context, namespace string, ops []protocol.PluginTransactionOperation) ([]protocol.Output, error)
	StorageDispatch(ctx context.Context, namespace string, action protocol.DispatchCommand) (protocol.DispatchOutput, error)
	StopDispatchTurn(ctx context.Context, namespace string, job protocol.JobID) error

	// Turn-scoped list/dispatch helpers for native module agent tools.
	PluginStorageListKeys(ctx context.Context, inv *store.AgentInvocation, namespace, prefix string, after *string, limit uint16) (protocol.PluginStoragePage, error)
	PluginStorageDispatch(ctx context.Context, inv *store.AgentInvocation, namespace string, action protocol.DispatchCommand) (protocol.DispatchOutput, error)

	LocalNodeID() protocol.NodeID
	Now() time.Time
	CurrentUser(ctx context.Context) (protocol.User, error)
	ProjectExists(ctx context.Context, id string) (bool, error)
	CheckProjectAccess(ctx context.Context, project protocol.ProjectID, manage bool) error
	CheckSessionAccess(ctx context.Context, session protocol.SessionID) error
	// StopSession stops the running turns of a session the current user may
	// access, as the session's stop button does. A session that is idle is
	// left as it is.
	StopSession(ctx context.Context, session protocol.SessionID) error
	ReadSession(ctx context.Context, session protocol.SessionID) (protocol.Session, error)
	// SessionCreationWatermark returns the current highest session CreationOrder
	// (0 when no sessions exist) so callers can verify a session was created
	// strictly after an earlier point without relying on wall-clock timestamps.
	SessionCreationWatermark(ctx context.Context) (uint64, error)
	ReadProjectCatalog(ctx context.Context) (protocol.ProjectsCatalog, error)
	ListTeams(ctx context.Context) ([]protocol.TeamProfile, error)
	PutTeam(ctx context.Context, team protocol.TeamProfile, expectedRevision uint64) (protocol.TeamProfile, error)
	LatestDirectorySession(ctx context.Context, namespace, kind, identity string) (protocol.SessionID, error)
	PostTaskDelivery(ctx context.Context, post TaskDeliveryPost) (bool, error)
	ListRoles(ctx context.Context) ([]protocol.RoleProfile, error)
	PutRole(ctx context.Context, role protocol.RoleProfile, expectedRevision uint64) (protocol.RoleProfile, error)
	PublishNotification(ctx context.Context, draft protocol.NotificationDraft) (protocol.NotificationNotice, error)
	ResolveNotification(ctx context.Context, key string) error
	ResolveModel(ctx context.Context, model string, effort *protocol.Effort, config *protocol.SessionConfig) (protocol.SessionConfig, error)
	ReadProviderAccountHTTP(ctx context.Context, provider protocol.ProviderID, expectedRevision uint64, namespace string, resolve func(protocol.Authentication) (protocol.PluginModelAuthEndpoint, bool)) (protocol.Authentication, protocol.PluginHttpResponse, error)
	ForwardModuleCommand(ctx context.Context, target protocol.NodeID, command protocol.Command) (protocol.Output, error)

	SetWakeSchedule(ctx context.Context, s WakeSchedule) (WakeSchedule, error)
	RemoveWakeSchedule(ctx context.Context, key string, expectedRevision uint64) error
	ListWakeSchedules(ctx context.Context, prefix string) ([]WakeSchedule, error)
	PublishWake(ctx context.Context, topic string, payload json.RawMessage, dedupeKey string) (protocol.EventID, error)

	StartModuleSession(ctx context.Context, req ModuleSessionStart) (protocol.SessionID, error)
	// QueueModuleTurn admits a turn into an existing session on the calling
	// module's behalf.
	//
	// Error-code contract for session lifecycle detection:
	//   - The ONLY error codes meaning "this session can no longer take turns"
	//     are protocol.ErrorCodeNotFound (the session does not exist or was
	//     removed) and protocol.ErrorCodeExpired (the session is archived).
	//   - protocol.ErrorCodeBusy is transient/re-entrant (for example, same-session
	//     re-entrant QueueModuleTurn from inside an active turn, or a full session
	//     queue) and is NEVER terminal.
	//   - protocol.ErrorCodeConflict is never returned as a terminal session-gone
	//     signal and must not be treated as one.
	QueueModuleTurn(ctx context.Context, req ModuleTurn) (protocol.TurnID, error)

	ConnectorHTTP(ctx context.Context, account protocol.ConnectorAccountID, req HTTPRequest) (HTTPResponse, error)
	ListConnectorAccounts(ctx context.Context) ([]ConnectorAccountSummary, error)

	// ListStandingApprovals returns active standing approval grants scoped to
	// the calling module (and applicable to project when non-nil). Modules can
	// never create or revoke standing grants.
	ListStandingApprovals(ctx context.Context, project *protocol.ProjectID) ([]protocol.StandingApproval, error)

	// ListProjectSessions returns up to limit (at most MaxProjectSessions)
	// top-level conversations of project that the current user may access,
	// newest first. Subagent children are omitted.
	ListProjectSessions(ctx context.Context, project protocol.ProjectID, limit int) ([]ProjectSession, error)

	// AllowStandingApproval lets a write tool built with BuildCustomTool
	// (DiscussionAllowed, one-time approval) be approved by the calling
	// module's active standing grant for operation in project, consuming one
	// use, instead of prompting. Without a matching grant it still prompts.
	AllowStandingApproval(tool engine.Tool, operation protocol.ToolOperation, project protocol.ProjectID) (engine.Tool, error)
}

func ModuleCallEnvironment

func ModuleCallEnvironment(ctx context.Context) (Host, string, bool)

type ModelContextProvider

type ModelContextProvider interface {
	ModelContextForTurn(context.Context, Host, *store.AgentInvocation) ([]string, error)
}

ModelContextProvider supplies transient data for the executing actor on each inference call, including turns where no tools are available. This data never becomes a conversation record.

type Module

type Module interface {
	ID() string
	ReplacesPlugins() []string
	Catalog() []ToolMeta
	ToolsForTurn(ctx context.Context, host Host, inv *store.AgentInvocation) ([]engine.Tool, error)
}

Module is one compile-time native Node feature module.

type ModuleService

type ModuleService interface {
	Call(ctx context.Context, caller protocol.NodeID, requestID protocol.RequestID, call protocol.NativeModuleCall) (json.RawMessage, error)
	Close() error
}

ModuleService serves project-authorized controller calls and owns its workers. Calls can run concurrently. A service must scope its records by call.ProjectID and close its workers before returning from Close.

func ServiceFor

func ServiceFor(host Host, module string) (ModuleService, bool)

ServiceFor returns the Node-owned service for a native tool's execution host.

type ModuleServiceProvider

type ModuleServiceProvider interface {
	OpenModuleService(ctx context.Context, profilePath string) (ModuleService, error)
}

ModuleServiceProvider opens one service per Node profile. The context is canceled when the Node stops or opening its remaining services fails.

type ModuleSessionStart

type ModuleSessionStart struct {
	Start protocol.ConversationStart
	// ReuseActiveAssociations selects an active standalone discussion owned by
	// the local user before creating an empty session. Model discussions may
	// try associations in order within their namespace. A silent role or team
	// discussion requires its exact association and current roster selection.
	ReuseActiveAssociations []protocol.ConversationAssociation
	IdempotencyKey          string
}

ModuleSessionStart creates a session on a native module's behalf. When IdempotencyKey is non-empty, repeating the call within 7 days returns the existing session ID without creating a duplicate.

type ModuleTurn

type ModuleTurn struct {
	Session        protocol.SessionID
	Message        protocol.ConversationInput
	Origin         TurnOrigin
	IdempotencyKey string
	AutoStart      bool
}

ModuleTurn queues an agent turn into an existing session on a native module's behalf via Host.QueueModuleTurn.

Error-code contract for Host.QueueModuleTurn:

  • The ONLY error codes meaning "this session can no longer take turns" are protocol.ErrorCodeNotFound (session does not exist or was removed) and protocol.ErrorCodeExpired (session is archived).
  • protocol.ErrorCodeBusy reports transient or re-entrant rejection (such as calling QueueModuleTurn for the same session from inside its active turn, or a full queue) and is NOT terminal.
  • protocol.ErrorCodeConflict is never a terminal "session gone" signal.

type PackageSourceProvider

type PackageSourceProvider interface {
	CallPackageSource(ctx context.Context, host Host, packageID string, project protocol.ProjectID, operation string, input json.RawMessage) (json.RawMessage, error)
}

PackageSourceProvider is the product's external work source service. The Node authenticates the package and derives its project from the captured callback. The provider checks the user's source binding for every exchange.

type PendingSessionApproval

type PendingSessionApproval struct {
	Approval  protocol.ConversationApproval
	Tool      string
	Arguments json.RawMessage
}

PendingSessionApproval describes one pending tool approval waiting in a session.

type PluginWebSocketSpec

type PluginWebSocketSpec struct {
	Package       string          `json:"package"`
	ConnectionKey string          `json:"connection_key"`
	Input         json.RawMessage `json:"input,omitempty"`
}

PluginWebSocketSpec configures one desired Node-managed WebSocket connection for an installed plugin declaring network.websocket.

type PluginWebSocketStatus

type PluginWebSocketStatus struct {
	Package       string `json:"package"`
	ConnectionKey string `json:"connection_key"`
	Connected     bool   `json:"connected"`
	LastError     string `json:"last_error,omitempty"`
	UpdatedAt     int64  `json:"updated_at,omitempty"`
}

PluginWebSocketStatus reports the live status of a managed plugin WebSocket.

type PreparedWorktree

type PreparedWorktree struct {
	Path    string
	Branch  string
	Discard func(context.Context) error
}

PreparedWorktree is a newly created checkout. Node registers it together with the execution session, and calls Discard if that transaction fails.

type ProcessCredential

type ProcessCredential struct {
	Username string
	Password protocol.Secret
}

type ProcessCredentialLookup

type ProcessCredentialLookup func(context.Context, string, []protocol.ConnectorKind) (*ProcessCredential, error)

ProcessCredentialLookup resolves explicitly provisioned basic authentication for a native module's child process. An empty result means no matching account.

type ProfileMigrator

type ProfileMigrator interface {
	MigrateProfile(context.Context, *sql.Conn) error
}

ProfileMigrator upgrades a compiled module's existing local data in the startup write transaction, before recovery starts any turns.

type ProfileModuleService

type ProfileModuleService interface {
	ModuleService
	AllowProfileScope() bool
}

ProfileModuleService is an optional capability for native ModuleServices that legitimately serve authenticated user/profile-scoped calls without a single project (for example a cross-project task board). Project-only modules must not implement this interface and stay fail-closed on empty ProjectID.

type ProjectSession

type ProjectSession struct {
	Session protocol.Session
	Reply   string
}

ProjectSession is a read-only view of one conversation in a project: the session with its activity and the leading text of its latest public assistant reply.

type ProjectSourcePreparer

type ProjectSourcePreparer func(context.Context, string, protocol.ProjectsSource) (string, error)

type ProjectTaskBoard

type ProjectTaskBoard interface {
	CreateTodo(context.Context, ProjectTaskBoardScope, protocol.CreateProjectTodoInput) (any, error)
	AssignOwner(context.Context, ProjectTaskBoardScope, protocol.AssignProjectTaskOwnerInput) (any, error)
	ReadProject(context.Context, ProjectTaskBoardScope, protocol.ReadProjectTaskInput) (any, error)
	// CheckStart recognizes a work ID in the selected project without writing it.
	CheckStart(context.Context, ProjectTaskBoardScope, protocol.RequestID) (bool, error)
}

ProjectTaskBoard delegates card storage to the assembled product while Node retains source, project and recipient authorization. It is native-only.

type ProjectTaskBoardItemRecorder

type ProjectTaskBoardItemRecorder interface {
	RecordStartedWorkItem(context.Context, ProjectTaskBoardScope, protocol.ProjectTaskWork) (uint64, bool, error)
}

ProjectTaskBoardItemRecorder extends ProjectTaskBoardRecorder by also returning the numeric board card ID assigned to the dispatched work so tool callers can immediately link the task card.

type ProjectTaskBoardRecorder

type ProjectTaskBoardRecorder interface {
	RecordStartedWork(context.Context, ProjectTaskBoardScope, protocol.ProjectTaskWork) (bool, error)
}

ProjectTaskBoardRecorder projects a newly dispatched task on a product's board before the committed execution is published. The work ID is stable across retries and implementations must accept already-recorded work.

type ProjectTaskBoardScope

type ProjectTaskBoardScope struct {
	ProfileDir string
	Node       protocol.NodeID
	Project    protocol.ProjectID
	Teams      []ProjectTaskOwnerChoice
	Roles      []ProjectTaskOwnerChoice
}

ProjectTaskBoardScope identifies the authorized local profile and project. Team and role choices are populated only when reading the board.

type ProjectTaskBoardStartGuard

type ProjectTaskBoardStartGuard interface {
	GuardCardStart(context.Context, ProjectTaskBoardScope, uint64) (context.Context, func(), error)
}

ProjectTaskBoardStartGuard optionally fences an authorized card between preflight and binding. Its context is passed to BindCardStart. The guard runs inside admission and must never call back into Node storage.

type ProjectTaskBoardStarter

type ProjectTaskBoardStarter interface {
	// CheckCardStart validates (item, revision) read-only prior to approval and
	// returns any existing work_id already reserved by that card.
	CheckCardStart(ctx context.Context, scope ProjectTaskBoardScope, item, revision uint64, task *protocol.RequestID) (protocol.RequestID, error)
	// BindCardStart attaches the confirmed Node execution work to the board card
	// after StartProjectTask commits and reports whether card state changed.
	BindCardStart(ctx context.Context, scope ProjectTaskBoardScope, item, revision uint64, work protocol.ProjectTaskWork) (bool, error)
}

ProjectTaskBoardStarter is optionally implemented by a ProjectTaskBoard so a Bot can start an existing board card by (item, revision) even when the card does not yet hold a work_id, without creating a duplicate card.

Contract:

  • CheckCardStart runs while Node holds LockPublication and a SQLite write transaction; implementations must be read-only and must never call back into Node writes (such as Host.PublishNotification) while holding board locks.
  • BindCardStart runs post-commit outside Node locks and must succeed idempotently on replay when the card is already bound to work.ID, even after its revision has advanced.

type ProjectTaskFollowUpHost

type ProjectTaskFollowUpHost interface {
	SubmitProjectTaskFollowUp(ctx context.Context, task protocol.RequestID, revision uint64, text string) (protocol.TurnID, error)
}

ProjectTaskFollowUpHost lets a native module submit a controller message for a routed task's delivery revision. Repeating the exact message returns the original execution turn.

type ProjectTaskOwnerChoice

type ProjectTaskOwnerChoice struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Revision uint64 `json:"revision"`
}

type ProjectTaskProposalReader

type ProjectTaskProposalReader interface {
	ListProjectTaskProposals(context.Context, protocol.ProjectID) ([]protocol.ProjectTaskProposal, error)
}

ProjectTaskProposalReader exposes a native module's pending requests to its own views. A zero project selects every project visible to the caller.

type ProjectTaskStopHost

type ProjectTaskStopHost interface {
	QueueProjectTaskStop(context.Context, protocol.RequestID, protocol.SessionID) error
}

ProjectTaskStopHost queues a durable stop for a desktop-owned execution receipt.

type ProjectTaskTranscriptHost

type ProjectTaskTranscriptHost interface {
	ReadProjectTaskTranscript(ctx context.Context, task protocol.RequestID, session protocol.SessionID, limit int) ([]SessionTranscriptEntry, error)
}

ProjectTaskTranscriptHost reads visible entries from the execution session bound to a desktop-owned routed task under the current executor grant.

type ProjectTaskWorkObserver

type ProjectTaskWorkObserver interface {
	OnProjectTaskWorkReported(ctx context.Context, work protocol.ProjectTaskWork) bool
}

ProjectTaskWorkObserver is an optional interface a profile ModuleService may implement to observe committed task starts, progress, questions, deliveries and failures, including automatic and owner-directed Squad transitions. Startup recovery may replay the same owner's Work ID and revision. Callbacks run under the work owner after the transaction commits. Returning true indicates the observer owns publishing any local durable notification for the report, suppressing Harness's generic fallback notice.

type ProjectTaskWorkPublisher

type ProjectTaskWorkPublisher interface {
	NotifyProjectTaskWorkChanged(context.Context) error
}

ProjectTaskWorkPublisher lets a module invalidate the work projection after an out-of-band change, such as a message received from a channel.

type ProjectWorkDefaultsProvider

type ProjectWorkDefaultsProvider interface {
	ProjectWorkDefaults(ctx context.Context, host Host, input protocol.StartProjectTaskInput) (*protocol.RoleModel, *protocol.Permission)
}

ProjectWorkDefaultsProvider is optionally implemented by a Module to supply fallback executor model and execution permission when board work starts directly via start_project_task.

type RawEvent

type RawEvent struct {
	Name    string
	Payload json.RawMessage
}

RawEvent carries a JSON-encoded domain event across plugin/transport boundaries.

type RegisteredModule

type RegisteredModule struct {
	Module
	Services ServiceCapabilities
}

func (RegisteredModule) RuntimeAvailable

func (m RegisteredModule) RuntimeAvailable(running ServiceCapabilities) bool

type RepositoryWatch

type RepositoryWatch struct {
	Open       func(context.Context, string) (RepositoryWatchFilter, []string, error)
	Invalidate func(string)
}

type RepositoryWatchFilter

type RepositoryWatchFilter interface {
	Changed([]string) bool
	ReferencesChanged([]string) bool
}

type ResolvedServices

type ResolvedServices struct {
	Databases             DatabaseExecutor
	SSH                   SSHFactory
	Terminal              TerminalFactory
	CodeIndex             codeindexapi.Factory
	Workspace             []WorkspaceBinder
	WorkspaceCapabilities ServiceCapabilities
	Modules               []RegisteredModule
}

type SSHFactory

type SSHFactory func(SSHServiceOptions) SSHService

type SSHServiceOptions

type SSHServiceOptions struct {
	Context       context.Context
	ReadSSH       func(context.Context, protocol.SshID, uint64) (protocol.SshProfile, protocol.SshCredential, error)
	WorkspaceRoot func(context.Context, protocol.WorktreeID, bool) (string, error)
	Transfers     *files.Transfers
	Terminals     *terminal.Service
	Installations *host.Installations
	Link          func() *link.Link
}

type SSHServiceProvider

type SSHServiceProvider interface {
	NewSSHService(SSHServiceOptions) SSHService
}

SSHServiceProvider supplies the service for the Node's SSH commands.

type ScopedToolConfig

type ScopedToolConfig struct {
	Spec            ToolSpec
	Instruction     string
	TurnInstruction prompt.Part
	PrepareArgs     func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	// ProjectTaskBoard serves native card operations. It is not a replacement for
	// the Node's approved project execution path.
	ProjectTaskBoard ProjectTaskBoard
	// ProjectTaskAutonomy reads the owner's saved policy for the exact project
	// of a board mutation in the native manager conversation. A false result
	// requires a one-time confirmation; errors refuse the operation.
	ProjectTaskAutonomy func(protocol.ProjectID) (bool, error)
	// AllowStandingApproval opts this tool invocation into matching active
	// user-created standing approval grants. Defaults to false: unless explicitly
	// set to true, matching standing grants are ignored and the tool call keeps
	// its one-time user approval prompt.
	AllowStandingApproval bool
	// ExecutorModel names a project's default executor model for
	// project_tasks.start. The executor runs on the selected team's or role's
	// bound model when it has one, otherwise on this model, otherwise on the
	// Node default. A nil func or a nil result keeps the Node default.
	ExecutorModel func(project protocol.ProjectID) *protocol.RoleModel
	// ExecutorPermission selects the execution permission (ask, project, full)
	// for project work started by project_tasks.start. A nil func or a nil
	// result keeps the default project work policy.
	ExecutorPermission func(project protocol.ProjectID) *protocol.Permission
}

ScopedToolConfig configures one native tool backed by a scoped Node operation. Project task operations use the invocation's session and turn as their source. Modules opt in by registering tools; declaring an operation does not expose it.

type ServiceCapabilities

type ServiceCapabilities uint8
const (
	ServiceDatabase ServiceCapabilities = 1 << iota
	ServiceSSH
	ServiceTerminal
	ServiceGit
	ServiceWorktrees
	ServiceCodeIndex
)

type SessionApprovalHost

type SessionApprovalHost interface {
	ListPendingSessionApprovals(ctx context.Context, session protocol.SessionID) ([]PendingSessionApproval, error)
	ResolveSessionApproval(ctx context.Context, session protocol.SessionID, approval protocol.ApprovalID, decision protocol.ConversationDecision) (protocol.ConversationApproval, error)
}

SessionApprovalHost is an optional Host capability allowing trusted native modules to list and resolve one-time pending approvals for authorized owner sessions outside active agent turns (for example, from an authenticated IM owner reply).

type SessionTranscriptEntry

type SessionTranscriptEntry struct {
	Sequence uint64   `json:"sequence"`
	Author   string   `json:"author"`
	Text     string   `json:"text,omitempty"`
	Tools    []string `json:"tools,omitempty"`
}

SessionTranscriptEntry is a bounded, read-only excerpt of one visible conversation entry (author text and tool call summaries).

type SessionTranscriptHost

type SessionTranscriptHost interface {
	ReadSessionTranscript(ctx context.Context, session protocol.SessionID, limit int) ([]SessionTranscriptEntry, error)
}

SessionTranscriptHost is an optional Host capability allowing trusted native modules to read bounded recent visible entries from an authorized session.

type SkillProvider

type SkillProvider interface {
	Skills() []BuiltInSkill
}

SkillProvider is optionally implemented by native modules that ship built-in skills (for example, web-search:research).

type TaskDeliveryPost

type TaskDeliveryPost = store.TaskDeliveryPost

Host exposes narrowly scoped Node execution services to native modules.

type TaskEventSink

type TaskEventSink interface {
	EmitTaskFeedback(ctx context.Context, event protocol.TaskFeedbackEvent) error
}

TaskEventSink receives canonical, deduplicated task feedback events from Node modules (for example local notifications, Feishu bot cards, or issue syncers).

type TerminalServiceProvider

type TerminalServiceProvider interface {
	NewTerminalService(context.Context, protocol.NodeID, func(context.Context, protocol.TerminalInfo)) *terminal.Service
}

TerminalServiceProvider supplies the Node's controller terminal service.

type ToolMeta

type ToolMeta struct {
	Name          string                    `json:"name"`
	LegacyPackage string                    `json:"legacy_package,omitempty"`
	LegacyServer  string                    `json:"legacy_server,omitempty"`
	LegacyName    string                    `json:"legacy_name,omitempty"`
	Presentation  protocol.ToolPresentation `json:"presentation,omitempty"`
	Grouping      protocol.ToolGrouping     `json:"grouping,omitempty"`
	Display       *protocol.ToolDisplay     `json:"display,omitempty"`
}

ToolMeta describes presentation, grouping, localized display metadata and legacy package-alias resolution for one native module tool.

func (ToolMeta) LegacyAlias

func (m ToolMeta) LegacyAlias() string

LegacyAlias returns the canonical alias formerly generated when this tool was owned by a bundled plugin package (or plugin MCP server), or an empty string if none applies.

type ToolSpec

type ToolSpec struct {
	Name              string                                `json:"name"`
	LegacyPackage     string                                `json:"legacy_package,omitempty"`
	LegacyServer      string                                `json:"legacy_server,omitempty"`
	LegacyName        string                                `json:"legacy_name,omitempty"`
	Description       string                                `json:"description"`
	Operation         protocol.ToolOperation                `json:"operation,omitempty"`
	Action            string                                `json:"action,omitempty"`
	Parameters        json.RawMessage                       `json:"parameters"`
	Initial           bool                                  `json:"initial,omitempty"`
	ReadOnly          bool                                  `json:"read_only,omitempty"`
	Concurrent        bool                                  `json:"concurrent,omitempty"`
	StreamRead        bool                                  `json:"stream_read,omitempty"`
	DiscussionAllowed bool                                  `json:"discussion_allowed,omitempty"`
	Contexts          []protocol.PluginConversationResource `json:"contexts,omitempty"`
	Platforms         []string                              `json:"platforms,omitempty"`
	Presentation      protocol.ToolPresentation             `json:"presentation,omitempty"`
	Grouping          protocol.ToolGrouping                 `json:"grouping,omitempty"`
	Display           *protocol.ToolDisplay                 `json:"display,omitempty"`
}

ToolSpec holds the declarative metadata of one native module tool, typically embedded as JSON in the module package.

func (ToolSpec) Available

func (s ToolSpec) Available(inv *store.AgentInvocation) bool

Available reports whether this tool can be offered in the captured turn.

func (ToolSpec) LegacyAlias

func (s ToolSpec) LegacyAlias() string

LegacyAlias returns the former plugin-scoped alias for this tool, if any.

func (ToolSpec) Meta

func (s ToolSpec) Meta() ToolMeta

Meta converts this specification to its static presentation metadata.

func (ToolSpec) SearchLabels

func (s ToolSpec) SearchLabels() []string

SearchLabels returns sorted, deduplicated display labels for tool_search.

type TurnCompletionEvent

type TurnCompletionEvent struct {
	Session   protocol.SessionID
	Turn      protocol.TurnID
	Status    protocol.ConversationStatus
	ReplyText string
	Error     string
}

TurnCompletionEvent carries the outcome and final assistant reply of an ended turn.

type TurnCompletionObserver

type TurnCompletionObserver interface {
	OnTurnCompleted(ctx context.Context, host Host, event TurnCompletionEvent)
}

TurnCompletionObserver is an optional module interface notified after a turn ends.

type TurnOrigin

type TurnOrigin = protocol.TurnOrigin

TurnOrigin identifies the native module that initiated an agent turn. Harness overwrites Module from the calling module's identity.

type WakeEvent

type WakeEvent struct {
	ID          protocol.EventID // stable; a retry delivers the same ID
	Topic       string
	Payload     json.RawMessage
	Schedule    *protocol.ScheduleID // set when a schedule fired it
	ScheduledMs *int64               // the slot it fired for
	Attempt     int                  // 1 on first delivery
}

WakeEvent delivers one durable wake occurrence to a WakeProvider.

type WakeMissedPolicy

type WakeMissedPolicy = store.WakeMissedPolicy

WakeMissedPolicy controls what happens when a wake schedule fires late after the Node was stopped or asleep.

type WakeProvider

type WakeProvider interface {
	WakeNamespace() string
	OnWake(ctx context.Context, host Host, event WakeEvent) error
}

WakeProvider is optionally implemented by a Module that receives durable in-process wake callbacks. WakeNamespace is the module's dispatch namespace.

type WakeSchedule

type WakeSchedule = store.WakeSchedule

WakeSchedule describes one module-owned durable wake schedule stored in the module's native dispatch namespace.

type WorkDeliveryEvent

type WorkDeliveryEvent struct {
	Package    string `json:"package"`
	SourceID   string `json:"source_id"`
	Event      string `json:"event,omitempty"`
	ExternalID string `json:"external_id,omitempty"`
}

WorkDeliveryEvent notifies listeners that a plugin work source has a new outbound delivery (task delivery, acceptance, or turn_reply) ready to claim.

type WorkSourcePlugin

type WorkSourcePlugin struct {
	Package           string                                `json:"package"`
	Declaration       *protocol.PluginWorkSourceDeclaration `json:"declaration,omitempty"`
	HasWebSocket      bool                                  `json:"has_websocket,omitempty"`
	AllowOwnerCommand bool                                  `json:"allow_owner_command,omitempty"`
}

WorkSourcePlugin describes an enabled compatible plugin declaring work.sources (and optional declarative work_source / websocket metadata).

type WorkSourcePluginHost

type WorkSourcePluginHost interface {
	EnabledWorkSourcePlugins(ctx context.Context) ([]WorkSourcePlugin, error)
	ReconcilePluginWebSockets(ctx context.Context, specs []PluginWebSocketSpec) error
	PluginWebSocketStatuses() []PluginWebSocketStatus
	NotifyPluginWorkSourceDelivery(ctx context.Context, pkg, sourceID string) error
	Events() *EventBus
}

WorkSourcePluginHost is an optional Host capability exposing declarative work_source plugins, Node-managed WebSocket reconciliation, and delivery wakes.

type WorkspaceBinder

type WorkspaceBinder func(*WorkspaceRuntime) (WorkspaceBindings, error)

type WorkspaceBindings

type WorkspaceBindings struct {
	// PrepareProcess binds an admitted network-capable command to its user.
	// A nil binding preserves the ordinary shell and environment.
	PrepareProcess          func(ctx context.Context, directory, command string) (*process.CommandBinding, error)
	Commands                map[string]WorkspaceCommand
	ProjectSources          map[string]ProjectSourcePreparer
	RepositoryWatch         *RepositoryWatch
	CaptureBoundary         func(root string) (string, error)
	StageTurnHunk           func(context.Context, string, protocol.ConversationCheckpointHunkSelection, func(string) (string, error)) (protocol.Output, error)
	RemoveUnusedWorktree    func(context.Context, store.ProjectWorktree, func()) (bool, error)
	PrepareIsolatedWorktree func(context.Context, store.ProjectWorktree, protocol.WorktreeID, string) (PreparedWorktree, error)
}

type WorkspaceCommand

type WorkspaceCommand struct {
	Lock WorkspaceLock
	// ProjectRoot selects the project's main workspace for commands addressed
	// to a project rather than a worktree.
	ProjectRoot func(protocol.Command) protocol.ProjectID
	Run         func(context.Context, WorkspaceCommandScope, protocol.Command) (protocol.Output, error)
}

WorkspaceCommand runs inside the same authorization, root resolution and durable completion path as core workspace operations.

type WorkspaceCommandHost

type WorkspaceCommandHost interface {
	MainWorktreeID(ctx context.Context, project protocol.ProjectID) (protocol.WorktreeID, error)
	RunLocalWorkspaceCommand(ctx context.Context, command protocol.Command) (protocol.Output, error)
}

WorkspaceCommandHost is an optional Host capability allowing trusted local native modules (such as Assistant) to inspect, merge, and clean up project worktrees through the Node's sanctioned workspace command pipeline.

type WorkspaceCommandScope

type WorkspaceCommandScope interface {
	Root() string
	ProtectEntry(path string) error
	Changed()
	CaptureWorktree(protocol.WorktreeID) (store.ProjectWorktree, error)
	RegisterWorktree(value protocol.Worktree, adopt bool) (protocol.Output, error)
	RemoveWorktree(id protocol.WorktreeID, remove func(path string) error) (protocol.Output, error)
}

type WorkspaceFactory

type WorkspaceFactory[T any] struct {
	Open func(WorkspaceOptions) (T, func() error, error)
}

WorkspaceFactory identifies one shared service. Modules that select the same factory instance bind only their own handlers to that service.

func (*WorkspaceFactory[T]) Bind

func (f *WorkspaceFactory[T]) Bind(bind func(T) WorkspaceBindings) WorkspaceBinder

type WorkspaceLock

type WorkspaceLock uint8
const (
	// WorkspaceLockEffect holds the resolved roots to durable completion.
	WorkspaceLockEffect WorkspaceLock = iota
	// WorkspaceLockLocal leaves locking of individual effect phases to the service.
	WorkspaceLockLocal
	// WorkspaceLockChange holds the roots and advances the registration revision on release.
	WorkspaceLockChange
)

type WorkspaceOptions

type WorkspaceOptions struct {
	ProcessCredential ProcessCredentialLookup
	Context           context.Context
	Profile           string
	Environment       []string
	Lock              func(string) func()
	Git               GitOptions
}

type WorkspaceRequestHost

type WorkspaceRequestHost interface {
	RunWorkspaceRequest(context.Context, protocol.Request) (protocol.Output, error)
	InspectWorkspaceRequest(context.Context, protocol.Request) (protocol.RequestOutcome, error)
}

WorkspaceRequestHost lets a local controller persist a durable workspace request and inspect its original admission on the owning Node after a disconnect.

type WorkspaceRuntime

type WorkspaceRuntime struct {
	// contains filtered or unexported fields
}

WorkspaceRuntime owns the services selected during one Node's startup.

func NewWorkspaceRuntime

func NewWorkspaceRuntime(options WorkspaceOptions) *WorkspaceRuntime

func (*WorkspaceRuntime) Close

func (r *WorkspaceRuntime) Close() error

type WorkspaceServiceProvider

type WorkspaceServiceProvider interface {
	WorkspaceServices() WorkspaceServices
}

type WorkspaceServices

type WorkspaceServices struct {
	Git       bool
	Worktrees bool
	Bind      WorkspaceBinder
}

WorkspaceServices declares a module's capabilities and binds its handlers. A capability by itself does not register commands or start a service.

type WorkspaceToolConfig

type WorkspaceToolConfig struct {
	// FileWritePaths declares that preparation preserves the file targets in the operation arguments.
	FileWritePaths bool
	// ArtifactPackage identifies the compile-time owner of a session artifact operation.
	ArtifactPackage protocol.PluginReference
	Spec            ToolSpec
	Instruction     string
	TurnInstruction prompt.Part
	ContextParts    []string
	PrepareArgs     func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult    func(ctx context.Context, args json.RawMessage, result engine.ToolResult) engine.ToolResult
}

WorkspaceToolConfig configures one native tool backed by a workspace operation.

Jump to

Keyboard shortcuts

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