@ai-sdk/policy-opa 0.0.0-cca10482-20260708215408

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