pi-auto-permissions 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +304 -0
- package/THIRD_PARTY_NOTICES.md +70 -0
- package/docs/implementation-plan.md +311 -0
- package/docs/invariants.md +555 -0
- package/package.json +59 -0
- package/src/canonical.ts +314 -0
- package/src/commands/index.ts +362 -0
- package/src/domain.ts +198 -0
- package/src/extension.ts +430 -0
- package/src/guardian/circuit-breaker.ts +102 -0
- package/src/guardian/index.ts +74 -0
- package/src/guardian/policy.ts +135 -0
- package/src/guardian/prompt.ts +379 -0
- package/src/guardian/reviewer.ts +599 -0
- package/src/guardian/types.ts +149 -0
- package/src/guardian/verdict.ts +211 -0
- package/src/pi/index.ts +13 -0
- package/src/pi/model-reviewer.ts +235 -0
- package/src/pi/transcript.ts +524 -0
- package/src/policy/dangerous-command.ts +312 -0
- package/src/policy/path-policy.ts +501 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/permission-engine.ts +474 -0
- package/src/sandbox/config.ts +188 -0
- package/src/sandbox/controller.ts +354 -0
- package/src/sandbox/index.ts +26 -0
- package/src/sandbox/runtime.ts +28 -0
- package/src/sandbox/types.ts +125 -0
- package/src/state/config-store.ts +580 -0
- package/src/state/index.ts +2 -0
- package/src/tools/bash.ts +101 -0
- package/src/tools/gate.ts +74 -0
- package/src/tools/index.ts +2 -0
- package/vendor/openai-codex/NOTICE +6 -0
- package/vendor/openai-codex/README.md +17 -0
- package/vendor/openai-codex/guardian/policy.md +42 -0
- package/vendor/openai-codex/guardian/policy_template.md +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pi-auto-permissions
|
|
2
|
+
Copyright 2026 pi-auto-permissions contributors
|
|
3
|
+
|
|
4
|
+
This product includes material adapted from OpenAI Codex, Copyright 2025
|
|
5
|
+
OpenAI, licensed under the Apache License, Version 2.0. See
|
|
6
|
+
THIRD_PARTY_NOTICES.md for exact source revisions and modified files.
|
package/README.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# pi-auto-permissions
|
|
2
|
+
|
|
3
|
+
`pi-auto-permissions` is a small, background permission guardrail for
|
|
4
|
+
[Pi](https://github.com/earendil-works/pi). It has exactly two selectable modes:
|
|
5
|
+
**Auto** and **Unrestricted**. Auto combines static rules, a Codex-inspired
|
|
6
|
+
model reviewer, and an OS shell sandbox; Unrestricted stays available for the
|
|
7
|
+
occasional session where the user deliberately wants no guardrail.
|
|
8
|
+
|
|
9
|
+
There is no Ask mode, per-action confirmation prompt, approval file, or command
|
|
10
|
+
catalog to maintain. A denied model action is not shown as a user approval
|
|
11
|
+
dialog. The model receives this terminal result instead:
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
Permission denied. This action was not executed. No override will be requested. Choose a materially safer action.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The model cannot appeal that result inside the action. It must issue a new,
|
|
18
|
+
materially safer action. The user can still deliberately change the session's
|
|
19
|
+
mode with `/perm`.
|
|
20
|
+
|
|
21
|
+
## Requirements and installation
|
|
22
|
+
|
|
23
|
+
- Pi `0.80.10`
|
|
24
|
+
- Node.js `22.19.0` or newer
|
|
25
|
+
- macOS or Linux for the strong shell sandbox
|
|
26
|
+
- On Linux, the Sandbox Runtime's `bubblewrap` (`bwrap`), `socat`, and
|
|
27
|
+
`ripgrep` (`rg`) dependencies, plus its supported seccomp helper
|
|
28
|
+
|
|
29
|
+
From a checked-out copy, install dependencies and register the package globally
|
|
30
|
+
with Pi:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm ci
|
|
34
|
+
pi install /absolute/path/to/pi-auto-permissions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use `pi install /absolute/path/to/pi-auto-permissions -l` for a project-local Pi
|
|
38
|
+
package instead. During development, it can be loaded for one run:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm ci
|
|
42
|
+
pi -e ./src/extension.ts
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The extension stores one private, machine-global permission record plus primary
|
|
46
|
+
and recovery copies of an internal monotonic revision watermark under Pi's agent
|
|
47
|
+
directory. Its only semantic settings are the enabled flag and reviewer tuple;
|
|
48
|
+
schema/revision bookkeeping is internal, model credentials continue to be
|
|
49
|
+
resolved by Pi, and credentials are never stored by this extension. There is
|
|
50
|
+
intentionally no user-managed permission configuration file.
|
|
51
|
+
|
|
52
|
+
## First use
|
|
53
|
+
|
|
54
|
+
Auto is unavailable until its complete reviewer tuple has been selected. Until
|
|
55
|
+
then, Unrestricted is the only effective mode and is shown as `Unrestricted`.
|
|
56
|
+
Select an exact Pi model and an explicit thinking level:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
/perm-auto-model provider/model thinkingLevel
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For example:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
/perm-auto-model openai/gpt-5.2 high
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The example is illustrative; the provider, model, credentials, and thinking
|
|
69
|
+
level must exist in the current Pi installation. Supported thinking-level
|
|
70
|
+
values are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`, but
|
|
71
|
+
each model may expose only a subset. The command validates availability,
|
|
72
|
+
authentication, and support for that exact level before atomically saving
|
|
73
|
+
`(provider, model, thinkingLevel)`.
|
|
74
|
+
|
|
75
|
+
In an interactive Pi session, `/perm-auto-model` with no arguments opens a
|
|
76
|
+
model picker followed by a picker containing only that model's supported
|
|
77
|
+
thinking levels. A successful selection also puts the current session in Auto.
|
|
78
|
+
It does not change the main conversation model or its thinking level.
|
|
79
|
+
|
|
80
|
+
## Commands
|
|
81
|
+
|
|
82
|
+
| Command | Effect |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `/perm auto` | Select Auto for this session. Rejected without a valid reviewer tuple. |
|
|
85
|
+
| `/perm unrestricted` | Select Unrestricted for this session. |
|
|
86
|
+
| `/perm` | Open the two-item Auto/Unrestricted picker in an interactive session. |
|
|
87
|
+
| `/perm-auto-model provider/model thinkingLevel` | Atomically select the global Auto reviewer tuple and put this session in Auto. |
|
|
88
|
+
| `/perm-auto-model` | Interactively pick the reviewer and its thinking level. |
|
|
89
|
+
| `/perm-enabled off` | Disable the extension's enforcement globally, including for existing and future sessions. |
|
|
90
|
+
| `/perm-enabled on` | Re-enable global enforcement. Sessions then use their own requested mode. |
|
|
91
|
+
|
|
92
|
+
`/perm-enabled` is an enable switch, not a third mode. Backends such as
|
|
93
|
+
review-only are implementation states and never appear in `/perm`.
|
|
94
|
+
|
|
95
|
+
Status is deliberately terse:
|
|
96
|
+
|
|
97
|
+
- `Auto` — strong shell sandbox initialized and Auto is active.
|
|
98
|
+
- `Auto (review-only)` — this OS is unsupported, so every model-originated
|
|
99
|
+
shell call is reviewed before any unsandboxed process can start.
|
|
100
|
+
- `Auto (sandbox unavailable)` — macOS/Linux sandbox setup/runtime failed or
|
|
101
|
+
another same-process session owns Sandbox Runtime; Auto shell calls fail
|
|
102
|
+
closed.
|
|
103
|
+
- `Auto (unavailable)` — catastrophic permission-engine construction failed;
|
|
104
|
+
all model tool gates deny and the extension's commands cannot mutate state
|
|
105
|
+
until a later successful session initialization (normally reload or process
|
|
106
|
+
restart).
|
|
107
|
+
- `Unrestricted` — explicitly selected, or Auto is not yet configured.
|
|
108
|
+
- `Off` — enforcement is globally disabled.
|
|
109
|
+
|
|
110
|
+
In an Auto-requested session, invalid durable state is reported as
|
|
111
|
+
`Auto (configuration fault)` and guarded actions fail closed. Explicit
|
|
112
|
+
Unrestricted remains a deliberate bypass. The management commands remain
|
|
113
|
+
available to attempt an explicit repair; repair refuses if neither private
|
|
114
|
+
revision watermark is valid enough to prove a monotonic next revision.
|
|
115
|
+
|
|
116
|
+
`Auto (unavailable)` is a narrower catastrophic construction state, not a
|
|
117
|
+
normal mode or backend. No engine exists there to consult even a previously
|
|
118
|
+
durable Off setting, so the outer gates deny rather than assuming a bypass.
|
|
119
|
+
|
|
120
|
+
## Session semantics
|
|
121
|
+
|
|
122
|
+
Every new, resumed, forked, cloned, or independently spawned Pi runtime starts
|
|
123
|
+
with requested mode Auto. In particular, an Unrestricted parent cannot confer
|
|
124
|
+
Unrestricted on a child process or subagent. If the reviewer has not been
|
|
125
|
+
selected yet, that default Auto intent becomes effective only after a reviewer
|
|
126
|
+
tuple exists.
|
|
127
|
+
|
|
128
|
+
`/reload` is the sole exception: it restores the requested mode of that same
|
|
129
|
+
logical runtime. Switching to another session or starting a child does not copy
|
|
130
|
+
that checkpoint. The global enabled flag and reviewer tuple are reread at tool
|
|
131
|
+
gates, so `/perm-enabled off`, `/perm-enabled on`, and reviewer changes also
|
|
132
|
+
affect already-running Pi processes. A same-runtime command actively cancels
|
|
133
|
+
that runtime's pending reviews. A sibling-process change cannot push an abort
|
|
134
|
+
signal across processes; it is detected at the next pre-model, post-model, or
|
|
135
|
+
final binding read and makes the old review stale.
|
|
136
|
+
|
|
137
|
+
Permission admission is the policy linearization point. If a sibling commits a
|
|
138
|
+
change before an action's controlling state read, the action uses the new state.
|
|
139
|
+
An action already finally admitted before the commit may still enter its
|
|
140
|
+
executor once; global Off is intentionally not a retroactive process-kill
|
|
141
|
+
switch.
|
|
142
|
+
|
|
143
|
+
## What Auto does
|
|
144
|
+
|
|
145
|
+
Auto classifies the final Pi tool call visible to this extension:
|
|
146
|
+
|
|
147
|
+
| Action | Auto behavior |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| Pi's built-in `read`, `grep`, `find`, `ls` | Statically admitted. |
|
|
150
|
+
| Pi's built-in `write` and `edit` within the workspace or OS temporary roots | Statically admitted unless the resolved target is protected metadata. |
|
|
151
|
+
| Other built-in `write` and `edit` targets | Reviewed before the direct file tool runs. |
|
|
152
|
+
| Built-in `write` and `edit` targeting this extension's state/lock paths | Statically denied in Auto without model review. |
|
|
153
|
+
| Ordinary `bash` on healthy macOS/Linux | Runs once in the fixed OS sandbox. |
|
|
154
|
+
| Codex-dangerous `bash` with the default sandbox permission | Reviewed; an exact allow runs once inside the fixed sandbox. |
|
|
155
|
+
| A `bash` call with `sandbox_permissions: "require_escalated"` | Reviewed; an exact allow runs once with normal host permissions. |
|
|
156
|
+
| Any `bash` on an unsupported OS (including WSL1) | Reviewed; an exact allow runs once with normal host permissions. |
|
|
157
|
+
| Any `bash` after a supported macOS/Linux sandbox failure | Denied before review or process creation. |
|
|
158
|
+
| Third-party/custom tool | Reviewed; an exact allow invokes its trusted implementation without OS containment. |
|
|
159
|
+
|
|
160
|
+
Static mutation admission resolves existing symlinks and the nearest existing
|
|
161
|
+
ancestor of a new path. Workspace `.git`, resolved Git directories, `.agents`,
|
|
162
|
+
`.codex`, and `.pi` are protected. The sandbox allows broad filesystem reads,
|
|
163
|
+
writes only to the workspace and temporary roots, keeps protected metadata and
|
|
164
|
+
the extension's durable state read-only, denies network and local binding, and
|
|
165
|
+
applies to descendant processes.
|
|
166
|
+
|
|
167
|
+
If direct-file path policy construction fails at startup, the fallback admits
|
|
168
|
+
only the four known read-only built-ins and statically denies every `write` or
|
|
169
|
+
`edit`. It does not guess path safety or ask the reviewer to replace missing
|
|
170
|
+
classification.
|
|
171
|
+
|
|
172
|
+
The reviewer sees a bounded conversation transcript and one canonical action.
|
|
173
|
+
It has no tools. Its result must be exact schema-valid JSON; `ask`, prose,
|
|
174
|
+
malformed output, timeouts, missing credentials, provider errors, cancellation,
|
|
175
|
+
state changes, and every other non-allow outcome all deny. Reviews have one
|
|
176
|
+
aggregate 90-second deadline, at most three provider attempts, and denial
|
|
177
|
+
circuit breakers to prevent loops.
|
|
178
|
+
|
|
179
|
+
A sandbox rejection is returned as an ordinary tool error. The extension does
|
|
180
|
+
not replay a command that may have started. The model may issue a different
|
|
181
|
+
command or a new exact `require_escalated` request, which is reviewed without
|
|
182
|
+
opening a user dialog.
|
|
183
|
+
|
|
184
|
+
The shell fallback matches the pinned Codex default Auto preset
|
|
185
|
+
(`OnRequest + AutoReview + workspace`) without custom exec-policy rules or
|
|
186
|
+
experimental permission features. Codex's optional rule files, managed-network
|
|
187
|
+
flow, and additional-permission features are intentionally not reproduced.
|
|
188
|
+
|
|
189
|
+
## Platform behavior
|
|
190
|
+
|
|
191
|
+
On macOS and Linux, startup performs dependency checks, initializes
|
|
192
|
+
`@anthropic-ai/sandbox-runtime`, and runs an actual contained `true` process.
|
|
193
|
+
Only a successful probe enables sandboxed shell execution. On Linux, missing
|
|
194
|
+
`bwrap`, `socat`, or strong seccomp/Unix-socket isolation is a sandbox failure.
|
|
195
|
+
|
|
196
|
+
Sandbox Runtime owns process-global policy, so a supported-host Node process has
|
|
197
|
+
one active strong-sandbox controller at a time. If another Pi session in that
|
|
198
|
+
same process starts concurrently, its backend is reported as sandbox unavailable
|
|
199
|
+
and its Auto shell calls deny; it never replaces or shares the first session's
|
|
200
|
+
workspace policy. Unsupported-host ReviewOnly sessions do not claim this owner.
|
|
201
|
+
The owner is released only after commands drain and reset succeeds. A failed
|
|
202
|
+
final reset poisons strong-sandbox reuse until that Node process restarts, which
|
|
203
|
+
prevents a later session from inheriting stale policy.
|
|
204
|
+
|
|
205
|
+
An unsupported OS uses the visibly labeled review-only fallback. Review-only is
|
|
206
|
+
functional but is not equivalent to containment: an allowed shell command has
|
|
207
|
+
the user's normal host permissions. By contrast, a dependency,
|
|
208
|
+
initialization, probe, or runtime failure on supported macOS/Linux never
|
|
209
|
+
silently downgrades to review-only. It reduces availability and reports
|
|
210
|
+
`Auto (sandbox unavailable)`.
|
|
211
|
+
|
|
212
|
+
## Trust boundary and limitations
|
|
213
|
+
|
|
214
|
+
This is a practical coding-agent guardrail, not a proof that model-approved
|
|
215
|
+
actions are safe. Its formal routing and state guarantees are documented in
|
|
216
|
+
[`docs/invariants.md`](docs/invariants.md), with the proof-linked construction
|
|
217
|
+
in [`docs/implementation-plan.md`](docs/implementation-plan.md). Important
|
|
218
|
+
limits are:
|
|
219
|
+
|
|
220
|
+
- A reviewer model is probabilistic and can make a wrong allow decision.
|
|
221
|
+
- Sandboxed shell commands have broad read access. The fixed sandbox blocks
|
|
222
|
+
network and unauthorized writes; it is not a general secret-reading boundary.
|
|
223
|
+
- Reviewed escalated shell commands, reviewed out-of-root direct file writes,
|
|
224
|
+
and reviewed custom tools execute without OS containment after an allow.
|
|
225
|
+
- Third-party tool implementations and other loaded Pi extensions are trusted.
|
|
226
|
+
They can have surprising effects, and this extension cannot sandbox their
|
|
227
|
+
implementation or stop a later extension from deliberately bypassing it.
|
|
228
|
+
- Pi's user-entered `!` and `!!` shell commands are explicit user actions and
|
|
229
|
+
are outside this model-action guardrail.
|
|
230
|
+
- Unrestricted and global Off intentionally bypass review and sandboxing.
|
|
231
|
+
- Kernel, Pi, Sandbox Runtime, provider, filesystem, and hostile local-process
|
|
232
|
+
bugs or subversion are outside the guarantee. Static paths resist ordinary
|
|
233
|
+
symlink indirection but do not claim to defeat a hostile local TOCTOU race.
|
|
234
|
+
- A compound sandboxed command can complete permitted effects before a later
|
|
235
|
+
operation is rejected. The extension never automatically retries it.
|
|
236
|
+
- On an unsupported OS, review-only provides model review, not process
|
|
237
|
+
isolation. On supported macOS/Linux, failed containment instead fails closed.
|
|
238
|
+
- Concurrent supported-host sessions in one Node process cannot each own a
|
|
239
|
+
different strong Sandbox Runtime policy. Additional sessions fail closed for
|
|
240
|
+
Auto shell until the owner closes successfully; reset failure requires a
|
|
241
|
+
process restart.
|
|
242
|
+
- Global policy changes do not retroactively kill actions already admitted at
|
|
243
|
+
their final permission check.
|
|
244
|
+
- A catastrophic permission-engine initialization failure denies all model tool
|
|
245
|
+
calls, but its slash-command host is unavailable until Pi successfully starts
|
|
246
|
+
the extension again.
|
|
247
|
+
|
|
248
|
+
## Testing
|
|
249
|
+
|
|
250
|
+
Run the deterministic suite from a clean install:
|
|
251
|
+
|
|
252
|
+
```sh
|
|
253
|
+
npm ci
|
|
254
|
+
npm run check
|
|
255
|
+
npm run pack:check
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Most sandbox lifecycle coverage uses controlled adapters, while the real OS
|
|
259
|
+
sandbox test stays gated. On a disposable macOS/Linux CI host with the native
|
|
260
|
+
prerequisites installed, opt in to the real process-boundary test:
|
|
261
|
+
|
|
262
|
+
```sh
|
|
263
|
+
npm run test:real-sandbox
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
That gate starts actual descendant shells and verifies workspace and temporary
|
|
267
|
+
writes, protected/outside/extension-state rejection, symlink and substitution
|
|
268
|
+
escapes, a Node-interpreter escape attempt, local TCP denial, and a workspace
|
|
269
|
+
that differs from the Node process cwd. Controlled controller tests cover
|
|
270
|
+
dependency/probe/runtime failures, ownership and reset poison, shutdown drain,
|
|
271
|
+
and no replay after ambiguous execution failure. The rest of the deterministic
|
|
272
|
+
suite covers the effective-mode truth table, state durability and process races,
|
|
273
|
+
path and symlink cases, pinned Codex dangerous-command cases, strict review
|
|
274
|
+
verdicts, deadlines and cancellation, stale bindings, commands, public
|
|
275
|
+
ExtensionRunner/ResourceLoader integration, two real print-mode `AgentSession`
|
|
276
|
+
flows, lack of action-review dialogs, the explicit traceability manifest, and
|
|
277
|
+
provenance hashes. The manifest maps every invariant to a named test file/title
|
|
278
|
+
witness and fails if that witness disappears. The suite does not claim packaged
|
|
279
|
+
CLI, live TUI, RPC, or JSON-mode coverage.
|
|
280
|
+
|
|
281
|
+
## License and attribution
|
|
282
|
+
|
|
283
|
+
This project is licensed under the
|
|
284
|
+
[Apache License 2.0](LICENSE). See [NOTICE](NOTICE) and
|
|
285
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
286
|
+
|
|
287
|
+
- The Guardian policy and dangerous-command behavior are adapted from
|
|
288
|
+
[OpenAI Codex revision `0fb559f0f6e231a88ac02ea002d3ecd248e2b515`](https://github.com/openai/codex/tree/0fb559f0f6e231a88ac02ea002d3ecd248e2b515),
|
|
289
|
+
Apache-2.0. The exact upstream Guardian files and notice are vendored with
|
|
290
|
+
recorded SHA-256 hashes in
|
|
291
|
+
[`vendor/openai-codex/README.md`](vendor/openai-codex/README.md); derivative
|
|
292
|
+
source files identify their modifications.
|
|
293
|
+
- Pi integration targets `@earendil-works/pi-coding-agent` `0.80.10` at
|
|
294
|
+
[revision `3da591ab74ab9ab407e72ed882600b2c851fae21`](https://github.com/earendil-works/pi/tree/3da591ab74ab9ab407e72ed882600b2c851fae21),
|
|
295
|
+
MIT.
|
|
296
|
+
- Shell containment uses `@anthropic-ai/sandbox-runtime` `0.0.65`,
|
|
297
|
+
Apache-2.0.
|
|
298
|
+
- Portable Codex-compatible shell parsing uses `web-tree-sitter` `0.25.10`
|
|
299
|
+
and `tree-sitter-bash` `0.25.1`, both MIT.
|
|
300
|
+
- Atomic cross-process state locking uses `proper-lockfile` `4.1.2`, MIT.
|
|
301
|
+
|
|
302
|
+
Runtime dependencies and the Pi development target are exact-version pinned in
|
|
303
|
+
`package.json` and `package-lock.json`; the provenance unit test verifies those
|
|
304
|
+
pins, upstream revisions, licenses, notices, and vendored hashes offline.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## OpenAI Codex
|
|
4
|
+
|
|
5
|
+
Portions of the automatic-review policy and command-safety behavior are adapted
|
|
6
|
+
from [OpenAI Codex](https://github.com/openai/codex) at revision
|
|
7
|
+
`0fb559f0f6e231a88ac02ea002d3ecd248e2b515`.
|
|
8
|
+
|
|
9
|
+
Copyright 2025 OpenAI.
|
|
10
|
+
|
|
11
|
+
Licensed under the Apache License, Version 2.0. The repository root `LICENSE`
|
|
12
|
+
contains the license text. Adapted files carry a modification notice and retain
|
|
13
|
+
their exact upstream source path and revision.
|
|
14
|
+
|
|
15
|
+
This project changes Codex's denial recovery behavior: it removes human override
|
|
16
|
+
and user-approval paths, returning a terminal model-directed denial instead.
|
|
17
|
+
|
|
18
|
+
## Pi
|
|
19
|
+
|
|
20
|
+
The extension API integration follows examples and public interfaces from
|
|
21
|
+
[Pi](https://github.com/earendil-works/pi) at revision
|
|
22
|
+
`3da591ab74ab9ab407e72ed882600b2c851fae21`.
|
|
23
|
+
|
|
24
|
+
Copyright (c) 2025 Mario Zechner.
|
|
25
|
+
|
|
26
|
+
Pi is licensed under the MIT License:
|
|
27
|
+
|
|
28
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
29
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
30
|
+
> in the Software without restriction, including without limitation the rights
|
|
31
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
32
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
33
|
+
> furnished to do so, subject to the following conditions:
|
|
34
|
+
>
|
|
35
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
36
|
+
> copies or substantial portions of the Software.
|
|
37
|
+
>
|
|
38
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
39
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
40
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
41
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
42
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
43
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
44
|
+
> SOFTWARE.
|
|
45
|
+
|
|
46
|
+
## Anthropic Sandbox Runtime
|
|
47
|
+
|
|
48
|
+
Shell containment uses
|
|
49
|
+
[`@anthropic-ai/sandbox-runtime`](https://github.com/anthropic-experimental/sandbox-runtime)
|
|
50
|
+
`0.0.65`, licensed under the Apache License, Version 2.0. It is an exact-version
|
|
51
|
+
pinned external dependency and is not copied into this repository.
|
|
52
|
+
|
|
53
|
+
## Tree-sitter and Tree-sitter Bash
|
|
54
|
+
|
|
55
|
+
Codex-compatible shell parsing uses `web-tree-sitter` `0.25.10` and the
|
|
56
|
+
`tree-sitter-bash` `0.25.1` WebAssembly grammar. Both are distributed under the
|
|
57
|
+
MIT License. The grammar is from the same Tree-sitter Bash 0.25 series used by
|
|
58
|
+
the referenced Codex revision; native install scripts are not required or
|
|
59
|
+
executed.
|
|
60
|
+
|
|
61
|
+
`tree-sitter-bash` is Copyright (c) 2017 Max Brunsfeld.
|
|
62
|
+
|
|
63
|
+
`web-tree-sitter` is Copyright (c) 2018-2024 Max Brunsfeld.
|
|
64
|
+
|
|
65
|
+
## proper-lockfile
|
|
66
|
+
|
|
67
|
+
Atomic cross-process configuration locking uses `proper-lockfile` `4.1.2`,
|
|
68
|
+
Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>, distributed under
|
|
69
|
+
the MIT License. It is an exact-version pinned external dependency and is not
|
|
70
|
+
copied into this repository.
|