@grwnd/pi-governance 1.2.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 +190 -0
- package/README.md +199 -0
- package/dist/index.cjs +195 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +129 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +167 -0
- package/dist/index.js.map +1 -0
- package/package.json +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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 the 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 the 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 any 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
|
+
Copyright 2026 Grwnd AI
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="pi-governance logo" width="180" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@grwnd/pi-governance</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Governance, RBAC, audit, and human-in-the-loop for Pi-based coding agents.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/Grwnd-AI/pi-governance/actions/workflows/ci.yml"><img src="https://github.com/Grwnd-AI/pi-governance/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@grwnd/pi-governance"><img src="https://img.shields.io/npm/v/@grwnd/pi-governance" alt="npm" /></a>
|
|
14
|
+
<a href="https://github.com/Grwnd-AI/pi-governance/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="License" /></a>
|
|
15
|
+
<a href="https://grwnd-ai.github.io/pi-governance/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-blue" alt="Docs" /></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What is this?
|
|
21
|
+
|
|
22
|
+
`pi-governance` is a Pi extension that intercepts every tool call your AI coding agent makes and enforces policy before execution. It provides:
|
|
23
|
+
|
|
24
|
+
- **Role-based access control** — define who can use which tools
|
|
25
|
+
- **Bash command classification** — auto-block dangerous commands (`rm -rf`, `sudo`, `curl | sh`)
|
|
26
|
+
- **Path-level file gating** — restrict read/write to scoped directories
|
|
27
|
+
- **Human-in-the-loop approval** — require sign-off for sensitive operations
|
|
28
|
+
- **Audit logging** — structured JSONL logs of every governance decision
|
|
29
|
+
- **Prompt-level policy** — role-scoped system prompt templates
|
|
30
|
+
|
|
31
|
+
It works as a drop-in shim. Install it, and your existing Pi agent gains governance controls without any code changes.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pi install npm:@grwnd/pi-governance
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
That's it. On next session start, governance is active with sensible defaults:
|
|
42
|
+
|
|
43
|
+
- All tools allowed
|
|
44
|
+
- Dangerous bash commands blocked
|
|
45
|
+
- Supervised mode (approval required for writes and bash)
|
|
46
|
+
- Audit logged to `~/.pi/agent/audit.jsonl`
|
|
47
|
+
|
|
48
|
+
### Configure
|
|
49
|
+
|
|
50
|
+
Create `.pi/governance.yaml` in your project root (committed to git for team-wide policy):
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
auth:
|
|
54
|
+
provider: env
|
|
55
|
+
|
|
56
|
+
policy:
|
|
57
|
+
engine: yaml
|
|
58
|
+
yaml:
|
|
59
|
+
rules_file: ./governance-rules.yaml
|
|
60
|
+
|
|
61
|
+
hitl:
|
|
62
|
+
default_mode: supervised
|
|
63
|
+
timeout_seconds: 300
|
|
64
|
+
|
|
65
|
+
audit:
|
|
66
|
+
sinks:
|
|
67
|
+
- type: jsonl
|
|
68
|
+
path: ~/.pi/agent/audit.jsonl
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Define Roles
|
|
72
|
+
|
|
73
|
+
Create `governance-rules.yaml`:
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
roles:
|
|
77
|
+
analyst:
|
|
78
|
+
allowed_tools: [read]
|
|
79
|
+
blocked_tools: [write, edit, bash]
|
|
80
|
+
execution_mode: supervised
|
|
81
|
+
human_approval:
|
|
82
|
+
required_for: [all]
|
|
83
|
+
allowed_paths:
|
|
84
|
+
- '{{project_path}}/**'
|
|
85
|
+
blocked_paths:
|
|
86
|
+
- '**/secrets/**'
|
|
87
|
+
- '**/.env*'
|
|
88
|
+
|
|
89
|
+
project_lead:
|
|
90
|
+
allowed_tools: [read, write, edit, bash]
|
|
91
|
+
blocked_tools: []
|
|
92
|
+
execution_mode: supervised
|
|
93
|
+
human_approval:
|
|
94
|
+
required_for: [bash, write]
|
|
95
|
+
auto_approve: [read, edit]
|
|
96
|
+
allowed_paths:
|
|
97
|
+
- '{{project_path}}/**'
|
|
98
|
+
blocked_paths:
|
|
99
|
+
- '**/secrets/**'
|
|
100
|
+
|
|
101
|
+
admin:
|
|
102
|
+
allowed_tools: [all]
|
|
103
|
+
blocked_tools: []
|
|
104
|
+
execution_mode: autonomous
|
|
105
|
+
human_approval:
|
|
106
|
+
required_for: []
|
|
107
|
+
allowed_paths: ['**']
|
|
108
|
+
blocked_paths: []
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Set Identity
|
|
112
|
+
|
|
113
|
+
Set environment variables before starting your Pi session:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
export GRWND_USER=alice
|
|
117
|
+
export GRWND_ROLE=project_lead
|
|
118
|
+
export GRWND_ORG_UNIT=cornerstone_aec
|
|
119
|
+
|
|
120
|
+
pi
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Or use a local users file for team setups — see the [docs](https://grwnd-ai.github.io/pi-governance/).
|
|
124
|
+
|
|
125
|
+
### Check Status
|
|
126
|
+
|
|
127
|
+
Inside a governed Pi session:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
/governance status
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Governance active
|
|
135
|
+
User: alice
|
|
136
|
+
Role: project_lead
|
|
137
|
+
Org Unit: cornerstone_aec
|
|
138
|
+
Engine: yaml
|
|
139
|
+
Mode: supervised
|
|
140
|
+
Session: 3 tool calls, 0 denials
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
User message → Pi Agent Runtime
|
|
147
|
+
│
|
|
148
|
+
┌─────┴──────┐
|
|
149
|
+
│ onSessionStart │ ← Identity resolution
|
|
150
|
+
│ → load policy │ ← Select prompt template
|
|
151
|
+
└─────┬──────┘
|
|
152
|
+
│
|
|
153
|
+
┌─────┴──────────┐
|
|
154
|
+
│ onBeforeToolCall │ ← RBAC: tool allowed?
|
|
155
|
+
│ → classify bash │ ← Path check
|
|
156
|
+
│ → HITL approval │ ← Audit log
|
|
157
|
+
└─────┬──────────┘
|
|
158
|
+
│
|
|
159
|
+
allow │ deny
|
|
160
|
+
│ └→ Return denial message
|
|
161
|
+
│
|
|
162
|
+
┌─────┴──────────┐
|
|
163
|
+
│ onAfterToolCall │ ← Audit result
|
|
164
|
+
└────────────────┘
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Dual Policy Engine
|
|
168
|
+
|
|
169
|
+
Choose between two policy engines:
|
|
170
|
+
|
|
171
|
+
| Engine | Best for | Dependency |
|
|
172
|
+
| ------------------ | ---------------------------------------------- | ---------------- |
|
|
173
|
+
| **YAML** (default) | Simple setups, quick start | Zero — built-in |
|
|
174
|
+
| **Oso/Polar** | Complex RBAC, relational policies, inheritance | `oso` (optional) |
|
|
175
|
+
|
|
176
|
+
Switch engines in config:
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
policy:
|
|
180
|
+
engine: oso
|
|
181
|
+
oso:
|
|
182
|
+
polar_files:
|
|
183
|
+
- ./policies/base.polar
|
|
184
|
+
- ./policies/tools.polar
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Documentation
|
|
188
|
+
|
|
189
|
+
Full documentation at **[grwnd-ai.github.io/pi-governance](https://grwnd-ai.github.io/pi-governance/)**.
|
|
190
|
+
|
|
191
|
+
- [Quick Start](https://grwnd-ai.github.io/pi-governance/guide/quickstart)
|
|
192
|
+
- [Team Deployment](https://grwnd-ai.github.io/pi-governance/guide/team-deployment)
|
|
193
|
+
- [YAML Policies](https://grwnd-ai.github.io/pi-governance/guide/yaml-policies)
|
|
194
|
+
- [Bash Classifier](https://grwnd-ai.github.io/pi-governance/guide/bash-classifier)
|
|
195
|
+
- [Configuration Reference](https://grwnd-ai.github.io/pi-governance/reference/config)
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
[Apache-2.0](LICENSE)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ConfigValidationError: () => ConfigValidationError,
|
|
24
|
+
loadConfig: () => loadConfig
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/lib/config/loader.ts
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_yaml = require("yaml");
|
|
31
|
+
var import_value = require("@sinclair/typebox/value");
|
|
32
|
+
|
|
33
|
+
// src/lib/config/schema.ts
|
|
34
|
+
var import_typebox = require("@sinclair/typebox");
|
|
35
|
+
var AuthEnvConfig = import_typebox.Type.Object({
|
|
36
|
+
user_var: import_typebox.Type.String({ default: "GRWND_USER" }),
|
|
37
|
+
role_var: import_typebox.Type.String({ default: "GRWND_ROLE" }),
|
|
38
|
+
org_unit_var: import_typebox.Type.String({ default: "GRWND_ORG_UNIT" })
|
|
39
|
+
});
|
|
40
|
+
var AuthLocalConfig = import_typebox.Type.Object({
|
|
41
|
+
users_file: import_typebox.Type.String({ default: "./users.yaml" })
|
|
42
|
+
});
|
|
43
|
+
var AuthConfig = import_typebox.Type.Object({
|
|
44
|
+
provider: import_typebox.Type.Union([import_typebox.Type.Literal("env"), import_typebox.Type.Literal("local"), import_typebox.Type.Literal("oidc")], {
|
|
45
|
+
default: "env"
|
|
46
|
+
}),
|
|
47
|
+
env: import_typebox.Type.Optional(AuthEnvConfig),
|
|
48
|
+
local: import_typebox.Type.Optional(AuthLocalConfig)
|
|
49
|
+
});
|
|
50
|
+
var YamlPolicyConfig = import_typebox.Type.Object({
|
|
51
|
+
rules_file: import_typebox.Type.String({ default: "./governance-rules.yaml" })
|
|
52
|
+
});
|
|
53
|
+
var OsoPolicyConfig = import_typebox.Type.Object({
|
|
54
|
+
polar_files: import_typebox.Type.Array(import_typebox.Type.String(), {
|
|
55
|
+
default: ["./policies/base.polar", "./policies/tools.polar"]
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
var PolicyConfig = import_typebox.Type.Object({
|
|
59
|
+
engine: import_typebox.Type.Union([import_typebox.Type.Literal("yaml"), import_typebox.Type.Literal("oso")], { default: "yaml" }),
|
|
60
|
+
yaml: import_typebox.Type.Optional(YamlPolicyConfig),
|
|
61
|
+
oso: import_typebox.Type.Optional(OsoPolicyConfig)
|
|
62
|
+
});
|
|
63
|
+
var TemplatesConfig = import_typebox.Type.Object({
|
|
64
|
+
directory: import_typebox.Type.String({ default: "./templates/" }),
|
|
65
|
+
default: import_typebox.Type.String({ default: "project-lead" })
|
|
66
|
+
});
|
|
67
|
+
var HitlWebhookConfig = import_typebox.Type.Object({
|
|
68
|
+
url: import_typebox.Type.String()
|
|
69
|
+
});
|
|
70
|
+
var HitlConfig = import_typebox.Type.Object({
|
|
71
|
+
default_mode: import_typebox.Type.Union(
|
|
72
|
+
[import_typebox.Type.Literal("autonomous"), import_typebox.Type.Literal("supervised"), import_typebox.Type.Literal("dry_run")],
|
|
73
|
+
{ default: "supervised" }
|
|
74
|
+
),
|
|
75
|
+
approval_channel: import_typebox.Type.Union([import_typebox.Type.Literal("cli"), import_typebox.Type.Literal("webhook")], { default: "cli" }),
|
|
76
|
+
timeout_seconds: import_typebox.Type.Number({ default: 300, minimum: 10, maximum: 3600 }),
|
|
77
|
+
webhook: import_typebox.Type.Optional(HitlWebhookConfig)
|
|
78
|
+
});
|
|
79
|
+
var JsonlSinkConfig = import_typebox.Type.Object({
|
|
80
|
+
type: import_typebox.Type.Literal("jsonl"),
|
|
81
|
+
path: import_typebox.Type.String({ default: "~/.pi/agent/audit.jsonl" })
|
|
82
|
+
});
|
|
83
|
+
var WebhookSinkConfig = import_typebox.Type.Object({
|
|
84
|
+
type: import_typebox.Type.Literal("webhook"),
|
|
85
|
+
url: import_typebox.Type.String()
|
|
86
|
+
});
|
|
87
|
+
var PostgresSinkConfig = import_typebox.Type.Object({
|
|
88
|
+
type: import_typebox.Type.Literal("postgres"),
|
|
89
|
+
connection: import_typebox.Type.String()
|
|
90
|
+
});
|
|
91
|
+
var AuditSinkConfig = import_typebox.Type.Union([JsonlSinkConfig, WebhookSinkConfig, PostgresSinkConfig]);
|
|
92
|
+
var AuditConfig = import_typebox.Type.Object({
|
|
93
|
+
sinks: import_typebox.Type.Array(AuditSinkConfig, {
|
|
94
|
+
default: [{ type: "jsonl", path: "~/.pi/agent/audit.jsonl" }]
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
var OrgUnitOverride = import_typebox.Type.Object({
|
|
98
|
+
hitl: import_typebox.Type.Optional(import_typebox.Type.Partial(HitlConfig)),
|
|
99
|
+
policy: import_typebox.Type.Optional(
|
|
100
|
+
import_typebox.Type.Object({
|
|
101
|
+
extra_polar: import_typebox.Type.Optional(import_typebox.Type.String()),
|
|
102
|
+
extra_rules: import_typebox.Type.Optional(import_typebox.Type.String())
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
});
|
|
106
|
+
var GovernanceConfigSchema = import_typebox.Type.Object({
|
|
107
|
+
auth: import_typebox.Type.Optional(AuthConfig),
|
|
108
|
+
policy: import_typebox.Type.Optional(PolicyConfig),
|
|
109
|
+
templates: import_typebox.Type.Optional(TemplatesConfig),
|
|
110
|
+
hitl: import_typebox.Type.Optional(HitlConfig),
|
|
111
|
+
audit: import_typebox.Type.Optional(AuditConfig),
|
|
112
|
+
org_units: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), OrgUnitOverride))
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// src/lib/config/defaults.ts
|
|
116
|
+
var DEFAULTS = {
|
|
117
|
+
auth: {
|
|
118
|
+
provider: "env",
|
|
119
|
+
env: {
|
|
120
|
+
user_var: "GRWND_USER",
|
|
121
|
+
role_var: "GRWND_ROLE",
|
|
122
|
+
org_unit_var: "GRWND_ORG_UNIT"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
policy: {
|
|
126
|
+
engine: "yaml",
|
|
127
|
+
yaml: {
|
|
128
|
+
rules_file: "./governance-rules.yaml"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
templates: {
|
|
132
|
+
directory: "./templates/",
|
|
133
|
+
default: "project-lead"
|
|
134
|
+
},
|
|
135
|
+
hitl: {
|
|
136
|
+
default_mode: "supervised",
|
|
137
|
+
approval_channel: "cli",
|
|
138
|
+
timeout_seconds: 300
|
|
139
|
+
},
|
|
140
|
+
audit: {
|
|
141
|
+
sinks: [{ type: "jsonl", path: "~/.pi/agent/audit.jsonl" }]
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// src/lib/config/loader.ts
|
|
146
|
+
var CONFIG_PATHS = [
|
|
147
|
+
process.env.GRWND_GOVERNANCE_CONFIG,
|
|
148
|
+
".pi/governance.yaml",
|
|
149
|
+
`${process.env.HOME}/.pi/agent/governance.yaml`
|
|
150
|
+
];
|
|
151
|
+
function loadConfig() {
|
|
152
|
+
for (const path of CONFIG_PATHS) {
|
|
153
|
+
if (path && (0, import_fs.existsSync)(path)) {
|
|
154
|
+
const raw = (0, import_fs.readFileSync)(path, "utf-8");
|
|
155
|
+
const parsed = (0, import_yaml.parse)(raw);
|
|
156
|
+
const resolved = resolveEnvVars(parsed);
|
|
157
|
+
const errors = [...import_value.Value.Errors(GovernanceConfigSchema, resolved)];
|
|
158
|
+
if (errors.length > 0) {
|
|
159
|
+
throw new ConfigValidationError(
|
|
160
|
+
path,
|
|
161
|
+
errors.map((e) => ({ path: e.path, message: e.message }))
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
const config = import_value.Value.Default(GovernanceConfigSchema, resolved);
|
|
165
|
+
return { config, source: path };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { config: DEFAULTS, source: "built-in" };
|
|
169
|
+
}
|
|
170
|
+
function resolveEnvVars(obj) {
|
|
171
|
+
if (typeof obj === "string") {
|
|
172
|
+
return obj.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] ?? "");
|
|
173
|
+
}
|
|
174
|
+
if (Array.isArray(obj)) return obj.map(resolveEnvVars);
|
|
175
|
+
if (obj && typeof obj === "object") {
|
|
176
|
+
return Object.fromEntries(
|
|
177
|
+
Object.entries(obj).map(([k, v]) => [k, resolveEnvVars(v)])
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return obj;
|
|
181
|
+
}
|
|
182
|
+
var ConfigValidationError = class extends Error {
|
|
183
|
+
constructor(path, errors) {
|
|
184
|
+
const details = errors.map((e) => ` ${e.path}: ${e.message}`).join("\n");
|
|
185
|
+
super(`Invalid governance config at ${path}:
|
|
186
|
+
${details}`);
|
|
187
|
+
this.name = "ConfigValidationError";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
ConfigValidationError,
|
|
193
|
+
loadConfig
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/config/loader.ts","../src/lib/config/schema.ts","../src/lib/config/defaults.ts"],"sourcesContent":["export { type GovernanceConfig } from './lib/config/schema.js';\nexport { loadConfig, ConfigValidationError } from './lib/config/loader.js';\nexport {\n type PolicyEngine,\n type PolicyDecision,\n type PathOperation,\n type ExecutionMode,\n type BashOverrides,\n} from './lib/policy/engine.js';\nexport { type IdentityProvider, type ResolvedIdentity } from './lib/identity/provider.js';\nexport { type FactStore, type RoleBinding, type Relation } from './lib/facts/store.js';\nexport { type BashClassification } from './lib/bash/classifier.js';\nexport { type AuditSink } from './lib/audit/sinks/sink.js';\n","import { existsSync, readFileSync } from 'fs';\nimport { parse as parseYaml } from 'yaml';\nimport { Value } from '@sinclair/typebox/value';\nimport { GovernanceConfigSchema, type GovernanceConfig } from './schema.js';\nimport { DEFAULTS } from './defaults.js';\n\nconst CONFIG_PATHS = [\n process.env.GRWND_GOVERNANCE_CONFIG,\n '.pi/governance.yaml',\n `${process.env.HOME}/.pi/agent/governance.yaml`,\n];\n\nexport function loadConfig(): { config: GovernanceConfig; source: string } {\n for (const path of CONFIG_PATHS) {\n if (path && existsSync(path)) {\n const raw = readFileSync(path, 'utf-8');\n const parsed = parseYaml(raw);\n\n const resolved = resolveEnvVars(parsed);\n\n const errors = [...Value.Errors(GovernanceConfigSchema, resolved)];\n if (errors.length > 0) {\n throw new ConfigValidationError(\n path,\n errors.map((e) => ({ path: e.path, message: e.message })),\n );\n }\n\n const config = Value.Default(GovernanceConfigSchema, resolved) as GovernanceConfig;\n return { config, source: path };\n }\n }\n\n return { config: DEFAULTS, source: 'built-in' };\n}\n\nfunction resolveEnvVars(obj: unknown): unknown {\n if (typeof obj === 'string') {\n return obj.replace(/\\$\\{(\\w+)\\}/g, (_, name: string) => process.env[name] ?? '');\n }\n if (Array.isArray(obj)) return obj.map(resolveEnvVars);\n if (obj && typeof obj === 'object') {\n return Object.fromEntries(\n Object.entries(obj as Record<string, unknown>).map(([k, v]) => [k, resolveEnvVars(v)]),\n );\n }\n return obj;\n}\n\nexport class ConfigValidationError extends Error {\n constructor(path: string, errors: Array<{ path: string; message: string }>) {\n const details = errors.map((e) => ` ${e.path}: ${e.message}`).join('\\n');\n super(`Invalid governance config at ${path}:\\n${details}`);\n this.name = 'ConfigValidationError';\n }\n}\n","import { Type, type Static } from '@sinclair/typebox';\n\nconst AuthEnvConfig = Type.Object({\n user_var: Type.String({ default: 'GRWND_USER' }),\n role_var: Type.String({ default: 'GRWND_ROLE' }),\n org_unit_var: Type.String({ default: 'GRWND_ORG_UNIT' }),\n});\n\nconst AuthLocalConfig = Type.Object({\n users_file: Type.String({ default: './users.yaml' }),\n});\n\nconst AuthConfig = Type.Object({\n provider: Type.Union([Type.Literal('env'), Type.Literal('local'), Type.Literal('oidc')], {\n default: 'env',\n }),\n env: Type.Optional(AuthEnvConfig),\n local: Type.Optional(AuthLocalConfig),\n});\n\nexport type AuthConfigType = Static<typeof AuthConfig>;\n\nconst YamlPolicyConfig = Type.Object({\n rules_file: Type.String({ default: './governance-rules.yaml' }),\n});\n\nconst OsoPolicyConfig = Type.Object({\n polar_files: Type.Array(Type.String(), {\n default: ['./policies/base.polar', './policies/tools.polar'],\n }),\n});\n\nconst PolicyConfig = Type.Object({\n engine: Type.Union([Type.Literal('yaml'), Type.Literal('oso')], { default: 'yaml' }),\n yaml: Type.Optional(YamlPolicyConfig),\n oso: Type.Optional(OsoPolicyConfig),\n});\n\nconst TemplatesConfig = Type.Object({\n directory: Type.String({ default: './templates/' }),\n default: Type.String({ default: 'project-lead' }),\n});\n\nconst HitlWebhookConfig = Type.Object({\n url: Type.String(),\n});\n\nconst HitlConfig = Type.Object({\n default_mode: Type.Union(\n [Type.Literal('autonomous'), Type.Literal('supervised'), Type.Literal('dry_run')],\n { default: 'supervised' },\n ),\n approval_channel: Type.Union([Type.Literal('cli'), Type.Literal('webhook')], { default: 'cli' }),\n timeout_seconds: Type.Number({ default: 300, minimum: 10, maximum: 3600 }),\n webhook: Type.Optional(HitlWebhookConfig),\n});\n\nconst JsonlSinkConfig = Type.Object({\n type: Type.Literal('jsonl'),\n path: Type.String({ default: '~/.pi/agent/audit.jsonl' }),\n});\n\nconst WebhookSinkConfig = Type.Object({\n type: Type.Literal('webhook'),\n url: Type.String(),\n});\n\nconst PostgresSinkConfig = Type.Object({\n type: Type.Literal('postgres'),\n connection: Type.String(),\n});\n\nconst AuditSinkConfig = Type.Union([JsonlSinkConfig, WebhookSinkConfig, PostgresSinkConfig]);\n\nconst AuditConfig = Type.Object({\n sinks: Type.Array(AuditSinkConfig, {\n default: [{ type: 'jsonl', path: '~/.pi/agent/audit.jsonl' }],\n }),\n});\n\nconst OrgUnitOverride = Type.Object({\n hitl: Type.Optional(Type.Partial(HitlConfig)),\n policy: Type.Optional(\n Type.Object({\n extra_polar: Type.Optional(Type.String()),\n extra_rules: Type.Optional(Type.String()),\n }),\n ),\n});\n\nexport const GovernanceConfigSchema = Type.Object({\n auth: Type.Optional(AuthConfig),\n policy: Type.Optional(PolicyConfig),\n templates: Type.Optional(TemplatesConfig),\n hitl: Type.Optional(HitlConfig),\n audit: Type.Optional(AuditConfig),\n org_units: Type.Optional(Type.Record(Type.String(), OrgUnitOverride)),\n});\n\nexport type GovernanceConfig = Static<typeof GovernanceConfigSchema>;\n","import type { GovernanceConfig } from './schema.js';\n\nexport const DEFAULTS: GovernanceConfig = {\n auth: {\n provider: 'env',\n env: {\n user_var: 'GRWND_USER',\n role_var: 'GRWND_ROLE',\n org_unit_var: 'GRWND_ORG_UNIT',\n },\n },\n policy: {\n engine: 'yaml',\n yaml: {\n rules_file: './governance-rules.yaml',\n },\n },\n templates: {\n directory: './templates/',\n default: 'project-lead',\n },\n hitl: {\n default_mode: 'supervised',\n approval_channel: 'cli',\n timeout_seconds: 300,\n },\n audit: {\n sinks: [{ type: 'jsonl', path: '~/.pi/agent/audit.jsonl' }],\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gBAAyC;AACzC,kBAAmC;AACnC,mBAAsB;;;ACFtB,qBAAkC;AAElC,IAAM,gBAAgB,oBAAK,OAAO;AAAA,EAChC,UAAU,oBAAK,OAAO,EAAE,SAAS,aAAa,CAAC;AAAA,EAC/C,UAAU,oBAAK,OAAO,EAAE,SAAS,aAAa,CAAC;AAAA,EAC/C,cAAc,oBAAK,OAAO,EAAE,SAAS,iBAAiB,CAAC;AACzD,CAAC;AAED,IAAM,kBAAkB,oBAAK,OAAO;AAAA,EAClC,YAAY,oBAAK,OAAO,EAAE,SAAS,eAAe,CAAC;AACrD,CAAC;AAED,IAAM,aAAa,oBAAK,OAAO;AAAA,EAC7B,UAAU,oBAAK,MAAM,CAAC,oBAAK,QAAQ,KAAK,GAAG,oBAAK,QAAQ,OAAO,GAAG,oBAAK,QAAQ,MAAM,CAAC,GAAG;AAAA,IACvF,SAAS;AAAA,EACX,CAAC;AAAA,EACD,KAAK,oBAAK,SAAS,aAAa;AAAA,EAChC,OAAO,oBAAK,SAAS,eAAe;AACtC,CAAC;AAID,IAAM,mBAAmB,oBAAK,OAAO;AAAA,EACnC,YAAY,oBAAK,OAAO,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IAAI,IAAI,cAAc;AACrD,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,WAAO,OAAO;AAAA,MACZ,OAAO,QAAQ,GAA8B,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;AAAA,IACvF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAY,MAAc,QAAkD;AAC1E,UAAM,UAAU,OAAO,IAAI,CAAC,MAAM,KAAK,EAAE,IAAI,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,IAAI;AACxE,UAAM,gCAAgC,IAAI;AAAA,EAAM,OAAO,EAAE;AACzD,SAAK,OAAO;AAAA,EACd;AACF;","names":["parseYaml"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
+
import { Static } from '@sinclair/typebox';
|
|
3
|
+
|
|
4
|
+
declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
|
|
5
|
+
auth: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
6
|
+
provider: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"env">, _sinclair_typebox.TLiteral<"local">, _sinclair_typebox.TLiteral<"oidc">]>;
|
|
7
|
+
env: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
8
|
+
user_var: _sinclair_typebox.TString;
|
|
9
|
+
role_var: _sinclair_typebox.TString;
|
|
10
|
+
org_unit_var: _sinclair_typebox.TString;
|
|
11
|
+
}>>;
|
|
12
|
+
local: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
13
|
+
users_file: _sinclair_typebox.TString;
|
|
14
|
+
}>>;
|
|
15
|
+
}>>;
|
|
16
|
+
policy: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
17
|
+
engine: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"yaml">, _sinclair_typebox.TLiteral<"oso">]>;
|
|
18
|
+
yaml: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
19
|
+
rules_file: _sinclair_typebox.TString;
|
|
20
|
+
}>>;
|
|
21
|
+
oso: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
22
|
+
polar_files: _sinclair_typebox.TArray<_sinclair_typebox.TString>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>>;
|
|
25
|
+
templates: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
26
|
+
directory: _sinclair_typebox.TString;
|
|
27
|
+
default: _sinclair_typebox.TString;
|
|
28
|
+
}>>;
|
|
29
|
+
hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
30
|
+
default_mode: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>;
|
|
31
|
+
approval_channel: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"cli">, _sinclair_typebox.TLiteral<"webhook">]>;
|
|
32
|
+
timeout_seconds: _sinclair_typebox.TNumber;
|
|
33
|
+
webhook: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
34
|
+
url: _sinclair_typebox.TString;
|
|
35
|
+
}>>;
|
|
36
|
+
}>>;
|
|
37
|
+
audit: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
38
|
+
sinks: _sinclair_typebox.TArray<_sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
39
|
+
type: _sinclair_typebox.TLiteral<"jsonl">;
|
|
40
|
+
path: _sinclair_typebox.TString;
|
|
41
|
+
}>, _sinclair_typebox.TObject<{
|
|
42
|
+
type: _sinclair_typebox.TLiteral<"webhook">;
|
|
43
|
+
url: _sinclair_typebox.TString;
|
|
44
|
+
}>, _sinclair_typebox.TObject<{
|
|
45
|
+
type: _sinclair_typebox.TLiteral<"postgres">;
|
|
46
|
+
connection: _sinclair_typebox.TString;
|
|
47
|
+
}>]>>;
|
|
48
|
+
}>>;
|
|
49
|
+
org_units: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
|
|
50
|
+
hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
51
|
+
default_mode: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>>;
|
|
52
|
+
approval_channel: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"cli">, _sinclair_typebox.TLiteral<"webhook">]>>;
|
|
53
|
+
timeout_seconds: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
54
|
+
webhook: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
55
|
+
url: _sinclair_typebox.TString;
|
|
56
|
+
}>>;
|
|
57
|
+
}>>;
|
|
58
|
+
policy: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
59
|
+
extra_polar: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
60
|
+
extra_rules: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
61
|
+
}>>;
|
|
62
|
+
}>>>;
|
|
63
|
+
}>;
|
|
64
|
+
type GovernanceConfig = Static<typeof GovernanceConfigSchema>;
|
|
65
|
+
|
|
66
|
+
declare function loadConfig(): {
|
|
67
|
+
config: GovernanceConfig;
|
|
68
|
+
source: string;
|
|
69
|
+
};
|
|
70
|
+
declare class ConfigValidationError extends Error {
|
|
71
|
+
constructor(path: string, errors: Array<{
|
|
72
|
+
path: string;
|
|
73
|
+
message: string;
|
|
74
|
+
}>);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type PolicyDecision = 'allow' | 'deny' | 'needs_approval';
|
|
78
|
+
type PathOperation = 'read' | 'write';
|
|
79
|
+
type ExecutionMode = 'autonomous' | 'supervised' | 'dry_run';
|
|
80
|
+
interface BashOverrides {
|
|
81
|
+
additionalBlocked?: RegExp[];
|
|
82
|
+
additionalAllowed?: RegExp[];
|
|
83
|
+
}
|
|
84
|
+
interface PolicyEngine {
|
|
85
|
+
evaluateTool(role: string, tool: string): PolicyDecision;
|
|
86
|
+
evaluatePath(role: string, orgUnit: string, operation: PathOperation, path: string): PolicyDecision;
|
|
87
|
+
requiresApproval(role: string, tool: string): boolean;
|
|
88
|
+
getExecutionMode(role: string): ExecutionMode;
|
|
89
|
+
getTemplateName(role: string): string;
|
|
90
|
+
getBashOverrides(role: string): BashOverrides;
|
|
91
|
+
getTokenBudget(role: string): number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ResolvedIdentity {
|
|
95
|
+
userId: string;
|
|
96
|
+
role: string;
|
|
97
|
+
orgUnit: string;
|
|
98
|
+
source: string;
|
|
99
|
+
}
|
|
100
|
+
interface IdentityProvider {
|
|
101
|
+
name: string;
|
|
102
|
+
resolve(): Promise<ResolvedIdentity | null>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface RoleBinding {
|
|
106
|
+
userId: string;
|
|
107
|
+
role: string;
|
|
108
|
+
orgUnit: string;
|
|
109
|
+
config?: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
interface Relation {
|
|
112
|
+
subject: string;
|
|
113
|
+
predicate: string;
|
|
114
|
+
object: string;
|
|
115
|
+
}
|
|
116
|
+
interface FactStore {
|
|
117
|
+
getRoles(userId: string): Promise<RoleBinding[]>;
|
|
118
|
+
getAllRoleBindings(): Promise<RoleBinding[]>;
|
|
119
|
+
getRelations(subject: string, predicate: string): Promise<Relation[]>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type BashClassification = 'safe' | 'dangerous' | 'needs_review';
|
|
123
|
+
|
|
124
|
+
interface AuditSink {
|
|
125
|
+
write(record: Record<string, unknown>): Promise<void>;
|
|
126
|
+
flush(): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { type AuditSink, type BashClassification, type BashOverrides, ConfigValidationError, type ExecutionMode, type FactStore, type GovernanceConfig, type IdentityProvider, type PathOperation, type PolicyDecision, type PolicyEngine, type Relation, type ResolvedIdentity, type RoleBinding, loadConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
+
import { Static } from '@sinclair/typebox';
|
|
3
|
+
|
|
4
|
+
declare const GovernanceConfigSchema: _sinclair_typebox.TObject<{
|
|
5
|
+
auth: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
6
|
+
provider: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"env">, _sinclair_typebox.TLiteral<"local">, _sinclair_typebox.TLiteral<"oidc">]>;
|
|
7
|
+
env: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
8
|
+
user_var: _sinclair_typebox.TString;
|
|
9
|
+
role_var: _sinclair_typebox.TString;
|
|
10
|
+
org_unit_var: _sinclair_typebox.TString;
|
|
11
|
+
}>>;
|
|
12
|
+
local: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
13
|
+
users_file: _sinclair_typebox.TString;
|
|
14
|
+
}>>;
|
|
15
|
+
}>>;
|
|
16
|
+
policy: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
17
|
+
engine: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"yaml">, _sinclair_typebox.TLiteral<"oso">]>;
|
|
18
|
+
yaml: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
19
|
+
rules_file: _sinclair_typebox.TString;
|
|
20
|
+
}>>;
|
|
21
|
+
oso: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
22
|
+
polar_files: _sinclair_typebox.TArray<_sinclair_typebox.TString>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>>;
|
|
25
|
+
templates: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
26
|
+
directory: _sinclair_typebox.TString;
|
|
27
|
+
default: _sinclair_typebox.TString;
|
|
28
|
+
}>>;
|
|
29
|
+
hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
30
|
+
default_mode: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>;
|
|
31
|
+
approval_channel: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"cli">, _sinclair_typebox.TLiteral<"webhook">]>;
|
|
32
|
+
timeout_seconds: _sinclair_typebox.TNumber;
|
|
33
|
+
webhook: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
34
|
+
url: _sinclair_typebox.TString;
|
|
35
|
+
}>>;
|
|
36
|
+
}>>;
|
|
37
|
+
audit: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
38
|
+
sinks: _sinclair_typebox.TArray<_sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
39
|
+
type: _sinclair_typebox.TLiteral<"jsonl">;
|
|
40
|
+
path: _sinclair_typebox.TString;
|
|
41
|
+
}>, _sinclair_typebox.TObject<{
|
|
42
|
+
type: _sinclair_typebox.TLiteral<"webhook">;
|
|
43
|
+
url: _sinclair_typebox.TString;
|
|
44
|
+
}>, _sinclair_typebox.TObject<{
|
|
45
|
+
type: _sinclair_typebox.TLiteral<"postgres">;
|
|
46
|
+
connection: _sinclair_typebox.TString;
|
|
47
|
+
}>]>>;
|
|
48
|
+
}>>;
|
|
49
|
+
org_units: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
|
|
50
|
+
hitl: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
51
|
+
default_mode: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"autonomous">, _sinclair_typebox.TLiteral<"supervised">, _sinclair_typebox.TLiteral<"dry_run">]>>;
|
|
52
|
+
approval_channel: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"cli">, _sinclair_typebox.TLiteral<"webhook">]>>;
|
|
53
|
+
timeout_seconds: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
54
|
+
webhook: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
55
|
+
url: _sinclair_typebox.TString;
|
|
56
|
+
}>>;
|
|
57
|
+
}>>;
|
|
58
|
+
policy: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
59
|
+
extra_polar: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
60
|
+
extra_rules: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
61
|
+
}>>;
|
|
62
|
+
}>>>;
|
|
63
|
+
}>;
|
|
64
|
+
type GovernanceConfig = Static<typeof GovernanceConfigSchema>;
|
|
65
|
+
|
|
66
|
+
declare function loadConfig(): {
|
|
67
|
+
config: GovernanceConfig;
|
|
68
|
+
source: string;
|
|
69
|
+
};
|
|
70
|
+
declare class ConfigValidationError extends Error {
|
|
71
|
+
constructor(path: string, errors: Array<{
|
|
72
|
+
path: string;
|
|
73
|
+
message: string;
|
|
74
|
+
}>);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type PolicyDecision = 'allow' | 'deny' | 'needs_approval';
|
|
78
|
+
type PathOperation = 'read' | 'write';
|
|
79
|
+
type ExecutionMode = 'autonomous' | 'supervised' | 'dry_run';
|
|
80
|
+
interface BashOverrides {
|
|
81
|
+
additionalBlocked?: RegExp[];
|
|
82
|
+
additionalAllowed?: RegExp[];
|
|
83
|
+
}
|
|
84
|
+
interface PolicyEngine {
|
|
85
|
+
evaluateTool(role: string, tool: string): PolicyDecision;
|
|
86
|
+
evaluatePath(role: string, orgUnit: string, operation: PathOperation, path: string): PolicyDecision;
|
|
87
|
+
requiresApproval(role: string, tool: string): boolean;
|
|
88
|
+
getExecutionMode(role: string): ExecutionMode;
|
|
89
|
+
getTemplateName(role: string): string;
|
|
90
|
+
getBashOverrides(role: string): BashOverrides;
|
|
91
|
+
getTokenBudget(role: string): number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ResolvedIdentity {
|
|
95
|
+
userId: string;
|
|
96
|
+
role: string;
|
|
97
|
+
orgUnit: string;
|
|
98
|
+
source: string;
|
|
99
|
+
}
|
|
100
|
+
interface IdentityProvider {
|
|
101
|
+
name: string;
|
|
102
|
+
resolve(): Promise<ResolvedIdentity | null>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface RoleBinding {
|
|
106
|
+
userId: string;
|
|
107
|
+
role: string;
|
|
108
|
+
orgUnit: string;
|
|
109
|
+
config?: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
interface Relation {
|
|
112
|
+
subject: string;
|
|
113
|
+
predicate: string;
|
|
114
|
+
object: string;
|
|
115
|
+
}
|
|
116
|
+
interface FactStore {
|
|
117
|
+
getRoles(userId: string): Promise<RoleBinding[]>;
|
|
118
|
+
getAllRoleBindings(): Promise<RoleBinding[]>;
|
|
119
|
+
getRelations(subject: string, predicate: string): Promise<Relation[]>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type BashClassification = 'safe' | 'dangerous' | 'needs_review';
|
|
123
|
+
|
|
124
|
+
interface AuditSink {
|
|
125
|
+
write(record: Record<string, unknown>): Promise<void>;
|
|
126
|
+
flush(): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { type AuditSink, type BashClassification, type BashOverrides, ConfigValidationError, type ExecutionMode, type FactStore, type GovernanceConfig, type IdentityProvider, type PathOperation, type PolicyDecision, type PolicyEngine, type Relation, type ResolvedIdentity, type RoleBinding, loadConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// src/lib/config/loader.ts
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { Value } from "@sinclair/typebox/value";
|
|
5
|
+
|
|
6
|
+
// src/lib/config/schema.ts
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
8
|
+
var AuthEnvConfig = Type.Object({
|
|
9
|
+
user_var: Type.String({ default: "GRWND_USER" }),
|
|
10
|
+
role_var: Type.String({ default: "GRWND_ROLE" }),
|
|
11
|
+
org_unit_var: Type.String({ default: "GRWND_ORG_UNIT" })
|
|
12
|
+
});
|
|
13
|
+
var AuthLocalConfig = Type.Object({
|
|
14
|
+
users_file: Type.String({ default: "./users.yaml" })
|
|
15
|
+
});
|
|
16
|
+
var AuthConfig = Type.Object({
|
|
17
|
+
provider: Type.Union([Type.Literal("env"), Type.Literal("local"), Type.Literal("oidc")], {
|
|
18
|
+
default: "env"
|
|
19
|
+
}),
|
|
20
|
+
env: Type.Optional(AuthEnvConfig),
|
|
21
|
+
local: Type.Optional(AuthLocalConfig)
|
|
22
|
+
});
|
|
23
|
+
var YamlPolicyConfig = Type.Object({
|
|
24
|
+
rules_file: Type.String({ default: "./governance-rules.yaml" })
|
|
25
|
+
});
|
|
26
|
+
var OsoPolicyConfig = Type.Object({
|
|
27
|
+
polar_files: Type.Array(Type.String(), {
|
|
28
|
+
default: ["./policies/base.polar", "./policies/tools.polar"]
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
var PolicyConfig = Type.Object({
|
|
32
|
+
engine: Type.Union([Type.Literal("yaml"), Type.Literal("oso")], { default: "yaml" }),
|
|
33
|
+
yaml: Type.Optional(YamlPolicyConfig),
|
|
34
|
+
oso: Type.Optional(OsoPolicyConfig)
|
|
35
|
+
});
|
|
36
|
+
var TemplatesConfig = Type.Object({
|
|
37
|
+
directory: Type.String({ default: "./templates/" }),
|
|
38
|
+
default: Type.String({ default: "project-lead" })
|
|
39
|
+
});
|
|
40
|
+
var HitlWebhookConfig = Type.Object({
|
|
41
|
+
url: Type.String()
|
|
42
|
+
});
|
|
43
|
+
var HitlConfig = Type.Object({
|
|
44
|
+
default_mode: Type.Union(
|
|
45
|
+
[Type.Literal("autonomous"), Type.Literal("supervised"), Type.Literal("dry_run")],
|
|
46
|
+
{ default: "supervised" }
|
|
47
|
+
),
|
|
48
|
+
approval_channel: Type.Union([Type.Literal("cli"), Type.Literal("webhook")], { default: "cli" }),
|
|
49
|
+
timeout_seconds: Type.Number({ default: 300, minimum: 10, maximum: 3600 }),
|
|
50
|
+
webhook: Type.Optional(HitlWebhookConfig)
|
|
51
|
+
});
|
|
52
|
+
var JsonlSinkConfig = Type.Object({
|
|
53
|
+
type: Type.Literal("jsonl"),
|
|
54
|
+
path: Type.String({ default: "~/.pi/agent/audit.jsonl" })
|
|
55
|
+
});
|
|
56
|
+
var WebhookSinkConfig = Type.Object({
|
|
57
|
+
type: Type.Literal("webhook"),
|
|
58
|
+
url: Type.String()
|
|
59
|
+
});
|
|
60
|
+
var PostgresSinkConfig = Type.Object({
|
|
61
|
+
type: Type.Literal("postgres"),
|
|
62
|
+
connection: Type.String()
|
|
63
|
+
});
|
|
64
|
+
var AuditSinkConfig = Type.Union([JsonlSinkConfig, WebhookSinkConfig, PostgresSinkConfig]);
|
|
65
|
+
var AuditConfig = Type.Object({
|
|
66
|
+
sinks: Type.Array(AuditSinkConfig, {
|
|
67
|
+
default: [{ type: "jsonl", path: "~/.pi/agent/audit.jsonl" }]
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
var OrgUnitOverride = Type.Object({
|
|
71
|
+
hitl: Type.Optional(Type.Partial(HitlConfig)),
|
|
72
|
+
policy: Type.Optional(
|
|
73
|
+
Type.Object({
|
|
74
|
+
extra_polar: Type.Optional(Type.String()),
|
|
75
|
+
extra_rules: Type.Optional(Type.String())
|
|
76
|
+
})
|
|
77
|
+
)
|
|
78
|
+
});
|
|
79
|
+
var GovernanceConfigSchema = Type.Object({
|
|
80
|
+
auth: Type.Optional(AuthConfig),
|
|
81
|
+
policy: Type.Optional(PolicyConfig),
|
|
82
|
+
templates: Type.Optional(TemplatesConfig),
|
|
83
|
+
hitl: Type.Optional(HitlConfig),
|
|
84
|
+
audit: Type.Optional(AuditConfig),
|
|
85
|
+
org_units: Type.Optional(Type.Record(Type.String(), OrgUnitOverride))
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/lib/config/defaults.ts
|
|
89
|
+
var DEFAULTS = {
|
|
90
|
+
auth: {
|
|
91
|
+
provider: "env",
|
|
92
|
+
env: {
|
|
93
|
+
user_var: "GRWND_USER",
|
|
94
|
+
role_var: "GRWND_ROLE",
|
|
95
|
+
org_unit_var: "GRWND_ORG_UNIT"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
policy: {
|
|
99
|
+
engine: "yaml",
|
|
100
|
+
yaml: {
|
|
101
|
+
rules_file: "./governance-rules.yaml"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
templates: {
|
|
105
|
+
directory: "./templates/",
|
|
106
|
+
default: "project-lead"
|
|
107
|
+
},
|
|
108
|
+
hitl: {
|
|
109
|
+
default_mode: "supervised",
|
|
110
|
+
approval_channel: "cli",
|
|
111
|
+
timeout_seconds: 300
|
|
112
|
+
},
|
|
113
|
+
audit: {
|
|
114
|
+
sinks: [{ type: "jsonl", path: "~/.pi/agent/audit.jsonl" }]
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/lib/config/loader.ts
|
|
119
|
+
var CONFIG_PATHS = [
|
|
120
|
+
process.env.GRWND_GOVERNANCE_CONFIG,
|
|
121
|
+
".pi/governance.yaml",
|
|
122
|
+
`${process.env.HOME}/.pi/agent/governance.yaml`
|
|
123
|
+
];
|
|
124
|
+
function loadConfig() {
|
|
125
|
+
for (const path of CONFIG_PATHS) {
|
|
126
|
+
if (path && existsSync(path)) {
|
|
127
|
+
const raw = readFileSync(path, "utf-8");
|
|
128
|
+
const parsed = parseYaml(raw);
|
|
129
|
+
const resolved = resolveEnvVars(parsed);
|
|
130
|
+
const errors = [...Value.Errors(GovernanceConfigSchema, resolved)];
|
|
131
|
+
if (errors.length > 0) {
|
|
132
|
+
throw new ConfigValidationError(
|
|
133
|
+
path,
|
|
134
|
+
errors.map((e) => ({ path: e.path, message: e.message }))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const config = Value.Default(GovernanceConfigSchema, resolved);
|
|
138
|
+
return { config, source: path };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return { config: DEFAULTS, source: "built-in" };
|
|
142
|
+
}
|
|
143
|
+
function resolveEnvVars(obj) {
|
|
144
|
+
if (typeof obj === "string") {
|
|
145
|
+
return obj.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] ?? "");
|
|
146
|
+
}
|
|
147
|
+
if (Array.isArray(obj)) return obj.map(resolveEnvVars);
|
|
148
|
+
if (obj && typeof obj === "object") {
|
|
149
|
+
return Object.fromEntries(
|
|
150
|
+
Object.entries(obj).map(([k, v]) => [k, resolveEnvVars(v)])
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return obj;
|
|
154
|
+
}
|
|
155
|
+
var ConfigValidationError = class extends Error {
|
|
156
|
+
constructor(path, errors) {
|
|
157
|
+
const details = errors.map((e) => ` ${e.path}: ${e.message}`).join("\n");
|
|
158
|
+
super(`Invalid governance config at ${path}:
|
|
159
|
+
${details}`);
|
|
160
|
+
this.name = "ConfigValidationError";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
export {
|
|
164
|
+
ConfigValidationError,
|
|
165
|
+
loadConfig
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/config/loader.ts","../src/lib/config/schema.ts","../src/lib/config/defaults.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { parse as parseYaml } from 'yaml';\nimport { Value } from '@sinclair/typebox/value';\nimport { GovernanceConfigSchema, type GovernanceConfig } from './schema.js';\nimport { DEFAULTS } from './defaults.js';\n\nconst CONFIG_PATHS = [\n process.env.GRWND_GOVERNANCE_CONFIG,\n '.pi/governance.yaml',\n `${process.env.HOME}/.pi/agent/governance.yaml`,\n];\n\nexport function loadConfig(): { config: GovernanceConfig; source: string } {\n for (const path of CONFIG_PATHS) {\n if (path && existsSync(path)) {\n const raw = readFileSync(path, 'utf-8');\n const parsed = parseYaml(raw);\n\n const resolved = resolveEnvVars(parsed);\n\n const errors = [...Value.Errors(GovernanceConfigSchema, resolved)];\n if (errors.length > 0) {\n throw new ConfigValidationError(\n path,\n errors.map((e) => ({ path: e.path, message: e.message })),\n );\n }\n\n const config = Value.Default(GovernanceConfigSchema, resolved) as GovernanceConfig;\n return { config, source: path };\n }\n }\n\n return { config: DEFAULTS, source: 'built-in' };\n}\n\nfunction resolveEnvVars(obj: unknown): unknown {\n if (typeof obj === 'string') {\n return obj.replace(/\\$\\{(\\w+)\\}/g, (_, name: string) => process.env[name] ?? '');\n }\n if (Array.isArray(obj)) return obj.map(resolveEnvVars);\n if (obj && typeof obj === 'object') {\n return Object.fromEntries(\n Object.entries(obj as Record<string, unknown>).map(([k, v]) => [k, resolveEnvVars(v)]),\n );\n }\n return obj;\n}\n\nexport class ConfigValidationError extends Error {\n constructor(path: string, errors: Array<{ path: string; message: string }>) {\n const details = errors.map((e) => ` ${e.path}: ${e.message}`).join('\\n');\n super(`Invalid governance config at ${path}:\\n${details}`);\n this.name = 'ConfigValidationError';\n }\n}\n","import { Type, type Static } from '@sinclair/typebox';\n\nconst AuthEnvConfig = Type.Object({\n user_var: Type.String({ default: 'GRWND_USER' }),\n role_var: Type.String({ default: 'GRWND_ROLE' }),\n org_unit_var: Type.String({ default: 'GRWND_ORG_UNIT' }),\n});\n\nconst AuthLocalConfig = Type.Object({\n users_file: Type.String({ default: './users.yaml' }),\n});\n\nconst AuthConfig = Type.Object({\n provider: Type.Union([Type.Literal('env'), Type.Literal('local'), Type.Literal('oidc')], {\n default: 'env',\n }),\n env: Type.Optional(AuthEnvConfig),\n local: Type.Optional(AuthLocalConfig),\n});\n\nexport type AuthConfigType = Static<typeof AuthConfig>;\n\nconst YamlPolicyConfig = Type.Object({\n rules_file: Type.String({ default: './governance-rules.yaml' }),\n});\n\nconst OsoPolicyConfig = Type.Object({\n polar_files: Type.Array(Type.String(), {\n default: ['./policies/base.polar', './policies/tools.polar'],\n }),\n});\n\nconst PolicyConfig = Type.Object({\n engine: Type.Union([Type.Literal('yaml'), Type.Literal('oso')], { default: 'yaml' }),\n yaml: Type.Optional(YamlPolicyConfig),\n oso: Type.Optional(OsoPolicyConfig),\n});\n\nconst TemplatesConfig = Type.Object({\n directory: Type.String({ default: './templates/' }),\n default: Type.String({ default: 'project-lead' }),\n});\n\nconst HitlWebhookConfig = Type.Object({\n url: Type.String(),\n});\n\nconst HitlConfig = Type.Object({\n default_mode: Type.Union(\n [Type.Literal('autonomous'), Type.Literal('supervised'), Type.Literal('dry_run')],\n { default: 'supervised' },\n ),\n approval_channel: Type.Union([Type.Literal('cli'), Type.Literal('webhook')], { default: 'cli' }),\n timeout_seconds: Type.Number({ default: 300, minimum: 10, maximum: 3600 }),\n webhook: Type.Optional(HitlWebhookConfig),\n});\n\nconst JsonlSinkConfig = Type.Object({\n type: Type.Literal('jsonl'),\n path: Type.String({ default: '~/.pi/agent/audit.jsonl' }),\n});\n\nconst WebhookSinkConfig = Type.Object({\n type: Type.Literal('webhook'),\n url: Type.String(),\n});\n\nconst PostgresSinkConfig = Type.Object({\n type: Type.Literal('postgres'),\n connection: Type.String(),\n});\n\nconst AuditSinkConfig = Type.Union([JsonlSinkConfig, WebhookSinkConfig, PostgresSinkConfig]);\n\nconst AuditConfig = Type.Object({\n sinks: Type.Array(AuditSinkConfig, {\n default: [{ type: 'jsonl', path: '~/.pi/agent/audit.jsonl' }],\n }),\n});\n\nconst OrgUnitOverride = Type.Object({\n hitl: Type.Optional(Type.Partial(HitlConfig)),\n policy: Type.Optional(\n Type.Object({\n extra_polar: Type.Optional(Type.String()),\n extra_rules: Type.Optional(Type.String()),\n }),\n ),\n});\n\nexport const GovernanceConfigSchema = Type.Object({\n auth: Type.Optional(AuthConfig),\n policy: Type.Optional(PolicyConfig),\n templates: Type.Optional(TemplatesConfig),\n hitl: Type.Optional(HitlConfig),\n audit: Type.Optional(AuditConfig),\n org_units: Type.Optional(Type.Record(Type.String(), OrgUnitOverride)),\n});\n\nexport type GovernanceConfig = Static<typeof GovernanceConfigSchema>;\n","import type { GovernanceConfig } from './schema.js';\n\nexport const DEFAULTS: GovernanceConfig = {\n auth: {\n provider: 'env',\n env: {\n user_var: 'GRWND_USER',\n role_var: 'GRWND_ROLE',\n org_unit_var: 'GRWND_ORG_UNIT',\n },\n },\n policy: {\n engine: 'yaml',\n yaml: {\n rules_file: './governance-rules.yaml',\n },\n },\n templates: {\n directory: './templates/',\n default: 'project-lead',\n },\n hitl: {\n default_mode: 'supervised',\n approval_channel: 'cli',\n timeout_seconds: 300,\n },\n audit: {\n sinks: [{ type: 'jsonl', path: '~/.pi/agent/audit.jsonl' }],\n },\n};\n"],"mappings":";AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa;;;ACFtB,SAAS,YAAyB;AAElC,IAAM,gBAAgB,KAAK,OAAO;AAAA,EAChC,UAAU,KAAK,OAAO,EAAE,SAAS,aAAa,CAAC;AAAA,EAC/C,UAAU,KAAK,OAAO,EAAE,SAAS,aAAa,CAAC;AAAA,EAC/C,cAAc,KAAK,OAAO,EAAE,SAAS,iBAAiB,CAAC;AACzD,CAAC;AAED,IAAM,kBAAkB,KAAK,OAAO;AAAA,EAClC,YAAY,KAAK,OAAO,EAAE,SAAS,eAAe,CAAC;AACrD,CAAC;AAED,IAAM,aAAa,KAAK,OAAO;AAAA,EAC7B,UAAU,KAAK,MAAM,CAAC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eAAe,KAAuB;AAC7C,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,IAAI,QAAQ,gBAAgB,CAAC,GAAG,SAAiB,QAAQ,IAAI,IAAI,KAAK,EAAE;AAAA,EACjF;AACA,MAAI,MAAM,QAAQ,GAAG,EAAG,QAAO,IAAI,IAAI,cAAc;AACrD,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,WAAO,OAAO;AAAA,MACZ,OAAO,QAAQ,GAA8B,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;AAAA,IACvF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAY,MAAc,QAAkD;AAC1E,UAAM,UAAU,OAAO,IAAI,CAAC,MAAM,KAAK,EAAE,IAAI,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,IAAI;AACxE,UAAM,gCAAgC,IAAI;AAAA,EAAM,OAAO,EAAE;AACzD,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grwnd/pi-governance",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Governance, RBAC, audit, and HITL for Pi-based coding agents",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"governance",
|
|
8
|
+
"rbac",
|
|
9
|
+
"audit",
|
|
10
|
+
"hitl"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"author": "Grwnd AI",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Grwnd-AI/pi-governance.git"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"prompts",
|
|
37
|
+
"policies",
|
|
38
|
+
"skills"
|
|
39
|
+
],
|
|
40
|
+
"pi": {
|
|
41
|
+
"extensions": [
|
|
42
|
+
"./dist/extensions"
|
|
43
|
+
],
|
|
44
|
+
"skills": [
|
|
45
|
+
"./skills"
|
|
46
|
+
],
|
|
47
|
+
"prompts": [
|
|
48
|
+
"./prompts"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"test": "vitest run",
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"test:coverage": "vitest run --coverage",
|
|
56
|
+
"lint": "eslint .",
|
|
57
|
+
"format": "prettier --write .",
|
|
58
|
+
"format:check": "prettier --check .",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"docs:dev": "vitepress dev docs",
|
|
61
|
+
"docs:build": "vitepress build docs",
|
|
62
|
+
"docs:preview": "vitepress preview docs",
|
|
63
|
+
"prepare": "husky"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@mariozechner/pi-coding-agent": ">=0.50.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@mariozechner/pi-coding-agent": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@sinclair/typebox": "^0.33.0",
|
|
75
|
+
"minimatch": "^9.0.0",
|
|
76
|
+
"yaml": "^2.0.0"
|
|
77
|
+
},
|
|
78
|
+
"optionalDependencies": {
|
|
79
|
+
"oso": "^0.27.0"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
83
|
+
"@semantic-release/git": "^10.0.0",
|
|
84
|
+
"@types/node": "^25.3.3",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
86
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
87
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
88
|
+
"eslint": "^9.0.0",
|
|
89
|
+
"husky": "^9.0.0",
|
|
90
|
+
"lint-staged": "^15.0.0",
|
|
91
|
+
"prettier": "^3.3.0",
|
|
92
|
+
"semantic-release": "^24.0.0",
|
|
93
|
+
"tsup": "^8.0.0",
|
|
94
|
+
"typescript": "^5.5.0",
|
|
95
|
+
"typescript-eslint": "^8.0.0",
|
|
96
|
+
"vitepress": "^1.6.0",
|
|
97
|
+
"vitest": "^3.0.0"
|
|
98
|
+
},
|
|
99
|
+
"lint-staged": {
|
|
100
|
+
"*.{ts,tsx}": [
|
|
101
|
+
"eslint --fix",
|
|
102
|
+
"prettier --write"
|
|
103
|
+
],
|
|
104
|
+
"*.{json,md,yaml,yml}": [
|
|
105
|
+
"prettier --write"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"packageManager": "pnpm@10.30.3",
|
|
109
|
+
"engines": {
|
|
110
|
+
"node": ">=20"
|
|
111
|
+
}
|
|
112
|
+
}
|