Repository navigation
Expand file tree
/
Copy pathdeclaration.go
More file actions
121 lines (116 loc) · 4.84 KB
/
Copy pathdeclaration.go
File metadata and controls
121 lines (116 loc) · 4.84 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Package mcode declares the MiniMax Code Harness.
package mcode
import (
"encoding/json"
"errors"
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
"github.com/MiniMax-AI/OpenAgentCore/internal/harnessconfig"
)
// FunctionServerLabel is the native MCP server that carries public functions.
const FunctionServerLabel = "functions"
// Declaration is the only authored description of the MiniMax Code Harness. The
// Runtime may narrow Capabilities for the installed host, never widen them.
// Whitespace-only text is unsupported because the native runtime refuses such
// prompts with "Local message content or attachments are required.".
var Declaration = harnessconfig.Declaration{
Kind: "mcode",
Label: "MiniMax Code",
Configuration: harnessconfig.Configuration{Providers: []harnessconfig.Provider{
{Protocol: "anthropic"},
{Protocol: "responses"},
{Protocol: "chat_completions"},
}, MaxOutputTokens: true},
Capabilities: proto.AgentKindCapabilities{
SubagentObservations: proto.CapabilitySupported,
Streaming: proto.CapabilitySupported,
Usage: proto.CapabilityUnsupported,
Resume: proto.CapabilitySupported,
RetainedNativeHistory: proto.CapabilityUnsupported,
NativeSessionRecovery: proto.CapabilityUnsupported,
MessageItems: proto.CapabilityUnsupported,
ToolObservations: proto.CapabilitySupported,
EnvironmentNone: proto.CapabilitySupported,
LocalEnvironment: proto.CapabilitySupported,
Preparation: proto.CapabilitySupported,
WorkspaceReadPreparation: proto.CapabilitySupported,
WorkspaceOutputExport: proto.CapabilitySupported,
ExecutionControls: proto.CapabilitySupported,
StructuredOutput: proto.CapabilityUnsupported,
ToolSearch: proto.CapabilityUnsupported,
MessageImages: proto.CapabilityUnsupported,
FunctionResultImages: proto.CapabilityUnsupported,
SubagentControl: proto.CapabilitySupported,
DurableInputReceipts: proto.CapabilitySupported,
DurableTurns: proto.CapabilitySupported,
FunctionTools: proto.CapabilitySupported,
MCPHTTPTools: proto.CapabilitySupported,
MCPHTTPRequired: proto.CapabilityUnsupported,
MCPHTTPBearerAuth: proto.CapabilitySupported,
},
// Native search needs a MiniMax account credential that Core does not hold, so
// features.webSearch stays false and disabled is the only mode. Effort becomes the
// custom model's only thinking option, and none disables native thinking.
// MiniMax Code has no native home for summary, service tier or programmatic
// tool calling.
// Medium is the official default verbosity and needs no setting.
Execution: harnessconfig.ExecutionOptions{
WebSearchModes: []string{"disabled"},
ReasoningEfforts: []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"},
ProgrammaticToolCalling: []bool{false},
TextVerbosities: []string{"medium"},
},
Placements: []string{"none", "openai_hosted", "self_hosted"},
MCPOrigins: []string{"service", "environment"},
WhitespaceOnlyText: proto.CapabilityUnsupported,
ValidateTools: func(functions []proto.FunctionTool, mcp []proto.MCPHTTPServer) error {
if err := harnessconfig.RequireObjectSchemas(functions); err != nil {
return err
}
for _, tool := range functions {
// The adapter's MCP server library gives x-mcp-header transport meaning.
if hasKey(tool.Parameters, "x-mcp-header") {
return errors.New("The configured engine does not support the x-mcp-header keyword in function schemas.")
}
}
for _, server := range mcp {
// Native starts session stdio servers in its home directory, which is private state, never the cwd a declaration names.
if server.Stdio != nil {
return errors.New("The configured engine cannot start MCP stdio servers in the declared cwd.")
}
if server.AllowedTools != nil || server.Required {
return errors.New("The configured engine requires allowed_tools=null and required=false.")
}
// The adapter serves public functions under this label.
if len(functions) > 0 && server.ServerLabel == FunctionServerLabel {
return errors.New("The configured engine reserves the HTTP MCP label functions.")
}
}
return nil
},
}
// hasKey reports whether the JSON document has an object member with this name at any depth.
func hasKey(raw json.RawMessage, key string) bool {
var found func(any) bool
found = func(v any) bool {
switch v := v.(type) {
case map[string]any:
if _, ok := v[key]; ok {
return true
}
for _, child := range v {
if found(child) {
return true
}
}
case []any:
for _, child := range v {
if found(child) {
return true
}
}
}
return false
}
var doc any
return json.Unmarshal(raw, &doc) == nil && found(doc)
}