oficina / equipo Public

claude: answer in-profile workspace file actions without asking

The ask rules route workspace Read/Write/Edit/Glob/Grep through Equipo's
callback so symlink refusals are observable. Protected paths are refused
first; other workspace paths are allowed by Equipo, so only actions beyond
the profile reach a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 07d9f80c27735b68aa31932f41d65d352b8fa35c parent f43b06d
2 files changed, +48 −1
  • internal/runner/provider/claude/answers.go +33 −0
  • internal/runner/provider/claude/answers_test.go +15 −1

CI cancelled — superseded by a newer push — run details

diff --git a/internal/runner/provider/claude/answers.go b/internal/runner/provider/claude/answers.go
index 0f2b5208..461bae4c 100644
--- a/internal/runner/provider/claude/answers.go
+++ b/internal/runner/provider/claude/answers.go
@@ -53,6 +53,12 @@ func (l *Launcher) Permission(ctx context.Context, session provider.Session, raw
l.mu.Unlock()
return permissionResult(q, provider.Answer{Behavior: "deny"}, s.launch.Policy)
}
+ // Workspace file actions are within the profile: Equipo answers them after
+ // the protected-path check, so the person is only asked beyond the profile.
+ if workspaceNativePath(q) {
+ l.mu.Unlock()
+ return permissionResult(q, provider.Answer{Behavior: "allow"}, s.launch.Policy)
+ }
id := "permission:" + rand.Text()
p := &pendingPermission{raw: bytes.Clone(raw), request: q, turn: s.turn.ID, reply: make(chan json.RawMessage, 1)}
if s.permissions == nil {
@@ -264,3 +270,30 @@ func protectedNativePath(q permissionRequest, policy provider.Policy) bool {
}
return false
}
+
+// workspaceNativePath reports a native file action whose path is inside
+// /workspace. Callers must first refuse protectedNativePath, which also
+// rejects workspace symlinks that leave the workspace.
+func workspaceNativePath(q permissionRequest) bool {
+ if !slices.Contains([]string{"Read", "Write", "Edit", "Glob", "Grep"}, q.Tool) {
+ return false
+ }
+ var input map[string]json.RawMessage
+ if json.Unmarshal(q.Input, &input) != nil {
+ return false
+ }
+ path := "/workspace"
+ for _, key := range []string{"file_path", "path"} {
+ if raw, ok := input[key]; ok {
+ if json.Unmarshal(raw, &path) != nil || path == "" || strings.HasPrefix(path, "~") {
+ return false
+ }
+ break
+ }
+ }
+ if !filepath.IsAbs(path) {
+ path = filepath.Join("/workspace", path)
+ }
+ path = filepath.Clean(path)
+ return path == "/workspace" || strings.HasPrefix(path, "/workspace/")
+}
diff --git a/internal/runner/provider/claude/answers_test.go b/internal/runner/provider/claude/answers_test.go
index 449cc346..d366874d 100644
--- a/internal/runner/provider/claude/answers_test.go
+++ b/internal/runner/provider/claude/answers_test.go
@@ -1,6 +1,7 @@
package claude
import (
+ "bytes"
"context"
"encoding/json"
"os"
@@ -136,8 +137,21 @@ func TestClaudePermissionResponsePinnedWire(t *testing.T) {
raw json.RawMessage
err error
}
+ // A workspace action inside the profile is answered by Equipo, not relayed.
+ allowed, e := f.l.Permission(ctx, s, fixture.Request)
+ var allow struct{ Behavior string }
+ if e != nil || json.Unmarshal(allowed, &allow) != nil || allow.Behavior != "allow" {
+ t.Fatalf("workspace action not allowed in profile: %s %v", allowed, e)
+ }
+ select {
+ case ev := <-events:
+ t.Fatalf("workspace action relayed to a person: %s", ev.Payload)
+ default:
+ }
+ // Outside the workspace the pinned request still reaches the person.
+ outside := bytes.Replace(fixture.Request, []byte(`/workspace/hello.txt`), []byte(`/srv/hello.txt`), 1)
result := make(chan response, 1)
- go func() { raw, err := f.l.Permission(ctx, s, fixture.Request); result <- response{raw, err} }()
+ go func() { raw, err := f.l.Permission(ctx, s, outside); result <- response{raw, err} }()
select {
case ev := <-events:
if e = f.l.Respond(ctx, s, provider.Answer{TurnID: "turn", RequestID: ev.RequestID, Behavior: "deny"}); e != nil {