@ai-sdk/policy-opa 0.0.0-07500555-20260730161446

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,522 @@
1
+ # @ai-sdk/policy
2
+
3
+ ## 0.0.0-07500555-20260730161446
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [589d87c]
8
+ - Updated dependencies [7f6650b]
9
+ - Updated dependencies [106ea59]
10
+ - @ai-sdk/provider@0.0.0-07500555-20260730161446
11
+ - ai@0.0.0-07500555-20260730161446
12
+ - @ai-sdk/provider-utils@0.0.0-07500555-20260730161446
13
+
14
+ ## 1.0.34
15
+
16
+ ### Patch Changes
17
+
18
+ - ai@7.0.34
19
+
20
+ ## 1.0.33
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [02ffdcb]
25
+ - Updated dependencies [76cb673]
26
+ - Updated dependencies [e808fa5]
27
+ - Updated dependencies [33647d7]
28
+ - @ai-sdk/provider-utils@5.0.12
29
+ - ai@7.0.33
30
+
31
+ ## 1.0.32
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [6cd7c74]
36
+ - Updated dependencies [e35bcae]
37
+ - Updated dependencies [a4eb3f3]
38
+ - ai@7.0.32
39
+
40
+ ## 1.0.31
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [70f18c3]
45
+ - Updated dependencies [cd06458]
46
+ - ai@7.0.31
47
+ - @ai-sdk/provider-utils@5.0.11
48
+
49
+ ## 1.0.30
50
+
51
+ ### Patch Changes
52
+
53
+ - ai@7.0.30
54
+
55
+ ## 1.0.29
56
+
57
+ ### Patch Changes
58
+
59
+ - ai@7.0.29
60
+
61
+ ## 1.0.28
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [0bc8d4f]
66
+ - ai@7.0.28
67
+
68
+ ## 1.0.27
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [ac01b79]
73
+ - Updated dependencies [31c7be8]
74
+ - Updated dependencies [2696562]
75
+ - ai@7.0.27
76
+ - @ai-sdk/provider-utils@5.0.10
77
+
78
+ ## 1.0.26
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [27d294d]
83
+ - ai@7.0.26
84
+
85
+ ## 1.0.25
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [4be62c1]
90
+ - Updated dependencies [7805e4a]
91
+ - Updated dependencies [7805e4a]
92
+ - Updated dependencies [f8e82fd]
93
+ - Updated dependencies [cd12954]
94
+ - @ai-sdk/provider-utils@5.0.9
95
+ - ai@7.0.25
96
+
97
+ ## 1.0.24
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [e193290]
102
+ - Updated dependencies [e193290]
103
+ - @ai-sdk/provider-utils@5.0.8
104
+ - ai@7.0.24
105
+
106
+ ## 1.0.23
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [930f949]
111
+ - ai@7.0.23
112
+
113
+ ## 1.0.22
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [8f89c25]
118
+ - ai@7.0.22
119
+
120
+ ## 1.0.21
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [308a519]
125
+ - ai@7.0.21
126
+
127
+ ## 1.0.20
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [b9ac19f]
132
+ - Updated dependencies [a4186d6]
133
+ - ai@7.0.20
134
+
135
+ ## 1.0.19
136
+
137
+ ### Patch Changes
138
+
139
+ - 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.
140
+
141
+ - `@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.
142
+ - `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.
143
+
144
+ - 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.
145
+ - Updated dependencies [be7f05a]
146
+ - Updated dependencies [ee55a07]
147
+ - Updated dependencies [aad737d]
148
+ - Updated dependencies [0f93c57]
149
+ - ai@7.0.19
150
+ - @ai-sdk/provider@4.0.3
151
+ - @ai-sdk/provider-utils@5.0.7
152
+
153
+ ## 1.0.18
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies [ac306ed]
158
+ - @ai-sdk/provider-utils@5.0.6
159
+ - ai@7.0.18
160
+
161
+ ## 1.0.17
162
+
163
+ ### Patch Changes
164
+
165
+ - ai@7.0.17
166
+
167
+ ## 1.0.16
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies [a8f9b6d]
172
+ - ai@7.0.16
173
+
174
+ ## 1.0.15
175
+
176
+ ### Patch Changes
177
+
178
+ - ai@7.0.15
179
+
180
+ ## 1.0.14
181
+
182
+ ### Patch Changes
183
+
184
+ - 5c5c0f5: Add experimental streaming transcription support for transcription models, including OpenAI `gpt-realtime-whisper` and xAI WebSocket STT.
185
+ - Updated dependencies [5c5c0f5]
186
+ - ai@7.0.14
187
+ - @ai-sdk/provider@4.0.2
188
+ - @ai-sdk/provider-utils@5.0.5
189
+
190
+ ## 1.0.13
191
+
192
+ ### Patch Changes
193
+
194
+ - ai@7.0.13
195
+
196
+ ## 1.0.12
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies [ecfeb6f]
201
+ - Updated dependencies [a193137]
202
+ - Updated dependencies [c6f5e62]
203
+ - ai@7.0.12
204
+ - @ai-sdk/provider-utils@5.0.4
205
+
206
+ ## 1.0.11
207
+
208
+ ### Patch Changes
209
+
210
+ - Updated dependencies [0a87626]
211
+ - ai@7.0.11
212
+
213
+ ## 1.0.10
214
+
215
+ ### Patch Changes
216
+
217
+ - Updated dependencies [8c616f0]
218
+ - ai@7.0.10
219
+ - @ai-sdk/provider-utils@5.0.3
220
+
221
+ ## 1.0.9
222
+
223
+ ### Patch Changes
224
+
225
+ - ai@7.0.9
226
+
227
+ ## 1.0.8
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [0274f34]
232
+ - @ai-sdk/provider@4.0.1
233
+ - ai@7.0.8
234
+ - @ai-sdk/provider-utils@5.0.2
235
+
236
+ ## 1.0.7
237
+
238
+ ### Patch Changes
239
+
240
+ - Updated dependencies [d598481]
241
+ - ai@7.0.7
242
+
243
+ ## 1.0.6
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [989402d]
248
+ - ai@7.0.6
249
+
250
+ ## 1.0.5
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [a2750db]
255
+ - ai@7.0.5
256
+
257
+ ## 1.0.4
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [6a436e3]
262
+ - @ai-sdk/provider-utils@5.0.1
263
+ - ai@7.0.4
264
+
265
+ ## 1.0.3
266
+
267
+ ### Patch Changes
268
+
269
+ - ai@7.0.3
270
+
271
+ ## 1.0.2
272
+
273
+ ### Patch Changes
274
+
275
+ - ai@7.0.2
276
+
277
+ ## 1.0.1
278
+
279
+ ### Patch Changes
280
+
281
+ - ai@7.0.1
282
+
283
+ ## 1.0.0
284
+
285
+ ### Major Changes
286
+
287
+ - a94c258: Introduce `@ai-sdk/policy-opa`, an Open Policy Agent adapter for the
288
+ `toolApproval` callback on `generateText` / `streamText` / `ToolLoopAgent`.
289
+
290
+ Everything is exported from the package root. The engine-neutral core is a
291
+ `PolicyClient` interface, `shadow()` for safe policy rollout with
292
+ fire-and-forget telemetry, and `wrapMcpTools()` for making approval
293
+ configuration total over a discovered tool surface. The OPA layer ships
294
+ `opaPolicy` / `optionalOpaPolicy` (Rego-as-code authorization),
295
+ `wasmPolicyClient` and `httpPolicyClient` backends (lazy-loaded optional peer
296
+ deps), `opaCapabilityMiddleware` for fail-closed model-level tool filtering,
297
+ and `normalizeOpaDecision` for users who call OPA themselves.
298
+
299
+ Sits entirely on top of the public SDK surface, with no changes to `ai`,
300
+ `@ai-sdk/provider`, or `@ai-sdk/provider-utils`. Transitive enforcement
301
+ (coarse dispatchers like `bash` / `http.request` / MCP proxies) is handled
302
+ inside the user's `toolApproval` by parsing the dispatcher input and routing
303
+ to the same Rego rule that gates the direct tool.
304
+
305
+ ### Patch Changes
306
+
307
+ - 9a1b0ea: Initial release
308
+ - b8396f0: trigger initial beta release
309
+
310
+ ## 1.0.0-beta.24
311
+
312
+ ### Patch Changes
313
+
314
+ - ai@7.0.0-beta.187
315
+
316
+ ## 1.0.0-beta.23
317
+
318
+ ### Patch Changes
319
+
320
+ - ai@7.0.0-beta.186
321
+
322
+ ## 1.0.0-beta.22
323
+
324
+ ### Patch Changes
325
+
326
+ - Updated dependencies [75763b0]
327
+ - ai@7.0.0-beta.185
328
+
329
+ ## 1.0.0-beta.21
330
+
331
+ ### Patch Changes
332
+
333
+ - Updated dependencies [0416e3e]
334
+ - @ai-sdk/provider@4.0.0-beta.20
335
+ - ai@7.0.0-beta.184
336
+ - @ai-sdk/provider-utils@5.0.0-beta.50
337
+
338
+ ## 1.0.0-beta.20
339
+
340
+ ### Patch Changes
341
+
342
+ - ai@7.0.0-beta.183
343
+
344
+ ## 1.0.0-beta.19
345
+
346
+ ### Patch Changes
347
+
348
+ - Updated dependencies [cc6ab90]
349
+ - ai@7.0.0-beta.182
350
+
351
+ ## 1.0.0-beta.18
352
+
353
+ ### Patch Changes
354
+
355
+ - Updated dependencies [6a2caf9]
356
+ - ai@7.0.0-beta.181
357
+
358
+ ## 1.0.0-beta.17
359
+
360
+ ### Patch Changes
361
+
362
+ - Updated dependencies [81a284b]
363
+ - ai@7.0.0-beta.180
364
+
365
+ ## 1.0.0-beta.16
366
+
367
+ ### Patch Changes
368
+
369
+ - ai@7.0.0-beta.179
370
+
371
+ ## 1.0.0-beta.15
372
+
373
+ ### Patch Changes
374
+
375
+ - Updated dependencies [b097c52]
376
+ - ai@7.0.0-beta.178
377
+
378
+ ## 1.0.0-beta.14
379
+
380
+ ### Patch Changes
381
+
382
+ - b8396f0: trigger initial beta release
383
+ - Updated dependencies [b8396f0]
384
+ - @ai-sdk/provider-utils@5.0.0-beta.49
385
+ - @ai-sdk/provider@4.0.0-beta.19
386
+ - ai@7.0.0-beta.177
387
+
388
+ ## 1.0.0-canary.13
389
+
390
+ ### Patch Changes
391
+
392
+ - ai@7.0.0-canary.176
393
+
394
+ ## 1.0.0-canary.12
395
+
396
+ ### Patch Changes
397
+
398
+ - Updated dependencies [6ec57f5]
399
+ - ai@7.0.0-canary.175
400
+
401
+ ## 1.0.0-canary.11
402
+
403
+ ### Patch Changes
404
+
405
+ - ai@7.0.0-canary.174
406
+
407
+ ## 1.0.0-canary.10
408
+
409
+ ### Patch Changes
410
+
411
+ - ai@7.0.0-canary.173
412
+
413
+ ## 1.0.0-canary.9
414
+
415
+ ### Patch Changes
416
+
417
+ - Updated dependencies [aeda373]
418
+ - Updated dependencies [25a64f8]
419
+ - Updated dependencies [375fdd7]
420
+ - Updated dependencies [f18b08f]
421
+ - Updated dependencies [b4507d5]
422
+ - @ai-sdk/provider-utils@5.0.0-canary.48
423
+ - ai@7.0.0-canary.172
424
+
425
+ ## 1.0.0-canary.8
426
+
427
+ ### Patch Changes
428
+
429
+ - Updated dependencies [89ad56f]
430
+ - Updated dependencies [f9a496f]
431
+ - Updated dependencies [3295831]
432
+ - ai@7.0.0-canary.171
433
+
434
+ ## 1.0.0-canary.7
435
+
436
+ ### Patch Changes
437
+
438
+ - Updated dependencies [bae5e2b]
439
+ - Updated dependencies [69d7128]
440
+ - ai@7.0.0-canary.170
441
+ - @ai-sdk/provider-utils@5.0.0-canary.47
442
+
443
+ ## 1.0.0-canary.6
444
+
445
+ ### Patch Changes
446
+
447
+ - Updated dependencies [a5018ab]
448
+ - Updated dependencies [21d3d60]
449
+ - Updated dependencies [426dbbb]
450
+ - Updated dependencies [7fd3360]
451
+ - ai@7.0.0-canary.169
452
+
453
+ ## 1.0.0-canary.5
454
+
455
+ ### Patch Changes
456
+
457
+ - Updated dependencies [1e4b350]
458
+ - ai@7.0.0-canary.168
459
+
460
+ ## 1.0.0-canary.4
461
+
462
+ ### Patch Changes
463
+
464
+ - Updated dependencies [4757690]
465
+ - Updated dependencies [eeefc3f]
466
+ - Updated dependencies [b79b6a8]
467
+ - ai@7.0.0-canary.167
468
+
469
+ ## 1.0.0-canary.3
470
+
471
+ ### Patch Changes
472
+
473
+ - Updated dependencies [19736ee]
474
+ - Updated dependencies [d66ae02]
475
+ - Updated dependencies [e4182bd]
476
+ - ai@7.0.0-canary.166
477
+
478
+ ## 1.0.0-canary.2
479
+
480
+ ### Patch Changes
481
+
482
+ - Updated dependencies [ce769dd]
483
+ - @ai-sdk/provider@4.0.0-canary.18
484
+ - ai@7.0.0-canary.165
485
+ - @ai-sdk/provider-utils@5.0.0-canary.46
486
+
487
+ ## 1.0.0-canary.1
488
+
489
+ ### Patch Changes
490
+
491
+ - 9a1b0ea: Initial release
492
+ - ai@7.0.0-canary.164
493
+
494
+ ## 1.0.0-canary.0
495
+
496
+ ### Major Changes
497
+
498
+ - a94c258: Introduce `@ai-sdk/policy-opa`, an Open Policy Agent adapter for the
499
+ `toolApproval` callback on `generateText` / `streamText` / `ToolLoopAgent`.
500
+
501
+ Everything is exported from the package root. The engine-neutral core is a
502
+ `PolicyClient` interface, `shadow()` for safe policy rollout with
503
+ fire-and-forget telemetry, and `wrapMcpTools()` for making approval
504
+ configuration total over a discovered tool surface. The OPA layer ships
505
+ `opaPolicy` / `optionalOpaPolicy` (Rego-as-code authorization),
506
+ `wasmPolicyClient` and `httpPolicyClient` backends (lazy-loaded optional peer
507
+ deps), `opaCapabilityMiddleware` for fail-closed model-level tool filtering,
508
+ and `normalizeOpaDecision` for users who call OPA themselves.
509
+
510
+ Sits entirely on top of the public SDK surface, with no changes to `ai`,
511
+ `@ai-sdk/provider`, or `@ai-sdk/provider-utils`. Transitive enforcement
512
+ (coarse dispatchers like `bash` / `http.request` / MCP proxies) is handled
513
+ inside the user's `toolApproval` by parsing the dispatcher input and routing
514
+ to the same Rego rule that gates the direct tool.
515
+
516
+ ### Patch Changes
517
+
518
+ - Updated dependencies [ee798eb]
519
+ - Updated dependencies [daf6637]
520
+ - Updated dependencies [c907622]
521
+ - @ai-sdk/provider-utils@5.0.0-canary.45
522
+ - 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.