Skip to content

Commit ca997da

Browse files
author
SqlRush
committed
feat: port sandbox core+seatbelt (spec 12) and code-mode (spec 25)
- internal/sandbox: SandboxPolicy model + AskForApproval x policy matrix, macOS seatbelt (.sbpl generation + sandbox-exec spawn), common spawn path (env/cwd/PTY). Linux/Windows backends stubbed with explicit not-implemented errors (specs 13/14). - internal/codemode: code-mode JS runtime on goja (exec/wait tools, cell isolation, ToolInvoker bridge for nested tool calls, RuntimeResponse). JS-feature gaps vs V8 noted as deviations. - go.mod: add dop251/goja. (app-server-protocol spec 32 production code builds; finishing its turn_item test consistency separately — 503 interrupted that agent mid-reconcile.)
1 parent f05eeee commit ca997da

24 files changed

Lines changed: 3392 additions & 0 deletions

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ require (
1111
github.com/creack/pty v1.1.24 // indirect
1212
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
1313
github.com/danieljoos/wincred v1.2.3 // indirect
14+
github.com/dlclark/regexp2 v1.11.4 // indirect
15+
github.com/dop251/goja v0.0.0-20260311135729-065cd970411c // indirect
1416
github.com/emirpasic/gods v1.18.1 // indirect
1517
github.com/fsnotify/fsnotify v1.10.1 // indirect
1618
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
1719
github.com/go-git/go-billy/v5 v5.9.0 // indirect
1820
github.com/go-git/go-git/v5 v5.19.1 // indirect
21+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
1922
github.com/godbus/dbus/v5 v5.2.2 // indirect
2023
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
24+
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
2125
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
2226
github.com/kevinburke/ssh_config v1.2.0 // indirect
2327
github.com/klauspost/compress v1.18.6 // indirect
@@ -32,6 +36,7 @@ require (
3236
golang.org/x/crypto v0.50.0 // indirect
3337
golang.org/x/net v0.53.0 // indirect
3438
golang.org/x/sys v0.43.0 // indirect
39+
golang.org/x/text v0.36.0 // indirect
3540
gopkg.in/warnings.v0 v0.1.2 // indirect
3641
mvdan.cc/sh/v3 v3.13.1 // indirect
3742
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMF
1717
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
1818
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1919
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
20+
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
21+
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
22+
github.com/dop251/goja v0.0.0-20260311135729-065cd970411c h1:OcLmPfx1T1RmZVHHFwWMPaZDdRf0DBMZOFMVWJa7Pdk=
23+
github.com/dop251/goja v0.0.0-20260311135729-065cd970411c/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
2024
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
2125
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
2226
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
@@ -27,10 +31,14 @@ github.com/go-git/go-billy/v5 v5.9.0 h1:jItGXszUDRtR/AlferWPTMN4j38BQ88XnXKbilmm
2731
github.com/go-git/go-billy/v5 v5.9.0/go.mod h1:jCnQMLj9eUgGU7+ludSTYoZL/GGmii14RxKFj7ROgHw=
2832
github.com/go-git/go-git/v5 v5.19.1 h1:nX27AnaU43/K5bKktKwgBmR9lawoYVe1Ckg0rgzzN00=
2933
github.com/go-git/go-git/v5 v5.19.1/go.mod h1:Pb1v0c7/g8aGQJwx9Us09W85yGoyvSwuhEGMH7zjDKQ=
34+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
35+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
3036
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
3137
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
3238
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
3339
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
40+
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U=
41+
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
3442
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
3543
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
3644
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
@@ -80,6 +88,8 @@ golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
8088
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
8189
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
8290
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
91+
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
92+
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
8393
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8494
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8595
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/codemode/cell.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package codemode
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
)
7+
8+
// CellID mirrors codex's `CellId`. It is a newtype wrapper over a string that
9+
// scopes a single code-mode invocation within a session. CellIDs are allocated
10+
// monotonically by a session and reused as map keys, so it is a comparable
11+
// value type.
12+
type CellID struct {
13+
value string
14+
}
15+
16+
// NewCellID constructs a CellID from a raw string, mirroring codex's
17+
// `CellId::new`.
18+
func NewCellID(value string) CellID {
19+
return CellID{value: value}
20+
}
21+
22+
// String renders the underlying identifier, mirroring codex's Display impl.
23+
func (c CellID) String() string {
24+
return c.value
25+
}
26+
27+
// AsStr returns the underlying identifier, mirroring codex's `as_str`.
28+
func (c CellID) AsStr() string {
29+
return c.value
30+
}
31+
32+
// MarshalJSON emits the bare string, mirroring serde's newtype-struct encoding.
33+
func (c CellID) MarshalJSON() ([]byte, error) {
34+
return json.Marshal(c.value)
35+
}
36+
37+
// UnmarshalJSON parses a bare string into the CellID.
38+
func (c *CellID) UnmarshalJSON(data []byte) error {
39+
var raw string
40+
if err := json.Unmarshal(data, &raw); err != nil {
41+
return fmt.Errorf("decode cell id: %w", err)
42+
}
43+
c.value = raw
44+
return nil
45+
}

0 commit comments

Comments
 (0)