tigrbl-kms 0.0.1.dev1__py3-none-any.whl → 0.3.0.dev3__py3-none-any.whl

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.
tigrbl_kms/__init__.py CHANGED
@@ -1,14 +0,0 @@
1
- from .ExampleAgent import ExampleAgent as ExampleAgent
2
-
3
- __version__ = "0.6.0.dev26"
4
- __long_desc__ = """
5
-
6
- # Swarmauri Example Plugin
7
-
8
- This repository includes an example of a Swarmauri Plugin.
9
-
10
- Visit us at: https://swarmauri.com
11
- Follow us at: https://github.com/swarmauri
12
- Star us at: https://github.com/swarmauri/swarmauri-sdk
13
-
14
- """
tigrbl_kms/__main__.py ADDED
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import uvicorn
5
+
6
+
7
+ def main() -> None:
8
+ """Run the tigrbl_kms server using uvicorn."""
9
+ host = os.getenv("HOST", "0.0.0.0")
10
+ port = int(os.getenv("PORT", "8000"))
11
+ log_level = os.getenv("TIGRBL_KMS_LOG_LEVEL", "debug").lower()
12
+ uvicorn.run(
13
+ "tigrbl_kms.app:app",
14
+ host=host,
15
+ port=port,
16
+ log_level=log_level,
17
+ proxy_headers=True,
18
+ forwarded_allow_ips="*",
19
+ )
20
+
21
+
22
+ if __name__ == "__main__":
23
+ main()
tigrbl_kms/app.py ADDED
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+
5
+ from tigrbl import TigrblApp
6
+ from tigrbl.engine import engine as build_engine
7
+ from swarmauri_crypto_paramiko import ParamikoCrypto
8
+ from swarmauri_standard.key_providers import InMemoryKeyProvider
9
+ from .orm import Key, KeyVersion
10
+
11
+ DB_URL = os.getenv("KMS_DATABASE_URL", "sqlite+aiosqlite:///./kms.db")
12
+ ENGINE = build_engine(DB_URL)
13
+
14
+
15
+ # API-level hooks (v3): stash shared services into ctx before any handler runs
16
+ async def _stash_ctx(ctx):
17
+ global CRYPTO, KEY_PROVIDER
18
+ try:
19
+ CRYPTO
20
+ except NameError:
21
+ CRYPTO = ParamikoCrypto()
22
+ try:
23
+ KEY_PROVIDER
24
+ except NameError:
25
+ KEY_PROVIDER = InMemoryKeyProvider()
26
+ ctx["crypto"] = CRYPTO
27
+ ctx["key_provider"] = KEY_PROVIDER
28
+
29
+
30
+ app = TigrblApp(
31
+ title="Tigrbl-KMS",
32
+ version="0.1.0",
33
+ openapi_url="/openapi.json",
34
+ docs_url="/docs",
35
+ engine=ENGINE,
36
+ api_hooks={"*": {"PRE_TX_BEGIN": [_stash_ctx]}},
37
+ )
38
+
39
+
40
+ # Custom ops return raw dicts so no finalize hook needed
41
+ app.include_models([Key, KeyVersion], base_prefix="/kms")
42
+ app.mount_jsonrpc(prefix="/kms/rpc")
43
+ app.attach_diagnostics(prefix="/system")
44
+
45
+
46
+ # Initialize database tables on startup
47
+ @app.on_event("startup")
48
+ async def startup_event():
49
+ await app.initialize()
tigrbl_kms/cli.py ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python3
2
+ """Entry point for the TigrblKMS command-line interface."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import typer
7
+ import uvicorn
8
+
9
+
10
+ app = typer.Typer(help="CLI for TigrblKMS service")
11
+
12
+
13
+ @app.command()
14
+ def serve(
15
+ host: str = typer.Option("127.0.0.1", help="Bind host"),
16
+ port: int = typer.Option(8000, help="Bind port"),
17
+ reload: bool = typer.Option(True, help="Auto-reload on changes"),
18
+ ):
19
+ """Start the TigrblKMS FastAPI service via uvicorn."""
20
+ uvicorn.run(
21
+ "tigrbl_kms.app:app",
22
+ host=host,
23
+ port=port,
24
+ reload=reload,
25
+ factory=False,
26
+ )
27
+
28
+
29
+ if __name__ == "__main__":
30
+ app()
@@ -0,0 +1,4 @@
1
+ from .key import Key
2
+ from .key_version import KeyVersion
3
+
4
+ __all__ = ["Key", "KeyVersion"]