ghemud-agentkit 0.1.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.
Files changed (78) hide show
  1. ghemud_agentkit-0.1.0/.github/workflows/ci.yml +58 -0
  2. ghemud_agentkit-0.1.0/.github/workflows/release.yml +39 -0
  3. ghemud_agentkit-0.1.0/.gitignore +12 -0
  4. ghemud_agentkit-0.1.0/CHANGELOG.md +61 -0
  5. ghemud_agentkit-0.1.0/CITATION.cff +19 -0
  6. ghemud_agentkit-0.1.0/CODE_OF_CONDUCT.md +15 -0
  7. ghemud_agentkit-0.1.0/CONTRIBUTING.md +37 -0
  8. ghemud_agentkit-0.1.0/CREDITS.md +11 -0
  9. ghemud_agentkit-0.1.0/LICENSE +15 -0
  10. ghemud_agentkit-0.1.0/NOTICE +5 -0
  11. ghemud_agentkit-0.1.0/PKG-INFO +158 -0
  12. ghemud_agentkit-0.1.0/README.md +108 -0
  13. ghemud_agentkit-0.1.0/SECURITY.md +24 -0
  14. ghemud_agentkit-0.1.0/docs/agent-loop.md +118 -0
  15. ghemud_agentkit-0.1.0/docs/deployment.md +96 -0
  16. ghemud_agentkit-0.1.0/docs/policies.md +127 -0
  17. ghemud_agentkit-0.1.0/docs/providers.md +106 -0
  18. ghemud_agentkit-0.1.0/docs/quickstart.md +134 -0
  19. ghemud_agentkit-0.1.0/docs/security.md +98 -0
  20. ghemud_agentkit-0.1.0/docs/testing.md +140 -0
  21. ghemud_agentkit-0.1.0/examples/01_quickstart.py +66 -0
  22. ghemud_agentkit-0.1.0/examples/02_agent_loop.py +69 -0
  23. ghemud_agentkit-0.1.0/examples/03_permissions.py +85 -0
  24. ghemud_agentkit-0.1.0/examples/04_sandbox.py +103 -0
  25. ghemud_agentkit-0.1.0/pyproject.toml +129 -0
  26. ghemud_agentkit-0.1.0/src/ghemud_agentkit/__init__.py +156 -0
  27. ghemud_agentkit-0.1.0/src/ghemud_agentkit/__main__.py +6 -0
  28. ghemud_agentkit-0.1.0/src/ghemud_agentkit/_version.py +12 -0
  29. ghemud_agentkit-0.1.0/src/ghemud_agentkit/approvals.py +498 -0
  30. ghemud_agentkit-0.1.0/src/ghemud_agentkit/audit.py +329 -0
  31. ghemud_agentkit-0.1.0/src/ghemud_agentkit/budgets.py +196 -0
  32. ghemud_agentkit-0.1.0/src/ghemud_agentkit/capabilities.py +96 -0
  33. ghemud_agentkit-0.1.0/src/ghemud_agentkit/cli/__init__.py +0 -0
  34. ghemud_agentkit-0.1.0/src/ghemud_agentkit/cli/main.py +392 -0
  35. ghemud_agentkit-0.1.0/src/ghemud_agentkit/concurrency.py +221 -0
  36. ghemud_agentkit-0.1.0/src/ghemud_agentkit/errors.py +218 -0
  37. ghemud_agentkit-0.1.0/src/ghemud_agentkit/events.py +275 -0
  38. ghemud_agentkit-0.1.0/src/ghemud_agentkit/interop/__init__.py +10 -0
  39. ghemud_agentkit-0.1.0/src/ghemud_agentkit/interop/mcp.py +187 -0
  40. ghemud_agentkit-0.1.0/src/ghemud_agentkit/lifecycle.py +242 -0
  41. ghemud_agentkit-0.1.0/src/ghemud_agentkit/loop.py +456 -0
  42. ghemud_agentkit-0.1.0/src/ghemud_agentkit/middleware.py +127 -0
  43. ghemud_agentkit-0.1.0/src/ghemud_agentkit/models/__init__.py +37 -0
  44. ghemud_agentkit-0.1.0/src/ghemud_agentkit/models/base.py +201 -0
  45. ghemud_agentkit-0.1.0/src/ghemud_agentkit/models/fake.py +172 -0
  46. ghemud_agentkit-0.1.0/src/ghemud_agentkit/models/openai_adapter.py +160 -0
  47. ghemud_agentkit-0.1.0/src/ghemud_agentkit/permissions.py +371 -0
  48. ghemud_agentkit-0.1.0/src/ghemud_agentkit/py.typed +1 -0
  49. ghemud_agentkit-0.1.0/src/ghemud_agentkit/registry.py +300 -0
  50. ghemud_agentkit-0.1.0/src/ghemud_agentkit/resilience.py +249 -0
  51. ghemud_agentkit-0.1.0/src/ghemud_agentkit/results.py +315 -0
  52. ghemud_agentkit-0.1.0/src/ghemud_agentkit/runtime.py +1158 -0
  53. ghemud_agentkit-0.1.0/src/ghemud_agentkit/sandbox.py +250 -0
  54. ghemud_agentkit-0.1.0/src/ghemud_agentkit/schema/__init__.py +39 -0
  55. ghemud_agentkit-0.1.0/src/ghemud_agentkit/schema/generation.py +541 -0
  56. ghemud_agentkit-0.1.0/src/ghemud_agentkit/schema/redaction.py +170 -0
  57. ghemud_agentkit-0.1.0/src/ghemud_agentkit/schema/validation.py +446 -0
  58. ghemud_agentkit-0.1.0/src/ghemud_agentkit/security.py +151 -0
  59. ghemud_agentkit-0.1.0/src/ghemud_agentkit/state.py +140 -0
  60. ghemud_agentkit-0.1.0/src/ghemud_agentkit/tools/__init__.py +30 -0
  61. ghemud_agentkit-0.1.0/src/ghemud_agentkit/tools/base.py +400 -0
  62. ghemud_agentkit-0.1.0/src/ghemud_agentkit/tools/builtin.py +263 -0
  63. ghemud_agentkit-0.1.0/src/ghemud_agentkit/tools/decorator.py +357 -0
  64. ghemud_agentkit-0.1.0/src/ghemud_agentkit/tracing.py +206 -0
  65. ghemud_agentkit-0.1.0/tests/conftest.py +87 -0
  66. ghemud_agentkit-0.1.0/tests/integration/test_agent_loop.py +337 -0
  67. ghemud_agentkit-0.1.0/tests/integration/test_builtin_tools.py +198 -0
  68. ghemud_agentkit-0.1.0/tests/security/test_adversarial_inputs.py +465 -0
  69. ghemud_agentkit-0.1.0/tests/unit/test_cli.py +175 -0
  70. ghemud_agentkit-0.1.0/tests/unit/test_enhancements.py +463 -0
  71. ghemud_agentkit-0.1.0/tests/unit/test_interop.py +101 -0
  72. ghemud_agentkit-0.1.0/tests/unit/test_lifecycle_results_events.py +565 -0
  73. ghemud_agentkit-0.1.0/tests/unit/test_redaction.py +92 -0
  74. ghemud_agentkit-0.1.0/tests/unit/test_resilience_concurrency_state.py +284 -0
  75. ghemud_agentkit-0.1.0/tests/unit/test_runtime.py +445 -0
  76. ghemud_agentkit-0.1.0/tests/unit/test_schema_generation.py +184 -0
  77. ghemud_agentkit-0.1.0/tests/unit/test_schema_validation.py +203 -0
  78. ghemud_agentkit-0.1.0/tests/unit/test_tools_and_registry.py +239 -0
@@ -0,0 +1,58 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install ruff
17
+ - run: ruff check src tests examples
18
+ - run: ruff format --check src tests examples
19
+
20
+ typecheck:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v5
25
+ with:
26
+ python-version: "3.12"
27
+ - run: pip install -e ".[dev]"
28
+ - run: mypy src/ghemud_agentkit
29
+
30
+ test:
31
+ runs-on: ubuntu-latest
32
+ strategy:
33
+ matrix:
34
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+ - uses: actions/setup-python@v5
38
+ with:
39
+ python-version: ${{ matrix.python-version }}
40
+ - run: pip install -e ".[dev]"
41
+ - run: pytest -q --cov=ghemud_agentkit --cov-report=term-missing
42
+ - run: pytest -m security -q # explicit adversarial gate
43
+
44
+ build:
45
+ runs-on: ubuntu-latest
46
+ needs: [lint, typecheck, test]
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - uses: actions/setup-python@v5
50
+ with:
51
+ python-version: "3.12"
52
+ - run: pip install build twine
53
+ - run: python -m build
54
+ - run: twine check dist/*
55
+ - uses: actions/upload-artifact@v4
56
+ with:
57
+ name: dist
58
+ path: dist/
@@ -0,0 +1,39 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ publish-testpypi:
9
+ runs-on: ubuntu-latest
10
+ environment: testpypi
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install build twine
17
+ - run: python -m build
18
+ - run: twine check dist/*
19
+ - run: twine upload --repository testpypi dist/*
20
+ env:
21
+ TWINE_USERNAME: __token__
22
+ TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
23
+
24
+ publish-pypi:
25
+ runs-on: ubuntu-latest
26
+ needs: publish-testpypi
27
+ environment: pypi
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+ - run: pip install build twine
34
+ - run: python -m build
35
+ - run: twine check dist/*
36
+ - run: twine upload dist/*
37
+ env:
38
+ TWINE_USERNAME: __token__
39
+ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ coverage.xml
12
+ *.log
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ All notable changes to Ghemud AgentKit are documented in this file. The project follows semantic versioning.
4
+
5
+ ## 0.1.0 (2026-08-23)
6
+
7
+ First public release by **Yashraj Sachin Ghemud**.
8
+
9
+ ### Core
10
+ - `@tool` decorator + class-based Tool API with schema inference from type
11
+ hints (primitives, Literal/Enum, containers, dataclasses, optional pydantic);
12
+ fail-closed on unsupported annotations.
13
+ - Deterministic JSON Schema generation with canonical serialization and
14
+ schema digests (discovery == enforcement, provable).
15
+ - Built-in zero-dependency argument validator: closed schemas, size/depth/
16
+ item/string limits, NaN/Infinity rejection, JSON-pointer error paths.
17
+ - Registry: namespaced, composite (first-match + conflict detection),
18
+ immutable snapshots, capability discovery, risk-filtered discovery docs.
19
+ - Invocation lifecycle state machine with validated transitions and
20
+ structured events under stable, time-sortable invocation IDs.
21
+
22
+ ### Security
23
+ - Capability-based permission policies (allow/deny/approval, risk tiers,
24
+ most-restrictive-wins composition, JSON policy files + CLI validation).
25
+ - Human approval flow with TTL'd requests AND TTL'd decisions; auto-deny
26
+ for non-interactive runtimes; provider interface (console/callback/static).
27
+ - Mandatory emission-time secret redaction (name heuristics + declarations +
28
+ value-shape scanning) across events, audit, results, and error messages.
29
+ - Tamper-evident hash-chained audit trail with optional HMAC signing,
30
+ JSONL file sink, and chain verification.
31
+ - Security test suite: prompt-injection args, type confusion, path traversal
32
+ (incl. symlink), command injection, secret exfiltration, oversized
33
+ payloads, budget bypass, retry-resurrection of denied calls.
34
+ - PathGuard jail, safe AST math evaluator, secret-shape result scanning.
35
+ - Sandbox boundary: `SandboxExecutor` interface + `SubprocessSandboxExecutor`
36
+ (hard timeout kills, process-group kill) with documented trust boundary.
37
+
38
+ ### Runtime
39
+ - Full pipeline: lookup → validate → authorize → middleware → approve →
40
+ reserve → execute → normalize → audit.
41
+ - Bounded exponential backoff with full jitter; retries only for
42
+ idempotent/retryable tools; failure classification.
43
+ - Time/cost/tool-call budgets with atomic reserve/commit/release.
44
+ - Per-tool + global concurrency limits; token-bucket rate limits.
45
+ - Graceful shutdown with drain reporting (nothing silently abandoned).
46
+ - Middleware hooks (before/after, onion ordering, veto → denial flow).
47
+
48
+ ### Agents
49
+ - Provider-neutral model interface; deterministic Scripted/Static/Flaky
50
+ fake models; OpenAI adapter (optional extra).
51
+ - Agent loop: parallel tool calls, deterministic result ordering, eight
52
+ explicit stop conditions, cancellation racing model calls.
53
+ - Streaming tool results as an extension (async iterators aggregate for
54
+ non-streaming consumers; `run_stream` for streaming consumers).
55
+
56
+ ### Tooling
57
+ - CLI: list / inspect / validate-policy / run (+ --dry-run) / trace / replay
58
+ / doctor. `run` always applies the full pipeline.
59
+ - MCP interop adapter (optional extra) with schema consistency via
60
+ discovery-document digests.
61
+ - Trace recording + replay (JSONL, redacted at emission).
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use Ghemud AgentKit in research or software, please cite it using this metadata."
3
+ title: "Ghemud AgentKit"
4
+ abstract: "A secure, provider-agnostic Python runtime for AI agent tool execution with policies, budgets, approvals, and audit trails."
5
+ type: software
6
+ authors:
7
+ - family-names: Ghemud
8
+ given-names: Yashraj Sachin
9
+ repository-code: "https://github.com/yashraj-ghemud/ghemud-agentkit"
10
+ url: "https://github.com/yashraj-ghemud/ghemud-agentkit"
11
+ license: Apache-2.0
12
+ version: 0.1.0
13
+ date-released: 2026-08-23
14
+ keywords:
15
+ - AI agents
16
+ - agent runtime
17
+ - Python
18
+ - security
19
+ - tool calling
@@ -0,0 +1,15 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our pledge
4
+
5
+ We pledge to make participation in the Ghemud AgentKit community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity or expression, experience level, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our standards
8
+
9
+ Constructive collaboration, respectful disagreement, and empathy are expected. Harassment, discriminatory language, personal attacks, intimidation, and publication of private information without permission are not acceptable.
10
+
11
+ ## Enforcement
12
+
13
+ Report unacceptable behavior privately through the repository’s security contact channel. Reports will be reviewed fairly and, where appropriate, may lead to correction, warning, temporary restriction, or removal from community spaces.
14
+
15
+ This policy is adapted from the Contributor Covenant, version 2.1.
@@ -0,0 +1,37 @@
1
+ # Contributing to Ghemud AgentKit
2
+
3
+ Thanks for helping build a safer tool runtime for agents. Ghemud AgentKit was created and is maintained by **Yashraj Sachin Ghemud**.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/yashraj-ghemud/ghemud-agentkit.git && cd ghemud-agentkit
9
+ pip install -e ".[dev]"
10
+ make test
11
+ ```
12
+
13
+ ## Ground rules
14
+
15
+ 1. **The pipeline is the product.** Features that bypass validation, policy,
16
+ or audit are not features — they're vulnerabilities. Every PR that adds a
17
+ capability must state its security boundary in the PR description.
18
+ 2. **Tests first for security behavior.** New guard? Negative test. New tool
19
+ declaration? Validation test. New event? Assert it carries the stable
20
+ invocation ID.
21
+ 3. **Model output is untrusted.** Any code path that consumes model-produced
22
+ fields must validate first. `tests/security/` is the pattern book.
23
+ 4. **No secrets in telemetry, ever.** Events/audit/results pass through the
24
+ redaction pipeline at emission time. There is no opt-out, and PRs adding
25
+ one will be closed.
26
+ 5. **Optional dependencies stay optional.** Core imports must never require
27
+ extras; guard imports and raise `InteroperabilityError` with install
28
+ instructions.
29
+ 6. **Zero required dependencies in core.** Adding one requires a design
30
+ doc explaining why wrapping/integrating is insufficient.
31
+
32
+ ## Checklist
33
+
34
+ - [ ] `make lint && make typecheck && make test && make security`
35
+ - [ ] Docstrings on all public APIs (type hints are mandatory)
36
+ - [ ] `CHANGELOG.md` entry
37
+ - [ ] Docs updated if behavior changed
@@ -0,0 +1,11 @@
1
+ # Credits
2
+
3
+ ## Creator and maintainer
4
+
5
+ **Ghemud AgentKit** was created and is maintained by **Yashraj Sachin Ghemud**.
6
+
7
+ The project’s design centers on secure, provider-agnostic execution for Python AI-agent tools. Its public documentation, distribution metadata, release process, and repository stewardship are credited to Yashraj Sachin Ghemud.
8
+
9
+ ## Acknowledgements
10
+
11
+ Ghemud AgentKit is released as open-source software under the Apache License 2.0. Contributions from the community are welcome and will be acknowledged through GitHub’s contributor history and release notes.
@@ -0,0 +1,15 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Ghemud AgentKit
2
+ Copyright 2026 Yashraj Sachin Ghemud
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.5
2
+ Name: ghemud-agentkit
3
+ Version: 0.1.0
4
+ Summary: A secure, provider-agnostic Python runtime for AI agent tool execution with policies, budgets, approvals, and audit trails.
5
+ Project-URL: Homepage, https://github.com/yashraj-ghemud/ghemud-agentkit
6
+ Project-URL: Documentation, https://github.com/yashraj-ghemud/ghemud-agentkit/tree/main/docs
7
+ Project-URL: Changelog, https://github.com/yashraj-ghemud/ghemud-agentkit/blob/main/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/yashraj-ghemud/ghemud-agentkit/issues
9
+ Project-URL: Source, https://github.com/yashraj-ghemud/ghemud-agentkit
10
+ Author: Yashraj Sachin Ghemud
11
+ Maintainer: Yashraj Sachin Ghemud
12
+ License: Apache-2.0
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Keywords: agent runtime,agent security,agentic ai,ai agents,artificial intelligence,llm tools,model context protocol,python ai framework,secure tool calling,tool orchestration
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: License :: OSI Approved :: Apache Software License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Software Development :: Testing
29
+ Classifier: Typing :: Typed
30
+ Requires-Python: >=3.10
31
+ Provides-Extra: dev
32
+ Requires-Dist: build>=1.2; extra == 'dev'
33
+ Requires-Dist: jsonschema>=4.19; extra == 'dev'
34
+ Requires-Dist: mypy>=1.10; extra == 'dev'
35
+ Requires-Dist: pydantic>=2.5; extra == 'dev'
36
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
37
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
38
+ Requires-Dist: pytest>=8.0; extra == 'dev'
39
+ Requires-Dist: ruff>=0.5; extra == 'dev'
40
+ Requires-Dist: twine>=6.0; extra == 'dev'
41
+ Provides-Extra: jsonschema
42
+ Requires-Dist: jsonschema>=4.19; extra == 'jsonschema'
43
+ Provides-Extra: mcp
44
+ Requires-Dist: mcp>=1.0; extra == 'mcp'
45
+ Provides-Extra: openai
46
+ Requires-Dist: openai>=1.30; extra == 'openai'
47
+ Provides-Extra: pydantic
48
+ Requires-Dist: pydantic>=2.5; extra == 'pydantic'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # Ghemud AgentKit
52
+
53
+ **A secure, provider-agnostic runtime for AI agents to discover and execute tools — with explicit permissions, budgets, retries, approvals, and a tamper-evident audit trail.**
54
+
55
+ Created and maintained by **Yashraj Sachin Ghemud**, Ghemud AgentKit is the **runtime boundary between an AI agent decision and a real-world side effect**. It validates model output as untrusted input, checks capabilities before execution, and records an observable, bounded, auditable invocation lifecycle.
56
+
57
+ > **Built for Python developers who need secure AI-agent tool execution.** Ghemud AgentKit brings permissions, approvals, budgets, retries, redaction, and auditability into a provider-agnostic runtime.
58
+
59
+ ```python
60
+ from ghemud_agentkit import ToolRegistry, ToolRuntime, tool
61
+
62
+ @tool(description="Add two integers")
63
+ def add(a: int, b: int) -> int:
64
+ """Add a and b."""
65
+ return a + b
66
+
67
+ registry = ToolRegistry()
68
+ registry.register(add)
69
+ runtime = ToolRuntime(registry) # conservative defaults
70
+
71
+ result = await runtime.run("add", {"a": 2, "b": 3})
72
+ assert result.content == 5
73
+ ```
74
+
75
+ ## Why Ghemud AgentKit
76
+
77
+ | Without a runtime boundary | With Ghemud AgentKit |
78
+ |---|---|
79
+ | Model output trusted as function calls | Model output validated against JSON Schema with size/depth limits |
80
+ | "The agent has access to everything" | Capability-based permissions: allow / deny / human-approval, evaluated **before** side effects |
81
+ | Unbounded tool loops | Time, cost, and tool-call budgets with atomic reservation |
82
+ | Secrets sprayed through logs | Mandatory redaction in every event, audit record, and model-visible result |
83
+ | No answer to "who approved what, when" | Hash-chained (optionally HMAC-signed) audit trail |
84
+ | Untestable without a provider API key | Deterministic fake models; zero network in the entire test suite |
85
+
86
+ ## The 30-second tour
87
+
88
+ ```python
89
+ import asyncio
90
+ from ghemud_agentkit import (
91
+ AgentLoop, LoopConfig, ScriptedModel,
92
+ ToolRegistry, ToolRuntime, tool,
93
+ )
94
+ from ghemud_agentkit.models import tool_call, text_response
95
+
96
+ registry = ToolRegistry()
97
+ # ... register tools ...
98
+
99
+ runtime = ToolRuntime(registry)
100
+
101
+ # Deterministic loop with a scripted model (no API key, no network):
102
+ model = ScriptedModel([
103
+ tool_call("add", {"a": 19, "b": 23}), # 1) model calls a tool
104
+ text_response("19 + 23 = 42"), # 2) model answers
105
+ ])
106
+ loop = AgentLoop(model, runtime, config=LoopConfig(max_iterations=5))
107
+ result = asyncio.run(loop.run("what is 19+23?"))
108
+ print(result.final_text) # -> "19 + 23 = 42"
109
+ print(result.stop_reason) # -> StopReason.COMPLETED
110
+ ```
111
+
112
+ Swap `ScriptedModel` for the OpenAI adapter (`pip install "ghemud-agentkit[openai]"`) and the same loop, policies, budgets, and audit trail run against a real provider.
113
+
114
+ ## What's in the box
115
+
116
+ - **Tool API** — `@tool` decorator with schema inference from type hints (dataclasses, pydantic, `Literal`, enums, containers); sync and async tools; injected `ctx: ToolContext` for cancellation, state, and deadlines.
117
+ - **Registries** — namespaced, composite (first-match-wins with conflict detection), immutable snapshots, capability discovery.
118
+ - **Invocation lifecycle** — validated state machine (`requested → validated → authorized → [approval] → queued → running → terminal`) with structured events at every transition under one stable invocation ID.
119
+ - **Permissions** — capability-based policies with deny > approval > allow precedence, risk tiers, and a conservative `DefaultPolicy`.
120
+ - **Human approval** — TTL'd approval requests *and* TTL'd decisions; auto-deny for non-interactive environments; pluggable providers (console, callback, static).
121
+ - **Resilience** — bounded exponential backoff with jitter; retries only for idempotent/retryable tools; failure classification (validation/policy/approval/timeout/transient/application/…).
122
+ - **Budgets** — time, cost, and tool-call ceilings with atomic reserve/commit/release; budget state never leaks into error messages.
123
+ - **Observability** — typed event bus, in-memory collectors, mandatory secret redaction, debug events opt-in.
124
+ - **Audit** — hash-chained records (args digested from the *redacted* view), optional HMAC signing, JSONL file sink, chain verification API.
125
+ - **Agent loop** — model ↔ tools alternation with parallel tool calls, deterministic ordering, and eight explicit stop conditions.
126
+ - **CLI** — `list`, `inspect`, `validate-policy`, `run --dry-run`, `trace`.
127
+ - **Interop** — MCP adapter (optional extra); discovery schemas are byte-identical to enforcement schemas.
128
+
129
+ ## Installation
130
+
131
+ ```bash
132
+ pip install ghemud-agentkit # core, zero required dependencies
133
+ pip install "ghemud-agentkit[openai]" # + OpenAI adapter
134
+ pip install "ghemud-agentkit[mcp]" # + MCP interop
135
+ ```
136
+
137
+ Python 3.10+ · Apache-2.0.
138
+
139
+ ## Documentation
140
+
141
+ - [Quick start](docs/quickstart.md) — deterministic local tools in 5 minutes
142
+ - [Agent loop tutorial](docs/agent-loop.md) — budgets, parallel calls, stop conditions
143
+ - [Security model](docs/security.md) — trust boundaries and the permission system
144
+ - [Permission policy guide](docs/policies.md) — rules, tiers, composition
145
+ - [Provider adapters](docs/providers.md) — fake models, OpenAI, writing your own
146
+ - [Testing guide](docs/testing.md) — deterministic agent tests without network
147
+ - [What Ghemud AgentKit does NOT guarantee](docs/security.md#what-ghemud_agentkit-does-not-guarantee) — read this before production
148
+
149
+ ## Compatibility policy
150
+
151
+ Semantic versioning. The public API is `from ghemud_agentkit import ...` plus stable submodules; anything documented in this README is covered. Internals (underscore-prefixed modules and names) may change at any patch release.
152
+
153
+ ## Author, citation, and contribution
154
+
155
+ Ghemud AgentKit was created by **Yashraj Sachin Ghemud**. Use the metadata in [CITATION.cff](CITATION.cff) when citing this software, review [CREDITS.md](CREDITS.md) for project attribution, and see [CONTRIBUTING.md](CONTRIBUTING.md), [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md), and [SECURITY.md](SECURITY.md) before participating or reporting a vulnerability.
156
+
157
+ ---
158
+ *Ghemud AgentKit treats model output as adversarial input even when the application trusts the model. If you remember one thing about this library, remember that.*
@@ -0,0 +1,108 @@
1
+ # Ghemud AgentKit
2
+
3
+ **A secure, provider-agnostic runtime for AI agents to discover and execute tools — with explicit permissions, budgets, retries, approvals, and a tamper-evident audit trail.**
4
+
5
+ Created and maintained by **Yashraj Sachin Ghemud**, Ghemud AgentKit is the **runtime boundary between an AI agent decision and a real-world side effect**. It validates model output as untrusted input, checks capabilities before execution, and records an observable, bounded, auditable invocation lifecycle.
6
+
7
+ > **Built for Python developers who need secure AI-agent tool execution.** Ghemud AgentKit brings permissions, approvals, budgets, retries, redaction, and auditability into a provider-agnostic runtime.
8
+
9
+ ```python
10
+ from ghemud_agentkit import ToolRegistry, ToolRuntime, tool
11
+
12
+ @tool(description="Add two integers")
13
+ def add(a: int, b: int) -> int:
14
+ """Add a and b."""
15
+ return a + b
16
+
17
+ registry = ToolRegistry()
18
+ registry.register(add)
19
+ runtime = ToolRuntime(registry) # conservative defaults
20
+
21
+ result = await runtime.run("add", {"a": 2, "b": 3})
22
+ assert result.content == 5
23
+ ```
24
+
25
+ ## Why Ghemud AgentKit
26
+
27
+ | Without a runtime boundary | With Ghemud AgentKit |
28
+ |---|---|
29
+ | Model output trusted as function calls | Model output validated against JSON Schema with size/depth limits |
30
+ | "The agent has access to everything" | Capability-based permissions: allow / deny / human-approval, evaluated **before** side effects |
31
+ | Unbounded tool loops | Time, cost, and tool-call budgets with atomic reservation |
32
+ | Secrets sprayed through logs | Mandatory redaction in every event, audit record, and model-visible result |
33
+ | No answer to "who approved what, when" | Hash-chained (optionally HMAC-signed) audit trail |
34
+ | Untestable without a provider API key | Deterministic fake models; zero network in the entire test suite |
35
+
36
+ ## The 30-second tour
37
+
38
+ ```python
39
+ import asyncio
40
+ from ghemud_agentkit import (
41
+ AgentLoop, LoopConfig, ScriptedModel,
42
+ ToolRegistry, ToolRuntime, tool,
43
+ )
44
+ from ghemud_agentkit.models import tool_call, text_response
45
+
46
+ registry = ToolRegistry()
47
+ # ... register tools ...
48
+
49
+ runtime = ToolRuntime(registry)
50
+
51
+ # Deterministic loop with a scripted model (no API key, no network):
52
+ model = ScriptedModel([
53
+ tool_call("add", {"a": 19, "b": 23}), # 1) model calls a tool
54
+ text_response("19 + 23 = 42"), # 2) model answers
55
+ ])
56
+ loop = AgentLoop(model, runtime, config=LoopConfig(max_iterations=5))
57
+ result = asyncio.run(loop.run("what is 19+23?"))
58
+ print(result.final_text) # -> "19 + 23 = 42"
59
+ print(result.stop_reason) # -> StopReason.COMPLETED
60
+ ```
61
+
62
+ Swap `ScriptedModel` for the OpenAI adapter (`pip install "ghemud-agentkit[openai]"`) and the same loop, policies, budgets, and audit trail run against a real provider.
63
+
64
+ ## What's in the box
65
+
66
+ - **Tool API** — `@tool` decorator with schema inference from type hints (dataclasses, pydantic, `Literal`, enums, containers); sync and async tools; injected `ctx: ToolContext` for cancellation, state, and deadlines.
67
+ - **Registries** — namespaced, composite (first-match-wins with conflict detection), immutable snapshots, capability discovery.
68
+ - **Invocation lifecycle** — validated state machine (`requested → validated → authorized → [approval] → queued → running → terminal`) with structured events at every transition under one stable invocation ID.
69
+ - **Permissions** — capability-based policies with deny > approval > allow precedence, risk tiers, and a conservative `DefaultPolicy`.
70
+ - **Human approval** — TTL'd approval requests *and* TTL'd decisions; auto-deny for non-interactive environments; pluggable providers (console, callback, static).
71
+ - **Resilience** — bounded exponential backoff with jitter; retries only for idempotent/retryable tools; failure classification (validation/policy/approval/timeout/transient/application/…).
72
+ - **Budgets** — time, cost, and tool-call ceilings with atomic reserve/commit/release; budget state never leaks into error messages.
73
+ - **Observability** — typed event bus, in-memory collectors, mandatory secret redaction, debug events opt-in.
74
+ - **Audit** — hash-chained records (args digested from the *redacted* view), optional HMAC signing, JSONL file sink, chain verification API.
75
+ - **Agent loop** — model ↔ tools alternation with parallel tool calls, deterministic ordering, and eight explicit stop conditions.
76
+ - **CLI** — `list`, `inspect`, `validate-policy`, `run --dry-run`, `trace`.
77
+ - **Interop** — MCP adapter (optional extra); discovery schemas are byte-identical to enforcement schemas.
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install ghemud-agentkit # core, zero required dependencies
83
+ pip install "ghemud-agentkit[openai]" # + OpenAI adapter
84
+ pip install "ghemud-agentkit[mcp]" # + MCP interop
85
+ ```
86
+
87
+ Python 3.10+ · Apache-2.0.
88
+
89
+ ## Documentation
90
+
91
+ - [Quick start](docs/quickstart.md) — deterministic local tools in 5 minutes
92
+ - [Agent loop tutorial](docs/agent-loop.md) — budgets, parallel calls, stop conditions
93
+ - [Security model](docs/security.md) — trust boundaries and the permission system
94
+ - [Permission policy guide](docs/policies.md) — rules, tiers, composition
95
+ - [Provider adapters](docs/providers.md) — fake models, OpenAI, writing your own
96
+ - [Testing guide](docs/testing.md) — deterministic agent tests without network
97
+ - [What Ghemud AgentKit does NOT guarantee](docs/security.md#what-ghemud_agentkit-does-not-guarantee) — read this before production
98
+
99
+ ## Compatibility policy
100
+
101
+ Semantic versioning. The public API is `from ghemud_agentkit import ...` plus stable submodules; anything documented in this README is covered. Internals (underscore-prefixed modules and names) may change at any patch release.
102
+
103
+ ## Author, citation, and contribution
104
+
105
+ Ghemud AgentKit was created by **Yashraj Sachin Ghemud**. Use the metadata in [CITATION.cff](CITATION.cff) when citing this software, review [CREDITS.md](CREDITS.md) for project attribution, and see [CONTRIBUTING.md](CONTRIBUTING.md), [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md), and [SECURITY.md](SECURITY.md) before participating or reporting a vulnerability.
106
+
107
+ ---
108
+ *Ghemud AgentKit treats model output as adversarial input even when the application trusts the model. If you remember one thing about this library, remember that.*
@@ -0,0 +1,24 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Only the latest published release receives security fixes.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Do not open a public issue for a suspected vulnerability. Instead, use the
10
+ repository's private security-advisory workflow and include a minimal
11
+ reproduction, affected version, and impact assessment. Do not include secrets,
12
+ access tokens, or private data.
13
+
14
+ Yashraj Sachin Ghemud will assess valid reports and coordinate a fix or mitigation.
15
+
16
+ ## Scope
17
+
18
+ In scope: the Ghemud AgentKit runtime, schema generation/validation, permission
19
+ system, approval flow, audit trail, and adapters shipped in this repository.
20
+
21
+ Out of scope: vulnerabilities in provider SDKs, model alignment behavior,
22
+ and deployments that disable documented safeguards. Ghemud AgentKit is an
23
+ application-layer control and does not replace operating-system isolation,
24
+ secret management, identity and access management, or network controls.