Repository navigation
Expand file tree
/
Copy pathexecution_test.go
More file actions
66 lines (60 loc) · 1.96 KB
/
Copy pathexecution_test.go
File metadata and controls
66 lines (60 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mcode
import (
"encoding/json"
"os"
"path/filepath"
"strings"
"testing"
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
)
func TestExecutionOptionsInheritUserEnvironment(t *testing.T) {
r := testRequest(t)
t.Setenv("OAC_TEST_SECRET_CANARY", "secret")
t.Setenv("NODE_OPTIONS", "--import=untrusted")
opts, err := prepareOptions(testStateRoot(t), r)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(strings.Join(opts.Env, "\n"), "OAC_TEST_SECRET_CANARY=secret") {
t.Fatal("user environment lost")
}
data, err := os.ReadFile(filepath.Join(opts.DataDir, "config.yaml"))
if err != nil {
t.Fatal(err)
}
var config map[string]any
if json.Unmarshal(data, &config) != nil {
t.Fatal("bad config")
}
features := config["agents"].(map[string]any)["default"].(map[string]any)["features"].(map[string]any)
for _, k := range []string{"mavis", "delegation", "webSearch"} {
if features[k] != false {
t.Fatalf("%s remains enabled", k)
}
}
}
func TestExecutionRejectsUnqualifiedAuthority(t *testing.T) {
for _, change := range []func(*proto.PromptRequestPayload){
func(r *proto.PromptRequestPayload) { r.DisableExecutionEnvironment = false },
func(r *proto.PromptRequestPayload) { r.DisableSubagents = false },
func(r *proto.PromptRequestPayload) { r.RequireExistingNativeSession = true },
func(r *proto.PromptRequestPayload) { r.FunctionTools = []proto.FunctionTool{{Name: "f"}} },
func(r *proto.PromptRequestPayload) {
r.ExecutionControls.WebSearch = &proto.WebSearchControl{Mode: "live", ContextSize: "medium"}
},
} {
r := testRequest(t)
change(&r)
if _, err := prepareOptions(testStateRoot(t), r); err == nil {
t.Fatal("unsupported execution accepted")
}
}
}
func TestPublicTextDoesNotInvokeACPCommands(t *testing.T) {
for _, text := range []string{"/model", "/compact", "hello"} {
blocks := promptContent(text)
if len(blocks) != 2 || blocks[0]["text"] != text || blocks[1]["text"] != "" {
t.Fatal(blocks)
}
}
}