zuplo 7.6.6 → 7.6.7
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.
|
@@ -171,8 +171,9 @@ options exactly.
|
|
|
171
171
|
|
|
172
172
|
## Configure credentials
|
|
173
173
|
|
|
174
|
-
If a policy needs a credential—say it calls an external moderation API—
|
|
175
|
-
|
|
174
|
+
If a policy needs a credential—say it calls an external moderation API—store it
|
|
175
|
+
as an [environment variable](../articles/environment-variables.mdx) and
|
|
176
|
+
reference it with `$env(...)` in the declaration's options:
|
|
176
177
|
|
|
177
178
|
```json title="config/policies.json"
|
|
178
179
|
{
|
|
@@ -182,14 +183,17 @@ the declaration's options, and let chain entries inherit it:
|
|
|
182
183
|
"export": "default",
|
|
183
184
|
"module": "$import(./modules/my-moderation-policy)",
|
|
184
185
|
"options": {
|
|
185
|
-
"apiKey": "
|
|
186
|
+
"apiKey": "$env(MODERATION_API_KEY)"
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
```
|
|
190
191
|
|
|
191
192
|
Leave the chain entry's options out so it inherits the declaration's values—an
|
|
192
|
-
entry that sets its own options replaces them completely.
|
|
193
|
+
entry that sets its own options replaces them completely. An entry that does set
|
|
194
|
+
its own options can use `$env(...)` references too, so one declared policy can
|
|
195
|
+
read a different credential or setting per app. See
|
|
196
|
+
[Options and secrets](./policy-chains.mdx#options-and-secrets).
|
|
193
197
|
|
|
194
198
|
## Beyond filtering
|
|
195
199
|
|
|
@@ -90,8 +90,27 @@ an entry with empty options replaces the declared options with an empty object,
|
|
|
90
90
|
which breaks a policy that has required settings. Omit options entirely to
|
|
91
91
|
inherit.
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
Entry options may reference
|
|
94
|
+
[environment variables](../articles/environment-variables.mdx) with
|
|
95
|
+
`$env(VAR_NAME)`, exactly as in `policies.json`. The gateway resolves each
|
|
96
|
+
reference when the chain runs, so a per-app entry can carry its own
|
|
97
|
+
environment-backed value:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"name": "my-moderation-policy",
|
|
102
|
+
"options": {
|
|
103
|
+
"apiKey": "$env(MODERATION_API_KEY)",
|
|
104
|
+
"threshold": 0.8
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A reference to an unset variable fails the request with a configuration error
|
|
110
|
+
naming the variable—it never silently resolves to an empty string.
|
|
111
|
+
|
|
112
|
+
Alternatively, keep credentials in the declaration's options and let entries
|
|
113
|
+
inherit them, so the gateway's repository—not app configuration—holds them. See
|
|
95
114
|
[Configure credentials](./custom-policies.mdx#configure-credentials).
|
|
96
115
|
|
|
97
116
|
## Recommended order
|
|
@@ -535,9 +535,33 @@ From a chain policy you can:
|
|
|
535
535
|
|
|
536
536
|
## Store secrets safely
|
|
537
537
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
538
|
+
Application chain options can reference project environment variables. Use a
|
|
539
|
+
standalone reference when the complete option value comes from one variable, or
|
|
540
|
+
embed one or more references in a larger string:
|
|
541
|
+
|
|
542
|
+
```json
|
|
543
|
+
{
|
|
544
|
+
"inboundPolicyChain": [
|
|
545
|
+
{
|
|
546
|
+
"name": "my-ai-guardrail",
|
|
547
|
+
"options": {
|
|
548
|
+
"apiKey": "$env(MY_GUARDRAIL_API_KEY)",
|
|
549
|
+
"authorization": "Bearer $env(MY_GUARDRAIL_API_KEY)"
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
The executor resolves `$env(NAME)` references when it instantiates an enabled
|
|
557
|
+
chain entry. Resolution visits string values recursively through nested objects
|
|
558
|
+
and arrays. Object keys remain literal. If a referenced variable is missing or
|
|
559
|
+
restricted, the executor rejects the configuration with an error that identifies
|
|
560
|
+
the variable and the chain entry; it never substitutes an empty string.
|
|
561
|
+
|
|
562
|
+
To share the same environment-backed options across applications, keep them in
|
|
563
|
+
the pre-declared policy's `handler.options`, then omit `options` from the
|
|
564
|
+
application chain entry to inherit them:
|
|
541
565
|
|
|
542
566
|
```json
|
|
543
567
|
{
|
|
@@ -563,9 +587,9 @@ to inherit them:
|
|
|
563
587
|
}
|
|
564
588
|
```
|
|
565
589
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
590
|
+
Declared `handler.options` use the normal build-time environment resolution.
|
|
591
|
+
Application entry options are resolved at runtime and replace the declaration's
|
|
592
|
+
complete options object; the two objects are not merged.
|
|
569
593
|
|
|
570
594
|
## Chain entry reference
|
|
571
595
|
|
|
@@ -578,8 +602,8 @@ Every chain entry supports:
|
|
|
578
602
|
without running it. Omitted or `true` entries run normally.
|
|
579
603
|
|
|
580
604
|
Disabled entries are still validated. They must be well-formed, name a declared
|
|
581
|
-
policy,
|
|
582
|
-
|
|
605
|
+
policy, and cannot select the configuration loader or executor. Their options
|
|
606
|
+
are not instantiated, so their environment references are not resolved.
|
|
583
607
|
|
|
584
608
|
The executor permits repeated entries and cannot infer the behavior of custom or
|
|
585
609
|
wrapper policies. Configuration authors are responsible for avoiding repeated
|
|
@@ -606,7 +630,9 @@ Before deploying:
|
|
|
606
630
|
1. Declare every selectable policy in `config/policies.json`.
|
|
607
631
|
2. Configure application and team policy templates with the policies each app
|
|
608
632
|
may edit or remove.
|
|
609
|
-
3. Put environment-backed values in declared policy options
|
|
633
|
+
3. Put shared environment-backed values in declared policy options, or use
|
|
634
|
+
`$env(...)` in application entry option values when each application needs
|
|
635
|
+
its own complete options object.
|
|
610
636
|
4. Place the configuration loader before the executor on every AI Gateway route
|
|
611
637
|
(or the executor alone when you prefer the combined path). Add AI Gateway
|
|
612
638
|
Authentication to an application's chain for that app only, or before the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zuplo",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The official Zuplo CLI for local development and platform management",
|
|
6
6
|
"homepage": "https://zuplo.com/docs/cli/overview",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"zuplo": "zuplo.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@zuplo/cli": "7.6.
|
|
36
|
-
"@zuplo/core": "7.6.
|
|
37
|
-
"@zuplo/runtime": "7.6.
|
|
38
|
-
"@zuplo/test": "7.6.
|
|
35
|
+
"@zuplo/cli": "7.6.7",
|
|
36
|
+
"@zuplo/core": "7.6.7",
|
|
37
|
+
"@zuplo/runtime": "7.6.7",
|
|
38
|
+
"@zuplo/test": "7.6.7"
|
|
39
39
|
}
|
|
40
40
|
}
|