@ai-sdk/policy-opa 0.0.0-6b196531-20260710185421

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 ADDED
@@ -0,0 +1,409 @@
1
+ # @ai-sdk/policy
2
+
3
+ ## 0.0.0-6b196531-20260710185421
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [036463b]
8
+ - Updated dependencies [9988975]
9
+ - Updated dependencies [036463b]
10
+ - Updated dependencies [6b19653]
11
+ - @ai-sdk/provider-utils@0.0.0-6b196531-20260710185421
12
+ - ai@0.0.0-6b196531-20260710185421
13
+
14
+ ## 1.0.20
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [b9ac19f]
19
+ - Updated dependencies [a4186d6]
20
+ - ai@7.0.20
21
+
22
+ ## 1.0.19
23
+
24
+ ### Patch Changes
25
+
26
+ - aad737d: Use own-property checks when resolving per-tool approvals so tool names and approval ids that match inherited object properties (e.g. `constructor`, `toString`, `valueOf`, `__proto__`) are treated as unconfigured/absent.
27
+
28
+ - `@ai-sdk/policy-opa`: `wrapMcpTools` builds its per-tool map with a null prototype and reads supplied approvals via an own-property check, and `shadow` guards its per-tool map lookup the same way.
29
+ - `ai`: tool and tool-context lookups keyed by a model- or client-supplied name now go through an own-property check (`getOwn`), so a name matching an inherited object property resolves to "no such tool"/"unconfigured" instead of a prototype value. This covers the approval path (per-tool approval resolution and replay re-validation) as well as tool-call parsing, execution, streaming callbacks, and UI message conversion/validation. The human-in-the-loop approval matching (`collectToolApprovals`) and streaming tool-name maps are built with a null prototype so a client-supplied id that matches an inherited property no longer slips past the "unknown approval" / "tool call not found" guards.
30
+
31
+ - 47bd0a6: `wrapMcpTools`: per-tool approval functions now fail closed. In the per-tool map form, a per-tool approval function that returns a "no opinion" result (`not-applicable` or `undefined`) is now forced through the configured fallback (`user-approval` by default), matching the generic-function form. Previously such a result passed through and the tool resolved to `not-applicable`, letting it run without an approval request. Static per-tool statuses the caller configured explicitly are unchanged.
32
+ - Updated dependencies [be7f05a]
33
+ - Updated dependencies [ee55a07]
34
+ - Updated dependencies [aad737d]
35
+ - Updated dependencies [0f93c57]
36
+ - ai@7.0.19
37
+ - @ai-sdk/provider@4.0.3
38
+ - @ai-sdk/provider-utils@5.0.7
39
+
40
+ ## 1.0.18
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [ac306ed]
45
+ - @ai-sdk/provider-utils@5.0.6
46
+ - ai@7.0.18
47
+
48
+ ## 1.0.17
49
+
50
+ ### Patch Changes
51
+
52
+ - ai@7.0.17
53
+
54
+ ## 1.0.16
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [a8f9b6d]
59
+ - ai@7.0.16
60
+
61
+ ## 1.0.15
62
+
63
+ ### Patch Changes
64
+
65
+ - ai@7.0.15
66
+
67
+ ## 1.0.14
68
+
69
+ ### Patch Changes
70
+
71
+ - 5c5c0f5: Add experimental streaming transcription support for transcription models, including OpenAI `gpt-realtime-whisper` and xAI WebSocket STT.
72
+ - Updated dependencies [5c5c0f5]
73
+ - ai@7.0.14
74
+ - @ai-sdk/provider@4.0.2
75
+ - @ai-sdk/provider-utils@5.0.5
76
+
77
+ ## 1.0.13
78
+
79
+ ### Patch Changes
80
+
81
+ - ai@7.0.13
82
+
83
+ ## 1.0.12
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies [ecfeb6f]
88
+ - Updated dependencies [a193137]
89
+ - Updated dependencies [c6f5e62]
90
+ - ai@7.0.12
91
+ - @ai-sdk/provider-utils@5.0.4
92
+
93
+ ## 1.0.11
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [0a87626]
98
+ - ai@7.0.11
99
+
100
+ ## 1.0.10
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies [8c616f0]
105
+ - ai@7.0.10
106
+ - @ai-sdk/provider-utils@5.0.3
107
+
108
+ ## 1.0.9
109
+
110
+ ### Patch Changes
111
+
112
+ - ai@7.0.9
113
+
114
+ ## 1.0.8
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [0274f34]
119
+ - @ai-sdk/provider@4.0.1
120
+ - ai@7.0.8
121
+ - @ai-sdk/provider-utils@5.0.2
122
+
123
+ ## 1.0.7
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [d598481]
128
+ - ai@7.0.7
129
+
130
+ ## 1.0.6
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies [989402d]
135
+ - ai@7.0.6
136
+
137
+ ## 1.0.5
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies [a2750db]
142
+ - ai@7.0.5
143
+
144
+ ## 1.0.4
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies [6a436e3]
149
+ - @ai-sdk/provider-utils@5.0.1
150
+ - ai@7.0.4
151
+
152
+ ## 1.0.3
153
+
154
+ ### Patch Changes
155
+
156
+ - ai@7.0.3
157
+
158
+ ## 1.0.2
159
+
160
+ ### Patch Changes
161
+
162
+ - ai@7.0.2
163
+
164
+ ## 1.0.1
165
+
166
+ ### Patch Changes
167
+
168
+ - ai@7.0.1
169
+
170
+ ## 1.0.0
171
+
172
+ ### Major Changes
173
+
174
+ - a94c258: Introduce `@ai-sdk/policy-opa`, an Open Policy Agent adapter for the
175
+ `toolApproval` callback on `generateText` / `streamText` / `ToolLoopAgent`.
176
+
177
+ Everything is exported from the package root. The engine-neutral core is a
178
+ `PolicyClient` interface, `shadow()` for safe policy rollout with
179
+ fire-and-forget telemetry, and `wrapMcpTools()` for making approval
180
+ configuration total over a discovered tool surface. The OPA layer ships
181
+ `opaPolicy` / `optionalOpaPolicy` (Rego-as-code authorization),
182
+ `wasmPolicyClient` and `httpPolicyClient` backends (lazy-loaded optional peer
183
+ deps), `opaCapabilityMiddleware` for fail-closed model-level tool filtering,
184
+ and `normalizeOpaDecision` for users who call OPA themselves.
185
+
186
+ Sits entirely on top of the public SDK surface, with no changes to `ai`,
187
+ `@ai-sdk/provider`, or `@ai-sdk/provider-utils`. Transitive enforcement
188
+ (coarse dispatchers like `bash` / `http.request` / MCP proxies) is handled
189
+ inside the user's `toolApproval` by parsing the dispatcher input and routing
190
+ to the same Rego rule that gates the direct tool.
191
+
192
+ ### Patch Changes
193
+
194
+ - 9a1b0ea: Initial release
195
+ - b8396f0: trigger initial beta release
196
+
197
+ ## 1.0.0-beta.24
198
+
199
+ ### Patch Changes
200
+
201
+ - ai@7.0.0-beta.187
202
+
203
+ ## 1.0.0-beta.23
204
+
205
+ ### Patch Changes
206
+
207
+ - ai@7.0.0-beta.186
208
+
209
+ ## 1.0.0-beta.22
210
+
211
+ ### Patch Changes
212
+
213
+ - Updated dependencies [75763b0]
214
+ - ai@7.0.0-beta.185
215
+
216
+ ## 1.0.0-beta.21
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [0416e3e]
221
+ - @ai-sdk/provider@4.0.0-beta.20
222
+ - ai@7.0.0-beta.184
223
+ - @ai-sdk/provider-utils@5.0.0-beta.50
224
+
225
+ ## 1.0.0-beta.20
226
+
227
+ ### Patch Changes
228
+
229
+ - ai@7.0.0-beta.183
230
+
231
+ ## 1.0.0-beta.19
232
+
233
+ ### Patch Changes
234
+
235
+ - Updated dependencies [cc6ab90]
236
+ - ai@7.0.0-beta.182
237
+
238
+ ## 1.0.0-beta.18
239
+
240
+ ### Patch Changes
241
+
242
+ - Updated dependencies [6a2caf9]
243
+ - ai@7.0.0-beta.181
244
+
245
+ ## 1.0.0-beta.17
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [81a284b]
250
+ - ai@7.0.0-beta.180
251
+
252
+ ## 1.0.0-beta.16
253
+
254
+ ### Patch Changes
255
+
256
+ - ai@7.0.0-beta.179
257
+
258
+ ## 1.0.0-beta.15
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies [b097c52]
263
+ - ai@7.0.0-beta.178
264
+
265
+ ## 1.0.0-beta.14
266
+
267
+ ### Patch Changes
268
+
269
+ - b8396f0: trigger initial beta release
270
+ - Updated dependencies [b8396f0]
271
+ - @ai-sdk/provider-utils@5.0.0-beta.49
272
+ - @ai-sdk/provider@4.0.0-beta.19
273
+ - ai@7.0.0-beta.177
274
+
275
+ ## 1.0.0-canary.13
276
+
277
+ ### Patch Changes
278
+
279
+ - ai@7.0.0-canary.176
280
+
281
+ ## 1.0.0-canary.12
282
+
283
+ ### Patch Changes
284
+
285
+ - Updated dependencies [6ec57f5]
286
+ - ai@7.0.0-canary.175
287
+
288
+ ## 1.0.0-canary.11
289
+
290
+ ### Patch Changes
291
+
292
+ - ai@7.0.0-canary.174
293
+
294
+ ## 1.0.0-canary.10
295
+
296
+ ### Patch Changes
297
+
298
+ - ai@7.0.0-canary.173
299
+
300
+ ## 1.0.0-canary.9
301
+
302
+ ### Patch Changes
303
+
304
+ - Updated dependencies [aeda373]
305
+ - Updated dependencies [25a64f8]
306
+ - Updated dependencies [375fdd7]
307
+ - Updated dependencies [f18b08f]
308
+ - Updated dependencies [b4507d5]
309
+ - @ai-sdk/provider-utils@5.0.0-canary.48
310
+ - ai@7.0.0-canary.172
311
+
312
+ ## 1.0.0-canary.8
313
+
314
+ ### Patch Changes
315
+
316
+ - Updated dependencies [89ad56f]
317
+ - Updated dependencies [f9a496f]
318
+ - Updated dependencies [3295831]
319
+ - ai@7.0.0-canary.171
320
+
321
+ ## 1.0.0-canary.7
322
+
323
+ ### Patch Changes
324
+
325
+ - Updated dependencies [bae5e2b]
326
+ - Updated dependencies [69d7128]
327
+ - ai@7.0.0-canary.170
328
+ - @ai-sdk/provider-utils@5.0.0-canary.47
329
+
330
+ ## 1.0.0-canary.6
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies [a5018ab]
335
+ - Updated dependencies [21d3d60]
336
+ - Updated dependencies [426dbbb]
337
+ - Updated dependencies [7fd3360]
338
+ - ai@7.0.0-canary.169
339
+
340
+ ## 1.0.0-canary.5
341
+
342
+ ### Patch Changes
343
+
344
+ - Updated dependencies [1e4b350]
345
+ - ai@7.0.0-canary.168
346
+
347
+ ## 1.0.0-canary.4
348
+
349
+ ### Patch Changes
350
+
351
+ - Updated dependencies [4757690]
352
+ - Updated dependencies [eeefc3f]
353
+ - Updated dependencies [b79b6a8]
354
+ - ai@7.0.0-canary.167
355
+
356
+ ## 1.0.0-canary.3
357
+
358
+ ### Patch Changes
359
+
360
+ - Updated dependencies [19736ee]
361
+ - Updated dependencies [d66ae02]
362
+ - Updated dependencies [e4182bd]
363
+ - ai@7.0.0-canary.166
364
+
365
+ ## 1.0.0-canary.2
366
+
367
+ ### Patch Changes
368
+
369
+ - Updated dependencies [ce769dd]
370
+ - @ai-sdk/provider@4.0.0-canary.18
371
+ - ai@7.0.0-canary.165
372
+ - @ai-sdk/provider-utils@5.0.0-canary.46
373
+
374
+ ## 1.0.0-canary.1
375
+
376
+ ### Patch Changes
377
+
378
+ - 9a1b0ea: Initial release
379
+ - ai@7.0.0-canary.164
380
+
381
+ ## 1.0.0-canary.0
382
+
383
+ ### Major Changes
384
+
385
+ - a94c258: Introduce `@ai-sdk/policy-opa`, an Open Policy Agent adapter for the
386
+ `toolApproval` callback on `generateText` / `streamText` / `ToolLoopAgent`.
387
+
388
+ Everything is exported from the package root. The engine-neutral core is a
389
+ `PolicyClient` interface, `shadow()` for safe policy rollout with
390
+ fire-and-forget telemetry, and `wrapMcpTools()` for making approval
391
+ configuration total over a discovered tool surface. The OPA layer ships
392
+ `opaPolicy` / `optionalOpaPolicy` (Rego-as-code authorization),
393
+ `wasmPolicyClient` and `httpPolicyClient` backends (lazy-loaded optional peer
394
+ deps), `opaCapabilityMiddleware` for fail-closed model-level tool filtering,
395
+ and `normalizeOpaDecision` for users who call OPA themselves.
396
+
397
+ Sits entirely on top of the public SDK surface, with no changes to `ai`,
398
+ `@ai-sdk/provider`, or `@ai-sdk/provider-utils`. Transitive enforcement
399
+ (coarse dispatchers like `bash` / `http.request` / MCP proxies) is handled
400
+ inside the user's `toolApproval` by parsing the dispatcher input and routing
401
+ to the same Rego rule that gates the direct tool.
402
+
403
+ ### Patch Changes
404
+
405
+ - Updated dependencies [ee798eb]
406
+ - Updated dependencies [daf6637]
407
+ - Updated dependencies [c907622]
408
+ - @ai-sdk/provider-utils@5.0.0-canary.45
409
+ - 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.