@grwnd/pi-governance 2.0.0 → 3.0.1

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 CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright 2026 Grwnd AI
178
+ Copyright 2026 dtmirizzi
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -9,11 +9,11 @@
9
9
  </p>
10
10
 
11
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>
12
+ <a href="https://github.com/dtmirizzi/pi-governance/actions/workflows/ci.yml"><img src="https://github.com/dtmirizzi/pi-governance/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
13
13
  <a href="https://www.npmjs.com/package/@grwnd/pi-governance"><img src="https://img.shields.io/npm/v/@grwnd/pi-governance" alt="npm pi-governance" /></a>
14
14
  <a href="https://www.npmjs.com/package/@grwnd/openclaw-governance"><img src="https://img.shields.io/npm/v/@grwnd/openclaw-governance?label=openclaw-governance" alt="npm openclaw-governance" /></a>
15
- <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>
16
- <a href="https://grwnd-ai.github.io/pi-governance/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-blue" alt="Docs" /></a>
15
+ <a href="https://github.com/dtmirizzi/pi-governance/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="License" /></a>
16
+ <a href="https://dtmirizzi.github.io/pi-governance/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-blue" alt="Docs" /></a>
17
17
  </p>
18
18
 
19
19
  ---
@@ -52,26 +52,26 @@ Opens a browser-based wizard to configure roles, DLP, audit, and HITL. Generates
52
52
 
53
53
  ### Manual YAML
54
54
 
55
- Create `.pi/governance.yaml` and `governance-rules.yaml` — see the [Configuration Reference](https://grwnd-ai.github.io/pi-governance/reference/config).
55
+ Create `.pi/governance.yaml` and `governance-rules.yaml` — see the [Configuration Reference](https://dtmirizzi.github.io/pi-governance/reference/config).
56
56
 
57
57
  ### Set identity
58
58
 
59
59
  ```bash
60
- export PI_RBAC_ROLE=project_lead # analyst | project_lead | admin | auditor
60
+ export PI_GOV_ROLE=project_lead # analyst | project_lead | admin | auditor
61
61
  pi
62
62
  /governance status
63
63
  ```
64
64
 
65
65
  ## Documentation
66
66
 
67
- Full docs at **[grwnd-ai.github.io/pi-governance](https://grwnd-ai.github.io/pi-governance/)**.
67
+ Full docs at **[dtmirizzi.github.io/pi-governance](https://dtmirizzi.github.io/pi-governance/)**.
68
68
 
69
- - [Why Governance?](https://grwnd-ai.github.io/pi-governance/guide/why) — What can go wrong without controls
70
- - [Quick Start](https://grwnd-ai.github.io/pi-governance/guide/quickstart) — Install and configure
71
- - [Common Scenarios](https://grwnd-ai.github.io/pi-governance/guide/scenarios) — Copy-paste configs
72
- - [YAML Policies](https://grwnd-ai.github.io/pi-governance/guide/yaml-policies) — Full policy reference
73
- - [DLP Guide](https://grwnd-ai.github.io/pi-governance/guide/dlp) — Data loss prevention
74
- - [OpenClaw Integration](https://grwnd-ai.github.io/pi-governance/guide/openclaw) — MCP tool governance
69
+ - [Why Governance?](https://dtmirizzi.github.io/pi-governance/guide/why) — What can go wrong without controls
70
+ - [Quick Start](https://dtmirizzi.github.io/pi-governance/guide/quickstart) — Install and configure
71
+ - [Common Scenarios](https://dtmirizzi.github.io/pi-governance/guide/scenarios) — Copy-paste configs
72
+ - [YAML Policies](https://dtmirizzi.github.io/pi-governance/guide/yaml-policies) — Full policy reference
73
+ - [DLP Guide](https://dtmirizzi.github.io/pi-governance/guide/dlp) — Data loss prevention
74
+ - [OpenClaw Integration](https://dtmirizzi.github.io/pi-governance/guide/openclaw) — MCP tool governance
75
75
 
76
76
  ## License
77
77
 
@@ -39,9 +39,9 @@ var init_defaults = __esm({
39
39
  auth: {
40
40
  provider: "env",
41
41
  env: {
42
- user_var: "PI_RBAC_USER",
43
- role_var: "PI_RBAC_ROLE",
44
- org_unit_var: "PI_RBAC_ORG_UNIT"
42
+ user_var: "PI_GOV_USER",
43
+ role_var: "PI_GOV_ROLE",
44
+ org_unit_var: "PI_GOV_ORG_UNIT"
45
45
  }
46
46
  },
47
47
  policy: {
@@ -920,15 +920,15 @@ var init_html = __esm({
920
920
  <div class="field-row-3">
921
921
  <div class="field">
922
922
  <label>User Var</label>
923
- <input type="text" id="auth-user-var" value="PI_RBAC_USER" onchange="updatePreview()">
923
+ <input type="text" id="auth-user-var" value="PI_GOV_USER" onchange="updatePreview()">
924
924
  </div>
925
925
  <div class="field">
926
926
  <label>Role Var</label>
927
- <input type="text" id="auth-role-var" value="PI_RBAC_ROLE" onchange="updatePreview()">
927
+ <input type="text" id="auth-role-var" value="PI_GOV_ROLE" onchange="updatePreview()">
928
928
  </div>
929
929
  <div class="field">
930
930
  <label>Org Unit Var</label>
931
- <input type="text" id="auth-org-unit-var" value="PI_RBAC_ORG_UNIT" onchange="updatePreview()">
931
+ <input type="text" id="auth-org-unit-var" value="PI_GOV_ORG_UNIT" onchange="updatePreview()">
932
932
  </div>
933
933
  </div>
934
934
  </div>
@@ -1378,9 +1378,9 @@ function buildGovernanceConfig() {
1378
1378
  cfg.auth = { provider: authProvider };
1379
1379
  if (authProvider === 'env') {
1380
1380
  cfg.auth.env = {
1381
- user_var: document.getElementById('auth-user-var').value || 'PI_RBAC_USER',
1382
- role_var: document.getElementById('auth-role-var').value || 'PI_RBAC_ROLE',
1383
- org_unit_var: document.getElementById('auth-org-unit-var').value || 'PI_RBAC_ORG_UNIT'
1381
+ user_var: document.getElementById('auth-user-var').value || 'PI_GOV_USER',
1382
+ role_var: document.getElementById('auth-role-var').value || 'PI_GOV_ROLE',
1383
+ org_unit_var: document.getElementById('auth-org-unit-var').value || 'PI_GOV_ORG_UNIT'
1384
1384
  };
1385
1385
  } else if (authProvider === 'local') {
1386
1386
  cfg.auth.local = {
@@ -1718,9 +1718,9 @@ var import_value = require("@sinclair/typebox/value");
1718
1718
  // src/lib/config/schema.ts
1719
1719
  var import_typebox = require("@sinclair/typebox");
1720
1720
  var AuthEnvConfig = import_typebox.Type.Object({
1721
- user_var: import_typebox.Type.String({ default: "PI_RBAC_USER" }),
1722
- role_var: import_typebox.Type.String({ default: "PI_RBAC_ROLE" }),
1723
- org_unit_var: import_typebox.Type.String({ default: "PI_RBAC_ORG_UNIT" })
1721
+ user_var: import_typebox.Type.String({ default: "PI_GOV_USER" }),
1722
+ role_var: import_typebox.Type.String({ default: "PI_GOV_ROLE" }),
1723
+ org_unit_var: import_typebox.Type.String({ default: "PI_GOV_ORG_UNIT" })
1724
1724
  });
1725
1725
  var AuthLocalConfig = import_typebox.Type.Object({
1726
1726
  users_file: import_typebox.Type.String({ default: "./users.yaml" })
@@ -1867,7 +1867,7 @@ var GovernanceConfigSchema = import_typebox.Type.Object({
1867
1867
  init_defaults();
1868
1868
  function getConfigPaths() {
1869
1869
  return [
1870
- process.env["PI_RBAC_GOVERNANCE_CONFIG"],
1870
+ process.env["PI_GOV_GOVERNANCE_CONFIG"],
1871
1871
  ".pi/governance.yaml",
1872
1872
  `${process.env["HOME"]}/.pi/agent/governance.yaml`
1873
1873
  ];
@@ -1914,7 +1914,7 @@ ${details}`);
1914
1914
 
1915
1915
  // src/lib/identity/env-provider.ts
1916
1916
  var EnvIdentityProvider = class {
1917
- constructor(userVar = "PI_RBAC_USER", roleVar = "PI_RBAC_ROLE", orgUnitVar = "PI_RBAC_ORG_UNIT") {
1917
+ constructor(userVar = "PI_GOV_USER", roleVar = "PI_GOV_ROLE", orgUnitVar = "PI_GOV_ORG_UNIT") {
1918
1918
  this.userVar = userVar;
1919
1919
  this.roleVar = roleVar;
1920
1920
  this.orgUnitVar = orgUnitVar;
@@ -3130,6 +3130,7 @@ var piGovernance = (pi) => {
3130
3130
  );
3131
3131
  });
3132
3132
  pi.on("tool_call", async (event, _ctx) => {
3133
+ if (!audit || !policyEngine || !identity) return void 0;
3133
3134
  const { toolName, input } = event;
3134
3135
  const params = summarizeParams(toolName, input);
3135
3136
  const baseRecord = {
@@ -3346,6 +3347,7 @@ var piGovernance = (pi) => {
3346
3347
  return void 0;
3347
3348
  });
3348
3349
  pi.on("tool_result", async (event, _ctx) => {
3350
+ if (!audit || !identity) return;
3349
3351
  if (dlpScanner && dlpMasker && event.output) {
3350
3352
  const result = dlpScanner.scan(event.output);
3351
3353
  if (result.hasMatches) {
@@ -3397,15 +3399,16 @@ var piGovernance = (pi) => {
3397
3399
  });
3398
3400
  pi.on("session_shutdown", async (_event, _ctx) => {
3399
3401
  configWatcher?.stop();
3402
+ if (!audit) return;
3400
3403
  await audit.log({
3401
3404
  sessionId,
3402
3405
  event: "session_end",
3403
- userId: identity.userId,
3404
- role: identity.role,
3405
- orgUnit: identity.orgUnit,
3406
+ userId: identity?.userId,
3407
+ role: identity?.role,
3408
+ orgUnit: identity?.orgUnit,
3406
3409
  metadata: {
3407
3410
  stats: { ...stats },
3408
- budget: { used: budgetTracker.used(), remaining: budgetTracker.remaining() },
3411
+ budget: budgetTracker ? { used: budgetTracker.used(), remaining: budgetTracker.remaining() } : void 0,
3409
3412
  summary: Object.fromEntries(audit.getSummary())
3410
3413
  }
3411
3414
  });