@ai-sdk/policy-opa 0.0.0 → 1.0.0-canary.10
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.
- package/CHANGELOG.md +118 -0
- package/LICENSE +13 -0
- package/README.md +636 -0
- package/dist/index.d.ts +362 -0
- package/dist/index.js +295 -0
- package/dist/index.js.map +1 -0
- package/package.json +83 -1
- package/src/index.ts +19 -0
- package/src/opa/evaluate-policy.ts +24 -0
- package/src/opa/http-policy-client.ts +57 -0
- package/src/opa/normalize-opa-decision.ts +56 -0
- package/src/opa/opa-capability-middleware.ts +130 -0
- package/src/opa/opa-policy.ts +152 -0
- package/src/opa/test-helpers.ts +14 -0
- package/src/opa/wasm-policy-client.ts +78 -0
- package/src/policy-client.ts +20 -0
- package/src/policy-decision.ts +13 -0
- package/src/shadow.ts +180 -0
- package/src/wrap-mcp-tools.ts +97 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @ai-sdk/policy
|
|
2
|
+
|
|
3
|
+
## 1.0.0-canary.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ai@7.0.0-canary.173
|
|
8
|
+
|
|
9
|
+
## 1.0.0-canary.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [aeda373]
|
|
14
|
+
- Updated dependencies [25a64f8]
|
|
15
|
+
- Updated dependencies [375fdd7]
|
|
16
|
+
- Updated dependencies [f18b08f]
|
|
17
|
+
- Updated dependencies [b4507d5]
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.0-canary.48
|
|
19
|
+
- ai@7.0.0-canary.172
|
|
20
|
+
|
|
21
|
+
## 1.0.0-canary.8
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [89ad56f]
|
|
26
|
+
- Updated dependencies [f9a496f]
|
|
27
|
+
- Updated dependencies [3295831]
|
|
28
|
+
- ai@7.0.0-canary.171
|
|
29
|
+
|
|
30
|
+
## 1.0.0-canary.7
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [bae5e2b]
|
|
35
|
+
- Updated dependencies [69d7128]
|
|
36
|
+
- ai@7.0.0-canary.170
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.0-canary.47
|
|
38
|
+
|
|
39
|
+
## 1.0.0-canary.6
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [a5018ab]
|
|
44
|
+
- Updated dependencies [21d3d60]
|
|
45
|
+
- Updated dependencies [426dbbb]
|
|
46
|
+
- Updated dependencies [7fd3360]
|
|
47
|
+
- ai@7.0.0-canary.169
|
|
48
|
+
|
|
49
|
+
## 1.0.0-canary.5
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [1e4b350]
|
|
54
|
+
- ai@7.0.0-canary.168
|
|
55
|
+
|
|
56
|
+
## 1.0.0-canary.4
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [4757690]
|
|
61
|
+
- Updated dependencies [eeefc3f]
|
|
62
|
+
- Updated dependencies [b79b6a8]
|
|
63
|
+
- ai@7.0.0-canary.167
|
|
64
|
+
|
|
65
|
+
## 1.0.0-canary.3
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [19736ee]
|
|
70
|
+
- Updated dependencies [d66ae02]
|
|
71
|
+
- Updated dependencies [e4182bd]
|
|
72
|
+
- ai@7.0.0-canary.166
|
|
73
|
+
|
|
74
|
+
## 1.0.0-canary.2
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [ce769dd]
|
|
79
|
+
- @ai-sdk/provider@4.0.0-canary.18
|
|
80
|
+
- ai@7.0.0-canary.165
|
|
81
|
+
- @ai-sdk/provider-utils@5.0.0-canary.46
|
|
82
|
+
|
|
83
|
+
## 1.0.0-canary.1
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 9a1b0ea: Initial release
|
|
88
|
+
- ai@7.0.0-canary.164
|
|
89
|
+
|
|
90
|
+
## 1.0.0-canary.0
|
|
91
|
+
|
|
92
|
+
### Major Changes
|
|
93
|
+
|
|
94
|
+
- a94c258: Introduce `@ai-sdk/policy-opa`, an Open Policy Agent adapter for the
|
|
95
|
+
`toolApproval` callback on `generateText` / `streamText` / `ToolLoopAgent`.
|
|
96
|
+
|
|
97
|
+
Everything is exported from the package root. The engine-neutral core is a
|
|
98
|
+
`PolicyClient` interface, `shadow()` for safe policy rollout with
|
|
99
|
+
fire-and-forget telemetry, and `wrapMcpTools()` for making approval
|
|
100
|
+
configuration total over a discovered tool surface. The OPA layer ships
|
|
101
|
+
`opaPolicy` / `optionalOpaPolicy` (Rego-as-code authorization),
|
|
102
|
+
`wasmPolicyClient` and `httpPolicyClient` backends (lazy-loaded optional peer
|
|
103
|
+
deps), `opaCapabilityMiddleware` for fail-closed model-level tool filtering,
|
|
104
|
+
and `normalizeOpaDecision` for users who call OPA themselves.
|
|
105
|
+
|
|
106
|
+
Sits entirely on top of the public SDK surface, with no changes to `ai`,
|
|
107
|
+
`@ai-sdk/provider`, or `@ai-sdk/provider-utils`. Transitive enforcement
|
|
108
|
+
(coarse dispatchers like `bash` / `http.request` / MCP proxies) is handled
|
|
109
|
+
inside the user's `toolApproval` by parsing the dispatcher input and routing
|
|
110
|
+
to the same Rego rule that gates the direct tool.
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [ee798eb]
|
|
115
|
+
- Updated dependencies [daf6637]
|
|
116
|
+
- Updated dependencies [c907622]
|
|
117
|
+
- @ai-sdk/provider-utils@5.0.0-canary.45
|
|
118
|
+
- ai@7.0.0-canary.163
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|