openscript-sdk 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 (109) hide show
  1. openscript_sdk-0.1.0/LICENSE +190 -0
  2. openscript_sdk-0.1.0/PKG-INFO +225 -0
  3. openscript_sdk-0.1.0/README.md +165 -0
  4. openscript_sdk-0.1.0/openscript_sdk/__init__.py +217 -0
  5. openscript_sdk-0.1.0/openscript_sdk/contracts/__init__.py +82 -0
  6. openscript_sdk-0.1.0/openscript_sdk/contracts/interceptor.py +98 -0
  7. openscript_sdk-0.1.0/openscript_sdk/contracts/server_types.py +87 -0
  8. openscript_sdk-0.1.0/openscript_sdk/contracts/session_graph.py +123 -0
  9. openscript_sdk-0.1.0/openscript_sdk/contracts/types.py +76 -0
  10. openscript_sdk-0.1.0/openscript_sdk/events/__init__.py +0 -0
  11. openscript_sdk-0.1.0/openscript_sdk/events/approvals.py +309 -0
  12. openscript_sdk-0.1.0/openscript_sdk/events/models.py +26 -0
  13. openscript_sdk-0.1.0/openscript_sdk/events/store.py +79 -0
  14. openscript_sdk-0.1.0/openscript_sdk/events/writer.py +100 -0
  15. openscript_sdk-0.1.0/openscript_sdk/hooks/claude_code.py +479 -0
  16. openscript_sdk-0.1.0/openscript_sdk/hooks/claude_code_example.yaml +62 -0
  17. openscript_sdk-0.1.0/openscript_sdk/hooks/claude_code_strict_example.yaml +73 -0
  18. openscript_sdk-0.1.0/openscript_sdk/hooks/config.py +144 -0
  19. openscript_sdk-0.1.0/openscript_sdk/hooks/settings_example.json +28 -0
  20. openscript_sdk-0.1.0/openscript_sdk/hooks/settings_strict_example.json +28 -0
  21. openscript_sdk-0.1.0/openscript_sdk/integrations/langchain.py +32 -0
  22. openscript_sdk-0.1.0/openscript_sdk/integrations/langgraph.py +32 -0
  23. openscript_sdk-0.1.0/openscript_sdk/interceptors/base.py +15 -0
  24. openscript_sdk-0.1.0/openscript_sdk/interceptors/event_writer.py +131 -0
  25. openscript_sdk-0.1.0/openscript_sdk/interceptors/pii.py +168 -0
  26. openscript_sdk-0.1.0/openscript_sdk/interceptors/threat.py +674 -0
  27. openscript_sdk-0.1.0/openscript_sdk/logging.py +94 -0
  28. openscript_sdk-0.1.0/openscript_sdk/middleware/middleware.py +543 -0
  29. openscript_sdk-0.1.0/openscript_sdk/middleware/tool.py +247 -0
  30. openscript_sdk-0.1.0/openscript_sdk/observability/__init__.py +11 -0
  31. openscript_sdk-0.1.0/openscript_sdk/observability/metrics.py +105 -0
  32. openscript_sdk-0.1.0/openscript_sdk/observability/risk.py +54 -0
  33. openscript_sdk-0.1.0/openscript_sdk/observability/tracing.py +67 -0
  34. openscript_sdk-0.1.0/openscript_sdk/policies/compliance.py +261 -0
  35. openscript_sdk-0.1.0/openscript_sdk/policies/config.py +244 -0
  36. openscript_sdk-0.1.0/openscript_sdk/policies/harmful_request.py +617 -0
  37. openscript_sdk-0.1.0/openscript_sdk/policies/normalize.py +489 -0
  38. openscript_sdk-0.1.0/openscript_sdk/policies/output_schema.py +353 -0
  39. openscript_sdk-0.1.0/openscript_sdk/policies/policies_example.yaml +36 -0
  40. openscript_sdk-0.1.0/openscript_sdk/policies/redaction.py +359 -0
  41. openscript_sdk-0.1.0/openscript_sdk/policies/secrets.py +239 -0
  42. openscript_sdk-0.1.0/openscript_sdk/policies/semantic.py +348 -0
  43. openscript_sdk-0.1.0/openscript_sdk/policies/semantic_head.py +9 -0
  44. openscript_sdk-0.1.0/openscript_sdk/policies/session_taint.py +399 -0
  45. openscript_sdk-0.1.0/openscript_sdk/policies/taint_store.py +111 -0
  46. openscript_sdk-0.1.0/openscript_sdk/policies/tool_firewall.py +434 -0
  47. openscript_sdk-0.1.0/openscript_sdk/policies/tools_example.yaml +81 -0
  48. openscript_sdk-0.1.0/openscript_sdk/policies/toxicity.py +247 -0
  49. openscript_sdk-0.1.0/openscript_sdk/py.typed +0 -0
  50. openscript_sdk-0.1.0/openscript_sdk/server/__init__.py +1 -0
  51. openscript_sdk-0.1.0/openscript_sdk/server/app.py +153 -0
  52. openscript_sdk-0.1.0/openscript_sdk/server/auth.py +19 -0
  53. openscript_sdk-0.1.0/openscript_sdk/server/guard.py +126 -0
  54. openscript_sdk-0.1.0/openscript_sdk/server/guard_example.yaml +55 -0
  55. openscript_sdk-0.1.0/openscript_sdk/server/routers/__init__.py +0 -0
  56. openscript_sdk-0.1.0/openscript_sdk/server/routers/approvals.py +69 -0
  57. openscript_sdk-0.1.0/openscript_sdk/server/routers/guard.py +231 -0
  58. openscript_sdk-0.1.0/openscript_sdk/server/routers/sessions.py +80 -0
  59. openscript_sdk-0.1.0/openscript_sdk/server/routers/sse.py +69 -0
  60. openscript_sdk-0.1.0/openscript_sdk/server/routers/threat.py +119 -0
  61. openscript_sdk-0.1.0/openscript_sdk/server/static/dashboard/index.html +209 -0
  62. openscript_sdk-0.1.0/openscript_sdk/server/static/dashboard/session.html +339 -0
  63. openscript_sdk-0.1.0/openscript_sdk.egg-info/PKG-INFO +225 -0
  64. openscript_sdk-0.1.0/openscript_sdk.egg-info/SOURCES.txt +107 -0
  65. openscript_sdk-0.1.0/openscript_sdk.egg-info/dependency_links.txt +1 -0
  66. openscript_sdk-0.1.0/openscript_sdk.egg-info/entry_points.txt +2 -0
  67. openscript_sdk-0.1.0/openscript_sdk.egg-info/requires.txt +40 -0
  68. openscript_sdk-0.1.0/openscript_sdk.egg-info/top_level.txt +1 -0
  69. openscript_sdk-0.1.0/pyproject.toml +202 -0
  70. openscript_sdk-0.1.0/setup.cfg +4 -0
  71. openscript_sdk-0.1.0/tests/test_agent_receives.py +98 -0
  72. openscript_sdk-0.1.0/tests/test_agentdojo_guard.py +100 -0
  73. openscript_sdk-0.1.0/tests/test_agentdojo_model.py +357 -0
  74. openscript_sdk-0.1.0/tests/test_agentdojo_named.py +141 -0
  75. openscript_sdk-0.1.0/tests/test_agentdojo_results.py +594 -0
  76. openscript_sdk-0.1.0/tests/test_api_migration.py +244 -0
  77. openscript_sdk-0.1.0/tests/test_approval_hash.py +134 -0
  78. openscript_sdk-0.1.0/tests/test_approvals.py +464 -0
  79. openscript_sdk-0.1.0/tests/test_audit.py +170 -0
  80. openscript_sdk-0.1.0/tests/test_blocked_audit.py +220 -0
  81. openscript_sdk-0.1.0/tests/test_claude_code_hook.py +574 -0
  82. openscript_sdk-0.1.0/tests/test_compliance_policy.py +255 -0
  83. openscript_sdk-0.1.0/tests/test_evals.py +178 -0
  84. openscript_sdk-0.1.0/tests/test_extension.py +165 -0
  85. openscript_sdk-0.1.0/tests/test_harmful_request_policy.py +241 -0
  86. openscript_sdk-0.1.0/tests/test_integration.py +178 -0
  87. openscript_sdk-0.1.0/tests/test_lazy_exports.py +59 -0
  88. openscript_sdk-0.1.0/tests/test_ledger.py +200 -0
  89. openscript_sdk-0.1.0/tests/test_logging.py +98 -0
  90. openscript_sdk-0.1.0/tests/test_middleware.py +212 -0
  91. openscript_sdk-0.1.0/tests/test_noop_benchmark.py +68 -0
  92. openscript_sdk-0.1.0/tests/test_normalize.py +150 -0
  93. openscript_sdk-0.1.0/tests/test_observability.py +205 -0
  94. openscript_sdk-0.1.0/tests/test_output_schema.py +301 -0
  95. openscript_sdk-0.1.0/tests/test_pii_interceptor.py +177 -0
  96. openscript_sdk-0.1.0/tests/test_policy_config.py +253 -0
  97. openscript_sdk-0.1.0/tests/test_pyodide_compat.py +211 -0
  98. openscript_sdk-0.1.0/tests/test_redaction.py +105 -0
  99. openscript_sdk-0.1.0/tests/test_redis_approvals.py +281 -0
  100. openscript_sdk-0.1.0/tests/test_risk_scoring.py +244 -0
  101. openscript_sdk-0.1.0/tests/test_secrets_policy.py +351 -0
  102. openscript_sdk-0.1.0/tests/test_secure_tool.py +649 -0
  103. openscript_sdk-0.1.0/tests/test_semantic_policy.py +272 -0
  104. openscript_sdk-0.1.0/tests/test_session_taint.py +649 -0
  105. openscript_sdk-0.1.0/tests/test_streaming.py +301 -0
  106. openscript_sdk-0.1.0/tests/test_taint_store.py +117 -0
  107. openscript_sdk-0.1.0/tests/test_threat_interceptor.py +204 -0
  108. openscript_sdk-0.1.0/tests/test_tool_firewall.py +541 -0
  109. openscript_sdk-0.1.0/tests/test_toxicity_policy.py +163 -0
@@ -0,0 +1,190 @@
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 not
33
+ limited to compiled object code, generated documentation, and
34
+ 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
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including the original
49
+ version of the Work and any modifications or additions to that Work or
50
+ Derivative Works thereof, that is intentionally submitted to the Licensor
51
+ for inclusion in the Work by the copyright owner or by an individual or
52
+ Legal Entity authorized to submit on behalf of the copyright owner. For
53
+ the purposes of this definition, "submitted" means any form of electronic,
54
+ verbal, or written communication sent to the Licensor or its
55
+ representatives, including but not limited to communication on electronic
56
+ mailing lists, source code control systems, and issue tracking systems that
57
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
58
+ and improving the Work, but excluding communication that is conspicuously
59
+ marked or otherwise designated in writing by the copyright owner as
60
+ "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Sharif Parish / Bluesky Labs
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: openscript-sdk
3
+ Version: 0.1.0
4
+ Summary: Hold an AI agent's irreversible tool calls until a person approves that exact call
5
+ Author: Sharif Parish
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/saintparish4/openscript
8
+ Project-URL: Documentation, https://github.com/saintparish4/openscript/blob/master/docs/guide.md
9
+ Project-URL: Source, https://github.com/saintparish4/openscript
10
+ Project-URL: Issues, https://github.com/saintparish4/openscript/issues
11
+ Project-URL: Demo, https://openscript-demo.vercel.app/
12
+ Keywords: ai-agents,agent-security,prompt-injection,human-in-the-loop,tool-calling,llm,guardrails,claude-code
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pydantic<3,>=2.10
27
+ Requires-Dist: structlog>=25.5.0
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: ml
30
+ Requires-Dist: sentence-transformers>=2.2; extra == "ml"
31
+ Provides-Extra: redis
32
+ Requires-Dist: redis>=7.3.0; extra == "redis"
33
+ Provides-Extra: metrics
34
+ Requires-Dist: prometheus-client>=0.24.1; extra == "metrics"
35
+ Provides-Extra: otel
36
+ Requires-Dist: opentelemetry-sdk>=1.27; extra == "otel"
37
+ Requires-Dist: opentelemetry-exporter-otlp>=1.27; extra == "otel"
38
+ Provides-Extra: server
39
+ Requires-Dist: openscript-sdk[metrics,redis]; extra == "server"
40
+ Requires-Dist: fastapi>=0.128.0; extra == "server"
41
+ Requires-Dist: uvicorn>=0.42.0; extra == "server"
42
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.48; extra == "server"
43
+ Requires-Dist: asyncpg>=0.31.0; extra == "server"
44
+ Requires-Dist: python-dotenv>=1.0.0; extra == "server"
45
+ Provides-Extra: demo
46
+ Requires-Dist: openscript-sdk[metrics]; extra == "demo"
47
+ Requires-Dist: rich>=13.0.0; extra == "demo"
48
+ Requires-Dist: python-dotenv>=1.0.0; extra == "demo"
49
+ Provides-Extra: dev
50
+ Requires-Dist: pytest>=9.0.2; extra == "dev"
51
+ Requires-Dist: pytest-asyncio>=1.3.0; extra == "dev"
52
+ Requires-Dist: pytest-benchmark>=5.2.3; extra == "dev"
53
+ Requires-Dist: black>=26.1.0; extra == "dev"
54
+ Requires-Dist: ruff>=0.15.6; extra == "dev"
55
+ Requires-Dist: mypy>=1.19.1; extra == "dev"
56
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
57
+ Requires-Dist: hypothesis>=6.151.9; extra == "dev"
58
+ Requires-Dist: build>=1.2; extra == "dev"
59
+ Dynamic: license-file
60
+
61
+ # OpenScript
62
+
63
+ [![CI](https://github.com/saintparish4/openscript/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/saintparish4/openscript/actions/workflows/ci.yml)
64
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/saintparish4/openscript/blob/master/LICENSE)
65
+ [![Live demo](https://img.shields.io/badge/demo-live%20in%20your%20browser-22c55e)](https://openscript-demo.vercel.app/)
66
+
67
+ **Irreversible actions wait for a person, even when the model has been fooled.**
68
+
69
+ OpenScript sits between an AI agent and the tools it calls. It refuses calls
70
+ outside rules you write, holds the ones that cannot be undone until a person
71
+ approves that exact call, masks secrets and PII, and records every decision.
72
+ None of it depends on recognising an attack, so it still holds when the model
73
+ is fooled, wrong, or swapped for another.
74
+
75
+ It is for anyone building an agent whose tools have real effects, such as
76
+ payments, email or a shell, in Python with any framework. It is version
77
+ 0.1.0 and alpha: the API may still change.
78
+
79
+ **[Try the live demo →](https://openscript-demo.vercel.app/)** The package
80
+ runs in your browser tab, compiled to WebAssembly, with no backend.
81
+
82
+ ## What it is not
83
+
84
+ - **Not an injection detector to rely on.** It has pattern detectors, and they
85
+ catch 2 to 7% of attacks they were not written for. The boundary is the
86
+ rules and the approvals, and the rules are only as tight as you write them.
87
+ - **Not a compliance certification.** Its compliance presets assist a
88
+ program and certify nothing.
89
+
90
+ ## What it has been shown to do
91
+
92
+ Measured on [AgentDojo](https://github.com/ethz-spylab/agentdojo)'s banking
93
+ and Slack suites, with Qwen2.5-7B-Instruct, a model that follows prompt
94
+ injections. The protocol was frozen before the run.
95
+
96
+ | The run | |
97
+ |---|---|
98
+ | Hardware | 1 NVIDIA RTX 4090 on RunPod, Secure Cloud, EU-RO-1 |
99
+ | Serving | vLLM 0.10.2, bf16, temperature 0 |
100
+ | Size | 1,430 cases, 5,382 requests, 9.8M input and 0.63M output tokens |
101
+ | Errors | 0 |
102
+ | Date | 2026-11-04 |
103
+
104
+ | Configuration | Attacks that succeeded | Attacker's irreversible actions that took effect |
105
+ |---|---|---|
106
+ | No protection | 58 of 249 | 108 |
107
+ | Session rule: hold irreversible calls after an untrusted read | 6 of 249 | 10 |
108
+ | Ask a person on every irreversible call | **0 of 249** | **0** |
109
+ | No policy at all, effect side enforcing | **0 of 249** | **0** |
110
+
111
+ - **The effect side is the boundary.** A ledger in front of each irreversible
112
+ tool applies a call only with a token minted when a person approves it. A
113
+ call that goes round the wrapper changes nothing.
114
+ - **Safety has a price, and it is published.** In the run above, asking on
115
+ every irreversible call meant a person on 23 of the 37 ordinary tasks. In
116
+ the no-model replay of all four suites it is 59 of 97. The session rule
117
+ asks less and misses the attacks that arrive through Slack's channel
118
+ listing.
119
+ - **It was attacked before it was trusted.** A [red team](https://github.com/saintparish4/openscript/blob/master/docs/red-team.md)
120
+ searched for bypasses and published 7 findings, each committed as a
121
+ failing test before its fix.
122
+
123
+ Every number, with its date, command and caveats, is in
124
+ [`docs/metrics.md`](https://github.com/saintparish4/openscript/blob/master/docs/metrics.md). The claim and what it does not cover
125
+ are in [the threat model](https://github.com/saintparish4/openscript/blob/master/docs/threat-model.md).
126
+
127
+ ## How it works
128
+
129
+ ```
130
+ agent ── calls a tool ──► SecureTool ── before: tool rules · session rule ──► refuse / hold for a person
131
+ │
132
+ ▼ the call that was checked, and nothing else
133
+ effect side ── a person's token? ──► apply, and write it in the ledger
134
+ │
135
+ ▼
136
+ after: mask secrets and PII · record
137
+ ```
138
+
139
+ - **Tool rules** limit which tools, arguments, recipients and amounts are
140
+ allowed, in YAML.
141
+ - **The session rule** remembers when a session has read something a
142
+ stranger wrote, and then holds the calls you list as irreversible.
143
+ - **An approval** is single-use, expires in an hour, and is bound to the
144
+ tool, its exact arguments and the session.
145
+ - **The effect side** ([`evals/ledger.py`](https://github.com/saintparish4/openscript/blob/master/evals/ledger.py)) is a reference
146
+ implementation, standard library only.
147
+
148
+ ## Quick start
149
+
150
+ ```bash
151
+ pip install openscript-sdk # Python 3.11+; pulls pydantic, structlog and PyYAML
152
+ ```
153
+
154
+ The distribution is `openscript-sdk` and the package imports as
155
+ `openscript_sdk`. The extras are `[server]` (the FastAPI server, whose
156
+ database migrations are in this repository's `alembic/`), `[redis]`,
157
+ `[metrics]` and `[otel]`. To work on it, clone the repository and run
158
+ `make install`.
159
+
160
+ A tool that the rules hold
161
+ waits for a person, and the retry with the approval runs that exact call
162
+ once:
163
+
164
+ ```python
165
+ from openscript_sdk import ActionBlockedError, SecureTool, ToolFirewallPolicy
166
+
167
+ async def transfer_funds(to: str, amount: int) -> str: ...
168
+
169
+ transfer = SecureTool(transfer_funds, policies=[ToolFirewallPolicy(rules_path="tools.yaml")])
170
+
171
+ call = {"to": "acct-22", "amount": 500}
172
+ try:
173
+ await transfer.call(call) # held: the tool does not run
174
+ except ActionBlockedError as held:
175
+ approval_id = held.approval_id # a person approves it ...
176
+
177
+ await transfer.call(call, approval_id=approval_id) # ... and the same call runs, once
178
+ ```
179
+
180
+ ```yaml
181
+ # tools.yaml
182
+ default_deny: true
183
+ rules:
184
+ transfer_funds:
185
+ requires_approval: true
186
+ args:
187
+ amount: {min: 0, max: 1000}
188
+ ```
189
+
190
+ Also in the package: redaction of secrets and PII, input screening, an audit
191
+ trail and an event server. The [guide](https://github.com/saintparish4/openscript/blob/master/docs/guide.md) covers each.
192
+
193
+ ## Where it runs
194
+
195
+ | Surface | Start here |
196
+ |---|---|
197
+ | Python agents and tools (LangChain, LangGraph, anything with `invoke`) | [the guide](https://github.com/saintparish4/openscript/blob/master/docs/guide.md) |
198
+ | Claude Code, as a hook, with a strict profile that holds Bash after a web read | [the hook](https://github.com/saintparish4/openscript/blob/master/docs/guide.md#the-claude-code-hook-what-it-adds-and-what-it-does-not-do) |
199
+ | Java agents, through the server | [`clients/java`](https://github.com/saintparish4/openscript/blob/master/clients/java/README.md) |
200
+ | A browser, and a Chrome extension | [the demo](https://openscript-demo.vercel.app/) |
201
+
202
+ ## Further reading
203
+
204
+ - [`docs/guide.md`](https://github.com/saintparish4/openscript/blob/master/docs/guide.md): every feature, its limits and its
205
+ configuration, including environment variables and options.
206
+ - [`docs/metrics.md`](https://github.com/saintparish4/openscript/blob/master/docs/metrics.md): every measurement.
207
+ - [`docs/threat-model.md`](https://github.com/saintparish4/openscript/blob/master/docs/threat-model.md) and
208
+ [`docs/red-team.md`](https://github.com/saintparish4/openscript/blob/master/docs/red-team.md): the claim and the attempts to
209
+ break it.
210
+ - [`docs/submission.md`](https://github.com/saintparish4/openscript/blob/master/docs/submission.md): the AI-safety challenge
211
+ write-up.
212
+
213
+ ## Contributing
214
+
215
+ ```bash
216
+ make install && pytest && ruff check . && black --check . && mypy --strict openscript_sdk/ --exclude openscript_sdk/server/
217
+ ```
218
+
219
+ [CONTRIBUTING.md](https://github.com/saintparish4/openscript/blob/master/CONTRIBUTING.md) has the full checklist, including the
220
+ Pyodide and Java checks. Changes to approvals, the session rule or the hook
221
+ also run `pytest tests/bypass`.
222
+
223
+ ## License
224
+
225
+ Apache License 2.0. See [LICENSE](https://github.com/saintparish4/openscript/blob/master/LICENSE).
@@ -0,0 +1,165 @@
1
+ # OpenScript
2
+
3
+ [![CI](https://github.com/saintparish4/openscript/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/saintparish4/openscript/actions/workflows/ci.yml)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/saintparish4/openscript/blob/master/LICENSE)
5
+ [![Live demo](https://img.shields.io/badge/demo-live%20in%20your%20browser-22c55e)](https://openscript-demo.vercel.app/)
6
+
7
+ **Irreversible actions wait for a person, even when the model has been fooled.**
8
+
9
+ OpenScript sits between an AI agent and the tools it calls. It refuses calls
10
+ outside rules you write, holds the ones that cannot be undone until a person
11
+ approves that exact call, masks secrets and PII, and records every decision.
12
+ None of it depends on recognising an attack, so it still holds when the model
13
+ is fooled, wrong, or swapped for another.
14
+
15
+ It is for anyone building an agent whose tools have real effects, such as
16
+ payments, email or a shell, in Python with any framework. It is version
17
+ 0.1.0 and alpha: the API may still change.
18
+
19
+ **[Try the live demo →](https://openscript-demo.vercel.app/)** The package
20
+ runs in your browser tab, compiled to WebAssembly, with no backend.
21
+
22
+ ## What it is not
23
+
24
+ - **Not an injection detector to rely on.** It has pattern detectors, and they
25
+ catch 2 to 7% of attacks they were not written for. The boundary is the
26
+ rules and the approvals, and the rules are only as tight as you write them.
27
+ - **Not a compliance certification.** Its compliance presets assist a
28
+ program and certify nothing.
29
+
30
+ ## What it has been shown to do
31
+
32
+ Measured on [AgentDojo](https://github.com/ethz-spylab/agentdojo)'s banking
33
+ and Slack suites, with Qwen2.5-7B-Instruct, a model that follows prompt
34
+ injections. The protocol was frozen before the run.
35
+
36
+ | The run | |
37
+ |---|---|
38
+ | Hardware | 1 NVIDIA RTX 4090 on RunPod, Secure Cloud, EU-RO-1 |
39
+ | Serving | vLLM 0.10.2, bf16, temperature 0 |
40
+ | Size | 1,430 cases, 5,382 requests, 9.8M input and 0.63M output tokens |
41
+ | Errors | 0 |
42
+ | Date | 2026-11-04 |
43
+
44
+ | Configuration | Attacks that succeeded | Attacker's irreversible actions that took effect |
45
+ |---|---|---|
46
+ | No protection | 58 of 249 | 108 |
47
+ | Session rule: hold irreversible calls after an untrusted read | 6 of 249 | 10 |
48
+ | Ask a person on every irreversible call | **0 of 249** | **0** |
49
+ | No policy at all, effect side enforcing | **0 of 249** | **0** |
50
+
51
+ - **The effect side is the boundary.** A ledger in front of each irreversible
52
+ tool applies a call only with a token minted when a person approves it. A
53
+ call that goes round the wrapper changes nothing.
54
+ - **Safety has a price, and it is published.** In the run above, asking on
55
+ every irreversible call meant a person on 23 of the 37 ordinary tasks. In
56
+ the no-model replay of all four suites it is 59 of 97. The session rule
57
+ asks less and misses the attacks that arrive through Slack's channel
58
+ listing.
59
+ - **It was attacked before it was trusted.** A [red team](https://github.com/saintparish4/openscript/blob/master/docs/red-team.md)
60
+ searched for bypasses and published 7 findings, each committed as a
61
+ failing test before its fix.
62
+
63
+ Every number, with its date, command and caveats, is in
64
+ [`docs/metrics.md`](https://github.com/saintparish4/openscript/blob/master/docs/metrics.md). The claim and what it does not cover
65
+ are in [the threat model](https://github.com/saintparish4/openscript/blob/master/docs/threat-model.md).
66
+
67
+ ## How it works
68
+
69
+ ```
70
+ agent ── calls a tool ──► SecureTool ── before: tool rules · session rule ──► refuse / hold for a person
71
+ │
72
+ ▼ the call that was checked, and nothing else
73
+ effect side ── a person's token? ──► apply, and write it in the ledger
74
+ │
75
+ ▼
76
+ after: mask secrets and PII · record
77
+ ```
78
+
79
+ - **Tool rules** limit which tools, arguments, recipients and amounts are
80
+ allowed, in YAML.
81
+ - **The session rule** remembers when a session has read something a
82
+ stranger wrote, and then holds the calls you list as irreversible.
83
+ - **An approval** is single-use, expires in an hour, and is bound to the
84
+ tool, its exact arguments and the session.
85
+ - **The effect side** ([`evals/ledger.py`](https://github.com/saintparish4/openscript/blob/master/evals/ledger.py)) is a reference
86
+ implementation, standard library only.
87
+
88
+ ## Quick start
89
+
90
+ ```bash
91
+ pip install openscript-sdk # Python 3.11+; pulls pydantic, structlog and PyYAML
92
+ ```
93
+
94
+ The distribution is `openscript-sdk` and the package imports as
95
+ `openscript_sdk`. The extras are `[server]` (the FastAPI server, whose
96
+ database migrations are in this repository's `alembic/`), `[redis]`,
97
+ `[metrics]` and `[otel]`. To work on it, clone the repository and run
98
+ `make install`.
99
+
100
+ A tool that the rules hold
101
+ waits for a person, and the retry with the approval runs that exact call
102
+ once:
103
+
104
+ ```python
105
+ from openscript_sdk import ActionBlockedError, SecureTool, ToolFirewallPolicy
106
+
107
+ async def transfer_funds(to: str, amount: int) -> str: ...
108
+
109
+ transfer = SecureTool(transfer_funds, policies=[ToolFirewallPolicy(rules_path="tools.yaml")])
110
+
111
+ call = {"to": "acct-22", "amount": 500}
112
+ try:
113
+ await transfer.call(call) # held: the tool does not run
114
+ except ActionBlockedError as held:
115
+ approval_id = held.approval_id # a person approves it ...
116
+
117
+ await transfer.call(call, approval_id=approval_id) # ... and the same call runs, once
118
+ ```
119
+
120
+ ```yaml
121
+ # tools.yaml
122
+ default_deny: true
123
+ rules:
124
+ transfer_funds:
125
+ requires_approval: true
126
+ args:
127
+ amount: {min: 0, max: 1000}
128
+ ```
129
+
130
+ Also in the package: redaction of secrets and PII, input screening, an audit
131
+ trail and an event server. The [guide](https://github.com/saintparish4/openscript/blob/master/docs/guide.md) covers each.
132
+
133
+ ## Where it runs
134
+
135
+ | Surface | Start here |
136
+ |---|---|
137
+ | Python agents and tools (LangChain, LangGraph, anything with `invoke`) | [the guide](https://github.com/saintparish4/openscript/blob/master/docs/guide.md) |
138
+ | Claude Code, as a hook, with a strict profile that holds Bash after a web read | [the hook](https://github.com/saintparish4/openscript/blob/master/docs/guide.md#the-claude-code-hook-what-it-adds-and-what-it-does-not-do) |
139
+ | Java agents, through the server | [`clients/java`](https://github.com/saintparish4/openscript/blob/master/clients/java/README.md) |
140
+ | A browser, and a Chrome extension | [the demo](https://openscript-demo.vercel.app/) |
141
+
142
+ ## Further reading
143
+
144
+ - [`docs/guide.md`](https://github.com/saintparish4/openscript/blob/master/docs/guide.md): every feature, its limits and its
145
+ configuration, including environment variables and options.
146
+ - [`docs/metrics.md`](https://github.com/saintparish4/openscript/blob/master/docs/metrics.md): every measurement.
147
+ - [`docs/threat-model.md`](https://github.com/saintparish4/openscript/blob/master/docs/threat-model.md) and
148
+ [`docs/red-team.md`](https://github.com/saintparish4/openscript/blob/master/docs/red-team.md): the claim and the attempts to
149
+ break it.
150
+ - [`docs/submission.md`](https://github.com/saintparish4/openscript/blob/master/docs/submission.md): the AI-safety challenge
151
+ write-up.
152
+
153
+ ## Contributing
154
+
155
+ ```bash
156
+ make install && pytest && ruff check . && black --check . && mypy --strict openscript_sdk/ --exclude openscript_sdk/server/
157
+ ```
158
+
159
+ [CONTRIBUTING.md](https://github.com/saintparish4/openscript/blob/master/CONTRIBUTING.md) has the full checklist, including the
160
+ Pyodide and Java checks. Changes to approvals, the session rule or the hook
161
+ also run `pytest tests/bypass`.
162
+
163
+ ## License
164
+
165
+ Apache License 2.0. See [LICENSE](https://github.com/saintparish4/openscript/blob/master/LICENSE).