chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)

This commit is contained in:
runny committed 2026-11-13 17:54:56 +08:00
commit 9097ee699d
5769 files changed
+1446466

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package sandbox
import (
"context"
"fmt"
)
func connectRemoteSession(
ctx context.Context, client RemoteSandboxClient, req RemoteConnectRequest,
) (RemoteSandboxHandle, error) {
if connector, ok := client.(RemoteSessionConnector); ok {
return connector.ConnectSession(ctx, req)
}
// Compatibility for providers that do not offer a combined connect/probe.
summary, err := client.Get(ctx, req.SandboxID)
if err != nil {
return nil, err
}
if err := validateSessionSummary(client.Provider(), req.SandboxID, summary); err != nil {
return nil, err
}
return client.Connect(ctx, req)
}
func validateSessionSummary(provider RemoteProvider, id string, summary *RemoteSandboxSummary) error {
if summary == nil {
return NewRemoteError(provider, "ConnectSession", RemoteErrorKindInternal,
"provider returned no sandbox summary", nil)
}
if summary.ID != id {
return NewRemoteError(provider, "ConnectSession", RemoteErrorKindInternal,
fmt.Sprintf("provider returned sandbox %q for binding %q", summary.ID, id), nil)
}
if summary.State == RemoteStateTerminal {
return NewRemoteError(provider, "ConnectSession", RemoteErrorKindTerminal, "sandbox is terminal", nil)
}
return nil
}