源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
This commit is contained in:
commit
2ed3415fb7
8018 files changed
+1936476
No files matched your search
@@ -0,0 +1,107 @@
|
||||
package agentruntime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultWorkspaceEnvName = "TUTTI_WORKSPACE_ID"
|
||||
defaultOpenClawSessionKeyPrefix = "agent:main:tsh-"
|
||||
)
|
||||
|
||||
type ClientInfo struct {
|
||||
Name string
|
||||
Title string
|
||||
Version string
|
||||
}
|
||||
|
||||
type HostMetadata struct {
|
||||
ClientInfo ClientInfo
|
||||
WorkspaceEnvName string
|
||||
OpenClawSessionKeyPrefix string
|
||||
}
|
||||
|
||||
// CommandNetworkAccessPolicy returns whether the host explicitly allows a
|
||||
// provider's commands and subprocesses to use the network. A nil policy denies
|
||||
// command network access.
|
||||
type CommandNetworkAccessPolicy func(provider string) bool
|
||||
|
||||
type ControllerOptions struct {
|
||||
HostMetadata HostMetadata
|
||||
ProviderCommandResolver ProviderCommandResolver
|
||||
ProviderLaunchPreparer ProviderLaunchPreparer
|
||||
AdapterResolver AdapterResolver
|
||||
CommandNetworkAccessPolicy CommandNetworkAccessPolicy
|
||||
}
|
||||
|
||||
type AdapterResolveInput struct {
|
||||
Provider string
|
||||
AgentTargetID string
|
||||
CWD string
|
||||
ProviderTargetRef map[string]any
|
||||
}
|
||||
|
||||
type AdapterResolver interface {
|
||||
ResolveAdapter(context.Context, AdapterResolveInput) (Adapter, error)
|
||||
}
|
||||
|
||||
type ProviderCommand struct {
|
||||
Command []string
|
||||
Env []string
|
||||
}
|
||||
|
||||
type ProviderCommandResolver func(context.Context, string) (ProviderCommand, error)
|
||||
|
||||
func LegacyHostMetadata() HostMetadata {
|
||||
return HostMetadata{
|
||||
ClientInfo: ClientInfo{
|
||||
Name: "tsh-desktop",
|
||||
Title: "tsh",
|
||||
Version: "0.1.0",
|
||||
},
|
||||
WorkspaceEnvName: defaultWorkspaceEnvName,
|
||||
OpenClawSessionKeyPrefix: defaultOpenClawSessionKeyPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeHostMetadata(input HostMetadata) HostMetadata {
|
||||
defaults := LegacyHostMetadata()
|
||||
out := input
|
||||
if strings.TrimSpace(out.ClientInfo.Name) == "" {
|
||||
out.ClientInfo.Name = defaults.ClientInfo.Name
|
||||
}
|
||||
if strings.TrimSpace(out.ClientInfo.Title) == "" {
|
||||
out.ClientInfo.Title = defaults.ClientInfo.Title
|
||||
}
|
||||
if strings.TrimSpace(out.ClientInfo.Version) == "" {
|
||||
out.ClientInfo.Version = defaults.ClientInfo.Version
|
||||
}
|
||||
if strings.TrimSpace(out.WorkspaceEnvName) == "" {
|
||||
out.WorkspaceEnvName = defaults.WorkspaceEnvName
|
||||
}
|
||||
if strings.TrimSpace(out.OpenClawSessionKeyPrefix) == "" {
|
||||
out.OpenClawSessionKeyPrefix = defaults.OpenClawSessionKeyPrefix
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (m HostMetadata) clientInfoParams() map[string]any {
|
||||
return map[string]any{
|
||||
"name": m.ClientInfo.Name,
|
||||
"title": m.ClientInfo.Title,
|
||||
"version": m.ClientInfo.Version,
|
||||
}
|
||||
}
|
||||
|
||||
func workspaceEnv(session Session, host HostMetadata) []string {
|
||||
roomID := strings.TrimSpace(session.RoomID)
|
||||
if roomID == "" {
|
||||
return nil
|
||||
}
|
||||
envName := strings.TrimSpace(host.WorkspaceEnvName)
|
||||
if envName == "" {
|
||||
return nil
|
||||
}
|
||||
return []string{envName + "=" + roomID}
|
||||
}
|
||||
Reference in new issue
Block a user