-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathexecution.go
More file actions
62 lines (55 loc) · 2.62 KB
/
Copy pathexecution.go
File metadata and controls
62 lines (55 loc) · 2.62 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
package mcode
import (
"fmt"
"os"
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
)
// SupportsExecution is an operator opt-in, separate from ordinary product availability.
func SupportsExecution(version string) bool {
return os.Getenv("OAC_RUNTIME_MCODE_AGENTS_API") == "1" && version == SupportedVersion
}
func validateExecutionRequest(req proto.PromptRequestPayload) error {
if !req.DisableExecutionEnvironment || req.AgentStateKey == "" || req.LocalEnvironment != nil || req.RequireExistingNativeSession || len(req.FunctionTools) != 0 || (req.MCPHTTPServers != nil && len(*req.MCPHTTPServers) != 0) {
return fmt.Errorf("mcode: unsupported execution configuration")
}
if req.ExecutionControls == nil || req.ExecutionControls.OutputFormat != nil || req.ExecutionControls.WebSearch != "disabled" || (req.ExecutionControls.TextVerbosity != "" && req.ExecutionControls.TextVerbosity != "medium") {
return fmt.Errorf("mcode: unsupported execution controls")
}
if !req.DisableSubagents {
if req.MaxConcurrentSubagents == nil || *req.MaxConcurrentSubagents < 1 {
return fmt.Errorf("mcode: Subagent concurrency limit is required")
}
if _, _, err := subagentReader(); err != nil {
return err
}
}
if mode := optionString(req.AgentOptions, "mode"); mode != "" {
return fmt.Errorf("mcode: text execution uses default native permissions")
}
if req.AgentOptions["plugins"] != nil {
return fmt.Errorf("mcode: execution cannot import plugins")
}
if req.AgentOptions["skills"] != nil || req.AgentOptions["mcp_servers"] != nil || req.AgentOptions["env"] != nil {
return fmt.Errorf("mcode: execution cannot import product capabilities or environment")
}
return nil
}
func configureTextExecution(config map[string]any) {
config["agents"] = map[string]any{"default": map[string]any{
"tools": []string{}, "builtinTools": []string{}, "skills": []string{},
"features": map[string]bool{"mavis": false, "delegation": false, "webSearch": false},
}}
config["askUser"] = map[string]bool{"enabled": false}
config["beta"] = map[string]bool{"browserUseTooling": false, "mcodeTools": false, "threadGoal": false}
}
// Harness children use the daemon user's ordinary environment.
func executionEnvironment() []string { return os.Environ() }
// ACP commands are only recognized for a single text block. Public input must
// remain user text; ordinary product Sessions retain their native command behavior.
func promptContent(text string, public bool) []map[string]string {
blocks := []map[string]string{{"type": "text", "text": text}}
if public {
blocks = append(blocks, map[string]string{"type": "text", "text": ""})
}
return blocks
}