kpihx-bw 4.0.0__tar.gz
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.
- kpihx_bw-4.0.0/PKG-INFO +124 -0
- kpihx_bw-4.0.0/README.md +109 -0
- kpihx_bw-4.0.0/pyproject.toml +37 -0
- kpihx_bw-4.0.0/src/k_bw/__init__.py +0 -0
- kpihx_bw-4.0.0/src/k_bw/cli_bridge.py +432 -0
- kpihx_bw-4.0.0/src/k_bw/cli_support.py +365 -0
- kpihx_bw-4.0.0/src/k_bw/config.py +255 -0
- kpihx_bw-4.0.0/src/k_bw/config.yaml +27 -0
- kpihx_bw-4.0.0/src/k_bw/daemon.py +63 -0
- kpihx_bw-4.0.0/src/k_bw/logger.py +141 -0
- kpihx_bw-4.0.0/src/k_bw/logic.py +1382 -0
- kpihx_bw-4.0.0/src/k_bw/main.py +584 -0
- kpihx_bw-4.0.0/src/k_bw/models.py +590 -0
- kpihx_bw-4.0.0/src/k_bw/scrubber.py +52 -0
- kpihx_bw-4.0.0/src/k_bw/server.py +119 -0
- kpihx_bw-4.0.0/src/k_bw/session.py +27 -0
- kpihx_bw-4.0.0/src/k_bw/subprocess_wrapper.py +595 -0
- kpihx_bw-4.0.0/src/k_bw/transaction.py +714 -0
- kpihx_bw-4.0.0/src/k_bw/ui.py +460 -0
- kpihx_bw-4.0.0/src/k_bw/unlock_lease.py +131 -0
- kpihx_bw-4.0.0/src/k_bw/vault_runtime.py +291 -0
- kpihx_bw-4.0.0/src/k_bw/wal.py +152 -0
- kpihx_bw-4.0.0/src/k_bw/web_ui.py +817 -0
kpihx_bw-4.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: kpihx-bw
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: A sovereign proxy acting as a security-hardened blind hub between LLMs and the Bitwarden CLI. Zero Trust ยท AI-Blind ยท ACID.
|
|
5
|
+
Author: KpihX
|
|
6
|
+
Author-email: KpihX <kapoivha@gmail.com>
|
|
7
|
+
Requires-Dist: mcp>=1.26.0
|
|
8
|
+
Requires-Dist: pydantic>=2.12.5
|
|
9
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
10
|
+
Requires-Dist: rich>=14.3.3
|
|
11
|
+
Requires-Dist: typer>=0.12.0
|
|
12
|
+
Requires-Dist: cryptography>=44.0.0
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# ๐ k-bw โ Sovereign Bitwarden Appliance
|
|
17
|
+
|
|
18
|
+
> **Zero Trust ยท AI-Blind ยท ACID Durable**
|
|
19
|
+
> The authoritative appliance for Bitwarden organization vault control. Keep AI agents and LLMs blind to your real secrets while giving them full auditing and refactoring powers.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ๐๏ธ Project Architecture (Sovereign Tree)
|
|
24
|
+
|
|
25
|
+
```ascii
|
|
26
|
+
BW-PROXY PROJECT
|
|
27
|
+
โโโ ๐ src/k_bw/ โโโ Core Engine (ACID Transaction, WAL, Redaction)
|
|
28
|
+
โโโ ๐ scripts/ โโโ Host-side Shims (Dynamic porting, Browser HITL)
|
|
29
|
+
โโโ ๐ docs/ โโโ Deep-dive Hardening & Operator Guides
|
|
30
|
+
โโโ ๐ install.sh โโโ System-wide Appliance Installer (Root-owned)
|
|
31
|
+
โโโ ๐ Makefile โโโ Developer & Release Automator
|
|
32
|
+
โโโ ๐ Dockerfile โโโ Multi-stage Hardened Runtime
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## ๐ Installation Modes
|
|
38
|
+
|
|
39
|
+
### A. Appliance Mode (Standard Pro)
|
|
40
|
+
Ideal for production use. Installs a root-owned binary and uses the official image.
|
|
41
|
+
|
|
42
|
+
**Via curl (Zero-Clone):**
|
|
43
|
+
```bash
|
|
44
|
+
curl -fsSL https://raw.githubusercontent.com/kpihx-labs/k-bw/main/install.sh | sudo bash
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**What it does internally:**
|
|
48
|
+
1. **Image**: Pulls `ghcr.io/kpihx-labs/k-bw:latest`.
|
|
49
|
+
2. **Binary**: Creates `/usr/local/bin/k-bw` (owned by root).
|
|
50
|
+
3. **Config**: Seeds `~/.config/k-bw/` (owned by the invoking user).
|
|
51
|
+
4. **Data**: Creates a persistent Docker volume `k-bw-data`.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### B. Developer Mode (Source Clone)
|
|
56
|
+
Ideal for contribution or source-level auditing.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/kpihx-labs/k-bw.git
|
|
60
|
+
cd k-bw
|
|
61
|
+
make docker-install # Requires SUDO for builds
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## โ๏ธ Core Mechanisms (The Magic)
|
|
67
|
+
|
|
68
|
+
### 1. The HITL Browser Flux
|
|
69
|
+
When an AI agent requests a vault change, the proxy intercepts the execution:
|
|
70
|
+
1. **Port Allocation**: The host shim finds a free random port.
|
|
71
|
+
2. **Container Launch**: The appliance starts, mapping the internal HITL server to that port.
|
|
72
|
+
3. **URL Interception**: The shim detects the Approval URL in stdout and **automatically opens your browser**.
|
|
73
|
+
4. **Human Approval**: You review the rationale and the diff, then approve with your Master Password.
|
|
74
|
+
|
|
75
|
+
### 2. The 3-Phase ACID Commit (WAL)
|
|
76
|
+
Every mutation is transactional.
|
|
77
|
+
- **Simulation**: Actions are validated in RAM first.
|
|
78
|
+
- **WAL**: Actions are encrypted and logged to disk *before* execution.
|
|
79
|
+
- **Commit**: Actions are sent to the Bitwarden CLI.
|
|
80
|
+
- **Rollback**: If a crash occurs, the proxy performs a LIFO rollback on the next start.
|
|
81
|
+
|
|
82
|
+
### 3. Scoped Union Fetch
|
|
83
|
+
To handle organizational vaults without metadata loss:
|
|
84
|
+
- The proxy discovers all accessible **Organizations** and **Collections** first.
|
|
85
|
+
- It then performs scoped queries (`--organizationid`) to fetch "rich" items with full metadata.
|
|
86
|
+
- It merges results with the global vault list, ensuring organizational assignments are preserved.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## ๐น๏ธ Interface Modes
|
|
91
|
+
|
|
92
|
+
### 1. CLI Mode (Recommended for Humans & AI Agents) ๐
|
|
93
|
+
The CLI is the most efficient and agnostic way to interact with the appliance. It uses RPC 2.0 (JSON), supports exact examples, and provides rich help documentation.
|
|
94
|
+
|
|
95
|
+
**For AI Agents:** Using the CLI via `run_command` is more token-efficient than MCP and offers greater flexibility.
|
|
96
|
+
```bash
|
|
97
|
+
k-bw admin status # Health check
|
|
98
|
+
k-bw admin unlock # Create a 5-minute session lease
|
|
99
|
+
k-bw do list-items # Quick redacted scan
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
> [!TIP]
|
|
103
|
+
> **AI Integration**: To enable full AI recognition of these commands, copy the `.agents/skills/k-bw` directory to your global `~/.agents/skills/` or into a project-specific `.agents/skills/` directory.
|
|
104
|
+
|
|
105
|
+
### 2. MCP Mode (Standard Stdio)
|
|
106
|
+
Start the stdio server for standard MCP clients like Gemini, Claude, or Cursor.
|
|
107
|
+
```bash
|
|
108
|
+
k-bw mcp serve
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## ๐ ๏ธ Maintenance & Release
|
|
114
|
+
|
|
115
|
+
- **Update**: `curl ... | sudo bash` (re-runs the installer).
|
|
116
|
+
- **Uninstall**: `sudo ./uninstall.sh`.
|
|
117
|
+
- **Release (Dev)**: `make release` (automatic tagging and GHCR propulsion).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## โ๏ธ License
|
|
122
|
+
MIT License. See `LICENSE` for details.
|
|
123
|
+
|
|
124
|
+
Designed with โค๏ธ by **KpihX**.
|
kpihx_bw-4.0.0/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# ๐ k-bw โ Sovereign Bitwarden Appliance
|
|
2
|
+
|
|
3
|
+
> **Zero Trust ยท AI-Blind ยท ACID Durable**
|
|
4
|
+
> The authoritative appliance for Bitwarden organization vault control. Keep AI agents and LLMs blind to your real secrets while giving them full auditing and refactoring powers.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ๐๏ธ Project Architecture (Sovereign Tree)
|
|
9
|
+
|
|
10
|
+
```ascii
|
|
11
|
+
BW-PROXY PROJECT
|
|
12
|
+
โโโ ๐ src/k_bw/ โโโ Core Engine (ACID Transaction, WAL, Redaction)
|
|
13
|
+
โโโ ๐ scripts/ โโโ Host-side Shims (Dynamic porting, Browser HITL)
|
|
14
|
+
โโโ ๐ docs/ โโโ Deep-dive Hardening & Operator Guides
|
|
15
|
+
โโโ ๐ install.sh โโโ System-wide Appliance Installer (Root-owned)
|
|
16
|
+
โโโ ๐ Makefile โโโ Developer & Release Automator
|
|
17
|
+
โโโ ๐ Dockerfile โโโ Multi-stage Hardened Runtime
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ๐ Installation Modes
|
|
23
|
+
|
|
24
|
+
### A. Appliance Mode (Standard Pro)
|
|
25
|
+
Ideal for production use. Installs a root-owned binary and uses the official image.
|
|
26
|
+
|
|
27
|
+
**Via curl (Zero-Clone):**
|
|
28
|
+
```bash
|
|
29
|
+
curl -fsSL https://raw.githubusercontent.com/kpihx-labs/k-bw/main/install.sh | sudo bash
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**What it does internally:**
|
|
33
|
+
1. **Image**: Pulls `ghcr.io/kpihx-labs/k-bw:latest`.
|
|
34
|
+
2. **Binary**: Creates `/usr/local/bin/k-bw` (owned by root).
|
|
35
|
+
3. **Config**: Seeds `~/.config/k-bw/` (owned by the invoking user).
|
|
36
|
+
4. **Data**: Creates a persistent Docker volume `k-bw-data`.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### B. Developer Mode (Source Clone)
|
|
41
|
+
Ideal for contribution or source-level auditing.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/kpihx-labs/k-bw.git
|
|
45
|
+
cd k-bw
|
|
46
|
+
make docker-install # Requires SUDO for builds
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## โ๏ธ Core Mechanisms (The Magic)
|
|
52
|
+
|
|
53
|
+
### 1. The HITL Browser Flux
|
|
54
|
+
When an AI agent requests a vault change, the proxy intercepts the execution:
|
|
55
|
+
1. **Port Allocation**: The host shim finds a free random port.
|
|
56
|
+
2. **Container Launch**: The appliance starts, mapping the internal HITL server to that port.
|
|
57
|
+
3. **URL Interception**: The shim detects the Approval URL in stdout and **automatically opens your browser**.
|
|
58
|
+
4. **Human Approval**: You review the rationale and the diff, then approve with your Master Password.
|
|
59
|
+
|
|
60
|
+
### 2. The 3-Phase ACID Commit (WAL)
|
|
61
|
+
Every mutation is transactional.
|
|
62
|
+
- **Simulation**: Actions are validated in RAM first.
|
|
63
|
+
- **WAL**: Actions are encrypted and logged to disk *before* execution.
|
|
64
|
+
- **Commit**: Actions are sent to the Bitwarden CLI.
|
|
65
|
+
- **Rollback**: If a crash occurs, the proxy performs a LIFO rollback on the next start.
|
|
66
|
+
|
|
67
|
+
### 3. Scoped Union Fetch
|
|
68
|
+
To handle organizational vaults without metadata loss:
|
|
69
|
+
- The proxy discovers all accessible **Organizations** and **Collections** first.
|
|
70
|
+
- It then performs scoped queries (`--organizationid`) to fetch "rich" items with full metadata.
|
|
71
|
+
- It merges results with the global vault list, ensuring organizational assignments are preserved.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## ๐น๏ธ Interface Modes
|
|
76
|
+
|
|
77
|
+
### 1. CLI Mode (Recommended for Humans & AI Agents) ๐
|
|
78
|
+
The CLI is the most efficient and agnostic way to interact with the appliance. It uses RPC 2.0 (JSON), supports exact examples, and provides rich help documentation.
|
|
79
|
+
|
|
80
|
+
**For AI Agents:** Using the CLI via `run_command` is more token-efficient than MCP and offers greater flexibility.
|
|
81
|
+
```bash
|
|
82
|
+
k-bw admin status # Health check
|
|
83
|
+
k-bw admin unlock # Create a 5-minute session lease
|
|
84
|
+
k-bw do list-items # Quick redacted scan
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> [!TIP]
|
|
88
|
+
> **AI Integration**: To enable full AI recognition of these commands, copy the `.agents/skills/k-bw` directory to your global `~/.agents/skills/` or into a project-specific `.agents/skills/` directory.
|
|
89
|
+
|
|
90
|
+
### 2. MCP Mode (Standard Stdio)
|
|
91
|
+
Start the stdio server for standard MCP clients like Gemini, Claude, or Cursor.
|
|
92
|
+
```bash
|
|
93
|
+
k-bw mcp serve
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ๐ ๏ธ Maintenance & Release
|
|
99
|
+
|
|
100
|
+
- **Update**: `curl ... | sudo bash` (re-runs the installer).
|
|
101
|
+
- **Uninstall**: `sudo ./uninstall.sh`.
|
|
102
|
+
- **Release (Dev)**: `make release` (automatic tagging and GHCR propulsion).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## โ๏ธ License
|
|
107
|
+
MIT License. See `LICENSE` for details.
|
|
108
|
+
|
|
109
|
+
Designed with โค๏ธ by **KpihX**.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "kpihx-bw"
|
|
3
|
+
version = "4.0.0"
|
|
4
|
+
description = "A sovereign proxy acting as a security-hardened blind hub between LLMs and the Bitwarden CLI. Zero Trust ยท AI-Blind ยท ACID."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "KpihX", email = "kapoivha@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"mcp>=1.26.0",
|
|
12
|
+
"pydantic>=2.12.5",
|
|
13
|
+
"pyyaml>=6.0.3",
|
|
14
|
+
"rich>=14.3.3",
|
|
15
|
+
"typer>=0.12.0",
|
|
16
|
+
"cryptography>=44.0.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
k-bw = "k_bw.main:main"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["uv_build>=0.10.3,<0.11.0"]
|
|
24
|
+
build-backend = "uv_build"
|
|
25
|
+
|
|
26
|
+
[tool.uv.build-backend]
|
|
27
|
+
module-name = "k_bw"
|
|
28
|
+
|
|
29
|
+
[dependency-groups]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest>=9.0.2",
|
|
32
|
+
"pytest-cov>=7.0.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.pytest.ini_options]
|
|
36
|
+
testpaths = ["tests"]
|
|
37
|
+
python_files = ["test_*.py"]
|
|
File without changes
|