agentmcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 49 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

This section is empty.

Variables

View Source
var ErrRunning = errors.New("MCP 实例正在运行或管理操作忙碌,请先停止服务后重试")

Functions

func DownloadDeliveryMode

func DownloadDeliveryMode(cfg config.MCP) string

交付规则取自本次运行配置,不根据单个请求的来源猜测调用方文件系统。

func FormatLogLine

func FormatLogLine(line LogLine, ansi bool) string

FormatLogLine 的 ANSI 编号与 GUI 色板语义相同。外部终端决定实际颜色。

Types

type AccountView

type AccountView struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Username string   `json:"username"`
	Actions  []string `json:"actions"`
}

type AccountsInput

type AccountsInput struct {
	PageInput
	Profile      string `json:"profile"`
	Organization string `json:"organization"`
	AssetID      string `json:"asset_id"`
}

type AliasView

type AliasView struct {
	Name             string `json:"name"`
	Profile          string `json:"profile"`
	Organization     string `json:"organization"`
	AssetReference   string `json:"asset_reference"`
	AccountReference string `json:"account_reference"`
	AssetID          string `json:"asset_id,omitempty"`
	AccountID        string `json:"account_id,omitempty"`
	ResolutionStatus string `json:"resolution_status"`
}

type AliasesInput

type AliasesInput struct {
	PageInput
	Profile      string `json:"profile"`
	Organization string `json:"organization,omitempty"`
}

type AssetInput

type AssetInput struct {
	Profile      string `json:"profile"`
	Organization string `json:"organization"`
	AssetID      string `json:"asset_id"`
}

type AssetResult

type AssetResult struct {
	Profile      string         `json:"profile"`
	Organization string         `json:"organization"`
	Asset        AssetView      `json:"asset"`
	Accounts     []AccountView  `json:"accounts"`
	Protocols    []ProtocolView `json:"protocols"`
}

type AssetView

type AssetView struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Address  string `json:"address"`
	Type     string `json:"type"`
	Category string `json:"category"`
}

type AssetsInput

type AssetsInput struct {
	PageInput
	Profile      string `json:"profile"`
	Organization string `json:"organization"`
	Search       string `json:"search,omitempty"`
}

type AuthReader

type AuthReader interface {
	Status(string) (auth.Status, error)
}

type CallDetails

type CallDetails struct {
	Summary, Conditions       string
	ConnectionID, ExecutionID string
	Duration                  time.Duration
}

CallDetails 只接受调用摘要和经过白名单筛选的条件,不持有原始请求或响应。

type CancelInput

type CancelInput struct {
	ExecutionID string `json:"execution_id"`
	Mode        string `json:"mode,omitempty"`
}

type CloseInput

type CloseInput struct {
	ConnectionID string `json:"connection_id"`
	Mode         string `json:"mode,omitempty"`
}

type CommitUploadInput

type CommitUploadInput struct {
	SourceID   string `json:"source_id"`
	RequestKey string `json:"request_key"`
	TimeoutMS  int    `json:"timeout_ms,omitempty"`
	WaitMS     *int   `json:"wait_ms,omitempty"`
}

type ConfigReader

type ConfigReader interface{ Load() (config.Config, error) }

type ConnectionInput

type ConnectionInput struct {
	ConnectionID string `json:"connection_id"`
}

type ConnectionView

type ConnectionView struct {
	ID                        string         `json:"connection_id"`
	Target                    ResolvedTarget `json:"target"`
	Status                    string         `json:"status"`
	TransportGeneration       uint64         `json:"transport_generation"`
	TransportConnected        bool           `json:"transport_connected"`
	CreatedAt                 time.Time      `json:"created_at"`
	LastUsedAt                time.Time      `json:"last_used_at"`
	ActiveExecutionID         string         `json:"active_execution_id,omitempty"`
	ClosedAt                  *time.Time     `json:"closed_at,omitempty"`
	CloseReason               string         `json:"close_reason,omitempty"`
	LastError                 *Fault         `json:"last_error,omitempty"`
	ExecCapability            string         `json:"exec_capability"`
	RemoteDeadlineCapability  string         `json:"remote_deadline_capability"`
	LastDisconnectReason      string         `json:"last_disconnect_reason,omitempty"`
	RetryAfterMS              int64          `json:"retry_after_ms"`
	RecentUnknownExecutionIDs []string       `json:"recent_unknown_execution_ids"`
}

type Connector

type Connector struct {
	Config     ConfigReader
	Auth       IdentitySource
	Queries    *Queries
	Connect    connect.Service
	KnownHosts string
	Timeout    time.Duration
}

Connector 读取默认选择并将唯一目标固定为 ID;不修改配置,不发起交互登录或主机信任弹窗。

func (Connector) Dial

func (c Connector) Dial(ctx context.Context, r ResolvedTarget) (*ssh.Client, error)

func (Connector) DialUpload

func (c Connector) DialUpload(ctx context.Context, r ResolvedTarget) (*ssh.Client, error)

func (Connector) OpenDownloadSFTP

func (c Connector) OpenDownloadSFTP(ctx context.Context, r ResolvedTarget) (DownloadSFTP, error)

func (Connector) OpenUploadSFTP

func (c Connector) OpenUploadSFTP(ctx context.Context, r ResolvedTarget) (UploadSFTP, error)

func (Connector) Resolve

func (c Connector) Resolve(ctx context.Context, in Target) (ResolvedTarget, error)

func (Connector) Validate

func (c Connector) Validate(ctx context.Context, r ResolvedTarget) error

type DownloadIDInput

type DownloadIDInput struct {
	DownloadID string `json:"download_id"`
}

type DownloadInput

type DownloadInput struct {
	Target         Target   `json:"target,omitempty"`
	ConnectionID   string   `json:"connection_id,omitempty"`
	RequestKey     string   `json:"request_key"`
	RemotePaths    []string `json:"remote_paths"`
	LocalDirectory string   `json:"local_directory,omitempty"`
	TimeoutMS      int      `json:"timeout_ms,omitempty"`
	WaitMS         *int     `json:"wait_ms,omitempty"`
}
type DownloadLink struct {
	URL                string                 `json:"url,omitempty"`
	FileName           string                 `json:"file_name"`
	Format             string                 `json:"format"`
	Size               int64                  `json:"size"`
	ExpiresAt          time.Time              `json:"expires_at"`
	RequiresExtraction bool                   `json:"requires_extraction"`
	RestoreName        string                 `json:"restore_name"`
	Artifact           downloadcache.Artifact `json:"-"`
	Available          bool                   `json:"available"`
	UnavailableReason  string                 `json:"unavailable_reason,omitempty"`
}

type DownloadProgress

type DownloadProgress struct {
	Phase            string          `json:"phase"`
	Protocol         string          `json:"protocol,omitempty"`
	TransferredBytes int64           `json:"transferred_bytes"`
	TransferBytes    int64           `json:"transfer_bytes"`
	Published        *DownloadResult `json:"-"`
}

type DownloadRemote

type DownloadRemote interface {
	Open(string) (io.ReadCloser, error)
	Close() error
}

type DownloadRename

type DownloadRename struct {
	Source      string `json:"source"`
	ArchivePath string `json:"archive_path"`
}

ArchivePath 是准备包中的相对位置;只有同名独立来源被改名时返回对应关系。

type DownloadResult

type DownloadResult struct {
	Delivery        string           `json:"delivery,omitempty"`
	Link            *DownloadLink    `json:"link,omitempty"`
	Instructions    string           `json:"instructions,omitempty"`
	RenamedEntries  []DownloadRename `json:"renamed_entries,omitempty"`
	Directory       string           `json:"directory,omitempty"`
	Files           []DownloadedFile `json:"files,omitempty"`
	Warnings        []string         `json:"warnings,omitempty"`
	RemoteArtifacts []string         `json:"remote_artifacts,omitempty"`
}

type DownloadSFTP

type DownloadSFTP struct {
	Client  DownloadRemote
	Root    *string
	Account string
}

type DownloadView

type DownloadView struct {
	ID     string         `json:"download_id"`
	Target ResolvedTarget `json:"target"`
	Status string         `json:"status"`
	DownloadProgress
	DownloadResult
	FilesReady        bool       `json:"files_ready"`
	RemoteMayContinue bool       `json:"remote_may_continue"`
	AcceptedAt        time.Time  `json:"accepted_at"`
	DeadlineAt        time.Time  `json:"deadline_at"`
	FinishedAt        *time.Time `json:"finished_at,omitempty"`
	Error             *Fault     `json:"error,omitempty"`
}

type DownloadedFile

type DownloadedFile struct {
	Path   string `json:"path"`
	Source string `json:"source"`
	Size   int64  `json:"size"`
	// 保留可选字段以兼容 MCP schema;自动下载不再计算或填充内容哈希。
	SHA256     string `json:"sha256,omitempty"`
	CapturedAt string `json:"captured_at,omitempty"`
}

type DownloadsPageInput

type DownloadsPageInput struct {
	PageInput
	Status string `json:"status,omitempty"`
}

type Engine

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

Engine 归属于一次服务实例;HTTP 请求结束不取消它拥有的工作。

func NewEngine

func NewEngine(opts EngineOptions) *Engine

func (*Engine) CancelDownload

func (e *Engine) CancelDownload(_ context.Context, in DownloadIDInput) (DownloadView, error)

func (*Engine) CancelExecution

func (e *Engine) CancelExecution(ctx context.Context, in CancelInput) (ExecutionView, error)

func (*Engine) CancelUpload

func (e *Engine) CancelUpload(_ context.Context, in UploadIDInput) (UploadView, error)

func (*Engine) CancelUploadSource

func (e *Engine) CancelUploadSource(_ context.Context, in UploadSourceInput) (UploadSourceView, error)

func (*Engine) CloseConnection

func (e *Engine) CloseConnection(ctx context.Context, in CloseInput) (ConnectionView, error)

func (*Engine) CommitUpload

func (e *Engine) CommitUpload(ctx context.Context, in CommitUploadInput) (UploadView, error)

func (*Engine) ConnectionsPage

func (e *Engine) ConnectionsPage(ctx context.Context, in PageInput) (Page[ConnectionView], error)

func (*Engine) DownloadFiles

func (e *Engine) DownloadFiles(ctx context.Context, in DownloadInput) (DownloadView, error)

func (*Engine) DownloadsPage

func (e *Engine) DownloadsPage(_ context.Context, in DownloadsPageInput) (Page[DownloadView], error)

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, in ExecuteInput) (ExecutionView, error)

func (*Engine) ExecutionsPage

func (e *Engine) ExecutionsPage(ctx context.Context, in ExecutionsPageInput) (Page[ExecutionView], error)

func (*Engine) GetConnection

func (e *Engine) GetConnection(_ context.Context, in ConnectionInput) (ConnectionView, error)

func (*Engine) GetDownload

func (e *Engine) GetDownload(ctx context.Context, in GetDownloadInput) (DownloadView, error)

func (*Engine) GetExecution

func (e *Engine) GetExecution(ctx context.Context, in GetExecutionInput) (ExecutionView, error)

func (*Engine) GetUpload

func (e *Engine) GetUpload(ctx context.Context, in GetUploadInput) (UploadView, error)

func (*Engine) GetUploadSource

func (e *Engine) GetUploadSource(_ context.Context, in UploadSourceInput) (UploadSourceView, error)

func (*Engine) Limits

func (e *Engine) Limits() map[string]int64

func (*Engine) ListConnections

func (e *Engine) ListConnections(_ context.Context, _ struct{}) ([]ConnectionView, error)

func (*Engine) ListExecutions

func (e *Engine) ListExecutions(_ context.Context, in ListExecutionsInput) ([]ExecutionView, error)

func (*Engine) Open

func (e *Engine) Open(ctx context.Context, in OpenInput) (OpenResult, error)

func (*Engine) PrepareUpload

func (e *Engine) PrepareUpload(ctx context.Context, in PrepareUploadInput) (UploadSourceView, error)

func (*Engine) RecordCall

func (e *Engine) RecordCall(name string, err error, details ...CallDetails)

func (*Engine) RequestEpoch

func (e *Engine) RequestEpoch() uint64

func (*Engine) Retire

func (e *Engine) Retire()

Retire 在宿主停止实例后解除仓库到旧 Engine 的引用。历史只保留单条操作, 不因一条日志而保留整个旧实例的索引、连接池和上下文;在途清理仍持有自己的 Engine。

func (*Engine) Shutdown

func (e *Engine) Shutdown(ctx context.Context) error

Shutdown 请求停止共享任务,并在同一截止时间内等待;超时只能放弃跟踪,不能宣称远端已停止。

func (*Engine) Stats

func (e *Engine) Stats() EngineStats

func (*Engine) UploadFiles

func (e *Engine) UploadFiles(ctx context.Context, in UploadInput) (UploadView, error)

func (*Engine) UploadsPage

func (e *Engine) UploadsPage(_ context.Context, in UploadsPageInput) (Page[UploadView], error)

type EngineOptions

type EngineOptions struct {
	History             *History
	Instance            string
	Resolve             func(context.Context, Target) (ResolvedTarget, error)
	Validate            func(context.Context, ResolvedTarget) error
	Dial                func(context.Context, ResolvedTarget) (*ssh.Client, error)
	OpenSFTP            func(context.Context, ResolvedTarget) (DownloadSFTP, error)
	Download            func(context.Context, ResolvedTarget, DownloadInput, func(DownloadProgress)) (DownloadResult, error)
	DialUpload          func(context.Context, ResolvedTarget) (*ssh.Client, error)
	OpenUploadSFTP      func(context.Context, ResolvedTarget) (UploadSFTP, error)
	Upload              func(context.Context, ResolvedTarget, UploadInput, func(UploadProgress)) (UploadResult, error)
	UploadCache         *uploadcache.Store
	DeliveryMode        string
	DownloadCache       *downloadcache.Store
	Limits              Limits
	Now                 func() time.Time
	MaintenanceInterval time.Duration
}

type EngineStats

type EngineStats struct {
	Connections            int  `json:"connections"`
	SSHConnections         int  `json:"ssh_connections"`
	Connecting             int  `json:"connecting"`
	Executions             int  `json:"executions"`
	Downloads              int  `json:"downloads"`
	UnknownDownloads       int  `json:"unknown_downloads"`
	DownloadTransportSlots int  `json:"download_transport_slots"`
	Uploads                int  `json:"uploads"`
	UnknownUploads         int  `json:"unknown_uploads"`
	UploadTransportSlots   int  `json:"upload_transport_slots"`
	UploadSources          int  `json:"upload_sources"`
	UploadReceiving        int  `json:"upload_receiving"`
	UnknownExecutions      int  `json:"unknown_executions"`
	Draining               bool `json:"draining"`
}

type ExecuteInput

type ExecuteInput struct {
	ConnectionID    string            `json:"connection_id"`
	RequestKey      string            `json:"request_key"`
	Command         string            `json:"command"`
	Cwd             string            `json:"cwd"`
	Env             map[string]string `json:"env,omitempty"`
	TimeoutMS       int               `json:"timeout_ms,omitempty"`
	TimeoutStrategy string            `json:"timeout_strategy,omitempty"`
	WaitMS          *int              `json:"wait_ms,omitempty"`
}

type ExecutionView

type ExecutionView struct {
	ID                  string         `json:"execution_id"`
	ConnectionID        string         `json:"connection_id"`
	Target              ResolvedTarget `json:"target"`
	TransportGeneration uint64         `json:"transport_generation"`
	ConnectAttempts     int            `json:"connect_attempts"`
	Reconnected         bool           `json:"reconnected"`
	Status              string         `json:"status"`
	DispatchState       string         `json:"dispatch_state"`
	RemoteState         string         `json:"remote_state"`
	RemoteMayContinue   bool           `json:"remote_may_continue"`
	TerminationScope    string         `json:"termination_scope"`
	AcceptedAt          time.Time      `json:"accepted_at"`
	PrepareDeadlineAt   time.Time      `json:"prepare_deadline_at"`
	StartedAt           *time.Time     `json:"started_at,omitempty"`
	FinishedAt          *time.Time     `json:"finished_at,omitempty"`
	ExitCode            *int           `json:"exit_code"`
	ExitSignal          string         `json:"exit_signal,omitempty"`
	Error               *Fault         `json:"error,omitempty"`
	Reason              string         `json:"reason,omitempty"`
	TimeoutMS           int            `json:"timeout_ms"`
	TimeoutStrategy     string         `json:"timeout_strategy"`
	CancelRequested     bool           `json:"cancel_requested"`
	CancelConfirmed     bool           `json:"cancel_confirmed"`
	CancelError         *Fault         `json:"cancel_error,omitempty"`
	Output              OutputView     `json:"output"`
}

type ExecutionsPageInput

type ExecutionsPageInput struct {
	PageInput
	ListExecutionsInput
}

type Fault

type Fault struct {
	Code       string          `json:"code"`
	Message    string          `json:"message"`
	Retryable  bool            `json:"retryable"`
	Resolution *ResolutionHint `json:"resolution,omitempty"`
}

Fault 只携带适合向 Agent 返回的信息,不透传凭据或上游原始响应。

func (*Fault) Error

func (f *Fault) Error() string

type GetDownloadInput

type GetDownloadInput struct {
	DownloadID string `json:"download_id"`
	WaitMS     *int   `json:"wait_ms,omitempty"`
}

type GetExecutionInput

type GetExecutionInput struct {
	ExecutionID string `json:"execution_id"`
	Cursor      uint64 `json:"cursor,omitempty"`
	MaxBytes    int    `json:"max_bytes,omitempty"`
	WaitMS      int    `json:"wait_ms,omitempty"`
}

type GetUploadInput

type GetUploadInput struct {
	UploadID string `json:"upload_id"`
	WaitMS   *int   `json:"wait_ms,omitempty"`
}

type HandlerFactory

type HandlerFactory func(Instance, config.MCP, string) http.Handler

type History

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

History 是宿主内共享的操作仓库。Engine 索引和输出链表只引用这里的对象; 所有实例共用同一把锁,回收时无需持有两个 Engine 锁或调用外部订阅者。

func NewHistory

func NewHistory(limit int) *History

func (*History) Read

func (h *History) Read(cursor uint64, limit int) LogPage

Read 是 GUI 和未来 CLI 共用的增量接口;不返回 stdout、stderr 或环境变量。 游标跨服务重启连续,宿主进程结束后失效;掉队显式返回 Gap。

func (*History) Record

func (h *History) Record(instance, event, severity string, detail int, text string)

type IdentitySource

type IdentitySource interface {
	Identity(context.Context, string) (auth.LoginIdentity, error)
	EnsureFresh(context.Context, string) (credential.Token, error)
}

type Instance

type Instance struct {
	ID                string     `json:"id"`
	Host              string     `json:"host"`
	URL               string     `json:"url"`
	StartedAt         time.Time  `json:"startedAt"`
	Config            config.MCP `json:"config"`
	ConfigFingerprint string     `json:"configFingerprint"`
}

type Limits

type Limits struct {
	Connections, Transports, Closed, Executions, Requests, ActiveRequests int
	OutputBytes, TotalOutputBytes                                         int
	IdleTimeout, HistoryTTL, ConnectTimeout, ChannelTimeout, Cooldown     time.Duration
}

type ListExecutionsInput

type ListExecutionsInput struct {
	ConnectionID string `json:"connection_id,omitempty"`
	Status       string `json:"status,omitempty"`
}

type LogLine

type LogLine struct {
	Sequence     uint64    `json:"sequence"`
	Time         time.Time `json:"time"`
	Instance     string    `json:"instance"`
	Severity     string    `json:"severity"`
	Detail       int       `json:"detail"`
	ConnectionID string    `json:"connectionID,omitempty"`
	ExecutionID  string    `json:"executionID,omitempty"`
	Event        string    `json:"event"`
	Text         string    `json:"text"`
}

type LogPage

type LogPage struct {
	Lines      []LogLine `json:"lines"`
	NextCursor uint64    `json:"nextCursor"`
	HasMore    bool      `json:"hasMore"`
	Gap        bool      `json:"gap"`
}

type OpenInput

type OpenInput struct {
	Target     Target `json:"target"`
	RequestKey string `json:"request_key"`
	Reuse      *bool  `json:"reuse,omitempty"`
}

type OpenResult

type OpenResult struct {
	Status     string          `json:"status"`
	Connection *ConnectionView `json:"connection,omitempty"`
	Reused     bool            `json:"reused"`
	Error      *Fault          `json:"error,omitempty"`
}

type OutputChunk

type OutputChunk struct {
	Sequence uint64 `json:"seq"`
	Stream   string `json:"stream"`
	Encoding string `json:"encoding"`
	Data     string `json:"data"`
}

type OutputView

type OutputView struct {
	Chunks         []OutputChunk `json:"chunks"`
	NextCursor     uint64        `json:"next_cursor"`
	EarliestCursor uint64        `json:"earliest_cursor"`
	HasMore        bool          `json:"has_more"`
	Gap            bool          `json:"output_gap"`
	Truncated      bool          `json:"output_truncated"`
	Incomplete     bool          `json:"output_incomplete"`
	DroppedBytes   int64         `json:"dropped_bytes"`
}

type Page

type Page[T any] struct {
	Profile      string `json:"profile,omitempty"`
	Organization string `json:"organization,omitempty"`
	Items        []T    `json:"items"`
	Total        int    `json:"total"`
	NextCursor   string `json:"next_cursor,omitempty"`
}

type PageInput

type PageInput struct {
	Cursor string `json:"cursor,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

type PrepareUploadInput

type PrepareUploadInput struct {
	Target          Target        `json:"target,omitempty"`
	ConnectionID    string        `json:"connection_id,omitempty"`
	RequestKey      string        `json:"request_key"`
	RemoteDirectory string        `json:"remote_directory"`
	Format          string        `json:"format"`
	Size            int64         `json:"size"`
	Entries         []UploadEntry `json:"entries"`
}

type ProfilePageInput

type ProfilePageInput struct {
	PageInput
	Profile string `json:"profile"`
}

type ProfileView

type ProfileView struct {
	Name             string `json:"name"`
	Site             string `json:"site"`
	Organization     string `json:"organization"`
	Current          bool   `json:"current"`
	LoggedIn         bool   `json:"logged_in"`
	Expired          bool   `json:"expired"`
	RefreshAvailable bool   `json:"refresh_available"`
}

type ProtocolView

type ProtocolView struct {
	Name string `json:"name"`
	Port int    `json:"port"`
}

type Queries

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

func NewQueries

func NewQueries(instance string, config ConfigReader, auth AuthReader, resources ResourceReader) *Queries

func (*Queries) GetAsset

func (q *Queries) GetAsset(ctx context.Context, input AssetInput) (AssetResult, error)

func (*Queries) ListAccounts

func (q *Queries) ListAccounts(ctx context.Context, input AccountsInput) (Page[AccountView], error)

func (*Queries) ListAliases

func (q *Queries) ListAliases(ctx context.Context, input AliasesInput) (Page[AliasView], error)

func (*Queries) ListAssets

func (q *Queries) ListAssets(ctx context.Context, input AssetsInput) (Page[AssetView], error)

func (*Queries) ListOrganizations

func (q *Queries) ListOrganizations(ctx context.Context, input ProfilePageInput) (Page[jumpserver.Organization], error)

func (*Queries) ListProfiles

func (q *Queries) ListProfiles(ctx context.Context, input PageInput) (Page[ProfileView], error)

type QueryError

type QueryError struct {
	Code      string
	Message   string
	Retryable bool
}

func (*QueryError) Error

func (e *QueryError) Error() string

type ResolutionHint

type ResolutionHint struct {
	Profile      string        `json:"profile,omitempty"`
	Organization string        `json:"organization,omitempty"`
	AssetID      string        `json:"asset_id,omitempty"`
	NextTool     string        `json:"next_tool"`
	Assets       []AssetView   `json:"assets,omitempty"`
	Accounts     []AccountView `json:"accounts,omitempty"`
	Truncated    bool          `json:"truncated,omitempty"`
}

ResolutionHint 只提供当前解析范围和有界公开候选,不携带上游响应或凭据。

type ResolvedTarget

type ResolvedTarget struct {
	Target
	Site               string `json:"site"`
	CredentialIdentity string `json:"credential_identity"`
}

type ResourceReader

type ResourceReader interface {
	ListOrganizations(context.Context, string) ([]jumpserver.Organization, error)
	ListAssets(context.Context, string, string, string, int, int) (jumpserver.AssetPage, error)
	GetAssetByID(context.Context, string, string, string) (jumpserver.AssetDetail, error)
}

type Runtime

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

Runtime 的生存期属于宿主进程,不属于启动请求或 MCP 协议会话。

func NewRuntime

func NewRuntime(settings Settings, host string, handler HandlerFactory) *Runtime

func (*Runtime) CloseConnection

func (r *Runtime) CloseConnection(ctx context.Context, input CloseInput) (ConnectionView, error)

func (*Runtime) Connections

func (r *Runtime) Connections(ctx context.Context) ([]ConnectionView, error)

func (*Runtime) History

func (r *Runtime) History() *History

func (*Runtime) Restart

func (r *Runtime) Restart(ctx context.Context) (Status, error)

Restart 将本进程的停止与启动串行化;不会关闭或接管外部宿主。

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context) (Status, error)

func (*Runtime) Status

func (r *Runtime) Status(ctx context.Context) (Status, error)

func (*Runtime) Stop

func (r *Runtime) Stop(ctx context.Context) error

func (*Runtime) Wait

func (r *Runtime) Wait(ctx context.Context) error

Wait 等待当前监听结束,不依赖运行期间可能发生变化的磁盘配置。 取消等待不停止服务;宿主使用独立清理上下文调用 Stop。

type Settings

type Settings struct {
	Store config.Store
	// 仅兼容旧开发版的独立 Token 文件;显式保存后以 config.toml 为准。
	Credentials credential.Backend
	Locker      filelock.Locker
}

func (Settings) AcquireInstance

func (s Settings) AcquireInstance(ctx context.Context) (func() error, error)

AcquireInstance 约束服务生存期,同一应用数据目录只允许一个宿主监听。

func (Settings) Config

func (s Settings) Config() (config.MCP, error)

func (Settings) GenerateToken

func (s Settings) GenerateToken(ctx context.Context) (string, error)

GenerateToken 只生成草稿,不写配置或独立凭据,也不要求服务停止。

func (Settings) SaveConfig

func (s Settings) SaveConfig(ctx context.Context, value config.MCP) error

SaveConfig 一次原子写入完整配置;运行中的服务继续使用启动快照。

func (Settings) TokenConfigured

func (s Settings) TokenConfigured() (bool, error)

func (Settings) UpdateConfig

func (s Settings) UpdateConfig(ctx context.Context, change func(*config.MCP) error) (config.MCP, error)

UpdateConfig 在配置锁内读取最新值、合并修改并一次保存,避免覆盖并发修改的未指定字段。 变更回调不可再次获取配置锁;返回值仅在保存成功时有效。

type Status

type Status struct {
	State           string       `json:"state"`
	Instance        *Instance    `json:"instance"`
	Config          config.MCP   `json:"config"`
	TokenConfigured bool         `json:"tokenConfigured"`
	RestartRequired bool         `json:"restartRequired"`
	Error           string       `json:"error"`
	Counts          *EngineStats `json:"counts,omitempty"`
	StopWarning     string       `json:"stopWarning,omitempty"`
}

type Target

type Target struct {
	Profile      string `json:"profile,omitempty" jsonschema:"省略时使用当前 Profile,只读取不修改配置"`
	Name         string `` /* 138-byte string literal not displayed */
	Organization string `json:"organization,omitempty"`
	AssetID      string `json:"asset_id,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	Alias        string `json:"alias,omitempty"`
}

type UploadEntry

type UploadEntry struct {
	Name      string `json:"name"`
	Size      int64  `json:"size"`
	Directory bool   `json:"directory"`
}

type UploadIDInput

type UploadIDInput struct {
	UploadID string `json:"upload_id"`
}

type UploadInput

type UploadInput struct {
	Target          Target   `json:"target,omitempty"`
	ConnectionID    string   `json:"connection_id,omitempty"`
	RequestKey      string   `json:"request_key"`
	Source          string   `json:"source"`
	LocalPaths      []string `json:"local_paths"`
	RemoteDirectory string   `json:"remote_directory"`
	TimeoutMS       int      `json:"timeout_ms,omitempty"`
	WaitMS          *int     `json:"wait_ms,omitempty"`
	// contains filtered or unexported fields
}

type UploadProgress

type UploadProgress struct {
	Phase            string        `json:"phase"`
	Protocol         string        `json:"protocol,omitempty"`
	TransferredBytes int64         `json:"transferred_bytes"`
	TransferBytes    int64         `json:"transfer_bytes"`
	Published        *UploadResult `json:"-"`
}

type UploadRemote

type UploadRemote interface {
	OpenFile(string, int) (io.WriteCloser, error)
	Close() error
}

type UploadResult

type UploadResult struct {
	Directory       string         `json:"directory,omitempty"`
	Files           []UploadedFile `json:"files,omitempty"`
	Warnings        []string       `json:"warnings,omitempty"`
	RemoteArtifacts []string       `json:"remote_artifacts,omitempty"`
}

type UploadSFTP

type UploadSFTP struct {
	Client  UploadRemote
	Root    *string
	Account string
}

type UploadSourceInput

type UploadSourceInput struct {
	SourceID string `json:"source_id"`
}

type UploadSourceView

type UploadSourceView struct {
	uploadcache.View
	Target          ResolvedTarget `json:"target"`
	RemoteDirectory string         `json:"remote_directory,omitempty"`
	Format          string         `json:"format,omitempty"`
	EntryCount      int            `json:"entry_count"`
	URL             string         `json:"url,omitempty"`
	Method          string         `json:"method,omitempty"`
}

type UploadView

type UploadView struct {
	ID                 string         `json:"upload_id"`
	Target             ResolvedTarget `json:"target"`
	Status             string         `json:"status"`
	Source             string         `json:"source"`
	SourceID           string         `json:"source_id,omitempty"`
	HTTPSourceRequired bool           `json:"http_source_required,omitempty"`
	UploadProgress
	UploadResult
	FilesReady        bool       `json:"files_ready"`
	RemoteMayContinue bool       `json:"remote_may_continue"`
	AcceptedAt        time.Time  `json:"accepted_at"`
	DeadlineAt        time.Time  `json:"deadline_at"`
	FinishedAt        *time.Time `json:"finished_at,omitempty"`
	Error             *Fault     `json:"error,omitempty"`
}

type UploadedFile

type UploadedFile struct {
	Path      string `json:"path"`
	Name      string `json:"name"`
	Source    string `json:"source,omitempty"`
	Size      int64  `json:"size"`
	Directory bool   `json:"directory"`
	Status    string `json:"status"`
	Error     string `json:"error,omitempty"`
}

type UploadsPageInput

type UploadsPageInput struct {
	PageInput
	Status string `json:"status,omitempty"`
}

Jump to

Keyboard shortcuts

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