agent-loop-guard-runtime 0.6.0a2__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 (81) hide show
  1. agent_loop_guard_runtime-0.6.0a2/LICENSE +202 -0
  2. agent_loop_guard_runtime-0.6.0a2/PKG-INFO +407 -0
  3. agent_loop_guard_runtime-0.6.0a2/README.md +362 -0
  4. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/PKG-INFO +407 -0
  5. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/SOURCES.txt +79 -0
  6. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/dependency_links.txt +1 -0
  7. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/entry_points.txt +2 -0
  8. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/requires.txt +28 -0
  9. agent_loop_guard_runtime-0.6.0a2/agent_loop_guard_runtime.egg-info/top_level.txt +1 -0
  10. agent_loop_guard_runtime-0.6.0a2/app/__init__.py +6 -0
  11. agent_loop_guard_runtime-0.6.0a2/app/api/__init__.py +1 -0
  12. agent_loop_guard_runtime-0.6.0a2/app/api/admin_routes.py +179 -0
  13. agent_loop_guard_runtime-0.6.0a2/app/api/anthropic_routes.py +21 -0
  14. agent_loop_guard_runtime-0.6.0a2/app/api/common.py +457 -0
  15. agent_loop_guard_runtime-0.6.0a2/app/api/mcp_routes.py +218 -0
  16. agent_loop_guard_runtime-0.6.0a2/app/api/openai_routes.py +26 -0
  17. agent_loop_guard_runtime-0.6.0a2/app/api/replay_routes.py +202 -0
  18. agent_loop_guard_runtime-0.6.0a2/app/api/ui_routes.py +295 -0
  19. agent_loop_guard_runtime-0.6.0a2/app/benchmark/__init__.py +2 -0
  20. agent_loop_guard_runtime-0.6.0a2/app/benchmark/adapters.py +97 -0
  21. agent_loop_guard_runtime-0.6.0a2/app/benchmark/data/starter-v1.json +38 -0
  22. agent_loop_guard_runtime-0.6.0a2/app/benchmark/dataset.py +59 -0
  23. agent_loop_guard_runtime-0.6.0a2/app/benchmark/models.py +46 -0
  24. agent_loop_guard_runtime-0.6.0a2/app/benchmark/runner.py +63 -0
  25. agent_loop_guard_runtime-0.6.0a2/app/benchmark/scorers.py +34 -0
  26. agent_loop_guard_runtime-0.6.0a2/app/benchmark/statistics.py +48 -0
  27. agent_loop_guard_runtime-0.6.0a2/app/benchmark/storage.py +78 -0
  28. agent_loop_guard_runtime-0.6.0a2/app/cli.py +624 -0
  29. agent_loop_guard_runtime-0.6.0a2/app/core/config.py +196 -0
  30. agent_loop_guard_runtime-0.6.0a2/app/core/demo.py +109 -0
  31. agent_loop_guard_runtime-0.6.0a2/app/core/loop_detector.py +120 -0
  32. agent_loop_guard_runtime-0.6.0a2/app/core/policy_engine.py +167 -0
  33. agent_loop_guard_runtime-0.6.0a2/app/core/redaction.py +84 -0
  34. agent_loop_guard_runtime-0.6.0a2/app/core/security.py +54 -0
  35. agent_loop_guard_runtime-0.6.0a2/app/core/token_meter.py +67 -0
  36. agent_loop_guard_runtime-0.6.0a2/app/db/models.py +296 -0
  37. agent_loop_guard_runtime-0.6.0a2/app/db/repository.py +1488 -0
  38. agent_loop_guard_runtime-0.6.0a2/app/db/session.py +57 -0
  39. agent_loop_guard_runtime-0.6.0a2/app/main.py +59 -0
  40. agent_loop_guard_runtime-0.6.0a2/app/mcp/__init__.py +1 -0
  41. agent_loop_guard_runtime-0.6.0a2/app/mcp/gateway.py +230 -0
  42. agent_loop_guard_runtime-0.6.0a2/app/mcp/policy.py +281 -0
  43. agent_loop_guard_runtime-0.6.0a2/app/mcp/presets/development.yml +25 -0
  44. agent_loop_guard_runtime-0.6.0a2/app/mcp/presets/filesystem.yml +18 -0
  45. agent_loop_guard_runtime-0.6.0a2/app/mcp/stdio.py +142 -0
  46. agent_loop_guard_runtime-0.6.0a2/app/platform/__init__.py +1 -0
  47. agent_loop_guard_runtime-0.6.0a2/app/platform/alembic/__init__.py +2 -0
  48. agent_loop_guard_runtime-0.6.0a2/app/platform/alembic/env.py +38 -0
  49. agent_loop_guard_runtime-0.6.0a2/app/platform/alembic/script.py.mako +24 -0
  50. agent_loop_guard_runtime-0.6.0a2/app/platform/alembic/versions/0001_initial_schema.py +18 -0
  51. agent_loop_guard_runtime-0.6.0a2/app/platform/alembic/versions/__init__.py +2 -0
  52. agent_loop_guard_runtime-0.6.0a2/app/platform/events.py +44 -0
  53. agent_loop_guard_runtime-0.6.0a2/app/platform/maintenance.py +138 -0
  54. agent_loop_guard_runtime-0.6.0a2/app/platform/migrations.py +24 -0
  55. agent_loop_guard_runtime-0.6.0a2/app/platform/setup.py +92 -0
  56. agent_loop_guard_runtime-0.6.0a2/app/providers/__init__.py +5 -0
  57. agent_loop_guard_runtime-0.6.0a2/app/providers/base.py +23 -0
  58. agent_loop_guard_runtime-0.6.0a2/app/providers/mock.py +169 -0
  59. agent_loop_guard_runtime-0.6.0a2/app/providers/upstream.py +101 -0
  60. agent_loop_guard_runtime-0.6.0a2/app/replay/__init__.py +1 -0
  61. agent_loop_guard_runtime-0.6.0a2/app/replay/costs.py +37 -0
  62. agent_loop_guard_runtime-0.6.0a2/app/replay/formats.py +87 -0
  63. agent_loop_guard_runtime-0.6.0a2/app/replay/sdk.py +102 -0
  64. agent_loop_guard_runtime-0.6.0a2/app/sandbox/__init__.py +2 -0
  65. agent_loop_guard_runtime-0.6.0a2/app/sandbox/policy.py +22 -0
  66. agent_loop_guard_runtime-0.6.0a2/app/sandbox/workspace.py +281 -0
  67. agent_loop_guard_runtime-0.6.0a2/app/static/styles.css +327 -0
  68. agent_loop_guard_runtime-0.6.0a2/app/templates/agents.html +48 -0
  69. agent_loop_guard_runtime-0.6.0a2/app/templates/base.html +27 -0
  70. agent_loop_guard_runtime-0.6.0a2/app/templates/dashboard.html +55 -0
  71. agent_loop_guard_runtime-0.6.0a2/app/templates/demo.html +36 -0
  72. agent_loop_guard_runtime-0.6.0a2/app/templates/mcp.html +69 -0
  73. agent_loop_guard_runtime-0.6.0a2/app/templates/policies.html +30 -0
  74. agent_loop_guard_runtime-0.6.0a2/app/templates/replay.html +63 -0
  75. agent_loop_guard_runtime-0.6.0a2/app/templates/replay_compare.html +74 -0
  76. agent_loop_guard_runtime-0.6.0a2/app/templates/replay_detail.html +130 -0
  77. agent_loop_guard_runtime-0.6.0a2/app/templates/session_detail.html +71 -0
  78. agent_loop_guard_runtime-0.6.0a2/app/templates/sessions.html +24 -0
  79. agent_loop_guard_runtime-0.6.0a2/app/templates/settings.html +20 -0
  80. agent_loop_guard_runtime-0.6.0a2/pyproject.toml +93 -0
  81. agent_loop_guard_runtime-0.6.0a2/setup.cfg +4 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,407 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-loop-guard-runtime
3
+ Version: 0.6.0a2
4
+ Summary: Local runtime guard for coding agents with loop detection and explainable policy decisions.
5
+ Author: Agent Loop Guard contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/RIMUMURUDEV/agent-loop-guard
8
+ Project-URL: Repository, https://github.com/RIMUMURUDEV/agent-loop-guard.git
9
+ Project-URL: Issues, https://github.com/RIMUMURUDEV/agent-loop-guard/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Framework :: FastAPI
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: alembic>=1.13
22
+ Requires-Dist: fastapi>=0.115
23
+ Requires-Dist: httpx>=0.27
24
+ Requires-Dist: jinja2>=3.1
25
+ Requires-Dist: jsonschema>=4.23
26
+ Requires-Dist: pydantic>=2.8
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: sqlalchemy>=2.0
29
+ Requires-Dist: uvicorn[standard]>=0.30
30
+ Provides-Extra: mcp
31
+ Provides-Extra: bench
32
+ Requires-Dist: duckdb>=1.1; extra == "bench"
33
+ Requires-Dist: mlflow>=3.0; extra == "bench"
34
+ Requires-Dist: pyarrow>=17.0; extra == "bench"
35
+ Provides-Extra: sandbox
36
+ Provides-Extra: docs
37
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
38
+ Provides-Extra: dev
39
+ Requires-Dist: coverage[toml]>=7.6; extra == "dev"
40
+ Requires-Dist: pytest>=8.3; extra == "dev"
41
+ Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
42
+ Requires-Dist: respx>=0.21; extra == "dev"
43
+ Requires-Dist: ruff>=0.6; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # Agent Loop Guard
47
+
48
+ [![CI](https://github.com/RIMUMURUDEV/agent-loop-guard/actions/workflows/ci.yml/badge.svg)](https://github.com/RIMUMURUDEV/agent-loop-guard/actions/workflows/ci.yml)
49
+ [![Documentation](https://github.com/RIMUMURUDEV/agent-loop-guard/actions/workflows/docs.yml/badge.svg)](https://rimumurudev.github.io/agent-loop-guard/)
50
+ [![Python 3.11-3.13](https://img.shields.io/badge/python-3.11--3.13-3776AB.svg)](https://www.python.org/)
51
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-2F6F44.svg)](LICENSE)
52
+ [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/RIMUMURUDEV.agent-loop-guard-vscode?label=VS%20Code)](https://marketplace.visualstudio.com/items?itemName=RIMUMURUDEV.agent-loop-guard-vscode)
53
+
54
+ Agent Loop Guard is an Apache-2.0 local safety and observability toolkit for coding agents. It combines a loop guard, MCP permission firewall, session replay, deterministic benchmark lab, and a Docker-backed sandbox technical preview.
55
+
56
+ The default setup uses a local mock provider, so the demo works without an external API key.
57
+
58
+ ![Agent Loop Guard dashboard](https://raw.githubusercontent.com/RIMUMURUDEV/agent-loop-guard/main/docs/assets/dashboard.png)
59
+
60
+ ## Install
61
+
62
+ Install the current alpha directly from GitHub. The installed command is `alg`:
63
+
64
+ ```bash
65
+ pipx install git+https://github.com/RIMUMURUDEV/agent-loop-guard.git
66
+ # or
67
+ uv tool install git+https://github.com/RIMUMURUDEV/agent-loop-guard.git
68
+ ```
69
+
70
+ Run once without a permanent installation:
71
+
72
+ ```bash
73
+ uvx --from git+https://github.com/RIMUMURUDEV/agent-loop-guard.git alg doctor
74
+ ```
75
+
76
+ PyPI publication under the distribution name `agent-loop-guard-runtime` is planned after trusted publishing is configured. The project does not claim that an unpublished package is available.
77
+
78
+ For development from this checkout:
79
+
80
+ ```bash
81
+ python -m venv .venv
82
+ .venv\Scripts\activate
83
+ pip install -e ".[dev]"
84
+ alg setup
85
+ alg doctor
86
+ alg guard run
87
+ ```
88
+
89
+ Open `http://127.0.0.1:8787`, then run Demo Lab or:
90
+
91
+ ```bash
92
+ alg demo exact-loop
93
+ ```
94
+
95
+ Default local gateway key:
96
+
97
+ ```text
98
+ alg_demo_key
99
+ ```
100
+
101
+ ## Proxy Endpoints
102
+
103
+ OpenAI-compatible:
104
+
105
+ ```text
106
+ POST /v1/responses
107
+ POST /v1/chat/completions
108
+ GET /v1/models
109
+ ```
110
+
111
+ Anthropic-compatible:
112
+
113
+ ```text
114
+ POST /v1/messages
115
+ POST /v1/messages/count_tokens
116
+ ```
117
+
118
+ Connectivity probe:
119
+
120
+ ```text
121
+ HEAD /
122
+ ```
123
+
124
+ Use `Authorization: Bearer alg_demo_key` or `x-api-key: alg_demo_key`.
125
+
126
+ `alg setup` creates a local YAML configuration and connection profiles for Codex, Claude Code, Cline, and OpenCode under `.agent-loop-guard/profiles`. Open `http://127.0.0.1:8787`, then run Demo Lab or `alg demo exact-loop`.
127
+
128
+ ## Modules
129
+
130
+ ```text
131
+ alg setup | doctor | status | open
132
+ alg guard run
133
+ alg mcp run | serve | validate-policy | test-server
134
+ alg replay import | export
135
+ alg bench dataset validate | run | compare | regression-check
136
+ alg sandbox create | exec | diff | apply | discard | export
137
+ ```
138
+
139
+ - **Guard** detects exact request, tool, error, and sequence loops with Shadow and Enforce modes.
140
+ - **MCP Firewall** proxies stdio and Streamable HTTP, validates schemas, filters discovery, and applies YAML policies.
141
+ - **Replay** stores redacted traces, spans, events, costs, deterministic failure tags, and JSONL/OpenTelemetry exports.
142
+ - **Benchmark Lab** runs the bundled 30-task dataset through mock, HTTP, or CLI adapters and computes paired bootstrap confidence intervals.
143
+ - **Sandbox Preview** runs a copied workspace in a resource-limited Docker container and applies no changes before explicit approval.
144
+
145
+ Read the [public documentation](https://rimumurudev.github.io/agent-loop-guard/), [Architecture](docs/architecture.md), [Threat Model](docs/security.md), [Benchmark Guide](docs/guides/benchmark.md), and [Sandbox Guide](docs/guides/sandbox.md). A [Russian overview](docs/ru/index.md) is also available.
146
+
147
+ ## Guard Behavior
148
+
149
+ The guard implements:
150
+
151
+ - exact repeated request detection
152
+ - repeated tool call detection
153
+ - repeated upstream error detection
154
+ - repeated request sequence detection
155
+ - request and token limits
156
+ - project-level Shadow and Enforce modes
157
+ - manual session and agent pause/resume
158
+ - metadata-only logging by default
159
+ - JSON session export and aggregate CSV export
160
+ - trace runs, spans, events, replay UI, JSON export, and run comparison
161
+
162
+ Shadow Mode flags suspicious requests without blocking. Enforce Mode blocks requests when a blocking rule triggers.
163
+
164
+ ## MCP Firewall
165
+
166
+ Validate and run a stdio policy proxy:
167
+
168
+ ```bash
169
+ alg mcp validate-policy app/mcp/presets/filesystem.yml
170
+ alg mcp run --policy app/mcp/presets/filesystem.yml -- your-mcp-server
171
+ ```
172
+
173
+ For Streamable HTTP, configure a server under `mcp.servers`, run `alg mcp serve`, and connect to `/mcp/{server_id}`. Approval requests appear at `/mcp`. Raw arguments and secrets are redacted; audit records store hashes and policy metadata.
174
+
175
+ ## Session Replay
176
+
177
+ Every proxied model request now creates a replay trace automatically. Open:
178
+
179
+ ```text
180
+ http://127.0.0.1:8787/replay
181
+ ```
182
+
183
+ The Replay view shows trace runs, model request spans, policy decision events, token totals, duration, source session links, JSON export, and a simple two-run comparison.
184
+
185
+ Replay ingest API:
186
+
187
+ ```text
188
+ POST /api/v1/traces
189
+ POST /api/v1/spans
190
+ POST /api/v1/events/batch
191
+ GET /api/v1/runs
192
+ GET /api/v1/runs/{trace_id}
193
+ GET /api/v1/runs/{trace_id}/export?format=json|jsonl|otel
194
+ POST /api/v1/runs/import
195
+ POST /api/v1/runs/{trace_id}/pin
196
+ POST /api/v1/compare
197
+ ```
198
+
199
+ CLI transfer:
200
+
201
+ ```bash
202
+ alg replay export TRACE_ID --format jsonl --output trace.jsonl
203
+ alg replay import trace.jsonl
204
+ ```
205
+
206
+ ## Benchmark Lab
207
+
208
+ ```bash
209
+ alg bench dataset validate
210
+ alg bench run --adapter mock --candidate baseline --output baseline.jsonl
211
+ alg bench run --adapter mock --variant regressed --candidate candidate --output candidate.jsonl
212
+ alg bench regression-check baseline.jsonl candidate.jsonl
213
+ ```
214
+
215
+ Parquet, DuckDB, and MLflow are optional:
216
+
217
+ ```bash
218
+ pip install -e ".[bench]"
219
+ ```
220
+
221
+ The regression command exits `0` for no regression, `1` for a statistically supported regression, and `2` when the result is inconclusive.
222
+
223
+ ## Sandbox Preview
224
+
225
+ Docker must be installed and running first. The original project is not mounted into the container; the sandbox uses a private copy.
226
+
227
+ ```bash
228
+ alg sandbox create .
229
+ alg sandbox exec SANDBOX_ID -- pytest -q
230
+ alg sandbox diff SANDBOX_ID
231
+ alg sandbox apply SANDBOX_ID --path app/example.py
232
+ alg sandbox discard SANDBOX_ID
233
+ ```
234
+
235
+ Network is disabled by default. This is a defense-in-depth development tool, not a certified security boundary; read [the threat model](docs/security.md) before using it with untrusted code.
236
+
237
+ Minimal trace ingest example:
238
+
239
+ ```bash
240
+ curl -X POST http://127.0.0.1:8787/api/v1/traces ^
241
+ -H "Content-Type: application/json" ^
242
+ -d "{\"trace_id\":\"demo_trace\",\"task_id\":\"demo\",\"spans\":[{\"name\":\"tool.call\",\"start_ns\":1,\"end_ns\":2000000}]}"
243
+ ```
244
+
245
+ ## Agent Setup
246
+
247
+ Codex CLI:
248
+
249
+ ```toml
250
+ model = "demo-model"
251
+ model_provider = "agent_loop_guard"
252
+
253
+ [model_providers.agent_loop_guard]
254
+ name = "Agent Loop Guard"
255
+ base_url = "http://127.0.0.1:8787/v1"
256
+ env_key = "ALG_GATEWAY_KEY"
257
+ ```
258
+
259
+ Claude Code:
260
+
261
+ ```bash
262
+ set ANTHROPIC_BASE_URL=http://127.0.0.1:8787
263
+ set ANTHROPIC_AUTH_TOKEN=alg_demo_key
264
+ ```
265
+
266
+ OpenCode:
267
+
268
+ ```json
269
+ {
270
+ "provider": {
271
+ "alg": {
272
+ "npm": "@ai-sdk/openai-compatible",
273
+ "name": "Agent Loop Guard",
274
+ "options": {
275
+ "baseURL": "http://127.0.0.1:8787/v1",
276
+ "apiKey": "{env:ALG_GATEWAY_KEY}"
277
+ },
278
+ "models": {
279
+ "demo-model": {"name": "Guarded model"}
280
+ }
281
+ }
282
+ },
283
+ "model": "alg/demo-model"
284
+ }
285
+ ```
286
+
287
+ Cline:
288
+
289
+ ```text
290
+ API Provider: OpenAI Compatible
291
+ Base URL: http://127.0.0.1:8787/v1
292
+ API Key: alg_demo_key
293
+ Model ID: demo-model
294
+ ```
295
+
296
+ ## VS Code Extension
297
+
298
+ The VS Code extension starts the local guard daemon, shows health in the status bar, opens dashboard and replay views, and copies agent connection settings.
299
+
300
+ Install it from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=RIMUMURUDEV.agent-loop-guard-vscode) or from the command line:
301
+
302
+ ```bash
303
+ code --install-extension RIMUMURUDEV.agent-loop-guard-vscode
304
+ ```
305
+
306
+ Install the Python runtime first, then use `Agent Loop Guard: Setup Current Workspace`:
307
+
308
+ ```bash
309
+ pipx install git+https://github.com/RIMUMURUDEV/agent-loop-guard.git
310
+ ```
311
+
312
+ Run the extension from source:
313
+
314
+ ```bash
315
+ cd extensions/vscode
316
+ npm run check
317
+ ```
318
+
319
+ Then open this repository in VS Code, press `F5`, and run `Agent Loop Guard: Start Guard` in the Extension Development Host.
320
+
321
+ Package and install a local `.vsix`:
322
+
323
+ ```bash
324
+ cd extensions/vscode
325
+ npm run package
326
+ code --install-extension agent-loop-guard-vscode-0.2.0.vsix
327
+ ```
328
+
329
+ If `alg` is installed globally, keep `agentLoopGuard.startMode` as `cli`. To run from this checkout instead, set:
330
+
331
+ ```json
332
+ {
333
+ "agentLoopGuard.startMode": "source",
334
+ "agentLoopGuard.pythonPath": ".venv\\Scripts\\python.exe",
335
+ "agentLoopGuard.sourcePath": "C:\\path\\to\\agent-loop-guard"
336
+ }
337
+ ```
338
+
339
+ After the guard is running, point agents at:
340
+
341
+ ```text
342
+ OpenAI base URL: http://127.0.0.1:8787/v1
343
+ Anthropic base URL: http://127.0.0.1:8787
344
+ API key: alg_demo_key
345
+ ```
346
+
347
+ See `extensions/vscode/README.md` for all commands and settings.
348
+
349
+ ## Configuration
350
+
351
+ Create a config file:
352
+
353
+ ```bash
354
+ alg init --path agent-loop-guard.yml
355
+ ```
356
+
357
+ Run with it:
358
+
359
+ ```bash
360
+ alg run --config agent-loop-guard.yml
361
+ ```
362
+
363
+ Environment overrides include:
364
+
365
+ - `ALG_HOST`
366
+ - `ALG_PORT`
367
+ - `ALG_STORAGE_URL`
368
+ - `ALG_MODE`
369
+ - `ALG_PROVIDER`
370
+ - `ALG_GATEWAY_KEY`
371
+ - `ALG_OPENAI_BASE_URL`
372
+ - `OPENAI_API_KEY`
373
+ - `ALG_ANTHROPIC_BASE_URL`
374
+ - `ANTHROPIC_API_KEY`
375
+
376
+ ## Development
377
+
378
+ ```bash
379
+ pip install -e ".[dev,docs]"
380
+ pytest -q
381
+ ruff check .
382
+ mkdocs build --strict
383
+ ```
384
+
385
+ Run the documentation site locally:
386
+
387
+ ```bash
388
+ mkdocs serve
389
+ ```
390
+
391
+ The full contributor workflow is in [CONTRIBUTING.md](CONTRIBUTING.md). Security assumptions and private reporting guidance are in [SECURITY.md](SECURITY.md).
392
+
393
+ Docker:
394
+
395
+ ```bash
396
+ docker compose up --build
397
+ ```
398
+
399
+ ## Project Status
400
+
401
+ This repository is developed as an educational open-source project. Guard, MCP, Replay, and Benchmark are locally testable. Sandbox is a technical preview and its real Docker smoke-test runs only on Linux CI; it could not be executed on the current Windows machine because Docker is not installed. The VS Code extension is publicly available; PyPI publication still requires trusted-publisher account setup.
402
+
403
+ There is no telemetry, paid cloud, subscription, SLA, or closed feature set. Optional donations may be added later, but they do not influence architecture or priorities.
404
+
405
+ ## Limits
406
+
407
+ The toolkit only sees traffic routed through it. It does not provide enterprise IAM, distributed leases, legal audit guarantees, a kernel-level isolation guarantee, or hidden chain-of-thought capture. Full Content Logging is off by default and should not be enabled for sensitive data unless the data owner understands the risk.