WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
package sandbox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type contractHandle struct {
|
||||
id string
|
||||
provider RemoteProvider
|
||||
metadata map[string]string
|
||||
}
|
||||
|
||||
func (h *contractHandle) ID() string { return h.id }
|
||||
func (h *contractHandle) Provider() RemoteProvider { return h.provider }
|
||||
func (h *contractHandle) Metadata() map[string]string { return h.metadata }
|
||||
|
||||
type contractClient struct {
|
||||
provider RemoteProvider
|
||||
capabilities RemoteSandboxCapabilities
|
||||
}
|
||||
|
||||
func (c *contractClient) Provider() RemoteProvider { return c.provider }
|
||||
func (c *contractClient) Capabilities() RemoteSandboxCapabilities {
|
||||
return c.capabilities
|
||||
}
|
||||
func (c *contractClient) Health(context.Context) error { return nil }
|
||||
func (c *contractClient) Create(_ context.Context, req RemoteCreateRequest) (RemoteSandboxHandle, error) {
|
||||
return &contractHandle{id: "sandbox-1", provider: c.provider, metadata: req.Metadata}, nil
|
||||
}
|
||||
func (c *contractClient) Connect(context.Context, RemoteConnectRequest) (RemoteSandboxHandle, error) {
|
||||
return &contractHandle{id: "sandbox-1", provider: c.provider}, nil
|
||||
}
|
||||
func (c *contractClient) Get(context.Context, string) (*RemoteSandboxSummary, error) {
|
||||
return &RemoteSandboxSummary{ID: "sandbox-1", State: RemoteStateRunning}, nil
|
||||
}
|
||||
func (c *contractClient) List(context.Context, RemoteListFilter) ([]RemoteSandboxSummary, error) {
|
||||
return []RemoteSandboxSummary{{ID: "sandbox-1", State: RemoteStateRunning}}, nil
|
||||
}
|
||||
func (c *contractClient) Delete(context.Context, string) error { return nil }
|
||||
func (c *contractClient) Exec(
|
||||
context.Context,
|
||||
RemoteSandboxHandle,
|
||||
RemoteExecRequest,
|
||||
) (*RemoteExecResult, error) {
|
||||
return &RemoteExecResult{ExitCode: 0}, nil
|
||||
}
|
||||
func (c *contractClient) WriteFile(context.Context, RemoteSandboxHandle, string, []byte) error {
|
||||
return nil
|
||||
}
|
||||
func (c *contractClient) ReadFile(context.Context, RemoteSandboxHandle, string) ([]byte, error) {
|
||||
return []byte("content"), nil
|
||||
}
|
||||
func (c *contractClient) ListDir(context.Context, RemoteSandboxHandle, string) ([]RemoteDirEntry, error) {
|
||||
return []RemoteDirEntry{{Name: "file", Type: RemoteEntryFile}}, nil
|
||||
}
|
||||
func (c *contractClient) MakeDir(context.Context, RemoteSandboxHandle, string) error {
|
||||
return nil
|
||||
}
|
||||
func (c *contractClient) Remove(context.Context, RemoteSandboxHandle, string) error {
|
||||
return nil
|
||||
}
|
||||
func (c *contractClient) Stat(context.Context, RemoteSandboxHandle, string) (*RemoteStatEntry, error) {
|
||||
return &RemoteStatEntry{Path: "/workspace/file", Type: RemoteEntryFile}, nil
|
||||
}
|
||||
|
||||
var _ RemoteSandboxClient = (*contractClient)(nil)
|
||||
|
||||
func TestRemoteClientContractExposesProviderAndReconnectCapability(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := &contractClient{
|
||||
provider: SandboxTypeE2B,
|
||||
capabilities: RemoteSandboxCapabilities{
|
||||
SupportsReconnect: true,
|
||||
},
|
||||
}
|
||||
|
||||
if got := client.Provider(); got != SandboxTypeE2B {
|
||||
t.Fatalf("Provider() = %q, want %q", got, SandboxTypeE2B)
|
||||
}
|
||||
if !client.Capabilities().SupportsReconnect {
|
||||
t.Fatal("reconnect capability must be explicit")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteTypesRepresentProviderNeutralSemantics(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
timeout := RemoteTimeoutPolicy{
|
||||
Mode: RemoteTimeoutExplicit,
|
||||
Value: 15 * time.Minute,
|
||||
Action: RemoteOnTimeoutPause,
|
||||
AutoResume: true,
|
||||
}
|
||||
if timeout.Mode != RemoteTimeoutExplicit || timeout.Action != RemoteOnTimeoutPause {
|
||||
t.Fatalf("unexpected timeout policy: %+v", timeout)
|
||||
}
|
||||
|
||||
direct := RemoteExecRequest{Command: "python3", Args: []string{"-V"}}
|
||||
if direct.Shell || len(direct.Args) != 1 {
|
||||
t.Fatalf("direct execution lost argv semantics: %+v", direct)
|
||||
}
|
||||
|
||||
shell := RemoteExecRequest{Command: "printf '%s' ok", Shell: true}
|
||||
if !shell.Shell || len(shell.Args) != 0 {
|
||||
t.Fatalf("shell execution representation is ambiguous: %+v", shell)
|
||||
}
|
||||
|
||||
states := []RemoteSandboxState{
|
||||
RemoteStateRunning,
|
||||
RemoteStatePaused,
|
||||
RemoteStateTransitioning,
|
||||
RemoteStateTerminal,
|
||||
RemoteStateUnknown,
|
||||
}
|
||||
if got, want := len(states), 5; got != want {
|
||||
t.Fatalf("normalized state count = %d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user