Skip to content

Commit 3436d7e

Browse files
committed
refactor: use external go-restricted-runner package
The runner package has been extracted to a standalone repository at github.com/inercia/go-restricted-runner. This commit: - Removes the local pkg/runner/ directory (20 files) - Updates imports in pkg/command to use the external package - Adds go-restricted-runner as a dependency - Creates a runner-compatible logger adapter for the external package The external package provides the same runner implementations: exec, sandbox-exec (macOS), firejail (Linux), and docker.
1 parent 6930c35 commit 3436d7e

20 files changed

Lines changed: 15 additions & 2721 deletions

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.25.5
55
require (
66
github.com/Masterminds/sprig/v3 v3.3.0
77
github.com/google/cel-go v0.26.1
8+
github.com/inercia/go-restricted-runner v0.0.0-20260204084804-4beca5b00656
89
github.com/mark3labs/mcp-go v0.43.2
9-
github.com/sashabaranov/go-openai v1.41.2
1010
github.com/spf13/cobra v1.10.2
1111
golang.org/x/sys v0.40.0
1212
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI
3030
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
3131
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3232
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
33+
github.com/inercia/go-restricted-runner v0.0.0-20260204084804-4beca5b00656 h1:HiSK6vBznkAmgZSsuK2zETq2k8dDTZd2VuaGBsQz5kQ=
34+
github.com/inercia/go-restricted-runner v0.0.0-20260204084804-4beca5b00656/go.mod h1:4eJiTSKybwS7d6yCPiX26xIN1mfLkqRj69cNaW3RltQ=
3335
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
3436
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
3537
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@@ -52,8 +54,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
5254
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
5355
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
5456
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
55-
github.com/sashabaranov/go-openai v1.41.2 h1:vfPRBZNMpnqu8ELsclWcAvF19lDNgh1t6TVfFFOPiSM=
56-
github.com/sashabaranov/go-openai v1.41.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
5757
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
5858
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
5959
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=

pkg/command/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
"github.com/inercia/MCPShell/pkg/common"
1818
"github.com/inercia/MCPShell/pkg/config"
19-
"github.com/inercia/MCPShell/pkg/runner"
19+
"github.com/inercia/go-restricted-runner/pkg/runner"
2020
)
2121

2222
// CommandHandler encapsulates the configuration and behavior needed to handle tool commands.

pkg/command/command_exec.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88
"time"
99

1010
"github.com/inercia/MCPShell/pkg/common"
11-
"github.com/inercia/MCPShell/pkg/runner"
11+
runnercommon "github.com/inercia/go-restricted-runner/pkg/common"
12+
"github.com/inercia/go-restricted-runner/pkg/runner"
1213
)
1314

1415
// executeToolCommand handles the core logic of executing a command with the given parameters.
@@ -153,7 +154,15 @@ func (h *CommandHandler) executeToolCommand(ctx context.Context, params map[stri
153154

154155
// Create the appropriate runner with options
155156
h.logger.Debug("Creating runner of type %s and checking implicit requirements", runnerType)
156-
r, err := runner.New(runnerType, runnerOptions, h.logger)
157+
158+
// Create a runner-compatible logger
159+
runnerLogger, err := runnercommon.NewLogger("", "", runnercommon.LogLevel(h.logger.Level()), false)
160+
if err != nil {
161+
h.logger.Error("Error creating runner logger: %v", err)
162+
return "", nil, fmt.Errorf("error creating runner logger: %v", err)
163+
}
164+
165+
r, err := runner.New(runnerType, runnerOptions, runnerLogger)
157166
if err != nil {
158167
h.logger.Error("Error creating runner: %v", err)
159168
return "", nil, fmt.Errorf("error creating runner: %v", err)

0 commit comments

Comments
 (0)