Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/daemon/internal/agent/codex/executor_native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package codex
import (
"context"
"encoding/json"
"log/slog"
"os"
"os/exec"
"strings"
Expand All @@ -11,7 +12,6 @@ import (

"github.com/MiniMax-AI/OpenAgentCore/apps/daemon/internal/agent"
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
obslog "github.com/MiniMax-AI/OpenAgentCore/internal/obs/log"
)

// This opt-in test uses the real pinned harness and an explicitly configured
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestExecutorNativeReuse(t *testing.T) {
}
cfg := defaultSessionConfig()
cfg.codexBinary = binary
cfg.logger = obslog.Discard()
cfg.logger = slog.New(slog.DiscardHandler)
req := proto.PromptRequestPayload{
AgentKind: "codex", AgentStateKey: "executor-native",
DisableExecutionEnvironment: true, DisableSubagents: true, ObserveMessages: true,
Expand Down
69 changes: 0 additions & 69 deletions apps/daemon/internal/agent/installroot/lock.go

This file was deleted.

39 changes: 0 additions & 39 deletions apps/daemon/internal/agent/installroot/lock_test.go

This file was deleted.

1 change: 1 addition & 0 deletions apps/daemon/internal/agent/installroot/probe.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package installroot probes native adapter installations.
package installroot

import (
Expand Down
26 changes: 12 additions & 14 deletions apps/daemon/internal/agent/mcode/declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,18 @@ func discoverWithCheck(parent context.Context, options agent.DiscoveryOptions, r
return runtime
}
result.Available, result.Version = true, version
if SupportsExecution(version) {
result.Capabilities.Steering = proto.CapabilitySupported
result.Capabilities.DurableTurns = proto.CapabilitySupported
result.Capabilities.DurableInputReceipts = proto.CapabilitySupported
result.Capabilities.ExecutionControls = proto.CapabilitySupported
result.Capabilities.ProgrammaticToolCallingDisable = proto.CapabilitySupported
result.Capabilities.ToolObservations = proto.CapabilitySupported
result.Capabilities.SubagentControl = proto.CapabilitySupported
// Native preparation verifies the applied admission/tool profile before input.
result.Capabilities.SubagentObservations = proto.CapabilitySupported
result.Capabilities.EnvironmentNone = proto.CapabilitySupported
result.Capabilities.MCPHTTPTools = proto.CapabilitySupported
result.Capabilities.MCPHTTPBearerAuth = proto.CapabilitySupported
}
result.Capabilities.Steering = proto.CapabilitySupported
result.Capabilities.DurableTurns = proto.CapabilitySupported
result.Capabilities.DurableInputReceipts = proto.CapabilitySupported
result.Capabilities.ExecutionControls = proto.CapabilitySupported
result.Capabilities.ProgrammaticToolCallingDisable = proto.CapabilitySupported
result.Capabilities.ToolObservations = proto.CapabilitySupported
result.Capabilities.SubagentControl = proto.CapabilitySupported
// Native preparation verifies the applied admission/tool profile before input.
result.Capabilities.SubagentObservations = proto.CapabilitySupported
result.Capabilities.EnvironmentNone = proto.CapabilitySupported
result.Capabilities.MCPHTTPTools = proto.CapabilitySupported
result.Capabilities.MCPHTTPBearerAuth = proto.CapabilitySupported
runtime.Info = result
workspace := discoverWorkspace(parent, options, runtime)
if runtime.Info.Available {
Expand Down
21 changes: 11 additions & 10 deletions apps/daemon/internal/agent/mcode/declaration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mcode

import (
"context"
"errors"
"io"
"reflect"
"testing"
Expand All @@ -10,20 +11,20 @@ import (
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
)

func TestMCodeExecutionOptInIsVersionBound(t *testing.T) {
// An available runtime is execution-capable; a rejected native version is unavailable.
func TestMCodeExecutionFollowsAvailability(t *testing.T) {
for _, tc := range []struct {
enabled, version string
qualified bool
}{{"", "0.4.12", false}, {"1", "0.3.11", false}, {"1", "0.4.12", true}} {
t.Run(tc.enabled+"/"+tc.version, func(t *testing.T) {
t.Setenv("OAC_RUNTIME_MCODE_AGENTS_API", tc.enabled)
version string
check error
}{{SupportedVersion, nil}, {"0.3.11", errors.New("mcode: unsupported version 0.3.11")}} {
t.Run(tc.version, func(t *testing.T) {
rc := agent.DiscoveryOptions{Stdout: io.Discard, Stderr: io.Discard}
runtime := discoverWithCheck(t.Context(), rc, Declaration.Info, func(context.Context, string) (string, error) { return tc.version, nil })
if runtime.Executor == nil || runtime.Info.Capabilities.WorkspaceReadPreparation.IsSupported() {
runtime := discoverWithCheck(t.Context(), rc, Declaration.Info, func(context.Context, string) (string, error) { return tc.version, tc.check })
info, available := runtime.Info, tc.check == nil
if (runtime.Executor != nil) != available || info.Capabilities.WorkspaceReadPreparation.IsSupported() {
t.Fatalf("factories: %+v", runtime)
}
info := runtime.Info
if !info.Available || info.Capabilities.EnvironmentNone.IsSupported() != tc.qualified || info.Capabilities.DurableInputReceipts.IsSupported() != tc.qualified || info.Capabilities.SubagentObservations.IsSupported() != tc.qualified {
if info.Available != available || info.Capabilities.EnvironmentNone.IsSupported() != available || info.Capabilities.DurableInputReceipts.IsSupported() != available || info.Capabilities.SubagentObservations.IsSupported() != available {
t.Fatalf("capabilities=%+v", info.Capabilities)
}
if info.Capabilities.NativeSessionRecovery.IsSupported() || info.Capabilities.LocalEnvironment.IsSupported() || info.Capabilities.FunctionTools.IsSupported() {
Expand Down
4 changes: 0 additions & 4 deletions apps/daemon/internal/agent/mcode/discovery_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ func discoverWorkspace(parent context.Context, options agent.DiscoveryOptions, r
if binding == nil {
return nil
}
if !runtime.Info.Available || !SupportsExecution(runtime.Info.Version) {
fail(fmt.Errorf("local execution requires the qualified native version"))
return nil
}
root, err := paths.Root()
if err != nil {
fail(err)
Expand Down
7 changes: 0 additions & 7 deletions apps/daemon/internal/agent/mcode/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import (
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
)

// SupportsExecution reports whether the daemon advertises MiniMax Code execution:
// the operator sets OAC_RUNTIME_MCODE_AGENTS_API=1 and the native version is the
// qualified one. Otherwise discovery reports only 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")
Expand Down
2 changes: 1 addition & 1 deletion apps/daemon/internal/agent/mcode/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func Installation() agent.Installation {
return agent.Installation{AgentKind: "mcode", Version: SupportedVersion, Supported: func() bool { return runtime.GOOS == "linux" || runtime.GOOS == "darwin" },
Environment: func(dir, node string) map[string]string {
return map[string]string{"OAC_RUNTIME_MCODE_BIN": filepath.Join(dir, "native", "cli.js"), "OAC_RUNTIME_MCODE_NODE": node, "OAC_RUNTIME_MCODE_WORKSPACE_BRIDGE": filepath.Join(dir, "bridge.mjs"), "OAC_RUNTIME_MCODE_AGENTS_API": "1"}
return map[string]string{"OAC_RUNTIME_MCODE_BIN": filepath.Join(dir, "native", "cli.js"), "OAC_RUNTIME_MCODE_NODE": node, "OAC_RUNTIME_MCODE_WORKSPACE_BRIDGE": filepath.Join(dir, "bridge.mjs")}
},
Check: func(ctx context.Context, dir, node string, env []string) error {
got, err := installroot.Probe(ctx, node, []string{filepath.Join(dir, "native", "cli.js"), "--version"}, env, dir)
Expand Down
2 changes: 1 addition & 1 deletion apps/daemon/internal/cli/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func spawnBackground(ctx context.Context, rc *runContext, profile string, argv [
} else if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, daemonize.ErrStaleOrCorrupt) {
return fmt.Errorf("connect: check pidfile: %w", err)
}
// Stale pidfile → remove so WritePIDFile starts clean.
// Stale pidfile → remove so Spawn starts clean.
_ = daemonize.RemovePIDFile(pidPath)

if err := daemonize.EnsureLogFile(logPath); err != nil {
Expand Down
11 changes: 0 additions & 11 deletions apps/daemon/internal/cli/connect_environment_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ func bindEnvironmentRuntime(remote string, bound environmentEnrollment, credenti
return nil
}

// Neither selecting private state nor selecting its parent grants workspace access.
func environmentPathsOverlap(first, second string) bool {
for _, pair := range [][2]string{{first, second}, {second, first}} {
relative, err := filepath.Rel(pair[0], pair[1])
if err == nil && (relative == "." || filepath.IsLocal(relative)) {
return true
}
}
return false
}

func saveEnvironmentBinding(root string, want environmentBinding) error {
// Store the binding with the other daemon state.
dir := filepath.Join(root, "daemon")
Expand Down
25 changes: 2 additions & 23 deletions apps/daemon/internal/daemonize/logfile.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package daemonize

import (
"bufio"
"errors"
"fmt"
"github.com/MiniMax-AI/OpenAgentCore/internal/runtimefs"
"io"
"os"
"path/filepath"
"time"

"github.com/MiniMax-AI/OpenAgentCore/internal/runtimefs"
)

// TailOptions configures Tail.
Expand Down Expand Up @@ -149,27 +149,6 @@ func EnsureLogFile(path string) error {
return f.Close()
}

// MustWriteLine appends one line to path with 0o600 mode, adding a
// trailing newline if missing. Returns errors despite the name —
// kept short because it's used in startup hot paths.
func MustWriteLine(path string, line string) error {
f, err := openPrivateLog(path)
if err != nil {
return err
}
defer f.Close()
bw := bufio.NewWriter(f)
if _, err := bw.WriteString(line); err != nil {
return err
}
if len(line) == 0 || line[len(line)-1] != '\n' {
if _, err := bw.WriteString("\n"); err != nil {
return err
}
}
return bw.Flush()
}

func openPrivateLog(path string) (*os.File, error) {
root, err := os.OpenRoot(filepath.Dir(path))
if err != nil {
Expand Down
15 changes: 0 additions & 15 deletions apps/daemon/internal/daemonize/logfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,6 @@ func TestEnsureLogFileCreatesMissingParentDir(t *testing.T) {
}
}

func TestMustWriteLineAppendsTrailingNewline(t *testing.T) {
dir := privateTempDir(t)
path := filepath.Join(dir, "ml.log")
if err := MustWriteLine(path, "no-newline"); err != nil {
t.Fatalf("MustWriteLine: %v", err)
}
if err := MustWriteLine(path, "has-newline\n"); err != nil {
t.Fatalf("MustWriteLine: %v", err)
}
body, _ := os.ReadFile(path)
if string(body) != "no-newline\nhas-newline\n" {
t.Errorf("body = %q", string(body))
}
}

// safeBuf wraps bytes.Buffer with a mutex so concurrent reads/writes
// during Tail's poll loop don't race.
type safeBuf struct {
Expand Down
11 changes: 0 additions & 11 deletions apps/daemon/internal/daemonize/pidfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ type processIdentity struct {
StopEvent string `json:"stop_event,omitempty"`
}

func WritePIDFile(path string, pid int) error {
identity, err := identifyProcess(pid)
if err != nil {
return err
}
identity.StopEvent = os.Getenv(stopEventEnv)
return writeIdentity(path, identity)
}

func writeIdentity(path string, identity processIdentity) error {
if path == "" {
return errors.New("daemonize: process record path required")
Expand Down Expand Up @@ -71,8 +62,6 @@ func ReadPIDFile(path string) (int, error) {
return identity.PID, err
}

func IsAlive(pid int) error { _, err := identifyProcess(pid); return err }

// StopPIDFile never removes ownership before the exact process has exited.
// A cleanup timeout leaves the record available for observation and a later stop.
func StopPIDFile(path string, timeout time.Duration) error {
Expand Down
8 changes: 6 additions & 2 deletions apps/daemon/internal/daemonize/pidfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import (

func TestProcessRecordIdentity(t *testing.T) {
path := filepath.Join(privateTempDir(t), "connect.pid")
if err := WritePIDFile(path, os.Getpid()); err != nil {
record, err := identifyProcess(os.Getpid())
if err == nil {
err = writeIdentity(path, record)
}
if err != nil {
t.Fatal(err)
}
pid, err := ReadPIDFile(path)
Expand All @@ -34,7 +38,7 @@ func TestProcessRecordIdentity(t *testing.T) {
if err = StopPIDFile(path, time.Second); !errors.Is(err, ErrStaleOrCorrupt) {
t.Fatal("stale identity was accepted", err)
}
if err = IsAlive(os.Getpid()); err != nil {
if _, err = identifyProcess(os.Getpid()); err != nil {
t.Fatal("unrelated process was affected", err)
}
if _, err = os.Stat(path); err != nil {
Expand Down
Loading
Loading